var mapsindoors=(()=>{var B_=Object.create;var _o=Object.defineProperty;var k_=Object.getOwnPropertyDescriptor;var z_=Object.getOwnPropertyNames;var V_=Object.getPrototypeOf,H_=Object.prototype.hasOwnProperty;var G_=(i,e,t)=>e in i?_o(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var W_=(i,e)=>()=>(i&&(e=i(i=0)),e);var bn=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),em=(i,e)=>{for(var t in e)_o(i,t,{get:e[t],enumerable:!0})},tm=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of z_(e))!H_.call(i,s)&&s!==t&&_o(i,s,{get:()=>e[s],enumerable:!(n=k_(e,s))||n.enumerable});return i};var Jt=(i,e,t)=>(t=i!=null?B_(V_(i)):{},tm(e||!i||!i.__esModule?_o(t,"default",{value:i,enumerable:!0}):t,i)),X_=i=>tm(_o({},"__esModule",{value:!0}),i);var fi=(i,e,t)=>(G_(i,typeof e!="symbol"?e+"":e,t),t),dh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Mn=(i,e,t)=>(dh(i,e,"read from private field"),t?t.call(i):e.get(i)),di=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},nm=(i,e,t,n)=>(dh(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var ph=(i,e,t)=>(dh(i,e,"access private method"),t);var Y,E=W_(()=>{Y=["https://api.mapsindoors.com"]});var im=bn(Da=>{"use strict";E();Object.defineProperty(Da,"__esModule",{value:!0});Da.storageFactory=void 0;function Y_(i){var e={};function t(){try{var c="__some_random_key_you_are_not_going_to_use__";return i().setItem(c,c),i().removeItem(c),!0}catch{return!1}}function n(){t()?i().clear():e={}}function s(c){return t()?i().getItem(c):e.hasOwnProperty(c)?e[c]:null}function r(c){return t()?i().key(c):Object.keys(e)[c]||null}function o(c){t()?i().removeItem(c):delete e[c]}function a(c,h){t()?i().setItem(c,h):e[c]=String(h)}function l(){return t()?i().length:Object.keys(e).length}return{getItem:s,setItem:a,removeItem:o,clear:n,key:r,get length(){return l()}}}Da.storageFactory=Y_});var Sn=bn((jT,mh)=>{"use strict";E();var lr=typeof Reflect=="object"?Reflect:null,sm=lr&&typeof lr.apply=="function"?lr.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},Ua;lr&&typeof lr.ownKeys=="function"?Ua=lr.ownKeys:Object.getOwnPropertySymbols?Ua=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ua=function(e){return Object.getOwnPropertyNames(e)};function K_(i){console&&console.warn&&console.warn(i)}var om=Number.isNaN||function(e){return e!==e};function ht(){ht.init.call(this)}mh.exports=ht;mh.exports.once=j_;ht.EventEmitter=ht;ht.prototype._events=void 0;ht.prototype._eventsCount=0;ht.prototype._maxListeners=void 0;var rm=10;function Fa(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(ht,"defaultMaxListeners",{enumerable:!0,get:function(){return rm},set:function(i){if(typeof i!="number"||i<0||om(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");rm=i}});ht.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ht.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||om(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function am(i){return i._maxListeners===void 0?ht.defaultMaxListeners:i._maxListeners}ht.prototype.getMaxListeners=function(){return am(this)};ht.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var s=e==="error",r=this._events;if(r!==void 0)s=s&&r.error===void 0;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=r[e];if(l===void 0)return!1;if(typeof l=="function")sm(l,this,t);else for(var c=l.length,h=fm(l,c),n=0;n<c;++n)sm(h[n],this,t);return!0};function lm(i,e,t,n){var s,r,o;if(Fa(t),r=i._events,r===void 0?(r=i._events=Object.create(null),i._eventsCount=0):(r.newListener!==void 0&&(i.emit("newListener",e,t.listener?t.listener:t),r=i._events),o=r[e]),o===void 0)o=r[e]=t,++i._eventsCount;else if(typeof o=="function"?o=r[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),s=am(i),s>0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,K_(a)}return i}ht.prototype.addListener=function(e,t){return lm(this,e,t,!1)};ht.prototype.on=ht.prototype.addListener;ht.prototype.prependListener=function(e,t){return lm(this,e,t,!0)};function Z_(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function cm(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},s=Z_.bind(n);return s.listener=t,n.wrapFn=s,s}ht.prototype.once=function(e,t){return Fa(t),this.on(e,cm(this,e,t)),this};ht.prototype.prependOnceListener=function(e,t){return Fa(t),this.prependListener(e,cm(this,e,t)),this};ht.prototype.removeListener=function(e,t){var n,s,r,o,a;if(Fa(t),s=this._events,s===void 0)return this;if(n=s[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,r=o;break}if(r<0)return this;r===0?n.shift():$_(n,r),n.length===1&&(s[e]=n[0]),s.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};ht.prototype.off=ht.prototype.removeListener;ht.prototype.removeAllListeners=function(e){var t,n,s;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var r=Object.keys(n),o;for(s=0;s<r.length;++s)o=r[s],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this};function hm(i,e,t){var n=i._events;if(n===void 0)return[];var s=n[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?J_(s):fm(s,s.length)}ht.prototype.listeners=function(e){return hm(this,e,!0)};ht.prototype.rawListeners=function(e){return hm(this,e,!1)};ht.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):um.call(i,e)};ht.prototype.listenerCount=um;function um(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}ht.prototype.eventNames=function(){return this._eventsCount>0?Ua(this._events):[]};function fm(i,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=i[n];return t}function $_(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function J_(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}function j_(i,e){return new Promise(function(t,n){function s(o){i.removeListener(e,r),n(o)}function r(){typeof i.removeListener=="function"&&i.removeListener("error",s),t([].slice.call(arguments))}dm(i,e,r,{once:!0}),e!=="error"&&Q_(i,s,{once:!0})})}function Q_(i,e,t){typeof i.on=="function"&&dm(i,"error",e,t)}function dm(i,e,t,n){if(typeof i.on=="function")n.once?i.once(e,t):i.on(e,t);else if(typeof i.addEventListener=="function")i.addEventListener(e,function s(r){n.once&&i.removeEventListener(e,s),t(r)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var Hm=bn((Eo,Yh)=>{E();(function(e,t){typeof Eo=="object"&&typeof Yh=="object"?Yh.exports=t():typeof define=="function"&&define.amd?define(t):typeof Eo=="object"?Eo=t():e.Paho=t()})(Eo,function(){var e=function(t){var n="@VERSION@-@BUILDLEVEL@",s=t.localStorage||function(){var _={};return{setItem:function(x,T){_[x]=T},getItem:function(x){return _[x]},removeItem:function(x){delete _[x]}}}(),r={CONNECT:1,CONNACK:2,PUBLISH:3,PUBACK:4,PUBREC:5,PUBREL:6,PUBCOMP:7,SUBSCRIBE:8,SUBACK:9,UNSUBSCRIBE:10,UNSUBACK:11,PINGREQ:12,PINGRESP:13,DISCONNECT:14},o=function(_,x){for(var T in _)if(_.hasOwnProperty(T))if(x.hasOwnProperty(T)){if(typeof _[T]!==x[T])throw new Error(h(l.INVALID_TYPE,[typeof _[T],T]))}else{var P="Unknown property, "+T+". Valid properties are:";for(var U in x)x.hasOwnProperty(U)&&(P=P+" "+U);throw new Error(P)}},a=function(_,x){return function(){return _.apply(x,arguments)}},l={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."},BUFFER_FULL:{code:18,text:"AMQJS0018E Message buffer is full, maximum buffer size: {0}."}},c={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},h=function(_,x){var T=_.text;if(x){for(var P,U,N=0;N<x.length;N++)if(P="{"+N+"}",U=T.indexOf(P),U>0){var H=T.substring(0,U),G=T.substring(U+P.length);T=H+x[N]+G}}return T},u=[0,6,77,81,73,115,100,112,3],f=[0,4,77,81,84,84,4],d=function(_,x){this.type=_;for(var T in x)x.hasOwnProperty(T)&&(this[T]=x[T])};d.prototype.encode=function(){var _=(this.type&15)<<4,x=0,T=[],P=0,U;switch(this.messageIdentifier!==void 0&&(x+=2),this.type){case r.CONNECT:switch(this.mqttVersion){case 3:x+=u.length+3;break;case 4:x+=f.length+3;break}x+=b(this.clientId)+2,this.willMessage!==void 0&&(x+=b(this.willMessage.destinationName)+2,U=this.willMessage.payloadBytes,U instanceof Uint8Array||(U=new Uint8Array(H)),x+=U.byteLength+2),this.userName!==void 0&&(x+=b(this.userName)+2),this.password!==void 0&&(x+=b(this.password)+2);break;case r.SUBSCRIBE:_|=2;for(var N=0;N<this.topics.length;N++)T[N]=b(this.topics[N]),x+=T[N]+2;x+=this.requestedQos.length;break;case r.UNSUBSCRIBE:_|=2;for(var N=0;N<this.topics.length;N++)T[N]=b(this.topics[N]),x+=T[N]+2;break;case r.PUBREL:_|=2;break;case r.PUBLISH:this.payloadMessage.duplicate&&(_|=8),_=_|=this.payloadMessage.qos<<1,this.payloadMessage.retained&&(_|=1),P=b(this.payloadMessage.destinationName),x+=P+2;var H=this.payloadMessage.payloadBytes;x+=H.byteLength,H instanceof ArrayBuffer?H=new Uint8Array(H):H instanceof Uint8Array||(H=new Uint8Array(H.buffer));break;case r.DISCONNECT:break;default:break}var G=M(x),$=G.length+1,re=new ArrayBuffer(x+$),J=new Uint8Array(re);if(J[0]=_,J.set(G,1),this.type==r.PUBLISH)$=p(this.payloadMessage.destinationName,P,J,$);else if(this.type==r.CONNECT){switch(this.mqttVersion){case 3:J.set(u,$),$+=u.length;break;case 4:J.set(f,$),$+=f.length;break}var V=0;this.cleanSession&&(V=2),this.willMessage!==void 0&&(V|=4,V|=this.willMessage.qos<<3,this.willMessage.retained&&(V|=32)),this.userName!==void 0&&(V|=128),this.password!==void 0&&(V|=64),J[$++]=V,$=g(this.keepAliveInterval,J,$)}switch(this.messageIdentifier!==void 0&&($=g(this.messageIdentifier,J,$)),this.type){case r.CONNECT:$=p(this.clientId,b(this.clientId),J,$),this.willMessage!==void 0&&($=p(this.willMessage.destinationName,b(this.willMessage.destinationName),J,$),$=g(U.byteLength,J,$),J.set(U,$),$+=U.byteLength),this.userName!==void 0&&($=p(this.userName,b(this.userName),J,$)),this.password!==void 0&&($=p(this.password,b(this.password),J,$));break;case r.PUBLISH:J.set(H,$);break;case r.SUBSCRIBE:for(var N=0;N<this.topics.length;N++)$=p(this.topics[N],T[N],J,$),J[$++]=this.requestedQos[N];break;case r.UNSUBSCRIBE:for(var N=0;N<this.topics.length;N++)$=p(this.topics[N],T[N],J,$);break;default:}return re};function y(_,x){var T=x,P=_[x],U=P>>4,N=P&=15;x+=1;var H,G=0,$=1;do{if(x==_.length)return[null,T];H=_[x++],G+=(H&127)*$,$*=128}while((H&128)!==0);var re=x+G;if(re>_.length)return[null,T];var J=new d(U);switch(U){case r.CONNACK:var V=_[x++];V&1&&(J.sessionPresent=!0),J.returnCode=_[x++];break;case r.PUBLISH:var xe=N>>1&3,X=m(_,x);x+=2;var ne=O(_,x,X);x+=X,xe>0&&(J.messageIdentifier=m(_,x),x+=2);var oe=new v(_.subarray(x,re));(N&1)==1&&(oe.retained=!0),(N&8)==8&&(oe.duplicate=!0),oe.qos=xe,oe.destinationName=ne,J.payloadMessage=oe;break;case r.PUBACK:case r.PUBREC:case r.PUBREL:case r.PUBCOMP:case r.UNSUBACK:J.messageIdentifier=m(_,x);break;case r.SUBACK:J.messageIdentifier=m(_,x),x+=2,J.returnCode=_.subarray(x,re);break;default:break}return[J,re]}function g(_,x,T){return x[T++]=_>>8,x[T++]=_%256,T}function p(_,x,T,P){return P=g(x,T,P),S(_,T,P),P+x}function m(_,x){return 256*_[x]+_[x+1]}function M(_){var x=new Array(1),T=0;do{var P=_%128;_=_>>7,_>0&&(P|=128),x[T++]=P}while(_>0&&T<4);return x}function b(_){for(var x=0,T=0;T<_.length;T++){var P=_.charCodeAt(T);P>2047?(55296<=P&&P<=56319&&(T++,x++),x+=3):P>127?x+=2:x++}return x}function S(_,x,T){for(var P=T,U=0;U<_.length;U++){var N=_.charCodeAt(U);if(55296<=N&&N<=56319){var H=_.charCodeAt(++U);if(isNaN(H))throw new Error(h(l.MALFORMED_UNICODE,[N,H]));N=(N-55296<<10)+(H-56320)+65536}N<=127?x[P++]=N:N<=2047?(x[P++]=N>>6&31|192,x[P++]=N&63|128):N<=65535?(x[P++]=N>>12&15|224,x[P++]=N>>6&63|128,x[P++]=N&63|128):(x[P++]=N>>18&7|240,x[P++]=N>>12&63|128,x[P++]=N>>6&63|128,x[P++]=N&63|128)}return x}function O(_,x,T){for(var P="",U,N=x;N<x+T;){var H=_[N++];if(H<128)U=H;else{var G=_[N++]-128;if(G<0)throw new Error(h(l.MALFORMED_UTF,[H.toString(16),G.toString(16),""]));if(H<224)U=64*(H-192)+G;else{var $=_[N++]-128;if($<0)throw new Error(h(l.MALFORMED_UTF,[H.toString(16),G.toString(16),$.toString(16)]));if(H<240)U=4096*(H-224)+64*G+$;else{var re=_[N++]-128;if(re<0)throw new Error(h(l.MALFORMED_UTF,[H.toString(16),G.toString(16),$.toString(16),re.toString(16)]));if(H<248)U=262144*(H-240)+4096*G+64*$+re;else throw new Error(h(l.MALFORMED_UTF,[H.toString(16),G.toString(16),$.toString(16),re.toString(16)]))}}}U>65535&&(U-=65536,P+=String.fromCharCode(55296+(U>>10)),U=56320+(U&1023)),P+=String.fromCharCode(U)}return P}var L=function(_,x){this._client=_,this._keepAliveInterval=x*1e3,this.isReset=!1;var T=new d(r.PINGREQ).encode(),P=function(N){return function(){return U.apply(N)}},U=function(){this.isReset?(this.isReset=!1,this._client._trace("Pinger.doPing","send PINGREQ"),this._client.socket.send(T),this.timeout=setTimeout(P(this),this._keepAliveInterval)):(this._client._trace("Pinger.doPing","Timed out"),this._client._disconnected(l.PING_TIMEOUT.code,h(l.PING_TIMEOUT)))};this.reset=function(){this.isReset=!0,clearTimeout(this.timeout),this._keepAliveInterval>0&&(this.timeout=setTimeout(P(this),this._keepAliveInterval))},this.cancel=function(){clearTimeout(this.timeout)}},R=function(_,x,T,P){x||(x=30);var U=function(N,H,G){return function(){return N.apply(H,G)}};this.timeout=setTimeout(U(T,_,P),x*1e3),this.cancel=function(){clearTimeout(this.timeout)}},C=function(_,x,T,P,U){if(!("WebSocket"in t&&t.WebSocket!==null))throw new Error(h(l.UNSUPPORTED,["WebSocket"]));if(!("ArrayBuffer"in t&&t.ArrayBuffer!==null))throw new Error(h(l.UNSUPPORTED,["ArrayBuffer"]));this._trace("Paho.Client",_,x,T,P,U),this.host=x,this.port=T,this.path=P,this.uri=_,this.clientId=U,this._wsuri=null,this._localKey=x+":"+T+(P!="/mqtt"?":"+P:"")+":"+U+":",this._msg_queue=[],this._buffered_msg_queue=[],this._sentMessages={},this._receivedMessages={},this._notify_msg_sent={},this._message_identifier=1,this._sequence=0;for(var N in s)(N.indexOf("Sent:"+this._localKey)===0||N.indexOf("Received:"+this._localKey)===0)&&this.restore(N)};C.prototype.host=null,C.prototype.port=null,C.prototype.path=null,C.prototype.uri=null,C.prototype.clientId=null,C.prototype.socket=null,C.prototype.connected=!1,C.prototype.maxMessageIdentifier=65536,C.prototype.connectOptions=null,C.prototype.hostIndex=null,C.prototype.onConnected=null,C.prototype.onConnectionLost=null,C.prototype.onMessageDelivered=null,C.prototype.onMessageArrived=null,C.prototype.traceFunction=null,C.prototype._msg_queue=null,C.prototype._buffered_msg_queue=null,C.prototype._connectTimeout=null,C.prototype.sendPinger=null,C.prototype.receivePinger=null,C.prototype._reconnectInterval=1,C.prototype._reconnecting=!1,C.prototype._reconnectTimeout=null,C.prototype.disconnectedPublishing=!1,C.prototype.disconnectedBufferSize=5e3,C.prototype.receiveBuffer=null,C.prototype._traceBuffer=null,C.prototype._MAX_TRACE_ENTRIES=100,C.prototype.connect=function(_){var x=this._traceMask(_,"password");if(this._trace("Client.connect",x,this.socket,this.connected),this.connected)throw new Error(h(l.INVALID_STATE,["already connected"]));if(this.socket)throw new Error(h(l.INVALID_STATE,["already connected"]));this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),this.connectOptions=_,this._reconnectInterval=1,this._reconnecting=!1,_.uris?(this.hostIndex=0,this._doConnect(_.uris[0])):this._doConnect(this.uri)},C.prototype.subscribe=function(_,x){if(this._trace("Client.subscribe",_,x),!this.connected)throw new Error(h(l.INVALID_STATE,["not connected"]));var T=new d(r.SUBSCRIBE);T.topics=_.constructor===Array?_:[_],x.qos===void 0&&(x.qos=0),T.requestedQos=[];for(var P=0;P<T.topics.length;P++)T.requestedQos[P]=x.qos;x.onSuccess&&(T.onSuccess=function(U){x.onSuccess({invocationContext:x.invocationContext,grantedQos:U})}),x.onFailure&&(T.onFailure=function(U){x.onFailure({invocationContext:x.invocationContext,errorCode:U,errorMessage:h(U)})}),x.timeout&&(T.timeOut=new R(this,x.timeout,x.onFailure,[{invocationContext:x.invocationContext,errorCode:l.SUBSCRIBE_TIMEOUT.code,errorMessage:h(l.SUBSCRIBE_TIMEOUT)}])),this._requires_ack(T),this._schedule_message(T)},C.prototype.unsubscribe=function(_,x){if(this._trace("Client.unsubscribe",_,x),!this.connected)throw new Error(h(l.INVALID_STATE,["not connected"]));var T=new d(r.UNSUBSCRIBE);T.topics=_.constructor===Array?_:[_],x.onSuccess&&(T.callback=function(){x.onSuccess({invocationContext:x.invocationContext})}),x.timeout&&(T.timeOut=new R(this,x.timeout,x.onFailure,[{invocationContext:x.invocationContext,errorCode:l.UNSUBSCRIBE_TIMEOUT.code,errorMessage:h(l.UNSUBSCRIBE_TIMEOUT)}])),this._requires_ack(T),this._schedule_message(T)},C.prototype.send=function(_){this._trace("Client.send",_);var x=new d(r.PUBLISH);if(x.payloadMessage=_,this.connected)_.qos>0?this._requires_ack(x):this.onMessageDelivered&&(this._notify_msg_sent[x]=this.onMessageDelivered(x.payloadMessage)),this._schedule_message(x);else if(this._reconnecting&&this.disconnectedPublishing){var T=Object.keys(this._sentMessages).length+this._buffered_msg_queue.length;if(T>this.disconnectedBufferSize)throw new Error(h(l.BUFFER_FULL,[this.disconnectedBufferSize]));_.qos>0?this._requires_ack(x):(x.sequence=++this._sequence,this._buffered_msg_queue.unshift(x))}else throw new Error(h(l.INVALID_STATE,["not connected"]))},C.prototype.disconnect=function(){if(this._trace("Client.disconnect"),this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),!this.socket)throw new Error(h(l.INVALID_STATE,["not connecting or connected"]));var _=new d(r.DISCONNECT);this._notify_msg_sent[_]=a(this._disconnected,this),this._schedule_message(_)},C.prototype.getTraceLog=function(){if(this._traceBuffer!==null){this._trace("Client.getTraceLog",new Date),this._trace("Client.getTraceLog in flight messages",this._sentMessages.length);for(var _ in this._sentMessages)this._trace("_sentMessages ",_,this._sentMessages[_]);for(var _ in this._receivedMessages)this._trace("_receivedMessages ",_,this._receivedMessages[_]);return this._traceBuffer}},C.prototype.startTrace=function(){this._traceBuffer===null&&(this._traceBuffer=[]),this._trace("Client.startTrace",new Date,n)},C.prototype.stopTrace=function(){delete this._traceBuffer},C.prototype._doConnect=function(_){if(this.connectOptions.useSSL){var x=_.split(":");x[0]="wss",_=x.join(":")}this._wsuri=_,this.connected=!1,this.connectOptions.mqttVersion<4?this.socket=new WebSocket(_,["mqttv3.1"]):this.socket=new WebSocket(_,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=a(this._on_socket_open,this),this.socket.onmessage=a(this._on_socket_message,this),this.socket.onerror=a(this._on_socket_error,this),this.socket.onclose=a(this._on_socket_close,this),this.sendPinger=new L(this,this.connectOptions.keepAliveInterval),this.receivePinger=new L(this,this.connectOptions.keepAliveInterval),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._connectTimeout=new R(this,this.connectOptions.timeout,this._disconnected,[l.CONNECT_TIMEOUT.code,h(l.CONNECT_TIMEOUT)])},C.prototype._schedule_message=function(_){this._msg_queue.unshift(_),this.connected&&this._process_queue()},C.prototype.store=function(_,x){var T={type:x.type,messageIdentifier:x.messageIdentifier,version:1};switch(x.type){case r.PUBLISH:x.pubRecReceived&&(T.pubRecReceived=!0),T.payloadMessage={};for(var P="",U=x.payloadMessage.payloadBytes,N=0;N<U.length;N++)U[N]<=15?P=P+"0"+U[N].toString(16):P=P+U[N].toString(16);T.payloadMessage.payloadHex=P,T.payloadMessage.qos=x.payloadMessage.qos,T.payloadMessage.destinationName=x.payloadMessage.destinationName,x.payloadMessage.duplicate&&(T.payloadMessage.duplicate=!0),x.payloadMessage.retained&&(T.payloadMessage.retained=!0),_.indexOf("Sent:")===0&&(x.sequence===void 0&&(x.sequence=++this._sequence),T.sequence=x.sequence);break;default:throw Error(h(l.INVALID_STORED_DATA,[_+this._localKey+x.messageIdentifier,T]))}s.setItem(_+this._localKey+x.messageIdentifier,JSON.stringify(T))},C.prototype.restore=function(_){var x=s.getItem(_),T=JSON.parse(x),P=new d(T.type,T);switch(T.type){case r.PUBLISH:for(var U=T.payloadMessage.payloadHex,N=new ArrayBuffer(U.length/2),H=new Uint8Array(N),G=0;U.length>=2;){var $=parseInt(U.substring(0,2),16);U=U.substring(2,U.length),H[G++]=$}var re=new v(H);re.qos=T.payloadMessage.qos,re.destinationName=T.payloadMessage.destinationName,T.payloadMessage.duplicate&&(re.duplicate=!0),T.payloadMessage.retained&&(re.retained=!0),P.payloadMessage=re;break;default:throw Error(h(l.INVALID_STORED_DATA,[_,x]))}_.indexOf("Sent:"+this._localKey)===0?(P.payloadMessage.duplicate=!0,this._sentMessages[P.messageIdentifier]=P):_.indexOf("Received:"+this._localKey)===0&&(this._receivedMessages[P.messageIdentifier]=P)},C.prototype._process_queue=function(){for(var _=null;_=this._msg_queue.pop();)this._socket_send(_),this._notify_msg_sent[_]&&(this._notify_msg_sent[_](),delete this._notify_msg_sent[_])},C.prototype._requires_ack=function(_){var x=Object.keys(this._sentMessages).length;if(x>this.maxMessageIdentifier)throw Error("Too many messages:"+x);for(;this._sentMessages[this._message_identifier]!==void 0;)this._message_identifier++;_.messageIdentifier=this._message_identifier,this._sentMessages[_.messageIdentifier]=_,_.type===r.PUBLISH&&this.store("Sent:",_),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},C.prototype._on_socket_open=function(){var _=new d(r.CONNECT,this.connectOptions);_.clientId=this.clientId,this._socket_send(_)},C.prototype._on_socket_message=function(_){this._trace("Client._on_socket_message",_.data);for(var x=this._deframeMessages(_.data),T=0;T<x.length;T+=1)this._handleMessage(x[T])},C.prototype._deframeMessages=function(_){var x=new Uint8Array(_),T=[];if(this.receiveBuffer){var P=new Uint8Array(this.receiveBuffer.length+x.length);P.set(this.receiveBuffer),P.set(x,this.receiveBuffer.length),x=P,delete this.receiveBuffer}try{for(var U=0;U<x.length;){var N=y(x,U),H=N[0];if(U=N[1],H!==null)T.push(H);else break}U<x.length&&(this.receiveBuffer=x.subarray(U))}catch($){var G=$.hasOwnProperty("stack")=="undefined"?$.stack.toString():"No Error Stack Available";this._disconnected(l.INTERNAL_ERROR.code,h(l.INTERNAL_ERROR,[$.message,G]));return}return T},C.prototype._handleMessage=function(_){this._trace("Client._handleMessage",_);try{switch(_.type){case r.CONNACK:if(this._connectTimeout.cancel(),this._reconnectTimeout&&this._reconnectTimeout.cancel(),this.connectOptions.cleanSession){for(var x in this._sentMessages){var V=this._sentMessages[x];s.removeItem("Sent:"+this._localKey+V.messageIdentifier)}this._sentMessages={};for(var x in this._receivedMessages){var re=this._receivedMessages[x];s.removeItem("Received:"+this._localKey+re.messageIdentifier)}this._receivedMessages={}}if(_.returnCode===0)this.connected=!0,this.connectOptions.uris&&(this.hostIndex=this.connectOptions.uris.length);else{this._disconnected(l.CONNACK_RETURNCODE.code,h(l.CONNACK_RETURNCODE,[_.returnCode,c[_.returnCode]]));break}var U=[];for(var T in this._sentMessages)this._sentMessages.hasOwnProperty(T)&&U.push(this._sentMessages[T]);if(this._buffered_msg_queue.length>0)for(var P=null;P=this._buffered_msg_queue.pop();)U.push(P),this.onMessageDelivered&&(this._notify_msg_sent[P]=this.onMessageDelivered(P.payloadMessage));for(var U=U.sort(function(X,ne){return X.sequence-ne.sequence}),N=0,H=U.length;N<H;N++){var V=U[N];if(V.type==r.PUBLISH&&V.pubRecReceived){var G=new d(r.PUBREL,{messageIdentifier:V.messageIdentifier});this._schedule_message(G)}else this._schedule_message(V)}this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext});var $=!1;this._reconnecting&&($=!0,this._reconnectInterval=1,this._reconnecting=!1),this._connected($,this._wsuri),this._process_queue();break;case r.PUBLISH:this._receivePublish(_);break;case r.PUBACK:var V=this._sentMessages[_.messageIdentifier];V&&(delete this._sentMessages[_.messageIdentifier],s.removeItem("Sent:"+this._localKey+_.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(V.payloadMessage));break;case r.PUBREC:var V=this._sentMessages[_.messageIdentifier];if(V){V.pubRecReceived=!0;var G=new d(r.PUBREL,{messageIdentifier:_.messageIdentifier});this.store("Sent:",V),this._schedule_message(G)}break;case r.PUBREL:var re=this._receivedMessages[_.messageIdentifier];s.removeItem("Received:"+this._localKey+_.messageIdentifier),re&&(this._receiveMessage(re),delete this._receivedMessages[_.messageIdentifier]);var J=new d(r.PUBCOMP,{messageIdentifier:_.messageIdentifier});this._schedule_message(J);break;case r.PUBCOMP:var V=this._sentMessages[_.messageIdentifier];delete this._sentMessages[_.messageIdentifier],s.removeItem("Sent:"+this._localKey+_.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(V.payloadMessage);break;case r.SUBACK:var V=this._sentMessages[_.messageIdentifier];V&&(V.timeOut&&V.timeOut.cancel(),_.returnCode[0]===128?V.onFailure&&V.onFailure(_.returnCode):V.onSuccess&&V.onSuccess(_.returnCode),delete this._sentMessages[_.messageIdentifier]);break;case r.UNSUBACK:var V=this._sentMessages[_.messageIdentifier];V&&(V.timeOut&&V.timeOut.cancel(),V.callback&&V.callback(),delete this._sentMessages[_.messageIdentifier]);break;case r.PINGRESP:this.sendPinger.reset();break;case r.DISCONNECT:this._disconnected(l.INVALID_MQTT_MESSAGE_TYPE.code,h(l.INVALID_MQTT_MESSAGE_TYPE,[_.type]));break;default:this._disconnected(l.INVALID_MQTT_MESSAGE_TYPE.code,h(l.INVALID_MQTT_MESSAGE_TYPE,[_.type]))}}catch(X){var xe=X.hasOwnProperty("stack")=="undefined"?X.stack.toString():"No Error Stack Available";this._disconnected(l.INTERNAL_ERROR.code,h(l.INTERNAL_ERROR,[X.message,xe]));return}},C.prototype._on_socket_error=function(_){this._reconnecting||this._disconnected(l.SOCKET_ERROR.code,h(l.SOCKET_ERROR,[_.data]))},C.prototype._on_socket_close=function(){this._reconnecting||this._disconnected(l.SOCKET_CLOSE.code,h(l.SOCKET_CLOSE))},C.prototype._socket_send=function(_){if(_.type==1){var x=this._traceMask(_,"password");this._trace("Client._socket_send",x)}else this._trace("Client._socket_send",_);this.socket.send(_.encode()),this.sendPinger.reset()},C.prototype._receivePublish=function(_){switch(_.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(_);break;case 1:var x=new d(r.PUBACK,{messageIdentifier:_.messageIdentifier});this._schedule_message(x),this._receiveMessage(_);break;case 2:this._receivedMessages[_.messageIdentifier]=_,this.store("Received:",_);var T=new d(r.PUBREC,{messageIdentifier:_.messageIdentifier});this._schedule_message(T);break;default:throw Error("Invaild qos="+_.payloadMessage.qos)}},C.prototype._receiveMessage=function(_){this.onMessageArrived&&this.onMessageArrived(_.payloadMessage)},C.prototype._connected=function(_,x){this.onConnected&&this.onConnected(_,x)},C.prototype._reconnect=function(){this._trace("Client._reconnect"),this.connected||(this._reconnecting=!0,this.sendPinger.cancel(),this.receivePinger.cancel(),this._reconnectInterval<128&&(this._reconnectInterval=this._reconnectInterval*2),this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri))},C.prototype._disconnected=function(_,x){if(this._trace("Client._disconnected",_,x),_!==void 0&&this._reconnecting){this._reconnectTimeout=new R(this,this._reconnectInterval,this._reconnect);return}if(this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._msg_queue=[],this._buffered_msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.readyState===1&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndex<this.connectOptions.uris.length-1)this.hostIndex++,this._doConnect(this.connectOptions.uris[this.hostIndex]);else if(_===void 0&&(_=l.OK.code,x=h(l.OK)),this.connected){if(this.connected=!1,this.onConnectionLost&&this.onConnectionLost({errorCode:_,errorMessage:x,reconnect:this.connectOptions.reconnect,uri:this._wsuri}),_!==l.OK.code&&this.connectOptions.reconnect){this._reconnectInterval=1,this._reconnect();return}}else this.connectOptions.mqttVersion===4&&this.connectOptions.mqttVersionExplicit===!1?(this._trace("Failed to connect V4, dropping back to V3"),this.connectOptions.mqttVersion=3,this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri)):this.connectOptions.onFailure&&this.connectOptions.onFailure({invocationContext:this.connectOptions.invocationContext,errorCode:_,errorMessage:x})},C.prototype._trace=function(){if(this.traceFunction){var _=Array.prototype.slice.call(arguments);for(var x in _)typeof _[x]<"u"&&_.splice(x,1,JSON.stringify(_[x]));var T=_.join("");this.traceFunction({severity:"Debug",message:T})}if(this._traceBuffer!==null)for(var x=0,P=arguments.length;x<P;x++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),x===0?this._traceBuffer.push(arguments[x]):typeof arguments[x]>"u"?this._traceBuffer.push(arguments[x]):this._traceBuffer.push("  "+JSON.stringify(arguments[x]))},C.prototype._traceMask=function(_,x){var T={};for(var P in _)_.hasOwnProperty(P)&&(P==x?T[P]="******":T[P]=_[P]);return T};var j=function(_,x,T,P){var U;if(typeof _!="string")throw new Error(h(l.INVALID_TYPE,[typeof _,"host"]));if(arguments.length==2){P=x,U=_;var N=U.match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(N)_=N[4]||N[2],x=parseInt(N[7]),T=N[8];else throw new Error(h(l.INVALID_ARGUMENT,[_,"host"]))}else{if(arguments.length==3&&(P=T,T="/mqtt"),typeof x!="number"||x<0)throw new Error(h(l.INVALID_TYPE,[typeof x,"port"]));if(typeof T!="string")throw new Error(h(l.INVALID_TYPE,[typeof T,"path"]));var H=_.indexOf(":")!==-1&&_.slice(0,1)!=="["&&_.slice(-1)!=="]";U="ws://"+(H?"["+_+"]":_)+":"+x+T}for(var G=0,$=0;$<P.length;$++){var re=P.charCodeAt($);55296<=re&&re<=56319&&$++,G++}if(typeof P!="string"||G>65535)throw new Error(h(l.INVALID_ARGUMENT,[P,"clientId"]));var J=new C(U,_,x,T,P);Object.defineProperties(this,{host:{get:function(){return _},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},port:{get:function(){return x},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},path:{get:function(){return T},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},uri:{get:function(){return U},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},clientId:{get:function(){return J.clientId},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},onConnected:{get:function(){return J.onConnected},set:function(V){if(typeof V=="function")J.onConnected=V;else throw new Error(h(l.INVALID_TYPE,[typeof V,"onConnected"]))}},disconnectedPublishing:{get:function(){return J.disconnectedPublishing},set:function(V){J.disconnectedPublishing=V}},disconnectedBufferSize:{get:function(){return J.disconnectedBufferSize},set:function(V){J.disconnectedBufferSize=V}},onConnectionLost:{get:function(){return J.onConnectionLost},set:function(V){if(typeof V=="function")J.onConnectionLost=V;else throw new Error(h(l.INVALID_TYPE,[typeof V,"onConnectionLost"]))}},onMessageDelivered:{get:function(){return J.onMessageDelivered},set:function(V){if(typeof V=="function")J.onMessageDelivered=V;else throw new Error(h(l.INVALID_TYPE,[typeof V,"onMessageDelivered"]))}},onMessageArrived:{get:function(){return J.onMessageArrived},set:function(V){if(typeof V=="function")J.onMessageArrived=V;else throw new Error(h(l.INVALID_TYPE,[typeof V,"onMessageArrived"]))}},trace:{get:function(){return J.traceFunction},set:function(V){if(typeof V=="function")J.traceFunction=V;else throw new Error(h(l.INVALID_TYPE,[typeof V,"onTrace"]))}}}),this.connect=function(V){if(V=V||{},o(V,{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",reconnect:"boolean",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),V.keepAliveInterval===void 0&&(V.keepAliveInterval=60),V.mqttVersion>4||V.mqttVersion<3)throw new Error(h(l.INVALID_ARGUMENT,[V.mqttVersion,"connectOptions.mqttVersion"]));if(V.mqttVersion===void 0?(V.mqttVersionExplicit=!1,V.mqttVersion=4):V.mqttVersionExplicit=!0,V.password!==void 0&&V.userName===void 0)throw new Error(h(l.INVALID_ARGUMENT,[V.password,"connectOptions.password"]));if(V.willMessage){if(!(V.willMessage instanceof v))throw new Error(h(l.INVALID_TYPE,[V.willMessage,"connectOptions.willMessage"]));if(V.willMessage.stringPayload=null,typeof V.willMessage.destinationName>"u")throw new Error(h(l.INVALID_TYPE,[typeof V.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if(typeof V.cleanSession>"u"&&(V.cleanSession=!0),V.hosts){if(!(V.hosts instanceof Array))throw new Error(h(l.INVALID_ARGUMENT,[V.hosts,"connectOptions.hosts"]));if(V.hosts.length<1)throw new Error(h(l.INVALID_ARGUMENT,[V.hosts,"connectOptions.hosts"]));for(var xe=!1,X=0;X<V.hosts.length;X++){if(typeof V.hosts[X]!="string")throw new Error(h(l.INVALID_TYPE,[typeof V.hosts[X],"connectOptions.hosts["+X+"]"]));if(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(V.hosts[X])){if(X===0)xe=!0;else if(!xe)throw new Error(h(l.INVALID_ARGUMENT,[V.hosts[X],"connectOptions.hosts["+X+"]"]))}else if(xe)throw new Error(h(l.INVALID_ARGUMENT,[V.hosts[X],"connectOptions.hosts["+X+"]"]))}if(xe)V.uris=V.hosts;else{if(!V.ports)throw new Error(h(l.INVALID_ARGUMENT,[V.ports,"connectOptions.ports"]));if(!(V.ports instanceof Array))throw new Error(h(l.INVALID_ARGUMENT,[V.ports,"connectOptions.ports"]));if(V.hosts.length!==V.ports.length)throw new Error(h(l.INVALID_ARGUMENT,[V.ports,"connectOptions.ports"]));V.uris=[];for(var X=0;X<V.hosts.length;X++){if(typeof V.ports[X]!="number"||V.ports[X]<0)throw new Error(h(l.INVALID_TYPE,[typeof V.ports[X],"connectOptions.ports["+X+"]"]));var ne=V.hosts[X],oe=V.ports[X],ge=ne.indexOf(":")!==-1;U="ws://"+(ge?"["+ne+"]":ne)+":"+oe+T,V.uris.push(U)}}}J.connect(V)},this.subscribe=function(V,xe){if(typeof V!="string"&&V.constructor!==Array)throw new Error("Invalid argument:"+V);if(xe=xe||{},o(xe,{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),xe.timeout&&!xe.onFailure)throw new Error("subscribeOptions.timeout specified with no onFailure callback.");if(typeof xe.qos<"u"&&!(xe.qos===0||xe.qos===1||xe.qos===2))throw new Error(h(l.INVALID_ARGUMENT,[xe.qos,"subscribeOptions.qos"]));J.subscribe(V,xe)},this.unsubscribe=function(V,xe){if(typeof V!="string"&&V.constructor!==Array)throw new Error("Invalid argument:"+V);if(xe=xe||{},o(xe,{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),xe.timeout&&!xe.onFailure)throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");J.unsubscribe(V,xe)},this.send=function(V,xe,X,ne){var oe;if(arguments.length===0)throw new Error("Invalid argument.length");if(arguments.length==1){if(!(V instanceof v)&&typeof V!="string")throw new Error("Invalid argument:"+typeof V);if(oe=V,typeof oe.destinationName>"u")throw new Error(h(l.INVALID_ARGUMENT,[oe.destinationName,"Message.destinationName"]));J.send(oe)}else oe=new v(xe),oe.destinationName=V,arguments.length>=3&&(oe.qos=X),arguments.length>=4&&(oe.retained=ne),J.send(oe)},this.publish=function(V,xe,X,ne){var oe;if(arguments.length===0)throw new Error("Invalid argument.length");if(arguments.length==1){if(!(V instanceof v)&&typeof V!="string")throw new Error("Invalid argument:"+typeof V);if(oe=V,typeof oe.destinationName>"u")throw new Error(h(l.INVALID_ARGUMENT,[oe.destinationName,"Message.destinationName"]));J.send(oe)}else oe=new v(xe),oe.destinationName=V,arguments.length>=3&&(oe.qos=X),arguments.length>=4&&(oe.retained=ne),J.send(oe)},this.disconnect=function(){J.disconnect()},this.getTraceLog=function(){return J.getTraceLog()},this.startTrace=function(){J.startTrace()},this.stopTrace=function(){J.stopTrace()},this.isConnected=function(){return J.connected}},v=function(_){var x;if(typeof _=="string"||_ instanceof ArrayBuffer||ArrayBuffer.isView(_)&&!(_ instanceof DataView))x=_;else throw h(l.INVALID_ARGUMENT,[_,"newPayload"]);var T,P=0,U=!1,N=!1;Object.defineProperties(this,{payloadString:{enumerable:!0,get:function(){return typeof x=="string"?x:O(x,0,x.length)}},payloadBytes:{enumerable:!0,get:function(){if(typeof x=="string"){var H=new ArrayBuffer(b(x)),G=new Uint8Array(H);return S(x,G,0),G}else return x}},destinationName:{enumerable:!0,get:function(){return T},set:function(H){if(typeof H=="string")T=H;else throw new Error(h(l.INVALID_ARGUMENT,[H,"newDestinationName"]))}},qos:{enumerable:!0,get:function(){return P},set:function(H){if(H===0||H===1||H===2)P=H;else throw new Error("Invalid argument:"+H)}},retained:{enumerable:!0,get:function(){return U},set:function(H){if(typeof H=="boolean")U=H;else throw new Error(h(l.INVALID_ARGUMENT,[H,"newRetained"]))}},topic:{enumerable:!0,get:function(){return T},set:function(H){T=H}},duplicate:{enumerable:!0,get:function(){return N},set:function(H){N=H}}})};return{Client:j,Message:v}}(typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{});return e})});var yg=bn((e2,gg)=>{"use strict";E();gg.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var vg=bn((t2,_g)=>{E();_g.exports=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")}});var Mg=bn((n2,bg)=>{"use strict";E();var ax=vg(),lx=Array.prototype.concat,cx=Array.prototype.slice,xg=bg.exports=function(e){for(var t=[],n=0,s=e.length;n<s;n++){var r=e[n];ax(r)?t=lx.call(t,cx.call(r)):t.push(r)}return t};xg.wrap=function(i){return function(){return i(xg(arguments))}}});var Eg=bn((i2,Ag)=>{E();var Lo=yg(),Po=Mg(),Sg=Object.hasOwnProperty,wg=Object.create(null);for(ul in Lo)Sg.call(Lo,ul)&&(wg[Lo[ul]]=ul);var ul,En=Ag.exports={to:{},get:{}};En.get=function(i){var e=i.substring(0,3).toLowerCase(),t,n;switch(e){case"hsl":t=En.get.hsl(i),n="hsl";break;case"hwb":t=En.get.hwb(i),n="hwb";break;default:t=En.get.rgb(i),n="rgb";break}return t?{model:n,value:t}:null};En.get.rgb=function(i){if(!i)return null;var e=/^#([a-f0-9]{3,4})$/i,t=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,n=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,s=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,r=/^(\w+)$/,o=[0,0,0,1],a,l,c;if(a=i.match(t)){for(c=a[2],a=a[1],l=0;l<3;l++){var h=l*2;o[l]=parseInt(a.slice(h,h+2),16)}c&&(o[3]=parseInt(c,16)/255)}else if(a=i.match(e)){for(a=a[1],c=a[3],l=0;l<3;l++)o[l]=parseInt(a[l]+a[l],16);c&&(o[3]=parseInt(c+c,16)/255)}else if(a=i.match(n)){for(l=0;l<3;l++)o[l]=parseInt(a[l+1],0);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else if(a=i.match(s)){for(l=0;l<3;l++)o[l]=Math.round(parseFloat(a[l+1])*2.55);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else return(a=i.match(r))?a[1]==="transparent"?[0,0,0,0]:Sg.call(Lo,a[1])?(o=Lo[a[1]],o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=Ji(o[l],0,255);return o[3]=Ji(o[3],0,1),o};En.get.hsl=function(i){if(!i)return null;var e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,t=i.match(e);if(t){var n=parseFloat(t[4]),s=(parseFloat(t[1])%360+360)%360,r=Ji(parseFloat(t[2]),0,100),o=Ji(parseFloat(t[3]),0,100),a=Ji(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};En.get.hwb=function(i){if(!i)return null;var e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,t=i.match(e);if(t){var n=parseFloat(t[4]),s=(parseFloat(t[1])%360+360)%360,r=Ji(parseFloat(t[2]),0,100),o=Ji(parseFloat(t[3]),0,100),a=Ji(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};En.to.hex=function(){var i=Po(arguments);return"#"+fl(i[0])+fl(i[1])+fl(i[2])+(i[3]<1?fl(Math.round(i[3]*255)):"")};En.to.rgb=function(){var i=Po(arguments);return i.length<4||i[3]===1?"rgb("+Math.round(i[0])+", "+Math.round(i[1])+", "+Math.round(i[2])+")":"rgba("+Math.round(i[0])+", "+Math.round(i[1])+", "+Math.round(i[2])+", "+i[3]+")"};En.to.rgb.percent=function(){var i=Po(arguments),e=Math.round(i[0]/255*100),t=Math.round(i[1]/255*100),n=Math.round(i[2]/255*100);return i.length<4||i[3]===1?"rgb("+e+"%, "+t+"%, "+n+"%)":"rgba("+e+"%, "+t+"%, "+n+"%, "+i[3]+")"};En.to.hsl=function(){var i=Po(arguments);return i.length<4||i[3]===1?"hsl("+i[0]+", "+i[1]+"%, "+i[2]+"%)":"hsla("+i[0]+", "+i[1]+"%, "+i[2]+"%, "+i[3]+")"};En.to.hwb=function(){var i=Po(arguments),e="";return i.length>=4&&i[3]!==1&&(e=", "+i[3]),"hwb("+i[0]+", "+i[1]+"%, "+i[2]+"%"+e+")"};En.to.keyword=function(i){return wg[i.slice(0,3)]};function Ji(i,e,t){return Math.min(Math.max(e,i),t)}function fl(i){var e=Math.round(i).toString(16).toUpperCase();return e.length<2?"0"+e:e}});var Ig=bn((s2,Tg)=>{"use strict";E();Tg.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var cu=bn((r2,Cg)=>{E();var No=Ig(),Rg={};for(let i of Object.keys(No))Rg[No[i]]=i;var Me={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Cg.exports=Me;for(let i of Object.keys(Me)){if(!("channels"in Me[i]))throw new Error("missing channels property: "+i);if(!("labels"in Me[i]))throw new Error("missing channel labels property: "+i);if(Me[i].labels.length!==Me[i].channels)throw new Error("channel and label counts mismatch: "+i);let{channels:e,labels:t}=Me[i];delete Me[i].channels,delete Me[i].labels,Object.defineProperty(Me[i],"channels",{value:e}),Object.defineProperty(Me[i],"labels",{value:t})}Me.rgb.hsl=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=r-s,a,l;r===s?a=0:e===r?a=(t-n)/o:t===r?a=2+(n-e)/o:n===r&&(a=4+(e-t)/o),a=Math.min(a*60,360),a<0&&(a+=360);let c=(s+r)/2;return r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};Me.rgb.hsv=function(i){let e,t,n,s,r,o=i[0]/255,a=i[1]/255,l=i[2]/255,c=Math.max(o,a,l),h=c-Math.min(o,a,l),u=function(f){return(c-f)/6/h+1/2};return h===0?(s=0,r=0):(r=h/c,e=u(o),t=u(a),n=u(l),o===c?s=n-t:a===c?s=1/3+e-n:l===c&&(s=2/3+t-e),s<0?s+=1:s>1&&(s-=1)),[s*360,r*100,c*100]};Me.rgb.hwb=function(i){let e=i[0],t=i[1],n=i[2],s=Me.rgb.hsl(i)[0],r=1/255*Math.min(e,Math.min(t,n));return n=1-1/255*Math.max(e,Math.max(t,n)),[s,r*100,n*100]};Me.rgb.cmyk=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.min(1-e,1-t,1-n),r=(1-e-s)/(1-s)||0,o=(1-t-s)/(1-s)||0,a=(1-n-s)/(1-s)||0;return[r*100,o*100,a*100,s*100]};function hx(i,e){return(i[0]-e[0])**2+(i[1]-e[1])**2+(i[2]-e[2])**2}Me.rgb.keyword=function(i){let e=Rg[i];if(e)return e;let t=1/0,n;for(let s of Object.keys(No)){let r=No[s],o=hx(i,r);o<t&&(t=o,n=s)}return n};Me.keyword.rgb=function(i){return No[i]};Me.rgb.xyz=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let s=e*.4124+t*.3576+n*.1805,r=e*.2126+t*.7152+n*.0722,o=e*.0193+t*.1192+n*.9505;return[s*100,r*100,o*100]};Me.rgb.lab=function(i){let e=Me.rgb.xyz(i),t=e[0],n=e[1],s=e[2];t/=95.047,n/=100,s/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let r=116*n-16,o=500*(t-n),a=200*(n-s);return[r,o,a]};Me.hsl.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100,s,r,o;if(t===0)return o=n*255,[o,o,o];n<.5?s=n*(1+t):s=n+t-n*t;let a=2*n-s,l=[0,0,0];for(let c=0;c<3;c++)r=e+1/3*-(c-1),r<0&&r++,r>1&&r--,6*r<1?o=a+(s-a)*6*r:2*r<1?o=s:3*r<2?o=a+(s-a)*(2/3-r)*6:o=a,l[c]=o*255;return l};Me.hsl.hsv=function(i){let e=i[0],t=i[1]/100,n=i[2]/100,s=t,r=Math.max(n,.01);n*=2,t*=n<=1?n:2-n,s*=r<=1?r:2-r;let o=(n+t)/2,a=n===0?2*s/(r+s):2*t/(n+t);return[e,a*100,o*100]};Me.hsv.rgb=function(i){let e=i[0]/60,t=i[1]/100,n=i[2]/100,s=Math.floor(e)%6,r=e-Math.floor(e),o=255*n*(1-t),a=255*n*(1-t*r),l=255*n*(1-t*(1-r));switch(n*=255,s){case 0:return[n,l,o];case 1:return[a,n,o];case 2:return[o,n,l];case 3:return[o,a,n];case 4:return[l,o,n];case 5:return[n,o,a]}};Me.hsv.hsl=function(i){let e=i[0],t=i[1]/100,n=i[2]/100,s=Math.max(n,.01),r,o;o=(2-t)*n;let a=(2-t)*s;return r=t*s,r/=a<=1?a:2-a,r=r||0,o/=2,[e,r*100,o*100]};Me.hwb.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100,s=t+n,r;s>1&&(t/=s,n/=s);let o=Math.floor(6*e),a=1-n;r=6*e-o,(o&1)!==0&&(r=1-r);let l=t+r*(a-t),c,h,u;switch(o){default:case 6:case 0:c=a,h=l,u=t;break;case 1:c=l,h=a,u=t;break;case 2:c=t,h=a,u=l;break;case 3:c=t,h=l,u=a;break;case 4:c=l,h=t,u=a;break;case 5:c=a,h=t,u=l;break}return[c*255,h*255,u*255]};Me.cmyk.rgb=function(i){let e=i[0]/100,t=i[1]/100,n=i[2]/100,s=i[3]/100,r=1-Math.min(1,e*(1-s)+s),o=1-Math.min(1,t*(1-s)+s),a=1-Math.min(1,n*(1-s)+s);return[r*255,o*255,a*255]};Me.xyz.rgb=function(i){let e=i[0]/100,t=i[1]/100,n=i[2]/100,s,r,o;return s=e*3.2406+t*-1.5372+n*-.4986,r=e*-.9689+t*1.8758+n*.0415,o=e*.0557+t*-.204+n*1.057,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,r=r>.0031308?1.055*r**(1/2.4)-.055:r*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),[s*255,r*255,o*255]};Me.xyz.lab=function(i){let e=i[0],t=i[1],n=i[2];e/=95.047,t/=100,n/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let s=116*t-16,r=500*(e-t),o=200*(t-n);return[s,r,o]};Me.lab.xyz=function(i){let e=i[0],t=i[1],n=i[2],s,r,o;r=(e+16)/116,s=t/500+r,o=r-n/200;let a=r**3,l=s**3,c=o**3;return r=a>.008856?a:(r-16/116)/7.787,s=l>.008856?l:(s-16/116)/7.787,o=c>.008856?c:(o-16/116)/7.787,s*=95.047,r*=100,o*=108.883,[s,r,o]};Me.lab.lch=function(i){let e=i[0],t=i[1],n=i[2],s;s=Math.atan2(n,t)*360/2/Math.PI,s<0&&(s+=360);let o=Math.sqrt(t*t+n*n);return[e,o,s]};Me.lch.lab=function(i){let e=i[0],t=i[1],s=i[2]/360*2*Math.PI,r=t*Math.cos(s),o=t*Math.sin(s);return[e,r,o]};Me.rgb.ansi16=function(i,e=null){let[t,n,s]=i,r=e===null?Me.rgb.hsv(i)[2]:e;if(r=Math.round(r/50),r===0)return 30;let o=30+(Math.round(s/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return r===2&&(o+=60),o};Me.hsv.ansi16=function(i){return Me.rgb.ansi16(Me.hsv.rgb(i),i[2])};Me.rgb.ansi256=function(i){let e=i[0],t=i[1],n=i[2];return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)};Me.ansi16.rgb=function(i){let e=i%10;if(e===0||e===7)return i>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let t=(~~(i>50)+1)*.5,n=(e&1)*t*255,s=(e>>1&1)*t*255,r=(e>>2&1)*t*255;return[n,s,r]};Me.ansi256.rgb=function(i){if(i>=232){let r=(i-232)*10+8;return[r,r,r]}i-=16;let e,t=Math.floor(i/36)/5*255,n=Math.floor((e=i%36)/6)/5*255,s=e%6/5*255;return[t,n,s]};Me.rgb.hex=function(i){let t=(((Math.round(i[0])&255)<<16)+((Math.round(i[1])&255)<<8)+(Math.round(i[2])&255)).toString(16).toUpperCase();return"000000".substring(t.length)+t};Me.hex.rgb=function(i){let e=i.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let t=e[0];e[0].length===3&&(t=t.split("").map(a=>a+a).join(""));let n=parseInt(t,16),s=n>>16&255,r=n>>8&255,o=n&255;return[s,r,o]};Me.rgb.hcg=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.max(Math.max(e,t),n),r=Math.min(Math.min(e,t),n),o=s-r,a,l;return o<1?a=r/(1-o):a=0,o<=0?l=0:s===e?l=(t-n)/o%6:s===t?l=2+(n-e)/o:l=4+(e-t)/o,l/=6,l%=1,[l*360,o*100,a*100]};Me.hsl.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=t<.5?2*e*t:2*e*(1-t),s=0;return n<1&&(s=(t-.5*n)/(1-n)),[i[0],n*100,s*100]};Me.hsv.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=e*t,s=0;return n<1&&(s=(t-n)/(1-n)),[i[0],n*100,s*100]};Me.hcg.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100;if(t===0)return[n*255,n*255,n*255];let s=[0,0,0],r=e%1*6,o=r%1,a=1-o,l=0;switch(Math.floor(r)){case 0:s[0]=1,s[1]=o,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=o;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=o,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-t)*n,[(t*s[0]+l)*255,(t*s[1]+l)*255,(t*s[2]+l)*255]};Me.hcg.hsv=function(i){let e=i[1]/100,t=i[2]/100,n=e+t*(1-e),s=0;return n>0&&(s=e/n),[i[0],s*100,n*100]};Me.hcg.hsl=function(i){let e=i[1]/100,n=i[2]/100*(1-e)+.5*e,s=0;return n>0&&n<.5?s=e/(2*n):n>=.5&&n<1&&(s=e/(2*(1-n))),[i[0],s*100,n*100]};Me.hcg.hwb=function(i){let e=i[1]/100,t=i[2]/100,n=e+t*(1-e);return[i[0],(n-e)*100,(1-n)*100]};Me.hwb.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=1-t,s=n-e,r=0;return s<1&&(r=(n-s)/(1-s)),[i[0],s*100,r*100]};Me.apple.rgb=function(i){return[i[0]/65535*255,i[1]/65535*255,i[2]/65535*255]};Me.rgb.apple=function(i){return[i[0]/255*65535,i[1]/255*65535,i[2]/255*65535]};Me.gray.rgb=function(i){return[i[0]/100*255,i[0]/100*255,i[0]/100*255]};Me.gray.hsl=function(i){return[0,0,i[0]]};Me.gray.hsv=Me.gray.hsl;Me.gray.hwb=function(i){return[0,100,i[0]]};Me.gray.cmyk=function(i){return[0,0,0,i[0]]};Me.gray.lab=function(i){return[i[0],0,0]};Me.gray.hex=function(i){let e=Math.round(i[0]/100*255)&255,n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n};Me.rgb.gray=function(i){return[(i[0]+i[1]+i[2])/3/255*100]}});var Pg=bn((o2,Lg)=>{E();var dl=cu();function ux(){let i={},e=Object.keys(dl);for(let t=e.length,n=0;n<t;n++)i[e[n]]={distance:-1,parent:null};return i}function fx(i){let e=ux(),t=[i];for(e[i].distance=0;t.length;){let n=t.pop(),s=Object.keys(dl[n]);for(let r=s.length,o=0;o<r;o++){let a=s[o],l=e[a];l.distance===-1&&(l.distance=e[n].distance+1,l.parent=n,t.unshift(a))}}return e}function dx(i,e){return function(t){return e(i(t))}}function px(i,e){let t=[e[i].parent,i],n=dl[e[i].parent][i],s=e[i].parent;for(;e[s].parent;)t.unshift(e[s].parent),n=dx(dl[e[s].parent][s],n),s=e[s].parent;return n.conversion=t,n}Lg.exports=function(i){let e=fx(i),t={},n=Object.keys(e);for(let s=n.length,r=0;r<s;r++){let o=n[r];e[o].parent!==null&&(t[o]=px(o,e))}return t}});var Og=bn((a2,Ng)=>{E();var hu=cu(),mx=Pg(),gr={},gx=Object.keys(hu);function yx(i){let e=function(...t){let n=t[0];return n==null?n:(n.length>1&&(t=n),i(t))};return"conversion"in i&&(e.conversion=i.conversion),e}function _x(i){let e=function(...t){let n=t[0];if(n==null)return n;n.length>1&&(t=n);let s=i(t);if(typeof s=="object")for(let r=s.length,o=0;o<r;o++)s[o]=Math.round(s[o]);return s};return"conversion"in i&&(e.conversion=i.conversion),e}gx.forEach(i=>{gr[i]={},Object.defineProperty(gr[i],"channels",{value:hu[i].channels}),Object.defineProperty(gr[i],"labels",{value:hu[i].labels});let e=mx(i);Object.keys(e).forEach(n=>{let s=e[n];gr[i][n]=_x(s),gr[i][n].raw=yx(s)})});Ng.exports=gr});var Fg=bn((l2,Ug)=>{E();var yr=Eg(),Tn=Og(),Dg=["keyword","gray","hex"],uu={};for(let i of Object.keys(Tn))uu[[...Tn[i].labels].sort().join("")]=i;var pl={};function Gt(i,e){if(!(this instanceof Gt))return new Gt(i,e);if(e&&e in Dg&&(e=null),e&&!(e in Tn))throw new Error("Unknown model: "+e);let t,n;if(i==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(i instanceof Gt)this.model=i.model,this.color=[...i.color],this.valpha=i.valpha;else if(typeof i=="string"){let s=yr.get(i);if(s===null)throw new Error("Unable to parse color from string: "+i);this.model=s.model,n=Tn[this.model].channels,this.color=s.value.slice(0,n),this.valpha=typeof s.value[n]=="number"?s.value[n]:1}else if(i.length>0){this.model=e||"rgb",n=Tn[this.model].channels;let s=Array.prototype.slice.call(i,0,n);this.color=fu(s,n),this.valpha=typeof i[n]=="number"?i[n]:1}else if(typeof i=="number")this.model="rgb",this.color=[i>>16&255,i>>8&255,i&255],this.valpha=1;else{this.valpha=1;let s=Object.keys(i);"alpha"in i&&(s.splice(s.indexOf("alpha"),1),this.valpha=typeof i.alpha=="number"?i.alpha:0);let r=s.sort().join("");if(!(r in uu))throw new Error("Unable to parse color from object: "+JSON.stringify(i));this.model=uu[r];let{labels:o}=Tn[this.model],a=[];for(t=0;t<o.length;t++)a.push(i[o[t]]);this.color=fu(a)}if(pl[this.model])for(n=Tn[this.model].channels,t=0;t<n;t++){let s=pl[this.model][t];s&&(this.color[t]=s(this.color[t]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}Gt.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(i){let e=this.model in yr.to?this:this.rgb();e=e.round(typeof i=="number"?i:1);let t=e.valpha===1?e.color:[...e.color,this.valpha];return yr.to[e.model](t)},percentString(i){let e=this.rgb().round(typeof i=="number"?i:1),t=e.valpha===1?e.color:[...e.color,this.valpha];return yr.to.rgb.percent(t)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let i={},{channels:e}=Tn[this.model],{labels:t}=Tn[this.model];for(let n=0;n<e;n++)i[t[n]]=this.color[n];return this.valpha!==1&&(i.alpha=this.valpha),i},unitArray(){let i=this.rgb().color;return i[0]/=255,i[1]/=255,i[2]/=255,this.valpha!==1&&i.push(this.valpha),i},unitObject(){let i=this.rgb().object();return i.r/=255,i.g/=255,i.b/=255,this.valpha!==1&&(i.alpha=this.valpha),i},round(i){return i=Math.max(i||0,0),new Gt([...this.color.map(xx(i)),this.valpha],this.model)},alpha(i){return i!==void 0?new Gt([...this.color,Math.max(0,Math.min(1,i))],this.model):this.valpha},red:Mt("rgb",0,Bt(255)),green:Mt("rgb",1,Bt(255)),blue:Mt("rgb",2,Bt(255)),hue:Mt(["hsl","hsv","hsl","hwb","hcg"],0,i=>(i%360+360)%360),saturationl:Mt("hsl",1,Bt(100)),lightness:Mt("hsl",2,Bt(100)),saturationv:Mt("hsv",1,Bt(100)),value:Mt("hsv",2,Bt(100)),chroma:Mt("hcg",1,Bt(100)),gray:Mt("hcg",2,Bt(100)),white:Mt("hwb",1,Bt(100)),wblack:Mt("hwb",2,Bt(100)),cyan:Mt("cmyk",0,Bt(100)),magenta:Mt("cmyk",1,Bt(100)),yellow:Mt("cmyk",2,Bt(100)),black:Mt("cmyk",3,Bt(100)),x:Mt("xyz",0,Bt(95.047)),y:Mt("xyz",1,Bt(100)),z:Mt("xyz",2,Bt(108.833)),l:Mt("lab",0,Bt(100)),a:Mt("lab",1),b:Mt("lab",2),keyword(i){return i!==void 0?new Gt(i):Tn[this.model].keyword(this.color)},hex(i){return i!==void 0?new Gt(i):yr.to.hex(this.rgb().round().color)},hexa(i){if(i!==void 0)return new Gt(i);let e=this.rgb().round().color,t=Math.round(this.valpha*255).toString(16).toUpperCase();return t.length===1&&(t="0"+t),yr.to.hex(e)+t},rgbNumber(){let i=this.rgb().color;return(i[0]&255)<<16|(i[1]&255)<<8|i[2]&255},luminosity(){let i=this.rgb().color,e=[];for(let[t,n]of i.entries()){let s=n/255;e[t]=s<=.04045?s/12.92:((s+.055)/1.055)**2.4}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(i){let e=this.luminosity(),t=i.luminosity();return e>t?(e+.05)/(t+.05):(t+.05)/(e+.05)},level(i){let e=this.contrast(i);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){let i=this.rgb().color;return(i[0]*2126+i[1]*7152+i[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let i=this.rgb();for(let e=0;e<3;e++)i.color[e]=255-i.color[e];return i},lighten(i){let e=this.hsl();return e.color[2]+=e.color[2]*i,e},darken(i){let e=this.hsl();return e.color[2]-=e.color[2]*i,e},saturate(i){let e=this.hsl();return e.color[1]+=e.color[1]*i,e},desaturate(i){let e=this.hsl();return e.color[1]-=e.color[1]*i,e},whiten(i){let e=this.hwb();return e.color[1]+=e.color[1]*i,e},blacken(i){let e=this.hwb();return e.color[2]+=e.color[2]*i,e},grayscale(){let i=this.rgb().color,e=i[0]*.3+i[1]*.59+i[2]*.11;return Gt.rgb(e,e,e)},fade(i){return this.alpha(this.valpha-this.valpha*i)},opaquer(i){return this.alpha(this.valpha+this.valpha*i)},rotate(i){let e=this.hsl(),t=e.color[0];return t=(t+i)%360,t=t<0?360+t:t,e.color[0]=t,e},mix(i,e){if(!i||!i.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof i);let t=i.rgb(),n=this.rgb(),s=e===void 0?.5:e,r=2*s-1,o=t.alpha()-n.alpha(),a=((r*o===-1?r:(r+o)/(1+r*o))+1)/2,l=1-a;return Gt.rgb(a*t.red()+l*n.red(),a*t.green()+l*n.green(),a*t.blue()+l*n.blue(),t.alpha()*s+n.alpha()*(1-s))}};for(let i of Object.keys(Tn)){if(Dg.includes(i))continue;let{channels:e}=Tn[i];Gt.prototype[i]=function(...t){return this.model===i?new Gt(this):t.length>0?new Gt(t,i):new Gt([...bx(Tn[this.model][i].raw(this.color)),this.valpha],i)},Gt[i]=function(...t){let n=t[0];return typeof n=="number"&&(n=fu(t,e)),new Gt(n,i)}}function vx(i,e){return Number(i.toFixed(e))}function xx(i){return function(e){return vx(e,i)}}function Mt(i,e,t){i=Array.isArray(i)?i:[i];for(let n of i)(pl[n]||(pl[n]=[]))[e]=t;return i=i[0],function(n){let s;return n!==void 0?(t&&(n=t(n)),s=this[i](),s.color[e]=n,s):(s=this[i]().color[e],t&&(s=t(s)),s)}}function Bt(i){return function(e){return Math.max(0,Math.min(i,e))}}function bx(i){return Array.isArray(i)?i:[i]}function fu(i,e){for(let t=0;t<e;t++)typeof i[t]!="number"&&(i[t]=0);return i}Ug.exports=Gt});var C_=bn((cD,R_)=>{"use strict";E();var CT=function(e){return LT(e)&&!PT(e)};function LT(i){return!!i&&typeof i=="object"}function PT(i){var e=Object.prototype.toString.call(i);return e==="[object RegExp]"||e==="[object Date]"||DT(i)}var NT=typeof Symbol=="function"&&Symbol.for,OT=NT?Symbol.for("react.element"):60103;function DT(i){return i.$$typeof===OT}function UT(i){return Array.isArray(i)?[]:{}}function Pa(i,e){return e.clone!==!1&&e.isMergeableObject(i)?yo(UT(i),i,e):i}function FT(i,e,t){return i.concat(e).map(function(n){return Pa(n,t)})}function BT(i,e){if(!e.customMerge)return yo;var t=e.customMerge(i);return typeof t=="function"?t:yo}function kT(i){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(i).filter(function(e){return Object.propertyIsEnumerable.call(i,e)}):[]}function T_(i){return Object.keys(i).concat(kT(i))}function I_(i,e){try{return e in i}catch{return!1}}function zT(i,e){return I_(i,e)&&!(Object.hasOwnProperty.call(i,e)&&Object.propertyIsEnumerable.call(i,e))}function VT(i,e,t){var n={};return t.isMergeableObject(i)&&T_(i).forEach(function(s){n[s]=Pa(i[s],t)}),T_(e).forEach(function(s){zT(i,s)||(I_(i,s)&&t.isMergeableObject(e[s])?n[s]=BT(s,t)(i[s],e[s],t):n[s]=Pa(e[s],t))}),n}function yo(i,e,t){t=t||{},t.arrayMerge=t.arrayMerge||FT,t.isMergeableObject=t.isMergeableObject||CT,t.cloneUnlessOtherwiseSpecified=Pa;var n=Array.isArray(e),s=Array.isArray(i),r=n===s;return r?n?t.arrayMerge(i,e,t):VT(i,e,t):Pa(e,t)}yo.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,s){return yo(n,s,t)},{})};var HT=yo;R_.exports=HT});var KT={};em(KT,{BadgeRenderer:()=>Ct,FloorSelector:()=>Rl,LiveDataManager:()=>Ft,LogEvents:()=>pt,Logger:()=>Rt,MapsIndoors:()=>vi,PositionControl:()=>lh,PositionState:()=>wt,UserRole:()=>cr,directions:()=>XT,mapView:()=>WT,services:()=>YT});E();E();E();E();var Sh=Jt(im());E();var pm=Jt(Sn());E();var gh=class{constructor(e,t){this.id=e,this.name=t}},cr=gh;var yh=class extends pm.EventEmitter{#e;#t;#n;constructor(){super();let e=document.currentScript||function(){let t=document.getElementsByTagName("script");return t[t.length-1]}();if(e){let t=new URL(e.src).searchParams;this.#e=t.get("language")||t.get("lr")||navigator.language||navigator.userLanguage||"en",this.#t=t.get("apikey")||t.get("apiKey")||void 0}else this.#e="en";this._userRoles=null,this._venuesToSync=[],this.eventLoggingEnabled=!0}get bookingServiceUrl(){return"https://booking.mapsindoors.com/{{API_KEY}}/api/booking"}get apiUrl(){return Y[0]}get apiUrls(){return Y}get language(){return this.#e}set language(e){e>""&&e!==this.#e&&(this.#e=e,this.emit("language_changed",{lr:this.#e}))}get apiKey(){return this.#t}set apiKey(e){e!==this.#t&&(this.#t=e,this.emit("apikey_changed",{apiKey:this.apiKey}))}set authToken(e){this._authToken=e,this.emit("authtoken_changed",{authToken:this.authToken})}get authToken(){return this._authToken}get version(){return"4.41.2"}get userRoles(){return this._userRoles}set userRoles(e=[]){this._userRoles=[].concat(e).filter(t=>t instanceof cr),this.emit("userroles_changed",{userRoles:this.userRoles})}get venuesToSync(){return this._venuesToSync}set venuesToSync(e=[]){this._venuesToSync=[].concat(e),this.emit("venuestosync_changed",{venuesToSync:this.venuesToSync})}get eventLoggingEnabled(){return this.#n===!0}set eventLoggingEnabled(e=!1){this.#n=e===!0,this.#n?this.emit("eventlogging_enabled"):this.emit("eventlogging_disabled")}},ce=new yh;var bh=(0,Sh.storageFactory)(()=>localStorage),mm=(0,Sh.storageFactory)(()=>sessionStorage),vo=new Map,Mh=class{#e;constructor(){}getJson(e,t={}){return this.get(e,t).then(gm)}prepareUrl(e,t,n){if(t.substr(0,2)==="~/")return`${e}/${t.substr(2)}${n??""}`;if(/^http(s)?:\/\//i.test(t))return t=t.replace("{{API_KEY}}",ce.apiKey),`${t}${n??""}`;if(ce.apiKey)return`${e}/${ce.apiKey}/api/${t}${n??""}`;throw Error("Missing api key!")}delete(e,t={}){return this.getApiConfig().then(_h).then(vh).then(({headers:n,apiHost:s})=>{let r=ka(t.search),o=this.prepareUrl(s,e,r);return n=Object.assign({},n,t.headers),fetch(o,{method:"DELETE",headers:n}).then(xh).catch(a=>{if(a instanceof hr){if(a.status===401)return this.getApiConfig().then(Ba).then(()=>this.delete(e,t));throw a}return this.getApiConfig(!1).then(()=>this.delete(e,t))})})}post(e,t={}){return this.getApiConfig().then(_h).then(vh).then(({headers:n,apiHost:s})=>{let r=JSON.stringify(t.body||""),o=ka(t.search);n=Object.assign({},{"Content-Type":"application/json","Content-Length":r.length},n,t.headers);let a=this.prepareUrl(s,e,o);return fetch(a,{method:"POST",headers:n,body:r}).then(xh).catch(c=>{if(c instanceof hr){if(c.status===401)return this.getApiConfig().then(Ba).then(()=>this.post(e,t));throw c}return this.getApiConfig(!1).then(()=>this.post(e,t))})})}get(e,t={}){return this.getApiConfig().then(_h).then(vh).then(({headers:n,apiHost:s})=>{let r=ka(t.search),o=this.prepareUrl(s,e,r);n=Object.assign({},n,t.headers);let a=av(o,n);if(vo.has(a))return vo.get(a);let l=fetch(o,{headers:n}).then(xh).then(c=>(vo.delete(a),c)).catch(c=>{if(vo.delete(a),c instanceof hr){if(c.status===401)return this.getApiConfig().then(Ba).then(()=>this.get(e,t));throw c}return this.getApiConfig(!1).then(()=>this.get(e,t))});return vo.set(a,l),l})}getApiConfig(e=!0){let t=nv().map(n=>`${n}/${ce.apiKey}`);return e&&this.#e?this.#e:this.#e=ev(t).then(iv).then(Ba).then(sv)}sendLogPackage(e){let t=`~/${e.apiKey}/api/logPackage`;return this.getApiConfig().then(({apiHost:n})=>{let s=this.prepareUrl(n,t),r=new Blob([JSON.stringify(e)],{type:"application/json",length:e.length});return navigator?.sendBeacon(s,r)})}},it=new Mh;function ka(i={}){return i.lr=i.lr||ce.language,i=Object.keys(i).reduce((e,t)=>{let n=i[t];return n instanceof Array&&n.length>0?e.push(n.map(s=>`${t}=${encodeURIComponent(s)}`).join("&")):n?.toString()>""&&!(n instanceof Object)&&e.push(`${t}=${encodeURIComponent(n)}`),e},[]),i=i.join("&"),i>""?"?"+i:""}function _h({sessionToken:i,apiHost:e,headers:t={},...n}){return t["mapsindoors-sdk-version"]=`jsapi/${ce.version}`,t["mapsindoors-session-token"]=i,{apiHost:e,headers:t,...n}}function vh({apiHost:i,headers:e,...t}){return ce.authToken&&(e.Authorization=`Bearer ${ce.authToken}`),{apiHost:i,headers:e,...t}}function ev(i){return tv(i.map(e=>rv(`${e}/api`))).then(e=>(e.apiHost=ov(e.apiHost),e))}function tv(i){return new Promise((t,n)=>{Promise.all(i).then(s=>{s.every(r=>e(r))&&n("Unable to reach any of the backend servers! Are you offline?")});for(let s of i)Promise.resolve(s).then(r=>{e(r)||t(r)})});function e(t){return t instanceof Error}}function nv(){let i=bh.getItem("mi:apiUrls");return i>""?i.split(";"):ce.apiUrls}function iv(i){let e=bh.getItem("mi:apiUrls"),t=i.backendUrls.join(";");return e!==t&&bh.setItem("mi:apiUrls",t),i}function Ba(i){return new Promise(e=>{if(i.authRequired&&i.authRequired===!0){let t=Object.freeze({authIssuer:i.authIssuer,authClients:i.authClients});ce.once("authtoken_changed",()=>{e(i)}),mapsindoors.MapsIndoors.onAuthRequired.call(null,t)}else e(i)})}function sv(i){return mm.getItem("mi:sessionToken")||mm.setItem("mi:sessionToken",i.sessionToken),i}function rv(i){return fetch(i).then(gm).then(e=>Object.assign({apiHost:i},e)).catch(e=>e)}function gm(i){return i.clone().json()}function xh(i){return i.ok?i:i.text().then(e=>{throw new hr(e||i.statusText||"Unknown error!",i.status)})}function ov(i){return new URL(i).origin}var hr=class extends Error{constructor(e,t){super(e),this.name="HttpError",this.status=t}};function av(i,e){return`${i};${Object.entries(e).flatMap(t=>t.join(":")).join(";")}`}function qi(i,e){let t=ka(e);return btoa(`${i}${t}`)}var Ss,Ms=class{static async getConfig(){if(!ce.apiKey)return new Promise(t=>{ce.once("apikey_changed",()=>Ms.getConfig().then(t))});let e=`${ce.apiKey}:${ce.language}`;if(Mn(Ms,Ss).has(e))return Mn(Ms,Ss).get(e);{let t=await it.getJson("~/sync/appconfig/",{search:{solutionId:ce.apiKey}});return Mn(Ms,Ss).set(e,t),t}}static clearCache(){Mn(Ms,Ss).clear()}},ws=Ms;Ss=new WeakMap,di(ws,Ss,new Map);E();E();E();var Kt=[];for(za=0;za<256;++za)Kt.push((za+256).toString(16).slice(1));var za;function ym(i,e=0){return(Kt[i[e+0]]+Kt[i[e+1]]+Kt[i[e+2]]+Kt[i[e+3]]+"-"+Kt[i[e+4]]+Kt[i[e+5]]+"-"+Kt[i[e+6]]+Kt[i[e+7]]+"-"+Kt[i[e+8]]+Kt[i[e+9]]+"-"+Kt[i[e+10]]+Kt[i[e+11]]+Kt[i[e+12]]+Kt[i[e+13]]+Kt[i[e+14]]+Kt[i[e+15]]).toLowerCase()}E();var Va,lv=new Uint8Array(16);function wh(){if(!Va&&(Va=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Va))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Va(lv)}E();E();var cv=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ah={randomUUID:cv};function hv(i,e,t){if(Ah.randomUUID&&!e&&!i)return Ah.randomUUID();i=i||{};var n=i.random||(i.rng||wh)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=n[s];return e}return ym(n)}var xo=hv;E();E();var _m=Jt(Sn()),Eh,bo=class extends _m.default{#e;constructor(e){super(),uv(e)?this.#e=e:this.#e=new Map}getItem(e){if(Ha(e))return this.#e instanceof Map?this.#e.get(e):this.#e.getItem(e)}setItem(e,t){Ha(e)&&Ha(t)&&(this.#e instanceof Map?this.#e.set(e,t):this.#e.setItem(e,t),this.emit("itemSet"))}removeItem(e){Ha(e)&&(this.#e instanceof Map?this.#e.delete(e):this.#e.removeItem(e),this.emit("itemRemoved"))}clear(){this.#e.clear()}key(e){if(Number.isInteger(e))return this.#e instanceof Map?Array.from(this.#e.keys())[e]||null:this.#e.key(e)}keys(){return this.#e instanceof Map?this.#e.keys():Object.keys(this.#e)[Symbol.iterator]()}entries(){return this[Symbol.iterator]()}values(){return this.#e instanceof Map?this.#e.values():Object.values(this.#e)[Symbol.iterator]()}get length(){return this.#e instanceof Map?this.#e.size:this.#e.length}[Symbol.iterator](){return this.#e instanceof Map?this.#e[Symbol.iterator]():Object.entries(this.#e)[Symbol.iterator]()}static get localStorage(){return Eh||(Eh=new bo(window.localStorage)),Eh}};function uv(i){try{let e="__some_random_key_you_are_not_going_to_use__";return i.setItem(e,e),i.removeItem(e),!0}catch{return!1}}function Ha(i){return i.constructor===String}var vm=bo;var xm=Jt(Sn()),Th=vm.localStorage,Ih=class extends xm.default{constructor(){super(),window.addEventListener("online",()=>{for(let[e,t]of Th)if(e.startsWith("MI_LOGPACKAGE:")){let n=JSON.parse(t);n.timestamp=e.replace("MI_LOGPACKAGE:",""),this.dispatch(n)}})}async dispatch(e){navigator.onLine?await it.sendLogPackage(e)?Th.removeItem(`MI_LOGPACKAGE:${e.timestamp}`):this.emit("error",{apiKey:e.apiKey}):Th.setItem(`MI_LOGPACKAGE:${e.timestamp}`,JSON.stringify(e))}},Ga=new Ih;E();var Rh=class{#e;#t;#n;#i;constructor(e,t,n){this.#e=Object.freeze(e),this.#t=Object.freeze(t),this.#n=n,this.#i=Date.now()}get apiKey(){return this.#e}get timestamp(){return this.#i}toJSON(){return{apiKey:this.#e,entries:this.#n,sessionData:this.#t}}},bm=Rh;var Ch=class{#e;#t;#n;constructor(e){this.apiKey=e,this.#t=[],this.#n={component:"MapsIndoors JavaScript SDK",componentVersion:ce.version,deviceUserAgent:window.navigator.userAgent,hostApplicationName:location.hostname,sessionId:xo(),sessionStartDate:new Date().toISOString()},this.interval||(this.interval=setInterval(()=>{this.flush()},3e4))}get apiKey(){return this.#e}set apiKey(e){!this.#e&&e>""&&(this.#e=e)}log(e){this.#t.push(e),this.#t.length===1e3&&this.flush()}async flush(){if(this.#t.length!==0){let e=new bm(this.#e,this.#n,this.#t);this.#t=[],await Ga.dispatch(e)}}dismiss(){this.#n=null,this.#t=null}},Lh=Ch;E();var pt=Object.freeze({appLifeTime:{ENTERED_FOREGROUND:{domain:"app_life_time",event:"entered_foreground"},ENTERED_BACKGROUND:{domain:"app_life_time",event:"entered_background"},MAP_INSTANTIATED:{domain:"app_life_time",event:"map_instantiated"},MAPSINDOORS_INSTANTIATED:{domain:"app_life_time",event:"mapsindoors_instantiated"},SDK_LOADED:{domain:"app_life_time",event:"sdk_loaded"},SDK_UNLOADED:{domain:"app_life_time",event:"sdk_unloaded"}},configuration:{LANGUAGE_CHANGED:{domain:"configuration",event:"language_changed"}},directions:{DIRECTIONS_REQUESTED:{domain:"directions",event:"directions_requested"},DIRECTIONS_RENDERED:{domain:"directions",event:"directions_rendered"}},liveData:{LIVEDATA_ENABLED_FOR_MAP:{domain:"live_data",event:"livedata_enabled_for_map"},SUBSCRIPTION_STARTED:{domain:"live_data",event:"subscription_started"},SUBSCRIPTION_STOPPED:{domain:"live_data",event:"subscription_stopped"}},map:{MAP_CLICKED:{domain:"map",event:"map_clicked"}},search:{SEARCH_PERFORMED:{domain:"search",event:"search_performed"}}});var Ph=class{#e;#t;constructor(){this.#e=!1,ce.on("apikey_changed",()=>{this.enable()}),ce.on("eventlogging_enabled",()=>{this.enable()}),ce.on("eventlogging_disabled",()=>{this.disable()}),ce.on("language_changed",()=>{this.log(pt.configuration.LANGUAGE_CHANGED)}),Ga.on("error",({apiKey:e})=>{e===this.#t.apiKey&&this.disable()}),window.addEventListener("beforeunload",()=>{this&&this.#t&&(this.log(pt.appLifeTime.SDK_UNLOADED),this.#t.flush())}),window.addEventListener("focus",()=>{this.log(pt.appLifeTime.ENTERED_FOREGROUND)}),window.addEventListener("blur",()=>{this.log(pt.appLifeTime.ENTERED_BACKGROUND)}),this.enable().then(()=>{this.log(pt.appLifeTime.SDK_LOADED)})}get enabled(){return this.#e}async enable(){let e=await ws.getConfig(),t=e&&e.logConfig&&e.logConfig.eventLoggingEnabled===!0,n=ce.eventLoggingEnabled;t===!0&&n===!0?(this.#e===!1||ce.apiKey!==this.#t.apiKey)&&(this.#t=new Lh(ce.apiKey),this.#e=!0):this.disable()}disable(){this.#e===!0&&(this.#e=!1,this.#t.dismiss(),this.#t=null)}log(e,t){this.#e&&this.#t instanceof Lh&&this.#t.log({logType:"event",domain:e.domain,name:e.event,parameters:t,date:new Date().toISOString()})}},Rt=new Ph;E();E();var Zt=Object.freeze({CENTER:"center",ABOVE:"above",RIGHT:"right",BELOW:"below",LEFT:"left"}),Qn=Object.freeze({TOP_LEFT:"top_left",TOP_RIGHT:"top_right",BOTTOM_RIGHT:"bottom_right",BOTTOM_LEFT:"bottom_left"});var Nh=new Map,Ct=class{constructor({backgroundColor:e="#1E2025",fontFamily:t='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:n="14px",fontWeight:s="bold",position:r=Qn.BOTTOM_LEFT,size:o={width:24,height:24},strokeColor:a="#fafafa",strokeWidth:l=0,text:c="",textColor:h="#FCFCFC"}={}){Object.assign(this,{backgroundColor:e,fontFamily:t,fontSize:n,fontWeight:s,position:r,size:o,strokeColor:a,strokeWidth:l,text:c,textColor:h})}overlay(e,t={}){let n=Object.assign({radius:8,scale:1},this,t),s=`${e?.src}-${JSON.stringify(n)}`;return Nh.has(s)?Promise.resolve(Nh.get(s)):new Promise(r=>{let{size:o,strokeColor:a,strokeWidth:l,radius:c,position:h,text:u,backgroundColor:f,textColor:d,scale:y}=n,{width:g,height:p}=e instanceof Image?o:{width:0,height:0},m=fv(h),M=Math.min(g,p)/2,b=c*y,S=l*y,O=0,L=0,R=Math.ceil(M+M*Math.cos(ur(m))),C=Math.ceil(M+M*Math.sin(ur(m))),j=Math.max(R+b+S-(M<<1),-(R-(b+S)),0),v=Math.max(C+b+S-(M<<1),-(C-(b+S)),0);O=j,L=v,R<M?R+=j:R-=(M<<1)-g-j,C<M?C+=v:C-=(M<<1)-p-v;let _=document.createElement("canvas"),x=_.getContext("2d");x.imageSmoothingQuality="high",x.textAlign="center",x.textBaseline="middle",x.font=`${this.fontWeight} ${this.fontSize}  ${this.fontFamily}`;let T=x.measureText(u);if(_.width=Math.max(g+Math.ceil(j*2),Math.ceil(T.width+R+S*2)),_.height=p+Math.ceil(v*2),e instanceof Image&&x.drawImage(e,O,L,g,p),x.textAlign="center",x.textBaseline="middle",x.font=`${this.fontWeight} ${this.fontSize}  ${this.fontFamily}`,x.lineWidth=S,x.strokeStyle=a,T.width>b*1.6){let U=Math.ceil(T.width-b),N=R+U/2;x.beginPath(),x.arc(R,C,b,ur(90),ur(270),!1),x.arc(R+U,C,b,ur(270),ur(90),!1),x.closePath(),x.fillStyle=f,x.fill(),l>0&&x.stroke(),x.fillStyle=d,x.fillText(u,N,C)}else x.arc(R,C,b,0,Math.PI*2,!0),x.fillStyle=f,l>0&&x.stroke(),x.fill(),x.fillStyle=d,x.fillText(u,R,C);let P=new Image;P.onload=()=>{Nh.set(s,P),r(P)},P.src=_.toDataURL("image/png")})}};function fv(i){switch(i?.toString()?.toLowerCase()){case"1":case Qn.TOP_LEFT:return 225;case"2":case Qn.TOP_RIGHT:return 315;case"3":case Qn.BOTTOM_RIGHT:return 45;case"4":case Qn.BOTTOM_LEFT:default:return 135}}function ur(i){return i*(Math.PI/180)}Ct.UnavailableBadge=new Ct({text:"\xD7",backgroundColor:"#DE1B1B"});Ct.AvailableBadge=new Ct({text:"\u2713",backgroundColor:"#2a844e",fontSize:"12px"});Ct.TextBadge=new Ct({fontSize:"11px"});Ct.BadgePosition=Qn;Object.freeze(Ct);E();E();E();var Mm=Jt(Sn());E();function Oh(i,e,t){let n=Object(i);Object.prototype.hasOwnProperty.call(n,t)||(n[t]=n[e]),Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}function Ke(i){return i==null}function Yi(i){return JSON.parse(JSON.stringify(i))}var Dh=class extends Mm.default{#e=new Map;constructor(){super()}set(e,t,n=!1){if(typeof e=="string"){let s=this.#e.get(e);(n||s!==t)&&(this.#e.set(e,t),this.emit(`${e.toLowerCase()}_changed`,{newValue:t,oldValue:s}),this.emit("changed",{key:e,newValue:t,oldValue:s}))}}setValues(e={}){if(typeof e=="object"&&!Ke(e))for(let t of Object.keys(e))this.set(t,e[t])}get(e){return this.#e.get(e)}getValues(){return Object.fromEntries(this.#e)}},Et=Dh;E();E();function jt(i){return i*Math.PI/180}function As(i){return i*180/Math.PI}function Sm(i){return 1/Math.cos(i)}function Mo(i,e){return Number(Number(i).toFixed(e))}var Wa=6378137,dv=12756274,Es=4007501668557849e-8,pi=class{constructor(e,t,n){this.lat=e,this.lng=t,this.floor=n}toUrlValue(){return pi.toUrlValue(this)}toArray(){return pi.toArray(this)}computeDistanceTo(e){return pi.computeDistanceBetween(this,e)}computeDestination(e,t){return pi.computeDestination(this,e,t)}static create(e){let t;return e instanceof Array&&e.length>=2?t=[e[1],e[0],e[2]]:e.coordinates instanceof Array&&e.coordinates.length>=2?t=[e.coordinates[1],e.coordinates[0],e.coordinates[2]]:e.geometry&&e.geometry.coordinates instanceof Array&&e.geometry.coordinates.length>=2?t=[e.geometry.coordinates[1],e.geometry.coordinates[0],e.geometry.coordinates[2]]:e.lat&&e.lng&&(t=[e.lat,e.lng,e.floor]),t?new pi(...t):null}static toUrlValue(e){return`${e.lat},${e.lng},${e.floor||0}`}static toArray(e){return[e.lng,e.lat]}static computeDistanceBetween(e,t){let n=jt(t.lat-e.lat),s=jt(t.lng-e.lng),r=jt(e.lat),o=jt(t.lat),a=.5-Math.cos(n)/2+Math.cos(r)*Math.cos(o)*(1-Math.cos(s))/2;return dv*Math.asin(Math.sqrt(a))}static computeDestination(e,t,n){let s=jt(e.lng),r=jt(e.lat),o=jt(n),a=Math.asin(Math.sin(r)*Math.cos(t/Wa)+Math.cos(r)*Math.sin(t/Wa)*Math.cos(o)),l=s+Math.atan2(Math.sin(o)*Math.sin(t/Wa)*Math.cos(r),Math.cos(t/Wa)-Math.sin(r)*Math.sin(a));return new pi(As(a),As(l))}static getMeterPerPixel(e,t){return Math.cos(jt(e))*Es/(256*2**t)}static getPixelsPerMeter(e,t){return 256/(Math.cos(jt(e))*Es/2**t)}},Lt=pi;var Qt={color:{comment:"These colors are based upon the work done by CA Technologies with Mineral UI: https://github.com/mineral-ui/mineral-ui",black:{base:{value:"hsl(223, 11%, 13%)",comment:"The a11y rating of white on top of this color: AAA"},black:{value:"hsl(0, 0%, 0%)",comment:"The a11y rating of white on top of this color: AAA"}},white:{base:{value:"hsl(0, 0%, 99%)",comment:"This is the standard background color."},white:{value:"hsl(0, 0%, 100%)"}},transparent:{base:{value:"hsla(0, 0, 0, 0%)",comment:"This is a 100% transparent color."}},hotorchid:{base:{value:"#EF6CCE"}},gray:{base:{value:"{color.gray.60.value}"},"10":{value:"hsl(216, 33%, 97%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(216, 33%, 94%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(218, 31%, 90%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(218, 28%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(217, 22%, 74%)",comment:"The a11y rating of black on top of this color: AAA"},"60":{value:"hsl(217, 15%, 61%)",comment:"The a11y rating of black on top of this color: AA"},"70":{value:"hsl(217, 10%, 49%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA"},"80":{value:"hsl(218, 11%, 39%)",comment:"The a11y rating of white on top of this color: AA"},"90":{value:"hsl(215, 11%, 30%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(217, 11%, 23%)",comment:"The a11y rating of white on top of this color: AAA"}},red:{base:{value:"{color.red.60.value}"},"10":{value:"hsl(0, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(0, 79%, 91%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(0, 87%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(0, 92%, 77%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(0, 89%, 64%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(0, 78%, 49%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(0, 87%, 39%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(0, 82%, 31%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(0, 67%, 24%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(0, 50%, 18%)",comment:"The a11y rating of white on top of this color: AAA"}},green:{base:{value:"{color.green.60.value}"},"10":{value:"hsl(144, 71%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(144, 65%, 80%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(144, 57%, 67%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(144, 47%, 55%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(144, 46%, 43%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(144, 52%, 34%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(144, 53%, 27%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(144, 52%, 21%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(144, 49%, 16%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(143, 43%, 12%)",comment:"The a11y rating of white on top of this color: AAA"}},blue:{base:{value:"{color.blue.60.value}"},"10":{value:"hsl(215, 67%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(217, 88%, 90%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(217, 93%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(217, 92%, 75%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(217, 84%, 64%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(217, 69%, 52%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(217, 74%, 43%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(217, 80%, 33%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(217, 75%, 25%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(218, 48%, 16%)",comment:"The a11y rating of white on top of this color: AAA"}},bronze:{base:{value:"{color.bronze.60.value}"},"10":{value:"hsl(33, 79%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(33, 88%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(33, 86%, 71%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(33, 79%, 58%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(33, 85%, 44%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(33, 100%, 34%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(33, 96%, 28%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(33, 87%, 22%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(33, 75%, 17%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(32, 62%, 12%)",comment:"The a11y rating of white on top of this color: AAA"}},purple:{base:{value:"{color.purple.60.value}"},"10":{value:"hsl(270, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(271, 77%, 92%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(271, 79%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(270, 77%, 78%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(270, 72%, 68%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(270, 61%, 59%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(270, 52%, 49%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(270, 57%, 39%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(270, 56%, 29%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(270, 49%, 22%)",comment:"The a11y rating of white on top of this color: AAA"}},magenta:{base:{value:"{color.magenta.60.value}"},"10":{value:"hsl(336, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(335, 79%, 91%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(335, 88%, 84%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(335, 87%, 76%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(335, 81%, 63%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(335, 71%, 49%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(335, 81%, 38%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(335, 77%, 31%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(335, 64%, 23%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(336, 52%, 17%)",comment:"The a11y rating of white on top of this color: AAA"}},indigo:{base:{value:"{color.indigo.60.value}"},"10":{value:"hsl(240, 63%, 97%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(240, 84%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(240, 91%, 87%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(240, 89%, 82%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(240, 81%, 74%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(240, 72%, 65%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(240, 59%, 56%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(240, 53%, 46%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(240, 55%, 35%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(240, 46%, 23%)",comment:"The a11y rating of white on top of this color: AAA"}},sky:{base:{value:"{color.sky.60.value}"},"10":{value:"hsl(200, 64%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(200, 86%, 86%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(200, 87%, 76%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(200, 81%, 63%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(200, 73%, 49%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(200, 87%, 37%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(200, 92%, 30%)",comment:"The a11y rating of white on top of this color: AA."},"80":{value:"hsl(200, 90%, 23%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(201, 80%, 18%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(200, 65%, 13%)",comment:"The a11y rating of white on top of this color: AAA"}},teal:{base:{value:"{color.teal.60.value}"},"10":{value:"hsl(177, 54%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(177, 66%, 79%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(176, 59%, 64%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(176, 49%, 51%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(176, 60%, 39%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(176, 70%, 30%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(176, 72%, 24%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(176, 73%, 19%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(176, 69%, 14%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(176, 65%, 10%)",comment:"The a11y rating of white on top of this color: AAA"}},slate:{base:{value:"{color.slate.60.value}"},"10":{value:"hsl(198, 38%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(206, 68%, 88%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(206, 63%, 79%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(205, 55%, 69%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(205, 42%, 55%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(205, 37%, 45%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(205, 40%, 36%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(204, 38%, 28%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(204, 33%, 21%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(205, 25%, 15%)",comment:"The a11y rating of white on top of this color: AAA"}},dusk:{base:{value:"{color.dusk.60.value}"},"10":{value:"hsl(264, 24%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(256, 63%, 92%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(256, 61%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(255, 52%, 77%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(255, 43%, 67%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(254, 33%, 55%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(255, 29%, 46%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(255, 30%, 36%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(255, 26%, 26%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(253, 20%, 18%)",comment:"The a11y rating of white on top of this color: AAA"}}}};E();E();E();E();var ei=Object.freeze({RIGHT:"left",LEFT:"right",TOP:"bottom",BOTTOM:"top"});var se={clickable:!0,visible:!0,iconVisible:!0,zoomFrom:16,zoomTo:999,icon:"https://app.mapsindoors.com/mapsindoors/cms/assets/icons/misc/default-marker.png?71488",iconScale:1,iconSize:{width:20,height:20},iconPlacement:Zt.CENTER,labelVisible:!0,label:"{{name}}",labelZoomFrom:16,labelType:"FLOATING",labelStyle:{textSize:12,textColor:"#1F2937",textOpacity:1,haloColor:"#ffffff",haloWidth:2,haloBlur:0,bearing:0,graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-lightgray.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]},position:ei.TOP},labelZoomTo:999,polygon:{visible:!1,zoomFrom:18,zoomTo:999,strokeWidth:2,strokeColor:Qt.color.blue[60].value,strokeOpacity:1,fillColor:Qt.color.blue[60].value,fillOpacity:.2},model2D:{visible:!0,zoomFrom:16,zoomTo:999,model:null,widthMeters:0,heightMeters:0,bearing:0},walls:{visible:!0,color:Qt.color.gray[70].value,height:2,zoomFrom:16,zoomTo:999},extrusion:{visible:!0,color:Qt.color.gray[50].value,height:2.25,zoomFrom:16,zoomTo:999},model3D:{visible:!0,zoomFrom:16,zoomTo:999,model:null,rotationX:0,rotationY:0,rotationZ:0},badge:{visible:!1,zoomFrom:18,zoomTo:22,radius:5,strokeWidth:2,strokeColor:"#3071D9",fillColor:"#3071D9",scale:1,position:Qn.TOP_LEFT}},Xa={polygonVisible:!0,polygonStrokeColor:Qt.color.blue[60].value,polygonStrokeOpacity:1,polygonStrokeWeight:2,polygonFillOpacity:0,polygonZoomFrom:18,polygonZoomTo:999,clickable:!1},wm={iconScale:1.25,polygon:{lightnessFactor:-.1},labelStyle:{graphic:{stretchX:[[15,385]],stretchY:[[15,385]],content:[24,24,376,376]}},extrusion:{lightnessFactor:-.1},badge:{scale:1.25}},Ts={zoomFrom:15,zoomTo:999,polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},labelStyle:{graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-highlight.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]}},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},badge:{visible:!0,zoomFrom:15,zoomTo:999,radius:6,strokeWidth:4,strokeColor:"#ffffff",fillColor:"#ec4899",scale:1,position:Qn.TOP_LEFT}},Is={zoomFrom:0,zoomTo:999,visible:!0,iconVisible:!0,icon:"https://app.mapsindoors.com/mapsindoors/gfx/select-pin.png",iconScale:1,iconPlacement:Zt.ABOVE,iconSize:{width:24,height:28},polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},labelStyle:{graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-selection.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]}},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1}},Am={zoomFrom:15,zoomTo:999,iconScale:1.25,polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},badge:{visible:!0,zoomFrom:15,zoomTo:999,radius:6,strokeWidth:4,strokeColor:"#ffffff",fillColor:"#ec4899",scale:1.25,position:Qn.TOP_LEFT}},Em={zoomFrom:0,zoomTo:999,visible:!0,iconVisible:!0,icon:"https://app.mapsindoors.com/mapsindoors/gfx/select-pin.png",iconScale:1.25,iconPlacement:Zt.ABOVE,iconSize:{width:24,height:28},polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15}},mv={iconVisible:!1,labelVisible:!1,zoomFrom:10,zoomTo:15,label:"{{name}}",clickable:!1,polygonVisible:!1},gv={iconVisible:!1,labelVisible:!1,zoomFrom:15,zoomTo:18,label:"{{name}}",clickable:!1,polygonVisible:!1},yv={iconVisible:!1,labelVisible:!1,clickable:!1,polygonVisible:!1},Tm={MI_VENUE:mv,MI_FLOOR:yv,MI_BUILDING:gv};E();var Uh=class{#e=new Map;get(e){if(e){let t=this.#e.get(e);return t||(t=fetch(e).then(_v).then(n=>n.blob()).then(n=>URL.createObjectURL(n)).then(n=>Im(n)).catch(()=>Im("data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")),this.#e.set(e,t)),t}return Promise.resolve(null)}clear(){this.#e.forEach(async e=>{let t=await e;URL.revokeObjectURL(t.src)}),this.#e.clear()}};function _v(i){if(!i.ok)throw Error(i.statusText);return i}function Im(i){return new Promise(e=>{let t=new Image;t.onload=()=>e(t),t.onerror=()=>e(null),t.src=i})}var vv=new Uh,fr=vv;E();var Fh=class{#e=new Map;constructor(){}get(e){if(!e)return Promise.resolve(null);if(this.#e.has(e))return this.#e.get(e);let t=fetch(e).then(xv).then(n=>n.blob()).then(n=>URL.createObjectURL(n)).catch(()=>(this.#e.delete(e),null));return this.#e.set(e,t),t}has(e){return this.#e.has(e)}clear(){for(let e of this.#e.keys())this.#e.get(e).then(URL.revokeObjectURL),this.#e.delete(e);this.#e.clear()}};function xv(i){if(!i.ok)throw Error(i.statusText);return i}var bv=new Fh,Rm=bv;E();var Bh=class{static removeHtmlFrom(e){return new DOMParser().parseFromString(e,"text/html").body.textContent||""}static capitalize(e){return typeof e!="string"?"":`${e.charAt(0).toUpperCase()}${e.slice(1)}`}},mi=Bh;var st=class{constructor(e){Object.assign(this,e)}set imageSize(e){this.iconSize=e}set imageScale(e){this.iconScale=e}set polygonStrokeWidth(e){this.polygonStrokeWeight=e}set polygon(e){if(e)for(let[t,n]of Object.entries(e))this[`polygon${mi.capitalize(t)}`]=n}set labelStyle(e){if(e)for(let[t,n]of Object.entries(e)){let s=t.toLowerCase().startsWith("label")?t.slice(5):t;this[`labelStyle${mi.capitalize(s)}`]=n}}set model2D(e){if(e)for(let[t,n]of Object.entries(e))this[`model2D${mi.capitalize(t)}`]=n}set walls(e){if(e)for(let[t,n]of Object.entries(e))this[`walls${mi.capitalize(t)}`]=n}set extrusion(e){if(e)for(let[t,n]of Object.entries(e))this[`extrusion${mi.capitalize(t)}`]=n}set model3D(e){if(e)for(let[t,n]of Object.entries(e))this[`model3D${mi.capitalize(t)}`]=n}set badge(e){if(e)for(let[t,n]of Object.entries(e))this[`badge${mi.capitalize(t)}`]=n}getIcon(){return this.icon instanceof Image?Promise.resolve(this.icon):this._getIconUrl()>""?fr.get(this._getIconUrl()):Promise.resolve(null)}getIconSize(){let{width:e,height:t}=this.iconSize||{};return e>=0&&t>=0?this.iconSize:{width:0,height:0}}_getIconUrl(){let e=this.icon;if(e){let t=this.getIconSize(),n=Math.max(2,window.devicePixelRatio||1),s=n*t.width,r=n*t.height,o=new URL(e);o.searchParams.append("width",s),o.searchParams.append("height",r),o.searchParams.append("fitMode","cover"),e=o.toString()}return e}get3DModel(){return this.model3DModel?Rm.get(this.model3DModel):Promise.resolve(null)}static merge(e){return e instanceof Array&&e.length>0?e.reduce((t,n={})=>{let s=n instanceof st;if(!s&&Object.keys(n).length===0)return t;n=s?n:new st(n);for(let r of Object.keys(n))(t[r]===void 0||n[r]!==null&&n[r]!==void 0)&&(t[r]=n[r]);return t},new st):null}static get DEFAULT_RULE(){return Object.freeze(Mv)}static get MAX_ZOOM(){return 999}static get IconPlacement(){return Zt}},Mv=new st(se);E();function Cm(i,e={}){let t=Number(i),n=Object.keys(e?.floors??{});if(n.length===0)return;if(!Number.isNaN(t)&&n.includes(t.toString()))return i;if(Number.isFinite(Number(e.defaultFloor)))return Number(e.defaultFloor);if(i===void 0)return;let s=Object.keys(e.floors).map(Number).sort((r,o)=>o-r).reduce((r,o)=>Math.abs(t-o)<=Math.abs(t-r)?o:r);return parseInt(s)}var lu={};em(lu,{AppConfigService:()=>ws,BookingService:()=>mg,DirectionsService:()=>Za,DistanceMatrixService:()=>dr,GeoCodeService:()=>pr,LocationsService:()=>fn,ShareService:()=>ox,SolutionsService:()=>Ps,VenuesService:()=>mt});E();E();E();var Dt=class{static fromGeoJSON(e){if(!e)throw new Error("Invalid GeoJSON object!");if(Array.isArray(e.bbox)&&(e.bbox.length===4||e.bbox.length===6))return{south:e.bbox[1],west:e.bbox[0],north:e.bbox[3],east:e.bbox[2]};let t=(e.type||"").toLowerCase(),n={south:90,west:180,north:-90,east:-180};switch(t){case"feature":return this.fromGeoJSON(e?.geometry);case"point":return{south:e.coordinates[1],west:e.coordinates[0],north:e.coordinates[1],east:e.coordinates[0]};case"linestring":case"multipoint":return s(n,e.coordinates);case"polygon":case"multilinestring":return e.coordinates.reduce(s,n);case"multipolygon":return e.coordinates.reduce((r,o)=>o.reduce(s,r),n);case"geometrycollection":return e.geometries.reduce((r,o)=>this.combine(r,this.fromGeoJSON(o)),n);case"featurecollection":return e.features.reduce((r,o)=>this.combine(r,this.fromGeoJSON(o.geometry)),n);default:throw new Error("Invalid GeoJSON object!")}function s(r,o){let a=o.map(c=>c[0]),l=o.map(c=>c[1]);return r.south=Math.min(r.south,...l),r.west=Math.min(r.west,...a),r.north=Math.max(r.north,...l),r.east=Math.max(r.east,...a),r}}static combine(...e){return e.reduce((t,n)=>t?{south:Math.min(t.south,n.south),west:Math.min(t.west,n.west),north:Math.max(t.north,n.north),east:Math.max(t.east,n.east)}:n)}static equals(e,t){return e.south===t.south&&e.west===t.west&&e.north===t.north&&e.east===t.east}static fromCenterAndRadius(e,t){let n=t*1.414,{lat:s,lng:r}=Lt.computeDestination(e,n,45),{lat:o,lng:a}=Lt.computeDestination(e,n,225);return{south:o,west:a,north:s,east:r}}static getCenter(e){return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}static toUrlValue(e){return Dt.isLatLngBounds(e)?`${e.south},${e.west},${e.north},${e.east}`:""}static isLatLngBounds(e){let{south:t,west:n,north:s,east:r}=e??{};return!isNaN(Number.parseFloat(t))&&!isNaN(Number.parseFloat(n))&&!isNaN(Number.parseFloat(s))&&!isNaN(Number.parseFloat(r))}};E();E();E();var Xe=Object.freeze({RAMP:"ramp",STAIRS:"stairs",STEPS:"steps",LADDER:"ladder",ESCALATOR:"escalator",TRAVELATOR:"travelator",ELEVATOR:"elevator",UNCLASSIFIED:"unclassified",RESIDENTIAL:"residential",FOOTWAY:"footway",WHEELCHAIR_RAMP:"wheelchairramp",WHEELCHAIR_LIFT:"wheelchairlift"});var dr=class{static getDistanceMatrix(e={}){if(!e.graphId)throw new kh("graphId");if(!e.origins)throw new kh("origins");if(!e.destinations)throw new kh("destinations");let t=["steps","stairs"].indexOf(e.avoid?.toLowerCase())>-1?[Xe.STAIRS,Xe.STEPS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(","),n="";e.origins=[].concat(e.origins),e.destinations=[].concat(e.destinations),Array.isArray(e?.excludeHighwayTypes)?(t=e?.avoidHighwayTypes?.join(",")??"",n=e.excludeHighwayTypes.join(",")):Array.isArray(e?.avoidHighwayTypes)&&(t=e.avoidHighwayTypes.join(","));let s=e.origins.map(a=>Object.prototype.hasOwnProperty.call(a,"lat")?Lt.toUrlValue(a):a).join("|"),r=e.destinations.map(a=>Object.prototype.hasOwnProperty.call(a,"lat")?Lt.toUrlValue(a):a).join("|"),o={avoid:t,exclude:n,origins:s,destinations:r,mode:e.travelMode,graphId:e.graphId,appUserRoleIds:[].concat(e.userRoles).join(","),v:7};return it.getJson(`distancematrix/${e.graphId}`,{search:o}).then(a=>(a.status==="OK"&&(a.origins=e.origins,a.destinations=e.destinations,delete a.origin_addresses,delete a.destination_addresses),a))}};function kh(i){this.message=`The reqired paramter "${i}" is missing!`}E();var pr=class{static reverseGeoCode(e){return e=[].concat(e),e=e.map(t=>`${t.lat},${t.lng}`),it.getJson("geocode",{search:{point:e}})}};var en=class{static getRoute({origin:e,destination:t,graphId:n,userRoles:s=[],avoidStairs:r,avoidHighwayTypes:o,excludeHighwayTypes:a,stops:l=[],optimize:c=!1}){let h="",u=r?[Xe.STAIRS,Xe.STEPS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(",");s&&s.length===0&&(s=(ce.userRoles||[]).map(d=>d.id)),Array.isArray(a)?(u=Array.isArray(o)?o.join(","):"",h=a.join(",")):Array.isArray(o)&&(u=o.join(","));let f={origin:typeof e=="string"?e:Lt.toUrlValue(e),destination:typeof t=="string"?t:Lt.toUrlValue(t),appUserRoleIds:[].concat(s).join(","),mode:"WALKING",avoid:u,exclude:h,stops:l.map(d=>Object.prototype.hasOwnProperty.call(d,"lat")?Lt.toUrlValue(d):d).join("|"),optimize:c,v:7};return it.getJson(`directions/${n}`,{search:f}).then(({routes:d,status:y})=>{if(y!=="OK")return{route:null,status:y};if(d&&d instanceof Array){let g=d[0];return g.stops=[],g.legs=g.legs.reduce((p,m)=>{let M=["route_start","stop_reached","floor_change"].includes(m?.leg_start_reason),b=p.length===0&&wv(e);if(m.leg_start_reason==="stop_reached"&&g.stops.push(m.start_location),m=Ev(m),b&&(m=Tv(m,e)),M)p.push(m);else{let S=p.length-1;p[S]=Av(p[S],m)}return p},[]),{route:g,status:y}}return{route:null,status:""}}).then(Sv)}static getGraphId(e){return e=[].concat(e).map(t=>typeof t=="string"?t:Lt.toUrlValue(t)),it.getJson("directions/contains",{search:{point:e,v:7}})}static getDetails(e){return it.getJson(`directions/details/${e}`,{search:{v:7}})}static getEntryPointsFor(e,t){if(!e>"")return Promise.resolve([]);if(e instanceof Array)return Promise.all(e.map(n=>en.getEntryPointsFor(n,t)));if(e>""){let n=e;return it.getJson(`directions/details/${n}`,{search:{v:7}}).then(({entryPoints:s})=>s instanceof Array&&s.length>0?(t>""&&(s=s.filter(r=>(r.travelModes||[]).some(a=>a.toUpperCase()===t.toUpperCase()))),s.map(r=>({lat:r.coordinates[1],lng:r.coordinates[0],floor:r.coordinates[2],label:r.label?r.label[Object.keys(r.label)[0]]:null,travelModes:r.travelModes}))):Promise.resolve([]))}}static getDistanceMatrix(e={}){return dr.getDistanceMatrix(e)}};async function Sv({route:i,status:e}){if(i&&i.legs&&i.legs.length>0){let t=i.legs.reduce((a,l)=>a.concat(l.steps),[]),n=t.reduce((a,l)=>a.concat([l.start_location,l.end_location]),[]),s=await pr.reverseGeoCode(n),[r,o]=await Promise.all([mt.getVenues(),mt.getBuildings()]);t.forEach(a=>{let l=s.shift(),c=s.shift();a.start_context={venue:l.venue?r.find(h=>h.id===l.venue.id):null,building:l.building?o.find(h=>h.id===l.building.id):null,floor:{name:a.start_location.floor_name,index:a.start_location.zLevel}},a.end_context={venue:c.venue?r.find(h=>h.id===c.venue.id):null,building:c.building?o.find(h=>h.id===c.building.id):null,floor:{name:a.end_location.floor_name,index:a.end_location.zLevel}}})}return{route:i,status:e}}function wv(i){return i.travelModes&&i.travelModes.length===1&&["driving","bicycling"].includes(i.travelModes[0].toLowerCase())}function Av(...i){return i.reduce((e,t)=>e?(e.steps=e.steps.concat(t.steps),e.end_location=t.end_location,e.distance={text:"",value:e.distance.value+t.distance.value},e.duration={text:"",value:e.duration.value+t.duration.value},e.geometry.coordinates=e.geometry.coordinates.concat(t.geometry.coordinates),e.leg_end_reason=t.leg_end_reason,e.stop_index=t.stop_index,e):t)}function Ev(i){return i.geometry={type:"LineString",coordinates:[]},i.steps=i.steps.reduce((e,t)=>{let n=e[e.length-1],s=t.geometry.map(r=>[r.lng,r.lat]);if(t.geometry={type:"LineString",coordinates:s},i.geometry.coordinates=i.geometry.coordinates.concat(s),t.route_context=t.abutters==="OutsideOnVenue"?"Outside":t.abutters,t.instructions=t.instructions||t.html_instructions,t.start_context=null,t.end_context=null,delete t.html_instructions,delete t.abutters,!n||n.route_context!==t.route_context||n.travel_mode!==t.travel_mode){let r=Object.assign({},t);r.steps=[t],e.push(r)}else n.geometry.coordinates=[].concat(n.geometry.coordinates,s),n.end_location=t.end_location,n.distance={text:"",value:n.distance.value+t.distance.value},n.duration={text:"",value:n.duration.value+t.duration.value},n.steps.push(t);return e},[]),i}function Tv(i,e){return i.steps[0].label=e.label,i.steps[0].parking=!0,i.steps.map(t=>(t.travel_mode="WALKING",t.steps.map(n=>(n.travel_mode="WALKING",n)),t)),i}E();function So(i=[],e,t){let n=0,s=i.length;for(t=t instanceof Function?t:(r,o)=>r<o;n<s;){let r=n+s>>>1;t(i[r],e)?n=r+1:s=r}return i.splice(n,0,e),i.length}var Za=class{#e;constructor(e){this.#e=e}setExternalProvider(e){this.#e=e}async getRoute({origin:e,destination:t,travelMode:n="WALKING",avoidStairs:s=!1,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a=[],stops:l=[],optimize:c=!1}){let h;a.length>0?a=[].concat(a):ce.userRoles&&ce.userRoles.length>0&&(a=ce.userRoles.map(y=>y.id));let u=this.#e,f={origin:e,destination:t,travelMode:n,avoidStairs:s,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a,stops:l,optimize:c},d={travel_modes:n,avoid:`${s?"stairs":""}`,avoidHighwayTypes:r,excludeHighwayTypes:o,user_roles:a?a.join(","):""};if(e&&t){let[y,g]=await en.getGraphId([e,t]);if(y===g&&y>"")return en.getRoute({...f,graphId:y}).then(p=>p.route).then(p=>(d.provider="mapsindoors",Rt.log(pt.directions.DIRECTIONS_REQUESTED,d),p));if(u){let[p,m]=await en.getEntryPointsFor([y,g],n);if(!y&&!g)h=this.#e.getRoute({origin:e,destination:t,travelMode:n}).then(M=>M.route);else if(p.length>0&&!g)h=this._getOutboundRoute({...f,waypoints:p,graphId:y});else if(m.length>0&&!y)h=this._getInboundRoute({...f,waypoints:m,graphId:g});else if(p.length>0&&m.length>0){let M={origin:p,destination:m},b={origin:y,destination:g};h=this._getRouteBetweenVenues({origin:e,destination:t,waypoints:M,graphIds:b,travelMode:n,avoidStairs:s,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a})}return d.provider=this.#e.ProviderName,Rt.log(pt.directions.DIRECTIONS_REQUESTED,d),h}}}async _getOutboundRoute({origin:e,destination:t,waypoints:n,travelMode:s,graphId:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c,stops:h=[],optimize:u=!1}){let f=Cv({travelMode:s,origin:e,destination:t,stops:h}),d=qa(s,n),y=Ya(f,d);y.splice(5);let g={avoid:o?[Xe.STAIRS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:y,graphId:r,origins:[e],travelMode:s,userRoles:c},p={destinations:[t],origins:y,travelMode:s},m=await Promise.all([en.getDistanceMatrix(g),this.#e.getDistanceMatrix(p)]),M=Ka(m);return M?await Promise.all([en.getRoute({origin:M.origin,destination:M.waypoints[0],travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r,stops:h,optimize:u}),this.#e.getRoute({origin:M.waypoints[0],destination:M.destination,travelMode:s})]).then(([S,O])=>zh(S.route,O.route)):void 0}async _getInboundRoute({origin:e,destination:t,waypoints:n,travelMode:s,graphId:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c,stops:h=[],optimize:u=!1}){let f=Rv({travelMode:s,origin:e,destination:t,stops:h}),d=qa(s,n),y=Ya(f,d);y.splice(5);let g={destinations:y,origins:[e],travelMode:s},p={avoid:o?[Xe.STAIRS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:[t],graphId:r,origins:y,travelMode:s,userRoles:c},m=await Promise.all([this.#e.getDistanceMatrix(g),en.getDistanceMatrix(p)]),M=Ka(m);return M?await Promise.all([this.#e.getRoute({origin:M.origin,destination:M.waypoints[0],travelMode:s}),en.getRoute({origin:M.waypoints[0],destination:M.destination,travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r,stops:h,optimize:u})]).then(([S,O])=>zh(S.route,O.route)):void 0}async _getRouteBetweenVenues({origin:e,destination:t,waypoints:n,travelMode:s,graphIds:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c}){let h=qa(s,n.origin),u=qa(s,n.destination),f=Ya(s==="WALKING"?t:e,h),d=Ya(s==="WALKING"?e:t,u);f.splice(5),d.splice(5);let y={destinations:d,origins:f,travelMode:s},g={avoid:o?[Xe.STAIRS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:f,graphId:r.origin,origins:[e],travelMode:s,userRoles:c},p={avoid:o?[Xe.STAIRS,Xe.LADDER,Xe.ESCALATOR].join(","):[Xe.WHEELCHAIR_RAMP,Xe.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:[t],graphId:r.destination,origins:d,travelMode:s,userRoles:c},m=await Promise.all([en.getDistanceMatrix(g),this.#e.getDistanceMatrix(y),en.getDistanceMatrix(p)]),M=Ka(m);return M?await Promise.all([en.getRoute({origin:M.origin,destination:M.waypoints[0],travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r.origin}),this.#e.getRoute({origin:M.waypoints[0],destination:M.waypoints[1],travelMode:s}),en.getRoute({origin:M.waypoints[1],destination:M.destination,travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r.destination})]).then(S=>zh(...S.map(O=>O.route))):void 0}};function Ka(i){let e=i.splice(-1,1)[0],t=i.splice(-1,1)[0];function n(r,o){return{text:"",value:r.distance.value+o.distance.value}}function s(r,o){return{text:"",value:r.duration.value+o.duration.value}}for(let[r,o]of t.rows.entries()){let a=[];for(let[l,c]of o.elements.entries())for(let h of e?.rows?.[l]?.elements??[])if(h&&c.status==="OK"&&h.status==="OK"){let u={distance:n(c,h),duration:s(c,h),destination:h.destination||e.destinations[0],origin:t.origins[r],status:h.status,waypoints:h.waypoints?[].concat(e.origins[l],h.waypoints):[e.origins[l]]};a.push(u)}else a.push(null);o.elements=a}if(i.length>0)return Ka([].concat(i,t));{let r=[];for(let o of t.rows[0].elements)o&&So(r,o,(a,l)=>a.distance.value<l.distance.value);return r[0]}}function qa(i,e){if(["driving","bicycling"].includes(i.toLowerCase())){let t=e.filter(n=>n.travelModes&&n.travelModes.length===1&&n.travelModes[0].toLowerCase()===i.toLowerCase());return t.length>0?t:e}else return e}function Ya(i,e){return e.reduce((t,n)=>{let s=Lt.computeDistanceBetween(n,i);return So(t,[s,n],(r,o)=>r[0]<o[0]),t},[]).map(t=>t[1])}function Iv(...i){return i.reduce((e,t)=>{if(e.length===0)return e.concat(t);let n=e.splice(-1,1)[0],s=t.splice(0,1)[0],r=n.steps.splice(-1,1)[0],o=s.steps.splice(0,1)[0],a={distance:{text:"",value:n.distance.value+s.distance.value},duration:{text:"",value:n.duration.value+s.duration.value},end_address:s.end_address,end_location:s.end_location,geometry:{type:"LineString",coordinates:n.geometry.coordinates.concat(s.geometry.coordinates)},leg_end_reason:s.leg_end_reason,leg_start_reason:s.leg_start_reason,stop_index:s.stop_index};if(o.parking===!0||o.travel_mode!==r.travel_mode)Object.assign(n,a,{steps:[].concat(n.steps,r,o,s.steps)});else{let l=Object.assign(r,{distance:{text:"",value:r.distance.value+o.distance.value},duration:{text:"",value:r.duration.value+o.duration.value},end_location:o.end_location,geometry:{type:"LineString",coordinates:r.geometry.coordinates.concat(o.geometry.coordinates)},steps:[].concat(r.steps,o.steps)});Object.assign(n,a,{steps:[].concat(n.steps,l,s.steps)})}return e.concat(n,t)},[])}function zh(...i){return i.reduce((e,t)=>{if(!e)return t;let n=Iv(e.legs,t.legs);return{bounds:Dt.combine(...n.map(r=>Dt.fromGeoJSON(r.geometry))),legs:n,copyrights:[e.copyrights,t.copyrights].join(" & "),warnings:[].concat(e.warnings,t.warnings),stops:[].concat(e.stops??[],t.stops??[]),ordered_stop_indexes:[].concat(e.ordered_stop_indexes??[],t.ordered_stop_indexes??[])}})}function Rv({travelMode:i,origin:e,destination:t,stops:n=[]}){return n.length>0?n[0]:i==="WALKING"?e:t}function Cv({travelMode:i,origin:e,destination:t,stops:n=[]}){return n.length>0?n[n.length-1]:i==="WALKING"?t:e}E();var dg=Jt(Sn());E();E();var Vh=class{#e=new Map;update(e,t){this.#e.has(e)||this.#e.set(e,new Map);let n=this.#e.get(e);n.get(t.domainType)?.timestamp>t.timestamp||n.set(t.domainType,t)}get(e){return this.#e.get(e)??new Map}getByDomain(e,t){return this.get(e)?.get(t)}remove(e,t){if(!this.#e.has(e))return;this.#e.get(e).delete(t)}},Ai=new Vh;var wo,$a,Lm,Ja,Pm,$t=class{constructor(){di(this,$a);di(this,Ja);di(this,wo,void 0);Object.defineProperty(this,"displayRule",{enumerable:!0,get:ph(this,$a,Lm),set:ph(this,Ja,Pm)})}getFieldForKey(e){let t=this.properties.fields;if(t&&e>""){if(t[e])return t[e];if(t[e.toLowerCase()])return t[e.toLowerCase()];let n=Object.keys(t).reduce((s,r)=>(s[r.toLowerCase()]=r,s),{});return t[n[e.toLowerCase()]]}}get liveUpdates(){return Ai.get(this.id)}getLiveDataForDomain(e){return Ai.getByDomain(this.id,e)}};wo=new WeakMap,$a=new WeakSet,Lm=function(){return Mn(this,wo)},Ja=new WeakSet,Pm=function(e){e instanceof st||(e=new st(e)),nm(this,wo,e)},fi($t,"MIType",Object.freeze({MI_VENUE:"MI_VENUE",MI_BUILDING:"MI_BUILDING",MI_BUILDING_OUTLINE:"MI_BUILDING_OUTLINE",MI_FLOOR:"MI_FLOOR"}));E();E();var gi=class{};fi(gi,"isString",e=>Object.prototype.toString.call(e)==="[object String]"),fi(gi,"isNumber",e=>Object.prototype.toString.call(e)==="[object Number]"),fi(gi,"isBoolean",e=>Object.prototype.toString.call(e)==="[object Boolean]"),fi(gi,"isUndefined",e=>e===void 0||typeof e>"u"),fi(gi,"isNull",e=>e===null),fi(gi,"optional",e=>t=>t==null||e(t)),fi(gi,"isAny",()=>!0);var un=gi;E();var ti=class{#e=new Map;constructor(){this.config=ce,this.http=it}cacheableRequest(e,t={}){t.lr=t.lr||this.config.language;let n=qi(e,t);if(this.#e.has(n))return this.#e.get(n);{let s=it.getJson(e,{search:t});return this.#e.set(n,s),s}}resetRequestCache(){this.#e.clear()}};E();E();E();var Ut=63710088e-1,Nm={centimeters:Ut*100,centimetres:Ut*100,degrees:Ut/111325,feet:Ut*3.28084,inches:Ut*39.37,kilometers:Ut/1e3,kilometres:Ut/1e3,meters:Ut,metres:Ut,miles:Ut/1609.344,millimeters:Ut*1e3,millimetres:Ut*1e3,nauticalmiles:Ut/1852,radians:1,yards:Ut*1.0936},BR={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/Ut,yards:1.0936133};function mr(i,e,t){t===void 0&&(t={});var n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}function Rs(i,e,t){if(t===void 0&&(t={}),!i)throw new Error("coordinates is required");if(!Array.isArray(i))throw new Error("coordinates must be an Array");if(i.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Hh(i[0])||!Hh(i[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:i};return mr(n,e,t)}function ja(i,e,t){t===void 0&&(t={});for(var n=0,s=i;n<s.length;n++){var r=s[n];if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<r[r.length-1].length;o++)if(r[r.length-1][o]!==r[0][o])throw new Error("First and last Position are not equivalent.")}var a={type:"Polygon",coordinates:i};return mr(a,e,t)}function Ki(i,e,t){if(t===void 0&&(t={}),i.length<2)throw new Error("coordinates must be an array of two or more positions");var n={type:"LineString",coordinates:i};return mr(n,e,t)}function Gh(i,e){e===void 0&&(e="kilometers");var t=Nm[e];if(!t)throw new Error(e+" units is invalid");return i*t}function Wh(i,e){e===void 0&&(e="kilometers");var t=Nm[e];if(!t)throw new Error(e+" units is invalid");return i/t}function Cs(i){var e=i%(2*Math.PI);return e*180/Math.PI}function Tt(i){var e=i%360;return e*Math.PI/180}function Qa(i,e,t){if(e===void 0&&(e="kilometers"),t===void 0&&(t="kilometers"),!(i>=0))throw new Error("length must be a positive number");return Gh(Wh(i,e),t)}function Hh(i){return!isNaN(i)&&i!==null&&!Array.isArray(i)}function Ls(i){return!!i&&i.constructor===Object}function Zi(i,e,t){if(i!==null)for(var n,s,r,o,a,l,c,h=0,u=0,f,d=i.type,y=d==="FeatureCollection",g=d==="Feature",p=y?i.features.length:1,m=0;m<p;m++){c=y?i.features[m].geometry:g?i.geometry:i,f=c?c.type==="GeometryCollection":!1,a=f?c.geometries.length:1;for(var M=0;M<a;M++){var b=0,S=0;if(o=f?c.geometries[M]:c,o!==null){l=o.coordinates;var O=o.type;switch(h=t&&(O==="Polygon"||O==="MultiPolygon")?1:0,O){case null:break;case"Point":if(e(l,u,m,b,S)===!1)return!1;u++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(e(l[n],u,m,b,S)===!1)return!1;u++,O==="MultiPoint"&&b++}O==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(s=0;s<l[n].length-h;s++){if(e(l[n][s],u,m,b,S)===!1)return!1;u++}O==="MultiLineString"&&b++,O==="Polygon"&&S++}O==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(S=0,s=0;s<l[n].length;s++){for(r=0;r<l[n][s].length-h;r++){if(e(l[n][s][r],u,m,b,S)===!1)return!1;u++}S++}b++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(Zi(o.geometries[n],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Om(i,e){var t,n,s,r,o,a,l,c,h,u,f=0,d=i.type==="FeatureCollection",y=i.type==="Feature",g=d?i.features.length:1;for(t=0;t<g;t++){for(a=d?i.features[t].geometry:y?i.geometry:i,c=d?i.features[t].properties:y?i.properties:{},h=d?i.features[t].bbox:y?i.bbox:void 0,u=d?i.features[t].id:y?i.id:void 0,l=a?a.type==="GeometryCollection":!1,o=l?a.geometries.length:1,s=0;s<o;s++){if(r=l?a.geometries[s]:a,r===null){if(e(null,f,c,h,u)===!1)return!1;continue}switch(r.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(r,f,c,h,u)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<r.geometries.length;n++)if(e(r.geometries[n],f,c,h,u)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}f++}}function Dm(i,e,t){var n=t;return Om(i,function(s,r,o,a,l){r===0&&t===void 0?n=s:n=e(n,s,r,o,a,l)}),n}function Lv(i,e){Om(i,function(t,n,s,r,o){var a=t===null?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return e(mr(t,s,{bbox:r,id:o}),n,0)===!1?!1:void 0}var l;switch(a){case"MultiPoint":l="Point";break;case"MultiLineString":l="LineString";break;case"MultiPolygon":l="Polygon";break}for(var c=0;c<t.coordinates.length;c++){var h=t.coordinates[c],u={type:l,coordinates:h};if(e(mr(u,s),n,c)===!1)return!1}})}function Pv(i,e){Lv(i,function(t,n,s){var r=0;if(!!t.geometry){var o=t.geometry.type;if(!(o==="Point"||o==="MultiPoint")){var a,l=0,c=0,h=0;if(Zi(t,function(u,f,d,y,g){if(a===void 0||n>l||y>c||g>h){a=u,l=n,c=y,h=g,r=0;return}var p=Ki([a,u],t.properties);if(e(p,n,s,g,r)===!1)return!1;r++,a=u})===!1)return!1}}})}function Um(i,e,t){var n=t,s=!1;return Pv(i,function(r,o,a,l,c){s===!1&&t===void 0?n=r:n=e(n,r,o,a,l,c),s=!0}),n}var Fm=6378137;function Ao(i){return Dm(i,function(e,t){return e+Nv(t)},0)}function Nv(i){var e=0,t;switch(i.type){case"Polygon":return Bm(i.coordinates);case"MultiPolygon":for(t=0;t<i.coordinates.length;t++)e+=Bm(i.coordinates[t]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Bm(i){var e=0;if(i&&i.length>0){e+=Math.abs(km(i[0]));for(var t=1;t<i.length;t++)e-=Math.abs(km(i[t]))}return e}function km(i){var e,t,n,s,r,o,a,l=0,c=i.length;if(c>2){for(a=0;a<c;a++)a===c-2?(s=c-2,r=c-1,o=0):a===c-1?(s=c-1,r=0,o=1):(s=a,r=a+1,o=a+2),e=i[s],t=i[r],n=i[o],l+=(Xh(n[0])-Xh(e[0]))*Math.sin(Xh(t[1]));l=l*Fm*Fm/2}return l}function Xh(i){return i*Math.PI/180}var zm={anchor:null,createdAt:null,defaultFloor:null,entryPoints:null,floorNames:null,geometry:null,graphId:null,id:null,lastModified:null,name:null,solutionId:null,styles:null,tilesUrl:null,venueInfo:null},Vm={administrativeId:null,venueId:null,anchor:null,buildingInfo:null,createdAt:null,floors:null,geometry:null,id:null,lastModified:null},qh=class extends ti{#e=new Map;#t=new Map;constructor(){super(),ce.on("apikey_changed",()=>{this.resetRequestCache(),this.getVenues()})}async getVenues(){let e=ce.venuesToSync,t=[];if(e?.length>0){let n=e.map(this.getVenue.bind(this));t=await Promise.all(n).then(s=>s.flat())}else t=await this.cacheableRequest("~/sync/venues",{solutionId:ce.apiKey,v:7,includeFloornames:!0});return this.#e.clear(),this.#t.clear(),t.map(n=>(n=Object.assign({},zm,n),this.#e.set(n.name?.toLowerCase(),n),this.#t.set(n.id,n),n))}getVenue(e){return un.isString(e)===!1||!e?Promise.resolve(null):this.#t.has(e)?Promise.resolve(this.#t.get(e)):this.cacheableRequest("~/sync/venues",{solutionId:ce.apiKey,venueId:e,v:7,includeFloornames:!0}).then(t=>t[0]).then(t=>Object.assign({},zm,t)).then(t=>(this.#e.set(t.name?.toLowerCase(),t),this.#t.set(t.id,t),t)).catch(()=>null)}async getVenueByName(e){return un.isString(e)===!1?null:(this.#e.size===0&&await this.getVenues(),this.#e.get(e?.toLowerCase()))}getBuildings(e){return new Promise(t=>{this.cacheableRequest("~/sync/buildings",{solutionId:ce.apiKey,venueId:e,v:7}).then(n=>Array.isArray(n)?n:[]).then(n=>n.map(s=>Object.assign({},Vm,s))).then(n=>t(n))})}getBuilding(e,t){return new Promise((n,s)=>{this.cacheableRequest(`buildings/details/${e}`,{v:7,...t}).then(r=>{r=Object.assign({},Vm,r),r.area=Ov(r.geometry),n(r)}).catch(()=>s())})}getBuildingInView(e,t){return e?this.cacheableRequest("buildings",Object.assign({},{viewport:Dt.toUrlValue(e),v:7},t)).then(n=>n.id?n:null):Promise.resolve(null)}clearCache(){this.#e.clear(),this.#t.clear(),this.resetRequestCache()}};function Ov(i){return i.type==="Polygon"?Ao(i):0}var mt=new qh;E();var Zm=Jt(Sn());E();function ni(i,e,t){var n=t||{},s=n.noTrailing,r=s===void 0?!1:s,o=n.noLeading,a=o===void 0?!1:o,l=n.debounceMode,c=l===void 0?void 0:l,h,u=!1,f=0;function d(){h&&clearTimeout(h)}function y(p){var m=p||{},M=m.upcomingOnly,b=M===void 0?!1:M;d(),u=!b}function g(){for(var p=arguments.length,m=new Array(p),M=0;M<p;M++)m[M]=arguments[M];var b=this,S=Date.now()-f;if(u)return;function O(){f=Date.now(),e.apply(b,m)}function L(){h=void 0}!a&&c&&!h&&O(),d(),c===void 0&&S>i?a?(f=Date.now(),r||(h=setTimeout(c?L:O,i))):O():r!==!0&&(h=setTimeout(c?L:O,c===void 0?i-S:i))}return g.cancel=y,g}E();var Gm=Jt(Sn()),Wm=Jt(Hm());E();var wn=Object.freeze({DISCONNECTED:"DISCONNECTED",CONNECTED:"CONNECTED",CONNECTING:"CONNECTING"});var el=class extends Gm.default{#e=new Map;#t;#n=wn.DISCONNECTED;get status(){return this.#n}subscribe(e){return new Promise((t,n)=>{this.status!==wn.CONNECTED&&n("No connection"),this.#t.subscribe(e,{onSuccess:()=>t(),onFailure:s=>n(s)})})}onMessageArrived(e){let t=JSON.parse(e.payloadString);if(t.topic=t.topic||e.topic,!t.topic)return;let n=this.#e.get(t.id);n&&t.timestamp<n||(this.#e.set(t.id,t.timestamp),this.emit("update_received",t))}unsubscribe(e){return new Promise((t,n)=>{this.status!==wn.CONNECTED&&n("No connection"),this.#t.unsubscribe(e,{onSuccess:()=>t(),onFailure:s=>n(s)})})}connect(){return new Promise((e,t)=>{if(this.#t)return e();this.setStatus(wn.CONNECTING);let n=new Wm.default.Client("livedata-mq.mapsindoors.com",parseInt(8084),xo());n.onConnectionLost=s=>{this.setStatus(wn.DISCONNECTED),s.errorCode!==0&&this.emit("error",s)},n.onConnected=s=>{s&&this.emit("reconnected")},n.connect({useSSL:!0,reconnect:!0,onSuccess:()=>{this.#t=n,this.#t.onMessageArrived=this.onMessageArrived.bind(this),this.setStatus(wn.CONNECTED),this.#e.clear(),e()},onFailure:s=>{console.warn("Could not connect to live data message queue."),this.setStatus(wn.DISCONNECTED),t(s)}})})}disconnect(){this.#t.disconnect(),this.setStatus(wn.DISCONNECTED)}setStatus(e){this.#n=e,this.emit("status_changed",e)}};E();var Kh=class{#e;activeDomainTypes(){return this.#e!==void 0?Promise.resolve(this.#e):it.getJson(`https://liveapi.mapsindoors.com/api/livedata/details/${ce.apiKey}`).then(e=>(this.#e=e.domainTypes.map(t=>t.toLowerCase()),this.#e))}},Zh=new Kh;E();E();function ii(i,e){return i.reduce((t,n)=>t&&t[n]?t[n]:null,e)}var $h=new Map,tn=Object.freeze({UNAVAILABLE:"unavailable",AVAILABLE:"available",BRONZE:"bronze",TEXT:"text"});async function Hn(i,e,t,n,s,r){if(!Dv(i,s,r,e.src))return null;let o=null;switch(s){case tn.UNAVAILABLE:o=await Ct.UnavailableBadge.overlay(e,{size:{width:t,height:n}});break;case tn.AVAILABLE:o=await Ct.AvailableBadge.overlay(e,{size:{width:t,height:n}});break;case tn.BRONZE:o=await new Ct({text:r,backgroundColor:ii(["color","bronze","60","value"],Qt)}).overlay(e,{size:{width:t,height:n}});break;case tn.TEXT:o=await Ct.TextBadge.overlay(e,{text:r,size:{width:t,height:n}});break}return o&&$h.set(i,{badgeType:s,badgeValue:r,iconSrc:e.src}),o}function Xm(i){$h.delete(i)}async function qm(i,e,t){let n=e.getStatefulDisplayRule(i,!0),s=await n.getIcon();if(!s)return null;let r=i.liveUpdates.get(Ft.LiveDataDomainTypes.AVAILABILITY),o=i.liveUpdates.get(Ft.LiveDataDomainTypes.OCCUPANCY),a=i.liveUpdates.get(Ft.LiveDataDomainTypes.TEMPERATURE),l=i.liveUpdates.get(Ft.LiveDataDomainTypes.CO2),c=i.liveUpdates.get(Ft.LiveDataDomainTypes.HUMIDITY),h=i.liveUpdates.get(Ft.LiveDataDomainTypes.COUNT);if(t.has(Ft.LiveDataDomainTypes.AVAILABILITY)&&t.has(Ft.LiveDataDomainTypes.OCCUPANCY)&&r&&o&&!Ke(r.properties.available)&&!Ke(o.properties.nrOfPeople))return o.properties.nrOfPeople<0||o.properties.peoplePresence<0?await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.BRONZE,"-"):o.properties.nrOfPeople>0&&r.properties.available===!1?await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.UNAVAILABLE):o.properties.nrOfPeople>0&&r.properties.available===!0?await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.BRONZE,o.properties.nrOfPeople.toString()):o.properties.nrOfPeople===0&&r.properties.available===!1?await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.BRONZE,"-"):o.properties.nrOfPeople===0&&r.properties.available===!0?await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.AVAILABLE):null;if(t.has(Ft.LiveDataDomainTypes.AVAILABILITY)&&r&&!Ke(r.properties.available)){if(r.properties.available===!0)return await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.AVAILABLE);if(r.properties.available===!1)return await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.UNAVAILABLE)}if(t.has(Ft.LiveDataDomainTypes.OCCUPANCY)&&o&&!Ke(o.properties.nrOfPeople)){let u;return o.properties.nrOfPeople<0||o.properties.peoplePresence<0?u="-":u=o.properties.nrOfPeople.toString(),await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.TEXT,u)}if(t.has(Ft.LiveDataDomainTypes.TEMPERATURE)&&a&&!Ke(a.properties.temperature)){let u;return navigator.language==="en-US"?u=Math.round(a.properties.temperature*9/5-459.67):u=Math.round(a.properties.temperature-273.15),await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.TEXT,`${u}\xB0`)}if(t.has(Ft.LiveDataDomainTypes.CO2)&&l&&!Ke(l.properties.co2Level))return await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.TEXT,Math.trunc(l.properties.co2Level).toString());if(t.has(Ft.LiveDataDomainTypes.HUMIDITY)&&c&&!Ke(c.properties.relativeHumidity))return await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.TEXT,`${Math.trunc(c.properties.relativeHumidity)}%`);if(t.has(Ft.LiveDataDomainTypes.COUNT)&&h&&!Ke(h.properties.count))return await Hn(i.id,s,n.iconSize.width,n.iconSize.height,tn.TEXT,h.properties.count.toString())}function Dv(i,e,t,n){let s=$h.get(i);return!(s&&s.badgeType===e&&s.badgeValue===t&&s.iconSrc===n)}var Uv=1e3,Fv=2e3,Jh=Object.freeze({OCCUPANCY:"occupancy",AVAILABILITY:"availability",POSITION:"position",TEMPERATURE:"temperature",CO2:"co2",HUMIDITY:"humidity",COUNT:"count"}),Ft=class extends Zm.default{#e;#t;#n;#i;#r;#o;#a;#s;#l;#c;#h;#u;#f;constructor(e){super(),this.#e=null,this.#i={},this.#n=[],this.#s=new Map,this.mapsindoorsInstanceThrottler=ni(Uv,()=>{this.mapsindoorsInstance.emit("data_updated")}),this.mapUpdateThrottler=ni(Fv,()=>{this._updateEnabledTopics()}),this.displayRuleOverridesThrottler=ni(2e3,()=>{this.mapsindoorsInstance.revertDisplayRule([...this.#f]),this.#f.clear(),this.mapsindoorsInstance.overrideDisplayRule(this.#u),this.#u.clear()}),this.#t=new el,this.mapsindoorsInstance=e,this._listenForLocationChanges(),this.#t.on("update_received",t=>{zv.call(this,t,this.#i)}),this.#t.on("status_changed",t=>{this.emit("live_data_status_changed",t)}),this.#t.on("error",t=>{this.emit("live_data_error",t)}),this.#t.on("reconnected",()=>{this.#d(this.subscribedTopics)}),ce.on("userroles_changed",()=>{this.mapsindoorsInstance.once("locations_changed",()=>Bv.call(this))}),this.subscribedTopics=[],this.#c=this._listenForLocationChanges.bind(this),this.#h=this._defaultEnableLiveDataCallback.bind(this),this.#l=!1,this.#r=new Set,this.#o=new Map,this.#a=new Set,this.#u=new Map,this.#f=new Set}get status(){return this.#t.status}static get LiveDataDomainTypes(){return Jh}get LiveDataInfo(){return Zh}async subscribe(e){let t=Km(e);await Ym(t)!==!1&&(await this.#d([e]),Rt.log(pt.liveData.SUBSCRIPTION_STARTED,{domain_type:t}))}async#d(e){if(e.length===0)return;if(this.#t.status!==wn.CONNECTED){this.#n.push(...e),this.#t.status!==wn.CONNECTING&&this.#t.connect().then(()=>{let n=this.#n;this.#n=[],this.#d(n)});return}for(let n of e)this.#i[n]=[],await this.#t.subscribe(n);let t=await Jm(e);await Hv.call(this,e,t,this.#i),this.subscribedTopics.push(...e)}async unsubscribe(e){await this.#p(e);let t=Km(e);Rt.log(pt.liveData.SUBSCRIPTION_STOPPED,{domain_type:t})}async#p(e){if(this.#t.status!==wn.CONNECTED)return this.#n.splice(this.#n.indexOf(e),1),!1;await this.#t.unsubscribe(e),this.subscribedTopics=this.subscribedTopics.filter(t=>t!==e)}async getLiveUpdate(e,t){return await Ai.getByDomain(e,t)}async enableLiveData(e,t){if(e=e.toLowerCase(),await Ym(e)!==!1){if(this.#r.has(e)){console.warn(`Live Data for ${e} is already enabled`);return}this.#s.size===0&&this._listenForLocationChanges(),this.#r.add(e),await this._updateEnabledTopics.call(this),Rt.log(pt.liveData.LIVEDATA_ENABLED_FOR_MAP,{domain_type:e}),this.#l||(this.mapsindoorsInstance.getMapView().addListener("idle",this.#c),this.mapsindoorsInstance.addListener("floor_changed",this.#c),this.#l=!0),t instanceof Function?(this.#o.set(e,t),this.mapsindoorsInstance.on("livedata_locations_updated",this.#o.get(e))):this.mapsindoorsInstance.on("livedata_locations_updated",this.#h)}}async _defaultEnableLiveDataCallback(e){let t=new Set;for(let[n,s]of e.data)if(!this.#o.has(n)){for(let r of s)if(!t.has(r)){if(!r.liveUpdates||r.liveUpdates.size===0||r.liveUpdates.size===1&&r.liveUpdates.get("position"))Xm(r.id),this.#f.add(r.id);else{let o=await qm(r,this.mapsindoorsInstance,this.#r);if(o){let a={iconSize:{width:o.width,height:o.height},icon:o};this.#u.set(r.id,a)}}t.add(r),this.displayRuleOverridesThrottler()}}}_listenForLocationChanges(){this.mapsindoorsInstance.once("locations_changed",e=>{this.#s=e,this.mapUpdateThrottler()})}async disableLiveData(e){if(e=e.toLowerCase(),!this.#r.has(e))return;let t=new Map;t.set(e,[]);let n=await fn.getLocations();for(let s of n)await Vv.call(this,s,e)&&t.get(e).push(s);this.mapsindoorsInstance.emit("livedata_locations_updated",{data:t}),this.#r.delete(e),await this._updateEnabledTopics.call(this),this.#l&&(this.mapsindoorsInstance.getMapView().removeListener("bounds_changed",this.#c),this.mapsindoorsInstance.removeListener("floor_changed",this.#c),this.#o.has(e)||this.mapsindoorsInstance.removeListener("livedata_locations_updated",this.#h),this.#l=!1),this.#o.has(e)&&(this.mapsindoorsInstance.removeListener("livedata_locations_updated",this.#o.get(e)),this.#o.delete(e))}async _updateEnabledTopics(){if(this.#e===null){let n=await mapsindoors.services.SolutionsService.getSolution(ce.apiKey);this.#e=n.id}let e=await kv(this.#s,this.#r,this.#e),t=[];for(let n of e)this.#a.has(n)||t.push(n);this.#d(t);for(let n of this.#a)e.has(n)||this.#p(n);this.#a=e}};async function Ym(i){return(await Zh.activeDomainTypes()).includes(i)?!0:(console.warn(`Live Data for ${i} is not available`),!1)}async function Bv(){(await Jm(this.subscribedTopics)).forEach(async e=>{await jh.call(this,e.id,e)})}async function kv(i,e,t){let n=new Set,s=new Set,r=new Set;for(let o of i)o?.id?.substring(0,3)?.toLowerCase()!=="mi_"&&o&&o.properties&&(Ke(o.properties.buildingId)?r.add(o):s.add(o));for(let o of r)for(let a of e)n.add(`${t}/+/+/+/+/${o.id}/${a}`);for(let o of s)for(let a of e)n.add(`${t}/+/+/${o.properties.parentId??"+"}/+/+/${a}`);return await n}async function zv(i,e){let t=Object.keys(e).find(n=>$m(i.topic,n));t?e[t].push(i):(await jh.call(this,i.id,i),this.emit("live_update_received",i))}async function jh(i,e){await Ai.update(i,e),this.mapsindoorsInstanceThrottler()}function Vv(i,e){return Ai.remove(i.id,e),this.mapsindoorsInstanceThrottler(),!0}function $m(i,e){if(i===e)return!0;let t=i.split("/"),n=e.split("/");if(t.length!==n.length&&e.slice(-1)!=="#")return!1;for(let s=0;s<t.length;s++){let r=t[s],o=n[s];if(o==="#")return!0;if(r!==o&&o!=="+")return!1}return!0}async function Hv(i,e,t){for(let n of i){let s=t[n];if(!!s){for(let r of e){if(!$m(r.topic,n))continue;let o=s.filter(c=>c.id===r.id),l=[r].concat(o).reduce((c,h)=>c.timestamp>h.timestamp?c:h);await jh.call(this,l.id,l),this.emit("live_update_received",l)}delete t[n]}}}function Jm(i){return i.length===0?[]:fetch("https://liveapi.mapsindoors.com/api/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:i})}).then(e=>e.ok?e.json():[])}function Km(i){return i.split("/").slice(-1)[0].toLowerCase()}E();E();function Qh(i,e,t){if(i!==null)for(var n,s,r,o,a,l,c,h=0,u=0,f,d=i.type,y=d==="FeatureCollection",g=d==="Feature",p=y?i.features.length:1,m=0;m<p;m++){c=y?i.features[m].geometry:g?i.geometry:i,f=c?c.type==="GeometryCollection":!1,a=f?c.geometries.length:1;for(var M=0;M<a;M++){var b=0,S=0;if(o=f?c.geometries[M]:c,o!==null){l=o.coordinates;var O=o.type;switch(h=t&&(O==="Polygon"||O==="MultiPolygon")?1:0,O){case null:break;case"Point":if(e(l,u,m,b,S)===!1)return!1;u++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(e(l[n],u,m,b,S)===!1)return!1;u++,O==="MultiPoint"&&b++}O==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(s=0;s<l[n].length-h;s++){if(e(l[n][s],u,m,b,S)===!1)return!1;u++}O==="MultiLineString"&&b++,O==="Polygon"&&S++}O==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(S=0,s=0;s<l[n].length;s++){for(r=0;r<l[n][s].length-h;r++){if(e(l[n][s][r],u,m,b,S)===!1)return!1;u++}S++}b++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(Qh(o.geometries[n],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Gv(i,e={}){if(i.bbox!=null&&e.recompute!==!0)return i.bbox;let t=[1/0,1/0,-1/0,-1/0];return Qh(i,n=>{t[0]>n[0]&&(t[0]=n[0]),t[1]>n[1]&&(t[1]=n[1]),t[2]<n[0]&&(t[2]=n[0]),t[3]<n[1]&&(t[3]=n[1])}),t}var jm=Gv;E();var eu=5,To=Symbol("cache"),tu=class extends ti{constructor(){super(),this[To]=new Map}async getDerivedGeometries(e,t,n,s=["wall","extrusion"]){t=Array.isArray(t)?t:[t].filter(Boolean);let{modules:r}=await Ps.getSolution();if(r?.includes("3dwalls")||r?.includes("3dextrusions"))if(t?.length>0){let o=t.map(a=>this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,venueId:a,v:eu,floorIndex:n?.toString(),geometryTypes:s?.join(",")}));return Promise.all(o).then(a=>a.flat())}else return this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,v:eu,floorIndex:n?.toString(),geometryTypes:s?.join(",")});return Promise.resolve([])}async getDerivedGeometriesWithin(e,t,n,s,r=["wall","extrusion"],o=!1){let{modules:a}=await Ps.getSolution();if(!a?.includes("3dwalls")||!a?.includes("3dextrusions"))return[];let c={solutionId:ce.apiKey,venueId:e,floorIndex:t?.toString(),appUserRoleIds:s,geometryTypes:r?.join(","),bbox:n,v:7,onlyOutside:o},h=qi("~/sync/derivedgeometry/bbox",c);return this[To].has(h)||this[To].set(h,it.getJson("~/sync/derivedgeometry/bbox",{search:c})),this[To].get(h)}async getFloorPlan(e,t,n){return await this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,venueId:t,v:eu,geometryTypes:"floorplan",floorIndex:n}).then(s=>({type:"FeatureCollection",features:[...s.map(r=>({type:"Feature",geometry:r.geometry,properties:{type:r.type}}))]}))}clearCache(){this[To].clear(),this.resetRequestCache()}},$i=new tu;E();var tl=class{#e;#t=7;constructor(e=16){this.#e=Math.pow(2,e)}getIntersectingCells(e){let{south:t,west:n,north:s,east:r}=e,o=this.getCell({lat:s,lng:n}),a=this.getCell({lat:t,lng:r}),l=[];for(let c=o.x;c<=a.x;c++)for(let h=o.y;h<=a.y;h++){let u=this.#n({x:c,y:h});l.push(u)}return l}getCell({lat:e,lng:t}){let n=this.#e,s=Math.floor(n*((t+180)/360)),r=Math.floor(n*(1-Math.log(Math.tan(jt(e))+Sm(jt(e)))/Math.PI)/2);return{x:s,y:r}}getCellBounds({lat:e,lng:t}){let{x:n,y:s}=this.getCell({lat:e,lng:t});return this.#n({x:n,y:s})}#n({x:e,y:t}){let[n,s]=this.#i({x:e,y:t}),[r,o]=this.#i({x:e+1,y:t+1});return{south:Mo(o,this.#t),west:Mo(n,this.#t),north:Mo(s,this.#t),east:Mo(r,this.#t)}}#i({x:e,y:t}){let n=this.#e,s=As(Math.atan(Math.sinh(Math.PI*(1-2*t/n))));return[e/n*360-180,s]}};E();E();E();function Wv(i,e){e===void 0&&(e={});var t=0,n=0,s=0;return Zi(i,function(r){t+=r[0],n+=r[1],s++},!0),Rs([t/s,n/s],e.properties)}var Qm=Wv;E();E();function Ht(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return i.geometry.coordinates;if(i.type==="Point")return i.coordinates}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return i;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function nl(i){if(Array.isArray(i))return i;if(i.type==="Feature"){if(i.geometry!==null)return i.geometry.coordinates}else if(i.coordinates)return i.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Xv(i,e,t){t===void 0&&(t={});var n;t.final?n=eg(Ht(e),Ht(i)):n=eg(Ht(i),Ht(e));var s=n>180?-(360-n):n;return s}function eg(i,e){var t=Tt(i[1]),n=Tt(e[1]),s=Tt(e[0]-i[0]);s>Math.PI&&(s-=2*Math.PI),s<-Math.PI&&(s+=2*Math.PI);var r=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(t/2+Math.PI/4)),o=Math.atan2(s,r);return(Cs(o)+360)%360}var tg=Xv;E();function qv(i,e,t){t===void 0&&(t={});var n=Ht(i),s=Ht(e);s[0]+=s[0]-n[0]>180?-360:n[0]-s[0]>180?360:0;var r=Yv(n,s),o=Qa(r,"meters",t.units);return o}function Yv(i,e,t){t=t===void 0?Ut:Number(t);var n=t,s=i[1]*Math.PI/180,r=e[1]*Math.PI/180,o=r-s,a=Math.abs(e[0]-i[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);var l=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),c=Math.abs(l)>1e-11?o/l:Math.cos(s),h=Math.sqrt(o*o+c*c*a*a),u=h*n;return u}var ng=qv;E();function Kv(i,e,t,n){n===void 0&&(n={});var s=e<0,r=Qa(Math.abs(e),n.units,"meters");s&&(r=-Math.abs(r));var o=Ht(i),a=Zv(o,r,t);return a[0]+=a[0]-o[0]>180?-360:o[0]-a[0]>180?360:0,Rs(a,n.properties)}function Zv(i,e,t,n){n=n===void 0?Ut:Number(n);var s=e/n,r=i[0]*Math.PI/180,o=Tt(i[1]),a=Tt(t),l=s*Math.cos(a),c=o+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),u=Math.abs(h)>1e-11?l/h:Math.cos(o),f=s*Math.sin(a)/u,d=r+f;return[(d*180/Math.PI+540)%360-180,c*180/Math.PI]}var il=Kv;E();function $v(i){if(!i)throw new Error("geojson is required");switch(i.type){case"Feature":return ig(i);case"FeatureCollection":return Jv(i);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return nu(i);default:throw new Error("unknown GeoJSON type")}}function ig(i){var e={type:"Feature"};return Object.keys(i).forEach(function(t){switch(t){case"type":case"properties":case"geometry":return;default:e[t]=i[t]}}),e.properties=sg(i.properties),e.geometry=nu(i.geometry),e}function sg(i){var e={};return i&&Object.keys(i).forEach(function(t){var n=i[t];typeof n=="object"?n===null?e[t]=null:Array.isArray(n)?e[t]=n.map(function(s){return s}):e[t]=sg(n):e[t]=n}),e}function Jv(i){var e={type:"FeatureCollection"};return Object.keys(i).forEach(function(t){switch(t){case"type":case"features":return;default:e[t]=i[t]}}),e.features=i.features.map(function(t){return ig(t)}),e}function nu(i){var e={type:i.type};return i.bbox&&(e.bbox=i.bbox),i.type==="GeometryCollection"?(e.geometries=i.geometries.map(function(t){return nu(t)}),e):(e.coordinates=rg(i.coordinates),e)}function rg(i){var e=i;return typeof e[0]!="object"?e.slice():e.map(function(t){return rg(t)})}var sl=$v;function jv(i,e,t){if(t=t||{},!Ls(t))throw new Error("options is invalid");var n=t.pivot,s=t.mutate;if(!i)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(n||(n=Qm(i)),(s===!1||s===void 0)&&(i=sl(i)),Zi(i,function(r){var o=tg(n,r),a=o+e,l=ng(n,r),c=nl(il(n,l,a));r[0]=c[0],r[1]=c[1]})),i}var rl=jv;E();function Qv(i,e,t,n){if(n=n||{},!Ls(n))throw new Error("options is invalid");var s=n.units,r=n.zTranslation,o=n.mutate;if(!i)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("distance is required");if(r&&typeof r!="number"&&isNaN(r))throw new Error("zTranslation is not a number");if(r=r!==void 0?r:0,e===0&&r===0)return i;if(t==null||isNaN(t))throw new Error("direction is required");return e<0&&(e=-e,t=t+180),(o===!1||o===void 0)&&(i=sl(i)),Zi(i,function(a){var l=nl(il(a,e,t,{units:s}));a[0]=l[0],a[1]=l[1],r&&a.length===3&&(a[2]+=r)}),i}var Io=Qv;function iu(i,e,t){let n=Math.sqrt(e**2+t**2)/2,s=As(Math.atan(e/t)),r=Io(i,n,s,{units:"meters"});return[...Io(i,n,s+180,{units:"meters"}).coordinates,...r.coordinates]}function ag(i,e,t,n){if(i?.type!=="Point")throw new Error("Center must be a GeoJSON Point");let s=Math.sqrt(e**2+t**2)/2,r=Math.atan(e/t)*57.29577951308232,o=Io(i,s,r,{units:"meters"}),a=Io(i,s,r+180,{units:"meters"}),l=ja([[[a.coordinates[0],a.coordinates[1]],[o.coordinates[0],a.coordinates[1]],[o.coordinates[0],o.coordinates[1]],[a.coordinates[0],o.coordinates[1]],[a.coordinates[0],a.coordinates[1]]]]);return l.properties.imageBounds=[...a.coordinates,...o.coordinates],rl(l,n,{mutate:!0})}function su(i,e){return Array.isArray(i)||(i=og(i)),Array.isArray(e)||(e=og(e)),i[0]<=e[2]&&i[2]>=e[0]&&i[1]<=e[3]&&i[3]>=e[1]}function lg(i){return{north:i[3],east:i[2],south:i[1],west:i[0]}}function og(i){return[i.west,i.south,i.east,i.north]}function cg([i,e],t,{width:n,height:s}){let o=Math.pow(2,t),a=Es/(o*256),l=Math.cos(jt(e))*Es/(o*256),c=n*a,u=s*l/Es*360,f=c/Es*360;return{south:e-u/2,west:i-f/2,north:e+u/2,east:i+f/2}}function hg(i,{width:e,height:t}){let s=i.east-i.west,r=i.north-i.south,o=(i.north+i.south)/2,a=Math.log2(360*t/r/256/Math.cos(jt(o))),l=Math.log2(360*e/s/256);return Math.min(a,l)}function ug({lat:i,lng:e},t){let s=256*Math.pow(2,t);e=(e+180)%360-180;let r=i*Math.PI/180,o=e*Math.PI/180,a=-85.05112878,c=Math.max(Math.min(r,85.05112878*Math.PI/180),a*Math.PI/180),h=Math.sin(c),u=.5-Math.log((1+h)/(1-h))/(4*Math.PI),d=(o+Math.PI)/(2*Math.PI)*s,y=u*s,g=Math.min(Math.max(d,0),s-1),p=Math.min(Math.max(y,0),s-1);return{x:g,y:p}}var Ns=Symbol("applyLiveDataPositionUpdates"),An=Symbol("cache"),fg=Symbol("grid"),ru=Symbol("externalIdCache"),ou=class extends dg.default{constructor(){super(),this[ru]=new Map,this[An]=new Map,this[fg]=new tl}[Ns](e){return[].concat(e).map(t=>{let n=Ai.getByDomain(t.id,Jh.POSITION);if(n){if(n.properties.coordinates&&typeof n.properties.coordinates.longitude=="number"&&typeof n.properties.coordinates.latitude=="number"){let s=[Number(n.properties.coordinates.longitude),Number(n.properties.coordinates.latitude)];t.geometry.type==="Point"&&(t.geometry.coordinates=s),t.properties.anchor&&t.properties.anchor.coordinates&&(t.properties.anchor.coordinates=s)}typeof n.properties.floor=="number"&&(t.properties.floor=n.properties.floor)}return t})}async getLocation(e){let t={v:7,extendedLocations:!0},n=qi(`locations/details/${e}`,t);if(this[An].has(n)){let r=await this[An].get(n);return this[Ns](r).at(0)}let s=Promise.all([mt.getBuildings(),it.getJson(`locations/details/${e}`,{search:{...t}})]).then(([r,o])=>$i.getDerivedGeometries(ce.apiKey,null,o.properties.floor).then(a=>[r,o,a])).then(ol).then(r=>r.map(o=>al(o))).then(r=>(this[An].set(n,r),r)).then(r=>this[Ns](r).at(0));return this[An].set(n,s),await s}getLocationsWithin(e,t,n,s=[],r=!1){let a={solutionId:ce.apiKey,venueId:e,v:7,appUserRoleIds:s,floorIndex:t?.toString(),bbox:n,onlyOutside:r},l=qi("~/sync/locations/bbox",a);return this[An].has(l)||this[An].set(l,it.getJson("~/sync/locations/bbox",{search:a})),this[An].get(l)}#e(e,t,n=[]){return this.getLocationsWithin(e,void 0,t,n,!0)}#t(e,t,n=[]){return $i.getDerivedGeometriesWithin(e,void 0,t,n,void 0,!0)}async dataSource(e,t){if(Ke(t))return[];let n=(ce.userRoles||[]).map(y=>y.id).join(","),s=this[fg],r=await mt.getVenues(),o=[],a=[],l=[],c=new Map,h=r.flatMap(y=>y?.locationBounds?.coordinates.map(g=>[jm({type:"Polygon",coordinates:g}),y]));for(let[y,g]of h){if(!su(e,y))continue;c.set(g.id,g),l.push(mt.getBuildings(g.id));let p=s.getIntersectingCells(lg(y));for(let m of p){if(!su(e,m))continue;let M=Dt.toUrlValue(m),b=this.getLocationsWithin(g.id,t,M,n);a.push(b);let S=this.#e(g.id,M,n);a.push(S);let O=$i.getDerivedGeometriesWithin(g.id,t,M,n);o.push(O);let L=this.#t(g.id,M,n);o.push(L)}}let u=await Promise.all(l).then(y=>y.flat()),f=await Promise.all(o).then(y=>y.flat()),d=await Promise.all(a).then(y=>y.flat());return ol([u,d,f]).then(y=>[...y,...Array.from(c.values()).map(tx),...u.map(g=>[nx(g,{venues:c}),ix(g.floors?.[t],{building:g,venues:c,floorIndex:t})]).flat()].filter(g=>!!g)).then(y=>y.filter(ex()).map(g=>al(g))).then(y=>this[Ns](y))}async getLocationsByExternalId(e){if(!e)return[];if(e=[].concat(e),e.length<1)return[];let t={v:7},n=[];return e=e.filter(s=>{let r=this[ru].get(s);return r?(n.push(r),!1):!0}),await Promise.all([mt.getBuildings(),it.post("locations/externalid",{body:e,search:{...t}}).then(s=>s.clone().json())]).then(ol).then(s=>s.map(r=>(r=al(r),this[ru].set(r.properties.externalId,r),r))).then(s=>s.concat(n)).then(s=>this[Ns](s))}async getLocations(e){e=e||{};let t={},n=e.types instanceof Array?e.types.join(","):e.types,s=e.venue?await mt.getVenueByName(e.venue)??await mt.getVenue(e.venue)??e.venue:null,r=s?.id,o=(ce.userRoles||[]).map(c=>c.id).join(",");t.q=e.q,t.qFields=e.fields||void 0,t.venue=s?.name??e.venue,t.building=e.building,t.floor=isNaN(e.floor)?void 0:e.floor.toString(),t.categories=e.categories instanceof Array?e.categories.join(","):e.categories,t.types=n,t.bbox=e.bbox?Dt.toUrlValue(e.bbox):void 0,t.take=e.take,t.skip=e.skip,t.radius=e.radius,t.includeOutsidePOI=e.includeOutsidePOI,t.orderBy=e.orderBy&&e.sortOrder?e.orderBy+" "+e.sortOrder:e.orderBy||void 0,t.extendedLocations=!0,t.appUserRoleIds=o,t.lr=e.lr||void 0,t.v=7,typeof e.near=="string"?t.near=e.near:e.near&&typeof e.near=="object"?t.near=`${e.near.lat}, ${e.near.lng}`:t.near=void 0;let a=qi("locations",t);if(this[An].has(a)){let c=await this[An].get(a);return this[Ns](c)}let l=Promise.all([mt.getBuildings(r),it.getJson("locations",{search:{...t}}),$i.getDerivedGeometries(ce.apiKey,r,e.floor)]).then(ol).then(c=>c.map(h=>al(h))).then(c=>(this[An].set(a,c),c)).then(c=>this[Ns](c));return this[An].set(a,l),l}clearCache(){return this[An].clear()}};function ex(){let i=new Date().getTime()/1e3;return e=>!e.properties.activeFrom&&!e.properties.activeTo?!0:e.properties.activeFrom&&e.properties.activeTo?e.properties.activeFrom<=i&&e.properties.activeTo>=i:e.properties.activeFrom?e.properties.activeFrom<=i:e.properties.activeTo?e.properties.activeTo>=i:!0}async function ol([i,e,t=[]]){e=e instanceof Array?e:[e];let n=new Map(i.map(o=>[o.administrativeId.toLowerCase(),o])),s=new Map(t.filter(o=>o.type.toLowerCase()==="wall").map(o=>[o.geodataId,o])),r=new Map(t.filter(o=>o.type.toLowerCase()==="extrusion").map(o=>[o.geodataId,o]));for(let o of e){let a=o.properties.venueId??o.properties.venue,l=await mt.getVenueByName(a?.toLowerCase());o.properties.venue=l?.venueInfo?.name??l?.name??o.properties.venue,o.properties.venueId??=l?.name;let c=o.properties.buildingId||o.properties.building,h=n.get(c?.toLowerCase());o.properties.building=h?.buildingInfo?.name??o.properties.building,o.properties.buildingId??=h?.id,o.properties.extrusionGeometry=r.get(o.id)?.geometry,o.properties.wallGeometry=s.get(o.id)?.geometry;let u=h?.floors?.[o.properties.floor];o.properties.floorId??=u?.id,o.properties.parentId=u?.id??h?.id??l?.id??null,o.properties.displayRule=o.properties.displayRule?new st(o.properties.displayRule):null}return e}function tx(i){return{id:i.id,type:"Feature",geometry:i.geometry,area:ll(i.geometry),properties:Object.assign({administrativeId:i.name,anchor:i.anchor,floor:"0",locationType:"venue",status:i.status,type:$t.MIType.MI_VENUE,venue:i.name},i.venueInfo)}}function nx(i,{venues:e}){let t=e.get(i.venueId);return{id:i.id,type:"Feature",geometry:i.geometry,area:ll(i.geometry),properties:Object.assign({anchor:i.anchor,administrativeId:i.administrativeId,floor:"0",locationType:"building",parentId:i.venueId,status:i.status,type:$t.MIType.MI_BUILDING,venue:t?.name??""},i.buildingInfo)}}function ix(i,{building:e,venues:t,floorIndex:n}){let s=t.get(e.venueId);if(!!i)return{id:i.id,type:"Feature",geometry:i.geometry,area:ll(i.geometry),properties:{anchor:e.anchor,building:e.administrativeId,buildingId:e.id,floor:n?.toString()??"",locationType:"floor",floorName:i.name,parentId:e.id,status:i.status,type:$t.MIType.MI_FLOOR,venue:s?.name??""}}}var pg={get(i,e){let t=i[e];return t===i.getLocations?function(){return Rt.log(pt.search.SEARCH_PERFORMED,{parameters_used:Object.keys(arguments[0]).join(", ")}),t.apply(this,arguments)}:t}};function al(i){if(!i)return null;let e={id:null,type:null,geometry:null,properties:null},t={aliases:null,anchor:null,building:null,categories:{},displayRule:null,externalId:null,fields:{},floor:null,floorName:null,imageURL:null,locationType:null,mapElement:null,locationSettings:{selectable:null},name:null,roomId:null,type:null,venue:null};return i=Object.assign(new $t,e,i),Object.prototype.hasOwnProperty.call(i?.properties,"imageurl")&&(Object.prototype.hasOwnProperty.call(i?.properties,"imageURL")||(i.properties.imageURL=i.properties.imageurl),delete i.properties.imageurl),i.properties=Object.assign({},t,i.properties),i.properties.externalId&&(i.properties.roomId=i.properties.externalId),i.properties.displayRule&&(Oh(i.properties.displayRule,"imageScale","iconScale"),Oh(i.properties.displayRule,"imageSize","iconSize")),i.area=ll(i.geometry),i.properties.displayRule=i.properties.displayRule?new st(i.properties.displayRule):null,i=sx(i),i.properties.geodesicDistance&&delete i.properties.geodesicDistance,i}function ll(i){return i&&i.type==="Polygon"?Ao(i):0}function sx(i){switch(i.properties?.locationType?.toLowerCase()){case"venue":return i.type=$t.MIType.MI_VENUE,i;case"building":return i.type=$t.MIType.MI_BUILDING,i;case"floor":return i.type=$t.MIType.MI_FLOOR,i;default:return i}}var fn=new ou;E();var rx={availableLanguages:null,createdAt:null,createdBy:null,customerId:null,defaultLanguage:null,expirationDate:null,id:null,implementationType:null,lastModified:null,lastModifiedBy:null,locationTemplate:null,mapClientUrl:null,minimumVersion:null,modules:null,name:null,types:null,whitelabel:null},cl=class extends ti{constructor(){super(),this.config.on("apikey_changed",()=>{this.resetRequestCache(),this.getSolution()})}getSolution(){return this.cacheableRequest("~/sync/solutions",{solutionId:this.config.apiKey,v:7}).then(e=>Object.assign({},rx,e)).then(e=>{for(let t of Object.values(e.types))t.displayRule=new st(t.displayRule);return e})}getCategories(e={}){return this.cacheableRequest("~/sync/categories",{solutionId:this.config.apiKey,...e})}getUserRoles(e={}){return this.cacheableRequest("~/sync/appuserroles",{solutionId:this.config.apiKey,...e}).then(t=>t.map(({id:n,name:s})=>new cr(n,s)))}};E();var hl=class extends ti{directionsToPhone(e,t,n,s,r){return new Promise((o,a)=>{this.http.post("share/route",{body:{CountryCode:s,PhoneNumber:r,Type:"sms",VenueId:e,OriginLocationId:t,DestinationLocationId:n}}).then(()=>o()).catch(l=>{let c=JSON.parse(l.message);a(c.message)})})}};E();E();var Os=class{#e;constructor({bookingId:e,locationId:t,startTime:n,endTime:s,participants:r,title:o,description:a,managed:l}){this.#e=e,this.locationId=t,this.startTime=new Date(n),this.endTime=new Date(s),this.participants=r,this.title=o,this.description=a,this.managed=l}get bookingId(){return this.#e}};E();var Ro=class{constructor(e,t){this.providerTenantId=t,this.accessToken=e}};var Co=ce.bookingServiceUrl,au=class{#e;get MPBooking(){return Os}get BookingAuthenticationConfig(){return Ro}getBookableLocations({startTime:e,endTime:t,venue:n,building:s,floorIndex:r,category:o,locationType:a}){let l=new Date(e).toISOString(),c=new Date(t).toISOString();return it.getJson(`${Co}/available`,{search:{fromUtc:l,toUtc:c,venue:n,building:s,floor:r,category:o,locationType:a},headers:this.#t()})}getLocationsConfiguredForBooking(){return it.getJson(`${Co}/bookable`,{headers:this.#t()})}getBookingsUsingQuery({location:e,ownerId:t,startTime:n,endTime:s}){let r=e?"locationbookings":t?"userbookings":null,o=e?e.id:null,a=n?new Date(n).toISOString():null,l=s?new Date(s).toISOString():null;return r&&a&&l?it.getJson(`${Co}/${r}`,{search:{locationId:o,userId:t,fromUtc:a,toUtc:l},headers:this.#t()}).then(c=>c.map(h=>this.#n(h))):Promise.reject()}performBooking(e){return e instanceof Os?it.post(`${Co}`,{body:{locationId:e.locationId,title:e.title,description:e.description,fromUtc:new Date(e.startTime).toISOString(),toUtc:new Date(e.endTime).toISOString(),inviteList:e.participants||[]},headers:this.#t()}).then(t=>t.json()).then(t=>this.#n(t)):Promise.reject("Invalid booking!")}cancelBooking(e){return e instanceof Os?it.delete(`${Co}`,{search:{bookingId:e.bookingId,locationId:e.locationId},headers:this.#t()}):Promise.reject("Invalid booking!")}setAuthenticationConfig(e){(e instanceof Ro||e===null)&&(this.#e=e)}#t(){return this.#e?{"user-access-token":this.#e.accessToken,"provider-tenantid":this.#e.providerTenantId}:null}#n(e){return e&&new Os({bookingId:e.id,startTime:e.fromUtc,endTime:e.toUtc,participants:e.inviteList,...e})}},mg=new au;var Ps=new cl,ox=new hl;E();var Yg=Jt(Sn());E();E();var yi={align:"center",color:Qt.color.gray[100].value,fontFamily:"Open Sans, Helvetica, sans-serif",fontSize:"12px",fontWeight:700,strokeStyle:"#444",strokeWeight:0,shadowBlur:0,shadowColor:"#000",maxLength:-1};E();var Bg=Jt(Fg());function ml(i,e=0){let t;if(e===0)return i;let n=(0,Bg.default)(i).hsl(),s=n.l();return e>0?t=s+(100-s)*e:t=s-s*Math.abs(e),n.l(t).hex().toString()}E();var Ee=Object.freeze({LABEL:"label",LABEL_FLOATING:"label_floating",LABEL_FLAT:"label_flat",LABEL_GRAPHIC:"label_graphic",MODEL2D:"model2d",MODEL3D:"model3d",POINT:"point",POLYGON:"polygon",ROOM_EXTRUSION:"room_extrusion",WALL_EXTRUSION:"wall_extrusion"});E();var gl=Object.freeze({FLOATING:"FLOATING",FLAT:"FLAT",GRAPHIC:"GRAPHIC"});E();function yl(i){try{let e=i();return[void 0,e]}catch(e){return[e,void 0]}}function kg(i){return i().then(e=>[void 0,e]).catch(e=>[e,void 0])}E();E();E();function _l(i,e,t=0,n=i.length-1,s=Mx){for(;n>t;){if(n-t>600){let l=n-t+1,c=e-t+1,h=Math.log(l),u=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1),d=Math.max(t,Math.floor(e-c*u/l+f)),y=Math.min(n,Math.floor(e+(l-c)*u/l+f));_l(i,e,d,y,s)}let r=i[e],o=t,a=n;for(Oo(i,t,e),s(i[n],r)>0&&Oo(i,t,n);o<a;){for(Oo(i,o,a),o++,a--;s(i[o],r)<0;)o++;for(;s(i[a],r)>0;)a--}s(i[t],r)===0?Oo(i,t,a):(a++,Oo(i,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function Oo(i,e,t){let n=i[e];i[e]=i[t],i[t]=n}function Mx(i,e){return i<e?-1:i>e?1:0}var Fo=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!xl(e,t))return n;let s=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){let a=t.children[o],l=t.leaf?s(a):a;xl(e,l)&&(t.leaf?n.push(a):pu(e,l)?this._all(a,n):r.push(a))}t=r.pop()}return n}collides(e){let t=this.data;if(!xl(e,t))return!1;let n=[];for(;t;){for(let s=0;s<t.children.length;s++){let r=t.children[s],o=t.leaf?this.toBBox(r):r;if(xl(e,o)){if(t.leaf||pu(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=vr([]),this}remove(e,t){if(!e)return this;let n=this.data,s=this.toBBox(e),r=[],o=[],a,l,c;for(;n||r.length;){if(n||(n=r.pop(),l=r[r.length-1],a=o.pop(),c=!0),n.leaf){let h=Sx(e,n.children,t);if(h!==-1)return n.children.splice(h,1),r.push(n),this._condense(r),this}!c&&!n.leaf&&pu(n,s)?(r.push(n),o.push(a),a=0,l=n,n=n.children[0]):l?(a++,n=l.children[a],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,s){let r=n-t+1,o=this._maxEntries,a;if(r<=o)return a=vr(e.slice(t,n+1)),_r(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=vr([]),a.leaf=!1,a.height=s;let l=Math.ceil(r/o),c=l*Math.ceil(Math.sqrt(o));zg(e,t,n,c,this.compareMinX);for(let h=t;h<=n;h+=c){let u=Math.min(h+c-1,n);zg(e,h,u,l,this.compareMinY);for(let f=h;f<=u;f+=l){let d=Math.min(f+l-1,u);a.children.push(this._build(e,f,d,s-1))}}return _r(a,this.toBBox),a}_chooseSubtree(e,t,n,s){for(;s.push(t),!(t.leaf||s.length-1===n);){let r=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){let c=t.children[l],h=du(c),u=Ex(e,c)-h;u<o?(o=u,r=h<r?h:r,a=c):u===o&&h<r&&(r=h,a=c)}t=a||t.children[0]}return t}_insert(e,t,n){let s=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(s,this.data,t,r);for(o.children.push(e),Uo(o,s);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){let n=e[t],s=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,s);let o=this._chooseSplitIndex(n,r,s),a=vr(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,_r(n,this.toBBox),_r(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=vr([e,t]),this.data.height=e.height+1,this.data.leaf=!1,_r(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let s,r=1/0,o=1/0;for(let a=t;a<=n-t;a++){let l=Do(e,0,a,this.toBBox),c=Do(e,a,n,this.toBBox),h=Tx(l,c),u=du(l)+du(c);h<r?(r=h,s=a,o=u<o?u:o):h===r&&u<o&&(o=u,s=a)}return s||n-t}_chooseSplitAxis(e,t,n){let s=e.leaf?this.compareMinX:wx,r=e.leaf?this.compareMinY:Ax,o=this._allDistMargin(e,t,n,s),a=this._allDistMargin(e,t,n,r);o<a&&e.children.sort(s)}_allDistMargin(e,t,n,s){e.children.sort(s);let r=this.toBBox,o=Do(e,0,t,r),a=Do(e,n-t,n,r),l=vl(o)+vl(a);for(let c=t;c<n-t;c++){let h=e.children[c];Uo(o,e.leaf?r(h):h),l+=vl(o)}for(let c=n-t-1;c>=t;c--){let h=e.children[c];Uo(a,e.leaf?r(h):h),l+=vl(a)}return l}_adjustParentBBoxes(e,t,n){for(let s=n;s>=0;s--)Uo(t[s],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():_r(e[t],this.toBBox)}};function Sx(i,e,t){if(!t)return e.indexOf(i);for(let n=0;n<e.length;n++)if(t(i,e[n]))return n;return-1}function _r(i,e){Do(i,0,i.children.length,e,i)}function Do(i,e,t,n,s){s||(s=vr(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=e;r<t;r++){let o=i.children[r];Uo(s,i.leaf?n(o):o)}return s}function Uo(i,e){return i.minX=Math.min(i.minX,e.minX),i.minY=Math.min(i.minY,e.minY),i.maxX=Math.max(i.maxX,e.maxX),i.maxY=Math.max(i.maxY,e.maxY),i}function wx(i,e){return i.minX-e.minX}function Ax(i,e){return i.minY-e.minY}function du(i){return(i.maxX-i.minX)*(i.maxY-i.minY)}function vl(i){return i.maxX-i.minX+(i.maxY-i.minY)}function Ex(i,e){return(Math.max(e.maxX,i.maxX)-Math.min(e.minX,i.minX))*(Math.max(e.maxY,i.maxY)-Math.min(e.minY,i.minY))}function Tx(i,e){let t=Math.max(i.minX,e.minX),n=Math.max(i.minY,e.minY),s=Math.min(i.maxX,e.maxX),r=Math.min(i.maxY,e.maxY);return Math.max(0,s-t)*Math.max(0,r-n)}function pu(i,e){return i.minX<=e.minX&&i.minY<=e.minY&&e.maxX<=i.maxX&&e.maxY<=i.maxY}function xl(i,e){return e.minX<=i.maxX&&e.minY<=i.maxY&&e.maxX>=i.minX&&e.maxY>=i.minY}function vr(i){return{children:i,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function zg(i,e,t,n,s){let r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;let o=e+Math.ceil((t-e)/n/2)*n;_l(i,o,e,t,s),r.push(e,o,o,t)}}var bl=class{#e=new Fo;#t=0;#n=.9;constructor({padding:e=4,scaleFactor:t=.9}={}){this.#n??=t,this.#t??=e}handleCollision(e,t){let n=e.properties.iconAllowOverlap,s=ug({lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]},t),r=this.#t,o=this.#n,a=this.#i(s,e.properties.iconSize,r);a.viewModel=e,a.scaled=!1,a.isActiveState=n;let l=this.#e.search(a).filter(h=>!h.scaled&&!h.isActiveState),c=0;for(;l.length>0&&c<=3;){if(c++,!n){let h=this.#r(e,o);a=this.#i(s,h.properties.iconSize,r),a.viewModel=h,a.scaled=!0,a.isActiveState=n}l.forEach(h=>{h.viewModel=this.#r(h.viewModel,o);let u=this.#i(s,h.viewModel.properties.iconSize,r);h.minX=u.minX,h.minY=u.minY,h.maxX=u.maxX,h.maxY=u.maxY,h.scaled=!0,this.#e.remove(h),this.#e.insert(h)}),l=this.#e.search(a).filter(h=>l.includes(h)&&!h.isActiveState)}this.#e.insert(a)}#i(e,t,n=0){return{minX:e.x-t.width/2-n,minY:e.y-t.height/2-n,maxX:e.x+t.width/2+n,maxY:e.y+t.height/2+n}}#r(e,t){let n=e.properties.icon,{width:s,height:r}=e.properties.iconSize,o={width:s*t,height:r*t};return e.properties.iconSize={width:s*t,height:r*t},e.properties.iconScale=o.width/n.naturalWidth,e}};var Ix=new Ct({}),Rx=1e5,Vg=2e5,Cx=3e5,Lx=4e5,Px=5e5,Nx=6e5,Ox=7e5,Bo=8e5,Dx=9e5,gu=0,Gg=4e5-1;async function yu({viewData:i,viewDataMap:e,mapsIndoors:t,options:n={},callback:s=()=>{}}){let{dynamicIconScaling:r=!1,roomExtrusions:o=!1}=n,a=new Map,l=new Map,c=new Set(t.getHighlight()),h=t.getMapView().getZoom(),u=new bl,f=[];function d(y){return y&&l.set(y.id,y),y}for(let[y,g]of i.entries()){let p=t.getStatefulDisplayRule(g);if(!Ml(p)||!mu(g)||Ke(p.model2DModel))continue;let m=t.getLocationSettings(g),M=Lx+y,b=Xx(g,p,M,m,t).then(d),S=Wx(g,p,M,m,n,t).then(d);f.push(S,b)}for(let[y,g]of i.entries()){if(["Polygon","MultiPolygon"].indexOf(g?.geometry?.type)===-1)continue;let p=t.getStatefulDisplayRule(g);if(!Ml(p))continue;let m=t.getLocationSettings(g),M=Cx+y,b=await qx(g,p,M,m,t);d(b)}s(l);for(let[y,g]of i.entries()){if(!g||!mu(g))continue;if(g?.liveUpdates?.size>0){let j=e.get(g.id);for(let[v,_]of g.liveUpdates){let x=new Date(_.timestamp),T=j&&j.liveUpdates&&j.liveUpdates.has(v)?new Date(j.liveUpdates.get(v).timestamp):null;x>T&&(a.has(v)?a.get(v).push(g):a.set(v,[g]))}}let p=t.getStatefulDisplayRule(g);if(!Ml(p))continue;let m=t.getLocationSettings(g),M=t.getSelectedLocation()?.id===g.id,b=c.has(g.id),S=t.getHoveredLocation()?.id===g.id,O={isSelected:M,isHighlighted:b,isHovered:S},L=Vg+y,R=Rx+y,C=await Hx(g,p,R,O,m,t);if(C&&(r&&u.handleCollision(C,h),d(C)),p.labelType===gl.FLOATING){let j=await zx(g,p,L,m,t,C);d(j)}else if(p.labelType===gl.FLAT){let j=await Vx(g,p,L,m,t);d(j)}else if(p.labelType===gl.GRAPHIC){let j=t.getHoveredLocation()?.id===g.id,v=c.has(g.id),_=Vg+y,x=await $x(g,p,_,m,M,j,v,t);d(x)}}s(l);for(let[y,g]of i.entries())if(g){let p=t.getStatefulDisplayRule(g),m=t.getLocationSettings(g);if(!Ml(p))continue;if(!Ke(g.properties.wallGeometry)){let M=Px+y,b=Yx(g,p,M,m,t).then(d);f.push(b)}if(o&&!Ke(g.properties.extrusionGeometry)){let M=Nx+y,b=Kx(g,p,M,m,t).then(d);f.push(b)}if(!Ke(p.model3DModel)&&mu(g)){let M=Ox+y,b=Zx(g,p,M,m,t).then(d);f.push(b)}}return await Promise.all(f),a.size>0&&t.emit("livedata_locations_updated",{data:a}),l}function ji(i,e,t){return i=i!==null?Number(i):NaN,e=i!==null?Number(e):NaN,!Number.isFinite(i)||!Number.isFinite(e)||i<0||e<0?!1:i<=t&&e>=t}function mu(i){return i.geometry.type==="Point"||i.properties.anchor&&i.properties.anchor.type==="Point"}function Ml(i){return i.visible===!0}function Sl(i,e){let t=i.labelZoomFrom||i.zoomFrom,n=i.labelZoomTo||i.zoomTo;return i.labelVisible&&ji(t,n,e)&&i.label>""}function Ux(i,e){let t=i.wallsZoomFrom||i.zoomFrom,n=i.wallsZoomTo||i.zoomTo;return i.wallsVisible===!0&&ji(t,n,e)}function Fx(i,e){let t=i.extrusionZoomFrom||i.zoomFrom,n=i.extrusionZoomTo||i.zoomTo;return i.extrusionVisible===!0&&ji(t,n,e)}function Bx(i,e){let t=i.model3DZoomFrom||i.zoomFrom,n=i.model3DZoomTo||i.zoomTo;return i.model3DVisible===!0&&ji(t,n,e)}function _u(i,e){let t=i.zoomFrom||0,n=i.zoomTo||Number.MAX_VALUE;return i.iconVisible===!0&&ji(t,n,e)}function Wg(i,e){let t=i.badgeZoomFrom||0,n=i.badgeZoomTo||Number.MAX_VALUE;return i.badgeVisible===!0&&ji(t,n,e)}function kx(i,e){return i.clickable===!0&&(_u(i,e)||Sl(i,e))}function Hg(i,e){let t=i.polygonZoomFrom||0,n=i.polygonZoomTo||Number.MAX_VALUE;return i.polygonVisible&&ji(t,n,e)}function Xg(i,e){let t=i.model2DZoomFrom||0,n=i.model2DZoomTo||Number.MAX_VALUE;return i.model2DWidthMeters>0&&i.model2DHeightMeters>0&&i.model2DModel&&i.model2DVisible===!0&&ji(t,n,e)}function _i(i,e){let t=e?.selectable!==!1,n=i.clickable;return(Ke(n)||n)&&t}function zx(i,e,t,n,s,r){let a=s.getMapView().getZoom();if(Sl(e,a)){let l={clickable:_i(e,n),originalId:i.id,featureClass:Ee.LABEL_FLOATING,sortKey:t,labelText:wl(e.label,i),...jx(s,e,r)},c={type:"Feature",id:`TEXT_LABEL:${i.id}`,geometry:Yi(i.properties.anchor||i.geometry),properties:l};return Promise.resolve(c)}else return Promise.resolve(null)}function Vx(i,e,t,n,s){let r=s.getMapView(),o=r.getZoom(),l=(r.getBearing()%360+360)%360,c=Ke(e.labelStyleBearing)?se.labelStyle.bearing:e.labelStyleBearing,h=Math.abs(l-c)<=90||Math.abs(l-c)>=270?c:c+180;if(Sl(e,o)){let u={clickable:_i(e,n),originalId:i.id,featureClass:Ee.LABEL_FLAT,sortKey:t,labelText:wl(e.label,i),labelStyleBearing:h,...eb(s,e)},f={type:"Feature",id:`FLAT_LABEL:${i.id}`,geometry:Yi(i.properties.anchor||i.geometry),properties:u};return Promise.resolve(f)}else return Promise.resolve(null)}async function Hx(i,e,t,{isSelected:n,isHighlighted:s,isHovered:r},o,a){let c=a.getMapView().getZoom(),h={originalId:i.id,featureClass:Ee.POINT},u,f,d;return _u(e,c)&&(u=await e.getIcon(),f=xu(e),d=nb(e)),Wg(e,c)&&(u=await Gx(u,e),f={width:u.width,height:u.height},d={x:f.width/2,y:f.height/2}),u?(Object.assign(h,{clickable:_i(e,o),title:wl(e.title,i),iconAnchor:d,icon:u,iconSrc:u.src,iconSize:f,iconScale:f.width/u.naturalWidth,sortKey:n?Dx:t,zIndex:i.properties.zIndex,iconAllowOverlap:n||s,hovered:r,iconPlacement:ib(e)}),{type:"Feature",id:`ICON:${i.id}`,geometry:Yi(i.properties.anchor||i.geometry),liveUpdates:i.liveUpdates?new Map([...i.liveUpdates]):void 0,properties:h}):Promise.resolve(null)}async function Gx(i,e){if(!e.badgeVisible)return i;let t={size:xu(e),scale:e.badgeScale,radius:e.badgeRadius,backgroundColor:e.badgeFillColor,position:e.badgePosition??Ct.BadgePosition.TOP_LEFT,strokeColor:e.badgeStrokeColor,strokeWidth:e.badgeStrokeWidth};return await Ix.overlay(i,t)}function Wx(i,e,t,n,s,r){let{roomExtrusions:o}=s;return new Promise(a=>{let c=r.getMapView().getZoom();if(Xg(e,c)){let h=o&&e.extrusionVisible?(e.extrusionHeight??0)+.001:.001;fr.get(e.model2DModel).then(u=>{let f=[e.model2DWidthMeters/u.naturalWidth,1,e.model2DHeightMeters/u.naturalHeight],d={type:"Feature",id:`2DMODEL:${i.id}`,geometry:i.properties.anchor??i.geometry,properties:{clickable:_i(e,n),originalId:i.id,featureClass:Ee.MODEL2D,sortKey:t,fillOpacity:0,strokeOpacity:0,strokeWidth:0,widthMeters:e.model2DWidthMeters,heightMeters:e.model2DHeightMeters,bearing:e.model2DBearing,rotation:[90,0,(e.model2DBearing%360+360)%360],scale:f,translation:[0,0,h],imageUrl:u.src}};return a(d)})}else return a(null)})}function Xx(i,e,t,n,s){let o=s.getMapView().getZoom();if(!Xg(e,o)||!_i(e,n))return Promise.resolve(null);let a=(e.model2DBearing%360+360)%360,l=i.properties.anchor??i.geometry,{width:c,height:h}={width:e.model2DWidthMeters,height:e.model2DHeightMeters},[,u]=yl(()=>ag(l,c,h,a)),f={type:"Feature",id:`2DMODEL_POLYGON:${i.id}`,geometry:u?.geometry??i.geometry,properties:{clickable:!0,originalId:i.id,featureClass:Ee.POLYGON,sortKey:t,fillOpacity:0,strokeOpacity:0,strokeWidth:0}};return Promise.resolve(f)}function qx(i,e,t,n,s){let o=s.getMapView().getZoom(),a={type:"Feature",id:`POLYGON:${i.id}`,geometry:i.geometry,liveUpdates:i.liveUpdates?new Map([...i.liveUpdates]):void 0,properties:{clickable:_i(e,n),originalId:i.id,featureClass:Ee.POLYGON,sortKey:i.properties.zIndex||t||0,type:i.properties.type}};return Hg(e,o)?(Object.assign(a.properties,{fillColor:ml(e.polygonFillColor,e.polygonLightnessFactor),fillOpacity:e.polygonFillColor>""?e.polygonFillOpacity:0,strokeColor:ml(e.polygonStrokeColor||e.polygonFillColor||"#000",e.polygonLightnessFactor),strokeOpacity:e.polygonStrokeColor>""?isNaN(e.polygonStrokeOpacity)?1:e.polygonStrokeOpacity:0,strokeWidth:e.polygonStrokeColor>""?parseInt(e.polygonStrokeWeight??2):0}),Promise.resolve(a)):Hg(e,o)&&kx(e,o)?(Object.assign(a.properties,{fillOpacity:0,strokeOpacity:0}),Promise.resolve(a)):Promise.resolve(null)}function Yx(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<gu||!Ux(e,o))return Promise.resolve(null);{let a={type:"Feature",id:`WALL_EXTRUSION:${i.id}`,geometry:i.properties.wallGeometry,properties:{clickable:_i(e,n),featureClass:Ee.WALL_EXTRUSION,originalId:i.id,sortKey:i.properties.zIndex||t||0,type:"MI_EXTRUDED_WALLS",fillColor:e.wallsColor,height:e.wallsHeight}};return Promise.resolve(a)}}function Kx(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<gu||!Fx(e,o))return Promise.resolve(null);{let a={type:"Feature",id:`ROOM_EXTRUSION:${i.id}`,geometry:i.properties.extrusionGeometry,properties:{clickable:_i(e,n),featureClass:Ee.ROOM_EXTRUSION,originalId:i.id,sortKey:i.properties.zIndex||t||0,type:"MI_EXTRUDED_ROOM",fillColor:ml(e.extrusionColor,e.extrusionLightnessFactor),height:e.extrusionHeight}};return Promise.resolve(a)}}async function Zx(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<gu||!Bx(e,o))return Promise.resolve(null);{let a=await e.get3DModel(),l={type:"Feature",id:`3DMODEL:${i.id}`,geometry:Yi(i.properties.anchor||i.geometry),properties:{clickable:_i(e,n),featureClass:Ee.MODEL3D,sortKey:i.properties.zIndex||t||0,originalId:i.id,type:"MI_MODEL_3D",modelName:btoa(e.model3DModel),url:a,rotation:[e.model3DRotationX,e.model3DRotationY,e.model3DRotationZ],scale:[e.model3DScale,e.model3DScale,e.model3DScale]}};return Promise.resolve(l)}}async function $x(i,e,t,n,s,r,o,a){let c=(await a.getMapView()).getZoom();if(Sl(e,c)){let h={clickable:_i(e,n),originalId:i.id,featureClass:Ee.LABEL_GRAPHIC,sortKey:i?.properties?.zIndex||t||0,labelText:wl(e.label,i),...ob(e,s,o),...Qx(a,e,r,s,o)},u={type:"Feature",id:`GRAPHIC_LABEL:${i.id}`,geometry:Yi(i.properties.anchor||i.geometry),properties:h};return Promise.resolve(u)}else return Promise.resolve(null)}function wl(i,e,t){let n=/{{(.*?)}}/g,s,r=i;for(;(s=n.exec(i))!==null;)r=r.replace(s[0],e.properties[s[1]]||"");return r&&t>0&&r.length>t&&(r=r.slice(0,t).trim()+"\u2026"),r}function Jx(i,e){let t=i.getLabelOptions()||{};t.style=t.style||{};let n=t.style.fontSize?parseInt(t.style.fontSize):parseInt(yi.fontSize);return{labelFont:t.style.fontFamily||yi.fontFamily,labelSize:n,labelFontWeight:t.style.fontWeight||yi.fontWeight,labelColor:t.style.color||yi.color,labelStrokeStyle:t.style.strokeStyle||yi.strokeStyle,labelStrokeWidth:parseInt(t.style.strokeWeight||yi.strokeWeight),labelShadowBlur:t.style.shadowBlur?parseInt(t.style.shadowBlur):yi.shadowBlur,labelShadowColor:t.style.shadowColor||yi.shadowColor,labelOffset:qg(n,e.iconVisible,t.pixelOffset),labelMaxWidth:e.labelMaxWidth||-1,labelMaxLength:t.maxLength||yi.maxLength}}function vu(i,e){let t=i.getLabelOptions()||{};return t.style=t.style||{},{labelMaxWidth:e.labelMaxWidth>=0?e.labelMaxWidth:-1,labelStyleHaloColor:t.style.shadowColor||e.labelStyleHaloColor||se.labelStyle.haloColor,labelStyleOpacity:t.style.textOpacity>=0?t.style.textOpacity:e.labelStyleTextOpacity>=0?e.labelStyleTextOpacity:se.labelStyle.textOpacity}}function jx(i,e,t){let n=i.getLabelOptions()||{};n.style=n.style||{};let r=i.getMapView().getZoom(),o=Jx(i,e),a=sb(e);return{...o,labelOffset:n.pixelOffset?qg(e.labelStyleTextSize,e.iconVisible,n.pixelOffset):tb(e,a,t?.properties?.iconSize),labelStylePosition:_u(e,r)||Wg(e,r)?a:se.labelStyle.position,labelStyleSize:n.style.fontSize?parseInt(n.style.fontSize):parseInt(n.style.fontSize)||e.labelStyleTextSize||se.labelStyle.textSize,labelStyleColor:n.style.color||e.labelStyleTextColor||se.labelStyle.textColor,labelStyleHaloBlur:parseInt(n.style.shadowBlur)>=0?n.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:se.labelStyle.haloBlur,labelStyleHaloWidth:n.style.haloWidth>=0?n.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:se.labelStyle.haloWidth,...vu(i,e),iconPlacement:t?.properties?.iconPlacement}}function Qx(i,e,t,n,s){let r=i.getLabelOptions()||{};r.style=r.style||{};let o=3;return{labelStyleSize:t?r.style.fontSize?parseInt(r.style.fontSize)+o:parseInt(r.style.fontSize)||e.labelStyleTextSize+o:e.labelStyleTextSize||se.labelStyle.textSize,labelStyleColor:n||s?"#FFFFFF":r.style.color||e.labelStyleTextColor||se.labelStyle.textColor,labelStyleHaloBlur:n||s?0:parseInt(r.style.shadowBlur)>=0?r.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:se.labelStyle.haloBlur,labelStyleHaloWidth:n||s?0:r.style.haloWidth>=0?r.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:se.labelStyle.haloWidth,...vu(i,e)}}function eb(i,e){let t=i.getLabelOptions()||{};return t.style=t.style||{},{labelStyleSize:t.style.fontSize?parseInt(t.style.fontSize):parseInt(t.style.fontSize)||e.labelStyleTextSize||se.labelStyle.textSize,labelStyleColor:t.style.color||e.labelStyleTextColor||se.labelStyle.textColor,labelStyleHaloBlur:parseInt(t.style.shadowBlur)>=0?t.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:se.labelStyle.haloBlur,labelStyleHaloWidth:t.style.haloWidth>=0?t.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:se.labelStyle.haloWidth,...vu(i,e)}}function tb(i,e,t){let n=i.labelStyleTextSize>0?i.labelStyleTextSize:12,s=15,r=0,o=0,{widthOffset:a,heightOffset:l}=rb(t,n,s);switch(i.iconPlacement.toLowerCase()){case Zt.LEFT:r=-a/2;break;case Zt.RIGHT:r=a/2;break;case Zt.ABOVE:o=-l/2;break;case Zt.BELOW:o=l/2;break}switch(e){case ei.RIGHT:return[a+r,o];case ei.LEFT:return[-a+r,o];case ei.TOP:return[r,-l+o];case ei.BOTTOM:return[r,l+o];default:return[0,0]}}function qg(i,e,t){let n={height:e===!1?0:t?t.height:20,width:t?t.width:0};return[n.width/i,n.height/i]}function nb(i){let e=xu(i);return i.anchor||{x:Math.round(e.width/2),y:Math.round(e.height/2)}}function xu(i){let e=i.iconScale??i.imageScale??1,{width:t,height:n}=i.iconSize??i.imageSize;return t>0&&n>0?{width:t*e,height:n*e}:{width:24*e,height:24*e}}function ib(i){switch(i?.iconPlacement?.toLowerCase()){case Zt.ABOVE:return"bottom";case Zt.RIGHT:return"left";case Zt.BELOW:return"top";case Zt.LEFT:return"right";default:return"center"}}function sb(i){switch(i?.labelStylePosition?.toLowerCase()){case ei.BOTTOM:return"bottom";case ei.LEFT:return"left";case ei.RIGHT:return"right";case ei.TOP:return"top";default:return"center"}}function rb(i,e,t){let n=i?i.width:0,s=i?i.height:0,o=document.createElement("canvas").getContext("2d");o.font=`${e}px Open Sans Bold`;let a=o.measureText("Mjgp"),l=(n+t)/2/e,c=s/2/(a.fontBoundingBoxAscent-a.fontBoundingBoxDescent);return{widthOffset:l,heightOffset:c}}function ob(i,e,t){let n=new Image;return n.crossOrigin="Anonymous",n.width=80,n.height=32,e&&!t?(n.src=Is?.labelStyle?.graphic?.backgroundImage??se.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:Is?.labelStyle?.graphic?.stretchX??se.labelStyle.graphic.stretchX,stretchY:Is?.labelStyle?.graphic?.stretchY??se.labelStyle.graphic.stretchY,content:Is?.labelStyle?.graphic?.content??se.labelStyle.graphic.content}}):t?(n.src=Ts?.labelStyle?.graphic?.backgroundImage??se.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:Ts?.labelStyle?.graphic?.stretchX??se.labelStyle.graphic.stretchX,stretchY:Ts?.labelStyle?.graphic?.stretchY??se.labelStyle.graphic.stretchY,content:Ts?.labelStyle?.graphic?.content??se.labelStyle.graphic.content}}):(n.src=i?.labelStyleGraphic?.backgroundImage??se.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:i?.labelStyleGraphic?.stretchX??se.labelStyle.graphic.stretchX,stretchY:i?.labelStyleGraphic?.stretchY??se.labelStyle.graphic.stretchY,content:i?.labelStyleGraphic?.content??se.labelStyle.graphic.content}})}var Al=class extends Yg.EventEmitter{#e=!1;#t;#n;#i;#r=!1;#o=!1;constructor(e){super(),this.#t=e,this.#n=new Set,this.#i=new Map}#a(){return this.#t.getMapView()?.getBounds()}#s(){return this.#t?.getFloor()}#l(){return this.#t?.getSolutionConfig()}#c(){return this.#t?.getMapView()?.getZoom()}addDataSource(e){return typeof e=="function"?(this.#n.add(e),e):null}set dynamicIconScaling(e){this.#r=e}get dynamicIconScaling(){return this.#r}set roomExtrusions(e){this.#o=e}get roomExtrusions(){return this.#o}#h(e){this.#i=e,!this.#e&&(this.#e=!0,window.requestAnimationFrame(()=>{this.emit("partial_update",this.#i),this.#e=!1}))}#u=!1;#f=null;update(e=!1){if(this.#u){this.#f={fitView:e};return}this.#u=!0;let t=this.#l(),n=this.#a(),s=this.#s(),r=this.#c(),o={dynamicIconScaling:this.#r,roomExtrusions:this.#o};if(Ke(n)||Ke(s)||Ke(r)){this.#u=!1;return}if(r<(t?.minimumDataLoadZoomLevel??10)){this.#u=!1;return}window.requestAnimationFrame(()=>{Promise.all(Array.from(this.#n).map(a=>a.apply(null,[n,s]))).then(a=>[...new Map(a.flat().map(l=>[l?.id,l])).values()]).then(a=>this.#d(a)).then(a=>this.#p(a,e,this.#t)).then(a=>ab(a)).then(a=>yu({viewData:a,viewDataMap:this.#i,mapsIndoors:this.#t,options:o,callback:this.#h.bind(this)})).then(a=>this.#i=a).finally(()=>{setTimeout(()=>{if(this.emit("update_completed"),this.#u=!1,this.#f){let{fitView:a}=this.#f??{};this.#f=null,this.update(a)}})})})}getViewData(){return this.#i}#d(e){let t=this.#t.getFilter();return t&&t.length>0?e.filter(n=>n?(n.properties&&typeof n.properties.type=="string"?n.properties.type:"").toLowerCase().startsWith("mi_")||t.includes(n.id):!1):e}#p(e,t,n){if(t&&e.length>0){let s=[180,90,-180,-90],r=e.reduce((o,a)=>{if(!a||a?.properties?.type?.toLowerCase()?.startsWith("mi_"))return o;let l=Dt.fromGeoJSON(a.geometry);return o.bbox=Dt.combine(o.bbox,l),o.features.push(a),o},{type:"FeatureCollection",features:[],bbox:s});Dt.equals(r.bbox,s)||n.goTo(r,{padding:50})}return e}};function ab(i){let e=[];for(let t of i)t&&!isNaN(t.area)&&So(e,t,(n,s)=>n.area>s.area);return e}E();var xr=class{static merge(e){return e.reduce((t,n={})=>{for(let s of Object.keys(n))(t[s]===void 0||n[s]!==null&&n[s]!==void 0)&&(t[s]=n[s]);return t},new xr)}};E();var Kg=Jt(Sn()),bu=class extends Kg.EventEmitter{},Mu=new bu;E();var Zg=Jt(Sn()),Ds=class extends Zg.EventEmitter{#e=new Map;set(e,t){if(e instanceof Map&&!t)for(let[n,s]of e)this.#e.set(n.toLowerCase(),s);else{let n=e instanceof Array?e:[e];for(let s of n)t?this.#e.set(s.toLowerCase(),t):this.#e.delete(s.toLowerCase())}this.emit("change")}get(e){return this.#e.get(e?.toLowerCase())}clear(){this.#e.clear()}};var Qg=Jt(Sn());E();E();var Su=class{static validateModel(e,t,n){let s={...e};return Reflect.ownKeys(s).reduce((r,o)=>{let a=t[o],l=s[o];!a||a(l)||n&&(s[o]=n[o])},[]),s}static failedValidations(e,t){let n=[];return Reflect.ownKeys(e).reduce((s,r)=>{let o=t[r],a=e[r];!o||o(a)||n.push(r)},[]),n.length>0&&console.error(`Validations failures: ${n.join(", ")}`),n}},El=Su;E();var $g=i=>El.validateModel(i,{extrusionOpacity:un.isNumber,wallOpacity:un.isNumber},In.DEFAULTS),In=class{constructor(e){Object.assign(this,$g(e))}static merge(e,t){return new In({...e,...$g(t)})}static get DEFAULTS(){return Object.freeze({extrusionOpacity:1,wallOpacity:1})}};var lb={enableClustering:!0,collisionHandling:0},Jg=i=>El.validateModel(i,{enableClustering:un.isBoolean,collisionHandling:un.isNumber,automatedZoomLimit:un.optional(un.isNumber),settings3D:un.isAny,mainDisplayRule:un.isAny,stateDisplayRules:un.isAny},lb),Ei=class{#e;#t={hover:new st(wm),highlight:new st(Ts),selection:new st(Is),hoverHighlight:new st(Am),hoverSelection:new st(Em)};#n;#i;#r(){return this.#e}#o(e){this.#e=st.merge([st.DEFAULT_RULE,this.#e,e])}#a(){return this.#t}#s(e){e??={};for(let[t,n]of Object.entries(e))t in this.#t&&(this.#t[t]=new st({...this.#t[t],...n}))}#l(){return this.#n}#c(e){this.#n=In.merge(this.#n,e)}#h(){return this.#i}#u(e){this.#i=st.merge([Xa,e])}constructor(e){Object.defineProperty(this,"mainDisplayRule",{enumerable:!0,get:this.#r,set:this.#o}),Object.defineProperty(this,"settings3D",{enumerable:!0,get:this.#l,set:this.#c}),Object.defineProperty(this,"buildingHighlightDisplayRule",{enumerable:!0,get:this.#h,set:this.#u}),Object.defineProperty(this,"stateDisplayRules",{enumerable:!0,get:this.#a,set:this.#s});let t;e&&(t=Yi(e)),Object.assign(this,Jg(t))}static merge(e,t){if(!e&&!t)return new Ei;if(!t)return e;let n=Jg(t),s={...e,...n};return s.buildingHighlightDisplayRule={...e.buildingHighlightDisplayRule,...n.buildingHighlightDisplayRule},s.settings3D={...e.settings3D,...n.settings3D},s.mainDisplayRule={...e.mainDisplayRule,...n.mainDisplayRule},s.stateDisplayRules={...e.stateDisplayRules,...n.stateDisplayRules},new Ei(s)}};var jg=()=>{},vi=class extends Qg.default{#e=new Et;#t=new Ds;#n;#i=new Ds;#r=new Ds;#o=new Set;#a=new Set;#s=new Et;#l;#c=null;#h=null;#u="automatic";#f="automatic";constructor(e){super();let t=e||{};this.__VERSION__="4.41.2",this.#l=new Al(this),this.#f=e?.buildingSelectionMode?.toLowerCase()==="manual"?"manual":"automatic",this.#u=e?.floorSelectionMode?.toLowerCase()==="manual"?"manual":"automatic";let n=this.#l;n.addDataSource((s,r)=>fn.dataSource(s,r).then(o=>(this.emit("locations_changed",o),o))),n.addDataSource((s,r)=>{if(this.#f==="manual"){let o=this.getBuilding();return o?.floors?.[r]?.geometry?Promise.resolve({id:`MI_${o.id}_${r}`,type:"Feature",geometry:o.floors[r].geometry,area:o.area,properties:{type:$t.MIType.MI_BUILDING_OUTLINE}}):Promise.resolve(null)}else{let o=this.getMapView();if(o.getPitch()!==0){let l=o.getDiv(),c=l.offsetWidth,h=l.offsetHeight,u=o.getCenter(),f=o.unproject(c>h?{x:c,y:h/2}:{x:c/2,y:h}),d=Lt.computeDistanceBetween(u,f),y=Lt.computeDestination(u,d,225),g=Lt.computeDestination(u,d,45);s={south:y.lat,west:y.lng,north:g.lat,east:g.lng}}return this.#v(s).then(l=>!l||!(l.floors&&l.floors[r])?null:{id:`MI_${l.id}_${r}`,type:"Feature",geometry:l.floors[r].geometry,area:l.area,properties:{type:$t.MIType.MI_BUILDING_OUTLINE,zIndex:Gg}})}});for(let[s,r]of Object.entries(Tm))this.#t.set(s,r);ce.on("apikey_changed",()=>{mt.getVenues().then(s=>{s.length&&(ce.venuesToSync?.length>0&&(s=s.filter(r=>ce.venuesToSync.includes(r.id))),this.setVenue(s[0]))})}),this.#s.addListener("venue_changed",({oldValue:s})=>{let r=this.getVenue(),o=this.getFloor();if(typeof r=="string"&&r>""){mt.getVenue(r).then(a=>this.setVenue(a));return}if(this.#f==="automatic"&&this.#u==="automatic"){let a=s?.id===r?.id?this.getFloor()??r.defaultFloor:r.defaultFloor??o??0;this.setFloor(a)}this.setMapsIndoorsStyle(t.mapStyle||r?.styles?.[0]),this.getMapView().setMapsIndoorsTileURL(this.getTileURL()),this.#_().then(a=>this.getMapView().setFloorPlan(a)),s?.id!==r?.id&&(this.#g(r?.geometry),this.emit("venue_changed",r))}),n.on("update_completed",this.#y.bind(this)),n.on("partial_update",this.#y.bind(this)),this.#s.addListener("building_changed",({oldValue:s})=>{let r=this.getBuilding(),o=this.getFloor(),a=this.#u?.toLowerCase()==="automatic"?Cm(o,r):void 0;!Ke(a)&&a!==o?this.setFloor(a):n.update(),s?.id!==r?.id&&this.emit("building_changed",r)}),this.#s.addListener("floor_changed",()=>{let s=this.getMapView();if(s&&s.isReady){n.update();let r=Number(this.getFloor());this.getMapView().setMapsIndoorsTileURL(this.getTileURL()),this.#_().then(o=>this.getMapView().setFloorPlan(o)),this.emit("floor_changed",r)}}),this.addListener("data_updated",this.#m.bind(this)),Mu.on("synchronize_content",this.#m.bind(this)),this.#i.addListener("change",this.#m.bind(this)),this.#r.addListener("change",this.#m.bind(this)),this.#s.addListener("solutionconfig_changed",()=>{let s=this.#s.get("solutionConfig"),r=this.#s.get("buildingOutlineOptions"),o=st.merge([s?.buildingHighlightDisplayRule,{polygon:r}]);this.setDisplayRule($t.MIType.MI_BUILDING_OUTLINE,o),this.getMapView()?.setSolutionConfig(s),n.update(),this.emit("redraw")}),this.#s.addListener("mapview_changed",()=>{let s=this.getMapView();s.addListener("bounds_changed",ni(500,function(){n.update()})),s.addListener("ready",()=>{this.#l.update()}),s.addListener("click",a=>{fn.getLocation(a).then(l=>{this.emit("click",l),Rt.log(pt.map.MAP_CLICKED,{location_type:l?.properties?.locationType})})}),s.addListener("mouseenter",({id:a})=>{let l=this.#h?.id;l!==a&&(l&&r.call(this,l),o.call(this,a))});function r(a){this.#h=this.#h?.id===a?null:this.#h,this.#l.update(),fn.getLocation(a).then(l=>{this.emit("mouseleave",l)})}function o(a){!a||fn.getLocation(a).then(l=>{this.#h=l,this.emit("mouseenter",l),this.#l.update()})}s.addListener("zoom_changed",()=>{this.emit("zoom_changed",this.getZoom())}),Ps.getSolution().then(a=>{let l=new Ei(a.solutionConfig),c=a.modules||[],h=new Map(a.types.map(f=>[f.name.toLowerCase(),f]));this.#s.set("types",h),this.#s.set("solutionConfig",l),this.#s.set("modules",c),c.includes("z22")&&this.getMapView().enableZoom22(),c.includes("dynamicLabelPosition")&&this.getMapView()?.enableDynamicLabelPosition&&this.getMapView().enableDynamicLabelPosition(),this.#l.dynamicIconScaling=c.includes("dynamicIconScaling"),this.#l.roomExtrusions=c.includes("3dextrusions"),a.whitelabel||s.addLogo();let u=this.getVenue();!u||!u.id?this.once("venue_changed",()=>{this.emit("ready")}):this.emit("ready")})}),this.#s.addListener("mapstyle_changed",()=>{let s=this.getVenue();s&&s.id&&this.getMapView().setMapsIndoorsTileURL(this.getTileURL())}),this.#s.addListener("buildingoutlineoptions_changed",()=>{let s=this.#s.get("solutionConfig")?.buildingHighlightDisplayRule,r=this.#i.get($t.MIType.MI_BUILDING_OUTLINE),o=this.#s.get("buildingOutlineOptions"),a=st.merge([r,s,{polygon:o}]);this.setDisplayRule($t.MIType.MI_BUILDING_OUTLINE,a)}),this.#s.addListener("labeloptions_changed",()=>{let s=this.getMapView();s&&s.getBounds()&&(n.update(),s.setLabelOptions(this.#s.get("labelOptions")))}),!t.venue&&!this.getVenue()&&mt.getVenues().then(s=>{this.getVenue()||this.setVenue(s[0])}),ce.on("language_changed",async()=>{let s=this.getVenue()?.id,r=this.getBuilding()?.id,[o,a]=await Promise.all([mt.getVenue(s),mt.getBuilding(r)]);this.#s.set("venue",o),this.#s.set("building",a)}),fn.on("update_completed",()=>{n.update()}),fn.on("locations_deleted",()=>{n.update()}),this.#s.setValues(t),this.#s.addListener("floorselectionmode_changed",({newValue:s,oldValue:r})=>{r!==s&&(this.#u=s?.toLowerCase()==="manual"?"manual":"automatic",this.#s.set("building",this.getBuilding(),!0))}),this.#s.addListener("buildingselectionmode_changed",({newValue:s,oldValue:r})=>{r!==s&&(this.#f=s?.toLowerCase()==="manual"?"manual":"automatic",this.#s.set("building",this.getBuilding(),!0))}),ce.on("userroles_changed",()=>{this.#l.update()}),Rt.log(pt.appLifeTime.MAPSINDOORS_INSTANTIATED)}getBuilding(){return this.#s.get("building")}setBuilding(e){if(Object.keys(e.floors??{}).length===0){mt.getBuilding(e.id).then(t=>this.#s.set("building",t));return}this.#s.set("building",e)}fitBuilding(e,{padding:t,maxZoom:n}={padding:0}){e=e||this.getBuilding();let s=this.getMapView();return e?new Promise((r,o)=>{(typeof e=="string"?mt.getBuilding(e):Promise.resolve(e)).then(a=>{s&&s.isReady?this.goTo(a?.geometry,{padding:t,maxZoom:n}).then(r,o):this.once("ready",()=>{this.fitBuilding.call(this,a).then(r,o)})}).catch(o)}):Promise.reject()}goTo(e,{padding:t,maxZoom:n}={padding:0}){let s=this.#s.get("solutionConfig"),r=this.getMapView(),o=r.getDiv()?.getBoundingClientRect()??{};n=n??s?.automatedZoomLimit??r.getMaxZoom();let[a,l]=yl(()=>Dt.fromGeoJSON(e));if(a)return Promise.reject(a);let c=hg(l,o,n),h=Lt.toArray(Dt.getCenter(l)),u=c<=n?l:cg(h,n,o);return r.fitBounds(u,t)}filter(e,t){this.#o=new Set(e),this.#l.update(t)}getFilter(){return[...this.#o]}highlight(e,t){this.#a=new Set(e),this.#l.update(t)}getHighlight(){return[...this.#a]}hoverLocation(e){e?.id!==this.#h?.id&&(this.#h=e,this.#l.update())}unhoverLocation(){this.#h=null,this.#l.update()}getHoveredLocation(){return this.#h}selectLocation(e){e?.id!==this.#c?.id&&(this.#c=e,this.#l.update())}deselectLocation(){this.#c=null,this.#l.update()}getSelectedLocation(){return this.#c}getLocationSettings(e){if(!e?.id)return null;let t=this.#s.get("solutionConfig"),n=e?.properties?.type?.toLowerCase(),r=(this.#s.get("types")??new Map).get(n)??{},o=e.properties.locationSettings,a=[t?.locationSettings||{},r.locationSettings||{},this.#e.get(n)||{},o||{},this.#e.get(e.id)||{}];return xr.merge(a)}setLocationSettings(e,t){let n=[].concat(e);if(n.length!==0)for(let s of n){let r=s?.id??s?.toLowerCase();!r||this.#e.set(r,t)}}setBuildingOutlineOptions(e){this.#s.set("buildingOutlineOptions",e)}getBuildingOutlineOptions(){let e=this.#s.get("buildingOutlineOptions"),t=Xa;return Object.assign({},{visible:t.visible,strokeColor:t.polygonStrokeColor,strokeOpacity:t.polygonStrokeOpacity,strokeWeight:t.polygonStrokeWeight,zoomFrom:t.zoomFrom,zoomTo:t.zoomTo},e)}_addDataSource(e){this.#l.addDataSource(e)}#d(e){let n=this.#s.get("solutionConfig")?.mainDisplayRule??{},s=e?.properties?.originalId??e?.id,r=e?.properties?.type?.toLowerCase(),o=e?.properties?.displayRule||{},l=(this.#s.get("types")??new Map).get(r)??{};return[st.DEFAULT_RULE,n||{},this.#t.get(r)||{},l.displayRule||{},this.#i.get(r)||{},o,this.#i.get(s)||{}]}setDisplayRule(e,t){this.#i.set(e,t)}getDisplayRule(e,t=!1){let n=this.#d(e),s=t?{}:this.#r.get(e?.id);return st.merge([...n,s])}getStatefulDisplayRule(e,t=!1){let n=this.#d(e),s=this.#p(e?.id),r=t?{}:this.#r.get(e?.id);return st.merge([...n,s,r])}#p(e){let t=this.#s.get("solutionConfig"),{highlight:n,hover:s,hoverHighlight:r,selection:o,hoverSelection:a}=t?.stateDisplayRules??{};return e===this.#h?.id&&e===this.#c?.id?a:e===this.#c?.id?o:e===this.#h?.id&&this.#a.has(e)?r:this.#a.has(e)?n:e===this.#h?.id&&this.getLocationSettings(this.#h).selectable?s:{}}getDirectionsRenderer(){let e=this.getMapView();if(e)return this.#n||(this.#n=new e.DirectionsRenderer(this)),this.#n}setFloor(e){let t=this.getMapView(),n=Number(e),s=Number(this.getFloor());if(!isNaN(n)&&n!==s){if(!t?.isReady){t.once("ready",()=>this.setFloor(e));return}this.#s.set("floor",n)}}getFloor(){return this.#s.get("floor")?.toString()}getMap(){let e=this.getMapView();return e?e.getMap():null}getZoom(){let e=this.getMapView();return e?e.getZoom():null}setZoom(e){let t=this.getMapView();t&&t.setZoom(e)}getMaxZoom(){let e=this.getMapView();return e?e.getMaxZoom():null}setVenue(e){let t=this.getMapView(),n=this.getVenue();(e&&typeof e=="string"&&!n||e&&typeof e=="object"&&!n||e&&typeof e=="object"&&n&&typeof n=="string"||e&&typeof e=="string"&&n&&typeof n=="object"&&n.id!==e||e&&typeof e=="string"&&n&&typeof n=="string"&&n!==e||e&&typeof e=="object"&&n&&typeof n=="object"&&n.id!==e.id)&&(t?n&&e&&n.solutionId>""&&n.solutionId!==e.solutionId?Ps.getSolution().then(s=>{this.once("venue_changed",()=>{this.emit("ready")});let r=new Map(s.types.map(o=>[o.name.toLowerCase(),o]));this.#s.set("types",r),this.#s.set("solutionConfig",new Ei(s.solutionConfig)),this.#s.set("venue",e)}):this.#s.set("venue",e):this.once("ready",()=>{this.setVenue.call(this,e)}))}getVenue(){return this.#s.get("venue")}fitVenue(e,{padding:t,maxZoom:n}={padding:0}){e=e||this.getVenue();let s=this.getMapView();return e?new Promise((r,o)=>{(typeof e=="string"?mt.getVenue(e):Promise.resolve(e)).then(a=>{s&&s.isReady?this.goTo(a?.geometry,{padding:t,maxZoom:n}).then(r,o):s.once("ready",()=>{this.fitVenue.call(this,a).then(r,o)})}).catch(o)}):Promise.reject()}setLabelOptions(e){this.#s.set("labelOptions",e)}getLabelOptions(){return this.#s.get("labelOptions")}setMapsIndoorsStyle(e){e&&e.folder>""&&this.#s.set("mapStyle",e)}getMapIndoorsStyle(){return this.#s.get("mapStyle")}getMapIndoorsStyles(){let e=this.getVenue();if(e?.styles)return e.styles}overrideDisplayRule(e,t){this.#r.set(e,t)}revertDisplayRule(e){this.#r.set(e,null)}setMapView(e){this.#s.set("mapView",e)}getMapView(){return this.#s.get("mapView")}getTileURL(){let e=this.getVenue(),t=this.getMapIndoorsStyle(),n=Number(this.getFloor());return!e?.tilesUrl||!t?.folder||Number.isNaN(n)||typeof e.tilesUrl!="string"?null:e.tilesUrl.replace("{floor}",n).replace("{style}",t.folder)}deallocate(){fr.clear(),this.#i.clear(),this.#t.clear(),this.#r.clear(),this.#s.removeAllListeners(),this.getMapView().deallocate(),ce.removeAllListeners(),this.removeAllListeners()}getSolutionConfig(){return ce.apiKey?this.#s.get("solutionConfig"):null}setSolutionConfig(e){let t=this.#s.get("solutionConfig");if(t){let n=Ei.merge(t,e);this.#s.set("solutionConfig",n)}}setBuildingSelectionMode(e="automatic"){["manual","automatic"].includes(e.toLowerCase())&&e!==this.#f&&this.#s.set("buildingSelectionMode",e)}getBuildingSelectionMode(){return this.#f?.toLowerCase()==="automatic"?"automatic":"manual"}setFloorSelectionMode(e="automatic"){["manual","automatic"].includes(e.toLowerCase())&&e!==this.#u&&this.#s.set("floorSelectionMode",e)}getFloorSelectionMode(){return this.#u?.toLowerCase()==="automatic"?"automatic":"manual"}#m(){this.#l.update(),this.emit("redraw")}static setMapsIndoorsApiKey(e){ce.apiKey=e}static getLanguage(){return ce.language}static setLanguage(e){e>""&&(ce.language=e)}static set onAuthRequired(e){jg=typeof e=="function"?e:()=>{}}static get onAuthRequired(){return jg}static setAuthToken(e){ce.authToken=e}static setUserRoles(e){ce.userRoles=e}static getUserRoles(){return ce.userRoles}static disableEventLogging(e=!0){ce.eventLoggingEnabled=e!==!0}static addVenuesToSync(e){ce.venuesToSync=[...new Set([].concat(e,ce.venuesToSync))]}static removeVenuesToSync(e){e=[].concat(e),ce.venuesToSync=ce.venuesToSync.filter(t=>!e.includes(t))}static get eventLoggingEnabled(){return ce.eventLoggingEnabled}static async synchronizeContent(){return fn.clearCache(),mt.clearCache(),$i.clearCache(),Mu.emit("synchronize_content"),await Promise.resolve()}#v(e){return mt.getBuildingInView(e).then(t=>{let n=this.getBuilding();return t?!n||n.id!==t.id?mt.getBuilding(t.id).then(s=>{let r=this.getBuilding();return s&&(!r||r.id!==s.id)?s:r}):n:null}).then(t=>(this.#s.set("building",t),t))}#y=ni(16.66,function(){let e=this.getMapView();if(e&&e.setViewData&&e.isReady){let t=this.#l.getViewData();e.setViewData(t)}});#g(e){let t=this.#s.get("modules"),n=this.getMapView();if(!n){this.#s.once("mapview_changed",()=>this.#g(e));return}if(!t){this.#s.once("modules_changed",()=>this.#g(e));return}!t.includes("cliplayer")||n.set("clipping_mask",e)}async#_(){let e=this.getVenue(),t=Number(this.getFloor());return Ke(e?.id)||Ke(ce?.apiKey)?{type:"FeatureCollection",features:[]}:isNaN(t)?{type:"FeatureCollection",features:[]}:await $i.getFloorPlan(ce.apiKey,e.id,t)}};E();E();function cb(i,e,t){t===void 0&&(t={});var n=Ht(i),s=Ht(e),r=Tt(s[1]-n[1]),o=Tt(s[0]-n[0]),a=Tt(n[1]),l=Tt(s[1]),c=Math.pow(Math.sin(r/2),2)+Math.pow(Math.sin(o/2),2)*Math.cos(a)*Math.cos(l);return Gh(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),t.units)}var Tl=cb;function wu(i,e){return e===void 0&&(e={}),Um(i,function(t,n){var s=n.geometry.coordinates;return t+Tl(s[0],s[1],e)},0)}E();E();function ko(i,e,t){if(t===void 0&&(t={}),t.final===!0)return hb(i,e);var n=Ht(i),s=Ht(e),r=Tt(n[0]),o=Tt(s[0]),a=Tt(n[1]),l=Tt(s[1]),c=Math.sin(o-r)*Math.cos(l),h=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(o-r);return Cs(Math.atan2(c,h))}function hb(i,e){var t=ko(e,i);return t=(t+180)%360,t}E();function br(i,e,t,n){n===void 0&&(n={});var s=Ht(i),r=Tt(s[0]),o=Tt(s[1]),a=Tt(t),l=Wh(e,n.units),c=Math.asin(Math.sin(o)*Math.cos(l)+Math.cos(o)*Math.sin(l)*Math.cos(a)),h=r+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(o),Math.cos(l)-Math.sin(o)*Math.sin(c)),u=Cs(h),f=Cs(c);return Rs([u,f],n.properties)}function ub(i,e,t,n){if(n=n||{},!Ls(n))throw new Error("options is invalid");var s,r=[];if(i.type==="Feature")s=i.geometry.coordinates;else if(i.type==="LineString")s=i.coordinates;else throw new Error("input must be a LineString Feature or Geometry");for(var o=s.length,a=0,l,c,h,u=0;u<s.length&&!(e>=a&&u===s.length-1);u++){if(a>e&&r.length===0){if(l=e-a,!l)return r.push(s[u]),Ki(r);c=ko(s[u],s[u-1])-180,h=br(s[u],l,c,n),r.push(h.geometry.coordinates)}if(a>=t)return l=t-a,l?(c=ko(s[u],s[u-1])-180,h=br(s[u],l,c,n),r.push(h.geometry.coordinates),Ki(r)):(r.push(s[u]),Ki(r));if(a>=e&&r.push(s[u]),u===s.length-1)return Ki(r);a+=Tl(s[u],s[u+1],n)}if(a<e&&s.length===o)throw new Error("Start position is beyond line");var f=s[s.length-1];return Ki([f,f])}var e0=ub;var t0={type:"Feature",geometry:{type:"LineString",coordinates:[]}},Mr=class extends Et{#e;#t;#n;#i;#r;#o;#a;#s=function(){};constructor(e){super();let t=Object.assign({},{geodesic:!0,minAnimationTime:1.2,speed:300,strokeColor:ii(["color","blue","10","value"],Qt)||"hsl(215, 67%, 96%)",strokeOpacity:1,strokeWeight:2,zIndex:Bo+1},e);this.setValues(t)}setPath(e){e&&e!==this.#i&&(this.#i=e,this.#n=wu(this.#i,{units:"meters"}),this.#e=this.#i.coordinates.reduce((t,n)=>t+n[1],0)/this.#i.coordinates.length,this.#o=0,this.#a=0)}start(){this.#i&&(this.#r=!0,this.#o=performance.now()-this.#a,this.#t=window.requestAnimationFrame(this.#l.bind(this)))}stop(){this.#r=!1,window.cancelAnimationFrame(this.#t),this.#s.call(null,t0),this.#t=null,this.#a=0}pause(){this.#r=!1,window.cancelAnimationFrame(this.#t),this.#t=null}clear(){this.stop(),this.#i=null}set onanimationframe(e){e&&e.constructor&&e.call&&e.apply&&(this.#s=e)}getOptions(){return this.getValues()}setOptions(e){this.setValues(e)}#l(e){let t=this.get("mapsIndoors");if(t instanceof vi&&this.#i&&this.#r){let n=t0,s=t.getZoom(),r=fb.call(this,s,this.#n,this.#e);this.#o=this.#o===0?e:this.#o,this.#a=e-this.#o;let o=r*(this.#a/1e3),a=o<=this.#n?0:o-this.#n,l=o<=this.#n?o:this.#n;o>0&&a<this.#n&&(n=e0(this.#i,a,l,{units:"meters"}),n.properties=this.getOptions()),o>=this.#n*2&&(this.#o=e),this.#s.call(null,n),this.#t=window.requestAnimationFrame(this.#l.bind(this))}}};function fb(i,e,t){let n=this.get("speed"),s=this.get("minAnimationTime");return n*=Lt.getMeterPerPixel(t,i),e/n<s?e/s:n}E();var Sr=class{#e=!0;#t="#ef4444";#n="#ffffff";#i="#ffffff";#r={width:56,height:66};#o=this.#r.width/this.#r.height;#a={x:this.#r.width/2,y:17};#s=28;#l=new Path2D("M55.77,24.35C54.16,11.74,43.82,1.57,31.16.17c-1.05-.11-2.11-.17-3.16-.17C12.56,0,0,12.56,0,28c0,11.57,7.27,22.09,18.08,26.18.55.21.97.57,1.19,1.03l3.34,6.84c1.01,2.08,3.08,3.37,5.39,3.37s4.38-1.29,5.39-3.37l3.34-6.86c.22-.44.64-.8,1.19-1.01,12.16-4.6,19.5-16.86,17.85-29.83Z");#c=new Path2D("M36.5,50.44c-1.46.55-2.68,1.59-3.36,3l-3.34,6.86c-.73,1.5-2.87,1.5-3.6,0l-3.34-6.85c-.68-1.4-1.9-2.45-3.36-3.01-9.06-3.43-15.5-12.18-15.5-22.44C4,13.84,16.26,2.56,30.72,4.15c10.88,1.2,19.7,9.85,21.08,20.71,1.47,11.58-5.33,21.81-15.3,25.58Z");constructor({fillColor:e="#ef4444",numbered:t=!0}={}){this.#e=t,this.#t=e}getImage(e){return new Promise(t=>{let s=56/this.#o,r=document.createElement("canvas");r.width=56,r.height=s;let o=r.getContext("2d");o.scale(56/this.#r.width,s/this.#r.height),o.imageSmoothingQuality="high",o.textAlign="center",o.textBaseline="hanging",o.textRendering="optimizeLegibility",o.font=`bold ${this.#s}px sans-serif`,o.clearRect(0,0,r.width,r.height),o.fillStyle=this.#n,o.fill(this.#l),o.fillStyle=this.#t,o.fill(this.#c),this.#e&&Number.isInteger(e)&&(o.fillStyle=this.#i,o.fillText(e,this.#a.x,this.#a.y,r.width));let a=new Image(r.width,r.height);a.onload=()=>t(a),a.src=r.toDataURL()})}};var db={strokeColor:"#3071D9",strokeOpacity:1,strokeWeight:4,zIndex:Bo,fitBounds:!0,visible:!0},Il=class{#e;#t;#n;#i=new Sr;constructor(e){if(this.#n=e.mapsIndoors,!(this.#n instanceof vi))throw new Error("mapsIndoors is not an instance of MapsIndoors");let t=e.animation===void 0?new Mr({mapsIndoors:this.#n}):e.animation;e.defaultRouteStopIconProvider===null?this.#i=null:e.defaultRouteStopIconProvider!==void 0&&typeof e.defaultRouteStopIconProvider.getImage=="function"&&(this.#i=e.defaultRouteStopIconProvider);let n=this.#n.getMapView();this.#e=new n.DirectionsRenderer(Object.assign({},db,e)),this.#e.set("legIndex",0),this.#e.set("stepIndex",-1),this.setAnimation(t),this.#n.on("floor_changed",()=>{this.#r(this.getStepIndex(),this.getLegIndex())})}setAnimation(e){let t=this.getAnimation();t&&t.clear(),this.#e.set("animation",e)}getAnimation(){return this.#e.get("animation")}async setRoute(e,t=new Map){let n=await pb(e,t,this.#i);this.#e.set("viewModel",n),this.#t=e,this.setStepIndex(-1,0)}getRoute(){return this.#t}setOptions(e){this.#e.setValues(e)}getVisible(){return this.#e.get("visible")}setVisible(e){this.#e.set("visible",e)}setLegIndex(e){let t=this.getRoute();if(t&&t.legs){let n=yb(e,t.legs);n!==this.getLegIndex()&&this.setStepIndex(-1,n)}}getLegIndex(){return this.#e.get("legIndex")}setStepIndex(e,t){let n=this.#e.get("mapsIndoors"),s=this.#e.get("fitBoundsPadding"),r=this.getRoute();if(t=isNaN(t)||t<0?this.getLegIndex():t,r&&r.legs&&n0(t,r.legs)){let o=r.legs[t],a=parseInt(n.getFloor()),l=isNaN(o.end_location.zLevel)?0:parseInt(o.end_location.zLevel),c;if(e===-1)this.#e.setStepIndex(e,t),this.#r(e,t),c=o.geometry;else if(o&&o.steps&&n0(e,o.steps))this.#e.setStepIndex(e,t),this.#r(e,t),c=o.steps[e].geometry;else return;a!==l&&n.setFloor(l),this.#e.get("fitBounds")===!0&&c&&n.goTo(c,{padding:s}).then(()=>{a!==l&&n.setFloor(l)})}else r||(this.#e.setStepIndex(e,t),this.#r(0,-1))}#r(e,t){let n=parseInt(this.#n.getFloor()),s=this.getAnimation(),[r]=this.#e.get("viewModel")??[];if(!(!s||!r))if(e>-1&&t>-1){let o=ii([t,e],r);if(o.properties.routeContext!=="Outside"&&o?.properties?.floorIndex!==n){s.clear();return}s.setPath(o.geometry),s.start()}else if(e===-1&&t>-1){let o=r[t]?.reduce((a,l)=>l.properties.routeContext!=="Outside"&&parseInt(l.properties.floorIndex)!==n?a:a.concat(l.geometry.coordinates),[]);s.setPath({type:"LineString",coordinates:o}),s.start()}else s.stop()}getStepIndex(){return this.#e.get("stepIndex")}nextLeg(){this.setLegIndex(this.getLegIndex()+1)}previousLeg(){this.setLegIndex(this.getLegIndex()-1)}nextStep(){let e=this.getRoute(),t=this.getLegIndex(),n=this.getStepIndex()+1;if(e&&e.legs){let s=e.legs[t];s&&s.steps&&n<s.steps.length?this.setStepIndex(n,t):this.setStepIndex(0,t+1)}}previousStep(){let e=this.getRoute(),t=this.getLegIndex(),n=this.getStepIndex();if(e&&e.legs){if(n===0&&t===0)return;if(t>0&&n<=0){t-=1;let s=e.legs[t];s&&s.steps&&this.setStepIndex(s.steps.length-1,t)}else this.setStepIndex(n-1,t)}}};async function pb(i,e=new Map,t){if(i&&i.legs){let n=mb(e,t),s=await Promise.all(i.stops?.map(n)??[]);return[i.legs.map(gb),s]}return[]}function mb(i,e){return async function(n,s){let r=i.get(s),a=await(r?.iconProvider??e)?.getImage(s+1),l=a?{width:a.width,height:a.height}:void 0;return{id:s,type:"Feature",geometry:{type:"Point",coordinates:[n.lng,n.lat]},properties:{floorIndex:n.zLevel,stopIndex:s,icon:a,iconSrc:a?.src,iconScale:.5,iconSize:l,iconPlacement:"bottom",labelFont:'"Open Sans Bold", "Arial Unicode MS Regular", sans-serif',labelFontWeight:"bold",labelText:r?.label??"",labelSize:16,labelColor:"#1F2937",labelStrokeBlur:0,labelStrokeStyle:"#FFFFFF",labelStrokeWidth:2,labelOffset:[0,.75],labelOpacity:1,sortKey:Bo-s,visibility:"visible"}}}}function gb(i,e){return(i.steps||[]).map((t,n)=>({type:"Feature",geometry:t.geometry,properties:{floorIndex:t.end_location.zLevel,routeContext:t.route_context,legIndex:e,stepIndex:n,visibility:"visible"}}))}function n0(i,e){return Number.isInteger(i)&&i>-1&&i<e.length}function yb(i,e){return Math.max(0,Math.min(e.length-1,i))}E();var Rl=class{constructor(e,t){e.className="mapsindoors floor-selector",t.addListener("building_changed",s);let n=new MutationObserver(()=>{document.body.contains(e)&&(r(),n.disconnect())});n.observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0}),t.addListener("floor_changed",function(){let a=t.getFloor().toString();Array.from(e.childNodes).forEach(c=>{let h=c.className.split(" ");c.getAttribute("data-floor")===a?h.indexOf("active")<0&&h.push("active"):h.splice(h.indexOf("active"),1),c.className=h.join(" ")})}),t.getBuilding()&&s.call(t);function s(){let a=t.getBuilding();if(e.innerHTML="",a){let l=t.getFloor(),c=!Ke(l)&&!isNaN(l)?l.toString():"",h=a.floors;Object.keys(h).sort((u,f)=>f-u).forEach(u=>{let f=document.createElement("a");f.innerHTML=h[u].name,f.setAttribute("data-floor",u),f.onclick=o,f.className=c===u?"active":"",e.appendChild(f)}),r()}}function r(){if(e.scrollHeight>e.clientHeight){let a=e.querySelector(".active");(a&&a.offsetTop+a.clientHeight<e.scrollTop||a.offsetTop>e.scrollTop+e.clientHeight)&&(e.scrollTop=a.offsetTop-e.clientHeight/2-a.clientHeight/2)}}function o(){t.setFloor(this.getAttribute("data-floor"))}}};E();var zo=class{#e;#t;constructor(){google&&google.maps&&google.maps.DirectionsService&&(this.#e=new google.maps.DirectionsService,this.#t=new google.maps.DistanceMatrixService)}get ProviderName(){return"google"}static get availableTravelModes(){return["DRIVING","WALKING","BICYCLING","TRANSIT"]}getRoute(e){return new Promise(t=>{delete e.origin.floor,delete e.destination.floor,e.language=ce.language,this.#e.route(e,(n,s)=>{if(s!==google.maps.DirectionsStatus.OK)return t({route:null,status:s});let r=n.routes[0];for(let o of r.legs)if(o.start_location=o.start_location.toJSON(),o.end_location=o.end_location.toJSON(),o.steps=i0(o.steps,e.travelMode),o.geometry={type:"LineString",coordinates:o.steps.reduce((a,l)=>a.concat(l.geometry.coordinates),[])},!o.arrival_time&&!o.departure_time){let a={distance:o.distance,duration:o.duration,end_context:null,end_location:o.end_location,geometry:o.geometry,highway:null,start_context:null,start_location:o.start_location,steps:o.steps};o.steps=[Object.assign({},o.steps[0],a)]}t({route:r,status:s})})})}getDistanceMatrix(e={origins:[],destinations:[],travelMode:"WALKING"}){let t={origins:e.origins,destinations:e.destinations,travelMode:e.travelMode};return new Promise(s=>{t.travelMode&&t.origins&&t.destinations?this.#t.getDistanceMatrix(t,(r,o)=>{s({rows:r.rows,origins:e.origins,destinations:e.destinations,status:o})}):s({rows:[{elements:[{status:"OK",distance:{value:0},duration:{value:0},origin:e.origins[0],destination:e.destinations[0],mode:e.travelMode}]}]})}).then(n);function n(s){return s.rows.forEach((r,o)=>r.elements.forEach((a,l)=>{a.origin=e.origins[o],a.destination=e.destinations[l],a.mode=e.travelMode})),s}}};function i0(i=[],e){if(!(i.length<0))return i.map(t=>{let n={type:"LineString",coordinates:t.path.map(r=>[r.lng(),r.lat()])},s={distance:t.distance,duration:t.duration,end_context:null,end_location:t.end_location.toJSON(),geometry:n,highway:null,instructions:mi.removeHtmlFrom(t.instructions),maneuver:t.maneuver,route_context:"Outside",start_context:null,start_location:t.start_location.toJSON(),steps:t.steps?i0(t.steps):[],travel_mode:_b(t.travel_mode)||e};return t.transit&&(s.transit_information=t.transit),s})}function _b(i){return zo.availableTravelModes.includes(i.toUpperCase())?i.toUpperCase():null}E();E();E();E();var Rn=63710088e-1,lN={centimeters:Rn*100,centimetres:Rn*100,degrees:360/(2*Math.PI),feet:Rn*3.28084,inches:Rn*39.37,kilometers:Rn/1e3,kilometres:Rn/1e3,meters:Rn,metres:Rn,miles:Rn/1609.344,millimeters:Rn*1e3,millimetres:Rn*1e3,nauticalmiles:Rn/1852,radians:1,yards:Rn*1.0936};function vb(i,e,t={}){let n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}function s0(i,e,t={}){for(let s of i){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<s[s.length-1].length;r++)if(s[s.length-1][r]!==s[0][r])throw new Error("First and last Position are not equivalent.")}return vb({type:"Polygon",coordinates:i},e,t)}function xb(i,e={}){let t=Number(i[0]),n=Number(i[1]),s=Number(i[2]),r=Number(i[3]);if(i.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");let o=[t,n];return s0([[o,[s,n],[s,r],[t,r],o]],e.properties,{bbox:i,id:e.id})}var r0=xb;E();E();var bb=Object.defineProperty,wr=(i,e)=>bb(i,"name",{value:e,configurable:!0}),a0=class{constructor(e){this.direction=!1,this.compareProperties=!0;var t,n,s;this.precision=10**-((t=e?.precision)!=null?t:17),this.direction=(n=e?.direction)!=null?n:!1,this.compareProperties=(s=e?.compareProperties)!=null?s:!0}compare(e,t){if(e.type!==t.type||!Vo(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){let n=Au(e),s=Au(t);return n.every(r=>s.some(o=>this.compare(r,o)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((n,s)=>Math.abs(n-t[s])<this.precision)}compareLine(e,t,n=0,s=!1){if(!Vo(e,t))return!1;let r=e,o=t;if(s&&!this.compareCoord(r[0],o[0])){let l=this.fixStartIndex(o,r);if(l)o=l;else return!1}let a=this.compareCoord(r[n],o[n]);return this.direction||a?this.comparePath(r,o):this.compareCoord(r[n],o[o.length-(1+n)])?this.comparePath(r.slice().reverse(),o):!1}fixStartIndex(e,t){let n,s=-1;for(let r=0;r<e.length;r++)if(this.compareCoord(e[r],t[0])){s=r;break}return s>=0&&(n=[].concat(e.slice(s,e.length),e.slice(1,s+1))),n}comparePath(e,t){return e.every((n,s)=>this.compareCoord(n,t[s]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){let n=e.coordinates.slice(1,e.coordinates.length),s=t.coordinates.slice(1,t.coordinates.length);return n.every(r=>s.some(o=>this.compareLine(r,o,1,!0)))}return!1}compareGeometryCollection(e,t){return Vo(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((n,s)=>this.compare(n,t.geometries[s]))}compareFeature(e,t){return e.id===t.id&&(this.compareProperties?Tu(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return Vo(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((n,s)=>this.compare(n,t.features[s]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||(e.bbox&&t.bbox?this.compareCoord(e.bbox,t.bbox):!1)}};wr(a0,"GeojsonEquality");var Mb=a0;function Vo(i,e){return i.coordinates?i.coordinates.length===e.coordinates.length:i.length===e.length}wr(Vo,"sameLength");function Au(i){return i.coordinates.map(e=>({type:i.type.replace("Multi",""),coordinates:e}))}wr(Au,"explode");function Eu(i,e,t){return new Mb(t).compare(i,e)}wr(Eu,"geojsonEquality");function Tu(i,e){if(i===null&&e===null)return!0;if(i===null||e===null)return!1;let t=Object.keys(i),n=Object.keys(e);if(t.length!==n.length)return!1;for(var s of t){let r=i[s],o=e[s],a=o0(r)&&o0(o);if(a&&!Tu(r,o)||!a&&r!==o)return!1}return!0}wr(Tu,"equal");var o0=wr(i=>i!=null&&typeof i=="object","isObject");E();E();var Cn=63710088e-1,pN={centimeters:Cn*100,centimetres:Cn*100,degrees:360/(2*Math.PI),feet:Cn*3.28084,inches:Cn*39.37,kilometers:Cn/1e3,kilometres:Cn/1e3,meters:Cn,metres:Cn,miles:Cn/1609.344,millimeters:Cn*1e3,millimetres:Cn*1e3,nauticalmiles:Cn/1852,radians:1,yards:Cn*1.0936};function l0(i,e,t={}){let n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}E();function Ho(i){if(Array.isArray(i))return i;if(i.type==="Feature"){if(i.geometry!==null)return i.geometry.coordinates}else if(i.coordinates)return i.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function c0(i,e){return i.type==="FeatureCollection"?"FeatureCollection":i.type==="GeometryCollection"?"GeometryCollection":i.type==="Feature"&&i.geometry!==null?i.geometry.type:i.type}function Ru(i,e={}){var t=typeof e=="object"?e.mutate:e;if(!i)throw new Error("geojson is required");var n=c0(i),s=[];switch(n){case"LineString":s=Iu(i,n);break;case"MultiLineString":case"Polygon":Ho(i).forEach(function(o){s.push(Iu(o,n))});break;case"MultiPolygon":Ho(i).forEach(function(o){var a=[];o.forEach(function(l){a.push(Iu(l,n))}),s.push(a)});break;case"Point":return i;case"MultiPoint":var r={};Ho(i).forEach(function(o){var a=o.join("-");Object.prototype.hasOwnProperty.call(r,a)||(s.push(o),r[a]=!0)});break;default:throw new Error(n+" geometry not supported")}return i.coordinates?t===!0?(i.coordinates=s,i):{type:n,coordinates:s}:t===!0?(i.geometry.coordinates=s,i):l0({type:n,coordinates:s},i.properties,{bbox:i.bbox,id:i.id})}function Iu(i,e){var t=Ho(i);if(t.length===2&&!h0(t[0],t[1]))return t;var n=[],s=t.length-1,r=n.length;n.push(t[0]);for(var o=1;o<s;o++){var a=n[n.length-1];t[o][0]===a[0]&&t[o][1]===a[1]||(n.push(t[o]),r=n.length,r>2&&u0(n[r-3],n[r-1],n[r-2])&&n.splice(n.length-2,1))}if(n.push(t[t.length-1]),r=n.length,(e==="Polygon"||e==="MultiPolygon")&&h0(t[0],t[t.length-1])&&r<4)throw new Error("invalid polygon");return e==="LineString"&&r<3||u0(n[r-3],n[r-1],n[r-2])&&n.splice(n.length-2,1),n}function h0(i,e){return i[0]===e[0]&&i[1]===e[1]}function u0(i,e,t){var n=t[0],s=t[1],r=i[0],o=i[1],a=e[0],l=e[1],c=n-r,h=s-o,u=a-r,f=l-o,d=c*f-h*u;return d!==0?!1:Math.abs(u)>=Math.abs(f)?u>0?r<=n&&n<=a:a<=n&&n<=r:f>0?o<=s&&s<=l:l<=s&&s<=o}E();function Cu(i){return i.type==="Feature"?i.geometry:i}function Sb(i,e,t={}){let n=t.precision;if(n=n==null||isNaN(n)?6:n,typeof n!="number"||!(n>=0))throw new Error("precision must be a positive number");let s=Cu(i).type,r=Cu(e).type;return s!==r?!1:Eu(Ru(i),Ru(e),{precision:n})}var f0=Sb;var Cl=class{#e;#t;#n;#i=window.devicePixelRatio*5;#r;#o;constructor(e,t){this.#e=e,this.#t=new google.maps.OverlayView,this.#t.onAdd=this.onAdd.bind(this),this.#t.draw=this.draw.bind(this),this.#t.onRemove=this.onRemove.bind(this),this.#r=iu(this.#e.geometry,this.#e.properties.widthMeters,this.#e.properties.heightMeters),this.#o=this.#a(this.#r,this.#e),this.#t.setMap(t)}update(e){return Ke(this.getMap())||!wb(this.#e,e,["featureClass","sortKey","type"])?(this.#e=e,this.#r=iu(this.#e.geometry,this.#e.properties.widthMeters,this.#e.properties.heightMeters),this.#o=this.#a(this.#r,this.#e),this.#n instanceof HTMLImageElement&&(this.#n.src=this.#e.properties.imageUrl,this.draw()),!0):this.#e.properties.sortKey!==e.properties.sortKey?(this.#e=e,this.#n instanceof HTMLImageElement&&(this.#n.style.zIndex=this.#e.properties.sortKey),!0):!1}onAdd(){this.#n=document.createElement("img"),this.#n.style.position="absolute",this.#n.src=this.#e.properties.imageUrl,this.#t.getPanes().overlayLayer.appendChild(this.#n)}draw(){let e=this.#r,t=this.#t.getProjection();if(!t)return;let n=t.fromLatLngToDivPixel({lat:e[1],lng:e[0]}),s=t.fromLatLngToDivPixel({lat:e[3],lng:e[2]});if(this.#n){let r=s.x-n.x,o=n.y-s.y,a=r<=this.#i||o<=this.#i?"none":"block";this.#n.style.display=a,this.#n.style.left=`${Math.round(n.x)}px`,this.#n.style.top=`${Math.round(s.y)}px`,this.#n.style.width=`${Math.round(r)}px`,this.#n.style.height=`${Math.round(o)}px`,this.#n.style.zIndex=this.#e.properties.sortKey,this.#n.style.transform=`rotate(${this.#e.properties.bearing}deg)`}}teardown(){this.#t.setMap(null)}onRemove(){this.#n.parentNode.removeChild(this.#n),google.maps.event.clearInstanceListeners(this),this.#n=void 0}setMap(e){e!==this.#t.getMap()&&this.#t.setMap(e)}getMap(){return this.#t.getMap()}getHitbox(){return this.#o}#a(e,t){let n=r0(e,{properties:{...t.properties},id:t.id});return rl(n,t.properties.bearing)}};function wb(i,e,t){if(!f0(i.geometry,e.geometry)||i.id!==e.id||Object.keys(i.properties).length!==Object.keys(e.properties).length)return!1;for(let n of Object.keys(i.properties))if(!t.includes(n)){if(Array.isArray(i.properties[n])&&Array.isArray(e.properties[n])){if(i.properties[n].length!==e.properties[n].length||i.properties[n].some((s,r)=>s!==e.properties[n][r]))return!1}else if(i.properties[n]!==e.properties[n])return!1}return!0}E();var Ll=class extends Et{#e;#t;constructor(e,t){super(),this.on("map_changed",n=>{n.newValue instanceof google.maps.Map&&(this.#e.setMap(n.newValue),this.#t.setMap(n.newValue))}),this.on("provider_changed",n=>{let s=document.querySelector("mi-my-position")??t;if(n.oldValue)n.oldValue.off?(n.oldValue.off("position_received",this.#n.bind(this)),n.oldValue.off("position_error",this.#i.bind(this))):(s.removeEventListener("position_received",this.#n.bind(this)),s.removeEventListener("position_error",this.#i.bind(this)));else{let r=this.get("map");this.#e.setMap(r),this.#t.setMap(r)}if(n.newValue){let r=n.newValue;this.set("markerOptions",r.options.positionMarkerStyles),this.set("accuracyOptions",r.options.accuracyCircleStyles),this.set("maxAccuracy",r.options.maxAccuracy),r.on?(r.on("position_received",this.#n.bind(this)),r.on("position_error",this.#i.bind(this))):(s.addEventListener("position_received",this.#n.bind(this)),s.addEventListener("position_error",this.#i.bind(this))),r.hasValidPosition()&&this.#n({position:r.currentPosition,accurate:r.positionIsAccurate})}else this.#e.setMap(null),this.#t.setMap(null)}),this.on("markeroptions_changed",n=>{let s=n.newValue,r={path:google.maps.SymbolPath.CIRCLE,fillColor:s.fillColor,fillOpacity:parseFloat(s.fillOpacity),strokeWeight:parseInt(s.strokeWeight),strokeColor:s.strokeColor,scale:parseInt(s.radius)};this.#e.setIcon(r)}),this.on("accuracyoptions_changed",n=>{let s=n.newValue;this.#t.setOptions({fillColor:s.fillColor,fillOpacity:parseFloat(s.fillOpacity),strokeWeight:0})}),this.#e=new google.maps.Marker({clickable:!1,zIndex:Number.MAX_SAFE_INTEGER}),this.#t=new google.maps.Circle({clickable:!1,zIndex:Number.MAX_SAFE_INTEGER-1}),this.setValues({map:e,provider:t})}#n(e){let t=e.detail?e.detail.position.coords:e.position.coords,n=this.get("maxAccuracy");t.accuracy<=n?(this.#e.setVisible(!0),this.#e.setPosition({lat:t.latitude,lng:t.longitude}),this.#t.setVisible(!0),this.#t.setCenter({lat:t.latitude,lng:t.longitude}),this.#t.setRadius(t.accuracy)):(this.#e.setVisible(!1),this.#t.setVisible(!1))}#i(){this.#e.setVisible(!1),this.#t.setVisible(!1)}setProvider(e){this.set("provider",e)}deallocate(){this.set("provider",null),this.set("map",null),this.#e=void 0,this.#t=void 0}};E();E();var Ab={visible:!0},Ar=class{#e=new google.maps.OverlayView;#t;constructor(e,t){let n=parseInt(e.properties.labelSize),s={clickable:e?.properties?.clickable,position:new google.maps.LatLng({lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]}),map:t,text:e.properties.labelText,visible:e.properties.labelVisible??Ab.visible,style:{fontFamily:e.properties.labelFont,fontSize:`${n}px`,fontWeight:e.properties.labelFontWeight||"normal",color:e.properties.labelColor,strokeStyle:e.properties.labelStrokeStyle,strokeWeight:Ib(e),shadowBlur:e.properties.labelShadowBlur||0,shadowColor:e.properties.labelShadowColor,iconPlacement:e.properties.iconPlacement??Zt.CENTER},pixelOffset:Rb(e.properties.labelOffset,n,e.properties.iconPlacement),maxLength:e.properties.labelMaxLength,maxWidth:e.properties.labelMaxWidth,id:e.id};this.#e.setOptions(s),this.#e.addListener("visible_changed",()=>{let r=this.#t;if(r){let o=this.getVisible();r.style.display=o?"":"none",o&&this.#n()}}),this.#e.addListener("clickable_changed",()=>{let r=this.#t,o=this.#e.get("clickable");r&&(r.style.cursor=o===!0?"pointer":"")}),this.#e.addListener("style_changed",()=>{this.#n()}),this.#e.addListener("text_changed",()=>{this.#n()}),this.#e.addListener("maxlength_changed",()=>{this.#n()}),this.#e.addListener("pixeloffset_changed",()=>{this.draw()}),this.#e.addListener("position_changed",()=>{this.draw()}),this.#e.onAdd=this.onAdd.bind(this),this.#e.draw=this.draw.bind(this),this.#e.onRemove=this.onRemove.bind(this)}teardown(){this.#e.setMap(null)}setOptions(e){this.#e.setOptions(e)}onAdd(){let e=this.#e.get("clickable"),t=this.#t=document.createElement("canvas"),n=this.getVisible();t.style.position="absolute",t.style.display=n?"":"none",t.style.cursor=e===!0?"pointer":"",this.#e.getPanes().overlayMouseTarget.appendChild(t),this.#n(),t.addEventListener("click",s=>{this.#e.get("clickable")===!0&&(s.cancelBubble=!0,google.maps.event.trigger(this,"click"))}),t.addEventListener("mouseenter",()=>{google.maps.event.trigger(this,"mouseenter")}),t.addEventListener("mouseleave",()=>{google.maps.event.trigger(this,"mouseleave")})}onRemove(){this.#t.parentNode.removeChild(this.#t),google.maps.event.clearInstanceListeners(this),this.#t=void 0}draw(){let e=this.#e.getProjection(),t=this.#t,n=this.#e.get("position"),s=e.fromLatLngToDivPixel(n),r=this.getPixelOffset();t.style.top=`${Math.round(r.height+s.y)}px`,t.style.left=`${Math.round(r.width+s.x)}px`}setStyle(e){this.#e.set("style",e)}getStyle(){return this.#e.get("style")}setText(e){this.getText()!==e&&this.#e.set("text",e||"")}getText(){return this.#e.get("text")||""}setVisible(e){this.#e.set("visible",e)}getVisible(){return this.#e.get("visible")}setPixelOffset(e){this.#e.set("pixelOffset",e)}getPixelOffset(){return this.#e.get("pixelOffset")||{width:0,height:0}}getMap(){return this.#e.getMap()}setMap(e){(e!==this.#e.getMap()&&e instanceof google.maps.Map||e===null)&&this.#e.setMap(e)}setMaxLength(e){this.#e.set("maxLength",e)}getMaxLength(){return this.#e.get("maxLength")}setMaxWidth(e){this.#e.set("maxWidth",e)}getMaxWidth(){return this.#e.get("maxWidth")}setPosition(e){this.#e.set("position",e)}getPosition(){return this.#e.get("position")}#n(){let e=this.#t,t=this.getStyle(),n=e.getContext("2d"),s=parseInt(t.strokeWeight),r=parseInt(t.shadowBlur||0),o=this.getMaxLength()||-1,a=this.getMaxWidth()-(s+r)||-1,l=Cb(this.getText(),o),c=l.split(`
`);if(e.style.display!=="none"&&l>""){p0(e,t),a>0&&d0(c,n)>a&&(c=Lb(c,n,a));let h=Tb(s+r,n);e.width=d0(c,n)+(s+r),e.height=h*c.length,n.clearRect(0,0,e.width,e.height),p0(e,t);let u=(s+r)/2,f=(s+r)/2;for(let d of c)s&&n.strokeText(d,u,f),n.fillText(d,u,f),f+=h;Eb(e,t)}}};function Eb(i,e){switch((e.align||"center").toLowerCase()){case"left":i.style.marginLeft=`${-parseInt(i.width)}px`;break;case"center":i.style.marginLeft=`${Math.round(-parseInt(i.width)/2)}px`;break;default:i.style.marginLeft="0px";break}}function Tb(i,e){let t=e.measureText("Hg");return Math.ceil(t.actualBoundingBoxDescent+t.actualBoundingBoxAscent+i)*1.2}function d0(i,e){return i.reduce((t,n)=>Math.max(e.measureText(n).width,t),0)}function Ib(i){return Number.isNaN(i.properties.labelStrokeWidth)?0:i.properties.labelStrokeWidth*2}function Rb(i,e,t="center"){let n=Number.isNaN(i?.[1])?18:e*i[1];t==="bottom"&&(n=n-e/2);let s=Number.isNaN(i?.[0])?0:e*i[0];return{height:n,width:s}}function p0(i,e){let t=i.getContext("2d");t.textBaseline="top",t.lineJoin="round",t.lineWidth=e.strokeWeight,t.strokeStyle=e.strokeStyle,t.fillStyle=e.color,t.shadowColor=e.shadowColor,t.shadowBlur=parseInt(e.shadowBlur),t.font=`${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}function Cb(i,e){return i=i||"",e>0&&i.length+3>e?i.slice(0,e).trim()+"...":i}function Lb(i,e,t){let n=[];for(let s of i)if(e.measureText(s).width>t){let o=s.split(" "),a=o.length;for(;o.length>0;){if(e.measureText(o.slice(0,a)).width<t){n=n.concat(o.splice(0,a).join(" ")),a=o.length;continue}else if(a===1){n=n.concat(Pb(o.shift(),e,t));let l=n[n.length-1];n.length>1&&e.measureText(`${l} M`).width<t&&l.length>1&&o.unshift(n.pop()),a=o.length;continue}a--}}return n}function Pb(i,e,t){let n=[],s=i.split(""),r=i.length;for(;s.length>0;){let o=s.slice(0,r).join("");if(e.measureText(o).width<t||o.length===1){n=n.concat(s.splice(0,r).join("")),r=s.length;continue}r--}return n}var Pl=class extends Et{#e=[];#t;#n;#i=new Map;constructor(e){super();let t=e.mapsIndoors,n=t.getMapView().getMap();this.#t=new google.maps.Data({map:n,style:Nb.bind(this)}),this.#n=new google.maps.Polyline({map:n}),this.on("changed",({key:s})=>{switch(s){case"viewModel":case"legIndex":this.#o.call(this);break;case"strokeColor":case"strokeWeight":case"strokeOpacity":case"visible":case"zIndex":this.#t.setStyle(this.#t.getStyle());break}}),this.on("visible_changed",({newValue:s})=>{let r=s===!0,o=this.get("animation");this.#n.setVisible(r),o&&(r===!0?o.start():o.stop())}),this.on("animation_changed",({newValue:s})=>{let r=s;r&&(r.onanimationframe=o=>{if(o){let a=o.geometry.coordinates.map(l=>({lat:l[1],lng:l[0]}));this.#n.setOptions(o.properties),this.#n.setPath(a)}})}),this.setValues(e),t.on("floor_changed",this.#o.bind(this))}setStepIndex(e,t){this.set("legIndex",t),this.set("stepIndex",e)}#r(){let[e]=this.get("viewModel")??[],t=this.get("mapsIndoors"),n=parseInt(t.getFloor()),s=this.get("legIndex");if(t&&e?.[s])for(let r of e[s]){let o=parseInt(r.properties.floorIndex),a=r.properties.routeContext;r.properties.visibility=a==="Outside"||o===n?"visible":"none"}}#o(){let e=this.get("mapsIndoors"),t=e.getMapView().getMap(),[n,s]=this.get("viewModel")??[],r=this.get("animation"),o=this.get("legIndex"),a=parseInt(e.getFloor());!n?.[o]&&r&&r.clear();for(let c of this.#e)this.#t.remove(c);let l=new Map(s?.filter(c=>parseInt(c.properties.floorIndex)===a).map(c=>[c.id,c])??[]);for(let[c,h]of this.#i)l.has(c)||h.setMap(null);if(n?.[o]){let c=n[o];this.#r(),this.#e=this.#t.addGeoJson({type:"FeatureCollection",features:[...c,...l.values()]});for(let[h,u]of l){let f=this.#i.get(h);if(u.properties.labelText>"")if(f){f.getMap()===null&&f.setMap(t);let d=f.getPosition(),y=new google.maps.LatLng({lat:u.geometry.coordinates[1],lng:u.geometry.coordinates[0]});d.equals(y)||f.setPosition(y),f.getText()!==u.properties.labelText&&f.setText(u.properties.labelText)}else f=new Ar(u,t),this.#i.set(h,f);else f?.setMap(null),this.#i.delete(h)}}}};function Nb(i){let e=this.get("visible")===!0&&i.getProperty("visibility")==="visible",t=i.getProperty("iconSrc"),n=i.getProperty("iconSize")??{width:0,height:0},s;return t&&(s={url:t,scaledSize:new google.maps.Size(n.width*.5,n.height*.5)}),e?{strokeColor:this.get("strokeColor"),strokeWeight:this.get("strokeWeight"),strokeOpacity:this.get("strokeOpacity"),zIndex:this.get("zIndex"),visible:e,icon:s}:{visible:!1}}E();var dn={INITIALIZING:"INITIALIZING",READY:"READY"};var Nl=class extends Et{#e=dn.INITIALIZING;#t=new Map;#n=new Map;#i;#r;#o=new google.maps.Data;#a;#s=[];get isReady(){return this.#e===dn.READY}constructor({element:e,zoom:t=0,showMapMarkers:n,...s}){if(super(),this.#a=!isNaN(s.maxZoom)&&s.maxZoom>=0,this.#o.setStyle({fillColor:"#ffffff",fillOpacity:1,strokeColor:"#6B7280",strokeWeight:1.2,zIndex:4e5}),google,google?.maps?.Map){s.maxZoom=s.maxZoom||21,n===!1&&(s.styles??=[],s.styles.push({featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi",elementType:"geometry",stylers:[{visibility:"off"}]}));let r=new google.maps.Map(e,{zoom:t,...s});Rt.log(pt.appLifeTime.MAP_INSTANTIATED),google.maps.event.addListener(r,"idle",()=>{this.emit("idle")}),google.maps.event.addListener(r,"bounds_changed",()=>{this.emit("bounds_changed")}),google.maps.event.addListener(r,"center_changed",()=>{this.emit("center_changed")}),r.data.addListener("click",({feature:o})=>{let a=o.getProperty("originalId");a.startsWith("MI_")||this.emit("click",a)}),r.data.addListener("mouseover",({feature:o})=>{let a=o.getProperty("originalId"),l=o.getId();a.startsWith("MI_")||(this.#s.push([l,a]),this.emit("mouseenter",{id:a}))}),r.data.addListener("mouseout",({feature:o})=>{let a=this.#s.findIndex(l=>l[0]===o.getId());this.#s.splice(a,1),this.emit("mouseenter",{id:this.#s[this.#s.length-1]?.[1]})}),google.maps.event.addListener(r,"maptypeid_changed",()=>{this.emit("maptypeid_changed")}),google.maps.event.addListener(r,"zoom_changed",()=>{this.emit("zoom_changed")}),google.maps.event.addListener(r,"tilesloaded",()=>{this.emit("tiles_loaded")}),google.maps.event.addListener(r,"drag",()=>{this.emit("drag")}),google.maps.event.addListener(r,"dragend",()=>{this.emit("dragend")}),google.maps.event.addListener(r,"dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),google.maps.event.addListener(r,"tilt_changed",()=>{this.emit("user_interaction")}),google.maps.event.addListener(r,"heading_changed",()=>{this.emit("rotateend")}),this.set("map",r),this.set("element",e),r.data.setStyle(this.#c.bind(this)),google.maps.event.addListenerOnce(r,"idle",()=>{this.getMap().getRenderingType()==="VECTOR"?(this.set("rotatable",!0),this.set("tiltable",!0)):(this.set("rotatable",!1),this.set("tiltable",!1))}),this.#o.setMap(r),this.#e=dn.READY,this.emit("ready")}}getMap(){return this.get("map")}deallocate(){this.getMap().controls.forEach(e=>{e.getArray().forEach(n=>{n.remove()}),e.clear()}),this.#t.forEach(e=>{e.teardown()}),this.#t.clear(),this.#n.forEach(e=>{e.teardown()}),this.#n.clear(),this.#i&&(this.#i.deallocate(),this.#i=void 0),this.set("map",null),this.set("element",null)}getBounds(){let e=this.get("map");return e?.getBounds instanceof Function?e.getBounds()?.toJSON():null}getBearing(){let e=this.get("map");return e?.getHeading instanceof Function?e.getHeading():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setViewData(e){this.#r=e;let t=[Ee.ROOM_EXTRUSION,Ee.WALL_EXTRUSION,Ee.MODEL3D,Ee.LABEL_GRAPHIC,Ee.LABEL_FLAT];e.forEach((s,r)=>{t.includes(s.properties.featureClass)&&e.delete(r)});let n=this.get("map");n.data.forEach(s=>{let r=s.getId();e.has(r)||n.data.remove(s)});for(let[s,r]of this.#t)e.has(s)||r.setMap(null);for(let[s,r]of this.#n)if(!e.has(s)){r.setMap(null);let o=n.data.getFeatureById(s);o&&n.data.remove(o)}for(let[s,r]of e){let o=r.properties.featureClass;if(o===Ee.LABEL||o===Ee.LABEL_FLOATING){let a=this.#t.get(r.id);if(a){a.getMap()===null&&(a.setMap(this.getMap()),this.#l(r,a));let l=a.getPosition(),c=new google.maps.LatLng({lat:r.geometry.coordinates[1],lng:r.geometry.coordinates[0]});l.equals(c)||a.setPosition(c),a.getText()!==r.properties.labelText&&a.setText(r.properties.labelText)}else a=new Ar(r,this.getMap()),this.#t.set(r.id,a),this.#l(r,a)}else if(o===Ee.MODEL2D){let a=this.#n.get(r.id);if(a)a?.update(r)&&(a.setMap(this.getMap()),n.data.addGeoJson(a.getHitbox()));else{let l=new Cl(r,this.getMap());n.data.addGeoJson(l.getHitbox()),this.#n.set(r.id,l)}}else{let a=n.data.getFeatureById(s);if(!a)n.data.addGeoJson(r);else{let l=a.getGeometry();if(l.getType()==="Point"){let c=l.get(),h=new google.maps.LatLng({lat:r.geometry.coordinates[1],lng:r.geometry.coordinates[0]});c.equals(h)||(n.data.remove(a),n.data.addGeoJson(r))}}}}n.data.setStyle(this.#c.bind(this))}#l(e,t){google.maps.event.addListener(t,"click",()=>{this.emit("click",e.properties.originalId)}),google.maps.event.addListener(t,"mouseenter",()=>{this.emit("mouseenter",{id:e.properties.originalId})}),google.maps.event.addListener(t,"mouseleave",()=>{this.emit("mouseenter",{})})}setMapsIndoorsTileURL(e){let t=this.getMap();if(t instanceof google.maps.Map&&e>""){let n=t.overlayMapTypes.getArray().filter(r=>r.name==="MapsIndoorsTiles");n.forEach(r=>{let o=n.findIndex(a=>a.name===r.name);t.overlayMapTypes.removeAt(o)});let s=new Lu(e);t.overlayMapTypes.push(s)}}setLabelOptions(e){this.getMap().data.forEach(n=>{this.#t.has(n.getId())&&this.#t.get(n.getId()).setOptions(e)})}fitBounds(e,t){return new Promise(n=>{let s=this.get("map");s?.fitBounds instanceof Function&&(google.maps.event.addListenerOnce(s,"idle",n),s.fitBounds(e,t))})}getZoom(){let e=this.get("map");return e?.getZoom instanceof Function?e.getZoom():null}getMaxZoom(){let e=this.get("map");if(e)return e.get("maxZoom")}getPitch(){return 0}setZoom(e){let t=this.get("map");t?.setZoom instanceof Function&&t.setZoom(e)}getCenter(){let e=this.get("map");return e?.getCenter instanceof Function?e.getCenter().toJSON():null}setCenter(e){let t=this.get("map");t?.setCenter instanceof Function&&t.setCenter(e)}setSolutionConfig(){}panTo(e){let t=this.get("map");t?.panTo&&t.panTo(e)}easeTo({center:e,rotation:t,tilt:n}){let s=this.get("map");s&&s.easeTo&&(s.panTo(e),s.setHeading(t),s.setTilt(n))}tilt(e){this.get("map").setTilt(e)}rotate(e){this.get("map").setHeading(e)}panToBounds(e){let t=this.get("map");t?.panToBounds instanceof Function&&t.panToBounds(e)}getDiv(){return this.get("element")}project({lat:e,lng:t}){let n=this.get("map");if(n?.getProjection instanceof Function){let s=n.getProjection(),r=new google.maps.LatLng(e,t),o=s.fromLatLngToPoint(r);return{x:o.x,y:o.y}}else return null}unproject({x:e,y:t}){let n=this.get("map");if(n?.getProjection instanceof Function){let s=n.getProjection(),r=new google.maps.Point(e,t);return s.fromPointToLatLng(r).toJSON()}else return null}addLogo(){if(this.isReady){if(this.get("map")){let t=this.getDiv();if(t?.appendChild instanceof Function){let n=document.createElement("img");n.id="mi_map_logo",n.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",n.style.width="96px",n.style.height="20px",n.style.margin="5px",n.style.position="absolute",n.style.right="54px",n.style.bottom="18px",n.style.zIndex="10000000",t.appendChild(n),new ResizeObserver(()=>{t.clientWidth<359||t.clientHeight<359?n.style.display!=="none"&&(n.style.display="none"):n.style.display==="none"&&(n.style.display="")}).observe(t)}}}else this.once("ready",()=>{this.addLogo()})}get DirectionsRenderer(){return Pl}enableZoom22(){let e=this.get("map");if(e?.set instanceof Function&&!this.#a)return e.set("maxZoom",22)}setPositionProvider(e){let t=this.getMap();this.#i?this.#i.setProvider(e):this.#i=new Ll(t,e)}setFloorPlan(e){this.#o.forEach(t=>this.#o.remove(t)),this.#o.addGeoJson(e)}#c(e){let t=this.#r?.get(e.getId());if(t){let n=t.properties.iconSrc,s=Ob(t),r=t.properties.iconSize,o=t.properties.fillColor,a=t.properties.fillOpacity,l=t.properties.strokeColor,c=t.properties.strokeOpacity,h=t.properties.strokeWidth,u=t.properties.clickable,f=t.properties?.hovered?t.properties.sortKey+1e5:t.properties.sortKey;return{icon:{url:n,anchor:s,scaledSize:r,labelOrigin:new google.maps.Point(20,50)},fillColor:o,fillOpacity:a,strokeColor:l,strokeOpacity:c,strokeWeight:h,clickable:u,zIndex:f}}return null}hideFeatures(){}setSlot(){}getSlot(){}};function Ob(i){let{iconSize:e,iconPlacement:t,featureClass:n}=i.properties;if(n===Ee.POINT&&e){let{width:s,height:r}=e;switch(t){case"bottom_right":return{x:s,y:r};case"bottom":return{x:s/2,y:r};case"bottom_left":return{x:0,y:r};case"left":return{x:0,y:r/2};case"top_left":return{x:0,y:0};case"top":return{x:s/2,y:0};case"top_right":return{x:s,y:0};case"right":return{x:s,y:r/2};default:return{x:s/2,y:r/2}}}return{x:0,y:0}}var Lu=class{constructor(e){return new google.maps.ImageMapType({getTileUrl:function(t,n){return e.replace("{z}",n).replace("{x}",t.x).replace("{y}",t.y)},tileSize:new google.maps.Size(256,256),name:"MapsIndoorsTiles"})}};E();var Db={route:null,status:"ZERO_RESULTS"},m0={route:null,status:"INVALID_REQUEST"},g0=new Map([["DRIVING","mapbox/driving"],["WALKING","mapbox/walking"],["BICYCLING","mapbox/cycling"]]),Go=class{constructor(e){this.accessToken=e}get ProviderName(){return"mapbox"}_getMapboxDirectionsProfile(e){let t=g0,n=(e||"").toUpperCase();return t.has(n)?t.get(n)||"WALKING":(console.error(`TravelMode "${e}" is not supported.`),null)}static get availableTravelModes(){return Array.from(g0.keys())}getRoute(e){let t=this._getMapboxDirectionsProfile(e.travelMode),n=Ol(e.origin),s=Ol(e.destination);if(!t)return Promise.resolve(m0);let r=`https://api.mapbox.com/directions/v5/${t}/${n};${s}?geometries=geojson&steps=true&access_token=${this.accessToken}&language=${ce.language}`;return fetch(r).then(o=>o.json()).then(o=>{let{routes:a,code:l}=o;if(l!=="Ok")return Db;let c=a[0];for(let h of c.legs){h.geometry={type:"LineString",coordinates:[]},h.distance=_0(h),h.duration=v0(h);let u=Object.assign({},h.steps[0]),f=h.steps[h.steps.length-1];y0(f)==="arrive"&&h.steps.pop(),u.steps=h.steps.map(d=>{let y=d.geometry.coordinates,g=y[0],p=y[y.length-1];return h.geometry.coordinates=h.geometry.coordinates.concat(y),{distance:_0(d),duration:v0(d),end_location:x0(p),geometry:d.geometry,highway:null,instructions:d.maneuver.instruction,maneuver:y0(d),route_context:"Outside",start_location:x0(g),travel_mode:b0(d.mode)||e.travelMode}}),h.start_location=u.steps[0].start_location,h.end_location=u.steps[u.steps.length-1].end_location,u.distance=h.distance,u.duration=h.duration,u.end_context=null,u.end_location=h.end_location,u.geometry=h.geometry,u.highway=null,u.maneuver="",u.route_context="Outside",u.start_context=null,u.start_location=h.start_location,u.travel_mode=b0(u.mode)||e.travelMode,delete u.mode,h.steps=[u]}return{route:c,status:l.toUpperCase()}})}getDistanceMatrix(e={origins:[],destinations:[],travelMode:"WALKING"}){let t=this._getMapboxDirectionsProfile(e.travelMode),n=e.origins.map(Ol),s=e.destinations.map(Ol),r={access_token:this.accessToken,annotations:"duration,distance",sources:n.length>1||s.length>1?[...n.keys()].join(";"):"",destinations:[...s.keys()].map(o=>o+=n.length).join(";")};if(t&&n&&s){let o=`https://api.mapbox.com/directions-matrix/v1/${t}/${n.join(";")};${s.join(";")}?${Ub(r)}`;return fetch(o).then(a=>a.json()).then(a=>a.code!=="Ok"?m0:{rows:a.sources.map((c,h)=>{let u=a.distances[h],f=a.durations[h];return{elements:a.destinations.map((y,g)=>({distance:{value:u[g]||0,text:""},duration:{value:f[g]||0,text:""},mode:e.travelMode,status:u[g]!==null?"OK":"ZERO_RESULTS"}))}}),origins:e.origins,destinations:e.destinations,status:"OK"})}}};function y0(i){let e=i.maneuver.type,t=i.maneuver.modifier;return t=t>""?`-${t.replace(" ","-")}`:"",`${e}${t}`}function _0(i){return{text:"",value:i.distance}}function v0(i){return{text:"",value:i.duration}}function x0(i){return{lat:i[1],lng:i[0]}}function Ol(i){return`${i.lng},${i.lat}`}function Ub(i){return Object.entries(i).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}function b0(i=""){return Go.availableTravelModes.includes(i.toUpperCase())?i.toUpperCase():null}E();E();E();function Fb(i,e,t){t===void 0&&(t={});for(var n=t.steps||64,s=t.properties?t.properties:!Array.isArray(i)&&i.type==="Feature"&&i.properties?i.properties:{},r=[],o=0;o<n;o++)r.push(br(i,e,o*-360/n,t).geometry.coordinates);return r.push(r[0]),ja([r],s)}var Dl=Fb;var Us="MI_POSITION_SOURCE",Pu="MI_CIRCLE_LAYER",Nu="MI_FILL_LAYER",Ul=class extends Et{constructor(e,t){super(),e instanceof mapboxgl.Map&&(e.getSource(Us)||e.addSource(Us,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(Pu)||e.addLayer({id:Pu,filter:["all",["==","$type","Point"]],type:"circle",source:Us,paint:{"circle-color":["get","fillColor"],"circle-radius":["get","radius"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":["get","strokeWeight"],"circle-stroke-color":["get","strokeColor"],"circle-stroke-opacity":["get","fillOpacity"],"circle-pitch-alignment":"map","circle-pitch-scale":"viewport"}}),e.getLayer(Nu)||e.addLayer({id:Nu,filter:["all",["==","$type","Polygon"]],type:"fill",source:Us,paint:{"fill-color":["get","fillColor"],"fill-opacity":["to-number",["get","fillOpacity"]]}})),this.on("provider_changed",n=>{let s=document.querySelector("mi-my-position")??t;if(n.oldValue&&(n.oldValue.off?(n.oldValue.off("position_received",this.#e.bind(this)),n.oldValue.off("position_error",this.#t.bind(this))):(s.removeEventListener("position_received",this.#e.bind(this)),s.removeEventListener("position_error",this.#t.bind(this)))),n.newValue){let r=n.newValue,o=r.options.positionMarkerStyles,a=r.options.accuracyCircleStyles;this.set("markerOptions",{fillColor:o.fillColor,fillOpacity:parseFloat(o.fillOpacity),strokeColor:o.strokeColor,strokeWeight:parseInt(o.strokeWeight),radius:parseInt(o.radius)}),this.set("accuracyOptions",a),this.set("maxAccuracy",r.options.maxAccuracy),r.on?(r.on("position_received",this.#e.bind(this)),r.on("position_error",this.#t.bind(this))):(s.addEventListener("position_received",this.#e.bind(this)),s.addEventListener("position_error",this.#t.bind(this))),r.hasValidPosition()&&this.#e({position:r.currentPosition,accurate:r.positionIsAccurate})}}),this.setValues({map:e,provider:t})}#e(e){let n=this.get("map").getSource(Us),s=e.detail?e.detail.position.coords:e.position.coords,r=this.get("maxAccuracy"),o=this.get("markerOptions"),a=this.get("accuracyOptions");if(s.accuracy<=r){let l={type:"Feature",geometry:{type:"Point",coordinates:[s.longitude,s.latitude]},properties:o},c=Dl(l,s.accuracy,{steps:360,units:"meters",properties:a});n.setData({type:"FeatureCollection",features:[l,c]})}else n.setData({type:"FeatureCollection",features:[]})}#t(){let t=this.get("map").getSource(Us);t&&t.setData({type:"FeatureCollection",features:[]})}setProvider(e){this.set("provider",e)}deallocate(){let e=this.get("map");e.removeLayer(Pu),e.removeLayer(Nu),e.removeSource(Us),this.set("provider",null),this.set("map",null)}};E();var Du=Symbol(),Bl=Symbol(),Wo=Symbol(),Fs=Symbol(),S0=Symbol(),Fl=Symbol(),Bs=Symbol(),Er=class extends Et{constructor(e){super(),this[Bs]=Uu(),this[Fs]=`MI_${this[Bs]}_route`,this[S0]=`MI_${this[Bs]}_icons`,this[Wo]=Uu(),this[Du]=`MI_${this[Wo]}_animation`,this.on("mapsindoors_changed",()=>{let t=this.get("mapsIndoors");if(t instanceof vi){t.on("floor_changed",Ou.bind(this));let n=t.getMap(),s=t.getMapView();this.set("map",n),s.isReady&&M0.call(this),s.on("ready",()=>{M0.call(this),this.get("viewModel")&&Ou.call(this)})}}),this.on("animation_changed",({newValue:t})=>{let n=t;n&&(n.onanimationframe=s=>{this[Bl]&&this[Bl].setData(s)})}),this.on("changed",({key:t,newValue:n})=>{let s=this.get("map");if(!!s)switch(t){case"viewModel":case"legIndex":Ou.call(this);break;case"strokeColor":s.setPaintProperty(this[Fs],"line-color",n);break;case"strokeWeight":s.setPaintProperty(this[Fs],"line-width",n);break;case"strokeOpacity":s.setPaintProperty(this[Fs],"line-opacity",n);break}}),this.on("visible_changed",({newValue:t})=>{let n=t===!0,s=this.get("map"),r=this.get("animation");!s||(s.setLayoutProperty(this[Fs],"visibility",n?"visible":"none"),s.setLayoutProperty(this[Du],"visibility",n?"visible":"none"),r&&n?r.start():r.stop())}),this.setValues(e)}setStepIndex(e,t){this.set("stepIndex",e),this.set("legIndex",t)}};function M0(){let i=this.get("map");if(!i||i.getLayer(this[Fs]))return;i.addSource(this[Bs],{type:"geojson",data:{type:"FeatureCollection",features:[]}}),i.addSource(this[Wo],{type:"geojson",data:{type:"FeatureCollection",features:[]}});let e=null;i.getLayer(kl)?e=kl:i.getLayer(Tr)&&(e=Tr),i.addLayer({id:this[Fs],type:"line",slot:"middle",source:this[Bs],filter:["all",["==","visibility","visible"],["==","$type","LineString"]],layout:{"line-join":"round","line-cap":"round",visibility:"visible"},paint:{"line-color":this.get("strokeColor"),"line-width":this.get("strokeWeight"),"line-opacity":this.get("strokeOpacity")}},e),i.addLayer({id:this[Du],type:"line",slot:"middle",source:this[Wo],layout:{"line-join":"round","line-cap":"round",visibility:"visible","line-sort-key":["get","zIndex"]},paint:{"line-width":["get","strokeWeight"],"line-color":["get","strokeColor"],"line-opacity":["get","strokeOpacity"]}},e),i.addLayer({id:this[S0],type:"symbol",slot:"middle",source:this[Bs],filter:["all",["==","visibility","visible"],["==","$type","Point"]],layout:{"icon-allow-overlap":!0,"icon-anchor":"bottom","icon-image":["get","iconSrc"],"icon-optional":!1,"icon-size":["get","iconScale"],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-allow-overlap":!0,"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-padding":0,"text-size":["number",["get","labelSize"],se.labelStyle.textSize],"text-offset":["get","labelOffset"]},paint:{"text-color":["to-color",["get","labelColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStrokeStyle"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStrokeWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStrokeBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelOpacity"],se.labelStyle.textOpacity]}}),this[Fl]=i.getSource(this[Bs]),this[Bl]=i.getSource(this[Wo])}function Ou(){let i=this.get("mapsIndoors"),e=this.get("map"),t=parseInt(i.getFloor()),n=this.get("animation"),s=this.get("legIndex"),[r,o]=this.get("viewModel")??[];if(!r?.[s]&&n&&n.clear(),this[Fl])if(r?.[s]){let a=o?.filter(l=>parseInt(l.properties.floorIndex)===t);for(let l of a)if(l.properties.iconSrc&&!e.hasImage(l.properties.iconSrc)){let c=Uu();e.addImage(c,l.properties.icon),l.properties.iconSrc=c}for(let l of r[s]){let c=parseInt(l.properties.floorIndex),h=l.properties.routeContext;l.properties.visibility=h==="Outside"||c===t?"visible":"none"}this[Fl].setData({type:"FeatureCollection",features:[...r[s],...a]})}else this[Fl].setData({type:"FeatureCollection",features:[]}),this[Bl].setData({type:"FeatureCollection",features:[]})}function Uu(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}E();E();E();var pa="169";var Bb=0,w0=1,kb=2;var Vy=1,zb=2,Ni=3,Si=0,mn=1,Nn=2,as=0,Wr=1,A0=2,E0=3,T0=4,Vb=5,qs=100,Hb=101,Gb=102,Wb=103,Xb=104,qb=200,Yb=201,Kb=202,Zb=203,yf=204,_f=205,$b=206,Jb=207,jb=208,Qb=209,eM=210,tM=211,nM=212,iM=213,sM=214,vf=0,xf=1,bf=2,Kr=3,Mf=4,Sf=5,wf=6,Af=7,Hy=0,rM=1,oM=2,ls=0,aM=1,lM=2,cM=3,hM=4,uM=5,fM=6,dM=7,I0="attached",pM="detached",Gy=300,Zr=301,$r=302,Ef=303,Tf=304,qc=306,Ui=1e3,li=1001,Zs=1002,Xt=1003,ma=1004;var rs=1005;var Ot=1006,Ks=1007;var Wn=1008;var Fi=1009,Wy=1010,Xy=1011,sa=1012,Cd=1013,$s=1014,ci=1015,ga=1016,Ld=1017,Pd=1018,Jr=1020,qy=35902,Yy=1021,Ky=1022,pn=1023,Zy=1024,$y=1025,Xr=1026,jr=1027,Nd=1028,Od=1029,Jy=1030,Dd=1031;var Ud=1033,dc=33776,pc=33777,mc=33778,gc=33779,If=35840,Rf=35841,Cf=35842,Lf=35843,Pf=36196,Nf=37492,Of=37496,Df=37808,Uf=37809,Ff=37810,Bf=37811,kf=37812,zf=37813,Vf=37814,Hf=37815,Gf=37816,Wf=37817,Xf=37818,qf=37819,Yf=37820,Kf=37821,yc=36492,Zf=36494,$f=36495,jy=36283,Jf=36284,jf=36285,Qf=36286;var cs=2300,hs=2301,Fu=2302,R0=2400,C0=2401,L0=2402,mM=2500;var Qy=0,Yc=1,ya=2,gM=3200,yM=3201;var e_=0,_M=1,bi="",Nt="srgb",qt="srgb-linear",Fd="display-p3",Kc="display-p3-linear",vc="linear",_t="srgb",xc="rec709",bc="p3";var Ir=7680;var P0=519,vM=512,xM=513,bM=514,t_=515,MM=516,SM=517,wM=518,AM=519,ed=35044;var N0="300 es",Di=2e3,Mc=2001,us=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let s=this._listeners[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},nn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],O0=1234567,ta=Math.PI/180,Qr=180/Math.PI;function hi(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]+"-"+nn[e&255]+nn[e>>8&255]+"-"+nn[e>>16&15|64]+nn[e>>24&255]+"-"+nn[t&63|128]+nn[t>>8&255]+"-"+nn[t>>16&255]+nn[t>>24&255]+nn[n&255]+nn[n>>8&255]+nn[n>>16&255]+nn[n>>24&255]).toLowerCase()}function rn(i,e,t){return Math.max(e,Math.min(t,i))}function Bd(i,e){return(i%e+e)%e}function EM(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function TM(i,e,t){return i!==e?(t-i)/(e-i):0}function na(i,e,t){return(1-t)*i+t*e}function IM(i,e,t,n){return na(i,e,1-Math.exp(-t*n))}function RM(i,e=1){return e-Math.abs(Bd(i,e*2)-e)}function CM(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function LM(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function PM(i,e){return i+Math.floor(Math.random()*(e-i+1))}function NM(i,e){return i+Math.random()*(e-i)}function OM(i){return i*(.5-Math.random())}function DM(i){i!==void 0&&(O0=i);let e=O0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function UM(i){return i*ta}function FM(i){return i*Qr}function BM(i){return(i&i-1)===0&&i!==0}function kM(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function zM(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function VM(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),f=o((e-n)/2),d=r((n-e)/2),y=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*u,l*f,a*c);break;case"YZY":i.set(l*f,a*h,l*u,a*c);break;case"ZXZ":i.set(l*u,l*f,a*h,a*c);break;case"XZX":i.set(a*h,l*y,l*d,a*c);break;case"YXY":i.set(l*d,a*h,l*y,a*c);break;case"ZYZ":i.set(l*y,l*d,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ai(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function lt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var co={DEG2RAD:ta,RAD2DEG:Qr,generateUUID:hi,clamp:rn,euclideanModulo:Bd,mapLinear:EM,inverseLerp:TM,lerp:na,damp:IM,pingpong:RM,smoothstep:CM,smootherstep:LM,randInt:PM,randFloat:NM,randFloatSpread:OM,seededRandom:DM,degToRad:UM,radToDeg:FM,isPowerOfTwo:BM,ceilPowerOfTwo:kM,floorPowerOfTwo:zM,setQuaternionFromProperEuler:VM,normalize:lt,denormalize:ai},Ve=class{constructor(e=0,t=0){Ve.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ke=class{constructor(e,t,n,s,r,o,a,l,c){ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],f=n[2],d=n[5],y=n[8],g=s[0],p=s[3],m=s[6],M=s[1],b=s[4],S=s[7],O=s[2],L=s[5],R=s[8];return r[0]=o*g+a*M+l*O,r[3]=o*p+a*b+l*L,r[6]=o*m+a*S+l*R,r[1]=c*g+h*M+u*O,r[4]=c*p+h*b+u*L,r[7]=c*m+h*S+u*R,r[2]=f*g+d*M+y*O,r[5]=f*p+d*b+y*L,r[8]=f*m+d*S+y*R,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*o-a*c,f=a*l-h*r,d=c*r-o*l,y=t*u+n*f+s*d;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/y;return e[0]=u*g,e[1]=(s*c-h*n)*g,e[2]=(a*n-s*o)*g,e[3]=f*g,e[4]=(h*t-s*l)*g,e[5]=(s*r-a*t)*g,e[6]=d*g,e[7]=(n*l-c*t)*g,e[8]=(o*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Bu.makeScale(e,t)),this}rotate(e){return this.premultiply(Bu.makeRotation(-e)),this}translate(e,t){return this.premultiply(Bu.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Bu=new ke;function n_(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ra(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function HM(){let i=ra("canvas");return i.style.display="block",i}var D0={};function _c(i){i in D0||(D0[i]=!0,console.warn(i))}function GM(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function WM(i){let e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function XM(i){let e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var U0=new ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),F0=new ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Xo={[qt]:{transfer:vc,primaries:xc,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Nt]:{transfer:_t,primaries:xc,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Kc]:{transfer:vc,primaries:bc,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(F0),fromReference:i=>i.applyMatrix3(U0)},[Fd]:{transfer:_t,primaries:bc,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(F0),fromReference:i=>i.applyMatrix3(U0).convertLinearToSRGB()}},qM=new Set([qt,Kc]),je={enabled:!0,_workingColorSpace:qt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!qM.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;let n=Xo[e].toReference,s=Xo[t].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return Xo[i].primaries},getTransfer:function(i){return i===bi?vc:Xo[i].transfer},getLuminanceCoefficients:function(i,e=this._workingColorSpace){return i.fromArray(Xo[e].luminanceCoefficients)}};function qr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ku(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Rr,td=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Rr===void 0&&(Rr=ra("canvas")),Rr.width=e.width,Rr.height=e.height;let n=Rr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Rr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=ra("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=qr(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(qr(t[n]/255)*255):t[n]=qr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},YM=0,eo=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:YM++}),this.uuid=hi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(zu(s[o].image)):r.push(zu(s[o]))}else r=zu(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function zu(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?td.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var KM=0,vt=class extends us{constructor(e=vt.DEFAULT_IMAGE,t=vt.DEFAULT_MAPPING,n=li,s=li,r=Ot,o=Wn,a=pn,l=Fi,c=vt.DEFAULT_ANISOTROPY,h=bi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:KM++}),this.uuid=hi(),this.name="",this.source=new eo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gy)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ui:e.x=e.x-Math.floor(e.x);break;case li:e.x=e.x<0?0:1;break;case Zs:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ui:e.y=e.y-Math.floor(e.y);break;case li:e.y=e.y<0?0:1;break;case Zs:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};vt.DEFAULT_IMAGE=null;vt.DEFAULT_MAPPING=Gy;vt.DEFAULT_ANISOTROPY=1;var Qe=class{constructor(e=0,t=0,n=0,s=1){Qe.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],u=l[8],f=l[1],d=l[5],y=l[9],g=l[2],p=l[6],m=l[10];if(Math.abs(h-f)<.01&&Math.abs(u-g)<.01&&Math.abs(y-p)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+g)<.1&&Math.abs(y+p)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let b=(c+1)/2,S=(d+1)/2,O=(m+1)/2,L=(h+f)/4,R=(u+g)/4,C=(y+p)/4;return b>S&&b>O?b<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(b),s=L/n,r=R/n):S>O?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=L/s,r=C/s):O<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(O),n=R/r,s=C/r),this.set(n,s,r,t),this}let M=Math.sqrt((p-y)*(p-y)+(u-g)*(u-g)+(f-h)*(f-h));return Math.abs(M)<.001&&(M=1),this.x=(p-y)/M,this.y=(u-g)/M,this.z=(f-h)/M,this.w=Math.acos((c+d+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},nd=class extends us{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Qe(0,0,e,t),this.scissorTest=!1,this.viewport=new Qe(0,0,e,t);let s={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ot,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let r=new vt(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,s=e.textures.length;n<s;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new eo(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Bi=class extends nd{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Sc=class extends vt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var id=class extends vt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Dn=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],f=r[o+0],d=r[o+1],y=r[o+2],g=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=y,e[t+3]=g;return}if(u!==g||l!==f||c!==d||h!==y){let p=1-a,m=l*f+c*d+h*y+u*g,M=m>=0?1:-1,b=1-m*m;if(b>Number.EPSILON){let O=Math.sqrt(b),L=Math.atan2(O,m*M);p=Math.sin(p*L)/O,a=Math.sin(a*L)/O}let S=a*M;if(l=l*p+f*S,c=c*p+d*S,h=h*p+y*S,u=u*p+g*S,p===1-a){let O=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=O,c*=O,h*=O,u*=O}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[o],f=r[o+1],d=r[o+2],y=r[o+3];return e[t]=a*y+h*u+l*d-c*f,e[t+1]=l*y+h*f+c*u-a*d,e[t+2]=c*y+h*d+a*f-l*u,e[t+3]=h*y-a*u-l*f-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),u=a(r/2),f=l(n/2),d=l(s/2),y=l(r/2);switch(o){case"XYZ":this._x=f*h*u+c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u-f*d*y;break;case"YXZ":this._x=f*h*u+c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u+f*d*y;break;case"ZXY":this._x=f*h*u-c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u-f*d*y;break;case"ZYX":this._x=f*h*u-c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u+f*d*y;break;case"YZX":this._x=f*h*u+c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u-f*d*y;break;case"XZY":this._x=f*h*u-c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u+f*d*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],u=t[10],f=n+a+u;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-l)*d,this._y=(r-c)*d,this._z=(o-s)*d}else if(n>a&&n>u){let d=2*Math.sqrt(1+n-a-u);this._w=(h-l)/d,this._x=.25*d,this._y=(s+o)/d,this._z=(r+c)/d}else if(a>u){let d=2*Math.sqrt(1+a-n-u);this._w=(r-c)/d,this._x=(s+o)/d,this._y=.25*d,this._z=(l+h)/d}else{let d=2*Math.sqrt(1+u-n-a);this._w=(o-s)/d,this._x=(r+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(rn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,s=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=s,this._z=r,this;let l=1-a*a;if(l<=Number.EPSILON){let d=1-t;return this._w=d*o+t*this._w,this._x=d*n+t*this._x,this._y=d*s+t*this._y,this._z=d*r+t*this._z,this.normalize(),this}let c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=o*u+this._w*f,this._x=n*u+this._x*f,this._y=s*u+this._y*f,this._z=r*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},F=class{constructor(e=0,t=0,n=0){F.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(B0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(B0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),u=2*(r*n-o*t);return this.x=t+l*c+o*u-a*h,this.y=n+l*h+a*c-r*u,this.z=s+l*u+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Vu.copy(this).projectOnVector(e),this.sub(Vu)}reflect(e){return this.sub(Vu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Vu=new F,B0=new Dn,qn=class{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(si.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(si.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=si.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,si):si.fromBufferAttribute(r,o),si.applyMatrix4(e.matrixWorld),this.expandByPoint(si);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),zl.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),zl.copy(n.boundingBox)),zl.applyMatrix4(e.matrixWorld),this.union(zl)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,si),si.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(qo),Vl.subVectors(this.max,qo),Cr.subVectors(e.a,qo),Lr.subVectors(e.b,qo),Pr.subVectors(e.c,qo),Qi.subVectors(Lr,Cr),es.subVectors(Pr,Lr),ks.subVectors(Cr,Pr);let t=[0,-Qi.z,Qi.y,0,-es.z,es.y,0,-ks.z,ks.y,Qi.z,0,-Qi.x,es.z,0,-es.x,ks.z,0,-ks.x,-Qi.y,Qi.x,0,-es.y,es.x,0,-ks.y,ks.x,0];return!Hu(t,Cr,Lr,Pr,Vl)||(t=[1,0,0,0,1,0,0,0,1],!Hu(t,Cr,Lr,Pr,Vl))?!1:(Hl.crossVectors(Qi,es),t=[Hl.x,Hl.y,Hl.z],Hu(t,Cr,Lr,Pr,Vl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,si).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(si).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ti[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ti[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ti[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ti[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ti[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ti[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ti[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ti[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ti),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Ti=[new F,new F,new F,new F,new F,new F,new F,new F],si=new F,zl=new qn,Cr=new F,Lr=new F,Pr=new F,Qi=new F,es=new F,ks=new F,qo=new F,Vl=new F,Hl=new F,zs=new F;function Hu(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){zs.fromArray(i,r);let a=s.x*Math.abs(zs.x)+s.y*Math.abs(zs.y)+s.z*Math.abs(zs.z),l=e.dot(zs),c=t.dot(zs),h=n.dot(zs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var ZM=new qn,Yo=new F,Gu=new F,Un=class{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):ZM.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yo.subVectors(e,this.center);let t=Yo.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Yo,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Gu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yo.copy(e.center).add(Gu)),this.expandByPoint(Yo.copy(e.center).sub(Gu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Ii=new F,Wu=new F,Gl=new F,ts=new F,Xu=new F,Wl=new F,qu=new F,Js=class{constructor(e=new F,t=new F(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ii)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ii.copy(this.origin).addScaledVector(this.direction,t),Ii.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Wu.copy(e).add(t).multiplyScalar(.5),Gl.copy(t).sub(e).normalize(),ts.copy(this.origin).sub(Wu);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Gl),a=ts.dot(this.direction),l=-ts.dot(Gl),c=ts.lengthSq(),h=Math.abs(1-o*o),u,f,d,y;if(h>0)if(u=o*l-a,f=o*a-l,y=r*h,u>=0)if(f>=-y)if(f<=y){let g=1/h;u*=g,f*=g,d=u*(u+o*f+2*a)+f*(o*u+f+2*l)+c}else f=r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;else f=-r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;else f<=-y?(u=Math.max(0,-(-o*r+a)),f=u>0?-r:Math.min(Math.max(-r,-l),r),d=-u*u+f*(f+2*l)+c):f<=y?(u=0,f=Math.min(Math.max(-r,-l),r),d=f*(f+2*l)+c):(u=Math.max(0,-(o*r+a)),f=u>0?r:Math.min(Math.max(-r,-l),r),d=-u*u+f*(f+2*l)+c);else f=o>0?-r:r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Wu).addScaledVector(Gl,f),d}intersectSphere(e,t){Ii.subVectors(e.center,this.origin);let n=Ii.dot(this.direction),s=Ii.dot(Ii)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,s=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,s=(e.min.x-f.x)*c),h>=0?(r=(e.min.y-f.y)*h,o=(e.max.y-f.y)*h):(r=(e.max.y-f.y)*h,o=(e.min.y-f.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Ii)!==null}intersectTriangle(e,t,n,s,r){Xu.subVectors(t,e),Wl.subVectors(n,e),qu.crossVectors(Xu,Wl);let o=this.direction.dot(qu),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ts.subVectors(this.origin,e);let l=a*this.direction.dot(Wl.crossVectors(ts,Wl));if(l<0)return null;let c=a*this.direction.dot(Xu.cross(ts));if(c<0||l+c>o)return null;let h=-a*ts.dot(qu);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ie=class{constructor(e,t,n,s,r,o,a,l,c,h,u,f,d,y,g,p){Ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c,h,u,f,d,y,g,p)}set(e,t,n,s,r,o,a,l,c,h,u,f,d,y,g,p){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=s,m[1]=r,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=y,m[11]=g,m[15]=p,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 Ie().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,s=1/Nr.setFromMatrixColumn(e,0).length(),r=1/Nr.setFromMatrixColumn(e,1).length(),o=1/Nr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=o*h,d=o*u,y=a*h,g=a*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=d+y*c,t[5]=f-g*c,t[9]=-a*l,t[2]=g-f*c,t[6]=y+d*c,t[10]=o*l}else if(e.order==="YXZ"){let f=l*h,d=l*u,y=c*h,g=c*u;t[0]=f+g*a,t[4]=y*a-d,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=d*a-y,t[6]=g+f*a,t[10]=o*l}else if(e.order==="ZXY"){let f=l*h,d=l*u,y=c*h,g=c*u;t[0]=f-g*a,t[4]=-o*u,t[8]=y+d*a,t[1]=d+y*a,t[5]=o*h,t[9]=g-f*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let f=o*h,d=o*u,y=a*h,g=a*u;t[0]=l*h,t[4]=y*c-d,t[8]=f*c+g,t[1]=l*u,t[5]=g*c+f,t[9]=d*c-y,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let f=o*l,d=o*c,y=a*l,g=a*c;t[0]=l*h,t[4]=g-f*u,t[8]=y*u+d,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=d*u+y,t[10]=f-g*u}else if(e.order==="XZY"){let f=o*l,d=o*c,y=a*l,g=a*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=f*u+g,t[5]=o*h,t[9]=d*u-y,t[2]=y*u-d,t[6]=a*h,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose($M,e,JM)}lookAt(e,t,n){let s=this.elements;return Ln.subVectors(e,t),Ln.lengthSq()===0&&(Ln.z=1),Ln.normalize(),ns.crossVectors(n,Ln),ns.lengthSq()===0&&(Math.abs(n.z)===1?Ln.x+=1e-4:Ln.z+=1e-4,Ln.normalize(),ns.crossVectors(n,Ln)),ns.normalize(),Xl.crossVectors(Ln,ns),s[0]=ns.x,s[4]=Xl.x,s[8]=Ln.x,s[1]=ns.y,s[5]=Xl.y,s[9]=Ln.y,s[2]=ns.z,s[6]=Xl.z,s[10]=Ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],f=n[9],d=n[13],y=n[2],g=n[6],p=n[10],m=n[14],M=n[3],b=n[7],S=n[11],O=n[15],L=s[0],R=s[4],C=s[8],j=s[12],v=s[1],_=s[5],x=s[9],T=s[13],P=s[2],U=s[6],N=s[10],H=s[14],G=s[3],$=s[7],re=s[11],J=s[15];return r[0]=o*L+a*v+l*P+c*G,r[4]=o*R+a*_+l*U+c*$,r[8]=o*C+a*x+l*N+c*re,r[12]=o*j+a*T+l*H+c*J,r[1]=h*L+u*v+f*P+d*G,r[5]=h*R+u*_+f*U+d*$,r[9]=h*C+u*x+f*N+d*re,r[13]=h*j+u*T+f*H+d*J,r[2]=y*L+g*v+p*P+m*G,r[6]=y*R+g*_+p*U+m*$,r[10]=y*C+g*x+p*N+m*re,r[14]=y*j+g*T+p*H+m*J,r[3]=M*L+b*v+S*P+O*G,r[7]=M*R+b*_+S*U+O*$,r[11]=M*C+b*x+S*N+O*re,r[15]=M*j+b*T+S*H+O*J,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],u=e[6],f=e[10],d=e[14],y=e[3],g=e[7],p=e[11],m=e[15];return y*(+r*l*u-s*c*u-r*a*f+n*c*f+s*a*d-n*l*d)+g*(+t*l*d-t*c*f+r*o*f-s*o*d+s*c*h-r*l*h)+p*(+t*c*u-t*a*d-r*o*u+n*o*d+r*a*h-n*c*h)+m*(-s*a*h-t*l*u+t*a*f+s*o*u-n*o*f+n*l*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],f=e[10],d=e[11],y=e[12],g=e[13],p=e[14],m=e[15],M=u*p*c-g*f*c+g*l*d-a*p*d-u*l*m+a*f*m,b=y*f*c-h*p*c-y*l*d+o*p*d+h*l*m-o*f*m,S=h*g*c-y*u*c+y*a*d-o*g*d-h*a*m+o*u*m,O=y*u*l-h*g*l-y*a*f+o*g*f+h*a*p-o*u*p,L=t*M+n*b+s*S+r*O;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/L;return e[0]=M*R,e[1]=(g*f*r-u*p*r-g*s*d+n*p*d+u*s*m-n*f*m)*R,e[2]=(a*p*r-g*l*r+g*s*c-n*p*c-a*s*m+n*l*m)*R,e[3]=(u*l*r-a*f*r-u*s*c+n*f*c+a*s*d-n*l*d)*R,e[4]=b*R,e[5]=(h*p*r-y*f*r+y*s*d-t*p*d-h*s*m+t*f*m)*R,e[6]=(y*l*r-o*p*r-y*s*c+t*p*c+o*s*m-t*l*m)*R,e[7]=(o*f*r-h*l*r+h*s*c-t*f*c-o*s*d+t*l*d)*R,e[8]=S*R,e[9]=(y*u*r-h*g*r-y*n*d+t*g*d+h*n*m-t*u*m)*R,e[10]=(o*g*r-y*a*r+y*n*c-t*g*c-o*n*m+t*a*m)*R,e[11]=(h*a*r-o*u*r-h*n*c+t*u*c+o*n*d-t*a*d)*R,e[12]=O*R,e[13]=(h*g*s-y*u*s+y*n*f-t*g*f-h*n*p+t*u*p)*R,e[14]=(y*a*s-o*g*s-y*n*l+t*g*l+o*n*p-t*a*p)*R,e[15]=(o*u*s-h*a*s+h*n*l-t*u*l-o*n*f+t*a*f)*R,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+n,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,u=a+a,f=r*c,d=r*h,y=r*u,g=o*h,p=o*u,m=a*u,M=l*c,b=l*h,S=l*u,O=n.x,L=n.y,R=n.z;return s[0]=(1-(g+m))*O,s[1]=(d+S)*O,s[2]=(y-b)*O,s[3]=0,s[4]=(d-S)*L,s[5]=(1-(f+m))*L,s[6]=(p+M)*L,s[7]=0,s[8]=(y+b)*R,s[9]=(p-M)*R,s[10]=(1-(f+g))*R,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements,r=Nr.set(s[0],s[1],s[2]).length(),o=Nr.set(s[4],s[5],s[6]).length(),a=Nr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],ri.copy(this);let c=1/r,h=1/o,u=1/a;return ri.elements[0]*=c,ri.elements[1]*=c,ri.elements[2]*=c,ri.elements[4]*=h,ri.elements[5]*=h,ri.elements[6]*=h,ri.elements[8]*=u,ri.elements[9]*=u,ri.elements[10]*=u,t.setFromRotationMatrix(ri),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,s,r,o,a=Di){let l=this.elements,c=2*r/(t-e),h=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),d,y;if(a===Di)d=-(o+r)/(o-r),y=-2*o*r/(o-r);else if(a===Mc)d=-o/(o-r),y=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=d,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=Di){let l=this.elements,c=1/(t-e),h=1/(n-s),u=1/(o-r),f=(t+e)*c,d=(n+s)*h,y,g;if(a===Di)y=(o+r)*u,g=-2*u;else if(a===Mc)y=r*u,g=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-d,l[2]=0,l[6]=0,l[10]=g,l[14]=-y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Nr=new F,ri=new Ie,$M=new F(0,0,0),JM=new F(1,1,1),ns=new F,Xl=new F,Ln=new F,k0=new Ie,z0=new Dn,on=class{constructor(e=0,t=0,n=0,s=on.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],u=s[2],f=s[6],d=s[10];switch(t){case"XYZ":this._y=Math.asin(rn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-rn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(rn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-rn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(rn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-rn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return k0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(k0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return z0.setFromEuler(this),this.setFromQuaternion(z0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};on.DEFAULT_ORDER="XYZ";var oa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},jM=0,V0=new F,Or=new Dn,Ri=new Ie,ql=new F,Ko=new F,QM=new F,eS=new Dn,H0=new F(1,0,0),G0=new F(0,1,0),W0=new F(0,0,1),X0={type:"added"},tS={type:"removed"},Dr={type:"childadded",child:null},Yu={type:"childremoved",child:null},ut=class extends us{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=hi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new F,t=new on,n=new Dn,s=new F(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Ie},normalMatrix:{value:new ke}}),this.matrix=new Ie,this.matrixWorld=new Ie,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new oa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Or.setFromAxisAngle(e,t),this.quaternion.multiply(Or),this}rotateOnWorldAxis(e,t){return Or.setFromAxisAngle(e,t),this.quaternion.premultiply(Or),this}rotateX(e){return this.rotateOnAxis(H0,e)}rotateY(e){return this.rotateOnAxis(G0,e)}rotateZ(e){return this.rotateOnAxis(W0,e)}translateOnAxis(e,t){return V0.copy(e).applyQuaternion(this.quaternion),this.position.add(V0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(H0,e)}translateY(e){return this.translateOnAxis(G0,e)}translateZ(e){return this.translateOnAxis(W0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ri.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ql.copy(e):ql.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ko.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ri.lookAt(Ko,ql,this.up):Ri.lookAt(ql,Ko,this.up),this.quaternion.setFromRotationMatrix(Ri),s&&(Ri.extractRotation(s.matrixWorld),Or.setFromRotationMatrix(Ri),this.quaternion.premultiply(Or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(X0),Dr.child=e,this.dispatchEvent(Dr),Dr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(tS),Yu.child=e,this.dispatchEvent(Yu),Yu.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ri.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ri.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ri),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(X0),Dr.child=e,this.dispatchEvent(Dr),Dr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ko,e,QM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ko,eS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),u=o(e.shapes),f=o(e.skeletons),d=o(e.animations),y=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),y.length>0&&(n.nodes=y)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};ut.DEFAULT_UP=new F(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var oi=new F,Ci=new F,Ku=new F,Li=new F,Ur=new F,Fr=new F,q0=new F,Zu=new F,$u=new F,Ju=new F,ju=new Qe,Qu=new Qe,ef=new Qe,On=class{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),oi.subVectors(e,t),s.cross(oi);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){oi.subVectors(s,t),Ci.subVectors(n,t),Ku.subVectors(e,t);let o=oi.dot(oi),a=oi.dot(Ci),l=oi.dot(Ku),c=Ci.dot(Ci),h=Ci.dot(Ku),u=o*c-a*a;if(u===0)return r.set(0,0,0),null;let f=1/u,d=(c*l-a*h)*f,y=(o*h-a*l)*f;return r.set(1-d-y,y,d)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Li)===null?!1:Li.x>=0&&Li.y>=0&&Li.x+Li.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,Li)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Li.x),l.addScaledVector(o,Li.y),l.addScaledVector(a,Li.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return ju.setScalar(0),Qu.setScalar(0),ef.setScalar(0),ju.fromBufferAttribute(e,t),Qu.fromBufferAttribute(e,n),ef.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(ju,r.x),o.addScaledVector(Qu,r.y),o.addScaledVector(ef,r.z),o}static isFrontFacing(e,t,n,s){return oi.subVectors(n,t),Ci.subVectors(e,t),oi.cross(Ci).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return oi.subVectors(this.c,this.b),Ci.subVectors(this.a,this.b),oi.cross(Ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return On.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return On.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return On.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return On.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return On.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;Ur.subVectors(s,n),Fr.subVectors(r,n),Zu.subVectors(e,n);let l=Ur.dot(Zu),c=Fr.dot(Zu);if(l<=0&&c<=0)return t.copy(n);$u.subVectors(e,s);let h=Ur.dot($u),u=Fr.dot($u);if(h>=0&&u<=h)return t.copy(s);let f=l*u-h*c;if(f<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(Ur,o);Ju.subVectors(e,r);let d=Ur.dot(Ju),y=Fr.dot(Ju);if(y>=0&&d<=y)return t.copy(r);let g=d*c-l*y;if(g<=0&&c>=0&&y<=0)return a=c/(c-y),t.copy(n).addScaledVector(Fr,a);let p=h*y-d*u;if(p<=0&&u-h>=0&&d-y>=0)return q0.subVectors(r,s),a=(u-h)/(u-h+(d-y)),t.copy(s).addScaledVector(q0,a);let m=1/(p+g+f);return o=g*m,a=f*m,t.copy(n).addScaledVector(Ur,o).addScaledVector(Fr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},i_={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},is={h:0,s:0,l:0},Yl={h:0,s:0,l:0};function tf(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Re=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=je.workingColorSpace){if(e=Bd(e,1),t=rn(t,0,1),n=rn(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=tf(o,r,e+1/3),this.g=tf(o,r,e),this.b=tf(o,r,e-1/3)}return je.toWorkingColorSpace(this,s),this}setStyle(e,t=Nt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nt){let n=i_[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=qr(e.r),this.g=qr(e.g),this.b=qr(e.b),this}copyLinearToSRGB(e){return this.r=ku(e.r),this.g=ku(e.g),this.b=ku(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nt){return je.fromWorkingColorSpace(sn.copy(this),e),Math.round(rn(sn.r*255,0,255))*65536+Math.round(rn(sn.g*255,0,255))*256+Math.round(rn(sn.b*255,0,255))}getHexString(e=Nt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.fromWorkingColorSpace(sn.copy(this),t);let n=sn.r,s=sn.g,r=sn.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=je.workingColorSpace){return je.fromWorkingColorSpace(sn.copy(this),t),e.r=sn.r,e.g=sn.g,e.b=sn.b,e}getStyle(e=Nt){je.fromWorkingColorSpace(sn.copy(this),e);let t=sn.r,n=sn.g,s=sn.b;return e!==Nt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(is),this.setHSL(is.h+e,is.s+t,is.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(is),e.getHSL(Yl);let n=na(is.h,Yl.h,t),s=na(is.s,Yl.s,t),r=na(is.l,Yl.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},sn=new Re;Re.NAMES=i_;var nS=0,Fn=class extends us{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nS++}),this.uuid=hi(),this.name="",this.type="Material",this.blending=Wr,this.side=Si,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yf,this.blendDst=_f,this.blendEquation=qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Re(0,0,0),this.blendAlpha=0,this.depthFunc=Kr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=P0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ir,this.stencilZFail=Ir,this.stencilZPass=Ir,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.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Wr&&(n.blending=this.blending),this.side!==Si&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==yf&&(n.blendSrc=this.blendSrc),this.blendDst!==_f&&(n.blendDst=this.blendDst),this.blendEquation!==qs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Kr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==P0&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ir&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ir&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ir&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}},gn=class extends Fn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=Hy,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};var Pt=new F,Kl=new Ve,ft=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ed,this.updateRanges=[],this.gpuType=ci,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Kl.fromBufferAttribute(this,t),Kl.applyMatrix3(e),this.setXY(t,Kl.x,Kl.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix3(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ai(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=lt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ai(t,this.array)),t}setX(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ai(t,this.array)),t}setY(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ai(t,this.array)),t}setZ(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ai(t,this.array)),t}setW(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),s=lt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),s=lt(s,this.array),r=lt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ed&&(e.usage=this.usage),e}};var wc=class extends ft{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Ac=class extends ft{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Xn=class extends ft{constructor(e,t,n){super(new Float32Array(e),t,n)}},iS=0,Gn=new Ie,nf=new ut,Br=new F,Pn=new qn,Zo=new qn,Wt=new F,yn=class extends us{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iS++}),this.uuid=hi(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(n_(e)?Ac:wc)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Gn.makeRotationFromQuaternion(e),this.applyMatrix4(Gn),this}rotateX(e){return Gn.makeRotationX(e),this.applyMatrix4(Gn),this}rotateY(e){return Gn.makeRotationY(e),this.applyMatrix4(Gn),this}rotateZ(e){return Gn.makeRotationZ(e),this.applyMatrix4(Gn),this}translate(e,t,n){return Gn.makeTranslation(e,t,n),this.applyMatrix4(Gn),this}scale(e,t,n){return Gn.makeScale(e,t,n),this.applyMatrix4(Gn),this}lookAt(e){return nf.lookAt(e),nf.updateMatrix(),this.applyMatrix4(nf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Br).negate(),this.translate(Br.x,Br.y,Br.z),this}setFromPoints(e){let t=[];for(let n=0,s=e.length;n<s;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Xn(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new qn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];Pn.setFromBufferAttribute(r),this.morphTargetsRelative?(Wt.addVectors(this.boundingBox.min,Pn.min),this.boundingBox.expandByPoint(Wt),Wt.addVectors(this.boundingBox.max,Pn.max),this.boundingBox.expandByPoint(Wt)):(this.boundingBox.expandByPoint(Pn.min),this.boundingBox.expandByPoint(Pn.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(){this.boundingSphere===null&&(this.boundingSphere=new Un);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){let n=this.boundingSphere.center;if(Pn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];Zo.setFromBufferAttribute(a),this.morphTargetsRelative?(Wt.addVectors(Pn.min,Zo.min),Pn.expandByPoint(Wt),Wt.addVectors(Pn.max,Zo.max),Pn.expandByPoint(Wt)):(Pn.expandByPoint(Zo.min),Pn.expandByPoint(Zo.max))}Pn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Wt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Wt));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)Wt.fromBufferAttribute(a,c),l&&(Br.fromBufferAttribute(e,c),Wt.add(Br)),s=Math.max(s,n.distanceToSquared(Wt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ft(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let C=0;C<n.count;C++)a[C]=new F,l[C]=new F;let c=new F,h=new F,u=new F,f=new Ve,d=new Ve,y=new Ve,g=new F,p=new F;function m(C,j,v){c.fromBufferAttribute(n,C),h.fromBufferAttribute(n,j),u.fromBufferAttribute(n,v),f.fromBufferAttribute(r,C),d.fromBufferAttribute(r,j),y.fromBufferAttribute(r,v),h.sub(c),u.sub(c),d.sub(f),y.sub(f);let _=1/(d.x*y.y-y.x*d.y);!isFinite(_)||(g.copy(h).multiplyScalar(y.y).addScaledVector(u,-d.y).multiplyScalar(_),p.copy(u).multiplyScalar(d.x).addScaledVector(h,-y.x).multiplyScalar(_),a[C].add(g),a[j].add(g),a[v].add(g),l[C].add(p),l[j].add(p),l[v].add(p))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let C=0,j=M.length;C<j;++C){let v=M[C],_=v.start,x=v.count;for(let T=_,P=_+x;T<P;T+=3)m(e.getX(T+0),e.getX(T+1),e.getX(T+2))}let b=new F,S=new F,O=new F,L=new F;function R(C){O.fromBufferAttribute(s,C),L.copy(O);let j=a[C];b.copy(j),b.sub(O.multiplyScalar(O.dot(j))).normalize(),S.crossVectors(L,j);let _=S.dot(l[C])<0?-1:1;o.setXYZW(C,b.x,b.y,b.z,_)}for(let C=0,j=M.length;C<j;++C){let v=M[C],_=v.start,x=v.count;for(let T=_,P=_+x;T<P;T+=3)R(e.getX(T+0)),R(e.getX(T+1)),R(e.getX(T+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ft(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);let s=new F,r=new F,o=new F,a=new F,l=new F,c=new F,h=new F,u=new F;if(e)for(let f=0,d=e.count;f<d;f+=3){let y=e.getX(f+0),g=e.getX(f+1),p=e.getX(f+2);s.fromBufferAttribute(t,y),r.fromBufferAttribute(t,g),o.fromBufferAttribute(t,p),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),a.fromBufferAttribute(n,y),l.fromBufferAttribute(n,g),c.fromBufferAttribute(n,p),a.add(h),l.add(h),c.add(h),n.setXYZ(y,a.x,a.y,a.z),n.setXYZ(g,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let f=0,d=t.count;f<d;f+=3)s.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Wt.fromBufferAttribute(e,t),Wt.normalize(),e.setXYZ(t,Wt.x,Wt.y,Wt.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,u=a.normalized,f=new c.constructor(l.length*h),d=0,y=0;for(let g=0,p=l.length;g<p;g++){a.isInterleavedBufferAttribute?d=l[g]*a.data.stride+a.offset:d=l[g]*h;for(let m=0;m<h;m++)f[y++]=c[d++]}return new ft(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new yn,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=e(l,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let h=0,u=c.length;h<u;h++){let f=c[h],d=e(f,n);l.push(d)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,f=c.length;u<f;u++){let d=c[u];h.push(d.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],u=r[c];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Y0=new Ie,Vs=new Js,Zl=new Un,K0=new F,$l=new F,Jl=new F,jl=new F,sf=new F,Ql=new F,Z0=new F,ec=new F,St=class extends ut{constructor(e=new yn,t=new gn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){Ql.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=a[l],u=r[l];h!==0&&(sf.fromBufferAttribute(u,e),o?Ql.addScaledVector(sf,h):Ql.addScaledVector(sf.sub(t),h))}t.add(Ql)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Zl.copy(n.boundingSphere),Zl.applyMatrix4(r),Vs.copy(e.ray).recast(e.near),!(Zl.containsPoint(Vs.origin)===!1&&(Vs.intersectSphere(Zl,K0)===null||Vs.origin.distanceToSquared(K0)>(e.far-e.near)**2))&&(Y0.copy(r).invert(),Vs.copy(e.ray).applyMatrix4(Y0),!(n.boundingBox!==null&&Vs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Vs)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,f=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(o))for(let y=0,g=f.length;y<g;y++){let p=f[y],m=o[p.materialIndex],M=Math.max(p.start,d.start),b=Math.min(a.count,Math.min(p.start+p.count,d.start+d.count));for(let S=M,O=b;S<O;S+=3){let L=a.getX(S),R=a.getX(S+1),C=a.getX(S+2);s=tc(this,m,e,n,c,h,u,L,R,C),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let y=Math.max(0,d.start),g=Math.min(a.count,d.start+d.count);for(let p=y,m=g;p<m;p+=3){let M=a.getX(p),b=a.getX(p+1),S=a.getX(p+2);s=tc(this,o,e,n,c,h,u,M,b,S),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let y=0,g=f.length;y<g;y++){let p=f[y],m=o[p.materialIndex],M=Math.max(p.start,d.start),b=Math.min(l.count,Math.min(p.start+p.count,d.start+d.count));for(let S=M,O=b;S<O;S+=3){let L=S,R=S+1,C=S+2;s=tc(this,m,e,n,c,h,u,L,R,C),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let y=Math.max(0,d.start),g=Math.min(l.count,d.start+d.count);for(let p=y,m=g;p<m;p+=3){let M=p,b=p+1,S=p+2;s=tc(this,o,e,n,c,h,u,M,b,S),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}}};function sS(i,e,t,n,s,r,o,a){let l;if(e.side===mn?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,e.side===Si,a),l===null)return null;ec.copy(a),ec.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(ec);return c<t.near||c>t.far?null:{distance:c,point:ec.clone(),object:i}}function tc(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,$l),i.getVertexPosition(l,Jl),i.getVertexPosition(c,jl);let h=sS(i,e,t,n,$l,Jl,jl,Z0);if(h){let u=new F;On.getBarycoord(Z0,$l,Jl,jl,u),s&&(h.uv=On.getInterpolatedAttribute(s,a,l,c,u,new Ve)),r&&(h.uv1=On.getInterpolatedAttribute(r,a,l,c,u,new Ve)),o&&(h.normal=On.getInterpolatedAttribute(o,a,l,c,u,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new F,materialIndex:0};On.getNormal($l,Jl,jl,f.normal),h.face=f,h.barycoord=u}return h}var js=class extends yn{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],u=[],f=0,d=0;y("z","y","x",-1,-1,n,t,e,o,r,0),y("z","y","x",1,-1,n,t,-e,o,r,1),y("x","z","y",1,1,e,n,t,s,o,2),y("x","z","y",1,-1,e,n,-t,s,o,3),y("x","y","z",1,-1,e,t,n,s,r,4),y("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Xn(c,3)),this.setAttribute("normal",new Xn(h,3)),this.setAttribute("uv",new Xn(u,2));function y(g,p,m,M,b,S,O,L,R,C,j){let v=S/R,_=O/C,x=S/2,T=O/2,P=L/2,U=R+1,N=C+1,H=0,G=0,$=new F;for(let re=0;re<N;re++){let J=re*_-T;for(let V=0;V<U;V++){let xe=V*v-x;$[g]=xe*M,$[p]=J*b,$[m]=P,c.push($.x,$.y,$.z),$[g]=0,$[p]=0,$[m]=L>0?1:-1,h.push($.x,$.y,$.z),u.push(V/R),u.push(1-re/C),H+=1}}for(let re=0;re<C;re++)for(let J=0;J<R;J++){let V=f+J+U*re,xe=f+J+U*(re+1),X=f+(J+1)+U*(re+1),ne=f+(J+1)+U*re;l.push(V,xe,ne),l.push(xe,X,ne),G+=6}a.addGroup(d,G,j),d+=G,f+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new js(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function to(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function ln(i){let e={};for(let t=0;t<i.length;t++){let n=to(i[t]);for(let s in n)e[s]=n[s]}return e}function rS(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function s_(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:je.workingColorSpace}var oS={clone:to,merge:ln},aS=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,lS=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,Yn=class extends Fn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=aS,this.fragmentShader=lS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=to(e.uniforms),this.uniformsGroups=rS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},fs=class extends ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ie,this.projectionMatrix=new Ie,this.projectionMatrixInverse=new Ie,this.coordinateSystem=Di}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},ss=new F,$0=new Ve,J0=new Ve,kt=class extends fs{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Qr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ta*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Qr*2*Math.atan(Math.tan(ta*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ss.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ss.x,ss.y).multiplyScalar(-e/ss.z),ss.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ss.x,ss.y).multiplyScalar(-e/ss.z)}getViewSize(e,t){return this.getViewBounds(e,$0,J0),t.subVectors(J0,$0)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ta*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},kr=-90,zr=1,sd=class extends ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new kt(kr,zr,e,t);s.layers=this.layers,this.add(s);let r=new kt(kr,zr,e,t);r.layers=this.layers,this.add(r);let o=new kt(kr,zr,e,t);o.layers=this.layers,this.add(o);let a=new kt(kr,zr,e,t);a.layers=this.layers,this.add(a);let l=new kt(kr,zr,e,t);l.layers=this.layers,this.add(l);let c=new kt(kr,zr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===Di)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Mc)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,r),e.setRenderTarget(n,1,s),e.render(t,o),e.setRenderTarget(n,2,s),e.render(t,a),e.setRenderTarget(n,3,s),e.render(t,l),e.setRenderTarget(n,4,s),e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,s),e.render(t,h),e.setRenderTarget(u,f,d),e.xr.enabled=y,n.texture.needsPMREMUpdate=!0}},Ec=class extends vt{constructor(e,t,n,s,r,o,a,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:Zr,super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},rd=class extends Bi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Ec(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ot}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},s=new js(5,5,5),r=new Yn({name:"CubemapFromEquirect",uniforms:to(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:mn,blending:as});r.uniforms.tEquirect.value=t;let o=new St(s,r),a=t.minFilter;return t.minFilter===Wn&&(t.minFilter=Ot),new sd(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,s){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},rf=new F,cS=new F,hS=new ke,Oi=class{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=rf.subVectors(n,t).cross(cS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(rf),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||hS.getNormalMatrix(e),s=this.coplanarPoint(rf).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Hs=new Un,nc=new F,aa=class{constructor(e=new Oi,t=new Oi,n=new Oi,s=new Oi,r=new Oi,o=new Oi){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Di){let n=this.planes,s=e.elements,r=s[0],o=s[1],a=s[2],l=s[3],c=s[4],h=s[5],u=s[6],f=s[7],d=s[8],y=s[9],g=s[10],p=s[11],m=s[12],M=s[13],b=s[14],S=s[15];if(n[0].setComponents(l-r,f-c,p-d,S-m).normalize(),n[1].setComponents(l+r,f+c,p+d,S+m).normalize(),n[2].setComponents(l+o,f+h,p+y,S+M).normalize(),n[3].setComponents(l-o,f-h,p-y,S-M).normalize(),n[4].setComponents(l-a,f-u,p-g,S-b).normalize(),t===Di)n[5].setComponents(l+a,f+u,p+g,S+b).normalize();else if(t===Mc)n[5].setComponents(a,u,g,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hs)}intersectsSprite(e){return Hs.center.set(0,0,0),Hs.radius=.7071067811865476,Hs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hs)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(nc.x=s.normal.x>0?e.max.x:e.min.x,nc.y=s.normal.y>0?e.max.y:e.min.y,nc.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(nc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function r_(){let i=null,e=!1,t=null,n=null;function s(r,o){t(r,o),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function uS(i){let e=new WeakMap;function t(a,l){let c=a.array,h=a.usage,u=c.byteLength,f=i.createBuffer();i.bindBuffer(l,f),i.bufferData(l,c,h),a.onUploadCallback();let d;if(c instanceof Float32Array)d=i.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)d=i.SHORT;else if(c instanceof Uint32Array)d=i.UNSIGNED_INT;else if(c instanceof Int32Array)d=i.INT;else if(c instanceof Int8Array)d=i.BYTE;else if(c instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:d,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,l,c){let h=l.array,u=l.updateRanges;if(i.bindBuffer(c,a),u.length===0)i.bufferSubData(c,0,h);else{u.sort((d,y)=>d.start-y.start);let f=0;for(let d=1;d<u.length;d++){let y=u[f],g=u[d];g.start<=y.start+y.count+1?y.count=Math.max(y.count,g.start+g.count-y.start):(++f,u[f]=g)}u.length=f+1;for(let d=0,y=u.length;d<y;d++){let g=u[d];i.bufferSubData(c,g.start*h.BYTES_PER_ELEMENT,h,g.start,g.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(i.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var Kn=class extends yn{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(s),c=a+1,h=l+1,u=e/a,f=t/l,d=[],y=[],g=[],p=[];for(let m=0;m<h;m++){let M=m*f-o;for(let b=0;b<c;b++){let S=b*u-r;y.push(S,-M,0),g.push(0,0,1),p.push(b/a),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let M=0;M<a;M++){let b=M+c*m,S=M+c*(m+1),O=M+1+c*(m+1),L=M+1+c*m;d.push(b,S,L),d.push(S,O,L)}this.setIndex(d),this.setAttribute("position",new Xn(y,3)),this.setAttribute("normal",new Xn(g,3)),this.setAttribute("uv",new Xn(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kn(e.width,e.height,e.widthSegments,e.heightSegments)}},fS=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,dS=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,pS=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,mS=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,gS=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,yS=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,_S=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,vS=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,xS=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,bS=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,MS=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,SS=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,wS=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,AS=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,ES=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,TS=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,IS=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,RS=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,CS=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,LS=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,PS=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,NS=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,OS=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,DS=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,US=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,FS=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,BS=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,kS=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,zS=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,VS=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,HS="gl_FragColor = linearToOutputTexel( gl_FragColor );",GS=`
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
	vec3( 0.8224621, 0.177538, 0.0 ),
	vec3( 0.0331941, 0.9668058, 0.0 ),
	vec3( 0.0170827, 0.0723974, 0.9105199 )
);
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
	vec3( 1.2249401, - 0.2249404, 0.0 ),
	vec3( - 0.0420569, 1.0420571, 0.0 ),
	vec3( - 0.0196376, - 0.0786361, 1.0982735 )
);
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
	return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
}
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
	return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
}
vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return 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 );
}`,WS=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,XS=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,qS=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,YS=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,KS=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,ZS=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,$S=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,JS=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,jS=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,QS=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,ew=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,tw=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,nw=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,iw=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,sw=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,rw=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,ow=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,aw=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,lw=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,cw=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,hw=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,uw=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,fw=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,dw=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,pw=`#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,mw=`#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,gw=`#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,yw=`#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,_w=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,vw=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,xw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,bw=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,Mw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,Sw=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,ww=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,Aw=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,Ew=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,Tw=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,Iw=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,Rw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,Cw=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,Lw=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,Pw=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,Nw=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,Ow=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,Dw=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,Uw=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,Fw=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,Bw=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,kw=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,zw=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,Vw=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Hw=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,Gw=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Ww=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,Xw=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,qw=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,Yw=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,Kw=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,Zw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,$w=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,Jw=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,jw=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,Qw=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,eA=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,tA=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,nA=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,iA=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,sA=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,rA=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,oA=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
		
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
		
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		
		#else
		
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,aA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,lA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,cA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,hA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,uA=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,fA=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,dA=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,pA=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,mA=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,gA=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,yA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,_A=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,vA=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,xA=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,bA=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,MA=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,SA=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,wA=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,AA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,EA=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,TA=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,IA=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,RA=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,CA=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,LA=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,PA=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,NA=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,OA=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,DA=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,UA=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,FA=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,BA=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,kA=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,zA=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,VA=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,HA=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,GA=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,WA=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,ze={alphahash_fragment:fS,alphahash_pars_fragment:dS,alphamap_fragment:pS,alphamap_pars_fragment:mS,alphatest_fragment:gS,alphatest_pars_fragment:yS,aomap_fragment:_S,aomap_pars_fragment:vS,batching_pars_vertex:xS,batching_vertex:bS,begin_vertex:MS,beginnormal_vertex:SS,bsdfs:wS,iridescence_fragment:AS,bumpmap_pars_fragment:ES,clipping_planes_fragment:TS,clipping_planes_pars_fragment:IS,clipping_planes_pars_vertex:RS,clipping_planes_vertex:CS,color_fragment:LS,color_pars_fragment:PS,color_pars_vertex:NS,color_vertex:OS,common:DS,cube_uv_reflection_fragment:US,defaultnormal_vertex:FS,displacementmap_pars_vertex:BS,displacementmap_vertex:kS,emissivemap_fragment:zS,emissivemap_pars_fragment:VS,colorspace_fragment:HS,colorspace_pars_fragment:GS,envmap_fragment:WS,envmap_common_pars_fragment:XS,envmap_pars_fragment:qS,envmap_pars_vertex:YS,envmap_physical_pars_fragment:sw,envmap_vertex:KS,fog_vertex:ZS,fog_pars_vertex:$S,fog_fragment:JS,fog_pars_fragment:jS,gradientmap_pars_fragment:QS,lightmap_pars_fragment:ew,lights_lambert_fragment:tw,lights_lambert_pars_fragment:nw,lights_pars_begin:iw,lights_toon_fragment:rw,lights_toon_pars_fragment:ow,lights_phong_fragment:aw,lights_phong_pars_fragment:lw,lights_physical_fragment:cw,lights_physical_pars_fragment:hw,lights_fragment_begin:uw,lights_fragment_maps:fw,lights_fragment_end:dw,logdepthbuf_fragment:pw,logdepthbuf_pars_fragment:mw,logdepthbuf_pars_vertex:gw,logdepthbuf_vertex:yw,map_fragment:_w,map_pars_fragment:vw,map_particle_fragment:xw,map_particle_pars_fragment:bw,metalnessmap_fragment:Mw,metalnessmap_pars_fragment:Sw,morphinstance_vertex:ww,morphcolor_vertex:Aw,morphnormal_vertex:Ew,morphtarget_pars_vertex:Tw,morphtarget_vertex:Iw,normal_fragment_begin:Rw,normal_fragment_maps:Cw,normal_pars_fragment:Lw,normal_pars_vertex:Pw,normal_vertex:Nw,normalmap_pars_fragment:Ow,clearcoat_normal_fragment_begin:Dw,clearcoat_normal_fragment_maps:Uw,clearcoat_pars_fragment:Fw,iridescence_pars_fragment:Bw,opaque_fragment:kw,packing:zw,premultiplied_alpha_fragment:Vw,project_vertex:Hw,dithering_fragment:Gw,dithering_pars_fragment:Ww,roughnessmap_fragment:Xw,roughnessmap_pars_fragment:qw,shadowmap_pars_fragment:Yw,shadowmap_pars_vertex:Kw,shadowmap_vertex:Zw,shadowmask_pars_fragment:$w,skinbase_vertex:Jw,skinning_pars_vertex:jw,skinning_vertex:Qw,skinnormal_vertex:eA,specularmap_fragment:tA,specularmap_pars_fragment:nA,tonemapping_fragment:iA,tonemapping_pars_fragment:sA,transmission_fragment:rA,transmission_pars_fragment:oA,uv_pars_fragment:aA,uv_pars_vertex:lA,uv_vertex:cA,worldpos_vertex:hA,background_vert:uA,background_frag:fA,backgroundCube_vert:dA,backgroundCube_frag:pA,cube_vert:mA,cube_frag:gA,depth_vert:yA,depth_frag:_A,distanceRGBA_vert:vA,distanceRGBA_frag:xA,equirect_vert:bA,equirect_frag:MA,linedashed_vert:SA,linedashed_frag:wA,meshbasic_vert:AA,meshbasic_frag:EA,meshlambert_vert:TA,meshlambert_frag:IA,meshmatcap_vert:RA,meshmatcap_frag:CA,meshnormal_vert:LA,meshnormal_frag:PA,meshphong_vert:NA,meshphong_frag:OA,meshphysical_vert:DA,meshphysical_frag:UA,meshtoon_vert:FA,meshtoon_frag:BA,points_vert:kA,points_frag:zA,shadow_vert:VA,shadow_frag:HA,sprite_vert:GA,sprite_frag:WA},he={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Re(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},xi={basic:{uniforms:ln([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:ln([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Re(0)}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:ln([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:ln([he.common,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.roughnessmap,he.metalnessmap,he.fog,he.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:ln([he.common,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.gradientmap,he.fog,he.lights,{emissive:{value:new Re(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:ln([he.common,he.bumpmap,he.normalmap,he.displacementmap,he.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:ln([he.points,he.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:ln([he.common,he.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:ln([he.common,he.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:ln([he.common,he.bumpmap,he.normalmap,he.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:ln([he.sprite,he.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distanceRGBA:{uniforms:ln([he.common,he.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distanceRGBA_vert,fragmentShader:ze.distanceRGBA_frag},shadow:{uniforms:ln([he.lights,he.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};xi.physical={uniforms:ln([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new Re(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};var ic={r:0,b:0,g:0},Gs=new on,XA=new Ie;function qA(i,e,t,n,s,r,o){let a=new Re(0),l=r===!0?0:1,c,h,u=null,f=0,d=null;function y(M){let b=M.isScene===!0?M.background:null;return b&&b.isTexture&&(b=(M.backgroundBlurriness>0?t:e).get(b)),b}function g(M){let b=!1,S=y(M);S===null?m(a,l):S&&S.isColor&&(m(S,1),b=!0);let O=i.xr.getEnvironmentBlendMode();O==="additive"?n.buffers.color.setClear(0,0,0,1,o):O==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||b)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(M,b){let S=y(b);S&&(S.isCubeTexture||S.mapping===qc)?(h===void 0&&(h=new St(new js(1,1,1),new Yn({name:"BackgroundCubeMaterial",uniforms:to(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:mn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(O,L,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),Gs.copy(b.backgroundRotation),Gs.x*=-1,Gs.y*=-1,Gs.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Gs.y*=-1,Gs.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(XA.makeRotationFromEuler(Gs)),h.material.toneMapped=je.getTransfer(S.colorSpace)!==_t,(u!==S||f!==S.version||d!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,f=S.version,d=i.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new St(new Kn(2,2),new Yn({name:"BackgroundMaterial",uniforms:to(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:Si,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.toneMapped=je.getTransfer(S.colorSpace)!==_t,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||f!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,f=S.version,d=i.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function m(M,b){M.getRGB(ic,s_(i)),n.buffers.color.setClear(ic.r,ic.g,ic.b,b,o)}return{getClearColor:function(){return a},setClearColor:function(M,b=1){a.set(M),l=b,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(M){l=M,m(a,l)},render:g,addToRenderList:p}}function YA(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=f(null),r=s,o=!1;function a(v,_,x,T,P){let U=!1,N=u(T,x,_);r!==N&&(r=N,c(r.object)),U=d(v,T,x,P),U&&y(v,T,x,P),P!==null&&e.update(P,i.ELEMENT_ARRAY_BUFFER),(U||o)&&(o=!1,S(v,_,x,T),P!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return i.createVertexArray()}function c(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,_,x){let T=x.wireframe===!0,P=n[v.id];P===void 0&&(P={},n[v.id]=P);let U=P[_.id];U===void 0&&(U={},P[_.id]=U);let N=U[T];return N===void 0&&(N=f(l()),U[T]=N),N}function f(v){let _=[],x=[],T=[];for(let P=0;P<t;P++)_[P]=0,x[P]=0,T[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:_,enabledAttributes:x,attributeDivisors:T,object:v,attributes:{},index:null}}function d(v,_,x,T){let P=r.attributes,U=_.attributes,N=0,H=x.getAttributes();for(let G in H)if(H[G].location>=0){let re=P[G],J=U[G];if(J===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(J=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(J=v.instanceColor)),re===void 0||re.attribute!==J||J&&re.data!==J.data)return!0;N++}return r.attributesNum!==N||r.index!==T}function y(v,_,x,T){let P={},U=_.attributes,N=0,H=x.getAttributes();for(let G in H)if(H[G].location>=0){let re=U[G];re===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(re=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(re=v.instanceColor));let J={};J.attribute=re,re&&re.data&&(J.data=re.data),P[G]=J,N++}r.attributes=P,r.attributesNum=N,r.index=T}function g(){let v=r.newAttributes;for(let _=0,x=v.length;_<x;_++)v[_]=0}function p(v){m(v,0)}function m(v,_){let x=r.newAttributes,T=r.enabledAttributes,P=r.attributeDivisors;x[v]=1,T[v]===0&&(i.enableVertexAttribArray(v),T[v]=1),P[v]!==_&&(i.vertexAttribDivisor(v,_),P[v]=_)}function M(){let v=r.newAttributes,_=r.enabledAttributes;for(let x=0,T=_.length;x<T;x++)_[x]!==v[x]&&(i.disableVertexAttribArray(x),_[x]=0)}function b(v,_,x,T,P,U,N){N===!0?i.vertexAttribIPointer(v,_,x,P,U):i.vertexAttribPointer(v,_,x,T,P,U)}function S(v,_,x,T){g();let P=T.attributes,U=x.getAttributes(),N=_.defaultAttributeValues;for(let H in U){let G=U[H];if(G.location>=0){let $=P[H];if($===void 0&&(H==="instanceMatrix"&&v.instanceMatrix&&($=v.instanceMatrix),H==="instanceColor"&&v.instanceColor&&($=v.instanceColor)),$!==void 0){let re=$.normalized,J=$.itemSize,V=e.get($);if(V===void 0)continue;let xe=V.buffer,X=V.type,ne=V.bytesPerElement,oe=X===i.INT||X===i.UNSIGNED_INT||$.gpuType===Cd;if($.isInterleavedBufferAttribute){let ge=$.data,Fe=ge.stride,Le=$.offset;if(ge.isInstancedInterleavedBuffer){for(let Ze=0;Ze<G.locationSize;Ze++)m(G.location+Ze,ge.meshPerAttribute);v.isInstancedMesh!==!0&&T._maxInstanceCount===void 0&&(T._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Ze=0;Ze<G.locationSize;Ze++)p(G.location+Ze);i.bindBuffer(i.ARRAY_BUFFER,xe);for(let Ze=0;Ze<G.locationSize;Ze++)b(G.location+Ze,J/G.locationSize,X,re,Fe*ne,(Le+J/G.locationSize*Ze)*ne,oe)}else{if($.isInstancedBufferAttribute){for(let ge=0;ge<G.locationSize;ge++)m(G.location+ge,$.meshPerAttribute);v.isInstancedMesh!==!0&&T._maxInstanceCount===void 0&&(T._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let ge=0;ge<G.locationSize;ge++)p(G.location+ge);i.bindBuffer(i.ARRAY_BUFFER,xe);for(let ge=0;ge<G.locationSize;ge++)b(G.location+ge,J/G.locationSize,X,re,J*ne,J/G.locationSize*ge*ne,oe)}}else if(N!==void 0){let re=N[H];if(re!==void 0)switch(re.length){case 2:i.vertexAttrib2fv(G.location,re);break;case 3:i.vertexAttrib3fv(G.location,re);break;case 4:i.vertexAttrib4fv(G.location,re);break;default:i.vertexAttrib1fv(G.location,re)}}}}M()}function O(){C();for(let v in n){let _=n[v];for(let x in _){let T=_[x];for(let P in T)h(T[P].object),delete T[P];delete _[x]}delete n[v]}}function L(v){if(n[v.id]===void 0)return;let _=n[v.id];for(let x in _){let T=_[x];for(let P in T)h(T[P].object),delete T[P];delete _[x]}delete n[v.id]}function R(v){for(let _ in n){let x=n[_];if(x[v.id]===void 0)continue;let T=x[v.id];for(let P in T)h(T[P].object),delete T[P];delete x[v.id]}}function C(){j(),o=!0,r!==s&&(r=s,c(r.object))}function j(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:C,resetDefaultState:j,dispose:O,releaseStatesOfGeometry:L,releaseStatesOfProgram:R,initAttributes:g,enableAttribute:p,disableUnusedAttributes:M}}function KA(i,e,t){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function o(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),t.update(h,n,u))}function a(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let d=0;for(let y=0;y<u;y++)d+=h[y];t.update(d,n,1)}function l(c,h,u,f){if(u===0)return;let d=e.get("WEBGL_multi_draw");if(d===null)for(let y=0;y<c.length;y++)o(c[y],h[y],f[y]);else{d.multiDrawArraysInstancedWEBGL(n,c,0,h,0,f,0,u);let y=0;for(let g=0;g<u;g++)y+=h[g];for(let g=0;g<f.length;g++)t.update(y,n,f[g])}}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function ZA(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let R=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(R){return!(R!==pn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(R){let C=R===ga&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Fi&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==ci&&!C)}function l(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let u=t.logarithmicDepthBuffer===!0,f=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(f===!0){let R=e.get("EXT_clip_control");R.clipControlEXT(R.LOWER_LEFT_EXT,R.ZERO_TO_ONE_EXT)}let d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),M=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),O=y>0,L=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:y,maxTextureSize:g,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:M,maxVaryings:b,maxFragmentUniforms:S,vertexTextures:O,maxSamples:L}}function $A(i){let e=this,t=null,n=0,s=!1,r=!1,o=new Oi,a=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){let d=u.length!==0||f||n!==0||s;return s=f,n=u.length,d},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){let y=u.clippingPlanes,g=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||y===null||y.length===0||r&&!p)r?h(null):c();else{let M=r?0:n,b=M*4,S=m.clippingState||null;l.value=S,S=h(y,f,b,d);for(let O=0;O!==b;++O)S[O]=t[O];m.clippingState=S,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,y){let g=u!==null?u.length:0,p=null;if(g!==0){if(p=l.value,y!==!0||p===null){let m=d+g*4,M=f.matrixWorldInverse;a.getNormalMatrix(M),(p===null||p.length<m)&&(p=new Float32Array(m));for(let b=0,S=d;b!==g;++b,S+=4)o.copy(u[b]).applyMatrix4(M,a),o.normal.toArray(p,S),p[S+3]=o.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,p}}function JA(i){let e=new WeakMap;function t(o,a){return a===Ef?o.mapping=Zr:a===Tf&&(o.mapping=$r),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Ef||a===Tf)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new rd(l.height);return c.fromEquirectangularTexture(i,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){let a=o.target;a.removeEventListener("dispose",s);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}var no=class extends fs{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Gr=4,j0=[.125,.215,.35,.446,.526,.582],Ys=20,of=new no,Q0=new Re,af=null,lf=0,cf=0,hf=!1,Xs=(1+Math.sqrt(5))/2,Vr=1/Xs,ey=[new F(-Xs,Vr,0),new F(Xs,Vr,0),new F(-Vr,0,Xs),new F(Vr,0,Xs),new F(0,Xs,-Vr),new F(0,Xs,Vr),new F(-1,1,-1),new F(1,1,-1),new F(-1,1,1),new F(1,1,1)],Tc=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,s=100){af=this._renderer.getRenderTarget(),lf=this._renderer.getActiveCubeFace(),cf=this._renderer.getActiveMipmapLevel(),hf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=iy(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ny(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(af,lf,cf),this._renderer.xr.enabled=hf,e.scissorTest=!1,sc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Zr||e.mapping===$r?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),af=this._renderer.getRenderTarget(),lf=this._renderer.getActiveCubeFace(),cf=this._renderer.getActiveMipmapLevel(),hf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ot,minFilter:Ot,generateMipmaps:!1,type:ga,format:pn,colorSpace:qt,depthBuffer:!1},s=ty(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ty(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=jA(r)),this._blurMaterial=QA(r,e,t)}return s}_compileMaterial(e){let t=new St(this._lodPlanes[0],e);this._renderer.compile(t,of)}_sceneToCubeUV(e,t,n,s){let a=new kt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Q0),h.toneMapping=ls,h.autoClear=!1;let d=new gn({name:"PMREM.Background",side:mn,depthWrite:!1,depthTest:!1}),y=new St(new js,d),g=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,g=!0):(d.color.copy(Q0),g=!0);for(let m=0;m<6;m++){let M=m%3;M===0?(a.up.set(0,l[m],0),a.lookAt(c[m],0,0)):M===1?(a.up.set(0,0,l[m]),a.lookAt(0,c[m],0)):(a.up.set(0,l[m],0),a.lookAt(0,0,c[m]));let b=this._cubeSize;sc(s,M*b,m>2?b:0,b,b),h.setRenderTarget(s),g&&h.render(y,a),h.render(e,a)}y.geometry.dispose(),y.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===Zr||e.mapping===$r;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=iy()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ny());let r=s?this._cubemapMaterial:this._equirectMaterial,o=new St(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;sc(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,of)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodPlanes.length;for(let r=1;r<s;r++){let o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=ey[(s-r-1)%ey.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new St(this._lodPlanes[s],c),f=c.uniforms,d=this._sizeLods[n]-1,y=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*Ys-1),g=r/y,p=isFinite(r)?1+Math.floor(h*g):Ys;p>Ys&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Ys}`);let m=[],M=0;for(let R=0;R<Ys;++R){let C=R/g,j=Math.exp(-C*C/2);m.push(j),R===0?M+=j:R<p&&(M+=2*j)}for(let R=0;R<m.length;R++)m[R]=m[R]/M;f.envMap.value=e.texture,f.samples.value=p,f.weights.value=m,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:b}=this;f.dTheta.value=y,f.mipInt.value=b-n;let S=this._sizeLods[s],O=3*S*(s>b-Gr?s-b+Gr:0),L=4*(this._cubeSize-S);sc(t,O,L,3*S,2*S),l.setRenderTarget(t),l.render(u,of)}};function jA(i){let e=[],t=[],n=[],s=i,r=i-Gr+1+j0.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);t.push(a);let l=1/a;o>i-Gr?l=j0[o-i+Gr-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),h=-c,u=1+c,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,y=6,g=3,p=2,m=1,M=new Float32Array(g*y*d),b=new Float32Array(p*y*d),S=new Float32Array(m*y*d);for(let L=0;L<d;L++){let R=L%3*2/3-1,C=L>2?0:-1,j=[R,C,0,R+2/3,C,0,R+2/3,C+1,0,R,C,0,R+2/3,C+1,0,R,C+1,0];M.set(j,g*y*L),b.set(f,p*y*L);let v=[L,L,L,L,L,L];S.set(v,m*y*L)}let O=new yn;O.setAttribute("position",new ft(M,g)),O.setAttribute("uv",new ft(b,p)),O.setAttribute("faceIndex",new ft(S,m)),e.push(O),s>Gr&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function ty(i,e,t){let n=new Bi(i,e,t);return n.texture.mapping=qc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function sc(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function QA(i,e,t){let n=new Float32Array(Ys),s=new F(0,1,0);return new Yn({name:"SphericalGaussianBlur",defines:{n:Ys,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:kd(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:as,depthTest:!1,depthWrite:!1})}function ny(){return new Yn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:kd(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:as,depthTest:!1,depthWrite:!1})}function iy(){return new Yn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:kd(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:as,depthTest:!1,depthWrite:!1})}function kd(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function e1(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===Ef||l===Tf,h=l===Zr||l===$r;if(c||h){let u=e.get(a),f=u!==void 0?u.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return t===null&&(t=new Tc(i)),u=c?t.fromEquirectangular(a,u):t.fromCubemap(a,u),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),u.texture;if(u!==void 0)return u.texture;{let d=a.image;return c&&d&&d.height>0||h&&d&&s(d)?(t===null&&(t=new Tc(i)),u=c?t.fromEquirectangular(a):t.fromCubemap(a),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),a.addEventListener("dispose",r),u.texture):null}}}return a}function s(a){let l=0,c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function r(a){let l=a.target;l.removeEventListener("dispose",r);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function t1(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&_c("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function n1(i,e,t,n){let s={},r=new WeakMap;function o(u){let f=u.target;f.index!==null&&e.remove(f.index);for(let y in f.attributes)e.remove(f.attributes[y]);for(let y in f.morphAttributes){let g=f.morphAttributes[y];for(let p=0,m=g.length;p<m;p++)e.remove(g[p])}f.removeEventListener("dispose",o),delete s[f.id];let d=r.get(f);d&&(e.remove(d),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(u,f){return s[f.id]===!0||(f.addEventListener("dispose",o),s[f.id]=!0,t.memory.geometries++),f}function l(u){let f=u.attributes;for(let y in f)e.update(f[y],i.ARRAY_BUFFER);let d=u.morphAttributes;for(let y in d){let g=d[y];for(let p=0,m=g.length;p<m;p++)e.update(g[p],i.ARRAY_BUFFER)}}function c(u){let f=[],d=u.index,y=u.attributes.position,g=0;if(d!==null){let M=d.array;g=d.version;for(let b=0,S=M.length;b<S;b+=3){let O=M[b+0],L=M[b+1],R=M[b+2];f.push(O,L,L,R,R,O)}}else if(y!==void 0){let M=y.array;g=y.version;for(let b=0,S=M.length/3-1;b<S;b+=3){let O=b+0,L=b+1,R=b+2;f.push(O,L,L,R,R,O)}}else return;let p=new(n_(f)?Ac:wc)(f,1);p.version=g;let m=r.get(u);m&&e.remove(m),r.set(u,p)}function h(u){let f=r.get(u);if(f){let d=u.index;d!==null&&f.version<d.version&&c(u)}else c(u);return r.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function i1(i,e,t){let n;function s(f){n=f}let r,o;function a(f){r=f.type,o=f.bytesPerElement}function l(f,d){i.drawElements(n,d,r,f*o),t.update(d,n,1)}function c(f,d,y){y!==0&&(i.drawElementsInstanced(n,d,r,f*o,y),t.update(d,n,y))}function h(f,d,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,f,0,y);let p=0;for(let m=0;m<y;m++)p+=d[m];t.update(p,n,1)}function u(f,d,y,g){if(y===0)return;let p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<f.length;m++)c(f[m]/o,d[m],g[m]);else{p.multiDrawElementsInstancedWEBGL(n,d,0,r,f,0,g,0,y);let m=0;for(let M=0;M<y;M++)m+=d[M];for(let M=0;M<g.length;M++)t.update(m,n,g[M])}}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function s1(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function r1(i,e,t){let n=new WeakMap,s=new Qe;function r(o,a,l){let c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,f=n.get(a);if(f===void 0||f.count!==u){let j=function(){R.dispose(),n.delete(a),a.removeEventListener("dispose",j)};f!==void 0&&f.texture.dispose();let d=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],M=a.morphAttributes.color||[],b=0;d===!0&&(b=1),y===!0&&(b=2),g===!0&&(b=3);let S=a.attributes.position.count*b,O=1;S>e.maxTextureSize&&(O=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let L=new Float32Array(S*O*4*u),R=new Sc(L,S,O,u);R.type=ci,R.needsUpdate=!0;let C=b*4;for(let v=0;v<u;v++){let _=p[v],x=m[v],T=M[v],P=S*O*4*v;for(let U=0;U<_.count;U++){let N=U*C;d===!0&&(s.fromBufferAttribute(_,U),L[P+N+0]=s.x,L[P+N+1]=s.y,L[P+N+2]=s.z,L[P+N+3]=0),y===!0&&(s.fromBufferAttribute(x,U),L[P+N+4]=s.x,L[P+N+5]=s.y,L[P+N+6]=s.z,L[P+N+7]=0),g===!0&&(s.fromBufferAttribute(T,U),L[P+N+8]=s.x,L[P+N+9]=s.y,L[P+N+10]=s.z,L[P+N+11]=T.itemSize===4?s.w:1)}}f={count:u,texture:R,size:new Ve(S,O)},n.set(a,f),a.addEventListener("dispose",j)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let d=0;for(let g=0;g<c.length;g++)d+=c[g];let y=a.morphTargetsRelative?1:1-d;l.getUniforms().setValue(i,"morphTargetBaseInfluence",y),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:r}}function o1(i,e,t,n){let s=new WeakMap;function r(l){let c=n.render.frame,h=l.geometry,u=e.get(l,h);if(s.get(u)!==c&&(e.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),s.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){let f=l.skeleton;s.get(f)!==c&&(f.update(),s.set(f,c))}return u}function o(){s=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}var Ic=class extends vt{constructor(e,t,n,s,r,o,a,l,c,h=Xr){if(h!==Xr&&h!==jr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Xr&&(n=$s),n===void 0&&h===jr&&(n=Jr),super(null,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Xt,this.minFilter=l!==void 0?l:Xt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},o_=new vt,sy=new Ic(1,1),a_=new Sc,l_=new id,c_=new Ec,ry=[],oy=[],ay=new Float32Array(16),ly=new Float32Array(9),cy=new Float32Array(4);function ho(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=ry[s];if(r===void 0&&(r=new Float32Array(s),ry[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function zt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Vt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Zc(i,e){let t=oy[e];t===void 0&&(t=new Int32Array(e),oy[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function a1(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function l1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;i.uniform2fv(this.addr,e),Vt(t,e)}}function c1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(zt(t,e))return;i.uniform3fv(this.addr,e),Vt(t,e)}}function h1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;i.uniform4fv(this.addr,e),Vt(t,e)}}function u1(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;cy.set(n),i.uniformMatrix2fv(this.addr,!1,cy),Vt(t,n)}}function f1(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;ly.set(n),i.uniformMatrix3fv(this.addr,!1,ly),Vt(t,n)}}function d1(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;ay.set(n),i.uniformMatrix4fv(this.addr,!1,ay),Vt(t,n)}}function p1(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function m1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;i.uniform2iv(this.addr,e),Vt(t,e)}}function g1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(zt(t,e))return;i.uniform3iv(this.addr,e),Vt(t,e)}}function y1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;i.uniform4iv(this.addr,e),Vt(t,e)}}function _1(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function v1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;i.uniform2uiv(this.addr,e),Vt(t,e)}}function x1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(zt(t,e))return;i.uniform3uiv(this.addr,e),Vt(t,e)}}function b1(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;i.uniform4uiv(this.addr,e),Vt(t,e)}}function M1(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(sy.compareFunction=t_,r=sy):r=o_,t.setTexture2D(e||r,s)}function S1(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||l_,s)}function w1(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||c_,s)}function A1(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||a_,s)}function E1(i){switch(i){case 5126:return a1;case 35664:return l1;case 35665:return c1;case 35666:return h1;case 35674:return u1;case 35675:return f1;case 35676:return d1;case 5124:case 35670:return p1;case 35667:case 35671:return m1;case 35668:case 35672:return g1;case 35669:case 35673:return y1;case 5125:return _1;case 36294:return v1;case 36295:return x1;case 36296:return b1;case 35678:case 36198:case 36298:case 36306:case 35682:return M1;case 35679:case 36299:case 36307:return S1;case 35680:case 36300:case 36308:case 36293:return w1;case 36289:case 36303:case 36311:case 36292:return A1}}function T1(i,e){i.uniform1fv(this.addr,e)}function I1(i,e){let t=ho(e,this.size,2);i.uniform2fv(this.addr,t)}function R1(i,e){let t=ho(e,this.size,3);i.uniform3fv(this.addr,t)}function C1(i,e){let t=ho(e,this.size,4);i.uniform4fv(this.addr,t)}function L1(i,e){let t=ho(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function P1(i,e){let t=ho(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function N1(i,e){let t=ho(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function O1(i,e){i.uniform1iv(this.addr,e)}function D1(i,e){i.uniform2iv(this.addr,e)}function U1(i,e){i.uniform3iv(this.addr,e)}function F1(i,e){i.uniform4iv(this.addr,e)}function B1(i,e){i.uniform1uiv(this.addr,e)}function k1(i,e){i.uniform2uiv(this.addr,e)}function z1(i,e){i.uniform3uiv(this.addr,e)}function V1(i,e){i.uniform4uiv(this.addr,e)}function H1(i,e,t){let n=this.cache,s=e.length,r=Zc(t,s);zt(n,r)||(i.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||o_,r[o])}function G1(i,e,t){let n=this.cache,s=e.length,r=Zc(t,s);zt(n,r)||(i.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||l_,r[o])}function W1(i,e,t){let n=this.cache,s=e.length,r=Zc(t,s);zt(n,r)||(i.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||c_,r[o])}function X1(i,e,t){let n=this.cache,s=e.length,r=Zc(t,s);zt(n,r)||(i.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||a_,r[o])}function q1(i){switch(i){case 5126:return T1;case 35664:return I1;case 35665:return R1;case 35666:return C1;case 35674:return L1;case 35675:return P1;case 35676:return N1;case 5124:case 35670:return O1;case 35667:case 35671:return D1;case 35668:case 35672:return U1;case 35669:case 35673:return F1;case 5125:return B1;case 36294:return k1;case 36295:return z1;case 36296:return V1;case 35678:case 36198:case 36298:case 36306:case 35682:return H1;case 35679:case 36299:case 36307:return G1;case 35680:case 36300:case 36308:case 36293:return W1;case 36289:case 36303:case 36311:case 36292:return X1}}var od=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=E1(t.type)}},ad=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=q1(t.type)}},ld=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},uf=/(\w+)(\])?(\[|\.)?/g;function hy(i,e){i.seq.push(e),i.map[e.id]=e}function Y1(i,e,t){let n=i.name,s=n.length;for(uf.lastIndex=0;;){let r=uf.exec(n),o=uf.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){hy(t,c===void 0?new od(a,i,e):new ad(a,i,e));break}else{let u=t.map[a];u===void 0&&(u=new ld(a),hy(t,u)),t=u}}}var Yr=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);Y1(r,o,this)}}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function uy(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var K1=37297,Z1=0;function $1(i,e){let t=i.split(`
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
`)}function J1(i){let e=je.getPrimaries(je.workingColorSpace),t=je.getPrimaries(i),n;switch(e===t?n="":e===bc&&t===xc?n="LinearDisplayP3ToLinearSRGB":e===xc&&t===bc&&(n="LinearSRGBToLinearDisplayP3"),i){case qt:case Kc:return[n,"LinearTransferOETF"];case Nt:case Fd:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function fy(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=i.getShaderInfoLog(e).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\d+)/.exec(s);if(r){let o=parseInt(r[1]);return t.toUpperCase()+`

`+s+`

`+$1(i.getShaderSource(e),o)}else return s}function j1(i,e){let t=J1(e);return`vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function Q1(i,e){let t;switch(e){case aM:t="Linear";break;case lM:t="Reinhard";break;case cM:t="Cineon";break;case hM:t="ACESFilmic";break;case fM:t="AgX";break;case dM:t="Neutral";break;case uM:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var rc=new F;function eE(){je.getLuminanceCoefficients(rc);let i=rc.x.toFixed(4),e=rc.y.toFixed(4),t=rc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${i}, ${e}, ${t} );`,"	return dot( weights, rgb );","}"].join(`
`)}function tE(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ea).join(`
`)}function nE(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function iE(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function ea(i){return i!==""}function dy(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).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_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function py(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var sE=/^[ \t]*#include +<([\w\d./]+)>/gm;function cd(i){return i.replace(sE,oE)}var rE=new Map;function oE(i,e){let t=ze[e];if(t===void 0){let n=rE.get(e);if(n!==void 0)t=ze[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return cd(t)}var aE=/#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 my(i){return i.replace(aE,lE)}function lE(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function gy(i){let e=`precision ${i.precision} float;
	precision ${i.precision} int;
	precision ${i.precision} sampler2D;
	precision ${i.precision} samplerCube;
	precision ${i.precision} sampler3D;
	precision ${i.precision} sampler2DArray;
	precision ${i.precision} sampler2DShadow;
	precision ${i.precision} samplerCubeShadow;
	precision ${i.precision} sampler2DArrayShadow;
	precision ${i.precision} isampler2D;
	precision ${i.precision} isampler3D;
	precision ${i.precision} isamplerCube;
	precision ${i.precision} isampler2DArray;
	precision ${i.precision} usampler2D;
	precision ${i.precision} usampler3D;
	precision ${i.precision} usamplerCube;
	precision ${i.precision} usampler2DArray;
	`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function cE(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Vy?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===zb?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Ni&&(e="SHADOWMAP_TYPE_VSM"),e}function hE(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Zr:case $r:e="ENVMAP_TYPE_CUBE";break;case qc:e="ENVMAP_TYPE_CUBE_UV";break}return e}function uE(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case $r:e="ENVMAP_MODE_REFRACTION";break}return e}function fE(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Hy:e="ENVMAP_BLENDING_MULTIPLY";break;case rM:e="ENVMAP_BLENDING_MIX";break;case oM:e="ENVMAP_BLENDING_ADD";break}return e}function dE(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function pE(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=cE(t),c=hE(t),h=uE(t),u=fE(t),f=dE(t),d=tE(t),y=nE(r),g=s.createProgram(),p,m,M=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(ea).join(`
`),p.length>0&&(p+=`
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(ea).join(`
`),m.length>0&&(m+=`
`)):(p=[gy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","	uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","	attribute vec2 uv1;","#endif","#ifdef USE_UV2","	attribute vec2 uv2;","#endif","#ifdef USE_UV3","	attribute vec2 uv3;","#endif","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(ea).join(`
`),m=[gy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ls?"#define TONE_MAPPING":"",t.toneMapping!==ls?ze.tonemapping_pars_fragment:"",t.toneMapping!==ls?Q1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,j1("linearToOutputTexel",t.outputColorSpace),eE(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(ea).join(`
`)),o=cd(o),o=dy(o,t),o=py(o,t),a=cd(a),a=dy(a,t),a=py(a,t),o=my(o),a=my(a),t.isRawShaderMaterial!==!0&&(M=`#version 300 es
`,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+p,m=["#define varying in",t.glslVersion===N0?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===N0?"":"#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(`
`)+`
`+m);let b=M+p+o,S=M+m+a,O=uy(s,s.VERTEX_SHADER,b),L=uy(s,s.FRAGMENT_SHADER,S);s.attachShader(g,O),s.attachShader(g,L),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function R(_){if(i.debug.checkShaderErrors){let x=s.getProgramInfoLog(g).trim(),T=s.getShaderInfoLog(O).trim(),P=s.getShaderInfoLog(L).trim(),U=!0,N=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(U=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,g,O,L);else{let H=fy(s,O,"vertex"),G=fy(s,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+`

Material Name: `+_.name+`
Material Type: `+_.type+`

Program Info Log: `+x+`
`+H+`
`+G)}else x!==""?console.warn("THREE.WebGLProgram: Program Info Log:",x):(T===""||P==="")&&(N=!1);N&&(_.diagnostics={runnable:U,programLog:x,vertexShader:{log:T,prefix:p},fragmentShader:{log:P,prefix:m}})}s.deleteShader(O),s.deleteShader(L),C=new Yr(s,g),j=iE(s,g)}let C;this.getUniforms=function(){return C===void 0&&R(this),C};let j;this.getAttributes=function(){return j===void 0&&R(this),j};let v=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(g,K1)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Z1++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=O,this.fragmentShader=L,this}var mE=0,hd=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new ud(e),t.set(e,n)),n}},ud=class{constructor(e){this.id=mE++,this.code=e,this.usedTimes=0}};function gE(i,e,t,n,s,r,o){let a=new oa,l=new hd,c=new Set,h=[],u=s.logarithmicDepthBuffer,f=s.reverseDepthBuffer,d=s.vertexTextures,y=s.precision,g={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"};function p(v){return c.add(v),v===0?"uv":`uv${v}`}function m(v,_,x,T,P){let U=T.fog,N=P.geometry,H=v.isMeshStandardMaterial?T.environment:null,G=(v.isMeshStandardMaterial?t:e).get(v.envMap||H),$=!!G&&G.mapping===qc?G.image.height:null,re=g[v.type];v.precision!==null&&(y=s.getMaxPrecision(v.precision),y!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",y,"instead."));let J=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,V=J!==void 0?J.length:0,xe=0;N.morphAttributes.position!==void 0&&(xe=1),N.morphAttributes.normal!==void 0&&(xe=2),N.morphAttributes.color!==void 0&&(xe=3);let X,ne,oe,ge;if(re){let hn=xi[re];X=hn.vertexShader,ne=hn.fragmentShader}else X=v.vertexShader,ne=v.fragmentShader,l.update(v),oe=l.getVertexShaderID(v),ge=l.getFragmentShaderID(v);let Fe=i.getRenderTarget(),Le=P.isInstancedMesh===!0,Ze=P.isBatchedMesh===!0,ct=!!v.map,$e=!!v.matcap,D=!!G,_n=!!v.aoMap,qe=!!v.lightMap,et=!!v.bumpMap,Ne=!!v.normalMap,gt=!!v.displacementMap,Ue=!!v.emissiveMap,I=!!v.metalnessMap,w=!!v.roughnessMap,W=v.anisotropy>0,ee=v.clearcoat>0,ie=v.dispersion>0,Q=v.iridescence>0,we=v.sheen>0,ue=v.transmission>0,ye=W&&!!v.anisotropyMap,tt=ee&&!!v.clearcoatMap,ae=ee&&!!v.clearcoatNormalMap,_e=ee&&!!v.clearcoatRoughnessMap,Oe=Q&&!!v.iridescenceMap,De=Q&&!!v.iridescenceThicknessMap,ve=we&&!!v.sheenColorMap,Ye=we&&!!v.sheenRoughnessMap,Be=!!v.specularMap,dt=!!v.specularColorMap,B=!!v.specularIntensityMap,pe=ue&&!!v.transmissionMap,Z=ue&&!!v.thicknessMap,te=!!v.gradientMap,fe=!!v.alphaMap,me=v.alphaTest>0,Je=!!v.alphaHash,It=!!v.extensions,cn=ls;v.toneMapped&&(Fe===null||Fe.isXRRenderTarget===!0)&&(cn=i.toneMapping);let nt={shaderID:re,shaderType:v.type,shaderName:v.name,vertexShader:X,fragmentShader:ne,defines:v.defines,customVertexShaderID:oe,customFragmentShaderID:ge,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:y,batching:Ze,batchingColor:Ze&&P._colorsTexture!==null,instancing:Le,instancingColor:Le&&P.instanceColor!==null,instancingMorph:Le&&P.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Fe===null?i.outputColorSpace:Fe.isXRRenderTarget===!0?Fe.texture.colorSpace:qt,alphaToCoverage:!!v.alphaToCoverage,map:ct,matcap:$e,envMap:D,envMapMode:D&&G.mapping,envMapCubeUVHeight:$,aoMap:_n,lightMap:qe,bumpMap:et,normalMap:Ne,displacementMap:d&&gt,emissiveMap:Ue,normalMapObjectSpace:Ne&&v.normalMapType===_M,normalMapTangentSpace:Ne&&v.normalMapType===e_,metalnessMap:I,roughnessMap:w,anisotropy:W,anisotropyMap:ye,clearcoat:ee,clearcoatMap:tt,clearcoatNormalMap:ae,clearcoatRoughnessMap:_e,dispersion:ie,iridescence:Q,iridescenceMap:Oe,iridescenceThicknessMap:De,sheen:we,sheenColorMap:ve,sheenRoughnessMap:Ye,specularMap:Be,specularColorMap:dt,specularIntensityMap:B,transmission:ue,transmissionMap:pe,thicknessMap:Z,gradientMap:te,opaque:v.transparent===!1&&v.blending===Wr&&v.alphaToCoverage===!1,alphaMap:fe,alphaTest:me,alphaHash:Je,combine:v.combine,mapUv:ct&&p(v.map.channel),aoMapUv:_n&&p(v.aoMap.channel),lightMapUv:qe&&p(v.lightMap.channel),bumpMapUv:et&&p(v.bumpMap.channel),normalMapUv:Ne&&p(v.normalMap.channel),displacementMapUv:gt&&p(v.displacementMap.channel),emissiveMapUv:Ue&&p(v.emissiveMap.channel),metalnessMapUv:I&&p(v.metalnessMap.channel),roughnessMapUv:w&&p(v.roughnessMap.channel),anisotropyMapUv:ye&&p(v.anisotropyMap.channel),clearcoatMapUv:tt&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:ae&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Oe&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:De&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:ve&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&p(v.sheenRoughnessMap.channel),specularMapUv:Be&&p(v.specularMap.channel),specularColorMapUv:dt&&p(v.specularColorMap.channel),specularIntensityMapUv:B&&p(v.specularIntensityMap.channel),transmissionMapUv:pe&&p(v.transmissionMap.channel),thicknessMapUv:Z&&p(v.thicknessMap.channel),alphaMapUv:fe&&p(v.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(Ne||W),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!N.attributes.uv&&(ct||fe),fog:!!U,useFog:v.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:f,skinning:P.isSkinnedMesh===!0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:V,morphTextureStride:xe,numDirLights:_.directional.length,numPointLights:_.point.length,numSpotLights:_.spot.length,numSpotLightMaps:_.spotLightMap.length,numRectAreaLights:_.rectArea.length,numHemiLights:_.hemi.length,numDirLightShadows:_.directionalShadowMap.length,numPointLightShadows:_.pointShadowMap.length,numSpotLightShadows:_.spotShadowMap.length,numSpotLightShadowsWithMaps:_.numSpotLightShadowsWithMaps,numLightProbes:_.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&x.length>0,shadowMapType:i.shadowMap.type,toneMapping:cn,decodeVideoTexture:ct&&v.map.isVideoTexture===!0&&je.getTransfer(v.map.colorSpace)===_t,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Nn,flipSided:v.side===mn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:It&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(It&&v.extensions.multiDraw===!0||Ze)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return nt.vertexUv1s=c.has(1),nt.vertexUv2s=c.has(2),nt.vertexUv3s=c.has(3),c.clear(),nt}function M(v){let _=[];if(v.shaderID?_.push(v.shaderID):(_.push(v.customVertexShaderID),_.push(v.customFragmentShaderID)),v.defines!==void 0)for(let x in v.defines)_.push(x),_.push(v.defines[x]);return v.isRawShaderMaterial===!1&&(b(_,v),S(_,v),_.push(i.outputColorSpace)),_.push(v.customProgramCacheKey),_.join()}function b(v,_){v.push(_.precision),v.push(_.outputColorSpace),v.push(_.envMapMode),v.push(_.envMapCubeUVHeight),v.push(_.mapUv),v.push(_.alphaMapUv),v.push(_.lightMapUv),v.push(_.aoMapUv),v.push(_.bumpMapUv),v.push(_.normalMapUv),v.push(_.displacementMapUv),v.push(_.emissiveMapUv),v.push(_.metalnessMapUv),v.push(_.roughnessMapUv),v.push(_.anisotropyMapUv),v.push(_.clearcoatMapUv),v.push(_.clearcoatNormalMapUv),v.push(_.clearcoatRoughnessMapUv),v.push(_.iridescenceMapUv),v.push(_.iridescenceThicknessMapUv),v.push(_.sheenColorMapUv),v.push(_.sheenRoughnessMapUv),v.push(_.specularMapUv),v.push(_.specularColorMapUv),v.push(_.specularIntensityMapUv),v.push(_.transmissionMapUv),v.push(_.thicknessMapUv),v.push(_.combine),v.push(_.fogExp2),v.push(_.sizeAttenuation),v.push(_.morphTargetsCount),v.push(_.morphAttributeCount),v.push(_.numDirLights),v.push(_.numPointLights),v.push(_.numSpotLights),v.push(_.numSpotLightMaps),v.push(_.numHemiLights),v.push(_.numRectAreaLights),v.push(_.numDirLightShadows),v.push(_.numPointLightShadows),v.push(_.numSpotLightShadows),v.push(_.numSpotLightShadowsWithMaps),v.push(_.numLightProbes),v.push(_.shadowMapType),v.push(_.toneMapping),v.push(_.numClippingPlanes),v.push(_.numClipIntersection),v.push(_.depthPacking)}function S(v,_){a.disableAll(),_.supportsVertexTextures&&a.enable(0),_.instancing&&a.enable(1),_.instancingColor&&a.enable(2),_.instancingMorph&&a.enable(3),_.matcap&&a.enable(4),_.envMap&&a.enable(5),_.normalMapObjectSpace&&a.enable(6),_.normalMapTangentSpace&&a.enable(7),_.clearcoat&&a.enable(8),_.iridescence&&a.enable(9),_.alphaTest&&a.enable(10),_.vertexColors&&a.enable(11),_.vertexAlphas&&a.enable(12),_.vertexUv1s&&a.enable(13),_.vertexUv2s&&a.enable(14),_.vertexUv3s&&a.enable(15),_.vertexTangents&&a.enable(16),_.anisotropy&&a.enable(17),_.alphaHash&&a.enable(18),_.batching&&a.enable(19),_.dispersion&&a.enable(20),_.batchingColor&&a.enable(21),v.push(a.mask),a.disableAll(),_.fog&&a.enable(0),_.useFog&&a.enable(1),_.flatShading&&a.enable(2),_.logarithmicDepthBuffer&&a.enable(3),_.reverseDepthBuffer&&a.enable(4),_.skinning&&a.enable(5),_.morphTargets&&a.enable(6),_.morphNormals&&a.enable(7),_.morphColors&&a.enable(8),_.premultipliedAlpha&&a.enable(9),_.shadowMapEnabled&&a.enable(10),_.doubleSided&&a.enable(11),_.flipSided&&a.enable(12),_.useDepthPacking&&a.enable(13),_.dithering&&a.enable(14),_.transmission&&a.enable(15),_.sheen&&a.enable(16),_.opaque&&a.enable(17),_.pointsUvs&&a.enable(18),_.decodeVideoTexture&&a.enable(19),_.alphaToCoverage&&a.enable(20),v.push(a.mask)}function O(v){let _=g[v.type],x;if(_){let T=xi[_];x=oS.clone(T.uniforms)}else x=v.uniforms;return x}function L(v,_){let x;for(let T=0,P=h.length;T<P;T++){let U=h[T];if(U.cacheKey===_){x=U,++x.usedTimes;break}}return x===void 0&&(x=new pE(i,_,v,r),h.push(x)),x}function R(v){if(--v.usedTimes===0){let _=h.indexOf(v);h[_]=h[h.length-1],h.pop(),v.destroy()}}function C(v){l.remove(v)}function j(){l.dispose()}return{getParameters:m,getProgramCacheKey:M,getUniforms:O,acquireProgram:L,releaseProgram:R,releaseShaderCache:C,programs:h,dispose:j}}function yE(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function _E(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function yy(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function _y(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u,f,d,y,g,p){let m=i[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:y,renderOrder:u.renderOrder,z:g,group:p},i[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=y,m.renderOrder=u.renderOrder,m.z=g,m.group=p),e++,m}function a(u,f,d,y,g,p){let m=o(u,f,d,y,g,p);d.transmission>0?n.push(m):d.transparent===!0?s.push(m):t.push(m)}function l(u,f,d,y,g,p){let m=o(u,f,d,y,g,p);d.transmission>0?n.unshift(m):d.transparent===!0?s.unshift(m):t.unshift(m)}function c(u,f){t.length>1&&t.sort(u||_E),n.length>1&&n.sort(f||yy),s.length>1&&s.sort(f||yy)}function h(){for(let u=e,f=i.length;u<f;u++){let d=i[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:a,unshift:l,finish:h,sort:c}}function vE(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new _y,i.set(n,[o])):s>=r.length?(o=new _y,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function xE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new F,color:new Re};break;case"SpotLight":t={position:new F,direction:new F,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Re,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":t={color:new Re,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function bE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var ME=0;function SE(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function wE(i){let e=new xE,t=bE(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new F);let s=new F,r=new Ie,o=new Ie;function a(c){let h=0,u=0,f=0;for(let j=0;j<9;j++)n.probe[j].set(0,0,0);let d=0,y=0,g=0,p=0,m=0,M=0,b=0,S=0,O=0,L=0,R=0;c.sort(SE);for(let j=0,v=c.length;j<v;j++){let _=c[j],x=_.color,T=_.intensity,P=_.distance,U=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)h+=x.r*T,u+=x.g*T,f+=x.b*T;else if(_.isLightProbe){for(let N=0;N<9;N++)n.probe[N].addScaledVector(_.sh.coefficients[N],T);R++}else if(_.isDirectionalLight){let N=e.get(_);if(N.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){let H=_.shadow,G=t.get(_);G.shadowIntensity=H.intensity,G.shadowBias=H.bias,G.shadowNormalBias=H.normalBias,G.shadowRadius=H.radius,G.shadowMapSize=H.mapSize,n.directionalShadow[d]=G,n.directionalShadowMap[d]=U,n.directionalShadowMatrix[d]=_.shadow.matrix,M++}n.directional[d]=N,d++}else if(_.isSpotLight){let N=e.get(_);N.position.setFromMatrixPosition(_.matrixWorld),N.color.copy(x).multiplyScalar(T),N.distance=P,N.coneCos=Math.cos(_.angle),N.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),N.decay=_.decay,n.spot[g]=N;let H=_.shadow;if(_.map&&(n.spotLightMap[O]=_.map,O++,H.updateMatrices(_),_.castShadow&&L++),n.spotLightMatrix[g]=H.matrix,_.castShadow){let G=t.get(_);G.shadowIntensity=H.intensity,G.shadowBias=H.bias,G.shadowNormalBias=H.normalBias,G.shadowRadius=H.radius,G.shadowMapSize=H.mapSize,n.spotShadow[g]=G,n.spotShadowMap[g]=U,S++}g++}else if(_.isRectAreaLight){let N=e.get(_);N.color.copy(x).multiplyScalar(T),N.halfWidth.set(_.width*.5,0,0),N.halfHeight.set(0,_.height*.5,0),n.rectArea[p]=N,p++}else if(_.isPointLight){let N=e.get(_);if(N.color.copy(_.color).multiplyScalar(_.intensity),N.distance=_.distance,N.decay=_.decay,_.castShadow){let H=_.shadow,G=t.get(_);G.shadowIntensity=H.intensity,G.shadowBias=H.bias,G.shadowNormalBias=H.normalBias,G.shadowRadius=H.radius,G.shadowMapSize=H.mapSize,G.shadowCameraNear=H.camera.near,G.shadowCameraFar=H.camera.far,n.pointShadow[y]=G,n.pointShadowMap[y]=U,n.pointShadowMatrix[y]=_.shadow.matrix,b++}n.point[y]=N,y++}else if(_.isHemisphereLight){let N=e.get(_);N.skyColor.copy(_.color).multiplyScalar(T),N.groundColor.copy(_.groundColor).multiplyScalar(T),n.hemi[m]=N,m++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=he.LTC_FLOAT_1,n.rectAreaLTC2=he.LTC_FLOAT_2):(n.rectAreaLTC1=he.LTC_HALF_1,n.rectAreaLTC2=he.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=f;let C=n.hash;(C.directionalLength!==d||C.pointLength!==y||C.spotLength!==g||C.rectAreaLength!==p||C.hemiLength!==m||C.numDirectionalShadows!==M||C.numPointShadows!==b||C.numSpotShadows!==S||C.numSpotMaps!==O||C.numLightProbes!==R)&&(n.directional.length=d,n.spot.length=g,n.rectArea.length=p,n.point.length=y,n.hemi.length=m,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=M,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=S+O-L,n.spotLightMap.length=O,n.numSpotLightShadowsWithMaps=L,n.numLightProbes=R,C.directionalLength=d,C.pointLength=y,C.spotLength=g,C.rectAreaLength=p,C.hemiLength=m,C.numDirectionalShadows=M,C.numPointShadows=b,C.numSpotShadows=S,C.numSpotMaps=O,C.numLightProbes=R,n.version=ME++)}function l(c,h){let u=0,f=0,d=0,y=0,g=0,p=h.matrixWorldInverse;for(let m=0,M=c.length;m<M;m++){let b=c[m];if(b.isDirectionalLight){let S=n.directional[u];S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),u++}else if(b.isSpotLight){let S=n.spot[d];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(p),S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),d++}else if(b.isRectAreaLight){let S=n.rectArea[y];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(p),o.identity(),r.copy(b.matrixWorld),r.premultiply(p),o.extractRotation(r),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),y++}else if(b.isPointLight){let S=n.point[f];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(p),f++}else if(b.isHemisphereLight){let S=n.hemi[g];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(p),g++}}}return{setup:a,setupView:l,state:n}}function vy(i){let e=new wE(i),t=[],n=[];function s(h){c.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function o(h){n.push(h)}function a(){e.setup(t)}function l(h){e.setupView(t,h)}let c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function AE(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new vy(i),e.set(s,[a])):r>=o.length?(a=new vy(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var fd=class extends Fn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=gM,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},dd=class extends Fn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},EE=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,TE=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function IE(i,e,t){let n=new aa,s=new Ve,r=new Ve,o=new Qe,a=new fd({depthPacking:yM}),l=new dd,c={},h=t.maxTextureSize,u={[Si]:mn,[mn]:Si,[Nn]:Nn},f=new Yn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:EE,fragmentShader:TE}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let y=new yn;y.setAttribute("position",new ft(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new St(y,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Vy;let m=this.type;this.render=function(L,R,C){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||L.length===0)return;let j=i.getRenderTarget(),v=i.getActiveCubeFace(),_=i.getActiveMipmapLevel(),x=i.state;x.setBlending(as),x.buffers.color.setClear(1,1,1,1),x.buffers.depth.setTest(!0),x.setScissorTest(!1);let T=m!==Ni&&this.type===Ni,P=m===Ni&&this.type!==Ni;for(let U=0,N=L.length;U<N;U++){let H=L[U],G=H.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",H,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let $=G.getFrameExtents();if(s.multiply($),r.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/$.x),s.x=r.x*$.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/$.y),s.y=r.y*$.y,G.mapSize.y=r.y)),G.map===null||T===!0||P===!0){let J=this.type!==Ni?{minFilter:Xt,magFilter:Xt}:{};G.map!==null&&G.map.dispose(),G.map=new Bi(s.x,s.y,J),G.map.texture.name=H.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();let re=G.getViewportCount();for(let J=0;J<re;J++){let V=G.getViewport(J);o.set(r.x*V.x,r.y*V.y,r.x*V.z,r.y*V.w),x.viewport(o),G.updateMatrices(H,J),n=G.getFrustum(),S(R,C,G.camera,H,this.type)}G.isPointLightShadow!==!0&&this.type===Ni&&M(G,C),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,i.setRenderTarget(j,v,_)};function M(L,R){let C=e.update(g);f.defines.VSM_SAMPLES!==L.blurSamples&&(f.defines.VSM_SAMPLES=L.blurSamples,d.defines.VSM_SAMPLES=L.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),L.mapPass===null&&(L.mapPass=new Bi(s.x,s.y)),f.uniforms.shadow_pass.value=L.map.texture,f.uniforms.resolution.value=L.mapSize,f.uniforms.radius.value=L.radius,i.setRenderTarget(L.mapPass),i.clear(),i.renderBufferDirect(R,null,C,f,g,null),d.uniforms.shadow_pass.value=L.mapPass.texture,d.uniforms.resolution.value=L.mapSize,d.uniforms.radius.value=L.radius,i.setRenderTarget(L.map),i.clear(),i.renderBufferDirect(R,null,C,d,g,null)}function b(L,R,C,j){let v=null,_=C.isPointLight===!0?L.customDistanceMaterial:L.customDepthMaterial;if(_!==void 0)v=_;else if(v=C.isPointLight===!0?l:a,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let x=v.uuid,T=R.uuid,P=c[x];P===void 0&&(P={},c[x]=P);let U=P[T];U===void 0&&(U=v.clone(),P[T]=U,R.addEventListener("dispose",O)),v=U}if(v.visible=R.visible,v.wireframe=R.wireframe,j===Ni?v.side=R.shadowSide!==null?R.shadowSide:R.side:v.side=R.shadowSide!==null?R.shadowSide:u[R.side],v.alphaMap=R.alphaMap,v.alphaTest=R.alphaTest,v.map=R.map,v.clipShadows=R.clipShadows,v.clippingPlanes=R.clippingPlanes,v.clipIntersection=R.clipIntersection,v.displacementMap=R.displacementMap,v.displacementScale=R.displacementScale,v.displacementBias=R.displacementBias,v.wireframeLinewidth=R.wireframeLinewidth,v.linewidth=R.linewidth,C.isPointLight===!0&&v.isMeshDistanceMaterial===!0){let x=i.properties.get(v);x.light=C}return v}function S(L,R,C,j,v){if(L.visible===!1)return;if(L.layers.test(R.layers)&&(L.isMesh||L.isLine||L.isPoints)&&(L.castShadow||L.receiveShadow&&v===Ni)&&(!L.frustumCulled||n.intersectsObject(L))){L.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,L.matrixWorld);let T=e.update(L),P=L.material;if(Array.isArray(P)){let U=T.groups;for(let N=0,H=U.length;N<H;N++){let G=U[N],$=P[G.materialIndex];if($&&$.visible){let re=b(L,$,j,v);L.onBeforeShadow(i,L,R,C,T,re,G),i.renderBufferDirect(C,null,T,re,L,G),L.onAfterShadow(i,L,R,C,T,re,G)}}}else if(P.visible){let U=b(L,P,j,v);L.onBeforeShadow(i,L,R,C,T,U,null),i.renderBufferDirect(C,null,T,U,L,null),L.onAfterShadow(i,L,R,C,T,U,null)}}let x=L.children;for(let T=0,P=x.length;T<P;T++)S(x[T],R,C,j,v)}function O(L){L.target.removeEventListener("dispose",O);for(let C in c){let j=c[C],v=L.target.uuid;v in j&&(j[v].dispose(),delete j[v])}}}var RE={[vf]:xf,[bf]:wf,[Mf]:Af,[Kr]:Sf,[xf]:vf,[wf]:bf,[Af]:Mf,[Sf]:Kr};function CE(i){function e(){let B=!1,pe=new Qe,Z=null,te=new Qe(0,0,0,0);return{setMask:function(fe){Z!==fe&&!B&&(i.colorMask(fe,fe,fe,fe),Z=fe)},setLocked:function(fe){B=fe},setClear:function(fe,me,Je,It,cn){cn===!0&&(fe*=It,me*=It,Je*=It),pe.set(fe,me,Je,It),te.equals(pe)===!1&&(i.clearColor(fe,me,Je,It),te.copy(pe))},reset:function(){B=!1,Z=null,te.set(-1,0,0,0)}}}function t(){let B=!1,pe=!1,Z=null,te=null,fe=null;return{setReversed:function(me){pe=me},setTest:function(me){me?oe(i.DEPTH_TEST):ge(i.DEPTH_TEST)},setMask:function(me){Z!==me&&!B&&(i.depthMask(me),Z=me)},setFunc:function(me){if(pe&&(me=RE[me]),te!==me){switch(me){case vf:i.depthFunc(i.NEVER);break;case xf:i.depthFunc(i.ALWAYS);break;case bf:i.depthFunc(i.LESS);break;case Kr:i.depthFunc(i.LEQUAL);break;case Mf:i.depthFunc(i.EQUAL);break;case Sf:i.depthFunc(i.GEQUAL);break;case wf:i.depthFunc(i.GREATER);break;case Af:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}te=me}},setLocked:function(me){B=me},setClear:function(me){fe!==me&&(i.clearDepth(me),fe=me)},reset:function(){B=!1,Z=null,te=null,fe=null}}}function n(){let B=!1,pe=null,Z=null,te=null,fe=null,me=null,Je=null,It=null,cn=null;return{setTest:function(nt){B||(nt?oe(i.STENCIL_TEST):ge(i.STENCIL_TEST))},setMask:function(nt){pe!==nt&&!B&&(i.stencilMask(nt),pe=nt)},setFunc:function(nt,hn,wi){(Z!==nt||te!==hn||fe!==wi)&&(i.stencilFunc(nt,hn,wi),Z=nt,te=hn,fe=wi)},setOp:function(nt,hn,wi){(me!==nt||Je!==hn||It!==wi)&&(i.stencilOp(nt,hn,wi),me=nt,Je=hn,It=wi)},setLocked:function(nt){B=nt},setClear:function(nt){cn!==nt&&(i.clearStencil(nt),cn=nt)},reset:function(){B=!1,pe=null,Z=null,te=null,fe=null,me=null,Je=null,It=null,cn=null}}}let s=new e,r=new t,o=new n,a=new WeakMap,l=new WeakMap,c={},h={},u=new WeakMap,f=[],d=null,y=!1,g=null,p=null,m=null,M=null,b=null,S=null,O=null,L=new Re(0,0,0),R=0,C=!1,j=null,v=null,_=null,x=null,T=null,P=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),U=!1,N=0,H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(H)[1]),U=N>=1):H.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),U=N>=2);let G=null,$={},re=i.getParameter(i.SCISSOR_BOX),J=i.getParameter(i.VIEWPORT),V=new Qe().fromArray(re),xe=new Qe().fromArray(J);function X(B,pe,Z,te){let fe=new Uint8Array(4),me=i.createTexture();i.bindTexture(B,me),i.texParameteri(B,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(B,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Je=0;Je<Z;Je++)B===i.TEXTURE_3D||B===i.TEXTURE_2D_ARRAY?i.texImage3D(pe,0,i.RGBA,1,1,te,0,i.RGBA,i.UNSIGNED_BYTE,fe):i.texImage2D(pe+Je,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,fe);return me}let ne={};ne[i.TEXTURE_2D]=X(i.TEXTURE_2D,i.TEXTURE_2D,1),ne[i.TEXTURE_CUBE_MAP]=X(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ne[i.TEXTURE_2D_ARRAY]=X(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ne[i.TEXTURE_3D]=X(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),oe(i.DEPTH_TEST),r.setFunc(Kr),qe(!1),et(w0),oe(i.CULL_FACE),D(as);function oe(B){c[B]!==!0&&(i.enable(B),c[B]=!0)}function ge(B){c[B]!==!1&&(i.disable(B),c[B]=!1)}function Fe(B,pe){return h[B]!==pe?(i.bindFramebuffer(B,pe),h[B]=pe,B===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=pe),B===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=pe),!0):!1}function Le(B,pe){let Z=f,te=!1;if(B){Z=u.get(pe),Z===void 0&&(Z=[],u.set(pe,Z));let fe=B.textures;if(Z.length!==fe.length||Z[0]!==i.COLOR_ATTACHMENT0){for(let me=0,Je=fe.length;me<Je;me++)Z[me]=i.COLOR_ATTACHMENT0+me;Z.length=fe.length,te=!0}}else Z[0]!==i.BACK&&(Z[0]=i.BACK,te=!0);te&&i.drawBuffers(Z)}function Ze(B){return d!==B?(i.useProgram(B),d=B,!0):!1}let ct={[qs]:i.FUNC_ADD,[Hb]:i.FUNC_SUBTRACT,[Gb]:i.FUNC_REVERSE_SUBTRACT};ct[Wb]=i.MIN,ct[Xb]=i.MAX;let $e={[qb]:i.ZERO,[Yb]:i.ONE,[Kb]:i.SRC_COLOR,[yf]:i.SRC_ALPHA,[eM]:i.SRC_ALPHA_SATURATE,[jb]:i.DST_COLOR,[$b]:i.DST_ALPHA,[Zb]:i.ONE_MINUS_SRC_COLOR,[_f]:i.ONE_MINUS_SRC_ALPHA,[Qb]:i.ONE_MINUS_DST_COLOR,[Jb]:i.ONE_MINUS_DST_ALPHA,[tM]:i.CONSTANT_COLOR,[nM]:i.ONE_MINUS_CONSTANT_COLOR,[iM]:i.CONSTANT_ALPHA,[sM]:i.ONE_MINUS_CONSTANT_ALPHA};function D(B,pe,Z,te,fe,me,Je,It,cn,nt){if(B===as){y===!0&&(ge(i.BLEND),y=!1);return}if(y===!1&&(oe(i.BLEND),y=!0),B!==Vb){if(B!==g||nt!==C){if((p!==qs||b!==qs)&&(i.blendEquation(i.FUNC_ADD),p=qs,b=qs),nt)switch(B){case Wr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case A0:i.blendFunc(i.ONE,i.ONE);break;case E0:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case T0:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}else switch(B){case Wr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case A0:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case E0:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case T0:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}m=null,M=null,S=null,O=null,L.set(0,0,0),R=0,g=B,C=nt}return}fe=fe||pe,me=me||Z,Je=Je||te,(pe!==p||fe!==b)&&(i.blendEquationSeparate(ct[pe],ct[fe]),p=pe,b=fe),(Z!==m||te!==M||me!==S||Je!==O)&&(i.blendFuncSeparate($e[Z],$e[te],$e[me],$e[Je]),m=Z,M=te,S=me,O=Je),(It.equals(L)===!1||cn!==R)&&(i.blendColor(It.r,It.g,It.b,cn),L.copy(It),R=cn),g=B,C=!1}function _n(B,pe){B.side===Nn?ge(i.CULL_FACE):oe(i.CULL_FACE);let Z=B.side===mn;pe&&(Z=!Z),qe(Z),B.blending===Wr&&B.transparent===!1?D(as):D(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),r.setFunc(B.depthFunc),r.setTest(B.depthTest),r.setMask(B.depthWrite),s.setMask(B.colorWrite);let te=B.stencilWrite;o.setTest(te),te&&(o.setMask(B.stencilWriteMask),o.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),o.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),gt(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?oe(i.SAMPLE_ALPHA_TO_COVERAGE):ge(i.SAMPLE_ALPHA_TO_COVERAGE)}function qe(B){j!==B&&(B?i.frontFace(i.CW):i.frontFace(i.CCW),j=B)}function et(B){B!==Bb?(oe(i.CULL_FACE),B!==v&&(B===w0?i.cullFace(i.BACK):B===kb?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ge(i.CULL_FACE),v=B}function Ne(B){B!==_&&(U&&i.lineWidth(B),_=B)}function gt(B,pe,Z){B?(oe(i.POLYGON_OFFSET_FILL),(x!==pe||T!==Z)&&(i.polygonOffset(pe,Z),x=pe,T=Z)):ge(i.POLYGON_OFFSET_FILL)}function Ue(B){B?oe(i.SCISSOR_TEST):ge(i.SCISSOR_TEST)}function I(B){B===void 0&&(B=i.TEXTURE0+P-1),G!==B&&(i.activeTexture(B),G=B)}function w(B,pe,Z){Z===void 0&&(G===null?Z=i.TEXTURE0+P-1:Z=G);let te=$[Z];te===void 0&&(te={type:void 0,texture:void 0},$[Z]=te),(te.type!==B||te.texture!==pe)&&(G!==Z&&(i.activeTexture(Z),G=Z),i.bindTexture(B,pe||ne[B]),te.type=B,te.texture=pe)}function W(){let B=$[G];B!==void 0&&B.type!==void 0&&(i.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function ee(){try{i.compressedTexImage2D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ie(){try{i.compressedTexImage3D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Q(){try{i.texSubImage2D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function we(){try{i.texSubImage3D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ue(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ye(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function tt(){try{i.texStorage2D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ae(){try{i.texStorage3D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function _e(){try{i.texImage2D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Oe(){try{i.texImage3D.apply(i,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function De(B){V.equals(B)===!1&&(i.scissor(B.x,B.y,B.z,B.w),V.copy(B))}function ve(B){xe.equals(B)===!1&&(i.viewport(B.x,B.y,B.z,B.w),xe.copy(B))}function Ye(B,pe){let Z=l.get(pe);Z===void 0&&(Z=new WeakMap,l.set(pe,Z));let te=Z.get(B);te===void 0&&(te=i.getUniformBlockIndex(pe,B.name),Z.set(B,te))}function Be(B,pe){let te=l.get(pe).get(B);a.get(pe)!==te&&(i.uniformBlockBinding(pe,te,B.__bindingPointIndex),a.set(pe,te))}function dt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},G=null,$={},h={},u=new WeakMap,f=[],d=null,y=!1,g=null,p=null,m=null,M=null,b=null,S=null,O=null,L=new Re(0,0,0),R=0,C=!1,j=null,v=null,_=null,x=null,T=null,V.set(0,0,i.canvas.width,i.canvas.height),xe.set(0,0,i.canvas.width,i.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:oe,disable:ge,bindFramebuffer:Fe,drawBuffers:Le,useProgram:Ze,setBlending:D,setMaterial:_n,setFlipSided:qe,setCullFace:et,setLineWidth:Ne,setPolygonOffset:gt,setScissorTest:Ue,activeTexture:I,bindTexture:w,unbindTexture:W,compressedTexImage2D:ee,compressedTexImage3D:ie,texImage2D:_e,texImage3D:Oe,updateUBOMapping:Ye,uniformBlockBinding:Be,texStorage2D:tt,texStorage3D:ae,texSubImage2D:Q,texSubImage3D:we,compressedTexSubImage2D:ue,compressedTexSubImage3D:ye,scissor:De,viewport:ve,reset:dt}}function xy(i,e,t,n){let s=LE(n);switch(t){case Yy:return i*e;case Zy:return i*e;case $y:return i*e*2;case Nd:return i*e/s.components*s.byteLength;case Od:return i*e/s.components*s.byteLength;case Jy:return i*e*2/s.components*s.byteLength;case Dd:return i*e*2/s.components*s.byteLength;case Ky:return i*e*3/s.components*s.byteLength;case pn:return i*e*4/s.components*s.byteLength;case Ud:return i*e*4/s.components*s.byteLength;case dc:case pc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case mc:case gc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Rf:case Lf:return Math.max(i,16)*Math.max(e,8)/4;case If:case Cf:return Math.max(i,8)*Math.max(e,8)/2;case Pf:case Nf:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Of:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Df:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Uf:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ff:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Bf:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case kf:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case zf:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Vf:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Hf:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Gf:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Wf:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Xf:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case qf:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Yf:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Kf:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case yc:case Zf:case $f:return Math.ceil(i/4)*Math.ceil(e/4)*16;case jy:case Jf:return Math.ceil(i/4)*Math.ceil(e/4)*8;case jf:case Qf:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function LE(i){switch(i){case Fi:case Wy:return{byteLength:1,components:1};case sa:case Xy:case ga:return{byteLength:2,components:1};case Ld:case Pd:return{byteLength:2,components:4};case $s:case Cd:case ci:return{byteLength:4,components:1};case qy:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function PE(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ve,h=new WeakMap,u,f=new WeakMap,d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(I,w){return d?new OffscreenCanvas(I,w):ra("canvas")}function g(I,w,W){let ee=1,ie=Ue(I);if((ie.width>W||ie.height>W)&&(ee=W/Math.max(ie.width,ie.height)),ee<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){let Q=Math.floor(ee*ie.width),we=Math.floor(ee*ie.height);u===void 0&&(u=y(Q,we));let ue=w?y(Q,we):u;return ue.width=Q,ue.height=we,ue.getContext("2d").drawImage(I,0,0,Q,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+Q+"x"+we+")."),ue}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+")."),I;return I}function p(I){return I.generateMipmaps&&I.minFilter!==Xt&&I.minFilter!==Ot}function m(I){i.generateMipmap(I)}function M(I,w,W,ee,ie=!1){if(I!==null){if(i[I]!==void 0)return i[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Q=w;if(w===i.RED&&(W===i.FLOAT&&(Q=i.R32F),W===i.HALF_FLOAT&&(Q=i.R16F),W===i.UNSIGNED_BYTE&&(Q=i.R8)),w===i.RED_INTEGER&&(W===i.UNSIGNED_BYTE&&(Q=i.R8UI),W===i.UNSIGNED_SHORT&&(Q=i.R16UI),W===i.UNSIGNED_INT&&(Q=i.R32UI),W===i.BYTE&&(Q=i.R8I),W===i.SHORT&&(Q=i.R16I),W===i.INT&&(Q=i.R32I)),w===i.RG&&(W===i.FLOAT&&(Q=i.RG32F),W===i.HALF_FLOAT&&(Q=i.RG16F),W===i.UNSIGNED_BYTE&&(Q=i.RG8)),w===i.RG_INTEGER&&(W===i.UNSIGNED_BYTE&&(Q=i.RG8UI),W===i.UNSIGNED_SHORT&&(Q=i.RG16UI),W===i.UNSIGNED_INT&&(Q=i.RG32UI),W===i.BYTE&&(Q=i.RG8I),W===i.SHORT&&(Q=i.RG16I),W===i.INT&&(Q=i.RG32I)),w===i.RGB_INTEGER&&(W===i.UNSIGNED_BYTE&&(Q=i.RGB8UI),W===i.UNSIGNED_SHORT&&(Q=i.RGB16UI),W===i.UNSIGNED_INT&&(Q=i.RGB32UI),W===i.BYTE&&(Q=i.RGB8I),W===i.SHORT&&(Q=i.RGB16I),W===i.INT&&(Q=i.RGB32I)),w===i.RGBA_INTEGER&&(W===i.UNSIGNED_BYTE&&(Q=i.RGBA8UI),W===i.UNSIGNED_SHORT&&(Q=i.RGBA16UI),W===i.UNSIGNED_INT&&(Q=i.RGBA32UI),W===i.BYTE&&(Q=i.RGBA8I),W===i.SHORT&&(Q=i.RGBA16I),W===i.INT&&(Q=i.RGBA32I)),w===i.RGB&&W===i.UNSIGNED_INT_5_9_9_9_REV&&(Q=i.RGB9_E5),w===i.RGBA){let we=ie?vc:je.getTransfer(ee);W===i.FLOAT&&(Q=i.RGBA32F),W===i.HALF_FLOAT&&(Q=i.RGBA16F),W===i.UNSIGNED_BYTE&&(Q=we===_t?i.SRGB8_ALPHA8:i.RGBA8),W===i.UNSIGNED_SHORT_4_4_4_4&&(Q=i.RGBA4),W===i.UNSIGNED_SHORT_5_5_5_1&&(Q=i.RGB5_A1)}return(Q===i.R16F||Q===i.R32F||Q===i.RG16F||Q===i.RG32F||Q===i.RGBA16F||Q===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Q}function b(I,w){let W;return I?w===null||w===$s||w===Jr?W=i.DEPTH24_STENCIL8:w===ci?W=i.DEPTH32F_STENCIL8:w===sa&&(W=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===$s||w===Jr?W=i.DEPTH_COMPONENT24:w===ci?W=i.DEPTH_COMPONENT32F:w===sa&&(W=i.DEPTH_COMPONENT16),W}function S(I,w){return p(I)===!0||I.isFramebufferTexture&&I.minFilter!==Xt&&I.minFilter!==Ot?Math.log2(Math.max(w.width,w.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?w.mipmaps.length:1}function O(I){let w=I.target;w.removeEventListener("dispose",O),R(w),w.isVideoTexture&&h.delete(w)}function L(I){let w=I.target;w.removeEventListener("dispose",L),j(w)}function R(I){let w=n.get(I);if(w.__webglInit===void 0)return;let W=I.source,ee=f.get(W);if(ee){let ie=ee[w.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&C(I),Object.keys(ee).length===0&&f.delete(W)}n.remove(I)}function C(I){let w=n.get(I);i.deleteTexture(w.__webglTexture);let W=I.source,ee=f.get(W);delete ee[w.__cacheKey],o.memory.textures--}function j(I){let w=n.get(I);if(I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(w.__webglFramebuffer[ee]))for(let ie=0;ie<w.__webglFramebuffer[ee].length;ie++)i.deleteFramebuffer(w.__webglFramebuffer[ee][ie]);else i.deleteFramebuffer(w.__webglFramebuffer[ee]);w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer[ee])}else{if(Array.isArray(w.__webglFramebuffer))for(let ee=0;ee<w.__webglFramebuffer.length;ee++)i.deleteFramebuffer(w.__webglFramebuffer[ee]);else i.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&i.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let ee=0;ee<w.__webglColorRenderbuffer.length;ee++)w.__webglColorRenderbuffer[ee]&&i.deleteRenderbuffer(w.__webglColorRenderbuffer[ee]);w.__webglDepthRenderbuffer&&i.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let W=I.textures;for(let ee=0,ie=W.length;ee<ie;ee++){let Q=n.get(W[ee]);Q.__webglTexture&&(i.deleteTexture(Q.__webglTexture),o.memory.textures--),n.remove(W[ee])}n.remove(I)}let v=0;function _(){v=0}function x(){let I=v;return I>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+s.maxTextures),v+=1,I}function T(I){let w=[];return w.push(I.wrapS),w.push(I.wrapT),w.push(I.wrapR||0),w.push(I.magFilter),w.push(I.minFilter),w.push(I.anisotropy),w.push(I.internalFormat),w.push(I.format),w.push(I.type),w.push(I.generateMipmaps),w.push(I.premultiplyAlpha),w.push(I.flipY),w.push(I.unpackAlignment),w.push(I.colorSpace),w.join()}function P(I,w){let W=n.get(I);if(I.isVideoTexture&&Ne(I),I.isRenderTargetTexture===!1&&I.version>0&&W.__version!==I.version){let ee=I.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{xe(W,I,w);return}}t.bindTexture(i.TEXTURE_2D,W.__webglTexture,i.TEXTURE0+w)}function U(I,w){let W=n.get(I);if(I.version>0&&W.__version!==I.version){xe(W,I,w);return}t.bindTexture(i.TEXTURE_2D_ARRAY,W.__webglTexture,i.TEXTURE0+w)}function N(I,w){let W=n.get(I);if(I.version>0&&W.__version!==I.version){xe(W,I,w);return}t.bindTexture(i.TEXTURE_3D,W.__webglTexture,i.TEXTURE0+w)}function H(I,w){let W=n.get(I);if(I.version>0&&W.__version!==I.version){X(W,I,w);return}t.bindTexture(i.TEXTURE_CUBE_MAP,W.__webglTexture,i.TEXTURE0+w)}let G={[Ui]:i.REPEAT,[li]:i.CLAMP_TO_EDGE,[Zs]:i.MIRRORED_REPEAT},$={[Xt]:i.NEAREST,[ma]:i.NEAREST_MIPMAP_NEAREST,[rs]:i.NEAREST_MIPMAP_LINEAR,[Ot]:i.LINEAR,[Ks]:i.LINEAR_MIPMAP_NEAREST,[Wn]:i.LINEAR_MIPMAP_LINEAR},re={[vM]:i.NEVER,[AM]:i.ALWAYS,[xM]:i.LESS,[t_]:i.LEQUAL,[bM]:i.EQUAL,[wM]:i.GEQUAL,[MM]:i.GREATER,[SM]:i.NOTEQUAL};function J(I,w){if(w.type===ci&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Ot||w.magFilter===Ks||w.magFilter===rs||w.magFilter===Wn||w.minFilter===Ot||w.minFilter===Ks||w.minFilter===rs||w.minFilter===Wn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(I,i.TEXTURE_WRAP_S,G[w.wrapS]),i.texParameteri(I,i.TEXTURE_WRAP_T,G[w.wrapT]),(I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY)&&i.texParameteri(I,i.TEXTURE_WRAP_R,G[w.wrapR]),i.texParameteri(I,i.TEXTURE_MAG_FILTER,$[w.magFilter]),i.texParameteri(I,i.TEXTURE_MIN_FILTER,$[w.minFilter]),w.compareFunction&&(i.texParameteri(I,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(I,i.TEXTURE_COMPARE_FUNC,re[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===Xt||w.minFilter!==rs&&w.minFilter!==Wn||w.type===ci&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||n.get(w).__currentAnisotropy){let W=e.get("EXT_texture_filter_anisotropic");i.texParameterf(I,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,s.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy}}}function V(I,w){let W=!1;I.__webglInit===void 0&&(I.__webglInit=!0,w.addEventListener("dispose",O));let ee=w.source,ie=f.get(ee);ie===void 0&&(ie={},f.set(ee,ie));let Q=T(w);if(Q!==I.__cacheKey){ie[Q]===void 0&&(ie[Q]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,W=!0),ie[Q].usedTimes++;let we=ie[I.__cacheKey];we!==void 0&&(ie[I.__cacheKey].usedTimes--,we.usedTimes===0&&C(w)),I.__cacheKey=Q,I.__webglTexture=ie[Q].texture}return W}function xe(I,w,W){let ee=i.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(ee=i.TEXTURE_2D_ARRAY),w.isData3DTexture&&(ee=i.TEXTURE_3D);let ie=V(I,w),Q=w.source;t.bindTexture(ee,I.__webglTexture,i.TEXTURE0+W);let we=n.get(Q);if(Q.version!==we.__version||ie===!0){t.activeTexture(i.TEXTURE0+W);let ue=je.getPrimaries(je.workingColorSpace),ye=w.colorSpace===bi?null:je.getPrimaries(w.colorSpace),tt=w.colorSpace===bi||ue===ye?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,tt);let ae=g(w.image,!1,s.maxTextureSize);ae=gt(w,ae);let _e=r.convert(w.format,w.colorSpace),Oe=r.convert(w.type),De=M(w.internalFormat,_e,Oe,w.colorSpace,w.isVideoTexture);J(ee,w);let ve,Ye=w.mipmaps,Be=w.isVideoTexture!==!0,dt=we.__version===void 0||ie===!0,B=Q.dataReady,pe=S(w,ae);if(w.isDepthTexture)De=b(w.format===jr,w.type),dt&&(Be?t.texStorage2D(i.TEXTURE_2D,1,De,ae.width,ae.height):t.texImage2D(i.TEXTURE_2D,0,De,ae.width,ae.height,0,_e,Oe,null));else if(w.isDataTexture)if(Ye.length>0){Be&&dt&&t.texStorage2D(i.TEXTURE_2D,pe,De,Ye[0].width,Ye[0].height);for(let Z=0,te=Ye.length;Z<te;Z++)ve=Ye[Z],Be?B&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,ve.width,ve.height,_e,Oe,ve.data):t.texImage2D(i.TEXTURE_2D,Z,De,ve.width,ve.height,0,_e,Oe,ve.data);w.generateMipmaps=!1}else Be?(dt&&t.texStorage2D(i.TEXTURE_2D,pe,De,ae.width,ae.height),B&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ae.width,ae.height,_e,Oe,ae.data)):t.texImage2D(i.TEXTURE_2D,0,De,ae.width,ae.height,0,_e,Oe,ae.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Be&&dt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,pe,De,Ye[0].width,Ye[0].height,ae.depth);for(let Z=0,te=Ye.length;Z<te;Z++)if(ve=Ye[Z],w.format!==pn)if(_e!==null)if(Be){if(B)if(w.layerUpdates.size>0){let fe=xy(ve.width,ve.height,w.format,w.type);for(let me of w.layerUpdates){let Je=ve.data.subarray(me*fe/ve.data.BYTES_PER_ELEMENT,(me+1)*fe/ve.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,me,ve.width,ve.height,1,_e,Je,0,0)}w.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ve.width,ve.height,ae.depth,_e,ve.data,0,0)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,De,ve.width,ve.height,ae.depth,0,ve.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Be?B&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ve.width,ve.height,ae.depth,_e,Oe,ve.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,De,ve.width,ve.height,ae.depth,0,_e,Oe,ve.data)}else{Be&&dt&&t.texStorage2D(i.TEXTURE_2D,pe,De,Ye[0].width,Ye[0].height);for(let Z=0,te=Ye.length;Z<te;Z++)ve=Ye[Z],w.format!==pn?_e!==null?Be?B&&t.compressedTexSubImage2D(i.TEXTURE_2D,Z,0,0,ve.width,ve.height,_e,ve.data):t.compressedTexImage2D(i.TEXTURE_2D,Z,De,ve.width,ve.height,0,ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Be?B&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,ve.width,ve.height,_e,Oe,ve.data):t.texImage2D(i.TEXTURE_2D,Z,De,ve.width,ve.height,0,_e,Oe,ve.data)}else if(w.isDataArrayTexture)if(Be){if(dt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,pe,De,ae.width,ae.height,ae.depth),B)if(w.layerUpdates.size>0){let Z=xy(ae.width,ae.height,w.format,w.type);for(let te of w.layerUpdates){let fe=ae.data.subarray(te*Z/ae.data.BYTES_PER_ELEMENT,(te+1)*Z/ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,te,ae.width,ae.height,1,_e,Oe,fe)}w.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,_e,Oe,ae.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,De,ae.width,ae.height,ae.depth,0,_e,Oe,ae.data);else if(w.isData3DTexture)Be?(dt&&t.texStorage3D(i.TEXTURE_3D,pe,De,ae.width,ae.height,ae.depth),B&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,_e,Oe,ae.data)):t.texImage3D(i.TEXTURE_3D,0,De,ae.width,ae.height,ae.depth,0,_e,Oe,ae.data);else if(w.isFramebufferTexture){if(dt)if(Be)t.texStorage2D(i.TEXTURE_2D,pe,De,ae.width,ae.height);else{let Z=ae.width,te=ae.height;for(let fe=0;fe<pe;fe++)t.texImage2D(i.TEXTURE_2D,fe,De,Z,te,0,_e,Oe,null),Z>>=1,te>>=1}}else if(Ye.length>0){if(Be&&dt){let Z=Ue(Ye[0]);t.texStorage2D(i.TEXTURE_2D,pe,De,Z.width,Z.height)}for(let Z=0,te=Ye.length;Z<te;Z++)ve=Ye[Z],Be?B&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,_e,Oe,ve):t.texImage2D(i.TEXTURE_2D,Z,De,_e,Oe,ve);w.generateMipmaps=!1}else if(Be){if(dt){let Z=Ue(ae);t.texStorage2D(i.TEXTURE_2D,pe,De,Z.width,Z.height)}B&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,_e,Oe,ae)}else t.texImage2D(i.TEXTURE_2D,0,De,_e,Oe,ae);p(w)&&m(ee),we.__version=Q.version,w.onUpdate&&w.onUpdate(w)}I.__version=w.version}function X(I,w,W){if(w.image.length!==6)return;let ee=V(I,w),ie=w.source;t.bindTexture(i.TEXTURE_CUBE_MAP,I.__webglTexture,i.TEXTURE0+W);let Q=n.get(ie);if(ie.version!==Q.__version||ee===!0){t.activeTexture(i.TEXTURE0+W);let we=je.getPrimaries(je.workingColorSpace),ue=w.colorSpace===bi?null:je.getPrimaries(w.colorSpace),ye=w.colorSpace===bi||we===ue?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye);let tt=w.isCompressedTexture||w.image[0].isCompressedTexture,ae=w.image[0]&&w.image[0].isDataTexture,_e=[];for(let te=0;te<6;te++)!tt&&!ae?_e[te]=g(w.image[te],!0,s.maxCubemapSize):_e[te]=ae?w.image[te].image:w.image[te],_e[te]=gt(w,_e[te]);let Oe=_e[0],De=r.convert(w.format,w.colorSpace),ve=r.convert(w.type),Ye=M(w.internalFormat,De,ve,w.colorSpace),Be=w.isVideoTexture!==!0,dt=Q.__version===void 0||ee===!0,B=ie.dataReady,pe=S(w,Oe);J(i.TEXTURE_CUBE_MAP,w);let Z;if(tt){Be&&dt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Ye,Oe.width,Oe.height);for(let te=0;te<6;te++){Z=_e[te].mipmaps;for(let fe=0;fe<Z.length;fe++){let me=Z[fe];w.format!==pn?De!==null?Be?B&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe,0,0,me.width,me.height,De,me.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe,Ye,me.width,me.height,0,me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Be?B&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe,0,0,me.width,me.height,De,ve,me.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe,Ye,me.width,me.height,0,De,ve,me.data)}}}else{if(Z=w.mipmaps,Be&&dt){Z.length>0&&pe++;let te=Ue(_e[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Ye,te.width,te.height)}for(let te=0;te<6;te++)if(ae){Be?B&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,_e[te].width,_e[te].height,De,ve,_e[te].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ye,_e[te].width,_e[te].height,0,De,ve,_e[te].data);for(let fe=0;fe<Z.length;fe++){let Je=Z[fe].image[te].image;Be?B&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe+1,0,0,Je.width,Je.height,De,ve,Je.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe+1,Ye,Je.width,Je.height,0,De,ve,Je.data)}}else{Be?B&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,De,ve,_e[te]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ye,De,ve,_e[te]);for(let fe=0;fe<Z.length;fe++){let me=Z[fe];Be?B&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe+1,0,0,De,ve,me.image[te]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe+1,Ye,De,ve,me.image[te])}}}p(w)&&m(i.TEXTURE_CUBE_MAP),Q.__version=ie.version,w.onUpdate&&w.onUpdate(w)}I.__version=w.version}function ne(I,w,W,ee,ie,Q){let we=r.convert(W.format,W.colorSpace),ue=r.convert(W.type),ye=M(W.internalFormat,we,ue,W.colorSpace);if(!n.get(w).__hasExternalTextures){let ae=Math.max(1,w.width>>Q),_e=Math.max(1,w.height>>Q);ie===i.TEXTURE_3D||ie===i.TEXTURE_2D_ARRAY?t.texImage3D(ie,Q,ye,ae,_e,w.depth,0,we,ue,null):t.texImage2D(ie,Q,ye,ae,_e,0,we,ue,null)}t.bindFramebuffer(i.FRAMEBUFFER,I),et(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ee,ie,n.get(W).__webglTexture,0,qe(w)):(ie===i.TEXTURE_2D||ie>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,ee,ie,n.get(W).__webglTexture,Q),t.bindFramebuffer(i.FRAMEBUFFER,null)}function oe(I,w,W){if(i.bindRenderbuffer(i.RENDERBUFFER,I),w.depthBuffer){let ee=w.depthTexture,ie=ee&&ee.isDepthTexture?ee.type:null,Q=b(w.stencilBuffer,ie),we=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ue=qe(w);et(w)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ue,Q,w.width,w.height):W?i.renderbufferStorageMultisample(i.RENDERBUFFER,ue,Q,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,Q,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,we,i.RENDERBUFFER,I)}else{let ee=w.textures;for(let ie=0;ie<ee.length;ie++){let Q=ee[ie],we=r.convert(Q.format,Q.colorSpace),ue=r.convert(Q.type),ye=M(Q.internalFormat,we,ue,Q.colorSpace),tt=qe(w);W&&et(w)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,tt,ye,w.width,w.height):et(w)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,tt,ye,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,ye,w.width,w.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ge(I,w){if(w&&w.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,I),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(w.depthTexture).__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),P(w.depthTexture,0);let ee=n.get(w.depthTexture).__webglTexture,ie=qe(w);if(w.depthTexture.format===Xr)et(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ee,0,ie):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ee,0);else if(w.depthTexture.format===jr)et(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ee,0,ie):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ee,0);else throw new Error("Unknown depthTexture format")}function Fe(I){let w=n.get(I),W=I.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==I.depthTexture){let ee=I.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),ee){let ie=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,ee.removeEventListener("dispose",ie)};ee.addEventListener("dispose",ie),w.__depthDisposeCallback=ie}w.__boundDepthTexture=ee}if(I.depthTexture&&!w.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");ge(w.__webglFramebuffer,I)}else if(W){w.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)if(t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer[ee]),w.__webglDepthbuffer[ee]===void 0)w.__webglDepthbuffer[ee]=i.createRenderbuffer(),oe(w.__webglDepthbuffer[ee],I,!1);else{let ie=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Q=w.__webglDepthbuffer[ee];i.bindRenderbuffer(i.RENDERBUFFER,Q),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,Q)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=i.createRenderbuffer(),oe(w.__webglDepthbuffer,I,!1);else{let ee=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=w.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,ie)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Le(I,w,W){let ee=n.get(I);w!==void 0&&ne(ee.__webglFramebuffer,I,I.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),W!==void 0&&Fe(I)}function Ze(I){let w=I.texture,W=n.get(I),ee=n.get(w);I.addEventListener("dispose",L);let ie=I.textures,Q=I.isWebGLCubeRenderTarget===!0,we=ie.length>1;if(we||(ee.__webglTexture===void 0&&(ee.__webglTexture=i.createTexture()),ee.__version=w.version,o.memory.textures++),Q){W.__webglFramebuffer=[];for(let ue=0;ue<6;ue++)if(w.mipmaps&&w.mipmaps.length>0){W.__webglFramebuffer[ue]=[];for(let ye=0;ye<w.mipmaps.length;ye++)W.__webglFramebuffer[ue][ye]=i.createFramebuffer()}else W.__webglFramebuffer[ue]=i.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){W.__webglFramebuffer=[];for(let ue=0;ue<w.mipmaps.length;ue++)W.__webglFramebuffer[ue]=i.createFramebuffer()}else W.__webglFramebuffer=i.createFramebuffer();if(we)for(let ue=0,ye=ie.length;ue<ye;ue++){let tt=n.get(ie[ue]);tt.__webglTexture===void 0&&(tt.__webglTexture=i.createTexture(),o.memory.textures++)}if(I.samples>0&&et(I)===!1){W.__webglMultisampledFramebuffer=i.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let ue=0;ue<ie.length;ue++){let ye=ie[ue];W.__webglColorRenderbuffer[ue]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,W.__webglColorRenderbuffer[ue]);let tt=r.convert(ye.format,ye.colorSpace),ae=r.convert(ye.type),_e=M(ye.internalFormat,tt,ae,ye.colorSpace,I.isXRRenderTarget===!0),Oe=qe(I);i.renderbufferStorageMultisample(i.RENDERBUFFER,Oe,_e,I.width,I.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ue,i.RENDERBUFFER,W.__webglColorRenderbuffer[ue])}i.bindRenderbuffer(i.RENDERBUFFER,null),I.depthBuffer&&(W.__webglDepthRenderbuffer=i.createRenderbuffer(),oe(W.__webglDepthRenderbuffer,I,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Q){t.bindTexture(i.TEXTURE_CUBE_MAP,ee.__webglTexture),J(i.TEXTURE_CUBE_MAP,w);for(let ue=0;ue<6;ue++)if(w.mipmaps&&w.mipmaps.length>0)for(let ye=0;ye<w.mipmaps.length;ye++)ne(W.__webglFramebuffer[ue][ye],I,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ue,ye);else ne(W.__webglFramebuffer[ue],I,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0);p(w)&&m(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(we){for(let ue=0,ye=ie.length;ue<ye;ue++){let tt=ie[ue],ae=n.get(tt);t.bindTexture(i.TEXTURE_2D,ae.__webglTexture),J(i.TEXTURE_2D,tt),ne(W.__webglFramebuffer,I,tt,i.COLOR_ATTACHMENT0+ue,i.TEXTURE_2D,0),p(tt)&&m(i.TEXTURE_2D)}t.unbindTexture()}else{let ue=i.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(ue=I.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,ee.__webglTexture),J(ue,w),w.mipmaps&&w.mipmaps.length>0)for(let ye=0;ye<w.mipmaps.length;ye++)ne(W.__webglFramebuffer[ye],I,w,i.COLOR_ATTACHMENT0,ue,ye);else ne(W.__webglFramebuffer,I,w,i.COLOR_ATTACHMENT0,ue,0);p(w)&&m(ue),t.unbindTexture()}I.depthBuffer&&Fe(I)}function ct(I){let w=I.textures;for(let W=0,ee=w.length;W<ee;W++){let ie=w[W];if(p(ie)){let Q=I.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,we=n.get(ie).__webglTexture;t.bindTexture(Q,we),m(Q),t.unbindTexture()}}}let $e=[],D=[];function _n(I){if(I.samples>0){if(et(I)===!1){let w=I.textures,W=I.width,ee=I.height,ie=i.COLOR_BUFFER_BIT,Q=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,we=n.get(I),ue=w.length>1;if(ue)for(let ye=0;ye<w.length;ye++)t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ye,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ye,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let ye=0;ye<w.length;ye++){if(I.resolveDepthBuffer&&(I.depthBuffer&&(ie|=i.DEPTH_BUFFER_BIT),I.stencilBuffer&&I.resolveStencilBuffer&&(ie|=i.STENCIL_BUFFER_BIT)),ue){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,we.__webglColorRenderbuffer[ye]);let tt=n.get(w[ye]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,tt,0)}i.blitFramebuffer(0,0,W,ee,0,0,W,ee,ie,i.NEAREST),l===!0&&($e.length=0,D.length=0,$e.push(i.COLOR_ATTACHMENT0+ye),I.depthBuffer&&I.resolveDepthBuffer===!1&&($e.push(Q),D.push(Q),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,D)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$e))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ue)for(let ye=0;ye<w.length;ye++){t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ye,i.RENDERBUFFER,we.__webglColorRenderbuffer[ye]);let tt=n.get(w[ye]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ye,i.TEXTURE_2D,tt,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}else if(I.depthBuffer&&I.resolveDepthBuffer===!1&&l){let w=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[w])}}}function qe(I){return Math.min(s.maxSamples,I.samples)}function et(I){let w=n.get(I);return I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function Ne(I){let w=o.render.frame;h.get(I)!==w&&(h.set(I,w),I.update())}function gt(I,w){let W=I.colorSpace,ee=I.format,ie=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||W!==qt&&W!==bi&&(je.getTransfer(W)===_t?(ee!==pn||ie!==Fi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),w}function Ue(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(c.width=I.naturalWidth||I.width,c.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(c.width=I.displayWidth,c.height=I.displayHeight):(c.width=I.width,c.height=I.height),c}this.allocateTextureUnit=x,this.resetTextureUnits=_,this.setTexture2D=P,this.setTexture2DArray=U,this.setTexture3D=N,this.setTextureCube=H,this.rebindTextures=Le,this.setupRenderTarget=Ze,this.updateRenderTargetMipmap=ct,this.updateMultisampleRenderTarget=_n,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=ne,this.useMultisampledRTT=et}function NE(i,e){function t(n,s=bi){let r,o=je.getTransfer(s);if(n===Fi)return i.UNSIGNED_BYTE;if(n===Ld)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Pd)return i.UNSIGNED_SHORT_5_5_5_1;if(n===qy)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Wy)return i.BYTE;if(n===Xy)return i.SHORT;if(n===sa)return i.UNSIGNED_SHORT;if(n===Cd)return i.INT;if(n===$s)return i.UNSIGNED_INT;if(n===ci)return i.FLOAT;if(n===ga)return i.HALF_FLOAT;if(n===Yy)return i.ALPHA;if(n===Ky)return i.RGB;if(n===pn)return i.RGBA;if(n===Zy)return i.LUMINANCE;if(n===$y)return i.LUMINANCE_ALPHA;if(n===Xr)return i.DEPTH_COMPONENT;if(n===jr)return i.DEPTH_STENCIL;if(n===Nd)return i.RED;if(n===Od)return i.RED_INTEGER;if(n===Jy)return i.RG;if(n===Dd)return i.RG_INTEGER;if(n===Ud)return i.RGBA_INTEGER;if(n===dc||n===pc||n===mc||n===gc)if(o===_t)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===dc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===pc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===mc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===gc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===dc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===pc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===mc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===gc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===If||n===Rf||n===Cf||n===Lf)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===If)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Rf)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Cf)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Lf)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Pf||n===Nf||n===Of)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Pf||n===Nf)return o===_t?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Of)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Df||n===Uf||n===Ff||n===Bf||n===kf||n===zf||n===Vf||n===Hf||n===Gf||n===Wf||n===Xf||n===qf||n===Yf||n===Kf)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Df)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Uf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ff)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Bf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===kf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===zf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Vf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Hf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Gf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Wf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Xf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===qf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Yf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Kf)return o===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===yc||n===Zf||n===$f)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===yc)return o===_t?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Zf)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$f)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===jy||n===Jf||n===jf||n===Qf)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===yc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Jf)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===jf)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Qf)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Jr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var pd=class extends kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Mi=class extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},OE={type:"move"},ia=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Mi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Mi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Mi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let g of e.hand.values()){let p=t.getJointPose(g,n),m=this._getHandJoint(c,g);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,y=.005;c.inputState.pinching&&f>d+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(OE)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Mi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},DE=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,UE=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`,md=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let s=new vt,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Yn({vertexShader:DE,fragmentShader:UE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new St(new Kn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},gd=class extends us{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,u=null,f=null,d=null,y=null,g=new md,p=t.getContextAttributes(),m=null,M=null,b=[],S=[],O=new Ve,L=null,R=new kt;R.layers.enable(1),R.viewport=new Qe;let C=new kt;C.layers.enable(2),C.viewport=new Qe;let j=[R,C],v=new pd;v.layers.enable(1),v.layers.enable(2);let _=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let ne=b[X];return ne===void 0&&(ne=new ia,b[X]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(X){let ne=b[X];return ne===void 0&&(ne=new ia,b[X]=ne),ne.getGripSpace()},this.getHand=function(X){let ne=b[X];return ne===void 0&&(ne=new ia,b[X]=ne),ne.getHandSpace()};function T(X){let ne=S.indexOf(X.inputSource);if(ne===-1)return;let oe=b[ne];oe!==void 0&&(oe.update(X.inputSource,X.frame,c||o),oe.dispatchEvent({type:X.type,data:X.inputSource}))}function P(){s.removeEventListener("select",T),s.removeEventListener("selectstart",T),s.removeEventListener("selectend",T),s.removeEventListener("squeeze",T),s.removeEventListener("squeezestart",T),s.removeEventListener("squeezeend",T),s.removeEventListener("end",P),s.removeEventListener("inputsourceschange",U);for(let X=0;X<b.length;X++){let ne=S[X];ne!==null&&(S[X]=null,b[X].disconnect(ne))}_=null,x=null,g.reset(),e.setRenderTarget(m),d=null,f=null,u=null,s=null,M=null,xe.stop(),n.isPresenting=!1,e.setPixelRatio(L),e.setSize(O.width,O.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){r=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){a=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return y},this.getSession=function(){return s},this.setSession=async function(X){if(s=X,s!==null){if(m=e.getRenderTarget(),s.addEventListener("select",T),s.addEventListener("selectstart",T),s.addEventListener("selectend",T),s.addEventListener("squeeze",T),s.addEventListener("squeezestart",T),s.addEventListener("squeezeend",T),s.addEventListener("end",P),s.addEventListener("inputsourceschange",U),p.xrCompatible!==!0&&await t.makeXRCompatible(),L=e.getPixelRatio(),e.getSize(O),s.renderState.layers===void 0){let ne={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),M=new Bi(d.framebufferWidth,d.framebufferHeight,{format:pn,type:Fi,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil})}else{let ne=null,oe=null,ge=null;p.depth&&(ge=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=p.stencil?jr:Xr,oe=p.stencil?Jr:$s);let Fe={colorFormat:t.RGBA8,depthFormat:ge,scaleFactor:r};u=new XRWebGLBinding(s,t),f=u.createProjectionLayer(Fe),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),M=new Bi(f.textureWidth,f.textureHeight,{format:pn,type:Fi,depthTexture:new Ic(f.textureWidth,f.textureHeight,oe,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),xe.setContext(s),xe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function U(X){for(let ne=0;ne<X.removed.length;ne++){let oe=X.removed[ne],ge=S.indexOf(oe);ge>=0&&(S[ge]=null,b[ge].disconnect(oe))}for(let ne=0;ne<X.added.length;ne++){let oe=X.added[ne],ge=S.indexOf(oe);if(ge===-1){for(let Le=0;Le<b.length;Le++)if(Le>=S.length){S.push(oe),ge=Le;break}else if(S[Le]===null){S[Le]=oe,ge=Le;break}if(ge===-1)break}let Fe=b[ge];Fe&&Fe.connect(oe)}}let N=new F,H=new F;function G(X,ne,oe){N.setFromMatrixPosition(ne.matrixWorld),H.setFromMatrixPosition(oe.matrixWorld);let ge=N.distanceTo(H),Fe=ne.projectionMatrix.elements,Le=oe.projectionMatrix.elements,Ze=Fe[14]/(Fe[10]-1),ct=Fe[14]/(Fe[10]+1),$e=(Fe[9]+1)/Fe[5],D=(Fe[9]-1)/Fe[5],_n=(Fe[8]-1)/Fe[0],qe=(Le[8]+1)/Le[0],et=Ze*_n,Ne=Ze*qe,gt=ge/(-_n+qe),Ue=gt*-_n;if(ne.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Ue),X.translateZ(gt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Fe[10]===-1)X.projectionMatrix.copy(ne.projectionMatrix),X.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{let I=Ze+gt,w=ct+gt,W=et-Ue,ee=Ne+(ge-Ue),ie=$e*ct/w*I,Q=D*ct/w*I;X.projectionMatrix.makePerspective(W,ee,ie,Q,I,w),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function $(X,ne){ne===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(ne.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(s===null)return;let ne=X.near,oe=X.far;g.texture!==null&&(g.depthNear>0&&(ne=g.depthNear),g.depthFar>0&&(oe=g.depthFar)),v.near=C.near=R.near=ne,v.far=C.far=R.far=oe,(_!==v.near||x!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),_=v.near,x=v.far);let ge=X.parent,Fe=v.cameras;$(v,ge);for(let Le=0;Le<Fe.length;Le++)$(Fe[Le],ge);Fe.length===2?G(v,R,C):v.projectionMatrix.copy(R.projectionMatrix),re(X,v,ge)};function re(X,ne,oe){oe===null?X.matrix.copy(ne.matrixWorld):(X.matrix.copy(oe.matrixWorld),X.matrix.invert(),X.matrix.multiply(ne.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(ne.projectionMatrix),X.projectionMatrixInverse.copy(ne.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Qr*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(f===null&&d===null))return l},this.setFoveation=function(X){l=X,f!==null&&(f.fixedFoveation=X),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=X)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(v)};let J=null;function V(X,ne){if(h=ne.getViewerPose(c||o),y=ne,h!==null){let oe=h.views;d!==null&&(e.setRenderTargetFramebuffer(M,d.framebuffer),e.setRenderTarget(M));let ge=!1;oe.length!==v.cameras.length&&(v.cameras.length=0,ge=!0);for(let Le=0;Le<oe.length;Le++){let Ze=oe[Le],ct=null;if(d!==null)ct=d.getViewport(Ze);else{let D=u.getViewSubImage(f,Ze);ct=D.viewport,Le===0&&(e.setRenderTargetTextures(M,D.colorTexture,f.ignoreDepthValues?void 0:D.depthStencilTexture),e.setRenderTarget(M))}let $e=j[Le];$e===void 0&&($e=new kt,$e.layers.enable(Le),$e.viewport=new Qe,j[Le]=$e),$e.matrix.fromArray(Ze.transform.matrix),$e.matrix.decompose($e.position,$e.quaternion,$e.scale),$e.projectionMatrix.fromArray(Ze.projectionMatrix),$e.projectionMatrixInverse.copy($e.projectionMatrix).invert(),$e.viewport.set(ct.x,ct.y,ct.width,ct.height),Le===0&&(v.matrix.copy($e.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),ge===!0&&v.cameras.push($e)}let Fe=s.enabledFeatures;if(Fe&&Fe.includes("depth-sensing")){let Le=u.getDepthInformation(oe[0]);Le&&Le.isValid&&Le.texture&&g.init(e,Le,s.renderState)}}for(let oe=0;oe<b.length;oe++){let ge=S[oe],Fe=b[oe];ge!==null&&Fe!==void 0&&Fe.update(ge,ne,c||o)}J&&J(X,ne),ne.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ne}),y=null}let xe=new r_;xe.setAnimationLoop(V),this.setAnimationLoop=function(X){J=X},this.dispose=function(){}}},Ws=new on,FE=new Ie;function BE(i,e){function t(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,s_(i)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function s(p,m,M,b,S){m.isMeshBasicMaterial||m.isMeshLambertMaterial?r(p,m):m.isMeshToonMaterial?(r(p,m),u(p,m)):m.isMeshPhongMaterial?(r(p,m),h(p,m)):m.isMeshStandardMaterial?(r(p,m),f(p,m),m.isMeshPhysicalMaterial&&d(p,m,S)):m.isMeshMatcapMaterial?(r(p,m),y(p,m)):m.isMeshDepthMaterial?r(p,m):m.isMeshDistanceMaterial?(r(p,m),g(p,m)):m.isMeshNormalMaterial?r(p,m):m.isLineBasicMaterial?(o(p,m),m.isLineDashedMaterial&&a(p,m)):m.isPointsMaterial?l(p,m,M,b):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,t(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===mn&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,t(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===mn&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,t(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,t(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let M=e.get(m),b=M.envMap,S=M.envMapRotation;b&&(p.envMap.value=b,Ws.copy(S),Ws.x*=-1,Ws.y*=-1,Ws.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Ws.y*=-1,Ws.z*=-1),p.envMapRotation.value.setFromMatrix4(FE.makeRotationFromEuler(Ws)),p.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,p.aoMapTransform))}function o(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform))}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,M,b){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*M,p.scale.value=b*.5,m.map&&(p.map.value=m.map,t(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function f(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function d(p,m,M){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===mn&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=M.texture,p.transmissionSamplerSize.value.set(M.width,M.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,p.specularIntensityMapTransform))}function y(p,m){m.matcap&&(p.matcap.value=m.matcap)}function g(p,m){let M=e.get(m).light;p.referencePosition.value.setFromMatrixPosition(M.matrixWorld),p.nearDistance.value=M.shadow.camera.near,p.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function kE(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,b){let S=b.program;n.uniformBlockBinding(M,S)}function c(M,b){let S=s[M.id];S===void 0&&(y(M),S=h(M),s[M.id]=S,M.addEventListener("dispose",p));let O=b.program;n.updateUBOMapping(M,O);let L=e.render.frame;r[M.id]!==L&&(f(M),r[M.id]=L)}function h(M){let b=u();M.__bindingPointIndex=b;let S=i.createBuffer(),O=M.__size,L=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,O,L),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,S),S}function u(){for(let M=0;M<a;M++)if(o.indexOf(M)===-1)return o.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(M){let b=s[M.id],S=M.uniforms,O=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let L=0,R=S.length;L<R;L++){let C=Array.isArray(S[L])?S[L]:[S[L]];for(let j=0,v=C.length;j<v;j++){let _=C[j];if(d(_,L,j,O)===!0){let x=_.__offset,T=Array.isArray(_.value)?_.value:[_.value],P=0;for(let U=0;U<T.length;U++){let N=T[U],H=g(N);typeof N=="number"||typeof N=="boolean"?(_.__data[0]=N,i.bufferSubData(i.UNIFORM_BUFFER,x+P,_.__data)):N.isMatrix3?(_.__data[0]=N.elements[0],_.__data[1]=N.elements[1],_.__data[2]=N.elements[2],_.__data[3]=0,_.__data[4]=N.elements[3],_.__data[5]=N.elements[4],_.__data[6]=N.elements[5],_.__data[7]=0,_.__data[8]=N.elements[6],_.__data[9]=N.elements[7],_.__data[10]=N.elements[8],_.__data[11]=0):(N.toArray(_.__data,P),P+=H.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,x,_.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(M,b,S,O){let L=M.value,R=b+"_"+S;if(O[R]===void 0)return typeof L=="number"||typeof L=="boolean"?O[R]=L:O[R]=L.clone(),!0;{let C=O[R];if(typeof L=="number"||typeof L=="boolean"){if(C!==L)return O[R]=L,!0}else if(C.equals(L)===!1)return C.copy(L),!0}return!1}function y(M){let b=M.uniforms,S=0,O=16;for(let R=0,C=b.length;R<C;R++){let j=Array.isArray(b[R])?b[R]:[b[R]];for(let v=0,_=j.length;v<_;v++){let x=j[v],T=Array.isArray(x.value)?x.value:[x.value];for(let P=0,U=T.length;P<U;P++){let N=T[P],H=g(N),G=S%O,$=G%H.boundary,re=G+$;S+=$,re!==0&&O-re<H.storage&&(S+=O-re),x.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),x.__offset=S,S+=H.storage}}}let L=S%O;return L>0&&(S+=O-L),M.__size=S,M.__cache={},this}function g(M){let b={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(b.boundary=4,b.storage=4):M.isVector2?(b.boundary=8,b.storage=8):M.isVector3||M.isColor?(b.boundary=16,b.storage=12):M.isVector4?(b.boundary=16,b.storage=16):M.isMatrix3?(b.boundary=48,b.storage=48):M.isMatrix4?(b.boundary=64,b.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),b}function p(M){let b=M.target;b.removeEventListener("dispose",p);let S=o.indexOf(b.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function m(){for(let M in s)i.deleteBuffer(s[M]);o=[],s={},r={}}return{bind:l,update:c,dispose:m}}var ds=class{constructor(e={}){let{canvas:t=HM(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=o;let d=new Uint32Array(4),y=new Int32Array(4),g=null,p=null,m=[],M=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Nt,this.toneMapping=ls,this.toneMappingExposure=1;let b=this,S=!1,O=0,L=0,R=null,C=-1,j=null,v=new Qe,_=new Qe,x=null,T=new Re(0),P=0,U=t.width,N=t.height,H=1,G=null,$=null,re=new Qe(0,0,U,N),J=new Qe(0,0,U,N),V=!1,xe=new aa,X=!1,ne=!1,oe=new Ie,ge=new Ie,Fe=new F,Le=new Qe,Ze={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ct=!1;function $e(){return R===null?H:1}let D=n;function _n(A,k){return t.getContext(A,k)}try{let A={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${pa}`),t.addEventListener("webglcontextlost",te,!1),t.addEventListener("webglcontextrestored",fe,!1),t.addEventListener("webglcontextcreationerror",me,!1),D===null){let k="webgl2";if(D=_n(k,A),D===null)throw _n(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let qe,et,Ne,gt,Ue,I,w,W,ee,ie,Q,we,ue,ye,tt,ae,_e,Oe,De,ve,Ye,Be,dt,B;function pe(){qe=new t1(D),qe.init(),Be=new NE(D,qe),et=new ZA(D,qe,e,Be),Ne=new CE(D),et.reverseDepthBuffer&&Ne.buffers.depth.setReversed(!0),gt=new s1(D),Ue=new yE,I=new PE(D,qe,Ne,Ue,et,Be,gt),w=new JA(b),W=new e1(b),ee=new uS(D),dt=new YA(D,ee),ie=new n1(D,ee,gt,dt),Q=new o1(D,ie,ee,gt),De=new r1(D,et,I),ae=new $A(Ue),we=new gE(b,w,W,qe,et,dt,ae),ue=new BE(b,Ue),ye=new vE,tt=new AE(qe),Oe=new qA(b,w,W,Ne,Q,f,l),_e=new IE(b,Q,et),B=new kE(D,gt,et,Ne),ve=new KA(D,qe,gt),Ye=new i1(D,qe,gt),gt.programs=we.programs,b.capabilities=et,b.extensions=qe,b.properties=Ue,b.renderLists=ye,b.shadowMap=_e,b.state=Ne,b.info=gt}pe();let Z=new gd(b,D);this.xr=Z,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let A=qe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){let A=qe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(A){A!==void 0&&(H=A,this.setSize(U,N,!1))},this.getSize=function(A){return A.set(U,N)},this.setSize=function(A,k,q=!0){if(Z.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}U=A,N=k,t.width=Math.floor(A*H),t.height=Math.floor(k*H),q===!0&&(t.style.width=A+"px",t.style.height=k+"px"),this.setViewport(0,0,A,k)},this.getDrawingBufferSize=function(A){return A.set(U*H,N*H).floor()},this.setDrawingBufferSize=function(A,k,q){U=A,N=k,H=q,t.width=Math.floor(A*q),t.height=Math.floor(k*q),this.setViewport(0,0,A,k)},this.getCurrentViewport=function(A){return A.copy(v)},this.getViewport=function(A){return A.copy(re)},this.setViewport=function(A,k,q,K){A.isVector4?re.set(A.x,A.y,A.z,A.w):re.set(A,k,q,K),Ne.viewport(v.copy(re).multiplyScalar(H).round())},this.getScissor=function(A){return A.copy(J)},this.setScissor=function(A,k,q,K){A.isVector4?J.set(A.x,A.y,A.z,A.w):J.set(A,k,q,K),Ne.scissor(_.copy(J).multiplyScalar(H).round())},this.getScissorTest=function(){return V},this.setScissorTest=function(A){Ne.setScissorTest(V=A)},this.setOpaqueSort=function(A){G=A},this.setTransparentSort=function(A){$=A},this.getClearColor=function(A){return A.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor.apply(Oe,arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha.apply(Oe,arguments)},this.clear=function(A=!0,k=!0,q=!0){let K=0;if(A){let z=!1;if(R!==null){let le=R.texture.format;z=le===Ud||le===Dd||le===Od}if(z){let le=R.texture.type,de=le===Fi||le===$s||le===sa||le===Jr||le===Ld||le===Pd,be=Oe.getClearColor(),Se=Oe.getClearAlpha(),Ce=be.r,Pe=be.g,Ae=be.b;de?(d[0]=Ce,d[1]=Pe,d[2]=Ae,d[3]=Se,D.clearBufferuiv(D.COLOR,0,d)):(y[0]=Ce,y[1]=Pe,y[2]=Ae,y[3]=Se,D.clearBufferiv(D.COLOR,0,y))}else K|=D.COLOR_BUFFER_BIT}k&&(K|=D.DEPTH_BUFFER_BIT,D.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),q&&(K|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(K)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",te,!1),t.removeEventListener("webglcontextrestored",fe,!1),t.removeEventListener("webglcontextcreationerror",me,!1),ye.dispose(),tt.dispose(),Ue.dispose(),w.dispose(),W.dispose(),Q.dispose(),dt.dispose(),B.dispose(),we.dispose(),Z.dispose(),Z.removeEventListener("sessionstart",qp),Z.removeEventListener("sessionend",Yp),bs.stop()};function te(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function fe(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;let A=gt.autoReset,k=_e.enabled,q=_e.autoUpdate,K=_e.needsUpdate,z=_e.type;pe(),gt.autoReset=A,_e.enabled=k,_e.autoUpdate=q,_e.needsUpdate=K,_e.type=z}function me(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Je(A){let k=A.target;k.removeEventListener("dispose",Je),It(k)}function It(A){cn(A),Ue.remove(A)}function cn(A){let k=Ue.get(A).programs;k!==void 0&&(k.forEach(function(q){we.releaseProgram(q)}),A.isShaderMaterial&&we.releaseShaderCache(A))}this.renderBufferDirect=function(A,k,q,K,z,le){k===null&&(k=Ze);let de=z.isMesh&&z.matrixWorld.determinant()<0,be=O_(A,k,q,K,z);Ne.setMaterial(K,de);let Se=q.index,Ce=1;if(K.wireframe===!0){if(Se=ie.getWireframeAttribute(q),Se===void 0)return;Ce=2}let Pe=q.drawRange,Ae=q.attributes.position,at=Pe.start*Ce,yt=(Pe.start+Pe.count)*Ce;le!==null&&(at=Math.max(at,le.start*Ce),yt=Math.min(yt,(le.start+le.count)*Ce)),Se!==null?(at=Math.max(at,0),yt=Math.min(yt,Se.count)):Ae!=null&&(at=Math.max(at,0),yt=Math.min(yt,Ae.count));let xt=yt-at;if(xt<0||xt===1/0)return;dt.setup(z,K,be,q,Se);let vn,rt=ve;if(Se!==null&&(vn=ee.get(Se),rt=Ye,rt.setIndex(vn)),z.isMesh)K.wireframe===!0?(Ne.setLineWidth(K.wireframeLinewidth*$e()),rt.setMode(D.LINES)):rt.setMode(D.TRIANGLES);else if(z.isLine){let Te=K.linewidth;Te===void 0&&(Te=1),Ne.setLineWidth(Te*$e()),z.isLineSegments?rt.setMode(D.LINES):z.isLineLoop?rt.setMode(D.LINE_LOOP):rt.setMode(D.LINE_STRIP)}else z.isPoints?rt.setMode(D.POINTS):z.isSprite&&rt.setMode(D.TRIANGLES);if(z.isBatchedMesh)if(z._multiDrawInstances!==null)rt.renderMultiDrawInstances(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount,z._multiDrawInstances);else if(qe.get("WEBGL_multi_draw"))rt.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{let Te=z._multiDrawStarts,Yt=z._multiDrawCounts,ot=z._multiDrawCount,jn=Se?ee.get(Se).bytesPerElement:1,ar=Ue.get(K).currentProgram.getUniforms();for(let xn=0;xn<ot;xn++)ar.setValue(D,"_gl_DrawID",xn),rt.render(Te[xn]/jn,Yt[xn])}else if(z.isInstancedMesh)rt.renderInstances(at,xt,z.count);else if(q.isInstancedBufferGeometry){let Te=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Yt=Math.min(q.instanceCount,Te);rt.renderInstances(at,xt,Yt)}else rt.render(at,xt)};function nt(A,k,q){A.transparent===!0&&A.side===Nn&&A.forceSinglePass===!1?(A.side=mn,A.needsUpdate=!0,Oa(A,k,q),A.side=Si,A.needsUpdate=!0,Oa(A,k,q),A.side=Nn):Oa(A,k,q)}this.compile=function(A,k,q=null){q===null&&(q=A),p=tt.get(q),p.init(k),M.push(p),q.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(p.pushLight(z),z.castShadow&&p.pushShadow(z))}),A!==q&&A.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(p.pushLight(z),z.castShadow&&p.pushShadow(z))}),p.setupLights();let K=new Set;return A.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let le=z.material;if(le)if(Array.isArray(le))for(let de=0;de<le.length;de++){let be=le[de];nt(be,q,z),K.add(be)}else nt(le,q,z),K.add(le)}),M.pop(),p=null,K},this.compileAsync=function(A,k,q=null){let K=this.compile(A,k,q);return new Promise(z=>{function le(){if(K.forEach(function(de){Ue.get(de).currentProgram.isReady()&&K.delete(de)}),K.size===0){z(A);return}setTimeout(le,10)}qe.get("KHR_parallel_shader_compile")!==null?le():setTimeout(le,10)})};let hn=null;function wi(A){hn&&hn(A)}function qp(){bs.stop()}function Yp(){bs.start()}let bs=new r_;bs.setAnimationLoop(wi),typeof self<"u"&&bs.setContext(self),this.setAnimationLoop=function(A){hn=A,Z.setAnimationLoop(A),A===null?bs.stop():bs.start()},Z.addEventListener("sessionstart",qp),Z.addEventListener("sessionend",Yp),this.render=function(A,k){if(k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),Z.enabled===!0&&Z.isPresenting===!0&&(Z.cameraAutoUpdate===!0&&Z.updateCamera(k),k=Z.getCamera()),A.isScene===!0&&A.onBeforeRender(b,A,k,R),p=tt.get(A,M.length),p.init(k),M.push(p),ge.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),xe.setFromProjectionMatrix(ge),ne=this.localClippingEnabled,X=ae.init(this.clippingPlanes,ne),g=ye.get(A,m.length),g.init(),m.push(g),Z.enabled===!0&&Z.isPresenting===!0){let le=b.xr.getDepthSensingMesh();le!==null&&ch(le,k,-1/0,b.sortObjects)}ch(A,k,0,b.sortObjects),g.finish(),b.sortObjects===!0&&g.sort(G,$),ct=Z.enabled===!1||Z.isPresenting===!1||Z.hasDepthSensing()===!1,ct&&Oe.addToRenderList(g,A),this.info.render.frame++,X===!0&&ae.beginShadows();let q=p.state.shadowsArray;_e.render(q,A,k),X===!0&&ae.endShadows(),this.info.autoReset===!0&&this.info.reset();let K=g.opaque,z=g.transmissive;if(p.setupLights(),k.isArrayCamera){let le=k.cameras;if(z.length>0)for(let de=0,be=le.length;de<be;de++){let Se=le[de];Zp(K,z,A,Se)}ct&&Oe.render(A);for(let de=0,be=le.length;de<be;de++){let Se=le[de];Kp(g,A,Se,Se.viewport)}}else z.length>0&&Zp(K,z,A,k),ct&&Oe.render(A),Kp(g,A,k);R!==null&&(I.updateMultisampleRenderTarget(R),I.updateRenderTargetMipmap(R)),A.isScene===!0&&A.onAfterRender(b,A,k),dt.resetDefaultState(),C=-1,j=null,M.pop(),M.length>0?(p=M[M.length-1],X===!0&&ae.setGlobalState(b.clippingPlanes,p.state.camera)):p=null,m.pop(),m.length>0?g=m[m.length-1]:g=null};function ch(A,k,q,K){if(A.visible===!1)return;if(A.layers.test(k.layers)){if(A.isGroup)q=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(k);else if(A.isLight)p.pushLight(A),A.castShadow&&p.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||xe.intersectsSprite(A)){K&&Le.setFromMatrixPosition(A.matrixWorld).applyMatrix4(ge);let de=Q.update(A),be=A.material;be.visible&&g.push(A,de,be,q,Le.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||xe.intersectsObject(A))){let de=Q.update(A),be=A.material;if(K&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),Le.copy(A.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),Le.copy(de.boundingSphere.center)),Le.applyMatrix4(A.matrixWorld).applyMatrix4(ge)),Array.isArray(be)){let Se=de.groups;for(let Ce=0,Pe=Se.length;Ce<Pe;Ce++){let Ae=Se[Ce],at=be[Ae.materialIndex];at&&at.visible&&g.push(A,de,at,q,Le.z,Ae)}}else be.visible&&g.push(A,de,be,q,Le.z,null)}}let le=A.children;for(let de=0,be=le.length;de<be;de++)ch(le[de],k,q,K)}function Kp(A,k,q,K){let z=A.opaque,le=A.transmissive,de=A.transparent;p.setupLightsView(q),X===!0&&ae.setGlobalState(b.clippingPlanes,q),K&&Ne.viewport(v.copy(K)),z.length>0&&Na(z,k,q),le.length>0&&Na(le,k,q),de.length>0&&Na(de,k,q),Ne.buffers.depth.setTest(!0),Ne.buffers.depth.setMask(!0),Ne.buffers.color.setMask(!0),Ne.setPolygonOffset(!1)}function Zp(A,k,q,K){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[K.id]===void 0&&(p.state.transmissionRenderTarget[K.id]=new Bi(1,1,{generateMipmaps:!0,type:qe.has("EXT_color_buffer_half_float")||qe.has("EXT_color_buffer_float")?ga:Fi,minFilter:Wn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:je.workingColorSpace}));let le=p.state.transmissionRenderTarget[K.id],de=K.viewport||v;le.setSize(de.z,de.w);let be=b.getRenderTarget();b.setRenderTarget(le),b.getClearColor(T),P=b.getClearAlpha(),P<1&&b.setClearColor(16777215,.5),b.clear(),ct&&Oe.render(q);let Se=b.toneMapping;b.toneMapping=ls;let Ce=K.viewport;if(K.viewport!==void 0&&(K.viewport=void 0),p.setupLightsView(K),X===!0&&ae.setGlobalState(b.clippingPlanes,K),Na(A,q,K),I.updateMultisampleRenderTarget(le),I.updateRenderTargetMipmap(le),qe.has("WEBGL_multisampled_render_to_texture")===!1){let Pe=!1;for(let Ae=0,at=k.length;Ae<at;Ae++){let yt=k[Ae],xt=yt.object,vn=yt.geometry,rt=yt.material,Te=yt.group;if(rt.side===Nn&&xt.layers.test(K.layers)){let Yt=rt.side;rt.side=mn,rt.needsUpdate=!0,$p(xt,q,K,vn,rt,Te),rt.side=Yt,rt.needsUpdate=!0,Pe=!0}}Pe===!0&&(I.updateMultisampleRenderTarget(le),I.updateRenderTargetMipmap(le))}b.setRenderTarget(be),b.setClearColor(T,P),Ce!==void 0&&(K.viewport=Ce),b.toneMapping=Se}function Na(A,k,q){let K=k.isScene===!0?k.overrideMaterial:null;for(let z=0,le=A.length;z<le;z++){let de=A[z],be=de.object,Se=de.geometry,Ce=K===null?de.material:K,Pe=de.group;be.layers.test(q.layers)&&$p(be,k,q,Se,Ce,Pe)}}function $p(A,k,q,K,z,le){A.onBeforeRender(b,k,q,K,z,le),A.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),z.onBeforeRender(b,k,q,K,A,le),z.transparent===!0&&z.side===Nn&&z.forceSinglePass===!1?(z.side=mn,z.needsUpdate=!0,b.renderBufferDirect(q,k,K,z,A,le),z.side=Si,z.needsUpdate=!0,b.renderBufferDirect(q,k,K,z,A,le),z.side=Nn):b.renderBufferDirect(q,k,K,z,A,le),A.onAfterRender(b,k,q,K,z,le)}function Oa(A,k,q){k.isScene!==!0&&(k=Ze);let K=Ue.get(A),z=p.state.lights,le=p.state.shadowsArray,de=z.state.version,be=we.getParameters(A,z.state,le,k,q),Se=we.getProgramCacheKey(be),Ce=K.programs;K.environment=A.isMeshStandardMaterial?k.environment:null,K.fog=k.fog,K.envMap=(A.isMeshStandardMaterial?W:w).get(A.envMap||K.environment),K.envMapRotation=K.environment!==null&&A.envMap===null?k.environmentRotation:A.envMapRotation,Ce===void 0&&(A.addEventListener("dispose",Je),Ce=new Map,K.programs=Ce);let Pe=Ce.get(Se);if(Pe!==void 0){if(K.currentProgram===Pe&&K.lightsStateVersion===de)return jp(A,be),Pe}else be.uniforms=we.getUniforms(A),A.onBeforeCompile(be,b),Pe=we.acquireProgram(be,Se),Ce.set(Se,Pe),K.uniforms=be.uniforms;let Ae=K.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Ae.clippingPlanes=ae.uniform),jp(A,be),K.needsLights=U_(A),K.lightsStateVersion=de,K.needsLights&&(Ae.ambientLightColor.value=z.state.ambient,Ae.lightProbe.value=z.state.probe,Ae.directionalLights.value=z.state.directional,Ae.directionalLightShadows.value=z.state.directionalShadow,Ae.spotLights.value=z.state.spot,Ae.spotLightShadows.value=z.state.spotShadow,Ae.rectAreaLights.value=z.state.rectArea,Ae.ltc_1.value=z.state.rectAreaLTC1,Ae.ltc_2.value=z.state.rectAreaLTC2,Ae.pointLights.value=z.state.point,Ae.pointLightShadows.value=z.state.pointShadow,Ae.hemisphereLights.value=z.state.hemi,Ae.directionalShadowMap.value=z.state.directionalShadowMap,Ae.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Ae.spotShadowMap.value=z.state.spotShadowMap,Ae.spotLightMatrix.value=z.state.spotLightMatrix,Ae.spotLightMap.value=z.state.spotLightMap,Ae.pointShadowMap.value=z.state.pointShadowMap,Ae.pointShadowMatrix.value=z.state.pointShadowMatrix),K.currentProgram=Pe,K.uniformsList=null,Pe}function Jp(A){if(A.uniformsList===null){let k=A.currentProgram.getUniforms();A.uniformsList=Yr.seqWithValue(k.seq,A.uniforms)}return A.uniformsList}function jp(A,k){let q=Ue.get(A);q.outputColorSpace=k.outputColorSpace,q.batching=k.batching,q.batchingColor=k.batchingColor,q.instancing=k.instancing,q.instancingColor=k.instancingColor,q.instancingMorph=k.instancingMorph,q.skinning=k.skinning,q.morphTargets=k.morphTargets,q.morphNormals=k.morphNormals,q.morphColors=k.morphColors,q.morphTargetsCount=k.morphTargetsCount,q.numClippingPlanes=k.numClippingPlanes,q.numIntersection=k.numClipIntersection,q.vertexAlphas=k.vertexAlphas,q.vertexTangents=k.vertexTangents,q.toneMapping=k.toneMapping}function O_(A,k,q,K,z){k.isScene!==!0&&(k=Ze),I.resetTextureUnits();let le=k.fog,de=K.isMeshStandardMaterial?k.environment:null,be=R===null?b.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:qt,Se=(K.isMeshStandardMaterial?W:w).get(K.envMap||de),Ce=K.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Pe=!!q.attributes.tangent&&(!!K.normalMap||K.anisotropy>0),Ae=!!q.morphAttributes.position,at=!!q.morphAttributes.normal,yt=!!q.morphAttributes.color,xt=ls;K.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(xt=b.toneMapping);let vn=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,rt=vn!==void 0?vn.length:0,Te=Ue.get(K),Yt=p.state.lights;if(X===!0&&(ne===!0||A!==j)){let Vn=A===j&&K.id===C;ae.setState(K,A,Vn)}let ot=!1;K.version===Te.__version?(Te.needsLights&&Te.lightsStateVersion!==Yt.state.version||Te.outputColorSpace!==be||z.isBatchedMesh&&Te.batching===!1||!z.isBatchedMesh&&Te.batching===!0||z.isBatchedMesh&&Te.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Te.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Te.instancing===!1||!z.isInstancedMesh&&Te.instancing===!0||z.isSkinnedMesh&&Te.skinning===!1||!z.isSkinnedMesh&&Te.skinning===!0||z.isInstancedMesh&&Te.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Te.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Te.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Te.instancingMorph===!1&&z.morphTexture!==null||Te.envMap!==Se||K.fog===!0&&Te.fog!==le||Te.numClippingPlanes!==void 0&&(Te.numClippingPlanes!==ae.numPlanes||Te.numIntersection!==ae.numIntersection)||Te.vertexAlphas!==Ce||Te.vertexTangents!==Pe||Te.morphTargets!==Ae||Te.morphNormals!==at||Te.morphColors!==yt||Te.toneMapping!==xt||Te.morphTargetsCount!==rt)&&(ot=!0):(ot=!0,Te.__version=K.version);let jn=Te.currentProgram;ot===!0&&(jn=Oa(K,k,z));let ar=!1,xn=!1,hh=!1,At=jn.getUniforms(),Xi=Te.uniforms;if(Ne.useProgram(jn.program)&&(ar=!0,xn=!0,hh=!0),K.id!==C&&(C=K.id,xn=!0),ar||j!==A){et.reverseDepthBuffer?(oe.copy(A.projectionMatrix),WM(oe),XM(oe),At.setValue(D,"projectionMatrix",oe)):At.setValue(D,"projectionMatrix",A.projectionMatrix),At.setValue(D,"viewMatrix",A.matrixWorldInverse);let Vn=At.map.cameraPosition;Vn!==void 0&&Vn.setValue(D,Fe.setFromMatrixPosition(A.matrixWorld)),et.logarithmicDepthBuffer&&At.setValue(D,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&At.setValue(D,"isOrthographic",A.isOrthographicCamera===!0),j!==A&&(j=A,xn=!0,hh=!0)}if(z.isSkinnedMesh){At.setOptional(D,z,"bindMatrix"),At.setOptional(D,z,"bindMatrixInverse");let Vn=z.skeleton;Vn&&(Vn.boneTexture===null&&Vn.computeBoneTexture(),At.setValue(D,"boneTexture",Vn.boneTexture,I))}z.isBatchedMesh&&(At.setOptional(D,z,"batchingTexture"),At.setValue(D,"batchingTexture",z._matricesTexture,I),At.setOptional(D,z,"batchingIdTexture"),At.setValue(D,"batchingIdTexture",z._indirectTexture,I),At.setOptional(D,z,"batchingColorTexture"),z._colorsTexture!==null&&At.setValue(D,"batchingColorTexture",z._colorsTexture,I));let uh=q.morphAttributes;if((uh.position!==void 0||uh.normal!==void 0||uh.color!==void 0)&&De.update(z,q,jn),(xn||Te.receiveShadow!==z.receiveShadow)&&(Te.receiveShadow=z.receiveShadow,At.setValue(D,"receiveShadow",z.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(Xi.envMap.value=Se,Xi.flipEnvMap.value=Se.isCubeTexture&&Se.isRenderTargetTexture===!1?-1:1),K.isMeshStandardMaterial&&K.envMap===null&&k.environment!==null&&(Xi.envMapIntensity.value=k.environmentIntensity),xn&&(At.setValue(D,"toneMappingExposure",b.toneMappingExposure),Te.needsLights&&D_(Xi,hh),le&&K.fog===!0&&ue.refreshFogUniforms(Xi,le),ue.refreshMaterialUniforms(Xi,K,H,N,p.state.transmissionRenderTarget[A.id]),Yr.upload(D,Jp(Te),Xi,I)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(Yr.upload(D,Jp(Te),Xi,I),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&At.setValue(D,"center",z.center),At.setValue(D,"modelViewMatrix",z.modelViewMatrix),At.setValue(D,"normalMatrix",z.normalMatrix),At.setValue(D,"modelMatrix",z.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){let Vn=K.uniformsGroups;for(let fh=0,F_=Vn.length;fh<F_;fh++){let Qp=Vn[fh];B.update(Qp,jn),B.bind(Qp,jn)}}return jn}function D_(A,k){A.ambientLightColor.needsUpdate=k,A.lightProbe.needsUpdate=k,A.directionalLights.needsUpdate=k,A.directionalLightShadows.needsUpdate=k,A.pointLights.needsUpdate=k,A.pointLightShadows.needsUpdate=k,A.spotLights.needsUpdate=k,A.spotLightShadows.needsUpdate=k,A.rectAreaLights.needsUpdate=k,A.hemisphereLights.needsUpdate=k}function U_(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(A,k,q){Ue.get(A.texture).__webglTexture=k,Ue.get(A.depthTexture).__webglTexture=q;let K=Ue.get(A);K.__hasExternalTextures=!0,K.__autoAllocateDepthBuffer=q===void 0,K.__autoAllocateDepthBuffer||qe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),K.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,k){let q=Ue.get(A);q.__webglFramebuffer=k,q.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(A,k=0,q=0){R=A,O=k,L=q;let K=!0,z=null,le=!1,de=!1;if(A){let Se=Ue.get(A);if(Se.__useDefaultFramebuffer!==void 0)Ne.bindFramebuffer(D.FRAMEBUFFER,null),K=!1;else if(Se.__webglFramebuffer===void 0)I.setupRenderTarget(A);else if(Se.__hasExternalTextures)I.rebindTextures(A,Ue.get(A.texture).__webglTexture,Ue.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){let Ae=A.depthTexture;if(Se.__boundDepthTexture!==Ae){if(Ae!==null&&Ue.has(Ae)&&(A.width!==Ae.image.width||A.height!==Ae.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");I.setupDepthRenderbuffer(A)}}let Ce=A.texture;(Ce.isData3DTexture||Ce.isDataArrayTexture||Ce.isCompressedArrayTexture)&&(de=!0);let Pe=Ue.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Pe[k])?z=Pe[k][q]:z=Pe[k],le=!0):A.samples>0&&I.useMultisampledRTT(A)===!1?z=Ue.get(A).__webglMultisampledFramebuffer:Array.isArray(Pe)?z=Pe[q]:z=Pe,v.copy(A.viewport),_.copy(A.scissor),x=A.scissorTest}else v.copy(re).multiplyScalar(H).floor(),_.copy(J).multiplyScalar(H).floor(),x=V;if(Ne.bindFramebuffer(D.FRAMEBUFFER,z)&&K&&Ne.drawBuffers(A,z),Ne.viewport(v),Ne.scissor(_),Ne.setScissorTest(x),le){let Se=Ue.get(A.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+k,Se.__webglTexture,q)}else if(de){let Se=Ue.get(A.texture),Ce=k||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,Se.__webglTexture,q||0,Ce)}C=-1},this.readRenderTargetPixels=function(A,k,q,K,z,le,de){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=Ue.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&de!==void 0&&(be=be[de]),be){Ne.bindFramebuffer(D.FRAMEBUFFER,be);try{let Se=A.texture,Ce=Se.format,Pe=Se.type;if(!et.textureFormatReadable(Ce)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!et.textureTypeReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=A.width-K&&q>=0&&q<=A.height-z&&D.readPixels(k,q,K,z,Be.convert(Ce),Be.convert(Pe),le)}finally{let Se=R!==null?Ue.get(R).__webglFramebuffer:null;Ne.bindFramebuffer(D.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(A,k,q,K,z,le,de){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=Ue.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&de!==void 0&&(be=be[de]),be){let Se=A.texture,Ce=Se.format,Pe=Se.type;if(!et.textureFormatReadable(Ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(k>=0&&k<=A.width-K&&q>=0&&q<=A.height-z){Ne.bindFramebuffer(D.FRAMEBUFFER,be);let Ae=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ae),D.bufferData(D.PIXEL_PACK_BUFFER,le.byteLength,D.STREAM_READ),D.readPixels(k,q,K,z,Be.convert(Ce),Be.convert(Pe),0);let at=R!==null?Ue.get(R).__webglFramebuffer:null;Ne.bindFramebuffer(D.FRAMEBUFFER,at);let yt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await GM(D,yt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ae),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,le),D.deleteBuffer(Ae),D.deleteSync(yt),le}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,k=null,q=0){A.isTexture!==!0&&(_c("WebGLRenderer: copyFramebufferToTexture function signature has changed."),k=arguments[0]||null,A=arguments[1]);let K=Math.pow(2,-q),z=Math.floor(A.image.width*K),le=Math.floor(A.image.height*K),de=k!==null?k.x:0,be=k!==null?k.y:0;I.setTexture2D(A,0),D.copyTexSubImage2D(D.TEXTURE_2D,q,0,0,de,be,z,le),Ne.unbindTexture()},this.copyTextureToTexture=function(A,k,q=null,K=null,z=0){A.isTexture!==!0&&(_c("WebGLRenderer: copyTextureToTexture function signature has changed."),K=arguments[0]||null,A=arguments[1],k=arguments[2],z=arguments[3]||0,q=null);let le,de,be,Se,Ce,Pe;q!==null?(le=q.max.x-q.min.x,de=q.max.y-q.min.y,be=q.min.x,Se=q.min.y):(le=A.image.width,de=A.image.height,be=0,Se=0),K!==null?(Ce=K.x,Pe=K.y):(Ce=0,Pe=0);let Ae=Be.convert(k.format),at=Be.convert(k.type);I.setTexture2D(k,0),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,k.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,k.unpackAlignment);let yt=D.getParameter(D.UNPACK_ROW_LENGTH),xt=D.getParameter(D.UNPACK_IMAGE_HEIGHT),vn=D.getParameter(D.UNPACK_SKIP_PIXELS),rt=D.getParameter(D.UNPACK_SKIP_ROWS),Te=D.getParameter(D.UNPACK_SKIP_IMAGES),Yt=A.isCompressedTexture?A.mipmaps[z]:A.image;D.pixelStorei(D.UNPACK_ROW_LENGTH,Yt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Yt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,be),D.pixelStorei(D.UNPACK_SKIP_ROWS,Se),A.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,z,Ce,Pe,le,de,Ae,at,Yt.data):A.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,z,Ce,Pe,Yt.width,Yt.height,Ae,Yt.data):D.texSubImage2D(D.TEXTURE_2D,z,Ce,Pe,le,de,Ae,at,Yt),D.pixelStorei(D.UNPACK_ROW_LENGTH,yt),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,xt),D.pixelStorei(D.UNPACK_SKIP_PIXELS,vn),D.pixelStorei(D.UNPACK_SKIP_ROWS,rt),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Te),z===0&&k.generateMipmaps&&D.generateMipmap(D.TEXTURE_2D),Ne.unbindTexture()},this.copyTextureToTexture3D=function(A,k,q=null,K=null,z=0){A.isTexture!==!0&&(_c("WebGLRenderer: copyTextureToTexture3D function signature has changed."),q=arguments[0]||null,K=arguments[1]||null,A=arguments[2],k=arguments[3],z=arguments[4]||0);let le,de,be,Se,Ce,Pe,Ae,at,yt,xt=A.isCompressedTexture?A.mipmaps[z]:A.image;q!==null?(le=q.max.x-q.min.x,de=q.max.y-q.min.y,be=q.max.z-q.min.z,Se=q.min.x,Ce=q.min.y,Pe=q.min.z):(le=xt.width,de=xt.height,be=xt.depth,Se=0,Ce=0,Pe=0),K!==null?(Ae=K.x,at=K.y,yt=K.z):(Ae=0,at=0,yt=0);let vn=Be.convert(k.format),rt=Be.convert(k.type),Te;if(k.isData3DTexture)I.setTexture3D(k,0),Te=D.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)I.setTexture2DArray(k,0),Te=D.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,k.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,k.unpackAlignment);let Yt=D.getParameter(D.UNPACK_ROW_LENGTH),ot=D.getParameter(D.UNPACK_IMAGE_HEIGHT),jn=D.getParameter(D.UNPACK_SKIP_PIXELS),ar=D.getParameter(D.UNPACK_SKIP_ROWS),xn=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,xt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,xt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Se),D.pixelStorei(D.UNPACK_SKIP_ROWS,Ce),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Pe),A.isDataTexture||A.isData3DTexture?D.texSubImage3D(Te,z,Ae,at,yt,le,de,be,vn,rt,xt.data):k.isCompressedArrayTexture?D.compressedTexSubImage3D(Te,z,Ae,at,yt,le,de,be,vn,xt.data):D.texSubImage3D(Te,z,Ae,at,yt,le,de,be,vn,rt,xt),D.pixelStorei(D.UNPACK_ROW_LENGTH,Yt),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ot),D.pixelStorei(D.UNPACK_SKIP_PIXELS,jn),D.pixelStorei(D.UNPACK_SKIP_ROWS,ar),D.pixelStorei(D.UNPACK_SKIP_IMAGES,xn),z===0&&k.generateMipmaps&&D.generateMipmap(Te),Ne.unbindTexture()},this.initRenderTarget=function(A){Ue.get(A).__webglFramebuffer===void 0&&I.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?I.setTextureCube(A,0):A.isData3DTexture?I.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?I.setTexture2DArray(A,0):I.setTexture2D(A,0),Ne.unbindTexture()},this.resetState=function(){O=0,L=0,R=null,Ne.reset(),dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Fd?"display-p3":"srgb",t.unpackColorSpace=je.workingColorSpace===Kc?"display-p3":"srgb"}};var Bn=class extends ut{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new on,this.environmentIntensity=1,this.environmentRotation=new on,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},la=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ed,this.updateRanges=[],this.version=0,this.uuid=hi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},an=new F,Qs=class{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ai(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=lt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ai(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ai(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ai(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ai(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),s=lt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),s=lt(s,this.array),r=lt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new ft(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Qs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var by=new F,My=new Qe,Sy=new Qe,zE=new F,wy=new Ie,oc=new F,ff=new Un,Ay=new Ie,df=new Js,Rc=class extends St{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=I0,this.bindMatrix=new Ie,this.bindMatrixInverse=new Ie,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new qn),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oc),this.boundingBox.expandByPoint(oc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Un),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oc),this.boundingSphere.expandByPoint(oc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ff.copy(this.boundingSphere),ff.applyMatrix4(s),e.ray.intersectsSphere(ff)!==!1&&(Ay.copy(s).invert(),df.copy(e.ray).applyMatrix4(Ay),!(this.boundingBox!==null&&df.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,df)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Qe,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===I0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===pM?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,s=this.geometry;My.fromBufferAttribute(s.attributes.skinIndex,e),Sy.fromBufferAttribute(s.attributes.skinWeight,e),by.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let o=Sy.getComponent(r);if(o!==0){let a=My.getComponent(r);wy.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(zE.copy(by).applyMatrix4(wy),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},ca=class extends ut{constructor(){super(),this.isBone=!0,this.type="Bone"}},Cc=class extends vt{constructor(e=null,t=1,n=1,s,r,o,a,l,c=Xt,h=Xt,u,f){super(null,o,a,l,c,h,s,r,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ey=new Ie,VE=new Ie,io=class{constructor(e=[],t=[]){this.uuid=hi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new Ie)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ie;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,o=e.length;r<o;r++){let a=e[r]?e[r].matrixWorld:VE;Ey.multiplyMatrices(a,t[r]),Ey.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new io(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Cc(t,e,e,pn,ci);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){let r=e.bones[n],o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new ca),this.bones.push(o),this.boneInverses.push(new Ie().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){let o=t[s];e.bones.push(o.uuid);let a=n[s];e.boneInverses.push(a.toArray())}return e}},er=class extends ft{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Hr=new Ie,Ty=new Ie,ac=[],Iy=new qn,HE=new Ie,$o=new St,Jo=new Un,Lc=class extends St{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new er(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,HE)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new qn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Hr),Iy.copy(e.boundingBox).applyMatrix4(Hr),this.boundingBox.union(Iy)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Un),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Hr),Jo.copy(e.boundingSphere).applyMatrix4(Hr),this.boundingSphere.union(Jo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=s[o+a]}raycast(e,t){let n=this.matrixWorld,s=this.count;if($o.geometry=this.geometry,$o.material=this.material,$o.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Jo.copy(this.boundingSphere),Jo.applyMatrix4(n),e.ray.intersectsSphere(Jo)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,Hr),Ty.multiplyMatrices(n,Hr),$o.matrixWorld=Ty,$o.raycast(e,ac);for(let o=0,a=ac.length;o<a;o++){let l=ac[o];l.instanceId=r,l.object=this,t.push(l)}ac.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new er(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new Cc(new Float32Array(s*this.count),s,this.count,Nd,ci));let r=this.morphTexture.source.data.data,o=0;for(let c=0;c<n.length;c++)o+=n[c];let a=this.geometry.morphTargetsRelative?1:1-o,l=s*e;r[l]=a,r.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};var ha=class extends Fn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Pc=new F,Nc=new F,Ry=new Ie,jo=new Js,lc=new Un,pf=new F,Cy=new F,so=class extends ut{constructor(e=new yn,t=new ha){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Pc.fromBufferAttribute(t,s-1),Nc.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Pc.distanceTo(Nc);e.setAttribute("lineDistance",new Xn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),lc.copy(n.boundingSphere),lc.applyMatrix4(s),lc.radius+=r,e.ray.intersectsSphere(lc)===!1)return;Ry.copy(s).invert(),jo.copy(e.ray).applyMatrix4(Ry);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){let d=Math.max(0,o.start),y=Math.min(h.count,o.start+o.count);for(let g=d,p=y-1;g<p;g+=c){let m=h.getX(g),M=h.getX(g+1),b=cc(this,e,jo,l,m,M);b&&t.push(b)}if(this.isLineLoop){let g=h.getX(y-1),p=h.getX(d),m=cc(this,e,jo,l,g,p);m&&t.push(m)}}else{let d=Math.max(0,o.start),y=Math.min(f.count,o.start+o.count);for(let g=d,p=y-1;g<p;g+=c){let m=cc(this,e,jo,l,g,g+1);m&&t.push(m)}if(this.isLineLoop){let g=cc(this,e,jo,l,y-1,d);g&&t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function cc(i,e,t,n,s,r){let o=i.geometry.attributes.position;if(Pc.fromBufferAttribute(o,s),Nc.fromBufferAttribute(o,r),t.distanceSqToSegment(Pc,Nc,pf,Cy)>n)return;pf.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(pf);if(!(l<e.near||l>e.far))return{distance:l,point:Cy.clone().applyMatrix4(i.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:i}}var Ly=new F,Py=new F,Oc=class extends so{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Ly.fromBufferAttribute(t,s),Py.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Ly.distanceTo(Py);e.setAttribute("lineDistance",new Xn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Dc=class extends so{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ua=class extends Fn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Re(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ny=new Ie,yd=new Js,hc=new Un,uc=new F,Uc=class extends ut{constructor(e=new yn,t=new ua){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hc.copy(n.boundingSphere),hc.applyMatrix4(s),hc.radius+=r,e.ray.intersectsSphere(hc)===!1)return;Ny.copy(s).invert(),yd.copy(e.ray).applyMatrix4(Ny);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,o.start),d=Math.min(c.count,o.start+o.count);for(let y=f,g=d;y<g;y++){let p=c.getX(y);uc.fromBufferAttribute(u,p),Oy(uc,p,l,s,e,t,this)}}else{let f=Math.max(0,o.start),d=Math.min(u.count,o.start+o.count);for(let y=f,g=d;y<g;y++)uc.fromBufferAttribute(u,y),Oy(uc,y,l,s,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Oy(i,e,t,n,s,r,o){let a=yd.distanceSqToPoint(i);if(a<t){let l=new F;yd.closestPointToPoint(i,l),l.applyMatrix4(n);let c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var ro=class extends vt{constructor(e,t,n,s,r,o,a,l,c,h,u,f){super(null,o,a,l,c,h,s,r,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};var Fc=class extends vt{constructor(e,t,n,s,r,o,a,l,c){super(e,t,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var oo=class extends Fn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Re(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 Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=e_,this.normalScale=new Ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},kn=class extends oo{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ve(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return rn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Re(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Re(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Re(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};function fc(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function GE(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function WE(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function Dy(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let l=0;l!==e;++l)s[o++]=i[a+l]}return s}function h_(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=i[s++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=i[s++];while(r!==void 0)}var ps=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},_d=class extends ps{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:R0,endingEnd:R0}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case C0:r=e,a=2*t-n;break;case L0:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case C0:o=e,l=2*n-t;break;case L0:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,y=(n-t)/(s-t),g=y*y,p=g*y,m=-f*p+2*f*g-f*y,M=(1+f)*p+(-1.5-2*f)*g+(-.5+f)*y+1,b=(-1-d)*p+(1.5+d)*g+.5*y,S=d*p-d*g;for(let O=0;O!==a;++O)r[O]=m*o[h+O]+M*o[c+O]+b*o[l+O]+S*o[u+O];return r}},vd=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(s-t),u=1-h;for(let f=0;f!==a;++f)r[f]=o[c+f]*u+o[l+f]*h;return r}},xd=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},Zn=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fc(t,this.TimeBufferType),this.values=fc(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fc(e.times,Array),values:fc(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new xd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _d(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case cs:t=this.InterpolantFactoryMethodDiscrete;break;case hs:t=this.InterpolantFactoryMethodLinear;break;case Fu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cs;case this.InterpolantFactoryMethodLinear:return hs;case this.InterpolantFactoryMethodSmooth:return Fu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&GE(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Fu,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(s)l=!0;else{let u=a*n,f=u-n,d=u+n;for(let y=0;y!==n;++y){let g=t[u+y];if(g!==t[f+y]||g!==t[d+y]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};Zn.prototype.TimeBufferType=Float32Array;Zn.prototype.ValueBufferType=Float32Array;Zn.prototype.DefaultInterpolation=hs;var ms=class extends Zn{constructor(e,t,n){super(e,t,n)}};ms.prototype.ValueTypeName="bool";ms.prototype.ValueBufferType=Array;ms.prototype.DefaultInterpolation=cs;ms.prototype.InterpolantFactoryMethodLinear=void 0;ms.prototype.InterpolantFactoryMethodSmooth=void 0;var Bc=class extends Zn{};Bc.prototype.ValueTypeName="color";var ki=class extends Zn{};ki.prototype.ValueTypeName="number";var bd=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)Dn.slerpFlat(r,0,o,c-a,o,c,l);return r}},zi=class extends Zn{InterpolantFactoryMethodLinear(e){return new bd(this.times,this.values,this.getValueSize(),e)}};zi.prototype.ValueTypeName="quaternion";zi.prototype.InterpolantFactoryMethodSmooth=void 0;var gs=class extends Zn{constructor(e,t,n){super(e,t,n)}};gs.prototype.ValueTypeName="string";gs.prototype.ValueBufferType=Array;gs.prototype.DefaultInterpolation=cs;gs.prototype.InterpolantFactoryMethodLinear=void 0;gs.prototype.InterpolantFactoryMethodSmooth=void 0;var Vi=class extends Zn{};Vi.prototype.ValueTypeName="vector";var kc=class{constructor(e="",t=-1,n=[],s=mM){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=hi(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(qE(n[o]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Zn.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,o=[];for(let a=0;a<r;a++){let l=[],c=[];l.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let h=WE(l);l=Dy(l,1,h),c=Dy(c,1,h),!s&&l[0]===0&&(l.push(r),c.push(c[0])),o.push(new ki(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let s={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],h=c.name.match(r);if(h&&h.length>1){let u=h[1],f=s[u];f||(s[u]=f=[]),f.push(c)}}let o=[];for(let a in s)o.push(this.CreateFromMorphTargetSequence(a,s[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,f,d,y,g){if(d.length!==0){let p=[],m=[];h_(d,p,m,y),p.length!==0&&g.push(new u(f,p,m))}},s=[],r=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let u=0;u<c.length;u++){let f=c[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let d={},y;for(y=0;y<f.length;y++)if(f[y].morphTargets)for(let g=0;g<f[y].morphTargets.length;g++)d[f[y].morphTargets[g]]=-1;for(let g in d){let p=[],m=[];for(let M=0;M!==f[y].morphTargets.length;++M){let b=f[y];p.push(b.time),m.push(b.morphTarget===g?1:0)}s.push(new ki(".morphTargetInfluence["+g+"]",p,m))}l=d.length*o}else{let d=".bones["+t[u].name+"]";n(Vi,d+".position",f,"pos",s),n(zi,d+".quaternion",f,"rot",s),n(Vi,d+".scale",f,"scl",s)}}return s.length===0?null:new this(r,l,s,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function XE(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ki;case"vector":case"vector2":case"vector3":case"vector4":return Vi;case"color":return Bc;case"quaternion":return zi;case"bool":case"boolean":return ms;case"string":return gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function qE(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=XE(i.type);if(i.times===void 0){let t=[],n=[];h_(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}var os={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Md=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){let d=c[u],y=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return y}return null}}},YE=new Md,Hi=class{constructor(e){this.manager=e!==void 0?e:YE,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Pi={},Sd=class extends Error{constructor(e,t){super(e),this.response=t}},fa=class extends Hi{constructor(e){super(e)}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=os.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Pi[e]!==void 0){Pi[e].push({onLoad:t,onProgress:n,onError:s});return}Pi[e]=[],Pi[e].push({onLoad:t,onProgress:n,onError:s});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Pi[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=f?parseInt(f):0,y=d!==0,g=0,p=new ReadableStream({start(m){M();function M(){u.read().then(({done:b,value:S})=>{if(b)m.close();else{g+=S.byteLength;let O=new ProgressEvent("progress",{lengthComputable:y,loaded:g,total:d});for(let L=0,R=h.length;L<R;L++){let C=h[L];C.onProgress&&C.onProgress(O)}m.enqueue(S),M()}},b=>{m.error(b)})}}});return new Response(p)}else throw new Sd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(y=>d.decode(y))}}}).then(c=>{os.add(e,c);let h=Pi[e];delete Pi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{let h=Pi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Pi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var wd=class extends Hi{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=os.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;let a=ra("img");function l(){h(),os.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(u){h(),s&&s(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}};var ys=class extends Hi{constructor(e){super(e)}load(e,t,n,s){let r=new vt,o=new wd(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}},ao=class extends ut{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},zc=class extends ao{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},mf=new Ie,Uy=new F,Fy=new F,da=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ve(512,512),this.map=null,this.mapPass=null,this.matrix=new Ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new aa,this._frameExtents=new Ve(1,1),this._viewportCount=1,this._viewports=[new Qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Uy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Uy),Fy.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Fy),t.updateMatrixWorld(),mf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mf),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(mf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ad=class extends da{constructor(){super(new kt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=Qr*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Vc=class extends ao{constructor(e,t,n=0,s=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=s,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new Ad}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},By=new Ie,Qo=new F,gf=new F,Ed=class extends da{constructor(){super(new kt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ve(4,2),this._viewportCount=6,this._viewports=[new Qe(2,1,1,1),new Qe(0,1,1,1),new Qe(3,1,1,1),new Qe(1,1,1,1),new Qe(3,0,1,1),new Qe(1,0,1,1)],this._cubeDirections=[new F(1,0,0),new F(-1,0,0),new F(0,0,1),new F(0,0,-1),new F(0,1,0),new F(0,-1,0)],this._cubeUps=[new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,0,1),new F(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,s=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Qo.setFromMatrixPosition(e.matrixWorld),n.position.copy(Qo),gf.copy(n.position),gf.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(gf),n.updateMatrixWorld(),s.makeTranslation(-Qo.x,-Qo.y,-Qo.z),By.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(By)}},Hc=class extends ao{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Ed}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Td=class extends da{constructor(){super(new no(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Gc=class extends ao{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new Td}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var _s=class{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,s=e.length;n<s;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}};var Wc=class extends Hi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=os.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{s&&s(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return os.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),os.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});os.add(e,l),r.manager.itemStart(e)}};var zd="\\[\\]\\.:\\/",KE=new RegExp("["+zd+"]","g"),Vd="[^"+zd+"]",ZE="[^"+zd.replace("\\.","")+"]",$E=/((?:WC+[\/:])*)/.source.replace("WC",Vd),JE=/(WCOD+)?/.source.replace("WCOD",ZE),jE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Vd),QE=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Vd),eT=new RegExp("^"+$E+JE+jE+QE+"$"),tT=["material","materials","bones","map"],Id=class{constructor(e,t,n){let s=n||He.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},He=class{constructor(e,t,n){this.path=t,this.parsedPath=n||He.parseTrackName(t),this.node=He.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new He.Composite(e,t,n):new He(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(KE,"")}static parseTrackName(e){let t=eT.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);tT.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=He.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[s];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};He.Composite=Id;He.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};He.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};He.prototype.GetterByBindingType=[He.prototype._getValue_direct,He.prototype._getValue_array,He.prototype._getValue_arrayElement,He.prototype._getValue_toArray];He.prototype.SetterByBindingTypeAndVersioning=[[He.prototype._setValue_direct,He.prototype._setValue_direct_setNeedsUpdate,He.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[He.prototype._setValue_array,He.prototype._setValue_array_setNeedsUpdate,He.prototype._setValue_array_setMatrixWorldNeedsUpdate],[He.prototype._setValue_arrayElement,He.prototype._setValue_arrayElement_setNeedsUpdate,He.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[He.prototype._setValue_fromArray,He.prototype._setValue_fromArray_setNeedsUpdate,He.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var aO=new Float32Array(1);var lo=class{constructor(e){this.value=e}clone(){return new lo(this.value.clone===void 0?this.value:this.value.clone())}};var ky=new Ie,Xc=class{constructor(e,t,n=0,s=1/0){this.ray=new Js(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new oa,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return ky.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ky),this}intersectObject(e,t=!0,n=[]){return Rd(e,this,n,t),n.sort(zy),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Rd(e[s],this,n,t);return n.sort(zy),n}};function zy(i,e){return i.distance-e.distance}function Rd(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){let r=i.children;for(let o=0,a=r.length;o<a;o++)Rd(r[o],e,t,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pa);E();function Hd(i,e){if(e===Qy)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===ya||e===Yc){let t=i.getIndex();if(t===null){let o=[],a=i.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,s=[];if(e===ya)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let r=i.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var $c=class extends Hi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Zd(t)}),this.register(function(t){return new $d(t)}),this.register(function(t){return new rp(t)}),this.register(function(t){return new op(t)}),this.register(function(t){return new ap(t)}),this.register(function(t){return new jd(t)}),this.register(function(t){return new Qd(t)}),this.register(function(t){return new ep(t)}),this.register(function(t){return new tp(t)}),this.register(function(t){return new Kd(t)}),this.register(function(t){return new np(t)}),this.register(function(t){return new Jd(t)}),this.register(function(t){return new sp(t)}),this.register(function(t){return new ip(t)}),this.register(function(t){return new qd(t)}),this.register(function(t){return new lp(t)}),this.register(function(t){return new cp(t)})}load(e,t,n,s){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let c=_s.extractUrlBase(e);o=_s.resolveURL(c,this.path)}else o=_s.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new fa(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r,o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===m_){try{o[Ge.KHR_BINARY_GLTF]=new hp(e)}catch(u){s&&s(u);return}r=JSON.parse(o[Ge.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new yp(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let u=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(u){case Ge.KHR_MATERIALS_UNLIT:o[u]=new Yd;break;case Ge.KHR_DRACO_MESH_COMPRESSION:o[u]=new up(r,this.dracoLoader);break;case Ge.KHR_TEXTURE_TRANSFORM:o[u]=new fp;break;case Ge.KHR_MESH_QUANTIZATION:o[u]=new dp;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};function nT(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}var Ge={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},qd=class{constructor(e){this.parser=e,this.name=Ge.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,s=t.cache.get(n);if(s)return s;let r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,h=new Re(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],qt);let u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Gc(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Hc(h),c.distance=u;break;case"spot":c=new Vc(h),c.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,Gi(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}},Yd=class{constructor(){this.name=Ge.KHR_MATERIALS_UNLIT}getMaterialType(){return gn}extendParams(e,t,n){let s=[];e.color=new Re(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],qt),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Nt))}return Promise.all(s)}},Kd=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},Zd=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ve(a,a)}return Promise.all(r)}},$d=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}},Jd=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},jd=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[];t.sheenColor=new Re(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],qt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Nt)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},Qd=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},ep=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Re().setRGB(a[0],a[1],a[2],qt),Promise.all(r)}},tp=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},np=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new Re().setRGB(a[0],a[1],a[2],qt),o.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,Nt)),Promise.all(r)}},ip=class{constructor(e){this.parser=e,this.name=Ge.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}},sp=class{constructor(e){this.parser=e,this.name=Ge.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:kn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},rp=class{constructor(e){this.parser=e,this.name=Ge.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;let r=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},op=class{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},ap=class{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},lp=class{constructor(e){this.name=Ge.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let l=s.byteOffset||0,c=s.byteLength||0,h=s.count,u=s.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,s.mode,s.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,s.mode,s.filter),d})})}else return null}},cp=class{constructor(e){this.name=Ge.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let c of s.primitives)if(c.mode!==$n.TRIANGLES&&c.mode!==$n.TRIANGLE_STRIP&&c.mode!==$n.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let h=c.pop(),u=h.isGroup?h.children:[h],f=c[0].count,d=[];for(let y of u){let g=new Ie,p=new F,m=new Dn,M=new F(1,1,1),b=new Lc(y.geometry,y.material,f);for(let S=0;S<f;S++)l.TRANSLATION&&p.fromBufferAttribute(l.TRANSLATION,S),l.ROTATION&&m.fromBufferAttribute(l.ROTATION,S),l.SCALE&&M.fromBufferAttribute(l.SCALE,S),b.setMatrixAt(S,g.compose(p,m,M));for(let S in l)if(S==="_COLOR_0"){let O=l[S];b.instanceColor=new er(O.array,O.itemSize,O.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&y.geometry.setAttribute(S,l[S]);ut.prototype.copy.call(b,y),this.parser.assignFinalMaterial(b),d.push(b)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}},m_="glTF",_a=12,u_={JSON:1313821514,BIN:5130562},hp=class{constructor(e){this.name=Ge.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,_a),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==m_)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let s=this.header.length-_a,r=new DataView(e,_a),o=0;for(;o<s;){let a=r.getUint32(o,!0);o+=4;let l=r.getUint32(o,!0);if(o+=4,l===u_.JSON){let c=new Uint8Array(e,_a+o,a);this.content=n.decode(c)}else if(l===u_.BIN){let c=_a+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},up=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ge.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(let h in o){let u=mp[h]||h.toLowerCase();a[u]=o[h]}for(let h in e.attributes){let u=mp[h]||h.toLowerCase();if(o[h]!==void 0){let f=n.accessors[e.attributes[h]],d=uo[f.componentType];c[u]=d.name,l[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){s.decodeDracoFile(h,function(d){for(let y in d.attributes){let g=d.attributes[y],p=l[y];p!==void 0&&(g.normalized=p)}u(d)},a,c,qt,f)})})}},fp=class{constructor(){this.name=Ge.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},dp=class{constructor(){this.name=Ge.KHR_MESH_QUANTIZATION}},Jc=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=s-t,u=(n-t)/h,f=u*u,d=f*u,y=e*c,g=y-c,p=-2*d+3*f,m=d-f,M=1-p,b=m-f+u;for(let S=0;S!==a;S++){let O=o[g+S+a],L=o[g+S+l]*h,R=o[y+S+a],C=o[y+S]*h;r[S]=M*O+b*L+p*R+m*C}return r}},iT=new Dn,pp=class extends Jc{interpolate_(e,t,n,s){let r=super.interpolate_(e,t,n,s);return iT.fromArray(r).normalize().toArray(r),r}},$n={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},uo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},f_={9728:Xt,9729:Ot,9984:ma,9985:Ks,9986:rs,9987:Wn},d_={33071:li,33648:Zs,10497:Ui},Gd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},mp={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},vs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},sT={CUBICSPLINE:void 0,LINEAR:hs,STEP:cs},Wd={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function rT(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new oo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Si})),i.DefaultMaterial}function tr(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Gi(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function oT(i,e,t){let n=!1,s=!1,r=!1;for(let c=0,h=e.length;c<h;c++){let u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);let o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){let u=e[c];if(n){let f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;o.push(f)}if(s){let f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;a.push(f)}if(r){let f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){let h=c[0],u=c[1],f=c[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=f),i.morphTargetsRelative=!0,i})}function aT(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function lT(i){let e,t=i.extensions&&i.extensions[Ge.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Xd(t.attributes):e=i.indices+":"+Xd(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+Xd(i.targets[n]);return e}function Xd(i){let e="",t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function gp(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function cT(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}var hT=new Ie,yp=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new nT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);s=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?this.textureLoader=new ys(this.options.manager):this.textureLoader=new Wc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new fa(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return tr(r,a,s),Gi(a,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){let o=t[s].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){let o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let s=n.clone(),r=(o,a)=>{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,h]of o.children.entries())r(h,a.children[c])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let s=e(t[n]);if(s)return s}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let s=0;s<t.length;s++){let r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ge.KHR_BINARY_GLTF].body);let s=this.options;return new Promise(function(r,o){n.load(_s.resolveURL(t.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){let t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){let o=Gd[s.type],a=uo[s.componentType],l=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new ft(c,o,l))}let r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],l=Gd[s.type],c=uo[s.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,f=s.byteOffset||0,d=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0,g,p;if(d&&d!==u){let m=Math.floor(f/d),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+m+":"+s.count,b=t.cache.get(M);b||(g=new c(a,m*d,s.count*d/h),b=new la(g,d/h),t.cache.add(M,b)),p=new Qs(b,l,f%d/h,y)}else a===null?g=new c(s.count*l):g=new c(a,f,s.count*l),p=new ft(g,l,y);if(s.sparse!==void 0){let m=Gd.SCALAR,M=uo[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,S=s.sparse.values.byteOffset||0,O=new M(o[1],b,s.sparse.count*m),L=new c(o[2],S,s.sparse.count*l);a!==null&&(p=new ft(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let R=0,C=O.length;R<C;R++){let j=O[R];if(p.setX(j,L[R*l]),l>=2&&p.setY(j,L[R*l+1]),l>=3&&p.setZ(j,L[R*l+2]),l>=4&&p.setW(j,L[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=y}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let f=(r.samplers||{})[o.sampler]||{};return h.magFilter=f_[f.magFilter]||Ot,h.minFilter=f_[f.minFilter]||Wn,h.wrapS=d_[f.wrapS]||Ui,h.wrapT=d_[f.wrapT]||Ui,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let o=s.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(f),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(l).then(function(u){return new Promise(function(f,d){let y=f;t.isImageBitmapLoader===!0&&(y=function(g){let p=new vt(g);p.needsUpdate=!0,f(p)}),t.load(_s.resolveURL(u,r.path),y,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),Gi(u,o),u.userData.mimeType=o.mimeType||cT(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[Ge.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Ge.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=r.associations.get(o);o=r.extensions[Ge.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new ua,Fn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new ha,Fn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return oo}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],o,a={},l=r.extensions||{},c=[];if(l[Ge.KHR_MATERIALS_UNLIT]){let u=s[Ge.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new Re(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],qt),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,Nt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Nn);let h=r.alphaMode||Wd.OPAQUE;if(h===Wd.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Wd.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==gn&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ve(1,1),r.normalTexture.scale!==void 0)){let u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==gn&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==gn){let u=r.emissiveFactor;a.emissive=new Re().setRGB(u[0],u[1],u[2],qt)}return r.emissiveTexture!==void 0&&o!==gn&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Nt)),Promise.all(c).then(function(){let u=new o(a);return r.name&&(u.name=r.name),Gi(u,r),t.associations.set(u,{materials:e}),r.extensions&&tr(s,u,r),u})}createUniqueName(e){let t=He.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[Ge.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return p_(l,a,t)})}let o=[];for(let a=0,l=e.length;a<l;a++){let c=e[a],h=lT(c),u=s[h];if(u)o.push(u.promise);else{let f;c.extensions&&c.extensions[Ge.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=p_(new yn,c,t),s[h]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){let h=o[l].material===void 0?rT(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){let c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let d=0,y=h.length;d<y;d++){let g=h[d],p=o[d],m,M=c[d];if(p.mode===$n.TRIANGLES||p.mode===$n.TRIANGLE_STRIP||p.mode===$n.TRIANGLE_FAN||p.mode===void 0)m=r.isSkinnedMesh===!0?new Rc(g,M):new St(g,M),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),p.mode===$n.TRIANGLE_STRIP?m.geometry=Hd(m.geometry,Yc):p.mode===$n.TRIANGLE_FAN&&(m.geometry=Hd(m.geometry,ya));else if(p.mode===$n.LINES)m=new Oc(g,M);else if(p.mode===$n.LINE_STRIP)m=new so(g,M);else if(p.mode===$n.LINE_LOOP)m=new Dc(g,M);else if(p.mode===$n.POINTS)m=new Uc(g,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(m.geometry.morphAttributes).length>0&&aT(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),Gi(m,r),p.extensions&&tr(s,m,p),t.assignFinalMaterial(m),u.push(m)}for(let d=0,y=u.length;d<y;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&tr(s,u[0],r),u[0];let f=new Mi;r.extensions&&tr(s,f,r),t.associations.set(f,{meshes:e});for(let d=0,y=u.length;d<y;d++)f.add(u[d]);return f})}loadCamera(e){let t,n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new kt(co.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new no(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Gi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){let r=s.pop(),o=s,a=[],l=[];for(let c=0,h=o.length;c<h;c++){let u=o[c];if(u){a.push(u);let f=new Ie;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new io(a,l)})}loadAnimation(e){let t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let u=0,f=s.channels.length;u<f;u++){let d=s.channels[u],y=s.samplers[d.sampler],g=d.target,p=g.node,m=s.parameters!==void 0?s.parameters[y.input]:y.input,M=s.parameters!==void 0?s.parameters[y.output]:y.output;g.node!==void 0&&(o.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",m)),l.push(this.getDependency("accessor",M)),c.push(y),h.push(g))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){let f=u[0],d=u[1],y=u[2],g=u[3],p=u[4],m=[];for(let M=0,b=f.length;M<b;M++){let S=f[M],O=d[M],L=y[M],R=g[M],C=p[M];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();let j=n._createAnimationTracks(S,O,L,R,C);if(j)for(let v=0;v<j.length;v++)m.push(j[v])}return new kc(r,void 0,m)})}createNodeMesh(e){let t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(!!a.isMesh)for(let l=0,c=s.weights.length;l<c;l++)a.morphTargetInfluences[l]=s.weights[l]}),o})}loadNode(e){let t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));let l=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){let h=c[0],u=c[1],f=c[2];f!==null&&h.traverse(function(d){!d.isSkinnedMesh||d.bind(f,hT)});for(let d=0,y=u.length;d<y;d++)h.add(u[d]);return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new ca:c.length>1?h=new Mi:c.length===1?h=c[0]:h=new ut,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),Gi(h,r),r.extensions&&tr(n,h,r),r.matrix!==void 0){let u=new Ie;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new Mi;n.name&&(r.name=s.createUniqueName(n.name)),Gi(r,n),n.extensions&&tr(t,r,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(s.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,u=l.length;h<u;h++)r.add(l[h]);let c=h=>{let u=new Map;for(let[f,d]of s.associations)(f instanceof Fn||f instanceof vt)&&u.set(f,d);return h.traverse(f=>{let d=s.associations.get(f);d!=null&&u.set(f,d)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,n,s,r){let o=[],a=e.name?e.name:e.uuid,l=[];vs[r.path]===vs.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(vs[r.path]){case vs.weights:c=ki;break;case vs.rotation:c=zi;break;case vs.position:case vs.scale:c=Vi;break;default:switch(n.itemSize){case 1:c=ki;break;case 2:case 3:default:c=Vi;break}break}let h=s.interpolation!==void 0?sT[s.interpolation]:hs,u=this._getArrayFromAccessor(n);for(let f=0,d=l.length;f<d;f++){let y=new c(l[f]+"."+vs[r.path],t.array,u,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=gp(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let s=this instanceof zi?pp:Jc;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function uT(i,e,t){let n=e.attributes,s=new qn;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(s.set(new F(l[0],l[1],l[2]),new F(c[0],c[1],c[2])),a.normalized){let h=gp(uo[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=e.targets;if(r!==void 0){let a=new F,l=new F;for(let c=0,h=r.length;c<h;c++){let u=r[c];if(u.POSITION!==void 0){let f=t.json.accessors[u.POSITION],d=f.min,y=f.max;if(d!==void 0&&y!==void 0){if(l.setX(Math.max(Math.abs(d[0]),Math.abs(y[0]))),l.setY(Math.max(Math.abs(d[1]),Math.abs(y[1]))),l.setZ(Math.max(Math.abs(d[2]),Math.abs(y[2]))),f.normalized){let g=gp(uo[f.componentType]);l.multiplyScalar(g)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}i.boundingBox=s;let o=new Un;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=o}function p_(i,e,t){let n=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){i.setAttribute(a,l)})}for(let o in n){let a=mp[o]||o.toLowerCase();a in i.attributes||s.push(r(n[o],a))}if(e.indices!==void 0&&!i.index){let o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});s.push(o)}return je.workingColorSpace!==qt&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`),Gi(i,e),uT(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?oT(i,e.targets,t):i})}E();var fT=Math.PI/180,pO=180/Math.PI;function xs(i){return i*fT}function g_(i,e){let t,n=new Xc,s=new Map;function r(h){return h.getSource(i).serialize().data.features.filter(u=>u.properties.featureClass===Ee.MODEL3D)}function o(h){let u=new fs,f=h.id,d=s.get(f),y=d?d.scene:new Bn,g=new zc(11646413,9998214,1.1);g.position.set(0,10,0),(!d||d.feature.properties.url!==h.properties.url)&&(y.clear(),s.delete(f),new $c().load(h.properties.url,function(M){M.scene.rotateX(xs(90)),y.add(M.scene),y.add(g)}.bind(this)));let p=new F(h.properties.scale[0]??1,h.properties.scale[0]??1,h.properties.scale[0]??1);y.scale.set(p.x,p.y,p.z),y.setRotationFromEuler(a(h.properties)),s.set(f,{feature:h,scene:y,camera:u})}function a(h){let u=xs(360-(h.rotation[0]??0)),f=xs(h.rotation[1]??0),d=xs(360-(h.rotation[2]??0));return new on(u,f,d,"ZXY")}function l(h){let u=h.geometry.coordinates,f=0,d=mapboxgl.MercatorCoordinate.fromLngLat(u,f),y={x:90,y:0,z:0};return{modelTransform:{translateX:d.x,translateY:d.y,translateZ:d.z,rotateX:xs(y.x+h.properties.rotation[0]),rotateY:xs(y.y+h.properties.rotation[1]),rotateZ:xs(y.z+h.properties.rotation[2]),scale:d.meterInMercatorCoordinateUnits()},sceneKey:h.id}}function c(h,u){let f=h.modelTransform,d=new Ie().fromArray(u),y=new Ie().makeTranslation(f.translateX,f.translateY,f.translateZ).scale(new F(f.scale,-f.scale,f.scale)),g=s.get(h.sceneKey).camera;g.projectionMatrix=d.multiply(y),t.resetState(),t.render(s.get(h.sceneKey).scene,g)}return{id:e,type:"custom",renderingMode:"3d",onAdd:(h,u)=>{this.map=h,t=new ds({canvas:h.getCanvas(),context:u,antialias:!0}),t.autoClear=!1},render:(h,u)=>{r(this.map).map(f=>(o(f),f)).map(f=>l(f)).forEach(f=>c(f,u)),this.map.triggerRepaint()},queryRendered3DModels:h=>{let u=r(this.map).filter(d=>d.properties.clickable),f=dT(h,this.map,s,n,u);return f.length===0?null:f.reduce((d,y)=>{let g=d.intersect?Math.min(...d.intersect.map(m=>m.distance)):Number.MAX_SAFE_INTEGER,p=Math.min(...y.intersect.map(m=>m.distance));return g<p?d:y},{}).feature}}}function dT(i,e,t,n,s){let r=new Ve;r.x=i.x/e.transform.width*2-1,r.y=1-i.y/e.transform.height*2;let o=[];return t.forEach(a=>{if(!s.some(g=>a.feature.id===g.id))return;let c=a.camera,h=new Ie().copy(c.projectionMatrix).invert(),u=new F().applyMatrix4(h),d=new F(r.x,r.y,1).applyMatrix4(h).clone().sub(u).normalize();n.set(u,d);let y=n.intersectObjects(a.scene.children,!0);y.length>0&&o.push({intersect:y,feature:a.feature})}),o}E();var pT=!!document.createElement("canvas").getContext("webgl2"),jc=class{#e=new Map;#t=new Map;#n;#i;#r=new ys;id;renderingMode="3d";type="custom";constructor(e){this.id=e}setData(e){this.#e=e.filter(t=>t?.properties?.featureClass===Ee.MODEL2D).reduce((t,n)=>{let s=n?.id.toString(),r={scene:new Bn,transformation:new Ie},o=mapboxgl.MercatorCoordinate.fromLngLat(n.properties?.anchor??n.geometry.coordinates,0),a=new Kn(n.properties.widthMeters,n.properties.heightMeters),l=this.#a(o),c=this.#o(n.properties),{scene:h,transformation:u}=r,f=new gn({map:this.#s(n.properties.imageUrl),transparent:!0,depthTest:!1}),d=new St(a,f);return h.add(d),h.setRotationFromEuler(c),u.makeTranslation(o.x,o.y,o.z),u.scale(l),t.set(s,r)},new Map)}onAdd(e,t){this.#n=e,this.#i=new ds({canvas:this.#n.getCanvas(),context:t,antialias:!0}),this.#i.autoClear=!1}render(e,t){let n=new fs;for(let s of this.#e.values()){let r=s.scene;if(r){let o=s.transformation;n.projectionMatrix=new Ie().fromArray(t).multiply(o),this.#i.resetState(),this.#i.render(r,n)}}this.#n.triggerRepaint()}#o(e){let t=_p(0),n=_p(0),s=_p(-(e.bearing%360+360)%360);return new on(t,n,s,"XYZ")}#a(e){let t=e.meterInMercatorCoordinateUnits();return new F(t,-t,t)}#s(e){if(!this.#t.has(e)){let t=this.#r.load(e);pT&&(t.minFilter=Ot),this.#t.set(e,t)}return this.#t.get(e).clone()}};function _p(i){return i*.01745329251}var ui="MI_GEOJSON_SOURCE",va="MI_FLOOR_PLAN_SOURCE",mT="MI_FLOOR_PLAN_FILL",gT="MI_FLOOR_PLAN_LINE",y_="MI_HIGHLIGHT_LAYER",yT="MI_MODEL_2D_LAYER",kl="MI_MODEL_3D_LAYER",_T="MI_OUTLINE_LAYER",Tr="MI_POINT_LAYER",xa="MI_POLYGON_LAYER",ba="MI_ROOMS_LAYER",Ma="MI_TILES_LAYER",Qc="MI_TILES_SOURCE",vp="MI_WALLS_LAYER",__="MI_FLAT_LABELS_LAYER",xp="MI_GRAPHIC_LABELS_LAYER",eh=class extends Et{#e=dn.INITIALIZING;#t;#n;#i=new jc(yT);#r=null;constructor({element:e,maxZoom:t,accessToken:n,pitch:s=0,bearing:r=0,...o}){if(super(),this.#n=this.isMaxZoomLevelValid(t),mapboxgl&&mapboxgl.Map){mapboxgl.accessToken=n;let a=new mapboxgl.Map({container:e,style:"mapbox://styles/mapbox/streets-v11",maxZoom:Sa(t),bearing:r,pitch:s,...o});Rt.log(pt.appLifeTime.MAP_INSTANTIATED),a.on("load",()=>{a.addSource(va,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),a.addSource(ui,{type:"geojson",data:{type:"FeatureCollection",features:[]}});let{wallOpacity:l,extrusionOpacity:c}=this.#a();a.addLayer({filter:["any",["==","featureClass",Ee.POLYGON],["==","featureClass",Ee.MODEL2D]],id:xa,type:"fill",source:ui,layout:{"fill-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"fill-color":["to-color",["get","fillColor"],se.polygon.fillColor],"fill-opacity":["number",["get","fillOpacity"],se.polygon.fillOpacity]}}),a.addLayer({filter:["==","featureClass",Ee.POLYGON],id:_T,type:"line",source:ui,layout:{"line-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"line-width":["number",["get","strokeWidth"],se.polygon.strokeWidth],"line-color":["to-color",["get","strokeColor"],se.polygon.strokeColor],"line-opacity":["number",["get","strokeOpacity"],se.polygon.strokeOpacity]}}),a.addLayer({id:mT,type:"fill",source:va,paint:{"fill-color":["match",["get","type"],"floorplan","#ffffff","extrusion","#fcfcf2","#ffffff"]}}),a.addLayer({id:gT,type:"line",source:va,filter:["==",["get","type"],"floorplan"],paint:{"line-width":1.2,"line-color":"#6B7280"}}),a.addLayer(this.#i),a.addLayer({filter:["any",["==","featureClass",Ee.LABEL_FLAT]],id:__,source:ui,type:"symbol",layout:{"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-size":["interpolate",["exponential",2],["zoom"],1,["number",["*",["get","labelStyleSize"],2384185791015625e-22],["*",se.labelStyle.textSize,2384185791015625e-22]],22,["number",["get","labelStyleSize"]],23,["number",["*",["get","labelStyleSize"],2],["*",se.labelStyle.textSize,2]],24,["number",["*",["get","labelStyleSize"],4],["*",se.labelStyle.textSize,4]],25,["number",["*",["get","labelStyleSize"],8],["*",se.labelStyle.textSize,8]]],"text-ignore-placement":!0,"text-allow-overlap":!0,"icon-allow-overlap":!0,"text-rotation-alignment":"map","text-rotate":["number",["get","labelStyleBearing"],se.labelStyle.bearing]},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),this.#r=g_(ui,kl),a.addLayer(this.#r),a.addLayer({filter:["any",["==","featureClass",Ee.WALL_EXTRUSION]],id:vp,type:"fill-extrusion",source:ui,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":l,"fill-extrusion-height":["get","height"]}}),a.addLayer({id:ba,filter:["==","featureClass",Ee.ROOM_EXTRUSION],type:"fill-extrusion",source:ui,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":c,"fill-extrusion-height":["get","height"]}}),a.addLayer({filter:["all",["!=","iconAllowOverlap",!0],["any",["==","featureClass",Ee.POINT],["==","featureClass",Ee.LABEL_FLOATING]]],id:Tr,type:"symbol",source:ui,layout:{"icon-allow-overlap":!1,"icon-optional":!0,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"text-padding":0,"text-optional":!0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-size":["number",["get","labelStyleSize"],se.labelStyle.textSize],"text-letter-spacing":-.01,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!1},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),a.addLayer({filter:["all",["==","iconAllowOverlap",!0],["any",["==","featureClass",Ee.POINT],["==","featureClass",Ee.LABEL_FLOATING]]],id:y_,type:"symbol",source:ui,layout:{"icon-allow-overlap":!0,"icon-optional":!1,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MIN_SAFE_INTEGER],"text-padding":0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Regular","Arial Unicode MS Regular"]],"text-size":["number",["get","labelSize"],12],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!0},paint:{"text-color":["to-color",["get","labelColor"],"hsl(217, 11%, 23%)"],"text-halo-color":["to-color",["get","labelShadowColor"],"#000"],"text-halo-width":["number",["get","labelShadowBlur"],0],"text-halo-blur":["case",[">",["get","labelShadowBlur"],0],1,0]}}),a.addLayer({filter:["any",["==","featureClass",Ee.LABEL_GRAPHIC]],id:xp,source:ui,type:"symbol",layout:{"icon-text-fit":"both","icon-image":["get","imageId"],"icon-allow-overlap":!0,"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"text-size":["number",["get","labelStyleSize"],se.labelStyle.textSize],"text-allow-overlap":!0,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-padding":0},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),this.#e=dn.READY,a.on("mousemove",this.#o(100)),this.emit("ready")}),a.on("moveend",()=>{this.emit("idle")}),a.on("move",()=>{this.emit("bounds_changed")}),a.on("center_changed",()=>{this.emit("center_changed")}),a.on("click",l=>{let c=this.#r?.queryRendered3DModels(l.point)||a.queryRenderedFeatures(l.point,{layers:[xa,Tr,ba,xp,__]}).find(h=>!h?.properties?.originalId.startsWith("MI_")&&h?.properties?.clickable===!0);c&&c.properties.clickable!==!1&&this.emit("click",c.properties.originalId)}),a.on("maptypeid_changed",()=>{this.emit("maptypeid_changed")}),a.on("touchstart",()=>{this.emit("user_interaction")}),a.on("zoomend",()=>{this.emit("zoom_changed"),this.emit("user_interaction")}),a.on("tilesloaded",()=>{this.emit("tiles_loaded")}),a.on("dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),a.on("drag",()=>{this.emit("drag")}),a.on("dragend",()=>{this.emit("dragend")}),a.on("rotateend",()=>{this.emit("rotateend")}),a.on("styleimagemissing",l=>{a.loadImage(l.id,(c,h)=>{c||a.hasImage(l.id)||a.addImage(l.id,h)})}),this.addListener("solutionconfig_changed",()=>{let{wallOpacity:l,extrusionOpacity:c}=this.#a();a.getLayer(vp)&&a.setPaintProperty(vp,"fill-extrusion-opacity",l),a.getLayer(ba)&&a.setPaintProperty(ba,"fill-extrusion-opacity",c)}),this.set("map",a),this.set("element",e),this.set("rotatable",!0),this.set("tiltable",!0)}}#o(e){let t=this.#r,n=this.get("map"),s=null;return ni(e,({point:r})=>{if(t){let l=t?.queryRendered3DModels(r);if(l)return this.emit("mouseenter",{id:l?.properties?.originalId})}let a=n.queryRenderedFeatures(r,{layers:[xa,ba,Tr,y_,xp]}).find(l=>!l?.properties?.originalId.startsWith("MI_"));a&&a.properties.originalId!==s?(s=a.properties.originalId,this.emit("mouseenter",{id:a?.properties?.originalId})):!a&&s&&(s=null,this.emit("mouseenter",{id:null}))})}#a(){let e=this.get("solutionconfig"),t=e?.settings3D?.wallOpacity??In.DEFAULTS.wallOpacity,n=e?.settings3D?.extrusionOpacity??In.DEFAULTS.extrusionOpacity;return{wallOpacity:t,extrusionOpacity:n}}isMaxZoomLevelValid(e){return Number.isInteger(+e)&&e>=0}get isReady(){return this.#e===dn.READY}#s(){let e=this.get("tileUrl");if(e>""){let t=this.getMap(),n=t.getLayer(Ma),s=t.getSource(Qc),r=t.getLayer(xa)?xa:null,o={type:"raster",tiles:[e],tileSize:256};s&&n&&(t.removeLayer(Ma),t.removeSource(Qc)),t.addSource(Qc,o),t.addLayer({id:Ma,type:"raster",source:Qc,minzoom:0},r)}}setViewData(e){let t=this.getMap(),n=t?.getSource(ui);if(n){let s=Array.from(e.values());for(let r of s.filter(o=>o.properties.icon instanceof Image)){let o=r.properties.icon;t.hasImage(o.src)||t.addImage(o.src,o)}for(let r of s.filter(o=>o.properties.featureClass===Ee.LABEL_GRAPHIC)){if(!(r?.properties?.backgroundImage instanceof Image))continue;let o=r.properties.backgroundImage,a=`${o.src}+${JSON.stringify(r.properties.iconTextFit)}`;t.hasImage(a)||t.addImage(a,o,r.properties.iconTextFit),r.properties.imageId=a}n.setData({type:"FeatureCollection",features:s}),this.#i.setData(s)}}setMapsIndoorsTileURL(e){let t=this.getMap();this.get("tileUrl")!==e&&e>""&&(this.set("tileUrl",e),t.getLayer(Ma)||this.isReady?this.#s():t.once("load",()=>{this.#s()}))}get DirectionsRenderer(){return Er}getMap(){return this.get("map")}deallocate(){this.getMap().remove(),this.set("map",null)}getBounds(){let e=this.get("map");if(e&&e.getBounds){let t=e.getBounds();return{west:t.getWest(),south:t.getSouth(),east:t.getEast(),north:t.getNorth()}}return null}getBearing(){let e=this.get("map");return e&&e.getBearing?e.getBearing():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setLabelOptions(){}fitBounds({west:e,south:t,east:n,north:s},r){return new Promise(o=>{let a=this.get("map");if(a&&a.fitBounds){this.once("idle",o);let l={lon:e,lat:t},c={lon:n,lat:s};a.fitBounds([l,c],{padding:r,bearing:a.getBearing(),pitch:a.getPitch(),linear:!0,duration:1e3})}})}getZoom(){let e=this.get("map");return e&&e.getZoom?e.getZoom()+1:null}getMaxZoom(){let e=this.get("map");if(e&&e.getMaxZoom)return e.getMaxZoom()+1}enableZoom22(){let e=this.get("map");e&&e.setMaxZoom&&!this.#n&&(e.setMaxZoom(Sa(25)),e.getLayer(Ma)||this.isReady?this.#s():e.once("load",()=>{this.#s()}))}getPitch(){let e=this.get("map");return e&&e.getPitch?e.getPitch():0}setZoom(e){let t=this.get("map");t&&t.setZoom&&t.setZoom(e-1)}getCenter(){let e=this.get("map");return e&&e.getCenter?e.getCenter():null}setCenter({lat:e,lng:t}){let n=this.get("map");n&&n.setCenter&&n.setCenter([t,e])}setSolutionConfig(e){this.set("solutionconfig",e)}panTo({lat:e,lng:t}){let n=this.get("map");n&&n.panTo&&n.panTo([t,e])}easeTo({center:e,rotation:t,tilt:n,easing:s}){let r=this.get("map");r&&r.easeTo&&r.easeTo({center:e,bearing:t,pitch:n,easing:s})}tilt(e,t){let n=this.get("map");t?n.easeTo({pitch:e,duration:t}):n.setPitch(e)}rotate(e){this.get("map").setBearing(e)}panToBounds({west:e,south:t,east:n,north:s}){let r=this.get("map");if(r&&r.panTo&&mapboxgl.LngLatBounds){let a=new mapboxgl.LngLatBounds([e,t,n,s]).getCenter();this.panTo(a)}}getDiv(){return this.get("element")}project({lat:e,lng:t}){let n=this.get("map");return n&&n.project?n.project({lat:e,lng:t}):null}unproject({x:e,y:t}){let n=this.get("map");return n&&n.unproject?n.unproject([e,t]):null}addLogo(){if(this.isReady){if(this.get("map")){let t=this.getDiv();if(t){let n=document.createElement("img");n.id="mi_map_logo",n.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",n.style.width="96px",n.style.height="20px",n.style.margin="5px",n.style.position="absolute",n.style.right="0",n.style.bottom="18px",t.appendChild(n),new ResizeObserver(()=>{t.clientWidth<359||t.clientHeight<359?n.style.display!=="none"&&(n.style.display="none"):n.style.display==="none"&&(n.style.display="")}).observe(t)}}}else this.once("ready",()=>{this.addLogo()})}setPositionProvider(e){let t=this.getMap();this.#t?this.#t.setProvider(e):this.#t=new Ul(t,e)}setFloorPlan(e){let t=this.get("map");this.isReady&&t.getSource(va)?t.getSource(va).setData(e):t.once("load",()=>this.setFloorPlan(e))}hideFeatures(){}setSlot(){}getSlot(){}};function Sa(i){return isNaN(i)?20:i-1>0?i-1:20}E();E();var nr="MI_POSITION_SOURCE",bp="MI_CIRCLE_LAYER",Mp="MI_FILL_LAYER",th=class extends Et{#e=null;constructor(e,t){if(super(),!(e instanceof mapboxgl.Map))throw new Error("MapboxBlueDot: map must be an instance of mapboxgl.Map");e.on("style.load",()=>{this.#t(e),this.#e&&this.#n(this.#e)}),this.#t(e),this.on("provider_changed",n=>{let s=document.querySelector("mi-my-position")??t;if(n.oldValue&&(n.oldValue.off?(n.oldValue.off("position_received",this.#n.bind(this)),n.oldValue.off("position_error",this.#i.bind(this))):(s.removeEventListener("position_received",this.#n.bind(this)),s.removeEventListener("position_error",this.#i.bind(this)))),n.newValue){let r=n.newValue,o=r.options.positionMarkerStyles,a=r.options.accuracyCircleStyles;this.set("markerOptions",{fillColor:o.fillColor,fillOpacity:parseFloat(o.fillOpacity),strokeColor:o.strokeColor,strokeWeight:parseInt(o.strokeWeight),radius:parseInt(o.radius)}),this.set("accuracyOptions",a),this.set("maxAccuracy",r.options.maxAccuracy),r.on?(r.on("position_received",this.#n.bind(this)),r.on("position_error",this.#i.bind(this))):(s.addEventListener("position_received",this.#n.bind(this)),s.addEventListener("position_error",this.#i.bind(this))),r.hasValidPosition()&&this.#n({position:r.currentPosition,accurate:r.positionIsAccurate})}}),this.setValues({map:e,provider:t})}#t(e){!e||(e.getSource(nr)||e.addSource(nr,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(bp)||e.addLayer({id:bp,filter:["all",["==","$type","Point"]],type:"circle",slot:"top",source:nr,paint:{"circle-color":["get","fillColor"],"circle-radius":["get","radius"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":["get","strokeWeight"],"circle-stroke-color":["get","strokeColor"],"circle-stroke-opacity":["get","fillOpacity"],"circle-pitch-alignment":"map","circle-pitch-scale":"viewport","circle-emissive-strength":1}}),e.getLayer(Mp)||e.addLayer({id:Mp,filter:["all",["==","$type","Polygon"]],type:"fill",slot:"top",source:nr,paint:{"fill-color":["get","fillColor"],"fill-opacity":["to-number",["get","fillOpacity"]]}}))}#n(e){let n=this.get("map").getSource(nr),s=e?.detail?e.detail.position.coords:e.position.coords,r=this.get("maxAccuracy"),o=this.get("markerOptions"),a=this.get("accuracyOptions");if(!(!n||!s))if(s.accuracy<=r){let l={type:"Feature",geometry:{type:"Point",coordinates:[s.longitude,s.latitude]},properties:o},c=Dl(l,s.accuracy,{steps:360,units:"meters",properties:a});n.setData({type:"FeatureCollection",features:[l,c]}),this.#e=e}else n.setData({type:"FeatureCollection",features:[]})}#i(){let t=this.get("map").getSource(nr);!t||t.setData({type:"FeatureCollection",features:[]})}setProvider(e){this.set("provider",e)}deallocate(){let e=this.get("map");e.removeLayer(bp),e.removeLayer(Mp),e.removeSource(nr),this.set("provider",null),this.set("map",null)}};E();var Wi=Object.freeze({MODEL2D:"MODEL2D",WALLS2D:"WALLS2D",MODEL3D:"MODEL3D",WALLS3D:"WALLS3D",EXTRUSION3D:"EXTRUSION3D",EXTRUDEDBUILDINGS:"EXTRUDEDBUILDINGS"});E();E();E();var wa,Sp,fo,nh;function ih(i,e=1/0,t=null){Sp||(Sp=new Kn(2,2,1,1)),fo||(fo=new Yn({uniforms:{blitTexture:new lo(i)},vertexShader:`
			varying vec2 vUv;
			void main(){
				vUv = uv;
				gl_Position = vec4(position.xy * 1.0,0.,.999999);
			}`,fragmentShader:`
			uniform sampler2D blitTexture; 
			varying vec2 vUv;

			void main(){ 
				gl_FragColor = vec4(vUv.xy, 0, 1);
				
				#ifdef IS_SRGB
				gl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );
				#else
				gl_FragColor = texture2D( blitTexture, vUv);
				#endif
			}`})),fo.uniforms.blitTexture.value=i,fo.defines.IS_SRGB=i.colorSpace==Nt,fo.needsUpdate=!0,nh||(nh=new St(Sp,fo),nh.frustumCulled=!1);let n=new kt,s=new Bn;s.add(nh),t===null&&(t=wa=new ds({antialias:!1}));let r=Math.min(i.image.width,e),o=Math.min(i.image.height,e);t.setSize(r,o),t.clear(),t.render(s,n);let a=document.createElement("canvas"),l=a.getContext("2d");a.width=r,a.height=o,l.drawImage(t.domElement,0,0,r,o);let c=new Fc(a);return c.minFilter=i.minFilter,c.magFilter=i.magFilter,c.wrapS=i.wrapS,c.wrapT=i.wrapT,c.colorSpace=i.colorSpace,c.name=i.name,wa&&(wa.forceContextLoss(),wa.dispose(),wa=null),c}var v_={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},po=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Tp(e)}),this.register(function(e){return new Ip(e)}),this.register(function(e){return new Pp(e)}),this.register(function(e){return new Np(e)}),this.register(function(e){return new Op(e)}),this.register(function(e){return new Dp(e)}),this.register(function(e){return new Rp(e)}),this.register(function(e){return new Cp(e)}),this.register(function(e){return new Lp(e)}),this.register(function(e){return new Up(e)}),this.register(function(e){return new Fp(e)}),this.register(function(e){return new Bp(e)}),this.register(function(e){return new kp(e)}),this.register(function(e){return new zp(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r=new Ep,o=[];for(let a=0,l=this.pluginCallbacks.length;a<l;a++)o.push(this.pluginCallbacks[a](r));r.setPlugins(o),r.write(e,t,s).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,s,r,t)})}},We={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},wp="KHR_mesh_quantization",zn={};zn[Xt]=We.NEAREST;zn[ma]=We.NEAREST_MIPMAP_NEAREST;zn[rs]=We.NEAREST_MIPMAP_LINEAR;zn[Ot]=We.LINEAR;zn[Ks]=We.LINEAR_MIPMAP_NEAREST;zn[Wn]=We.LINEAR_MIPMAP_LINEAR;zn[li]=We.CLAMP_TO_EDGE;zn[Ui]=We.REPEAT;zn[Zs]=We.MIRRORED_REPEAT;var x_={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},vT=new Re,b_=12,xT=1179937895,bT=2,M_=8,MT=1313821514,ST=5130562;function Aa(i,e){return i.length===e.length&&i.every(function(t,n){return t===e[n]})}function wT(i){return new TextEncoder().encode(i).buffer}function AT(i){return Aa(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function ET(i,e,t){let n={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let r=0;r<i.itemSize;r++){let o;i.itemSize>4?o=i.array[s*i.itemSize+r]:(r===0?o=i.getX(s):r===1?o=i.getY(s):r===2?o=i.getZ(s):r===3&&(o=i.getW(s)),i.normalized===!0&&(o=co.normalize(o,i.array))),n.min[r]=Math.min(n.min[r],o),n.max[r]=Math.max(n.max[r],o)}return n}function A_(i){return Math.ceil(i/4)*4}function Ap(i,e=0){let t=A_(i.byteLength);if(t!==i.byteLength){let n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let s=i.byteLength;s<t;s++)n[s]=e;return n.buffer}return i}function S_(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function w_(i,e){if(i.toBlob!==void 0)return new Promise(n=>i.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}var Ep=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+pa}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let s=this,r=s.buffers,o=s.json;n=s.options;let a=s.extensionsUsed,l=s.extensionsRequired,c=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(a),u=Object.keys(l);if(h.length>0&&(o.extensionsUsed=h),u.length>0&&(o.extensionsRequired=u),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(c),f.onloadend=function(){let d=Ap(f.result),y=new DataView(new ArrayBuffer(M_));y.setUint32(0,d.byteLength,!0),y.setUint32(4,ST,!0);let g=Ap(wT(JSON.stringify(o)),32),p=new DataView(new ArrayBuffer(M_));p.setUint32(0,g.byteLength,!0),p.setUint32(4,MT,!0);let m=new ArrayBuffer(b_),M=new DataView(m);M.setUint32(0,xT,!0),M.setUint32(4,bT,!0);let b=b_+p.byteLength+g.byteLength+y.byteLength+d.byteLength;M.setUint32(8,b,!0);let S=new Blob([m,p,g,y,d],{type:"application/octet-stream"}),O=new FileReader;O.readAsArrayBuffer(S),O.onloadend=function(){t(O.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(c),f.onloadend=function(){let d=f.result;o.buffers[0].uri=d,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,s=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in r.gltfExtensions)t.extensions[o]=r.gltfExtensions[o],s[o]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new F;for(let s=0,r=e.count;s<r;s++)if(Math.abs(n.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),s=new F;for(let r=0,o=n.count;r<o;r++)s.fromBufferAttribute(n,r),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(r,s.x,s.y,s.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(s.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(s.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(d){return d.colorSpace===Nt?function(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}:function(g){return g}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof ro&&(e=ih(e)),t instanceof ro&&(t=ih(t));let s=e?e.image:null,r=t?t.image:null,o=Math.max(s?s.width:0,r?r.width:0),a=Math.max(s?s.height:0,r?r.height:0),l=S_();l.width=o,l.height=a;let c=l.getContext("2d",{willReadFrequently:!0});c.fillStyle="#00ffff",c.fillRect(0,0,o,a);let h=c.getImageData(0,0,o,a);if(s){c.drawImage(s,0,0,o,a);let d=n(e),y=c.getImageData(0,0,o,a).data;for(let g=2;g<y.length;g+=4)h.data[g]=d(y[g]/256)*256}if(r){c.drawImage(r,0,0,o,a);let d=n(t),y=c.getImageData(0,0,o,a).data;for(let g=1;g<y.length;g+=4)h.data[g]=d(y[g]/256)*256}c.putImageData(h,0,0);let f=(e||t).clone();return f.source=new eo(l),f.colorSpace=bi,f.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),f}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,s,r){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(t){case We.BYTE:case We.UNSIGNED_BYTE:a=1;break;case We.SHORT:case We.UNSIGNED_SHORT:a=2;break;default:a=4}let l=e.itemSize*a;r===We.ARRAY_BUFFER&&(l=Math.ceil(l/4)*4);let c=A_(s*l),h=new DataView(new ArrayBuffer(c)),u=0;for(let y=n;y<n+s;y++){for(let g=0;g<e.itemSize;g++){let p;e.itemSize>4?p=e.array[y*e.itemSize+g]:(g===0?p=e.getX(y):g===1?p=e.getY(y):g===2?p=e.getZ(y):g===3&&(p=e.getW(y)),e.normalized===!0&&(p=co.normalize(p,e.array))),t===We.FLOAT?h.setFloat32(u,p,!0):t===We.INT?h.setInt32(u,p,!0):t===We.UNSIGNED_INT?h.setUint32(u,p,!0):t===We.SHORT?h.setInt16(u,p,!0):t===We.UNSIGNED_SHORT?h.setUint16(u,p,!0):t===We.BYTE?h.setInt8(u,p):t===We.UNSIGNED_BYTE&&h.setUint8(u,p),u+=a}u%l!==0&&(u+=l-u%l)}let f={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return r!==void 0&&(f.target=r),r===We.ARRAY_BUFFER&&(f.byteStride=l),this.byteOffset+=c,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let o=Ap(r.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,s(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,s){let r=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(e.array.constructor===Float32Array)a=We.FLOAT;else if(e.array.constructor===Int32Array)a=We.INT;else if(e.array.constructor===Uint32Array)a=We.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=We.SHORT;else if(e.array.constructor===Uint16Array)a=We.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=We.BYTE;else if(e.array.constructor===Uint8Array)a=We.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;let l=ET(e,n,s),c;t!==void 0&&(c=e===t.index?We.ELEMENT_ARRAY_BUFFER:We.ARRAY_BUFFER);let h=this.processBufferView(e,a,n,s,c),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:a,count:s,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(u)-1}processImage(e,t,n,s="image/png"){if(e!==null){let r=this,o=r.cache,a=r.json,l=r.options,c=r.pending;o.images.has(e)||o.images.set(e,{});let h=o.images.get(e),u=s+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];a.images||(a.images=[]);let f={mimeType:s},d=S_();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);let y=d.getContext("2d",{willReadFrequently:!0});if(n===!0&&(y.translate(0,d.height),y.scale(1,-1)),e.data!==void 0){t!==pn&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let p=new Uint8ClampedArray(e.height*e.width*4);for(let m=0;m<p.length;m+=4)p[m+0]=e.data[m+0],p[m+1]=e.data[m+1],p[m+2]=e.data[m+2],p[m+3]=e.data[m+3];y.putImageData(new ImageData(p,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)y.drawImage(e,0,0,d.width,d.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");l.binary===!0?c.push(w_(d,s).then(p=>r.processBufferViewImage(p)).then(p=>{f.bufferView=p})):d.toDataURL!==void 0?f.uri=d.toDataURL(s):c.push(w_(d,s).then(p=>new FileReader().readAsDataURL(p)).then(p=>{f.uri=p}));let g=a.images.push(f)-1;return h[u]=g,g}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:zn[e.magFilter],minFilter:zn[e.minFilter],wrapS:zn[e.wrapS],wrapT:zn[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let n=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof ro&&(e=ih(e,n.maxTextureSize));let o=e.userData.mimeType;o==="image/webp"&&(o="image/png");let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(a.name=e.name),this._invokeAll(function(c){c.writeTexture&&c.writeTexture(e,a)});let l=r.textures.push(a)-1;return s.textures.set(e,l),l}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=e.color.toArray().concat([e.opacity]);if(Aa(r,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(l,a),s.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){let a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),s.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){let a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let c={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(c,e.emissiveMap),s.emissiveTexture=c}}if(e.normalMap){let a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),s.normalTexture=a}if(e.aoMap){let a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),s.occlusionTexture=a}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===Nn&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,s)});let o=n.materials.push(s)-1;return t.materials.set(e,o),o}processMesh(e){let t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let S=0,O=e.material.length;S<O;S++)s.push(e.material[S].uuid);else s.push(e.material.uuid);let r=s.join(":");if(t.meshes.has(r))return t.meshes.get(r);let o=e.geometry,a;e.isLineSegments?a=We.LINES:e.isLineLoop?a=We.LINE_LOOP:e.isLine?a=We.LINE_STRIP:e.isPoints?a=We.POINTS:a=e.material.wireframe?We.LINES:We.TRIANGLES;let l={},c={},h=[],u=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=o.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let y=null;for(let S in o.attributes){if(S.slice(0,5)==="morph")continue;let O=o.attributes[S];if(S=f[S]||S.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(S)||(S="_"+S),t.attributes.has(this.getUID(O))){c[S]=t.attributes.get(this.getUID(O));continue}y=null;let R=O.array;S==="JOINTS_0"&&!(R instanceof Uint16Array)&&!(R instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),y=new ft(new Uint16Array(R),O.itemSize,O.normalized));let C=this.processAccessor(y||O,o);C!==null&&(S.startsWith("_")||this.detectMeshQuantization(S,O),c[S]=C,t.attributes.set(this.getUID(O),C))}if(d!==void 0&&o.setAttribute("normal",d),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let S=[],O=[],L={};if(e.morphTargetDictionary!==void 0)for(let R in e.morphTargetDictionary)L[e.morphTargetDictionary[R]]=R;for(let R=0;R<e.morphTargetInfluences.length;++R){let C={},j=!1;for(let v in o.morphAttributes){if(v!=="position"&&v!=="normal"){j||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),j=!0);continue}let _=o.morphAttributes[v][R],x=v.toUpperCase(),T=o.attributes[v];if(t.attributes.has(this.getUID(_,!0))){C[x]=t.attributes.get(this.getUID(_,!0));continue}let P=_.clone();if(!o.morphTargetsRelative)for(let U=0,N=_.count;U<N;U++)for(let H=0;H<_.itemSize;H++)H===0&&P.setX(U,_.getX(U)-T.getX(U)),H===1&&P.setY(U,_.getY(U)-T.getY(U)),H===2&&P.setZ(U,_.getZ(U)-T.getZ(U)),H===3&&P.setW(U,_.getW(U)-T.getW(U));C[x]=this.processAccessor(P,o),t.attributes.set(this.getUID(T,!0),C[x])}u.push(C),S.push(e.morphTargetInfluences[R]),e.morphTargetDictionary!==void 0&&O.push(L[R])}l.weights=S,O.length>0&&(l.extras={},l.extras.targetNames=O)}let g=Array.isArray(e.material);if(g&&o.groups.length===0)return null;let p=!1;if(g&&o.index===null){let S=[];for(let O=0,L=o.attributes.position.count;O<L;O++)S[O]=O;o.setIndex(S),p=!0}let m=g?e.material:[e.material],M=g?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let S=0,O=M.length;S<O;S++){let L={mode:a,attributes:c};if(this.serializeUserData(o,L),u.length>0&&(L.targets=u),o.index!==null){let C=this.getUID(o.index);(M[S].start!==void 0||M[S].count!==void 0)&&(C+=":"+M[S].start+":"+M[S].count),t.attributes.has(C)?L.indices=t.attributes.get(C):(L.indices=this.processAccessor(o.index,o,M[S].start,M[S].count),t.attributes.set(C,L.indices)),L.indices===null&&delete L.indices}let R=this.processMaterial(m[M[S].materialIndex]);R!==null&&(L.material=R),h.push(L)}p===!0&&o.setIndex(null),l.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(S){S.writeMesh&&S.writeMesh(e,l)});let b=n.meshes.push(l)-1;return t.meshes.set(r,b),b}detectMeshQuantization(e,t){if(this.extensionsUsed[wp])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let s=e.split("_",1)[0];v_[s]&&v_[s].includes(n)&&(this.extensionsUsed[wp]=!0,this.extensionsRequired[wp]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:co.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){let n=this.json,s=this.nodeMap;n.animations||(n.animations=[]),e=po.Utils.mergeMorphTargetTracks(e.clone(),t);let r=e.tracks,o=[],a=[];for(let l=0;l<r.length;++l){let c=r[l],h=He.parseTrackName(c.name),u=He.findNode(t,h.nodeName),f=x_[h.propertyName];if(h.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(h.objectIndex):u=void 0),!u||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name);continue}let d=1,y=c.values.length/c.times.length;f===x_.morphTargetInfluences&&(y/=u.morphTargetInfluences.length);let g;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(g="CUBICSPLINE",y/=3):c.getInterpolation()===cs?g="STEP":g="LINEAR",a.push({input:this.processAccessor(new ft(c.times,d)),output:this.processAccessor(new ft(c.values,y)),interpolation:g}),o.push({sampler:a.length-1,target:{node:s.get(u),path:f}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:a,channels:o}),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;let o=e.skeleton.bones[0];if(o===void 0)return null;let a=[],l=new Float32Array(r.bones.length*16),c=new Ie;for(let u=0;u<r.bones.length;++u)a.push(n.get(r.bones[u])),c.copy(r.boneInverses[u]),c.multiply(e.bindMatrix).toArray(l,u*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new ft(l,16)),joints:a,skeleton:n.get(o)}),s.skin=t.skins.length-1}processNode(e){let t=this.json,n=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);let r={};if(n.trs){let a=e.quaternion.toArray(),l=e.position.toArray(),c=e.scale.toArray();Aa(a,[0,0,0,1])||(r.rotation=a),Aa(l,[0,0,0])||(r.translation=l),Aa(c,[1,1,1])||(r.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),AT(e.matrix)===!1&&(r.matrix=e.matrix.elements);if(e.name!==""&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){let a=this.processMesh(e);a!==null&&(r.mesh=a)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let a=[];for(let l=0,c=e.children.length;l<c;l++){let h=e.children[l];if(h.visible||n.onlyVisible===!1){let u=this.processNode(h);u!==null&&a.push(u)}}a.length>0&&(r.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,r)});let o=t.nodes.push(r)-1;return s.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);let r=[];for(let o=0,a=e.children.length;o<a;o++){let l=e.children[o];if(l.visible||n.onlyVisible===!1){let c=this.processNode(l);c!==null&&r.push(c)}}r.length>0&&(s.nodes=r),this.serializeUserData(e,s)}processObjects(e){let t=new Bn;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(s){s.beforeParse&&s.beforeParse(e)});let n=[];for(let s=0;s<e.length;s++)e[s]instanceof Bn?this.processScene(e[s]):n.push(e[s]);n.length>0&&this.processObjects(n);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll(function(s){s.afterParse&&s.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},Tp=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let n=this.writer,s=n.json,r=n.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},r[this.name]=!0);let a=s.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},Ip=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Rp=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let o={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),r.clearcoatTexture=o}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let o={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){let o={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),r.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Cp=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let s=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Lp=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let o={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),r.iridescenceTexture=o}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let o={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Pp=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let o={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),r.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Np=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let o={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),r.thicknessTexture=o}e.attenuationDistance!==1/0&&(r.attenuationDistance=e.attenuationDistance),r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Op=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Dp=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(vT)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.specularIntensityMap){let o={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),r.specularTexture=o}if(e.specularColorMap){let o={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),r.specularColorTexture=o}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Up=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.sheenRoughnessMap){let o={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),r.sheenRoughnessTexture=o}if(e.sheenColorMap){let o={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),r.sheenColorTexture=o}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Fp=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.anisotropyMap){let o={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),r.anisotropyTexture=o}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Bp=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},kp=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.bumpMap){let o={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),r.bumpTexture=o}r.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},zp=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,s=e,r=new Float32Array(s.count*3),o=new Float32Array(s.count*4),a=new Float32Array(s.count*3),l=new Ie,c=new F,h=new Dn,u=new F;for(let d=0;d<s.count;d++)s.getMatrixAt(d,l),l.decompose(c,h,u),c.toArray(r,d*3),h.toArray(o,d*4),u.toArray(a,d*3);let f={TRANSLATION:n.processAccessor(new ft(r,3)),ROTATION:n.processAccessor(new ft(o,4)),SCALE:n.processAccessor(new ft(a,3))};s.instanceColor&&(f._COLOR_0=n.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:f},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};po.Utils={insertKeyframe:function(i,e){let n=i.getValueSize(),s=new i.TimeBufferType(i.times.length+1),r=new i.ValueBufferType(i.values.length+n),o=i.createInterpolant(new i.ValueBufferType(n)),a;if(i.times.length===0){s[0]=e;for(let l=0;l<n;l++)r[l]=0;a=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<.001)return 0;s[0]=e,s.set(i.times,1),r.set(o.evaluate(e),0),r.set(i.values,n),a=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;s[s.length-1]=e,s.set(i.times,0),r.set(i.values,0),r.set(o.evaluate(e),i.values.length),a=s.length-1}else for(let l=0;l<i.times.length;l++){if(Math.abs(i.times[l]-e)<.001)return l;if(i.times[l]<e&&i.times[l+1]>e){s.set(i.times.slice(0,l+1),0),s[l+1]=e,s.set(i.times.slice(l+1),l+2),r.set(i.values.slice(0,(l+1)*n),0),r.set(o.evaluate(e),(l+1)*n),r.set(i.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return i.times=s,i.values=r,a},mergeMorphTargetTracks:function(i,e){let t=[],n={},s=i.tracks;for(let r=0;r<s.length;++r){let o=s[r],a=He.parseTrackName(o.name),l=He.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(hs)}let c=l.morphTargetInfluences.length,h=l.morphTargetDictionary[a.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let u;if(n[l.uuid]===void 0){u=o.clone();let d=new u.ValueBufferType(c*u.times.length);for(let y=0;y<u.times.length;y++)d[y*c+h]=u.values[y];u.name=(a.nodeName||"")+".morphTargetInfluences",u.values=d,n[l.uuid]=u,t.push(u);continue}let f=o.createInterpolant(new o.ValueBufferType(1));u=n[l.uuid];for(let d=0;d<u.times.length;d++)u.values[d*c+h]=f.evaluate(u.times[d]);for(let d=0;d<o.times.length;d++){let y=this.insertKeyframe(u,o.times[d]);u.values[y*c+h]=o.values[d]}}return i.tracks=t,i}};var TT=!!document.createElement("canvas").getContext("webgl2"),sh,rh,mo,ir=class{static async createModel(e){if(e?.properties?.featureClass!==Ee.MODEL2D||!e?.properties?.imageUrl)return;let t=btoa(e.properties.imageUrl.toLowerCase());if(Mn(this,mo).has(t))return Mn(this,mo).get(t);let n=new Bn,[s,r]=await kg(()=>Mn(this,sh).loadAsync(e.properties.imageUrl));if(s)return;TT&&(r.minFilter=Ot);let o=new Kn(r.image.naturalWidth,r.image.naturalHeight),a=new gn({map:r,transparent:!0,depthTest:!1}),l=new St(o,a);n.add(l);let c=await Mn(this,rh).parseAsync(n,{binary:!0}),h=new Blob([c],{type:"application/octet-stream"}),u=URL.createObjectURL(h);return Mn(this,mo).set(t,u),u}};sh=new WeakMap,rh=new WeakMap,mo=new WeakMap,di(ir,sh,new ys),di(ir,rh,new po),di(ir,mo,new Map);var Jn="MI_GEOJSON_SOURCE",Ea="MI_FLOOR_PLAN_SOURCE",Vp="MI_FLOOR_PLAN_FILL",Hp="MI_FLOOR_PLAN_LINE",Gp="MI_CLIP_LAYER_SOURCE",IT="MI_CLIP_LAYER",sr="MI_HIGHLIGHT_LAYER",Ta="MI_MODEL_3D_LAYER",Ia="MI_MODEL_2D_LAYER",RT="MI_OUTLINE_LAYER",rr="MI_POINT_LAYER",Ra="MI_POLYGON_LAYER",or="MI_ROOMS_LAYER",Ca="MI_TILES_LAYER",oh="MI_TILES_SOURCE",La="MI_WALLS_LAYER",E_="MI_FLAT_LABELS_LAYER",Wp="MI_GRAPHIC_LABELS_LAYER",ah=class extends Et{#e=dn.INITIALIZING;#t;#n;#i;#r=[];#o=!0;#a=new Set;constructor({element:e,maxZoom:t,mapsIndoorsTransitionLevel:n=17,showMapMarkers:s,showRoadNameLabels:r,lightPreset:o="day",accessToken:a,pitch:l=0,bearing:c=0,...h}){super(),this.#n=this.isMaxZoomLevelValid(t),this.#i=n;let u=!0,f=null;if(mapboxgl&&mapboxgl.Map){mapboxgl.accessToken=a;let g=new mapboxgl.Map({container:e,maxZoom:Sa(t),style:"mapbox://styles/mapspeople/clrakuu6s003j01pf11uz5d45?optimize=true",bearing:c,pitch:l,...h});Rt.log(pt.appLifeTime.MAP_INSTANTIATED),g.on("style.load",()=>{this.#a.clear();let m=g.getStyle()?.imports?.some(S=>S.id==="basemap")??!1,{wallOpacity:M,extrusionOpacity:b}=this.#l();g.addSource(Ea,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),g.addSource(Jn,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),g.addSource(Gp,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),m&&(g.setConfigProperty("basemap","lightPreset",o),s!==void 0&&(g.setConfigProperty("basemap","showPointOfInterestLabels",s),g.setConfigProperty("basemap","showTransitLabels",s)),r!==void 0&&g.setConfigProperty("basemap","showRoadLabels",r),this.getMapboxZoomLevel(h?.zoom)>this.getMapboxZoomLevel(this.#i)&&(go(0,g),g.setConfigProperty("basemap","showPointOfInterestLabels",!1),g.setConfigProperty("basemap","showTransitLabels",!1))),g.addLayer({id:IT,type:"clip",source:Gp,layout:{"clip-layer-types":["model"],"clip-layer-scope":["basemap"]}}),g.addLayer({filter:["any",["==","featureClass",Ee.POLYGON],["==","featureClass",Ee.MODEL2D]],id:Ra,type:"fill",slot:"middle",source:Jn,layout:{"fill-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"fill-color":["to-color",["get","fillColor"],se.polygon.fillColor],"fill-opacity":["number",["get","fillOpacity"],se.polygon.fillOpacity]}}),g.addLayer({id:Vp,type:"fill",slot:"middle",source:Ea,paint:{"fill-color":["match",["get","type"],"floorplan","#ffffff","extrusion","#fcfcf2","#ffffff"]}}),g.addLayer({id:Hp,type:"line",slot:"middle",source:Ea,filter:["==",["get","type"],"floorplan"],paint:{"line-width":1.2,"line-color":"#6B7280"}}),g.addLayer({filter:["==","featureClass",Ee.POLYGON],id:RT,type:"line",slot:"middle",source:Jn,layout:{"line-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"line-width":["number",["get","strokeWidth"],se.polygon.strokeWidth],"line-color":["to-color",["get","strokeColor"],se.polygon.strokeColor],"line-opacity":["number",["get","strokeOpacity"],se.polygon.strokeOpacity]}}),g.addLayer({filter:["any",["==","featureClass",Ee.LABEL_FLAT]],id:E_,source:Jn,type:"symbol",slot:"middle",layout:{"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-size":["interpolate",["exponential",2],["zoom"],1,["number",["*",["get","labelStyleSize"],2384185791015625e-22],["*",se.labelStyle.textSize,2384185791015625e-22]],22,["number",["get","labelStyleSize"]],23,["number",["*",["get","labelStyleSize"],2],["*",se.labelStyle.textSize,2]],24,["number",["*",["get","labelStyleSize"],4],["*",se.labelStyle.textSize,4]],25,["number",["*",["get","labelStyleSize"],8],["*",se.labelStyle.textSize,8]]],"text-ignore-placement":!0,"text-allow-overlap":!0,"icon-allow-overlap":!0,"text-rotation-alignment":"map","text-rotate":["number",["get","labelStyleBearing"],se.labelStyle.bearing]},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),g.addLayer({filter:["==","featureClass",Ee.MODEL3D],id:Ta,type:"model",slot:"middle",source:Jn,paint:{"model-rotation":["get","rotation"],"model-scale":["get","scale"]},layout:{"model-id":["get","modelName"]}}),g.addLayer({filter:["any",["==","featureClass",Ee.WALL_EXTRUSION]],id:La,type:"fill-extrusion",slot:"middle",source:Jn,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":M,"fill-extrusion-height":["get","height"]}}),g.addLayer({id:or,filter:["==","featureClass",Ee.ROOM_EXTRUSION],type:"fill-extrusion",slot:"middle",source:Jn,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":b,"fill-extrusion-height":["get","height"]}}),g.addLayer({filter:["==","featureClass",Ee.MODEL2D],id:Ia,type:"model",slot:"middle",source:Jn,paint:{"model-rotation":["get","rotation"],"model-scale":["get","scale"],"model-translation":["get","translation"],"model-cast-shadows":!1},layout:{"model-id":["get","modelId"]}}),g.addLayer({filter:["any",["==","featureClass",Ee.LABEL_GRAPHIC]],id:Wp,source:Jn,slot:"top",type:"symbol",layout:{"icon-text-fit":"both","icon-image":["get","imageId"],"icon-allow-overlap":!0,"text-field":["get","labelText"],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-size":["number",["get","labelStyleSize"],se.labelStyle.textSize],"text-allow-overlap":!0,"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-letter-spacing":-.01,"text-padding":0},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),g.addLayer({filter:["all",["!=","iconAllowOverlap",!0],["any",["==","featureClass",Ee.POINT],["==","featureClass",Ee.LABEL_FLOATING]]],id:rr,type:"symbol",slot:"middle",source:Jn,layout:{"icon-allow-overlap":!1,"icon-optional":!0,"icon-image":["get","iconSrc"],"icon-anchor":["get","iconPlacement"],"icon-size":["number",["get","iconScale"],1],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-padding":0,"text-optional":!0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-size":["number",["get","labelStyleSize"],se.labelStyle.textSize],"text-letter-spacing":-.01,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!1},paint:{"text-color":["to-color",["get","labelStyleColor"],se.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],se.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],se.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],se.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],se.labelStyle.textOpacity]}}),g.addLayer({filter:["all",["==","iconAllowOverlap",!0],["any",["==","featureClass",Ee.POINT],["==","featureClass",Ee.LABEL_FLOATING]]],id:sr,type:"symbol",slot:"middle",source:Jn,layout:{"icon-allow-overlap":!0,"icon-optional":!1,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MIN_SAFE_INTEGER],"symbol-z-elevate":!0,"text-padding":0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Regular","Arial Unicode MS Regular"]],"text-size":["number",["get","labelSize"],12],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!0},paint:{"text-color":["to-color",["get","labelColor"],"hsl(217, 11%, 23%)"],"text-halo-color":["to-color",["get","labelShadowColor"],"#000"],"text-halo-width":["number",["get","labelShadowBlur"],0],"text-halo-blur":["case",[">",["get","labelShadowBlur"],0],1,0]}}),this.#e===dn.READY&&this.#c(),this.#e=dn.READY,this.emit("ready")}),g.on("moveend",()=>{this.emit("idle")}),g.on("move",()=>{this.emit("bounds_changed")}),g.on("center_changed",()=>{this.emit("center_changed")}),g.on("style.load",()=>{(g.getStyle()?.imports?.some(M=>M.id==="basemap")??!1)&&g.on("zoom",()=>{if(this.#o){let M=g.getZoom(),b=this.getMapboxZoomLevel(n),S=this.getMapboxZoomLevel(n+1),O=r===void 0,L=s===void 0,R;if(M>b&&M<S){let C=(M-b)/(S-b);R=1-C,O&&y(!0,g)}else M<S?(R=1,O&&y(!0,g),L&&d(!0,g)):M>b&&(R=0,O&&y(!1,g),L&&d(!1,g));go(R,g)}})}),g.on("click",p=>{let m=g.queryRenderedFeatures(p.point,{layers:[Ra,rr,sr,or,Wp,E_,Ta]}).find(M=>!M?.properties?.originalId?.startsWith("MI_")&&M?.properties?.clickable===!0);m&&m.properties.clickable!==!1&&this.emit("click",m.properties.originalId)}),g.on("mousemove",this.#s(66,g)),g.on("maptypeid_changed",()=>{this.emit("maptypeid_changed")}),g.on("touchstart",()=>{this.emit("user_interaction")}),g.on("zoomend",()=>{this.emit("zoom_changed"),this.emit("user_interaction")}),g.on("tilesloaded",()=>{this.emit("tiles_loaded")}),g.on("dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),g.on("drag",()=>{this.emit("drag")}),g.on("dragend",()=>{this.emit("dragend")}),g.on("rotateend",()=>{this.emit("rotateend")}),g.on("styleimagemissing",p=>{g.loadImage(p.id,(m,M)=>{m||g.hasImage(p.id)||g.addImage(p.id,M)})}),this.addListener("solutionconfig_changed",()=>{let{wallOpacity:p,extrusionOpacity:m}=this.#l();g.getLayer(La)&&g.setPaintProperty(La,"fill-extrusion-opacity",p),g.getLayer(or)&&g.setPaintProperty(or,"fill-extrusion-opacity",m)}),this.set("map",g),this.set("element",e),this.set("rotatable",!0),this.set("tiltable",!0),this.addListener("clipping_mask_changed",({newValue:p})=>{let m={type:"Feature",geometry:p,properties:{}};if(this.#e!==dn.READY){this.once("ready",()=>{this.set("clipping_mask",p,!0)});return}g.getSource(Gp)?.setData({type:"FeatureCollection",features:[m]})})}function d(g,p){u!==g&&(u=g,p.setConfigProperty("basemap","showPointOfInterestLabels",g),p.setConfigProperty("basemap","showPlaceLabels",g),p.setConfigProperty("basemap","showTransitLabels",g))}function y(g,p){f!==g&&(f=g,p.setConfigProperty("basemap","showRoadLabels",g))}}#s(e,t){let n=null;return ni(e,({point:s,lngLat:r})=>{if(!t.isStyleLoaded())return;let a=t.queryRenderedFeatures(s,{layers:[Ra,or,rr,sr,Wp,Ta]}).find(l=>!l?.properties?.originalId.startsWith("MI_"));a&&a.geometry.type==="Point"&&(a.geometry={type:"Point",coordinates:r.toArray()}),a&&a.properties.originalId!==n?(n=a.properties.originalId,this.emit("mouseenter",{id:a?.properties?.originalId})):!a&&n&&(n=null,this.emit("mouseenter",{id:null}))})}#l(){let e=this.get("solutionconfig"),t=e?.settings3D?.wallOpacity??In.DEFAULTS.wallOpacity,n=e?.settings3D?.extrusionOpacity??In.DEFAULTS.extrusionOpacity;return{wallOpacity:t,extrusionOpacity:n}}isMaxZoomLevelValid(e){return Number.isInteger(+e)&&e>=0}hideFeatures(e){if(!this.isReady){this.once("ready",()=>{this.hideFeatures(e)});return}let t=this.getMap();this.#r=e;let n=this.getZoom();e.includes(Wi.WALLS2D)?(t.setLayoutProperty(Vp,"visibility","none"),t.setLayoutProperty(Hp,"visibility","none")):(t.setLayoutProperty(Vp,"visibility","visible"),t.setLayoutProperty(Hp,"visibility","visible")),e.includes(Wi.WALLS3D)?t.setLayoutProperty(La,"visibility","none"):t.setLayoutProperty(La,"visibility","visible"),e.includes(Wi.MODEL2D)?t.setLayoutProperty(Ia,"visibility","none"):t.setLayoutProperty(Ia,"visibility","visible"),e.includes(Wi.MODEL3D)?t.setLayoutProperty(Ta,"visibility","none"):t.setLayoutProperty(Ta,"visibility","visible"),e.includes(Wi.EXTRUSION3D)?(t.setLayoutProperty(or,"visibility","none"),t.setPaintProperty(Ia,"model-translation",["literal",[0,0,0]])):(t.setLayoutProperty(or,"visibility","visible"),t.setPaintProperty(Ia,"model-translation",["get","translation"]));let c=e.includes(Wi.EXTRUDEDBUILDINGS);if(c)this.#o=!1,go(0,t);else if(n>this.#i+1)go(0,t);else if(this.#i<n&&n<this.#i+1){let h=(n-this.#i)/(this.#i+1-this.#i);go(h,t)}else go(1,t);c||(this.#o=!0)}get MapboxFeatures(){return Wi}get FeatureType(){return Wi}getHiddenFeatures(){return this.#r}get isReady(){return this.#e===dn.READY}#c(){let e=this.get("tileUrl");if(e>""){let t=this.getMap(),n=t.getLayer(Ca),s=t.getSource(oh),r=t.getLayer(Ra)?Ra:null,o={type:"raster",tiles:[e],tileSize:256},a=["interpolate",["linear"],["zoom"],this.getMapboxZoomLevel(this.#i),0,this.getMapboxZoomLevel(this.#i+1),1];s&&n&&(t.removeLayer(Ca),t.removeSource(oh)),t.addSource(oh,o),t.addLayer({id:Ca,type:"raster",source:oh,slot:"middle",paint:{"raster-opacity":a}},r)}}async setViewData(e){let t=this.getMap(),n=t?.getSource(Jn);if(!n)return;let s=[...e.values()];for(let[r,o]of s.entries()){if(o.id=r,o.properties?.hovered&&(o.properties.sortKey=o.properties.sortKey-1e5),o.properties?.icon instanceof Image){let a=o.properties.icon;t.hasImage(a.src)||t.addImage(a.src,a)}if(o.properties?.backgroundImage instanceof Image){let a=o.properties.backgroundImage,l=`${a.src}+${JSON.stringify(o.properties.iconTextFit)}`;t.hasImage(l)||t.addImage(l,a,o.properties.iconTextFit),o.properties.imageId=l}if(o.properties.featureClass===Ee.MODEL2D){let a=btoa(o.properties.imageUrl);if(o.properties.modelId=a,!this.#a.has(a)){this.#a.add(a);let l=await ir.createModel(o);if(!l)continue;t.addModel(a,l)}}if(o.properties.featureClass===Ee.MODEL3D){let a=o.properties.modelName;this.#a.has(a)||(this.#a.add(a),t.addModel(a,o.properties.url))}}n.setData({type:"FeatureCollection",features:s})}setMapsIndoorsTileURL(e){let t=this.getMap();this.get("tileUrl")!==e&&e>""&&(this.set("tileUrl",e),t.getLayer(Ca)||this.isReady?this.#c():t.once("load",()=>{this.#c()}))}get DirectionsRenderer(){return Er}getMapboxZoomLevel(e){return e-1}getMap(){return this.get("map")}deallocate(){this.getMap().remove(),this.set("map",null)}getBounds(){let e=this.get("map");if(e&&e.getBounds){let t=e.getBounds();return{west:t.getWest(),south:t.getSouth(),east:t.getEast(),north:t.getNorth()}}return null}getBearing(){let e=this.get("map");return e&&e.getBearing?e.getBearing():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setLabelOptions(){}fitBounds({west:e,south:t,east:n,north:s},r){return new Promise(o=>{let a=this.get("map");if(a&&a.fitBounds){this.once("idle",o);let l={lon:e,lat:t},c={lon:n,lat:s};a.fitBounds([l,c],{padding:r,bearing:a.getBearing(),pitch:a.getPitch(),linear:!0,duration:1e3})}})}getZoom(){let e=this.get("map");return e&&e.getZoom?e.getZoom()+1:null}getMaxZoom(){let e=this.get("map");if(e&&e.getMaxZoom)return e.getMaxZoom()+1}enableZoom22(){let e=this.get("map");e&&e.setMaxZoom&&!this.#n&&(e.setMaxZoom(Sa(25)),e.getLayer(Ca)||this.isReady?this.#c():e.once("load",()=>{this.#c()}))}enableDynamicLabelPosition(){let e=this.get("map").getLayer(rr),t=this.get("map").getLayer(sr);if(!e||!t){this.once("ready",()=>this.enableDynamicLabelPosition());return}this.get("map").setLayoutProperty(rr,"text-anchor",null),this.get("map").setLayoutProperty(rr,"text-variable-anchor",["literal",["center","bottom","top","left","right"]]),this.get("map").setLayoutProperty(rr,"text-justify","auto"),this.get("map").setLayoutProperty(sr,"text-anchor",null),this.get("map").setLayoutProperty(sr,"text-variable-anchor",["literal",["center","bottom","top","left","right"]]),this.get("map").setLayoutProperty(sr,"text-justify","auto")}getPitch(){let e=this.get("map");return e&&e.getPitch?e.getPitch():0}setZoom(e){let t=this.get("map");t&&t.setZoom&&t.setZoom(e-1)}getCenter(){let e=this.get("map");return e&&e.getCenter?e.getCenter():null}setCenter({lat:e,lng:t}){let n=this.get("map");n&&n.setCenter&&n.setCenter([t,e])}setSolutionConfig(e){this.set("solutionconfig",e)}panTo({lat:e,lng:t}){let n=this.get("map");n&&n.panTo&&n.panTo([t,e])}easeTo({center:e,rotation:t,tilt:n,easing:s}){let r=this.get("map");r&&r.easeTo&&r.easeTo({center:e,bearing:t,pitch:n,easing:s})}tilt(e,t){let n=this.get("map");t?n.easeTo({pitch:e,duration:t}):n.setPitch(e)}rotate(e){this.get("map").setBearing(e)}panToBounds({west:e,south:t,east:n,north:s}){let r=this.get("map");if(r&&r.panTo&&mapboxgl.LngLatBounds){let a=new mapboxgl.LngLatBounds([e,t,n,s]).getCenter();this.panTo(a)}}getDiv(){return this.get("element")}project({lat:e,lng:t}){let n=this.get("map");return n&&n.project?n.project({lat:e,lng:t}):null}unproject({x:e,y:t}){let n=this.get("map");return n&&n.unproject?n.unproject([e,t]):null}addLogo(){if(this.isReady){if(this.get("map")){let t=this.getDiv();if(t){let n=document.createElement("img");n.id="mi_map_logo",n.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",n.style.width="96px",n.style.height="20px",n.style.margin="5px",n.style.position="absolute",n.style.right="0",n.style.bottom="18px",t.appendChild(n),new ResizeObserver(()=>{t.clientWidth<359||t.clientHeight<359?n.style.display!=="none"&&(n.style.display="none"):n.style.display==="none"&&(n.style.display="")}).observe(t)}}}else this.once("ready",()=>{this.addLogo()})}setPositionProvider(e){let t=this.getMap();this.#t?this.#t.setProvider(e):this.#t=new th(t,e)}setFloorPlan(e){let t=this.get("map");this.isReady&&t.getSource(Ea)?t.getSource(Ea).setData(e):t.once("style.load",()=>this.setFloorPlan(e))}setSlot(e,t){this.get("map").setSlot(e,t)}getSlot(e){return this.get("map").getSlot(e)}};function go(i,e){if(isNaN(i))return;e.getConfigProperty("basemap","buildingsOpacity")!==i&&e.setConfigProperty("basemap","buildingsOpacity",i)}E();var P_=Jt(Sn()),N_=Jt(C_());E();var wt=Object.freeze({POSITION_UNKNOWN:"POSITION_UNKNOWN",POSITION_REQUESTING:"POSITION_REQUESTING",POSITION_INACCURATE:"POSITION_INACCURATE",POSITION_KNOWN:"POSITION_KNOWN",POSITION_CENTERED:"POSITION_CENTERED"});var L_={opacity:{"xx-small":{value:"0"},"x-small":{value:"0.08"},small:{value:"0.16"},medium:{value:"0.24"},large:{value:"0.48"},"x-large":{value:"0.72"},"xx-large":{value:"0.88"},"xxx-large":{value:"1"}}};var lh=class extends P_.default{constructor(e,t){if(super(),!navigator.geolocation){this.emit("position_error",{code:10,message:"Geolocation not available"});return}this.mapsIndoors=t.mapsIndoors,delete t.mapsIndoors,this.positionState,this.currentPosition,this.positionIsAccurate,this.options=(0,N_.default)({maxAccuracy:200,positionOptions:{timeout:3e4,enableHighAccuracy:!0,maximumAge:0},positionMarkerStyles:{radius:"12px",strokeWeight:"2px",strokeColor:ii(["color","white","white","value"],Qt)||"white",fillColor:ii(["color","blue","60","value"],Qt)||"#4169E1",fillOpacity:1},accuracyCircleStyles:{fillColor:ii(["color","blue","60","value"],Qt)||"#4169E1",fillOpacity:ii(["opacity","small","value"],L_)||.16}},t),e.className="mapsindoors position-control",this.positionButton=document.createElement("button"),this.positionButton.addEventListener("click",this.positionButtonClicked.bind(this)),e.appendChild(this.positionButton),!("permissions"in navigator)||!("query"in navigator.permissions)?this.setPositionState(wt.POSITION_UNKNOWN):navigator.permissions.query({name:"geolocation"}).then(n=>{n.state==="granted"?this.watchPosition():this.setPositionState(wt.POSITION_UNKNOWN)})}positionButtonClicked(e){switch(e.stopPropagation(),this.positionState){case wt.POSITION_UNKNOWN:this.watchPosition(!0);break;case wt.POSITION_KNOWN:case wt.POSITION_CENTERED:this.panToCurrentPosition();break}}setPositionProviderOnMapView(){let e=this.mapsIndoors.getMapView();e.isReady?e.setPositionProvider(this):e.once("ready",()=>{e.setPositionProvider(this)})}setPositionState(e){this.positionState=e;let t="mapsindoors position-control__button position-control__button--",n="";switch(this.positionState){case wt.POSITION_UNKNOWN:case wt.POSITION_INACCURATE:t+="unknown",n="Show position on map";break;case wt.POSITION_REQUESTING:t+="requesting",n="Requesting position...";break;case wt.POSITION_KNOWN:t+="known",n="Center position on map";break;case wt.POSITION_CENTERED:t+="centered",n="Center position on map";break}this.positionButton.className=t,this.positionButton.setAttribute("aria-label",n)}watchPosition(e=!1){if(!navigator.geolocation)return;this.setPositionState(wt.POSITION_REQUESTING),this.setPositionProviderOnMapView();let t=Date.now();navigator.geolocation.watchPosition(n=>{this.currentPosition&&n.coords.accuracy===this.currentPosition.coords.accuracy&&n.coords.latitude===this.currentPosition.coords.latitude&&n.coords.longitude===this.currentPosition.coords.longitude||(this.currentPosition=n,this.positionIsAccurate=this.currentPosition.coords.accuracy<=this.options.maxAccuracy,this.positionIsAccurate?this.setPositionState(wt.POSITION_KNOWN):(this.setPositionState(wt.POSITION_INACCURATE),this.emit("position_error",{code:11,message:"Inaccurate position: "+n.coords.accuracy})),this.emit("position_received",{position:this.currentPosition,selfInvoked:e,accurate:this.positionIsAccurate}))},n=>{(n.code!==3||!this.currentPosition||this.currentPosition.timestamp<=t)&&this.setPositionUnknown(n)},this.options.positionOptions)}setPositionUnknown(e){this.setPositionState(wt.POSITION_UNKNOWN),this.emit("position_error",e)}hasValidPosition(){return[wt.POSITION_KNOWN,wt.POSITION_CENTERED,wt.POSITION_INACCURATE].includes(this.positionState)}panToCurrentPosition(){!this.hasValidPosition()||(this.mapsIndoors.getMapView().panTo({lat:this.currentPosition.coords.latitude,lng:this.currentPosition.coords.longitude}),this.setPositionState(wt.POSITION_CENTERED),this.mapsIndoors.getMapView().once("idle",()=>{this.mapsIndoors.getMapView().once("idle",()=>{this.setPositionState(wt.POSITION_KNOWN)})}))}};var WT={GoogleMapsView:Nl,MapboxView:eh,MapboxV3View:ah},XT={GoogleMapsProvider:zo,MapboxProvider:Go,DirectionsRenderer:Il,DefaultRouteAnimation:Mr,DefaultRouteStopIconProvider:Sr},qT=new Proxy(fn,pg),YT=Object.assign({},lu,{LocationsService:qT}),Xp=document.createElement("link");Xp.rel="stylesheet";Xp.href=document.currentScript.src.replace(/\.js(\.gz)?([?#]?(.*?))$/,".css$1");document.head.appendChild(Xp);return X_(KT);})();
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
