@needle-tools/engine 4.4.0-beta → 4.4.0-beta.10
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 +65 -2
- package/dist/assets/generateMeshBVH.worker-b7788939.js +25 -0
- package/dist/needle-engine.bundle.js +6808 -6645
- package/dist/needle-engine.bundle.light.js +7071 -6908
- package/dist/needle-engine.bundle.light.min.js +169 -139
- package/dist/needle-engine.bundle.light.umd.cjs +173 -143
- package/dist/needle-engine.bundle.min.js +169 -139
- package/dist/needle-engine.bundle.umd.cjs +172 -142
- package/dist/needle-engine.d.ts +0 -9
- package/dist/needle-engine.js +468 -467
- package/dist/needle-engine.light.d.ts +0 -9
- package/dist/needle-engine.light.js +468 -467
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/postprocessing.js +1673 -1527
- package/dist/postprocessing.light.js +1673 -1527
- package/dist/postprocessing.light.min.js +80 -66
- package/dist/postprocessing.light.umd.cjs +83 -69
- package/dist/postprocessing.min.js +80 -66
- package/dist/postprocessing.umd.cjs +83 -69
- package/dist/vendor.js +5109 -5123
- package/dist/vendor.light.js +5109 -5123
- package/dist/vendor.light.min.js +84 -84
- package/dist/vendor.light.umd.cjs +78 -78
- package/dist/vendor.min.js +84 -84
- package/dist/vendor.umd.cjs +78 -78
- package/lib/engine/codegen/register_types.js +2 -0
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_components.js +3 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +10 -1
- package/lib/engine/engine_context.js +33 -12
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_element.js +12 -10
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_gameobject.js +5 -0
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_license.d.ts +2 -0
- package/lib/engine/engine_license.js +103 -62
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +40 -24
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_physics_rapier.js +10 -9
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +6 -2
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.js +1 -1
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/js-extensions/RGBAColor.d.ts +1 -0
- package/lib/engine/js-extensions/RGBAColor.js +48 -0
- package/lib/engine/js-extensions/RGBAColor.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +4 -3
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +6 -6
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +4 -0
- package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/xr/NeedleXRController.js +2 -3
- package/lib/engine/xr/NeedleXRController.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +12 -12
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/AudioSource.js +7 -0
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Camera.js +18 -12
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +8 -14
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/GroundProjection.js +1 -1
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/NeedleMenu.js +1 -1
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +3 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +1 -0
- package/lib/engine-components/ReflectionProbe.js +16 -9
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +28 -7
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SyncedTransform.d.ts +6 -0
- package/lib/engine-components/SyncedTransform.js +10 -5
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/USDZUI.js +2 -1
- package/lib/engine-components/export/usdz/extensions/USDZUI.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +0 -1
- package/lib/engine-components/ui/BaseUIComponent.js +1 -1
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +1 -1
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js +1 -0
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/RaycastUtils.js +1 -1
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +2 -2
- package/lib/engine-components/ui/RectTransform.js +9 -6
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/ui/Symbols.d.ts +1 -0
- package/lib/engine-components/ui/Symbols.js +2 -0
- package/lib/engine-components/ui/Symbols.js.map +1 -0
- package/lib/engine-components/ui/Utils.js +1 -1
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components/utils/EnvironmentScene.d.ts +1 -1
- package/lib/engine-components/utils/EnvironmentScene.js +1 -1
- package/lib/engine-components/utils/EnvironmentScene.js.map +1 -1
- package/package.json +3 -3
- package/plugins/common/buildinfo.js +1 -0
- package/plugins/common/cloud.js +2 -0
- package/plugins/common/license.js +174 -33
- package/plugins/types/userconfig.d.ts +5 -0
- package/plugins/vite/build-pipeline.js +4 -3
- package/plugins/vite/dependencies.js +17 -7
- package/plugins/vite/facebook-instant-games.js +7 -4
- package/plugins/vite/index.js +1 -1
- package/src/engine/codegen/register_types.ts +2 -0
- package/src/engine/engine_addressables.ts +3 -2
- package/src/engine/engine_components.ts +2 -1
- package/src/engine/engine_context.ts +36 -12
- package/src/engine/engine_element.ts +10 -9
- package/src/engine/engine_gameobject.ts +7 -0
- package/src/engine/engine_license.ts +116 -67
- package/src/engine/engine_networking_blob.ts +47 -26
- package/src/engine/engine_physics_rapier.ts +10 -12
- package/src/engine/engine_serialization_core.ts +6 -1
- package/src/engine/engine_utils_screenshot.ts +1 -1
- package/src/engine/js-extensions/RGBAColor.ts +50 -0
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +6 -6
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +6 -6
- package/src/engine/webcomponents/needle menu/needle-menu.ts +13 -2
- package/src/engine/xr/NeedleXRController.ts +2 -3
- package/src/engine/xr/NeedleXRSession.ts +12 -12
- package/src/engine-components/AudioSource.ts +8 -3
- package/src/engine-components/Camera.ts +34 -22
- package/src/engine-components/CameraUtils.ts +8 -16
- package/src/engine-components/GroundProjection.ts +1 -1
- package/src/engine-components/NeedleMenu.ts +1 -1
- package/src/engine-components/OrbitControls.ts +2 -1
- package/src/engine-components/ReflectionProbe.ts +15 -8
- package/src/engine-components/SceneSwitcher.ts +28 -11
- package/src/engine-components/SyncedTransform.ts +11 -6
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/export/usdz/extensions/USDZUI.ts +2 -2
- package/src/engine-components/ui/BaseUIComponent.ts +1 -1
- package/src/engine-components/ui/EventSystem.ts +1 -1
- package/src/engine-components/ui/Graphic.ts +1 -1
- package/src/engine-components/ui/RaycastUtils.ts +1 -1
- package/src/engine-components/ui/RectTransform.ts +10 -7
- package/src/engine-components/ui/Symbols.ts +2 -0
- package/src/engine-components/ui/Utils.ts +2 -1
- package/src/engine-components/utils/EnvironmentScene.ts +1 -1
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";const X=require("./three.light.umd.cjs"),ot={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function Vr(s){const t=await fetch(s);if(t.ok)return t.json();throw new Error(t.statusText)}async function Fc(s){if(!s)throw new Error("No basePath supplied");return await Vr(`${s}/profilesList.json`)}async function Qc(s,t,e=null,i=!0){if(!s)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const n=await Fc(t);let o;if(s.profiles.some(c=>{const a=n[c];return a&&(o={profileId:c,profilePath:`${t}/${a.path}`,deprecated:!!a.deprecated}),!!o}),!o){if(!e)throw new Error("No matching profile name found");const c=n[e];if(!c)throw new Error(`No matching profile name found and default profile "${e}" missing.`);o={profileId:e,profilePath:`${t}/${c.path}`,deprecated:!!c.deprecated}}const r=await Vr(o.profilePath);let l;if(i){let c;if(s.handedness==="any"?c=r.layouts[Object.keys(r.layouts)[0]]:c=r.layouts[s.handedness],!c)throw new Error(`No matching handedness, ${s.handedness}, in profile ${o.profileId}`);c.assetPath&&(l=o.profilePath.replace("profile.json",c.assetPath))}return{profile:r,assetPath:l}}const wc={xAxis:0,yAxis:0,button:0,state:ot.ComponentState.DEFAULT};function Bc(s=0,t=0){let e=s,i=t;if(Math.sqrt(s*s+t*t)>1){const r=Math.atan2(t,s);e=Math.cos(r),i=Math.sin(r)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class Ec{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===ot.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(wc)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:n}){const{normalizedXAxis:o,normalizedYAxis:r}=Bc(t,e);switch(this.componentProperty){case ot.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?o:.5;break;case ot.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?r:.5;break;case ot.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case ot.ComponentProperty.STATE:this.valueNodeProperty===ot.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(n):this.value=this.states.includes(n)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class jc{constructor(t,e){if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(i=>{const n=new Ec(e.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:ot.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(t){if(this.values.state=ot.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){const e=t.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=ot.ComponentState.PRESSED:(e.touched||this.values.button>ot.ButtonTouchThreshold)&&(this.values.state=ot.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.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===ot.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>ot.AxisTouchThreshold&&(this.values.state=ot.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.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===ot.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>ot.AxisTouchThreshold&&(this.values.state=ot.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Oc{constructor(t,e,i){if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(n=>{const o=this.layoutDescription.components[n];this.components[n]=new jc(n,o)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const rn=2,wt=4,ee=4,Rr=4,ae=new Int32Array(2),bo=new Float32Array(ae.buffer),yo=new Float64Array(ae.buffer),as=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class se{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?se.ZERO:new se(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}se.ZERO=new se(0,0);var vn;(function(s){s[s.UTF8_BYTES=1]="UTF8_BYTES",s[s.UTF16_STRING=2]="UTF16_STRING"})(vn||(vn={}));class gi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new gi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new se(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new se(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return ae[0]=this.readInt32(t),bo[0]}readFloat64(t){return ae[as?0:1]=this.readInt32(t),ae[as?1:0]=this.readInt32(t+4),yo[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){bo[0]=e,this.writeInt32(t,ae[0])}writeFloat64(t,e){yo[0]=e,this.writeInt32(t,ae[as?0:1]),this.writeInt32(t+4,ae[as?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+wt+ee)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<ee;e++)t+=String.fromCharCode(this.readInt8(this.position_+wt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let n="",o=0;if(t+=wt,e===vn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;o<i;){let r;const l=this.readUint8(t+o++);if(l<192)r=l;else{const c=this.readUint8(t+o++);if(l<224)r=(l&31)<<6|c&63;else{const a=this.readUint8(t+o++);if(l<240)r=(l&15)<<12|(c&63)<<6|a&63;else{const d=this.readUint8(t+o++);r=(l&7)<<18|(c&63)<<12|(a&63)<<6|d&63}}}r<65536?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode((r>>10)+55296,(r&1024-1)+56320))}return n}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+wt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let e=0;e<ee;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+wt+e))return!1;return!0}createLong(t,e){return se.create(t,e)}createScalarList(t,e){const i=[];for(let n=0;n<e;++n)t(n)!==null&&i.push(t(n));return i}createObjList(t,e){const i=[];for(let n=0;n<e;++n){const o=t(n);o!==null&&i.push(o.unpack())}return i}}class to{constructor(t){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 e;t?e=t:e=1024,this.bb=gi.allocate(e),this.space=e}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(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){const n=this.bb.capacity();this.bb=to.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||!e.equals(i))&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=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(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=e<<1,n=gi.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(wt,0),this.writeInt32(this.offset()-t+wt)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=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 t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const n=2;this.addInt16(t-this.object_start);const o=(i+n)*rn;this.addInt16(o);let r=0;const l=this.space;t:for(e=0;e<this.vtables.length;e++){const c=this.bb.capacity()-this.vtables[e];if(o==this.bb.readInt16(c)){for(let a=rn;a<o;a+=rn)if(this.bb.readInt16(l+a)!=this.bb.readInt16(c+a))continue t;r=this.vtables[e];break}}return r?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,r-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const n=i?Rr:0;if(e){const o=e;if(this.prep(this.minalign,wt+ee+n),o.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let r=ee-1;r>=0;r--)this.writeInt8(o.charCodeAt(r))}this.prep(this.minalign,wt+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(!(this.bb.readInt16(n+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(wt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i<t.length;){let n;const o=t.charCodeAt(i++);if(o<55296||o>=56320)n=o;else{const r=t.charCodeAt(i++);n=(o<<10)+r+(65536-56623104-56320)}n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(n&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,n=this.space,o=this.bb.bytes();i<e.length;i++)o[n++]=e[i];return this.endVector()}createLong(t,e){return se.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let i=0;i<t.length;++i){const n=t[i];if(n!==null)e.push(this.createObjectOffset(n));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}function qs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xr={exports:{}};(function(s){var t={};t.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),t.useArrayBufferView=!t.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),s.exports.binaryFeatures=t;var e=s.exports.BlobBuilder;typeof window<"u"&&(e=s.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(n){typeof n=="number"?this._pieces.push(n):(this.flush(),this._parts.push(n))},i.prototype.flush=function(){if(this._pieces.length>0){var n=new Uint8Array(this._pieces);t.useArrayBufferView||(n=n.buffer),this._parts.push(n),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var n=new e,o=0,r=this._parts.length;o<r;o++)n.append(this._parts[o]);return n.getBlob()}else return new Blob(this._parts)},s.exports.BufferBuilder=i})(xr);var Lr=xr.exports,Dc=Lr.BufferBuilder,Go=Lr.binaryFeatures,_c={unpack:function(s){var t=new ht(s);return t.unpack()},pack:function(s){var t=new ut;t.pack(s);var e=t.getBuffer();return e}},Ac=_c;function ht(s){this.index=0,this.dataBuffer=s,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}ht.prototype.unpack=function(){var s=this.unpack_uint8();if(s<128)return s;if((s^224)<32)return(s^224)-32;var t;if((t=s^160)<=15)return this.unpack_raw(t);if((t=s^176)<=15)return this.unpack_string(t);if((t=s^144)<=15)return this.unpack_array(t);if((t=s^128)<=15)return this.unpack_map(t);switch(s){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 t=this.unpack_uint16(),this.unpack_string(t);case 217:return t=this.unpack_uint32(),this.unpack_string(t);case 218:return t=this.unpack_uint16(),this.unpack_raw(t);case 219:return t=this.unpack_uint32(),this.unpack_raw(t);case 220:return t=this.unpack_uint16(),this.unpack_array(t);case 221:return t=this.unpack_uint32(),this.unpack_array(t);case 222:return t=this.unpack_uint16(),this.unpack_map(t);case 223:return t=this.unpack_uint32(),this.unpack_map(t)}};ht.prototype.unpack_uint8=function(){var s=this.dataView[this.index]&255;return this.index++,s};ht.prototype.unpack_uint16=function(){var s=this.read(2),t=(s[0]&255)*256+(s[1]&255);return this.index+=2,t};ht.prototype.unpack_uint32=function(){var s=this.read(4),t=((s[0]*256+s[1])*256+s[2])*256+s[3];return this.index+=4,t};ht.prototype.unpack_uint64=function(){var s=this.read(8),t=((((((s[0]*256+s[1])*256+s[2])*256+s[3])*256+s[4])*256+s[5])*256+s[6])*256+s[7];return this.index+=8,t};ht.prototype.unpack_int8=function(){var s=this.unpack_uint8();return s<128?s:s-256};ht.prototype.unpack_int16=function(){var s=this.unpack_uint16();return s<32768?s:s-65536};ht.prototype.unpack_int32=function(){var s=this.unpack_uint32();return s<Math.pow(2,31)?s:s-Math.pow(2,32)};ht.prototype.unpack_int64=function(){var s=this.unpack_uint64();return s<Math.pow(2,63)?s:s-Math.pow(2,64)};ht.prototype.unpack_raw=function(s){if(this.length<this.index+s)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+s+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+s);return this.index+=s,t};ht.prototype.unpack_string=function(s){for(var t=this.read(s),e=0,i="",n,o;e<s;)n=t[e],n<128?(i+=String.fromCharCode(n),e++):(n^192)<32?(o=(n^192)<<6|t[e+1]&63,i+=String.fromCharCode(o),e+=2):(o=(n&15)<<12|(t[e+1]&63)<<6|t[e+2]&63,i+=String.fromCharCode(o),e+=3);return this.index+=s,i};ht.prototype.unpack_array=function(s){for(var t=new Array(s),e=0;e<s;e++)t[e]=this.unpack();return t};ht.prototype.unpack_map=function(s){for(var t={},e=0;e<s;e++){var i=this.unpack(),n=this.unpack();t[i]=n}return t};ht.prototype.unpack_float=function(){var s=this.unpack_uint32(),t=s>>31,e=(s>>23&255)-127,i=s&8388607|8388608;return(t===0?1:-1)*i*Math.pow(2,e-23)};ht.prototype.unpack_double=function(){var s=this.unpack_uint32(),t=this.unpack_uint32(),e=s>>31,i=(s>>20&2047)-1023,n=s&1048575|1048576,o=n*Math.pow(2,i-20)+t*Math.pow(2,i-52);return(e===0?1:-1)*o};ht.prototype.read=function(s){var t=this.index;if(t+s<=this.length)return this.dataView.subarray(t,t+s);throw new Error("BinaryPackFailure: read index out of range")};function ut(){this.bufferBuilder=new Dc}ut.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()};ut.prototype.pack=function(s){var t=typeof s;if(t==="string")this.pack_string(s);else if(t==="number")Math.floor(s)===s?this.pack_integer(s):this.pack_double(s);else if(t==="boolean")s===!0?this.bufferBuilder.append(195):s===!1&&this.bufferBuilder.append(194);else if(t==="undefined")this.bufferBuilder.append(192);else if(t==="object")if(s===null)this.bufferBuilder.append(192);else{var e=s.constructor;if(e==Array)this.pack_array(s);else if(e==Blob||e==File||s instanceof Blob||s instanceof File)this.pack_bin(s);else if(e==ArrayBuffer)Go.useArrayBufferView?this.pack_bin(new Uint8Array(s)):this.pack_bin(s);else if("BYTES_PER_ELEMENT"in s)Go.useArrayBufferView?this.pack_bin(new Uint8Array(s.buffer)):this.pack_bin(s.buffer);else if(e==Object||e.toString().startsWith("class"))this.pack_object(s);else if(e==Date)this.pack_string(s.toString());else if(typeof s.toBinaryPack=="function")this.bufferBuilder.append(s.toBinaryPack());else throw new Error('Type "'+e.toString()+'" not yet supported')}else throw new Error('Type "'+t+'" not yet supported');this.bufferBuilder.flush()};ut.prototype.pack_bin=function(s){var t=s.length||s.byteLength||s.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(s)};ut.prototype.pack_string=function(s){var t=$c(s);if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(s)};ut.prototype.pack_array=function(s){var t=s.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(t);else throw new Error("Invalid length");for(var e=0;e<t;e++)this.pack(s[e])};ut.prototype.pack_integer=function(s){if(s>=-32&&s<=127)this.bufferBuilder.append(s&255);else if(s>=0&&s<=255)this.bufferBuilder.append(204),this.pack_uint8(s);else if(s>=-128&&s<=127)this.bufferBuilder.append(208),this.pack_int8(s);else if(s>=0&&s<=65535)this.bufferBuilder.append(205),this.pack_uint16(s);else if(s>=-32768&&s<=32767)this.bufferBuilder.append(209),this.pack_int16(s);else if(s>=0&&s<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(s);else if(s>=-2147483648&&s<=2147483647)this.bufferBuilder.append(210),this.pack_int32(s);else if(s>=-9223372036854776e3&&s<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(s);else if(s>=0&&s<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(s);else throw new Error("Invalid integer")};ut.prototype.pack_double=function(s){var t=0;s<0&&(t=1,s=-s);var e=Math.floor(Math.log(s)/Math.LN2),i=s/Math.pow(2,e)-1,n=Math.floor(i*Math.pow(2,52)),o=Math.pow(2,32),r=t<<31|e+1023<<20|n/o&1048575,l=n%o;this.bufferBuilder.append(203),this.pack_int32(r),this.pack_int32(l)};ut.prototype.pack_object=function(s){var t=Object.keys(s),e=t.length;if(e<=15)this.pack_uint8(128+e);else if(e<=65535)this.bufferBuilder.append(222),this.pack_uint16(e);else if(e<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(e);else throw new Error("Invalid length");for(var i in s)s.hasOwnProperty(i)&&(this.pack(i),this.pack(s[i]))};ut.prototype.pack_uint8=function(s){this.bufferBuilder.append(s)};ut.prototype.pack_uint16=function(s){this.bufferBuilder.append(s>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_uint32=function(s){var t=s&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)};ut.prototype.pack_uint64=function(s){var t=s/Math.pow(2,32),e=s%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};ut.prototype.pack_int8=function(s){this.bufferBuilder.append(s&255)};ut.prototype.pack_int16=function(s){this.bufferBuilder.append((s&65280)>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_int32=function(s){this.bufferBuilder.append(s>>>24&255),this.bufferBuilder.append((s&16711680)>>>16),this.bufferBuilder.append((s&65280)>>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_int64=function(s){var t=Math.floor(s/Math.pow(2,32)),e=s%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};function qc(s){var t=s.charCodeAt(0);return t<=2047?"00":t<=65535?"000":t<=2097151?"0000":t<=67108863?"00000":"000000"}function $c(s){return s.length>600?new Blob([s]).size:s.replace(/[^\u0000-\u007F]/g,qc).length}const Zo=qs(Ac);let Sr=!0,Wr=!0;function fi(s,t,e){const i=s.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function qe(s,t,e){if(!s.RTCPeerConnection)return;const i=s.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(r,l){if(r!==t)return n.apply(this,arguments);const c=a=>{const d=e(a);d&&(l.handleEvent?l.handleEvent(d):l(d))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(l,c),n.apply(this,[r,c])};const o=i.removeEventListener;i.removeEventListener=function(r,l){if(r!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(l))return o.apply(this,arguments);const c=this._eventMap[t].get(l);return this._eventMap[t].delete(l),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[r,c])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(r){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),r&&this.addEventListener(t,this["_on"+t]=r)},enumerable:!0,configurable:!0})}function tl(s){return typeof s!="boolean"?new Error("Argument type: "+typeof s+". Please use a boolean."):(Sr=s,s?"adapter.js logging disabled":"adapter.js logging enabled")}function el(s){return typeof s!="boolean"?new Error("Argument type: "+typeof s+". Please use a boolean."):(Wr=!s,"adapter.js deprecation warnings "+(s?"disabled":"enabled"))}function eo(){if(typeof window=="object"){if(Sr)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function $s(s,t){Wr&&console.warn(s+" is deprecated, please use "+t+" instead.")}function il(s){const t={browser:null,version:null};if(typeof s>"u"||!s.navigator)return t.browser="Not a browser.",t;const{navigator:e}=s;if(e.mozGetUserMedia)t.browser="firefox",t.version=fi(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||s.isSecureContext===!1&&s.webkitRTCPeerConnection&&!s.RTCIceGatherer)t.browser="chrome",t.version=fi(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=fi(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(s.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=fi(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=s.RTCRtpTransceiver&&"currentDirection"in s.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function Xo(s){return Object.prototype.toString.call(s)==="[object Object]"}function gr(s){return Xo(s)?Object.keys(s).reduce(function(t,e){const i=Xo(s[e]),n=i?gr(s[e]):s[e],o=i&&!Object.keys(n).length;return n===void 0||o?t:Object.assign(t,{[e]:n})},{}):s}function Kn(s,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?Kn(s,s.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(n=>{Kn(s,s.get(n),e)})}))}function fo(s,t,e){const i=e?"outbound-rtp":"inbound-rtp",n=new Map;if(t===null)return n;const o=[];return s.forEach(r=>{r.type==="track"&&r.trackIdentifier===t.id&&o.push(r)}),o.forEach(r=>{s.forEach(l=>{l.type===i&&l.trackId===r.id&&Kn(s,l,n)})}),n}const Vo=eo;function Cr(s,t){const e=s&&s.navigator;if(!e.mediaDevices)return;const i=function(l){if(typeof l!="object"||l.mandatory||l.optional)return l;const c={};return Object.keys(l).forEach(a=>{if(a==="require"||a==="advanced"||a==="mediaSource")return;const d=typeof l[a]=="object"?l[a]:{ideal:l[a]};d.exact!==void 0&&typeof d.exact=="number"&&(d.min=d.max=d.exact);const h=function(u,p){return u?u+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(d.ideal!==void 0){c.optional=c.optional||[];let u={};typeof d.ideal=="number"?(u[h("min",a)]=d.ideal,c.optional.push(u),u={},u[h("max",a)]=d.ideal,c.optional.push(u)):(u[h("",a)]=d.ideal,c.optional.push(u))}d.exact!==void 0&&typeof d.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",a)]=d.exact):["min","max"].forEach(u=>{d[u]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(u,a)]=d[u])})}),l.advanced&&(c.optional=(c.optional||[]).concat(l.advanced)),c},n=function(l,c){if(t.version>=61)return c(l);if(l=JSON.parse(JSON.stringify(l)),l&&typeof l.audio=="object"){const a=function(d,h,u){h in d&&!(u in d)&&(d[u]=d[h],delete d[h])};l=JSON.parse(JSON.stringify(l)),a(l.audio,"autoGainControl","googAutoGainControl"),a(l.audio,"noiseSuppression","googNoiseSuppression"),l.audio=i(l.audio)}if(l&&typeof l.video=="object"){let a=l.video.facingMode;a=a&&(typeof a=="object"?a:{ideal:a});const d=t.version<66;if(a&&(a.exact==="user"||a.exact==="environment"||a.ideal==="user"||a.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!d)){delete l.video.facingMode;let h;if(a.exact==="environment"||a.ideal==="environment"?h=["back","rear"]:(a.exact==="user"||a.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(u=>{u=u.filter(m=>m.kind==="videoinput");let p=u.find(m=>h.some(b=>m.label.toLowerCase().includes(b)));return!p&&u.length&&h.includes("back")&&(p=u[u.length-1]),p&&(l.video.deviceId=a.exact?{exact:p.deviceId}:{ideal:p.deviceId}),l.video=i(l.video),Vo("chrome: "+JSON.stringify(l)),c(l)})}l.video=i(l.video)}return Vo("chrome: "+JSON.stringify(l)),c(l)},o=function(l){return t.version>=64?l:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[l.name]||l.name,message:l.message,constraint:l.constraint||l.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},r=function(l,c,a){n(l,d=>{e.webkitGetUserMedia(d,c,h=>{a&&a(o(h))})})};if(e.getUserMedia=r.bind(e),e.mediaDevices.getUserMedia){const l=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(c){return n(c,a=>l(a).then(d=>{if(a.audio&&!d.getAudioTracks().length||a.video&&!d.getVideoTracks().length)throw d.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return d},d=>Promise.reject(o(d))))}}}function sl(s,t){if(!(s.navigator.mediaDevices&&"getDisplayMedia"in s.navigator.mediaDevices)&&s.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}s.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(n=>{const o=i.video&&i.video.width,r=i.video&&i.video.height,l=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:l||3}},o&&(i.video.mandatory.maxWidth=o),r&&(i.video.mandatory.maxHeight=r),s.navigator.mediaDevices.getUserMedia(i)})}}}function zr(s){s.MediaStream=s.MediaStream||s.webkitMediaStream}function vr(s){if(typeof s=="object"&&s.RTCPeerConnection&&!("ontrack"in s.RTCPeerConnection.prototype)){Object.defineProperty(s.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=s.RTCPeerConnection.prototype.setRemoteDescription;s.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",n=>{let o;s.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(l=>l.track&&l.track.id===n.track.id):o={track:n.track};const r=new Event("track");r.track=n.track,r.receiver=o,r.transceiver={receiver:o},r.streams=[i.stream],this.dispatchEvent(r)}),i.stream.getTracks().forEach(n=>{let o;s.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(l=>l.track&&l.track.id===n.id):o={track:n};const r=new Event("track");r.track=n,r.receiver=o,r.transceiver={receiver:o},r.streams=[i.stream],this.dispatchEvent(r)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else qe(s,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Kr(s){if(typeof s=="object"&&s.RTCPeerConnection&&!("getSenders"in s.RTCPeerConnection.prototype)&&"createDTMFSender"in s.RTCPeerConnection.prototype){const t=function(n,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=n.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:n}};if(!s.RTCPeerConnection.prototype.getSenders){s.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=s.RTCPeerConnection.prototype.addTrack;s.RTCPeerConnection.prototype.addTrack=function(l,c){let a=n.apply(this,arguments);return a||(a=t(this,l),this._senders.push(a)),a};const o=s.RTCPeerConnection.prototype.removeTrack;s.RTCPeerConnection.prototype.removeTrack=function(l){o.apply(this,arguments);const c=this._senders.indexOf(l);c!==-1&&this._senders.splice(c,1)}}const e=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(o){this._senders=this._senders||[],e.apply(this,[o]),o.getTracks().forEach(r=>{this._senders.push(t(this,r))})};const i=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(o){this._senders=this._senders||[],i.apply(this,[o]),o.getTracks().forEach(r=>{const l=this._senders.find(c=>c.track===r);l&&this._senders.splice(this._senders.indexOf(l),1)})}}else if(typeof s=="object"&&s.RTCPeerConnection&&"getSenders"in s.RTCPeerConnection.prototype&&"createDTMFSender"in s.RTCPeerConnection.prototype&&s.RTCRtpSender&&!("dtmf"in s.RTCRtpSender.prototype)){const t=s.RTCPeerConnection.prototype.getSenders;s.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i},Object.defineProperty(s.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 Tr(s){if(!s.RTCPeerConnection)return;const t=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(){const[i,n,o]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const r=function(c){const a={};return c.result().forEach(h=>{const u={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(p=>{u[p]=h.stat(p)}),a[u.id]=u}),a},l=function(c){return new Map(Object.keys(c).map(a=>[a,c[a]]))};if(arguments.length>=2){const c=function(a){n(l(r(a)))};return t.apply(this,[c,i])}return new Promise((c,a)=>{t.apply(this,[function(d){c(l(r(d)))},a])}).then(n,o)}}function Mr(s){if(!(typeof s=="object"&&s.RTCPeerConnection&&s.RTCRtpSender&&s.RTCRtpReceiver))return;if(!("getStats"in s.RTCRtpSender.prototype)){const e=s.RTCPeerConnection.prototype.getSenders;e&&(s.RTCPeerConnection.prototype.getSenders=function(){const o=e.apply(this,[]);return o.forEach(r=>r._pc=this),o});const i=s.RTCPeerConnection.prototype.addTrack;i&&(s.RTCPeerConnection.prototype.addTrack=function(){const o=i.apply(this,arguments);return o._pc=this,o}),s.RTCRtpSender.prototype.getStats=function(){const o=this;return this._pc.getStats().then(r=>fo(r,o.track,!0))}}if(!("getStats"in s.RTCRtpReceiver.prototype)){const e=s.RTCPeerConnection.prototype.getReceivers;e&&(s.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(o=>o._pc=this),n}),qe(s,"track",i=>(i.receiver._pc=i.srcElement,i)),s.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(o=>fo(o,n.track,!1))}}if(!("getStats"in s.RTCRtpSender.prototype&&"getStats"in s.RTCRtpReceiver.prototype))return;const t=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof s.MediaStreamTrack){const i=arguments[0];let n,o,r;return this.getSenders().forEach(l=>{l.track===i&&(n?r=!0:n=l)}),this.getReceivers().forEach(l=>(l.track===i&&(o?r=!0:o=l),l.track===i)),r||n&&o?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():o?o.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Yr(s){s.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(r=>this._shimmedLocalStreams[r][0])};const t=s.RTCPeerConnection.prototype.addTrack;s.RTCPeerConnection.prototype.addTrack=function(r,l){if(!l)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.apply(this,arguments);return this._shimmedLocalStreams[l.id]?this._shimmedLocalStreams[l.id].indexOf(c)===-1&&this._shimmedLocalStreams[l.id].push(c):this._shimmedLocalStreams[l.id]=[l,c],c};const e=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(r){this._shimmedLocalStreams=this._shimmedLocalStreams||{},r.getTracks().forEach(a=>{if(this.getSenders().find(h=>h.track===a))throw new DOMException("Track already exists.","InvalidAccessError")});const l=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(a=>l.indexOf(a)===-1);this._shimmedLocalStreams[r.id]=[r].concat(c)};const i=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(r){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[r.id],i.apply(this,arguments)};const n=s.RTCPeerConnection.prototype.removeTrack;s.RTCPeerConnection.prototype.removeTrack=function(r){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},r&&Object.keys(this._shimmedLocalStreams).forEach(l=>{const c=this._shimmedLocalStreams[l].indexOf(r);c!==-1&&this._shimmedLocalStreams[l].splice(c,1),this._shimmedLocalStreams[l].length===1&&delete this._shimmedLocalStreams[l]}),n.apply(this,arguments)}}function kr(s,t){if(!s.RTCPeerConnection)return;if(s.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Yr(s);const e=s.RTCPeerConnection.prototype.getLocalStreams;s.RTCPeerConnection.prototype.getLocalStreams=function(){const d=e.apply(this);return this._reverseStreams=this._reverseStreams||{},d.map(h=>this._reverseStreams[h.id])};const i=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(d){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},d.getTracks().forEach(h=>{if(this.getSenders().find(p=>p.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[d.id]){const h=new s.MediaStream(d.getTracks());this._streams[d.id]=h,this._reverseStreams[h.id]=d,d=h}i.apply(this,[d])};const n=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(d){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[d.id]||d]),delete this._reverseStreams[this._streams[d.id]?this._streams[d.id].id:d.id],delete this._streams[d.id]},s.RTCPeerConnection.prototype.addTrack=function(d,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const u=[].slice.call(arguments,1);if(u.length!==1||!u[0].getTracks().find(b=>b===d))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(b=>b.track===d))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const m=this._streams[h.id];if(m)m.addTrack(d),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const b=new s.MediaStream([d]);this._streams[h.id]=b,this._reverseStreams[b.id]=h,this.addStream(b)}return this.getSenders().find(b=>b.track===d)};function o(a,d){let h=d.sdp;return Object.keys(a._reverseStreams||[]).forEach(u=>{const p=a._reverseStreams[u],m=a._streams[p.id];h=h.replace(new RegExp(m.id,"g"),p.id)}),new RTCSessionDescription({type:d.type,sdp:h})}function r(a,d){let h=d.sdp;return Object.keys(a._reverseStreams||[]).forEach(u=>{const p=a._reverseStreams[u],m=a._streams[p.id];h=h.replace(new RegExp(p.id,"g"),m.id)}),new RTCSessionDescription({type:d.type,sdp:h})}["createOffer","createAnswer"].forEach(function(a){const d=s.RTCPeerConnection.prototype[a],h={[a](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?d.apply(this,[m=>{const b=o(this,m);u[0].apply(null,[b])},m=>{u[1]&&u[1].apply(null,m)},arguments[2]]):d.apply(this,arguments).then(m=>o(this,m))}};s.RTCPeerConnection.prototype[a]=h[a]});const l=s.RTCPeerConnection.prototype.setLocalDescription;s.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?l.apply(this,arguments):(arguments[0]=r(this,arguments[0]),l.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(s.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(s.RTCPeerConnection.prototype,"localDescription",{get(){const a=c.get.apply(this);return a.type===""?a:o(this,a)}}),s.RTCPeerConnection.prototype.removeTrack=function(d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!d._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(d._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let u;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(b=>d.track===b)&&(u=this._streams[p])}),u&&(u.getTracks().length===1?this.removeStream(this._reverseStreams[u.id]):u.removeTrack(d.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Tn(s,t){!s.RTCPeerConnection&&s.webkitRTCPeerConnection&&(s.RTCPeerConnection=s.webkitRTCPeerConnection),s.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=s.RTCPeerConnection.prototype[e],n={[e](){return arguments[0]=new(e==="addIceCandidate"?s.RTCIceCandidate:s.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};s.RTCPeerConnection.prototype[e]=n[e]})}function Hr(s,t){qe(s,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const Ro=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Hr,shimAddTrackRemoveTrack:kr,shimAddTrackRemoveTrackWithNative:Yr,shimGetDisplayMedia:sl,shimGetSendersWithDtmf:Kr,shimGetStats:Tr,shimGetUserMedia:Cr,shimMediaStream:zr,shimOnTrack:vr,shimPeerConnection:Tn,shimSenderReceiverGetStats:Mr},Symbol.toStringTag,{value:"Module"}));function nl(s,t){let e=!1;return s=JSON.parse(JSON.stringify(s)),s.filter(i=>{if(i&&(i.urls||i.url)){let n=i.urls||i.url;i.url&&!i.urls&&$s("RTCIceServer.url","RTCIceServer.urls");const o=typeof n=="string";return o&&(n=[n]),n=n.filter(r=>{if(r.indexOf("stun:")===0)return!1;const l=r.startsWith("turn")&&!r.startsWith("turn:[")&&r.includes("transport=udp");return l&&!e?(e=!0,!0):l&&!e}),delete i.url,i.urls=o?n[0]:n,!!n.length}})}var Nr={exports:{}};(function(s){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
1
|
+
"use strict";const x=require("./three.light.umd.cjs"),st={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function _o(r){const t=await fetch(r);if(t.ok)return t.json();throw new Error(t.statusText)}async function La(r){if(!r)throw new Error("No basePath supplied");return await _o(`${r}/profilesList.json`)}async function Va(r,t,e=null,i=!0){if(!r)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const n=await La(t);let s;if(r.profiles.some(a=>{const l=n[a];return l&&(s={profileId:a,profilePath:`${t}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!e)throw new Error("No matching profile name found");const a=n[e];if(!a)throw new Error(`No matching profile name found and default profile "${e}" missing.`);s={profileId:e,profilePath:`${t}/${a.path}`,deprecated:!!a.deprecated}}const o=await _o(s.profilePath);let c;if(i){let a;if(r.handedness==="any"?a=o.layouts[Object.keys(o.layouts)[0]]:a=o.layouts[r.handedness],!a)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);a.assetPath&&(c=s.profilePath.replace("profile.json",a.assetPath))}return{profile:o,assetPath:c}}const Ja={xAxis:0,yAxis:0,button:0,state:st.ComponentState.DEFAULT};function Ga(r=0,t=0){let e=r,i=t;if(Math.sqrt(r*r+t*t)>1){const o=Math.atan2(t,r);e=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class ja{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===st.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(Ja)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:n}){const{normalizedXAxis:s,normalizedYAxis:o}=Ga(t,e);switch(this.componentProperty){case st.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?s:.5;break;case st.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?o:.5;break;case st.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case st.ComponentProperty.STATE:this.valueNodeProperty===st.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(n):this.value=this.states.includes(n)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class $a{constructor(t,e){if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(i=>{const n=new ja(e.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:st.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(t){if(this.values.state=st.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){const e=t.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=st.ComponentState.PRESSED:(e.touched||this.values.button>st.ButtonTouchThreshold)&&(this.values.state=st.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.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===st.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.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===st.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Ha{constructor(t,e,i){if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(n=>{const s=this.layoutDescription.components[n];this.components[n]=new $a(n,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const on=2,jt=4,ee=4,bo=4,le=new Int32Array(2),ps=new Float32Array(le.buffer),ms=new Float64Array(le.buffer),lr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class re{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?re.ZERO:new re(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}re.ZERO=new re(0,0);var Rn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Rn||(Rn={}));class Pi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new Pi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new re(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new re(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return le[0]=this.readInt32(t),ps[0]}readFloat64(t){return le[lr?0:1]=this.readInt32(t),le[lr?1:0]=this.readInt32(t+4),ms[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){ps[0]=e,this.writeInt32(t,le[0])}writeFloat64(t,e){ms[0]=e,this.writeInt32(t,le[lr?0:1]),this.writeInt32(t+4,le[lr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+jt+ee)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<ee;e++)t+=String.fromCharCode(this.readInt8(this.position_+jt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let n="",s=0;if(t+=jt,e===Rn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){let o;const c=this.readUint8(t+s++);if(c<192)o=c;else{const a=this.readUint8(t+s++);if(c<224)o=(c&31)<<6|a&63;else{const l=this.readUint8(t+s++);if(c<240)o=(c&15)<<12|(a&63)<<6|l&63;else{const u=this.readUint8(t+s++);o=(c&7)<<18|(a&63)<<12|(l&63)<<6|u&63}}}o<65536?n+=String.fromCharCode(o):(o-=65536,n+=String.fromCharCode((o>>10)+55296,(o&1024-1)+56320))}return n}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+jt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let e=0;e<ee;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+jt+e))return!1;return!0}createLong(t,e){return re.create(t,e)}createScalarList(t,e){const i=[];for(let n=0;n<e;++n)t(n)!==null&&i.push(t(n));return i}createObjList(t,e){const i=[];for(let n=0;n<e;++n){const s=t(n);s!==null&&i.push(s.unpack())}return i}}class ts{constructor(t){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 e;t?e=t:e=1024,this.bb=Pi.allocate(e),this.space=e}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(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){const n=this.bb.capacity();this.bb=ts.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||!e.equals(i))&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=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(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=e<<1,n=Pi.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(jt,0),this.writeInt32(this.offset()-t+jt)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=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 t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const n=2;this.addInt16(t-this.object_start);const s=(i+n)*on;this.addInt16(s);let o=0;const c=this.space;t:for(e=0;e<this.vtables.length;e++){const a=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(a)){for(let l=on;l<s;l+=on)if(this.bb.readInt16(c+l)!=this.bb.readInt16(a+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const n=i?bo:0;if(e){const s=e;if(this.prep(this.minalign,jt+ee+n),s.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let o=ee-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,jt+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(!(this.bb.readInt16(n+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(jt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i<t.length;){let n;const s=t.charCodeAt(i++);if(s<55296||s>=56320)n=s;else{const o=t.charCodeAt(i++);n=(s<<10)+o+(65536-56623104-56320)}n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(n&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,n=this.space,s=this.bb.bytes();i<e.length;i++)s[n++]=e[i];return this.endVector()}createLong(t,e){return re.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let i=0;i<t.length;++i){const n=t[i];if(n!==null)e.push(this.createObjectOffset(n));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}function Qr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var So={exports:{}};(function(r){var t={};t.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),t.useArrayBufferView=!t.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),r.exports.binaryFeatures=t;var e=r.exports.BlobBuilder;typeof window<"u"&&(e=r.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(n){typeof n=="number"?this._pieces.push(n):(this.flush(),this._parts.push(n))},i.prototype.flush=function(){if(this._pieces.length>0){var n=new Uint8Array(this._pieces);t.useArrayBufferView||(n=n.buffer),this._parts.push(n),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var n=new e,s=0,o=this._parts.length;s<o;s++)n.append(this._parts[s]);return n.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=i})(So);var To=So.exports,qa=To.BufferBuilder,ys=To.binaryFeatures,Xa={unpack:function(r){var t=new ht(r);return t.unpack()},pack:function(r){var t=new ft;t.pack(r);var e=t.getBuffer();return e}},Wa=Xa;function ht(r){this.index=0,this.dataBuffer=r,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}ht.prototype.unpack=function(){var r=this.unpack_uint8();if(r<128)return r;if((r^224)<32)return(r^224)-32;var t;if((t=r^160)<=15)return this.unpack_raw(t);if((t=r^176)<=15)return this.unpack_string(t);if((t=r^144)<=15)return this.unpack_array(t);if((t=r^128)<=15)return this.unpack_map(t);switch(r){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 t=this.unpack_uint16(),this.unpack_string(t);case 217:return t=this.unpack_uint32(),this.unpack_string(t);case 218:return t=this.unpack_uint16(),this.unpack_raw(t);case 219:return t=this.unpack_uint32(),this.unpack_raw(t);case 220:return t=this.unpack_uint16(),this.unpack_array(t);case 221:return t=this.unpack_uint32(),this.unpack_array(t);case 222:return t=this.unpack_uint16(),this.unpack_map(t);case 223:return t=this.unpack_uint32(),this.unpack_map(t)}};ht.prototype.unpack_uint8=function(){var r=this.dataView[this.index]&255;return this.index++,r};ht.prototype.unpack_uint16=function(){var r=this.read(2),t=(r[0]&255)*256+(r[1]&255);return this.index+=2,t};ht.prototype.unpack_uint32=function(){var r=this.read(4),t=((r[0]*256+r[1])*256+r[2])*256+r[3];return this.index+=4,t};ht.prototype.unpack_uint64=function(){var r=this.read(8),t=((((((r[0]*256+r[1])*256+r[2])*256+r[3])*256+r[4])*256+r[5])*256+r[6])*256+r[7];return this.index+=8,t};ht.prototype.unpack_int8=function(){var r=this.unpack_uint8();return r<128?r:r-256};ht.prototype.unpack_int16=function(){var r=this.unpack_uint16();return r<32768?r:r-65536};ht.prototype.unpack_int32=function(){var r=this.unpack_uint32();return r<Math.pow(2,31)?r:r-Math.pow(2,32)};ht.prototype.unpack_int64=function(){var r=this.unpack_uint64();return r<Math.pow(2,63)?r:r-Math.pow(2,64)};ht.prototype.unpack_raw=function(r){if(this.length<this.index+r)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+r+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+r);return this.index+=r,t};ht.prototype.unpack_string=function(r){for(var t=this.read(r),e=0,i="",n,s;e<r;)n=t[e],n<128?(i+=String.fromCharCode(n),e++):(n^192)<32?(s=(n^192)<<6|t[e+1]&63,i+=String.fromCharCode(s),e+=2):(s=(n&15)<<12|(t[e+1]&63)<<6|t[e+2]&63,i+=String.fromCharCode(s),e+=3);return this.index+=r,i};ht.prototype.unpack_array=function(r){for(var t=new Array(r),e=0;e<r;e++)t[e]=this.unpack();return t};ht.prototype.unpack_map=function(r){for(var t={},e=0;e<r;e++){var i=this.unpack(),n=this.unpack();t[i]=n}return t};ht.prototype.unpack_float=function(){var r=this.unpack_uint32(),t=r>>31,e=(r>>23&255)-127,i=r&8388607|8388608;return(t===0?1:-1)*i*Math.pow(2,e-23)};ht.prototype.unpack_double=function(){var r=this.unpack_uint32(),t=this.unpack_uint32(),e=r>>31,i=(r>>20&2047)-1023,n=r&1048575|1048576,s=n*Math.pow(2,i-20)+t*Math.pow(2,i-52);return(e===0?1:-1)*s};ht.prototype.read=function(r){var t=this.index;if(t+r<=this.length)return this.dataView.subarray(t,t+r);throw new Error("BinaryPackFailure: read index out of range")};function ft(){this.bufferBuilder=new qa}ft.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()};ft.prototype.pack=function(r){var t=typeof r;if(t==="string")this.pack_string(r);else if(t==="number")Math.floor(r)===r?this.pack_integer(r):this.pack_double(r);else if(t==="boolean")r===!0?this.bufferBuilder.append(195):r===!1&&this.bufferBuilder.append(194);else if(t==="undefined")this.bufferBuilder.append(192);else if(t==="object")if(r===null)this.bufferBuilder.append(192);else{var e=r.constructor;if(e==Array)this.pack_array(r);else if(e==Blob||e==File||r instanceof Blob||r instanceof File)this.pack_bin(r);else if(e==ArrayBuffer)ys.useArrayBufferView?this.pack_bin(new Uint8Array(r)):this.pack_bin(r);else if("BYTES_PER_ELEMENT"in r)ys.useArrayBufferView?this.pack_bin(new Uint8Array(r.buffer)):this.pack_bin(r.buffer);else if(e==Object||e.toString().startsWith("class"))this.pack_object(r);else if(e==Date)this.pack_string(r.toString());else if(typeof r.toBinaryPack=="function")this.bufferBuilder.append(r.toBinaryPack());else throw new Error('Type "'+e.toString()+'" not yet supported')}else throw new Error('Type "'+t+'" not yet supported');this.bufferBuilder.flush()};ft.prototype.pack_bin=function(r){var t=r.length||r.byteLength||r.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(r)};ft.prototype.pack_string=function(r){var t=Za(r);if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(r)};ft.prototype.pack_array=function(r){var t=r.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(t);else throw new Error("Invalid length");for(var e=0;e<t;e++)this.pack(r[e])};ft.prototype.pack_integer=function(r){if(r>=-32&&r<=127)this.bufferBuilder.append(r&255);else if(r>=0&&r<=255)this.bufferBuilder.append(204),this.pack_uint8(r);else if(r>=-128&&r<=127)this.bufferBuilder.append(208),this.pack_int8(r);else if(r>=0&&r<=65535)this.bufferBuilder.append(205),this.pack_uint16(r);else if(r>=-32768&&r<=32767)this.bufferBuilder.append(209),this.pack_int16(r);else if(r>=0&&r<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(r);else if(r>=-2147483648&&r<=2147483647)this.bufferBuilder.append(210),this.pack_int32(r);else if(r>=-9223372036854776e3&&r<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(r);else if(r>=0&&r<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(r);else throw new Error("Invalid integer")};ft.prototype.pack_double=function(r){var t=0;r<0&&(t=1,r=-r);var e=Math.floor(Math.log(r)/Math.LN2),i=r/Math.pow(2,e)-1,n=Math.floor(i*Math.pow(2,52)),s=Math.pow(2,32),o=t<<31|e+1023<<20|n/s&1048575,c=n%s;this.bufferBuilder.append(203),this.pack_int32(o),this.pack_int32(c)};ft.prototype.pack_object=function(r){var t=Object.keys(r),e=t.length;if(e<=15)this.pack_uint8(128+e);else if(e<=65535)this.bufferBuilder.append(222),this.pack_uint16(e);else if(e<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(e);else throw new Error("Invalid length");for(var i in r)r.hasOwnProperty(i)&&(this.pack(i),this.pack(r[i]))};ft.prototype.pack_uint8=function(r){this.bufferBuilder.append(r)};ft.prototype.pack_uint16=function(r){this.bufferBuilder.append(r>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_uint32=function(r){var t=r&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)};ft.prototype.pack_uint64=function(r){var t=r/Math.pow(2,32),e=r%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};ft.prototype.pack_int8=function(r){this.bufferBuilder.append(r&255)};ft.prototype.pack_int16=function(r){this.bufferBuilder.append((r&65280)>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_int32=function(r){this.bufferBuilder.append(r>>>24&255),this.bufferBuilder.append((r&16711680)>>>16),this.bufferBuilder.append((r&65280)>>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_int64=function(r){var t=Math.floor(r/Math.pow(2,32)),e=r%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};function Ya(r){var t=r.charCodeAt(0);return t<=2047?"00":t<=65535?"000":t<=2097151?"0000":t<=67108863?"00000":"000000"}function Za(r){return r.length>600?new Blob([r]).size:r.replace(/[^\u0000-\u007F]/g,Ya).length}const gs=Qr(Wa);let Mo=!0,Co=!0;function _i(r,t,e){const i=r.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function Qe(r,t,e){if(!r.RTCPeerConnection)return;const i=r.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(o,c){if(o!==t)return n.apply(this,arguments);const a=l=>{const u=e(l);u&&(c.handleEvent?c.handleEvent(u):c(u))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(c,a),n.apply(this,[o,a])};const s=i.removeEventListener;i.removeEventListener=function(o,c){if(o!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(c))return s.apply(this,arguments);const a=this._eventMap[t].get(c);return this._eventMap[t].delete(c),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,a])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(o){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),o&&this.addEventListener(t,this["_on"+t]=o)},enumerable:!0,configurable:!0})}function Qa(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Mo=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Ka(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Co=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function es(){if(typeof window=="object"){if(Mo)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Kr(r,t){Co&&console.warn(r+" is deprecated, please use "+t+" instead.")}function tc(r){const t={browser:null,version:null};if(typeof r>"u"||!r.navigator)return t.browser="Not a browser.",t;const{navigator:e}=r;if(e.mozGetUserMedia)t.browser="firefox",t.version=_i(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)t.browser="chrome",t.version=_i(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=_i(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=_i(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function vs(r){return Object.prototype.toString.call(r)==="[object Object]"}function wo(r){return vs(r)?Object.keys(r).reduce(function(t,e){const i=vs(r[e]),n=i?wo(r[e]):r[e],s=i&&!Object.keys(n).length;return n===void 0||s?t:Object.assign(t,{[e]:n})},{}):r}function kn(r,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?kn(r,r.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(n=>{kn(r,r.get(n),e)})}))}function xs(r,t,e){const i=e?"outbound-rtp":"inbound-rtp",n=new Map;if(t===null)return n;const s=[];return r.forEach(o=>{o.type==="track"&&o.trackIdentifier===t.id&&s.push(o)}),s.forEach(o=>{r.forEach(c=>{c.type===i&&c.trackId===o.id&&kn(r,c,n)})}),n}const _s=es;function Po(r,t){const e=r&&r.navigator;if(!e.mediaDevices)return;const i=function(c){if(typeof c!="object"||c.mandatory||c.optional)return c;const a={};return Object.keys(c).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof c[l]=="object"?c[l]:{ideal:c[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const h=function(f,d){return f?f+d.charAt(0).toUpperCase()+d.slice(1):d==="deviceId"?"sourceId":d};if(u.ideal!==void 0){a.optional=a.optional||[];let f={};typeof u.ideal=="number"?(f[h("min",l)]=u.ideal,a.optional.push(f),f={},f[h("max",l)]=u.ideal,a.optional.push(f)):(f[h("",l)]=u.ideal,a.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(a.mandatory=a.mandatory||{},a.mandatory[h("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(a.mandatory=a.mandatory||{},a.mandatory[h(f,l)]=u[f])})}),c.advanced&&(a.optional=(a.optional||[]).concat(c.advanced)),a},n=function(c,a){if(t.version>=61)return a(c);if(c=JSON.parse(JSON.stringify(c)),c&&typeof c.audio=="object"){const l=function(u,h,f){h in u&&!(f in u)&&(u[f]=u[h],delete u[h])};c=JSON.parse(JSON.stringify(c)),l(c.audio,"autoGainControl","googAutoGainControl"),l(c.audio,"noiseSuppression","googNoiseSuppression"),c.audio=i(c.audio)}if(c&&typeof c.video=="object"){let l=c.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=t.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete c.video.facingMode;let h;if(l.exact==="environment"||l.ideal==="environment"?h=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(f=>{f=f.filter(p=>p.kind==="videoinput");let d=f.find(p=>h.some(m=>p.label.toLowerCase().includes(m)));return!d&&f.length&&h.includes("back")&&(d=f[f.length-1]),d&&(c.video.deviceId=l.exact?{exact:d.deviceId}:{ideal:d.deviceId}),c.video=i(c.video),_s("chrome: "+JSON.stringify(c)),a(c)})}c.video=i(c.video)}return _s("chrome: "+JSON.stringify(c)),a(c)},s=function(c){return t.version>=64?c:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[c.name]||c.name,message:c.message,constraint:c.constraint||c.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},o=function(c,a,l){n(c,u=>{e.webkitGetUserMedia(u,a,h=>{l&&l(s(h))})})};if(e.getUserMedia=o.bind(e),e.mediaDevices.getUserMedia){const c=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(a){return n(a,l=>c(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))}}}function ec(r,t){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(n=>{const s=i.video&&i.video.width,o=i.video&&i.video.height,c=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:c||3}},s&&(i.video.mandatory.maxWidth=s),o&&(i.video.mandatory.maxHeight=o),r.navigator.mediaDevices.getUserMedia(i)})}}}function Eo(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Ao(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",n=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(c=>c.track&&c.track.id===n.track.id):s={track:n.track};const o=new Event("track");o.track=n.track,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)}),i.stream.getTracks().forEach(n=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(c=>c.track&&c.track.id===n.id):s={track:n};const o=new Event("track");o.track=n,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Qe(r,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Ro(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const t=function(n,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=n.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:n}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(c,a){let l=n.apply(this,arguments);return l||(l=t(this,c),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(c){s.apply(this,arguments);const a=this._senders.indexOf(c);a!==-1&&this._senders.splice(a,1)}}const e=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],e.apply(this,[s]),s.getTracks().forEach(o=>{this._senders.push(t(this,o))})};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(o=>{const c=this._senders.find(a=>a.track===o);c&&this._senders.splice(this._senders.indexOf(c),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 t=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i},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 ko(r){if(!r.RTCPeerConnection)return;const t=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[i,n,s]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const o=function(a){const l={};return a.result().forEach(h=>{const f={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(d=>{f[d]=h.stat(d)}),l[f.id]=f}),l},c=function(a){return new Map(Object.keys(a).map(l=>[l,a[l]]))};if(arguments.length>=2){const a=function(l){n(c(o(l)))};return t.apply(this,[a,i])}return new Promise((a,l)=>{t.apply(this,[function(u){a(c(o(u)))},l])}).then(n,s)}}function Bo(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(o=>o._pc=this),s});const i=r.RTCPeerConnection.prototype.addTrack;i&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(o=>xs(o,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(s=>s._pc=this),n}),Qe(r,"track",i=>(i.receiver._pc=i.srcElement,i)),r.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(s=>xs(s,n.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const t=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const i=arguments[0];let n,s,o;return this.getSenders().forEach(c=>{c.track===i&&(n?o=!0:n=c)}),this.getReceivers().forEach(c=>(c.track===i&&(s?o=!0:s=c),c.track===i)),o||n&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function zo(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const t=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(o,c){if(!c)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const a=t.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(a)===-1&&this._shimmedLocalStreams[c.id].push(a):this._shimmedLocalStreams[c.id]=[c,a],a};const e=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(l=>{if(this.getSenders().find(h=>h.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const c=this.getSenders();e.apply(this,arguments);const a=this.getSenders().filter(l=>c.indexOf(l)===-1);this._shimmedLocalStreams[o.id]=[o].concat(a)};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],i.apply(this,arguments)};const n=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(c=>{const a=this._shimmedLocalStreams[c].indexOf(o);a!==-1&&this._shimmedLocalStreams[c].splice(a,1),this._shimmedLocalStreams[c].length===1&&delete this._shimmedLocalStreams[c]}),n.apply(this,arguments)}}function Oo(r,t){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&t.version>=65)return zo(r);const e=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=e.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(h=>this._reverseStreams[h.id])};const i=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(h=>{if(this.getSenders().find(d=>d.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const h=new r.MediaStream(u.getTracks());this._streams[u.id]=h,this._reverseStreams[h.id]=u,u=h}i.apply(this,[u])};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.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,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[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 p=this._streams[h.id];if(p)p.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const m=new r.MediaStream([u]);this._streams[h.id]=m,this._reverseStreams[m.id]=h,this.addStream(m)}return this.getSenders().find(m=>m.track===u)};function s(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],p=l._streams[d.id];h=h.replace(new RegExp(p.id,"g"),d.id)}),new RTCSessionDescription({type:u.type,sdp:h})}function o(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],p=l._streams[d.id];h=h.replace(new RegExp(d.id,"g"),p.id)}),new RTCSessionDescription({type:u.type,sdp:h})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],h={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[p=>{const m=s(this,p);f[0].apply(null,[m])},p=>{f[1]&&f[1].apply(null,p)},arguments[2]]):u.apply(this,arguments).then(p=>s(this,p))}};r.RTCPeerConnection.prototype[l]=h[l]});const c=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?c.apply(this,arguments):(arguments[0]=o(this,arguments[0]),c.apply(this,arguments))};const a=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=a.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 f;Object.keys(this._streams).forEach(d=>{this._streams[d].getTracks().find(m=>u.track===m)&&(f=this._streams[d])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Bn(r,t){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=r.RTCPeerConnection.prototype[e],n={[e](){return arguments[0]=new(e==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};r.RTCPeerConnection.prototype[e]=n[e]})}function Io(r,t){Qe(r,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const bs=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Io,shimAddTrackRemoveTrack:Oo,shimAddTrackRemoveTrackWithNative:zo,shimGetDisplayMedia:ec,shimGetSendersWithDtmf:Ro,shimGetStats:ko,shimGetUserMedia:Po,shimMediaStream:Eo,shimOnTrack:Ao,shimPeerConnection:Bn,shimSenderReceiverGetStats:Bo},Symbol.toStringTag,{value:"Module"}));function ic(r,t){let e=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(i=>{if(i&&(i.urls||i.url)){let n=i.urls||i.url;i.url&&!i.urls&&Kr("RTCIceServer.url","RTCIceServer.urls");const s=typeof n=="string";return s&&(n=[n]),n=n.filter(o=>{if(o.indexOf("stun:")===0)return!1;const c=o.startsWith("turn")&&!o.startsWith("turn:[")&&o.includes("transport=udp");return c&&!e?(e=!0,!0):c&&!e}),delete i.url,i.urls=s?n[0]:n,!!n.length}})}var No={exports:{}};(function(r){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
2
2
|
`).map(function(i){return i.trim()})},t.splitSections=function(e){var i=e.split(`
|
|
3
|
-
m=`);return i.map(function(n,
|
|
4
|
-
`})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(n){return n.indexOf(i)===0})},t.parseCandidate=function(e){var i;e.indexOf("a=candidate:")===0?i=e.substring(12).split(" "):i=e.substring(10).split(" ");for(var n={foundation:i[0],component:parseInt(i[1],10),protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]},
|
|
3
|
+
m=`);return i.map(function(n,s){return(s>0?"m="+n:n).trim()+`\r
|
|
4
|
+
`})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(n){return n.indexOf(i)===0})},t.parseCandidate=function(e){var i;e.indexOf("a=candidate:")===0?i=e.substring(12).split(" "):i=e.substring(10).split(" ");for(var n={foundation:i[0],component:parseInt(i[1],10),protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]},s=8;s<i.length;s+=2)switch(i[s]){case"raddr":n.relatedAddress=i[s+1];break;case"rport":n.relatedPort=parseInt(i[s+1],10);break;case"tcptype":n.tcpType=i[s+1];break;case"ufrag":n.ufrag=i[s+1],n.usernameFragment=i[s+1];break;default:n[i[s]]=i[s+1];break}return n},t.writeCandidate=function(e){var i=[];i.push(e.foundation),i.push(e.component),i.push(e.protocol.toUpperCase()),i.push(e.priority),i.push(e.address||e.ip),i.push(e.port);var n=e.type;return i.push("typ"),i.push(n),n!=="host"&&e.relatedAddress&&e.relatedPort&&(i.push("raddr"),i.push(e.relatedAddress),i.push("rport"),i.push(e.relatedPort)),e.tcpType&&e.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(i.push("ufrag"),i.push(e.usernameFragment||e.ufrag)),"candidate:"+i.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var i=e.substr(9).split(" "),n={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),n.name=i[0],n.clockRate=parseInt(i[1],10),n.channels=i.length===3?parseInt(i[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var i=e.payloadType;e.preferredPayloadType!==void 0&&(i=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+i+" "+e.name+"/"+e.clockRate+(n!==1?"/"+n:"")+`\r
|
|
5
5
|
`},t.parseExtmap=function(e){var i=e.substr(9).split(" ");return{id:parseInt(i[0],10),direction:i[0].indexOf("/")>0?i[0].split("/")[1]:"sendrecv",uri:i[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+`\r
|
|
6
|
-
`},t.parseFmtp=function(e){for(var i={},n,
|
|
7
|
-
`}return i},t.parseRtcpFb=function(e){var i=e.substr(e.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},t.writeRtcpFb=function(e){var i="",n=e.payloadType;return e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(
|
|
8
|
-
`}),i},t.parseSsrcMedia=function(e){var i=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,i-7),10)},
|
|
9
|
-
`;return e.fingerprints.forEach(function(
|
|
6
|
+
`},t.parseFmtp=function(e){for(var i={},n,s=e.substr(e.indexOf(" ")+1).split(";"),o=0;o<s.length;o++)n=s[o].trim().split("="),i[n[0].trim()]=n[1];return i},t.writeFmtp=function(e){var i="",n=e.payloadType;if(e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var s=[];Object.keys(e.parameters).forEach(function(o){e.parameters[o]?s.push(o+"="+e.parameters[o]):s.push(o)}),i+="a=fmtp:"+n+" "+s.join(";")+`\r
|
|
7
|
+
`}return i},t.parseRtcpFb=function(e){var i=e.substr(e.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},t.writeRtcpFb=function(e){var i="",n=e.payloadType;return e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(s){i+="a=rtcp-fb:"+n+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
|
|
8
|
+
`}),i},t.parseSsrcMedia=function(e){var i=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,i-7),10)},s=e.indexOf(":",i);return s>-1?(n.attribute=e.substr(i+1,s-i-1),n.value=e.substr(s+1)):n.attribute=e.substr(i+1),n},t.parseSsrcGroup=function(e){var i=e.substr(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(function(n){return parseInt(n,10)})}},t.getMid=function(e){var i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){var i=e.substr(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1]}},t.getDtlsParameters=function(e,i){var n=t.matchPrefix(e+i,"a=fingerprint:");return{role:"auto",fingerprints:n.map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,i){var n="a=setup:"+i+`\r
|
|
9
|
+
`;return e.fingerprints.forEach(function(s){n+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
|
|
10
10
|
`}),n},t.parseCryptoLine=function(e){var i=e.substr(9).split(" ");return{tag:parseInt(i[0],10),cryptoSuite:i[1],keyParams:i[2],sessionParams:i.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(typeof e.keyParams=="object"?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+`\r
|
|
11
|
-
`},t.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var i=e.substr(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){var n=t.matchPrefix(e+i,"a=crypto:");return n.map(t.parseCryptoLine)},t.getIceParameters=function(e,i){var n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],
|
|
11
|
+
`},t.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var i=e.substr(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){var n=t.matchPrefix(e+i,"a=crypto:");return n.map(t.parseCryptoLine)},t.getIceParameters=function(e,i){var n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],s=t.matchPrefix(e+i,"a=ice-pwd:")[0];return n&&s?{usernameFragment:n.substr(12),password:s.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+`\r
|
|
12
12
|
a=ice-pwd:`+e.password+`\r
|
|
13
|
-
`},t.parseRtpParameters=function(e){for(var i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e),
|
|
13
|
+
`},t.parseRtpParameters=function(e){for(var i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e),s=n[0].split(" "),o=3;o<s.length;o++){var c=s[o],a=t.matchPrefix(e,"a=rtpmap:"+c+" ")[0];if(a){var l=t.parseRtpMap(a),u=t.matchPrefix(e,"a=fmtp:"+c+" ");switch(l.parameters=u.length?t.parseFmtp(u[0]):{},l.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+c+" ").map(t.parseRtcpFb),i.codecs.push(l),l.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(l.name.toUpperCase());break}}}return t.matchPrefix(e,"a=extmap:").forEach(function(h){i.headerExtensions.push(t.parseExtmap(h))}),i},t.writeRtpDescription=function(e,i){var n="";n+="m="+e+" ",n+=i.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=i.codecs.map(function(o){return o.preferredPayloadType!==void 0?o.preferredPayloadType:o.payloadType}).join(" ")+`\r
|
|
14
14
|
`,n+=`c=IN IP4 0.0.0.0\r
|
|
15
15
|
`,n+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
16
|
-
`,i.codecs.forEach(function(
|
|
16
|
+
`,i.codecs.forEach(function(o){n+=t.writeRtpMap(o),n+=t.writeFmtp(o),n+=t.writeRtcpFb(o)});var s=0;return i.codecs.forEach(function(o){o.maxptime>s&&(s=o.maxptime)}),s>0&&(n+="a=maxptime:"+s+`\r
|
|
17
17
|
`),n+=`a=rtcp-mux\r
|
|
18
|
-
`,i.headerExtensions&&i.headerExtensions.forEach(function(
|
|
18
|
+
`,i.headerExtensions&&i.headerExtensions.forEach(function(o){n+=t.writeExtmap(o)}),n},t.parseRtpEncodingParameters=function(e){var i=[],n=t.parseRtpParameters(e),s=n.fecMechanisms.indexOf("RED")!==-1,o=n.fecMechanisms.indexOf("ULPFEC")!==-1,c=t.matchPrefix(e,"a=ssrc:").map(function(f){return t.parseSsrcMedia(f)}).filter(function(f){return f.attribute==="cname"}),a=c.length>0&&c[0].ssrc,l,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(f){var d=f.substr(17).split(" ");return d.map(function(p){return parseInt(p,10)})});u.length>0&&u[0].length>1&&u[0][0]===a&&(l=u[0][1]),n.codecs.forEach(function(f){if(f.name.toUpperCase()==="RTX"&&f.parameters.apt){var d={ssrc:a,codecPayloadType:parseInt(f.parameters.apt,10)};a&&l&&(d.rtx={ssrc:l}),i.push(d),s&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},i.push(d))}}),i.length===0&&a&&i.push({ssrc:a});var h=t.matchPrefix(e,"b=");return h.length&&(h[0].indexOf("b=TIAS:")===0?h=parseInt(h[0].substr(7),10):h[0].indexOf("b=AS:")===0?h=parseInt(h[0].substr(5),10)*1e3*.95-50*40*8:h=void 0,i.forEach(function(f){f.maxBitrate=h})),i},t.parseRtcpParameters=function(e){var i={},n=t.matchPrefix(e,"a=ssrc:").map(function(c){return t.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];n&&(i.cname=n.value,i.ssrc=n.ssrc);var s=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=s.length>0,i.compound=s.length===0;var o=t.matchPrefix(e,"a=rtcp-mux");return i.mux=o.length>0,i},t.parseMsid=function(e){var i,n=t.matchPrefix(e,"a=msid:");if(n.length===1)return i=n[0].substr(7).split(" "),{stream:i[0],track:i[1]};var s=t.matchPrefix(e,"a=ssrc:").map(function(o){return t.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="msid"});if(s.length>0)return i=s[0].value.split(" "),{stream:i[0],track:i[1]}},t.parseSctpDescription=function(e){var i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:"),s;n.length>0&&(s=parseInt(n[0].substr(19),10)),isNaN(s)&&(s=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:i.fmt,maxMessageSize:s};var c=t.matchPrefix(e,"a=sctpmap:");if(c.length>0){var a=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:s}}},t.writeSctpDescription=function(e,i){var n=[];return e.protocol!=="DTLS/SCTP"?n=["m="+e.kind+" 9 "+e.protocol+" "+i.protocol+`\r
|
|
19
19
|
`,`c=IN IP4 0.0.0.0\r
|
|
20
20
|
`,"a=sctp-port:"+i.port+`\r
|
|
21
21
|
`]:n=["m="+e.kind+" 9 "+e.protocol+" "+i.port+`\r
|
|
22
22
|
`,`c=IN IP4 0.0.0.0\r
|
|
23
23
|
`,"a=sctpmap:"+i.port+" "+i.protocol+` 65535\r
|
|
24
24
|
`],i.maxMessageSize!==void 0&&n.push("a=max-message-size:"+i.maxMessageSize+`\r
|
|
25
|
-
`),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,n){var o
|
|
26
|
-
o=`+
|
|
25
|
+
`),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,n){var s,o=i!==void 0?i:2;e?s=e:s=t.generateSessionId();var c=n||"thisisadapterortc";return`v=0\r
|
|
26
|
+
o=`+c+" "+s+" "+o+` IN IP4 127.0.0.1\r
|
|
27
27
|
s=-\r
|
|
28
28
|
t=0 0\r
|
|
29
|
-
`},t.writeMediaSection=function(e,i,n,
|
|
30
|
-
`,e.direction?
|
|
31
|
-
`:e.rtpSender&&e.rtpReceiver?
|
|
32
|
-
`:e.rtpSender?
|
|
33
|
-
`:e.rtpReceiver?
|
|
34
|
-
`:r+=`a=inactive\r
|
|
35
|
-
`,e.rtpSender){var l="msid:"+o.id+" "+e.rtpSender.track.id+`\r
|
|
36
|
-
`;r+="a="+l,r+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+l,e.sendEncodingParameters[0].rtx&&(r+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+l,r+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
37
|
-
`)}return r+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r
|
|
38
|
-
`,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(r+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r
|
|
39
|
-
`),r},t.getDirection=function(e,i){for(var n=t.splitLines(e),o=0;o<n.length;o++)switch(n[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[o].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){var i=t.splitLines(e),n=i[0].split(" ");return n[0].substr(2)},t.isRejected=function(e){return e.split(" ",2)[1]==="0"},t.parseMLine=function(e){var i=t.splitLines(e),n=i[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var i=t.matchPrefix(e,"o=")[0],n=i.substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if(typeof e!="string"||e.length===0)return!1;for(var i=t.splitLines(e),n=0;n<i.length;n++)if(i[n].length<2||i[n].charAt(1)!=="=")return!1;return!0},s.exports=t})(Nr);var Ir=Nr.exports;const Hs=qs(Ir);var k=Ir;function ol(s){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[s.type]||s.type}function xo(s,t,e,i,n){var o=k.writeRtpDescription(s.kind,t);if(o+=k.writeIceParameters(s.iceGatherer.getLocalParameters()),o+=k.writeDtlsParameters(s.dtlsTransport.getLocalParameters(),e==="offer"?"actpass":n||"active"),o+="a=mid:"+s.mid+`\r
|
|
40
|
-
`,s.rtpSender&&s.rtpReceiver?o+=`a=sendrecv\r
|
|
41
|
-
`:s.rtpSender?o+=`a=sendonly\r
|
|
42
|
-
`:s.rtpReceiver?o+=`a=recvonly\r
|
|
29
|
+
`},t.writeMediaSection=function(e,i,n,s){var o=t.writeRtpDescription(e.kind,i);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),n==="offer"?"actpass":"active"),o+="a=mid:"+e.mid+`\r
|
|
30
|
+
`,e.direction?o+="a="+e.direction+`\r
|
|
31
|
+
`:e.rtpSender&&e.rtpReceiver?o+=`a=sendrecv\r
|
|
32
|
+
`:e.rtpSender?o+=`a=sendonly\r
|
|
33
|
+
`:e.rtpReceiver?o+=`a=recvonly\r
|
|
43
34
|
`:o+=`a=inactive\r
|
|
44
|
-
`,
|
|
45
|
-
`;o+="a="+
|
|
46
|
-
`)}return o+="a=ssrc:"+
|
|
47
|
-
`,
|
|
48
|
-
`),o}
|
|
49
|
-
|
|
50
|
-
`,d._localDescription.sdp=k.getDescription(d._localDescription.sdp)+Z.join("");var V=d.transceivers.every(function(R){return R.iceGatherer&&R.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),G||d._dispatchEvent("icecandidate",m),V&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},s.setTimeout(function(){u.forEach(function(p){h.onlocalcandidate(p)})},0)}},o.prototype._createIceAndDtlsTransports=function(){var c=this,a=new s.RTCIceTransport(null);a.onicestatechange=function(){c._updateIceConnectionState(),c._updateConnectionState()};var d=new s.RTCDtlsTransport(a);return d.ondtlsstatechange=function(){c._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),c._updateConnectionState()},{iceTransport:a,dtlsTransport:d}},o.prototype._disposeIceAndDtlsTransports=function(c){var a=this.transceivers[c].iceGatherer;a&&(delete a.onlocalcandidate,delete this.transceivers[c].iceGatherer);var d=this.transceivers[c].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[c].iceTransport);var h=this.transceivers[c].dtlsTransport;h&&(delete h.ondtlsstatechange,delete h.onerror,delete this.transceivers[c].dtlsTransport)},o.prototype._transceive=function(c,a,d){var h=ds(c.localCapabilities,c.remoteCapabilities);a&&c.rtpSender&&(h.encodings=c.sendEncodingParameters,h.rtcp={cname:k.localCName,compound:c.rtcpParameters.compound},c.recvEncodingParameters.length&&(h.rtcp.ssrc=c.recvEncodingParameters[0].ssrc),c.rtpSender.send(h)),d&&c.rtpReceiver&&h.codecs.length>0&&(c.kind==="video"&&c.recvEncodingParameters&&t<15019&&c.recvEncodingParameters.forEach(function(u){delete u.rtx}),c.recvEncodingParameters.length?h.encodings=c.recvEncodingParameters:h.encodings=[{}],h.rtcp={compound:c.rtcpParameters.compound},c.rtcpParameters.cname&&(h.rtcp.cname=c.rtcpParameters.cname),c.sendEncodingParameters.length&&(h.rtcp.ssrc=c.sendEncodingParameters[0].ssrc),c.rtpReceiver.receive(h))},o.prototype.setLocalDescription=function(c){var a=this;if(["offer","answer"].indexOf(c.type)===-1)return Promise.reject(mt("TypeError",'Unsupported type "'+c.type+'"'));if(!Lo("setLocalDescription",c.type,a.signalingState)||a._isClosed)return Promise.reject(mt("InvalidStateError","Can not set local "+c.type+" in state "+a.signalingState));var d,h;if(c.type==="offer")d=k.splitSections(c.sdp),h=d.shift(),d.forEach(function(p,m){var b=k.parseRtpParameters(p);a.transceivers[m].localCapabilities=b}),a.transceivers.forEach(function(p,m){a._gather(p.mid,m)});else if(c.type==="answer"){d=k.splitSections(a._remoteDescription.sdp),h=d.shift();var u=k.matchPrefix(h,"a=ice-lite").length>0;d.forEach(function(p,m){var b=a.transceivers[m],G=b.iceGatherer,y=b.iceTransport,Z=b.dtlsTransport,V=b.localCapabilities,R=b.remoteCapabilities,f=k.isRejected(p)&&k.matchPrefix(p,"a=bundle-only").length===0;if(!f&&!b.rejected){var x=k.getIceParameters(p,h),L=k.getDtlsParameters(p,h);u&&(L.role="server"),(!a.usingBundle||m===0)&&(a._gather(b.mid,m),y.state==="new"&&y.start(G,x,u?"controlling":"controlled"),Z.state==="new"&&Z.start(L));var W=ds(V,R);a._transceive(b,W.codecs.length>0,!1)}})}return a._localDescription={type:c.type,sdp:c.sdp},c.type==="offer"?a._updateSignalingState("have-local-offer"):a._updateSignalingState("stable"),Promise.resolve()},o.prototype.setRemoteDescription=function(c){var a=this;if(["offer","answer"].indexOf(c.type)===-1)return Promise.reject(mt("TypeError",'Unsupported type "'+c.type+'"'));if(!Lo("setRemoteDescription",c.type,a.signalingState)||a._isClosed)return Promise.reject(mt("InvalidStateError","Can not set remote "+c.type+" in state "+a.signalingState));var d={};a.remoteStreams.forEach(function(y){d[y.id]=y});var h=[],u=k.splitSections(c.sdp),p=u.shift(),m=k.matchPrefix(p,"a=ice-lite").length>0,b=k.matchPrefix(p,"a=group:BUNDLE ").length>0;a.usingBundle=b;var G=k.matchPrefix(p,"a=ice-options:")[0];return G?a.canTrickleIceCandidates=G.substr(14).split(" ").indexOf("trickle")>=0:a.canTrickleIceCandidates=!1,u.forEach(function(y,Z){var V=k.splitLines(y),R=k.getKind(y),f=k.isRejected(y)&&k.matchPrefix(y,"a=bundle-only").length===0,x=V[0].substr(2).split(" ")[2],L=k.getDirection(y,p),W=k.parseMsid(y),C=k.getMid(y)||k.generateIdentifier();if(f||R==="application"&&(x==="DTLS/SCTP"||x==="UDP/DTLS/SCTP")){a.transceivers[Z]={mid:C,kind:R,protocol:x,rejected:!0};return}!f&&a.transceivers[Z]&&a.transceivers[Z].rejected&&(a.transceivers[Z]=a._createTransceiver(R,!0));var S,z,g,v,K,Y,H,I,P,D=k.parseRtpParameters(y),it,tt;f||(it=k.getIceParameters(y,p),tt=k.getDtlsParameters(y,p),tt.role="client"),H=k.parseRtpEncodingParameters(y);var St=k.parseRtcpParameters(y),Vt=k.matchPrefix(y,"a=end-of-candidates",p).length>0,st=k.matchPrefix(y,"a=candidate:").map(function(_){return k.parseCandidate(_)}).filter(function(_){return _.component===1});if((c.type==="offer"||c.type==="answer")&&!f&&b&&Z>0&&a.transceivers[Z]&&(a._disposeIceAndDtlsTransports(Z),a.transceivers[Z].iceGatherer=a.transceivers[0].iceGatherer,a.transceivers[Z].iceTransport=a.transceivers[0].iceTransport,a.transceivers[Z].dtlsTransport=a.transceivers[0].dtlsTransport,a.transceivers[Z].rtpSender&&a.transceivers[Z].rtpSender.setTransport(a.transceivers[0].dtlsTransport),a.transceivers[Z].rtpReceiver&&a.transceivers[Z].rtpReceiver.setTransport(a.transceivers[0].dtlsTransport)),c.type==="offer"&&!f){S=a.transceivers[Z]||a._createTransceiver(R),S.mid=C,S.iceGatherer||(S.iceGatherer=a._createIceGatherer(Z,b)),st.length&&S.iceTransport.state==="new"&&(Vt&&(!b||Z===0)?S.iceTransport.setRemoteCandidates(st):st.forEach(function(_){cn(S.iceTransport,_)})),I=s.RTCRtpReceiver.getCapabilities(R),t<15019&&(I.codecs=I.codecs.filter(function(_){return _.name!=="rtx"})),Y=S.sendEncodingParameters||[{ssrc:(2*Z+2)*1001}];var pt=!1;if(L==="sendrecv"||L==="sendonly"){if(pt=!S.rtpReceiver,K=S.rtpReceiver||new s.RTCRtpReceiver(S.dtlsTransport,R),pt){var et;P=K.track,W&&W.stream==="-"||(W?(d[W.stream]||(d[W.stream]=new s.MediaStream,Object.defineProperty(d[W.stream],"id",{get:function(){return W.stream}})),Object.defineProperty(P,"id",{get:function(){return W.track}}),et=d[W.stream]):(d.default||(d.default=new s.MediaStream),et=d.default)),et&&(e(P,et),S.associatedRemoteMediaStreams.push(et)),h.push([P,K,et])}}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach(function(_){var Ut=_.getTracks().find(function(jt){return jt.id===S.rtpReceiver.track.id});Ut&&i(Ut,_)}),S.associatedRemoteMediaStreams=[]);S.localCapabilities=I,S.remoteCapabilities=D,S.rtpReceiver=K,S.rtcpParameters=St,S.sendEncodingParameters=Y,S.recvEncodingParameters=H,a._transceive(a.transceivers[Z],!1,pt)}else if(c.type==="answer"&&!f){S=a.transceivers[Z],z=S.iceGatherer,g=S.iceTransport,v=S.dtlsTransport,K=S.rtpReceiver,Y=S.sendEncodingParameters,I=S.localCapabilities,a.transceivers[Z].recvEncodingParameters=H,a.transceivers[Z].remoteCapabilities=D,a.transceivers[Z].rtcpParameters=St,st.length&&g.state==="new"&&((m||Vt)&&(!b||Z===0)?g.setRemoteCandidates(st):st.forEach(function(_){cn(S.iceTransport,_)})),(!b||Z===0)&&(g.state==="new"&&g.start(z,it,"controlling"),v.state==="new"&&v.start(tt));var j=ds(S.localCapabilities,S.remoteCapabilities),oe=j.codecs.filter(function(_){return _.name.toLowerCase()==="rtx"}).length;!oe&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,a._transceive(S,L==="sendrecv"||L==="recvonly",L==="sendrecv"||L==="sendonly"),K&&(L==="sendrecv"||L==="sendonly")?(P=K.track,W?(d[W.stream]||(d[W.stream]=new s.MediaStream),e(P,d[W.stream]),h.push([P,K,d[W.stream]])):(d.default||(d.default=new s.MediaStream),e(P,d.default),h.push([P,K,d.default]))):delete S.rtpReceiver}}),a._dtlsRole===void 0&&(a._dtlsRole=c.type==="offer"?"active":"passive"),a._remoteDescription={type:c.type,sdp:c.sdp},c.type==="offer"?a._updateSignalingState("have-remote-offer"):a._updateSignalingState("stable"),Object.keys(d).forEach(function(y){var Z=d[y];if(Z.getTracks().length){if(a.remoteStreams.indexOf(Z)===-1){a.remoteStreams.push(Z);var V=new Event("addstream");V.stream=Z,s.setTimeout(function(){a._dispatchEvent("addstream",V)})}h.forEach(function(R){var f=R[0],x=R[1];Z.id===R[2].id&&n(a,f,x,[Z])})}}),h.forEach(function(y){y[2]||n(a,y[0],y[1],[])}),s.setTimeout(function(){a&&a.transceivers&&a.transceivers.forEach(function(y){y.iceTransport&&y.iceTransport.state==="new"&&y.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),y.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},o.prototype.close=function(){this.transceivers.forEach(function(c){c.iceTransport&&c.iceTransport.stop(),c.dtlsTransport&&c.dtlsTransport.stop(),c.rtpSender&&c.rtpSender.stop(),c.rtpReceiver&&c.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},o.prototype._updateSignalingState=function(c){this.signalingState=c;var a=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",a)},o.prototype._maybeFireNegotiationNeeded=function(){var c=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,s.setTimeout(function(){if(c.needNegotiation){c.needNegotiation=!1;var a=new Event("negotiationneeded");c._dispatchEvent("negotiationneeded",a)}},0))},o.prototype._updateIceConnectionState=function(){var c,a={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(h){h.iceTransport&&!h.rejected&&a[h.iceTransport.state]++}),c="new",a.failed>0?c="failed":a.checking>0?c="checking":a.disconnected>0?c="disconnected":a.new>0?c="new":a.connected>0?c="connected":a.completed>0&&(c="completed"),c!==this.iceConnectionState){this.iceConnectionState=c;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},o.prototype._updateConnectionState=function(){var c,a={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(h){h.iceTransport&&h.dtlsTransport&&!h.rejected&&(a[h.iceTransport.state]++,a[h.dtlsTransport.state]++)}),a.connected+=a.completed,c="new",a.failed>0?c="failed":a.connecting>0?c="connecting":a.disconnected>0?c="disconnected":a.new>0?c="new":a.connected>0&&(c="connected"),c!==this.connectionState){this.connectionState=c;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},o.prototype.createOffer=function(){var c=this;if(c._isClosed)return Promise.reject(mt("InvalidStateError","Can not call createOffer after close"));var a=c.transceivers.filter(function(m){return m.kind==="audio"}).length,d=c.transceivers.filter(function(m){return m.kind==="video"}).length,h=arguments[0];if(h){if(h.mandatory||h.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");h.offerToReceiveAudio!==void 0&&(h.offerToReceiveAudio===!0?a=1:h.offerToReceiveAudio===!1?a=0:a=h.offerToReceiveAudio),h.offerToReceiveVideo!==void 0&&(h.offerToReceiveVideo===!0?d=1:h.offerToReceiveVideo===!1?d=0:d=h.offerToReceiveVideo)}for(c.transceivers.forEach(function(m){m.kind==="audio"?(a--,a<0&&(m.wantReceive=!1)):m.kind==="video"&&(d--,d<0&&(m.wantReceive=!1))});a>0||d>0;)a>0&&(c._createTransceiver("audio"),a--),d>0&&(c._createTransceiver("video"),d--);var u=k.writeSessionBoilerplate(c._sdpSessionId,c._sdpSessionVersion++);c.transceivers.forEach(function(m,b){var G=m.track,y=m.kind,Z=m.mid||k.generateIdentifier();m.mid=Z,m.iceGatherer||(m.iceGatherer=c._createIceGatherer(b,c.usingBundle));var V=s.RTCRtpSender.getCapabilities(y);t<15019&&(V.codecs=V.codecs.filter(function(f){return f.name!=="rtx"})),V.codecs.forEach(function(f){f.name==="H264"&&f.parameters["level-asymmetry-allowed"]===void 0&&(f.parameters["level-asymmetry-allowed"]="1"),m.remoteCapabilities&&m.remoteCapabilities.codecs&&m.remoteCapabilities.codecs.forEach(function(x){f.name.toLowerCase()===x.name.toLowerCase()&&f.clockRate===x.clockRate&&(f.preferredPayloadType=x.payloadType)})}),V.headerExtensions.forEach(function(f){var x=m.remoteCapabilities&&m.remoteCapabilities.headerExtensions||[];x.forEach(function(L){f.uri===L.uri&&(f.id=L.id)})});var R=m.sendEncodingParameters||[{ssrc:(2*b+1)*1001}];G&&t>=15019&&y==="video"&&!R[0].rtx&&(R[0].rtx={ssrc:R[0].ssrc+1}),m.wantReceive&&(m.rtpReceiver=new s.RTCRtpReceiver(m.dtlsTransport,y)),m.localCapabilities=V,m.sendEncodingParameters=R}),c._config.bundlePolicy!=="max-compat"&&(u+="a=group:BUNDLE "+c.transceivers.map(function(m){return m.mid}).join(" ")+`\r
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`,
|
|
54
|
-
|
|
55
|
-
`)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`:
|
|
59
|
-
`:u.kind==="audio"?a+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
|
|
35
|
+
`,e.rtpSender){var c="msid:"+s.id+" "+e.rtpSender.track.id+`\r
|
|
36
|
+
`;o+="a="+c,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
37
|
+
`)}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r
|
|
38
|
+
`,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r
|
|
39
|
+
`),o},t.getDirection=function(e,i){for(var n=t.splitLines(e),s=0;s<n.length;s++)switch(n[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[s].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){var i=t.splitLines(e),n=i[0].split(" ");return n[0].substr(2)},t.isRejected=function(e){return e.split(" ",2)[1]==="0"},t.parseMLine=function(e){var i=t.splitLines(e),n=i[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var i=t.matchPrefix(e,"o=")[0],n=i.substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if(typeof e!="string"||e.length===0)return!1;for(var i=t.splitLines(e),n=0;n<i.length;n++)if(i[n].length<2||i[n].charAt(1)!=="=")return!1;return!0},r.exports=t})(No);var Uo=No.exports;const Nr=Qr(Uo);var I=Uo;function rc(r){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[r.type]||r.type}function Ss(r,t,e,i,n){var s=I.writeRtpDescription(r.kind,t);if(s+=I.writeIceParameters(r.iceGatherer.getLocalParameters()),s+=I.writeDtlsParameters(r.dtlsTransport.getLocalParameters(),e==="offer"?"actpass":n||"active"),s+="a=mid:"+r.mid+`\r
|
|
40
|
+
`,r.rtpSender&&r.rtpReceiver?s+=`a=sendrecv\r
|
|
41
|
+
`:r.rtpSender?s+=`a=sendonly\r
|
|
42
|
+
`:r.rtpReceiver?s+=`a=recvonly\r
|
|
43
|
+
`:s+=`a=inactive\r
|
|
44
|
+
`,r.rtpSender){var o=r.rtpSender._initialTrackId||r.rtpSender.track.id;r.rtpSender._initialTrackId=o;var c="msid:"+(i?i.id:"-")+" "+o+`\r
|
|
45
|
+
`;s+="a="+c,s+="a=ssrc:"+r.sendEncodingParameters[0].ssrc+" "+c,r.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+r.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+r.sendEncodingParameters[0].ssrc+" "+r.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
46
|
+
`)}return s+="a=ssrc:"+r.sendEncodingParameters[0].ssrc+" cname:"+I.localCName+`\r
|
|
47
|
+
`,r.rtpSender&&r.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+r.sendEncodingParameters[0].rtx.ssrc+" cname:"+I.localCName+`\r
|
|
48
|
+
`),s}function nc(r,t){var e=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(function(i){if(i&&(i.urls||i.url)){var n=i.urls||i.url;i.url&&!i.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var s=typeof n=="string";return s&&(n=[n]),n=n.filter(function(o){var c=o.indexOf("turn:")===0&&o.indexOf("transport=udp")!==-1&&o.indexOf("turn:[")===-1&&!e;return c?(e=!0,!0):o.indexOf("stun:")===0&&t>=14393&&o.indexOf("?transport=udp")===-1}),delete i.url,i.urls=s?n[0]:n,!!n.length}})}function ur(r,t){var e={codecs:[],headerExtensions:[],fecMechanisms:[]},i=function(s,o){s=parseInt(s,10);for(var c=0;c<o.length;c++)if(o[c].payloadType===s||o[c].preferredPayloadType===s)return o[c]},n=function(s,o,c,a){var l=i(s.parameters.apt,c),u=i(o.parameters.apt,a);return l&&u&&l.name.toLowerCase()===u.name.toLowerCase()};return r.codecs.forEach(function(s){for(var o=0;o<t.codecs.length;o++){var c=t.codecs[o];if(s.name.toLowerCase()===c.name.toLowerCase()&&s.clockRate===c.clockRate){if(s.name.toLowerCase()==="rtx"&&s.parameters&&c.parameters.apt&&!n(s,c,r.codecs,t.codecs))continue;c=JSON.parse(JSON.stringify(c)),c.numChannels=Math.min(s.numChannels,c.numChannels),e.codecs.push(c),c.rtcpFeedback=c.rtcpFeedback.filter(function(a){for(var l=0;l<s.rtcpFeedback.length;l++)if(s.rtcpFeedback[l].type===a.type&&s.rtcpFeedback[l].parameter===a.parameter)return!0;return!1});break}}}),r.headerExtensions.forEach(function(s){for(var o=0;o<t.headerExtensions.length;o++){var c=t.headerExtensions[o];if(s.uri===c.uri){e.headerExtensions.push(c);break}}}),e}function Ts(r,t,e){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"]}}[t][r].indexOf(e)!==-1}function an(r,t){var e=r.getRemoteCandidates().find(function(i){return t.foundation===i.foundation&&t.ip===i.ip&&t.port===i.port&&t.priority===i.priority&&t.protocol===i.protocol&&t.type===i.type});return e||r.addRemoteCandidate(t),!e}function pt(r,t){var e=new Error(t);return e.name=r,e.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[r],e}var sc=function(r,t){function e(a,l){l.addTrack(a),l.dispatchEvent(new r.MediaStreamTrackEvent("addtrack",{track:a}))}function i(a,l){l.removeTrack(a),l.dispatchEvent(new r.MediaStreamTrackEvent("removetrack",{track:a}))}function n(a,l,u,h){var f=new Event("track");f.track=l,f.receiver=u,f.transceiver={receiver:u},f.streams=h,r.setTimeout(function(){a._dispatchEvent("track",f)})}var s=function(a){var l=this,u=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(f){l[f]=u[f].bind(u)}),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",a=JSON.parse(JSON.stringify(a||{})),this.usingBundle=a.bundlePolicy==="max-bundle",a.rtcpMuxPolicy==="negotiate")throw pt("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(a.rtcpMuxPolicy||(a.rtcpMuxPolicy="require"),a.iceTransportPolicy){case"all":case"relay":break;default:a.iceTransportPolicy="all";break}switch(a.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:a.bundlePolicy="balanced";break}if(a.iceServers=nc(a.iceServers||[],t),this._iceGatherers=[],a.iceCandidatePoolSize)for(var h=a.iceCandidatePoolSize;h>0;h--)this._iceGatherers.push(new r.RTCIceGatherer({iceServers:a.iceServers,gatherPolicy:a.iceTransportPolicy}));else a.iceCandidatePoolSize=0;this._config=a,this.transceivers=[],this._sdpSessionId=I.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(s.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(s.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),s.prototype.onicecandidate=null,s.prototype.onaddstream=null,s.prototype.ontrack=null,s.prototype.onremovestream=null,s.prototype.onsignalingstatechange=null,s.prototype.oniceconnectionstatechange=null,s.prototype.onconnectionstatechange=null,s.prototype.onicegatheringstatechange=null,s.prototype.onnegotiationneeded=null,s.prototype.ondatachannel=null,s.prototype._dispatchEvent=function(a,l){this._isClosed||(this.dispatchEvent(l),typeof this["on"+a]=="function"&&this["on"+a](l))},s.prototype._emitGatheringStateChange=function(){var a=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",a)},s.prototype.getConfiguration=function(){return this._config},s.prototype.getLocalStreams=function(){return this.localStreams},s.prototype.getRemoteStreams=function(){return this.remoteStreams},s.prototype._createTransceiver=function(a,l){var u=this.transceivers.length>0,h={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:a,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&u)h.iceTransport=this.transceivers[0].iceTransport,h.dtlsTransport=this.transceivers[0].dtlsTransport;else{var f=this._createIceAndDtlsTransports();h.iceTransport=f.iceTransport,h.dtlsTransport=f.dtlsTransport}return l||this.transceivers.push(h),h},s.prototype.addTrack=function(a,l){if(this._isClosed)throw pt("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var u=this.transceivers.find(function(d){return d.track===a});if(u)throw pt("InvalidAccessError","Track already exists.");for(var h,f=0;f<this.transceivers.length;f++)!this.transceivers[f].track&&this.transceivers[f].kind===a.kind&&(h=this.transceivers[f]);return h||(h=this._createTransceiver(a.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(l)===-1&&this.localStreams.push(l),h.track=a,h.stream=l,h.rtpSender=new r.RTCRtpSender(a,h.dtlsTransport),h.rtpSender},s.prototype.addStream=function(a){var l=this;if(t>=15025)a.getTracks().forEach(function(h){l.addTrack(h,a)});else{var u=a.clone();a.getTracks().forEach(function(h,f){var d=u.getTracks()[f];h.addEventListener("enabled",function(p){d.enabled=p.enabled})}),u.getTracks().forEach(function(h){l.addTrack(h,u)})}},s.prototype.removeTrack=function(a){if(this._isClosed)throw pt("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(a instanceof r.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var l=this.transceivers.find(function(f){return f.rtpSender===a});if(!l)throw pt("InvalidAccessError","Sender was not created by this connection.");var u=l.stream;l.rtpSender.stop(),l.rtpSender=null,l.track=null,l.stream=null;var h=this.transceivers.map(function(f){return f.stream});h.indexOf(u)===-1&&this.localStreams.indexOf(u)>-1&&this.localStreams.splice(this.localStreams.indexOf(u),1),this._maybeFireNegotiationNeeded()},s.prototype.removeStream=function(a){var l=this;a.getTracks().forEach(function(u){var h=l.getSenders().find(function(f){return f.track===u});h&&l.removeTrack(h)})},s.prototype.getSenders=function(){return this.transceivers.filter(function(a){return!!a.rtpSender}).map(function(a){return a.rtpSender})},s.prototype.getReceivers=function(){return this.transceivers.filter(function(a){return!!a.rtpReceiver}).map(function(a){return a.rtpReceiver})},s.prototype._createIceGatherer=function(a,l){var u=this;if(l&&a>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var h=new r.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(h,"state",{value:"new",writable:!0}),this.transceivers[a].bufferedCandidateEvents=[],this.transceivers[a].bufferCandidates=function(f){var d=!f.candidate||Object.keys(f.candidate).length===0;h.state=d?"completed":"gathering",u.transceivers[a].bufferedCandidateEvents!==null&&u.transceivers[a].bufferedCandidateEvents.push(f)},h.addEventListener("localcandidate",this.transceivers[a].bufferCandidates),h},s.prototype._gather=function(a,l){var u=this,h=this.transceivers[l].iceGatherer;if(!h.onlocalcandidate){var f=this.transceivers[l].bufferedCandidateEvents;this.transceivers[l].bufferedCandidateEvents=null,h.removeEventListener("localcandidate",this.transceivers[l].bufferCandidates),h.onlocalcandidate=function(d){if(!(u.usingBundle&&l>0)){var p=new Event("icecandidate");p.candidate={sdpMid:a,sdpMLineIndex:l};var m=d.candidate,g=!m||Object.keys(m).length===0;if(g)(h.state==="new"||h.state==="gathering")&&(h.state="completed");else{h.state==="new"&&(h.state="gathering"),m.component=1,m.ufrag=h.getLocalParameters().usernameFragment;var y=I.writeCandidate(m);p.candidate=Object.assign(p.candidate,I.parseCandidate(y)),p.candidate.candidate=y,p.candidate.toJSON=function(){return{candidate:p.candidate.candidate,sdpMid:p.candidate.sdpMid,sdpMLineIndex:p.candidate.sdpMLineIndex,usernameFragment:p.candidate.usernameFragment}}}var v=I.getMediaSections(u._localDescription.sdp);g?v[p.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
|
|
49
|
+
`:v[p.candidate.sdpMLineIndex]+="a="+p.candidate.candidate+`\r
|
|
50
|
+
`,u._localDescription.sdp=I.getDescription(u._localDescription.sdp)+v.join("");var b=u.transceivers.every(function(S){return S.iceGatherer&&S.iceGatherer.state==="completed"});u.iceGatheringState!=="gathering"&&(u.iceGatheringState="gathering",u._emitGatheringStateChange()),g||u._dispatchEvent("icecandidate",p),b&&(u._dispatchEvent("icecandidate",new Event("icecandidate")),u.iceGatheringState="complete",u._emitGatheringStateChange())}},r.setTimeout(function(){f.forEach(function(d){h.onlocalcandidate(d)})},0)}},s.prototype._createIceAndDtlsTransports=function(){var a=this,l=new r.RTCIceTransport(null);l.onicestatechange=function(){a._updateIceConnectionState(),a._updateConnectionState()};var u=new r.RTCDtlsTransport(l);return u.ondtlsstatechange=function(){a._updateConnectionState()},u.onerror=function(){Object.defineProperty(u,"state",{value:"failed",writable:!0}),a._updateConnectionState()},{iceTransport:l,dtlsTransport:u}},s.prototype._disposeIceAndDtlsTransports=function(a){var l=this.transceivers[a].iceGatherer;l&&(delete l.onlocalcandidate,delete this.transceivers[a].iceGatherer);var u=this.transceivers[a].iceTransport;u&&(delete u.onicestatechange,delete this.transceivers[a].iceTransport);var h=this.transceivers[a].dtlsTransport;h&&(delete h.ondtlsstatechange,delete h.onerror,delete this.transceivers[a].dtlsTransport)},s.prototype._transceive=function(a,l,u){var h=ur(a.localCapabilities,a.remoteCapabilities);l&&a.rtpSender&&(h.encodings=a.sendEncodingParameters,h.rtcp={cname:I.localCName,compound:a.rtcpParameters.compound},a.recvEncodingParameters.length&&(h.rtcp.ssrc=a.recvEncodingParameters[0].ssrc),a.rtpSender.send(h)),u&&a.rtpReceiver&&h.codecs.length>0&&(a.kind==="video"&&a.recvEncodingParameters&&t<15019&&a.recvEncodingParameters.forEach(function(f){delete f.rtx}),a.recvEncodingParameters.length?h.encodings=a.recvEncodingParameters:h.encodings=[{}],h.rtcp={compound:a.rtcpParameters.compound},a.rtcpParameters.cname&&(h.rtcp.cname=a.rtcpParameters.cname),a.sendEncodingParameters.length&&(h.rtcp.ssrc=a.sendEncodingParameters[0].ssrc),a.rtpReceiver.receive(h))},s.prototype.setLocalDescription=function(a){var l=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(pt("TypeError",'Unsupported type "'+a.type+'"'));if(!Ts("setLocalDescription",a.type,l.signalingState)||l._isClosed)return Promise.reject(pt("InvalidStateError","Can not set local "+a.type+" in state "+l.signalingState));var u,h;if(a.type==="offer")u=I.splitSections(a.sdp),h=u.shift(),u.forEach(function(d,p){var m=I.parseRtpParameters(d);l.transceivers[p].localCapabilities=m}),l.transceivers.forEach(function(d,p){l._gather(d.mid,p)});else if(a.type==="answer"){u=I.splitSections(l._remoteDescription.sdp),h=u.shift();var f=I.matchPrefix(h,"a=ice-lite").length>0;u.forEach(function(d,p){var m=l.transceivers[p],g=m.iceGatherer,y=m.iceTransport,v=m.dtlsTransport,b=m.localCapabilities,S=m.remoteCapabilities,_=I.isRejected(d)&&I.matchPrefix(d,"a=bundle-only").length===0;if(!_&&!m.rejected){var T=I.getIceParameters(d,h),M=I.getDtlsParameters(d,h);f&&(M.role="server"),(!l.usingBundle||p===0)&&(l._gather(m.mid,p),y.state==="new"&&y.start(g,T,f?"controlling":"controlled"),v.state==="new"&&v.start(M));var w=ur(b,S);l._transceive(m,w.codecs.length>0,!1)}})}return l._localDescription={type:a.type,sdp:a.sdp},a.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},s.prototype.setRemoteDescription=function(a){var l=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(pt("TypeError",'Unsupported type "'+a.type+'"'));if(!Ts("setRemoteDescription",a.type,l.signalingState)||l._isClosed)return Promise.reject(pt("InvalidStateError","Can not set remote "+a.type+" in state "+l.signalingState));var u={};l.remoteStreams.forEach(function(y){u[y.id]=y});var h=[],f=I.splitSections(a.sdp),d=f.shift(),p=I.matchPrefix(d,"a=ice-lite").length>0,m=I.matchPrefix(d,"a=group:BUNDLE ").length>0;l.usingBundle=m;var g=I.matchPrefix(d,"a=ice-options:")[0];return g?l.canTrickleIceCandidates=g.substr(14).split(" ").indexOf("trickle")>=0:l.canTrickleIceCandidates=!1,f.forEach(function(y,v){var b=I.splitLines(y),S=I.getKind(y),_=I.isRejected(y)&&I.matchPrefix(y,"a=bundle-only").length===0,T=b[0].substr(2).split(" ")[2],M=I.getDirection(y,d),w=I.parseMsid(y),E=I.getMid(y)||I.generateIdentifier();if(_||S==="application"&&(T==="DTLS/SCTP"||T==="UDP/DTLS/SCTP")){l.transceivers[v]={mid:E,kind:S,protocol:T,rejected:!0};return}!_&&l.transceivers[v]&&l.transceivers[v].rejected&&(l.transceivers[v]=l._createTransceiver(S,!0));var C,A,P,R,k,O,N,D,V,W=I.parseRtpParameters(y),it,tt;_||(it=I.getIceParameters(y,d),tt=I.getDtlsParameters(y,d),tt.role="client"),N=I.parseRtpEncodingParameters(y);var Ct=I.parseRtcpParameters(y),bt=I.matchPrefix(y,"a=end-of-candidates",d).length>0,rt=I.matchPrefix(y,"a=candidate:").map(function(Y){return I.parseCandidate(Y)}).filter(function(Y){return Y.component===1});if((a.type==="offer"||a.type==="answer")&&!_&&m&&v>0&&l.transceivers[v]&&(l._disposeIceAndDtlsTransports(v),l.transceivers[v].iceGatherer=l.transceivers[0].iceGatherer,l.transceivers[v].iceTransport=l.transceivers[0].iceTransport,l.transceivers[v].dtlsTransport=l.transceivers[0].dtlsTransport,l.transceivers[v].rtpSender&&l.transceivers[v].rtpSender.setTransport(l.transceivers[0].dtlsTransport),l.transceivers[v].rtpReceiver&&l.transceivers[v].rtpReceiver.setTransport(l.transceivers[0].dtlsTransport)),a.type==="offer"&&!_){C=l.transceivers[v]||l._createTransceiver(S),C.mid=E,C.iceGatherer||(C.iceGatherer=l._createIceGatherer(v,m)),rt.length&&C.iceTransport.state==="new"&&(bt&&(!m||v===0)?C.iceTransport.setRemoteCandidates(rt):rt.forEach(function(Y){an(C.iceTransport,Y)})),D=r.RTCRtpReceiver.getCapabilities(S),t<15019&&(D.codecs=D.codecs.filter(function(Y){return Y.name!=="rtx"})),O=C.sendEncodingParameters||[{ssrc:(2*v+2)*1001}];var dt=!1;if(M==="sendrecv"||M==="sendonly"){if(dt=!C.rtpReceiver,k=C.rtpReceiver||new r.RTCRtpReceiver(C.dtlsTransport,S),dt){var et;V=k.track,w&&w.stream==="-"||(w?(u[w.stream]||(u[w.stream]=new r.MediaStream,Object.defineProperty(u[w.stream],"id",{get:function(){return w.stream}})),Object.defineProperty(V,"id",{get:function(){return w.track}}),et=u[w.stream]):(u.default||(u.default=new r.MediaStream),et=u.default)),et&&(e(V,et),C.associatedRemoteMediaStreams.push(et)),h.push([V,k,et])}}else C.rtpReceiver&&C.rtpReceiver.track&&(C.associatedRemoteMediaStreams.forEach(function(Y){var Lt=Y.getTracks().find(function(qt){return qt.id===C.rtpReceiver.track.id});Lt&&i(Lt,Y)}),C.associatedRemoteMediaStreams=[]);C.localCapabilities=D,C.remoteCapabilities=W,C.rtpReceiver=k,C.rtcpParameters=Ct,C.sendEncodingParameters=O,C.recvEncodingParameters=N,l._transceive(l.transceivers[v],!1,dt)}else if(a.type==="answer"&&!_){C=l.transceivers[v],A=C.iceGatherer,P=C.iceTransport,R=C.dtlsTransport,k=C.rtpReceiver,O=C.sendEncodingParameters,D=C.localCapabilities,l.transceivers[v].recvEncodingParameters=N,l.transceivers[v].remoteCapabilities=W,l.transceivers[v].rtcpParameters=Ct,rt.length&&P.state==="new"&&((p||bt)&&(!m||v===0)?P.setRemoteCandidates(rt):rt.forEach(function(Y){an(C.iceTransport,Y)})),(!m||v===0)&&(P.state==="new"&&P.start(A,it,"controlling"),R.state==="new"&&R.start(tt));var q=ur(C.localCapabilities,C.remoteCapabilities),se=q.codecs.filter(function(Y){return Y.name.toLowerCase()==="rtx"}).length;!se&&C.sendEncodingParameters[0].rtx&&delete C.sendEncodingParameters[0].rtx,l._transceive(C,M==="sendrecv"||M==="recvonly",M==="sendrecv"||M==="sendonly"),k&&(M==="sendrecv"||M==="sendonly")?(V=k.track,w?(u[w.stream]||(u[w.stream]=new r.MediaStream),e(V,u[w.stream]),h.push([V,k,u[w.stream]])):(u.default||(u.default=new r.MediaStream),e(V,u.default),h.push([V,k,u.default]))):delete C.rtpReceiver}}),l._dtlsRole===void 0&&(l._dtlsRole=a.type==="offer"?"active":"passive"),l._remoteDescription={type:a.type,sdp:a.sdp},a.type==="offer"?l._updateSignalingState("have-remote-offer"):l._updateSignalingState("stable"),Object.keys(u).forEach(function(y){var v=u[y];if(v.getTracks().length){if(l.remoteStreams.indexOf(v)===-1){l.remoteStreams.push(v);var b=new Event("addstream");b.stream=v,r.setTimeout(function(){l._dispatchEvent("addstream",b)})}h.forEach(function(S){var _=S[0],T=S[1];v.id===S[2].id&&n(l,_,T,[v])})}}),h.forEach(function(y){y[2]||n(l,y[0],y[1],[])}),r.setTimeout(function(){l&&l.transceivers&&l.transceivers.forEach(function(y){y.iceTransport&&y.iceTransport.state==="new"&&y.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),y.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},s.prototype.close=function(){this.transceivers.forEach(function(a){a.iceTransport&&a.iceTransport.stop(),a.dtlsTransport&&a.dtlsTransport.stop(),a.rtpSender&&a.rtpSender.stop(),a.rtpReceiver&&a.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},s.prototype._updateSignalingState=function(a){this.signalingState=a;var l=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",l)},s.prototype._maybeFireNegotiationNeeded=function(){var a=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,r.setTimeout(function(){if(a.needNegotiation){a.needNegotiation=!1;var l=new Event("negotiationneeded");a._dispatchEvent("negotiationneeded",l)}},0))},s.prototype._updateIceConnectionState=function(){var a,l={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(h){h.iceTransport&&!h.rejected&&l[h.iceTransport.state]++}),a="new",l.failed>0?a="failed":l.checking>0?a="checking":l.disconnected>0?a="disconnected":l.new>0?a="new":l.connected>0?a="connected":l.completed>0&&(a="completed"),a!==this.iceConnectionState){this.iceConnectionState=a;var u=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",u)}},s.prototype._updateConnectionState=function(){var a,l={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(h){h.iceTransport&&h.dtlsTransport&&!h.rejected&&(l[h.iceTransport.state]++,l[h.dtlsTransport.state]++)}),l.connected+=l.completed,a="new",l.failed>0?a="failed":l.connecting>0?a="connecting":l.disconnected>0?a="disconnected":l.new>0?a="new":l.connected>0&&(a="connected"),a!==this.connectionState){this.connectionState=a;var u=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",u)}},s.prototype.createOffer=function(){var a=this;if(a._isClosed)return Promise.reject(pt("InvalidStateError","Can not call createOffer after close"));var l=a.transceivers.filter(function(p){return p.kind==="audio"}).length,u=a.transceivers.filter(function(p){return p.kind==="video"}).length,h=arguments[0];if(h){if(h.mandatory||h.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");h.offerToReceiveAudio!==void 0&&(h.offerToReceiveAudio===!0?l=1:h.offerToReceiveAudio===!1?l=0:l=h.offerToReceiveAudio),h.offerToReceiveVideo!==void 0&&(h.offerToReceiveVideo===!0?u=1:h.offerToReceiveVideo===!1?u=0:u=h.offerToReceiveVideo)}for(a.transceivers.forEach(function(p){p.kind==="audio"?(l--,l<0&&(p.wantReceive=!1)):p.kind==="video"&&(u--,u<0&&(p.wantReceive=!1))});l>0||u>0;)l>0&&(a._createTransceiver("audio"),l--),u>0&&(a._createTransceiver("video"),u--);var f=I.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.transceivers.forEach(function(p,m){var g=p.track,y=p.kind,v=p.mid||I.generateIdentifier();p.mid=v,p.iceGatherer||(p.iceGatherer=a._createIceGatherer(m,a.usingBundle));var b=r.RTCRtpSender.getCapabilities(y);t<15019&&(b.codecs=b.codecs.filter(function(_){return _.name!=="rtx"})),b.codecs.forEach(function(_){_.name==="H264"&&_.parameters["level-asymmetry-allowed"]===void 0&&(_.parameters["level-asymmetry-allowed"]="1"),p.remoteCapabilities&&p.remoteCapabilities.codecs&&p.remoteCapabilities.codecs.forEach(function(T){_.name.toLowerCase()===T.name.toLowerCase()&&_.clockRate===T.clockRate&&(_.preferredPayloadType=T.payloadType)})}),b.headerExtensions.forEach(function(_){var T=p.remoteCapabilities&&p.remoteCapabilities.headerExtensions||[];T.forEach(function(M){_.uri===M.uri&&(_.id=M.id)})});var S=p.sendEncodingParameters||[{ssrc:(2*m+1)*1001}];g&&t>=15019&&y==="video"&&!S[0].rtx&&(S[0].rtx={ssrc:S[0].ssrc+1}),p.wantReceive&&(p.rtpReceiver=new r.RTCRtpReceiver(p.dtlsTransport,y)),p.localCapabilities=b,p.sendEncodingParameters=S}),a._config.bundlePolicy!=="max-compat"&&(f+="a=group:BUNDLE "+a.transceivers.map(function(p){return p.mid}).join(" ")+`\r
|
|
51
|
+
`),f+=`a=ice-options:trickle\r
|
|
52
|
+
`,a.transceivers.forEach(function(p,m){f+=Ss(p,p.localCapabilities,"offer",p.stream,a._dtlsRole),f+=`a=rtcp-rsize\r
|
|
53
|
+
`,p.iceGatherer&&a.iceGatheringState!=="new"&&(m===0||!a.usingBundle)&&(p.iceGatherer.getLocalCandidates().forEach(function(g){g.component=1,f+="a="+I.writeCandidate(g)+`\r
|
|
54
|
+
`}),p.iceGatherer.state==="completed"&&(f+=`a=end-of-candidates\r
|
|
55
|
+
`))});var d=new r.RTCSessionDescription({type:"offer",sdp:f});return Promise.resolve(d)},s.prototype.createAnswer=function(){var a=this;if(a._isClosed)return Promise.reject(pt("InvalidStateError","Can not call createAnswer after close"));if(!(a.signalingState==="have-remote-offer"||a.signalingState==="have-local-pranswer"))return Promise.reject(pt("InvalidStateError","Can not call createAnswer in signalingState "+a.signalingState));var l=I.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.usingBundle&&(l+="a=group:BUNDLE "+a.transceivers.map(function(f){return f.mid}).join(" ")+`\r
|
|
56
|
+
`),l+=`a=ice-options:trickle\r
|
|
57
|
+
`;var u=I.getMediaSections(a._remoteDescription.sdp).length;a.transceivers.forEach(function(f,d){if(!(d+1>u)){if(f.rejected){f.kind==="application"?f.protocol==="DTLS/SCTP"?l+=`m=application 0 DTLS/SCTP 5000\r
|
|
58
|
+
`:l+="m=application 0 "+f.protocol+` webrtc-datachannel\r
|
|
59
|
+
`:f.kind==="audio"?l+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
|
|
60
60
|
a=rtpmap:0 PCMU/8000\r
|
|
61
|
-
`:
|
|
61
|
+
`:f.kind==="video"&&(l+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
|
|
62
62
|
a=rtpmap:120 VP8/90000\r
|
|
63
|
-
`),
|
|
63
|
+
`),l+=`c=IN IP4 0.0.0.0\r
|
|
64
64
|
a=inactive\r
|
|
65
|
-
a=mid:`+
|
|
66
|
-
`;return}if(
|
|
67
|
-
`)}});var h=new
|
|
68
|
-
`,
|
|
69
|
-
`,a._remoteDescription.sdp=k.getDescription(a._remoteDescription.sdp)+d.join("")}else return u(mt("OperationError","Can not add ICE candidate"))}else return u(mt("InvalidStateError","Can not add ICE candidate without a remote description"));h()})},o.prototype.getStats=function(c){if(c&&c instanceof s.MediaStreamTrack){var a=null;if(this.transceivers.forEach(function(h){h.rtpSender&&h.rtpSender.track===c?a=h.rtpSender:h.rtpReceiver&&h.rtpReceiver.track===c&&(a=h.rtpReceiver)}),!a)throw mt("InvalidAccessError","Invalid selector.");return a.getStats()}var d=[];return this.transceivers.forEach(function(h){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(u){h[u]&&d.push(h[u].getStats())})}),Promise.all(d).then(function(h){var u=new Map;return h.forEach(function(p){p.forEach(function(m){u.set(m.id,m)})}),u})};var r=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];r.forEach(function(c){var a=s[c];if(a&&a.prototype&&a.prototype.getStats){var d=a.prototype.getStats;a.prototype.getStats=function(){return d.apply(this).then(function(h){var u=new Map;return Object.keys(h).forEach(function(p){h[p].type=ol(h[p]),u.set(p,h[p])}),u})}}});var l=["createOffer","createAnswer"];return l.forEach(function(c){var a=o.prototype[c];o.prototype[c]=function(){var d=arguments;return typeof d[0]=="function"||typeof d[1]=="function"?a.apply(this,[arguments[2]]).then(function(h){typeof d[0]=="function"&&d[0].apply(null,[h])},function(h){typeof d[1]=="function"&&d[1].apply(null,[h])}):a.apply(this,arguments)}}),l=["setLocalDescription","setRemoteDescription","addIceCandidate"],l.forEach(function(c){var a=o.prototype[c];o.prototype[c]=function(){var d=arguments;return typeof d[1]=="function"||typeof d[2]=="function"?a.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)},function(h){typeof d[2]=="function"&&d[2].apply(null,[h])}):a.apply(this,arguments)}}),["getStats"].forEach(function(c){var a=o.prototype[c];o.prototype[c]=function(){var d=arguments;return typeof d[1]=="function"?a.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)}):a.apply(this,arguments)}}),o};const ll=qs(cl);function Jr(s){const t=s&&s.navigator,e=function(n){return{name:{PermissionDeniedError:"NotAllowedError"}[n.name]||n.name,message:n.message,constraint:n.constraint,toString(){return this.name}}},i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(n){return i(n).catch(o=>Promise.reject(e(o)))}}function Ur(s){"getDisplayMedia"in s.navigator&&s.navigator.mediaDevices&&(s.navigator.mediaDevices&&"getDisplayMedia"in s.navigator.mediaDevices||(s.navigator.mediaDevices.getDisplayMedia=s.navigator.getDisplayMedia.bind(s.navigator)))}function Mn(s,t){if(s.RTCIceGatherer&&(s.RTCIceCandidate||(s.RTCIceCandidate=function(n){return n}),s.RTCSessionDescription||(s.RTCSessionDescription=function(n){return n}),t.version<15025)){const i=Object.getOwnPropertyDescriptor(s.MediaStreamTrack.prototype,"enabled");Object.defineProperty(s.MediaStreamTrack.prototype,"enabled",{set(n){i.set.call(this,n);const o=new Event("enabled");o.enabled=n,this.dispatchEvent(o)}})}s.RTCRtpSender&&!("dtmf"in s.RTCRtpSender.prototype)&&Object.defineProperty(s.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new s.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),s.RTCDtmfSender&&!s.RTCDTMFSender&&(s.RTCDTMFSender=s.RTCDtmfSender);const e=ll(s,t.version);s.RTCPeerConnection=function(n){return n&&n.iceServers&&(n.iceServers=nl(n.iceServers,t.version),eo("ICE servers after filtering:",n.iceServers)),new e(n)},s.RTCPeerConnection.prototype=e.prototype}function Pr(s){s.RTCRtpSender&&!("replaceTrack"in s.RTCRtpSender.prototype)&&(s.RTCRtpSender.prototype.replaceTrack=s.RTCRtpSender.prototype.setTrack)}const So=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:Ur,shimGetUserMedia:Jr,shimPeerConnection:Mn,shimReplaceTrack:Pr},Symbol.toStringTag,{value:"Module"}));function Fr(s,t){const e=s&&s.navigator,i=s&&s.MediaStreamTrack;if(e.getUserMedia=function(n,o,r){$s("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),e.mediaDevices.getUserMedia(n).then(o,r)},!(t.version>55&&"autoGainControl"in e.mediaDevices.getSupportedConstraints())){const n=function(r,l,c){l in r&&!(c in r)&&(r[c]=r[l],delete r[l])},o=e.mediaDevices.getUserMedia.bind(e.mediaDevices);if(e.mediaDevices.getUserMedia=function(r){return typeof r=="object"&&typeof r.audio=="object"&&(r=JSON.parse(JSON.stringify(r)),n(r.audio,"autoGainControl","mozAutoGainControl"),n(r.audio,"noiseSuppression","mozNoiseSuppression")),o(r)},i&&i.prototype.getSettings){const r=i.prototype.getSettings;i.prototype.getSettings=function(){const l=r.apply(this,arguments);return n(l,"mozAutoGainControl","autoGainControl"),n(l,"mozNoiseSuppression","noiseSuppression"),l}}if(i&&i.prototype.applyConstraints){const r=i.prototype.applyConstraints;i.prototype.applyConstraints=function(l){return this.kind==="audio"&&typeof l=="object"&&(l=JSON.parse(JSON.stringify(l)),n(l,"autoGainControl","mozAutoGainControl"),n(l,"noiseSuppression","mozNoiseSuppression")),r.apply(this,[l])}}}}function al(s,t){s.navigator.mediaDevices&&"getDisplayMedia"in s.navigator.mediaDevices||s.navigator.mediaDevices&&(s.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return i.video===!0?i.video={mediaSource:t}:i.video.mediaSource=t,s.navigator.mediaDevices.getUserMedia(i)})}function Qr(s){typeof s=="object"&&s.RTCTrackEvent&&"receiver"in s.RTCTrackEvent.prototype&&!("transceiver"in s.RTCTrackEvent.prototype)&&Object.defineProperty(s.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Yn(s,t){if(typeof s!="object"||!(s.RTCPeerConnection||s.mozRTCPeerConnection))return;!s.RTCPeerConnection&&s.mozRTCPeerConnection&&(s.RTCPeerConnection=s.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const o=s.RTCPeerConnection.prototype[n],r={[n](){return arguments[0]=new(n==="addIceCandidate"?s.RTCIceCandidate:s.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};s.RTCPeerConnection.prototype[n]=r[n]});const e={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(){const[o,r,l]=arguments;return i.apply(this,[o||null]).then(c=>{if(t.version<53&&!r)try{c.forEach(a=>{a.type=e[a.type]||a.type})}catch(a){if(a.name!=="TypeError")throw a;c.forEach((d,h)=>{c.set(h,Object.assign({},d,{type:e[d.type]||d.type}))})}return c}).then(r,l)}}function wr(s){if(!(typeof s=="object"&&s.RTCPeerConnection&&s.RTCRtpSender)||s.RTCRtpSender&&"getStats"in s.RTCRtpSender.prototype)return;const t=s.RTCPeerConnection.prototype.getSenders;t&&(s.RTCPeerConnection.prototype.getSenders=function(){const n=t.apply(this,[]);return n.forEach(o=>o._pc=this),n});const e=s.RTCPeerConnection.prototype.addTrack;e&&(s.RTCPeerConnection.prototype.addTrack=function(){const n=e.apply(this,arguments);return n._pc=this,n}),s.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Br(s){if(!(typeof s=="object"&&s.RTCPeerConnection&&s.RTCRtpSender)||s.RTCRtpSender&&"getStats"in s.RTCRtpReceiver.prototype)return;const t=s.RTCPeerConnection.prototype.getReceivers;t&&(s.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i}),qe(s,"track",e=>(e.receiver._pc=e.srcElement,e)),s.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Er(s){!s.RTCPeerConnection||"removeStream"in s.RTCPeerConnection.prototype||(s.RTCPeerConnection.prototype.removeStream=function(e){$s("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&e.getTracks().includes(i.track)&&this.removeTrack(i)})})}function jr(s){s.DataChannel&&!s.RTCDataChannel&&(s.RTCDataChannel=s.DataChannel)}function Or(s){if(!(typeof s=="object"&&s.RTCPeerConnection))return;const t=s.RTCPeerConnection.prototype.addTransceiver;t&&(s.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const i=arguments[1],n=i&&"sendEncodings"in i;n&&i.sendEncodings.forEach(r=>{if("rid"in r&&!/^[a-z0-9]{0,16}$/i.test(r.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in r&&!(parseFloat(r.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in r&&!(parseFloat(r.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const o=t.apply(this,arguments);if(n){const{sender:r}=o,l=r.getParameters();(!("encodings"in l)||l.encodings.length===1&&Object.keys(l.encodings[0]).length===0)&&(l.encodings=i.sendEncodings,r.sendEncodings=i.sendEncodings,this.setParametersPromises.push(r.setParameters(l).then(()=>{delete r.sendEncodings}).catch(()=>{delete r.sendEncodings})))}return o})}function Dr(s){if(!(typeof s=="object"&&s.RTCRtpSender))return;const t=s.RTCRtpSender.prototype.getParameters;t&&(s.RTCRtpSender.prototype.getParameters=function(){const i=t.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function _r(s){if(!(typeof s=="object"&&s.RTCPeerConnection))return;const t=s.RTCPeerConnection.prototype.createOffer;s.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function Ar(s){if(!(typeof s=="object"&&s.RTCPeerConnection))return;const t=s.RTCPeerConnection.prototype.createAnswer;s.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}const Wo=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:Or,shimCreateAnswer:Ar,shimCreateOffer:_r,shimGetDisplayMedia:al,shimGetParameters:Dr,shimGetUserMedia:Fr,shimOnTrack:Qr,shimPeerConnection:Yn,shimRTCDataChannel:jr,shimReceiverGetStats:Br,shimRemoveStream:Er,shimSenderGetStats:wr},Symbol.toStringTag,{value:"Module"}));function qr(s){if(!(typeof s!="object"||!s.RTCPeerConnection)){if("getLocalStreams"in s.RTCPeerConnection.prototype||(s.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in s.RTCPeerConnection.prototype)){const t=s.RTCPeerConnection.prototype.addTrack;s.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(n=>t.call(this,n,i)),i.getVideoTracks().forEach(n=>t.call(this,n,i))},s.RTCPeerConnection.prototype.addTrack=function(i,...n){return n&&n.forEach(o=>{this._localStreams?this._localStreams.includes(o)||this._localStreams.push(o):this._localStreams=[o]}),t.apply(this,arguments)}}"removeStream"in s.RTCPeerConnection.prototype||(s.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(e);if(i===-1)return;this._localStreams.splice(i,1);const n=e.getTracks();this.getSenders().forEach(o=>{n.includes(o.track)&&this.removeTrack(o)})})}}function $r(s){if(!(typeof s!="object"||!s.RTCPeerConnection)&&("getRemoteStreams"in s.RTCPeerConnection.prototype||(s.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in s.RTCPeerConnection.prototype))){Object.defineProperty(s.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(n=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(n))return;this._remoteStreams.push(n);const o=new Event("addstream");o.stream=n,this.dispatchEvent(o)})})}});const t=s.RTCPeerConnection.prototype.setRemoteDescription;s.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(n){n.streams.forEach(o=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(o)>=0)return;i._remoteStreams.push(o);const r=new Event("addstream");r.stream=o,i.dispatchEvent(r)})}),t.apply(i,arguments)}}}function tc(s){if(typeof s!="object"||!s.RTCPeerConnection)return;const t=s.RTCPeerConnection.prototype,e=t.createOffer,i=t.createAnswer,n=t.setLocalDescription,o=t.setRemoteDescription,r=t.addIceCandidate;t.createOffer=function(a,d){const h=arguments.length>=2?arguments[2]:arguments[0],u=e.apply(this,[h]);return d?(u.then(a,d),Promise.resolve()):u},t.createAnswer=function(a,d){const h=arguments.length>=2?arguments[2]:arguments[0],u=i.apply(this,[h]);return d?(u.then(a,d),Promise.resolve()):u};let l=function(c,a,d){const h=n.apply(this,[c]);return d?(h.then(a,d),Promise.resolve()):h};t.setLocalDescription=l,l=function(c,a,d){const h=o.apply(this,[c]);return d?(h.then(a,d),Promise.resolve()):h},t.setRemoteDescription=l,l=function(c,a,d){const h=r.apply(this,[c]);return d?(h.then(a,d),Promise.resolve()):h},t.addIceCandidate=l}function ec(s){const t=s&&s.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=n=>i(ic(n))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(i,n,o){t.mediaDevices.getUserMedia(i).then(n,o)}.bind(t))}function ic(s){return s&&s.video!==void 0?Object.assign({},s,{video:gr(s.video)}):s}function sc(s){if(!s.RTCPeerConnection)return;const t=s.RTCPeerConnection;s.RTCPeerConnection=function(i,n){if(i&&i.iceServers){const o=[];for(let r=0;r<i.iceServers.length;r++){let l=i.iceServers[r];!l.hasOwnProperty("urls")&&l.hasOwnProperty("url")?($s("RTCIceServer.url","RTCIceServer.urls"),l=JSON.parse(JSON.stringify(l)),l.urls=l.url,delete l.url,o.push(l)):o.push(i.iceServers[r])}i.iceServers=o}return new t(i,n)},s.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(s.RTCPeerConnection,"generateCertificate",{get(){return t.generateCertificate}})}function nc(s){typeof s=="object"&&s.RTCTrackEvent&&"receiver"in s.RTCTrackEvent.prototype&&!("transceiver"in s.RTCTrackEvent.prototype)&&Object.defineProperty(s.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function oc(s){const t=s.RTCPeerConnection.prototype.createOffer;s.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const n=this.getTransceivers().find(r=>r.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&n?n.direction==="sendrecv"?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":n.direction==="recvonly"&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):i.offerToReceiveAudio===!0&&!n&&this.addTransceiver("audio"),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const o=this.getTransceivers().find(r=>r.receiver.track.kind==="video");i.offerToReceiveVideo===!1&&o?o.direction==="sendrecv"?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":o.direction==="recvonly"&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):i.offerToReceiveVideo===!0&&!o&&this.addTransceiver("video")}return t.apply(this,arguments)}}function rc(s){typeof s!="object"||s.AudioContext||(s.AudioContext=s.webkitAudioContext)}const go=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:rc,shimCallbacksAPI:tc,shimConstraints:ic,shimCreateOfferLegacy:oc,shimGetUserMedia:ec,shimLocalStreamsAPI:qr,shimRTCIceServerUrls:sc,shimRemoteStreamsAPI:$r,shimTrackEventTransceiver:nc},Symbol.toStringTag,{value:"Module"}));function Ns(s){if(!s.RTCIceCandidate||s.RTCIceCandidate&&"foundation"in s.RTCIceCandidate.prototype)return;const t=s.RTCIceCandidate;s.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substr(2)),i.candidate&&i.candidate.length){const n=new t(i),o=Hs.parseCandidate(i.candidate),r=Object.assign(n,o);return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(i)},s.RTCIceCandidate.prototype=t.prototype,qe(s,"icecandidate",e=>(e.candidate&&Object.defineProperty(e,"candidate",{value:new s.RTCIceCandidate(e.candidate),writable:"false"}),e))}function Vi(s,t){if(!s.RTCPeerConnection)return;"sctp"in s.RTCPeerConnection.prototype||Object.defineProperty(s.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const e=function(l){if(!l||!l.sdp)return!1;const c=Hs.splitSections(l.sdp);return c.shift(),c.some(a=>{const d=Hs.parseMLine(a);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},i=function(l){const c=l.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const a=parseInt(c[1],10);return a!==a?-1:a},n=function(l){let c=65536;return t.browser==="firefox"&&(t.version<57?l===-1?c=16384:c=2147483637:t.version<60?c=t.version===57?65535:65536:c=2147483637),c},o=function(l,c){let a=65536;t.browser==="firefox"&&t.version===57&&(a=65535);const d=Hs.matchPrefix(l.sdp,"a=max-message-size:");return d.length>0?a=parseInt(d[0].substr(19),10):t.browser==="firefox"&&c!==-1&&(a=2147483637),a},r=s.RTCPeerConnection.prototype.setRemoteDescription;s.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.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(e(arguments[0])){const c=i(arguments[0]),a=n(c),d=o(arguments[0],c);let h;a===0&&d===0?h=Number.POSITIVE_INFINITY:a===0||d===0?h=Math.max(a,d):h=Math.min(a,d);const u={};Object.defineProperty(u,"maxMessageSize",{get(){return h}}),this._sctp=u}return r.apply(this,arguments)}}function Ri(s){if(!(s.RTCPeerConnection&&"createDataChannel"in s.RTCPeerConnection.prototype))return;function t(i,n){const o=i.send;i.send=function(){const l=arguments[0],c=l.length||l.size||l.byteLength;if(i.readyState==="open"&&n.sctp&&c>n.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+n.sctp.maxMessageSize+" bytes)");return o.apply(i,arguments)}}const e=s.RTCPeerConnection.prototype.createDataChannel;s.RTCPeerConnection.prototype.createDataChannel=function(){const n=e.apply(this,arguments);return t(n,this),n},qe(s,"datachannel",i=>(t(i.channel,i.target),i))}function kn(s){if(!s.RTCPeerConnection||"connectionState"in s.RTCPeerConnection.prototype)return;const t=s.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=n=>{const o=n.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const r=new Event("connectionstatechange",n);o.dispatchEvent(r)}return n},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function Hn(s,t){if(!s.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;const e=s.RTCPeerConnection.prototype.setRemoteDescription;s.RTCPeerConnection.prototype.setRemoteDescription=function(n){if(n&&n.sdp&&n.sdp.indexOf(`
|
|
70
|
-
a=extmap-allow-mixed`)!==-1){const
|
|
71
|
-
`).filter(
|
|
72
|
-
`);
|
|
65
|
+
a=mid:`+f.mid+`\r
|
|
66
|
+
`;return}if(f.stream){var p;f.kind==="audio"?p=f.stream.getAudioTracks()[0]:f.kind==="video"&&(p=f.stream.getVideoTracks()[0]),p&&t>=15019&&f.kind==="video"&&!f.sendEncodingParameters[0].rtx&&(f.sendEncodingParameters[0].rtx={ssrc:f.sendEncodingParameters[0].ssrc+1})}var m=ur(f.localCapabilities,f.remoteCapabilities),g=m.codecs.filter(function(y){return y.name.toLowerCase()==="rtx"}).length;!g&&f.sendEncodingParameters[0].rtx&&delete f.sendEncodingParameters[0].rtx,l+=Ss(f,m,"answer",f.stream,a._dtlsRole),f.rtcpParameters&&f.rtcpParameters.reducedSize&&(l+=`a=rtcp-rsize\r
|
|
67
|
+
`)}});var h=new r.RTCSessionDescription({type:"answer",sdp:l});return Promise.resolve(h)},s.prototype.addIceCandidate=function(a){var l=this,u;return a&&!(a.sdpMLineIndex!==void 0||a.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(h,f){if(l._remoteDescription)if(!a||a.candidate==="")for(var d=0;d<l.transceivers.length&&!(!l.transceivers[d].rejected&&(l.transceivers[d].iceTransport.addRemoteCandidate({}),u=I.getMediaSections(l._remoteDescription.sdp),u[d]+=`a=end-of-candidates\r
|
|
68
|
+
`,l._remoteDescription.sdp=I.getDescription(l._remoteDescription.sdp)+u.join(""),l.usingBundle));d++);else{var p=a.sdpMLineIndex;if(a.sdpMid){for(var m=0;m<l.transceivers.length;m++)if(l.transceivers[m].mid===a.sdpMid){p=m;break}}var g=l.transceivers[p];if(g){if(g.rejected)return h();var y=Object.keys(a.candidate).length>0?I.parseCandidate(a.candidate):{};if(y.protocol==="tcp"&&(y.port===0||y.port===9)||y.component&&y.component!==1)return h();if((p===0||p>0&&g.iceTransport!==l.transceivers[0].iceTransport)&&!an(g.iceTransport,y))return f(pt("OperationError","Can not add ICE candidate"));var v=a.candidate.trim();v.indexOf("a=")===0&&(v=v.substr(2)),u=I.getMediaSections(l._remoteDescription.sdp),u[p]+="a="+(y.type?v:"end-of-candidates")+`\r
|
|
69
|
+
`,l._remoteDescription.sdp=I.getDescription(l._remoteDescription.sdp)+u.join("")}else return f(pt("OperationError","Can not add ICE candidate"))}else return f(pt("InvalidStateError","Can not add ICE candidate without a remote description"));h()})},s.prototype.getStats=function(a){if(a&&a instanceof r.MediaStreamTrack){var l=null;if(this.transceivers.forEach(function(h){h.rtpSender&&h.rtpSender.track===a?l=h.rtpSender:h.rtpReceiver&&h.rtpReceiver.track===a&&(l=h.rtpReceiver)}),!l)throw pt("InvalidAccessError","Invalid selector.");return l.getStats()}var u=[];return this.transceivers.forEach(function(h){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(f){h[f]&&u.push(h[f].getStats())})}),Promise.all(u).then(function(h){var f=new Map;return h.forEach(function(d){d.forEach(function(p){f.set(p.id,p)})}),f})};var o=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];o.forEach(function(a){var l=r[a];if(l&&l.prototype&&l.prototype.getStats){var u=l.prototype.getStats;l.prototype.getStats=function(){return u.apply(this).then(function(h){var f=new Map;return Object.keys(h).forEach(function(d){h[d].type=rc(h[d]),f.set(d,h[d])}),f})}}});var c=["createOffer","createAnswer"];return c.forEach(function(a){var l=s.prototype[a];s.prototype[a]=function(){var u=arguments;return typeof u[0]=="function"||typeof u[1]=="function"?l.apply(this,[arguments[2]]).then(function(h){typeof u[0]=="function"&&u[0].apply(null,[h])},function(h){typeof u[1]=="function"&&u[1].apply(null,[h])}):l.apply(this,arguments)}}),c=["setLocalDescription","setRemoteDescription","addIceCandidate"],c.forEach(function(a){var l=s.prototype[a];s.prototype[a]=function(){var u=arguments;return typeof u[1]=="function"||typeof u[2]=="function"?l.apply(this,arguments).then(function(){typeof u[1]=="function"&&u[1].apply(null)},function(h){typeof u[2]=="function"&&u[2].apply(null,[h])}):l.apply(this,arguments)}}),["getStats"].forEach(function(a){var l=s.prototype[a];s.prototype[a]=function(){var u=arguments;return typeof u[1]=="function"?l.apply(this,arguments).then(function(){typeof u[1]=="function"&&u[1].apply(null)}):l.apply(this,arguments)}}),s};const oc=Qr(sc);function Do(r){const t=r&&r.navigator,e=function(n){return{name:{PermissionDeniedError:"NotAllowedError"}[n.name]||n.name,message:n.message,constraint:n.constraint,toString(){return this.name}}},i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(n){return i(n).catch(s=>Promise.reject(e(s)))}}function Fo(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 zn(r,t){if(r.RTCIceGatherer&&(r.RTCIceCandidate||(r.RTCIceCandidate=function(n){return n}),r.RTCSessionDescription||(r.RTCSessionDescription=function(n){return n}),t.version<15025)){const i=Object.getOwnPropertyDescriptor(r.MediaStreamTrack.prototype,"enabled");Object.defineProperty(r.MediaStreamTrack.prototype,"enabled",{set(n){i.set.call(this,n);const s=new Event("enabled");s.enabled=n,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 e=oc(r,t.version);r.RTCPeerConnection=function(n){return n&&n.iceServers&&(n.iceServers=ic(n.iceServers,t.version),es("ICE servers after filtering:",n.iceServers)),new e(n)},r.RTCPeerConnection.prototype=e.prototype}function Lo(r){r.RTCRtpSender&&!("replaceTrack"in r.RTCRtpSender.prototype)&&(r.RTCRtpSender.prototype.replaceTrack=r.RTCRtpSender.prototype.setTrack)}const Ms=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:Fo,shimGetUserMedia:Do,shimPeerConnection:zn,shimReplaceTrack:Lo},Symbol.toStringTag,{value:"Module"}));function Vo(r,t){const e=r&&r.navigator,i=r&&r.MediaStreamTrack;if(e.getUserMedia=function(n,s,o){Kr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),e.mediaDevices.getUserMedia(n).then(s,o)},!(t.version>55&&"autoGainControl"in e.mediaDevices.getSupportedConstraints())){const n=function(o,c,a){c in o&&!(a in o)&&(o[a]=o[c],delete o[c])},s=e.mediaDevices.getUserMedia.bind(e.mediaDevices);if(e.mediaDevices.getUserMedia=function(o){return typeof o=="object"&&typeof o.audio=="object"&&(o=JSON.parse(JSON.stringify(o)),n(o.audio,"autoGainControl","mozAutoGainControl"),n(o.audio,"noiseSuppression","mozNoiseSuppression")),s(o)},i&&i.prototype.getSettings){const o=i.prototype.getSettings;i.prototype.getSettings=function(){const c=o.apply(this,arguments);return n(c,"mozAutoGainControl","autoGainControl"),n(c,"mozNoiseSuppression","noiseSuppression"),c}}if(i&&i.prototype.applyConstraints){const o=i.prototype.applyConstraints;i.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),n(c,"autoGainControl","mozAutoGainControl"),n(c,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[c])}}}}function ac(r,t){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return i.video===!0?i.video={mediaSource:t}:i.video.mediaSource=t,r.navigator.mediaDevices.getUserMedia(i)})}function Jo(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 On(r,t){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection))return;!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const s=r.RTCPeerConnection.prototype[n],o={[n](){return arguments[0]=new(n==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};r.RTCPeerConnection.prototype[n]=o[n]});const e={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[s,o,c]=arguments;return i.apply(this,[s||null]).then(a=>{if(t.version<53&&!o)try{a.forEach(l=>{l.type=e[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;a.forEach((u,h)=>{a.set(h,Object.assign({},u,{type:e[u.type]||u.type}))})}return a}).then(o,c)}}function Go(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const t=r.RTCPeerConnection.prototype.getSenders;t&&(r.RTCPeerConnection.prototype.getSenders=function(){const n=t.apply(this,[]);return n.forEach(s=>s._pc=this),n});const e=r.RTCPeerConnection.prototype.addTrack;e&&(r.RTCPeerConnection.prototype.addTrack=function(){const n=e.apply(this,arguments);return n._pc=this,n}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function jo(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i}),Qe(r,"track",e=>(e.receiver._pc=e.srcElement,e)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function $o(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){Kr("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&e.getTracks().includes(i.track)&&this.removeTrack(i)})})}function Ho(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function qo(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const t=r.RTCPeerConnection.prototype.addTransceiver;t&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const i=arguments[1],n=i&&"sendEncodings"in i;n&&i.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=t.apply(this,arguments);if(n){const{sender:o}=s,c=o.getParameters();(!("encodings"in c)||c.encodings.length===1&&Object.keys(c.encodings[0]).length===0)&&(c.encodings=i.sendEncodings,o.sendEncodings=i.sendEncodings,this.setParametersPromises.push(o.setParameters(c).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return s})}function Xo(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const t=r.RTCRtpSender.prototype.getParameters;t&&(r.RTCRtpSender.prototype.getParameters=function(){const i=t.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function Wo(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const t=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function Yo(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const t=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}const Cs=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:qo,shimCreateAnswer:Yo,shimCreateOffer:Wo,shimGetDisplayMedia:ac,shimGetParameters:Xo,shimGetUserMedia:Vo,shimOnTrack:Jo,shimPeerConnection:On,shimRTCDataChannel:Ho,shimReceiverGetStats:jo,shimRemoveStream:$o,shimSenderGetStats:Go},Symbol.toStringTag,{value:"Module"}));function Zo(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 t=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(n=>t.call(this,n,i)),i.getVideoTracks().forEach(n=>t.call(this,n,i))},r.RTCPeerConnection.prototype.addTrack=function(i,...n){return n&&n.forEach(s=>{this._localStreams?this._localStreams.includes(s)||this._localStreams.push(s):this._localStreams=[s]}),t.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(e);if(i===-1)return;this._localStreams.splice(i,1);const n=e.getTracks();this.getSenders().forEach(s=>{n.includes(s.track)&&this.removeTrack(s)})})}}function Qo(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(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(n=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(n))return;this._remoteStreams.push(n);const s=new Event("addstream");s.stream=n,this.dispatchEvent(s)})})}});const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(n){n.streams.forEach(s=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(s)>=0)return;i._remoteStreams.push(s);const o=new Event("addstream");o.stream=s,i.dispatchEvent(o)})}),t.apply(i,arguments)}}}function Ko(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const t=r.RTCPeerConnection.prototype,e=t.createOffer,i=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(l,u){const h=arguments.length>=2?arguments[2]:arguments[0],f=e.apply(this,[h]);return u?(f.then(l,u),Promise.resolve()):f},t.createAnswer=function(l,u){const h=arguments.length>=2?arguments[2]:arguments[0],f=i.apply(this,[h]);return u?(f.then(l,u),Promise.resolve()):f};let c=function(a,l,u){const h=n.apply(this,[a]);return u?(h.then(l,u),Promise.resolve()):h};t.setLocalDescription=c,c=function(a,l,u){const h=s.apply(this,[a]);return u?(h.then(l,u),Promise.resolve()):h},t.setRemoteDescription=c,c=function(a,l,u){const h=o.apply(this,[a]);return u?(h.then(l,u),Promise.resolve()):h},t.addIceCandidate=c}function ta(r){const t=r&&r.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=n=>i(ea(n))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(i,n,s){t.mediaDevices.getUserMedia(i).then(n,s)}.bind(t))}function ea(r){return r&&r.video!==void 0?Object.assign({},r,{video:wo(r.video)}):r}function ia(r){if(!r.RTCPeerConnection)return;const t=r.RTCPeerConnection;r.RTCPeerConnection=function(i,n){if(i&&i.iceServers){const s=[];for(let o=0;o<i.iceServers.length;o++){let c=i.iceServers[o];!c.hasOwnProperty("urls")&&c.hasOwnProperty("url")?(Kr("RTCIceServer.url","RTCIceServer.urls"),c=JSON.parse(JSON.stringify(c)),c.urls=c.url,delete c.url,s.push(c)):s.push(i.iceServers[o])}i.iceServers=s}return new t(i,n)},r.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return t.generateCertificate}})}function ra(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 na(r){const t=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const n=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&n?n.direction==="sendrecv"?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":n.direction==="recvonly"&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):i.offerToReceiveAudio===!0&&!n&&this.addTransceiver("audio"),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const s=this.getTransceivers().find(o=>o.receiver.track.kind==="video");i.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"):i.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video")}return t.apply(this,arguments)}}function sa(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}const ws=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:sa,shimCallbacksAPI:Ko,shimConstraints:ea,shimCreateOfferLegacy:na,shimGetUserMedia:ta,shimLocalStreamsAPI:Zo,shimRTCIceServerUrls:ia,shimRemoteStreamsAPI:Qo,shimTrackEventTransceiver:ra},Symbol.toStringTag,{value:"Module"}));function Ur(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const t=r.RTCIceCandidate;r.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substr(2)),i.candidate&&i.candidate.length){const n=new t(i),s=Nr.parseCandidate(i.candidate),o=Object.assign(n,s);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(i)},r.RTCIceCandidate.prototype=t.prototype,Qe(r,"icecandidate",e=>(e.candidate&&Object.defineProperty(e,"candidate",{value:new r.RTCIceCandidate(e.candidate),writable:"false"}),e))}function bi(r,t){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 e=function(c){if(!c||!c.sdp)return!1;const a=Nr.splitSections(c.sdp);return a.shift(),a.some(l=>{const u=Nr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},i=function(c){const a=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(a===null||a.length<2)return-1;const l=parseInt(a[1],10);return l!==l?-1:l},n=function(c){let a=65536;return t.browser==="firefox"&&(t.version<57?c===-1?a=16384:a=2147483637:t.version<60?a=t.version===57?65535:65536:a=2147483637),a},s=function(c,a){let l=65536;t.browser==="firefox"&&t.version===57&&(l=65535);const u=Nr.matchPrefix(c.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):t.browser==="firefox"&&a!==-1&&(l=2147483637),l},o=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){const{sdpSemantics:a}=this.getConfiguration();a==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(e(arguments[0])){const a=i(arguments[0]),l=n(a),u=s(arguments[0],a);let h;l===0&&u===0?h=Number.POSITIVE_INFINITY:l===0||u===0?h=Math.max(l,u):h=Math.min(l,u);const f={};Object.defineProperty(f,"maxMessageSize",{get(){return h}}),this._sctp=f}return o.apply(this,arguments)}}function Si(r){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype))return;function t(i,n){const s=i.send;i.send=function(){const c=arguments[0],a=c.length||c.size||c.byteLength;if(i.readyState==="open"&&n.sctp&&a>n.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+n.sctp.maxMessageSize+" bytes)");return s.apply(i,arguments)}}const e=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const n=e.apply(this,arguments);return t(n,this),n},Qe(r,"datachannel",i=>(t(i.channel,i.target),i))}function In(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const t=r.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=n=>{const s=n.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const o=new Event("connectionstatechange",n);s.dispatchEvent(o)}return n},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function Nn(r,t){if(!r.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(n){if(n&&n.sdp&&n.sdp.indexOf(`
|
|
70
|
+
a=extmap-allow-mixed`)!==-1){const s=n.sdp.split(`
|
|
71
|
+
`).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
|
|
72
|
+
`);r.RTCSessionDescription&&n instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:n.type,sdp:s}):n.sdp=s}return e.apply(this,arguments)}}function Dr(r,t){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const e=r.RTCPeerConnection.prototype.addIceCandidate;!e||e.length===0||(r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const cc=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:Nn,shimAddIceCandidateNullOrEmpty:Dr,shimConnectionState:In,shimMaxMessageSize:bi,shimRTCIceCandidate:Ur,shimSendThrowTypeError:Si},Symbol.toStringTag,{value:"Module"}));function lc({window:r}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const e=es,i=tc(r),n={browserDetails:i,commonShim:cc,extractVersion:_i,disableLog:Qa,disableWarnings:Ka};switch(i.browser){case"chrome":if(!bs||!Bn||!t.shimChrome)return e("Chrome shim is not included in this adapter release."),n;if(i.version===null)return e("Chrome shim can not determine version, not shimming."),n;e("adapter.js shimming chrome."),n.browserShim=bs,Dr(r,i),Po(r,i),Eo(r),Bn(r,i),Ao(r),Oo(r,i),Ro(r),ko(r),Bo(r),Io(r,i),Ur(r),In(r),bi(r,i),Si(r),Nn(r,i);break;case"firefox":if(!Cs||!On||!t.shimFirefox)return e("Firefox shim is not included in this adapter release."),n;e("adapter.js shimming firefox."),n.browserShim=Cs,Dr(r,i),Vo(r,i),On(r,i),Jo(r),$o(r),Go(r),jo(r),Ho(r),qo(r),Xo(r),Wo(r),Yo(r),Ur(r),In(r),bi(r,i),Si(r);break;case"edge":if(!Ms||!zn||!t.shimEdge)return e("MS edge shim is not included in this adapter release."),n;e("adapter.js shimming edge."),n.browserShim=Ms,Do(r),Fo(r),zn(r,i),Lo(r),bi(r,i),Si(r);break;case"safari":if(!ws||!t.shimSafari)return e("Safari shim is not included in this adapter release."),n;e("adapter.js shimming safari."),n.browserShim=ws,Dr(r,i),ia(r),na(r),Ko(r),Zo(r),Qo(r),ra(r),ta(r),sa(r),Ur(r),bi(r,i),Si(r),Nn(r,i);break;default:e("Unsupported browser!");break}return n}const Ps=lc({window:typeof window>"u"?void 0:window});function Ht(r,t,e,i){Object.defineProperty(r,t,{get:e,set:i,enumerable:!0,configurable:!0})}var cn=Ps.default||Ps,si=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 t=this.getBrowser(),e=this.getVersion(),i=this.supportedBrowsers.includes(t);return i?t==="chrome"?e>=this.minChromeVersion:t==="firefox"?e>=this.minFirefoxVersion:t==="safari"?!this.isIOS&&e>=this.minSafariVersion:!1:!1},r.prototype.getBrowser=function(){return cn.browserDetails.browser},r.prototype.getVersion=function(){return cn.browserDetails.version||0},r.prototype.isUnifiedPlanSupported=function(){var t=this.getBrowser(),e=cn.browserDetails.version||0;if(t==="chrome"&&e<this.minChromeVersion)return!1;if(t==="firefox"&&e>=this.minFirefoxVersion)return!0;if(!window.RTCRtpTransceiver||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var i,n=!1;try{i=new RTCPeerConnection,i.addTransceiver("audio"),n=!0}catch{}finally{i&&i.close()}return n},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())},s}()),zo={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"},ul=function(){function s(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=zo,this.browser=oi.getBrowser(),this.browserVersion=oi.getVersion(),this.supports=function(){var t={browser:oi.isBrowserSupported(),webRTC:oi.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!t.webRTC)return t;var e;try{e=new RTCPeerConnection(zo),t.audioVideo=!0;var i=void 0;try{i=e.createDataChannel("_PEERJSTEST",{ordered:!0}),t.data=!0,t.reliable=!!i.ordered;try{i.binaryType="blob",t.binaryBlob=!oi.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{e&&e.close()}return t}(),this.pack=Zo.pack,this.unpack=Zo.unpack,this._dataCount=1}return s.prototype.noop=function(){},s.prototype.validateId=function(t){return!t||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(t)},s.prototype.chunk=function(t){for(var e=[],i=t.size,n=Math.ceil(i/U.chunkedMTU),o=0,r=0;r<i;){var l=Math.min(i,r+U.chunkedMTU),c=t.slice(r,l),a={__peerData:this._dataCount,n:o,data:c,total:n};e.push(a),r=l,o++}return this._dataCount++,e},s.prototype.blobToArrayBuffer=function(t,e){var i=new FileReader;return i.onload=function(n){n.target&&e(n.target.result)},i.readAsArrayBuffer(t),i},s.prototype.binaryStringToArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;i++)e[i]=t.charCodeAt(i)&255;return e.buffer},s.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},s.prototype.isSecure=function(){return location.protocol==="https:"},s}(),U=new ul,cc={};Et(cc,"Peer",()=>Jn,s=>Jn=s);var cs={},pl=Object.prototype.hasOwnProperty,ft="~";function Ci(){}Object.create&&(Ci.prototype=Object.create(null),new Ci().__proto__||(ft=!1));function ml(s,t,e){this.fn=s,this.context=t,this.once=e||!1}function lc(s,t,e,i,n){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new ml(e,i||s,n),r=ft?ft+t:t;return s._events[r]?s._events[r].fn?s._events[r]=[s._events[r],o]:s._events[r].push(o):(s._events[r]=o,s._eventsCount++),s}function Js(s,t){--s._eventsCount===0?s._events=new Ci:delete s._events[t]}function yt(){this._events=new Ci,this._eventsCount=0}yt.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)pl.call(e,i)&&t.push(ft?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};yt.prototype.listeners=function(t){var e=ft?ft+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,o=i.length,r=new Array(o);n<o;n++)r[n]=i[n].fn;return r};yt.prototype.listenerCount=function(t){var e=ft?ft+t:t,i=this._events[e];return i?i.fn?1:i.length:0};yt.prototype.emit=function(t,e,i,n,o,r){var l=ft?ft+t:t;if(!this._events[l])return!1;var c=this._events[l],a=arguments.length,d,h;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),a){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,n),!0;case 5:return c.fn.call(c.context,e,i,n,o),!0;case 6:return c.fn.call(c.context,e,i,n,o,r),!0}for(h=1,d=new Array(a-1);h<a;h++)d[h-1]=arguments[h];c.fn.apply(c.context,d)}else{var u=c.length,p;for(h=0;h<u;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),a){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,i);break;case 4:c[h].fn.call(c[h].context,e,i,n);break;default:if(!d)for(p=1,d=new Array(a-1);p<a;p++)d[p-1]=arguments[p];c[h].fn.apply(c[h].context,d)}}return!0};yt.prototype.on=function(t,e,i){return lc(this,t,e,i,!1)};yt.prototype.once=function(t,e,i){return lc(this,t,e,i,!0)};yt.prototype.removeListener=function(t,e,i,n){var o=ft?ft+t:t;if(!this._events[o])return this;if(!e)return Js(this,o),this;var r=this._events[o];if(r.fn)r.fn===e&&(!n||r.once)&&(!i||r.context===i)&&Js(this,o);else{for(var l=0,c=[],a=r.length;l<a;l++)(r[l].fn!==e||n&&!r[l].once||i&&r[l].context!==i)&&c.push(r[l]);c.length?this._events[o]=c.length===1?c[0]:c:Js(this,o)}return this};yt.prototype.removeAllListeners=function(t){var e;return t?(e=ft?ft+t:t,this._events[e]&&Js(this,e)):(this._events=new Ci,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=ft;yt.EventEmitter=yt;cs=yt;var T={};Et(T,"LogLevel",()=>Rt,s=>Rt=s);Et(T,"default",()=>vo,s=>vo=s);var Se=function(s,t){var e=typeof Symbol=="function"&&s[Symbol.iterator];if(!e)return s;var i=e.call(s),n,o=[],r;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(l){r={error:l}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return o},We=function(s,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,o;i<n;i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return s.concat(o||Array.prototype.slice.call(t))},bl="PeerJS: ",Rt;(function(s){s[s.Disabled=0]="Disabled",s[s.Errors=1]="Errors",s[s.Warnings=2]="Warnings",s[s.All=3]="All"})(Rt||(Rt={}));var yl=function(){function s(){this._logLevel=Rt.Disabled}return Object.defineProperty(s.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){this._logLevel=t},enumerable:!1,configurable:!0}),s.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=Rt.All&&this._print.apply(this,We([Rt.All],Se(t),!1))},s.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=Rt.Warnings&&this._print.apply(this,We([Rt.Warnings],Se(t),!1))},s.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=Rt.Errors&&this._print.apply(this,We([Rt.Errors],Se(t),!1))},s.prototype.setLogFunction=function(t){this._print=t},s.prototype._print=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=We([bl],Se(e),!1);for(var o in n)n[o]instanceof Error&&(n[o]="("+n[o].name+") "+n[o].message);t>=Rt.All?console.log.apply(console,We([],Se(n),!1)):t>=Rt.Warnings?console.warn.apply(console,We(["WARNING"],Se(n),!1)):t>=Rt.Errors&&console.error.apply(console,We(["ERROR"],Se(n),!1))},s}(),vo=new yl,ac={};Et(ac,"Socket",()=>Ko,s=>Ko=s);var It;(function(s){s.Data="data",s.Media="media"})(It||(It={}));var A;(function(s){s.BrowserIncompatible="browser-incompatible",s.Disconnected="disconnected",s.InvalidID="invalid-id",s.InvalidKey="invalid-key",s.Network="network",s.PeerUnavailable="peer-unavailable",s.SslUnavailable="ssl-unavailable",s.ServerError="server-error",s.SocketError="socket-error",s.SocketClosed="socket-closed",s.UnavailableID="unavailable-id",s.WebRTC="webrtc"})(A||(A={}));var te;(function(s){s.Binary="binary",s.BinaryUTF8="binary-utf8",s.JSON="json"})(te||(te={}));var ie;(function(s){s.Message="message",s.Disconnected="disconnected",s.Error="error",s.Close="close"})(ie||(ie={}));var dt;(function(s){s.Heartbeat="HEARTBEAT",s.Candidate="CANDIDATE",s.Offer="OFFER",s.Answer="ANSWER",s.Open="OPEN",s.Error="ERROR",s.IdTaken="ID-TAKEN",s.InvalidKey="INVALID-KEY",s.Leave="LEAVE",s.Expire="EXPIRE"})(dt||(dt={}));var io={};io=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 Gl=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Zl=function(s,t){var e=typeof Symbol=="function"&&s[Symbol.iterator];if(!e)return s;var i=e.call(s),n,o=[],r;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(l){r={error:l}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return o},Xl=function(s,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,o;i<n;i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return s.concat(o||Array.prototype.slice.call(t))},fl=function(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],i=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ko=function(s){Gl(t,s);function t(e,i,n,o,r,l){l===void 0&&(l=5e3);var c=s.call(this)||this;c.pingInterval=l,c._disconnected=!0,c._messagesQueue=[];var a=e?"wss://":"ws://";return c._baseUrl=a+i+":"+n+o+"peerjs?key="+r,c}return t.prototype.start=function(e,i){var n=this;this._id=e;var o="".concat(this._baseUrl,"&id=").concat(e,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(o+"&version="+io.version),this._disconnected=!1,this._socket.onmessage=function(r){var l;try{l=JSON.parse(r.data),T.default.log("Server message received:",l)}catch{T.default.log("Invalid server message",r.data);return}n.emit(ie.Message,l)},this._socket.onclose=function(r){n._disconnected||(T.default.log("Socket closed.",r),n._cleanup(),n._disconnected=!0,n.emit(ie.Disconnected))},this._socket.onopen=function(){n._disconnected||(n._sendQueuedMessages(),T.default.log("Socket open"),n._scheduleHeartbeat())})},t.prototype._scheduleHeartbeat=function(){var e=this;this._wsPingTimer=setTimeout(function(){e._sendHeartbeat()},this.pingInterval)},t.prototype._sendHeartbeat=function(){if(!this._wsOpen()){T.default.log("Cannot send heartbeat, because socket closed");return}var e=JSON.stringify({type:dt.Heartbeat});this._socket.send(e),this._scheduleHeartbeat()},t.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},t.prototype._sendQueuedMessages=function(){var e,i,n=Xl([],Zl(this._messagesQueue),!1);this._messagesQueue=[];try{for(var o=fl(n),r=o.next();!r.done;r=o.next()){var l=r.value;this.send(l)}}catch(c){e={error:c}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},t.prototype.send=function(e){if(!this._disconnected){if(!this._id){this._messagesQueue.push(e);return}if(!e.type){this.emit(ie.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(e);this._socket.send(i)}}},t.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},t.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)},t}(cs.EventEmitter),Nn={};Et(Nn,"MediaConnection",()=>Yo,s=>Yo=s);var so={};Et(so,"Negotiator",()=>To,s=>To=s);var Fs=function(){return Fs=Object.assign||function(s){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Fs.apply(this,arguments)},hs=function(s,t,e,i){function n(o){return o instanceof e?o:new e(function(r){r(o)})}return new(e||(e=Promise))(function(o,r){function l(d){try{a(i.next(d))}catch(h){r(h)}}function c(d){try{a(i.throw(d))}catch(h){r(h)}}function a(d){d.done?o(d.value):n(d.value).then(l,c)}a((i=i.apply(s,t||[])).next())})},us=function(s,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,r;return r={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function l(a){return function(d){return c([a,d])}}function c(a){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(o=a[0]&2?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,n=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){e.label=a[1];break}if(a[0]===6&&e.label<o[1]){e.label=o[1],o=a;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(a);break}o[2]&&e.ops.pop(),e.trys.pop();continue}a=t.call(s,e)}catch(d){a=[6,d],n=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},To=function(){function s(t){this.connection=t}return s.prototype.startConnection=function(t){var e=this._startPeerConnection();if(this.connection.peerConnection=e,this.connection.type===It.Media&&t._stream&&this._addTracksToConnection(t._stream,e),t.originator){if(this.connection.type===It.Data){var i=this.connection,n={ordered:!!t.reliable},o=e.createDataChannel(i.label,n);i.initialize(o)}this._makeOffer()}else this.handleSDP("OFFER",t.sdp)},s.prototype._startPeerConnection=function(){T.default.log("Creating RTCPeerConnection.");var t=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(t),t},s.prototype._setupListeners=function(t){var e=this,i=this.connection.peer,n=this.connection.connectionId,o=this.connection.type,r=this.connection.provider;T.default.log("Listening for ICE candidates."),t.onicecandidate=function(l){!l.candidate||!l.candidate.candidate||(T.default.log("Received ICE candidates for ".concat(i,":"),l.candidate),r.socket.send({type:dt.Candidate,payload:{candidate:l.candidate,type:o,connectionId:n},dst:i}))},t.oniceconnectionstatechange=function(){switch(t.iceConnectionState){case"failed":T.default.log("iceConnectionState is failed, closing connections to "+i),e.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),e.connection.close();break;case"closed":T.default.log("iceConnectionState is closed, closing connections to "+i),e.connection.emit("error",new Error("Connection to "+i+" closed.")),e.connection.close();break;case"disconnected":T.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":t.onicecandidate=U.noop;break}e.connection.emit("iceStateChanged",t.iceConnectionState)},T.default.log("Listening for data channel"),t.ondatachannel=function(l){T.default.log("Received data channel");var c=l.channel,a=r.getConnection(i,n);a.initialize(c)},T.default.log("Listening for remote stream"),t.ontrack=function(l){T.default.log("Received remote stream");var c=l.streams[0],a=r.getConnection(i,n);if(a.type===It.Media){var d=a;e._addStreamToMediaConnection(c,d)}}},s.prototype.cleanup=function(){T.default.log("Cleaning up PeerConnection to "+this.connection.peer);var t=this.connection.peerConnection;if(t){this.connection.peerConnection=null,t.onicecandidate=t.oniceconnectionstatechange=t.ondatachannel=t.ontrack=function(){};var e=t.signalingState!=="closed",i=!1;if(this.connection.type===It.Data){var n=this.connection,o=n.dataChannel;o&&(i=!!o.readyState&&o.readyState!=="closed")}(e||i)&&t.close()}},s.prototype._makeOffer=function(){return hs(this,void 0,Promise,function(){var t,e,i,n,o,r,l;return us(this,function(c){switch(c.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,t.createOffer(this.connection.options.constraints)];case 2:i=c.sent(),T.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return c.sent(),T.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),n={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:U.browser},this.connection.type===It.Data&&(o=this.connection,n=Fs(Fs({},n),{label:o.label,reliable:o.reliable,serialization:o.serialization})),e.socket.send({type:dt.Offer,payload:n,dst:this.connection.peer}),[3,6];case 5:return r=c.sent(),r!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(e.emitError(A.WebRTC,r),T.default.log("Failed to setLocalDescription, ",r)),[3,6];case 6:return[3,8];case 7:return l=c.sent(),e.emitError(A.WebRTC,l),T.default.log("Failed to createOffer, ",l),[3,8];case 8:return[2]}})})},s.prototype._makeAnswer=function(){return hs(this,void 0,Promise,function(){var t,e,i,n,o;return us(this,function(r){switch(r.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,r.label=1;case 1:return r.trys.push([1,7,,8]),[4,t.createAnswer()];case 2:i=r.sent(),T.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),r.label=3;case 3:return r.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return r.sent(),T.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),e.socket.send({type:dt.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:U.browser},dst:this.connection.peer}),[3,6];case 5:return n=r.sent(),e.emitError(A.WebRTC,n),T.default.log("Failed to setLocalDescription, ",n),[3,6];case 6:return[3,8];case 7:return o=r.sent(),e.emitError(A.WebRTC,o),T.default.log("Failed to create answer, ",o),[3,8];case 8:return[2]}})})},s.prototype.handleSDP=function(t,e){return hs(this,void 0,Promise,function(){var i,n,o,r;return us(this,function(l){switch(l.label){case 0:e=new RTCSessionDescription(e),i=this.connection.peerConnection,n=this.connection.provider,T.default.log("Setting remote description",e),o=this,l.label=1;case 1:return l.trys.push([1,5,,6]),[4,i.setRemoteDescription(e)];case 2:return l.sent(),T.default.log("Set remoteDescription:".concat(t," for:").concat(this.connection.peer)),t!=="OFFER"?[3,4]:[4,o._makeAnswer()];case 3:l.sent(),l.label=4;case 4:return[3,6];case 5:return r=l.sent(),n.emitError(A.WebRTC,r),T.default.log("Failed to setRemoteDescription, ",r),[3,6];case 6:return[2]}})})},s.prototype.handleCandidate=function(t){return hs(this,void 0,Promise,function(){var e,i,n,o,r,l;return us(this,function(c){switch(c.label){case 0:T.default.log("handleCandidate:",t),e=t.candidate,i=t.sdpMLineIndex,n=t.sdpMid,o=this.connection.peerConnection,r=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.addIceCandidate(new RTCIceCandidate({sdpMid:n,sdpMLineIndex:i,candidate:e}))];case 2:return c.sent(),T.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return l=c.sent(),r.emitError(A.WebRTC,l),T.default.log("Failed to handleCandidate, ",l),[3,4];case 4:return[2]}})})},s.prototype._addTracksToConnection=function(t,e){if(T.default.log("add tracks from stream ".concat(t.id," to peer connection")),!e.addTrack)return T.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");t.getTracks().forEach(function(i){e.addTrack(i,t)})},s.prototype._addStreamToMediaConnection=function(t,e){T.default.log("add stream ".concat(t.id," to media connection ").concat(e.connectionId)),e.addStream(t)},s}(),no={};Et(no,"BaseConnection",()=>Mo,s=>Mo=s);var Vl=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Mo=function(s){Vl(t,s);function t(e,i,n){var o=s.call(this)||this;return o.peer=e,o.provider=i,o.options=n,o._open=!1,o.metadata=n.metadata,o}return Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),t}(cs.EventEmitter),Rl=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Qs=function(){return Qs=Object.assign||function(s){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Qs.apply(this,arguments)},xl=function(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],i=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Yo=function(s){Rl(t,s);function t(e,i,n){var o=s.call(this,e,i,n)||this;return o._localStream=o.options._stream,o.connectionId=o.options.connectionId||t.ID_PREFIX+U.randomToken(),o._negotiator=new so.Negotiator(o),o._localStream&&o._negotiator.startConnection({_stream:o._localStream,originator:!0}),o}return Object.defineProperty(t.prototype,"type",{get:function(){return It.Media},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),t.prototype.addStream=function(e){T.default.log("Receiving stream",e),this._remoteStream=e,s.prototype.emit.call(this,"stream",e)},t.prototype.handleMessage=function(e){var i=e.type,n=e.payload;switch(e.type){case dt.Answer:this._negotiator.handleSDP(i,n.sdp),this._open=!0;break;case dt.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:T.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},t.prototype.answer=function(e,i){var n,o;if(i===void 0&&(i={}),this._localStream){T.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=e,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(Qs(Qs({},this.options._payload),{_stream:e}));var r=this.provider._getMessages(this.connectionId);try{for(var l=xl(r),c=l.next();!c.done;c=l.next()){var a=c.value;this.handleMessage(a)}}catch(d){n={error:d}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}this._open=!0},t.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,s.prototype.emit.call(this,"close"))},t.ID_PREFIX="mc_",t}(no.BaseConnection),In={};Et(In,"DataConnection",()=>Ho,s=>Ho=s);var dc={};Et(dc,"EncodingQueue",()=>ko,s=>ko=s);var Ll=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),ko=function(s){Ll(t,s);function t(){var e=s.call(this)||this;return e.fileReader=new FileReader,e._queue=[],e._processing=!1,e.fileReader.onload=function(i){e._processing=!1,i.target&&e.emit("done",i.target.result),e.doNextTask()},e.fileReader.onerror=function(i){T.default.error("EncodingQueue error:",i),e._processing=!1,e.destroy(),e.emit("error",i)},e}return Object.defineProperty(t.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),t.prototype.enque=function(e){this.queue.push(e),!this.processing&&this.doNextTask()},t.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},t.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},t}(cs.EventEmitter),Sl=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Wl=function(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],i=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ho=function(s){Sl(t,s);function t(e,i,n){var o=s.call(this,e,i,n)||this;return o.stringify=JSON.stringify,o.parse=JSON.parse,o._buffer=[],o._bufferSize=0,o._buffering=!1,o._chunkedData={},o._encodingQueue=new dc.EncodingQueue,o.connectionId=o.options.connectionId||t.ID_PREFIX+U.randomToken(),o.label=o.options.label||o.connectionId,o.serialization=o.options.serialization||te.Binary,o.reliable=!!o.options.reliable,o._encodingQueue.on("done",function(r){o._bufferedSend(r)}),o._encodingQueue.on("error",function(){T.default.error("DC#".concat(o.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),o.close()}),o._negotiator=new so.Negotiator(o),o._negotiator.startConnection(o.options._payload||{originator:!0}),o}return Object.defineProperty(t.prototype,"type",{get:function(){return It.Data},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._dc=e,this._configureDataChannel()},t.prototype._configureDataChannel=function(){var e=this;(!U.supports.binaryBlob||U.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){T.default.log("DC#".concat(e.connectionId," dc connection success")),e._open=!0,e.emit("open")},this.dataChannel.onmessage=function(i){T.default.log("DC#".concat(e.connectionId," dc onmessage:"),i.data),e._handleDataMessage(i)},this.dataChannel.onclose=function(){T.default.log("DC#".concat(e.connectionId," dc closed for:"),e.peer),e.close()}},t.prototype._handleDataMessage=function(e){var i=this,n=e.data,o=n.constructor,r=this.serialization===te.Binary||this.serialization===te.BinaryUTF8,l=n;if(r){if(o===Blob){U.blobToArrayBuffer(n,function(a){var d=U.unpack(a);i.emit("data",d)});return}else if(o===ArrayBuffer)l=U.unpack(n);else if(o===String){var c=U.binaryStringToArrayBuffer(n);l=U.unpack(c)}}else this.serialization===te.JSON&&(l=this.parse(n));if(l.__peerData){this._handleChunk(l);return}s.prototype.emit.call(this,"data",l)},t.prototype._handleChunk=function(e){var i=e.__peerData,n=this._chunkedData[i]||{data:[],count:0,total:e.total};if(n.data[e.n]=e.data,n.count++,this._chunkedData[i]=n,n.total===n.count){delete this._chunkedData[i];var o=new Blob(n.data);this._handleDataMessage({data:o})}},t.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,s.prototype.emit.call(this,"close"))},t.prototype.send=function(e,i){if(!this.open){s.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===te.JSON)this._bufferedSend(this.stringify(e));else if(this.serialization===te.Binary||this.serialization===te.BinaryUTF8){var n=U.pack(e);if(!i&&n.size>U.chunkedMTU){this._sendChunks(n);return}U.supports.binaryBlob?this._bufferedSend(n):this._encodingQueue.enque(n)}else this._bufferedSend(e)},t.prototype._bufferedSend=function(e){(this._buffering||!this._trySend(e))&&(this._buffer.push(e),this._bufferSize=this._buffer.length)},t.prototype._trySend=function(e){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>t.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(e)}catch(n){return T.default.error("DC#:".concat(this.connectionId," Error when sending:"),n),this._buffering=!0,this.close(),!1}return!0},t.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var e=this._buffer[0];this._trySend(e)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},t.prototype._sendChunks=function(e){var i,n,o=U.chunk(e);T.default.log("DC#".concat(this.connectionId," Try to send ").concat(o.length," chunks..."));try{for(var r=Wl(o),l=r.next();!l.done;l=r.next()){var c=l.value;this.send(c,!0)}}catch(a){i={error:a}}finally{try{l&&!l.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}},t.prototype.handleMessage=function(e){var i=e.payload;switch(e.type){case dt.Answer:this._negotiator.handleSDP(e.type,i.sdp);break;case dt.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:T.default.warn("Unrecognized message type:",e.type,"from peer:",this.peer);break}},t.ID_PREFIX="dc_",t.MAX_BUFFERED_AMOUNT=8388608,t}(no.BaseConnection),hc={};Et(hc,"API",()=>Jo,s=>Jo=s);var No=function(s,t,e,i){function n(o){return o instanceof e?o:new e(function(r){r(o)})}return new(e||(e=Promise))(function(o,r){function l(d){try{a(i.next(d))}catch(h){r(h)}}function c(d){try{a(i.throw(d))}catch(h){r(h)}}function a(d){d.done?o(d.value):n(d.value).then(l,c)}a((i=i.apply(s,t||[])).next())})},Io=function(s,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,r;return r={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function l(a){return function(d){return c([a,d])}}function c(a){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(o=a[0]&2?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,n=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){e.label=a[1];break}if(a[0]===6&&e.label<o[1]){e.label=o[1],o=a;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(a);break}o[2]&&e.ops.pop(),e.trys.pop();continue}a=t.call(s,e)}catch(d){a=[6,d],n=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Jo=function(){function s(t){this._options=t}return s.prototype._buildRequest=function(t){var e=this._options.secure?"https":"http",i=this._options,n=i.host,o=i.port,r=i.path,l=i.key,c=new URL("".concat(e,"://").concat(n,":").concat(o).concat(r).concat(l,"/").concat(t));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",io.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},s.prototype.retrieveId=function(){return No(this,void 0,Promise,function(){var t,e,i;return Io(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(t=n.sent(),t.status!==200)throw new Error("Error. Status:".concat(t.status));return[2,t.text()];case 2:throw e=n.sent(),T.default.error("Error retrieving ID",e),i="",this._options.path==="/"&&this._options.host!==U.CLOUD_HOST&&(i=" 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."+i);case 3:return[2]}})})},s.prototype.listAllPeers=function(){return No(this,void 0,Promise,function(){var t,e,i;return Io(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(t=n.sent(),t.status!==200)throw t.status===401?(e="",this._options.host===U.CLOUD_HOST?e="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":e="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. "+e)):new Error("Error. Status:".concat(t.status));return[2,t.json()];case 2:throw i=n.sent(),T.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},s}(),gl=function(){var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},s(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");s(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Si=function(){return Si=Object.assign||function(s){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Si.apply(this,arguments)},ri=function(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],i=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Cl=function(s,t){var e=typeof Symbol=="function"&&s[Symbol.iterator];if(!e)return s;var i=e.call(s),n,o=[],r;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(l){r={error:l}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}return o},Jn=function(s){gl(t,s);function t(e,i){var n=s.call(this)||this;n._id=null,n._lastServerId=null,n._destroyed=!1,n._disconnected=!1,n._open=!1,n._connections=new Map,n._lostMessages=new Map;var o;return e&&e.constructor==Object?i=e:e&&(o=e.toString()),i=Si({debug:0,host:U.CLOUD_HOST,port:U.CLOUD_PORT,path:"/",key:t.DEFAULT_KEY,token:U.randomToken(),config:U.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),n._options=i,n._options.host==="/"&&(n._options.host=window.location.hostname),n._options.path&&(n._options.path[0]!=="/"&&(n._options.path="/"+n._options.path),n._options.path[n._options.path.length-1]!=="/"&&(n._options.path+="/")),n._options.secure===void 0&&n._options.host!==U.CLOUD_HOST?n._options.secure=U.isSecure():n._options.host==U.CLOUD_HOST&&(n._options.secure=!0),n._options.logFunction&&T.default.setLogFunction(n._options.logFunction),T.default.logLevel=n._options.debug||0,n._api=new hc.API(i),n._socket=n._createServerConnection(),!U.supports.audioVideo&&!U.supports.data?(n._delayedAbort(A.BrowserIncompatible,"The current browser does not support WebRTC"),n):o&&!U.validateId(o)?(n._delayedAbort(A.InvalidID,'ID "'.concat(o,'" is invalid')),n):(o?n._initialize(o):n._api.retrieveId().then(function(r){return n._initialize(r)}).catch(function(r){return n._abort(A.ServerError,r)}),n)}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connections",{get:function(){var e,i,n=Object.create(null);try{for(var o=ri(this._connections),r=o.next();!r.done;r=o.next()){var l=Cl(r.value,2),c=l[0],a=l[1];n[c]=a}}catch(d){e={error:d}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),t.prototype._createServerConnection=function(){var e=this,i=new ac.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(ie.Message,function(n){e._handleMessage(n)}),i.on(ie.Error,function(n){e._abort(A.SocketError,n)}),i.on(ie.Disconnected,function(){e.disconnected||(e.emitError(A.Network,"Lost connection to server."),e.disconnect())}),i.on(ie.Close,function(){e.disconnected||e._abort(A.SocketClosed,"Underlying socket is already closed.")}),i},t.prototype._initialize=function(e){this._id=e,this.socket.start(e,this._options.token)},t.prototype._handleMessage=function(e){var i,n,o=e.type,r=e.payload,l=e.src;switch(o){case dt.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case dt.Error:this._abort(A.ServerError,r.msg);break;case dt.IdTaken:this._abort(A.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case dt.InvalidKey:this._abort(A.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case dt.Leave:T.default.log("Received leave message from ".concat(l)),this._cleanupPeer(l),this._connections.delete(l);break;case dt.Expire:this.emitError(A.PeerUnavailable,"Could not connect to peer ".concat(l));break;case dt.Offer:var m=r.connectionId,b=this.getConnection(l,m);if(b&&(b.close(),T.default.warn("Offer received for existing Connection ID:".concat(m))),r.type===It.Media){var c=new Nn.MediaConnection(l,this,{connectionId:m,_payload:r,metadata:r.metadata});b=c,this._addConnection(l,b),this.emit("call",c)}else if(r.type===It.Data){var a=new In.DataConnection(l,this,{connectionId:m,_payload:r,metadata:r.metadata,label:r.label,serialization:r.serialization,reliable:r.reliable});b=a,this._addConnection(l,b),this.emit("connection",a)}else{T.default.warn("Received malformed connection type:".concat(r.type));return}var d=this._getMessages(m);try{for(var h=ri(d),u=h.next();!u.done;u=h.next()){var p=u.value;b.handleMessage(p)}}catch(G){i={error:G}}finally{try{u&&!u.done&&(n=h.return)&&n.call(h)}finally{if(i)throw i.error}}break;default:if(!r){T.default.warn("You received a malformed message from ".concat(l," of type ").concat(o));return}var m=r.connectionId,b=this.getConnection(l,m);b&&b.peerConnection?b.handleMessage(e):m?this._storeMessage(m,e):T.default.warn("You received an unrecognized message:",e);break}},t.prototype._storeMessage=function(e,i){this._lostMessages.has(e)||this._lostMessages.set(e,[]),this._lostMessages.get(e).push(i)},t.prototype._getMessages=function(e){var i=this._lostMessages.get(e);return i?(this._lostMessages.delete(e),i):[]},t.prototype.connect=function(e,i){if(i===void 0&&(i={}),this.disconnected){T.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(A.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var n=new In.DataConnection(e,this,i);return this._addConnection(e,n),n},t.prototype.call=function(e,i,n){if(n===void 0&&(n={}),this.disconnected){T.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(A.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){T.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var o=new Nn.MediaConnection(e,this,Si(Si({},n),{_stream:i}));return this._addConnection(e,o),o},t.prototype._addConnection=function(e,i){T.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(e)),this._connections.has(e)||this._connections.set(e,[]),this._connections.get(e).push(i)},t.prototype._removeConnection=function(e){var i=this._connections.get(e.peer);if(i){var n=i.indexOf(e);n!==-1&&i.splice(n,1)}this._lostMessages.delete(e.connectionId)},t.prototype.getConnection=function(e,i){var n,o,r=this._connections.get(e);if(!r)return null;try{for(var l=ri(r),c=l.next();!c.done;c=l.next()){var a=c.value;if(a.connectionId===i)return a}}catch(d){n={error:d}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}return null},t.prototype._delayedAbort=function(e,i){var n=this;setTimeout(function(){n._abort(e,i)},0)},t.prototype._abort=function(e,i){T.default.error("Aborting!"),this.emitError(e,i),this._lastServerId?this.disconnect():this.destroy()},t.prototype.emitError=function(e,i){T.default.error("Error:",i);var n;typeof i=="string"?n=new Error(i):n=i,n.type=e,this.emit("error",n)},t.prototype.destroy=function(){this.destroyed||(T.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},t.prototype._cleanup=function(){var e,i;try{for(var n=ri(this._connections.keys()),o=n.next();!o.done;o=n.next()){var r=o.value;this._cleanupPeer(r),this._connections.delete(r)}}catch(l){e={error:l}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(e)throw e.error}}this.socket.removeAllListeners()},t.prototype._cleanupPeer=function(e){var i,n,o=this._connections.get(e);if(o)try{for(var r=ri(o),l=r.next();!l.done;l=r.next()){var c=l.value;c.close()}}catch(a){i={error:a}}finally{try{l&&!l.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}},t.prototype.disconnect=function(){if(!this.disconnected){var e=this.id;T.default.log("Disconnect peer with ID:".concat(e)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=e,this._id=null,this.emit("disconnected",e)}},t.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)T.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)T.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!"))}},t.prototype.listAllPeers=function(e){var i=this;e===void 0&&(e=function(n){}),this._api.listAllPeers().then(function(n){return e(n)}).catch(function(n){return i._abort(A.ServerError,n)})},t.DEFAULT_KEY="peerjs",t}(cs.EventEmitter),uc=cc.Peer;const zl=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Jn},default:uc,util:U},Symbol.toStringTag,{value:"Module"})),vl=/^(?:[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 Kl(s){return typeof s=="string"&&vl.test(s)}const at=[];for(let s=0;s<256;++s)at.push((s+256).toString(16).slice(1));function Tl(s,t=0){return at[s[t+0]]+at[s[t+1]]+at[s[t+2]]+at[s[t+3]]+"-"+at[s[t+4]]+at[s[t+5]]+"-"+at[s[t+6]]+at[s[t+7]]+"-"+at[s[t+8]]+at[s[t+9]]+"-"+at[s[t+10]]+at[s[t+11]]+at[s[t+12]]+at[s[t+13]]+at[s[t+14]]+at[s[t+15]]}function Ml(s){if(!Kl(s))throw TypeError("Invalid UUID");let t;const e=new Uint8Array(16);return e[0]=(t=parseInt(s.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(s.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(s.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(s.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(s.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function Yl(s){s=unescape(encodeURIComponent(s));const t=[];for(let e=0;e<s.length;++e)t.push(s.charCodeAt(e));return t}const kl="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Hl="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Nl(s,t,e){function i(n,o,r,l){var c;if(typeof n=="string"&&(n=Yl(n)),typeof o=="string"&&(o=Ml(o)),((c=o)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let a=new Uint8Array(16+n.length);if(a.set(o),a.set(n,o.length),a=e(a),a[6]=a[6]&15|t,a[8]=a[8]&63|128,r){l=l||0;for(let d=0;d<16;++d)r[l+d]=a[d];return r}return Tl(a)}try{i.name=s}catch{}return i.DNS=kl,i.URL=Hl,i}function Il(s,t,e,i){switch(s){case 0:return t&e^~t&i;case 1:return t^e^i;case 2:return t&e^t&i^e&i;case 3:return t^e^i}}function an(s,t){return s<<t|s>>>32-t}function Jl(s){const t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof s=="string"){const r=unescape(encodeURIComponent(s));s=[];for(let l=0;l<r.length;++l)s.push(r.charCodeAt(l))}else Array.isArray(s)||(s=Array.prototype.slice.call(s));s.push(128);const i=s.length/4+2,n=Math.ceil(i/16),o=new Array(n);for(let r=0;r<n;++r){const l=new Uint32Array(16);for(let c=0;c<16;++c)l[c]=s[r*64+c*4]<<24|s[r*64+c*4+1]<<16|s[r*64+c*4+2]<<8|s[r*64+c*4+3];o[r]=l}o[n-1][14]=(s.length-1)*8/Math.pow(2,32),o[n-1][14]=Math.floor(o[n-1][14]),o[n-1][15]=(s.length-1)*8&4294967295;for(let r=0;r<n;++r){const l=new Uint32Array(80);for(let p=0;p<16;++p)l[p]=o[r][p];for(let p=16;p<80;++p)l[p]=an(l[p-3]^l[p-8]^l[p-14]^l[p-16],1);let c=e[0],a=e[1],d=e[2],h=e[3],u=e[4];for(let p=0;p<80;++p){const m=Math.floor(p/20),b=an(c,5)+Il(m,a,d,h)+u+t[m]+l[p]>>>0;u=h,h=d,d=an(a,30)>>>0,a=c,c=b}e[0]=e[0]+c>>>0,e[1]=e[1]+a>>>0,e[2]=e[2]+d>>>0,e[3]=e[3]+h>>>0,e[4]=e[4]+u>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}const Ul=Nl("v5",80,Jl),Pl=Ul;var pc={exports:{}},mc={exports:{}};(function(){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,i){return e<<i|e>>>32-i},rotr:function(e,i){return e<<32-i|e>>>i},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var i=0;i<e.length;i++)e[i]=t.endian(e[i]);return e},randomBytes:function(e){for(var i=[];e>0;e--)i.push(Math.floor(Math.random()*256));return i},bytesToWords:function(e){for(var i=[],n=0,o=0;n<e.length;n++,o+=8)i[o>>>5]|=e[n]<<24-o%32;return i},wordsToBytes:function(e){for(var i=[],n=0;n<e.length*32;n+=8)i.push(e[n>>>5]>>>24-n%32&255);return i},bytesToHex:function(e){for(var i=[],n=0;n<e.length;n++)i.push((e[n]>>>4).toString(16)),i.push((e[n]&15).toString(16));return i.join("")},hexToBytes:function(e){for(var i=[],n=0;n<e.length;n+=2)i.push(parseInt(e.substr(n,2),16));return i},bytesToBase64:function(e){for(var i=[],n=0;n<e.length;n+=3)for(var o=e[n]<<16|e[n+1]<<8|e[n+2],r=0;r<4;r++)n*8+r*6<=e.length*8?i.push(s.charAt(o>>>6*(3-r)&63)):i.push("=");return i.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var i=[],n=0,o=0;n<e.length;o=++n%4)o!=0&&i.push((s.indexOf(e.charAt(n-1))&Math.pow(2,-2*o+8)-1)<<o*2|s.indexOf(e.charAt(n))>>>6-o*2);return i}};mc.exports=t})();var Fl=mc.exports,Un={utf8:{stringToBytes:function(s){return Un.bin.stringToBytes(unescape(encodeURIComponent(s)))},bytesToString:function(s){return decodeURIComponent(escape(Un.bin.bytesToString(s)))}},bin:{stringToBytes:function(s){for(var t=[],e=0;e<s.length;e++)t.push(s.charCodeAt(e)&255);return t},bytesToString:function(s){for(var t=[],e=0;e<s.length;e++)t.push(String.fromCharCode(s[e]));return t.join("")}}},Uo=Un;/*!
|
|
78
|
+
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r}()),Es={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"},uc=function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=Es,this.browser=si.getBrowser(),this.browserVersion=si.getVersion(),this.supports=function(){var t={browser:si.isBrowserSupported(),webRTC:si.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!t.webRTC)return t;var e;try{e=new RTCPeerConnection(Es),t.audioVideo=!0;var i=void 0;try{i=e.createDataChannel("_PEERJSTEST",{ordered:!0}),t.data=!0,t.reliable=!!i.ordered;try{i.binaryType="blob",t.binaryBlob=!si.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{e&&e.close()}return t}(),this.pack=gs.pack,this.unpack=gs.unpack,this._dataCount=1}return r.prototype.noop=function(){},r.prototype.validateId=function(t){return!t||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(t)},r.prototype.chunk=function(t){for(var e=[],i=t.size,n=Math.ceil(i/L.chunkedMTU),s=0,o=0;o<i;){var c=Math.min(i,o+L.chunkedMTU),a=t.slice(o,c),l={__peerData:this._dataCount,n:s,data:a,total:n};e.push(l),o=c,s++}return this._dataCount++,e},r.prototype.blobToArrayBuffer=function(t,e){var i=new FileReader;return i.onload=function(n){n.target&&e(n.target.result)},i.readAsArrayBuffer(t),i},r.prototype.binaryStringToArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;i++)e[i]=t.charCodeAt(i)&255;return e.buffer},r.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},r.prototype.isSecure=function(){return location.protocol==="https:"},r}(),L=new uc,oa={};Ht(oa,"Peer",()=>Fn,r=>Fn=r);var ar={},hc=Object.prototype.hasOwnProperty,_t="~";function Ei(){}Object.create&&(Ei.prototype=Object.create(null),new Ei().__proto__||(_t=!1));function fc(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function aa(r,t,e,i,n){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new fc(e,i||r,n),o=_t?_t+t:t;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Fr(r,t){--r._eventsCount===0?r._events=new Ei:delete r._events[t]}function yt(){this._events=new Ei,this._eventsCount=0}yt.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)hc.call(e,i)&&t.push(_t?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};yt.prototype.listeners=function(t){var e=_t?_t+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,o=new Array(s);n<s;n++)o[n]=i[n].fn;return o};yt.prototype.listenerCount=function(t){var e=_t?_t+t:t,i=this._events[e];return i?i.fn?1:i.length:0};yt.prototype.emit=function(t,e,i,n,s,o){var c=_t?_t+t:t;if(!this._events[c])return!1;var a=this._events[c],l=arguments.length,u,h;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,e),!0;case 3:return a.fn.call(a.context,e,i),!0;case 4:return a.fn.call(a.context,e,i,n),!0;case 5:return a.fn.call(a.context,e,i,n,s),!0;case 6:return a.fn.call(a.context,e,i,n,s,o),!0}for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];a.fn.apply(a.context,u)}else{var f=a.length,d;for(h=0;h<f;h++)switch(a[h].once&&this.removeListener(t,a[h].fn,void 0,!0),l){case 1:a[h].fn.call(a[h].context);break;case 2:a[h].fn.call(a[h].context,e);break;case 3:a[h].fn.call(a[h].context,e,i);break;case 4:a[h].fn.call(a[h].context,e,i,n);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];a[h].fn.apply(a[h].context,u)}}return!0};yt.prototype.on=function(t,e,i){return aa(this,t,e,i,!1)};yt.prototype.once=function(t,e,i){return aa(this,t,e,i,!0)};yt.prototype.removeListener=function(t,e,i,n){var s=_t?_t+t:t;if(!this._events[s])return this;if(!e)return Fr(this,s),this;var o=this._events[s];if(o.fn)o.fn===e&&(!n||o.once)&&(!i||o.context===i)&&Fr(this,s);else{for(var c=0,a=[],l=o.length;c<l;c++)(o[c].fn!==e||n&&!o[c].once||i&&o[c].context!==i)&&a.push(o[c]);a.length?this._events[s]=a.length===1?a[0]:a:Fr(this,s)}return this};yt.prototype.removeAllListeners=function(t){var e;return t?(e=_t?_t+t:t,this._events[e]&&Fr(this,e)):(this._events=new Ei,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=_t;yt.EventEmitter=yt;ar=yt;var B={};Ht(B,"LogLevel",()=>St,r=>St=r);Ht(B,"default",()=>As,r=>As=r);var Ce=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),n,s=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},we=function(r,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,s;i<n;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return r.concat(s||Array.prototype.slice.call(t))},dc="PeerJS: ",St;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(St||(St={}));var pc=function(){function r(){this._logLevel=St.Disabled}return Object.defineProperty(r.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){this._logLevel=t},enumerable:!1,configurable:!0}),r.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=St.All&&this._print.apply(this,we([St.All],Ce(t),!1))},r.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=St.Warnings&&this._print.apply(this,we([St.Warnings],Ce(t),!1))},r.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=St.Errors&&this._print.apply(this,we([St.Errors],Ce(t),!1))},r.prototype.setLogFunction=function(t){this._print=t},r.prototype._print=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=we([dc],Ce(e),!1);for(var s in n)n[s]instanceof Error&&(n[s]="("+n[s].name+") "+n[s].message);t>=St.All?console.log.apply(console,we([],Ce(n),!1)):t>=St.Warnings?console.warn.apply(console,we(["WARNING"],Ce(n),!1)):t>=St.Errors&&console.error.apply(console,we(["ERROR"],Ce(n),!1))},r}(),As=new pc,ca={};Ht(ca,"Socket",()=>Rs,r=>Rs=r);var Dt;(function(r){r.Data="data",r.Media="media"})(Dt||(Dt={}));var Z;(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"})(Z||(Z={}));var te;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(te||(te={}));var ie;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(ie||(ie={}));var ut;(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"})(ut||(ut={}));var is={};is=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 mc=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),yc=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),n,s=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},gc=function(r,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,s;i<n;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return r.concat(s||Array.prototype.slice.call(t))},vc=function(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Rs=function(r){mc(t,r);function t(e,i,n,s,o,c){c===void 0&&(c=5e3);var a=r.call(this)||this;a.pingInterval=c,a._disconnected=!0,a._messagesQueue=[];var l=e?"wss://":"ws://";return a._baseUrl=l+i+":"+n+s+"peerjs?key="+o,a}return t.prototype.start=function(e,i){var n=this;this._id=e;var s="".concat(this._baseUrl,"&id=").concat(e,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+is.version),this._disconnected=!1,this._socket.onmessage=function(o){var c;try{c=JSON.parse(o.data),B.default.log("Server message received:",c)}catch{B.default.log("Invalid server message",o.data);return}n.emit(ie.Message,c)},this._socket.onclose=function(o){n._disconnected||(B.default.log("Socket closed.",o),n._cleanup(),n._disconnected=!0,n.emit(ie.Disconnected))},this._socket.onopen=function(){n._disconnected||(n._sendQueuedMessages(),B.default.log("Socket open"),n._scheduleHeartbeat())})},t.prototype._scheduleHeartbeat=function(){var e=this;this._wsPingTimer=setTimeout(function(){e._sendHeartbeat()},this.pingInterval)},t.prototype._sendHeartbeat=function(){if(!this._wsOpen()){B.default.log("Cannot send heartbeat, because socket closed");return}var e=JSON.stringify({type:ut.Heartbeat});this._socket.send(e),this._scheduleHeartbeat()},t.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},t.prototype._sendQueuedMessages=function(){var e,i,n=gc([],yc(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=vc(n),o=s.next();!o.done;o=s.next()){var c=o.value;this.send(c)}}catch(a){e={error:a}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}},t.prototype.send=function(e){if(!this._disconnected){if(!this._id){this._messagesQueue.push(e);return}if(!e.type){this.emit(ie.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(e);this._socket.send(i)}}},t.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},t.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)},t}(ar.EventEmitter),Un={};Ht(Un,"MediaConnection",()=>zs,r=>zs=r);var rs={};Ht(rs,"Negotiator",()=>ks,r=>ks=r);var Jr=function(){return Jr=Object.assign||function(r){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Jr.apply(this,arguments)},hr=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(u){try{l(i.next(u))}catch(h){o(h)}}function a(u){try{l(i.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):n(u.value).then(c,a)}l((i=i.apply(r,t||[])).next())})},fr=function(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(l){return function(u){return a([l,u])}}function a(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,n=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(r,e)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ks=function(){function r(t){this.connection=t}return r.prototype.startConnection=function(t){var e=this._startPeerConnection();if(this.connection.peerConnection=e,this.connection.type===Dt.Media&&t._stream&&this._addTracksToConnection(t._stream,e),t.originator){if(this.connection.type===Dt.Data){var i=this.connection,n={ordered:!!t.reliable},s=e.createDataChannel(i.label,n);i.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",t.sdp)},r.prototype._startPeerConnection=function(){B.default.log("Creating RTCPeerConnection.");var t=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(t),t},r.prototype._setupListeners=function(t){var e=this,i=this.connection.peer,n=this.connection.connectionId,s=this.connection.type,o=this.connection.provider;B.default.log("Listening for ICE candidates."),t.onicecandidate=function(c){!c.candidate||!c.candidate.candidate||(B.default.log("Received ICE candidates for ".concat(i,":"),c.candidate),o.socket.send({type:ut.Candidate,payload:{candidate:c.candidate,type:s,connectionId:n},dst:i}))},t.oniceconnectionstatechange=function(){switch(t.iceConnectionState){case"failed":B.default.log("iceConnectionState is failed, closing connections to "+i),e.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),e.connection.close();break;case"closed":B.default.log("iceConnectionState is closed, closing connections to "+i),e.connection.emit("error",new Error("Connection to "+i+" closed.")),e.connection.close();break;case"disconnected":B.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":t.onicecandidate=L.noop;break}e.connection.emit("iceStateChanged",t.iceConnectionState)},B.default.log("Listening for data channel"),t.ondatachannel=function(c){B.default.log("Received data channel");var a=c.channel,l=o.getConnection(i,n);l.initialize(a)},B.default.log("Listening for remote stream"),t.ontrack=function(c){B.default.log("Received remote stream");var a=c.streams[0],l=o.getConnection(i,n);if(l.type===Dt.Media){var u=l;e._addStreamToMediaConnection(a,u)}}},r.prototype.cleanup=function(){B.default.log("Cleaning up PeerConnection to "+this.connection.peer);var t=this.connection.peerConnection;if(t){this.connection.peerConnection=null,t.onicecandidate=t.oniceconnectionstatechange=t.ondatachannel=t.ontrack=function(){};var e=t.signalingState!=="closed",i=!1;if(this.connection.type===Dt.Data){var n=this.connection,s=n.dataChannel;s&&(i=!!s.readyState&&s.readyState!=="closed")}(e||i)&&t.close()}},r.prototype._makeOffer=function(){return hr(this,void 0,Promise,function(){var t,e,i,n,s,o,c;return fr(this,function(a){switch(a.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,t.createOffer(this.connection.options.constraints)];case 2:i=a.sent(),B.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return a.sent(),B.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),n={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:L.browser},this.connection.type===Dt.Data&&(s=this.connection,n=Jr(Jr({},n),{label:s.label,reliable:s.reliable,serialization:s.serialization})),e.socket.send({type:ut.Offer,payload:n,dst:this.connection.peer}),[3,6];case 5:return o=a.sent(),o!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(e.emitError(Z.WebRTC,o),B.default.log("Failed to setLocalDescription, ",o)),[3,6];case 6:return[3,8];case 7:return c=a.sent(),e.emitError(Z.WebRTC,c),B.default.log("Failed to createOffer, ",c),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return hr(this,void 0,Promise,function(){var t,e,i,n,s;return fr(this,function(o){switch(o.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,o.label=1;case 1:return o.trys.push([1,7,,8]),[4,t.createAnswer()];case 2:i=o.sent(),B.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return o.sent(),B.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),e.socket.send({type:ut.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:L.browser},dst:this.connection.peer}),[3,6];case 5:return n=o.sent(),e.emitError(Z.WebRTC,n),B.default.log("Failed to setLocalDescription, ",n),[3,6];case 6:return[3,8];case 7:return s=o.sent(),e.emitError(Z.WebRTC,s),B.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(t,e){return hr(this,void 0,Promise,function(){var i,n,s,o;return fr(this,function(c){switch(c.label){case 0:e=new RTCSessionDescription(e),i=this.connection.peerConnection,n=this.connection.provider,B.default.log("Setting remote description",e),s=this,c.label=1;case 1:return c.trys.push([1,5,,6]),[4,i.setRemoteDescription(e)];case 2:return c.sent(),B.default.log("Set remoteDescription:".concat(t," for:").concat(this.connection.peer)),t!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:c.sent(),c.label=4;case 4:return[3,6];case 5:return o=c.sent(),n.emitError(Z.WebRTC,o),B.default.log("Failed to setRemoteDescription, ",o),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(t){return hr(this,void 0,Promise,function(){var e,i,n,s,o,c;return fr(this,function(a){switch(a.label){case 0:B.default.log("handleCandidate:",t),e=t.candidate,i=t.sdpMLineIndex,n=t.sdpMid,s=this.connection.peerConnection,o=this.connection.provider,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:n,sdpMLineIndex:i,candidate:e}))];case 2:return a.sent(),B.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return c=a.sent(),o.emitError(Z.WebRTC,c),B.default.log("Failed to handleCandidate, ",c),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(t,e){if(B.default.log("add tracks from stream ".concat(t.id," to peer connection")),!e.addTrack)return B.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");t.getTracks().forEach(function(i){e.addTrack(i,t)})},r.prototype._addStreamToMediaConnection=function(t,e){B.default.log("add stream ".concat(t.id," to media connection ").concat(e.connectionId)),e.addStream(t)},r}(),ns={};Ht(ns,"BaseConnection",()=>Bs,r=>Bs=r);var xc=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Bs=function(r){xc(t,r);function t(e,i,n){var s=r.call(this)||this;return s.peer=e,s.provider=i,s.options=n,s._open=!1,s.metadata=n.metadata,s}return Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),t}(ar.EventEmitter),_c=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Gr=function(){return Gr=Object.assign||function(r){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Gr.apply(this,arguments)},bc=function(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},zs=function(r){_c(t,r);function t(e,i,n){var s=r.call(this,e,i,n)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||t.ID_PREFIX+L.randomToken(),s._negotiator=new rs.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(t.prototype,"type",{get:function(){return Dt.Media},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),t.prototype.addStream=function(e){B.default.log("Receiving stream",e),this._remoteStream=e,r.prototype.emit.call(this,"stream",e)},t.prototype.handleMessage=function(e){var i=e.type,n=e.payload;switch(e.type){case ut.Answer:this._negotiator.handleSDP(i,n.sdp),this._open=!0;break;case ut.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:B.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},t.prototype.answer=function(e,i){var n,s;if(i===void 0&&(i={}),this._localStream){B.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=e,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(Gr(Gr({},this.options._payload),{_stream:e}));var o=this.provider._getMessages(this.connectionId);try{for(var c=bc(o),a=c.next();!a.done;a=c.next()){var l=a.value;this.handleMessage(l)}}catch(u){n={error:u}}finally{try{a&&!a.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}this._open=!0},t.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"))},t.ID_PREFIX="mc_",t}(ns.BaseConnection),Dn={};Ht(Dn,"DataConnection",()=>Is,r=>Is=r);var la={};Ht(la,"EncodingQueue",()=>Os,r=>Os=r);var Sc=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Os=function(r){Sc(t,r);function t(){var e=r.call(this)||this;return e.fileReader=new FileReader,e._queue=[],e._processing=!1,e.fileReader.onload=function(i){e._processing=!1,i.target&&e.emit("done",i.target.result),e.doNextTask()},e.fileReader.onerror=function(i){B.default.error("EncodingQueue error:",i),e._processing=!1,e.destroy(),e.emit("error",i)},e}return Object.defineProperty(t.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),t.prototype.enque=function(e){this.queue.push(e),!this.processing&&this.doNextTask()},t.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},t.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},t}(ar.EventEmitter),Tc=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Mc=function(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Is=function(r){Tc(t,r);function t(e,i,n){var s=r.call(this,e,i,n)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new la.EncodingQueue,s.connectionId=s.options.connectionId||t.ID_PREFIX+L.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||te.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(o){s._bufferedSend(o)}),s._encodingQueue.on("error",function(){B.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new rs.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(t.prototype,"type",{get:function(){return Dt.Data},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._dc=e,this._configureDataChannel()},t.prototype._configureDataChannel=function(){var e=this;(!L.supports.binaryBlob||L.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){B.default.log("DC#".concat(e.connectionId," dc connection success")),e._open=!0,e.emit("open")},this.dataChannel.onmessage=function(i){B.default.log("DC#".concat(e.connectionId," dc onmessage:"),i.data),e._handleDataMessage(i)},this.dataChannel.onclose=function(){B.default.log("DC#".concat(e.connectionId," dc closed for:"),e.peer),e.close()}},t.prototype._handleDataMessage=function(e){var i=this,n=e.data,s=n.constructor,o=this.serialization===te.Binary||this.serialization===te.BinaryUTF8,c=n;if(o){if(s===Blob){L.blobToArrayBuffer(n,function(l){var u=L.unpack(l);i.emit("data",u)});return}else if(s===ArrayBuffer)c=L.unpack(n);else if(s===String){var a=L.binaryStringToArrayBuffer(n);c=L.unpack(a)}}else this.serialization===te.JSON&&(c=this.parse(n));if(c.__peerData){this._handleChunk(c);return}r.prototype.emit.call(this,"data",c)},t.prototype._handleChunk=function(e){var i=e.__peerData,n=this._chunkedData[i]||{data:[],count:0,total:e.total};if(n.data[e.n]=e.data,n.count++,this._chunkedData[i]=n,n.total===n.count){delete this._chunkedData[i];var s=new Blob(n.data);this._handleDataMessage({data:s})}},t.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"))},t.prototype.send=function(e,i){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===te.JSON)this._bufferedSend(this.stringify(e));else if(this.serialization===te.Binary||this.serialization===te.BinaryUTF8){var n=L.pack(e);if(!i&&n.size>L.chunkedMTU){this._sendChunks(n);return}L.supports.binaryBlob?this._bufferedSend(n):this._encodingQueue.enque(n)}else this._bufferedSend(e)},t.prototype._bufferedSend=function(e){(this._buffering||!this._trySend(e))&&(this._buffer.push(e),this._bufferSize=this._buffer.length)},t.prototype._trySend=function(e){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>t.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(e)}catch(n){return B.default.error("DC#:".concat(this.connectionId," Error when sending:"),n),this._buffering=!0,this.close(),!1}return!0},t.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var e=this._buffer[0];this._trySend(e)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},t.prototype._sendChunks=function(e){var i,n,s=L.chunk(e);B.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var o=Mc(s),c=o.next();!c.done;c=o.next()){var a=c.value;this.send(a,!0)}}catch(l){i={error:l}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},t.prototype.handleMessage=function(e){var i=e.payload;switch(e.type){case ut.Answer:this._negotiator.handleSDP(e.type,i.sdp);break;case ut.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:B.default.warn("Unrecognized message type:",e.type,"from peer:",this.peer);break}},t.ID_PREFIX="dc_",t.MAX_BUFFERED_AMOUNT=8388608,t}(ns.BaseConnection),ua={};Ht(ua,"API",()=>Ds,r=>Ds=r);var Ns=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(u){try{l(i.next(u))}catch(h){o(h)}}function a(u){try{l(i.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):n(u.value).then(c,a)}l((i=i.apply(r,t||[])).next())})},Us=function(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(l){return function(u){return a([l,u])}}function a(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,n=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(r,e)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ds=function(){function r(t){this._options=t}return r.prototype._buildRequest=function(t){var e=this._options.secure?"https":"http",i=this._options,n=i.host,s=i.port,o=i.path,c=i.key,a=new URL("".concat(e,"://").concat(n,":").concat(s).concat(o).concat(c,"/").concat(t));return a.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),a.searchParams.set("version",is.version),fetch(a.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return Ns(this,void 0,Promise,function(){var t,e,i;return Us(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(t=n.sent(),t.status!==200)throw new Error("Error. Status:".concat(t.status));return[2,t.text()];case 2:throw e=n.sent(),B.default.error("Error retrieving ID",e),i="",this._options.path==="/"&&this._options.host!==L.CLOUD_HOST&&(i=" 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."+i);case 3:return[2]}})})},r.prototype.listAllPeers=function(){return Ns(this,void 0,Promise,function(){var t,e,i;return Us(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(t=n.sent(),t.status!==200)throw t.status===401?(e="",this._options.host===L.CLOUD_HOST?e="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":e="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. "+e)):new Error("Error. Status:".concat(t.status));return[2,t.json()];case 2:throw i=n.sent(),B.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},r}(),Cc=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Ci=function(){return Ci=Object.assign||function(r){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Ci.apply(this,arguments)},oi=function(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},wc=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),n,s=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Fn=function(r){Cc(t,r);function t(e,i){var n=r.call(this)||this;n._id=null,n._lastServerId=null,n._destroyed=!1,n._disconnected=!1,n._open=!1,n._connections=new Map,n._lostMessages=new Map;var s;return e&&e.constructor==Object?i=e:e&&(s=e.toString()),i=Ci({debug:0,host:L.CLOUD_HOST,port:L.CLOUD_PORT,path:"/",key:t.DEFAULT_KEY,token:L.randomToken(),config:L.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),n._options=i,n._options.host==="/"&&(n._options.host=window.location.hostname),n._options.path&&(n._options.path[0]!=="/"&&(n._options.path="/"+n._options.path),n._options.path[n._options.path.length-1]!=="/"&&(n._options.path+="/")),n._options.secure===void 0&&n._options.host!==L.CLOUD_HOST?n._options.secure=L.isSecure():n._options.host==L.CLOUD_HOST&&(n._options.secure=!0),n._options.logFunction&&B.default.setLogFunction(n._options.logFunction),B.default.logLevel=n._options.debug||0,n._api=new ua.API(i),n._socket=n._createServerConnection(),!L.supports.audioVideo&&!L.supports.data?(n._delayedAbort(Z.BrowserIncompatible,"The current browser does not support WebRTC"),n):s&&!L.validateId(s)?(n._delayedAbort(Z.InvalidID,'ID "'.concat(s,'" is invalid')),n):(s?n._initialize(s):n._api.retrieveId().then(function(o){return n._initialize(o)}).catch(function(o){return n._abort(Z.ServerError,o)}),n)}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connections",{get:function(){var e,i,n=Object.create(null);try{for(var s=oi(this._connections),o=s.next();!o.done;o=s.next()){var c=wc(o.value,2),a=c[0],l=c[1];n[a]=l}}catch(u){e={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),t.prototype._createServerConnection=function(){var e=this,i=new ca.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(ie.Message,function(n){e._handleMessage(n)}),i.on(ie.Error,function(n){e._abort(Z.SocketError,n)}),i.on(ie.Disconnected,function(){e.disconnected||(e.emitError(Z.Network,"Lost connection to server."),e.disconnect())}),i.on(ie.Close,function(){e.disconnected||e._abort(Z.SocketClosed,"Underlying socket is already closed.")}),i},t.prototype._initialize=function(e){this._id=e,this.socket.start(e,this._options.token)},t.prototype._handleMessage=function(e){var i,n,s=e.type,o=e.payload,c=e.src;switch(s){case ut.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case ut.Error:this._abort(Z.ServerError,o.msg);break;case ut.IdTaken:this._abort(Z.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case ut.InvalidKey:this._abort(Z.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case ut.Leave:B.default.log("Received leave message from ".concat(c)),this._cleanupPeer(c),this._connections.delete(c);break;case ut.Expire:this.emitError(Z.PeerUnavailable,"Could not connect to peer ".concat(c));break;case ut.Offer:var p=o.connectionId,m=this.getConnection(c,p);if(m&&(m.close(),B.default.warn("Offer received for existing Connection ID:".concat(p))),o.type===Dt.Media){var a=new Un.MediaConnection(c,this,{connectionId:p,_payload:o,metadata:o.metadata});m=a,this._addConnection(c,m),this.emit("call",a)}else if(o.type===Dt.Data){var l=new Dn.DataConnection(c,this,{connectionId:p,_payload:o,metadata:o.metadata,label:o.label,serialization:o.serialization,reliable:o.reliable});m=l,this._addConnection(c,m),this.emit("connection",l)}else{B.default.warn("Received malformed connection type:".concat(o.type));return}var u=this._getMessages(p);try{for(var h=oi(u),f=h.next();!f.done;f=h.next()){var d=f.value;m.handleMessage(d)}}catch(g){i={error:g}}finally{try{f&&!f.done&&(n=h.return)&&n.call(h)}finally{if(i)throw i.error}}break;default:if(!o){B.default.warn("You received a malformed message from ".concat(c," of type ").concat(s));return}var p=o.connectionId,m=this.getConnection(c,p);m&&m.peerConnection?m.handleMessage(e):p?this._storeMessage(p,e):B.default.warn("You received an unrecognized message:",e);break}},t.prototype._storeMessage=function(e,i){this._lostMessages.has(e)||this._lostMessages.set(e,[]),this._lostMessages.get(e).push(i)},t.prototype._getMessages=function(e){var i=this._lostMessages.get(e);return i?(this._lostMessages.delete(e),i):[]},t.prototype.connect=function(e,i){if(i===void 0&&(i={}),this.disconnected){B.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(Z.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var n=new Dn.DataConnection(e,this,i);return this._addConnection(e,n),n},t.prototype.call=function(e,i,n){if(n===void 0&&(n={}),this.disconnected){B.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(Z.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){B.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Un.MediaConnection(e,this,Ci(Ci({},n),{_stream:i}));return this._addConnection(e,s),s},t.prototype._addConnection=function(e,i){B.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(e)),this._connections.has(e)||this._connections.set(e,[]),this._connections.get(e).push(i)},t.prototype._removeConnection=function(e){var i=this._connections.get(e.peer);if(i){var n=i.indexOf(e);n!==-1&&i.splice(n,1)}this._lostMessages.delete(e.connectionId)},t.prototype.getConnection=function(e,i){var n,s,o=this._connections.get(e);if(!o)return null;try{for(var c=oi(o),a=c.next();!a.done;a=c.next()){var l=a.value;if(l.connectionId===i)return l}}catch(u){n={error:u}}finally{try{a&&!a.done&&(s=c.return)&&s.call(c)}finally{if(n)throw n.error}}return null},t.prototype._delayedAbort=function(e,i){var n=this;setTimeout(function(){n._abort(e,i)},0)},t.prototype._abort=function(e,i){B.default.error("Aborting!"),this.emitError(e,i),this._lastServerId?this.disconnect():this.destroy()},t.prototype.emitError=function(e,i){B.default.error("Error:",i);var n;typeof i=="string"?n=new Error(i):n=i,n.type=e,this.emit("error",n)},t.prototype.destroy=function(){this.destroyed||(B.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},t.prototype._cleanup=function(){var e,i;try{for(var n=oi(this._connections.keys()),s=n.next();!s.done;s=n.next()){var o=s.value;this._cleanupPeer(o),this._connections.delete(o)}}catch(c){e={error:c}}finally{try{s&&!s.done&&(i=n.return)&&i.call(n)}finally{if(e)throw e.error}}this.socket.removeAllListeners()},t.prototype._cleanupPeer=function(e){var i,n,s=this._connections.get(e);if(s)try{for(var o=oi(s),c=o.next();!c.done;c=o.next()){var a=c.value;a.close()}}catch(l){i={error:l}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},t.prototype.disconnect=function(){if(!this.disconnected){var e=this.id;B.default.log("Disconnect peer with ID:".concat(e)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=e,this._id=null,this.emit("disconnected",e)}},t.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)B.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)B.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!"))}},t.prototype.listAllPeers=function(e){var i=this;e===void 0&&(e=function(n){}),this._api.listAllPeers().then(function(n){return e(n)}).catch(function(n){return i._abort(Z.ServerError,n)})},t.DEFAULT_KEY="peerjs",t}(ar.EventEmitter),ha=oa.Peer;const Pc=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Fn},default:ha,util:L},Symbol.toStringTag,{value:"Module"})),Ec=/^(?:[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 Ac(r){return typeof r=="string"&&Ec.test(r)}const lt=[];for(let r=0;r<256;++r)lt.push((r+256).toString(16).slice(1));function Rc(r,t=0){return lt[r[t+0]]+lt[r[t+1]]+lt[r[t+2]]+lt[r[t+3]]+"-"+lt[r[t+4]]+lt[r[t+5]]+"-"+lt[r[t+6]]+lt[r[t+7]]+"-"+lt[r[t+8]]+lt[r[t+9]]+"-"+lt[r[t+10]]+lt[r[t+11]]+lt[r[t+12]]+lt[r[t+13]]+lt[r[t+14]]+lt[r[t+15]]}function kc(r){if(!Ac(r))throw TypeError("Invalid UUID");let t;const e=new Uint8Array(16);return e[0]=(t=parseInt(r.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(r.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(r.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(r.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(r.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function Bc(r){r=unescape(encodeURIComponent(r));const t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}const zc="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Oc="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ic(r,t,e){function i(n,s,o,c){var a;if(typeof n=="string"&&(n=Bc(n)),typeof s=="string"&&(s=kc(s)),((a=s)===null||a===void 0?void 0:a.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+n.length);if(l.set(s),l.set(n,s.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,o){c=c||0;for(let u=0;u<16;++u)o[c+u]=l[u];return o}return Rc(l)}try{i.name=r}catch{}return i.DNS=zc,i.URL=Oc,i}function Nc(r,t,e,i){switch(r){case 0:return t&e^~t&i;case 1:return t^e^i;case 2:return t&e^t&i^e&i;case 3:return t^e^i}}function ln(r,t){return r<<t|r>>>32-t}function Uc(r){const t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){const o=unescape(encodeURIComponent(r));r=[];for(let c=0;c<o.length;++c)r.push(o.charCodeAt(c))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);const i=r.length/4+2,n=Math.ceil(i/16),s=new Array(n);for(let o=0;o<n;++o){const c=new Uint32Array(16);for(let a=0;a<16;++a)c[a]=r[o*64+a*4]<<24|r[o*64+a*4+1]<<16|r[o*64+a*4+2]<<8|r[o*64+a*4+3];s[o]=c}s[n-1][14]=(r.length-1)*8/Math.pow(2,32),s[n-1][14]=Math.floor(s[n-1][14]),s[n-1][15]=(r.length-1)*8&4294967295;for(let o=0;o<n;++o){const c=new Uint32Array(80);for(let d=0;d<16;++d)c[d]=s[o][d];for(let d=16;d<80;++d)c[d]=ln(c[d-3]^c[d-8]^c[d-14]^c[d-16],1);let a=e[0],l=e[1],u=e[2],h=e[3],f=e[4];for(let d=0;d<80;++d){const p=Math.floor(d/20),m=ln(a,5)+Nc(p,l,u,h)+f+t[p]+c[d]>>>0;f=h,h=u,u=ln(l,30)>>>0,l=a,a=m}e[0]=e[0]+a>>>0,e[1]=e[1]+l>>>0,e[2]=e[2]+u>>>0,e[3]=e[3]+h>>>0,e[4]=e[4]+f>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}const Dc=Ic("v5",80,Uc),Fc=Dc;var fa={exports:{}},da={exports:{}};(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,i){return e<<i|e>>>32-i},rotr:function(e,i){return e<<32-i|e>>>i},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var i=0;i<e.length;i++)e[i]=t.endian(e[i]);return e},randomBytes:function(e){for(var i=[];e>0;e--)i.push(Math.floor(Math.random()*256));return i},bytesToWords:function(e){for(var i=[],n=0,s=0;n<e.length;n++,s+=8)i[s>>>5]|=e[n]<<24-s%32;return i},wordsToBytes:function(e){for(var i=[],n=0;n<e.length*32;n+=8)i.push(e[n>>>5]>>>24-n%32&255);return i},bytesToHex:function(e){for(var i=[],n=0;n<e.length;n++)i.push((e[n]>>>4).toString(16)),i.push((e[n]&15).toString(16));return i.join("")},hexToBytes:function(e){for(var i=[],n=0;n<e.length;n+=2)i.push(parseInt(e.substr(n,2),16));return i},bytesToBase64:function(e){for(var i=[],n=0;n<e.length;n+=3)for(var s=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)n*8+o*6<=e.length*8?i.push(r.charAt(s>>>6*(3-o)&63)):i.push("=");return i.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var i=[],n=0,s=0;n<e.length;s=++n%4)s!=0&&i.push((r.indexOf(e.charAt(n-1))&Math.pow(2,-2*s+8)-1)<<s*2|r.indexOf(e.charAt(n))>>>6-s*2);return i}};da.exports=t})();var Lc=da.exports,Ln={utf8:{stringToBytes:function(r){return Ln.bin.stringToBytes(unescape(encodeURIComponent(r)))},bytesToString:function(r){return decodeURIComponent(escape(Ln.bin.bytesToString(r)))}},bin:{stringToBytes:function(r){for(var t=[],e=0;e<r.length;e++)t.push(r.charCodeAt(e)&255);return t},bytesToString:function(r){for(var t=[],e=0;e<r.length;e++)t.push(String.fromCharCode(r[e]));return t.join("")}}},Fs=Ln;/*!
|
|
79
79
|
* Determine if an object is a Buffer
|
|
80
80
|
*
|
|
81
81
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
82
82
|
* @license MIT
|
|
83
|
-
*/var Ql=function(s){return s!=null&&(bc(s)||wl(s)||!!s._isBuffer)};function bc(s){return!!s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function wl(s){return typeof s.readFloatLE=="function"&&typeof s.slice=="function"&&bc(s.slice(0,0))}(function(){var s=Fl,t=Uo.utf8,e=Ql,i=Uo.bin,n=function(o,r){o.constructor==String?r&&r.encoding==="binary"?o=i.stringToBytes(o):o=t.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var l=s.bytesToWords(o),c=o.length*8,a=1732584193,d=-271733879,h=-1732584194,u=271733878,p=0;p<l.length;p++)l[p]=(l[p]<<8|l[p]>>>24)&16711935|(l[p]<<24|l[p]>>>8)&4278255360;l[c>>>5]|=128<<c%32,l[(c+64>>>9<<4)+14]=c;for(var m=n._ff,b=n._gg,G=n._hh,y=n._ii,p=0;p<l.length;p+=16){var Z=a,V=d,R=h,f=u;a=m(a,d,h,u,l[p+0],7,-680876936),u=m(u,a,d,h,l[p+1],12,-389564586),h=m(h,u,a,d,l[p+2],17,606105819),d=m(d,h,u,a,l[p+3],22,-1044525330),a=m(a,d,h,u,l[p+4],7,-176418897),u=m(u,a,d,h,l[p+5],12,1200080426),h=m(h,u,a,d,l[p+6],17,-1473231341),d=m(d,h,u,a,l[p+7],22,-45705983),a=m(a,d,h,u,l[p+8],7,1770035416),u=m(u,a,d,h,l[p+9],12,-1958414417),h=m(h,u,a,d,l[p+10],17,-42063),d=m(d,h,u,a,l[p+11],22,-1990404162),a=m(a,d,h,u,l[p+12],7,1804603682),u=m(u,a,d,h,l[p+13],12,-40341101),h=m(h,u,a,d,l[p+14],17,-1502002290),d=m(d,h,u,a,l[p+15],22,1236535329),a=b(a,d,h,u,l[p+1],5,-165796510),u=b(u,a,d,h,l[p+6],9,-1069501632),h=b(h,u,a,d,l[p+11],14,643717713),d=b(d,h,u,a,l[p+0],20,-373897302),a=b(a,d,h,u,l[p+5],5,-701558691),u=b(u,a,d,h,l[p+10],9,38016083),h=b(h,u,a,d,l[p+15],14,-660478335),d=b(d,h,u,a,l[p+4],20,-405537848),a=b(a,d,h,u,l[p+9],5,568446438),u=b(u,a,d,h,l[p+14],9,-1019803690),h=b(h,u,a,d,l[p+3],14,-187363961),d=b(d,h,u,a,l[p+8],20,1163531501),a=b(a,d,h,u,l[p+13],5,-1444681467),u=b(u,a,d,h,l[p+2],9,-51403784),h=b(h,u,a,d,l[p+7],14,1735328473),d=b(d,h,u,a,l[p+12],20,-1926607734),a=G(a,d,h,u,l[p+5],4,-378558),u=G(u,a,d,h,l[p+8],11,-2022574463),h=G(h,u,a,d,l[p+11],16,1839030562),d=G(d,h,u,a,l[p+14],23,-35309556),a=G(a,d,h,u,l[p+1],4,-1530992060),u=G(u,a,d,h,l[p+4],11,1272893353),h=G(h,u,a,d,l[p+7],16,-155497632),d=G(d,h,u,a,l[p+10],23,-1094730640),a=G(a,d,h,u,l[p+13],4,681279174),u=G(u,a,d,h,l[p+0],11,-358537222),h=G(h,u,a,d,l[p+3],16,-722521979),d=G(d,h,u,a,l[p+6],23,76029189),a=G(a,d,h,u,l[p+9],4,-640364487),u=G(u,a,d,h,l[p+12],11,-421815835),h=G(h,u,a,d,l[p+15],16,530742520),d=G(d,h,u,a,l[p+2],23,-995338651),a=y(a,d,h,u,l[p+0],6,-198630844),u=y(u,a,d,h,l[p+7],10,1126891415),h=y(h,u,a,d,l[p+14],15,-1416354905),d=y(d,h,u,a,l[p+5],21,-57434055),a=y(a,d,h,u,l[p+12],6,1700485571),u=y(u,a,d,h,l[p+3],10,-1894986606),h=y(h,u,a,d,l[p+10],15,-1051523),d=y(d,h,u,a,l[p+1],21,-2054922799),a=y(a,d,h,u,l[p+8],6,1873313359),u=y(u,a,d,h,l[p+15],10,-30611744),h=y(h,u,a,d,l[p+6],15,-1560198380),d=y(d,h,u,a,l[p+13],21,1309151649),a=y(a,d,h,u,l[p+4],6,-145523070),u=y(u,a,d,h,l[p+11],10,-1120210379),h=y(h,u,a,d,l[p+2],15,718787259),d=y(d,h,u,a,l[p+9],21,-343485551),a=a+Z>>>0,d=d+V>>>0,h=h+R>>>0,u=u+f>>>0}return s.endian([a,d,h,u])};n._ff=function(o,r,l,c,a,d,h){var u=o+(r&l|~r&c)+(a>>>0)+h;return(u<<d|u>>>32-d)+r},n._gg=function(o,r,l,c,a,d,h){var u=o+(r&c|l&~c)+(a>>>0)+h;return(u<<d|u>>>32-d)+r},n._hh=function(o,r,l,c,a,d,h){var u=o+(r^l^c)+(a>>>0)+h;return(u<<d|u>>>32-d)+r},n._ii=function(o,r,l,c,a,d,h){var u=o+(l^(r|~c))+(a>>>0)+h;return(u<<d|u>>>32-d)+r},n._blocksize=16,n._digestsize=16,pc.exports=function(o,r){if(o==null)throw new Error("Illegal argument "+o);var l=s.wordsToBytes(n(o,r));return r&&r.asBytes?l:r&&r.asString?i.bytesToString(l):s.bytesToHex(l)}})();var Bl=pc.exports;const El=qs(Bl),bt=["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 Po=1234567;const yc=Math.PI/180,Gc=180/Math.PI;function jl(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(bt[s&255]+bt[s>>8&255]+bt[s>>16&255]+bt[s>>24&255]+"-"+bt[t&255]+bt[t>>8&255]+"-"+bt[t>>16&15|64]+bt[t>>24&255]+"-"+bt[e&63|128]+bt[e>>8&255]+"-"+bt[e>>16&255]+bt[e>>24&255]+bt[i&255]+bt[i>>8&255]+bt[i>>16&255]+bt[i>>24&255]).toLowerCase()}function Qt(s,t,e){return Math.max(t,Math.min(e,s))}function Zc(s,t){return(s%t+t)%t}function Ol(s,t,e,i,n){return i+(s-t)*(n-i)/(e-t)}function Dl(s,t,e){return s!==t?(e-s)/(t-s):0}function Xc(s,t,e){return(1-e)*s+e*t}function _l(s,t,e,i){return Xc(s,t,1-Math.exp(-e*i))}function Al(s,t=1){return t-Math.abs(Zc(s,t*2)-t)}function ql(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function $l(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function ta(s,t){return s+Math.floor(Math.random()*(t-s+1))}function ea(s,t){return s+Math.random()*(t-s)}function ia(s){return s*(.5-Math.random())}function sa(s){s!==void 0&&(Po=s);let t=Po+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function na(s){return s*yc}function oa(s){return s*Gc}function ra(s){return(s&s-1)===0&&s!==0}function ca(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function la(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function aa(s,t,e,i,n){const o=Math.cos,r=Math.sin,l=o(e/2),c=r(e/2),a=o((t+i)/2),d=r((t+i)/2),h=o((t-i)/2),u=r((t-i)/2),p=o((i-t)/2),m=r((i-t)/2);switch(n){case"XYX":s.set(l*d,c*h,c*u,l*a);break;case"YZY":s.set(c*u,l*d,c*h,l*a);break;case"ZXZ":s.set(c*h,c*u,l*d,l*a);break;case"XZX":s.set(l*d,c*m,c*p,l*a);break;case"YXY":s.set(c*p,l*d,c*m,l*a);break;case"ZYZ":s.set(c*m,c*p,l*d,l*a);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function da(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function ha(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const $e={DEG2RAD:yc,RAD2DEG:Gc,generateUUID:jl,clamp:Qt,euclideanModulo:Zc,mapLinear:Ol,inverseLerp:Dl,lerp:Xc,damp:_l,pingpong:Al,smoothstep:ql,smootherstep:$l,randInt:ta,randFloat:ea,randFloatSpread:ia,seededRandom:sa,degToRad:na,radToDeg:oa,isPowerOfTwo:ra,ceilPowerOfTwo:ca,floorPowerOfTwo:la,setQuaternionFromProperEuler:aa,normalize:ha,denormalize:da};class Q{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,o,r,l){let c=i[n+0],a=i[n+1],d=i[n+2],h=i[n+3];const u=o[r+0],p=o[r+1],m=o[r+2],b=o[r+3];if(l===0){t[e+0]=c,t[e+1]=a,t[e+2]=d,t[e+3]=h;return}if(l===1){t[e+0]=u,t[e+1]=p,t[e+2]=m,t[e+3]=b;return}if(h!==b||c!==u||a!==p||d!==m){let G=1-l;const y=c*u+a*p+d*m+h*b,Z=y>=0?1:-1,V=1-y*y;if(V>Number.EPSILON){const f=Math.sqrt(V),x=Math.atan2(f,y*Z);G=Math.sin(G*x)/f,l=Math.sin(l*x)/f}const R=l*Z;if(c=c*G+u*R,a=a*G+p*R,d=d*G+m*R,h=h*G+b*R,G===1-l){const f=1/Math.sqrt(c*c+a*a+d*d+h*h);c*=f,a*=f,d*=f,h*=f}}t[e]=c,t[e+1]=a,t[e+2]=d,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,n,o,r){const l=i[n],c=i[n+1],a=i[n+2],d=i[n+3],h=o[r],u=o[r+1],p=o[r+2],m=o[r+3];return t[e]=l*m+d*h+c*p-a*u,t[e+1]=c*m+d*u+a*h-l*p,t[e+2]=a*m+d*p+l*u-c*h,t[e+3]=d*m-l*h-c*u-a*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new Q(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,o=t._z,r=t._order,l=Math.cos,c=Math.sin,a=l(i/2),d=l(n/2),h=l(o/2),u=c(i/2),p=c(n/2),m=c(o/2);switch(r){case"XYZ":this._x=u*d*h+a*p*m,this._y=a*p*h-u*d*m,this._z=a*d*m+u*p*h,this._w=a*d*h-u*p*m;break;case"YXZ":this._x=u*d*h+a*p*m,this._y=a*p*h-u*d*m,this._z=a*d*m-u*p*h,this._w=a*d*h+u*p*m;break;case"ZXY":this._x=u*d*h-a*p*m,this._y=a*p*h+u*d*m,this._z=a*d*m+u*p*h,this._w=a*d*h-u*p*m;break;case"ZYX":this._x=u*d*h-a*p*m,this._y=a*p*h+u*d*m,this._z=a*d*m-u*p*h,this._w=a*d*h+u*p*m;break;case"YZX":this._x=u*d*h+a*p*m,this._y=a*p*h+u*d*m,this._z=a*d*m-u*p*h,this._w=a*d*h-u*p*m;break;case"XZY":this._x=u*d*h-a*p*m,this._y=a*p*h-u*d*m,this._z=a*d*m+u*p*h,this._w=a*d*h+u*p*m;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],o=e[8],r=e[1],l=e[5],c=e[9],a=e[2],d=e[6],h=e[10],u=i+l+h;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(d-c)*p,this._y=(o-a)*p,this._z=(r-n)*p}else if(i>l&&i>h){const p=2*Math.sqrt(1+i-l-h);this._w=(d-c)/p,this._x=.25*p,this._y=(n+r)/p,this._z=(o+a)/p}else if(l>h){const p=2*Math.sqrt(1+l-i-h);this._w=(o-a)/p,this._x=(n+r)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+h-i-l);this._w=(r-n)/p,this._x=(o+a)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Qt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,o=t._z,r=t._w,l=e._x,c=e._y,a=e._z,d=e._w;return this._x=i*d+r*l+n*a-o*c,this._y=n*d+r*c+o*l-i*a,this._z=o*d+r*a+i*c-n*l,this._w=r*d-i*l-n*c-o*a,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,n=this._y,o=this._z,r=this._w;let l=r*t._w+i*t._x+n*t._y+o*t._z;if(l<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,l=-l):this.copy(t),l>=1)return this._w=r,this._x=i,this._y=n,this._z=o,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-e;return this._w=p*r+e*this._w,this._x=p*i+e*this._x,this._y=p*n+e*this._y,this._z=p*o+e*this._z,this.normalize(),this}const a=Math.sqrt(c),d=Math.atan2(a,l),h=Math.sin((1-e)*d)/a,u=Math.sin(e*d)/a;return this._w=r*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=o*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),o=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),o*Math.sin(e),o*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class M{constructor(t=0,e=0,i=0){this.isVector3=!0,M.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new M(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Fo.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Fo.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,o=t.elements;return this.x=o[0]*e+o[3]*i+o[6]*n,this.y=o[1]*e+o[4]*i+o[7]*n,this.z=o[2]*e+o[5]*i+o[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,o=t.elements,r=1/(o[3]*e+o[7]*i+o[11]*n+o[15]);return this.x=(o[0]*e+o[4]*i+o[8]*n+o[12])*r,this.y=(o[1]*e+o[5]*i+o[9]*n+o[13])*r,this.z=(o[2]*e+o[6]*i+o[10]*n+o[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,o=t.x,r=t.y,l=t.z,c=t.w,a=2*(r*n-l*i),d=2*(l*e-o*n),h=2*(o*i-r*e);return this.x=e+c*a+r*h-l*d,this.y=i+c*d+l*a-o*h,this.z=n+c*h+o*d-r*a,this}transformDirection(t){const e=this.x,i=this.y,n=this.z,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*n,this.y=o[1]*e+o[5]*i+o[9]*n,this.z=o[2]*e+o[6]*i+o[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,o=t.z,r=e.x,l=e.y,c=e.z;return this.x=n*c-o*l,this.y=o*r-i*c,this.z=i*l-n*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return dn.copy(this).projectOnVector(t),this.sub(dn)}reflect(t){return this.sub(dn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Qt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),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 dn=new M,Fo=new Q,ps=2e3,Qo=2001;class Jt{constructor(t,e,i,n,o,r,l,c,a,d,h,u,p,m,b,G){this.isMatrix4=!0,Jt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,o,r,l,c,a,d,h,u,p,m,b,G)}extractPosition(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)}multiplyToArray(t,e,i){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(t){return this.makeRotationFromQuaternion(t)}set(t,e,i,n,o,r,l,c,a,d,h,u,p,m,b,G){const y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=n,y[1]=o,y[5]=r,y[9]=l,y[13]=c,y[2]=a,y[6]=d,y[10]=h,y[14]=u,y[3]=p,y[7]=m,y[11]=b,y[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 Jt().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Ie.setFromMatrixColumn(t,0).length(),o=1/Ie.setFromMatrixColumn(t,1).length(),r=1/Ie.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*o,e[5]=i[5]*o,e[6]=i[6]*o,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,o=t.z,r=Math.cos(i),l=Math.sin(i),c=Math.cos(n),a=Math.sin(n),d=Math.cos(o),h=Math.sin(o);if(t.order==="XYZ"){const u=r*d,p=r*h,m=l*d,b=l*h;e[0]=c*d,e[4]=-c*h,e[8]=a,e[1]=p+m*a,e[5]=u-b*a,e[9]=-l*c,e[2]=b-u*a,e[6]=m+p*a,e[10]=r*c}else if(t.order==="YXZ"){const u=c*d,p=c*h,m=a*d,b=a*h;e[0]=u+b*l,e[4]=m*l-p,e[8]=r*a,e[1]=r*h,e[5]=r*d,e[9]=-l,e[2]=p*l-m,e[6]=b+u*l,e[10]=r*c}else if(t.order==="ZXY"){const u=c*d,p=c*h,m=a*d,b=a*h;e[0]=u-b*l,e[4]=-r*h,e[8]=m+p*l,e[1]=p+m*l,e[5]=r*d,e[9]=b-u*l,e[2]=-r*a,e[6]=l,e[10]=r*c}else if(t.order==="ZYX"){const u=r*d,p=r*h,m=l*d,b=l*h;e[0]=c*d,e[4]=m*a-p,e[8]=u*a+b,e[1]=c*h,e[5]=b*a+u,e[9]=p*a-m,e[2]=-a,e[6]=l*c,e[10]=r*c}else if(t.order==="YZX"){const u=r*c,p=r*a,m=l*c,b=l*a;e[0]=c*d,e[4]=b-u*h,e[8]=m*h+p,e[1]=h,e[5]=r*d,e[9]=-l*d,e[2]=-a*d,e[6]=p*h+m,e[10]=u-b*h}else if(t.order==="XZY"){const u=r*c,p=r*a,m=l*c,b=l*a;e[0]=c*d,e[4]=-h,e[8]=a*d,e[1]=u*h+b,e[5]=r*d,e[9]=p*h-m,e[2]=m*h-p,e[6]=l*d,e[10]=b*h+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ua,t,pa)}lookAt(t,e,i){const n=this.elements;return Wt.subVectors(t,e),Wt.lengthSq()===0&&(Wt.z=1),Wt.normalize(),re.crossVectors(i,Wt),re.lengthSq()===0&&(Math.abs(i.z)===1?Wt.x+=1e-4:Wt.z+=1e-4,Wt.normalize(),re.crossVectors(i,Wt)),re.normalize(),ms.crossVectors(Wt,re),n[0]=re.x,n[4]=ms.x,n[8]=Wt.x,n[1]=re.y,n[5]=ms.y,n[9]=Wt.y,n[2]=re.z,n[6]=ms.z,n[10]=Wt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,o=this.elements,r=i[0],l=i[4],c=i[8],a=i[12],d=i[1],h=i[5],u=i[9],p=i[13],m=i[2],b=i[6],G=i[10],y=i[14],Z=i[3],V=i[7],R=i[11],f=i[15],x=n[0],L=n[4],W=n[8],C=n[12],S=n[1],z=n[5],g=n[9],v=n[13],K=n[2],Y=n[6],H=n[10],I=n[14],P=n[3],D=n[7],it=n[11],tt=n[15];return o[0]=r*x+l*S+c*K+a*P,o[4]=r*L+l*z+c*Y+a*D,o[8]=r*W+l*g+c*H+a*it,o[12]=r*C+l*v+c*I+a*tt,o[1]=d*x+h*S+u*K+p*P,o[5]=d*L+h*z+u*Y+p*D,o[9]=d*W+h*g+u*H+p*it,o[13]=d*C+h*v+u*I+p*tt,o[2]=m*x+b*S+G*K+y*P,o[6]=m*L+b*z+G*Y+y*D,o[10]=m*W+b*g+G*H+y*it,o[14]=m*C+b*v+G*I+y*tt,o[3]=Z*x+V*S+R*K+f*P,o[7]=Z*L+V*z+R*Y+f*D,o[11]=Z*W+V*g+R*H+f*it,o[15]=Z*C+V*v+R*I+f*tt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],o=t[12],r=t[1],l=t[5],c=t[9],a=t[13],d=t[2],h=t[6],u=t[10],p=t[14],m=t[3],b=t[7],G=t[11],y=t[15];return m*(+o*c*h-n*a*h-o*l*u+i*a*u+n*l*p-i*c*p)+b*(+e*c*p-e*a*u+o*r*u-n*r*p+n*a*d-o*c*d)+G*(+e*a*h-e*l*p-o*r*h+i*r*p+o*l*d-i*a*d)+y*(-n*l*d-e*c*h+e*l*u+n*r*h-i*r*u+i*c*d)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],o=t[3],r=t[4],l=t[5],c=t[6],a=t[7],d=t[8],h=t[9],u=t[10],p=t[11],m=t[12],b=t[13],G=t[14],y=t[15],Z=h*G*a-b*u*a+b*c*p-l*G*p-h*c*y+l*u*y,V=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n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),o=1-i,r=t.x,l=t.y,c=t.z,a=o*r,d=o*l;return this.set(a*r+i,a*l-n*c,a*c+n*l,0,a*l+n*c,d*l+i,d*c-n*r,0,a*c-n*l,d*c+n*r,o*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,o,r){return this.set(1,i,o,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,o=e._x,r=e._y,l=e._z,c=e._w,a=o+o,d=r+r,h=l+l,u=o*a,p=o*d,m=o*h,b=r*d,G=r*h,y=l*h,Z=c*a,V=c*d,R=c*h,f=i.x,x=i.y,L=i.z;return n[0]=(1-(b+y))*f,n[1]=(p+R)*f,n[2]=(m-V)*f,n[3]=0,n[4]=(p-R)*x,n[5]=(1-(u+y))*x,n[6]=(G+Z)*x,n[7]=0,n[8]=(m+V)*L,n[9]=(G-Z)*L,n[10]=(1-(u+b))*L,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let o=Ie.set(n[0],n[1],n[2]).length();const r=Ie.set(n[4],n[5],n[6]).length(),l=Ie.set(n[8],n[9],n[10]).length();this.determinant()<0&&(o=-o),t.x=n[12],t.y=n[13],t.z=n[14],Ht.copy(this);const a=1/o,d=1/r,h=1/l;return Ht.elements[0]*=a,Ht.elements[1]*=a,Ht.elements[2]*=a,Ht.elements[4]*=d,Ht.elements[5]*=d,Ht.elements[6]*=d,Ht.elements[8]*=h,Ht.elements[9]*=h,Ht.elements[10]*=h,e.setFromRotationMatrix(Ht),i.x=o,i.y=r,i.z=l,this}makePerspective(t,e,i,n,o,r,l=ps){const c=this.elements,a=2*o/(e-t),d=2*o/(i-n),h=(e+t)/(e-t),u=(i+n)/(i-n);let p,m;if(l===ps)p=-(r+o)/(r-o),m=-2*r*o/(r-o);else if(l===Qo)p=-r/(r-o),m=-r*o/(r-o);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=a,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,i,n,o,r,l=ps){const c=this.elements,a=1/(e-t),d=1/(i-n),h=1/(r-o),u=(e+t)*a,p=(i+n)*d;let m,b;if(l===ps)m=(r+o)*h,b=-2*h;else if(l===Qo)m=o*h,b=-1*h;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*a,c[4]=0,c[8]=0,c[12]=-u,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=b,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Ie=new M,Ht=new Jt,ua=new M(0,0,0),pa=new M(1,1,1),re=new M,ms=new M,Wt=new M,wo=new Jt,Bo=new Q;class zi{constructor(t=0,e=0,i=0,n=zi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new zi(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,o=n[0],r=n[4],l=n[8],c=n[1],a=n[5],d=n[9],h=n[2],u=n[6],p=n[10];switch(e){case"XYZ":this._y=Math.asin(Qt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-r,o)):(this._x=Math.atan2(u,a),this._z=0);break;case"YXZ":this._x=Math.asin(-Qt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,a)):(this._y=Math.atan2(-h,o),this._z=0);break;case"ZXY":this._x=Math.asin(Qt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-r,a)):(this._y=0,this._z=Math.atan2(c,o));break;case"ZYX":this._y=Math.asin(-Qt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-r,a));break;case"YZX":this._z=Math.asin(Qt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,a),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Qt(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,a),this._y=Math.atan2(l,o)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return wo.makeRotationFromQuaternion(t),this.setFromRotationMatrix(wo,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Bo.setFromEuler(this),this.setFromQuaternion(Bo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(t){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}zi.DEFAULT_ORDER="XYZ";class De{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new De(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Qt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),o=this.x-t.x,r=this.y-t.y;return this.x=o*i-r*n+t.x,this.y=o*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}De.isVector2=!0;class Lt{constructor(t=0,e=0,i=0,n=1){Lt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new Lt(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,o=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*o,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*o,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*o,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*o,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,o;const c=t.elements,a=c[0],d=c[4],h=c[8],u=c[1],p=c[5],m=c[9],b=c[2],G=c[6],y=c[10];if(Math.abs(d-u)<.01&&Math.abs(h-b)<.01&&Math.abs(m-G)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+b)<.1&&Math.abs(m+G)<.1&&Math.abs(a+p+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const V=(a+1)/2,R=(p+1)/2,f=(y+1)/2,x=(d+u)/4,L=(h+b)/4,W=(m+G)/4;return V>R&&V>f?V<.01?(i=0,n=.707106781,o=.707106781):(i=Math.sqrt(V),n=x/i,o=L/i):R>f?R<.01?(i=.707106781,n=0,o=.707106781):(n=Math.sqrt(R),i=x/n,o=W/n):f<.01?(i=.707106781,n=.707106781,o=0):(o=Math.sqrt(f),i=L/o,n=W/o),this.set(i,n,o,e),this}let Z=Math.sqrt((G-m)*(G-m)+(h-b)*(h-b)+(u-d)*(u-d));return Math.abs(Z)<.001&&(Z=1),this.x=(G-m)/Z,this.y=(h-b)/Z,this.z=(u-d)/Z,this.w=Math.acos((a+p+y-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}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 Bt{constructor(t,e,i,n,o,r,l,c,a){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,o,r,l,c,a)}set(t,e,i,n,o,r,l,c,a){const d=this.elements;return d[0]=t,d[1]=n,d[2]=l,d[3]=e,d[4]=o,d[5]=c,d[6]=i,d[7]=r,d[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,o=this.elements,r=i[0],l=i[3],c=i[6],a=i[1],d=i[4],h=i[7],u=i[2],p=i[5],m=i[8],b=n[0],G=n[3],y=n[6],Z=n[1],V=n[4],R=n[7],f=n[2],x=n[5],L=n[8];return o[0]=r*b+l*Z+c*f,o[3]=r*G+l*V+c*x,o[6]=r*y+l*R+c*L,o[1]=a*b+d*Z+h*f,o[4]=a*G+d*V+h*x,o[7]=a*y+d*R+h*L,o[2]=u*b+p*Z+m*f,o[5]=u*G+p*V+m*x,o[8]=u*y+p*R+m*L,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],o=t[3],r=t[4],l=t[5],c=t[6],a=t[7],d=t[8];return e*r*d-e*l*a-i*o*d+i*l*c+n*o*a-n*r*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],o=t[3],r=t[4],l=t[5],c=t[6],a=t[7],d=t[8],h=d*r-l*a,u=l*c-d*o,p=a*o-r*c,m=e*h+i*u+n*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/m;return t[0]=h*b,t[1]=(n*a-d*i)*b,t[2]=(l*i-n*r)*b,t[3]=u*b,t[4]=(d*e-n*c)*b,t[5]=(n*o-l*e)*b,t[6]=p*b,t[7]=(i*c-a*e)*b,t[8]=(r*e-i*o)*b,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,o,r,l){const c=Math.cos(o),a=Math.sin(o);return this.set(i*c,i*a,-i*(c*r+a*l)+r+t,-n*a,n*c,-n*(-a*r+c*l)+l+e,0,0,1),this}scale(t,e){return this.premultiply(hn.makeScale(t,e)),this}rotate(t){return this.premultiply(hn.makeRotation(-t)),this}translate(t,e){return this.premultiply(hn.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new Bt().fromArray(this.elements)}}const hn=new Bt;var Xt;(function(s){s[s.Random=0]="Random",s[s.Loop=1]="Loop",s[s.PingPong=2]="PingPong",s[s.Burst=3]="Burst"})(Xt||(Xt={}));function ls(s,t,e,i){let n;switch(Xt.Random===s?t=Math.random():Xt.Burst===s&&i.isBursting&&(t=i.burstParticleIndex/i.burstParticleCount),e>0?n=Math.floor(t/e)*e:n=t,s){case Xt.Loop:n=n%1;break;case Xt.PingPong:n=Math.abs(n%2-1);break}return n}class Me{constructor(t,e,i,n){this.p=[t,e,i,n]}genValue(t){const e=t*t,i=t*t*t,n=1-t,o=n*n,r=o*n;return this.p[0]*r+this.p[1]*o*t*3+this.p[2]*n*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,n=i.length-1;n>0;n--){const o=[];for(let r=0;r<n;r++){const l=n*(i[r+1]-i[r]);o.push(l)}e.push(o),i=o}return e}getSlope(t){const e=this.derivativeCoefficients(this.p)[0],i=1-t,n=i*i,o=i*t*2,r=t*t;return n*e[0]+o*e[1]+r*e[2]}controlCurve(t,e){this.p[1]=t/3+this.p[0],this.p[2]=this.p[3]-e/3}hull(t){let e=this.p,i=[],n,o=0,r=0,l=0;const c=[];for(c[o++]=e[0],c[o++]=e[1],c[o++]=e[2],c[o++]=e[3];e.length>1;){for(i=[],r=0,l=e.length-1;r<l;r++)n=t*e[r]+(1-t)*e[r+1],c[o++]=n,i.push(n);e=i}return c}split(t){const e=this.hull(t);return{left:new Me(e[0],e[4],e[7],e[9]),right:new Me(e[9],e[8],e[6],e[3]),span:e}}clone(){return new Me(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(t){return new Me(t.p0,t.p1,t.p2,t.p3)}}const vi=s=>({r:s.x,g:s.y,b:s.z,a:s.w}),Ki=s=>new Lt(s.r,s.g,s.b,s.a),ma=(s,t)=>{switch(t){case"Vector3":return new M(s.x,s.y,s.z);case"Vector4":return new Lt(s.x,s.y,s.z,s.w);case"Color":return new M(s.r,s.g,s.b);case"Number":return s;default:return s}},ba=(s,t)=>{switch(t){case"Vector3":return{x:s.x,y:s.y,z:s.z};case"Vector4":return{x:s.x,y:s.y,z:s.z,w:s.w};case"Color":return{r:s.x,g:s.y,b:s.z};case"Number":return s;default:return s}};class ws{constructor(t,e){this.a=t,this.b=e,this.type="value"}startGen(t){}genColor(t,e){const i=Math.random();return e.copy(this.a).lerp(this.b,i)}toJSON(){return{type:"RandomColor",a:vi(this.a),b:vi(this.b)}}static fromJSON(t){return new ws(Ki(t.a),Ki(t.b))}clone(){return new ws(this.a.clone(),this.b.clone())}}class _e{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e){return this.indexCount===-1&&this.startGen(t),e.copy(this.a).lerp(this.b,t[this.indexCount])}toJSON(){return{type:"ColorRange",a:vi(this.a),b:vi(this.b)}}static fromJSON(t){return new _e(Ki(t.a),Ki(t.b))}clone(){return new _e(this.a.clone(),this.b.clone())}}class he{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,n=this.keys.length-1;for(;i+1<n;)if(e=Math.floor((i+n)/2),t<this.getStartX(e))n=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let o=i;o<=n;o++)if(t>=this.getStartX(o)&&t<=this.getEndX(o))return o;return-1}getStartX(t){return this.keys[t][1]}getEndX(t){return t+1<this.keys.length?this.keys[t+1][1]:1}genValue(t,e){const i=this.findKey(e);return this.subType==="Number"?i===-1?this.keys[0][0]:i+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[i+1][0]-this.keys[i][0])*((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))+this.keys[i][0]:i===-1?t.copy(this.keys[0][0]):i+1>=this.keys.length?t.copy(this.keys[this.keys.length-1][0]):t.copy(this.keys[i][0]).lerp(this.keys[i+1][0],(e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([t,e])=>({value:ba(t,this.subType),pos:e}))}}static fromJSON(t){return new he(t.keys.map(e=>[ma(e.value,t.subType),e.pos]),t.subType)}clone(){return this.subType==="Number"?new he(this.keys.map(([t,e])=>[t,e]),this.subType):new he(this.keys.map(([t,e])=>[t.clone(),e]),this.subType)}}const bs=new M;class Ye{constructor(t=[[new M(0,0,0),0],[new M(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new he(t,"Color"),this.alpha=new he(e,"Number")}genColor(t,e,i){return this.color.genValue(bs,i),e.set(bs.x,bs.y,bs.z,this.alpha.genValue(1,i))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(t){if(t.functions){const e=t.functions.map(i=>[_e.fromJSON(i.function).a,i.start]);return t.functions.length>0&&e.push([_e.fromJSON(t.functions[t.functions.length-1].function).b,1]),new Ye(e.map(i=>[new M(i[0].x,i[0].y,i[0].z),i[1]]),e.map(i=>[i[0].w,i[1]]))}else{const e=new Ye;return e.alpha=he.fromJSON(t.alpha),e.color=he.fromJSON(t.color),e}}clone(){const t=new Ye;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const un=new Lt;class Bs{constructor(t,e){this.indexCount=0,this.type="function",this.gradient1=t,this.gradient2=e}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e,i){return this.gradient1.genColor(t,e,i),this.gradient2.genColor(t,un,i),t&&t[this.indexCount]!==void 0?e.lerp(un,t[this.indexCount]):e.lerp(un,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new Bs(Ye.fromJSON(t.gradient1),Ye.fromJSON(t.gradient2))}clone(){return new Bs(this.gradient1.clone(),this.gradient2.clone())}}class ke{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:vi(this.color)}}static fromJSON(t){return new ke(Ki(t.color))}clone(){return new ke(this.color.clone())}}function oo(s){switch(s.type){case"ConstantColor":return ke.fromJSON(s);case"ColorRange":return _e.fromJSON(s);case"RandomColor":return ws.fromJSON(s);case"Gradient":return Ye.fromJSON(s);case"RandomColorBetweenGradient":return Bs.fromJSON(s);default:return new ke(new Lt(1,1,1,1))}}class J{constructor(t){this.value=t,this.type="value"}startGen(t){}genValue(t){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(t){return new J(t.value)}clone(){return new J(this.value)}}class He{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genValue(t){return this.indexCount===-1&&this.startGen(t),$e.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new He(t.a,t.b)}clone(){return new He(this.a,this.b)}}class ya{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,n=this.functions.length-1;for(;i+1<n;)if(e=Math.floor((i+n)/2),t<this.getStartX(e))n=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let o=i;o<=n;o++)if(t>=this.functions[o][1]&&t<=this.getEndX(o))return o;return-1}getStartX(t){return this.functions[t][1]}setStartX(t,e){t>0&&(this.functions[t][1]=e)}getEndX(t){return t+1<this.functions.length?this.functions[t+1][1]:1}setEndX(t,e){t+1<this.functions.length&&(this.functions[t+1][1]=e)}insertFunction(t,e){const i=this.findFunction(t);this.functions.splice(i+1,0,[e,t])}removeFunction(t){return this.functions.splice(t,1)[0][0]}getFunction(t){return this.functions[t][0]}setFunction(t,e){this.functions[t][0]=e}get numOfFunctions(){return this.functions.length}}class Ti extends ya{constructor(t=[[new Me(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=t}genValue(t,e=0){const i=this.findFunction(e);return i===-1?0:this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(t,e){if(e<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let n=1/e;n<=1;n+=1/e)i=[i,"L",n*t,this.genValue(void 0,n)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([t,e])=>({function:t.toJSON(),start:e}))}}static fromJSON(t){return new Ti(t.functions.map(e=>[Me.fromJSON(e.function),e.start]))}clone(){return new Ti(this.functions.map(([t,e])=>[t.clone(),e]))}startGen(t){}}function N(s){switch(s.type){case"ConstantValue":return J.fromJSON(s);case"IntervalValue":return He.fromJSON(s);case"PiecewiseBezier":return Ti.fromJSON(s);default:return new J(0)}}class Mi{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){this.indexCount=t.length,t.push(new Q);let e,i,n,o,r,l;do e=Math.random()*2-1,i=Math.random()*2-1,n=e*e+i*i;while(n>1);do o=Math.random()*2-1,r=Math.random()*2-1,l=o*o+r*r;while(l>1);const c=Math.sqrt((1-n)/l);t[this.indexCount].set(e,i,c*o,c*r)}genValue(t,e,i,n){return this.indexCount===-1&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new Mi}clone(){return new Mi}}class Yi{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,n){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,n)*i)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(t){return new Yi(new M(t.axis.x,t.axis.y,t.axis.z),N(t.angle))}clone(){return new Yi(this.axis.clone(),this.angle.clone())}}class Es{constructor(t,e,i,n){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new zi(0,0,0,n)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,n){return this.eular.set(this.angleX.genValue(t,n)*i,this.angleY.genValue(t,n)*i,this.angleZ.genValue(t,n)*i),e.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(t){return new Es(N(t.angleX),N(t.angleY),N(t.angleZ),t.eulerOrder)}clone(){return new Es(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function fc(s){switch(s.type){case"AxisAngle":return Yi.fromJSON(s);case"Euler":return Es.fromJSON(s);case"RandomQuat":return Mi.fromJSON(s);default:return new Mi}}class Ne{constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="vec3function"}startGen(t){this.x.startGen(t),this.y.startGen(t),this.z.startGen(t)}genValue(t,e,i){return e.set(this.x.genValue(t,i),this.y.genValue(t,i),this.z.genValue(t,i))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new Ne(N(t.x),N(t.y),N(t.z))}clone(){return new Ne(this.x,this.y,this.z)}}function Ga(s){switch(s.type){case"Vector3Function":return Ne.fromJSON(s);default:return new Ne(new J(0),new J(0),new J(0))}}function js(s){switch(s.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return N(s);case"AxisAngle":case"RandomQuat":case"Euler":return fc(s);case"Vector3Function":return Ga(s);default:return new J(0)}}class ki{constructor(t={}){var e,i,n,o,r,l,c;this.type="cone",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.angle=(o=t.angle)!==null&&o!==void 0?o:Math.PI/6,this.mode=(r=t.mode)!==null&&r!==void 0?r:Xt.Random,this.spread=(l=t.spread)!==null&&l!==void 0?l:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new J(1),this.memory=[]}update(t,e){Xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=ls(this.mode,this.currentValue,this.spread,e),n=$e.lerp(1-this.thickness,1,Math.random()),o=i*this.arc,r=Math.sqrt(n),l=Math.sin(o),c=Math.cos(o);t.position.x=r*c,t.position.y=r*l,t.position.z=0;const a=this.angle*r;t.velocity.set(0,0,Math.cos(a)).addScaledVector(t.position,Math.sin(a)).multiplyScalar(t.startSpeed),t.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(t){return new ki({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new ki({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Hi{constructor(t={}){var e,i,n,o,r,l;this.type="circle",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(o=t.mode)!==null&&o!==void 0?o:Xt.Random,this.spread=(r=t.spread)!==null&&r!==void 0?r:0,this.speed=(l=t.speed)!==null&&l!==void 0?l:new J(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=ls(this.mode,this.currentValue,this.spread,e),n=$e.lerp(1-this.thickness,1,Math.random()),o=i*this.arc;t.position.x=Math.cos(o),t.position.y=Math.sin(o),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*n)}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(t){return new Hi({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Hi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function ys(s,t){return Math.floor(Math.random()*(t-s))+s}const tn=new M(0,1,0),en=new M(0,0,0),Za=new M(1,1,1),Eo=new M(0,0,1);class Ni{constructor(t={}){var e,i,n,o,r,l,c;this.type="donut",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.donutRadius=(o=t.donutRadius)!==null&&o!==void 0?o:this.radius*.2,this.mode=(r=t.mode)!==null&&r!==void 0?r:Xt.Random,this.spread=(l=t.spread)!==null&&l!==void 0?l:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new J(1),this.memory=[],this._m1=new Jt}update(t,e){Xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=ls(this.mode,this.currentValue,this.spread,e),n=Math.random(),o=$e.lerp(1-this.thickness,1,Math.random()),r=i*this.arc,l=n*Math.PI*2,c=Math.sin(r),a=Math.cos(r);t.position.x=this.radius*a,t.position.y=this.radius*c,t.position.z=0,t.velocity.z=this.donutRadius*o*Math.sin(l),t.velocity.x=this.donutRadius*o*Math.cos(l)*a,t.velocity.y=this.donutRadius*o*Math.cos(l)*c,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof Q&&(this._m1.lookAt(en,t.velocity,tn),t.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(t){return new Ni({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Ni({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ii{constructor(){this.type="point",this._m1=new Jt}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),n=e*Math.PI*2,o=Math.acos(2*i-1),r=Math.cbrt(Math.random()),l=Math.sin(n),c=Math.cos(n),a=Math.sin(o),d=Math.cos(o);t.velocity.x=r*a*c,t.velocity.y=r*a*l,t.velocity.z=r*d,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0),t.rotation instanceof Q&&(this._m1.lookAt(en,t.position,tn),t.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(t){return new Ii}clone(){return new Ii}}class Ae{constructor(t={}){var e,i,n,o,r,l;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(o=t.mode)!==null&&o!==void 0?o:Xt.Random,this.spread=(r=t.spread)!==null&&r!==void 0?r:0,this.speed=(l=t.speed)!==null&&l!==void 0?l:new J(1),this.memory=[],this._m1=new Jt}update(t,e){Xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=ls(this.mode,this.currentValue,this.spread,e),n=Math.random(),o=$e.lerp(1-this.thickness,1,Math.random()),r=i*this.arc,l=Math.acos(2*n-1),c=Math.sin(r),a=Math.cos(r),d=Math.sin(l),h=Math.cos(l);t.position.x=d*a,t.position.y=d*c,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*o),t.rotation instanceof Q&&(this._m1.lookAt(en,t.position,tn),t.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(t){return new Ae({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Ae({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ji{constructor(t={}){var e,i,n,o,r,l;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(o=t.mode)!==null&&o!==void 0?o:Xt.Random,this.spread=(r=t.spread)!==null&&r!==void 0?r:0,this.speed=(l=t.speed)!==null&&l!==void 0?l:new J(1),this.memory=[],this._m1=new Jt}update(t,e){Xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=ls(this.mode,this.currentValue,this.spread,e),n=Math.random(),o=$e.lerp(1-this.thickness,1,Math.random()),r=i*this.arc,l=Math.acos(n),c=Math.sin(r),a=Math.cos(r),d=Math.sin(l),h=Math.cos(l);t.position.x=d*a,t.position.y=d*c,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*o),t.rotation instanceof Q&&(this._m1.lookAt(en,t.position,tn),t.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(t){return new Ji({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Ji({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ui{constructor(t={}){var e,i,n,o;this.type="grid",this.width=(e=t.width)!==null&&e!==void 0?e:1,this.height=(i=t.height)!==null&&i!==void 0?i:1,this.column=(n=t.column)!==null&&n!==void 0?n:10,this.row=(o=t.row)!==null&&o!==void 0?o:10}initialize(t){const e=Math.floor(Math.random()*this.row),i=Math.floor(Math.random()*this.column);t.position.x=i*this.width/this.column-this.width/2,t.position.y=e*this.height/this.row-this.height/2,t.position.z=0,t.velocity.set(0,0,t.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(t){return new Ui(t)}clone(){return new Ui({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}const Pn={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Hi,loadJSON:Hi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:ki,loadJSON:ki.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ni,loadJSON:Ni.fromJSON},point:{type:"point",params:[],constructor:Ii,loadJSON:Ii.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ae,loadJSON:Ae.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ji,loadJSON:Ji.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Ui,loadJSON:Ui.fromJSON}};function Xa(s,t){return Pn[s.type].loadJSON(s,t)}class Pi{constructor(t){this.color=t,this.type="ColorOverLife"}initialize(t){this.color.startGen(t.memory)}update(t,e){this.color.genColor(t.memory,t.color,t.age/t.life),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(t){return new Pi(oo(t.color))}clone(){return new Pi(this.color.clone())}reset(){}}class Fi{constructor(t){this.angularVelocity=t,this.type="RotationOverLife"}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){typeof t.rotation=="number"&&(t.rotation+=e*this.angularVelocity.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Fi(N(t.angularVelocity))}frameUpdate(t){}clone(){return new Fi(this.angularVelocity.clone())}reset(){}}class Qi{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new Q,this.tempQuat2=new Q}initialize(t){t.rotation instanceof Q&&(t.angularVelocity=new Q,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof Q&&(this.angularVelocity.genValue(t.memory,this.tempQuat,e,t.age/t.life),t.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Qi(fc(t.angularVelocity))}frameUpdate(t){}clone(){return new Qi(this.angularVelocity.clone())}reset(){}}class wi{initialize(t,e){this.ps=e,this.x.startGen(t.memory),this.y.startGen(t.memory),this.z.startGen(t.memory)}constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="ForceOverLife",this._temp=new M,this._tempScale=new M,this._tempQ=new Q}update(t,e){this._temp.set(this.x.genValue(t.memory,t.age/t.life),this.y.genValue(t.memory,t.age/t.life),this.z.genValue(t.memory,t.age/t.life)),this.ps.worldSpace?t.velocity.addScaledVector(this._temp,e):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),t.velocity.addScaledVector(this._temp,e))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new wi(N(t.x),N(t.y),N(t.z))}frameUpdate(t){if(this.ps&&!this.ps.worldSpace){const e=this._temp,i=this._tempQ,n=this._tempScale;this.ps.emitter.matrixWorld.decompose(e,i,n),i.invert(),n.set(1/n.x,1/n.y,1/n.z)}}clone(){return new wi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Bi{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof Ne?this.size.genValue(t.memory,t.size,t.age/t.life).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(t){return new Bi(js(t.size))}frameUpdate(t){}clone(){return new Bi(this.size.clone())}reset(){}}class Ei{initialize(t){this.speed.startGen(t.memory)}constructor(t){this.speed=t,this.type="SpeedOverLife"}update(t){t.speedModifier=this.speed.genValue(t.memory,t.age/t.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(t){return new Ei(N(t.speed))}frameUpdate(t){}clone(){return new Ei(this.speed.clone())}reset(){}}class ji{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof Ti&&(t.uvTile=this.frame.genValue(t.memory,t.age/t.life))}frameUpdate(t){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(t){return new ji(N(t.frame))}clone(){return new ji(this.frame.clone())}reset(){}}class Oi{constructor(t,e=new M(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new M,this.rotation=new Q}initialize(t){this.orbitSpeed.startGen(t.memory)}update(t,e){this.temp.copy(t.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(t.memory,t.age/t.life)*e),t.position.sub(this.temp),t.position.applyQuaternion(this.rotation),t.position.add(this.temp)}frameUpdate(t){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(t){return new Oi(N(t.orbitSpeed),t.axis?new M(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new Oi(this.orbitSpeed.clone())}reset(){}}class pn{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class fa{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 t=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}}pop(){if(this.tail){const t=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}}queue(t){const e=new pn(t);this.tail||(this.tail=e),this.head&&(this.head.prev=e,e.next=this.head),this.head=e,this.length++}push(t){const e=new pn(t);this.head||(this.head=e),this.tail&&(this.tail.next=e,e.prev=this.tail),this.tail=e,this.length++}insertBefore(t,e){const i=new pn(e);i.next=t,i.prev=t.prev,i.prev!==null&&(i.prev.next=i),i.next.prev=i,t==this.head&&(this.head=i),this.length++}remove(t){if(this.head===null||this.tail===null)return;let e=this.head;for(t===this.head.data&&(this.head=this.head.next),t===this.tail.data&&(this.tail=this.tail.prev);e.next!==null&&e.data!==t;)e=e.next;e.data===t&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.length--)}*values(){let t=this.head;for(;t!==null;)yield t.data,t=t.next}}class Va{constructor(){this.startSpeed=0,this.startColor=new Lt,this.startSize=new M(1,1,1),this.position=new M,this.velocity=new M,this.age=0,this.life=1,this.size=new M(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new Lt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class Ra{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class Os{constructor(){this.startSpeed=0,this.startColor=new Lt,this.startSize=new M(1,1,1),this.position=new M,this.velocity=new M,this.age=0,this.life=1,this.size=new M(1,1,1),this.length=100,this.speedModifier=1,this.color=new Lt,this.previous=new fa,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Ra(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 Di{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof Os){const e=t.previous.values();for(let i=0;i<t.previous.length;i++){const n=e.next();n.value.size=this.width.genValue(t.memory,(t.previous.length-i)/t.length)}}}frameUpdate(t){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(t){return new Di(N(t.width))}clone(){return new Di(this.width.clone())}reset(){}}class _i{constructor(t,e){this.direction=t,this.magnitude=e,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(t){}update(t,e){t.velocity.addScaledVector(this.direction,this.magnitudeValue*e)}frameUpdate(t){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(t){var e;return new _i(new M(t.direction[0],t.direction[1],t.direction[2]),N((e=t.magnitude)!==null&&e!==void 0?e:t.force))}clone(){return new _i(this.direction.clone(),this.magnitude.clone())}reset(){}}class Ai{constructor(t,e){this.center=t,this.magnitude=e,this.type="GravityForce",this.temp=new M}initialize(t){}update(t,e){this.temp.copy(this.center).sub(t.position).normalize(),t.velocity.addScaledVector(this.temp,this.magnitude/t.position.distanceToSquared(this.center)*e)}frameUpdate(t){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(t){return new Ai(new M(t.center[0],t.center[1],t.center[2]),t.magnitude)}clone(){return new Ai(this.center.clone(),this.magnitude)}reset(){}}class qi{constructor(t){this.angle=t,this.type="ChangeEmitDirection",this._temp=new M,this._q=new Q,this.memory={data:[],dataCount:0}}initialize(t){const e=t.velocity.length();e!=0&&(t.velocity.normalize(),t.velocity.x===0&&t.velocity.y===0?this._temp.set(0,t.velocity.z,0):this._temp.set(-t.velocity.y,t.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(t.velocity),t.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),t.velocity.applyQuaternion(this._q),t.velocity.setLength(e))}update(t,e){}frameUpdate(t){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(t){return new qi(N(t.angle))}clone(){return new qi(this.angle)}reset(){}}var je;(function(s){s[s.Death=0]="Death",s[s.Birth=1]="Birth",s[s.Frame=2]="Frame"})(je||(je={}));class $i{constructor(t,e,i,n=je.Frame,o=1){this.particleSystem=t,this.useVelocityAsBasis=e,this.subParticleSystem=i,this.mode=n,this.emitProbability=o,this.type="EmitSubParticleSystem",this.q_=new Q,this.v_=new M,this.v2_=new M,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(t){}update(t,e){this.mode===je.Frame?this.emit(t,e):this.mode===je.Birth&&t.age===0?this.emit(t,e):this.mode===je.Death&&t.age+e>=t.life&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const i=new Jt;this.setMatrixFromParticle(i,t),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:i,travelDistance:0,particle:t})}frameUpdate(t){if(this.subParticleSystem)for(let e=0;e<this.subEmissions.length;e++)if(this.subEmissions[e].time>=this.subParticleSystem.system.duration)this.subEmissions[e]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,e--;else{const i=this.subEmissions[e];i.particle&&i.particle.age<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(t,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(t,e){return new $i(e,t.useVelocityAsBasis,t.subParticleSystem,t.mode,t.emitProbability)}clone(){return new $i(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(t,e){let i;if(e.rotation===void 0||this.useVelocityAsBasis)if(e.velocity.x===0&&e.velocity.y===0&&(e.velocity.z===1||e.velocity.z===0))t.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1);else{this.v_.copy(Eo).cross(e.velocity),this.v2_.copy(e.velocity).cross(this.v_);const n=this.v_.length(),o=this.v2_.length();t.set(this.v_.x/n,this.v2_.x/o,e.velocity.x,e.position.x,this.v_.y/n,this.v2_.y/o,e.velocity.y,e.position.y,this.v_.z/n,this.v2_.z/o,e.velocity.z,e.position.z,0,0,0,1)}else e.rotation instanceof Q?i=e.rotation:(this.q_.setFromAxisAngle(Eo,e.rotation),i=this.q_),t.compose(e.position,i,Za);this.particleSystem.worldSpace||t.multiplyMatrices(this.particleSystem.emitter.matrixWorld,t)}}const xa=.5*(Math.sqrt(3)-1),ci=(3-Math.sqrt(3))/6,La=1/3,Pt=1/6,Sa=(Math.sqrt(5)-1)/4,rt=(5-Math.sqrt(5))/20,nt=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]),q=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 Vc{constructor(t=Math.random){const e=typeof t=="function"?t:ga(t);this.p=Wa(e),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let i=0;i<512;i++)this.perm[i]=this.p[i&255],this.permMod12[i]=this.perm[i]%12}noise2D(t,e){const i=this.permMod12,n=this.perm;let o=0,r=0,l=0;const c=(t+e)*xa,a=Math.floor(t+c),d=Math.floor(e+c),h=(a+d)*ci,u=a-h,p=d-h,m=t-u,b=e-p;let G,y;m>b?(G=1,y=0):(G=0,y=1);const Z=m-G+ci,V=b-y+ci,R=m-1+2*ci,f=b-1+2*ci,x=a&255,L=d&255;let W=.5-m*m-b*b;if(W>=0){const z=i[x+n[L]]*3;W*=W,o=W*W*(nt[z]*m+nt[z+1]*b)}let C=.5-Z*Z-V*V;if(C>=0){const z=i[x+G+n[L+y]]*3;C*=C,r=C*C*(nt[z]*Z+nt[z+1]*V)}let S=.5-R*R-f*f;if(S>=0){const z=i[x+1+n[L+1]]*3;S*=S,l=S*S*(nt[z]*R+nt[z+1]*f)}return 70*(o+r+l)}noise3D(t,e,i){const n=this.permMod12,o=this.perm;let r,l,c,a;const d=(t+e+i)*La,h=Math.floor(t+d),u=Math.floor(e+d),p=Math.floor(i+d),m=(h+u+p)*Pt,b=h-m,G=u-m,y=p-m,Z=t-b,V=e-G,R=i-y;let f,x,L,W,C,S;Z>=V?V>=R?(f=1,x=0,L=0,W=1,C=1,S=0):Z>=R?(f=1,x=0,L=0,W=1,C=0,S=1):(f=0,x=0,L=1,W=1,C=0,S=1):V<R?(f=0,x=0,L=1,W=0,C=1,S=1):Z<R?(f=0,x=1,L=0,W=0,C=1,S=1):(f=0,x=1,L=0,W=1,C=1,S=0);const z=Z-f+Pt,g=V-x+Pt,v=R-L+Pt,K=Z-W+2*Pt,Y=V-C+2*Pt,H=R-S+2*Pt,I=Z-1+3*Pt,P=V-1+3*Pt,D=R-1+3*Pt,it=h&255,tt=u&255,St=p&255;let Vt=.6-Z*Z-V*V-R*R;if(Vt<0)r=0;else{const j=n[it+o[tt+o[St]]]*3;Vt*=Vt,r=Vt*Vt*(nt[j]*Z+nt[j+1]*V+nt[j+2]*R)}let st=.6-z*z-g*g-v*v;if(st<0)l=0;else{const j=n[it+f+o[tt+x+o[St+L]]]*3;st*=st,l=st*st*(nt[j]*z+nt[j+1]*g+nt[j+2]*v)}let pt=.6-K*K-Y*Y-H*H;if(pt<0)c=0;else{const j=n[it+W+o[tt+C+o[St+S]]]*3;pt*=pt,c=pt*pt*(nt[j]*K+nt[j+1]*Y+nt[j+2]*H)}let et=.6-I*I-P*P-D*D;if(et<0)a=0;else{const j=n[it+1+o[tt+1+o[St+1]]]*3;et*=et,a=et*et*(nt[j]*I+nt[j+1]*P+nt[j+2]*D)}return 32*(r+l+c+a)}noise4D(t,e,i,n){const o=this.perm;let r,l,c,a,d;const h=(t+e+i+n)*Sa,u=Math.floor(t+h),p=Math.floor(e+h),m=Math.floor(i+h),b=Math.floor(n+h),G=(u+p+m+b)*rt,y=u-G,Z=p-G,V=m-G,R=b-G,f=t-y,x=e-Z,L=i-V,W=n-R;let C=0,S=0,z=0,g=0;f>x?C++:S++,f>L?C++:z++,f>W?C++:g++,x>L?S++:z++,x>W?S++:g++,L>W?z++:g++;const v=C>=3?1:0,K=S>=3?1:0,Y=z>=3?1:0,H=g>=3?1:0,I=C>=2?1:0,P=S>=2?1:0,D=z>=2?1:0,it=g>=2?1:0,tt=C>=1?1:0,St=S>=1?1:0,Vt=z>=1?1:0,st=g>=1?1:0,pt=f-v+rt,et=x-K+rt,j=L-Y+rt,oe=W-H+rt,_=f-I+2*rt,Ut=x-P+2*rt,jt=L-D+2*rt,ye=W-it+2*rt,Ge=f-tt+3*rt,Ze=x-St+3*rt,Xe=L-Vt+3*rt,fe=W-st+3*rt,Ve=f-1+4*rt,Re=x-1+4*rt,xe=L-1+4*rt,Le=W-1+4*rt,Ot=u&255,Dt=p&255,_t=m&255,At=b&255;let qt=.6-f*f-x*x-L*L-W*W;if(qt<0)r=0;else{const F=o[Ot+o[Dt+o[_t+o[At]]]]%32*4;qt*=qt,r=qt*qt*(q[F]*f+q[F+1]*x+q[F+2]*L+q[F+3]*W)}let Tt=.6-pt*pt-et*et-j*j-oe*oe;if(Tt<0)l=0;else{const F=o[Ot+v+o[Dt+K+o[_t+Y+o[At+H]]]]%32*4;Tt*=Tt,l=Tt*Tt*(q[F]*pt+q[F+1]*et+q[F+2]*j+q[F+3]*oe)}let Mt=.6-_*_-Ut*Ut-jt*jt-ye*ye;if(Mt<0)c=0;else{const F=o[Ot+I+o[Dt+P+o[_t+D+o[At+it]]]]%32*4;Mt*=Mt,c=Mt*Mt*(q[F]*_+q[F+1]*Ut+q[F+2]*jt+q[F+3]*ye)}let Yt=.6-Ge*Ge-Ze*Ze-Xe*Xe-fe*fe;if(Yt<0)a=0;else{const F=o[Ot+tt+o[Dt+St+o[_t+Vt+o[At+st]]]]%32*4;Yt*=Yt,a=Yt*Yt*(q[F]*Ge+q[F+1]*Ze+q[F+2]*Xe+q[F+3]*fe)}let kt=.6-Ve*Ve-Re*Re-xe*xe-Le*Le;if(kt<0)d=0;else{const F=o[Ot+1+o[Dt+1+o[_t+1+o[At+1]]]]%32*4;kt*=kt,d=kt*kt*(q[F]*Ve+q[F+1]*Re+q[F+2]*xe+q[F+3]*Le)}return 27*(r+l+c+a+d)}}function Wa(s){const t=new Uint8Array(256);for(let e=0;e<256;e++)t[e]=e;for(let e=0;e<255;e++){const i=e+~~(s()*(256-e)),n=t[e];t[e]=t[i],t[i]=n}return t}function ga(s){let t=0,e=0,i=0,n=1;const o=Ca();return t=o(" "),e=o(" "),i=o(" "),t-=o(s),t<0&&(t+=1),e-=o(s),e<0&&(e+=1),i-=o(s),i<0&&(i+=1),function(){const r=2091639*t+n*23283064365386963e-26;return t=e,e=i,i=r-(n=r|0)}}function Ca(){let s=4022871197;return function(t){t=t.toString();for(let e=0;e<t.length;e++){s+=t.charCodeAt(e);let i=.02519603282416938*s;s=i>>>0,i-=s,i*=s,s=i>>>0,i-=s,s+=i*4294967296}return(s>>>0)*23283064365386963e-26}}class ts{constructor(t,e,i,n){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=n,this.type="TurbulenceField",this.generator=new Vc,this.timeOffset=new M,this.temp=new M,this.temp2=new M,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(t){}update(t,e){const i=t.position.x/this.scale.x,n=t.position.y/this.scale.y,o=t.position.z/this.scale.z;this.temp.set(0,0,0);let r=1;for(let l=0;l<this.octaves;l++)this.temp2.set(this.generator.noise4D(i*r,n*r,o*r,this.timeOffset.x*r)/r,this.generator.noise4D(i*r,n*r,o*r,this.timeOffset.y*r)/r,this.generator.noise4D(i*r,n*r,o*r,this.timeOffset.z*r)/r),this.temp.add(this.temp2),r*=2;this.temp.multiply(this.velocityMultiplier),t.velocity.addScaledVector(this.temp,e)}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(t){this.timeOffset.x+=t*this.timeScale.x,this.timeOffset.y+=t*this.timeScale.y,this.timeOffset.z+=t*this.timeScale.z}static fromJSON(t){return new ts(new M(t.scale[0],t.scale[1],t.scale[2]),t.octaves,new M(t.velocityMultiplier[0],t.velocityMultiplier[1],t.velocityMultiplier[2]),new M(t.timeScale[0],t.timeScale[1],t.timeScale[2]))}clone(){return new ts(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Ft=[],mn=new M,bn=new Q;class es{constructor(t,e,i=new J(1),n=new J(0)){if(this.frequency=t,this.power=e,this.positionAmount=i,this.rotationAmount=n,this.type="Noise",this.duration=0,Ft.length===0)for(let o=0;o<100;o++)Ft.push(new Vc)}initialize(t){t.lastPosNoise=new M,typeof t.rotation=="number"?t.lastRotNoise=0:t.lastRotNoise=new Q,t.generatorIndex=[ys(0,100),ys(0,100),ys(0,100),ys(0,100)],this.positionAmount.startGen(t.memory),this.rotationAmount.startGen(t.memory),this.frequency.startGen(t.memory),this.power.startGen(t.memory)}update(t,e){let i=this.frequency.genValue(t.memory,t.age/t.life),n=this.power.genValue(t.memory,t.age/t.life),o=this.positionAmount.genValue(t.memory,t.age/t.life),r=this.rotationAmount.genValue(t.memory,t.age/t.life);o>0&&t.lastPosNoise!==void 0&&(t.position.sub(t.lastPosNoise),mn.set(Ft[t.generatorIndex[0]].noise2D(0,t.age*i)*n*o,Ft[t.generatorIndex[1]].noise2D(0,t.age*i)*n*o,Ft[t.generatorIndex[2]].noise2D(0,t.age*i)*n*o),t.position.add(mn),t.lastPosNoise.copy(mn)),r>0&&t.lastRotNoise!==void 0&&(typeof t.rotation=="number"?(t.rotation-=t.lastRotNoise,t.rotation+=Ft[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*n*r):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),bn.set(Ft[t.generatorIndex[0]].noise2D(0,t.age*i)*n*r,Ft[t.generatorIndex[1]].noise2D(0,t.age*i)*n*r,Ft[t.generatorIndex[2]].noise2D(0,t.age*i)*n*r,Ft[t.generatorIndex[3]].noise2D(0,t.age*i)*n*r).normalize(),t.rotation.multiply(bn),t.lastRotNoise.copy(bn)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(t){this.duration+=t}static fromJSON(t){return new es(N(t.frequency),N(t.power),N(t.positionAmount),N(t.rotationAmount))}clone(){return new es(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class is{constructor(t,e){this.color=t,this.speedRange=e,this.type="ColorBySpeed"}initialize(t){this.color.startGen(t.memory)}update(t,e){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(t.memory,t.color,i),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new is(oo(t.color),He.fromJSON(t.speedRange))}clone(){return new is(this.color.clone(),this.speedRange.clone())}reset(){}}class ss{initialize(t){this.size.startGen(t.memory)}constructor(t,e){this.size=t,this.speedRange=e,this.type="SizeBySpeed"}update(t){const e=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof Ne?this.size.genValue(t.memory,t.size,e).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,e))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new ss(js(t.size),He.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new ss(this.size.clone(),this.speedRange.clone())}reset(){}}class ns{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new Q}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){if(typeof t.rotation=="number"){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);t.rotation+=e*this.angularVelocity.genValue(t.memory,i)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new ns(N(t.angularVelocity),He.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new ns(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class os{initialize(t){this.speed.startGen(t.memory)}constructor(t,e){this.speed=t,this.dampen=e,this.type="LimitSpeedOverLife"}update(t,e){let i=t.velocity.length(),n=this.speed.genValue(t.memory,t.age/t.life);if(i>n){const o=(i-n)/i;t.velocity.multiplyScalar(1-o*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new os(N(t.speed),t.dampen)}frameUpdate(t){}clone(){return new os(this.speed.clone(),this.dampen)}reset(){}}const Ds={ApplyForce:{type:"ApplyForce",constructor:_i,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:_i.fromJSON},Noise:{type:"Noise",constructor:es,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:es.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:ts,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:ts.fromJSON},GravityForce:{type:"GravityForce",constructor:Ai,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Ai.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Pi,params:[["color",["colorFunc"]]],loadJSON:Pi.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Fi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Fi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Qi,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Qi.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Bi,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Bi.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:is,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:is.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:ns,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:ns.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:ss,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:ss.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Ei,params:[["speed",["value","valueFunc"]]],loadJSON:Ei.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:ji,params:[["frame",["value","valueFunc"]]],loadJSON:ji.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:wi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:wi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Oi,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Oi.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Di,params:[["width",["value","valueFunc"]]],loadJSON:Di.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:qi,params:[["angle",["value"]]],loadJSON:qi.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:$i,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:$i.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:os,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:os.fromJSON}};function za(s,t){return Ds[s.type]?Ds[s.type].loadJSON(s,t):null}const va=[];function Ka(s){if(!va.find(e=>e.id===s.id)){s.initialize();for(const e of s.emitterShapes)Pn[e.type]||(Pn[e.type]=e);for(const e of s.behaviors)Ds[e.type]||(Ds[e.type]=e)}}var Ta=`
|
|
83
|
+
*/var Vc=function(r){return r!=null&&(pa(r)||Jc(r)||!!r._isBuffer)};function pa(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Jc(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&pa(r.slice(0,0))}(function(){var r=Lc,t=Fs.utf8,e=Vc,i=Fs.bin,n=function(s,o){s.constructor==String?o&&o.encoding==="binary"?s=i.stringToBytes(s):s=t.stringToBytes(s):e(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var c=r.bytesToWords(s),a=s.length*8,l=1732584193,u=-271733879,h=-1732584194,f=271733878,d=0;d<c.length;d++)c[d]=(c[d]<<8|c[d]>>>24)&16711935|(c[d]<<24|c[d]>>>8)&4278255360;c[a>>>5]|=128<<a%32,c[(a+64>>>9<<4)+14]=a;for(var p=n._ff,m=n._gg,g=n._hh,y=n._ii,d=0;d<c.length;d+=16){var v=l,b=u,S=h,_=f;l=p(l,u,h,f,c[d+0],7,-680876936),f=p(f,l,u,h,c[d+1],12,-389564586),h=p(h,f,l,u,c[d+2],17,606105819),u=p(u,h,f,l,c[d+3],22,-1044525330),l=p(l,u,h,f,c[d+4],7,-176418897),f=p(f,l,u,h,c[d+5],12,1200080426),h=p(h,f,l,u,c[d+6],17,-1473231341),u=p(u,h,f,l,c[d+7],22,-45705983),l=p(l,u,h,f,c[d+8],7,1770035416),f=p(f,l,u,h,c[d+9],12,-1958414417),h=p(h,f,l,u,c[d+10],17,-42063),u=p(u,h,f,l,c[d+11],22,-1990404162),l=p(l,u,h,f,c[d+12],7,1804603682),f=p(f,l,u,h,c[d+13],12,-40341101),h=p(h,f,l,u,c[d+14],17,-1502002290),u=p(u,h,f,l,c[d+15],22,1236535329),l=m(l,u,h,f,c[d+1],5,-165796510),f=m(f,l,u,h,c[d+6],9,-1069501632),h=m(h,f,l,u,c[d+11],14,643717713),u=m(u,h,f,l,c[d+0],20,-373897302),l=m(l,u,h,f,c[d+5],5,-701558691),f=m(f,l,u,h,c[d+10],9,38016083),h=m(h,f,l,u,c[d+15],14,-660478335),u=m(u,h,f,l,c[d+4],20,-405537848),l=m(l,u,h,f,c[d+9],5,568446438),f=m(f,l,u,h,c[d+14],9,-1019803690),h=m(h,f,l,u,c[d+3],14,-187363961),u=m(u,h,f,l,c[d+8],20,1163531501),l=m(l,u,h,f,c[d+13],5,-1444681467),f=m(f,l,u,h,c[d+2],9,-51403784),h=m(h,f,l,u,c[d+7],14,1735328473),u=m(u,h,f,l,c[d+12],20,-1926607734),l=g(l,u,h,f,c[d+5],4,-378558),f=g(f,l,u,h,c[d+8],11,-2022574463),h=g(h,f,l,u,c[d+11],16,1839030562),u=g(u,h,f,l,c[d+14],23,-35309556),l=g(l,u,h,f,c[d+1],4,-1530992060),f=g(f,l,u,h,c[d+4],11,1272893353),h=g(h,f,l,u,c[d+7],16,-155497632),u=g(u,h,f,l,c[d+10],23,-1094730640),l=g(l,u,h,f,c[d+13],4,681279174),f=g(f,l,u,h,c[d+0],11,-358537222),h=g(h,f,l,u,c[d+3],16,-722521979),u=g(u,h,f,l,c[d+6],23,76029189),l=g(l,u,h,f,c[d+9],4,-640364487),f=g(f,l,u,h,c[d+12],11,-421815835),h=g(h,f,l,u,c[d+15],16,530742520),u=g(u,h,f,l,c[d+2],23,-995338651),l=y(l,u,h,f,c[d+0],6,-198630844),f=y(f,l,u,h,c[d+7],10,1126891415),h=y(h,f,l,u,c[d+14],15,-1416354905),u=y(u,h,f,l,c[d+5],21,-57434055),l=y(l,u,h,f,c[d+12],6,1700485571),f=y(f,l,u,h,c[d+3],10,-1894986606),h=y(h,f,l,u,c[d+10],15,-1051523),u=y(u,h,f,l,c[d+1],21,-2054922799),l=y(l,u,h,f,c[d+8],6,1873313359),f=y(f,l,u,h,c[d+15],10,-30611744),h=y(h,f,l,u,c[d+6],15,-1560198380),u=y(u,h,f,l,c[d+13],21,1309151649),l=y(l,u,h,f,c[d+4],6,-145523070),f=y(f,l,u,h,c[d+11],10,-1120210379),h=y(h,f,l,u,c[d+2],15,718787259),u=y(u,h,f,l,c[d+9],21,-343485551),l=l+v>>>0,u=u+b>>>0,h=h+S>>>0,f=f+_>>>0}return r.endian([l,u,h,f])};n._ff=function(s,o,c,a,l,u,h){var f=s+(o&c|~o&a)+(l>>>0)+h;return(f<<u|f>>>32-u)+o},n._gg=function(s,o,c,a,l,u,h){var f=s+(o&a|c&~a)+(l>>>0)+h;return(f<<u|f>>>32-u)+o},n._hh=function(s,o,c,a,l,u,h){var f=s+(o^c^a)+(l>>>0)+h;return(f<<u|f>>>32-u)+o},n._ii=function(s,o,c,a,l,u,h){var f=s+(c^(o|~a))+(l>>>0)+h;return(f<<u|f>>>32-u)+o},n._blocksize=16,n._digestsize=16,fa.exports=function(s,o){if(s==null)throw new Error("Illegal argument "+s);var c=r.wordsToBytes(n(s,o));return o&&o.asBytes?c:o&&o.asString?i.bytesToString(c):r.bytesToHex(c)}})();var Gc=fa.exports;const jc=Qr(Gc),mt=["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 Ls=1234567;const ma=Math.PI/180,ya=180/Math.PI;function $c(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(mt[r&255]+mt[r>>8&255]+mt[r>>16&255]+mt[r>>24&255]+"-"+mt[t&255]+mt[t>>8&255]+"-"+mt[t>>16&15|64]+mt[t>>24&255]+"-"+mt[e&63|128]+mt[e>>8&255]+"-"+mt[e>>16&255]+mt[e>>24&255]+mt[i&255]+mt[i>>8&255]+mt[i>>16&255]+mt[i>>24&255]).toLowerCase()}function Gt(r,t,e){return Math.max(t,Math.min(e,r))}function ga(r,t){return(r%t+t)%t}function Hc(r,t,e,i,n){return i+(r-t)*(n-i)/(e-t)}function qc(r,t,e){return r!==t?(e-r)/(t-r):0}function va(r,t,e){return(1-e)*r+e*t}function Xc(r,t,e,i){return va(r,t,1-Math.exp(-e*i))}function Wc(r,t=1){return t-Math.abs(ga(r,t*2)-t)}function Yc(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Zc(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Qc(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Kc(r,t){return r+Math.random()*(t-r)}function tl(r){return r*(.5-Math.random())}function el(r){r!==void 0&&(Ls=r);let t=Ls+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function il(r){return r*ma}function rl(r){return r*ya}function nl(r){return(r&r-1)===0&&r!==0}function sl(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ol(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function al(r,t,e,i,n){const s=Math.cos,o=Math.sin,c=s(e/2),a=o(e/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),f=o((t-i)/2),d=s((i-t)/2),p=o((i-t)/2);switch(n){case"XYX":r.set(c*u,a*h,a*f,c*l);break;case"YZY":r.set(a*f,c*u,a*h,c*l);break;case"ZXZ":r.set(a*h,a*f,c*u,c*l);break;case"XZX":r.set(c*u,a*p,a*d,c*l);break;case"YXY":r.set(a*d,c*u,a*p,c*l);break;case"ZYZ":r.set(a*p,a*d,c*u,c*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function cl(r,t){switch(t.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 ll(r,t){switch(t.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 Ke={DEG2RAD:ma,RAD2DEG:ya,generateUUID:$c,clamp:Gt,euclideanModulo:ga,mapLinear:Hc,inverseLerp:qc,lerp:va,damp:Xc,pingpong:Wc,smoothstep:Yc,smootherstep:Zc,randInt:Qc,randFloat:Kc,randFloatSpread:tl,seededRandom:el,degToRad:il,radToDeg:rl,isPowerOfTwo:nl,ceilPowerOfTwo:sl,floorPowerOfTwo:ol,setQuaternionFromProperEuler:al,normalize:ll,denormalize:cl};class G{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,o,c){let a=i[n+0],l=i[n+1],u=i[n+2],h=i[n+3];const f=s[o+0],d=s[o+1],p=s[o+2],m=s[o+3];if(c===0){t[e+0]=a,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(c===1){t[e+0]=f,t[e+1]=d,t[e+2]=p,t[e+3]=m;return}if(h!==m||a!==f||l!==d||u!==p){let g=1-c;const y=a*f+l*d+u*p+h*m,v=y>=0?1:-1,b=1-y*y;if(b>Number.EPSILON){const _=Math.sqrt(b),T=Math.atan2(_,y*v);g=Math.sin(g*T)/_,c=Math.sin(c*T)/_}const S=c*v;if(a=a*g+f*S,l=l*g+d*S,u=u*g+p*S,h=h*g+m*S,g===1-c){const _=1/Math.sqrt(a*a+l*l+u*u+h*h);a*=_,l*=_,u*=_,h*=_}}t[e]=a,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,n,s,o){const c=i[n],a=i[n+1],l=i[n+2],u=i[n+3],h=s[o],f=s[o+1],d=s[o+2],p=s[o+3];return t[e]=c*p+u*h+a*d-l*f,t[e+1]=a*p+u*f+l*h-c*d,t[e+2]=l*p+u*d+c*f-a*h,t[e+3]=u*p-c*h-a*f-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new G(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,s=t._z,o=t._order,c=Math.cos,a=Math.sin,l=c(i/2),u=c(n/2),h=c(s/2),f=a(i/2),d=a(n/2),p=a(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"YZX":this._x=f*u*h+l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h-f*d*p;break;case"XZY":this._x=f*u*h-l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h+f*d*p;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],o=e[1],c=e[5],a=e[9],l=e[2],u=e[6],h=e[10],f=i+c+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-a)*d,this._y=(s-l)*d,this._z=(o-n)*d}else if(i>c&&i>h){const d=2*Math.sqrt(1+i-c-h);this._w=(u-a)/d,this._x=.25*d,this._y=(n+o)/d,this._z=(s+l)/d}else if(c>h){const d=2*Math.sqrt(1+c-i-h);this._w=(s-l)/d,this._x=(n+o)/d,this._y=.25*d,this._z=(a+u)/d}else{const d=2*Math.sqrt(1+h-i-c);this._w=(o-n)/d,this._x=(s+l)/d,this._y=(a+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,o=t._w,c=e._x,a=e._y,l=e._z,u=e._w;return this._x=i*u+o*c+n*l-s*a,this._y=n*u+o*a+s*c-i*l,this._z=s*u+o*l+i*a-n*c,this._w=o*u-i*c-n*a-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,n=this._y,s=this._z,o=this._w;let c=o*t._w+i*t._x+n*t._y+s*t._z;if(c<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,c=-c):this.copy(t),c>=1)return this._w=o,this._x=i,this._y=n,this._z=s,this;const a=1-c*c;if(a<=Number.EPSILON){const d=1-e;return this._w=d*o+e*this._w,this._x=d*i+e*this._x,this._y=d*n+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(a),u=Math.atan2(l,c),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=i*h+this._x*f,this._y=n*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class z{constructor(t=0,e=0,i=0){this.isVector3=!0,z.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new z(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Vs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Vs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*o,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,o=t.y,c=t.z,a=t.w,l=2*(o*n-c*i),u=2*(c*e-s*n),h=2*(s*i-o*e);return this.x=e+a*l+o*h-c*u,this.y=i+a*u+c*l-s*h,this.z=n+a*h+s*u-o*l,this}transformDirection(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,o=e.x,c=e.y,a=e.z;return this.x=n*a-s*c,this.y=s*o-i*a,this.z=i*c-n*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return un.copy(this).projectOnVector(t),this.sub(un)}reflect(t){return this.sub(un.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),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 un=new z,Vs=new G,dr=2e3,Js=2001;class Ft{constructor(t,e,i,n,s,o,c,a,l,u,h,f,d,p,m,g){this.isMatrix4=!0,Ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,o,c,a,l,u,h,f,d,p,m,g)}extractPosition(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)}multiplyToArray(t,e,i){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(t){return this.makeRotationFromQuaternion(t)}set(t,e,i,n,s,o,c,a,l,u,h,f,d,p,m,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=n,y[1]=s,y[5]=o,y[9]=c,y[13]=a,y[2]=l,y[6]=u,y[10]=h,y[14]=f,y[3]=d,y[7]=p,y[11]=m,y[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 Ft().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/De.setFromMatrixColumn(t,0).length(),s=1/De.setFromMatrixColumn(t,1).length(),o=1/De.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,o=Math.cos(i),c=Math.sin(i),a=Math.cos(n),l=Math.sin(n),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){const f=o*u,d=o*h,p=c*u,m=c*h;e[0]=a*u,e[4]=-a*h,e[8]=l,e[1]=d+p*l,e[5]=f-m*l,e[9]=-c*a,e[2]=m-f*l,e[6]=p+d*l,e[10]=o*a}else if(t.order==="YXZ"){const f=a*u,d=a*h,p=l*u,m=l*h;e[0]=f+m*c,e[4]=p*c-d,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-c,e[2]=d*c-p,e[6]=m+f*c,e[10]=o*a}else if(t.order==="ZXY"){const f=a*u,d=a*h,p=l*u,m=l*h;e[0]=f-m*c,e[4]=-o*h,e[8]=p+d*c,e[1]=d+p*c,e[5]=o*u,e[9]=m-f*c,e[2]=-o*l,e[6]=c,e[10]=o*a}else if(t.order==="ZYX"){const f=o*u,d=o*h,p=c*u,m=c*h;e[0]=a*u,e[4]=p*l-d,e[8]=f*l+m,e[1]=a*h,e[5]=m*l+f,e[9]=d*l-p,e[2]=-l,e[6]=c*a,e[10]=o*a}else if(t.order==="YZX"){const f=o*a,d=o*l,p=c*a,m=c*l;e[0]=a*u,e[4]=m-f*h,e[8]=p*h+d,e[1]=h,e[5]=o*u,e[9]=-c*u,e[2]=-l*u,e[6]=d*h+p,e[10]=f-m*h}else if(t.order==="XZY"){const f=o*a,d=o*l,p=c*a,m=c*l;e[0]=a*u,e[4]=-h,e[8]=l*u,e[1]=f*h+m,e[5]=o*u,e[9]=d*h-p,e[2]=p*h-d,e[6]=c*u,e[10]=m*h+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ul,t,hl)}lookAt(t,e,i){const n=this.elements;return wt.subVectors(t,e),wt.lengthSq()===0&&(wt.z=1),wt.normalize(),oe.crossVectors(i,wt),oe.lengthSq()===0&&(Math.abs(i.z)===1?wt.x+=1e-4:wt.z+=1e-4,wt.normalize(),oe.crossVectors(i,wt)),oe.normalize(),pr.crossVectors(wt,oe),n[0]=oe.x,n[4]=pr.x,n[8]=wt.x,n[1]=oe.y,n[5]=pr.y,n[9]=wt.y,n[2]=oe.z,n[6]=pr.z,n[10]=wt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,o=i[0],c=i[4],a=i[8],l=i[12],u=i[1],h=i[5],f=i[9],d=i[13],p=i[2],m=i[6],g=i[10],y=i[14],v=i[3],b=i[7],S=i[11],_=i[15],T=n[0],M=n[4],w=n[8],E=n[12],C=n[1],A=n[5],P=n[9],R=n[13],k=n[2],O=n[6],N=n[10],D=n[14],V=n[3],W=n[7],it=n[11],tt=n[15];return s[0]=o*T+c*C+a*k+l*V,s[4]=o*M+c*A+a*O+l*W,s[8]=o*w+c*P+a*N+l*it,s[12]=o*E+c*R+a*D+l*tt,s[1]=u*T+h*C+f*k+d*V,s[5]=u*M+h*A+f*O+d*W,s[9]=u*w+h*P+f*N+d*it,s[13]=u*E+h*R+f*D+d*tt,s[2]=p*T+m*C+g*k+y*V,s[6]=p*M+m*A+g*O+y*W,s[10]=p*w+m*P+g*N+y*it,s[14]=p*E+m*R+g*D+y*tt,s[3]=v*T+b*C+S*k+_*V,s[7]=v*M+b*A+S*O+_*W,s[11]=v*w+b*P+S*N+_*it,s[15]=v*E+b*R+S*D+_*tt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[12],o=t[1],c=t[5],a=t[9],l=t[13],u=t[2],h=t[6],f=t[10],d=t[14],p=t[3],m=t[7],g=t[11],y=t[15];return p*(+s*a*h-n*l*h-s*c*f+i*l*f+n*c*d-i*a*d)+m*(+e*a*d-e*l*f+s*o*f-n*o*d+n*l*u-s*a*u)+g*(+e*l*h-e*c*d-s*o*h+i*o*d+s*c*u-i*l*u)+y*(-n*c*u-e*a*h+e*c*f+n*o*h-i*o*f+i*a*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],c=t[5],a=t[6],l=t[7],u=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],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],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,o=t.x,c=t.y,a=t.z,l=s*o,u=s*c;return this.set(l*o+i,l*c-n*a,l*a+n*c,0,l*c+n*a,u*c+i,u*a-n*o,0,l*a-n*c,u*a+n*o,s*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,o){return this.set(1,i,s,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,o=e._y,c=e._z,a=e._w,l=s+s,u=o+o,h=c+c,f=s*l,d=s*u,p=s*h,m=o*u,g=o*h,y=c*h,v=a*l,b=a*u,S=a*h,_=i.x,T=i.y,M=i.z;return n[0]=(1-(m+y))*_,n[1]=(d+S)*_,n[2]=(p-b)*_,n[3]=0,n[4]=(d-S)*T,n[5]=(1-(f+y))*T,n[6]=(g+v)*T,n[7]=0,n[8]=(p+b)*M,n[9]=(g-v)*M,n[10]=(1-(f+m))*M,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let s=De.set(n[0],n[1],n[2]).length();const o=De.set(n[4],n[5],n[6]).length(),c=De.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],Nt.copy(this);const l=1/s,u=1/o,h=1/c;return Nt.elements[0]*=l,Nt.elements[1]*=l,Nt.elements[2]*=l,Nt.elements[4]*=u,Nt.elements[5]*=u,Nt.elements[6]*=u,Nt.elements[8]*=h,Nt.elements[9]*=h,Nt.elements[10]*=h,e.setFromRotationMatrix(Nt),i.x=s,i.y=o,i.z=c,this}makePerspective(t,e,i,n,s,o,c=dr){const a=this.elements,l=2*s/(e-t),u=2*s/(i-n),h=(e+t)/(e-t),f=(i+n)/(i-n);let d,p;if(c===dr)d=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(c===Js)d=-o/(o-s),p=-o*s/(o-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+c);return a[0]=l,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=u,a[9]=f,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,n,s,o,c=dr){const a=this.elements,l=1/(e-t),u=1/(i-n),h=1/(o-s),f=(e+t)*l,d=(i+n)*u;let p,m;if(c===dr)p=(o+s)*h,m=-2*h;else if(c===Js)p=s*h,m=-1*h;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-f,a[1]=0,a[5]=2*u,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=m,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const De=new z,Nt=new Ft,ul=new z(0,0,0),hl=new z(1,1,1),oe=new z,pr=new z,wt=new z,Gs=new Ft,js=new G;class Ai{constructor(t=0,e=0,i=0,n=Ai.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new Ai(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,s=n[0],o=n[4],c=n[8],a=n[1],l=n[5],u=n[9],h=n[2],f=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(c,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,s));break;case"ZYX":this._y=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(a,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(c,d));break;case"XZY":this._z=Math.asin(-Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(c,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Gs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Gs,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return js.setFromEuler(this),this.setFromQuaternion(js,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(t){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ai.DEFAULT_ORDER="XYZ";class We{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new We(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*i-o*n+t.x,this.y=s*n+o*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}We.isVector2=!0;class Mt{constructor(t=0,e=0,i=0,n=1){Mt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new Mt(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*n+o[12]*s,this.y=o[1]*e+o[5]*i+o[9]*n+o[13]*s,this.z=o[2]*e+o[6]*i+o[10]*n+o[14]*s,this.w=o[3]*e+o[7]*i+o[11]*n+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,s;const a=t.elements,l=a[0],u=a[4],h=a[8],f=a[1],d=a[5],p=a[9],m=a[2],g=a[6],y=a[10];if(Math.abs(u-f)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const b=(l+1)/2,S=(d+1)/2,_=(y+1)/2,T=(u+f)/4,M=(h+m)/4,w=(p+g)/4;return b>S&&b>_?b<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(b),n=T/i,s=M/i):S>_?S<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(S),i=T/n,s=w/n):_<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(_),i=M/s,n=w/s),this.set(i,n,s,e),this}let v=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(f-u)*(f-u));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(h-m)/v,this.z=(f-u)/v,this.w=Math.acos((l+d+y-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}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 $t{constructor(t,e,i,n,s,o,c,a,l){$t.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,o,c,a,l)}set(t,e,i,n,s,o,c,a,l){const u=this.elements;return u[0]=t,u[1]=n,u[2]=c,u[3]=e,u[4]=s,u[5]=a,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,o=i[0],c=i[3],a=i[6],l=i[1],u=i[4],h=i[7],f=i[2],d=i[5],p=i[8],m=n[0],g=n[3],y=n[6],v=n[1],b=n[4],S=n[7],_=n[2],T=n[5],M=n[8];return s[0]=o*m+c*v+a*_,s[3]=o*g+c*b+a*T,s[6]=o*y+c*S+a*M,s[1]=l*m+u*v+h*_,s[4]=l*g+u*b+h*T,s[7]=l*y+u*S+h*M,s[2]=f*m+d*v+p*_,s[5]=f*g+d*b+p*T,s[8]=f*y+d*S+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],c=t[5],a=t[6],l=t[7],u=t[8];return e*o*u-e*c*l-i*s*u+i*c*a+n*s*l-n*o*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],c=t[5],a=t[6],l=t[7],u=t[8],h=u*o-c*l,f=c*a-u*s,d=l*s-o*a,p=e*h+i*f+n*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(n*l-u*i)*m,t[2]=(c*i-n*o)*m,t[3]=f*m,t[4]=(u*e-n*a)*m,t[5]=(n*s-c*e)*m,t[6]=d*m,t[7]=(i*a-l*e)*m,t[8]=(o*e-i*s)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,s,o,c){const a=Math.cos(s),l=Math.sin(s);return this.set(i*a,i*l,-i*(a*o+l*c)+o+t,-n*l,n*a,-n*(-l*o+a*c)+c+e,0,0,1),this}scale(t,e){return this.premultiply(hn.makeScale(t,e)),this}rotate(t){return this.premultiply(hn.makeRotation(-t)),this}translate(t,e){return this.premultiply(hn.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new $t().fromArray(this.elements)}}const hn=new $t;var xt;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(xt||(xt={}));function cr(r,t,e,i){let n;switch(xt.Random===r?t=Math.random():xt.Burst===r&&i.isBursting&&(t=i.burstParticleIndex/i.burstParticleCount),e>0?n=Math.floor(t/e)*e:n=t,r){case xt.Loop:n=n%1;break;case xt.PingPong:n=Math.abs(n%2-1);break}return n}class ze{constructor(t,e,i,n){this.p=[t,e,i,n]}genValue(t){const e=t*t,i=t*t*t,n=1-t,s=n*n,o=s*n;return this.p[0]*o+this.p[1]*s*t*3+this.p[2]*n*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,n=i.length-1;n>0;n--){const s=[];for(let o=0;o<n;o++){const c=n*(i[o+1]-i[o]);s.push(c)}e.push(s),i=s}return e}getSlope(t){const e=this.derivativeCoefficients(this.p)[0],i=1-t,n=i*i,s=i*t*2,o=t*t;return n*e[0]+s*e[1]+o*e[2]}controlCurve(t,e){this.p[1]=t/3+this.p[0],this.p[2]=this.p[3]-e/3}hull(t){let e=this.p,i=[],n,s=0,o=0,c=0;const a=[];for(a[s++]=e[0],a[s++]=e[1],a[s++]=e[2],a[s++]=e[3];e.length>1;){for(i=[],o=0,c=e.length-1;o<c;o++)n=t*e[o]+(1-t)*e[o+1],a[s++]=n,i.push(n);e=i}return a}split(t){const e=this.hull(t);return{left:new ze(e[0],e[4],e[7],e[9]),right:new ze(e[9],e[8],e[6],e[3]),span:e}}clone(){return new ze(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(t){return new ze(t.p0,t.p1,t.p2,t.p3)}}const Ri=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),ki=r=>new Mt(r.r,r.g,r.b,r.a),fl=(r,t)=>{switch(t){case"Vector3":return new z(r.x,r.y,r.z);case"Vector4":return new Mt(r.x,r.y,r.z,r.w);case"Color":return new z(r.r,r.g,r.b);case"Number":return r;default:return r}},dl=(r,t)=>{switch(t){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 jr{constructor(t,e){this.a=t,this.b=e,this.type="value"}startGen(t){}genColor(t,e){const i=Math.random();return e.copy(this.a).lerp(this.b,i)}toJSON(){return{type:"RandomColor",a:Ri(this.a),b:Ri(this.b)}}static fromJSON(t){return new jr(ki(t.a),ki(t.b))}clone(){return new jr(this.a.clone(),this.b.clone())}}class Ye{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e){return this.indexCount===-1&&this.startGen(t),e.copy(this.a).lerp(this.b,t[this.indexCount])}toJSON(){return{type:"ColorRange",a:Ri(this.a),b:Ri(this.b)}}static fromJSON(t){return new Ye(ki(t.a),ki(t.b))}clone(){return new Ye(this.a.clone(),this.b.clone())}}class he{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,n=this.keys.length-1;for(;i+1<n;)if(e=Math.floor((i+n)/2),t<this.getStartX(e))n=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let s=i;s<=n;s++)if(t>=this.getStartX(s)&&t<=this.getEndX(s))return s;return-1}getStartX(t){return this.keys[t][1]}getEndX(t){return t+1<this.keys.length?this.keys[t+1][1]:1}genValue(t,e){const i=this.findKey(e);return this.subType==="Number"?i===-1?this.keys[0][0]:i+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[i+1][0]-this.keys[i][0])*((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))+this.keys[i][0]:i===-1?t.copy(this.keys[0][0]):i+1>=this.keys.length?t.copy(this.keys[this.keys.length-1][0]):t.copy(this.keys[i][0]).lerp(this.keys[i+1][0],(e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([t,e])=>({value:dl(t,this.subType),pos:e}))}}static fromJSON(t){return new he(t.keys.map(e=>[fl(e.value,t.subType),e.pos]),t.subType)}clone(){return this.subType==="Number"?new he(this.keys.map(([t,e])=>[t,e]),this.subType):new he(this.keys.map(([t,e])=>[t.clone(),e]),this.subType)}}const mr=new z;class Oe{constructor(t=[[new z(0,0,0),0],[new z(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new he(t,"Color"),this.alpha=new he(e,"Number")}genColor(t,e,i){return this.color.genValue(mr,i),e.set(mr.x,mr.y,mr.z,this.alpha.genValue(1,i))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(t){if(t.functions){const e=t.functions.map(i=>[Ye.fromJSON(i.function).a,i.start]);return t.functions.length>0&&e.push([Ye.fromJSON(t.functions[t.functions.length-1].function).b,1]),new Oe(e.map(i=>[new z(i[0].x,i[0].y,i[0].z),i[1]]),e.map(i=>[i[0].w,i[1]]))}else{const e=new Oe;return e.alpha=he.fromJSON(t.alpha),e.color=he.fromJSON(t.color),e}}clone(){const t=new Oe;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const fn=new Mt;class $r{constructor(t,e){this.indexCount=0,this.type="function",this.gradient1=t,this.gradient2=e}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e,i){return this.gradient1.genColor(t,e,i),this.gradient2.genColor(t,fn,i),t&&t[this.indexCount]!==void 0?e.lerp(fn,t[this.indexCount]):e.lerp(fn,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new $r(Oe.fromJSON(t.gradient1),Oe.fromJSON(t.gradient2))}clone(){return new $r(this.gradient1.clone(),this.gradient2.clone())}}class Ie{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:Ri(this.color)}}static fromJSON(t){return new Ie(ki(t.color))}clone(){return new Ie(this.color.clone())}}function ss(r){switch(r.type){case"ConstantColor":return Ie.fromJSON(r);case"ColorRange":return Ye.fromJSON(r);case"RandomColor":return jr.fromJSON(r);case"Gradient":return Oe.fromJSON(r);case"RandomColorBetweenGradient":return $r.fromJSON(r);default:return new Ie(new Mt(1,1,1,1))}}class F{constructor(t){this.value=t,this.type="value"}startGen(t){}genValue(t){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(t){return new F(t.value)}clone(){return new F(this.value)}}class Ne{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genValue(t){return this.indexCount===-1&&this.startGen(t),Ke.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new Ne(t.a,t.b)}clone(){return new Ne(this.a,this.b)}}class pl{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,n=this.functions.length-1;for(;i+1<n;)if(e=Math.floor((i+n)/2),t<this.getStartX(e))n=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let s=i;s<=n;s++)if(t>=this.functions[s][1]&&t<=this.getEndX(s))return s;return-1}getStartX(t){return this.functions[t][1]}setStartX(t,e){t>0&&(this.functions[t][1]=e)}getEndX(t){return t+1<this.functions.length?this.functions[t+1][1]:1}setEndX(t,e){t+1<this.functions.length&&(this.functions[t+1][1]=e)}insertFunction(t,e){const i=this.findFunction(t);this.functions.splice(i+1,0,[e,t])}removeFunction(t){return this.functions.splice(t,1)[0][0]}getFunction(t){return this.functions[t][0]}setFunction(t,e){this.functions[t][0]=e}get numOfFunctions(){return this.functions.length}}class Bi extends pl{constructor(t=[[new ze(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=t}genValue(t,e=0){const i=this.findFunction(e);return i===-1?0:this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(t,e){if(e<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let n=1/e;n<=1;n+=1/e)i=[i,"L",n*t,this.genValue(void 0,n)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([t,e])=>({function:t.toJSON(),start:e}))}}static fromJSON(t){return new Bi(t.functions.map(e=>[ze.fromJSON(e.function),e.start]))}clone(){return new Bi(this.functions.map(([t,e])=>[t.clone(),e]))}startGen(t){}}function U(r){switch(r.type){case"ConstantValue":return F.fromJSON(r);case"IntervalValue":return Ne.fromJSON(r);case"PiecewiseBezier":return Bi.fromJSON(r);default:return new F(0)}}class zi{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){this.indexCount=t.length,t.push(new G);let e,i,n,s,o,c;do e=Math.random()*2-1,i=Math.random()*2-1,n=e*e+i*i;while(n>1);do s=Math.random()*2-1,o=Math.random()*2-1,c=s*s+o*o;while(c>1);const a=Math.sqrt((1-n)/c);t[this.indexCount].set(e,i,a*s,a*o)}genValue(t,e,i,n){return this.indexCount===-1&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new zi}clone(){return new zi}}class Oi{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,n){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,n)*i)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(t){return new Oi(new z(t.axis.x,t.axis.y,t.axis.z),U(t.angle))}clone(){return new Oi(this.axis.clone(),this.angle.clone())}}class Hr{constructor(t,e,i,n){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new Ai(0,0,0,n)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,n){return this.eular.set(this.angleX.genValue(t,n)*i,this.angleY.genValue(t,n)*i,this.angleZ.genValue(t,n)*i),e.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(t){return new Hr(U(t.angleX),U(t.angleY),U(t.angleZ),t.eulerOrder)}clone(){return new Hr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function xa(r){switch(r.type){case"AxisAngle":return Oi.fromJSON(r);case"Euler":return Hr.fromJSON(r);case"RandomQuat":return zi.fromJSON(r);default:return new zi}}class Ue{constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="vec3function"}startGen(t){this.x.startGen(t),this.y.startGen(t),this.z.startGen(t)}genValue(t,e,i){return e.set(this.x.genValue(t,i),this.y.genValue(t,i),this.z.genValue(t,i))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new Ue(U(t.x),U(t.y),U(t.z))}clone(){return new Ue(this.x,this.y,this.z)}}function ml(r){switch(r.type){case"Vector3Function":return Ue.fromJSON(r);default:return new Ue(new F(0),new F(0),new F(0))}}function qr(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return U(r);case"AxisAngle":case"RandomQuat":case"Euler":return xa(r);case"Vector3Function":return ml(r);default:return new F(0)}}class Ii{constructor(t={}){var e,i,n,s,o,c,a;this.type="cone",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.angle=(s=t.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(o=t.mode)!==null&&o!==void 0?o:xt.Random,this.spread=(c=t.spread)!==null&&c!==void 0?c:0,this.speed=(a=t.speed)!==null&&a!==void 0?a:new F(1),this.memory=[]}update(t,e){xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=cr(this.mode,this.currentValue,this.spread,e),n=Ke.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,o=Math.sqrt(n),c=Math.sin(s),a=Math.cos(s);t.position.x=o*a,t.position.y=o*c,t.position.z=0;const l=this.angle*o;t.velocity.set(0,0,Math.cos(l)).addScaledVector(t.position,Math.sin(l)).multiplyScalar(t.startSpeed),t.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(t){return new Ii({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?U(t.speed):void 0,spread:t.spread})}clone(){return new Ii({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ni{constructor(t={}){var e,i,n,s,o,c;this.type="circle",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:xt.Random,this.spread=(o=t.spread)!==null&&o!==void 0?o:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new F(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=cr(this.mode,this.currentValue,this.spread,e),n=Ke.lerp(1-this.thickness,1,Math.random()),s=i*this.arc;t.position.x=Math.cos(s),t.position.y=Math.sin(s),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*n)}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(t){return new Ni({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?U(t.speed):void 0,spread:t.spread})}clone(){return new Ni({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function yr(r,t){return Math.floor(Math.random()*(t-r))+r}const tn=new z(0,1,0),en=new z(0,0,0),yl=new z(1,1,1),$s=new z(0,0,1);class Ui{constructor(t={}){var e,i,n,s,o,c,a;this.type="donut",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.donutRadius=(s=t.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(o=t.mode)!==null&&o!==void 0?o:xt.Random,this.spread=(c=t.spread)!==null&&c!==void 0?c:0,this.speed=(a=t.speed)!==null&&a!==void 0?a:new F(1),this.memory=[],this._m1=new Ft}update(t,e){xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=cr(this.mode,this.currentValue,this.spread,e),n=Math.random(),s=Ke.lerp(1-this.thickness,1,Math.random()),o=i*this.arc,c=n*Math.PI*2,a=Math.sin(o),l=Math.cos(o);t.position.x=this.radius*l,t.position.y=this.radius*a,t.position.z=0,t.velocity.z=this.donutRadius*s*Math.sin(c),t.velocity.x=this.donutRadius*s*Math.cos(c)*l,t.velocity.y=this.donutRadius*s*Math.cos(c)*a,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof G&&(this._m1.lookAt(en,t.velocity,tn),t.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(t){return new Ui({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?U(t.speed):void 0,spread:t.spread})}clone(){return new Ui({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Di{constructor(){this.type="point",this._m1=new Ft}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),n=e*Math.PI*2,s=Math.acos(2*i-1),o=Math.cbrt(Math.random()),c=Math.sin(n),a=Math.cos(n),l=Math.sin(s),u=Math.cos(s);t.velocity.x=o*l*a,t.velocity.y=o*l*c,t.velocity.z=o*u,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0),t.rotation instanceof G&&(this._m1.lookAt(en,t.position,tn),t.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(t){return new Di}clone(){return new Di}}class Ze{constructor(t={}){var e,i,n,s,o,c;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:xt.Random,this.spread=(o=t.spread)!==null&&o!==void 0?o:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new F(1),this.memory=[],this._m1=new Ft}update(t,e){xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=cr(this.mode,this.currentValue,this.spread,e),n=Math.random(),s=Ke.lerp(1-this.thickness,1,Math.random()),o=i*this.arc,c=Math.acos(2*n-1),a=Math.sin(o),l=Math.cos(o),u=Math.sin(c),h=Math.cos(c);t.position.x=u*l,t.position.y=u*a,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s),t.rotation instanceof G&&(this._m1.lookAt(en,t.position,tn),t.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(t){return new Ze({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?U(t.speed):void 0,spread:t.spread})}clone(){return new Ze({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Fi{constructor(t={}){var e,i,n,s,o,c;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(n=t.thickness)!==null&&n!==void 0?n:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:xt.Random,this.spread=(o=t.spread)!==null&&o!==void 0?o:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new F(1),this.memory=[],this._m1=new Ft}update(t,e){xt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=cr(this.mode,this.currentValue,this.spread,e),n=Math.random(),s=Ke.lerp(1-this.thickness,1,Math.random()),o=i*this.arc,c=Math.acos(n),a=Math.sin(o),l=Math.cos(o),u=Math.sin(c),h=Math.cos(c);t.position.x=u*l,t.position.y=u*a,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s),t.rotation instanceof G&&(this._m1.lookAt(en,t.position,tn),t.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(t){return new Fi({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?U(t.speed):void 0,spread:t.spread})}clone(){return new Fi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Li{constructor(t={}){var e,i,n,s;this.type="grid",this.width=(e=t.width)!==null&&e!==void 0?e:1,this.height=(i=t.height)!==null&&i!==void 0?i:1,this.column=(n=t.column)!==null&&n!==void 0?n:10,this.row=(s=t.row)!==null&&s!==void 0?s:10}initialize(t){const e=Math.floor(Math.random()*this.row),i=Math.floor(Math.random()*this.column);t.position.x=i*this.width/this.column-this.width/2,t.position.y=e*this.height/this.row-this.height/2,t.position.z=0,t.velocity.set(0,0,t.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(t){return new Li(t)}clone(){return new Li({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}const Vn={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ni,loadJSON:Ni.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ii,loadJSON:Ii.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ui,loadJSON:Ui.fromJSON},point:{type:"point",params:[],constructor:Di,loadJSON:Di.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ze,loadJSON:Ze.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Fi,loadJSON:Fi.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Li,loadJSON:Li.fromJSON}};function gl(r,t){return Vn[r.type].loadJSON(r,t)}class Vi{constructor(t){this.color=t,this.type="ColorOverLife"}initialize(t){this.color.startGen(t.memory)}update(t,e){this.color.genColor(t.memory,t.color,t.age/t.life),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(t){return new Vi(ss(t.color))}clone(){return new Vi(this.color.clone())}reset(){}}class Ji{constructor(t){this.angularVelocity=t,this.type="RotationOverLife"}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){typeof t.rotation=="number"&&(t.rotation+=e*this.angularVelocity.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Ji(U(t.angularVelocity))}frameUpdate(t){}clone(){return new Ji(this.angularVelocity.clone())}reset(){}}class Gi{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new G,this.tempQuat2=new G}initialize(t){t.rotation instanceof G&&(t.angularVelocity=new G,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof G&&(this.angularVelocity.genValue(t.memory,this.tempQuat,e,t.age/t.life),t.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Gi(xa(t.angularVelocity))}frameUpdate(t){}clone(){return new Gi(this.angularVelocity.clone())}reset(){}}class ji{initialize(t,e){this.ps=e,this.x.startGen(t.memory),this.y.startGen(t.memory),this.z.startGen(t.memory)}constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="ForceOverLife",this._temp=new z,this._tempScale=new z,this._tempQ=new G}update(t,e){this._temp.set(this.x.genValue(t.memory,t.age/t.life),this.y.genValue(t.memory,t.age/t.life),this.z.genValue(t.memory,t.age/t.life)),this.ps.worldSpace?t.velocity.addScaledVector(this._temp,e):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),t.velocity.addScaledVector(this._temp,e))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new ji(U(t.x),U(t.y),U(t.z))}frameUpdate(t){if(this.ps&&!this.ps.worldSpace){const e=this._temp,i=this._tempQ,n=this._tempScale;this.ps.emitter.matrixWorld.decompose(e,i,n),i.invert(),n.set(1/n.x,1/n.y,1/n.z)}}clone(){return new ji(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class $i{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof Ue?this.size.genValue(t.memory,t.size,t.age/t.life).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(t){return new $i(qr(t.size))}frameUpdate(t){}clone(){return new $i(this.size.clone())}reset(){}}class Hi{initialize(t){this.speed.startGen(t.memory)}constructor(t){this.speed=t,this.type="SpeedOverLife"}update(t){t.speedModifier=this.speed.genValue(t.memory,t.age/t.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(t){return new Hi(U(t.speed))}frameUpdate(t){}clone(){return new Hi(this.speed.clone())}reset(){}}class qi{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof Bi&&(t.uvTile=this.frame.genValue(t.memory,t.age/t.life))}frameUpdate(t){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(t){return new qi(U(t.frame))}clone(){return new qi(this.frame.clone())}reset(){}}class Xi{constructor(t,e=new z(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new z,this.rotation=new G}initialize(t){this.orbitSpeed.startGen(t.memory)}update(t,e){this.temp.copy(t.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(t.memory,t.age/t.life)*e),t.position.sub(this.temp),t.position.applyQuaternion(this.rotation),t.position.add(this.temp)}frameUpdate(t){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(t){return new Xi(U(t.orbitSpeed),t.axis?new z(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new Xi(this.orbitSpeed.clone())}reset(){}}class dn{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class vl{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 t=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}}pop(){if(this.tail){const t=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}}queue(t){const e=new dn(t);this.tail||(this.tail=e),this.head&&(this.head.prev=e,e.next=this.head),this.head=e,this.length++}push(t){const e=new dn(t);this.head||(this.head=e),this.tail&&(this.tail.next=e,e.prev=this.tail),this.tail=e,this.length++}insertBefore(t,e){const i=new dn(e);i.next=t,i.prev=t.prev,i.prev!==null&&(i.prev.next=i),i.next.prev=i,t==this.head&&(this.head=i),this.length++}remove(t){if(this.head===null||this.tail===null)return;let e=this.head;for(t===this.head.data&&(this.head=this.head.next),t===this.tail.data&&(this.tail=this.tail.prev);e.next!==null&&e.data!==t;)e=e.next;e.data===t&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.length--)}*values(){let t=this.head;for(;t!==null;)yield t.data,t=t.next}}class xl{constructor(){this.startSpeed=0,this.startColor=new Mt,this.startSize=new z(1,1,1),this.position=new z,this.velocity=new z,this.age=0,this.life=1,this.size=new z(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new Mt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class _l{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class Xr{constructor(){this.startSpeed=0,this.startColor=new Mt,this.startSize=new z(1,1,1),this.position=new z,this.velocity=new z,this.age=0,this.life=1,this.size=new z(1,1,1),this.length=100,this.speedModifier=1,this.color=new Mt,this.previous=new vl,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new _l(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 Wi{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof Xr){const e=t.previous.values();for(let i=0;i<t.previous.length;i++){const n=e.next();n.value.size=this.width.genValue(t.memory,(t.previous.length-i)/t.length)}}}frameUpdate(t){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(t){return new Wi(U(t.width))}clone(){return new Wi(this.width.clone())}reset(){}}class Yi{constructor(t,e){this.direction=t,this.magnitude=e,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(t){}update(t,e){t.velocity.addScaledVector(this.direction,this.magnitudeValue*e)}frameUpdate(t){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(t){var e;return new Yi(new z(t.direction[0],t.direction[1],t.direction[2]),U((e=t.magnitude)!==null&&e!==void 0?e:t.force))}clone(){return new Yi(this.direction.clone(),this.magnitude.clone())}reset(){}}class Zi{constructor(t,e){this.center=t,this.magnitude=e,this.type="GravityForce",this.temp=new z}initialize(t){}update(t,e){this.temp.copy(this.center).sub(t.position).normalize(),t.velocity.addScaledVector(this.temp,this.magnitude/t.position.distanceToSquared(this.center)*e)}frameUpdate(t){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(t){return new Zi(new z(t.center[0],t.center[1],t.center[2]),t.magnitude)}clone(){return new Zi(this.center.clone(),this.magnitude)}reset(){}}class Qi{constructor(t){this.angle=t,this.type="ChangeEmitDirection",this._temp=new z,this._q=new G,this.memory={data:[],dataCount:0}}initialize(t){const e=t.velocity.length();e!=0&&(t.velocity.normalize(),t.velocity.x===0&&t.velocity.y===0?this._temp.set(0,t.velocity.z,0):this._temp.set(-t.velocity.y,t.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(t.velocity),t.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),t.velocity.applyQuaternion(this._q),t.velocity.setLength(e))}update(t,e){}frameUpdate(t){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(t){return new Qi(U(t.angle))}clone(){return new Qi(this.angle)}reset(){}}var qe;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(qe||(qe={}));class Ki{constructor(t,e,i,n=qe.Frame,s=1){this.particleSystem=t,this.useVelocityAsBasis=e,this.subParticleSystem=i,this.mode=n,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new G,this.v_=new z,this.v2_=new z,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(t){}update(t,e){this.mode===qe.Frame?this.emit(t,e):this.mode===qe.Birth&&t.age===0?this.emit(t,e):this.mode===qe.Death&&t.age+e>=t.life&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const i=new Ft;this.setMatrixFromParticle(i,t),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:i,travelDistance:0,particle:t})}frameUpdate(t){if(this.subParticleSystem)for(let e=0;e<this.subEmissions.length;e++)if(this.subEmissions[e].time>=this.subParticleSystem.system.duration)this.subEmissions[e]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,e--;else{const i=this.subEmissions[e];i.particle&&i.particle.age<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(t,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(t,e){return new Ki(e,t.useVelocityAsBasis,t.subParticleSystem,t.mode,t.emitProbability)}clone(){return new Ki(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(t,e){let i;if(e.rotation===void 0||this.useVelocityAsBasis)if(e.velocity.x===0&&e.velocity.y===0&&(e.velocity.z===1||e.velocity.z===0))t.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1);else{this.v_.copy($s).cross(e.velocity),this.v2_.copy(e.velocity).cross(this.v_);const n=this.v_.length(),s=this.v2_.length();t.set(this.v_.x/n,this.v2_.x/s,e.velocity.x,e.position.x,this.v_.y/n,this.v2_.y/s,e.velocity.y,e.position.y,this.v_.z/n,this.v2_.z/s,e.velocity.z,e.position.z,0,0,0,1)}else e.rotation instanceof G?i=e.rotation:(this.q_.setFromAxisAngle($s,e.rotation),i=this.q_),t.compose(e.position,i,yl);this.particleSystem.worldSpace||t.multiplyMatrices(this.particleSystem.emitter.matrixWorld,t)}}const bl=.5*(Math.sqrt(3)-1),ai=(3-Math.sqrt(3))/6,Sl=1/3,Vt=1/6,Tl=(Math.sqrt(5)-1)/4,ot=(5-Math.sqrt(5))/20,nt=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]),Q=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 _a{constructor(t=Math.random){const e=typeof t=="function"?t:Cl(t);this.p=Ml(e),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let i=0;i<512;i++)this.perm[i]=this.p[i&255],this.permMod12[i]=this.perm[i]%12}noise2D(t,e){const i=this.permMod12,n=this.perm;let s=0,o=0,c=0;const a=(t+e)*bl,l=Math.floor(t+a),u=Math.floor(e+a),h=(l+u)*ai,f=l-h,d=u-h,p=t-f,m=e-d;let g,y;p>m?(g=1,y=0):(g=0,y=1);const v=p-g+ai,b=m-y+ai,S=p-1+2*ai,_=m-1+2*ai,T=l&255,M=u&255;let w=.5-p*p-m*m;if(w>=0){const A=i[T+n[M]]*3;w*=w,s=w*w*(nt[A]*p+nt[A+1]*m)}let E=.5-v*v-b*b;if(E>=0){const A=i[T+g+n[M+y]]*3;E*=E,o=E*E*(nt[A]*v+nt[A+1]*b)}let C=.5-S*S-_*_;if(C>=0){const A=i[T+1+n[M+1]]*3;C*=C,c=C*C*(nt[A]*S+nt[A+1]*_)}return 70*(s+o+c)}noise3D(t,e,i){const n=this.permMod12,s=this.perm;let o,c,a,l;const u=(t+e+i)*Sl,h=Math.floor(t+u),f=Math.floor(e+u),d=Math.floor(i+u),p=(h+f+d)*Vt,m=h-p,g=f-p,y=d-p,v=t-m,b=e-g,S=i-y;let _,T,M,w,E,C;v>=b?b>=S?(_=1,T=0,M=0,w=1,E=1,C=0):v>=S?(_=1,T=0,M=0,w=1,E=0,C=1):(_=0,T=0,M=1,w=1,E=0,C=1):b<S?(_=0,T=0,M=1,w=0,E=1,C=1):v<S?(_=0,T=1,M=0,w=0,E=1,C=1):(_=0,T=1,M=0,w=1,E=1,C=0);const A=v-_+Vt,P=b-T+Vt,R=S-M+Vt,k=v-w+2*Vt,O=b-E+2*Vt,N=S-C+2*Vt,D=v-1+3*Vt,V=b-1+3*Vt,W=S-1+3*Vt,it=h&255,tt=f&255,Ct=d&255;let bt=.6-v*v-b*b-S*S;if(bt<0)o=0;else{const q=n[it+s[tt+s[Ct]]]*3;bt*=bt,o=bt*bt*(nt[q]*v+nt[q+1]*b+nt[q+2]*S)}let rt=.6-A*A-P*P-R*R;if(rt<0)c=0;else{const q=n[it+_+s[tt+T+s[Ct+M]]]*3;rt*=rt,c=rt*rt*(nt[q]*A+nt[q+1]*P+nt[q+2]*R)}let dt=.6-k*k-O*O-N*N;if(dt<0)a=0;else{const q=n[it+w+s[tt+E+s[Ct+C]]]*3;dt*=dt,a=dt*dt*(nt[q]*k+nt[q+1]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ye*ye;if(zt<0)a=0;else{const J=s[Xt+D+s[Wt+V+s[Yt+W+s[Zt+it]]]]%32*4;zt*=zt,a=zt*zt*(Q[J]*Y+Q[J+1]*Lt+Q[J+2]*qt+Q[J+3]*ye)}let Ot=.6-ge*ge-ve*ve-xe*xe-_e*_e;if(Ot<0)l=0;else{const J=s[Xt+tt+s[Wt+Ct+s[Yt+bt+s[Zt+rt]]]]%32*4;Ot*=Ot,l=Ot*Ot*(Q[J]*ge+Q[J+1]*ve+Q[J+2]*xe+Q[J+3]*_e)}let It=.6-be*be-Se*Se-Te*Te-Me*Me;if(It<0)u=0;else{const J=s[Xt+1+s[Wt+1+s[Yt+1+s[Zt+1]]]]%32*4;It*=It,u=It*It*(Q[J]*be+Q[J+1]*Se+Q[J+2]*Te+Q[J+3]*Me)}return 27*(o+c+a+l+u)}}function Ml(r){const t=new Uint8Array(256);for(let e=0;e<256;e++)t[e]=e;for(let e=0;e<255;e++){const i=e+~~(r()*(256-e)),n=t[e];t[e]=t[i],t[i]=n}return t}function Cl(r){let t=0,e=0,i=0,n=1;const s=wl();return t=s(" "),e=s(" "),i=s(" "),t-=s(r),t<0&&(t+=1),e-=s(r),e<0&&(e+=1),i-=s(r),i<0&&(i+=1),function(){const o=2091639*t+n*23283064365386963e-26;return t=e,e=i,i=o-(n=o|0)}}function wl(){let r=4022871197;return function(t){t=t.toString();for(let e=0;e<t.length;e++){r+=t.charCodeAt(e);let i=.02519603282416938*r;r=i>>>0,i-=r,i*=r,r=i>>>0,i-=r,r+=i*4294967296}return(r>>>0)*23283064365386963e-26}}class tr{constructor(t,e,i,n){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=n,this.type="TurbulenceField",this.generator=new _a,this.timeOffset=new z,this.temp=new z,this.temp2=new z,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(t){}update(t,e){const i=t.position.x/this.scale.x,n=t.position.y/this.scale.y,s=t.position.z/this.scale.z;this.temp.set(0,0,0);let o=1;for(let c=0;c<this.octaves;c++)this.temp2.set(this.generator.noise4D(i*o,n*o,s*o,this.timeOffset.x*o)/o,this.generator.noise4D(i*o,n*o,s*o,this.timeOffset.y*o)/o,this.generator.noise4D(i*o,n*o,s*o,this.timeOffset.z*o)/o),this.temp.add(this.temp2),o*=2;this.temp.multiply(this.velocityMultiplier),t.velocity.addScaledVector(this.temp,e)}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(t){this.timeOffset.x+=t*this.timeScale.x,this.timeOffset.y+=t*this.timeScale.y,this.timeOffset.z+=t*this.timeScale.z}static fromJSON(t){return new tr(new z(t.scale[0],t.scale[1],t.scale[2]),t.octaves,new z(t.velocityMultiplier[0],t.velocityMultiplier[1],t.velocityMultiplier[2]),new z(t.timeScale[0],t.timeScale[1],t.timeScale[2]))}clone(){return new tr(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Jt=[],pn=new z,mn=new G;class er{constructor(t,e,i=new F(1),n=new F(0)){if(this.frequency=t,this.power=e,this.positionAmount=i,this.rotationAmount=n,this.type="Noise",this.duration=0,Jt.length===0)for(let s=0;s<100;s++)Jt.push(new _a)}initialize(t){t.lastPosNoise=new z,typeof t.rotation=="number"?t.lastRotNoise=0:t.lastRotNoise=new G,t.generatorIndex=[yr(0,100),yr(0,100),yr(0,100),yr(0,100)],this.positionAmount.startGen(t.memory),this.rotationAmount.startGen(t.memory),this.frequency.startGen(t.memory),this.power.startGen(t.memory)}update(t,e){let i=this.frequency.genValue(t.memory,t.age/t.life),n=this.power.genValue(t.memory,t.age/t.life),s=this.positionAmount.genValue(t.memory,t.age/t.life),o=this.rotationAmount.genValue(t.memory,t.age/t.life);s>0&&t.lastPosNoise!==void 0&&(t.position.sub(t.lastPosNoise),pn.set(Jt[t.generatorIndex[0]].noise2D(0,t.age*i)*n*s,Jt[t.generatorIndex[1]].noise2D(0,t.age*i)*n*s,Jt[t.generatorIndex[2]].noise2D(0,t.age*i)*n*s),t.position.add(pn),t.lastPosNoise.copy(pn)),o>0&&t.lastRotNoise!==void 0&&(typeof t.rotation=="number"?(t.rotation-=t.lastRotNoise,t.rotation+=Jt[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*n*o):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),mn.set(Jt[t.generatorIndex[0]].noise2D(0,t.age*i)*n*o,Jt[t.generatorIndex[1]].noise2D(0,t.age*i)*n*o,Jt[t.generatorIndex[2]].noise2D(0,t.age*i)*n*o,Jt[t.generatorIndex[3]].noise2D(0,t.age*i)*n*o).normalize(),t.rotation.multiply(mn),t.lastRotNoise.copy(mn)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(t){this.duration+=t}static fromJSON(t){return new er(U(t.frequency),U(t.power),U(t.positionAmount),U(t.rotationAmount))}clone(){return new er(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class ir{constructor(t,e){this.color=t,this.speedRange=e,this.type="ColorBySpeed"}initialize(t){this.color.startGen(t.memory)}update(t,e){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(t.memory,t.color,i),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new ir(ss(t.color),Ne.fromJSON(t.speedRange))}clone(){return new ir(this.color.clone(),this.speedRange.clone())}reset(){}}class rr{initialize(t){this.size.startGen(t.memory)}constructor(t,e){this.size=t,this.speedRange=e,this.type="SizeBySpeed"}update(t){const e=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof Ue?this.size.genValue(t.memory,t.size,e).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,e))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new rr(qr(t.size),Ne.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new rr(this.size.clone(),this.speedRange.clone())}reset(){}}class nr{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new G}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){if(typeof t.rotation=="number"){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);t.rotation+=e*this.angularVelocity.genValue(t.memory,i)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new nr(U(t.angularVelocity),Ne.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new nr(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class sr{initialize(t){this.speed.startGen(t.memory)}constructor(t,e){this.speed=t,this.dampen=e,this.type="LimitSpeedOverLife"}update(t,e){let i=t.velocity.length(),n=this.speed.genValue(t.memory,t.age/t.life);if(i>n){const s=(i-n)/i;t.velocity.multiplyScalar(1-s*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new sr(U(t.speed),t.dampen)}frameUpdate(t){}clone(){return new sr(this.speed.clone(),this.dampen)}reset(){}}const Wr={ApplyForce:{type:"ApplyForce",constructor:Yi,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Yi.fromJSON},Noise:{type:"Noise",constructor:er,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:er.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:tr,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:tr.fromJSON},GravityForce:{type:"GravityForce",constructor:Zi,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Zi.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Vi,params:[["color",["colorFunc"]]],loadJSON:Vi.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Ji,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Ji.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Gi,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Gi.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:$i,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:$i.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:ir,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:ir.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:nr,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:nr.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:rr,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:rr.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Hi,params:[["speed",["value","valueFunc"]]],loadJSON:Hi.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:qi,params:[["frame",["value","valueFunc"]]],loadJSON:qi.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:ji,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:ji.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Xi,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Xi.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Wi,params:[["width",["value","valueFunc"]]],loadJSON:Wi.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Qi,params:[["angle",["value"]]],loadJSON:Qi.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Ki,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:Ki.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:sr,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:sr.fromJSON}};function Pl(r,t){return Wr[r.type]?Wr[r.type].loadJSON(r,t):null}const El=[];function Al(r){if(!El.find(e=>e.id===r.id)){r.initialize();for(const e of r.emitterShapes)Vn[e.type]||(Vn[e.type]=e);for(const e of r.behaviors)Wr[e.type]||(Wr[e.type]=e)}}var Rl=`
|
|
84
84
|
#ifdef SOFT_PARTICLES
|
|
85
85
|
|
|
86
86
|
/* #ifdef LOGDEPTH
|
|
@@ -102,7 +102,7 @@ a=extmap-allow-mixed`)!==-1){const o=n.sdp.split(`
|
|
|
102
102
|
|
|
103
103
|
//gl_FragColor = vec4(softParticlesFade , 0, 0, 1);
|
|
104
104
|
#endif
|
|
105
|
-
`,
|
|
105
|
+
`,kl=`
|
|
106
106
|
#ifdef SOFT_PARTICLES
|
|
107
107
|
|
|
108
108
|
uniform sampler2D depthTexture;
|
|
@@ -124,17 +124,17 @@ a=extmap-allow-mixed`)!==-1){const o=n.sdp.split(`
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
#endif
|
|
127
|
-
`,
|
|
127
|
+
`,Bl=`
|
|
128
128
|
#ifdef SOFT_PARTICLES
|
|
129
129
|
varying vec4 projPosition;
|
|
130
130
|
varying float linearDepth;
|
|
131
131
|
#endif
|
|
132
|
-
`,
|
|
132
|
+
`,zl=`
|
|
133
133
|
#ifdef SOFT_PARTICLES
|
|
134
134
|
projPosition = gl_Position;
|
|
135
135
|
linearDepth = -mvPosition.z;
|
|
136
136
|
#endif
|
|
137
|
-
`,
|
|
137
|
+
`,Ol=`
|
|
138
138
|
#ifdef USE_MAP
|
|
139
139
|
vec4 texelColor = texture2D( map, vUv);
|
|
140
140
|
#ifdef TILE_BLEND
|
|
@@ -142,7 +142,7 @@ a=extmap-allow-mixed`)!==-1){const o=n.sdp.split(`
|
|
|
142
142
|
#endif
|
|
143
143
|
diffuseColor *= texelColor;
|
|
144
144
|
#endif
|
|
145
|
-
`,
|
|
145
|
+
`,Il=`
|
|
146
146
|
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
147
147
|
|
|
148
148
|
varying vec2 vUv;
|
|
@@ -293,7 +293,7 @@ a=extmap-allow-mixed`)!==-1){const o=n.sdp.split(`
|
|
|
293
293
|
varying vec2 vThicknessMapUv;
|
|
294
294
|
|
|
295
295
|
#endif
|
|
296
|
-
`,
|
|
296
|
+
`,Nl=`
|
|
297
297
|
#ifdef UV_TILE
|
|
298
298
|
attribute float uvTile;
|
|
299
299
|
uniform vec2 tileCount;
|
|
@@ -463,7 +463,7 @@ a=extmap-allow-mixed`)!==-1){const o=n.sdp.split(`
|
|
|
463
463
|
varying vec2 vThicknessMapUv;
|
|
464
464
|
|
|
465
465
|
#endif
|
|
466
|
-
`,
|
|
466
|
+
`,Ul=`
|
|
467
467
|
#ifdef UV_TILE
|
|
468
468
|
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
469
469
|
#ifdef TILE_BLEND
|
|
@@ -601,7 +601,7 @@ vThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_U
|
|
|
601
601
|
|
|
602
602
|
#endif
|
|
603
603
|
|
|
604
|
-
`;const ce=X.ShaderChunk;function Ua(){ce.tile_pars_vertex=Ia,ce.tile_vertex=Ja,ce.tile_pars_fragment=Na,ce.tile_fragment=Ha,ce.soft_pars_vertex=Ya,ce.soft_vertex=ka,ce.soft_pars_fragment=Ma,ce.soft_fragment=Ta}class Pa extends X.Object3D{constructor(t){super(),this.type="ParticleEmitter",this.system=t}clone(){const t=this.system.clone();return t.emitter.copy(this,!0),t.emitter}dispose(){}extractFromCache(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}toJSON(t,e={}){const i=this.children;this.children=this.children.filter(o=>o.type!=="ParticleSystemPreview");const n=super.toJSON(t);return this.children=i,this.system!==null&&(n.object.ps=this.system.toJSON(t,e)),n}}exports.RenderMode=void 0;(function(s){s[s.BillBoard=0]="BillBoard",s[s.StretchedBillBoard=1]="StretchedBillBoard",s[s.Mesh=2]="Mesh",s[s.Trail=3]="Trail",s[s.HorizontalBillBoard=4]="HorizontalBillBoard",s[s.VerticalBillBoard=5]="VerticalBillBoard"})(exports.RenderMode||(exports.RenderMode={}));class Rc extends X.Mesh{constructor(t){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const e=new X.Layers;e.mask=t.layers.mask;const i=t.material.clone();i.defines={},Object.assign(i.defines,t.material.defines),this.settings={instancingGeometry:t.instancingGeometry,renderMode:t.renderMode,renderOrder:t.renderOrder,material:i,uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softNearFade:t.softNearFade,softFarFade:t.softFarFade,layers:e},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(t){this.systems.add(t)}removeSystem(t){this.systems.delete(t)}applyDepthTexture(t){const e=this.material.uniforms.depthTexture;e&&e.value!==t&&(e.value=t,this.material.needsUpdate=!0)}}const Fa=new M(0,0,1),yn=new Q,Qa=new M,wa=new M;new M;const jo=60,Ba=new X.PlaneGeometry(1,1,1,1);class _s{set time(t){this.emissionState.time=t}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(t){this.rendererSettings.material.map=t,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(t){this.rendererSettings.material=t,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(t){this.rendererSettings.uTileCount=t,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(t){this.rendererSettings.vTileCount=t,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(t){this.rendererSettings.blendTiles=t,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(t){this.rendererSettings.softParticles=t,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(t){this.rendererSettings.softNearFade=t,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(t){this.rendererSettings.softFarFade=t,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(t){if((this.rendererSettings.renderMode!=exports.RenderMode.Trail&&t===exports.RenderMode.Trail||this.rendererSettings.renderMode==exports.RenderMode.Trail&&t!==exports.RenderMode.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==t)switch(t){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new J(30),followLocalOrigin:!1};break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={geometry:new X.PlaneGeometry(1,1)},this.startRotation=new Yi(new M(0,1,0),new J(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new J(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 J(0));break}this.rendererSettings.renderMode=t,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(t){this.rendererSettings.material.blending=t,this.neededToUpdateRender=!0}constructor(t){var e,i,n,o,r,l,c,a,d,h,u,p,m,b,G,y,Z,V,R,f,x,L,W,C,S,z;if(this.temp=new M,this.travelDistance=0,this.normalMatrix=new Bt,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=t.autoDestroy===void 0?!1:t.autoDestroy,this.duration=(e=t.duration)!==null&&e!==void 0?e:1,this.looping=t.looping===void 0?!0:t.looping,this.prewarm=t.prewarm===void 0?!1:t.prewarm,this.startLife=(i=t.startLife)!==null&&i!==void 0?i:new J(5),this.startSpeed=(n=t.startSpeed)!==null&&n!==void 0?n:new J(0),this.startRotation=(o=t.startRotation)!==null&&o!==void 0?o:new J(0),this.startSize=(r=t.startSize)!==null&&r!==void 0?r:new J(1),this.startColor=(l=t.startColor)!==null&&l!==void 0?l:new ke(new Lt(1,1,1,1)),this.emissionOverTime=(c=t.emissionOverTime)!==null&&c!==void 0?c:new J(10),this.emissionOverDistance=(a=t.emissionOverDistance)!==null&&a!==void 0?a:new J(0),this.emissionBursts=(d=t.emissionBursts)!==null&&d!==void 0?d:[],this.onlyUsedByOther=(h=t.onlyUsedByOther)!==null&&h!==void 0?h:!1,this.emitterShape=(u=t.shape)!==null&&u!==void 0?u:new Ae,this.behaviors=(p=t.behaviors)!==null&&p!==void 0?p:new Array,this.worldSpace=(m=t.worldSpace)!==null&&m!==void 0?m:!1,this.rendererEmitterSettings=(b=t.rendererEmitterSettings)!==null&&b!==void 0?b:{},t.renderMode===exports.RenderMode.StretchedBillBoard){const g=this.rendererEmitterSettings;t.speedFactor!==void 0&&(g.speedFactor=t.speedFactor),g.speedFactor=(G=g.speedFactor)!==null&&G!==void 0?G:0,g.lengthFactor=(y=g.lengthFactor)!==null&&y!==void 0?y:0}this.rendererSettings={instancingGeometry:(Z=t.instancingGeometry)!==null&&Z!==void 0?Z:Ba,renderMode:(V=t.renderMode)!==null&&V!==void 0?V:exports.RenderMode.BillBoard,renderOrder:(R=t.renderOrder)!==null&&R!==void 0?R:0,material:t.material,uTileCount:(f=t.uTileCount)!==null&&f!==void 0?f:1,vTileCount:(x=t.vTileCount)!==null&&x!==void 0?x:1,blendTiles:(L=t.blendTiles)!==null&&L!==void 0?L:!1,softParticles:(W=t.softParticles)!==null&&W!==void 0?W:!1,softNearFade:(C=t.softNearFade)!==null&&C!==void 0?C:0,softFarFade:(S=t.softFarFade)!==null&&S!==void 0?S:0,layers:(z=t.layers)!==null&&z!==void 0?z:new X.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=t.startTileIndex||new J(0),this.emitter=new Pa(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(g=>g.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(t,e,i){yn.setFromRotationMatrix(i);const n=Qa,o=yn,r=wa;i.decompose(n,o,r);for(let l=0;l<t;l++){for(e.burstParticleIndex=l,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===exports.RenderMode.Trail?this.particles.push(new Os):this.particles.push(new Va);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,e.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,e.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,e.time/this.duration);else{const a=this.startSize.genValue(c.memory,e.time/this.duration);c.startSize.set(a,a,a)}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 a=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===exports.RenderMode.Mesh?(a.rotation instanceof Q||(a.rotation=new Q),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,a.rotation,1,e.time/this.duration):a.rotation.setFromAxisAngle(Fa,this.startRotation.genValue(a.memory,e.time/this.duration))):this.startRotation.type==="rotation"?a.rotation=0:a.rotation=this.startRotation.genValue(a.memory,e.time/this.duration)}else if(this.rendererSettings.renderMode===exports.RenderMode.Trail){const a=c;this.rendererEmitterSettings.startLength.startGen(a.memory),a.length=this.rendererEmitterSettings.startLength.genValue(a.memory,e.time/this.duration)}if(this.emitterShape.initialize(c,e),this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin){const a=c;a.localPosition=new M().copy(a.position)}this.worldSpace?(c.position.applyMatrix4(i),c.startSize.multiply(r).abs(),c.size.copy(c.startSize),c.velocity.multiply(r).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof Q&&c.rotation.multiplyQuaternions(yn,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=i);for(let a=0;a<this.behaviors.length;a++)this.behaviors[a].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(t=>{t.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(t){if(this.paused)return;let e=this.emitter;for(;e.parent;)e=e.parent;if(e.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 i=0;i<this.duration*jo;i++)this.update(1/jo)}t>.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(t,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,t);for(let i=0;i<this.behaviors.length;i++){this.behaviors[i].frameUpdate(t);for(let n=0;n<this.particleNum;n++)this.particles[n].died||this.behaviors[i].update(this.particles[n],t)}for(let i=0;i<this.particleNum;i++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[i].localPosition?(this.particles[i].position.copy(this.particles[i].localPosition),this.particles[i].parentMatrix?this.particles[i].position.applyMatrix4(this.particles[i].parentMatrix):this.particles[i].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[i].position.addScaledVector(this.particles[i].velocity,t*this.particles[i].speedModifier),this.particles[i].age+=t;if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let i=0;i<this.particleNum;i++)this.particles[i].update();for(let i=0;i<this.particleNum;i++){const n=this.particles[i];n.died&&(!(n instanceof Os)||n.previous.length===0)&&(this.particles[i]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=n,this.particleNum--,i--,this.fire({type:"particleDied",particleSystem:this,particle:n}))}}emit(t,e,i){e.time>this.duration&&(this.looping?(e.time-=this.duration,e.burstIndex=0,this.behaviors.forEach(o=>{o.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(i);const n=Math.ceil(e.waitEmiting);for(this.spawn(n,e,i),e.waitEmiting-=n;e.burstIndex<this.emissionBursts.length&&this.emissionBursts[e.burstIndex].time<=e.time;){if(Math.random()<this.emissionBursts[e.burstIndex].probability){const o=this.emissionBursts[e.burstIndex].count.genValue(this.memory,this.time);e.isBursting=!0,e.burstParticleCount=o,this.spawn(o,e,i),e.isBursting=!1}e.burstIndex++}if(!this.emitEnded&&(e.waitEmiting+=t*this.emissionOverTime.genValue(this.memory,e.time/this.duration),e.previousWorldPos!=null)){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),e.travelDistance+=e.previousWorldPos.distanceTo(this.temp);const o=this.emissionOverDistance.genValue(this.memory,e.time/this.duration);if(e.travelDistance*o>0){const r=Math.floor(e.travelDistance*o);e.travelDistance-=r/o,e.waitEmiting+=r}}e.previousWorldPos===void 0&&(e.previousWorldPos=new M),e.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),e.time+=t}toJSON(t,e={}){var i;if((t===void 0||typeof t=="string")&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),t.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(t),e.useUrlForImage&&((i=this.texture)===null||i===void 0?void 0:i.source)!==void 0){const l=this.texture.source;t.images[l.uuid]={uuid:l.uuid,url:this.texture.image.url}}let o;this.renderMode===exports.RenderMode.Trail?o={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.Mesh?o={}:this.renderMode===exports.RenderMode.StretchedBillBoard?o={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:o={};const r=this.rendererSettings.instancingGeometry;return t.geometries&&!t.geometries[r.uuid]&&(t.geometries[r.uuid]=r.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(l=>({time:l.time,count:l.count.toJSON(),probability:l.probability,interval:l.interval,cycle:l.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:o,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(l=>l.toJSON()),worldSpace:this.worldSpace}}static fromJSON(t,e,i){var n,o;const r=Xa(t.shape,e);let l;if(t.renderMode===exports.RenderMode.Trail){const d=t.rendererEmitterSettings;l={startLength:d.startLength!=null?N(d.startLength):new J(30),followLocalOrigin:d.followLocalOrigin}}else t.renderMode===exports.RenderMode.Mesh?l={}:t.renderMode===exports.RenderMode.StretchedBillBoard?(l=t.rendererEmitterSettings,t.speedFactor!=null&&(l.speedFactor=t.speedFactor)):l={};const c=new X.Layers;t.layers&&(c.mask=t.layers);const a=new _s({autoDestroy:t.autoDestroy,looping:t.looping,prewarm:t.prewarm,duration:t.duration,shape:r,startLife:N(t.startLife),startSpeed:N(t.startSpeed),startRotation:js(t.startRotation),startSize:js(t.startSize),startColor:oo(t.startColor),emissionOverTime:N(t.emissionOverTime),emissionOverDistance:N(t.emissionOverDistance),emissionBursts:(n=t.emissionBursts)===null||n===void 0?void 0:n.map(d=>{var h,u,p;return{time:d.time,count:typeof d.count=="number"?new J(d.count):N(d.count),probability:(h=d.probability)!==null&&h!==void 0?h:1,interval:(u=d.interval)!==null&&u!==void 0?u:.1,cycle:(p=d.cycle)!==null&&p!==void 0?p:1}}),onlyUsedByOther:t.onlyUsedByOther,instancingGeometry:e.geometries[t.instancingGeometry],renderMode:t.renderMode,rendererEmitterSettings:l,renderOrder:t.renderOrder,layers:c,material:t.material?e.materials[t.material]:t.texture?new X.MeshBasicMaterial({map:e.textures[t.texture],transparent:(o=t.transparent)!==null&&o!==void 0?o:!0,blending:t.blending,side:X.DoubleSide}):new X.MeshBasicMaterial({color:16777215,transparent:!0,blending:X.AdditiveBlending,side:X.DoubleSide}),startTileIndex:typeof t.startTileIndex=="number"?new J(t.startTileIndex):N(t.startTileIndex),uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softFarFade:t.softFarFade,softNearFade:t.softNearFade,behaviors:[],worldSpace:t.worldSpace});return a.behaviors=t.behaviors.map(d=>{const h=za(d,a);return h.type==="EmitSubParticleSystem"&&(i[d.subParticleSystem]=h),h}),a}addBehavior(t){this.behaviors.push(t)}getRendererSettings(){return this.rendererSettings}addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}removeEventListener(t,e){if(this.listeners[t]){const i=this.listeners[t].indexOf(e);i!==-1&&this.listeners[t].splice(i,1)}}fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach(e=>e(t))}clone(){const t=[];for(const o of this.emissionBursts){const r={};Object.assign(r,o),t.push(r)}const e=[];for(const o of this.behaviors)e.push(o.clone());let i;this.renderMode===exports.RenderMode.Trail?i={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?i={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:i={};const n=new X.Layers;return n.mask=this.layers.mask,new _s({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:t,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:i,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:e,worldSpace:this.worldSpace,layers:n})}}var Gn=`
|
|
604
|
+
`;const ae=x.ShaderChunk;function Dl(){ae.tile_pars_vertex=Nl,ae.tile_vertex=Ul,ae.tile_pars_fragment=Il,ae.tile_fragment=Ol,ae.soft_pars_vertex=Bl,ae.soft_vertex=zl,ae.soft_pars_fragment=kl,ae.soft_fragment=Rl}class Fl extends x.Object3D{constructor(t){super(),this.type="ParticleEmitter",this.system=t}clone(){const t=this.system.clone();return t.emitter.copy(this,!0),t.emitter}dispose(){}extractFromCache(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}toJSON(t,e={}){const i=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const n=super.toJSON(t);return this.children=i,this.system!==null&&(n.object.ps=this.system.toJSON(t,e)),n}}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 ba extends x.Mesh{constructor(t){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const e=new x.Layers;e.mask=t.layers.mask;const i=t.material.clone();i.defines={},Object.assign(i.defines,t.material.defines),this.settings={instancingGeometry:t.instancingGeometry,renderMode:t.renderMode,renderOrder:t.renderOrder,material:i,uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softNearFade:t.softNearFade,softFarFade:t.softFarFade,layers:e},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(t){this.systems.add(t)}removeSystem(t){this.systems.delete(t)}applyDepthTexture(t){const e=this.material.uniforms.depthTexture;e&&e.value!==t&&(e.value=t,this.material.needsUpdate=!0)}}const Ll=new z(0,0,1),yn=new G,Vl=new z,Jl=new z;new z;const Hs=60,Gl=new x.PlaneGeometry(1,1,1,1);class Yr{set time(t){this.emissionState.time=t}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(t){this.rendererSettings.material.map=t,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(t){this.rendererSettings.material=t,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(t){this.rendererSettings.uTileCount=t,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(t){this.rendererSettings.vTileCount=t,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(t){this.rendererSettings.blendTiles=t,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(t){this.rendererSettings.softParticles=t,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(t){this.rendererSettings.softNearFade=t,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(t){this.rendererSettings.softFarFade=t,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(t){if((this.rendererSettings.renderMode!=exports.RenderMode.Trail&&t===exports.RenderMode.Trail||this.rendererSettings.renderMode==exports.RenderMode.Trail&&t!==exports.RenderMode.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==t)switch(t){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new F(30),followLocalOrigin:!1};break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={geometry:new x.PlaneGeometry(1,1)},this.startRotation=new Oi(new z(0,1,0),new F(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new F(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 F(0));break}this.rendererSettings.renderMode=t,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(t){this.rendererSettings.material.blending=t,this.neededToUpdateRender=!0}constructor(t){var e,i,n,s,o,c,a,l,u,h,f,d,p,m,g,y,v,b,S,_,T,M,w,E,C,A;if(this.temp=new z,this.travelDistance=0,this.normalMatrix=new $t,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=t.autoDestroy===void 0?!1:t.autoDestroy,this.duration=(e=t.duration)!==null&&e!==void 0?e:1,this.looping=t.looping===void 0?!0:t.looping,this.prewarm=t.prewarm===void 0?!1:t.prewarm,this.startLife=(i=t.startLife)!==null&&i!==void 0?i:new F(5),this.startSpeed=(n=t.startSpeed)!==null&&n!==void 0?n:new F(0),this.startRotation=(s=t.startRotation)!==null&&s!==void 0?s:new F(0),this.startSize=(o=t.startSize)!==null&&o!==void 0?o:new F(1),this.startColor=(c=t.startColor)!==null&&c!==void 0?c:new Ie(new Mt(1,1,1,1)),this.emissionOverTime=(a=t.emissionOverTime)!==null&&a!==void 0?a:new F(10),this.emissionOverDistance=(l=t.emissionOverDistance)!==null&&l!==void 0?l:new F(0),this.emissionBursts=(u=t.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(h=t.onlyUsedByOther)!==null&&h!==void 0?h:!1,this.emitterShape=(f=t.shape)!==null&&f!==void 0?f:new Ze,this.behaviors=(d=t.behaviors)!==null&&d!==void 0?d:new Array,this.worldSpace=(p=t.worldSpace)!==null&&p!==void 0?p:!1,this.rendererEmitterSettings=(m=t.rendererEmitterSettings)!==null&&m!==void 0?m:{},t.renderMode===exports.RenderMode.StretchedBillBoard){const P=this.rendererEmitterSettings;t.speedFactor!==void 0&&(P.speedFactor=t.speedFactor),P.speedFactor=(g=P.speedFactor)!==null&&g!==void 0?g:0,P.lengthFactor=(y=P.lengthFactor)!==null&&y!==void 0?y:0}this.rendererSettings={instancingGeometry:(v=t.instancingGeometry)!==null&&v!==void 0?v:Gl,renderMode:(b=t.renderMode)!==null&&b!==void 0?b:exports.RenderMode.BillBoard,renderOrder:(S=t.renderOrder)!==null&&S!==void 0?S:0,material:t.material,uTileCount:(_=t.uTileCount)!==null&&_!==void 0?_:1,vTileCount:(T=t.vTileCount)!==null&&T!==void 0?T:1,blendTiles:(M=t.blendTiles)!==null&&M!==void 0?M:!1,softParticles:(w=t.softParticles)!==null&&w!==void 0?w:!1,softNearFade:(E=t.softNearFade)!==null&&E!==void 0?E:0,softFarFade:(C=t.softFarFade)!==null&&C!==void 0?C:0,layers:(A=t.layers)!==null&&A!==void 0?A:new x.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=t.startTileIndex||new F(0),this.emitter=new Fl(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(P=>P.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(t,e,i){yn.setFromRotationMatrix(i);const n=Vl,s=yn,o=Jl;i.decompose(n,s,o);for(let c=0;c<t;c++){for(e.burstParticleIndex=c,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===exports.RenderMode.Trail?this.particles.push(new Xr):this.particles.push(new xl);const a=this.particles[this.particleNum-1];if(a.reset(),a.speedModifier=1,this.startColor.startGen(a.memory),this.startColor.genColor(a.memory,a.startColor,this.emissionState.time),a.color.copy(a.startColor),this.startSpeed.startGen(a.memory),a.startSpeed=this.startSpeed.genValue(a.memory,e.time/this.duration),this.startLife.startGen(a.memory),a.life=this.startLife.genValue(a.memory,e.time/this.duration),a.age=0,this.startSize.startGen(a.memory),this.startSize.type==="vec3function")this.startSize.genValue(a.memory,a.startSize,e.time/this.duration);else{const l=this.startSize.genValue(a.memory,e.time/this.duration);a.startSize.set(l,l,l)}if(this.startTileIndex.startGen(a.memory),a.uvTile=this.startTileIndex.genValue(a.memory),a.size.copy(a.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=a;this.startRotation.startGen(a.memory),this.rendererSettings.renderMode===exports.RenderMode.Mesh?(l.rotation instanceof G||(l.rotation=new G),this.startRotation.type==="rotation"?this.startRotation.genValue(a.memory,l.rotation,1,e.time/this.duration):l.rotation.setFromAxisAngle(Ll,this.startRotation.genValue(l.memory,e.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,e.time/this.duration)}else if(this.rendererSettings.renderMode===exports.RenderMode.Trail){const l=a;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,e.time/this.duration)}if(this.emitterShape.initialize(a,e),this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=a;l.localPosition=new z().copy(l.position)}this.worldSpace?(a.position.applyMatrix4(i),a.startSize.multiply(o).abs(),a.size.copy(a.startSize),a.velocity.multiply(o).applyMatrix3(this.normalMatrix),a.rotation&&a.rotation instanceof G&&a.rotation.multiplyQuaternions(yn,a.rotation)):this.onlyUsedByOther&&(a.parentMatrix=i);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(a,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(t=>{t.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(t){if(this.paused)return;let e=this.emitter;for(;e.parent;)e=e.parent;if(e.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 i=0;i<this.duration*Hs;i++)this.update(1/Hs)}t>.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(t,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,t);for(let i=0;i<this.behaviors.length;i++){this.behaviors[i].frameUpdate(t);for(let n=0;n<this.particleNum;n++)this.particles[n].died||this.behaviors[i].update(this.particles[n],t)}for(let i=0;i<this.particleNum;i++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[i].localPosition?(this.particles[i].position.copy(this.particles[i].localPosition),this.particles[i].parentMatrix?this.particles[i].position.applyMatrix4(this.particles[i].parentMatrix):this.particles[i].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[i].position.addScaledVector(this.particles[i].velocity,t*this.particles[i].speedModifier),this.particles[i].age+=t;if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let i=0;i<this.particleNum;i++)this.particles[i].update();for(let i=0;i<this.particleNum;i++){const n=this.particles[i];n.died&&(!(n instanceof Xr)||n.previous.length===0)&&(this.particles[i]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=n,this.particleNum--,i--,this.fire({type:"particleDied",particleSystem:this,particle:n}))}}emit(t,e,i){e.time>this.duration&&(this.looping?(e.time-=this.duration,e.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(i);const n=Math.ceil(e.waitEmiting);for(this.spawn(n,e,i),e.waitEmiting-=n;e.burstIndex<this.emissionBursts.length&&this.emissionBursts[e.burstIndex].time<=e.time;){if(Math.random()<this.emissionBursts[e.burstIndex].probability){const s=this.emissionBursts[e.burstIndex].count.genValue(this.memory,this.time);e.isBursting=!0,e.burstParticleCount=s,this.spawn(s,e,i),e.isBursting=!1}e.burstIndex++}if(!this.emitEnded&&(e.waitEmiting+=t*this.emissionOverTime.genValue(this.memory,e.time/this.duration),e.previousWorldPos!=null)){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),e.travelDistance+=e.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,e.time/this.duration);if(e.travelDistance*s>0){const o=Math.floor(e.travelDistance*s);e.travelDistance-=o/s,e.waitEmiting+=o}}e.previousWorldPos===void 0&&(e.previousWorldPos=new z),e.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),e.time+=t}toJSON(t,e={}){var i;if((t===void 0||typeof t=="string")&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),t.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(t),e.useUrlForImage&&((i=this.texture)===null||i===void 0?void 0:i.source)!==void 0){const c=this.texture.source;t.images[c.uuid]={uuid:c.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 o=this.rendererSettings.instancingGeometry;return t.geometries&&!t.geometries[o.uuid]&&(t.geometries[o.uuid]=o.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(c=>({time:c.time,count:c.count.toJSON(),probability:c.probability,interval:c.interval,cycle:c.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(c=>c.toJSON()),worldSpace:this.worldSpace}}static fromJSON(t,e,i){var n,s;const o=gl(t.shape,e);let c;if(t.renderMode===exports.RenderMode.Trail){const u=t.rendererEmitterSettings;c={startLength:u.startLength!=null?U(u.startLength):new F(30),followLocalOrigin:u.followLocalOrigin}}else t.renderMode===exports.RenderMode.Mesh?c={}:t.renderMode===exports.RenderMode.StretchedBillBoard?(c=t.rendererEmitterSettings,t.speedFactor!=null&&(c.speedFactor=t.speedFactor)):c={};const a=new x.Layers;t.layers&&(a.mask=t.layers);const l=new Yr({autoDestroy:t.autoDestroy,looping:t.looping,prewarm:t.prewarm,duration:t.duration,shape:o,startLife:U(t.startLife),startSpeed:U(t.startSpeed),startRotation:qr(t.startRotation),startSize:qr(t.startSize),startColor:ss(t.startColor),emissionOverTime:U(t.emissionOverTime),emissionOverDistance:U(t.emissionOverDistance),emissionBursts:(n=t.emissionBursts)===null||n===void 0?void 0:n.map(u=>{var h,f,d;return{time:u.time,count:typeof u.count=="number"?new F(u.count):U(u.count),probability:(h=u.probability)!==null&&h!==void 0?h:1,interval:(f=u.interval)!==null&&f!==void 0?f:.1,cycle:(d=u.cycle)!==null&&d!==void 0?d:1}}),onlyUsedByOther:t.onlyUsedByOther,instancingGeometry:e.geometries[t.instancingGeometry],renderMode:t.renderMode,rendererEmitterSettings:c,renderOrder:t.renderOrder,layers:a,material:t.material?e.materials[t.material]:t.texture?new x.MeshBasicMaterial({map:e.textures[t.texture],transparent:(s=t.transparent)!==null&&s!==void 0?s:!0,blending:t.blending,side:x.DoubleSide}):new x.MeshBasicMaterial({color:16777215,transparent:!0,blending:x.AdditiveBlending,side:x.DoubleSide}),startTileIndex:typeof t.startTileIndex=="number"?new F(t.startTileIndex):U(t.startTileIndex),uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softFarFade:t.softFarFade,softNearFade:t.softNearFade,behaviors:[],worldSpace:t.worldSpace});return l.behaviors=t.behaviors.map(u=>{const h=Pl(u,l);return h.type==="EmitSubParticleSystem"&&(i[u.subParticleSystem]=h),h}),l}addBehavior(t){this.behaviors.push(t)}getRendererSettings(){return this.rendererSettings}addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}removeEventListener(t,e){if(this.listeners[t]){const i=this.listeners[t].indexOf(e);i!==-1&&this.listeners[t].splice(i,1)}}fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach(e=>e(t))}clone(){const t=[];for(const s of this.emissionBursts){const o={};Object.assign(o,s),t.push(o)}const e=[];for(const s of this.behaviors)e.push(s.clone());let i;this.renderMode===exports.RenderMode.Trail?i={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?i={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:i={};const n=new x.Layers;return n.mask=this.layers.mask,new Yr({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:t,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:i,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:e,worldSpace:this.worldSpace,layers:n})}}var gn=`
|
|
605
605
|
|
|
606
606
|
#include <common>
|
|
607
607
|
#include <color_pars_fragment>
|
|
@@ -636,7 +636,7 @@ void main() {
|
|
|
636
636
|
#include <soft_fragment>
|
|
637
637
|
#include <tonemapping_fragment>
|
|
638
638
|
}
|
|
639
|
-
`,
|
|
639
|
+
`,os=`
|
|
640
640
|
#define STANDARD
|
|
641
641
|
|
|
642
642
|
#ifdef PHYSICAL
|
|
@@ -801,7 +801,7 @@ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoat
|
|
|
801
801
|
#include <fog_fragment>
|
|
802
802
|
#include <premultiplied_alpha_fragment>
|
|
803
803
|
#include <dithering_fragment>
|
|
804
|
-
}`,
|
|
804
|
+
}`,jl=`
|
|
805
805
|
#include <common>
|
|
806
806
|
#include <color_pars_vertex>
|
|
807
807
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -847,7 +847,7 @@ void main() {
|
|
|
847
847
|
#include <tile_vertex>
|
|
848
848
|
#include <soft_vertex>
|
|
849
849
|
}
|
|
850
|
-
|
|
850
|
+
`,$l=`
|
|
851
851
|
#include <common>
|
|
852
852
|
#include <color_pars_vertex>
|
|
853
853
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -884,7 +884,7 @@ void main() {
|
|
|
884
884
|
#include <tile_vertex>
|
|
885
885
|
#include <soft_vertex>
|
|
886
886
|
}
|
|
887
|
-
`,
|
|
887
|
+
`,as=`
|
|
888
888
|
#define STANDARD
|
|
889
889
|
varying vec3 vViewPosition;
|
|
890
890
|
#ifdef USE_TRANSMISSION
|
|
@@ -969,7 +969,7 @@ void main() {
|
|
|
969
969
|
vWorldPosition = worldPosition.xyz;
|
|
970
970
|
#endif
|
|
971
971
|
}
|
|
972
|
-
`,
|
|
972
|
+
`,Hl=`
|
|
973
973
|
#include <common>
|
|
974
974
|
#include <color_pars_vertex>
|
|
975
975
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -1010,7 +1010,7 @@ void main() {
|
|
|
1010
1010
|
#include <tile_vertex>
|
|
1011
1011
|
#include <soft_vertex>
|
|
1012
1012
|
}
|
|
1013
|
-
`;function Fn(s){return s===0?"uv":`uv${s}`}class Da extends X.MeshStandardMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=co,t.fragmentShader=ro}}class _a extends X.MeshPhysicalMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=co,t.fragmentShader=ro}}class Aa extends Rc{constructor(t){super(t),this.vector_=new M,this.vector2_=new M,this.vector3_=new M,this.quaternion_=new Q,this.quaternion2_=new Q,this.quaternion3_=new Q,this.rotationMat_=new Bt,this.rotationMat2_=new Bt,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(X.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 X.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new X.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new X.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(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={},e={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(t.map=new X.Uniform$1(this.settings.material.map)),this.settings.material.alphaTest&&(e.USE_ALPHATEST="",t.alphaTest=new X.Uniform$1(this.settings.material.alphaTest)),e.USE_UV="";const i=this.settings.uTileCount,n=this.settings.vTileCount;(i>1||n>1)&&(e.UV_TILE="",t.tileCount=new X.Uniform$1(new De(i,n))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(e.USE_NORMALMAP="",e.NORMALMAP_UV=Fn(this.settings.material.normalMap.channel),t.normalMapTransform=new X.Uniform$1(new Bt().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(e.USE_MAP="",this.settings.blendTiles&&(e.TILE_BLEND=""),e.MAP_UV=Fn(this.settings.material.map.channel),t.mapTransform=new X.Uniform$1(new Bt().copy(this.settings.material.map.matrix))),e.USE_COLOR_ALPHA="";let o;if(this.settings.softParticles){e.SOFT_PARTICLES="";const l=this.settings.softNearFade,c=1/(this.settings.softFarFade-this.settings.softNearFade);t.softParams=new X.Uniform$1(new De(l,c)),t.depthTexture=new X.Uniform$1(null);const a=t.projParams=new X.Uniform$1(new Lt);o=(d,h,u)=>{a.value.set(u.near,u.far,0,0)}}let r=!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 l,c;this.settings.renderMode===exports.RenderMode.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(e.USE_COLOR="",l=co,c=ro,r=!0):(l=ja,c=Gn):(l=Ea,c=Gn),this.settings.renderMode===exports.RenderMode.VerticalBillBoard?e.VERTICAL="":this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&(e.HORIZONTAL="");let a=!1;this.settings.renderMode===exports.RenderMode.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new Da({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,a=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new _a({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,a=!0)),a||(this.material=new X.ShaderMaterial({uniforms:t,defines:e,vertexShader:l,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:r}))}else if(this.settings.renderMode===exports.RenderMode.StretchedBillBoard)t.speedFactor=new X.Uniform$1(1),this.material=new X.ShaderMaterial({uniforms:t,defines:e,vertexShader:Oa,fragmentShader:Gn,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&&o&&(this.material.onBeforeRender=o)}update(){let t=0,e=0;this.systems.forEach(i=>{e+=i.particleNum}),e>this.maxParticles&&this.expandBuffers(e),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const n=i.particles,o=i.particleNum,r=this.quaternion2_,l=this.vector2_,c=this.vector3_;i.emitter.matrixWorld.decompose(l,r,c),this.rotationMat_.setFromMatrix4(i.emitter.matrixWorld);for(let a=0;a<o;a++,t++){const d=n[a];if(this.settings.renderMode===exports.RenderMode.Mesh){let u;if(i.worldSpace)u=d.rotation;else{let p;d.parentMatrix?p=this.quaternion3_.setFromRotationMatrix(d.parentMatrix):p=r,u=this.quaternion_,u.copy(p).multiply(d.rotation)}this.rotationBuffer.setXYZW(t,u.x,u.y,u.z,u.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(t,d.rotation);let h;if(i.worldSpace?h=d.position:(h=this.vector_,d.parentMatrix?h.copy(d.position).applyMatrix4(d.parentMatrix):h.copy(d.position).applyMatrix4(i.emitter.matrixWorld)),this.offsetBuffer.setXYZ(t,h.x,h.y,h.z),this.colorBuffer.setXYZW(t,d.color.x,d.color.y,d.color.z,d.color.w),i.worldSpace?this.sizeBuffer.setXYZ(t,d.size.x,d.size.y,d.size.z):d.parentMatrix?this.sizeBuffer.setXYZ(t,d.size.x,d.size.y,d.size.z):this.sizeBuffer.setXYZ(t,d.size.x*Math.abs(c.x),d.size.y*Math.abs(c.y),d.size.z*Math.abs(c.z)),this.uvTileBuffer.setX(t,d.uvTile),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer){let u=i.rendererEmitterSettings.speedFactor;u===0&&(u=.001);const p=i.rendererEmitterSettings.lengthFactor;let m;i.worldSpace?m=d.velocity:(m=this.vector_,d.parentMatrix?(this.rotationMat2_.setFromMatrix4(d.parentMatrix),m.copy(d.velocity).applyMatrix3(this.rotationMat2_)):m.copy(d.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(t,m.x*u,m.y*u,m.z*u,p)}}}),this.geometry.instanceCount=t,t>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,t*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,t*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,t),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,t*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,t*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,t),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var qa=`
|
|
1013
|
+
`;function Jn(r){return r===0?"uv":`uv${r}`}class ql extends x.MeshStandardMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=as,t.fragmentShader=os}}class Xl extends x.MeshPhysicalMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=as,t.fragmentShader=os}}class Wl extends ba{constructor(t){super(t),this.vector_=new z,this.vector2_=new z,this.vector3_=new z,this.quaternion_=new G,this.quaternion2_=new G,this.quaternion3_=new G,this.rotationMat_=new $t,this.rotationMat2_=new $t,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(x.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 x.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new x.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new x.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(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={},e={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(t.map=new x.Uniform$1(this.settings.material.map)),this.settings.material.alphaTest&&(e.USE_ALPHATEST="",t.alphaTest=new x.Uniform$1(this.settings.material.alphaTest)),e.USE_UV="";const i=this.settings.uTileCount,n=this.settings.vTileCount;(i>1||n>1)&&(e.UV_TILE="",t.tileCount=new x.Uniform$1(new We(i,n))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(e.USE_NORMALMAP="",e.NORMALMAP_UV=Jn(this.settings.material.normalMap.channel),t.normalMapTransform=new x.Uniform$1(new $t().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(e.USE_MAP="",this.settings.blendTiles&&(e.TILE_BLEND=""),e.MAP_UV=Jn(this.settings.material.map.channel),t.mapTransform=new x.Uniform$1(new $t().copy(this.settings.material.map.matrix))),e.USE_COLOR_ALPHA="";let s;if(this.settings.softParticles){e.SOFT_PARTICLES="";const c=this.settings.softNearFade,a=1/(this.settings.softFarFade-this.settings.softNearFade);t.softParams=new x.Uniform$1(new We(c,a)),t.depthTexture=new x.Uniform$1(null);const l=t.projParams=new x.Uniform$1(new Mt);s=(u,h,f)=>{l.value.set(f.near,f.far,0,0)}}let o=!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 c,a;this.settings.renderMode===exports.RenderMode.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(e.USE_COLOR="",c=as,a=os,o=!0):(c=$l,a=gn):(c=jl,a=gn),this.settings.renderMode===exports.RenderMode.VerticalBillBoard?e.VERTICAL="":this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&(e.HORIZONTAL="");let l=!1;this.settings.renderMode===exports.RenderMode.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new ql({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,l=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new Xl({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,l=!0)),l||(this.material=new x.ShaderMaterial({uniforms:t,defines:e,vertexShader:c,fragmentShader:a,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:o}))}else if(this.settings.renderMode===exports.RenderMode.StretchedBillBoard)t.speedFactor=new x.Uniform$1(1),this.material=new x.ShaderMaterial({uniforms:t,defines:e,vertexShader:Hl,fragmentShader:gn,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 t=0,e=0;this.systems.forEach(i=>{e+=i.particleNum}),e>this.maxParticles&&this.expandBuffers(e),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const n=i.particles,s=i.particleNum,o=this.quaternion2_,c=this.vector2_,a=this.vector3_;i.emitter.matrixWorld.decompose(c,o,a),this.rotationMat_.setFromMatrix4(i.emitter.matrixWorld);for(let l=0;l<s;l++,t++){const u=n[l];if(this.settings.renderMode===exports.RenderMode.Mesh){let f;if(i.worldSpace)f=u.rotation;else{let d;u.parentMatrix?d=this.quaternion3_.setFromRotationMatrix(u.parentMatrix):d=o,f=this.quaternion_,f.copy(d).multiply(u.rotation)}this.rotationBuffer.setXYZW(t,f.x,f.y,f.z,f.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(t,u.rotation);let h;if(i.worldSpace?h=u.position:(h=this.vector_,u.parentMatrix?h.copy(u.position).applyMatrix4(u.parentMatrix):h.copy(u.position).applyMatrix4(i.emitter.matrixWorld)),this.offsetBuffer.setXYZ(t,h.x,h.y,h.z),this.colorBuffer.setXYZW(t,u.color.x,u.color.y,u.color.z,u.color.w),i.worldSpace?this.sizeBuffer.setXYZ(t,u.size.x,u.size.y,u.size.z):u.parentMatrix?this.sizeBuffer.setXYZ(t,u.size.x,u.size.y,u.size.z):this.sizeBuffer.setXYZ(t,u.size.x*Math.abs(a.x),u.size.y*Math.abs(a.y),u.size.z*Math.abs(a.z)),this.uvTileBuffer.setX(t,u.uvTile),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer){let f=i.rendererEmitterSettings.speedFactor;f===0&&(f=.001);const d=i.rendererEmitterSettings.lengthFactor;let p;i.worldSpace?p=u.velocity:(p=this.vector_,u.parentMatrix?(this.rotationMat2_.setFromMatrix4(u.parentMatrix),p.copy(u.velocity).applyMatrix3(this.rotationMat2_)):p.copy(u.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(t,p.x*f,p.y*f,p.z*f,d)}}}),this.geometry.instanceCount=t,t>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,t*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,t*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,t),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,t*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,t*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,t),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var Yl=`
|
|
1014
1014
|
|
|
1015
1015
|
#include <common>
|
|
1016
1016
|
#include <tile_pars_fragment>
|
|
@@ -1043,7 +1043,7 @@ void main() {
|
|
|
1043
1043
|
|
|
1044
1044
|
#include <fog_fragment>
|
|
1045
1045
|
#include <tonemapping_fragment>
|
|
1046
|
-
}
|
|
1046
|
+
}`,Zl=`
|
|
1047
1047
|
#include <common>
|
|
1048
1048
|
#include <tile_pars_vertex>
|
|
1049
1049
|
#include <color_pars_vertex>
|
|
@@ -1118,7 +1118,7 @@ void main() {
|
|
|
1118
1118
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
1119
|
|
|
1120
1120
|
#include <fog_vertex>
|
|
1121
|
-
}`;class td extends Rc{constructor(t){super(t),this.vector_=new M,this.vector2_=new M,this.vector3_=new M,this.quaternion_=new Q,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new X.BufferGeometry,this.indexBuffer=new X.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new X.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(X.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new De(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},e={};if(e.USE_UV="",e.USE_COLOR_ALPHA="",this.settings.material.map&&(e.USE_MAP="",e.MAP_UV=Fn(this.settings.material.map.channel),t.map=new X.Uniform$1(this.settings.material.map),t.mapTransform=new X.Uniform$1(new Bt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new X.ShaderMaterial({uniforms:t,defines:e,vertexShader:$a,fragmentShader:qa,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||X.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 t=0,e=0,i=0;this.systems.forEach(n=>{for(let o=0;o<n.particleNum;o++)i+=n.particles[o].previous.length*2}),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach(n=>{n.emitter.updateMatrixWorld&&(n.emitter.updateWorldMatrix(!0,!1),n.emitter.updateMatrixWorld(!0));const o=this.quaternion_,r=this.vector2_,l=this.vector3_;n.emitter.matrixWorld.decompose(r,o,l);const c=n.particles,a=n.particleNum,d=this.settings.uTileCount,h=this.settings.vTileCount,u=1/d,p=1/h;for(let m=0;m<a;m++){const b=c[m],G=b.uvTile%h,y=Math.floor(b.uvTile/h+.001),Z=b.previous.values();let V=Z.next(),R=V.value,f=R;V.done||(V=Z.next());let x;V.value!==void 0?x=V.value:x=f;for(let L=0;L<b.previous.length;L++,t+=2){if(this.positionBuffer.setXYZ(t,f.position.x,f.position.y,f.position.z),this.positionBuffer.setXYZ(t+1,f.position.x,f.position.y,f.position.z),n.worldSpace?(this.positionBuffer.setXYZ(t,f.position.x,f.position.y,f.position.z),this.positionBuffer.setXYZ(t+1,f.position.x,f.position.y,f.position.z)):(b.parentMatrix?this.vector_.copy(f.position).applyMatrix4(b.parentMatrix):this.vector_.copy(f.position).applyMatrix4(n.emitter.matrixWorld),this.positionBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),n.worldSpace?(this.previousBuffer.setXYZ(t,R.position.x,R.position.y,R.position.z),this.previousBuffer.setXYZ(t+1,R.position.x,R.position.y,R.position.z)):(b.parentMatrix?this.vector_.copy(R.position).applyMatrix4(b.parentMatrix):this.vector_.copy(R.position).applyMatrix4(n.emitter.matrixWorld),this.previousBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),n.worldSpace?(this.nextBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.nextBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z)):(b.parentMatrix?this.vector_.copy(x.position).applyMatrix4(b.parentMatrix):this.vector_.copy(x.position).applyMatrix4(n.emitter.matrixWorld),this.nextBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(t,-1),this.sideBuffer.setX(t+1,1),n.worldSpace)this.widthBuffer.setX(t,f.size),this.widthBuffer.setX(t+1,f.size);else if(b.parentMatrix)this.widthBuffer.setX(t,f.size),this.widthBuffer.setX(t+1,f.size);else{const W=(Math.abs(l.x)+Math.abs(l.y)+Math.abs(l.z))/3;this.widthBuffer.setX(t,f.size*W),this.widthBuffer.setX(t+1,f.size*W)}this.uvBuffer.setXY(t,(L/b.previous.length+G)*u,(h-y-1)*p),this.uvBuffer.setXY(t+1,(L/b.previous.length+G)*u,(h-y)*p),this.colorBuffer.setXYZW(t,f.color.x,f.color.y,f.color.z,f.color.w),this.colorBuffer.setXYZW(t+1,f.color.x,f.color.y,f.color.z,f.color.w),L+1<b.previous.length&&(this.indexBuffer.setX(e*3,t),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+2),e++,this.indexBuffer.setX(e*3,t+2),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+3),e++),R=f,f=x,V.done||(V=Z.next(),V.value!==void 0&&(x=V.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,t*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,t*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,t*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,t*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,e*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,e*3)}dispose(){this.geometry.dispose()}}class rs{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,t===void 0||typeof t=="string")return;const e=new X.Triangle;this._triangleIndexToArea.length=0;let i=0;if(!t.getIndex())return;const n=t.getIndex().array,o=n.length/3;this._triangleIndexToArea.push(0);for(let r=0;r<o;r++)e.setFromAttributeAndIndices(t.getAttribute("position"),n[r*3],n[r*3+1],n[r*3+2]),i+=e.getArea(),this._triangleIndexToArea.push(i);t.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(t){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new X.Vector3,this._tempB=new X.Vector3,this._tempC=new X.Vector3,t&&(this.geometry=t)}initialize(t){const e=this._geometry;if(!e||e.getIndex()===null){t.position.set(0,0,0),t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);return}const i=this._triangleIndexToArea.length-1;let n=0,o=i;const r=Math.random()*this._triangleIndexToArea[i];for(;n+1<o;){const p=Math.floor((n+o)/2);r<this._triangleIndexToArea[p]?o=p:n=p}let l=Math.random(),c=Math.random();l+c>1&&(l=1-l,c=1-c);const a=e.getIndex().array[n*3],d=e.getIndex().array[n*3+1],h=e.getIndex().array[n*3+2],u=e.getAttribute("position");this._tempA.fromBufferAttribute(u,a),this._tempB.fromBufferAttribute(u,d),this._tempC.fromBufferAttribute(u,h),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,l).addScaledVector(this._tempC,c),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new rs(e.geometries[t.geometry])}clone(){return new rs(this._geometry)}update(t,e){}}Ka({id:"three.quarks",initialize:()=>{},emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:rs,loadJSON:rs.fromJSON}],behaviors:[]});class lo extends X.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(t,e){return t.material.side===e.material.side&&t.material.blending===e.material.blending&&t.material.blendSrc===e.material.blendSrc&&t.material.blendDst===e.material.blendDst&&t.material.blendEquation===e.material.blendEquation&&t.material.premultipliedAlpha===e.material.premultipliedAlpha&&t.material.transparent===e.material.transparent&&t.material.depthTest===e.material.depthTest&&t.material.type===e.material.type&&t.material.alphaTest===e.material.alphaTest&&t.material.map===e.material.map&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layers.mask===e.layers.mask}addSystem(t){t._renderer=this;const e=t.getRendererSettings();for(let n=0;n<this.batches.length;n++)if(lo.equals(this.batches[n].settings,e)){this.batches[n].addSystem(t),this.systemToBatchIndex.set(t,n);return}let i;switch(e.renderMode){case exports.RenderMode.Trail:i=new td(e);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:i=new Aa(e);break}this.depthTexture&&i.applyDepthTexture(this.depthTexture),i.addSystem(t),this.batches.push(i),this.systemToBatchIndex.set(t,this.batches.length-1),this.add(i)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);e!=null&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}update(t){this.systemToBatchIndex.forEach((e,i)=>{i.update(t)});for(let e=0;e<this.batches.length;e++)this.batches[e].update()}}const ed=lo;Ua();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const xc=Math.sqrt(5),id=(xc-1)/4,ct=(5-xc)/20,Gs=s=>Math.floor(s)|0,Zs=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 sd(s=Math.random){const t=nd(s),e=new Float64Array(t).map(r=>Zs[r%32*4]),i=new Float64Array(t).map(r=>Zs[r%32*4+1]),n=new Float64Array(t).map(r=>Zs[r%32*4+2]),o=new Float64Array(t).map(r=>Zs[r%32*4+3]);return function(l,c,a,d){let h,u,p,m,b;const G=(l+c+a+d)*id,y=Gs(l+G),Z=Gs(c+G),V=Gs(a+G),R=Gs(d+G),f=(y+Z+V+R)*ct,x=y-f,L=Z-f,W=V-f,C=R-f,S=l-x,z=c-L,g=a-W,v=d-C;let K=0,Y=0,H=0,I=0;S>z?K++:Y++,S>g?K++:H++,S>v?K++:I++,z>g?Y++:H++,z>v?Y++:I++,g>v?H++:I++;const P=K>=3?1:0,D=Y>=3?1:0,it=H>=3?1:0,tt=I>=3?1:0,St=K>=2?1:0,Vt=Y>=2?1:0,st=H>=2?1:0,pt=I>=2?1:0,et=K>=1?1:0,j=Y>=1?1:0,oe=H>=1?1:0,_=I>=1?1:0,Ut=S-P+ct,jt=z-D+ct,ye=g-it+ct,Ge=v-tt+ct,Ze=S-St+2*ct,Xe=z-Vt+2*ct,fe=g-st+2*ct,Ve=v-pt+2*ct,Re=S-et+3*ct,xe=z-j+3*ct,Le=g-oe+3*ct,Ot=v-_+3*ct,Dt=S-1+4*ct,_t=z-1+4*ct,At=g-1+4*ct,qt=v-1+4*ct,Tt=y&255,Mt=Z&255,Yt=V&255,kt=R&255;let F=.6-S*S-z*z-g*g-v*v;if(F<0)h=0;else{const O=Tt+t[Mt+t[Yt+t[kt]]];F*=F,h=F*F*(e[O]*S+i[O]*z+n[O]*g+o[O]*v)}let ei=.6-Ut*Ut-jt*jt-ye*ye-Ge*Ge;if(ei<0)u=0;else{const O=Tt+P+t[Mt+D+t[Yt+it+t[kt+tt]]];ei*=ei,u=ei*ei*(e[O]*Ut+i[O]*jt+n[O]*ye+o[O]*Ge)}let ii=.6-Ze*Ze-Xe*Xe-fe*fe-Ve*Ve;if(ii<0)p=0;else{const O=Tt+St+t[Mt+Vt+t[Yt+st+t[kt+pt]]];ii*=ii,p=ii*ii*(e[O]*Ze+i[O]*Xe+n[O]*fe+o[O]*Ve)}let si=.6-Re*Re-xe*xe-Le*Le-Ot*Ot;if(si<0)m=0;else{const O=Tt+et+t[Mt+j+t[Yt+oe+t[kt+_]]];si*=si,m=si*si*(e[O]*Re+i[O]*xe+n[O]*Le+o[O]*Ot)}let ni=.6-Dt*Dt-_t*_t-At*At-qt*qt;if(ni<0)b=0;else{const O=Tt+1+t[Mt+1+t[Yt+1+t[kt+1]]];ni*=ni,b=ni*ni*(e[O]*Dt+i[O]*_t+n[O]*At+o[O]*qt)}return 27*(h+u+p+m+b)}}function nd(s){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const n=i+~~(s()*(256-i)),o=e[i];e[i]=e[n],e[n]=o}for(let i=256;i<512;i++)e[i]=e[i-256];return e}class od{constructor(t){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Backoff must be a positive integer");this.backoff=t}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class rd{constructor(t,e){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Base must be a positive integer or zero");if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=t,this.expMax=e,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}}class cd{constructor(t,e,i){if(this.i=0,this._retries=0,t<0)throw new Error("Initial must be a positive number or zero");if(e<0)throw new Error("Increment must be a positive number or zero");if(i!==void 0&&i<0)throw new Error("Max must be undefined, a positive number or zero");if(i!==void 0&&i<t)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=t,this.increment=e,this.max=i}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class ld{constructor(){this.elements=[]}add(t){this.elements.push(t)}clear(){this.elements.length=0}forEach(t){this.elements.forEach(t)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class ad{constructor(t){if(!Number.isInteger(t)||t<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(t+1),this.head=0,this.tail=0}add(t){this.elements[this.head]=t,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(t){for(let e=this.tail;e!==this.head;e=(e+1)%this.elements.length)t(this.elements[e])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const t=this.peek();return t!==void 0&&(this.tail=(this.tail+1)%this.elements.length),t}}var w;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry",s.reconnect="reconnect"})(w||(w={}));class Lc{constructor(t,e,i){var n,o,r,l,c,a,d,h,u,p,m,b,G,y,Z;this._closedByUser=!1,this.handleOpenEvent=V=>this.handleEvent(w.open,V),this.handleErrorEvent=V=>this.handleEvent(w.error,V),this.handleCloseEvent=V=>this.handleEvent(w.close,V),this.handleMessageEvent=V=>this.handleEvent(w.message,V),this._url=t,this._protocols=e,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(n=i==null?void 0:i.retry)===null||n===void 0?void 0:n.maxRetries,instantReconnect:(o=i==null?void 0:i.retry)===null||o===void 0?void 0:o.instantReconnect,backoff:(r=i==null?void 0:i.retry)===null||r===void 0?void 0:r.backoff},listeners:{open:[...(c=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.open)!==null&&c!==void 0?c:[]],close:[...(d=(a=i==null?void 0:i.listeners)===null||a===void 0?void 0:a.close)!==null&&d!==void 0?d:[]],error:[...(u=(h=i==null?void 0:i.listeners)===null||h===void 0?void 0:h.error)!==null&&u!==void 0?u:[]],message:[...(m=(p=i==null?void 0:i.listeners)===null||p===void 0?void 0:p.message)!==null&&m!==void 0?m:[]],retry:[...(G=(b=i==null?void 0:i.listeners)===null||b===void 0?void 0:b.retry)!==null&&G!==void 0?G:[]],reconnect:[...(Z=(y=i==null?void 0:i.listeners)===null||y===void 0?void 0:y.reconnect)!==null&&Z!==void 0?Z:[]]}},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(t){this._underlyingWebsocket.binaryType=t}send(t){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(t):this.buffer!==void 0&&this.buffer.add(t))}close(t,e){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(t,e)}addEventListener(t,e,i){this._options.listeners[t].push({listener:e,options:i})}removeEventListener(t,e,i){const n=o=>o.listener!==e||o.options!==i;this._options.listeners[t]=this._options.listeners[t].filter(n)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(w.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(w.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(w.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(w.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(w.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(w.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(w.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(w.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(t,e){const i=this._options.listeners[t],n=[];i.forEach(({listener:o,options:r})=>{o(this,e),(r===void 0||r.once===void 0||!r.once)&&n.push({listener:o,options:r})}),this._options.listeners[t]=n}handleEvent(t,e){switch(t){case w.close:this.dispatchEvent(t,e),this.scheduleConnectionRetryIfNeeded();break;case w.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},n=new CustomEvent(w.reconnect,{detail:i});this.dispatchEvent(w.reconnect,n),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(t,e),this.sendBufferedData();break;case w.retry:this.dispatchEvent(t,e),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(t,e);break}}sendBufferedData(){if(this.buffer!==void 0)for(let t=this.buffer.read();t!==void 0;t=this.buffer.read())this.send(t)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const t=i=>{const n=new CustomEvent(w.retry,{detail:i});this.handleEvent(w.retry,n)},e={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||e.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>t(e),e.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class dd{constructor(t){this._url=t}get url(){return this._url}withProtocols(t){return this._protocols=t,this}get protocols(){return this._protocols}withMaxRetries(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{maxRetries:t})}),this}get maxRetries(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.maxRetries}withInstantReconnect(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{instantReconnect:t})}),this}get instantReconnect(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.instantReconnect}withBackoff(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{backoff:t})}),this}get backoff(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.backoff}withBuffer(t){return this._options=Object.assign(Object.assign({},this._options),{buffer:t}),this}get buffer(){var t;return(t=this._options)===null||t===void 0?void 0:t.buffer}onOpen(t,e){return this.addListener(w.open,t,e),this}onClose(t,e){return this.addListener(w.close,t,e),this}onError(t,e){return this.addListener(w.error,t,e),this}onMessage(t,e){return this.addListener(w.message,t,e),this}onRetry(t,e){return this.addListener(w.retry,t,e),this}onReconnect(t,e){return this.addListener(w.reconnect,t,e),this}build(){return new Lc(this._url,this._protocols,this._options)}addListener(t,e,i){var n,o,r,l,c,a,d,h,u,p,m,b,G,y,Z,V,R,f,x,L,W;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(r=(o=(n=this._options)===null||n===void 0?void 0:n.listeners)===null||o===void 0?void 0:o.open)!==null&&r!==void 0?r:[],close:(a=(c=(l=this._options)===null||l===void 0?void 0:l.listeners)===null||c===void 0?void 0:c.close)!==null&&a!==void 0?a:[],error:(u=(h=(d=this._options)===null||d===void 0?void 0:d.listeners)===null||h===void 0?void 0:h.error)!==null&&u!==void 0?u:[],message:(b=(m=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||m===void 0?void 0:m.message)!==null&&b!==void 0?b:[],retry:(Z=(y=(G=this._options)===null||G===void 0?void 0:G.listeners)===null||y===void 0?void 0:y.retry)!==null&&Z!==void 0?Z:[],reconnect:(f=(R=(V=this._options)===null||V===void 0?void 0:V.listeners)===null||R===void 0?void 0:R.reconnect)!==null&&f!==void 0?f:[],[t]:[...(W=(L=(x=this._options)===null||x===void 0?void 0:x.listeners)===null||L===void 0?void 0:L[t])!==null&&W!==void 0?W:[],{listener:e,options:i}]}}),this}}const hd=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:ld,ConstantBackoff:od,ExponentialBackoff:rd,LinearBackoff:cd,RingQueue:ad,Websocket:Lc,WebsocketBuilder:dd,get WebsocketEvent(){return w}},Symbol.toStringTag,{value:"Module"})),ao=0,Sc=1,Wc=2,ud=0,pd=1,Qn=2,Us=1.25,wn=1,pe=6*4+4+4,sn=65535,md=Math.pow(2,-24),Zn=Symbol("SKIP_GENERATION");function gc(s){return s.index?s.index.count:s.attributes.position.count}function ti(s){return gc(s)/3}function Cc(s,t=ArrayBuffer){return s>65535?new Uint32Array(new t(4*s)):new Uint16Array(new t(2*s))}function bd(s,t){if(!s.index){const e=s.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=Cc(e,i);s.setIndex(new X.BufferAttribute(n,1));for(let o=0;o<e;o++)n[o]=o}}function zc(s,t){const e=ti(s),i=t||s.drawRange,n=i.start/3,o=(i.start+i.count)/3,r=Math.max(0,n),l=Math.min(e,o)-r;return[{offset:Math.floor(r),count:Math.floor(l)}]}function vc(s,t){if(!s.groups||!s.groups.length)return zc(s,t);const e=[],i=new Set,n=t||s.drawRange,o=n.start/3,r=(n.start+n.count)/3;for(const c of s.groups){const a=c.start/3,d=(c.start+c.count)/3;i.add(Math.max(o,a)),i.add(Math.min(r,d))}const l=Array.from(i.values()).sort((c,a)=>c-a);for(let c=0;c<l.length-1;c++){const a=l[c],d=l[c+1];e.push({offset:Math.floor(a),count:Math.floor(d-a)})}return e}function yd(s,t){const e=ti(s),i=vc(s,t).sort((r,l)=>r.offset-l.offset),n=i[i.length-1];n.count=Math.min(e-n.offset,n.count);let o=0;return i.forEach(({count:r})=>o+=r),e!==o}function Xn(s,t,e,i,n){let o=1/0,r=1/0,l=1/0,c=-1/0,a=-1/0,d=-1/0,h=1/0,u=1/0,p=1/0,m=-1/0,b=-1/0,G=-1/0;for(let y=t*6,Z=(t+e)*6;y<Z;y+=6){const V=s[y+0],R=s[y+1],f=V-R,x=V+R;f<o&&(o=f),x>c&&(c=x),V<h&&(h=V),V>m&&(m=V);const L=s[y+2],W=s[y+3],C=L-W,S=L+W;C<r&&(r=C),S>a&&(a=S),L<u&&(u=L),L>b&&(b=L);const z=s[y+4],g=s[y+5],v=z-g,K=z+g;v<l&&(l=v),K>d&&(d=K),z<p&&(p=z),z>G&&(G=z)}i[0]=o,i[1]=r,i[2]=l,i[3]=c,i[4]=a,i[5]=d,n[0]=h,n[1]=u,n[2]=p,n[3]=m,n[4]=b,n[5]=G}function Gd(s,t=null,e=null,i=null){const n=s.attributes.position,o=s.index?s.index.array:null,r=ti(s),l=n.normalized;let c;t===null?(c=new Float32Array(r*6),e=0,i=r):(c=t,e=e||0,i=i||r);const a=n.array,d=n.offset||0;let h=3;n.isInterleavedBufferAttribute&&(h=n.data.stride);const u=["getX","getY","getZ"];for(let p=e;p<e+i;p++){const m=p*3,b=p*6;let G=m+0,y=m+1,Z=m+2;o&&(G=o[G],y=o[y],Z=o[Z]),l||(G=G*h+d,y=y*h+d,Z=Z*h+d);for(let V=0;V<3;V++){let R,f,x;l?(R=n[u[V]](G),f=n[u[V]](y),x=n[u[V]](Z)):(R=a[G+V],f=a[y+V],x=a[Z+V]);let L=R;f<L&&(L=f),x<L&&(L=x);let W=R;f>W&&(W=f),x>W&&(W=x);const C=(W-L)/2,S=V*2;c[b+S+0]=L+C,c[b+S+1]=C+(Math.abs(L)+C)*md}}return c}function B(s,t,e){return e.min.x=t[s],e.min.y=t[s+1],e.min.z=t[s+2],e.max.x=t[s+3],e.max.y=t[s+4],e.max.z=t[s+5],e}function Oo(s){let t=-1,e=-1/0;for(let i=0;i<3;i++){const n=s[i+3]-s[i];n>e&&(e=n,t=i)}return t}function Do(s,t){t.set(s)}function _o(s,t,e){let i,n;for(let o=0;o<3;o++){const r=o+3;i=s[o],n=t[o],e[o]=i<n?i:n,i=s[r],n=t[r],e[r]=i>n?i:n}}function Xs(s,t,e){for(let i=0;i<3;i++){const n=t[s+2*i],o=t[s+2*i+1],r=n-o,l=n+o;r<e[i]&&(e[i]=r),l>e[i+3]&&(e[i+3]=l)}}function li(s){const t=s[3]-s[0],e=s[4]-s[1],i=s[5]-s[2];return 2*(t*e+e*i+i*t)}const $t=32,Zd=(s,t)=>s.candidate-t.candidate,le=new Array($t).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),fs=new Float32Array(6);function Xd(s,t,e,i,n,o){let r=-1,l=0;if(o===ao)r=Oo(t),r!==-1&&(l=(t[r]+t[r+3])/2);else if(o===Sc)r=Oo(s),r!==-1&&(l=fd(e,i,n,r));else if(o===Wc){const c=li(s);let a=Us*n;const d=i*6,h=(i+n)*6;for(let u=0;u<3;u++){const p=t[u],G=(t[u+3]-p)/$t;if(n<$t/4){const y=[...le];y.length=n;let Z=0;for(let R=d;R<h;R+=6,Z++){const f=y[Z];f.candidate=e[R+2*u],f.count=0;const{bounds:x,leftCacheBounds:L,rightCacheBounds:W}=f;for(let C=0;C<3;C++)W[C]=1/0,W[C+3]=-1/0,L[C]=1/0,L[C+3]=-1/0,x[C]=1/0,x[C+3]=-1/0;Xs(R,e,x)}y.sort(Zd);let V=n;for(let R=0;R<V;R++){const f=y[R];for(;R+1<V&&y[R+1].candidate===f.candidate;)y.splice(R+1,1),V--}for(let R=d;R<h;R+=6){const f=e[R+2*u];for(let x=0;x<V;x++){const L=y[x];f>=L.candidate?Xs(R,e,L.rightCacheBounds):(Xs(R,e,L.leftCacheBounds),L.count++)}}for(let R=0;R<V;R++){const f=y[R],x=f.count,L=n-f.count,W=f.leftCacheBounds,C=f.rightCacheBounds;let S=0;x!==0&&(S=li(W)/c);let z=0;L!==0&&(z=li(C)/c);const g=wn+Us*(S*x+z*L);g<a&&(r=u,a=g,l=f.candidate)}}else{for(let V=0;V<$t;V++){const R=le[V];R.count=0,R.candidate=p+G+V*G;const f=R.bounds;for(let x=0;x<3;x++)f[x]=1/0,f[x+3]=-1/0}for(let V=d;V<h;V+=6){let x=~~((e[V+2*u]-p)/G);x>=$t&&(x=$t-1);const L=le[x];L.count++,Xs(V,e,L.bounds)}const y=le[$t-1];Do(y.bounds,y.rightCacheBounds);for(let V=$t-2;V>=0;V--){const R=le[V],f=le[V+1];_o(R.bounds,f.rightCacheBounds,R.rightCacheBounds)}let Z=0;for(let V=0;V<$t-1;V++){const R=le[V],f=R.count,x=R.bounds,W=le[V+1].rightCacheBounds;f!==0&&(Z===0?Do(x,fs):_o(x,fs,fs)),Z+=f;let C=0,S=0;Z!==0&&(C=li(fs)/c);const z=n-Z;z!==0&&(S=li(W)/c);const g=wn+Us*(C*Z+S*z);g<a&&(r=u,a=g,l=R.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${o} used.`);return{axis:r,pos:l}}function fd(s,t,e,i){let n=0;for(let o=t,r=t+e;o<r;o++)n+=s[o*6+i*2];return n/e}class fn{constructor(){this.boundingData=new Float32Array(6)}}function Vd(s,t,e,i,n,o){let r=i,l=i+n-1;const c=o.pos,a=o.axis*2;for(;;){for(;r<=l&&e[r*6+a]<c;)r++;for(;r<=l&&e[l*6+a]>=c;)l--;if(r<l){for(let d=0;d<3;d++){let h=t[r*3+d];t[r*3+d]=t[l*3+d],t[l*3+d]=h}for(let d=0;d<6;d++){let h=e[r*6+d];e[r*6+d]=e[l*6+d],e[l*6+d]=h}r++,l--}else return r}}function Rd(s,t,e,i,n,o){let r=i,l=i+n-1;const c=o.pos,a=o.axis*2;for(;;){for(;r<=l&&e[r*6+a]<c;)r++;for(;r<=l&&e[l*6+a]>=c;)l--;if(r<l){let d=s[r];s[r]=s[l],s[l]=d;for(let h=0;h<6;h++){let u=e[r*6+h];e[r*6+h]=e[l*6+h],e[l*6+h]=u}r++,l--}else return r}}function Zt(s,t){return t[s+15]===65535}function xt(s,t){return t[s+6]}function gt(s,t){return t[s+14]}function zt(s){return s+8}function Ct(s,t){return t[s+6]}function ho(s,t){return t[s+7]}let Kc,xi,Ps,Tc;const xd=Math.pow(2,32);function Bn(s){return"count"in s?1:1+Bn(s.left)+Bn(s.right)}function Ld(s,t,e){return Kc=new Float32Array(e),xi=new Uint32Array(e),Ps=new Uint16Array(e),Tc=new Uint8Array(e),En(s,t)}function En(s,t){const e=s/4,i=s/2,n="count"in t,o=t.boundingData;for(let r=0;r<6;r++)Kc[e+r]=o[r];if(n)if(t.buffer){const r=t.buffer;Tc.set(new Uint8Array(r),s);for(let l=s,c=s+r.byteLength;l<c;l+=pe){const a=l/2;Zt(a,Ps)||(xi[l/4+6]+=e)}return s+r.byteLength}else{const r=t.offset,l=t.count;return xi[e+6]=r,Ps[i+14]=l,Ps[i+15]=sn,s+pe}else{const r=t.left,l=t.right,c=t.splitAxis;let a;if(a=En(s+pe,r),a/4>xd)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return xi[e+6]=a/4,a=En(a,l),xi[e+7]=c,a}}function Sd(s,t){const e=(s.index?s.index.count:s.attributes.position.count)/3,i=e>2**16,n=i?4:2,o=t?new SharedArrayBuffer(e*n):new ArrayBuffer(e*n),r=i?new Uint32Array(o):new Uint16Array(o);for(let l=0,c=r.length;l<c;l++)r[l]=l;return r}function Wd(s,t,e,i,n){const{maxDepth:o,verbose:r,maxLeafTris:l,strategy:c,onProgress:a,indirect:d}=n,h=s._indirectBuffer,u=s.geometry,p=u.index?u.index.array:null,m=d?Rd:Vd,b=ti(u),G=new Float32Array(6);let y=!1;const Z=new fn;return Xn(t,e,i,Z.boundingData,G),R(Z,e,i,G),Z;function V(f){a&&a(f/b)}function R(f,x,L,W=null,C=0){if(!y&&C>=o&&(y=!0,r&&(console.warn(`MeshBVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`),console.warn(u))),L<=l||C>=o)return V(x+L),f.offset=x,f.count=L,f;const S=Xd(f.boundingData,W,t,x,L,c);if(S.axis===-1)return V(x+L),f.offset=x,f.count=L,f;const z=m(h,p,t,x,L,S);if(z===x||z===x+L)V(x+L),f.offset=x,f.count=L;else{f.splitAxis=S.axis;const g=new fn,v=x,K=z-x;f.left=g,Xn(t,v,K,g.boundingData,G),R(g,v,K,G,C+1);const Y=new fn,H=z,I=L-K;f.right=Y,Xn(t,H,I,Y.boundingData,G),R(Y,H,I,G,C+1)}return f}}function gd(s,t){const e=s.geometry;t.indirect&&(s._indirectBuffer=Sd(e,t.useSharedArrayBuffer),yd(e,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),s._indirectBuffer||bd(e,t);const i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=Gd(e),o=t.indirect?zc(e,t.range):vc(e,t.range);s._roots=o.map(r=>{const l=Wd(s,n,r.offset,r.count,t),c=Bn(l),a=new i(pe*c);return Ld(0,l,a),a})}class ne{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,n=-1/0;for(let o=0,r=t.length;o<r;o++){const c=t[o][e];i=c<i?c:i,n=c>n?c:n}this.min=i,this.max=n}setFromPoints(t,e){let i=1/0,n=-1/0;for(let o=0,r=e.length;o<r;o++){const l=e[o],c=t.dot(l);i=c<i?c:i,n=c>n?c:n}this.min=i,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}}ne.prototype.setFromBox=function(){const s=new X.Vector3;return function(e,i){const n=i.min,o=i.max;let r=1/0,l=-1/0;for(let c=0;c<=1;c++)for(let a=0;a<=1;a++)for(let d=0;d<=1;d++){s.x=n.x*c+o.x*(1-c),s.y=n.y*a+o.y*(1-a),s.z=n.z*d+o.z*(1-d);const h=e.dot(s);r=Math.min(h,r),l=Math.max(h,l)}this.min=r,this.max=l}}();const Cd=function(){const s=new X.Vector3,t=new X.Vector3,e=new X.Vector3;return function(n,o,r){const l=n.start,c=s,a=o.start,d=t;e.subVectors(l,a),s.subVectors(n.end,n.start),t.subVectors(o.end,o.start);const h=e.dot(d),u=d.dot(c),p=d.dot(d),m=e.dot(c),G=c.dot(c)*p-u*u;let y,Z;G!==0?y=(h*u-m*p)/G:y=0,Z=(h+y*u)/p,r.x=y,r.y=Z}}(),uo=function(){const s=new X.Vector2,t=new X.Vector3,e=new X.Vector3;return function(n,o,r,l){Cd(n,o,s);let c=s.x,a=s.y;if(c>=0&&c<=1&&a>=0&&a<=1){n.at(c,r),o.at(a,l);return}else if(c>=0&&c<=1){a<0?o.at(0,l):o.at(1,l),n.closestPointToPoint(l,!0,r);return}else if(a>=0&&a<=1){c<0?n.at(0,r):n.at(1,r),o.closestPointToPoint(r,!0,l);return}else{let d;c<0?d=n.start:d=n.end;let h;a<0?h=o.start:h=o.end;const u=t,p=e;if(n.closestPointToPoint(h,!0,t),o.closestPointToPoint(d,!0,e),u.distanceToSquared(h)<=p.distanceToSquared(d)){r.copy(u),l.copy(h);return}else{r.copy(d),l.copy(p);return}}}}(),zd=function(){const s=new X.Vector3,t=new X.Vector3,e=new X.Plane,i=new X.Line3;return function(o,r){const{radius:l,center:c}=o,{a,b:d,c:h}=r;if(i.start=a,i.end=d,i.closestPointToPoint(c,!0,s).distanceTo(c)<=l||(i.start=a,i.end=h,i.closestPointToPoint(c,!0,s).distanceTo(c)<=l)||(i.start=d,i.end=h,i.closestPointToPoint(c,!0,s).distanceTo(c)<=l))return!0;const b=r.getPlane(e);if(Math.abs(b.distanceToPoint(c))<=l){const y=b.projectPoint(c,t);if(r.containsPoint(y))return!0}return!1}}(),vd=1e-15;function Vn(s){return Math.abs(s)<vd}class Kt extends X.Triangle{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new X.Vector3),this.satBounds=new Array(4).fill().map(()=>new ne),this.points=[this.a,this.b,this.c],this.sphere=new X.Sphere,this.plane=new X.Plane,this.needsUpdate=!0}intersectsSphere(t){return zd(t,this)}update(){const t=this.a,e=this.b,i=this.c,n=this.points,o=this.satAxes,r=this.satBounds,l=o[0],c=r[0];this.getNormal(l),c.setFromPoints(l,n);const a=o[1],d=r[1];a.subVectors(t,e),d.setFromPoints(a,n);const h=o[2],u=r[2];h.subVectors(e,i),u.setFromPoints(h,n);const p=o[3],m=r[3];p.subVectors(i,t),m.setFromPoints(p,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(l,t),this.needsUpdate=!1}}Kt.prototype.closestPointToSegment=function(){const s=new X.Vector3,t=new X.Vector3,e=new X.Line3;return function(n,o=null,r=null){const{start:l,end:c}=n,a=this.points;let d,h=1/0;for(let u=0;u<3;u++){const p=(u+1)%3;e.start.copy(a[u]),e.end.copy(a[p]),uo(e,n,s,t),d=s.distanceToSquared(t),d<h&&(h=d,o&&o.copy(s),r&&r.copy(t))}return this.closestPointToPoint(l,s),d=l.distanceToSquared(s),d<h&&(h=d,o&&o.copy(s),r&&r.copy(l)),this.closestPointToPoint(c,s),d=c.distanceToSquared(s),d<h&&(h=d,o&&o.copy(s),r&&r.copy(c)),Math.sqrt(h)}}();Kt.prototype.intersectsTriangle=function(){const s=new Kt,t=new Array(3),e=new Array(3),i=new ne,n=new ne,o=new X.Vector3,r=new X.Vector3,l=new X.Vector3,c=new X.Vector3,a=new X.Vector3,d=new X.Line3,h=new X.Line3,u=new X.Line3,p=new X.Vector3;function m(b,G,y){const Z=b.points;let V=0,R=-1;for(let f=0;f<3;f++){const{start:x,end:L}=d;x.copy(Z[f]),L.copy(Z[(f+1)%3]),d.delta(r);const W=Vn(G.distanceToPoint(x));if(Vn(G.normal.dot(r))&&W){y.copy(d),V=2;break}const C=G.intersectLine(d,p);if(!C&&W&&p.copy(x),(C||W)&&!Vn(p.distanceTo(L))){if(V<=1)(V===1?y.start:y.end).copy(p),W&&(R=V);else if(V>=2){(R===1?y.start:y.end).copy(p),V=2;break}if(V++,V===2&&R===-1)break}}return V}return function(G,y=null,Z=!1){this.needsUpdate&&this.update(),G.isExtendedTriangle?G.needsUpdate&&G.update():(s.copy(G),s.update(),G=s);const V=this.plane,R=G.plane;if(Math.abs(V.normal.dot(R.normal))>1-1e-10){const f=this.satBounds,x=this.satAxes;e[0]=G.a,e[1]=G.b,e[2]=G.c;for(let C=0;C<4;C++){const S=f[C],z=x[C];if(i.setFromPoints(z,e),S.isSeparated(i))return!1}const L=G.satBounds,W=G.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let C=0;C<4;C++){const S=L[C],z=W[C];if(i.setFromPoints(z,t),S.isSeparated(i))return!1}for(let C=0;C<4;C++){const S=x[C];for(let z=0;z<4;z++){const g=W[z];if(o.crossVectors(S,g),i.setFromPoints(o,t),n.setFromPoints(o,e),i.isSeparated(n))return!1}}return y&&(Z||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),y.start.set(0,0,0),y.end.set(0,0,0)),!0}else{const f=m(this,R,h);if(f===1&&G.containsPoint(h.end))return y&&(y.start.copy(h.end),y.end.copy(h.end)),!0;if(f!==2)return!1;const x=m(G,V,u);if(x===1&&this.containsPoint(u.end))return y&&(y.start.copy(u.end),y.end.copy(u.end)),!0;if(x!==2)return!1;if(h.delta(l),u.delta(c),l.dot(c)<0){let v=u.start;u.start=u.end,u.end=v}const L=h.start.dot(l),W=h.end.dot(l),C=u.start.dot(l),S=u.end.dot(l),z=W<C,g=L<S;return L!==S&&C!==W&&z===g?!1:(y&&(a.subVectors(h.start,u.start),a.dot(l)>0?y.start.copy(h.start):y.start.copy(u.start),a.subVectors(h.end,u.end),a.dot(l)<0?y.end.copy(h.end):y.end.copy(u.end)),!0)}}}();Kt.prototype.distanceToPoint=function(){const s=new X.Vector3;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();Kt.prototype.distanceToTriangle=function(){const s=new X.Vector3,t=new X.Vector3,e=["a","b","c"],i=new X.Line3,n=new X.Line3;return function(r,l=null,c=null){const a=l||c?i:null;if(this.intersectsTriangle(r,a))return(l||c)&&(l&&a.getCenter(l),c&&a.getCenter(c)),0;let d=1/0;for(let h=0;h<3;h++){let u;const p=e[h],m=r[p];this.closestPointToPoint(m,s),u=m.distanceToSquared(s),u<d&&(d=u,l&&l.copy(s),c&&c.copy(m));const b=this[p];r.closestPointToPoint(b,s),u=b.distanceToSquared(s),u<d&&(d=u,l&&l.copy(b),c&&c.copy(s))}for(let h=0;h<3;h++){const u=e[h],p=e[(h+1)%3];i.set(this[u],this[p]);for(let m=0;m<3;m++){const b=e[m],G=e[(m+1)%3];n.set(r[b],r[G]),uo(i,n,s,t);const y=s.distanceToSquared(t);y<d&&(d=y,l&&l.copy(s),c&&c.copy(t))}}return Math.sqrt(d)}}();class Gt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new X.Vector3,this.max=new X.Vector3,this.matrix=new X.Matrix4,this.invMatrix=new X.Matrix4,this.points=new Array(8).fill().map(()=>new X.Vector3),this.satAxes=new Array(3).fill().map(()=>new X.Vector3),this.satBounds=new Array(3).fill().map(()=>new ne),this.alignedSatBounds=new Array(3).fill().map(()=>new ne),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}Gt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,n=this.points;for(let a=0;a<=1;a++)for(let d=0;d<=1;d++)for(let h=0;h<=1;h++){const u=1*a|2*d|4*h,p=n[u];p.x=a?i.x:e.x,p.y=d?i.y:e.y,p.z=h?i.z:e.z,p.applyMatrix4(t)}const o=this.satBounds,r=this.satAxes,l=n[0];for(let a=0;a<3;a++){const d=r[a],h=o[a],u=1<<a,p=n[u];d.subVectors(l,p),h.setFromPoints(d,n)}const c=this.alignedSatBounds;c[0].setFromPointsField(n,"x"),c[1].setFromPointsField(n,"y"),c[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Gt.prototype.intersectsBox=function(){const s=new ne;return function(e){this.needsUpdate&&this.update();const i=e.min,n=e.max,o=this.satBounds,r=this.satAxes,l=this.alignedSatBounds;if(s.min=i.x,s.max=n.x,l[0].isSeparated(s)||(s.min=i.y,s.max=n.y,l[1].isSeparated(s))||(s.min=i.z,s.max=n.z,l[2].isSeparated(s)))return!1;for(let c=0;c<3;c++){const a=r[c],d=o[c];if(s.setFromBox(a,e),d.isSeparated(s))return!1}return!0}}();Gt.prototype.intersectsTriangle=function(){const s=new Kt,t=new Array(3),e=new ne,i=new ne,n=new X.Vector3;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(s.copy(r),s.update(),r=s);const l=this.satBounds,c=this.satAxes;t[0]=r.a,t[1]=r.b,t[2]=r.c;for(let u=0;u<3;u++){const p=l[u],m=c[u];if(e.setFromPoints(m,t),p.isSeparated(e))return!1}const a=r.satBounds,d=r.satAxes,h=this.points;for(let u=0;u<3;u++){const p=a[u],m=d[u];if(e.setFromPoints(m,h),p.isSeparated(e))return!1}for(let u=0;u<3;u++){const p=c[u];for(let m=0;m<4;m++){const b=d[m];if(n.crossVectors(p,b),e.setFromPoints(n,t),i.setFromPoints(n,h),e.isSeparated(i))return!1}}return!0}}();Gt.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Gt.prototype.distanceToPoint=function(){const s=new X.Vector3;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();Gt.prototype.distanceToBox=function(){const s=["x","y","z"],t=new Array(12).fill().map(()=>new X.Line3),e=new Array(12).fill().map(()=>new X.Line3),i=new X.Vector3,n=new X.Vector3;return function(r,l=0,c=null,a=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(c||a)&&(r.getCenter(n),this.closestPointToPoint(n,i),r.closestPointToPoint(i,n),c&&c.copy(i),a&&a.copy(n)),0;const d=l*l,h=r.min,u=r.max,p=this.points;let m=1/0;for(let G=0;G<8;G++){const y=p[G];n.copy(y).clamp(h,u);const Z=y.distanceToSquared(n);if(Z<m&&(m=Z,c&&c.copy(y),a&&a.copy(n),Z<d))return Math.sqrt(Z)}let b=0;for(let G=0;G<3;G++)for(let y=0;y<=1;y++)for(let Z=0;Z<=1;Z++){const V=(G+1)%3,R=(G+2)%3,f=y<<V|Z<<R,x=1<<G|y<<V|Z<<R,L=p[f],W=p[x];t[b].set(L,W);const S=s[G],z=s[V],g=s[R],v=e[b],K=v.start,Y=v.end;K[S]=h[S],K[z]=y?h[z]:u[z],K[g]=Z?h[g]:u[z],Y[S]=u[S],Y[z]=y?h[z]:u[z],Y[g]=Z?h[g]:u[z],b++}for(let G=0;G<=1;G++)for(let y=0;y<=1;y++)for(let Z=0;Z<=1;Z++){n.x=G?u.x:h.x,n.y=y?u.y:h.y,n.z=Z?u.z:h.z,this.closestPointToPoint(n,i);const V=n.distanceToSquared(i);if(V<m&&(m=V,c&&c.copy(i),a&&a.copy(n),V<d))return Math.sqrt(V)}for(let G=0;G<12;G++){const y=t[G];for(let Z=0;Z<12;Z++){const V=e[Z];uo(y,V,i,n);const R=i.distanceToSquared(n);if(R<m&&(m=R,c&&c.copy(i),a&&a.copy(n),R<d))return Math.sqrt(R)}}return Math.sqrt(m)}}();class po{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class Kd extends po{constructor(){super(()=>new Kt)}}const vt=new Kd;class Td{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const E=new Td;let ue,Oe;const Je=[],Vs=new po(()=>new X.Box3);function Md(s,t,e,i,n,o){ue=Vs.getPrimitive(),Oe=Vs.getPrimitive(),Je.push(ue,Oe),E.setBuffer(s._roots[t]);const r=jn(0,s.geometry,e,i,n,o);E.clearBuffer(),Vs.releasePrimitive(ue),Vs.releasePrimitive(Oe),Je.pop(),Je.pop();const l=Je.length;return l>0&&(Oe=Je[l-1],ue=Je[l-2]),r}function jn(s,t,e,i,n=null,o=0,r=0){const{float32Array:l,uint16Array:c,uint32Array:a}=E;let d=s*2;if(Zt(d,c)){const u=xt(s,a),p=gt(d,c);return B(s,l,ue),i(u,p,!1,r,o+s,ue)}else{let S=function(g){const{uint16Array:v,uint32Array:K}=E;let Y=g*2;for(;!Zt(Y,v);)g=zt(g),Y=g*2;return xt(g,K)},z=function(g){const{uint16Array:v,uint32Array:K}=E;let Y=g*2;for(;!Zt(Y,v);)g=Ct(g,K),Y=g*2;return xt(g,K)+gt(Y,v)};const u=zt(s),p=Ct(s,a);let m=u,b=p,G,y,Z,V;if(n&&(Z=ue,V=Oe,B(m,l,Z),B(b,l,V),G=n(Z),y=n(V),y<G)){m=p,b=u;const g=G;G=y,y=g,Z=V}Z||(Z=ue,B(m,l,Z));const R=Zt(m*2,c),f=e(Z,R,G,r+1,o+m);let x;if(f===Qn){const g=S(m),K=z(m)-g;x=i(g,K,!0,r+1,o+m,Z)}else x=f&&jn(m,t,e,i,n,o,r+1);if(x)return!0;V=Oe,B(b,l,V);const L=Zt(b*2,c),W=e(V,L,y,r+1,o+b);let C;if(W===Qn){const g=S(b),K=z(b)-g;C=i(g,K,!0,r+1,o+b,V)}else C=W&&jn(b,t,e,i,n,o,r+1);return!!C}}const ai=new X.Vector3,Rn=new X.Vector3;function Yd(s,t,e={},i=0,n=1/0){const o=i*i,r=n*n;let l=1/0,c=null;if(s.shapecast({boundsTraverseOrder:d=>(ai.copy(t).clamp(d.min,d.max),ai.distanceToSquared(t)),intersectsBounds:(d,h,u)=>u<l&&u<r,intersectsTriangle:(d,h)=>{d.closestPointToPoint(t,ai);const u=t.distanceToSquared(ai);return u<l&&(Rn.copy(ai),l=u,c=h),u<o}}),l===1/0)return null;const a=Math.sqrt(l);return e.point?e.point.copy(Rn):e.point=Rn.clone(),e.distance=a,e.faceIndex=c,e}const kd=parseInt(X.REVISION)>=169,ge=new X.Vector3,Ce=new X.Vector3,ze=new X.Vector3,Rs=new X.Vector2,xs=new X.Vector2,Ls=new X.Vector2,Ao=new X.Vector3,qo=new X.Vector3,$o=new X.Vector3,di=new X.Vector3;function Hd(s,t,e,i,n,o,r,l){let c;if(o===X.BackSide?c=s.intersectTriangle(i,e,t,!0,n):c=s.intersectTriangle(t,e,i,o!==X.DoubleSide,n),c===null)return null;const a=s.origin.distanceTo(n);return a<r||a>l?null:{distance:a,point:n.clone()}}function Nd(s,t,e,i,n,o,r,l,c,a,d){ge.fromBufferAttribute(t,o),Ce.fromBufferAttribute(t,r),ze.fromBufferAttribute(t,l);const h=Hd(s,ge,Ce,ze,di,c,a,d);if(h){const u=new X.Vector3;X.Triangle.getBarycoord(di,ge,Ce,ze,u),i&&(Rs.fromBufferAttribute(i,o),xs.fromBufferAttribute(i,r),Ls.fromBufferAttribute(i,l),h.uv=X.Triangle.getInterpolation(di,ge,Ce,ze,Rs,xs,Ls,new X.Vector2)),n&&(Rs.fromBufferAttribute(n,o),xs.fromBufferAttribute(n,r),Ls.fromBufferAttribute(n,l),h.uv1=X.Triangle.getInterpolation(di,ge,Ce,ze,Rs,xs,Ls,new X.Vector2)),e&&(Ao.fromBufferAttribute(e,o),qo.fromBufferAttribute(e,r),$o.fromBufferAttribute(e,l),h.normal=X.Triangle.getInterpolation(di,ge,Ce,ze,Ao,qo,$o,new X.Vector3),h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:r,c:l,normal:new X.Vector3,materialIndex:0};X.Triangle.getNormal(ge,Ce,ze,p.normal),h.face=p,h.faceIndex=o,kd&&(h.barycoord=u)}return h}function nn(s,t,e,i,n,o,r){const l=i*3;let c=l+0,a=l+1,d=l+2;const h=s.index;s.index&&(c=h.getX(c),a=h.getX(a),d=h.getX(d));const{position:u,normal:p,uv:m,uv1:b}=s.attributes,G=Nd(e,u,p,m,b,c,a,d,t,o,r);return G?(G.faceIndex=i,n&&n.push(G),G):null}function $(s,t,e,i){const n=s.a,o=s.b,r=s.c;let l=t,c=t+1,a=t+2;e&&(l=e.getX(l),c=e.getX(c),a=e.getX(a)),n.x=i.getX(l),n.y=i.getY(l),n.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a)}const hi=new X.Vector3,ui=new X.Vector3,pi=new X.Vector3,tr=new X.Vector2,er=new X.Vector2,ir=new X.Vector2;function Id(s,t,e,i){const n=t.getIndex().array,o=t.getAttribute("position"),r=t.getAttribute("uv"),l=n[e*3],c=n[e*3+1],a=n[e*3+2];hi.fromBufferAttribute(o,l),ui.fromBufferAttribute(o,c),pi.fromBufferAttribute(o,a);let d=0;const h=t.groups,u=e*3;for(let b=0,G=h.length;b<G;b++){const y=h[b],{start:Z,count:V}=y;if(u>=Z&&u<Z+V){d=y.materialIndex;break}}const p=i&&i.barycoord?i.barycoord:new X.Vector3;X.Triangle.getBarycoord(s,hi,ui,pi,p);let m=null;return r&&(tr.fromBufferAttribute(r,l),er.fromBufferAttribute(r,c),ir.fromBufferAttribute(r,a),i&&i.uv?m=i.uv:m=new X.Vector2,X.Triangle.getInterpolation(s,hi,ui,pi,tr,er,ir,m)),i?(i.face||(i.face={}),i.face.a=l,i.face.b=c,i.face.c=a,i.face.materialIndex=d,i.face.normal||(i.face.normal=new X.Vector3),X.Triangle.getNormal(hi,ui,pi,i.face.normal),m&&(i.uv=m),i.barycoord=p,i):{face:{a:l,b:c,c:a,materialIndex:d,normal:X.Triangle.getNormal(hi,ui,pi,new X.Vector3)},uv:m,barycoord:p}}function Jd(s,t,e,i,n,o,r,l){const{geometry:c,_indirectBuffer:a}=s;for(let d=i,h=i+n;d<h;d++)nn(c,t,e,d,o,r,l)}function Ud(s,t,e,i,n,o,r){const{geometry:l,_indirectBuffer:c}=s;let a=1/0,d=null;for(let h=i,u=i+n;h<u;h++){let p;p=nn(l,t,e,h,null,o,r),p&&p.distance<a&&(d=p,a=p.distance)}return d}function Pd(s,t,e,i,n,o,r){const{geometry:l}=e,{index:c}=l,a=l.attributes.position;for(let d=s,h=t+s;d<h;d++){let u;if(u=d,$(r,u*3,c,a),r.needsUpdate=!0,i(r,u,n,o))return!0}return!1}function Fd(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=s.geometry,i=e.index?e.index.array:null,n=e.attributes.position;let o,r,l,c,a=0;const d=s._roots;for(let u=0,p=d.length;u<p;u++)o=d[u],r=new Uint32Array(o),l=new Uint16Array(o),c=new Float32Array(o),h(0,a),a+=o.byteLength;function h(u,p,m=!1){const b=u*2;if(l[b+15]===sn){const y=r[u+6],Z=l[b+14];let V=1/0,R=1/0,f=1/0,x=-1/0,L=-1/0,W=-1/0;for(let C=3*y,S=3*(y+Z);C<S;C++){let z=i[C];const g=n.getX(z),v=n.getY(z),K=n.getZ(z);g<V&&(V=g),g>x&&(x=g),v<R&&(R=v),v>L&&(L=v),K<f&&(f=K),K>W&&(W=K)}return c[u+0]!==V||c[u+1]!==R||c[u+2]!==f||c[u+3]!==x||c[u+4]!==L||c[u+5]!==W?(c[u+0]=V,c[u+1]=R,c[u+2]=f,c[u+3]=x,c[u+4]=L,c[u+5]=W,!0):!1}else{const y=u+8,Z=r[u+6],V=y+p,R=Z+p;let f=m,x=!1,L=!1;t?f||(x=t.has(V),L=t.has(R),f=!x&&!L):(x=!0,L=!0);const W=f||x,C=f||L;let S=!1;W&&(S=h(y,p,f));let z=!1;C&&(z=h(Z,p,f));const g=S||z;if(g)for(let v=0;v<3;v++){const K=y+v,Y=Z+v,H=c[K],I=c[K+3],P=c[Y],D=c[Y+3];c[u+v]=H<P?H:P,c[u+v+3]=I>D?I:D}return g}}}function me(s,t,e,i,n){let o,r,l,c,a,d;const h=1/e.direction.x,u=1/e.direction.y,p=1/e.direction.z,m=e.origin.x,b=e.origin.y,G=e.origin.z;let y=t[s],Z=t[s+3],V=t[s+1],R=t[s+3+1],f=t[s+2],x=t[s+3+2];return h>=0?(o=(y-m)*h,r=(Z-m)*h):(o=(Z-m)*h,r=(y-m)*h),u>=0?(l=(V-b)*u,c=(R-b)*u):(l=(R-b)*u,c=(V-b)*u),o>c||l>r||((l>o||isNaN(o))&&(o=l),(c<r||isNaN(r))&&(r=c),p>=0?(a=(f-G)*p,d=(x-G)*p):(a=(x-G)*p,d=(f-G)*p),o>d||a>r)?!1:((a>o||o!==o)&&(o=a),(d<r||r!==r)&&(r=d),o<=n&&r>=i)}function Qd(s,t,e,i,n,o,r,l){const{geometry:c,_indirectBuffer:a}=s;for(let d=i,h=i+n;d<h;d++){let u=a?a[d]:d;nn(c,t,e,u,o,r,l)}}function wd(s,t,e,i,n,o,r){const{geometry:l,_indirectBuffer:c}=s;let a=1/0,d=null;for(let h=i,u=i+n;h<u;h++){let p;p=nn(l,t,e,c?c[h]:h,null,o,r),p&&p.distance<a&&(d=p,a=p.distance)}return d}function Bd(s,t,e,i,n,o,r){const{geometry:l}=e,{index:c}=l,a=l.attributes.position;for(let d=s,h=t+s;d<h;d++){let u;if(u=e.resolveTriangleIndex(d),$(r,u*3,c,a),r.needsUpdate=!0,i(r,u,n,o))return!0}return!1}function Ed(s,t,e,i,n,o,r){E.setBuffer(s._roots[t]),On(0,s,e,i,n,o,r),E.clearBuffer()}function On(s,t,e,i,n,o,r){const{float32Array:l,uint16Array:c,uint32Array:a}=E,d=s*2;if(Zt(d,c)){const u=xt(s,a),p=gt(d,c);Jd(t,e,i,u,p,n,o,r)}else{const u=zt(s);me(u,l,i,o,r)&&On(u,t,e,i,n,o,r);const p=Ct(s,a);me(p,l,i,o,r)&&On(p,t,e,i,n,o,r)}}const jd=["x","y","z"];function Od(s,t,e,i,n,o){E.setBuffer(s._roots[t]);const r=Dn(0,s,e,i,n,o);return E.clearBuffer(),r}function Dn(s,t,e,i,n,o){const{float32Array:r,uint16Array:l,uint32Array:c}=E;let a=s*2;if(Zt(a,l)){const h=xt(s,c),u=gt(a,l);return Ud(t,e,i,h,u,n,o)}else{const h=ho(s,c),u=jd[h],m=i.direction[u]>=0;let b,G;m?(b=zt(s),G=Ct(s,c)):(b=Ct(s,c),G=zt(s));const Z=me(b,r,i,n,o)?Dn(b,t,e,i,n,o):null;if(Z){const f=Z.point[u];if(m?f<=r[G+h]:f>=r[G+h+3])return Z}const R=me(G,r,i,n,o)?Dn(G,t,e,i,n,o):null;return Z&&R?Z.distance<=R.distance?Z:R:Z||R||null}}const Ss=new X.Box3,Ue=new Kt,Pe=new Kt,mi=new X.Matrix4,sr=new Gt,Ws=new Gt;function Dd(s,t,e,i){E.setBuffer(s._roots[t]);const n=_n(0,s,e,i);return E.clearBuffer(),n}function _n(s,t,e,i,n=null){const{float32Array:o,uint16Array:r,uint32Array:l}=E;let c=s*2;if(n===null&&(e.boundingBox||e.computeBoundingBox(),sr.set(e.boundingBox.min,e.boundingBox.max,i),n=sr),Zt(c,r)){const d=t.geometry,h=d.index,u=d.attributes.position,p=e.index,m=e.attributes.position,b=xt(s,l),G=gt(c,r);if(mi.copy(i).invert(),e.boundsTree)return B(s,o,Ws),Ws.matrix.copy(mi),Ws.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:Z=>Ws.intersectsBox(Z),intersectsTriangle:Z=>{Z.a.applyMatrix4(i),Z.b.applyMatrix4(i),Z.c.applyMatrix4(i),Z.needsUpdate=!0;for(let V=b*3,R=(G+b)*3;V<R;V+=3)if($(Pe,V,h,u),Pe.needsUpdate=!0,Z.intersectsTriangle(Pe))return!0;return!1}});for(let y=b*3,Z=(G+b)*3;y<Z;y+=3){$(Ue,y,h,u),Ue.a.applyMatrix4(mi),Ue.b.applyMatrix4(mi),Ue.c.applyMatrix4(mi),Ue.needsUpdate=!0;for(let V=0,R=p.count;V<R;V+=3)if($(Pe,V,p,m),Pe.needsUpdate=!0,Ue.intersectsTriangle(Pe))return!0}}else{const d=s+8,h=l[s+6];return B(d,o,Ss),!!(n.intersectsBox(Ss)&&_n(d,t,e,i,n)||(B(h,o,Ss),n.intersectsBox(Ss)&&_n(h,t,e,i,n)))}}const gs=new X.Matrix4,xn=new Gt,bi=new Gt,_d=new X.Vector3,Ad=new X.Vector3,qd=new X.Vector3,$d=new X.Vector3;function th(s,t,e,i={},n={},o=0,r=1/0){t.boundingBox||t.computeBoundingBox(),xn.set(t.boundingBox.min,t.boundingBox.max,e),xn.needsUpdate=!0;const l=s.geometry,c=l.attributes.position,a=l.index,d=t.attributes.position,h=t.index,u=vt.getPrimitive(),p=vt.getPrimitive();let m=_d,b=Ad,G=null,y=null;n&&(G=qd,y=$d);let Z=1/0,V=null,R=null;return gs.copy(e).invert(),bi.matrix.copy(gs),s.shapecast({boundsTraverseOrder:f=>xn.distanceToBox(f),intersectsBounds:(f,x,L)=>L<Z&&L<r?(x&&(bi.min.copy(f.min),bi.max.copy(f.max),bi.needsUpdate=!0),!0):!1,intersectsRange:(f,x)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:W=>bi.distanceToBox(W),intersectsBounds:(W,C,S)=>S<Z&&S<r,intersectsRange:(W,C)=>{for(let S=W,z=W+C;S<z;S++){$(p,3*S,h,d),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let g=f,v=f+x;g<v;g++){$(u,3*g,a,c),u.needsUpdate=!0;const K=u.distanceToTriangle(p,m,G);if(K<Z&&(b.copy(m),y&&y.copy(G),Z=K,V=g,R=S),K<o)return!0}}}});{const L=ti(t);for(let W=0,C=L;W<C;W++){$(p,3*W,h,d),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let S=f,z=f+x;S<z;S++){$(u,3*S,a,c),u.needsUpdate=!0;const g=u.distanceToTriangle(p,m,G);if(g<Z&&(b.copy(m),y&&y.copy(G),Z=g,V=S,R=W),g<o)return!0}}}}}),vt.releasePrimitive(u),vt.releasePrimitive(p),Z===1/0?null:(i.point?i.point.copy(b):i.point=b.clone(),i.distance=Z,i.faceIndex=V,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(gs),b.applyMatrix4(gs),n.distance=b.sub(n.point).length(),n.faceIndex=R),i)}function eh(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=s.geometry,i=e.index?e.index.array:null,n=e.attributes.position;let o,r,l,c,a=0;const d=s._roots;for(let u=0,p=d.length;u<p;u++)o=d[u],r=new Uint32Array(o),l=new Uint16Array(o),c=new Float32Array(o),h(0,a),a+=o.byteLength;function h(u,p,m=!1){const b=u*2;if(l[b+15]===sn){const y=r[u+6],Z=l[b+14];let V=1/0,R=1/0,f=1/0,x=-1/0,L=-1/0,W=-1/0;for(let C=y,S=y+Z;C<S;C++){const z=3*s.resolveTriangleIndex(C);for(let g=0;g<3;g++){let v=z+g;v=i?i[v]:v;const K=n.getX(v),Y=n.getY(v),H=n.getZ(v);K<V&&(V=K),K>x&&(x=K),Y<R&&(R=Y),Y>L&&(L=Y),H<f&&(f=H),H>W&&(W=H)}}return c[u+0]!==V||c[u+1]!==R||c[u+2]!==f||c[u+3]!==x||c[u+4]!==L||c[u+5]!==W?(c[u+0]=V,c[u+1]=R,c[u+2]=f,c[u+3]=x,c[u+4]=L,c[u+5]=W,!0):!1}else{const y=u+8,Z=r[u+6],V=y+p,R=Z+p;let f=m,x=!1,L=!1;t?f||(x=t.has(V),L=t.has(R),f=!x&&!L):(x=!0,L=!0);const W=f||x,C=f||L;let S=!1;W&&(S=h(y,p,f));let z=!1;C&&(z=h(Z,p,f));const g=S||z;if(g)for(let v=0;v<3;v++){const K=y+v,Y=Z+v,H=c[K],I=c[K+3],P=c[Y],D=c[Y+3];c[u+v]=H<P?H:P,c[u+v+3]=I>D?I:D}return g}}}function ih(s,t,e,i,n,o,r){E.setBuffer(s._roots[t]),An(0,s,e,i,n,o,r),E.clearBuffer()}function An(s,t,e,i,n,o,r){const{float32Array:l,uint16Array:c,uint32Array:a}=E,d=s*2;if(Zt(d,c)){const u=xt(s,a),p=gt(d,c);Qd(t,e,i,u,p,n,o,r)}else{const u=zt(s);me(u,l,i,o,r)&&An(u,t,e,i,n,o,r);const p=Ct(s,a);me(p,l,i,o,r)&&An(p,t,e,i,n,o,r)}}const sh=["x","y","z"];function nh(s,t,e,i,n,o){E.setBuffer(s._roots[t]);const r=qn(0,s,e,i,n,o);return E.clearBuffer(),r}function qn(s,t,e,i,n,o){const{float32Array:r,uint16Array:l,uint32Array:c}=E;let a=s*2;if(Zt(a,l)){const h=xt(s,c),u=gt(a,l);return wd(t,e,i,h,u,n,o)}else{const h=ho(s,c),u=sh[h],m=i.direction[u]>=0;let b,G;m?(b=zt(s),G=Ct(s,c)):(b=Ct(s,c),G=zt(s));const Z=me(b,r,i,n,o)?qn(b,t,e,i,n,o):null;if(Z){const f=Z.point[u];if(m?f<=r[G+h]:f>=r[G+h+3])return Z}const R=me(G,r,i,n,o)?qn(G,t,e,i,n,o):null;return Z&&R?Z.distance<=R.distance?Z:R:Z||R||null}}const Cs=new X.Box3,Fe=new Kt,Qe=new Kt,yi=new X.Matrix4,nr=new Gt,zs=new Gt;function oh(s,t,e,i){E.setBuffer(s._roots[t]);const n=$n(0,s,e,i);return E.clearBuffer(),n}function $n(s,t,e,i,n=null){const{float32Array:o,uint16Array:r,uint32Array:l}=E;let c=s*2;if(n===null&&(e.boundingBox||e.computeBoundingBox(),nr.set(e.boundingBox.min,e.boundingBox.max,i),n=nr),Zt(c,r)){const d=t.geometry,h=d.index,u=d.attributes.position,p=e.index,m=e.attributes.position,b=xt(s,l),G=gt(c,r);if(yi.copy(i).invert(),e.boundsTree)return B(s,o,zs),zs.matrix.copy(yi),zs.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:Z=>zs.intersectsBox(Z),intersectsTriangle:Z=>{Z.a.applyMatrix4(i),Z.b.applyMatrix4(i),Z.c.applyMatrix4(i),Z.needsUpdate=!0;for(let V=b,R=G+b;V<R;V++)if($(Qe,3*t.resolveTriangleIndex(V),h,u),Qe.needsUpdate=!0,Z.intersectsTriangle(Qe))return!0;return!1}});for(let y=b,Z=G+b;y<Z;y++){const V=t.resolveTriangleIndex(y);$(Fe,3*V,h,u),Fe.a.applyMatrix4(yi),Fe.b.applyMatrix4(yi),Fe.c.applyMatrix4(yi),Fe.needsUpdate=!0;for(let R=0,f=p.count;R<f;R+=3)if($(Qe,R,p,m),Qe.needsUpdate=!0,Fe.intersectsTriangle(Qe))return!0}}else{const d=s+8,h=l[s+6];return B(d,o,Cs),!!(n.intersectsBox(Cs)&&$n(d,t,e,i,n)||(B(h,o,Cs),n.intersectsBox(Cs)&&$n(h,t,e,i,n)))}}const vs=new X.Matrix4,Ln=new Gt,Gi=new Gt,rh=new X.Vector3,ch=new X.Vector3,lh=new X.Vector3,ah=new X.Vector3;function dh(s,t,e,i={},n={},o=0,r=1/0){t.boundingBox||t.computeBoundingBox(),Ln.set(t.boundingBox.min,t.boundingBox.max,e),Ln.needsUpdate=!0;const l=s.geometry,c=l.attributes.position,a=l.index,d=t.attributes.position,h=t.index,u=vt.getPrimitive(),p=vt.getPrimitive();let m=rh,b=ch,G=null,y=null;n&&(G=lh,y=ah);let Z=1/0,V=null,R=null;return vs.copy(e).invert(),Gi.matrix.copy(vs),s.shapecast({boundsTraverseOrder:f=>Ln.distanceToBox(f),intersectsBounds:(f,x,L)=>L<Z&&L<r?(x&&(Gi.min.copy(f.min),Gi.max.copy(f.max),Gi.needsUpdate=!0),!0):!1,intersectsRange:(f,x)=>{if(t.boundsTree){const L=t.boundsTree;return L.shapecast({boundsTraverseOrder:W=>Gi.distanceToBox(W),intersectsBounds:(W,C,S)=>S<Z&&S<r,intersectsRange:(W,C)=>{for(let S=W,z=W+C;S<z;S++){const g=L.resolveTriangleIndex(S);$(p,3*g,h,d),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let v=f,K=f+x;v<K;v++){const Y=s.resolveTriangleIndex(v);$(u,3*Y,a,c),u.needsUpdate=!0;const H=u.distanceToTriangle(p,m,G);if(H<Z&&(b.copy(m),y&&y.copy(G),Z=H,V=v,R=S),H<o)return!0}}}})}else{const L=ti(t);for(let W=0,C=L;W<C;W++){$(p,3*W,h,d),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let S=f,z=f+x;S<z;S++){const g=s.resolveTriangleIndex(S);$(u,3*g,a,c),u.needsUpdate=!0;const v=u.distanceToTriangle(p,m,G);if(v<Z&&(b.copy(m),y&&y.copy(G),Z=v,V=S,R=W),v<o)return!0}}}}}),vt.releasePrimitive(u),vt.releasePrimitive(p),Z===1/0?null:(i.point?i.point.copy(b):i.point=b.clone(),i.distance=Z,i.faceIndex=V,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(vs),b.applyMatrix4(vs),n.distance=b.sub(n.point).length(),n.faceIndex=R),i)}function Mc(){return typeof SharedArrayBuffer<"u"}const Wi=new E.constructor,As=new E.constructor,de=new po(()=>new X.Box3),we=new X.Box3,Be=new X.Box3,Sn=new X.Box3,Wn=new X.Box3;let gn=!1;function hh(s,t,e,i){if(gn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");gn=!0;const n=s._roots,o=t._roots;let r,l=0,c=0;const a=new X.Matrix4().copy(e).invert();for(let d=0,h=n.length;d<h;d++){Wi.setBuffer(n[d]),c=0;const u=de.getPrimitive();B(0,Wi.float32Array,u),u.applyMatrix4(a);for(let p=0,m=o.length;p<m&&(As.setBuffer(o[p]),r=Nt(0,0,e,a,i,l,c,0,0,u),As.clearBuffer(),c+=o[p].length,!r);p++);if(de.releasePrimitive(u),Wi.clearBuffer(),l+=n[d].length,r)break}return gn=!1,r}function Nt(s,t,e,i,n,o=0,r=0,l=0,c=0,a=null,d=!1){let h,u;d?(h=As,u=Wi):(h=Wi,u=As);const p=h.float32Array,m=h.uint32Array,b=h.uint16Array,G=u.float32Array,y=u.uint32Array,Z=u.uint16Array,V=s*2,R=t*2,f=Zt(V,b),x=Zt(R,Z);let L=!1;if(x&&f)d?L=n(xt(t,y),gt(t*2,Z),xt(s,m),gt(s*2,b),c,r+t,l,o+s):L=n(xt(s,m),gt(s*2,b),xt(t,y),gt(t*2,Z),l,o+s,c,r+t);else if(x){const W=de.getPrimitive();B(t,G,W),W.applyMatrix4(e);const C=zt(s),S=Ct(s,m);B(C,p,we),B(S,p,Be);const z=W.intersectsBox(we),g=W.intersectsBox(Be);L=z&&Nt(t,C,i,e,n,r,o,c,l+1,W,!d)||g&&Nt(t,S,i,e,n,r,o,c,l+1,W,!d),de.releasePrimitive(W)}else{const W=zt(t),C=Ct(t,y);B(W,G,Sn),B(C,G,Wn);const S=a.intersectsBox(Sn),z=a.intersectsBox(Wn);if(S&&z)L=Nt(s,W,e,i,n,o,r,l,c+1,a,d)||Nt(s,C,e,i,n,o,r,l,c+1,a,d);else if(S)if(f)L=Nt(s,W,e,i,n,o,r,l,c+1,a,d);else{const g=de.getPrimitive();g.copy(Sn).applyMatrix4(e);const v=zt(s),K=Ct(s,m);B(v,p,we),B(K,p,Be);const Y=g.intersectsBox(we),H=g.intersectsBox(Be);L=Y&&Nt(W,v,i,e,n,r,o,c,l+1,g,!d)||H&&Nt(W,K,i,e,n,r,o,c,l+1,g,!d),de.releasePrimitive(g)}else if(z)if(f)L=Nt(s,C,e,i,n,o,r,l,c+1,a,d);else{const g=de.getPrimitive();g.copy(Wn).applyMatrix4(e);const v=zt(s),K=Ct(s,m);B(v,p,we),B(K,p,Be);const Y=g.intersectsBox(we),H=g.intersectsBox(Be);L=Y&&Nt(C,v,i,e,n,r,o,c,l+1,g,!d)||H&&Nt(C,K,i,e,n,r,o,c,l+1,g,!d),de.releasePrimitive(g)}}return L}const Ks=new Gt,or=new X.Box3,uh={strategy:ao,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class be{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,n=t._roots,o=t._indirectBuffer,r=i.getIndex();let l;return e.cloneBuffers?l={roots:n.map(c=>c.slice()),index:r?r.array.slice():null,indirectBuffer:o?o.slice():null}:l={roots:n,index:r?r.array:null,indirectBuffer:o},l}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:n,roots:o,indirectBuffer:r}=t,l=new be(e,{...i,[Zn]:!0});if(l._roots=o,l._indirectBuffer=r||null,i.setIndex){const c=e.getIndex();if(c===null){const a=new X.BufferAttribute(t.index,1,!1);e.setIndex(a)}else c.array!==n&&(c.array.set(n),c.needsUpdate=!0)}return l}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({...uh,[Zn]:!1},e),e.useSharedArrayBuffer&&!Mc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[Zn]||(gd(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new X.Box3))),this.resolveTriangleIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i}refit(t=null){return(this.indirect?eh:Fd)(this,t)}traverse(t,e=0){const i=this._roots[e],n=new Uint32Array(i),o=new Uint16Array(i);r(0);function r(l,c=0){const a=l*2,d=o[a+15]===sn;if(d){const h=n[l+6],u=o[a+14];t(c,d,new Float32Array(i,l*4,6),h,u)}else{const h=l+pe/4,u=n[l+6],p=n[l+7];t(c,d,new Float32Array(i,l*4,6),p)||(r(h,c+1),r(u,c+1))}}}raycast(t,e=X.FrontSide,i=0,n=1/0){const o=this._roots,r=this.geometry,l=[],c=e.isMaterial,a=Array.isArray(e),d=r.groups,h=c?e.side:e,u=this.indirect?ih:Ed;for(let p=0,m=o.length;p<m;p++){const b=a?e[d[p].materialIndex].side:h,G=l.length;if(u(this,p,b,t,l,i,n),a){const y=d[p].materialIndex;for(let Z=G,V=l.length;Z<V;Z++)l[Z].face.materialIndex=y}}return l}raycastFirst(t,e=X.FrontSide,i=0,n=1/0){const o=this._roots,r=this.geometry,l=e.isMaterial,c=Array.isArray(e);let a=null;const d=r.groups,h=l?e.side:e,u=this.indirect?nh:Od;for(let p=0,m=o.length;p<m;p++){const b=c?e[d[p].materialIndex].side:h,G=u(this,p,b,t,i,n);G!=null&&(a==null||G.distance<a.distance)&&(a=G,c&&(G.face.materialIndex=d[p].materialIndex))}return a}intersectsGeometry(t,e){let i=!1;const n=this._roots,o=this.indirect?oh:Dd;for(let r=0,l=n.length;r<l&&(i=o(this,r,t,e),!i);r++);return i}shapecast(t){const e=vt.getPrimitive(),i=this.indirect?Bd:Pd;let{boundsTraverseOrder:n,intersectsBounds:o,intersectsRange:r,intersectsTriangle:l}=t;if(r&&l){const h=r;r=(u,p,m,b,G)=>h(u,p,m,b,G)?!0:i(u,p,this,l,m,b,e)}else r||(l?r=(h,u,p,m)=>i(h,u,this,l,p,m,e):r=(h,u,p)=>p);let c=!1,a=0;const d=this._roots;for(let h=0,u=d.length;h<u;h++){const p=d[h];if(c=Md(this,h,o,r,n,a),c)break;a+=p.byteLength}return vt.releasePrimitive(e),c}bvhcast(t,e,i){let{intersectsRanges:n,intersectsTriangles:o}=i;const r=vt.getPrimitive(),l=this.geometry.index,c=this.geometry.attributes.position,a=this.indirect?m=>{const b=this.resolveTriangleIndex(m);$(r,b*3,l,c)}:m=>{$(r,m*3,l,c)},d=vt.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,p=t.indirect?m=>{const b=t.resolveTriangleIndex(m);$(d,b*3,h,u)}:m=>{$(d,m*3,h,u)};if(o){const m=(b,G,y,Z,V,R,f,x)=>{for(let L=y,W=y+Z;L<W;L++){p(L),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let C=b,S=b+G;C<S;C++)if(a(C),r.needsUpdate=!0,o(r,d,C,L,V,R,f,x))return!0}return!1};if(n){const b=n;n=function(G,y,Z,V,R,f,x,L){return b(G,y,Z,V,R,f,x,L)?!0:m(G,y,Z,V,R,f,x,L)}}else n=m}return hh(this,t,e,n)}intersectsBox(t,e){return Ks.set(t.min,t.max,e),Ks.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ks.intersectsBox(i),intersectsTriangle:i=>Ks.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},n={},o=0,r=1/0){return(this.indirect?dh:th)(this,t,e,i,n,o,r)}closestPointToPoint(t,e={},i=0,n=1/0){return Yd(this,t,e,i,n)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{B(0,new Float32Array(i),or),t.union(or)}),t}}const rr=new X.Box3,cr=new X.Matrix4;class ph extends X.Object3D{get isMesh(){return!this.displayEdges}get isLineSegments(){return this.displayEdges}get isLine(){return this.displayEdges}getVertexPosition(...t){return X.Mesh.prototype.getVertexPosition.call(this,...t)}constructor(t,e,i=10,n=0){super(),this.material=e,this.geometry=new X.BufferGeometry,this.name="MeshBVHRootHelper",this.depth=i,this.displayParents=!1,this.bvh=t,this.displayEdges=!0,this._group=n}raycast(){}update(){const t=this.geometry,e=this.bvh,i=this._group;if(t.dispose(),this.visible=!1,e){const n=this.depth-1,o=this.displayParents;let r=0;e.traverse((u,p)=>{if(u>=n||p)return r++,!0;o&&r++},i);let l=0;const c=new Float32Array(8*3*r);e.traverse((u,p,m)=>{const b=u>=n||p;if(b||o){B(0,m,rr);const{min:G,max:y}=rr;for(let Z=-1;Z<=1;Z+=2){const V=Z<0?G.x:y.x;for(let R=-1;R<=1;R+=2){const f=R<0?G.y:y.y;for(let x=-1;x<=1;x+=2){const L=x<0?G.z:y.z;c[l+0]=V,c[l+1]=f,c[l+2]=L,l+=3}}}return b}},i);let a,d;this.displayEdges?d=new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):d=new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),c.length>65535?a=new Uint32Array(d.length*r):a=new Uint16Array(d.length*r);const h=d.length;for(let u=0;u<r;u++){const p=u*8,m=u*h;for(let b=0;b<h;b++)a[m+b]=p+d[b]}t.setIndex(new X.BufferAttribute(a,1,!1)),t.setAttribute("position",new X.BufferAttribute(c,3,!1)),this.visible=!0}}}class mo extends X.Group{get color(){return this.edgeMaterial.color}get opacity(){return this.edgeMaterial.opacity}set opacity(t){this.edgeMaterial.opacity=t,this.meshMaterial.opacity=t}constructor(t=null,e=null,i=10){t instanceof be&&(i=e||10,e=t,t=null),typeof e=="number"&&(i=e,e=null),super(),this.name="MeshBVHHelper",this.depth=i,this.mesh=t,this.bvh=e,this.displayParents=!1,this.displayEdges=!0,this.objectIndex=0,this._roots=[];const n=new X.LineBasicMaterial({color:65416,transparent:!0,opacity:.3,depthWrite:!1}),o=new X.MeshBasicMaterial({color:65416,transparent:!0,opacity:.3,depthWrite:!1});o.color=n.color,this.edgeMaterial=n,this.meshMaterial=o,this.update()}update(){const t=this.mesh;let e=this.bvh||t.geometry.boundsTree||null;if(t.isBatchedMesh&&t.boundsTrees&&!e){const n=t._drawInfo[this.objectIndex];n&&(e=t.boundsTrees[n.geometryIndex]||e)}const i=e?e._roots.length:0;for(;this._roots.length>i;){const n=this._roots.pop();n.geometry.dispose(),this.remove(n)}for(let n=0;n<i;n++){const{depth:o,edgeMaterial:r,meshMaterial:l,displayParents:c,displayEdges:a}=this;if(n>=this._roots.length){const h=new ph(e,r,o,n);this.add(h),this._roots.push(h)}const d=this._roots[n];d.bvh=e,d.depth=o,d.displayParents=c,d.displayEdges=a,d.material=a?r:l,d.update()}}updateMatrixWorld(...t){const e=this.mesh,i=this.parent;e!==null&&(e.updateWorldMatrix(!0,!1),i?this.matrix.copy(i.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,cr),this.matrix.multiply(cr)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new mo(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].geometry.dispose()}}const Zi=new X.Box3,lr=new X.Box3,Ee=new X.Vector3;function ar(s){switch(typeof s){case"number":return 8;case"string":return s.length*2;case"boolean":return 4;default:return 0}}function mh(s){return/(Uint|Int|Float)(8|16|32)Array/.test(s.constructor.name)}function bh(s,t){const e={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return s.traverse((i,n,o,r,l)=>{const c=o[3]-o[0],a=o[1+3]-o[1],d=o[2+3]-o[2],h=2*(c*a+a*d+d*c);e.nodeCount++,n?(e.leafNodeCount++,e.depth.min=Math.min(i,e.depth.min),e.depth.max=Math.max(i,e.depth.max),e.tris.min=Math.min(l,e.tris.min),e.tris.max=Math.max(l,e.tris.max),e.surfaceAreaScore+=h*Us*l):(e.splits[r]++,e.surfaceAreaScore+=h*wn)},t),e.tris.min===1/0&&(e.tris.min=0,e.tris.max=0),e.depth.min===1/0&&(e.depth.min=0,e.depth.max=0),e}function yh(s){return s._roots.map((t,e)=>bh(s,e))}function Gh(s){const t=new Set,e=[s];let i=0;for(;e.length;){const n=e.pop();if(!t.has(n)){t.add(n);for(let o in n){if(!Object.hasOwn(n,o))continue;i+=ar(o);const r=n[o];r&&(typeof r=="object"||typeof r=="function")?mh(r)||Mc()&&r instanceof SharedArrayBuffer||r instanceof ArrayBuffer?i+=r.byteLength:e.push(r):i+=ar(r)}}}return i}function Zh(s){const t=s.geometry,e=[],i=t.index,n=t.getAttribute("position");let o=!0;return s.traverse((r,l,c,a,d)=>{const h={depth:r,isLeaf:l,boundingData:c,offset:a,count:d};e[r]=h,B(0,c,Zi);const u=e[r-1];if(l)for(let p=a,m=a+d;p<m;p++){const b=s.resolveTriangleIndex(p);let G=3*b,y=3*b+1,Z=3*b+2;i&&(G=i.getX(G),y=i.getX(y),Z=i.getX(Z));let V;Ee.fromBufferAttribute(n,G),V=Zi.containsPoint(Ee),Ee.fromBufferAttribute(n,y),V=V&&Zi.containsPoint(Ee),Ee.fromBufferAttribute(n,Z),V=V&&Zi.containsPoint(Ee),console.assert(V,"Leaf bounds does not fully contain triangle."),o=o&&V}if(u){B(0,c,lr);const p=lr.containsBox(Zi);console.assert(p,"Parent bounds does not fully contain child."),o=o&&p}}),o}function Xh(s){const t=[];return s.traverse((e,i,n,o,r)=>{const l={bounds:B(0,n,new X.Box3)};i?(l.count=r,l.offset=o):(l.left=null,l.right=null),t[e]=l;const c=t[e-1];c&&(c.left===null?c.left=l:c.right=l)}),t[0]}function dr(s,t,e){return s===null?null:(s.point.applyMatrix4(t.matrixWorld),s.distance=s.point.distanceTo(e.ray.origin),s.object=t,s)}const fh=parseInt(X.REVISION)>=166,Ts=new X.Ray,hr=new X.Vector3,ur=new X.Matrix4,Vh=X.Mesh.prototype.raycast,Rh=X.BatchedMesh.prototype.raycast,pr=new X.Vector3,lt=new X.Mesh,Ms=[];function xh(s,t){this.isBatchedMesh?Lh.call(this,s,t):Sh.call(this,s,t)}function Lh(s,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,n=this._drawRanges||this._geometryInfo,o=this.matrixWorld;lt.material=this.material,lt.geometry=this.geometry;const r=lt.geometry.boundsTree,l=lt.geometry.drawRange;lt.geometry.boundingSphere===null&&(lt.geometry.boundingSphere=new X.Sphere);for(let c=0,a=i.length;c<a;c++){if(!this.getVisibleAt(c))continue;const d=i[c].geometryIndex;if(lt.geometry.boundsTree=e[d],this.getMatrixAt(c,lt.matrixWorld).premultiply(o),!lt.geometry.boundsTree){this.getBoundingBoxAt(d,lt.geometry.boundingBox),this.getBoundingSphereAt(d,lt.geometry.boundingSphere);const h=n[d];lt.geometry.setDrawRange(h.start,h.count)}lt.raycast(s,Ms);for(let h=0,u=Ms.length;h<u;h++){const p=Ms[h];p.object=this,p.batchId=c,t.push(p)}Ms.length=0}lt.geometry.boundsTree=r,lt.geometry.drawRange=l,lt.material=null,lt.geometry=null}else Rh.call(this,s,t)}function Sh(s,t){if(this.geometry.boundsTree){if(this.material===void 0)return;ur.copy(this.matrixWorld).invert(),Ts.copy(s.ray).applyMatrix4(ur),pr.setFromMatrixScale(this.matrixWorld),hr.copy(Ts.direction).multiply(pr);const e=hr.length(),i=s.near/e,n=s.far/e,o=this.geometry.boundsTree;if(s.firstHitOnly===!0){const r=dr(o.raycastFirst(Ts,this.material,i,n),this,s);r&&t.push(r)}else{const r=o.raycast(Ts,this.material,i,n);for(let l=0,c=r.length;l<c;l++){const a=dr(r[l],this,s);a&&t.push(a)}}}else Vh.call(this,s,t)}function Wh(s={}){return this.boundsTree=new be(this,s),this.boundsTree}function gh(){this.boundsTree=null}function Ch(s=-1,t={}){if(!fh)throw new Error("BatchedMesh: Three r166+ is required to compute bounds trees.");t.indirect&&console.warn('"Indirect" is set to false because it is not supported for BatchedMesh.'),t={...t,indirect:!1,range:null};const e=this._drawRanges||this._geometryInfo,i=this._geometryCount;this.boundsTrees||(this.boundsTrees=new Array(i).fill(null));const n=this.boundsTrees;for(;n.length<i;)n.push(null);if(s<0){for(let o=0;o<i;o++)t.range=e[o],n[o]=new be(this.geometry,t);return n}else return s<e.length&&(t.range=e[s],n[s]=new be(this.geometry,t)),n[s]||null}function zh(s=-1){s<0?this.boundsTrees.fill(null):s<this.boundsTree.length&&(this.boundsTrees[s]=null)}function vh(s){switch(s){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Kh(s){switch(s){case 1:return X.RedFormat;case 2:return X.RGFormat;case 3:return X.RGBAFormat;case 4:return X.RGBAFormat}}function mr(s){switch(s){case 1:return X.RedIntegerFormat;case 2:return X.RGIntegerFormat;case 3:return X.RGBAIntegerFormat;case 4:return X.RGBAIntegerFormat}}class on extends X.DataTexture{constructor(){super(),this.minFilter=X.NearestFilter,this.magFilter=X.NearestFilter,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,i=t.itemSize,n=t.count;if(e!==null){if(i*n%e!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=n*i/e}const o=t.itemSize,r=t.count,l=t.normalized,c=t.array.constructor,a=c.BYTES_PER_ELEMENT;let d=this._forcedType,h=o;if(d===null)switch(c){case Float32Array:d=X.FloatType;break;case Uint8Array:case Uint16Array:case Uint32Array:d=X.UnsignedIntType;break;case Int8Array:case Int16Array:case Int32Array:d=X.IntType;break}let u,p,m,b,G=vh(o);switch(d){case X.FloatType:m=1,p=Kh(o),l&&a===1?(b=c,G+="8",c===Uint8Array?u=X.UnsignedByteType:(u=X.ByteType,G+="_SNORM")):(b=Float32Array,G+="32F",u=X.FloatType);break;case X.IntType:G+=a*8+"I",m=l?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,p=mr(o),a===1?(b=Int8Array,u=X.ByteType):a===2?(b=Int16Array,u=X.ShortType):(b=Int32Array,u=X.IntType);break;case X.UnsignedIntType:G+=a*8+"UI",m=l?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,p=mr(o),a===1?(b=Uint8Array,u=X.UnsignedByteType):a===2?(b=Uint16Array,u=X.UnsignedShortType):(b=Uint32Array,u=X.UnsignedIntType);break}h===3&&(p===X.RGBAFormat||p===X.RGBAIntegerFormat)&&(h=4);const y=Math.ceil(Math.sqrt(r))||1,Z=h*y*y,V=new b(Z),R=t.normalized;t.normalized=!1;for(let f=0;f<r;f++){const x=h*f;V[x]=t.getX(f)/m,o>=2&&(V[x+1]=t.getY(f)/m),o>=3&&(V[x+2]=t.getZ(f)/m,h===4&&(V[x+3]=1)),o>=4&&(V[x+3]=t.getW(f)/m)}t.normalized=R,this.internalFormat=G,this.format=p,this.type=u,this.image.width=y,this.image.height=y,this.image.data=V,this.needsUpdate=!0,this.dispose(),t.itemSize=i,t.count=n}}class Yc extends on{constructor(){super(),this._forcedType=X.UnsignedIntType}}class Th extends on{constructor(){super(),this._forcedType=X.IntType}}class kc extends on{constructor(){super(),this._forcedType=X.FloatType}}class Mh{constructor(){this.index=new Yc,this.position=new kc,this.bvhBounds=new X.DataTexture,this.bvhContents=new X.DataTexture,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(kh(t,this.bvhBounds,this.bvhContents),this.position.updateFrom(e.attributes.position),t.indirect){const i=t._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(e.index)this._cachedIndexAttr=e.index.clone();else{const n=Cc(gc(e));this._cachedIndexAttr=new X.BufferAttribute(n,1,!1)}Yh(e,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(e.index)}dispose(){const{index:t,position:e,bvhBounds:i,bvhContents:n}=this;t&&t.dispose(),e&&e.dispose(),i&&i.dispose(),n&&n.dispose()}}function Yh(s,t,e){const i=e.array,n=s.index?s.index.array:null;for(let o=0,r=t.length;o<r;o++){const l=3*o,c=3*t[o];for(let a=0;a<3;a++)i[l+a]=n?n[c+a]:c+a}}function kh(s,t,e){const i=s._roots;if(i.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const n=i[0],o=new Uint16Array(n),r=new Uint32Array(n),l=new Float32Array(n),c=n.byteLength/pe,a=2*Math.ceil(Math.sqrt(c/2)),d=new Float32Array(4*a*a),h=Math.ceil(Math.sqrt(c)),u=new Uint32Array(2*h*h);for(let p=0;p<c;p++){const m=p*pe/4,b=m*2,G=m;for(let y=0;y<3;y++)d[8*p+0+y]=l[G+0+y],d[8*p+4+y]=l[G+3+y];if(Zt(b,o)){const y=gt(b,o),Z=xt(m,r),V=4294901760|y;u[p*2+0]=V,u[p*2+1]=Z}else{const y=4*Ct(m,r)/pe,Z=ho(m,r);u[p*2+0]=Z,u[p*2+1]=y}}t.image.data=d,t.image.width=a,t.image.height=a,t.format=X.RGBAFormat,t.type=X.FloatType,t.internalFormat="RGBA32F",t.minFilter=X.NearestFilter,t.magFilter=X.NearestFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose(),e.image.data=u,e.image.width=h,e.image.height=h,e.format=X.RGIntegerFormat,e.type=X.UnsignedIntType,e.internalFormat="RG32UI",e.minFilter=X.NearestFilter,e.magFilter=X.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose()}const ve=new X.Vector3,Ke=new X.Vector3,Te=new X.Vector3,br=new X.Vector4,Ys=new X.Vector3,Cn=new X.Vector3,yr=new X.Vector4,Gr=new X.Vector4,ks=new X.Matrix4,Zr=new X.Matrix4;function Xi(s,t){if(!s&&!t)return;const e=s.count===t.count,i=s.normalized===t.normalized,n=s.array.constructor===t.array.constructor,o=s.itemSize===t.itemSize;if(!e||!i||!n||!o)throw new Error}function Li(s,t=null){const e=s.array.constructor,i=s.normalized,n=s.itemSize,o=t===null?s.count:t;return new X.BufferAttribute(new e(n*o),n,i)}function Hc(s,t,e=0){if(s.isInterleavedBufferAttribute){const i=s.itemSize;for(let n=0,o=s.count;n<o;n++){const r=n+e;t.setX(r,s.getX(n)),i>=2&&t.setY(r,s.getY(n)),i>=3&&t.setZ(r,s.getZ(n)),i>=4&&t.setW(r,s.getW(n))}}else{const i=t.array,n=i.constructor,o=i.BYTES_PER_ELEMENT*s.itemSize*e;new n(i.buffer,o,s.array.length).set(s.array)}}function Hh(s,t,e){const i=s.elements,n=t.elements;for(let o=0,r=n.length;o<r;o++)i[o]+=n[o]*e}function Xr(s,t,e){const i=s.skeleton,n=s.geometry,o=i.bones,r=i.boneInverses;yr.fromBufferAttribute(n.attributes.skinIndex,t),Gr.fromBufferAttribute(n.attributes.skinWeight,t),ks.elements.fill(0);for(let l=0;l<4;l++){const c=Gr.getComponent(l);if(c!==0){const a=yr.getComponent(l);Zr.multiplyMatrices(o[a].matrixWorld,r[a]),Hh(ks,Zr,c)}}return ks.multiply(s.bindMatrix).premultiply(s.bindMatrixInverse),e.transformDirection(ks),e}function zn(s,t,e,i,n){Ys.set(0,0,0);for(let o=0,r=s.length;o<r;o++){const l=t[o],c=s[o];l!==0&&(Cn.fromBufferAttribute(c,i),e?Ys.addScaledVector(Cn,l):Ys.addScaledVector(Cn.sub(n),l))}n.add(Ys)}function Nh(s,t={useGroups:!1,updateIndex:!1,skipAttributes:[]},e=new X.BufferGeometry){const i=s[0].index!==null,{useGroups:n=!1,updateIndex:o=!1,skipAttributes:r=[]}=t,l=new Set(Object.keys(s[0].attributes)),c={};let a=0;e.clearGroups();for(let d=0;d<s.length;++d){const h=s[d];let u=0;if(i!==(h.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const p in h.attributes){if(!l.has(p))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.');c[p]===void 0&&(c[p]=[]),c[p].push(h.attributes[p]),u++}if(u!==l.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(n){let p;if(i)p=h.index.count;else if(h.attributes.position!==void 0)p=h.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");e.addGroup(a,p,d),a+=p}}if(i){let d=!1;if(!e.index){let h=0;for(let u=0;u<s.length;++u)h+=s[u].index.count;e.setIndex(new X.BufferAttribute(new Uint32Array(h),1,!1)),d=!0}if(o||d){const h=e.index;let u=0,p=0;for(let m=0;m<s.length;++m){const b=s[m],G=b.index;if(r[m]!==!0)for(let y=0;y<G.count;++y)h.setX(u,G.getX(y)+p),u++;p+=b.attributes.position.count}}}for(const d in c){const h=c[d];if(!(d in e.attributes)){let m=0;for(const b in h)m+=h[b].count;e.setAttribute(d,Li(c[d][0],m))}const u=e.attributes[d];let p=0;for(let m=0,b=h.length;m<b;m++){const G=h[m];r[m]!==!0&&Hc(G,u,p),p+=G.count}}return e}function Ih(s,t){if(s===null||t===null)return s===t;if(s.length!==t.length)return!1;for(let e=0,i=s.length;e<i;e++)if(s[e]!==t[e])return!1;return!0}function Jh(s){const{index:t,attributes:e}=s;if(t)for(let i=0,n=t.count;i<n;i+=3){const o=t.getX(i),r=t.getX(i+2);t.setX(i,r),t.setX(i+2,o)}else for(const i in e){const n=e[i],o=n.itemSize;for(let r=0,l=n.count;r<l;r+=3)for(let c=0;c<o;c++){const a=n.getComponent(r,c),d=n.getComponent(r+2,c);n.setComponent(r,c,d),n.setComponent(r+2,c,a)}}return s}class Uh{constructor(t){this.matrixWorld=new X.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=t,this.update()}update(){const t=this.mesh,e=t.geometry,i=t.skeleton,n=(e.index?e.index.count:e.attributes.position.count)/3;if(this.matrixWorld.copy(t.matrixWorld),this.geometryHash=e.attributes.position.version,this.primitiveCount=n,i){i.boneTexture||i.computeBoneTexture(),i.update();const o=i.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==o.length?this.boneMatrices=o.slice():this.boneMatrices.set(o)}else this.boneMatrices=null}didChange(){const t=this.mesh,e=t.geometry,i=(e.index?e.index.count:e.attributes.position.count)/3;return!(this.matrixWorld.equals(t.matrixWorld)&&this.geometryHash===e.attributes.position.version&&Ih(t.skeleton&&t.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===i)}}class Ph{constructor(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(i=>{i.traverseVisible(n=>{n.isMesh&&e.push(n)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new X.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new X.BufferGeometry){let e=[];const{meshes:i,useGroups:n,_intermediateGeometry:o,_diffMap:r}=this;for(let l=0,c=i.length;l<c;l++){const a=i[l],d=o[l],h=r.get(a);!h||h.didChange(a)?(this._convertToStaticGeometry(a,d),e.push(!1),h?h.update():r.set(a,new Uh(a))):e.push(!0)}if(o.length===0){t.setIndex(null);const l=t.attributes;for(const c in l)t.deleteAttribute(c);for(const c in this.attributes)t.setAttribute(this.attributes[c],new X.BufferAttribute(new Float32Array(0),4,!1))}else Nh(o,{useGroups:n,skipAttributes:e},t);for(const l in t.attributes)t.attributes[l].needsUpdate=!0;return t}_convertToStaticGeometry(t,e=new X.BufferGeometry){const i=t.geometry,n=this.applyWorldTransforms,o=this.attributes.includes("normal"),r=this.attributes.includes("tangent"),l=i.attributes,c=e.attributes;!e.index&&i.index&&(e.index=i.index.clone()),c.position||e.setAttribute("position",Li(l.position)),o&&!c.normal&&l.normal&&e.setAttribute("normal",Li(l.normal)),r&&!c.tangent&&l.tangent&&e.setAttribute("tangent",Li(l.tangent)),Xi(i.index,e.index),Xi(l.position,c.position),o&&Xi(l.normal,c.normal),r&&Xi(l.tangent,c.tangent);const a=l.position,d=o?l.normal:null,h=r?l.tangent:null,u=i.morphAttributes.position,p=i.morphAttributes.normal,m=i.morphAttributes.tangent,b=i.morphTargetsRelative,G=t.morphTargetInfluences,y=new X.Matrix3;y.getNormalMatrix(t.matrixWorld),i.index&&e.index.array.set(i.index.array);for(let Z=0,V=l.position.count;Z<V;Z++)ve.fromBufferAttribute(a,Z),d&&Ke.fromBufferAttribute(d,Z),h&&(br.fromBufferAttribute(h,Z),Te.fromBufferAttribute(h,Z)),G&&(u&&zn(u,G,b,Z,ve),p&&zn(p,G,b,Z,Ke),m&&zn(m,G,b,Z,Te)),t.isSkinnedMesh&&(t.applyBoneTransform(Z,ve),d&&Xr(t,Z,Ke),h&&Xr(t,Z,Te)),n&&ve.applyMatrix4(t.matrixWorld),c.position.setXYZ(Z,ve.x,ve.y,ve.z),d&&(n&&Ke.applyNormalMatrix(y),c.normal.setXYZ(Z,Ke.x,Ke.y,Ke.z)),h&&(n&&Te.transformDirection(t.matrixWorld),c.tangent.setXYZW(Z,Te.x,Te.y,Te.z,br.w));for(const Z in this.attributes){const V=this.attributes[Z];V==="position"||V==="tangent"||V==="normal"||!(V in l)||(c[V]||e.setAttribute(V,Li(l[V])),Xi(l[V],c[V]),Hc(l[V],c[V]))}return t.matrixWorld.determinant()<0&&Jh(e),e}}const Nc=`
|
|
1121
|
+
}`;class Ql extends ba{constructor(t){super(t),this.vector_=new z,this.vector2_=new z,this.vector3_=new z,this.quaternion_=new G,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new x.BufferGeometry,this.indexBuffer=new x.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new x.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(x.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new We(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},e={};if(e.USE_UV="",e.USE_COLOR_ALPHA="",this.settings.material.map&&(e.USE_MAP="",e.MAP_UV=Jn(this.settings.material.map.channel),t.map=new x.Uniform$1(this.settings.material.map),t.mapTransform=new x.Uniform$1(new $t().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new x.ShaderMaterial({uniforms:t,defines:e,vertexShader:Zl,fragmentShader:Yl,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||x.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 t=0,e=0,i=0;this.systems.forEach(n=>{for(let s=0;s<n.particleNum;s++)i+=n.particles[s].previous.length*2}),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach(n=>{n.emitter.updateMatrixWorld&&(n.emitter.updateWorldMatrix(!0,!1),n.emitter.updateMatrixWorld(!0));const s=this.quaternion_,o=this.vector2_,c=this.vector3_;n.emitter.matrixWorld.decompose(o,s,c);const a=n.particles,l=n.particleNum,u=this.settings.uTileCount,h=this.settings.vTileCount,f=1/u,d=1/h;for(let p=0;p<l;p++){const m=a[p],g=m.uvTile%h,y=Math.floor(m.uvTile/h+.001),v=m.previous.values();let b=v.next(),S=b.value,_=S;b.done||(b=v.next());let T;b.value!==void 0?T=b.value:T=_;for(let M=0;M<m.previous.length;M++,t+=2){if(this.positionBuffer.setXYZ(t,_.position.x,_.position.y,_.position.z),this.positionBuffer.setXYZ(t+1,_.position.x,_.position.y,_.position.z),n.worldSpace?(this.positionBuffer.setXYZ(t,_.position.x,_.position.y,_.position.z),this.positionBuffer.setXYZ(t+1,_.position.x,_.position.y,_.position.z)):(m.parentMatrix?this.vector_.copy(_.position).applyMatrix4(m.parentMatrix):this.vector_.copy(_.position).applyMatrix4(n.emitter.matrixWorld),this.positionBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),n.worldSpace?(this.previousBuffer.setXYZ(t,S.position.x,S.position.y,S.position.z),this.previousBuffer.setXYZ(t+1,S.position.x,S.position.y,S.position.z)):(m.parentMatrix?this.vector_.copy(S.position).applyMatrix4(m.parentMatrix):this.vector_.copy(S.position).applyMatrix4(n.emitter.matrixWorld),this.previousBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),n.worldSpace?(this.nextBuffer.setXYZ(t,T.position.x,T.position.y,T.position.z),this.nextBuffer.setXYZ(t+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(n.emitter.matrixWorld),this.nextBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(t,-1),this.sideBuffer.setX(t+1,1),n.worldSpace)this.widthBuffer.setX(t,_.size),this.widthBuffer.setX(t+1,_.size);else if(m.parentMatrix)this.widthBuffer.setX(t,_.size),this.widthBuffer.setX(t+1,_.size);else{const w=(Math.abs(c.x)+Math.abs(c.y)+Math.abs(c.z))/3;this.widthBuffer.setX(t,_.size*w),this.widthBuffer.setX(t+1,_.size*w)}this.uvBuffer.setXY(t,(M/m.previous.length+g)*f,(h-y-1)*d),this.uvBuffer.setXY(t+1,(M/m.previous.length+g)*f,(h-y)*d),this.colorBuffer.setXYZW(t,_.color.x,_.color.y,_.color.z,_.color.w),this.colorBuffer.setXYZW(t+1,_.color.x,_.color.y,_.color.z,_.color.w),M+1<m.previous.length&&(this.indexBuffer.setX(e*3,t),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+2),e++,this.indexBuffer.setX(e*3,t+2),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+3),e++),S=_,_=T,b.done||(b=v.next(),b.value!==void 0&&(T=b.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,t*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,t*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,t*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,t*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,e*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,e*3)}dispose(){this.geometry.dispose()}}class or{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,t===void 0||typeof t=="string")return;const e=new x.Triangle;this._triangleIndexToArea.length=0;let i=0;if(!t.getIndex())return;const n=t.getIndex().array,s=n.length/3;this._triangleIndexToArea.push(0);for(let o=0;o<s;o++)e.setFromAttributeAndIndices(t.getAttribute("position"),n[o*3],n[o*3+1],n[o*3+2]),i+=e.getArea(),this._triangleIndexToArea.push(i);t.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(t){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new x.Vector3,this._tempB=new x.Vector3,this._tempC=new x.Vector3,t&&(this.geometry=t)}initialize(t){const e=this._geometry;if(!e||e.getIndex()===null){t.position.set(0,0,0),t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);return}const i=this._triangleIndexToArea.length-1;let n=0,s=i;const o=Math.random()*this._triangleIndexToArea[i];for(;n+1<s;){const d=Math.floor((n+s)/2);o<this._triangleIndexToArea[d]?s=d:n=d}let c=Math.random(),a=Math.random();c+a>1&&(c=1-c,a=1-a);const l=e.getIndex().array[n*3],u=e.getIndex().array[n*3+1],h=e.getIndex().array[n*3+2],f=e.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,h),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,c).addScaledVector(this._tempC,a),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new or(e.geometries[t.geometry])}clone(){return new or(this._geometry)}update(t,e){}}Al({id:"three.quarks",initialize:()=>{},emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:or,loadJSON:or.fromJSON}],behaviors:[]});class cs extends x.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(t,e){return t.material.side===e.material.side&&t.material.blending===e.material.blending&&t.material.blendSrc===e.material.blendSrc&&t.material.blendDst===e.material.blendDst&&t.material.blendEquation===e.material.blendEquation&&t.material.premultipliedAlpha===e.material.premultipliedAlpha&&t.material.transparent===e.material.transparent&&t.material.depthTest===e.material.depthTest&&t.material.type===e.material.type&&t.material.alphaTest===e.material.alphaTest&&t.material.map===e.material.map&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layers.mask===e.layers.mask}addSystem(t){t._renderer=this;const e=t.getRendererSettings();for(let n=0;n<this.batches.length;n++)if(cs.equals(this.batches[n].settings,e)){this.batches[n].addSystem(t),this.systemToBatchIndex.set(t,n);return}let i;switch(e.renderMode){case exports.RenderMode.Trail:i=new Ql(e);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:i=new Wl(e);break}this.depthTexture&&i.applyDepthTexture(this.depthTexture),i.addSystem(t),this.batches.push(i),this.systemToBatchIndex.set(t,this.batches.length-1),this.add(i)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);e!=null&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}update(t){this.systemToBatchIndex.forEach((e,i)=>{i.update(t)});for(let e=0;e<this.batches.length;e++)this.batches[e].update()}}const Kl=cs;Dl();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const Sa=Math.sqrt(5),tu=(Sa-1)/4,at=(5-Sa)/20,gr=r=>Math.floor(r)|0,vr=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 eu(r=Math.random){const t=iu(r),e=new Float64Array(t).map(o=>vr[o%32*4]),i=new Float64Array(t).map(o=>vr[o%32*4+1]),n=new Float64Array(t).map(o=>vr[o%32*4+2]),s=new Float64Array(t).map(o=>vr[o%32*4+3]);return function(c,a,l,u){let h,f,d,p,m;const g=(c+a+l+u)*tu,y=gr(c+g),v=gr(a+g),b=gr(l+g),S=gr(u+g),_=(y+v+b+S)*at,T=y-_,M=v-_,w=b-_,E=S-_,C=c-T,A=a-M,P=l-w,R=u-E;let k=0,O=0,N=0,D=0;C>A?k++:O++,C>P?k++:N++,C>R?k++:D++,A>P?O++:N++,A>R?O++:D++,P>R?N++:D++;const V=k>=3?1:0,W=O>=3?1:0,it=N>=3?1:0,tt=D>=3?1:0,Ct=k>=2?1:0,bt=O>=2?1:0,rt=N>=2?1:0,dt=D>=2?1:0,et=k>=1?1:0,q=O>=1?1:0,se=N>=1?1:0,Y=D>=1?1:0,Lt=C-V+at,qt=A-W+at,ye=P-it+at,ge=R-tt+at,ve=C-Ct+2*at,xe=A-bt+2*at,_e=P-rt+2*at,be=R-dt+2*at,Se=C-et+3*at,Te=A-q+3*at,Me=P-se+3*at,Xt=R-Y+3*at,Wt=C-1+4*at,Yt=A-1+4*at,Zt=P-1+4*at,Qt=R-1+4*at,Bt=y&255,zt=v&255,Ot=b&255,It=S&255;let J=.6-C*C-A*A-P*P-R*R;if(J<0)h=0;else{const X=Bt+t[zt+t[Ot+t[It]]];J*=J,h=J*J*(e[X]*C+i[X]*A+n[X]*P+s[X]*R)}let ei=.6-Lt*Lt-qt*qt-ye*ye-ge*ge;if(ei<0)f=0;else{const X=Bt+V+t[zt+W+t[Ot+it+t[It+tt]]];ei*=ei,f=ei*ei*(e[X]*Lt+i[X]*qt+n[X]*ye+s[X]*ge)}let ii=.6-ve*ve-xe*xe-_e*_e-be*be;if(ii<0)d=0;else{const X=Bt+Ct+t[zt+bt+t[Ot+rt+t[It+dt]]];ii*=ii,d=ii*ii*(e[X]*ve+i[X]*xe+n[X]*_e+s[X]*be)}let ri=.6-Se*Se-Te*Te-Me*Me-Xt*Xt;if(ri<0)p=0;else{const X=Bt+et+t[zt+q+t[Ot+se+t[It+Y]]];ri*=ri,p=ri*ri*(e[X]*Se+i[X]*Te+n[X]*Me+s[X]*Xt)}let ni=.6-Wt*Wt-Yt*Yt-Zt*Zt-Qt*Qt;if(ni<0)m=0;else{const X=Bt+1+t[zt+1+t[Ot+1+t[It+1]]];ni*=ni,m=ni*ni*(e[X]*Wt+i[X]*Yt+n[X]*Zt+s[X]*Qt)}return 27*(h+f+d+p+m)}}function iu(r){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const n=i+~~(r()*(256-i)),s=e[i];e[i]=e[n],e[n]=s}for(let i=256;i<512;i++)e[i]=e[i-256];return e}class ru{constructor(t){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Backoff must be a positive integer");this.backoff=t}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class nu{constructor(t,e){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Base must be a positive integer or zero");if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=t,this.expMax=e,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}}class su{constructor(t,e,i){if(this.i=0,this._retries=0,t<0)throw new Error("Initial must be a positive number or zero");if(e<0)throw new Error("Increment must be a positive number or zero");if(i!==void 0&&i<0)throw new Error("Max must be undefined, a positive number or zero");if(i!==void 0&&i<t)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=t,this.increment=e,this.max=i}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class ou{constructor(){this.elements=[]}add(t){this.elements.push(t)}clear(){this.elements.length=0}forEach(t){this.elements.forEach(t)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class au{constructor(t){if(!Number.isInteger(t)||t<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(t+1),this.head=0,this.tail=0}add(t){this.elements[this.head]=t,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(t){for(let e=this.tail;e!==this.head;e=(e+1)%this.elements.length)t(this.elements[e])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const t=this.peek();return t!==void 0&&(this.tail=(this.tail+1)%this.elements.length),t}}var j;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(j||(j={}));class Ta{constructor(t,e,i){var n,s,o,c,a,l,u,h,f,d,p,m,g,y,v;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(j.open,b),this.handleErrorEvent=b=>this.handleEvent(j.error,b),this.handleCloseEvent=b=>this.handleEvent(j.close,b),this.handleMessageEvent=b=>this.handleEvent(j.message,b),this._url=t,this._protocols=e,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(n=i==null?void 0:i.retry)===null||n===void 0?void 0:n.maxRetries,instantReconnect:(s=i==null?void 0:i.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(o=i==null?void 0:i.retry)===null||o===void 0?void 0:o.backoff},listeners:{open:[...(a=(c=i==null?void 0:i.listeners)===null||c===void 0?void 0:c.open)!==null&&a!==void 0?a:[]],close:[...(u=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(h=i==null?void 0:i.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[]],message:[...(p=(d=i==null?void 0:i.listeners)===null||d===void 0?void 0:d.message)!==null&&p!==void 0?p:[]],retry:[...(g=(m=i==null?void 0:i.listeners)===null||m===void 0?void 0:m.retry)!==null&&g!==void 0?g:[]],reconnect:[...(v=(y=i==null?void 0:i.listeners)===null||y===void 0?void 0:y.reconnect)!==null&&v!==void 0?v:[]]}},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(t){this._underlyingWebsocket.binaryType=t}send(t){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(t):this.buffer!==void 0&&this.buffer.add(t))}close(t,e){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(t,e)}addEventListener(t,e,i){this._options.listeners[t].push({listener:e,options:i})}removeEventListener(t,e,i){const n=s=>s.listener!==e||s.options!==i;this._options.listeners[t]=this._options.listeners[t].filter(n)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(j.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(j.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(j.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(j.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(j.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(j.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(j.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(j.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(t,e){const i=this._options.listeners[t],n=[];i.forEach(({listener:s,options:o})=>{s(this,e),(o===void 0||o.once===void 0||!o.once)&&n.push({listener:s,options:o})}),this._options.listeners[t]=n}handleEvent(t,e){switch(t){case j.close:this.dispatchEvent(t,e),this.scheduleConnectionRetryIfNeeded();break;case j.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},n=new CustomEvent(j.reconnect,{detail:i});this.dispatchEvent(j.reconnect,n),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(t,e),this.sendBufferedData();break;case j.retry:this.dispatchEvent(t,e),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(t,e);break}}sendBufferedData(){if(this.buffer!==void 0)for(let t=this.buffer.read();t!==void 0;t=this.buffer.read())this.send(t)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const t=i=>{const n=new CustomEvent(j.retry,{detail:i});this.handleEvent(j.retry,n)},e={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||e.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>t(e),e.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class cu{constructor(t){this._url=t}get url(){return this._url}withProtocols(t){return this._protocols=t,this}get protocols(){return this._protocols}withMaxRetries(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{maxRetries:t})}),this}get maxRetries(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.maxRetries}withInstantReconnect(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{instantReconnect:t})}),this}get instantReconnect(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.instantReconnect}withBackoff(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{backoff:t})}),this}get backoff(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.backoff}withBuffer(t){return this._options=Object.assign(Object.assign({},this._options),{buffer:t}),this}get buffer(){var t;return(t=this._options)===null||t===void 0?void 0:t.buffer}onOpen(t,e){return this.addListener(j.open,t,e),this}onClose(t,e){return this.addListener(j.close,t,e),this}onError(t,e){return this.addListener(j.error,t,e),this}onMessage(t,e){return this.addListener(j.message,t,e),this}onRetry(t,e){return this.addListener(j.retry,t,e),this}onReconnect(t,e){return this.addListener(j.reconnect,t,e),this}build(){return new Ta(this._url,this._protocols,this._options)}addListener(t,e,i){var n,s,o,c,a,l,u,h,f,d,p,m,g,y,v,b,S,_,T,M,w;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(o=(s=(n=this._options)===null||n===void 0?void 0:n.listeners)===null||s===void 0?void 0:s.open)!==null&&o!==void 0?o:[],close:(l=(a=(c=this._options)===null||c===void 0?void 0:c.listeners)===null||a===void 0?void 0:a.close)!==null&&l!==void 0?l:[],error:(f=(h=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[],message:(m=(p=(d=this._options)===null||d===void 0?void 0:d.listeners)===null||p===void 0?void 0:p.message)!==null&&m!==void 0?m:[],retry:(v=(y=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||y===void 0?void 0:y.retry)!==null&&v!==void 0?v:[],reconnect:(_=(S=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||S===void 0?void 0:S.reconnect)!==null&&_!==void 0?_:[],[t]:[...(w=(M=(T=this._options)===null||T===void 0?void 0:T.listeners)===null||M===void 0?void 0:M[t])!==null&&w!==void 0?w:[],{listener:e,options:i}]}}),this}}const lu=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:ou,ConstantBackoff:ru,ExponentialBackoff:nu,LinearBackoff:su,RingQueue:au,Websocket:Ta,WebsocketBuilder:cu,get WebsocketEvent(){return j}},Symbol.toStringTag,{value:"Module"})),ls=0,Ma=1,Ca=2,uu=0,hu=1,Gn=2,Lr=1.25,jn=1,de=6*4+4+4,rn=65535,fu=Math.pow(2,-24),vn=Symbol("SKIP_GENERATION");function wa(r){return r.index?r.index.count:r.attributes.position.count}function ti(r){return wa(r)/3}function Pa(r,t=ArrayBuffer){return r>65535?new Uint32Array(new t(4*r)):new Uint16Array(new t(2*r))}function du(r,t){if(!r.index){const e=r.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=Pa(e,i);r.setIndex(new x.BufferAttribute(n,1));for(let s=0;s<e;s++)n[s]=s}}function Ea(r,t){const e=ti(r),i=t||r.drawRange,n=i.start/3,s=(i.start+i.count)/3,o=Math.max(0,n),c=Math.min(e,s)-o;return[{offset:Math.floor(o),count:Math.floor(c)}]}function Aa(r,t){if(!r.groups||!r.groups.length)return Ea(r,t);const e=[],i=new Set,n=t||r.drawRange,s=n.start/3,o=(n.start+n.count)/3;for(const a of r.groups){const l=a.start/3,u=(a.start+a.count)/3;i.add(Math.max(s,l)),i.add(Math.min(o,u))}const c=Array.from(i.values()).sort((a,l)=>a-l);for(let a=0;a<c.length-1;a++){const l=c[a],u=c[a+1];e.push({offset:Math.floor(l),count:Math.floor(u-l)})}return e}function pu(r,t){const e=ti(r),i=Aa(r,t).sort((o,c)=>o.offset-c.offset),n=i[i.length-1];n.count=Math.min(e-n.offset,n.count);let s=0;return i.forEach(({count:o})=>s+=o),e!==s}function xn(r,t,e,i,n){let s=1/0,o=1/0,c=1/0,a=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,p=-1/0,m=-1/0,g=-1/0;for(let y=t*6,v=(t+e)*6;y<v;y+=6){const b=r[y+0],S=r[y+1],_=b-S,T=b+S;_<s&&(s=_),T>a&&(a=T),b<h&&(h=b),b>p&&(p=b);const M=r[y+2],w=r[y+3],E=M-w,C=M+w;E<o&&(o=E),C>l&&(l=C),M<f&&(f=M),M>m&&(m=M);const A=r[y+4],P=r[y+5],R=A-P,k=A+P;R<c&&(c=R),k>u&&(u=k),A<d&&(d=A),A>g&&(g=A)}i[0]=s,i[1]=o,i[2]=c,i[3]=a,i[4]=l,i[5]=u,n[0]=h,n[1]=f,n[2]=d,n[3]=p,n[4]=m,n[5]=g}function mu(r,t=null,e=null,i=null){const n=r.attributes.position,s=r.index?r.index.array:null,o=ti(r),c=n.normalized;let a;t===null?(a=new Float32Array(o*6),e=0,i=o):(a=t,e=e||0,i=i||o);const l=n.array,u=n.offset||0;let h=3;n.isInterleavedBufferAttribute&&(h=n.data.stride);const f=["getX","getY","getZ"];for(let d=e;d<e+i;d++){const p=d*3,m=d*6;let g=p+0,y=p+1,v=p+2;s&&(g=s[g],y=s[y],v=s[v]),c||(g=g*h+u,y=y*h+u,v=v*h+u);for(let b=0;b<3;b++){let S,_,T;c?(S=n[f[b]](g),_=n[f[b]](y),T=n[f[b]](v)):(S=l[g+b],_=l[y+b],T=l[v+b]);let M=S;_<M&&(M=_),T<M&&(M=T);let w=S;_>w&&(w=_),T>w&&(w=T);const E=(w-M)/2,C=b*2;a[m+C+0]=M+E,a[m+C+1]=E+(Math.abs(M)+E)*fu}}return a}function $(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function qs(r){let t=-1,e=-1/0;for(let i=0;i<3;i++){const n=r[i+3]-r[i];n>e&&(e=n,t=i)}return t}function Xs(r,t){t.set(r)}function Ws(r,t,e){let i,n;for(let s=0;s<3;s++){const o=s+3;i=r[s],n=t[s],e[s]=i<n?i:n,i=r[o],n=t[o],e[o]=i>n?i:n}}function xr(r,t,e){for(let i=0;i<3;i++){const n=t[r+2*i],s=t[r+2*i+1],o=n-s,c=n+s;o<e[i]&&(e[i]=o),c>e[i+3]&&(e[i+3]=c)}}function ci(r){const t=r[3]-r[0],e=r[4]-r[1],i=r[5]-r[2];return 2*(t*e+e*i+i*t)}const Kt=32,yu=(r,t)=>r.candidate-t.candidate,ce=new Array(Kt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),_r=new Float32Array(6);function gu(r,t,e,i,n,s){let o=-1,c=0;if(s===ls)o=qs(t),o!==-1&&(c=(t[o]+t[o+3])/2);else if(s===Ma)o=qs(r),o!==-1&&(c=vu(e,i,n,o));else if(s===Ca){const a=ci(r);let l=Lr*n;const u=i*6,h=(i+n)*6;for(let f=0;f<3;f++){const d=t[f],g=(t[f+3]-d)/Kt;if(n<Kt/4){const y=[...ce];y.length=n;let v=0;for(let S=u;S<h;S+=6,v++){const _=y[v];_.candidate=e[S+2*f],_.count=0;const{bounds:T,leftCacheBounds:M,rightCacheBounds:w}=_;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,T[E]=1/0,T[E+3]=-1/0;xr(S,e,T)}y.sort(yu);let b=n;for(let S=0;S<b;S++){const _=y[S];for(;S+1<b&&y[S+1].candidate===_.candidate;)y.splice(S+1,1),b--}for(let S=u;S<h;S+=6){const _=e[S+2*f];for(let T=0;T<b;T++){const M=y[T];_>=M.candidate?xr(S,e,M.rightCacheBounds):(xr(S,e,M.leftCacheBounds),M.count++)}}for(let S=0;S<b;S++){const _=y[S],T=_.count,M=n-_.count,w=_.leftCacheBounds,E=_.rightCacheBounds;let C=0;T!==0&&(C=ci(w)/a);let A=0;M!==0&&(A=ci(E)/a);const P=jn+Lr*(C*T+A*M);P<l&&(o=f,l=P,c=_.candidate)}}else{for(let b=0;b<Kt;b++){const S=ce[b];S.count=0,S.candidate=d+g+b*g;const _=S.bounds;for(let T=0;T<3;T++)_[T]=1/0,_[T+3]=-1/0}for(let b=u;b<h;b+=6){let T=~~((e[b+2*f]-d)/g);T>=Kt&&(T=Kt-1);const M=ce[T];M.count++,xr(b,e,M.bounds)}const y=ce[Kt-1];Xs(y.bounds,y.rightCacheBounds);for(let b=Kt-2;b>=0;b--){const S=ce[b],_=ce[b+1];Ws(S.bounds,_.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let b=0;b<Kt-1;b++){const S=ce[b],_=S.count,T=S.bounds,w=ce[b+1].rightCacheBounds;_!==0&&(v===0?Xs(T,_r):Ws(T,_r,_r)),v+=_;let E=0,C=0;v!==0&&(E=ci(_r)/a);const A=n-v;A!==0&&(C=ci(w)/a);const P=jn+Lr*(E*v+C*A);P<l&&(o=f,l=P,c=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:c}}function vu(r,t,e,i){let n=0;for(let s=t,o=t+e;s<o;s++)n+=r[s*6+i*2];return n/e}class _n{constructor(){this.boundingData=new Float32Array(6)}}function xu(r,t,e,i,n,s){let o=i,c=i+n-1;const a=s.pos,l=s.axis*2;for(;;){for(;o<=c&&e[o*6+l]<a;)o++;for(;o<=c&&e[c*6+l]>=a;)c--;if(o<c){for(let u=0;u<3;u++){let h=t[o*3+u];t[o*3+u]=t[c*3+u],t[c*3+u]=h}for(let u=0;u<6;u++){let h=e[o*6+u];e[o*6+u]=e[c*6+u],e[c*6+u]=h}o++,c--}else return o}}function _u(r,t,e,i,n,s){let o=i,c=i+n-1;const a=s.pos,l=s.axis*2;for(;;){for(;o<=c&&e[o*6+l]<a;)o++;for(;o<=c&&e[c*6+l]>=a;)c--;if(o<c){let u=r[o];r[o]=r[c],r[c]=u;for(let h=0;h<6;h++){let f=e[o*6+h];e[o*6+h]=e[c*6+h],e[c*6+h]=f}o++,c--}else return o}}function vt(r,t){return t[r+15]===65535}function Tt(r,t){return t[r+6]}function Pt(r,t){return t[r+14]}function At(r){return r+8}function Et(r,t){return t[r+6]}function us(r,t){return t[r+7]}let Ra,Ti,Vr,ka;const bu=Math.pow(2,32);function $n(r){return"count"in r?1:1+$n(r.left)+$n(r.right)}function Su(r,t,e){return Ra=new Float32Array(e),Ti=new Uint32Array(e),Vr=new Uint16Array(e),ka=new Uint8Array(e),Hn(r,t)}function Hn(r,t){const e=r/4,i=r/2,n="count"in t,s=t.boundingData;for(let o=0;o<6;o++)Ra[e+o]=s[o];if(n)if(t.buffer){const o=t.buffer;ka.set(new Uint8Array(o),r);for(let c=r,a=r+o.byteLength;c<a;c+=de){const l=c/2;vt(l,Vr)||(Ti[c/4+6]+=e)}return r+o.byteLength}else{const o=t.offset,c=t.count;return Ti[e+6]=o,Vr[i+14]=c,Vr[i+15]=rn,r+de}else{const o=t.left,c=t.right,a=t.splitAxis;let l;if(l=Hn(r+de,o),l/4>bu)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Ti[e+6]=l/4,l=Hn(l,c),Ti[e+7]=a,l}}function Tu(r,t){const e=(r.index?r.index.count:r.attributes.position.count)/3,i=e>2**16,n=i?4:2,s=t?new SharedArrayBuffer(e*n):new ArrayBuffer(e*n),o=i?new Uint32Array(s):new Uint16Array(s);for(let c=0,a=o.length;c<a;c++)o[c]=c;return o}function Mu(r,t,e,i,n){const{maxDepth:s,verbose:o,maxLeafTris:c,strategy:a,onProgress:l,indirect:u}=n,h=r._indirectBuffer,f=r.geometry,d=f.index?f.index.array:null,p=u?_u:xu,m=ti(f),g=new Float32Array(6);let y=!1;const v=new _n;return xn(t,e,i,v.boundingData,g),S(v,e,i,g),v;function b(_){l&&l(_/m)}function S(_,T,M,w=null,E=0){if(!y&&E>=s&&(y=!0,o&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),M<=c||E>=s)return b(T+M),_.offset=T,_.count=M,_;const C=gu(_.boundingData,w,t,T,M,a);if(C.axis===-1)return b(T+M),_.offset=T,_.count=M,_;const A=p(h,d,t,T,M,C);if(A===T||A===T+M)b(T+M),_.offset=T,_.count=M;else{_.splitAxis=C.axis;const P=new _n,R=T,k=A-T;_.left=P,xn(t,R,k,P.boundingData,g),S(P,R,k,g,E+1);const O=new _n,N=A,D=M-k;_.right=O,xn(t,N,D,O.boundingData,g),S(O,N,D,g,E+1)}return _}}function Cu(r,t){const e=r.geometry;t.indirect&&(r._indirectBuffer=Tu(e,t.useSharedArrayBuffer),pu(e,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||du(e,t);const i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=mu(e),s=t.indirect?Ea(e,t.range):Aa(e,t.range);r._roots=s.map(o=>{const c=Mu(r,n,o.offset,o.count,t),a=$n(c),l=new i(de*a);return Su(0,c,l),l})}class ne{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){const a=t[s][e];i=a<i?a:i,n=a>n?a:n}this.min=i,this.max=n}setFromPoints(t,e){let i=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){const c=e[s],a=t.dot(c);i=a<i?a:i,n=a>n?a:n}this.min=i,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}}ne.prototype.setFromBox=function(){const r=new x.Vector3;return function(e,i){const n=i.min,s=i.max;let o=1/0,c=-1/0;for(let a=0;a<=1;a++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){r.x=n.x*a+s.x*(1-a),r.y=n.y*l+s.y*(1-l),r.z=n.z*u+s.z*(1-u);const h=e.dot(r);o=Math.min(h,o),c=Math.max(h,c)}this.min=o,this.max=c}}();const wu=function(){const r=new x.Vector3,t=new x.Vector3,e=new x.Vector3;return function(n,s,o){const c=n.start,a=r,l=s.start,u=t;e.subVectors(c,l),r.subVectors(n.end,n.start),t.subVectors(s.end,s.start);const h=e.dot(u),f=u.dot(a),d=u.dot(u),p=e.dot(a),g=a.dot(a)*d-f*f;let y,v;g!==0?y=(h*f-p*d)/g:y=0,v=(h+y*f)/d,o.x=y,o.y=v}}(),hs=function(){const r=new x.Vector2,t=new x.Vector3,e=new x.Vector3;return function(n,s,o,c){wu(n,s,r);let a=r.x,l=r.y;if(a>=0&&a<=1&&l>=0&&l<=1){n.at(a,o),s.at(l,c);return}else if(a>=0&&a<=1){l<0?s.at(0,c):s.at(1,c),n.closestPointToPoint(c,!0,o);return}else if(l>=0&&l<=1){a<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,c);return}else{let u;a<0?u=n.start:u=n.end;let h;l<0?h=s.start:h=s.end;const f=t,d=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=d.distanceToSquared(u)){o.copy(f),c.copy(h);return}else{o.copy(u),c.copy(d);return}}}}(),Pu=function(){const r=new x.Vector3,t=new x.Vector3,e=new x.Plane,i=new x.Line3;return function(s,o){const{radius:c,center:a}=s,{a:l,b:u,c:h}=o;if(i.start=l,i.end=u,i.closestPointToPoint(a,!0,r).distanceTo(a)<=c||(i.start=l,i.end=h,i.closestPointToPoint(a,!0,r).distanceTo(a)<=c)||(i.start=u,i.end=h,i.closestPointToPoint(a,!0,r).distanceTo(a)<=c))return!0;const m=o.getPlane(e);if(Math.abs(m.distanceToPoint(a))<=c){const y=m.projectPoint(a,t);if(o.containsPoint(y))return!0}return!1}}(),Eu=1e-15;function bn(r){return Math.abs(r)<Eu}class kt extends x.Triangle{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new x.Vector3),this.satBounds=new Array(4).fill().map(()=>new ne),this.points=[this.a,this.b,this.c],this.sphere=new x.Sphere,this.plane=new x.Plane,this.needsUpdate=!0}intersectsSphere(t){return Pu(t,this)}update(){const t=this.a,e=this.b,i=this.c,n=this.points,s=this.satAxes,o=this.satBounds,c=s[0],a=o[0];this.getNormal(c),a.setFromPoints(c,n);const l=s[1],u=o[1];l.subVectors(t,e),u.setFromPoints(l,n);const h=s[2],f=o[2];h.subVectors(e,i),f.setFromPoints(h,n);const d=s[3],p=o[3];d.subVectors(i,t),p.setFromPoints(d,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,t),this.needsUpdate=!1}}kt.prototype.closestPointToSegment=function(){const r=new x.Vector3,t=new x.Vector3,e=new x.Line3;return function(n,s=null,o=null){const{start:c,end:a}=n,l=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[d]),hs(e,n,r,t),u=r.distanceToSquared(t),u<h&&(h=u,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<h&&(h=u,s&&s.copy(r),o&&o.copy(c)),this.closestPointToPoint(a,r),u=a.distanceToSquared(r),u<h&&(h=u,s&&s.copy(r),o&&o.copy(a)),Math.sqrt(h)}}();kt.prototype.intersectsTriangle=function(){const r=new kt,t=new Array(3),e=new Array(3),i=new ne,n=new ne,s=new x.Vector3,o=new x.Vector3,c=new x.Vector3,a=new x.Vector3,l=new x.Vector3,u=new x.Line3,h=new x.Line3,f=new x.Line3,d=new x.Vector3;function p(m,g,y){const v=m.points;let b=0,S=-1;for(let _=0;_<3;_++){const{start:T,end:M}=u;T.copy(v[_]),M.copy(v[(_+1)%3]),u.delta(o);const w=bn(g.distanceToPoint(T));if(bn(g.normal.dot(o))&&w){y.copy(u),b=2;break}const E=g.intersectLine(u,d);if(!E&&w&&d.copy(T),(E||w)&&!bn(d.distanceTo(M))){if(b<=1)(b===1?y.start:y.end).copy(d),w&&(S=b);else if(b>=2){(S===1?y.start:y.end).copy(d),b=2;break}if(b++,b===2&&S===-1)break}}return b}return function(g,y=null,v=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(r.copy(g),r.update(),g=r);const b=this.plane,S=g.plane;if(Math.abs(b.normal.dot(S.normal))>1-1e-10){const _=this.satBounds,T=this.satAxes;e[0]=g.a,e[1]=g.b,e[2]=g.c;for(let E=0;E<4;E++){const C=_[E],A=T[E];if(i.setFromPoints(A,e),C.isSeparated(i))return!1}const M=g.satBounds,w=g.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){const C=M[E],A=w[E];if(i.setFromPoints(A,t),C.isSeparated(i))return!1}for(let E=0;E<4;E++){const C=T[E];for(let A=0;A<4;A++){const P=w[A];if(s.crossVectors(C,P),i.setFromPoints(s,t),n.setFromPoints(s,e),i.isSeparated(n))return!1}}return y&&(v||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),y.start.set(0,0,0),y.end.set(0,0,0)),!0}else{const _=p(this,S,h);if(_===1&&g.containsPoint(h.end))return y&&(y.start.copy(h.end),y.end.copy(h.end)),!0;if(_!==2)return!1;const T=p(g,b,f);if(T===1&&this.containsPoint(f.end))return y&&(y.start.copy(f.end),y.end.copy(f.end)),!0;if(T!==2)return!1;if(h.delta(c),f.delta(a),c.dot(a)<0){let R=f.start;f.start=f.end,f.end=R}const M=h.start.dot(c),w=h.end.dot(c),E=f.start.dot(c),C=f.end.dot(c),A=w<E,P=M<C;return M!==C&&E!==w&&A===P?!1:(y&&(l.subVectors(h.start,f.start),l.dot(c)>0?y.start.copy(h.start):y.start.copy(f.start),l.subVectors(h.end,f.end),l.dot(c)<0?y.end.copy(h.end):y.end.copy(f.end)),!0)}}}();kt.prototype.distanceToPoint=function(){const r=new x.Vector3;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();kt.prototype.distanceToTriangle=function(){const r=new x.Vector3,t=new x.Vector3,e=["a","b","c"],i=new x.Line3,n=new x.Line3;return function(o,c=null,a=null){const l=c||a?i:null;if(this.intersectsTriangle(o,l))return(c||a)&&(c&&l.getCenter(c),a&&l.getCenter(a)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=e[h],p=o[d];this.closestPointToPoint(p,r),f=p.distanceToSquared(r),f<u&&(u=f,c&&c.copy(r),a&&a.copy(p));const m=this[d];o.closestPointToPoint(m,r),f=m.distanceToSquared(r),f<u&&(u=f,c&&c.copy(m),a&&a.copy(r))}for(let h=0;h<3;h++){const f=e[h],d=e[(h+1)%3];i.set(this[f],this[d]);for(let p=0;p<3;p++){const m=e[p],g=e[(p+1)%3];n.set(o[m],o[g]),hs(i,n,r,t);const y=r.distanceToSquared(t);y<u&&(u=y,c&&c.copy(r),a&&a.copy(t))}}return Math.sqrt(u)}}();class gt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new x.Vector3,this.max=new x.Vector3,this.matrix=new x.Matrix4,this.invMatrix=new x.Matrix4,this.points=new Array(8).fill().map(()=>new x.Vector3),this.satAxes=new Array(3).fill().map(()=>new x.Vector3),this.satBounds=new Array(3).fill().map(()=>new ne),this.alignedSatBounds=new Array(3).fill().map(()=>new ne),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}gt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,n=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const f=1*l|2*u|4*h,d=n[f];d.x=l?i.x:e.x,d.y=u?i.y:e.y,d.z=h?i.z:e.z,d.applyMatrix4(t)}const s=this.satBounds,o=this.satAxes,c=n[0];for(let l=0;l<3;l++){const u=o[l],h=s[l],f=1<<l,d=n[f];u.subVectors(c,d),h.setFromPoints(u,n)}const a=this.alignedSatBounds;a[0].setFromPointsField(n,"x"),a[1].setFromPointsField(n,"y"),a[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();gt.prototype.intersectsBox=function(){const r=new ne;return function(e){this.needsUpdate&&this.update();const i=e.min,n=e.max,s=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(r.min=i.x,r.max=n.x,c[0].isSeparated(r)||(r.min=i.y,r.max=n.y,c[1].isSeparated(r))||(r.min=i.z,r.max=n.z,c[2].isSeparated(r)))return!1;for(let a=0;a<3;a++){const l=o[a],u=s[a];if(r.setFromBox(l,e),u.isSeparated(r))return!1}return!0}}();gt.prototype.intersectsTriangle=function(){const r=new kt,t=new Array(3),e=new ne,i=new ne,n=new x.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const c=this.satBounds,a=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let f=0;f<3;f++){const d=c[f],p=a[f];if(e.setFromPoints(p,t),d.isSeparated(e))return!1}const l=o.satBounds,u=o.satAxes,h=this.points;for(let f=0;f<3;f++){const d=l[f],p=u[f];if(e.setFromPoints(p,h),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=a[f];for(let p=0;p<4;p++){const m=u[p];if(n.crossVectors(d,m),e.setFromPoints(n,t),i.setFromPoints(n,h),e.isSeparated(i))return!1}}return!0}}();gt.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();gt.prototype.distanceToPoint=function(){const r=new x.Vector3;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();gt.prototype.distanceToBox=function(){const r=["x","y","z"],t=new Array(12).fill().map(()=>new x.Line3),e=new Array(12).fill().map(()=>new x.Line3),i=new x.Vector3,n=new x.Vector3;return function(o,c=0,a=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(a||l)&&(o.getCenter(n),this.closestPointToPoint(n,i),o.closestPointToPoint(i,n),a&&a.copy(i),l&&l.copy(n)),0;const u=c*c,h=o.min,f=o.max,d=this.points;let p=1/0;for(let g=0;g<8;g++){const y=d[g];n.copy(y).clamp(h,f);const v=y.distanceToSquared(n);if(v<p&&(p=v,a&&a.copy(y),l&&l.copy(n),v<u))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){const b=(g+1)%3,S=(g+2)%3,_=y<<b|v<<S,T=1<<g|y<<b|v<<S,M=d[_],w=d[T];t[m].set(M,w);const C=r[g],A=r[b],P=r[S],R=e[m],k=R.start,O=R.end;k[C]=h[C],k[A]=y?h[A]:f[A],k[P]=v?h[P]:f[A],O[C]=f[C],O[A]=y?h[A]:f[A],O[P]=v?h[P]:f[A],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){n.x=g?f.x:h.x,n.y=y?f.y:h.y,n.z=v?f.z:h.z,this.closestPointToPoint(n,i);const b=n.distanceToSquared(i);if(b<p&&(p=b,a&&a.copy(i),l&&l.copy(n),b<u))return Math.sqrt(b)}for(let g=0;g<12;g++){const y=t[g];for(let v=0;v<12;v++){const b=e[v];hs(y,b,i,n);const S=i.distanceToSquared(n);if(S<p&&(p=S,a&&a.copy(i),l&&l.copy(n),S<u))return Math.sqrt(S)}}return Math.sqrt(p)}}();class fs{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class Au extends fs{constructor(){super(()=>new kt)}}const Rt=new Au;class Ru{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const H=new Ru;let fe,Xe;const Fe=[],br=new fs(()=>new x.Box3);function ku(r,t,e,i,n,s){fe=br.getPrimitive(),Xe=br.getPrimitive(),Fe.push(fe,Xe),H.setBuffer(r._roots[t]);const o=qn(0,r.geometry,e,i,n,s);H.clearBuffer(),br.releasePrimitive(fe),br.releasePrimitive(Xe),Fe.pop(),Fe.pop();const c=Fe.length;return c>0&&(Xe=Fe[c-1],fe=Fe[c-2]),o}function qn(r,t,e,i,n=null,s=0,o=0){const{float32Array:c,uint16Array:a,uint32Array:l}=H;let u=r*2;if(vt(u,a)){const f=Tt(r,l),d=Pt(u,a);return $(r,c,fe),i(f,d,!1,o,s+r,fe)}else{let C=function(P){const{uint16Array:R,uint32Array:k}=H;let O=P*2;for(;!vt(O,R);)P=At(P),O=P*2;return Tt(P,k)},A=function(P){const{uint16Array:R,uint32Array:k}=H;let O=P*2;for(;!vt(O,R);)P=Et(P,k),O=P*2;return Tt(P,k)+Pt(O,R)};const f=At(r),d=Et(r,l);let p=f,m=d,g,y,v,b;if(n&&(v=fe,b=Xe,$(p,c,v),$(m,c,b),g=n(v),y=n(b),y<g)){p=d,m=f;const P=g;g=y,y=P,v=b}v||(v=fe,$(p,c,v));const S=vt(p*2,a),_=e(v,S,g,o+1,s+p);let T;if(_===Gn){const P=C(p),k=A(p)-P;T=i(P,k,!0,o+1,s+p,v)}else T=_&&qn(p,t,e,i,n,s,o+1);if(T)return!0;b=Xe,$(m,c,b);const M=vt(m*2,a),w=e(b,M,y,o+1,s+m);let E;if(w===Gn){const P=C(m),k=A(m)-P;E=i(P,k,!0,o+1,s+m,b)}else E=w&&qn(m,t,e,i,n,s,o+1);return!!E}}const li=new x.Vector3,Sn=new x.Vector3;function Bu(r,t,e={},i=0,n=1/0){const s=i*i,o=n*n;let c=1/0,a=null;if(r.shapecast({boundsTraverseOrder:u=>(li.copy(t).clamp(u.min,u.max),li.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<c&&f<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,li);const f=t.distanceToSquared(li);return f<c&&(Sn.copy(li),c=f,a=h),f<s}}),c===1/0)return null;const l=Math.sqrt(c);return e.point?e.point.copy(Sn):e.point=Sn.clone(),e.distance=l,e.faceIndex=a,e}const zu=parseInt(x.REVISION)>=169,Pe=new x.Vector3,Ee=new x.Vector3,Ae=new x.Vector3,Sr=new x.Vector2,Tr=new x.Vector2,Mr=new x.Vector2,Ys=new x.Vector3,Zs=new x.Vector3,Qs=new x.Vector3,ui=new x.Vector3;function Ou(r,t,e,i,n,s,o,c){let a;if(s===x.BackSide?a=r.intersectTriangle(i,e,t,!0,n):a=r.intersectTriangle(t,e,i,s!==x.DoubleSide,n),a===null)return null;const l=r.origin.distanceTo(n);return l<o||l>c?null:{distance:l,point:n.clone()}}function Iu(r,t,e,i,n,s,o,c,a,l,u){Pe.fromBufferAttribute(t,s),Ee.fromBufferAttribute(t,o),Ae.fromBufferAttribute(t,c);const h=Ou(r,Pe,Ee,Ae,ui,a,l,u);if(h){const f=new x.Vector3;x.Triangle.getBarycoord(ui,Pe,Ee,Ae,f),i&&(Sr.fromBufferAttribute(i,s),Tr.fromBufferAttribute(i,o),Mr.fromBufferAttribute(i,c),h.uv=x.Triangle.getInterpolation(ui,Pe,Ee,Ae,Sr,Tr,Mr,new x.Vector2)),n&&(Sr.fromBufferAttribute(n,s),Tr.fromBufferAttribute(n,o),Mr.fromBufferAttribute(n,c),h.uv1=x.Triangle.getInterpolation(ui,Pe,Ee,Ae,Sr,Tr,Mr,new x.Vector2)),e&&(Ys.fromBufferAttribute(e,s),Zs.fromBufferAttribute(e,o),Qs.fromBufferAttribute(e,c),h.normal=x.Triangle.getInterpolation(ui,Pe,Ee,Ae,Ys,Zs,Qs,new x.Vector3),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const d={a:s,b:o,c,normal:new x.Vector3,materialIndex:0};x.Triangle.getNormal(Pe,Ee,Ae,d.normal),h.face=d,h.faceIndex=s,zu&&(h.barycoord=f)}return h}function nn(r,t,e,i,n,s,o){const c=i*3;let a=c+0,l=c+1,u=c+2;const h=r.index;r.index&&(a=h.getX(a),l=h.getX(l),u=h.getX(u));const{position:f,normal:d,uv:p,uv1:m}=r.attributes,g=Iu(e,f,d,p,m,a,l,u,t,s,o);return g?(g.faceIndex=i,n&&n.push(g),g):null}function K(r,t,e,i){const n=r.a,s=r.b,o=r.c;let c=t,a=t+1,l=t+2;e&&(c=e.getX(c),a=e.getX(a),l=e.getX(l)),n.x=i.getX(c),n.y=i.getY(c),n.z=i.getZ(c),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),o.x=i.getX(l),o.y=i.getY(l),o.z=i.getZ(l)}const hi=new x.Vector3,fi=new x.Vector3,di=new x.Vector3,Ks=new x.Vector2,to=new x.Vector2,eo=new x.Vector2;function Nu(r,t,e,i){const n=t.getIndex().array,s=t.getAttribute("position"),o=t.getAttribute("uv"),c=n[e*3],a=n[e*3+1],l=n[e*3+2];hi.fromBufferAttribute(s,c),fi.fromBufferAttribute(s,a),di.fromBufferAttribute(s,l);let u=0;const h=t.groups,f=e*3;for(let m=0,g=h.length;m<g;m++){const y=h[m],{start:v,count:b}=y;if(f>=v&&f<v+b){u=y.materialIndex;break}}const d=i&&i.barycoord?i.barycoord:new x.Vector3;x.Triangle.getBarycoord(r,hi,fi,di,d);let p=null;return o&&(Ks.fromBufferAttribute(o,c),to.fromBufferAttribute(o,a),eo.fromBufferAttribute(o,l),i&&i.uv?p=i.uv:p=new x.Vector2,x.Triangle.getInterpolation(r,hi,fi,di,Ks,to,eo,p)),i?(i.face||(i.face={}),i.face.a=c,i.face.b=a,i.face.c=l,i.face.materialIndex=u,i.face.normal||(i.face.normal=new x.Vector3),x.Triangle.getNormal(hi,fi,di,i.face.normal),p&&(i.uv=p),i.barycoord=d,i):{face:{a:c,b:a,c:l,materialIndex:u,normal:x.Triangle.getNormal(hi,fi,di,new x.Vector3)},uv:p,barycoord:d}}function Uu(r,t,e,i,n,s,o,c){const{geometry:a,_indirectBuffer:l}=r;for(let u=i,h=i+n;u<h;u++)nn(a,t,e,u,s,o,c)}function Du(r,t,e,i,n,s,o){const{geometry:c,_indirectBuffer:a}=r;let l=1/0,u=null;for(let h=i,f=i+n;h<f;h++){let d;d=nn(c,t,e,h,null,s,o),d&&d.distance<l&&(u=d,l=d.distance)}return u}function Fu(r,t,e,i,n,s,o){const{geometry:c}=e,{index:a}=c,l=c.attributes.position;for(let u=r,h=t+r;u<h;u++){let f;if(f=u,K(o,f*3,a,l),o.needsUpdate=!0,i(o,f,n,s))return!0}return!1}function Lu(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,n=e.attributes.position;let s,o,c,a,l=0;const u=r._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],o=new Uint32Array(s),c=new Uint16Array(s),a=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,p=!1){const m=f*2;if(c[m+15]===rn){const y=o[f+6],v=c[m+14];let b=1/0,S=1/0,_=1/0,T=-1/0,M=-1/0,w=-1/0;for(let E=3*y,C=3*(y+v);E<C;E++){let A=i[E];const P=n.getX(A),R=n.getY(A),k=n.getZ(A);P<b&&(b=P),P>T&&(T=P),R<S&&(S=R),R>M&&(M=R),k<_&&(_=k),k>w&&(w=k)}return a[f+0]!==b||a[f+1]!==S||a[f+2]!==_||a[f+3]!==T||a[f+4]!==M||a[f+5]!==w?(a[f+0]=b,a[f+1]=S,a[f+2]=_,a[f+3]=T,a[f+4]=M,a[f+5]=w,!0):!1}else{const y=f+8,v=o[f+6],b=y+d,S=v+d;let _=p,T=!1,M=!1;t?_||(T=t.has(b),M=t.has(S),_=!T&&!M):(T=!0,M=!0);const w=_||T,E=_||M;let C=!1;w&&(C=h(y,d,_));let A=!1;E&&(A=h(v,d,_));const P=C||A;if(P)for(let R=0;R<3;R++){const k=y+R,O=v+R,N=a[k],D=a[k+3],V=a[O],W=a[O+3];a[f+R]=N<V?N:V,a[f+R+3]=D>W?D:W}return P}}}function pe(r,t,e,i,n){let s,o,c,a,l,u;const h=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,p=e.origin.x,m=e.origin.y,g=e.origin.z;let y=t[r],v=t[r+3],b=t[r+1],S=t[r+3+1],_=t[r+2],T=t[r+3+2];return h>=0?(s=(y-p)*h,o=(v-p)*h):(s=(v-p)*h,o=(y-p)*h),f>=0?(c=(b-m)*f,a=(S-m)*f):(c=(S-m)*f,a=(b-m)*f),s>a||c>o||((c>s||isNaN(s))&&(s=c),(a<o||isNaN(o))&&(o=a),d>=0?(l=(_-g)*d,u=(T-g)*d):(l=(T-g)*d,u=(_-g)*d),s>u||l>o)?!1:((l>s||s!==s)&&(s=l),(u<o||o!==o)&&(o=u),s<=n&&o>=i)}function Vu(r,t,e,i,n,s,o,c){const{geometry:a,_indirectBuffer:l}=r;for(let u=i,h=i+n;u<h;u++){let f=l?l[u]:u;nn(a,t,e,f,s,o,c)}}function Ju(r,t,e,i,n,s,o){const{geometry:c,_indirectBuffer:a}=r;let l=1/0,u=null;for(let h=i,f=i+n;h<f;h++){let d;d=nn(c,t,e,a?a[h]:h,null,s,o),d&&d.distance<l&&(u=d,l=d.distance)}return u}function Gu(r,t,e,i,n,s,o){const{geometry:c}=e,{index:a}=c,l=c.attributes.position;for(let u=r,h=t+r;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),K(o,f*3,a,l),o.needsUpdate=!0,i(o,f,n,s))return!0}return!1}function ju(r,t,e,i,n,s,o){H.setBuffer(r._roots[t]),Xn(0,r,e,i,n,s,o),H.clearBuffer()}function Xn(r,t,e,i,n,s,o){const{float32Array:c,uint16Array:a,uint32Array:l}=H,u=r*2;if(vt(u,a)){const f=Tt(r,l),d=Pt(u,a);Uu(t,e,i,f,d,n,s,o)}else{const f=At(r);pe(f,c,i,s,o)&&Xn(f,t,e,i,n,s,o);const d=Et(r,l);pe(d,c,i,s,o)&&Xn(d,t,e,i,n,s,o)}}const $u=["x","y","z"];function Hu(r,t,e,i,n,s){H.setBuffer(r._roots[t]);const o=Wn(0,r,e,i,n,s);return H.clearBuffer(),o}function Wn(r,t,e,i,n,s){const{float32Array:o,uint16Array:c,uint32Array:a}=H;let l=r*2;if(vt(l,c)){const h=Tt(r,a),f=Pt(l,c);return Du(t,e,i,h,f,n,s)}else{const h=us(r,a),f=$u[h],p=i.direction[f]>=0;let m,g;p?(m=At(r),g=Et(r,a)):(m=Et(r,a),g=At(r));const v=pe(m,o,i,n,s)?Wn(m,t,e,i,n,s):null;if(v){const _=v.point[f];if(p?_<=o[g+h]:_>=o[g+h+3])return v}const S=pe(g,o,i,n,s)?Wn(g,t,e,i,n,s):null;return v&&S?v.distance<=S.distance?v:S:v||S||null}}const Cr=new x.Box3,Le=new kt,Ve=new kt,pi=new x.Matrix4,io=new gt,wr=new gt;function qu(r,t,e,i){H.setBuffer(r._roots[t]);const n=Yn(0,r,e,i);return H.clearBuffer(),n}function Yn(r,t,e,i,n=null){const{float32Array:s,uint16Array:o,uint32Array:c}=H;let a=r*2;if(n===null&&(e.boundingBox||e.computeBoundingBox(),io.set(e.boundingBox.min,e.boundingBox.max,i),n=io),vt(a,o)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,p=e.attributes.position,m=Tt(r,c),g=Pt(a,o);if(pi.copy(i).invert(),e.boundsTree)return $(r,s,wr),wr.matrix.copy(pi),wr.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>wr.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let b=m*3,S=(g+m)*3;b<S;b+=3)if(K(Ve,b,h,f),Ve.needsUpdate=!0,v.intersectsTriangle(Ve))return!0;return!1}});for(let y=m*3,v=(g+m)*3;y<v;y+=3){K(Le,y,h,f),Le.a.applyMatrix4(pi),Le.b.applyMatrix4(pi),Le.c.applyMatrix4(pi),Le.needsUpdate=!0;for(let b=0,S=d.count;b<S;b+=3)if(K(Ve,b,d,p),Ve.needsUpdate=!0,Le.intersectsTriangle(Ve))return!0}}else{const u=r+8,h=c[r+6];return $(u,s,Cr),!!(n.intersectsBox(Cr)&&Yn(u,t,e,i,n)||($(h,s,Cr),n.intersectsBox(Cr)&&Yn(h,t,e,i,n)))}}const Pr=new x.Matrix4,Tn=new gt,mi=new gt,Xu=new x.Vector3,Wu=new x.Vector3,Yu=new x.Vector3,Zu=new x.Vector3;function Qu(r,t,e,i={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Tn.set(t.boundingBox.min,t.boundingBox.max,e),Tn.needsUpdate=!0;const c=r.geometry,a=c.attributes.position,l=c.index,u=t.attributes.position,h=t.index,f=Rt.getPrimitive(),d=Rt.getPrimitive();let p=Xu,m=Wu,g=null,y=null;n&&(g=Yu,y=Zu);let v=1/0,b=null,S=null;return Pr.copy(e).invert(),mi.matrix.copy(Pr),r.shapecast({boundsTraverseOrder:_=>Tn.distanceToBox(_),intersectsBounds:(_,T,M)=>M<v&&M<o?(T&&(mi.min.copy(_.min),mi.max.copy(_.max),mi.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:w=>mi.distanceToBox(w),intersectsBounds:(w,E,C)=>C<v&&C<o,intersectsRange:(w,E)=>{for(let C=w,A=w+E;C<A;C++){K(d,3*C,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=_,R=_+T;P<R;P++){K(f,3*P,l,a),f.needsUpdate=!0;const k=f.distanceToTriangle(d,p,g);if(k<v&&(m.copy(p),y&&y.copy(g),v=k,b=P,S=C),k<s)return!0}}}});{const M=ti(t);for(let w=0,E=M;w<E;w++){K(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let C=_,A=_+T;C<A;C++){K(f,3*C,l,a),f.needsUpdate=!0;const P=f.distanceToTriangle(d,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,b=C,S=w),P<s)return!0}}}}}),Rt.releasePrimitive(f),Rt.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=b,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(Pr),m.applyMatrix4(Pr),n.distance=m.sub(n.point).length(),n.faceIndex=S),i)}function Ku(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,n=e.attributes.position;let s,o,c,a,l=0;const u=r._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],o=new Uint32Array(s),c=new Uint16Array(s),a=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,p=!1){const m=f*2;if(c[m+15]===rn){const y=o[f+6],v=c[m+14];let b=1/0,S=1/0,_=1/0,T=-1/0,M=-1/0,w=-1/0;for(let E=y,C=y+v;E<C;E++){const A=3*r.resolveTriangleIndex(E);for(let P=0;P<3;P++){let R=A+P;R=i?i[R]:R;const k=n.getX(R),O=n.getY(R),N=n.getZ(R);k<b&&(b=k),k>T&&(T=k),O<S&&(S=O),O>M&&(M=O),N<_&&(_=N),N>w&&(w=N)}}return a[f+0]!==b||a[f+1]!==S||a[f+2]!==_||a[f+3]!==T||a[f+4]!==M||a[f+5]!==w?(a[f+0]=b,a[f+1]=S,a[f+2]=_,a[f+3]=T,a[f+4]=M,a[f+5]=w,!0):!1}else{const y=f+8,v=o[f+6],b=y+d,S=v+d;let _=p,T=!1,M=!1;t?_||(T=t.has(b),M=t.has(S),_=!T&&!M):(T=!0,M=!0);const w=_||T,E=_||M;let C=!1;w&&(C=h(y,d,_));let A=!1;E&&(A=h(v,d,_));const P=C||A;if(P)for(let R=0;R<3;R++){const k=y+R,O=v+R,N=a[k],D=a[k+3],V=a[O],W=a[O+3];a[f+R]=N<V?N:V,a[f+R+3]=D>W?D:W}return P}}}function th(r,t,e,i,n,s,o){H.setBuffer(r._roots[t]),Zn(0,r,e,i,n,s,o),H.clearBuffer()}function Zn(r,t,e,i,n,s,o){const{float32Array:c,uint16Array:a,uint32Array:l}=H,u=r*2;if(vt(u,a)){const f=Tt(r,l),d=Pt(u,a);Vu(t,e,i,f,d,n,s,o)}else{const f=At(r);pe(f,c,i,s,o)&&Zn(f,t,e,i,n,s,o);const d=Et(r,l);pe(d,c,i,s,o)&&Zn(d,t,e,i,n,s,o)}}const eh=["x","y","z"];function ih(r,t,e,i,n,s){H.setBuffer(r._roots[t]);const o=Qn(0,r,e,i,n,s);return H.clearBuffer(),o}function Qn(r,t,e,i,n,s){const{float32Array:o,uint16Array:c,uint32Array:a}=H;let l=r*2;if(vt(l,c)){const h=Tt(r,a),f=Pt(l,c);return Ju(t,e,i,h,f,n,s)}else{const h=us(r,a),f=eh[h],p=i.direction[f]>=0;let m,g;p?(m=At(r),g=Et(r,a)):(m=Et(r,a),g=At(r));const v=pe(m,o,i,n,s)?Qn(m,t,e,i,n,s):null;if(v){const _=v.point[f];if(p?_<=o[g+h]:_>=o[g+h+3])return v}const S=pe(g,o,i,n,s)?Qn(g,t,e,i,n,s):null;return v&&S?v.distance<=S.distance?v:S:v||S||null}}const Er=new x.Box3,Je=new kt,Ge=new kt,yi=new x.Matrix4,ro=new gt,Ar=new gt;function rh(r,t,e,i){H.setBuffer(r._roots[t]);const n=Kn(0,r,e,i);return H.clearBuffer(),n}function Kn(r,t,e,i,n=null){const{float32Array:s,uint16Array:o,uint32Array:c}=H;let a=r*2;if(n===null&&(e.boundingBox||e.computeBoundingBox(),ro.set(e.boundingBox.min,e.boundingBox.max,i),n=ro),vt(a,o)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,p=e.attributes.position,m=Tt(r,c),g=Pt(a,o);if(yi.copy(i).invert(),e.boundsTree)return $(r,s,Ar),Ar.matrix.copy(yi),Ar.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>Ar.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let b=m,S=g+m;b<S;b++)if(K(Ge,3*t.resolveTriangleIndex(b),h,f),Ge.needsUpdate=!0,v.intersectsTriangle(Ge))return!0;return!1}});for(let y=m,v=g+m;y<v;y++){const b=t.resolveTriangleIndex(y);K(Je,3*b,h,f),Je.a.applyMatrix4(yi),Je.b.applyMatrix4(yi),Je.c.applyMatrix4(yi),Je.needsUpdate=!0;for(let S=0,_=d.count;S<_;S+=3)if(K(Ge,S,d,p),Ge.needsUpdate=!0,Je.intersectsTriangle(Ge))return!0}}else{const u=r+8,h=c[r+6];return $(u,s,Er),!!(n.intersectsBox(Er)&&Kn(u,t,e,i,n)||($(h,s,Er),n.intersectsBox(Er)&&Kn(h,t,e,i,n)))}}const Rr=new x.Matrix4,Mn=new gt,gi=new gt,nh=new x.Vector3,sh=new x.Vector3,oh=new x.Vector3,ah=new x.Vector3;function ch(r,t,e,i={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Mn.set(t.boundingBox.min,t.boundingBox.max,e),Mn.needsUpdate=!0;const c=r.geometry,a=c.attributes.position,l=c.index,u=t.attributes.position,h=t.index,f=Rt.getPrimitive(),d=Rt.getPrimitive();let p=nh,m=sh,g=null,y=null;n&&(g=oh,y=ah);let v=1/0,b=null,S=null;return Rr.copy(e).invert(),gi.matrix.copy(Rr),r.shapecast({boundsTraverseOrder:_=>Mn.distanceToBox(_),intersectsBounds:(_,T,M)=>M<v&&M<o?(T&&(gi.min.copy(_.min),gi.max.copy(_.max),gi.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(t.boundsTree){const M=t.boundsTree;return M.shapecast({boundsTraverseOrder:w=>gi.distanceToBox(w),intersectsBounds:(w,E,C)=>C<v&&C<o,intersectsRange:(w,E)=>{for(let C=w,A=w+E;C<A;C++){const P=M.resolveTriangleIndex(C);K(d,3*P,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let R=_,k=_+T;R<k;R++){const O=r.resolveTriangleIndex(R);K(f,3*O,l,a),f.needsUpdate=!0;const N=f.distanceToTriangle(d,p,g);if(N<v&&(m.copy(p),y&&y.copy(g),v=N,b=R,S=C),N<s)return!0}}}})}else{const M=ti(t);for(let w=0,E=M;w<E;w++){K(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let C=_,A=_+T;C<A;C++){const P=r.resolveTriangleIndex(C);K(f,3*P,l,a),f.needsUpdate=!0;const R=f.distanceToTriangle(d,p,g);if(R<v&&(m.copy(p),y&&y.copy(g),v=R,b=C,S=w),R<s)return!0}}}}}),Rt.releasePrimitive(f),Rt.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=b,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(Rr),m.applyMatrix4(Rr),n.distance=m.sub(n.point).length(),n.faceIndex=S),i)}function Ba(){return typeof SharedArrayBuffer<"u"}const wi=new H.constructor,Zr=new H.constructor,ue=new fs(()=>new x.Box3),je=new x.Box3,$e=new x.Box3,Cn=new x.Box3,wn=new x.Box3;let Pn=!1;function lh(r,t,e,i){if(Pn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Pn=!0;const n=r._roots,s=t._roots;let o,c=0,a=0;const l=new x.Matrix4().copy(e).invert();for(let u=0,h=n.length;u<h;u++){wi.setBuffer(n[u]),a=0;const f=ue.getPrimitive();$(0,wi.float32Array,f),f.applyMatrix4(l);for(let d=0,p=s.length;d<p&&(Zr.setBuffer(s[d]),o=Ut(0,0,e,l,i,c,a,0,0,f),Zr.clearBuffer(),a+=s[d].length,!o);d++);if(ue.releasePrimitive(f),wi.clearBuffer(),c+=n[u].length,o)break}return Pn=!1,o}function Ut(r,t,e,i,n,s=0,o=0,c=0,a=0,l=null,u=!1){let h,f;u?(h=Zr,f=wi):(h=wi,f=Zr);const d=h.float32Array,p=h.uint32Array,m=h.uint16Array,g=f.float32Array,y=f.uint32Array,v=f.uint16Array,b=r*2,S=t*2,_=vt(b,m),T=vt(S,v);let M=!1;if(T&&_)u?M=n(Tt(t,y),Pt(t*2,v),Tt(r,p),Pt(r*2,m),a,o+t,c,s+r):M=n(Tt(r,p),Pt(r*2,m),Tt(t,y),Pt(t*2,v),c,s+r,a,o+t);else if(T){const w=ue.getPrimitive();$(t,g,w),w.applyMatrix4(e);const E=At(r),C=Et(r,p);$(E,d,je),$(C,d,$e);const A=w.intersectsBox(je),P=w.intersectsBox($e);M=A&&Ut(t,E,i,e,n,o,s,a,c+1,w,!u)||P&&Ut(t,C,i,e,n,o,s,a,c+1,w,!u),ue.releasePrimitive(w)}else{const w=At(t),E=Et(t,y);$(w,g,Cn),$(E,g,wn);const C=l.intersectsBox(Cn),A=l.intersectsBox(wn);if(C&&A)M=Ut(r,w,e,i,n,s,o,c,a+1,l,u)||Ut(r,E,e,i,n,s,o,c,a+1,l,u);else if(C)if(_)M=Ut(r,w,e,i,n,s,o,c,a+1,l,u);else{const P=ue.getPrimitive();P.copy(Cn).applyMatrix4(e);const R=At(r),k=Et(r,p);$(R,d,je),$(k,d,$e);const O=P.intersectsBox(je),N=P.intersectsBox($e);M=O&&Ut(w,R,i,e,n,o,s,a,c+1,P,!u)||N&&Ut(w,k,i,e,n,o,s,a,c+1,P,!u),ue.releasePrimitive(P)}else if(A)if(_)M=Ut(r,E,e,i,n,s,o,c,a+1,l,u);else{const P=ue.getPrimitive();P.copy(wn).applyMatrix4(e);const R=At(r),k=Et(r,p);$(R,d,je),$(k,d,$e);const O=P.intersectsBox(je),N=P.intersectsBox($e);M=O&&Ut(E,R,i,e,n,o,s,a,c+1,P,!u)||N&&Ut(E,k,i,e,n,o,s,a,c+1,P,!u),ue.releasePrimitive(P)}}return M}const kr=new gt,no=new x.Box3,uh={strategy:ls,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class me{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,n=t._roots,s=t._indirectBuffer,o=i.getIndex();let c;return e.cloneBuffers?c={roots:n.map(a=>a.slice()),index:o?o.array.slice():null,indirectBuffer:s?s.slice():null}:c={roots:n,index:o?o.array:null,indirectBuffer:s},c}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:n,roots:s,indirectBuffer:o}=t,c=new me(e,{...i,[vn]:!0});if(c._roots=s,c._indirectBuffer=o||null,i.setIndex){const a=e.getIndex();if(a===null){const l=new x.BufferAttribute(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({...uh,[vn]:!1},e),e.useSharedArrayBuffer&&!Ba())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[vn]||(Cu(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new x.Box3))),this.resolveTriangleIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i}refit(t=null){return(this.indirect?Ku:Lu)(this,t)}traverse(t,e=0){const i=this._roots[e],n=new Uint32Array(i),s=new Uint16Array(i);o(0);function o(c,a=0){const l=c*2,u=s[l+15]===rn;if(u){const h=n[c+6],f=s[l+14];t(a,u,new Float32Array(i,c*4,6),h,f)}else{const h=c+de/4,f=n[c+6],d=n[c+7];t(a,u,new Float32Array(i,c*4,6),d)||(o(h,a+1),o(f,a+1))}}}raycast(t,e=x.FrontSide,i=0,n=1/0){const s=this._roots,o=this.geometry,c=[],a=e.isMaterial,l=Array.isArray(e),u=o.groups,h=a?e.side:e,f=this.indirect?th:ju;for(let d=0,p=s.length;d<p;d++){const m=l?e[u[d].materialIndex].side:h,g=c.length;if(f(this,d,m,t,c,i,n),l){const y=u[d].materialIndex;for(let v=g,b=c.length;v<b;v++)c[v].face.materialIndex=y}}return c}raycastFirst(t,e=x.FrontSide,i=0,n=1/0){const s=this._roots,o=this.geometry,c=e.isMaterial,a=Array.isArray(e);let l=null;const u=o.groups,h=c?e.side:e,f=this.indirect?ih:Hu;for(let d=0,p=s.length;d<p;d++){const m=a?e[u[d].materialIndex].side:h,g=f(this,d,m,t,i,n);g!=null&&(l==null||g.distance<l.distance)&&(l=g,a&&(g.face.materialIndex=u[d].materialIndex))}return l}intersectsGeometry(t,e){let i=!1;const n=this._roots,s=this.indirect?rh:qu;for(let o=0,c=n.length;o<c&&(i=s(this,o,t,e),!i);o++);return i}shapecast(t){const e=Rt.getPrimitive(),i=this.indirect?Gu:Fu;let{boundsTraverseOrder:n,intersectsBounds:s,intersectsRange:o,intersectsTriangle:c}=t;if(o&&c){const h=o;o=(f,d,p,m,g)=>h(f,d,p,m,g)?!0:i(f,d,this,c,p,m,e)}else o||(c?o=(h,f,d,p)=>i(h,f,this,c,d,p,e):o=(h,f,d)=>d);let a=!1,l=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(a=ku(this,h,s,o,n,l),a)break;l+=d.byteLength}return Rt.releasePrimitive(e),a}bvhcast(t,e,i){let{intersectsRanges:n,intersectsTriangles:s}=i;const o=Rt.getPrimitive(),c=this.geometry.index,a=this.geometry.attributes.position,l=this.indirect?p=>{const m=this.resolveTriangleIndex(p);K(o,m*3,c,a)}:p=>{K(o,p*3,c,a)},u=Rt.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?p=>{const m=t.resolveTriangleIndex(p);K(u,m*3,h,f)}:p=>{K(u,p*3,h,f)};if(s){const p=(m,g,y,v,b,S,_,T)=>{for(let M=y,w=y+v;M<w;M++){d(M),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let E=m,C=m+g;E<C;E++)if(l(E),o.needsUpdate=!0,s(o,u,E,M,b,S,_,T))return!0}return!1};if(n){const m=n;n=function(g,y,v,b,S,_,T,M){return m(g,y,v,b,S,_,T,M)?!0:p(g,y,v,b,S,_,T,M)}}else n=p}return lh(this,t,e,n)}intersectsBox(t,e){return kr.set(t.min,t.max,e),kr.needsUpdate=!0,this.shapecast({intersectsBounds:i=>kr.intersectsBox(i),intersectsTriangle:i=>kr.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},n={},s=0,o=1/0){return(this.indirect?ch:Qu)(this,t,e,i,n,s,o)}closestPointToPoint(t,e={},i=0,n=1/0){return Bu(this,t,e,i,n)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{$(0,new Float32Array(i),no),t.union(no)}),t}}const so=new x.Box3,oo=new x.Matrix4;class hh extends x.Object3D{get isMesh(){return!this.displayEdges}get isLineSegments(){return this.displayEdges}get isLine(){return this.displayEdges}getVertexPosition(...t){return x.Mesh.prototype.getVertexPosition.call(this,...t)}constructor(t,e,i=10,n=0){super(),this.material=e,this.geometry=new x.BufferGeometry,this.name="MeshBVHRootHelper",this.depth=i,this.displayParents=!1,this.bvh=t,this.displayEdges=!0,this._group=n}raycast(){}update(){const t=this.geometry,e=this.bvh,i=this._group;if(t.dispose(),this.visible=!1,e){const n=this.depth-1,s=this.displayParents;let o=0;e.traverse((f,d)=>{if(f>=n||d)return o++,!0;s&&o++},i);let c=0;const a=new Float32Array(8*3*o);e.traverse((f,d,p)=>{const m=f>=n||d;if(m||s){$(0,p,so);const{min:g,max:y}=so;for(let v=-1;v<=1;v+=2){const b=v<0?g.x:y.x;for(let S=-1;S<=1;S+=2){const _=S<0?g.y:y.y;for(let T=-1;T<=1;T+=2){const M=T<0?g.z:y.z;a[c+0]=b,a[c+1]=_,a[c+2]=M,c+=3}}}return m}},i);let l,u;this.displayEdges?u=new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):u=new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),a.length>65535?l=new Uint32Array(u.length*o):l=new Uint16Array(u.length*o);const h=u.length;for(let f=0;f<o;f++){const d=f*8,p=f*h;for(let m=0;m<h;m++)l[p+m]=d+u[m]}t.setIndex(new x.BufferAttribute(l,1,!1)),t.setAttribute("position",new x.BufferAttribute(a,3,!1)),this.visible=!0}}}class ds extends x.Group{get color(){return this.edgeMaterial.color}get opacity(){return this.edgeMaterial.opacity}set opacity(t){this.edgeMaterial.opacity=t,this.meshMaterial.opacity=t}constructor(t=null,e=null,i=10){t instanceof me&&(i=e||10,e=t,t=null),typeof e=="number"&&(i=e,e=null),super(),this.name="MeshBVHHelper",this.depth=i,this.mesh=t,this.bvh=e,this.displayParents=!1,this.displayEdges=!0,this.objectIndex=0,this._roots=[];const n=new x.LineBasicMaterial({color:65416,transparent:!0,opacity:.3,depthWrite:!1}),s=new x.MeshBasicMaterial({color:65416,transparent:!0,opacity:.3,depthWrite:!1});s.color=n.color,this.edgeMaterial=n,this.meshMaterial=s,this.update()}update(){const t=this.mesh;let e=this.bvh||t.geometry.boundsTree||null;if(t.isBatchedMesh&&t.boundsTrees&&!e){const n=t._drawInfo[this.objectIndex];n&&(e=t.boundsTrees[n.geometryIndex]||e)}const i=e?e._roots.length:0;for(;this._roots.length>i;){const n=this._roots.pop();n.geometry.dispose(),this.remove(n)}for(let n=0;n<i;n++){const{depth:s,edgeMaterial:o,meshMaterial:c,displayParents:a,displayEdges:l}=this;if(n>=this._roots.length){const h=new hh(e,o,s,n);this.add(h),this._roots.push(h)}const u=this._roots[n];u.bvh=e,u.depth=s,u.displayParents=a,u.displayEdges=l,u.material=l?o:c,u.update()}}updateMatrixWorld(...t){const e=this.mesh,i=this.parent;e!==null&&(e.updateWorldMatrix(!0,!1),i?this.matrix.copy(i.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,oo),this.matrix.multiply(oo)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new ds(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].geometry.dispose()}}const vi=new x.Box3,ao=new x.Box3,He=new x.Vector3;function co(r){switch(typeof r){case"number":return 8;case"string":return r.length*2;case"boolean":return 4;default:return 0}}function fh(r){return/(Uint|Int|Float)(8|16|32)Array/.test(r.constructor.name)}function dh(r,t){const e={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return r.traverse((i,n,s,o,c)=>{const a=s[3]-s[0],l=s[1+3]-s[1],u=s[2+3]-s[2],h=2*(a*l+l*u+u*a);e.nodeCount++,n?(e.leafNodeCount++,e.depth.min=Math.min(i,e.depth.min),e.depth.max=Math.max(i,e.depth.max),e.tris.min=Math.min(c,e.tris.min),e.tris.max=Math.max(c,e.tris.max),e.surfaceAreaScore+=h*Lr*c):(e.splits[o]++,e.surfaceAreaScore+=h*jn)},t),e.tris.min===1/0&&(e.tris.min=0,e.tris.max=0),e.depth.min===1/0&&(e.depth.min=0,e.depth.max=0),e}function ph(r){return r._roots.map((t,e)=>dh(r,e))}function mh(r){const t=new Set,e=[r];let i=0;for(;e.length;){const n=e.pop();if(!t.has(n)){t.add(n);for(let s in n){if(!Object.hasOwn(n,s))continue;i+=co(s);const o=n[s];o&&(typeof o=="object"||typeof o=="function")?fh(o)||Ba()&&o instanceof SharedArrayBuffer||o instanceof ArrayBuffer?i+=o.byteLength:e.push(o):i+=co(o)}}}return i}function yh(r){const t=r.geometry,e=[],i=t.index,n=t.getAttribute("position");let s=!0;return r.traverse((o,c,a,l,u)=>{const h={depth:o,isLeaf:c,boundingData:a,offset:l,count:u};e[o]=h,$(0,a,vi);const f=e[o-1];if(c)for(let d=l,p=l+u;d<p;d++){const m=r.resolveTriangleIndex(d);let g=3*m,y=3*m+1,v=3*m+2;i&&(g=i.getX(g),y=i.getX(y),v=i.getX(v));let b;He.fromBufferAttribute(n,g),b=vi.containsPoint(He),He.fromBufferAttribute(n,y),b=b&&vi.containsPoint(He),He.fromBufferAttribute(n,v),b=b&&vi.containsPoint(He),console.assert(b,"Leaf bounds does not fully contain triangle."),s=s&&b}if(f){$(0,a,ao);const d=ao.containsBox(vi);console.assert(d,"Parent bounds does not fully contain child."),s=s&&d}}),s}function gh(r){const t=[];return r.traverse((e,i,n,s,o)=>{const c={bounds:$(0,n,new x.Box3)};i?(c.count=o,c.offset=s):(c.left=null,c.right=null),t[e]=c;const a=t[e-1];a&&(a.left===null?a.left=c:a.right=c)}),t[0]}function lo(r,t,e){return r===null?null:(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r)}const vh=parseInt(x.REVISION)>=166,Br=new x.Ray,uo=new x.Vector3,ho=new x.Matrix4,xh=x.Mesh.prototype.raycast,_h=x.BatchedMesh.prototype.raycast,fo=new x.Vector3,ct=new x.Mesh,zr=[];function bh(r,t){this.isBatchedMesh?Sh.call(this,r,t):Th.call(this,r,t)}function Sh(r,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,n=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ct.material=this.material,ct.geometry=this.geometry;const o=ct.geometry.boundsTree,c=ct.geometry.drawRange;ct.geometry.boundingSphere===null&&(ct.geometry.boundingSphere=new x.Sphere);for(let a=0,l=i.length;a<l;a++){if(!this.getVisibleAt(a))continue;const u=i[a].geometryIndex;if(ct.geometry.boundsTree=e[u],this.getMatrixAt(a,ct.matrixWorld).premultiply(s),!ct.geometry.boundsTree){this.getBoundingBoxAt(u,ct.geometry.boundingBox),this.getBoundingSphereAt(u,ct.geometry.boundingSphere);const h=n[u];ct.geometry.setDrawRange(h.start,h.count)}ct.raycast(r,zr);for(let h=0,f=zr.length;h<f;h++){const d=zr[h];d.object=this,d.batchId=a,t.push(d)}zr.length=0}ct.geometry.boundsTree=o,ct.geometry.drawRange=c,ct.material=null,ct.geometry=null}else _h.call(this,r,t)}function Th(r,t){if(this.geometry.boundsTree){if(this.material===void 0)return;ho.copy(this.matrixWorld).invert(),Br.copy(r.ray).applyMatrix4(ho),fo.setFromMatrixScale(this.matrixWorld),uo.copy(Br.direction).multiply(fo);const e=uo.length(),i=r.near/e,n=r.far/e,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const o=lo(s.raycastFirst(Br,this.material,i,n),this,r);o&&t.push(o)}else{const o=s.raycast(Br,this.material,i,n);for(let c=0,a=o.length;c<a;c++){const l=lo(o[c],this,r);l&&t.push(l)}}}else xh.call(this,r,t)}function Mh(r={}){return this.boundsTree=new me(this,r),this.boundsTree}function Ch(){this.boundsTree=null}function wh(r=-1,t={}){if(!vh)throw new Error("BatchedMesh: Three r166+ is required to compute bounds trees.");t.indirect&&console.warn('"Indirect" is set to false because it is not supported for BatchedMesh.'),t={...t,indirect:!1,range:null};const e=this._drawRanges||this._geometryInfo,i=this._geometryCount;this.boundsTrees||(this.boundsTrees=new Array(i).fill(null));const n=this.boundsTrees;for(;n.length<i;)n.push(null);if(r<0){for(let s=0;s<i;s++)t.range=e[s],n[s]=new me(this.geometry,t);return n}else return r<e.length&&(t.range=e[r],n[r]=new me(this.geometry,t)),n[r]||null}function Ph(r=-1){r<0?this.boundsTrees.fill(null):r<this.boundsTree.length&&(this.boundsTrees[r]=null)}function Eh(r){switch(r){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Ah(r){switch(r){case 1:return x.RedFormat;case 2:return x.RGFormat;case 3:return x.RGBAFormat;case 4:return x.RGBAFormat}}function po(r){switch(r){case 1:return x.RedIntegerFormat;case 2:return x.RGIntegerFormat;case 3:return x.RGBAIntegerFormat;case 4:return x.RGBAIntegerFormat}}class sn extends x.DataTexture{constructor(){super(),this.minFilter=x.NearestFilter,this.magFilter=x.NearestFilter,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,i=t.itemSize,n=t.count;if(e!==null){if(i*n%e!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=n*i/e}const s=t.itemSize,o=t.count,c=t.normalized,a=t.array.constructor,l=a.BYTES_PER_ELEMENT;let u=this._forcedType,h=s;if(u===null)switch(a){case Float32Array:u=x.FloatType;break;case Uint8Array:case Uint16Array:case Uint32Array:u=x.UnsignedIntType;break;case Int8Array:case Int16Array:case Int32Array:u=x.IntType;break}let f,d,p,m,g=Eh(s);switch(u){case x.FloatType:p=1,d=Ah(s),c&&l===1?(m=a,g+="8",a===Uint8Array?f=x.UnsignedByteType:(f=x.ByteType,g+="_SNORM")):(m=Float32Array,g+="32F",f=x.FloatType);break;case x.IntType:g+=l*8+"I",p=c?Math.pow(2,a.BYTES_PER_ELEMENT*8-1):1,d=po(s),l===1?(m=Int8Array,f=x.ByteType):l===2?(m=Int16Array,f=x.ShortType):(m=Int32Array,f=x.IntType);break;case x.UnsignedIntType:g+=l*8+"UI",p=c?Math.pow(2,a.BYTES_PER_ELEMENT*8-1):1,d=po(s),l===1?(m=Uint8Array,f=x.UnsignedByteType):l===2?(m=Uint16Array,f=x.UnsignedShortType):(m=Uint32Array,f=x.UnsignedIntType);break}h===3&&(d===x.RGBAFormat||d===x.RGBAIntegerFormat)&&(h=4);const y=Math.ceil(Math.sqrt(o))||1,v=h*y*y,b=new m(v),S=t.normalized;t.normalized=!1;for(let _=0;_<o;_++){const T=h*_;b[T]=t.getX(_)/p,s>=2&&(b[T+1]=t.getY(_)/p),s>=3&&(b[T+2]=t.getZ(_)/p,h===4&&(b[T+3]=1)),s>=4&&(b[T+3]=t.getW(_)/p)}t.normalized=S,this.internalFormat=g,this.format=d,this.type=f,this.image.width=y,this.image.height=y,this.image.data=b,this.needsUpdate=!0,this.dispose(),t.itemSize=i,t.count=n}}class za extends sn{constructor(){super(),this._forcedType=x.UnsignedIntType}}class Rh extends sn{constructor(){super(),this._forcedType=x.IntType}}class Oa extends sn{constructor(){super(),this._forcedType=x.FloatType}}class kh{constructor(){this.index=new za,this.position=new Oa,this.bvhBounds=new x.DataTexture,this.bvhContents=new x.DataTexture,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(zh(t,this.bvhBounds,this.bvhContents),this.position.updateFrom(e.attributes.position),t.indirect){const i=t._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(e.index)this._cachedIndexAttr=e.index.clone();else{const n=Pa(wa(e));this._cachedIndexAttr=new x.BufferAttribute(n,1,!1)}Bh(e,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(e.index)}dispose(){const{index:t,position:e,bvhBounds:i,bvhContents:n}=this;t&&t.dispose(),e&&e.dispose(),i&&i.dispose(),n&&n.dispose()}}function Bh(r,t,e){const i=e.array,n=r.index?r.index.array:null;for(let s=0,o=t.length;s<o;s++){const c=3*s,a=3*t[s];for(let l=0;l<3;l++)i[c+l]=n?n[a+l]:a+l}}function zh(r,t,e){const i=r._roots;if(i.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const n=i[0],s=new Uint16Array(n),o=new Uint32Array(n),c=new Float32Array(n),a=n.byteLength/de,l=2*Math.ceil(Math.sqrt(a/2)),u=new Float32Array(4*l*l),h=Math.ceil(Math.sqrt(a)),f=new Uint32Array(2*h*h);for(let d=0;d<a;d++){const p=d*de/4,m=p*2,g=p;for(let y=0;y<3;y++)u[8*d+0+y]=c[g+0+y],u[8*d+4+y]=c[g+3+y];if(vt(m,s)){const y=Pt(m,s),v=Tt(p,o),b=4294901760|y;f[d*2+0]=b,f[d*2+1]=v}else{const y=4*Et(p,o)/de,v=us(p,o);f[d*2+0]=v,f[d*2+1]=y}}t.image.data=u,t.image.width=l,t.image.height=l,t.format=x.RGBAFormat,t.type=x.FloatType,t.internalFormat="RGBA32F",t.minFilter=x.NearestFilter,t.magFilter=x.NearestFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose(),e.image.data=f,e.image.width=h,e.image.height=h,e.format=x.RGIntegerFormat,e.type=x.UnsignedIntType,e.internalFormat="RG32UI",e.minFilter=x.NearestFilter,e.magFilter=x.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose()}const Re=new x.Vector3,ke=new x.Vector3,Be=new x.Vector3,mo=new x.Vector4,Or=new x.Vector3,En=new x.Vector3,yo=new x.Vector4,go=new x.Vector4,Ir=new x.Matrix4,vo=new x.Matrix4;function xi(r,t){if(!r&&!t)return;const e=r.count===t.count,i=r.normalized===t.normalized,n=r.array.constructor===t.array.constructor,s=r.itemSize===t.itemSize;if(!e||!i||!n||!s)throw new Error}function Mi(r,t=null){const e=r.array.constructor,i=r.normalized,n=r.itemSize,s=t===null?r.count:t;return new x.BufferAttribute(new e(n*s),n,i)}function Ia(r,t,e=0){if(r.isInterleavedBufferAttribute){const i=r.itemSize;for(let n=0,s=r.count;n<s;n++){const o=n+e;t.setX(o,r.getX(n)),i>=2&&t.setY(o,r.getY(n)),i>=3&&t.setZ(o,r.getZ(n)),i>=4&&t.setW(o,r.getW(n))}}else{const i=t.array,n=i.constructor,s=i.BYTES_PER_ELEMENT*r.itemSize*e;new n(i.buffer,s,r.array.length).set(r.array)}}function Oh(r,t,e){const i=r.elements,n=t.elements;for(let s=0,o=n.length;s<o;s++)i[s]+=n[s]*e}function xo(r,t,e){const i=r.skeleton,n=r.geometry,s=i.bones,o=i.boneInverses;yo.fromBufferAttribute(n.attributes.skinIndex,t),go.fromBufferAttribute(n.attributes.skinWeight,t),Ir.elements.fill(0);for(let c=0;c<4;c++){const a=go.getComponent(c);if(a!==0){const l=yo.getComponent(c);vo.multiplyMatrices(s[l].matrixWorld,o[l]),Oh(Ir,vo,a)}}return Ir.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),e.transformDirection(Ir),e}function An(r,t,e,i,n){Or.set(0,0,0);for(let s=0,o=r.length;s<o;s++){const c=t[s],a=r[s];c!==0&&(En.fromBufferAttribute(a,i),e?Or.addScaledVector(En,c):Or.addScaledVector(En.sub(n),c))}n.add(Or)}function Ih(r,t={useGroups:!1,updateIndex:!1,skipAttributes:[]},e=new x.BufferGeometry){const i=r[0].index!==null,{useGroups:n=!1,updateIndex:s=!1,skipAttributes:o=[]}=t,c=new Set(Object.keys(r[0].attributes)),a={};let l=0;e.clearGroups();for(let u=0;u<r.length;++u){const h=r[u];let f=0;if(i!==(h.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 d in h.attributes){if(!c.has(d))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.');a[d]===void 0&&(a[d]=[]),a[d].push(h.attributes[d]),f++}if(f!==c.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(n){let d;if(i)d=h.index.count;else if(h.attributes.position!==void 0)d=h.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");e.addGroup(l,d,u),l+=d}}if(i){let u=!1;if(!e.index){let h=0;for(let f=0;f<r.length;++f)h+=r[f].index.count;e.setIndex(new x.BufferAttribute(new Uint32Array(h),1,!1)),u=!0}if(s||u){const h=e.index;let f=0,d=0;for(let p=0;p<r.length;++p){const m=r[p],g=m.index;if(o[p]!==!0)for(let y=0;y<g.count;++y)h.setX(f,g.getX(y)+d),f++;d+=m.attributes.position.count}}}for(const u in a){const h=a[u];if(!(u in e.attributes)){let p=0;for(const m in h)p+=h[m].count;e.setAttribute(u,Mi(a[u][0],p))}const f=e.attributes[u];let d=0;for(let p=0,m=h.length;p<m;p++){const g=h[p];o[p]!==!0&&Ia(g,f,d),d+=g.count}}return e}function Nh(r,t){if(r===null||t===null)return r===t;if(r.length!==t.length)return!1;for(let e=0,i=r.length;e<i;e++)if(r[e]!==t[e])return!1;return!0}function Uh(r){const{index:t,attributes:e}=r;if(t)for(let i=0,n=t.count;i<n;i+=3){const s=t.getX(i),o=t.getX(i+2);t.setX(i,o),t.setX(i+2,s)}else for(const i in e){const n=e[i],s=n.itemSize;for(let o=0,c=n.count;o<c;o+=3)for(let a=0;a<s;a++){const l=n.getComponent(o,a),u=n.getComponent(o+2,a);n.setComponent(o,a,u),n.setComponent(o+2,a,l)}}return r}class Dh{constructor(t){this.matrixWorld=new x.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=t,this.update()}update(){const t=this.mesh,e=t.geometry,i=t.skeleton,n=(e.index?e.index.count:e.attributes.position.count)/3;if(this.matrixWorld.copy(t.matrixWorld),this.geometryHash=e.attributes.position.version,this.primitiveCount=n,i){i.boneTexture||i.computeBoneTexture(),i.update();const s=i.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const t=this.mesh,e=t.geometry,i=(e.index?e.index.count:e.attributes.position.count)/3;return!(this.matrixWorld.equals(t.matrixWorld)&&this.geometryHash===e.attributes.position.version&&Nh(t.skeleton&&t.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===i)}}class Fh{constructor(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(i=>{i.traverseVisible(n=>{n.isMesh&&e.push(n)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new x.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new x.BufferGeometry){let e=[];const{meshes:i,useGroups:n,_intermediateGeometry:s,_diffMap:o}=this;for(let c=0,a=i.length;c<a;c++){const l=i[c],u=s[c],h=o.get(l);!h||h.didChange(l)?(this._convertToStaticGeometry(l,u),e.push(!1),h?h.update():o.set(l,new Dh(l))):e.push(!0)}if(s.length===0){t.setIndex(null);const c=t.attributes;for(const a in c)t.deleteAttribute(a);for(const a in this.attributes)t.setAttribute(this.attributes[a],new x.BufferAttribute(new Float32Array(0),4,!1))}else Ih(s,{useGroups:n,skipAttributes:e},t);for(const c in t.attributes)t.attributes[c].needsUpdate=!0;return t}_convertToStaticGeometry(t,e=new x.BufferGeometry){const i=t.geometry,n=this.applyWorldTransforms,s=this.attributes.includes("normal"),o=this.attributes.includes("tangent"),c=i.attributes,a=e.attributes;!e.index&&i.index&&(e.index=i.index.clone()),a.position||e.setAttribute("position",Mi(c.position)),s&&!a.normal&&c.normal&&e.setAttribute("normal",Mi(c.normal)),o&&!a.tangent&&c.tangent&&e.setAttribute("tangent",Mi(c.tangent)),xi(i.index,e.index),xi(c.position,a.position),s&&xi(c.normal,a.normal),o&&xi(c.tangent,a.tangent);const l=c.position,u=s?c.normal:null,h=o?c.tangent:null,f=i.morphAttributes.position,d=i.morphAttributes.normal,p=i.morphAttributes.tangent,m=i.morphTargetsRelative,g=t.morphTargetInfluences,y=new x.Matrix3;y.getNormalMatrix(t.matrixWorld),i.index&&e.index.array.set(i.index.array);for(let v=0,b=c.position.count;v<b;v++)Re.fromBufferAttribute(l,v),u&&ke.fromBufferAttribute(u,v),h&&(mo.fromBufferAttribute(h,v),Be.fromBufferAttribute(h,v)),g&&(f&&An(f,g,m,v,Re),d&&An(d,g,m,v,ke),p&&An(p,g,m,v,Be)),t.isSkinnedMesh&&(t.applyBoneTransform(v,Re),u&&xo(t,v,ke),h&&xo(t,v,Be)),n&&Re.applyMatrix4(t.matrixWorld),a.position.setXYZ(v,Re.x,Re.y,Re.z),u&&(n&&ke.applyNormalMatrix(y),a.normal.setXYZ(v,ke.x,ke.y,ke.z)),h&&(n&&Be.transformDirection(t.matrixWorld),a.tangent.setXYZW(v,Be.x,Be.y,Be.z,mo.w));for(const v in this.attributes){const b=this.attributes[v];b==="position"||b==="tangent"||b==="normal"||!(b in c)||(a[b]||e.setAttribute(b,Mi(c[b])),xi(c[b],a[b]),Ia(c[b],a[b]))}return t.matrixWorld.determinant()<0&&Uh(e),e}}const Na=`
|
|
1122
1122
|
|
|
1123
1123
|
// A stack of uint32 indices can can store the indices for
|
|
1124
1124
|
// a perfectly balanced tree with a depth up to 31. Lower stack
|
|
@@ -1200,7 +1200,7 @@ void ndcToCameraRay(
|
|
|
1200
1200
|
rayDirection = direction.xyz;
|
|
1201
1201
|
|
|
1202
1202
|
}
|
|
1203
|
-
`,
|
|
1203
|
+
`,Ua=`
|
|
1204
1204
|
|
|
1205
1205
|
float dot2( vec3 v ) {
|
|
1206
1206
|
|
|
@@ -1385,7 +1385,7 @@ float _bvhClosestPointToPoint(
|
|
|
1385
1385
|
return sqrt( closestDistanceSquared );
|
|
1386
1386
|
|
|
1387
1387
|
}
|
|
1388
|
-
`,
|
|
1388
|
+
`,Da=`
|
|
1389
1389
|
|
|
1390
1390
|
#ifndef TRI_INTERSECT_EPSILON
|
|
1391
1391
|
#define TRI_INTERSECT_EPSILON 1e-5
|
|
@@ -1589,7 +1589,7 @@ bool _bvhIntersectFirstHit(
|
|
|
1589
1589
|
return found;
|
|
1590
1590
|
|
|
1591
1591
|
}
|
|
1592
|
-
`,
|
|
1592
|
+
`,Fa=`
|
|
1593
1593
|
struct BVH {
|
|
1594
1594
|
|
|
1595
1595
|
usampler2D index;
|
|
@@ -1599,7 +1599,7 @@ struct BVH {
|
|
|
1599
1599
|
usampler2D bvhContents;
|
|
1600
1600
|
|
|
1601
1601
|
};
|
|
1602
|
-
`,
|
|
1603
|
-
${
|
|
1604
|
-
${
|
|
1605
|
-
`,Eh=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Sc,BVHShaderGLSL:Fh,CENTER:ao,CONTAINED:Qn,ExtendedTriangle:Kt,FloatVertexAttributeTexture:kc,INTERSECTED:pd,IntVertexAttributeTexture:Th,MeshBVH:be,MeshBVHHelper:mo,MeshBVHUniformStruct:Mh,NOT_INTERSECTED:ud,OrientedBox:Gt,SAH:Wc,StaticGeometryGenerator:Ph,UIntVertexAttributeTexture:Yc,VertexAttributeTexture:on,acceleratedRaycast:xh,computeBatchedBoundsTree:Ch,computeBoundsTree:Wh,disposeBatchedBoundsTree:zh,disposeBoundsTree:gh,estimateMemoryInBytes:Gh,getBVHExtremes:yh,getJSONStructure:Xh,getTriangleHitPointInfo:Id,shaderDistanceFunction:wh,shaderIntersectFunction:Bh,shaderStructs:Qh,validateBounds:Zh},Symbol.toStringTag,{value:"Module"}));class jh{constructor(t){this.name="WorkerBase",this.running=!1,this.worker=t,this.worker.onerror=e=>{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...t){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 e=this.runTask(this.worker,...t);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}const Pc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBBbj10eXBlb2YgZG9jdW1lbnQ8InUiP2R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aGlzLnksdGhpcy56LHRoaXMudyl9Y29weSh0KXtyZXR1cm4gdGhpcy54PXQueCx0aGlzLnk9dC55LHRoaXMuej10LnosdGhpcy53PXQudyE9PXZvaWQgMD90Lnc6MSx0aGlzfWFkZCh0KXtyZXR1cm4gdGhpcy54Kz10LngsdGhpcy55Kz10LnksdGhpcy56Kz10LnosdGhpcy53Kz10LncsdGhpc31hZGRTY2FsYXIodCl7cmV0dXJuIHRoaXMueCs9dCx0aGlzLnkrPXQsdGhpcy56Kz10LHRoaXMudys9dCx0aGlzfWFkZFZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueCtlLngsdGhpcy55PXQueStlLnksdGhpcy56PXQueitlLnosdGhpcy53PXQudytlLncsdGhpc31hZGRTY2FsZWRWZWN0b3IodCxlKXtyZXR1cm4gdGhpcy54Kz10LngqZSx0aGlzLnkrPXQueSplLHRoaXMueis9dC56KmUsdGhpcy53Kz10LncqZSx0aGlzfXN1Yih0KXtyZXR1cm4gdGhpcy54LT10LngsdGhpcy55LT10LnksdGhpcy56LT10LnosdGhpcy53LT10LncsdGhpc31zdWJTY2FsYXIodCl7cmV0dXJuIHRoaXMueC09dCx0aGlzLnktPXQsdGhpcy56LT10LHRoaXMudy09dCx0aGlzfXN1YlZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueC1lLngsdGhpcy55PXQueS1lLnksdGhpcy56PXQuei1lLnosdGhpcy53PXQudy1lLncsdGhpc31tdWx0aXBseSh0KXtyZXR1cm4gdGhpcy54Kj10LngsdGhpcy55Kj10LnksdGhpcy56Kj10LnosdGhpcy53Kj10LncsdGhpc31tdWx0aXBseVNjYWxhcih0KXtyZXR1cm4gdGhpcy54Kj10LHRoaXMueSo9dCx0aGlzLnoqPXQsdGhpcy53Kj10LHRoaXN9YXBwbHlNYXRyaXg0KHQpe2NvbnN0IGU9dGhpcy54LHM9dGhpcy55LG49dGhpcy56LGk9dGhpcy53LG89dC5lbGVtZW50cztyZXR1cm4gdGhpc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J1bmModGhpcy53KSx0aGlzfW5lZ2F0ZSgpe3JldHVybiB0aGlzLng9LXRoaXMueCx0aGlzLnk9LXRoaXMueSx0aGlzLno9LXRoaXMueix0aGlzLnc9LXRoaXMudyx0aGlzfWRvdCh0KXtyZXR1cm4gdGhpcy54KnQueCt0aGlzLnkqdC55K3RoaXMueip0LnordGhpcy53KnQud31sZW5ndGhTcSgpe3JldHVybiB0aGlzLngqdGhpcy54K3RoaXMueSp0aGlzLnkrdGhpcy56KnRoaXMueit0aGlzLncqdGhpcy53fWxlbmd0aCgpe3JldHVybiBNYXRoLnNxcnQodGhpcy54KnRoaXMueCt0aGlzLnkqdGhpcy55K3RoaXMueip0aGlzLnordGhpcy53KnRoaXMudyl9bWFuaGF0dGFuTGVuZ3RoKCl7cmV0dXJuIE1hdGguYWJzKHRoaXMueCkrTWF0aC5hYnModGhpcy55KStNYXRoLmFicyh0aGlzLnopK01hdGguYWJzKHRoaXMudyl9bm9ybWFsaXplKCl7cmV0dXJuIHRoaXMuZGl2aWRlU2NhbGFyKHRoaXMubGVuZ3RoKCl8fDEpfXNldExlbmd0aCh0KXtyZXR1cm4gdGhpcy5ub3JtYWxpemUoKS5tdWx0aXBseVNjYWxhcih0KX1sZXJwKHQsZSl7cmV0dXJuIHRoaXMueCs9KHQueC10aGlzLngpKmUsdGhpcy55Kz0odC55LXRoaXMueSkqZSx0aGlzLnorPSh0LnotdGhpcy56KSplLHRoaXMudys9KHQudy10aGlzLncpKmUsdGhpc31sZXJwVmVjdG9ycyh0LGUscyl7cmV0dXJuIHRoaXMueD10LngrKGUueC10LngpKnMsdGhpcy55PXQueSsoZS55LXQueSkqcyx0aGlzLno9dC56KyhlLnotdC56KSpzLHRoaXMudz10LncrKGUudy10LncpKnMsdGhpc31lcXVhbHModCl7cmV0dXJuIHQueD09PXRoaXMueCYmdC55PT09dGhpcy55JiZ0Lno9PT10aGlzLnomJnQudz09PXRoaXMud31mcm9tQXJyYXkodCxlPTApe3JldHVybiB0aGl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Glvbk1hdHJpeEludmVyc2UpLmFwcGx5TWF0cml4NCh0Lm1hdHJpeFdvcmxkKX10cmFuc2Zvcm1EaXJlY3Rpb24odCl7Y29uc3QgZT10aGlzLngscz10aGlzLnksbj10aGlzLnosaT10LmVsZW1lbnRzO3JldHVybiB0aGlzLng9aVswXSplK2lbNF0qcytpWzhdKm4sdGhpcy55PWlbMV0qZStpWzVdKnMraVs5XSpuLHRoaXMuej1pWzJdKmUraVs2XSpzK2lbMTBdKm4sdGhpcy5ub3JtYWxpemUoKX1kaXZpZGUodCl7cmV0dXJuIHRoaXMueC89dC54LHRoaXMueS89dC55LHRoaXMuei89dC56LHRoaXN9ZGl2aWRlU2NhbGFyKHQpe3JldHVybiB0aGlzLm11bHRpcGx5U2NhbGFyKDEvdCl9bWluKHQpe3JldHVybiB0aGlzLng9TWF0aC5taW4odGhpcy54LHQueCksdGhpcy55PU1hdGgubWluKHRoaXMueSx0LnkpLHRoaXMuej1NYXRoLm1pbih0aGlzLnosdC56KSx0aGlzfW1heCh0KXtyZXR1cm4gdGhpcy54PU1hdGgubWF4KHRoaXMueCx0LngpLHRoaXMueT1NYXRoLm1heCh0aGlzLnksdC55KSx0aGlzLno9TWF0aC5tYXgodGhpcy56LHQueiksdGhpc31jbGFtcCh0LGUpe3JldHVybiB0aGlzLng9TWF0aC5tYXgodC54LE1hdGgubWluKGUueCx0aGlzLngpKSx0aGlzLnk9TWF0aC5tYXgodC55LE1hdGgubWluKGUueSx0aGlzLnkpKSx0aGlzLno9TWF0aC5tYXgodC56LE1hdGgubWluKGUueix0aGlzLnopKSx0aGlzfWNsYW1wU2NhbGFyKHQsZSl7cmV0dXJuIHRoaXMueD1NYXRoLm1heCh0LE1hdGgubWluKGUsdGhpcy54KSksdGhpcy55PU1hdGgubWF4KHQsTWF0aC5taW4oZSx0aGlzLnkpKSx0aGlzLno9TWF0aC5tYXgodCxNYXRoLm1pbihlLHRoaXMueikpLHRoaXN9Y2xhbXBMZW5ndGgodCxlKXtj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Lm11bChpKSx1PW8ueC5tdWwoaSksaD1vLnkubXVsKGkpLGw9YS5kaXYoMiksZD1jLmRpdigyKSxmPXUuZGl2KDIpLHA9aC5kaXYoMik7cmV0dXJuIGZlKHModC54eS5hZGQoRChhLGMpKSx0LnopLHModC54eS5hZGQoRCgwLGMpKSx0LnopLHModC54eS5hZGQoRCh1LGMpKSx0LnopLHModC54eS5hZGQoRChsLGQpKSx0LnopLHModC54eS5hZGQoRCgwLGQpKSx0LnopLHModC54eS5hZGQoRChmLGQpKSx0LnopLHModC54eS5hZGQoRChhLDApKSx0LnopLHModC54eS5hZGQoRChsLDApKSx0LnopLHModC54eSx0LnopLHModC54eS5hZGQoRChmLDApKSx0LnopLHModC54eS5hZGQoRCh1LDApKSx0LnopLHModC54eS5hZGQoRChsLHApKSx0LnopLHModC54eS5hZGQoRCgwLHApKSx0LnopLHModC54eS5hZGQoRChmLHApKSx0LnopLHModC54eS5hZGQoRChhLGgpKSx0LnopLHModC54eS5hZGQoRCgwLGgpKSx0LnopLHModC54eS5hZGQoRCh1LGgpKSx0LnopKS5tdWwoMS8xNyl9KSx0dCgoe2RlcHRoVGV4dHVyZTpyLHNoYWRvd0Nvb3JkOnQsc2hhZG93OmV9KT0+e2NvbnN0IHM9KGgsbCk9PmFzKHIsaCkuY29tcGFyZShsKSxuPXBlKCJtYXBTaXplIiwidmVjMiIsZSkuc2V0R3JvdXAoZGUpLGk9RCgxKS5kaXYobiksbz1pLngsYT1pLnksYz10Lnh5LHU9cmkoYy5tdWwobikuYWRkKC41KSk7cmV0dXJuIGMuc3ViQXNzaWduKHUubXVsKGkpKSxmZShzKGMsdC56KSxzKGMuYWRkKEQobywwKSksdC56KSxzKGMuYWRkKEQoMCxhKSksdC56KSxzKGMuYWRkKGkpLHQueikscmUocyhjLmFkZChEKG8ubmVnYXRlKCksMCkpLHQueikscyhjLmFkZChEKG8ubXVsKDIpLDApKSx0LnopLHUueCkscmUocyhjLmFkZChEKG8ubmVnYXRlKCksYSkpL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vwcyl7Y29uc3QgaD1pLmdyb3Vwcztmb3IoY29uc3QgbCBpbiBoKXtjb25zdCBkPWhbbF07by5hZGRHcm91cChkLnN0YXJ0LGQuY291bnQsZC5tYXRlcmlhbEluZGV4KX19Y29uc3QgYT1uZXcgVG4obyxpKSxjPVRuLnNlcmlhbGl6ZShhLHtjb3B5SW5kZXhCdWZmZXI6ITF9KTtsZXQgdT1bbi5idWZmZXIsLi4uYy5yb290c107Yy5pbmRleCYmdS5wdXNoKGMuaW5kZXguYnVmZmVyKSx1PXUuZmlsdGVyKGg9PnR5cGVvZiBTaGFyZWRBcnJheUJ1ZmZlcj4idSJ8fCEoaCBpbnN0YW5jZW9mIFNoYXJlZEFycmF5QnVmZmVyKSksYS5faW5kaXJlY3RCdWZmZXImJnUucHVzaChjLmluZGlyZWN0QnVmZmVyLmJ1ZmZlcikscG9zdE1lc3NhZ2Uoe2Vycm9yOm51bGwsc2VyaWFsaXplZDpjLHBvc2l0aW9uOm4scHJvZ3Jlc3M6MX0sdSl9Y2F0Y2gobyl7cG9zdE1lc3NhZ2Uoe2Vycm9yOm8sc2VyaWFsaXplZDpudWxsLHBvc2l0aW9uOm51bGwscHJvZ3Jlc3M6MX0pfX19KSgpOwo=",fr=typeof window<"u"&&window.Blob&&new Blob([atob(Pc)],{type:"text/javascript;charset=utf-8"});function Oh(){let s;try{if(s=fr&&(window.URL||window.webkitURL).createObjectURL(fr),!s)throw"";return new Worker(s)}catch{return new Worker("data:application/javascript;base64,"+Pc)}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}exports.$70d766613f57b014$export$2e2bcd8739ae039=uc;exports.BatchedParticleRenderer=ed;exports.Builder=to;exports.ByteBuffer=gi;exports.ConstantColor=ke;exports.ConstantValue=J;exports.Matrix4=Jt;exports.MeshBVH=be;exports.MotionController=Oc;exports.ParticleSystem=_s;exports.SIZE_PREFIX_LENGTH=Rr;exports.TrailParticle=Os;exports.Vector4=Lt;exports.WorkerBase=jh;exports.WorkerWrapper=Oh;exports.bundler=zl;exports.createNoise4D=sd;exports.fetchProfile=Qc;exports.index=hd;exports.index$1=Eh;exports.md5=El;exports.v5=Pl;
|
|
1602
|
+
`,Lh=Object.freeze(Object.defineProperty({__proto__:null,bvh_distance_functions:Ua,bvh_ray_functions:Da,bvh_struct_definitions:Fa,common_functions:Na},Symbol.toStringTag,{value:"Module"})),Vh=Fa,Jh=Ua,Gh=`
|
|
1603
|
+
${Na}
|
|
1604
|
+
${Da}
|
|
1605
|
+
`,jh=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Ma,BVHShaderGLSL:Lh,CENTER:ls,CONTAINED:Gn,ExtendedTriangle:kt,FloatVertexAttributeTexture:Oa,INTERSECTED:hu,IntVertexAttributeTexture:Rh,MeshBVH:me,MeshBVHHelper:ds,MeshBVHUniformStruct:kh,NOT_INTERSECTED:uu,OrientedBox:gt,SAH:Ca,StaticGeometryGenerator:Fh,UIntVertexAttributeTexture:za,VertexAttributeTexture:sn,acceleratedRaycast:bh,computeBatchedBoundsTree:wh,computeBoundsTree:Mh,disposeBatchedBoundsTree:Ph,disposeBoundsTree:Ch,estimateMemoryInBytes:mh,getBVHExtremes:ph,getJSONStructure:gh,getTriangleHitPointInfo:Nu,shaderDistanceFunction:Jh,shaderIntersectFunction:Gh,shaderStructs:Vh,validateBounds:yh},Symbol.toStringTag,{value:"Module"}));class $h{constructor(t){this.name="WorkerBase",this.running=!1,this.worker=t,this.worker.onerror=e=>{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...t){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 e=this.runTask(this.worker,...t);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}exports.$70d766613f57b014$export$2e2bcd8739ae039=ha;exports.BatchedParticleRenderer=Kl;exports.Builder=ts;exports.ByteBuffer=Pi;exports.ConstantColor=Ie;exports.ConstantValue=F;exports.Matrix4=Ft;exports.MeshBVH=me;exports.MotionController=Ha;exports.ParticleSystem=Yr;exports.SIZE_PREFIX_LENGTH=bo;exports.TrailParticle=Xr;exports.Vector4=Mt;exports.WorkerBase=$h;exports.bundler=Pc;exports.createNoise4D=eu;exports.fetchProfile=Va;exports.index=lu;exports.index$1=jh;exports.md5=jc;exports.v5=Fc;
|