@needle-tools/engine 4.12.0-next.de80571 → 4.12.0-next.f546e2b
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/CHANGELOG.md +1 -1
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-iyfPIK6R.js +21 -0
- package/dist/{gltf-progressive-DZrY8VT6.min.js → gltf-progressive-BmSygnAC.min.js} +2 -2
- package/dist/{gltf-progressive-DgYz5BYa.js → gltf-progressive-DnLBuGK5.js} +24 -24
- package/dist/{gltf-progressive-DWcmTMCh.umd.cjs → gltf-progressive-Rs-ojtXy.umd.cjs} +1 -1
- package/dist/{loader.worker-Dip-PthR.js → loader.worker-DWzfDpAl.js} +4 -4
- package/dist/{needle-engine.bundle-S3PalR7r.min.js → needle-engine.bundle-BcsvlMBI.min.js} +150 -151
- package/dist/needle-engine.bundle-Dw_P6rEZ.umd.cjs +1646 -0
- package/dist/{needle-engine.bundle-CbrIHiN8.js → needle-engine.bundle-qhXfGDpR.js} +8564 -8382
- package/dist/needle-engine.d.ts +108 -43
- package/dist/needle-engine.js +4 -4
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-DYDtB188.min.js → postprocessing-B5ksn9-G.min.js} +54 -54
- package/dist/{postprocessing-CMgoN5t5.umd.cjs → postprocessing-DZtb9Nnn.umd.cjs} +81 -81
- package/dist/{postprocessing-BTW9pD_s.js → postprocessing-__7s9wON.js} +450 -441
- package/dist/{three-DfMvBzXi.js → three-BCCkyCA5.js} +1 -7
- package/dist/{three-qj71I7J3.umd.cjs → three-Bf2NBxAw.umd.cjs} +2 -2
- package/dist/{three-B7CT31Bt.min.js → three-W7zWTcfP.min.js} +1 -1
- package/dist/{three-examples-CsW4_6LI.umd.cjs → three-examples-Dho7cuu4.umd.cjs} +4 -4
- package/dist/{three-examples-D1P7eEhn.min.js → three-examples-MsJjauyk.min.js} +10 -10
- package/dist/{three-examples-D1SK93ek.js → three-examples-y2GeYlze.js} +2 -20
- package/dist/{three-mesh-ui-C_uSB5dD.js → three-mesh-ui-3nSSizT4.js} +1 -1
- package/dist/{three-mesh-ui-LQ44s0AL.min.js → three-mesh-ui-CIez6qJQ.min.js} +1 -1
- package/dist/{three-mesh-ui-DpATDXwU.umd.cjs → three-mesh-ui-zsOOA5Pq.umd.cjs} +1 -1
- package/dist/{vendor-D0zoswDa.js → vendor-DMZcbVO1.js} +3707 -3527
- package/dist/vendor-sURMCFSI.min.js +1116 -0
- package/dist/{vendor-UCpFAwt1.umd.cjs → vendor-tyBvnMF-.umd.cjs} +39 -39
- package/lib/engine/codegen/register_types.js +0 -2
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_console.js +403 -1
- package/lib/engine/debug/debug_console.js.map +1 -1
- package/lib/engine/engine_components.js +3 -3
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_input.d.ts +5 -0
- package/lib/engine/engine_input.js +6 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_license.js +3 -9
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_networking.js +5 -5
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics_rapier.js +1 -1
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +4 -1
- package/lib/engine/engine_utils.js +28 -4
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +29 -7
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/webcomponents/WebXRButtons.js +13 -5
- package/lib/engine/webcomponents/WebXRButtons.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -5
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js +4 -0
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +1 -1
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +1 -1
- package/lib/engine/xr/NeedleXRSession.js +67 -24
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +12 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine/xr/usdz.js +6 -2
- package/lib/engine/xr/usdz.js.map +1 -1
- package/lib/engine-components/AlignmentConstraint.d.ts +1 -1
- package/lib/engine-components/AlignmentConstraint.js +1 -1
- package/lib/engine-components/Animation.d.ts +1 -1
- package/lib/engine-components/Animation.js +1 -1
- package/lib/engine-components/Animator.d.ts +1 -1
- package/lib/engine-components/Animator.js +1 -1
- package/lib/engine-components/AudioListener.d.ts +1 -1
- package/lib/engine-components/AudioListener.js +1 -1
- package/lib/engine-components/AudioSource.d.ts +1 -1
- package/lib/engine-components/AudioSource.js +1 -1
- package/lib/engine-components/Camera.d.ts +1 -1
- package/lib/engine-components/Camera.js +1 -1
- package/lib/engine-components/CharacterController.d.ts +6 -2
- package/lib/engine-components/CharacterController.js +6 -2
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +1 -1
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +2 -1
- package/lib/engine-components/Component.js +3 -2
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.js +3 -0
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +14 -0
- package/lib/engine-components/Joints.js +14 -0
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/LookAtConstraint.d.ts +1 -1
- package/lib/engine-components/LookAtConstraint.js +1 -1
- package/lib/engine-components/OrbitControls.d.ts +1 -1
- package/lib/engine-components/OrbitControls.js +1 -1
- package/lib/engine-components/Renderer.d.ts +6 -0
- package/lib/engine-components/Renderer.js +6 -0
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RendererInstancing.js +5 -3
- package/lib/engine-components/RendererInstancing.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +18 -14
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js +15 -7
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SpriteRenderer.d.ts +2 -1
- package/lib/engine-components/SpriteRenderer.js +2 -1
- package/lib/engine-components/SpriteRenderer.js.map +1 -1
- package/lib/engine-components/api.d.ts +1 -0
- package/lib/engine-components/api.js +1 -0
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +0 -1
- package/lib/engine-components/codegen/components.js +0 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.d.ts +1 -1
- package/lib/engine-components/timeline/SignalAsset.js +1 -1
- package/lib/engine-components/ui/Raycaster.d.ts +3 -2
- package/lib/engine-components/ui/Raycaster.js +3 -2
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +6 -0
- package/lib/engine-components/ui/RectTransform.js +6 -0
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +2 -1
- package/lib/engine-components/utils/LookAt.js +2 -1
- package/lib/engine-components/utils/LookAt.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +1 -1
- package/lib/engine-components/web/CursorFollow.js +1 -1
- package/lib/engine-components/web/HoverAnimation.d.ts +1 -1
- package/lib/engine-components/web/HoverAnimation.js +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +1 -1
- package/lib/engine-components/web/ViewBox.js +1 -1
- package/lib/engine-components/webxr/Avatar.js +2 -0
- package/lib/engine-components/webxr/Avatar.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.js +18 -12
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/package.json +3 -3
- package/plugins/vite/poster-client.js +8 -1
- package/src/engine/codegen/register_types.ts +0 -2
- package/src/engine/debug/debug_console.ts +449 -1
- package/src/engine/engine_components.ts +4 -4
- package/src/engine/engine_input.ts +7 -0
- package/src/engine/engine_license.ts +3 -8
- package/src/engine/engine_networking.ts +5 -5
- package/src/engine/engine_physics.ts +3 -3
- package/src/engine/engine_physics_rapier.ts +1 -1
- package/src/engine/engine_utils.ts +23 -4
- package/src/engine/extensions/extensions.ts +30 -6
- package/src/engine/webcomponents/WebXRButtons.ts +15 -5
- package/src/engine/webcomponents/needle menu/needle-menu.ts +4 -5
- package/src/engine/webcomponents/needle-engine.ar-overlay.ts +6 -0
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/NeedleXRSession.ts +78 -27
- package/src/engine/xr/TempXRContext.ts +12 -2
- package/src/engine/xr/usdz.ts +6 -1
- package/src/engine-components/AlignmentConstraint.ts +1 -1
- package/src/engine-components/Animation.ts +1 -1
- package/src/engine-components/Animator.ts +1 -1
- package/src/engine-components/AudioListener.ts +1 -1
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/Camera.ts +1 -1
- package/src/engine-components/CharacterController.ts +6 -2
- package/src/engine-components/Collider.ts +1 -1
- package/src/engine-components/Component.ts +5 -4
- package/src/engine-components/DragControls.ts +4 -0
- package/src/engine-components/Joints.ts +14 -0
- package/src/engine-components/LookAtConstraint.ts +1 -1
- package/src/engine-components/OrbitControls.ts +1 -1
- package/src/engine-components/Renderer.ts +6 -0
- package/src/engine-components/RendererInstancing.ts +6 -3
- package/src/engine-components/SceneSwitcher.ts +17 -17
- package/src/engine-components/SpectatorCamera.ts +21 -10
- package/src/engine-components/SpriteRenderer.ts +2 -1
- package/src/engine-components/api.ts +2 -1
- package/src/engine-components/codegen/components.ts +0 -1
- package/src/engine-components/timeline/SignalAsset.ts +1 -1
- package/src/engine-components/ui/Raycaster.ts +3 -2
- package/src/engine-components/ui/RectTransform.ts +6 -0
- package/src/engine-components/utils/LookAt.ts +2 -1
- package/src/engine-components/web/CursorFollow.ts +1 -1
- package/src/engine-components/web/HoverAnimation.ts +1 -1
- package/src/engine-components/web/ViewBox.ts +1 -1
- package/src/engine-components/webxr/Avatar.ts +4 -0
- package/src/engine-components/webxr/WebXR.ts +19 -11
- package/dist/generateMeshBVH.worker-mO20N_b8.js +0 -21
- package/dist/needle-engine.bundle-BGixCtrn.umd.cjs +0 -1647
- package/dist/vendor-BKGa4GE0.min.js +0 -1116
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const R=require("./three-qj71I7J3.umd.cjs"),Ae={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function qa(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function gl(r){return await qa(`${r}/profilesList.json`)}async function vl(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await gl(e);let s;if(r.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await qa(s.profilePath);let o;if(n){let c;if(r.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[r.handedness],!c)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const Sl={xAxis:0,yAxis:0,button:0,state:Ae.ComponentState.DEFAULT};function xl(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const a=Math.atan2(e,r);t=Math.cos(a),n=Math.sin(a)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class _l{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ae.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Sl)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=xl(e,t);switch(this.componentProperty){case Ae.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case Ae.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case Ae.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case Ae.ComponentProperty.STATE:this.valueNodeProperty===Ae.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class bl{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(n=>{const i=new _l(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ae.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=Ae.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Ae.ComponentState.PRESSED:(t.touched||this.values.button>Ae.ButtonTouchThreshold)&&(this.values.state=Ae.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Ae.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Ae.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class Tl{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new bl(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const rs=2,At=4,jt=4,Xa=4,Zt=new Int32Array(2),Do=new Float32Array(Zt.buffer),Fo=new Float64Array(Zt.buffer),Zi=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class $t{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?$t.ZERO:new $t(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}$t.ZERO=new $t(0,0);var Bs;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Bs||(Bs={}));class ai{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new ai(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new $t(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new $t(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Zt[0]=this.readInt32(e),Do[0]}readFloat64(e){return Zt[Zi?0:1]=this.readInt32(e),Zt[Zi?1:0]=this.readInt32(e+4),Fo[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){Do[0]=t,this.writeInt32(e,Zt[0])}writeFloat64(e,t){Fo[0]=t,this.writeInt32(e,Zt[Zi?0:1]),this.writeInt32(e+4,Zt[Zi?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+At+jt)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<jt;t++)e+=String.fromCharCode(this.readInt8(this.position_+At+t));return e}__offset(e,t){const n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const n=this.readInt32(e);let i="",s=0;if(e+=At,t===Bs.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;s<n;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+At}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let t=0;t<jt;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+At+t))return!1;return!0}createLong(e,t){return $t.create(e,t)}createScalarList(e,t){const n=[];for(let i=0;i<t;++i)e(i)!==null&&n.push(e(i));return n}createObjList(e,t){const n=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&n.push(s.unpack())}return n}}class io{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=ai.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const n=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<n+e+t;){const i=this.bb.capacity();this.bb=io.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=t<<1,i=ai.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(At,0),this.writeInt32(this.offset()-e+At)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(n+i)*rs;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=rs;l<s;l+=rs)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){const i=n?Xa:0;if(t){const s=t;if(this.prep(this.minalign,At+jt+i),s.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let a=jt-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,At+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const n=this.bb.capacity()-e,i=n-this.bb.readInt32(n);if(!(this.bb.readInt16(i+t)!=0))throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(At,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let n=0;for(;n<e.length;){let i;const s=e.charCodeAt(n++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(n++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let n=0,i=this.space,s=this.bb.bytes();n<t.length;n++)s[i++]=t[n];return this.endVector()}createLong(e,t){return $t.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let n=0;n<e.length;++n){const i=e[n];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function Fr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ss={exports:{}},Lo;function Vo(){return Lo||(Lo=1,(function(r){var e={};e.useBlobBuilder=(function(){try{return new Blob([]),!1}catch{return!0}})(),e.useArrayBufferView=!e.useBlobBuilder&&(function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}})(),r.exports.binaryFeatures=e;var t=r.exports.BlobBuilder;typeof window<"u"&&(t=r.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function n(){this._pieces=[],this._parts=[]}n.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},n.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},n.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=n})(ss)),ss.exports}var os,Jo;function Ml(){if(Jo)return os;Jo=1;var r=Vo().BufferBuilder,e=Vo().binaryFeatures,t={unpack:function(o){var c=new n(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};os=t;function n(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}n.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},n.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},n.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},n.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},n.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},n.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},n.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},n.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},n.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},n.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},n.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",f,p;l<o;)f=c[l],f<128?(u+=String.fromCharCode(f),l++):(f^192)<32?(p=(f^192)<<6|c[l+1]&63,u+=String.fromCharCode(p),l+=2):(p=(f&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(p),l+=3);return this.index+=o,u},n.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},n.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),f=this.unpack();c[u]=f}return c},n.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},n.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,f=o&1048575|1048576,p=f*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*p},n.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new r}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,f=Math.floor(u*Math.pow(2,52)),p=Math.pow(2,32),m=c<<31|l+1023<<20|f/p&1048575,x=f%p;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(x)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return os}var Cl=Ml();const jo=Fr(Cl);let Ya=!0,Za=!0;function Qn(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Un(r,e,t){if(!r.RTCPeerConnection)return;const n=r.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const u=t(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=n.removeEventListener;n.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(n,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function wl(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Ya=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Pl(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Za=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function ro(){if(typeof window=="object"){if(Ya)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Lr(r,e){Za&&console.warn(r+" is deprecated, please use "+e+" instead.")}function El(r){const e={browser:null,version:null};if(typeof r>"u"||!r.navigator)return e.browser="Not a browser.",e;const{navigator:t}=r;if(t.mozGetUserMedia)e.browser="firefox",e.version=Qn(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=Qn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=Qn(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Qn(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function Go(r){return Object.prototype.toString.call(r)==="[object Object]"}function Ka(r){return Go(r)?Object.keys(r).reduce(function(e,t){const n=Go(r[t]),i=n?Ka(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function Ns(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Ns(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{Ns(r,r.get(i),t)})}))}function $o(r,e,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return r.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{r.forEach(o=>{o.type===n&&o.trackId===a.id&&Ns(r,o,i)})}),i}const Wo=ro;function Qa(r,e){const t=r&&r.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const f=function(p,m){return p?p+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let p={};typeof u.ideal=="number"?(p[f("min",l)]=u.ideal,c.optional.push(p),p={},p[f("max",l)]=u.ideal,c.optional.push(p)):(p[f("",l)]=u.ideal,c.optional.push(p))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[f("",l)]=u.exact):["min","max"].forEach(p=>{u[p]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[f(p,l)]=u[p])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,f,p){f in u&&!(p in u)&&(u[p]=u[f],delete u[f])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let f;if(l.exact==="environment"||l.ideal==="environment"?f=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(f=["front"]),f)return t.mediaDevices.enumerateDevices().then(p=>{p=p.filter(x=>x.kind==="videoinput");let m=p.find(x=>f.some(M=>x.label.toLowerCase().includes(M)));return!m&&p.length&&f.includes("back")&&(m=p[p.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),Wo("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return Wo("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,u=>{t.webkitGetUserMedia(u,c,f=>{l&&l(s(f))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(f=>{f.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function kl(r,e){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(n){return e(n).then(i=>{const s=n.video&&n.video.width,a=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:o||3}},s&&(n.video.mandatory.maxWidth=s),a&&(n.video.mandatory.maxHeight=a),r.navigator.mediaDevices.getUserMedia(n)})}}}function ec(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function tc(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):s={track:i.track};const a=new Event("track");a.track=i.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)}),n.stream.getTracks().forEach(i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.id):s={track:i};const a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Un(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function nc(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(o,c){let l=i.apply(this,arguments);return l||(l=e(this,o),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function ic(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[n,i,s]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const a=function(c){const l={};return c.result().forEach(f=>{const p={id:f.id,timestamp:f.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[f.type]||f.type};f.names().forEach(m=>{p[m]=f.stat(m)}),l[p.id]=p}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){i(o(a(l)))};return e.apply(this,[c,n])}return new Promise((c,l)=>{e.apply(this,[function(u){c(o(a(u)))},l])}).then(i,s)}}function rc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const t=r.RTCPeerConnection.prototype.getSenders;t&&(r.RTCPeerConnection.prototype.getSenders=function(){const s=t.apply(this,[]);return s.forEach(a=>a._pc=this),s});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=n.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>$o(a,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i}),Un(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>$o(s,i.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const n=arguments[0];let i,s,a;return this.getSenders().forEach(o=>{o.track===n&&(i?a=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(s?a=!0:s=o),o.track===n)),a||i&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function sc(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function oc(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return sc(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=t.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(f=>this._reverseStreams[f.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(f=>{if(this.getSenders().find(m=>m.track===f))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const f=new r.MediaStream(u.getTracks());this._streams[u.id]=f,this._reverseStreams[f.id]=u,u=f}n.apply(this,[u])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},r.RTCPeerConnection.prototype.addTrack=function(u,f){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const p=[].slice.call(arguments,1);if(p.length!==1||!p[0].getTracks().find(M=>M===u))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(M=>M.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const x=this._streams[f.id];if(x)x.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const M=new r.MediaStream([u]);this._streams[f.id]=M,this._reverseStreams[M.id]=f,this.addStream(M)}return this.getSenders().find(M=>M.track===u)};function s(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],x=l._streams[m.id];f=f.replace(new RegExp(x.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:f})}function a(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],x=l._streams[m.id];f=f.replace(new RegExp(m.id,"g"),x.id)}),new RTCSessionDescription({type:u.type,sdp:f})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],f={[l](){const p=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[x=>{const M=s(this,x);p[0].apply(null,[M])},x=>{p[1]&&p[1].apply(null,x)},arguments[2]]):u.apply(this,arguments).then(x=>s(this,x))}};r.RTCPeerConnection.prototype[l]=f[l]});const o=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),r.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let p;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(M=>u.track===M)&&(p=this._streams[m])}),p&&(p.getTracks().length===1?this.removeStream(this._reverseStreams[p.id]):p.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Us(r,e){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]})}function ac(r,e){Un(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Ho=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:ac,shimAddTrackRemoveTrack:oc,shimAddTrackRemoveTrackWithNative:sc,shimGetDisplayMedia:kl,shimGetSendersWithDtmf:nc,shimGetStats:ic,shimGetUserMedia:Qa,shimMediaStream:ec,shimOnTrack:tc,shimPeerConnection:Us,shimSenderReceiverGetStats:rc},Symbol.toStringTag,{value:"Module"}));function Rl(r,e){let t=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(n=>{if(n&&(n.urls||n.url)){let i=n.urls||n.url;n.url&&!n.urls&&Lr("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete n.url,n.urls=s?i[0]:i,!!i.length}})}var as={exports:{}},qo;function cc(){return qo||(qo=1,(function(r){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
1
|
+
"use strict";const A=require("./three-Bf2NBxAw.umd.cjs"),ze={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function Qa(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function Cl(r){return await Qa(`${r}/profilesList.json`)}async function wl(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await Cl(e);let s;if(r.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await Qa(s.profilePath);let o;if(n){let c;if(r.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[r.handedness],!c)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const Pl={xAxis:0,yAxis:0,button:0,state:ze.ComponentState.DEFAULT};function El(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const a=Math.atan2(e,r);t=Math.cos(a),n=Math.sin(a)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class kl{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===ze.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Pl)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=El(e,t);switch(this.componentProperty){case ze.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case ze.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case ze.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case ze.ComponentProperty.STATE:this.valueNodeProperty===ze.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class Rl{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(n=>{const i=new kl(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:ze.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=ze.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=ze.ComponentState.PRESSED:(t.touched||this.values.button>ze.ButtonTouchThreshold)&&(this.values.state=ze.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===ze.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>ze.AxisTouchThreshold&&(this.values.state=ze.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===ze.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>ze.AxisTouchThreshold&&(this.values.state=ze.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class Al{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new Rl(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const as=2,zt=4,$t=4,ec=4,Qt=new Int32Array(2),Go=new Float32Array(Qt.buffer),$o=new Float64Array(Qt.buffer),Ki=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class Ht{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?Ht.ZERO:new Ht(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}Ht.ZERO=new Ht(0,0);var Ds;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Ds||(Ds={}));class li{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new li(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new Ht(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new Ht(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Qt[0]=this.readInt32(e),Go[0]}readFloat64(e){return Qt[Ki?0:1]=this.readInt32(e),Qt[Ki?1:0]=this.readInt32(e+4),$o[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){Go[0]=t,this.writeInt32(e,Qt[0])}writeFloat64(e,t){$o[0]=t,this.writeInt32(e,Qt[Ki?0:1]),this.writeInt32(e+4,Qt[Ki?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+zt+$t)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<$t;t++)e+=String.fromCharCode(this.readInt8(this.position_+zt+t));return e}__offset(e,t){const n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const n=this.readInt32(e);let i="",s=0;if(e+=zt,t===Ds.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;s<n;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+zt}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=$t)throw new Error("FlatBuffers: file identifier must be length "+$t);for(let t=0;t<$t;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+zt+t))return!1;return!0}createLong(e,t){return Ht.create(e,t)}createScalarList(e,t){const n=[];for(let i=0;i<t;++i)e(i)!==null&&n.push(e(i));return n}createObjList(e,t){const n=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&n.push(s.unpack())}return n}}class ao{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=li.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const n=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<n+e+t;){const i=this.bb.capacity();this.bb=ao.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=t<<1,i=li.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(zt,0),this.writeInt32(this.offset()-e+zt)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(n+i)*as;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=as;l<s;l+=as)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){const i=n?ec:0;if(t){const s=t;if(this.prep(this.minalign,zt+$t+i),s.length!=$t)throw new Error("FlatBuffers: file identifier must be length "+$t);for(let a=$t-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,zt+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const n=this.bb.capacity()-e,i=n-this.bb.readInt32(n);if(!(this.bb.readInt16(i+t)!=0))throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(zt,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let n=0;for(;n<e.length;){let i;const s=e.charCodeAt(n++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(n++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let n=0,i=this.space,s=this.bb.bytes();n<t.length;n++)s[i++]=t[n];return this.endVector()}createLong(e,t){return Ht.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let n=0;n<e.length;++n){const i=e[n];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function Vr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cs={exports:{}},Wo;function Ho(){return Wo||(Wo=1,(function(r){var e={};e.useBlobBuilder=(function(){try{return new Blob([]),!1}catch{return!0}})(),e.useArrayBufferView=!e.useBlobBuilder&&(function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}})(),r.exports.binaryFeatures=e;var t=r.exports.BlobBuilder;typeof window<"u"&&(t=r.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function n(){this._pieces=[],this._parts=[]}n.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},n.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},n.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=n})(cs)),cs.exports}var ls,qo;function Ol(){if(qo)return ls;qo=1;var r=Ho().BufferBuilder,e=Ho().binaryFeatures,t={unpack:function(o){var c=new n(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};ls=t;function n(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}n.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},n.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},n.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},n.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},n.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},n.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},n.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},n.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},n.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},n.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},n.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",f,p;l<o;)f=c[l],f<128?(u+=String.fromCharCode(f),l++):(f^192)<32?(p=(f^192)<<6|c[l+1]&63,u+=String.fromCharCode(p),l+=2):(p=(f&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(p),l+=3);return this.index+=o,u},n.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},n.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),f=this.unpack();c[u]=f}return c},n.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},n.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,f=o&1048575|1048576,p=f*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*p},n.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new r}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,f=Math.floor(u*Math.pow(2,52)),p=Math.pow(2,32),m=c<<31|l+1023<<20|f/p&1048575,x=f%p;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(x)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return ls}var zl=Ol();const Xo=Vr(zl);let tc=!0,nc=!0;function ii(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Jn(r,e,t){if(!r.RTCPeerConnection)return;const n=r.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const u=t(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=n.removeEventListener;n.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(n,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function Il(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(tc=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Bl(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(nc=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function co(){if(typeof window=="object"){if(tc)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Jr(r,e){nc&&console.warn(r+" is deprecated, please use "+e+" instead.")}function Nl(r){const e={browser:null,version:null};if(typeof r>"u"||!r.navigator)return e.browser="Not a browser.",e;const{navigator:t}=r;if(t.mozGetUserMedia)e.browser="firefox",e.version=ii(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=ii(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=ii(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=ii(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function Yo(r){return Object.prototype.toString.call(r)==="[object Object]"}function ic(r){return Yo(r)?Object.keys(r).reduce(function(e,t){const n=Yo(r[t]),i=n?ic(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function Fs(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Fs(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{Fs(r,r.get(i),t)})}))}function Zo(r,e,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return r.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{r.forEach(o=>{o.type===n&&o.trackId===a.id&&Fs(r,o,i)})}),i}const Ko=co;function rc(r,e){const t=r&&r.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const f=function(p,m){return p?p+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let p={};typeof u.ideal=="number"?(p[f("min",l)]=u.ideal,c.optional.push(p),p={},p[f("max",l)]=u.ideal,c.optional.push(p)):(p[f("",l)]=u.ideal,c.optional.push(p))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[f("",l)]=u.exact):["min","max"].forEach(p=>{u[p]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[f(p,l)]=u[p])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,f,p){f in u&&!(p in u)&&(u[p]=u[f],delete u[f])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let f;if(l.exact==="environment"||l.ideal==="environment"?f=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(f=["front"]),f)return t.mediaDevices.enumerateDevices().then(p=>{p=p.filter(x=>x.kind==="videoinput");let m=p.find(x=>f.some(T=>x.label.toLowerCase().includes(T)));return!m&&p.length&&f.includes("back")&&(m=p[p.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),Ko("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return Ko("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,u=>{t.webkitGetUserMedia(u,c,f=>{l&&l(s(f))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(f=>{f.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function Ul(r,e){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(n){return e(n).then(i=>{const s=n.video&&n.video.width,a=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:o||3}},s&&(n.video.mandatory.maxWidth=s),a&&(n.video.mandatory.maxHeight=a),r.navigator.mediaDevices.getUserMedia(n)})}}}function sc(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function oc(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):s={track:i.track};const a=new Event("track");a.track=i.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)}),n.stream.getTracks().forEach(i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.id):s={track:i};const a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Jn(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function ac(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(o,c){let l=i.apply(this,arguments);return l||(l=e(this,o),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function cc(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[n,i,s]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const a=function(c){const l={};return c.result().forEach(f=>{const p={id:f.id,timestamp:f.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[f.type]||f.type};f.names().forEach(m=>{p[m]=f.stat(m)}),l[p.id]=p}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){i(o(a(l)))};return e.apply(this,[c,n])}return new Promise((c,l)=>{e.apply(this,[function(u){c(o(a(u)))},l])}).then(i,s)}}function lc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const t=r.RTCPeerConnection.prototype.getSenders;t&&(r.RTCPeerConnection.prototype.getSenders=function(){const s=t.apply(this,[]);return s.forEach(a=>a._pc=this),s});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=n.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>Zo(a,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i}),Jn(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>Zo(s,i.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const n=arguments[0];let i,s,a;return this.getSenders().forEach(o=>{o.track===n&&(i?a=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(s?a=!0:s=o),o.track===n)),a||i&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function uc(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function hc(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return uc(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=t.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(f=>this._reverseStreams[f.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(f=>{if(this.getSenders().find(m=>m.track===f))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const f=new r.MediaStream(u.getTracks());this._streams[u.id]=f,this._reverseStreams[f.id]=u,u=f}n.apply(this,[u])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},r.RTCPeerConnection.prototype.addTrack=function(u,f){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const p=[].slice.call(arguments,1);if(p.length!==1||!p[0].getTracks().find(T=>T===u))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(T=>T.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const x=this._streams[f.id];if(x)x.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const T=new r.MediaStream([u]);this._streams[f.id]=T,this._reverseStreams[T.id]=f,this.addStream(T)}return this.getSenders().find(T=>T.track===u)};function s(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],x=l._streams[m.id];f=f.replace(new RegExp(x.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:f})}function a(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],x=l._streams[m.id];f=f.replace(new RegExp(m.id,"g"),x.id)}),new RTCSessionDescription({type:u.type,sdp:f})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],f={[l](){const p=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[x=>{const T=s(this,x);p[0].apply(null,[T])},x=>{p[1]&&p[1].apply(null,x)},arguments[2]]):u.apply(this,arguments).then(x=>s(this,x))}};r.RTCPeerConnection.prototype[l]=f[l]});const o=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),r.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let p;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(T=>u.track===T)&&(p=this._streams[m])}),p&&(p.getTracks().length===1?this.removeStream(this._reverseStreams[p.id]):p.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ls(r,e){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]})}function fc(r,e){Jn(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Qo=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:fc,shimAddTrackRemoveTrack:hc,shimAddTrackRemoveTrackWithNative:uc,shimGetDisplayMedia:Ul,shimGetSendersWithDtmf:ac,shimGetStats:cc,shimGetUserMedia:rc,shimMediaStream:sc,shimOnTrack:oc,shimPeerConnection:Ls,shimSenderReceiverGetStats:lc},Symbol.toStringTag,{value:"Module"}));function Dl(r,e){let t=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(n=>{if(n&&(n.urls||n.url)){let i=n.urls||n.url;n.url&&!n.urls&&Jr("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete n.url,n.urls=s?i[0]:i,!!i.length}})}var us={exports:{}},ea;function dc(){return ea||(ea=1,(function(r){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
2
2
|
`).map(function(n){return n.trim()})},e.splitSections=function(t){var n=t.split(`
|
|
3
3
|
m=`);return n.map(function(i,s){return(s>0?"m="+i:i).trim()+`\r
|
|
4
4
|
`})},e.getDescription=function(t){var n=e.splitSections(t);return n&&n[0]},e.getMediaSections=function(t){var n=e.splitSections(t);return n.shift(),n},e.matchPrefix=function(t,n){return e.splitLines(t).filter(function(i){return i.indexOf(n)===0})},e.parseCandidate=function(t){var n;t.indexOf("a=candidate:")===0?n=t.substring(12).split(" "):n=t.substring(10).split(" ");for(var i={foundation:n[0],component:parseInt(n[1],10),protocol:n[2].toLowerCase(),priority:parseInt(n[3],10),ip:n[4],address:n[4],port:parseInt(n[5],10),type:n[7]},s=8;s<n.length;s+=2)switch(n[s]){case"raddr":i.relatedAddress=n[s+1];break;case"rport":i.relatedPort=parseInt(n[s+1],10);break;case"tcptype":i.tcpType=n[s+1];break;case"ufrag":i.ufrag=n[s+1],i.usernameFragment=n[s+1];break;default:i[n[s]]=n[s+1];break}return i},e.writeCandidate=function(t){var n=[];n.push(t.foundation),n.push(t.component),n.push(t.protocol.toUpperCase()),n.push(t.priority),n.push(t.address||t.ip),n.push(t.port);var i=t.type;return n.push("typ"),n.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(n.push("raddr"),n.push(t.relatedAddress),n.push("rport"),n.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(n.push("tcptype"),n.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(n.push("ufrag"),n.push(t.usernameFragment||t.ufrag)),"candidate:"+n.join(" ")},e.parseIceOptions=function(t){return t.substr(14).split(" ")},e.parseRtpMap=function(t){var n=t.substr(9).split(" "),i={payloadType:parseInt(n.shift(),10)};return n=n[0].split("/"),i.name=n[0],i.clockRate=parseInt(n[1],10),i.channels=n.length===3?parseInt(n[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){var n=t.payloadType;t.preferredPayloadType!==void 0&&(n=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+n+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
|
|
@@ -36,46 +36,46 @@ t=0 0\r
|
|
|
36
36
|
`;a+="a="+o,a+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+o,t.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
37
37
|
`)}return a+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
|
|
38
38
|
`,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
|
|
39
|
-
`),a},e.getDirection=function(t,n){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return n?e.getDirection(n):"sendrecv"},e.getKind=function(t){var n=e.splitLines(t),i=n[0].split(" ");return i[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var n=e.splitLines(t),i=n[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(t){var n=e.matchPrefix(t,"o=")[0],i=n.substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var n=e.splitLines(t),i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},r.exports=e})(
|
|
39
|
+
`),a},e.getDirection=function(t,n){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return n?e.getDirection(n):"sendrecv"},e.getKind=function(t){var n=e.splitLines(t),i=n[0].split(" ");return i[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var n=e.splitLines(t),i=n[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(t){var n=e.matchPrefix(t,"o=")[0],i=n.substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var n=e.splitLines(t),i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},r.exports=e})(us)),us.exports}var hs,ta;function Fl(){if(ta)return hs;ta=1;var r=dc();function e(c){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[c.type]||c.type}function t(c,l,u,f,p){var m=r.writeRtpDescription(c.kind,l);if(m+=r.writeIceParameters(c.iceGatherer.getLocalParameters()),m+=r.writeDtlsParameters(c.dtlsTransport.getLocalParameters(),u==="offer"?"actpass":p||"active"),m+="a=mid:"+c.mid+`\r
|
|
40
40
|
`,c.rtpSender&&c.rtpReceiver?m+=`a=sendrecv\r
|
|
41
41
|
`:c.rtpSender?m+=`a=sendonly\r
|
|
42
42
|
`:c.rtpReceiver?m+=`a=recvonly\r
|
|
43
43
|
`:m+=`a=inactive\r
|
|
44
|
-
`,c.rtpSender){var x=c.rtpSender._initialTrackId||c.rtpSender.track.id;c.rtpSender._initialTrackId=x;var
|
|
45
|
-
`;m+="a="+
|
|
44
|
+
`,c.rtpSender){var x=c.rtpSender._initialTrackId||c.rtpSender.track.id;c.rtpSender._initialTrackId=x;var T="msid:"+(f?f.id:"-")+" "+x+`\r
|
|
45
|
+
`;m+="a="+T,m+="a=ssrc:"+c.sendEncodingParameters[0].ssrc+" "+T,c.sendEncodingParameters[0].rtx&&(m+="a=ssrc:"+c.sendEncodingParameters[0].rtx.ssrc+" "+T,m+="a=ssrc-group:FID "+c.sendEncodingParameters[0].ssrc+" "+c.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
46
46
|
`)}return m+="a=ssrc:"+c.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+`\r
|
|
47
47
|
`,c.rtpSender&&c.sendEncodingParameters[0].rtx&&(m+="a=ssrc:"+c.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+`\r
|
|
48
|
-
`),m}function n(c,l){var u=!1;return c=JSON.parse(JSON.stringify(c)),c.filter(function(f){if(f&&(f.urls||f.url)){var p=f.urls||f.url;f.url&&!f.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var m=typeof p=="string";return m&&(p=[p]),p=p.filter(function(x){var
|
|
49
|
-
`:
|
|
50
|
-
`,b._localDescription.sdp=r.getDescription(b._localDescription.sdp)+A.join("");var N=b.transceivers.every(function(z){return z.iceGatherer&&z.iceGatherer.state==="completed"});b.iceGatheringState!=="gathering"&&(b.iceGatheringState="gathering",b._emitGatheringStateChange()),O||b._dispatchEvent("icecandidate",P),N&&(b._dispatchEvent("icecandidate",new Event("icecandidate")),b.iceGatheringState="complete",b._emitGatheringStateChange())}},c.setTimeout(function(){C.forEach(function(T){_.onlocalcandidate(T)})},0)}},m.prototype._createIceAndDtlsTransports=function(){var g=this,v=new c.RTCIceTransport(null);v.onicestatechange=function(){g._updateIceConnectionState(),g._updateConnectionState()};var b=new c.RTCDtlsTransport(v);return b.ondtlsstatechange=function(){g._updateConnectionState()},b.onerror=function(){Object.defineProperty(b,"state",{value:"failed",writable:!0}),g._updateConnectionState()},{iceTransport:v,dtlsTransport:b}},m.prototype._disposeIceAndDtlsTransports=function(g){var v=this.transceivers[g].iceGatherer;v&&(delete v.onlocalcandidate,delete this.transceivers[g].iceGatherer);var b=this.transceivers[g].iceTransport;b&&(delete b.onicestatechange,delete this.transceivers[g].iceTransport);var _=this.transceivers[g].dtlsTransport;_&&(delete _.ondtlsstatechange,delete _.onerror,delete this.transceivers[g].dtlsTransport)},m.prototype._transceive=function(g,v,b){var _=i(g.localCapabilities,g.remoteCapabilities);v&&g.rtpSender&&(_.encodings=g.sendEncodingParameters,_.rtcp={cname:r.localCName,compound:g.rtcpParameters.compound},g.recvEncodingParameters.length&&(_.rtcp.ssrc=g.recvEncodingParameters[0].ssrc),g.rtpSender.send(_)),b&&g.rtpReceiver&&_.codecs.length>0&&(g.kind==="video"&&g.recvEncodingParameters&&l<15019&&g.recvEncodingParameters.forEach(function(C){delete C.rtx}),g.recvEncodingParameters.length?_.encodings=g.recvEncodingParameters:_.encodings=[{}],_.rtcp={compound:g.rtcpParameters.compound},g.rtcpParameters.cname&&(_.rtcp.cname=g.rtcpParameters.cname),g.sendEncodingParameters.length&&(_.rtcp.ssrc=g.sendEncodingParameters[0].ssrc),g.rtpReceiver.receive(_))},m.prototype.setLocalDescription=function(g){var v=this;if(["offer","answer"].indexOf(g.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+g.type+'"'));if(!s("setLocalDescription",g.type,v.signalingState)||v._isClosed)return Promise.reject(o("InvalidStateError","Can not set local "+g.type+" in state "+v.signalingState));var b,_;if(g.type==="offer")b=r.splitSections(g.sdp),_=b.shift(),b.forEach(function(T,P){var E=r.parseRtpParameters(T);v.transceivers[P].localCapabilities=E}),v.transceivers.forEach(function(T,P){v._gather(T.mid,P)});else if(g.type==="answer"){b=r.splitSections(v._remoteDescription.sdp),_=b.shift();var C=r.matchPrefix(_,"a=ice-lite").length>0;b.forEach(function(T,P){var E=v.transceivers[P],O=E.iceGatherer,I=E.iceTransport,A=E.dtlsTransport,N=E.localCapabilities,z=E.remoteCapabilities,U=r.isRejected(T)&&r.matchPrefix(T,"a=bundle-only").length===0;if(!U&&!E.rejected){var F=r.getIceParameters(T,_),J=r.getDtlsParameters(T,_);C&&(J.role="server"),(!v.usingBundle||P===0)&&(v._gather(E.mid,P),I.state==="new"&&I.start(O,F,C?"controlling":"controlled"),A.state==="new"&&A.start(J));var j=i(N,z);v._transceive(E,j.codecs.length>0,!1)}})}return v._localDescription={type:g.type,sdp:g.sdp},g.type==="offer"?v._updateSignalingState("have-local-offer"):v._updateSignalingState("stable"),Promise.resolve()},m.prototype.setRemoteDescription=function(g){var v=this;if(["offer","answer"].indexOf(g.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+g.type+'"'));if(!s("setRemoteDescription",g.type,v.signalingState)||v._isClosed)return Promise.reject(o("InvalidStateError","Can not set remote "+g.type+" in state "+v.signalingState));var b={};v.remoteStreams.forEach(function(I){b[I.id]=I});var _=[],C=r.splitSections(g.sdp),T=C.shift(),P=r.matchPrefix(T,"a=ice-lite").length>0,E=r.matchPrefix(T,"a=group:BUNDLE ").length>0;v.usingBundle=E;var O=r.matchPrefix(T,"a=ice-options:")[0];return O?v.canTrickleIceCandidates=O.substr(14).split(" ").indexOf("trickle")>=0:v.canTrickleIceCandidates=!1,C.forEach(function(I,A){var N=r.splitLines(I),z=r.getKind(I),U=r.isRejected(I)&&r.matchPrefix(I,"a=bundle-only").length===0,F=N[0].substr(2).split(" ")[2],J=r.getDirection(I,T),j=r.parseMsid(I),q=r.getMid(I)||r.generateIdentifier();if(U||z==="application"&&(F==="DTLS/SCTP"||F==="UDP/DTLS/SCTP")){v.transceivers[A]={mid:q,kind:z,protocol:F,rejected:!0};return}!U&&v.transceivers[A]&&v.transceivers[A].rejected&&(v.transceivers[A]=v._createTransceiver(z,!0));var G,ne,ie,he,se,ge,be,oe,fe,ae=r.parseRtpParameters(I),je,Ue;U||(je=r.getIceParameters(I,T),Ue=r.getDtlsParameters(I,T),Ue.role="client"),be=r.parseRtpEncodingParameters(I);var De=r.parseRtcpParameters(I),Ge=r.matchPrefix(I,"a=end-of-candidates",T).length>0,xe=r.matchPrefix(I,"a=candidate:").map(function(de){return r.parseCandidate(de)}).filter(function(de){return de.component===1});if((g.type==="offer"||g.type==="answer")&&!U&&E&&A>0&&v.transceivers[A]&&(v._disposeIceAndDtlsTransports(A),v.transceivers[A].iceGatherer=v.transceivers[0].iceGatherer,v.transceivers[A].iceTransport=v.transceivers[0].iceTransport,v.transceivers[A].dtlsTransport=v.transceivers[0].dtlsTransport,v.transceivers[A].rtpSender&&v.transceivers[A].rtpSender.setTransport(v.transceivers[0].dtlsTransport),v.transceivers[A].rtpReceiver&&v.transceivers[A].rtpReceiver.setTransport(v.transceivers[0].dtlsTransport)),g.type==="offer"&&!U){G=v.transceivers[A]||v._createTransceiver(z),G.mid=q,G.iceGatherer||(G.iceGatherer=v._createIceGatherer(A,E)),xe.length&&G.iceTransport.state==="new"&&(Ge&&(!E||A===0)?G.iceTransport.setRemoteCandidates(xe):xe.forEach(function(de){a(G.iceTransport,de)})),oe=c.RTCRtpReceiver.getCapabilities(z),l<15019&&(oe.codecs=oe.codecs.filter(function(de){return de.name!=="rtx"})),ge=G.sendEncodingParameters||[{ssrc:(2*A+2)*1001}];var ye=!1;if(J==="sendrecv"||J==="sendonly"){if(ye=!G.rtpReceiver,se=G.rtpReceiver||new c.RTCRtpReceiver(G.dtlsTransport,z),ye){var ce;fe=se.track,j&&j.stream==="-"||(j?(b[j.stream]||(b[j.stream]=new c.MediaStream,Object.defineProperty(b[j.stream],"id",{get:function(){return j.stream}})),Object.defineProperty(fe,"id",{get:function(){return j.track}}),ce=b[j.stream]):(b.default||(b.default=new c.MediaStream),ce=b.default)),ce&&(u(fe,ce),G.associatedRemoteMediaStreams.push(ce)),_.push([fe,se,ce])}}else G.rtpReceiver&&G.rtpReceiver.track&&(G.associatedRemoteMediaStreams.forEach(function(de){var Ye=de.getTracks().find(function(yt){return yt.id===G.rtpReceiver.track.id});Ye&&f(Ye,de)}),G.associatedRemoteMediaStreams=[]);G.localCapabilities=oe,G.remoteCapabilities=ae,G.rtpReceiver=se,G.rtcpParameters=De,G.sendEncodingParameters=ge,G.recvEncodingParameters=be,v._transceive(v.transceivers[A],!1,ye)}else if(g.type==="answer"&&!U){G=v.transceivers[A],ne=G.iceGatherer,ie=G.iceTransport,he=G.dtlsTransport,se=G.rtpReceiver,ge=G.sendEncodingParameters,oe=G.localCapabilities,v.transceivers[A].recvEncodingParameters=be,v.transceivers[A].remoteCapabilities=ae,v.transceivers[A].rtcpParameters=De,xe.length&&ie.state==="new"&&((P||Ge)&&(!E||A===0)?ie.setRemoteCandidates(xe):xe.forEach(function(de){a(G.iceTransport,de)})),(!E||A===0)&&(ie.state==="new"&&ie.start(ne,je,"controlling"),he.state==="new"&&he.start(Ue));var st=i(G.localCapabilities,G.remoteCapabilities),Pe=st.codecs.filter(function(de){return de.name.toLowerCase()==="rtx"}).length;!Pe&&G.sendEncodingParameters[0].rtx&&delete G.sendEncodingParameters[0].rtx,v._transceive(G,J==="sendrecv"||J==="recvonly",J==="sendrecv"||J==="sendonly"),se&&(J==="sendrecv"||J==="sendonly")?(fe=se.track,j?(b[j.stream]||(b[j.stream]=new c.MediaStream),u(fe,b[j.stream]),_.push([fe,se,b[j.stream]])):(b.default||(b.default=new c.MediaStream),u(fe,b.default),_.push([fe,se,b.default]))):delete G.rtpReceiver}}),v._dtlsRole===void 0&&(v._dtlsRole=g.type==="offer"?"active":"passive"),v._remoteDescription={type:g.type,sdp:g.sdp},g.type==="offer"?v._updateSignalingState("have-remote-offer"):v._updateSignalingState("stable"),Object.keys(b).forEach(function(I){var A=b[I];if(A.getTracks().length){if(v.remoteStreams.indexOf(A)===-1){v.remoteStreams.push(A);var N=new Event("addstream");N.stream=A,c.setTimeout(function(){v._dispatchEvent("addstream",N)})}_.forEach(function(z){var U=z[0],F=z[1];A.id===z[2].id&&p(v,U,F,[A])})}}),_.forEach(function(I){I[2]||p(v,I[0],I[1],[])}),c.setTimeout(function(){v&&v.transceivers&&v.transceivers.forEach(function(I){I.iceTransport&&I.iceTransport.state==="new"&&I.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),I.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},m.prototype.close=function(){this.transceivers.forEach(function(g){g.iceTransport&&g.iceTransport.stop(),g.dtlsTransport&&g.dtlsTransport.stop(),g.rtpSender&&g.rtpSender.stop(),g.rtpReceiver&&g.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},m.prototype._updateSignalingState=function(g){this.signalingState=g;var v=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",v)},m.prototype._maybeFireNegotiationNeeded=function(){var g=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,c.setTimeout(function(){if(g.needNegotiation){g.needNegotiation=!1;var v=new Event("negotiationneeded");g._dispatchEvent("negotiationneeded",v)}},0))},m.prototype._updateIceConnectionState=function(){var g,v={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(_){_.iceTransport&&!_.rejected&&v[_.iceTransport.state]++}),g="new",v.failed>0?g="failed":v.checking>0?g="checking":v.disconnected>0?g="disconnected":v.new>0?g="new":v.connected>0?g="connected":v.completed>0&&(g="completed"),g!==this.iceConnectionState){this.iceConnectionState=g;var b=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",b)}},m.prototype._updateConnectionState=function(){var g,v={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(_){_.iceTransport&&_.dtlsTransport&&!_.rejected&&(v[_.iceTransport.state]++,v[_.dtlsTransport.state]++)}),v.connected+=v.completed,g="new",v.failed>0?g="failed":v.connecting>0?g="connecting":v.disconnected>0?g="disconnected":v.new>0?g="new":v.connected>0&&(g="connected"),g!==this.connectionState){this.connectionState=g;var b=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",b)}},m.prototype.createOffer=function(){var g=this;if(g._isClosed)return Promise.reject(o("InvalidStateError","Can not call createOffer after close"));var v=g.transceivers.filter(function(P){return P.kind==="audio"}).length,b=g.transceivers.filter(function(P){return P.kind==="video"}).length,_=arguments[0];if(_){if(_.mandatory||_.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");_.offerToReceiveAudio!==void 0&&(_.offerToReceiveAudio===!0?v=1:_.offerToReceiveAudio===!1?v=0:v=_.offerToReceiveAudio),_.offerToReceiveVideo!==void 0&&(_.offerToReceiveVideo===!0?b=1:_.offerToReceiveVideo===!1?b=0:b=_.offerToReceiveVideo)}for(g.transceivers.forEach(function(P){P.kind==="audio"?(v--,v<0&&(P.wantReceive=!1)):P.kind==="video"&&(b--,b<0&&(P.wantReceive=!1))});v>0||b>0;)v>0&&(g._createTransceiver("audio"),v--),b>0&&(g._createTransceiver("video"),b--);var C=r.writeSessionBoilerplate(g._sdpSessionId,g._sdpSessionVersion++);g.transceivers.forEach(function(P,E){var O=P.track,I=P.kind,A=P.mid||r.generateIdentifier();P.mid=A,P.iceGatherer||(P.iceGatherer=g._createIceGatherer(E,g.usingBundle));var N=c.RTCRtpSender.getCapabilities(I);l<15019&&(N.codecs=N.codecs.filter(function(U){return U.name!=="rtx"})),N.codecs.forEach(function(U){U.name==="H264"&&U.parameters["level-asymmetry-allowed"]===void 0&&(U.parameters["level-asymmetry-allowed"]="1"),P.remoteCapabilities&&P.remoteCapabilities.codecs&&P.remoteCapabilities.codecs.forEach(function(F){U.name.toLowerCase()===F.name.toLowerCase()&&U.clockRate===F.clockRate&&(U.preferredPayloadType=F.payloadType)})}),N.headerExtensions.forEach(function(U){var F=P.remoteCapabilities&&P.remoteCapabilities.headerExtensions||[];F.forEach(function(J){U.uri===J.uri&&(U.id=J.id)})});var z=P.sendEncodingParameters||[{ssrc:(2*E+1)*1001}];O&&l>=15019&&I==="video"&&!z[0].rtx&&(z[0].rtx={ssrc:z[0].ssrc+1}),P.wantReceive&&(P.rtpReceiver=new c.RTCRtpReceiver(P.dtlsTransport,I)),P.localCapabilities=N,P.sendEncodingParameters=z}),g._config.bundlePolicy!=="max-compat"&&(C+="a=group:BUNDLE "+g.transceivers.map(function(P){return P.mid}).join(" ")+`\r
|
|
51
|
-
`),
|
|
52
|
-
`,g.transceivers.forEach(function(P,E){
|
|
53
|
-
`,P.iceGatherer&&g.iceGatheringState!=="new"&&(E===0||!g.usingBundle)&&(P.iceGatherer.getLocalCandidates().forEach(function(
|
|
54
|
-
`}),P.iceGatherer.state==="completed"&&(
|
|
55
|
-
`))});var
|
|
48
|
+
`),m}function n(c,l){var u=!1;return c=JSON.parse(JSON.stringify(c)),c.filter(function(f){if(f&&(f.urls||f.url)){var p=f.urls||f.url;f.url&&!f.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var m=typeof p=="string";return m&&(p=[p]),p=p.filter(function(x){var T=x.indexOf("turn:")===0&&x.indexOf("transport=udp")!==-1&&x.indexOf("turn:[")===-1&&!u;return T?(u=!0,!0):x.indexOf("stun:")===0&&l>=14393&&x.indexOf("?transport=udp")===-1}),delete f.url,f.urls=m?p[0]:p,!!p.length}})}function i(c,l){var u={codecs:[],headerExtensions:[],fecMechanisms:[]},f=function(m,x){m=parseInt(m,10);for(var T=0;T<x.length;T++)if(x[T].payloadType===m||x[T].preferredPayloadType===m)return x[T]},p=function(m,x,T,g){var v=f(m.parameters.apt,T),_=f(x.parameters.apt,g);return v&&_&&v.name.toLowerCase()===_.name.toLowerCase()};return c.codecs.forEach(function(m){for(var x=0;x<l.codecs.length;x++){var T=l.codecs[x];if(m.name.toLowerCase()===T.name.toLowerCase()&&m.clockRate===T.clockRate){if(m.name.toLowerCase()==="rtx"&&m.parameters&&T.parameters.apt&&!p(m,T,c.codecs,l.codecs))continue;T=JSON.parse(JSON.stringify(T)),T.numChannels=Math.min(m.numChannels,T.numChannels),u.codecs.push(T),T.rtcpFeedback=T.rtcpFeedback.filter(function(g){for(var v=0;v<m.rtcpFeedback.length;v++)if(m.rtcpFeedback[v].type===g.type&&m.rtcpFeedback[v].parameter===g.parameter)return!0;return!1});break}}}),c.headerExtensions.forEach(function(m){for(var x=0;x<l.headerExtensions.length;x++){var T=l.headerExtensions[x];if(m.uri===T.uri){u.headerExtensions.push(T);break}}}),u}function s(c,l,u){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[l][c].indexOf(u)!==-1}function a(c,l){var u=c.getRemoteCandidates().find(function(f){return l.foundation===f.foundation&&l.ip===f.ip&&l.port===f.port&&l.priority===f.priority&&l.protocol===f.protocol&&l.type===f.type});return u||c.addRemoteCandidate(l),!u}function o(c,l){var u=new Error(l);return u.name=c,u.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[c],u}return hs=function(c,l){function u(g,v){v.addTrack(g),v.dispatchEvent(new c.MediaStreamTrackEvent("addtrack",{track:g}))}function f(g,v){v.removeTrack(g),v.dispatchEvent(new c.MediaStreamTrackEvent("removetrack",{track:g}))}function p(g,v,_,b){var M=new Event("track");M.track=v,M.receiver=_,M.transceiver={receiver:_},M.streams=b,c.setTimeout(function(){g._dispatchEvent("track",M)})}var m=function(g){var v=this,_=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(M){v[M]=_[M].bind(_)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",g=JSON.parse(JSON.stringify(g||{})),this.usingBundle=g.bundlePolicy==="max-bundle",g.rtcpMuxPolicy==="negotiate")throw o("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(g.rtcpMuxPolicy||(g.rtcpMuxPolicy="require"),g.iceTransportPolicy){case"all":case"relay":break;default:g.iceTransportPolicy="all";break}switch(g.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:g.bundlePolicy="balanced";break}if(g.iceServers=n(g.iceServers||[],l),this._iceGatherers=[],g.iceCandidatePoolSize)for(var b=g.iceCandidatePoolSize;b>0;b--)this._iceGatherers.push(new c.RTCIceGatherer({iceServers:g.iceServers,gatherPolicy:g.iceTransportPolicy}));else g.iceCandidatePoolSize=0;this._config=g,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(m.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(m.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),m.prototype.onicecandidate=null,m.prototype.onaddstream=null,m.prototype.ontrack=null,m.prototype.onremovestream=null,m.prototype.onsignalingstatechange=null,m.prototype.oniceconnectionstatechange=null,m.prototype.onconnectionstatechange=null,m.prototype.onicegatheringstatechange=null,m.prototype.onnegotiationneeded=null,m.prototype.ondatachannel=null,m.prototype._dispatchEvent=function(g,v){this._isClosed||(this.dispatchEvent(v),typeof this["on"+g]=="function"&&this["on"+g](v))},m.prototype._emitGatheringStateChange=function(){var g=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",g)},m.prototype.getConfiguration=function(){return this._config},m.prototype.getLocalStreams=function(){return this.localStreams},m.prototype.getRemoteStreams=function(){return this.remoteStreams},m.prototype._createTransceiver=function(g,v){var _=this.transceivers.length>0,b={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:g,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&_)b.iceTransport=this.transceivers[0].iceTransport,b.dtlsTransport=this.transceivers[0].dtlsTransport;else{var M=this._createIceAndDtlsTransports();b.iceTransport=M.iceTransport,b.dtlsTransport=M.dtlsTransport}return v||this.transceivers.push(b),b},m.prototype.addTrack=function(g,v){if(this._isClosed)throw o("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var _=this.transceivers.find(function(C){return C.track===g});if(_)throw o("InvalidAccessError","Track already exists.");for(var b,M=0;M<this.transceivers.length;M++)!this.transceivers[M].track&&this.transceivers[M].kind===g.kind&&(b=this.transceivers[M]);return b||(b=this._createTransceiver(g.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(v)===-1&&this.localStreams.push(v),b.track=g,b.stream=v,b.rtpSender=new c.RTCRtpSender(g,b.dtlsTransport),b.rtpSender},m.prototype.addStream=function(g){var v=this;if(l>=15025)g.getTracks().forEach(function(b){v.addTrack(b,g)});else{var _=g.clone();g.getTracks().forEach(function(b,M){var C=_.getTracks()[M];b.addEventListener("enabled",function(P){C.enabled=P.enabled})}),_.getTracks().forEach(function(b){v.addTrack(b,_)})}},m.prototype.removeTrack=function(g){if(this._isClosed)throw o("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(g instanceof c.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var v=this.transceivers.find(function(M){return M.rtpSender===g});if(!v)throw o("InvalidAccessError","Sender was not created by this connection.");var _=v.stream;v.rtpSender.stop(),v.rtpSender=null,v.track=null,v.stream=null;var b=this.transceivers.map(function(M){return M.stream});b.indexOf(_)===-1&&this.localStreams.indexOf(_)>-1&&this.localStreams.splice(this.localStreams.indexOf(_),1),this._maybeFireNegotiationNeeded()},m.prototype.removeStream=function(g){var v=this;g.getTracks().forEach(function(_){var b=v.getSenders().find(function(M){return M.track===_});b&&v.removeTrack(b)})},m.prototype.getSenders=function(){return this.transceivers.filter(function(g){return!!g.rtpSender}).map(function(g){return g.rtpSender})},m.prototype.getReceivers=function(){return this.transceivers.filter(function(g){return!!g.rtpReceiver}).map(function(g){return g.rtpReceiver})},m.prototype._createIceGatherer=function(g,v){var _=this;if(v&&g>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var b=new c.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(b,"state",{value:"new",writable:!0}),this.transceivers[g].bufferedCandidateEvents=[],this.transceivers[g].bufferCandidates=function(M){var C=!M.candidate||Object.keys(M.candidate).length===0;b.state=C?"completed":"gathering",_.transceivers[g].bufferedCandidateEvents!==null&&_.transceivers[g].bufferedCandidateEvents.push(M)},b.addEventListener("localcandidate",this.transceivers[g].bufferCandidates),b},m.prototype._gather=function(g,v){var _=this,b=this.transceivers[v].iceGatherer;if(!b.onlocalcandidate){var M=this.transceivers[v].bufferedCandidateEvents;this.transceivers[v].bufferedCandidateEvents=null,b.removeEventListener("localcandidate",this.transceivers[v].bufferCandidates),b.onlocalcandidate=function(C){if(!(_.usingBundle&&v>0)){var P=new Event("icecandidate");P.candidate={sdpMid:g,sdpMLineIndex:v};var E=C.candidate,z=!E||Object.keys(E).length===0;if(z)(b.state==="new"||b.state==="gathering")&&(b.state="completed");else{b.state==="new"&&(b.state="gathering"),E.component=1,E.ufrag=b.getLocalParameters().usernameFragment;var I=r.writeCandidate(E);P.candidate=Object.assign(P.candidate,r.parseCandidate(I)),P.candidate.candidate=I,P.candidate.toJSON=function(){return{candidate:P.candidate.candidate,sdpMid:P.candidate.sdpMid,sdpMLineIndex:P.candidate.sdpMLineIndex,usernameFragment:P.candidate.usernameFragment}}}var R=r.getMediaSections(_._localDescription.sdp);z?R[P.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
|
|
49
|
+
`:R[P.candidate.sdpMLineIndex]+="a="+P.candidate.candidate+`\r
|
|
50
|
+
`,_._localDescription.sdp=r.getDescription(_._localDescription.sdp)+R.join("");var N=_.transceivers.every(function(O){return O.iceGatherer&&O.iceGatherer.state==="completed"});_.iceGatheringState!=="gathering"&&(_.iceGatheringState="gathering",_._emitGatheringStateChange()),z||_._dispatchEvent("icecandidate",P),N&&(_._dispatchEvent("icecandidate",new Event("icecandidate")),_.iceGatheringState="complete",_._emitGatheringStateChange())}},c.setTimeout(function(){M.forEach(function(C){b.onlocalcandidate(C)})},0)}},m.prototype._createIceAndDtlsTransports=function(){var g=this,v=new c.RTCIceTransport(null);v.onicestatechange=function(){g._updateIceConnectionState(),g._updateConnectionState()};var _=new c.RTCDtlsTransport(v);return _.ondtlsstatechange=function(){g._updateConnectionState()},_.onerror=function(){Object.defineProperty(_,"state",{value:"failed",writable:!0}),g._updateConnectionState()},{iceTransport:v,dtlsTransport:_}},m.prototype._disposeIceAndDtlsTransports=function(g){var v=this.transceivers[g].iceGatherer;v&&(delete v.onlocalcandidate,delete this.transceivers[g].iceGatherer);var _=this.transceivers[g].iceTransport;_&&(delete _.onicestatechange,delete this.transceivers[g].iceTransport);var b=this.transceivers[g].dtlsTransport;b&&(delete b.ondtlsstatechange,delete b.onerror,delete this.transceivers[g].dtlsTransport)},m.prototype._transceive=function(g,v,_){var b=i(g.localCapabilities,g.remoteCapabilities);v&&g.rtpSender&&(b.encodings=g.sendEncodingParameters,b.rtcp={cname:r.localCName,compound:g.rtcpParameters.compound},g.recvEncodingParameters.length&&(b.rtcp.ssrc=g.recvEncodingParameters[0].ssrc),g.rtpSender.send(b)),_&&g.rtpReceiver&&b.codecs.length>0&&(g.kind==="video"&&g.recvEncodingParameters&&l<15019&&g.recvEncodingParameters.forEach(function(M){delete M.rtx}),g.recvEncodingParameters.length?b.encodings=g.recvEncodingParameters:b.encodings=[{}],b.rtcp={compound:g.rtcpParameters.compound},g.rtcpParameters.cname&&(b.rtcp.cname=g.rtcpParameters.cname),g.sendEncodingParameters.length&&(b.rtcp.ssrc=g.sendEncodingParameters[0].ssrc),g.rtpReceiver.receive(b))},m.prototype.setLocalDescription=function(g){var v=this;if(["offer","answer"].indexOf(g.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+g.type+'"'));if(!s("setLocalDescription",g.type,v.signalingState)||v._isClosed)return Promise.reject(o("InvalidStateError","Can not set local "+g.type+" in state "+v.signalingState));var _,b;if(g.type==="offer")_=r.splitSections(g.sdp),b=_.shift(),_.forEach(function(C,P){var E=r.parseRtpParameters(C);v.transceivers[P].localCapabilities=E}),v.transceivers.forEach(function(C,P){v._gather(C.mid,P)});else if(g.type==="answer"){_=r.splitSections(v._remoteDescription.sdp),b=_.shift();var M=r.matchPrefix(b,"a=ice-lite").length>0;_.forEach(function(C,P){var E=v.transceivers[P],z=E.iceGatherer,I=E.iceTransport,R=E.dtlsTransport,N=E.localCapabilities,O=E.remoteCapabilities,U=r.isRejected(C)&&r.matchPrefix(C,"a=bundle-only").length===0;if(!U&&!E.rejected){var L=r.getIceParameters(C,b),J=r.getDtlsParameters(C,b);M&&(J.role="server"),(!v.usingBundle||P===0)&&(v._gather(E.mid,P),I.state==="new"&&I.start(z,L,M?"controlling":"controlled"),R.state==="new"&&R.start(J));var W=i(N,O);v._transceive(E,W.codecs.length>0,!1)}})}return v._localDescription={type:g.type,sdp:g.sdp},g.type==="offer"?v._updateSignalingState("have-local-offer"):v._updateSignalingState("stable"),Promise.resolve()},m.prototype.setRemoteDescription=function(g){var v=this;if(["offer","answer"].indexOf(g.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+g.type+'"'));if(!s("setRemoteDescription",g.type,v.signalingState)||v._isClosed)return Promise.reject(o("InvalidStateError","Can not set remote "+g.type+" in state "+v.signalingState));var _={};v.remoteStreams.forEach(function(I){_[I.id]=I});var b=[],M=r.splitSections(g.sdp),C=M.shift(),P=r.matchPrefix(C,"a=ice-lite").length>0,E=r.matchPrefix(C,"a=group:BUNDLE ").length>0;v.usingBundle=E;var z=r.matchPrefix(C,"a=ice-options:")[0];return z?v.canTrickleIceCandidates=z.substr(14).split(" ").indexOf("trickle")>=0:v.canTrickleIceCandidates=!1,M.forEach(function(I,R){var N=r.splitLines(I),O=r.getKind(I),U=r.isRejected(I)&&r.matchPrefix(I,"a=bundle-only").length===0,L=N[0].substr(2).split(" ")[2],J=r.getDirection(I,C),W=r.parseMsid(I),K=r.getMid(I)||r.generateIdentifier();if(U||O==="application"&&(L==="DTLS/SCTP"||L==="UDP/DTLS/SCTP")){v.transceivers[R]={mid:K,kind:O,protocol:L,rejected:!0};return}!U&&v.transceivers[R]&&v.transceivers[R].rejected&&(v.transceivers[R]=v._createTransceiver(O,!0));var $,me,ne,ue,re,ge,be,se,he,oe=r.parseRtpParameters(I),Xe,Ve;U||(Xe=r.getIceParameters(I,C),Ve=r.getDtlsParameters(I,C),Ve.role="client"),be=r.parseRtpEncodingParameters(I);var Je=r.parseRtcpParameters(I),Ye=r.matchPrefix(I,"a=end-of-candidates",C).length>0,xe=r.matchPrefix(I,"a=candidate:").map(function(fe){return r.parseCandidate(fe)}).filter(function(fe){return fe.component===1});if((g.type==="offer"||g.type==="answer")&&!U&&E&&R>0&&v.transceivers[R]&&(v._disposeIceAndDtlsTransports(R),v.transceivers[R].iceGatherer=v.transceivers[0].iceGatherer,v.transceivers[R].iceTransport=v.transceivers[0].iceTransport,v.transceivers[R].dtlsTransport=v.transceivers[0].dtlsTransport,v.transceivers[R].rtpSender&&v.transceivers[R].rtpSender.setTransport(v.transceivers[0].dtlsTransport),v.transceivers[R].rtpReceiver&&v.transceivers[R].rtpReceiver.setTransport(v.transceivers[0].dtlsTransport)),g.type==="offer"&&!U){$=v.transceivers[R]||v._createTransceiver(O),$.mid=K,$.iceGatherer||($.iceGatherer=v._createIceGatherer(R,E)),xe.length&&$.iceTransport.state==="new"&&(Ye&&(!E||R===0)?$.iceTransport.setRemoteCandidates(xe):xe.forEach(function(fe){a($.iceTransport,fe)})),se=c.RTCRtpReceiver.getCapabilities(O),l<15019&&(se.codecs=se.codecs.filter(function(fe){return fe.name!=="rtx"})),ge=$.sendEncodingParameters||[{ssrc:(2*R+2)*1001}];var ye=!1;if(J==="sendrecv"||J==="sendonly"){if(ye=!$.rtpReceiver,re=$.rtpReceiver||new c.RTCRtpReceiver($.dtlsTransport,O),ye){var ae;he=re.track,W&&W.stream==="-"||(W?(_[W.stream]||(_[W.stream]=new c.MediaStream,Object.defineProperty(_[W.stream],"id",{get:function(){return W.stream}})),Object.defineProperty(he,"id",{get:function(){return W.track}}),ae=_[W.stream]):(_.default||(_.default=new c.MediaStream),ae=_.default)),ae&&(u(he,ae),$.associatedRemoteMediaStreams.push(ae)),b.push([he,re,ae])}}else $.rtpReceiver&&$.rtpReceiver.track&&($.associatedRemoteMediaStreams.forEach(function(fe){var it=fe.getTracks().find(function(vt){return vt.id===$.rtpReceiver.track.id});it&&f(it,fe)}),$.associatedRemoteMediaStreams=[]);$.localCapabilities=se,$.remoteCapabilities=oe,$.rtpReceiver=re,$.rtcpParameters=Je,$.sendEncodingParameters=ge,$.recvEncodingParameters=be,v._transceive(v.transceivers[R],!1,ye)}else if(g.type==="answer"&&!U){$=v.transceivers[R],me=$.iceGatherer,ne=$.iceTransport,ue=$.dtlsTransport,re=$.rtpReceiver,ge=$.sendEncodingParameters,se=$.localCapabilities,v.transceivers[R].recvEncodingParameters=be,v.transceivers[R].remoteCapabilities=oe,v.transceivers[R].rtcpParameters=Je,xe.length&&ne.state==="new"&&((P||Ye)&&(!E||R===0)?ne.setRemoteCandidates(xe):xe.forEach(function(fe){a($.iceTransport,fe)})),(!E||R===0)&&(ne.state==="new"&&ne.start(me,Xe,"controlling"),ue.state==="new"&&ue.start(Ve));var ut=i($.localCapabilities,$.remoteCapabilities),ke=ut.codecs.filter(function(fe){return fe.name.toLowerCase()==="rtx"}).length;!ke&&$.sendEncodingParameters[0].rtx&&delete $.sendEncodingParameters[0].rtx,v._transceive($,J==="sendrecv"||J==="recvonly",J==="sendrecv"||J==="sendonly"),re&&(J==="sendrecv"||J==="sendonly")?(he=re.track,W?(_[W.stream]||(_[W.stream]=new c.MediaStream),u(he,_[W.stream]),b.push([he,re,_[W.stream]])):(_.default||(_.default=new c.MediaStream),u(he,_.default),b.push([he,re,_.default]))):delete $.rtpReceiver}}),v._dtlsRole===void 0&&(v._dtlsRole=g.type==="offer"?"active":"passive"),v._remoteDescription={type:g.type,sdp:g.sdp},g.type==="offer"?v._updateSignalingState("have-remote-offer"):v._updateSignalingState("stable"),Object.keys(_).forEach(function(I){var R=_[I];if(R.getTracks().length){if(v.remoteStreams.indexOf(R)===-1){v.remoteStreams.push(R);var N=new Event("addstream");N.stream=R,c.setTimeout(function(){v._dispatchEvent("addstream",N)})}b.forEach(function(O){var U=O[0],L=O[1];R.id===O[2].id&&p(v,U,L,[R])})}}),b.forEach(function(I){I[2]||p(v,I[0],I[1],[])}),c.setTimeout(function(){v&&v.transceivers&&v.transceivers.forEach(function(I){I.iceTransport&&I.iceTransport.state==="new"&&I.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),I.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},m.prototype.close=function(){this.transceivers.forEach(function(g){g.iceTransport&&g.iceTransport.stop(),g.dtlsTransport&&g.dtlsTransport.stop(),g.rtpSender&&g.rtpSender.stop(),g.rtpReceiver&&g.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},m.prototype._updateSignalingState=function(g){this.signalingState=g;var v=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",v)},m.prototype._maybeFireNegotiationNeeded=function(){var g=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,c.setTimeout(function(){if(g.needNegotiation){g.needNegotiation=!1;var v=new Event("negotiationneeded");g._dispatchEvent("negotiationneeded",v)}},0))},m.prototype._updateIceConnectionState=function(){var g,v={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(b){b.iceTransport&&!b.rejected&&v[b.iceTransport.state]++}),g="new",v.failed>0?g="failed":v.checking>0?g="checking":v.disconnected>0?g="disconnected":v.new>0?g="new":v.connected>0?g="connected":v.completed>0&&(g="completed"),g!==this.iceConnectionState){this.iceConnectionState=g;var _=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",_)}},m.prototype._updateConnectionState=function(){var g,v={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(b){b.iceTransport&&b.dtlsTransport&&!b.rejected&&(v[b.iceTransport.state]++,v[b.dtlsTransport.state]++)}),v.connected+=v.completed,g="new",v.failed>0?g="failed":v.connecting>0?g="connecting":v.disconnected>0?g="disconnected":v.new>0?g="new":v.connected>0&&(g="connected"),g!==this.connectionState){this.connectionState=g;var _=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",_)}},m.prototype.createOffer=function(){var g=this;if(g._isClosed)return Promise.reject(o("InvalidStateError","Can not call createOffer after close"));var v=g.transceivers.filter(function(P){return P.kind==="audio"}).length,_=g.transceivers.filter(function(P){return P.kind==="video"}).length,b=arguments[0];if(b){if(b.mandatory||b.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");b.offerToReceiveAudio!==void 0&&(b.offerToReceiveAudio===!0?v=1:b.offerToReceiveAudio===!1?v=0:v=b.offerToReceiveAudio),b.offerToReceiveVideo!==void 0&&(b.offerToReceiveVideo===!0?_=1:b.offerToReceiveVideo===!1?_=0:_=b.offerToReceiveVideo)}for(g.transceivers.forEach(function(P){P.kind==="audio"?(v--,v<0&&(P.wantReceive=!1)):P.kind==="video"&&(_--,_<0&&(P.wantReceive=!1))});v>0||_>0;)v>0&&(g._createTransceiver("audio"),v--),_>0&&(g._createTransceiver("video"),_--);var M=r.writeSessionBoilerplate(g._sdpSessionId,g._sdpSessionVersion++);g.transceivers.forEach(function(P,E){var z=P.track,I=P.kind,R=P.mid||r.generateIdentifier();P.mid=R,P.iceGatherer||(P.iceGatherer=g._createIceGatherer(E,g.usingBundle));var N=c.RTCRtpSender.getCapabilities(I);l<15019&&(N.codecs=N.codecs.filter(function(U){return U.name!=="rtx"})),N.codecs.forEach(function(U){U.name==="H264"&&U.parameters["level-asymmetry-allowed"]===void 0&&(U.parameters["level-asymmetry-allowed"]="1"),P.remoteCapabilities&&P.remoteCapabilities.codecs&&P.remoteCapabilities.codecs.forEach(function(L){U.name.toLowerCase()===L.name.toLowerCase()&&U.clockRate===L.clockRate&&(U.preferredPayloadType=L.payloadType)})}),N.headerExtensions.forEach(function(U){var L=P.remoteCapabilities&&P.remoteCapabilities.headerExtensions||[];L.forEach(function(J){U.uri===J.uri&&(U.id=J.id)})});var O=P.sendEncodingParameters||[{ssrc:(2*E+1)*1001}];z&&l>=15019&&I==="video"&&!O[0].rtx&&(O[0].rtx={ssrc:O[0].ssrc+1}),P.wantReceive&&(P.rtpReceiver=new c.RTCRtpReceiver(P.dtlsTransport,I)),P.localCapabilities=N,P.sendEncodingParameters=O}),g._config.bundlePolicy!=="max-compat"&&(M+="a=group:BUNDLE "+g.transceivers.map(function(P){return P.mid}).join(" ")+`\r
|
|
51
|
+
`),M+=`a=ice-options:trickle\r
|
|
52
|
+
`,g.transceivers.forEach(function(P,E){M+=t(P,P.localCapabilities,"offer",P.stream,g._dtlsRole),M+=`a=rtcp-rsize\r
|
|
53
|
+
`,P.iceGatherer&&g.iceGatheringState!=="new"&&(E===0||!g.usingBundle)&&(P.iceGatherer.getLocalCandidates().forEach(function(z){z.component=1,M+="a="+r.writeCandidate(z)+`\r
|
|
54
|
+
`}),P.iceGatherer.state==="completed"&&(M+=`a=end-of-candidates\r
|
|
55
|
+
`))});var C=new c.RTCSessionDescription({type:"offer",sdp:M});return Promise.resolve(C)},m.prototype.createAnswer=function(){var g=this;if(g._isClosed)return Promise.reject(o("InvalidStateError","Can not call createAnswer after close"));if(!(g.signalingState==="have-remote-offer"||g.signalingState==="have-local-pranswer"))return Promise.reject(o("InvalidStateError","Can not call createAnswer in signalingState "+g.signalingState));var v=r.writeSessionBoilerplate(g._sdpSessionId,g._sdpSessionVersion++);g.usingBundle&&(v+="a=group:BUNDLE "+g.transceivers.map(function(M){return M.mid}).join(" ")+`\r
|
|
56
56
|
`),v+=`a=ice-options:trickle\r
|
|
57
|
-
`;var
|
|
58
|
-
`:v+="m=application 0 "+
|
|
59
|
-
`:
|
|
57
|
+
`;var _=r.getMediaSections(g._remoteDescription.sdp).length;g.transceivers.forEach(function(M,C){if(!(C+1>_)){if(M.rejected){M.kind==="application"?M.protocol==="DTLS/SCTP"?v+=`m=application 0 DTLS/SCTP 5000\r
|
|
58
|
+
`:v+="m=application 0 "+M.protocol+` webrtc-datachannel\r
|
|
59
|
+
`:M.kind==="audio"?v+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
|
|
60
60
|
a=rtpmap:0 PCMU/8000\r
|
|
61
|
-
`:
|
|
61
|
+
`:M.kind==="video"&&(v+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
|
|
62
62
|
a=rtpmap:120 VP8/90000\r
|
|
63
63
|
`),v+=`c=IN IP4 0.0.0.0\r
|
|
64
64
|
a=inactive\r
|
|
65
|
-
a=mid:`+
|
|
66
|
-
`;return}if(
|
|
67
|
-
`)}});var
|
|
68
|
-
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+
|
|
69
|
-
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+b.join("")}else return C(o("OperationError","Can not add ICE candidate"))}else return C(o("InvalidStateError","Can not add ICE candidate without a remote description"));_()})},m.prototype.getStats=function(g){if(g&&g instanceof c.MediaStreamTrack){var v=null;if(this.transceivers.forEach(function(_){_.rtpSender&&_.rtpSender.track===g?v=_.rtpSender:_.rtpReceiver&&_.rtpReceiver.track===g&&(v=_.rtpReceiver)}),!v)throw o("InvalidAccessError","Invalid selector.");return v.getStats()}var b=[];return this.transceivers.forEach(function(_){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(C){_[C]&&b.push(_[C].getStats())})}),Promise.all(b).then(function(_){var C=new Map;return _.forEach(function(T){T.forEach(function(P){C.set(P.id,P)})}),C})};var x=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];x.forEach(function(g){var v=c[g];if(v&&v.prototype&&v.prototype.getStats){var b=v.prototype.getStats;v.prototype.getStats=function(){return b.apply(this).then(function(_){var C=new Map;return Object.keys(_).forEach(function(T){_[T].type=e(_[T]),C.set(T,_[T])}),C})}}});var M=["createOffer","createAnswer"];return M.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var b=arguments;return typeof b[0]=="function"||typeof b[1]=="function"?v.apply(this,[arguments[2]]).then(function(_){typeof b[0]=="function"&&b[0].apply(null,[_])},function(_){typeof b[1]=="function"&&b[1].apply(null,[_])}):v.apply(this,arguments)}}),M=["setLocalDescription","setRemoteDescription","addIceCandidate"],M.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var b=arguments;return typeof b[1]=="function"||typeof b[2]=="function"?v.apply(this,arguments).then(function(){typeof b[1]=="function"&&b[1].apply(null)},function(_){typeof b[2]=="function"&&b[2].apply(null,[_])}):v.apply(this,arguments)}}),["getStats"].forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var b=arguments;return typeof b[1]=="function"?v.apply(this,arguments).then(function(){typeof b[1]=="function"&&b[1].apply(null)}):v.apply(this,arguments)}}),m},cs}var Ol=Al();const zl=Fr(Ol);function lc(r){const e=r&&r.navigator,t=function(i){return{name:{PermissionDeniedError:"NotAllowedError"}[i.name]||i.name,message:i.message,constraint:i.constraint,toString(){return this.name}}},n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(i){return n(i).catch(s=>Promise.reject(t(s)))})}function uc(r){"getDisplayMedia"in r.navigator&&r.navigator.mediaDevices&&(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||(r.navigator.mediaDevices.getDisplayMedia=r.navigator.getDisplayMedia.bind(r.navigator)))}function Ds(r,e){if(r.RTCIceGatherer&&(r.RTCIceCandidate||(r.RTCIceCandidate=function(i){return i}),r.RTCSessionDescription||(r.RTCSessionDescription=function(i){return i}),e.version<15025)){const n=Object.getOwnPropertyDescriptor(r.MediaStreamTrack.prototype,"enabled");Object.defineProperty(r.MediaStreamTrack.prototype,"enabled",{set(i){n.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)&&Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new r.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),r.RTCDtmfSender&&!r.RTCDTMFSender&&(r.RTCDTMFSender=r.RTCDtmfSender);const t=zl(r,e.version);r.RTCPeerConnection=function(i){return i&&i.iceServers&&(i.iceServers=Rl(i.iceServers,e.version),ro("ICE servers after filtering:",i.iceServers)),new t(i)},r.RTCPeerConnection.prototype=t.prototype}function hc(r){r.RTCRtpSender&&!("replaceTrack"in r.RTCRtpSender.prototype)&&(r.RTCRtpSender.prototype.replaceTrack=r.RTCRtpSender.prototype.setTrack)}const Yo=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:uc,shimGetUserMedia:lc,shimPeerConnection:Ds,shimReplaceTrack:hc},Symbol.toStringTag,{value:"Module"}));function fc(r,e){const t=r&&r.navigator,n=r&&r.MediaStreamTrack;if(t.getUserMedia=function(i,s,a){Lr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)}),n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const o=a.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function Il(r,e){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,r.navigator.mediaDevices.getUserMedia(n)})}function dc(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Fs(r,e){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection))return;!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=r.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};r.RTCPeerConnection.prototype[i]=a[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[s,a,o]=arguments;return n.apply(this,[s||null]).then(c=>{if(e.version<53&&!a)try{c.forEach(l=>{l.type=t[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((u,f)=>{c.set(f,Object.assign({},u,{type:t[u.type]||u.type}))})}return c}).then(a,o)}}function pc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(s=>s._pc=this),i});const t=r.RTCPeerConnection.prototype.addTrack;t&&(r.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function mc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n}),Un(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function yc(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){Lr("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function gc(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function vc(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.addTransceiver;e&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],i=n&&"sendEncodings"in n;i&&n.sendEncodings.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(i){const{sender:a}=s,o=a.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=n.sendEncodings,a.sendEncodings=n.sendEncodings,this.setParametersPromises.push(a.setParameters(o).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function Sc(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const e=r.RTCRtpSender.prototype.getParameters;e&&(r.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function xc(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function _c(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}const Zo=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:vc,shimCreateAnswer:_c,shimCreateOffer:xc,shimGetDisplayMedia:Il,shimGetParameters:Sc,shimGetUserMedia:fc,shimOnTrack:dc,shimPeerConnection:Fs,shimRTCDataChannel:gc,shimReceiverGetStats:mc,shimRemoveStream:yc,shimSenderGetStats:pc},Symbol.toStringTag,{value:"Module"}));function bc(r){if(!(typeof r!="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>e.call(this,i,n)),n.getVideoTracks().forEach(i=>e.call(this,i,n))},r.RTCPeerConnection.prototype.addTrack=function(n,...i){return i&&i.forEach(s=>{this._localStreams?this._localStreams.includes(s)||this._localStreams.push(s):this._localStreams=[s]}),e.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(s=>{i.includes(s.track)&&this.removeTrack(s)})})}}function Tc(r){if(!(typeof r!="object"||!r.RTCPeerConnection)&&("getRemoteStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in r.RTCPeerConnection.prototype))){Object.defineProperty(r.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(s=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(s)>=0)return;n._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,n.dispatchEvent(a)})}),e.apply(n,arguments)}}}function Mc(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(l,u){const f=arguments.length>=2?arguments[2]:arguments[0],p=t.apply(this,[f]);return u?(p.then(l,u),Promise.resolve()):p},e.createAnswer=function(l,u){const f=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[f]);return u?(p.then(l,u),Promise.resolve()):p};let o=function(c,l,u){const f=i.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f};e.setLocalDescription=o,o=function(c,l,u){const f=s.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f},e.setRemoteDescription=o,o=function(c,l,u){const f=a.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f},e.addIceCandidate=o}function Cc(r){const e=r&&r.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>n(wc(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(n,i,s){e.mediaDevices.getUserMedia(n).then(i,s)}).bind(e))}function wc(r){return r&&r.video!==void 0?Object.assign({},r,{video:Ka(r.video)}):r}function Pc(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection;r.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const s=[];for(let a=0;a<n.iceServers.length;a++){let o=n.iceServers[a];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Lr("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,s.push(o)):s.push(n.iceServers[a])}n.iceServers=s}return new e(n,i)},r.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Ec(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function kc(r){const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio"),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):n.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video")}return e.apply(this,arguments)}}function Rc(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}const Ko=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:Rc,shimCallbacksAPI:Mc,shimConstraints:wc,shimCreateOfferLegacy:kc,shimGetUserMedia:Cc,shimLocalStreamsAPI:bc,shimRTCIceServerUrls:Pc,shimRemoteStreamsAPI:Tc,shimTrackEventTransceiver:Ec},Symbol.toStringTag,{value:"Module"}));var Bl=cc();const Mr=Fr(Bl);function Cr(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const e=r.RTCIceCandidate;r.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const i=new e(n),s=Mr.parseCandidate(n.candidate),a=Object.assign(i,s);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new e(n)},r.RTCIceCandidate.prototype=e.prototype,Un(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ei(r,e){if(!r.RTCPeerConnection)return;"sctp"in r.RTCPeerConnection.prototype||Object.defineProperty(r.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const c=Mr.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=Mr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},n=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},i=function(o){let c=65536;return e.browser==="firefox"&&(e.version<57?o===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const u=Mr.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const c=n(arguments[0]),l=i(c),u=s(arguments[0],c);let f;l===0&&u===0?f=Number.POSITIVE_INFINITY:l===0||u===0?f=Math.max(l,u):f=Math.min(l,u);const p={};Object.defineProperty(p,"maxMessageSize",{get(){return f}}),this._sctp=p}return a.apply(this,arguments)}}function ti(r){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype))return;function e(n,i){const s=n.send;n.send=function(){const o=arguments[0],c=o.length||o.size||o.byteLength;if(n.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(n,arguments)}}const t=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const i=t.apply(this,arguments);return e(i,this),i},Un(r,"datachannel",n=>(e(n.channel,n.target),n))}function Ls(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const e=r.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Vs(r,e){if(!r.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
|
|
65
|
+
a=mid:`+M.mid+`\r
|
|
66
|
+
`;return}if(M.stream){var P;M.kind==="audio"?P=M.stream.getAudioTracks()[0]:M.kind==="video"&&(P=M.stream.getVideoTracks()[0]),P&&l>=15019&&M.kind==="video"&&!M.sendEncodingParameters[0].rtx&&(M.sendEncodingParameters[0].rtx={ssrc:M.sendEncodingParameters[0].ssrc+1})}var E=i(M.localCapabilities,M.remoteCapabilities),z=E.codecs.filter(function(I){return I.name.toLowerCase()==="rtx"}).length;!z&&M.sendEncodingParameters[0].rtx&&delete M.sendEncodingParameters[0].rtx,v+=t(M,E,"answer",M.stream,g._dtlsRole),M.rtcpParameters&&M.rtcpParameters.reducedSize&&(v+=`a=rtcp-rsize\r
|
|
67
|
+
`)}});var b=new c.RTCSessionDescription({type:"answer",sdp:v});return Promise.resolve(b)},m.prototype.addIceCandidate=function(g){var v=this,_;return g&&!(g.sdpMLineIndex!==void 0||g.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(b,M){if(v._remoteDescription)if(!g||g.candidate==="")for(var C=0;C<v.transceivers.length&&!(!v.transceivers[C].rejected&&(v.transceivers[C].iceTransport.addRemoteCandidate({}),_=r.getMediaSections(v._remoteDescription.sdp),_[C]+=`a=end-of-candidates\r
|
|
68
|
+
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+_.join(""),v.usingBundle));C++);else{var P=g.sdpMLineIndex;if(g.sdpMid){for(var E=0;E<v.transceivers.length;E++)if(v.transceivers[E].mid===g.sdpMid){P=E;break}}var z=v.transceivers[P];if(z){if(z.rejected)return b();var I=Object.keys(g.candidate).length>0?r.parseCandidate(g.candidate):{};if(I.protocol==="tcp"&&(I.port===0||I.port===9)||I.component&&I.component!==1)return b();if((P===0||P>0&&z.iceTransport!==v.transceivers[0].iceTransport)&&!a(z.iceTransport,I))return M(o("OperationError","Can not add ICE candidate"));var R=g.candidate.trim();R.indexOf("a=")===0&&(R=R.substr(2)),_=r.getMediaSections(v._remoteDescription.sdp),_[P]+="a="+(I.type?R:"end-of-candidates")+`\r
|
|
69
|
+
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+_.join("")}else return M(o("OperationError","Can not add ICE candidate"))}else return M(o("InvalidStateError","Can not add ICE candidate without a remote description"));b()})},m.prototype.getStats=function(g){if(g&&g instanceof c.MediaStreamTrack){var v=null;if(this.transceivers.forEach(function(b){b.rtpSender&&b.rtpSender.track===g?v=b.rtpSender:b.rtpReceiver&&b.rtpReceiver.track===g&&(v=b.rtpReceiver)}),!v)throw o("InvalidAccessError","Invalid selector.");return v.getStats()}var _=[];return this.transceivers.forEach(function(b){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(M){b[M]&&_.push(b[M].getStats())})}),Promise.all(_).then(function(b){var M=new Map;return b.forEach(function(C){C.forEach(function(P){M.set(P.id,P)})}),M})};var x=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];x.forEach(function(g){var v=c[g];if(v&&v.prototype&&v.prototype.getStats){var _=v.prototype.getStats;v.prototype.getStats=function(){return _.apply(this).then(function(b){var M=new Map;return Object.keys(b).forEach(function(C){b[C].type=e(b[C]),M.set(C,b[C])}),M})}}});var T=["createOffer","createAnswer"];return T.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[0]=="function"||typeof _[1]=="function"?v.apply(this,[arguments[2]]).then(function(b){typeof _[0]=="function"&&_[0].apply(null,[b])},function(b){typeof _[1]=="function"&&_[1].apply(null,[b])}):v.apply(this,arguments)}}),T=["setLocalDescription","setRemoteDescription","addIceCandidate"],T.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"||typeof _[2]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)},function(b){typeof _[2]=="function"&&_[2].apply(null,[b])}):v.apply(this,arguments)}}),["getStats"].forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)}):v.apply(this,arguments)}}),m},hs}var Ll=Fl();const Vl=Vr(Ll);function pc(r){const e=r&&r.navigator,t=function(i){return{name:{PermissionDeniedError:"NotAllowedError"}[i.name]||i.name,message:i.message,constraint:i.constraint,toString(){return this.name}}},n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(i){return n(i).catch(s=>Promise.reject(t(s)))})}function mc(r){"getDisplayMedia"in r.navigator&&r.navigator.mediaDevices&&(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||(r.navigator.mediaDevices.getDisplayMedia=r.navigator.getDisplayMedia.bind(r.navigator)))}function Vs(r,e){if(r.RTCIceGatherer&&(r.RTCIceCandidate||(r.RTCIceCandidate=function(i){return i}),r.RTCSessionDescription||(r.RTCSessionDescription=function(i){return i}),e.version<15025)){const n=Object.getOwnPropertyDescriptor(r.MediaStreamTrack.prototype,"enabled");Object.defineProperty(r.MediaStreamTrack.prototype,"enabled",{set(i){n.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)&&Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new r.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),r.RTCDtmfSender&&!r.RTCDTMFSender&&(r.RTCDTMFSender=r.RTCDtmfSender);const t=Vl(r,e.version);r.RTCPeerConnection=function(i){return i&&i.iceServers&&(i.iceServers=Dl(i.iceServers,e.version),co("ICE servers after filtering:",i.iceServers)),new t(i)},r.RTCPeerConnection.prototype=t.prototype}function yc(r){r.RTCRtpSender&&!("replaceTrack"in r.RTCRtpSender.prototype)&&(r.RTCRtpSender.prototype.replaceTrack=r.RTCRtpSender.prototype.setTrack)}const na=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:mc,shimGetUserMedia:pc,shimPeerConnection:Vs,shimReplaceTrack:yc},Symbol.toStringTag,{value:"Module"}));function gc(r,e){const t=r&&r.navigator,n=r&&r.MediaStreamTrack;if(t.getUserMedia=function(i,s,a){Jr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)}),n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const o=a.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function Jl(r,e){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,r.navigator.mediaDevices.getUserMedia(n)})}function vc(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Js(r,e){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection))return;!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=r.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};r.RTCPeerConnection.prototype[i]=a[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[s,a,o]=arguments;return n.apply(this,[s||null]).then(c=>{if(e.version<53&&!a)try{c.forEach(l=>{l.type=t[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((u,f)=>{c.set(f,Object.assign({},u,{type:t[u.type]||u.type}))})}return c}).then(a,o)}}function Sc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(s=>s._pc=this),i});const t=r.RTCPeerConnection.prototype.addTrack;t&&(r.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function xc(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n}),Jn(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function _c(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){Jr("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function bc(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function Tc(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.addTransceiver;e&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],i=n&&"sendEncodings"in n;i&&n.sendEncodings.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(i){const{sender:a}=s,o=a.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=n.sendEncodings,a.sendEncodings=n.sendEncodings,this.setParametersPromises.push(a.setParameters(o).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function Mc(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const e=r.RTCRtpSender.prototype.getParameters;e&&(r.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function Cc(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function wc(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}const ia=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:Tc,shimCreateAnswer:wc,shimCreateOffer:Cc,shimGetDisplayMedia:Jl,shimGetParameters:Mc,shimGetUserMedia:gc,shimOnTrack:vc,shimPeerConnection:Js,shimRTCDataChannel:bc,shimReceiverGetStats:xc,shimRemoveStream:_c,shimSenderGetStats:Sc},Symbol.toStringTag,{value:"Module"}));function Pc(r){if(!(typeof r!="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>e.call(this,i,n)),n.getVideoTracks().forEach(i=>e.call(this,i,n))},r.RTCPeerConnection.prototype.addTrack=function(n,...i){return i&&i.forEach(s=>{this._localStreams?this._localStreams.includes(s)||this._localStreams.push(s):this._localStreams=[s]}),e.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(s=>{i.includes(s.track)&&this.removeTrack(s)})})}}function Ec(r){if(!(typeof r!="object"||!r.RTCPeerConnection)&&("getRemoteStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in r.RTCPeerConnection.prototype))){Object.defineProperty(r.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(s=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(s)>=0)return;n._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,n.dispatchEvent(a)})}),e.apply(n,arguments)}}}function kc(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(l,u){const f=arguments.length>=2?arguments[2]:arguments[0],p=t.apply(this,[f]);return u?(p.then(l,u),Promise.resolve()):p},e.createAnswer=function(l,u){const f=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[f]);return u?(p.then(l,u),Promise.resolve()):p};let o=function(c,l,u){const f=i.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f};e.setLocalDescription=o,o=function(c,l,u){const f=s.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f},e.setRemoteDescription=o,o=function(c,l,u){const f=a.apply(this,[c]);return u?(f.then(l,u),Promise.resolve()):f},e.addIceCandidate=o}function Rc(r){const e=r&&r.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>n(Ac(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(n,i,s){e.mediaDevices.getUserMedia(n).then(i,s)}).bind(e))}function Ac(r){return r&&r.video!==void 0?Object.assign({},r,{video:ic(r.video)}):r}function Oc(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection;r.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const s=[];for(let a=0;a<n.iceServers.length;a++){let o=n.iceServers[a];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Jr("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,s.push(o)):s.push(n.iceServers[a])}n.iceServers=s}return new e(n,i)},r.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function zc(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ic(r){const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio"),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):n.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video")}return e.apply(this,arguments)}}function Bc(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}const ra=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:Bc,shimCallbacksAPI:kc,shimConstraints:Ac,shimCreateOfferLegacy:Ic,shimGetUserMedia:Rc,shimLocalStreamsAPI:Pc,shimRTCIceServerUrls:Oc,shimRemoteStreamsAPI:Ec,shimTrackEventTransceiver:zc},Symbol.toStringTag,{value:"Module"}));var jl=dc();const Cr=Vr(jl);function wr(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const e=r.RTCIceCandidate;r.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const i=new e(n),s=Cr.parseCandidate(n.candidate),a=Object.assign(i,s);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new e(n)},r.RTCIceCandidate.prototype=e.prototype,Jn(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ri(r,e){if(!r.RTCPeerConnection)return;"sctp"in r.RTCPeerConnection.prototype||Object.defineProperty(r.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const c=Cr.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=Cr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},n=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},i=function(o){let c=65536;return e.browser==="firefox"&&(e.version<57?o===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const u=Cr.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const c=n(arguments[0]),l=i(c),u=s(arguments[0],c);let f;l===0&&u===0?f=Number.POSITIVE_INFINITY:l===0||u===0?f=Math.max(l,u):f=Math.min(l,u);const p={};Object.defineProperty(p,"maxMessageSize",{get(){return f}}),this._sctp=p}return a.apply(this,arguments)}}function si(r){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype))return;function e(n,i){const s=n.send;n.send=function(){const o=arguments[0],c=o.length||o.size||o.byteLength;if(n.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(n,arguments)}}const t=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const i=t.apply(this,arguments);return e(i,this),i},Jn(r,"datachannel",n=>(e(n.channel,n.target),n))}function js(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const e=r.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Gs(r,e){if(!r.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
|
|
70
70
|
a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
71
71
|
`).filter(a=>a.trim()!=="a=extmap-allow-mixed").join(`
|
|
72
|
-
`);r.RTCSessionDescription&&i instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:i.type,sdp:s}):i.sdp=s}return t.apply(this,arguments)}}function
|
|
72
|
+
`);r.RTCSessionDescription&&i instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:i.type,sdp:s}):i.sdp=s}return t.apply(this,arguments)}}function Pr(r,e){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const t=r.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const Gl=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:Gs,shimAddIceCandidateNullOrEmpty:Pr,shimConnectionState:js,shimMaxMessageSize:ri,shimRTCIceCandidate:wr,shimSendThrowTypeError:si},Symbol.toStringTag,{value:"Module"}));function $l({window:r}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=co,n=Nl(r),i={browserDetails:n,commonShim:Gl,extractVersion:ii,disableLog:Il,disableWarnings:Bl};switch(n.browser){case"chrome":if(!Qo||!Ls||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(n.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=Qo,Pr(r,n),rc(r,n),sc(r),Ls(r,n),oc(r),hc(r,n),ac(r),cc(r),lc(r),fc(r,n),wr(r),js(r),ri(r,n),si(r),Gs(r,n);break;case"firefox":if(!ia||!Js||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=ia,Pr(r,n),gc(r,n),Js(r,n),vc(r),_c(r),Sc(r),xc(r),bc(r),Tc(r),Mc(r),Cc(r),wc(r),wr(r),js(r),ri(r,n),si(r);break;case"edge":if(!na||!Vs||!e.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=na,pc(r),mc(r),Vs(r,n),yc(r),ri(r,n),si(r);break;case"safari":if(!ra||!e.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=ra,Pr(r,n),Oc(r),Ic(r),kc(r),Pc(r),Ec(r),zc(r),Rc(r),Bc(r),wr(r),ri(r,n),si(r),Gs(r,n);break;default:t("Unsupported browser!");break}return i}const sa=$l({window:typeof window>"u"?void 0:window});function Bt(r,e,t,n){Object.defineProperty(r,e,{get:t,set:n,enumerable:!0,configurable:!0})}var fs=sa.default||sa,Wn=new((function(){function r(){this.isIOS=["iPad","iPhone","iPod"].includes(navigator.platform),this.supportedBrowsers=["firefox","chrome","safari"],this.minFirefoxVersion=59,this.minChromeVersion=72,this.minSafariVersion=605}return r.prototype.isWebRTCSupported=function(){return typeof RTCPeerConnection<"u"},r.prototype.isBrowserSupported=function(){var e=this.getBrowser(),t=this.getVersion(),n=this.supportedBrowsers.includes(e);return n?e==="chrome"?t>=this.minChromeVersion:e==="firefox"?t>=this.minFirefoxVersion:e==="safari"?!this.isIOS&&t>=this.minSafariVersion:!1:!1},r.prototype.getBrowser=function(){return fs.browserDetails.browser},r.prototype.getVersion=function(){return fs.browserDetails.version||0},r.prototype.isUnifiedPlanSupported=function(){var e=this.getBrowser(),t=fs.browserDetails.version||0;if(e==="chrome"&&t<this.minChromeVersion)return!1;if(e==="firefox"&&t>=this.minFirefoxVersion)return!0;if(!window.RTCRtpTransceiver||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var n,i=!1;try{n=new RTCPeerConnection,n.addTransceiver("audio"),i=!0}catch{}finally{n&&n.close()}return i},r.prototype.toString=function(){return`Supports:
|
|
73
73
|
browser:`.concat(this.getBrowser(),`
|
|
74
74
|
version:`).concat(this.getVersion(),`
|
|
75
75
|
isIOS:`).concat(this.isIOS,`
|
|
76
76
|
isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
|
|
77
77
|
isBrowserSupported:`).concat(this.isBrowserSupported(),`
|
|
78
|
-
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),ea={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"},Dl=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=ea,this.browser=Jn.getBrowser(),this.browserVersion=Jn.getVersion(),this.supports=(function(){var e={browser:Jn.isBrowserSupported(),webRTC:Jn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(ea),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=!Jn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=jo.pack,this.unpack=jo.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 Dl,Ac={};zt(Ac,"Peer",()=>Gs,r=>Gs=r);var Vi={},Fl=Object.prototype.hasOwnProperty,Xe="~";function ci(){}Object.create&&(ci.prototype=Object.create(null),new ci().__proto__||(Xe=!1));function Ll(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Oc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Ll(t,n||r,i),a=Xe?Xe+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 Pr(r,e){--r._eventsCount===0?r._events=new ci:delete r._events[e]}function Ve(){this._events=new ci,this._eventsCount=0}Ve.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Fl.call(t,n)&&e.push(Xe?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ve.prototype.listeners=function(e){var t=Xe?Xe+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};Ve.prototype.listenerCount=function(e){var t=Xe?Xe+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ve.prototype.emit=function(e,t,n,i,s,a){var o=Xe?Xe+e:e;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,f;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(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p=c.length,m;for(f=0;f<p;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(m=1,u=new Array(l-1);m<l;m++)u[m-1]=arguments[m];c[f].fn.apply(c[f].context,u)}}return!0};Ve.prototype.on=function(e,t,n){return Oc(this,e,t,n,!1)};Ve.prototype.once=function(e,t,n){return Oc(this,e,t,n,!0)};Ve.prototype.removeListener=function(e,t,n,i){var s=Xe?Xe+e:e;if(!this._events[s])return this;if(!t)return Pr(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&Pr(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:Pr(this,s)}return this};Ve.prototype.removeAllListeners=function(e){var t;return e?(t=Xe?Xe+e:e,this._events[t]&&Pr(this,t)):(this._events=new ci,this._eventsCount=0),this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.addListener=Ve.prototype.on;Ve.prefixed=Xe;Ve.EventEmitter=Ve;Vi=Ve;var $={};zt($,"LogLevel",()=>Qe,r=>Qe=r);zt($,"default",()=>ta,r=>ta=r);var sn=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},on=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))},Vl="PeerJS: ",Qe;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(Qe||(Qe={}));var Jl=(function(){function r(){this._logLevel=Qe.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>=Qe.All&&this._print.apply(this,on([Qe.All],sn(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Warnings&&this._print.apply(this,on([Qe.Warnings],sn(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Errors&&this._print.apply(this,on([Qe.Errors],sn(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=on([Vl],sn(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=Qe.All?console.log.apply(console,on([],sn(i),!1)):e>=Qe.Warnings?console.warn.apply(console,on(["WARNING"],sn(i),!1)):e>=Qe.Errors&&console.error.apply(console,on(["ERROR"],sn(i),!1))},r})(),ta=new Jl,zc={};zt(zc,"Socket",()=>na,r=>na=r);var Ct;(function(r){r.Data="data",r.Media="media"})(Ct||(Ct={}));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 Vt;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(Vt||(Vt={}));var Gt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(Gt||(Gt={}));var Ne;(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"})(Ne||(Ne={}));var so={};so=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 jl=(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)}})(),Gl=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},$l=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))},Wl=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.")},na=(function(r){jl(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="+so.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),$.default.log("Server message received:",o)}catch{$.default.log("Invalid server message",a.data);return}i.emit(Gt.Message,o)},this._socket.onclose=function(a){i._disconnected||($.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(Gt.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),$.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()){$.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Ne.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=$l([],Gl(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=Wl(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(Gt.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})(Vi.EventEmitter),Js={};zt(Js,"MediaConnection",()=>sa,r=>sa=r);var oo={};zt(oo,"Negotiator",()=>ia,r=>ia=r);var kr=function(){return kr=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},kr.apply(this,arguments)},Ki=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(u){try{l(n.next(u))}catch(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},Qi=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(u){return c([l,u])}}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(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ia=(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===Ct.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Ct.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(){$.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;$.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||($.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Ne.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":$.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":$.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":$.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)},$.default.log("Listening for data channel"),e.ondatachannel=function(o){$.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},$.default.log("Listening for remote stream"),e.ontrack=function(o){$.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Ct.Media){var u=l;t._addStreamToMediaConnection(c,u)}}},r.prototype.cleanup=function(){$.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===Ct.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return Qi(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(),$.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(),$.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===Ct.Data&&(s=this.connection,i=kr(kr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Ne.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),$.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(_e.WebRTC,o),$.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s;return Qi(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(),$.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(),$.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Ne.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),$.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(_e.WebRTC,s),$.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return Ki(this,void 0,Promise,function(){var n,i,s,a;return Qi(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,$.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(),$.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),$.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return Ki(this,void 0,Promise,function(){var t,n,i,s,a,o;return Qi(this,function(c){switch(c.label){case 0:$.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(),$.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(_e.WebRTC,o),$.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if($.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return $.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){$.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r})(),ao={};zt(ao,"BaseConnection",()=>ra,r=>ra=r);var Hl=(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)}})(),ra=(function(r){Hl(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})(Vi.EventEmitter),ql=(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)}})(),Rr=function(){return Rr=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},Rr.apply(this,arguments)},Xl=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.")},sa=(function(r){ql(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 oo.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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){$.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 Ne.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Ne.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:$.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){$.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(Rr(Rr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Xl(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(u){i={error:u}}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})(ao.BaseConnection),js={};zt(js,"DataConnection",()=>aa,r=>aa=r);var Ic={};zt(Ic,"EncodingQueue",()=>oa,r=>oa=r);var Yl=(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)}})(),oa=(function(r){Yl(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){$.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})(Vi.EventEmitter),Zl=(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)}})(),Kl=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.")},aa=(function(r){Zl(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 Ic.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||Vt.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){$.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new oo.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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(){$.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){$.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){$.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===Vt.Binary||this.serialization===Vt.BinaryUTF8,o=i;if(a){if(s===Blob){te.blobToArrayBuffer(i,function(l){var u=te.unpack(l);n.emit("data",u)});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===Vt.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===Vt.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===Vt.Binary||this.serialization===Vt.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 $.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);$.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Kl(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 Ne.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Ne.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:$.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e})(ao.BaseConnection),Bc={};zt(Bc,"API",()=>ua,r=>ua=r);var ca=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(u){try{l(n.next(u))}catch(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},la=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(u){return c([l,u])}}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(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ua=(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",so.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.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 ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r})(),Ql=(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)}})(),ri=function(){return ri=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},ri.apply(this,arguments)},jn=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.")},eu=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){Ql(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=ri({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&&$.default.setLogFunction(i._options.logFunction),$.default.logLevel=i._options.debug||0,i._api=new Bc.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=jn(this._connections),a=s.next();!a.done;a=s.next()){var o=eu(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(u){t={error:u}}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 zc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(Gt.Message,function(i){t._handleMessage(i)}),n.on(Gt.Error,function(i){t._abort(_e.SocketError,i)}),n.on(Gt.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on(Gt.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 Ne.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Ne.Error:this._abort(_e.ServerError,a.msg);break;case Ne.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Ne.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Ne.Leave:$.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Ne.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Ne.Offer:var x=a.connectionId,M=this.getConnection(o,x);if(M&&(M.close(),$.default.warn("Offer received for existing Connection ID:".concat(x))),a.type===Ct.Media){var c=new Js.MediaConnection(o,this,{connectionId:x,_payload:a,metadata:a.metadata});M=c,this._addConnection(o,M),this.emit("call",c)}else if(a.type===Ct.Data){var l=new js.DataConnection(o,this,{connectionId:x,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});M=l,this._addConnection(o,M),this.emit("connection",l)}else{$.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(x);try{for(var f=jn(u),p=f.next();!p.done;p=f.next()){var m=p.value;M.handleMessage(m)}}catch(g){n={error:g}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}break;default:if(!a){$.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var x=a.connectionId,M=this.getConnection(o,x);M&&M.peerConnection?M.handleMessage(t):x?this._storeMessage(x,t):$.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){$.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){$.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){$.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Js.MediaConnection(t,this,ri(ri({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){$.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=jn(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(u){i={error:u}}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){$.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){$.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||($.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=jn(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=jn(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;$.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)$.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)$.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})(Vi.EventEmitter),Nc=Ac.Peer;const tu=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Gs},default:Nc,util:te},Symbol.toStringTag,{value:"Module"})),nu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function iu(r){return typeof r=="string"&&nu.test(r)}const Be=[];for(let r=0;r<256;++r)Be.push((r+256).toString(16).slice(1));function ru(r,e=0){return Be[r[e+0]]+Be[r[e+1]]+Be[r[e+2]]+Be[r[e+3]]+"-"+Be[r[e+4]]+Be[r[e+5]]+"-"+Be[r[e+6]]+Be[r[e+7]]+"-"+Be[r[e+8]]+Be[r[e+9]]+"-"+Be[r[e+10]]+Be[r[e+11]]+Be[r[e+12]]+Be[r[e+13]]+Be[r[e+14]]+Be[r[e+15]]}function su(r){if(!iu(r))throw TypeError("Invalid UUID");let e;const t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function ou(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const au="6ba7b810-9dad-11d1-80b4-00c04fd430c8",cu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function lu(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=ou(i)),typeof s=="string"&&(s=su(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(s),l.set(i,s.length),l=t(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,a){o=o||0;for(let u=0;u<16;++u)a[o+u]=l[u];return a}return ru(l)}try{n.name=r}catch{}return n.DNS=au,n.URL=cu,n}function uu(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function us(r,e){return r<<e|r>>>32-e}function hu(r){const e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){const a=unescape(encodeURIComponent(r));r=[];for(let o=0;o<a.length;++o)r.push(a.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);const n=r.length/4+2,i=Math.ceil(n/16),s=new Array(i);for(let a=0;a<i;++a){const o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=r[a*64+c*4]<<24|r[a*64+c*4+1]<<16|r[a*64+c*4+2]<<8|r[a*64+c*4+3];s[a]=o}s[i-1][14]=(r.length-1)*8/Math.pow(2,32),s[i-1][14]=Math.floor(s[i-1][14]),s[i-1][15]=(r.length-1)*8&4294967295;for(let a=0;a<i;++a){const o=new Uint32Array(80);for(let m=0;m<16;++m)o[m]=s[a][m];for(let m=16;m<80;++m)o[m]=us(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],f=t[3],p=t[4];for(let m=0;m<80;++m){const x=Math.floor(m/20),M=us(c,5)+uu(x,l,u,f)+p+e[x]+o[m]>>>0;p=f,f=u,u=us(l,30)>>>0,l=c,c=M}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+f>>>0,t[4]=t[4]+p>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}const fu=lu("v5",80,hu);var hs={exports:{}},fs={exports:{}},ha;function du(){return ha||(ha=1,(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(t,n){return t<<n|t>>>32-n},rotr:function(t,n){return t<<32-n|t>>>n},endian:function(t){if(t.constructor==Number)return e.rotl(t,8)&16711935|e.rotl(t,24)&4278255360;for(var n=0;n<t.length;n++)t[n]=e.endian(t[n]);return t},randomBytes:function(t){for(var n=[];t>0;t--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(t){for(var n=[],i=0,s=0;i<t.length;i++,s+=8)n[s>>>5]|=t[i]<<24-s%32;return n},wordsToBytes:function(t){for(var n=[],i=0;i<t.length*32;i+=8)n.push(t[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(t){for(var n=[],i=0;i<t.length;i++)n.push((t[i]>>>4).toString(16)),n.push((t[i]&15).toString(16));return n.join("")},hexToBytes:function(t){for(var n=[],i=0;i<t.length;i+=2)n.push(parseInt(t.substr(i,2),16));return n},bytesToBase64:function(t){for(var n=[],i=0;i<t.length;i+=3)for(var s=t[i]<<16|t[i+1]<<8|t[i+2],a=0;a<4;a++)i*8+a*6<=t.length*8?n.push(r.charAt(s>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,s=0;i<t.length;s=++i%4)s!=0&&n.push((r.indexOf(t.charAt(i-1))&Math.pow(2,-2*s+8)-1)<<s*2|r.indexOf(t.charAt(i))>>>6-s*2);return n}};fs.exports=e})()),fs.exports}var ds,fa;function da(){if(fa)return ds;fa=1;var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n)&255);return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};return ds=r,ds}var ps,pa;function pu(){if(pa)return ps;pa=1,ps=function(t){return t!=null&&(r(t)||e(t)||!!t._isBuffer)};function r(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function e(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&r(t.slice(0,0))}return ps}var ma;function mu(){return ma||(ma=1,(function(){var r=du(),e=da().utf8,t=pu(),n=da().bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=n.stringToBytes(s):s=e.stringToBytes(s):t(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=r.bytesToWords(s),c=s.length*8,l=1732584193,u=-271733879,f=-1732584194,p=271733878,m=0;m<o.length;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360;o[c>>>5]|=128<<c%32,o[(c+64>>>9<<4)+14]=c;for(var x=i._ff,M=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var b=l,_=u,C=f,T=p;l=x(l,u,f,p,o[m+0],7,-680876936),p=x(p,l,u,f,o[m+1],12,-389564586),f=x(f,p,l,u,o[m+2],17,606105819),u=x(u,f,p,l,o[m+3],22,-1044525330),l=x(l,u,f,p,o[m+4],7,-176418897),p=x(p,l,u,f,o[m+5],12,1200080426),f=x(f,p,l,u,o[m+6],17,-1473231341),u=x(u,f,p,l,o[m+7],22,-45705983),l=x(l,u,f,p,o[m+8],7,1770035416),p=x(p,l,u,f,o[m+9],12,-1958414417),f=x(f,p,l,u,o[m+10],17,-42063),u=x(u,f,p,l,o[m+11],22,-1990404162),l=x(l,u,f,p,o[m+12],7,1804603682),p=x(p,l,u,f,o[m+13],12,-40341101),f=x(f,p,l,u,o[m+14],17,-1502002290),u=x(u,f,p,l,o[m+15],22,1236535329),l=M(l,u,f,p,o[m+1],5,-165796510),p=M(p,l,u,f,o[m+6],9,-1069501632),f=M(f,p,l,u,o[m+11],14,643717713),u=M(u,f,p,l,o[m+0],20,-373897302),l=M(l,u,f,p,o[m+5],5,-701558691),p=M(p,l,u,f,o[m+10],9,38016083),f=M(f,p,l,u,o[m+15],14,-660478335),u=M(u,f,p,l,o[m+4],20,-405537848),l=M(l,u,f,p,o[m+9],5,568446438),p=M(p,l,u,f,o[m+14],9,-1019803690),f=M(f,p,l,u,o[m+3],14,-187363961),u=M(u,f,p,l,o[m+8],20,1163531501),l=M(l,u,f,p,o[m+13],5,-1444681467),p=M(p,l,u,f,o[m+2],9,-51403784),f=M(f,p,l,u,o[m+7],14,1735328473),u=M(u,f,p,l,o[m+12],20,-1926607734),l=g(l,u,f,p,o[m+5],4,-378558),p=g(p,l,u,f,o[m+8],11,-2022574463),f=g(f,p,l,u,o[m+11],16,1839030562),u=g(u,f,p,l,o[m+14],23,-35309556),l=g(l,u,f,p,o[m+1],4,-1530992060),p=g(p,l,u,f,o[m+4],11,1272893353),f=g(f,p,l,u,o[m+7],16,-155497632),u=g(u,f,p,l,o[m+10],23,-1094730640),l=g(l,u,f,p,o[m+13],4,681279174),p=g(p,l,u,f,o[m+0],11,-358537222),f=g(f,p,l,u,o[m+3],16,-722521979),u=g(u,f,p,l,o[m+6],23,76029189),l=g(l,u,f,p,o[m+9],4,-640364487),p=g(p,l,u,f,o[m+12],11,-421815835),f=g(f,p,l,u,o[m+15],16,530742520),u=g(u,f,p,l,o[m+2],23,-995338651),l=v(l,u,f,p,o[m+0],6,-198630844),p=v(p,l,u,f,o[m+7],10,1126891415),f=v(f,p,l,u,o[m+14],15,-1416354905),u=v(u,f,p,l,o[m+5],21,-57434055),l=v(l,u,f,p,o[m+12],6,1700485571),p=v(p,l,u,f,o[m+3],10,-1894986606),f=v(f,p,l,u,o[m+10],15,-1051523),u=v(u,f,p,l,o[m+1],21,-2054922799),l=v(l,u,f,p,o[m+8],6,1873313359),p=v(p,l,u,f,o[m+15],10,-30611744),f=v(f,p,l,u,o[m+6],15,-1560198380),u=v(u,f,p,l,o[m+13],21,1309151649),l=v(l,u,f,p,o[m+4],6,-145523070),p=v(p,l,u,f,o[m+11],10,-1120210379),f=v(f,p,l,u,o[m+2],15,718787259),u=v(u,f,p,l,o[m+9],21,-343485551),l=l+b>>>0,u=u+_>>>0,f=f+C>>>0,p=p+T>>>0}return r.endian([l,u,f,p])};i._ff=function(s,a,o,c,l,u,f){var p=s+(a&o|~a&c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._gg=function(s,a,o,c,l,u,f){var p=s+(a&c|o&~c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._hh=function(s,a,o,c,l,u,f){var p=s+(a^o^c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._ii=function(s,a,o,c,l,u,f){var p=s+(o^(a|~c))+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._blocksize=16,i._digestsize=16,hs.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=r.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?n.bytesToString(o):r.bytesToHex(o)}})()),hs.exports}var yu=mu();const gu=Fr(yu),Le=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ya=1234567;const Uc=Math.PI/180,Dc=180/Math.PI;function vu(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Le[r&255]+Le[r>>8&255]+Le[r>>16&255]+Le[r>>24&255]+"-"+Le[e&255]+Le[e>>8&255]+"-"+Le[e>>16&15|64]+Le[e>>24&255]+"-"+Le[t&63|128]+Le[t>>8&255]+"-"+Le[t>>16&255]+Le[t>>24&255]+Le[n&255]+Le[n>>8&255]+Le[n>>16&255]+Le[n>>24&255]).toLowerCase()}function Rt(r,e,t){return Math.max(e,Math.min(t,r))}function Fc(r,e){return(r%e+e)%e}function Su(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function xu(r,e,t){return r!==e?(t-r)/(e-r):0}function Lc(r,e,t){return(1-t)*r+t*e}function _u(r,e,t,n){return Lc(r,e,1-Math.exp(-t*n))}function bu(r,e=1){return e-Math.abs(Fc(r,e*2)-e)}function Tu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Mu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Cu(r,e){return r+Math.floor(Math.random()*(e-r+1))}function wu(r,e){return r+Math.random()*(e-r)}function Pu(r){return r*(.5-Math.random())}function Eu(r){r!==void 0&&(ya=r);let e=ya+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ku(r){return r*Uc}function Ru(r){return r*Dc}function Au(r){return(r&r-1)===0&&r!==0}function Ou(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function zu(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Iu(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),u=a((e+n)/2),f=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),x=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*f,c*p,o*l);break;case"YZY":r.set(c*p,o*u,c*f,o*l);break;case"ZXZ":r.set(c*f,c*p,o*u,o*l);break;case"XZX":r.set(o*u,c*x,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*x,o*l);break;case"ZYZ":r.set(c*x,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Bu(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Nu(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Dn={DEG2RAD:Uc,RAD2DEG:Dc,generateUUID:vu,clamp:Rt,euclideanModulo:Fc,mapLinear:Su,inverseLerp:xu,lerp:Lc,damp:_u,pingpong:bu,smoothstep:Tu,smootherstep:Mu,randInt:Cu,randFloat:wu,randFloatSpread:Pu,seededRandom:Eu,degToRad:ku,radToDeg:Ru,isPowerOfTwo:Au,ceilPowerOfTwo:Ou,floorPowerOfTwo:zu,setQuaternionFromProperEuler:Iu,normalize:Nu,denormalize:Bu};class re{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],u=n[i+2],f=n[i+3];const p=s[a+0],m=s[a+1],x=s[a+2],M=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=x,e[t+3]=M;return}if(f!==M||c!==p||l!==m||u!==x){let g=1-o;const v=c*p+l*m+u*x+f*M,b=v>=0?1:-1,_=1-v*v;if(_>Number.EPSILON){const T=Math.sqrt(_),P=Math.atan2(T,v*b);g=Math.sin(g*P)/T,o=Math.sin(o*P)/T}const C=o*b;if(c=c*g+p*C,l=l*g+m*C,u=u*g+x*C,f=f*g+M*C,g===1-o){const T=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=T,l*=T,u*=T,f*=T}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],f=s[a],p=s[a+1],m=s[a+2],x=s[a+3];return e[t]=o*x+u*f+c*m-l*p,e[t+1]=c*x+u*p+l*f-o*m,e[t+2]=l*x+u*m+o*p-c*f,e[t+3]=u*x-o*f-c*p-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new re(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),f=o(s/2),p=c(n/2),m=c(i/2),x=c(s/2);switch(a){case"XYZ":this._x=p*u*f+l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f-p*m*x;break;case"YXZ":this._x=p*u*f+l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f+p*m*x;break;case"ZXY":this._x=p*u*f-l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f-p*m*x;break;case"ZYX":this._x=p*u*f-l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f+p*m*x;break;case"YZX":this._x=p*u*f+l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f-p*m*x;break;case"XZY":this._x=p*u*f-l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f+p*m*x;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],f=t[10],p=n+o+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-i)*m}else if(n>o&&n>f){const m=2*Math.sqrt(1+n-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);this._w=(s-l)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+f-n-o);this._w=(a-i)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Rt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-s*c,this._y=i*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-i*o,this._w=a*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),f=Math.sin((1-t)*u)/l,p=Math.sin(t*u)/l;return this._w=a*f+this._w*p,this._x=n*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class W{constructor(e=0,t=0,n=0){this.isVector3=!0,W.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new W(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ga.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ga.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),u=2*(o*t-s*i),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*u,this.y=n+c*u+o*l-s*f,this.z=i+c*f+s*u-a*l,this}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ms.copy(this).projectOnVector(e),this.sub(ms)}reflect(e){return this.sub(ms.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Rt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ms=new W,ga=new re,er=2e3,va=2001;class wt{constructor(e,t,n,i,s,a,o,c,l,u,f,p,m,x,M,g){this.isMatrix4=!0,wt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l,u,f,p,m,x,M,g)}extractPosition(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}multiplyToArray(e,t,n){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(e){return this.makeRotationFromQuaternion(e)}set(e,t,n,i,s,a,o,c,l,u,f,p,m,x,M,g){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=a,v[9]=o,v[13]=c,v[2]=l,v[6]=u,v[10]=f,v[14]=p,v[3]=m,v[7]=x,v[11]=M,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new wt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Mn.setFromMatrixColumn(e,0).length(),s=1/Mn.setFromMatrixColumn(e,1).length(),a=1/Mn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const p=a*u,m=a*f,x=o*u,M=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+x*l,t[5]=p-M*l,t[9]=-o*c,t[2]=M-p*l,t[6]=x+m*l,t[10]=a*c}else if(e.order==="YXZ"){const p=c*u,m=c*f,x=l*u,M=l*f;t[0]=p+M*o,t[4]=x*o-m,t[8]=a*l,t[1]=a*f,t[5]=a*u,t[9]=-o,t[2]=m*o-x,t[6]=M+p*o,t[10]=a*c}else if(e.order==="ZXY"){const p=c*u,m=c*f,x=l*u,M=l*f;t[0]=p-M*o,t[4]=-a*f,t[8]=x+m*o,t[1]=m+x*o,t[5]=a*u,t[9]=M-p*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const p=a*u,m=a*f,x=o*u,M=o*f;t[0]=c*u,t[4]=x*l-m,t[8]=p*l+M,t[1]=c*f,t[5]=M*l+p,t[9]=m*l-x,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const p=a*c,m=a*l,x=o*c,M=o*l;t[0]=c*u,t[4]=M-p*f,t[8]=x*f+m,t[1]=f,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+x,t[10]=p-M*f}else if(e.order==="XZY"){const p=a*c,m=a*l,x=o*c,M=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=p*f+M,t[5]=a*u,t[9]=m*f-x,t[2]=x*f-m,t[6]=o*u,t[10]=M*f+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Uu,e,Du)}lookAt(e,t,n){const i=this.elements;return it.subVectors(e,t),it.lengthSq()===0&&(it.z=1),it.normalize(),qt.crossVectors(n,it),qt.lengthSq()===0&&(Math.abs(n.z)===1?it.x+=1e-4:it.z+=1e-4,it.normalize(),qt.crossVectors(n,it)),qt.normalize(),tr.crossVectors(it,qt),i[0]=qt.x,i[4]=tr.x,i[8]=it.x,i[1]=qt.y,i[5]=tr.y,i[9]=it.y,i[2]=qt.z,i[6]=tr.z,i[10]=it.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],f=n[5],p=n[9],m=n[13],x=n[2],M=n[6],g=n[10],v=n[14],b=n[3],_=n[7],C=n[11],T=n[15],P=i[0],E=i[4],O=i[8],I=i[12],A=i[1],N=i[5],z=i[9],U=i[13],F=i[2],J=i[6],j=i[10],q=i[14],G=i[3],ne=i[7],ie=i[11],he=i[15];return s[0]=a*P+o*A+c*F+l*G,s[4]=a*E+o*N+c*J+l*ne,s[8]=a*O+o*z+c*j+l*ie,s[12]=a*I+o*U+c*q+l*he,s[1]=u*P+f*A+p*F+m*G,s[5]=u*E+f*N+p*J+m*ne,s[9]=u*O+f*z+p*j+m*ie,s[13]=u*I+f*U+p*q+m*he,s[2]=x*P+M*A+g*F+v*G,s[6]=x*E+M*N+g*J+v*ne,s[10]=x*O+M*z+g*j+v*ie,s[14]=x*I+M*U+g*q+v*he,s[3]=b*P+_*A+C*F+T*G,s[7]=b*E+_*N+C*J+T*ne,s[11]=b*O+_*z+C*j+T*ie,s[15]=b*I+_*U+C*q+T*he,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],f=e[6],p=e[10],m=e[14],x=e[3],M=e[7],g=e[11],v=e[15];return x*(+s*c*f-i*l*f-s*o*p+n*l*p+i*o*m-n*c*m)+M*(+t*c*m-t*l*p+s*a*p-i*a*m+i*l*u-s*c*u)+g*(+t*l*f-t*o*m-s*a*f+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*f+t*o*p+i*a*f-n*a*p+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=e[9],p=e[10],m=e[11],x=e[12],M=e[13],g=e[14],v=e[15],b=f*g*l-M*p*l+M*c*m-o*g*m-f*c*v+o*p*v,_=x*p*l-u*g*l-x*c*m+a*g*m+u*c*v-a*p*v,C=u*M*l-x*f*l+x*o*m-a*M*m-u*o*v+a*f*v,T=x*f*c-u*M*c-x*o*p+a*M*p+u*o*g-a*f*g,P=t*b+n*_+i*C+s*T;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/P;return e[0]=b*E,e[1]=(M*p*s-f*g*s-M*i*m+n*g*m+f*i*v-n*p*v)*E,e[2]=(o*g*s-M*c*s+M*i*l-n*g*l-o*i*v+n*c*v)*E,e[3]=(f*c*s-o*p*s-f*i*l+n*p*l+o*i*m-n*c*m)*E,e[4]=_*E,e[5]=(u*g*s-x*p*s+x*i*m-t*g*m-u*i*v+t*p*v)*E,e[6]=(x*c*s-a*g*s-x*i*l+t*g*l+a*i*v-t*c*v)*E,e[7]=(a*p*s-u*c*s+u*i*l-t*p*l-a*i*m+t*c*m)*E,e[8]=C*E,e[9]=(x*f*s-u*M*s-x*n*m+t*M*m+u*n*v-t*f*v)*E,e[10]=(a*M*s-x*o*s+x*n*l-t*M*l-a*n*v+t*o*v)*E,e[11]=(u*o*s-a*f*s-u*n*l+t*f*l+a*n*m-t*o*m)*E,e[12]=T*E,e[13]=(u*M*i-x*f*i+x*n*p-t*M*p-u*n*g+t*f*g)*E,e[14]=(x*o*i-a*M*i-x*n*c+t*M*c+a*n*g-t*o*g)*E,e[15]=(a*f*i-u*o*i+u*n*c-t*f*c-a*n*p+t*o*p)*E,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*a,0,l*c-i*o,u*c+i*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,f=o+o,p=s*l,m=s*u,x=s*f,M=a*u,g=a*f,v=o*f,b=c*l,_=c*u,C=c*f,T=n.x,P=n.y,E=n.z;return i[0]=(1-(M+v))*T,i[1]=(m+C)*T,i[2]=(x-_)*T,i[3]=0,i[4]=(m-C)*P,i[5]=(1-(p+v))*P,i[6]=(g+b)*P,i[7]=0,i[8]=(x+_)*E,i[9]=(g-b)*E,i[10]=(1-(p+M))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Mn.set(i[0],i[1],i[2]).length();const a=Mn.set(i[4],i[5],i[6]).length(),o=Mn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Tt.copy(this);const l=1/s,u=1/a,f=1/o;return Tt.elements[0]*=l,Tt.elements[1]*=l,Tt.elements[2]*=l,Tt.elements[4]*=u,Tt.elements[5]*=u,Tt.elements[6]*=u,Tt.elements[8]*=f,Tt.elements[9]*=f,Tt.elements[10]*=f,t.setFromRotationMatrix(Tt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=er){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),p=(n+i)/(n-i);let m,x;if(o===er)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===va)m=-a/(a-s),x=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=er){const c=this.elements,l=1/(t-e),u=1/(n-i),f=1/(a-s),p=(t+e)*l,m=(n+i)*u;let x,M;if(o===er)x=(a+s)*f,M=-2*f;else if(o===va)x=s*f,M=-1*f;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=M,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Mn=new W,Tt=new wt,Uu=new W(0,0,0),Du=new W(1,1,1),qt=new W,tr=new W,it=new W,Sa=new wt,xa=new re;class li{constructor(e=0,t=0,n=0,i=li.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new li(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],u=i[9],f=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Rt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Rt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Rt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Rt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Rt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Sa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Sa,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xa.setFromEuler(this),this.setFromQuaternion(xa,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(e){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}li.DEFAULT_ORDER="XYZ";class In{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new In(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Rt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}In.isVector2=!0;class tt{constructor(e=0,t=0,n=0,i=1){tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new tt(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],f=c[8],p=c[1],m=c[5],x=c[9],M=c[2],g=c[6],v=c[10];if(Math.abs(u-p)<.01&&Math.abs(f-M)<.01&&Math.abs(x-g)<.01){if(Math.abs(u+p)<.1&&Math.abs(f+M)<.1&&Math.abs(x+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(l+1)/2,C=(m+1)/2,T=(v+1)/2,P=(u+p)/4,E=(f+M)/4,O=(x+g)/4;return _>C&&_>T?_<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(_),i=P/n,s=E/n):C>T?C<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(C),n=P/i,s=O/i):T<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),n=E/s,i=O/s),this.set(n,i,s,t),this}let b=Math.sqrt((g-x)*(g-x)+(f-M)*(f-M)+(p-u)*(p-u));return Math.abs(b)<.001&&(b=1),this.x=(g-x)/b,this.y=(f-M)/b,this.z=(p-u)/b,this.w=Math.acos((l+m+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ot{constructor(e,t,n,i,s,a,o,c,l){Ot.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],f=n[7],p=n[2],m=n[5],x=n[8],M=i[0],g=i[3],v=i[6],b=i[1],_=i[4],C=i[7],T=i[2],P=i[5],E=i[8];return s[0]=a*M+o*b+c*T,s[3]=a*g+o*_+c*P,s[6]=a*v+o*C+c*E,s[1]=l*M+u*b+f*T,s[4]=l*g+u*_+f*P,s[7]=l*v+u*C+f*E,s[2]=p*M+m*b+x*T,s[5]=p*g+m*_+x*P,s[8]=p*v+m*C+x*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=u*a-o*l,p=o*c-u*s,m=l*s-a*c,x=t*f+n*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/x;return e[0]=f*M,e[1]=(i*l-u*n)*M,e[2]=(o*n-i*a)*M,e[3]=p*M,e[4]=(u*t-i*c)*M,e[5]=(i*s-o*t)*M,e[6]=m*M,e[7]=(n*c-l*t)*M,e[8]=(a*t-n*s)*M,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ys.makeScale(e,t)),this}rotate(e){return this.premultiply(ys.makeRotation(-e)),this}translate(e,t){return this.premultiply(ys.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new Ot().fromArray(this.elements)}}const ys=new Ot;var qe;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(qe||(qe={}));function Ji(r,e,t,n){let i;switch(qe.Random===r?e=Math.random():qe.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case qe.Loop:i=i%1;break;case qe.PingPong:i=Math.abs(i%2-1);break}return i}class pn{constructor(e,t,n,i){this.p=[e,t,n,i]}genValue(e){const t=e*e,n=e*e*e,i=1-e,s=i*i,a=s*i;return this.p[0]*a+this.p[1]*s*e*3+this.p[2]*i*t*3+this.p[3]*n}derivativeCoefficients(e){const t=[];for(let n=e,i=n.length-1;i>0;i--){const s=[];for(let a=0;a<i;a++){const o=i*(n[a+1]-n[a]);s.push(o)}t.push(s),n=s}return t}getSlope(e){const t=this.derivativeCoefficients(this.p)[0],n=1-e,i=n*n,s=n*e*2,a=e*e;return i*t[0]+s*t[1]+a*t[2]}controlCurve(e,t){this.p[1]=e/3+this.p[0],this.p[2]=this.p[3]-t/3}hull(e){let t=this.p,n=[],i,s=0,a=0,o=0;const c=[];for(c[s++]=t[0],c[s++]=t[1],c[s++]=t[2],c[s++]=t[3];t.length>1;){for(n=[],a=0,o=t.length-1;a<o;a++)i=e*t[a]+(1-e)*t[a+1],c[s++]=i,n.push(i);t=n}return c}split(e){const t=this.hull(e);return{left:new pn(t[0],t[4],t[7],t[9]),right:new pn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new pn(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(e){return new pn(e.p0,e.p1,e.p2,e.p3)}}const ui=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),hi=r=>new tt(r.r,r.g,r.b,r.a),Fu=(r,e)=>{switch(e){case"Vector3":return new W(r.x,r.y,r.z);case"Vector4":return new tt(r.x,r.y,r.z,r.w);case"Color":return new W(r.r,r.g,r.b);case"Number":return r;default:return r}},Lu=(r,e)=>{switch(e){case"Vector3":return{x:r.x,y:r.y,z:r.z};case"Vector4":return{x:r.x,y:r.y,z:r.z,w:r.w};case"Color":return{r:r.x,g:r.y,b:r.z};case"Number":return r;default:return r}};class Ar{constructor(e,t){this.a=e,this.b=t,this.type="value"}startGen(e){}genColor(e,t){const n=Math.random();return t.copy(this.a).lerp(this.b,n)}toJSON(){return{type:"RandomColor",a:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Ar(hi(e.a),hi(e.b))}clone(){return new Ar(this.a.clone(),this.b.clone())}}class Bn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t){return this.indexCount===-1&&this.startGen(e),t.copy(this.a).lerp(this.b,e[this.indexCount])}toJSON(){return{type:"ColorRange",a:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Bn(hi(e.a),hi(e.b))}clone(){return new Bn(this.a.clone(),this.b.clone())}}class Qt{constructor(e,t){this.subType=t,this.type="function",this.keys=e}findKey(e){let t=0,n=0,i=this.keys.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.getStartX(s)&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.keys[e][1]}getEndX(e){return e+1<this.keys.length?this.keys[e+1][1]:1}genValue(e,t){const n=this.findKey(t);return this.subType==="Number"?n===-1?this.keys[0][0]:n+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[n+1][0]-this.keys[n][0])*((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))+this.keys[n][0]:n===-1?e.copy(this.keys[0][0]):n+1>=this.keys.length?e.copy(this.keys[this.keys.length-1][0]):e.copy(this.keys[n][0]).lerp(this.keys[n+1][0],(t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([e,t])=>({value:Lu(e,this.subType),pos:t}))}}static fromJSON(e){return new Qt(e.keys.map(t=>[Fu(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new Qt(this.keys.map(([e,t])=>[e,t]),this.subType):new Qt(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const nr=new W;class mn{constructor(e=[[new W(0,0,0),0],[new W(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new Qt(e,"Color"),this.alpha=new Qt(t,"Number")}genColor(e,t,n){return this.color.genValue(nr,n),t.set(nr.x,nr.y,nr.z,this.alpha.genValue(1,n))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(e){if(e.functions){const t=e.functions.map(n=>[Bn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Bn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new mn(t.map(n=>[new W(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new mn;return t.alpha=Qt.fromJSON(e.alpha),t.color=Qt.fromJSON(e.color),t}}clone(){const e=new mn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const gs=new tt;class Or{constructor(e,t){this.indexCount=0,this.type="function",this.gradient1=e,this.gradient2=t}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t,n){return this.gradient1.genColor(e,t,n),this.gradient2.genColor(e,gs,n),e&&e[this.indexCount]!==void 0?t.lerp(gs,e[this.indexCount]):t.lerp(gs,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Or(mn.fromJSON(e.gradient1),mn.fromJSON(e.gradient2))}clone(){return new Or(this.gradient1.clone(),this.gradient2.clone())}}class yn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:ui(this.color)}}static fromJSON(e){return new yn(hi(e.color))}clone(){return new yn(this.color.clone())}}function co(r){switch(r.type){case"ConstantColor":return yn.fromJSON(r);case"ColorRange":return Bn.fromJSON(r);case"RandomColor":return Ar.fromJSON(r);case"Gradient":return mn.fromJSON(r);case"RandomColorBetweenGradient":return Or.fromJSON(r);default:return new yn(new tt(1,1,1,1))}}class ee{constructor(e){this.value=e,this.type="value"}startGen(e){}genValue(e){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(e){return new ee(e.value)}clone(){return new ee(this.value)}}class gn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genValue(e){return this.indexCount===-1&&this.startGen(e),Dn.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new gn(e.a,e.b)}clone(){return new gn(this.a,this.b)}}class Vu{constructor(){this.functions=new Array}findFunction(e){let t=0,n=0,i=this.functions.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.functions[s][1]&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.functions[e][1]}setStartX(e,t){e>0&&(this.functions[e][1]=t)}getEndX(e){return e+1<this.functions.length?this.functions[e+1][1]:1}setEndX(e,t){e+1<this.functions.length&&(this.functions[e+1][1]=t)}insertFunction(e,t){const n=this.findFunction(e);this.functions.splice(n+1,0,[t,e])}removeFunction(e){return this.functions.splice(e,1)[0][0]}getFunction(e){return this.functions[e][0]}setFunction(e,t){this.functions[e][0]=t}get numOfFunctions(){return this.functions.length}}class fi extends Vu{constructor(e=[[new pn(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=e}genValue(e,t=0){const n=this.findFunction(t);return n===-1?0:this.functions[n][0].genValue((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toSVG(e,t){if(t<1)return"";let n=["M",0,this.functions[0][0].p[0]].join(" ");for(let i=1/t;i<=1;i+=1/t)n=[n,"L",i*e,this.genValue(void 0,i)].join(" ");return n}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([e,t])=>({function:e.toJSON(),start:t}))}}static fromJSON(e){return new fi(e.functions.map(t=>[pn.fromJSON(t.function),t.start]))}clone(){return new fi(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function K(r){switch(r.type){case"ConstantValue":return ee.fromJSON(r);case"IntervalValue":return gn.fromJSON(r);case"PiecewiseBezier":return fi.fromJSON(r);default:return new ee(0)}}class di{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new re);let t,n,i,s,a,o;do t=Math.random()*2-1,n=Math.random()*2-1,i=t*t+n*n;while(i>1);do s=Math.random()*2-1,a=Math.random()*2-1,o=s*s+a*a;while(o>1);const c=Math.sqrt((1-i)/o);e[this.indexCount].set(t,n,c*s,c*a)}genValue(e,t,n,i){return this.indexCount===-1&&this.startGen(e),t.copy(e[this.indexCount]),t}toJSON(){return{type:"RandomQuat"}}static fromJSON(e){return new di}clone(){return new di}}class pi{constructor(e,t){this.axis=e,this.angle=t,this.type="rotation"}startGen(e){this.angle.startGen(e)}genValue(e,t,n,i){return t.setFromAxisAngle(this.axis,this.angle.genValue(e,i)*n)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(e){return new pi(new W(e.axis.x,e.axis.y,e.axis.z),K(e.angle))}clone(){return new pi(this.axis.clone(),this.angle.clone())}}class zr{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new li(0,0,0,i)}startGen(e){this.angleX.startGen(e),this.angleY.startGen(e),this.angleZ.startGen(e)}genValue(e,t,n,i){return this.eular.set(this.angleX.genValue(e,i)*n,this.angleY.genValue(e,i)*n,this.angleZ.genValue(e,i)*n),t.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(e){return new zr(K(e.angleX),K(e.angleY),K(e.angleZ),e.eulerOrder)}clone(){return new zr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Vc(r){switch(r.type){case"AxisAngle":return pi.fromJSON(r);case"Euler":return zr.fromJSON(r);case"RandomQuat":return di.fromJSON(r);default:return new di}}class vn{constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="vec3function"}startGen(e){this.x.startGen(e),this.y.startGen(e),this.z.startGen(e)}genValue(e,t,n){return t.set(this.x.genValue(e,n),this.y.genValue(e,n),this.z.genValue(e,n))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new vn(K(e.x),K(e.y),K(e.z))}clone(){return new vn(this.x,this.y,this.z)}}function Ju(r){switch(r.type){case"Vector3Function":return vn.fromJSON(r);default:return new vn(new ee(0),new ee(0),new ee(0))}}function Ir(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return K(r);case"AxisAngle":case"RandomQuat":case"Euler":return Vc(r);case"Vector3Function":return Ju(r);default:return new ee(0)}}class mi{constructor(e={}){var t,n,i,s,a,o,c;this.type="cone",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.angle=(s=e.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(a=e.mode)!==null&&a!==void 0?a:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[]}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Dn.lerp(1-this.thickness,1,Math.random()),s=n*this.arc,a=Math.sqrt(i),o=Math.sin(s),c=Math.cos(s);e.position.x=a*c,e.position.y=a*o,e.position.z=0;const l=this.angle*a;e.velocity.set(0,0,Math.cos(l)).addScaledVector(e.position,Math.sin(l)).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new mi({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new mi({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class yi{constructor(e={}){var t,n,i,s,a,o;this.type="circle",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Dn.lerp(1-this.thickness,1,Math.random()),s=n*this.arc;e.position.x=Math.cos(s),e.position.y=Math.sin(s),e.position.z=0,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*i)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new yi({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new yi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function ir(r,e){return Math.floor(Math.random()*(e-r))+r}const Vr=new W(0,1,0),Jr=new W(0,0,0),ju=new W(1,1,1),_a=new W(0,0,1);class gi{constructor(e={}){var t,n,i,s,a,o,c;this.type="donut",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.donutRadius=(s=e.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(a=e.mode)!==null&&a!==void 0?a:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Dn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=i*Math.PI*2,c=Math.sin(a),l=Math.cos(a);e.position.x=this.radius*l,e.position.y=this.radius*c,e.position.z=0,e.velocity.z=this.donutRadius*s*Math.sin(o),e.velocity.x=this.donutRadius*s*Math.cos(o)*l,e.velocity.y=this.donutRadius*s*Math.cos(o)*c,e.position.add(e.velocity),e.velocity.normalize().multiplyScalar(e.startSpeed),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.velocity,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new gi({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new gi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class vi{constructor(){this.type="point",this._m1=new wt}update(e,t){}initialize(e){const t=Math.random(),n=Math.random(),i=t*Math.PI*2,s=Math.acos(2*n-1),a=Math.cbrt(Math.random()),o=Math.sin(i),c=Math.cos(i),l=Math.sin(s),u=Math.cos(s);e.velocity.x=a*l*c,e.velocity.y=a*l*o,e.velocity.z=a*u,e.velocity.multiplyScalar(e.startSpeed),e.position.setScalar(0),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new vi}clone(){return new vi}}class Nn{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Dn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(2*i-1),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Nn({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Nn({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Si{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Dn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(i),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Si({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Si({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class xi{constructor(e={}){var t,n,i,s;this.type="grid",this.width=(t=e.width)!==null&&t!==void 0?t:1,this.height=(n=e.height)!==null&&n!==void 0?n:1,this.column=(i=e.column)!==null&&i!==void 0?i:10,this.row=(s=e.row)!==null&&s!==void 0?s:10}initialize(e){const t=Math.floor(Math.random()*this.row),n=Math.floor(Math.random()*this.column);e.position.x=n*this.width/this.column-this.width/2,e.position.y=t*this.height/this.row-this.height/2,e.position.z=0,e.velocity.set(0,0,e.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(e){return new xi(e)}clone(){return new xi({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const $s={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:yi,loadJSON:yi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:mi,loadJSON:mi.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:gi,loadJSON:gi.fromJSON},point:{type:"point",params:[],constructor:vi,loadJSON:vi.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Nn,loadJSON:Nn.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Si,loadJSON:Si.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:xi,loadJSON:xi.fromJSON}};function Gu(r,e){return $s[r.type].loadJSON(r,e)}class _i{constructor(e){this.color=e,this.type="ColorOverLife"}initialize(e){this.color.startGen(e.memory)}update(e,t){this.color.genColor(e.memory,e.color,e.age/e.life),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(e){return new _i(co(e.color))}clone(){return new _i(this.color.clone())}reset(){}}class bi{constructor(e){this.angularVelocity=e,this.type="RotationOverLife"}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){typeof e.rotation=="number"&&(e.rotation+=t*this.angularVelocity.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new bi(K(e.angularVelocity))}frameUpdate(e){}clone(){return new bi(this.angularVelocity.clone())}reset(){}}class Ti{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new re,this.tempQuat2=new re}initialize(e){e.rotation instanceof re&&(e.angularVelocity=new re,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof re&&(this.angularVelocity.genValue(e.memory,this.tempQuat,t,e.age/e.life),e.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Ti(Vc(e.angularVelocity))}frameUpdate(e){}clone(){return new Ti(this.angularVelocity.clone())}reset(){}}class Mi{initialize(e,t){this.ps=t,this.x.startGen(e.memory),this.y.startGen(e.memory),this.z.startGen(e.memory)}constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="ForceOverLife",this._temp=new W,this._tempScale=new W,this._tempQ=new re}update(e,t){this._temp.set(this.x.genValue(e.memory,e.age/e.life),this.y.genValue(e.memory,e.age/e.life),this.z.genValue(e.memory,e.age/e.life)),this.ps.worldSpace?e.velocity.addScaledVector(this._temp,t):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),e.velocity.addScaledVector(this._temp,t))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new Mi(K(e.x),K(e.y),K(e.z))}frameUpdate(e){if(this.ps&&!this.ps.worldSpace){const t=this._temp,n=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(t,n,i),n.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new Mi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ci{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof vn?this.size.genValue(e.memory,e.size,e.age/e.life).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(e){return new Ci(Ir(e.size))}frameUpdate(e){}clone(){return new Ci(this.size.clone())}reset(){}}class wi{initialize(e){this.speed.startGen(e.memory)}constructor(e){this.speed=e,this.type="SpeedOverLife"}update(e){e.speedModifier=this.speed.genValue(e.memory,e.age/e.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(e){return new wi(K(e.speed))}frameUpdate(e){}clone(){return new wi(this.speed.clone())}reset(){}}class Pi{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof fi&&(e.uvTile=this.frame.genValue(e.memory,e.age/e.life))}frameUpdate(e){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(e){return new Pi(K(e.frame))}clone(){return new Pi(this.frame.clone())}reset(){}}class Ei{constructor(e,t=new W(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new W,this.rotation=new re}initialize(e){this.orbitSpeed.startGen(e.memory)}update(e,t){this.temp.copy(e.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(e.memory,e.age/e.life)*t),e.position.sub(this.temp),e.position.applyQuaternion(this.rotation),e.position.add(this.temp)}frameUpdate(e){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(e){return new Ei(K(e.orbitSpeed),e.axis?new W(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Ei(this.orbitSpeed.clone())}reset(){}}class vs{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class $u{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return this.head===null}clear(){this.length=0,this.head=this.tail=null}front(){return this.head===null?null:this.head.data}back(){return this.tail===null?null:this.tail.data}dequeue(){if(this.head){const e=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}}pop(){if(this.tail){const e=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}}queue(e){const t=new vs(e);this.tail||(this.tail=t),this.head&&(this.head.prev=t,t.next=this.head),this.head=t,this.length++}push(e){const t=new vs(e);this.head||(this.head=t),this.tail&&(this.tail.next=t,t.prev=this.tail),this.tail=t,this.length++}insertBefore(e,t){const n=new vs(t);n.next=e,n.prev=e.prev,n.prev!==null&&(n.prev.next=n),n.next.prev=n,e==this.head&&(this.head=n),this.length++}remove(e){if(this.head===null||this.tail===null)return;let t=this.head;for(e===this.head.data&&(this.head=this.head.next),e===this.tail.data&&(this.tail=this.tail.prev);t.next!==null&&t.data!==e;)t=t.next;t.data===e&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.length--)}*values(){let e=this.head;for(;e!==null;)yield e.data,e=e.next}}class Wu{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new tt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class Hu{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Br{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(1,1,1),this.length=100,this.speedModifier=1,this.color=new tt,this.previous=new $u,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Hu(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class ki{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Br){const t=e.previous.values();for(let n=0;n<e.previous.length;n++){const i=t.next();i.value.size=this.width.genValue(e.memory,(e.previous.length-n)/e.length)}}}frameUpdate(e){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(e){return new ki(K(e.width))}clone(){return new ki(this.width.clone())}reset(){}}class Ri{constructor(e,t){this.direction=e,this.magnitude=t,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(e){}update(e,t){e.velocity.addScaledVector(this.direction,this.magnitudeValue*t)}frameUpdate(e){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(e){var t;return new Ri(new W(e.direction[0],e.direction[1],e.direction[2]),K((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Ri(this.direction.clone(),this.magnitude.clone())}reset(){}}class Ai{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new W}initialize(e){}update(e,t){this.temp.copy(this.center).sub(e.position).normalize(),e.velocity.addScaledVector(this.temp,this.magnitude/e.position.distanceToSquared(this.center)*t)}frameUpdate(e){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(e){return new Ai(new W(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new Ai(this.center.clone(),this.magnitude)}reset(){}}class Oi{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new W,this._q=new re,this.memory={data:[],dataCount:0}}initialize(e){const t=e.velocity.length();t!=0&&(e.velocity.normalize(),e.velocity.x===0&&e.velocity.y===0?this._temp.set(0,e.velocity.z,0):this._temp.set(-e.velocity.y,e.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(e.velocity),e.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),e.velocity.applyQuaternion(this._q),e.velocity.setLength(t))}update(e,t){}frameUpdate(e){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(e){return new Oi(K(e.angle))}clone(){return new Oi(this.angle)}reset(){}}var On;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(On||(On={}));class zi{constructor(e,t,n,i=On.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new re,this.v_=new W,this.v2_=new W,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===On.Frame?this.emit(e,t):this.mode===On.Birth&&e.age===0?this.emit(e,t):this.mode===On.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new wt;this.setMatrixFromParticle(n,e),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:n,travelDistance:0,particle:e})}frameUpdate(e){if(this.subParticleSystem)for(let t=0;t<this.subEmissions.length;t++)if(this.subEmissions[t].time>=this.subParticleSystem.system.duration)this.subEmissions[t]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,t--;else{const n=this.subEmissions[t];n.particle&&n.particle.age<n.particle.life?this.setMatrixFromParticle(n.matrix,n.particle):n.particle=void 0,this.subParticleSystem.system.emit(e,n,n.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(e,t){return new zi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new zi(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(e,t){let n;if(t.rotation===void 0||this.useVelocityAsBasis)if(t.velocity.x===0&&t.velocity.y===0&&(t.velocity.z===1||t.velocity.z===0))e.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1);else{this.v_.copy(_a).cross(t.velocity),this.v2_.copy(t.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();e.set(this.v_.x/i,this.v2_.x/s,t.velocity.x,t.position.x,this.v_.y/i,this.v2_.y/s,t.velocity.y,t.position.y,this.v_.z/i,this.v2_.z/s,t.velocity.z,t.position.z,0,0,0,1)}else t.rotation instanceof re?n=t.rotation:(this.q_.setFromAxisAngle(_a,t.rotation),n=this.q_),e.compose(t.position,n,ju);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const qu=.5*(Math.sqrt(3)-1),Gn=(3-Math.sqrt(3))/6,Xu=1/3,Et=1/6,Yu=(Math.sqrt(5)-1)/4,Oe=(5-Math.sqrt(5))/20,Re=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),Me=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);class Jc{constructor(e=Math.random){const t=typeof e=="function"?e:Ku(e);this.p=Zu(t),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let n=0;n<512;n++)this.perm[n]=this.p[n&255],this.permMod12[n]=this.perm[n]%12}noise2D(e,t){const n=this.permMod12,i=this.perm;let s=0,a=0,o=0;const c=(e+t)*qu,l=Math.floor(e+c),u=Math.floor(t+c),f=(l+u)*Gn,p=l-f,m=u-f,x=e-p,M=t-m;let g,v;x>M?(g=1,v=0):(g=0,v=1);const b=x-g+Gn,_=M-v+Gn,C=x-1+2*Gn,T=M-1+2*Gn,P=l&255,E=u&255;let O=.5-x*x-M*M;if(O>=0){const N=n[P+i[E]]*3;O*=O,s=O*O*(Re[N]*x+Re[N+1]*M)}let I=.5-b*b-_*_;if(I>=0){const N=n[P+g+i[E+v]]*3;I*=I,a=I*I*(Re[N]*b+Re[N+1]*_)}let A=.5-C*C-T*T;if(A>=0){const N=n[P+1+i[E+1]]*3;A*=A,o=A*A*(Re[N]*C+Re[N+1]*T)}return 70*(s+a+o)}noise3D(e,t,n){const i=this.permMod12,s=this.perm;let a,o,c,l;const u=(e+t+n)*Xu,f=Math.floor(e+u),p=Math.floor(t+u),m=Math.floor(n+u),x=(f+p+m)*Et,M=f-x,g=p-x,v=m-x,b=e-M,_=t-g,C=n-v;let T,P,E,O,I,A;b>=_?_>=C?(T=1,P=0,E=0,O=1,I=1,A=0):b>=C?(T=1,P=0,E=0,O=1,I=0,A=1):(T=0,P=0,E=1,O=1,I=0,A=1):_<C?(T=0,P=0,E=1,O=0,I=1,A=1):b<C?(T=0,P=1,E=0,O=0,I=1,A=1):(T=0,P=1,E=0,O=1,I=1,A=0);const N=b-T+Et,z=_-P+Et,U=C-E+Et,F=b-O+2*Et,J=_-I+2*Et,j=C-A+2*Et,q=b-1+3*Et,G=_-1+3*Et,ne=C-1+3*Et,ie=f&255,he=p&255,se=m&255;let ge=.6-b*b-_*_-C*C;if(ge<0)a=0;else{const ae=i[ie+s[he+s[se]]]*3;ge*=ge,a=ge*ge*(Re[ae]*b+Re[ae+1]*_+Re[ae+2]*C)}let be=.6-N*N-z*z-U*U;if(be<0)o=0;else{const ae=i[ie+T+s[he+P+s[se+E]]]*3;be*=be,o=be*be*(Re[ae]*N+Re[ae+1]*z+Re[ae+2]*U)}let oe=.6-F*F-J*J-j*j;if(oe<0)c=0;else{const ae=i[ie+O+s[he+I+s[se+A]]]*3;oe*=oe,c=oe*oe*(Re[ae]*F+Re[ae+1]*J+Re[ae+2]*j)}let fe=.6-q*q-G*G-ne*ne;if(fe<0)l=0;else{const ae=i[ie+1+s[he+1+s[se+1]]]*3;fe*=fe,l=fe*fe*(Re[ae]*q+Re[ae+1]*G+Re[ae+2]*ne)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const f=(e+t+n+i)*Yu,p=Math.floor(e+f),m=Math.floor(t+f),x=Math.floor(n+f),M=Math.floor(i+f),g=(p+m+x+M)*Oe,v=p-g,b=m-g,_=x-g,C=M-g,T=e-v,P=t-b,E=n-_,O=i-C;let I=0,A=0,N=0,z=0;T>P?I++:A++,T>E?I++:N++,T>O?I++:z++,P>E?A++:N++,P>O?A++:z++,E>O?N++:z++;const U=I>=3?1:0,F=A>=3?1:0,J=N>=3?1:0,j=z>=3?1:0,q=I>=2?1:0,G=A>=2?1:0,ne=N>=2?1:0,ie=z>=2?1:0,he=I>=1?1:0,se=A>=1?1:0,ge=N>=1?1:0,be=z>=1?1:0,oe=T-U+Oe,fe=P-F+Oe,ae=E-J+Oe,je=O-j+Oe,Ue=T-q+2*Oe,De=P-G+2*Oe,Ge=E-ne+2*Oe,xe=O-ie+2*Oe,ye=T-he+3*Oe,ce=P-se+3*Oe,st=E-ge+3*Oe,Pe=O-be+3*Oe,de=T-1+4*Oe,Ye=P-1+4*Oe,yt=E-1+4*Oe,gt=O-1+4*Oe,Ze=p&255,vt=m&255,ot=x&255,at=M&255;let St=.6-T*T-P*P-E*E-O*O;if(St<0)a=0;else{const Q=s[Ze+s[vt+s[ot+s[at]]]]%32*4;St*=St,a=St*St*(Me[Q]*T+Me[Q+1]*P+Me[Q+2]*E+Me[Q+3]*O)}let Ee=.6-oe*oe-fe*fe-ae*ae-je*je;if(Ee<0)o=0;else{const Q=s[Ze+U+s[vt+F+s[ot+J+s[at+j]]]]%32*4;Ee*=Ee,o=Ee*Ee*(Me[Q]*oe+Me[Q+1]*fe+Me[Q+2]*ae+Me[Q+3]*je)}let $e=.6-Ue*Ue-De*De-Ge*Ge-xe*xe;if($e<0)c=0;else{const Q=s[Ze+q+s[vt+G+s[ot+ne+s[at+ie]]]]%32*4;$e*=$e,c=$e*$e*(Me[Q]*Ue+Me[Q+1]*De+Me[Q+2]*Ge+Me[Q+3]*xe)}let nt=.6-ye*ye-ce*ce-st*st-Pe*Pe;if(nt<0)l=0;else{const Q=s[Ze+he+s[vt+se+s[ot+ge+s[at+be]]]]%32*4;nt*=nt,l=nt*nt*(Me[Q]*ye+Me[Q+1]*ce+Me[Q+2]*st+Me[Q+3]*Pe)}let We=.6-de*de-Ye*Ye-yt*yt-gt*gt;if(We<0)u=0;else{const Q=s[Ze+1+s[vt+1+s[ot+1+s[at+1]]]]%32*4;We*=We,u=We*We*(Me[Q]*de+Me[Q+1]*Ye+Me[Q+2]*yt+Me[Q+3]*gt)}return 27*(a+o+c+l+u)}}function Zu(r){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let t=0;t<255;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}return e}function Ku(r){let e=0,t=0,n=0,i=1;const s=Qu();return e=s(" "),t=s(" "),n=s(" "),e-=s(r),e<0&&(e+=1),t-=s(r),t<0&&(t+=1),n-=s(r),n<0&&(n+=1),function(){const a=2091639*e+i*23283064365386963e-26;return e=t,t=n,n=a-(i=a|0)}}function Qu(){let r=4022871197;return function(e){e=e.toString();for(let t=0;t<e.length;t++){r+=e.charCodeAt(t);let n=.02519603282416938*r;r=n>>>0,n-=r,n*=r,r=n>>>0,n-=r,r+=n*4294967296}return(r>>>0)*23283064365386963e-26}}class Ii{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Jc,this.timeOffset=new W,this.temp=new W,this.temp2=new W,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(e){}update(e,t){const n=e.position.x/this.scale.x,i=e.position.y/this.scale.y,s=e.position.z/this.scale.z;this.temp.set(0,0,0);let a=1;for(let o=0;o<this.octaves;o++)this.temp2.set(this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.x*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.y*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.z*a)/a),this.temp.add(this.temp2),a*=2;this.temp.multiply(this.velocityMultiplier),e.velocity.addScaledVector(this.temp,t)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(e){this.timeOffset.x+=e*this.timeScale.x,this.timeOffset.y+=e*this.timeScale.y,this.timeOffset.z+=e*this.timeScale.z}static fromJSON(e){return new Ii(new W(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new W(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new W(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Ii(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const kt=[],Ss=new W,xs=new re;class Bi{constructor(e,t,n=new ee(1),i=new ee(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,kt.length===0)for(let s=0;s<100;s++)kt.push(new Jc)}initialize(e){e.lastPosNoise=new W,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new re,e.generatorIndex=[ir(0,100),ir(0,100),ir(0,100),ir(0,100)],this.positionAmount.startGen(e.memory),this.rotationAmount.startGen(e.memory),this.frequency.startGen(e.memory),this.power.startGen(e.memory)}update(e,t){let n=this.frequency.genValue(e.memory,e.age/e.life),i=this.power.genValue(e.memory,e.age/e.life),s=this.positionAmount.genValue(e.memory,e.age/e.life),a=this.rotationAmount.genValue(e.memory,e.age/e.life);s>0&&e.lastPosNoise!==void 0&&(e.position.sub(e.lastPosNoise),Ss.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(Ss),e.lastPosNoise.copy(Ss)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=kt[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),xs.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(xs),e.lastRotNoise.copy(xs)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(e){this.duration+=e}static fromJSON(e){return new Bi(K(e.frequency),K(e.power),K(e.positionAmount),K(e.rotationAmount))}clone(){return new Bi(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Ni{constructor(e,t){this.color=e,this.speedRange=t,this.type="ColorBySpeed"}initialize(e){this.color.startGen(e.memory)}update(e,t){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(e.memory,e.color,n),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Ni(co(e.color),gn.fromJSON(e.speedRange))}clone(){return new Ni(this.color.clone(),this.speedRange.clone())}reset(){}}class Ui{initialize(e){this.size.startGen(e.memory)}constructor(e,t){this.size=e,this.speedRange=t,this.type="SizeBySpeed"}update(e){const t=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof vn?this.size.genValue(e.memory,e.size,t).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,t))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Ui(Ir(e.size),gn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Ui(this.size.clone(),this.speedRange.clone())}reset(){}}class Di{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new re}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){if(typeof e.rotation=="number"){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);e.rotation+=t*this.angularVelocity.genValue(e.memory,n)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Di(K(e.angularVelocity),gn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Di(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Fi{initialize(e){this.speed.startGen(e.memory)}constructor(e,t){this.speed=e,this.dampen=t,this.type="LimitSpeedOverLife"}update(e,t){let n=e.velocity.length(),i=this.speed.genValue(e.memory,e.age/e.life);if(n>i){const s=(n-i)/n;e.velocity.multiplyScalar(1-s*this.dampen*t*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(e){return new Fi(K(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Fi(this.speed.clone(),this.dampen)}reset(){}}const Nr={ApplyForce:{type:"ApplyForce",constructor:Ri,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Ri.fromJSON},Noise:{type:"Noise",constructor:Bi,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Bi.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Ii,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Ii.fromJSON},GravityForce:{type:"GravityForce",constructor:Ai,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Ai.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:_i,params:[["color",["colorFunc"]]],loadJSON:_i.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:bi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:bi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Ti,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Ti.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ci,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ci.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Ni,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Ni.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Di,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Di.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Ui,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Ui.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:wi,params:[["speed",["value","valueFunc"]]],loadJSON:wi.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Pi,params:[["frame",["value","valueFunc"]]],loadJSON:Pi.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Mi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Mi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Ei,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Ei.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:ki,params:[["width",["value","valueFunc"]]],loadJSON:ki.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Oi,params:[["angle",["value"]]],loadJSON:Oi.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:zi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:zi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Fi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Fi.fromJSON}};function eh(r,e){return Nr[r.type]?Nr[r.type].loadJSON(r,e):null}const th=[];function nh(r){if(!th.find(t=>t.id===r.id)){for(const t of r.emitterShapes)$s[t.type]||($s[t.type]=t);for(const t of r.behaviors)Nr[t.type]||(Nr[t.type]=t)}}var ih=`
|
|
78
|
+
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),oa={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"},Wl=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=oa,this.browser=Wn.getBrowser(),this.browserVersion=Wn.getVersion(),this.supports=(function(){var e={browser:Wn.isBrowserSupported(),webRTC:Wn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(oa),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=!Wn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=Xo.pack,this.unpack=Xo.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 Wl,Nc={};Bt(Nc,"Peer",()=>Hs,r=>Hs=r);var ji={},Hl=Object.prototype.hasOwnProperty,nt="~";function ui(){}Object.create&&(ui.prototype=Object.create(null),new ui().__proto__||(nt=!1));function ql(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Uc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new ql(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 ui:delete r._events[e]}function He(){this._events=new ui,this._eventsCount=0}He.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Hl.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,u,f;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(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p=c.length,m;for(f=0;f<p;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(m=1,u=new Array(l-1);m<l;m++)u[m-1]=arguments[m];c[f].fn.apply(c[f].context,u)}}return!0};He.prototype.on=function(e,t,n){return Uc(this,e,t,n,!1)};He.prototype.once=function(e,t,n){return Uc(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 ui,this._eventsCount=0),this};He.prototype.off=He.prototype.removeListener;He.prototype.addListener=He.prototype.on;He.prefixed=nt;He.EventEmitter=He;ji=He;var j={};Bt(j,"LogLevel",()=>ot,r=>ot=r);Bt(j,"default",()=>aa,r=>aa=r);var an=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},cn=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))},Xl="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 Yl=(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,cn([ot.All],an(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,cn([ot.Warnings],an(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,cn([ot.Errors],an(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=cn([Xl],an(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,cn([],an(i),!1)):e>=ot.Warnings?console.warn.apply(console,cn(["WARNING"],an(i),!1)):e>=ot.Errors&&console.error.apply(console,cn(["ERROR"],an(i),!1))},r})(),aa=new Yl,Dc={};Bt(Dc,"Socket",()=>ca,r=>ca=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 Wt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(Wt||(Wt={}));var Le;(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"})(Le||(Le={}));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 Zl=(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)}})(),Kl=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},Ql=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))},eu=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.")},ca=(function(r){Zl(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(Wt.Message,o)},this._socket.onclose=function(a){i._disconnected||(j.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(Wt.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:Le.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=Ql([],Kl(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=eu(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(Wt.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})(ji.EventEmitter),$s={};Bt($s,"MediaConnection",()=>ha,r=>ha=r);var uo={};Bt(uo,"Negotiator",()=>la,r=>la=r);var Ar=function(){return Ar=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},Ar.apply(this,arguments)},Qi=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(u){try{l(n.next(u))}catch(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},er=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(u){return c([l,u])}}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(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},la=(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:Le.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 u=l;t._addStreamToMediaConnection(c,u)}}},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 Qi(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return er(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=Ar(Ar({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Le.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 Qi(this,void 0,Promise,function(){var e,t,n,i,s;return er(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:Le.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 Qi(this,void 0,Promise,function(){var n,i,s,a;return er(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 Qi(this,void 0,Promise,function(){var t,n,i,s,a,o;return er(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",()=>ua,r=>ua=r);var tu=(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)}})(),ua=(function(r){tu(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})(ji.EventEmitter),nu=(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)}})(),Or=function(){return Or=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},Or.apply(this,arguments)},iu=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){nu(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 Le.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Le.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(Or(Or({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=iu(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(u){i={error:u}}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),Ws={};Bt(Ws,"DataConnection",()=>da,r=>da=r);var Fc={};Bt(Fc,"EncodingQueue",()=>fa,r=>fa=r);var ru=(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)}})(),fa=(function(r){ru(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})(ji.EventEmitter),su=(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)}})(),ou=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.")},da=(function(r){su(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 Fc.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 u=te.unpack(l);n.emit("data",u)});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=ou(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 Le.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Le.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",()=>ya,r=>ya=r);var pa=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(u){try{l(n.next(u))}catch(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},ma=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(u){return c([l,u])}}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(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ya=(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 pa(this,void 0,Promise,function(){var e,t,n;return ma(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 pa(this,void 0,Promise,function(){var e,t,n;return ma(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})(),au=(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)},Hn=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.")},cu=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},Hs=(function(r){au(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=Hn(this._connections),a=s.next();!a.done;a=s.next()){var o=cu(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(u){t={error:u}}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 Dc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(Wt.Message,function(i){t._handleMessage(i)}),n.on(Wt.Error,function(i){t._abort(_e.SocketError,i)}),n.on(Wt.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on(Wt.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 Le.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Le.Error:this._abort(_e.ServerError,a.msg);break;case Le.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Le.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Le.Leave:j.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Le.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Le.Offer:var x=a.connectionId,T=this.getConnection(o,x);if(T&&(T.close(),j.default.warn("Offer received for existing Connection ID:".concat(x))),a.type===Pt.Media){var c=new $s.MediaConnection(o,this,{connectionId:x,_payload:a,metadata:a.metadata});T=c,this._addConnection(o,T),this.emit("call",c)}else if(a.type===Pt.Data){var l=new Ws.DataConnection(o,this,{connectionId:x,_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 u=this._getMessages(x);try{for(var f=Hn(u),p=f.next();!p.done;p=f.next()){var m=p.value;T.handleMessage(m)}}catch(g){n={error:g}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}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 x=a.connectionId,T=this.getConnection(o,x);T&&T.peerConnection?T.handleMessage(t):x?this._storeMessage(x,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 Ws.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 $s.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=Hn(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(u){i={error:u}}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=Hn(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=Hn(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})(ji.EventEmitter),Vc=Nc.Peer;const lu=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Hs},default:Vc,util:te},Symbol.toStringTag,{value:"Module"})),uu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function hu(r){return typeof r=="string"&&uu.test(r)}const Fe=[];for(let r=0;r<256;++r)Fe.push((r+256).toString(16).slice(1));function fu(r,e=0){return Fe[r[e+0]]+Fe[r[e+1]]+Fe[r[e+2]]+Fe[r[e+3]]+"-"+Fe[r[e+4]]+Fe[r[e+5]]+"-"+Fe[r[e+6]]+Fe[r[e+7]]+"-"+Fe[r[e+8]]+Fe[r[e+9]]+"-"+Fe[r[e+10]]+Fe[r[e+11]]+Fe[r[e+12]]+Fe[r[e+13]]+Fe[r[e+14]]+Fe[r[e+15]]}function du(r){if(!hu(r))throw TypeError("Invalid UUID");let e;const t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function pu(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const mu="6ba7b810-9dad-11d1-80b4-00c04fd430c8",yu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function gu(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=pu(i)),typeof s=="string"&&(s=du(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(s),l.set(i,s.length),l=t(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,a){o=o||0;for(let u=0;u<16;++u)a[o+u]=l[u];return a}return fu(l)}try{n.name=r}catch{}return n.DNS=mu,n.URL=yu,n}function vu(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function ds(r,e){return r<<e|r>>>32-e}function Su(r){const e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){const a=unescape(encodeURIComponent(r));r=[];for(let o=0;o<a.length;++o)r.push(a.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);const n=r.length/4+2,i=Math.ceil(n/16),s=new Array(i);for(let a=0;a<i;++a){const o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=r[a*64+c*4]<<24|r[a*64+c*4+1]<<16|r[a*64+c*4+2]<<8|r[a*64+c*4+3];s[a]=o}s[i-1][14]=(r.length-1)*8/Math.pow(2,32),s[i-1][14]=Math.floor(s[i-1][14]),s[i-1][15]=(r.length-1)*8&4294967295;for(let a=0;a<i;++a){const o=new Uint32Array(80);for(let m=0;m<16;++m)o[m]=s[a][m];for(let m=16;m<80;++m)o[m]=ds(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],f=t[3],p=t[4];for(let m=0;m<80;++m){const x=Math.floor(m/20),T=ds(c,5)+vu(x,l,u,f)+p+e[x]+o[m]>>>0;p=f,f=u,u=ds(l,30)>>>0,l=c,c=T}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+f>>>0,t[4]=t[4]+p>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}const xu=gu("v5",80,Su);var ps={exports:{}},ms={exports:{}},ga;function _u(){return ga||(ga=1,(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(t,n){return t<<n|t>>>32-n},rotr:function(t,n){return t<<32-n|t>>>n},endian:function(t){if(t.constructor==Number)return e.rotl(t,8)&16711935|e.rotl(t,24)&4278255360;for(var n=0;n<t.length;n++)t[n]=e.endian(t[n]);return t},randomBytes:function(t){for(var n=[];t>0;t--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(t){for(var n=[],i=0,s=0;i<t.length;i++,s+=8)n[s>>>5]|=t[i]<<24-s%32;return n},wordsToBytes:function(t){for(var n=[],i=0;i<t.length*32;i+=8)n.push(t[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(t){for(var n=[],i=0;i<t.length;i++)n.push((t[i]>>>4).toString(16)),n.push((t[i]&15).toString(16));return n.join("")},hexToBytes:function(t){for(var n=[],i=0;i<t.length;i+=2)n.push(parseInt(t.substr(i,2),16));return n},bytesToBase64:function(t){for(var n=[],i=0;i<t.length;i+=3)for(var s=t[i]<<16|t[i+1]<<8|t[i+2],a=0;a<4;a++)i*8+a*6<=t.length*8?n.push(r.charAt(s>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,s=0;i<t.length;s=++i%4)s!=0&&n.push((r.indexOf(t.charAt(i-1))&Math.pow(2,-2*s+8)-1)<<s*2|r.indexOf(t.charAt(i))>>>6-s*2);return n}};ms.exports=e})()),ms.exports}var ys,va;function Sa(){if(va)return ys;va=1;var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n)&255);return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};return ys=r,ys}var gs,xa;function bu(){if(xa)return gs;xa=1,gs=function(t){return t!=null&&(r(t)||e(t)||!!t._isBuffer)};function r(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function e(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&r(t.slice(0,0))}return gs}var _a;function Tu(){return _a||(_a=1,(function(){var r=_u(),e=Sa().utf8,t=bu(),n=Sa().bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=n.stringToBytes(s):s=e.stringToBytes(s):t(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=r.bytesToWords(s),c=s.length*8,l=1732584193,u=-271733879,f=-1732584194,p=271733878,m=0;m<o.length;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360;o[c>>>5]|=128<<c%32,o[(c+64>>>9<<4)+14]=c;for(var x=i._ff,T=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var _=l,b=u,M=f,C=p;l=x(l,u,f,p,o[m+0],7,-680876936),p=x(p,l,u,f,o[m+1],12,-389564586),f=x(f,p,l,u,o[m+2],17,606105819),u=x(u,f,p,l,o[m+3],22,-1044525330),l=x(l,u,f,p,o[m+4],7,-176418897),p=x(p,l,u,f,o[m+5],12,1200080426),f=x(f,p,l,u,o[m+6],17,-1473231341),u=x(u,f,p,l,o[m+7],22,-45705983),l=x(l,u,f,p,o[m+8],7,1770035416),p=x(p,l,u,f,o[m+9],12,-1958414417),f=x(f,p,l,u,o[m+10],17,-42063),u=x(u,f,p,l,o[m+11],22,-1990404162),l=x(l,u,f,p,o[m+12],7,1804603682),p=x(p,l,u,f,o[m+13],12,-40341101),f=x(f,p,l,u,o[m+14],17,-1502002290),u=x(u,f,p,l,o[m+15],22,1236535329),l=T(l,u,f,p,o[m+1],5,-165796510),p=T(p,l,u,f,o[m+6],9,-1069501632),f=T(f,p,l,u,o[m+11],14,643717713),u=T(u,f,p,l,o[m+0],20,-373897302),l=T(l,u,f,p,o[m+5],5,-701558691),p=T(p,l,u,f,o[m+10],9,38016083),f=T(f,p,l,u,o[m+15],14,-660478335),u=T(u,f,p,l,o[m+4],20,-405537848),l=T(l,u,f,p,o[m+9],5,568446438),p=T(p,l,u,f,o[m+14],9,-1019803690),f=T(f,p,l,u,o[m+3],14,-187363961),u=T(u,f,p,l,o[m+8],20,1163531501),l=T(l,u,f,p,o[m+13],5,-1444681467),p=T(p,l,u,f,o[m+2],9,-51403784),f=T(f,p,l,u,o[m+7],14,1735328473),u=T(u,f,p,l,o[m+12],20,-1926607734),l=g(l,u,f,p,o[m+5],4,-378558),p=g(p,l,u,f,o[m+8],11,-2022574463),f=g(f,p,l,u,o[m+11],16,1839030562),u=g(u,f,p,l,o[m+14],23,-35309556),l=g(l,u,f,p,o[m+1],4,-1530992060),p=g(p,l,u,f,o[m+4],11,1272893353),f=g(f,p,l,u,o[m+7],16,-155497632),u=g(u,f,p,l,o[m+10],23,-1094730640),l=g(l,u,f,p,o[m+13],4,681279174),p=g(p,l,u,f,o[m+0],11,-358537222),f=g(f,p,l,u,o[m+3],16,-722521979),u=g(u,f,p,l,o[m+6],23,76029189),l=g(l,u,f,p,o[m+9],4,-640364487),p=g(p,l,u,f,o[m+12],11,-421815835),f=g(f,p,l,u,o[m+15],16,530742520),u=g(u,f,p,l,o[m+2],23,-995338651),l=v(l,u,f,p,o[m+0],6,-198630844),p=v(p,l,u,f,o[m+7],10,1126891415),f=v(f,p,l,u,o[m+14],15,-1416354905),u=v(u,f,p,l,o[m+5],21,-57434055),l=v(l,u,f,p,o[m+12],6,1700485571),p=v(p,l,u,f,o[m+3],10,-1894986606),f=v(f,p,l,u,o[m+10],15,-1051523),u=v(u,f,p,l,o[m+1],21,-2054922799),l=v(l,u,f,p,o[m+8],6,1873313359),p=v(p,l,u,f,o[m+15],10,-30611744),f=v(f,p,l,u,o[m+6],15,-1560198380),u=v(u,f,p,l,o[m+13],21,1309151649),l=v(l,u,f,p,o[m+4],6,-145523070),p=v(p,l,u,f,o[m+11],10,-1120210379),f=v(f,p,l,u,o[m+2],15,718787259),u=v(u,f,p,l,o[m+9],21,-343485551),l=l+_>>>0,u=u+b>>>0,f=f+M>>>0,p=p+C>>>0}return r.endian([l,u,f,p])};i._ff=function(s,a,o,c,l,u,f){var p=s+(a&o|~a&c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._gg=function(s,a,o,c,l,u,f){var p=s+(a&c|o&~c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._hh=function(s,a,o,c,l,u,f){var p=s+(a^o^c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._ii=function(s,a,o,c,l,u,f){var p=s+(o^(a|~c))+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._blocksize=16,i._digestsize=16,ps.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=r.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?n.bytesToString(o):r.bytesToHex(o)}})()),ps.exports}var Mu=Tu();const Cu=Vr(Mu),Ge=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ba=1234567;const Jc=Math.PI/180,jc=180/Math.PI;function wu(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ge[r&255]+Ge[r>>8&255]+Ge[r>>16&255]+Ge[r>>24&255]+"-"+Ge[e&255]+Ge[e>>8&255]+"-"+Ge[e>>16&15|64]+Ge[e>>24&255]+"-"+Ge[t&63|128]+Ge[t>>8&255]+"-"+Ge[t>>16&255]+Ge[t>>24&255]+Ge[n&255]+Ge[n>>8&255]+Ge[n>>16&255]+Ge[n>>24&255]).toLowerCase()}function Ot(r,e,t){return Math.max(e,Math.min(t,r))}function Gc(r,e){return(r%e+e)%e}function Pu(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Eu(r,e,t){return r!==e?(t-r)/(e-r):0}function $c(r,e,t){return(1-t)*r+t*e}function ku(r,e,t,n){return $c(r,e,1-Math.exp(-t*n))}function Ru(r,e=1){return e-Math.abs(Gc(r,e*2)-e)}function Au(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Ou(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function zu(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Iu(r,e){return r+Math.random()*(e-r)}function Bu(r){return r*(.5-Math.random())}function Nu(r){r!==void 0&&(ba=r);let e=ba+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Uu(r){return r*Jc}function Du(r){return r*jc}function Fu(r){return(r&r-1)===0&&r!==0}function Lu(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Vu(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Ju(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),u=a((e+n)/2),f=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),x=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*f,c*p,o*l);break;case"YZY":r.set(c*p,o*u,c*f,o*l);break;case"ZXZ":r.set(c*f,c*p,o*u,o*l);break;case"XZX":r.set(o*u,c*x,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*x,o*l);break;case"ZYZ":r.set(c*x,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ju(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Gu(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const jn={DEG2RAD:Jc,RAD2DEG:jc,generateUUID:wu,clamp:Ot,euclideanModulo:Gc,mapLinear:Pu,inverseLerp:Eu,lerp:$c,damp:ku,pingpong:Ru,smoothstep:Au,smootherstep:Ou,randInt:zu,randFloat:Iu,randFloatSpread:Bu,seededRandom:Nu,degToRad:Uu,radToDeg:Du,isPowerOfTwo:Fu,ceilPowerOfTwo:Lu,floorPowerOfTwo:Vu,setQuaternionFromProperEuler:Ju,normalize:Gu,denormalize:ju};class ie{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],u=n[i+2],f=n[i+3];const p=s[a+0],m=s[a+1],x=s[a+2],T=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=x,e[t+3]=T;return}if(f!==T||c!==p||l!==m||u!==x){let g=1-o;const v=c*p+l*m+u*x+f*T,_=v>=0?1:-1,b=1-v*v;if(b>Number.EPSILON){const C=Math.sqrt(b),P=Math.atan2(C,v*_);g=Math.sin(g*P)/C,o=Math.sin(o*P)/C}const M=o*_;if(c=c*g+p*M,l=l*g+m*M,u=u*g+x*M,f=f*g+T*M,g===1-o){const C=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=C,l*=C,u*=C,f*=C}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],f=s[a],p=s[a+1],m=s[a+2],x=s[a+3];return e[t]=o*x+u*f+c*m-l*p,e[t+1]=c*x+u*p+l*f-o*m,e[t+2]=l*x+u*m+o*p-c*f,e[t+3]=u*x-o*f-c*p-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new ie(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),f=o(s/2),p=c(n/2),m=c(i/2),x=c(s/2);switch(a){case"XYZ":this._x=p*u*f+l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f-p*m*x;break;case"YXZ":this._x=p*u*f+l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f+p*m*x;break;case"ZXY":this._x=p*u*f-l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f-p*m*x;break;case"ZYX":this._x=p*u*f-l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f+p*m*x;break;case"YZX":this._x=p*u*f+l*m*x,this._y=l*m*f+p*u*x,this._z=l*u*x-p*m*f,this._w=l*u*f-p*m*x;break;case"XZY":this._x=p*u*f-l*m*x,this._y=l*m*f-p*u*x,this._z=l*u*x+p*m*f,this._w=l*u*f+p*m*x;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],f=t[10],p=n+o+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-i)*m}else if(n>o&&n>f){const m=2*Math.sqrt(1+n-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);this._w=(s-l)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+f-n-o);this._w=(a-i)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ot(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-s*c,this._y=i*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-i*o,this._w=a*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),f=Math.sin((1-t)*u)/l,p=Math.sin(t*u)/l;return this._w=a*f+this._w*p,this._x=n*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,t=0,n=0){this.isVector3=!0,G.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new G(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ta.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ta.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),u=2*(o*t-s*i),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*u,this.y=n+c*u+o*l-s*f,this.z=i+c*f+s*u-a*l,this}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return vs.copy(this).projectOnVector(e),this.sub(vs)}reflect(e){return this.sub(vs.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ot(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vs=new G,Ta=new ie,tr=2e3,Ma=2001;class Et{constructor(e,t,n,i,s,a,o,c,l,u,f,p,m,x,T,g){this.isMatrix4=!0,Et.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l,u,f,p,m,x,T,g)}extractPosition(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}multiplyToArray(e,t,n){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(e){return this.makeRotationFromQuaternion(e)}set(e,t,n,i,s,a,o,c,l,u,f,p,m,x,T,g){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=a,v[9]=o,v[13]=c,v[2]=l,v[6]=u,v[10]=f,v[14]=p,v[3]=m,v[7]=x,v[11]=T,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Et().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/wn.setFromMatrixColumn(e,0).length(),s=1/wn.setFromMatrixColumn(e,1).length(),a=1/wn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const p=a*u,m=a*f,x=o*u,T=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+x*l,t[5]=p-T*l,t[9]=-o*c,t[2]=T-p*l,t[6]=x+m*l,t[10]=a*c}else if(e.order==="YXZ"){const p=c*u,m=c*f,x=l*u,T=l*f;t[0]=p+T*o,t[4]=x*o-m,t[8]=a*l,t[1]=a*f,t[5]=a*u,t[9]=-o,t[2]=m*o-x,t[6]=T+p*o,t[10]=a*c}else if(e.order==="ZXY"){const p=c*u,m=c*f,x=l*u,T=l*f;t[0]=p-T*o,t[4]=-a*f,t[8]=x+m*o,t[1]=m+x*o,t[5]=a*u,t[9]=T-p*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const p=a*u,m=a*f,x=o*u,T=o*f;t[0]=c*u,t[4]=x*l-m,t[8]=p*l+T,t[1]=c*f,t[5]=T*l+p,t[9]=m*l-x,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const p=a*c,m=a*l,x=o*c,T=o*l;t[0]=c*u,t[4]=T-p*f,t[8]=x*f+m,t[1]=f,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+x,t[10]=p-T*f}else if(e.order==="XZY"){const p=a*c,m=a*l,x=o*c,T=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=p*f+T,t[5]=a*u,t[9]=m*f-x,t[2]=x*f-m,t[6]=o*u,t[10]=T*f+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose($u,e,Wu)}lookAt(e,t,n){const i=this.elements;return lt.subVectors(e,t),lt.lengthSq()===0&&(lt.z=1),lt.normalize(),Yt.crossVectors(n,lt),Yt.lengthSq()===0&&(Math.abs(n.z)===1?lt.x+=1e-4:lt.z+=1e-4,lt.normalize(),Yt.crossVectors(n,lt)),Yt.normalize(),nr.crossVectors(lt,Yt),i[0]=Yt.x,i[4]=nr.x,i[8]=lt.x,i[1]=Yt.y,i[5]=nr.y,i[9]=lt.y,i[2]=Yt.z,i[6]=nr.z,i[10]=lt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],f=n[5],p=n[9],m=n[13],x=n[2],T=n[6],g=n[10],v=n[14],_=n[3],b=n[7],M=n[11],C=n[15],P=i[0],E=i[4],z=i[8],I=i[12],R=i[1],N=i[5],O=i[9],U=i[13],L=i[2],J=i[6],W=i[10],K=i[14],$=i[3],me=i[7],ne=i[11],ue=i[15];return s[0]=a*P+o*R+c*L+l*$,s[4]=a*E+o*N+c*J+l*me,s[8]=a*z+o*O+c*W+l*ne,s[12]=a*I+o*U+c*K+l*ue,s[1]=u*P+f*R+p*L+m*$,s[5]=u*E+f*N+p*J+m*me,s[9]=u*z+f*O+p*W+m*ne,s[13]=u*I+f*U+p*K+m*ue,s[2]=x*P+T*R+g*L+v*$,s[6]=x*E+T*N+g*J+v*me,s[10]=x*z+T*O+g*W+v*ne,s[14]=x*I+T*U+g*K+v*ue,s[3]=_*P+b*R+M*L+C*$,s[7]=_*E+b*N+M*J+C*me,s[11]=_*z+b*O+M*W+C*ne,s[15]=_*I+b*U+M*K+C*ue,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],f=e[6],p=e[10],m=e[14],x=e[3],T=e[7],g=e[11],v=e[15];return x*(+s*c*f-i*l*f-s*o*p+n*l*p+i*o*m-n*c*m)+T*(+t*c*m-t*l*p+s*a*p-i*a*m+i*l*u-s*c*u)+g*(+t*l*f-t*o*m-s*a*f+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*f+t*o*p+i*a*f-n*a*p+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=e[9],p=e[10],m=e[11],x=e[12],T=e[13],g=e[14],v=e[15],_=f*g*l-T*p*l+T*c*m-o*g*m-f*c*v+o*p*v,b=x*p*l-u*g*l-x*c*m+a*g*m+u*c*v-a*p*v,M=u*T*l-x*f*l+x*o*m-a*T*m-u*o*v+a*f*v,C=x*f*c-u*T*c-x*o*p+a*T*p+u*o*g-a*f*g,P=t*_+n*b+i*M+s*C;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/P;return e[0]=_*E,e[1]=(T*p*s-f*g*s-T*i*m+n*g*m+f*i*v-n*p*v)*E,e[2]=(o*g*s-T*c*s+T*i*l-n*g*l-o*i*v+n*c*v)*E,e[3]=(f*c*s-o*p*s-f*i*l+n*p*l+o*i*m-n*c*m)*E,e[4]=b*E,e[5]=(u*g*s-x*p*s+x*i*m-t*g*m-u*i*v+t*p*v)*E,e[6]=(x*c*s-a*g*s-x*i*l+t*g*l+a*i*v-t*c*v)*E,e[7]=(a*p*s-u*c*s+u*i*l-t*p*l-a*i*m+t*c*m)*E,e[8]=M*E,e[9]=(x*f*s-u*T*s-x*n*m+t*T*m+u*n*v-t*f*v)*E,e[10]=(a*T*s-x*o*s+x*n*l-t*T*l-a*n*v+t*o*v)*E,e[11]=(u*o*s-a*f*s-u*n*l+t*f*l+a*n*m-t*o*m)*E,e[12]=C*E,e[13]=(u*T*i-x*f*i+x*n*p-t*T*p-u*n*g+t*f*g)*E,e[14]=(x*o*i-a*T*i-x*n*c+t*T*c+a*n*g-t*o*g)*E,e[15]=(a*f*i-u*o*i+u*n*c-t*f*c-a*n*p+t*o*p)*E,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*a,0,l*c-i*o,u*c+i*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,f=o+o,p=s*l,m=s*u,x=s*f,T=a*u,g=a*f,v=o*f,_=c*l,b=c*u,M=c*f,C=n.x,P=n.y,E=n.z;return i[0]=(1-(T+v))*C,i[1]=(m+M)*C,i[2]=(x-b)*C,i[3]=0,i[4]=(m-M)*P,i[5]=(1-(p+v))*P,i[6]=(g+_)*P,i[7]=0,i[8]=(x+b)*E,i[9]=(g-_)*E,i[10]=(1-(p+T))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=wn.set(i[0],i[1],i[2]).length();const a=wn.set(i[4],i[5],i[6]).length(),o=wn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ct.copy(this);const l=1/s,u=1/a,f=1/o;return Ct.elements[0]*=l,Ct.elements[1]*=l,Ct.elements[2]*=l,Ct.elements[4]*=u,Ct.elements[5]*=u,Ct.elements[6]*=u,Ct.elements[8]*=f,Ct.elements[9]*=f,Ct.elements[10]*=f,t.setFromRotationMatrix(Ct),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=tr){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),p=(n+i)/(n-i);let m,x;if(o===tr)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===Ma)m=-a/(a-s),x=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=tr){const c=this.elements,l=1/(t-e),u=1/(n-i),f=1/(a-s),p=(t+e)*l,m=(n+i)*u;let x,T;if(o===tr)x=(a+s)*f,T=-2*f;else if(o===Ma)x=s*f,T=-1*f;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=T,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const wn=new G,Ct=new Et,$u=new G(0,0,0),Wu=new G(1,1,1),Yt=new G,nr=new G,lt=new G,Ca=new Et,wa=new ie;class hi{constructor(e=0,t=0,n=0,i=hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new hi(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],u=i[9],f=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ot(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ot(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Ot(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ca.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ca,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return wa.setFromEuler(this),this.setFromQuaternion(wa,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(e){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hi.DEFAULT_ORDER="XYZ";class Dn{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Dn(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ot(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Dn.isVector2=!0;class at{constructor(e=0,t=0,n=0,i=1){at.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new at(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],f=c[8],p=c[1],m=c[5],x=c[9],T=c[2],g=c[6],v=c[10];if(Math.abs(u-p)<.01&&Math.abs(f-T)<.01&&Math.abs(x-g)<.01){if(Math.abs(u+p)<.1&&Math.abs(f+T)<.1&&Math.abs(x+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,M=(m+1)/2,C=(v+1)/2,P=(u+p)/4,E=(f+T)/4,z=(x+g)/4;return b>M&&b>C?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=P/n,s=E/n):M>C?M<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(M),n=P/i,s=z/i):C<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),n=E/s,i=z/s),this.set(n,i,s,t),this}let _=Math.sqrt((g-x)*(g-x)+(f-T)*(f-T)+(p-u)*(p-u));return Math.abs(_)<.001&&(_=1),this.x=(g-x)/_,this.y=(f-T)/_,this.z=(p-u)/_,this.w=Math.acos((l+m+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class It{constructor(e,t,n,i,s,a,o,c,l){It.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],f=n[7],p=n[2],m=n[5],x=n[8],T=i[0],g=i[3],v=i[6],_=i[1],b=i[4],M=i[7],C=i[2],P=i[5],E=i[8];return s[0]=a*T+o*_+c*C,s[3]=a*g+o*b+c*P,s[6]=a*v+o*M+c*E,s[1]=l*T+u*_+f*C,s[4]=l*g+u*b+f*P,s[7]=l*v+u*M+f*E,s[2]=p*T+m*_+x*C,s[5]=p*g+m*b+x*P,s[8]=p*v+m*M+x*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=u*a-o*l,p=o*c-u*s,m=l*s-a*c,x=t*f+n*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/x;return e[0]=f*T,e[1]=(i*l-u*n)*T,e[2]=(o*n-i*a)*T,e[3]=p*T,e[4]=(u*t-i*c)*T,e[5]=(i*s-o*t)*T,e[6]=m*T,e[7]=(n*c-l*t)*T,e[8]=(a*t-n*s)*T,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ss.makeScale(e,t)),this}rotate(e){return this.premultiply(Ss.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ss.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new It().fromArray(this.elements)}}const Ss=new It;var et;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(et||(et={}));function Gi(r,e,t,n){let i;switch(et.Random===r?e=Math.random():et.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case et.Loop:i=i%1;break;case et.PingPong:i=Math.abs(i%2-1);break}return i}class yn{constructor(e,t,n,i){this.p=[e,t,n,i]}genValue(e){const t=e*e,n=e*e*e,i=1-e,s=i*i,a=s*i;return this.p[0]*a+this.p[1]*s*e*3+this.p[2]*i*t*3+this.p[3]*n}derivativeCoefficients(e){const t=[];for(let n=e,i=n.length-1;i>0;i--){const s=[];for(let a=0;a<i;a++){const o=i*(n[a+1]-n[a]);s.push(o)}t.push(s),n=s}return t}getSlope(e){const t=this.derivativeCoefficients(this.p)[0],n=1-e,i=n*n,s=n*e*2,a=e*e;return i*t[0]+s*t[1]+a*t[2]}controlCurve(e,t){this.p[1]=e/3+this.p[0],this.p[2]=this.p[3]-t/3}hull(e){let t=this.p,n=[],i,s=0,a=0,o=0;const c=[];for(c[s++]=t[0],c[s++]=t[1],c[s++]=t[2],c[s++]=t[3];t.length>1;){for(n=[],a=0,o=t.length-1;a<o;a++)i=e*t[a]+(1-e)*t[a+1],c[s++]=i,n.push(i);t=n}return c}split(e){const t=this.hull(e);return{left:new yn(t[0],t[4],t[7],t[9]),right:new yn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new yn(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(e){return new yn(e.p0,e.p1,e.p2,e.p3)}}const fi=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),di=r=>new at(r.r,r.g,r.b,r.a),Hu=(r,e)=>{switch(e){case"Vector3":return new G(r.x,r.y,r.z);case"Vector4":return new at(r.x,r.y,r.z,r.w);case"Color":return new G(r.r,r.g,r.b);case"Number":return r;default:return r}},qu=(r,e)=>{switch(e){case"Vector3":return{x:r.x,y:r.y,z:r.z};case"Vector4":return{x:r.x,y:r.y,z:r.z,w:r.w};case"Color":return{r:r.x,g:r.y,b:r.z};case"Number":return r;default:return r}};class zr{constructor(e,t){this.a=e,this.b=t,this.type="value"}startGen(e){}genColor(e,t){const n=Math.random();return t.copy(this.a).lerp(this.b,n)}toJSON(){return{type:"RandomColor",a:fi(this.a),b:fi(this.b)}}static fromJSON(e){return new zr(di(e.a),di(e.b))}clone(){return new zr(this.a.clone(),this.b.clone())}}class Fn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t){return this.indexCount===-1&&this.startGen(e),t.copy(this.a).lerp(this.b,e[this.indexCount])}toJSON(){return{type:"ColorRange",a:fi(this.a),b:fi(this.b)}}static fromJSON(e){return new Fn(di(e.a),di(e.b))}clone(){return new Fn(this.a.clone(),this.b.clone())}}class tn{constructor(e,t){this.subType=t,this.type="function",this.keys=e}findKey(e){let t=0,n=0,i=this.keys.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.getStartX(s)&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.keys[e][1]}getEndX(e){return e+1<this.keys.length?this.keys[e+1][1]:1}genValue(e,t){const n=this.findKey(t);return this.subType==="Number"?n===-1?this.keys[0][0]:n+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[n+1][0]-this.keys[n][0])*((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))+this.keys[n][0]:n===-1?e.copy(this.keys[0][0]):n+1>=this.keys.length?e.copy(this.keys[this.keys.length-1][0]):e.copy(this.keys[n][0]).lerp(this.keys[n+1][0],(t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([e,t])=>({value:qu(e,this.subType),pos:t}))}}static fromJSON(e){return new tn(e.keys.map(t=>[Hu(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new tn(this.keys.map(([e,t])=>[e,t]),this.subType):new tn(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const ir=new G;class gn{constructor(e=[[new G(0,0,0),0],[new G(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new tn(e,"Color"),this.alpha=new tn(t,"Number")}genColor(e,t,n){return this.color.genValue(ir,n),t.set(ir.x,ir.y,ir.z,this.alpha.genValue(1,n))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(e){if(e.functions){const t=e.functions.map(n=>[Fn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Fn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new gn(t.map(n=>[new G(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new gn;return t.alpha=tn.fromJSON(e.alpha),t.color=tn.fromJSON(e.color),t}}clone(){const e=new gn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const xs=new at;class Ir{constructor(e,t){this.indexCount=0,this.type="function",this.gradient1=e,this.gradient2=t}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t,n){return this.gradient1.genColor(e,t,n),this.gradient2.genColor(e,xs,n),e&&e[this.indexCount]!==void 0?t.lerp(xs,e[this.indexCount]):t.lerp(xs,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Ir(gn.fromJSON(e.gradient1),gn.fromJSON(e.gradient2))}clone(){return new Ir(this.gradient1.clone(),this.gradient2.clone())}}class vn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:fi(this.color)}}static fromJSON(e){return new vn(di(e.color))}clone(){return new vn(this.color.clone())}}function fo(r){switch(r.type){case"ConstantColor":return vn.fromJSON(r);case"ColorRange":return Fn.fromJSON(r);case"RandomColor":return zr.fromJSON(r);case"Gradient":return gn.fromJSON(r);case"RandomColorBetweenGradient":return Ir.fromJSON(r);default:return new vn(new at(1,1,1,1))}}class ee{constructor(e){this.value=e,this.type="value"}startGen(e){}genValue(e){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(e){return new ee(e.value)}clone(){return new ee(this.value)}}class Sn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genValue(e){return this.indexCount===-1&&this.startGen(e),jn.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new Sn(e.a,e.b)}clone(){return new Sn(this.a,this.b)}}class Xu{constructor(){this.functions=new Array}findFunction(e){let t=0,n=0,i=this.functions.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.functions[s][1]&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.functions[e][1]}setStartX(e,t){e>0&&(this.functions[e][1]=t)}getEndX(e){return e+1<this.functions.length?this.functions[e+1][1]:1}setEndX(e,t){e+1<this.functions.length&&(this.functions[e+1][1]=t)}insertFunction(e,t){const n=this.findFunction(e);this.functions.splice(n+1,0,[t,e])}removeFunction(e){return this.functions.splice(e,1)[0][0]}getFunction(e){return this.functions[e][0]}setFunction(e,t){this.functions[e][0]=t}get numOfFunctions(){return this.functions.length}}class pi extends Xu{constructor(e=[[new yn(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=e}genValue(e,t=0){const n=this.findFunction(t);return n===-1?0:this.functions[n][0].genValue((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toSVG(e,t){if(t<1)return"";let n=["M",0,this.functions[0][0].p[0]].join(" ");for(let i=1/t;i<=1;i+=1/t)n=[n,"L",i*e,this.genValue(void 0,i)].join(" ");return n}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([e,t])=>({function:e.toJSON(),start:t}))}}static fromJSON(e){return new pi(e.functions.map(t=>[yn.fromJSON(t.function),t.start]))}clone(){return new pi(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function Z(r){switch(r.type){case"ConstantValue":return ee.fromJSON(r);case"IntervalValue":return Sn.fromJSON(r);case"PiecewiseBezier":return pi.fromJSON(r);default:return new ee(0)}}class mi{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new ie);let t,n,i,s,a,o;do t=Math.random()*2-1,n=Math.random()*2-1,i=t*t+n*n;while(i>1);do s=Math.random()*2-1,a=Math.random()*2-1,o=s*s+a*a;while(o>1);const c=Math.sqrt((1-i)/o);e[this.indexCount].set(t,n,c*s,c*a)}genValue(e,t,n,i){return this.indexCount===-1&&this.startGen(e),t.copy(e[this.indexCount]),t}toJSON(){return{type:"RandomQuat"}}static fromJSON(e){return new mi}clone(){return new mi}}class yi{constructor(e,t){this.axis=e,this.angle=t,this.type="rotation"}startGen(e){this.angle.startGen(e)}genValue(e,t,n,i){return t.setFromAxisAngle(this.axis,this.angle.genValue(e,i)*n)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(e){return new yi(new G(e.axis.x,e.axis.y,e.axis.z),Z(e.angle))}clone(){return new yi(this.axis.clone(),this.angle.clone())}}class Br{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new hi(0,0,0,i)}startGen(e){this.angleX.startGen(e),this.angleY.startGen(e),this.angleZ.startGen(e)}genValue(e,t,n,i){return this.eular.set(this.angleX.genValue(e,i)*n,this.angleY.genValue(e,i)*n,this.angleZ.genValue(e,i)*n),t.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(e){return new Br(Z(e.angleX),Z(e.angleY),Z(e.angleZ),e.eulerOrder)}clone(){return new Br(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Wc(r){switch(r.type){case"AxisAngle":return yi.fromJSON(r);case"Euler":return Br.fromJSON(r);case"RandomQuat":return mi.fromJSON(r);default:return new mi}}class xn{constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="vec3function"}startGen(e){this.x.startGen(e),this.y.startGen(e),this.z.startGen(e)}genValue(e,t,n){return t.set(this.x.genValue(e,n),this.y.genValue(e,n),this.z.genValue(e,n))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new xn(Z(e.x),Z(e.y),Z(e.z))}clone(){return new xn(this.x,this.y,this.z)}}function Yu(r){return r.type==="Vector3Function"?xn.fromJSON(r):new xn(new ee(0),new ee(0),new ee(0))}function Nr(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Z(r);case"AxisAngle":case"RandomQuat":case"Euler":return Wc(r);case"Vector3Function":return Yu(r);default:return new ee(0)}}class gi{constructor(e={}){var t,n,i,s,a,o,c;this.type="cone",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.angle=(s=e.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(a=e.mode)!==null&&a!==void 0?a:et.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[]}update(e,t){et.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Gi(this.mode,this.currentValue,this.spread,t),i=jn.lerp(1-this.thickness,1,Math.random()),s=n*this.arc,a=Math.sqrt(i),o=Math.sin(s),c=Math.cos(s);e.position.x=a*c,e.position.y=a*o,e.position.z=0;const l=this.angle*a;e.velocity.set(0,0,Math.cos(l)).addScaledVector(e.position,Math.sin(l)).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new gi({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?Z(e.speed):void 0,spread:e.spread})}clone(){return new gi({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class vi{constructor(e={}){var t,n,i,s,a,o;this.type="circle",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:et.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=Gi(this.mode,this.currentValue,this.spread,t),i=jn.lerp(1-this.thickness,1,Math.random()),s=n*this.arc;e.position.x=Math.cos(s),e.position.y=Math.sin(s),e.position.z=0,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*i)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new vi({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Z(e.speed):void 0,spread:e.spread})}clone(){return new vi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function rr(r,e){return Math.floor(Math.random()*(e-r))+r}const jr=new G(0,1,0),Gr=new G(0,0,0),Zu=new G(1,1,1),Pa=new G(0,0,1);class Si{constructor(e={}){var t,n,i,s,a,o,c;this.type="donut",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.donutRadius=(s=e.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(a=e.mode)!==null&&a!==void 0?a:et.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[],this._m1=new Et}update(e,t){et.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Gi(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=jn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=i*Math.PI*2,c=Math.sin(a),l=Math.cos(a);e.position.x=this.radius*l,e.position.y=this.radius*c,e.position.z=0,e.velocity.z=this.donutRadius*s*Math.sin(o),e.velocity.x=this.donutRadius*s*Math.cos(o)*l,e.velocity.y=this.donutRadius*s*Math.cos(o)*c,e.position.add(e.velocity),e.velocity.normalize().multiplyScalar(e.startSpeed),e.rotation instanceof ie&&(this._m1.lookAt(Gr,e.velocity,jr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Si({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?Z(e.speed):void 0,spread:e.spread})}clone(){return new Si({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class xi{constructor(){this.type="point",this._m1=new Et}update(e,t){}initialize(e){const t=Math.random(),n=Math.random(),i=t*Math.PI*2,s=Math.acos(2*n-1),a=Math.cbrt(Math.random()),o=Math.sin(i),c=Math.cos(i),l=Math.sin(s),u=Math.cos(s);e.velocity.x=a*l*c,e.velocity.y=a*l*o,e.velocity.z=a*u,e.velocity.multiplyScalar(e.startSpeed),e.position.setScalar(0),e.rotation instanceof ie&&(this._m1.lookAt(Gr,e.position,jr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new xi}clone(){return new xi}}class Ln{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:et.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new Et}update(e,t){et.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Gi(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=jn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(2*i-1),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(Gr,e.position,jr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ln({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Z(e.speed):void 0,spread:e.spread})}clone(){return new Ln({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class _i{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:et.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new Et}update(e,t){et.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Gi(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=jn.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(i),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(Gr,e.position,jr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new _i({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Z(e.speed):void 0,spread:e.spread})}clone(){return new _i({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class bi{constructor(e={}){var t,n,i,s;this.type="grid",this.width=(t=e.width)!==null&&t!==void 0?t:1,this.height=(n=e.height)!==null&&n!==void 0?n:1,this.column=(i=e.column)!==null&&i!==void 0?i:10,this.row=(s=e.row)!==null&&s!==void 0?s:10}initialize(e){const t=Math.floor(Math.random()*this.row),n=Math.floor(Math.random()*this.column);e.position.x=n*this.width/this.column-this.width/2,e.position.y=t*this.height/this.row-this.height/2,e.position.z=0,e.velocity.set(0,0,e.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(e){return new bi(e)}clone(){return new bi({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const qs={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:vi,loadJSON:vi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:gi,loadJSON:gi.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Si,loadJSON:Si.fromJSON},point:{type:"point",params:[],constructor:xi,loadJSON:xi.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ln,loadJSON:Ln.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:_i,loadJSON:_i.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:bi,loadJSON:bi.fromJSON}};function Ku(r,e){return qs[r.type].loadJSON(r,e)}class Ti{constructor(e){this.color=e,this.type="ColorOverLife"}initialize(e){this.color.startGen(e.memory)}update(e,t){this.color.genColor(e.memory,e.color,e.age/e.life),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(e){return new Ti(fo(e.color))}clone(){return new Ti(this.color.clone())}reset(){}}class Mi{constructor(e){this.angularVelocity=e,this.type="RotationOverLife"}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){typeof e.rotation=="number"&&(e.rotation+=t*this.angularVelocity.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Mi(Z(e.angularVelocity))}frameUpdate(e){}clone(){return new Mi(this.angularVelocity.clone())}reset(){}}class Ci{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new ie,this.tempQuat2=new ie}initialize(e){e.rotation instanceof ie&&(e.angularVelocity=new ie,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof ie&&(this.angularVelocity.genValue(e.memory,this.tempQuat,t,e.age/e.life),e.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Ci(Wc(e.angularVelocity))}frameUpdate(e){}clone(){return new Ci(this.angularVelocity.clone())}reset(){}}class wi{initialize(e,t){this.ps=t,this.x.startGen(e.memory),this.y.startGen(e.memory),this.z.startGen(e.memory)}constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="ForceOverLife",this._temp=new G,this._tempScale=new G,this._tempQ=new ie}update(e,t){this._temp.set(this.x.genValue(e.memory,e.age/e.life),this.y.genValue(e.memory,e.age/e.life),this.z.genValue(e.memory,e.age/e.life)),this.ps.worldSpace?e.velocity.addScaledVector(this._temp,t):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),e.velocity.addScaledVector(this._temp,t))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new wi(Z(e.x),Z(e.y),Z(e.z))}frameUpdate(e){if(this.ps&&!this.ps.worldSpace){const t=this._temp,n=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(t,n,i),n.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new wi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Pi{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof xn?this.size.genValue(e.memory,e.size,e.age/e.life).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(e){return new Pi(Nr(e.size))}frameUpdate(e){}clone(){return new Pi(this.size.clone())}reset(){}}class Ei{initialize(e){this.speed.startGen(e.memory)}constructor(e){this.speed=e,this.type="SpeedOverLife"}update(e){e.speedModifier=this.speed.genValue(e.memory,e.age/e.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(e){return new Ei(Z(e.speed))}frameUpdate(e){}clone(){return new Ei(this.speed.clone())}reset(){}}class ki{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof pi&&(e.uvTile=this.frame.genValue(e.memory,e.age/e.life))}frameUpdate(e){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(e){return new ki(Z(e.frame))}clone(){return new ki(this.frame.clone())}reset(){}}class Ri{constructor(e,t=new G(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new G,this.rotation=new ie}initialize(e){this.orbitSpeed.startGen(e.memory)}update(e,t){this.temp.copy(e.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(e.memory,e.age/e.life)*t),e.position.sub(this.temp),e.position.applyQuaternion(this.rotation),e.position.add(this.temp)}frameUpdate(e){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(e){return new Ri(Z(e.orbitSpeed),e.axis?new G(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Ri(this.orbitSpeed.clone())}reset(){}}class _s{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class Qu{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return this.head===null}clear(){this.length=0,this.head=this.tail=null}front(){return this.head===null?null:this.head.data}back(){return this.tail===null?null:this.tail.data}dequeue(){if(this.head){const e=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}}pop(){if(this.tail){const e=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}}queue(e){const t=new _s(e);this.tail||(this.tail=t),this.head&&(this.head.prev=t,t.next=this.head),this.head=t,this.length++}push(e){const t=new _s(e);this.head||(this.head=t),this.tail&&(this.tail.next=t,t.prev=this.tail),this.tail=t,this.length++}insertBefore(e,t){const n=new _s(t);n.next=e,n.prev=e.prev,n.prev!==null&&(n.prev.next=n),n.next.prev=n,e==this.head&&(this.head=n),this.length++}remove(e){if(this.head===null||this.tail===null)return;let t=this.head;for(e===this.head.data&&(this.head=this.head.next),e===this.tail.data&&(this.tail=this.tail.prev);t.next!==null&&t.data!==e;)t=t.next;t.data===e&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.length--)}*values(){let e=this.head;for(;e!==null;)yield e.data,e=e.next}}class eh{constructor(){this.startSpeed=0,this.startColor=new at,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new at,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class th{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Ur{constructor(){this.startSpeed=0,this.startColor=new at,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.length=100,this.speedModifier=1,this.color=new at,this.previous=new Qu,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new th(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class Ai{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Ur){const t=e.previous.values();for(let n=0;n<e.previous.length;n++){const i=t.next();i.value.size=this.width.genValue(e.memory,(e.previous.length-n)/e.length)}}}frameUpdate(e){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(e){return new Ai(Z(e.width))}clone(){return new Ai(this.width.clone())}reset(){}}class Oi{constructor(e,t){this.direction=e,this.magnitude=t,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(e){}update(e,t){e.velocity.addScaledVector(this.direction,this.magnitudeValue*t)}frameUpdate(e){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(e){var t;return new Oi(new G(e.direction[0],e.direction[1],e.direction[2]),Z((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Oi(this.direction.clone(),this.magnitude.clone())}reset(){}}class zi{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new G}initialize(e){}update(e,t){this.temp.copy(this.center).sub(e.position).normalize(),e.velocity.addScaledVector(this.temp,this.magnitude/e.position.distanceToSquared(this.center)*t)}frameUpdate(e){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(e){return new zi(new G(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new zi(this.center.clone(),this.magnitude)}reset(){}}class Ii{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new G,this._q=new ie,this.memory={data:[],dataCount:0}}initialize(e){const t=e.velocity.length();t!=0&&(e.velocity.normalize(),e.velocity.x===0&&e.velocity.y===0?this._temp.set(0,e.velocity.z,0):this._temp.set(-e.velocity.y,e.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(e.velocity),e.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),e.velocity.applyQuaternion(this._q),e.velocity.setLength(t))}update(e,t){}frameUpdate(e){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(e){return new Ii(Z(e.angle))}clone(){return new Ii(this.angle)}reset(){}}var Nn;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(Nn||(Nn={}));class Bi{constructor(e,t,n,i=Nn.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new ie,this.v_=new G,this.v2_=new G,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===Nn.Frame?this.emit(e,t):this.mode===Nn.Birth&&e.age===0?this.emit(e,t):this.mode===Nn.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new Et;this.setMatrixFromParticle(n,e),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:n,travelDistance:0,particle:e})}frameUpdate(e){if(this.subParticleSystem)for(let t=0;t<this.subEmissions.length;t++)if(this.subEmissions[t].time>=this.subParticleSystem.system.duration)this.subEmissions[t]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,t--;else{const n=this.subEmissions[t];n.particle&&n.particle.age<n.particle.life?this.setMatrixFromParticle(n.matrix,n.particle):n.particle=void 0,this.subParticleSystem.system.emit(e,n,n.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(e,t){return new Bi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new Bi(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(e,t){let n;if(t.rotation===void 0||this.useVelocityAsBasis)if(t.velocity.x===0&&t.velocity.y===0&&(t.velocity.z===1||t.velocity.z===0))e.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1);else{this.v_.copy(Pa).cross(t.velocity),this.v2_.copy(t.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();e.set(this.v_.x/i,this.v2_.x/s,t.velocity.x,t.position.x,this.v_.y/i,this.v2_.y/s,t.velocity.y,t.position.y,this.v_.z/i,this.v2_.z/s,t.velocity.z,t.position.z,0,0,0,1)}else t.rotation instanceof ie?n=t.rotation:(this.q_.setFromAxisAngle(Pa,t.rotation),n=this.q_),e.compose(t.position,n,Zu);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const nh=.5*(Math.sqrt(3)-1),qn=(3-Math.sqrt(3))/6,ih=1/3,Rt=1/6,rh=(Math.sqrt(5)-1)/4,Ne=(5-Math.sqrt(5))/20,Oe=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),Me=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);class Hc{constructor(e=Math.random){const t=typeof e=="function"?e:oh(e);this.p=sh(t),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let n=0;n<512;n++)this.perm[n]=this.p[n&255],this.permMod12[n]=this.perm[n]%12}noise2D(e,t){const n=this.permMod12,i=this.perm;let s=0,a=0,o=0;const c=(e+t)*nh,l=Math.floor(e+c),u=Math.floor(t+c),f=(l+u)*qn,p=l-f,m=u-f,x=e-p,T=t-m;let g,v;x>T?(g=1,v=0):(g=0,v=1);const _=x-g+qn,b=T-v+qn,M=x-1+2*qn,C=T-1+2*qn,P=l&255,E=u&255;let z=.5-x*x-T*T;if(z>=0){const N=n[P+i[E]]*3;z*=z,s=z*z*(Oe[N]*x+Oe[N+1]*T)}let I=.5-_*_-b*b;if(I>=0){const N=n[P+g+i[E+v]]*3;I*=I,a=I*I*(Oe[N]*_+Oe[N+1]*b)}let R=.5-M*M-C*C;if(R>=0){const N=n[P+1+i[E+1]]*3;R*=R,o=R*R*(Oe[N]*M+Oe[N+1]*C)}return 70*(s+a+o)}noise3D(e,t,n){const i=this.permMod12,s=this.perm;let a,o,c,l;const u=(e+t+n)*ih,f=Math.floor(e+u),p=Math.floor(t+u),m=Math.floor(n+u),x=(f+p+m)*Rt,T=f-x,g=p-x,v=m-x,_=e-T,b=t-g,M=n-v;let C,P,E,z,I,R;_>=b?b>=M?(C=1,P=0,E=0,z=1,I=1,R=0):_>=M?(C=1,P=0,E=0,z=1,I=0,R=1):(C=0,P=0,E=1,z=1,I=0,R=1):b<M?(C=0,P=0,E=1,z=0,I=1,R=1):_<M?(C=0,P=1,E=0,z=0,I=1,R=1):(C=0,P=1,E=0,z=1,I=1,R=0);const N=_-C+Rt,O=b-P+Rt,U=M-E+Rt,L=_-z+2*Rt,J=b-I+2*Rt,W=M-R+2*Rt,K=_-1+3*Rt,$=b-1+3*Rt,me=M-1+3*Rt,ne=f&255,ue=p&255,re=m&255;let ge=.6-_*_-b*b-M*M;if(ge<0)a=0;else{const oe=i[ne+s[ue+s[re]]]*3;ge*=ge,a=ge*ge*(Oe[oe]*_+Oe[oe+1]*b+Oe[oe+2]*M)}let be=.6-N*N-O*O-U*U;if(be<0)o=0;else{const oe=i[ne+C+s[ue+P+s[re+E]]]*3;be*=be,o=be*be*(Oe[oe]*N+Oe[oe+1]*O+Oe[oe+2]*U)}let se=.6-L*L-J*J-W*W;if(se<0)c=0;else{const oe=i[ne+z+s[ue+I+s[re+R]]]*3;se*=se,c=se*se*(Oe[oe]*L+Oe[oe+1]*J+Oe[oe+2]*W)}let he=.6-K*K-$*$-me*me;if(he<0)l=0;else{const oe=i[ne+1+s[ue+1+s[re+1]]]*3;he*=he,l=he*he*(Oe[oe]*K+Oe[oe+1]*$+Oe[oe+2]*me)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const f=(e+t+n+i)*rh,p=Math.floor(e+f),m=Math.floor(t+f),x=Math.floor(n+f),T=Math.floor(i+f),g=(p+m+x+T)*Ne,v=p-g,_=m-g,b=x-g,M=T-g,C=e-v,P=t-_,E=n-b,z=i-M;let I=0,R=0,N=0,O=0;C>P?I++:R++,C>E?I++:N++,C>z?I++:O++,P>E?R++:N++,P>z?R++:O++,E>z?N++:O++;const U=I>=3?1:0,L=R>=3?1:0,J=N>=3?1:0,W=O>=3?1:0,K=I>=2?1:0,$=R>=2?1:0,me=N>=2?1:0,ne=O>=2?1:0,ue=I>=1?1:0,re=R>=1?1:0,ge=N>=1?1:0,be=O>=1?1:0,se=C-U+Ne,he=P-L+Ne,oe=E-J+Ne,Xe=z-W+Ne,Ve=C-K+2*Ne,Je=P-$+2*Ne,Ye=E-me+2*Ne,xe=z-ne+2*Ne,ye=C-ue+3*Ne,ae=P-re+3*Ne,ut=E-ge+3*Ne,ke=z-be+3*Ne,fe=C-1+4*Ne,it=P-1+4*Ne,vt=E-1+4*Ne,St=z-1+4*Ne,rt=p&255,xt=m&255,ht=x&255,ft=T&255;let _t=.6-C*C-P*P-E*E-z*z;if(_t<0)a=0;else{const Q=s[rt+s[xt+s[ht+s[ft]]]]%32*4;_t*=_t,a=_t*_t*(Me[Q]*C+Me[Q+1]*P+Me[Q+2]*E+Me[Q+3]*z)}let Re=.6-se*se-he*he-oe*oe-Xe*Xe;if(Re<0)o=0;else{const Q=s[rt+U+s[xt+L+s[ht+J+s[ft+W]]]]%32*4;Re*=Re,o=Re*Re*(Me[Q]*se+Me[Q+1]*he+Me[Q+2]*oe+Me[Q+3]*Xe)}let Ze=.6-Ve*Ve-Je*Je-Ye*Ye-xe*xe;if(Ze<0)c=0;else{const Q=s[rt+K+s[xt+$+s[ht+me+s[ft+ne]]]]%32*4;Ze*=Ze,c=Ze*Ze*(Me[Q]*Ve+Me[Q+1]*Je+Me[Q+2]*Ye+Me[Q+3]*xe)}let ct=.6-ye*ye-ae*ae-ut*ut-ke*ke;if(ct<0)l=0;else{const Q=s[rt+ue+s[xt+re+s[ht+ge+s[ft+be]]]]%32*4;ct*=ct,l=ct*ct*(Me[Q]*ye+Me[Q+1]*ae+Me[Q+2]*ut+Me[Q+3]*ke)}let Ke=.6-fe*fe-it*it-vt*vt-St*St;if(Ke<0)u=0;else{const Q=s[rt+1+s[xt+1+s[ht+1+s[ft+1]]]]%32*4;Ke*=Ke,u=Ke*Ke*(Me[Q]*fe+Me[Q+1]*it+Me[Q+2]*vt+Me[Q+3]*St)}return 27*(a+o+c+l+u)}}function sh(r){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let t=0;t<255;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}return e}function oh(r){let e=0,t=0,n=0,i=1;const s=ah();return e=s(" "),t=s(" "),n=s(" "),e-=s(r),e<0&&(e+=1),t-=s(r),t<0&&(t+=1),n-=s(r),n<0&&(n+=1),function(){const a=2091639*e+i*23283064365386963e-26;return e=t,t=n,n=a-(i=a|0)}}function ah(){let r=4022871197;return function(e){e=e.toString();for(let t=0;t<e.length;t++){r+=e.charCodeAt(t);let n=.02519603282416938*r;r=n>>>0,n-=r,n*=r,r=n>>>0,n-=r,r+=n*4294967296}return(r>>>0)*23283064365386963e-26}}class Ni{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Hc,this.timeOffset=new G,this.temp=new G,this.temp2=new G,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(e){}update(e,t){const n=e.position.x/this.scale.x,i=e.position.y/this.scale.y,s=e.position.z/this.scale.z;this.temp.set(0,0,0);let a=1;for(let o=0;o<this.octaves;o++)this.temp2.set(this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.x*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.y*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.z*a)/a),this.temp.add(this.temp2),a*=2;this.temp.multiply(this.velocityMultiplier),e.velocity.addScaledVector(this.temp,t)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(e){this.timeOffset.x+=e*this.timeScale.x,this.timeOffset.y+=e*this.timeScale.y,this.timeOffset.z+=e*this.timeScale.z}static fromJSON(e){return new Ni(new G(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new G(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new G(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Ni(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const At=[],bs=new G,Ts=new ie;class Ui{constructor(e,t,n=new ee(1),i=new ee(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,At.length===0)for(let s=0;s<100;s++)At.push(new Hc)}initialize(e){e.lastPosNoise=new G,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new ie,e.generatorIndex=[rr(0,100),rr(0,100),rr(0,100),rr(0,100)],this.positionAmount.startGen(e.memory),this.rotationAmount.startGen(e.memory),this.frequency.startGen(e.memory),this.power.startGen(e.memory)}update(e,t){let n=this.frequency.genValue(e.memory,e.age/e.life),i=this.power.genValue(e.memory,e.age/e.life),s=this.positionAmount.genValue(e.memory,e.age/e.life),a=this.rotationAmount.genValue(e.memory,e.age/e.life);s>0&&e.lastPosNoise!==void 0&&(e.position.sub(e.lastPosNoise),bs.set(At[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,At[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,At[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(bs),e.lastPosNoise.copy(bs)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=At[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),Ts.set(At[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,At[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,At[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,At[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(Ts),e.lastRotNoise.copy(Ts)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(e){this.duration+=e}static fromJSON(e){return new Ui(Z(e.frequency),Z(e.power),Z(e.positionAmount),Z(e.rotationAmount))}clone(){return new Ui(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Di{constructor(e,t){this.color=e,this.speedRange=t,this.type="ColorBySpeed"}initialize(e){this.color.startGen(e.memory)}update(e,t){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(e.memory,e.color,n),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Di(fo(e.color),Sn.fromJSON(e.speedRange))}clone(){return new Di(this.color.clone(),this.speedRange.clone())}reset(){}}class Fi{initialize(e){this.size.startGen(e.memory)}constructor(e,t){this.size=e,this.speedRange=t,this.type="SizeBySpeed"}update(e){const t=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof xn?this.size.genValue(e.memory,e.size,t).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,t))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Fi(Nr(e.size),Sn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Fi(this.size.clone(),this.speedRange.clone())}reset(){}}class Li{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new ie}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){if(typeof e.rotation=="number"){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);e.rotation+=t*this.angularVelocity.genValue(e.memory,n)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Li(Z(e.angularVelocity),Sn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Li(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Vi{initialize(e){this.speed.startGen(e.memory)}constructor(e,t){this.speed=e,this.dampen=t,this.type="LimitSpeedOverLife"}update(e,t){let n=e.velocity.length(),i=this.speed.genValue(e.memory,e.age/e.life);if(n>i){const s=(n-i)/n;e.velocity.multiplyScalar(1-s*this.dampen*t*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(e){return new Vi(Z(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Vi(this.speed.clone(),this.dampen)}reset(){}}const Dr={ApplyForce:{type:"ApplyForce",constructor:Oi,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Oi.fromJSON},Noise:{type:"Noise",constructor:Ui,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Ui.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Ni,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Ni.fromJSON},GravityForce:{type:"GravityForce",constructor:zi,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:zi.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Ti,params:[["color",["colorFunc"]]],loadJSON:Ti.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Mi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Mi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Ci,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Ci.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Pi,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Pi.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Di,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Di.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Li,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Li.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Fi,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Fi.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Ei,params:[["speed",["value","valueFunc"]]],loadJSON:Ei.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:ki,params:[["frame",["value","valueFunc"]]],loadJSON:ki.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:wi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:wi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Ri,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Ri.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Ai,params:[["width",["value","valueFunc"]]],loadJSON:Ai.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Ii,params:[["angle",["value"]]],loadJSON:Ii.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Bi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:Bi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Vi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Vi.fromJSON}};function ch(r,e){return Dr[r.type]?Dr[r.type].loadJSON(r,e):null}const lh=[];function uh(r){if(!lh.find(t=>t.id===r.id)){for(const t of r.emitterShapes)qs[t.type]||(qs[t.type]=t);for(const t of r.behaviors)Dr[t.type]||(Dr[t.type]=t)}}var hh=`
|
|
79
79
|
#ifdef SOFT_PARTICLES
|
|
80
80
|
|
|
81
81
|
/* #ifdef LOGDEPTH
|
|
@@ -97,7 +97,7 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
97
97
|
|
|
98
98
|
//gl_FragColor = vec4(softParticlesFade , 0, 0, 1);
|
|
99
99
|
#endif
|
|
100
|
-
`,
|
|
100
|
+
`,fh=`
|
|
101
101
|
#ifdef SOFT_PARTICLES
|
|
102
102
|
|
|
103
103
|
uniform sampler2D depthTexture;
|
|
@@ -119,17 +119,17 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
#endif
|
|
122
|
-
`,
|
|
122
|
+
`,dh=`
|
|
123
123
|
#ifdef SOFT_PARTICLES
|
|
124
124
|
varying vec4 projPosition;
|
|
125
125
|
varying float linearDepth;
|
|
126
126
|
#endif
|
|
127
|
-
`,
|
|
127
|
+
`,ph=`
|
|
128
128
|
#ifdef SOFT_PARTICLES
|
|
129
129
|
projPosition = gl_Position;
|
|
130
130
|
linearDepth = -mvPosition.z;
|
|
131
131
|
#endif
|
|
132
|
-
`,
|
|
132
|
+
`,mh=`
|
|
133
133
|
#ifdef USE_MAP
|
|
134
134
|
vec4 texelColor = texture2D( map, vUv);
|
|
135
135
|
#ifdef TILE_BLEND
|
|
@@ -137,7 +137,7 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
137
137
|
#endif
|
|
138
138
|
diffuseColor *= texelColor;
|
|
139
139
|
#endif
|
|
140
|
-
`,
|
|
140
|
+
`,yh=`
|
|
141
141
|
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
142
142
|
|
|
143
143
|
varying vec2 vUv;
|
|
@@ -288,7 +288,7 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
288
288
|
varying vec2 vThicknessMapUv;
|
|
289
289
|
|
|
290
290
|
#endif
|
|
291
|
-
`,
|
|
291
|
+
`,gh=`
|
|
292
292
|
#ifdef UV_TILE
|
|
293
293
|
attribute float uvTile;
|
|
294
294
|
uniform vec2 tileCount;
|
|
@@ -458,7 +458,7 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
|
458
458
|
varying vec2 vThicknessMapUv;
|
|
459
459
|
|
|
460
460
|
#endif
|
|
461
|
-
`,
|
|
461
|
+
`,vh=`
|
|
462
462
|
#ifdef UV_TILE
|
|
463
463
|
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
464
464
|
#ifdef TILE_BLEND
|
|
@@ -596,7 +596,7 @@ vThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_U
|
|
|
596
596
|
|
|
597
597
|
#endif
|
|
598
598
|
|
|
599
|
-
`;const Xt=R.ShaderChunk;function hh(){Xt.tile_pars_vertex=lh,Xt.tile_vertex=uh,Xt.tile_pars_fragment=ch,Xt.tile_fragment=ah,Xt.soft_pars_vertex=sh,Xt.soft_vertex=oh,Xt.soft_pars_fragment=rh,Xt.soft_fragment=ih}class fh extends R.Object3D{constructor(e){super(),this.type="ParticleEmitter",this.system=e}clone(){const e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}dispose(){}extractFromCache(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}toJSON(e,t={}){const n=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const i=super.toJSON(e);return this.children=n,this.system!==null&&(i.object.ps=this.system.toJSON(e,t)),i}}exports.RenderMode=void 0;(function(r){r[r.BillBoard=0]="BillBoard",r[r.StretchedBillBoard=1]="StretchedBillBoard",r[r.Mesh=2]="Mesh",r[r.Trail=3]="Trail",r[r.HorizontalBillBoard=4]="HorizontalBillBoard",r[r.VerticalBillBoard=5]="VerticalBillBoard"})(exports.RenderMode||(exports.RenderMode={}));class jc extends R.Mesh{constructor(e){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const t=new R.Layers;t.mask=e.layers.mask;const n=e.material.clone();n.defines={},Object.assign(n.defines,e.material.defines),this.settings={instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,material:n,uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softNearFade:e.softNearFade,softFarFade:e.softFarFade,layers:t},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(e){this.systems.add(e)}removeSystem(e){this.systems.delete(e)}applyDepthTexture(e){const t=this.material.uniforms.depthTexture;t&&t.value!==e&&(t.value=e,this.material.needsUpdate=!0)}}const dh=new W(0,0,1),_s=new re,ph=new W,mh=new W;new W;const ba=60,yh=new R.PlaneGeometry(1,1,1,1);class Ur{set time(e){this.emissionState.time=e}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(e){this.rendererSettings.material.map=e,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(e){this.rendererSettings.material=e,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(e){this.rendererSettings.uTileCount=e,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(e){this.rendererSettings.vTileCount=e,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(e){this.rendererSettings.blendTiles=e,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(e){this.rendererSettings.softParticles=e,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(e){this.rendererSettings.softNearFade=e,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(e){this.rendererSettings.softFarFade=e,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(e){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=e,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(e){if((this.rendererSettings.renderMode!=exports.RenderMode.Trail&&e===exports.RenderMode.Trail||this.rendererSettings.renderMode==exports.RenderMode.Trail&&e!==exports.RenderMode.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==e)switch(e){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new ee(30),followLocalOrigin:!1};break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={geometry:new R.PlaneGeometry(1,1)},this.startRotation=new pi(new W(0,1,0),new ee(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new ee(0));break;case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new ee(0));break}this.rendererSettings.renderMode=e,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(e){this.rendererSettings.renderOrder=e,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(e){this.rendererSettings.material.blending=e,this.neededToUpdateRender=!0}constructor(e){var t,n,i,s,a,o,c,l,u,f,p,m,x,M,g,v,b,_,C,T,P,E,O,I,A,N;if(this.temp=new W,this.travelDistance=0,this.normalMatrix=new Ot,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=e.autoDestroy===void 0?!1:e.autoDestroy,this.duration=(t=e.duration)!==null&&t!==void 0?t:1,this.looping=e.looping===void 0?!0:e.looping,this.prewarm=e.prewarm===void 0?!1:e.prewarm,this.startLife=(n=e.startLife)!==null&&n!==void 0?n:new ee(5),this.startSpeed=(i=e.startSpeed)!==null&&i!==void 0?i:new ee(0),this.startRotation=(s=e.startRotation)!==null&&s!==void 0?s:new ee(0),this.startSize=(a=e.startSize)!==null&&a!==void 0?a:new ee(1),this.startColor=(o=e.startColor)!==null&&o!==void 0?o:new yn(new tt(1,1,1,1)),this.emissionOverTime=(c=e.emissionOverTime)!==null&&c!==void 0?c:new ee(10),this.emissionOverDistance=(l=e.emissionOverDistance)!==null&&l!==void 0?l:new ee(0),this.emissionBursts=(u=e.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(f=e.onlyUsedByOther)!==null&&f!==void 0?f:!1,this.emitterShape=(p=e.shape)!==null&&p!==void 0?p:new Nn,this.behaviors=(m=e.behaviors)!==null&&m!==void 0?m:new Array,this.worldSpace=(x=e.worldSpace)!==null&&x!==void 0?x:!1,this.rendererEmitterSettings=(M=e.rendererEmitterSettings)!==null&&M!==void 0?M:{},e.renderMode===exports.RenderMode.StretchedBillBoard){const z=this.rendererEmitterSettings;e.speedFactor!==void 0&&(z.speedFactor=e.speedFactor),z.speedFactor=(g=z.speedFactor)!==null&&g!==void 0?g:0,z.lengthFactor=(v=z.lengthFactor)!==null&&v!==void 0?v:0}this.rendererSettings={instancingGeometry:(b=e.instancingGeometry)!==null&&b!==void 0?b:yh,renderMode:(_=e.renderMode)!==null&&_!==void 0?_:exports.RenderMode.BillBoard,renderOrder:(C=e.renderOrder)!==null&&C!==void 0?C:0,material:e.material,uTileCount:(T=e.uTileCount)!==null&&T!==void 0?T:1,vTileCount:(P=e.vTileCount)!==null&&P!==void 0?P:1,blendTiles:(E=e.blendTiles)!==null&&E!==void 0?E:!1,softParticles:(O=e.softParticles)!==null&&O!==void 0?O:!1,softNearFade:(I=e.softNearFade)!==null&&I!==void 0?I:0,softFarFade:(A=e.softFarFade)!==null&&A!==void 0?A:0,layers:(N=e.layers)!==null&&N!==void 0?N:new R.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=e.startTileIndex||new ee(0),this.emitter=new fh(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(z=>z.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}spawn(e,t,n){_s.setFromRotationMatrix(n);const i=ph,s=_s,a=mh;n.decompose(i,s,a);for(let o=0;o<e;o++){for(t.burstParticleIndex=o,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===exports.RenderMode.Trail?this.particles.push(new Br):this.particles.push(new Wu);const c=this.particles[this.particleNum-1];if(c.reset(),c.speedModifier=1,this.startColor.startGen(c.memory),this.startColor.genColor(c.memory,c.startColor,this.emissionState.time),c.color.copy(c.startColor),this.startSpeed.startGen(c.memory),c.startSpeed=this.startSpeed.genValue(c.memory,t.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,t.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,t.time/this.duration);else{const l=this.startSize.genValue(c.memory,t.time/this.duration);c.startSize.set(l,l,l)}if(this.startTileIndex.startGen(c.memory),c.uvTile=this.startTileIndex.genValue(c.memory),c.size.copy(c.startSize),this.rendererSettings.renderMode===exports.RenderMode.Mesh||this.rendererSettings.renderMode===exports.RenderMode.BillBoard||this.rendererSettings.renderMode===exports.RenderMode.VerticalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.HorizontalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.StretchedBillBoard){const l=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===exports.RenderMode.Mesh?(l.rotation instanceof re||(l.rotation=new re),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,l.rotation,1,t.time/this.duration):l.rotation.setFromAxisAngle(dh,this.startRotation.genValue(l.memory,t.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,t.time/this.duration)}else if(this.rendererSettings.renderMode===exports.RenderMode.Trail){const l=c;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,t.time/this.duration)}if(this.emitterShape.initialize(c,t),this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=c;l.localPosition=new W().copy(l.position)}this.worldSpace?(c.position.applyMatrix4(n),c.startSize.multiply(a).abs(),c.size.copy(c.startSize),c.velocity.multiply(a).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof re&&c.rotation.multiplyQuaternions(_s,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=n);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(c,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(e=>{e.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(e=>e.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(e){if(this.paused)return;let t=this.emitter;for(;t.parent;)t=t.parent;if(t.type!=="Scene"){this.dispose();return}if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let n=0;n<this.duration*ba;n++)this.update(1/ba)}e>.1&&(e=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(e,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,e);for(let n=0;n<this.behaviors.length;n++){this.behaviors[n].frameUpdate(e);for(let i=0;i<this.particleNum;i++)this.particles[i].died||this.behaviors[n].update(this.particles[i],e)}for(let n=0;n<this.particleNum;n++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[n].localPosition?(this.particles[n].position.copy(this.particles[n].localPosition),this.particles[n].parentMatrix?this.particles[n].position.applyMatrix4(this.particles[n].parentMatrix):this.particles[n].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[n].position.addScaledVector(this.particles[n].velocity,e*this.particles[n].speedModifier),this.particles[n].age+=e;if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let n=0;n<this.particleNum;n++)this.particles[n].update();for(let n=0;n<this.particleNum;n++){const i=this.particles[n];i.died&&(!(i instanceof Br)||i.previous.length===0)&&(this.particles[n]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=i,this.particleNum--,n--,this.fire({type:"particleDied",particleSystem:this,particle:i}))}}emit(e,t,n){t.time>this.duration&&(this.looping?(t.time-=this.duration,t.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(n);const i=Math.ceil(t.waitEmiting);for(this.spawn(i,t,n),t.waitEmiting-=i;t.burstIndex<this.emissionBursts.length&&this.emissionBursts[t.burstIndex].time<=t.time;){if(Math.random()<this.emissionBursts[t.burstIndex].probability){const s=this.emissionBursts[t.burstIndex].count.genValue(this.memory,this.time);t.isBursting=!0,t.burstParticleCount=s,this.spawn(s,t,n),t.isBursting=!1}t.burstIndex++}if(!this.emitEnded&&(t.waitEmiting+=e*this.emissionOverTime.genValue(this.memory,t.time/this.duration),t.previousWorldPos!=null)){this.temp.set(n.elements[12],n.elements[13],n.elements[14]),t.travelDistance+=t.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,t.time/this.duration);if(t.travelDistance*s>0){const a=Math.floor(t.travelDistance*s);t.travelDistance-=a/s,t.waitEmiting+=a}}t.previousWorldPos===void 0&&(t.previousWorldPos=new W),t.previousWorldPos.set(n.elements[12],n.elements[13],n.elements[14]),t.time+=e}toJSON(e,t={}){var n;if((e===void 0||typeof e=="string")&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),e.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(e),t.useUrlForImage&&((n=this.texture)===null||n===void 0?void 0:n.source)!==void 0){const o=this.texture.source;e.images[o.uuid]={uuid:o.uuid,url:this.texture.image.url}}let s;this.renderMode===exports.RenderMode.Trail?s={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.Mesh?s={}:this.renderMode===exports.RenderMode.StretchedBillBoard?s={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:s={};const a=this.rendererSettings.instancingGeometry;return e.geometries&&!e.geometries[a.uuid]&&(e.geometries[a.uuid]=a.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(o=>({time:o.time,count:o.count.toJSON(),probability:o.probability,interval:o.interval,cycle:o.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:s,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map(o=>o.toJSON()),worldSpace:this.worldSpace}}static fromJSON(e,t,n){var i,s;const a=Gu(e.shape,t);let o;if(e.renderMode===exports.RenderMode.Trail){const u=e.rendererEmitterSettings;o={startLength:u.startLength!=null?K(u.startLength):new ee(30),followLocalOrigin:u.followLocalOrigin}}else e.renderMode===exports.RenderMode.Mesh?o={}:e.renderMode===exports.RenderMode.StretchedBillBoard?(o=e.rendererEmitterSettings,e.speedFactor!=null&&(o.speedFactor=e.speedFactor)):o={};const c=new R.Layers;e.layers&&(c.mask=e.layers);const l=new Ur({autoDestroy:e.autoDestroy,looping:e.looping,prewarm:e.prewarm,duration:e.duration,shape:a,startLife:K(e.startLife),startSpeed:K(e.startSpeed),startRotation:Ir(e.startRotation),startSize:Ir(e.startSize),startColor:co(e.startColor),emissionOverTime:K(e.emissionOverTime),emissionOverDistance:K(e.emissionOverDistance),emissionBursts:(i=e.emissionBursts)===null||i===void 0?void 0:i.map(u=>{var f,p,m;return{time:u.time,count:typeof u.count=="number"?new ee(u.count):K(u.count),probability:(f=u.probability)!==null&&f!==void 0?f:1,interval:(p=u.interval)!==null&&p!==void 0?p:.1,cycle:(m=u.cycle)!==null&&m!==void 0?m:1}}),onlyUsedByOther:e.onlyUsedByOther,instancingGeometry:t.geometries[e.instancingGeometry],renderMode:e.renderMode,rendererEmitterSettings:o,renderOrder:e.renderOrder,layers:c,material:e.material?t.materials[e.material]:e.texture?new R.MeshBasicMaterial({map:t.textures[e.texture],transparent:(s=e.transparent)!==null&&s!==void 0?s:!0,blending:e.blending,side:R.DoubleSide}):new R.MeshBasicMaterial({color:16777215,transparent:!0,blending:R.AdditiveBlending,side:R.DoubleSide}),startTileIndex:typeof e.startTileIndex=="number"?new ee(e.startTileIndex):K(e.startTileIndex),uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softFarFade:e.softFarFade,softNearFade:e.softNearFade,behaviors:[],worldSpace:e.worldSpace});return l.behaviors=e.behaviors.map(u=>{const f=eh(u,l);return f.type==="EmitSubParticleSystem"&&(n[u.subParticleSystem]=f),f}),l}addBehavior(e){this.behaviors.push(e)}getRendererSettings(){return this.rendererSettings}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeAllEventListeners(e){this.listeners[e]&&(this.listeners[e]=[])}removeEventListener(e,t){if(this.listeners[e]){const n=this.listeners[e].indexOf(t);n!==-1&&this.listeners[e].splice(n,1)}}fire(e){this.listeners[e.type]&&this.listeners[e.type].forEach(t=>t(e))}clone(){const e=[];for(const s of this.emissionBursts){const a={};Object.assign(a,s),e.push(a)}const t=[];for(const s of this.behaviors)t.push(s.clone());let n;this.renderMode===exports.RenderMode.Trail?n={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?n={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:n={};const i=new R.Layers;return i.mask=this.layers.mask,new Ur({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:e,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:t,worldSpace:this.worldSpace,layers:i})}}var bs=`
|
|
599
|
+
`;const Zt=A.ShaderChunk;function Sh(){Zt.tile_pars_vertex=gh,Zt.tile_vertex=vh,Zt.tile_pars_fragment=yh,Zt.tile_fragment=mh,Zt.soft_pars_vertex=dh,Zt.soft_vertex=ph,Zt.soft_pars_fragment=fh,Zt.soft_fragment=hh}class xh extends A.Object3D{constructor(e){super(),this.type="ParticleEmitter",this.system=e}clone(){const e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}dispose(){}extractFromCache(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}toJSON(e,t={}){const n=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const i=super.toJSON(e);return this.children=n,this.system!==null&&(i.object.ps=this.system.toJSON(e,t)),i}}exports.RenderMode=void 0;(function(r){r[r.BillBoard=0]="BillBoard",r[r.StretchedBillBoard=1]="StretchedBillBoard",r[r.Mesh=2]="Mesh",r[r.Trail=3]="Trail",r[r.HorizontalBillBoard=4]="HorizontalBillBoard",r[r.VerticalBillBoard=5]="VerticalBillBoard"})(exports.RenderMode||(exports.RenderMode={}));class qc extends A.Mesh{constructor(e){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const t=new A.Layers;t.mask=e.layers.mask;const n=e.material.clone();n.defines={},Object.assign(n.defines,e.material.defines),this.settings={instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,material:n,uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softNearFade:e.softNearFade,softFarFade:e.softFarFade,layers:t},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(e){this.systems.add(e)}removeSystem(e){this.systems.delete(e)}applyDepthTexture(e){const t=this.material.uniforms.depthTexture;t&&t.value!==e&&(t.value=e,this.material.needsUpdate=!0)}}const _h=new G(0,0,1),Ms=new ie,bh=new G,Th=new G;new G;const Ea=60,Mh=new A.PlaneGeometry(1,1,1,1);class Fr{set time(e){this.emissionState.time=e}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(e){this.rendererSettings.material.map=e,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(e){this.rendererSettings.material=e,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(e){this.rendererSettings.uTileCount=e,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(e){this.rendererSettings.vTileCount=e,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(e){this.rendererSettings.blendTiles=e,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(e){this.rendererSettings.softParticles=e,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(e){this.rendererSettings.softNearFade=e,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(e){this.rendererSettings.softFarFade=e,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(e){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=e,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(e){if((this.rendererSettings.renderMode!=exports.RenderMode.Trail&&e===exports.RenderMode.Trail||this.rendererSettings.renderMode==exports.RenderMode.Trail&&e!==exports.RenderMode.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==e)switch(e){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new ee(30),followLocalOrigin:!1};break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={geometry:new A.PlaneGeometry(1,1)},this.startRotation=new yi(new G(0,1,0),new ee(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new ee(0));break;case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new ee(0));break}this.rendererSettings.renderMode=e,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(e){this.rendererSettings.renderOrder=e,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(e){this.rendererSettings.material.blending=e,this.neededToUpdateRender=!0}constructor(e){var t,n,i,s,a,o,c,l,u,f,p,m,x,T,g,v,_,b,M,C,P,E,z,I,R,N;if(this.temp=new G,this.travelDistance=0,this.normalMatrix=new It,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=e.autoDestroy===void 0?!1:e.autoDestroy,this.duration=(t=e.duration)!==null&&t!==void 0?t:1,this.looping=e.looping===void 0?!0:e.looping,this.prewarm=e.prewarm===void 0?!1:e.prewarm,this.startLife=(n=e.startLife)!==null&&n!==void 0?n:new ee(5),this.startSpeed=(i=e.startSpeed)!==null&&i!==void 0?i:new ee(0),this.startRotation=(s=e.startRotation)!==null&&s!==void 0?s:new ee(0),this.startSize=(a=e.startSize)!==null&&a!==void 0?a:new ee(1),this.startColor=(o=e.startColor)!==null&&o!==void 0?o:new vn(new at(1,1,1,1)),this.emissionOverTime=(c=e.emissionOverTime)!==null&&c!==void 0?c:new ee(10),this.emissionOverDistance=(l=e.emissionOverDistance)!==null&&l!==void 0?l:new ee(0),this.emissionBursts=(u=e.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(f=e.onlyUsedByOther)!==null&&f!==void 0?f:!1,this.emitterShape=(p=e.shape)!==null&&p!==void 0?p:new Ln,this.behaviors=(m=e.behaviors)!==null&&m!==void 0?m:new Array,this.worldSpace=(x=e.worldSpace)!==null&&x!==void 0?x:!1,this.rendererEmitterSettings=(T=e.rendererEmitterSettings)!==null&&T!==void 0?T:{},e.renderMode===exports.RenderMode.StretchedBillBoard){const O=this.rendererEmitterSettings;e.speedFactor!==void 0&&(O.speedFactor=e.speedFactor),O.speedFactor=(g=O.speedFactor)!==null&&g!==void 0?g:0,O.lengthFactor=(v=O.lengthFactor)!==null&&v!==void 0?v:0}this.rendererSettings={instancingGeometry:(_=e.instancingGeometry)!==null&&_!==void 0?_:Mh,renderMode:(b=e.renderMode)!==null&&b!==void 0?b:exports.RenderMode.BillBoard,renderOrder:(M=e.renderOrder)!==null&&M!==void 0?M:0,material:e.material,uTileCount:(C=e.uTileCount)!==null&&C!==void 0?C:1,vTileCount:(P=e.vTileCount)!==null&&P!==void 0?P:1,blendTiles:(E=e.blendTiles)!==null&&E!==void 0?E:!1,softParticles:(z=e.softParticles)!==null&&z!==void 0?z:!1,softNearFade:(I=e.softNearFade)!==null&&I!==void 0?I:0,softFarFade:(R=e.softFarFade)!==null&&R!==void 0?R:0,layers:(N=e.layers)!==null&&N!==void 0?N:new A.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=e.startTileIndex||new ee(0),this.emitter=new xh(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(O=>O.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}spawn(e,t,n){Ms.setFromRotationMatrix(n);const i=bh,s=Ms,a=Th;n.decompose(i,s,a);for(let o=0;o<e;o++){for(t.burstParticleIndex=o,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===exports.RenderMode.Trail?this.particles.push(new Ur):this.particles.push(new eh);const c=this.particles[this.particleNum-1];if(c.reset(),c.speedModifier=1,this.startColor.startGen(c.memory),this.startColor.genColor(c.memory,c.startColor,this.emissionState.time),c.color.copy(c.startColor),this.startSpeed.startGen(c.memory),c.startSpeed=this.startSpeed.genValue(c.memory,t.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,t.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,t.time/this.duration);else{const l=this.startSize.genValue(c.memory,t.time/this.duration);c.startSize.set(l,l,l)}if(this.startTileIndex.startGen(c.memory),c.uvTile=this.startTileIndex.genValue(c.memory),c.size.copy(c.startSize),this.rendererSettings.renderMode===exports.RenderMode.Mesh||this.rendererSettings.renderMode===exports.RenderMode.BillBoard||this.rendererSettings.renderMode===exports.RenderMode.VerticalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.HorizontalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.StretchedBillBoard){const l=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===exports.RenderMode.Mesh?(l.rotation instanceof ie||(l.rotation=new ie),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,l.rotation,1,t.time/this.duration):l.rotation.setFromAxisAngle(_h,this.startRotation.genValue(l.memory,t.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,t.time/this.duration)}else if(this.rendererSettings.renderMode===exports.RenderMode.Trail){const l=c;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,t.time/this.duration)}if(this.emitterShape.initialize(c,t),this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=c;l.localPosition=new G().copy(l.position)}this.worldSpace?(c.position.applyMatrix4(n),c.startSize.multiply(a).abs(),c.size.copy(c.startSize),c.velocity.multiply(a).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof ie&&c.rotation.multiplyQuaternions(Ms,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=n);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(c,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(e=>{e.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(e=>e.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(e){if(this.paused)return;let t=this.emitter;for(;t.parent;)t=t.parent;if(t.type!=="Scene"){this.dispose();return}if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let n=0;n<this.duration*Ea;n++)this.update(1/Ea)}e>.1&&(e=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(e,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,e);for(let n=0;n<this.behaviors.length;n++){this.behaviors[n].frameUpdate(e);for(let i=0;i<this.particleNum;i++)this.particles[i].died||this.behaviors[n].update(this.particles[i],e)}for(let n=0;n<this.particleNum;n++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[n].localPosition?(this.particles[n].position.copy(this.particles[n].localPosition),this.particles[n].parentMatrix?this.particles[n].position.applyMatrix4(this.particles[n].parentMatrix):this.particles[n].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[n].position.addScaledVector(this.particles[n].velocity,e*this.particles[n].speedModifier),this.particles[n].age+=e;if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let n=0;n<this.particleNum;n++)this.particles[n].update();for(let n=0;n<this.particleNum;n++){const i=this.particles[n];i.died&&(!(i instanceof Ur)||i.previous.length===0)&&(this.particles[n]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=i,this.particleNum--,n--,this.fire({type:"particleDied",particleSystem:this,particle:i}))}}emit(e,t,n){t.time>this.duration&&(this.looping?(t.time-=this.duration,t.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(n);const i=Math.ceil(t.waitEmiting);for(this.spawn(i,t,n),t.waitEmiting-=i;t.burstIndex<this.emissionBursts.length&&this.emissionBursts[t.burstIndex].time<=t.time;){if(Math.random()<this.emissionBursts[t.burstIndex].probability){const s=this.emissionBursts[t.burstIndex].count.genValue(this.memory,this.time);t.isBursting=!0,t.burstParticleCount=s,this.spawn(s,t,n),t.isBursting=!1}t.burstIndex++}if(!this.emitEnded&&(t.waitEmiting+=e*this.emissionOverTime.genValue(this.memory,t.time/this.duration),t.previousWorldPos!=null)){this.temp.set(n.elements[12],n.elements[13],n.elements[14]),t.travelDistance+=t.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,t.time/this.duration);if(t.travelDistance*s>0){const a=Math.floor(t.travelDistance*s);t.travelDistance-=a/s,t.waitEmiting+=a}}t.previousWorldPos===void 0&&(t.previousWorldPos=new G),t.previousWorldPos.set(n.elements[12],n.elements[13],n.elements[14]),t.time+=e}toJSON(e,t={}){var n;if((e===void 0||typeof e=="string")&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),e.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(e),t.useUrlForImage&&((n=this.texture)===null||n===void 0?void 0:n.source)!==void 0){const o=this.texture.source;e.images[o.uuid]={uuid:o.uuid,url:this.texture.image.url}}let s;this.renderMode===exports.RenderMode.Trail?s={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.Mesh?s={}:this.renderMode===exports.RenderMode.StretchedBillBoard?s={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:s={};const a=this.rendererSettings.instancingGeometry;return e.geometries&&!e.geometries[a.uuid]&&(e.geometries[a.uuid]=a.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(o=>({time:o.time,count:o.count.toJSON(),probability:o.probability,interval:o.interval,cycle:o.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:s,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map(o=>o.toJSON()),worldSpace:this.worldSpace}}static fromJSON(e,t,n){var i,s;const a=Ku(e.shape,t);let o;if(e.renderMode===exports.RenderMode.Trail){const u=e.rendererEmitterSettings;o={startLength:u.startLength!=null?Z(u.startLength):new ee(30),followLocalOrigin:u.followLocalOrigin}}else e.renderMode===exports.RenderMode.Mesh?o={}:e.renderMode===exports.RenderMode.StretchedBillBoard?(o=e.rendererEmitterSettings,e.speedFactor!=null&&(o.speedFactor=e.speedFactor)):o={};const c=new A.Layers;e.layers&&(c.mask=e.layers);const l=new Fr({autoDestroy:e.autoDestroy,looping:e.looping,prewarm:e.prewarm,duration:e.duration,shape:a,startLife:Z(e.startLife),startSpeed:Z(e.startSpeed),startRotation:Nr(e.startRotation),startSize:Nr(e.startSize),startColor:fo(e.startColor),emissionOverTime:Z(e.emissionOverTime),emissionOverDistance:Z(e.emissionOverDistance),emissionBursts:(i=e.emissionBursts)===null||i===void 0?void 0:i.map(u=>{var f,p,m;return{time:u.time,count:typeof u.count=="number"?new ee(u.count):Z(u.count),probability:(f=u.probability)!==null&&f!==void 0?f:1,interval:(p=u.interval)!==null&&p!==void 0?p:.1,cycle:(m=u.cycle)!==null&&m!==void 0?m:1}}),onlyUsedByOther:e.onlyUsedByOther,instancingGeometry:t.geometries[e.instancingGeometry],renderMode:e.renderMode,rendererEmitterSettings:o,renderOrder:e.renderOrder,layers:c,material:e.material?t.materials[e.material]:e.texture?new A.MeshBasicMaterial({map:t.textures[e.texture],transparent:(s=e.transparent)!==null&&s!==void 0?s:!0,blending:e.blending,side:A.DoubleSide}):new A.MeshBasicMaterial({color:16777215,transparent:!0,blending:A.AdditiveBlending,side:A.DoubleSide}),startTileIndex:typeof e.startTileIndex=="number"?new ee(e.startTileIndex):Z(e.startTileIndex),uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softFarFade:e.softFarFade,softNearFade:e.softNearFade,behaviors:[],worldSpace:e.worldSpace});return l.behaviors=e.behaviors.map(u=>{const f=ch(u,l);return f.type==="EmitSubParticleSystem"&&(n[u.subParticleSystem]=f),f}),l}addBehavior(e){this.behaviors.push(e)}getRendererSettings(){return this.rendererSettings}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeAllEventListeners(e){this.listeners[e]&&(this.listeners[e]=[])}removeEventListener(e,t){if(this.listeners[e]){const n=this.listeners[e].indexOf(t);n!==-1&&this.listeners[e].splice(n,1)}}fire(e){this.listeners[e.type]&&this.listeners[e.type].forEach(t=>t(e))}clone(){const e=[];for(const s of this.emissionBursts){const a={};Object.assign(a,s),e.push(a)}const t=[];for(const s of this.behaviors)t.push(s.clone());let n;this.renderMode===exports.RenderMode.Trail?n={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?n={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:n={};const i=new A.Layers;return i.mask=this.layers.mask,new Fr({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:e,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:t,worldSpace:this.worldSpace,layers:i})}}var Cs=`
|
|
600
600
|
|
|
601
601
|
#include <common>
|
|
602
602
|
#include <color_pars_fragment>
|
|
@@ -631,7 +631,7 @@ void main() {
|
|
|
631
631
|
#include <soft_fragment>
|
|
632
632
|
#include <tonemapping_fragment>
|
|
633
633
|
}
|
|
634
|
-
`,
|
|
634
|
+
`,po=`
|
|
635
635
|
#define STANDARD
|
|
636
636
|
|
|
637
637
|
#ifdef PHYSICAL
|
|
@@ -796,7 +796,7 @@ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoat
|
|
|
796
796
|
#include <fog_fragment>
|
|
797
797
|
#include <premultiplied_alpha_fragment>
|
|
798
798
|
#include <dithering_fragment>
|
|
799
|
-
}`,
|
|
799
|
+
}`,Ch=`
|
|
800
800
|
#include <common>
|
|
801
801
|
#include <color_pars_vertex>
|
|
802
802
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -842,7 +842,7 @@ void main() {
|
|
|
842
842
|
#include <tile_vertex>
|
|
843
843
|
#include <soft_vertex>
|
|
844
844
|
}
|
|
845
|
-
`,
|
|
845
|
+
`,wh=`
|
|
846
846
|
#include <common>
|
|
847
847
|
#include <color_pars_vertex>
|
|
848
848
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -879,7 +879,7 @@ void main() {
|
|
|
879
879
|
#include <tile_vertex>
|
|
880
880
|
#include <soft_vertex>
|
|
881
881
|
}
|
|
882
|
-
`,
|
|
882
|
+
`,mo=`
|
|
883
883
|
#define STANDARD
|
|
884
884
|
varying vec3 vViewPosition;
|
|
885
885
|
#ifdef USE_TRANSMISSION
|
|
@@ -964,7 +964,7 @@ void main() {
|
|
|
964
964
|
vWorldPosition = worldPosition.xyz;
|
|
965
965
|
#endif
|
|
966
966
|
}
|
|
967
|
-
`,
|
|
967
|
+
`,Ph=`
|
|
968
968
|
#include <common>
|
|
969
969
|
#include <color_pars_vertex>
|
|
970
970
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -1005,7 +1005,7 @@ void main() {
|
|
|
1005
1005
|
#include <tile_vertex>
|
|
1006
1006
|
#include <soft_vertex>
|
|
1007
1007
|
}
|
|
1008
|
-
`;function Ws(r){return r===0?"uv":`uv${r}`}class xh extends R.MeshStandardMaterial{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=uo,e.fragmentShader=lo}}class _h extends R.MeshPhysicalMaterial{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=uo,e.fragmentShader=lo}}class bh extends jc{constructor(e){super(e),this.vector_=new W,this.vector2_=new W,this.vector3_=new W,this.quaternion_=new re,this.quaternion2_=new re,this.quaternion3_=new re,this.rotationMat_=new Ot,this.rotationMat2_=new Ot,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)):(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.StretchedBillBoard)&&(this.rotationBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new R.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new R.InstancedBufferGeometry,this.geometry.setIndex(this.settings.instancingGeometry.getIndex()),this.settings.instancingGeometry.hasAttribute("normal")&&this.geometry.setAttribute("normal",this.settings.instancingGeometry.getAttribute("normal")),this.geometry.setAttribute("position",this.settings.instancingGeometry.getAttribute("position")),this.geometry.setAttribute("uv",this.settings.instancingGeometry.getAttribute("uv")),this.buildExpandableBuffers()}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={},t={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(e.map=new R.Uniform$1(this.settings.material.map)),this.settings.material.alphaTest&&(t.USE_ALPHATEST="",e.alphaTest=new R.Uniform$1(this.settings.material.alphaTest)),t.USE_UV="";const n=this.settings.uTileCount,i=this.settings.vTileCount;(n>1||i>1)&&(t.UV_TILE="",e.tileCount=new R.Uniform$1(new In(n,i))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(t.USE_NORMALMAP="",t.NORMALMAP_UV=Ws(this.settings.material.normalMap.channel),e.normalMapTransform=new R.Uniform$1(new Ot().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(t.USE_MAP="",this.settings.blendTiles&&(t.TILE_BLEND=""),t.MAP_UV=Ws(this.settings.material.map.channel),e.mapTransform=new R.Uniform$1(new Ot().copy(this.settings.material.map.matrix))),t.USE_COLOR_ALPHA="";let s;if(this.settings.softParticles){t.SOFT_PARTICLES="";const o=this.settings.softNearFade,c=1/(this.settings.softFarFade-this.settings.softNearFade);e.softParams=new R.Uniform$1(new In(o,c)),e.depthTexture=new R.Uniform$1(null);const l=e.projParams=new R.Uniform$1(new tt);s=(u,f,p)=>{l.value.set(p.near,p.far,0,0)}}let a=!1;if(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.Mesh){let o,c;this.settings.renderMode===exports.RenderMode.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(t.USE_COLOR="",o=uo,c=lo,a=!0):(o=vh,c=bs):(o=gh,c=bs),this.settings.renderMode===exports.RenderMode.VerticalBillBoard?t.VERTICAL="":this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&(t.HORIZONTAL="");let l=!1;this.settings.renderMode===exports.RenderMode.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new xh({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new _h({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0)),l||(this.material=new R.ShaderMaterial({uniforms:e,defines:t,vertexShader:o,fragmentShader:c,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest,lights:a}))}else if(this.settings.renderMode===exports.RenderMode.StretchedBillBoard)e.speedFactor=new R.Uniform$1(1),this.material=new R.ShaderMaterial({uniforms:e,defines:t,vertexShader:Sh,fragmentShader:bs,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest});else throw new Error("render mode unavailable");this.material&&s&&(this.material.onBeforeRender=s)}update(){let e=0,t=0;this.systems.forEach(n=>{t+=n.particleNum}),t>this.maxParticles&&this.expandBuffers(t),this.systems.forEach(n=>{n.emitter.updateMatrixWorld&&(n.emitter.updateWorldMatrix(!0,!1),n.emitter.updateMatrixWorld(!0));const i=n.particles,s=n.particleNum,a=this.quaternion2_,o=this.vector2_,c=this.vector3_;n.emitter.matrixWorld.decompose(o,a,c),this.rotationMat_.setFromMatrix4(n.emitter.matrixWorld);for(let l=0;l<s;l++,e++){const u=i[l];if(this.settings.renderMode===exports.RenderMode.Mesh){let p;if(n.worldSpace)p=u.rotation;else{let m;u.parentMatrix?m=this.quaternion3_.setFromRotationMatrix(u.parentMatrix):m=a,p=this.quaternion_,p.copy(m).multiply(u.rotation)}this.rotationBuffer.setXYZW(e,p.x,p.y,p.z,p.w)}else(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&this.rotationBuffer.setX(e,u.rotation);let f;if(n.worldSpace?f=u.position:(f=this.vector_,u.parentMatrix?f.copy(u.position).applyMatrix4(u.parentMatrix):f.copy(u.position).applyMatrix4(n.emitter.matrixWorld)),this.offsetBuffer.setXYZ(e,f.x,f.y,f.z),this.colorBuffer.setXYZW(e,u.color.x,u.color.y,u.color.z,u.color.w),n.worldSpace?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):u.parentMatrix?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):this.sizeBuffer.setXYZ(e,u.size.x*Math.abs(c.x),u.size.y*Math.abs(c.y),u.size.z*Math.abs(c.z)),this.uvTileBuffer.setX(e,u.uvTile),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer){let p=n.rendererEmitterSettings.speedFactor;p===0&&(p=.001);const m=n.rendererEmitterSettings.lengthFactor;let x;n.worldSpace?x=u.velocity:(x=this.vector_,u.parentMatrix?(this.rotationMat2_.setFromMatrix4(u.parentMatrix),x.copy(u.velocity).applyMatrix3(this.rotationMat2_)):x.copy(u.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(e,x.x*p,x.y*p,x.z*p,m)}}}),this.geometry.instanceCount=e,e>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,e*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,e*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,e),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,e*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e*4),this.rotationBuffer.needsUpdate=!0):(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var Th=`
|
|
1008
|
+
`;function Xs(r){return r===0?"uv":`uv${r}`}class Eh extends A.MeshStandardMaterial{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=mo,e.fragmentShader=po}}class kh extends A.MeshPhysicalMaterial{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=mo,e.fragmentShader=po}}class Rh extends qc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.quaternion2_=new ie,this.quaternion3_=new ie,this.rotationMat_=new It,this.rotationMat2_=new It,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)):(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.StretchedBillBoard)&&(this.rotationBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new A.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new A.InstancedBufferGeometry,this.geometry.setIndex(this.settings.instancingGeometry.getIndex()),this.settings.instancingGeometry.hasAttribute("normal")&&this.geometry.setAttribute("normal",this.settings.instancingGeometry.getAttribute("normal")),this.geometry.setAttribute("position",this.settings.instancingGeometry.getAttribute("position")),this.geometry.setAttribute("uv",this.settings.instancingGeometry.getAttribute("uv")),this.buildExpandableBuffers()}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={},t={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(e.map=new A.Uniform$1(this.settings.material.map)),this.settings.material.alphaTest&&(t.USE_ALPHATEST="",e.alphaTest=new A.Uniform$1(this.settings.material.alphaTest)),t.USE_UV="";const n=this.settings.uTileCount,i=this.settings.vTileCount;(n>1||i>1)&&(t.UV_TILE="",e.tileCount=new A.Uniform$1(new Dn(n,i))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(t.USE_NORMALMAP="",t.NORMALMAP_UV=Xs(this.settings.material.normalMap.channel),e.normalMapTransform=new A.Uniform$1(new It().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(t.USE_MAP="",this.settings.blendTiles&&(t.TILE_BLEND=""),t.MAP_UV=Xs(this.settings.material.map.channel),e.mapTransform=new A.Uniform$1(new It().copy(this.settings.material.map.matrix))),t.USE_COLOR_ALPHA="";let s;if(this.settings.softParticles){t.SOFT_PARTICLES="";const o=this.settings.softNearFade,c=1/(this.settings.softFarFade-this.settings.softNearFade);e.softParams=new A.Uniform$1(new Dn(o,c)),e.depthTexture=new A.Uniform$1(null);const l=e.projParams=new A.Uniform$1(new at);s=(u,f,p)=>{l.value.set(p.near,p.far,0,0)}}let a=!1;if(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.Mesh){let o,c;this.settings.renderMode===exports.RenderMode.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(t.USE_COLOR="",o=mo,c=po,a=!0):(o=wh,c=Cs):(o=Ch,c=Cs),this.settings.renderMode===exports.RenderMode.VerticalBillBoard?t.VERTICAL="":this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&(t.HORIZONTAL="");let l=!1;this.settings.renderMode===exports.RenderMode.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new Eh({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new kh({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0)),l||(this.material=new A.ShaderMaterial({uniforms:e,defines:t,vertexShader:o,fragmentShader:c,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest,lights:a}))}else if(this.settings.renderMode===exports.RenderMode.StretchedBillBoard)e.speedFactor=new A.Uniform$1(1),this.material=new A.ShaderMaterial({uniforms:e,defines:t,vertexShader:Ph,fragmentShader:Cs,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest});else throw new Error("render mode unavailable");this.material&&s&&(this.material.onBeforeRender=s)}update(){let e=0,t=0;this.systems.forEach(n=>{t+=n.particleNum}),t>this.maxParticles&&this.expandBuffers(t),this.systems.forEach(n=>{n.emitter.updateMatrixWorld&&(n.emitter.updateWorldMatrix(!0,!1),n.emitter.updateMatrixWorld(!0));const i=n.particles,s=n.particleNum,a=this.quaternion2_,o=this.vector2_,c=this.vector3_;n.emitter.matrixWorld.decompose(o,a,c),this.rotationMat_.setFromMatrix4(n.emitter.matrixWorld);for(let l=0;l<s;l++,e++){const u=i[l];if(this.settings.renderMode===exports.RenderMode.Mesh){let p;if(n.worldSpace)p=u.rotation;else{let m;u.parentMatrix?m=this.quaternion3_.setFromRotationMatrix(u.parentMatrix):m=a,p=this.quaternion_,p.copy(m).multiply(u.rotation)}this.rotationBuffer.setXYZW(e,p.x,p.y,p.z,p.w)}else(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&this.rotationBuffer.setX(e,u.rotation);let f;if(n.worldSpace?f=u.position:(f=this.vector_,u.parentMatrix?f.copy(u.position).applyMatrix4(u.parentMatrix):f.copy(u.position).applyMatrix4(n.emitter.matrixWorld)),this.offsetBuffer.setXYZ(e,f.x,f.y,f.z),this.colorBuffer.setXYZW(e,u.color.x,u.color.y,u.color.z,u.color.w),n.worldSpace?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):u.parentMatrix?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):this.sizeBuffer.setXYZ(e,u.size.x*Math.abs(c.x),u.size.y*Math.abs(c.y),u.size.z*Math.abs(c.z)),this.uvTileBuffer.setX(e,u.uvTile),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer){let p=n.rendererEmitterSettings.speedFactor;p===0&&(p=.001);const m=n.rendererEmitterSettings.lengthFactor;let x;n.worldSpace?x=u.velocity:(x=this.vector_,u.parentMatrix?(this.rotationMat2_.setFromMatrix4(u.parentMatrix),x.copy(u.velocity).applyMatrix3(this.rotationMat2_)):x.copy(u.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(e,x.x*p,x.y*p,x.z*p,m)}}}),this.geometry.instanceCount=e,e>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,e*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,e*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,e),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,e*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e*4),this.rotationBuffer.needsUpdate=!0):(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var Ah=`
|
|
1009
1009
|
|
|
1010
1010
|
#include <common>
|
|
1011
1011
|
#include <tile_pars_fragment>
|
|
@@ -1038,7 +1038,7 @@ void main() {
|
|
|
1038
1038
|
|
|
1039
1039
|
#include <fog_fragment>
|
|
1040
1040
|
#include <tonemapping_fragment>
|
|
1041
|
-
}`,
|
|
1041
|
+
}`,Oh=`
|
|
1042
1042
|
#include <common>
|
|
1043
1043
|
#include <tile_pars_vertex>
|
|
1044
1044
|
#include <color_pars_vertex>
|
|
@@ -1113,4 +1113,4 @@ void main() {
|
|
|
1113
1113
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1114
1114
|
|
|
1115
1115
|
#include <fog_vertex>
|
|
1116
|
-
}`;class Ch extends jc{constructor(e){super(e),this.vector_=new W,this.vector2_=new W,this.vector3_=new W,this.quaternion_=new re,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new R.BufferGeometry,this.indexBuffer=new R.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new In(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Ws(this.settings.material.map.channel),e.map=new R.Uniform$1(this.settings.material.map),e.mapTransform=new R.Uniform$1(new Ot().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new R.ShaderMaterial({uniforms:e,defines:t,vertexShader:Mh,fragmentShader:Th,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||R.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const M=c[x],g=M.uvTile%f,v=Math.floor(M.uvTile/f+.001),b=M.previous.values();let _=b.next(),C=_.value,T=C;_.done||(_=b.next());let P;_.value!==void 0?P=_.value:P=T;for(let E=0;E<M.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,T.position.x,T.position.y,T.position.z),this.positionBuffer.setXYZ(e+1,T.position.x,T.position.y,T.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,T.position.x,T.position.y,T.position.z),this.positionBuffer.setXYZ(e+1,T.position.x,T.position.y,T.position.z)):(M.parentMatrix?this.vector_.copy(T.position).applyMatrix4(M.parentMatrix):this.vector_.copy(T.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.previousBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(M.parentMatrix?this.vector_.copy(C.position).applyMatrix4(M.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(M.parentMatrix?this.vector_.copy(P.position).applyMatrix4(M.parentMatrix):this.vector_.copy(P.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,T.size),this.widthBuffer.setX(e+1,T.size);else if(M.parentMatrix)this.widthBuffer.setX(e,T.size),this.widthBuffer.setX(e+1,T.size);else{const O=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,T.size*O),this.widthBuffer.setX(e+1,T.size*O)}this.uvBuffer.setXY(e,(E/M.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/M.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,T.color.x,T.color.y,T.color.z,T.color.w),this.colorBuffer.setXYZW(e+1,T.color.x,T.color.y,T.color.z,T.color.w),E+1<M.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),C=T,T=P,_.done||(_=b.next(),_.value!==void 0&&(P=_.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Li{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new R.Triangle;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new R.Vector3,this._tempB=new R.Vector3,this._tempC=new R.Vector3,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Li(t.geometries[e.geometry])}clone(){return new Li(this._geometry)}update(e,t){}}nh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Li,loadJSON:Li.fromJSON}],behaviors:[]});class ho extends R.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(ho.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new Ch(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new bh(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const wh=ho;hh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const Gc=Math.sqrt(5),Ph=(Gc-1)/4,ze=(5-Gc)/20,rr=r=>Math.floor(r)|0,sr=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Eh(r=Math.random){const e=kh(r),t=new Float64Array(e).map(a=>sr[a%32*4]),n=new Float64Array(e).map(a=>sr[a%32*4+1]),i=new Float64Array(e).map(a=>sr[a%32*4+2]),s=new Float64Array(e).map(a=>sr[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,M;const g=(o+c+l+u)*Ph,v=rr(o+g),b=rr(c+g),_=rr(l+g),C=rr(u+g),T=(v+b+_+C)*ze,P=v-T,E=b-T,O=_-T,I=C-T,A=o-P,N=c-E,z=l-O,U=u-I;let F=0,J=0,j=0,q=0;A>N?F++:J++,A>z?F++:j++,A>U?F++:q++,N>z?J++:j++,N>U?J++:q++,z>U?j++:q++;const G=F>=3?1:0,ne=J>=3?1:0,ie=j>=3?1:0,he=q>=3?1:0,se=F>=2?1:0,ge=J>=2?1:0,be=j>=2?1:0,oe=q>=2?1:0,fe=F>=1?1:0,ae=J>=1?1:0,je=j>=1?1:0,Ue=q>=1?1:0,De=A-G+ze,Ge=N-ne+ze,xe=z-ie+ze,ye=U-he+ze,ce=A-se+2*ze,st=N-ge+2*ze,Pe=z-be+2*ze,de=U-oe+2*ze,Ye=A-fe+3*ze,yt=N-ae+3*ze,gt=z-je+3*ze,Ze=U-Ue+3*ze,vt=A-1+4*ze,ot=N-1+4*ze,at=z-1+4*ze,St=U-1+4*ze,Ee=v&255,$e=b&255,nt=_&255,We=C&255;let Q=.6-A*A-N*N-z*z-U*U;if(Q<0)f=0;else{const ue=Ee+e[$e+e[nt+e[We]]];Q*=Q,f=Q*Q*(t[ue]*A+n[ue]*N+i[ue]*z+s[ue]*U)}let xt=.6-De*De-Ge*Ge-xe*xe-ye*ye;if(xt<0)p=0;else{const ue=Ee+G+e[$e+ne+e[nt+ie+e[We+he]]];xt*=xt,p=xt*xt*(t[ue]*De+n[ue]*Ge+i[ue]*xe+s[ue]*ye)}let It=.6-ce*ce-st*st-Pe*Pe-de*de;if(It<0)m=0;else{const ue=Ee+se+e[$e+ge+e[nt+be+e[We+oe]]];It*=It,m=It*It*(t[ue]*ce+n[ue]*st+i[ue]*Pe+s[ue]*de)}let _t=.6-Ye*Ye-yt*yt-gt*gt-Ze*Ze;if(_t<0)x=0;else{const ue=Ee+fe+e[$e+ae+e[nt+je+e[We+Ue]]];_t*=_t,x=_t*_t*(t[ue]*Ye+n[ue]*yt+i[ue]*gt+s[ue]*Ze)}let Bt=.6-vt*vt-ot*ot-at*at-St*St;if(Bt<0)M=0;else{const ue=Ee+1+e[$e+1+e[nt+1+e[We+1]]];Bt*=Bt,M=Bt*Bt*(t[ue]*vt+n[ue]*ot+i[ue]*at+s[ue]*St)}return 27*(f+p+m+x+M)}}function kh(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Rh=Object.defineProperty,Ah=(r,e,t)=>e in r?Rh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Ah(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class M extends r{}class g extends r{}class v extends r{}class b extends r{}class _ extends r{}class C extends r{}class T extends r{}class P extends r{}class E extends r{}class O extends r{}class I{constructor(d){Ce(this,"input"),Ce(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);d.push(w),y+=String.fromCodePoint(w).length}return d}}function A(h){return h===10}function N(h){return A(h)||h===8192||h===32}function z(h){return h>=48&&h<=57}function U(h){return z(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return F(h)||z(h)||h===45}function j(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function q(h,d){return h===92&&!A(d)}function G(h,d,y){return h===45?F(d)||d===45||q(d,y):!!F(h)||h===92&&q(h,d)}function ne(h,d,y){return h===43||h===45?z(d)||d===46&&z(y):z(h===46?d:h)}function ie(h){const d=h.consume();if(U(d)){let y=[d];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function he(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const w=h.peek()[0];w===void 0||(A(w)?h.consume():y.value+=String.fromCodePoint(ie(h)))}else y.value+=String.fromCodePoint(S)}}function se(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!q(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ie(h))}}}function ge(h){let d=(function(y){let S="integer",w="";for([43,45].includes(y.peek()[0])&&(w+=String.fromCodePoint(y.consume()));z(...y.peek());)w+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&z(y.peek()[1]))for(w+=String.fromCodePoint(y.consume(),y.consume()),S="number";z(...y.peek());)w+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&z(y.peek()[2])?(w+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):z(y.peek()[1])&&(w+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(w),type:S}})(h);return G(...h.peek())?new p(d.value,d.type,se(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function be(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;q(...h.peek())&&ie(h)}}function oe(h){const d=se(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(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)||j(w))return be(y),new c;if(w===92){if(!q(...y.peek()))return be(y),new c;S.value+=ie(y)}else S.value+=String.fromCodePoint(w)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function fe(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return he(h,d);if(d===35){if(J(y[0])||q(...y)){const S=new i;return G(...y)&&(S.type="id"),S.value=se(h),S}return new l(String.fromCodePoint(d))}return d===39?he(h,d):d===40?new T:d===41?new P:d===43?ne(...y)?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===44?new b:d===45?ne(...h.peek())?(h.reconsume(d),ge(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new M):G(...h.peek())?(h.reconsume(d),oe(h)):new l(String.fromCodePoint(d)):d===46?ne(...h.peek())?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?G(...y)?new n(se(h)):new l(String.fromCodePoint(d)):d===91?new _:d===92?q(...y)?(h.reconsume(d),oe(h)):new l(String.fromCodePoint(d)):d===93?new C:d===123?new E:d===125?new O:z(d)?(h.reconsume(d),ge(h)):F(d)?(h.reconsume(d),oe(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const ae=new Set(["px","deg","s","hz","dppx","number","fr"]);function je(h){return ae.has(h.toLowerCase())}function Ue(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function De(h){const d=[];let y=0;function S(){let k=0;const B=y;for(;y<h.length;){const L=h.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 h.slice(B,y)}function w(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?w():d.push(S())}return d}function Ge(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function xe(h,d){const y=[],S=[];for(const w of h)d(w)?y.push(w):S.push(w);return[y,S]}function ye(h,d={}){function y(S){return Array.from(S).map((w=>ye(w,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const w=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(w,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(ye(h.value,d));break;case"clamp":h=new CSSMathClamp(ye(h.lower,d),ye(h.value,d),ye(h.upper,d));break;case"invert":h=new CSSMathInvert(ye(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&je(w.unit)&&w.unit===S[0].unit))){const w=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[w,k]=xe(S,(L=>L instanceof CSSUnitValue&&L.unit!=="percent")),B=Array.from(Ge(w,"unit").values());if(B.some((L=>L.length>0))){const L=B.map((D=>{const V=Math[h.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...L,...k):new CSSMathMax(...L,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const B=k.filter((L=>L instanceof CSSUnitValue));return[...k.filter((L=>!(L instanceof CSSUnitValue))),...Array.from(Ge(B,"unit").entries()).map((([L,D])=>{const V=D.reduce(((H,{value:Y})=>H+Y),0);return new CSSUnitValue(V,L)}))]},w=[];for(const k of h.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(h instanceof CSSMathProduct){let S=[];for(const B of h.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&&je(B.unit)||B instanceof CSSMathInvert&&B.value instanceof CSSUnitValue&&je(B.value.unit)))){const B=new CSSMathProduct(...S).toSum();if(B&&B.values.length===1)return B.values[0]}return new CSSMathProduct(...S)}return h}const ce=null,st=["percent","length","angle","time","frequency","resolution","flex"],Pe={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}}},de=new Map;for(const h of Object.values(Pe))if(h.compatible)for(const d of h.units)de.set(d,h);function Ye(h){return de.get(h)}function yt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function gt(h){return h==="number"?{}:h==="percent"?{percent:1}:Pe.absoluteLengths.units.has(h)||Pe.fontRelativeLengths.units.has(h)||Pe.viewportRelativeLengths.units.has(h)?{length:1}:Pe.angle.units.has(h)?{angle:1}:Pe.time.units.has(h)?{time:1}:Pe.frequency.units.has(h)?{frequency:1}:Pe.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ce}function Ze(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=Ye(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Ze(h.value);if(d===ce||d.length>1)return ce;const y=d[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Ze(y),w=[];if(S===ce)return ce;for(const k of d)for(const B of S)w.push([k[0]*B[0],yt(k[1],B[1])]);d=w}return d}throw new Error("Not implemented")}function vt(h,d){if(gt(d)===ce)throw new SyntaxError("The string did not match the expected pattern.");const y=Ze(h);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=Ye(B),V=Ye(k);return!V||D!==V?ce:new CSSUnitValue(L*V.ratios[B]/V.ratios[k],k)})(ot(y[0]),d);if(S===ce)throw new TypeError;return S}function ot(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ce;if(S.length===0)return new CSSUnitValue(d,"number");const w=S[0];return w[1]!==1?ce:new CSSUnitValue(d,w[0])}function at(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Ze(h).map((S=>ot(S)));if(y.some((S=>S===ce)))throw new TypeError("Type error");return new CSSMathSum(...y)}function St(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ce;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of st)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Ee{constructor(d,y){Ce(this,"name"),Ce(this,"values"),this.name=d,this.values=y}}class $e{constructor(d,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=d,this.associatedToken=y}}function nt(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new I(d),S=[];for(;;){const w=fe(y);if(w===void 0)return S;S.push(w)}})(h);throw new TypeError("Invalid input type "+typeof h)}function We(h){const d=h.shift();return d instanceof E||d instanceof _||d instanceof T?(function(y,S){let w;if(S instanceof E)w=O;else if(S instanceof T)w=P;else{if(!(S instanceof _))return;w=C}const k=new $e([],S);for(;;){const B=y.shift();if(B instanceof w||B===void 0)return k;y.unshift(B),k.value.push(We(y))}})(h,d):d instanceof t?(function(y,S){const w=new Ee(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return w;S.unshift(k),w.values.push(We(S))}})(d,h):d}function Q(h){if(h instanceof T||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function xt(h){return h[h.length-1]}function It(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",w=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function _t(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>_t(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>_t(d))));if(h.type==="NEGATE")return new CSSMathNegate(_t(h.value));if(h.type==="INVERT")return new CSSMathInvert(_t(h.value));if(h instanceof $e)return Bt(new Ee("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return ue(h)}function Bt(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((w=>!(w instanceof m||w instanceof b))).map((w=>ye(Bt(new Ee("calc",w)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=_t((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof u||B instanceof p||B instanceof f||B instanceof Ee||B instanceof $e||B instanceof e)k.push(B);else if(B instanceof l&&["*","/","+","-"].includes(B.value)){for(;w.length&&!(xt(w)instanceof T)&&Q(xt(w))>Q(B);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(It(L,V,D))}w.push(B)}else if(B instanceof T)w.push(B);else if(B instanceof P){if(!w.length)return null;for(;!(xt(w)instanceof T);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(It(L,V,D))}if(!(xt(w)instanceof T))return null;w.pop()}else if(!(B instanceof m))return null}for(;w.length;){if(xt(w)instanceof T)return null;const B=w.pop(),L=k.pop(),D=k.pop();k.push(It(B,D,L))}return k[0]})([...h.values]));let y;try{y=ye(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function ue(h){return h instanceof Ee&&["calc","min","max","clamp"].includes(h.name)?Bt(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function Qc(h){const d=(function(y){const S=nt(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const w=We(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?w:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Ee||new CSSStyleSheet().insertRule("error",0),d instanceof p&>(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),ue(d)}(function(){let h=new WeakMap;function d(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(Qc(B),{})}}class S extends y{constructor(B,L,D,V){super(),h.set(this,{values:d(B),operator:L,name:D||L,delimiter:V||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const B=h.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),h.set(this,{value:k,unit:B})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return vt(this,k)}toSum(...k){return at(this,...k)}type(){return gt(h.get(this).unit)}toString(){const k=h.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 at(this,...k)}type(){return h.get(this).values.map((k=>k.type())).reduce(St)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const B={};for(const L of st)B[L]=-1*k[L];return B})(h.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 yo="block";let Fe=new WeakMap,Nt=new WeakMap;const Gi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function go(h){return h===document.scrollingElement?document:h}function nn(h){Wr(h);let d=Fe.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function vo(h,d){if(!h)return null;const y=Nt.get(h).sourceMeasurements,S=getComputedStyle(h);let w=y.scrollTop;return Ue(d,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function $r(h,d){const y=ye(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function Wr(h){if(!(h instanceof xn))return void(function(y){const S=Fe.get(y);if(!S.anonymousSource)return;const w=xo(S.anonymousSource,S.anonymousTarget);Sn(y,w)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void Sn(h,null);Sn(h,Kr(d))}function So(h){return["block","inline","x","y"].includes(h)}function Hr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function qr(h,d){if(!h||!d)return;let y=0,S=0,w=d;const k=h.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const B=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:B.fontSize}}function $i(h){let d=Nt.get(h);d.sourceMeasurements=Hr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof xn&&(Fe.get(S).subjectMeasurements=qr(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&nn(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function Sn(h,d){const y=Fe.get(h),S=y.source;if(S!=d){if(S){const w=Nt.get(S);if(w){w.timelineRefs.delete(h);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(),Nt.delete(S))}}if(y.source=d,d){let w=Nt.get(d);if(!w){w={timelineRefs:new Set,sourceMeasurements:Hr(d)},Nt.set(d,w);const k=new ResizeObserver((D=>{for(const V of D)$i(y.source)}));k.observe(d);for(const D of d.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)$i(V.target)}));B.observe(d,{attributes:!0,attributeFilter:["style","class"]});const L=()=>{w.sourceMeasurements.scrollLeft=d.scrollLeft,w.sourceMeasurements.scrollTop=d.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&nn(V)}};go(d).addEventListener("scroll",L),w.disconnect=()=>{k.disconnect(),B.disconnect(),go(d).removeEventListener("scroll",L)}}w.timelineRefs.add(new WeakRef(h))}}}function Xr(h,d){let y=Fe.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Yr(h,d,y){let S=Fe.get(h).animations;for(let w=0;w<S.length;w++)if(S[w].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{nn(h)}))}class He{constructor(d){if(Fe.set(this,{source:null,axis:yo,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Sn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=yo){if(!So(d.axis))throw TypeError("Invalid axis");Fe.get(this).axis=d.axis}nn(this)}set source(d){Sn(this,d),nn(this)}get source(){return Fe.get(this).source}set axis(d){if(!So(d))throw TypeError("Invalid axis");Fe.get(this).axis=d,nn(this)}get axis(){return Fe.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==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=vo(y,w),B=(function(L,D){const V=Nt.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 Zr(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function xo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return Kr(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function el(h){switch(getComputedStyle(h).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 _o(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function tl(h){return getComputedStyle(h).position!="static"||_o(h)}function nl(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return Zr(h,el);case"absolute":return Zr(h,tl);case"fixed":return Zr(h,_o)}}function Kr(h){if(h&&h.isConnected){for(;h=nl(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function Ln(h,d){const y=Fe.get(h),S=y.subjectMeasurements,w=Nt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof xn?Qr(d,w,S,y.axis,y.inset):null}function Qr(h,d,y,S,w){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let B,L,D={fontSize:y.fontSize};Ue(S,d)==="x"?(B=y.offsetWidth,L=y.left,D.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(L+=d.scrollWidth-d.clientWidth,D.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),D.containerSize=d.clientWidth):(B=y.offsetHeight,L=y.top,D.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],D.containerSize=d.clientHeight);const V=(function(is,Yi){const pl={start:0,end:0};if(!is)return pl;const[ml,yl]=[is.start,is.end].map(((No,Uo)=>No==="auto"?Yi.scrollPadding[Uo]==="auto"?0:parseFloat(Yi.scrollPadding[Uo]):$r(No,{percentageReference:CSS.px(Yi.containerSize),fontSize:CSS.px(parseFloat(Yi.fontSize))})));return{start:ml,end:yl}})(w,D),H=L-D.containerSize+V.end,Y=L+B-V.start,Z=H+B,pe=Y-B,Te=Math.min(Z,pe),Ke=Math.max(Z,pe);let bt,ct;const Bo=B>D.containerSize-V.start-V.end;switch(h){case"cover":bt=H,ct=Y;break;case"contain":bt=Te,ct=Ke;break;case"entry":bt=H,ct=Te;break;case"exit":bt=Ke,ct=Y;break;case"entry-crossing":bt=H,ct=Bo?Ke:Te;break;case"exit-crossing":bt=Bo?Te:Ke,ct=Y}return{start:bt,end:ct}}function bo(h,d){if(h instanceof xn){const{rangeName:y,offset:S}=d;return To(Ln(h,y),S,Ln(h,"cover"),h.subject)}if(h instanceof He){const{axis:y,source:S}=h,{sourceMeasurements:w}=Nt.get(S);let k;return k=Ue(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,$r(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function To(h,d,y,S){if(!h||!y)return 0;let w=getComputedStyle(S);return($r(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(w.fontSize))})+h.start-y.start)/(y.end-y.start)}let xn=class extends He{constructor(d){super(d);const y=Fe.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let w;if(w=typeof S=="string"?De(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]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{$i(y.source)})).observe(y.subject),new MutationObserver((()=>{$i(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),Wr(this),y.subjectMeasurements=qr(y.source,y.subject),nn(this)}get source(){return Wr(this),Fe.get(this).source}set source(d){throw new Error("Cannot set the source of a view timeline")}get subject(){return Fe.get(this).subject}get axis(){return Fe.get(this).axis}get currentTime(){const y=vo(this.source,this.axis);if(y==null)return null;const S=Ln(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(Ln(this,"cover").start)}get endOffset(){return CSS.px(Ln(this,"cover").end)}};const il=document.getAnimations,rl=window.Element.prototype.getAnimations,sl=window.Element.prototype.animate,Mo=window.Animation;class _n{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function Vn(h){h.readyPromise=new _n,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Wi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Po(h):wo(h))}))}function Co(){return new DOMException("The user aborted a request","AbortError")}function rn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Dt(h),w=S?y*d/S:0;return CSS.percent(w)}function ve(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Dt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.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 wo(h){const d=ve(h,h.timeline.currentTime);if(h.holdTime!=null)Pt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;Pt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Ut(h,!1,!1),Ft(h),h.pendingTask=null}function Po(h){const d=ve(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),Pt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Ut(h,!1,!1),Ft(h),h.pendingTask=null}function Eo(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function bn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function Pt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function ko(h){if(!h.timeline)return null;const d=ve(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Ut(h,d,y){if(!h.timeline)return;let S=d?ve(h,h.proxy.currentTime):ko(h);if(S&&h.startTime!=null&&!h.proxy.pending){const w=bn(h),k=Dt(h);let B=h.previousCurrentTime;w>0&&S>=k&&h.previousCurrentTime!=null?((B===null||B<k)&&(B=k),h.holdTime=d?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),h.holdTime=d?S:B):w!=0&&(d&&h.holdTime!==null&&(h.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})(h,h.holdTime)),h.holdTime=null)}Ft(h),h.previousCurrentTime=ve(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new _n),h.finishedPromise.state=="pending"&&(y?Eo(h):Promise.resolve().then((()=>{Eo(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new _n),h.animation.playState!="paused"&&h.animation.pause())}function Dt(h){const d=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Ft(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;es(h,(ve(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&es(h,h.holdTime)}function es(h,d){const y=h.timeline,S=h.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+w}function ts(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,w=ve(h,h.proxy.currentTime);bn(h)==0&&w==null&&(h.holdTime=0),w==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Ft(h),h.readyPromise||Vn(h),h.pendingTask="play",Yr(h.timeline,h.animation,ns.bind(h.proxy)),Ut(h,!1,!1))}function ns(h){const d=X.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Wi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Po(d):wo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(d,h);es(d,(S-ve(d,this.startTime))*this.playbackRate),Ut(d,!1,!1)}}function Ro(h){h.specifiedTiming=null}let X=new WeakMap;window.addEventListener("pagehide",(h=>{X=new WeakMap}),!1);let Ao=new WeakMap;function Wi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Oo(k.timeline):k.animationRange.start;return bo(k.timeline,B)})(h))}catch(k){y=CSS.percent(0),h.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"?zo(k.timeline):k.animationRange.end;return 1-bo(k.timeline,B)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const w=bn(h);h.startTime=ve(h,w>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Ro(h)}function Hi(h){throw new Error("Unsupported timeline class")}function Oo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof He?CSS.percent(0):void Hi()}function zo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof He?CSS.percent(100):void Hi()}function ol(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Oo(h),end:zo(h)};if(h instanceof ViewTimeline){const S=De(d),w=[],k=[];if(S.forEach((B=>{if(Gi.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${d}"`)}})),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(h instanceof He){const S=d.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}Hi()}function qi(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(w=d.offset);else{const k=De(d);k.length===1?Gi.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(!Gi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(h instanceof He)return CSSNumericValue.parse(d);Hi()}class Xi{constructor(d,y,S={}){const w=y instanceof He,k=d instanceof Mo?d:new Mo(d,w?void 0:y);Ao.set(k,this),X.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?ol(y,S["animation-range"]):null,proxy:this})}get effect(){const d=X.get(this);return d.timeline?(d.effect||(d.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 Y=y.duration??100;H.localTime=rn(y,H.localTime),H.endTime=rn(y,H.endTime),H.activeDuration=rn(y,H.activeDuration);const Z=Dt(y),pe=H.iterations?(Z-H.delay-H.endDelay)/H.iterations:0;H.duration=Z?CSS.percent(Y*pe/Z):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 Y,Z=Object.assign({},y.specifiedTiming);if(Z.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Z.duration===null||Z.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Z.delay=0,Z.endDelay=0,Y=Z.iterations?1e5:0,Z.duration=Z.iterations?(Y-Z.delay-Z.endDelay)/Z.iterations:0,Z.duration<0&&(Z.duration=0,Z.endDelay=Y-Z.delay),w.apply(S,[Z])),y.normalizedTiming=Z,y.specifiedTiming}},L={apply:function(V,H,Y){if(Y&&Y.length){if(y.timeline&&Y[0]){const Z=Y[0],pe=Z.duration;if(pe===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Z.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");pe!==void 0&&pe!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,Y),Ro(y)}}},D=new Proxy(S,{get:function(V,H){const Y=V[H];return typeof Y=="function"?Y.bind(S):Y},set:function(V,H,Y){return V[H]=Y,!0}});return D.getComputedTiming=new Proxy(S.getComputedTiming,k),D.getTiming=new Proxy(S.getTiming,B),D.updateTiming=new Proxy(S.updateTiming,L),D})(d)),d.effect):d.animation.effect}set effect(d){const y=X.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=X.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=X.get(this),S=this.timeline;if(S==d)return;const w=this.playState,k=this.currentTime;let B,L=Dt(y);B=k===null?null:L===0?0:ve(y,k)/L;const D=S instanceof He,V=d instanceof He,H=this.pending;if(D&&Xr(y.timeline,y.animation),V)return y.timeline=d,Pt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Vn(y),y.pendingTask="play",Yr(y.timeline,y.animation,ns.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*L),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||Vn(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Ut(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Xr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Dt(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=X.get(this);return d.timeline?rn(d,d.startTime):d.animation.startTime}set startTime(d){const y=X.get(this);if(d=ve(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ve(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Ft(y));const S=ve(y,this.currentTime);Pt(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Ut(y,!0,!1),Ft(y)}get currentTime(){const d=X.get(this);return d.timeline?d.holdTime!=null?rn(d,d.holdTime):rn(d,ko(d)):d.animation.currentTime}set currentTime(d){const y=X.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,d),y.pendingTask=="pause"&&(y.holdTime=ve(y,d),Pt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Ut(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return X.get(this).animation.playbackRate}set playbackRate(d){const y=X.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=X.get(this);if(!d.timeline)return d.animation.playState;const y=ve(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Dt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=X.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=X.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof He&&(y.animationRange.start=qi(y.timeline,d,"start"),Wi(y),Ft(y))}get rangeEnd(){var d;return((d=X.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=X.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof He&&(y.animationRange.end=qi(y.timeline,d,"end"),Wi(y),Ft(y))}get replaceState(){return X.get(this).animation.pending}get pending(){const d=X.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=X.get(this);if(!d.timeline)return void d.animation.finish();const y=bn(d),S=Dt(d);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");Pt(d);const w=y<0?0:S;this.currentTime=rn(d,w);const k=ve(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-w/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Ut(d,!0,!0)}play(){const d=X.get(this);d.timeline?ts(d):d.animation.play()}pause(){const d=X.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Vn(d),d.pendingTask="pause",Yr(d.timeline,d.animation,ns.bind(d.proxy))):d.animation.pause()}reverse(){const d=X.get(this),y=bn(d),S=ve(d,this.currentTime),w=Dt(d)==1/0,k=y!=0&&(y<0||S>0||!w);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-bn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ts(d)}updatePlaybackRate(d){const y=X.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":Pt(y);break;case"finished":const w=ve(y,y.timeline.currentTime),k=w!==null?(w-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?w:w!=null&&k!=null?(w-k)/d:null,Pt(y),Ut(y,!1,!1),Ft(y);break;default:ts(y)}}persist(){X.get(this).animation.persist()}get id(){return X.get(this).animation.id}set id(d){X.get(this).animation.id=d}cancel(){const d=X.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,Pt(y),y.readyPromise.reject(Co()),Vn(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Co()),d.finishedPromise=new _n,d.animation.cancel()),d.startTime=null,d.holdTime=null,Xr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return X.get(this).animation.onfinish}set onfinish(d){X.get(this).animation.onfinish=d}get oncancel(){return X.get(this).animation.oncancel}set oncancel(d){X.get(this).animation.oncancel=d}get onremove(){return X.get(this).animation.onremove}set onremove(d){X.get(this).animation.onremove=d}get finished(){const d=X.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new _n),d.finishedPromise.promise):d.animation.finished}get ready(){const d=X.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new _n,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){X.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){X.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){X.get(this).animation.dispatchEvent(d)}}function al(h,d){const y=d.timeline;y instanceof He&&delete d.timeline;const S=sl.apply(this,[h,d]),w=new Xi(S,y);return y instanceof He&&(S.pause(),X.get(w).animationRange={start:qi(y,d.rangeStart,"start"),end:qi(y,d.rangeEnd,"end")},w.play()),w}function Io(h){for(let d=0;d<h.length;++d){let y=Ao.get(h[d]);y&&(h[d]=y)}return h}function cl(h){return Io(rl.apply(this,[h]))}function ll(h){return Io(il.apply(this,[h]))}const ke={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\(([^)]*)\)/},Tn=["block","inline","x","y"],ul=["nearest","root","self"],Ht=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(h,d,y){const S={sheetSrc:h,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&&(d?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:xo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),w=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!w)return;let k=[],B=[],L=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(B=this.extractMatches(h.block.contents,ke.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(h.block.contents,ke.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(D," 1s "+D),L=!0))})),L&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,B)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let w=[];if(d){const B=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE);for(const L of B){const D=this.split(L);let V={selector:h.selector,name:""};D.length==1?V.name=D[0]:D.length==2&&(Tn.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(h.block.contents,ke.SCROLL_TIMELINE_NAME);for(let L=0;L<B.length;L++)if(L<w.length)w[L].name=B[L];else{let D={selector:h.selector,name:B[L]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_AXIS);if(k=B.filter((L=>Tn.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(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),w=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const D=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let Y={selector:h.selector,name:"",inset:null};H.length==1?Y.name=H[0]:H.length==2&&(Tn.includes(H[0])?(Y.axis=H[0],Y.name=H[1]):(Y.axis=H[1],Y.name=H[0])),k.push(Y)}}if(y){const D=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_NAME);for(let V=0;V<D.length;V++)if(V<k.length)k[V].name=D[V];else{let H={selector:h.selector,name:D[V],inset:null};k.push(H)}}let B=[],L=[];if(w&&(B=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_AXIS);if(L=D.filter((V=>Tn.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(h){return h.split(" ").filter((d=>{return y=d,ke.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,ke.ANIMATION_TIME_RANGE));const w=Math.max(d.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=ke.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.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(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=ke.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Tn.includes(w)?S.axis=w:ul.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(h){const d=ke.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Tn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){ke.IDENTIFIER.lastIndex=h.index;const d=ke.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(D){return Gi.some((V=>D.startsWith(V)))}const S=h.block.contents,w=(function(D){let V=0,H=-1,Y=-1;const Z=[];for(let pe=0;pe<D.length;pe++)D[pe]=="{"?V++:D[pe]=="}"&&V--,V==1&&D[pe]!="{"&&D[pe]!="}"&&H==-1&&(H=pe),V==2&&D[pe]=="{"&&(Y=pe,Z.push({start:H,end:Y}),H=Y=-1);return Z})(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((Y=>{const Z=Y.split(" ").map((Te=>Te.trim())).filter((Te=>Te!="")).join(" "),pe=k.size;k.set(pe,Z),H.push(`${pe}%`),y(Z)&&(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?(h.block.contents=L.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const w=S.index-d;S.index=h+y.length+w}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){ke.WHITE_SPACE.lastIndex=h.index;const d=ke.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function hl(h,d,y,S,w,k){const B=Hr(d),L=qr(d,y);return To(Qr(h,B,L,S,w),k,Qr("cover",B,L,S,w),y)}function fl(h,d,y){const S=Ht.getAnimationTimelineOptions(d,y);if(!S)return null;const w=S["animation-timeline"];if(!w)return null;let k=Ht.getScrollTimelineOptions(w,y)||Ht.getViewTimelineOptions(w,y);return k?(k.subject&&(function(B,L){const D=Kr(L.subject),V=L.axis||L.axis;function H(Z,pe){let Te=null;for(const[Ke,bt]of Z)if(Ke==100*pe.offset){if(bt=="from")Te=0;else if(bt=="to")Te=100;else{const ct=bt.split(" ");Te=ct.length==1?parseFloat(ct[0]):100*hl(ct[0],D,L.subject,V,L.inset,CSS.percent(parseFloat(ct[1])))}break}return Te}const Y=Ht.keyframeNamesSelectors.get(B.animationName);if(Y&&Y.size){const Z=[];B.effect.getKeyframes().forEach((Te=>{const Ke=H(Y,Te);Ke!==null&&Ke>=0&&Ke<=100&&(Te.offset=Ke/100,Z.push(Te))}));const pe=Z.sort(((Te,Ke)=>Te.offset<Ke.offset?-1:Te.affset>Ke.offset?1:0));B.effect.setKeyframes(pe)}})(h,k),{timeline:k.source?new He(k):new xn(k),animOptions:S}):null}function dl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let w=Ht.transpileStyleSheet(S.innerHTML,!0);w=Ht.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=Ht.transpileStyleSheet(k,!0);if(B=Ht.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&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=fl(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof Xi)y.timeline=S.timeline;else{const w=new Xi(y,S.timeline,S.animOptions);y.pause(),w.play()}}))}))}(function(){if(!dl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:He}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:xn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:al}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Xi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:cl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:ll}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Oh{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 le;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(le||(le={}));class $c{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,M,g,v,b;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(le.open,_),this.handleErrorEvent=_=>this.handleEvent(le.error,_),this.handleCloseEvent=_=>this.handleEvent(le.close,_),this.handleMessageEvent=_=>this.handleEvent(le.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:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(M=n?.listeners)===null||M===void 0?void 0:M.retry)!==null&&g!==void 0?g:[]],reconnect:[...(b=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&b!==void 0?b:[]]}},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(le.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(le.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(le.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(le.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(le.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(le.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(le.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(le.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 le.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case le.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(le.reconnect,{detail:n});this.dispatchEvent(le.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case le.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(le.retry,{detail:n});this.handleEvent(le.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 zh{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(le.open,e,t),this}onClose(e,t){return this.addListener(le.close,e,t),this}onError(e,t){return this.addListener(le.error,e,t),this}onMessage(e,t){return this.addListener(le.message,e,t),this}onRetry(e,t){return this.addListener(le.retry,e,t),this}onReconnect(e,t){return this.addListener(le.reconnect,e,t),this}build(){return new $c(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,M,g,v,b,_,C,T,P,E,O;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:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(M=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&M!==void 0?M:[],retry:(b=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&b!==void 0?b:[],reconnect:(T=(C=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||C===void 0?void 0:C.reconnect)!==null&&T!==void 0?T:[],[e]:[...(O=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const Ih=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Oh,Websocket:$c,WebsocketBuilder:zh,get WebsocketEvent(){return le}},Symbol.toStringTag,{value:"Module"})),fo=0,Wc=1,Hc=2,Hs=2,Ts=1.25,Ta=1,si=32,jr=65535,Bh=Math.pow(2,-24),Ms=Symbol("SKIP_GENERATION");function Nh(r){return r.index?r.index.count:r.attributes.position.count}function Fn(r){return Nh(r)/3}function Uh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Dh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Uh(t,n);r.setIndex(new R.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function qc(r,e){const t=Fn(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Ma(r,e){if(!r.groups||!r.groups.length)return qc(r,e);const t=[],n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=[];for(const l of r.groups){const u=l.start/3,f=(l.start+l.count)/3;u<s&&f>i&&(a.push({pos:Math.max(i,u),isStart:!0}),a.push({pos:Math.min(s,f),isStart:!1}))}a.sort((l,u)=>l.pos!==u.pos?l.pos-u.pos:l.type==="end"?-1:1);let o=0,c=null;for(const l of a){const u=l.pos;o!==0&&u!==c&&t.push({offset:c,count:u-c}),o+=l.isStart?1:-1,c=u}return t}function Cs(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,M=-1/0,g=-1/0;const v=r.offset||0;for(let b=(e-v)*6,_=(e+t-v)*6;b<_;b+=6){const C=r[b+0],T=r[b+1],P=C-T,E=C+T;P<s&&(s=P),E>c&&(c=E),C<f&&(f=C),C>x&&(x=C);const O=r[b+2],I=r[b+3],A=O-I,N=O+I;A<a&&(a=A),N>l&&(l=N),O<p&&(p=O),O>M&&(M=O);const z=r[b+4],U=r[b+5],F=z-U,J=z+U;F<o&&(o=F),J>u&&(u=J),z<m&&(m=z),z>g&&(g=z)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=M,i[5]=g}function Ca(r,e,t=null,n=null,i=null){const s=r.attributes.position,a=r.index?r.index.array:null,o=s.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const c=s.array,l=s.offset||0;let u=3;s.isInterleavedBufferAttribute&&(u=s.data.stride);const f=["getX","getY","getZ"],p=i.offset;for(let m=e,x=e+t;m<x;m++){const g=(n?n[m]:m)*3,v=(m-p)*6;let b=g+0,_=g+1,C=g+2;a&&(b=a[b],_=a[_],C=a[C]),o||(b=b*u+l,_=_*u+l,C=C*u+l);for(let T=0;T<3;T++){let P,E,O;o?(P=s[f[T]](b),E=s[f[T]](_),O=s[f[T]](C)):(P=c[b+T],E=c[_+T],O=c[C+T]);let I=P;E<I&&(I=E),O<I&&(I=O);let A=P;E>A&&(A=E),O>A&&(A=O);const N=(A-I)/2,z=T*2;i[v+z+0]=I+N,i[v+z+1]=N+(Math.abs(I)+N)*Bh}}return i}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 wa(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 Pa(r,e){e.set(r)}function Ea(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 or(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 $n(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)}const Lt=32,Fh=(r,e)=>r.candidate-e.candidate,Yt=new Array(Lt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ar=new Float32Array(6);function Lh(r,e,t,n,i,s){let a=-1,o=0;if(s===fo)a=wa(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Wc)a=wa(r),a!==-1&&(o=Vh(t,n,i,a));else if(s===Hc){const c=$n(r);let l=Ts*i;const u=t.offset||0,f=(n-u)*6,p=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],v=(e[m+3]-x)/Lt;if(i<Lt/4){const b=[...Yt];b.length=i;let _=0;for(let T=f;T<p;T+=6,_++){const P=b[_];P.candidate=t[T+2*m],P.count=0;const{bounds:E,leftCacheBounds:O,rightCacheBounds:I}=P;for(let A=0;A<3;A++)I[A]=1/0,I[A+3]=-1/0,O[A]=1/0,O[A+3]=-1/0,E[A]=1/0,E[A+3]=-1/0;or(T,t,E)}b.sort(Fh);let C=i;for(let T=0;T<C;T++){const P=b[T];for(;T+1<C&&b[T+1].candidate===P.candidate;)b.splice(T+1,1),C--}for(let T=f;T<p;T+=6){const P=t[T+2*m];for(let E=0;E<C;E++){const O=b[E];P>=O.candidate?or(T,t,O.rightCacheBounds):(or(T,t,O.leftCacheBounds),O.count++)}}for(let T=0;T<C;T++){const P=b[T],E=P.count,O=i-P.count,I=P.leftCacheBounds,A=P.rightCacheBounds;let N=0;E!==0&&(N=$n(I)/c);let z=0;O!==0&&(z=$n(A)/c);const U=Ta+Ts*(N*E+z*O);U<l&&(a=m,l=U,o=P.candidate)}}else{for(let C=0;C<Lt;C++){const T=Yt[C];T.count=0,T.candidate=x+v+C*v;const P=T.bounds;for(let E=0;E<3;E++)P[E]=1/0,P[E+3]=-1/0}for(let C=f;C<p;C+=6){let E=~~((t[C+2*m]-x)/v);E>=Lt&&(E=Lt-1);const O=Yt[E];O.count++,or(C,t,O.bounds)}const b=Yt[Lt-1];Pa(b.bounds,b.rightCacheBounds);for(let C=Lt-2;C>=0;C--){const T=Yt[C],P=Yt[C+1];Ea(T.bounds,P.rightCacheBounds,T.rightCacheBounds)}let _=0;for(let C=0;C<Lt-1;C++){const T=Yt[C],P=T.count,E=T.bounds,I=Yt[C+1].rightCacheBounds;P!==0&&(_===0?Pa(E,ar):Ea(E,ar,ar)),_+=P;let A=0,N=0;_!==0&&(A=$n(ar)/c);const z=i-_;z!==0&&(N=$n(I)/c);const U=Ta+Ts*(A*_+N*z);U<l&&(a=m,l=U,o=T.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Vh(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 ws{constructor(){this.boundingData=new Float32Array(6)}}function Jh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let f=0;f<3;f++){let p=e[a*3+f];e[a*3+f]=e[o*3+f],e[o*3+f]=p}for(let f=0;f<6;f++){const p=a-u,m=o-u,x=t[p*6+f];t[p*6+f]=t[m*6+f],t[m*6+f]=x}a++,o--}else return a}}function jh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){let f=r[a];r[a]=r[o],r[o]=f;for(let p=0;p<6;p++){const m=a-u,x=o-u,M=t[m*6+p];t[m*6+p]=t[x*6+p],t[x*6+p]=M}a++,o--}else return a}}function et(r,e){return e[r+15]===65535}function rt(r,e){return e[r+6]}function ht(r,e){return e[r+14]}function ft(r){return r+8}function dt(r,e){return e[r+6]}function Xc(r,e){return e[r+7]}let Yc,ni,Er,Zc;const Gh=Math.pow(2,32);function qs(r){return"count"in r?1:1+qs(r.left)+qs(r.right)}function $h(r,e,t){return Yc=new Float32Array(t),ni=new Uint32Array(t),Er=new Uint16Array(t),Zc=new Uint8Array(t),Xs(r,e)}function Xs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)Yc[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;Zc.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=si){const l=o/2;et(l,Er)||(ni[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ni[t+6]=a,Er[n+14]=o,Er[n+15]=jr,r+si}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=Xs(r+si,a),l/4>Gh)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ni[t+6]=l/4,l=Xs(l,o),ni[t+7]=c,l}}function Wh(r,e,t){const i=(r.index?r.index.count:r.attributes.position.count)/3>2**16,s=t.reduce((u,f)=>u+f.count,0),a=i?4:2,o=e?new SharedArrayBuffer(s*a):new ArrayBuffer(s*a),c=i?new Uint32Array(o):new Uint16Array(o);let l=0;for(let u=0;u<t.length;u++){const{offset:f,count:p}=t[u];for(let m=0;m<p;m++)c[l+m]=f+m;l+=p}return c}function Hh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,f=r._indirectBuffer,p=r.geometry,m=p.index?p.index.array:null,x=u?jh:Jh,M=Fn(p),g=new Float32Array(6);let v=!1;const b=new ws;return Cs(e,t,n,b.boundingData,g),C(b,t,n,g),b;function _(T){l&&l(T/M)}function C(T,P,E,O=null,I=0){if(!v&&I>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p))),E<=o||I>=s)return _(P+E),T.offset=P,T.count=E,T;const A=Lh(T.boundingData,O,e,P,E,c);if(A.axis===-1)return _(P+E),T.offset=P,T.count=E,T;const N=x(f,m,e,P,E,A);if(N===P||N===P+E)_(P+E),T.offset=P,T.count=E;else{T.splitAxis=A.axis;const z=new ws,U=P,F=N-P;T.left=z,Cs(e,U,F,z.boundingData,g),C(z,U,F,g,I+1);const J=new ws,j=N,q=E-F;T.right=J,Cs(e,j,q,J.boundingData,g),C(J,j,q,g,I+1)}return T}}function qh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.geometry;let i,s;if(e.indirect){const a=Ma(n,e.range),o=Wh(n,e.useSharedArrayBuffer,a);r._indirectBuffer=o,i=Ca(n,0,o.length,o),s=[{offset:0,count:o.length}]}else{Dh(n,e);const a=qc(n,e.range)[0];i=Ca(n,a.offset,a.count),s=Ma(n,e.range)}r._roots=s.map(a=>{const o=Hh(r,i,a.offset,a.count,e),c=qs(o),l=new t(si*c);return $h(0,o,l),l})}class Wt{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}}Wt.prototype.setFromBox=(function(){const r=new R.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 u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const Xh=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,b;g!==0?v=(f*p-x*m)/g:v=0,b=(f+v*p)/m,a.x=v,a.y=b}})(),po=(function(){const r=new R.Vector2,e=new R.Vector3,t=new R.Vector3;return function(i,s,a,o){Xh(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 u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),Yh=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Plane,n=new R.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const M=a.getPlane(t);if(Math.abs(M.distanceToPoint(c))<=o){const v=M.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),Zh=["x","y","z"],Jt=1e-15,ka=Jt*Jt;function lt(r){return Math.abs(r)<Jt}class mt extends R.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new R.Vector3),this.satBounds=new Array(4).fill().map(()=>new Wt),this.points=[this.a,this.b,this.c],this.plane=new R.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new R.Line3,this.needsUpdate=!0}intersectsSphere(e){return Yh(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],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const M=l.length(),g=f.length(),v=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,M<Jt?g<Jt||v<Jt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<Jt?v<Jt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<Jt&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}mt.prototype.closestPointToSegment=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),po(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();mt.prototype.intersectsTriangle=(function(){const r=new mt,e=new Wt,t=new Wt,n=new R.Vector3,i=new R.Vector3,s=new R.Vector3,a=new R.Vector3,o=new R.Line3,c=new R.Line3,l=new R.Vector3,u=new R.Vector2,f=new R.Vector2;function p(_,C,T,P){const E=n;!_.isDegenerateIntoPoint&&!_.isDegenerateIntoSegment?E.copy(_.plane.normal):E.copy(C.plane.normal);const O=_.satBounds,I=_.satAxes;for(let z=1;z<4;z++){const U=O[z],F=I[z];if(e.setFromPoints(F,C.points),U.isSeparated(e)||(a.copy(E).cross(F),e.setFromPoints(a,_.points),t.setFromPoints(a,C.points),e.isSeparated(t)))return!1}const A=C.satBounds,N=C.satAxes;for(let z=1;z<4;z++){const U=A[z],F=N[z];if(e.setFromPoints(F,_.points),U.isSeparated(e)||(a.crossVectors(E,F),e.setFromPoints(a,_.points),t.setFromPoints(a,C.points),e.isSeparated(t)))return!1}return T&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),T.start.set(0,0,0),T.end.set(0,0,0)),!0}function m(_,C,T,P,E,O,I,A,N,z,U){let F=I/(I-A);z.x=P+(E-P)*F,U.start.subVectors(C,_).multiplyScalar(F).add(_),F=I/(I-N),z.y=P+(O-P)*F,U.end.subVectors(T,_).multiplyScalar(F).add(_)}function x(_,C,T,P,E,O,I,A,N,z,U){if(E>0)m(_.c,_.a,_.b,P,C,T,N,I,A,z,U);else if(O>0)m(_.b,_.a,_.c,T,C,P,A,I,N,z,U);else if(A*N>0||I!=0)m(_.a,_.b,_.c,C,T,P,I,A,N,z,U);else if(A!=0)m(_.b,_.a,_.c,T,C,P,A,I,N,z,U);else if(N!=0)m(_.c,_.a,_.b,P,C,T,N,I,A,z,U);else return!0;return!1}function M(_,C,T,P){const E=C.degenerateSegment,O=_.plane.distanceToPoint(E.start),I=_.plane.distanceToPoint(E.end);return lt(O)?lt(I)?p(_,C,T,P):(T&&(T.start.copy(E.start),T.end.copy(E.start)),_.containsPoint(E.start)):lt(I)?(T&&(T.start.copy(E.end),T.end.copy(E.end)),_.containsPoint(E.end)):_.plane.intersectLine(E,n)!=null?(T&&(T.start.copy(n),T.end.copy(n)),_.containsPoint(n)):!1}function g(_,C,T){const P=C.a;return lt(_.plane.distanceToPoint(P))&&_.containsPoint(P)?(T&&(T.start.copy(P),T.end.copy(P)),!0):!1}function v(_,C,T){const P=_.degenerateSegment,E=C.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<ka?(T&&(T.start.copy(E),T.end.copy(E)),!0):!1}function b(_,C,T,P){if(_.isDegenerateIntoSegment)if(C.isDegenerateIntoSegment){const E=_.degenerateSegment,O=C.degenerateSegment,I=i,A=s;E.delta(I),O.delta(A);const N=n.subVectors(O.start,E.start),z=I.x*A.y-I.y*A.x;if(lt(z))return!1;const U=(N.x*A.y-N.y*A.x)/z,F=-(I.x*N.y-I.y*N.x)/z;if(U<0||U>1||F<0||F>1)return!1;const J=E.start.z+I.z*U,j=O.start.z+A.z*F;return lt(J-j)?(T&&(T.start.copy(E.start).addScaledVector(I,U),T.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return C.isDegenerateIntoPoint?v(_,C,T):M(C,_,T,P);else{if(_.isDegenerateIntoPoint)return C.isDegenerateIntoPoint?C.a.distanceToSquared(_.a)<ka?(T&&(T.start.copy(_.a),T.end.copy(_.a)),!0):!1:C.isDegenerateIntoSegment?v(C,_,T):g(C,_,T);if(C.isDegenerateIntoPoint)return g(_,C,T);if(C.isDegenerateIntoSegment)return M(_,C,T,P)}}return function(C,T=null,P=!1){this.needsUpdate&&this.update(),C.isExtendedTriangle?C.needsUpdate&&C.update():(r.copy(C),r.update(),C=r);const E=b(this,C,T,P);if(E!==void 0)return E;const O=this.plane,I=C.plane;let A=I.distanceToPoint(this.a),N=I.distanceToPoint(this.b),z=I.distanceToPoint(this.c);lt(A)&&(A=0),lt(N)&&(N=0),lt(z)&&(z=0);const U=A*N,F=A*z;if(U>0&&F>0)return!1;let J=O.distanceToPoint(C.a),j=O.distanceToPoint(C.b),q=O.distanceToPoint(C.c);lt(J)&&(J=0),lt(j)&&(j=0),lt(q)&&(q=0);const G=J*j,ne=J*q;if(G>0&&ne>0)return!1;i.copy(O.normal),s.copy(I.normal);const ie=i.cross(s);let he=0,se=Math.abs(ie.x);const ge=Math.abs(ie.y);ge>se&&(se=ge,he=1),Math.abs(ie.z)>se&&(he=2);const oe=Zh[he],fe=this.a[oe],ae=this.b[oe],je=this.c[oe],Ue=C.a[oe],De=C.b[oe],Ge=C.c[oe];if(x(this,fe,ae,je,U,F,A,N,z,u,o))return p(this,C,T,P);if(x(C,Ue,De,Ge,G,ne,J,j,q,f,c))return p(this,C,T,P);if(u.y<u.x){const xe=u.y;u.y=u.x,u.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(f.y<f.x){const xe=f.y;f.y=f.x,f.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<f.x||f.y<u.x?!1:(T&&(f.x>u.x?T.start.copy(c.start):T.start.copy(o.start),f.y<u.y?T.end.copy(c.end):T.end.copy(o.end)),!0)}})();mt.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();mt.prototype.distanceToTriangle=(function(){const r=new R.Vector3,e=new R.Vector3,t=["a","b","c"],n=new R.Line3,i=new R.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 u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const M=this[m];a.closestPointToPoint(M,r),p=M.distanceToSquared(r),p<u&&(u=p,o&&o.copy(M),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const M=t[x],g=t[(x+1)%3];i.set(a[M],a[g]),po(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();class Je{constructor(e,t,n){this.isOrientedBox=!0,this.min=new R.Vector3,this.max=new R.Vector3,this.matrix=new R.Matrix4,this.invMatrix=new R.Matrix4,this.points=new Array(8).fill().map(()=>new R.Vector3),this.satAxes=new Array(3).fill().map(()=>new R.Vector3),this.satBounds=new Array(3).fill().map(()=>new Wt),this.alignedSatBounds=new Array(3).fill().map(()=>new Wt),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}}Je.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 u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,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}})();Je.prototype.intersectsBox=(function(){const r=new Wt;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],u=s[c];if(r.setFromBox(l,t),u.isSeparated(r))return!1}return!0}})();Je.prototype.intersectsTriangle=(function(){const r=new mt,e=new Array(3),t=new Wt,n=new Wt,i=new R.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 p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const M=u[x];if(i.crossVectors(m,M),t.setFromPoints(i,e),n.setFromPoints(i,f),t.isSeparated(n))return!1}}return!0}})();Je.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}})();Je.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();Je.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new R.Line3),t=new Array(12).fill().map(()=>new R.Line3),n=new R.Vector3,i=new R.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 u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const b=v.distanceToSquared(i);if(b<x&&(x=b,c&&c.copy(v),l&&l.copy(i),b<u))return Math.sqrt(b)}let M=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){const _=(g+1)%3,C=(g+2)%3,T=v<<_|b<<C,P=1<<g|v<<_|b<<C,E=m[T],O=m[P];e[M].set(E,O);const A=r[g],N=r[_],z=r[C],U=t[M],F=U.start,J=U.end;F[A]=f[A],F[N]=v?f[N]:p[N],F[z]=b?f[z]:p[N],J[A]=p[A],J[N]=v?f[N]:p[N],J[z]=b?f[z]:p[N],M++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=b?p.z:f.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<x&&(x=_,c&&c.copy(n),l&&l.copy(i),_<u))return Math.sqrt(_)}for(let g=0;g<12;g++){const v=e[g];for(let b=0;b<12;b++){const _=t[b];po(v,_,n,i);const C=n.distanceToSquared(i);if(C<x&&(x=C,c&&c.copy(n),l&&l.copy(i),C<u))return Math.sqrt(C)}}return Math.sqrt(x)}})();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 Kh extends mo{constructor(){super(()=>new mt)}}const pt=new Kh;class Qh{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 me=new Qh;let en,zn;const Cn=[],cr=new mo(()=>new R.Box3);function ef(r,e,t,n,i,s){en=cr.getPrimitive(),zn=cr.getPrimitive(),Cn.push(en,zn),me.setBuffer(r._roots[e]);const a=Ys(0,r.geometry,t,n,i,s);me.clearBuffer(),cr.releasePrimitive(en),cr.releasePrimitive(zn),Cn.pop(),Cn.pop();const o=Cn.length;return o>0&&(zn=Cn[o-1],en=Cn[o-2]),a}function Ys(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=me;let u=r*2;if(et(u,c)){const p=rt(r,l),m=ht(u,c);return Se(r,o,en),n(p,m,!1,a,s+r,en)}else{let A=function(z){const{uint16Array:U,uint32Array:F}=me;let J=z*2;for(;!et(J,U);)z=ft(z),J=z*2;return rt(z,F)},N=function(z){const{uint16Array:U,uint32Array:F}=me;let J=z*2;for(;!et(J,U);)z=dt(z,F),J=z*2;return rt(z,F)+ht(J,U)};const p=ft(r),m=dt(r,l);let x=p,M=m,g,v,b,_;if(i&&(b=en,_=zn,Se(x,o,b),Se(M,o,_),g=i(b),v=i(_),v<g)){x=m,M=p;const z=g;g=v,v=z,b=_}b||(b=en,Se(x,o,b));const C=et(x*2,c),T=t(b,C,g,a+1,s+x);let P;if(T===Hs){const z=A(x),F=N(x)-z;P=n(z,F,!0,a+1,s+x,b)}else P=T&&Ys(x,e,t,n,i,s,a+1);if(P)return!0;_=zn,Se(M,o,_);const E=et(M*2,c),O=t(_,E,v,a+1,s+M);let I;if(O===Hs){const z=A(M),F=N(M)-z;I=n(z,F,!0,a+1,s+M,_)}else I=O&&Ys(M,e,t,n,i,s,a+1);return!!I}}const Wn=new R.Vector3,Ps=new R.Vector3;function tf(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:u=>(Wn.copy(e).clamp(u.min,u.max),Wn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Wn);const p=e.distanceToSquared(Wn);return p<o&&(Ps.copy(Wn),o=p,c=f),p<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 lr=parseInt(R.REVISION)>=169,nf=parseInt(R.REVISION)<=161,an=new R.Vector3,cn=new R.Vector3,ln=new R.Vector3,ur=new R.Vector2,hr=new R.Vector2,fr=new R.Vector2,Ra=new R.Vector3,Aa=new R.Vector3,Oa=new R.Vector3,Hn=new R.Vector3;function rf(r,e,t,n,i,s,a,o){let c;if(s===R.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==R.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function za(r,e,t,n,i,s,a,o,c,l,u){an.fromBufferAttribute(e,s),cn.fromBufferAttribute(e,a),ln.fromBufferAttribute(e,o);const f=rf(r,an,cn,ln,Hn,c,l,u);if(f){if(n){ur.fromBufferAttribute(n,s),hr.fromBufferAttribute(n,a),fr.fromBufferAttribute(n,o),f.uv=new R.Vector2;const m=R.Triangle.getInterpolation(Hn,an,cn,ln,ur,hr,fr,f.uv);lr||(f.uv=m)}if(i){ur.fromBufferAttribute(i,s),hr.fromBufferAttribute(i,a),fr.fromBufferAttribute(i,o),f.uv1=new R.Vector2;const m=R.Triangle.getInterpolation(Hn,an,cn,ln,ur,hr,fr,f.uv1);lr||(f.uv1=m),nf&&(f.uv2=f.uv1)}if(t){Ra.fromBufferAttribute(t,s),Aa.fromBufferAttribute(t,a),Oa.fromBufferAttribute(t,o),f.normal=new R.Vector3;const m=R.Triangle.getInterpolation(Hn,an,cn,ln,Ra,Aa,Oa,f.normal);f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1),lr||(f.normal=m)}const p={a:s,b:a,c:o,normal:new R.Vector3,materialIndex:0};if(R.Triangle.getNormal(an,cn,ln,p.normal),f.face=p,f.faceIndex=s,lr){const m=new R.Vector3;R.Triangle.getBarycoord(Hn,an,cn,ln,m),f.barycoord=m}}return f}function Ia(r){return r&&r.isMaterial?r.side:r}function Gr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:f,groups:p}=r;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:m,normal:x,uv:M,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let b=0,_=p.length;b<_;b++){const{start:C,count:T,materialIndex:P}=p[b];if(v>=C&&v<C+T){const E=Ia(e[P]),O=za(t,m,x,M,g,c,l,u,E,s,a);if(O)if(O.faceIndex=n,O.face.materialIndex=P,i)i.push(O);else return O}}}else{const v=Ia(e),b=za(t,m,x,M,g,c,l,u,v,s,a);if(b)if(b.faceIndex=n,b.face.materialIndex=0,i)i.push(b);else return b}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 sf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Gr(c,e,t,u,s,a,o)}function of(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Gr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function af(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function cf(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 u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const M=p*2;if(o[M+15]===jr){const v=a[p+6],b=o[M+14];let _=1/0,C=1/0,T=1/0,P=-1/0,E=-1/0,O=-1/0;for(let I=3*v,A=3*(v+b);I<A;I++){let N=n[I];const z=i.getX(N),U=i.getY(N),F=i.getZ(N);z<_&&(_=z),z>P&&(P=z),U<C&&(C=U),U>E&&(E=U),F<T&&(T=F),F>O&&(O=F)}return c[p+0]!==_||c[p+1]!==C||c[p+2]!==T||c[p+3]!==P||c[p+4]!==E||c[p+5]!==O?(c[p+0]=_,c[p+1]=C,c[p+2]=T,c[p+3]=P,c[p+4]=E,c[p+5]=O,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,C=b+m;let T=x,P=!1,E=!1;e?T||(P=e.has(_),E=e.has(C),T=!P&&!E):(P=!0,E=!0);const O=T||P,I=T||E;let A=!1;O&&(A=f(v,m,T));let N=!1;I&&(N=f(b,m,T));const z=A||N;if(z)for(let U=0;U<3;U++){const F=v+U,J=b+U,j=c[F],q=c[F+3],G=c[J],ne=c[J+3];c[p+U]=j<G?j:G,c[p+U+3]=q>ne?q:ne}return z}}}function tn(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,M=t.origin.y,g=t.origin.z;let v=e[r],b=e[r+3],_=e[r+1],C=e[r+3+1],T=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(b-x)*f):(s=(b-x)*f,a=(v-x)*f),p>=0?(o=(_-M)*p,c=(C-M)*p):(o=(C-M)*p,c=(_-M)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(T-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(T-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function lf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Gr(c,e,t,p,s,a,o)}}function uf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Gr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function hf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function ff(r,e,t,n,i,s,a){me.setBuffer(r._roots[e]),Zs(0,r,t,n,i,s,a),me.clearBuffer()}function Zs(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=me,u=r*2;if(et(u,c)){const p=rt(r,l),m=ht(u,c);sf(e,t,n,p,m,i,s,a)}else{const p=ft(r);tn(p,o,n,s,a)&&Zs(p,e,t,n,i,s,a);const m=dt(r,l);tn(m,o,n,s,a)&&Zs(m,e,t,n,i,s,a)}}const df=["x","y","z"];function pf(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const a=Ks(0,r,t,n,i,s);return me.clearBuffer(),a}function Ks(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=me;let l=r*2;if(et(l,o)){const f=rt(r,c),p=ht(l,o);return of(e,t,n,f,p,i,s)}else{const f=Xc(r,c),p=df[f],x=n.direction[p]>=0;let M,g;x?(M=ft(r),g=dt(r,c)):(M=dt(r,c),g=ft(r));const b=tn(M,a,n,i,s)?Ks(M,e,t,n,i,s):null;if(b){const T=b.point[p];if(x?T<=a[g+f]:T>=a[g+f+3])return b}const C=tn(g,a,n,i,s)?Ks(g,e,t,n,i,s):null;return b&&C?b.distance<=C.distance?b:C:b||C||null}}const dr=new R.Box3,wn=new mt,Pn=new mt,qn=new R.Matrix4,Ba=new Je,pr=new Je;function mf(r,e,t,n){me.setBuffer(r._roots[e]);const i=Qs(0,r,t,n);return me.clearBuffer(),i}function Qs(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=me;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ba.set(t.boundingBox.min,t.boundingBox.max,n),i=Ba),et(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,M=rt(r,o),g=ht(c,a);if(qn.copy(n).invert(),t.boundsTree)return Se(r,s,pr),pr.matrix.copy(qn),pr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>pr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=M*3,C=(g+M)*3;_<C;_+=3)if(we(Pn,_,f,p),Pn.needsUpdate=!0,b.intersectsTriangle(Pn))return!0;return!1}});{const v=Fn(t);for(let b=M*3,_=(g+M)*3;b<_;b+=3){we(wn,b,f,p),wn.a.applyMatrix4(qn),wn.b.applyMatrix4(qn),wn.c.applyMatrix4(qn),wn.needsUpdate=!0;for(let C=0,T=v*3;C<T;C+=3)if(we(Pn,C,m,x),Pn.needsUpdate=!0,wn.intersectsTriangle(Pn))return!0}}}else{const u=r+8,f=o[r+6];return Se(u,s,dr),!!(i.intersectsBox(dr)&&Qs(u,e,t,n,i)||(Se(f,s,dr),i.intersectsBox(dr)&&Qs(f,e,t,n,i)))}}const mr=new R.Matrix4,Es=new Je,Xn=new Je,yf=new R.Vector3,gf=new R.Vector3,vf=new R.Vector3,Sf=new R.Vector3;function xf(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,u=e.attributes.position,f=e.index,p=pt.getPrimitive(),m=pt.getPrimitive();let x=yf,M=gf,g=null,v=null;i&&(g=vf,v=Sf);let b=1/0,_=null,C=null;return mr.copy(t).invert(),Xn.matrix.copy(mr),r.shapecast({boundsTraverseOrder:T=>Es.distanceToBox(T),intersectsBounds:(T,P,E)=>E<b&&E<a?(P&&(Xn.min.copy(T.min),Xn.max.copy(T.max),Xn.needsUpdate=!0),!0):!1,intersectsRange:(T,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:O=>Xn.distanceToBox(O),intersectsBounds:(O,I,A)=>A<b&&A<a,intersectsRange:(O,I)=>{for(let A=O,N=O+I;A<N;A++){we(m,3*A,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let z=T,U=T+P;z<U;z++){we(p,3*z,l,c),p.needsUpdate=!0;const F=p.distanceToTriangle(m,x,g);if(F<b&&(M.copy(x),v&&v.copy(g),b=F,_=z,C=A),F<s)return!0}}}});{const E=Fn(e);for(let O=0,I=E;O<I;O++){we(m,3*O,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=T,N=T+P;A<N;A++){we(p,3*A,l,c),p.needsUpdate=!0;const z=p.distanceToTriangle(m,x,g);if(z<b&&(M.copy(x),v&&v.copy(g),b=z,_=A,C=O),z<s)return!0}}}}}),pt.releasePrimitive(p),pt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(M):n.point=M.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(mr),M.applyMatrix4(mr),i.distance=M.sub(i.point).length(),i.faceIndex=C),n)}function _f(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 u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const M=p*2;if(o[M+15]===jr){const v=a[p+6],b=o[M+14];let _=1/0,C=1/0,T=1/0,P=-1/0,E=-1/0,O=-1/0;for(let I=v,A=v+b;I<A;I++){const N=3*r.resolveTriangleIndex(I);for(let z=0;z<3;z++){let U=N+z;U=n?n[U]:U;const F=i.getX(U),J=i.getY(U),j=i.getZ(U);F<_&&(_=F),F>P&&(P=F),J<C&&(C=J),J>E&&(E=J),j<T&&(T=j),j>O&&(O=j)}}return c[p+0]!==_||c[p+1]!==C||c[p+2]!==T||c[p+3]!==P||c[p+4]!==E||c[p+5]!==O?(c[p+0]=_,c[p+1]=C,c[p+2]=T,c[p+3]=P,c[p+4]=E,c[p+5]=O,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,C=b+m;let T=x,P=!1,E=!1;e?T||(P=e.has(_),E=e.has(C),T=!P&&!E):(P=!0,E=!0);const O=T||P,I=T||E;let A=!1;O&&(A=f(v,m,T));let N=!1;I&&(N=f(b,m,T));const z=A||N;if(z)for(let U=0;U<3;U++){const F=v+U,J=b+U,j=c[F],q=c[F+3],G=c[J],ne=c[J+3];c[p+U]=j<G?j:G,c[p+U+3]=q>ne?q:ne}return z}}}function bf(r,e,t,n,i,s,a){me.setBuffer(r._roots[e]),eo(0,r,t,n,i,s,a),me.clearBuffer()}function eo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=me,u=r*2;if(et(u,c)){const p=rt(r,l),m=ht(u,c);lf(e,t,n,p,m,i,s,a)}else{const p=ft(r);tn(p,o,n,s,a)&&eo(p,e,t,n,i,s,a);const m=dt(r,l);tn(m,o,n,s,a)&&eo(m,e,t,n,i,s,a)}}const Tf=["x","y","z"];function Mf(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const a=to(0,r,t,n,i,s);return me.clearBuffer(),a}function to(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=me;let l=r*2;if(et(l,o)){const f=rt(r,c),p=ht(l,o);return uf(e,t,n,f,p,i,s)}else{const f=Xc(r,c),p=Tf[f],x=n.direction[p]>=0;let M,g;x?(M=ft(r),g=dt(r,c)):(M=dt(r,c),g=ft(r));const b=tn(M,a,n,i,s)?to(M,e,t,n,i,s):null;if(b){const T=b.point[p];if(x?T<=a[g+f]:T>=a[g+f+3])return b}const C=tn(g,a,n,i,s)?to(g,e,t,n,i,s):null;return b&&C?b.distance<=C.distance?b:C:b||C||null}}const yr=new R.Box3,En=new mt,kn=new mt,Yn=new R.Matrix4,Na=new Je,gr=new Je;function Cf(r,e,t,n){me.setBuffer(r._roots[e]);const i=no(0,r,t,n);return me.clearBuffer(),i}function no(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=me;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Na.set(t.boundingBox.min,t.boundingBox.max,n),i=Na),et(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,M=rt(r,o),g=ht(c,a);if(Yn.copy(n).invert(),t.boundsTree)return Se(r,s,gr),gr.matrix.copy(Yn),gr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>gr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=M,C=g+M;_<C;_++)if(we(kn,3*e.resolveTriangleIndex(_),f,p),kn.needsUpdate=!0,b.intersectsTriangle(kn))return!0;return!1}});{const v=Fn(t);for(let b=M,_=g+M;b<_;b++){const C=e.resolveTriangleIndex(b);we(En,3*C,f,p),En.a.applyMatrix4(Yn),En.b.applyMatrix4(Yn),En.c.applyMatrix4(Yn),En.needsUpdate=!0;for(let T=0,P=v*3;T<P;T+=3)if(we(kn,T,m,x),kn.needsUpdate=!0,En.intersectsTriangle(kn))return!0}}}else{const u=r+8,f=o[r+6];return Se(u,s,yr),!!(i.intersectsBox(yr)&&no(u,e,t,n,i)||(Se(f,s,yr),i.intersectsBox(yr)&&no(f,e,t,n,i)))}}const vr=new R.Matrix4,ks=new Je,Zn=new Je,wf=new R.Vector3,Pf=new R.Vector3,Ef=new R.Vector3,kf=new R.Vector3;function Rf(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,u=e.attributes.position,f=e.index,p=pt.getPrimitive(),m=pt.getPrimitive();let x=wf,M=Pf,g=null,v=null;i&&(g=Ef,v=kf);let b=1/0,_=null,C=null;return vr.copy(t).invert(),Zn.matrix.copy(vr),r.shapecast({boundsTraverseOrder:T=>ks.distanceToBox(T),intersectsBounds:(T,P,E)=>E<b&&E<a?(P&&(Zn.min.copy(T.min),Zn.max.copy(T.max),Zn.needsUpdate=!0),!0):!1,intersectsRange:(T,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:O=>Zn.distanceToBox(O),intersectsBounds:(O,I,A)=>A<b&&A<a,intersectsRange:(O,I)=>{for(let A=O,N=O+I;A<N;A++){const z=E.resolveTriangleIndex(A);we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=T,F=T+P;U<F;U++){const J=r.resolveTriangleIndex(U);we(p,3*J,l,c),p.needsUpdate=!0;const j=p.distanceToTriangle(m,x,g);if(j<b&&(M.copy(x),v&&v.copy(g),b=j,_=U,C=A),j<s)return!0}}}})}else{const E=Fn(e);for(let O=0,I=E;O<I;O++){we(m,3*O,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=T,N=T+P;A<N;A++){const z=r.resolveTriangleIndex(A);we(p,3*z,l,c),p.needsUpdate=!0;const U=p.distanceToTriangle(m,x,g);if(U<b&&(M.copy(x),v&&v.copy(g),b=U,_=A,C=O),U<s)return!0}}}}}),pt.releasePrimitive(p),pt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(M):n.point=M.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(vr),M.applyMatrix4(vr),i.distance=M.sub(i.point).length(),i.faceIndex=C),n)}function Af(){return typeof SharedArrayBuffer<"u"}const oi=new me.constructor,Dr=new me.constructor,Kt=new mo(()=>new R.Box3),Rn=new R.Box3,An=new R.Box3,Rs=new R.Box3,As=new R.Box3;let Os=!1;function Of(r,e,t,n){if(Os)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Os=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new R.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){oi.setBuffer(i[u]),c=0;const p=Kt.getPrimitive();Se(0,oi.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Dr.setBuffer(s[m]),a=Mt(0,0,t,l,n,o,c,0,0,p),Dr.clearBuffer(),c+=s[m].byteLength,!a);m++);if(Kt.releasePrimitive(p),oi.clearBuffer(),o+=i[u].byteLength,a)break}return Os=!1,a}function Mt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Dr,p=oi):(f=oi,p=Dr);const m=f.float32Array,x=f.uint32Array,M=f.uint16Array,g=p.float32Array,v=p.uint32Array,b=p.uint16Array,_=r*2,C=e*2,T=et(_,M),P=et(C,b);let E=!1;if(P&&T)u?E=i(rt(e,v),ht(e*2,b),rt(r,x),ht(r*2,M),c,a+e,o,s+r):E=i(rt(r,x),ht(r*2,M),rt(e,v),ht(e*2,b),o,s+r,c,a+e);else if(P){const O=Kt.getPrimitive();Se(e,g,O),O.applyMatrix4(t);const I=ft(r),A=dt(r,x);Se(I,m,Rn),Se(A,m,An);const N=O.intersectsBox(Rn),z=O.intersectsBox(An);E=N&&Mt(e,I,n,t,i,a,s,c,o+1,O,!u)||z&&Mt(e,A,n,t,i,a,s,c,o+1,O,!u),Kt.releasePrimitive(O)}else{const O=ft(e),I=dt(e,v);Se(O,g,Rs),Se(I,g,As);const A=l.intersectsBox(Rs),N=l.intersectsBox(As);if(A&&N)E=Mt(r,O,t,n,i,s,a,o,c+1,l,u)||Mt(r,I,t,n,i,s,a,o,c+1,l,u);else if(A)if(T)E=Mt(r,O,t,n,i,s,a,o,c+1,l,u);else{const z=Kt.getPrimitive();z.copy(Rs).applyMatrix4(t);const U=ft(r),F=dt(r,x);Se(U,m,Rn),Se(F,m,An);const J=z.intersectsBox(Rn),j=z.intersectsBox(An);E=J&&Mt(O,U,n,t,i,a,s,c,o+1,z,!u)||j&&Mt(O,F,n,t,i,a,s,c,o+1,z,!u),Kt.releasePrimitive(z)}else if(N)if(T)E=Mt(r,I,t,n,i,s,a,o,c+1,l,u);else{const z=Kt.getPrimitive();z.copy(As).applyMatrix4(t);const U=ft(r),F=dt(r,x);Se(U,m,Rn),Se(F,m,An);const J=z.intersectsBox(Rn),j=z.intersectsBox(An);E=J&&Mt(I,U,n,t,i,a,s,c,o+1,z,!u)||j&&Mt(I,F,n,t,i,a,s,c,o+1,z,!u),Kt.releasePrimitive(z)}}return E}const Sr=new Je,Ua=new R.Box3,zf={strategy:fo,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class ji{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new ji(t,{...n,[Ms]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new R.BufferAttribute(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...zf,[Ms]:!1},t),t.useSharedArrayBuffer&&!Af())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ms]||(qh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new R.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?_f:cf)(this,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,u=s[l+15]===jr;if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=o+si/4,p=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,c+1))}}}raycast(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?bf:ff;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?Mf:pf;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?Cf:mf;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=pt.getPrimitive(),n=this.indirect?hf:af;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const f=a;a=(p,m,x,M,g)=>f(p,m,x,M,g)?!0:n(p,m,this,o,x,M,t)}else a||(o?a=(f,p,m,x)=>n(f,p,this,o,m,x,t):a=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=ef(this,f,s,a,i,l),c)break;l+=m.byteLength}return pt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=pt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const M=this.resolveTriangleIndex(x);we(a,M*3,o,c)}:x=>{we(a,x*3,o,c)},u=pt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const M=e.resolveTriangleIndex(x);we(u,M*3,f,p)}:x=>{we(u,x*3,f,p)};if(s){const x=(M,g,v,b,_,C,T,P)=>{for(let E=v,O=v+b;E<O;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=M,A=M+g;I<A;I++)if(l(I),a.needsUpdate=!0,s(a,u,I,E,_,C,T,P))return!0}return!1};if(i){const M=i;i=function(g,v,b,_,C,T,P,E){return M(g,v,b,_,C,T,P,E)?!0:x(g,v,b,_,C,T,P,E)}}else i=x}return Of(this,e,t,i)}intersectsBox(e,t){return Sr.set(e.min,e.max,t),Sr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Sr.intersectsBox(n),intersectsTriangle:n=>Sr.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?Rf:xf)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return tf(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),Ua),e.union(Ua)}),e}}function Da(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 R.Ray,Fa=new R.Vector3,La=new R.Matrix4,If=R.Mesh.prototype.raycast,Bf=R.BatchedMesh.prototype.raycast,Va=new R.Vector3,Ie=new R.Mesh,_r=[];function Nf(r,e){this.isBatchedMesh?Uf.call(this,r,e):Df.call(this,r,e)}function Uf(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ie.material=this.material,Ie.geometry=this.geometry;const a=Ie.geometry.boundsTree,o=Ie.geometry.drawRange;Ie.geometry.boundingSphere===null&&(Ie.geometry.boundingSphere=new R.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ie.geometry.boundsTree=t[u],this.getMatrixAt(c,Ie.matrixWorld).premultiply(s),!Ie.geometry.boundsTree){this.getBoundingBoxAt(u,Ie.geometry.boundingBox),this.getBoundingSphereAt(u,Ie.geometry.boundingSphere);const f=i[u];Ie.geometry.setDrawRange(f.start,f.count)}Ie.raycast(r,_r);for(let f=0,p=_r.length;f<p;f++){const m=_r[f];m.object=this,m.batchId=c,e.push(m)}_r.length=0}Ie.geometry.boundsTree=a,Ie.geometry.drawRange=o,Ie.material=null,Ie.geometry=null}else Bf.call(this,r,e)}function Df(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;La.copy(this.matrixWorld).invert(),xr.copy(r.ray).applyMatrix4(La),Va.setFromMatrixScale(this.matrixWorld),Fa.copy(xr.direction).multiply(Va);const t=Fa.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=Da(s.raycastFirst(xr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(xr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=Da(a[o],this,r);l&&e.push(l)}}}else If.call(this,r,e)}function Ff(r={}){return this.boundsTree=new ji(this,r),this.boundsTree}const un=new R.Vector3,hn=new R.Vector3,fn=new R.Vector3,Ja=new R.Vector4,br=new R.Vector3,zs=new R.Vector3,ja=new R.Vector4,Ga=new R.Vector4,Tr=new R.Matrix4,$a=new R.Matrix4;function Kn(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 ii(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new R.BufferAttribute(new t(i*s),i,n)}function Kc(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 Lf(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 Wa(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;ja.fromBufferAttribute(i.attributes.skinIndex,e),Ga.fromBufferAttribute(i.attributes.skinWeight,e),Tr.elements.fill(0);for(let o=0;o<4;o++){const c=Ga.getComponent(o);if(c!==0){const l=ja.getComponent(o);$a.multiplyMatrices(s[l].matrixWorld,a[l]),Lf(Tr,$a,c)}}return Tr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Tr),t}function Is(r,e,t,n,i){br.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(zs.fromBufferAttribute(c,n),t?br.addScaledVector(zs,o):br.addScaledVector(zs.sub(i),o))}i.add(br)}function Vf(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new R.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 u=0;u<r.length;++u){const f=r[u];let p=0;if(n!==(f.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 m in f.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new R.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const M=r[x],g=M.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=M.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const M in f)x+=f[M].count;t.setAttribute(u,ii(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,M=f.length;x<M;x++){const g=f[x];a[x]!==!0&&Kc(g,p,m),m+=g.count}}return t}function Jf(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 jf(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),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class Gf{constructor(e){this.matrixWorld=new R.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&&Jf(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class $f{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 R.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 R.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],u=s[o],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new Gf(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 R.BufferAttribute(new Float32Array(0),4,!1))}else Vf(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new R.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",ii(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",ii(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",ii(o.tangent)),Kn(n.index,t.index),Kn(o.position,c.position),s&&Kn(o.normal,c.normal),a&&Kn(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,M=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new R.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let b=0,_=o.position.count;b<_;b++)un.fromBufferAttribute(l,b),u&&hn.fromBufferAttribute(u,b),f&&(Ja.fromBufferAttribute(f,b),fn.fromBufferAttribute(f,b)),g&&(p&&Is(p,g,M,b,un),m&&Is(m,g,M,b,hn),x&&Is(x,g,M,b,fn)),e.isSkinnedMesh&&(e.applyBoneTransform(b,un),u&&Wa(e,b,hn),f&&Wa(e,b,fn)),i&&un.applyMatrix4(e.matrixWorld),c.position.setXYZ(b,un.x,un.y,un.z),u&&(i&&hn.applyNormalMatrix(v),c.normal.setXYZ(b,hn.x,hn.y,hn.z)),f&&(i&&fn.transformDirection(e.matrixWorld),c.tangent.setXYZW(b,fn.x,fn.y,fn.z,Ja.w));for(const b in this.attributes){const _=this.attributes[b];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,ii(o[_])),Kn(o[_],c[_]),Kc(o[_],c[_]))}return e.matrixWorld.determinant()<0&&jf(t),t}}const Wf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Wc,CENTER:fo,CONTAINED:Hs,ExtendedTriangle:mt,MeshBVH:ji,OrientedBox:Je,SAH:Hc,StaticGeometryGenerator:$f,acceleratedRaycast:Nf,computeBoundsTree:Ff},Symbol.toStringTag,{value:"Module"}));class Hf{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 ut={node:"node",material:"material",camera:"camera",light:"light"},dn="KHR_animation_pointer",qf={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete};class Xf{constructor(e){this.name=dn,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){Zf();const t=e.target,n=t.extensions&&t.extensions[dn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=ut.node,a;if(n){const c=t.extensions[dn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=ut.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=ut.light:l.startsWith("/cameras/")&&(s=ut.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case ut.material:const u=("/materials/"+a.toString()+"/").length,f=l.substring(0,u);switch(i=l.substring(u),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=f+i;break;case ut.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),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=m+i;break;case ut.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),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 ut.camera:const M=("/cameras/"+a.toString()+"/").length,g=l.substring(0,M);switch(i=l.substring(M),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[dn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===ut.node?o=this.parser.getDependency("node",a):s===ut.material?o=this.parser.getDependency("material",a):s===ut.light?o=this.parser.getDependency("light",a):s===ut.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[dn]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[dn].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof R.SkinnedMesh&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,M){try{const g=M.split(".").filter(Boolean),b=g[g.length-1].replace(/\[.*\]$/,"");return b in x?typeof x[b]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let M,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(e,o)?(M=R.BooleanKeyframeTrack,g=!0):M=R.NumberKeyframeTrack;break;case 2:case 3:M=R.VectorKeyframeTrack;break;case 4:o.endsWith(".quaternion")?M=R.QuaternionKeyframeTrack:M=R.ColorKeyframeTrack;break}if(!M){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?qf[i.interpolation]:R.InterpolateLinear;let b=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(b=b.map(C=>C/Math.PI*180)),g&&(b=b.map(C=>C>0));const _=new M(o,t.array,b,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(_),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const C=new Float32Array(b.length/4);for(let P=0,E=b.length/4;P<E;P+=1)C[P]=b[P*4+3];const T=new M(o.replace(".color",".opacity"),t.array,C,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(T)}}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=[],u=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],M=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[M.input]:M.input,b=s.parameters!==void 0?s.parameters[M.output]:M.output;let _=t.loadAnimationTargetFromChannelWithAnimationPointer(x);_||(_=t.loadAnimationTargetFromChannel(x)),o.push(_),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",b)),u.push(M),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],M=p[2],g=p[3],v=p[4],b=[];for(let _=0,C=m.length;_<C;_++){const T=m[_],P=x[_],E=M[_],O=g[_],I=v[_];if(T===void 0)continue;T.updateMatrix&&(T.updateMatrix(),T.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(T,P,E,O,I);if(A||(A=i._createAnimationTracks(T,P,E,O,I)),A)for(let N=0;N<A.length;N++)b.push(A[N])}return new R.AnimationClip(a,void 0,b)})}}let Ha=!1,Yf=null;function Zf(){if(Ha)return;Ha=!0;const r=Yf||=R.PropertyBinding.findNode;R.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(dn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Kf=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Xf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=Nc;exports.BatchedParticleRenderer=wh;exports.Builder=io;exports.ByteBuffer=ai;exports.ConstantColor=yn;exports.ConstantValue=ee;exports.Matrix4=wt;exports.MeshBVH=ji;exports.MotionController=Tl;exports.ParticleSystem=Ur;exports.SIZE_PREFIX_LENGTH=Xa;exports.TrailParticle=Br;exports.Vector4=tt;exports.WorkerBase=Hf;exports.bundler=tu;exports.createNoise4D=Eh;exports.fetchProfile=vl;exports.index=Ih;exports.index$1=Wf;exports.index$2=Kf;exports.md5=gu;exports.v5=fu;
|
|
1116
|
+
}`;class zh extends qc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new A.BufferGeometry,this.indexBuffer=new A.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Dn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Xs(this.settings.material.map.channel),e.map=new A.Uniform$1(this.settings.material.map),e.mapTransform=new A.Uniform$1(new It().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new A.ShaderMaterial({uniforms:e,defines:t,vertexShader:Oh,fragmentShader:Ah,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||A.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const T=c[x],g=T.uvTile%f,v=Math.floor(T.uvTile/f+.001),_=T.previous.values();let b=_.next(),M=b.value,C=M;b.done||(b=_.next());let P;b.value!==void 0?P=b.value:P=C;for(let E=0;E<T.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(T.parentMatrix?this.vector_.copy(C.position).applyMatrix4(T.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.previousBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(T.parentMatrix?this.vector_.copy(M.position).applyMatrix4(T.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(T.parentMatrix?this.vector_.copy(P.position).applyMatrix4(T.parentMatrix):this.vector_.copy(P.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else if(T.parentMatrix)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else{const z=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,C.size*z),this.widthBuffer.setX(e+1,C.size*z)}this.uvBuffer.setXY(e,(E/T.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/T.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,C.color.x,C.color.y,C.color.z,C.color.w),this.colorBuffer.setXYZW(e+1,C.color.x,C.color.y,C.color.z,C.color.w),E+1<T.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),M=C,C=P,b.done||(b=_.next(),b.value!==void 0&&(P=b.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ji{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new A.Triangle;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new A.Vector3,this._tempB=new A.Vector3,this._tempC=new A.Vector3,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ji(t.geometries[e.geometry])}clone(){return new Ji(this._geometry)}update(e,t){}}uh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ji,loadJSON:Ji.fromJSON}],behaviors:[]});class yo extends A.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(yo.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new zh(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new Rh(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const Ih=yo;Sh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const Xc=Math.sqrt(5),Bh=(Xc-1)/4,Ue=(5-Xc)/20,sr=r=>Math.floor(r)|0,or=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Nh(r=Math.random){const e=Uh(r),t=new Float64Array(e).map(a=>or[a%32*4]),n=new Float64Array(e).map(a=>or[a%32*4+1]),i=new Float64Array(e).map(a=>or[a%32*4+2]),s=new Float64Array(e).map(a=>or[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,T;const g=(o+c+l+u)*Bh,v=sr(o+g),_=sr(c+g),b=sr(l+g),M=sr(u+g),C=(v+_+b+M)*Ue,P=v-C,E=_-C,z=b-C,I=M-C,R=o-P,N=c-E,O=l-z,U=u-I;let L=0,J=0,W=0,K=0;R>N?L++:J++,R>O?L++:W++,R>U?L++:K++,N>O?J++:W++,N>U?J++:K++,O>U?W++:K++;const $=L>=3?1:0,me=J>=3?1:0,ne=W>=3?1:0,ue=K>=3?1:0,re=L>=2?1:0,ge=J>=2?1:0,be=W>=2?1:0,se=K>=2?1:0,he=L>=1?1:0,oe=J>=1?1:0,Xe=W>=1?1:0,Ve=K>=1?1:0,Je=R-$+Ue,Ye=N-me+Ue,xe=O-ne+Ue,ye=U-ue+Ue,ae=R-re+2*Ue,ut=N-ge+2*Ue,ke=O-be+2*Ue,fe=U-se+2*Ue,it=R-he+3*Ue,vt=N-oe+3*Ue,St=O-Xe+3*Ue,rt=U-Ve+3*Ue,xt=R-1+4*Ue,ht=N-1+4*Ue,ft=O-1+4*Ue,_t=U-1+4*Ue,Re=v&255,Ze=_&255,ct=b&255,Ke=M&255;let Q=.6-R*R-N*N-O*O-U*U;if(Q<0)f=0;else{const le=Re+e[Ze+e[ct+e[Ke]]];Q*=Q,f=Q*Q*(t[le]*R+n[le]*N+i[le]*O+s[le]*U)}let bt=.6-Je*Je-Ye*Ye-xe*xe-ye*ye;if(bt<0)p=0;else{const le=Re+$+e[Ze+me+e[ct+ne+e[Ke+ue]]];bt*=bt,p=bt*bt*(t[le]*Je+n[le]*Ye+i[le]*xe+s[le]*ye)}let Nt=.6-ae*ae-ut*ut-ke*ke-fe*fe;if(Nt<0)m=0;else{const le=Re+re+e[Ze+ge+e[ct+be+e[Ke+se]]];Nt*=Nt,m=Nt*Nt*(t[le]*ae+n[le]*ut+i[le]*ke+s[le]*fe)}let Tt=.6-it*it-vt*vt-St*St-rt*rt;if(Tt<0)x=0;else{const le=Re+he+e[Ze+oe+e[ct+Xe+e[Ke+Ve]]];Tt*=Tt,x=Tt*Tt*(t[le]*it+n[le]*vt+i[le]*St+s[le]*rt)}let Ut=.6-xt*xt-ht*ht-ft*ft-_t*_t;if(Ut<0)T=0;else{const le=Re+1+e[Ze+1+e[ct+1+e[Ke+1]]];Ut*=Ut,T=Ut*Ut*(t[le]*xt+n[le]*ht+i[le]*ft+s[le]*_t)}return 27*(f+p+m+x+T)}}function Uh(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Dh=Object.defineProperty,Fh=(r,e,t)=>e in r?Dh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Fh(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class T extends r{}class g extends r{}class v extends r{}class _ extends r{}class b 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(d){Ce(this,"input"),Ce(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);d.push(w),y+=String.fromCodePoint(w).length}return d}}function R(h){return h===10}function N(h){return R(h)||h===8192||h===32}function O(h){return h>=48&&h<=57}function U(h){return O(h)||h>=65&&h<=70||h>=97&&h<=102}function L(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return L(h)||O(h)||h===45}function W(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function K(h,d){return h===92&&!R(d)}function $(h,d,y){return h===45?L(d)||d===45||K(d,y):!!L(h)||h===92&&K(h,d)}function me(h,d,y){return h===43||h===45?O(d)||d===46&&O(y):O(h===46?d:h)}function ne(h){const d=h.consume();if(U(d)){let y=[d];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function ue(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const w=h.peek()[0];w===void 0||(R(w)?h.consume():y.value+=String.fromCodePoint(ne(h)))}else y.value+=String.fromCodePoint(S)}}function re(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!K(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ne(h))}}}function ge(h){let d=(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}})(h);return $(...h.peek())?new p(d.value,d.type,re(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function be(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;K(...h.peek())&&ne(h)}}function se(h){const d=re(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(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(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)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function he(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return ue(h,d);if(d===35){if(J(y[0])||K(...y)){const S=new i;return $(...y)&&(S.type="id"),S.value=re(h),S}return new l(String.fromCodePoint(d))}return d===39?ue(h,d):d===40?new C:d===41?new P:d===43?me(...y)?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?me(...h.peek())?(h.reconsume(d),ge(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new T):$(...h.peek())?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===46?me(...h.peek())?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?$(...y)?new n(re(h)):new l(String.fromCodePoint(d)):d===91?new b:d===92?K(...y)?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===93?new M:d===123?new E:d===125?new z:O(d)?(h.reconsume(d),ge(h)):L(d)?(h.reconsume(d),se(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function Xe(h){return oe.has(h.toLowerCase())}function Ve(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function Je(h){const d=[];let y=0;function S(){let k=0;const B=y;for(;y<h.length;){const F=h.slice(y,y+1);if(/\s/.test(F)&&k===0)break;if(F==="(")k+=1;else if(F===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(B,y)}function w(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?w():d.push(S())}return d}function Ye(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function xe(h,d){const y=[],S=[];for(const w of h)d(w)?y.push(w):S.push(w);return[y,S]}function ye(h,d={}){function y(S){return Array.from(S).map((w=>ye(w,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const w=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(w,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(ye(h.value,d));break;case"clamp":h=new CSSMathClamp(ye(h.lower,d),ye(h.value,d),ye(h.upper,d));break;case"invert":h=new CSSMathInvert(ye(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&Xe(w.unit)&&w.unit===S[0].unit))){const w=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[w,k]=xe(S,(F=>F instanceof CSSUnitValue&&F.unit!=="percent")),B=Array.from(Ye(w,"unit").values());if(B.some((F=>F.length>0))){const F=B.map((D=>{const V=Math[h.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...F,...k):new CSSMathMax(...F,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const B=k.filter((F=>F instanceof CSSUnitValue));return[...k.filter((F=>!(F instanceof CSSUnitValue))),...Array.from(Ye(B,"unit").entries()).map((([F,D])=>{const V=D.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,F)}))]},w=[];for(const k of h.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(h instanceof CSSMathProduct){let S=[];for(const B of h.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(((F,{value:D})=>F*D),1);S=[new CSSUnitValue(B,"number"),...k]}if(S.length===2){let B,F;for(const D of S)D instanceof CSSUnitValue&&D.unit==="number"?B=D:D instanceof CSSMathSum&&[...D.values].every((V=>V instanceof CSSUnitValue))&&(F=D);if(B&&F)return new CSSMathSum(...[...F.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 h}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 h of Object.values(ke))if(h.compatible)for(const d of h.units)fe.set(d,h);function it(h){return fe.get(h)}function vt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function St(h){return h==="number"?{}:h==="percent"?{percent:1}:ke.absoluteLengths.units.has(h)||ke.fontRelativeLengths.units.has(h)||ke.viewportRelativeLengths.units.has(h)?{length:1}:ke.angle.units.has(h)?{angle:1}:ke.time.units.has(h)?{time:1}:ke.frequency.units.has(h)?{frequency:1}:ke.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function rt(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=it(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=rt(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=rt(y),w=[];if(S===ae)return ae;for(const k of d)for(const B of S)w.push([k[0]*B[0],vt(k[1],B[1])]);d=w}return d}throw new Error("Not implemented")}function xt(h,d){if(St(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=rt(h);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,F=w.value,D=it(B),V=it(k);return!V||D!==V?ae:new CSSUnitValue(F*V.ratios[B]/V.ratios[k],k)})(ht(y[0]),d);if(S===ae)throw new TypeError;return S}function ht(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const w=S[0];return w[1]!==1?ae:new CSSUnitValue(d,w[0])}function ft(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=rt(h).map((S=>ht(S)));if(y.some((S=>S===ae)))throw new TypeError("Type error");return new CSSMathSum(...y)}function _t(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of ut)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Re{constructor(d,y){Ce(this,"name"),Ce(this,"values"),this.name=d,this.values=y}}class Ze{constructor(d,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=d,this.associatedToken=y}}function ct(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new I(d),S=[];for(;;){const w=he(y);if(w===void 0)return S;S.push(w)}})(h);throw new TypeError("Invalid input type "+typeof h)}function Ke(h){const d=h.shift();return d instanceof E||d instanceof b||d instanceof C?(function(y,S){let w;if(S instanceof E)w=z;else if(S instanceof C)w=P;else{if(!(S instanceof b))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))}})(h,d):d 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))}})(d,h):d}function Q(h){if(h instanceof C||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function bt(h){return h[h.length-1]}function Nt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",w=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function Tt(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>Tt(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>Tt(d))));if(h.type==="NEGATE")return new CSSMathNegate(Tt(h.value));if(h.type==="INVERT")return new CSSMathInvert(Tt(h.value));if(h instanceof Ze)return Ut(new Re("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return le(h)}function Ut(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((w=>!(w instanceof m||w instanceof _))).map((w=>ye(Ut(new Re("calc",w)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=Tt((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof u||B instanceof p||B instanceof f||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 F=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(F,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 F=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(F,V,D))}if(!(bt(w)instanceof C))return null;w.pop()}else if(!(B instanceof m))return null}for(;w.length;){if(bt(w)instanceof C)return null;const B=w.pop(),F=k.pop(),D=k.pop();k.push(Nt(B,D,F))}return k[0]})([...h.values]));let y;try{y=ye(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function le(h){return h instanceof Re&&["calc","min","max","clamp"].includes(h.name)?Ut(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function al(h){const d=(function(y){const S=ct(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const w=Ke(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?w:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Re||new CSSStyleSheet().insertRule("error",0),d instanceof p&&St(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),le(d)}(function(){let h=new WeakMap;function d(k){const B=[];for(let D=0;D<k.length;D++)B[D]=typeof(F=k[D])=="number"?new CSSUnitValue(F,"number"):F;var F;return B}class y{static parse(B){return B instanceof y?B:ye(al(B),{})}}class S extends y{constructor(B,F,D,V){super(),h.set(this,{values:d(B),operator:F,name:D||F,delimiter:V||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const B=h.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),h.set(this,{value:k,unit:B})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ft(this,...k)}type(){return St(h.get(this).unit)}toString(){const k=h.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 h.get(this).values.map((k=>k.type())).reduce(_t)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const B={};for(const F of ut)B[F]=-1*k[F];return B})(h.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 bo="block";let je=new WeakMap,Dt=new WeakMap;const $i=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function To(h){return h===document.scrollingElement?document:h}function sn(h){Xr(h);let d=je.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Mo(h,d){if(!h)return null;const y=Dt.get(h).sourceMeasurements,S=getComputedStyle(h);let w=y.scrollTop;return Ve(d,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function qr(h,d){const y=ye(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function Xr(h){if(!(h instanceof bn))return void(function(y){const S=je.get(y);if(!S.anonymousSource)return;const w=wo(S.anonymousSource,S.anonymousTarget);_n(y,w)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void _n(h,null);_n(h,ts(d))}function Co(h){return["block","inline","x","y"].includes(h)}function Yr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function Zr(h,d){if(!h||!d)return;let y=0,S=0,w=d;const k=h.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const B=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:B.fontSize}}function Wi(h){let d=Dt.get(h);d.sourceMeasurements=Yr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof bn&&(je.get(S).subjectMeasurements=Zr(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&sn(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function _n(h,d){const y=je.get(h),S=y.source;if(S!=d){if(S){const w=Dt.get(S);if(w){w.timelineRefs.delete(h);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=d,d){let w=Dt.get(d);if(!w){w={timelineRefs:new Set,sourceMeasurements:Yr(d)},Dt.set(d,w);const k=new ResizeObserver((D=>{for(const V of D)Wi(y.source)}));k.observe(d);for(const D of d.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)Wi(V.target)}));B.observe(d,{attributes:!0,attributeFilter:["style","class"]});const F=()=>{w.sourceMeasurements.scrollLeft=d.scrollLeft,w.sourceMeasurements.scrollTop=d.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&sn(V)}};To(d).addEventListener("scroll",F),w.disconnect=()=>{k.disconnect(),B.disconnect(),To(d).removeEventListener("scroll",F)}}w.timelineRefs.add(new WeakRef(h))}}}function Kr(h,d){let y=je.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Qr(h,d,y){let S=je.get(h).animations;for(let w=0;w<S.length;w++)if(S[w].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{sn(h)}))}class Qe{constructor(d){if(je.set(this,{source:null,axis:bo,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),_n(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=bo){if(!Co(d.axis))throw TypeError("Invalid axis");je.get(this).axis=d.axis}sn(this)}set source(d){_n(this,d),sn(this)}get source(){return je.get(this).source}set axis(d){if(!Co(d))throw TypeError("Invalid axis");je.get(this).axis=d,sn(this)}get axis(){return je.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==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=Mo(y,w),B=(function(F,D){const V=Dt.get(F).sourceMeasurements,H=getComputedStyle(F).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 es(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function wo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return ts(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function cl(h){switch(getComputedStyle(h).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 Po(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function ll(h){return getComputedStyle(h).position!="static"||Po(h)}function ul(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return es(h,cl);case"absolute":return es(h,ll);case"fixed":return es(h,Po)}}function ts(h){if(h&&h.isConnected){for(;h=ul(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function Gn(h,d){const y=je.get(h),S=y.subjectMeasurements,w=Dt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof bn?ns(d,w,S,y.axis,y.inset):null}function ns(h,d,y,S,w){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let B,F,D={fontSize:y.fontSize};Ve(S,d)==="x"?(B=y.offsetWidth,F=y.left,D.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(F+=d.scrollWidth-d.clientWidth,D.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),D.containerSize=d.clientWidth):(B=y.offsetHeight,F=y.top,D.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],D.containerSize=d.clientHeight);const V=(function(os,Zi){const bl={start:0,end:0};if(!os)return bl;const[Tl,Ml]=[os.start,os.end].map(((Jo,jo)=>Jo==="auto"?Zi.scrollPadding[jo]==="auto"?0:parseFloat(Zi.scrollPadding[jo]):qr(Jo,{percentageReference:CSS.px(Zi.containerSize),fontSize:CSS.px(parseFloat(Zi.fontSize))})));return{start:Tl,end:Ml}})(w,D),H=F-D.containerSize+V.end,X=F+B-V.start,Y=H+B,de=X-B,Te=Math.min(Y,de),st=Math.max(Y,de);let Mt,dt;const Vo=B>D.containerSize-V.start-V.end;switch(h){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=Vo?st:Te;break;case"exit-crossing":Mt=Vo?Te:st,dt=X}return{start:Mt,end:dt}}function Eo(h,d){if(h instanceof bn){const{rangeName:y,offset:S}=d;return ko(Gn(h,y),S,Gn(h,"cover"),h.subject)}if(h instanceof Qe){const{axis:y,source:S}=h,{sourceMeasurements:w}=Dt.get(S);let k;return k=Ve(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,qr(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function ko(h,d,y,S){if(!h||!y)return 0;let w=getComputedStyle(S);return(qr(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(w.fontSize))})+h.start-y.start)/(y.end-y.start)}let bn=class extends Qe{constructor(d){super(d);const y=je.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.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]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{Wi(y.source)})).observe(y.subject),new MutationObserver((()=>{Wi(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),Xr(this),y.subjectMeasurements=Zr(y.source,y.subject),sn(this)}get source(){return Xr(this),je.get(this).source}set source(d){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=Mo(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 hl=document.getAnimations,fl=window.Element.prototype.getAnimations,dl=window.Element.prototype.animate,Ro=window.Animation;class Tn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function $n(h){h.readyPromise=new Tn,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Hi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&zo(h):Oo(h))}))}function Ao(){return new DOMException("The user aborted a request","AbortError")}function on(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Lt(h),w=S?y*d/S:0;return CSS.percent(w)}function ve(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Lt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.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 Oo(h){const d=ve(h,h.timeline.currentTime);if(h.holdTime!=null)kt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;kt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Ft(h,!1,!1),Vt(h),h.pendingTask=null}function zo(h){const d=ve(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),kt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Ft(h,!1,!1),Vt(h),h.pendingTask=null}function Io(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function Mn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function kt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Bo(h){if(!h.timeline)return null;const d=ve(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Ft(h,d,y){if(!h.timeline)return;let S=d?ve(h,h.proxy.currentTime):Bo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const w=Mn(h),k=Lt(h);let B=h.previousCurrentTime;w>0&&S>=k&&h.previousCurrentTime!=null?((B===null||B<k)&&(B=k),h.holdTime=d?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),h.holdTime=d?S:B):w!=0&&(d&&h.holdTime!==null&&(h.startTime=(function(F,D){if(!F.timeline)return null;const V=ve(F,F.timeline.currentTime);return V==null?null:V-D/F.animation.playbackRate})(h,h.holdTime)),h.holdTime=null)}Vt(h),h.previousCurrentTime=ve(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Tn),h.finishedPromise.state=="pending"&&(y?Io(h):Promise.resolve().then((()=>{Io(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Tn),h.animation.playState!="paused"&&h.animation.pause())}function Lt(h){const d=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Vt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;is(h,(ve(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&is(h,h.holdTime)}function is(h,d){const y=h.timeline,S=h.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+w}function rs(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,w=ve(h,h.proxy.currentTime);Mn(h)==0&&w==null&&(h.holdTime=0),w==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Vt(h),h.readyPromise||$n(h),h.pendingTask="play",Qr(h.timeline,h.animation,ss.bind(h.proxy)),Ft(h,!1,!1))}function ss(h){const d=q.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Hi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&zo(d):Oo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(d,h);is(d,(S-ve(d,this.startTime))*this.playbackRate),Ft(d,!1,!1)}}function No(h){h.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(h=>{q=new WeakMap}),!1);let Uo=new WeakMap;function Hi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Do(k.timeline):k.animationRange.start;return Eo(k.timeline,B)})(h))}catch(k){y=CSS.percent(0),h.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"?Fo(k.timeline):k.animationRange.end;return 1-Eo(k.timeline,B)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const w=Mn(h);h.startTime=ve(h,w>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&No(h)}function qi(h){throw new Error("Unsupported timeline class")}function Do(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof Qe?CSS.percent(0):void qi()}function Fo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof Qe?CSS.percent(100):void qi()}function pl(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Do(h),end:Fo(h)};if(h instanceof ViewTimeline){const S=Je(d),w=[],k=[];if(S.forEach((B=>{if($i.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${d}"`)}})),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(h instanceof Qe){const S=d.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(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(w=d.offset);else{const k=Je(d);k.length===1?$i.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(!$i.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(h instanceof Qe)return CSSNumericValue.parse(d);qi()}class Yi{constructor(d,y,S={}){const w=y instanceof Qe,k=d instanceof Ro?d:new Ro(d,w?void 0:y);Uo.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?pl(y,S["animation-range"]):null,proxy:this})}get effect(){const d=q.get(this);return d.timeline?(d.effect||(d.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=on(y,H.localTime),H.endTime=on(y,H.endTime),H.activeDuration=on(y,H.activeDuration);const Y=Lt(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}},F={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),No(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,F),D})(d)),d.effect):d.animation.effect}set effect(d){const y=q.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=q.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=q.get(this),S=this.timeline;if(S==d)return;const w=this.playState,k=this.currentTime;let B,F=Lt(y);B=k===null?null:F===0?0:ve(y,k)/F;const D=S instanceof Qe,V=d instanceof Qe,H=this.pending;if(D&&Kr(y.timeline,y.animation),V)return y.timeline=d,kt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||$n(y),y.pendingTask="play",Qr(y.timeline,y.animation,ss.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*F),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||$n(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Ft(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Kr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Lt(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=q.get(this);return d.timeline?on(d,d.startTime):d.animation.startTime}set startTime(d){const y=q.get(this);if(d=ve(y,d),!y.timeline)return void(y.animation.startTime=d);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=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Ft(y,!0,!1),Vt(y)}get currentTime(){const d=q.get(this);return d.timeline?d.holdTime!=null?on(d,d.holdTime):on(d,Bo(d)):d.animation.currentTime}set currentTime(d){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,d),y.pendingTask=="pause"&&(y.holdTime=ve(y,d),kt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Ft(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(d){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=q.get(this);if(!d.timeline)return d.animation.playState;const y=ve(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Lt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=q.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof Qe&&(y.animationRange.start=Xi(y.timeline,d,"start"),Hi(y),Vt(y))}get rangeEnd(){var d;return((d=q.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof Qe&&(y.animationRange.end=Xi(y.timeline,d,"end"),Hi(y),Vt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const d=q.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=q.get(this);if(!d.timeline)return void d.animation.finish();const y=Mn(d),S=Lt(d);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(d);const w=y<0?0:S;this.currentTime=on(d,w);const k=ve(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-w/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Ft(d,!0,!0)}play(){const d=q.get(this);d.timeline?rs(d):d.animation.play()}pause(){const d=q.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||$n(d),d.pendingTask="pause",Qr(d.timeline,d.animation,ss.bind(d.proxy))):d.animation.pause()}reverse(){const d=q.get(this),y=Mn(d),S=ve(d,this.currentTime),w=Lt(d)==1/0,k=y!=0&&(y<0||S>0||!w);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-Mn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),rs(d)}updatePlaybackRate(d){const y=q.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);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=d==0?w:w!=null&&k!=null?(w-k)/d:null,kt(y),Ft(y,!1,!1),Vt(y);break;default:rs(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(d){q.get(this).animation.id=d}cancel(){const d=q.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,kt(y),y.readyPromise.reject(Ao()),$n(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Ao()),d.finishedPromise=new Tn,d.animation.cancel()),d.startTime=null,d.holdTime=null,Kr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(d){q.get(this).animation.onfinish=d}get oncancel(){return q.get(this).animation.oncancel}set oncancel(d){q.get(this).animation.oncancel=d}get onremove(){return q.get(this).animation.onremove}set onremove(d){q.get(this).animation.onremove=d}get finished(){const d=q.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Tn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=q.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Tn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){q.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){q.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){q.get(this).animation.dispatchEvent(d)}}function ml(h,d){const y=d.timeline;y instanceof Qe&&delete d.timeline;const S=dl.apply(this,[h,d]),w=new Yi(S,y);return y instanceof Qe&&(S.pause(),q.get(w).animationRange={start:Xi(y,d.rangeStart,"start"),end:Xi(y,d.rangeEnd,"end")},w.play()),w}function Lo(h){for(let d=0;d<h.length;++d){let y=Uo.get(h[d]);y&&(h[d]=y)}return h}function yl(h){return Lo(fl.apply(this,[h]))}function gl(h){return Lo(hl.apply(this,[h]))}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"],vl=["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(h,d,y){const S={sheetSrc:h,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&&(d?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:wo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),w=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!w)return;let k=[],B=[],F=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(B=this.extractMatches(h.block.contents,Ae.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(h.block.contents,Ae.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(D," 1s "+D),F=!0))})),F&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,B)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let w=[];if(d){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE);for(const F of B){const D=this.split(F);let V={selector:h.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(h.block.contents,Ae.SCROLL_TIMELINE_NAME);for(let F=0;F<B.length;F++)if(F<w.length)w[F].name=B[F];else{let D={selector:h.selector,name:B[F]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE_AXIS);if(k=B.filter((F=>Cn.includes(F))),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(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),w=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let X={selector:h.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(h.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:h.selector,name:D[V],inset:null};k.push(H)}}let B=[],F=[];if(w&&(B=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_AXIS);if(F=D.filter((V=>Cn.includes(V))),F.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]),F.length&&(k[D].axis=F[D%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter((d=>{return y=d,Ae.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,Ae.ANIMATION_TIME_RANGE));const w=Math.max(d.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=Ae.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.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(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=Ae.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:vl.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(h){const d=Ae.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Cn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){Ae.IDENTIFIER.lastIndex=h.index;const d=Ae.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(D){return $i.some((V=>D.startsWith(V)))}const S=h.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 F=[];F.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)})),F.push(H.join(",")),D==w.length-1?F.push(S.substring(w[D].end)):F.push(S.substring(w[D].end,w[D+1].start))}return B?(h.block.contents=F.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const w=S.index-d;S.index=h+y.length+w}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){Ae.WHITE_SPACE.lastIndex=h.index;const d=Ae.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function Sl(h,d,y,S,w,k){const B=Yr(d),F=Zr(d,y);return ko(ns(h,B,F,S,w),k,ns("cover",B,F,S,w),y)}function xl(h,d,y){const S=Xt.getAnimationTimelineOptions(d,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,F){const D=ts(F.subject),V=F.axis||F.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*Sl(dt[0],D,F.subject,V,F.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)}})(h,k),{timeline:k.source?new Qe(k):new bn(k),animOptions:S}):null}function _l(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(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 F=new Blob([B],{type:"text/css"}),D=URL.createObjectURL(F);S.setAttribute("href",D)}}))}new MutationObserver((S=>{for(const w of S)for(const k of w.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=xl(y,y.animationName,d.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(!_l()){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:ml}))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:yl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:gl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Lh{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 Yc{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(ce.open,b),this.handleErrorEvent=b=>this.handleEvent(ce.error,b),this.handleCloseEvent=b=>this.handleEvent(ce.close,b),this.handleMessageEvent=b=>this.handleEvent(ce.message,b),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:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},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 Vh{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 Yc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_,b,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:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(T=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&T!==void 0?T:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(C=(M=(b=this._options)===null||b===void 0?void 0:b.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 Jh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Lh,Websocket:Yc,WebsocketBuilder:Vh,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),go=0,Zc=1,Kc=2,Ys=2,ws=1.25,ka=1,$e=32,Pe=$e/4,Qc=65535,kr=Math.pow(2,-24),$r=Symbol("SKIP_GENERATION"),el={strategy:go,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$r]:!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 Ra(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 Aa(r,e){e.set(r)}function Oa(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]===Qc}function We(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 vo(r,e){return e[r+7]}function Ps(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,T=-1/0,g=-1/0;const v=r.offset||0;for(let _=(e-v)*6,b=(e+t-v)*6;_<b;_+=6){const M=r[_+0],C=r[_+1],P=M-C,E=M+C;P<s&&(s=P),E>c&&(c=E),M<f&&(f=M),M>x&&(x=M);const z=r[_+2],I=r[_+3],R=z-I,N=z+I;R<a&&(a=R),N>l&&(l=N),z<p&&(p=z),z>T&&(T=z);const O=r[_+4],U=r[_+5],L=O-U,J=O+U;L<o&&(o=L),J>u&&(u=J),O<m&&(m=O),O>g&&(g=O)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=T,i[5]=g}const Jt=32,jh=(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 Gh(r,e,t,n,i,s){let a=-1,o=0;if(s===go)a=Ra(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Zc)a=Ra(r),a!==-1&&(o=$h(t,n,i,a));else if(s===Kc){const c=Xn(r);let l=ws*i;const u=t.offset||0,f=(n-u)*6,p=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],v=(e[m+3]-x)/Jt;if(i<Jt/4){const _=[...Kt];_.length=i;let b=0;for(let C=f;C<p;C+=6,b++){const P=_[b];P.candidate=t[C+2*m],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)}_.sort(jh);let M=i;for(let C=0;C<M;C++){const P=_[C];for(;C+1<M&&_[C+1].candidate===P.candidate;)_.splice(C+1,1),M--}for(let C=f;C<p;C+=6){const P=t[C+2*m];for(let E=0;E<M;E++){const z=_[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=_[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=ka+ws*(N*E+O*z);U<l&&(a=m,l=U,o=P.candidate)}}else{for(let M=0;M<Jt;M++){const C=Kt[M];C.count=0,C.candidate=x+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=f;M<p;M+=6){let E=~~((t[M+2*m]-x)/v);E>=Jt&&(E=Jt-1);const z=Kt[E];z.count++,ar(M,t,z.bounds)}const _=Kt[Jt-1];Aa(_.bounds,_.rightCacheBounds);for(let M=Jt-2;M>=0;M--){const C=Kt[M],P=Kt[M+1];Oa(C.bounds,P.rightCacheBounds,C.rightCacheBounds)}let b=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&&(b===0?Aa(E,cr):Oa(E,cr,cr)),b+=P;let R=0,N=0;b!==0&&(R=Xn(cr)/c);const O=i-b;O!==0&&(N=Xn(I)/c);const U=ka+ws*(R*b+N*O);U<l&&(a=m,l=U,o=C.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function $h(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 Es{constructor(){this.boundingData=new Float32Array(6)}}function Wh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let f=0;f<e;f++){let p=r[a*e+f];r[a*e+f]=r[o*e+f],r[o*e+f]=p}for(let f=0;f<6;f++){const p=a-u,m=o-u,x=t[p*6+f];t[p*6+f]=t[m*6+f],t[m*6+f]=x}a++,o--}else return a}}let tl,Rr,Zs,nl;const Hh=Math.pow(2,32);function Ks(r){return"count"in r?1:1+Ks(r.left)+Ks(r.right)}function qh(r,e,t){return tl=new Float32Array(t),Rr=new Uint32Array(t),Zs=new Uint16Array(t),nl=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++)tl[t+a]=s[a];if(i)return e.buffer?(nl.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Rr[t+6]=e.offset,Zs[n+14]=e.count,Zs[n+15]=Qc,r+$e);{const{left:a,right:o,splitAxis:c}=e,l=r+$e;let u=Qs(l,a);const f=r/$e,m=u/$e-f;if(m>Hh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Rr[t+6]=m,Rr[t+7]=c,Qs(u,o)}}function Xh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,u=r.primitiveBuffer,f=r.primitiveBufferStride,p=new Float32Array(6);let m=!1;const x=new Es;return Ps(e,t,n,x.boundingData,p),g(x,t,n,p),x;function T(v){l&&l(v/n)}function g(v,_,b,M=null,C=0){if(!m&&C>=s&&(m=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),b<=o||C>=s)return T(_+b),v.offset=_,v.count=b,v;const P=Gh(v.boundingData,M,e,_,b,c);if(P.axis===-1)return T(_+b),v.offset=_,v.count=b,v;const E=Wh(u,f,e,_,b,P);if(E===_||E===_+b)T(_+b),v.offset=_,v.count=b;else{v.splitAxis=P.axis;const z=new Es,I=_,R=E-_;v.left=z,Ps(e,I,R,z.boundingData,p),g(z,I,R,p,C+1);const N=new Es,O=E,U=b-R;v.right=N,Ps(e,O,U,N.boundingData,p),g(N,O,U,p,C+1)}return v}}function Yh(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=Xh(r,o,c.offset,c.count,e),u=Ks(l),f=new t($e*u);return qh(0,l,f),f})}class So{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 Zh{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 Zh;let nn,Un;const Pn=[],lr=new So(()=>new A.Box3);function Kh(r,e,t,n,i,s){nn=lr.getPrimitive(),Un=lr.getPrimitive(),Pn.push(nn,Un),pe.setBuffer(r._roots[e]);const a=eo(0,r.geometry,t,n,i,s);pe.clearBuffer(),lr.releasePrimitive(nn),lr.releasePrimitive(Un),Pn.pop(),Pn.pop();const o=Pn.length;return o>0&&(Un=Pn[o-1],nn=Pn[o-2]),a}function eo(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=pe;let u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);return Se(r,o,nn),n(p,m,!1,a,s+r/Pe,nn)}else{let R=function(O){const{uint16Array:U,uint32Array:L}=pe;let J=O*2;for(;!Ee(J,U);)O=Ie(O),J=O*2;return We(O,L)},N=function(O){const{uint16Array:U,uint32Array:L}=pe;let J=O*2;for(;!Ee(J,U);)O=Be(O,L),J=O*2;return We(O,L)+tt(J,U)};const p=Ie(r),m=Be(r,l);let x=p,T=m,g,v,_,b;if(i&&(_=nn,b=Un,Se(x,o,_),Se(T,o,b),g=i(_),v=i(b),v<g)){x=m,T=p;const O=g;g=v,v=O,_=b}_||(_=nn,Se(x,o,_));const M=Ee(x*2,c),C=t(_,M,g,a+1,s+x/Pe);let P;if(C===Ys){const O=R(x),L=N(x)-O;P=n(O,L,!0,a+1,s+x/Pe,_)}else P=C&&eo(x,e,t,n,i,s,a+1);if(P)return!0;b=Un,Se(T,o,b);const E=Ee(T*2,c),z=t(b,E,v,a+1,s+T/Pe);let I;if(z===Ys){const O=R(T),L=N(T)-O;I=n(O,L,!0,a+1,s+T/Pe,b)}else I=z&&eo(T,e,t,n,i,s,a+1);return!!I}}const ci=new pe.constructor,Lr=new pe.constructor,en=new So(()=>new A.Box3),En=new A.Box3,kn=new A.Box3,ks=new A.Box3,Rs=new A.Box3;let As=!1;function Qh(r,e,t,n){if(As)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");As=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new A.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){ci.setBuffer(i[u]),c=0;const p=en.getPrimitive();Se(0,ci.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Lr.setBuffer(s[m]),a=wt(0,0,t,l,n,o,c,0,0,p),Lr.clearBuffer(),c+=s[m].byteLength/$e,!a);m++);if(en.releasePrimitive(p),ci.clearBuffer(),o+=i[u].byteLength/$e,a)break}return As=!1,a}function wt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Lr,p=ci):(f=ci,p=Lr);const m=f.float32Array,x=f.uint32Array,T=f.uint16Array,g=p.float32Array,v=p.uint32Array,_=p.uint16Array,b=r*2,M=e*2,C=Ee(b,T),P=Ee(M,_);let E=!1;if(P&&C)u?E=i(We(e,v),tt(e*2,_),We(r,x),tt(r*2,T),c,a+e/Pe,o,s+r/Pe):E=i(We(r,x),tt(r*2,T),We(e,v),tt(e*2,_),o,s+r/Pe,c,a+e/Pe);else if(P){const z=en.getPrimitive();Se(e,g,z),z.applyMatrix4(t);const I=Ie(r),R=Be(r,x);Se(I,m,En),Se(R,m,kn);const N=z.intersectsBox(En),O=z.intersectsBox(kn);E=N&&wt(e,I,n,t,i,a,s,c,o+1,z,!u)||O&&wt(e,R,n,t,i,a,s,c,o+1,z,!u),en.releasePrimitive(z)}else{const z=Ie(e),I=Be(e,v);Se(z,g,ks),Se(I,g,Rs);const R=l.intersectsBox(ks),N=l.intersectsBox(Rs);if(R&&N)E=wt(r,z,t,n,i,s,a,o,c+1,l,u)||wt(r,I,t,n,i,s,a,o,c+1,l,u);else if(R)if(C)E=wt(r,z,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(ks).applyMatrix4(t);const U=Ie(r),L=Be(r,x);Se(U,m,En),Se(L,m,kn);const J=O.intersectsBox(En),W=O.intersectsBox(kn);E=J&&wt(z,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(z,L,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}else if(N)if(C)E=wt(r,I,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(Rs).applyMatrix4(t);const U=Ie(r),L=Be(r,x);Se(U,m,En),Se(L,m,kn);const J=O.intersectsBox(En),W=O.intersectsBox(kn);E=J&&wt(I,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(I,L,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}}return E}const za=new A.Box3,Rn=new Float32Array(6);class il{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...el,...e},Yh(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,u=-1/0;for(let f=e,p=e+t;f<p;f++){this.writePrimitiveBounds(f,Rn,0);const[m,x,T,g,v,_]=Rn;m<s&&(s=m),g>c&&(c=g),x<a&&(a=x),v>l&&(l=v),T<o&&(o=T),_>u&&(u=_)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,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,u,f,p]=Rn,m=(o+u)/2,x=(c+f)/2,T=(l+p)/2,g=(u-o)/2,v=(f-c)/2,_=(p-l)/2,b=(s-i)*6;n[b+0]=m,n[b+1]=g+(Math.abs(m)+g)*kr,n[b+2]=x,n[b+3]=v+(Math.abs(x)+v)*kr,n[b+4]=T,n[b+5]=_+(Math.abs(T)+_)*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/$e;for(let l=0;l<c;l++){const u=Pe*l,f=2*u;Ee(f,o)&&(a[u+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,u=Ee(l,s);if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=Ie(o),p=Be(o,i),m=vo(o,i);e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,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/$e;for(let l=c-1;l>=0;l--){const u=l*Pe,f=u*2;if(Ee(f,a)){const m=We(u,s),x=tt(f,a);this.writePrimitiveRangeBounds(m,x,Rn,0),o.set(Rn,u)}else{const m=Ie(u),x=Be(u,s);for(let T=0;T<3;T++){const g=o[m+T],v=o[m+T+3],_=o[x+T],b=o[x+T+3];o[u+T]=g<_?g:_,o[u+T+3]=v>b?v:b}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),za),e.union(za)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const f=i;i=(p,m,x,T,g)=>f(p,m,x,T,g)?!0:o(p,m,this,s,x,T,a)}else i||(s?i=(f,p,m,x)=>o(f,p,this,s,m,x,a):i=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=Kh(this,f,n,i,t,l),c)break;l+=m.byteLength/$e}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Qh(this,e,t,i)}}function ef(){return typeof SharedArrayBuffer<"u"}function xo(r){return r.index?r.index.count:r.attributes.position.count}function Wr(r){return xo(r)/3}function tf(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function nf(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=tf(t,n);r.setIndex(new A.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function rf(r,e,t){const n=xo(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 sf(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Ia(r,e,t){const n=rf(r,e,t),i=sf(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=xo(r)/t,l=[];for(const p of i){const{offset:m,count:x}=p,T=m,g=isFinite(x)?x:c-m,v=m+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((p,m)=>p.pos!==m.pos?p.pos-m.pos:p.type==="end"?-1:1);let u=0,f=null;for(const p of l){const m=p.pos;u!==0&&m!==f&&s.push({offset:f,count:m-f}),u+=p.isStart?1:-1,f=m}return s}function rl(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.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:u,count:f}=r[l];for(let p=0;p<f;p++)o[c+p]=u+p;c+=f}return o}class sl extends il{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&&!ef())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={...el,...t},t[$r]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Ia(t,e.range,n),s=rl(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else nf(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}]:Ia(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 u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const of=(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,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,_;g!==0?v=(f*p-x*m)/g:v=0,_=(f+v*p)/m,a.x=v,a.y=_}})(),_o=(function(){const r=new A.Vector2,e=new A.Vector3,t=new A.Vector3;return function(i,s,a,o){of(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 u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),af=(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:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,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}})(),cf=["x","y","z"],Gt=1e-15,Ba=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 af(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],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const T=l.length(),g=f.length(),v=m.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 u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),_o(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();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,u=new A.Vector2,f=new A.Vector2;function p(b,M,C,P){const E=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?E.copy(b.plane.normal):E.copy(M.plane.normal);const z=b.satBounds,I=b.satAxes;for(let O=1;O<4;O++){const U=z[O],L=I[O];if(e.setFromPoints(L,M.points),U.isSeparated(e)||(a.copy(E).cross(L),e.setFromPoints(a,b.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],L=N[O];if(e.setFromPoints(L,b.points),U.isSeparated(e)||(a.crossVectors(E,L),e.setFromPoints(a,b.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 m(b,M,C,P,E,z,I,R,N,O,U){let L=I/(I-R);O.x=P+(E-P)*L,U.start.subVectors(M,b).multiplyScalar(L).add(b),L=I/(I-N),O.y=P+(z-P)*L,U.end.subVectors(C,b).multiplyScalar(L).add(b)}function x(b,M,C,P,E,z,I,R,N,O,U){if(E>0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else if(z>0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(R*N>0||I!=0)m(b.a,b.b,b.c,M,C,P,I,R,N,O,U);else if(R!=0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(N!=0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else return!0;return!1}function T(b,M,C,P){const E=M.degenerateSegment,z=b.plane.distanceToPoint(E.start),I=b.plane.distanceToPoint(E.end);return pt(z)?pt(I)?p(b,M,C,P):(C&&(C.start.copy(E.start),C.end.copy(E.start)),b.containsPoint(E.start)):pt(I)?(C&&(C.start.copy(E.end),C.end.copy(E.end)),b.containsPoint(E.end)):b.plane.intersectLine(E,n)!=null?(C&&(C.start.copy(n),C.end.copy(n)),b.containsPoint(n)):!1}function g(b,M,C){const P=M.a;return pt(b.plane.distanceToPoint(P))&&b.containsPoint(P)?(C&&(C.start.copy(P),C.end.copy(P)),!0):!1}function v(b,M,C){const P=b.degenerateSegment,E=M.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<Ba?(C&&(C.start.copy(E),C.end.copy(E)),!0):!1}function _(b,M,C,P){if(b.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const E=b.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,L=-(I.x*N.y-I.y*N.x)/O;if(U<0||U>1||L<0||L>1)return!1;const J=E.start.z+I.z*U,W=z.start.z+R.z*L;return pt(J-W)?(C&&(C.start.copy(E.start).addScaledVector(I,U),C.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return M.isDegenerateIntoPoint?v(b,M,C):T(M,b,C,P);else{if(b.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(b.a)<Ba?(C&&(C.start.copy(b.a),C.end.copy(b.a)),!0):!1:M.isDegenerateIntoSegment?v(M,b,C):g(M,b,C);if(M.isDegenerateIntoPoint)return g(b,M,C);if(M.isDegenerateIntoSegment)return T(b,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=_(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,L=R*O;if(U>0&&L>0)return!1;let J=z.distanceToPoint(M.a),W=z.distanceToPoint(M.b),K=z.distanceToPoint(M.c);pt(J)&&(J=0),pt(W)&&(W=0),pt(K)&&(K=0);const $=J*W,me=J*K;if($>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=cf[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(x(this,he,oe,Xe,U,L,R,N,O,u,o))return p(this,M,C,P);if(x(M,Ve,Je,Ye,$,me,J,W,K,f,c))return p(this,M,C,P);if(u.y<u.x){const xe=u.y;u.y=u.x,u.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(f.y<f.x){const xe=f.y;f.y=f.x,f.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<f.x||f.y<u.x?!1:(C&&(f.x>u.x?C.start.copy(c.start):C.start.copy(o.start),f.y<u.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 u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const T=this[m];a.closestPointToPoint(T,r),p=T.distanceToSquared(r),p<u&&(u=p,o&&o.copy(T),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const T=t[x],g=t[(x+1)%3];i.set(a[T],a[g]),_o(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();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 u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,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],u=s[c];if(r.setFromBox(l,t),u.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 p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const T=u[x];if(i.crossVectors(m,T),t.setFromPoints(i,e),n.setFromPoints(i,f),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 u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const _=v.distanceToSquared(i);if(_<x&&(x=_,c&&c.copy(v),l&&l.copy(i),_<u))return Math.sqrt(_)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){const b=(g+1)%3,M=(g+2)%3,C=v<<b|_<<M,P=1<<g|v<<b|_<<M,E=m[C],z=m[P];e[T].set(E,z);const R=r[g],N=r[b],O=r[M],U=t[T],L=U.start,J=U.end;L[R]=f[R],L[N]=v?f[N]:p[N],L[O]=_?f[O]:p[N],J[R]=p[R],J[N]=v?f[N]:p[N],J[O]=_?f[O]:p[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=_?p.z:f.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<x&&(x=b,c&&c.copy(n),l&&l.copy(i),b<u))return Math.sqrt(b)}for(let g=0;g<12;g++){const v=e[g];for(let _=0;_<12;_++){const b=t[_];_o(v,b,n,i);const M=n.distanceToSquared(i);if(M<x&&(x=M,c&&c.copy(n),l&&l.copy(i),M<u))return Math.sqrt(M)}}return Math.sqrt(x)}})();class lf extends So{constructor(){super(()=>new gt)}}const yt=new lf,Yn=new A.Vector3,Os=new A.Vector3;function uf(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:u=>(Yn.copy(e).clamp(u.min,u.max),Yn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Yn);const p=e.distanceToSquared(Yn);return p<o&&(Os.copy(Yn),o=p,c=f),p<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Os):t.point=Os.clone(),t.distance=l,t.faceIndex=c,t}const ur=parseInt(A.REVISION)>=169,hf=parseInt(A.REVISION)<=161,ln=new A.Vector3,un=new A.Vector3,hn=new A.Vector3,hr=new A.Vector2,fr=new A.Vector2,dr=new A.Vector2,Na=new A.Vector3,Ua=new A.Vector3,Da=new A.Vector3,Zn=new A.Vector3;function ff(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 Fa(r,e,t,n,i,s,a,o,c,l,u){ln.fromBufferAttribute(e,s),un.fromBufferAttribute(e,a),hn.fromBufferAttribute(e,o);const f=ff(r,ln,un,hn,Zn,c,l,u);if(f){if(n){hr.fromBufferAttribute(n,s),fr.fromBufferAttribute(n,a),dr.fromBufferAttribute(n,o),f.uv=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv);ur||(f.uv=m)}if(i){hr.fromBufferAttribute(i,s),fr.fromBufferAttribute(i,a),dr.fromBufferAttribute(i,o),f.uv1=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv1);ur||(f.uv1=m),hf&&(f.uv2=f.uv1)}if(t){Na.fromBufferAttribute(t,s),Ua.fromBufferAttribute(t,a),Da.fromBufferAttribute(t,o),f.normal=new A.Vector3;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,Na,Ua,Da,f.normal);f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1),ur||(f.normal=m)}const p={a:s,b:a,c:o,normal:new A.Vector3,materialIndex:0};if(A.Triangle.getNormal(ln,un,hn,p.normal),f.face=p,f.faceIndex=s,ur){const m=new A.Vector3;A.Triangle.getBarycoord(Zn,ln,un,hn,m),f.barycoord=m}}return f}function La(r){return r&&r.isMaterial?r.side:r}function Hr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:f,groups:p}=r;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:m,normal:x,uv:T,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let _=0,b=p.length;_<b;_++){const{start:M,count:C,materialIndex:P}=p[_];if(v>=M&&v<M+C){const E=La(e[P]),z=Fa(t,m,x,T,g,c,l,u,E,s,a);if(z)if(z.faceIndex=n,z.face.materialIndex=P,i)i.push(z);else return z}}}else{const v=La(e),_=Fa(t,m,x,T,g,c,l,u,v,s,a);if(_)if(_.faceIndex=n,_.face.materialIndex=0,i)i.push(_);else return _}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 df(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Hr(c,e,t,u,s,a,o)}function pf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function mf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function yf(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 u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=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<_&&(_=N),N>C&&(C=N),O<b&&(b=O),O>P&&(P=O),U<M&&(M=U),U>E&&(E=U)}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],L=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=L>W?L:W}return I}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],b=e[r+1],M=e[r+3+1],C=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(_-x)*f):(s=(_-x)*f,a=(v-x)*f),p>=0?(o=(b-T)*p,c=(M-T)*p):(o=(M-T)*p,c=(b-T)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(C-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(C-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function gf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Hr(c,e,t,p,s,a,o)}}function vf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Sf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function xf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),to(0,r,t,n,i,s,a),pe.clearBuffer()}function to(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);df(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&to(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&to(m,e,t,n,i,s,a)}}const _f=["x","y","z"];function bf(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=no(0,r,t,n,i,s);return pe.clearBuffer(),a}function no(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return pf(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=_f[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?no(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?no(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const pr=new A.Box3,An=new gt,On=new gt,Kn=new A.Matrix4,Va=new qe,mr=new qe;function Tf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=io(0,r,t,n);return pe.clearBuffer(),i}function io(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(),Va.set(t.boundingBox.min,t.boundingBox.max,n),i=Va),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(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:_=>mr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T*3,M=(g+T)*3;b<M;b+=3)if(we(On,b,f,p),On.needsUpdate=!0,_.intersectsTriangle(On))return!0;return!1}});{const v=Wr(t);for(let _=T*3,b=(g+T)*3;_<b;_+=3){we(An,_,f,p),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,m,x),On.needsUpdate=!0,An.intersectsTriangle(On))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,pr),!!(i.intersectsBox(pr)&&io(u,e,t,n,i)||(Se(f,s,pr),i.intersectsBox(pr)&&io(f,e,t,n,i)))}}const yr=new A.Matrix4,zs=new qe,Qn=new qe,Mf=new A.Vector3,Cf=new A.Vector3,wf=new A.Vector3,Pf=new A.Vector3;function Ef(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),zs.set(e.boundingBox.min,e.boundingBox.max,t),zs.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=Mf,T=Cf,g=null,v=null;i&&(g=wf,v=Pf);let _=1/0,b=null,M=null;return yr.copy(t).invert(),Qn.matrix.copy(yr),r.shapecast({boundsTraverseOrder:C=>zs.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&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<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){we(m,3*R,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let O=C,U=C+P;O<U;O++){we(p,3*O,l,c),p.needsUpdate=!0;const L=p.distanceToTriangle(m,x,g);if(L<_&&(T.copy(x),v&&v.copy(g),_=L,b=O,M=R),L<s)return!0}}}});{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){we(p,3*R,l,c),p.needsUpdate=!0;const O=p.distanceToTriangle(m,x,g);if(O<_&&(T.copy(x),v&&v.copy(g),_=O,b=R,M=z),O<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,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 kf(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 u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=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),L=i.getY(O),J=i.getZ(O);U<_&&(_=U),U>C&&(C=U),L<b&&(b=L),L>P&&(P=L),J<M&&(M=J),J>E&&(E=J)}}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],L=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=L>W?L:W}return I}}}function Rf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),ro(0,r,t,n,i,s,a),pe.clearBuffer()}function ro(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);gf(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&ro(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&ro(m,e,t,n,i,s,a)}}const Af=["x","y","z"];function Of(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=so(0,r,t,n,i,s);return pe.clearBuffer(),a}function so(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return vf(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=Af[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?so(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?so(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const gr=new A.Box3,zn=new gt,In=new gt,ei=new A.Matrix4,Ja=new qe,vr=new qe;function zf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=oo(0,r,t,n);return pe.clearBuffer(),i}function oo(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(),Ja.set(t.boundingBox.min,t.boundingBox.max,n),i=Ja),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(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:_=>vr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T,M=g+T;b<M;b++)if(we(In,3*e.resolveTriangleIndex(b),f,p),In.needsUpdate=!0,_.intersectsTriangle(In))return!0;return!1}});{const v=Wr(t);for(let _=T,b=g+T;_<b;_++){const M=e.resolveTriangleIndex(_);we(zn,3*M,f,p),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,m,x),In.needsUpdate=!0,zn.intersectsTriangle(In))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,gr),!!(i.intersectsBox(gr)&&oo(u,e,t,n,i)||(Se(f,s,gr),i.intersectsBox(gr)&&oo(f,e,t,n,i)))}}const Sr=new A.Matrix4,Is=new qe,ti=new qe,If=new A.Vector3,Bf=new A.Vector3,Nf=new A.Vector3,Uf=new A.Vector3;function Df(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Is.set(e.boundingBox.min,e.boundingBox.max,t),Is.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=If,T=Bf,g=null,v=null;i&&(g=Nf,v=Uf);let _=1/0,b=null,M=null;return Sr.copy(t).invert(),ti.matrix.copy(Sr),r.shapecast({boundsTraverseOrder:C=>Is.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&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<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){const O=E.resolveTriangleIndex(R);we(m,3*O,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=C,L=C+P;U<L;U++){const J=r.resolveTriangleIndex(U);we(p,3*J,l,c),p.needsUpdate=!0;const W=p.distanceToTriangle(m,x,g);if(W<_&&(T.copy(x),v&&v.copy(g),_=W,b=U,M=R),W<s)return!0}}}})}else{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){const O=r.resolveTriangleIndex(R);we(p,3*O,l,c),p.needsUpdate=!0;const U=p.distanceToTriangle(m,x,g);if(U<_&&(T.copy(x),v&&v.copy(g),_=U,b=R,M=z),U<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,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 ja(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,Ga=new A.Vector3,$a=new A.Matrix4,Wa=new A.Vector3,Bs=["getX","getY","getZ"];class Vn extends sl{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,[$r]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new A.BufferAttribute(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const f=l[u],p=new Uint32Array(f),m=new Uint16Array(f);for(let x=0,T=f.byteLength/$e;x<T;x++){const g=Pe*x,v=2*g;Ee(v,m)||(p[g+6]=p[g+6]/Pe-x)}}}}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 u=l+0,f=l+1,p=l+2;o&&(u=o[u],f=o[f],p=o[p]);for(let m=0;m<3;m++){const x=a[Bs[m]](u),T=a[Bs[m]](f),g=a[Bs[m]](p);let v=x;T<v&&(v=T),g<v&&(v=g);let _=x;T>_&&(_=T),g>_&&(_=g),t[n+m]=v,t[n+m+3]=_}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,u=a.offset||0;let f=3;a.isInterleavedBufferAttribute&&(f=a.data.stride);const p=["getX","getY","getZ"],m=n.offset;for(let x=e,T=e+t;x<T;x++){const v=(s?s[x]:x)*3,_=(x-m)*6;let b=v+0,M=v+1,C=v+2;o&&(b=o[b],M=o[M],C=o[C]),c||(b=b*f+u,M=M*f+u,C=C*f+u);for(let P=0;P<3;P++){let E,z,I;c?(E=a[p[P]](b),z=a[p[P]](M),I=a[p[P]](C)):(E=l[b+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[_+U+0]=R+O,n[_+U+1]=O+(Math.abs(R)+O)*kr}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;$a.copy(e.matrixWorld).invert(),_r.copy(t.ray).applyMatrix4($a),Wa.setFromMatrixScale(e.matrixWorld),Ga.copy(_r.direction).multiply(Wa);const s=Ga.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(_r,i,a,o);c=ja(c,e,t),c&&n.push(c)}else{const c=this.raycast(_r,i,a,o);for(let l=0,u=c.length;l<u;l++){const f=ja(c[l],e,t);f&&n.push(f)}}return n}refit(e=null){return(this.indirect?kf:yf)(this,e)}raycast(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?Rf:xf;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?Of:bf;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?zf:Tf;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?Sf:mf});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?x=>{const T=this.resolveTriangleIndex(x);we(a,T*3,o,c)}:x=>{we(a,x*3,o,c)},u=yt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const T=e.resolveTriangleIndex(x);we(u,T*3,f,p)}:x=>{we(u,x*3,f,p)};if(s){if(!(e instanceof Vn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const x=(T,g,v,_,b,M,C,P)=>{for(let E=v,z=v+_;E<z;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=T,R=T+g;I<R;I++)if(l(I),a.needsUpdate=!0,s(a,u,I,E,b,M,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,_,b,M,C,P,E){return T(g,v,_,b,M,C,P,E)?!0:x(g,v,_,b,M,C,P,E)}}else i=x}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?Df:Ef)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return uf(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 Ff(r,e){if(this.isBatchedMesh)Lf.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 Lf(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 u=n[c].geometryIndex;if(De.geometry.boundsTree=t[u],this.getMatrixAt(c,De.matrixWorld).premultiply(s),!De.geometry.boundsTree){this.getBoundingBoxAt(u,De.geometry.boundingBox),this.getBoundingSphereAt(u,De.geometry.boundingSphere);const f=i[u];De.geometry.setDrawRange(f.start,f.count)}De.raycast(r,br);for(let f=0,p=br.length;f<p;f++){const m=br[f];m.object=this,m.batchId=c,e.push(m)}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 Vf(r={}){const{type:e=Vn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const fn=new A.Vector3,dn=new A.Vector3,pn=new A.Vector3,Ha=new A.Vector4,Tr=new A.Vector3,Ns=new A.Vector3,qa=new A.Vector4,Xa=new A.Vector4,Mr=new A.Matrix4,Ya=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 ol(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 Jf(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 Za(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;qa.fromBufferAttribute(i.attributes.skinIndex,e),Xa.fromBufferAttribute(i.attributes.skinWeight,e),Mr.elements.fill(0);for(let o=0;o<4;o++){const c=Xa.getComponent(o);if(c!==0){const l=qa.getComponent(o);Ya.multiplyMatrices(s[l].matrixWorld,a[l]),Jf(Mr,Ya,c)}}return Mr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Mr),t}function Us(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&&(Ns.fromBufferAttribute(c,n),t?Tr.addScaledVector(Ns,o):Tr.addScaledVector(Ns.sub(i),o))}i.add(Tr)}function jf(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 u=0;u<r.length;++u){const f=r[u];let p=0;if(n!==(f.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 m in f.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new A.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const T=r[x],g=T.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=T.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const T in f)x+=f[T].count;t.setAttribute(u,oi(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,T=f.length;x<T;x++){const g=f[x];a[x]!==!0&&ol(g,p,m),m+=g.count}}return t}function Gf(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 $f(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),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class Wf{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&&Gf(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Hf{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],u=s[o],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new Wf(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 jf(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,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=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 _=0,b=o.position.count;_<b;_++)fn.fromBufferAttribute(l,_),u&&dn.fromBufferAttribute(u,_),f&&(Ha.fromBufferAttribute(f,_),pn.fromBufferAttribute(f,_)),g&&(p&&Us(p,g,T,_,fn),m&&Us(m,g,T,_,dn),x&&Us(x,g,T,_,pn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,fn),u&&Za(e,_,dn),f&&Za(e,_,pn)),i&&fn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,fn.x,fn.y,fn.z),u&&(i&&dn.applyNormalMatrix(v),c.normal.setXYZ(_,dn.x,dn.y,dn.z)),f&&(i&&pn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,pn.x,pn.y,pn.z,Ha.w));for(const _ in this.attributes){const b=this.attributes[_];b==="position"||b==="tangent"||b==="normal"||!(b in o)||(c[b]||t.setAttribute(b,oi(o[b])),ni(o[b],c[b]),ol(o[b],c[b]))}return e.matrixWorld.determinant()<0&&$f(t),t}}const qf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Zc,BVH:il,CENTER:go,CONTAINED:Ys,ExtendedTriangle:gt,GeometryBVH:sl,MeshBVH:Vn,OrientedBox:qe,SAH:Kc,SKIP_GENERATION:$r,StaticGeometryGenerator:Hf,acceleratedRaycast:Ff,computeBoundsTree:Vf,generateIndirectBuffer:rl},Symbol.toStringTag,{value:"Module"}));class Xf{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"},mn="KHR_animation_pointer",Yf={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear,STEP:A.InterpolateDiscrete};class Zf{constructor(e){this.name=mn,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){Qf();const t=e.target,n=t.extensions&&t.extensions[mn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=mt.node,a;if(n){const c=t.extensions[mn];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 u=("/materials/"+a.toString()+"/").length,f=l.substring(0,u);switch(i=l.substring(u),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=f+i;break;case mt.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),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=m+i;break;case mt.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),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[mn].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[mn]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[mn].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof A.SkinnedMesh&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,T){try{const g=T.split(".").filter(Boolean),_=g[g.length-1].replace(/\[.*\]$/,"");return _ in x?typeof x[_]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(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?Yf[i.interpolation]:A.InterpolateLinear;let _=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(_=_.map(M=>M/Math.PI*180)),g&&(_=_.map(M=>M>0));const b=new T(o,t.array,_,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),c.push(b),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const M=new Float32Array(_.length/4);for(let P=0,E=_.length/4;P<E;P+=1)M[P]=_[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,M,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),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=[],u=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],T=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,_=s.parameters!==void 0?s.parameters[T.output]:T.output;let b=t.loadAnimationTargetFromChannelWithAnimationPointer(x);b||(b=t.loadAnimationTargetFromChannel(x)),o.push(b),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(T),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],T=p[2],g=p[3],v=p[4],_=[];for(let b=0,M=m.length;b<M;b++){const C=m[b],P=x[b],E=T[b],z=g[b],I=v[b];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++)_.push(R[N])}return new A.AnimationClip(a,void 0,_)})}}let Ka=!1,Kf=null;function Qf(){if(Ka)return;Ka=!0;const r=Kf||=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(mn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const ed=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Zf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=Vc;exports.BatchedParticleRenderer=Ih;exports.Builder=ao;exports.ByteBuffer=li;exports.ConstantColor=vn;exports.ConstantValue=ee;exports.Matrix4=Et;exports.MeshBVH=Vn;exports.MotionController=Al;exports.ParticleSystem=Fr;exports.SIZE_PREFIX_LENGTH=ec;exports.TrailParticle=Ur;exports.Vector4=at;exports.WorkerBase=Xf;exports.bundler=lu;exports.createNoise4D=Nh;exports.fetchProfile=wl;exports.index=Jh;exports.index$1=qf;exports.index$2=ed;exports.md5=Cu;exports.v5=xu;
|