15 ***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function n(t){return"function"==typeof t}var r=!1,s={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack;r=t},get useDeprecatedSynchronousErrorHandling(){return r}};function o(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(s.useDeprecatedSynchronousErrorHandling)throw t;o(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function h(t){return null!==t&&"object"==typeof t}var l=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),u=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var i=this,r=i._parentOrParents,s=i._ctorUnsubscribe,o=i._unsubscribe,a=i._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof t)r.remove(this);else if(null!==r)for(var u=0;u<r.length;++u){r[u].remove(this)}if(n(o)){s&&(this._unsubscribe=void 0);try{o.call(this)}catch(t){e=t instanceof l?d(t.errors):[t]}}if(c(a)){u=-1;for(var p=a.length;++u<p;){var f=a[u];if(h(f))try{f.unsubscribe()}catch(t){e=e||[],t instanceof l?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new l(e)}},t.prototype.add=function(e){var i=e;if(!e)return t.EMPTY;switch(typeof e){case"function":i=new t(e);case"object":if(i===this||i.closed||"function"!=typeof i.unsubscribe)return i;if(this.closed)return i.unsubscribe(),i;if(!(i instanceof t)){var n=i;(i=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var r=i._parentOrParents;if(null===r)i._parentOrParents=this;else if(r instanceof t){if(r===this)return i;i._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return i;r.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[i]:s.push(i),i},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var i=e.indexOf(t);-1!==i&&e.splice(i,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof l?e.errors:e)}),[])}var p=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),f=function(t){function e(i,n,r){var s=t.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=a;break;case 1:if(!i){s.destination=a;break}if("object"==typeof i){i instanceof e?(s.syncErrorThrowable=i.syncErrorThrowable,s.destination=i,i.add(s)):(s.syncErrorThrowable=!0,s.destination=new m(s,i));break}default:s.syncErrorThrowable=!0,s.destination=new m(s,i,n,r)}return s}return i(e,t),e.prototype[p]=function(){return this},e.create=function(t,i,n){var r=new e(t,i,n);return r.syncErrorThrowable=!1,r},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(u),m=function(t){function e(e,i,r,s){var o,c=t.call(this)||this;c._parentSubscriber=e;var h=c;return n(i)?o=i:i&&(o=i.next,r=i.error,s=i.complete,i!==a&&(n((h=Object.create(i)).unsubscribe)&&c.add(h.unsubscribe.bind(h)),h.unsubscribe=c.unsubscribe.bind(c))),c._context=h,c._next=o,c._error=r,c._complete=s,c}return i(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,i=s.useDeprecatedSynchronousErrorHandling;if(this._error)i&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)i?(e.syncErrorValue=t,e.syncErrorThrown=!0):o(t),this.unsubscribe();else{if(this.unsubscribe(),i)throw t;o(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var i=function(){return t._complete.call(t._context)};s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,i),this.unsubscribe()):(this.__tryOrUnsub(i),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),s.useDeprecatedSynchronousErrorHandling)throw t;o(t)}},e.prototype.__tryOrSetError=function(t,e,i){if(!s.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,i)}catch(e){return s.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(o(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(f);var g=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function _(t){return t}function v(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return y(t)}function y(t){return 0===t.length?_:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var b=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var i=new t;return i.source=this,i.operator=e,i},t.prototype.subscribe=function(t,e,i){var n=this.operator,r=function(t,e,i){if(t){if(t instanceof f)return t;if(t[p])return t[p]()}return t||e||i?new f(t,e,i):new f(a)}(t,e,i);if(n?r.add(n.call(r,this.source)):r.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!r.syncErrorThrowable?this._subscribe(r):this._trySubscribe(r)),s.useDeprecatedSynchronousErrorHandling&&r.syncErrorThrowable&&(r.syncErrorThrowable=!1,r.syncErrorThrown))throw r.syncErrorValue;return r},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){s.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),!function(t){for(;t;){var e=t,i=e.closed,n=e.destination,r=e.isStopped;if(i||r)return!1;t=n&&n instanceof f?n:null}return!0}(t)?console.warn(e):t.error(e)}},t.prototype.forEach=function(t,e){var i=this;return new(e=x(e))((function(e,n){var r;r=i.subscribe((function(e){try{t(e)}catch(t){n(t),r&&r.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[g]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:y(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=x(t))((function(t,i){var n;e.subscribe((function(t){return n=t}),(function(t){return i(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function x(t){if(t||(t=Promise),!t)throw new Error("no Promise impl found");return t}var w=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),S=function(t){function e(e,i){var n=t.call(this)||this;return n.subject=e,n.subscriber=i,n.closed=!1,n}return i(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var i=e.indexOf(this.subscriber);-1!==i&&e.splice(i,1)}}},e}(u),M=function(t){function e(e){var i=t.call(this,e)||this;return i.destination=e,i}return i(e,t),e}(f),T=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return i(e,t),e.prototype[p]=function(){return new M(this)},e.prototype.lift=function(t){var e=new C(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new w;if(!this.isStopped)for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].next(t)},e.prototype.error=function(t){if(this.closed)throw new w;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new w;this.isStopped=!0;for(var t=this.observers,e=t.length,i=t.slice(),n=0;n<e;n++)i[n].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new w;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new w;return this.hasError?(t.error(this.thrownError),u.EMPTY):this.isStopped?(t.complete(),u.EMPTY):(this.observers.push(t),new S(this,t))},e.prototype.asObservable=function(){var t=new b;return t.source=this,t},e.create=function(t,e){return new C(t,e)},e}(b),C=function(t){function e(e,i){var n=t.call(this)||this;return n.destination=e,n.source=i,n}return i(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):u.EMPTY},e}(T);function E(){return function(t){return t.lift(new I(t))}}var I=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var i=this.connectable;i._refCount++;var n=new A(t,i),r=e.subscribe(n);return n.closed||(n.connection=i.connect()),r},t}(),A=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return i(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var i=this.connection,n=t._connection;this.connection=null,!n||i&&n!==i||n.unsubscribe()}}else this.connection=null},e}(f),P=function(t){function e(e,i){var n=t.call(this)||this;return n.source=e,n.subjectFactory=i,n._refCount=0,n._isComplete=!1,n}return i(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new u).add(this.source.subscribe(new L(this.getSubject(),this))),t.closed&&(this._connection=null,t=u.EMPTY)),t},e.prototype.refCount=function(){return E()(this)},e}(b),R=function(){var t=P.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),L=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return i(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(M),O=function(t){function e(e){var i=t.call(this)||this;return i._value=e,i}return i(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var i=t.prototype._subscribe.call(this,e);return i&&!i.closed&&e.next(this._value),i},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new w;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(T),N=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n.pending=!1,n}return i(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var i=this.id,n=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(n,i,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,i){return void 0===i&&(i=0),setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,e,i){if(void 0===i&&(i=0),null!==i&&this.delay===i&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,e);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var i=!1,n=void 0;try{this.work(t)}catch(t){i=!0,n=!!t&&t||new Error(t)}if(i)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,i=e.actions,n=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&i.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,i){return t.call(this)||this}return i(e,t),e.prototype.schedule=function(t,e){return this},e}(u)),D=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return i(e,t),e.prototype.schedule=function(e,i){return void 0===i&&(i=0),i>0?t.prototype.schedule.call(this,e,i):(this.delay=i,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,i){return i>0||this.closed?t.prototype.execute.call(this,e,i):this._execute(e,i)},e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,i,n):e.flush(this)},e}(N),$=function(){function t(e,i){void 0===i&&(i=t.now),this.SchedulerAction=e,this.now=i}return t.prototype.schedule=function(t,e,i){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(i,e)},t.now=function(){return Date.now()},t}(),k=function(t){function e(i,n){void 0===n&&(n=$.now);var r=t.call(this,i,(function(){return e.delegate&&e.delegate!==r?e.delegate.now():n()}))||this;return r.actions=[],r.active=!1,r.scheduled=void 0,r}return i(e,t),e.prototype.schedule=function(i,n,r){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(i,n,r):t.prototype.schedule.call(this,i,n,r)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var i;this.active=!0;do{if(i=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,i){for(;t=e.shift();)t.unsubscribe();throw i}}},e}($),z=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(k))(D),F=new b((function(t){return t.complete()}));function B(t){return t?function(t){return new b((function(e){return t.schedule((function(){return e.complete()}))}))}(t):F}function j(t){return t&&"function"==typeof t.schedule}var H=function(t){return function(e){for(var i=0,n=t.length;i<n&&!e.closed;i++)e.next(t[i]);e.complete()}};function U(t,e){return new b((function(i){var n=new u,r=0;return n.add(e.schedule((function(){r!==t.length?(i.next(t[r++]),i.closed||n.add(this.schedule())):i.complete()}))),n}))}function V(t,e){return e?U(t,e):new b(H(t))}function G(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return j(i)?(t.pop(),U(t,i)):V(t)}function q(t,e){return new b(e?function(i){return e.schedule(W,0,{error:t,subscriber:i})}:function(e){return e.error(t)})}function W(t){var e=t.error;t.subscriber.error(e)}var X=function(){function t(t,e,i){this.kind=t,this.value=e,this.error=i,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,i){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return i&&i()}},t.prototype.accept=function(t,e,i){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,i)},t.prototype.toObservable=function(){switch(this.kind){case"N":return G(this.value);case"E":return q(this.error);case"C":return B()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}(),Y=function(t){function e(e,i,n){void 0===n&&(n=0);var r=t.call(this,e)||this;return r.scheduler=i,r.delay=n,r}return i(e,t),e.dispatch=function(t){var e=t.notification,i=t.destination;e.observe(i),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new Z(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(X.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(X.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(X.createComplete()),this.unsubscribe()},e}(f),Z=function(){return function(t,e){this.notification=t,this.destination=e}}(),J=function(t){function e(e,i,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===i&&(i=Number.POSITIVE_INFINITY);var r=t.call(this)||this;return r.scheduler=n,r._events=[],r._infiniteTimeWindow=!1,r._bufferSize=e<1?1:e,r._windowTime=i<1?1:i,i===Number.POSITIVE_INFINITY?(r._infiniteTimeWindow=!0,r.next=r.nextInfiniteTimeWindow):r.next=r.nextTimeWindow,r}return i(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var i=this._events;i.push(e),i.length>this._bufferSize&&i.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new K(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,i=this._infiniteTimeWindow,n=i?this._events:this._trimBufferThenGetEvents(),r=this.scheduler,s=n.length;if(this.closed)throw new w;if(this.isStopped||this.hasError?e=u.EMPTY:(this.observers.push(t),e=new S(this,t)),r&&t.add(t=new Y(t,r)),i)for(var o=0;o<s&&!t.closed;o++)t.next(n[o]);else for(o=0;o<s&&!t.closed;o++)t.next(n[o].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||z).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,i=this._windowTime,n=this._events,r=n.length,s=0;s<r&&!(t-n[s].time<i);)s++;return r>e&&(s=Math.max(s,r-e)),s>0&&n.splice(0,s),n},e}(T),K=function(){return function(t,e){this.time=t,this.value=e}}(),Q=new k(N);function tt(){}var et=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),it=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}(),nt=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}();function rt(t,e){return function(i){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new st(t,e))}}var st=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new ot(t,this.project,this.thisArg))},t}(),ot=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.project=i,r.count=0,r.thisArg=n||r,r}return i(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(f),at=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(f),ct=function(t){function e(e,i,n){var r=t.call(this)||this;return r.parent=e,r.outerValue=i,r.outerIndex=n,r.index=0,r}return i(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(f);function ht(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var lt=ht(),ut=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function dt(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var pt=function(t){if(t&&"function"==typeof t[g])return n=t,function(t){var e=n[g]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(ut(t))return H(t);if(dt(t))return i=t,function(t){return i.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,o),t};if(t&&"function"==typeof t[lt])return e=t,function(t){for(var i=e[lt]();;){var n=void 0;try{n=i.next()}catch(e){return t.error(e),t}if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof i.return&&t.add((function(){i.return&&i.return()})),t};var e,i,n,r=h(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+r+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};function ft(t,e,i,n,r){if(void 0===r&&(r=new ct(t,i,n)),!r.closed)return e instanceof b?e.subscribe(r):pt(e)(r)}var mt={};function gt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=void 0,n=void 0;return j(t[t.length-1])&&(n=t.pop()),"function"==typeof t[t.length-1]&&(i=t.pop()),1===t.length&&c(t[0])&&(t=t[0]),V(t,n).lift(new _t(i))}var _t=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new vt(t,this.resultSelector))},t}(),vt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.resultSelector=i,n.active=0,n.values=[],n.observables=[],n}return i(e,t),e.prototype._next=function(t){this.values.push(mt),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var i=0;i<e;i++){var n=t[i];this.add(ft(this,n,void 0,i))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,i){var n=this.values,r=n[i],s=this.toRespond?r===mt?--this.toRespond:this.toRespond:0;n[i]=e,0===s&&(this.resultSelector?this._tryResultSelector(n):this.destination.next(n.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(at);function yt(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[g]}(t))return function(t,e){return new b((function(i){var n=new u;return n.add(e.schedule((function(){var r=t[g]();n.add(r.subscribe({next:function(t){n.add(e.schedule((function(){return i.next(t)})))},error:function(t){n.add(e.schedule((function(){return i.error(t)})))},complete:function(){n.add(e.schedule((function(){return i.complete()})))}}))}))),n}))}(t,e);if(dt(t))return function(t,e){return new b((function(i){var n=new u;return n.add(e.schedule((function(){return t.then((function(t){n.add(e.schedule((function(){i.next(t),n.add(e.schedule((function(){return i.complete()})))})))}),(function(t){n.add(e.schedule((function(){return i.error(t)})))}))}))),n}))}(t,e);if(ut(t))return U(t,e);if(function(t){return t&&"function"==typeof t[lt]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new b((function(i){var n,r=new u;return r.add((function(){n&&"function"==typeof n.return&&n.return()})),r.add(e.schedule((function(){n=t[lt](),r.add(e.schedule((function(){if(!i.closed){var t,e;try{var r=n.next();t=r.value,e=r.done}catch(t){return void i.error(t)}e?i.complete():(i.next(t),this.schedule())}})))}))),r}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}function bt(t,e){return e?yt(t,e):t instanceof b?t:new b(pt(t))}var xt=function(t){function e(e){var i=t.call(this)||this;return i.parent=e,i}return i(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(f),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(f);function St(t,e){if(!e.closed)return t instanceof b?t.subscribe(e):pt(t)(e)}function Mt(t,e,i){return void 0===i&&(i=Number.POSITIVE_INFINITY),"function"==typeof e?function(n){return n.pipe(Mt((function(i,n){return bt(t(i,n)).pipe(rt((function(t,r){return e(i,t,n,r)})))}),i))}:("number"==typeof e&&(i=e),function(e){return e.lift(new Tt(t,i))})}var Tt=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new Ct(t,this.project,this.concurrent))},t}(),Ct=function(t){function e(e,i,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e)||this;return r.project=i,r.concurrent=n,r.hasCompleted=!1,r.buffer=[],r.active=0,r.index=0,r}return i(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new xt(this),i=this.destination;i.add(e);var n=St(t,e);n!==e&&i.add(n)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(wt);function Et(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),Mt(_,t)}function It(){return Et(1)}function At(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return It()(G.apply(void 0,t))}function Pt(t,e,i,r){return n(i)&&(r=i,i=void 0),r?Pt(t,e,i).pipe(rt((function(t){return c(t)?r.apply(void 0,t):r(t)}))):new b((function(n){Rt(t,e,(function(t){arguments.length>1?n.next(Array.prototype.slice.call(arguments)):n.next(t)}),n,i)}))}function Rt(t,e,i,n,r){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,i,r),s=function(){return o.removeEventListener(e,i,r)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,i),s=function(){return a.off(e,i)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var c=t;t.addListener(e,i),s=function(){return c.removeListener(e,i)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var h=0,l=t.length;h<l;h++)Rt(t[h],e,i,n,r)}n.add(s)}function Lt(t){return!c(t)&&t-parseFloat(t)+1>=0}function Ot(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=Number.POSITIVE_INFINITY,n=null,r=t[t.length-1];return j(r)?(n=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(i=t.pop())):"number"==typeof r&&(i=t.pop()),null===n&&1===t.length&&t[0]instanceof b?t[0]:Et(i)(V(t,n))}function Nt(t,e){return function(i){return i.lift(new Dt(t,e))}}var Dt=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new $t(t,this.predicate,this.thisArg))},t}(),$t=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.thisArg=n,r.count=0,r}return i(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(f);function kt(t,e,i){void 0===t&&(t=0);var n=-1;return Lt(e)?n=Number(e)<1?1:Number(e):j(e)&&(i=e),j(i)||(i=Q),new b((function(e){var r=Lt(t)?t:+t-i.now();return i.schedule(zt,r,{index:0,period:n,subscriber:e})}))}function zt(t){var e=t.index,i=t.period,n=t.subscriber;if(n.next(e),!n.closed){if(-1===i)return n.complete();t.index=e+1,this.schedule(t,i)}}function Ft(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return"function"==typeof i&&t.pop(),V(t,void 0).lift(new Bt(i))}var Bt=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new jt(t,this.resultSelector))},t}(),jt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.resultSelector=i,r.iterators=[],r.active=0,r.resultSelector="function"==typeof i?i:void 0,r}return i(e,t),e.prototype._next=function(t){var e=this.iterators;c(t)?e.push(new Ut(t)):"function"==typeof t[lt]?e.push(new Ht(t[lt]())):e.push(new Vt(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var i=0;i<e;i++){var n=t[i];if(n.stillUnsubscribed)this.destination.add(n.subscribe());else this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,i=this.destination,n=0;n<e;n++){if("function"==typeof(o=t[n]).hasValue&&!o.hasValue())return}var r=!1,s=[];for(n=0;n<e;n++){var o,a=(o=t[n]).next();if(o.hasCompleted()&&(r=!0),a.done)return void i.complete();s.push(a.value)}this.resultSelector?this._tryresultSelector(s):i.next(s),r&&i.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(f),Ht=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return Boolean(t&&t.done)},t}(),Ut=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[lt]=function(){return this},t.prototype.next=function(t){var e=this.index++,i=this.array;return e<this.length?{value:i[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),Vt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.parent=i,r.observable=n,r.stillUnsubscribed=!0,r.buffer=[],r.isComplete=!1,r}return i(e,t),e.prototype[lt]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return St(this.observable,new xt(this))},e}(wt);var Gt=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new qt(t,this.durationSelector))},t}(),qt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.durationSelector=i,n.hasValue=!1,n}return i(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var i=St(e,new xt(this));!i||i.closed?this.clearThrottle():this.add(this.throttled=i)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,i=t.hasValue,n=t.throttled;n&&(this.remove(n),this.throttled=void 0,n.unsubscribe()),i&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(wt);function Wt(t,e){return void 0===e&&(e=Q),i=function(){return kt(t,e)},function(t){return t.lift(new Gt(i))};var i}function Xt(t,e){return void 0===e&&(e=null),function(i){return i.lift(new Yt(t,e))}}var Yt=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?Jt:Zt}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),Zt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.bufferSize=i,n.buffer=[],n}return i(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(f),Jt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.bufferSize=i,r.startBufferEvery=n,r.buffers=[],r.count=0,r}return i(e,t),e.prototype._next=function(t){var e=this,i=e.bufferSize,n=e.startBufferEvery,r=e.buffers,s=e.count;this.count++,s%n==0&&r.push([]);for(var o=r.length;o--;){var a=r[o];a.push(t),a.length===i&&(r.splice(o,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,i=this.destination;e.length>0;){var n=e.shift();n.length>0&&i.next(n)}t.prototype._complete.call(this)},e}(f);var Kt=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new Qt(t,this.closingSelector))},t}(),Qt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.closingSelector=i,n.subscribing=!1,n.openBuffer(),n}return i(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,i=this.buffer;this.buffer&&this.destination.next(i),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new u,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add(St(e,new xt(this))),this.subscribing=!1},e}(wt);function te(t){return function(e){var i=new ee(t),n=e.lift(i);return i.caught=n}}var ee=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new ie(t,this.selector,this.caught))},t}(),ie=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.selector=i,r.caught=n,r}return i(e,t),e.prototype.error=function(e){if(!this.isStopped){var i=void 0;try{i=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var n=new xt(this);this.add(n);var r=St(i,n);r!==n&&this.add(r)}},e}(wt);function ne(t,e){return Mt(t,e,1)}function re(t,e){return void 0===e&&(e=Q),function(i){return i.lift(new se(t,e))}}var se=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new oe(t,this.dueTime,this.scheduler))},t}(),oe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.dueTime=i,r.scheduler=n,r.debouncedSubscription=null,r.lastValue=null,r.hasValue=!1,r}return i(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(ae,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(f);function ae(t){t.debouncedNext()}function ce(t){return void 0===t&&(t=null),function(e){return e.lift(new he(t))}}var he=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new le(t,this.defaultValue))},t}(),le=function(t){function e(e,i){var n=t.call(this,e)||this;return n.defaultValue=i,n.isEmpty=!0,n}return i(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(f);function ue(t,e){return function(i){return i.lift(new de(t,e))}}var de=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new pe(t,this.compare,this.keySelector))},t}(),pe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.keySelector=n,r.hasKey=!1,"function"==typeof i&&(r.compare=i),r}return i(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var i=this.keySelector;e=i?i(t):t}catch(t){return this.destination.error(t)}var n=!1;if(this.hasKey)try{n=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;n||(this.key=e,this.destination.next(t))},e}(f);function fe(t){return void 0===t&&(t=_e),function(e){return e.lift(new me(t))}}var me=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new ge(t,this.errorFactory))},t}(),ge=function(t){function e(e,i){var n=t.call(this,e)||this;return n.errorFactory=i,n.hasValue=!1,n}return i(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(f);function _e(){return new it}function ve(t){return function(e){return 0===t?B():e.lift(new ye(t))}}var ye=function(){function t(t){if(this.total=t,this.total<0)throw new et}return t.prototype.call=function(t,e){return e.subscribe(new be(t,this.total))},t}(),be=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.count=0,n}return i(e,t),e.prototype._next=function(t){var e=this.total,i=++this.count;i<=e&&(this.destination.next(t),i===e&&(this.destination.complete(),this.unsubscribe()))},e}(f);function xe(t,e,i){return void 0===e&&(e=Number.POSITIVE_INFINITY),e=(e||0)<1?Number.POSITIVE_INFINITY:e,function(n){return n.lift(new we(t,e,i))}}var we=function(){function t(t,e,i){this.project=t,this.concurrent=e,this.scheduler=i}return t.prototype.call=function(t,e){return e.subscribe(new Se(t,this.project,this.concurrent,this.scheduler))},t}(),Se=function(t){function e(e,i,n,r){var s=t.call(this,e)||this;return s.project=i,s.concurrent=n,s.scheduler=r,s.index=0,s.active=0,s.hasCompleted=!1,n<Number.POSITIVE_INFINITY&&(s.buffer=[]),s}return i(e,t),e.dispatch=function(t){var e=t.subscriber,i=t.result,n=t.value,r=t.index;e.subscribeToProjection(i,n,r)},e.prototype._next=function(t){var i=this.destination;if(i.closed)this._complete();else{var n=this.index++;if(this.active<this.concurrent){i.next(t);try{var r=(0,this.project)(t,n);if(this.scheduler){var s={subscriber:this,result:r,value:t,index:n};this.destination.add(this.scheduler.schedule(e.dispatch,0,s))}else this.subscribeToProjection(r,t,n)}catch(t){i.error(t)}}else this.buffer.push(t)}},e.prototype.subscribeToProjection=function(t,e,i){this.active++,this.destination.add(St(t,new xt(this)))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this._next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(wt);function Me(t){return function(e){return e.lift(new Te(t))}}var Te=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new Ce(t,this.callback))},t}(),Ce=function(t){function e(e,i){var n=t.call(this,e)||this;return n.add(new u(i)),n}return i(e,t),e}(f);function Ee(t,e){var i=arguments.length>=2;return function(n){return n.pipe(t?Nt((function(e,i){return t(e,i,n)})):_,ve(1),i?ce(e):fe((function(){return new it})))}}function Ie(t){return function(e){return 0===t?B():e.lift(new Ae(t))}}var Ae=function(){function t(t){if(this.total=t,this.total<0)throw new et}return t.prototype.call=function(t,e){return e.subscribe(new Pe(t,this.total))},t}(),Pe=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.ring=new Array,n.count=0,n}return i(e,t),e.prototype._next=function(t){var e=this.ring,i=this.total,n=this.count++;e.length<i?e.push(t):e[n%i]=t},e.prototype._complete=function(){var t=this.destination,e=this.count;if(e>0)for(var i=this.count>=this.total?this.total:this.count,n=this.ring,r=0;r<i;r++){var s=e++%i;t.next(n[s])}t.complete()},e}(f);function Re(t,e){var i=arguments.length>=2;return function(n){return n.pipe(t?Nt((function(e,i){return t(e,i,n)})):_,Ie(1),i?ce(e):fe((function(){return new it})))}}function Le(t,e){var i=!1;return arguments.length>=2&&(i=!0),function(n){return n.lift(new Oe(t,e,i))}}var Oe=function(){function t(t,e,i){void 0===i&&(i=!1),this.accumulator=t,this.seed=e,this.hasSeed=i}return t.prototype.call=function(t,e){return e.subscribe(new Ne(t,this.accumulator,this.seed,this.hasSeed))},t}(),Ne=function(t){function e(e,i,n,r){var s=t.call(this,e)||this;return s.accumulator=i,s._seed=n,s.hasSeed=r,s.index=0,s}return i(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.accumulator(this.seed,t,i)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(f);function De(t,e){return arguments.length>=2?function(i){return v(Le(t,e),Ie(1),ce(e))(i)}:function(e){return v(Le((function(e,i,n){return t(e,i,n+1)})),Ie(1))(e)}}function $e(t,e){return function(i){var n;if(n="function"==typeof t?t:function(){return t},"function"==typeof e)return i.lift(new ke(n,e));var r=Object.create(i,R);return r.source=i,r.subjectFactory=n,r}}var ke=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var i=this.selector,n=this.subjectFactory(),r=i(n).subscribe(t);return r.add(e.subscribe(n)),r},t}();function ze(){return function(t){return t.lift(new Fe)}}var Fe=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Be(t))},t}(),Be=function(t){function e(e){var i=t.call(this,e)||this;return i.hasPrev=!1,i}return i(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(f);function je(t,e){return function(i){for(var n=i,r=0;r<e;r++){var s=null!=n?n[t[r]]:void 0;if(void 0===s)return;n=s}return n}}function He(t){return t?$e((function(){return new T}),t):$e(new T)}function Ue(t,e,i,n){i&&"function"!=typeof i&&(n=i);var r="function"==typeof i?i:void 0,s=new J(t,e,n);return function(t){return $e((function(){return s}),r)(t)}}function Ve(t){return void 0===t&&(t=-1),function(e){return e.lift(new Ge(t,e))}}var Ge=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new qe(t,this.count,this.source))},t}(),qe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.count=i,r.source=n,r}return i(e,t),e.prototype.error=function(e){if(!this.isStopped){var i=this.source,n=this.count;if(0===n)return t.prototype.error.call(this,e);n>-1&&(this.count=n-1),i.subscribe(this._unsubscribeAndRecycle())}},e}(f);var We=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var i=new Xe(t),n=e.subscribe(i);return n.add(St(this.notifier,new xt(i))),n},t}(),Xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return i(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(wt);function Ye(){return new T}function Ze(){return function(t){return E()($e(Ye)(t))}}function Je(t){return function(e){return e.lift(new Ke(t))}}var Ke=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new Qe(t,this.total))},t}(),Qe=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.count=0,n}return i(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(f);function ti(t){return function(e){return e.lift(new ei(t))}}var ei=function(){function t(t){this.predicate=t}return t.prototype.call=function(t,e){return e.subscribe(new ii(t,this.predicate))},t}(),ii=function(t){function e(e,i){var n=t.call(this,e)||this;return n.predicate=i,n.skipping=!0,n.index=0,n}return i(e,t),e.prototype._next=function(t){var e=this.destination;this.skipping&&this.tryCallPredicate(t),this.skipping||e.next(t)},e.prototype.tryCallPredicate=function(t){try{var e=this.predicate(t,this.index++);this.skipping=Boolean(e)}catch(t){this.destination.error(t)}},e}(f);function ni(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return j(i)?(t.pop(),function(e){return At(t,e,i)}):function(e){return At(t,e)}}function ri(t,e){return"function"==typeof e?function(i){return i.pipe(ri((function(i,n){return bt(t(i,n)).pipe(rt((function(t,r){return e(i,t,n,r)})))})))}:function(e){return e.lift(new si(t))}}var si=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new oi(t,this.project))},t}(),oi=function(t){function e(e,i){var n=t.call(this,e)||this;return n.project=i,n.index=0,n}return i(e,t),e.prototype._next=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this._innerSub(e)},e.prototype._innerSub=function(t){var e=this.innerSubscription;e&&e.unsubscribe();var i=new xt(this),n=this.destination;n.add(i),this.innerSubscription=St(t,i),this.innerSubscription!==i&&n.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=void 0},e.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t){this.destination.next(t)},e}(wt);function ai(t){return function(e){return e.lift(new ci(t))}}var ci=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var i=new hi(t),n=St(this.notifier,new xt(i));return n&&!i.seenValue?(i.add(n),e.subscribe(i)):i},t}(),hi=function(t){function e(e){var i=t.call(this,e)||this;return i.seenValue=!1,i}return i(e,t),e.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(wt);function li(t,e){return void 0===e&&(e=!1),function(i){return i.lift(new ui(t,e))}}var ui=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new di(t,this.predicate,this.inclusive))},t}(),di=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.inclusive=n,r.index=0,r}return i(e,t),e.prototype._next=function(t){var e,i=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void i.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var i=this.destination;Boolean(e)?i.next(t):(this.inclusive&&i.next(t),i.complete())},e}(f);function pi(t,e,i){return function(n){return n.lift(new fi(t,e,i))}}var fi=function(){function t(t,e,i){this.nextOrObserver=t,this.error=e,this.complete=i}return t.prototype.call=function(t,e){return e.subscribe(new mi(t,this.nextOrObserver,this.error,this.complete))},t}(),mi=function(t){function e(e,i,r,s){var o=t.call(this,e)||this;return o._tapNext=tt,o._tapError=tt,o._tapComplete=tt,o._tapError=r||tt,o._tapComplete=s||tt,n(i)?(o._context=o,o._tapNext=i):i&&(o._context=i,o._tapNext=i.next||tt,o._tapError=i.error||tt,o._tapComplete=i.complete||tt),o}return i(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(f);function gi(t,e,i){return void 0===i&&(i=Q),function(n){var r,s=(r=t)instanceof Date&&!isNaN(+r),o=s?+t-i.now():Math.abs(t);return n.lift(new _i(o,s,e,i))}}var _i=function(){function t(t,e,i,n){this.waitFor=t,this.absoluteTimeout=e,this.withObservable=i,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new vi(t,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},t}(),vi=function(t){function e(e,i,n,r,s){var o=t.call(this,e)||this;return o.absoluteTimeout=i,o.waitFor=n,o.withObservable=r,o.scheduler=s,o.scheduleTimeout(),o}return i(e,t),e.dispatchTimeout=function(t){var e=t.withObservable;t._unsubscribeAndRecycle(),t.add(St(e,new xt(t)))},e.prototype.scheduleTimeout=function(){var t=this.action;t?this.action=t.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(e.dispatchTimeout,this.waitFor,this))},e.prototype._next=function(e){this.absoluteTimeout||this.scheduleTimeout(),t.prototype._next.call(this,e)},e.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},e}(wt);function yi(t,e){return void 0===e&&(e=Q),gi(t,q(new nt),e)}function bi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var i;"function"==typeof t[t.length-1]&&(i=t.pop());var n=t;return e.lift(new xi(n,i))}}var xi=function(){function t(t,e){this.observables=t,this.project=e}return t.prototype.call=function(t,e){return e.subscribe(new wi(t,this.observables,this.project))},t}(),wi=function(t){function e(e,i,n){var r=t.call(this,e)||this;r.observables=i,r.project=n,r.toRespond=[];var s=i.length;r.values=new Array(s);for(var o=0;o<s;o++)r.toRespond.push(o);for(o=0;o<s;o++){var a=i[o];r.add(ft(r,a,void 0,o))}return r}return i(e,t),e.prototype.notifyNext=function(t,e,i){this.values[i]=e;var n=this.toRespond;if(n.length>0){var r=n.indexOf(i);-1!==r&&n.splice(r,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(at);class Si{createFilter(t){return new Function("node","return "+this._compile(t)+";")}_compile(t){if(null==t||t.length<=1)return"true";const e=t[0];return"("+("=="===e?this._compileComparisonOp("===",t[1],t[2],!1):"!="===e?this._compileComparisonOp("!==",t[1],t[2],!1):">"===e||">="===e||"<"===e||"<="===e?this._compileComparisonOp(e,t[1],t[2],!0):"in"===e?this._compileInOp(t[1],t.slice(2)):"!in"===e?this._compileNegation(this._compileInOp(t[1],t.slice(2))):"all"===e?this._compileLogicalOp(t.slice(1),"&&"):"true")+")"}_compare(t,e){return t<e?-1:t>e?1:0}_compileComparisonOp(t,e,i,n){const r=this._compilePropertyReference(e),s=JSON.stringify(i);return(n?"typeof "+r+"===typeof "+s+"&&":"")+r+t+s}_compileInOp(t,e){const i=this._compare;return JSON.stringify(e.sort(i))+".indexOf("+this._compilePropertyReference(t)+")!==-1"}_compileLogicalOp(t,e){const i=this._compile.bind(this);return t.map(i).join(e)}_compileNegation(t){return"!("+t+")"}_compilePropertyReference(t){return"node["+JSON.stringify(t)+"]"}}const Mi=100,Ti=1e3,Ci=1001,Ei=1002,Ii=1003,Ai=1006,Pi=1008,Ri=1009,Li=1012,Oi=1014,Ni=1015,Di=1016,$i=1020,ki=1022,zi=1023,Fi=1026,Bi=1027,ji=2300,Hi=2301,Ui=2302,Vi=2400,Gi=2401,qi=2402,Wi=2500,Xi=3e3,Yi=7680,Zi=35044,Ji=35048,Ki="300 es";function Qi(){}Object.assign(Qi.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t)}}});const tn=[];for(let t=0;t<256;t++)tn[t]=(t<16?"0":"")+t.toString(16);let en=1234567;const nn={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(tn[255&t]+tn[t>>8&255]+tn[t>>16&255]+tn[t>>24&255]+"-"+tn[255&e]+tn[e>>8&255]+"-"+tn[e>>16&15|64]+tn[e>>24&255]+"-"+tn[63&i|128]+tn[i>>8&255]+"-"+tn[i>>16&255]+tn[i>>24&255]+tn[255&n]+tn[n>>8&255]+tn[n>>16&255]+tn[n>>24&255]).toUpperCase()},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},damp:function(t,e,i,n){return nn.lerp(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(nn.euclideanModulo(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(en=t%2147483647),en=16807*en%2147483647,(en-1)/2147483646},degToRad:function(t){return t*nn.DEG2RAD},radToDeg:function(t){return t*nn.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,o=Math.sin,a=s(i/2),c=o(i/2),h=s((e+n)/2),l=o((e+n)/2),u=s((e-n)/2),d=o((e-n)/2),p=s((n-e)/2),f=o((n-e)/2);switch(r){case"XYX":t.set(a*l,c*u,c*d,a*h);break;case"YZY":t.set(c*d,a*l,c*u,a*h);break;case"ZXZ":t.set(c*u,c*d,a*l,a*h);break;case"XZX":t.set(a*l,c*f,c*p,a*h);break;case"YXY":t.set(c*p,a*l,c*f,a*h);break;case"ZYZ":t.set(c*f,c*p,a*l,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class rn{constructor(t=0,e=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}class sn{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,n,r,s,o,a,c){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=r,h[5]=a,h[6]=i,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return(new this.constructor).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[3],a=i[6],c=i[1],h=i[4],l=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],_=n[1],v=n[4],y=n[7],b=n[2],x=n[5],w=n[8];return r[0]=s*f+o*_+a*b,r[3]=s*m+o*v+a*x,r[6]=s*g+o*y+a*w,r[1]=c*f+h*_+l*b,r[4]=c*m+h*v+l*x,r[7]=c*g+h*y+l*w,r[2]=u*f+d*_+p*b,r[5]=u*m+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return e*s*h-e*o*c-i*r*h+i*o*a+n*r*c-n*s*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=h*s-o*c,u=o*a-h*r,d=c*r-s*a,p=e*l+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=l*f,t[1]=(n*c-h*i)*f,t[2]=(o*i-n*s)*f,t[3]=u*f,t[4]=(h*e-n*a)*f,t[5]=(n*r-o*e)*f,t[6]=d*f,t[7]=(i*a-c*e)*f,t[8]=(s*e-i*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).copy(this).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,o){const a=Math.cos(r),c=Math.sin(r);return this.set(i*a,i*c,-i*(a*s+c*o)+s+t,-n*c,n*a,-n*(-c*s+a*o)+o+e,0,0,1),this}scale(t,e){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],s=n[3],o=n[6],a=n[1],c=n[4],h=n[7];return n[0]=e*r+i*a,n[3]=e*s+i*c,n[6]=e*o+i*h,n[1]=-i*r+e*a,n[4]=-i*s+e*c,n[7]=-i*o+e*h,this}translate(t,e){const i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}}let on;const an={getDataURL:function(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===on&&(on=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),on.width=t.width,on.height=t.height;const i=on.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=on}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}};let cn=0;function hn(t=hn.DEFAULT_IMAGE,e=hn.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,o=1023,a=1009,c=1,h=3e3){Object.defineProperty(this,"id",{value:cn++}),this.uuid=nn.generateUUID(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new rn(0,0),this.repeat=new rn(1,1),this.center=new rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new sn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.version=0,this.onUpdate=null}function ln(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?an.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}hn.DEFAULT_IMAGE=void 0,hn.DEFAULT_MAPPING=300,hn.prototype=Object.assign(Object.create(Qi.prototype),{constructor:hn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=nn.generateUUID()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)n[t].isDataTexture?e.push(ln(n[t].image)):e.push(ln(n[t]))}else e=ln(n);t.images[n.uuid]={uuid:n.uuid,url:e}}i.image=n.uuid}return e||(t.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ti:t.x=t.x-Math.floor(t.x);break;case Ci:t.x=t.x<0?0:1;break;case Ei:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Ti:t.y=t.y-Math.floor(t.y);break;case Ci:t.y=t.y<0?0:1;break;case Ei:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(hn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});class un{constructor(t=0,e=0,i=0,n=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,o=.1,a=t.elements,c=a[0],h=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(h-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(d+1)/2,_=(g+1)/2,v=(h+u)/4,y=(l+f)/4,b=(p+m)/4;return t>a&&t>_?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=v/i,r=y/i):a>_?a<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(a),i=v/n,r=b/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=y/r,n=b/r),this.set(i,n,r,e),this}let _=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(l-f)/_,this.z=(u-h)/_,this.w=Math.acos((c+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}class dn extends Qi{constructor(t,e,i){super(),Object.defineProperty(this,"isWebGLRenderTarget",{value:!0}),this.width=t,this.height=e,this.scissor=new un(0,0,t,e),this.scissorTest=!1,this.viewport=new un(0,0,t,e),i=i||{},this.texture=new hn(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:Ai,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setSize(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class pn{constructor(t=0,e=0,i=0,n=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=e,this._z=i,this._w=n}static slerp(t,e,i,n){return i.copy(t).slerp(e,n)}static slerpFlat(t,e,i,n,r,s,o){let a=i[n+0],c=i[n+1],h=i[n+2],l=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||c!==d||h!==p){let t=1-o;const e=a*u+c*d+h*p+l*f,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,o=Math.sin(o*s)/r}const r=o*i;if(a=a*t+u*r,c=c*t+d*r,h=h*t+p*r,l=l*t+f*r,t===1-o){const t=1/Math.sqrt(a*a+c*c+h*h+l*l);a*=t,c*=t,h*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,i,n,r,s){const o=i[n],a=i[n+1],c=i[n+2],h=i[n+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=o*p+h*l+a*d-c*u,t[e+1]=a*p+h*u+c*l-o*d,t[e+2]=c*p+h*d+o*u-a*l,t[e+3]=h*p-o*l-a*u-c*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=t._x,n=t._y,r=t._z,s=t._order,o=Math.cos,a=Math.sin,c=o(i/2),h=o(n/2),l=o(r/2),u=a(i/2),d=a(n/2),p=a(r/2);switch(s){case"XYZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"YXZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"ZXY":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"ZYX":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"YZX":this._x=u*h*l+c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l-u*d*p;break;case"XZY":this._x=u*h*l-c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],o=e[5],a=e[9],c=e[2],h=e[6],l=e[10],u=i+o+l;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(r-c)*t,this._z=(s-n)*t}else if(i>o&&i>l){const t=2*Math.sqrt(1+i-o-l);this._w=(h-a)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+c)/t}else if(o>l){const t=2*Math.sqrt(1+o-i-l);this._w=(r-c)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+l-i-o);this._w=(s-n)/t,this._x=(r+c)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-6?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(nn.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,o=e._x,a=e._y,c=e._z,h=e._w;return this._x=i*h+s*o+n*c-r*a,this._y=n*h+s*a+r*o-i*c,this._z=r*h+s*c+i*a-n*o,this._w=s*h-i*o-n*a-r*c,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let o=s*t._w+i*t._x+n*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(a),h=Math.atan2(c,o),l=Math.sin((1-e)*h)/c,u=Math.sin(e*h)/c;return this._w=s*l+this._w*u,this._x=i*l+this._x*u,this._y=n*l+this._y*u,this._z=r*l+this._z*u,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}class fn{constructor(t=0,e=0,i=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(gn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z,a=t.w,c=a*e+s*n-o*i,h=a*i+o*e-r*n,l=a*n+r*i-s*e,u=-r*e-s*i-o*n;return this.x=c*a+u*-r+h*-o-l*-s,this.y=h*a+u*-s+l*-r-c*-o,this.z=l*a+u*-o+c*-s-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return mn.copy(this).projectOnVector(t),this.sub(mn)}reflect(t){return this.sub(mn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(nn.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const mn=new fn,gn=new pn;class _n{constructor(t,e){Object.defineProperty(this,"isBox3",{value:!0}),this.min=void 0!==t?t:new fn(1/0,1/0,1/0),this.max=void 0!==e?e:new fn(-1/0,-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=t.length;a<c;a+=3){const c=t[a],h=t[a+1],l=t[a+2];c<e&&(e=c),h<i&&(i=h),l<n&&(n=l),c>r&&(r=c),h>s&&(s=h),l>o&&(o=l)}return this.min.set(e,i,n),this.max.set(r,s,o),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=t.count;a<c;a++){const c=t.getX(a),h=t.getY(a),l=t.getZ(a);c<e&&(e=c),h<i&&(i=h),l<n&&(n=l),c>r&&(r=c),h>s&&(s=h),l>o&&(o=l)}return this.min.set(e,i,n),this.max.set(r,s,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=bn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new fn),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new fn),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);const e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),xn.copy(e.boundingBox),xn.applyMatrix4(t.matrixWorld),this.union(xn));const i=t.children;for(let t=0,e=i.length;t<e;t++)this.expandByObject(i[t]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new fn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,bn),bn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(In),An.subVectors(this.max,In),wn.subVectors(t.a,In),Sn.subVectors(t.b,In),Mn.subVectors(t.c,In),Tn.subVectors(Sn,wn),Cn.subVectors(Mn,Sn),En.subVectors(wn,Mn);let e=[0,-Tn.z,Tn.y,0,-Cn.z,Cn.y,0,-En.z,En.y,Tn.z,0,-Tn.x,Cn.z,0,-Cn.x,En.z,0,-En.x,-Tn.y,Tn.x,0,-Cn.y,Cn.x,0,-En.y,En.x,0];return!!vn(e,wn,Sn,Mn,An)&&(e=[1,0,0,0,1,0,0,0,1],!!vn(e,wn,Sn,Mn,An)&&(Pn.crossVectors(Tn,Cn),e=[Pn.x,Pn.y,Pn.z],vn(e,wn,Sn,Mn,An)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new fn),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return bn.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(bn).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yn)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}function vn(t,e,i,n,r){for(let s=0,o=t.length-3;s<=o;s+=3){Rn.fromArray(t,s);const o=r.x*Math.abs(Rn.x)+r.y*Math.abs(Rn.y)+r.z*Math.abs(Rn.z),a=e.dot(Rn),c=i.dot(Rn),h=n.dot(Rn);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>o)return!1}return!0}const yn=[new fn,new fn,new fn,new fn,new fn,new fn,new fn,new fn],bn=new fn,xn=new _n,wn=new fn,Sn=new fn,Mn=new fn,Tn=new fn,Cn=new fn,En=new fn,In=new fn,An=new fn,Pn=new fn,Rn=new fn,Ln=new _n;class On{constructor(t,e){this.center=void 0!==t?t:new fn,this.radius=void 0!==e?e:-1}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Ln.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new fn),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new _n),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}}const Nn=new fn,Dn=new fn,$n=new fn,kn=new fn,zn=new fn,Fn=new fn,Bn=new fn;class jn{constructor(t,e){this.origin=void 0!==t?t:new fn,this.direction=void 0!==e?e:new fn(0,0,-1)}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new fn),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Nn)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new fn),e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Nn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Nn.copy(this.direction).multiplyScalar(e).add(this.origin),Nn.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Dn.copy(t).add(e).multiplyScalar(.5),$n.copy(e).sub(t).normalize(),kn.copy(this.origin).sub(Dn);const r=.5*t.distanceTo(e),s=-this.direction.dot($n),o=kn.dot(this.direction),a=-kn.dot($n),c=kn.lengthSq(),h=Math.abs(1-s*s);let l,u,d,p;if(h>0)if(l=s*a-o,u=s*o-a,p=r*h,l>=0)if(u>=-p)if(u<=p){const t=1/h;l*=t,u*=t,d=l*(l+s*u+2*o)+u*(s*l+u+2*a)+c}else u=r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u=-r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u<=-p?(l=Math.max(0,-(-s*r+o)),u=l>0?-r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c):u<=p?(l=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(l=Math.max(0,-(s*r+o)),u=l>0?r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c);else u=s>0?-r:r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;return i&&i.copy(this.direction).multiplyScalar(l).add(this.origin),n&&n.copy($n).multiplyScalar(u).add(Dn),d}intersectSphere(t,e){Nn.subVectors(t.center,this.origin);const i=Nn.dot(this.direction),n=Nn.dot(Nn)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),o=i-s,a=i+s;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,o,a;const c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(i=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Nn)}intersectTriangle(t,e,i,n,r){zn.subVectors(e,t),Fn.subVectors(i,t),Bn.crossVectors(zn,Fn);let s,o=this.direction.dot(Bn);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}kn.subVectors(this.origin,t);const a=s*this.direction.dot(Fn.crossVectors(kn,Fn));if(a<0)return null;const c=s*this.direction.dot(zn.cross(kn));if(c<0)return null;if(a+c>o)return null;const h=-s*kn.dot(Bn);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}class Hn{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,n,r,s,o,a,c,h,l,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Hn).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Un.setFromMatrixColumn(t,0).length(),r=1/Un.setFromMatrixColumn(t,1).length(),s=1/Un.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),c=Math.sin(n),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=s*h,i=s*l,n=o*h,r=o*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=i+n*c,e[5]=t-r*c,e[9]=-o*a,e[2]=r-t*c,e[6]=n+i*c,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,i=a*l,n=c*h,r=c*l;e[0]=t+r*o,e[4]=n*o-i,e[8]=s*c,e[1]=s*l,e[5]=s*h,e[9]=-o,e[2]=i*o-n,e[6]=r+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,i=a*l,n=c*h,r=c*l;e[0]=t-r*o,e[4]=-s*l,e[8]=n+i*o,e[1]=i+n*o,e[5]=s*h,e[9]=r-t*o,e[2]=-s*c,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,i=s*l,n=o*h,r=o*l;e[0]=a*h,e[4]=n*c-i,e[8]=t*c+r,e[1]=a*l,e[5]=r*c+t,e[9]=i*c-n,e[2]=-c,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,i=s*c,n=o*a,r=o*c;e[0]=a*h,e[4]=r-t*l,e[8]=n*l+i,e[1]=l,e[5]=s*h,e[9]=-o*h,e[2]=-c*h,e[6]=i*l+n,e[10]=t-r*l}else if("XZY"===t.order){const t=s*a,i=s*c,n=o*a,r=o*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=t*l+r,e[5]=s*h,e[9]=i*l-n,e[2]=n*l-i,e[6]=o*h,e[10]=r*l+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Gn,t,qn)}lookAt(t,e,i){const n=this.elements;return Yn.subVectors(t,e),0===Yn.lengthSq()&&(Yn.z=1),Yn.normalize(),Wn.crossVectors(i,Yn),0===Wn.lengthSq()&&(1===Math.abs(i.z)?Yn.x+=1e-4:Yn.z+=1e-4,Yn.normalize(),Wn.crossVectors(i,Yn)),Wn.normalize(),Xn.crossVectors(Yn,Wn),n[0]=Wn.x,n[4]=Xn.x,n[8]=Yn.x,n[1]=Wn.y,n[5]=Xn.y,n[9]=Yn.y,n[2]=Wn.z,n[6]=Xn.z,n[10]=Yn.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[4],a=i[8],c=i[12],h=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],_=i[3],v=i[7],y=i[11],b=i[15],x=n[0],w=n[4],S=n[8],M=n[12],T=n[1],C=n[5],E=n[9],I=n[13],A=n[2],P=n[6],R=n[10],L=n[14],O=n[3],N=n[7],D=n[11],$=n[15];return r[0]=s*x+o*T+a*A+c*O,r[4]=s*w+o*C+a*P+c*N,r[8]=s*S+o*E+a*R+c*D,r[12]=s*M+o*I+a*L+c*$,r[1]=h*x+l*T+u*A+d*O,r[5]=h*w+l*C+u*P+d*N,r[9]=h*S+l*E+u*R+d*D,r[13]=h*M+l*I+u*L+d*$,r[2]=p*x+f*T+m*A+g*O,r[6]=p*w+f*C+m*P+g*N,r[10]=p*S+f*E+m*R+g*D,r[14]=p*M+f*I+m*L+g*$,r[3]=_*x+v*T+y*A+b*O,r[7]=_*w+v*C+y*P+b*N,r[11]=_*S+v*E+y*R+b*D,r[15]=_*M+v*I+y*L+b*$,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],o=t[5],a=t[9],c=t[13],h=t[2],l=t[6],u=t[10],d=t[14];return t[3]*(+r*a*l-n*c*l-r*o*u+i*c*u+n*o*d-i*a*d)+t[7]*(+e*a*d-e*c*u+r*s*u-n*s*d+n*c*h-r*a*h)+t[11]*(+e*c*l-e*o*d-r*s*l+i*s*d+r*o*h-i*c*h)+t[15]*(-n*o*h-e*a*l+e*o*u+n*s*l-i*s*u+i*a*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=l*m*c-f*u*c+f*a*d-o*m*d-l*a*g+o*u*g,v=p*u*c-h*m*c-p*a*d+s*m*d+h*a*g-s*u*g,y=h*f*c-p*l*c+p*o*d-s*f*d-h*o*g+s*l*g,b=p*l*a-h*f*a-p*o*u+s*f*u+h*o*m-s*l*m,x=e*_+i*v+n*y+r*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return t[0]=_*w,t[1]=(f*u*r-l*m*r-f*n*d+i*m*d+l*n*g-i*u*g)*w,t[2]=(o*m*r-f*a*r+f*n*c-i*m*c-o*n*g+i*a*g)*w,t[3]=(l*a*r-o*u*r-l*n*c+i*u*c+o*n*d-i*a*d)*w,t[4]=v*w,t[5]=(h*m*r-p*u*r+p*n*d-e*m*d-h*n*g+e*u*g)*w,t[6]=(p*a*r-s*m*r-p*n*c+e*m*c+s*n*g-e*a*g)*w,t[7]=(s*u*r-h*a*r+h*n*c-e*u*c-s*n*d+e*a*d)*w,t[8]=y*w,t[9]=(p*l*r-h*f*r-p*i*d+e*f*d+h*i*g-e*l*g)*w,t[10]=(s*f*r-p*o*r+p*i*c-e*f*c-s*i*g+e*o*g)*w,t[11]=(h*o*r-s*l*r-h*i*c+e*l*c+s*i*d-e*o*d)*w,t[12]=b*w,t[13]=(h*f*n-p*l*n+p*i*u-e*f*u-h*i*m+e*l*m)*w,t[14]=(p*o*n-s*f*n-p*i*a+e*f*a+s*i*m-e*o*m)*w,t[15]=(s*l*n-h*o*n+h*i*a-e*l*a-s*i*u+e*o*u)*w,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,o=t.y,a=t.z,c=r*s,h=r*o;return this.set(c*s+i,c*o-n*a,c*a+n*o,0,c*o+n*a,h*o+i,h*a-n*s,0,c*a-n*o,h*a+n*s,r*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,c=r+r,h=s+s,l=o+o,u=r*c,d=r*h,p=r*l,f=s*h,m=s*l,g=o*l,_=a*c,v=a*h,y=a*l,b=i.x,x=i.y,w=i.z;return n[0]=(1-(f+g))*b,n[1]=(d+y)*b,n[2]=(p-v)*b,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(m+_)*x,n[7]=0,n[8]=(p+v)*w,n[9]=(m-_)*w,n[10]=(1-(u+f))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=Un.set(n[0],n[1],n[2]).length();const s=Un.set(n[4],n[5],n[6]).length(),o=Un.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],Vn.copy(this);const a=1/r,c=1/s,h=1/o;return Vn.elements[0]*=a,Vn.elements[1]*=a,Vn.elements[2]*=a,Vn.elements[4]*=c,Vn.elements[5]*=c,Vn.elements[6]*=c,Vn.elements[8]*=h,Vn.elements[9]*=h,Vn.elements[10]*=h,e.setFromRotationMatrix(Vn),i.x=r,i.y=s,i.z=o,this}makePerspective(t,e,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,a=2*r/(e-t),c=2*r/(i-n),h=(e+t)/(e-t),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,r,s){const o=this.elements,a=1/(e-t),c=1/(i-n),h=1/(s-r),l=(e+t)*a,u=(i+n)*c,d=(s+r)*h;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*h,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Un=new fn,Vn=new Hn,Gn=new fn(0,0,0),qn=new fn(1,1,1),Wn=new fn,Xn=new fn,Yn=new fn;class Zn{constructor(t=0,e=0,i=0,n=Zn.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,i){const n=nn.clamp,r=t.elements,s=r[0],o=r[4],a=r[8],c=r[1],h=r[5],l=r[9],u=r[2],d=r[6],p=r[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-n(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-l,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Jn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Jn,e,i)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return Kn.setFromEuler(this),this.setFromQuaternion(Kn,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new fn(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Zn.DefaultOrder="XYZ",Zn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const Jn=new Hn,Kn=new pn;class Qn{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}}let tr=0;const er=new fn,ir=new pn,nr=new Hn,rr=new fn,sr=new fn,or=new fn,ar=new pn,cr=new fn(1,0,0),hr=new fn(0,1,0),lr=new fn(0,0,1),ur={type:"added"},dr={type:"removed"};function pr(){Object.defineProperty(this,"id",{value:tr++}),this.uuid=nn.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pr.DefaultUp.clone();const t=new fn,e=new Zn,i=new pn,n=new fn(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Hn},normalMatrix:{value:new sn}}),this.matrix=new Hn,this.matrixWorld=new Hn,this.matrixAutoUpdate=pr.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Qn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}pr.DefaultUp=new fn(0,1,0),pr.DefaultMatrixAutoUpdate=!0,pr.prototype=Object.assign(Object.create(Qi.prototype),{constructor:pr,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return ir.setFromAxisAngle(t,e),this.quaternion.multiply(ir),this},rotateOnWorldAxis:function(t,e){return ir.setFromAxisAngle(t,e),this.quaternion.premultiply(ir),this},rotateX:function(t){return this.rotateOnAxis(cr,t)},rotateY:function(t){return this.rotateOnAxis(hr,t)},rotateZ:function(t){return this.rotateOnAxis(lr,t)},translateOnAxis:function(t,e){return er.copy(t).applyQuaternion(this.quaternion),this.position.add(er.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(cr,t)},translateY:function(t){return this.translateOnAxis(hr,t)},translateZ:function(t){return this.translateOnAxis(lr,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(nr.copy(this.matrixWorld).invert())},lookAt:function(t,e,i){t.isVector3?rr.copy(t):rr.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),sr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?nr.lookAt(sr,rr,this.up):nr.lookAt(rr,sr,this.up),this.quaternion.setFromRotationMatrix(nr),n&&(nr.extractRotation(n.matrixWorld),ir.setFromRotationMatrix(nr),this.quaternion.premultiply(ir.invert()))},add:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(ur)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(dr)),this},clear:function(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(dr)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),nr.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),nr.multiply(t.parent.matrixWorld)),t.applyMatrix4(nr),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new pn),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sr,t,or),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sr,ar,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)},traverseAncestors:function(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].updateWorldMatrix(!1,!0)}},toJSON:function(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=s(t.geometries),n=s(t.materials),r=s(t.textures),o=s(t.images),a=s(t.shapes),c=s(t.skeletons),h=s(t.animations);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),o.length>0&&(i.images=o),a.length>0&&(i.shapes=a),c.length>0&&(i.skeletons=c),h.length>0&&(i.animations=h)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}});const fr=new fn,mr=new fn,gr=new sn;class _r{constructor(t,e){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=void 0!==t?t:new fn(1,0,0),this.constant=void 0!==e?e:0}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=fr.subVectors(i,e).cross(mr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new fn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new fn);const i=t.delta(fr),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?void 0:e.copy(i).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new fn),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||gr.getNormalMatrix(t),n=this.coplanarPoint(fr).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}const vr=new fn,yr=new fn,br=new fn,xr=new fn,wr=new fn,Sr=new fn,Mr=new fn,Tr=new fn,Cr=new fn,Er=new fn;class Ir{constructor(t,e,i){this.a=void 0!==t?t:new fn,this.b=void 0!==e?e:new fn,this.c=void 0!==i?i:new fn}static getNormal(t,e,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new fn),n.subVectors(i,e),vr.subVectors(t,e),n.cross(vr);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){vr.subVectors(n,e),yr.subVectors(i,e),br.subVectors(t,e);const s=vr.dot(vr),o=vr.dot(yr),a=vr.dot(br),c=yr.dot(yr),h=yr.dot(br),l=s*c-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new fn),0===l)return r.set(-2,-1,-1);const u=1/l,d=(c*a-o*h)*u,p=(s*h-o*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,xr),xr.x>=0&&xr.y>=0&&xr.x+xr.y<=1}static getUV(t,e,i,n,r,s,o,a){return this.getBarycoord(t,e,i,n,xr),a.set(0,0),a.addScaledVector(r,xr.x),a.addScaledVector(s,xr.y),a.addScaledVector(o,xr.z),a}static isFrontFacing(t,e,i,n){return vr.subVectors(i,e),yr.subVectors(t,e),vr.cross(yr).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return vr.subVectors(this.c,this.b),yr.subVectors(this.a,this.b),.5*vr.cross(yr).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new fn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ir.getNormal(this.a,this.b,this.c,t)}getPlane(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new _r),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ir.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return Ir.getUV(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Ir.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ir.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new fn);const i=this.a,n=this.b,r=this.c;let s,o;wr.subVectors(n,i),Sr.subVectors(r,i),Tr.subVectors(t,i);const a=wr.dot(Tr),c=Sr.dot(Tr);if(a<=0&&c<=0)return e.copy(i);Cr.subVectors(t,n);const h=wr.dot(Cr),l=Sr.dot(Cr);if(h>=0&&l<=h)return e.copy(n);const u=a*l-h*c;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(i).addScaledVector(wr,s);Er.subVectors(t,r);const d=wr.dot(Er),p=Sr.dot(Er);if(p>=0&&d<=p)return e.copy(r);const f=d*c-a*p;if(f<=0&&c>=0&&p<=0)return o=c/(c-p),e.copy(i).addScaledVector(Sr,o);const m=h*p-d*l;if(m<=0&&l-h>=0&&d-p>=0)return Mr.subVectors(r,n),o=(l-h)/(l-h+(d-p)),e.copy(n).addScaledVector(Mr,o);const g=1/(m+f+u);return s=f*g,o=u*g,e.copy(i).addScaledVector(wr,s).addScaledVector(Sr,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ar={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Pr={h:0,s:0,l:0},Rr={h:0,s:0,l:0};function Lr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Or(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Nr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Dr{constructor(t,e,i){return Object.defineProperty(this,"isColor",{value:!0}),void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,i){return this.r=t,this.g=e,this.b=i,this}setHSL(t,e,i){if(t=nn.euclideanModulo(t,1),e=nn.clamp(e,0,1),i=nn.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Lr(r,n,t+1/3),this.g=Lr(r,n,t),this.b=Lr(r,n,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=Ar[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Or(t.r),this.g=Or(t.g),this.b=Or(t.b),this}copyLinearToSRGB(t){return this.r=Nr(t.r),this.g=Nr(t.g),this.b=Nr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const e=this.r,i=this.g,n=this.b,r=Math.max(e,i,n),s=Math.min(e,i,n);let o,a;const c=(s+r)/2;if(s===r)o=0,a=0;else{const t=r-s;switch(a=c<=.5?t/(r+s):t/(2-r-s),r){case e:o=(i-n)/t+(i<n?6:0);break;case i:o=(n-e)/t+2;break;case n:o=(e-i)/t+4}o/=6}return t.h=o,t.s=a,t.l=c,t}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(t,e,i){return this.getHSL(Pr),Pr.h+=t,Pr.s+=e,Pr.l+=i,this.setHSL(Pr.h,Pr.s,Pr.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Pr),t.getHSL(Rr);const i=nn.lerp(Pr.h,Rr.h,e),n=nn.lerp(Pr.s,Rr.s,e),r=nn.lerp(Pr.l,Rr.l,e);return this.setHSL(i,n,r),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}Dr.NAMES=Ar,Dr.prototype.r=1,Dr.prototype.g=1,Dr.prototype.b=1;class $r{constructor(t,e,i,n,r,s=0){this.a=t,this.b=e,this.c=i,this.normal=n&&n.isVector3?n:new fn,this.vertexNormals=Array.isArray(n)?n:[],this.color=r&&r.isColor?r:new Dr,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=s}clone(){return(new this.constructor).copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}}let kr=0;function zr(){Object.defineProperty(this,"id",{value:kr++}),this.uuid=nn.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yi,this.stencilZFail=Yi,this.stencilZPass=Yi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function Fr(t){zr.call(this),this.type="MeshBasicMaterial",this.color=new Dr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}zr.prototype=Object.assign(Object.create(Qi.prototype),{constructor:zr,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}},toJSON:function(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(zr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Fr.prototype=Object.create(zr.prototype),Fr.prototype.constructor=Fr,Fr.prototype.isMeshBasicMaterial=!0,Fr.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};const Br=new fn,jr=new rn;function Hr(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.usage=Zi,this.updateRange={offset:0,count:-1},this.version=0}function Ur(t,e,i){Hr.call(this,new Int8Array(t),e,i)}function Vr(t,e,i){Hr.call(this,new Uint8Array(t),e,i)}function Gr(t,e,i){Hr.call(this,new Uint8ClampedArray(t),e,i)}function qr(t,e,i){Hr.call(this,new Int16Array(t),e,i)}function Wr(t,e,i){Hr.call(this,new Uint16Array(t),e,i)}function Xr(t,e,i){Hr.call(this,new Int32Array(t),e,i)}function Yr(t,e,i){Hr.call(this,new Uint32Array(t),e,i)}function Zr(t,e,i){Hr.call(this,new Uint16Array(t),e,i)}function Jr(t,e,i){Hr.call(this,new Float32Array(t),e,i)}function Kr(t,e,i){Hr.call(this,new Float64Array(t),e,i)}function Qr(t){if(0===t.length)return-1/0;let e=t[0];for(let i=1,n=t.length;i<n;++i)t[i]>e&&(e=t[i]);return e}Object.defineProperty(Hr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Hr.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new Dr),e[i++]=r.r,e[i++]=r.g,e[i++]=r.b}return this},copyVector2sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new rn),e[i++]=r.x,e[i++]=r.y}return this},copyVector3sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new fn),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z}return this},copyVector4sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new un),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z,e[i++]=r.w}return this},applyMatrix3:function(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)jr.fromBufferAttribute(this,e),jr.applyMatrix3(t),this.setXY(e,jr.x,jr.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)Br.fromBufferAttribute(this,e),Br.applyMatrix3(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},applyMatrix4:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.applyMatrix4(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},applyNormalMatrix:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.applyNormalMatrix(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},transformDirection:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.transformDirection(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},set:function(t,e=0){return this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Ur.prototype=Object.create(Hr.prototype),Ur.prototype.constructor=Ur,Vr.prototype=Object.create(Hr.prototype),Vr.prototype.constructor=Vr,Gr.prototype=Object.create(Hr.prototype),Gr.prototype.constructor=Gr,qr.prototype=Object.create(Hr.prototype),qr.prototype.constructor=qr,Wr.prototype=Object.create(Hr.prototype),Wr.prototype.constructor=Wr,Xr.prototype=Object.create(Hr.prototype),Xr.prototype.constructor=Xr,Yr.prototype=Object.create(Hr.prototype),Yr.prototype.constructor=Yr,Zr.prototype=Object.create(Hr.prototype),Zr.prototype.constructor=Zr,Zr.prototype.isFloat16BufferAttribute=!0,Jr.prototype=Object.create(Hr.prototype),Jr.prototype.constructor=Jr,Kr.prototype=Object.create(Hr.prototype),Kr.prototype.constructor=Kr;const ts={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function es(t,e){return new ts[t](e)}let is=0;const ns=new Hn,rs=new pr,ss=new fn,os=new _n,as=new _n,cs=new fn;function hs(){Object.defineProperty(this,"id",{value:is++}),this.uuid=nn.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}hs.prototype=Object.assign(Object.create(Qi.prototype),{constructor:hs,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(Qr(t)>65535?Yr:Wr)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},hasAttribute:function(t){return void 0!==this.attributes[t]},addGroup:function(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new sn).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return ns.makeRotationX(t),this.applyMatrix4(ns),this},rotateY:function(t){return ns.makeRotationY(t),this.applyMatrix4(ns),this},rotateZ:function(t){return ns.makeRotationZ(t),this.applyMatrix4(ns),this},translate:function(t,e,i){return ns.makeTranslation(t,e,i),this.applyMatrix4(ns),this},scale:function(t,e,i){return ns.makeScale(t,e,i),this.applyMatrix4(ns),this},lookAt:function(t){return rs.lookAt(t),rs.updateMatrix(),this.applyMatrix4(rs.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(ss).negate(),this.translate(ss.x,ss.y,ss.z),this},setFromPoints:function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Jr(e,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new _n);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new fn(-1/0,-1/0,-1/0),new fn(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];os.setFromBufferAttribute(i),this.morphTargetsRelative?(cs.addVectors(this.boundingBox.min,os.min),this.boundingBox.expandByPoint(cs),cs.addVectors(this.boundingBox.max,os.max),this.boundingBox.expandByPoint(cs)):(this.boundingBox.expandByPoint(os.min),this.boundingBox.expandByPoint(os.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new On);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new fn,1/0);if(t){const i=this.boundingSphere.center;if(os.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];as.setFromBufferAttribute(i),this.morphTargetsRelative?(cs.addVectors(os.min,as.min),os.expandByPoint(cs),cs.addVectors(os.max,as.max),os.expandByPoint(cs)):(os.expandByPoint(as.min),os.expandByPoint(as.max))}os.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)cs.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(cs));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],o=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)cs.fromBufferAttribute(s,e),o&&(ss.fromBufferAttribute(t,e),cs.add(ss)),n=Math.max(n,i.distanceToSquared(cs))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.array,n=e.position.array,r=e.normal.array,s=e.uv.array,o=n.length/3;void 0===e.tangent&&this.setAttribute("tangent",new Hr(new Float32Array(4*o),4));const a=e.tangent.array,c=[],h=[];for(let t=0;t<o;t++)c[t]=new fn,h[t]=new fn;const l=new fn,u=new fn,d=new fn,p=new rn,f=new rn,m=new rn,g=new fn,_=new fn;function v(t,e,i){l.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(s,2*t),f.fromArray(s,2*e),m.fromArray(s,2*i),u.sub(l),d.sub(l),f.sub(p),m.sub(p);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),_.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),c[t].add(g),c[e].add(g),c[i].add(g),h[t].add(_),h[e].add(_),h[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)v(i[t+0],i[t+1],i[t+2])}const b=new fn,x=new fn,w=new fn,S=new fn;function M(t){w.fromArray(r,3*t),S.copy(w);const e=c[t];b.copy(e),b.sub(w.multiplyScalar(w.dot(e))).normalize(),x.crossVectors(S,e);const i=x.dot(h[t])<0?-1:1;a[4*t]=b.x,a[4*t+1]=b.y,a[4*t+2]=b.z,a[4*t+3]=i}for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)M(i[t+0]),M(i[t+1]),M(i[t+2])}},computeVertexNormals:function(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new Hr(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new fn,r=new fn,s=new fn,o=new fn,a=new fn,c=new fn,h=new fn,l=new fn;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),l.subVectors(n,r),h.cross(l),o.fromBufferAttribute(i,d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,f),o.add(h),a.add(h),c.add(h),i.setXYZ(d,o.x,o.y,o.z),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let t=0,o=e.count;t<o;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),l.subVectors(n,r),h.cross(l),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===t.attributes[n])continue;const r=i[n].array,s=t.attributes[n],o=s.array,a=s.itemSize*e,c=Math.min(o.length,r.length-a);for(let t=0,e=a;t<c;t++,e++)r[e]=o[t]}return this},normalizeNormals:function(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)cs.fromBufferAttribute(t,e),cs.normalize(),t.setXYZ(e,cs.x,cs.y,cs.z)},toNonIndexed:function(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,s=new i.constructor(e.length*n);let o=0,a=0;for(let t=0,r=e.length;t<r;t++){o=e[t]*n;for(let t=0;t<n;t++)s[a++]=i[o++]}return new Hr(s,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new hs,i=this.index.array,n=this.attributes;for(const r in n){const s=t(n[r],i);e.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],o=r[n];for(let e=0,n=o.length;e<n;e++){const n=t(o[e],i);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.addGroup(i.start,i.count,i.materialIndex)}return e},toJSON:function(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e],r=n.toJSON(t.data);""!==n.name&&(r.name=n.name),t.data.attributes[e]=r}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r=n.toJSON(t.data);""!==n.name&&(r.name=n.name),s.push(r)}s.length>0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t},clone:function(){return(new hs).copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const ls=new Hn,us=new jn,ds=new On,ps=new fn,fs=new fn,ms=new fn,gs=new fn,_s=new fn,vs=new fn,ys=new fn,bs=new fn,xs=new fn,ws=new rn,Ss=new rn,Ms=new rn,Ts=new fn,Cs=new fn;function Es(t=new hs,e=new Fr){pr.call(this),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}function Is(t,e,i,n,r,s,o,a,c,h,l,u){ps.fromBufferAttribute(r,h),fs.fromBufferAttribute(r,l),ms.fromBufferAttribute(r,u);const d=t.morphTargetInfluences;if(e.morphTargets&&s&&d){ys.set(0,0,0),bs.set(0,0,0),xs.set(0,0,0);for(let t=0,e=s.length;t<e;t++){const e=d[t],i=s[t];0!==e&&(gs.fromBufferAttribute(i,h),_s.fromBufferAttribute(i,l),vs.fromBufferAttribute(i,u),o?(ys.addScaledVector(gs,e),bs.addScaledVector(_s,e),xs.addScaledVector(vs,e)):(ys.addScaledVector(gs.sub(ps),e),bs.addScaledVector(_s.sub(fs),e),xs.addScaledVector(vs.sub(ms),e)))}ps.add(ys),fs.add(bs),ms.add(xs)}t.isSkinnedMesh&&(t.boneTransform(h,ps),t.boneTransform(l,fs),t.boneTransform(u,ms));const p=function(t,e,i,n,r,s,o,a){let c;if(c=1===e.side?n.intersectTriangle(o,s,r,!0,a):n.intersectTriangle(r,s,o,2!==e.side,a),null===c)return null;Cs.copy(a),Cs.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(Cs);return h<i.near||h>i.far?null:{distance:h,point:Cs.clone(),object:t}}(t,e,i,n,ps,fs,ms,Ts);if(p){a&&(ws.fromBufferAttribute(a,h),Ss.fromBufferAttribute(a,l),Ms.fromBufferAttribute(a,u),p.uv=Ir.getUV(Ts,ps,fs,ms,ws,Ss,Ms,new rn)),c&&(ws.fromBufferAttribute(c,h),Ss.fromBufferAttribute(c,l),Ms.fromBufferAttribute(c,u),p.uv2=Ir.getUV(Ts,ps,fs,ms,ws,Ss,Ms,new rn));const t=new $r(h,l,u);Ir.getNormal(ps,fs,ms,t.normal),p.face=t}return p}Es.prototype=Object.assign(Object.create(pr.prototype),{constructor:Es,isMesh:!0,copy:function(t){return pr.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),ds.copy(i.boundingSphere),ds.applyMatrix4(r),!1===t.ray.intersectsSphere(ds))return;if(ls.copy(r).invert(),us.copy(t.ray).applyMatrix4(ls),null!==i.boundingBox&&!1===us.intersectsBox(i.boundingBox))return;let s;if(i.isBufferGeometry){const r=i.index,o=i.attributes.position,a=i.morphAttributes.position,c=i.morphTargetsRelative,h=i.attributes.uv,l=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,p=u.length;i<p;i++){const p=u[i],f=n[p.materialIndex];for(let i=Math.max(p.start,d.start),n=Math.min(p.start+p.count,d.start+d.count);i<n;i+=3){const n=r.getX(i),u=r.getX(i+1),d=r.getX(i+2);s=Is(this,f,t,us,o,a,c,h,l,n,u,d),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{for(let i=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);i<u;i+=3){const u=r.getX(i),d=r.getX(i+1),p=r.getX(i+2);s=Is(this,n,t,us,o,a,c,h,l,u,d,p),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}else if(void 0!==o)if(Array.isArray(n))for(let i=0,r=u.length;i<r;i++){const r=u[i],p=n[r.materialIndex];for(let i=Math.max(r.start,d.start),n=Math.min(r.start+r.count,d.start+d.count);i<n;i+=3){s=Is(this,p,t,us,o,a,c,h,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,e.push(s))}}else{for(let i=Math.max(0,d.start),r=Math.min(o.count,d.start+d.count);i<r;i+=3){s=Is(this,n,t,us,o,a,c,h,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});class As extends hs{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const o=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const a=[],c=[],h=[],l=[];let u=0,d=0;function p(t,e,i,n,r,s,p,f,m,g,_){const v=s/m,y=p/g,b=s/2,x=p/2,w=f/2,S=m+1,M=g+1;let T=0,C=0;const E=new fn;for(let s=0;s<M;s++){const o=s*y-x;for(let a=0;a<S;a++){const u=a*v-b;E[t]=u*n,E[e]=o*r,E[i]=w,c.push(E.x,E.y,E.z),E[t]=0,E[e]=0,E[i]=f>0?1:-1,h.push(E.x,E.y,E.z),l.push(a/m),l.push(1-s/g),T+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const i=u+e+S*t,n=u+e+S*(t+1),r=u+(e+1)+S*(t+1),s=u+(e+1)+S*t;a.push(i,n,s),a.push(n,r,s),C+=6}o.addGroup(d,C,_),d+=C,u+=T}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new Jr(c,3)),this.setAttribute("normal",new Jr(h,3)),this.setAttribute("uv",new Jr(l,2))}}function Ps(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}}return e}function Rs(t){const e={};for(let i=0;i<t.length;i++){const n=Ps(t[i]);for(const t in n)e[t]=n[t]}return e}const Ls={clone:Ps,merge:Rs};function Os(t){zr.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function Ns(){pr.call(this),this.type="Camera",this.matrixWorldInverse=new Hn,this.projectionMatrix=new Hn,this.projectionMatrixInverse=new Hn}function Ds(t=50,e=1,i=.1,n=2e3){Ns.call(this),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Os.prototype=Object.create(zr.prototype),Os.prototype.constructor=Os,Os.prototype.isShaderMaterial=!0,Os.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ps(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this},Os.prototype.toJSON=function(t){const e=zr.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},Ns.prototype=Object.assign(Object.create(pr.prototype),{constructor:Ns,isCamera:!0,copy:function(t,e){return pr.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){pr.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(t,e){pr.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),Ds.prototype=Object.assign(Object.create(Ns.prototype),{constructor:Ds,isPerspectiveCamera:!0,copy:function(t,e){return Ns.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){const e=.5*this.getFilmHeight()/t;this.fov=2*nn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){const t=Math.tan(.5*nn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*nn.RAD2DEG*Math.atan(Math.tan(.5*nn.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=this.near;let e=t*Math.tan(.5*nn.DEG2RAD*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,o=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/o,n*=s.width/t,i*=s.height/o}const o=this.filmOffset;0!==o&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});const $s=90;function ks(t,e,i){if(pr.call(this),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new Ds($s,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new fn(1,0,0)),this.add(n);const r=new Ds($s,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new fn(-1,0,0)),this.add(r);const s=new Ds($s,1,t,e);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new fn(0,1,0)),this.add(s);const o=new Ds($s,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new fn(0,-1,0)),this.add(o);const a=new Ds($s,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new fn(0,0,1)),this.add(a);const c=new Ds($s,1,t,e);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new fn(0,0,-1)),this.add(c),this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();const h=t.xr.enabled,l=t.getRenderTarget();t.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,s),t.setRenderTarget(i,3),t.render(e,o),t.setRenderTarget(i,4),t.render(e,a),i.texture.generateMipmaps=u,t.setRenderTarget(i,5),t.render(e,c),t.setRenderTarget(l),t.xr.enabled=h}}function zs(t,e,i,n,r,s,o,a,c,h){t=void 0!==t?t:[],e=void 0!==e?e:301,o=void 0!==o?o:ki,hn.call(this,t,e,i,n,r,s,o,a,c,h),this.flipY=!1,this._needsFlipEnvMap=!0}ks.prototype=Object.create(pr.prototype),ks.prototype.constructor=ks,zs.prototype=Object.create(hn.prototype),zs.prototype.constructor=zs,zs.prototype.isCubeTexture=!0,Object.defineProperty(zs.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});class Fs extends dn{constructor(t,e,i){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=i),super(t,t,e),Object.defineProperty(this,"isWebGLCubeRenderTarget",{value:!0}),e=e||{},this.texture=new zs(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=zi,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new As(5,5,5),r=new Os({name:"CubemapFromEquirect",uniforms:Ps(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Es(n,r),o=e.minFilter;e.minFilter===Pi&&(e.minFilter=Ai);return new ks(1,10,this).update(t,s),e.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}function Bs(t,e,i,n,r,s,o,a,c,h,l,u){hn.call(this,null,s,o,a,c,h,n,r,l,u),this.image={data:t||null,width:e||1,height:i||1},this.magFilter=void 0!==c?c:Ii,this.minFilter=void 0!==h?h:Ii,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Bs.prototype=Object.create(hn.prototype),Bs.prototype.constructor=Bs,Bs.prototype.isDataTexture=!0;const js=new On,Hs=new fn;class Us{constructor(t,e,i,n,r,s){this.planes=[void 0!==t?t:new _r,void 0!==e?e:new _r,void 0!==i?i:new _r,void 0!==n?n:new _r,void 0!==r?r:new _r,void 0!==s?s:new _r]}set(t,e,i,n,r,s){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this}clone(){return(new this.constructor).copy(this)}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],h=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],_=i[14],v=i[15];return e[0].setComponents(o-n,l-a,f-u,v-m).normalize(),e[1].setComponents(o+n,l+a,f+u,v+m).normalize(),e[2].setComponents(o+r,l+c,f+d,v+g).normalize(),e[3].setComponents(o-r,l-c,f-d,v-g).normalize(),e[4].setComponents(o-s,l-h,f-p,v-_).normalize(),e[5].setComponents(o+s,l+h,f+p,v+_).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),js.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(js)}intersectsSprite(t){return js.center.set(0,0,0),js.radius=.7071067811865476,js.applyMatrix4(t.matrixWorld),this.intersectsSphere(js)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(Hs.x=n.normal.x>0?t.max.x:t.min.x,Hs.y=n.normal.y>0?t.max.y:t.min.y,Hs.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Hs)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}}function Vs(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Gs(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const s=n.get(e);void 0===s?n.set(e,function(e,n){const r=e.array,s=e.usage,o=t.createBuffer();t.bindBuffer(n,o),t.bufferData(n,r,s),e.onUploadCallback();let a=5126;return r instanceof Float32Array?a=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?i?a=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:r instanceof Int16Array?a=5122:r instanceof Uint32Array?a=5125:r instanceof Int32Array?a=5124:r instanceof Int8Array?a=5120:r instanceof Uint8Array&&(a=5121),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):s.version<e.version&&(!function(e,n,r){const s=n.array,o=n.updateRange;t.bindBuffer(r,e),-1===o.count?t.bufferSubData(r,0,s):(i?t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s,o.offset,o.count):t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s.subarray(o.offset,o.offset+o.count)),o.count=-1)}(s.buffer,e,r),s.version=e.version)}}}class qs extends hs{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,s=e/2,o=Math.floor(i),a=Math.floor(n),c=o+1,h=a+1,l=t/o,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let i=0;i<c;i++){const n=i*l-r;p.push(n,-e,0),f.push(0,0,1),m.push(i/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const i=e+c*t,n=e+c*(t+1),r=e+1+c*(t+1),s=e+1+c*t;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Jr(p,3)),this.setAttribute("normal",new Jr(f,3)),this.setAttribute("uv",new Jr(m,2))}}const Ws={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},Xs={common:{diffuse:{value:new Dr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new sn},uv2Transform:{value:new sn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Dr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new sn}},sprite:{diffuse:{value:new Dr(15658734)},opacity:{value:1},center:{value:new rn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new sn}}},Ys={basic:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.fog]),vertexShader:Ws.meshbasic_vert,fragmentShader:Ws.meshbasic_frag},lambert:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Ws.meshlambert_vert,fragmentShader:Ws.meshlambert_frag},phong:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)},specular:{value:new Dr(1118481)},shininess:{value:30}}]),vertexShader:Ws.meshphong_vert,fragmentShader:Ws.meshphong_frag},standard:{uniforms:Rs([Xs.common,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.roughnessmap,Xs.metalnessmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ws.meshphysical_vert,fragmentShader:Ws.meshphysical_frag},toon:{uniforms:Rs([Xs.common,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.gradientmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Ws.meshtoon_vert,fragmentShader:Ws.meshtoon_frag},matcap:{uniforms:Rs([Xs.common,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.fog,{matcap:{value:null}}]),vertexShader:Ws.meshmatcap_vert,fragmentShader:Ws.meshmatcap_frag},points:{uniforms:Rs([Xs.points,Xs.fog]),vertexShader:Ws.points_vert,fragmentShader:Ws.points_frag},dashed:{uniforms:Rs([Xs.common,Xs.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ws.linedashed_vert,fragmentShader:Ws.linedashed_frag},depth:{uniforms:Rs([Xs.common,Xs.displacementmap]),vertexShader:Ws.depth_vert,fragmentShader:Ws.depth_frag},normal:{uniforms:Rs([Xs.common,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,{opacity:{value:1}}]),vertexShader:Ws.normal_vert,fragmentShader:Ws.normal_frag},sprite:{uniforms:Rs([Xs.sprite,Xs.fog]),vertexShader:Ws.sprite_vert,fragmentShader:Ws.sprite_frag},background:{uniforms:{uvTransform:{value:new sn},t2D:{value:null}},vertexShader:Ws.background_vert,fragmentShader:Ws.background_frag},cube:{uniforms:Rs([Xs.envmap,{opacity:{value:1}}]),vertexShader:Ws.cube_vert,fragmentShader:Ws.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ws.equirect_vert,fragmentShader:Ws.equirect_frag},distanceRGBA:{uniforms:Rs([Xs.common,Xs.displacementmap,{referencePosition:{value:new fn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ws.distanceRGBA_vert,fragmentShader:Ws.distanceRGBA_frag},shadow:{uniforms:Rs([Xs.lights,Xs.fog,{color:{value:new Dr(0)},opacity:{value:1}}]),vertexShader:Ws.shadow_vert,fragmentShader:Ws.shadow_frag}};function Zs(t,e,i,n,r){const s=new Dr(0);let o,a,c=0,h=null,l=0,u=null;function d(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),c=e,d(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,d(s,c)},render:function(i,r,p,f){let m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,_=g.getSession&&g.getSession();_&&"additive"===_.environmentBlendMode&&(m=null),null===m?d(s,c):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.isWebGLCubeRenderTarget||306===m.mapping)?(void 0===a&&(a=new Es(new As(1,1,1),new Os({name:"BackgroundCubeMaterial",uniforms:Ps(Ys.cube.uniforms),vertexShader:Ys.cube.vertexShader,fragmentShader:Ys.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),m.isWebGLCubeRenderTarget&&(m=m.texture),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&m._needsFlipEnvMap?-1:1,h===m&&l===m.version&&u===t.toneMapping||(a.material.needsUpdate=!0,h=m,l=m.version,u=t.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===o&&(o=new Es(new qs(2,2),new Os({name:"BackgroundMaterial",uniforms:Ps(Ys.background.uniforms),vertexShader:Ys.background.vertexShader,fragmentShader:Ys.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),o.material.uniforms.uvTransform.value.copy(m.matrix),h===m&&l===m.version&&u===t.toneMapping||(o.material.needsUpdate=!0,h=m,l=m.version,u=t.toneMapping),i.unshift(o,o.geometry,o.material,0,0,null))}}}function Js(t,e,i,n){const r=t.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||null!==s,a={},c=d(null);let h=c;function l(e){return n.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function u(e){return n.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function d(t){const e=[],i=[],n=[];for(let t=0;t<r;t++)e[t]=0,i[t]=0,n[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function p(){const t=h.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){m(t,0)}function m(i,r){const s=h.newAttributes,o=h.enabledAttributes,a=h.attributeDivisors;if(s[i]=1,0===o[i]&&(t.enableVertexAttribArray(i),o[i]=1),a[i]!==r){(n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),a[i]=r}}function g(){const e=h.newAttributes,i=h.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function _(e,i,r,s,o,a){!0!==n.isWebGL2||5124!==r&&5125!==r?t.vertexAttribPointer(e,i,r,s,o,a):t.vertexAttribIPointer(e,i,r,o,a)}function v(){y(),h!==c&&(h=c,l(h.object))}function y(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:function(r,c,u,v,y){let b=!1;if(o){const e=function(e,i,r){const o=!0===r.wireframe;let c=a[e.id];void 0===c&&(c={},a[e.id]=c);let h=c[i.id];void 0===h&&(h={},c[i.id]=h);let l=h[o];void 0===l&&(l=d(n.isWebGL2?t.createVertexArray():s.createVertexArrayOES()),h[o]=l);return l}(v,u,c);h!==e&&(h=e,l(h.object)),b=function(t,e){const i=h.attributes,n=t.attributes;let r=0;for(const t in n){const e=i[t],s=n[t];if(void 0===e)return!0;if(e.attribute!==s)return!0;if(e.data!==s.data)return!0;r++}return h.attributesNum!==r||h.index!==e}(v,y),b&&function(t,e){const i={},n=t.attributes;let r=0;for(const t in n){const e=n[t],s={};s.attribute=e,e.data&&(s.data=e.data),i[t]=s,r++}h.attributes=i,h.attributesNum=r,h.index=e}(v,y)}else{const t=!0===c.wireframe;h.geometry===v.id&&h.program===u.id&&h.wireframe===t||(h.geometry=v.id,h.program=u.id,h.wireframe=t,b=!0)}!0===r.isInstancedMesh&&(b=!0),null!==y&&i.update(y,34963),b&&(!function(r,s,o,a){if(!1===n.isWebGL2&&(r.isInstancedMesh||a.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();const c=a.attributes,h=o.getAttributes(),l=s.defaultAttributeValues;for(const e in h){const n=h[e];if(n>=0){const s=c[e];if(void 0!==s){const e=s.normalized,r=s.itemSize,o=i.get(s);if(void 0===o)continue;const c=o.buffer,h=o.type,l=o.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,o=i.stride,u=s.offset;i&&i.isInstancedInterleavedBuffer?(m(n,i.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=i.meshPerAttribute*i.count)):f(n),t.bindBuffer(34962,c),_(n,r,h,e,o*l,u*l)}else s.isInstancedBufferAttribute?(m(n,s.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)):f(n),t.bindBuffer(34962,c),_(n,r,h,e,0,0)}else if("instanceMatrix"===e){const e=i.get(r.instanceMatrix);if(void 0===e)continue;const s=e.buffer,o=e.type;m(n+0,1),m(n+1,1),m(n+2,1),m(n+3,1),t.bindBuffer(34962,s),t.vertexAttribPointer(n+0,4,o,!1,64,0),t.vertexAttribPointer(n+1,4,o,!1,64,16),t.vertexAttribPointer(n+2,4,o,!1,64,32),t.vertexAttribPointer(n+3,4,o,!1,64,48)}else if("instanceColor"===e){const e=i.get(r.instanceColor);if(void 0===e)continue;const s=e.buffer,o=e.type;m(n,1),t.bindBuffer(34962,s),t.vertexAttribPointer(n,3,o,!1,12,0)}else if(void 0!==l){const i=l[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(n,i);break;case 3:t.vertexAttrib3fv(n,i);break;case 4:t.vertexAttrib4fv(n,i);break;default:t.vertexAttrib1fv(n,i)}}}}g()}(r,c,u,v),null!==y&&t.bindBuffer(34963,i.get(y).buffer))},reset:v,resetDefaultState:y,dispose:function(){v();for(const t in a){const e=a[t];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t]}},releaseStatesOfGeometry:function(t){if(void 0===a[t.id])return;const e=a[t.id];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t.id]},releaseStatesOfProgram:function(t){for(const e in a){const i=a[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)u(n[t].object),delete n[t];delete i[t.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function Ks(t,e,i,n){const r=n.isWebGL2;let s;this.setMode=function(t){s=t},this.render=function(e,n){t.drawArrays(s,e,n),i.update(n,s,1)},this.renderInstances=function(n,o,a){if(0===a)return;let c,h;if(r)c=t,h="drawArraysInstanced";else if(c=e.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===c)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[h](s,n,o,a),i.update(o,s,a)}}function Qs(t,e,i){let n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==i.precision?i.precision:"highp";const a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);const c=!0===i.logarithmicDepthBuffer,h=t.getParameter(34930),l=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),_=l>0,v=s||!!e.get("OES_texture_float");return{isWebGL2:s,getMaxAnisotropy:function(){if(void 0!==n)return n;const i=e.get("EXT_texture_filter_anisotropic");return n=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,n},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:_,floatFragmentTextures:v,floatVertexTextures:_&&v,maxSamples:s?t.getParameter(36183):0}}function to(t){const e=this;let i=null,n=0,r=!1,s=!1;const o=new _r,a=new sn,c={value:null,needsUpdate:!1};function h(){c.value!==i&&(c.value=i,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function l(t,i,n,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=c.value,!0!==r||null===h){const e=n+4*s,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)o.copy(t[e]).applyMatrix4(r,a),o.normal.toArray(h,i),h[i+3]=o.constant}c.value=h,c.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,s){const o=0!==t.length||e||0!==n||r;return r=e,i=l(t,s,0),n=t.length,o},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1,h()},this.setState=function(e,o,a){const u=e.clippingPlanes,d=e.clipIntersection,p=e.clipShadows,f=t.get(e);if(!r||null===u||0===u.length||s&&!p)s?l(null):h();else{const t=s?0:n,e=4*t;let r=f.clippingState||null;c.value=r,r=l(u,o,e,a);for(let t=0;t!==e;++t)r[t]=i[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function eo(t){let e=new WeakMap;function i(t,e){return 303===e?t.mapping=301:304===e&&(t.mapping=302),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(303===s||304===s){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const o=t.getRenderList(),a=t.getRenderTarget(),c=new Fs(s.height/2);return c.fromEquirectangularTexture(t,r),e.set(r,c),t.setRenderTarget(a),t.setRenderList(o),r.addEventListener("dispose",n),i(c.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}function io(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function no(t,e,i,n){const r={},s=new WeakMap;function o(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",o),delete r[a.id];const c=s.get(a);c&&(e.remove(c),s.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(t){const i=[],n=t.index,r=t.attributes.position;let o=0;if(null!==n){const t=n.array;o=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{const t=r.array;o=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const a=new(Qr(i)>65535?Yr:Wr)(i,1);a.version=o;const c=s.get(t);c&&e.remove(c),s.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",o),r[e.id]=!0,i.memory.geometries++),e},update:function(t){const i=t.attributes;for(const t in i)e.update(i[t],34962);const n=t.morphAttributes;for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t++)e.update(i[t],34962)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&a(t)}else a(t);return s.get(t)}}}function ro(t,e,i,n){const r=n.isWebGL2;let s,o,a;this.setMode=function(t){s=t},this.setIndex=function(t){o=t.type,a=t.bytesPerElement},this.render=function(e,n){t.drawElements(s,n,o,e*a),i.update(n,s,1)},this.renderInstances=function(n,c,h){if(0===h)return;let l,u;if(r)l=t,u="drawElementsInstanced";else if(l=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===l)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](s,c,o,n*a,h),i.update(c,s,h)}}function so(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,i,n){switch(e.calls++,i){case 4:e.triangles+=n*(t/3);break;case 1:e.lines+=n*(t/2);break;case 3:e.lines+=n*(t-1);break;case 2:e.lines+=n*t;break;case 0:e.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function oo(t,e){return t[0]-e[0]}function ao(t,e){return Math.abs(e[1])-Math.abs(t[1])}function co(t){const e={},i=new Float32Array(8),n=[];for(let t=0;t<8;t++)n[t]=[t,0];return{update:function(r,s,o,a){const c=r.morphTargetInfluences,h=void 0===c?0:c.length;let l=e[s.id];if(void 0===l){l=[];for(let t=0;t<h;t++)l[t]=[t,0];e[s.id]=l}for(let t=0;t<h;t++){const e=l[t];e[0]=t,e[1]=c[t]}l.sort(ao);for(let t=0;t<8;t++)t<h&&l[t][1]?(n[t][0]=l[t][0],n[t][1]=l[t][1]):(n[t][0]=Number.MAX_SAFE_INTEGER,n[t][1]=0);n.sort(oo);const u=o.morphTargets&&s.morphAttributes.position,d=o.morphNormals&&s.morphAttributes.normal;let p=0;for(let t=0;t<8;t++){const e=n[t],r=e[0],o=e[1];r!==Number.MAX_SAFE_INTEGER&&o?(u&&s.getAttribute("morphTarget"+t)!==u[r]&&s.setAttribute("morphTarget"+t,u[r]),d&&s.getAttribute("morphNormal"+t)!==d[r]&&s.setAttribute("morphNormal"+t,d[r]),i[t]=o,p+=o):(u&&!0===s.hasAttribute("morphTarget"+t)&&s.deleteAttribute("morphTarget"+t),d&&!0===s.hasAttribute("morphNormal"+t)&&s.deleteAttribute("morphNormal"+t),i[t]=0)}const f=s.morphTargetsRelative?1:1-p;a.getUniforms().setValue(t,"morphTargetBaseInfluence",f),a.getUniforms().setValue(t,"morphTargetInfluences",i)}}}function ho(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(t){const o=n.render.frame,a=t.geometry,c=e.get(t,a);return r.get(c)!==o&&(e.update(c),r.set(c,o)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",s)&&t.addEventListener("dispose",s),i.update(t.instanceMatrix,34962),null!==t.instanceColor&&i.update(t.instanceColor,34962)),c},dispose:function(){r=new WeakMap}}}function lo(t=null,e=1,i=1,n=1){hn.call(this,null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Ii,this.minFilter=Ii,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function uo(t=null,e=1,i=1,n=1){hn.call(this,null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Ii,this.minFilter=Ii,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Ys.physical={uniforms:Rs([Ys.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new rn(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Dr(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Ws.meshphysical_vert,fragmentShader:Ws.meshphysical_frag},lo.prototype=Object.create(hn.prototype),lo.prototype.constructor=lo,lo.prototype.isDataTexture2DArray=!0,uo.prototype=Object.create(hn.prototype),uo.prototype.constructor=uo,uo.prototype.isDataTexture3D=!0;const po=new hn,fo=new lo,mo=new uo,go=new zs,_o=[],vo=[],yo=new Float32Array(16),bo=new Float32Array(9),xo=new Float32Array(4);function wo(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=_o[r];if(void 0===s&&(s=new Float32Array(r),_o[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function So(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Mo(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function To(t,e){let i=vo[e];void 0===i&&(i=new Int32Array(e),vo[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Co(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Eo(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(So(i,e))return;t.uniform2fv(this.addr,e),Mo(i,e)}}function Io(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(So(i,e))return;t.uniform3fv(this.addr,e),Mo(i,e)}}function Ao(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(So(i,e))return;t.uniform4fv(this.addr,e),Mo(i,e)}}function Po(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;xo.set(n),t.uniformMatrix2fv(this.addr,!1,xo),Mo(i,n)}}function Ro(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;bo.set(n),t.uniformMatrix3fv(this.addr,!1,bo),Mo(i,n)}}function Lo(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;yo.set(n),t.uniformMatrix4fv(this.addr,!1,yo),Mo(i,n)}}function Oo(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(e||po,r)}function No(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||fo,r)}function Do(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||mo,r)}function $o(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(e||go,r)}function ko(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function zo(t,e){const i=this.cache;So(i,e)||(t.uniform2iv(this.addr,e),Mo(i,e))}function Fo(t,e){const i=this.cache;So(i,e)||(t.uniform3iv(this.addr,e),Mo(i,e))}function Bo(t,e){const i=this.cache;So(i,e)||(t.uniform4iv(this.addr,e),Mo(i,e))}function jo(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Ho(t,e){t.uniform1fv(this.addr,e)}function Uo(t,e){t.uniform1iv(this.addr,e)}function Vo(t,e){t.uniform2iv(this.addr,e)}function Go(t,e){t.uniform3iv(this.addr,e)}function qo(t,e){t.uniform4iv(this.addr,e)}function Wo(t,e){const i=wo(e,this.size,2);t.uniform2fv(this.addr,i)}function Xo(t,e){const i=wo(e,this.size,3);t.uniform3fv(this.addr,i)}function Yo(t,e){const i=wo(e,this.size,4);t.uniform4fv(this.addr,i)}function Zo(t,e){const i=wo(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Jo(t,e){const i=wo(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Ko(t,e){const i=wo(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Qo(t,e,i){const n=e.length,r=To(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTexture2D(e[t]||po,r[t])}function ta(t,e,i){const n=e.length,r=To(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTextureCube(e[t]||go,r[t])}function ea(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Co;case 35664:return Eo;case 35665:return Io;case 35666:return Ao;case 35674:return Po;case 35675:return Ro;case 35676:return Lo;case 5124:case 35670:return ko;case 35667:case 35671:return zo;case 35668:case 35672:return Fo;case 35669:case 35673:return Bo;case 5125:return jo;case 35678:case 36198:case 36298:case 36306:case 35682:return Oo;case 35679:case 36299:case 36307:return Do;case 35680:case 36300:case 36308:case 36293:return $o;case 36289:case 36303:case 36311:case 36292:return No}}(e.type)}function ia(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ho;case 35664:return Wo;case 35665:return Xo;case 35666:return Yo;case 35674:return Zo;case 35675:return Jo;case 35676:return Ko;case 5124:case 35670:return Uo;case 35667:case 35671:return Vo;case 35668:case 35672:return Go;case 35669:case 35673:return qo;case 35678:case 36198:case 36298:case 36306:case 35682:return Qo;case 35680:case 36300:case 36308:case 36293:return ta}}(e.type)}function na(t){this.id=t,this.seq=[],this.map={}}ia.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Mo(e,t)},na.prototype.setValue=function(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}};const ra=/(\w+)(\])?(\[|\.)?/g;function sa(t,e){t.seq.push(e),t.map[e.id]=e}function oa(t,e,i){const n=t.name,r=n.length;for(ra.lastIndex=0;;){const s=ra.exec(n),o=ra.lastIndex;let a=s[1];const c="]"===s[2],h=s[3];if(c&&(a|=0),void 0===h||"["===h&&o+2===r){sa(i,void 0===h?new ea(a,t,e):new ia(a,t,e));break}{let t=i.map[a];void 0===t&&(t=new na(a),sa(i,t)),i=t}}}function aa(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,35718);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);oa(i,t.getUniformLocation(e,i.name),this)}}function ca(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}aa.prototype.setValue=function(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)},aa.prototype.setOptional=function(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)},aa.upload=function(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],o=i[s.id];!1!==o.needsUpdate&&s.setValue(t,o.value,n)}},aa.seqWithValue=function(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i};let ha=0;function la(t){switch(t){case Xi:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function ua(t,e,i){const n=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+"\n"+r+function(t){const e=t.split("\n");for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(t.getShaderSource(e))}function da(t,e){const i=la(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function pa(t,e){const i=la(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function fa(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ma(t){return""!==t}function ga(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function _a(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const va=/^[ \t]*#include +<([\w\d./]+)>/gm;function ya(t){return t.replace(va,ba)}function ba(t,e){const i=Ws[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ya(i)}const xa=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,wa=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Sa(t){return t.replace(wa,Ta).replace(xa,Ma)}function Ma(t,e,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Ta(t,e,i,n)}function Ta(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Ca(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Ea(t,e,i,n){const r=t.getContext(),s=i.defines;let o=i.vertexShader,a=i.fragmentShader;const c=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case 306:case 307:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),l=function(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case 302:case 307:e="ENVMAP_MODE_REFRACTION"}return e}(i),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),d=t.gammaFactor>0?t.gammaFactor:1,p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ma).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),m=r.createProgram();let g,_,v=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=[f].filter(ma).join("\n"),g.length>0&&(g+="\n"),_=[p,f].filter(ma).join("\n"),_.length>0&&(_+="\n")):(g=[Ca(i),"#define SHADER_NAME "+i.shaderName,f,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ma).join("\n"),_=[p,Ca(i),"#define SHADER_NAME "+i.shaderName,f,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+l:"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Ws.tonemapping_pars_fragment:"",0!==i.toneMapping?fa("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Ws.encodings_pars_fragment,i.map?da("mapTexelToLinear",i.mapEncoding):"",i.matcap?da("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?da("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?da("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?da("lightMapTexelToLinear",i.lightMapEncoding):"",pa("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ma).join("\n")),o=ya(o),o=ga(o,i),o=_a(o,i),a=ya(a),a=ga(a,i),a=_a(a,i),o=Sa(o),a=Sa(a),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(v="#version 300 es\n",g=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Ki?"":"out highp vec4 pc_fragColor;",i.glslVersion===Ki?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const y=v+_+a,b=ca(r,35633,v+g+o),x=ca(r,35632,y);if(r.attachShader(m,b),r.attachShader(m,x),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),t.debug.checkShaderErrors){const t=r.getProgramInfoLog(m).trim(),e=r.getShaderInfoLog(b).trim(),i=r.getShaderInfoLog(x).trim();let n=!0,s=!0;if(!1===r.getProgramParameter(m,35714)){n=!1;const e=ua(r,b,"vertex"),i=ua(r,x,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(m,35715),"gl.getProgramInfoLog",t,e,i)}else""!==t?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",t):""!==e&&""!==i||(s=!1);s&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:g},fragmentShader:{log:i,prefix:_}})}let w,S;return r.deleteShader(b),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new aa(r,m)),w},this.getAttributes=function(){return void 0===S&&(S=function(t,e){const i={},n=t.getProgramParameter(e,35721);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r).name;i[n]=t.getAttribLocation(e,n)}return i}(r,m)),S},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.name=i.shaderName,this.id=ha++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=x,this}function Ia(t,e,i,n,r,s){const o=[],a=n.isWebGL2,c=n.logarithmicDepthBuffer,h=n.floatVertexTextures,l=n.maxVertexUniforms,u=n.vertexTextures;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function m(t){let e;return t&&t.isTexture?e=t.encoding:t&&t.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=Xi,e}return{getParameters:function(r,o,f,g,_){const v=g.fog,y=r.isMeshStandardMaterial?g.environment:null,b=e.get(r.envMap||y),x=p[r.type],w=_.isSkinnedMesh?function(t){const e=t.skeleton.bones;if(h)return 1024;{const t=l,i=Math.floor((t-20)/4),n=Math.min(i,e.length);return n<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+n+"."),0):n}}(_):0;let S,M;if(null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.")),x){const t=Ys[x];S=t.vertexShader,M=t.fragmentShader}else S=r.vertexShader,M=r.fragmentShader;const T=t.getRenderTarget();return{isWebGL2:a,shaderID:x,shaderName:r.type,vertexShader:S,fragmentShader:M,defines:r.defines,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:u,outputEncoding:null!==T?m(T.texture):t.outputEncoding,map:!!r.map,mapEncoding:m(r.map),matcap:!!r.matcap,matcapEncoding:m(r.matcap),envMap:!!b,envMapMode:b&&b.mapping,envMapEncoding:m(b),envMapCubeUV:!!b&&(306===b.mapping||307===b.mapping),lightMap:!!r.lightMap,lightMapEncoding:m(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:m(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,transmissionMap:!!r.transmissionMap,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmissionMap||!r.displacementMap),fog:!!v,useFog:r.fog,fogExp2:v&&v.isFogExp2,flatShading:r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:c,skinning:r.skinning&&w>0,maxBones:w,useVertexTexture:h,morphTargets:r.morphTargets,morphNormals:r.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&f.length>0,shadowMapType:t.shadowMap.type,toneMapping:r.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||i.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t<f.length;t++)i.push(e[f[t]]);i.push(t.outputEncoding),i.push(t.gammaFactor)}return i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=p[t.type];let i;if(e){const t=Ys[e];i=Ls.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=o.length;t<e;t++){const e=o[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new Ea(t,i,e,r),o.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=o.indexOf(t);o[e]=o[o.length-1],o.pop(),t.destroy()}},programs:o}}function Aa(){let t=new WeakMap;return{get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Pa(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ra(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function La(t){const e=[];let i=0;const n=[],r=[],s={id:-1};function o(n,r,o,a,c,h){let l=e[i];const u=t.get(o);return void 0===l?(l={id:n.id,object:n,geometry:r,material:o,program:u.program||s,groupOrder:a,renderOrder:n.renderOrder,z:c,group:h},e[i]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=o,l.program=u.program||s,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=c,l.group=h),i++,l}return{opaque:n,transparent:r,init:function(){i=0,n.length=0,r.length=0},push:function(t,e,i,s,a,c){const h=o(t,e,i,s,a,c);(!0===i.transparent?r:n).push(h)},unshift:function(t,e,i,s,a,c){const h=o(t,e,i,s,a,c);(!0===i.transparent?r:n).unshift(h)},finish:function(){for(let t=i,n=e.length;t<n;t++){const i=e[t];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Pa),r.length>1&&r.sort(e||Ra)}}}function Oa(t){let e=new WeakMap;return{get:function(i,n){const r=e.get(i);let s;return void 0===r?(s=new La(t),e.set(i,new WeakMap),e.get(i).set(n,s)):(s=r.get(n),void 0===s&&(s=new La(t),r.set(n,s))),s},dispose:function(){e=new WeakMap}}}function Na(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new fn,color:new Dr};break;case"SpotLight":i={position:new fn,direction:new fn,color:new Dr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new fn,color:new Dr,distance:0,decay:0};break;case"HemisphereLight":i={direction:new fn,skyColor:new Dr,groundColor:new Dr};break;case"RectAreaLight":i={color:new Dr,position:new fn,halfWidth:new fn,halfHeight:new fn}}return t[e.id]=i,i}}}let Da=0;function $a(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ka(t,e){const i=new Na,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)r.probe.push(new fn);const s=new fn,o=new Hn,a=new Hn;return{setup:function(s){let o=0,a=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,l=0,u=0,d=0,p=0,f=0,m=0,g=0;s.sort($a);for(let t=0,e=s.length;t<e;t++){const e=s[t],_=e.color,v=e.intensity,y=e.distance,b=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=_.r*v,a+=_.g*v,c+=_.b*v;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],v);else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.directionalShadow[h]=i,r.directionalShadowMap[h]=b,r.directionalShadowMatrix[h]=e.shadow.matrix,f++}r.directional[h]=t,h++}else if(e.isSpotLight){const t=i.get(e);if(t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(_).multiplyScalar(v),t.distance=y,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.spotShadow[u]=i,r.spotShadowMap[u]=b,r.spotShadowMatrix[u]=e.shadow.matrix,g++}r.spot[u]=t,u++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(_).multiplyScalar(v),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[d]=t,d++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,r.pointShadow[l]=i,r.pointShadowMap[l]=b,r.pointShadowMatrix[l]=e.shadow.matrix,m++}r.point[l]=t,l++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(v),t.groundColor.copy(e.groundColor).multiplyScalar(v),r.hemi[p]=t,p++}}d>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Xs.LTC_FLOAT_1,r.rectAreaLTC2=Xs.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Xs.LTC_HALF_1,r.rectAreaLTC2=Xs.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=a,r.ambient[2]=c;const _=r.hash;_.directionalLength===h&&_.pointLength===l&&_.spotLength===u&&_.rectAreaLength===d&&_.hemiLength===p&&_.numDirectionalShadows===f&&_.numPointShadows===m&&_.numSpotShadows===g||(r.directional.length=h,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,_.directionalLength=h,_.pointLength=l,_.spotLength=u,_.rectAreaLength=d,_.hemiLength=p,_.numDirectionalShadows=f,_.numPointShadows=m,_.numSpotShadows=g,r.version=Da++)},setupView:function(t,e){let i=0,n=0,c=0,h=0,l=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=r.spot[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),c++}else if(d.isRectAreaLight){const t=r.rectArea[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),o.copy(d.matrixWorld),o.premultiply(u),a.extractRotation(o),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(d.isPointLight){const t=r.point[n];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const t=r.hemi[l];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),t.direction.normalize(),l++}}},state:r}}function za(t,e){const i=new ka(t,e),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(){i.setup(n)},setupLightsView:function(t){i.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){r.push(t)}}}function Fa(t,e){let i=new WeakMap;return{get:function(n,r=0){let s;return!1===i.has(n)?(s=new za(t,e),i.set(n,[]),i.get(n).push(s)):r>=i.get(n).length?(s=new za(t,e),i.get(n).push(s)):s=i.get(n)[r],s},dispose:function(){i=new WeakMap}}}function Ba(t){zr.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}function ja(t){zr.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new fn,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}Ba.prototype=Object.create(zr.prototype),Ba.prototype.constructor=Ba,Ba.prototype.isMeshDepthMaterial=!0,Ba.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},ja.prototype=Object.create(zr.prototype),ja.prototype.constructor=ja,ja.prototype.isMeshDistanceMaterial=!0,ja.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};function Ha(t,e,i){let n=new Us;const r=new rn,s=new rn,o=new un,a=[],c=[],h={},l={0:1,1:0,2:2},u=new Os({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new rn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),d=u.clone();d.defines.HORIZONTAL_PASS=1;const p=new hs;p.setAttribute("position",new Hr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Es(p,u),m=this;function g(i,n){const r=e.update(f);u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,u,f,null),d.uniforms.shadow_pass.value=i.mapPass.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,d,f,null)}function _(t,e,i){const n=t<<0|e<<1|i<<2;let r=a[n];return void 0===r&&(r=new Ba({depthPacking:3201,morphTargets:t,skinning:e}),a[n]=r),r}function v(t,e,i){const n=t<<0|e<<1|i<<2;let r=c[n];return void 0===r&&(r=new ja({morphTargets:t,skinning:e}),c[n]=r),r}function y(e,i,n,r,s,o,a){let c=null,u=_,d=e.customDepthMaterial;if(!0===r.isPointLight&&(u=v,d=e.customDistanceMaterial),void 0===d){let t=!1;!0===n.morphTargets&&(t=i.morphAttributes&&i.morphAttributes.position&&i.morphAttributes.position.length>0);let r=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e));c=u(t,r,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){const t=c.uuid,e=n.uuid;let i=h[t];void 0===i&&(i={},h[t]=i);let r=i[e];void 0===r&&(r=c.clone(),i[e]=r),c=r}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=3===a?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:l[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=s,c.farDistance=o),c}function b(i,r,s,o,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],l=r[h.materialIndex];if(l&&l.visible){const e=y(i,n,l,o,s.near,s.far,a);t.renderBufferDirect(s,null,n,e,i,h)}}}else if(r.visible){const e=y(i,n,r,o,s.near,s.far,a);t.renderBufferDirect(s,null,n,e,i,null)}}const c=i.children;for(let t=0,e=c.length;t<e;t++)b(c[t],r,s,o,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,a,c){if(!1===m.enabled)return;if(!1===m.autoUpdate&&!1===m.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let h=0,l=e.length;h<l;h++){const l=e[h],u=l.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),s.copy(u.mapSize),(r.x>i||r.y>i)&&(r.x>i&&(s.x=Math.floor(i/p.x),r.x=s.x*p.x,u.mapSize.x=s.x),r.y>i&&(s.y=Math.floor(i/p.y),r.y=s.y*p.y,u.mapSize.y=s.y)),null===u.map&&!u.isPointLightShadow&&3===this.type){const t={minFilter:Ai,magFilter:Ai,format:zi};u.map=new dn(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.mapPass=new dn(r.x,r.y,t),u.camera.updateProjectionMatrix()}if(null===u.map){const t={minFilter:Ii,magFilter:Ii,format:zi};u.map=new dn(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const e=u.getViewport(t);o.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),d.viewport(o),u.updateMatrices(l,t),n=u.getFrustum(),b(a,c,u.camera,l,this.type)}u.isPointLightShadow||3!==this.type||g(u,c),u.needsUpdate=!1}m.needsUpdate=!1,t.setRenderTarget(h,l,u)}}function Ua(t,e,i){const n=i.isWebGL2;const r=new function(){let e=!1;const i=new un;let n=null;const r=new un(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,o,a){!0===a&&(e*=o,n*=o,s*=o),i.set(e,n,s,o),!1===r.equals(i)&&(t.clearColor(e,n,s,o),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){let e=!1,i=null,n=null,r=null;return{setTest:function(t){t?O(2929):N(2929)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},o=new function(){let e=!1,i=null,n=null,r=null,s=null,o=null,a=null,c=null,h=null;return{setTest:function(t){e||(t?O(2960):N(2960))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,o){n===e&&r===i&&s===o||(t.stencilFunc(e,i,o),n=e,r=i,s=o)},setOp:function(e,i,n){o===e&&a===i&&c===n||(t.stencilOp(e,i,n),o=e,a=i,c=n)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,o=null,a=null,c=null,h=null}}};let a={},c=null,h=null,l=null,u=null,d=null,p=null,f=null,m=null,g=null,_=!1,v=null,y=null,b=null,x=null,w=null;const S=t.getParameter(35661);let M=!1,T=0;const C=t.getParameter(7938);-1!==C.indexOf("WebGL")?(T=parseFloat(/^WebGL (\d)/.exec(C)[1]),M=T>=1):-1!==C.indexOf("OpenGL ES")&&(T=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),M=T>=2);let E=null,I={};const A=new un,P=new un;function R(e,i,n){const r=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<n;e++)t.texImage2D(i+e,0,6408,1,1,0,6408,5121,r);return s}const L={};function O(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function N(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}L[3553]=R(3553,3553,1),L[34067]=R(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),O(2929),s.setFunc(3),z(!1),F(1),O(2884),k(0);const D={[Mi]:32774,101:32778,102:32779};if(n)D[103]=32775,D[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(D[103]=t.MIN_EXT,D[104]=t.MAX_EXT)}const $={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function k(e,i,n,r,s,o,a,c){if(0!==e){if(h||(O(3042),h=!0),5===e)s=s||i,o=o||n,a=a||r,i===u&&s===f||(t.blendEquationSeparate(D[i],D[s]),u=i,f=s),n===d&&r===p&&o===m&&a===g||(t.blendFuncSeparate($[n],$[r],$[o],$[a]),d=n,p=r,m=o,g=a),l=e,_=null;else if(e!==l||c!==_){if(u===Mi&&f===Mi||(t.blendEquation(32774),u=Mi,f=Mi),c)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}d=null,p=null,m=null,g=null,l=e,_=c}}else h&&(N(3042),h=!1)}function z(e){v!==e&&(e?t.frontFace(2304):t.frontFace(2305),v=e)}function F(e){0!==e?(O(2884),e!==y&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):N(2884),y=e}function B(e,i,n){e?(O(32823),x===i&&w===n||(t.polygonOffset(i,n),x=i,w=n)):N(32823)}function j(e){void 0===e&&(e=33984+S-1),E!==e&&(t.activeTexture(e),E=e)}return{buffers:{color:r,depth:s,stencil:o},enable:O,disable:N,useProgram:function(e){return c!==e&&(t.useProgram(e),c=e,!0)},setBlending:k,setMaterial:function(t,e){2===t.side?N(2884):O(2884);let i=1===t.side;e&&(i=!i),z(i),1===t.blending&&!1===t.transparent?k(0):k(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),r.setMask(t.colorWrite);const n=t.stencilWrite;o.setTest(n),n&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),B(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:z,setCullFace:F,setLineWidth:function(e){e!==b&&(M&&t.lineWidth(e),b=e)},setPolygonOffset:B,setScissorTest:function(t){t?O(3089):N(3089)},activeTexture:j,bindTexture:function(e,i){null===E&&j();let n=I[E];void 0===n&&(n={type:void 0,texture:void 0},I[E]=n),n.type===e&&n.texture===i||(t.bindTexture(e,i||L[e]),n.type=e,n.texture=i)},unbindTexture:function(){const e=I[E];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===A.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),A.copy(e))},viewport:function(e){!1===P.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),P.copy(e))},reset:function(){a={},E=null,I={},c=null,h=null,l=null,u=null,d=null,p=null,f=null,m=null,g=null,_=!1,v=null,y=null,b=null,x=null,w=null,r.reset(),s.reset(),o.reset()}}}function Va(t,e,i,n,r,s,o){const a=r.isWebGL2,c=r.maxTextures,h=r.maxCubemapSize,l=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(t,e,i,n){let r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?nn.floorPowerOfTwo:Math.floor,s=n(r*t.width),o=n(r*t.height);void 0===p&&(p=m(s,o));const a=i?m(s,o):p;a.width=s,a.height=o;return a.getContext("2d").drawImage(t,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+o+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function _(t){return nn.isPowerOfTwo(t.width)&&nn.isPowerOfTwo(t.height)}function v(t,e){return t.generateMipmaps&&e&&t.minFilter!==Ii&&t.minFilter!==Ai}function y(e,i,r,s){t.generateMipmap(e);n.get(i).__maxMipLevel=Math.log(Math.max(r,s))*Math.LOG2E}function b(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let s=n;return 6403===n&&(5126===r&&(s=33326),5131===r&&(s=33325),5121===r&&(s=33321)),6407===n&&(5126===r&&(s=34837),5131===r&&(s=34843),5121===r&&(s=32849)),6408===n&&(5126===r&&(s=34836),5131===r&&(s=34842),5121===r&&(s=32856)),33325!==s&&33326!==s&&34842!==s&&34836!==s||e.get("EXT_color_buffer_float"),s}function x(t){return t===Ii||1004===t||1005===t?9728:9729}function w(e){const i=e.target;i.removeEventListener("dispose",w),function(e){const i=n.get(e);if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture),n.remove(e)}(i),i.isVideoTexture&&d.delete(i),o.memory.textures--}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e),r=n.get(e.texture);if(!e)return;void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);n.remove(e.texture),n.remove(e)}(i),o.memory.textures--}let M=0;function T(t,e){const r=n.get(t);if(t.isVideoTexture&&function(t){const e=o.render.frame;d.get(t)!==e&&(d.set(t,e),t.update())}(t),t.version>0&&r.__version!==t.version){const i=t.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void R(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+e),i.bindTexture(3553,r.__webglTexture)}function C(e,r){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,n,r){if(6!==n.image.length)return;P(e,n),i.activeTexture(33984+r),i.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);const o=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),c=n.image[0]&&n.image[0].isDataTexture,l=[];for(let t=0;t<6;t++)l[t]=o||c?c?n.image[t].image:n.image[t]:g(n.image[t],!1,!0,h);const u=l[0],d=_(u)||a,p=s.convert(n.format),f=s.convert(n.type),m=b(n.internalFormat,p,f);let x;if(A(34067,n,d),o){for(let t=0;t<6;t++){x=l[t].mipmaps;for(let e=0;e<x.length;e++){const r=x[e];n.format!==zi&&n.format!==ki?null!==p?i.compressedTexImage2D(34069+t,e,m,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+t,e,m,r.width,r.height,0,p,f,r.data)}}e.__maxMipLevel=x.length-1}else{x=n.mipmaps;for(let t=0;t<6;t++)if(c){i.texImage2D(34069+t,0,m,l[t].width,l[t].height,0,p,f,l[t].data);for(let e=0;e<x.length;e++){const n=x[e].image[t].image;i.texImage2D(34069+t,e+1,m,n.width,n.height,0,p,f,n.data)}}else{i.texImage2D(34069+t,0,m,p,f,l[t]);for(let e=0;e<x.length;e++){const n=x[e];i.texImage2D(34069+t,e+1,m,p,f,n.image[t])}}e.__maxMipLevel=x.length}v(n,d)&&y(34067,n,u.width,u.height);e.__version=n.version,n.onUpdate&&n.onUpdate(n)}(o,e,r):(i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture))}const E={[Ti]:10497,[Ci]:33071,[Ei]:33648},I={[Ii]:9728,1004:9984,1005:9986,[Ai]:9729,1007:9985,[Pi]:9987};function A(i,s,o){o?(t.texParameteri(i,10242,E[s.wrapS]),t.texParameteri(i,10243,E[s.wrapT]),32879!==i&&35866!==i||t.texParameteri(i,32882,E[s.wrapR]),t.texParameteri(i,10240,I[s.magFilter]),t.texParameteri(i,10241,I[s.minFilter])):(t.texParameteri(i,10242,33071),t.texParameteri(i,10243,33071),32879!==i&&35866!==i||t.texParameteri(i,32882,33071),s.wrapS===Ci&&s.wrapT===Ci||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,10240,x(s.magFilter)),t.texParameteri(i,10241,x(s.minFilter)),s.minFilter!==Ii&&s.minFilter!==Ai&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const c=e.get("EXT_texture_filter_anisotropic");if(c){if(s.type===Ni&&null===e.get("OES_texture_float_linear"))return;if(s.type===Di&&null===(a||e.get("OES_texture_half_float_linear")))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function P(e,i){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",w),e.__webglTexture=t.createTexture(),o.memory.textures++)}function R(e,n,r){let o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),P(e,n),i.activeTexture(33984+r),i.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);const c=function(t){return!a&&(t.wrapS!==Ci||t.wrapT!==Ci||t.minFilter!==Ii&&t.minFilter!==Ai)}(n)&&!1===_(n.image),h=g(n.image,c,!1,l),u=_(h)||a,d=s.convert(n.format);let p,f=s.convert(n.type),m=b(n.internalFormat,d,f);A(o,n,u);const x=n.mipmaps;if(n.isDepthTexture)m=6402,a?m=n.type===Ni?36012:n.type===Oi?33190:n.type===$i?35056:33189:n.type===Ni&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===Fi&&6402===m&&n.type!==Li&&n.type!==Oi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=Li,f=s.convert(n.type)),n.format===Bi&&6402===m&&(m=34041,n.type!==$i&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=$i,f=s.convert(n.type))),i.texImage2D(3553,0,m,h.width,h.height,0,d,f,null);else if(n.isDataTexture)if(x.length>0&&u){for(let t=0,e=x.length;t<e;t++)p=x[t],i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,m,h.width,h.height,0,d,f,h.data),e.__maxMipLevel=0;else if(n.isCompressedTexture){for(let t=0,e=x.length;t<e;t++)p=x[t],n.format!==zi&&n.format!==ki?null!==d?i.compressedTexImage2D(3553,t,m,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);e.__maxMipLevel=x.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(x.length>0&&u){for(let t=0,e=x.length;t<e;t++)p=x[t],i.texImage2D(3553,t,m,d,f,p);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,m,d,f,h),e.__maxMipLevel=0;v(n,u)&&y(o,n,h.width,h.height),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function L(e,r,o,a){const c=s.convert(r.texture.format),h=s.convert(r.texture.type),l=b(r.texture.internalFormat,c,h);i.texImage2D(a,0,l,r.width,r.height,0,c,h,null),t.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,o,a,n.get(r.texture).__webglTexture,0),t.bindFramebuffer(36160,null)}function O(e,i,n){if(t.bindRenderbuffer(36161,e),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Ni?r=36012:e.type===Oi&&(r=33190));const n=D(i);t.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else t.renderbufferStorage(36161,r,i.width,i.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const e=D(i);t.renderbufferStorageMultisample(36161,e,35056,i.width,i.height)}else t.renderbufferStorage(36161,34041,i.width,i.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=s.convert(i.texture.format),r=s.convert(i.texture.type),o=b(i.texture.internalFormat,e,r);if(n){const e=D(i);t.renderbufferStorageMultisample(36161,e,o,i.width,i.height)}else t.renderbufferStorage(36161,o,i.width,i.height)}t.bindRenderbuffer(36161,null)}function N(e){const i=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),T(i.depthTexture,0);const r=n.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Fi)t.framebufferTexture2D(36160,36096,3553,r,0);else{if(i.depthTexture.format!==Bi)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,r,0)}}(i.__webglFramebuffer,e)}else if(r){i.__webglDepthbuffer=[];for(let n=0;n<6;n++)t.bindFramebuffer(36160,i.__webglFramebuffer[n]),i.__webglDepthbuffer[n]=t.createRenderbuffer(),O(i.__webglDepthbuffer[n],e,!1)}else t.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),O(i.__webglDepthbuffer,e,!1);t.bindFramebuffer(36160,null)}function D(t){return a&&t.isWebGLMultisampleRenderTarget?Math.min(u,t.samples):0}let $=!1,k=!1;this.allocateTextureUnit=function(){const t=M;return t>=c&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+c),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=T,this.setTexture2DArray=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=C,this.setupRenderTarget=function(e){const r=n.get(e),c=n.get(e.texture);e.addEventListener("dispose",S),c.__webglTexture=t.createTexture(),o.memory.textures++;const h=!0===e.isWebGLCubeRenderTarget,l=!0===e.isWebGLMultisampleRenderTarget,u=_(e)||a;if(!a||e.texture.format!==ki||e.texture.type!==Ni&&e.texture.type!==Di||(e.texture.format=zi,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){r.__webglFramebuffer=[];for(let e=0;e<6;e++)r.__webglFramebuffer[e]=t.createFramebuffer()}else if(r.__webglFramebuffer=t.createFramebuffer(),l)if(a){r.__webglMultisampledFramebuffer=t.createFramebuffer(),r.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,r.__webglColorRenderbuffer);const i=s.convert(e.texture.format),n=s.convert(e.texture.type),o=b(e.texture.internalFormat,i,n),a=D(e);t.renderbufferStorageMultisample(36161,a,o,e.width,e.height),t.bindFramebuffer(36160,r.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,r.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(r.__webglDepthRenderbuffer=t.createRenderbuffer(),O(r.__webglDepthRenderbuffer,e,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h){i.bindTexture(34067,c.__webglTexture),A(34067,e.texture,u);for(let t=0;t<6;t++)L(r.__webglFramebuffer[t],e,36064,34069+t);v(e.texture,u)&&y(34067,e.texture,e.width,e.height),i.bindTexture(34067,null)}else i.bindTexture(3553,c.__webglTexture),A(3553,e.texture,u),L(r.__webglFramebuffer,e,36064,3553),v(e.texture,u)&&y(3553,e.texture,e.width,e.height),i.bindTexture(3553,null);e.depthBuffer&&N(e)},this.updateRenderTargetMipmap=function(t){const e=t.texture;if(v(e,_(t)||a)){const r=t.isWebGLCubeRenderTarget?34067:3553,s=n.get(e).__webglTexture;i.bindTexture(r,s),y(r,e,t.width,t.height),i.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(a){const i=n.get(e);t.bindFramebuffer(36008,i.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,i.__webglFramebuffer);const r=e.width,s=e.height;let o=16384;e.depthBuffer&&(o|=256),e.stencilBuffer&&(o|=1024),t.blitFramebuffer(0,0,r,s,0,0,r,s,o,9728),t.bindFramebuffer(36160,i.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$=!0),t=t.texture),T(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===k&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),k=!0),t=t.texture),C(t,e)}}function Ga(t,e,i){const n=i.isWebGL2;return{convert:function(t){let i;if(t===Ri)return 5121;if(1017===t)return 32819;if(1018===t)return 32820;if(1019===t)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(t===Li)return 5123;if(1013===t)return 5124;if(t===Oi)return 5125;if(t===Ni)return 5126;if(t===Di)return n?5131:(i=e.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(1021===t)return 6406;if(t===ki)return 6407;if(t===zi)return 6408;if(1024===t)return 6409;if(1025===t)return 6410;if(t===Fi)return 6402;if(t===Bi)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(33776===t||33777===t||33778===t||33779===t){if(i=e.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===t)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===t)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===t)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===t)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===t||35841===t||35842===t||35843===t){if(i=e.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(35840===t)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===t)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===t)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===t)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===t)return i=e.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===t||37496===t)&&(i=e.get("WEBGL_compressed_texture_etc"),null!==i)){if(37492===t)return i.COMPRESSED_RGB8_ETC2;if(37496===t)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t||37840===t||37841===t||37842===t||37843===t||37844===t||37845===t||37846===t||37847===t||37848===t||37849===t||37850===t||37851===t||37852===t||37853===t?(i=e.get("WEBGL_compressed_texture_astc"),null!==i?t:null):36492===t?(i=e.get("EXT_texture_compression_bptc"),null!==i?t:null):t===$i?n?34042:(i=e.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}function qa(t=[]){Ds.call(this),this.cameras=t}function Wa(){pr.call(this),this.type="Group"}function Xa(){this._targetRay=null,this._grip=null,this._hand=null}function Ya(t,e){const i=this;let n=null,r=1,s=null,o="local-floor",a=null;const c=[],h=new Map,l=new Ds;l.layers.enable(1),l.viewport=new un;const u=new Ds;u.layers.enable(2),u.viewport=new un;const d=[l,u],p=new qa;p.layers.enable(1),p.layers.enable(2);let f=null,m=null;function g(t){const e=h.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function _(){h.forEach((function(t,e){t.disconnect(e)})),h.clear(),f=null,m=null,t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),S.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function v(t){const e=n.inputSources;for(let t=0;t<c.length;t++)h.set(e[t],c[t]);for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=h.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),h.delete(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e],n=h.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getGripSpace()},this.getHand=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){o=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getSession=function(){return n},this.setSession=async function(t){if(n=t,null!==n){n.addEventListener("select",g),n.addEventListener("selectstart",g),n.addEventListener("selectend",g),n.addEventListener("squeeze",g),n.addEventListener("squeezestart",g),n.addEventListener("squeezeend",g),n.addEventListener("end",_),n.addEventListener("inputsourceschange",v);const t=e.getContextAttributes();!0!==t.xrCompatible&&await e.makeXRCompatible();const a={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:r},c=new XRWebGLLayer(n,e,a);n.updateRenderState({baseLayer:c}),s=await n.requestReferenceSpace(o),S.setContext(n),S.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const y=new fn,b=new fn;function x(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.getCamera=function(t){p.near=u.near=l.near=t.near,p.far=u.far=l.far=t.far,f===p.near&&m===p.far||(n.updateRenderState({depthNear:p.near,depthFar:p.far}),f=p.near,m=p.far);const e=t.parent,i=p.cameras;x(p,e);for(let t=0;t<i.length;t++)x(i[t],e);t.matrixWorld.copy(p.matrixWorld),t.matrix.copy(p.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const r=t.children;for(let t=0,e=r.length;t<e;t++)r[t].updateMatrixWorld(!0);return 2===i.length?function(t,e,i){y.setFromMatrixPosition(e.matrixWorld),b.setFromMatrixPosition(i.matrixWorld);const n=y.distanceTo(b),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,o=r[14]/(r[10]-1),a=r[14]/(r[10]+1),c=(r[9]+1)/r[5],h=(r[9]-1)/r[5],l=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=o*l,p=o*u,f=n/(-l+u),m=f*-l;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=o+f,_=a+f,v=d-m,x=p+(n-m),w=c*a/_*g,S=h*a/_*g;t.projectionMatrix.makePerspective(v,x,w,S,g,_)}(p,l,u):p.projectionMatrix.copy(l.projectionMatrix),p};let w=null;const S=new Vs;S.setAnimationLoop((function(e,i){if(a=i.getViewerPose(s),null!==a){const e=a.views,i=n.renderState.baseLayer;t.setFramebuffer(i.framebuffer);let r=!1;e.length!==p.cameras.length&&(p.cameras.length=0,r=!0);for(let t=0;t<e.length;t++){const n=e[t],s=i.getViewport(n),o=d[t];o.matrix.fromArray(n.transform.matrix),o.projectionMatrix.fromArray(n.projectionMatrix),o.viewport.set(s.x,s.y,s.width,s.height),0===t&&p.matrix.copy(o.matrix),!0===r&&p.cameras.push(o)}}const r=n.inputSources;for(let t=0;t<c.length;t++){const e=c[t],n=r[t];e.update(n,i,s)}w&&w(e,i)})),this.setAnimationLoop=function(t){w=t},this.dispose=function(){}}function Za(t){function e(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map),i.alphaMap&&(e.alphaMap.value=i.alphaMap),i.specularMap&&(e.specularMap.value=i.specularMap);const n=t.get(i).envMap;if(n){e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&n._needsFlipEnvMap?-1:1,e.reflectivity.value=i.reflectivity,e.refractionRatio.value=i.refractionRatio;const r=t.get(n).__maxMipLevel;void 0!==r&&(e.maxMipLevel.value=r)}let r,s;i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap&&(r=i.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),i.aoMap?s=i.aoMap:i.lightMap&&(s=i.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),e.uv2Transform.value.copy(s.matrix))}function i(e,i){e.roughness.value=i.roughness,e.metalness.value=i.metalness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap),i.bumpMap&&(e.bumpMap.value=i.bumpMap,e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias);t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,r,s){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshPhongMaterial?(e(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e){i(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap);e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate());t.transmission.value=e.transmission,e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap)}(t,n):i(t,n)):n.isMeshMatcapMaterial?(e(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?(e(t,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n,r,s):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Ja(t){const e=void 0!==(t=t||{}).canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),i=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,s=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,h=void 0!==t.powerPreference?t.powerPreference:"default",l=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Xi,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;const f=this;let m=!1,g=null,_=0,v=0,y=null,b=null,x=-1,w=null;const S=new un,M=new un;let T=null,C=e.width,E=e.height,I=1,A=null,P=null;const R=new un(0,0,C,E),L=new un(0,0,C,E);let O=!1;const N=new Us;let D=!1,$=!1;const k=new Hn,z=new fn,F={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function B(){return null===y?I:1}let j,H,U,V,G,q,W,X,Y,Z,J,K,Q,tt,et,it,nt,rt,st,ot,at,ct=i;function ht(t,i){for(let n=0;n<t.length;n++){const r=t[n],s=e.getContext(r,i);if(null!==s)return s}return null}try{const t={alpha:n,depth:r,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:l};if(e.addEventListener("webglcontextlost",pt,!1),e.addEventListener("webglcontextrestored",ft,!1),null===ct){const e=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&e.shift(),ct=ht(e,t),null===ct)throw ht(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ct.getShaderPrecisionFormat&&(ct.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function lt(){j=new io(ct),H=new Qs(ct,j,t),j.init(H),ot=new Ga(ct,j,H),U=new Ua(ct,j,H),U.scissor(M.copy(L).multiplyScalar(I).floor()),U.viewport(S.copy(R).multiplyScalar(I).floor()),V=new so(ct),G=new Aa,q=new Va(ct,j,U,G,H,ot,V),W=new eo(f),X=new Gs(ct,H),at=new Js(ct,j,X,H),Y=new no(ct,X,V,at),Z=new ho(ct,Y,X,V),nt=new co(ct),et=new to(G),J=new Ia(f,W,j,H,at,et),K=new Za(G),Q=new Oa(G),tt=new Fa(j,H),it=new Zs(f,W,U,Z,a),rt=new Ks(ct,j,V,H),st=new ro(ct,j,V,H),V.programs=J.programs,f.capabilities=H,f.extensions=j,f.properties=G,f.renderLists=Q,f.state=U,f.info=V}lt();const ut=new Ya(f,ct);this.xr=ut;const dt=new Ha(f,Z,H.maxTextureSize);function pt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ft(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1,lt()}function mt(t){const e=t.target;e.removeEventListener("dispose",mt),function(t){gt(t),G.remove(t)}(e)}function gt(t){const e=G.get(t).program;void 0!==e&&J.releaseProgram(e)}this.shadowMap=dt,this.getContext=function(){return ct},this.getContextAttributes=function(){return ct.getContextAttributes()},this.forceContextLoss=function(){const t=j.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=j.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(t){void 0!==t&&(I=t,this.setSize(C,E,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new rn),t.set(C,E)},this.setSize=function(t,i,n){ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(C=t,E=i,e.width=Math.floor(t*I),e.height=Math.floor(i*I),!1!==n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new rn),t.set(C*I,E*I).floor()},this.setDrawingBufferSize=function(t,i,n){C=t,E=i,I=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new un),t.copy(S)},this.getViewport=function(t){return t.copy(R)},this.setViewport=function(t,e,i,n){t.isVector4?R.set(t.x,t.y,t.z,t.w):R.set(t,e,i,n),U.viewport(S.copy(R).multiplyScalar(I).floor())},this.getScissor=function(t){return t.copy(L)},this.setScissor=function(t,e,i,n){t.isVector4?L.set(t.x,t.y,t.z,t.w):L.set(t,e,i,n),U.scissor(M.copy(L).multiplyScalar(I).floor())},this.getScissorTest=function(){return O},this.setScissorTest=function(t){U.setScissorTest(O=t)},this.setOpaqueSort=function(t){A=t},this.setTransparentSort=function(t){P=t},this.getClearColor=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),t=new Dr),t.copy(it.getClearColor())},this.setClearColor=function(){it.setClearColor.apply(it,arguments)},this.getClearAlpha=function(){return it.getClearAlpha()},this.setClearAlpha=function(){it.setClearAlpha.apply(it,arguments)},this.clear=function(t,e,i){let n=0;(void 0===t||t)&&(n|=16384),(void 0===e||e)&&(n|=256),(void 0===i||i)&&(n|=1024),ct.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",pt,!1),e.removeEventListener("webglcontextrestored",ft,!1),Q.dispose(),tt.dispose(),G.dispose(),W.dispose(),Z.dispose(),at.dispose(),ut.dispose(),vt.stop()},this.renderBufferImmediate=function(t,e){at.initAttributes();const i=G.get(t);t.hasPositions&&!i.position&&(i.position=ct.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=ct.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=ct.createBuffer()),t.hasColors&&!i.color&&(i.color=ct.createBuffer());const n=e.getAttributes();t.hasPositions&&(ct.bindBuffer(34962,i.position),ct.bufferData(34962,t.positionArray,35048),at.enableAttribute(n.position),ct.vertexAttribPointer(n.position,3,5126,!1,0,0)),t.hasNormals&&(ct.bindBuffer(34962,i.normal),ct.bufferData(34962,t.normalArray,35048),at.enableAttribute(n.normal),ct.vertexAttribPointer(n.normal,3,5126,!1,0,0)),t.hasUvs&&(ct.bindBuffer(34962,i.uv),ct.bufferData(34962,t.uvArray,35048),at.enableAttribute(n.uv),ct.vertexAttribPointer(n.uv,2,5126,!1,0,0)),t.hasColors&&(ct.bindBuffer(34962,i.color),ct.bufferData(34962,t.colorArray,35048),at.enableAttribute(n.color),ct.vertexAttribPointer(n.color,3,5126,!1,0,0)),at.disableUnusedAttributes(),ct.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=F);const o=r.isMesh&&r.matrixWorld.determinant()<0,a=St(t,e,n,r);U.setMaterial(n,o);let c=i.index;const h=i.attributes.position;if(null===c){if(void 0===h||0===h.count)return}else if(0===c.count)return;let l,u=1;!0===n.wireframe&&(c=Y.getWireframeAttribute(i),u=2),(n.morphTargets||n.morphNormals)&&nt.update(r,i,n,a),at.setup(r,n,a,i,c);let d=rt;null!==c&&(l=X.get(c),d=st,d.setIndex(l));const p=null!==c?c.count:h.count,f=i.drawRange.start*u,m=i.drawRange.count*u,g=null!==s?s.start*u:0,_=null!==s?s.count*u:1/0,v=Math.max(f,g),y=Math.min(p,f+m,g+_)-1,b=Math.max(0,y-v+1);if(0!==b){if(r.isMesh)!0===n.wireframe?(U.setLineWidth(n.wireframeLinewidth*B()),d.setMode(1)):d.setMode(4);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),U.setLineWidth(t*B()),r.isLineSegments?d.setMode(1):r.isLineLoop?d.setMode(2):d.setMode(3)}else r.isPoints?d.setMode(0):r.isSprite&&d.setMode(4);if(r.isInstancedMesh)d.renderInstances(v,b,r.count);else if(i.isInstancedBufferGeometry){const t=Math.min(i.instanceCount,i._maxInstanceCount);d.renderInstances(v,b,t)}else d.render(v,b)}},this.compile=function(t,e){d=tt.get(t),d.init(),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights();const i=new WeakMap;t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++){const s=n[r];!1===i.has(s)&&(wt(s,t,e),i.set(s))}else!1===i.has(n)&&(wt(n,t,e),i.set(n))}))};let _t=null;const vt=new Vs;function yt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||N.intersectsSprite(t)){n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k);const e=Z.update(t),r=t.material;r.visible&&u.push(t,e,r,i,z.z,null)}}else if(t.isImmediateRenderObject)n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k),u.push(t,null,t.material,i,z.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==V.render.frame&&(t.skeleton.update(),t.skeleton.frame=V.render.frame),!t.frustumCulled||N.intersectsObject(t))){n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k);const e=Z.update(t),r=t.material;if(Array.isArray(r)){const n=e.groups;for(let s=0,o=n.length;s<o;s++){const o=n[s],a=r[o.materialIndex];a&&a.visible&&u.push(t,e,a,i,z.z,o)}}else r.visible&&u.push(t,e,r,i,z.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)yt(r[t],e,i,n)}function bt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=s.object,a=s.geometry,c=null===n?s.material:n,h=s.group;if(i.isArrayCamera){const t=i.cameras;for(let i=0,n=t.length;i<n;i++){const n=t[i];o.layers.test(n.layers)&&(U.viewport(S.copy(n.viewport)),d.setupLightsView(n),xt(o,e,n,a,c,h))}}else xt(o,e,i,a,c,h)}}function xt(t,e,i,n,r,s){if(t.onBeforeRender(f,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){const n=St(i,e,r,t);U.setMaterial(r),at.reset(),function(t,e){t.render((function(t){f.renderBufferImmediate(t,e)}))}(t,n)}else f.renderBufferDirect(i,e,n,r,t,s);t.onAfterRender(f,e,i,n,r,s)}function wt(t,e,i){!0!==e.isScene&&(e=F);const n=G.get(t),r=d.state.lights,s=d.state.shadowsArray,o=r.state.version,a=J.getParameters(t,r.state,s,e,i),c=J.getProgramCacheKey(a);let h=n.program,l=!0;if(n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=W.get(t.envMap||n.environment),void 0===h)t.addEventListener("dispose",mt);else if(h.cacheKey!==c)gt(t);else if(n.lightsStateVersion!==o)l=!1;else{if(void 0!==a.shaderID)return;l=!1}l&&(a.uniforms=J.getUniforms(t),t.onBeforeCompile(a,f),h=J.acquireProgram(a,c),n.program=h,n.uniforms=a.uniforms,n.outputEncoding=a.outputEncoding);const u=n.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=et.numPlanes,n.numIntersection=et.numIntersection,u.clippingPlanes=et.uniform),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=o,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=n.program.getUniforms(),m=aa.seqWithValue(p.seq,u);n.uniformsList=m}function St(t,e,i,n){!0!==e.isScene&&(e=F),q.resetTextureUnits();const r=e.fog,s=i.isMeshStandardMaterial?e.environment:null,o=null===y?f.outputEncoding:y.texture.encoding,a=W.get(i.envMap||s),c=G.get(i),h=d.state.lights;if(!0===D&&(!0===$||t!==w)){const e=t===w&&i.id===x;et.setState(i,t,e)}i.version===c.__version?i.fog&&c.fog!==r||c.environment!==s||c.needsLights&&c.lightsStateVersion!==h.state.version?wt(i,e,n):void 0===c.numClippingPlanes||c.numClippingPlanes===et.numPlanes&&c.numIntersection===et.numIntersection?(c.outputEncoding!==o||c.envMap!==a)&&wt(i,e,n):wt(i,e,n):(wt(i,e,n),c.__version=i.version);let l=!1,u=!1,p=!1;const m=c.program,g=m.getUniforms(),_=c.uniforms;if(U.useProgram(m.program)&&(l=!0,u=!0,p=!0),i.id!==x&&(x=i.id,u=!0),l||w!==t){if(g.setValue(ct,"projectionMatrix",t.projectionMatrix),H.logarithmicDepthBuffer&&g.setValue(ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),w!==t&&(w=t,u=!0,p=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const e=g.map.cameraPosition;void 0!==e&&e.setValue(ct,z.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&g.setValue(ct,"isOrthographic",!0===t.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||i.skinning)&&g.setValue(ct,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){g.setOptional(ct,n,"bindMatrix"),g.setOptional(ct,n,"bindMatrixInverse");const t=n.skeleton;if(t){const e=t.bones;if(H.floatVertexTextures){if(null===t.boneTexture){let i=Math.sqrt(4*e.length);i=nn.ceilPowerOfTwo(i),i=Math.max(i,4);const n=new Float32Array(i*i*4);n.set(t.boneMatrices);const r=new Bs(n,i,i,zi,Ni);t.boneMatrices=n,t.boneTexture=r,t.boneTextureSize=i}g.setValue(ct,"boneTexture",t.boneTexture,q),g.setValue(ct,"boneTextureSize",t.boneTextureSize)}else g.setOptional(ct,t,"boneMatrices")}}var v,b;return(u||c.receiveShadow!==n.receiveShadow)&&(c.receiveShadow=n.receiveShadow,g.setValue(ct,"receiveShadow",n.receiveShadow)),u&&(g.setValue(ct,"toneMappingExposure",f.toneMappingExposure),c.needsLights&&(b=p,(v=_).ambientLightColor.needsUpdate=b,v.lightProbe.needsUpdate=b,v.directionalLights.needsUpdate=b,v.directionalLightShadows.needsUpdate=b,v.pointLights.needsUpdate=b,v.pointLightShadows.needsUpdate=b,v.spotLights.needsUpdate=b,v.spotLightShadows.needsUpdate=b,v.rectAreaLights.needsUpdate=b,v.hemisphereLights.needsUpdate=b),r&&i.fog&&K.refreshFogUniforms(_,r),K.refreshMaterialUniforms(_,i,I,E),aa.upload(ct,c.uniformsList,_,q)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(aa.upload(ct,c.uniformsList,_,q),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&g.setValue(ct,"center",n.center),g.setValue(ct,"modelViewMatrix",n.modelViewMatrix),g.setValue(ct,"normalMatrix",n.normalMatrix),g.setValue(ct,"modelMatrix",n.matrixWorld),m}vt.setAnimationLoop((function(t){ut.isPresenting||_t&&_t(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){_t=t,ut.setAnimationLoop(t),null===t?vt.stop():vt.start()},this.render=function(t,e){let i,n;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),n=arguments[3]),void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===m)return;at.resetDefaultState(),x=-1,w=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===ut.enabled&&!0===ut.isPresenting&&(e=ut.getCamera(e)),!0===t.isScene&&t.onBeforeRender(f,t,e,i||y),d=tt.get(t,p.length),d.init(),p.push(d),k.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),N.setFromProjectionMatrix(k),$=this.localClippingEnabled,D=et.init(this.clippingPlanes,$,e),u=Q.get(t,e),u.init(),yt(t,e,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(A,P),!0===D&&et.beginShadows();const r=d.state.shadowsArray;dt.render(r,t,e),d.setupLights(),d.setupLightsView(e),!0===D&&et.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),it.render(u,t,e,n);const s=u.opaque,o=u.transparent;s.length>0&&bt(s,t,e),o.length>0&&bt(o,t,e),!0===t.isScene&&t.onAfterRender(f,t,e),null!==y&&(q.updateRenderTargetMipmap(y),q.updateMultisampleRenderTarget(y)),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1),p.pop(),d=p.length>0?p[p.length-1]:null,u=null},this.setFramebuffer=function(t){g!==t&&null===y&&ct.bindFramebuffer(36160,t),g=t},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderList=function(){return u},this.setRenderList=function(t){u=t},this.getRenderTarget=function(){return y},this.setRenderTarget=function(t,e=0,i=0){y=t,_=e,v=i,t&&void 0===G.get(t).__webglFramebuffer&&q.setupRenderTarget(t);let n=g,r=!1;if(t){const i=G.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=i[e],r=!0):n=t.isWebGLMultisampleRenderTarget?G.get(t).__webglMultisampledFramebuffer:i,S.copy(t.viewport),M.copy(t.scissor),T=t.scissorTest}else S.copy(R).multiplyScalar(I).floor(),M.copy(L).multiplyScalar(I).floor(),T=O;if(b!==n&&(ct.bindFramebuffer(36160,n),b=n),U.viewport(S),U.scissor(M),U.setScissorTest(T),r){const n=G.get(t.texture);ct.framebufferTexture2D(36160,36064,34069+e,n.__webglTexture,i)}},this.readRenderTargetPixels=function(t,e,i,n,r,s,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=G.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(a=a[o]),a){let o=!1;a!==b&&(ct.bindFramebuffer(36160,a),o=!0);try{const a=t.texture,c=a.format,h=a.type;if(c!==zi&&ot.convert(c)!==ct.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=h===Di&&(j.has("EXT_color_buffer_half_float")||H.isWebGL2&&j.has("EXT_color_buffer_float"));if(!(h===Ri||ot.convert(h)===ct.getParameter(35738)||h===Ni&&(H.isWebGL2||j.has("OES_texture_float")||j.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ct.checkFramebufferStatus(36160)?e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&ct.readPixels(e,i,n,r,ot.convert(c),ot.convert(h),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{o&&ct.bindFramebuffer(36160,b)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),s=Math.floor(e.image.height*n),o=ot.convert(e.format);q.setTexture2D(e,0),ct.copyTexImage2D(3553,i,o,t.x,t.y,r,s,0),U.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,s=e.image.height,o=ot.convert(i.format),a=ot.convert(i.type);q.setTexture2D(i,0),ct.pixelStorei(37440,i.flipY),ct.pixelStorei(37441,i.premultiplyAlpha),ct.pixelStorei(3317,i.unpackAlignment),e.isDataTexture?ct.texSubImage2D(3553,n,t.x,t.y,r,s,o,a,e.image.data):e.isCompressedTexture?ct.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):ct.texSubImage2D(3553,n,t.x,t.y,o,a,e.image),0===n&&i.generateMipmaps&&ct.generateMipmap(3553),U.unbindTexture()},this.initTexture=function(t){q.setTexture2D(t,0),U.unbindTexture()},this.resetState=function(){U.reset(),at.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Ka(t){Ja.call(this,t)}qa.prototype=Object.assign(Object.create(Ds.prototype),{constructor:qa,isArrayCamera:!0}),Wa.prototype=Object.assign(Object.create(pr.prototype),{constructor:Wa,isGroup:!0}),Object.assign(Xa.prototype,{constructor:Xa,getHandSpace:function(){return null===this._hand&&(this._hand=new Wa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Wa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Wa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(t,e,i){let n=null,r=null,s=null;const o=this._targetRay,a=this._grip,c=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState)if(c&&t.hand){s=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i);if(void 0===c.joints[n.jointName]){const t=new Wa;t.matrixAutoUpdate=!1,t.visible=!1,c.joints[n.jointName]=t,c.add(t)}const r=c.joints[n.jointName];null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=t.radius),r.visible=null!==t}const n=c.joints["index-finger-tip"],r=c.joints["thumb-tip"],o=n.position.distanceTo(r.position),a=.02,h=.005;c.inputState.pinching&&o>a+h?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&o<=a-h&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&(n=e.getPose(t.targetRaySpace,i),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale))),null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return null!==o&&(o.visible=null!==n),null!==a&&(a.visible=null!==r),null!==c&&(c.visible=null!==s),this}}),Object.assign(Ya.prototype,Qi.prototype),Ka.prototype=Object.assign(Object.create(Ja.prototype),{constructor:Ka,isWebGL1Renderer:!0});class Qa extends pr{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.environment&&(e.object.environment=this.environment.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}function tc(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Zi,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=nn.generateUUID()}Object.defineProperty(tc.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(tc.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this},set:function(t,e=0){return this.array.set(t,e),this},clone:function(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=nn.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new tc(new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),this.stride);return e.setUsage(this.usage),e},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=nn.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const ec=new fn;function ic(t,e,i,n){this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===n}function nc(t){zr.call(this),this.type="SpriteMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}let rc;Object.defineProperties(ic.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}}),Object.assign(ic.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,i=this.data.count;e<i;e++)ec.x=this.getX(e),ec.y=this.getY(e),ec.z=this.getZ(e),ec.applyMatrix4(t),this.setXYZ(e,ec.x,ec.y,ec.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this},clone:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new Hr(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ic(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}),nc.prototype=Object.create(zr.prototype),nc.prototype.constructor=nc,nc.prototype.isSpriteMaterial=!0,nc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};const sc=new fn,oc=new fn,ac=new fn,cc=new rn,hc=new rn,lc=new Hn,uc=new fn,dc=new fn,pc=new fn,fc=new rn,mc=new rn,gc=new rn;function _c(t){if(pr.call(this),this.type="Sprite",void 0===rc){rc=new hs;const t=new tc(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);rc.setIndex([0,1,2,0,2,3]),rc.setAttribute("position",new ic(t,3,0,!1)),rc.setAttribute("uv",new ic(t,2,3,!1))}this.geometry=rc,this.material=void 0!==t?t:new nc,this.center=new rn(.5,.5)}function vc(t,e,i,n,r,s){cc.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(hc.x=s*cc.x-r*cc.y,hc.y=r*cc.x+s*cc.y):hc.copy(cc),t.copy(e),t.x+=hc.x,t.y+=hc.y,t.applyMatrix4(lc)}_c.prototype=Object.assign(Object.create(pr.prototype),{constructor:_c,isSprite:!0,raycast:function(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),oc.setFromMatrixScale(this.matrixWorld),lc.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ac.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&oc.multiplyScalar(-ac.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;vc(uc.set(-.5,-.5,0),ac,s,oc,n,r),vc(dc.set(.5,-.5,0),ac,s,oc,n,r),vc(pc.set(.5,.5,0),ac,s,oc,n,r),fc.set(0,0),mc.set(1,0),gc.set(1,1);let o=t.ray.intersectTriangle(uc,dc,pc,!1,sc);if(null===o&&(vc(dc.set(-.5,.5,0),ac,s,oc,n,r),mc.set(0,1),o=t.ray.intersectTriangle(uc,pc,dc,!1,sc),null===o))return;const a=t.ray.origin.distanceTo(sc);a<t.near||a>t.far||e.push({distance:a,point:sc.clone(),uv:Ir.getUV(sc,uc,dc,pc,fc,mc,gc,new rn),face:null,object:this})},copy:function(t){return pr.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}});const yc=new fn,bc=new fn;function xc(){pr.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}xc.prototype=Object.assign(Object.create(pr.prototype),{constructor:xc,isLOD:!0,copy:function(t){pr.prototype.copy.call(this,t,!1);const e=t.levels;for(let t=0,i=e.length;t<i;t++){const i=e[t];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e=0){e=Math.abs(e);const i=this.levels;let n;for(n=0;n<i.length&&!(e<i[n].distance);n++);return i.splice(n,0,{distance:e,object:t}),this.add(t),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n&&!(t<e[i].distance);i++);return e[i-1].object}return null},raycast:function(t,e){if(this.levels.length>0){yc.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(yc);this.getObjectForDistance(i).raycast(t,e)}},update:function(t){const e=this.levels;if(e.length>1){yc.setFromMatrixPosition(t.matrixWorld),bc.setFromMatrixPosition(this.matrixWorld);const i=yc.distanceTo(bc)/t.zoom;let n,r;for(e[0].object.visible=!0,n=1,r=e.length;n<r&&i>=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)e[n].object.visible=!1}},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let t=0,n=i.length;t<n;t++){const n=i[t];e.object.levels.push({object:n.object.uuid,distance:n.distance})}return e}});const wc=new fn,Sc=new un,Mc=new un,Tc=new fn,Cc=new Hn;function Ec(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Es.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}function Ic(){pr.call(this),this.type="Bone"}Ec.prototype=Object.assign(Object.create(Es.prototype),{constructor:Ec,isSkinnedMesh:!0,copy:function(t){return Es.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const t=new un,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.w=e.getW(i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){Es.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(t,e){const i=this.skeleton,n=this.geometry;Sc.fromBufferAttribute(n.attributes.skinIndex,t),Mc.fromBufferAttribute(n.attributes.skinWeight,t),wc.fromBufferAttribute(n.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const n=Mc.getComponent(t);if(0!==n){const r=Sc.getComponent(t);Cc.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(Tc.copy(wc).applyMatrix4(Cc),n)}}return e.applyMatrix4(this.bindMatrixInverse)}}),Ic.prototype=Object.assign(Object.create(pr.prototype),{constructor:Ic,isBone:!0});const Ac=new Hn,Pc=new Hn;function Rc(t=[],e=[]){this.uuid=nn.generateUUID(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}Object.assign(Rc.prototype,{init:function(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Hn)}},calculateInverses:function(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Hn;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}},pose:function(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}},update:function(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const r=t[n]?t[n].matrixWorld:Pc;Ac.multiplyMatrices(r,e[n]),Ac.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)},clone:function(){return new Rc(this.bones,this.boneInverses)},getBoneByName:function(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}},dispose:function(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)},fromJSON:function(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const n=t.bones[i];let r=e[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Ic),this.bones.push(r),this.boneInverses.push((new Hn).fromArray(t.boneInverses[i]))}return this.init(),this},toJSON:function(){const t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,r=e.length;n<r;n++){const r=e[n];t.bones.push(r.uuid);const s=i[n];t.boneInverses.push(s.toArray())}return t}});const Lc=new Hn,Oc=new Hn,Nc=[],Dc=new Es;function $c(t,e,i){Es.call(this,t,e),this.instanceMatrix=new Hr(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}function kc(t){zr.call(this),this.type="LineBasicMaterial",this.color=new Dr(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}$c.prototype=Object.assign(Object.create(Es.prototype),{constructor:$c,isInstancedMesh:!0,copy:function(t){return Es.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this},getColorAt:function(t,e){e.fromArray(this.instanceColor.array,3*t)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){const i=this.matrixWorld,n=this.count;if(Dc.geometry=this.geometry,Dc.material=this.material,void 0!==Dc.material)for(let r=0;r<n;r++){this.getMatrixAt(r,Lc),Oc.multiplyMatrices(i,Lc),Dc.matrixWorld=Oc,Dc.raycast(t,Nc);for(let t=0,i=Nc.length;t<i;t++){const i=Nc[t];i.instanceId=r,i.object=this,e.push(i)}Nc.length=0}},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new Hr(new Float32Array(3*this.count),3)),e.toArray(this.instanceColor.array,3*t)},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}}),kc.prototype=Object.create(zr.prototype),kc.prototype.constructor=kc,kc.prototype.isLineBasicMaterial=!0,kc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this};const zc=new fn,Fc=new fn,Bc=new Hn,jc=new jn,Hc=new On;function Uc(t=new hs,e=new kc){pr.call(this),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}Uc.prototype=Object.assign(Object.create(pr.prototype),{constructor:Uc,isLine:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)zc.fromBufferAttribute(e,t-1),Fc.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=zc.distanceTo(Fc);t.setAttribute("lineDistance",new Jr(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Hc.copy(i.boundingSphere),Hc.applyMatrix4(n),Hc.radius+=r,!1===t.ray.intersectsSphere(Hc))return;Bc.copy(n).invert(),jc.copy(t.ray).applyMatrix4(Bc);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,a=new fn,c=new fn,h=new fn,l=new fn,u=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n){const i=n.array;for(let n=0,s=i.length-1;n<s;n+=u){const s=i[n],u=i[n+1];a.fromBufferAttribute(r,s),c.fromBufferAttribute(r,u);if(jc.distanceSqToSegment(a,c,l,h)>o)continue;l.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(l);d<t.near||d>t.far||e.push({distance:d,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else for(let i=0,n=r.count-1;i<n;i+=u){a.fromBufferAttribute(r,i),c.fromBufferAttribute(r,i+1);if(jc.distanceSqToSegment(a,c,l,h)>o)continue;l.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(l);n<t.near||n>t.far||e.push({distance:n,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const Vc=new fn,Gc=new fn;function qc(t,e){Uc.call(this,t,e),this.type="LineSegments"}function Wc(t,e){Uc.call(this,t,e),this.type="LineLoop"}function Xc(t){zr.call(this),this.type="PointsMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}qc.prototype=Object.assign(Object.create(Uc.prototype),{constructor:qc,isLineSegments:!0,computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)Vc.fromBufferAttribute(e,t),Gc.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+Vc.distanceTo(Gc);t.setAttribute("lineDistance",new Jr(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}),Wc.prototype=Object.assign(Object.create(Uc.prototype),{constructor:Wc,isLineLoop:!0}),Xc.prototype=Object.create(zr.prototype),Xc.prototype.constructor=Xc,Xc.prototype.isPointsMaterial=!0,Xc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};const Yc=new Hn,Zc=new jn,Jc=new On,Kc=new fn;function Qc(t=new hs,e=new Xc){pr.call(this),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}function th(t,e,i,n,r,s,o){const a=Zc.distanceSqToPoint(t);if(a<i){const i=new fn;Zc.closestPointToPoint(t,i),i.applyMatrix4(n);const c=r.ray.origin.distanceTo(i);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:i,index:e,face:null,object:o})}}function eh(t,e,i,n,r,s,o,a,c){hn.call(this,t,e,i,n,r,s,o,a,c),this.format=void 0!==o?o:ki,this.minFilter=void 0!==s?s:Ai,this.magFilter=void 0!==r?r:Ai,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}function ih(t,e,i,n,r,s,o,a,c,h,l,u){hn.call(this,null,s,o,a,c,h,n,r,l,u),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function nh(t,e,i,n,r,s,o,a,c){hn.call(this,t,e,i,n,r,s,o,a,c),this.needsUpdate=!0}function rh(t,e,i,n,r,s,o,a,c,h){if((h=void 0!==h?h:Fi)!==Fi&&h!==Bi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Fi&&(i=Li),void 0===i&&h===Bi&&(i=$i),hn.call(this,null,n,r,s,o,a,h,i,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:Ii,this.minFilter=void 0!==a?a:Ii,this.flipY=!1,this.generateMipmaps=!1}Qc.prototype=Object.assign(Object.create(pr.prototype),{constructor:Qc,isPoints:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Jc.copy(i.boundingSphere),Jc.applyMatrix4(n),Jc.radius+=r,!1===t.ray.intersectsSphere(Jc))return;Yc.copy(n).invert(),Zc.copy(t.ray).applyMatrix4(Yc);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position;if(null!==r){const i=r.array;for(let r=0,a=i.length;r<a;r++){const a=i[r];Kc.fromBufferAttribute(s,a),th(Kc,a,o,n,t,e,this)}}else for(let i=0,r=s.count;i<r;i++)Kc.fromBufferAttribute(s,i),th(Kc,i,o,n,t,e,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),eh.prototype=Object.assign(Object.create(hn.prototype),{constructor:eh,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),ih.prototype=Object.create(hn.prototype),ih.prototype.constructor=ih,ih.prototype.isCompressedTexture=!0,nh.prototype=Object.create(hn.prototype),nh.prototype.constructor=nh,nh.prototype.isCanvasTexture=!0,rh.prototype=Object.create(hn.prototype),rh.prototype.constructor=rh,rh.prototype.isDepthTexture=!0;class sh extends hs{constructor(t=1,e=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const r=[],s=[],o=[],a=[],c=new fn,h=new rn;s.push(0,0,0),o.push(0,0,1),a.push(.5,.5);for(let r=0,l=3;r<=e;r++,l+=3){const u=i+r/e*n;c.x=t*Math.cos(u),c.y=t*Math.sin(u),s.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(s[l]/t+1)/2,h.y=(s[l+1]/t+1)/2,a.push(h.x,h.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new Jr(s,3)),this.setAttribute("normal",new Jr(o,3)),this.setAttribute("uv",new Jr(a,2))}}new fn,new fn,new fn,new Ir;const oh=function(t,e,i){i=i||2;const n=e&&e.length,r=n?e[0]*i:t.length;let s=ah(t,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,h,l,u,d,p;if(n&&(s=function(t,e,i,n){const r=[];let s,o,a,c,h;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:t.length,h=ah(t,a,c,n,!1),h===h.next&&(h.steiner=!0),r.push(vh(h));for(r.sort(fh),s=0;s<r.length;s++)mh(r[s],i),i=ch(i,i.next);return i}(t,e,s,i)),t.length>80*i){a=h=t[0],c=l=t[1];for(let e=i;e<r;e+=i)u=t[e],d=t[e+1],u<a&&(a=u),d<c&&(c=d),u>h&&(h=u),d>l&&(l=d);p=Math.max(h-a,l-c),p=0!==p?1/p:0}return hh(s,o,i,a,c,p),o};function ah(t,e,i,n,r){let s,o;if(r===function(t,e,i,n){let r=0;for(let s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(s=e;s<i;s+=n)o=Ih(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=Ih(s,t[s],t[s+1],o);return o&&wh(o,o.next)&&(Ah(o),o=o.next),o}function ch(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!wh(n,n.next)&&0!==xh(n.prev,n,n.next))n=n.next;else{if(Ah(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function hh(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=_h(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,s,o,a,c,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<h&&(a++,n=n.nextZ,n);e++);for(c=h;a>0||c>0&&n;)0!==a&&(0===c||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)}(r)}(t,n,r,s);let a,c,h=t;for(;t.prev!==t.next;)if(a=t.prev,c=t.next,s?uh(t,n,r,s):lh(t))e.push(a.i/i),e.push(t.i/i),e.push(c.i/i),Ah(t),t=c.next,h=c.next;else if((t=c)===h){o?1===o?hh(t=dh(ch(t),e,i),e,i,n,r,s,2):2===o&&ph(t,e,i,n,r,s):hh(ch(t),e,i,n,r,s,1);break}}function lh(t){const e=t.prev,i=t,n=t.next;if(xh(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(yh(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&xh(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function uh(t,e,i,n){const r=t.prev,s=t,o=t.next;if(xh(r,s,o)>=0)return!1;const a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,c=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=_h(a,c,e,i,n),d=_h(h,l,e,i,n);let p=t.prevZ,f=t.nextZ;for(;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&xh(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&xh(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&xh(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&xh(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function dh(t,e,i){let n=t;do{const r=n.prev,s=n.next.next;!wh(r,s)&&Sh(r,n,n.next,s)&&Ch(r,s)&&Ch(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Ah(n),Ah(n.next),n=t=s),n=n.next}while(n!==t);return ch(n)}function ph(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&bh(o,t)){let a=Eh(o,t);return o=ch(o,o.next),a=ch(a,a.next),hh(o,e,i,n,r,s),void hh(a,e,i,n,r,s)}t=t.next}o=o.next}while(o!==t)}function fh(t,e){return t.x-e.x}function mh(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o){if(o=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!s)return null;if(n===o)return s;const a=s,c=s.x,h=s.y;let l,u=1/0;i=s;do{n>=i.x&&i.x>=c&&n!==i.x&&yh(r<h?n:o,r,c,h,r<h?o:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),Ch(i,t)&&(l<u||l===u&&(i.x>s.x||i.x===s.x&&gh(s,i)))&&(s=i,u=l)),i=i.next}while(i!==a);return s}(t,e)){const i=Eh(e,t);ch(e,e.next),ch(i,i.next)}}function gh(t,e){return xh(t.prev,t,e.prev)<0&&xh(e.next,t,t.next)<0}function _h(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function vh(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function yh(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function bh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Sh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Ch(t,e)&&Ch(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(xh(t.prev,t,e.prev)||xh(t,e.prev,e))||wh(t,e)&&xh(t.prev,t,t.next)>0&&xh(e.prev,e,e.next)>0)}function xh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function wh(t,e){return t.x===e.x&&t.y===e.y}function Sh(t,e,i,n){const r=Th(xh(t,e,i)),s=Th(xh(t,e,n)),o=Th(xh(i,n,t)),a=Th(xh(i,n,e));return r!==s&&o!==a||(!(0!==r||!Mh(t,i,e))||(!(0!==s||!Mh(t,n,e))||(!(0!==o||!Mh(i,t,n))||!(0!==a||!Mh(i,e,n)))))}function Mh(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Th(t){return t>0?1:t<0?-1:0}function Ch(t,e){return xh(t.prev,t,t.next)<0?xh(t,e,t.next)>=0&&xh(t,t.prev,e)>=0:xh(t,e,t.prev)<0||xh(t,t.next,e)<0}function Eh(t,e){const i=new Ph(t.i,t.x,t.y),n=new Ph(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Ih(t,e,i,n){const r=new Ph(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ah(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ph(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const Rh={area:function(t){const e=t.length;let i=0;for(let n=e-1,r=0;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i},isClockWise:function(t){return Rh.area(t)<0},triangulateShape:function(t,e){const i=[],n=[],r=[];Lh(t),Oh(i,t);let s=t.length;e.forEach(Lh);for(let t=0;t<e.length;t++)n.push(s),s+=e[t].length,Oh(i,e[t]);const o=oh(i,n);for(let t=0;t<o.length;t+=3)r.push(o.slice(t,t+3));return r}};function Lh(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Oh(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Nh extends hs{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],r=[];for(let e=0,i=t.length;e<i;e++){s(t[e])}function s(t){const s=[],o=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1;let c=void 0!==e.depth?e.depth:100,h=void 0===e.bevelEnabled||e.bevelEnabled,l=void 0!==e.bevelThickness?e.bevelThickness:6,u=void 0!==e.bevelSize?e.bevelSize:l-2,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:Dh;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),c=e.amount);let g,_,v,y,b,x=!1;f&&(g=f.getSpacedPoints(a),x=!0,h=!1,_=f.computeFrenetFrames(a,!1),v=new fn,y=new fn,b=new fn),h||(p=0,l=0,u=0,d=0);const w=t.extractPoints(o);let S=w.shape;const M=w.holes;if(!Rh.isClockWise(S)){S=S.reverse();for(let t=0,e=M.length;t<e;t++){const e=M[t];Rh.isClockWise(e)&&(M[t]=e.reverse())}}const T=Rh.triangulateShape(S,M),C=S;for(let t=0,e=M.length;t<e;t++){const e=M[t];S=S.concat(e)}function E(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}const I=S.length,A=T.length;function P(t,e,i){let n,r,s;const o=t.x-e.x,a=t.y-e.y,c=i.x-t.x,h=i.y-t.y,l=o*o+a*a,u=o*h-a*c;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(l),d=Math.sqrt(c*c+h*h),p=e.x-a/u,f=e.y+o/u,m=((i.x-h/d-p)*h-(i.y+c/d-f)*c)/(o*h-a*c);n=p+o*m-t.x,r=f+a*m-t.y;const g=n*n+r*r;if(g<=2)return new rn(n,r);s=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?c>Number.EPSILON&&(t=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(h)&&(t=!0),t?(n=-a,r=o,s=Math.sqrt(l)):(n=o,r=a,s=Math.sqrt(l/2))}return new rn(n/s,r/s)}const R=[];for(let t=0,e=C.length,i=e-1,n=t+1;t<e;t++,i++,n++)i===e&&(i=0),n===e&&(n=0),R[t]=P(C[t],C[i],C[n]);const L=[];let O,N=R.concat();for(let t=0,e=M.length;t<e;t++){const e=M[t];O=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),O[t]=P(e[t],e[n],e[r]);L.push(O),N=N.concat(O)}for(let t=0;t<p;t++){const e=t/p,i=l*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=C.length;t<e;t++){const e=E(C[t],R[t],n);k(e.x,e.y,-i)}for(let t=0,e=M.length;t<e;t++){const e=M[t];O=L[t];for(let t=0,r=e.length;t<r;t++){const r=E(e[t],O[t],n);k(r.x,r.y,-i)}}}const D=u+d;for(let t=0;t<I;t++){const e=h?E(S[t],N[t],D):S[t];x?(y.copy(_.normals[0]).multiplyScalar(e.x),v.copy(_.binormals[0]).multiplyScalar(e.y),b.copy(g[0]).add(y).add(v),k(b.x,b.y,b.z)):k(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<I;e++){const i=h?E(S[e],N[e],D):S[e];x?(y.copy(_.normals[t]).multiplyScalar(i.x),v.copy(_.binormals[t]).multiplyScalar(i.y),b.copy(g[t]).add(y).add(v),k(b.x,b.y,b.z)):k(i.x,i.y,c/a*t)}for(let t=p-1;t>=0;t--){const e=t/p,i=l*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=C.length;t<e;t++){const e=E(C[t],R[t],n);k(e.x,e.y,c+i)}for(let t=0,e=M.length;t<e;t++){const e=M[t];O=L[t];for(let t=0,r=e.length;t<r;t++){const r=E(e[t],O[t],n);x?k(r.x,r.y+g[a-1].y,g[a-1].x+i):k(r.x,r.y,c+i)}}}function $(t,e){let i=t.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=a+2*p;t<i;t++){const i=I*t,s=I*(t+1);F(e+n+i,e+r+i,e+r+s,e+n+s)}}}function k(t,e,i){s.push(t),s.push(e),s.push(i)}function z(t,e,r){B(t),B(e),B(r);const s=n.length/3,o=m.generateTopUV(i,n,s-3,s-2,s-1);j(o[0]),j(o[1]),j(o[2])}function F(t,e,r,s){B(t),B(e),B(s),B(e),B(r),B(s);const o=n.length/3,a=m.generateSideWallUV(i,n,o-6,o-3,o-2,o-1);j(a[0]),j(a[1]),j(a[3]),j(a[1]),j(a[2]),j(a[3])}function B(t){n.push(s[3*t+0]),n.push(s[3*t+1]),n.push(s[3*t+2])}function j(t){r.push(t.x),r.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=I*t;for(let t=0;t<A;t++){const i=T[t];z(i[2]+e,i[1]+e,i[0]+e)}t=a+2*p,e=I*t;for(let t=0;t<A;t++){const i=T[t];z(i[0]+e,i[1]+e,i[2]+e)}}else{for(let t=0;t<A;t++){const e=T[t];z(e[2],e[1],e[0])}for(let t=0;t<A;t++){const e=T[t];z(e[0]+I*a,e[1]+I*a,e[2]+I*a)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;$(C,e),e+=C.length;for(let t=0,i=M.length;t<i;t++){const i=M[t];$(i,e),e+=i.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new Jr(n,3)),this.setAttribute("uv",new Jr(r,2)),this.computeVertexNormals()}toJSON(){const t=hs.prototype.toJSON.call(this);return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){const n=t[e];i.shapes.push(n.uuid)}else i.shapes.push(t.uuid);void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,t)}}const Dh={generateTopUV:function(t,e,i,n,r){const s=e[3*i],o=e[3*i+1],a=e[3*n],c=e[3*n+1],h=e[3*r],l=e[3*r+1];return[new rn(s,o),new rn(a,c),new rn(h,l)]},generateSideWallUV:function(t,e,i,n,r,s){const o=e[3*i],a=e[3*i+1],c=e[3*i+2],h=e[3*n],l=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],_=e[3*s+2];return Math.abs(a-l)<.01?[new rn(o,1-c),new rn(h,1-u),new rn(d,1-f),new rn(m,1-_)]:[new rn(a,1-c),new rn(l,1-u),new rn(p,1-f),new rn(g,1-_)]}};function $h(t,e,i){hs.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i};const n=[],r=[],s=[],o=[],a=1e-5,c=new fn,h=new fn,l=new fn,u=new fn,d=new fn;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=e+1;for(let n=0;n<=i;n++){const p=n/i;for(let i=0;i<=e;i++){const n=i/e;t(n,p,h),r.push(h.x,h.y,h.z),n-a>=0?(t(n-a,p,l),u.subVectors(h,l)):(t(n+a,p,l),u.subVectors(l,h)),p-a>=0?(t(n,p-a,l),d.subVectors(h,l)):(t(n,p+a,l),d.subVectors(l,h)),c.crossVectors(u,d).normalize(),s.push(c.x,c.y,c.z),o.push(n,p)}}for(let t=0;t<i;t++)for(let i=0;i<e;i++){const e=t*p+i,r=t*p+i+1,s=(t+1)*p+i+1,o=(t+1)*p+i;n.push(e,r,o),n.push(r,s,o)}this.setIndex(n),this.setAttribute("position",new Jr(r,3)),this.setAttribute("normal",new Jr(s,3)),this.setAttribute("uv",new Jr(o,2))}$h.prototype=Object.create(hs.prototype),$h.prototype.constructor=$h;class kh extends hs{constructor(t,e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],r=[],s=[];let o=0,a=0;if(!1===Array.isArray(t))c(t);else for(let e=0;e<t.length;e++)c(t[e]),this.addGroup(o,a,e),o+=a,a=0;function c(t){const o=n.length/3,c=t.extractPoints(e);let h=c.shape;const l=c.holes;!1===Rh.isClockWise(h)&&(h=h.reverse());for(let t=0,e=l.length;t<e;t++){const e=l[t];!0===Rh.isClockWise(e)&&(l[t]=e.reverse())}const u=Rh.triangulateShape(h,l);for(let t=0,e=l.length;t<e;t++){const e=l[t];h=h.concat(e)}for(let t=0,e=h.length;t<e;t++){const e=h[t];n.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],n=e[0]+o,r=e[1]+o,s=e[2]+o;i.push(n,r,s),a+=3}}this.setIndex(i),this.setAttribute("position",new Jr(n,3)),this.setAttribute("normal",new Jr(r,3)),this.setAttribute("uv",new Jr(s,2))}toJSON(){const t=hs.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}}class zh extends hs{constructor(t=1,e=8,i=6,n=0,r=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(s+o,Math.PI);let c=0;const h=[],l=new fn,u=new fn,d=[],p=[],f=[],m=[];for(let d=0;d<=i;d++){const g=[],_=d/i;let v=0;0==d&&0==s?v=.5/e:d==i&&a==Math.PI&&(v=-.5/e);for(let i=0;i<=e;i++){const a=i/e;l.x=-t*Math.cos(n+a*r)*Math.sin(s+_*o),l.y=t*Math.cos(s+_*o),l.z=t*Math.sin(n+a*r)*Math.sin(s+_*o),p.push(l.x,l.y,l.z),u.copy(l).normalize(),f.push(u.x,u.y,u.z),m.push(a+v,1-_),g.push(c++)}h.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=h[t][n+1],r=h[t][n],o=h[t+1][n],c=h[t+1][n+1];(0!==t||s>0)&&d.push(e,r,c),(t!==i-1||a<Math.PI)&&d.push(r,o,c)}this.setIndex(d),this.setAttribute("position",new Jr(p,3)),this.setAttribute("normal",new Jr(f,3)),this.setAttribute("uv",new Jr(m,2))}}function Fh(t){zr.call(this),this.type="ShadowMaterial",this.color=new Dr(0),this.transparent=!0,this.setValues(t)}function Bh(t){Os.call(this,t),this.type="RawShaderMaterial"}function jh(t){zr.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Dr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}function Hh(t){jh.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new rn(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=nn.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}function Uh(t){zr.call(this),this.type="MeshPhongMaterial",this.color=new Dr(16777215),this.specular=new Dr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Vh(t){zr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Dr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gh(t){zr.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function qh(t){zr.call(this),this.type="MeshLambertMaterial",this.color=new Dr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Wh(t){zr.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Dr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Xh(t){kc.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Fh.prototype=Object.create(zr.prototype),Fh.prototype.constructor=Fh,Fh.prototype.isShadowMaterial=!0,Fh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this},Bh.prototype=Object.create(Os.prototype),Bh.prototype.constructor=Bh,Bh.prototype.isRawShaderMaterial=!0,jh.prototype=Object.create(zr.prototype),jh.prototype.constructor=jh,jh.prototype.isMeshStandardMaterial=!0,jh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this},Hh.prototype=Object.create(jh.prototype),Hh.prototype.constructor=Hh,Hh.prototype.isMeshPhysicalMaterial=!0,Hh.prototype.copy=function(t){return jh.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new Dr).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this},Uh.prototype=Object.create(zr.prototype),Uh.prototype.constructor=Uh,Uh.prototype.isMeshPhongMaterial=!0,Uh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Vh.prototype=Object.create(zr.prototype),Vh.prototype.constructor=Vh,Vh.prototype.isMeshToonMaterial=!0,Vh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gh.prototype=Object.create(zr.prototype),Gh.prototype.constructor=Gh,Gh.prototype.isMeshNormalMaterial=!0,Gh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},qh.prototype=Object.create(zr.prototype),qh.prototype.constructor=qh,qh.prototype.isMeshLambertMaterial=!0,qh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Wh.prototype=Object.create(zr.prototype),Wh.prototype.constructor=Wh,Wh.prototype.isMeshMatcapMaterial=!0,Wh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Xh.prototype=Object.create(kc.prototype),Xh.prototype.constructor=Xh,Xh.prototype.isLineDashedMaterial=!0,Xh.prototype.copy=function(t){return kc.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Yh=Object.freeze({__proto__:null,ShadowMaterial:Fh,SpriteMaterial:nc,RawShaderMaterial:Bh,ShaderMaterial:Os,PointsMaterial:Xc,MeshPhysicalMaterial:Hh,MeshStandardMaterial:jh,MeshPhongMaterial:Uh,MeshToonMaterial:Vh,MeshNormalMaterial:Gh,MeshLambertMaterial:qh,MeshDepthMaterial:Ba,MeshDistanceMaterial:ja,MeshBasicMaterial:Fr,MeshMatcapMaterial:Wh,LineDashedMaterial:Xh,LineBasicMaterial:kc,Material:zr});const Zh={arraySlice:function(t,e,i){return Zh.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){const n=t.length,r=new t.constructor(n);for(let s=0,o=0;o!==n;++s){const n=i[s]*e;for(let i=0;i!==e;++i)r[o++]=t[n+i]}return r},flattenJSON:function(t,e,i,n){let r=1,s=t[0];for(;void 0!==s&&void 0===s[n];)s=t[r++];if(void 0===s)return;let o=s[n];if(void 0!==o)if(Array.isArray(o))do{o=s[n],void 0!==o&&(e.push(s.time),i.push.apply(i,o)),s=t[r++]}while(void 0!==s);else if(void 0!==o.toArray)do{o=s[n],void 0!==o&&(e.push(s.time),o.toArray(i,i.length)),s=t[r++]}while(void 0!==s);else do{o=s[n],void 0!==o&&(e.push(s.time),i.push(o)),s=t[r++]}while(void 0!==s)},subclip:function(t,e,i,n,r=30){const s=t.clone();s.name=e;const o=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],a=e.getValueSize(),c=[],h=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<i||s>=n)){c.push(e.times[t]);for(let i=0;i<a;++i)h.push(e.values[t*a+i])}}0!==c.length&&(e.times=Zh.convertArray(c,e.times.constructor),e.values=Zh.convertArray(h,e.values.constructor),o.push(e))}s.tracks=o;let a=1/0;for(let t=0;t<s.tracks.length;++t)a>s.tracks[t].times[0]&&(a=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,s=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const o=t.tracks.find((function(t){return t.name===n.name&&t.ValueTypeName===r}));if(void 0===o)continue;let a=0;const c=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=c/3);let h=0;const l=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=l/3);const u=n.times.length-1;let d;if(s<=n.times[0]){const t=a,e=c-a;d=Zh.arraySlice(n.values,t,e)}else if(s>=n.times[u]){const t=u*c+a,e=t+c-a;d=Zh.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=a,i=c-a;t.evaluate(s),d=Zh.arraySlice(t.resultBuffer,e,i)}if("quaternion"===r){(new pn).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let t=0;t<p;++t){const e=t*l+h;if("quaternion"===r)pn.multiplyQuaternionsFlat(o.values,e,d,0,o.values,e);else{const t=l-2*h;for(let i=0;i<t;++i)o.values[e+i]-=d[i]}}}return t.blendMode=2501,t}};function Jh(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function Kh(t,e,i,n){Jh.call(this,t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Qh(t,e,i,n){Jh.call(this,t,e,i,n)}function tl(t,e,i,n){Jh.call(this,t,e,i,n)}function el(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Zh.convertArray(e,this.TimeBufferType),this.values=Zh.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}function il(t,e,i){el.call(this,t,e,i)}function nl(t,e,i,n){el.call(this,t,e,i,n)}function rl(t,e,i,n){el.call(this,t,e,i,n)}function sl(t,e,i,n){Jh.call(this,t,e,i,n)}function ol(t,e,i,n){el.call(this,t,e,i,n)}function al(t,e,i,n){el.call(this,t,e,i,n)}function cl(t,e,i,n){el.call(this,t,e,i,n)}function hl(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=nn.generateUUID(),this.duration<0&&this.resetDuration()}function ll(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return rl;case"vector":case"vector2":case"vector3":case"vector4":return cl;case"color":return nl;case"quaternion":return ol;case"bool":case"boolean":return il;case"string":return al}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];Zh.flattenJSON(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(Jh.prototype,{evaluate:function(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let s;i:{n:if(!(t<n)){for(let s=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,r)}if(i===s)break;if(r=n,n=e[++i],t<n)break e}s=e.length;break i}if(t>=r)break t;{const o=e[1];t<o&&(i=2,r=o);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===s)break;if(n=r,r=e[--i-1],t>=r)break e}s=i,i=0}}for(;i<s;){const n=i+s>>>1;t<e[n]?s=n:i=n+1}if(n=e[i],r=e[i-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,r,t)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n;for(let t=0;t!==n;++t)e[t]=i[r+t];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Jh.prototype,{beforeStart_:Jh.prototype.copySampleValue_,afterEnd_:Jh.prototype.copySampleValue_}),Kh.prototype=Object.assign(Object.create(Jh.prototype),{constructor:Kh,DefaultSettings_:{endingStart:Vi,endingEnd:Vi},intervalChanged_:function(t,e,i){const n=this.parameterPositions;let r=t-2,s=t+1,o=n[r],a=n[s];if(void 0===o)switch(this.getSettings_().endingStart){case Gi:r=t,o=2*e-i;break;case qi:r=n.length-2,o=e+n[r]-n[r+1];break;default:r=t,o=i}if(void 0===a)switch(this.getSettings_().endingEnd){case Gi:s=t,a=2*i-e;break;case qi:s=1,a=i+n[1]-n[0];break;default:s=t-1,a=e}const c=.5*(i-e),h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(a-i),this._offsetPrev=r*h,this._offsetNext=s*h},interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,c=a-o,h=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,_=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,v=(-1-d)*m+(1.5+d)*f+.5*p,y=d*m-d*f;for(let t=0;t!==o;++t)r[t]=g*s[h+t]+_*s[c+t]+v*s[a+t]+y*s[l+t];return r}}),Qh.prototype=Object.assign(Object.create(Jh.prototype),{constructor:Qh,interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,c=a-o,h=(i-e)/(n-e),l=1-h;for(let t=0;t!==o;++t)r[t]=s[c+t]*l+s[a+t]*h;return r}}),tl.prototype=Object.assign(Object.create(Jh.prototype),{constructor:tl,interpolate_:function(t){return this.copySampleValue_(t-1)}}),Object.assign(el,{toJSON:function(t){const e=t.constructor;let i;if(void 0!==e.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Zh.convertArray(t.times,Array),values:Zh.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}}),Object.assign(el.prototype,{constructor:el,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Hi,InterpolantFactoryMethodDiscrete:function(t){return new tl(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Qh(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Kh(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){let e;switch(t){case ji:e=this.InterpolantFactoryMethodDiscrete;break;case Hi:e=this.InterpolantFactoryMethodLinear;break;case Ui:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ji;case this.InterpolantFactoryMethodLinear:return Hi;case this.InterpolantFactoryMethodSmooth:return Ui}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this},scale:function(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this},trim:function(t,e){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<t;)++r;for(;-1!==s&&i[s]>e;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=Zh.arraySlice(i,r,s),this.values=Zh.arraySlice(this.values,r*t,s*t)}return this},validate:function(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,s),t=!1;break}s=n}if(void 0!==n&&Zh.isTypedArray(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t},optimize:function(){const t=Zh.arraySlice(this.times),e=Zh.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===Ui,r=t.length-1;let s=1;for(let o=1;o<r;++o){let r=!1;const a=t[o];if(a!==t[o+1]&&(1!==o||a!==t[0]))if(n)r=!0;else{const t=o*i,n=t-i,s=t+i;for(let o=0;o!==i;++o){const i=e[t+o];if(i!==e[n+o]||i!==e[s+o]){r=!0;break}}}if(r){if(o!==s){t[s]=t[o];const n=o*i,r=s*i;for(let t=0;t!==i;++t)e[r+t]=e[n+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*i,n=s*i,o=0;o!==i;++o)e[n+o]=e[t+o];++s}return s!==t.length?(this.times=Zh.arraySlice(t,0,s),this.values=Zh.arraySlice(e,0,s*i)):(this.times=t,this.values=e),this},clone:function(){const t=Zh.arraySlice(this.times,0),e=Zh.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}),il.prototype=Object.assign(Object.create(el.prototype),{constructor:il,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:ji,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),nl.prototype=Object.assign(Object.create(el.prototype),{constructor:nl,ValueTypeName:"color"}),rl.prototype=Object.assign(Object.create(el.prototype),{constructor:rl,ValueTypeName:"number"}),sl.prototype=Object.assign(Object.create(Jh.prototype),{constructor:sl,interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(i-e)/(n-e);let c=t*o;for(let t=c+o;c!==t;c+=4)pn.slerpFlat(r,0,s,c-o,s,c,a);return r}}),ol.prototype=Object.assign(Object.create(el.prototype),{constructor:ol,ValueTypeName:"quaternion",DefaultInterpolation:Hi,InterpolantFactoryMethodLinear:function(t){return new sl(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),al.prototype=Object.assign(Object.create(el.prototype),{constructor:al,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:ji,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),cl.prototype=Object.assign(Object.create(el.prototype),{constructor:cl,ValueTypeName:"vector"}),Object.assign(hl,{parse:function(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(ll(i[t]).scale(n));const r=new hl(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r},toJSON:function(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(el.toJSON(i[t]));return n},CreateFromMorphTargetSequence:function(t,e,i,n){const r=e.length,s=[];for(let t=0;t<r;t++){let o=[],a=[];o.push((t+r-1)%r,t,(t+1)%r),a.push(0,1,0);const c=Zh.getKeyframeOrder(o);o=Zh.sortedArray(o,1,c),a=Zh.sortedArray(a,1,c),n||0!==o[0]||(o.push(r),a.push(a[0])),s.push(new rl(".morphTargetInfluences["+e[t].name+"]",o,a).scale(1/i))}return new hl(t,-1,s)},findByName:function(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<i.length;t++)if(i[t].name===e)return i[t];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.name.match(r);if(s&&s.length>1){const t=s[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const s=[];for(const t in n)s.push(hl.CreateFromMorphTargetSequence(t,n[t],e,i));return s},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const s=[],o=[];Zh.flattenJSON(i,s,o,n),0!==s.length&&r.push(new t(e,s,o))}},n=[],r=t.name||"default",s=t.fps||30,o=t.blendMode;let a=t.length||-1;const c=t.hierarchy||[];for(let t=0;t<c.length;t++){const r=c[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let i=0;i<r[e].morphTargets.length;i++)t[r[e].morphTargets[i]]=-1;for(const i in t){const t=[],s=[];for(let n=0;n!==r[e].morphTargets.length;++n){const n=r[e];t.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new rl(".morphTargetInfluence["+i+"]",t,s))}a=t.length*(s||1)}else{const s=".bones["+e[t].name+"]";i(cl,s+".position",r,"pos",n),i(ol,s+".quaternion",r,"rot",n),i(cl,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new hl(r,a,n,o)}}),Object.assign(hl.prototype,{resetDuration:function(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this},trim:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new hl(this.name,this.duration,t,this.blendMode)},toJSON:function(){return hl.toJSON(this)}});const ul={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};const dl=new function(t,e,i){const n=this;let r,s=!1,o=0,a=0;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===s&&void 0!==n.onStart&&n.onStart(t,o,a),s=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return c.push(t,e),this},this.removeHandler=function(t){const e=c.indexOf(t);return-1!==e&&c.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=c.length;e<i;e+=2){const i=c[e],n=c[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}};function pl(t){this.manager=void 0!==t?t:dl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(pl.prototype,{load:function(){},loadAsync:function(t,e){const i=this;return new Promise((function(n,r){i.load(t,n,e,r)}))},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});const fl={};function ml(t){pl.call(this,t)}function gl(t){pl.call(this,t)}function _l(t){pl.call(this,t)}function vl(t){pl.call(this,t)}function yl(t){pl.call(this,t)}function bl(t){pl.call(this,t)}function xl(t){pl.call(this,t)}function wl(){this.type="Curve",this.arcLengthDivisions=200}function Sl(t,e,i,n,r,s,o,a){wl.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=i||1,this.yRadius=n||1,this.aStartAngle=r||0,this.aEndAngle=s||2*Math.PI,this.aClockwise=o||!1,this.aRotation=a||0}function Ml(t,e,i,n,r,s){Sl.call(this,t,e,i,i,n,r,s),this.type="ArcCurve"}function Tl(){let t=0,e=0,i=0,n=0;function r(r,s,o,a){t=r,e=o,i=-3*r+3*s-2*o-a,n=2*r-2*s+o+a}return{initCatmullRom:function(t,e,i,n,s){r(e,i,s*(i-t),s*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,s,o,a){let c=(e-t)/s-(i-t)/(s+o)+(i-e)/o,h=(i-e)/o-(n-e)/(o+a)+(n-i)/a;c*=o,h*=o,r(e,i,c,h)},calc:function(r){const s=r*r;return t+e*r+i*s+n*(s*r)}}}ml.prototype=Object.assign(Object.create(pl.prototype),{constructor:ml,load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;if(void 0!==fl[t])return void fl[t].push({onLoad:e,onProgress:i,onError:n});const o=t.match(/^data:(.*?)(;base64)?,(.*)$/);let a;if(o){const i=o[1],s=!!o[2];let a=o[3];a=decodeURIComponent(a),s&&(a=atob(a));try{let n;const s=(this.responseType||"").toLowerCase();switch(s){case"arraybuffer":case"blob":const t=new Uint8Array(a.length);for(let e=0;e<a.length;e++)t[e]=a.charCodeAt(e);n="blob"===s?new Blob([t.buffer],{type:i}):t.buffer;break;case"document":const e=new DOMParser;n=e.parseFromString(a,i);break;case"json":n=JSON.parse(a);break;default:n=a}setTimeout((function(){e&&e(n),r.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}),0)}}else{fl[t]=[],fl[t].push({onLoad:e,onProgress:i,onError:n}),a=new XMLHttpRequest,a.open("GET",t,!0),a.addEventListener("load",(function(e){const i=this.response,n=fl[t];if(delete fl[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),ul.add(t,i);for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onLoad&&e.onLoad(i)}r.manager.itemEnd(t)}else{for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}}),!1),a.addEventListener("progress",(function(e){const i=fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onProgress&&n.onProgress(e)}}),!1),a.addEventListener("error",(function(e){const i=fl[t];delete fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),a.addEventListener("abort",(function(e){const i=fl[t];delete fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(a.responseType=this.responseType),void 0!==this.withCredentials&&(a.withCredentials=this.withCredentials),a.overrideMimeType&&a.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const t in this.requestHeader)a.setRequestHeader(t,this.requestHeader[t]);a.send(null)}return r.manager.itemStart(t),a},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}}),gl.prototype=Object.assign(Object.create(pl.prototype),{constructor:gl,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e=[];for(let i=0;i<t.length;i++){const n=hl.parse(t[i]);e.push(n)}return e}}),_l.prototype=Object.assign(Object.create(pl.prototype),{constructor:_l,load:function(t,e,i,n){const r=this,s=[],o=new ih,a=new ml(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let c=0;function h(h){a.load(t[h],(function(t){const i=r.parse(t,!0);s[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},c+=1,6===c&&(1===i.mipmapCount&&(o.minFilter=Ai),o.image=s,o.format=i.format,o.needsUpdate=!0,e&&e(o))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)h(e);else a.load(t,(function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}o.image=s}else o.image.width=i.width,o.image.height=i.height,o.mipmaps=i.mipmaps;1===i.mipmapCount&&(o.minFilter=Ai),o.format=i.format,o.needsUpdate=!0,e&&e(o)}),i,n);return o}}),vl.prototype=Object.assign(Object.create(pl.prototype),{constructor:vl,load:function(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),ul.add(t,this),e&&e(this),r.manager.itemEnd(t)}function c(e){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}return o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}),yl.prototype=Object.assign(Object.create(pl.prototype),{constructor:yl,load:function(t,e,i,n){const r=new zs,s=new vl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function a(i){s.load(t[i],(function(t){r.images[i]=t,o++,6===o&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(let e=0;e<t.length;++e)a(e);return r}}),bl.prototype=Object.assign(Object.create(pl.prototype),{constructor:bl,load:function(t,e,i,n){const r=this,s=new Bs,o=new ml(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(t,(function(t){const i=r.parse(t);i&&(void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:Ci,s.wrapT=void 0!==i.wrapT?i.wrapT:Ci,s.magFilter=void 0!==i.magFilter?i.magFilter:Ai,s.minFilter=void 0!==i.minFilter?i.minFilter:Ai,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.encoding&&(s.encoding=i.encoding),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=Pi),1===i.mipmapCount&&(s.minFilter=Ai),s.needsUpdate=!0,e&&e(s,i))}),i,n),s}}),xl.prototype=Object.assign(Object.create(pl.prototype),{constructor:xl,load:function(t,e,i,n){const r=new hn,s=new vl(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(i){r.image=i;const n=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);r.format=n?ki:zi,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}),Object.assign(wl.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){const t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,n=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)i=this.getPoint(s/t),r+=i.distanceTo(n),e.push(r),n=i;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){const i=this.getLengths();let n=0;const r=i.length;let s;s=e||t*i[r-1];let o,a=0,c=r-1;for(;a<=c;)if(n=Math.floor(a+(c-a)/2),o=i[n]-s,o<0)a=n+1;else{if(!(o>0)){c=n;break}c=n-1}if(n=c,i[n]===s)return n/(r-1);const h=i[n];return(n+(s-h)/(i[n+1]-h))/(r-1)},getTangent:function(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),o=this.getPoint(r),a=e||(s.isVector2?new rn:new fn);return a.copy(o).sub(s).normalize(),a},getTangentAt:function(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)},computeFrenetFrames:function(t,e){const i=new fn,n=[],r=[],s=[],o=new fn,a=new Hn;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new fn),n[e].normalize()}r[0]=new fn,s[0]=new fn;let c=Number.MAX_VALUE;const h=Math.abs(n[0].x),l=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=c&&(c=h,i.set(1,0,0)),l<=c&&(c=l,i.set(0,1,0)),u<=c&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],o),s[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),o.crossVectors(n[e-1],n[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(nn.clamp(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(o,t))}s[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(nn.clamp(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(o.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],e*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),Sl.prototype=Object.create(wl.prototype),Sl.prototype.constructor=Sl,Sl.prototype.isEllipseCurve=!0,Sl.prototype.getPoint=function(t,e){const i=e||new rn,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const o=this.aStartAngle+t*r;let a=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=a-this.aX,n=c-this.aY;a=i*t-n*e+this.aX,c=i*e+n*t+this.aY}return i.set(a,c)},Sl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Sl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},Sl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Ml.prototype=Object.create(Sl.prototype),Ml.prototype.constructor=Ml,Ml.prototype.isArcCurve=!0;const Cl=new fn,El=new Tl,Il=new Tl,Al=new Tl;function Pl(t=[],e=!1,i="centripetal",n=.5){wl.call(this),this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}function Rl(t,e,i,n,r){const s=.5*(n-e),o=.5*(r-i),a=t*t;return(2*i-2*n+s+o)*(t*a)+(-3*i+3*n-2*s-o)*a+s*t+i}function Ll(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function Ol(t,e,i,n,r){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}function Nl(t=new rn,e=new rn,i=new rn,n=new rn){wl.call(this),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}function Dl(t=new fn,e=new fn,i=new fn,n=new fn){wl.call(this),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}function $l(t=new rn,e=new rn){wl.call(this),this.type="LineCurve",this.v1=t,this.v2=e}function kl(t=new fn,e=new fn){wl.call(this),this.type="LineCurve3",this.v1=t,this.v2=e}function zl(t=new rn,e=new rn,i=new rn){wl.call(this),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}function Fl(t=new fn,e=new fn,i=new fn){wl.call(this),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}function Bl(t=[]){wl.call(this),this.type="SplineCurve",this.points=t}Pl.prototype=Object.create(wl.prototype),Pl.prototype.constructor=Pl,Pl.prototype.isCatmullRomCurve3=!0,Pl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.points,r=n.length,s=(r-(this.closed?0:1))*t;let o,a,c=Math.floor(s),h=s-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/r)+1)*r:0===h&&c===r-1&&(c=r-2,h=1),this.closed||c>0?o=n[(c-1)%r]:(Cl.subVectors(n[0],n[1]).add(n[0]),o=Cl);const l=n[c%r],u=n[(c+1)%r];if(this.closed||c+2<r?a=n[(c+2)%r]:(Cl.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=Cl),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(o.distanceToSquared(l),t),i=Math.pow(l.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(a),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),El.initNonuniformCatmullRom(o.x,l.x,u.x,a.x,e,i,n),Il.initNonuniformCatmullRom(o.y,l.y,u.y,a.y,e,i,n),Al.initNonuniformCatmullRom(o.z,l.z,u.z,a.z,e,i,n)}else"catmullrom"===this.curveType&&(El.initCatmullRom(o.x,l.x,u.x,a.x,this.tension),Il.initCatmullRom(o.y,l.y,u.y,a.y,this.tension),Al.initCatmullRom(o.z,l.z,u.z,a.z,this.tension));return i.set(El.calc(h),Il.calc(h),Al.calc(h)),i},Pl.prototype.copy=function(t){wl.prototype.copy.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Pl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},Pl.prototype.fromJSON=function(t){wl.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new fn).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Nl.prototype=Object.create(wl.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isCubicBezierCurve=!0,Nl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Ol(t,n.x,r.x,s.x,o.x),Ol(t,n.y,r.y,s.y,o.y)),i},Nl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Nl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Nl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},Dl.prototype=Object.create(wl.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isCubicBezierCurve3=!0,Dl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Ol(t,n.x,r.x,s.x,o.x),Ol(t,n.y,r.y,s.y,o.y),Ol(t,n.z,r.z,s.z,o.z)),i},Dl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Dl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Dl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},$l.prototype=Object.create(wl.prototype),$l.prototype.constructor=$l,$l.prototype.isLineCurve=!0,$l.prototype.getPoint=function(t,e=new rn){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},$l.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},$l.prototype.getTangent=function(t,e){const i=e||new rn;return i.copy(this.v2).sub(this.v1).normalize(),i},$l.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},$l.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},$l.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},kl.prototype=Object.create(wl.prototype),kl.prototype.constructor=kl,kl.prototype.isLineCurve3=!0,kl.prototype.getPoint=function(t,e=new fn){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},kl.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},kl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},kl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},kl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},zl.prototype=Object.create(wl.prototype),zl.prototype.constructor=zl,zl.prototype.isQuadraticBezierCurve=!0,zl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Ll(t,n.x,r.x,s.x),Ll(t,n.y,r.y,s.y)),i},zl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},zl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},zl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Fl.prototype=Object.create(wl.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isQuadraticBezierCurve3=!0,Fl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Ll(t,n.x,r.x,s.x),Ll(t,n.y,r.y,s.y),Ll(t,n.z,r.z,s.z)),i},Fl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Fl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Fl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Bl.prototype=Object.create(wl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isSplineCurve=!0,Bl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.points,r=(n.length-1)*t,s=Math.floor(r),o=r-s,a=n[0===s?s:s-1],c=n[s],h=n[s>n.length-2?n.length-1:s+1],l=n[s>n.length-3?n.length-1:s+2];return i.set(Rl(o,a.x,c.x,h.x,l.x),Rl(o,a.y,c.y,h.y,l.y)),i},Bl.prototype.copy=function(t){wl.prototype.copy.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this},Bl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t},Bl.prototype.fromJSON=function(t){wl.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new rn).fromArray(i))}return this};var jl=Object.freeze({__proto__:null,ArcCurve:Ml,CatmullRomCurve3:Pl,CubicBezierCurve:Nl,CubicBezierCurve3:Dl,EllipseCurve:Sl,LineCurve:$l,LineCurve3:kl,QuadraticBezierCurve:zl,QuadraticBezierCurve3:Fl,SplineCurve:Bl});function Hl(){wl.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Ul(t){Hl.call(this),this.type="Path",this.currentPoint=new rn,t&&this.setFromPoints(t)}function Vl(t){Ul.call(this,t),this.uuid=nn.generateUUID(),this.type="Shape",this.holes=[]}function Gl(t,e=1){pr.call(this),this.type="Light",this.color=new Dr(t),this.intensity=e}function ql(t,e,i){Gl.call(this,t,i),this.type="HemisphereLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.groundColor=new Dr(e)}function Wl(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new rn(512,512),this.map=null,this.mapPass=null,this.matrix=new Hn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Us,this._frameExtents=new rn(1,1),this._viewportCount=1,this._viewports=[new un(0,0,1,1)]}function Xl(){Wl.call(this,new Ds(50,1,.5,500)),this.focus=1}function Yl(t,e,i,n,r,s){Gl.call(this,t,e),this.type="SpotLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.target=new pr,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==s?s:1,this.shadow=new Xl}function Zl(){Wl.call(this,new Ds(90,1,.5,500)),this._frameExtents=new rn(4,2),this._viewportCount=6,this._viewports=[new un(2,1,1,1),new un(0,1,1,1),new un(3,1,1,1),new un(1,1,1,1),new un(3,0,1,1),new un(1,0,1,1)],this._cubeDirections=[new fn(1,0,0),new fn(-1,0,0),new fn(0,0,1),new fn(0,0,-1),new fn(0,1,0),new fn(0,-1,0)],this._cubeUps=[new fn(0,1,0),new fn(0,1,0),new fn(0,1,0),new fn(0,1,0),new fn(0,0,1),new fn(0,0,-1)]}function Jl(t,e,i,n){Gl.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==n?n:1,this.shadow=new Zl}function Kl(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){Ns.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}function Ql(){Wl.call(this,new Kl(-5,5,5,-5,.5,500))}function tu(t,e){Gl.call(this,t,e),this.type="DirectionalLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.target=new pr,this.shadow=new Ql}function eu(t,e){Gl.call(this,t,e),this.type="AmbientLight"}function iu(t,e,i,n){Gl.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==n?n:10}Hl.prototype=Object.assign(Object.create(wl.prototype),{constructor:Hl,add:function(t){this.curves.push(t)},closePath:function(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new $l(e,t))},getPoint:function(t){const e=t*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=e){const t=i[n]-e,r=this.curves[n],s=r.getLength(),o=0===s?0:1-t/s;return r.getPointAt(o)}n++}return null},getLength:function(){const t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t=12){const e=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],o=s&&s.isEllipseCurve?2*t:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?t*s.points.length:t,a=s.getPoints(o);for(let t=0;t<a.length;t++){const n=a[t];i&&i.equals(n)||(e.push(n),i=n)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){wl.prototype.copy.call(this,t),this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){const t=wl.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t},fromJSON:function(t){wl.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new jl[i.type]).fromJSON(i))}return this}}),Ul.prototype=Object.assign(Object.create(Hl.prototype),{constructor:Ul,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){const i=new $l(this.currentPoint.clone(),new rn(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,i,n){const r=new zl(this.currentPoint.clone(),new rn(t,e),new rn(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this},bezierCurveTo:function(t,e,i,n,r,s){const o=new Nl(this.currentPoint.clone(),new rn(t,e),new rn(i,n),new rn(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this},splineThru:function(t){const e=new Bl([this.currentPoint.clone()].concat(t));return this.curves.push(e),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,i,n,r,s){const o=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(t+o,e+a,i,n,r,s),this},absarc:function(t,e,i,n,r,s){return this.absellipse(t,e,i,i,n,r,s),this},ellipse:function(t,e,i,n,r,s,o,a){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,i,n,r,s,o,a),this},absellipse:function(t,e,i,n,r,s,o,a){const c=new Sl(t,e,i,n,r,s,o,a);if(this.curves.length>0){const t=c.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this},copy:function(t){return Hl.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){const t=Hl.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Hl.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Vl.prototype=Object.assign(Object.create(Ul.prototype),{constructor:Vl,getPointsHoles:function(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){Ul.prototype.copy.call(this,t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this},toJSON:function(){const t=Ul.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t},fromJSON:function(t){Ul.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new Ul).fromJSON(i))}return this}}),Gl.prototype=Object.assign(Object.create(pr.prototype),{constructor:Gl,isLight:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),ql.prototype=Object.assign(Object.create(Gl.prototype),{constructor:ql,isHemisphereLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Wl.prototype,{_projScreenMatrix:new Hn,_lightPositionWorld:new fn,_lookTarget:new fn,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){const e=this.camera,i=this.matrix,n=this._projScreenMatrix,r=this._lookTarget,s=this._lightPositionWorld;s.setFromMatrixPosition(t.matrixWorld),e.position.copy(s),r.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(r),e.updateMatrixWorld(),n.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(n),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(e.projectionMatrix),i.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Xl.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Xl,isSpotLightShadow:!0,updateMatrices:function(t){const e=this.camera,i=2*nn.RAD2DEG*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),Wl.prototype.updateMatrices.call(this,t)}}),Yl.prototype=Object.assign(Object.create(Gl.prototype),{constructor:Yl,isSpotLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Zl.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Zl,isPointLightShadow:!0,updateMatrices:function(t,e=0){const i=this.camera,n=this.matrix,r=this._lightPositionWorld,s=this._lookTarget,o=this._projScreenMatrix;r.setFromMatrixPosition(t.matrixWorld),i.position.copy(r),s.copy(i.position),s.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(s),i.updateMatrixWorld(),n.makeTranslation(-r.x,-r.y,-r.z),o.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}}),Jl.prototype=Object.assign(Object.create(Gl.prototype),{constructor:Jl,isPointLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Kl.prototype=Object.assign(Object.create(Ns.prototype),{constructor:Kl,isOrthographicCamera:!0,copy:function(t,e){return Ns.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,o=n+e,a=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,o-=e*this.view.offsetY,a=o-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Ql.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Ql,isDirectionalLightShadow:!0,updateMatrices:function(t){Wl.prototype.updateMatrices.call(this,t)}}),tu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:tu,isDirectionalLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),eu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:eu,isAmbientLight:!0}),iu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:iu,isRectAreaLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){const e=Gl.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});class nu{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new fn)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*n),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*i),e.addScaledVector(s[4],i*n*1.092548),e.addScaledVector(s[5],n*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],i*r*1.092548),e.addScaledVector(s[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*n),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*i),e.addScaledVector(s[4],.858086*i*n),e.addScaledVector(s[5],.858086*n*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*i*r),e.addScaledVector(s[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}function ru(t,e){Gl.call(this,void 0,e),this.type="LightProbe",this.sh=void 0!==t?t:new nu}function su(t){pl.call(this,t),this.textures={}}ru.prototype=Object.assign(Object.create(Gl.prototype),{constructor:ru,isLightProbe:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.sh.copy(t.sh),this},fromJSON:function(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this},toJSON:function(t){const e=Gl.prototype.toJSON.call(this,t);return e.object.sh=this.sh.toArray(),e}}),su.prototype=Object.assign(Object.create(pl.prototype),{constructor:su,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const n=new Yh[t.type];if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=(new Dr).setHex(t.sheen)),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),1!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(n.skinning=t.skinning),void 0!==t.morphTargets&&(n.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(n.morphNormals=t.morphNormals),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.vertexTangents&&(n.vertexTangents=t.vertexTangents),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(n.uniforms[e]={},r.type){case"t":n.uniforms[e].value=i(r.value);break;case"c":n.uniforms[e].value=(new Dr).setHex(r.value);break;case"v2":n.uniforms[e].value=(new rn).fromArray(r.value);break;case"v3":n.uniforms[e].value=(new fn).fromArray(r.value);break;case"v4":n.uniforms[e].value=(new un).fromArray(r.value);break;case"m3":n.uniforms[e].value=(new sn).fromArray(r.value);break;case"m4":n.uniforms[e].value=(new Hn).fromArray(r.value);break;default:n.uniforms[e].value=r.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new rn).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new rn).fromArray(t.clearcoatNormalScale)),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),n},setTextures:function(t){return this.textures=t,this}});const ou=function(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function au(){hs.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function cu(t,e,i,n){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Hr.call(this,t,e,i),this.meshPerAttribute=n||1}function hu(t){pl.call(this,t)}function lu(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),pl.call(this,t),this.options={premultiplyAlpha:"none"}}function uu(){this.type="ShapePath",this.color=new Dr,this.subPaths=[],this.currentPath=null}au.prototype=Object.assign(Object.create(hs.prototype),{constructor:au,isInstancedBufferGeometry:!0,copy:function(t){return hs.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t=hs.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),cu.prototype=Object.assign(Object.create(Hr.prototype),{constructor:cu,isInstancedBufferAttribute:!0,copy:function(t){return Hr.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){const t=Hr.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),hu.prototype=Object.assign(Object.create(pl.prototype),{constructor:hu,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const r=t.interleavedBuffers[n],s=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers[e],r=new Uint32Array(n).buffer;return i[e]=r,r}(t,r.buffer),o=new tc(es(r.type,s),r.stride);return o.uuid=r.uuid,e[n]=o,o}const r=t.isInstancedBufferGeometry?new au:new hs,s=t.data.index;if(void 0!==s){const t=es(s.type,s.array);r.setIndex(new Hr(t,1))}const o=t.data.attributes;for(const e in o){const i=o[e];let s;if(i.isInterleavedBufferAttribute){s=new ic(n(t.data,i.data),i.itemSize,i.offset,i.normalized)}else{const t=es(i.type,i.array);s=new(i.isInstancedBufferAttribute?cu:Hr)(t,i.itemSize,i.normalized)}void 0!==i.name&&(s.name=i.name),r.setAttribute(e,s)}const a=t.data.morphAttributes;if(a)for(const e in a){const i=a[e],s=[];for(let e=0,r=i.length;e<r;e++){const r=i[e];let o;if(r.isInterleavedBufferAttribute){o=new ic(n(t.data,r.data),r.itemSize,r.offset,r.normalized)}else{o=new Hr(es(r.type,r.array),r.itemSize,r.normalized)}void 0!==r.name&&(o.name=r.name),s.push(o)}r.morphAttributes[e]=s}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const c=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==c)for(let t=0,e=c.length;t!==e;++t){const e=c[t];r.addGroup(e.start,e.count,e.materialIndex)}const h=t.data.boundingSphere;if(void 0!==h){const t=new fn;void 0!==h.center&&t.fromArray(h.center),r.boundingSphere=new On(t,h.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}),lu.prototype=Object.assign(Object.create(pl.prototype),{constructor:lu,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",fetch(t,o).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,r.options)})).then((function(i){ul.add(t,i),e&&e(i),r.manager.itemEnd(t)})).catch((function(e){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}}),Object.assign(uu.prototype,{moveTo:function(t,e){return this.currentPath=new Ul,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this},bezierCurveTo:function(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function i(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new Vl;r.curves=n.curves,e.push(r)}return e}function n(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],o=e[s],a=o.x-i.x,c=o.y-i.y;if(Math.abs(c)>Number.EPSILON){if(c<0&&(i=e[s],a=-a,o=e[r],c=-c),t.y<i.y||t.y>o.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=c*(t.x-i.x)-a*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(o.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=o.x)return!0}}return n}const r=Rh.isClockWise,s=this.subPaths;if(0===s.length)return[];if(!0===e)return i(s);let o,a,c;const h=[];if(1===s.length)return a=s[0],c=new Vl,c.curves=a.curves,h.push(c),h;let l=!r(s[0].getPoints());l=t?!l:l;const u=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,i=s.length;e<i;e++)a=s[e],p=a.getPoints(),o=r(p),o=t?!o:o,o?(!l&&d[g]&&g++,d[g]={s:new Vl,p:p},d[g].s.curves=a.curves,l&&g++,m[g]=[]):m[g].push({h:a,p:p[0]});if(!d[0])return i(s);if(d.length>1){let t=!1;const e=[];for(let t=0,e=d.length;t<e;t++)u[t]=[];for(let i=0,r=d.length;i<r;i++){const r=m[i];for(let s=0;s<r.length;s++){const o=r[s];let a=!0;for(let r=0;r<d.length;r++)n(o.p,d[r].p)&&(i!==r&&e.push({froms:i,tos:r,hole:s}),a?(a=!1,u[r].push(o)):t=!0);a&&u[i].push(o)}}e.length>0&&(t||(m=u))}for(let t=0,e=d.length;t<e;t++){c=d[t].s,h.push(c),f=m[t];for(let t=0,e=f.length;t<e;t++)c.holes.push(f[t].h)}return h}});class du{constructor(t){Object.defineProperty(this,"isFont",{value:!0}),this.type="Font",this.data=t}generateShapes(t,e=100){const i=[],n=function(t,e,i){const n=Array.from?Array.from(t):String(t).split(""),r=e/i.resolution,s=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,o=[];let a=0,c=0;for(let t=0;t<n.length;t++){const e=n[t];if("\n"===e)a=0,c-=s;else{const t=pu(e,r,a,c,i);a+=t.offsetX,o.push(t.path)}}return o}(t,e,this.data);for(let t=0,e=n.length;t<e;t++)Array.prototype.push.apply(i,n[t].toShapes());return i}}function pu(t,e,i,n,r){const s=r.glyphs[t]||r.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".");const o=new uu;let a,c,h,l,u,d,p,f;if(s.o){const t=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let r=0,s=t.length;r<s;){switch(t[r++]){case"m":a=t[r++]*e+i,c=t[r++]*e+n,o.moveTo(a,c);break;case"l":a=t[r++]*e+i,c=t[r++]*e+n,o.lineTo(a,c);break;case"q":h=t[r++]*e+i,l=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,o.quadraticCurveTo(u,d,h,l);break;case"b":h=t[r++]*e+i,l=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,p=t[r++]*e+i,f=t[r++]*e+n,o.bezierCurveTo(u,d,p,f,h,l)}}}return{offsetX:s.ha*e,path:o}}function fu(t){pl.call(this,t)}let mu;fu.prototype=Object.assign(Object.create(pl.prototype),{constructor:fu,load:function(t,e,i,n){const r=this,s=new ml(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(t){let i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}const n=r.parse(i);e&&e(n)}),i,n)},parse:function(t){return new du(t)}});const gu=function(){return void 0===mu&&(mu=new(window.AudioContext||window.webkitAudioContext)),mu};function _u(t){pl.call(this,t)}function vu(t,e,i){ru.call(this,void 0,i);const n=(new Dr).set(t),r=(new Dr).set(e),s=new fn(n.r,n.g,n.b),o=new fn(r.r,r.g,r.b),a=Math.sqrt(Math.PI),c=a*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(o).multiplyScalar(a),this.sh.coefficients[1].copy(s).sub(o).multiplyScalar(c)}function yu(t,e){ru.call(this,void 0,e);const i=(new Dr).set(t);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}_u.prototype=Object.assign(Object.create(pl.prototype),{constructor:_u,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setResponseType("arraybuffer"),s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{const t=i.slice(0);gu().decodeAudioData(t,(function(t){e(t)}))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}}),vu.prototype=Object.assign(Object.create(ru.prototype),{constructor:vu,isHemisphereLightProbe:!0,copy:function(t){return ru.prototype.copy.call(this,t),this},toJSON:function(t){return ru.prototype.toJSON.call(this,t)}}),yu.prototype=Object.assign(Object.create(ru.prototype),{constructor:yu,isAmbientLightProbe:!0,copy:function(t){return ru.prototype.copy.call(this,t),this},toJSON:function(t){return ru.prototype.toJSON.call(this,t)}});const bu=new Hn,xu=new Hn;Object.assign(function(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ds,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ds,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}.prototype,{update:function(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;const i=t.projectionMatrix.clone(),n=e.eyeSep/2,r=n*e.near/e.focus,s=e.near*Math.tan(nn.DEG2RAD*e.fov*.5)/e.zoom;let o,a;xu.elements[12]=-n,bu.elements[12]=n,o=-s*e.aspect+r,a=s*e.aspect+r,i.elements[0]=2*e.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(i),o=-s*e.aspect-r,a=s*e.aspect-r,i.elements[0]=2*e.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(xu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(bu)}});function wu(t,e,i){let n,r,s;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(wu.prototype,{accumulate:function(t,e){const i=this.buffer,n=this.valueSize,r=t*n+n;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==n;++t)i[r+t]=i[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(i,r,0,t,n)}this.cumulativeWeight=s},accumulateAdditive:function(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t},apply:function(t){const e=this.valueSize,i=this.buffer,n=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-r,e)}s>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){o.setValue(i,n);break}},saveOriginalState:function(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_setAdditiveIdentityNumeric:function(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]},_select:function(t,e,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]},_slerp:function(t,e,i,n){pn.slerpFlat(t,e,t,e,t,i,n)},_slerpAdditive:function(t,e,i,n,r){const s=this._workIndex*r;pn.multiplyQuaternionsFlat(t,s,t,e,t,i),pn.slerpFlat(t,e,t,e,t,s,n)},_lerp:function(t,e,i,n,r){const s=1-n;for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]*s+t[i+o]*n}},_lerpAdditive:function(t,e,i,n,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[i+s]*n}}});const Su="\\[\\]\\.:\\/",Mu=new RegExp("[\\[\\]\\.:\\/]","g"),Tu="[^\\[\\]\\.:\\/]",Cu="[^"+Su.replace("\\.","")+"]",Eu=/((?:WC+[\/:])*)/.source.replace("WC",Tu),Iu=/(WCOD+)?/.source.replace("WCOD",Cu),Au=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tu),Pu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tu),Ru=new RegExp("^"+Eu+Iu+Au+Pu+"$"),Lu=["material","materials","bones"];function Ou(t,e,i){const n=i||Nu.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Nu(t,e,i){this.path=e,this.parsedPath=i||Nu.parseTrackName(e),this.node=Nu.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(Ou.prototype,{getValue:function(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)},bind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(Nu,{Composite:Ou,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new Nu.Composite(t,e,i):new Nu(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Mu,"")},parseTrackName:function(t){const e=Ru.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==Lu.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i},findNode:function(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.name===e||r.uuid===e)return r;const s=i(r.children);if(s)return s}return null},n=i(t.children);if(n)return n}return null}}),Object.assign(Nu.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)t[e++]=i[n]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let r=e.propertyIndex;if(t||(t=Nu.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==n){if(void 0===t[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[n]}}const s=t[n];if(void 0===s){const i=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",t)}let o=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Nu.prototype,{_getValue_unbound:Nu.prototype.getValue,_setValue_unbound:Nu.prototype.setValue}),Object.assign(function(){this.uuid=nn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}.prototype,{isAnimationObjectGroup:!0,add:function(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let o,a=t.length,c=this.nCachedObjects_;for(let h=0,l=arguments.length;h!==l;++h){const l=arguments[h],u=l.uuid;let d=e[u];if(void 0===d){d=a++,e[u]=d,t.push(l);for(let t=0,e=s;t!==e;++t)r[t].push(new Nu(l,i[t],n[t]))}else if(d<c){o=t[d];const a=--c,h=t[a];e[h.uuid]=d,t[d]=h,e[u]=a,t[a]=l;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[a];let o=e[d];e[d]=s,void 0===o&&(o=new Nu(l,i[t],n[t])),e[a]=o}}else t[d]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c},remove:function(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s],a=o.uuid,c=e[a];if(void 0!==c&&c>=r){const s=r++,h=t[s];e[h.uuid]=c,t[c]=h,e[a]=s,t[s]=o;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[c];e[c]=n,e[s]=r}}}this.nCachedObjects_=r},uncache:function(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,c=e[a];if(void 0!==c)if(delete e[a],c<r){const o=--r,a=t[o],h=--s,l=t[h];e[a.uuid]=c,t[c]=a,e[l.uuid]=o,t[o]=l,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[o],r=e[h];e[c]=n,e[o]=r,e.pop()}}else{const r=--s,o=t[r];r>0&&(e[o.uuid]=c),t[c]=o,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[c]=e[r],e.pop()}}}this.nCachedObjects_=r},subscribe_:function(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,o=this._parsedPaths,a=this._objects,c=a.length,h=this.nCachedObjects_,l=new Array(c);n=r.length,i[t]=n,s.push(t),o.push(e),r.push(l);for(let i=h,n=a.length;i!==n;++i){const n=a[i];l[i]=new Nu(n,t,e)}return l},unsubscribe_:function(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o];e[t[o]]=i,s[i]=a,s.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}});class Du{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const r=e.tracks,s=r.length,o=new Array(s),a={endingStart:Vi,endingEnd:Vi};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);o[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,r=n/i,s=i/n;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,r=n.time,s=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+i,c[0]=t/s,c[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const n=(t-r)*i;if(n<0||0===i)return;this._startTime=null,e=i*n}e*=this._updateTimeScale(t);const s=this._updateTime(e),o=this._updateWeight(t);if(o>0){const t=this._interpolants,e=this._propertyBindings;switch(this.blendMode){case 2501:for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(s),e[i].accumulateAdditive(o);break;case Wi:default:for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(s),e[i].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const s=2202===i;if(0===t)return-1===r?n:s&&1==(1&r)?e-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&1==(1&r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=Gi,n.endingEnd=Gi):(n.endingStart=t?this.zeroSlopeAtStart?Gi:Vi:qi,n.endingEnd=e?this.zeroSlopeAtEnd?Gi:Vi:qi)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=e,o[1]=r+t,a[1]=i,this}}function $u(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}$u.prototype=Object.assign(Object.create(Qi.prototype),{constructor:$u,_bindAction:function(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,o=t._interpolants,a=i.uuid,c=this._bindingsByRootAndName;let h=c[a];void 0===h&&(h={},c[a]=h);for(let t=0;t!==r;++t){const r=n[t],c=r.name;let l=h[c];if(void 0!==l)s[t]=l;else{if(l=s[t],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,a,c));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;l=new wu(Nu.create(i,c,n),r.ValueTypeName,r.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,a,c),s[t]=l}o[t].resultBuffer=l.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t},_removeInactiveAction:function(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,a[h]=c,a.pop(),t._byClipCacheIndex=null;delete o.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete s[r],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.referenceCount&&this._removeInactiveBinding(i)}},_lendAction:function(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackAction:function(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_addInactiveBinding:function(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)},_removeInactiveBinding:function(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[n],a=e[e.length-1],c=t._cacheIndex;a._cacheIndex=c,e[c]=a,e.pop(),delete o[r],0===Object.keys(o).length&&delete s[n]},_lendBinding:function(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackBinding:function(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_lendControlInterpolant:function(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new Qh(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=e,t[e]=i),i},_takeBackControlInterpolant:function(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?hl.findByName(n,t):t;const o=null!==s?s.uuid:t,a=this._actionsByClip[o];let c=null;if(void 0===i&&(i=null!==s?s.blendMode:Wi),void 0!==a){const t=a.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;c=a.knownActions[0],null===s&&(s=c._clip)}if(null===s)return null;const h=new Du(this,s,e,i);return this._bindAction(h,c),this._addInactiveAction(h,o,r),h},existingAction:function(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?hl.findByName(i,t):t,s=r?r.uuid:t,o=this._actionsByClip[s];return void 0!==o&&o.actionByRoot[n]||null},stopAllAction:function(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this},update:function(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let o=0;o!==i;++o){e[o]._update(n,t,r,s)}const o=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)o[t].apply(s);return this},setTime:function(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}},uncacheRoot:function(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}},uncacheAction:function(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}});class ku{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new ku(void 0===this.value.clone?this.value:this.value.clone())}}function zu(t,e,i){tc.call(this,t,e),this.meshPerAttribute=i||1}function Fu(t,e,i,n,r){this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}function Bu(t,e,i,n){this.ray=new jn(t,e),this.near=i||0,this.far=n||1/0,this.camera=null,this.layers=new Qn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function ju(t,e){return t.distance-e.distance}function Hu(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)Hu(n[t],e,i,!0)}}zu.prototype=Object.assign(Object.create(tc.prototype),{constructor:zu,isInstancedInterleavedBuffer:!0,copy:function(t){return tc.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){const e=tc.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){const e=tc.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(Fu.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Fu.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}}),Object.assign(Bu.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)},intersectObject:function(t,e,i){const n=i||[];return Hu(t,this,n,e),n.sort(ju),n},intersectObjects:function(t,e,i){const n=i||[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(let i=0,r=t.length;i<r;i++)Hu(t[i],this,n,e);return n.sort(ju),n}});const Uu=new rn;function Vu(t){pr.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Vu.prototype=Object.create(pr.prototype),Vu.prototype.constructor=Vu,Vu.prototype.isImmediateRenderObject=!0;const Gu=new Fr({side:1,depthWrite:!1,depthTest:!1});function qu(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Pl.call(this,t),this.type="catmullrom"}new Es(new As,Gu),wl.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(wl.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Ul.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),qu.prototype=Object.create(Pl.prototype),Object.assign(qu.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Object.assign(pl.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ou(t)}}),pl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(class{constructor(t,e){Object.defineProperty(this,"isBox2",{value:!0}),this.min=void 0!==t?t:new rn(1/0,1/0),this.max=void 0!==e?e:new rn(-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Uu.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new rn),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new rn),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new rn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new rn),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Uu.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(_n.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(On.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),Us.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},Object.assign(nn,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),nn.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),nn.ceilPowerOfTwo(t)}}),Object.assign(sn.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},getInverse:function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()}}),Object.assign(Hn.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new fn).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,n,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,n,i,r,s)},getInverse:function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()}}),_r.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Object.assign(pn.prototype,{multiplyVector3:function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},inverse:function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()}}),Object.assign(jn.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(Ir.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}}),Object.assign(Ir,{barycoordFromPoint:function(t,e,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Ir.getBarycoord(t,e,i,n,r)},normal:function(t,e,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Ir.getNormal(t,e,i,n)}}),Object.assign(Vl.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Nh(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new kh(this,t)}}),Object.assign(rn.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(fn.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(un.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(pr.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(pr.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Es.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Es.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(xc.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Rc.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Ec.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(wl.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Ds.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Gl.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Hr.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Ji},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Ji)}}}),Object.assign(Hr.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Ji:Zi),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(hs.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new Hr(arguments[1],arguments[2])))},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},applyMatrix:function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(hs.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(au.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}}),Object.defineProperties(Bu.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}}),Object.defineProperties(tc.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===Ji},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Object.assign(tc.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Ji:Zi),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Nh.prototype,{getArrays:function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")}}),Object.assign(Qa.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}}),Object.defineProperties(ku.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(zr.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Dr}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Uh.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Hh.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}}),Object.defineProperties(Os.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(Ja.prototype,{clearTarget:function(t,e,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,i,n)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(Ja.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?3001:Xi}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ha.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(dn.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(class extends pr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return(new _u).load(t,(function(t){e.setBuffer(t)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),ks.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},ks.prototype.clear=function(t,e,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,i,n)},an.crossOrigin=void 0,an.loadTexture=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new xl;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},an.loadTextureCube=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new yl;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},an.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},an.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"125"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="125");const Wu=Math.PI/180,Xu=180/Math.PI,Yu=6378137,Zu=6356752.31424518;function Ju(t,e,i,n,r,s){const o=Qu(t,e,i);return function(t,e,i,n,r,s){const o=Qu(n,r,s),a=[t-o[0],e-o[1],i-o[2]];n*=Wu,r*=Wu;const c=Math.cos(n),h=Math.sin(n),l=Math.cos(r),u=Math.sin(r),d=-h*a[0]+c*a[1],p=-u*c*a[0]-u*h*a[1]+l*a[2],f=l*c*a[0]+l*h*a[1]+u*a[2];return[d,p,f]}(o[0],o[1],o[2],n,r,s)}function Ku(t,e,i,n,r,s){const o=function(t,e,i,n,r,s){const o=Qu(n,r,s);n*=Wu,r*=Wu;const a=Math.cos(n),c=Math.sin(n),h=Math.cos(r),l=Math.sin(r),u=-c*t-l*a*e+h*a*i+o[0],d=a*t-l*c*e+h*c*i+o[1],p=h*e+l*i+o[2];return[u,d,p]}(t,e,i,n,r,s);return function(t,e,i){const n=Yu,r=Zu,s=n*n,o=r*r,a=s-o,c=Math.sqrt(a/s),h=Math.sqrt(a/o),l=Math.sqrt(t*t+e*e),u=Math.atan2(i*n,l*r),d=Math.sin(u),p=Math.cos(u),f=Math.atan2(e,t),m=Math.atan2(i+h*h*r*d*d*d,l-c*c*n*p*p*p),g=Math.sin(m),_=Math.cos(m),v=n/Math.sqrt(1-c*c*g*g);return[f*Xu,m*Xu,l/_-v]}(o[0],o[1],o[2])}function Qu(t,e,i){const n=Yu,r=Zu;t*=Wu,e*=Wu;const s=Math.cos(t),o=Math.sin(t),a=Math.cos(e),c=Math.sin(e),h=n*n,l=r*r,u=1/Math.sqrt(h*a*a+l*c*c),d=(h*u+i)*a;return[d*s,d*o,(l*u+i)*c]}class td{boundingBoxCorners(t,e){const i=Ku(-e,-e,0,t.lng,t.lat,0),n=Ku(e,e,0,t.lng,t.lat,0);return[{lat:i[1],lng:i[0]},{lat:n[1],lng:n[0]}]}rotationFromCompass(t,e){let i=0,n=0,r=0;switch(e){case 1:i=Math.PI/2;break;case 3:i=-Math.PI/2,r=Math.PI;break;case 6:n=-Math.PI/2,r=-Math.PI/2;break;case 8:n=Math.PI/2,r=Math.PI/2}const s=(new Hn).makeRotationZ(r),o=new Zn(i,n,t*Math.PI/180,"XYZ"),a=(new Hn).makeRotationFromEuler(o),c=(new un).setAxisAngleFromRotationMatrix(a.multiply(s));return c.multiplyScalar(c.w).toArray().slice(0,3)}}class ed{constructor(t){if(!t)throw new Error(`Incorrect core image data ${t}`);this._cache=null,this._core=t,this._spatial=null}get assetsCached(){return null!=this._core&&null!=this._spatial&&null!=this._cache&&null!=this._cache.image&&null!=this._cache.mesh}get cameraParameters(){return this._spatial.camera_parameters}get cameraType(){return this._spatial.camera_type}get capturedAt(){return this._spatial.captured_at}get clusterId(){return this._spatial.cluster?this._spatial.cluster.id:null}get clusterUrl(){return this._spatial.cluster?this._spatial.cluster.url:null}get compassAngle(){return null!=this._spatial.computed_compass_angle?this._spatial.computed_compass_angle:this._spatial.compass_angle}get complete(){return null!=this._spatial}get computedAltitude(){return this._spatial.computed_altitude}get computedCompassAngle(){return this._spatial.computed_compass_angle}get computedLngLat(){return this._core.computed_geometry}get creatorId(){return this._spatial.creator.id}get creatorUsername(){return this._spatial.creator.username}get exifOrientation(){return this._spatial.exif_orientation}get height(){return this._spatial.height}get image(){return this._cache.image}get image$(){return this._cache.image$}get id(){return this._core.id}get lngLat(){return null!=this._core.computed_geometry?this._core.computed_geometry:this._core.geometry}get merged(){return null!=this._spatial&&null!=this._spatial.merge_id}get mergeId(){return this._spatial.merge_id}get mesh(){return this._cache.mesh}get originalAltitude(){return this._spatial.altitude}get originalCompassAngle(){return this._spatial.compass_angle}get originalLngLat(){return this._core.geometry}get ownerId(){return this._spatial.owner?this._spatial.owner.id:null}get private(){return this._spatial.private}get qualityScore(){return this._spatial.quality_score}get rotation(){return this._spatial.computed_rotation}get scale(){return this._spatial.atomic_scale}get sequenceId(){return this._core.sequence?this._core.sequence.id:null}get sequenceEdges(){return this._cache.sequenceEdges}get sequenceEdges$(){return this._cache.sequenceEdges$}get spatialEdges(){return this._cache.spatialEdges}get spatialEdges$(){return this._cache.spatialEdges$}get width(){return this._spatial.width}cacheAssets$(){return this._cache.cacheAssets$(this._spatial,this.merged).pipe(rt((()=>this)))}cacheImage$(){return this._cache.cacheImage$(this._spatial).pipe(rt((()=>this)))}cacheSequenceEdges(t){this._cache.cacheSequenceEdges(t)}cacheSpatialEdges(t){this._cache.cacheSpatialEdges(t)}dispose(){null!=this._cache&&(this._cache.dispose(),this._cache=null),this._core=null,this._spatial=null}initializeCache(t){if(null!=this._cache)throw new Error(`Image cache already initialized (${this.id}).`);this._cache=t}makeComplete(t){if(null==t)throw new Error("Fill can not be null.");this._spatial=t}resetSequenceEdges(){this._cache.resetSequenceEdges()}resetSpatialEdges(){this._cache.resetSpatialEdges()}uncache(){null!=this._cache&&(this._cache.dispose(),this._cache=null)}}class id{constructor(t){this._disposed=!1,this._provider=t,this._image=null,this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$=new T,this._image$=this._imageChanged$.pipe(ni(null),Ue(1),E()),this._iamgeSubscription=this._image$.subscribe(),this._sequenceEdgesChanged$=new T,this._sequenceEdges$=this._sequenceEdgesChanged$.pipe(ni(this._sequenceEdges),Ue(1),E()),this._sequenceEdgesSubscription=this._sequenceEdges$.subscribe((()=>{})),this._spatialEdgesChanged$=new T,this._spatialEdges$=this._spatialEdgesChanged$.pipe(ni(this._spatialEdges),Ue(1),E()),this._spatialEdgesSubscription=this._spatialEdges$.subscribe((()=>{})),this._cachingAssets$=null}get image(){return this._image}get image$(){return this._image$}get mesh(){return this._mesh}get sequenceEdges(){return this._sequenceEdges}get sequenceEdges$(){return this._sequenceEdges$}get spatialEdges(){return this._spatialEdges}get spatialEdges$(){return this._spatialEdges$}cacheAssets$(t,e){return null!=this._cachingAssets$||(this._cachingAssets$=gt(this._cacheImage$(t),this._cacheMesh$(t,e)).pipe(rt((([t,e])=>(this._image=t,this._mesh=e,this))),Me((()=>{this._cachingAssets$=null})),Ue(1),E()),this._cachingAssets$.pipe(Ee((t=>!!t._image))).subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{}))),this._cachingAssets$}cacheImage$(t){if(null!=this._image)return G(this);const e=this._cacheImage$(t).pipe(Ee((t=>!!t)),pi((t=>{this._disposeImage(),this._image=t})),rt((()=>this)),Ue(1),E());return e.subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{})),e}cacheSequenceEdges(t){this._sequenceEdges={cached:!0,edges:t},this._sequenceEdgesChanged$.next(this._sequenceEdges)}cacheSpatialEdges(t){this._spatialEdges={cached:!0,edges:t},this._spatialEdgesChanged$.next(this._spatialEdges)}dispose(){this._iamgeSubscription.unsubscribe(),this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._disposeImage(),this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$.next(null),this._sequenceEdgesChanged$.next(this._sequenceEdges),this._spatialEdgesChanged$.next(this._spatialEdges),this._disposed=!0,null!=this._imageAborter&&(this._imageAborter(),this._imageAborter=null),null!=this._meshAborter&&(this._meshAborter(),this._meshAborter=null)}resetSequenceEdges(){this._sequenceEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges)}resetSpatialEdges(){this._spatialEdges={cached:!1,edges:[]},this._spatialEdgesChanged$.next(this._spatialEdges)}_cacheImage$(t){return b.create((e=>{const i=new Promise(((t,e)=>{this._imageAborter=e})),n=t.thumb.url;if(n)this._provider.getImageBuffer(n,i).then((t=>{this._imageAborter=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{if(this._disposed){window.URL.revokeObjectURL(i.src);const t=`Image load was aborted (${n})`;e.error(new Error(t))}else e.next(i),e.complete()},i.onerror=()=>{this._imageAborter=null,e.error(new Error(`Failed to load image (${n})`))};const r=new Blob([t]);i.src=window.URL.createObjectURL(r)}),(t=>{this._imageAborter=null,e.error(t)}));else{const i=t.thumb.id,r=`Incorrect thumb URL for ${t.id} (${i}, ${n})`;e.error(new Error(r))}}))}_cacheMesh$(t,e){return b.create((i=>{if(!e)return i.next(this._createEmptyMesh()),void i.complete();const n=t.mesh.url;if(!n){const e=t.mesh.id,r=`Incorrect mesh URL for ${t.id} (${e}, ${n})`;return console.warn(r),i.next(this._createEmptyMesh()),void i.complete()}const r=new Promise(((t,e)=>{this._meshAborter=e}));this._provider.getMesh(n,r).then((t=>{this._meshAborter=null,this._disposed||(i.next(t),i.complete())}),(t=>{this._meshAborter=null,console.error(t),i.next(this._createEmptyMesh()),i.complete()}))}))}_createEmptyMesh(){return{faces:[],vertices:[]}}_disposeImage(){null!=this._image&&window.URL.revokeObjectURL(this._image.src),this._image=null}}class nd{constructor(t){this._id=t.id,this._imageIds=t.image_ids}get id(){return this._id}get imageIds(){return this._imageIds}dispose(){this._id=null,this._imageIds=null}findNext(t){let e=this._imageIds.indexOf(t);return e+1>=this._imageIds.length||-1===e?null:this._imageIds[e+1]}findPrev(t){let e=this._imageIds.indexOf(t);return 0===e||-1===e?null:this._imageIds[e-1]}}class rd{constructor(){this.sphericalPreferredDistance=2,this.sphericalMotion=2,this.sphericalSequencePenalty=1,this.sphericalMergeCCPenalty=4,this.stepPreferredDistance=4,this.stepMotion=3,this.stepRotation=4,this.stepSequencePenalty=2,this.stepMergeCCPenalty=6,this.similarDistance=2,this.similarRotation=3,this.turnDistance=4,this.turnMotion=2,this.turnSequencePenalty=1,this.turnMergeCCPenalty=4}}var sd;t.NavigationDirection=void 0,(sd=t.NavigationDirection||(t.NavigationDirection={}))[sd.Next=0]="Next",sd[sd.Prev=1]="Prev",sd[sd.StepLeft=2]="StepLeft",sd[sd.StepRight=3]="StepRight",sd[sd.StepForward=4]="StepForward",sd[sd.StepBackward=5]="StepBackward",sd[sd.TurnLeft=6]="TurnLeft",sd[sd.TurnRight=7]="TurnRight",sd[sd.TurnU=8]="TurnU",sd[sd.Spherical=9]="Spherical",sd[sd.Similar=10]="Similar";class od{constructor(){this.steps={},this.turns={},this.spherical={},this.steps[t.NavigationDirection.StepForward]={direction:t.NavigationDirection.StepForward,motionChange:0,useFallback:!0},this.steps[t.NavigationDirection.StepBackward]={direction:t.NavigationDirection.StepBackward,motionChange:Math.PI,useFallback:!0},this.steps[t.NavigationDirection.StepLeft]={direction:t.NavigationDirection.StepLeft,motionChange:Math.PI/2,useFallback:!1},this.steps[t.NavigationDirection.StepRight]={direction:t.NavigationDirection.StepRight,motionChange:-Math.PI/2,useFallback:!1},this.turns[t.NavigationDirection.TurnLeft]={direction:t.NavigationDirection.TurnLeft,directionChange:Math.PI/2,motionChange:Math.PI/4},this.turns[t.NavigationDirection.TurnRight]={direction:t.NavigationDirection.TurnRight,directionChange:-Math.PI/2,motionChange:-Math.PI/4},this.turns[t.NavigationDirection.TurnU]={direction:t.NavigationDirection.TurnU,directionChange:Math.PI,motionChange:null},this.spherical[t.NavigationDirection.StepForward]={direction:t.NavigationDirection.StepForward,directionChange:0,next:t.NavigationDirection.StepLeft,prev:t.NavigationDirection.StepRight},this.spherical[t.NavigationDirection.StepBackward]={direction:t.NavigationDirection.StepBackward,directionChange:Math.PI,next:t.NavigationDirection.StepRight,prev:t.NavigationDirection.StepLeft},this.spherical[t.NavigationDirection.StepLeft]={direction:t.NavigationDirection.StepLeft,directionChange:Math.PI/2,next:t.NavigationDirection.StepBackward,prev:t.NavigationDirection.StepForward},this.spherical[t.NavigationDirection.StepRight]={direction:t.NavigationDirection.StepRight,directionChange:-Math.PI/2,next:t.NavigationDirection.StepForward,prev:t.NavigationDirection.StepBackward}}}class ad{constructor(){this.sphericalMinDistance=.1,this.sphericalMaxDistance=20,this.sphericalPreferredDistance=5,this.sphericalMaxItems=4,this.sphericalMaxStepTurnChange=Math.PI/8,this.rotationMaxDistance=this.turnMaxRigDistance,this.rotationMaxDirectionChange=Math.PI/6,this.rotationMaxVerticalDirectionChange=Math.PI/8,this.similarMaxDirectionChange=Math.PI/8,this.similarMaxDistance=12,this.similarMinTimeDifference=432e5,this.stepMaxDistance=20,this.stepMaxDirectionChange=Math.PI/6,this.stepMaxDrift=Math.PI/6,this.stepPreferredDistance=4,this.turnMaxDistance=15,this.turnMaxDirectionChange=2*Math.PI/9,this.turnMaxRigDistance=.65,this.turnMinRigDirectionChange=Math.PI/6}get maxDistance(){return Math.max(this.sphericalMaxDistance,this.similarMaxDistance,this.stepMaxDistance,this.turnMaxDistance)}}class cd extends Error{constructor(t){super(t),Object.setPrototypeOf(this,cd.prototype),this.name="MapillaryError"}}class hd extends cd{constructor(t){super(null!=t?t:"The argument is not valid."),Object.setPrototypeOf(this,hd.prototype),this.name="ArgumentMapillaryError"}}class ld{constructor(){this._epsilon=1e-9}azimuthalToBearing(t){return-t+Math.PI/2}degToRad(t){return Math.PI*t/180}radToDeg(t){return 180*t/Math.PI}rotationMatrix(t){let e=new fn(t[0],t[1],t[2]),i=e.length();return i>0&&e.normalize(),(new Hn).makeRotationAxis(e,i)}rotate(t,e){let i=new fn(t[0],t[1],t[2]),n=this.rotationMatrix(e);return i.applyMatrix4(n),i}opticalCenter(t,e){let i=[-t[0],-t[1],-t[2]],n=[-e[0],-e[1],-e[2]];return this.rotate(n,i)}viewingDirection(t){let e=[-t[0],-t[1],-t[2]];return this.rotate([0,0,1],e)}wrap(t,e,i){if(i<e)throw new Error("Invalid arguments: max must be larger than min.");let n=i-e;for(;t>i||t<e;)t>i?t-=n:t<e&&(t+=n);return t}wrapAngle(t){return this.wrap(t,-Math.PI,Math.PI)}clamp(t,e,i){return t<e?e:t>i?i:t}angleBetweenVector2(t,e,i,n){let r=Math.atan2(n,i)-Math.atan2(e,t);return this.wrapAngle(r)}angleDifference(t,e){let i=e-t;return this.wrapAngle(i)}relativeRotationAngle(t,e){let i=this.rotationMatrix([-t[0],-t[1],-t[2]]),n=this.rotationMatrix(e),r=i.multiply(n).elements,s=r[0]+r[5]+r[10];return Math.acos(Math.max(Math.min((s-1)/2,1),-1))}angleToPlane(t,e){let i=(new fn).fromArray(t),n=i.length();if(n<this._epsilon)return 0;let r=i.dot((new fn).fromArray(e));return Math.asin(r/n)}azimuthal(t,e){const i=(new fn).fromArray(t),n=(new fn).fromArray(e),r=i.clone().dot(n),s=i.clone().sub(n.clone().multiplyScalar(r));return Math.atan2(s.y,s.x)}distanceFromLngLat(t,e,i,n){let r=this.degToRad(n-e),s=this.degToRad(i-t),o=Math.sin(r/2)*Math.sin(r/2)+Math.cos(this.degToRad(e))*Math.cos(this.degToRad(n))*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}}const ud=new ld;function dd(t){return"spherical"===t}function pd(t){return"fisheye"===t}function fd(t,e,i){const n=Ju(t.lng,t.lat,t.alt,i.lng,i.lat,i.alt),r=ud.rotate(n,e);return[-r.x,-r.y,-r.z]}function md(t,e,i,n,r){const s=[];for(let t=0;t<e.length;++t){const r=e[t],o=i[t];for(let t=0;t<=n;++t)s.push([r[0]+o[0]*t/n,r[1]+o[1]*t/n])}const o=new Ns;o.up.copy(t.upVector()),o.position.copy((new fn).fromArray(t.unprojectSfM([0,0],0))),o.lookAt((new fn).fromArray(t.unprojectSfM([0,0],10))),o.updateMatrix(),o.updateMatrixWorld(!0);return s.map((e=>{const i=t.unprojectBasic(e,1e4),n=r.worldToCamera(i,o);return[Math.abs(n[0]/n[2]),Math.abs(n[1]/n[2])]}))}class gd{constructor(t,e,i){this._spatial=new ld,this._settings=null!=t?t:new ad,this._directions=null!=e?e:new od,this._coefficients=null!=i?i:new rd}getPotentialEdges(t,e,i){if(!t.complete)throw new hd("Image has to be full.");if(!t.merged)return[];let n=this._spatial.viewingDirection(t.rotation),r=this._spatial.angleToPlane(n.toArray(),[0,0,1]),s=[];for(let o of e){if(!o.merged||o.id===t.id)continue;let e=Ju(o.lngLat.lng,o.lngLat.lat,o.computedAltitude,t.lngLat.lng,t.lngLat.lat,t.computedAltitude),a=new fn(e[0],e[1],e[2]),c=a.length();if(c>this._settings.maxDistance&&i.indexOf(o.id)<0)continue;let h=this._spatial.angleBetweenVector2(n.x,n.y,a.x,a.y),l=this._spatial.angleToPlane(a.toArray(),[0,0,1]),u=this._spatial.viewingDirection(o.rotation),d=this._spatial.angleBetweenVector2(n.x,n.y,u.x,u.y),p=this._spatial.angleToPlane(u.toArray(),[0,0,1])-r,f=this._spatial.relativeRotationAngle(t.rotation,o.rotation),m=this._spatial.angleBetweenVector2(1,0,a.x,a.y),g=null!=o.sequenceId&&null!=t.sequenceId&&o.sequenceId===t.sequenceId,_=o.mergeId===t.mergeId,v=o.creatorId===t.creatorId,y={capturedAt:o.capturedAt,directionChange:d,distance:c,spherical:dd(o.cameraType),id:o.id,motionChange:h,rotation:f,sameMergeCC:_,sameSequence:g,sameUser:v,sequenceId:o.sequenceId,verticalDirectionChange:p,verticalMotion:l,worldMotionAzimuth:m};s.push(y)}return s}computeSequenceEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(e.sequenceId!==i.id)throw new hd("Image and sequence does not correspond.");let n=[],r=i.findNext(e.id);null!=r&&n.push({data:{direction:t.NavigationDirection.Next,worldMotionAzimuth:Number.NaN},source:e.id,target:r});let s=i.findPrev(e.id);return null!=s&&n.push({data:{direction:t.NavigationDirection.Prev,worldMotionAzimuth:Number.NaN},source:e.id,target:s}),n}computeSimilarEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");let n=dd(e.cameraType),r={};for(let t of i)if(null!=t.sequenceId&&!t.sameSequence){if(n){if(!t.spherical)continue}else if(!t.spherical&&Math.abs(t.directionChange)>this._settings.similarMaxDirectionChange)continue;t.distance>this._settings.similarMaxDistance||t.sameUser&&Math.abs(t.capturedAt-e.capturedAt)<this._settings.similarMinTimeDifference||(null==r[t.sequenceId]&&(r[t.sequenceId]=[]),r[t.sequenceId].push(t))}let s=[],o=dd(e.cameraType)?t=>t.distance:t=>this._coefficients.similarDistance*t.distance+this._coefficients.similarRotation*t.rotation;for(let t in r){if(!r.hasOwnProperty(t))continue;let e=Number.MAX_VALUE,i=null;for(let n of r[t]){let t=o(n);t<e&&(e=t,i=n)}null!=i&&s.push(i)}return s.map((i=>({data:{direction:t.NavigationDirection.Similar,worldMotionAzimuth:i.worldMotionAzimuth},source:e.id,target:i.id})))}computeStepEdges(t,e,i,n){if(!t.complete)throw new hd("Image has to be full.");let r=[];if(dd(t.cameraType))return r;for(let s in this._directions.steps){if(!this._directions.steps.hasOwnProperty(s))continue;let o=this._directions.steps[s],a=Number.MAX_VALUE,c=null,h=null;for(let t of e){if(t.spherical)continue;if(Math.abs(t.directionChange)>this._settings.stepMaxDirectionChange)continue;let e=this._spatial.angleDifference(o.motionChange,t.motionChange),r=this._spatial.angleDifference(t.directionChange,e),s=Math.max(Math.abs(e),Math.abs(r));if(Math.abs(s)>this._settings.stepMaxDrift)continue;let l=t.id;if(!o.useFallback||l!==i&&l!==n||(h=t),t.distance>this._settings.stepMaxDistance)continue;e=Math.sqrt(e*e+t.verticalMotion*t.verticalMotion);let u=this._coefficients.stepPreferredDistance*Math.abs(t.distance-this._settings.stepPreferredDistance)/this._settings.stepMaxDistance+this._coefficients.stepMotion*e/this._settings.stepMaxDrift+this._coefficients.stepRotation*t.rotation/this._settings.stepMaxDirectionChange+this._coefficients.stepSequencePenalty*(t.sameSequence?0:1)+this._coefficients.stepMergeCCPenalty*(t.sameMergeCC?0:1);u<a&&(a=u,c=t)}c=null==c?h:c,null!=c&&r.push({data:{direction:o.direction,worldMotionAzimuth:c.worldMotionAzimuth},source:t.id,target:c.id})}return r}computeTurnEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");let n=[];if(dd(e.cameraType))return n;for(let r in this._directions.turns){if(!this._directions.turns.hasOwnProperty(r))continue;let s=this._directions.turns[r],o=Number.MAX_VALUE,a=null;for(let e of i){if(e.spherical)continue;if(e.distance>this._settings.turnMaxDistance)continue;let i,n=s.direction!==t.NavigationDirection.TurnU&&e.distance<this._settings.turnMaxRigDistance&&Math.abs(e.directionChange)>this._settings.turnMinRigDirectionChange,r=this._spatial.angleDifference(s.directionChange,e.directionChange);if(n&&e.directionChange*s.directionChange>0&&Math.abs(e.directionChange)<Math.abs(s.directionChange))i=-Math.PI/2+Math.abs(e.directionChange);else{if(Math.abs(r)>this._settings.turnMaxDirectionChange)continue;let t=s.motionChange?this._spatial.angleDifference(s.motionChange,e.motionChange):0;t=Math.sqrt(t*t+e.verticalMotion*e.verticalMotion),i=this._coefficients.turnDistance*e.distance/this._settings.turnMaxDistance+this._coefficients.turnMotion*t/Math.PI+this._coefficients.turnSequencePenalty*(e.sameSequence?0:1)+this._coefficients.turnMergeCCPenalty*(e.sameMergeCC?0:1)}i<o&&(o=i,a=e)}null!=a&&n.push({data:{direction:s.direction,worldMotionAzimuth:a.worldMotionAzimuth},source:e.id,target:a.id})}return n}computePerspectiveToSphericalEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(dd(e.cameraType))return[];let n=Number.MAX_VALUE,r=null;for(let t of i){if(!t.spherical)continue;let e=this._coefficients.sphericalPreferredDistance*Math.abs(t.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t.motionChange)/Math.PI+this._coefficients.sphericalMergeCCPenalty*(t.sameMergeCC?0:1);e<n&&(n=e,r=t)}return null==r?[]:[{data:{direction:t.NavigationDirection.Spherical,worldMotionAzimuth:r.worldMotionAzimuth},source:e.id,target:r.id}]}computeSphericalEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(!dd(e.cameraType))return[];let n=[],r=[],s=[];for(let t of i)if(!(t.distance>this._settings.sphericalMaxDistance))if(t.spherical){if(t.distance<this._settings.sphericalMinDistance)continue;r.push(t)}else for(let e in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(e))continue;let i=this._directions.spherical[e],n=this._spatial.angleDifference(t.directionChange,t.motionChange),r=this._spatial.angleDifference(i.directionChange,n);if(!(Math.abs(r)>this._settings.sphericalMaxStepTurnChange)){s.push([i.direction,t]);break}}let o=Math.PI/this._settings.sphericalMaxItems,a=[],c=[];for(let i=0;i<this._settings.sphericalMaxItems;i++){let s=i/this._settings.sphericalMaxItems*2*Math.PI,h=Number.MAX_VALUE,l=null;for(let t of r){let e=this._spatial.angleDifference(s,t.motionChange);if(Math.abs(e)>o)continue;let i=Number.MAX_VALUE;for(let e of a){let n=Math.abs(this._spatial.angleDifference(e,t.motionChange));n<i&&(i=n)}if(i<=o)continue;let n=this._coefficients.sphericalPreferredDistance*Math.abs(t.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e)/o+this._coefficients.sphericalSequencePenalty*(t.sameSequence?0:1)+this._coefficients.sphericalMergeCCPenalty*(t.sameMergeCC?0:1);n<h&&(h=n,l=t)}null!=l?(a.push(l.motionChange),n.push({data:{direction:t.NavigationDirection.Spherical,worldMotionAzimuth:l.worldMotionAzimuth},source:e.id,target:l.id})):c.push(s)}let h={};h[t.NavigationDirection.Spherical]=a,h[t.NavigationDirection.StepForward]=[],h[t.NavigationDirection.StepLeft]=[],h[t.NavigationDirection.StepBackward]=[],h[t.NavigationDirection.StepRight]=[];for(let i of c){let r=[];for(let a in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(a))continue;let c=this._directions.spherical[a],l=h[t.NavigationDirection.Spherical].concat(h[c.direction]).concat(h[c.prev]).concat(h[c.next]),u=Number.MAX_VALUE,d=null;for(let t of s){if(t[0]!==c.direction)continue;let e=this._spatial.angleDifference(i,t[1].motionChange);if(Math.abs(e)>o)continue;let n=Number.MAX_VALUE;for(let e of l){let i=Math.abs(this._spatial.angleDifference(e,t[1].motionChange));i<n&&(n=i)}if(n<=o)continue;let r=this._coefficients.sphericalPreferredDistance*Math.abs(t[1].distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e)/o+this._coefficients.sphericalMergeCCPenalty*(t[1].sameMergeCC?0:1);r<u&&(u=r,d=t)}null!=d&&(r.push(d),n.push({data:{direction:d[0],worldMotionAzimuth:d[1].worldMotionAzimuth},source:e.id,target:d[1].id}))}for(let t of r)h[t[0]].push(t[1].motionChange)}return n}}class _d extends cd{constructor(t){super(t),Object.setPrototypeOf(this,_d.prototype),this.name="GraphMapillaryError"}}class vd{constructor(t,e,i,n,r,s){this._api=t,this._cachedNodes={},this._cachedNodeTiles={},this._cachedSequenceNodes={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequenceNodes$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._changed$=new T,this._filterCreator=null!=r?r:new Si,this._filter=this._filterCreator.createFilter(void 0),this._filterSubject$=new T,this._filter$=At(G(this._filter),this._filterSubject$).pipe(Ue(1),E()),this._filterSubscription=this._filter$.subscribe((()=>{})),this._defaultAlt=2,this._edgeCalculator=null!=n?n:new gd,this._graphCalculator=null!=i?i:new td,this._configuration=null!=s?s:{maxSequences:50,maxUnusedImages:100,maxUnusedPreStoredImages:30,maxUnusedTiles:20},this._nodes={},this._nodeIndex=null!=e?e:new vd._spatialIndex(16),this._nodeIndexTiles={},this._nodeToTile={},this._preStored={},this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._tileThreshold=20}static register(t){vd._spatialIndex=t}get api(){return this._api}get changed$(){return this._changed$}get filter$(){return this._filter$}cacheBoundingBox$(t,e){const i=this._api.data.geometry.bboxToCellIds(t,e).filter((t=>!(t in this._cachedTiles))).map((t=>t in this._cachingTiles$?this._cachingTiles$[t]:this._cacheTile$(t)));return 0===i.length&&i.push(G(this)),bt(i).pipe(Et(),Re(),Mt((()=>{const i=this._nodeIndex.search({maxX:e.lng,maxY:e.lat,minX:t.lng,minY:t.lat}).map((t=>t.node)),n=[],r=[];for(const t of i)t.complete?n.push(t):r.push(t.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return Ot(G(n),bt(s.map((t=>this._api.getSpatialImages$(t).pipe(rt((t=>{const e=[];for(const i of t){if(!this.hasNode(i.node_id))continue;const t=this.getNode(i.node_id);t.complete||this._makeFull(t,i.node),e.push(t)}return e})))))).pipe(Et()))})),De(((t,e)=>t.concat(e))))}cacheCell$(t){return(t in this._cachedTiles?G(this):t in this._cachingTiles$?this._cachingTiles$[t]:this._cacheTile$(t)).pipe(Mt((()=>{const e=this._cachedTiles[t];e.accessed=(new Date).getTime();const i=e.nodes,n=[],r=[];for(const t of i)t.complete?n.push(t):r.push(t.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return Ot(G(n),bt(s.map((t=>this._api.getSpatialImages$(t).pipe(rt((t=>{const e=[];for(const i of t){if(!i.node){console.warn(`Image is empty (${i.node})`);continue}const t=i.node_id;if(!this.hasNode(t))continue;const n=this.getNode(t);n.complete||this._makeFull(n,i.node),e.push(n)}return e})))))).pipe(Et()))})),De(((t,e)=>t.concat(e))))}cacheFill$(t){if(t in this._cachingFull$)throw new _d(`Cannot fill node while caching full (${t}).`);if(!this.hasNode(t))throw new _d(`Cannot fill node that does not exist in graph (${t}).`);if(t in this._cachingFill$)return this._cachingFill$[t];const e=this.getNode(t);if(e.complete)throw new _d(`Cannot fill node that is already full (${t}).`);return this._cachingFill$[t]=this._api.getSpatialImages$([t]).pipe(pi((t=>{for(const i of t)i.node||console.warn(`Image is empty ${i.node_id}`),e.complete||this._makeFull(e,i.node),delete this._cachingFill$[i.node_id]})),rt((()=>this)),Me((()=>{t in this._cachingFill$&&delete this._cachingFill$[t],this._changed$.next(this)})),He(),E()),this._cachingFill$[t]}cacheFull$(t){if(t in this._cachingFull$)return this._cachingFull$[t];if(this.hasNode(t))throw new _d(`Cannot cache full node that already exist in graph (${t}).`);return this._cachingFull$[t]=this._api.getImages$([t]).pipe(pi((e=>{for(const i of e){if(!i.node)throw new _d(`Image does not exist (${t}, ${i.node}).`);const e=i.node_id;if(this.hasNode(e)){const e=this.getNode(t);e.complete||this._makeFull(e,i.node)}else{if(null==i.node.sequence.id)throw new _d(`Image has no sequence key (${t}).`);const n=new ed(i.node);this._makeFull(n,i.node);const r=this._api.data.geometry.lngLatToCellId(n.originalLngLat);this._preStore(r,n),this._setNode(n),delete this._cachingFull$[e]}}})),rt((()=>this)),Me((()=>{t in this._cachingFull$&&delete this._cachingFull$[t],this._changed$.next(this)})),He(),E()),this._cachingFull$[t]}cacheNodeSequence$(t){if(!this.hasNode(t))throw new _d(`Cannot cache sequence edges of node that does not exist in graph (${t}).`);let e=this.getNode(t);if(e.sequenceId in this._sequences)throw new _d(`Sequence already cached (${t}), (${e.sequenceId}).`);return this._cacheSequence$(e.sequenceId)}cacheSequence$(t){if(t in this._sequences)throw new _d(`Sequence already cached (${t})`);return this._cacheSequence$(t)}cacheSequenceEdges(t){let e=this.getNode(t);if(!(e.sequenceId in this._sequences))throw new _d(`Sequence is not cached (${t}), (${e.sequenceId})`);let i=this._sequences[e.sequenceId].sequence,n=this._edgeCalculator.computeSequenceEdges(e,i);e.cacheSequenceEdges(n)}cacheSequenceNodes$(t,e){if(!this.hasSequence(t))throw new _d(`Cannot cache sequence nodes of sequence that does not exist in graph (${t}).`);if(this.hasSequenceNodes(t))throw new _d(`Sequence nodes already cached (${t}).`);const i=this.getSequence(t);if(i.id in this._cachingSequenceNodes$)return this._cachingSequenceNodes$[i.id];const n=[],r=i.imageIds.slice();if(e&&r.length>50){const t=r.indexOf(e),i=Math.max(0,Math.min(t-25,r.length-50));n.push(r.splice(i,50))}for(;r.length>0;)n.push(r.splice(0,200));let s=n.length;const o=bt(n).pipe(Mt((t=>this._api.getImages$(t).pipe(pi((t=>{for(const e of t){if(!e.node){console.warn(`Image empty (${e.node_id})`);continue}const t=e.node_id;if(this.hasNode(t)){const i=this.getNode(t);i.complete||this._makeFull(i,e.node)}else{null==e.node.sequence.id&&console.warn(`Sequence missing, discarding node (${e.node_id})`);const t=new ed(e.node);this._makeFull(t,e.node);const i=this._api.data.geometry.lngLatToCellId(t.originalLngLat);this._preStore(i,t),this._setNode(t)}}s--})),rt((()=>this)))),6),Re(),Me((()=>{delete this._cachingSequenceNodes$[i.id],0===s&&(this._cachedSequenceNodes[i.id]=!0)})),He(),E());return this._cachingSequenceNodes$[i.id]=o,o}cacheSpatialArea$(t){if(!this.hasNode(t))throw new _d(`Cannot cache spatial area of node that does not exist in graph (${t}).`);if(t in this._cachedSpatialEdges)throw new _d(`Image already spatially cached (${t}).`);if(!(t in this._requiredSpatialArea))throw new _d(`Spatial area not determined (${t}).`);let e=this._requiredSpatialArea[t];if(0===Object.keys(e.cacheNodes).length)throw new _d(`Spatial nodes already cached (${t}).`);if(t in this._cachingSpatialArea$)return this._cachingSpatialArea$[t];let i=[];for(;e.cacheKeys.length>0;)i.push(e.cacheKeys.splice(0,200));let n=i.length,r=[];for(let s of i){let i=this._api.getSpatialImages$(s).pipe(pi((i=>{for(const t of i){if(!t.node){console.warn(`Image is empty (${t.node_id})`);continue}const i=t.node_id,n=e.cacheNodes[i];n.complete?delete e.cacheNodes[i]:(this._makeFull(n,t.node),delete e.cacheNodes[i])}0==--n&&delete this._cachingSpatialArea$[t]})),rt((()=>this)),te((i=>{for(let t of s)t in e.all&&delete e.all[t],t in e.cacheNodes&&delete e.cacheNodes[t];throw 0==--n&&delete this._cachingSpatialArea$[t],i})),Me((()=>{0===Object.keys(e.cacheNodes).length&&this._changed$.next(this)})),He(),E());r.push(i)}return this._cachingSpatialArea$[t]=r,r}cacheSpatialEdges(t){if(t in this._cachedSpatialEdges)throw new _d(`Spatial edges already cached (${t}).`);let e=this.getNode(t),i=this._sequences[e.sequenceId].sequence,n=[],r=i.findPrev(e.id);null!=r&&n.push(r);let s=i.findNext(e.id);null!=s&&n.push(s);let o=this._requiredSpatialArea[t].all,a=[],c=this._filter;for(let t in o){if(!o.hasOwnProperty(t))continue;let e=o[t];c(e)&&a.push(e)}let h=this._edgeCalculator.getPotentialEdges(e,a,n),l=this._edgeCalculator.computeStepEdges(e,h,r,s);l=l.concat(this._edgeCalculator.computeTurnEdges(e,h)),l=l.concat(this._edgeCalculator.computeSphericalEdges(e,h)),l=l.concat(this._edgeCalculator.computePerspectiveToSphericalEdges(e,h)),l=l.concat(this._edgeCalculator.computeSimilarEdges(e,h)),e.cacheSpatialEdges(l),this._cachedSpatialEdges[t]=e,delete this._requiredSpatialArea[t],delete this._cachedNodeTiles[t]}cacheTiles$(t){if(t in this._cachedNodeTiles)throw new _d(`Tiles already cached (${t}).`);if(t in this._cachedSpatialEdges)throw new _d(`Spatial edges already cached so tiles considered cached (${t}).`);if(!(t in this._requiredNodeTiles))throw new _d(`Tiles have not been determined (${t}).`);let e=this._requiredNodeTiles[t];if(0===e.cache.length&&0===e.caching.length)throw new _d(`Tiles already cached (${t}).`);if(!this.hasNode(t))throw new _d(`Cannot cache tiles of node that does not exist in graph (${t}).`);let i=e.cache.slice();e.caching=this._requiredNodeTiles[t].caching.concat(i),e.cache=[];let n=[];for(let i of e.caching){const r=i in this._cachingTiles$?this._cachingTiles$[i]:this._cacheTile$(i);n.push(r.pipe(pi((n=>{let r=e.caching.indexOf(i);r>-1&&e.caching.splice(r,1),0===e.caching.length&&0===e.cache.length&&(delete this._requiredNodeTiles[t],this._cachedNodeTiles[t]=!0)})),te((n=>{let r=e.caching.indexOf(i);throw r>-1&&e.caching.splice(r,1),0===e.caching.length&&0===e.cache.length&&(delete this._requiredNodeTiles[t],this._cachedNodeTiles[t]=!0),n})),Me((()=>{this._changed$.next(this)})),He(),E()))}return n}initializeCache(t){if(t in this._cachedNodes)throw new _d(`Image already in cache (${t}).`);const e=this.getNode(t),i=this._api.data;e.initializeCache(new id(i));const n=(new Date).getTime();this._cachedNodes[t]={accessed:n,node:e},this._updateCachedTileAccess(t,n)}isCachingFill(t){return t in this._cachingFill$}isCachingFull(t){return t in this._cachingFull$}isCachingNodeSequence(t){return this.getNode(t).sequenceId in this._cachingSequences$}isCachingSequence(t){return t in this._cachingSequences$}isCachingSequenceNodes(t){return t in this._cachingSequenceNodes$}isCachingTiles(t){return t in this._requiredNodeTiles&&0===this._requiredNodeTiles[t].cache.length&&this._requiredNodeTiles[t].caching.length>0}hasInitializedCache(t){return t in this._cachedNodes}hasNode(t){let e=(new Date).getTime();return this._updateCachedNodeAccess(t,e),this._updateCachedTileAccess(t,e),t in this._nodes}hasNodeSequence(t){let e=this.getNode(t).sequenceId,i=e in this._sequences;return i&&(this._sequences[e].accessed=(new Date).getTime()),i}hasSequence(t){let e=t in this._sequences;return e&&(this._sequences[t].accessed=(new Date).getTime()),e}hasSequenceNodes(t){return t in this._cachedSequenceNodes}hasSpatialArea(t){if(!this.hasNode(t))throw new _d(`Spatial area nodes cannot be determined if node not in graph (${t}).`);if(t in this._cachedSpatialEdges)return!0;if(t in this._requiredSpatialArea)return 0===Object.keys(this._requiredSpatialArea[t].cacheNodes).length;let e=this.getNode(t),i=this._graphCalculator.boundingBoxCorners(e.lngLat,this._tileThreshold),n=this._nodeIndex.search({maxX:i[1].lng,maxY:i[1].lat,minX:i[0].lng,minY:i[0].lat}),r={all:{},cacheKeys:[],cacheNodes:{}};for(let t of n)r.all[t.node.id]=t.node,t.node.complete||(r.cacheKeys.push(t.node.id),r.cacheNodes[t.node.id]=t.node);return this._requiredSpatialArea[t]=r,0===r.cacheKeys.length}hasTiles(t){if(t in this._cachedNodeTiles)return!0;if(t in this._cachedSpatialEdges)return!0;if(!this.hasNode(t))throw new _d(`Image does not exist in graph (${t}).`);let e={cache:[],caching:[]};if(t in this._requiredNodeTiles)e=this._requiredNodeTiles[t];else{const i=this.getNode(t),[n,r]=this._graphCalculator.boundingBoxCorners(i.lngLat,this._tileThreshold);e.cache=this._api.data.geometry.bboxToCellIds(n,r).filter((t=>!(t in this._cachedTiles))),e.cache.length>0&&(this._requiredNodeTiles[t]=e)}return 0===e.cache.length&&0===e.caching.length}getNode(t){let e=(new Date).getTime();return this._updateCachedNodeAccess(t,e),this._updateCachedTileAccess(t,e),this._nodes[t]}getSequence(t){let e=this._sequences[t];return e.accessed=(new Date).getTime(),e.sequence}resetSpatialEdges(){let t=Object.keys(this._cachedSpatialEdges);for(let e of t){this._cachedSpatialEdges[e].resetSpatialEdges(),delete this._cachedSpatialEdges[e]}}reset(t){const e=[];for(const i of t){if(!this.hasNode(i))throw new Error(`Image does not exist ${i}`);const t=this.getNode(i);t.resetSequenceEdges(),t.resetSpatialEdges(),e.push(t)}for(let e of Object.keys(this._cachedNodes))-1===t.indexOf(e)&&(this._cachedNodes[e].node.dispose(),delete this._cachedNodes[e]);this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._nodes={},this._nodeToTile={},this._preStored={};for(const t of e){this._nodes[t.id]=t;const e=this._api.data.geometry.lngLatToCellId(t.originalLngLat);this._preStore(e,t)}this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._nodeIndexTiles={},this._nodeIndex.clear()}setFilter(t){this._filter=this._filterCreator.createFilter(t),this._filterSubject$.next(this._filter)}uncache(t,e,i){const n={};this._addNewKeys(n,this._cachingFull$),this._addNewKeys(n,this._cachingFill$),this._addNewKeys(n,this._cachingSpatialArea$),this._addNewKeys(n,this._requiredNodeTiles),this._addNewKeys(n,this._requiredSpatialArea);for(const e of t)e in n||(n[e]=!0);const r=this._tileThreshold,s=this._graphCalculator,o=this._api.data.geometry,a=new Set(e);for(let t in n){if(!n.hasOwnProperty(t))continue;const e=this._nodes[t],[i,c]=s.boundingBoxCorners(e.lngLat,r),h=o.bboxToCellIds(i,c);for(const t of h)a.has(t)||a.add(t)}const c=[];for(let t in this._cachedTiles)this._cachedTiles.hasOwnProperty(t)&&!a.has(t)&&c.push([t,this._cachedTiles[t]]);const h=c.sort(((t,e)=>e[1].accessed-t[1].accessed)).slice(this._configuration.maxUnusedTiles).map((t=>t[0]));for(let t of h)this._uncacheTile(t,i);const l=[],u=[];for(let t in this._preStored){if(!this._preStored.hasOwnProperty(t)||t in this._cachingTiles$)continue;const e=this._preStored[t];for(let r in e)e.hasOwnProperty(r)&&!(r in n)&&e[r].sequenceId!==i&&(r in this._cachedNodes?l.push([this._cachedNodes[r],t]):u.push([r,t]))}const d=l.sort((([t],[e])=>e.accessed-t.accessed)).slice(this._configuration.maxUnusedPreStoredImages).map((([t,e])=>[t.node.id,e]));this._uncachePreStored(u),this._uncachePreStored(d);const p=[];for(let t in this._cachedNodes)this._cachedNodes.hasOwnProperty(t)&&!(t in n)&&p.push(this._cachedNodes[t]);const f=p.sort(((t,e)=>e.accessed-t.accessed)).slice(this._configuration.maxUnusedImages);for(const t of f){t.node.uncache();const e=t.node.id;delete this._cachedNodes[e],e in this._cachedNodeTiles&&delete this._cachedNodeTiles[e],e in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[e]}const m=[];for(let t in this._sequences)this._sequences.hasOwnProperty(t)&&!(t in this._cachingSequences$)&&t!==i&&m.push(this._sequences[t]);const g=m.sort(((t,e)=>e.accessed-t.accessed)).slice(this._configuration.maxSequences);for(const t of g){const e=t.sequence.id;delete this._sequences[e],e in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[e],t.sequence.dispose()}}updateCells$(t){const e=this._cachedTiles,i=this._cachingTiles$;return bt(t).pipe(Mt((t=>t in e?this._updateCell$(t):t in i?i[t].pipe(te((()=>G(this))),Mt((()=>this._updateCell$(t)))):B())))}unsubscribe(){this._filterSubscription.unsubscribe()}_addNewKeys(t,e){for(let i in e)e.hasOwnProperty(i)&&this.hasNode(i)&&(i in t||(t[i]=!0))}_cacheSequence$(t){return t in this._cachingSequences$||(this._cachingSequences$[t]=this._api.getSequence$(t).pipe(pi((e=>{e?(e.id in this._sequences||(this._sequences[e.id]={accessed:(new Date).getTime(),sequence:new nd(e)}),delete this._cachingSequences$[t]):console.warn(`Sequence does not exist (${t})`)})),rt((()=>this)),Me((()=>{t in this._cachingSequences$&&delete this._cachingSequences$[t],this._changed$.next(this)})),He(),E())),this._cachingSequences$[t]}_cacheTile$(t){return this._cachingTiles$[t]=this._api.getCoreImages$(t).pipe(pi((e=>{if(t in this._cachedTiles)return;const i=e.images;this._nodeIndexTiles[t]=[],this._cachedTiles[t]={accessed:(new Date).getTime(),nodes:[]};const n=this._cachedTiles[t].nodes,r=this._removeFromPreStore(t);for(const e of i){if(!e)break;if(null==e.sequence.id){console.warn(`Sequence missing, discarding node (${e.id})`);continue}if(null!=r&&e.id in r){const i=r[e.id];delete r[e.id],n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[t].push(s),this._nodeToTile[i.id]=t;continue}const i=new ed(e);n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[t].push(s),this._nodeToTile[i.id]=t,this._setNode(i)}delete this._cachingTiles$[t]})),rt((()=>this)),te((e=>{throw delete this._cachingTiles$[t],e})),He(),E()),this._cachingTiles$[t]}_makeFull(t,e){null==e.computed_altitude&&(e.computed_altitude=this._defaultAlt),null==e.computed_rotation&&(e.computed_rotation=this._graphCalculator.rotationFromCompass(e.compass_angle,e.exif_orientation)),t.makeComplete(e)}_preStore(t,e){t in this._preStored||(this._preStored[t]={}),this._preStored[t][e.id]=e}_removeFromPreStore(t){let e=null;return t in this._preStored&&(e=this._preStored[t],delete this._preStored[t]),e}_setNode(t){let e=t.id;if(this.hasNode(e))throw new _d(`Image already exist (${e}).`);this._nodes[e]=t}_uncacheTile(t,e){for(let i of this._cachedTiles[t].nodes){let n=i.id;delete this._nodeToTile[n],n in this._cachedNodes&&delete this._cachedNodes[n],n in this._cachedNodeTiles&&delete this._cachedNodeTiles[n],n in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[n],i.sequenceId===e?(this._preStore(t,i),i.uncache()):(delete this._nodes[n],i.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[i.sequenceId],i.dispose())}for(let e of this._nodeIndexTiles[t])this._nodeIndex.remove(e);delete this._nodeIndexTiles[t],delete this._cachedTiles[t]}_uncachePreStored(t){let e={};for(let[i,n]of t){i in this._nodes&&delete this._nodes[i],i in this._cachedNodes&&delete this._cachedNodes[i];let t=this._preStored[n][i];t.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[t.sequenceId],delete this._preStored[n][i],t.dispose(),e[n]=!0}for(let t in e)e.hasOwnProperty(t)&&0===Object.keys(this._preStored[t]).length&&delete this._preStored[t]}_updateCachedTileAccess(t,e){t in this._nodeToTile&&(this._cachedTiles[this._nodeToTile[t]].accessed=e)}_updateCachedNodeAccess(t,e){t in this._cachedNodes&&(this._cachedNodes[t].accessed=e)}_updateCell$(t){return this._api.getCoreImages$(t).pipe(Mt((e=>{if(!(t in this._cachedTiles))return B();const i=this._nodeIndex,n=this._nodeIndexTiles[t],r=this._nodeToTile,s=this._cachedTiles[t];s.accessed=(new Date).getTime();const o=s.nodes,a=e.images;for(const e of a){if(null==e)break;if(this.hasNode(e.id))continue;if(null==e.sequence.id){console.warn(`Sequence missing, discarding node (${e.id})`);continue}const s=new ed(e);o.push(s);const a={lat:s.lngLat.lat,lng:s.lngLat.lng,node:s};i.insert(a),n.push(a),r[s.id]=t,this._setNode(s)}return G(t)})),te((t=>(console.error(t),B()))))}}class yd{constructor(){this._hash={},this._index=new yd._spatialIndex(16),this._indexChanged$=new T,this._updated$=new T}static register(t){yd._spatialIndex=t}get changed$(){return this._indexChanged$}get updated$(){return this._updated$}add(t){const e=[],i=this._hash,n=this._index;for(const r of t){const t=r.id;t in i&&(n.remove(i[t]),e.push(r));const s={lat:r.lngLat.lat,lng:r.lngLat.lng,marker:r};i[t]=s,n.insert(s)}e.length>0&&this._updated$.next(e),t.length>e.length&&this._indexChanged$.next(this)}has(t){return t in this._hash}get(t){return this.has(t)?this._hash[t].marker:void 0}getAll(){return this._index.all().map((t=>t.marker))}remove(t){const e=this._hash,i=this._index;let n=!1;for(const r of t){if(!(r in e))continue;const t=e[r];i.remove(t),delete e[r],n=!0}n&&this._indexChanged$.next(this)}removeAll(){this._hash={},this._index.clear(),this._indexChanged$.next(this)}search([t,e]){return this._index.search({maxX:e.lng,maxY:e.lat,minX:t.lng,minY:t.lat}).map((t=>t.marker))}update(t){const e=this._hash,i=this._index,n=t.id;if(!(n in e))return;i.remove(e[n]);const r={lat:t.lngLat.lat,lng:t.lngLat.lng,marker:t};e[n]=r,i.insert(r)}}function bd(t,e,i,n,r){xd(t,e,i||0,n||t.length-1,r||Sd)}function xd(t,e,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,o=e-i+1,a=Math.log(s),c=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*c*(s-c)/s)*(o-s/2<0?-1:1);xd(t,e,Math.max(i,Math.floor(e-o*c/s+h)),Math.min(n,Math.floor(e+(s-o)*c/s+h)),r)}var l=t[e],u=i,d=n;for(wd(t,i,e),r(t[n],l)>0&&wd(t,i,n);u<d;){for(wd(t,u,d),u++,d--;r(t[u],l)<0;)u++;for(;r(t[d],l)>0;)d--}0===r(t[i],l)?wd(t,i,d):wd(t,++d,n),d<=e&&(i=d+1),e<=d&&(n=d-1)}}function wd(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Sd(t,e){return t<e?-1:t>e?1:0}function Md(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n<e.length;n++)if(i(t,e[n]))return n;return-1}function Td(t,e){Cd(t,0,t.children.length,e,t)}function Cd(t,e,i,n,r){r||(r=Dd(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<i;s++){const e=t.children[s];Ed(r,t.leaf?n(e):e)}return r}function Ed(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Id(t,e){return t.minX-e.minX}function Ad(t,e){return t.minY-e.minY}function Pd(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Rd(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ld(t,e){const i=Math.max(t.minX,e.minX),n=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function Od(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Nd(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Dd(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $d(t,e,i,n,r){const s=[e,i];for(;s.length;){if((i=s.pop())-(e=s.pop())<=n)continue;const o=e+Math.ceil((i-e)/n/2)*n;bd(t,o,e,i,r),s.push(e,o,o,i)}}class kd extends class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Nd(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?n(o):o;Nd(t,a)&&(e.leaf?i.push(o):Od(t,a)?this._all(o,i):r.push(o))}e=r.pop()}return i}collides(t){let e=this.data;if(!Nd(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const r=e.children[n],s=e.leaf?this.toBBox(r):r;if(Nd(t,s)){if(e.leaf||Od(t,s))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Dd([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),r=[],s=[];let o,a,c;for(;i||r.length;){if(i||(i=r.pop(),a=r[r.length-1],o=s.pop(),c=!0),i.leaf){const n=Md(t,i.children,e);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}c||i.leaf||!Od(i,n)?a?(o++,i=a.children[o],c=!1):i=null:(r.push(i),s.push(o),o=0,a=i,i=i.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const r=i-e+1;let s,o=this._maxEntries;if(r<=o)return s=Dd(t.slice(e,i+1)),Td(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),s=Dd([]),s.leaf=!1,s.height=n;const a=Math.ceil(r/o),c=a*Math.ceil(Math.sqrt(o));$d(t,e,i,c,this.compareMinX);for(let r=e;r<=i;r+=c){const e=Math.min(r+c-1,i);$d(t,r,e,a,this.compareMinY);for(let i=r;i<=e;i+=a){const r=Math.min(i+a-1,e);s.children.push(this._build(t,i,r,n-1))}}return Td(s,this.toBBox),s}_chooseSubtree(t,e,i,n){for(;n.push(e),!e.leaf&&n.length-1!==i;){let i,n=1/0,o=1/0;for(let a=0;a<e.children.length;a++){const c=e.children[a],h=Pd(c),l=(r=t,s=c,(Math.max(s.maxX,r.maxX)-Math.min(s.minX,r.minX))*(Math.max(s.maxY,r.maxY)-Math.min(s.minY,r.minY))-h);l<o?(o=l,n=h<n?h:n,i=c):l===o&&h<n&&(n=h,i=c)}e=i||e.children[0]}var r,s;return e}_insert(t,e,i){const n=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(n,this.data,e,r);for(s.children.push(t),Ed(s,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),o=Dd(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,Td(i,this.toBBox),Td(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=Dd([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Td(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,s=1/0;for(let o=e;o<=i-e;o++){const e=Cd(t,0,o,this.toBBox),a=Cd(t,o,i,this.toBBox),c=Ld(e,a),h=Pd(e)+Pd(a);c<r?(r=c,n=o,s=h<s?h:s):c===r&&h<s&&(s=h,n=o)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:Id,r=t.leaf?this.compareMinY:Ad;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const r=this.toBBox,s=Cd(t,0,e,r),o=Cd(t,i-e,i,r);let a=Rd(s)+Rd(o);for(let n=e;n<i-e;n++){const e=t.children[n];Ed(s,t.leaf?r(e):e),a+=Rd(s)}for(let n=i-e-1;n>=e;n--){const e=t.children[n];Ed(o,t.leaf?r(e):e),a+=Rd(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Ed(e[n],t)}_condense(t){for(let e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children,e.splice(e.indexOf(t[i]),1)):this.clear():Td(t[i],this.toBBox)}}{compareMinX(t,e){return t.lng-e.lng}compareMinY(t,e){return t.lat-e.lat}toBBox(t){return{minX:t.lng,minY:t.lat,maxX:t.lng,maxY:t.lat}}}var zd,Fd=Bd;function Bd(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=i,this.p2y=n}Bd.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},Bd.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},Bd.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},Bd.prototype.solveCurveX=function(t,e){var i,n,r,s,o;for(void 0===e&&(e=1e-6),r=t,o=0;o<8;o++){if(s=this.sampleCurveX(r)-t,Math.abs(s)<e)return r;var a=this.sampleCurveDerivativeX(r);if(Math.abs(a)<1e-6)break;r-=s/a}if((r=t)<(i=0))return i;if(r>(n=1))return n;for(;i<n;){if(s=this.sampleCurveX(r),Math.abs(s-t)<e)return r;t>s?i=r:n=r,r=.5*(n-i)+i}return r},Bd.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))},t.TransitionMode=void 0,(zd=t.TransitionMode||(t.TransitionMode={}))[zd.Default=0]="Default",zd[zd.Instantaneous=1]="Instantaneous";class jd{constructor(t){null!=t?(this._position=(new fn).fromArray(t.unprojectSfM([0,0],0)),this._lookat=(new fn).fromArray(t.unprojectSfM([0,0],10)),this._up=t.upVector(),this._focal=this._getFocal(t)):(this._position=new fn(0,0,0),this._lookat=new fn(1,0,0),this._up=new fn(0,0,1),this._focal=1)}get position(){return this._position}get lookat(){return this._lookat}get up(){return this._up}get focal(){return this._focal}set focal(t){this._focal=t}lerpCameras(t,e,i){this._position.subVectors(e.position,t.position).multiplyScalar(i).add(t.position),this._lookat.subVectors(e.lookat,t.lookat).multiplyScalar(i).add(t.lookat),this._up.subVectors(e.up,t.up).multiplyScalar(i).add(t.up),this._focal=(1-i)*t.focal+i*e.focal}copy(t){this._position.copy(t.position),this._lookat.copy(t.lookat),this._up.copy(t.up),this._focal=t.focal}clone(){let t=new jd;return t.position.copy(this._position),t.lookat.copy(this._lookat),t.up.copy(this._up),t.focal=this._focal,t}diff(t){let e=this._position.distanceToSquared(t.position),i=this._lookat.distanceToSquared(t.lookat),n=this._up.distanceToSquared(t.up),r=100*Math.abs(this._focal-t.focal);return Math.max(e,i,n,r)}_getFocal(t){return dd(t.cameraType)?.5/Math.tan(Math.PI/2):t.focal}}class Hd{constructor(t,e,i,n,r,s,o,a,c,h){this._orientation=this._getValue(t,1);let l=null!=o?o.width:4,u=null!=o?o.height:3,d=this._orientation<5;this._width=this._getValue(e,d?l:u),this._height=this._getValue(i,d?u:l),this._basicAspect=d?this._width/this._height:this._height/this._width,this._basicWidth=d?e:i,this._basicHeight=d?i:e;const p=this._getCameraParameters(c,h),f=p[0],m=p[1],g=p[2];this._focal=this._getValue(f,1),this._scale=this._getValue(n,0),this._worldToCamera=this.createWorldToCamera(r,s),this._worldToCameraInverse=(new Hn).copy(this._worldToCamera).invert(),this._scaledWorldToCamera=this._createScaledWorldToCamera(this._worldToCamera,this._scale),this._scaledWorldToCameraInverse=(new Hn).copy(this._scaledWorldToCamera).invert(),this._basicWorldToCamera=this._createBasicWorldToCamera(this._worldToCamera,t),this._textureScale=a||[1,1],this._ck1=m||0,this._ck2=g||0,this._cameraType=h||"perspective",this._radialPeak=this._getRadialPeak(this._ck1,this._ck2)}get ck1(){return this._ck1}get ck2(){return this._ck2}get cameraType(){return this._cameraType}get basicAspect(){return this._basicAspect}get basicHeight(){return this._basicHeight}get basicRt(){return this._basicWorldToCamera}get basicWidth(){return this._basicWidth}get focal(){return this._focal}get height(){return this._height}get orientation(){return this._orientation}get rt(){return this._worldToCamera}get srt(){return this._scaledWorldToCamera}get srtInverse(){return this._scaledWorldToCameraInverse}get scale(){return this._scale}get hasValidScale(){return this._scale>.01&&this._scale<50}get radialPeak(){return this._radialPeak}get width(){return this._width}upVector(){let t=this._worldToCamera.elements;switch(this._orientation){case 1:return new fn(-t[1],-t[5],-t[9]);case 3:return new fn(t[1],t[5],t[9]);case 6:return new fn(-t[0],-t[4],-t[8]);case 8:return new fn(t[0],t[4],t[8]);default:return new fn(-t[1],-t[5],-t[9])}}projectorMatrix(){let t=this._normalizedToTextureMatrix(),e=this._focal,i=(new Hn).set(e,0,0,0,0,e,0,0,0,0,0,0,0,0,1,0);return t.multiply(i),t.multiply(this._worldToCamera),t}projectBasic(t){let e=this.projectSfM(t);return this._sfmToBasic(e)}unprojectBasic(t,e,i){let n=this._basicToSfm(t);return this.unprojectSfM(n,e,i)}projectSfM(t){let e=new un(t[0],t[1],t[2],1);return e.applyMatrix4(this._worldToCamera),this._bearingToSfm([e.x,e.y,e.z])}unprojectSfM(t,e,i){const n=this._sfmToBearing(t),r=(i&&!dd(this._cameraType)?new un(e*n[0]/n[2],e*n[1]/n[2],e,1):new un(e*n[0],e*n[1],e*n[2],1)).applyMatrix4(this._worldToCameraInverse);return[r.x/r.w,r.y/r.w,r.z/r.w]}_sfmToBearing(t){if(dd(this._cameraType)){let e=2*t[0]*Math.PI,i=2*-t[1]*Math.PI;return[Math.cos(i)*Math.sin(e),-Math.sin(i),Math.cos(i)*Math.cos(e)]}if(pd(this._cameraType)){let[e,i]=[t[0]/this._focal,t[1]/this._focal];const n=Math.sqrt(e*e+i*i);let r=n/this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak),s=Math.cos(r),o=Math.sin(r);const a=n>1e-8?1/n:1;return[o*e*a,o*i*a,s]}{let[e,i]=[t[0]/this._focal,t[1]/this._focal];const n=Math.sqrt(e*e+i*i);let r=this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak);let s=new fn(e/r,i/r,1);return s.normalize(),[s.x,s.y,s.z]}}_distortionFromDistortedRadius(t,e,i,n){let r=1;for(let s=0;s<10;s++){let s=t/r;s>n&&(s=n),r=1+e*Math.pow(s,2)+i*Math.pow(s,4)}return r}_bearingToSfm(t){if(dd(this._cameraType)){let e=t[0],i=t[1],n=t[2],r=Math.atan2(e,n),s=Math.atan2(-i,Math.sqrt(e*e+n*n));return[r/(2*Math.PI),-s/(2*Math.PI)]}if(pd(this._cameraType)){if(t[2]>0){const[e,i,n]=t,r=Math.sqrt(e*e+i*i);let s=Math.atan2(r,n);s>this._radialPeak&&(s=this._radialPeak);const o=1+Math.pow(s,2)*(this._ck1+Math.pow(s,2)*this._ck2),a=this._focal*o*s/r;return[a*e,a*i]}return[t[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,t[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}if(t[2]>0){let[e,i]=[t[0]/t[2],t[1]/t[2]],n=e*e+i*i;const r=Math.pow(this._radialPeak,2);n>r&&(n=r);const s=1+this._ck1*n+this._ck2*Math.pow(n,2);return[this._focal*s*e,this._focal*s*i]}return[t[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,t[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}_basicToSfm(t){let e,i;switch(this._orientation){case 1:e=t[0],i=t[1];break;case 3:e=1-t[0],i=1-t[1];break;case 6:e=t[1],i=1-t[0];break;case 8:e=1-t[1],i=t[0];break;default:e=t[0],i=t[1]}let n=this._width,r=this._height,s=Math.max(n,r);return[e*n/s-n/s/2,i*r/s-r/s/2]}_sfmToBasic(t){let e,i,n=this._width,r=this._height,s=Math.max(n,r),o=(t[0]+n/s/2)/n*s,a=(t[1]+r/s/2)/r*s;switch(this._orientation){case 1:e=o,i=a;break;case 3:e=1-o,i=1-a;break;case 6:e=1-a,i=o;break;case 8:e=a,i=1-o;break;default:e=o,i=a}return[e,i]}_getValue(t,e){return null!=t&&t>0?t:e}_getCameraParameters(t,e){if(dd(e))return[];if(!t||0===t.length)return[1,0,0];const i=3-t.length;return i<=0?t:t.concat(new Array(i).fill(0))}createWorldToCamera(t,e){const i=new fn(t[0],t[1],t[2]),n=i.length();n>0&&i.normalize();const r=new Hn;return r.makeRotationAxis(i,n),r.setPosition(new fn(e[0],e[1],e[2])),r}_createScaledWorldToCamera(t,e){const i=t.clone(),n=i.elements;return n[12]=e*n[12],n[13]=e*n[13],n[14]=e*n[14],i.scale(new fn(e,e,e)),i}_createBasicWorldToCamera(t,e){const i=new fn(0,0,1);let n=0;switch(e){case 3:n=Math.PI;break;case 6:n=Math.PI/2;break;case 8:n=3*Math.PI/2}return(new Hn).makeRotationAxis(i,n).multiply(t)}_getRadialPeak(t,e){const i=5*e,n=3*t,r=Math.pow(n,2)-4*i*1;if(r<0)return;const s=(-n-Math.sqrt(r))/2/i,o=(-n+Math.sqrt(r))/2/i,a=Math.min(s,o),c=Math.max(s,o);return a>0?Math.sqrt(a):c>0?Math.sqrt(c):void 0}_normalizedToTextureMatrix(){const t=Math.max(this._width,this._height),e=this._orientation<5?this._textureScale[0]:this._textureScale[1],i=this._orientation<5?this._textureScale[1]:this._textureScale[0],n=t/this._width*e,r=t/this._height*i;switch(this._orientation){case 1:return(new Hn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1);case 3:return(new Hn).set(-n,0,0,.5,0,r,0,.5,0,0,1,0,0,0,0,1);case 6:return(new Hn).set(0,-r,0,.5,-n,0,0,.5,0,0,1,0,0,0,0,1);case 8:return(new Hn).set(0,r,0,.5,n,0,0,.5,0,0,1,0,0,0,0,1);default:return(new Hn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1)}}}class Ud{constructor(t){this._spatial=new ld,this._referenceThreshold=.01,this._transitionMode=t.transitionMode,this._reference=t.reference,this._alpha=t.alpha,this._camera=t.camera.clone(),this._zoom=t.zoom,this._currentIndex=t.currentIndex,this._trajectory=t.trajectory.slice(),this._trajectoryTransforms=[],this._trajectoryCameras=[];for(let t of this._trajectory){let e=this._imageToTranslation(t,this._reference),i=new Hd(t.exifOrientation,t.width,t.height,t.scale,t.rotation,e,t.image,void 0,t.cameraParameters,t.cameraType);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new jd(i))}this._currentImage=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousImage=this._trajectory.length>1&&this.currentIndex>0?this._trajectory[this._currentIndex-1]:null,this._currentCamera=this._trajectoryCameras.length>0?this._trajectoryCameras[this._currentIndex].clone():new jd,this._previousCamera=this._trajectoryCameras.length>1&&this.currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}get reference(){return this._reference}get alpha(){return this._getAlpha()}get camera(){return this._camera}get zoom(){return this._zoom}get trajectory(){return this._trajectory}get currentIndex(){return this._currentIndex}get currentImage(){return this._currentImage}get previousImage(){return this._previousImage}get currentCamera(){return this._currentCamera}get currentTransform(){return this._trajectoryTransforms.length>0?this._trajectoryTransforms[this.currentIndex]:null}get previousTransform(){return this._trajectoryTransforms.length>1&&this.currentIndex>0?this._trajectoryTransforms[this.currentIndex-1]:null}get motionless(){return this._motionless}get transitionMode(){return this._transitionMode}move(t){}moveTo(t){}rotate(t){}rotateUnbounded(t){}rotateWithoutInertia(t){}rotateBasic(t){}rotateBasicUnbounded(t){}rotateBasicWithoutInertia(t){}rotateToBasic(t){}setSpeed(t){}zoomIn(t,e){}update(t){}setCenter(t){}setZoom(t){}dolly(t){}orbit(t){}setViewMatrix(t){}truck(t){}append(t){if(t.length<1)throw Error("Trajectory can not be empty");this._currentIndex<0?this.set(t):(this._trajectory=this._trajectory.concat(t),this._appendToTrajectories(t))}prepend(t){if(t.length<1)throw Error("Trajectory can not be empty");this._trajectory=t.slice().concat(this._trajectory),this._currentIndex+=t.length,this._setCurrentImage(),this._setReference(this._currentImage)?this._setTrajectories():this._prependToTrajectories(t),this._setCurrentCamera()}remove(t){if(t<0)throw Error("n must be a positive integer");if(this._currentIndex-1<t)throw Error("Current and previous images can not be removed");for(let e=0;e<t;e++)this._trajectory.shift(),this._trajectoryTransforms.shift(),this._trajectoryCameras.shift(),this._currentIndex--;this._setCurrentImage()}clearPrior(){this._currentIndex>0&&this.remove(this._currentIndex-1)}clear(){this.cut(),this._currentIndex>0&&this.remove(this._currentIndex-1)}cut(){for(;this._trajectory.length-1>this._currentIndex;)this._trajectory.pop(),this._trajectoryTransforms.pop(),this._trajectoryCameras.pop()}set(t){this._setTrajectory(t),this._setCurrentImage(),this._setReference(this._currentImage),this._setTrajectories(),this._setCurrentCamera()}getCenter(){return null!=this._currentImage?this.currentTransform.projectBasic(this._camera.lookat.toArray()):[.5,.5]}setTransitionMode(t){this._transitionMode=t}_getAlpha(){return 1}_setCurrent(){this._setCurrentImage(),this._setReference(this._currentImage)&&this._setTrajectories(),this._setCurrentCamera()}_setCurrentCamera(){this._currentCamera=this._trajectoryCameras[this._currentIndex].clone(),this._previousCamera=this._currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}_motionlessTransition(){return null!=this._currentImage&&null!=this._previousImage&&(this._transitionMode===t.TransitionMode.Instantaneous||!(this._currentImage.merged&&this._previousImage.merged&&this._withinOriginalDistance()&&this._sameConnectedComponent()))}_setReference(t){return!(Math.abs(t.lngLat.lat-this.reference.lat)<this._referenceThreshold&&Math.abs(t.lngLat.lng-this.reference.lng)<this._referenceThreshold)&&(!(null!=this._previousImage&&!this._motionlessTransition())&&(this._reference.lat=t.lngLat.lat,this._reference.lng=t.lngLat.lng,this._reference.alt=t.computedAltitude,!0))}_setCurrentImage(){this._currentImage=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousImage=this._currentIndex>0?this._trajectory[this._currentIndex-1]:null}_setTrajectory(t){if(t.length<1)throw new hd("Trajectory can not be empty");null!=this._currentImage?(this._trajectory=[this._currentImage].concat(t),this._currentIndex=1):(this._trajectory=t.slice(),this._currentIndex=0)}_setTrajectories(){this._trajectoryTransforms.length=0,this._trajectoryCameras.length=0,this._appendToTrajectories(this._trajectory)}_appendToTrajectories(t){for(let e of t){if(!e.assetsCached)throw new hd("Assets must be cached when image is added to trajectory");let t=this._imageToTranslation(e,this.reference),i=new Hd(e.exifOrientation,e.width,e.height,e.scale,e.rotation,t,e.image,void 0,e.cameraParameters,e.cameraType);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new jd(i))}}_prependToTrajectories(t){for(let e of t.reverse()){if(!e.assetsCached)throw new hd("Assets must be cached when added to trajectory");let t=this._imageToTranslation(e,this.reference),i=new Hd(e.exifOrientation,e.width,e.height,e.scale,e.rotation,t,e.image,void 0,e.cameraParameters,e.cameraType);this._trajectoryTransforms.unshift(i),this._trajectoryCameras.unshift(new jd(i))}}_imageToTranslation(t,e){return fd({alt:t.computedAltitude,lat:t.lngLat.lat,lng:t.lngLat.lng},t.rotation,e)}_sameConnectedComponent(){let t=this._currentImage,e=this._previousImage;return!!t&&!!e&&t.mergeId===e.mergeId}_withinOriginalDistance(){let t=this._currentImage,e=this._previousImage;return!t||!e||this._spatial.distanceFromLngLat(t.originalLngLat.lng,t.originalLngLat.lat,e.originalLngLat.lng,e.originalLngLat.lat)<25}}class Vd{constructor(t,e){this._phi=t,this._theta=e}get phi(){return this._phi}set phi(t){this._phi=t}get theta(){return this._theta}set theta(t){this._theta=t}get isZero(){return 0===this._phi&&0===this._theta}copy(t){this._phi=t.phi,this._theta=t.theta}lerp(t,e){this._phi=(1-e)*this._phi+e*t.phi,this._theta=(1-e)*this._theta+e*t.theta}multiply(t){this._phi*=t,this._theta*=t}threshold(t){this._phi=Math.abs(this._phi)>t?this._phi:0,this._theta=Math.abs(this._theta)>t?this._theta:0}lengthSquared(){return this._phi*this._phi+this._theta*this._theta}reset(){this._phi=0,this._theta=0}}class Gd extends Ud{constructor(t){super(t),this._animationSpeed=1/40,this._rotationDelta=new Vd(0,0),this._requestedRotationDelta=null,this._basicRotation=[0,0],this._requestedBasicRotation=null,this._requestedBasicRotationUnbounded=null,this._rotationAcceleration=.86,this._rotationIncreaseAlpha=.97,this._rotationDecreaseAlpha=.9,this._rotationThreshold=.001,this._unboundedRotationAlpha=.8,this._desiredZoom=t.zoom,this._minZoom=0,this._maxZoom=3,this._lookatDepth=10,this._desiredLookat=null,this._desiredCenter=null}rotate(t){null!=this._currentImage&&(0===t.phi&&0===t.theta||(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedBasicRotation=null,null!=this._requestedRotationDelta?(this._requestedRotationDelta.phi=this._requestedRotationDelta.phi+t.phi,this._requestedRotationDelta.theta=this._requestedRotationDelta.theta+t.theta):this._requestedRotationDelta=new Vd(t.phi,t.theta)))}rotateUnbounded(t){if(null==this._currentImage)return;if(this._requestedBasicRotation=null,this._requestedRotationDelta=null,this._applyRotation(t,this._currentCamera),this._applyRotation(t,this._previousCamera),!this._desiredLookat)return;const e=(new pn).setFromUnitVectors(this._currentCamera.up,new fn(0,0,1)),i=e.clone().invert(),n=(new fn).copy(this._desiredLookat).sub(this._camera.position).applyQuaternion(e),r=n.length();let s=Math.atan2(n.y,n.x);s+=t.phi;let o=Math.atan2(Math.sqrt(n.x*n.x+n.y*n.y),n.z);o+=t.theta,o=Math.max(.1,Math.min(Math.PI-.1,o)),n.x=Math.sin(o)*Math.cos(s),n.y=Math.sin(o)*Math.sin(s),n.z=Math.cos(o),n.applyQuaternion(i),this._desiredLookat.copy(this._camera.position).add(n.multiplyScalar(r))}rotateWithoutInertia(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedBasicRotation=null,this._requestedRotationDelta=null;const e=Math.PI/(10*Math.pow(2,this._zoom)),i={phi:this._spatial.clamp(t.phi,-e,e),theta:this._spatial.clamp(t.theta,-e,e)};this._applyRotation(i,this._currentCamera),this._applyRotation(i,this._previousCamera)}rotateBasic(t){if(null!=this._currentImage)if(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,null!=this._requestedBasicRotation){this._requestedBasicRotation[0]+=t[0],this._requestedBasicRotation[1]+=t[1];let e=.05/Math.pow(2,this._zoom);this._requestedBasicRotation[0]=this._spatial.clamp(this._requestedBasicRotation[0],-e,e),this._requestedBasicRotation[1]=this._spatial.clamp(this._requestedBasicRotation[1],-e,e)}else this._requestedBasicRotation=t.slice()}rotateBasicUnbounded(t){null!=this._currentImage&&(null!=this._requestedBasicRotationUnbounded?(this._requestedBasicRotationUnbounded[0]+=t[0],this._requestedBasicRotationUnbounded[1]+=t[1]):this._requestedBasicRotationUnbounded=t.slice())}rotateBasicWithoutInertia(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null;const e=.05/Math.pow(2,this._zoom),i=t.slice();i[0]=this._spatial.clamp(i[0],-e,e),i[1]=this._spatial.clamp(i[1],-e,e),this._applyRotationBasic(i)}rotateToBasic(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,t[0]=this._spatial.clamp(t[0],0,1),t[1]=this._spatial.clamp(t[1],0,1);let e=this.currentTransform.unprojectBasic(t,this._lookatDepth);this._currentCamera.lookat.fromArray(e)}zoomIn(t,e){if(null==this._currentImage)return;this._desiredZoom=Math.max(this._minZoom,Math.min(this._maxZoom,this._desiredZoom+t));let i=this.currentTransform.projectBasic(this._currentCamera.lookat.toArray()),n=i[0],r=i[1],s=Math.pow(2,this._zoom),o=Math.pow(2,this._desiredZoom),a=e[0],c=e[1];dd(this.currentTransform.cameraType)&&(a-n>.5?a-=1:n-a>.5&&(a=1+a));let h=a-s/o*(a-n),l=c-s/o*(c-r);dd(this._currentImage.cameraType)?(h=this._spatial.wrap(h+this._basicRotation[0],0,1),l=this._spatial.clamp(l+this._basicRotation[1],.05,.95)):(h=this._spatial.clamp(h,0,1),l=this._spatial.clamp(l,0,1)),this._desiredLookat=(new fn).fromArray(this.currentTransform.unprojectBasic([h,l],this._lookatDepth))}setCenter(t){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._desiredZoom=this._zoom;let e=[this._spatial.clamp(t[0],0,1),this._spatial.clamp(t[1],0,1)];if(null==this._currentImage)return void(this._desiredCenter=e);this._desiredCenter=null;let i=(new fn).fromArray(this.currentTransform.unprojectBasic(e,this._lookatDepth)),n=null!=this.previousTransform?this.previousTransform:this.currentTransform,r=(new fn).fromArray(n.unprojectBasic(e,this._lookatDepth));this._currentCamera.lookat.copy(i),this._previousCamera.lookat.copy(r)}setZoom(t){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._zoom=this._spatial.clamp(t,this._minZoom,this._maxZoom),this._desiredZoom=this._zoom}_applyRotation(t,e){if(null==e)return;let i=(new pn).setFromUnitVectors(e.up,new fn(0,0,1)),n=i.clone().invert(),r=new fn;r.copy(e.lookat).sub(e.position),r.applyQuaternion(i);let s=r.length(),o=Math.atan2(r.y,r.x);o+=t.phi;let a=Math.atan2(Math.sqrt(r.x*r.x+r.y*r.y),r.z);a+=t.theta,a=Math.max(.1,Math.min(Math.PI-.1,a)),r.x=Math.sin(a)*Math.cos(o),r.y=Math.sin(a)*Math.sin(o),r.z=Math.cos(a),r.applyQuaternion(n),e.lookat.copy(e.position).add(r.multiplyScalar(s))}_applyRotationBasic(t){let e=this._currentImage,i=null!=this._previousImage?this.previousImage:this.currentImage,n=this._currentCamera,r=this._previousCamera,s=this.currentTransform,o=null!=this.previousTransform?this.previousTransform:this.currentTransform,a=s.projectBasic(n.lookat.toArray()),c=o.projectBasic(r.lookat.toArray());dd(e.cameraType)?(a[0]=this._spatial.wrap(a[0]+t[0],0,1),a[1]=this._spatial.clamp(a[1]+t[1],.05,.95)):(a[0]=this._spatial.clamp(a[0]+t[0],0,1),a[1]=this._spatial.clamp(a[1]+t[1],0,1)),dd(i.cameraType)?(c[0]=this._spatial.wrap(c[0]+t[0],0,1),c[1]=this._spatial.clamp(c[1]+t[1],.05,.95)):(c[0]=this._spatial.clamp(c[0]+t[0],0,1),c[1]=this._spatial.clamp(a[1]+t[1],0,1));let h=s.unprojectBasic(a,this._lookatDepth);n.lookat.fromArray(h);let l=o.unprojectBasic(c,this._lookatDepth);r.lookat.fromArray(l)}_updateZoom(t){let e=this._desiredZoom-this._zoom,i=e>0?1:e<0?-1:0;0!==e&&(Math.abs(e)<.002?(this._zoom=this._desiredZoom,null!=this._desiredLookat&&(this._desiredLookat=null)):this._zoom+=i*Math.max(Math.abs(5*t*e),.002))}_updateLookat(t){if(null===this._desiredLookat)return;let e=this._desiredLookat.distanceToSquared(this._currentCamera.lookat);Math.abs(e)<1e-6?(this._currentCamera.lookat.copy(this._desiredLookat),this._desiredLookat=null):this._currentCamera.lookat.lerp(this._desiredLookat,5*t)}_updateRotation(){if(null!=this._requestedRotationDelta){let t=this._rotationDelta.lengthSquared();return this._requestedRotationDelta.lengthSquared()>t?this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationIncreaseAlpha):this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationDecreaseAlpha),void(this._requestedRotationDelta=null)}if(this._rotationDelta.isZero)return;const t=dd(this.currentImage.cameraType)?1:this._alpha;this._rotationDelta.multiply(this._rotationAcceleration*t),this._rotationDelta.threshold(this._rotationThreshold)}_updateRotationBasic(){if(null!=this._requestedBasicRotation){let t=this._basicRotation[0],e=this._basicRotation[1],i=this._requestedBasicRotation[0],n=this._requestedBasicRotation[1];return Math.abs(i)>Math.abs(t)?this._basicRotation[0]=(1-this._rotationIncreaseAlpha)*t+this._rotationIncreaseAlpha*i:this._basicRotation[0]=(1-this._rotationDecreaseAlpha)*t+this._rotationDecreaseAlpha*i,Math.abs(n)>Math.abs(e)?this._basicRotation[1]=(1-this._rotationIncreaseAlpha)*e+this._rotationIncreaseAlpha*n:this._basicRotation[1]=(1-this._rotationDecreaseAlpha)*e+this._rotationDecreaseAlpha*n,void(this._requestedBasicRotation=null)}if(null!=this._requestedBasicRotationUnbounded){let t=this._requestedBasicRotationUnbounded[0],e=this._requestedBasicRotationUnbounded[1];if(Math.abs(t)>0&&(this._basicRotation[0]=(1-this._unboundedRotationAlpha)*this._basicRotation[0]+this._unboundedRotationAlpha*t),Math.abs(e)>0&&(this._basicRotation[1]=(1-this._unboundedRotationAlpha)*this._basicRotation[1]+this._unboundedRotationAlpha*e),null!=this._desiredLookat){let i=this.currentTransform.projectBasic(this._desiredLookat.toArray());i[0]+=t,i[1]+=e,this._desiredLookat=(new fn).fromArray(this.currentTransform.unprojectBasic(i,this._lookatDepth))}this._requestedBasicRotationUnbounded=null}0===this._basicRotation[0]&&0===this._basicRotation[1]||(this._basicRotation[0]=this._rotationAcceleration*this._basicRotation[0],this._basicRotation[1]=this._rotationAcceleration*this._basicRotation[1],Math.abs(this._basicRotation[0])<this._rotationThreshold/Math.pow(2,this._zoom)&&Math.abs(this._basicRotation[1])<this._rotationThreshold/Math.pow(2,this._zoom)&&(this._basicRotation=[0,0]))}_clearRotation(){dd(this._currentImage.cameraType)||(null!=this._requestedRotationDelta&&(this._requestedRotationDelta=null),this._rotationDelta.isZero||this._rotationDelta.reset(),null!=this._requestedBasicRotation&&(this._requestedBasicRotation=null),(this._basicRotation[0]>0||this._basicRotation[1]>0)&&(this._basicRotation=[0,0]))}_setDesiredCenter(){if(null==this._desiredCenter)return;let t=(new fn).fromArray(this.currentTransform.unprojectBasic(this._desiredCenter,this._lookatDepth)).sub(this._currentCamera.position);this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(t)),this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(t)),this._desiredCenter=null}_setDesiredZoom(){this._desiredZoom=dd(this._currentImage.cameraType)||null==this._previousImage?this._zoom:0}}class qd extends Gd{constructor(t){super(t),this._adjustCameras(),this._motionless=this._motionlessTransition(),this._baseAlpha=this._alpha,this._speedCoefficient=1,this._unitBezier=new qd._interpolator(.74,.67,.38,.96),this._useBezier=!1}static register(t){qd._interpolator=t}append(t){let e=0===this._trajectory.length;e&&this._resetTransition(),super.append(t),e&&(this._setDesiredCenter(),this._setDesiredZoom())}prepend(t){let e=0===this._trajectory.length;e&&this._resetTransition(),super.prepend(t),e&&(this._setDesiredCenter(),this._setDesiredZoom())}set(t){super.set(t),this._desiredLookat=null,this._resetTransition(),this._clearRotation(),this._setDesiredCenter(),this._setDesiredZoom(),this._trajectory.length<3&&(this._useBezier=!0)}setSpeed(t){this._speedCoefficient=this._spatial.clamp(t,0,10)}update(t){1===this._alpha&&this._currentIndex+this._alpha<this._trajectory.length&&(this._currentIndex+=1,this._useBezier=this._trajectory.length<3&&this._currentIndex+1===this._trajectory.length,this._setCurrent(),this._resetTransition(),this._clearRotation(),this._desiredZoom=dd(this._currentImage.cameraType)?this._zoom:0,this._desiredLookat=null);let e=this._animationSpeed*(60/t);this._baseAlpha=Math.min(1,this._baseAlpha+this._speedCoefficient*e),this._useBezier?this._alpha=this._unitBezier.solve(this._baseAlpha):this._alpha=this._baseAlpha,this._updateRotation(),this._rotationDelta.isZero||(this._applyRotation(this._rotationDelta,this._previousCamera),this._applyRotation(this._rotationDelta,this._currentCamera)),this._updateRotationBasic(),0===this._basicRotation[0]&&0===this._basicRotation[1]||this._applyRotationBasic(this._basicRotation),this._updateZoom(e),this._updateLookat(e),this._camera.lerpCameras(this._previousCamera,this._currentCamera,this.alpha)}_getAlpha(){return this._motionless?Math.ceil(this._alpha):this._alpha}_setCurrentCamera(){super._setCurrentCamera(),this._adjustCameras()}_adjustCameras(){if(null==this._previousImage)return;let t=this._camera.lookat.clone().sub(this._camera.position);this._previousCamera.lookat.copy(t.clone().add(this._previousCamera.position)),dd(this._currentImage.cameraType)&&this._currentCamera.lookat.copy(t.clone().add(this._currentCamera.position))}_resetTransition(){this._alpha=0,this._baseAlpha=0,this._motionless=this._motionlessTransition()}}class Wd{constructor(t,e){this._components={};for(const i in Wd.registeredComponents){if(!Wd.registeredComponents.hasOwnProperty(i))continue;const n=Wd.registeredComponents[i];this._components[i]={active:!1,component:new n(i,t,e)}}this._coverComponent=new Wd.registeredCoverComponent("cover",t,e),this._coverComponent.activate(),this._coverActivated=!0}static register(t){void 0===Wd.registeredComponents[t.componentName]&&(Wd.registeredComponents[t.componentName]=t)}static registerCover(t){Wd.registeredCoverComponent=t}get coverActivated(){return this._coverActivated}activateCover(){if(!this._coverActivated){this._coverActivated=!0;for(const t in this._components){if(!this._components.hasOwnProperty(t))continue;const e=this._components[t];e.active&&e.component.deactivate()}}}deactivateCover(){if(this._coverActivated){this._coverActivated=!1;for(const t in this._components){if(!this._components.hasOwnProperty(t))continue;const e=this._components[t];e.active&&e.component.activate()}}}activate(t){this._checkName(t),this._components[t].active=!0,this._coverActivated||this.get(t).activate()}configure(t,e){this._checkName(t),this.get(t).configure(e)}deactivate(t){this._checkName(t),this._components[t].active=!1,this._coverActivated||this.get(t).deactivate()}get(t){return this._components[t].component}getCover(){return this._coverComponent}remove(){this._coverComponent.deactivate();for(const t in this._components)this._components.hasOwnProperty(t)&&this._components[t].component.deactivate()}_checkName(t){if(!(t in this._components))throw new hd(`Component does not exist: ${t}`)}}Wd.registeredComponents={};var Xd=Array.isArray,Yd=Object.prototype.toString,Zd=Xd||function(t){return"[object Array]"===Yd.call(t)};var Jd="2";Qd.NONE=0,Qd.VTEXT=1,Qd.VNODE=2,Qd.WIDGET=3,Qd.PROPS=4,Qd.ORDER=5,Qd.INSERT=6,Qd.REMOVE=7,Qd.THUNK=8;var Kd=Qd;function Qd(t,e,i){this.type=Number(t),this.vNode=e,this.patch=i}Qd.prototype.version=Jd,Qd.prototype.type="VirtualPatch";var tp=function(t){return t&&"VirtualNode"===t.type&&t.version===Jd};var ep=function(t){return t&&"VirtualText"===t.type&&t.version===Jd};var ip=function(t){return t&&"Widget"===t.type};var np=function(t){return t&&"Thunk"===t.type};var rp=function(t,e){var i=t,n=e;np(e)&&(n=sp(e,t));np(t)&&(i=sp(t,null));return{a:i,b:n}};function sp(t,e){var i=t.vnode;if(i||(i=t.vnode=t.render(e)),!(tp(i)||ep(i)||ip(i)))throw new Error("thunk did not return a valid node");return i}var op=function(t){return"object"==typeof t&&null!==t},ap=function(t){return t&&("function"==typeof t.hook&&!t.hasOwnProperty("hook")||"function"==typeof t.unhook&&!t.hasOwnProperty("unhook"))};var cp=function t(e,i){var n;for(var r in e){r in i||((n=n||{})[r]=void 0);var s=e[r],o=i[r];if(s!==o)if(op(s)&&op(o))if(hp(o)!==hp(s))(n=n||{})[r]=o;else if(ap(o))(n=n||{})[r]=o;else{var a=t(s,o);a&&((n=n||{})[r]=a)}else(n=n||{})[r]=o}for(var c in i)c in e||((n=n||{})[c]=i[c]);return n};function hp(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__?t.__proto__:t.constructor?t.constructor.prototype:void 0}function lp(t,e){var i={a:t};return up(t,e,i,0),i}function up(t,e,i,n){if(t!==e){var r=i[n],s=!1;if(np(t)||np(e))fp(t,e,i,n);else if(null==e)ip(t)||(dp(t,i,n),r=i[n]),r=vp(r,new Kd(Kd.REMOVE,t,e));else if(tp(e))if(tp(t))if(t.tagName===e.tagName&&t.namespace===e.namespace&&t.key===e.key){var o=cp(t.properties,e.properties);o&&(r=vp(r,new Kd(Kd.PROPS,t,o))),r=function(t,e,i,n,r){for(var s=t.children,o=function(t,e){var i=_p(e),n=i.keys,r=i.free;if(r.length===e.length)return{children:e,moves:null};var s=_p(t),o=s.keys;if(s.free.length===t.length)return{children:e,moves:null};for(var a=[],c=0,h=r.length,l=0,u=0;u<t.length;u++){var d,p=t[u];p.key?n.hasOwnProperty(p.key)?(d=n[p.key],a.push(e[d])):(d=u-l++,a.push(null)):c<h?(d=r[c++],a.push(e[d])):(d=u-l++,a.push(null))}for(var f=c>=r.length?e.length:r[c],m=0;m<e.length;m++){var g=e[m];g.key?o.hasOwnProperty(g.key)||a.push(g):m>=f&&a.push(g)}for(var _,v=a.slice(),y=0,b=[],x=[],w=0;w<e.length;){var S=e[w];for(_=v[y];null===_&&v.length;)b.push(gp(v,y,null)),_=v[y];_&&_.key===S.key?(y++,w++):S.key?(_&&_.key&&n[_.key]!==w+1?(b.push(gp(v,y,_.key)),(_=v[y])&&_.key===S.key?y++:x.push({key:S.key,to:w})):x.push({key:S.key,to:w}),w++):_&&_.key&&b.push(gp(v,y,_.key))}for(;y<v.length;)_=v[y],b.push(gp(v,y,_&&_.key));if(b.length===l&&!x.length)return{children:a,moves:null};return{children:a,moves:{removes:b,inserts:x}}}(s,e.children),a=o.children,c=s.length,h=a.length,l=c>h?c:h,u=0;u<l;u++){var d=s[u],p=a[u];r+=1,d?up(d,p,i,r):p&&(n=vp(n,new Kd(Kd.INSERT,null,p))),tp(d)&&d.count&&(r+=d.count)}o.moves&&(n=vp(n,new Kd(Kd.ORDER,t,o.moves)));return n}(t,e,i,r,n)}else r=vp(r,new Kd(Kd.VNODE,t,e)),s=!0;else r=vp(r,new Kd(Kd.VNODE,t,e)),s=!0;else ep(e)?ep(t)?t.text!==e.text&&(r=vp(r,new Kd(Kd.VTEXT,t,e))):(r=vp(r,new Kd(Kd.VTEXT,t,e)),s=!0):ip(e)&&(ip(t)||(s=!0),r=vp(r,new Kd(Kd.WIDGET,t,e)));r&&(i[n]=r),s&&dp(t,i,n)}}function dp(t,e,i){mp(t,e,i),pp(t,e,i)}function pp(t,e,i){if(ip(t))"function"==typeof t.destroy&&(e[i]=vp(e[i],new Kd(Kd.REMOVE,t,null)));else if(tp(t)&&(t.hasWidgets||t.hasThunks))for(var n=t.children,r=n.length,s=0;s<r;s++){var o=n[s];pp(o,e,i+=1),tp(o)&&o.count&&(i+=o.count)}else np(t)&&fp(t,null,e,i)}function fp(t,e,i,n){var r=rp(t,e),s=lp(r.a,r.b);(function(t){for(var e in t)if("a"!==e)return!0;return!1})(s)&&(i[n]=new Kd(Kd.THUNK,null,s))}function mp(t,e,i){if(tp(t)){if(t.hooks&&(e[i]=vp(e[i],new Kd(Kd.PROPS,t,function(t){var e={};for(var i in t)e[i]=void 0;return e}(t.hooks)))),t.descendantHooks||t.hasThunks)for(var n=t.children,r=n.length,s=0;s<r;s++){var o=n[s];mp(o,e,i+=1),tp(o)&&o.count&&(i+=o.count)}}else np(t)&&fp(t,null,e,i)}function gp(t,e,i){return t.splice(e,1),{from:e,key:i}}function _p(t){for(var e={},i=[],n=t.length,r=0;r<n;r++){var s=t[r];s.key?e[s.key]=r:i.push(r)}return{keys:e,free:i}}function vp(t,e){return t?(Zd(t)?t.push(e):t=[t,e],t):e}var yp=lp,bp="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function xp(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})})),e}function wp(t){var e={exports:{}};return t(e,e.exports),e.exports}var Sp=Array.prototype.slice,Mp=function(t,e){"length"in t||(t=[t]);t=Sp.call(t);for(;t.length;){var i=t.shift(),n=e(i);if(n)return n;i.childNodes&&i.childNodes.length&&(t=Sp.call(i.childNodes).concat(t))}};var Tp=Cp;function Cp(t,e){if(!(this instanceof Cp))return new Cp(t,e);this.data=t,this.nodeValue=t,this.length=t.length,this.ownerDocument=e||null}Cp.prototype.nodeType=8,Cp.prototype.nodeName="#comment",Cp.prototype.toString=function(){return"[object Comment]"};var Ep=Ip;function Ip(t,e){if(!(this instanceof Ip))return new Ip(t);this.data=t||"",this.length=this.data.length,this.ownerDocument=e||null}Ip.prototype.type="DOMTextNode",Ip.prototype.nodeType=3,Ip.prototype.nodeName="#text",Ip.prototype.toString=function(){return this.data},Ip.prototype.replaceData=function(t,e,i){var n=this.data,r=n.substring(0,t),s=n.substring(t+e,n.length);this.data=r+i+s,this.length=this.data.length};var Ap=function(t){var e=this,i=t.type;t.target||(t.target=e);e.listeners||(e.listeners={});var n=e.listeners[i];if(n)return n.forEach((function(i){t.currentTarget=e,"function"==typeof i?i(t):i.handleEvent(t)}));e.parentNode&&e.parentNode.dispatchEvent(t)};var Pp=function(t,e){var i=this;i.listeners||(i.listeners={});i.listeners[t]||(i.listeners[t]=[]);-1===i.listeners[t].indexOf(e)&&i.listeners[t].push(e)};var Rp=function(t,e){var i=this;if(!i.listeners)return;if(!i.listeners[t])return;var n=i.listeners[t],r=n.indexOf(e);-1!==r&&n.splice(r,1)};var Lp=Np,Op=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function Np(t){switch(t.nodeType){case 3:return kp(t.data);case 8:return"\x3c!--"+t.data+"--\x3e";default:return function(t){var e=[],i=t.tagName;"http://www.w3.org/1999/xhtml"===t.namespaceURI&&(i=i.toLowerCase());e.push("<"+i+function(t){var e=[];for(var i in t)Dp(t,i)&&e.push({name:i,value:t[i]});for(var n in t._attributes)for(var r in t._attributes[n]){var s=t._attributes[n][r],o=(s.prefix?s.prefix+":":"")+r;e.push({name:o,value:s.value})}t.className&&e.push({name:"class",value:t.className});return e.length?$p(e):""}(t)+function(t){var e=t.dataset,i=[];for(var n in e)i.push({name:"data-"+n,value:e[n]});return i.length?$p(i):""}(t)),Op.indexOf(i)>-1?e.push(" />"):(e.push(">"),t.childNodes.length?e.push.apply(e,t.childNodes.map(Np)):t.textContent||t.innerText?e.push(kp(t.textContent||t.innerText)):t.innerHTML&&e.push(t.innerHTML),e.push("</"+i+">"));return e.join("")}(t)}}function Dp(t,e){var i=typeof t[e];return"style"===e&&Object.keys(t.style).length>0||t.hasOwnProperty(e)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==e&&"className"!==e&&"tagName"!==e&&"textContent"!==e&&"innerText"!==e&&"namespaceURI"!==e&&"innerHTML"!==e}function $p(t){var e=[];return t.forEach((function(t){var i=t.name,n=t.value;"style"===i&&(n=function(t){if("string"==typeof t)return t;var e="";return Object.keys(t).forEach((function(i){var n=t[i];i=i.replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()})),e+=i+":"+n+";"})),e}(n)),e.push(i+'="'+(kp(n).replace(/"/g,""")+'"'))})),e.length?" "+e.join(" "):""}function kp(t){var e="";return"string"==typeof t?e=t:t&&(e=t.toString()),e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var zp="http://www.w3.org/1999/xhtml",Fp=Bp;function Bp(t,e,i){if(!(this instanceof Bp))return new Bp(t);var n=void 0===i?zp:i||null;this.tagName=n===zp?String(t).toUpperCase():t,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=e||null,this.namespaceURI=n,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}Bp.prototype.type="DOMElement",Bp.prototype.nodeType=1,Bp.prototype.appendChild=function(t){return t.parentNode&&t.parentNode.removeChild(t),this.childNodes.push(t),t.parentNode=this,t},Bp.prototype.replaceChild=function(t,e){t.parentNode&&t.parentNode.removeChild(t);var i=this.childNodes.indexOf(e);return e.parentNode=null,this.childNodes[i]=t,t.parentNode=this,e},Bp.prototype.removeChild=function(t){var e=this.childNodes.indexOf(t);return this.childNodes.splice(e,1),t.parentNode=null,t},Bp.prototype.insertBefore=function(t,e){t.parentNode&&t.parentNode.removeChild(t);var i=null==e?-1:this.childNodes.indexOf(e);return i>-1?this.childNodes.splice(i,0,t):this.childNodes.push(t),t.parentNode=this,t},Bp.prototype.setAttributeNS=function(t,e,i){var n=null,r=e,s=e.indexOf(":");(s>-1&&(n=e.substr(0,s),r=e.substr(s+1)),"INPUT"===this.tagName&&"type"===e)?this.type=i:(this._attributes[t]||(this._attributes[t]={}))[r]={value:i,prefix:n}},Bp.prototype.getAttributeNS=function(t,e){var i=this._attributes[t],n=i&&i[e]&&i[e].value;return"INPUT"===this.tagName&&"type"===e?this.type:"string"!=typeof n?null:n},Bp.prototype.removeAttributeNS=function(t,e){var i=this._attributes[t];i&&delete i[e]},Bp.prototype.hasAttributeNS=function(t,e){var i=this._attributes[t];return!!i&&e in i},Bp.prototype.setAttribute=function(t,e){return this.setAttributeNS(null,t,e)},Bp.prototype.getAttribute=function(t){return this.getAttributeNS(null,t)},Bp.prototype.removeAttribute=function(t){return this.removeAttributeNS(null,t)},Bp.prototype.hasAttribute=function(t){return this.hasAttributeNS(null,t)},Bp.prototype.removeEventListener=Rp,Bp.prototype.addEventListener=Pp,Bp.prototype.dispatchEvent=Ap,Bp.prototype.focus=function(){},Bp.prototype.toString=function(){return Lp(this)},Bp.prototype.getElementsByClassName=function(t){var e=t.split(" "),i=[];return Mp(this,(function(t){if(1===t.nodeType){var n=(t.className||"").split(" ");e.every((function(t){return-1!==n.indexOf(t)}))&&i.push(t)}})),i},Bp.prototype.getElementsByTagName=function(t){t=t.toLowerCase();var e=[];return Mp(this.childNodes,(function(i){1!==i.nodeType||"*"!==t&&i.tagName.toLowerCase()!==t||e.push(i)})),e},Bp.prototype.contains=function(t){return Mp(this,(function(e){return t===e}))||!1};var jp=Hp;function Hp(t){if(!(this instanceof Hp))return new Hp;this.childNodes=[],this.parentNode=null,this.ownerDocument=t||null}Hp.prototype.type="DocumentFragment",Hp.prototype.nodeType=11,Hp.prototype.nodeName="#document-fragment",Hp.prototype.appendChild=Fp.prototype.appendChild,Hp.prototype.replaceChild=Fp.prototype.replaceChild,Hp.prototype.removeChild=Fp.prototype.removeChild,Hp.prototype.toString=function(){return this.childNodes.map((function(t){return String(t)})).join("")};var Up=Vp;function Vp(t){}Vp.prototype.initEvent=function(t,e,i){this.type=t,this.bubbles=e,this.cancelable=i},Vp.prototype.preventDefault=function(){};var Gp=qp;function qp(){if(!(this instanceof qp))return new qp;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Wp=qp.prototype;Wp.createTextNode=function(t){return new Ep(t,this)},Wp.createElementNS=function(t,e){var i=null===t?null:String(t);return new Fp(e,this,i)},Wp.createElement=function(t){return new Fp(t,this)},Wp.createDocumentFragment=function(){return new jp(this)},Wp.createEvent=function(t){return new Up(t)},Wp.createComment=function(t){return new Tp(t,this)},Wp.getElementById=function(t){return t=String(t),Mp(this.childNodes,(function(e){if(String(e.id)===t)return e}))||null},Wp.getElementsByClassName=Fp.prototype.getElementsByClassName,Wp.getElementsByTagName=Fp.prototype.getElementsByTagName,Wp.contains=Fp.prototype.contains,Wp.removeEventListener=Rp,Wp.addEventListener=Pp,Wp.dispatchEvent=Ap;var Xp,Yp=new Gp,Zp=void 0!==bp?bp:"undefined"!=typeof window?window:{};"undefined"!=typeof document?Xp=document:(Xp=Zp["__GLOBAL_DOCUMENT_CACHE@4"])||(Xp=Zp["__GLOBAL_DOCUMENT_CACHE@4"]=Yp);var Jp=Xp,Kp=function(t,e,i){for(var n in e){var r=e[n];void 0===r?Qp(t,n,r,i):ap(r)?(Qp(t,n,r,i),r.hook&&r.hook(t,n,i?i[n]:void 0)):op(r)?tf(t,e,i,n,r):t[n]=r}};function Qp(t,e,i,n){if(n){var r=n[e];if(ap(r))r.unhook&&r.unhook(t,e,i);else if("attributes"===e)for(var s in r)t.removeAttribute(s);else if("style"===e)for(var o in r)t.style[o]="";else t[e]="string"==typeof r?"":null}}function tf(t,e,i,n,r){var s=i?i[n]:void 0;if("attributes"!==n)if(s&&op(s)&&ef(s)!==ef(r))t[n]=r;else{op(t[n])||(t[n]={});var o="style"===n?"":void 0;for(var a in r){var c=r[a];t[n][a]=void 0===c?o:c}}else for(var h in r){var l=r[h];void 0===l?t.removeAttribute(h):t.setAttribute(h,l)}}function ef(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__?t.__proto__:t.constructor?t.constructor.prototype:void 0}var nf=function t(e,i){var n=i&&i.document||Jp,r=i?i.warn:null;if(e=rp(e).a,ip(e))return e.init();if(ep(e))return n.createTextNode(e.text);if(!tp(e))return r&&r("Item is not a valid virtual dom node",e),null;var s=null===e.namespace?n.createElement(e.tagName):n.createElementNS(e.namespace,e.tagName),o=e.properties;Kp(s,o);for(var a=e.children,c=0;c<a.length;c++){var h=t(a[c],i);h&&s.appendChild(h)}return s};var rf={},sf=function(t,e,i,n){return i&&0!==i.length?(i.sort(cf),of(t,e,i,n,0)):{}};function of(t,e,i,n,r){if(n=n||{},t){af(i,r,r)&&(n[r]=t);var s=e.children;if(s)for(var o=t.childNodes,a=0;a<e.children.length;a++){r+=1;var c=s[a]||rf,h=r+(c.count||0);af(i,r,h)&&of(o[a],c,i,n,r),r=h}}return n}function af(t,e,i){if(0===t.length)return!1;for(var n,r,s=0,o=t.length-1;s<=o;){if(r=t[n=(o+s)/2>>0],s===o)return r>=e&&r<=i;if(r<e)s=n+1;else{if(!(r>i))return!0;o=n-1}}return!1}function cf(t,e){return t>e?1:-1}var hf=function(t,e){if(ip(t)&&ip(e))return"name"in t&&"name"in e?t.id===e.id:t.init===e.init;return!1};var lf=function(t,e,i){var n=t.type,r=t.vNode,s=t.patch;switch(n){case Kd.REMOVE:return function(t,e){var i=t.parentNode;i&&i.removeChild(t);return uf(t,e),null}(e,r);case Kd.INSERT:return function(t,e,i){var n=i.render(e,i);t&&t.appendChild(n);return t}(e,s,i);case Kd.VTEXT:return function(t,e,i,n){var r;if(3===t.nodeType)t.replaceData(0,t.length,i.text),r=t;else{var s=t.parentNode;r=n.render(i,n),s&&r!==t&&s.replaceChild(r,t)}return r}(e,0,s,i);case Kd.WIDGET:return function(t,e,i,n){var r,s=hf(e,i);r=s?i.update(e,t)||t:n.render(i,n);var o=t.parentNode;o&&r!==t&&o.replaceChild(r,t);s||uf(t,e);return r}(e,r,s,i);case Kd.VNODE:return function(t,e,i,n){var r=t.parentNode,s=n.render(i,n);r&&s!==t&&r.replaceChild(s,t);return s}(e,0,s,i);case Kd.ORDER:return function(t,e){for(var i,n,r,s=t.childNodes,o={},a=0;a<e.removes.length;a++)i=s[(n=e.removes[a]).from],n.key&&(o[n.key]=i),t.removeChild(i);for(var c=s.length,h=0;h<e.inserts.length;h++)i=o[(r=e.inserts[h]).key],t.insertBefore(i,r.to>=c++?null:s[r.to])}(e,s),e;case Kd.PROPS:return Kp(e,s,r.properties),e;case Kd.THUNK:return function(t,e){t&&e&&t!==e&&t.parentNode&&t.parentNode.replaceChild(e,t);return e}(e,i.patch(e,s,i));default:return e}};function uf(t,e){"function"==typeof e.destroy&&ip(e)&&e.destroy(t)}function df(t,e,i){var n=function(t){var e=[];for(var i in t)"a"!==i&&e.push(Number(i));return e}(e);if(0===n.length)return t;var r=sf(t,e.a,n),s=t.ownerDocument;i.document||s===Jp||(i.document=s);for(var o=0;o<n.length;o++){var a=n[o];t=pf(t,r[a],e[a],i)}return t}function pf(t,e,i,n){if(!e)return t;var r;if(Zd(i))for(var s=0;s<i.length;s++)r=lf(i[s],e,n),e===t&&(t=r);else r=lf(i,e,n),e===t&&(t=r);return t}var ff=function t(e,i,n){return(n=n||{}).patch=n.patch&&n.patch!==t?n.patch:df,n.render=n.render||nf,n.patch(e,i,n)},mf=vf,gf={},_f=[];function vf(t,e,i,n,r){this.tagName=t,this.properties=e||gf,this.children=i||_f,this.key=null!=n?String(n):void 0,this.namespace="string"==typeof r?r:null;var s,o=i&&i.length||0,a=0,c=!1,h=!1,l=!1;for(var u in e)if(e.hasOwnProperty(u)){var d=e[u];ap(d)&&d.unhook&&(s||(s={}),s[u]=d)}for(var p=0;p<o;p++){var f=i[p];tp(f)?(a+=f.count||0,!c&&f.hasWidgets&&(c=!0),!h&&f.hasThunks&&(h=!0),l||!f.hooks&&!f.descendantHooks||(l=!0)):!c&&ip(f)?"function"==typeof f.destroy&&(c=!0):!h&&np(f)&&(h=!0)}this.count=o+a,this.hasWidgets=c,this.hasThunks=h,this.hooks=s,this.descendantHooks=l}vf.prototype.version=Jd,vf.prototype.type="VirtualNode";var yf=bf;function bf(t){this.text=String(t)}bf.prototype.version=Jd,bf.prototype.type="VirtualText";
22 var xf,wf,Sf,Mf=(wf=String.prototype.split,Sf=/()??/.exec("")[1]===xf,function(t,e,i){if("[object RegExp]"!==Object.prototype.toString.call(e))return wf.call(t,e,i);var n,r,s,o,a=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":""),h=0;for(e=new RegExp(e.source,c+"g"),t+="",Sf||(n=new RegExp("^"+e.source+"$(?!\\s)",c)),i=i===xf?-1>>>0:i>>>0;(r=e.exec(t))&&!((s=r.index+r[0].length)>h&&(a.push(t.slice(h,r.index)),!Sf&&r.length>1&&r[0].replace(n,(function(){for(var t=1;t<arguments.length-2;t++)arguments[t]===xf&&(r[t]=xf)})),r.length>1&&r.index<t.length&&Array.prototype.push.apply(a,r.slice(1)),o=r[0].length,h=s,a.length>=i));)e.lastIndex===r.index&&e.lastIndex++;return h===t.length?!o&&e.test("")||a.push(""):a.push(t.slice(h)),a.length>i?a.slice(0,i):a}),Tf=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/,Cf=/^\.|#/,Ef=function(t,e){if(!t)return"DIV";var i,n,r,s,o=!e.hasOwnProperty("id"),a=Mf(t,Tf),c=null;Cf.test(a[1])&&(c="DIV");for(s=0;s<a.length;s++)(n=a[s])&&(r=n.charAt(0),c?"."===r?(i=i||[]).push(n.substring(1,n.length)):"#"===r&&o&&(e.id=n.substring(1,n.length)):c=n);i&&(e.className&&i.push(e.className),e.className=i.join(" "));return e.namespace?c:c.toUpperCase()};var If=Af;function Af(t){if(!(this instanceof Af))return new Af(t);this.value=t}Af.prototype.hook=function(t,e){t[e]!==this.value&&(t[e]=this.value)};var Pf="undefined"!=typeof window?window:void 0!==bp?bp:{},Rf=function(t,e){if(t in Pf)return Pf[t];return Pf[t]=e,e};(function(t,e,i){var n="__INDIVIDUAL_ONE_VERSION_"+t,r=Rf(n+"_ENFORCE_SINGLETON",e);if(r!==e)throw new Error("Can only have one copy of "+t+".\nYou already have version "+r+" installed.\nThis means you cannot install version "+e);Rf(n,i)})("ev-store","7");var Lf="__EV_STORE_KEY@7",Of=function(t){var e=t[Lf];e||(e=t[Lf]={});return e};var Nf=Df;function Df(t){if(!(this instanceof Df))return new Df(t);this.value=t}function $f(t,e,i,n){if("string"==typeof t)e.push(new yf(t));else if("number"==typeof t)e.push(new yf(String(t)));else if(kf(t))e.push(t);else{if(!Zd(t)){if(null==t)return;throw function(t){var e=new Error;return e.type="virtual-hyperscript.unexpected.virtual-element",e.message="Unexpected virtual child passed to h().\nExpected a VNode / Vthunk / VWidget / string but:\ngot:\n"+zf(t.foreignObject)+".\nThe parent vnode is:\n"+zf(t.parentVnode),e.foreignObject=t.foreignObject,e.parentVnode=t.parentVnode,e}({foreignObject:t,parentVnode:{tagName:i,properties:n}})}for(var r=0;r<t.length;r++)$f(t[r],e,i,n)}}function kf(t){return tp(t)||ep(t)||ip(t)||np(t)}function zf(t){try{return JSON.stringify(t,null," ")}catch(e){return String(t)}}Df.prototype.hook=function(t,e){Of(t)[e.substr(3)]=this.value},Df.prototype.unhook=function(t,e){Of(t)[e.substr(3)]=void 0};var Ff,Bf,jf={diff:yp,patch:ff,h:function(t,e,i){var n,r,s,o,a=[];!i&&(c=e,"string"==typeof c||Zd(c)||kf(c))&&(i=e,r={});var c;n=Ef(t,r=r||e||{}),r.hasOwnProperty("key")&&(s=r.key,r.key=void 0);r.hasOwnProperty("namespace")&&(o=r.namespace,r.namespace=void 0);"INPUT"!==n||o||!r.hasOwnProperty("value")||void 0===r.value||ap(r.value)||(r.value=If(r.value));(function(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];if(ap(i))continue;"ev-"===e.substr(0,3)&&(t[e]=Nf(i))}})(r),null!=i&&$f(i,a,n,r);return new mf(n,r,a,s,o)},create:nf,VNode:mf,VText:yf};class Hf{constructor(){this._events={}}on(t,e){this._events[t]=this._events[t]||[],this._events[t].push(e)}off(t,e){if(t){if(this._listens(t)){const i=this._events[t].indexOf(e);i>=0&&this._events[t].splice(i,1),this._events[t].length||delete this._events[t]}}else this._events={}}fire(t,e){if(this._listens(t))for(const i of this._events[t])i(e)}_listens(t){return t in this._events}}class Uf{constructor(){this._subscriptions=[]}push(t){this._subscriptions.push(t)}unsubscribe(){for(const t of this._subscriptions)t.unsubscribe();this._subscriptions=[]}}class Vf extends Hf{constructor(t,e,i){super(),this._activated$=new O(!1),this._configurationSubject$=new T,this._activated=!1,this._container=e,this._name=t,this._navigator=i,this._subscriptions=new Uf,this._configuration$=this._configurationSubject$.pipe(ni(this.defaultConfiguration),Le(((t,e)=>{for(let i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t})),Ue(1),E()),this._configuration$.subscribe((()=>{}))}get activated(){return this._activated}get activated$(){return this._activated$}get defaultConfiguration(){return this._getDefaultConfiguration()}get configuration$(){return this._configuration$}get name(){return this._name}activate(t){this._activated||(void 0!==t&&this._configurationSubject$.next(t),this._activated=!0,this._activate(),this._activated$.next(!0))}configure(t){this._configurationSubject$.next(t)}deactivate(){this._activated&&(this._activated=!1,this._deactivate(),this._container.domRenderer.clear(this._name),this._container.glRenderer.clear(this._name),this._activated$.next(!1))}fire(t,e){super.fire(t,e)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}resize(){}}!function(t){t[t.Hidden=0]="Hidden",t[t.Loading=1]="Loading",t[t.Visible=2]="Visible"}(Ff||(Ff={}));class Gf extends Vf{constructor(t,e,i){super(t,e,i)}_activate(){const t=this.configuration$.pipe(Ee((t=>!!t.id)),Nt((t=>!t.src)),ri((t=>this._getImageSrc$(t.id).pipe(te((t=>(console.error(t),B())))))),Ue(1),E()),e=this._subscriptions;e.push(t.pipe(rt((t=>({src:t})))).subscribe((t=>{this._configurationSubject$.next(t)}))),e.push(gt(this.configuration$,t).pipe(Nt((([t,e])=>!!t.src&&t.src!==e)),Ee()).subscribe((([,t])=>{window.URL.revokeObjectURL(t)}))),e.push(this._configuration$.pipe(ue(void 0,(t=>t.state)),ri((t=>gt(G(t.state),this._navigator.stateService.currentImage$))),ri((([t,e])=>{const i=gt(G(e.id),e.image$.pipe(Nt((t=>!!t)),rt((t=>t.src))));return t===Ff.Visible?i.pipe(Ee()):i})),ue((([t,e],[i,n])=>t===i&&e===n)),rt((([t,e])=>({id:t,src:e})))).subscribe(this._configurationSubject$)),e.push(gt(this._configuration$,this._container.configurationService.exploreUrl$,this._container.renderService.size$).pipe(rt((([t,e,i])=>{if(!t.src)return{name:this._name,vNode:jf.h("div",[])};const n=i.width<=640||i.height<=480?".mapillary-cover-compact":"";if(t.state===Ff.Hidden){const e=jf.h("div.mapillary-cover-container.mapillary-cover-done"+n,[this._getCoverBackgroundVNode(t)]);return{name:this._name,vNode:e}}const r=jf.h("div.mapillary-cover-container"+n,[this._getCoverButtonVNode(t,e)]);return{name:this._name,vNode:r}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{state:Ff.Visible}}_getCoverButtonVNode(t,e){const i=t.state===Ff.Loading?"div.mapillary-cover.mapillary-cover-loading":"div.mapillary-cover",n=jf.h("div.mapillary-cover-button",[jf.h("div.mapillary-cover-button-icon",[])]),r=jf.h("a.mapillary-cover-logo",{href:e,target:"_blank"},[]),s=jf.h("div.mapillary-cover-indicator",{onclick:()=>{this.configure({state:Ff.Loading})}},[]);return jf.h(i,[this._getCoverBackgroundVNode(t),s,n,r])}_getCoverBackgroundVNode(t){const e={style:{backgroundImage:`url(${t.src})`}},i=[];return t.state===Ff.Loading&&i.push(jf.h("div.mapillary-cover-spinner",{},[])),jf.h("div.mapillary-cover-background",e,i)}_getImageSrc$(t){return b.create((e=>{this._navigator.api.getImages$([t]).subscribe((i=>{for(const n of i)if(n.node_id===t)return void this._navigator.api.data.getImageBuffer(n.node.thumb.url).then((i=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>{e.next(n.src),e.complete()},n.onerror=()=>{e.error(new Error(`Failed to load cover image (${t})`))};const r=new Blob([i]);n.src=window.URL.createObjectURL(r)}),(t=>{e.error(t)}));e.error(new cd(`Non existent cover key: ${t}`))}),(t=>{e.error(t)}))}))}}Gf.componentName="cover";class qf extends Vf{_activate(){this._subscriptions.push(gt(this._container.configurationService.exploreUrl$,this._navigator.stateService.currentImage$,this._container.renderService.size$).pipe(rt((([t,e,i])=>{const n=this._makeAttribution(e.creatorUsername,t,e.id,e.capturedAt,i.width);return{name:this._name,vNode:n}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}makeImageUrl(t,e){return`${t}/app/?pKey=${e}&focus=photo`}_makeAttribution(t,e,i,n,r){const s=r<=640,o=this._makeDate(n,s),a=this._makeBy(t,e,i,s),c=s?".mapillary-attribution-compact":"";return jf.h("div.mapillary-attribution-container"+c,{},[...a,o])}_makeBy(t,e,i,n){const r=jf.h("div.mapillary-attribution-logo",[]);return t?this._makeCreatorBy(r,t,e,i,n):this._makeGeneralBy(r,e,i,n)}_makeCreatorBy(t,e,i,n,r){const s=jf.h("a.mapillary-attribution-icon-container",{href:i,rel:"noreferrer",target:"_blank"},[t]),o=r?`${e}`:`image by ${e}`,a=jf.h("div.mapillary-attribution-username",{textContent:o},[]);return[s,jf.h("a.mapillary-attribution-image-container",{href:this.makeImageUrl(i,n),rel:"noreferrer",target:"_blank"},[a])]}_makeGeneralBy(t,e,i,n){const r=jf.h("div.mapillary-attribution-username",{textContent:"images by"},[]),s=[jf.h("div.mapillary-attribution-icon-container",{},[t]),jf.h("div.mapillary-attribution-username",{textContent:"contributors"},[])];n||s.unshift(r);return[jf.h("a.mapillary-attribution-image-container",{href:this.makeImageUrl(e,i),rel:"noreferrer",target:"_blank"},s)]}_makeDate(t,e){const i=new Date(t).toDateString().split(" "),n=(i.length>3?e?[i[3]]:[i[1],i[2]+",",i[3]]:i).join(" ");return jf.h("div.mapillary-attribution-date",{textContent:n},[])}}qf.componentName="attribution";class Wf{constructor(){this._unprojectDepth=200}basicToCanvas(t,e,i,n,r){const s=n.unprojectBasic([t,e],this._unprojectDepth);return this.projectToCanvas(s,i,r)}basicToCanvasSafe(t,e,i,n,r){const s=this.basicToViewportSafe(t,e,n,r);if(null===s)return null;return this.viewportToCanvas(s[0],s[1],i)}basicToViewport(t,e,i,n){const r=i.unprojectBasic([t,e],this._unprojectDepth);return this.projectToViewport(r,n)}basicToViewportSafe(t,e,i,n){const r=i.unprojectBasic([t,e],this._unprojectDepth);if(this.worldToCamera(r,n)[2]>0)return null;return this.projectToViewport(r,n)}cameraToViewport(t,e){const i=(new fn).fromArray(t).applyMatrix4(e.projectionMatrix);return[i.x,i.y]}canvasPosition(t,e){const i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}canvasToBasic(t,e,i,n,r){const s=this.unprojectFromCanvas(t,e,i,r).toArray();return n.projectBasic(s)}canvasToViewport(t,e,i){const[n,r]=this.containerToCanvas(i);return[2*t/n-1,1-2*e/r]}containerToCanvas(t){return[t.offsetWidth,t.offsetHeight]}getBasicDistances(t,e){const i=this.viewportToBasic(-1,1,t,e),n=this.viewportToBasic(1,1,t,e),r=this.viewportToBasic(1,-1,t,e),s=this.viewportToBasic(-1,-1,t,e);let o=0,a=0,c=0,h=0;return i[1]<0&&n[1]<0&&(o=i[1]>n[1]?-i[1]:-n[1]),n[0]>1&&r[0]>1&&(a=n[0]<r[0]?n[0]-1:r[0]-1),r[1]>1&&s[1]>1&&(c=r[1]<s[1]?r[1]-1:s[1]-1),s[0]<0&&i[0]<0&&(h=s[0]>i[0]?-s[0]:-i[0]),[o,a,c,h]}getPixelDistances(t,e,i){const n=this.viewportToBasic(-1,1,e,i),r=this.viewportToBasic(1,1,e,i),s=this.viewportToBasic(1,-1,e,i),o=this.viewportToBasic(-1,-1,e,i);let a=0,c=0,h=0,l=0;const[u,d]=this.containerToCanvas(t);if(n[1]<0&&r[1]<0){const s=n[1]>r[1]?n[0]:r[0],o=this.basicToCanvas(s,0,t,e,i);a=o[1]>0?o[1]:0}if(r[0]>1&&s[0]>1){const n=r[0]<s[0]?r[1]:s[1],o=this.basicToCanvas(1,n,t,e,i);c=o[0]<u?u-o[0]:0}if(s[1]>1&&o[1]>1){const n=s[1]<o[1]?s[0]:o[0],r=this.basicToCanvas(n,1,t,e,i);h=r[1]<d?d-r[1]:0}if(o[0]<0&&n[0]<0){const r=o[0]>n[0]?o[1]:n[1],s=this.basicToCanvas(0,r,t,e,i);l=s[0]>0?s[0]:0}return[a,c,h,l]}insideElement(t,e){const i=e.getBoundingClientRect(),n=i.left+e.clientLeft,r=n+e.clientWidth,s=i.top+e.clientTop,o=s+e.clientHeight;return t.clientX>n&&t.clientX<r&&t.clientY>s&&t.clientY<o}projectToCanvas(t,e,i){const n=this.projectToViewport(t,i);return this.viewportToCanvas(n[0],n[1],e)}projectToCanvasSafe(t,e,i){if(this.worldToCamera(t,i)[2]>0)return null;const n=this.projectToViewport(t,i);return this.viewportToCanvas(n[0],n[1],e)}projectToViewport(t,e){const i=new fn(t[0],t[1],t[2]).project(e);return[i.x,i.y]}unprojectFromCanvas(t,e,i,n){const r=this.canvasToViewport(t,e,i);return this.unprojectFromViewport(r[0],r[1],n)}unprojectFromViewport(t,e,i){return new fn(t,e,1).unproject(i)}viewportToBasic(t,e,i,n){const r=new fn(t,e,1).unproject(n).toArray();return i.projectBasic(r)}viewportToCanvas(t,e,i){const[n,r]=this.containerToCanvas(i);return[n*(t+1)/2,-r*(e-1)/2]}worldToCamera(t,e){return new fn(t[0],t[1],t[2]).applyMatrix4(e.matrixWorldInverse).toArray()}}t.ComponentSize=void 0,(Bf=t.ComponentSize||(t.ComponentSize={}))[Bf.Automatic=0]="Automatic",Bf[Bf.Large=1]="Large",Bf[Bf.Small=2]="Small";class Xf extends Vf{constructor(t,e,i){super(t,e,i),this._spatial=new ld,this._viewportCoords=new Wf,this._svgNamespace="http://www.w3.org/2000/svg",this._distinctThreshold=Math.PI/360,this._animationSpeed=.075,this._unitBezier=new Fd(.74,.67,.38,.96)}_activate(){const e=this._subscriptions,i=this._container.renderService.renderCamera$.pipe(rt((t=>{let e=this._spatial.degToRad(t.perspective.fov),i=t.perspective.aspect===Number.POSITIVE_INFINITY?Math.PI:2*Math.atan(t.perspective.aspect*Math.tan(.5*e));return[this._spatial.azimuthalToBearing(t.rotation.phi),i]})),ue(((t,e)=>Math.abs(e[0]-t[0])<this._distinctThreshold&&Math.abs(e[1]-t[1])<this._distinctThreshold))),n=gt(this._navigator.stateService.currentState$.pipe(ue(void 0,(t=>t.state.currentImage.id))),this._navigator.panService.panImages$).pipe(rt((([t,e])=>{const i=t.state.currentImage,n=t.state.currentTransform;if(dd(i.cameraType))return[Math.PI,Math.PI];const r=this._computeProjectedPoints(n),s=this._spatial.degToRad(this._computeHorizontalFov(r));let o=s/2,a=s/2;for(const[t,,n]of e){const e=this._spatial.wrap(t.compassAngle-i.compassAngle,-180,180);e<0?o=this._spatial.degToRad(Math.abs(e))+n/2:a=this._spatial.degToRad(Math.abs(e))+n/2}return[o,a]})),ue((([t,e],[i,n])=>Math.abs(i-t)<this._distinctThreshold&&Math.abs(n-e)<this._distinctThreshold))),r=gt(this._navigator.stateService.currentState$.pipe(ue(void 0,(t=>t.state.currentImage.id))),this._container.renderService.bearing$).pipe(rt((([t,e])=>this._spatial.degToRad(t.state.currentImage.compassAngle-e)))),s=new T,o=s.pipe(Le(((t,e)=>e(t)),{alpha:0,curr:[0,0,0],prev:[0,0,0]}),rt((t=>{const e=this._unitBezier.solve(t.alpha),i=t.curr,n=t.prev;return[this._interpolate(n[0],i[0],e),this._interpolate(n[1],i[1],e)]})));e.push(n.pipe(rt((t=>e=>{const i=this._unitBezier.solve(e.alpha),n=e.curr,r=e.prev,s=[this._interpolate(r[0],n[0],i),this._interpolate(r[1],n[1],i)];return{alpha:0,curr:t.slice(),prev:s}}))).subscribe(s)),e.push(n.pipe(ri((()=>this._container.renderService.renderCameraFrame$.pipe(Je(1),Le((t=>t+this._animationSpeed),0),li((t=>t<=1+this._animationSpeed)),rt((t=>Math.min(t,1)))))),rt((t=>e=>({alpha:t,curr:e.curr.slice(),prev:e.prev.slice()})))).subscribe(s));const a=gt(r,o).pipe(rt((([t,e])=>[t,e[0],e[1]])));e.push(gt(i,a,this._configuration$,this._container.renderService.size$).pipe(rt((([[e,i],[n,r,s],o,a])=>{const c=this._createBackground(e),h=this._createFovIndicator(r,s,n),l=this._createNorth(e),u=this._createCircleSectorCompass(this._createCircleSector(Math.max(Math.PI/20,i),"#FFF")),d=o.size===t.ComponentSize.Small||o.size===t.ComponentSize.Automatic&&a.width<640?".mapillary-bearing-compact":"";return{name:this._name,vNode:jf.h("div.mapillary-bearing-indicator-container"+d,{oncontextmenu:t=>{t.preventDefault()}},[c,h,l,u])}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{size:t.ComponentSize.Automatic}}_createFovIndicator(t,e,i){const n=this._createFovArc(t,e),r=jf.h("g",{attributes:{transform:"translate(18,18)"},namespace:this._svgNamespace},[n]);return jf.h("svg",{attributes:{viewBox:"0 0 36 36"},namespace:this._svgNamespace,style:{height:"36px",left:"2px",position:"absolute",top:"2px",transform:`rotateZ(${this._spatial.radToDeg(i)}deg)`,width:"36px"}},[r])}_createFovArc(t,e){const i=16.75,n=t+e;if(n>2*Math.PI-Math.PI/90)return jf.h("circle",{attributes:{cx:"0",cy:"0","fill-opacity":"0",r:"16.75",stroke:"#FFF","stroke-width":"2.5"},namespace:this._svgNamespace},[]);let r=-Math.PI/2-t,s=r+n,o=i*Math.cos(r),a=i*Math.sin(r),c=i*Math.cos(s),h=i*Math.sin(s),l=`M ${o} ${a} A 16.75 16.75 0 ${n>=Math.PI?1:0} 1 ${c} ${h}`;return jf.h("path",{attributes:{d:l,"fill-opacity":"0",stroke:"#FFF","stroke-width":"2.5"},namespace:this._svgNamespace},[])}_createCircleSectorCompass(t){let e=jf.h("g",{attributes:{transform:"translate(1,1)"},namespace:this._svgNamespace},[t]);return jf.h("svg",{attributes:{viewBox:"0 0 2 2"},namespace:this._svgNamespace,style:{height:"26px",left:"7px",position:"absolute",top:"7px",width:"26px"}},[e])}_createCircleSector(t,e){if(t>2*Math.PI-Math.PI/90)return jf.h("circle",{attributes:{cx:"0",cy:"0",fill:e,r:"1"},namespace:this._svgNamespace},[]);let i=-Math.PI/2-t/2,n=i+t,r=Math.cos(i),s=Math.sin(i),o=Math.cos(n),a=Math.sin(n),c=`M 0 0 ${r} ${s} A 1 1 0 ${t>=Math.PI?1:0} 1 ${o} ${a}`;return jf.h("path",{attributes:{d:c,fill:e},namespace:this._svgNamespace},[])}_createNorth(t){const e=jf.h("div.mapillary-bearing-north",[]);return jf.h("div.mapillary-bearing-north-container",{style:{transform:`rotateZ(${this._spatial.radToDeg(-t)}deg)`}},[e])}_createBackground(t){return jf.h("div.mapillary-bearing-indicator-background",{style:{transform:`rotateZ(${this._spatial.radToDeg(-t)}deg)`}},[jf.h("div.mapillary-bearing-indicator-background-circle",[]),jf.h("div.mapillary-bearing-indicator-background-arrow-container",[jf.h("div.mapillary-bearing-indicator-background-arrow",[])])])}_computeProjectedPoints(t){return md(t,[[1,0]],[[0,.5]],12,this._viewportCoords)}_computeHorizontalFov(t){const e=t.map((t=>this._coordToFov(t[0])));return Math.min(...e)}_coordToFov(t){return this._spatial.radToDeg(2*Math.atan(t))}_interpolate(t,e,i){return(1-i)*t+i*e}}Xf.componentName="bearing";class Yf extends Vf{constructor(t,e,i){super(t,e,i)}_activate(){const e=this._subscriptions;e.push(gt(this._navigator.stateService.currentImage$.pipe(ri((t=>t.sequenceEdges$)),Nt((t=>t.cached))),this._configuration$).pipe(ri((e=>{let i=e[0],n=e[1],r=Math.max(0,Math.min(4,n.depth.sequence));return Ot(this._cache$(i.edges,t.NavigationDirection.Next,r),this._cache$(i.edges,t.NavigationDirection.Prev,r)).pipe(te((t=>(console.error("Failed to cache sequence edges.",t),B()))))}))).subscribe((()=>{}))),e.push(gt(this._navigator.stateService.currentImage$.pipe(ri((t=>gt(G(t),t.spatialEdges$.pipe(Nt((t=>t.cached))))))),this._configuration$).pipe(ri((([[e,i],n])=>{let r=i.edges,s=n.depth,o=Math.max(0,Math.min(2,s.spherical)),a=dd(e.cameraType)?0:Math.max(0,Math.min(3,s.step)),c=dd(e.cameraType)?0:Math.max(0,Math.min(1,s.turn)),h=this._cache$(r,t.NavigationDirection.Spherical,o);return Ot(this._cache$(r,t.NavigationDirection.StepForward,a),this._cache$(r,t.NavigationDirection.StepBackward,a),this._cache$(r,t.NavigationDirection.StepLeft,a),this._cache$(r,t.NavigationDirection.StepRight,a),h,this._cache$(r,t.NavigationDirection.TurnLeft,c),this._cache$(r,t.NavigationDirection.TurnRight,c),this._cache$(r,t.NavigationDirection.TurnU,c)).pipe(te((t=>(console.error("Failed to cache spatial edges.",t),B()))))}))).subscribe((()=>{})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{depth:{spherical:1,sequence:2,step:1,turn:0}}}_cache$(t,e,i){return Ft(G(t),G(i)).pipe(xe((t=>{let i=t[0],n=t[1],r=[];if(n>0)for(let t of i)t.data.direction===e&&r.push(Ft(this._navigator.graphService.cacheImage$(t.target).pipe(Mt((t=>this._imageToEdges$(t,e)))),G(n-1)));return bt(r).pipe(Et())})),Je(1))}_imageToEdges$(e,i){return([t.NavigationDirection.Next,t.NavigationDirection.Prev].indexOf(i)>-1?e.sequenceEdges$:e.spatialEdges$).pipe(Ee((t=>t.cached)),rt((t=>t.edges)))}}Yf.componentName="cache";class Zf extends cd{constructor(t){super(null!=t?t:"The request was cancelled."),Object.setPrototypeOf(this,Zf.prototype),this.name="CancelMapillaryError"}}class Jf{constructor(t,e){this._spatial=new ld,this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820,this._configure(t),this._resize(e),this._reset()}get minWidth(){return this._minWidth}get maxWidth(){return this._maxWidth}get containerWidth(){return this._containerWidth}get containerWidthCss(){return this._containerWidthCss}get containerMarginCss(){return this._containerMarginCss}get containerLeftCss(){return this._containerLeftCss}get containerHeight(){return this._containerHeight}get containerHeightCss(){return this._containerHeightCss}get containerBottomCss(){return this._containerBottomCss}get stepCircleSize(){return this._stepCircleSize}get stepCircleSizeCss(){return this._stepCircleSizeCss}get stepCircleMarginCss(){return this._stepCircleMarginCss}get turnCircleSize(){return this._turnCircleSize}get turnCircleSizeCss(){return this._turnCircleSizeCss}get outerRadius(){return this._outerRadius}get innerRadius(){return this._innerRadius}get shadowOffset(){return this._shadowOffset}configure(t){this._configure(t),this._reset()}resize(t){this._resize(t),this._reset()}angleToCoordinates(t){return[Math.cos(t),Math.sin(t)]}relativeAngleToCoordiantes(t,e){let i=this._spatial.wrapAngle(t-e);return this.angleToCoordinates(i)}_configure(t){this._minWidth=t.minWidth,this._maxWidth=this._getMaxWidth(t.minWidth,t.maxWidth)}_resize(t){this._elementWidth=t.width,this._elementHeight=t.height}_reset(){this._containerWidth=this._getContainerWidth(this._elementWidth,this._elementHeight),this._containerHeight=this._getContainerHeight(this.containerWidth),this._stepCircleSize=this._getStepCircleDiameter(this._containerHeight),this._turnCircleSize=this._getTurnCircleDiameter(this.containerHeight),this._outerRadius=this._getOuterRadius(this._containerHeight),this._innerRadius=this._getInnerRadius(this._containerHeight),this._shadowOffset=3,this._containerWidthCss=this._numberToCssPixels(this._containerWidth),this._containerMarginCss=this._numberToCssPixels(-.5*this._containerWidth),this._containerLeftCss=this._numberToCssPixels(Math.floor(.5*this._elementWidth)),this._containerHeightCss=this._numberToCssPixels(this._containerHeight),this._containerBottomCss=this._numberToCssPixels(Math.floor(-.08*this._containerHeight)),this._stepCircleSizeCss=this._numberToCssPixels(this._stepCircleSize),this._stepCircleMarginCss=this._numberToCssPixels(-.5*this._stepCircleSize),this._turnCircleSizeCss=this._numberToCssPixels(this._turnCircleSize)}_getContainerWidth(t,e){let i=(t-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),n=(e-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight),r=Math.max(0,Math.min(1,Math.min(i,n)));return r=.04*Math.round(25*r),this._minWidth+r*(this._maxWidth-this._minWidth)}_getContainerHeight(t){return.77*t}_getStepCircleDiameter(t){return.34*t}_getTurnCircleDiameter(t){return.3*t}_getOuterRadius(t){return.31*t}_getInnerRadius(t){return.125*t}_numberToCssPixels(t){return t+"px"}_getMaxWidth(t,e){return t>e?t:e}}class Kf{constructor(e,i){this._isEdge=!1,this._spatial=new ld,this._calculator=new Jf(e,i),this._image=null,this._rotation={phi:0,theta:0},this._epsilon=.5*Math.PI/180,this._highlightKey=null,this._distinguishSequence=!1,this._needsRender=!1,this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[],this._stepDirections=[t.NavigationDirection.StepForward,t.NavigationDirection.StepBackward,t.NavigationDirection.StepLeft,t.NavigationDirection.StepRight],this._turnDirections=[t.NavigationDirection.TurnLeft,t.NavigationDirection.TurnRight,t.NavigationDirection.TurnU],this._turnNames={},this._turnNames[t.NavigationDirection.TurnLeft]="mapillary-direction-turn-left",this._turnNames[t.NavigationDirection.TurnRight]="mapillary-direction-turn-right",this._turnNames[t.NavigationDirection.TurnU]="mapillary-direction-turn-around";let n=!!document.documentMode;this._isEdge=!n&&!!window.StyleMedia}get needsRender(){return this._needsRender}render(t){this._needsRender=!1;let e=this._rotation,i=[],n=[];return dd(this._image.cameraType)?i=i.concat(this._createSphericalArrows(t,e)):(i=i.concat(this._createPerspectiveToSphericalArrows(t,e)),i=i.concat(this._createStepArrows(t,e)),n=n.concat(this._createTurnArrows(t))),this._getContainer(i,n,e)}setEdges(t,e){this._setEdges(t,e),this._setNeedsRender()}setImage(t){this._image=t,this._clearEdges(),this._setNeedsRender()}setRenderCamera(t){let e=t.rotation;Math.abs(e.phi-this._rotation.phi)<this._epsilon||(this._rotation=e,this._setNeedsRender())}setConfiguration(t){let e=!1;this._highlightKey===t.highlightId&&this._distinguishSequence===t.distinguishSequence||(this._highlightKey=t.highlightId,this._distinguishSequence=t.distinguishSequence,e=!0),this._calculator.minWidth===t.minWidth&&this._calculator.maxWidth===t.maxWidth||(this._calculator.configure(t),e=!0),e&&this._setNeedsRender()}resize(t){this._calculator.resize(t),this._setNeedsRender()}_setNeedsRender(){null!=this._image&&(this._needsRender=!0)}_clearEdges(){this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[]}_setEdges(e,i){this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[];for(let i of e.edges){let e=i.data.direction;this._stepDirections.indexOf(e)>-1?this._stepEdges.push(i):this._turnDirections.indexOf(e)>-1?this._turnEdges.push(i):i.data.direction===t.NavigationDirection.Spherical&&this._sphericalEdges.push(i)}if(this._distinguishSequence&&null!=i){let t=this._sphericalEdges.concat(this._stepEdges).concat(this._turnEdges);for(let e of t){let t=e.target;for(let e of i.imageIds)if(e===t){this._sequenceEdgeKeys.push(t);break}}}}_createSphericalArrows(t,e){let i=[];for(let n of this._sphericalEdges)i.push(this._createVNodeByKey(t,n.target,n.data.worldMotionAzimuth,e,this._calculator.outerRadius,"mapillary-direction-arrow-spherical"));for(let n of this._stepEdges)i.push(this._createSphericalToPerspectiveArrow(t,n.target,n.data.worldMotionAzimuth,e,n.data.direction));return i}_createSphericalToPerspectiveArrow(e,i,n,r,s){let o=Math.PI/8,a=r.phi;switch(s){case t.NavigationDirection.StepBackward:a=r.phi-Math.PI;break;case t.NavigationDirection.StepLeft:a=r.phi+Math.PI/2;break;case t.NavigationDirection.StepRight:a=r.phi-Math.PI/2}return Math.abs(this._spatial.wrapAngle(n-a))<o?this._createVNodeByKey(e,i,n,r,this._calculator.outerRadius,"mapillary-direction-arrow-step"):this._createVNodeInactive(i,n,r)}_createPerspectiveToSphericalArrows(t,e){let i=[];for(let n of this._sphericalEdges)i.push(this._createVNodeByKey(t,n.target,n.data.worldMotionAzimuth,e,this._calculator.innerRadius,"mapillary-direction-arrow-spherical",!0));return i}_createStepArrows(t,e){let i=[];for(let n of this._stepEdges)i.push(this._createVNodeByDirection(t,n.target,n.data.worldMotionAzimuth,e,n.data.direction));return i}_createTurnArrows(t){let e=[];for(let i of this._turnEdges){let n=i.data.direction,r=this._turnNames[n];e.push(this._createVNodeByTurn(t,i.target,r,n))}return e}_createVNodeByKey(t,e,i,n,r,s,o){return this._createVNode(e,i,n,r,s,"mapillary-direction-circle",(i=>{t.moveTo$(e).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}),o)}_createVNodeByDirection(t,e,i,n,r){return this._createVNode(e,i,n,this._calculator.outerRadius,"mapillary-direction-arrow-step","mapillary-direction-circle",(e=>{t.moveDir$(r).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}))}_createVNodeByTurn(e,i,n,r){let s={height:this._calculator.turnCircleSizeCss,transform:"rotate(0)",width:this._calculator.turnCircleSizeCss};switch(r){case t.NavigationDirection.TurnLeft:s.left="5px",s.top="5px";break;case t.NavigationDirection.TurnRight:s.right="5px",s.top="5px";break;case t.NavigationDirection.TurnU:s.left="5px",s.bottom="5px"}let o={attributes:{"data-id":i},onclick:t=>{e.moveDir$(r).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))},style:s},a="mapillary-direction-turn-circle";this._sequenceEdgeKeys.indexOf(i)>-1&&(a+="-sequence"),this._highlightKey===i&&(a+="-highlight");let c=jf.h(`div.${n}`,{},[]);return jf.h("div."+a,o,[c])}_createVNodeInactive(t,e,i){return this._createVNode(t,e,i,this._calculator.outerRadius,"mapillary-direction-arrow-inactive","mapillary-direction-circle-inactive")}_createVNode(t,e,i,n,r,s,o,a){let c=this._calculator.angleToCoordinates(e-i.phi),h=Math.round(-n*c[1]+.5*this._calculator.containerWidth),l=Math.round(-n*c[0]+.5*this._calculator.containerHeight),u=this._calculator.relativeAngleToCoordiantes(e,i.phi),d=this._calculator.shadowOffset,p=`drop-shadow(${-d*u[1]}px ${d*u[0]}px 1px rgba(0,0,0,0.8))`,f={style:{"-webkit-filter":p,filter:p}},m=jf.h("div."+r,f,[]),g=-this._spatial.radToDeg(e-i.phi),_=a?`translate(${h}px, ${l}px) rotate(${g}deg) translateZ(-0.01px)`:`translate(${h}px, ${l}px) rotate(${g}deg)`,v={attributes:{"data-id":t},onclick:o,style:{height:this._calculator.stepCircleSizeCss,marginLeft:this._calculator.stepCircleMarginCss,marginTop:this._calculator.stepCircleMarginCss,transform:_,width:this._calculator.stepCircleSizeCss}};return this._sequenceEdgeKeys.indexOf(t)>-1&&(s+="-sequence"),this._highlightKey===t&&(s+="-highlight"),jf.h("div."+s,v,[m])}_getContainer(t,e,i){let n=this._isEdge?"rotateX(60deg)":`perspective(${this._calculator.containerWidthCss}) rotateX(60deg)`,r={oncontextmenu:t=>{t.preventDefault()},style:{bottom:this._calculator.containerBottomCss,height:this._calculator.containerHeightCss,left:this._calculator.containerLeftCss,marginLeft:this._calculator.containerMarginCss,transform:n,width:this._calculator.containerWidthCss}};return jf.h("div.mapillary-direction-perspective",r,e.concat(t))}}class Qf extends Vf{constructor(t,e,i,n){super(t,e,i),this._renderer=n||new Kf(this.defaultConfiguration,{height:e.container.offsetHeight,width:e.container.offsetWidth}),this._hoveredIdSubject$=new T,this._hoveredId$=this._hoveredIdSubject$.pipe(Ze())}fire(t,e){super.fire(t,e)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}_activate(){const t=this._subscriptions;t.push(this._configuration$.subscribe((t=>{this._renderer.setConfiguration(t)}))),t.push(this._container.renderService.size$.subscribe((t=>{this._renderer.resize(t)}))),t.push(this._navigator.stateService.currentImage$.pipe(pi((t=>{this._container.domRenderer.render$.next({name:this._name,vNode:jf.h("div",{},[])}),this._renderer.setImage(t)})),bi(this._configuration$),ri((([t,e])=>gt(t.spatialEdges$,e.distinguishSequence?this._navigator.graphService.cacheSequence$(t.sequenceId).pipe(te((e=>(console.error(`Failed to cache sequence (${t.sequenceId})`,e),G(null))))):G(null))))).subscribe((([t,e])=>{this._renderer.setEdges(t,e)}))),t.push(this._container.renderService.renderCameraFrame$.pipe(pi((t=>{this._renderer.setRenderCamera(t)})),rt((()=>this._renderer)),Nt((t=>t.needsRender)),rt((t=>({name:this._name,vNode:t.render(this._navigator)})))).subscribe(this._container.domRenderer.render$)),t.push(gt(this._container.domRenderer.element$,this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$.pipe(ni(null)),this._container.mouseService.mouseUp$.pipe(ni(null))).pipe(rt((([t])=>{let e=t.getElementsByClassName("mapillary-direction-perspective");for(let t=0;t<e.length;t++){let i=e.item(t).querySelector(":hover");if(null!=i&&i.hasAttribute("data-id"))return i.getAttribute("data-id")}return null})),ue()).subscribe(this._hoveredIdSubject$)),t.push(this._hoveredId$.subscribe((t=>{const e="hover",i={id:t,target:this,type:e};this.fire(e,i)})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{distinguishSequence:!1,maxWidth:460,minWidth:260}}}Qf.componentName="direction";class tm{}tm.fisheye={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r = sqrt(x * x + y * y);\n float theta = atan(r, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.fisheyeCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r2 = sqrt(x * x + y * y);\n float theta = atan(r2, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r2;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.perspective={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.perspectiveCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.perspectiveDistorted={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.perspectiveDistortedCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.spherical={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#define tau 6.28318530718\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lng = atan(b.x, b.z);\n float x = lng / tau + 0.5;\n float y = lat / tau * 2.0 + 0.5;\n vec4 baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},tm.sphericalCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#define tau 6.28318530718\n\nuniform sampler2D projectorTex;\nuniform float curtain;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lng = atan(b.x, b.z);\n float x = lng / tau + 0.5;\n float y = lat / tau * 2.0 + 0.5;\n\n bool inverted = curtain < 0.5;\n\n float curtainMin = inverted ? curtain + 0.5 : curtain - 0.5;\n float curtainMax = curtain;\n\n bool insideCurtain = inverted ?\n x > curtainMin || x < curtainMax :\n x > curtainMin && x < curtainMax;\n\n vec4 baseColor;\n if (insideCurtain) {\n baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"};class em{constructor(t,e){this._imagePlaneDepth=null!=t?t:200,this._imageSphereRadius=null!=e?e:200}createMesh(t,e){return dd(e.cameraType)?this._createImageSphere(t,e):pd(e.cameraType)?this._createImagePlaneFisheye(t,e):this._createImagePlane(t,e)}createFlatMesh(t,e,i,n,r,s){let o=this._createTexture(t.image),a=new Os(this._createDistortedPlaneMaterialParameters(e,o));return new Es(this._getFlatImagePlaneGeoFromBasic(e,i,n,r,s),a)}createCurtainMesh(t,e){return dd(e.cameraType)?this._createSphereCurtainMesh(t,e):pd(e.cameraType)?this._createCurtainMeshFisheye(t,e):this._createCurtainMesh(t,e)}createDistortedCurtainMesh(t,e){return this._createDistortedCurtainMesh(t,e)}_createCurtainMesh(t,e){let i=this._createTexture(t.image),n=new Os(this._createCurtainPlaneMaterialParameters(e,i));return new Es(this._useMesh(e,t)?this._getImagePlaneGeo(e,t):this._getRegularFlatImagePlaneGeo(e),n)}_createCurtainMeshFisheye(t,e){let i=this._createTexture(t.image),n=new Os(this._createCurtainPlaneMaterialParametersFisheye(e,i));return new Es(this._useMesh(e,t)?this._getImagePlaneGeoFisheye(e,t):this._getRegularFlatImagePlaneGeo(e),n)}_createDistortedCurtainMesh(t,e){let i=this._createTexture(t.image),n=new Os(this._createDistortedCurtainPlaneMaterialParameters(e,i));return new Es(this._getRegularFlatImagePlaneGeo(e),n)}_createSphereCurtainMesh(t,e){let i=this._createTexture(t.image),n=new Os(this._createCurtainSphereMaterialParameters(e,i));return this._useMesh(e,t)?new Es(this._getImageSphereGeo(e,t),n):new Es(this._getFlatImageSphereGeo(e),n)}_createImageSphere(t,e){let i=this._createTexture(t.image),n=new Os(this._createSphereMaterialParameters(e,i));return this._useMesh(e,t)?new Es(this._getImageSphereGeo(e,t),n):new Es(this._getFlatImageSphereGeo(e),n)}_createImagePlane(t,e){let i=this._createTexture(t.image),n=new Os(this._createPlaneMaterialParameters(e,i));return new Es(this._useMesh(e,t)?this._getImagePlaneGeo(e,t):this._getRegularFlatImagePlaneGeo(e),n)}_createImagePlaneFisheye(t,e){let i=this._createTexture(t.image),n=new Os(this._createPlaneMaterialParametersFisheye(e,i));return new Es(this._useMesh(e,t)?this._getImagePlaneGeoFisheye(e,t):this._getRegularFlatImagePlaneGeoFisheye(e),n)}_createSphereMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.spherical.fragment,side:2,transparent:!0,uniforms:{opacity:{value:1},projectorMat:{value:t.rt},projectorTex:{value:e}},vertexShader:tm.spherical.vertex}}_createCurtainSphereMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.sphericalCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},opacity:{value:1},projectorMat:{value:t.rt},projectorTex:{value:e}},vertexShader:tm.sphericalCurtain.vertex}}_createPlaneMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.perspective.fragment,side:2,transparent:!0,uniforms:{focal:{value:t.focal},k1:{value:t.ck1},k2:{value:t.ck2},opacity:{value:1},projectorMat:{value:t.basicRt},projectorTex:{value:e},radial_peak:{value:t.radialPeak?t.radialPeak:0},scale_x:{value:Math.max(t.basicHeight,t.basicWidth)/t.basicWidth},scale_y:{value:Math.max(t.basicWidth,t.basicHeight)/t.basicHeight}},vertexShader:tm.perspective.vertex}}_createPlaneMaterialParametersFisheye(t,e){return{depthWrite:!1,fragmentShader:tm.fisheye.fragment,side:2,transparent:!0,uniforms:{focal:{value:t.focal},k1:{value:t.ck1},k2:{value:t.ck2},opacity:{value:1},projectorMat:{value:t.basicRt},projectorTex:{value:e},radial_peak:{value:t.radialPeak?t.radialPeak:0},scale_x:{value:Math.max(t.basicHeight,t.basicWidth)/t.basicWidth},scale_y:{value:Math.max(t.basicWidth,t.basicHeight)/t.basicHeight}},vertexShader:tm.fisheye.vertex}}_createCurtainPlaneMaterialParametersFisheye(t,e){return{depthWrite:!1,fragmentShader:tm.fisheyeCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},focal:{value:t.focal},k1:{value:t.ck1},k2:{value:t.ck2},opacity:{value:1},projectorMat:{value:t.basicRt},projectorTex:{value:e},radial_peak:{value:t.radialPeak?t.radialPeak:0},scale_x:{value:Math.max(t.basicHeight,t.basicWidth)/t.basicWidth},scale_y:{value:Math.max(t.basicWidth,t.basicHeight)/t.basicHeight}},vertexShader:tm.fisheyeCurtain.vertex}}_createCurtainPlaneMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.perspectiveCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},focal:{value:t.focal},k1:{value:t.ck1},k2:{value:t.ck2},opacity:{value:1},projectorMat:{value:t.basicRt},projectorTex:{value:e},radial_peak:{value:t.radialPeak?t.radialPeak:0},scale_x:{value:Math.max(t.basicHeight,t.basicWidth)/t.basicWidth},scale_y:{value:Math.max(t.basicWidth,t.basicHeight)/t.basicHeight}},vertexShader:tm.perspectiveCurtain.vertex}}_createDistortedCurtainPlaneMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.perspectiveDistortedCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},opacity:{value:1},projectorMat:{value:t.projectorMatrix()},projectorTex:{value:e}},vertexShader:tm.perspectiveDistortedCurtain.vertex}}_createDistortedPlaneMaterialParameters(t,e){return{depthWrite:!1,fragmentShader:tm.perspectiveDistorted.fragment,side:2,transparent:!0,uniforms:{opacity:{value:1},projectorMat:{value:t.projectorMatrix()},projectorTex:{value:e}},vertexShader:tm.perspectiveDistorted.vertex}}_createTexture(t){let e=new hn(t);return e.minFilter=Ai,e.needsUpdate=!0,e}_useMesh(t,e){return e.mesh.vertices.length&&t.hasValidScale}_getImageSphereGeo(t,e){const i=t.srtInverse;let n=5*t.scale,r=this._imageSphereRadius*t.scale,s=e.mesh.vertices,o=s.length/3,a=new Float32Array(s.length);for(let t=0;t<o;++t){let e=3*t,o=s[e+0],c=s[e+1],h=s[e+2],l=Math.sqrt(o*o+c*c+h*h),u=Math.max(n,Math.min(l,r))/l,d=new fn(o*u,c*u,h*u);d.applyMatrix4(i),a[e+0]=d.x,a[e+1]=d.y,a[e+2]=d.z}let c=e.mesh.faces,h=new Uint16Array(c.length);for(let t=0;t<c.length;++t)h[t]=c[t];let l=new hs;return l.setAttribute("position",new Hr(a,3)),l.setIndex(new Hr(h,1)),l}_getImagePlaneGeo(t,e){const i=t.srtInverse;let n=5*t.scale,r=this._imagePlaneDepth*t.scale,s=e.mesh.vertices,o=s.length/3,a=new Float32Array(s.length);for(let t=0;t<o;++t){let e=3*t,o=s[e+0],c=s[e+1],h=s[e+2];t<4&&(o*=3,c*=3);let l=Math.max(n,Math.min(h,r)),u=l/h,d=new fn(o*u,c*u,l);d.applyMatrix4(i),a[e+0]=d.x,a[e+1]=d.y,a[e+2]=d.z}let c=e.mesh.faces,h=new Uint16Array(c.length);for(let t=0;t<c.length;++t)h[t]=c[t];let l=new hs;return l.setAttribute("position",new Hr(a,3)),l.setIndex(new Hr(h,1)),l}_getImagePlaneGeoFisheye(t,e){const i=t.srtInverse;let n=5*t.scale,r=this._imagePlaneDepth*t.scale,s=e.mesh.vertices,o=s.length/3,a=new Float32Array(s.length);for(let t=0;t<o;++t){let e=3*t,o=s[e+0],c=s[e+1],h=s[e+2],l=Math.sqrt(o*o+c*c+h*h),u=Math.max(n,Math.min(l,r))/l,d=new fn(o*u,c*u,h*u);d.applyMatrix4(i),a[e+0]=d.x,a[e+1]=d.y,a[e+2]=d.z}let c=e.mesh.faces,h=new Uint16Array(c.length);for(let t=0;t<c.length;++t)h[t]=c[t];let l=new hs;return l.setAttribute("position",new Hr(a,3)),l.setIndex(new Hr(h,1)),l}_getFlatImageSphereGeo(t){const e=new zh(this._imageSphereRadius,20,40),i=t.rt.clone().invert();return e.applyMatrix4(i),e}_getRegularFlatImagePlaneGeo(t){let e=t.width,i=t.height,n=Math.max(e,i),r=e/2/n,s=i/2/n;return this._getFlatImagePlaneGeo(t,r,s)}_getFlatImagePlaneGeo(t,e,i){let n=[];return n.push(t.unprojectSfM([-e,-i],this._imagePlaneDepth)),n.push(t.unprojectSfM([e,-i],this._imagePlaneDepth)),n.push(t.unprojectSfM([e,i],this._imagePlaneDepth)),n.push(t.unprojectSfM([-e,i],this._imagePlaneDepth)),this._createFlatGeometry(n)}_getRegularFlatImagePlaneGeoFisheye(t){let e=t.width,i=t.height,n=Math.max(e,i),r=e/2/n,s=i/2/n;return this._getFlatImagePlaneGeoFisheye(t,r,s)}_getFlatImagePlaneGeoFisheye(t,e,i){let n=[];return n.push(t.unprojectSfM([-e,-i],this._imagePlaneDepth)),n.push(t.unprojectSfM([e,-i],this._imagePlaneDepth)),n.push(t.unprojectSfM([e,i],this._imagePlaneDepth)),n.push(t.unprojectSfM([-e,i],this._imagePlaneDepth)),this._createFlatGeometry(n)}_getFlatImagePlaneGeoFromBasic(t,e,i,n,r){let s=[];return s.push(t.unprojectBasic([e,n],this._imagePlaneDepth)),s.push(t.unprojectBasic([i,n],this._imagePlaneDepth)),s.push(t.unprojectBasic([i,r],this._imagePlaneDepth)),s.push(t.unprojectBasic([e,r],this._imagePlaneDepth)),this._createFlatGeometry(s)}_createFlatGeometry(t){let e=new Float32Array(12);for(let i=0;i<t.length;i++){let n=3*i;e[n+0]=t[i][0],e[n+1]=t[i][1],e[n+2]=t[i][2]}let i=new Uint16Array(6);i[0]=0,i[1]=1,i[2]=3,i[3]=1,i[4]=2,i[5]=3;let n=new hs;return n.setAttribute("position",new Hr(e,3)),n.setIndex(new Hr(i,1)),n}}class im{constructor(){this._planes={},this._planesOld={},this._planesPeriphery={},this._scene=new Qa,this._sceneOld=new Qa,this._scenePeriphery=new Qa}get planes(){return this._planes}get planesOld(){return this._planesOld}get planesPeriphery(){return this._planesPeriphery}get scene(){return this._scene}get sceneOld(){return this._sceneOld}get scenePeriphery(){return this._scenePeriphery}updateImagePlanes(t){this._dispose(this._planesOld,this.sceneOld);for(const t in this._planes){if(!this._planes.hasOwnProperty(t))continue;const e=this._planes[t];this._scene.remove(e),this._sceneOld.add(e)}for(const e in t)t.hasOwnProperty(e)&&this._scene.add(t[e]);this._planesOld=this._planes,this._planes=t}addImagePlanes(t){for(const e in t){if(!t.hasOwnProperty(e))continue;const i=t[e];this._scene.add(i),this._planes[e]=i}}addImagePlanesOld(t){for(const e in t){if(!t.hasOwnProperty(e))continue;const i=t[e];this._sceneOld.add(i),this._planesOld[e]=i}}setImagePlanes(t){this._clear(),this.addImagePlanes(t)}addPeripheryPlanes(t){for(const e in t){if(!t.hasOwnProperty(e))continue;const i=t[e];this._scenePeriphery.add(i),this._planesPeriphery[e]=i}}setPeripheryPlanes(t){this._clearPeriphery(),this.addPeripheryPlanes(t)}setImagePlanesOld(t){this._clearOld(),this.addImagePlanesOld(t)}clear(){this._clear(),this._clearOld()}_clear(){this._dispose(this._planes,this._scene),this._planes={}}_clearOld(){this._dispose(this._planesOld,this._sceneOld),this._planesOld={}}_clearPeriphery(){this._dispose(this._planesPeriphery,this._scenePeriphery),this._planesPeriphery={}}_dispose(t,e){for(const i in t){if(!t.hasOwnProperty(i))continue;const n=t[i];e.remove(n),n.geometry.dispose(),n.material.dispose();let r=n.material.uniforms.projectorTex.value;null!=r&&r.dispose()}}}class nm{constructor(){this._factory=new em,this._scene=new im,this._alpha=0,this._alphaOld=0,this._fadeOutSpeed=.05,this._currentKey=null,this._previousKey=null,this._providerDisposers={},this._frameId=0,this._needsRender=!1}get frameId(){return this._frameId}get needsRender(){return this._needsRender}indicateNeedsRender(){this._needsRender=!0}addPeripheryPlane(t,e){const i=this._factory.createMesh(t,e),n={};n[t.id]=i,this._scene.addPeripheryPlanes(n),this._needsRender=!0}clearPeripheryPlanes(){this._scene.setPeripheryPlanes({}),this._needsRender=!0}updateFrame(t){this._updateFrameId(t.id),this._needsRender=this._updateAlpha(t.state.alpha)||this._needsRender,this._needsRender=this._updateAlphaOld(t.state.alpha)||this._needsRender,this._needsRender=this._updateImagePlanes(t.state)||this._needsRender}setTextureProvider(t,e){if(t!==this._currentKey)return;let i=e.textureCreated$.subscribe((t=>{this._updateTexture(t)})),n=e.textureUpdated$.subscribe((t=>{this._needsRender=!0}));if(t in this._providerDisposers){(0,this._providerDisposers[t])(),delete this._providerDisposers[t]}this._providerDisposers[t]=()=>{i.unsubscribe(),n.unsubscribe(),e.dispose()}}updateTextureImage(t,e){this._needsRender=!0;const i=this._extend({},this._scene.planes,this._scene.planesOld,this._scene.planesPeriphery);for(const n in i){if(!i.hasOwnProperty(n))continue;if(n!==e.id)continue;let r=i[n].material.uniforms.projectorTex.value;r.image=t,r.needsUpdate=!0}}render(t,e){const i=this._scene.planes,n=this._scene.planesOld,r=this._scene.planesPeriphery,s=Object.keys(n).length?1:this._alpha,o=Object.keys(n).length?1:Math.floor(this._alpha);for(const t in i){if(!i.hasOwnProperty(t))continue;i[t].material.uniforms.opacity.value=s}for(const t in n){if(!n.hasOwnProperty(t))continue;n[t].material.uniforms.opacity.value=this._alphaOld}for(const t in r){if(!r.hasOwnProperty(t))continue;r[t].material.uniforms.opacity.value=o}e.render(this._scene.scenePeriphery,t),e.render(this._scene.scene,t),e.render(this._scene.sceneOld,t);for(const t in i){if(!i.hasOwnProperty(t))continue;i[t].material.uniforms.opacity.value=this._alpha}e.render(this._scene.scene,t)}clearNeedsRender(){this._needsRender=!1}dispose(){this._scene.clear()}_updateFrameId(t){this._frameId=t}_updateAlpha(t){return t!==this._alpha&&(this._alpha=t,!0)}_updateAlphaOld(t){return!(t<1||0===this._alphaOld)&&(this._alphaOld=Math.max(0,this._alphaOld-this._fadeOutSpeed),!0)}_updateImagePlanes(t){if(null==t.currentImage||t.currentImage.id===this._currentKey)return!1;let e=null!=t.previousImage?t.previousImage.id:null,i=t.currentImage.id;if(this._previousKey!==e&&this._previousKey!==i&&this._previousKey in this._providerDisposers){(0,this._providerDisposers[this._previousKey])(),delete this._providerDisposers[this._previousKey]}if(null!=e){if(e!==this._currentKey&&e!==this._previousKey){let i=this._factory.createMesh(t.previousImage,t.previousTransform);const n={};n[e]=i,this._scene.updateImagePlanes(n)}this._previousKey=e}this._currentKey=i;let n=this._factory.createMesh(t.currentImage,t.currentTransform);const r={};return r[i]=n,this._scene.updateImagePlanes(r),this._alphaOld=1,!0}_updateTexture(t){this._needsRender=!0;const e=this._scene.planes;for(const i in e){if(!e.hasOwnProperty(i))continue;let n=e[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=t}}_extend(t,...e){for(const i of e)for(const e in i)i.hasOwnProperty(e)&&(t[e]=i[e]);return t}}var rm;!function(t){t[t.Background=0]="Background",t[t.Opaque=1]="Opaque"}(rm||(rm={}));class sm{constructor(t){this._api=t,this._urls$=new Map}getImage$(t){let e;const i=new Promise(((t,i)=>{e=i}));return[b.create((n=>{this._api.data.getImageBuffer(t,i).then((t=>{e=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{window.URL.revokeObjectURL(i.src),n.next(i),n.complete()},i.onerror=()=>{e=null,window.URL.revokeObjectURL(i.src),n.error(new Error("Failed to load image tile"))};const r=new Blob([t]);i.src=window.URL.createObjectURL(r)}),(t=>{e=null,n.error(t)}))})),()=>{e&&e()}]}getURLs$(t,e){const i=this._inventId(t,e);if(this._urls$.has(i))return this._urls$.get(i);const n={imageId:t,z:e},r=this._api.getImageTiles$(n).pipe(rt((t=>t.node)),Me((()=>{this._urls$.delete(i)})),He(),E());return this._urls$.set(i,r),r}_inventId(t,e){return`${t}-${e}`}}class om{constructor(){this._tiles=new Map,this._urlLevels=new Set,this._urls=new Map}add(t,e){if(this._tiles.has(t))throw new Error(`Image tile already stored (${t})`);this._tiles.set(t,e)}addURLs(t,e){const i=this._urls;for(const t of e){const e=this.inventId(t);if(this._urls.has(e))throw new Error(`URL already stored (${e})`);i.set(e,t.url)}this._urlLevels.add(t)}dispose(){this._tiles.forEach((t=>window.URL.revokeObjectURL(t.src))),this._tiles.clear(),this._urls.clear(),this._urlLevels.clear()}get(t){return this._tiles.get(t)}getURL(t){return this._urls.get(t)}has(t){return this._tiles.has(t)}hasURL(t){return this._urls.has(t)}hasURLLevel(t){return this._urlLevels.has(t)}inventId(t){return`${t.z}-${t.x}-${t.y}`}}class am{constructor(){this._viewportCoords=new Wf}computeRegionOfInterest(t,e,i){const n=this._viewportBoundaryPoints(4),r=this._viewportPointsBoundingBox(n,t,i);this._clipBoundingBox(r);const s=2/e.width,o=2/e.height,a=[[-.5*s,.5*o],[.5*s,.5*o],[.5*s,-.5*o],[-.5*s,-.5*o]],c=this._viewportPointsBoundingBox(a,t,i),h=c.minX<c.maxX;return{bbox:r,pixelHeight:c.maxY-c.minY,pixelWidth:c.maxX-c.minX+(h?0:1)}}_viewportBoundaryPoints(t){const e=[],i=[[-1,1],[1,1],[1,-1],[-1,-1]],n=[[2,0],[0,-2],[-2,0],[0,2]];for(let r=0;r<4;++r){const s=i[r],o=n[r];for(let i=0;i<t;++i)e.push([s[0]+o[0]*i/t,s[1]+o[1]*i/t])}return e}_viewportPointsBoundingBox(t,e,i){const n=t.map((t=>this._viewportCoords.viewportToBasic(t[0],t[1],i,e.perspective)));return dd(i.cameraType)?this._boundingBoxSpherical(n):this._boundingBox(n)}_boundingBox(t){const e={maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY};for(let i=0;i<t.length;++i)e.minX=Math.min(e.minX,t[i][0]),e.maxX=Math.max(e.maxX,t[i][0]),e.minY=Math.min(e.minY,t[i][1]),e.maxY=Math.max(e.maxY,t[i][1]);return e}_boundingBoxSpherical(t){const e=[],i=[];for(let n=0;n<t.length;++n)e.push(t[n][0]),i.push(t[n][1]);e.sort(((t,e)=>this._sign(t-e))),i.sort(((t,e)=>this._sign(t-e)));const n=this._intervalSpherical(e);return{maxX:n[1],maxY:i[i.length-1],minX:n[0],minY:i[0]}}_intervalSpherical(t){let e=0,i=-1;for(let n=0;n<t.length-1;++n){const r=t[n+1]-t[n];r>e&&(e=r,i=n)}return t[0]+1-t[t.length-1]>e?[t[0],t[t.length-1]]:[t[i+1],t[i]]}_clipBoundingBox(t){t.minX=Math.max(0,Math.min(1,t.minX)),t.maxX=Math.max(0,Math.min(1,t.maxX)),t.minY=Math.max(0,Math.min(1,t.minY)),t.maxY=Math.max(0,Math.min(1,t.maxY))}_sign(t){return t>0?1:t<0?-1:0}}function cm(t,e,i){return Math.max(e,Math.min(i,t))}function hm(t){return 1024/lm(t)}function lm(t){return Math.pow(2,t.z-t.max)}function um(t){return Math.ceil(function(t){const e=Math.max(t.w,t.h);return Math.log(e)/Math.log(2)}(t))}function dm(t,e,i){const n=hm(i),r=e.w,s=e.h,o=Math.ceil(r/n)-1,a=Math.ceil(s/n)-1;return{x:cm(Math.floor(r*t[0]/n),0,o),y:cm(Math.floor(s*t[1]/n),0,a)}}function pm(t,e,i){const n=1024*(1/lm(i)),r=n*t.x,s=n*t.y,o=Math.min(n,e.w-r);return{h:Math.min(n,e.h-s),x:r,y:s,w:o}}function fm(t,e,i){return i*t<=e&&e<i*(t+1)}function mm(t,e){if(t.z===e.z)return t.x===e.x&&t.y===e.y;const i=t.z<e.z?t:e,n=t.z<e.z?e:t,r=1/lm({max:n.z,z:i.z}),s=fm(i.x,n.x,r),o=fm(i.y,n.y,r);return s&&o}function gm(t){return t.w>0&&t.h>0}class _m{constructor(t,e,i,n,r,s,o){const a={h:i,w:e};gm(a)||console.warn(`Original image size (${e}, ${i}) is invalid (${t}). Tiles will not be loaded.`),this._imageId=t,this._size=a,this._level={max:um(this._size),z:-1},this._holder=new Uf,this._updated$=new T,this._createdSubject$=new T,this._created$=this._createdSubject$.pipe(Ue(1),E()),this._holder.push(this._created$.subscribe((()=>{}))),this._hasSubject$=new T,this._has$=this._hasSubject$.pipe(ni(!1),Ue(1),E()),this._holder.push(this._has$.subscribe((()=>{}))),this._renderedLevel=new Set,this._rendered=new Map,this._subscriptions=new Map,this._urlSubscriptions=new Map,this._loader=r,this._store=s,this._background=n,this._renderer=o,this._aborts=[],this._render=null,this._disposed=!1}get disposed(){return this._disposed}get hasTexture$(){return this._has$}get id(){return this._imageId}get textureUpdated$(){return this._updated$}get textureCreated$(){return this._created$}abort(){this._subscriptions.forEach((t=>t.unsubscribe())),this._subscriptions.clear();for(const t of this._aborts)t();this._aborts=[]}dispose(){this._disposed?console.warn(`Texture already disposed (${this._imageId})`):(this._urlSubscriptions.forEach((t=>t.unsubscribe())),this._urlSubscriptions.clear(),this.abort(),null!=this._render&&(this._render.target.dispose(),this._render.target=null,this._render.camera=null,this._render=null),this._store.dispose(),this._holder.unsubscribe(),this._renderedLevel.clear(),this._background=null,this._renderer=null,this._disposed=!0)}setRegionOfInterest(t){if(!gm(this._size))return;const e=1/t.pixelWidth,i=function(t,e,i){return Math.max(e,Math.min(i,um(t)))}({h:1/t.pixelHeight,w:e},11,this._level.max);i!==this._level.z&&(this.abort(),this._level.z=i,this._renderedLevel.clear(),this._rendered.forEach(((t,e)=>{t.z===i&&this._renderedLevel.add(e)}))),null==this._render&&this._initRender();const n=function(t,e,i,n){const r=[];if(t.x>e.x){const s=hm(n),o=Math.ceil(i.w/s)-1;for(let e=t.x;e<=o;e++)r.push(e);for(let t=0;t<=e.x;t++)r.push(t)}else for(let i=t.x;i<=e.x;i++)r.push(i);const s=[];for(const i of r)for(let n=t.y;n<=e.y;n++)s.push({x:i,y:n});return s}(dm([t.bbox.minX,t.bbox.minY],this._size,this._level),dm([t.bbox.maxX,t.bbox.maxY],this._size,this._level),this._size,this._level);this._fetchTiles(i,n)}_fetchTile(t){const e=this._loader.getImage$(t.url),i=e[0],n=e[1];this._aborts.push(n);const r=this._store.inventId(t),s=i.subscribe((e=>{const i=pm(t,this._size,this._level);this._renderToTarget(i,e),this._subscriptions.delete(r),this._removeFromArray(n,this._aborts),this._markRendered(t),this._store.add(r,e),this._updated$.next(!0)}),(t=>{this._subscriptions.delete(r),this._removeFromArray(n,this._aborts),console.error(t)}));s.closed||this._subscriptions.set(r,s)}_fetchTiles(t,e){const i=(this._store.hasURLLevel(t)?G(void 0):this._loader.getURLs$(this._imageId,t).pipe(pi((e=>{this._store.hasURLLevel(t)||this._store.addURLs(t,e)})))).subscribe((()=>{if(t===this._level.z){for(const i of e){const e={x:i.x,y:i.y,z:t,url:null},n=this._store.inventId(e);if(!this._renderedLevel.has(n)&&!this._subscriptions.has(n))if(this._store.has(n)){const t=pm(i,this._size,this._level);this._renderToTarget(t,this._store.get(n)),this._markRendered(e),this._updated$.next(!0)}else e.url=this._store.getURL(n),this._fetchTile(e)}this._urlSubscriptions.delete(t)}}),(e=>{this._urlSubscriptions.delete(t),console.error(e)}));i.closed||this._urlSubscriptions.set(t,i)}_initRender(){const t=this._size.w/2,e=this._size.h/2,i=new Kl(-t,t,e,-e,-1,1);i.position.z=1;const n=this._renderer.getContext(),r=n.getParameter(n.MAX_TEXTURE_SIZE),s=Math.max(this._size.w,this._size.h),o=r>s?1:r/s,a=Math.floor(o*this._size.w),c=Math.floor(o*this._size.h),h=new dn(a,c,{depthBuffer:!1,format:ki,magFilter:Ai,minFilter:Ai,stencilBuffer:!1});this._render={camera:i,target:h};const l=pm({x:0,y:0},this._size,{max:this._level.max,z:0});this._renderToTarget(l,this._background),this._createdSubject$.next(h.texture),this._hasSubject$.next(!0)}_markRendered(t){const e=Array.from(this._rendered.entries()).filter((([e,i])=>i.z!==t.z));for(const[i,n]of e)mm(t,n)&&this._rendered.delete(i);const i=this._store.inventId(t);this._rendered.set(i,t),this._renderedLevel.add(i)}_removeFromArray(t,e){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}_renderToTarget(t,e){const i=new hn(e);i.minFilter=Ai,i.needsUpdate=!0;const n=new qs(t.w,t.h),r=new Fr({map:i,side:0}),s=new Es(n,r);s.position.x=-this._size.w/2+t.x+t.w/2,s.position.y=this._size.h/2-t.y-t.h/2;const o=new Qa;o.add(s);const a=this._renderer.getRenderTarget();this._renderer.resetState(),this._renderer.setRenderTarget(this._render.target),this._renderer.render(o,this._render.camera),this._renderer.setRenderTarget(a),o.remove(s),n.dispose(),r.dispose(),i.dispose()}}var vm,ym,bm,xm,wm,Sm;!function(t){t[t.Custom=0]="Custom",t[t.Earth=1]="Earth",t[t.Traversing=2]="Traversing",t[t.Waiting=3]="Waiting",t[t.WaitingInteractively=4]="WaitingInteractively"}(vm||(vm={}));class Mm extends Vf{constructor(t,e,i){super(t,e,i),this._imageTileLoader=new sm(i.api),this._roiCalculator=new am,this._rendererOperation$=new T,this._rendererCreator$=new T,this._rendererDisposer$=new T,this._renderer$=this._rendererOperation$.pipe(Le(((t,e)=>e(t)),null),Nt((t=>null!=t)),ue(void 0,(t=>t.frameId))),this._rendererCreator$.pipe(rt((()=>t=>{if(null!=t)throw new Error("Multiple image plane states can not be created at the same time");return new nm}))).subscribe(this._rendererOperation$),this._rendererDisposer$.pipe(rt((()=>t=>(t.dispose(),null)))).subscribe(this._rendererOperation$)}_activate(){const t=this._subscriptions;t.push(this._renderer$.pipe(rt((t=>{const e={name:this._name,renderer:{frameId:t.frameId,needsRender:t.needsRender,render:t.render.bind(t),pass:rm.Background}};return t.clearNeedsRender(),e}))).subscribe(this._container.glRenderer.render$)),this._rendererCreator$.next(null),t.push(this._navigator.stateService.currentState$.pipe(rt((t=>e=>(e.updateFrame(t),e)))).subscribe(this._rendererOperation$));const e=this._container.configurationService.imageTiling$.pipe(ri((t=>t?this._navigator.stateService.currentState$:new T)),ue(void 0,(t=>t.state.currentImage.id)),bi(this._container.glRenderer.webGLRenderer$),rt((([t,e])=>{const i=t.state,n=i.currentImage,r=i.currentTransform;return new _m(n.id,r.basicWidth,r.basicHeight,n.image,this._imageTileLoader,new om,e)})),Ue(1),E());t.push(e.subscribe((()=>{}))),t.push(e.pipe(rt((t=>e=>(e.setTextureProvider(t.id,t),e)))).subscribe(this._rendererOperation$)),t.push(e.pipe(ze()).subscribe((t=>{t[0].abort()})));const i=this._container.configurationService.imageTiling$.pipe(ri((t=>t?gt(this._navigator.stateService.state$,this._navigator.stateService.inTranslation$):new T)),ri((([t,e])=>(t===vm.Traversing||t===vm.Waiting||t===vm.WaitingInteractively)&&!e?this._container.renderService.renderCameraFrame$:B())),rt((t=>({camera:t,height:t.size.height.valueOf(),lookat:t.camera.lookat.clone(),width:t.size.width.valueOf(),zoom:t.zoom.valueOf()}))),ze(),rt((([t,e])=>{const i=t.width===e.width&&t.height===e.height&&t.zoom===e.zoom&&t.lookat.equals(e.lookat);return{camera:e.camera,stalled:i}})),ue(((t,e)=>t.stalled===e.stalled)),Nt((t=>t.stalled)),bi(this._container.renderService.size$,this._navigator.stateService.currentTransform$));t.push(e.pipe(ri((t=>i.pipe(rt((([e,i,n])=>{const r=e.camera,s=(new Wf).viewportToBasic(0,0,n,r.perspective);if(!(s[0]<0||s[1]<0||s[0]>1||s[1]>1))return[this._roiCalculator.computeRegionOfInterest(r,i,n),t]})),Nt((t=>!!t))))),Nt((t=>!t[1].disposed))).subscribe((([t,e])=>{e.setRegionOfInterest(t)})));const n=e.pipe(ri((t=>t.hasTexture$)),ni(!1),Ue(1),E());t.push(n.subscribe((()=>{}))),t.push(this._navigator.panService.panImages$.pipe(Nt((t=>0===t.length)),rt((()=>t=>(t.clearPeripheryPlanes(),t)))).subscribe(this._rendererOperation$));const r=this._navigator.panService.panImages$.pipe(ri((t=>bt(t).pipe(Mt((([t,e])=>gt(this._navigator.graphService.cacheImage$(t.id).pipe(te((e=>(console.error(`Failed to cache periphery image (${t.id})`,e),B())))),G(e))))))),Ze());t.push(r.pipe(rt((([t,e])=>i=>(i.addPeripheryPlane(t,e),i)))).subscribe(this._rendererOperation$)),t.push(r.pipe(Mt((([t])=>t.cacheImage$().pipe(te((()=>B()))))),rt((t=>e=>(e.updateTextureImage(t.image,t),e)))).subscribe(this._rendererOperation$));const s=this._navigator.stateService.currentState$.pipe(rt((t=>t.state.alpha<1)),ue()),o=gt(this._container.mouseService.active$,this._container.touchService.active$,this._navigator.stateService.inMotion$,s).pipe(rt((([t,e,i,n])=>!(t||e||i||n))),Nt((t=>t)));t.push(this._navigator.stateService.state$.pipe(ri((t=>t===vm.Traversing?this._navigator.panService.panImages$:B())),ri((t=>o.pipe(bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentImage$,this._navigator.stateService.currentTransform$),Mt((([,e,i,n])=>G([e,i,n,t])))))),ri((([t,e,i,n])=>{const r=t.camera.lookat.clone().sub(t.camera.position),s=[(new ld).viewingDirection(e.rotation).angleTo(r),void 0],o=(new Wf).viewportToBasic(0,0,i,t.perspective);o[0]>=0&&o[0]<=1&&o[1]>=0&&o[1]<=1&&(s[0]=Number.NEGATIVE_INFINITY);for(const[t]of n){const e=(new ld).viewingDirection(t.rotation).angleTo(r);e<s[0]&&(s[0]=e,s[1]=t.id)}return s[1]?this._navigator.moveTo$(s[1]).pipe(te((()=>B()))):B()}))).subscribe())}_deactivate(){this._rendererDisposer$.next(null),this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}}Mm.componentName="image";class Tm{constructor(t,e,i){this._component=t,this._container=e,this._navigator=i,this._enabled=!1}get isEnabled(){return this._enabled}enable(){!this._enabled&&this._component.activated&&(this._enable(),this._enabled=!0,this._component.configure(this._getConfiguration(!0)))}disable(){this._enabled&&(this._disable(),this._enabled=!1,this._component.activated&&this._component.configure(this._getConfiguration(!1)))}}class Cm extends Tm{_enable(){const e=this._navigator.stateService.currentImage$.pipe(ri((t=>t.sequenceEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(bi(e)).subscribe((([e,i])=>{let n=null;switch(e.keyCode){case 38:n=t.NavigationDirection.Next;break;case 40:n=t.NavigationDirection.Prev;break;default:return}if(e.preventDefault(),e.altKey&&!e.shiftKey&&i.cached)for(const t of i.edges)if(t.data.direction===n)return void this._navigator.moveTo$(t.target).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(t){return{keySequenceNavigation:t}}}class Em extends Tm{constructor(t,e,i,n){super(t,e,i),this._spatial=n}_enable(){const e=this._navigator.stateService.currentImage$.pipe(ri((t=>t.spatialEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(bi(e,this._navigator.stateService.currentState$)).subscribe((([e,i,n])=>{let r=dd(n.state.currentImage.cameraType),s=null;switch(e.keyCode){case 37:s=e.shiftKey&&!r?t.NavigationDirection.TurnLeft:t.NavigationDirection.StepLeft;break;case 38:s=e.shiftKey&&!r?t.NavigationDirection.Spherical:t.NavigationDirection.StepForward;break;case 39:s=e.shiftKey&&!r?t.NavigationDirection.TurnRight:t.NavigationDirection.StepRight;break;case 40:s=e.shiftKey&&!r?t.NavigationDirection.TurnU:t.NavigationDirection.StepBackward;break;default:return}if(e.preventDefault(),!(e.altKey||!i.cached||e.shiftKey&&r))if(r){const e={};e[t.NavigationDirection.StepBackward]=Math.PI,e[t.NavigationDirection.StepForward]=0,e[t.NavigationDirection.StepLeft]=Math.PI/2,e[t.NavigationDirection.StepRight]=-Math.PI/2;const r=this._rotationFromCamera(n.state.camera).phi,o=this._spatial.wrapAngle(r+e[s]),a=Math.PI/4,c=i.edges.filter((e=>e.data.direction===t.NavigationDirection.Spherical||e.data.direction===s));let h=Number.MAX_VALUE,l=null;for(const t of c){const e=Math.abs(this._spatial.wrapAngle(t.data.worldMotionAzimuth-o));e<Math.min(h,a)&&(h=e,l=t.target)}if(null==l)return;this._moveTo(l)}else this._moveDir(s,i)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(t){return{keySpatialNavigation:t}}_moveDir(t,e){for(const i of e.edges)if(i.data.direction===t)return void this._moveTo(i.target)}_moveTo(t){this._navigator.moveTo$(t).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}_rotationFromCamera(t){let e=t.lookat.clone().sub(t.position),i=e.clone().dot(t.up),n=e.clone().sub(t.up.clone().multiplyScalar(i));return{phi:Math.atan2(n.y,n.x),theta:Math.PI/2-this._spatial.angleToPlane(e.toArray(),[0,0,1])}}}class Im extends Tm{constructor(t,e,i,n){super(t,e,i),this._viewportCoords=n}_enable(){this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([t,e,i])=>{if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0;switch(t.key){case"+":n=1;break;case"-":n=-1;break;default:return}t.preventDefault();const r=this._viewportCoords.unprojectFromViewport(0,0,e.perspective),s=i.projectBasic(r.toArray());this._navigator.stateService.zoomIn(n,s)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(t){return{keyZoom:t}}}class Am extends Tm{_enable(){this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(bi(this._navigator.playService.playing$,this._navigator.playService.direction$,this._navigator.playService.speed$,this._navigator.stateService.currentImage$.pipe(ri((t=>t.sequenceEdges$))),this._navigator.stateService.state$.pipe(rt((t=>t===vm.Earth)),ue()))).subscribe((([e,i,n,r,s,o])=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){switch(e.key){case"D":if(!e.shiftKey)return;const a=i?null:n===t.NavigationDirection.Next?t.NavigationDirection.Prev:n===t.NavigationDirection.Prev?t.NavigationDirection.Next:null;null!=a&&this._navigator.playService.setDirection(a);break;case" ":if(e.shiftKey)return;if(!o)if(i)this._navigator.playService.stop();else for(let t of s.edges)t.data.direction===n&&this._navigator.playService.play();break;case"<":this._navigator.playService.setSpeed(r-.05);break;case">":this._navigator.playService.setSpeed(r+.05);break;default:return}e.preventDefault()}}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(t){return{keyPlay:t}}}class Pm extends Vf{constructor(t,e,i){super(t,e,i),this._keyPlayHandler=new Am(this,e,i),this._keySequenceNavigationHandler=new Cm(this,e,i),this._keySpatialNavigationHandler=new Em(this,e,i,new ld),this._keyZoomHandler=new Im(this,e,i,new Wf)}get keyPlay(){return this._keyPlayHandler}get keySequenceNavigation(){return this._keySequenceNavigationHandler}get keySpatialNavigation(){return this._keySpatialNavigationHandler}get keyZoom(){return this._keyZoomHandler}_activate(){this._subscriptions.push(this._configuration$.subscribe((t=>{t.keyPlay?this._keyPlayHandler.enable():this._keyPlayHandler.disable(),t.keySequenceNavigation?this._keySequenceNavigationHandler.enable():this._keySequenceNavigationHandler.disable(),t.keySpatialNavigation?this._keySpatialNavigationHandler.enable():this._keySpatialNavigationHandler.disable(),t.keyZoom?this._keyZoomHandler.enable():this._keyZoomHandler.disable()})))}_deactivate(){this._subscriptions.unsubscribe(),this._keyPlayHandler.disable(),this._keySequenceNavigationHandler.disable(),this._keySpatialNavigationHandler.disable(),this._keyZoomHandler.disable()}_getDefaultConfiguration(){return{keyPlay:!0,keySequenceNavigation:!0,keySpatialNavigation:!0,keyZoom:!0}}}Pm.componentName="keyboard";class Rm{constructor(t,e){this._needsRender=!1,this._interactiveObjects=[],this._markers={},this._objectMarkers={},this._raycaster=e||new Bu,this._scene=t||new Qa}get markers(){return this._markers}get needsRender(){return this._needsRender}add(t,e){t.id in this._markers&&this._dispose(t.id),t.createGeometry(e),this._scene.add(t.geometry),this._markers[t.id]=t;for(let e of t.getInteractiveObjects())this._interactiveObjects.push(e),this._objectMarkers[e.uuid]=t.id;this._needsRender=!0}clear(){for(const t in this._markers)this._markers.hasOwnProperty&&this._dispose(t);this._needsRender=!0}get(t){return this._markers[t]}getAll(){return Object.keys(this._markers).map((t=>this._markers[t]))}has(t){return t in this._markers}intersectObjects([t,e],i){this._raycaster.setFromCamera(new rn(t,e),i);const n=this._raycaster.intersectObjects(this._interactiveObjects);for(const t of n)if(t.object.uuid in this._objectMarkers)return this._objectMarkers[t.object.uuid];return null}lerpAltitude(t,e,i){t in this._markers&&(this._markers[t].lerpAltitude(e,i),this._needsRender=!0)}remove(t){t in this._markers&&(this._dispose(t),this._needsRender=!0)}render(t,e){e.render(this._scene,t),this._needsRender=!1}update(t,e,i){if(!(t in this._markers))return;this._markers[t].updatePosition(e,i),this._needsRender=!0}_dispose(t){const e=this._markers[t];this._scene.remove(e.geometry);for(let i of e.getInteractiveObjects()){const e=this._interactiveObjects.indexOf(i);-1!==e?this._interactiveObjects.splice(e,1):console.warn(`Object does not exist (${i.id}) for ${t}`),delete this._objectMarkers[i.uuid]}e.disposeGeometry(),delete this._markers[t]}}class Lm extends Vf{constructor(t,e,i){super(t,e,i),this._graphCalculator=new td,this._markerScene=new Rm,this._markerSet=new yd,this._viewportCoords=new Wf,this._relativeGroundAltitude=-2}add(t){this._markerSet.add(t)}fire(t,e){super.fire(t,e)}get(t){return this._markerSet.get(t)}getAll(){return this._markerSet.getAll()}getMarkerIdAt(t){return new Promise(((e,i)=>{this._container.renderService.renderCamera$.pipe(Ee(),rt((e=>{const i=this._viewportCoords.canvasToViewport(t[0],t[1],this._container.container);return this._markerScene.intersectObjects(i,e.perspective)}))).subscribe((t=>{e(t)}),(t=>{i(t)}))}))}has(t){return this._markerSet.has(t)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}remove(t){this._markerSet.remove(t)}removeAll(){this._markerSet.removeAll()}_activate(){const t=this._navigator.stateService.currentState$.pipe(rt((t=>t.state.camera.position.z+this._relativeGroundAltitude)),ue(((t,e)=>Math.abs(t-e)<.01)),Ue(1),E()),e=gt(t,this._navigator.stateService.reference$).pipe(Ee(),rt((()=>{})),Ue(1),E()),i=this._configuration$.pipe(rt((t=>({visibleBBoxSize:Math.max(1,Math.min(200,t.visibleBBoxSize))})))),n=this._navigator.stateService.currentImage$.pipe(rt((t=>t.lngLat)),Ue(1),E()),r=gt(i,n).pipe(rt((([t,e])=>this._graphCalculator.boundingBoxCorners(e,t.visibleBBoxSize/2))),Ue(1),E()),s=gt(At(G(this._markerSet),this._markerSet.changed$),r).pipe(rt((([t,e])=>t.search(e)))),o=this._subscriptions;o.push(e.pipe(ri((()=>s.pipe(bi(this._navigator.stateService.reference$,t))))).subscribe((([t,e,i])=>{const n=this._markerScene,r=n.markers,s=Object.assign({},r);for(const o of t)if(o.id in r)delete s[o.id];else{const t=Ju(o.lngLat.lng,o.lngLat.lat,e.alt+i,e.lng,e.lat,e.alt);n.add(o,t)}for(const t in s)s.hasOwnProperty(t)&&n.remove(t)}))),o.push(e.pipe(ri((()=>this._markerSet.updated$.pipe(bi(r,this._navigator.stateService.reference$,t))))).subscribe((([t,[e,i],n,r])=>{const s=this._markerScene;for(const o of t){const t=s.has(o.id),a=o.lngLat.lat>e.lat&&o.lngLat.lat<i.lat&&o.lngLat.lng>e.lng&&o.lngLat.lng<i.lng;if(a){const t=Ju(o.lngLat.lng,o.lngLat.lat,n.alt+r,n.lng,n.lat,n.alt);s.add(o,t)}else!a&&t&&s.remove(o.id)}}))),o.push(this._navigator.stateService.reference$.pipe(Je(1),bi(t)).subscribe((([t,e])=>{const i=this._markerScene;for(const n of i.getAll()){const r=Ju(n.lngLat.lng,n.lngLat.lat,t.alt+e,t.lng,t.lat,t.alt);i.update(n.id,r)}}))),o.push(t.pipe(Je(1),bi(this._navigator.stateService.reference$,n)).subscribe((([t,e,i])=>{const n=this._markerScene,r=Ju(i.lng,i.lat,e.alt+t,e.lng,e.lat,e.alt);for(const i of n.getAll()){const s=Ju(i.lngLat.lng,i.lngLat.lat,e.alt+t,e.lng,e.lat,e.alt),o=s[0]-r[0],a=s[1]-r[1],c=Math.sqrt(o*o+a*a);c>50||n.lerpAltitude(i.id,t,Math.min(1,Math.max(0,1.2-1.2*c/50)))}}))),o.push(this._navigator.stateService.currentState$.pipe(rt((t=>{const e=this._markerScene;return{name:this._name,renderer:{frameId:t.id,needsRender:e.needsRender,render:e.render.bind(e),pass:rm.Opaque}}}))).subscribe(this._container.glRenderer.render$));const a=gt(this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$).pipe(rt((([t,e])=>{const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(e,i),s=this._viewportCoords.canvasToViewport(n,r,i);return this._markerScene.intersectObjects(s,t.perspective)})),Ue(1),E()),c=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(rt((()=>!0))),h=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragEnd$).pipe(rt((()=>!1))),l=Ot(c,h).pipe(ni(!1));o.push(Ot(c.pipe(bi(a)),gt(h,G(null))).pipe(ni([!1,null]),ze()).subscribe((([t,e])=>{const i=e[0],n=i?"markerdragstart":"markerdragend",r=i?e[1]:t[1],s={marker:this._markerScene.get(r),target:this,type:n};this.fire(n,s)})));const u=Ot(this._container.mouseService.mouseDown$.pipe(rt((()=>!0))),this._container.mouseService.documentMouseUp$.pipe(rt((()=>!1)))).pipe(ni(!1));o.push(gt(this._container.mouseService.active$,a.pipe(ue()),u,l).pipe(rt((([t,e,i,n])=>!t&&null!=e&&i||n)),ue()).subscribe((t=>{t?(this._container.mouseService.claimMouse(this._name,1),this._container.mouseService.claimWheel(this._name,1)):(this._container.mouseService.unclaimMouse(this._name),this._container.mouseService.unclaimWheel(this._name))})));const d=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(bi(a,this._container.renderService.renderCamera$),rt((([t,e,i])=>{const n=this._markerScene.get(e),r=this._container.container,[s,o]=this._viewportCoords.projectToCanvas(n.geometry.position.toArray(),r,i.perspective),[a,c]=this._viewportCoords.canvasPosition(t,r);return[n,[a-s,c-o],i]})),Ue(1),E());o.push(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$).pipe(bi(d,this._navigator.stateService.reference$,i)).subscribe((([t,[e,i,n],r,s])=>{if(!this._markerScene.has(e.id))return;const o=this._container.container,[a,c]=this._viewportCoords.canvasPosition(t,o),h=a-i[0],l=c-i[1],[u,d]=this._viewportCoords.canvasToViewport(h,l,o),p=new fn(u,d,1).unproject(n.perspective).sub(n.perspective.position).normalize(),f=Math.min(this._relativeGroundAltitude/p.z,s.visibleBBoxSize/2-.1);if(f<0)return;const m=p.clone().multiplyScalar(f).add(n.perspective.position);m.z=n.perspective.position.z+this._relativeGroundAltitude;const[g,_]=Ku(m.x,m.y,m.z,r.lng,r.lat,r.alt);this._markerScene.update(e.id,m.toArray(),{lat:_,lng:g}),this._markerSet.update(e);const v="markerposition",y={marker:e,target:this,type:v};this.fire(v,y)})))}_deactivate(){this._subscriptions.unsubscribe(),this._markerScene.clear()}_getDefaultConfiguration(){return{visibleBBoxSize:100}}}function Om(t,e){return t.x<=Math.max(e.p1.x,e.p2.x)&&t.x>=Math.min(e.p1.x,e.p2.x)&&t.y>=Math.max(e.p1.y,e.p2.y)&&t.y>=Math.min(e.p1.y,e.p2.y)}function Nm(t,e){const i=t.p2.x-t.p1.x,n=t.p2.y-t.p1.y,r=e.p2.x-e.p1.x,s=e.p2.y-e.p1.y,o=i*s-n*r;return o*o<1e-10*(i*i+n*n)*(r*r+s*s)}function Dm(t,e,i){const n=(e.y-t.y)*(i.x-e.x)-(i.y-e.y)*(e.x-t.x);return(r=n)>0?1:r<0?-1:0;var r}function $m(t,e){if(Nm(t,e))return!1;const i=Dm(t.p1,t.p2,e.p1),n=Dm(t.p1,t.p2,e.p2),r=Dm(e.p1,e.p2,t.p1),s=Dm(e.p1,e.p2,t.p2);return i!==n&&r!==s||(!(0!==i||!Om(e.p1,t))||(!(0!==n||!Om(e.p2,t))||(!(0!==r||!Om(t.p1,e))||!(0!==s||!Om(t.p2,e)))))}function km(t,e){if(Nm(t,e))return;const i=t.p1.x,n=t.p2.x,r=t.p1.y,s=t.p2.y,o=e.p1.x,a=e.p2.x,c=e.p1.y,h=e.p2.y,l=(i-n)*(c-h)-(r-s)*(o-a);return{x:((i*s-r*n)*(o-a)-(i-n)*(o*h-c*a))/l,y:((i*s-r*n)*(c-h)-(r-s)*(o*h-c*a))/l}}function zm(t,e){return t>=-1&&t<=1&&e>=-1&&e<=1}function Fm(t,e){return t>=0&&t<=1&&e>=0&&e<=1}function Bm(t,e,i){const n=function(t){let e=[],i=[[0,0],[1,0],[1,1],[0,1]],n=[[1,0],[0,1],[-1,0],[0,-1]];for(let r=0;r<4;++r){let s=i[r],o=n[r];for(let i=0;i<t;++i)e.push([s[0]+o[0]*i/t,s[1]+o[1]*i/t])}return e}(100).map((n=>i.basicToViewportSafe(n[0],n[1],t,e))),r=[],s=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}],o=[!1,!1,!1,!1];for(let t=0;t<n.length;t++){const e=n[t],i=n[(t+1)%n.length];if(null===e)continue;if(null===i){zm(e[0],e[1])&&r.push(e);continue}const[a,c]=e,[h,l]=i;if(zm(a,c))if(zm(h,l))r.push(e);else for(let t=0;t<4;t++){const i={p1:{x:a,y:c},p2:{x:h,y:l}},n={p1:s[t],p2:s[(t+1)%4]};if($m(i,n)){const s=km(i,n);r.push(e,[s.x,s.y]),o[t]=!0}}}const[a,c]=i.viewportToBasic(-1,1,t,e),[h,l]=i.viewportToBasic(1,1,t,e),[u,d]=i.viewportToBasic(1,-1,t,e),[p,f]=i.viewportToBasic(-1,-1,t,e);Fm(a,c)&&(o[3]=o[0]=!0),Fm(h,l)&&(o[0]=o[1]=!0),Fm(u,d)&&(o[1]=o[2]=!0),Fm(p,f)&&(o[2]=o[3]=!0);const m=[-1,-1,1,1];for(let t of r){const e=t[0],i=t[1];e>m[1]&&(m[1]=e),e<m[3]&&(m[3]=e),i>m[0]&&(m[0]=i),i<m[2]&&(m[2]=i)}const g=[1,1,-1,-1],_=[];for(let t=0;t<4;t++)o[t]?_.push(0):_.push(Math.abs(g[t]-m[t]));return _}Lm.componentName="marker";class jm extends Tm{constructor(t,e,i,n,r){super(t,e,i),this._spatial=r,this._viewportCoords=n}_enable(){const t=this._navigator.stateService.currentState$.pipe(rt((t=>t.state.alpha<1)),ue());this._bounceSubscription=gt(t,this._navigator.stateService.inTranslation$,this._container.mouseService.active$,this._container.touchService.active$).pipe(rt((t=>t[0]||t[1]||t[2]||t[3])),ue(),ri((t=>t?B():gt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$.pipe(Ee())))),bi(this._navigator.panService.panImages$)).subscribe((([[t,e],i])=>{if(!e.hasValidScale&&t.camera.focal<.1)return;if(0===t.perspective.aspect||t.perspective.aspect===Number.POSITIVE_INFINITY)return;const n=Bm(e,t.perspective,this._viewportCoords),r=this._viewportCoords.viewportToBasic(0,0,e,t.perspective);(r[0]<0||r[0]>1)&&i.length>0&&(n[0]=n[2]=0);for(const[,e]of i){const i=Bm(e,t.perspective,this._viewportCoords);for(let t=1;t<n.length;t+=2)i[t]<n[t]&&(n[t]=i[t])}if(Math.max(...n)<.01)return;const s=n[1]-n[3],o=n[0]-n[2],a=this._viewportCoords.unprojectFromViewport(0,0,t.perspective).sub(t.perspective.position),c=this._viewportCoords.unprojectFromViewport(s,0,t.perspective).sub(t.perspective.position),h=this._viewportCoords.unprojectFromViewport(0,o,t.perspective).sub(t.perspective.position);let l=(s>0?1:-1)*c.angleTo(a),u=(o>0?1:-1)*h.angleTo(a);const d=Math.PI/60;l=this._spatial.clamp(.1*l,-d,d),u=this._spatial.clamp(.1*u,-d,d),this._navigator.stateService.rotateUnbounded({phi:l,theta:u})}))}_disable(){this._bounceSubscription.unsubscribe()}_getConfiguration(){return{}}}class Hm{static filteredPairwiseMouseDrag$(t,e){return this._filteredPairwiseMouseDrag$(t,e,e.mouseDragStart$,e.mouseDrag$,e.mouseDragEnd$)}static filteredPairwiseMouseRightDrag$(t,e){return this._filteredPairwiseMouseDrag$(t,e,e.mouseRightDragStart$,e.mouseRightDrag$,e.mouseRightDragEnd$)}static _filteredPairwiseMouseDrag$(t,e,i,n,r){return e.filtered$(t,i).pipe(ri((i=>Ot(At(G(i),e.filtered$(t,n)),e.filtered$(t,r).pipe(rt((()=>null)))).pipe(li((t=>!!t)),ni(null)))),ze(),Nt((t=>null!=t[0]&&null!=t[1])))}}class Um extends Tm{constructor(t,e,i,n,r){super(t,e,i),this._spatial=r,this._viewportCoords=n}_enable(){let t=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragStart$).pipe(rt((()=>!0)),Ze()),e=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$).pipe(rt((()=>!1)),Ze());this._activeMouseSubscription=Ot(t,e).subscribe(this._container.mouseService.activate$);const i=Ot(t,e).pipe(ri((t=>t?this._container.mouseService.documentMouseMove$:B())));this._preventDefaultSubscription=Ot(i,this._container.touchService.touchMove$).subscribe((t=>{t.preventDefault()}));let n=this._container.touchService.singleTouchDragStart$.pipe(rt((()=>!0))),r=this._container.touchService.singleTouchDragEnd$.pipe(rt((()=>!1)));this._activeTouchSubscription=Ot(n,r).subscribe(this._container.touchService.activate$);const s=this._navigator.stateService.currentState$.pipe(rt((t=>dd(t.state.currentImage.cameraType)||t.state.imagesAhead<1)),ue(),ri((t=>{if(!t)return B();const e=Hm.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService),i=Ot(this._container.touchService.singleTouchDragStart$,this._container.touchService.singleTouchDrag$,this._container.touchService.singleTouchDragEnd$.pipe(rt((()=>null)))).pipe(rt((t=>null!=t&&t.touches.length>0?t.touches[0]:null)),ze(),Nt((t=>null!=t[0]&&null!=t[1])));return Ot(e,i)})),bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,this._navigator.panService.panImages$),rt((([t,e,i,n])=>{let r=t[0],s=t[1],o=s.clientX-r.clientX,a=s.clientY-r.clientY,c=this._container.container,[h,l]=this._viewportCoords.canvasPosition(s,c),u=this._viewportCoords.unprojectFromCanvas(h,l,c,e.perspective).sub(e.perspective.position),d=this._viewportCoords.unprojectFromCanvas(h-o,l,c,e.perspective).sub(e.perspective.position),p=this._viewportCoords.unprojectFromCanvas(h,l-a,c,e.perspective).sub(e.perspective.position),f=(o>0?1:-1)*d.angleTo(u),m=(a>0?-1:1)*p.angleTo(u);const g=Bm(i,e.perspective,this._viewportCoords);for(const[,t]of n){const i=Bm(t,e.perspective,this._viewportCoords);for(let t=0;t<g.length;t++)i[t]<g[t]&&(g[t]=i[t])}return g[0]>0&&m<0&&(m/=Math.max(1,200*g[0])),g[2]>0&&m>0&&(m/=Math.max(1,200*g[2])),g[1]>0&&f<0&&(f/=Math.max(1,200*g[1])),g[3]>0&&f>0&&(f/=Math.max(1,200*g[3])),{phi:f,theta:m}})),Ze());var o;this._rotateWithoutInertiaSubscription=s.subscribe((t=>{this._navigator.stateService.rotateWithoutInertia(t)})),this._rotateSubscription=s.pipe(Le(((t,e)=>(this._drainBuffer(t),t.push([Date.now(),e]),t)),[]),(o=Ot(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$),this._container.touchService.singleTouchDragEnd$),function(t){return t.lift(new We(o))}),rt((t=>{const e=this._drainBuffer(t.slice()),i={phi:0,theta:0};for(const t of e)i.phi+=t[1].phi,i.theta+=t[1].theta;const n=e.length;n>0&&(i.phi/=n,i.theta/=n);const r=Math.PI/18;return i.phi=this._spatial.clamp(i.phi,-r,r),i.theta=this._spatial.clamp(i.theta,-r,r),i}))).subscribe((t=>{this._navigator.stateService.rotate(t)}))}_disable(){this._activeMouseSubscription.unsubscribe(),this._activeTouchSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._rotateSubscription.unsubscribe(),this._rotateWithoutInertiaSubscription.unsubscribe(),this._activeMouseSubscription=null,this._activeTouchSubscription=null,this._preventDefaultSubscription=null,this._rotateSubscription=null}_getConfiguration(t){return{dragPan:t}}_drainBuffer(t){const e=Date.now();for(;t.length>0&&e-t[0][0]>50;)t.shift();return t}}class Vm extends Tm{constructor(t,e,i,n,r){super(t,e,i),this._spatial=r,this._viewportCoords=n,this._subscriptions=new Uf}_enable(){const t=this._navigator.stateService.state$.pipe(rt((t=>t===vm.Earth)),Ue(1),E()),e=this._subscriptions;e.push(t.pipe(ri((t=>t?this._container.mouseService.mouseWheel$:B()))).subscribe((t=>{t.preventDefault()}))),e.push(t.pipe(ri((t=>t?Hm.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService).pipe(Nt((([t,e])=>!(t.ctrlKey&&e.ctrlKey)))):B())),bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$),rt((([[t,e],i,n])=>{const r=[0,0,1],s=[0,0,-2],o=this._planeIntersection(e,r,s,i.perspective,this._container.container),a=this._planeIntersection(t,r,s,i.perspective,this._container.container);if(!o||!a)return null;return(new fn).subVectors(o,a).multiplyScalar(-1).toArray()})),Nt((t=>!!t))).subscribe((t=>{this._navigator.stateService.truck(t)}))),e.push(t.pipe(ri((t=>t?Hm.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService).pipe(Nt((([t,e])=>t.ctrlKey&&e.ctrlKey))):B())),rt((([t,e])=>this._mousePairToRotation(t,e)))).subscribe((t=>{this._navigator.stateService.orbit(t)}))),e.push(t.pipe(ri((t=>t?Hm.filteredPairwiseMouseRightDrag$(this._component.name,this._container.mouseService).pipe(Nt((([t,e])=>!t.ctrlKey&&!e.ctrlKey))):B())),rt((([t,e])=>this._mousePairToRotation(t,e)))).subscribe((t=>{this._navigator.stateService.orbit(t)}))),e.push(t.pipe(ri((t=>t?this._container.mouseService.filteredWheel$(this._component.name,this._container.mouseService.mouseWheel$):B())),rt((t=>{let e=t.deltaY;1===t.deltaMode?e*=40:2===t.deltaMode&&(e*=800);return-e/this._viewportCoords.containerToCanvas(this._container.container)[1]}))).subscribe((t=>{this._navigator.stateService.dolly(t)})))}_disable(){this._subscriptions.unsubscribe()}_getConfiguration(){return{}}_eventToViewport(t,e){const i=this._viewportCoords.canvasPosition(t,e);return this._viewportCoords.canvasToViewport(i[0],i[1],e)}_mousePairToRotation(t,e){const[i,n]=this._eventToViewport(e,this._container.container),[r,s]=this._eventToViewport(t,this._container.container);return{phi:(r-i)*Math.PI,theta:(n-s)*Math.PI/2}}_planeIntersection(t,e,i,n,r){const[s,o]=this._viewportCoords.canvasPosition(t,r),a=this._viewportCoords.unprojectFromCanvas(s,o,r,n).sub(n.position).normalize();if(Math.abs(this._spatial.angleToPlane(a.toArray(),e))<Math.PI/90)return null;const c=n.position.clone(),h=(new fn).fromArray(e),l=(new fn).fromArray(i),u=(new fn).subVectors(l,c).dot(h)/a.clone().dot(h),d=(new fn).addVectors(c,a.multiplyScalar(u));return this._viewportCoords.worldToCamera(d.toArray(),n)[2]>0?null:d}}class Gm extends Tm{constructor(t,e,i,n){super(t,e,i),this._viewportCoords=n}_enable(){this._container.mouseService.claimWheel(this._component.name,0),this._preventDefaultSubscription=this._container.mouseService.mouseWheel$.subscribe((t=>{t.preventDefault()})),this._zoomSubscription=this._container.mouseService.filteredWheel$(this._component.name,this._container.mouseService.mouseWheel$).pipe(bi(this._navigator.stateService.currentState$,((t,e)=>[t,e])),Nt((t=>{let e=t[1].state;return dd(e.currentImage.cameraType)||e.imagesAhead<1})),rt((t=>t[0])),bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,((t,e,i)=>[t,e,i]))).subscribe((t=>{let e=t[0],i=t[1],n=t[2],r=this._container.container,[s,o]=this._viewportCoords.canvasPosition(e,r),a=this._viewportCoords.unprojectFromCanvas(s,o,r,i.perspective),c=n.projectBasic(a.toArray()),h=e.deltaY;1===e.deltaMode?h*=40:2===e.deltaMode&&(h*=800);let l=-3*h/this._viewportCoords.containerToCanvas(r)[1];this._navigator.stateService.zoomIn(l,c)}))}_disable(){this._container.mouseService.unclaimWheel(this._component.name),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(t){return{scrollZoom:t}}}class qm extends Tm{constructor(t,e,i,n){super(t,e,i),this._viewportCoords=n}_enable(){this._preventDefaultSubscription=this._container.touchService.pinch$.subscribe((t=>{t.originalEvent.preventDefault()}));let t=this._container.touchService.pinchStart$.pipe(rt((t=>!0))),e=this._container.touchService.pinchEnd$.pipe(rt((t=>!1)));this._activeSubscription=Ot(t,e).subscribe(this._container.touchService.activate$),this._zoomSubscription=this._container.touchService.pinch$.pipe(bi(this._navigator.stateService.currentState$),Nt((t=>{let e=t[1].state;return dd(e.currentImage.cameraType)||e.imagesAhead<1})),rt((t=>t[0])),bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([t,e,i])=>{let n=this._container.container,[r,s]=this._viewportCoords.canvasPosition(t,n),o=this._viewportCoords.unprojectFromCanvas(r,s,n,e.perspective),a=i.projectBasic(o.toArray());const[c,h]=this._viewportCoords.containerToCanvas(n);let l=3*t.distanceChange/Math.min(c,h);this._navigator.stateService.zoomIn(l,a)}))}_disable(){this._activeSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(t){return{touchZoom:t}}}class Wm extends Vf{constructor(t,e,i){super(t,e,i);const n=new ld,r=new Wf;this._bounceHandler=new jm(this,e,i,r,n),this._dragPanHandler=new Um(this,e,i,r,n),this._earthControlHandler=new Vm(this,e,i,r,n),this._scrollZoomHandler=new Gm(this,e,i,r),this._touchZoomHandler=new qm(this,e,i,r)}get dragPan(){return this._dragPanHandler}get earthControl(){return this._earthControlHandler}get scrollZoom(){return this._scrollZoomHandler}get touchZoom(){return this._touchZoomHandler}_activate(){this._bounceHandler.enable(),this._subscriptions.push(this._configuration$.subscribe((t=>{t.dragPan?this._dragPanHandler.enable():this._dragPanHandler.disable(),t.earthControl?this._earthControlHandler.enable():this._earthControlHandler.disable(),t.scrollZoom?this._scrollZoomHandler.enable():this._scrollZoomHandler.disable(),t.touchZoom?this._touchZoomHandler.enable():this._touchZoomHandler.disable()}))),this._container.mouseService.claimMouse(this._name,0)}_deactivate(){this._container.mouseService.unclaimMouse(this._name),this._subscriptions.unsubscribe(),this._bounceHandler.disable(),this._dragPanHandler.disable(),this._earthControlHandler.disable(),this._scrollZoomHandler.disable(),this._touchZoomHandler.disable()}_getDefaultConfiguration(){return{dragPan:!0,earthControl:!0,scrollZoom:!0,touchZoom:!0}}}Wm.componentName="pointer";class Xm{constructor(t){this._document=t||document}get document(){return this._document}createElement(t,e,i){const n=this._document.createElement(t);return e&&(n.className=e),i&&i.appendChild(n),n}}class Ym extends Vf{constructor(t,e,i,n){super(t,e,i),this._dom=n||new Xm,this._popups=[],this._added$=new T,this._popups$=new T}add(t){for(const e of t)-1===this._popups.indexOf(e)&&(this._popups.push(e),this._activated&&e.setParentContainer(this._popupContainer));this._added$.next(t),this._popups$.next(this._popups)}getAll(){return this._popups.slice()}remove(t){for(const e of t)this._remove(e);this._popups$.next(this._popups)}removeAll(){for(const t of this._popups.slice())this._remove(t);this._popups$.next(this._popups)}_activate(){this._popupContainer=this._dom.createElement("div","mapillary-popup-container",this._container.container);for(const t of this._popups)t.setParentContainer(this._popupContainer);const t=this._subscriptions;t.push(gt(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$).subscribe((([t,e,i])=>{for(const n of this._popups)n.update(t,e,i)})));const e=this._popups$.pipe(ni(this._popups),ri((t=>bt(t).pipe(Mt((t=>t.changed$))))),rt((t=>[t])));t.push(Ot(this._added$,e).pipe(bi(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$)).subscribe((([t,e,i,n])=>{for(const r of t)r.update(e,i,n)})))}_deactivate(){this._subscriptions.unsubscribe();for(const t of this._popups)t.remove();this._container.container.removeChild(this._popupContainer),delete this._popupContainer}_getDefaultConfiguration(){return{}}_remove(t){const e=this._popups.indexOf(t);if(-1===e)return;const i=this._popups.splice(e,1)[0];this._activated&&i.remove()}}Ym.componentName="popup",function(t){t[t.Sequence=0]="Sequence",t[t.Spatial=1]="Spatial"}(ym||(ym={})),function(t){t[t.Default=0]="Default",t[t.Playback=1]="Playback",t[t.Timeline=2]="Timeline"}(bm||(bm={}));class Zm{constructor(t){this._container=t,this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820,this._stepperDefaultWidth=108,this._controlsDefaultWidth=88,this._defaultHeight=30,this._expandControls=!1,this._mode=bm.Default,this._speed=.5,this._changingSpeed=!1,this._index=null,this._changingPosition=!1,this._mouseEnterDirection$=new T,this._mouseLeaveDirection$=new T,this._notifyChanged$=new T,this._notifyChangingPositionChanged$=new T,this._notifySpeedChanged$=new T,this._notifyIndexChanged$=new T}get changed$(){return this._notifyChanged$}get changingPositionChanged$(){return this._notifyChangingPositionChanged$}get speed$(){return this._notifySpeedChanged$}get index$(){return this._notifyIndexChanged$}get mouseEnterDirection$(){return this._mouseEnterDirection$}get mouseLeaveDirection$(){return this._mouseLeaveDirection$}activate(){this._changingSubscription||(this._changingSubscription=Ot(this._container.mouseService.documentMouseUp$,this._container.touchService.touchEnd$.pipe(Nt((t=>0===t.touches.length)))).subscribe((()=>{this._changingSpeed&&(this._changingSpeed=!1),this._changingPosition&&this._setChangingPosition(!1)})))}deactivate(){this._changingSubscription&&(this._changingSpeed=!1,this._changingPosition=!1,this._expandControls=!1,this._mode=bm.Default,this._changingSubscription.unsubscribe(),this._changingSubscription=null)}render(t,e,i,n,r,s,o,a,c){if(!1===e.visible)return jf.h("div.mapillary-sequence-container",{},[]);const h=this._createStepper(t,e,o,i,a,c),l=this._createSequenceControls(i),u=this._createPlaybackControls(i,n,a,e),d=this._createTimelineControls(i,r,s);return jf.h("div.mapillary-sequence-container",[h,l,u,d])}getContainerWidth(t,e){let i=e.minWidth,n=e.maxWidth;n<i&&(n=i);let r=(t.width-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),s=(t.height-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight);return i+Math.max(0,Math.min(1,Math.min(r,s)))*(n-i)}_createPositionInput(t,e){this._index=t;const i=t=>{this._index=Number(t.target.value),this._notifyIndexChanged$.next(this._index)},n=this._container.domContainer.getBoundingClientRect(),r=t=>{t.stopPropagation(),this._setChangingPosition(!0)},s=t=>{!0===this._changingPosition&&t.stopPropagation()},o={max:null!=e?e:1,min:0,onchange:i,oninput:i,onkeydown:t=>{"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key&&"ArrowUp"!==t.key||t.preventDefault()},onpointerdown:r,onpointermove:s,ontouchmove:s,ontouchstart:r,style:{width:`${Math.max(276,Math.min(410,5+.8*n.width))-65}px`},type:"range",value:null!=t?t:0},a=null==t||null==e||e<=1;a&&(o.disabled="true");const c=jf.h("input.mapillary-sequence-position",o,[]),h=a?".mapillary-sequence-position-container-inactive":".mapillary-sequence-position-container";return jf.h("div"+h,[c])}_createSpeedInput(t){this._speed=t;const e=t=>{this._speed=Number(t.target.value)/1e3,this._notifySpeedChanged$.next(this._speed)},i=this._container.domContainer.getBoundingClientRect(),n=Math.max(276,Math.min(410,5+.8*i.width))-160,r=t=>{this._changingSpeed=!0,t.stopPropagation()},s=t=>{!0===this._changingSpeed&&t.stopPropagation()},o=jf.h("input.mapillary-sequence-speed",{max:1e3,min:0,onchange:e,oninput:e,onkeydown:t=>{"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key&&"ArrowUp"!==t.key||t.preventDefault()},onpointerdown:r,onpointermove:s,ontouchmove:s,ontouchstart:r,style:{width:`${n}px`},type:"range",value:1e3*t},[]);return jf.h("div.mapillary-sequence-speed-container",[o])}_createPlaybackControls(e,i,n,r){if(this._mode!==bm.Playback)return jf.h("div.mapillary-sequence-playback",[]);const s=jf.h("div.mapillary-sequence-switch-icon.mapillary-sequence-icon-visible",[]),o=r.direction===t.NavigationDirection.Next?t.NavigationDirection.Prev:t.NavigationDirection.Next,a=r.playing,c={onclick:()=>{a||n.configure({direction:o})}},h=r.playing?".mapillary-sequence-switch-button-inactive":".mapillary-sequence-switch-button",l=jf.h("div"+h,c,[s]),u=jf.h("div.mapillary-sequence-slow-icon.mapillary-sequence-icon-visible",[]),d=jf.h("div.mapillary-sequence-slow-container",[u]),p=jf.h("div.mapillary-sequence-fast-icon.mapillary-sequence-icon-visible",[]),f=jf.h("div.mapillary-sequence-fast-container",[p]),m=jf.h("div.mapillary-sequence-close-icon.mapillary-sequence-icon-visible",[]),g={onclick:()=>{this._mode=bm.Default,this._notifyChanged$.next(this)}},_=jf.h("div.mapillary-sequence-close-button",g,[m]),v=[l,d,this._createSpeedInput(i),f,_],y={style:{top:`${Math.round(e/this._stepperDefaultWidth*this._defaultHeight+10)}px`}};return jf.h("div.mapillary-sequence-playback",y,v)}_createPlayingButton(e,i,n,r,s){let o=r.direction===t.NavigationDirection.Next&&null!=e||r.direction===t.NavigationDirection.Prev&&null!=i;o=o&&n;let a={onclick:r.playing?()=>{s.stop()}:o?()=>{s.play()}:null},c={};r.direction===t.NavigationDirection.Prev&&(c.style={transform:"rotate(180deg) translate(50%, 50%)"});let h=jf.h("div.mapillary-sequence-icon",c,[]),l=r.playing?"mapillary-sequence-stop":o?"mapillary-sequence-play":"mapillary-sequence-play-inactive";return jf.h("div."+l,a,[h])}_createSequenceControls(t){const e=Math.round(8/this._stepperDefaultWidth*t),i={onclick:()=>{this._expandControls=!this._expandControls,this._mode=bm.Default,this._notifyChanged$.next(this)},style:{"border-bottom-right-radius":`${e}px`,"border-top-right-radius":`${e}px`}},n=jf.h("div.mapillary-sequence-expander-bar",[]),r=jf.h("div.mapillary-sequence-expander-button",i,[n]),s=this._mode===bm.Playback?".mapillary-sequence-fast-icon-gray.mapillary-sequence-icon-visible":".mapillary-sequence-fast-icon",o=jf.h("div"+s,[]),a={onclick:()=>{this._mode=this._mode===bm.Playback?bm.Default:bm.Playback,this._notifyChanged$.next(this)}},c=jf.h("div.mapillary-sequence-playback-button",a,[o]),h=this._mode===bm.Timeline?".mapillary-sequence-timeline-icon-gray.mapillary-sequence-icon-visible":".mapillary-sequence-timeline-icon",l=jf.h("div"+h,[]),u={onclick:()=>{this._mode=this._mode===bm.Timeline?bm.Default:bm.Timeline,this._notifyChanged$.next(this)}},d=jf.h("div.mapillary-sequence-timeline-button",u,[l]),p={style:{height:this._defaultHeight/this._stepperDefaultWidth*t+"px",transform:`translate(${t/2+2}px, 0)`,width:this._controlsDefaultWidth/this._stepperDefaultWidth*t+"px"}},f=".mapillary-sequence-controls"+(this._expandControls?".mapillary-sequence-controls-expanded":"");return jf.h("div"+f,p,[c,d,r])}_createSequenceArrows(e,i,n,r,s){let o={onclick:null!=e?()=>{s.moveDir$(t.NavigationDirection.Next).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}:null,onpointerenter:()=>{this._mouseEnterDirection$.next(t.NavigationDirection.Next)},onpointerleave:()=>{this._mouseLeaveDirection$.next(t.NavigationDirection.Next)}};const a=Math.round(8/this._stepperDefaultWidth*n);let c={onclick:null!=i?()=>{s.moveDir$(t.NavigationDirection.Prev).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))}:null,onpointerenter:()=>{this._mouseEnterDirection$.next(t.NavigationDirection.Prev)},onpointerleave:()=>{this._mouseLeaveDirection$.next(t.NavigationDirection.Prev)},style:{"border-bottom-left-radius":`${a}px`,"border-top-left-radius":`${a}px`}},h=this._getStepClassName(t.NavigationDirection.Next,e,r.highlightId),l=this._getStepClassName(t.NavigationDirection.Prev,i,r.highlightId),u=jf.h("div.mapillary-sequence-icon",[]),d=jf.h("div.mapillary-sequence-icon",[]);return[jf.h("div."+l,c,[d]),jf.h("div."+h,o,[u])]}_createStepper(e,i,n,r,s,o){let a=null,c=null;for(let i of e.edges)i.data.direction===t.NavigationDirection.Next&&(a=i.target),i.data.direction===t.NavigationDirection.Prev&&(c=i.target);const h=this._createPlayingButton(a,c,n,i,s),l=this._createSequenceArrows(a,c,r,i,o);l.splice(1,0,h);const u={oncontextmenu:t=>{t.preventDefault()},style:{height:this._defaultHeight/this._stepperDefaultWidth*r+"px",width:r+"px"}};return jf.h("div.mapillary-sequence-stepper",u,l)}_createTimelineControls(t,e,i){if(this._mode!==bm.Timeline)return jf.h("div.mapillary-sequence-timeline",[]);const n=this._createPositionInput(e,i),r=jf.h("div.mapillary-sequence-close-icon.mapillary-sequence-icon-visible",[]),s={onclick:()=>{this._mode=bm.Default,this._notifyChanged$.next(this)}},o=jf.h("div.mapillary-sequence-close-button",s,[r]),a={style:{top:`${Math.round(t/this._stepperDefaultWidth*this._defaultHeight+10)}px`}};return jf.h("div.mapillary-sequence-timeline",a,[n,o])}_getStepClassName(e,i,n){let r=e===t.NavigationDirection.Next?"mapillary-sequence-step-next":"mapillary-sequence-step-prev";return null==i?r+="-inactive":n===i&&(r+="-highlight"),r}_setChangingPosition(t){this._changingPosition=t,this._notifyChangingPositionChanged$.next(t)}}class Jm extends Vf{constructor(t,e,i,n,r){super(t,e,i),this._sequenceDOMRenderer=n||new Zm(e),this._scheduler=r,this._containerWidth$=new T,this._hoveredIdSubject$=new T,this._hoveredId$=this._hoveredIdSubject$.pipe(Ze()),this._navigator.playService.playing$.pipe(Je(1),bi(this._configuration$)).subscribe((([t,e])=>{const i="playing",n={playing:t,target:this,type:i};this.fire(i,n),t!==e.playing&&(t?this.play():this.stop())})),this._navigator.playService.direction$.pipe(Je(1),bi(this._configuration$)).subscribe((([t,e])=>{t!==e.direction&&this.configure({direction:t})}))}fire(t,e){super.fire(t,e)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}play(){this.configure({playing:!0})}stop(){this.configure({playing:!1})}_activate(){this._sequenceDOMRenderer.activate();const t=this._navigator.stateService.currentImage$.pipe(ri((t=>t.sequenceEdges$)),Ue(1),E()),e=this._navigator.stateService.currentImage$.pipe(ue(void 0,(t=>t.sequenceId)),ri((t=>At(G(null),this._navigator.graphService.cacheSequence$(t.sequenceId).pipe(Ve(3),te((t=>(console.error("Failed to cache sequence",t),G(null)))))))),ni(null),Ue(1),E()),i=this._subscriptions;i.push(e.subscribe());const n=this._sequenceDOMRenderer.index$.pipe(bi(e),rt((([t,e])=>null!=e?e.imageIds[t]:null)),Nt((t=>!!t)),ue(),He(),E());i.push(Ot(n.pipe(re(100,this._scheduler)),n.pipe(Wt(400,this._scheduler))).pipe(ue(),ri((t=>this._navigator.moveTo$(t).pipe(te((()=>B())))))).subscribe()),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(Nt((t=>t))).subscribe((()=>{this._navigator.graphService.setGraphMode(ym.Sequence)}))),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(Nt((t=>!t))).subscribe((()=>{this._navigator.graphService.setGraphMode(ym.Spatial)}))),this._navigator.graphService.graphMode$.pipe(ri((t=>t===ym.Spatial?this._navigator.stateService.currentImage$.pipe(ve(2)):B())),Nt((t=>!t.spatialEdges.cached)),ri((t=>this._navigator.graphService.cacheImage$(t.id).pipe(te((()=>B())))))).subscribe(),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(Nt((t=>t))).subscribe((()=>{this._navigator.playService.stop()}))),i.push(gt(this._navigator.graphService.graphMode$,this._sequenceDOMRenderer.changingPositionChanged$.pipe(ni(!1),ue())).pipe(bi(this._navigator.stateService.currentImage$),ri((([[t,e],i])=>e&&t===ym.Sequence?this._navigator.graphService.cacheSequenceImages$(i.sequenceId,i.id).pipe(Ve(3),te((t=>(console.error("Failed to cache sequence images.",t),B())))):B()))).subscribe());const r=e.pipe(ri((t=>{if(!t)return G({index:null,max:null});let e=!0;return this._sequenceDOMRenderer.changingPositionChanged$.pipe(ni(!1),ue(),ri((t=>{const i=!t&&e?0:1;return e=!1,t?n:this._navigator.stateService.currentImage$.pipe(rt((t=>t.id)),ue(),Je(i))})),rt((e=>{const i=t.imageIds.indexOf(e);return-1===i?{index:null,max:null}:{index:i,max:t.imageIds.length-1}})))}))),s=this._navigator.stateService.state$.pipe(rt((t=>t===vm.Earth)),ue());i.push(gt(t,this._configuration$,this._containerWidth$,this._sequenceDOMRenderer.changed$.pipe(ni(this._sequenceDOMRenderer)),this._navigator.playService.speed$,r,s).pipe(rt((([t,e,i,,n,r,s])=>{const o=this._sequenceDOMRenderer.render(t,e,i,n,r.index,r.max,!s,this,this._navigator);return{name:this._name,vNode:o}}))).subscribe(this._container.domRenderer.render$)),i.push(this._sequenceDOMRenderer.speed$.subscribe((t=>{this._navigator.playService.setSpeed(t)}))),i.push(this._configuration$.pipe(rt((t=>t.direction)),ue()).subscribe((t=>{this._navigator.playService.setDirection(t)}))),i.push(gt(this._container.renderService.size$,this._configuration$.pipe(ue(((t,e)=>t[0]===e[0]&&t[1]===e[1]),(t=>[t.minWidth,t.maxWidth])))).pipe(rt((([t,e])=>this._sequenceDOMRenderer.getContainerWidth(t,e)))).subscribe(this._containerWidth$)),i.push(this._configuration$.pipe(rt((t=>t.playing)),ue()).subscribe((t=>{t?this._navigator.playService.play():this._navigator.playService.stop()}))),i.push(this._sequenceDOMRenderer.mouseEnterDirection$.pipe(ri((e=>At(t.pipe(rt((t=>{for(let i of t.edges)if(i.data.direction===e)return i.target;return null})),ai(this._sequenceDOMRenderer.mouseLeaveDirection$)),G(null)))),ue()).subscribe(this._hoveredIdSubject$)),i.push(this._hoveredId$.subscribe((t=>{const e="hover",i={id:t,target:this,type:e};this.fire(e,i)})))}_deactivate(){this._subscriptions.unsubscribe(),this._sequenceDOMRenderer.deactivate()}_getDefaultConfiguration(){return{direction:t.NavigationDirection.Next,maxWidth:108,minWidth:70,playing:!1,visible:!0}}}Jm.componentName="sequence",t.SliderConfigurationMode=void 0,(xm=t.SliderConfigurationMode||(t.SliderConfigurationMode={}))[xm.Motion=0]="Motion",xm[xm.Stationary=1]="Stationary";class Km{constructor(){this._factory=new em,this._scene=new im,this._spatial=new ld,this._currentKey=null,this._previousKey=null,this._disabled=!1,this._curtain=1,this._frameId=0,this._needsRender=!1,this._mode=null,this._currentProviderDisposers={},this._previousProviderDisposers={}}get disabled(){return this._disabled}get frameId(){return this._frameId}get needsRender(){return this._needsRender}setTextureProvider(t,e){this._setTextureProvider(t,this._currentKey,e,this._currentProviderDisposers,this._updateTexture.bind(this))}setTextureProviderPrev(t,e){this._setTextureProvider(t,this._previousKey,e,this._previousProviderDisposers,this._updateTexturePrev.bind(this))}update(t,e){this._updateFrameId(t.id),this._updateImagePlanes(t.state,e)}updateCurtain(t){this._curtain!==t&&(this._curtain=t,this._updateCurtain(),this._needsRender=!0)}updateTexture(t,e){const i=e.id===this._currentKey?this._scene.planes:e.id===this._previousKey?this._scene.planesOld:{};if(0!==Object.keys(i).length){this._needsRender=!0;for(const e in i){if(!i.hasOwnProperty(e))continue;let n=i[e].material.uniforms.projectorTex.value;n.image=t,n.needsUpdate=!0}}}updateTextureImage(t,e){if(this._currentKey!==e.id)return;this._needsRender=!0;const i=this._scene.planes;for(const e in i){if(!i.hasOwnProperty(e))continue;let n=i[e].material.uniforms.projectorTex.value;n.image=t,n.needsUpdate=!0}}render(t,e){this.disabled||e.render(this._scene.sceneOld,t),e.render(this._scene.scene,t),this._needsRender=!1}dispose(){this._scene.clear();for(const t in this._currentProviderDisposers)this._currentProviderDisposers.hasOwnProperty(t)&&this._currentProviderDisposers[t]();for(const t in this._previousProviderDisposers)this._previousProviderDisposers.hasOwnProperty(t)&&this._previousProviderDisposers[t]();this._currentProviderDisposers={},this._previousProviderDisposers={}}_getBasicCorners(t,e){let i,n;return t>e?(i=.5,n=.5*t/e):(i=.5*e/t,n=.5),[[.5-i,.5-n],[.5+i,.5+n]]}_setDisabled(t){this._disabled=null==t.currentImage||null==t.previousImage||dd(t.currentImage.cameraType)&&!dd(t.previousImage.cameraType)}_setTextureProvider(t,e,i,n,r){if(t!==e)return;let s=i.textureCreated$.subscribe(r),o=i.textureUpdated$.subscribe((t=>{this._needsRender=!0}));if(t in n){(0,n[t])(),delete n[t]}n[t]=()=>{s.unsubscribe(),o.unsubscribe(),i.dispose()}}_updateCurtain(){const t=this._scene.planes;for(const e in t){if(!t.hasOwnProperty(e))continue;let i=t[e].material;i.uniforms.curtain&&(i.uniforms.curtain.value=this._curtain)}}_updateFrameId(t){this._frameId=t}_updateImagePlanes(e,i){const n=null!=e.currentImage&&this._currentKey!==e.currentImage.id,r=null!=e.previousImage&&this._previousKey!==e.previousImage.id,s=this._mode!==i;if(!(n||r||s))return;this._setDisabled(e),this._needsRender=!0,this._mode=i;const o=e.motionless||i===t.SliderConfigurationMode.Stationary||dd(e.currentImage.cameraType);if((this.disabled||r)&&this._previousKey in this._previousProviderDisposers&&(this._previousProviderDisposers[this._previousKey](),delete this._previousProviderDisposers[this._previousKey]),this.disabled)this._scene.setImagePlanesOld({});else if(r||s){const t=e.previousImage;this._previousKey=t.id;const i=e.currentTransform.rt.elements;let n=[i[12],i[13],i[14]];const r=e.currentTransform.basicAspect,s=e.previousTransform.basicAspect,a=r>s?[1,s/r]:[r/s,1];let c=e.currentImage.rotation,h=e.currentImage.width,l=e.currentImage.height;dd(t.cameraType)&&(c=e.previousImage.rotation,n=this._spatial.rotate(this._spatial.opticalCenter(e.currentImage.rotation,n).toArray(),c).multiplyScalar(-1).toArray(),h=e.previousImage.width,l=e.previousImage.height);const u=new Hd(e.currentImage.exifOrientation,h,l,e.currentImage.scale,c,n,t.image,a,e.currentImage.cameraParameters,e.currentImage.cameraType);let d;if(dd(t.cameraType))d=this._factory.createMesh(t,o||dd(e.currentImage.cameraType)?u:e.previousTransform);else if(o){const[[t,i],[n,o]]=this._getBasicCorners(r,s);d=this._factory.createFlatMesh(e.previousImage,u,t,n,i,o)}else d=this._factory.createMesh(e.previousImage,e.previousTransform);const p={};p[t.id]=d,this._scene.setImagePlanesOld(p)}if(n||s){this._currentKey in this._currentProviderDisposers&&(this._currentProviderDisposers[this._currentKey](),delete this._currentProviderDisposers[this._currentKey]),this._currentKey=e.currentImage.id;const t={};dd(e.currentImage.cameraType)?t[e.currentImage.id]=this._factory.createCurtainMesh(e.currentImage,e.currentTransform):t[e.currentImage.id]=o?this._factory.createDistortedCurtainMesh(e.currentImage,e.currentTransform):this._factory.createCurtainMesh(e.currentImage,e.currentTransform),this._scene.setImagePlanes(t),this._updateCurtain()}}_updateTexture(t){this._needsRender=!0;const e=this._scene.planes;for(const i in e){if(!e.hasOwnProperty(i))continue;let n=e[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=t}}_updateTexturePrev(t){this._needsRender=!0;const e=this._scene.planesOld;for(const i in e){if(!e.hasOwnProperty(i))continue;let n=e[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=t}}}class Qm{constructor(t){this._container=t,this._interacting=!1,this._notifyModeChanged$=new T,this._notifyPositionChanged$=new T,this._stopInteractionSubscription=null}get mode$(){return this._notifyModeChanged$}get position$(){return this._notifyPositionChanged$}activate(){this._stopInteractionSubscription||(this._stopInteractionSubscription=Ot(this._container.mouseService.documentMouseUp$,this._container.touchService.touchEnd$.pipe(Nt((t=>0===t.touches.length)))).subscribe((t=>{this._interacting&&(this._interacting=!1)})))}deactivate(){this._stopInteractionSubscription&&(this._interacting=!1,this._stopInteractionSubscription.unsubscribe(),this._stopInteractionSubscription=null)}render(t,e,i,n,r){const s=[];if(r){s.push(jf.h("div.mapillary-slider-border",[]));const r=!(i||n);r&&(s.push(this._createModeButton(e)),s.push(this._createModeButton2d(e))),s.push(this._createPositionInput(t,r))}const o=this._container.domContainer.getBoundingClientRect(),a=Math.max(215,Math.min(400,o.width-100));return jf.h("div.mapillary-slider-container",{style:{width:`${a}px`}},s)}_createModeButton(e){const i={onclick:()=>{e!==t.SliderConfigurationMode.Motion&&this._notifyModeChanged$.next(t.SliderConfigurationMode.Motion)}},n=e===t.SliderConfigurationMode.Stationary?"mapillary-slider-mode-button-inactive":"mapillary-slider-mode-button";return jf.h("div."+n,i,[jf.h("div.mapillary-slider-mode-icon",[])])}_createModeButton2d(e){const i={onclick:()=>{e!==t.SliderConfigurationMode.Stationary&&this._notifyModeChanged$.next(t.SliderConfigurationMode.Stationary)}},n=e===t.SliderConfigurationMode.Motion?"mapillary-slider-mode-button-2d-inactive":"mapillary-slider-mode-button-2d";return jf.h("div."+n,i,[jf.h("div.mapillary-slider-mode-icon-2d",[])])}_createPositionInput(t,e){const i=t=>{this._notifyPositionChanged$.next(Number(t.target.value)/1e3)},n=t=>{this._interacting=!0,t.stopPropagation()},r=t=>{this._interacting&&t.stopPropagation()},s=this._container.domContainer.getBoundingClientRect(),o=Math.max(215,Math.min(400,s.width-105))-84+(e?0:52),a=jf.h("input.mapillary-slider-position",{max:1e3,min:0,onchange:i,oninput:i,onkeydown:t=>{"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key&&"ArrowUp"!==t.key||t.preventDefault()},onpointerdown:n,onpointermove:r,ontouchmove:r,ontouchstart:n,style:{width:`${o}px`},type:"range",value:1e3*t},[]);return jf.h("div.mapillary-slider-position-container",[a])}}class tg extends Vf{constructor(t,e,i,n){super(t,e,i),this._viewportCoords=n||new Wf,this._domRenderer=new Qm(e),this._imageTileLoader=new sm(i.api),this._roiCalculator=new am,this._spatial=new ld,this._glRendererOperation$=new T,this._glRendererCreator$=new T,this._glRendererDisposer$=new T,this._glRenderer$=this._glRendererOperation$.pipe(Le(((t,e)=>e(t)),null),Nt((t=>null!=t)),ue(void 0,(t=>t.frameId))),this._glRendererCreator$.pipe(rt((()=>t=>{if(null!=t)throw new Error("Multiple slider states can not be created at the same time");return new Km}))).subscribe(this._glRendererOperation$),this._glRendererDisposer$.pipe(rt((()=>t=>(t.dispose(),null)))).subscribe(this._glRendererOperation$)}_activate(){const e=this._subscriptions;e.push(this._domRenderer.mode$.subscribe((t=>{this.configure({mode:t})}))),e.push(this._glRenderer$.pipe(rt((t=>({name:this._name,renderer:{frameId:t.frameId,needsRender:t.needsRender,render:t.render.bind(t),pass:rm.Background}})))).subscribe(this._container.glRenderer.render$));const i=At(this.configuration$.pipe(rt((t=>null!=t.initialPosition?t.initialPosition:1)),Ee()),this._domRenderer.position$),n=this.configuration$.pipe(rt((t=>t.mode)),ue()),r=this._navigator.stateService.currentState$.pipe(rt((t=>t.state.motionless)),ue()),s=this._navigator.stateService.currentState$.pipe(rt((t=>dd(t.state.currentImage.cameraType))),ue()),o=gt(this._configuration$.pipe(rt((t=>t.sliderVisible))),this._navigator.stateService.currentState$.pipe(rt((t=>!(null==t.state.currentImage||null==t.state.previousImage||dd(t.state.currentImage.cameraType)&&!dd(t.state.previousImage.cameraType)))),ue())).pipe(rt((([t,e])=>t&&e)),ue());this._waitSubscription=gt(n,r,s,o).pipe(bi(this._navigator.stateService.state$)).subscribe((([[e,i,n,r],s])=>{const o=r&&(i||e===t.SliderConfigurationMode.Stationary||n);o&&s!==vm.WaitingInteractively?this._navigator.stateService.waitInteractively():o||s===vm.Waiting||this._navigator.stateService.wait()})),e.push(gt(i,n,r,s,o).subscribe((([e,i,n,r])=>{n||i===t.SliderConfigurationMode.Stationary||r?this._navigator.stateService.moveTo(1):this._navigator.stateService.moveTo(e)}))),e.push(gt(i,n,r,s,o,this._container.renderService.size$).pipe(rt((([t,e,i,n,r])=>({name:this._name,vNode:this._domRenderer.render(t,e,i,n,r)})))).subscribe(this._container.domRenderer.render$)),this._glRendererCreator$.next(null),e.push(gt(i,s,o,this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$).pipe(rt((([t,e,i,n,r])=>{if(!e)return i?t:1;const s=this._viewportCoords.viewportToBasic(-1.15,0,r,n.perspective),o=this._viewportCoords.viewportToBasic(1.15,0,r,n.perspective),a=o[0]<s[0]?o[0]+1:o[0],c=s[0]+t*(a-s[0]);return c>1?c-1:c})),rt((t=>e=>(e.updateCurtain(t),e)))).subscribe(this._glRendererOperation$)),e.push(gt(this._navigator.stateService.currentState$,n).pipe(rt((([t,e])=>i=>(i.update(t,e),i)))).subscribe(this._glRendererOperation$)),e.push(this._configuration$.pipe(Nt((t=>null!=t.ids)),ri((t=>Ft(Ft(this._catchCacheImage$(t.ids.background),this._catchCacheImage$(t.ids.foreground)).pipe(rt((t=>({background:t[0],foreground:t[1]})))),this._navigator.stateService.currentState$.pipe(Ee())).pipe(rt((t=>({images:t[0],state:t[1].state}))))))).subscribe((t=>{null!=t.state.currentImage&&null!=t.state.previousImage&&t.state.currentImage.id===t.images.foreground.id&&t.state.previousImage.id===t.images.background.id||(t.state.currentImage.id!==t.images.background.id?t.state.currentImage.id!==t.images.foreground.id||1!==t.state.trajectory.length?(this._navigator.stateService.setImages([t.images.background]),this._navigator.stateService.setImages([t.images.foreground])):this._navigator.stateService.prependImages([t.images.background]):this._navigator.stateService.setImages([t.images.foreground]))}),(t=>{console.error(t)})));const a=this._container.configurationService.imageTiling$.pipe(ri((t=>t?this._navigator.stateService.currentState$:new T)),ue(void 0,(t=>t.state.currentImage.id)),bi(this._container.glRenderer.webGLRenderer$,this._container.renderService.size$),rt((([t,e,i])=>{const n=t.state;Math.max(i.width,i.height);const r=n.currentImage,s=n.currentTransform;return new _m(r.id,s.basicWidth,s.basicHeight,r.image,this._imageTileLoader,new om,e)})),Ue(1),E());e.push(a.subscribe((()=>{}))),e.push(a.pipe(rt((t=>e=>(e.setTextureProvider(t.id,t),e)))).subscribe(this._glRendererOperation$)),e.push(a.pipe(ze()).subscribe((t=>{t[0].abort()})));const c=this._container.configurationService.imageTiling$.pipe(ri((t=>t?gt(this._container.renderService.renderCameraFrame$,this._container.renderService.size$.pipe(re(250))):new T)),rt((([t,e])=>[t.camera.position.clone(),t.camera.lookat.clone(),t.zoom.valueOf(),e.height.valueOf(),e.width.valueOf()])),ze(),ti((t=>t[1][2]-t[0][2]<0||0===t[1][2])),rt((t=>{let e=t[0][0].equals(t[1][0]),i=t[0][1].equals(t[1][1]),n=t[0][2]===t[1][2],r=t[0][3]===t[1][3],s=t[0][4]===t[1][4];return e&&i&&n&&r&&s})),ue(),Nt((t=>t)),ri((()=>this._container.renderService.renderCameraFrame$.pipe(Ee()))),bi(this._container.renderService.size$,this._navigator.stateService.currentTransform$));e.push(a.pipe(ri((t=>c.pipe(rt((([e,i,n])=>[this._roiCalculator.computeRegionOfInterest(e,i,n),t]))))),Nt((t=>!t[1].disposed))).subscribe((t=>{let e=t[0];t[1].setRegionOfInterest(e)})));const h=a.pipe(ri((t=>t.hasTexture$)),ni(!1),Ue(1),E());e.push(h.subscribe((()=>{})));const l=this._container.configurationService.imageTiling$.pipe(ri((t=>t?this._navigator.stateService.currentState$:new T)),Nt((t=>!!t.state.previousImage)),ue(void 0,(t=>t.state.previousImage.id)),bi(this._container.glRenderer.webGLRenderer$,this._container.renderService.size$),rt((([t,e,i])=>{const n=t.state,r=n.previousImage,s=n.previousTransform;return new _m(r.id,s.basicWidth,s.basicHeight,r.image,this._imageTileLoader,new om,e)})),Ue(1),E());e.push(l.subscribe((()=>{}))),e.push(l.pipe(rt((t=>e=>(e.setTextureProviderPrev(t.id,t),e)))).subscribe(this._glRendererOperation$)),e.push(l.pipe(ze()).subscribe((t=>{t[0].abort()})));const u=this._container.configurationService.imageTiling$.pipe(ri((t=>t?gt(this._container.renderService.renderCameraFrame$,this._container.renderService.size$.pipe(re(250))):new T)),rt((([t,e])=>[t.camera.position.clone(),t.camera.lookat.clone(),t.zoom.valueOf(),e.height.valueOf(),e.width.valueOf()])),ze(),ti((t=>t[1][2]-t[0][2]<0||0===t[1][2])),rt((t=>{let e=t[0][0].equals(t[1][0]),i=t[0][1].equals(t[1][1]),n=t[0][2]===t[1][2],r=t[0][3]===t[1][3],s=t[0][4]===t[1][4];return e&&i&&n&&r&&s})),ue(),Nt((t=>t)),ri((()=>this._container.renderService.renderCameraFrame$.pipe(Ee()))),bi(this._container.renderService.size$,this._navigator.stateService.currentTransform$));e.push(l.pipe(ri((t=>u.pipe(rt((([e,i,n])=>[this._roiCalculator.computeRegionOfInterest(e,i,n),t]))))),Nt((t=>!t[1].disposed)),bi(this._navigator.stateService.currentState$)).subscribe((([[t,e],i])=>{let n=null;if(dd(i.state.previousImage.cameraType))if(dd(i.state.currentImage.cameraType)){const e=this._spatial.viewingDirection(i.state.currentImage.rotation),r=this._spatial.viewingDirection(i.state.previousImage.rotation),s=this._spatial.angleBetweenVector2(e.x,e.y,r.x,r.y)/(2*Math.PI);n={bbox:{maxX:this._spatial.wrap(t.bbox.maxX+s,0,1),maxY:t.bbox.maxY,minX:this._spatial.wrap(t.bbox.minX+s,0,1),minY:t.bbox.minY},pixelHeight:t.pixelHeight,pixelWidth:t.pixelWidth}}else{const e=this._spatial.viewingDirection(i.state.currentImage.rotation),r=this._spatial.viewingDirection(i.state.previousImage.rotation),s=this._spatial.angleBetweenVector2(e.x,e.y,r.x,r.y)/(2*Math.PI),o=this._spatial.angleToPlane(e.toArray(),[0,0,1]),a=(this._spatial.angleToPlane(r.toArray(),[0,0,1])-o)/(2*Math.PI),c=i.state.currentTransform,h=Math.max(c.basicWidth,c.basicHeight),l=h>0?2*Math.atan(.5*c.basicWidth/(h*c.focal)):Math.PI/3,u=h>0?2*Math.atan(.5*c.basicHeight/(h*c.focal)):Math.PI/3,d=l/(2*Math.PI),p=u/Math.PI,f=(t.bbox.maxX-t.bbox.minX)*d,m=(t.bbox.maxY-t.bbox.minY)*p,g=t.pixelWidth*d,_=t.pixelHeight*p,v=(t.bbox.minX+t.bbox.maxX)/2-.5,y=(t.bbox.minY+t.bbox.maxY)/2-.5,b=.5+s+d*v-f/2,x=.5+s+d*v+f/2,w=.5+a+p*y-m/2,S=.5+a+p*y+m/2;n={bbox:{maxX:this._spatial.wrap(x,0,1),maxY:S,minX:this._spatial.wrap(b,0,1),minY:w},pixelHeight:_,pixelWidth:g}}else{const e=i.state.currentTransform.basicAspect,r=i.state.previousTransform.basicAspect,[[s,o],[a,c]]=this._getBasicCorners(e,r),h=a-s,l=c-o,u=t.pixelWidth/h,d=t.pixelHeight/l,p=(h-1)/(2*h)+t.bbox.minX/h,f=(h-1)/(2*h)+t.bbox.maxX/h,m=(l-1)/(2*l)+t.bbox.minY/l,g={maxX:f,maxY:(l-1)/(2*l)+t.bbox.maxY/l,minX:p,minY:m};this._clipBoundingBox(g),n={bbox:g,pixelHeight:d,pixelWidth:u}}e.setRegionOfInterest(n)})));const d=l.pipe(ri((t=>t.hasTexture$)),ni(!1),Ue(1),E());e.push(d.subscribe((()=>{})))}_deactivate(){this._waitSubscription.unsubscribe(),this._navigator.stateService.state$.pipe(Ee()).subscribe((t=>{t!==vm.Traversing&&this._navigator.stateService.traverse()})),this._glRendererDisposer$.next(null),this._domRenderer.deactivate(),this._subscriptions.unsubscribe(),this.configure({ids:null})}_getDefaultConfiguration(){return{initialPosition:1,mode:t.SliderConfigurationMode.Motion,sliderVisible:!0}}_catchCacheImage$(t){return this._navigator.graphService.cacheImage$(t).pipe(te((e=>(console.error(`Failed to cache slider image (${t})`,e),B()))))}_getBasicCorners(t,e){let i,n;return t>e?(i=.5,n=.5*t/e):(i=.5*e/t,n=.5),[[.5-i,.5-n],[.5+i,.5+n]]}_clipBoundingBox(t){t.minX=Math.max(0,Math.min(1,t.minX)),t.maxX=Math.max(0,Math.min(1,t.maxX)),t.minY=Math.max(0,Math.min(1,t.minY)),t.maxY=Math.max(0,Math.min(1,t.maxY))}}tg.componentName="slider";class eg{constructor(e,i){this._subscriptions=new Uf,this._graphService=e,this._stateService=i;const n=this._subscriptions;this._directionSubject$=new T,this._direction$=this._directionSubject$.pipe(ni(t.NavigationDirection.Next),Ue(1),E()),n.push(this._direction$.subscribe()),this._playing=!1,this._playingSubject$=new T,this._playing$=this._playingSubject$.pipe(ni(this._playing),Ue(1),E()),n.push(this._playing$.subscribe()),this._speed=.5,this._speedSubject$=new T,this._speed$=this._speedSubject$.pipe(ni(this._speed),Ue(1),E()),n.push(this._speed$.subscribe()),this._imagesAhead=this._mapImagesAhead(this._mapSpeed(this._speed)),this._bridging$=null}get playing(){return this._playing}get direction$(){return this._direction$}get playing$(){return this._playing$}get speed$(){return this._speed$}play(){if(this._playing)return;this._stateService.cutImages();const e=this._setSpeed(this._speed);this._stateService.setSpeed(e),this._graphModeSubscription=this._speed$.pipe(rt((t=>t>eg.sequenceSpeed?ym.Sequence:ym.Spatial)),ue()).subscribe((t=>{this._graphService.setGraphMode(t)})),this._cacheSubscription=gt(this._stateService.currentImage$.pipe(rt((t=>[t.sequenceId,t.id])),ue(void 0,(([t])=>t))),this._graphService.graphMode$,this._direction$).pipe(ri((([[e,i],n,r])=>{if(r!==t.NavigationDirection.Next&&r!==t.NavigationDirection.Prev)return G([void 0,r]);return gt((n===ym.Sequence?this._graphService.cacheSequenceImages$(e,i):this._graphService.cacheSequence$(e)).pipe(Ve(3),te((t=>(console.error(t),G(void 0))))),G(r))})),ri((([e,i])=>{if(void 0===e)return B();const n=e.imageIds.slice();return i===t.NavigationDirection.Prev&&n.reverse(),this._stateService.currentState$.pipe(rt((t=>[t.state.trajectory[t.state.trajectory.length-1].id,t.state.imagesAhead])),Le((([t,e],[i,r])=>{void 0===t&&(t=i);const s=n.length-1;if(r>=this._imagesAhead||n[s]===t)return[t,[]];const o=n.indexOf(i),a=n.indexOf(t)+1,c=Math.min(s,o+this._imagesAhead-r)+1;return c<=a?[t,[]]:[n[c-1],n.slice(a,c)]}),[void 0,[]]),Mt((([t,e])=>bt(e))))})),Mt((t=>this._graphService.cacheImage$(t).pipe(te((()=>B())))),6)).subscribe(),this._playingSubscription=this._stateService.currentState$.pipe(Nt((t=>t.state.imagesAhead<this._imagesAhead)),ue(void 0,(t=>t.state.lastImage.id)),rt((t=>{const e=t.state.lastImage,i=t.state.trajectory;let n;for(let t=i.length-2;t>=0;t--){const r=i[t];if(r.sequenceId!==e.sequenceId)break;if(r.capturedAt!==e.capturedAt){n=r.capturedAt<e.capturedAt;break}}return[t.state.lastImage,n]})),bi(this._direction$),ri((([[e,i],n])=>Ft(([t.NavigationDirection.Next,t.NavigationDirection.Prev].indexOf(n)>-1?e.sequenceEdges$:e.spatialEdges$).pipe(Ee((t=>t.cached)),yi(15e3)),G(n)).pipe(rt((([t,e])=>{for(let i of t.edges)if(i.data.direction===e)return i.target;return null})),ri((t=>null!=t?this._graphService.cacheImage$(t):B())))))).subscribe((t=>{this._stateService.appendImagess([t])}),(t=>{console.error(t),this.stop()})),this._clearSubscription=this._stateService.currentImage$.pipe(Xt(1,10)).subscribe((t=>{this._stateService.clearPriorImages()})),this._setPlaying(!0);const i=this._stateService.currentState$.pipe(rt((t=>t.state)),ue((([t,e],[i,n])=>t===i&&e===n),(t=>[t.currentImage.id,t.lastImage.id])),Nt((t=>t.currentImage.id===t.lastImage.id&&t.currentIndex===t.trajectory.length-1)),rt((t=>t.currentImage)));this._stopSubscription=gt(i,this._direction$).pipe(ri((([e,i])=>{const n=([t.NavigationDirection.Next,t.NavigationDirection.Prev].indexOf(i)>-1?e.sequenceEdges$:e.spatialEdges$).pipe(Ee((t=>t.cached)),yi(15e3),te((t=>(console.error(t),G({cached:!1,edges:[]})))));return gt(G(i),n).pipe(rt((([t,e])=>{for(const i of e.edges)if(i.data.direction===t)return!0;return!1})))})),Mt((t=>t||!this._bridging$?G(t):this._bridging$.pipe(rt((t=>null!=t)),te((t=>(console.error(t),G(!1))))))),Ee((t=>!t))).subscribe(void 0,void 0,(()=>{this.stop()})),this._stopSubscription.closed&&(this._stopSubscription=null),this._earthSubscription=this._stateService.state$.pipe(rt((t=>t===vm.Earth)),ue(),Ee((t=>t))).subscribe(void 0,void 0,(()=>{this.stop()})),this._earthSubscription.closed&&(this._earthSubscription=null)}dispose(){this.stop(),this._subscriptions.unsubscribe()}setDirection(t){this._directionSubject$.next(t)}setSpeed(t){if((t=Math.max(0,Math.min(1,t)))===this._speed)return;const e=this._setSpeed(t);this._playing&&this._stateService.setSpeed(e),this._speedSubject$.next(this._speed)}stop(){this._playing&&(this._stopSubscription&&(this._stopSubscription.closed||this._stopSubscription.unsubscribe(),this._stopSubscription=null),this._earthSubscription&&(this._earthSubscription.closed||this._earthSubscription.unsubscribe(),this._earthSubscription=null),this._graphModeSubscription.unsubscribe(),this._graphModeSubscription=null,this._cacheSubscription.unsubscribe(),this._cacheSubscription=null,this._playingSubscription.unsubscribe(),this._playingSubscription=null,this._clearSubscription.unsubscribe(),this._clearSubscription=null,this._stateService.setSpeed(1),this._stateService.cutImages(),this._graphService.setGraphMode(ym.Spatial),this._setPlaying(!1))}_mapSpeed(t){const e=2*t-1;return Math.pow(10,e)-.2*e}_mapImagesAhead(t){return Math.round(Math.max(10,Math.min(50,8+6*t)))}_setPlaying(t){this._playing=t,this._playingSubject$.next(t)}_setSpeed(t){this._speed=t;const e=this._mapSpeed(this._speed);return this._imagesAhead=this._mapImagesAhead(e),e}}eg.sequenceSpeed=.54,t.CameraVisualizationMode=void 0,(wm=t.CameraVisualizationMode||(t.CameraVisualizationMode={}))[wm.Hidden=0]="Hidden",wm[wm.Homogeneous=1]="Homogeneous",wm[wm.Cluster=2]="Cluster",wm[wm.ConnectedComponent=3]="ConnectedComponent",wm[wm.Sequence=4]="Sequence",t.OriginalPositionMode=void 0,(Sm=t.OriginalPositionMode||(t.OriginalPositionMode={}))[Sm.Hidden=0]="Hidden",Sm[Sm.Altitude=1]="Altitude",Sm[Sm.Flat=2]="Flat";class ig extends Qc{constructor(t){super(),this._originalSize=t.originalSize;const e=t.cluster,i=t.scale,n=t.translation;this._makeAttributes(e),this.material.size=i*this._originalSize,this.material.vertexColors=!0,this.material.needsUpdate=!0,this.matrixAutoUpdate=!1,this.position.fromArray(n),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}resize(t){this.material.size=t*this._originalSize,this.material.needsUpdate=!0}_makeAttributes(t){const e=[],i=[],n=t.points;for(const t in n){if(!n.hasOwnProperty(t))continue;const r=n[t];e.push(...r.coordinates);const s=r.color;i.push(s[0]),i.push(s[1]),i.push(s[2])}const r=this.geometry;r.setAttribute("position",new Hr(new Float32Array(e),3)),r.setAttribute("color",new Hr(new Float32Array(i),3))}}class ng extends Uc{constructor(t){super(),this._makeAttributes(t),this.matrixAutoUpdate=!1,this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}_makeAttributes(t){const e=t.slice();e.push(t[0]);let i=0;const n=new Float32Array(3*(t.length+1));for(const t of e)n[i++]=t[0],n[i++]=t[1],n[i++]=t[2];this.geometry.setAttribute("position",new Hr(n,3))}}function rg(t,e){return t===e}function sg(t){const e=function(t){return Math.pow(2,t)}(t)/2;return{min:[-e,-e,-e],max:[e,e,e]}}class og{constructor(t,e,i,n){this.level=t,this.leafLevel=e,this.boundingBox=i,this.parent=n,this.children=[],this.items=[],n&&n.children.push(this)}get isEmpty(){return!(this.children.length||this.items.length)}add(t){const e=this;if(!e.boundingBox.containsPoint(t.position))throw new Error("Item not contained in node");if(rg(e.level,e.leafLevel))return e.items.push(t),this;for(const i of e.children)if(i.boundingBox.containsPoint(t.position))return i.add(t);for(const i of e._generateBoundingBoxes())if(i.containsPoint(t.position)){return new og(e.level-1,e.leafLevel,i,e).add(t)}throw new Error("Item not contained in children")}intersect(t,e,i){if(t.intersectBox(this.boundingBox,e))if(rg(this.level,this.leafLevel))i.push(this);else for(const n of this.children)n.intersect(t,e,i)}remove(t){const e=this.items.indexOf(t);if(e<0)throw new Error(`Item does not exist ${t.uuid}`);this.items.splice(e,1)}traverse(){const t=this;if(!t.isEmpty)return;const e=t.parent;if(!e)return;const i=e.children.indexOf(t);if(i<0)throw new Error("Corrupt octree");e.children.splice(i,1),this.parent=null,e.traverse()}_generateBoundingBoxes(){const t=this.boundingBox.min,e=(this.boundingBox.max.x-t.x)/2,i=[[t.x,t.y+e,t.z+e],[t.x+e,t.y+e,t.z+e],[t.x,t.y,t.z+e],[t.x+e,t.y,t.z+e],[t.x,t.y+e,t.z],[t.x+e,t.y+e,t.z],[t.x,t.y,t.z],[t.x+e,t.y,t.z]],n=[];for(const[t,r,s]of i)n.push(new _n(new fn(t,r,s),new fn(t+e,r+e,s+e)));return n}}class ag{constructor(t,e){if(this.rootLevel=t,this.leafLevel=e,e>t)throw new Error;this._index=new Map,this._root=this._makeRoot()}get root(){return this._root}add(t){if(!this.root.boundingBox.containsPoint(t.position))return void console.warn(`Object outside bounding box ${t.uuid}`);const e=this._root.add(t);this._index.set(t.uuid,e)}has(t){return this._index.has(t.uuid)}intersect(t){const e=[],i=new fn;return this._root.intersect(t,i,e),e.map((t=>t.items)).reduce(((t,e)=>(t.push(...e),t)),[])}reset(){this._root=this._makeRoot(),this._index.clear()}remove(t){if(!this.has(t))throw new Error(`Frame does not exist ${t.uuid}`);const e=this._index.get(t.uuid);e.remove(t),e.traverse(),this._index.delete(t.uuid)}_makeRoot(){const t=this.rootLevel,e=sg(t),i=new _n((new fn).fromArray(e.min),(new fn).fromArray(e.max));return new og(t,this.leafLevel,i)}}class cg{constructor(t,e){this._objects=[],this._objectImageMap=new Map,this._octree=null!=t?t:new ag(14,6),this._raycaster=null!=e?e:new Bu,this._interactiveLayer=1,this._raycaster=e||new Bu(void 0,void 0,1,1e4),this._lineThreshold=.2,this._largeLineThreshold=.4,this._raycaster.params.Line.threshold=this._lineThreshold,this._raycaster.layers.set(this._interactiveLayer)}get interactiveLayer(){return this._interactiveLayer}get octree(){return this._octree}get raycaster(){return this._raycaster}add(t,e){const i=t.uuid;this._objectImageMap.set(i,e),this._objects.push(t),this._octree.add(t)}intersectObjects(t,e){this._raycaster.setFromCamera((new rn).fromArray(t),e);const i=this._octree.intersect(this.raycaster.ray),n=this._raycaster.intersectObjects(i),r=this._objectImageMap;for(const t of n){const e=t.object.uuid;if(r.has(e))return r.get(e)}return null}remove(t){const e=this._objects,i=e.indexOf(t);if(-1!==i){const n=e.splice(i,1);for(const t of n)this._objectImageMap.delete(t.uuid);this._octree.remove(t)}else console.warn("Object does not exist")}resetIntersectionThreshold(t){this._raycaster.params.Line.threshold=t?this._largeLineThreshold:this._lineThreshold}}class hg extends Uc{constructor(t){super(t.geometry,t.material);const e=t.mode,i=t.originalOrigin,n=t.transform.unprojectBasic([0,0],0);this._relativeAltitude=i[2]-n[2],this._makeAttributes(n,i,e),this.matrixAutoUpdate=!1,this.position.fromArray(n),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}setMode(t){const e=this.geometry.attributes.position;e.array[5]=this._modeToAltitude(t),e.needsUpdate=!0,this.geometry.computeBoundingSphere()}_makeAttributes(t,e,i){const n=new Float32Array(6);n[0]=0,n[1]=0,n[2]=0,n[3]=e[0]-t[0],n[4]=e[1]-t[1],n[5]=this._modeToAltitude(i);const r=new Hr(n,3);this.geometry.setAttribute("position",r),r.needsUpdate=!0,this.geometry.computeBoundingSphere()}_modeToAltitude(e){return e===t.OriginalPositionMode.Altitude?this._relativeAltitude:0}}class lg extends qc{constructor(t){super(t.geometry,t.material);const e=t.color,i=t.size,n=t.scale,r=t.transform,s=r.unprojectBasic([0,0],0),o=this._makePositions(i,r,s);this._makeAttributes(o,e),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),this.matrixAutoUpdate=!1,this.position.fromArray(s),this.scale.set(n,n,n),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}setColor(t){return this._updateColorAttribute(t),this}resize(t){return this.scale.set(t,t,t),this.updateMatrix(),this.updateMatrixWorld(!1),this}_makeAttributes(t,e){const i=this.geometry,n=new Hr(new Float32Array(t),3);i.setAttribute("position",n),n.needsUpdate=!0;const r=new Hr(new Float32Array(t.length),3);i.setAttribute("color",r),this._updateColorAttribute(e)}_updateColorAttribute(t){const[e,i,n]=new Dr(t).toArray(),r=this.geometry.attributes.color,s=r.array,o=s.length;let a=0;for(let t=0;t<o;t++)s[a++]=e,s[a++]=i,s[a++]=n;r.needsUpdate=!0}}class ug extends lg{_makePositions(t,e,i){const n=[];n.push(...this._makeAxis(t,e,i)),n.push(...this._makeLat(.5,10,t,e,i));for(const r of[0,.25,.5,.75])n.push(...this._makeLng(r,10,t,e,i));return n}_makeAxis(t,e,i){const n=e.unprojectBasic([.5,1],.8*t),r=e.unprojectBasic([.5,0],1.2*t);return[n[0]-i[0],n[1]-i[1],n[2]-i[2],r[0]-i[0],r[1]-i[1],r[2]-i[2]]}_makeLat(t,e,i,n,r){const s=.8*i,[o,a,c]=r,h=[],l=n.unprojectBasic([0,t],s);l[0]-=o,l[1]-=a,l[2]-=c,h.push(...l);for(let i=1;i<=e;i++){const r=n.unprojectBasic([i/e,t],s);r[0]-=o,r[1]-=a,r[2]-=c,h.push(...r,...r)}return h.push(...l),h}_makeLng(t,e,i,n,r){const s=.8*i,[o,a,c]=r,h=[],l=n.unprojectBasic([t,0],s);l[0]-=o,l[1]-=a,l[2]-=c,h.push(...l);for(let i=0;i<=e;i++){const r=n.unprojectBasic([t,i/e],s);r[0]-=o,r[1]-=a,r[2]-=c,h.push(...r,...r)}return h.push(...l),h}}class dg extends lg{_makePositions(t,e,i){const n=[];return n.push(...this._makeDiags(t,e,i)),n.push(...this._makeFrame(t,8,e,i)),n}_makeDiags(t,e,i){const n=t,[r,s,o]=i,a=[0,0,0],c=[];for(const t of[[0,0],[1,0],[1,1],[0,1]]){const i=e.unprojectBasic(t,n,!0);i[0]-=r,i[1]-=s,i[2]-=o,c.push(...a,...i)}return c}_makeFrame(t,e,i,n){const r=[];r.push(...this._subsample([0,1],[0,0],e)),r.push(...this._subsample([0,0],[1,0],e)),r.push(...this._subsample([1,0],[1,1],e));const s=t,[o,a,c]=n,h=[];for(const t of r){const e=i.unprojectBasic(t,s,!0);e[0]-=o,e[1]-=a,e[2]-=c,h.push(...e)}return h}_interpolate(t,e,i){return t+i*(e-t)}_subsample(t,e,i){if(i<1)return[t,e];const n=[];n.push(t);for(let r=0;r<=i;r++){const s=[];for(let n=0;n<3;n++)s.push(this._interpolate(t[n],e[n],r/(i+1)));n.push(s),n.push(s)}return n.push(e),n}}class pg{constructor(t,e,i){this.id=t,this._scene=e,this._intersection=i,this.cameras=new pr,this.keys=[],this._positionLines={},this._positions=new pr,this._cameraFrames={},this._clusters=new Map,this._connectedComponents=new Map,this._sequences=new Map,this._props={},this.clusterVisibles={},this._frameMaterial=new kc({fog:!1,vertexColors:!0}),this._positionMaterial=new kc({fog:!1,color:16711680}),this._scene.add(this.cameras,this._positions)}addImage(t){const e=t.image,i=e.id;if(this.hasImage(i))throw new Error(`Image exists ${i}`);const n=t.idMap.ccId;this._connectedComponents.has(n)||this._connectedComponents.set(n,[]);const r=t.idMap.clusterId;this._clusters.has(r)||this._clusters.set(r,[]);const s=t.idMap.sequenceId;this._sequences.has(s)||this._sequences.set(s,[]),this._props[i]={image:e,ids:{ccId:n,clusterId:r,sequenceId:s}},this.keys.push(i)}applyCameraColor(t,e){this._cameraFrames[t].setColor(e)}applyCameraSize(t){for(const e of this.cameras.children)e.resize(t)}applyFilter(t){var e;const i=this.clusterVisibles;for(const t in i)i.hasOwnProperty(t)&&(i[t]=!1);const n=this._cameraFrames,r=this._positionLines,s=this._intersection.interactiveLayer;for(const o of Object.values(this._props)){const a=o.image,c=t(a),h=a.id;r[h].visible=c;const l=n[h];this._setCameraVisibility(l,c,s),i[e=o.ids.clusterId]||(i[e]=c)}}applyPositionMode(e){this._positions.visible=e!==t.OriginalPositionMode.Hidden;for(const t of this._positions.children)t.setMode(e)}dispose(){this._disposeCameras(),this._disposePositions(),this._scene=null,this._intersection=null}getCamerasByMode(e){if(e===t.CameraVisualizationMode.Cluster)return this._clusters;if(e===t.CameraVisualizationMode.ConnectedComponent)return this._connectedComponents;if(e===t.CameraVisualizationMode.Sequence)return this._sequences;const i=t.CameraVisualizationMode,n=i[i.Homogeneous],r=new Map;return r.set(n,this.cameras.children),r}getColorId(e,i){const n=this._props[e],r=t.CameraVisualizationMode;switch(i){case r.Cluster:return n.ids.clusterId;case r.ConnectedComponent:return n.ids.ccId;case r.Sequence:return n.ids.sequenceId;default:return r[r.Homogeneous]}}hasImage(t){return-1!==this.keys.indexOf(t)}visualize(t){var e,i;const n=t.id,r=t.visible,s=t.transform,o={color:t.color,material:this._frameMaterial,scale:t.scale,size:t.maxSize,transform:s},a=dd(s.cameraType)?new ug(o):new dg(o),c=this._intersection.interactiveLayer;this._setCameraVisibility(a,r,c),this.cameras.add(a),this._cameraFrames[n]=a;this._intersection.add(a,n);const h=this._props[n].ids;(e=this.clusterVisibles)[i=h.clusterId]||(e[i]=r),this._connectedComponents.get(h.ccId).push(a),this._clusters.get(h.clusterId).push(a),this._sequences.get(h.sequenceId).push(a);const l={material:this._positionMaterial,mode:t.positionMode,originalOrigin:t.originalPosition,transform:s},u=new hg(l);u.visible=r,this._positions.add(u),this._positionLines[n]=u}_disposeCameras(){const t=this._intersection,e=this.cameras;for(const i of e.children.slice())i.dispose(),t.remove(i),e.remove(i);this._scene.remove(this.cameras)}_disposePositions(){const t=this._positions;for(const e of t.children.slice())e.dispose(),t.remove(e);this._scene.remove(this._positions)}_setCameraVisibility(t,e,i){t.visible=e,e?t.layers.enable(i):t.layers.disable(i)}}class fg{constructor(){this._colors=new Map;const e=t.CameraVisualizationMode;this._colors.set(e[e.Homogeneous],"#FFFFFF")}getColor(t){const e=this._colors;return e.has(t)||e.set(t,this._randomColor()),e.get(t)}_randomColor(){return`hsl(${Math.floor(360*Math.random())}, 100%, 50%)`}}function mg(e){return e!==t.CameraVisualizationMode.Hidden}class gg{constructor(e,i){this._rayNearScale=1.1,this._originalPointSize=2,this._originalCameraSize=2,this._imageCellMap=new Map,this._scene=i||new Qa,this._scene.autoUpdate=!1,this._intersection=new cg,this._assets=new fg,this._needsRender=!1,this._images={},this._cells={},this._cellClusters={},this._clusters={},this._cameraVisualizationMode=e.cameraVisualizationMode?e.cameraVisualizationMode:t.CameraVisualizationMode.Homogeneous,this._cameraSize=e.cameraSize,this._pointSize=e.pointSize,this._pointsVisible=e.pointsVisible,this._positionMode=e.originalPositionMode,this._cellsVisible=e.cellsVisible,this._hoveredId=null,this._selectedId=null,this._colors={hover:"#FF0000",select:"#FF8000"},this._filter=()=>!0}get needsRender(){return this._needsRender}get intersection(){return this._intersection}addCluster(t,e,i){if(this.hasCluster(t.id,i))return;const n=t.id;if(!(n in this._clusters)){this._clusters[n]={points:new pr,cellIds:[]};const i=this._getClusterVisible(n);this._clusters[n].points.visible=i,this._clusters[n].points.add(new ig({cluster:t,originalSize:this._originalPointSize,scale:this._pointSize,translation:e})),this._scene.add(this._clusters[n].points)}-1===this._clusters[n].cellIds.indexOf(i)&&this._clusters[n].cellIds.push(i),i in this._cellClusters||(this._cellClusters[i]={keys:[]}),-1===this._cellClusters[i].keys.indexOf(n)&&this._cellClusters[i].keys.push(n),this._needsRender=!0}addImage(t,e,i,n){var r,s,o;const a=t.id,c={clusterId:null!==(r=t.clusterId)&&void 0!==r?r:"NO_CLUSTER_ID",sequenceId:null!==(s=t.sequenceId)&&void 0!==s?s:"NO_SEQUENCE_ID",ccId:null!==(o=t.mergeId)&&void 0!==o?o:"NO_MERGE_ID"};if(!(n in this._images)){const t=new pg(n,this._scene,this._intersection);t.cameras.visible=mg(this._cameraVisualizationMode),t.applyPositionMode(this._positionMode),this._images[n]=t}const h=this._images[n];if(h.hasImage(a))return;h.addImage({idMap:c,image:t});const l=h.getColorId(a,this._cameraVisualizationMode),u=this._assets.getColor(l),d=this._filter(t);if(h.visualize({id:a,color:u,positionMode:this._positionMode,scale:this._cameraSize,transform:e,visible:d,maxSize:this._originalCameraSize,originalPosition:i}),this._imageCellMap.set(a,n),a===this._selectedId&&this._highlight(a,this._colors.select,this._cameraVisualizationMode),c.clusterId in this._clusters){const t=this._getClusterVisible(c.clusterId);this._clusters[c.clusterId].points.visible=t}this._needsRender=!0}addCell(t,e){if(this.hasCell(e))return;const i=new ng(t);this._cells[e]=new pr,this._cells[e].visible=this._cellsVisible,this._cells[e].add(i),this._scene.add(this._cells[e]),this._needsRender=!0}deactivate(){this._filter=()=>!0,this._selectedId=null,this._hoveredId=null,this.uncache()}hasCluster(t,e){return t in this._clusters&&-1!==this._clusters[t].cellIds.indexOf(e)}hasCell(t){return t in this._cells}hasImage(t,e){return e in this._images&&this._images[e].hasImage(t)}setCameraSize(t){if(Math.abs(t-this._cameraSize)<.001)return;const e=this._images;for(const i of Object.keys(e))e[i].applyCameraSize(t);this._intersection.raycaster.near=this._getNear(t),this._cameraSize=t,this._needsRender=!0}setFilter(t){this._filter=t;const e={};for(const i of Object.values(this._images)){i.applyFilter(t);const n=i.clusterVisibles;for(const t in n)n.hasOwnProperty(t)&&(t in e||(e[t]=!1),e[t]||(e[t]=n[t]))}const i=this._pointsVisible;for(const t in e){if(!e.hasOwnProperty(t))continue;e[t]&&(e[t]=i);const n=e[t];t in this._clusters&&(this._clusters[t].points.visible=n)}this._needsRender=!0}setHoveredImage(t){if(null!=t&&!this._imageCellMap.has(t))throw new cd(`Image does not exist: ${t}`);this._hoveredId!==t&&(this._needsRender=!0,null!=this._hoveredId&&(this._hoveredId===this._selectedId?this._highlight(this._hoveredId,this._colors.select,this._cameraVisualizationMode):this._resetCameraColor(this._hoveredId)),this._highlight(t,this._colors.hover,this._cameraVisualizationMode),this._hoveredId=t)}setNavigationState(t){this._intersection.resetIntersectionThreshold(t)}setPointSize(t){if(Math.abs(t-this._pointSize)<.001)return;const e=this._clusters;for(const i in e)if(e.hasOwnProperty(i))for(const n of e[i].points.children)n.resize(t);this._pointSize=t,this._needsRender=!0}setPointVisibility(t){if(t!==this._pointsVisible){for(const e in this._clusters)this._clusters.hasOwnProperty(e)&&(this._clusters[e].points.visible=t);this._pointsVisible=t,this._needsRender=!0}}setPositionMode(t){if(t!==this._positionMode){for(const e of Object.values(this._images))e.applyPositionMode(t);this._positionMode=t,this._needsRender=!0}}setSelectedImage(t){this._selectedId!==t&&(this._needsRender=!0,null!=this._selectedId&&this._resetCameraColor(this._selectedId),this._highlight(t,this._colors.select,this._cameraVisualizationMode),this._selectedId=t)}setCellVisibility(t){if(t!==this._cellsVisible){for(const e in this._cells)this._cells.hasOwnProperty(e)&&(this._cells[e].visible=t);this._cellsVisible=t,this._needsRender=!0}}setCameraVisualizationMode(t){if(t===this._cameraVisualizationMode)return;const e=mg(t),i=this._assets;for(const n of Object.values(this._images)){n.cameras.visible=e;n.getCamerasByMode(t).forEach(((t,e)=>{const n=i.getColor(e);for(const e of t)e.setColor(n)}))}this._highlight(this._hoveredId,this._colors.hover,t),this._highlight(this._selectedId,this._colors.select,t),this._cameraVisualizationMode=t,this._needsRender=!0}render(t,e){e.render(this._scene,t),this._needsRender=!1}uncache(t){for(const e of Object.keys(this._cellClusters))t&&-1!==t.indexOf(e)||this._disposeReconstruction(e);for(const e of Object.keys(this._images)){if(t&&-1!==t.indexOf(e))continue;const i=this._imageCellMap,n=this._images[e].keys;for(const t of n)i.delete(t);this._images[e].dispose(),delete this._images[e]}for(const e of Object.keys(this._cells))t&&-1!==t.indexOf(e)||this._disposeCell(e);this._needsRender=!0}_getClusterVisible(t){if(!this._pointsVisible)return!1;let e=!1;for(const i of Object.values(this._images)){const n=i.clusterVisibles;t in n&&(e||(e=n[t]))}return e}_disposePoints(t){for(const e of this._cellClusters[t].keys){if(!(e in this._clusters))continue;const i=this._clusters[e].cellIds.indexOf(t);if(-1!==i&&(this._clusters[e].cellIds.splice(i,1),!(this._clusters[e].cellIds.length>0))){for(const t of this._clusters[e].points.children.slice())t.dispose();this._scene.remove(this._clusters[e].points),delete this._clusters[e]}}}_disposeReconstruction(t){this._disposePoints(t),delete this._cellClusters[t]}_disposeCell(t){const e=this._cells[t];for(const t of e.children.slice())t.dispose(),e.remove(t);this._scene.remove(e),delete this._cells[t]}_getNear(t){const e=this._rayNearScale*this._originalCameraSize*t;return Math.max(1,e)}_resetCameraColor(t){const e=this._imageCellMap;if(null==t||!e.has(t))return;const i=e.get(t),n=this._images[i],r=n.getColorId(t,this._cameraVisualizationMode),s=this._assets.getColor(r);n.applyCameraColor(t,s)}_highlight(e,i,n){const r=this._imageCellMap;if(null==e||!r.has(e))return;const s=r.get(e);i=n===t.CameraVisualizationMode.Homogeneous?i:"#FFFFFF",this._images[s].applyCameraColor(e,i)}}class _g{constructor(t,e){this._graphService=t,this._data=e,this._cells={},this._cacheRequests={},this._clusters={},this._clusterCells={},this._cellClusters={},this._cachingCells$={},this._cachingClusters$={}}cacheClusters$(t){if(!this.hasCell(t))throw new Error("Cannot cache reconstructions of a non-existing cell.");if(this.hasClusters(t))throw new Error("Cannot cache reconstructions that already exists.");if(this.isCachingClusters(t))return this._cachingClusters$[t];const e=this.getCell(t).filter((t=>!!t.clusterId&&!!t.clusterUrl)).map((t=>({key:t.clusterId,url:t.clusterUrl}))),i=Array.from(new Map(e.map((t=>[t.key,t]))).values());let n;this._cellClusters[t]=i,this._cacheRequests[t]=[];const r=new Promise(((t,e)=>{n=e}));return this._cacheRequests[t].push(n),this._cachingClusters$[t]=this._cacheClusters$(i,t,r).pipe(Me((()=>{t in this._cachingClusters$&&delete this._cachingClusters$[t],t in this._cacheRequests&&delete this._cacheRequests[t]})),He(),E()),this._cachingClusters$[t]}cacheCell$(t){if(this.hasCell(t))throw new Error("Cannot cache cell that already exists.");return this.isCachingCell(t)||(this._cachingCells$[t]=this._graphService.cacheCell$(t).pipe(te((t=>(console.error(t),B()))),Nt((()=>!(t in this._cells))),pi((e=>{this._cells[t]=[],this._cells[t].push(...e),delete this._cachingCells$[t]})),Me((()=>{t in this._cachingCells$&&delete this._cachingCells$[t]})),He(),E())),this._cachingCells$[t]}isCachingClusters(t){return t in this._cachingClusters$}isCachingCell(t){return t in this._cachingCells$}hasClusters(t){if(t in this._cachingClusters$||!(t in this._cellClusters))return!1;for(const e of this._cellClusters[t])if(!(e.key in this._clusters))return!1;return!0}hasCell(t){return!(t in this._cachingCells$)&&t in this._cells}getClusters(t){return t in this._cellClusters?this._cellClusters[t].map((t=>this._clusters[t.key])).filter((t=>!!t)):[]}getCell(t){return t in this._cells?this._cells[t]:[]}uncache(t){for(let e of Object.keys(this._cacheRequests))if(!t||-1===t.indexOf(e)){for(const t of this._cacheRequests[e])t();delete this._cacheRequests[e]}for(let e of Object.keys(this._cellClusters))if(!t||-1===t.indexOf(e)){for(const t of this._cellClusters[e]){if(!(t.key in this._clusterCells))continue;const i=this._clusterCells[t.key].indexOf(e);-1!==i&&(this._clusterCells[t.key].splice(i,1),this._clusterCells[t.key].length>0||(delete this._clusterCells[t.key],delete this._clusters[t.key]))}delete this._cellClusters[e]}for(let e of Object.keys(this._cells))t&&-1!==t.indexOf(e)||delete this._cells[e]}updateCell$(t){if(!this.hasCell(t))throw new Error("Cannot update cell that does not exists.");return this._graphService.cacheCell$(t).pipe(te((t=>(console.error(t),B()))),Nt((()=>t in this._cells)),pi((e=>{this._cells[t]=[],this._cells[t].push(...e)})),He(),E())}updateClusters$(t){if(!this.hasCell(t))throw new Error("Cannot update reconstructions of a non-existing cell.");if(!this.hasClusters(t))throw new Error("Cannot update reconstructions for cell that is not cached.");const e=this.getCell(t).filter((t=>!!t.clusterId&&!!t.clusterUrl)).map((t=>({key:t.clusterId,url:t.clusterUrl}))),i=Array.from(new Map(e.map((t=>[t.key,t]))).values()).filter((t=>!(t.key in this._clusters)));return this._cellClusters[t].push(...i),this._cacheClusters$(i,t,null)}_cacheClusters$(t,e,i){return bt(t).pipe(Mt((t=>this._hasCluster(t.key)?G(this._getCluster(t.key)):this._getCluster$(t.url,t.key,i).pipe(te((t=>(t instanceof Zf||console.error(t),B()))))),6),Nt((()=>e in this._cellClusters)),pi((t=>{this._hasCluster(t.id)||(this._clusters[t.id]=t),t.id in this._clusterCells||(this._clusterCells[t.id]=[]),-1===this._clusterCells[t.id].indexOf(e)&&this._clusterCells[t.id].push(e)})))}_getCluster(t){return this._clusters[t]}_getCluster$(t,e,i){return b.create((n=>{this._data.getCluster(t,i).then((t=>{t.id=e,n.next(t),n.complete()}),(t=>{n.error(t)}))}))}_hasCluster(t){return t in this._clusters}}function vg(t,e,i){const n=new Set;return n.add(t),yg(n,[t],0,e,i),Array.from(n)}function yg(t,e,i,n,r){if(i>=n)return;const s=[];for(const t of e){const e=r.getAdjacent(t);s.push(...e)}const o=[];for(const e of s)t.has(e)||(t.add(e),o.push(e));yg(t,o,i+1,n,r)}class bg extends Vf{constructor(t,e,i){super(t,e,i),this._cache=new _g(i.graphService,i.api.data),this._scene=new gg(this._getDefaultConfiguration()),this._viewportCoords=new Wf,this._spatial=new ld}getFrameIdAt(t){return new Promise(((e,i)=>{this._container.renderService.renderCamera$.pipe(Ee(),rt((e=>{const i=this._viewportCoords.canvasToViewport(t[0],t[1],this._container.container);return this._scene.intersection.intersectObjects(i,e.perspective)}))).subscribe((t=>{e(t)}),(t=>{i(t)}))}))}_activate(){this._navigator.cacheService.configure({cellDepth:3});const t=this._subscriptions;t.push(this._navigator.stateService.reference$.subscribe((()=>{this._scene.uncache()}))),t.push(this._navigator.graphService.filter$.subscribe((t=>{this._scene.setFilter(t)})));const e=this._container.renderService.bearing$.pipe(rt((t=>6*Math.floor(t/6))),ue(),Ue(1),E()),i=this._navigator.stateService.currentImage$.pipe(rt((t=>this._navigator.api.data.geometry.lngLatToCellId(t.originalLngLat))),ue(),Ue(1),E()),n=this._configuration$.pipe(rt((t=>this._spatial.clamp(t.cellGridDepth,1,3))),ue(),Ue(1),E()),r=gt(this._navigator.playService.playing$,this._navigator.playService.speed$).pipe(rt((([t,e])=>t&&e>eg.sequenceSpeed)),ue(),Ue(1),E()),s=this._navigator.stateService.state$.pipe(rt((t=>function(t){return t===vm.Custom||t===vm.Earth}(t))),ue(),Ue(1),E());t.push(s.subscribe((t=>{this._scene.setNavigationState(t)})));const o=gt(s,r,e,n,this._navigator.stateService.currentImage$).pipe(ue((([t,e,i,n,r],[s,o,a,c,h])=>{if(t!==s)return!1;const l=r.id===h.id&&e===o&&n===c;return t?l:l&&i===a})),ne((([t,e,i,n,r])=>{if(t){const t=this._navigator.api.data.geometry,i=t.lngLatToCellId(r.originalLngLat);return G(e?[i]:vg(i,n,t))}const s=e?30:90;return G(this._cellsInFov(r,i,s))})),ri((t=>bt(t).pipe(Mt((t=>(this._cache.hasCell(t)?G(this._cache.getCell(t)):this._cache.cacheCell$(t)).pipe(rt((e=>({id:t,images:e}))))),6)))));t.push(o.pipe(bi(this._navigator.stateService.reference$)).subscribe((([t,e])=>{this._scene.hasCell(t.id)||this._scene.addCell(this._cellToTopocentric(t.id,e),t.id)}))),t.push(o.pipe(bi(this._navigator.stateService.reference$)).subscribe((([t,e])=>{this._addSceneImages(t,e)}))),t.push(o.pipe(ne((t=>{const e=t.id;let i;return i=this._cache.hasClusters(e)?bt(this._cache.getClusters(e)):this._cache.isCachingClusters(e)?this._cache.cacheClusters$(e).pipe(Re(null,{}),ri((()=>bt(this._cache.getClusters(e))))):this._cache.hasCell(e)?this._cache.cacheClusters$(e):B(),gt(G(e),i)})),bi(this._navigator.stateService.reference$)).subscribe((([[t,e],i])=>{this._scene.hasCluster(e.id,t)||this._scene.addCluster(e,this._computeTranslation(e,i),t)}))),t.push(this._configuration$.pipe(rt((t=>(t.cameraSize=this._spatial.clamp(t.cameraSize,.01,1),t.pointSize=this._spatial.clamp(t.pointSize,.01,1),{cameraSize:t.cameraSize,cameraVisualizationMode:t.cameraVisualizationMode,cellsVisible:t.cellsVisible,originalPositionMode:t.originalPositionMode,pointSize:t.pointSize,pointsVisible:t.pointsVisible}))),ue(((t,e)=>t.cameraSize===e.cameraSize&&t.cameraVisualizationMode===e.cameraVisualizationMode&&t.cellsVisible===e.cellsVisible&&t.originalPositionMode===e.originalPositionMode&&t.pointSize===e.pointSize&&t.pointsVisible===e.pointsVisible))).subscribe((t=>{this._scene.setCameraSize(t.cameraSize),this._scene.setPointSize(t.pointSize),this._scene.setPointVisibility(t.pointsVisible),this._scene.setCellVisibility(t.cellsVisible);const e=t.cameraVisualizationMode;this._scene.setCameraVisualizationMode(e);const i=t.originalPositionMode;this._scene.setPositionMode(i)}))),t.push(gt(i,n).subscribe((([t,e])=>{const i=vg(t,e,this._navigator.api.data.geometry);this._scene.uncache(i),this._cache.uncache(i)}))),t.push(this._navigator.playService.playing$.pipe(ri((t=>t?B():this._container.mouseService.dblClick$)),bi(this._container.renderService.renderCamera$),ri((([t,e])=>{const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(t,i),s=this._viewportCoords.canvasToViewport(n,r,i),o=this._scene.intersection.intersectObjects(s,e.perspective);return o?this._navigator.moveTo$(o).pipe(te((()=>B()))):B()}))).subscribe());const a=gt(this._configuration$,this._navigator.stateService.state$).pipe(rt((([t,e])=>(t.cameraSize=this._spatial.clamp(t.cameraSize,.01,1),{size:t.cameraSize,visible:mg(t.cameraVisualizationMode),state:e}))),ue(((t,e)=>t.size===e.size&&t.visible===e.visible&&t.state===e.state))),c=this._container.mouseService.mouseMove$.pipe(Ue(1),E());t.push(c.subscribe());const h=Ot(this._container.mouseService.mouseEnter$,this._container.mouseService.mouseLeave$,this._container.mouseService.windowBlur$);t.push(gt(this._navigator.playService.playing$,h,s,this._navigator.graphService.filter$).pipe(ri((([t,e])=>t||"pointerenter"!==e.type?gt(G(e),G(null),G(null)):gt(At(c.pipe(ve(1)),this._container.mouseService.mouseMove$),this._container.renderService.renderCamera$,a)))).subscribe((([t,e])=>{if("pointermove"!==t.type)return void this._scene.setHoveredImage(null);const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(t,i),s=this._viewportCoords.canvasToViewport(n,r,i),o=this._scene.intersection.intersectObjects(s,e.perspective);this._scene.setHoveredImage(o)}))),t.push(this._navigator.stateService.currentId$.subscribe((t=>{this._scene.setSelectedImage(t)}))),t.push(this._navigator.stateService.currentState$.pipe(rt((t=>{const e=this._scene;return{name:this._name,renderer:{frameId:t.id,needsRender:e.needsRender,render:e.render.bind(e),pass:rm.Opaque}}}))).subscribe(this._container.glRenderer.render$));const l=this._navigator.graphService.dataAdded$.pipe(Nt((t=>this._cache.hasCell(t))),Mt((t=>this._cache.updateCell$(t).pipe(rt((e=>({id:t,images:e}))),bi(this._navigator.stateService.reference$)))),He(),E());t.push(l.subscribe((([t,e])=>{this._addSceneImages(t,e)}))),t.push(l.pipe(ne((([t])=>{const e=t.id,i=this._cache;let n;return n=i.hasClusters(e)?i.updateClusters$(e):i.isCachingClusters(e)?this._cache.cacheClusters$(e).pipe(Re(null,{}),ri((()=>bt(i.updateClusters$(e))))):B(),gt(G(e),n)})),bi(this._navigator.stateService.reference$)).subscribe((([[t,e],i])=>{this._scene.hasCluster(e.id,t)||this._scene.addCluster(e,this._computeTranslation(e,i),t)})))}_deactivate(){this._subscriptions.unsubscribe(),this._cache.uncache(),this._scene.deactivate(),this._navigator.cacheService.configure()}_getDefaultConfiguration(){return{cameraSize:.1,cameraVisualizationMode:t.CameraVisualizationMode.Homogeneous,cellGridDepth:1,originalPositionMode:t.OriginalPositionMode.Hidden,pointSize:.1,pointsVisible:!0,cellsVisible:!1}}_addSceneImages(t,e){const i=t.id,n=t.images;for(const t of n)this._scene.hasImage(t.id,i)||this._scene.addImage(t,this._createTransform(t,e),this._computeOriginalPosition(t,e),i)}_cellsInFov(t,e,i){const n=this._spatial,r=this._navigator.api.data.geometry,s=r.lngLatToCellId(t.originalLngLat),o=[s],a=i/2,c=r.getAdjacent(s);for(const i of c){const s=r.getVertices(i);for(const r of s){const[s,c]=Ju(r.lng,r.lat,0,t.lngLat.lng,t.lngLat.lat,0),h=Math.atan2(c,s),l=n.radToDeg(n.azimuthalToBearing(h));Math.abs(l-e)<a&&o.push(i)}}return o}_computeOriginalPosition(t,e){return Ju(t.originalLngLat.lng,t.originalLngLat.lat,null!=t.originalAltitude?t.originalAltitude:t.computedAltitude,e.lng,e.lat,e.alt)}_cellToTopocentric(t,e){return this._navigator.api.data.geometry.getVertices(t).map((t=>Ju(t.lng,t.lat,-2,e.lng,e.lat,e.alt)))}_computeTranslation(t,e){return Ju(t.reference.lng,t.reference.lat,t.reference.alt,e.lng,e.lat,e.alt)}_createTransform(t,e){const i=fd({alt:t.computedAltitude,lat:t.lngLat.lat,lng:t.lngLat.lng},t.rotation,e);return new Hd(t.exifOrientation,t.width,t.height,t.scale,t.rotation,i,void 0,void 0,t.cameraParameters,t.cameraType)}}bg.componentName="spatial";class xg{constructor(){this._notifyChanged$=new T}get changed$(){return this._notifyChanged$}}class wg extends cd{constructor(t){super(null!=t?t:"The provided geometry value is incorrect"),Object.setPrototypeOf(this,wg.prototype),this.name="GeometryTagError"}}class Sg extends xg{constructor(t){super();if(t.length<2)throw new wg("A points geometry must have two or more positions.");this._points=[];for(const e of t){if(e[0]<0||e[0]>1||e[1]<0||e[1]>1)throw new wg("Basic coordinates of points must be on the interval [0, 1].");this._points.push(e.slice())}}get points(){return this._points}addPoint2d(t){const e=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];this._points.push(e),this._notifyChanged$.next(this)}getPoint2d(t){return this._points[t].slice()}removePoint2d(t){if(t<0||t>=this._points.length||this._points.length<3)throw new wg("Index for removed point must be valid.");this._points.splice(t,1),this._notifyChanged$.next(this)}setVertex2d(t,e,i){this.setPoint2d(t,e,i)}setPoint2d(t,e,i){const n=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._points[t]=n,this._notifyChanged$.next(this)}getPoints3d(t){return this._getPoints3d(this._points,t)}getPoint3d(t,e){return e.unprojectBasic(this._points[t],200)}getPoints2d(){return this._points.slice()}getCentroid2d(t){if(!t)throw new wg("Get centroid must be called with a transform for points geometries.");const[e,i,n,r]=this.getRect2d(t);return[e<n?(e+n)/2:(e+n+1)/2%1,(i+r)/2]}getCentroid3d(t){let e=this.getCentroid2d();return t.unprojectBasic(e,200)}getRect2d(t){let e=1,i=0,n=1,r=0;const s=this._points;for(const t of s)t[0]<e&&(e=t[0]),t[0]>i&&(i=t[0]),t[1]<n&&(n=t[1]),t[1]>r&&(r=t[1]);if(dd(t.cameraType)){const t=[];for(let e=0;e<s.length;e++)t[e]=e;t.sort(((t,e)=>s[t][0]<s[e][0]?-1:s[t][0]>s[e][0]?1:t<e?-1:1));let n=s[t[0]][0]+1-s[t[t.length-1]][0],r=0;for(let e=0;e<t.length-1;e++){const i=t[e],o=t[e+1],a=s[o][0]-s[i][0];a>n&&(n=a,r=e+1)}r>0&&(e=s[t[r]][0],i=s[t[r-1]][0])}return[e,n,i,r]}setCentroid2d(t,e){throw new Error("Not implemented")}_getPoints3d(t,e){return t.map((t=>e.unprojectBasic(t,200)))}}class Mg{constructor(t,e,i){this._geometry=t,this._transform=e,this._viewportCoords=i||new Wf,this._aborted$=new T,this._created$=new T,this._glObjectsChanged$=new T,this._geometryChangedSubscription=this._geometry.changed$.subscribe((()=>{this._onGeometryChanged(),this._glObjectsChanged$.next(this)}))}get geometry(){return this._geometry}get glObjects(){return this._glObjects}get aborted$(){return this._aborted$}get created$(){return this._created$}get glObjectsChanged$(){return this._glObjectsChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(rt((()=>this)))}dispose(){this._geometryChangedSubscription.unsubscribe()}_canvasToTransform(t){return`translate(-50%,-50%) translate(${Math.round(t[0])}px,${Math.round(t[1])}px)`}_colorToBackground(t){return"#"+("000000"+t.toString(16)).substr(-6)}_createOutine(t,e){const i=this._getLinePositions(t),n=new hs;n.setAttribute("position",new Hr(i,3));return new Uc(n,new kc({color:e,linewidth:1}))}_disposeLine(t){null!=t&&(t.geometry.dispose(),t.material.dispose())}_getLinePositions(t){const e=t.length,i=new Float32Array(3*e);for(let n=0;n<e;++n){const e=3*n,r=t[n];i[e]=r[0],i[e+1]=r[1],i[e+2]=r[2]}return i}}var Tg=Eg,Cg=Eg;function Eg(t,e,i){i=i||2;var n,r,s,o,a,c,h,l=e&&e.length,u=l?e[0]*i:t.length,d=Ig(t,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,i,n){var r,s,o,a=[];for(r=0,s=e.length;r<s;r++)(o=Ig(t,e[r]*n,r<s-1?e[r+1]*n:t.length,n,!1))===o.next&&(o.steiner=!0),a.push(Fg(o));for(a.sort(Dg),r=0;r<a.length;r++)$g(a[r],i),i=Ag(i,i.next);return i}(t,e,d,i)),t.length>80*i){n=s=t[0],r=o=t[1];for(var f=i;f<u;f+=i)(a=t[f])<n&&(n=a),(c=t[f+1])<r&&(r=c),a>s&&(s=a),c>o&&(o=c);h=0!==(h=Math.max(s-n,o-r))?1/h:0}return Pg(d,p,i,n,r,h),p}function Ig(t,e,i,n,r){var s,o;if(r===Kg(t,e,i,n)>0)for(s=e;s<i;s+=n)o=Yg(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=Yg(s,t[s],t[s+1],o);return o&&Ug(o,o.next)&&(Zg(o),o=o.next),o}function Ag(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!Ug(n,n.next)&&0!==Hg(n.prev,n,n.next))n=n.next;else{if(Zg(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function Pg(t,e,i,n,r,s,o){if(t){!o&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=zg(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,s,o,a,c,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<h&&(a++,n=n.nextZ);e++);for(c=h;a>0||c>0&&n;)0!==a&&(0===c||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)}(r)}(t,n,r,s);for(var a,c,h=t;t.prev!==t.next;)if(a=t.prev,c=t.next,s?Lg(t,n,r,s):Rg(t))e.push(a.i/i),e.push(t.i/i),e.push(c.i/i),Zg(t),t=c.next,h=c.next;else if((t=c)===h){o?1===o?Pg(t=Og(Ag(t),e,i),e,i,n,r,s,2):2===o&&Ng(t,e,i,n,r,s):Pg(Ag(t),e,i,n,r,s,1);break}}}function Rg(t){var e=t.prev,i=t,n=t.next;if(Hg(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Bg(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Hg(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Lg(t,e,i,n){var r=t.prev,s=t,o=t.next;if(Hg(r,s,o)>=0)return!1;for(var a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,c=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=zg(a,c,e,i,n),d=zg(h,l,e,i,n),p=t.prevZ,f=t.nextZ;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Bg(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Hg(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Bg(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Hg(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Bg(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Hg(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Bg(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Hg(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Og(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Ug(r,s)&&Vg(r,n,n.next,s)&&Wg(r,s)&&Wg(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Zg(n),Zg(n.next),n=t=s),n=n.next}while(n!==t);return Ag(n)}function Ng(t,e,i,n,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&jg(o,a)){var c=Xg(o,a);return o=Ag(o,o.next),c=Ag(c,c.next),Pg(o,e,i,n,r,s),void Pg(c,e,i,n,r,s)}a=a.next}o=o.next}while(o!==t)}function Dg(t,e){return t.x-e.x}function $g(t,e){if(e=function(t,e){var i,n=e,r=t.x,s=t.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o){if(o=a,a===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!i)return null;if(r===o)return i;var c,h=i,l=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=l&&r!==n.x&&Bg(s<u?r:o,s,l,u,s<u?o:r,s,n.x,n.y)&&(c=Math.abs(s-n.y)/(r-n.x),Wg(n,t)&&(c<d||c===d&&(n.x>i.x||n.x===i.x&&kg(i,n)))&&(i=n,d=c)),n=n.next}while(n!==h);return i}(t,e)){var i=Xg(e,t);Ag(e,e.next),Ag(i,i.next)}}function kg(t,e){return Hg(t.prev,t,e.prev)<0&&Hg(e.next,t,t.next)<0}function zg(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Fg(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Bg(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function jg(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Vg(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Wg(t,e)&&Wg(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Hg(t.prev,t,e.prev)||Hg(t,e.prev,e))||Ug(t,e)&&Hg(t.prev,t,t.next)>0&&Hg(e.prev,e,e.next)>0)}function Hg(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ug(t,e){return t.x===e.x&&t.y===e.y}function Vg(t,e,i,n){var r=qg(Hg(t,e,i)),s=qg(Hg(t,e,n)),o=qg(Hg(i,n,t)),a=qg(Hg(i,n,e));return r!==s&&o!==a||(!(0!==r||!Gg(t,i,e))||(!(0!==s||!Gg(t,n,e))||(!(0!==o||!Gg(i,t,n))||!(0!==a||!Gg(i,e,n)))))}function Gg(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function qg(t){return t>0?1:t<0?-1:0}function Wg(t,e){return Hg(t.prev,t,t.next)<0?Hg(t,e,t.next)>=0&&Hg(t,t.prev,e)>=0:Hg(t,e,t.prev)<0||Hg(t,t.next,e)<0}function Xg(t,e){var i=new Jg(t.i,t.x,t.y),n=new Jg(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Yg(t,e,i,n){var r=new Jg(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Zg(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Jg(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Kg(t,e,i,n){for(var r=0,s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}Eg.deviation=function(t,e,i,n){var r=e&&e.length,s=r?e[0]*i:t.length,o=Math.abs(Kg(t,0,s,i));if(r)for(var a=0,c=e.length;a<c;a++){var h=e[a]*i,l=a<c-1?e[a+1]*i:t.length;o-=Math.abs(Kg(t,h,l,i))}var u=0;for(a=0;a<n.length;a+=3){var d=n[a]*i,p=n[a+1]*i,f=n[a+2]*i;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},Eg.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<e;o++)i.vertices.push(t[r][s][o]);r>0&&(n+=t[r-1].length,i.holes.push(n))}return i},Tg.default=Cg;function Qg(t,e){return t<e?-1:t>e?1:0}var t_=xp(Object.freeze({__proto__:null,default:class{constructor(t=[],e=Qg){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(i(n,s)>=0)break;e[t]=s,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t<n;){let n=1+(t<<1),s=e[n];const o=n+1;if(o<this.length&&i(e[o],s)<0&&(n=o,s=e[o]),i(s,r)>=0)break;e[t]=s,t=n}e[t]=r}}}));t_.default&&(t_=t_.default);var e_=n_,i_=n_;function n_(t,e,i){var n,r,s,o;e=e||1;for(var a=0;a<t[0].length;a++){var c=t[0][a];(!a||c[0]<n)&&(n=c[0]),(!a||c[1]<r)&&(r=c[1]),(!a||c[0]>s)&&(s=c[0]),(!a||c[1]>o)&&(o=c[1])}var h=s-n,l=o-r,u=Math.min(h,l),d=u/2;if(0===u){var p=[n,r];return p.distance=0,p}for(var f=new t_(void 0,r_),m=n;m<s;m+=u)for(var g=r;g<o;g+=u)f.push(new s_(m+d,g+d,d,t));var _=function(t){for(var e=0,i=0,n=0,r=t[0],s=0,o=r.length,a=o-1;s<o;a=s++){var c=r[s],h=r[a],l=c[0]*h[1]-h[0]*c[1];i+=(c[0]+h[0])*l,n+=(c[1]+h[1])*l,e+=3*l}return 0===e?new s_(r[0][0],r[0][1],0,t):new s_(i/e,n/e,0,t)}(t),v=new s_(n+h/2,r+l/2,0,t);v.d>_.d&&(_=v);for(var y=f.length;f.length;){var b=f.pop();b.d>_.d&&(_=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,y)),b.max-_.d<=e||(d=b.h/2,f.push(new s_(b.x-d,b.y-d,d,t)),f.push(new s_(b.x+d,b.y-d,d,t)),f.push(new s_(b.x-d,b.y+d,d,t)),f.push(new s_(b.x+d,b.y+d,d,t)),y+=4)}i&&(console.log("num probes: "+y),console.log("best distance: "+_.d));var x=[_.x,_.y];return x.distance=_.d,x}function r_(t,e){return e.max-t.max}function s_(t,e,i,n){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var n=!1,r=1/0,s=0;s<i.length;s++)for(var o=i[s],a=0,c=o.length,h=c-1;a<c;h=a++){var l=o[a],u=o[h];l[1]>e!=u[1]>e&&t<(u[0]-l[0])*(e-l[1])/(u[1]-l[1])+l[0]&&(n=!n),r=Math.min(r,o_(t,e,l,u))}return 0===r?0:(n?1:-1)*Math.sqrt(r)}(t,e,n),this.max=this.d+this.h*Math.SQRT2}function o_(t,e,i,n){var r=i[0],s=i[1],o=n[0]-r,a=n[1]-s;if(0!==o||0!==a){var c=((t-r)*o+(e-s)*a)/(o*o+a*a);c>1?(r=n[0],s=n[1]):c>0&&(r+=o*c,s+=a*c)}return(o=t-r)*o+(a=e-s)*a}function a_(t,e){return t>e?1:t<e?-1:0}e_.default=i_;class c_{constructor(t=a_,e=!1){this._compare=t,this._root=null,this._size=0,this._noDuplicates=!!e}rotateLeft(t){var e=t.right;e&&(t.right=e.left,e.left&&(e.left.parent=t),e.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.left=t),t.parent=e}rotateRight(t){var e=t.left;e&&(t.left=e.right,e.right&&(e.right.parent=t),e.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.right=t),t.parent=e}_splay(t){for(;t.parent;){var e=t.parent;e.parent?e.left===t&&e.parent.left===e?(this.rotateRight(e.parent),this.rotateRight(e)):e.right===t&&e.parent.right===e?(this.rotateLeft(e.parent),this.rotateLeft(e)):e.left===t&&e.parent.right===e?(this.rotateRight(e),this.rotateLeft(e)):(this.rotateLeft(e),this.rotateRight(e)):e.left===t?this.rotateRight(e):this.rotateLeft(e)}}splay(t){for(var e,i,n,r,s;t.parent;)(i=(e=t.parent).parent)&&i.parent?((n=i.parent).left===i?n.left=t:n.right=t,t.parent=n):(t.parent=null,this._root=t),r=t.left,s=t.right,t===e.left?(i&&(i.left===e?(e.right?(i.left=e.right,i.left.parent=i):i.left=null,e.right=i,i.parent=e):(r?(i.right=r,r.parent=i):i.right=null,t.left=i,i.parent=t)),s?(e.left=s,s.parent=e):e.left=null,t.right=e,e.parent=t):(i&&(i.right===e?(e.left?(i.right=e.left,i.right.parent=i):i.right=null,e.left=i,i.parent=e):(s?(i.left=s,s.parent=i):i.left=null,t.right=i,i.parent=t)),r?(e.right=r,r.parent=e):e.right=null,t.left=e,e.parent=t)}replace(t,e){t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.parent=t.parent)}minNode(t=this._root){if(t)for(;t.left;)t=t.left;return t}maxNode(t=this._root){if(t)for(;t.right;)t=t.right;return t}insert(t,e){var i=this._root,n=null,r=this._compare;if(this._noDuplicates)for(;i;){if(n=i,0===r(i.key,t))return;i=r(i.key,t)<0?i.right:i.left}else for(;i;)n=i,i=r(i.key,t)<0?i.right:i.left;return i={key:t,data:e,left:null,right:null,parent:n},n?r(n.key,i.key)<0?n.right=i:n.left=i:this._root=i,this.splay(i),this._size++,i}find(t){for(var e=this._root,i=this._compare;e;){var n=i(e.key,t);if(n<0)e=e.right;else{if(!(n>0))return e;e=e.left}}return null}contains(t){for(var e=this._root,i=this._compare;e;){var n=i(t,e.key);if(0===n)return!0;e=n<0?e.left:e.right}return!1}remove(t){var e=this.find(t);if(!e)return!1;if(this.splay(e),e.left)if(e.right){var i=this.minNode(e.right);i.parent!==e&&(this.replace(i,i.right),i.right=e.right,i.right.parent=i),this.replace(e,i),i.left=e.left,i.left.parent=i}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}removeNode(t){if(!t)return!1;if(this.splay(t),t.left)if(t.right){var e=this.minNode(t.right);e.parent!==t&&(this.replace(e,e.right),e.right=t.right,e.right.parent=e),this.replace(t,e),e.left=t.left,e.left.parent=e}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}erase(t){var e=this.find(t);if(e){this.splay(e);var i=e.left,n=e.right,r=null;i&&(i.parent=null,r=this.maxNode(i),this.splay(r),this._root=r),n&&(i?r.right=n:this._root=n,n.parent=r),this._size--}}pop(){var t=this._root,e=null;if(t){for(;t.left;)t=t.left;e={key:t.key,data:t.data},this.remove(t.key)}return e}next(t){var e=t;if(e)if(e.right)for(e=e.right;e&&e.left;)e=e.left;else for(e=t.parent;e&&e.right===t;)t=e,e=e.parent;return e}prev(t){var e=t;if(e)if(e.left)for(e=e.left;e&&e.right;)e=e.right;else for(e=t.parent;e&&e.left===t;)t=e,e=e.parent;return e}forEach(t){for(var e=this._root,i=[],n=!1,r=0;!n;)e?(i.push(e),e=e.left):i.length>0?(t(e=i.pop(),r++),e=e.right):n=!0;return this}range(t,e,i,n){const r=[],s=this._compare;let o,a=this._root;for(;0!==r.length||a;)if(a)r.push(a),a=a.left;else{if(a=r.pop(),o=s(a.key,e),o>0)break;if(s(a.key,t)>=0&&i.call(n,a))return this;a=a.right}return this}keys(){for(var t=this._root,e=[],i=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),i.push(t.key),t=t.right):n=!0;return i}values(){for(var t=this._root,e=[],i=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),i.push(t.data),t=t.right):n=!0;return i}at(t){for(var e=this._root,i=[],n=!1,r=0;!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right}else n=!0;return null}load(t=[],e=[],i=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=t.length;return i&&l_(t,e,0,n-1,this._compare),this._root=h_(null,t,e,0,n),this._size=n,this}min(){var t=this.minNode(this._root);return t?t.key:null}max(){var t=this.maxNode(this._root);return t?t.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(t,e,i,n,r){return new c_(i,r).load(t,e,n)}}function h_(t,e,i,n,r){const s=r-n;if(s>0){const o=n+Math.floor(s/2),a={key:e[o],data:i[o],parent:t};return a.left=h_(a,e,i,n,o),a.right=h_(a,e,i,o+1,r),a}return null}function l_(t,e,i,n,r){if(i>=n)return;const s=t[i+n>>1];let o=i-1,a=n+1;for(;;){do{o++}while(r(t[o],s)<0);do{a--}while(r(t[a],s)>0);if(o>=a)break;let i=t[o];t[o]=t[a],t[a]=i,i=e[o],e[o]=e[a],e[a]=i}l_(t,e,i,a,r),l_(t,e,a+1,n,r)}function u_(t,e,i){null===e?(t.inOut=!1,t.otherInOut=!0):(t.isSubject===e.isSubject?(t.inOut=!e.inOut,t.otherInOut=e.otherInOut):(t.inOut=!e.otherInOut,t.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(t.prevInResult=!d_(e,i)||e.isVertical()?e.prevInResult:e));let n=d_(t,i);t.resultTransition=n?function(t,e){let i,n=!t.inOut,r=!t.otherInOut;switch(e){case 0:i=n&&r;break;case 1:i=n||r;break;case 3:i=n^r;break;case 2:i=t.isSubject?n&&!r:r&&!n}return i?1:-1}(t,i):0}function d_(t,e){switch(t.type){case 0:switch(e){case 0:return!t.otherInOut;case 1:return t.otherInOut;case 2:return t.isSubject&&t.otherInOut||!t.isSubject&&!t.otherInOut;case 3:return!0}break;case 2:return 0===e||1===e;case 3:return 2===e;case 1:return!1}return!1}class p_{constructor(t,e,i,n,r){this.left=e,this.point=t,this.otherEvent=i,this.isSubject=n,this.type=r||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(t){const e=this.point,i=this.otherEvent.point;return this.left?(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])>0:(i[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(i[1]-t[1])>0}isAbove(t){return!this.isBelow(t)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const t=new p_(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.contourId=this.contourId,t.resultTransition=this.resultTransition,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t}}function f_(t,e){return t[0]===e[0]&&t[1]===e[1]}const m_=134217729;function g_(t,e,i,n,r){let s,o,a,c,h=e[0],l=n[0],u=0,d=0;l>h==l>-h?(s=h,h=e[++u]):(s=l,l=n[++d]);let p=0;if(u<t&&d<i)for(l>h==l>-h?(o=h+s,a=s-(o-h),h=e[++u]):(o=l+s,a=s-(o-l),l=n[++d]),s=o,0!==a&&(r[p++]=a);u<t&&d<i;)l>h==l>-h?(o=s+h,c=o-s,a=s-(o-c)+(h-c),h=e[++u]):(o=s+l,c=o-s,a=s-(o-c)+(l-c),l=n[++d]),s=o,0!==a&&(r[p++]=a);for(;u<t;)o=s+h,c=o-s,a=s-(o-c)+(h-c),h=e[++u],s=o,0!==a&&(r[p++]=a);for(;d<i;)o=s+l,c=o-s,a=s-(o-c)+(l-c),l=n[++d],s=o,0!==a&&(r[p++]=a);return 0===s&&0!==p||(r[p++]=s),p}function __(t){return new Float64Array(t)}const v_=__(4),y_=__(8),b_=__(12),x_=__(16),w_=__(4);function S_(t,e,i,n,r,s){const o=(e-s)*(i-r),a=(t-r)*(n-s),c=o-a;if(0===o||0===a||o>0!=a>0)return c;const h=Math.abs(o+a);return Math.abs(c)>=33306690738754716e-32*h?c:-function(t,e,i,n,r,s,o){let a,c,h,l,u,d,p,f,m,g,_,v,y,b,x,w,S,M;const T=t-r,C=i-r,E=e-s,I=n-s;b=T*I,d=m_*T,p=d-(d-T),f=T-p,d=m_*I,m=d-(d-I),g=I-m,x=f*g-(b-p*m-f*m-p*g),w=E*C,d=m_*E,p=d-(d-E),f=E-p,d=m_*C,m=d-(d-C),g=C-m,S=f*g-(w-p*m-f*m-p*g),_=x-S,u=x-_,v_[0]=x-(_+u)+(u-S),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,v_[1]=y-(_+u)+(u-w),M=v+_,u=M-v,v_[2]=v-(M-u)+(_-u),v_[3]=M;let A=function(t,e){let i=e[0];for(let n=1;n<t;n++)i+=e[n];return i}(4,v_),P=22204460492503146e-32*o;if(A>=P||-A>=P)return A;if(u=t-T,a=t-(T+u)+(u-r),u=i-C,h=i-(C+u)+(u-r),u=e-E,c=e-(E+u)+(u-s),u=n-I,l=n-(I+u)+(u-s),0===a&&0===c&&0===h&&0===l)return A;if(P=11093356479670487e-47*o+33306690738754706e-32*Math.abs(A),A+=T*l+I*a-(E*h+C*c),A>=P||-A>=P)return A;b=a*I,d=m_*a,p=d-(d-a),f=a-p,d=m_*I,m=d-(d-I),g=I-m,x=f*g-(b-p*m-f*m-p*g),w=c*C,d=m_*c,p=d-(d-c),f=c-p,d=m_*C,m=d-(d-C),g=C-m,S=f*g-(w-p*m-f*m-p*g),_=x-S,u=x-_,w_[0]=x-(_+u)+(u-S),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,w_[1]=y-(_+u)+(u-w),M=v+_,u=M-v,w_[2]=v-(M-u)+(_-u),w_[3]=M;const R=g_(4,v_,4,w_,y_);b=T*l,d=m_*T,p=d-(d-T),f=T-p,d=m_*l,m=d-(d-l),g=l-m,x=f*g-(b-p*m-f*m-p*g),w=E*h,d=m_*E,p=d-(d-E),f=E-p,d=m_*h,m=d-(d-h),g=h-m,S=f*g-(w-p*m-f*m-p*g),_=x-S,u=x-_,w_[0]=x-(_+u)+(u-S),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,w_[1]=y-(_+u)+(u-w),M=v+_,u=M-v,w_[2]=v-(M-u)+(_-u),w_[3]=M;const L=g_(R,y_,4,w_,b_);b=a*l,d=m_*a,p=d-(d-a),f=a-p,d=m_*l,m=d-(d-l),g=l-m,x=f*g-(b-p*m-f*m-p*g),w=c*h,d=m_*c,p=d-(d-c),f=c-p,d=m_*h,m=d-(d-h),g=h-m,S=f*g-(w-p*m-f*m-p*g),_=x-S,u=x-_,w_[0]=x-(_+u)+(u-S),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,w_[1]=y-(_+u)+(u-w),M=v+_,u=M-v,w_[2]=v-(M-u)+(_-u),w_[3]=M;const O=g_(L,b_,4,w_,x_);return x_[O-1]}(t,e,i,n,r,s,h)}function M_(t,e,i){const n=S_(t[0],t[1],e[0],e[1],i[0],i[1]);return n>0?-1:n<0?1:0}function T_(t,e){const i=t.point,n=e.point;return i[0]>n[0]?1:i[0]<n[0]?-1:i[1]!==n[1]?i[1]>n[1]?1:-1:function(t,e,i,n){if(t.left!==e.left)return t.left?1:-1;if(0!==M_(i,t.otherEvent.point,e.otherEvent.point))return t.isBelow(e.otherEvent.point)?-1:1;return!t.isSubject&&e.isSubject?1:-1}(t,e,i)}function C_(t,e,i){const n=new p_(e,!1,t,t.isSubject),r=new p_(e,!0,t.otherEvent,t.isSubject);return f_(t.point,t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",t),n.contourId=r.contourId=t.contourId,T_(r,t.otherEvent)>0&&(t.otherEvent.left=!0,r.left=!1),t.otherEvent.otherEvent=r,t.otherEvent=n,i.push(r),i.push(n),i}function E_(t,e){return t[0]*e[1]-t[1]*e[0]}function I_(t,e){return t[0]*e[0]+t[1]*e[1]}function A_(t,e,i){const n=function(t,e,i,n,r){const s=[e[0]-t[0],e[1]-t[1]],o=[n[0]-i[0],n[1]-i[1]];function a(t,e,i){return[t[0]+e*i[0],t[1]+e*i[1]]}const c=[i[0]-t[0],i[1]-t[1]];let h=E_(s,o),l=h*h;const u=I_(s,s);if(l>0){const e=E_(c,o)/h;if(e<0||e>1)return null;const n=E_(c,s)/h;return n<0||n>1?null:0===e||1===e?r?null:[a(t,e,s)]:0===n||1===n?r?null:[a(i,n,o)]:[a(t,e,s)]}if(h=E_(c,s),l=h*h,l>0)return null;const d=I_(s,c)/u,p=d+I_(s,o)/u,f=Math.min(d,p),m=Math.max(d,p);return f<=1&&m>=0?1===f?r?null:[a(t,f>0?f:0,s)]:0===m?r?null:[a(t,m<1?m:1,s)]:r&&0===f&&1===m?null:[a(t,f>0?f:0,s),a(t,m<1?m:1,s)]:null}(t.point,t.otherEvent.point,e.point,e.otherEvent.point),r=n?n.length:0;if(0===r)return 0;if(1===r&&(f_(t.point,e.point)||f_(t.otherEvent.point,e.otherEvent.point)))return 0;if(2===r&&t.isSubject===e.isSubject)return 0;if(1===r)return f_(t.point,n[0])||f_(t.otherEvent.point,n[0])||C_(t,n[0],i),f_(e.point,n[0])||f_(e.otherEvent.point,n[0])||C_(e,n[0],i),1;const s=[];let o=!1,a=!1;return f_(t.point,e.point)?o=!0:1===T_(t,e)?s.push(e,t):s.push(t,e),f_(t.otherEvent.point,e.otherEvent.point)?a=!0:1===T_(t.otherEvent,e.otherEvent)?s.push(e.otherEvent,t.otherEvent):s.push(t.otherEvent,e.otherEvent),o&&a||o?(e.type=1,t.type=e.inOut===t.inOut?2:3,o&&!a&&C_(s[1].otherEvent,s[0].point,i),2):a?(C_(s[0],s[1].point,i),3):s[0]!==s[3].otherEvent?(C_(s[0],s[1].point,i),C_(s[1],s[2].point,i),3):(C_(s[0],s[1].point,i),C_(s[3].otherEvent,s[2].point,i),3)}function P_(t,e){if(t===e)return 0;if(0!==M_(t.point,t.otherEvent.point,e.point)||0!==M_(t.point,t.otherEvent.point,e.otherEvent.point))return f_(t.point,e.point)?t.isBelow(e.otherEvent.point)?-1:1:t.point[0]===e.point[0]?t.point[1]<e.point[1]?-1:1:1===T_(t,e)?e.isAbove(t.point)?-1:1:t.isBelow(e.point)?-1:1;if(t.isSubject!==e.isSubject)return t.isSubject?-1:1;{let i=t.point,n=e.point;if(i[0]===n[0]&&i[1]===n[1])return i=t.otherEvent.point,n=e.otherEvent.point,i[0]===n[0]&&i[1]===n[1]?0:t.contourId>e.contourId?1:-1}return 1===T_(t,e)?1:-1}class R_{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return null==this.holeOf}}function L_(t,e,i,n){let r,s=t+1,o=e[t].point;const a=e.length;for(s<a&&(r=e[s].point);s<a&&r[0]===o[0]&&r[1]===o[1];){if(!i[s])return s;s++,r=e[s].point}for(s=t-1;i[s]&&s>n;)s--;return s}function O_(t,e,i){const n=new R_;if(null!=t.prevInResult){const r=t.prevInResult,s=r.outputContourId;if(r.resultTransition>0){const t=e[s];if(null!=t.holeOf){const r=t.holeOf;e[r].holeIds.push(i),n.holeOf=r,n.depth=e[s].depth}else e[s].holeIds.push(i),n.holeOf=s,n.depth=e[s].depth+1}else n.holeOf=null,n.depth=e[s].depth}else n.holeOf=null,n.depth=0;return n}function N_(t){let e,i;const n=function(t){let e,i,n,r;const s=[];for(i=0,n=t.length;i<n;i++)e=t[i],(e.left&&e.inResult||!e.left&&e.otherEvent.inResult)&&s.push(e);let o=!1;for(;!o;)for(o=!0,i=0,n=s.length;i<n;i++)i+1<n&&1===T_(s[i],s[i+1])&&(r=s[i],s[i]=s[i+1],s[i+1]=r,o=!1);for(i=0,n=s.length;i<n;i++)e=s[i],e.otherPos=i;for(i=0,n=s.length;i<n;i++)e=s[i],e.left||(r=e.otherPos,e.otherPos=e.otherEvent.otherPos,e.otherEvent.otherPos=r);return s}(t),r={},s=[];for(e=0,i=n.length;e<i;e++){if(r[e])continue;const t=s.length,i=O_(n[e],s,t),o=e=>{r[e]=!0,n[e].outputContourId=t};let a=e,c=e;const h=n[e].point;for(i.points.push(h);o(a),a=n[a].otherPos,o(a),i.points.push(n[a].point),a=L_(a,n,r,c),a!=c;);s.push(i)}return s}var D_=k_,$_=k_;function k_(t,e){if(!(this instanceof k_))return new k_(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||z_,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}function z_(t,e){return t<e?-1:t>e?1:0}k_.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,i=this.compare,n=e[t];t>0;){var r=t-1>>1,s=e[r];if(i(n,s)>=0)break;e[t]=s,t=r}e[t]=n},_down:function(t){for(var e=this.data,i=this.compare,n=this.length>>1,r=e[t];t<n;){var s=1+(t<<1),o=s+1,a=e[s];if(o<this.length&&i(e[o],a)<0&&(s=o,a=e[o]),i(a,r)>=0)break;e[t]=a,t=s}e[t]=r}},D_.default=$_;const F_=Math.max,B_=Math.min;let j_=0;function H_(t,e,i,n,r,s){let o,a,c,h,l,u;for(o=0,a=t.length-1;o<a;o++){if(c=t[o],h=t[o+1],l=new p_(c,!1,void 0,e),u=new p_(h,!1,l,e),l.otherEvent=u,c[0]===h[0]&&c[1]===h[1])continue;l.contourId=u.contourId=i,s||(l.isExteriorRing=!1,u.isExteriorRing=!1),T_(l,u)>0?u.left=!0:l.left=!0;const a=c[0],d=c[1];r[0]=B_(r[0],a),r[1]=B_(r[1],d),r[2]=F_(r[2],a),r[3]=F_(r[3],d),n.push(l),n.push(u)}}const U_=[];function V_(t,e,i){"number"==typeof t[0][0][0]&&(t=[t]),"number"==typeof e[0][0][0]&&(e=[e]);let n=function(t,e,i){let n=null;return t.length*e.length==0&&(0===i?n=U_:2===i?n=t:1!==i&&3!==i||(n=0===t.length?e:t)),n}(t,e,i);if(n)return n===U_?null:n;const r=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],o=function(t,e,i,n,r){const s=new D_(null,T_);let o,a,c,h,l,u;for(c=0,h=t.length;c<h;c++)for(o=t[c],l=0,u=o.length;l<u;l++)a=0===l,a&&j_++,H_(o[l],!0,j_,s,i,a);for(c=0,h=e.length;c<h;c++)for(o=e[c],l=0,u=o.length;l<u;l++)a=0===l,2===r&&(a=!1),a&&j_++,H_(o[l],!1,j_,s,n,a);return s}(t,e,r,s,i);if(n=function(t,e,i,n,r){let s=null;return(i[0]>n[2]||n[0]>i[2]||i[1]>n[3]||n[1]>i[3])&&(0===r?s=U_:2===r?s=t:1!==r&&3!==r||(s=t.concat(e))),s}(t,e,r,s,i),n)return n===U_?null:n;const a=N_(function(t,e,i,n,r,s){const o=new c_(P_),a=[],c=Math.min(n[2],r[2]);let h,l,u;for(;0!==t.length;){let e=t.pop();if(a.push(e),0===s&&e.point[0]>c||2===s&&e.point[0]>n[2])break;if(e.left){l=h=o.insert(e),u=o.minNode(),h=h!==u?o.prev(h):null,l=o.next(l);const i=h?h.key:null;let n;if(u_(e,i,s),l&&2===A_(e,l.key,t)&&(u_(e,i,s),u_(e,l.key,s)),h&&2===A_(h.key,e,t)){let t=h;t=t!==u?o.prev(t):null,n=t?t.key:null,u_(i,n,s),u_(e,i,s)}}else e=e.otherEvent,l=h=o.find(e),h&&l&&(h=h!==u?o.prev(h):null,l=o.next(l),o.remove(e),l&&h&&A_(h.key,l.key,t))}return a}(o,0,0,r,s,i)),c=[];for(let t=0;t<a.length;t++){let e=a[t];if(e.isExterior()){let t=[e.points];for(let i=0;i<e.holeIds.length;i++){let n=e.holeIds[i];t.push(a[n].points)}c.push(t)}}return c}class G_ extends xg{constructor(){super(),this._subsampleThreshold=.005}_getPoleOfInaccessibility2d(t){return e_([t],.03)}_project(t,e){const i=this._createCamera(e.upVector().toArray(),e.unprojectSfM([0,0],0),e.unprojectSfM([0,0],10));return this._deunproject(t,e,i)}_subsample(t,e=this._subsampleThreshold){const i=[],n=t.length;for(let r=0;r<n;r++){const s=t[r],o=t[(r+1)%n];i.push(s);const a=Math.sqrt(Math.pow(o[0]-s[0],2)+Math.pow(o[1]-s[1],2)),c=Math.floor(a/e),h=1/(c+1);for(let t=1;t<=c;t++){const e=t*h,n=[(1-e)*s[0]+e*o[0],(1-e)*s[1]+e*o[1]];i.push(n)}}return i}_triangulate(t,e,i,n){let r=[t.slice(0,-1)];for(let t of null!=i?i:[])r.push(t.slice(0,-1));let s=e.slice(0,-1);for(let t of null!=n?n:[])s=s.concat(t.slice(0,-1));let o=Tg.flatten(r),a=Tg(o.vertices,o.holes,o.dimensions),c=[];for(let t=0;t<a.length;++t){let e=s[a[t]];c.push(e[0]),c.push(e[1]),c.push(e[2])}return c}_triangulateSpherical(t,e,i){const n=[],r=1e-9;for(let s=0;s<3;s++)for(let o=0;o<3;o++){const a=s/3+(0===s?-1e-9:r),c=o/3+(0===o?-1e-9:r),h=(s+1)/3+r,l=(o+1)/3+r,u=[[a,c],[a,l],[h,l],[h,c],[a,c]],d=[(2*s+1)/6,(2*o+1)/6];n.push(...this._triangulateSubarea(t,e,u,d,i))}return n}_unproject(t,e,i=200){return t.map((t=>e.unprojectBasic(t,i)))}_createCamera(t,e,i){const n=new Ns;return n.up.copy((new fn).fromArray(t)),n.position.copy((new fn).fromArray(e)),n.lookAt((new fn).fromArray(i)),n.updateMatrix(),n.updateMatrixWorld(!0),n}_deunproject(t,e,i){return t.map((t=>{const n=e.unprojectBasic(t,1e4),r=new fn(n[0],n[1],n[2]).applyMatrix4(i.matrixWorldInverse);return[r.x/r.z,r.y/r.z]}))}_triangulateSubarea(t,e,i,n,r){const s=V_([t,...e],[i],0);if(!s)return[];const o=[],a=this._subsampleThreshold,c=this._createCamera(r.upVector().toArray(),r.unprojectSfM([0,0],0),r.unprojectBasic(n,10));for(const t of s){const e=this._subsample(t[0],a),i=this._deunproject(e,r,c),n=this._unproject(e,r),s=[],h=[];for(let e=1;e<t.length;e++){let i=this._subsample(t[e],a);const n=this._deunproject(i,r,c),o=this._unproject(i,r);s.push(n),h.push(o)}o.push(...this._triangulate(i,n,s,h))}return o}}class q_ extends G_{constructor(t){if(super(),4!==t.length)throw new wg("Rectangle needs to have four values.");if(t[1]>t[3])throw new wg("Basic Y coordinates values can not be inverted.");for(let e of t)if(e<0||e>1)throw new wg("Basic coordinates must be on the interval [0, 1].");this._anchorIndex=void 0,this._rect=t.slice(0,4),this._inverted=this._rect[0]>this._rect[2]}get anchorIndex(){return this._anchorIndex}get inverted(){return this._inverted}get rect(){return this._rect}initializeAnchorIndexing(t){if(void 0!==this._anchorIndex)throw new wg("Anchor indexing is already initialized.");if(t<0||t>3)throw new wg(`Invalid anchor index: ${t}.`);this._anchorIndex=void 0===t?0:t}terminateAnchorIndexing(){this._anchorIndex=void 0}setOppositeVertex2d(t,e){if(void 0===this._anchorIndex)throw new wg("Anchor indexing needs to be initialized.");const i=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))],n=this._rect.slice(),r=0===this._anchorIndex?[n[0],n[3]]:1===this._anchorIndex?[n[0],n[1]]:2===this._anchorIndex?[n[2],n[1]]:[n[2],n[3]];if(dd(e.cameraType)){const t=this._anchorIndex<2?i[0]-n[2]:i[0]-n[0];!this._inverted&&this._anchorIndex<2&&i[0]<.25&&n[2]>.75&&t<-.5||!this._inverted&&this._anchorIndex>=2&&i[0]<.25&&n[2]>.75&&t<-.5?(this._inverted=!0,this._anchorIndex=r[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<.25&&n[0]>.75&&t<-.5?(this._inverted=!1,this._anchorIndex=r[0]>i[0]?r[1]>i[1]?3:2:r[1]>i[1]?0:1):!this._inverted&&this._anchorIndex>=2&&i[0]>.75&&n[0]<.25&&t>.5||!this._inverted&&this._anchorIndex<2&&i[0]>.75&&n[0]<.25&&t>.5?(this._inverted=!0,this._anchorIndex=r[1]>i[1]?3:2):this._inverted&&this._anchorIndex<2&&i[0]>.75&&n[2]<.25&&t>.5?(this._inverted=!1,this._anchorIndex=r[0]>i[0]?r[1]>i[1]?3:2:r[1]>i[1]?0:1):this._inverted&&this._anchorIndex<2&&i[0]>n[0]?(this._inverted=!1,this._anchorIndex=r[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<n[2]?(this._inverted=!1,this._anchorIndex=r[1]>i[1]?3:2):this._inverted?this._anchorIndex<2?this._anchorIndex=r[1]>i[1]?0:1:this._anchorIndex=r[1]>i[1]?3:2:this._anchorIndex=r[0]<=i[0]&&r[1]>i[1]?0:r[0]<=i[0]&&r[1]<=i[1]?1:r[0]>i[0]&&r[1]<=i[1]?2:3;const e=[];0===this._anchorIndex?(e[0]=r[0],e[1]=i[1],e[2]=i[0],e[3]=r[1]):1===this._anchorIndex?(e[0]=r[0],e[1]=r[1],e[2]=i[0],e[3]=i[1]):2===this._anchorIndex?(e[0]=i[0],e[1]=r[1],e[2]=r[0],e[3]=i[1]):(e[0]=i[0],e[1]=i[1],e[2]=r[0],e[3]=r[1]),(!this._inverted&&e[0]>e[2]||this._inverted&&e[0]<e[2])&&(e[0]=n[0],e[2]=n[2]),e[1]>e[3]&&(e[1]=n[1],e[3]=n[3]),this._rect[0]=e[0],this._rect[1]=e[1],this._rect[2]=e[2],this._rect[3]=e[3]}else{this._anchorIndex=r[0]<=i[0]&&r[1]>i[1]?0:r[0]<=i[0]&&r[1]<=i[1]?1:r[0]>i[0]&&r[1]<=i[1]?2:3;const t=[];0===this._anchorIndex?(t[0]=r[0],t[1]=i[1],t[2]=i[0],t[3]=r[1]):1===this._anchorIndex?(t[0]=r[0],t[1]=r[1],t[2]=i[0],t[3]=i[1]):2===this._anchorIndex?(t[0]=i[0],t[1]=r[1],t[2]=r[0],t[3]=i[1]):(t[0]=i[0],t[1]=i[1],t[2]=r[0],t[3]=r[1]),t[0]>t[2]&&(t[0]=n[0],t[2]=n[2]),t[1]>t[3]&&(t[1]=n[1],t[3]=n[3]),this._rect[0]=t[0],this._rect[1]=t[1],this._rect[2]=t[2],this._rect[3]=t[3]}this._notifyChanged$.next(this)}setVertex2d(t,e,i){let n=this._rect.slice(),r=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))],s=[];if(0===t?(s[0]=r[0],s[1]=n[1],s[2]=n[2],s[3]=r[1]):1===t?(s[0]=r[0],s[1]=r[1],s[2]=n[2],s[3]=n[3]):2===t?(s[0]=n[0],s[1]=r[1],s[2]=r[0],s[3]=n[3]):3===t&&(s[0]=n[0],s[1]=n[1],s[2]=r[0],s[3]=r[1]),dd(i.cameraType)){let e=t<2&&r[0]>.75&&n[0]<.25||t>=2&&this._inverted&&r[0]>.75&&n[2]<.25,i=t<2&&this._inverted&&r[0]<.25&&n[0]>.75||t>=2&&r[0]<.25&&n[2]>.75;e||i?this._inverted=!this._inverted:(s[0]-n[0]<-.25&&(s[0]=n[0]),s[2]-n[2]>.25&&(s[2]=n[2])),(!this._inverted&&s[0]>s[2]||this._inverted&&s[0]<s[2])&&(s[0]=n[0],s[2]=n[2])}else s[0]>s[2]&&(s[0]=n[0],s[2]=n[2]);s[1]>s[3]&&(s[1]=n[1],s[3]=n[3]),this._rect[0]=s[0],this._rect[1]=s[1],this._rect[2]=s[2],this._rect[3]=s[3],this._notifyChanged$.next(this)}setCentroid2d(t,e){let i=this._rect.slice(),n=i[0],r=this._inverted?i[2]+1:i[2],s=i[1],o=i[3],a=n+(r-n)/2,c=s+(o-s)/2,h=0;if(dd(e.cameraType))h=this._inverted?t[0]+1-a:t[0]-a;else{let e=-n,i=1-r;h=Math.max(e,Math.min(i,t[0]-a))}let l=-s,u=1-o,d=Math.max(l,Math.min(u,t[1]-c));this._rect[0]=i[0]+h,this._rect[1]=i[1]+d,this._rect[2]=i[2]+h,this._rect[3]=i[3]+d,this._rect[0]<0?(this._rect[0]+=1,this._inverted=!this._inverted):this._rect[0]>1&&(this._rect[0]-=1,this._inverted=!this._inverted),this._rect[2]<0?(this._rect[2]+=1,this._inverted=!this._inverted):this._rect[2]>1&&(this._rect[2]-=1,this._inverted=!this._inverted),this._notifyChanged$.next(this)}getPoints3d(t){return this._getPoints2d().map((e=>t.unprojectBasic(e,200)))}getVertex2d(t){return this._rectToVertices2d(this._rect)[t]}getNonAdjustedVertex2d(t){return this._rectToNonAdjustedVertices2d(this._rect)[t]}getVertex3d(t,e){return e.unprojectBasic(this._rectToVertices2d(this._rect)[t],200)}getVertices2d(){return this._rectToVertices2d(this._rect)}getVertices3d(t){return this._rectToVertices2d(this._rect).map((e=>t.unprojectBasic(e,200)))}getCentroid2d(){const t=this._rect;return[(t[0]+(this._inverted?t[2]+1:t[2]))/2,(t[1]+t[3])/2]}getCentroid3d(t){const e=this.getCentroid2d();return t.unprojectBasic(e,200)}getPoleOfInaccessibility2d(){return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect))}getPoleOfInaccessibility3d(t){let e=this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));return t.unprojectBasic(e,200)}getTriangles3d(t){return dd(t.cameraType)?[]:this._triangulate(this._project(this._getPoints2d(),t),this.getPoints3d(t))}validate(t){let e=this._rect;return!(!this._inverted&&t[0]<e[0]||t[0]-e[2]>.25||t[1]<e[1])}_getPoints2d(){let t=this._rectToVertices2d(this._rect),e=t.length-1,i=[];for(let n=0;n<e;++n){let e=t[n][0],r=t[n][1],s=(t[n+1][0]-e)/9,o=(t[n+1][1]-r)/9;for(let t=0;t<10;++t){let n=[e+t*s,r+t*o];i.push(n)}}return i}_rectToVertices2d(t){return[[t[0],t[3]],[t[0],t[1]],[this._inverted?t[2]+1:t[2],t[1]],[this._inverted?t[2]+1:t[2],t[3]],[t[0],t[3]]]}_rectToNonAdjustedVertices2d(t){return[[t[0],t[3]],[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]]]}}class W_ extends Mg{constructor(t,e,i,n){super(t,i,n),this._options={color:null==e.color?16777215:e.color,indicateCompleter:null==e.indicateCompleter||e.indicateCompleter},this._rectGeometry=new q_(this._geometry.getRect2d(i)),this._createGlObjects()}create(){this._geometry.points.length<3||(this._geometry.removePoint2d(this._geometry.points.length-1),this._created$.next(this))}dispose(){super.dispose(),this._disposeObjects()}getDOMObjects(t,e){const i={offsetHeight:e.height,offsetWidth:e.width},n=[],r=this._geometry.getPoints2d(),s=r.length;for(let e=0;e<s-1;e++){const o=e,[a,c]=r[e],h=this._viewportCoords.basicToCanvasSafe(a,c,i,this._transform,t);if(!h)continue;const l=t=>{t.stopPropagation(),this._aborted$.next(this)},u=t=>{t.stopPropagation(),this._geometry.removePoint2d(o)},d=this._canvasToTransform(h),p={onclick:0===e&&s<3?l:u,style:{transform:d}};n.push(jf.h("div.mapillary-tag-interactor",p,[]));const f={style:{background:this._colorToBackground(this._options.color),transform:d}};n.push(jf.h("div.mapillary-tag-vertex",f,[]))}if(s>2&&!0===this._options.indicateCompleter){const[e,r]=this._geometry.getCentroid2d(this._transform),s=this._viewportCoords.basicToCanvasSafe(e,r,i,this._transform,t);if(s){const t=t=>{t.stopPropagation(),this._geometry.removePoint2d(this._geometry.points.length-1),this._created$.next(this)},e=this._canvasToTransform(s),i={onclick:t,style:{transform:e}};n.push(jf.h("div.mapillary-tag-completer.mapillary-tag-larger",i,[]));const r={style:{background:this._colorToBackground(this._options.color),transform:e}};n.push(jf.h("div.mapillary-tag-vertex.mapillary-tag-larger",r,[]));const o={style:{transform:e}};n.push(jf.h("div.mapillary-tag-dot",o,[]))}}return n}_onGeometryChanged(){this._disposeObjects(),this._rectGeometry=new q_(this._geometry.getRect2d(this._transform)),this._createGlObjects()}_createGlObjects(){this._glObjects=[];const t=this._rectGeometry.getPoints3d(this._transform);this._outline=this._createOutine(t,this._options.color),this._glObjects.push(this._outline)}_disposeObjects(){this._disposeLine(this._outline),this._outline=null,this._glObjects=null}}class X_ extends G_{constructor(t,e){super();let i=t.length;if(i<3)throw new wg("A polygon must have three or more positions.");if(t[0][0]!==t[i-1][0]||t[0][1]!==t[i-1][1])throw new wg("First and last positions must be equivalent.");this._polygon=[];for(let e of t){if(e[0]<0||e[0]>1||e[1]<0||e[1]>1)throw new wg("Basic coordinates of polygon must be on the interval [0, 1].");this._polygon.push(e.slice())}if(this._holes=[],null!=e)for(let t=0;t<e.length;t++){let i=e[t],n=i.length;if(n<3)throw new wg("A polygon hole must have three or more positions.");if(i[0][0]!==i[n-1][0]||i[0][1]!==i[n-1][1])throw new wg("First and last positions of hole must be equivalent.");this._holes.push([]);for(let e of i){if(e[0]<0||e[0]>1||e[1]<0||e[1]>1)throw new wg("Basic coordinates of hole must be on the interval [0, 1].");this._holes[t].push(e.slice())}}}get polygon(){return this._polygon}get holes(){return this._holes}addVertex2d(t){let e=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];this._polygon.splice(this._polygon.length-1,0,e),this._notifyChanged$.next(this)}getVertex2d(t){return this._polygon[t].slice()}removeVertex2d(t){if(t<0||t>=this._polygon.length||this._polygon.length<4)throw new wg("Index for removed vertex must be valid.");if(t>0&&t<this._polygon.length-1)this._polygon.splice(t,1);else{this._polygon.splice(0,1),this._polygon.pop();let t=this._polygon[0].slice();this._polygon.push(t)}this._notifyChanged$.next(this)}setVertex2d(t,e,i){let n=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];0===t||t===this._polygon.length-1?(this._polygon[0]=n.slice(),this._polygon[this._polygon.length-1]=n.slice()):this._polygon[t]=n.slice(),this._notifyChanged$.next(this)}setCentroid2d(t,e){let i=this._polygon.map((t=>t[0])),n=this._polygon.map((t=>t[1])),r=Math.min.apply(Math,i),s=Math.max.apply(Math,i),o=Math.min.apply(Math,n),a=Math.max.apply(Math,n),c=this.getCentroid2d(),h=-r,l=1-s,u=-o,d=1-a,p=Math.max(h,Math.min(l,t[0]-c[0])),f=Math.max(u,Math.min(d,t[1]-c[1]));for(let t of this._polygon)t[0]+=p,t[1]+=f;this._notifyChanged$.next(this)}getPoints3d(t){return this._getPoints3d(this._subsample(this._polygon),t)}getVertex3d(t,e){return e.unprojectBasic(this._polygon[t],200)}getVertices2d(){return this._polygon.slice()}getVertices3d(t){return this._getPoints3d(this._polygon,t)}getHolePoints3d(t){return this._holes.map((e=>this._getPoints3d(this._subsample(e),t)))}getHoleVertices3d(t){return this._holes.map((e=>this._getPoints3d(e,t)))}getCentroid2d(){let t=this._polygon,e=0,i=0,n=0;for(let r=0;r<t.length-1;r++){let s=t[r][0],o=t[r][1],a=t[r+1][0],c=t[r+1][1],h=s*c-a*o;e+=h,i+=(s+a)*h,n+=(o+c)*h}return e/=2,i/=6*e,n/=6*e,[i,n]}getCentroid3d(t){let e=this.getCentroid2d();return t.unprojectBasic(e,200)}get3dDomainTriangles3d(t){return this._triangulate(this._project(this._polygon,t),this.getVertices3d(t),this._holes.map((e=>this._project(e,t))),this.getHoleVertices3d(t))}getTriangles3d(t){if(dd(t.cameraType))return this._triangulateSpherical(this._polygon.slice(),this.holes.slice(),t);const e=this._project(this._subsample(this._polygon),t),i=this.getPoints3d(t),n=this._holes.map((e=>this._project(this._subsample(e),t))),r=this.getHolePoints3d(t);return this._triangulate(e,i,n,r)}getPoleOfInaccessibility2d(){return this._getPoleOfInaccessibility2d(this._polygon.slice())}getPoleOfInaccessibility3d(t){let e=this._getPoleOfInaccessibility2d(this._polygon.slice());return t.unprojectBasic(e,200)}_getPoints3d(t,e){return t.map((t=>e.unprojectBasic(t,200)))}}class Y_ extends Mg{constructor(t,e,i,n){super(t,i,n),this._options={color:null==e.color?16777215:e.color},this._createGlObjects()}create(){if(this._geometry instanceof q_)this._created$.next(this);else if(this._geometry instanceof X_){const t=this._geometry;t.removeVertex2d(t.polygon.length-2),this._created$.next(this)}}dispose(){super.dispose(),this._disposeLine(this._outline),this._disposeObjects()}getDOMObjects(t,e){const i=[],n={offsetHeight:e.height,offsetWidth:e.width},r=t=>{t.stopPropagation(),this._aborted$.next(this)};if(this._geometry instanceof q_){const e=this._geometry.anchorIndex,s=void 0===e?1:e,[o,a]=this._geometry.getVertex2d(s),c=this._viewportCoords.basicToCanvasSafe(o,a,n,this._transform,t);if(null!=c){const t=this._colorToBackground(this._options.color),e=this._canvasToTransform(c),n={style:{background:t,transform:e}},s={onclick:r,style:{transform:e}};i.push(jf.h("div.mapillary-tag-interactor",s,[])),i.push(jf.h("div.mapillary-tag-vertex",n,[]))}}else if(this._geometry instanceof X_){const e=this._geometry,[s,o]=e.getVertex2d(0),a=this._viewportCoords.basicToCanvasSafe(s,o,n,this._transform,t);if(null!=a){const t={onclick:e.polygon.length>4?t=>{t.stopPropagation(),e.removeVertex2d(e.polygon.length-2),this._created$.next(this)}:r,style:{transform:this._canvasToTransform(a)}},n=e.polygon.length>4?"mapillary-tag-completer":"mapillary-tag-interactor";i.push(jf.h("div."+n,t,[]))}if(e.polygon.length>3){const[r,s]=e.getVertex2d(e.polygon.length-3),o=this._viewportCoords.basicToCanvasSafe(r,s,n,this._transform,t);if(null!=o){const t={onclick:t=>{t.stopPropagation(),e.removeVertex2d(e.polygon.length-3)},style:{transform:this._canvasToTransform(o)}};i.push(jf.h("div.mapillary-tag-interactor",t,[]))}}const c=e.polygon.slice();c.splice(-2,2);for(const e of c){const r=this._viewportCoords.basicToCanvasSafe(e[0],e[1],n,this._transform,t);if(null!=r){const t={style:{background:this._colorToBackground(this._options.color),transform:this._canvasToTransform(r)}};i.push(jf.h("div.mapillary-tag-vertex",t,[]))}}}return i}addPoint(t){if(this._geometry instanceof q_){if(!this._geometry.validate(t))return;this._created$.next(this)}else if(this._geometry instanceof X_){this._geometry.addVertex2d(t)}}_onGeometryChanged(){this._disposeLine(this._outline),this._disposeObjects(),this._createGlObjects()}_disposeObjects(){this._outline=null,this._glObjects=[]}_createGlObjects(){const t=this._geometry instanceof q_?this._geometry.getPoints3d(this._transform):this._geometry.getVertices3d(this._transform);this._outline=this._createOutine(t,this._options.color),this._glObjects=[this._outline]}}class Z_{constructor(t,e){this._component=t,this._navigator=e,this._tagOperation$=new T,this._createPoints$=new T,this._createPolygon$=new T,this._createRect$=new T,this._delete$=new T,this._tag$=this._tagOperation$.pipe(Le(((t,e)=>e(t)),null),Ze()),this._replayedTag$=this._tag$.pipe(Ue(1),E()),this._replayedTag$.subscribe(),this._createPoints$.pipe(bi(this._component.configuration$,this._navigator.stateService.currentTransform$),rt((([t,e,i])=>()=>{const n=new Sg([[t[0],t[1]],[t[0],t[1]]]);return new W_(n,{color:e.createColor,indicateCompleter:e.indicatePointsCompleter},i)}))).subscribe(this._tagOperation$),this._createRect$.pipe(bi(this._component.configuration$,this._navigator.stateService.currentTransform$),rt((([t,e,i])=>()=>{const n=new q_([t[0],t[1],t[0],t[1]]);return new Y_(n,{color:e.createColor},i)}))).subscribe(this._tagOperation$),this._createPolygon$.pipe(bi(this._component.configuration$,this._navigator.stateService.currentTransform$),rt((([t,e,i])=>()=>{const n=new X_([[t[0],t[1]],[t[0],t[1]],[t[0],t[1]]]);return new Y_(n,{color:e.createColor},i)}))).subscribe(this._tagOperation$),this._delete$.pipe(rt((()=>()=>null))).subscribe(this._tagOperation$)}get createRect$(){return this._createRect$}get createPolygon$(){return this._createPolygon$}get createPoints$(){return this._createPoints$}get delete$(){return this._delete$}get tag$(){return this._tag$}get replayedTag$(){return this._replayedTag$}}class J_{render(t,e,i,n,r){let s=[];for(const e of t)s=s.concat(e.getDOMObjects(i,n,r));return null!=e&&(s=s.concat(e.getDOMObjects(n,r))),jf.h("div.mapillary-tag-container",{},s)}clear(){return jf.h("div",{},[])}}class K_{constructor(t,e){this._createTag=null,this._needsRender=!1,this._raycaster=e||new Bu,this._scene=t||new Qa,this._objectTags={},this._retrievableObjects=[],this._tags={}}get needsRender(){return this._needsRender}add(t){for(let e of t)e.tag.id in this._tags&&this._remove(e.tag.id),this._add(e);this._needsRender=!0}addCreateTag(t){for(const e of t.glObjects)this._scene.add(e);this._createTag={tag:t,objects:t.glObjects},this._needsRender=!0}clear(){for(const t of Object.keys(this._tags))this._remove(t);this._needsRender=!1}get(t){return this.has(t)?this._tags[t].tag:void 0}has(t){return t in this._tags}hasCreateTag(){return null!=this._createTag}intersectObjects([t,e],i){this._raycaster.setFromCamera(new rn(t,e),i);const n=this._raycaster.intersectObjects(this._retrievableObjects),r=[];for(const t of n)t.object.uuid in this._objectTags&&r.push(this._objectTags[t.object.uuid]);return r}remove(t){for(const e of t)this._remove(e);this._needsRender=!0}removeAll(){for(const t of Object.keys(this._tags))this._remove(t);this._needsRender=!0}removeCreateTag(){if(null!=this._createTag){for(const t of this._createTag.objects)this._scene.remove(t);this._createTag.tag.dispose(),this._createTag=null,this._needsRender=!0}}render(t,e){e.render(this._scene,t),this._needsRender=!1}update(){this._needsRender=!0}updateCreateTagObjects(t){if(this._createTag.tag!==t)throw new Error("Create tags do not have the same reference.");for(let t of this._createTag.objects)this._scene.remove(t);for(const e of t.glObjects)this._scene.add(e);this._createTag.objects=t.glObjects,this._needsRender=!0}updateObjects(t){const e=t.tag.id;if(this._tags[e].tag!==t)throw new Error("Tags do not have the same reference.");const i=this._tags[e];this._removeObjects(i),delete this._tags[e],this._add(t),this._needsRender=!0}_add(t){const e=t.tag.id,i={tag:t,objects:[],retrievableObjects:[]};this._tags[e]=i;for(const e of t.getGLObjects())i.objects.push(e),this._scene.add(e);for(const e of t.getRetrievableObjects())i.retrievableObjects.push(e),this._retrievableObjects.push(e),this._objectTags[e.uuid]=t.tag.id}_remove(t){const e=this._tags[t];this._removeObjects(e),e.tag.dispose(),delete this._tags[t]}_removeObjects(t){for(const e of t.objects)this._scene.remove(e);for(const e of t.retrievableObjects){const t=this._retrievableObjects.indexOf(e);-1!==t&&this._retrievableObjects.splice(t,1)}}}var Q_,tv,ev,iv;t.TagMode=void 0,(Q_=t.TagMode||(t.TagMode={}))[Q_.Default=0]="Default",Q_[Q_.CreatePoint=1]="CreatePoint",Q_[Q_.CreatePoints=2]="CreatePoints",Q_[Q_.CreatePolygon=3]="CreatePolygon",Q_[Q_.CreateRect=4]="CreateRect",Q_[Q_.CreateRectDrag=5]="CreateRectDrag",function(t){t[t.None=0]="None",t[t.Centroid=1]="Centroid",t[t.Vertex=2]="Vertex"}(tv||(tv={}));class nv{constructor(t,e,i){this._tag=t,this._transform=e,this._viewportCoords=i||new Wf,this._glObjectsChanged$=new T,this._interact$=new T}get glObjectsChanged$(){return this._glObjectsChanged$}get interact$(){return this._interact$}get tag(){return this._tag}}class rv extends nv{constructor(t,e){super(t,e),this._geometryChangedSubscription=this._tag.geometry.changed$.subscribe((()=>{this._onGeometryChanged()})),this._changedSubscription=this._tag.changed$.subscribe((()=>{this._onTagChanged()&&this._glObjectsChanged$.next(this)}))}dispose(){this._changedSubscription.unsubscribe(),this._geometryChangedSubscription.unsubscribe()}_colorToCss(t){return"#"+("000000"+t.toString(16)).substr(-6)}_createFill(){let t=this._getTriangles(),e=new Float32Array(t),i=new hs;i.setAttribute("position",new Hr(e,3)),i.computeBoundingSphere();let n=new Fr({side:2,transparent:!0});return this._updateFillMaterial(n),new Es(i,n)}_createLine(t){let e=this._getLinePositions(t),i=new hs;i.setAttribute("position",new Hr(e,3)),i.computeBoundingSphere();let n=new kc;this._updateLineBasicMaterial(n);const r=new Uc(i,n);return r.renderOrder=1,r}_createOutline(){return this._createLine(this._getPoints3d())}_disposeFill(){null!=this._fill&&(this._fill.geometry.dispose(),this._fill.material.dispose(),this._fill=null)}_disposeOutline(){null!=this._outline&&(this._outline.geometry.dispose(),this._outline.material.dispose(),this._outline=null)}_getLinePositions(t){let e=t.length,i=new Float32Array(3*e);for(let n=0;n<e;++n){let e=3*n,r=t[n];i[e+0]=r[0],i[e+1]=r[1],i[e+2]=r[2]}return i}_interact(t,e,i){return n=>{let r=n.offsetX-n.target.offsetWidth/2,s=n.offsetY-n.target.offsetHeight/2;this._interact$.next({cursor:e,offsetX:r,offsetY:s,operation:t,tag:this._tag,vertexIndex:i})}}_updateFillGeometry(){let t=this._getTriangles(),e=new Float32Array(t),i=this._fill.geometry,n=i.getAttribute("position");n.array.length===e.length?(n.set(e),n.needsUpdate=!0):(i.deleteAttribute("position"),i.setAttribute("position",new Hr(e,3))),i.computeBoundingSphere()}_updateLine(t,e){let i=this._getLinePositions(e),n=t.geometry,r=n.getAttribute("position");r.set(i),r.needsUpdate=!0,n.computeBoundingSphere()}_updateOulineGeometry(){this._updateLine(this._outline,this._getPoints3d())}}class sv extends rv{constructor(t,e){super(t,e),this._rectGeometry=new q_(this._tag.geometry.getRect2d(e)),this._fill=dd(e.cameraType)?null:this._createFill(),this._outline=this._tag.lineWidth>=1?this._createOutline():null}dispose(){super.dispose(),this._disposeFill(),this._disposeOutline()}getDOMObjects(t,e,i){const n=[],r={offsetHeight:i.height,offsetWidth:i.width};if(!this._tag.editable)return n;const s=this._colorToCss(this._tag.lineColor),o=this._tag.geometry.getPoints2d();for(let t=0;t<o.length;t++){const[i,a]=o[t],c=this._viewportCoords.basicToCanvasSafe(i,a,r,this._transform,e);if(null==c)continue;const h="crosshair",l=this._interact(tv.Vertex,h,t),u=`translate(-50%, -50%) translate(${Math.round(c[0])}px,${Math.round(c[1])}px)`,d={onpointerdown:l,style:{background:s,transform:u,cursor:h}};if(n.push(jf.h("div.mapillary-tag-resizer",d,[])),!this._tag.indicateVertices)continue;const p={style:{background:s,transform:u}};n.push(jf.h("div.mapillary-tag-vertex",p,[]))}return n}getGLObjects(){const t=[];return null!=this._fill&&t.push(this._fill),null!=this._outline&&t.push(this._outline),t}getRetrievableObjects(){return null!=this._fill?[this._fill]:[]}_onGeometryChanged(){this._rectGeometry=new q_(this._tag.geometry.getRect2d(this._transform)),null!=this._fill&&this._updateFillGeometry(),null!=this._outline&&this._updateOulineGeometry()}_onTagChanged(){let t=!1;return null!=this._fill&&this._updateFillMaterial(this._fill.material),null==this._outline?this._tag.lineWidth>=1&&(this._outline=this._createOutline(),t=!0):this._updateOutlineMaterial(),t}_getPoints3d(){return this._rectGeometry.getPoints3d(this._transform)}_getTriangles(){return this._rectGeometry.getTriangles3d(this._transform)}_updateFillMaterial(t){t.color=new Dr(this._tag.fillColor),t.opacity=this._tag.fillOpacity,t.needsUpdate=!0}_updateLineBasicMaterial(t){t.color=new Dr(this._tag.lineColor),t.linewidth=Math.max(this._tag.lineWidth,1),t.visible=this._tag.lineWidth>=1&&this._tag.lineOpacity>0,t.opacity=this._tag.lineOpacity,t.transparent=this._tag.lineOpacity<1,t.needsUpdate=!0}_updateOutlineMaterial(){let t=this._outline.material;this._updateLineBasicMaterial(t)}}class ov extends Hf{constructor(t,e){super(),this._id=t,this._geometry=e,this._notifyChanged$=new T,this._notifyChanged$.subscribe((t=>{const e={target:this,type:"tag"};this.fire("tag",e)})),this._geometry.changed$.subscribe((t=>{const e="geometry",i={target:this,type:e};this.fire(e,i)}))}get id(){return this._id}get geometry(){return this._geometry}get changed$(){return this._notifyChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(rt((()=>this)),Ze())}fire(t,e){super.fire(t,e)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}}class av extends ov{constructor(t,e,i){super(t,e),i=i||{},this._editable=null!=i.editable&&i.editable,this._fillColor=null==i.fillColor?16777215:i.fillColor,this._fillOpacity=null==i.fillOpacity?0:i.fillOpacity,this._indicateVertices=null==i.indicateVertices||i.indicateVertices,this._lineColor=null==i.lineColor?16777215:i.lineColor,this._lineOpacity=null==i.lineOpacity?1:i.lineOpacity,this._lineWidth=null==i.lineWidth?1:i.lineWidth}get editable(){return this._editable}set editable(t){this._editable=t,this._notifyChanged$.next(this)}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor=t,this._notifyChanged$.next(this)}get fillOpacity(){return this._fillOpacity}set fillOpacity(t){this._fillOpacity=t,this._notifyChanged$.next(this)}get geometry(){return this._geometry}get indicateVertices(){return this._indicateVertices}set indicateVertices(t){this._indicateVertices=t,this._notifyChanged$.next(this)}get lineColor(){return this._lineColor}set lineColor(t){this._lineColor=t,this._notifyChanged$.next(this)}get lineOpacity(){return this._lineOpacity}set lineOpacity(t){this._lineOpacity=t,this._notifyChanged$.next(this)}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this._notifyChanged$.next(this)}setOptions(t){this._editable=null==t.editable?this._editable:t.editable,this._indicateVertices=null==t.indicateVertices?this._indicateVertices:t.indicateVertices,this._lineColor=null==t.lineColor?this._lineColor:t.lineColor,this._lineWidth=null==t.lineWidth?this._lineWidth:t.lineWidth,this._fillColor=null==t.fillColor?this._fillColor:t.fillColor,this._fillOpacity=null==t.fillOpacity?this._fillOpacity:t.fillOpacity,this._notifyChanged$.next(this)}}t.TagDomain=void 0,(ev=t.TagDomain||(t.TagDomain={}))[ev.TwoDimensional=0]="TwoDimensional",ev[ev.ThreeDimensional=1]="ThreeDimensional";class cv extends rv{constructor(e,i){super(e,i),this._fill=dd(i.cameraType)?e.domain===t.TagDomain.TwoDimensional&&e.geometry instanceof X_?this._createFill():null:this._createFill(),this._holes=this._tag.lineWidth>=1?this._createHoles():[],this._outline=this._tag.lineWidth>=1?this._createOutline():null}dispose(){super.dispose(),this._disposeFill(),this._disposeHoles(),this._disposeOutline()}getDOMObjects(t,e,i){const n=[],r=this._tag.geometry instanceof q_,s=!dd(this._transform.cameraType),o={offsetHeight:i.height,offsetWidth:i.width};if(null!=this._tag.icon&&(r||s)){const[i,r]=this._tag.geometry instanceof q_?this._tag.geometry.getVertex2d(this._tag.iconIndex):this._tag.geometry.getPoleOfInaccessibility2d(),s=this._viewportCoords.basicToCanvasSafe(i,r,o,this._transform,e);if(null!=s){const e=()=>{this._interact$.next({offsetX:0,offsetY:0,operation:tv.None,tag:this._tag})};if(t.loaded){const i=t.getDOMSprite(this._tag.icon,this._tag.iconFloat),r={onclick:t=>{t.stopPropagation(),this._tag.click$.next(this._tag)},onpointerdown:e,style:{transform:`translate(${Math.round(s[0])}px,${Math.round(s[1])}px)`}};n.push(jf.h("div.mapillary-tag-symbol",r,[i]))}}}else if(null!=this._tag.text&&(r||s)){const[t,i]=this._tag.geometry instanceof q_?this._tag.geometry.getVertex2d(3):this._tag.geometry.getPoleOfInaccessibility2d(),r=this._viewportCoords.basicToCanvasSafe(t,i,o,this._transform,e);if(null!=r){const t=Math.round(r[0]),e=Math.round(r[1]),i=this._tag.geometry instanceof q_?`translate(${t}px,${e}px)`:`translate(-50%, -50%) translate(${t}px,${e}px)`,s={onpointerdown:()=>{this._interact$.next({offsetX:0,offsetY:0,operation:tv.None,tag:this._tag})},style:{color:this._colorToCss(this._tag.textColor),transform:i},textContent:this._tag.text};n.push(jf.h("span.mapillary-tag-symbol",s,[]))}}if(!this._tag.editable)return n;const a=this._colorToCss(this._tag.lineColor);if(this._tag.geometry instanceof q_){const[t,i]=this._tag.geometry.getCentroid2d(),r=this._viewportCoords.basicToCanvasSafe(t,i,o,this._transform,e);if(null!=r){const t={onpointerdown:this._interact(tv.Centroid,"move"),style:{background:a,transform:`translate(-50%, -50%) translate(${Math.round(r[0])}px,${Math.round(r[1])}px)`}};n.push(jf.h("div.mapillary-tag-mover",t,[]))}}const c=this._tag.geometry.getVertices2d();for(let t=0;t<c.length-1;t++){if(r&&(null!=this._tag.icon&&t===this._tag.iconIndex||null==this._tag.icon&&null!=this._tag.text&&3===t))continue;const[i,s]=c[t],h=this._viewportCoords.basicToCanvasSafe(i,s,o,this._transform,e);if(null==h)continue;const l=r?t%2==0?"nesw-resize":"nwse-resize":"crosshair",u=this._interact(tv.Vertex,l,t),d=`translate(-50%, -50%) translate(${Math.round(h[0])}px,${Math.round(h[1])}px)`,p={onpointerdown:u,style:{background:a,transform:d,cursor:l}};if(n.push(jf.h("div.mapillary-tag-resizer",p,[])),!this._tag.indicateVertices)continue;const f={style:{background:a,transform:d}};n.push(jf.h("div.mapillary-tag-vertex",f,[]))}return n}getGLObjects(){const t=[];null!=this._fill&&t.push(this._fill);for(const e of this._holes)t.push(e);return null!=this._outline&&t.push(this._outline),t}getRetrievableObjects(){return null!=this._fill?[this._fill]:[]}_onGeometryChanged(){null!=this._fill&&this._updateFillGeometry(),this._holes.length>0&&this._updateHoleGeometries(),null!=this._outline&&this._updateOulineGeometry()}_onTagChanged(){let t=!1;return null!=this._fill&&this._updateFillMaterial(this._fill.material),null==this._outline?this._tag.lineWidth>=1&&(this._holes=this._createHoles(),this._outline=this._createOutline(),t=!0):(this._updateHoleMaterials(),this._updateOutlineMaterial()),t}_getPoints3d(){return this._in3dDomain()?this._tag.geometry.getVertices3d(this._transform):this._tag.geometry.getPoints3d(this._transform)}_getTriangles(){return this._in3dDomain()?this._tag.geometry.get3dDomainTriangles3d(this._transform):this._tag.geometry.getTriangles3d(this._transform)}_updateFillMaterial(t){t.color=new Dr(this._tag.fillColor),t.opacity=this._tag.fillOpacity,t.needsUpdate=!0}_updateLineBasicMaterial(t){t.color=new Dr(this._tag.lineColor),t.linewidth=Math.max(this._tag.lineWidth,1),t.visible=this._tag.lineWidth>=1&&this._tag.lineOpacity>0,t.opacity=this._tag.lineOpacity,t.transparent=this._tag.lineOpacity<1,t.needsUpdate=!0}_createHoles(){let t=[];if(this._tag.geometry instanceof X_){let e=this._getHoles3d();for(let i of e){let e=this._createLine(i);t.push(e)}}return t}_disposeHoles(){for(let t of this._holes)t.geometry.dispose(),t.material.dispose();this._holes=[]}_getHoles3d(){const t=this._tag.geometry;return this._in3dDomain()?t.getHoleVertices3d(this._transform):t.getHolePoints3d(this._transform)}_in3dDomain(){return this._tag.geometry instanceof X_&&this._tag.domain===t.TagDomain.ThreeDimensional}_updateHoleGeometries(){let t=this._getHoles3d();if(t.length!==this._holes.length)throw new Error("Changing the number of holes is not supported.");for(let e=0;e<this._holes.length;e++){let i=t[e],n=this._holes[e];this._updateLine(n,i)}}_updateHoleMaterials(){for(const t of this._holes)this._updateLineBasicMaterial(t.material)}_updateOutlineMaterial(){this._updateLineBasicMaterial(this._outline.material)}}t.Alignment=void 0,(iv=t.Alignment||(t.Alignment={}))[iv.Bottom=0]="Bottom",iv[iv.BottomLeft=1]="BottomLeft",iv[iv.BottomRight=2]="BottomRight",iv[iv.Center=3]="Center",iv[iv.Left=4]="Left",iv[iv.Right=5]="Right",iv[iv.Top=6]="Top",iv[iv.TopLeft=7]="TopLeft",iv[iv.TopRight=8]="TopRight";class hv extends ov{constructor(e,i,n){super(e,i);const r=null!=(n=n||{}).domain&&i instanceof X_?n.domain:t.TagDomain.TwoDimensional,s=this._twoDimensionalPolygon(r,i);this._domain=r,this._editable=null!=n.editable&&!s&&n.editable,this._fillColor=null==n.fillColor?16777215:n.fillColor,this._fillOpacity=null==n.fillOpacity?0:n.fillOpacity,this._icon=void 0===n.icon?null:n.icon,this._iconFloat=null==n.iconFloat?t.Alignment.Center:n.iconFloat,this._iconIndex=null==n.iconIndex?3:n.iconIndex,this._indicateVertices=null==n.indicateVertices||n.indicateVertices,this._lineColor=null==n.lineColor?16777215:n.lineColor,this._lineOpacity=null==n.lineOpacity?1:n.lineOpacity,this._lineWidth=null==n.lineWidth?1:n.lineWidth,this._text=void 0===n.text?null:n.text,this._textColor=null==n.textColor?16777215:n.textColor,this._click$=new T,this._click$.subscribe((()=>{const t="click",e={target:this,type:t};this.fire(t,e)}))}get click$(){return this._click$}get domain(){return this._domain}get editable(){return this._editable}set editable(t){this._twoDimensionalPolygon(this._domain,this._geometry)||(this._editable=t,this._notifyChanged$.next(this))}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor=t,this._notifyChanged$.next(this)}get fillOpacity(){return this._fillOpacity}set fillOpacity(t){this._fillOpacity=t,this._notifyChanged$.next(this)}get geometry(){return this._geometry}get icon(){return this._icon}set icon(t){this._icon=t,this._notifyChanged$.next(this)}get iconFloat(){return this._iconFloat}set iconFloat(t){this._iconFloat=t,this._notifyChanged$.next(this)}get iconIndex(){return this._iconIndex}set iconIndex(t){this._iconIndex=t,this._notifyChanged$.next(this)}get indicateVertices(){return this._indicateVertices}set indicateVertices(t){this._indicateVertices=t,this._notifyChanged$.next(this)}get lineColor(){return this._lineColor}set lineColor(t){this._lineColor=t,this._notifyChanged$.next(this)}get lineOpacity(){return this._lineOpacity}set lineOpacity(t){this._lineOpacity=t,this._notifyChanged$.next(this)}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this._notifyChanged$.next(this)}get text(){return this._text}set text(t){this._text=t,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this._notifyChanged$.next(this)}fire(t,e){super.fire(t,e)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}setOptions(t){const e=this._twoDimensionalPolygon(this._domain,this._geometry);this._editable=e||null==t.editable?this._editable:t.editable,this._icon=void 0===t.icon?this._icon:t.icon,this._iconFloat=null==t.iconFloat?this._iconFloat:t.iconFloat,this._iconIndex=null==t.iconIndex?this._iconIndex:t.iconIndex,this._indicateVertices=null==t.indicateVertices?this._indicateVertices:t.indicateVertices,this._lineColor=null==t.lineColor?this._lineColor:t.lineColor,this._lineWidth=null==t.lineWidth?this._lineWidth:t.lineWidth,this._fillColor=null==t.fillColor?this._fillColor:t.fillColor,this._fillOpacity=null==t.fillOpacity?this._fillOpacity:t.fillOpacity,this._text=void 0===t.text?this._text:t.text,this._textColor=null==t.textColor?this._textColor:t.textColor,this._notifyChanged$.next(this)}_twoDimensionalPolygon(e,i){return e!==t.TagDomain.ThreeDimensional&&i instanceof X_}}class lv extends nv{dispose(){}getDOMObjects(e,i,n){const r=this._tag,s={offsetHeight:n.height,offsetWidth:n.width},o=[],[a,c]=r.geometry.getCentroid2d(),h=this._viewportCoords.basicToCanvasSafe(a,c,s,this._transform,i);if(null!=h){const i=t=>{this._interact$.next({offsetX:0,offsetY:0,operation:tv.None,tag:r})},n=Math.round(h[0]),s=Math.round(h[1]);if(null!=r.icon){if(e.loaded){const a=e.getDOMSprite(r.icon,t.Alignment.Bottom),c={onpointerdown:i,style:{pointerEvents:"all",transform:`translate(${n}px,${s+8}px)`}};o.push(jf.h("div",c,[a]))}}else if(null!=r.text){const t=`translate(-50%,0%) translate(${n}px,${s+8}px)`,e={onpointerdown:i,style:{color:this._colorToCss(r.textColor),transform:t},textContent:r.text};o.push(jf.h("span.mapillary-tag-symbol",e,[]))}const a=this._interact(tv.Centroid,r,"move"),c=this._colorToCss(r.color),l=`translate(-50%,-50%) translate(${n}px,${s}px)`;if(r.editable){let t={onpointerdown:a,style:{background:c,transform:l}};o.push(jf.h("div.mapillary-tag-spot-interactor",t,[]))}const u={style:{background:c,transform:l}};o.push(jf.h("div.mapillary-tag-vertex",u,[]))}return o}getGLObjects(){return[]}getRetrievableObjects(){return[]}_colorToCss(t){return"#"+("000000"+t.toString(16)).substr(-6)}_interact(t,e,i,n){return r=>{const s=r.offsetX-r.target.offsetWidth/2,o=r.offsetY-r.target.offsetHeight/2;this._interact$.next({cursor:i,offsetX:s,offsetY:o,operation:t,tag:e,vertexIndex:n})}}}class uv extends ov{constructor(t,e,i){super(t,e),i=i||{},this._color=null==i.color?16777215:i.color,this._editable=null!=i.editable&&i.editable,this._icon=void 0===i.icon?null:i.icon,this._text=void 0===i.text?null:i.text,this._textColor=null==i.textColor?16777215:i.textColor}get color(){return this._color}set color(t){this._color=t,this._notifyChanged$.next(this)}get editable(){return this._editable}set editable(t){this._editable=t,this._notifyChanged$.next(this)}get icon(){return this._icon}set icon(t){this._icon=t,this._notifyChanged$.next(this)}get text(){return this._text}set text(t){this._text=t,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this._notifyChanged$.next(this)}setOptions(t){this._color=null==t.color?this._color:t.color,this._editable=null==t.editable?this._editable:t.editable,this._icon=void 0===t.icon?this._icon:t.icon,this._text=void 0===t.text?this._text:t.text,this._textColor=null==t.textColor?this._textColor:t.textColor,this._notifyChanged$.next(this)}}class dv{constructor(){this._active=!1,this._hash={},this._hashDeactivated={},this._notifyChanged$=new T}get active(){return this._active}get changed$(){return this._notifyChanged$}activate(t){if(!this._active){for(const e in this._hashDeactivated){if(!this._hashDeactivated.hasOwnProperty(e))continue;const i=this._hashDeactivated[e];this._add(i,t)}this._hashDeactivated={},this._active=!0,this._notifyChanged$.next(this)}}deactivate(){if(this._active){for(const t in this._hash)this._hash.hasOwnProperty(t)&&(this._hashDeactivated[t]=this._hash[t].tag);this._hash={},this._active=!1}}add(t,e){this._assertActivationState(!0);for(const i of t)this._add(i,e);this._notifyChanged$.next(this)}addDeactivated(t){this._assertActivationState(!1);for(const e of t){if(!(e instanceof hv||e instanceof uv||e instanceof av))throw new Error("Tag type not supported");this._hashDeactivated[e.id]=e}}get(t){return this.has(t)?this._hash[t]:void 0}getAll(){const t=this._hash;return Object.keys(t).map((e=>t[e]))}getAllDeactivated(){const t=this._hashDeactivated;return Object.keys(t).map((e=>t[e]))}getDeactivated(t){return this.hasDeactivated(t)?this._hashDeactivated[t]:void 0}has(t){return t in this._hash}hasDeactivated(t){return t in this._hashDeactivated}remove(t){this._assertActivationState(!0);const e=this._hash;for(const i of t)i in e&&delete e[i];this._notifyChanged$.next(this)}removeAll(){this._assertActivationState(!0),this._hash={},this._notifyChanged$.next(this)}removeAllDeactivated(){this._assertActivationState(!1),this._hashDeactivated={}}removeDeactivated(t){this._assertActivationState(!1);const e=this._hashDeactivated;for(const i of t)i in e&&delete e[i]}_add(t,e){if(t instanceof hv)this._hash[t.id]=new cv(t,e);else if(t instanceof uv)this._hash[t.id]=new lv(t,e);else{if(!(t instanceof av))throw new Error("Tag type not supported");this._hash[t.id]=new sv(t,e)}}_assertActivationState(t){if(t!==this._active)throw new Error("Tag set not in correct state for operation.")}}class pv extends xg{constructor(t){super();let e=t[0],i=t[1];if(e<0||e>1||i<0||i>1)throw new wg("Basic coordinates must be on the interval [0, 1].");this._point=t.slice()}get point(){return this._point}getCentroid2d(){return this._point.slice()}getCentroid3d(t){return t.unprojectBasic(this._point,200)}setCentroid2d(t,e){let i=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];this._point[0]=i[0],this._point[1]=i[1],this._notifyChanged$.next(this)}}class fv extends Tm{constructor(t,e,i,n){super(t,e,i),this._name=`${this._component.name}-${this._getNameExtension()}`,this._viewportCoords=n}_getConfiguration(t){return{}}_mouseEventToBasic(t,e,i,n,r,s){r=null!=r?r:0,s=null!=s?s:0;const[o,a]=this._viewportCoords.canvasPosition(t,e);return this._viewportCoords.canvasToBasic(o-r,a-s,e,n,i.perspective)}}class mv extends fv{constructor(t,e,i,n,r){super(t,e,i,n),this._tagCreator=r,this._geometryCreated$=new T}get geometryCreated$(){return this._geometryCreated$}_enable(){this._enableCreate(),this._container.container.classList.add("component-tag-create")}_disable(){this._container.container.classList.remove("component-tag-create"),this._disableCreate()}_validateBasic(t){const e=t[0],i=t[1];return 0<=e&&e<=1&&0<=i&&i<=1}_mouseEventToBasic$(t){return t.pipe(bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$),rt((([t,e,i])=>this._mouseEventToBasic(t,this._container.container,e,i))))}}class gv extends mv{_enableCreate(){this._container.mouseService.deferPixels(this._name,4),this._geometryCreatedSubscription=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(Nt(this._validateBasic),rt((t=>new pv(t)))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._geometryCreatedSubscription.unsubscribe()}_getNameExtension(){return"create-point"}}class _v extends mv{_enableCreate(){this._container.mouseService.deferPixels(this._name,4);const t=this._navigator.stateService.currentTransform$.pipe(rt((()=>{})),Ue(1),E());this._deleteSubscription=t.pipe(Je(1)).subscribe(this._tagCreator.delete$);const e=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(Ze());this._createSubscription=t.pipe(ri((()=>e.pipe(Nt(this._validateBasic),ve(1))))).subscribe(this._create$),this._setVertexSubscription=this._tagCreator.tag$.pipe(ri((t=>t?gt(G(t),Ot(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$),this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$):B()))).subscribe((([t,e,i,n])=>{const r=this._mouseEventToBasic(e,this._container.container,i,n);this._setVertex2d(t,r,n)})),this._addPointSubscription=this._tagCreator.tag$.pipe(ri((t=>t?gt(G(t),e):B()))).subscribe((([t,e])=>{this._addPoint(t,e)})),this._geometryCreateSubscription=this._tagCreator.tag$.pipe(ri((t=>t?t.created$.pipe(rt((t=>t.geometry))):B()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreateSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}}class vv extends _v{get _create$(){return this._tagCreator.createPoints$}_addPoint(t,e){t.geometry.addPoint2d(e)}_getNameExtension(){return"create-points"}_setVertex2d(t,e,i){t.geometry.setPoint2d(t.geometry.points.length-1,e,i)}}class yv extends _v{get _create$(){return this._tagCreator.createPolygon$}_addPoint(t,e){t.addPoint(e)}_getNameExtension(){return"create-polygon"}_setVertex2d(t,e,i){t.geometry.setVertex2d(t.geometry.polygon.length-2,e,i)}}class bv extends _v{get _create$(){return this._tagCreator.createRect$}_addPoint(t,e){const i=t.geometry;i.validate(e)||(e=i.getNonAdjustedVertex2d(3)),t.addPoint(e)}_enable(){super._enable(),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(Nt((t=>!!t))).subscribe((t=>{t.geometry.initializeAnchorIndexing()}))}_disable(){super._disable(),this._initializeAnchorIndexingSubscription.unsubscribe()}_getNameExtension(){return"create-rect"}_setVertex2d(t,e,i){t.geometry.setOppositeVertex2d(e,i)}}class xv extends mv{_enableCreate(){this._container.mouseService.claimMouse(this._name,2),this._deleteSubscription=this._navigator.stateService.currentTransform$.pipe(rt((t=>null)),Je(1)).subscribe(this._tagCreator.delete$),this._createSubscription=this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$)).pipe(Nt(this._validateBasic)).subscribe(this._tagCreator.createRect$),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(Nt((t=>!!t))).subscribe((t=>{t.geometry.initializeAnchorIndexing()}));const t=gt(Ot(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseMove$),this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseMove$)),this._container.renderService.renderCamera$).pipe(bi(this._navigator.stateService.currentTransform$),rt((([[t,e],i])=>this._mouseEventToBasic(t,this._container.container,e,i))));this._setVertexSubscription=this._tagCreator.tag$.pipe(ri((e=>e?gt(G(e),t,this._navigator.stateService.currentTransform$):B()))).subscribe((([t,e,i])=>{t.geometry.setOppositeVertex2d(e,i)}));const e=this._container.mouseService.mouseDragEnd$.pipe(bi(this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$)).pipe(Nt(this._validateBasic)),((t,e)=>e)),Ze());this._addPointSubscription=this._tagCreator.tag$.pipe(ri((t=>t?gt(G(t),e):B()))).subscribe((([t,e])=>{const i=t.geometry;i.validate(e)||(e=i.getNonAdjustedVertex2d(3)),t.addPoint(e)})),this._geometryCreatedSubscription=this._tagCreator.tag$.pipe(ri((t=>t?t.created$.pipe(rt((t=>t.geometry))):B()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.unclaimMouse(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreatedSubscription.unsubscribe(),this._initializeAnchorIndexingSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}_getNameExtension(){return"create-rect-drag"}}class wv extends fv{constructor(t,e,i,n,r){super(t,e,i,n),this._tagSet=r}_enable(){const t=this._tagSet.changed$.pipe(rt((t=>t.getAll())),ri((t=>bt(t).pipe(Mt((t=>t.interact$))))),ri((t=>At(G(t),this._container.mouseService.documentMouseUp$.pipe(rt((()=>({offsetX:0,offsetY:0,operation:tv.None,tag:null}))),Ee())))),Ze());Ot(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$).pipe(Ze()),this._claimMouseSubscription=t.pipe(ri((t=>t.tag?this._container.mouseService.domMouseDragStart$:B()))).subscribe((()=>{this._container.mouseService.claimMouse(this._name,3)})),this._cursorSubscription=t.pipe(rt((t=>t.cursor)),ue()).subscribe((t=>{const e=["crosshair","move","nesw-resize","nwse-resize"];for(const t of e)this._container.container.classList.remove(`component-tag-edit-${t}`);t&&this._container.container.classList.add(`component-tag-edit-${t}`)})),this._unclaimMouseSubscription=this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDragEnd$).subscribe((t=>{this._container.mouseService.unclaimMouse(this._name)})),this._preventDefaultSubscription=t.pipe(ri((t=>t.tag?this._container.mouseService.documentMouseMove$:B()))).subscribe((t=>{t.preventDefault()})),this._updateGeometrySubscription=t.pipe(ri((t=>{if(t.operation===tv.None||!t.tag)return B();return gt(this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDrag$).pipe(Nt((t=>this._viewportCoords.insideElement(t,this._container.container)))),this._container.renderService.renderCamera$).pipe(bi(G(t),this._navigator.stateService.currentTransform$,(([t,e],i,n)=>[t,e,i,n])))}))).subscribe((([t,e,i,n])=>{const r=this._mouseEventToBasic(t,this._container.container,e,n,i.offsetX,i.offsetY),s=i.tag.geometry;i.operation===tv.Centroid?s.setCentroid2d(r,n):i.operation===tv.Vertex&&s.setVertex2d(i.vertexIndex,r,n)}))}_disable(){this._claimMouseSubscription.unsubscribe(),this._cursorSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._unclaimMouseSubscription.unsubscribe(),this._updateGeometrySubscription.unsubscribe()}_getNameExtension(){return"edit-vertex"}}class Sv extends Vf{constructor(t,e,i){super(t,e,i),this._tagDomRenderer=new J_,this._tagScene=new K_,this._tagSet=new dv,this._tagCreator=new Z_(this,i),this._viewportCoords=new Wf,this._createHandlers={CreatePoint:new gv(this,e,i,this._viewportCoords,this._tagCreator),CreatePoints:new vv(this,e,i,this._viewportCoords,this._tagCreator),CreatePolygon:new yv(this,e,i,this._viewportCoords,this._tagCreator),CreateRect:new bv(this,e,i,this._viewportCoords,this._tagCreator),CreateRectDrag:new xv(this,e,i,this._viewportCoords,this._tagCreator),Default:void 0},this._editVertexHandler=new wv(this,e,i,this._viewportCoords,this._tagSet),this._renderTags$=this._tagSet.changed$.pipe(rt((t=>{const e=t.getAll();return e.sort(((t,e)=>{const i=t.tag.id,n=e.tag.id;return i<n?-1:i>n?1:0})),e})),Ze()),this._tagChanged$=this._renderTags$.pipe(ri((t=>bt(t).pipe(Mt((t=>Ot(t.tag.changed$,t.tag.geometryChanged$)))))),Ze()),this._renderTagGLChanged$=this._renderTags$.pipe(ri((t=>bt(t).pipe(Mt((t=>t.glObjectsChanged$))))),Ze()),this._createGeometryChanged$=this._tagCreator.tag$.pipe(ri((t=>null!=t?t.geometryChanged$:B())),Ze()),this._createGLObjectsChanged$=this._tagCreator.tag$.pipe(ri((t=>null!=t?t.glObjectsChanged$:B())),Ze()),this._creatingConfiguration$=this._configuration$.pipe(ue(((t,e)=>t.mode===e.mode),(t=>({createColor:t.createColor,mode:t.mode}))),Ue(1),E()),this._creatingConfiguration$.subscribe((t=>{const e="tagmode",i={mode:t.mode,target:this,type:e};this.fire(e,i)}))}add(t){this._activated?this._navigator.stateService.currentTransform$.pipe(Ee()).subscribe((e=>{this._tagSet.add(t,e);const i=t.map((t=>this._tagSet.get(t.id)));this._tagScene.add(i)})):this._tagSet.addDeactivated(t)}calculateRect(t){return new Promise(((e,i)=>{this._navigator.stateService.currentTransform$.pipe(Ee(),rt((e=>t.getRect2d(e)))).subscribe((t=>{e(t)}),(t=>{i(t)}))}))}create(){this._tagCreator.replayedTag$.pipe(Ee(),Nt((t=>!!t))).subscribe((t=>{t.create()}))}changeMode(t){this.configure({mode:t})}fire(t,e){super.fire(t,e)}get(t){if(this._activated){const e=this._tagSet.get(t);return void 0!==e?e.tag:void 0}return this._tagSet.getDeactivated(t)}getAll(){return this.activated?this._tagSet.getAll().map((t=>t.tag)):this._tagSet.getAllDeactivated()}getTagIdsAt(t){return new Promise(((e,i)=>{this._container.renderService.renderCamera$.pipe(Ee(),rt((e=>{const i=this._viewportCoords.canvasToViewport(t[0],t[1],this._container.container);return this._tagScene.intersectObjects(i,e.perspective)}))).subscribe((t=>{e(t)}),(t=>{i(t)}))}))}has(t){return this._activated?this._tagSet.has(t):this._tagSet.hasDeactivated(t)}off(t,e){super.off(t,e)}on(t,e){super.on(t,e)}remove(t){this._activated?(this._tagSet.remove(t),this._tagScene.remove(t)):this._tagSet.removeDeactivated(t)}removeAll(){this._activated?(this._tagSet.removeAll(),this._tagScene.removeAll()):this._tagSet.removeAllDeactivated()}_activate(){this._editVertexHandler.enable();const e=bt(Object.keys(this._createHandlers)).pipe(rt((t=>this._createHandlers[t])),Nt((t=>!!t)),Mt((t=>t.geometryCreated$)),Ze()),i=this._subscriptions;i.push(e.subscribe((t=>{const e="geometrycreate",i={geometry:t,target:this,type:e};this.fire(e,i)}))),i.push(this._tagCreator.tag$.pipe(ti((t=>null==t)),ue()).subscribe((t=>{const e=null!=t?"tagcreatestart":"tagcreateend",i={target:this,type:e};this.fire(e,i)}))),i.push(e.subscribe((()=>{this.changeMode(t.TagMode.Default)}))),i.push(this._creatingConfiguration$.subscribe((e=>{this._disableCreateHandlers();const i=t.TagMode[e.mode],n=this._createHandlers[i];n&&n.enable()}))),i.push(this._renderTags$.subscribe((()=>{const t="tags",e={target:this,type:t};this.fire(t,e)}))),i.push(this._tagCreator.tag$.pipe(ri((t=>null!=t?t.aborted$.pipe(rt((()=>null))):B()))).subscribe((()=>{this.changeMode(t.TagMode.Default)}))),i.push(this._tagCreator.tag$.subscribe((t=>{this._tagScene.hasCreateTag()&&this._tagScene.removeCreateTag(),null!=t&&this._tagScene.addCreateTag(t)}))),i.push(this._createGLObjectsChanged$.subscribe((t=>{this._tagScene.updateCreateTagObjects(t)}))),i.push(this._renderTagGLChanged$.subscribe((t=>{this._tagScene.updateObjects(t)}))),i.push(this._tagChanged$.subscribe((()=>{this._tagScene.update()}))),i.push(gt(this._renderTags$.pipe(ni([]),pi((()=>{this._container.domRenderer.render$.next({name:this._name,vNode:this._tagDomRenderer.clear()})}))),this._container.renderService.renderCamera$,this._container.spriteService.spriteAtlas$,this._container.renderService.size$,this._tagChanged$.pipe(ni(null)),Ot(this._tagCreator.tag$,this._createGeometryChanged$).pipe(ni(null))).pipe(rt((([t,e,i,n,,r])=>({name:this._name,vNode:this._tagDomRenderer.render(t,r,i,e.perspective,n)})))).subscribe(this._container.domRenderer.render$)),i.push(this._navigator.stateService.currentState$.pipe(rt((t=>{const e=this._tagScene;return{name:this._name,renderer:{frameId:t.id,needsRender:e.needsRender,render:e.render.bind(e),pass:rm.Opaque}}}))).subscribe(this._container.glRenderer.render$)),this._navigator.stateService.currentTransform$.pipe(Ee()).subscribe((t=>{this._tagSet.activate(t),this._tagScene.add(this._tagSet.getAll())}))}_deactivate(){this._editVertexHandler.disable(),this._disableCreateHandlers(),this._tagScene.clear(),this._tagSet.deactivate(),this._tagCreator.delete$.next(null),this._subscriptions.unsubscribe(),this._container.container.classList.remove("component-tag-create")}_getDefaultConfiguration(){return{createColor:16777215,indicatePointsCompleter:!0,mode:t.TagMode.Default}}_disableCreateHandlers(){const t=this._createHandlers;for(const e in t){if(!t.hasOwnProperty(e))continue;const i=t[e];i&&i.disable()}}}Sv.componentName="tag";class Mv extends Vf{constructor(t,e,i){super(t,e,i),this._viewportCoords=new Wf,this._zoomDelta$=new T}_activate(){const e=this._subscriptions;e.push(gt(this._navigator.stateService.currentState$,this._navigator.stateService.state$,this._configuration$,this._container.renderService.size$).pipe(rt((([e,i,n,r])=>{const s=e.state.zoom,o=jf.h("div.mapillary-zoom-in-icon",[]),a=s>=3||i===vm.Waiting?jf.h("div.mapillary-zoom-in-button-inactive",[o]):jf.h("div.mapillary-zoom-in-button",{onclick:()=>{this._zoomDelta$.next(1)}},[o]),c=jf.h("div.mapillary-zoom-out-icon",[]),h=s<=0||i===vm.Waiting?jf.h("div.mapillary-zoom-out-button-inactive",[c]):jf.h("div.mapillary-zoom-out-button",{onclick:()=>{this._zoomDelta$.next(-1)}},[c]),l=n.size===t.ComponentSize.Small||n.size===t.ComponentSize.Automatic&&r.width<640?".mapillary-zoom-compact":"";return{name:this._name,vNode:jf.h("div.mapillary-zoom-container"+l,{oncontextmenu:t=>{t.preventDefault()}},[a,h])}}))).subscribe(this._container.domRenderer.render$)),e.push(this._zoomDelta$.pipe(bi(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([t,e,i])=>{const n=this._viewportCoords.unprojectFromViewport(0,0,e.perspective),r=i.projectBasic(n.toArray());this._navigator.stateService.zoomIn(t,r)})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{size:t.ComponentSize.Automatic}}}Mv.componentName="zoom";class Tv extends Vf{constructor(t,e,i,n){super(t,e,i),this._canvasId=`${e.id}-${this._name}`,this._dom=n||new Xm}_activate(){const t=this._container.domRenderer.element$.pipe(rt((()=>this._dom.document.getElementById(this._canvasId))),Nt((t=>!!t)),rt((t=>{const e=t.parentElement,i=e.offsetWidth;return[t,{height:e.offsetHeight,width:i}]})),ue(((t,e)=>t.height===e.height&&t.width===e.width),(([,t])=>t)));this._subscriptions.push(gt(t,this._navigator.stateService.currentImage$).subscribe((([[t,e],i])=>{t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(i.image,0,0,e.width,e.height)}))),this._container.domRenderer.renderAdaptive$.next({name:this._name,vNode:jf.h(`canvas#${this._canvasId}`,[])})}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}}Tv.componentName="imagefallback";class Cv extends Vf{constructor(e,i,n){super(e,i,n),this._seqNames={},this._seqNames[t.NavigationDirection[t.NavigationDirection.Prev]]="-prev",this._seqNames[t.NavigationDirection[t.NavigationDirection.Next]]="-next",this._spaTopNames={},this._spaTopNames[t.NavigationDirection[t.NavigationDirection.TurnLeft]]="-turn-left",this._spaTopNames[t.NavigationDirection[t.NavigationDirection.StepLeft]]="-left",this._spaTopNames[t.NavigationDirection[t.NavigationDirection.StepForward]]="-forward",this._spaTopNames[t.NavigationDirection[t.NavigationDirection.StepRight]]="-right",this._spaTopNames[t.NavigationDirection[t.NavigationDirection.TurnRight]]="-turn-right",this._spaBottomNames={},this._spaBottomNames[t.NavigationDirection[t.NavigationDirection.TurnU]]="-turn-around",this._spaBottomNames[t.NavigationDirection[t.NavigationDirection.StepBackward]]="-backward"}_activate(){this._subscriptions.push(gt(this._navigator.stateService.currentImage$,this._configuration$).pipe(ri((([t,e])=>gt(e.sequence?t.sequenceEdges$.pipe(rt((t=>t.edges.map((t=>t.data.direction))))):G([]),!dd(t.cameraType)&&e.spatial?t.spatialEdges$.pipe(rt((t=>t.edges.map((t=>t.data.direction))))):G([])).pipe(rt((([t,e])=>t.concat(e)))))),rt((t=>{const e=this._createArrowRow(this._seqNames,t),i=this._createArrowRow(this._spaTopNames,t),n=this._createArrowRow(this._spaBottomNames,t),r=jf.h("div.mapillary-navigation-sequence",e),s=jf.h("div.NavigationSpatialTop",i),o=jf.h("div.mapillary-navigation-spatial-bottom",n),a=jf.h("div.mapillary-navigation-spatial",[s,o]);return{name:this._name,vNode:jf.h("div.NavigationContainer",[r,a])}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{sequence:!0,spatial:!0}}_createArrowRow(e,i){const n=[];for(const r in e){if(!e.hasOwnProperty(r))continue;const s=t.NavigationDirection[r];-1!==i.indexOf(s)?n.push(this._createVNode(s,e[r],"visible")):n.push(this._createVNode(s,e[r],"hidden"))}return n}_createVNode(t,e,i){return jf.h(`span.mapillary-navigation-button.mapillary-navigation${e}`,{onclick:()=>{this._navigator.moveDir$(t).subscribe(void 0,(t=>{t instanceof Zf||console.error(t)}))},style:{visibility:i}},[])}}Cv.componentName="navigationfallback";function Ev(t){let e=t.length;for(;--e>=0;)t[e]=0}const Iv=256,Av=286,Pv=30,Rv=15,Lv=new Uint8Array([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]),Ov=new Uint8Array([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]),Nv=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Dv=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$v=new Array(576);Ev($v);const kv=new Array(60);Ev(kv);const zv=new Array(512);Ev(zv);const Fv=new Array(256);Ev(Fv);const Bv=new Array(29);Ev(Bv);const jv=new Array(Pv);function Hv(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let Uv,Vv,Gv;function qv(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Ev(jv);const Wv=t=>t<256?zv[t]:zv[256+(t>>>7)],Xv=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Yv=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,Xv(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},Zv=(t,e,i)=>{Yv(t,i[2*e],i[2*e+1])},Jv=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},Kv=(t,e,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=Rv;r++)n[r]=o=o+i[r-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=Jv(n[e]++,e))}},Qv=t=>{let e;for(e=0;e<Av;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Pv;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},ty=t=>{t.bi_valid>8?Xv(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},ey=(t,e,i,n)=>{const r=2*e,s=2*i;return t[r]<t[s]||t[r]===t[s]&&n[e]<=n[i]},iy=(t,e,i)=>{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r<t.heap_len&&ey(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!ey(e,n,t.heap[r],t.depth));)t.heap[i]=t.heap[r],i=r,r<<=1;t.heap[i]=n},ny=(t,e,i)=>{let n,r,s,o,a=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],r=t.pending_buf[t.l_buf+a],a++,0===n?Zv(t,r,e):(s=Fv[r],Zv(t,s+Iv+1,e),o=Lv[s],0!==o&&(r-=Bv[s],Yv(t,r,o)),n--,s=Wv(n),Zv(t,s,i),o=Ov[s],0!==o&&(n-=jv[s],Yv(t,n,o)))}while(a<t.last_lit);Zv(t,256,e)},ry=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,c,h=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==i[2*o]?(t.heap[++t.heap_len]=h=o,t.depth[o]=0):i[2*o+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=h<2?++h:0,i[2*c]=1,t.depth[c]=0,t.opt_len--,r&&(t.static_len-=n[2*c+1]);for(e.max_code=h,o=t.heap_len>>1;o>=1;o--)iy(t,i,o);c=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],iy(t,i,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,i[2*c]=i[2*o]+i[2*a],t.depth[c]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,i[2*o+1]=i[2*a+1]=c,t.heap[1]=c++,iy(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length;let h,l,u,d,p,f,m=0;for(d=0;d<=Rv;d++)t.bl_count[d]=0;for(i[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)l=t.heap[h],d=i[2*i[2*l+1]+1]+1,d>c&&(d=c,m++),i[2*l+1]=d,l>n||(t.bl_count[d]++,p=0,l>=a&&(p=o[l-a]),f=i[2*l],t.opt_len+=f*(d+p),s&&(t.static_len+=f*(r[2*l+1]+p)));if(0!==m){do{for(d=c-1;0===t.bl_count[d];)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[c]--,m-=2}while(m>0);for(d=c;0!==d;d--)for(l=t.bl_count[d];0!==l;)u=t.heap[--h],u>n||(i[2*u+1]!==d&&(t.opt_len+=(d-i[2*u+1])*i[2*u],i[2*u+1]=d),l--)}})(t,e),Kv(i,h,t.bl_count)},sy=(t,e,i)=>{let n,r,s=-1,o=e[1],a=0,c=7,h=4;for(0===o&&(c=138,h=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=e[2*(n+1)+1],++a<c&&r===o||(a<h?t.bl_tree[2*r]+=a:0!==r?(r!==s&&t.bl_tree[2*r]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=r,0===o?(c=138,h=3):r===o?(c=6,h=3):(c=7,h=4))},oy=(t,e,i)=>{let n,r,s=-1,o=e[1],a=0,c=7,h=4;for(0===o&&(c=138,h=3),n=0;n<=i;n++)if(r=o,o=e[2*(n+1)+1],!(++a<c&&r===o)){if(a<h)do{Zv(t,r,t.bl_tree)}while(0!=--a);else 0!==r?(r!==s&&(Zv(t,r,t.bl_tree),a--),Zv(t,16,t.bl_tree),Yv(t,a-3,2)):a<=10?(Zv(t,17,t.bl_tree),Yv(t,a-3,3)):(Zv(t,18,t.bl_tree),Yv(t,a-11,7));a=0,s=r,0===o?(c=138,h=3):r===o?(c=6,h=3):(c=7,h=4)}};let ay=!1;const cy=(t,e,i,n)=>{Yv(t,0+(n?1:0),3),((t,e,i,n)=>{ty(t),n&&(Xv(t,i),Xv(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i,!0)};var hy={_tr_init:t=>{ay||((()=>{let t,e,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(Bv[n]=i,t=0;t<1<<Lv[n];t++)Fv[i++]=n;for(Fv[i-1]=n,r=0,n=0;n<16;n++)for(jv[n]=r,t=0;t<1<<Ov[n];t++)zv[r++]=n;for(r>>=7;n<Pv;n++)for(jv[n]=r<<7,t=0;t<1<<Ov[n]-7;t++)zv[256+r++]=n;for(e=0;e<=Rv;e++)s[e]=0;for(t=0;t<=143;)$v[2*t+1]=8,t++,s[8]++;for(;t<=255;)$v[2*t+1]=9,t++,s[9]++;for(;t<=279;)$v[2*t+1]=7,t++,s[7]++;for(;t<=287;)$v[2*t+1]=8,t++,s[8]++;for(Kv($v,287,s),t=0;t<Pv;t++)kv[2*t+1]=5,kv[2*t]=Jv(t,5);Uv=new Hv($v,Lv,257,Av,Rv),Vv=new Hv(kv,Ov,0,Pv,Rv),Gv=new Hv(new Array(0),Nv,0,19,7)})(),ay=!0),t.l_desc=new qv(t.dyn_ltree,Uv),t.d_desc=new qv(t.dyn_dtree,Vv),t.bl_desc=new qv(t.bl_tree,Gv),t.bi_buf=0,t.bi_valid=0,Qv(t)},_tr_stored_block:cy,_tr_flush_block:(t,e,i,n)=>{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Iv;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),ry(t,t.l_desc),ry(t,t.d_desc),o=(t=>{let e;for(sy(t,t.dyn_ltree,t.l_desc.max_code),sy(t,t.dyn_dtree,t.d_desc.max_code),ry(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Dv[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==e?cy(t,e,i,n):4===t.strategy||s===r?(Yv(t,2+(n?1:0),3),ny(t,$v,kv)):(Yv(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(Yv(t,e-257,5),Yv(t,i-1,5),Yv(t,n-4,4),r=0;r<n;r++)Yv(t,t.bl_tree[2*Dv[r]+1],3);oy(t,t.dyn_ltree,e-1),oy(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),ny(t,t.dyn_ltree,t.dyn_dtree)),Qv(t),n&&ty(t)},_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(Fv[i]+Iv+1)]++,t.dyn_dtree[2*Wv(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{Yv(t,2,3),Zv(t,256,$v),(t=>{16===t.bi_valid?(Xv(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var ly=(t,e,i,n)=>{let r=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+e[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16|0};const uy=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var dy=(t,e,i,n)=>{const r=uy,s=n+i;t^=-1;for(let i=n;i<s;i++)t=t>>>8^r[255&(t^e[i])];return-1^t},py={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},fy={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:my,_tr_stored_block:gy,_tr_flush_block:_y,_tr_tally:vy,_tr_align:yy}=hy,{Z_NO_FLUSH:by,Z_PARTIAL_FLUSH:xy,Z_FULL_FLUSH:wy,Z_FINISH:Sy,Z_BLOCK:My,Z_OK:Ty,Z_STREAM_END:Cy,Z_STREAM_ERROR:Ey,Z_DATA_ERROR:Iy,Z_BUF_ERROR:Ay,Z_DEFAULT_COMPRESSION:Py,Z_FILTERED:Ry,Z_HUFFMAN_ONLY:Ly,Z_RLE:Oy,Z_FIXED:Ny,Z_DEFAULT_STRATEGY:Dy,Z_UNKNOWN:$y,Z_DEFLATED:ky}=fy,zy=258,Fy=262,By=103,jy=113,Hy=666,Uy=(t,e)=>(t.msg=py[e],e),Vy=t=>(t<<1)-(t>4?9:0),Gy=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let qy=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const Wy=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},Xy=(t,e)=>{_y(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Wy(t.strm)},Yy=(t,e)=>{t.pending_buf[t.pending++]=e},Zy=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Jy=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=ly(t.adler,e,r,i):2===t.state.wrap&&(t.adler=dy(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},Ky=(t,e)=>{let i,n,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-Fy?t.strstart-(t.w_size-Fy):0,h=t.window,l=t.w_mask,u=t.prev,d=t.strstart+zy;let p=h[s+o-1],f=h[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(i=e,h[i+o]===f&&h[i+o-1]===p&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&s<d);if(n=zy-(d-s),s=d-zy,n>o){if(t.match_start=e,o=n,n>=a)break;p=h[s+o-1],f=h[s+o]}}}while((e=u[e&l])>c&&0!=--r);return o<=t.lookahead?o:t.lookahead},Qy=t=>{const e=t.w_size;let i,n,r,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Fy)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{r=t.head[--i],t.head[i]=r>=e?r-e:0}while(--n);n=e,i=n;do{r=t.prev[--i],t.prev[i]=r>=e?r-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=Jy(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=qy(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=qy(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Fy&&0!==t.strm.avail_in)},tb=(t,e)=>{let i,n;for(;;){if(t.lookahead<Fy){if(Qy(t),t.lookahead<Fy&&e===by)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=qy(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-Fy&&(t.match_length=Ky(t,i)),t.match_length>=3)if(n=vy(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=qy(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=qy(t,t.ins_h,t.window[t.strstart+1]);else n=vy(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Xy(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Sy?(Xy(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Xy(t,!1),0===t.strm.avail_out)?1:2},eb=(t,e)=>{let i,n,r;for(;;){if(t.lookahead<Fy){if(Qy(t),t.lookahead<Fy&&e===by)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=qy(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-Fy&&(t.match_length=Ky(t,i),t.match_length<=5&&(t.strategy===Ry||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=vy(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=qy(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Xy(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=vy(t,0,t.window[t.strstart-1]),n&&Xy(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=vy(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Sy?(Xy(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Xy(t,!1),0===t.strm.avail_out)?1:2};function ib(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const nb=[new ib(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Qy(t),0===t.lookahead&&e===by)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,Xy(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-Fy&&(Xy(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Sy?(Xy(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(Xy(t,!1),t.strm.avail_out),1)})),new ib(4,4,8,4,tb),new ib(4,5,16,8,tb),new ib(4,6,32,32,tb),new ib(4,4,16,16,eb),new ib(8,16,32,32,eb),new ib(8,16,128,128,eb),new ib(8,32,128,256,eb),new ib(32,128,258,1024,eb),new ib(32,258,258,4096,eb)];function rb(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ky,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Gy(this.dyn_ltree),Gy(this.dyn_dtree),Gy(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Gy(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Gy(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const sb=t=>{if(!t||!t.state)return Uy(t,Ey);t.total_in=t.total_out=0,t.data_type=$y;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:jy,t.adler=2===e.wrap?0:1,e.last_flush=by,my(e),Ty},ob=t=>{const e=sb(t);var i;return e===Ty&&((i=t.state).window_size=2*i.w_size,Gy(i.head),i.max_lazy_match=nb[i.level].max_lazy,i.good_match=nb[i.level].good_length,i.nice_match=nb[i.level].nice_length,i.max_chain_length=nb[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},ab=(t,e,i,n,r,s)=>{if(!t)return Ey;let o=1;if(e===Py&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==ky||n<8||n>15||e<0||e>9||s<0||s>Ny)return Uy(t,Ey);8===n&&(n=9);const a=new rb;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=s,a.method=i,ob(t)};var cb={deflateInit:(t,e)=>ab(t,e,ky,15,8,Dy),deflateInit2:ab,deflateReset:ob,deflateResetKeep:sb,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Ey:(t.state.gzhead=e,Ty):Ey,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>My||e<0)return t?Uy(t,Ey):Ey;const r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===Hy&&e!==Sy)return Uy(t,0===t.avail_out?Ay:Ey);r.strm=t;const s=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Yy(r,31),Yy(r,139),Yy(r,8),r.gzhead?(Yy(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Yy(r,255&r.gzhead.time),Yy(r,r.gzhead.time>>8&255),Yy(r,r.gzhead.time>>16&255),Yy(r,r.gzhead.time>>24&255),Yy(r,9===r.level?2:r.strategy>=Ly||r.level<2?4:0),Yy(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Yy(r,255&r.gzhead.extra.length),Yy(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=dy(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Yy(r,0),Yy(r,0),Yy(r,0),Yy(r,0),Yy(r,0),Yy(r,9===r.level?2:r.strategy>=Ly||r.level<2?4:0),Yy(r,3),r.status=jy);else{let e=ky+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=Ly||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,r.status=jy,Zy(r,e),0!==r.strstart&&(Zy(r,t.adler>>>16),Zy(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),Wy(t),i=r.pending,r.pending!==r.pending_buf_size));)Yy(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),Wy(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Yy(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),Wy(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Yy(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=dy(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=By)}else r.status=By;if(r.status===By&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&Wy(t),r.pending+2<=r.pending_buf_size&&(Yy(r,255&t.adler),Yy(r,t.adler>>8&255),t.adler=0,r.status=jy)):r.status=jy),0!==r.pending){if(Wy(t),0===t.avail_out)return r.last_flush=-1,Ty}else if(0===t.avail_in&&Vy(e)<=Vy(s)&&e!==Sy)return Uy(t,Ay);if(r.status===Hy&&0!==t.avail_in)return Uy(t,Ay);if(0!==t.avail_in||0!==r.lookahead||e!==by&&r.status!==Hy){let i=r.strategy===Ly?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(Qy(t),0===t.lookahead)){if(e===by)return 1;break}if(t.match_length=0,i=vy(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(Xy(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Sy?(Xy(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Xy(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===Oy?((t,e)=>{let i,n,r,s;const o=t.window;for(;;){if(t.lookahead<=zy){if(Qy(t),t.lookahead<=zy&&e===by)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=t.strstart+zy;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&r<s);t.match_length=zy-(s-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=vy(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=vy(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(Xy(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Sy?(Xy(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Xy(t,!1),0===t.strm.avail_out)?1:2})(r,e):nb[r.level].func(r,e);if(3!==i&&4!==i||(r.status=Hy),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),Ty;if(2===i&&(e===xy?yy(r):e!==My&&(gy(r,0,0,!1),e===wy&&(Gy(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Wy(t),0===t.avail_out))return r.last_flush=-1,Ty}return e!==Sy?Ty:r.wrap<=0?Cy:(2===r.wrap?(Yy(r,255&t.adler),Yy(r,t.adler>>8&255),Yy(r,t.adler>>16&255),Yy(r,t.adler>>24&255),Yy(r,255&t.total_in),Yy(r,t.total_in>>8&255),Yy(r,t.total_in>>16&255),Yy(r,t.total_in>>24&255)):(Zy(r,t.adler>>>16),Zy(r,65535&t.adler)),Wy(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Ty:Cy)},deflateEnd:t=>{if(!t||!t.state)return Ey;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==By&&e!==jy&&e!==Hy?Uy(t,Ey):(t.state=null,e===jy?Uy(t,Iy):Ty)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return Ey;const n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return Ey;if(1===r&&(t.adler=ly(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(Gy(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Qy(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=qy(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Qy(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=r,Ty},deflateInfo:"pako deflate (from Nodeca project)"};const hb=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var lb=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)hb(i,e)&&(t[e]=i[e])}}return t},ub=t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,r=t.length;e<r;e++){let r=t[e];i.set(r,n),n+=r.length}return i};let db=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){db=!1}const pb=new Uint8Array(256);for(let t=0;t<256;t++)pb[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;pb[254]=pb[254]=1;var fb=t=>{let e,i,n,r,s,o=t.length,a=0;for(r=0;r<o;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(a),s=0,r=0;s<a;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?e[s++]=i:i<2048?(e[s++]=192|i>>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},mb=(t,e)=>{let i,n;const r=e||t.length,s=new Array(2*r);for(n=0,i=0;i<r;){let e=t[i++];if(e<128){s[n++]=e;continue}let o=pb[e];if(o>4)s[n++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<r;)e=e<<6|63&t[i++],o--;o>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&db)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(s,n)},gb=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+pb[t[i]]>e?i:e};var _b=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const vb=Object.prototype.toString,{Z_NO_FLUSH:yb,Z_SYNC_FLUSH:bb,Z_FULL_FLUSH:xb,Z_FINISH:wb,Z_OK:Sb,Z_STREAM_END:Mb,Z_DEFAULT_COMPRESSION:Tb,Z_DEFAULT_STRATEGY:Cb,Z_DEFLATED:Eb}=fy;function Ib(t){this.options=lb({level:Tb,method:Eb,chunkSize:16384,windowBits:15,memLevel:8,strategy:Cb},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _b,this.strm.avail_out=0;let i=cb.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Sb)throw new Error(py[i]);if(e.header&&cb.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?fb(e.dictionary):"[object ArrayBuffer]"===vb.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=cb.deflateSetDictionary(this.strm,t),i!==Sb)throw new Error(py[i]);this._dict_set=!0}}Ib.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?wb:yb,"string"==typeof t?i.input=fb(t):"[object ArrayBuffer]"===vb.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===bb||s===xb)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=cb.deflate(i,s),r===Mb)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=cb.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Sb;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Ib.prototype.onData=function(t){this.chunks.push(t)},Ib.prototype.onEnd=function(t){t===Sb&&(this.result=ub(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ab=function(t,e){let i,n,r,s,o,a,c,h,l,u,d,p,f,m,g,_,v,y,b,x,w,S,M,T;const C=t.state;i=t.next_in,M=t.input,n=i+(t.avail_in-5),r=t.next_out,T=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=C.dmax,c=C.wsize,h=C.whave,l=C.wnext,u=C.window,d=C.hold,p=C.bits,f=C.lencode,m=C.distcode,g=(1<<C.lenbits)-1,_=(1<<C.distbits)-1;t:do{p<15&&(d+=M[i++]<<p,p+=8,d+=M[i++]<<p,p+=8),v=f[d&g];e:for(;;){if(y=v>>>24,d>>>=y,p-=y,y=v>>>16&255,0===y)T[r++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=f[(65535&v)+(d&(1<<y)-1)];continue e}if(32&y){C.mode=12;break t}t.msg="invalid literal/length code",C.mode=30;break t}b=65535&v,y&=15,y&&(p<y&&(d+=M[i++]<<p,p+=8),b+=d&(1<<y)-1,d>>>=y,p-=y),p<15&&(d+=M[i++]<<p,p+=8,d+=M[i++]<<p,p+=8),v=m[d&_];i:for(;;){if(y=v>>>24,d>>>=y,p-=y,y=v>>>16&255,!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<<y)-1)];continue i}t.msg="invalid distance code",C.mode=30;break t}if(x=65535&v,y&=15,p<y&&(d+=M[i++]<<p,p+=8,p<y&&(d+=M[i++]<<p,p+=8)),x+=d&(1<<y)-1,x>a){t.msg="invalid distance too far back",C.mode=30;break t}if(d>>>=y,p-=y,y=r-s,x>y){if(y=x-y,y>h&&C.sane){t.msg="invalid distance too far back",C.mode=30;break t}if(w=0,S=u,0===l){if(w+=c-y,y<b){b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,S=T}}else if(l<y){if(w+=c+l-y,y-=l,y<b){b-=y;do{T[r++]=u[w++]}while(--y);if(w=0,l<b){y=l,b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,S=T}}}else if(w+=l-y,y<b){b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,S=T}for(;b>2;)T[r++]=S[w++],T[r++]=S[w++],T[r++]=S[w++],b-=3;b&&(T[r++]=S[w++],b>1&&(T[r++]=S[w++]))}else{w=r-x;do{T[r++]=T[w++],T[r++]=T[w++],T[r++]=T[w++],b-=3}while(b>2);b&&(T[r++]=T[w++],b>1&&(T[r++]=T[w++]))}break}}break}}while(i<n&&r<o);b=p>>3,i-=b,p-=b<<3,d&=(1<<p)-1,t.next_in=i,t.next_out=r,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=r<o?o-r+257:257-(r-o),C.hold=d,C.bits=p};const Pb=15,Rb=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Lb=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Ob=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Nb=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Db=(t,e,i,n,r,s,o,a)=>{const c=a.bits;let h,l,u,d,p,f,m=0,g=0,_=0,v=0,y=0,b=0,x=0,w=0,S=0,M=0,T=null,C=0;const E=new Uint16Array(16),I=new Uint16Array(16);let A,P,R,L=null,O=0;for(m=0;m<=Pb;m++)E[m]=0;for(g=0;g<n;g++)E[e[i+g]]++;for(y=c,v=Pb;v>=1&&0===E[v];v--);if(y>v&&(y=v),0===v)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(_=1;_<v&&0===E[_];_++);for(y<_&&(y=_),w=1,m=1;m<=Pb;m++)if(w<<=1,w-=E[m],w<0)return-1;if(w>0&&(0===t||1!==v))return-1;for(I[1]=0,m=1;m<Pb;m++)I[m+1]=I[m]+E[m];for(g=0;g<n;g++)0!==e[i+g]&&(o[I[e[i+g]]++]=g);if(0===t?(T=L=o,f=19):1===t?(T=Rb,C-=257,L=Lb,O-=257,f=256):(T=Ob,L=Nb,f=-1),M=0,g=0,m=_,p=s,b=y,x=0,u=-1,S=1<<y,d=S-1,1===t&&S>852||2===t&&S>592)return 1;for(;;){A=m-x,o[g]<f?(P=0,R=o[g]):o[g]>f?(P=L[O+o[g]],R=T[C+o[g]]):(P=96,R=0),h=1<<m-x,l=1<<b,_=l;do{l-=h,r[p+(M>>x)+l]=A<<24|P<<16|R|0}while(0!==l);for(h=1<<m-1;M&h;)h>>=1;if(0!==h?(M&=h-1,M+=h):M=0,g++,0==--E[m]){if(m===v)break;m=e[i+o[g]]}if(m>y&&(M&d)!==u){for(0===x&&(x=y),p+=_,b=m-x,w=1<<b;b+x<v&&(w-=E[b+x],!(w<=0));)b++,w<<=1;if(S+=1<<b,1===t&&S>852||2===t&&S>592)return 1;u=M&d,r[u]=y<<24|b<<16|p-s|0}}return 0!==M&&(r[p+M]=m-x<<24|64<<16|0),a.bits=y,0};const{Z_FINISH:$b,Z_BLOCK:kb,Z_TREES:zb,Z_OK:Fb,Z_STREAM_END:Bb,Z_NEED_DICT:jb,Z_STREAM_ERROR:Hb,Z_DATA_ERROR:Ub,Z_MEM_ERROR:Vb,Z_BUF_ERROR:Gb,Z_DEFLATED:qb}=fy,Wb=12,Xb=30,Yb=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Zb(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Jb=t=>{if(!t||!t.state)return Hb;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Fb},Kb=t=>{if(!t||!t.state)return Hb;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Jb(t)},Qb=(t,e)=>{let i;if(!t||!t.state)return Hb;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Hb:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Kb(t))},tx=(t,e)=>{if(!t)return Hb;const i=new Zb;t.state=i,i.window=null;const n=Qb(t,e);return n!==Fb&&(t.state=null),n};let ex,ix,nx=!0;const rx=t=>{if(nx){ex=new Int32Array(512),ix=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Db(1,t.lens,0,288,ex,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Db(2,t.lens,0,32,ix,0,t.work,{bits:5}),nx=!1}t.lencode=ex,t.lenbits=9,t.distcode=ix,t.distbits=5},sx=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var ox={inflateReset:Kb,inflateReset2:Qb,inflateResetKeep:Jb,inflateInit:t=>tx(t,15),inflateInit2:tx,inflate:(t,e)=>{let i,n,r,s,o,a,c,h,l,u,d,p,f,m,g,_,v,y,b,x,w,S,M=0;const T=new Uint8Array(4);let C,E;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return Hb;i=t.state,i.mode===Wb&&(i.mode=13),o=t.next_out,r=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,l=i.bits,u=a,d=c,S=Fb;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;l<16;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(2&i.wrap&&35615===h){i.check=0,T[0]=255&h,T[1]=h>>>8&255,i.check=dy(i.check,T,2,0),h=0,l=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=Xb;break}if((15&h)!==qb){t.msg="unknown compression method",i.mode=Xb;break}if(h>>>=4,l-=4,w=8+(15&h),0===i.wbits)i.wbits=w;else if(w>i.wbits){t.msg="invalid window size",i.mode=Xb;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&h?10:Wb,h=0,l=0;break;case 2:for(;l<16;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(i.flags=h,(255&i.flags)!==qb){t.msg="unknown compression method",i.mode=Xb;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=Xb;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&(T[0]=255&h,T[1]=h>>>8&255,i.check=dy(i.check,T,2,0)),h=0,l=0,i.mode=3;case 3:for(;l<32;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.head&&(i.head.time=h),512&i.flags&&(T[0]=255&h,T[1]=h>>>8&255,T[2]=h>>>16&255,T[3]=h>>>24&255,i.check=dy(i.check,T,4,0)),h=0,l=0,i.mode=4;case 4:for(;l<16;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&(T[0]=255&h,T[1]=h>>>8&255,i.check=dy(i.check,T,2,0)),h=0,l=0,i.mode=5;case 5:if(1024&i.flags){for(;l<16;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&(T[0]=255&h,T[1]=h>>>8&255,i.check=dy(i.check,T,2,0)),h=0,l=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(p=i.length,p>a&&(p=a),p&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+p),w)),512&i.flags&&(i.check=dy(i.check,n,p,s)),a-=p,s+=p,i.length-=p),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;p=0;do{w=n[s+p++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&p<a);if(512&i.flags&&(i.check=dy(i.check,n,p,s)),a-=p,s+=p,w)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===a)break t;p=0;do{w=n[s+p++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w))}while(w&&p<a);if(512&i.flags&&(i.check=dy(i.check,n,p,s)),a-=p,s+=p,w)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;l<16;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(h!==(65535&i.check)){t.msg="header crc mismatch",i.mode=Xb;break}h=0,l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=Wb;break;case 10:for(;l<32;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}t.adler=i.check=Yb(h),h=0,l=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,i.hold=h,i.bits=l,jb;t.adler=i.check=1,i.mode=Wb;case Wb:if(e===kb||e===zb)break t;case 13:if(i.last){h>>>=7&l,l-=7&l,i.mode=27;break}for(;l<3;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}switch(i.last=1&h,h>>>=1,l-=1,3&h){case 0:i.mode=14;break;case 1:if(rx(i),i.mode=20,e===zb){h>>>=2,l-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=Xb}h>>>=2,l-=2;break;case 14:for(h>>>=7&l,l-=7&l;l<32;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",i.mode=Xb;break}if(i.length=65535&h,h=0,l=0,i.mode=15,e===zb)break t;case 15:i.mode=16;case 16:if(p=i.length,p){if(p>a&&(p=a),p>c&&(p=c),0===p)break t;r.set(n.subarray(s,s+p),o),a-=p,s+=p,c-=p,o+=p,i.length-=p;break}i.mode=Wb;break;case 17:for(;l<14;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(i.nlen=257+(31&h),h>>>=5,l-=5,i.ndist=1+(31&h),h>>>=5,l-=5,i.ncode=4+(15&h),h>>>=4,l-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Xb;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;l<3;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.lens[I[i.have++]]=7&h,h>>>=3,l-=3}for(;i.have<19;)i.lens[I[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,C={bits:i.lenbits},S=Db(0,i.lens,0,19,i.lencode,0,i.work,C),i.lenbits=C.bits,S){t.msg="invalid code lengths set",i.mode=Xb;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;M=i.lencode[h&(1<<i.lenbits)-1],g=M>>>24,_=M>>>16&255,v=65535&M,!(g<=l);){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(v<16)h>>>=g,l-=g,i.lens[i.have++]=v;else{if(16===v){for(E=g+2;l<E;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(h>>>=g,l-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=Xb;break}w=i.lens[i.have-1],p=3+(3&h),h>>>=2,l-=2}else if(17===v){for(E=g+3;l<E;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}h>>>=g,l-=g,w=0,p=3+(7&h),h>>>=3,l-=3}else{for(E=g+7;l<E;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}h>>>=g,l-=g,w=0,p=11+(127&h),h>>>=7,l-=7}if(i.have+p>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Xb;break}for(;p--;)i.lens[i.have++]=w}}if(i.mode===Xb)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Xb;break}if(i.lenbits=9,C={bits:i.lenbits},S=Db(1,i.lens,0,i.nlen,i.lencode,0,i.work,C),i.lenbits=C.bits,S){t.msg="invalid literal/lengths set",i.mode=Xb;break}if(i.distbits=6,i.distcode=i.distdyn,C={bits:i.distbits},S=Db(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,C),i.distbits=C.bits,S){t.msg="invalid distances set",i.mode=Xb;break}if(i.mode=20,e===zb)break t;case 20:i.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,i.hold=h,i.bits=l,Ab(t,d),o=t.next_out,r=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,l=i.bits,i.mode===Wb&&(i.back=-1);break}for(i.back=0;M=i.lencode[h&(1<<i.lenbits)-1],g=M>>>24,_=M>>>16&255,v=65535&M,!(g<=l);){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(_&&0==(240&_)){for(y=g,b=_,x=v;M=i.lencode[x+((h&(1<<y+b)-1)>>y)],g=M>>>24,_=M>>>16&255,v=65535&M,!(y+g<=l);){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}h>>>=y,l-=y,i.back+=y}if(h>>>=g,l-=g,i.back+=g,i.length=v,0===_){i.mode=26;break}if(32&_){i.back=-1,i.mode=Wb;break}if(64&_){t.msg="invalid literal/length code",i.mode=Xb;break}i.extra=15&_,i.mode=22;case 22:if(i.extra){for(E=i.extra;l<E;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;M=i.distcode[h&(1<<i.distbits)-1],g=M>>>24,_=M>>>16&255,v=65535&M,!(g<=l);){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(0==(240&_)){for(y=g,b=_,x=v;M=i.distcode[x+((h&(1<<y+b)-1)>>y)],g=M>>>24,_=M>>>16&255,v=65535&M,!(y+g<=l);){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}h>>>=y,l-=y,i.back+=y}if(h>>>=g,l-=g,i.back+=g,64&_){t.msg="invalid distance code",i.mode=Xb;break}i.offset=v,i.extra=15&_,i.mode=24;case 24:if(i.extra){for(E=i.extra;l<E;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Xb;break}i.mode=25;case 25:if(0===c)break t;if(p=d-c,i.offset>p){if(p=i.offset-p,p>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Xb;break}p>i.wnext?(p-=i.wnext,f=i.wsize-p):f=i.wnext-p,p>i.length&&(p=i.length),m=i.window}else m=r,f=o-i.offset,p=i.length;p>c&&(p=c),c-=p,i.length-=p;do{r[o++]=m[f++]}while(--p);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;l<32;){if(0===a)break t;a--,h|=n[s++]<<l,l+=8}if(d-=c,t.total_out+=d,i.total+=d,d&&(t.adler=i.check=i.flags?dy(i.check,r,d,o-d):ly(i.check,r,d,o-d)),d=c,(i.flags?h:Yb(h))!==i.check){t.msg="incorrect data check",i.mode=Xb;break}h=0,l=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;l<32;){if(0===a)break t;a--,h+=n[s++]<<l,l+=8}if(h!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=Xb;break}h=0,l=0}i.mode=29;case 29:S=Bb;break t;case Xb:S=Ub;break t;case 31:return Vb;case 32:default:return Hb}return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,i.hold=h,i.bits=l,(i.wsize||d!==t.avail_out&&i.mode<Xb&&(i.mode<27||e!==$b))&&sx(t,t.output,t.next_out,d-t.avail_out),u-=t.avail_in,d-=t.avail_out,t.total_in+=u,t.total_out+=d,i.total+=d,i.wrap&&d&&(t.adler=i.check=i.flags?dy(i.check,r,d,t.next_out-d):ly(i.check,r,d,t.next_out-d)),t.data_type=i.bits+(i.last?64:0)+(i.mode===Wb?128:0)+(20===i.mode||15===i.mode?256:0),(0===u&&0===d||e===$b)&&S===Fb&&(S=Gb),S},inflateEnd:t=>{if(!t||!t.state)return Hb;let e=t.state;return e.window&&(e.window=null),t.state=null,Fb},inflateGetHeader:(t,e)=>{if(!t||!t.state)return Hb;const i=t.state;return 0==(2&i.wrap)?Hb:(i.head=e,e.done=!1,Fb)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?Hb:11===n.mode&&(r=1,r=ly(r,e,i,0),r!==n.check)?Ub:(s=sx(t,e,i,i),s?(n.mode=31,Vb):(n.havedict=1,Fb))):Hb},inflateInfo:"pako inflate (from Nodeca project)"};var ax=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const cx=Object.prototype.toString,{Z_NO_FLUSH:hx,Z_FINISH:lx,Z_OK:ux,Z_STREAM_END:dx,Z_NEED_DICT:px,Z_STREAM_ERROR:fx,Z_DATA_ERROR:mx,Z_MEM_ERROR:gx}=fy;function _x(t){this.options=lb({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _b,this.strm.avail_out=0;let i=ox.inflateInit2(this.strm,e.windowBits);if(i!==ux)throw new Error(py[i]);if(this.header=new ax,ox.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=fb(e.dictionary):"[object ArrayBuffer]"===cx.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=ox.inflateSetDictionary(this.strm,e.dictionary),i!==ux)))throw new Error(py[i])}function vx(t,e){const i=new _x(e);if(i.push(t),i.err)throw i.msg||py[i.err];return i.result}_x.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?lx:hx,"[object ArrayBuffer]"===cx.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=ox.inflate(i,o),s===px&&r&&(s=ox.inflateSetDictionary(i,r),s===ux?s=ox.inflate(i,o):s===mx&&(s=px));i.avail_in>0&&s===dx&&i.state.wrap>0&&0!==t[i.next_in];)ox.inflateReset(i),s=ox.inflate(i,o);switch(s){case fx:case mx:case px:case gx:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===dx))if("string"===this.options.to){let t=gb(i.output,i.next_out),e=i.next_out-t,r=mb(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==ux||0!==a){if(s===dx)return s=ox.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},_x.prototype.onData=function(t){this.chunks.push(t)},_x.prototype.onEnd=function(t){t===ux&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=ub(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var yx={Inflate:_x,inflate:vx,inflateRaw:function(t,e){return(e=e||{}).raw=!0,vx(t,e)},ungzip:vx,constants:fy};const{Inflate:bx,inflate:xx,inflateRaw:wx,ungzip:Sx}=yx;var Mx=xx,Tx=function(t,e,i,n,r){var s,o,a=8*r-n-1,c=(1<<a)-1,h=c>>1,l=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=256*s+t[e+u],u+=d,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+u],u+=d,l-=8);if(0===s)s=1-h;else{if(s===c)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=h}return(p?-1:1)*o*Math.pow(2,s-n)},Cx=function(t,e,i,n,r,s){var o,a,c,h=8*s-r-1,l=(1<<h)-1,u=l>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,f=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+u>=1?d/c:d*Math.pow(2,1-u))*c>=2&&(o++,c/=2),o+u>=l?(a=0,o=l):o+u>=1?(a=(e*c-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+p]=255&o,p+=f,o/=256,h-=8);t[i+p-f]|=128*m},Ex=Ix;