@needle-tools/engine 5.1.0-beta.1 → 5.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.needle.json +1 -1
- package/dist/{materialx-jkHmVPez.js → materialx-BCzyAHFr.js} +1 -1
- package/dist/{materialx-B47Bz-xs.umd.cjs → materialx-BdEC3ugB.umd.cjs} +1 -1
- package/dist/{materialx-B85WjP7E.min.js → materialx-DnlAB5wd.min.js} +1 -1
- package/dist/{needle-engine.bundle-CWiO9cA8.umd.cjs → needle-engine.bundle-BcPtAnC9.umd.cjs} +98 -98
- package/dist/{needle-engine.bundle-DxJaiP7e.min.js → needle-engine.bundle-D0UTRn3W.min.js} +112 -112
- package/dist/{needle-engine.bundle-CFo3xWPu.js → needle-engine.bundle-H5HXbUCS.js} +2604 -2607
- package/dist/needle-engine.d.ts +8 -8
- package/dist/needle-engine.js +87 -87
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{vendor-1UvpPPSB.umd.cjs → vendor-CsClD1Nd.umd.cjs} +1 -1
- package/dist/{vendor-BQ2Vuntm.min.js → vendor-DQu6PDTB.min.js} +19 -19
- package/dist/{vendor-BslSKZPo.js → vendor-J7NvM88N.js} +342 -342
- package/lib/engine/api.d.ts +1 -1
- package/lib/engine/api.js +1 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_init.js +2 -2
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +72 -72
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +3 -3
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js +9 -9
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +2 -2
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +1 -1
- package/lib/engine-components/NeedleMenu.js +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +9 -5
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.js +4 -0
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.js +3 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/license.js +4 -4
- package/plugins/vite/build-pipeline.js +33 -2
- package/plugins/vite/license.js +4 -4
- package/src/engine/api.ts +1 -1
- package/src/engine/engine_init.ts +2 -2
- package/src/engine/engine_license.ts +69 -69
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +10 -10
- package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine-components/NeedleMenu.ts +2 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +12 -5
- package/src/engine-components/particlesystem/ParticleSystem.ts +4 -0
- package/src/engine-components/webxr/WebXRImageTracking.ts +1 -0
|
@@ -1113,4 +1113,4 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
1113
1113
|
isIOS:`).concat(this.isIOS,`
|
|
1114
1114
|
isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
|
|
1115
1115
|
isBrowserSupported:`).concat(this.isBrowserSupported(),`
|
|
1116
|
-
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),la={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},sh=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=la,this.browser=Hn.getBrowser(),this.browserVersion=Hn.getVersion(),this.supports=(function(){var e={browser:Hn.isBrowserSupported(),webRTC:Hn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(la),e.audioVideo=!0;var n=void 0;try{n=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!n.ordered;try{n.binaryType="blob",e.binaryBlob=!Hn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=Ko.pack,this.unpack=Ko.unpack,this._dataCount=1}return r.prototype.noop=function(){},r.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},r.prototype.chunk=function(e){for(var t=[],n=e.size,i=Math.ceil(n/te.chunkedMTU),s=0,a=0;a<n;){var o=Math.min(n,a+te.chunkedMTU),c=e.slice(a,o),l={__peerData:this._dataCount,n:s,data:c,total:i};t.push(l),a=o,s++}return this._dataCount++,t},r.prototype.blobToArrayBuffer=function(e,t){var n=new FileReader;return n.onload=function(i){i.target&&t(i.target.result)},n.readAsArrayBuffer(e),n},r.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer},r.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},r.prototype.isSecure=function(){return location.protocol==="https:"},r})(),te=new sh,Bc={};Bt(Bc,"Peer",()=>Gs,r=>Gs=r);var Gi={},oh=Object.prototype.hasOwnProperty,nt="~";function Ji(){}Object.create&&(Ji.prototype=Object.create(null),new Ji().__proto__||(nt=!1));function ah(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Nc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new ah(t,n||r,i),a=nt?nt+e:e;return r._events[a]?r._events[a].fn?r._events[a]=[r._events[a],s]:r._events[a].push(s):(r._events[a]=s,r._eventsCount++),r}function Er(r,e){--r._eventsCount===0?r._events=new Ji:delete r._events[e]}function He(){this._events=new Ji,this._eventsCount=0}He.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)oh.call(t,n)&&e.push(nt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};He.prototype.listeners=function(e){var t=nt?nt+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a};He.prototype.listenerCount=function(e){var t=nt?nt+e:e,n=this._events[t];return n?n.fn?1:n.length:0};He.prototype.emit=function(e,t,n,i,s,a){var o=nt?nt+e:e;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,h,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,a),!0}for(d=1,h=new Array(l-1);d<l;d++)h[d-1]=arguments[d];c.fn.apply(c.context,h)}else{var m=c.length,p;for(d=0;d<m;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!h)for(p=1,h=new Array(l-1);p<l;p++)h[p-1]=arguments[p];c[d].fn.apply(c[d].context,h)}}return!0};He.prototype.on=function(e,t,n){return Nc(this,e,t,n,!1)};He.prototype.once=function(e,t,n){return Nc(this,e,t,n,!0)};He.prototype.removeListener=function(e,t,n,i){var s=nt?nt+e:e;if(!this._events[s])return this;if(!t)return Er(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&Er(this,s);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==t||i&&!a[o].once||n&&a[o].context!==n)&&c.push(a[o]);c.length?this._events[s]=c.length===1?c[0]:c:Er(this,s)}return this};He.prototype.removeAllListeners=function(e){var t;return e?(t=nt?nt+e:e,this._events[t]&&Er(this,t)):(this._events=new Ji,this._eventsCount=0),this};He.prototype.off=He.prototype.removeListener;He.prototype.addListener=He.prototype.on;He.prefixed=nt;He.EventEmitter=He;Gi=He;var j={};Bt(j,"LogLevel",()=>ot,r=>ot=r);Bt(j,"default",()=>ua,r=>ua=r);var cn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},ln=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},ch="PeerJS: ",ot;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(ot||(ot={}));var lh=(function(){function r(){this._logLevel=ot.Disabled}return Object.defineProperty(r.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),r.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.All&&this._print.apply(this,ln([ot.All],cn(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.Warnings&&this._print.apply(this,ln([ot.Warnings],cn(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.Errors&&this._print.apply(this,ln([ot.Errors],cn(e),!1))},r.prototype.setLogFunction=function(e){this._print=e},r.prototype._print=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=ln([ch],cn(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=ot.All?console.log.apply(console,ln([],cn(i),!1)):e>=ot.Warnings?console.warn.apply(console,ln(["WARNING"],cn(i),!1)):e>=ot.Errors&&console.error.apply(console,ln(["ERROR"],cn(i),!1))},r})(),ua=new lh,Uc={};Bt(Uc,"Socket",()=>ha,r=>ha=r);var Pt;(function(r){r.Data="data",r.Media="media"})(Pt||(Pt={}));var _e;(function(r){r.BrowserIncompatible="browser-incompatible",r.Disconnected="disconnected",r.InvalidID="invalid-id",r.InvalidKey="invalid-key",r.Network="network",r.PeerUnavailable="peer-unavailable",r.SslUnavailable="ssl-unavailable",r.ServerError="server-error",r.SocketError="socket-error",r.SocketClosed="socket-closed",r.UnavailableID="unavailable-id",r.WebRTC="webrtc"})(_e||(_e={}));var jt;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(jt||(jt={}));var $t;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})($t||($t={}));var Fe;(function(r){r.Heartbeat="HEARTBEAT",r.Candidate="CANDIDATE",r.Offer="OFFER",r.Answer="ANSWER",r.Open="OPEN",r.Error="ERROR",r.IdTaken="ID-TAKEN",r.InvalidKey="INVALID-KEY",r.Leave="LEAVE",r.Expire="EXPIRE"})(Fe||(Fe={}));var lo={};lo=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz Stückler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","Sören Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var uh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),hh=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},fh=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},dh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ha=(function(r){uh(e,r);function e(t,n,i,s,a,o){o===void 0&&(o=5e3);var c=r.call(this)||this;c.pingInterval=o,c._disconnected=!0,c._messagesQueue=[];var l=t?"wss://":"ws://";return c._baseUrl=l+n+":"+i+s+"peerjs?key="+a,c}return e.prototype.start=function(t,n){var i=this;this._id=t;var s="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(n);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+lo.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),j.default.log("Server message received:",o)}catch{j.default.log("Invalid server message",a.data);return}i.emit($t.Message,o)},this._socket.onclose=function(a){i._disconnected||(j.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit($t.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),j.default.log("Socket open"),i._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){j.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Fe.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,n,i=fh([],hh(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=dh(i),a=s.next();!a.done;a=s.next()){var o=a.value;this.send(o)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit($t.Error,"Invalid message");return}if(this._wsOpen()){var n=JSON.stringify(t);this._socket.send(n)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e})(Gi.EventEmitter),Js={};Bt(Js,"MediaConnection",()=>pa,r=>pa=r);var uo={};Bt(uo,"Negotiator",()=>fa,r=>fa=r);var Dr=function(){return Dr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},Dr.apply(this,arguments)},sr=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{l(n.next(h))}catch(d){a(d)}}function c(h){try{l(n.throw(h))}catch(d){a(d)}}function l(h){h.done?s(h.value):i(h.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},or=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(h){l=[6,h],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},fa=(function(){function r(e){this.connection=e}return r.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===Pt.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Pt.Data){var n=this.connection,i={ordered:!!e.reliable},s=t.createDataChannel(n.label,i);n.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},r.prototype._startPeerConnection=function(){j.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},r.prototype._setupListeners=function(e){var t=this,n=this.connection.peer,i=this.connection.connectionId,s=this.connection.type,a=this.connection.provider;j.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||(j.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Fe.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":j.default.log("iceConnectionState is failed, closing connections to "+n),t.connection.emit("error",new Error("Negotiation of connection to "+n+" failed.")),t.connection.close();break;case"closed":j.default.log("iceConnectionState is closed, closing connections to "+n),t.connection.emit("error",new Error("Connection to "+n+" closed.")),t.connection.close();break;case"disconnected":j.default.log("iceConnectionState changed to disconnected on the connection with "+n);break;case"completed":e.onicecandidate=te.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},j.default.log("Listening for data channel"),e.ondatachannel=function(o){j.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},j.default.log("Listening for remote stream"),e.ontrack=function(o){j.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Pt.Media){var h=l;t._addStreamToMediaConnection(c,h)}}},r.prototype.cleanup=function(){j.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",n=!1;if(this.connection.type===Pt.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return sr(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return or(this,function(c){switch(c.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:n=c.sent(),j.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return c.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),i={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:te.browser},this.connection.type===Pt.Data&&(s=this.connection,i=Dr(Dr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Fe.Offer,payload:i,dst:this.connection.peer}),[3,6];case 5:return a=c.sent(),a!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(_e.WebRTC,a),j.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(_e.WebRTC,o),j.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return sr(this,void 0,Promise,function(){var e,t,n,i,s;return or(this,function(a){switch(a.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:n=a.sent(),j.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return a.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Fe.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,browser:te.browser},dst:this.connection.peer}),[3,6];case 5:return i=a.sent(),t.emitError(_e.WebRTC,i),j.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(_e.WebRTC,s),j.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return sr(this,void 0,Promise,function(){var n,i,s,a;return or(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,j.default.log("Setting remote description",t),s=this,o.label=1;case 1:return o.trys.push([1,5,,6]),[4,n.setRemoteDescription(t)];case 2:return o.sent(),j.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:return a=o.sent(),i.emitError(_e.WebRTC,a),j.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return sr(this,void 0,Promise,function(){var t,n,i,s,a,o;return or(this,function(c){switch(c.label){case 0:j.default.log("handleCandidate:",e),t=e.candidate,n=e.sdpMLineIndex,i=e.sdpMid,s=this.connection.peerConnection,a=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:i,sdpMLineIndex:n,candidate:t}))];case 2:return c.sent(),j.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(_e.WebRTC,o),j.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if(j.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return j.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype._addStreamToMediaConnection=function(e,t){j.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r})(),ho={};Bt(ho,"BaseConnection",()=>da,r=>da=r);var ph=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),da=(function(r){ph(e,r);function e(t,n,i){var s=r.call(this)||this;return s.peer=t,s.provider=n,s.options=i,s._open=!1,s.metadata=i.metadata,s}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e})(Gi.EventEmitter),mh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Lr=function(){return Lr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},Lr.apply(this,arguments)},yh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},pa=(function(r){mh(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s._negotiator=new uo.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Pt.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){j.default.log("Receiving stream",t),this._remoteStream=t,r.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var n=t.type,i=t.payload;switch(t.type){case Fe.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Fe.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:j.default.warn("Unrecognized message type:".concat(n," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,n){var i,s;if(n===void 0&&(n={}),this._localStream){j.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,n&&n.sdpTransform&&(this.options.sdpTransform=n.sdpTransform),this._negotiator.startConnection(Lr(Lr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=yh(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(h){i={error:h}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e})(ho.BaseConnection),js={};Bt(js,"DataConnection",()=>ya,r=>ya=r);var Dc={};Bt(Dc,"EncodingQueue",()=>ma,r=>ma=r);var gh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),ma=(function(r){gh(e,r);function e(){var t=r.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(n){t._processing=!1,n.target&&t.emit("done",n.target.result),t.doNextTask()},t.fileReader.onerror=function(n){j.default.error("EncodingQueue error:",n),t._processing=!1,t.destroy(),t.emit("error",n)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e})(Gi.EventEmitter),vh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Sh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ya=(function(r){vh(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new Dc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||jt.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){j.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new uo.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Pt.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!te.supports.binaryBlob||te.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){j.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){j.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){j.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var n=this,i=t.data,s=i.constructor,a=this.serialization===jt.Binary||this.serialization===jt.BinaryUTF8,o=i;if(a){if(s===Blob){te.blobToArrayBuffer(i,function(l){var h=te.unpack(l);n.emit("data",h)});return}else if(s===ArrayBuffer)o=te.unpack(i);else if(s===String){var c=te.binaryStringToArrayBuffer(i);o=te.unpack(c)}}else this.serialization===jt.JSON&&(o=this.parse(i));if(o.__peerData){this._handleChunk(o);return}r.prototype.emit.call(this,"data",o)},e.prototype._handleChunk=function(t){var n=t.__peerData,i=this._chunkedData[n]||{data:[],count:0,total:t.total};if(i.data[t.n]=t.data,i.count++,this._chunkedData[n]=i,i.total===i.count){delete this._chunkedData[n];var s=new Blob(i.data);this._handleDataMessage({data:s})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.prototype.send=function(t,n){if(!this.open){r.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===jt.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===jt.Binary||this.serialization===jt.BinaryUTF8){var i=te.pack(t);if(!n&&i.size>te.chunkedMTU){this._sendChunks(i);return}te.supports.binaryBlob?this._bufferedSend(i):this._encodingQueue.enque(i)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var n=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){n._buffering=!1,n._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(i){return j.default.error("DC#:".concat(this.connectionId," Error when sending:"),i),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var n,i,s=te.chunk(t);j.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Sh(s),o=a.next();!o.done;o=a.next()){var c=o.value;this.send(c,!0)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.handleMessage=function(t){var n=t.payload;switch(t.type){case Fe.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Fe.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:j.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e})(ho.BaseConnection),Lc={};Bt(Lc,"API",()=>Sa,r=>Sa=r);var ga=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{l(n.next(h))}catch(d){a(d)}}function c(h){try{l(n.throw(h))}catch(d){a(d)}}function l(h){h.done?s(h.value):i(h.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},va=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(h){l=[6,h],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Sa=(function(){function r(e){this._options=e}return r.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",n=this._options,i=n.host,s=n.port,a=n.path,o=n.key,c=new URL("".concat(t,"://").concat(i,":").concat(s).concat(a).concat(o,"/").concat(e));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",lo.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return ga(this,void 0,Promise,function(){var e,t,n;return va(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=i.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=i.sent(),j.default.error("Error retrieving ID",t),n="",this._options.path==="/"&&this._options.host!==te.CLOUD_HOST&&(n=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+n);case 3:return[2]}})})},r.prototype.listAllPeers=function(){return ga(this,void 0,Promise,function(){var e,t,n;return va(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=i.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===te.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw n=i.sent(),j.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r})(),xh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),ai=function(){return ai=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},ai.apply(this,arguments)},qn=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},_h=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Gs=(function(r){xh(e,r);function e(t,n){var i=r.call(this)||this;i._id=null,i._lastServerId=null,i._destroyed=!1,i._disconnected=!1,i._open=!1,i._connections=new Map,i._lostMessages=new Map;var s;return t&&t.constructor==Object?n=t:t&&(s=t.toString()),n=ai({debug:0,host:te.CLOUD_HOST,port:te.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:te.randomToken(),config:te.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},n),i._options=n,i._options.host==="/"&&(i._options.host=window.location.hostname),i._options.path&&(i._options.path[0]!=="/"&&(i._options.path="/"+i._options.path),i._options.path[i._options.path.length-1]!=="/"&&(i._options.path+="/")),i._options.secure===void 0&&i._options.host!==te.CLOUD_HOST?i._options.secure=te.isSecure():i._options.host==te.CLOUD_HOST&&(i._options.secure=!0),i._options.logFunction&&j.default.setLogFunction(i._options.logFunction),j.default.logLevel=i._options.debug||0,i._api=new Lc.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(_e.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(_e.InvalidID,'ID "'.concat(s,'" is invalid')),i):(s?i._initialize(s):i._api.retrieveId().then(function(a){return i._initialize(a)}).catch(function(a){return i._abort(_e.ServerError,a)}),i)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,n,i=Object.create(null);try{for(var s=qn(this._connections),a=s.next();!a.done;a=s.next()){var o=_h(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(h){t={error:h}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,n=new Uc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on($t.Message,function(i){t._handleMessage(i)}),n.on($t.Error,function(i){t._abort(_e.SocketError,i)}),n.on($t.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on($t.Close,function(){t.disconnected||t._abort(_e.SocketClosed,"Underlying socket is already closed.")}),n},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var n,i,s=t.type,a=t.payload,o=t.src;switch(s){case Fe.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Fe.Error:this._abort(_e.ServerError,a.msg);break;case Fe.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Fe.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Fe.Leave:j.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Fe.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Fe.Offer:var b=a.connectionId,T=this.getConnection(o,b);if(T&&(T.close(),j.default.warn("Offer received for existing Connection ID:".concat(b))),a.type===Pt.Media){var c=new Js.MediaConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata});T=c,this._addConnection(o,T),this.emit("call",c)}else if(a.type===Pt.Data){var l=new js.DataConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});T=l,this._addConnection(o,T),this.emit("connection",l)}else{j.default.warn("Received malformed connection type:".concat(a.type));return}var h=this._getMessages(b);try{for(var d=qn(h),m=d.next();!m.done;m=d.next()){var p=m.value;T.handleMessage(p)}}catch(g){n={error:g}}finally{try{m&&!m.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}break;default:if(!a){j.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var b=a.connectionId,T=this.getConnection(o,b);T&&T.peerConnection?T.handleMessage(t):b?this._storeMessage(b,t):j.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,n){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(n)},e.prototype._getMessages=function(t){var n=this._lostMessages.get(t);return n?(this._lostMessages.delete(t),n):[]},e.prototype.connect=function(t,n){if(n===void 0&&(n={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new js.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){j.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Js.MediaConnection(t,this,ai(ai({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){j.default.log("add connection ".concat(n.type,":").concat(n.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(n)},e.prototype._removeConnection=function(t){var n=this._connections.get(t.peer);if(n){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,n){var i,s,a=this._connections.get(t);if(!a)return null;try{for(var o=qn(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(h){i={error:h}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}return null},e.prototype._delayedAbort=function(t,n){var i=this;setTimeout(function(){i._abort(t,n)},0)},e.prototype._abort=function(t,n){j.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){j.default.error("Error:",n);var i;typeof n=="string"?i=new Error(n):i=n,i.type=t,this.emit("error",i)},e.prototype.destroy=function(){this.destroyed||(j.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,n;try{for(var i=qn(this._connections.keys()),s=i.next();!s.done;s=i.next()){var a=s.value;this._cleanupPeer(a),this._connections.delete(a)}}catch(o){t={error:o}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var n,i,s=this._connections.get(t);if(s)try{for(var a=qn(s),o=a.next();!o.done;o=a.next()){var c=o.value;c.close()}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;j.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)j.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)j.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var n=this;t===void 0&&(t=function(i){}),this._api.listAllPeers().then(function(i){return t(i)}).catch(function(i){return n._abort(_e.ServerError,i)})},e.DEFAULT_KEY="peerjs",e})(Gi.EventEmitter),bh=Bc.Peer;const Th=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Gs},default:bh,util:te},Symbol.toStringTag,{value:"Module"}));class Mh{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class Fc{constructor(e,t,n){var i,s,a,o,c,l,h,d,m,p,b,T,g,v,x;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(ce.open,_),this.handleErrorEvent=_=>this.handleEvent(ce.error,_),this.handleCloseEvent=_=>this.handleEvent(ce.close,_),this.handleMessageEvent=_=>this.handleEvent(ce.message,_),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(m=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&m!==void 0?m:[]],message:[...(b=(p=n?.listeners)===null||p===void 0?void 0:p.message)!==null&&b!==void 0?b:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(x=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&x!==void 0?x:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(ce.retry,{detail:n});this.handleEvent(ce.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class Ch{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new Fc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,h,d,m,p,b,T,g,v,x,_,M,C,P,E,z;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(m=(d=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||d===void 0?void 0:d.error)!==null&&m!==void 0?m:[],message:(T=(b=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||b===void 0?void 0:b.message)!==null&&T!==void 0?T:[],retry:(x=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&x!==void 0?x:[],reconnect:(C=(M=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||M===void 0?void 0:M.reconnect)!==null&&C!==void 0?C:[],[e]:[...(z=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&z!==void 0?z:[],{listener:t,options:n}]}}),this}}const wh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Mh,Websocket:Fc,WebsocketBuilder:Ch,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),fo=0,Vc=1,Jc=2,Ws=2,_s=1.25,xa=1,We=32,Pe=We/4,jc=65535,kr=Math.pow(2,-24),Gr=Symbol("SKIP_GENERATION"),Gc={strategy:fo,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Gr]:!1};function Se(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function _a(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function ba(r,e){e.set(r)}function Ta(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function ar(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Xn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function Ee(r,e){return e[r+15]===jc}function $e(r,e){return e[r+6]}function tt(r,e){return e[r+14]}function Ie(r){return r+Pe}function Be(r,e){const t=e[r+6];return r+t*Pe}function po(r,e){return e[r+7]}function bs(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0,d=1/0,m=1/0,p=1/0,b=-1/0,T=-1/0,g=-1/0;const v=r.offset||0;for(let x=(e-v)*6,_=(e+t-v)*6;x<_;x+=6){const M=r[x+0],C=r[x+1],P=M-C,E=M+C;P<s&&(s=P),E>c&&(c=E),M<d&&(d=M),M>b&&(b=M);const z=r[x+2],I=r[x+3],R=z-I,N=z+I;R<a&&(a=R),N>l&&(l=N),z<m&&(m=z),z>T&&(T=z);const O=r[x+4],U=r[x+5],F=O-U,J=O+U;F<o&&(o=F),J>h&&(h=J),O<p&&(p=O),O>g&&(g=O)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,i[0]=d,i[1]=m,i[2]=p,i[3]=b,i[4]=T,i[5]=g}const Jt=32,Ph=(r,e)=>r.candidate-e.candidate,Kt=new Array(Jt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),cr=new Float32Array(6);function Eh(r,e,t,n,i,s){let a=-1,o=0;if(s===fo)a=_a(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Vc)a=_a(r),a!==-1&&(o=kh(t,n,i,a));else if(s===Jc){const c=Xn(r);let l=_s*i;const h=t.offset||0,d=(n-h)*6,m=(n+i-h)*6;for(let p=0;p<3;p++){const b=e[p],v=(e[p+3]-b)/Jt;if(i<Jt/4){const x=[...Kt];x.length=i;let _=0;for(let C=d;C<m;C+=6,_++){const P=x[_];P.candidate=t[C+2*p],P.count=0;const{bounds:E,leftCacheBounds:z,rightCacheBounds:I}=P;for(let R=0;R<3;R++)I[R]=1/0,I[R+3]=-1/0,z[R]=1/0,z[R+3]=-1/0,E[R]=1/0,E[R+3]=-1/0;ar(C,t,E)}x.sort(Ph);let M=i;for(let C=0;C<M;C++){const P=x[C];for(;C+1<M&&x[C+1].candidate===P.candidate;)x.splice(C+1,1),M--}for(let C=d;C<m;C+=6){const P=t[C+2*p];for(let E=0;E<M;E++){const z=x[E];P>=z.candidate?ar(C,t,z.rightCacheBounds):(ar(C,t,z.leftCacheBounds),z.count++)}}for(let C=0;C<M;C++){const P=x[C],E=P.count,z=i-P.count,I=P.leftCacheBounds,R=P.rightCacheBounds;let N=0;E!==0&&(N=Xn(I)/c);let O=0;z!==0&&(O=Xn(R)/c);const U=xa+_s*(N*E+O*z);U<l&&(a=p,l=U,o=P.candidate)}}else{for(let M=0;M<Jt;M++){const C=Kt[M];C.count=0,C.candidate=b+v+M*v;const P=C.bounds;for(let E=0;E<3;E++)P[E]=1/0,P[E+3]=-1/0}for(let M=d;M<m;M+=6){let E=~~((t[M+2*p]-b)/v);E>=Jt&&(E=Jt-1);const z=Kt[E];z.count++,ar(M,t,z.bounds)}const x=Kt[Jt-1];ba(x.bounds,x.rightCacheBounds);for(let M=Jt-2;M>=0;M--){const C=Kt[M],P=Kt[M+1];Ta(C.bounds,P.rightCacheBounds,C.rightCacheBounds)}let _=0;for(let M=0;M<Jt-1;M++){const C=Kt[M],P=C.count,E=C.bounds,I=Kt[M+1].rightCacheBounds;P!==0&&(_===0?ba(E,cr):Ta(E,cr,cr)),_+=P;let R=0,N=0;_!==0&&(R=Xn(cr)/c);const O=i-_;O!==0&&(N=Xn(I)/c);const U=xa+_s*(R*_+N*O);U<l&&(a=p,l=U,o=C.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function kh(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class Ts{constructor(){this.boundingData=new Float32Array(6)}}function Rh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,h=t.offset||0;for(;;){for(;a<=o&&t[(a-h)*6+l]<c;)a++;for(;a<=o&&t[(o-h)*6+l]>=c;)o--;if(a<o){for(let d=0;d<e;d++){let m=r[a*e+d];r[a*e+d]=r[o*e+d],r[o*e+d]=m}for(let d=0;d<6;d++){const m=a-h,p=o-h,b=t[m*6+d];t[m*6+d]=t[p*6+d],t[p*6+d]=b}a++,o--}else return a}}let Wc,Rr,$s,$c;const Ah=Math.pow(2,32);function Hs(r){return"count"in r?1:1+Hs(r.left)+Hs(r.right)}function Oh(r,e,t){return Wc=new Float32Array(t),Rr=new Uint32Array(t),$s=new Uint16Array(t),$c=new Uint8Array(t),qs(r,e)}function qs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)Wc[t+a]=s[a];if(i)return e.buffer?($c.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Rr[t+6]=e.offset,$s[n+14]=e.count,$s[n+15]=jc,r+We);{const{left:a,right:o,splitAxis:c}=e,l=r+We;let h=qs(l,a);const d=r/We,p=h/We-d;if(p>Ah)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Rr[t+6]=p,Rr[t+7]=c,qs(h,o)}}function zh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,h=r.primitiveBuffer,d=r.primitiveBufferStride,m=new Float32Array(6);let p=!1;const b=new Ts;return bs(e,t,n,b.boundingData,m),g(b,t,n,m),b;function T(v){l&&l(v/n)}function g(v,x,_,M=null,C=0){if(!p&&C>=s&&(p=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),_<=o||C>=s)return T(x+_),v.offset=x,v.count=_,v;const P=Eh(v.boundingData,M,e,x,_,c);if(P.axis===-1)return T(x+_),v.offset=x,v.count=_,v;const E=Rh(h,d,e,x,_,P);if(E===x||E===x+_)T(x+_),v.offset=x,v.count=_;else{v.splitAxis=P.axis;const z=new Ts,I=x,R=E-x;v.left=z,bs(e,I,R,z.boundingData,m),g(z,I,R,m,C+1);const N=new Ts,O=E,U=_-R;v.right=N,bs(e,O,U,N.boundingData,m),g(N,O,U,m,C+1)}return v}}function Ih(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=zh(r,o,c.offset,c.count,e),h=Hs(l),d=new t(We*h);return Oh(0,l,d),d})}class mo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Bh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const pe=new Bh;let rn,Un;const Pn=[],lr=new mo(()=>new A.Box3);function Nh(r,e,t,n,i,s){rn=lr.getPrimitive(),Un=lr.getPrimitive(),Pn.push(rn,Un),pe.setBuffer(r._roots[e]);const a=Xs(0,r.geometry,t,n,i,s);pe.clearBuffer(),lr.releasePrimitive(rn),lr.releasePrimitive(Un),Pn.pop(),Pn.pop();const o=Pn.length;return o>0&&(Un=Pn[o-1],rn=Pn[o-2]),a}function Xs(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=pe;let h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);return Se(r,o,rn),n(m,p,!1,a,s+r/Pe,rn)}else{let R=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Ie(O),J=O*2;return $e(O,F)},N=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Be(O,F),J=O*2;return $e(O,F)+tt(J,U)};const m=Ie(r),p=Be(r,l);let b=m,T=p,g,v,x,_;if(i&&(x=rn,_=Un,Se(b,o,x),Se(T,o,_),g=i(x),v=i(_),v<g)){b=p,T=m;const O=g;g=v,v=O,x=_}x||(x=rn,Se(b,o,x));const M=Ee(b*2,c),C=t(x,M,g,a+1,s+b/Pe);let P;if(C===Ws){const O=R(b),F=N(b)-O;P=n(O,F,!0,a+1,s+b/Pe,x)}else P=C&&Xs(b,e,t,n,i,s,a+1);if(P)return!0;_=Un,Se(T,o,_);const E=Ee(T*2,c),z=t(_,E,v,a+1,s+T/Pe);let I;if(z===Ws){const O=R(T),F=N(T)-O;I=n(O,F,!0,a+1,s+T/Pe,_)}else I=z&&Xs(T,e,t,n,i,s,a+1);return!!I}}const ci=new pe.constructor,Fr=new pe.constructor,tn=new mo(()=>new A.Box3),En=new A.Box3,kn=new A.Box3,Ms=new A.Box3,Cs=new A.Box3;let ws=!1;function Uh(r,e,t,n){if(ws)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ws=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new A.Matrix4().copy(t).invert();for(let h=0,d=i.length;h<d;h++){ci.setBuffer(i[h]),c=0;const m=tn.getPrimitive();Se(0,ci.float32Array,m),m.applyMatrix4(l);for(let p=0,b=s.length;p<b&&(Fr.setBuffer(s[p]),a=wt(0,0,t,l,n,o,c,0,0,m),Fr.clearBuffer(),c+=s[p].byteLength/We,!a);p++);if(tn.releasePrimitive(m),ci.clearBuffer(),o+=i[h].byteLength/We,a)break}return ws=!1,a}function wt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,h=!1){let d,m;h?(d=Fr,m=ci):(d=ci,m=Fr);const p=d.float32Array,b=d.uint32Array,T=d.uint16Array,g=m.float32Array,v=m.uint32Array,x=m.uint16Array,_=r*2,M=e*2,C=Ee(_,T),P=Ee(M,x);let E=!1;if(P&&C)h?E=i($e(e,v),tt(e*2,x),$e(r,b),tt(r*2,T),c,a+e/Pe,o,s+r/Pe):E=i($e(r,b),tt(r*2,T),$e(e,v),tt(e*2,x),o,s+r/Pe,c,a+e/Pe);else if(P){const z=tn.getPrimitive();Se(e,g,z),z.applyMatrix4(t);const I=Ie(r),R=Be(r,b);Se(I,p,En),Se(R,p,kn);const N=z.intersectsBox(En),O=z.intersectsBox(kn);E=N&&wt(e,I,n,t,i,a,s,c,o+1,z,!h)||O&&wt(e,R,n,t,i,a,s,c,o+1,z,!h),tn.releasePrimitive(z)}else{const z=Ie(e),I=Be(e,v);Se(z,g,Ms),Se(I,g,Cs);const R=l.intersectsBox(Ms),N=l.intersectsBox(Cs);if(R&&N)E=wt(r,z,t,n,i,s,a,o,c+1,l,h)||wt(r,I,t,n,i,s,a,o,c+1,l,h);else if(R)if(C)E=wt(r,z,t,n,i,s,a,o,c+1,l,h);else{const O=tn.getPrimitive();O.copy(Ms).applyMatrix4(t);const U=Ie(r),F=Be(r,b);Se(U,p,En),Se(F,p,kn);const J=O.intersectsBox(En),$=O.intersectsBox(kn);E=J&&wt(z,U,n,t,i,a,s,c,o+1,O,!h)||$&&wt(z,F,n,t,i,a,s,c,o+1,O,!h),tn.releasePrimitive(O)}else if(N)if(C)E=wt(r,I,t,n,i,s,a,o,c+1,l,h);else{const O=tn.getPrimitive();O.copy(Cs).applyMatrix4(t);const U=Ie(r),F=Be(r,b);Se(U,p,En),Se(F,p,kn);const J=O.intersectsBox(En),$=O.intersectsBox(kn);E=J&&wt(I,U,n,t,i,a,s,c,o+1,O,!h)||$&&wt(I,F,n,t,i,a,s,c,o+1,O,!h),tn.releasePrimitive(O)}}return E}const Ma=new A.Box3,Rn=new Float32Array(6);class Hc{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Gc,...e},Ih(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0;for(let d=e,m=e+t;d<m;d++){this.writePrimitiveBounds(d,Rn,0);const[p,b,T,g,v,x]=Rn;p<s&&(s=p),g>c&&(c=g),b<a&&(a=b),v>l&&(l=v),T<o&&(o=T),x>h&&(h=x)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=h,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,Rn,0);const[o,c,l,h,d,m]=Rn,p=(o+h)/2,b=(c+d)/2,T=(l+m)/2,g=(h-o)/2,v=(d-c)/2,x=(m-l)/2,_=(s-i)*6;n[_+0]=p,n[_+1]=g+(Math.abs(p)+g)*kr,n[_+2]=b,n[_+3]=v+(Math.abs(b)+v)*kr,n[_+4]=T,n[_+5]=x+(Math.abs(T)+x)*kr}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/We;for(let l=0;l<c;l++){const h=Pe*l,d=2*h;Ee(d,o)&&(a[h+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,h=Ee(l,s);if(h){const d=i[o+6],m=s[l+14];e(c,h,new Float32Array(n,o*4,6),d,m)}else{const d=Ie(o),m=Be(o,i),p=po(o,i);e(c,h,new Float32Array(n,o*4,6),p)||(a(d,c+1),a(m,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/We;for(let l=c-1;l>=0;l--){const h=l*Pe,d=h*2;if(Ee(d,a)){const p=$e(h,s),b=tt(d,a);this.writePrimitiveRangeBounds(p,b,Rn,0),o.set(Rn,h)}else{const p=Ie(h),b=Be(h,s);for(let T=0;T<3;T++){const g=o[p+T],v=o[p+T+3],x=o[b+T],_=o[b+T+3];o[h+T]=g<x?g:x,o[h+T+3]=v>_?v:_}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),Ma),e.union(Ma)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const d=i;i=(m,p,b,T,g)=>d(m,p,b,T,g)?!0:o(m,p,this,s,b,T,a)}else i||(s?i=(d,m,p,b)=>o(d,m,this,s,p,b,a):i=(d,m,p)=>p);let c=!1,l=0;const h=this._roots;for(let d=0,m=h.length;d<m;d++){const p=h[d];if(c=Nh(this,d,n,i,t,l),c)break;l+=p.byteLength/We}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Uh(this,e,t,i)}}function Dh(){return typeof SharedArrayBuffer<"u"}function yo(r){return r.index?r.index.count:r.attributes.position.count}function Wr(r){return yo(r)/3}function Lh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Fh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Lh(t,n);r.setIndex(new A.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Vh(r,e,t){const n=yo(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function Jh(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Ca(r,e,t){const n=Vh(r,e,t),i=Jh(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=yo(r)/t,l=[];for(const m of i){const{offset:p,count:b}=m,T=p,g=isFinite(b)?b:c-p,v=p+g;T<o&&v>a&&(l.push({pos:Math.max(a,T),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((m,p)=>m.pos!==p.pos?m.pos-p.pos:m.type==="end"?-1:1);let h=0,d=null;for(const m of l){const p=m.pos;h!==0&&p!==d&&s.push({offset:d,count:p-d}),h+=m.isStart?1:-1,d=p}return s}function qc(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,h)=>l+h.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:h,count:d}=r[l];for(let m=0;m<d;m++)o[c+m]=h+m;c+=d}return o}class Xc extends Hc{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Dh())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Gc,...t},t[Gr]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Ca(t,e.range,n),s=qc(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else Fh(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new A.Box3))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Ca(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class qt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const c=e[s][t];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}qt.prototype.setFromBox=(function(){const r=new A.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*h+s.z*(1-h);const d=t.dot(r);a=Math.min(d,a),o=Math.max(d,o)}this.min=a,this.max=o}})();const jh=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,h=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const d=t.dot(h),m=h.dot(c),p=h.dot(h),b=t.dot(c),g=c.dot(c)*p-m*m;let v,x;g!==0?v=(d*m-b*p)/g:v=0,x=(d+v*m)/p,a.x=v,a.y=x}})(),go=(function(){const r=new A.Vector2,e=new A.Vector3,t=new A.Vector3;return function(i,s,a,o){jh(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let h;c<0?h=i.start:h=i.end;let d;l<0?d=s.start:d=s.end;const m=e,p=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(h,!0,t),m.distanceToSquared(d)<=p.distanceToSquared(h)){a.copy(m),o.copy(d);return}else{a.copy(h),o.copy(p);return}}}})(),Gh=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Plane,n=new A.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:h,c:d}=a;if(n.start=l,n.end=h,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=d,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=h,n.end=d,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),Wh=["x","y","z"],Gt=1e-15,wa=Gt*Gt;function pt(r){return Math.abs(r)<Gt}class gt extends A.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A.Vector3),this.satBounds=new Array(4).fill().map(()=>new qt),this.points=[this.a,this.b,this.c],this.plane=new A.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new A.Line3,this.needsUpdate=!0}intersectsSphere(e){return Gh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);const d=s[2],m=a[2];d.subVectors(t,n),m.setFromPoints(d,i);const p=s[3],b=a[3];p.subVectors(n,e),b.setFromPoints(p,i);const T=l.length(),g=d.length(),v=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,T<Gt?g<Gt||v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<Gt?v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<Gt&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}gt.prototype.closestPointToSegment=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let h,d=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(l[m]),t.end.copy(l[p]),go(t,i,r,e),h=r.distanceToSquared(e),h<d&&(d=h,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),h=o.distanceToSquared(r),h<d&&(d=h,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),h=c.distanceToSquared(r),h<d&&(d=h,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(d)}})();gt.prototype.intersectsTriangle=(function(){const r=new gt,e=new qt,t=new qt,n=new A.Vector3,i=new A.Vector3,s=new A.Vector3,a=new A.Vector3,o=new A.Line3,c=new A.Line3,l=new A.Vector3,h=new A.Vector2,d=new A.Vector2;function m(_,M,C,P){const E=n;!_.isDegenerateIntoPoint&&!_.isDegenerateIntoSegment?E.copy(_.plane.normal):E.copy(M.plane.normal);const z=_.satBounds,I=_.satAxes;for(let O=1;O<4;O++){const U=z[O],F=I[O];if(e.setFromPoints(F,M.points),U.isSeparated(e)||(a.copy(E).cross(F),e.setFromPoints(a,_.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}const R=M.satBounds,N=M.satAxes;for(let O=1;O<4;O++){const U=R[O],F=N[O];if(e.setFromPoints(F,_.points),U.isSeparated(e)||(a.crossVectors(E,F),e.setFromPoints(a,_.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}return C&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),C.start.set(0,0,0),C.end.set(0,0,0)),!0}function p(_,M,C,P,E,z,I,R,N,O,U){let F=I/(I-R);O.x=P+(E-P)*F,U.start.subVectors(M,_).multiplyScalar(F).add(_),F=I/(I-N),O.y=P+(z-P)*F,U.end.subVectors(C,_).multiplyScalar(F).add(_)}function b(_,M,C,P,E,z,I,R,N,O,U){if(E>0)p(_.c,_.a,_.b,P,M,C,N,I,R,O,U);else if(z>0)p(_.b,_.a,_.c,C,M,P,R,I,N,O,U);else if(R*N>0||I!=0)p(_.a,_.b,_.c,M,C,P,I,R,N,O,U);else if(R!=0)p(_.b,_.a,_.c,C,M,P,R,I,N,O,U);else if(N!=0)p(_.c,_.a,_.b,P,M,C,N,I,R,O,U);else return!0;return!1}function T(_,M,C,P){const E=M.degenerateSegment,z=_.plane.distanceToPoint(E.start),I=_.plane.distanceToPoint(E.end);return pt(z)?pt(I)?m(_,M,C,P):(C&&(C.start.copy(E.start),C.end.copy(E.start)),_.containsPoint(E.start)):pt(I)?(C&&(C.start.copy(E.end),C.end.copy(E.end)),_.containsPoint(E.end)):_.plane.intersectLine(E,n)!=null?(C&&(C.start.copy(n),C.end.copy(n)),_.containsPoint(n)):!1}function g(_,M,C){const P=M.a;return pt(_.plane.distanceToPoint(P))&&_.containsPoint(P)?(C&&(C.start.copy(P),C.end.copy(P)),!0):!1}function v(_,M,C){const P=_.degenerateSegment,E=M.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<wa?(C&&(C.start.copy(E),C.end.copy(E)),!0):!1}function x(_,M,C,P){if(_.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const E=_.degenerateSegment,z=M.degenerateSegment,I=i,R=s;E.delta(I),z.delta(R);const N=n.subVectors(z.start,E.start),O=I.x*R.y-I.y*R.x;if(pt(O))return!1;const U=(N.x*R.y-N.y*R.x)/O,F=-(I.x*N.y-I.y*N.x)/O;if(U<0||U>1||F<0||F>1)return!1;const J=E.start.z+I.z*U,$=z.start.z+R.z*F;return pt(J-$)?(C&&(C.start.copy(E.start).addScaledVector(I,U),C.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return M.isDegenerateIntoPoint?v(_,M,C):T(M,_,C,P);else{if(_.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(_.a)<wa?(C&&(C.start.copy(_.a),C.end.copy(_.a)),!0):!1:M.isDegenerateIntoSegment?v(M,_,C):g(M,_,C);if(M.isDegenerateIntoPoint)return g(_,M,C);if(M.isDegenerateIntoSegment)return T(_,M,C,P)}}return function(M,C=null,P=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(r.copy(M),r.update(),M=r);const E=x(this,M,C,P);if(E!==void 0)return E;const z=this.plane,I=M.plane;let R=I.distanceToPoint(this.a),N=I.distanceToPoint(this.b),O=I.distanceToPoint(this.c);pt(R)&&(R=0),pt(N)&&(N=0),pt(O)&&(O=0);const U=R*N,F=R*O;if(U>0&&F>0)return!1;let J=z.distanceToPoint(M.a),$=z.distanceToPoint(M.b),K=z.distanceToPoint(M.c);pt(J)&&(J=0),pt($)&&($=0),pt(K)&&(K=0);const W=J*$,me=J*K;if(W>0&&me>0)return!1;i.copy(z.normal),s.copy(I.normal);const ne=i.cross(s);let ue=0,re=Math.abs(ne.x);const ge=Math.abs(ne.y);ge>re&&(re=ge,ue=1),Math.abs(ne.z)>re&&(ue=2);const se=Wh[ue],he=this.a[se],oe=this.b[se],Xe=this.c[se],Ve=M.a[se],Je=M.b[se],Ye=M.c[se];if(b(this,he,oe,Xe,U,F,R,N,O,h,o))return m(this,M,C,P);if(b(M,Ve,Je,Ye,W,me,J,$,K,d,c))return m(this,M,C,P);if(h.y<h.x){const xe=h.y;h.y=h.x,h.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(d.y<d.x){const xe=d.y;d.y=d.x,d.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return h.y<d.x||d.y<h.x?!1:(C&&(d.x>h.x?C.start.copy(c.start):C.start.copy(o.start),d.y<h.y?C.end.copy(c.end):C.end.copy(o.end)),!0)}})();gt.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();gt.prototype.distanceToTriangle=(function(){const r=new A.Vector3,e=new A.Vector3,t=["a","b","c"],n=new A.Line3,i=new A.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let h=1/0;for(let d=0;d<3;d++){let m;const p=t[d],b=a[p];this.closestPointToPoint(b,r),m=b.distanceToSquared(r),m<h&&(h=m,o&&o.copy(r),c&&c.copy(b));const T=this[p];a.closestPointToPoint(T,r),m=T.distanceToSquared(r),m<h&&(h=m,o&&o.copy(T),c&&c.copy(r))}for(let d=0;d<3;d++){const m=t[d],p=t[(d+1)%3];n.set(this[m],this[p]);for(let b=0;b<3;b++){const T=t[b],g=t[(b+1)%3];i.set(a[T],a[g]),go(n,i,r,e);const v=r.distanceToSquared(e);v<h&&(h=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(h)}})();class qe{constructor(e,t,n){this.isOrientedBox=!0,this.min=new A.Vector3,this.max=new A.Vector3,this.matrix=new A.Matrix4,this.invMatrix=new A.Matrix4,this.points=new Array(8).fill().map(()=>new A.Vector3),this.satAxes=new Array(3).fill().map(()=>new A.Vector3),this.satBounds=new Array(3).fill().map(()=>new qt),this.alignedSatBounds=new Array(3).fill().map(()=>new qt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}qe.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const m=1*l|2*h|4*d,p=i[m];p.x=l?n.x:t.x,p.y=h?n.y:t.y,p.z=d?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const h=a[l],d=s[l],m=1<<l,p=i[m];h.subVectors(o,p),d.setFromPoints(h,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();qe.prototype.intersectsBox=(function(){const r=new qt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],h=s[c];if(r.setFromBox(l,t),h.isSeparated(r))return!1}return!0}})();qe.prototype.intersectsTriangle=(function(){const r=new gt,e=new Array(3),t=new qt,n=new qt,i=new A.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let m=0;m<3;m++){const p=o[m],b=c[m];if(t.setFromPoints(b,e),p.isSeparated(t))return!1}const l=a.satBounds,h=a.satAxes,d=this.points;for(let m=0;m<3;m++){const p=l[m],b=h[m];if(t.setFromPoints(b,d),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=c[m];for(let b=0;b<4;b++){const T=h[b];if(i.crossVectors(p,T),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}})();qe.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();qe.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();qe.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new A.Line3),t=new Array(12).fill().map(()=>new A.Line3),n=new A.Vector3,i=new A.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const h=o*o,d=a.min,m=a.max,p=this.points;let b=1/0;for(let g=0;g<8;g++){const v=p[g];i.copy(v).clamp(d,m);const x=v.distanceToSquared(i);if(x<b&&(b=x,c&&c.copy(v),l&&l.copy(i),x<h))return Math.sqrt(x)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let x=0;x<=1;x++){const _=(g+1)%3,M=(g+2)%3,C=v<<_|x<<M,P=1<<g|v<<_|x<<M,E=p[C],z=p[P];e[T].set(E,z);const R=r[g],N=r[_],O=r[M],U=t[T],F=U.start,J=U.end;F[R]=d[R],F[N]=v?d[N]:m[N],F[O]=x?d[O]:m[N],J[R]=m[R],J[N]=v?d[N]:m[N],J[O]=x?d[O]:m[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let x=0;x<=1;x++){i.x=g?m.x:d.x,i.y=v?m.y:d.y,i.z=x?m.z:d.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<b&&(b=_,c&&c.copy(n),l&&l.copy(i),_<h))return Math.sqrt(_)}for(let g=0;g<12;g++){const v=e[g];for(let x=0;x<12;x++){const _=t[x];go(v,_,n,i);const M=n.distanceToSquared(i);if(M<b&&(b=M,c&&c.copy(n),l&&l.copy(i),M<h))return Math.sqrt(M)}}return Math.sqrt(b)}})();class $h extends mo{constructor(){super(()=>new gt)}}const yt=new $h,Yn=new A.Vector3,Ps=new A.Vector3;function Hh(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:h=>(Yn.copy(e).clamp(h.min,h.max),Yn.distanceToSquared(e)),intersectsBounds:(h,d,m)=>m<o&&m<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Yn);const m=e.distanceToSquared(Yn);return m<o&&(Ps.copy(Yn),o=m,c=d),m<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Ps):t.point=Ps.clone(),t.distance=l,t.faceIndex=c,t}const ur=parseInt(A.REVISION)>=169,qh=parseInt(A.REVISION)<=161,un=new A.Vector3,hn=new A.Vector3,fn=new A.Vector3,hr=new A.Vector2,fr=new A.Vector2,dr=new A.Vector2,Pa=new A.Vector3,Ea=new A.Vector3,ka=new A.Vector3,Zn=new A.Vector3;function Xh(r,e,t,n,i,s,a,o){let c;if(s===A.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==A.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function Ra(r,e,t,n,i,s,a,o,c,l,h){un.fromBufferAttribute(e,s),hn.fromBufferAttribute(e,a),fn.fromBufferAttribute(e,o);const d=Xh(r,un,hn,fn,Zn,c,l,h);if(d){if(n){hr.fromBufferAttribute(n,s),fr.fromBufferAttribute(n,a),dr.fromBufferAttribute(n,o),d.uv=new A.Vector2;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,hr,fr,dr,d.uv);ur||(d.uv=p)}if(i){hr.fromBufferAttribute(i,s),fr.fromBufferAttribute(i,a),dr.fromBufferAttribute(i,o),d.uv1=new A.Vector2;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,hr,fr,dr,d.uv1);ur||(d.uv1=p),qh&&(d.uv2=d.uv1)}if(t){Pa.fromBufferAttribute(t,s),Ea.fromBufferAttribute(t,a),ka.fromBufferAttribute(t,o),d.normal=new A.Vector3;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,Pa,Ea,ka,d.normal);d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1),ur||(d.normal=p)}const m={a:s,b:a,c:o,normal:new A.Vector3,materialIndex:0};if(A.Triangle.getNormal(un,hn,fn,m.normal),d.face=m,d.faceIndex=s,ur){const p=new A.Vector3;A.Triangle.getBarycoord(Zn,un,hn,fn,p),d.barycoord=p}}return d}function Aa(r){return r&&r.isMaterial?r.side:r}function $r(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,h=o+2;const{index:d,groups:m}=r;r.index&&(c=d.getX(c),l=d.getX(l),h=d.getX(h));const{position:p,normal:b,uv:T,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let x=0,_=m.length;x<_;x++){const{start:M,count:C,materialIndex:P}=m[x];if(v>=M&&v<M+C){const E=Aa(e[P]),z=Ra(t,p,b,T,g,c,l,h,E,s,a);if(z)if(z.faceIndex=n,z.face.materialIndex=P,i)i.push(z);else return z}}}else{const v=Aa(e),x=Ra(t,p,b,T,g,c,l,h,v,s,a);if(x)if(x.faceIndex=n,x.face.materialIndex=0,i)i.push(x);else return x}return null}function we(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Yh(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let h=n,d=n+i;h<d;h++)$r(c,e,t,h,s,a,o)}function Zh(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=$r(o,e,t,d,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function Kh(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=r,d=e+r;h<d;h++){let m;if(m=h,we(a,m*3,c,l),a.needsUpdate=!0,n(a,m,i,s))return!0}return!1}function Qh(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(m,p,b=!1){const T=m*2;if(Ee(T,o)){const g=$e(m,a),v=tt(T,o);let x=1/0,_=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=3*g,I=3*(g+v);z<I;z++){let R=n[z];const N=i.getX(R),O=i.getY(R),U=i.getZ(R);N<x&&(x=N),N>C&&(C=N),O<_&&(_=O),O>P&&(P=O),U<M&&(M=U),U>E&&(E=U)}return c[m+0]!==x||c[m+1]!==_||c[m+2]!==M||c[m+3]!==C||c[m+4]!==P||c[m+5]!==E?(c[m+0]=x,c[m+1]=_,c[m+2]=M,c[m+3]=C,c[m+4]=P,c[m+5]=E,!0):!1}else{const g=Ie(m),v=Be(m,a);let x=b,_=!1,M=!1;if(e){if(!x){const R=g/Pe+p/We,N=v/Pe+p/We;_=e.has(R),M=e.has(N),x=!_&&!M}}else _=!0,M=!0;const C=x||_,P=x||M;let E=!1;C&&(E=d(g,p,x));let z=!1;P&&(z=d(v,p,x));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],$=c[O+3];c[m+R]=U<J?U:J,c[m+R+3]=F>$?F:$}return I}}}function sn(r,e,t,n,i){let s,a,o,c,l,h;const d=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,b=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],x=e[r+3],_=e[r+1],M=e[r+3+1],C=e[r+2],P=e[r+3+2];return d>=0?(s=(v-b)*d,a=(x-b)*d):(s=(x-b)*d,a=(v-b)*d),m>=0?(o=(_-T)*m,c=(M-T)*m):(o=(M-T)*m,c=(_-T)*m),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),p>=0?(l=(C-g)*p,h=(P-g)*p):(l=(P-g)*p,h=(C-g)*p),s>h||l>a)?!1:((l>s||s!==s)&&(s=l),(h<a||a!==a)&&(a=h),s<=i&&a>=n)}function ef(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let h=n,d=n+i;h<d;h++){let m=l?l[h]:h;$r(c,e,t,m,s,a,o)}}function tf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=$r(o,e,t,c?c[d]:d,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function nf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=r,d=e+r;h<d;h++){let m;if(m=t.resolveTriangleIndex(h),we(a,m*3,c,l),a.needsUpdate=!0,n(a,m,i,s))return!0}return!1}function rf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),Ys(0,r,t,n,i,s,a),pe.clearBuffer()}function Ys(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);Yh(e,t,n,m,p,i,s,a)}else{const m=Ie(r);sn(m,o,n,s,a)&&Ys(m,e,t,n,i,s,a);const p=Be(r,l);sn(p,o,n,s,a)&&Ys(p,e,t,n,i,s,a)}}const sf=["x","y","z"];function of(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=Zs(0,r,t,n,i,s);return pe.clearBuffer(),a}function Zs(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const d=$e(r,c),m=tt(l,o);return Zh(e,t,n,d,m,i,s)}else{const d=po(r,c),m=sf[d],b=n.direction[m]>=0;let T,g;b?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const x=sn(T,a,n,i,s)?Zs(T,e,t,n,i,s):null;if(x){const C=x.point[m];if(b?C<=a[g+d]:C>=a[g+d+3])return x}const M=sn(g,a,n,i,s)?Zs(g,e,t,n,i,s):null;return x&&M?x.distance<=M.distance?x:M:x||M||null}}const pr=new A.Box3,An=new gt,On=new gt,Kn=new A.Matrix4,Oa=new qe,mr=new qe;function af(r,e,t,n){pe.setBuffer(r._roots[e]);const i=Ks(0,r,t,n);return pe.clearBuffer(),i}function Ks(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Oa.set(t.boundingBox.min,t.boundingBox.max,n),i=Oa),Ee(c,a)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,b=t.attributes.position,T=$e(r,o),g=tt(c,a);if(Kn.copy(n).invert(),t.boundsTree)return Se(r,s,mr),mr.matrix.copy(Kn),mr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>mr.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let _=T*3,M=(g+T)*3;_<M;_+=3)if(we(On,_,d,m),On.needsUpdate=!0,x.intersectsTriangle(On))return!0;return!1}});{const v=Wr(t);for(let x=T*3,_=(g+T)*3;x<_;x+=3){we(An,x,d,m),An.a.applyMatrix4(Kn),An.b.applyMatrix4(Kn),An.c.applyMatrix4(Kn),An.needsUpdate=!0;for(let M=0,C=v*3;M<C;M+=3)if(we(On,M,p,b),On.needsUpdate=!0,An.intersectsTriangle(On))return!0}}}else{const h=Ie(r),d=Be(r,o);return Se(h,s,pr),!!(i.intersectsBox(pr)&&Ks(h,e,t,n,i)||(Se(d,s,pr),i.intersectsBox(pr)&&Ks(d,e,t,n,i)))}}const yr=new A.Matrix4,Es=new qe,Qn=new qe,cf=new A.Vector3,lf=new A.Vector3,uf=new A.Vector3,hf=new A.Vector3;function ff(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Es.set(e.boundingBox.min,e.boundingBox.max,t),Es.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,d=e.index,m=yt.getPrimitive(),p=yt.getPrimitive();let b=cf,T=lf,g=null,v=null;i&&(g=uf,v=hf);let x=1/0,_=null,M=null;return yr.copy(t).invert(),Qn.matrix.copy(yr),r.shapecast({boundsTraverseOrder:C=>Es.distanceToBox(C),intersectsBounds:(C,P,E)=>E<x&&E<a?(P&&(Qn.min.copy(C.min),Qn.max.copy(C.max),Qn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>Qn.distanceToBox(z),intersectsBounds:(z,I,R)=>R<x&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){we(p,3*R,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let O=C,U=C+P;O<U;O++){we(m,3*O,l,c),m.needsUpdate=!0;const F=m.distanceToTriangle(p,b,g);if(F<x&&(T.copy(b),v&&v.copy(g),x=F,_=O,M=R),F<s)return!0}}}});{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(p,3*z,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){we(m,3*R,l,c),m.needsUpdate=!0;const O=m.distanceToTriangle(p,b,g);if(O<x&&(T.copy(b),v&&v.copy(g),x=O,_=R,M=z),O<s)return!0}}}}}),yt.releasePrimitive(m),yt.releasePrimitive(p),x===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=x,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(yr),T.applyMatrix4(yr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function df(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(m,p,b=!1){const T=m*2;if(Ee(T,o)){const g=$e(m,a),v=tt(T,o);let x=1/0,_=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=g,I=g+v;z<I;z++){const R=3*r.resolveTriangleIndex(z);for(let N=0;N<3;N++){let O=R+N;O=n?n[O]:O;const U=i.getX(O),F=i.getY(O),J=i.getZ(O);U<x&&(x=U),U>C&&(C=U),F<_&&(_=F),F>P&&(P=F),J<M&&(M=J),J>E&&(E=J)}}return c[m+0]!==x||c[m+1]!==_||c[m+2]!==M||c[m+3]!==C||c[m+4]!==P||c[m+5]!==E?(c[m+0]=x,c[m+1]=_,c[m+2]=M,c[m+3]=C,c[m+4]=P,c[m+5]=E,!0):!1}else{const g=Ie(m),v=Be(m,a);let x=b,_=!1,M=!1;if(e){if(!x){const R=g/Pe+p/We,N=v/Pe+p/We;_=e.has(R),M=e.has(N),x=!_&&!M}}else _=!0,M=!0;const C=x||_,P=x||M;let E=!1;C&&(E=d(g,p,x));let z=!1;P&&(z=d(v,p,x));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],$=c[O+3];c[m+R]=U<J?U:J,c[m+R+3]=F>$?F:$}return I}}}function pf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),Qs(0,r,t,n,i,s,a),pe.clearBuffer()}function Qs(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);ef(e,t,n,m,p,i,s,a)}else{const m=Ie(r);sn(m,o,n,s,a)&&Qs(m,e,t,n,i,s,a);const p=Be(r,l);sn(p,o,n,s,a)&&Qs(p,e,t,n,i,s,a)}}const mf=["x","y","z"];function yf(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=eo(0,r,t,n,i,s);return pe.clearBuffer(),a}function eo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const d=$e(r,c),m=tt(l,o);return tf(e,t,n,d,m,i,s)}else{const d=po(r,c),m=mf[d],b=n.direction[m]>=0;let T,g;b?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const x=sn(T,a,n,i,s)?eo(T,e,t,n,i,s):null;if(x){const C=x.point[m];if(b?C<=a[g+d]:C>=a[g+d+3])return x}const M=sn(g,a,n,i,s)?eo(g,e,t,n,i,s):null;return x&&M?x.distance<=M.distance?x:M:x||M||null}}const gr=new A.Box3,zn=new gt,In=new gt,ei=new A.Matrix4,za=new qe,vr=new qe;function gf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=to(0,r,t,n);return pe.clearBuffer(),i}function to(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),za.set(t.boundingBox.min,t.boundingBox.max,n),i=za),Ee(c,a)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,b=t.attributes.position,T=$e(r,o),g=tt(c,a);if(ei.copy(n).invert(),t.boundsTree)return Se(r,s,vr),vr.matrix.copy(ei),vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>vr.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let _=T,M=g+T;_<M;_++)if(we(In,3*e.resolveTriangleIndex(_),d,m),In.needsUpdate=!0,x.intersectsTriangle(In))return!0;return!1}});{const v=Wr(t);for(let x=T,_=g+T;x<_;x++){const M=e.resolveTriangleIndex(x);we(zn,3*M,d,m),zn.a.applyMatrix4(ei),zn.b.applyMatrix4(ei),zn.c.applyMatrix4(ei),zn.needsUpdate=!0;for(let C=0,P=v*3;C<P;C+=3)if(we(In,C,p,b),In.needsUpdate=!0,zn.intersectsTriangle(In))return!0}}}else{const h=Ie(r),d=Be(r,o);return Se(h,s,gr),!!(i.intersectsBox(gr)&&to(h,e,t,n,i)||(Se(d,s,gr),i.intersectsBox(gr)&&to(d,e,t,n,i)))}}const Sr=new A.Matrix4,ks=new qe,ti=new qe,vf=new A.Vector3,Sf=new A.Vector3,xf=new A.Vector3,_f=new A.Vector3;function bf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ks.set(e.boundingBox.min,e.boundingBox.max,t),ks.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,d=e.index,m=yt.getPrimitive(),p=yt.getPrimitive();let b=vf,T=Sf,g=null,v=null;i&&(g=xf,v=_f);let x=1/0,_=null,M=null;return Sr.copy(t).invert(),ti.matrix.copy(Sr),r.shapecast({boundsTraverseOrder:C=>ks.distanceToBox(C),intersectsBounds:(C,P,E)=>E<x&&E<a?(P&&(ti.min.copy(C.min),ti.max.copy(C.max),ti.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:z=>ti.distanceToBox(z),intersectsBounds:(z,I,R)=>R<x&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){const O=E.resolveTriangleIndex(R);we(p,3*O,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let U=C,F=C+P;U<F;U++){const J=r.resolveTriangleIndex(U);we(m,3*J,l,c),m.needsUpdate=!0;const $=m.distanceToTriangle(p,b,g);if($<x&&(T.copy(b),v&&v.copy(g),x=$,_=U,M=R),$<s)return!0}}}})}else{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(p,3*z,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){const O=r.resolveTriangleIndex(R);we(m,3*O,l,c),m.needsUpdate=!0;const U=m.distanceToTriangle(p,b,g);if(U<x&&(T.copy(b),v&&v.copy(g),x=U,_=R,M=z),U<s)return!0}}}}}),yt.releasePrimitive(m),yt.releasePrimitive(p),x===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=x,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Sr),T.applyMatrix4(Sr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function Ia(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const xr=new qe,_r=new A.Ray,Ba=new A.Vector3,Na=new A.Matrix4,Ua=new A.Vector3,Rs=["getX","getY","getZ"];class Vn extends Xc{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Vn(t,{...n,[Gr]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const h=new A.BufferAttribute(e.index,1,!1);t.setIndex(h)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let h=0;h<l.length;h++){const d=l[h],m=new Uint32Array(d),p=new Uint16Array(d);for(let b=0,T=d.byteLength/We;b<T;b++){const g=Pe*b,v=2*g;Ee(v,p)||(m[g+6]=m[g+6]/Pe-b)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,l=(s?s[e]:e)*3;let h=l+0,d=l+1,m=l+2;o&&(h=o[h],d=o[d],m=o[m]);for(let p=0;p<3;p++){const b=a[Rs[p]](h),T=a[Rs[p]](d),g=a[Rs[p]](m);let v=b;T<v&&(v=T),g<v&&(v=g);let x=b;T>x&&(x=T),g>x&&(x=g),t[n+p]=v,t[n+p+3]=x}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,h=a.offset||0;let d=3;a.isInterleavedBufferAttribute&&(d=a.data.stride);const m=["getX","getY","getZ"],p=n.offset;for(let b=e,T=e+t;b<T;b++){const v=(s?s[b]:b)*3,x=(b-p)*6;let _=v+0,M=v+1,C=v+2;o&&(_=o[_],M=o[M],C=o[C]),c||(_=_*d+h,M=M*d+h,C=C*d+h);for(let P=0;P<3;P++){let E,z,I;c?(E=a[m[P]](_),z=a[m[P]](M),I=a[m[P]](C)):(E=l[_+P],z=l[M+P],I=l[C+P]);let R=E;z<R&&(R=z),I<R&&(R=I);let N=E;z>N&&(N=z),I>N&&(N=I);const O=(N-R)/2,U=P*2;n[x+U+0]=R+O,n[x+U+1]=O+(Math.abs(R)+O)*kr}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;Na.copy(e.matrixWorld).invert(),_r.copy(t.ray).applyMatrix4(Na),Ua.setFromMatrixScale(e.matrixWorld),Ba.copy(_r.direction).multiply(Ua);const s=Ba.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(_r,i,a,o);c=Ia(c,e,t),c&&n.push(c)}else{const c=this.raycast(_r,i,a,o);for(let l=0,h=c.length;l<h;l++){const d=Ia(c[l],e,t);d&&n.push(d)}}return n}refit(e=null){return(this.indirect?df:Qh)(this,e)}raycast(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?pf:rf;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?yf:of;for(let c=0,l=s.length;c<l;c++){const h=o(this,c,t,e,n,i);h!=null&&(a==null||h.distance<a.distance)&&(a=h)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?gf:af;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=yt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?nf:Kh});return yt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=yt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const T=this.resolveTriangleIndex(b);we(a,T*3,o,c)}:b=>{we(a,b*3,o,c)},h=yt.getPrimitive(),d=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?b=>{const T=e.resolveTriangleIndex(b);we(h,T*3,d,m)}:b=>{we(h,b*3,d,m)};if(s){if(!(e instanceof Vn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const b=(T,g,v,x,_,M,C,P)=>{for(let E=v,z=v+x;E<z;E++){p(E),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=T,R=T+g;I<R;I++)if(l(I),a.needsUpdate=!0,s(a,h,I,E,_,M,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,x,_,M,C,P,E){return T(g,v,x,_,M,C,P,E)?!0:b(g,v,x,_,M,C,P,E)}}else i=b}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return xr.set(e.min,e.max,t),xr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>xr.intersectsBox(n),intersectsTriangle:n=>xr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?bf:ff)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Hh(this,e,t,n,i)}}const Bn={Mesh:A.Mesh.prototype.raycast,Line:A.Line.prototype.raycast,LineSegments:A.LineSegments.prototype.raycast,LineLoop:A.LineLoop.prototype.raycast,Points:A.Points.prototype.raycast,BatchedMesh:A.BatchedMesh.prototype.raycast},De=new A.Mesh,br=[];function Tf(r,e){if(this.isBatchedMesh)Mf.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof A.Mesh)n=Bn.Mesh;else if(this instanceof A.LineSegments)n=Bn.LineSegments;else if(this instanceof A.LineLoop)n=Bn.LineLoop;else if(this instanceof A.Line)n=Bn.Line;else if(this instanceof A.Points)n=Bn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function Mf(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;De.material=this.material,De.geometry=this.geometry;const a=De.geometry.boundsTree,o=De.geometry.drawRange;De.geometry.boundingSphere===null&&(De.geometry.boundingSphere=new A.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const h=n[c].geometryIndex;if(De.geometry.boundsTree=t[h],this.getMatrixAt(c,De.matrixWorld).premultiply(s),!De.geometry.boundsTree){this.getBoundingBoxAt(h,De.geometry.boundingBox),this.getBoundingSphereAt(h,De.geometry.boundingSphere);const d=i[h];De.geometry.setDrawRange(d.start,d.count)}De.raycast(r,br);for(let d=0,m=br.length;d<m;d++){const p=br[d];p.object=this,p.batchId=c,e.push(p)}br.length=0}De.geometry.boundsTree=a,De.geometry.drawRange=o,De.material=null,De.geometry=null}else Bn.BatchedMesh.call(this,r,e)}function Cf(r={}){const{type:e=Vn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const dn=new A.Vector3,pn=new A.Vector3,mn=new A.Vector3,Da=new A.Vector4,Tr=new A.Vector3,As=new A.Vector3,La=new A.Vector4,Fa=new A.Vector4,Mr=new A.Matrix4,Va=new A.Matrix4;function ni(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function oi(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new A.BufferAttribute(new t(i*s),i,n)}function Yc(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function wf(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function Ja(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;La.fromBufferAttribute(i.attributes.skinIndex,e),Fa.fromBufferAttribute(i.attributes.skinWeight,e),Mr.elements.fill(0);for(let o=0;o<4;o++){const c=Fa.getComponent(o);if(c!==0){const l=La.getComponent(o);Va.multiplyMatrices(s[l].matrixWorld,a[l]),wf(Mr,Va,c)}}return Mr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Mr),t}function Os(r,e,t,n,i){Tr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(As.fromBufferAttribute(c,n),t?Tr.addScaledVector(As,o):Tr.addScaledVector(As.sub(i),o))}i.add(Tr)}function Pf(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new A.BufferGeometry){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let h=0;h<r.length;++h){const d=r[h];let m=0;if(n!==(d.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const p in d.attributes){if(!o.has(p))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.');c[p]===void 0&&(c[p]=[]),c[p].push(d.attributes[p]),m++}if(m!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,p,h),l+=p}}if(n){let h=!1;if(!t.index){let d=0;for(let m=0;m<r.length;++m)d+=r[m].index.count;t.setIndex(new A.BufferAttribute(new Uint32Array(d),1,!1)),h=!0}if(s||h){const d=t.index;let m=0,p=0;for(let b=0;b<r.length;++b){const T=r[b],g=T.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)d.setX(m,g.getX(v)+p),m++;p+=T.attributes.position.count}}}for(const h in c){const d=c[h];if(!(h in t.attributes)){let b=0;for(const T in d)b+=d[T].count;t.setAttribute(h,oi(c[h][0],b))}const m=t.attributes[h];let p=0;for(let b=0,T=d.length;b<T;b++){const g=d[b];a[b]!==!0&&Yc(g,m,p),p+=g.count}}return t}function Ef(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function kf(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),h=i.getComponent(a+2,c);i.setComponent(a,c,h),i.setComponent(a+2,c,l)}}return r}class Rf{constructor(e){this.matrixWorld=new A.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Ef(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Af{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new A.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new A.BufferGeometry){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],h=s[o],d=a.get(l);!d||d.didChange(l)?(this._convertToStaticGeometry(l,h),t.push(!1),d?d.update():a.set(l,new Rf(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new A.BufferAttribute(new Float32Array(0),4,!1))}else Pf(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new A.BufferGeometry){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",oi(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",oi(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",oi(o.tangent)),ni(n.index,t.index),ni(o.position,c.position),s&&ni(o.normal,c.normal),a&&ni(o.tangent,c.tangent);const l=o.position,h=s?o.normal:null,d=a?o.tangent:null,m=n.morphAttributes.position,p=n.morphAttributes.normal,b=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new A.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let x=0,_=o.position.count;x<_;x++)dn.fromBufferAttribute(l,x),h&&pn.fromBufferAttribute(h,x),d&&(Da.fromBufferAttribute(d,x),mn.fromBufferAttribute(d,x)),g&&(m&&Os(m,g,T,x,dn),p&&Os(p,g,T,x,pn),b&&Os(b,g,T,x,mn)),e.isSkinnedMesh&&(e.applyBoneTransform(x,dn),h&&Ja(e,x,pn),d&&Ja(e,x,mn)),i&&dn.applyMatrix4(e.matrixWorld),c.position.setXYZ(x,dn.x,dn.y,dn.z),h&&(i&&pn.applyNormalMatrix(v),c.normal.setXYZ(x,pn.x,pn.y,pn.z)),d&&(i&&mn.transformDirection(e.matrixWorld),c.tangent.setXYZW(x,mn.x,mn.y,mn.z,Da.w));for(const x in this.attributes){const _=this.attributes[x];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,oi(o[_])),ni(o[_],c[_]),Yc(o[_],c[_]))}return e.matrixWorld.determinant()<0&&kf(t),t}}const Of=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Vc,BVH:Hc,CENTER:fo,CONTAINED:Ws,ExtendedTriangle:gt,GeometryBVH:Xc,MeshBVH:Vn,OrientedBox:qe,SAH:Jc,SKIP_GENERATION:Gr,StaticGeometryGenerator:Af,acceleratedRaycast:Tf,computeBoundsTree:Cf,generateIndirectBuffer:qc},Symbol.toStringTag,{value:"Module"}));class zf{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const mt={node:"node",material:"material",camera:"camera",light:"light"},Qt="KHR_animation_pointer",If={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear,STEP:A.InterpolateDiscrete};class Bf{constructor(e){this.name=Qt,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){Uf();const t=e.target,n=t.extensions&&t.extensions[Qt]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=mt.node,a;if(n){const c=t.extensions[Qt];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=mt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=mt.light:l.startsWith("/cameras/")&&(s=mt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case mt.material:const h=("/materials/"+a.toString()+"/").length,d=l.substring(0,h);switch(i=l.substring(h),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=d+i;break;case mt.node:const m=("/nodes/"+a.toString()+"/").length,p=l.substring(0,m);if(i=l.substring(m),i.startsWith("weights/")){const v=i.substring(8);/^\d+$/.test(v)?i="morphTargetInfluences["+v+"]":console.warn(Qt+": invalid weight index",i,l)}else switch(i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":i="visible";break}l=p+i;break;case mt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case mt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Qt].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===mt.node?o=this.parser.getDependency("node",a):s===mt.material?o=this.parser.getDependency("material",a):s===mt.light?o=this.parser.getDependency("light",a):s===mt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Qt]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[Qt].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]?.startsWith("morphTargetInfluences")){const b=l[3];if(e.type==="Group"){for(const T of e.children)T instanceof A.SkinnedMesh&&T.morphTargetInfluences&&(l[3]=T.name,l[4]=b,p(this.parser));return c}}p(this.parser);function m(b,T){try{const g=T.split(".").filter(Boolean),x=g[g.length-1].replace(/\[.*\]$/,"");return x in b?typeof b[x]=="boolean":!1}catch{return!1}}function p(b){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&m(e,o)?(T=A.BooleanKeyframeTrack,g=!0):T=A.NumberKeyframeTrack;break;case 2:case 3:T=A.VectorKeyframeTrack;break;case 4:o.endsWith(".quaternion")?T=A.QuaternionKeyframeTrack:T=A.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?If[i.interpolation]:A.InterpolateLinear;let x=b._getArrayFromAccessor(n);o.endsWith(".fov")&&(x=x.map(M=>M/Math.PI*180)),g&&(x=x.map(M=>M>0));const _=new T(o,t.array,x,v);if(v==="CUBICSPLINE"&&b._createCubicSplineTrackInterpolant(_),c.push(_),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const M=new Float32Array(x.length/4);for(let P=0,E=x.length/4;P<E;P+=1)M[P]=x[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,M,v);v==="CUBICSPLINE"&&b._createCubicSplineTrackInterpolant(_),c.push(C)}}return c}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],h=[],d=[];for(let m=0,p=s.channels.length;m<p;m++){const b=s.channels[m],T=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,x=s.parameters!==void 0?s.parameters[T.output]:T.output;let _=t.loadAnimationTargetFromChannelWithAnimationPointer(b);_||(_=t.loadAnimationTargetFromChannel(b)),o.push(_),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",x)),h.push(T),d.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(d)]).then(function(m){const p=m[0],b=m[1],T=m[2],g=m[3],v=m[4],x=[];for(let _=0,M=p.length;_<M;_++){const C=p[_],P=b[_],E=T[_],z=g[_],I=v[_];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(C,P,E,z,I);if(R||(R=i._createAnimationTracks(C,P,E,z,I)),R)for(let N=0;N<R.length;N++)x.push(R[N])}return new A.AnimationClip(a,void 0,x)})}}let ja=!1,Nf=null;function Uf(){if(ja)return;ja=!0;const r=Nf||=A.PropertyBinding.findNode;A.PropertyBinding.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const c=Number.parseInt(a);let l=a;c>=0&&(l=c),i=i[l]}else{const c=e.getObjectByName(a);c&&(i=c)}}if(!i){const s=r(e,n[2]);return s||console.warn(Qt+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Df=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Bf},Symbol.toStringTag,{value:"Module"}));var Lf=Object.defineProperty,Ff=(r,e,t)=>e in r?Lf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Ff(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class t extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class n extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class i extends r{constructor(f,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=f,this.type=y}}class s extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class a extends r{}class o extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class c extends r{}class l extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class h extends r{constructor(f,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=f,this.type=y}}class d extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class m extends r{constructor(f,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=f,this.type=y,this.unit=S}}class p extends r{}class b extends r{}class T extends r{}class g extends r{}class v extends r{}class x extends r{}class _ extends r{}class M extends r{}class C extends r{}class P extends r{}class E extends r{}class z extends r{}class I{constructor(f){Ce(this,"input"),Ce(this,"index",0),this.input=f}consume(){const f=this.input.codePointAt(this.index);return f!==void 0&&(this.index+=String.fromCodePoint(f).length),f}reconsume(f){f!==void 0&&(this.index-=String.fromCodePoint(f).length)}peek(){const f=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);f.push(w),y+=String.fromCodePoint(w).length}return f}}function R(u){return u===10}function N(u){return R(u)||u===8192||u===32}function O(u){return u>=48&&u<=57}function U(u){return O(u)||u>=65&&u<=70||u>=97&&u<=102}function F(u){return(function(f){return(function(y){return y>=65&&y<=90})(f)||(function(y){return y>=97&&y<=122})(f)})(u)||(function(f){return f>=128})(u)||u===95}function J(u){return F(u)||O(u)||u===45}function $(u){return u>=0&&u<=8||u===11||u>=14&&u<=31||u===127}function K(u,f){return u===92&&!R(f)}function W(u,f,y){return u===45?F(f)||f===45||K(f,y):!!F(u)||u===92&&K(u,f)}function me(u,f,y){return u===43||u===45?O(f)||f===46&&O(y):O(u===46?f:u)}function ne(u){const f=u.consume();if(U(f)){let y=[f];for(;U(...u.peek())&&y.length<5;)y.push(u.consume());N(...u.peek())&&u.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return f===void 0?65533:f}function ue(u,f){const y=new s("");for(;;){const S=u.consume();if(S===f||S===void 0)return y;if(S===10)return u.reconsume(S),new a;if(S===92){const w=u.peek()[0];w===void 0||(R(w)?u.consume():y.value+=String.fromCodePoint(ne(u)))}else y.value+=String.fromCodePoint(S)}}function re(u){let f="";for(;;){const y=u.consume();if(J(y))f+=String.fromCodePoint(y);else{if(!K(...u.peek()))return u.reconsume(y),f;f+=String.fromCodePoint(ne(u))}}}function ge(u){let f=(function(y){let S="integer",w="";for([43,45].includes(y.peek()[0])&&(w+=String.fromCodePoint(y.consume()));O(...y.peek());)w+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&O(y.peek()[1]))for(w+=String.fromCodePoint(y.consume(),y.consume()),S="number";O(...y.peek());)w+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&O(y.peek()[2])?(w+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):O(y.peek()[1])&&(w+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(w),type:S}})(u);return W(...u.peek())?new m(f.value,f.type,re(u)):u.peek()[0]===37?(u.consume(),new d(f.value)):new h(f.value,f.type)}function be(u){for(;;){const f=u.consume();if(f===41||f===void 0)return;K(...u.peek())&&ne(u)}}function se(u){const f=re(u);if(f.match(/url/i)&&u.peek()[0]===40){for(u.consume();N(u.peek()[0])&&N(u.peek()[1]);)u.consume();return[34,39].includes(u.peek()[0])||N(u.peek()[0])&&[34,39].includes(u.peek()[1])?new t(f):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const w=y.consume();if(w===41||w===void 0)return S;if(N(w)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(be(y),new c)}if([34,39,40].includes(w)||$(w))return be(y),new c;if(w===92){if(!K(...y.peek()))return be(y),new c;S.value+=ne(y)}else S.value+=String.fromCodePoint(w)}})(u)}return u.peek()[0]===40?(u.consume(),new t(f)):new e(f)}function he(u){const f=u.consume(),y=u.peek();if(N(f)){for(;N(...u.peek());)u.consume();return new p}if(f===34)return ue(u,f);if(f===35){if(J(y[0])||K(...y)){const S=new i;return W(...y)&&(S.type="id"),S.value=re(u),S}return new l(String.fromCodePoint(f))}return f===39?ue(u,f):f===40?new C:f===41?new P:f===43?me(...y)?(u.reconsume(f),ge(u)):new l(String.fromCodePoint(f)):f===44?new x:f===45?me(...u.peek())?(u.reconsume(f),ge(u)):u.peek()[0]===45&&u.peek()[1]===62?(u.consume(),u.consume(),new T):W(...u.peek())?(u.reconsume(f),se(u)):new l(String.fromCodePoint(f)):f===46?me(...u.peek())?(u.reconsume(f),ge(u)):new l(String.fromCodePoint(f)):f===58?new g:f===59?new v:f===60?y[0]===33&&y[1]===45&&y[2]===45?(u.consume(),u.consume(),u.consume(),new b):new l(String.fromCodePoint(f)):f===64?W(...y)?new n(re(u)):new l(String.fromCodePoint(f)):f===91?new _:f===92?K(...y)?(u.reconsume(f),se(u)):new l(String.fromCodePoint(f)):f===93?new M:f===123?new E:f===125?new z:O(f)?(u.reconsume(f),ge(u)):F(f)?(u.reconsume(f),se(u)):f===void 0?void 0:new l(String.fromCodePoint(f))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function Xe(u){return oe.has(u.toLowerCase())}function Ve(u,f){if(["x","y"].includes(u))return u;if(!f)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=f.writingMode=="horizontal-tb";if(u==="block")u=y?"y":"x";else{if(u!=="inline")throw new TypeError(`Invalid axis “${u}”`);u=y?"x":"y"}return u}function Je(u){const f=[];let y=0;function S(){let k=0;const B=y;for(;y<u.length;){const L=u.slice(y,y+1);if(/\s/.test(L)&&k===0)break;if(L==="(")k+=1;else if(L===")"&&(k-=1,k===0)){y++;break}y++}return u.slice(B,y)}function w(){for(;/\s/.test(u.slice(y,y+1));)y++}for(;y<u.length;){const k=u.slice(y,y+1);/\s/.test(k)?w():f.push(S())}return f}function Ye(u,f){return u.reduce(((y,S)=>(y.has(S[f])?y.get(S[f]).push(S):y.set(S[f],[S]),y)),new Map)}function xe(u,f){const y=[],S=[];for(const w of u)f(w)?y.push(w):S.push(w);return[y,S]}function ye(u,f={}){function y(S){return Array.from(S).map((w=>ye(w,f)))}if(u instanceof CSSUnitValue){if(u.unit==="percent"&&f.percentageReference){const w=u.value/100*f.percentageReference.value,k=f.percentageReference.unit;return new CSSUnitValue(w,k)}const S=u.toSum();if(S&&S.values.length===1&&(u=S.values[0]),u instanceof CSSUnitValue&&u.unit==="em"&&f.fontSize&&(u=new CSSUnitValue(u.value*f.fontSize.value,f.fontSize.unit)),u instanceof CSSKeywordValue){if(u.value==="e")return new CSSUnitValue(Math.E,"number");if(u.value==="pi")return new CSSUnitValue(Math.PI,"number")}return u}if(!u.operator)return u;switch(u.operator){case"sum":u=new CSSMathSum(...y(u.values));break;case"product":u=new CSSMathProduct(...y(u.values));break;case"negate":u=new CSSMathNegate(ye(u.value,f));break;case"clamp":u=new CSSMathClamp(ye(u.lower,f),ye(u.value,f),ye(u.upper,f));break;case"invert":u=new CSSMathInvert(ye(u.value,f));break;case"min":u=new CSSMathMin(...y(u.values));break;case"max":u=new CSSMathMax(...y(u.values))}if(u instanceof CSSMathMin||u instanceof CSSMathMax){const S=Array.from(u.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&Xe(w.unit)&&w.unit===S[0].unit))){const w=Math[u.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(u instanceof CSSMathMin||u instanceof CSSMathMax){const S=Array.from(u.values),[w,k]=xe(S,(L=>L instanceof CSSUnitValue&&L.unit!=="percent")),B=Array.from(Ye(w,"unit").values());if(B.some((L=>L.length>0))){const L=B.map((D=>{const V=Math[u.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));u=u instanceof CSSMathMin?new CSSMathMin(...L,...k):new CSSMathMax(...L,...k)}return S.length===1?S[0]:u}if(u instanceof CSSMathNegate)return u.value instanceof CSSUnitValue?new CSSUnitValue(0-u.value.value,u.value.unit):u.value instanceof CSSMathNegate?u.value.value:u;if(u instanceof CSSMathInvert)return u.value instanceof CSSMathInvert?u.value.value:u;if(u instanceof CSSMathSum){let S=function(k){const B=k.filter((L=>L instanceof CSSUnitValue));return[...k.filter((L=>!(L instanceof CSSUnitValue))),...Array.from(Ye(B,"unit").entries()).map((([L,D])=>{const V=D.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,L)}))]},w=[];for(const k of u.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(u instanceof CSSMathProduct){let S=[];for(const B of u.values)B instanceof CSSMathProduct?S.push(...B.values):S.push(B);const[w,k]=xe(S,(B=>B instanceof CSSUnitValue&&B.unit==="number"));if(w.length>1){const B=w.reduce(((L,{value:D})=>L*D),1);S=[new CSSUnitValue(B,"number"),...k]}if(S.length===2){let B,L;for(const D of S)D instanceof CSSUnitValue&&D.unit==="number"?B=D:D instanceof CSSMathSum&&[...D.values].every((V=>V instanceof CSSUnitValue))&&(L=D);if(B&&L)return new CSSMathSum(...[...L.values].map((D=>new CSSUnitValue(D.value*B.value,D.unit))))}if(S.every((B=>B instanceof CSSUnitValue&&Xe(B.unit)||B instanceof CSSMathInvert&&B.value instanceof CSSUnitValue&&Xe(B.value.unit)))){const B=new CSSMathProduct(...S).toSum();if(B&&B.values.length===1)return B.values[0]}return new CSSMathProduct(...S)}return u}const ae=null,ut=["percent","length","angle","time","frequency","resolution","flex"],ke={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},fe=new Map;for(const u of Object.values(ke))if(u.compatible)for(const f of u.units)fe.set(f,u);function it(u){return fe.get(u)}function vt(u,f){const y={...u};for(const S of Object.keys(f))y[S]?y[S]+=f[S]:y[S]=f[S];return y}function St(u){return u==="number"?{}:u==="percent"?{percent:1}:ke.absoluteLengths.units.has(u)||ke.fontRelativeLengths.units.has(u)||ke.viewportRelativeLengths.units.has(u)?{length:1}:ke.angle.units.has(u)?{angle:1}:ke.time.units.has(u)?{time:1}:ke.frequency.units.has(u)?{frequency:1}:ke.resolution.units.has(u)?{resolution:1}:u==="fr"?{flex:1}:ae}function rt(u){if(u instanceof CSSUnitValue){let{unit:f,value:y}=u;const S=it(u.unit);return S&&f!==S.canonicalUnit&&(y*=S.ratios[f],f=S.canonicalUnit),f==="number"?[[y,{}]]:[[y,{[f]:1}]]}if(u instanceof CSSMathInvert){if(!(u.value instanceof CSSUnitValue))throw new Error("Not implemented");const f=rt(u.value);if(f===ae||f.length>1)return ae;const y=f[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return f[0]=[1/y[0],S],f}if(u instanceof CSSMathProduct){let f=[[1,{}]];for(const y of u.values){const S=rt(y),w=[];if(S===ae)return ae;for(const k of f)for(const B of S)w.push([k[0]*B[0],vt(k[1],B[1])]);f=w}return f}throw new Error("Not implemented")}function xt(u,f){if(St(f)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=rt(u);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(w,k){const B=w.unit,L=w.value,D=it(B),V=it(k);return!V||D!==V?ae:new CSSUnitValue(L*V.ratios[B]/V.ratios[k],k)})(ht(y[0]),f);if(S===ae)throw new TypeError;return S}function ht(u){const[f,y]=u,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(f,"number");const w=S[0];return w[1]!==1?ae:new CSSUnitValue(f,w[0])}function ft(u,...f){if(f&&f.length)throw new Error("Not implemented");const y=rt(u).map((S=>ht(S)));if(y.some((S=>S===ae)))throw new TypeError("Type error");return new CSSMathSum(...y)}function _t(u,f){if(u.percentHint&&f.percentHint&&u.percentHint!==f.percentHint)return ae;const y={...u,percentHint:u.percentHint??f.percentHint};for(const S of ut)f[S]&&(y[S]??(y[S]=0),y[S]+=f[S]);return y}class Re{constructor(f,y){Ce(this,"name"),Ce(this,"values"),this.name=f,this.values=y}}class Ze{constructor(f,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=f,this.associatedToken=y}}function ct(u){if(Array.isArray(u))return u;if(typeof u=="string")return(function(f){const y=new I(f),S=[];for(;;){const w=he(y);if(w===void 0)return S;S.push(w)}})(u);throw new TypeError("Invalid input type "+typeof u)}function Ke(u){const f=u.shift();return f instanceof E||f instanceof _||f instanceof C?(function(y,S){let w;if(S instanceof E)w=z;else if(S instanceof C)w=P;else{if(!(S instanceof _))return;w=M}const k=new Ze([],S);for(;;){const B=y.shift();if(B instanceof w||B===void 0)return k;y.unshift(B),k.value.push(Ke(y))}})(u,f):f instanceof t?(function(y,S){const w=new Re(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return w;S.unshift(k),w.values.push(Ke(S))}})(f,u):f}function Q(u){if(u instanceof C||u instanceof P)return 6;if(u instanceof l)switch(u.value){case"*":case"/":return 4;case"+":case"-":return 2}}function bt(u){return u[u.length-1]}function Nt(u,f,y){const S=["+","-"].includes(u.value)?"ADDITION":"MULTIPLICATION",w=f.type===S?f.values:[f],k=y.type===S?y.values:[y];return u.value==="-"?k[0]={type:"NEGATE",value:k[0]}:u.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function Tt(u){if(u.type==="ADDITION")return new CSSMathSum(...u.values.map((f=>Tt(f))));if(u.type==="MULTIPLICATION")return new CSSMathProduct(...u.values.map((f=>Tt(f))));if(u.type==="NEGATE")return new CSSMathNegate(Tt(u.value));if(u.type==="INVERT")return new CSSMathInvert(Tt(u.value));if(u instanceof Ze)return Ut(new Re("calc",u.value));if(u instanceof e){if(u.value==="e")return new CSSUnitValue(Math.E,"number");if(u.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return le(u)}function Ut(u){if(u.name==="min"||u.name==="max"){const S=u.values.filter((w=>!(w instanceof p||w instanceof x))).map((w=>ye(Ut(new Re("calc",w)))));return u.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(u.name!=="calc")return null;const f=Tt((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof h||B instanceof m||B instanceof d||B instanceof Re||B instanceof Ze||B instanceof e)k.push(B);else if(B instanceof l&&["*","/","+","-"].includes(B.value)){for(;w.length&&!(bt(w)instanceof C)&&Q(bt(w))>Q(B);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}w.push(B)}else if(B instanceof C)w.push(B);else if(B instanceof P){if(!w.length)return null;for(;!(bt(w)instanceof C);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}if(!(bt(w)instanceof C))return null;w.pop()}else if(!(B instanceof p))return null}for(;w.length;){if(bt(w)instanceof C)return null;const B=w.pop(),L=k.pop(),D=k.pop();k.push(Nt(B,D,L))}return k[0]})([...u.values]));let y;try{y=ye(f)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function le(u){return u instanceof Re&&["calc","min","max","clamp"].includes(u.name)?Ut(u):u instanceof h&&u.value===0&&!u.unit?new CSSUnitValue(0,"px"):u instanceof h?new CSSUnitValue(u.value,"number"):u instanceof d?new CSSUnitValue(u.value,"percent"):u instanceof m?new CSSUnitValue(u.value,u.unit):void 0}function Zc(u){const f=(function(y){const S=ct(y);for(;S[0]instanceof p;)S.shift();if(S[0]===void 0)return null;const w=Ke(S);for(;S[0]instanceof p;)S.shift();return S[0]===void 0?w:null})(u);return f===null&&new CSSStyleSheet().insertRule("error",0),f instanceof h||f instanceof d||f instanceof m||f instanceof Re||new CSSStyleSheet().insertRule("error",0),f instanceof m&&St(f.unit)===null&&new CSSStyleSheet().insertRule("error",0),le(f)}(function(){let u=new WeakMap;function f(k){const B=[];for(let D=0;D<k.length;D++)B[D]=typeof(L=k[D])=="number"?new CSSUnitValue(L,"number"):L;var L;return B}class y{static parse(B){return B instanceof y?B:ye(Zc(B),{})}}class S extends y{constructor(B,L,D,V){super(),u.set(this,{values:f(B),operator:L,name:D||L,delimiter:V||", "})}get operator(){return u.get(this).operator}get values(){return u.get(this).values}toString(){const B=u.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),u.set(this,{value:k,unit:B})}get value(){return u.get(this).value}set value(k){u.get(this).value=k}get unit(){return u.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ft(this,...k)}type(){return St(u.get(this).unit)}toString(){const k=u.get(this);return`${k.value}${(function(B){switch(B){case"percent":return"%";case"number":return"";default:return B.toLowerCase()}})(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ft(this,...k)}type(){return u.get(this).values.map((k=>k.type())).reduce(_t)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return u.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return u.get(this).values[1]}type(){return(function(k){const B={};for(const L of ut)B[L]=-1*k[L];return B})(u.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:B=>new CSSUnitValue(B,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,B]of Object.entries(w))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:B}))throw Error(`Error installing CSSOM support for ${k}`)})();const vo="block";let je=new WeakMap,Dt=new WeakMap;const Wi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function So(u){return u===document.scrollingElement?document:u}function on(u){qr(u);let f=je.get(u).animations;if(f.length===0)return;let y=u.currentTime;for(let S=0;S<f.length;S++)f[S].tickAnimation(y)}function xo(u,f){if(!u)return null;const y=Dt.get(u).sourceMeasurements,S=getComputedStyle(u);let w=y.scrollTop;return Ve(f,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function Hr(u,f){const y=ye(u,f);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof u)}function qr(u){if(!(u instanceof bn))return void(function(y){const S=je.get(y);if(!S.anonymousSource)return;const w=bo(S.anonymousSource,S.anonymousTarget);_n(y,w)})(u);const f=u.subject;if(!f||getComputedStyle(f).display=="none")return void _n(u,null);_n(u,es(f))}function _o(u){return["block","inline","x","y"].includes(u)}function Xr(u){const f=getComputedStyle(u);return{scrollLeft:u.scrollLeft,scrollTop:u.scrollTop,scrollWidth:u.scrollWidth,scrollHeight:u.scrollHeight,clientWidth:u.clientWidth,clientHeight:u.clientHeight,writingMode:f.writingMode,direction:f.direction,scrollPaddingTop:f.scrollPaddingTop,scrollPaddingBottom:f.scrollPaddingBottom,scrollPaddingLeft:f.scrollPaddingLeft,scrollPaddingRight:f.scrollPaddingRight}}function Yr(u,f){if(!u||!f)return;let y=0,S=0,w=f;const k=u.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=u.offsetLeft+u.clientLeft,y-=u.offsetTop+u.clientTop;const B=getComputedStyle(f);return{top:y,left:S,offsetWidth:f.offsetWidth,offsetHeight:f.offsetHeight,fontSize:B.fontSize}}function $i(u){let f=Dt.get(u);f.sourceMeasurements=Xr(u);for(const y of f.timelineRefs){const S=y.deref();S instanceof bn&&(je.get(S).subjectMeasurements=Yr(u,S.subject))}f.updateScheduled||(setTimeout((()=>{for(const y of f.timelineRefs){const S=y.deref();S&&on(S)}f.updateScheduled=!1})),f.updateScheduled=!0)}function _n(u,f){const y=je.get(u),S=y.source;if(S!=f){if(S){const w=Dt.get(S);if(w){w.timelineRefs.delete(u);const k=Array.from(w.timelineRefs).filter((B=>B.deref()===void 0));for(const B of k)w.timelineRefs.delete(B);w.timelineRefs.size===0&&(w.disconnect(),Dt.delete(S))}}if(y.source=f,f){let w=Dt.get(f);if(!w){w={timelineRefs:new Set,sourceMeasurements:Xr(f)},Dt.set(f,w);const k=new ResizeObserver((D=>{for(const V of D)$i(y.source)}));k.observe(f);for(const D of f.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)$i(V.target)}));B.observe(f,{attributes:!0,attributeFilter:["style","class"]});const L=()=>{w.sourceMeasurements.scrollLeft=f.scrollLeft,w.sourceMeasurements.scrollTop=f.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&on(V)}};So(f).addEventListener("scroll",L),w.disconnect=()=>{k.disconnect(),B.disconnect(),So(f).removeEventListener("scroll",L)}}w.timelineRefs.add(new WeakRef(u))}}}function Zr(u,f){let y=je.get(u).animations;for(let S=0;S<y.length;S++)y[S].animation==f&&y.splice(S,1)}function Kr(u,f,y){let S=je.get(u).animations;for(let w=0;w<S.length;w++)if(S[w].animation==f)return;S.push({animation:f,tickAnimation:y}),queueMicrotask((()=>{on(u)}))}class Qe{constructor(f){if(je.set(this,{source:null,axis:vo,anonymousSource:f?f.anonymousSource:null,anonymousTarget:f?f.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),_n(this,f&&f.source!==void 0?f.source:document.scrollingElement),f&&f.axis!==void 0&&f.axis!=vo){if(!_o(f.axis))throw TypeError("Invalid axis");je.get(this).axis=f.axis}on(this)}set source(f){_n(this,f),on(this)}get source(){return je.get(this).source}set axis(f){if(!_o(f))throw TypeError("Invalid axis");je.get(this).axis=f,on(this)}get axis(){return je.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const f=this.source;if(!f)return"inactive";let y=getComputedStyle(f);return y.display=="none"?"inactive":f==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const w=this.axis,k=xo(y,w),B=(function(L,D){const V=Dt.get(L).sourceMeasurements,H=getComputedStyle(L).writingMode=="horizontal-tb";return D==="block"?D=H?"y":"x":D==="inline"&&(D=H?"x":"y"),D==="y"?V.scrollHeight-V.clientHeight:D==="x"?V.scrollWidth-V.clientWidth:void 0})(y,w);return B>0?CSS.percent(100*k/B):CSS.percent(100)}get __polyfill(){return!0}}function Qr(u,f){let y=u.parentElement;for(;y!=null;){if(f(y))return y;y=y.parentElement}}function bo(u,f){switch(u){case"root":return document.scrollingElement;case"nearest":return es(f);case"self":return f;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Kc(u){switch(getComputedStyle(u).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function To(u){const f=getComputedStyle(u);return f.transform!="none"||f.perspective!="none"||f.willChange=="transform"||f.willChange=="perspective"||f.filter!="none"||f.willChange=="filter"||f.backdropFilter!="none"}function Qc(u){return getComputedStyle(u).position!="static"||To(u)}function el(u){switch(getComputedStyle(u).position){case"static":case"relative":case"sticky":return Qr(u,Kc);case"absolute":return Qr(u,Qc);case"fixed":return Qr(u,To)}}function es(u){if(u&&u.isConnected){for(;u=el(u);)switch(getComputedStyle(u)["overflow-x"]){case"auto":case"scroll":case"hidden":return u==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:u}return document.scrollingElement}}function Gn(u,f){const y=je.get(u),S=y.subjectMeasurements,w=Dt.get(y.source).sourceMeasurements;return u.phase==="inactive"?null:u instanceof bn?ts(f,w,S,y.axis,y.inset):null}function ts(u,f,y,S,w){const k=f.direction=="rtl"||f.writingMode=="vertical-rl";let B,L,D={fontSize:y.fontSize};Ve(S,f)==="x"?(B=y.offsetWidth,L=y.left,D.scrollPadding=[f.scrollPaddingLeft,f.scrollPaddingRight],k&&(L+=f.scrollWidth-f.clientWidth,D.scrollPadding=[f.scrollPaddingRight,f.scrollPaddingLeft]),D.containerSize=f.clientWidth):(B=y.offsetHeight,L=y.top,D.scrollPadding=[f.scrollPaddingTop,f.scrollPaddingBottom],D.containerSize=f.clientHeight);const V=(function(ss,Zi){const fl={start:0,end:0};if(!ss)return fl;const[dl,pl]=[ss.start,ss.end].map(((Do,Lo)=>Do==="auto"?Zi.scrollPadding[Lo]==="auto"?0:parseFloat(Zi.scrollPadding[Lo]):Hr(Do,{percentageReference:CSS.px(Zi.containerSize),fontSize:CSS.px(parseFloat(Zi.fontSize))})));return{start:dl,end:pl}})(w,D),H=L-D.containerSize+V.end,X=L+B-V.start,Y=H+B,de=X-B,Te=Math.min(Y,de),st=Math.max(Y,de);let Mt,dt;const Uo=B>D.containerSize-V.start-V.end;switch(u){case"cover":Mt=H,dt=X;break;case"contain":Mt=Te,dt=st;break;case"entry":Mt=H,dt=Te;break;case"exit":Mt=st,dt=X;break;case"entry-crossing":Mt=H,dt=Uo?st:Te;break;case"exit-crossing":Mt=Uo?Te:st,dt=X}return{start:Mt,end:dt}}function Mo(u,f){if(u instanceof bn){const{rangeName:y,offset:S}=f;return Co(Gn(u,y),S,Gn(u,"cover"),u.subject)}if(u instanceof Qe){const{axis:y,source:S}=u,{sourceMeasurements:w}=Dt.get(S);let k;return k=Ve(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,Hr(f,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(u)}function Co(u,f,y,S){if(!u||!y)return 0;let w=getComputedStyle(S);return(Hr(f,{percentageReference:CSS.px(u.end-u.start),fontSize:CSS.px(parseFloat(w.fontSize))})+u.start-y.start)/(y.end-y.start)}let bn=class extends Qe{constructor(f){super(f);const y=je.get(this);y.subject=f&&f.subject?f.subject:void 0,f&&f.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let w;if(w=typeof S=="string"?Je(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],w.length===0||w.length>2)throw TypeError("Invalid inset");for(const k of w){if(k==="auto")continue;const B=k.type();if(B.length!==1&&B.percent!==1)throw TypeError("Invalid inset")}return{start:w[0],end:w[1]??w[0]}})(f.inset)),y.subject&&(new ResizeObserver((()=>{$i(y.source)})).observe(y.subject),new MutationObserver((()=>{$i(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),qr(this),y.subjectMeasurements=Yr(y.source,y.subject),on(this)}get source(){return qr(this),je.get(this).source}set source(f){throw new Error("Cannot set the source of a view timeline")}get subject(){return je.get(this).subject}get axis(){return je.get(this).axis}get currentTime(){const y=xo(this.source,this.axis);if(y==null)return null;const S=Gn(this,"cover");if(!S)return null;const w=(y-S.start)/(S.end-S.start);return CSS.percent(100*w)}get startOffset(){return CSS.px(Gn(this,"cover").start)}get endOffset(){return CSS.px(Gn(this,"cover").end)}};const tl=document.getAnimations,nl=window.Element.prototype.getAnimations,il=window.Element.prototype.animate,wo=window.Animation;class Tn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((f,y)=>{this.nativeResolve=f,this.nativeReject=y}))}resolve(f){this.state="resolved",this.nativeResolve(f)}reject(f){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(f)}}function Wn(u){u.readyPromise=new Tn,requestAnimationFrame((()=>{var f;(((f=u.timeline)==null?void 0:f.currentTime)??null)!==null&&(Hi(u),u.pendingTask!=="play"||u.startTime===null&&u.holdTime===null?u.pendingTask==="pause"&&ko(u):Eo(u))}))}function Po(){return new DOMException("The user aborted a request","AbortError")}function an(u,f){if(f===null)return f;if(typeof f!="number")throw new DOMException(`Unexpected value: ${f}. Cannot convert to CssNumberish`,"InvalidStateError");const y=u.rangeDuration??100,S=Ft(u),w=S?y*f/S:0;return CSS.percent(w)}function ve(u,f){if(u.timeline){if(f===null)return f;if(f.unit==="percent"){const y=u.rangeDuration??100,S=Ft(u);return f.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(f==null||typeof f=="number")return f;const y=f.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Eo(u){const f=ve(u,u.timeline.currentTime);if(u.holdTime!=null)kt(u),u.animation.playbackRate==0?u.startTime=f:(u.startTime=f-u.holdTime/u.animation.playbackRate,u.holdTime=null);else if(u.startTime!==null&&u.pendingPlaybackRate!==null){const y=(f-u.startTime)*u.animation.playbackRate;kt(u);const S=u.animation.playbackRate;S==0?(u.holdTime=null,u.startTime=f):u.startTime=f-y/S}u.readyPromise&&u.readyPromise.state=="pending"&&u.readyPromise.resolve(u.proxy),Lt(u,!1,!1),Vt(u),u.pendingTask=null}function ko(u){const f=ve(u,u.timeline.currentTime);u.startTime!=null&&u.holdTime==null&&(u.holdTime=(f-u.startTime)*u.animation.playbackRate),kt(u),u.startTime=null,u.readyPromise.resolve(u.proxy),Lt(u,!1,!1),Vt(u),u.pendingTask=null}function Ro(u){if(!u.finishedPromise||u.finishedPromise.state!="pending"||u.proxy.playState!="finished")return;u.finishedPromise.resolve(u.proxy),u.animation.pause();const f=new CustomEvent("finish",{detail:{currentTime:u.proxy.currentTime,timelineTime:u.proxy.timeline.currentTime}});Object.defineProperty(f,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(f,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{u.animation.dispatchEvent(f)}))}))}function Mn(u){return u.pendingPlaybackRate!==null?u.pendingPlaybackRate:u.animation.playbackRate}function kt(u){u.pendingPlaybackRate!==null&&(u.animation.playbackRate=u.pendingPlaybackRate,u.pendingPlaybackRate=null)}function Ao(u){if(!u.timeline)return null;const f=ve(u,u.timeline.currentTime);if(f===null||u.startTime===null)return null;let y=(f-u.startTime)*u.animation.playbackRate;return y==-0&&(y=0),y}function Lt(u,f,y){if(!u.timeline)return;let S=f?ve(u,u.proxy.currentTime):Ao(u);if(S&&u.startTime!=null&&!u.proxy.pending){const w=Mn(u),k=Ft(u);let B=u.previousCurrentTime;w>0&&S>=k&&u.previousCurrentTime!=null?((B===null||B<k)&&(B=k),u.holdTime=f?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),u.holdTime=f?S:B):w!=0&&(f&&u.holdTime!==null&&(u.startTime=(function(L,D){if(!L.timeline)return null;const V=ve(L,L.timeline.currentTime);return V==null?null:V-D/L.animation.playbackRate})(u,u.holdTime)),u.holdTime=null)}Vt(u),u.previousCurrentTime=ve(u,u.proxy.currentTime),u.proxy.playState=="finished"?(u.finishedPromise||(u.finishedPromise=new Tn),u.finishedPromise.state=="pending"&&(y?Ro(u):Promise.resolve().then((()=>{Ro(u)})))):(u.finishedPromise&&u.finishedPromise.state=="resolved"&&(u.finishedPromise=new Tn),u.animation.playState!="paused"&&u.animation.pause())}function Ft(u){const f=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(u),y=f.delay+f.endDelay+f.iterations*f.duration;return Math.max(0,y)}function Vt(u){if(u.timeline)if(u.startTime!==null){const f=u.timeline.currentTime;if(f==null)return;ns(u,(ve(u,f)-u.startTime)*u.animation.playbackRate)}else u.holdTime!==null&&ns(u,u.holdTime)}function ns(u,f){const y=u.timeline,S=u.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;u.animation.currentTime=f+w}function is(u,f){if(!u.timeline)return;const y=u.proxy.playState=="paused"&&u.proxy.pending;let S=!1,w=ve(u,u.proxy.currentTime);Mn(u)==0&&w==null&&(u.holdTime=0),w==null&&(u.autoAlignStartTime=!0),(u.proxy.playState==="finished"||y)&&(u.holdTime=null,u.startTime=null,u.autoAlignStartTime=!0),u.holdTime&&(u.startTime=null),u.pendingTask&&(u.pendingTask=null,S=!0),(u.holdTime!==null||u.autoAlignStartTime||y||u.pendingPlaybackRate!==null)&&(u.readyPromise&&!S&&(u.readyPromise=null),Vt(u),u.readyPromise||Wn(u),u.pendingTask="play",Kr(u.timeline,u.animation,rs.bind(u.proxy)),Lt(u,!1,!1))}function rs(u){const f=q.get(this);if(!f)return;if(u==null)return void(f.proxy.playState!=="paused"&&f.animation.playState!="idle"&&f.animation.cancel());Hi(f),f.pendingTask&&requestAnimationFrame((()=>{f.pendingTask!=="play"||f.startTime===null&&f.holdTime===null?f.pendingTask==="pause"&&ko(f):Eo(f)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(f,u);ns(f,(S-ve(f,this.startTime))*this.playbackRate),Lt(f,!1,!1)}}function Oo(u){u.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(u=>{q=new WeakMap}),!1);let zo=new WeakMap;function Hi(u){if(!u.autoAlignStartTime||!u.timeline||!u.timeline.currentTime||u.proxy.playState==="idle"||u.proxy.playState==="paused"&&u.holdTime!==null)return;const f=u.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Io(k.timeline):k.animationRange.start;return Mo(k.timeline,B)})(u))}catch(k){y=CSS.percent(0),u.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const B=k.animationRange.end==="normal"?Bo(k.timeline):k.animationRange.end;return 1-Mo(k.timeline,B)})(u)))}catch(k){S=CSS.percent(100),u.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}u.rangeDuration=S.value-y.value;const w=Mn(u);u.startTime=ve(u,w>=0?y:S),u.holdTime=null,u.rangeDuration!==f&&Oo(u)}function qi(u){throw new Error("Unsupported timeline class")}function Io(u){return u instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:u instanceof Qe?CSS.percent(0):void qi()}function Bo(u){return u instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:u instanceof Qe?CSS.percent(100):void qi()}function rl(u,f){if(!f)return{start:"normal",end:"normal"};const y={start:Io(u),end:Bo(u)};if(u instanceof ViewTimeline){const S=Je(f),w=[],k=[];if(S.forEach((B=>{if(Wi.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${f}"`)}})),w.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return w.length&&(y.start.rangeName=w[0],y.end.rangeName=w.length>1?w[1]:w[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(u instanceof Qe){const S=f.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}qi()}function Xi(u,f,y){if(!f||f==="normal")return"normal";if(u instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(f instanceof Object)f.rangeName!==void 0&&(S=f.rangeName),f.offset!==void 0&&(w=f.offset);else{const k=Je(f);k.length===1?Wi.includes(k[0])?S=k[0]:w=ye(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],w=ye(CSSNumericValue.parse(k[1]),{}))}if(!Wi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(u instanceof Qe)return CSSNumericValue.parse(f);qi()}class Yi{constructor(f,y,S={}){const w=y instanceof Qe,k=f instanceof wo?f:new wo(f,w?void 0:y);zo.set(k,this),q.set(this,{animation:k,timeline:w?y:void 0,playState:w?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:w?rl(y,S["animation-range"]):null,proxy:this})}get effect(){const f=q.get(this);return f.timeline?(f.effect||(f.effect=(function(y){const S=y.animation.effect,w=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=an(y,H.localTime),H.endTime=an(y,H.endTime),H.activeDuration=an(y,H.activeDuration);const Y=Ft(y),de=H.iterations?(Y-H.delay-H.endDelay)/H.iterations:0;H.duration=Y?CSS.percent(X*de/Y):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},B={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Y=Object.assign({},y.specifiedTiming);if(Y.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Y.duration===null||Y.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Y.delay=0,Y.endDelay=0,X=Y.iterations?1e5:0,Y.duration=Y.iterations?(X-Y.delay-Y.endDelay)/Y.iterations:0,Y.duration<0&&(Y.duration=0,Y.endDelay=X-Y.delay),w.apply(S,[Y])),y.normalizedTiming=Y,y.specifiedTiming}},L={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Y=X[0],de=Y.duration;if(de===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Y.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");de!==void 0&&de!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),Oo(y)}}},D=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return D.getComputedTiming=new Proxy(S.getComputedTiming,k),D.getTiming=new Proxy(S.getTiming,B),D.updateTiming=new Proxy(S.updateTiming,L),D})(f)),f.effect):f.animation.effect}set effect(f){const y=q.get(this);y.animation.effect=f,y.effect=null,y.autoDurationEffect=null}get timeline(){const f=q.get(this);return f.timeline||f.animation.timeline}set timeline(f){const y=q.get(this),S=this.timeline;if(S==f)return;const w=this.playState,k=this.currentTime;let B,L=Ft(y);B=k===null?null:L===0?0:ve(y,k)/L;const D=S instanceof Qe,V=f instanceof Qe,H=this.pending;if(D&&Zr(y.timeline,y.animation),V)return y.timeline=f,kt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Wn(y),y.pendingTask="play",Kr(y.timeline,y.animation,rs.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*L),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||Wn(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Lt(y,!1,!1);if(y.animation.timeline!=f)throw TypeError("Unsupported timeline: "+f);if(Zr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Ft(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const f=q.get(this);return f.timeline?an(f,f.startTime):f.animation.startTime}set startTime(f){const y=q.get(this);if(f=ve(y,f),!y.timeline)return void(y.animation.startTime=f);y.autoAlignStartTime=!1,ve(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Vt(y));const S=ve(y,this.currentTime);kt(y),y.startTime=f,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1),Vt(y)}get currentTime(){const f=q.get(this);return f.timeline?f.holdTime!=null?an(f,f.holdTime):an(f,Ao(f)):f.animation.currentTime}set currentTime(f){const y=q.get(this);y.timeline?((function(S,w){if(w==null&&S.currentTime!==null)throw new TypeError;w=ve(S,w),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=w:S.startTime=ve(S,S.timeline.currentTime)-w/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,f),y.pendingTask=="pause"&&(y.holdTime=ve(y,f),kt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1)):y.animation.currentTime=f}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(f){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=f);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=f,S!==null&&(this.currentTime=S)}get playState(){const f=q.get(this);if(!f.timeline)return f.animation.playState;const y=ve(f,this.currentTime);return y===null&&f.startTime===null&&f.pendingTask==null?"idle":f.pendingTask=="pause"||f.startTime===null&&f.pendingTask!="play"?"paused":y!=null&&(f.animation.playbackRate>0&&y>=Ft(f)||f.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var f;return((f=q.get(this).animationRange)==null?void 0:f.start)??"normal"}set rangeStart(f){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=f;y.timeline instanceof Qe&&(y.animationRange.start=Xi(y.timeline,f,"start"),Hi(y),Vt(y))}get rangeEnd(){var f;return((f=q.get(this).animationRange)==null?void 0:f.end)??"normal"}set rangeEnd(f){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=f;y.timeline instanceof Qe&&(y.animationRange.end=Xi(y.timeline,f,"end"),Hi(y),Vt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const f=q.get(this);return f.timeline?!!f.readyPromise&&f.readyPromise.state=="pending":f.animation.pending}finish(){const f=q.get(this);if(!f.timeline)return void f.animation.finish();const y=Mn(f),S=Ft(f);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");kt(f);const w=y<0?0:S;this.currentTime=an(f,w);const k=ve(f,f.timeline.currentTime);f.startTime===null&&k!==null&&(f.startTime=k-w/f.animation.playbackRate),f.pendingTask=="pause"&&f.startTime!==null&&(f.holdTime=null,f.pendingTask=null,f.readyPromise.resolve(this)),f.pendingTask=="play"&&f.startTime!==null&&(f.pendingTask=null,f.readyPromise.resolve(this)),Lt(f,!0,!0)}play(){const f=q.get(this);f.timeline?is(f):f.animation.play()}pause(){const f=q.get(this);f.timeline?this.playState!="paused"&&(f.animation.currentTime===null&&(f.autoAlignStartTime=!0),f.pendingTask=="play"?f.pendingTask=null:f.readyPromise=null,f.readyPromise||Wn(f),f.pendingTask="pause",Kr(f.timeline,f.animation,rs.bind(f.proxy))):f.animation.pause()}reverse(){const f=q.get(this),y=Mn(f),S=ve(f,this.currentTime),w=Ft(f)==1/0,k=y!=0&&(y<0||S>0||!w);if(!f.timeline||!k)return k&&(f.pendingPlaybackRate=-Mn(f)),void f.animation.reverse();if(f.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),is(f)}updatePlaybackRate(f){const y=q.get(this);if(y.pendingPlaybackRate=f,!y.timeline)return void y.animation.updatePlaybackRate(f);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":kt(y);break;case"finished":const w=ve(y,y.timeline.currentTime),k=w!==null?(w-y.startTime)*y.animation.playbackRate:null;y.startTime=f==0?w:w!=null&&k!=null?(w-k)/f:null,kt(y),Lt(y,!1,!1),Vt(y);break;default:is(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(f){q.get(this).animation.id=f}cancel(){const f=q.get(this);f.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,kt(y),y.readyPromise.reject(Po()),Wn(y),y.readyPromise.resolve(y.proxy))})(f),f.finishedPromise&&f.finishedPromise.state=="pending"&&f.finishedPromise.reject(Po()),f.finishedPromise=new Tn,f.animation.cancel()),f.startTime=null,f.holdTime=null,Zr(f.timeline,f.animation)):f.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(f){q.get(this).animation.onfinish=f}get oncancel(){return q.get(this).animation.oncancel}set oncancel(f){q.get(this).animation.oncancel=f}get onremove(){return q.get(this).animation.onremove}set onremove(f){q.get(this).animation.onremove=f}get finished(){const f=q.get(this);return f.timeline?(f.finishedPromise||(f.finishedPromise=new Tn),f.finishedPromise.promise):f.animation.finished}get ready(){const f=q.get(this);return f.timeline?(f.readyPromise||(f.readyPromise=new Tn,f.readyPromise.resolve(this)),f.readyPromise.promise):f.animation.ready}addEventListener(f,y,S){q.get(this).animation.addEventListener(f,y,S)}removeEventListener(f,y,S){q.get(this).animation.removeEventListener(f,y,S)}dispatchEvent(f){q.get(this).animation.dispatchEvent(f)}}function sl(u,f){const y=f.timeline;y instanceof Qe&&delete f.timeline;const S=il.apply(this,[u,f]),w=new Yi(S,y);return y instanceof Qe&&(S.pause(),q.get(w).animationRange={start:Xi(y,f.rangeStart,"start"),end:Xi(y,f.rangeEnd,"end")},w.play()),w}function No(u){for(let f=0;f<u.length;++f){let y=zo.get(u[f]);y&&(u[f]=y)}return u}function ol(u){return No(nl.apply(this,[u]))}function al(u){return No(tl.apply(this,[u]))}const Ae={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Cn=["block","inline","x","y"],cl=["nearest","root","self"],Xt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(u,f,y){const S={sheetSrc:u,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const w=this.parseQualifiedRule(S);w&&(f?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(u,f){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(f.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==u))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(u,f){const y=this.anonymousScrollTimelineOptions.get(u);return y?{anonymousSource:y.source,anonymousTarget:f,source:bo(y.source??"nearest",f),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(u,f){const y=this.getAnonymousScrollTimelineOptions(u,f);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==u){const k=this.findPreviousSiblingOrAncestorMatchingSelector(f,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(u,f){let y=u;for(;y;){if(y.matches(f))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(u,f){const y=this.anonymousViewTimelineOptions.get(u);return y?{subject:f,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(u,f){const y=this.getAnonymousViewTimelineOptions(u,f);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==u){const k=this.findPreviousSiblingOrAncestorMatchingSelector(f,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(u,f){if(u.selector.includes("@keyframes"))return;const y=u.block.contents.includes("animation-name:"),S=u.block.contents.includes("animation-timeline:"),w=u.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(u),this.saveSubjectSelectorToViewTimeline(u),!S&&!y&&!w)return;let k=[],B=[],L=!1;S&&(k=this.extractScrollTimelineNames(u.block.contents)),y&&(B=this.extractMatches(u.block.contents,Ae.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(u.block.contents,Ae.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(u.block.contents=u.block.contents.replace("auto"," ")),u.block.contents=u.block.contents.replace(D," 1s "+D),L=!0))})),L&&this.replacePart(u.block.startIndex,u.block.endIndex,u.block.contents,f)),this.saveRelationInList(u,k,B)}saveSourceSelectorToScrollTimeline(u){const f=u.block.contents.includes("scroll-timeline:"),y=u.block.contents.includes("scroll-timeline-name:"),S=u.block.contents.includes("scroll-timeline-axis:");if(!f&&!y)return;let w=[];if(f){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE);for(const L of B){const D=this.split(L);let V={selector:u.selector,name:""};D.length==1?V.name=D[0]:D.length==2&&(Cn.includes(D[0])?(V.axis=D[0],V.name=D[1]):(V.axis=D[1],V.name=D[0])),w.push(V)}}if(y){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE_NAME);for(let L=0;L<B.length;L++)if(L<w.length)w[L].name=B[L];else{let D={selector:u.selector,name:B[L]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE_AXIS);if(k=B.filter((L=>Cn.includes(L))),k.length!=B.length)throw new Error("Invalid axis")}for(let B=0;B<w.length;B++)k.length&&(w[B].axis=k[B%w.length]);this.sourceSelectorToScrollTimeline.push(...w)}saveSubjectSelectorToViewTimeline(u){const f=u.block.contents.includes("view-timeline:"),y=u.block.contents.includes("view-timeline-name:"),S=u.block.contents.includes("view-timeline-axis:"),w=u.block.contents.includes("view-timeline-inset:");if(!f&&!y)return;let k=[];if(f){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let X={selector:u.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(Cn.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_NAME);for(let V=0;V<D.length;V++)if(V<k.length)k[V].name=D[V];else{let H={selector:u.selector,name:D[V],inset:null};k.push(H)}}let B=[],L=[];if(w&&(B=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_AXIS);if(L=D.filter((V=>Cn.includes(V))),L.length!=D.length)throw new Error("Invalid axis")}for(let D=0;D<k.length;D++)B.length&&(k[D].inset=B[D%k.length]),L.length&&(k[D].axis=L[D%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(u){return u.split(" ").filter((f=>{return y=f,Ae.TIME.exec(y);var y})).length>=1}hasAutoDuration(u){return u.split(" ").filter((f=>f==="auto")).length>=1}saveRelationInList(u,f,y){let S=[];u.block.contents.includes("animation-range:")&&(S=this.extractMatches(u.block.contents,Ae.ANIMATION_TIME_RANGE));const w=Math.max(f.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:u.selector,"animation-timeline":f[k%f.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(u){const f=Ae.ANIMATION_TIMELINE.exec(u)[1].trim(),y=[];return f.split(",").map((S=>S.trim())).forEach((S=>{if((function(w){return(w.startsWith("scroll")||w.startsWith("view"))&&w.includes("(")})(S)){const w=this.saveAnonymousTimelineName(S);y.push(w)}else y.push(S)})),y}saveAnonymousTimelineName(u){const f=":t"+this.nextAnonymousTimelineNameIndex++;return u.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(f,this.parseAnonymousScrollTimeline(u)):this.anonymousViewTimelineOptions.set(f,this.parseAnonymousViewTimeline(u)),f}parseAnonymousScrollTimeline(u){const f=Ae.ANONYMOUS_SCROLL_TIMELINE.exec(u);if(!f)return null;const y=f[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:cl.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(u){const f=Ae.ANONYMOUS_VIEW_TIMELINE.exec(u);if(!f)return null;const y=f[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(u){return this.findMatchingEntryInContainer(u,this.keyframeNamesSelectors)}findMatchingEntryInContainer(u,f){const y=u.split(" ").filter((S=>f.has(S)));return y?y[0]:null}parseIdentifier(u){Ae.IDENTIFIER.lastIndex=u.index;const f=Ae.IDENTIFIER.exec(u.sheetSrc);if(!f)throw this.parseError(u,"Expected an identifier");return u.index+=f[0].length,f[0]}parseKeyframesAndSaveNameMapping(u,f){if(u.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(u,f);u.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(u,f){function y(D){return Wi.some((V=>D.startsWith(V)))}const S=u.block.contents,w=(function(D){let V=0,H=-1,X=-1;const Y=[];for(let de=0;de<D.length;de++)D[de]=="{"?V++:D[de]=="}"&&V--,V==1&&D[de]!="{"&&D[de]!="}"&&H==-1&&(H=de),V==2&&D[de]=="{"&&(X=de,Y.push({start:H,end:X}),H=X=-1);return Y})(S);if(w.length==0)return new Map;const k=new Map;let B=!1;const L=[];L.push(S.substring(0,w[0].start));for(let D=0;D<w.length;D++){const V=S.substring(w[D].start,w[D].end);let H=[];V.split(",").forEach((X=>{const Y=X.split(" ").map((Te=>Te.trim())).filter((Te=>Te!="")).join(" "),de=k.size;k.set(de,Y),H.push(`${de}%`),y(Y)&&(B=!0)})),L.push(H.join(",")),D==w.length-1?L.push(S.substring(w[D].end)):L.push(S.substring(w[D].end,w[D+1].start))}return B?(u.block.contents=L.join(""),this.replacePart(u.block.startIndex,u.block.endIndex,u.block.contents,f),k):new Map}parseQualifiedRule(u){const f=u.index,y=this.parseSelector(u).trim();if(y)return{selector:y,block:this.eatBlock(u),startIndex:f,endIndex:u.index}}removeEnclosingDoubleQuotes(u){let f=u[0]=='"'?1:0,y=u[u.length-1]=='"'?u.length-1:u.length;return u.substring(f,y)}assertString(u,f){if(u.sheetSrc.substr(u.index,f.length)!=f)throw this.parseError(u,`Did not find expected sequence ${f}`);u.index+=f.length}replacePart(u,f,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,u)+y+S.sheetSrc.slice(f),S.index>=f){const w=S.index-f;S.index=u+y.length+w}}eatComment(u){this.assertString(u,"/*"),this.eatUntil("*/",u,!0),this.assertString(u,"*/")}eatBlock(u){const f=u.index;this.assertString(u,"{");let y=1;for(;y!=0;)this.lookAhead("/*",u)?this.eatComment(u):(u.sheetSrc[u.index]==="{"?y++:u.sheetSrc[u.index]==="}"&&y--,this.advance(u));const S=u.index;return{startIndex:f,endIndex:S,contents:u.sheetSrc.slice(f,S)}}advance(u){if(u.index++,u.index>u.sheetSrc.length)throw this.parseError(u,"Advanced beyond the end")}parseError(u,f){return Error(`(${u.name?u.name:"<anonymous file>"}): ${f}`)}eatUntil(u,f,y=!1){const S=f.index;for(;!this.lookAhead(u,f);)this.advance(f);return y&&(f.sheetSrc=f.sheetSrc.slice(0,S)+" ".repeat(f.index-S)+f.sheetSrc.slice(f.index)),f.sheetSrc.slice(S,f.index)}parseSelector(u){let f=u.index;if(this.eatUntil("{",u),f===u.index)throw Error("Empty selector");return u.sheetSrc.slice(f,u.index)}eatWhitespace(u){Ae.WHITE_SPACE.lastIndex=u.index;const f=Ae.WHITE_SPACE.exec(u.sheetSrc);f&&(u.index+=f[0].length)}lookAhead(u,f){return f.sheetSrc.substr(f.index,u.length)==u}peek(u){return u.sheetSrc[u.index]}extractMatches(u,f,y=","){return f.exec(u)[1].trim().split(y).map((S=>S.trim()))}split(u){return u.split(" ").map((f=>f.trim())).filter((f=>f!=""))}};function ll(u,f,y,S,w,k){const B=Xr(f),L=Yr(f,y);return Co(ts(u,B,L,S,w),k,ts("cover",B,L,S,w),y)}function ul(u,f,y){const S=Xt.getAnimationTimelineOptions(f,y);if(!S)return null;const w=S["animation-timeline"];if(!w)return null;let k=Xt.getScrollTimelineOptions(w,y)||Xt.getViewTimelineOptions(w,y);return k?(k.subject&&(function(B,L){const D=es(L.subject),V=L.axis||L.axis;function H(Y,de){let Te=null;for(const[st,Mt]of Y)if(st==100*de.offset){if(Mt=="from")Te=0;else if(Mt=="to")Te=100;else{const dt=Mt.split(" ");Te=dt.length==1?parseFloat(dt[0]):100*ll(dt[0],D,L.subject,V,L.inset,CSS.percent(parseFloat(dt[1])))}break}return Te}const X=Xt.keyframeNamesSelectors.get(B.animationName);if(X&&X.size){const Y=[];B.effect.getKeyframes().forEach((Te=>{const st=H(X,Te);st!==null&&st>=0&&st<=100&&(Te.offset=st/100,Y.push(Te))}));const de=Y.sort(((Te,st)=>Te.offset<st.offset?-1:Te.affset>st.offset?1:0));B.effect.setKeyframes(de)}})(u,k),{timeline:k.source?new Qe(k):new bn(k),animOptions:S}):null}function hl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function f(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let w=Xt.transpileStyleSheet(S.innerHTML,!0);w=Xt.transpileStyleSheet(w,!1),S.innerHTML=w}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async w=>{const k=await w.text();let B=Xt.transpileStyleSheet(k,!0);if(B=Xt.transpileStyleSheet(k,!1),B!=k){const L=new Blob([B],{type:"text/css"}),D=URL.createObjectURL(L);S.setAttribute("href",D)}}))}new MutationObserver((S=>{for(const w of S)for(const k of w.addedNodes)k instanceof HTMLStyleElement&&f(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>f(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const u=CSS.supports;CSS.supports=f=>(f=f.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),u(f)),window.addEventListener("animationstart",(f=>{f.target.getAnimations().filter((y=>y.animationName===f.animationName)).forEach((y=>{const S=ul(y,y.animationName,f.target);if(S)if(!S.timeline||y instanceof Yi)y.timeline=S.timeline;else{const w=new Yi(y,S.timeline,S.animOptions);y.pause(),w.play()}}))}))}(function(){if(!hl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:Qe}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:bn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:sl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Yi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:ol}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:al}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const Vf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Jf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BatchedParticleRenderer=Vu;exports.Builder=no;exports.ByteBuffer=li;exports.ConstantColor=vn;exports.ConstantValue=ee;exports.Matrix4=Et;exports.MeshBVH=Vn;exports.MotionController=Ol;exports.ParticleSystem=Ur;exports.SIZE_PREFIX_LENGTH=Ga;exports.TrailParticle=Br;exports.Vector4=at;exports.WorkerBase=zf;exports.__viteBrowserExternal=Jf;exports.bundler=Th;exports.createNoise4D=ju;exports.fetchProfile=Pl;exports.index=wh;exports.index$1=Of;exports.index$2=Df;exports.scrollTimeline=Vf;exports.v5=Cl;
|
|
1116
|
+
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),la={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},sh=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=la,this.browser=Hn.getBrowser(),this.browserVersion=Hn.getVersion(),this.supports=(function(){var e={browser:Hn.isBrowserSupported(),webRTC:Hn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(la),e.audioVideo=!0;var n=void 0;try{n=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!n.ordered;try{n.binaryType="blob",e.binaryBlob=!Hn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=Ko.pack,this.unpack=Ko.unpack,this._dataCount=1}return r.prototype.noop=function(){},r.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},r.prototype.chunk=function(e){for(var t=[],n=e.size,i=Math.ceil(n/te.chunkedMTU),s=0,a=0;a<n;){var o=Math.min(n,a+te.chunkedMTU),c=e.slice(a,o),l={__peerData:this._dataCount,n:s,data:c,total:i};t.push(l),a=o,s++}return this._dataCount++,t},r.prototype.blobToArrayBuffer=function(e,t){var n=new FileReader;return n.onload=function(i){i.target&&t(i.target.result)},n.readAsArrayBuffer(e),n},r.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer},r.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},r.prototype.isSecure=function(){return location.protocol==="https:"},r})(),te=new sh,Bc={};Bt(Bc,"Peer",()=>Gs,r=>Gs=r);var Gi={},oh=Object.prototype.hasOwnProperty,nt="~";function Ji(){}Object.create&&(Ji.prototype=Object.create(null),new Ji().__proto__||(nt=!1));function ah(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Nc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new ah(t,n||r,i),a=nt?nt+e:e;return r._events[a]?r._events[a].fn?r._events[a]=[r._events[a],s]:r._events[a].push(s):(r._events[a]=s,r._eventsCount++),r}function Er(r,e){--r._eventsCount===0?r._events=new Ji:delete r._events[e]}function He(){this._events=new Ji,this._eventsCount=0}He.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)oh.call(t,n)&&e.push(nt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};He.prototype.listeners=function(e){var t=nt?nt+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a};He.prototype.listenerCount=function(e){var t=nt?nt+e:e,n=this._events[t];return n?n.fn?1:n.length:0};He.prototype.emit=function(e,t,n,i,s,a){var o=nt?nt+e:e;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,h,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,a),!0}for(d=1,h=new Array(l-1);d<l;d++)h[d-1]=arguments[d];c.fn.apply(c.context,h)}else{var m=c.length,p;for(d=0;d<m;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!h)for(p=1,h=new Array(l-1);p<l;p++)h[p-1]=arguments[p];c[d].fn.apply(c[d].context,h)}}return!0};He.prototype.on=function(e,t,n){return Nc(this,e,t,n,!1)};He.prototype.once=function(e,t,n){return Nc(this,e,t,n,!0)};He.prototype.removeListener=function(e,t,n,i){var s=nt?nt+e:e;if(!this._events[s])return this;if(!t)return Er(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&Er(this,s);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==t||i&&!a[o].once||n&&a[o].context!==n)&&c.push(a[o]);c.length?this._events[s]=c.length===1?c[0]:c:Er(this,s)}return this};He.prototype.removeAllListeners=function(e){var t;return e?(t=nt?nt+e:e,this._events[t]&&Er(this,t)):(this._events=new Ji,this._eventsCount=0),this};He.prototype.off=He.prototype.removeListener;He.prototype.addListener=He.prototype.on;He.prefixed=nt;He.EventEmitter=He;Gi=He;var j={};Bt(j,"LogLevel",()=>ot,r=>ot=r);Bt(j,"default",()=>ua,r=>ua=r);var cn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},ln=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},ch="PeerJS: ",ot;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(ot||(ot={}));var lh=(function(){function r(){this._logLevel=ot.Disabled}return Object.defineProperty(r.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),r.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.All&&this._print.apply(this,ln([ot.All],cn(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.Warnings&&this._print.apply(this,ln([ot.Warnings],cn(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=ot.Errors&&this._print.apply(this,ln([ot.Errors],cn(e),!1))},r.prototype.setLogFunction=function(e){this._print=e},r.prototype._print=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=ln([ch],cn(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=ot.All?console.log.apply(console,ln([],cn(i),!1)):e>=ot.Warnings?console.warn.apply(console,ln(["WARNING"],cn(i),!1)):e>=ot.Errors&&console.error.apply(console,ln(["ERROR"],cn(i),!1))},r})(),ua=new lh,Uc={};Bt(Uc,"Socket",()=>ha,r=>ha=r);var Pt;(function(r){r.Data="data",r.Media="media"})(Pt||(Pt={}));var _e;(function(r){r.BrowserIncompatible="browser-incompatible",r.Disconnected="disconnected",r.InvalidID="invalid-id",r.InvalidKey="invalid-key",r.Network="network",r.PeerUnavailable="peer-unavailable",r.SslUnavailable="ssl-unavailable",r.ServerError="server-error",r.SocketError="socket-error",r.SocketClosed="socket-closed",r.UnavailableID="unavailable-id",r.WebRTC="webrtc"})(_e||(_e={}));var jt;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(jt||(jt={}));var $t;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})($t||($t={}));var Fe;(function(r){r.Heartbeat="HEARTBEAT",r.Candidate="CANDIDATE",r.Offer="OFFER",r.Answer="ANSWER",r.Open="OPEN",r.Error="ERROR",r.IdTaken="ID-TAKEN",r.InvalidKey="INVALID-KEY",r.Leave="LEAVE",r.Expire="EXPIRE"})(Fe||(Fe={}));var lo={};lo=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz Stückler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","Sören Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var uh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),hh=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},fh=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},dh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ha=(function(r){uh(e,r);function e(t,n,i,s,a,o){o===void 0&&(o=5e3);var c=r.call(this)||this;c.pingInterval=o,c._disconnected=!0,c._messagesQueue=[];var l=t?"wss://":"ws://";return c._baseUrl=l+n+":"+i+s+"peerjs?key="+a,c}return e.prototype.start=function(t,n){var i=this;this._id=t;var s="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(n);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+lo.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),j.default.log("Server message received:",o)}catch{j.default.log("Invalid server message",a.data);return}i.emit($t.Message,o)},this._socket.onclose=function(a){i._disconnected||(j.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit($t.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),j.default.log("Socket open"),i._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){j.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Fe.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,n,i=fh([],hh(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=dh(i),a=s.next();!a.done;a=s.next()){var o=a.value;this.send(o)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit($t.Error,"Invalid message");return}if(this._wsOpen()){var n=JSON.stringify(t);this._socket.send(n)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e})(Gi.EventEmitter),Js={};Bt(Js,"MediaConnection",()=>pa,r=>pa=r);var uo={};Bt(uo,"Negotiator",()=>fa,r=>fa=r);var Dr=function(){return Dr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},Dr.apply(this,arguments)},sr=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{l(n.next(h))}catch(d){a(d)}}function c(h){try{l(n.throw(h))}catch(d){a(d)}}function l(h){h.done?s(h.value):i(h.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},or=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(h){l=[6,h],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},fa=(function(){function r(e){this.connection=e}return r.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===Pt.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Pt.Data){var n=this.connection,i={ordered:!!e.reliable},s=t.createDataChannel(n.label,i);n.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},r.prototype._startPeerConnection=function(){j.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},r.prototype._setupListeners=function(e){var t=this,n=this.connection.peer,i=this.connection.connectionId,s=this.connection.type,a=this.connection.provider;j.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||(j.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Fe.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":j.default.log("iceConnectionState is failed, closing connections to "+n),t.connection.emit("error",new Error("Negotiation of connection to "+n+" failed.")),t.connection.close();break;case"closed":j.default.log("iceConnectionState is closed, closing connections to "+n),t.connection.emit("error",new Error("Connection to "+n+" closed.")),t.connection.close();break;case"disconnected":j.default.log("iceConnectionState changed to disconnected on the connection with "+n);break;case"completed":e.onicecandidate=te.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},j.default.log("Listening for data channel"),e.ondatachannel=function(o){j.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},j.default.log("Listening for remote stream"),e.ontrack=function(o){j.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Pt.Media){var h=l;t._addStreamToMediaConnection(c,h)}}},r.prototype.cleanup=function(){j.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",n=!1;if(this.connection.type===Pt.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return sr(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return or(this,function(c){switch(c.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:n=c.sent(),j.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return c.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),i={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:te.browser},this.connection.type===Pt.Data&&(s=this.connection,i=Dr(Dr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Fe.Offer,payload:i,dst:this.connection.peer}),[3,6];case 5:return a=c.sent(),a!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(_e.WebRTC,a),j.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(_e.WebRTC,o),j.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return sr(this,void 0,Promise,function(){var e,t,n,i,s;return or(this,function(a){switch(a.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:n=a.sent(),j.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return a.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Fe.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,browser:te.browser},dst:this.connection.peer}),[3,6];case 5:return i=a.sent(),t.emitError(_e.WebRTC,i),j.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(_e.WebRTC,s),j.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return sr(this,void 0,Promise,function(){var n,i,s,a;return or(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,j.default.log("Setting remote description",t),s=this,o.label=1;case 1:return o.trys.push([1,5,,6]),[4,n.setRemoteDescription(t)];case 2:return o.sent(),j.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:return a=o.sent(),i.emitError(_e.WebRTC,a),j.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return sr(this,void 0,Promise,function(){var t,n,i,s,a,o;return or(this,function(c){switch(c.label){case 0:j.default.log("handleCandidate:",e),t=e.candidate,n=e.sdpMLineIndex,i=e.sdpMid,s=this.connection.peerConnection,a=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:i,sdpMLineIndex:n,candidate:t}))];case 2:return c.sent(),j.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(_e.WebRTC,o),j.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if(j.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return j.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype._addStreamToMediaConnection=function(e,t){j.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r})(),ho={};Bt(ho,"BaseConnection",()=>da,r=>da=r);var ph=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),da=(function(r){ph(e,r);function e(t,n,i){var s=r.call(this)||this;return s.peer=t,s.provider=n,s.options=i,s._open=!1,s.metadata=i.metadata,s}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e})(Gi.EventEmitter),mh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Lr=function(){return Lr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},Lr.apply(this,arguments)},yh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},pa=(function(r){mh(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s._negotiator=new uo.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Pt.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){j.default.log("Receiving stream",t),this._remoteStream=t,r.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var n=t.type,i=t.payload;switch(t.type){case Fe.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Fe.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:j.default.warn("Unrecognized message type:".concat(n," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,n){var i,s;if(n===void 0&&(n={}),this._localStream){j.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,n&&n.sdpTransform&&(this.options.sdpTransform=n.sdpTransform),this._negotiator.startConnection(Lr(Lr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=yh(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(h){i={error:h}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e})(ho.BaseConnection),js={};Bt(js,"DataConnection",()=>ya,r=>ya=r);var Dc={};Bt(Dc,"EncodingQueue",()=>ma,r=>ma=r);var gh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),ma=(function(r){gh(e,r);function e(){var t=r.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(n){t._processing=!1,n.target&&t.emit("done",n.target.result),t.doNextTask()},t.fileReader.onerror=function(n){j.default.error("EncodingQueue error:",n),t._processing=!1,t.destroy(),t.emit("error",n)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e})(Gi.EventEmitter),vh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Sh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ya=(function(r){vh(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new Dc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||jt.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){j.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new uo.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Pt.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!te.supports.binaryBlob||te.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){j.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){j.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){j.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var n=this,i=t.data,s=i.constructor,a=this.serialization===jt.Binary||this.serialization===jt.BinaryUTF8,o=i;if(a){if(s===Blob){te.blobToArrayBuffer(i,function(l){var h=te.unpack(l);n.emit("data",h)});return}else if(s===ArrayBuffer)o=te.unpack(i);else if(s===String){var c=te.binaryStringToArrayBuffer(i);o=te.unpack(c)}}else this.serialization===jt.JSON&&(o=this.parse(i));if(o.__peerData){this._handleChunk(o);return}r.prototype.emit.call(this,"data",o)},e.prototype._handleChunk=function(t){var n=t.__peerData,i=this._chunkedData[n]||{data:[],count:0,total:t.total};if(i.data[t.n]=t.data,i.count++,this._chunkedData[n]=i,i.total===i.count){delete this._chunkedData[n];var s=new Blob(i.data);this._handleDataMessage({data:s})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.prototype.send=function(t,n){if(!this.open){r.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===jt.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===jt.Binary||this.serialization===jt.BinaryUTF8){var i=te.pack(t);if(!n&&i.size>te.chunkedMTU){this._sendChunks(i);return}te.supports.binaryBlob?this._bufferedSend(i):this._encodingQueue.enque(i)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var n=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){n._buffering=!1,n._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(i){return j.default.error("DC#:".concat(this.connectionId," Error when sending:"),i),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var n,i,s=te.chunk(t);j.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Sh(s),o=a.next();!o.done;o=a.next()){var c=o.value;this.send(c,!0)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.handleMessage=function(t){var n=t.payload;switch(t.type){case Fe.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Fe.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:j.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e})(ho.BaseConnection),Lc={};Bt(Lc,"API",()=>Sa,r=>Sa=r);var ga=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{l(n.next(h))}catch(d){a(d)}}function c(h){try{l(n.throw(h))}catch(d){a(d)}}function l(h){h.done?s(h.value):i(h.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},va=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(h){l=[6,h],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Sa=(function(){function r(e){this._options=e}return r.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",n=this._options,i=n.host,s=n.port,a=n.path,o=n.key,c=new URL("".concat(t,"://").concat(i,":").concat(s).concat(a).concat(o,"/").concat(e));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",lo.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return ga(this,void 0,Promise,function(){var e,t,n;return va(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=i.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=i.sent(),j.default.error("Error retrieving ID",t),n="",this._options.path==="/"&&this._options.host!==te.CLOUD_HOST&&(n=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+n);case 3:return[2]}})})},r.prototype.listAllPeers=function(){return ga(this,void 0,Promise,function(){var e,t,n;return va(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=i.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===te.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw n=i.sent(),j.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r})(),xh=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),ai=function(){return ai=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},ai.apply(this,arguments)},qn=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},_h=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Gs=(function(r){xh(e,r);function e(t,n){var i=r.call(this)||this;i._id=null,i._lastServerId=null,i._destroyed=!1,i._disconnected=!1,i._open=!1,i._connections=new Map,i._lostMessages=new Map;var s;return t&&t.constructor==Object?n=t:t&&(s=t.toString()),n=ai({debug:0,host:te.CLOUD_HOST,port:te.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:te.randomToken(),config:te.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},n),i._options=n,i._options.host==="/"&&(i._options.host=window.location.hostname),i._options.path&&(i._options.path[0]!=="/"&&(i._options.path="/"+i._options.path),i._options.path[i._options.path.length-1]!=="/"&&(i._options.path+="/")),i._options.secure===void 0&&i._options.host!==te.CLOUD_HOST?i._options.secure=te.isSecure():i._options.host==te.CLOUD_HOST&&(i._options.secure=!0),i._options.logFunction&&j.default.setLogFunction(i._options.logFunction),j.default.logLevel=i._options.debug||0,i._api=new Lc.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(_e.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(_e.InvalidID,'ID "'.concat(s,'" is invalid')),i):(s?i._initialize(s):i._api.retrieveId().then(function(a){return i._initialize(a)}).catch(function(a){return i._abort(_e.ServerError,a)}),i)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,n,i=Object.create(null);try{for(var s=qn(this._connections),a=s.next();!a.done;a=s.next()){var o=_h(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(h){t={error:h}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,n=new Uc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on($t.Message,function(i){t._handleMessage(i)}),n.on($t.Error,function(i){t._abort(_e.SocketError,i)}),n.on($t.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on($t.Close,function(){t.disconnected||t._abort(_e.SocketClosed,"Underlying socket is already closed.")}),n},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var n,i,s=t.type,a=t.payload,o=t.src;switch(s){case Fe.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Fe.Error:this._abort(_e.ServerError,a.msg);break;case Fe.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Fe.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Fe.Leave:j.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Fe.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Fe.Offer:var b=a.connectionId,T=this.getConnection(o,b);if(T&&(T.close(),j.default.warn("Offer received for existing Connection ID:".concat(b))),a.type===Pt.Media){var c=new Js.MediaConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata});T=c,this._addConnection(o,T),this.emit("call",c)}else if(a.type===Pt.Data){var l=new js.DataConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});T=l,this._addConnection(o,T),this.emit("connection",l)}else{j.default.warn("Received malformed connection type:".concat(a.type));return}var h=this._getMessages(b);try{for(var d=qn(h),m=d.next();!m.done;m=d.next()){var p=m.value;T.handleMessage(p)}}catch(g){n={error:g}}finally{try{m&&!m.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}break;default:if(!a){j.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var b=a.connectionId,T=this.getConnection(o,b);T&&T.peerConnection?T.handleMessage(t):b?this._storeMessage(b,t):j.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,n){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(n)},e.prototype._getMessages=function(t){var n=this._lostMessages.get(t);return n?(this._lostMessages.delete(t),n):[]},e.prototype.connect=function(t,n){if(n===void 0&&(n={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new js.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){j.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Js.MediaConnection(t,this,ai(ai({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){j.default.log("add connection ".concat(n.type,":").concat(n.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(n)},e.prototype._removeConnection=function(t){var n=this._connections.get(t.peer);if(n){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,n){var i,s,a=this._connections.get(t);if(!a)return null;try{for(var o=qn(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(h){i={error:h}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}return null},e.prototype._delayedAbort=function(t,n){var i=this;setTimeout(function(){i._abort(t,n)},0)},e.prototype._abort=function(t,n){j.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){j.default.error("Error:",n);var i;typeof n=="string"?i=new Error(n):i=n,i.type=t,this.emit("error",i)},e.prototype.destroy=function(){this.destroyed||(j.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,n;try{for(var i=qn(this._connections.keys()),s=i.next();!s.done;s=i.next()){var a=s.value;this._cleanupPeer(a),this._connections.delete(a)}}catch(o){t={error:o}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var n,i,s=this._connections.get(t);if(s)try{for(var a=qn(s),o=a.next();!o.done;o=a.next()){var c=o.value;c.close()}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;j.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)j.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)j.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var n=this;t===void 0&&(t=function(i){}),this._api.listAllPeers().then(function(i){return t(i)}).catch(function(i){return n._abort(_e.ServerError,i)})},e.DEFAULT_KEY="peerjs",e})(Gi.EventEmitter),bh=Bc.Peer;const Th=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Gs},default:bh,util:te},Symbol.toStringTag,{value:"Module"}));class Mh{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class Fc{constructor(e,t,n){var i,s,a,o,c,l,h,d,m,p,b,T,g,v,x;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(ce.open,_),this.handleErrorEvent=_=>this.handleEvent(ce.error,_),this.handleCloseEvent=_=>this.handleEvent(ce.close,_),this.handleMessageEvent=_=>this.handleEvent(ce.message,_),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(m=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&m!==void 0?m:[]],message:[...(b=(p=n?.listeners)===null||p===void 0?void 0:p.message)!==null&&b!==void 0?b:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(x=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&x!==void 0?x:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(ce.retry,{detail:n});this.handleEvent(ce.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class Ch{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new Fc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,h,d,m,p,b,T,g,v,x,_,M,C,P,E,z;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(m=(d=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||d===void 0?void 0:d.error)!==null&&m!==void 0?m:[],message:(T=(b=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||b===void 0?void 0:b.message)!==null&&T!==void 0?T:[],retry:(x=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&x!==void 0?x:[],reconnect:(C=(M=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||M===void 0?void 0:M.reconnect)!==null&&C!==void 0?C:[],[e]:[...(z=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&z!==void 0?z:[],{listener:t,options:n}]}}),this}}const wh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Mh,Websocket:Fc,WebsocketBuilder:Ch,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),fo=0,Vc=1,Jc=2,Ws=2,_s=1.25,xa=1,We=32,Pe=We/4,jc=65535,kr=Math.pow(2,-24),Gr=Symbol("SKIP_GENERATION"),Gc={strategy:fo,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Gr]:!1};function Se(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function _a(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function ba(r,e){e.set(r)}function Ta(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function ar(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Xn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function Ee(r,e){return e[r+15]===jc}function $e(r,e){return e[r+6]}function tt(r,e){return e[r+14]}function Ie(r){return r+Pe}function Be(r,e){const t=e[r+6];return r+t*Pe}function po(r,e){return e[r+7]}function bs(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0,d=1/0,m=1/0,p=1/0,b=-1/0,T=-1/0,g=-1/0;const v=r.offset||0;for(let x=(e-v)*6,_=(e+t-v)*6;x<_;x+=6){const M=r[x+0],C=r[x+1],P=M-C,E=M+C;P<s&&(s=P),E>c&&(c=E),M<d&&(d=M),M>b&&(b=M);const z=r[x+2],I=r[x+3],R=z-I,N=z+I;R<a&&(a=R),N>l&&(l=N),z<m&&(m=z),z>T&&(T=z);const O=r[x+4],U=r[x+5],F=O-U,J=O+U;F<o&&(o=F),J>h&&(h=J),O<p&&(p=O),O>g&&(g=O)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,i[0]=d,i[1]=m,i[2]=p,i[3]=b,i[4]=T,i[5]=g}const Jt=32,Ph=(r,e)=>r.candidate-e.candidate,Kt=new Array(Jt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),cr=new Float32Array(6);function Eh(r,e,t,n,i,s){let a=-1,o=0;if(s===fo)a=_a(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Vc)a=_a(r),a!==-1&&(o=kh(t,n,i,a));else if(s===Jc){const c=Xn(r);let l=_s*i;const h=t.offset||0,d=(n-h)*6,m=(n+i-h)*6;for(let p=0;p<3;p++){const b=e[p],v=(e[p+3]-b)/Jt;if(i<Jt/4){const x=[...Kt];x.length=i;let _=0;for(let C=d;C<m;C+=6,_++){const P=x[_];P.candidate=t[C+2*p],P.count=0;const{bounds:E,leftCacheBounds:z,rightCacheBounds:I}=P;for(let R=0;R<3;R++)I[R]=1/0,I[R+3]=-1/0,z[R]=1/0,z[R+3]=-1/0,E[R]=1/0,E[R+3]=-1/0;ar(C,t,E)}x.sort(Ph);let M=i;for(let C=0;C<M;C++){const P=x[C];for(;C+1<M&&x[C+1].candidate===P.candidate;)x.splice(C+1,1),M--}for(let C=d;C<m;C+=6){const P=t[C+2*p];for(let E=0;E<M;E++){const z=x[E];P>=z.candidate?ar(C,t,z.rightCacheBounds):(ar(C,t,z.leftCacheBounds),z.count++)}}for(let C=0;C<M;C++){const P=x[C],E=P.count,z=i-P.count,I=P.leftCacheBounds,R=P.rightCacheBounds;let N=0;E!==0&&(N=Xn(I)/c);let O=0;z!==0&&(O=Xn(R)/c);const U=xa+_s*(N*E+O*z);U<l&&(a=p,l=U,o=P.candidate)}}else{for(let M=0;M<Jt;M++){const C=Kt[M];C.count=0,C.candidate=b+v+M*v;const P=C.bounds;for(let E=0;E<3;E++)P[E]=1/0,P[E+3]=-1/0}for(let M=d;M<m;M+=6){let E=~~((t[M+2*p]-b)/v);E>=Jt&&(E=Jt-1);const z=Kt[E];z.count++,ar(M,t,z.bounds)}const x=Kt[Jt-1];ba(x.bounds,x.rightCacheBounds);for(let M=Jt-2;M>=0;M--){const C=Kt[M],P=Kt[M+1];Ta(C.bounds,P.rightCacheBounds,C.rightCacheBounds)}let _=0;for(let M=0;M<Jt-1;M++){const C=Kt[M],P=C.count,E=C.bounds,I=Kt[M+1].rightCacheBounds;P!==0&&(_===0?ba(E,cr):Ta(E,cr,cr)),_+=P;let R=0,N=0;_!==0&&(R=Xn(cr)/c);const O=i-_;O!==0&&(N=Xn(I)/c);const U=xa+_s*(R*_+N*O);U<l&&(a=p,l=U,o=C.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function kh(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class Ts{constructor(){this.boundingData=new Float32Array(6)}}function Rh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,h=t.offset||0;for(;;){for(;a<=o&&t[(a-h)*6+l]<c;)a++;for(;a<=o&&t[(o-h)*6+l]>=c;)o--;if(a<o){for(let d=0;d<e;d++){let m=r[a*e+d];r[a*e+d]=r[o*e+d],r[o*e+d]=m}for(let d=0;d<6;d++){const m=a-h,p=o-h,b=t[m*6+d];t[m*6+d]=t[p*6+d],t[p*6+d]=b}a++,o--}else return a}}let Wc,Rr,$s,$c;const Ah=Math.pow(2,32);function Hs(r){return"count"in r?1:1+Hs(r.left)+Hs(r.right)}function Oh(r,e,t){return Wc=new Float32Array(t),Rr=new Uint32Array(t),$s=new Uint16Array(t),$c=new Uint8Array(t),qs(r,e)}function qs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)Wc[t+a]=s[a];if(i)return e.buffer?($c.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Rr[t+6]=e.offset,$s[n+14]=e.count,$s[n+15]=jc,r+We);{const{left:a,right:o,splitAxis:c}=e,l=r+We;let h=qs(l,a);const d=r/We,p=h/We-d;if(p>Ah)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Rr[t+6]=p,Rr[t+7]=c,qs(h,o)}}function zh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,h=r.primitiveBuffer,d=r.primitiveBufferStride,m=new Float32Array(6);let p=!1;const b=new Ts;return bs(e,t,n,b.boundingData,m),g(b,t,n,m),b;function T(v){l&&l(v/n)}function g(v,x,_,M=null,C=0){if(!p&&C>=s&&(p=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),_<=o||C>=s)return T(x+_),v.offset=x,v.count=_,v;const P=Eh(v.boundingData,M,e,x,_,c);if(P.axis===-1)return T(x+_),v.offset=x,v.count=_,v;const E=Rh(h,d,e,x,_,P);if(E===x||E===x+_)T(x+_),v.offset=x,v.count=_;else{v.splitAxis=P.axis;const z=new Ts,I=x,R=E-x;v.left=z,bs(e,I,R,z.boundingData,m),g(z,I,R,m,C+1);const N=new Ts,O=E,U=_-R;v.right=N,bs(e,O,U,N.boundingData,m),g(N,O,U,m,C+1)}return v}}function Ih(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=zh(r,o,c.offset,c.count,e),h=Hs(l),d=new t(We*h);return Oh(0,l,d),d})}class mo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Bh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const pe=new Bh;let rn,Un;const Pn=[],lr=new mo(()=>new A.Box3);function Nh(r,e,t,n,i,s){rn=lr.getPrimitive(),Un=lr.getPrimitive(),Pn.push(rn,Un),pe.setBuffer(r._roots[e]);const a=Xs(0,r.geometry,t,n,i,s);pe.clearBuffer(),lr.releasePrimitive(rn),lr.releasePrimitive(Un),Pn.pop(),Pn.pop();const o=Pn.length;return o>0&&(Un=Pn[o-1],rn=Pn[o-2]),a}function Xs(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=pe;let h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);return Se(r,o,rn),n(m,p,!1,a,s+r/Pe,rn)}else{let R=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Ie(O),J=O*2;return $e(O,F)},N=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Be(O,F),J=O*2;return $e(O,F)+tt(J,U)};const m=Ie(r),p=Be(r,l);let b=m,T=p,g,v,x,_;if(i&&(x=rn,_=Un,Se(b,o,x),Se(T,o,_),g=i(x),v=i(_),v<g)){b=p,T=m;const O=g;g=v,v=O,x=_}x||(x=rn,Se(b,o,x));const M=Ee(b*2,c),C=t(x,M,g,a+1,s+b/Pe);let P;if(C===Ws){const O=R(b),F=N(b)-O;P=n(O,F,!0,a+1,s+b/Pe,x)}else P=C&&Xs(b,e,t,n,i,s,a+1);if(P)return!0;_=Un,Se(T,o,_);const E=Ee(T*2,c),z=t(_,E,v,a+1,s+T/Pe);let I;if(z===Ws){const O=R(T),F=N(T)-O;I=n(O,F,!0,a+1,s+T/Pe,_)}else I=z&&Xs(T,e,t,n,i,s,a+1);return!!I}}const ci=new pe.constructor,Fr=new pe.constructor,tn=new mo(()=>new A.Box3),En=new A.Box3,kn=new A.Box3,Ms=new A.Box3,Cs=new A.Box3;let ws=!1;function Uh(r,e,t,n){if(ws)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ws=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new A.Matrix4().copy(t).invert();for(let h=0,d=i.length;h<d;h++){ci.setBuffer(i[h]),c=0;const m=tn.getPrimitive();Se(0,ci.float32Array,m),m.applyMatrix4(l);for(let p=0,b=s.length;p<b&&(Fr.setBuffer(s[p]),a=wt(0,0,t,l,n,o,c,0,0,m),Fr.clearBuffer(),c+=s[p].byteLength/We,!a);p++);if(tn.releasePrimitive(m),ci.clearBuffer(),o+=i[h].byteLength/We,a)break}return ws=!1,a}function wt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,h=!1){let d,m;h?(d=Fr,m=ci):(d=ci,m=Fr);const p=d.float32Array,b=d.uint32Array,T=d.uint16Array,g=m.float32Array,v=m.uint32Array,x=m.uint16Array,_=r*2,M=e*2,C=Ee(_,T),P=Ee(M,x);let E=!1;if(P&&C)h?E=i($e(e,v),tt(e*2,x),$e(r,b),tt(r*2,T),c,a+e/Pe,o,s+r/Pe):E=i($e(r,b),tt(r*2,T),$e(e,v),tt(e*2,x),o,s+r/Pe,c,a+e/Pe);else if(P){const z=tn.getPrimitive();Se(e,g,z),z.applyMatrix4(t);const I=Ie(r),R=Be(r,b);Se(I,p,En),Se(R,p,kn);const N=z.intersectsBox(En),O=z.intersectsBox(kn);E=N&&wt(e,I,n,t,i,a,s,c,o+1,z,!h)||O&&wt(e,R,n,t,i,a,s,c,o+1,z,!h),tn.releasePrimitive(z)}else{const z=Ie(e),I=Be(e,v);Se(z,g,Ms),Se(I,g,Cs);const R=l.intersectsBox(Ms),N=l.intersectsBox(Cs);if(R&&N)E=wt(r,z,t,n,i,s,a,o,c+1,l,h)||wt(r,I,t,n,i,s,a,o,c+1,l,h);else if(R)if(C)E=wt(r,z,t,n,i,s,a,o,c+1,l,h);else{const O=tn.getPrimitive();O.copy(Ms).applyMatrix4(t);const U=Ie(r),F=Be(r,b);Se(U,p,En),Se(F,p,kn);const J=O.intersectsBox(En),$=O.intersectsBox(kn);E=J&&wt(z,U,n,t,i,a,s,c,o+1,O,!h)||$&&wt(z,F,n,t,i,a,s,c,o+1,O,!h),tn.releasePrimitive(O)}else if(N)if(C)E=wt(r,I,t,n,i,s,a,o,c+1,l,h);else{const O=tn.getPrimitive();O.copy(Cs).applyMatrix4(t);const U=Ie(r),F=Be(r,b);Se(U,p,En),Se(F,p,kn);const J=O.intersectsBox(En),$=O.intersectsBox(kn);E=J&&wt(I,U,n,t,i,a,s,c,o+1,O,!h)||$&&wt(I,F,n,t,i,a,s,c,o+1,O,!h),tn.releasePrimitive(O)}}return E}const Ma=new A.Box3,Rn=new Float32Array(6);class Hc{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Gc,...e},Ih(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0;for(let d=e,m=e+t;d<m;d++){this.writePrimitiveBounds(d,Rn,0);const[p,b,T,g,v,x]=Rn;p<s&&(s=p),g>c&&(c=g),b<a&&(a=b),v>l&&(l=v),T<o&&(o=T),x>h&&(h=x)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=h,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,Rn,0);const[o,c,l,h,d,m]=Rn,p=(o+h)/2,b=(c+d)/2,T=(l+m)/2,g=(h-o)/2,v=(d-c)/2,x=(m-l)/2,_=(s-i)*6;n[_+0]=p,n[_+1]=g+(Math.abs(p)+g)*kr,n[_+2]=b,n[_+3]=v+(Math.abs(b)+v)*kr,n[_+4]=T,n[_+5]=x+(Math.abs(T)+x)*kr}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/We;for(let l=0;l<c;l++){const h=Pe*l,d=2*h;Ee(d,o)&&(a[h+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,h=Ee(l,s);if(h){const d=i[o+6],m=s[l+14];e(c,h,new Float32Array(n,o*4,6),d,m)}else{const d=Ie(o),m=Be(o,i),p=po(o,i);e(c,h,new Float32Array(n,o*4,6),p)||(a(d,c+1),a(m,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/We;for(let l=c-1;l>=0;l--){const h=l*Pe,d=h*2;if(Ee(d,a)){const p=$e(h,s),b=tt(d,a);this.writePrimitiveRangeBounds(p,b,Rn,0),o.set(Rn,h)}else{const p=Ie(h),b=Be(h,s);for(let T=0;T<3;T++){const g=o[p+T],v=o[p+T+3],x=o[b+T],_=o[b+T+3];o[h+T]=g<x?g:x,o[h+T+3]=v>_?v:_}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),Ma),e.union(Ma)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const d=i;i=(m,p,b,T,g)=>d(m,p,b,T,g)?!0:o(m,p,this,s,b,T,a)}else i||(s?i=(d,m,p,b)=>o(d,m,this,s,p,b,a):i=(d,m,p)=>p);let c=!1,l=0;const h=this._roots;for(let d=0,m=h.length;d<m;d++){const p=h[d];if(c=Nh(this,d,n,i,t,l),c)break;l+=p.byteLength/We}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Uh(this,e,t,i)}}function Dh(){return typeof SharedArrayBuffer<"u"}function yo(r){return r.index?r.index.count:r.attributes.position.count}function Wr(r){return yo(r)/3}function Lh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Fh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Lh(t,n);r.setIndex(new A.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Vh(r,e,t){const n=yo(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function Jh(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Ca(r,e,t){const n=Vh(r,e,t),i=Jh(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=yo(r)/t,l=[];for(const m of i){const{offset:p,count:b}=m,T=p,g=isFinite(b)?b:c-p,v=p+g;T<o&&v>a&&(l.push({pos:Math.max(a,T),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((m,p)=>m.pos!==p.pos?m.pos-p.pos:m.type==="end"?-1:1);let h=0,d=null;for(const m of l){const p=m.pos;h!==0&&p!==d&&s.push({offset:d,count:p-d}),h+=m.isStart?1:-1,d=p}return s}function qc(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,h)=>l+h.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:h,count:d}=r[l];for(let m=0;m<d;m++)o[c+m]=h+m;c+=d}return o}class Xc extends Hc{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Dh())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Gc,...t},t[Gr]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Ca(t,e.range,n),s=qc(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else Fh(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new A.Box3))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Ca(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class qt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const c=e[s][t];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}qt.prototype.setFromBox=(function(){const r=new A.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*h+s.z*(1-h);const d=t.dot(r);a=Math.min(d,a),o=Math.max(d,o)}this.min=a,this.max=o}})();const jh=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,h=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const d=t.dot(h),m=h.dot(c),p=h.dot(h),b=t.dot(c),g=c.dot(c)*p-m*m;let v,x;g!==0?v=(d*m-b*p)/g:v=0,x=(d+v*m)/p,a.x=v,a.y=x}})(),go=(function(){const r=new A.Vector2,e=new A.Vector3,t=new A.Vector3;return function(i,s,a,o){jh(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let h;c<0?h=i.start:h=i.end;let d;l<0?d=s.start:d=s.end;const m=e,p=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(h,!0,t),m.distanceToSquared(d)<=p.distanceToSquared(h)){a.copy(m),o.copy(d);return}else{a.copy(h),o.copy(p);return}}}})(),Gh=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Plane,n=new A.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:h,c:d}=a;if(n.start=l,n.end=h,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=d,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=h,n.end=d,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),Wh=["x","y","z"],Gt=1e-15,wa=Gt*Gt;function pt(r){return Math.abs(r)<Gt}class gt extends A.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A.Vector3),this.satBounds=new Array(4).fill().map(()=>new qt),this.points=[this.a,this.b,this.c],this.plane=new A.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new A.Line3,this.needsUpdate=!0}intersectsSphere(e){return Gh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);const d=s[2],m=a[2];d.subVectors(t,n),m.setFromPoints(d,i);const p=s[3],b=a[3];p.subVectors(n,e),b.setFromPoints(p,i);const T=l.length(),g=d.length(),v=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,T<Gt?g<Gt||v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<Gt?v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<Gt&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}gt.prototype.closestPointToSegment=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let h,d=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(l[m]),t.end.copy(l[p]),go(t,i,r,e),h=r.distanceToSquared(e),h<d&&(d=h,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),h=o.distanceToSquared(r),h<d&&(d=h,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),h=c.distanceToSquared(r),h<d&&(d=h,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(d)}})();gt.prototype.intersectsTriangle=(function(){const r=new gt,e=new qt,t=new qt,n=new A.Vector3,i=new A.Vector3,s=new A.Vector3,a=new A.Vector3,o=new A.Line3,c=new A.Line3,l=new A.Vector3,h=new A.Vector2,d=new A.Vector2;function m(_,M,C,P){const E=n;!_.isDegenerateIntoPoint&&!_.isDegenerateIntoSegment?E.copy(_.plane.normal):E.copy(M.plane.normal);const z=_.satBounds,I=_.satAxes;for(let O=1;O<4;O++){const U=z[O],F=I[O];if(e.setFromPoints(F,M.points),U.isSeparated(e)||(a.copy(E).cross(F),e.setFromPoints(a,_.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}const R=M.satBounds,N=M.satAxes;for(let O=1;O<4;O++){const U=R[O],F=N[O];if(e.setFromPoints(F,_.points),U.isSeparated(e)||(a.crossVectors(E,F),e.setFromPoints(a,_.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}return C&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),C.start.set(0,0,0),C.end.set(0,0,0)),!0}function p(_,M,C,P,E,z,I,R,N,O,U){let F=I/(I-R);O.x=P+(E-P)*F,U.start.subVectors(M,_).multiplyScalar(F).add(_),F=I/(I-N),O.y=P+(z-P)*F,U.end.subVectors(C,_).multiplyScalar(F).add(_)}function b(_,M,C,P,E,z,I,R,N,O,U){if(E>0)p(_.c,_.a,_.b,P,M,C,N,I,R,O,U);else if(z>0)p(_.b,_.a,_.c,C,M,P,R,I,N,O,U);else if(R*N>0||I!=0)p(_.a,_.b,_.c,M,C,P,I,R,N,O,U);else if(R!=0)p(_.b,_.a,_.c,C,M,P,R,I,N,O,U);else if(N!=0)p(_.c,_.a,_.b,P,M,C,N,I,R,O,U);else return!0;return!1}function T(_,M,C,P){const E=M.degenerateSegment,z=_.plane.distanceToPoint(E.start),I=_.plane.distanceToPoint(E.end);return pt(z)?pt(I)?m(_,M,C,P):(C&&(C.start.copy(E.start),C.end.copy(E.start)),_.containsPoint(E.start)):pt(I)?(C&&(C.start.copy(E.end),C.end.copy(E.end)),_.containsPoint(E.end)):_.plane.intersectLine(E,n)!=null?(C&&(C.start.copy(n),C.end.copy(n)),_.containsPoint(n)):!1}function g(_,M,C){const P=M.a;return pt(_.plane.distanceToPoint(P))&&_.containsPoint(P)?(C&&(C.start.copy(P),C.end.copy(P)),!0):!1}function v(_,M,C){const P=_.degenerateSegment,E=M.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<wa?(C&&(C.start.copy(E),C.end.copy(E)),!0):!1}function x(_,M,C,P){if(_.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const E=_.degenerateSegment,z=M.degenerateSegment,I=i,R=s;E.delta(I),z.delta(R);const N=n.subVectors(z.start,E.start),O=I.x*R.y-I.y*R.x;if(pt(O))return!1;const U=(N.x*R.y-N.y*R.x)/O,F=-(I.x*N.y-I.y*N.x)/O;if(U<0||U>1||F<0||F>1)return!1;const J=E.start.z+I.z*U,$=z.start.z+R.z*F;return pt(J-$)?(C&&(C.start.copy(E.start).addScaledVector(I,U),C.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return M.isDegenerateIntoPoint?v(_,M,C):T(M,_,C,P);else{if(_.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(_.a)<wa?(C&&(C.start.copy(_.a),C.end.copy(_.a)),!0):!1:M.isDegenerateIntoSegment?v(M,_,C):g(M,_,C);if(M.isDegenerateIntoPoint)return g(_,M,C);if(M.isDegenerateIntoSegment)return T(_,M,C,P)}}return function(M,C=null,P=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(r.copy(M),r.update(),M=r);const E=x(this,M,C,P);if(E!==void 0)return E;const z=this.plane,I=M.plane;let R=I.distanceToPoint(this.a),N=I.distanceToPoint(this.b),O=I.distanceToPoint(this.c);pt(R)&&(R=0),pt(N)&&(N=0),pt(O)&&(O=0);const U=R*N,F=R*O;if(U>0&&F>0)return!1;let J=z.distanceToPoint(M.a),$=z.distanceToPoint(M.b),K=z.distanceToPoint(M.c);pt(J)&&(J=0),pt($)&&($=0),pt(K)&&(K=0);const W=J*$,me=J*K;if(W>0&&me>0)return!1;i.copy(z.normal),s.copy(I.normal);const ne=i.cross(s);let ue=0,re=Math.abs(ne.x);const ge=Math.abs(ne.y);ge>re&&(re=ge,ue=1),Math.abs(ne.z)>re&&(ue=2);const se=Wh[ue],he=this.a[se],oe=this.b[se],Xe=this.c[se],Ve=M.a[se],Je=M.b[se],Ye=M.c[se];if(b(this,he,oe,Xe,U,F,R,N,O,h,o))return m(this,M,C,P);if(b(M,Ve,Je,Ye,W,me,J,$,K,d,c))return m(this,M,C,P);if(h.y<h.x){const xe=h.y;h.y=h.x,h.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(d.y<d.x){const xe=d.y;d.y=d.x,d.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return h.y<d.x||d.y<h.x?!1:(C&&(d.x>h.x?C.start.copy(c.start):C.start.copy(o.start),d.y<h.y?C.end.copy(c.end):C.end.copy(o.end)),!0)}})();gt.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();gt.prototype.distanceToTriangle=(function(){const r=new A.Vector3,e=new A.Vector3,t=["a","b","c"],n=new A.Line3,i=new A.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let h=1/0;for(let d=0;d<3;d++){let m;const p=t[d],b=a[p];this.closestPointToPoint(b,r),m=b.distanceToSquared(r),m<h&&(h=m,o&&o.copy(r),c&&c.copy(b));const T=this[p];a.closestPointToPoint(T,r),m=T.distanceToSquared(r),m<h&&(h=m,o&&o.copy(T),c&&c.copy(r))}for(let d=0;d<3;d++){const m=t[d],p=t[(d+1)%3];n.set(this[m],this[p]);for(let b=0;b<3;b++){const T=t[b],g=t[(b+1)%3];i.set(a[T],a[g]),go(n,i,r,e);const v=r.distanceToSquared(e);v<h&&(h=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(h)}})();class qe{constructor(e,t,n){this.isOrientedBox=!0,this.min=new A.Vector3,this.max=new A.Vector3,this.matrix=new A.Matrix4,this.invMatrix=new A.Matrix4,this.points=new Array(8).fill().map(()=>new A.Vector3),this.satAxes=new Array(3).fill().map(()=>new A.Vector3),this.satBounds=new Array(3).fill().map(()=>new qt),this.alignedSatBounds=new Array(3).fill().map(()=>new qt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}qe.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const m=1*l|2*h|4*d,p=i[m];p.x=l?n.x:t.x,p.y=h?n.y:t.y,p.z=d?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const h=a[l],d=s[l],m=1<<l,p=i[m];h.subVectors(o,p),d.setFromPoints(h,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();qe.prototype.intersectsBox=(function(){const r=new qt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],h=s[c];if(r.setFromBox(l,t),h.isSeparated(r))return!1}return!0}})();qe.prototype.intersectsTriangle=(function(){const r=new gt,e=new Array(3),t=new qt,n=new qt,i=new A.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let m=0;m<3;m++){const p=o[m],b=c[m];if(t.setFromPoints(b,e),p.isSeparated(t))return!1}const l=a.satBounds,h=a.satAxes,d=this.points;for(let m=0;m<3;m++){const p=l[m],b=h[m];if(t.setFromPoints(b,d),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=c[m];for(let b=0;b<4;b++){const T=h[b];if(i.crossVectors(p,T),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}})();qe.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();qe.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();qe.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new A.Line3),t=new Array(12).fill().map(()=>new A.Line3),n=new A.Vector3,i=new A.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const h=o*o,d=a.min,m=a.max,p=this.points;let b=1/0;for(let g=0;g<8;g++){const v=p[g];i.copy(v).clamp(d,m);const x=v.distanceToSquared(i);if(x<b&&(b=x,c&&c.copy(v),l&&l.copy(i),x<h))return Math.sqrt(x)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let x=0;x<=1;x++){const _=(g+1)%3,M=(g+2)%3,C=v<<_|x<<M,P=1<<g|v<<_|x<<M,E=p[C],z=p[P];e[T].set(E,z);const R=r[g],N=r[_],O=r[M],U=t[T],F=U.start,J=U.end;F[R]=d[R],F[N]=v?d[N]:m[N],F[O]=x?d[O]:m[N],J[R]=m[R],J[N]=v?d[N]:m[N],J[O]=x?d[O]:m[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let x=0;x<=1;x++){i.x=g?m.x:d.x,i.y=v?m.y:d.y,i.z=x?m.z:d.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<b&&(b=_,c&&c.copy(n),l&&l.copy(i),_<h))return Math.sqrt(_)}for(let g=0;g<12;g++){const v=e[g];for(let x=0;x<12;x++){const _=t[x];go(v,_,n,i);const M=n.distanceToSquared(i);if(M<b&&(b=M,c&&c.copy(n),l&&l.copy(i),M<h))return Math.sqrt(M)}}return Math.sqrt(b)}})();class $h extends mo{constructor(){super(()=>new gt)}}const yt=new $h,Yn=new A.Vector3,Ps=new A.Vector3;function Hh(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:h=>(Yn.copy(e).clamp(h.min,h.max),Yn.distanceToSquared(e)),intersectsBounds:(h,d,m)=>m<o&&m<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Yn);const m=e.distanceToSquared(Yn);return m<o&&(Ps.copy(Yn),o=m,c=d),m<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Ps):t.point=Ps.clone(),t.distance=l,t.faceIndex=c,t}const ur=parseInt(A.REVISION)>=169,qh=parseInt(A.REVISION)<=161,un=new A.Vector3,hn=new A.Vector3,fn=new A.Vector3,hr=new A.Vector2,fr=new A.Vector2,dr=new A.Vector2,Pa=new A.Vector3,Ea=new A.Vector3,ka=new A.Vector3,Zn=new A.Vector3;function Xh(r,e,t,n,i,s,a,o){let c;if(s===A.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==A.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function Ra(r,e,t,n,i,s,a,o,c,l,h){un.fromBufferAttribute(e,s),hn.fromBufferAttribute(e,a),fn.fromBufferAttribute(e,o);const d=Xh(r,un,hn,fn,Zn,c,l,h);if(d){if(n){hr.fromBufferAttribute(n,s),fr.fromBufferAttribute(n,a),dr.fromBufferAttribute(n,o),d.uv=new A.Vector2;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,hr,fr,dr,d.uv);ur||(d.uv=p)}if(i){hr.fromBufferAttribute(i,s),fr.fromBufferAttribute(i,a),dr.fromBufferAttribute(i,o),d.uv1=new A.Vector2;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,hr,fr,dr,d.uv1);ur||(d.uv1=p),qh&&(d.uv2=d.uv1)}if(t){Pa.fromBufferAttribute(t,s),Ea.fromBufferAttribute(t,a),ka.fromBufferAttribute(t,o),d.normal=new A.Vector3;const p=A.Triangle.getInterpolation(Zn,un,hn,fn,Pa,Ea,ka,d.normal);d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1),ur||(d.normal=p)}const m={a:s,b:a,c:o,normal:new A.Vector3,materialIndex:0};if(A.Triangle.getNormal(un,hn,fn,m.normal),d.face=m,d.faceIndex=s,ur){const p=new A.Vector3;A.Triangle.getBarycoord(Zn,un,hn,fn,p),d.barycoord=p}}return d}function Aa(r){return r&&r.isMaterial?r.side:r}function $r(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,h=o+2;const{index:d,groups:m}=r;r.index&&(c=d.getX(c),l=d.getX(l),h=d.getX(h));const{position:p,normal:b,uv:T,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let x=0,_=m.length;x<_;x++){const{start:M,count:C,materialIndex:P}=m[x];if(v>=M&&v<M+C){const E=Aa(e[P]),z=Ra(t,p,b,T,g,c,l,h,E,s,a);if(z)if(z.faceIndex=n,z.face.materialIndex=P,i)i.push(z);else return z}}}else{const v=Aa(e),x=Ra(t,p,b,T,g,c,l,h,v,s,a);if(x)if(x.faceIndex=n,x.face.materialIndex=0,i)i.push(x);else return x}return null}function we(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Yh(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let h=n,d=n+i;h<d;h++)$r(c,e,t,h,s,a,o)}function Zh(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=$r(o,e,t,d,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function Kh(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=r,d=e+r;h<d;h++){let m;if(m=h,we(a,m*3,c,l),a.needsUpdate=!0,n(a,m,i,s))return!0}return!1}function Qh(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(m,p,b=!1){const T=m*2;if(Ee(T,o)){const g=$e(m,a),v=tt(T,o);let x=1/0,_=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=3*g,I=3*(g+v);z<I;z++){let R=n[z];const N=i.getX(R),O=i.getY(R),U=i.getZ(R);N<x&&(x=N),N>C&&(C=N),O<_&&(_=O),O>P&&(P=O),U<M&&(M=U),U>E&&(E=U)}return c[m+0]!==x||c[m+1]!==_||c[m+2]!==M||c[m+3]!==C||c[m+4]!==P||c[m+5]!==E?(c[m+0]=x,c[m+1]=_,c[m+2]=M,c[m+3]=C,c[m+4]=P,c[m+5]=E,!0):!1}else{const g=Ie(m),v=Be(m,a);let x=b,_=!1,M=!1;if(e){if(!x){const R=g/Pe+p/We,N=v/Pe+p/We;_=e.has(R),M=e.has(N),x=!_&&!M}}else _=!0,M=!0;const C=x||_,P=x||M;let E=!1;C&&(E=d(g,p,x));let z=!1;P&&(z=d(v,p,x));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],$=c[O+3];c[m+R]=U<J?U:J,c[m+R+3]=F>$?F:$}return I}}}function sn(r,e,t,n,i){let s,a,o,c,l,h;const d=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,b=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],x=e[r+3],_=e[r+1],M=e[r+3+1],C=e[r+2],P=e[r+3+2];return d>=0?(s=(v-b)*d,a=(x-b)*d):(s=(x-b)*d,a=(v-b)*d),m>=0?(o=(_-T)*m,c=(M-T)*m):(o=(M-T)*m,c=(_-T)*m),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),p>=0?(l=(C-g)*p,h=(P-g)*p):(l=(P-g)*p,h=(C-g)*p),s>h||l>a)?!1:((l>s||s!==s)&&(s=l),(h<a||a!==a)&&(a=h),s<=i&&a>=n)}function ef(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let h=n,d=n+i;h<d;h++){let m=l?l[h]:h;$r(c,e,t,m,s,a,o)}}function tf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=$r(o,e,t,c?c[d]:d,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function nf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=r,d=e+r;h<d;h++){let m;if(m=t.resolveTriangleIndex(h),we(a,m*3,c,l),a.needsUpdate=!0,n(a,m,i,s))return!0}return!1}function rf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),Ys(0,r,t,n,i,s,a),pe.clearBuffer()}function Ys(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);Yh(e,t,n,m,p,i,s,a)}else{const m=Ie(r);sn(m,o,n,s,a)&&Ys(m,e,t,n,i,s,a);const p=Be(r,l);sn(p,o,n,s,a)&&Ys(p,e,t,n,i,s,a)}}const sf=["x","y","z"];function of(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=Zs(0,r,t,n,i,s);return pe.clearBuffer(),a}function Zs(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const d=$e(r,c),m=tt(l,o);return Zh(e,t,n,d,m,i,s)}else{const d=po(r,c),m=sf[d],b=n.direction[m]>=0;let T,g;b?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const x=sn(T,a,n,i,s)?Zs(T,e,t,n,i,s):null;if(x){const C=x.point[m];if(b?C<=a[g+d]:C>=a[g+d+3])return x}const M=sn(g,a,n,i,s)?Zs(g,e,t,n,i,s):null;return x&&M?x.distance<=M.distance?x:M:x||M||null}}const pr=new A.Box3,An=new gt,On=new gt,Kn=new A.Matrix4,Oa=new qe,mr=new qe;function af(r,e,t,n){pe.setBuffer(r._roots[e]);const i=Ks(0,r,t,n);return pe.clearBuffer(),i}function Ks(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Oa.set(t.boundingBox.min,t.boundingBox.max,n),i=Oa),Ee(c,a)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,b=t.attributes.position,T=$e(r,o),g=tt(c,a);if(Kn.copy(n).invert(),t.boundsTree)return Se(r,s,mr),mr.matrix.copy(Kn),mr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>mr.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let _=T*3,M=(g+T)*3;_<M;_+=3)if(we(On,_,d,m),On.needsUpdate=!0,x.intersectsTriangle(On))return!0;return!1}});{const v=Wr(t);for(let x=T*3,_=(g+T)*3;x<_;x+=3){we(An,x,d,m),An.a.applyMatrix4(Kn),An.b.applyMatrix4(Kn),An.c.applyMatrix4(Kn),An.needsUpdate=!0;for(let M=0,C=v*3;M<C;M+=3)if(we(On,M,p,b),On.needsUpdate=!0,An.intersectsTriangle(On))return!0}}}else{const h=Ie(r),d=Be(r,o);return Se(h,s,pr),!!(i.intersectsBox(pr)&&Ks(h,e,t,n,i)||(Se(d,s,pr),i.intersectsBox(pr)&&Ks(d,e,t,n,i)))}}const yr=new A.Matrix4,Es=new qe,Qn=new qe,cf=new A.Vector3,lf=new A.Vector3,uf=new A.Vector3,hf=new A.Vector3;function ff(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Es.set(e.boundingBox.min,e.boundingBox.max,t),Es.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,d=e.index,m=yt.getPrimitive(),p=yt.getPrimitive();let b=cf,T=lf,g=null,v=null;i&&(g=uf,v=hf);let x=1/0,_=null,M=null;return yr.copy(t).invert(),Qn.matrix.copy(yr),r.shapecast({boundsTraverseOrder:C=>Es.distanceToBox(C),intersectsBounds:(C,P,E)=>E<x&&E<a?(P&&(Qn.min.copy(C.min),Qn.max.copy(C.max),Qn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>Qn.distanceToBox(z),intersectsBounds:(z,I,R)=>R<x&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){we(p,3*R,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let O=C,U=C+P;O<U;O++){we(m,3*O,l,c),m.needsUpdate=!0;const F=m.distanceToTriangle(p,b,g);if(F<x&&(T.copy(b),v&&v.copy(g),x=F,_=O,M=R),F<s)return!0}}}});{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(p,3*z,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){we(m,3*R,l,c),m.needsUpdate=!0;const O=m.distanceToTriangle(p,b,g);if(O<x&&(T.copy(b),v&&v.copy(g),x=O,_=R,M=z),O<s)return!0}}}}}),yt.releasePrimitive(m),yt.releasePrimitive(p),x===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=x,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(yr),T.applyMatrix4(yr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function df(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),d(0,l),l+=s.byteLength;function d(m,p,b=!1){const T=m*2;if(Ee(T,o)){const g=$e(m,a),v=tt(T,o);let x=1/0,_=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=g,I=g+v;z<I;z++){const R=3*r.resolveTriangleIndex(z);for(let N=0;N<3;N++){let O=R+N;O=n?n[O]:O;const U=i.getX(O),F=i.getY(O),J=i.getZ(O);U<x&&(x=U),U>C&&(C=U),F<_&&(_=F),F>P&&(P=F),J<M&&(M=J),J>E&&(E=J)}}return c[m+0]!==x||c[m+1]!==_||c[m+2]!==M||c[m+3]!==C||c[m+4]!==P||c[m+5]!==E?(c[m+0]=x,c[m+1]=_,c[m+2]=M,c[m+3]=C,c[m+4]=P,c[m+5]=E,!0):!1}else{const g=Ie(m),v=Be(m,a);let x=b,_=!1,M=!1;if(e){if(!x){const R=g/Pe+p/We,N=v/Pe+p/We;_=e.has(R),M=e.has(N),x=!_&&!M}}else _=!0,M=!0;const C=x||_,P=x||M;let E=!1;C&&(E=d(g,p,x));let z=!1;P&&(z=d(v,p,x));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],$=c[O+3];c[m+R]=U<J?U:J,c[m+R+3]=F>$?F:$}return I}}}function pf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),Qs(0,r,t,n,i,s,a),pe.clearBuffer()}function Qs(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,h=r*2;if(Ee(h,c)){const m=$e(r,l),p=tt(h,c);ef(e,t,n,m,p,i,s,a)}else{const m=Ie(r);sn(m,o,n,s,a)&&Qs(m,e,t,n,i,s,a);const p=Be(r,l);sn(p,o,n,s,a)&&Qs(p,e,t,n,i,s,a)}}const mf=["x","y","z"];function yf(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=eo(0,r,t,n,i,s);return pe.clearBuffer(),a}function eo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const d=$e(r,c),m=tt(l,o);return tf(e,t,n,d,m,i,s)}else{const d=po(r,c),m=mf[d],b=n.direction[m]>=0;let T,g;b?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const x=sn(T,a,n,i,s)?eo(T,e,t,n,i,s):null;if(x){const C=x.point[m];if(b?C<=a[g+d]:C>=a[g+d+3])return x}const M=sn(g,a,n,i,s)?eo(g,e,t,n,i,s):null;return x&&M?x.distance<=M.distance?x:M:x||M||null}}const gr=new A.Box3,zn=new gt,In=new gt,ei=new A.Matrix4,za=new qe,vr=new qe;function gf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=to(0,r,t,n);return pe.clearBuffer(),i}function to(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),za.set(t.boundingBox.min,t.boundingBox.max,n),i=za),Ee(c,a)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,b=t.attributes.position,T=$e(r,o),g=tt(c,a);if(ei.copy(n).invert(),t.boundsTree)return Se(r,s,vr),vr.matrix.copy(ei),vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>vr.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let _=T,M=g+T;_<M;_++)if(we(In,3*e.resolveTriangleIndex(_),d,m),In.needsUpdate=!0,x.intersectsTriangle(In))return!0;return!1}});{const v=Wr(t);for(let x=T,_=g+T;x<_;x++){const M=e.resolveTriangleIndex(x);we(zn,3*M,d,m),zn.a.applyMatrix4(ei),zn.b.applyMatrix4(ei),zn.c.applyMatrix4(ei),zn.needsUpdate=!0;for(let C=0,P=v*3;C<P;C+=3)if(we(In,C,p,b),In.needsUpdate=!0,zn.intersectsTriangle(In))return!0}}}else{const h=Ie(r),d=Be(r,o);return Se(h,s,gr),!!(i.intersectsBox(gr)&&to(h,e,t,n,i)||(Se(d,s,gr),i.intersectsBox(gr)&&to(d,e,t,n,i)))}}const Sr=new A.Matrix4,ks=new qe,ti=new qe,vf=new A.Vector3,Sf=new A.Vector3,xf=new A.Vector3,_f=new A.Vector3;function bf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ks.set(e.boundingBox.min,e.boundingBox.max,t),ks.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,d=e.index,m=yt.getPrimitive(),p=yt.getPrimitive();let b=vf,T=Sf,g=null,v=null;i&&(g=xf,v=_f);let x=1/0,_=null,M=null;return Sr.copy(t).invert(),ti.matrix.copy(Sr),r.shapecast({boundsTraverseOrder:C=>ks.distanceToBox(C),intersectsBounds:(C,P,E)=>E<x&&E<a?(P&&(ti.min.copy(C.min),ti.max.copy(C.max),ti.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:z=>ti.distanceToBox(z),intersectsBounds:(z,I,R)=>R<x&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){const O=E.resolveTriangleIndex(R);we(p,3*O,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let U=C,F=C+P;U<F;U++){const J=r.resolveTriangleIndex(U);we(m,3*J,l,c),m.needsUpdate=!0;const $=m.distanceToTriangle(p,b,g);if($<x&&(T.copy(b),v&&v.copy(g),x=$,_=U,M=R),$<s)return!0}}}})}else{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(p,3*z,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){const O=r.resolveTriangleIndex(R);we(m,3*O,l,c),m.needsUpdate=!0;const U=m.distanceToTriangle(p,b,g);if(U<x&&(T.copy(b),v&&v.copy(g),x=U,_=R,M=z),U<s)return!0}}}}}),yt.releasePrimitive(m),yt.releasePrimitive(p),x===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=x,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Sr),T.applyMatrix4(Sr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function Ia(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const xr=new qe,_r=new A.Ray,Ba=new A.Vector3,Na=new A.Matrix4,Ua=new A.Vector3,Rs=["getX","getY","getZ"];class Vn extends Xc{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Vn(t,{...n,[Gr]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const h=new A.BufferAttribute(e.index,1,!1);t.setIndex(h)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let h=0;h<l.length;h++){const d=l[h],m=new Uint32Array(d),p=new Uint16Array(d);for(let b=0,T=d.byteLength/We;b<T;b++){const g=Pe*b,v=2*g;Ee(v,p)||(m[g+6]=m[g+6]/Pe-b)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,l=(s?s[e]:e)*3;let h=l+0,d=l+1,m=l+2;o&&(h=o[h],d=o[d],m=o[m]);for(let p=0;p<3;p++){const b=a[Rs[p]](h),T=a[Rs[p]](d),g=a[Rs[p]](m);let v=b;T<v&&(v=T),g<v&&(v=g);let x=b;T>x&&(x=T),g>x&&(x=g),t[n+p]=v,t[n+p+3]=x}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,h=a.offset||0;let d=3;a.isInterleavedBufferAttribute&&(d=a.data.stride);const m=["getX","getY","getZ"],p=n.offset;for(let b=e,T=e+t;b<T;b++){const v=(s?s[b]:b)*3,x=(b-p)*6;let _=v+0,M=v+1,C=v+2;o&&(_=o[_],M=o[M],C=o[C]),c||(_=_*d+h,M=M*d+h,C=C*d+h);for(let P=0;P<3;P++){let E,z,I;c?(E=a[m[P]](_),z=a[m[P]](M),I=a[m[P]](C)):(E=l[_+P],z=l[M+P],I=l[C+P]);let R=E;z<R&&(R=z),I<R&&(R=I);let N=E;z>N&&(N=z),I>N&&(N=I);const O=(N-R)/2,U=P*2;n[x+U+0]=R+O,n[x+U+1]=O+(Math.abs(R)+O)*kr}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;Na.copy(e.matrixWorld).invert(),_r.copy(t.ray).applyMatrix4(Na),Ua.setFromMatrixScale(e.matrixWorld),Ba.copy(_r.direction).multiply(Ua);const s=Ba.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(_r,i,a,o);c=Ia(c,e,t),c&&n.push(c)}else{const c=this.raycast(_r,i,a,o);for(let l=0,h=c.length;l<h;l++){const d=Ia(c[l],e,t);d&&n.push(d)}}return n}refit(e=null){return(this.indirect?df:Qh)(this,e)}raycast(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?pf:rf;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?yf:of;for(let c=0,l=s.length;c<l;c++){const h=o(this,c,t,e,n,i);h!=null&&(a==null||h.distance<a.distance)&&(a=h)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?gf:af;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=yt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?nf:Kh});return yt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=yt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const T=this.resolveTriangleIndex(b);we(a,T*3,o,c)}:b=>{we(a,b*3,o,c)},h=yt.getPrimitive(),d=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?b=>{const T=e.resolveTriangleIndex(b);we(h,T*3,d,m)}:b=>{we(h,b*3,d,m)};if(s){if(!(e instanceof Vn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const b=(T,g,v,x,_,M,C,P)=>{for(let E=v,z=v+x;E<z;E++){p(E),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=T,R=T+g;I<R;I++)if(l(I),a.needsUpdate=!0,s(a,h,I,E,_,M,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,x,_,M,C,P,E){return T(g,v,x,_,M,C,P,E)?!0:b(g,v,x,_,M,C,P,E)}}else i=b}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return xr.set(e.min,e.max,t),xr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>xr.intersectsBox(n),intersectsTriangle:n=>xr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?bf:ff)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Hh(this,e,t,n,i)}}const Bn={Mesh:A.Mesh.prototype.raycast,Line:A.Line.prototype.raycast,LineSegments:A.LineSegments.prototype.raycast,LineLoop:A.LineLoop.prototype.raycast,Points:A.Points.prototype.raycast,BatchedMesh:A.BatchedMesh.prototype.raycast},De=new A.Mesh,br=[];function Tf(r,e){if(this.isBatchedMesh)Mf.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof A.Mesh)n=Bn.Mesh;else if(this instanceof A.LineSegments)n=Bn.LineSegments;else if(this instanceof A.LineLoop)n=Bn.LineLoop;else if(this instanceof A.Line)n=Bn.Line;else if(this instanceof A.Points)n=Bn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function Mf(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;De.material=this.material,De.geometry=this.geometry;const a=De.geometry.boundsTree,o=De.geometry.drawRange;De.geometry.boundingSphere===null&&(De.geometry.boundingSphere=new A.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const h=n[c].geometryIndex;if(De.geometry.boundsTree=t[h],this.getMatrixAt(c,De.matrixWorld).premultiply(s),!De.geometry.boundsTree){this.getBoundingBoxAt(h,De.geometry.boundingBox),this.getBoundingSphereAt(h,De.geometry.boundingSphere);const d=i[h];De.geometry.setDrawRange(d.start,d.count)}De.raycast(r,br);for(let d=0,m=br.length;d<m;d++){const p=br[d];p.object=this,p.batchId=c,e.push(p)}br.length=0}De.geometry.boundsTree=a,De.geometry.drawRange=o,De.material=null,De.geometry=null}else Bn.BatchedMesh.call(this,r,e)}function Cf(r={}){const{type:e=Vn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const dn=new A.Vector3,pn=new A.Vector3,mn=new A.Vector3,Da=new A.Vector4,Tr=new A.Vector3,As=new A.Vector3,La=new A.Vector4,Fa=new A.Vector4,Mr=new A.Matrix4,Va=new A.Matrix4;function ni(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function oi(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new A.BufferAttribute(new t(i*s),i,n)}function Yc(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function wf(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function Ja(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;La.fromBufferAttribute(i.attributes.skinIndex,e),Fa.fromBufferAttribute(i.attributes.skinWeight,e),Mr.elements.fill(0);for(let o=0;o<4;o++){const c=Fa.getComponent(o);if(c!==0){const l=La.getComponent(o);Va.multiplyMatrices(s[l].matrixWorld,a[l]),wf(Mr,Va,c)}}return Mr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Mr),t}function Os(r,e,t,n,i){Tr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(As.fromBufferAttribute(c,n),t?Tr.addScaledVector(As,o):Tr.addScaledVector(As.sub(i),o))}i.add(Tr)}function Pf(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new A.BufferGeometry){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let h=0;h<r.length;++h){const d=r[h];let m=0;if(n!==(d.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const p in d.attributes){if(!o.has(p))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.');c[p]===void 0&&(c[p]=[]),c[p].push(d.attributes[p]),m++}if(m!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,p,h),l+=p}}if(n){let h=!1;if(!t.index){let d=0;for(let m=0;m<r.length;++m)d+=r[m].index.count;t.setIndex(new A.BufferAttribute(new Uint32Array(d),1,!1)),h=!0}if(s||h){const d=t.index;let m=0,p=0;for(let b=0;b<r.length;++b){const T=r[b],g=T.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)d.setX(m,g.getX(v)+p),m++;p+=T.attributes.position.count}}}for(const h in c){const d=c[h];if(!(h in t.attributes)){let b=0;for(const T in d)b+=d[T].count;t.setAttribute(h,oi(c[h][0],b))}const m=t.attributes[h];let p=0;for(let b=0,T=d.length;b<T;b++){const g=d[b];a[b]!==!0&&Yc(g,m,p),p+=g.count}}return t}function Ef(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function kf(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),h=i.getComponent(a+2,c);i.setComponent(a,c,h),i.setComponent(a+2,c,l)}}return r}class Rf{constructor(e){this.matrixWorld=new A.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Ef(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Af{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new A.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new A.BufferGeometry){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],h=s[o],d=a.get(l);!d||d.didChange(l)?(this._convertToStaticGeometry(l,h),t.push(!1),d?d.update():a.set(l,new Rf(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new A.BufferAttribute(new Float32Array(0),4,!1))}else Pf(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new A.BufferGeometry){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",oi(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",oi(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",oi(o.tangent)),ni(n.index,t.index),ni(o.position,c.position),s&&ni(o.normal,c.normal),a&&ni(o.tangent,c.tangent);const l=o.position,h=s?o.normal:null,d=a?o.tangent:null,m=n.morphAttributes.position,p=n.morphAttributes.normal,b=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new A.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let x=0,_=o.position.count;x<_;x++)dn.fromBufferAttribute(l,x),h&&pn.fromBufferAttribute(h,x),d&&(Da.fromBufferAttribute(d,x),mn.fromBufferAttribute(d,x)),g&&(m&&Os(m,g,T,x,dn),p&&Os(p,g,T,x,pn),b&&Os(b,g,T,x,mn)),e.isSkinnedMesh&&(e.applyBoneTransform(x,dn),h&&Ja(e,x,pn),d&&Ja(e,x,mn)),i&&dn.applyMatrix4(e.matrixWorld),c.position.setXYZ(x,dn.x,dn.y,dn.z),h&&(i&&pn.applyNormalMatrix(v),c.normal.setXYZ(x,pn.x,pn.y,pn.z)),d&&(i&&mn.transformDirection(e.matrixWorld),c.tangent.setXYZW(x,mn.x,mn.y,mn.z,Da.w));for(const x in this.attributes){const _=this.attributes[x];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,oi(o[_])),ni(o[_],c[_]),Yc(o[_],c[_]))}return e.matrixWorld.determinant()<0&&kf(t),t}}const Of=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Vc,BVH:Hc,CENTER:fo,CONTAINED:Ws,ExtendedTriangle:gt,GeometryBVH:Xc,MeshBVH:Vn,OrientedBox:qe,SAH:Jc,SKIP_GENERATION:Gr,StaticGeometryGenerator:Af,acceleratedRaycast:Tf,computeBoundsTree:Cf,generateIndirectBuffer:qc},Symbol.toStringTag,{value:"Module"}));class zf{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const mt={node:"node",material:"material",camera:"camera",light:"light"},Qt="KHR_animation_pointer",If={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear,STEP:A.InterpolateDiscrete};class Bf{constructor(e){this.name=Qt,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){Uf();const t=e.target,n=t.extensions&&t.extensions[Qt]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=mt.node,a;if(n){const c=t.extensions[Qt];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=mt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=mt.light:l.startsWith("/cameras/")&&(s=mt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case mt.material:const h=("/materials/"+a.toString()+"/").length,d=l.substring(0,h);switch(i=l.substring(h),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=d+i;break;case mt.node:const m=("/nodes/"+a.toString()+"/").length,p=l.substring(0,m);if(i=l.substring(m),i.startsWith("weights/")){const v=i.substring(8);/^\d+$/.test(v)?i="morphTargetInfluences["+v+"]":console.warn(Qt+": invalid weight index",i,l)}else switch(i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":i="visible";break}l=p+i;break;case mt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case mt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Qt].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===mt.node?o=this.parser.getDependency("node",a):s===mt.material?o=this.parser.getDependency("material",a):s===mt.light?o=this.parser.getDependency("light",a):s===mt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Qt]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[Qt].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]?.startsWith("morphTargetInfluences")){const b=l[3];if(e.type==="Group"){for(const T of e.children)T.morphTargetInfluences&&(l[3]=T.name,l[4]=b,p(this.parser));return c}}p(this.parser);function m(b,T){try{const g=T.split(".").filter(Boolean),x=g[g.length-1].replace(/\[.*\]$/,"");return x in b?typeof b[x]=="boolean":!1}catch{return!1}}function p(b){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&m(e,o)?(T=A.BooleanKeyframeTrack,g=!0):T=A.NumberKeyframeTrack;break;case 2:case 3:T=A.VectorKeyframeTrack;break;case 4:o.endsWith(".quaternion")?T=A.QuaternionKeyframeTrack:T=A.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?If[i.interpolation]:A.InterpolateLinear;let x=b._getArrayFromAccessor(n);o.endsWith(".fov")&&(x=x.map(M=>M/Math.PI*180)),g&&(x=x.map(M=>M>0));const _=new T(o,t.array,x,v);if(v==="CUBICSPLINE"&&b._createCubicSplineTrackInterpolant(_),c.push(_),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const M=new Float32Array(x.length/4);for(let P=0,E=x.length/4;P<E;P+=1)M[P]=x[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,M,v);v==="CUBICSPLINE"&&b._createCubicSplineTrackInterpolant(_),c.push(C)}}return c}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],h=[],d=[];for(let m=0,p=s.channels.length;m<p;m++){const b=s.channels[m],T=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,x=s.parameters!==void 0?s.parameters[T.output]:T.output;let _=t.loadAnimationTargetFromChannelWithAnimationPointer(b);_||(_=t.loadAnimationTargetFromChannel(b)),o.push(_),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",x)),h.push(T),d.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(d)]).then(function(m){const p=m[0],b=m[1],T=m[2],g=m[3],v=m[4],x=[];for(let _=0,M=p.length;_<M;_++){const C=p[_],P=b[_],E=T[_],z=g[_],I=v[_];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(C,P,E,z,I);if(R||(R=i._createAnimationTracks(C,P,E,z,I)),R)for(let N=0;N<R.length;N++)x.push(R[N])}return new A.AnimationClip(a,void 0,x)})}}let ja=!1,Nf=null;function Uf(){if(ja)return;ja=!0;const r=Nf||=A.PropertyBinding.findNode;A.PropertyBinding.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const c=Number.parseInt(a);let l=a;c>=0&&(l=c),i=i[l]}else{const c=e.getObjectByName(a);c&&(i=c)}}if(!i){const s=r(e,n[2]);return s||console.warn(Qt+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Df=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Bf},Symbol.toStringTag,{value:"Module"}));var Lf=Object.defineProperty,Ff=(r,e,t)=>e in r?Lf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Ff(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class t extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class n extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class i extends r{constructor(f,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=f,this.type=y}}class s extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class a extends r{}class o extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class c extends r{}class l extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class h extends r{constructor(f,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=f,this.type=y}}class d extends r{constructor(f){super(),Ce(this,"value"),this.value=f}}class m extends r{constructor(f,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=f,this.type=y,this.unit=S}}class p extends r{}class b extends r{}class T extends r{}class g extends r{}class v extends r{}class x extends r{}class _ extends r{}class M extends r{}class C extends r{}class P extends r{}class E extends r{}class z extends r{}class I{constructor(f){Ce(this,"input"),Ce(this,"index",0),this.input=f}consume(){const f=this.input.codePointAt(this.index);return f!==void 0&&(this.index+=String.fromCodePoint(f).length),f}reconsume(f){f!==void 0&&(this.index-=String.fromCodePoint(f).length)}peek(){const f=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);f.push(w),y+=String.fromCodePoint(w).length}return f}}function R(u){return u===10}function N(u){return R(u)||u===8192||u===32}function O(u){return u>=48&&u<=57}function U(u){return O(u)||u>=65&&u<=70||u>=97&&u<=102}function F(u){return(function(f){return(function(y){return y>=65&&y<=90})(f)||(function(y){return y>=97&&y<=122})(f)})(u)||(function(f){return f>=128})(u)||u===95}function J(u){return F(u)||O(u)||u===45}function $(u){return u>=0&&u<=8||u===11||u>=14&&u<=31||u===127}function K(u,f){return u===92&&!R(f)}function W(u,f,y){return u===45?F(f)||f===45||K(f,y):!!F(u)||u===92&&K(u,f)}function me(u,f,y){return u===43||u===45?O(f)||f===46&&O(y):O(u===46?f:u)}function ne(u){const f=u.consume();if(U(f)){let y=[f];for(;U(...u.peek())&&y.length<5;)y.push(u.consume());N(...u.peek())&&u.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return f===void 0?65533:f}function ue(u,f){const y=new s("");for(;;){const S=u.consume();if(S===f||S===void 0)return y;if(S===10)return u.reconsume(S),new a;if(S===92){const w=u.peek()[0];w===void 0||(R(w)?u.consume():y.value+=String.fromCodePoint(ne(u)))}else y.value+=String.fromCodePoint(S)}}function re(u){let f="";for(;;){const y=u.consume();if(J(y))f+=String.fromCodePoint(y);else{if(!K(...u.peek()))return u.reconsume(y),f;f+=String.fromCodePoint(ne(u))}}}function ge(u){let f=(function(y){let S="integer",w="";for([43,45].includes(y.peek()[0])&&(w+=String.fromCodePoint(y.consume()));O(...y.peek());)w+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&O(y.peek()[1]))for(w+=String.fromCodePoint(y.consume(),y.consume()),S="number";O(...y.peek());)w+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&O(y.peek()[2])?(w+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):O(y.peek()[1])&&(w+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(w),type:S}})(u);return W(...u.peek())?new m(f.value,f.type,re(u)):u.peek()[0]===37?(u.consume(),new d(f.value)):new h(f.value,f.type)}function be(u){for(;;){const f=u.consume();if(f===41||f===void 0)return;K(...u.peek())&&ne(u)}}function se(u){const f=re(u);if(f.match(/url/i)&&u.peek()[0]===40){for(u.consume();N(u.peek()[0])&&N(u.peek()[1]);)u.consume();return[34,39].includes(u.peek()[0])||N(u.peek()[0])&&[34,39].includes(u.peek()[1])?new t(f):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const w=y.consume();if(w===41||w===void 0)return S;if(N(w)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(be(y),new c)}if([34,39,40].includes(w)||$(w))return be(y),new c;if(w===92){if(!K(...y.peek()))return be(y),new c;S.value+=ne(y)}else S.value+=String.fromCodePoint(w)}})(u)}return u.peek()[0]===40?(u.consume(),new t(f)):new e(f)}function he(u){const f=u.consume(),y=u.peek();if(N(f)){for(;N(...u.peek());)u.consume();return new p}if(f===34)return ue(u,f);if(f===35){if(J(y[0])||K(...y)){const S=new i;return W(...y)&&(S.type="id"),S.value=re(u),S}return new l(String.fromCodePoint(f))}return f===39?ue(u,f):f===40?new C:f===41?new P:f===43?me(...y)?(u.reconsume(f),ge(u)):new l(String.fromCodePoint(f)):f===44?new x:f===45?me(...u.peek())?(u.reconsume(f),ge(u)):u.peek()[0]===45&&u.peek()[1]===62?(u.consume(),u.consume(),new T):W(...u.peek())?(u.reconsume(f),se(u)):new l(String.fromCodePoint(f)):f===46?me(...u.peek())?(u.reconsume(f),ge(u)):new l(String.fromCodePoint(f)):f===58?new g:f===59?new v:f===60?y[0]===33&&y[1]===45&&y[2]===45?(u.consume(),u.consume(),u.consume(),new b):new l(String.fromCodePoint(f)):f===64?W(...y)?new n(re(u)):new l(String.fromCodePoint(f)):f===91?new _:f===92?K(...y)?(u.reconsume(f),se(u)):new l(String.fromCodePoint(f)):f===93?new M:f===123?new E:f===125?new z:O(f)?(u.reconsume(f),ge(u)):F(f)?(u.reconsume(f),se(u)):f===void 0?void 0:new l(String.fromCodePoint(f))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function Xe(u){return oe.has(u.toLowerCase())}function Ve(u,f){if(["x","y"].includes(u))return u;if(!f)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=f.writingMode=="horizontal-tb";if(u==="block")u=y?"y":"x";else{if(u!=="inline")throw new TypeError(`Invalid axis “${u}”`);u=y?"x":"y"}return u}function Je(u){const f=[];let y=0;function S(){let k=0;const B=y;for(;y<u.length;){const L=u.slice(y,y+1);if(/\s/.test(L)&&k===0)break;if(L==="(")k+=1;else if(L===")"&&(k-=1,k===0)){y++;break}y++}return u.slice(B,y)}function w(){for(;/\s/.test(u.slice(y,y+1));)y++}for(;y<u.length;){const k=u.slice(y,y+1);/\s/.test(k)?w():f.push(S())}return f}function Ye(u,f){return u.reduce(((y,S)=>(y.has(S[f])?y.get(S[f]).push(S):y.set(S[f],[S]),y)),new Map)}function xe(u,f){const y=[],S=[];for(const w of u)f(w)?y.push(w):S.push(w);return[y,S]}function ye(u,f={}){function y(S){return Array.from(S).map((w=>ye(w,f)))}if(u instanceof CSSUnitValue){if(u.unit==="percent"&&f.percentageReference){const w=u.value/100*f.percentageReference.value,k=f.percentageReference.unit;return new CSSUnitValue(w,k)}const S=u.toSum();if(S&&S.values.length===1&&(u=S.values[0]),u instanceof CSSUnitValue&&u.unit==="em"&&f.fontSize&&(u=new CSSUnitValue(u.value*f.fontSize.value,f.fontSize.unit)),u instanceof CSSKeywordValue){if(u.value==="e")return new CSSUnitValue(Math.E,"number");if(u.value==="pi")return new CSSUnitValue(Math.PI,"number")}return u}if(!u.operator)return u;switch(u.operator){case"sum":u=new CSSMathSum(...y(u.values));break;case"product":u=new CSSMathProduct(...y(u.values));break;case"negate":u=new CSSMathNegate(ye(u.value,f));break;case"clamp":u=new CSSMathClamp(ye(u.lower,f),ye(u.value,f),ye(u.upper,f));break;case"invert":u=new CSSMathInvert(ye(u.value,f));break;case"min":u=new CSSMathMin(...y(u.values));break;case"max":u=new CSSMathMax(...y(u.values))}if(u instanceof CSSMathMin||u instanceof CSSMathMax){const S=Array.from(u.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&Xe(w.unit)&&w.unit===S[0].unit))){const w=Math[u.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(u instanceof CSSMathMin||u instanceof CSSMathMax){const S=Array.from(u.values),[w,k]=xe(S,(L=>L instanceof CSSUnitValue&&L.unit!=="percent")),B=Array.from(Ye(w,"unit").values());if(B.some((L=>L.length>0))){const L=B.map((D=>{const V=Math[u.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));u=u instanceof CSSMathMin?new CSSMathMin(...L,...k):new CSSMathMax(...L,...k)}return S.length===1?S[0]:u}if(u instanceof CSSMathNegate)return u.value instanceof CSSUnitValue?new CSSUnitValue(0-u.value.value,u.value.unit):u.value instanceof CSSMathNegate?u.value.value:u;if(u instanceof CSSMathInvert)return u.value instanceof CSSMathInvert?u.value.value:u;if(u instanceof CSSMathSum){let S=function(k){const B=k.filter((L=>L instanceof CSSUnitValue));return[...k.filter((L=>!(L instanceof CSSUnitValue))),...Array.from(Ye(B,"unit").entries()).map((([L,D])=>{const V=D.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,L)}))]},w=[];for(const k of u.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(u instanceof CSSMathProduct){let S=[];for(const B of u.values)B instanceof CSSMathProduct?S.push(...B.values):S.push(B);const[w,k]=xe(S,(B=>B instanceof CSSUnitValue&&B.unit==="number"));if(w.length>1){const B=w.reduce(((L,{value:D})=>L*D),1);S=[new CSSUnitValue(B,"number"),...k]}if(S.length===2){let B,L;for(const D of S)D instanceof CSSUnitValue&&D.unit==="number"?B=D:D instanceof CSSMathSum&&[...D.values].every((V=>V instanceof CSSUnitValue))&&(L=D);if(B&&L)return new CSSMathSum(...[...L.values].map((D=>new CSSUnitValue(D.value*B.value,D.unit))))}if(S.every((B=>B instanceof CSSUnitValue&&Xe(B.unit)||B instanceof CSSMathInvert&&B.value instanceof CSSUnitValue&&Xe(B.value.unit)))){const B=new CSSMathProduct(...S).toSum();if(B&&B.values.length===1)return B.values[0]}return new CSSMathProduct(...S)}return u}const ae=null,ut=["percent","length","angle","time","frequency","resolution","flex"],ke={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},fe=new Map;for(const u of Object.values(ke))if(u.compatible)for(const f of u.units)fe.set(f,u);function it(u){return fe.get(u)}function vt(u,f){const y={...u};for(const S of Object.keys(f))y[S]?y[S]+=f[S]:y[S]=f[S];return y}function St(u){return u==="number"?{}:u==="percent"?{percent:1}:ke.absoluteLengths.units.has(u)||ke.fontRelativeLengths.units.has(u)||ke.viewportRelativeLengths.units.has(u)?{length:1}:ke.angle.units.has(u)?{angle:1}:ke.time.units.has(u)?{time:1}:ke.frequency.units.has(u)?{frequency:1}:ke.resolution.units.has(u)?{resolution:1}:u==="fr"?{flex:1}:ae}function rt(u){if(u instanceof CSSUnitValue){let{unit:f,value:y}=u;const S=it(u.unit);return S&&f!==S.canonicalUnit&&(y*=S.ratios[f],f=S.canonicalUnit),f==="number"?[[y,{}]]:[[y,{[f]:1}]]}if(u instanceof CSSMathInvert){if(!(u.value instanceof CSSUnitValue))throw new Error("Not implemented");const f=rt(u.value);if(f===ae||f.length>1)return ae;const y=f[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return f[0]=[1/y[0],S],f}if(u instanceof CSSMathProduct){let f=[[1,{}]];for(const y of u.values){const S=rt(y),w=[];if(S===ae)return ae;for(const k of f)for(const B of S)w.push([k[0]*B[0],vt(k[1],B[1])]);f=w}return f}throw new Error("Not implemented")}function xt(u,f){if(St(f)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=rt(u);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(w,k){const B=w.unit,L=w.value,D=it(B),V=it(k);return!V||D!==V?ae:new CSSUnitValue(L*V.ratios[B]/V.ratios[k],k)})(ht(y[0]),f);if(S===ae)throw new TypeError;return S}function ht(u){const[f,y]=u,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(f,"number");const w=S[0];return w[1]!==1?ae:new CSSUnitValue(f,w[0])}function ft(u,...f){if(f&&f.length)throw new Error("Not implemented");const y=rt(u).map((S=>ht(S)));if(y.some((S=>S===ae)))throw new TypeError("Type error");return new CSSMathSum(...y)}function _t(u,f){if(u.percentHint&&f.percentHint&&u.percentHint!==f.percentHint)return ae;const y={...u,percentHint:u.percentHint??f.percentHint};for(const S of ut)f[S]&&(y[S]??(y[S]=0),y[S]+=f[S]);return y}class Re{constructor(f,y){Ce(this,"name"),Ce(this,"values"),this.name=f,this.values=y}}class Ze{constructor(f,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=f,this.associatedToken=y}}function ct(u){if(Array.isArray(u))return u;if(typeof u=="string")return(function(f){const y=new I(f),S=[];for(;;){const w=he(y);if(w===void 0)return S;S.push(w)}})(u);throw new TypeError("Invalid input type "+typeof u)}function Ke(u){const f=u.shift();return f instanceof E||f instanceof _||f instanceof C?(function(y,S){let w;if(S instanceof E)w=z;else if(S instanceof C)w=P;else{if(!(S instanceof _))return;w=M}const k=new Ze([],S);for(;;){const B=y.shift();if(B instanceof w||B===void 0)return k;y.unshift(B),k.value.push(Ke(y))}})(u,f):f instanceof t?(function(y,S){const w=new Re(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return w;S.unshift(k),w.values.push(Ke(S))}})(f,u):f}function Q(u){if(u instanceof C||u instanceof P)return 6;if(u instanceof l)switch(u.value){case"*":case"/":return 4;case"+":case"-":return 2}}function bt(u){return u[u.length-1]}function Nt(u,f,y){const S=["+","-"].includes(u.value)?"ADDITION":"MULTIPLICATION",w=f.type===S?f.values:[f],k=y.type===S?y.values:[y];return u.value==="-"?k[0]={type:"NEGATE",value:k[0]}:u.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function Tt(u){if(u.type==="ADDITION")return new CSSMathSum(...u.values.map((f=>Tt(f))));if(u.type==="MULTIPLICATION")return new CSSMathProduct(...u.values.map((f=>Tt(f))));if(u.type==="NEGATE")return new CSSMathNegate(Tt(u.value));if(u.type==="INVERT")return new CSSMathInvert(Tt(u.value));if(u instanceof Ze)return Ut(new Re("calc",u.value));if(u instanceof e){if(u.value==="e")return new CSSUnitValue(Math.E,"number");if(u.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return le(u)}function Ut(u){if(u.name==="min"||u.name==="max"){const S=u.values.filter((w=>!(w instanceof p||w instanceof x))).map((w=>ye(Ut(new Re("calc",w)))));return u.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(u.name!=="calc")return null;const f=Tt((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof h||B instanceof m||B instanceof d||B instanceof Re||B instanceof Ze||B instanceof e)k.push(B);else if(B instanceof l&&["*","/","+","-"].includes(B.value)){for(;w.length&&!(bt(w)instanceof C)&&Q(bt(w))>Q(B);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}w.push(B)}else if(B instanceof C)w.push(B);else if(B instanceof P){if(!w.length)return null;for(;!(bt(w)instanceof C);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}if(!(bt(w)instanceof C))return null;w.pop()}else if(!(B instanceof p))return null}for(;w.length;){if(bt(w)instanceof C)return null;const B=w.pop(),L=k.pop(),D=k.pop();k.push(Nt(B,D,L))}return k[0]})([...u.values]));let y;try{y=ye(f)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function le(u){return u instanceof Re&&["calc","min","max","clamp"].includes(u.name)?Ut(u):u instanceof h&&u.value===0&&!u.unit?new CSSUnitValue(0,"px"):u instanceof h?new CSSUnitValue(u.value,"number"):u instanceof d?new CSSUnitValue(u.value,"percent"):u instanceof m?new CSSUnitValue(u.value,u.unit):void 0}function Zc(u){const f=(function(y){const S=ct(y);for(;S[0]instanceof p;)S.shift();if(S[0]===void 0)return null;const w=Ke(S);for(;S[0]instanceof p;)S.shift();return S[0]===void 0?w:null})(u);return f===null&&new CSSStyleSheet().insertRule("error",0),f instanceof h||f instanceof d||f instanceof m||f instanceof Re||new CSSStyleSheet().insertRule("error",0),f instanceof m&&St(f.unit)===null&&new CSSStyleSheet().insertRule("error",0),le(f)}(function(){let u=new WeakMap;function f(k){const B=[];for(let D=0;D<k.length;D++)B[D]=typeof(L=k[D])=="number"?new CSSUnitValue(L,"number"):L;var L;return B}class y{static parse(B){return B instanceof y?B:ye(Zc(B),{})}}class S extends y{constructor(B,L,D,V){super(),u.set(this,{values:f(B),operator:L,name:D||L,delimiter:V||", "})}get operator(){return u.get(this).operator}get values(){return u.get(this).values}toString(){const B=u.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),u.set(this,{value:k,unit:B})}get value(){return u.get(this).value}set value(k){u.get(this).value=k}get unit(){return u.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ft(this,...k)}type(){return St(u.get(this).unit)}toString(){const k=u.get(this);return`${k.value}${(function(B){switch(B){case"percent":return"%";case"number":return"";default:return B.toLowerCase()}})(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ft(this,...k)}type(){return u.get(this).values.map((k=>k.type())).reduce(_t)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return u.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return u.get(this).values[1]}type(){return(function(k){const B={};for(const L of ut)B[L]=-1*k[L];return B})(u.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:B=>new CSSUnitValue(B,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,B]of Object.entries(w))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:B}))throw Error(`Error installing CSSOM support for ${k}`)})();const vo="block";let je=new WeakMap,Dt=new WeakMap;const Wi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function So(u){return u===document.scrollingElement?document:u}function on(u){qr(u);let f=je.get(u).animations;if(f.length===0)return;let y=u.currentTime;for(let S=0;S<f.length;S++)f[S].tickAnimation(y)}function xo(u,f){if(!u)return null;const y=Dt.get(u).sourceMeasurements,S=getComputedStyle(u);let w=y.scrollTop;return Ve(f,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function Hr(u,f){const y=ye(u,f);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof u)}function qr(u){if(!(u instanceof bn))return void(function(y){const S=je.get(y);if(!S.anonymousSource)return;const w=bo(S.anonymousSource,S.anonymousTarget);_n(y,w)})(u);const f=u.subject;if(!f||getComputedStyle(f).display=="none")return void _n(u,null);_n(u,es(f))}function _o(u){return["block","inline","x","y"].includes(u)}function Xr(u){const f=getComputedStyle(u);return{scrollLeft:u.scrollLeft,scrollTop:u.scrollTop,scrollWidth:u.scrollWidth,scrollHeight:u.scrollHeight,clientWidth:u.clientWidth,clientHeight:u.clientHeight,writingMode:f.writingMode,direction:f.direction,scrollPaddingTop:f.scrollPaddingTop,scrollPaddingBottom:f.scrollPaddingBottom,scrollPaddingLeft:f.scrollPaddingLeft,scrollPaddingRight:f.scrollPaddingRight}}function Yr(u,f){if(!u||!f)return;let y=0,S=0,w=f;const k=u.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=u.offsetLeft+u.clientLeft,y-=u.offsetTop+u.clientTop;const B=getComputedStyle(f);return{top:y,left:S,offsetWidth:f.offsetWidth,offsetHeight:f.offsetHeight,fontSize:B.fontSize}}function $i(u){let f=Dt.get(u);f.sourceMeasurements=Xr(u);for(const y of f.timelineRefs){const S=y.deref();S instanceof bn&&(je.get(S).subjectMeasurements=Yr(u,S.subject))}f.updateScheduled||(setTimeout((()=>{for(const y of f.timelineRefs){const S=y.deref();S&&on(S)}f.updateScheduled=!1})),f.updateScheduled=!0)}function _n(u,f){const y=je.get(u),S=y.source;if(S!=f){if(S){const w=Dt.get(S);if(w){w.timelineRefs.delete(u);const k=Array.from(w.timelineRefs).filter((B=>B.deref()===void 0));for(const B of k)w.timelineRefs.delete(B);w.timelineRefs.size===0&&(w.disconnect(),Dt.delete(S))}}if(y.source=f,f){let w=Dt.get(f);if(!w){w={timelineRefs:new Set,sourceMeasurements:Xr(f)},Dt.set(f,w);const k=new ResizeObserver((D=>{for(const V of D)$i(y.source)}));k.observe(f);for(const D of f.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)$i(V.target)}));B.observe(f,{attributes:!0,attributeFilter:["style","class"]});const L=()=>{w.sourceMeasurements.scrollLeft=f.scrollLeft,w.sourceMeasurements.scrollTop=f.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&on(V)}};So(f).addEventListener("scroll",L),w.disconnect=()=>{k.disconnect(),B.disconnect(),So(f).removeEventListener("scroll",L)}}w.timelineRefs.add(new WeakRef(u))}}}function Zr(u,f){let y=je.get(u).animations;for(let S=0;S<y.length;S++)y[S].animation==f&&y.splice(S,1)}function Kr(u,f,y){let S=je.get(u).animations;for(let w=0;w<S.length;w++)if(S[w].animation==f)return;S.push({animation:f,tickAnimation:y}),queueMicrotask((()=>{on(u)}))}class Qe{constructor(f){if(je.set(this,{source:null,axis:vo,anonymousSource:f?f.anonymousSource:null,anonymousTarget:f?f.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),_n(this,f&&f.source!==void 0?f.source:document.scrollingElement),f&&f.axis!==void 0&&f.axis!=vo){if(!_o(f.axis))throw TypeError("Invalid axis");je.get(this).axis=f.axis}on(this)}set source(f){_n(this,f),on(this)}get source(){return je.get(this).source}set axis(f){if(!_o(f))throw TypeError("Invalid axis");je.get(this).axis=f,on(this)}get axis(){return je.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const f=this.source;if(!f)return"inactive";let y=getComputedStyle(f);return y.display=="none"?"inactive":f==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const w=this.axis,k=xo(y,w),B=(function(L,D){const V=Dt.get(L).sourceMeasurements,H=getComputedStyle(L).writingMode=="horizontal-tb";return D==="block"?D=H?"y":"x":D==="inline"&&(D=H?"x":"y"),D==="y"?V.scrollHeight-V.clientHeight:D==="x"?V.scrollWidth-V.clientWidth:void 0})(y,w);return B>0?CSS.percent(100*k/B):CSS.percent(100)}get __polyfill(){return!0}}function Qr(u,f){let y=u.parentElement;for(;y!=null;){if(f(y))return y;y=y.parentElement}}function bo(u,f){switch(u){case"root":return document.scrollingElement;case"nearest":return es(f);case"self":return f;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Kc(u){switch(getComputedStyle(u).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function To(u){const f=getComputedStyle(u);return f.transform!="none"||f.perspective!="none"||f.willChange=="transform"||f.willChange=="perspective"||f.filter!="none"||f.willChange=="filter"||f.backdropFilter!="none"}function Qc(u){return getComputedStyle(u).position!="static"||To(u)}function el(u){switch(getComputedStyle(u).position){case"static":case"relative":case"sticky":return Qr(u,Kc);case"absolute":return Qr(u,Qc);case"fixed":return Qr(u,To)}}function es(u){if(u&&u.isConnected){for(;u=el(u);)switch(getComputedStyle(u)["overflow-x"]){case"auto":case"scroll":case"hidden":return u==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:u}return document.scrollingElement}}function Gn(u,f){const y=je.get(u),S=y.subjectMeasurements,w=Dt.get(y.source).sourceMeasurements;return u.phase==="inactive"?null:u instanceof bn?ts(f,w,S,y.axis,y.inset):null}function ts(u,f,y,S,w){const k=f.direction=="rtl"||f.writingMode=="vertical-rl";let B,L,D={fontSize:y.fontSize};Ve(S,f)==="x"?(B=y.offsetWidth,L=y.left,D.scrollPadding=[f.scrollPaddingLeft,f.scrollPaddingRight],k&&(L+=f.scrollWidth-f.clientWidth,D.scrollPadding=[f.scrollPaddingRight,f.scrollPaddingLeft]),D.containerSize=f.clientWidth):(B=y.offsetHeight,L=y.top,D.scrollPadding=[f.scrollPaddingTop,f.scrollPaddingBottom],D.containerSize=f.clientHeight);const V=(function(ss,Zi){const fl={start:0,end:0};if(!ss)return fl;const[dl,pl]=[ss.start,ss.end].map(((Do,Lo)=>Do==="auto"?Zi.scrollPadding[Lo]==="auto"?0:parseFloat(Zi.scrollPadding[Lo]):Hr(Do,{percentageReference:CSS.px(Zi.containerSize),fontSize:CSS.px(parseFloat(Zi.fontSize))})));return{start:dl,end:pl}})(w,D),H=L-D.containerSize+V.end,X=L+B-V.start,Y=H+B,de=X-B,Te=Math.min(Y,de),st=Math.max(Y,de);let Mt,dt;const Uo=B>D.containerSize-V.start-V.end;switch(u){case"cover":Mt=H,dt=X;break;case"contain":Mt=Te,dt=st;break;case"entry":Mt=H,dt=Te;break;case"exit":Mt=st,dt=X;break;case"entry-crossing":Mt=H,dt=Uo?st:Te;break;case"exit-crossing":Mt=Uo?Te:st,dt=X}return{start:Mt,end:dt}}function Mo(u,f){if(u instanceof bn){const{rangeName:y,offset:S}=f;return Co(Gn(u,y),S,Gn(u,"cover"),u.subject)}if(u instanceof Qe){const{axis:y,source:S}=u,{sourceMeasurements:w}=Dt.get(S);let k;return k=Ve(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,Hr(f,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(u)}function Co(u,f,y,S){if(!u||!y)return 0;let w=getComputedStyle(S);return(Hr(f,{percentageReference:CSS.px(u.end-u.start),fontSize:CSS.px(parseFloat(w.fontSize))})+u.start-y.start)/(y.end-y.start)}let bn=class extends Qe{constructor(f){super(f);const y=je.get(this);y.subject=f&&f.subject?f.subject:void 0,f&&f.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let w;if(w=typeof S=="string"?Je(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],w.length===0||w.length>2)throw TypeError("Invalid inset");for(const k of w){if(k==="auto")continue;const B=k.type();if(B.length!==1&&B.percent!==1)throw TypeError("Invalid inset")}return{start:w[0],end:w[1]??w[0]}})(f.inset)),y.subject&&(new ResizeObserver((()=>{$i(y.source)})).observe(y.subject),new MutationObserver((()=>{$i(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),qr(this),y.subjectMeasurements=Yr(y.source,y.subject),on(this)}get source(){return qr(this),je.get(this).source}set source(f){throw new Error("Cannot set the source of a view timeline")}get subject(){return je.get(this).subject}get axis(){return je.get(this).axis}get currentTime(){const y=xo(this.source,this.axis);if(y==null)return null;const S=Gn(this,"cover");if(!S)return null;const w=(y-S.start)/(S.end-S.start);return CSS.percent(100*w)}get startOffset(){return CSS.px(Gn(this,"cover").start)}get endOffset(){return CSS.px(Gn(this,"cover").end)}};const tl=document.getAnimations,nl=window.Element.prototype.getAnimations,il=window.Element.prototype.animate,wo=window.Animation;class Tn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((f,y)=>{this.nativeResolve=f,this.nativeReject=y}))}resolve(f){this.state="resolved",this.nativeResolve(f)}reject(f){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(f)}}function Wn(u){u.readyPromise=new Tn,requestAnimationFrame((()=>{var f;(((f=u.timeline)==null?void 0:f.currentTime)??null)!==null&&(Hi(u),u.pendingTask!=="play"||u.startTime===null&&u.holdTime===null?u.pendingTask==="pause"&&ko(u):Eo(u))}))}function Po(){return new DOMException("The user aborted a request","AbortError")}function an(u,f){if(f===null)return f;if(typeof f!="number")throw new DOMException(`Unexpected value: ${f}. Cannot convert to CssNumberish`,"InvalidStateError");const y=u.rangeDuration??100,S=Ft(u),w=S?y*f/S:0;return CSS.percent(w)}function ve(u,f){if(u.timeline){if(f===null)return f;if(f.unit==="percent"){const y=u.rangeDuration??100,S=Ft(u);return f.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(f==null||typeof f=="number")return f;const y=f.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Eo(u){const f=ve(u,u.timeline.currentTime);if(u.holdTime!=null)kt(u),u.animation.playbackRate==0?u.startTime=f:(u.startTime=f-u.holdTime/u.animation.playbackRate,u.holdTime=null);else if(u.startTime!==null&&u.pendingPlaybackRate!==null){const y=(f-u.startTime)*u.animation.playbackRate;kt(u);const S=u.animation.playbackRate;S==0?(u.holdTime=null,u.startTime=f):u.startTime=f-y/S}u.readyPromise&&u.readyPromise.state=="pending"&&u.readyPromise.resolve(u.proxy),Lt(u,!1,!1),Vt(u),u.pendingTask=null}function ko(u){const f=ve(u,u.timeline.currentTime);u.startTime!=null&&u.holdTime==null&&(u.holdTime=(f-u.startTime)*u.animation.playbackRate),kt(u),u.startTime=null,u.readyPromise.resolve(u.proxy),Lt(u,!1,!1),Vt(u),u.pendingTask=null}function Ro(u){if(!u.finishedPromise||u.finishedPromise.state!="pending"||u.proxy.playState!="finished")return;u.finishedPromise.resolve(u.proxy),u.animation.pause();const f=new CustomEvent("finish",{detail:{currentTime:u.proxy.currentTime,timelineTime:u.proxy.timeline.currentTime}});Object.defineProperty(f,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(f,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{u.animation.dispatchEvent(f)}))}))}function Mn(u){return u.pendingPlaybackRate!==null?u.pendingPlaybackRate:u.animation.playbackRate}function kt(u){u.pendingPlaybackRate!==null&&(u.animation.playbackRate=u.pendingPlaybackRate,u.pendingPlaybackRate=null)}function Ao(u){if(!u.timeline)return null;const f=ve(u,u.timeline.currentTime);if(f===null||u.startTime===null)return null;let y=(f-u.startTime)*u.animation.playbackRate;return y==-0&&(y=0),y}function Lt(u,f,y){if(!u.timeline)return;let S=f?ve(u,u.proxy.currentTime):Ao(u);if(S&&u.startTime!=null&&!u.proxy.pending){const w=Mn(u),k=Ft(u);let B=u.previousCurrentTime;w>0&&S>=k&&u.previousCurrentTime!=null?((B===null||B<k)&&(B=k),u.holdTime=f?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),u.holdTime=f?S:B):w!=0&&(f&&u.holdTime!==null&&(u.startTime=(function(L,D){if(!L.timeline)return null;const V=ve(L,L.timeline.currentTime);return V==null?null:V-D/L.animation.playbackRate})(u,u.holdTime)),u.holdTime=null)}Vt(u),u.previousCurrentTime=ve(u,u.proxy.currentTime),u.proxy.playState=="finished"?(u.finishedPromise||(u.finishedPromise=new Tn),u.finishedPromise.state=="pending"&&(y?Ro(u):Promise.resolve().then((()=>{Ro(u)})))):(u.finishedPromise&&u.finishedPromise.state=="resolved"&&(u.finishedPromise=new Tn),u.animation.playState!="paused"&&u.animation.pause())}function Ft(u){const f=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(u),y=f.delay+f.endDelay+f.iterations*f.duration;return Math.max(0,y)}function Vt(u){if(u.timeline)if(u.startTime!==null){const f=u.timeline.currentTime;if(f==null)return;ns(u,(ve(u,f)-u.startTime)*u.animation.playbackRate)}else u.holdTime!==null&&ns(u,u.holdTime)}function ns(u,f){const y=u.timeline,S=u.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;u.animation.currentTime=f+w}function is(u,f){if(!u.timeline)return;const y=u.proxy.playState=="paused"&&u.proxy.pending;let S=!1,w=ve(u,u.proxy.currentTime);Mn(u)==0&&w==null&&(u.holdTime=0),w==null&&(u.autoAlignStartTime=!0),(u.proxy.playState==="finished"||y)&&(u.holdTime=null,u.startTime=null,u.autoAlignStartTime=!0),u.holdTime&&(u.startTime=null),u.pendingTask&&(u.pendingTask=null,S=!0),(u.holdTime!==null||u.autoAlignStartTime||y||u.pendingPlaybackRate!==null)&&(u.readyPromise&&!S&&(u.readyPromise=null),Vt(u),u.readyPromise||Wn(u),u.pendingTask="play",Kr(u.timeline,u.animation,rs.bind(u.proxy)),Lt(u,!1,!1))}function rs(u){const f=q.get(this);if(!f)return;if(u==null)return void(f.proxy.playState!=="paused"&&f.animation.playState!="idle"&&f.animation.cancel());Hi(f),f.pendingTask&&requestAnimationFrame((()=>{f.pendingTask!=="play"||f.startTime===null&&f.holdTime===null?f.pendingTask==="pause"&&ko(f):Eo(f)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(f,u);ns(f,(S-ve(f,this.startTime))*this.playbackRate),Lt(f,!1,!1)}}function Oo(u){u.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(u=>{q=new WeakMap}),!1);let zo=new WeakMap;function Hi(u){if(!u.autoAlignStartTime||!u.timeline||!u.timeline.currentTime||u.proxy.playState==="idle"||u.proxy.playState==="paused"&&u.holdTime!==null)return;const f=u.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Io(k.timeline):k.animationRange.start;return Mo(k.timeline,B)})(u))}catch(k){y=CSS.percent(0),u.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const B=k.animationRange.end==="normal"?Bo(k.timeline):k.animationRange.end;return 1-Mo(k.timeline,B)})(u)))}catch(k){S=CSS.percent(100),u.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}u.rangeDuration=S.value-y.value;const w=Mn(u);u.startTime=ve(u,w>=0?y:S),u.holdTime=null,u.rangeDuration!==f&&Oo(u)}function qi(u){throw new Error("Unsupported timeline class")}function Io(u){return u instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:u instanceof Qe?CSS.percent(0):void qi()}function Bo(u){return u instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:u instanceof Qe?CSS.percent(100):void qi()}function rl(u,f){if(!f)return{start:"normal",end:"normal"};const y={start:Io(u),end:Bo(u)};if(u instanceof ViewTimeline){const S=Je(f),w=[],k=[];if(S.forEach((B=>{if(Wi.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${f}"`)}})),w.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return w.length&&(y.start.rangeName=w[0],y.end.rangeName=w.length>1?w[1]:w[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(u instanceof Qe){const S=f.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}qi()}function Xi(u,f,y){if(!f||f==="normal")return"normal";if(u instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(f instanceof Object)f.rangeName!==void 0&&(S=f.rangeName),f.offset!==void 0&&(w=f.offset);else{const k=Je(f);k.length===1?Wi.includes(k[0])?S=k[0]:w=ye(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],w=ye(CSSNumericValue.parse(k[1]),{}))}if(!Wi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(u instanceof Qe)return CSSNumericValue.parse(f);qi()}class Yi{constructor(f,y,S={}){const w=y instanceof Qe,k=f instanceof wo?f:new wo(f,w?void 0:y);zo.set(k,this),q.set(this,{animation:k,timeline:w?y:void 0,playState:w?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:w?rl(y,S["animation-range"]):null,proxy:this})}get effect(){const f=q.get(this);return f.timeline?(f.effect||(f.effect=(function(y){const S=y.animation.effect,w=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=an(y,H.localTime),H.endTime=an(y,H.endTime),H.activeDuration=an(y,H.activeDuration);const Y=Ft(y),de=H.iterations?(Y-H.delay-H.endDelay)/H.iterations:0;H.duration=Y?CSS.percent(X*de/Y):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},B={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Y=Object.assign({},y.specifiedTiming);if(Y.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Y.duration===null||Y.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Y.delay=0,Y.endDelay=0,X=Y.iterations?1e5:0,Y.duration=Y.iterations?(X-Y.delay-Y.endDelay)/Y.iterations:0,Y.duration<0&&(Y.duration=0,Y.endDelay=X-Y.delay),w.apply(S,[Y])),y.normalizedTiming=Y,y.specifiedTiming}},L={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Y=X[0],de=Y.duration;if(de===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Y.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");de!==void 0&&de!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),Oo(y)}}},D=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return D.getComputedTiming=new Proxy(S.getComputedTiming,k),D.getTiming=new Proxy(S.getTiming,B),D.updateTiming=new Proxy(S.updateTiming,L),D})(f)),f.effect):f.animation.effect}set effect(f){const y=q.get(this);y.animation.effect=f,y.effect=null,y.autoDurationEffect=null}get timeline(){const f=q.get(this);return f.timeline||f.animation.timeline}set timeline(f){const y=q.get(this),S=this.timeline;if(S==f)return;const w=this.playState,k=this.currentTime;let B,L=Ft(y);B=k===null?null:L===0?0:ve(y,k)/L;const D=S instanceof Qe,V=f instanceof Qe,H=this.pending;if(D&&Zr(y.timeline,y.animation),V)return y.timeline=f,kt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Wn(y),y.pendingTask="play",Kr(y.timeline,y.animation,rs.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*L),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||Wn(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Lt(y,!1,!1);if(y.animation.timeline!=f)throw TypeError("Unsupported timeline: "+f);if(Zr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Ft(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const f=q.get(this);return f.timeline?an(f,f.startTime):f.animation.startTime}set startTime(f){const y=q.get(this);if(f=ve(y,f),!y.timeline)return void(y.animation.startTime=f);y.autoAlignStartTime=!1,ve(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Vt(y));const S=ve(y,this.currentTime);kt(y),y.startTime=f,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1),Vt(y)}get currentTime(){const f=q.get(this);return f.timeline?f.holdTime!=null?an(f,f.holdTime):an(f,Ao(f)):f.animation.currentTime}set currentTime(f){const y=q.get(this);y.timeline?((function(S,w){if(w==null&&S.currentTime!==null)throw new TypeError;w=ve(S,w),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=w:S.startTime=ve(S,S.timeline.currentTime)-w/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,f),y.pendingTask=="pause"&&(y.holdTime=ve(y,f),kt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1)):y.animation.currentTime=f}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(f){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=f);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=f,S!==null&&(this.currentTime=S)}get playState(){const f=q.get(this);if(!f.timeline)return f.animation.playState;const y=ve(f,this.currentTime);return y===null&&f.startTime===null&&f.pendingTask==null?"idle":f.pendingTask=="pause"||f.startTime===null&&f.pendingTask!="play"?"paused":y!=null&&(f.animation.playbackRate>0&&y>=Ft(f)||f.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var f;return((f=q.get(this).animationRange)==null?void 0:f.start)??"normal"}set rangeStart(f){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=f;y.timeline instanceof Qe&&(y.animationRange.start=Xi(y.timeline,f,"start"),Hi(y),Vt(y))}get rangeEnd(){var f;return((f=q.get(this).animationRange)==null?void 0:f.end)??"normal"}set rangeEnd(f){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=f;y.timeline instanceof Qe&&(y.animationRange.end=Xi(y.timeline,f,"end"),Hi(y),Vt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const f=q.get(this);return f.timeline?!!f.readyPromise&&f.readyPromise.state=="pending":f.animation.pending}finish(){const f=q.get(this);if(!f.timeline)return void f.animation.finish();const y=Mn(f),S=Ft(f);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");kt(f);const w=y<0?0:S;this.currentTime=an(f,w);const k=ve(f,f.timeline.currentTime);f.startTime===null&&k!==null&&(f.startTime=k-w/f.animation.playbackRate),f.pendingTask=="pause"&&f.startTime!==null&&(f.holdTime=null,f.pendingTask=null,f.readyPromise.resolve(this)),f.pendingTask=="play"&&f.startTime!==null&&(f.pendingTask=null,f.readyPromise.resolve(this)),Lt(f,!0,!0)}play(){const f=q.get(this);f.timeline?is(f):f.animation.play()}pause(){const f=q.get(this);f.timeline?this.playState!="paused"&&(f.animation.currentTime===null&&(f.autoAlignStartTime=!0),f.pendingTask=="play"?f.pendingTask=null:f.readyPromise=null,f.readyPromise||Wn(f),f.pendingTask="pause",Kr(f.timeline,f.animation,rs.bind(f.proxy))):f.animation.pause()}reverse(){const f=q.get(this),y=Mn(f),S=ve(f,this.currentTime),w=Ft(f)==1/0,k=y!=0&&(y<0||S>0||!w);if(!f.timeline||!k)return k&&(f.pendingPlaybackRate=-Mn(f)),void f.animation.reverse();if(f.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),is(f)}updatePlaybackRate(f){const y=q.get(this);if(y.pendingPlaybackRate=f,!y.timeline)return void y.animation.updatePlaybackRate(f);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":kt(y);break;case"finished":const w=ve(y,y.timeline.currentTime),k=w!==null?(w-y.startTime)*y.animation.playbackRate:null;y.startTime=f==0?w:w!=null&&k!=null?(w-k)/f:null,kt(y),Lt(y,!1,!1),Vt(y);break;default:is(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(f){q.get(this).animation.id=f}cancel(){const f=q.get(this);f.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,kt(y),y.readyPromise.reject(Po()),Wn(y),y.readyPromise.resolve(y.proxy))})(f),f.finishedPromise&&f.finishedPromise.state=="pending"&&f.finishedPromise.reject(Po()),f.finishedPromise=new Tn,f.animation.cancel()),f.startTime=null,f.holdTime=null,Zr(f.timeline,f.animation)):f.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(f){q.get(this).animation.onfinish=f}get oncancel(){return q.get(this).animation.oncancel}set oncancel(f){q.get(this).animation.oncancel=f}get onremove(){return q.get(this).animation.onremove}set onremove(f){q.get(this).animation.onremove=f}get finished(){const f=q.get(this);return f.timeline?(f.finishedPromise||(f.finishedPromise=new Tn),f.finishedPromise.promise):f.animation.finished}get ready(){const f=q.get(this);return f.timeline?(f.readyPromise||(f.readyPromise=new Tn,f.readyPromise.resolve(this)),f.readyPromise.promise):f.animation.ready}addEventListener(f,y,S){q.get(this).animation.addEventListener(f,y,S)}removeEventListener(f,y,S){q.get(this).animation.removeEventListener(f,y,S)}dispatchEvent(f){q.get(this).animation.dispatchEvent(f)}}function sl(u,f){const y=f.timeline;y instanceof Qe&&delete f.timeline;const S=il.apply(this,[u,f]),w=new Yi(S,y);return y instanceof Qe&&(S.pause(),q.get(w).animationRange={start:Xi(y,f.rangeStart,"start"),end:Xi(y,f.rangeEnd,"end")},w.play()),w}function No(u){for(let f=0;f<u.length;++f){let y=zo.get(u[f]);y&&(u[f]=y)}return u}function ol(u){return No(nl.apply(this,[u]))}function al(u){return No(tl.apply(this,[u]))}const Ae={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Cn=["block","inline","x","y"],cl=["nearest","root","self"],Xt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(u,f,y){const S={sheetSrc:u,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const w=this.parseQualifiedRule(S);w&&(f?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(u,f){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(f.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==u))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(u,f){const y=this.anonymousScrollTimelineOptions.get(u);return y?{anonymousSource:y.source,anonymousTarget:f,source:bo(y.source??"nearest",f),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(u,f){const y=this.getAnonymousScrollTimelineOptions(u,f);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==u){const k=this.findPreviousSiblingOrAncestorMatchingSelector(f,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(u,f){let y=u;for(;y;){if(y.matches(f))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(u,f){const y=this.anonymousViewTimelineOptions.get(u);return y?{subject:f,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(u,f){const y=this.getAnonymousViewTimelineOptions(u,f);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==u){const k=this.findPreviousSiblingOrAncestorMatchingSelector(f,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(u,f){if(u.selector.includes("@keyframes"))return;const y=u.block.contents.includes("animation-name:"),S=u.block.contents.includes("animation-timeline:"),w=u.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(u),this.saveSubjectSelectorToViewTimeline(u),!S&&!y&&!w)return;let k=[],B=[],L=!1;S&&(k=this.extractScrollTimelineNames(u.block.contents)),y&&(B=this.extractMatches(u.block.contents,Ae.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(u.block.contents,Ae.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(u.block.contents=u.block.contents.replace("auto"," ")),u.block.contents=u.block.contents.replace(D," 1s "+D),L=!0))})),L&&this.replacePart(u.block.startIndex,u.block.endIndex,u.block.contents,f)),this.saveRelationInList(u,k,B)}saveSourceSelectorToScrollTimeline(u){const f=u.block.contents.includes("scroll-timeline:"),y=u.block.contents.includes("scroll-timeline-name:"),S=u.block.contents.includes("scroll-timeline-axis:");if(!f&&!y)return;let w=[];if(f){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE);for(const L of B){const D=this.split(L);let V={selector:u.selector,name:""};D.length==1?V.name=D[0]:D.length==2&&(Cn.includes(D[0])?(V.axis=D[0],V.name=D[1]):(V.axis=D[1],V.name=D[0])),w.push(V)}}if(y){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE_NAME);for(let L=0;L<B.length;L++)if(L<w.length)w[L].name=B[L];else{let D={selector:u.selector,name:B[L]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(u.block.contents,Ae.SCROLL_TIMELINE_AXIS);if(k=B.filter((L=>Cn.includes(L))),k.length!=B.length)throw new Error("Invalid axis")}for(let B=0;B<w.length;B++)k.length&&(w[B].axis=k[B%w.length]);this.sourceSelectorToScrollTimeline.push(...w)}saveSubjectSelectorToViewTimeline(u){const f=u.block.contents.includes("view-timeline:"),y=u.block.contents.includes("view-timeline-name:"),S=u.block.contents.includes("view-timeline-axis:"),w=u.block.contents.includes("view-timeline-inset:");if(!f&&!y)return;let k=[];if(f){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let X={selector:u.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(Cn.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_NAME);for(let V=0;V<D.length;V++)if(V<k.length)k[V].name=D[V];else{let H={selector:u.selector,name:D[V],inset:null};k.push(H)}}let B=[],L=[];if(w&&(B=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(u.block.contents,Ae.VIEW_TIMELINE_AXIS);if(L=D.filter((V=>Cn.includes(V))),L.length!=D.length)throw new Error("Invalid axis")}for(let D=0;D<k.length;D++)B.length&&(k[D].inset=B[D%k.length]),L.length&&(k[D].axis=L[D%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(u){return u.split(" ").filter((f=>{return y=f,Ae.TIME.exec(y);var y})).length>=1}hasAutoDuration(u){return u.split(" ").filter((f=>f==="auto")).length>=1}saveRelationInList(u,f,y){let S=[];u.block.contents.includes("animation-range:")&&(S=this.extractMatches(u.block.contents,Ae.ANIMATION_TIME_RANGE));const w=Math.max(f.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:u.selector,"animation-timeline":f[k%f.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(u){const f=Ae.ANIMATION_TIMELINE.exec(u)[1].trim(),y=[];return f.split(",").map((S=>S.trim())).forEach((S=>{if((function(w){return(w.startsWith("scroll")||w.startsWith("view"))&&w.includes("(")})(S)){const w=this.saveAnonymousTimelineName(S);y.push(w)}else y.push(S)})),y}saveAnonymousTimelineName(u){const f=":t"+this.nextAnonymousTimelineNameIndex++;return u.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(f,this.parseAnonymousScrollTimeline(u)):this.anonymousViewTimelineOptions.set(f,this.parseAnonymousViewTimeline(u)),f}parseAnonymousScrollTimeline(u){const f=Ae.ANONYMOUS_SCROLL_TIMELINE.exec(u);if(!f)return null;const y=f[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:cl.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(u){const f=Ae.ANONYMOUS_VIEW_TIMELINE.exec(u);if(!f)return null;const y=f[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(u){return this.findMatchingEntryInContainer(u,this.keyframeNamesSelectors)}findMatchingEntryInContainer(u,f){const y=u.split(" ").filter((S=>f.has(S)));return y?y[0]:null}parseIdentifier(u){Ae.IDENTIFIER.lastIndex=u.index;const f=Ae.IDENTIFIER.exec(u.sheetSrc);if(!f)throw this.parseError(u,"Expected an identifier");return u.index+=f[0].length,f[0]}parseKeyframesAndSaveNameMapping(u,f){if(u.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(u,f);u.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(u,f){function y(D){return Wi.some((V=>D.startsWith(V)))}const S=u.block.contents,w=(function(D){let V=0,H=-1,X=-1;const Y=[];for(let de=0;de<D.length;de++)D[de]=="{"?V++:D[de]=="}"&&V--,V==1&&D[de]!="{"&&D[de]!="}"&&H==-1&&(H=de),V==2&&D[de]=="{"&&(X=de,Y.push({start:H,end:X}),H=X=-1);return Y})(S);if(w.length==0)return new Map;const k=new Map;let B=!1;const L=[];L.push(S.substring(0,w[0].start));for(let D=0;D<w.length;D++){const V=S.substring(w[D].start,w[D].end);let H=[];V.split(",").forEach((X=>{const Y=X.split(" ").map((Te=>Te.trim())).filter((Te=>Te!="")).join(" "),de=k.size;k.set(de,Y),H.push(`${de}%`),y(Y)&&(B=!0)})),L.push(H.join(",")),D==w.length-1?L.push(S.substring(w[D].end)):L.push(S.substring(w[D].end,w[D+1].start))}return B?(u.block.contents=L.join(""),this.replacePart(u.block.startIndex,u.block.endIndex,u.block.contents,f),k):new Map}parseQualifiedRule(u){const f=u.index,y=this.parseSelector(u).trim();if(y)return{selector:y,block:this.eatBlock(u),startIndex:f,endIndex:u.index}}removeEnclosingDoubleQuotes(u){let f=u[0]=='"'?1:0,y=u[u.length-1]=='"'?u.length-1:u.length;return u.substring(f,y)}assertString(u,f){if(u.sheetSrc.substr(u.index,f.length)!=f)throw this.parseError(u,`Did not find expected sequence ${f}`);u.index+=f.length}replacePart(u,f,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,u)+y+S.sheetSrc.slice(f),S.index>=f){const w=S.index-f;S.index=u+y.length+w}}eatComment(u){this.assertString(u,"/*"),this.eatUntil("*/",u,!0),this.assertString(u,"*/")}eatBlock(u){const f=u.index;this.assertString(u,"{");let y=1;for(;y!=0;)this.lookAhead("/*",u)?this.eatComment(u):(u.sheetSrc[u.index]==="{"?y++:u.sheetSrc[u.index]==="}"&&y--,this.advance(u));const S=u.index;return{startIndex:f,endIndex:S,contents:u.sheetSrc.slice(f,S)}}advance(u){if(u.index++,u.index>u.sheetSrc.length)throw this.parseError(u,"Advanced beyond the end")}parseError(u,f){return Error(`(${u.name?u.name:"<anonymous file>"}): ${f}`)}eatUntil(u,f,y=!1){const S=f.index;for(;!this.lookAhead(u,f);)this.advance(f);return y&&(f.sheetSrc=f.sheetSrc.slice(0,S)+" ".repeat(f.index-S)+f.sheetSrc.slice(f.index)),f.sheetSrc.slice(S,f.index)}parseSelector(u){let f=u.index;if(this.eatUntil("{",u),f===u.index)throw Error("Empty selector");return u.sheetSrc.slice(f,u.index)}eatWhitespace(u){Ae.WHITE_SPACE.lastIndex=u.index;const f=Ae.WHITE_SPACE.exec(u.sheetSrc);f&&(u.index+=f[0].length)}lookAhead(u,f){return f.sheetSrc.substr(f.index,u.length)==u}peek(u){return u.sheetSrc[u.index]}extractMatches(u,f,y=","){return f.exec(u)[1].trim().split(y).map((S=>S.trim()))}split(u){return u.split(" ").map((f=>f.trim())).filter((f=>f!=""))}};function ll(u,f,y,S,w,k){const B=Xr(f),L=Yr(f,y);return Co(ts(u,B,L,S,w),k,ts("cover",B,L,S,w),y)}function ul(u,f,y){const S=Xt.getAnimationTimelineOptions(f,y);if(!S)return null;const w=S["animation-timeline"];if(!w)return null;let k=Xt.getScrollTimelineOptions(w,y)||Xt.getViewTimelineOptions(w,y);return k?(k.subject&&(function(B,L){const D=es(L.subject),V=L.axis||L.axis;function H(Y,de){let Te=null;for(const[st,Mt]of Y)if(st==100*de.offset){if(Mt=="from")Te=0;else if(Mt=="to")Te=100;else{const dt=Mt.split(" ");Te=dt.length==1?parseFloat(dt[0]):100*ll(dt[0],D,L.subject,V,L.inset,CSS.percent(parseFloat(dt[1])))}break}return Te}const X=Xt.keyframeNamesSelectors.get(B.animationName);if(X&&X.size){const Y=[];B.effect.getKeyframes().forEach((Te=>{const st=H(X,Te);st!==null&&st>=0&&st<=100&&(Te.offset=st/100,Y.push(Te))}));const de=Y.sort(((Te,st)=>Te.offset<st.offset?-1:Te.affset>st.offset?1:0));B.effect.setKeyframes(de)}})(u,k),{timeline:k.source?new Qe(k):new bn(k),animOptions:S}):null}function hl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function f(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let w=Xt.transpileStyleSheet(S.innerHTML,!0);w=Xt.transpileStyleSheet(w,!1),S.innerHTML=w}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async w=>{const k=await w.text();let B=Xt.transpileStyleSheet(k,!0);if(B=Xt.transpileStyleSheet(k,!1),B!=k){const L=new Blob([B],{type:"text/css"}),D=URL.createObjectURL(L);S.setAttribute("href",D)}}))}new MutationObserver((S=>{for(const w of S)for(const k of w.addedNodes)k instanceof HTMLStyleElement&&f(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>f(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const u=CSS.supports;CSS.supports=f=>(f=f.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),u(f)),window.addEventListener("animationstart",(f=>{f.target.getAnimations().filter((y=>y.animationName===f.animationName)).forEach((y=>{const S=ul(y,y.animationName,f.target);if(S)if(!S.timeline||y instanceof Yi)y.timeline=S.timeline;else{const w=new Yi(y,S.timeline,S.animOptions);y.pause(),w.play()}}))}))}(function(){if(!hl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:Qe}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:bn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:sl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Yi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:ol}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:al}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const Vf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Jf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BatchedParticleRenderer=Vu;exports.Builder=no;exports.ByteBuffer=li;exports.ConstantColor=vn;exports.ConstantValue=ee;exports.Matrix4=Et;exports.MeshBVH=Vn;exports.MotionController=Ol;exports.ParticleSystem=Ur;exports.SIZE_PREFIX_LENGTH=Ga;exports.TrailParticle=Br;exports.Vector4=at;exports.WorkerBase=zf;exports.__viteBrowserExternal=Jf;exports.bundler=Th;exports.createNoise4D=ju;exports.fetchProfile=Pl;exports.index=wh;exports.index$1=Of;exports.index$2=Df;exports.scrollTimeline=Vf;exports.v5=Cl;
|