diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..6af40e84f038ab753468208c97c8ff986b4441e5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,55 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/5w_speaker.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/antenna.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/antenna_body_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/antenna_holder_l_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/antenna_holder_r_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/antenna_interface_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/arducam.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/bearing_85x110x13.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/big_lens_d40.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/body_down_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/body_foot_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/body_top_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/body_turning_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/bts2_m2_6x8.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/dc15_a01_case_b_dummy.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/dc15_a01_case_f_dummy.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/dc15_a01_case_m_dummy.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/dc15_a01_horn_dummy.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/glasses_dolder_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/head_back_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/head_front_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/head_mic_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/m12_fisheye_lens_1_8mm.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/mp01062_stewart_arm_3.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/neck_reference_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_1.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_2.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_3.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/pp01102_arducam_carter.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/small_lens_d30.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/stewart_link_ball.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/stewart_link_ball__2.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/stewart_link_rod.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/stewart_main_plate_3dprint.stl filter=lfs diff=lfs merge=lfs -text +frontend/dist/robot-3d/meshes/stewart_tricap_3dprint.stl filter=lfs diff=lfs merge=lfs -text +samples/ada-1.wav filter=lfs diff=lfs merge=lfs -text +samples/ada-2.wav filter=lfs diff=lfs merge=lfs -text +samples/ada-3.wav filter=lfs diff=lfs merge=lfs -text +samples/batman-1.wav filter=lfs diff=lfs merge=lfs -text +samples/batman-2.wav filter=lfs diff=lfs merge=lfs -text +samples/bode-1.wav filter=lfs diff=lfs merge=lfs -text +samples/bode-2.wav filter=lfs diff=lfs merge=lfs -text +samples/bode-3.wav filter=lfs diff=lfs merge=lfs -text +samples/jack-1.wav filter=lfs diff=lfs merge=lfs -text +samples/jack-2.wav filter=lfs diff=lfs merge=lfs -text +samples/jarvis-1.wav filter=lfs diff=lfs merge=lfs -text +samples/jarvis-2.wav filter=lfs diff=lfs merge=lfs -text +samples/surfer-1.wav filter=lfs diff=lfs merge=lfs -text +samples/surfer-2.wav filter=lfs diff=lfs merge=lfs -text +samples/yoda-1.wav filter=lfs diff=lfs merge=lfs -text +samples/yoda-2.wav filter=lfs diff=lfs merge=lfs -text diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..fd5cd67e61268ed6b3ebdf3d6e1f8e60dffb56c3 --- /dev/null +++ b/app.py @@ -0,0 +1,50 @@ +"""Small Talk — Hugging Face Space entrypoint. + +A Gradio app that wears no Gradio: we use `gradio.Server` (a FastAPI server with +Gradio's backend) purely as the host, then serve our own three.js meeting UI and +the /api control plane on it. Custom routes take priority over Gradio's, so the +visitor only ever sees the custom frontend — which also earns the hackathon's +"Off-Brand" badge. + +LiveKit (the WebRTC SFU) is LiveKit Cloud; credentials come from Space secrets +(LIVEKIT_URL / LIVEKIT_API_KEY / LIVEKIT_API_SECRET). The browser connects to +LiveKit Cloud directly; this app just mints tokens and runs the Reachy +publishers that stream the pre-rendered voice clips into the room. +""" +import os +import pathlib + +import gradio as gr +from fastapi.responses import FileResponse + +from backend.server import attach + +DIST = pathlib.Path(__file__).parent / "frontend" / "dist" + +app = gr.Server() +attach(app) # /api/* routes — registered before the static mounts below + +# Serve the built single-page app. These subdirs don't collide with /api or +# Gradio's own routes, so a simple per-folder static mount is enough. +from fastapi.staticfiles import StaticFiles # noqa: E402 + +for sub in ("assets", "robot-3d", "moves"): + d = DIST / sub + if d.is_dir(): + app.mount(f"/{sub}", StaticFiles(directory=str(d)), name=sub) + + +@app.get("/") +async def index(): + return FileResponse(DIST / "index.html") + + +@app.get("/favicon.ico") +async def favicon(): + return FileResponse(DIST / "index.html") # SPA injects an emoji favicon + + +if __name__ == "__main__": + # HF Spaces (sdk: gradio) runs this file; bind to the port it provides. + port = int(os.environ.get("GRADIO_SERVER_PORT", os.environ.get("PORT", 7860))) + app.launch(server_name="0.0.0.0", server_port=port) diff --git a/backend/__init__.py b/backend/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..7dbf3526ad63d5a7dbc316531859903e5006acc6 --- /dev/null +++ b/backend/__init__.py @@ -0,0 +1 @@ +"""Reachy Podcast backend — LiveKit room + audio publishing for Reachy Minis.""" diff --git a/backend/__pycache__/__init__.cpython-313.pyc b/backend/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fa5bdb37856d21ffa60a1c819a860893e663a6ce Binary files /dev/null and b/backend/__pycache__/__init__.cpython-313.pyc differ diff --git a/backend/__pycache__/audio.cpython-313.pyc b/backend/__pycache__/audio.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8f432a9fb569ac1b2a09420ffa199cc22b165011 Binary files /dev/null and b/backend/__pycache__/audio.cpython-313.pyc differ diff --git a/backend/__pycache__/config.cpython-313.pyc b/backend/__pycache__/config.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..949dd02a2c4cc90be841819fc5d47015323a0ce5 Binary files /dev/null and b/backend/__pycache__/config.cpython-313.pyc differ diff --git a/backend/__pycache__/publisher.cpython-313.pyc b/backend/__pycache__/publisher.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..77b26480f6974e2a275c80cf9017dadb664f764e Binary files /dev/null and b/backend/__pycache__/publisher.cpython-313.pyc differ diff --git a/backend/__pycache__/server.cpython-313.pyc b/backend/__pycache__/server.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b4967c8d3f75e6de7711f095ca941e971c50dd54 Binary files /dev/null and b/backend/__pycache__/server.cpython-313.pyc differ diff --git a/backend/__pycache__/tokens.cpython-313.pyc b/backend/__pycache__/tokens.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..32a9bd429f55cb23b2f61019c3fcb77cdd6b1e7f Binary files /dev/null and b/backend/__pycache__/tokens.cpython-313.pyc differ diff --git a/backend/audio.py b/backend/audio.py new file mode 100644 index 0000000000000000000000000000000000000000..042aa7d8a78c907f565e23b8488e25063875f51e --- /dev/null +++ b/backend/audio.py @@ -0,0 +1,32 @@ +"""Audio decoding helpers. + +We shell out to ffmpeg so we can ingest *anything* (wav, mp3, flac, ogg, m4a) +and always get back mono 16-bit PCM at LiveKit's preferred 48 kHz — no +per-format branching, no resampling surprises. +""" +import asyncio + +import numpy as np + +SAMPLE_RATE = 48000 +NUM_CHANNELS = 1 + + +async def decode_to_pcm(path: str, sample_rate: int = SAMPLE_RATE) -> np.ndarray: + """Decode `path` to a 1-D int16 numpy array (mono, `sample_rate` Hz).""" + proc = await asyncio.create_subprocess_exec( + "ffmpeg", + "-v", "error", + "-i", str(path), + "-f", "s16le", + "-acodec", "pcm_s16le", + "-ac", str(NUM_CHANNELS), + "-ar", str(sample_rate), + "-", + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + ) + out, err = await proc.communicate() + if proc.returncode != 0: + raise RuntimeError(f"ffmpeg failed decoding {path}: {err.decode(errors='ignore')}") + return np.frombuffer(out, dtype=np.int16).copy() diff --git a/backend/config.py b/backend/config.py new file mode 100644 index 0000000000000000000000000000000000000000..20885c14315817f1a020645a71ddd3128dd2aba3 --- /dev/null +++ b/backend/config.py @@ -0,0 +1,21 @@ +"""Runtime configuration, sourced from the environment (.env supported).""" +import os + +from dotenv import load_dotenv + +load_dotenv() + +# LiveKit dev server defaults (livekit-server --dev): key=devkey secret=secret. +LIVEKIT_URL = os.environ.get("LIVEKIT_URL", "ws://localhost:7880") +LIVEKIT_API_KEY = os.environ.get("LIVEKIT_API_KEY", "devkey") +LIVEKIT_API_SECRET = os.environ.get("LIVEKIT_API_SECRET", "secret") + +# The single room the podcast happens in (one per session is plenty for now). +ROOM_NAME = os.environ.get("REACHY_ROOM", "reachy-podcast") + +# Where pre-rendered / sample audio clips live (the TTS stage will drop files here). +import pathlib + +SAMPLES_DIR = pathlib.Path( + os.environ.get("REACHY_SAMPLES_DIR", pathlib.Path(__file__).parent.parent / "samples") +).resolve() diff --git a/backend/publisher.py b/backend/publisher.py new file mode 100644 index 0000000000000000000000000000000000000000..2fc218ee8e344d634d98c68d6fcbee1e7bd1f2a0 --- /dev/null +++ b/backend/publisher.py @@ -0,0 +1,139 @@ +"""ReachyPublisher — connects one Reachy Mini into the LiveKit room as a +participant and streams pre-rendered audio clips into the call as a live +audio track. + +Design notes +------------ +* One `rtc.Room` connection per Reachy (each has its own identity/token/track). +* Audio is pushed as 10 ms int16 frames at 48 kHz. `AudioSource.capture_frame` + applies backpressure (its internal queue drains at real-time playback speed), + so simply awaiting it frame-by-frame paces the stream to wall-clock — no + manual sleeps needed. +* `say_file()` enqueues a clip; an async worker plays the queue in order. This + is the seam the LLM+TTS cascade plugs into later: generate a line -> drop the + wav -> `say_file()`, while the next line is already being generated. +""" +import argparse +import asyncio + +import numpy as np +from livekit import rtc + +from . import config, tokens +from .audio import NUM_CHANNELS, SAMPLE_RATE, decode_to_pcm + +SAMPLES_PER_FRAME = SAMPLE_RATE // 100 # 10 ms + + +class ReachyPublisher: + def __init__( + self, + identity: str, + name: str | None = None, + room: str | None = None, + *, + color: str = "#c98a3c", + persona: str | None = None, + ): + self.identity = identity + self.name = name or identity + self.room_name = room or config.ROOM_NAME + self.metadata = {"role": "reachy", "color": color, "persona": persona} + + self.room = rtc.Room() + self.source = rtc.AudioSource(SAMPLE_RATE, NUM_CHANNELS) + self.track = rtc.LocalAudioTrack.create_audio_track( + f"{self.identity}-voice", self.source + ) + self._queue: asyncio.Queue = asyncio.Queue() + self._worker: asyncio.Task | None = None + + async def connect(self) -> "ReachyPublisher": + token = tokens.make_token( + self.identity, + self.name, + self.room_name, + can_publish=True, + can_subscribe=True, + metadata=self.metadata, + ) + await self.room.connect( + config.LIVEKIT_URL, token, options=rtc.RoomOptions(auto_subscribe=True) + ) + opts = rtc.TrackPublishOptions(source=rtc.TrackSource.SOURCE_MICROPHONE) + await self.room.local_participant.publish_track(self.track, opts) + self._worker = asyncio.create_task(self._run()) + print(f"[{self.identity}] connected to '{self.room_name}' and publishing") + return self + + async def say_file(self, path: str) -> None: + """Queue an audio clip to be spoken. Returns immediately.""" + await self._queue.put(str(path)) + + async def wait_until_idle(self) -> None: + """Block until every queued clip has finished playing.""" + await self._queue.join() + + async def _run(self) -> None: + while True: + path = await self._queue.get() + try: + pcm = await decode_to_pcm(path, SAMPLE_RATE) + await self._stream_pcm(pcm) + except Exception as e: # keep the worker alive across bad clips + print(f"[{self.identity}] failed to play {path}: {e}") + finally: + self._queue.task_done() + + async def _stream_pcm(self, pcm: np.ndarray) -> None: + frame = rtc.AudioFrame.create(SAMPLE_RATE, NUM_CHANNELS, SAMPLES_PER_FRAME) + buf = np.frombuffer(frame.data, dtype=np.int16) + for start in range(0, len(pcm), SAMPLES_PER_FRAME): + chunk = pcm[start : start + SAMPLES_PER_FRAME] + if len(chunk) < SAMPLES_PER_FRAME: # zero-pad the final frame + padded = np.zeros(SAMPLES_PER_FRAME, dtype=np.int16) + padded[: len(chunk)] = chunk + chunk = padded + np.copyto(buf, chunk) + await self.source.capture_frame(frame) # backpressure paces playback + await self.source.wait_for_playout() # don't clip the tail + + async def aclose(self) -> None: + if self._worker: + self._worker.cancel() + await self.room.disconnect() + print(f"[{self.identity}] disconnected") + + +# --------------------------------------------------------------------------- CLI + + +async def _cli_main(args: argparse.Namespace) -> None: + pub = ReachyPublisher( + args.identity, args.name, args.room, color=args.color, persona=args.persona + ) + await pub.connect() + try: + while True: + await pub.say_file(args.file) + await pub.wait_until_idle() + if not args.loop: + break + finally: + await pub.aclose() + + +def cli() -> None: + p = argparse.ArgumentParser(description="Publish an audio file into the Reachy podcast room") + p.add_argument("--identity", required=True, help="unique participant id, e.g. reachy-1") + p.add_argument("--name", help="display name, e.g. Ada") + p.add_argument("--room", help=f"room name (default: {config.ROOM_NAME})") + p.add_argument("--file", required=True, help="path to wav/mp3/etc to play") + p.add_argument("--color", default="#c98a3c", help="card accent colour (hex)") + p.add_argument("--persona", help="short persona blurb") + p.add_argument("--loop", action="store_true", help="replay the file on a loop") + asyncio.run(_cli_main(p.parse_args())) + + +if __name__ == "__main__": + cli() diff --git a/backend/server.py b/backend/server.py new file mode 100644 index 0000000000000000000000000000000000000000..4e0324f9c9122a1b1f0448b5e23511d442cdcdc9 --- /dev/null +++ b/backend/server.py @@ -0,0 +1,209 @@ +"""FastAPI control plane for the Reachy podcast. + +Responsibilities (Task 1 scope): +* Hand browser viewers a LiveKit token so they can join and watch/listen. +* Spawn / stop Reachy publishers on demand. +* Trigger a Reachy to "say" an audio clip (the seam the TTS stage plugs into). +* A /demo route that stands up two Reachies trading sample lines, so the whole + pipe (audio file -> LiveKit -> browser grid) can be verified end-to-end. +""" +import asyncio +import pathlib +import uuid + +from fastapi import FastAPI, HTTPException +from fastapi.middleware.cors import CORSMiddleware +from pydantic import BaseModel + +from . import config, tokens +from .publisher import ReachyPublisher + +# identity -> live publisher +PUBLISHERS: dict[str, ReachyPublisher] = {} +# background task driving the looping demo conversation +DEMO_TASK: asyncio.Task | None = None + + +def _resolve_clip(name_or_path: str) -> pathlib.Path: + """Resolve a clip reference to a real file, sandboxed to SAMPLES_DIR unless + an absolute path is given.""" + p = pathlib.Path(name_or_path) + if not p.is_absolute(): + p = (config.SAMPLES_DIR / name_or_path).resolve() + if config.SAMPLES_DIR not in p.parents and p != config.SAMPLES_DIR: + raise HTTPException(400, "clip path escapes samples dir") + if not p.exists(): + raise HTTPException(404, f"clip not found: {p}") + return p + + +# --------------------------------------------------------------------------- models + + +class TokenRequest(BaseModel): + identity: str | None = None + name: str | None = None + + +class JoinRequest(BaseModel): + identity: str + name: str | None = None + color: str = "#c98a3c" + persona: str | None = None + + +class SayRequest(BaseModel): + identity: str + clip: str # filename under samples/ or an absolute path + + +# --------------------------------------------------------------------------- routes + + +async def get_config(): + return {"livekitUrl": config.LIVEKIT_URL, "room": config.ROOM_NAME} + + +async def post_token(req: TokenRequest): + identity = req.identity or f"viewer-{uuid.uuid4().hex[:8]}" + token = tokens.make_token(identity, req.name, can_publish=False, can_subscribe=True) + return {"token": token, "url": config.LIVEKIT_URL, "room": config.ROOM_NAME, "identity": identity} + + +async def reachy_join(req: JoinRequest): + if req.identity in PUBLISHERS: + return {"ok": True, "already": True} + pub = ReachyPublisher(req.identity, req.name, color=req.color, persona=req.persona) + await pub.connect() + PUBLISHERS[req.identity] = pub + return {"ok": True} + + +async def reachy_say(req: SayRequest): + pub = PUBLISHERS.get(req.identity) + if not pub: + raise HTTPException(404, f"no such reachy: {req.identity}") + clip = _resolve_clip(req.clip) + await pub.say_file(str(clip)) + return {"ok": True} + + +async def reachy_leave(req: TokenRequest): + pub = PUBLISHERS.pop(req.identity or "", None) + if pub: + await pub.aclose() + return {"ok": True} + + +# A character: (identity, display name, card colour, persona blurb, clip prefix). +CASTS: dict[str, list[tuple[str, str, str, str, str]]] = { + "duo": [ + ("reachy-ada", "Ada", "#c98a3c", "curious, warm, asks big questions", "ada"), + ("reachy-bode", "Bode", "#5a6b3a", "dry wit, contrarian, loves a tangent", "bode"), + ], + "groupchat": [ + ("reachy-batman", "Batman", "#5b6b8c", "broods, works alone, encased-meat justice", "batman"), + ("reachy-jarvis", "JARVIS", "#37b3c9", "polite British AI butler, cites the data", "jarvis"), + ("reachy-jack", "Jack Sparrow", "#3fae9a", "rum-soaked pirate, picks whichever side has the rum", "jack"), + ("reachy-yoda", "Yoda", "#7bbf6a", "speaks in riddles, perpetually hungry", "yoda"), + ("reachy-surfer", "Surfer", "#ff8c42", "chill, everything is just vibes, brah", "surfer"), + ], +} + + +async def _start_conversation(cast: list[tuple[str, str, str, str, str]]) -> dict: + """Switch the room to `cast`: stop any running loop, drop publishers not in + the cast, connect the ones that are, and start a looping group conversation + where each character speaks its own clips (prefix-*.wav) in turn.""" + global DEMO_TASK + + if not any(config.SAMPLES_DIR.glob("*.wav")): + raise HTTPException( + 400, + f"no .wav files in {config.SAMPLES_DIR} " + "(run scripts/make-qwen-samples.py or scripts/make-samples.sh)", + ) + + # Stop the current loop before reshaping the cast. + if DEMO_TASK and not DEMO_TASK.done(): + DEMO_TASK.cancel() + DEMO_TASK = None + + wanted = {c[0] for c in cast} + for identity in list(PUBLISHERS): + if identity not in wanted: + await PUBLISHERS.pop(identity).aclose() + for identity, name, color, persona, _prefix in cast: + if identity not in PUBLISHERS: + pub = ReachyPublisher(identity, name, color=color, persona=persona) + await pub.connect() + PUBLISHERS[identity] = pub + + # Round-robin the cast, each character cycling through its own clips, so it + # reads like everyone taking turns in a group chat. + clips = {c[0]: sorted(config.SAMPLES_DIR.glob(f"{c[4]}*.wav")) for c in cast} + speakers = [c[0] for c in cast if clips[c[0]]] + sequence: list[tuple[str, str]] = [] + rounds = max((len(clips[s]) for s in speakers), default=0) + for k in range(rounds): + for s in speakers: + if k < len(clips[s]): + sequence.append((s, str(clips[s][k]))) + + if not sequence: + raise HTTPException(400, "no clips found for this cast") + + async def run_loop(): + i = 0 + while True: # loop forever so there's always something live + identity, clip = sequence[i % len(sequence)] + pub = PUBLISHERS.get(identity) + if not pub: + break + await pub.say_file(clip) + await pub.wait_until_idle() + await asyncio.sleep(0.35) + i += 1 + + DEMO_TASK = asyncio.create_task(run_loop()) + return {"ok": True, "cast": [c[0] for c in cast]} + + +async def demo(): + """Two Reachies (Ada & Bode) trading a podcast, looping forever.""" + return await _start_conversation(CASTS["duo"]) + + +async def groupchat(): + """Five chaotic personalities arguing about lunch, looping forever.""" + return await _start_conversation(CASTS["groupchat"]) + + +def attach(app) -> None: + """Register CORS + the /api routes onto `app` (works for a plain FastAPI in + local dev or a gradio.Server on the Space).""" + app.add_middleware( + CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"] + ) + app.add_api_route("/api/config", get_config, methods=["GET"]) + app.add_api_route("/api/token", post_token, methods=["POST"]) + app.add_api_route("/api/reachy/join", reachy_join, methods=["POST"]) + app.add_api_route("/api/reachy/say", reachy_say, methods=["POST"]) + app.add_api_route("/api/reachy/leave", reachy_leave, methods=["POST"]) + app.add_api_route("/api/demo", demo, methods=["POST"]) + app.add_api_route("/api/groupchat", groupchat, methods=["POST"]) + + +# Local dev app (the Space uses app.py / gradio.Server instead). +app = FastAPI(title="Reachy Podcast") +attach(app) + + +def run() -> None: + import uvicorn + + uvicorn.run("backend.server:app", host="0.0.0.0", port=8000, reload=False) + + +if __name__ == "__main__": + run() diff --git a/backend/tokens.py b/backend/tokens.py new file mode 100644 index 0000000000000000000000000000000000000000..e9d45cff9d577a197e8fbdff2e103497660b95d7 --- /dev/null +++ b/backend/tokens.py @@ -0,0 +1,40 @@ +"""LiveKit access-token minting (server-side).""" +import json + +from livekit import api + +from . import config + + +def make_token( + identity: str, + name: str | None = None, + room: str | None = None, + *, + can_publish: bool = False, + can_subscribe: bool = True, + metadata: dict | None = None, +) -> str: + """Mint a JWT for `identity` to join `room`. + + Viewers (browsers) get can_publish=False; Reachy publishers get True. + `metadata` is attached to the participant and is readable by all clients — + we use it to carry the Reachy's display colour / persona. + """ + room = room or config.ROOM_NAME + grants = api.VideoGrants( + room_join=True, + room=room, + can_publish=can_publish, + can_subscribe=can_subscribe, + can_publish_data=True, + ) + token = ( + api.AccessToken(config.LIVEKIT_API_KEY, config.LIVEKIT_API_SECRET) + .with_identity(identity) + .with_name(name or identity) + .with_grants(grants) + ) + if metadata: + token = token.with_metadata(json.dumps(metadata)) + return token.to_jwt() diff --git a/frontend/dist/assets/index-CMwLu78T.css b/frontend/dist/assets/index-CMwLu78T.css new file mode 100644 index 0000000000000000000000000000000000000000..513b8e78c38c378ce38ba85591350ec48c528e96 --- /dev/null +++ b/frontend/dist/assets/index-CMwLu78T.css @@ -0,0 +1 @@ +:root{--bg:#16130f;--panel:#211c16;--cream:#f6efe1;--muted:#b9ad97;--accent:#c98a3c;--rust:#8a4a2b}*{box-sizing:border-box}html,body{background:radial-gradient(ellipse at 20% 0%, #2a2218, var(--bg));height:100%;color:var(--cream);margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif}.hidden{display:none!important}.hidden-audio{opacity:0;width:0;height:0;position:absolute}#lobby{background:radial-gradient(at 75% 80%,#49e6c829,#0000 55%),radial-gradient(at 15% 15%,#6c7bff24,#0000 55%),#05070d;min-height:100%;position:relative;overflow:hidden}#hero3d{z-index:0;position:absolute;inset:0}.scanlines{z-index:1;pointer-events:none;opacity:.6;background:repeating-linear-gradient(0deg,#49e6c80a 0 1px,#0000 1px 4px);animation:8s linear infinite scan;position:absolute;inset:0;-webkit-mask-image:linear-gradient(#0000,#000 30% 70%,#0000);mask-image:linear-gradient(#0000,#000 30% 70%,#0000)}@keyframes scan{0%{background-position:0 0}to{background-position:0 -400px}}.lobby-inner{z-index:2;pointer-events:none;flex-direction:column;justify-content:center;max-width:620px;min-height:100%;padding:clamp(28px,7vw,90px);display:flex;position:relative}.lobby-inner>*{pointer-events:auto}.eyebrow{text-transform:uppercase;letter-spacing:.34em;width:fit-content;color:var(--cream);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);background:#49e6c80f;border:1px solid #49e6c866;border-radius:999px;align-items:center;gap:9px;padding:7px 14px;font-size:12px;font-weight:700;display:inline-flex}.eyebrow .pulse{background:#49e6c8;border-radius:50%;width:8px;height:8px;animation:1.5s infinite pulse;box-shadow:0 0 10px 2px #49e6c8}#lobby h1{letter-spacing:-.02em;color:#f4f8ff;text-shadow:0 2px 40px #49e6c840;margin:20px 0 14px;font-size:clamp(40px,7vw,76px);font-weight:800;line-height:.98}#lobby h1 em{background:linear-gradient(100deg,#49e6c8,#6c7bff 70%);color:#0000;-webkit-background-clip:text;background-clip:text;font-style:normal}#lobby p{color:#aeb8c8;max-width:30em;font-size:clamp(15px,1.6vw,18px);line-height:1.6}.lobby-actions{flex-wrap:wrap;gap:14px;margin-top:30px;display:flex}.btn{cursor:pointer;border:1px solid #0000;border-radius:12px;padding:14px 22px;font-size:15px;font-weight:700;transition:transform .18s,box-shadow .18s,background .18s,border-color .18s}.btn:disabled{opacity:.55;cursor:default}.btn-primary{color:#051018;background:linear-gradient(100deg,#49e6c8,#6c7bff);box-shadow:0 8px 30px -8px #49e6c8b3}.btn-primary:not(:disabled):hover{transform:translateY(-2px);box-shadow:0 12px 36px -8px #49e6c8e6}.btn-ghost{color:#eaf1f8;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#ffffff0a;border-color:#ffffff29}.btn-ghost:not(:disabled):hover{border-color:#49e6c8cc;box-shadow:0 0 0 1px #49e6c866,0 8px 24px -10px #49e6c880}.status{color:#7f8aa0;letter-spacing:.02em;min-height:18px;margin-top:18px;font-family:ui-monospace,monospace;font-size:13px}#stage{flex-direction:column;min-height:100%;display:flex}.topbar{border-bottom:1px solid #33291d;align-items:center;gap:14px;padding:14px 22px;display:flex}.brand{font-weight:700}.live-pill{letter-spacing:.1em;color:#ff6b5e;align-items:center;gap:7px;font-size:12px;font-weight:700;display:inline-flex}.live-pill .dot{background:#ff6b5e;border-radius:50%;width:8px;height:8px;animation:1.4s infinite pulse}@keyframes pulse{0%,to{opacity:1}50%{opacity:.3}}.grid{flex:1;align-content:center;gap:16px;padding:20px;display:grid}.spotlight{flex:1;gap:16px;min-height:0;padding:20px;display:flex}.spot-main{flex:1;min-width:0;display:flex}.spot-main .card{aspect-ratio:auto;width:100%;height:100%}.spot-strip{flex-direction:column;flex-shrink:0;gap:12px;width:clamp(150px,17vw,240px);display:flex;overflow-y:auto}.spot-strip .card{aspect-ratio:4/3;flex:none;width:100%}.card{aspect-ratio:4/3;background:linear-gradient(160deg,#241e17,#19150f);border:1px solid #382c1f;border-radius:16px;transition:border-color .2s,box-shadow .2s;position:relative;overflow:hidden}.card.talking{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent), 0 0 32px -8px var(--accent)}.card .twin{position:absolute;inset:0}.speaking-ring{pointer-events:none;box-shadow:inset 0 0 60px -30px var(--accent);opacity:0;border-radius:16px;transition:opacity .2s;position:absolute;inset:0}.card.talking .speaking-ring{opacity:1}.nameplate{-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);background:#0a080699;border-radius:999px;align-items:center;gap:8px;padding:6px 12px;font-size:13px;display:flex;position:absolute;bottom:12px;left:12px}.nameplate .dot{background:#5a4a35;border-radius:50%;width:8px;height:8px;transition:background .15s}.card.talking .nameplate .dot{background:var(--accent)}.nameplate .name{font-weight:700}.nameplate .persona{color:var(--muted);font-size:12px} diff --git a/frontend/dist/assets/index-DxhkjW4l.js b/frontend/dist/assets/index-DxhkjW4l.js new file mode 100644 index 0000000000000000000000000000000000000000..febb831967237eb0b60216992ad3a8bec4c777b1 --- /dev/null +++ b/frontend/dist/assets/index-DxhkjW4l.js @@ -0,0 +1,4287 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e,t){return t.forEach(function(t){t&&typeof t!=`string`&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var t=Object.defineProperty,n=(e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,r=(e,t,r)=>n(e,typeof t==`symbol`?t:t+``,r),i=class{constructor(){r(this,`_locking`),r(this,`_locks`),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e,t=new Promise(t=>e=()=>{--this._locks,t()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}};function a(e,t){if(!e)throw Error(t)}var o=34028234663852886e22,s=-34028234663852886e22,c=4294967295,l=2147483647,u=-2147483648;function d(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>l||ec||e<0)throw Error(`invalid uint 32: `+e)}function p(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>o||e({no:t.no,name:t.name,localName:e[t.no]})))}function _(e,t,n){let r=Object.create(null),i=Object.create(null),a=[];for(let e of t){let t=y(e);a.push(t),r[e.name]=t,i[e.no]=t}return{typeName:e,values:a,findName(e){return r[e]},findNumber(e){return i[e]}}}function v(e,t,n){let r={};for(let e of t){let t=y(e);r[t.localName]=t.no,r[t.no]=t.localName}return g(r,e,t),r}function y(e){return`localName`in e?e:Object.assign(Object.assign({},e),{localName:e.name})}var b=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){let n=this.getType().runtime.bin,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){let n=this.getType(),r=n.runtime.json,i=r.makeReadOptions(t);return r.readMessage(n,e,i,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`cannot decode ${this.getType().typeName} from JSON: ${e instanceof Error?e.message:String(e)}`)}return this.fromJson(n,t)}toBinary(e){let t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.finish()}toJson(e){let t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){let t=this.toJson(e);return JSON.stringify(t,null,e?.prettySpaces??0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function x(e,t,n,r){let i=r?.localName??t.substring(t.lastIndexOf(`.`)+1),a={[i]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[i];return Object.setPrototypeOf(a.prototype,new b),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary(e,t){return new a().fromBinary(e,t)},fromJson(e,t){return new a().fromJson(e,t)},fromJsonString(e,t){return new a().fromJsonString(e,t)},equals(t,n){return e.util.equals(a,t,n)}}),a}function S(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var w=4294967296;function T(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=w&&(i+=r/w|0,r%=w)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?k(r,i):ee(r,i)}function E(e,t){let n=ee(e,t),r=n.hi&2147483648;r&&(n=k(n.lo,n.hi));let i=D(n.lo,n.hi);return r?`-`+i:i}function D(e,t){if({lo:e,hi:t}=O(e,t),t<=2097151)return String(w*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+te(o)+te(a)}function O(e,t){return{lo:e>>>0,hi:t>>>0}}function ee(e,t){return{lo:e|0,hi:t|0}}function k(e,t){return t=~t,e?e=~e+1:t+=1,ee(e,t)}var te=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function ne(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function re(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function ie(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||{}.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||ri||ta(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>a(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),T(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),T(e)},dec(e,t){return E(e,t)},uDec(e,t){return D(e,t)}}}var A=ie(),j;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(j||={});var ae;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})(ae||={});function oe(e,t,n){if(t===n)return!0;if(e==j.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(f(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return d(e),ne(e,this.buf),this}bool(e){return this.buf.push(+!!e),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){p(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){f(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){d(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return d(e),e=(e<<1^e>>31)>>>0,ne(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=A.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=A.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=A.enc(e);return C(t.lo,t.hi,this.buf),this}sint64(e){let t=A.enc(e),n=t.hi>>31;return C(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=A.uEnc(e);return C(t.lo,t.hi,this.buf),this}},de=class{constructor(e,t){this.varint64=S,this.uint32=re,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case le.Varint:for(;this.buf[this.pos++]&128;);break;case le.Bit64:this.pos+=4;case le.Bit32:this.pos+=4;break;case le.LengthDelimited:let n=this.uint32();this.pos+=n;break;case le.StartGroup:for(;;){let[e,n]=this.tag();if(n===le.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(n,e)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return A.dec(...this.varint64())}uint64(){return A.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,A.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return A.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return A.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function fe(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){let n=typeof r==`function`?r():r;n.name=t.split(`.`).pop(),n.jsonName=`[${t}]`,i=e.util.newFieldList([n]).list()[0]}return i},runtime:e}}function pe(e){let t=e.field.localName,n=Object.create(null);return n[t]=me(e),[n,()=>n[t]]}function me(e){let t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case`enum`:return t.T.values[0].no;case`scalar`:return se(t.T,t.L);case`message`:let e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case`map`:throw`map fields are not allowed to be extensions`}}function he(e,t){if(!t.repeated&&(t.kind==`enum`||t.kind==`scalar`)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(e=>e.no===t.no)}var ge=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),_e=[];for(let e=0;e>4,o=a,i=2;break;case 2:n[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:n[r++]=(o&3)<<6|a,i=0;break}}if(i==1)throw Error(`invalid base64 string.`);return n.subarray(0,r)},enc(e){let t=``,n=0,r,i=0;for(let a=0;a>2],i=(r&3)<<4,n=1;break;case 1:t+=ge[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=ge[i|r>>6],t+=ge[r&63],n=0;break}return n&&(t+=ge[i],t+=`=`,n==1&&(t+=`=`)),t}};function ye(e,t,n){Se(t,e);let r=t.runtime.bin.makeReadOptions(n),i=he(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,o]=pe(t);for(let e of i)t.runtime.bin.readField(a,r.readerFactory(e.data),t.field,e.wireType,r);return o()}function be(e,t,n,r){Se(t,e);let i=t.runtime.bin.makeReadOptions(r),a=t.runtime.bin.makeWriteOptions(r);if(xe(e,t)){let n=e.getType().runtime.bin.listUnknownFields(e).filter(e=>e.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(let t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}let o=a.writerFactory(),s=t.field;!s.opt&&!s.repeated&&(s.kind==`enum`||s.kind==`scalar`)&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,o,a);let c=i.readerFactory(o.finish());for(;c.pose.no==t.field.no)}function Se(e,t){a(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function M(e,t){let n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case`enum`:case`scalar`:return e.opt||e.req?t[n]!==void 0:e.kind==`enum`?t[n]!==e.T.values[0].no:!ce(e.T,t[n]);case`message`:return t[n]!==void 0;case`map`:return Object.keys(t[n]).length>0}}function Ce(e,t){let n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case`map`:t[n]={};break;case`enum`:t[n]=r?e.T.values[0].no:void 0;break;case`scalar`:t[n]=r?se(e.T,e.L):void 0;break;case`message`:t[n]=void 0;break}}function we(e,t){if(typeof e!=`object`||!e||!Object.getOwnPropertyNames(b.prototype).every(t=>t in e&&typeof e[t]==`function`))return!1;let n=e.getType();return n===null||typeof n!=`function`||!(`typeName`in n)||typeof n.typeName!=`string`?!1:t===void 0?!0:n.typeName==t.typeName}function Te(e,t){return we(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}j.DOUBLE,j.FLOAT,j.INT64,j.UINT64,j.INT32,j.UINT32,j.BOOL,j.STRING,j.BYTES;var N={ignoreUnknownFields:!1},Ee={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function P(e){return e?Object.assign(Object.assign({},N),e):N}function De(e){return e?Object.assign(Object.assign({},Ee),e):Ee}var Oe=Symbol(),ke=Symbol();function Ae(){return{makeReadOptions:P,makeWriteOptions:De,readMessage(e,t,n,r){if(t==null||Array.isArray(t)||typeof t!=`object`)throw Error(`cannot decode message ${e.typeName} from JSON: ${je(t)}`);r??=new e;let i=new Map,a=n.typeRegistry;for(let[o,s]of Object.entries(t)){let t=e.fields.findJsonName(o);if(t){if(t.oneof){if(s===null&&t.kind==`scalar`)continue;let n=i.get(t.oneof);if(n!==void 0)throw Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${o}"`);i.set(t.oneof,o)}Me(r,s,t,n,e)}else{let t=!1;if(a?.findExtension&&o.startsWith(`[`)&&o.endsWith(`]`)){let i=a.findExtension(o.substring(1,o.length-1));if(i&&i.extendee.typeName==e.typeName){t=!0;let[e,a]=pe(i);Me(e,s,i.field,n,i),be(r,i,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw Error(`cannot decode message ${e.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(e,t){let n=e.getType(),r={},i;try{for(i of n.fields.byNumber()){if(!M(i,e)){if(i.req)throw`required field not set`;if(!t.emitDefaultValues||!Ie(i))continue}let n=i.oneof?e[i.oneof.localName].value:e[i.localName],a=Le(i,n,t);a!==void 0&&(r[t.useProtoFieldName?i.name:i.jsonName]=a)}let a=t.typeRegistry;if(a?.findExtensionFor)for(let i of n.runtime.bin.listUnknownFields(e)){let o=a.findExtensionFor(n.typeName,i.no);if(o&&xe(e,o)){let n=ye(e,o,t),i=Le(o.field,n,t);i!==void 0&&(r[o.field.jsonName]=i)}}}catch(e){let t=i?`cannot encode field ${n.typeName}.${i.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,r=e instanceof Error?e.message:String(e);throw Error(t+(r.length>0?`: ${r}`:``))}return r},readScalar(e,t,n){return Pe(e,t,n??ae.BIGINT,!0)},writeScalar(e,t,n){if(t!==void 0&&(n||ce(e,t)))return ze(e,t)},debug:je}}function je(e){if(e===null)return`null`;switch(typeof e){case`object`:return Array.isArray(e)?`array`:`object`;case`string`:return e.length>100?`string`:`"${e.split(`"`).join(`\\"`)}"`;default:return String(e)}}function Me(e,t,n,r,i){let o=n.localName;if(n.repeated){if(a(n.kind!=`map`),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${je(t)}`);let s=e[o];for(let e of t){if(e===null)throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${je(e)}`);switch(n.kind){case`message`:s.push(n.T.fromJson(e,r));break;case`enum`:let t=Fe(n.T,e,r.ignoreUnknownFields,!0);t!==ke&&s.push(t);break;case`scalar`:try{s.push(Pe(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${i.typeName}.${n.name} from JSON: ${je(e)}`;throw t instanceof Error&&t.message.length>0&&(r+=`: ${t.message}`),Error(r)}break}}}else if(n.kind==`map`){if(t===null)return;if(typeof t!=`object`||Array.isArray(t))throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${je(t)}`);let a=e[o];for(let[e,o]of Object.entries(t)){if(o===null)throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: map value null`);let s;try{s=Ne(n.K,e)}catch(e){let r=`cannot decode map key for field ${i.typeName}.${n.name} from JSON: ${je(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}switch(n.V.kind){case`message`:a[s]=n.V.T.fromJson(o,r);break;case`enum`:let e=Fe(n.V.T,o,r.ignoreUnknownFields,!0);e!==ke&&(a[s]=e);break;case`scalar`:try{a[s]=Pe(n.V.T,o,ae.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${i.typeName}.${n.name} from JSON: ${je(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}break}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:o},o=`value`),n.kind){case`message`:let a=n.T;if(t===null&&a.typeName!=`google.protobuf.Value`)return;let s=e[o];we(s)?s.fromJson(t,r):(e[o]=s=a.fromJson(t,r),a.fieldWrapper&&!n.oneof&&(e[o]=a.fieldWrapper.unwrapField(s)));break;case`enum`:let c=Fe(n.T,t,r.ignoreUnknownFields,!1);switch(c){case Oe:Ce(n,e);break;case ke:break;default:e[o]=c;break}break;case`scalar`:try{let r=Pe(n.T,t,n.L,!1);switch(r){case Oe:Ce(n,e);break;default:e[o]=r;break}}catch(e){let r=`cannot decode field ${i.typeName}.${n.name} from JSON: ${je(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}break}}function Ne(e,t){if(e===j.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1;break}return Pe(e,t,ae.BIGINT,!0).toString()}function Pe(e,t,n,r){if(t===null)return r?se(e,n):Oe;switch(e){case j.DOUBLE:case j.FLOAT:if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(t===``||typeof t==`string`&&t.trim().length!==t.length||typeof t!=`string`&&typeof t!=`number`)break;let r=Number(t);if(Number.isNaN(r)||!Number.isFinite(r))break;return e==j.FLOAT&&p(r),r;case j.INT32:case j.FIXED32:case j.SFIXED32:case j.SINT32:case j.UINT32:let i;if(typeof t==`number`?i=t:typeof t==`string`&&t.length>0&&t.trim().length===t.length&&(i=Number(t)),i===void 0)break;return e==j.UINT32||e==j.FIXED32?f(i):d(i),i;case j.INT64:case j.SFIXED64:case j.SINT64:if(typeof t!=`number`&&typeof t!=`string`)break;let a=A.parse(t);return n?a.toString():a;case j.FIXED64:case j.UINT64:if(typeof t!=`number`&&typeof t!=`string`)break;let o=A.uParse(t);return n?o.toString():o;case j.BOOL:if(typeof t!=`boolean`)break;return t;case j.STRING:if(typeof t!=`string`)break;return t;case j.BYTES:if(t===``)return new Uint8Array;if(typeof t!=`string`)break;return ve.dec(t)}throw Error()}function Fe(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:Oe;switch(typeof t){case`number`:if(Number.isInteger(t))return t;break;case`string`:let r=e.findName(t);if(r!==void 0)return r.no;if(n)return ke;break}throw Error(`cannot decode enum ${e.typeName} from JSON: ${je(t)}`)}function Ie(e){return e.repeated||e.kind==`map`?!0:!(e.oneof||e.kind==`message`||e.opt||e.req)}function Le(e,t,n){if(e.kind==`map`){a(typeof t==`object`&&!!t);let r={},i=Object.entries(t);switch(e.V.kind){case`scalar`:for(let[t,n]of i)r[t.toString()]=ze(e.V.T,n);break;case`message`:for(let[e,t]of i)r[e.toString()]=t.toJson(n);break;case`enum`:let t=e.V.T;for(let[e,a]of i)r[e.toString()]=Re(t,a,n.enumAsInteger);break}return n.emitDefaultValues||i.length>0?r:void 0}if(e.repeated){a(Array.isArray(t));let r=[];switch(e.kind){case`scalar`:for(let n=0;n0?r:void 0}switch(e.kind){case`scalar`:return ze(e.T,t);case`enum`:return Re(e.T,t,n.enumAsInteger);case`message`:return Te(e.T,t).toJson(n)}}function Re(e,t,n){return a(typeof t==`number`),e.typeName==`google.protobuf.NullValue`?null:n?t:e.findNumber(t)?.name??t}function ze(e,t){switch(e){case j.INT32:case j.SFIXED32:case j.SINT32:case j.FIXED32:case j.UINT32:return a(typeof t==`number`),t;case j.FLOAT:case j.DOUBLE:return a(typeof t==`number`),Number.isNaN(t)?`NaN`:t===1/0?`Infinity`:t===-1/0?`-Infinity`:t;case j.STRING:return a(typeof t==`string`),t;case j.BOOL:return a(typeof t==`boolean`),t;case j.UINT64:case j.FIXED64:case j.INT64:case j.SFIXED64:case j.SINT64:return a(typeof t==`bigint`||typeof t==`string`||typeof t==`number`),t.toString();case j.BYTES:return a(t instanceof Uint8Array),ve.enc(t)}}var Be=Symbol(`@bufbuild/protobuf/unknown-fields`),Ve={readUnknownFields:!0,readerFactory:e=>new de(e)},He={writeUnknownFields:!0,writerFactory:()=>new ue};function Ue(e){return e?Object.assign(Object.assign({},Ve),e):Ve}function We(e){return e?Object.assign(Object.assign({},He),e):He}function Ge(){return{makeReadOptions:Ue,makeWriteOptions:We,listUnknownFields(e){return e[Be]??[]},discardUnknownFields(e){delete e[Be]},writeUnknownFields(e,t){let n=e[Be];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)},onUnknownField(e,t,n,r){let i=e;Array.isArray(i[Be])||(i[Be]=[]),i[Be].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,i){let a=e.getType(),o=i?t.len:t.pos+n,s,c;for(;t.pos0&&(c=Ye),a){let n=e[o];if(r==le.LengthDelimited&&s!=j.STRING&&s!=j.BYTES){let e=t.uint32()+t.pos;for(;t.poswe(e,c)?e:new c(e));else{let e=a[n];c.fieldWrapper?c.typeName===`google.protobuf.BytesValue`?i[n]=at(e):i[n]=e:i[n]=we(e,c)?e:new c(e)}break}}},equals(e,t,n){return t===n?!0:!t||!n?!1:e.fields.byMember().every(e=>{let r=t[e.localName],i=n[e.localName];if(e.repeated){if(r.length!==i.length)return!1;switch(e.kind){case`message`:return r.every((t,n)=>e.T.equals(t,i[n]));case`scalar`:return r.every((t,n)=>oe(e.T,t,i[n]));case`enum`:return r.every((e,t)=>oe(j.INT32,e,i[t]))}throw Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case`message`:let t=r,n=i;return e.T.fieldWrapper&&(t!==void 0&&!we(t)&&(t=e.T.fieldWrapper.wrapField(t)),n!==void 0&&!we(n)&&(n=e.T.fieldWrapper.wrapField(n))),e.T.equals(t,n);case`enum`:return oe(j.INT32,r,i);case`scalar`:return oe(e.T,r,i);case`oneof`:if(r.case!==i.case)return!1;let a=e.findField(r.case);if(a===void 0)return!0;switch(a.kind){case`message`:return a.T.equals(r.value,i.value);case`enum`:return oe(j.INT32,r.value,i.value);case`scalar`:return oe(a.T,r.value,i.value)}throw Error(`oneof cannot contain ${a.kind}`);case`map`:let o=Object.keys(r).concat(Object.keys(i));switch(e.V.kind){case`message`:let t=e.V.T;return o.every(e=>t.equals(r[e],i[e]));case`enum`:return o.every(e=>oe(j.INT32,r[e],i[e]));case`scalar`:let n=e.V.T;return o.every(e=>oe(n,r[e],i[e]))}break}})},clone(e){let t=e.getType(),n=new t,r=n;for(let n of t.fields.byMember()){let t=e[n.localName],i;if(n.repeated)i=t.map(it);else if(n.kind==`map`){i=r[n.localName];for(let[e,n]of Object.entries(t))i[e]=it(n)}else i=n.kind==`oneof`?n.findField(t.case)?{case:t.case,value:it(t.value)}:{case:void 0}:it(t);r[n.localName]=i}for(let n of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,n.no,n.wireType,n.data);return n}}}function it(e){if(e===void 0)return e;if(we(e))return e.clone();if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function at(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function ot(e,t,n){return{syntax:e,json:Ae(),bin:Ge(),util:Object.assign(Object.assign({},rt()),{newFieldList:t,initFields:n}),makeMessageType(e,t,n){return x(this,e,t,n)},makeEnum:v,makeEnumType:_,getEnumType:h,makeExtension(e,t,n){return fe(this,e,t,n)}}}var st=class{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let e={};for(let t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){let e={};for(let t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||=this._normalizer(this._fields),this.all}byNumber(){return this.numbersAsc||=this.list().concat().sort((e,t)=>e.no-t.no),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}};function ct(e,t){let n=dt(e);return t?n:gt(ht(n))}function lt(e){return ct(e,!1)}var ut=dt;function dt(e){let t=!1,n=[];for(let r=0;r`${e}\$`,ht=e=>pt.has(e)?mt(e):e,gt=e=>ft.has(e)?mt(e):e,_t=class{constructor(e){this.kind=`oneof`,this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=lt(e)}addField(e){a(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;enew st(e,e=>vt(e)),e=>{for(let t of e.getType().fields.byMember()){if(t.opt)continue;let n=t.localName,r=e;if(t.repeated){r[n]=[];continue}switch(t.kind){case`oneof`:r[n]={case:void 0};break;case`enum`:r[n]=0;break;case`map`:r[n]={};break;case`scalar`:r[n]=se(t.T,t.L);break}}}),yt=class e extends b{constructor(e){super(),this.seconds=A.zero,this.nanos=0,F.util.initPartial(e,this)}fromJson(e,t){if(typeof e!=`string`)throw Error(`cannot decode google.protobuf.Timestamp from JSON: ${F.json.debug(e)}`);let n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);let r=Date.parse(n[1]+`-`+n[2]+`-`+n[3]+`T`+n[4]+`:`+n[5]+`:`+n[6]+(n[8]?n[8]:`Z`));if(Number.isNaN(r))throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);if(rDate.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);return this.seconds=A.parse(r/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt(`1`+n[7]+`0`.repeat(9-n[7].length))-1e9),this}toJson(e){let t=Number(this.seconds)*1e3;if(tDate.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(this.nanos<0)throw Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);let n=`Z`;if(this.nanos>0){let e=(this.nanos+1e9).toString().substring(1);n=e.substring(3)===`000000`?`.`+e.substring(0,3)+`Z`:e.substring(6)===`000`?`.`+e.substring(0,6)+`Z`:`.`+e+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return e.fromDate(new Date)}static fromDate(t){let n=t.getTime();return new e({seconds:A.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(t,n){return new e().fromBinary(t,n)}static fromJson(t,n){return new e().fromJson(t,n)}static fromJsonString(t,n){return new e().fromJsonString(t,n)}static equals(t,n){return F.util.equals(e,t,n)}};yt.runtime=F,yt.typeName=`google.protobuf.Timestamp`,yt.fields=F.util.newFieldList(()=>[{no:1,name:`seconds`,kind:`scalar`,T:3},{no:2,name:`nanos`,kind:`scalar`,T:5}]);var bt=F.makeMessageType(`livekit.MetricsBatch`,()=>[{no:1,name:`timestamp_ms`,kind:`scalar`,T:3},{no:2,name:`normalized_timestamp`,kind:`message`,T:yt},{no:3,name:`str_data`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`time_series`,kind:`message`,T:xt,repeated:!0},{no:5,name:`events`,kind:`message`,T:Ct,repeated:!0}]),xt=F.makeMessageType(`livekit.TimeSeriesMetric`,()=>[{no:1,name:`label`,kind:`scalar`,T:13},{no:2,name:`participant_identity`,kind:`scalar`,T:13},{no:3,name:`track_sid`,kind:`scalar`,T:13},{no:4,name:`samples`,kind:`message`,T:St,repeated:!0},{no:5,name:`rid`,kind:`scalar`,T:13}]),St=F.makeMessageType(`livekit.MetricSample`,()=>[{no:1,name:`timestamp_ms`,kind:`scalar`,T:3},{no:2,name:`normalized_timestamp`,kind:`message`,T:yt},{no:3,name:`value`,kind:`scalar`,T:2}]),Ct=F.makeMessageType(`livekit.EventMetric`,()=>[{no:1,name:`label`,kind:`scalar`,T:13},{no:2,name:`participant_identity`,kind:`scalar`,T:13},{no:3,name:`track_sid`,kind:`scalar`,T:13},{no:4,name:`start_timestamp_ms`,kind:`scalar`,T:3},{no:5,name:`end_timestamp_ms`,kind:`scalar`,T:3,opt:!0},{no:6,name:`normalized_start_timestamp`,kind:`message`,T:yt},{no:7,name:`normalized_end_timestamp`,kind:`message`,T:yt,opt:!0},{no:8,name:`metadata`,kind:`scalar`,T:9},{no:9,name:`rid`,kind:`scalar`,T:13}]),wt=F.makeEnum(`livekit.BackupCodecPolicy`,[{no:0,name:`PREFER_REGRESSION`},{no:1,name:`SIMULCAST`},{no:2,name:`REGRESSION`}]),Tt=F.makeEnum(`livekit.TrackType`,[{no:0,name:`AUDIO`},{no:1,name:`VIDEO`},{no:2,name:`DATA`}]),Et=F.makeEnum(`livekit.TrackSource`,[{no:0,name:`UNKNOWN`},{no:1,name:`CAMERA`},{no:2,name:`MICROPHONE`},{no:3,name:`SCREEN_SHARE`},{no:4,name:`SCREEN_SHARE_AUDIO`}]),Dt=F.makeEnum(`livekit.VideoQuality`,[{no:0,name:`LOW`},{no:1,name:`MEDIUM`},{no:2,name:`HIGH`},{no:3,name:`OFF`}]),Ot=F.makeEnum(`livekit.ConnectionQuality`,[{no:0,name:`POOR`},{no:1,name:`GOOD`},{no:2,name:`EXCELLENT`},{no:3,name:`LOST`}]),kt=F.makeEnum(`livekit.ClientConfigSetting`,[{no:0,name:`UNSET`},{no:1,name:`DISABLED`},{no:2,name:`ENABLED`}]),At=F.makeEnum(`livekit.DisconnectReason`,[{no:0,name:`UNKNOWN_REASON`},{no:1,name:`CLIENT_INITIATED`},{no:2,name:`DUPLICATE_IDENTITY`},{no:3,name:`SERVER_SHUTDOWN`},{no:4,name:`PARTICIPANT_REMOVED`},{no:5,name:`ROOM_DELETED`},{no:6,name:`STATE_MISMATCH`},{no:7,name:`JOIN_FAILURE`},{no:8,name:`MIGRATION`},{no:9,name:`SIGNAL_CLOSE`},{no:10,name:`ROOM_CLOSED`},{no:11,name:`USER_UNAVAILABLE`},{no:12,name:`USER_REJECTED`},{no:13,name:`SIP_TRUNK_FAILURE`},{no:14,name:`CONNECTION_TIMEOUT`},{no:15,name:`MEDIA_FAILURE`},{no:16,name:`AGENT_ERROR`}]),jt=F.makeEnum(`livekit.ReconnectReason`,[{no:0,name:`RR_UNKNOWN`},{no:1,name:`RR_SIGNAL_DISCONNECTED`},{no:2,name:`RR_PUBLISHER_FAILED`},{no:3,name:`RR_SUBSCRIBER_FAILED`},{no:4,name:`RR_SWITCH_CANDIDATE`}]),Mt=F.makeEnum(`livekit.SubscriptionError`,[{no:0,name:`SE_UNKNOWN`},{no:1,name:`SE_CODEC_UNSUPPORTED`},{no:2,name:`SE_TRACK_NOTFOUND`}]),Nt=F.makeEnum(`livekit.AudioTrackFeature`,[{no:0,name:`TF_STEREO`},{no:1,name:`TF_NO_DTX`},{no:2,name:`TF_AUTO_GAIN_CONTROL`},{no:3,name:`TF_ECHO_CANCELLATION`},{no:4,name:`TF_NOISE_SUPPRESSION`},{no:5,name:`TF_ENHANCED_NOISE_CANCELLATION`},{no:6,name:`TF_PRECONNECT_BUFFER`}]),Pt=F.makeEnum(`livekit.PacketTrailerFeature`,[{no:0,name:`PTF_USER_TIMESTAMP`},{no:1,name:`PTF_FRAME_ID`}]),Ft=F.makeMessageType(`livekit.Room`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`empty_timeout`,kind:`scalar`,T:13},{no:14,name:`departure_timeout`,kind:`scalar`,T:13},{no:4,name:`max_participants`,kind:`scalar`,T:13},{no:5,name:`creation_time`,kind:`scalar`,T:3},{no:15,name:`creation_time_ms`,kind:`scalar`,T:3},{no:6,name:`turn_password`,kind:`scalar`,T:9},{no:7,name:`enabled_codecs`,kind:`message`,T:It,repeated:!0},{no:8,name:`metadata`,kind:`scalar`,T:9},{no:9,name:`num_participants`,kind:`scalar`,T:13},{no:11,name:`num_publishers`,kind:`scalar`,T:13},{no:10,name:`active_recording`,kind:`scalar`,T:8},{no:13,name:`version`,kind:`message`,T:bn}]),It=F.makeMessageType(`livekit.Codec`,()=>[{no:1,name:`mime`,kind:`scalar`,T:9},{no:2,name:`fmtp_line`,kind:`scalar`,T:9}]),Lt=F.makeMessageType(`livekit.ParticipantPermission`,()=>[{no:1,name:`can_subscribe`,kind:`scalar`,T:8},{no:2,name:`can_publish`,kind:`scalar`,T:8},{no:3,name:`can_publish_data`,kind:`scalar`,T:8},{no:9,name:`can_publish_sources`,kind:`enum`,T:F.getEnumType(Et),repeated:!0},{no:7,name:`hidden`,kind:`scalar`,T:8},{no:8,name:`recorder`,kind:`scalar`,T:8},{no:10,name:`can_update_metadata`,kind:`scalar`,T:8},{no:11,name:`agent`,kind:`scalar`,T:8},{no:12,name:`can_subscribe_metrics`,kind:`scalar`,T:8},{no:13,name:`can_manage_agent_session`,kind:`scalar`,T:8}]),Rt=F.makeMessageType(`livekit.ParticipantInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`identity`,kind:`scalar`,T:9},{no:3,name:`state`,kind:`enum`,T:F.getEnumType(zt)},{no:4,name:`tracks`,kind:`message`,T:Wt,repeated:!0},{no:5,name:`metadata`,kind:`scalar`,T:9},{no:6,name:`joined_at`,kind:`scalar`,T:3},{no:17,name:`joined_at_ms`,kind:`scalar`,T:3},{no:9,name:`name`,kind:`scalar`,T:9},{no:10,name:`version`,kind:`scalar`,T:13},{no:11,name:`permission`,kind:`message`,T:Lt},{no:12,name:`region`,kind:`scalar`,T:9},{no:13,name:`is_publisher`,kind:`scalar`,T:8},{no:14,name:`kind`,kind:`enum`,T:F.getEnumType(Bt)},{no:15,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:16,name:`disconnect_reason`,kind:`enum`,T:F.getEnumType(At)},{no:18,name:`kind_details`,kind:`enum`,T:F.getEnumType(Vt),repeated:!0},{no:19,name:`data_tracks`,kind:`message`,T:Gt,repeated:!0},{no:20,name:`client_protocol`,kind:`scalar`,T:5}]),zt=F.makeEnum(`livekit.ParticipantInfo.State`,[{no:0,name:`JOINING`},{no:1,name:`JOINED`},{no:2,name:`ACTIVE`},{no:3,name:`DISCONNECTED`}]),Bt=F.makeEnum(`livekit.ParticipantInfo.Kind`,[{no:0,name:`STANDARD`},{no:1,name:`INGRESS`},{no:2,name:`EGRESS`},{no:3,name:`SIP`},{no:4,name:`AGENT`},{no:7,name:`CONNECTOR`},{no:8,name:`BRIDGE`}]),Vt=F.makeEnum(`livekit.ParticipantInfo.KindDetail`,[{no:0,name:`CLOUD_AGENT`},{no:1,name:`FORWARDED`},{no:2,name:`CONNECTOR_WHATSAPP`},{no:3,name:`CONNECTOR_TWILIO`},{no:4,name:`BRIDGE_RTSP`}]),Ht=F.makeEnum(`livekit.Encryption.Type`,[{no:0,name:`NONE`},{no:1,name:`GCM`},{no:2,name:`CUSTOM`}]),Ut=F.makeMessageType(`livekit.SimulcastCodecInfo`,()=>[{no:1,name:`mime_type`,kind:`scalar`,T:9},{no:2,name:`mid`,kind:`scalar`,T:9},{no:3,name:`cid`,kind:`scalar`,T:9},{no:4,name:`layers`,kind:`message`,T:qt,repeated:!0},{no:5,name:`video_layer_mode`,kind:`enum`,T:F.getEnumType(Jt)},{no:6,name:`sdp_cid`,kind:`scalar`,T:9}]),Wt=F.makeMessageType(`livekit.TrackInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`type`,kind:`enum`,T:F.getEnumType(Tt)},{no:3,name:`name`,kind:`scalar`,T:9},{no:4,name:`muted`,kind:`scalar`,T:8},{no:5,name:`width`,kind:`scalar`,T:13},{no:6,name:`height`,kind:`scalar`,T:13},{no:7,name:`simulcast`,kind:`scalar`,T:8},{no:8,name:`disable_dtx`,kind:`scalar`,T:8},{no:9,name:`source`,kind:`enum`,T:F.getEnumType(Et)},{no:10,name:`layers`,kind:`message`,T:qt,repeated:!0},{no:11,name:`mime_type`,kind:`scalar`,T:9},{no:12,name:`mid`,kind:`scalar`,T:9},{no:13,name:`codecs`,kind:`message`,T:Ut,repeated:!0},{no:14,name:`stereo`,kind:`scalar`,T:8},{no:15,name:`disable_red`,kind:`scalar`,T:8},{no:16,name:`encryption`,kind:`enum`,T:F.getEnumType(Ht)},{no:17,name:`stream`,kind:`scalar`,T:9},{no:18,name:`version`,kind:`message`,T:bn},{no:19,name:`audio_features`,kind:`enum`,T:F.getEnumType(Nt),repeated:!0},{no:20,name:`backup_codec_policy`,kind:`enum`,T:F.getEnumType(wt)},{no:21,name:`packet_trailer_features`,kind:`enum`,T:F.getEnumType(Pt),repeated:!0}]),Gt=F.makeMessageType(`livekit.DataTrackInfo`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13},{no:2,name:`sid`,kind:`scalar`,T:9},{no:3,name:`name`,kind:`scalar`,T:9},{no:4,name:`encryption`,kind:`enum`,T:F.getEnumType(Ht)}]),Kt=F.makeMessageType(`livekit.DataTrackSubscriptionOptions`,()=>[{no:1,name:`target_fps`,kind:`scalar`,T:13,opt:!0}]),qt=F.makeMessageType(`livekit.VideoLayer`,()=>[{no:1,name:`quality`,kind:`enum`,T:F.getEnumType(Dt)},{no:2,name:`width`,kind:`scalar`,T:13},{no:3,name:`height`,kind:`scalar`,T:13},{no:4,name:`bitrate`,kind:`scalar`,T:13},{no:5,name:`ssrc`,kind:`scalar`,T:13},{no:6,name:`spatial_layer`,kind:`scalar`,T:5},{no:7,name:`rid`,kind:`scalar`,T:9},{no:8,name:`repair_ssrc`,kind:`scalar`,T:13}]),Jt=F.makeEnum(`livekit.VideoLayer.Mode`,[{no:0,name:`MODE_UNUSED`},{no:1,name:`ONE_SPATIAL_LAYER_PER_STREAM`},{no:2,name:`MULTIPLE_SPATIAL_LAYERS_PER_STREAM`},{no:3,name:`ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR`}]),Yt=F.makeMessageType(`livekit.DataPacket`,()=>[{no:1,name:`kind`,kind:`enum`,T:F.getEnumType(Xt)},{no:4,name:`participant_identity`,kind:`scalar`,T:9},{no:5,name:`destination_identities`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`user`,kind:`message`,T:tn,oneof:`value`},{no:3,name:`speaker`,kind:`message`,T:$t,oneof:`value`},{no:6,name:`sip_dtmf`,kind:`message`,T:nn,oneof:`value`},{no:7,name:`transcription`,kind:`message`,T:rn,oneof:`value`},{no:8,name:`metrics`,kind:`message`,T:bt,oneof:`value`},{no:9,name:`chat_message`,kind:`message`,T:on,oneof:`value`},{no:10,name:`rpc_request`,kind:`message`,T:sn,oneof:`value`},{no:11,name:`rpc_ack`,kind:`message`,T:cn,oneof:`value`},{no:12,name:`rpc_response`,kind:`message`,T:ln,oneof:`value`},{no:13,name:`stream_header`,kind:`message`,T:wn,oneof:`value`},{no:14,name:`stream_chunk`,kind:`message`,T:Tn,oneof:`value`},{no:15,name:`stream_trailer`,kind:`message`,T:En,oneof:`value`},{no:18,name:`encrypted_packet`,kind:`message`,T:Zt,oneof:`value`},{no:16,name:`sequence`,kind:`scalar`,T:13},{no:17,name:`participant_sid`,kind:`scalar`,T:9}]),Xt=F.makeEnum(`livekit.DataPacket.Kind`,[{no:0,name:`RELIABLE`},{no:1,name:`LOSSY`}]),Zt=F.makeMessageType(`livekit.EncryptedPacket`,()=>[{no:1,name:`encryption_type`,kind:`enum`,T:F.getEnumType(Ht)},{no:2,name:`iv`,kind:`scalar`,T:12},{no:3,name:`key_index`,kind:`scalar`,T:13},{no:4,name:`encrypted_value`,kind:`scalar`,T:12}]),Qt=F.makeMessageType(`livekit.EncryptedPacketPayload`,()=>[{no:1,name:`user`,kind:`message`,T:tn,oneof:`value`},{no:3,name:`chat_message`,kind:`message`,T:on,oneof:`value`},{no:4,name:`rpc_request`,kind:`message`,T:sn,oneof:`value`},{no:5,name:`rpc_ack`,kind:`message`,T:cn,oneof:`value`},{no:6,name:`rpc_response`,kind:`message`,T:ln,oneof:`value`},{no:7,name:`stream_header`,kind:`message`,T:wn,oneof:`value`},{no:8,name:`stream_chunk`,kind:`message`,T:Tn,oneof:`value`},{no:9,name:`stream_trailer`,kind:`message`,T:En,oneof:`value`}]),$t=F.makeMessageType(`livekit.ActiveSpeakerUpdate`,()=>[{no:1,name:`speakers`,kind:`message`,T:en,repeated:!0}]),en=F.makeMessageType(`livekit.SpeakerInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`level`,kind:`scalar`,T:2},{no:3,name:`active`,kind:`scalar`,T:8}]),tn=F.makeMessageType(`livekit.UserPacket`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:5,name:`participant_identity`,kind:`scalar`,T:9},{no:2,name:`payload`,kind:`scalar`,T:12},{no:3,name:`destination_sids`,kind:`scalar`,T:9,repeated:!0},{no:6,name:`destination_identities`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`topic`,kind:`scalar`,T:9,opt:!0},{no:8,name:`id`,kind:`scalar`,T:9,opt:!0},{no:9,name:`start_time`,kind:`scalar`,T:4,opt:!0},{no:10,name:`end_time`,kind:`scalar`,T:4,opt:!0},{no:11,name:`nonce`,kind:`scalar`,T:12}]),nn=F.makeMessageType(`livekit.SipDTMF`,()=>[{no:3,name:`code`,kind:`scalar`,T:13},{no:4,name:`digit`,kind:`scalar`,T:9}]),rn=F.makeMessageType(`livekit.Transcription`,()=>[{no:2,name:`transcribed_participant_identity`,kind:`scalar`,T:9},{no:3,name:`track_id`,kind:`scalar`,T:9},{no:4,name:`segments`,kind:`message`,T:an,repeated:!0}]),an=F.makeMessageType(`livekit.TranscriptionSegment`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`text`,kind:`scalar`,T:9},{no:3,name:`start_time`,kind:`scalar`,T:4},{no:4,name:`end_time`,kind:`scalar`,T:4},{no:5,name:`final`,kind:`scalar`,T:8},{no:6,name:`language`,kind:`scalar`,T:9}]),on=F.makeMessageType(`livekit.ChatMessage`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`timestamp`,kind:`scalar`,T:3},{no:3,name:`edit_timestamp`,kind:`scalar`,T:3,opt:!0},{no:4,name:`message`,kind:`scalar`,T:9},{no:5,name:`deleted`,kind:`scalar`,T:8},{no:6,name:`generated`,kind:`scalar`,T:8}]),sn=F.makeMessageType(`livekit.RpcRequest`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`method`,kind:`scalar`,T:9},{no:3,name:`payload`,kind:`scalar`,T:9},{no:4,name:`response_timeout_ms`,kind:`scalar`,T:13},{no:5,name:`version`,kind:`scalar`,T:13},{no:6,name:`compressed_payload`,kind:`scalar`,T:12}]),cn=F.makeMessageType(`livekit.RpcAck`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:9}]),ln=F.makeMessageType(`livekit.RpcResponse`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:9},{no:2,name:`payload`,kind:`scalar`,T:9,oneof:`value`},{no:3,name:`error`,kind:`message`,T:un,oneof:`value`},{no:4,name:`compressed_payload`,kind:`scalar`,T:12,oneof:`value`}]),un=F.makeMessageType(`livekit.RpcError`,()=>[{no:1,name:`code`,kind:`scalar`,T:13},{no:2,name:`message`,kind:`scalar`,T:9},{no:3,name:`data`,kind:`scalar`,T:9}]),dn=F.makeMessageType(`livekit.ParticipantTracks`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sids`,kind:`scalar`,T:9,repeated:!0}]),fn=F.makeMessageType(`livekit.ServerInfo`,()=>[{no:1,name:`edition`,kind:`enum`,T:F.getEnumType(pn)},{no:2,name:`version`,kind:`scalar`,T:9},{no:3,name:`protocol`,kind:`scalar`,T:5},{no:4,name:`region`,kind:`scalar`,T:9},{no:5,name:`node_id`,kind:`scalar`,T:9},{no:6,name:`debug_info`,kind:`scalar`,T:9},{no:7,name:`agent_protocol`,kind:`scalar`,T:5}]),pn=F.makeEnum(`livekit.ServerInfo.Edition`,[{no:0,name:`Standard`},{no:1,name:`Cloud`}]),mn=F.makeMessageType(`livekit.ClientInfo`,()=>[{no:1,name:`sdk`,kind:`enum`,T:F.getEnumType(hn)},{no:2,name:`version`,kind:`scalar`,T:9},{no:3,name:`protocol`,kind:`scalar`,T:5},{no:4,name:`os`,kind:`scalar`,T:9},{no:5,name:`os_version`,kind:`scalar`,T:9},{no:6,name:`device_model`,kind:`scalar`,T:9},{no:7,name:`browser`,kind:`scalar`,T:9},{no:8,name:`browser_version`,kind:`scalar`,T:9},{no:9,name:`address`,kind:`scalar`,T:9},{no:10,name:`network`,kind:`scalar`,T:9},{no:11,name:`other_sdks`,kind:`scalar`,T:9},{no:12,name:`client_protocol`,kind:`scalar`,T:5},{no:13,name:`capabilities`,kind:`enum`,T:F.getEnumType(gn),repeated:!0}]),hn=F.makeEnum(`livekit.ClientInfo.SDK`,[{no:0,name:`UNKNOWN`},{no:1,name:`JS`},{no:2,name:`SWIFT`},{no:3,name:`ANDROID`},{no:4,name:`FLUTTER`},{no:5,name:`GO`},{no:6,name:`UNITY`},{no:7,name:`REACT_NATIVE`},{no:8,name:`RUST`},{no:9,name:`PYTHON`},{no:10,name:`CPP`},{no:11,name:`UNITY_WEB`},{no:12,name:`NODE`},{no:13,name:`UNREAL`},{no:14,name:`ESP32`}]),gn=F.makeEnum(`livekit.ClientInfo.Capability`,[{no:0,name:`CAP_UNUSED`},{no:1,name:`CAP_PACKET_TRAILER`}]),_n=F.makeMessageType(`livekit.ClientConfiguration`,()=>[{no:1,name:`video`,kind:`message`,T:vn},{no:2,name:`screen`,kind:`message`,T:vn},{no:3,name:`resume_connection`,kind:`enum`,T:F.getEnumType(kt)},{no:4,name:`disabled_codecs`,kind:`message`,T:yn},{no:5,name:`force_relay`,kind:`enum`,T:F.getEnumType(kt)}]),vn=F.makeMessageType(`livekit.VideoConfiguration`,()=>[{no:1,name:`hardware_encoder`,kind:`enum`,T:F.getEnumType(kt)}]),yn=F.makeMessageType(`livekit.DisabledCodecs`,()=>[{no:1,name:`codecs`,kind:`message`,T:It,repeated:!0},{no:2,name:`publish`,kind:`message`,T:It,repeated:!0}]),bn=F.makeMessageType(`livekit.TimedVersion`,()=>[{no:1,name:`unix_micro`,kind:`scalar`,T:3},{no:2,name:`ticks`,kind:`scalar`,T:5}]),xn=F.makeEnum(`livekit.DataStream.OperationType`,[{no:0,name:`CREATE`},{no:1,name:`UPDATE`},{no:2,name:`DELETE`},{no:3,name:`REACTION`}]),Sn=F.makeMessageType(`livekit.DataStream.TextHeader`,()=>[{no:1,name:`operation_type`,kind:`enum`,T:F.getEnumType(xn)},{no:2,name:`version`,kind:`scalar`,T:5},{no:3,name:`reply_to_stream_id`,kind:`scalar`,T:9},{no:4,name:`attached_stream_ids`,kind:`scalar`,T:9,repeated:!0},{no:5,name:`generated`,kind:`scalar`,T:8}],{localName:`DataStream_TextHeader`}),Cn=F.makeMessageType(`livekit.DataStream.ByteHeader`,()=>[{no:1,name:`name`,kind:`scalar`,T:9}],{localName:`DataStream_ByteHeader`}),wn=F.makeMessageType(`livekit.DataStream.Header`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`timestamp`,kind:`scalar`,T:3},{no:3,name:`topic`,kind:`scalar`,T:9},{no:4,name:`mime_type`,kind:`scalar`,T:9},{no:5,name:`total_length`,kind:`scalar`,T:4,opt:!0},{no:7,name:`encryption_type`,kind:`enum`,T:F.getEnumType(Ht)},{no:8,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:9,name:`text_header`,kind:`message`,T:Sn,oneof:`content_header`},{no:10,name:`byte_header`,kind:`message`,T:Cn,oneof:`content_header`}],{localName:`DataStream_Header`}),Tn=F.makeMessageType(`livekit.DataStream.Chunk`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`chunk_index`,kind:`scalar`,T:4},{no:3,name:`content`,kind:`scalar`,T:12},{no:4,name:`version`,kind:`scalar`,T:5},{no:5,name:`iv`,kind:`scalar`,T:12,opt:!0}],{localName:`DataStream_Chunk`}),En=F.makeMessageType(`livekit.DataStream.Trailer`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`reason`,kind:`scalar`,T:9},{no:3,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}}],{localName:`DataStream_Trailer`}),Dn=F.makeMessageType(`livekit.SubscribedAudioCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`enabled`,kind:`scalar`,T:8}]),On=F.makeEnum(`livekit.SignalTarget`,[{no:0,name:`PUBLISHER`},{no:1,name:`SUBSCRIBER`}]),kn=F.makeEnum(`livekit.StreamState`,[{no:0,name:`ACTIVE`},{no:1,name:`PAUSED`}]),An=F.makeEnum(`livekit.CandidateProtocol`,[{no:0,name:`UDP`},{no:1,name:`TCP`},{no:2,name:`TLS`}]),jn=F.makeMessageType(`livekit.SignalRequest`,()=>[{no:1,name:`offer`,kind:`message`,T:qn,oneof:`message`},{no:2,name:`answer`,kind:`message`,T:qn,oneof:`message`},{no:3,name:`trickle`,kind:`message`,T:Vn,oneof:`message`},{no:4,name:`add_track`,kind:`message`,T:Pn,oneof:`message`},{no:5,name:`mute`,kind:`message`,T:Hn,oneof:`message`},{no:6,name:`subscription`,kind:`message`,T:Yn,oneof:`message`},{no:7,name:`track_setting`,kind:`message`,T:Qn,oneof:`message`},{no:8,name:`leave`,kind:`message`,T:tr,oneof:`message`},{no:10,name:`update_layers`,kind:`message`,T:rr,oneof:`message`},{no:11,name:`subscription_permission`,kind:`message`,T:_r,oneof:`message`},{no:12,name:`sync_state`,kind:`message`,T:br,oneof:`message`},{no:13,name:`simulate`,kind:`message`,T:Cr,oneof:`message`},{no:14,name:`ping`,kind:`scalar`,T:3,oneof:`message`},{no:15,name:`update_metadata`,kind:`message`,T:ir,oneof:`message`},{no:16,name:`ping_req`,kind:`message`,T:wr,oneof:`message`},{no:17,name:`update_audio_track`,kind:`message`,T:$n,oneof:`message`},{no:18,name:`update_video_track`,kind:`message`,T:er,oneof:`message`},{no:19,name:`publish_data_track_request`,kind:`message`,T:Fn,oneof:`message`},{no:20,name:`unpublish_data_track_request`,kind:`message`,T:Ln,oneof:`message`},{no:21,name:`update_data_subscription`,kind:`message`,T:Xn,oneof:`message`}]),Mn=F.makeMessageType(`livekit.SignalResponse`,()=>[{no:1,name:`join`,kind:`message`,T:Un,oneof:`message`},{no:2,name:`answer`,kind:`message`,T:qn,oneof:`message`},{no:3,name:`offer`,kind:`message`,T:qn,oneof:`message`},{no:4,name:`trickle`,kind:`message`,T:Vn,oneof:`message`},{no:5,name:`update`,kind:`message`,T:Jn,oneof:`message`},{no:6,name:`track_published`,kind:`message`,T:Gn,oneof:`message`},{no:8,name:`leave`,kind:`message`,T:tr,oneof:`message`},{no:9,name:`mute`,kind:`message`,T:Hn,oneof:`message`},{no:10,name:`speakers_changed`,kind:`message`,T:or,oneof:`message`},{no:11,name:`room_update`,kind:`message`,T:sr,oneof:`message`},{no:12,name:`connection_quality`,kind:`message`,T:lr,oneof:`message`},{no:13,name:`stream_state_update`,kind:`message`,T:dr,oneof:`message`},{no:14,name:`subscribed_quality_update`,kind:`message`,T:mr,oneof:`message`},{no:15,name:`subscription_permission_update`,kind:`message`,T:vr,oneof:`message`},{no:16,name:`refresh_token`,kind:`scalar`,T:9,oneof:`message`},{no:17,name:`track_unpublished`,kind:`message`,T:Kn,oneof:`message`},{no:18,name:`pong`,kind:`scalar`,T:3,oneof:`message`},{no:19,name:`reconnect`,kind:`message`,T:Wn,oneof:`message`},{no:20,name:`pong_resp`,kind:`message`,T:Tr,oneof:`message`},{no:21,name:`subscription_response`,kind:`message`,T:Or,oneof:`message`},{no:22,name:`request_response`,kind:`message`,T:kr,oneof:`message`},{no:23,name:`track_subscribed`,kind:`message`,T:jr,oneof:`message`},{no:24,name:`room_moved`,kind:`message`,T:yr,oneof:`message`},{no:25,name:`media_sections_requirement`,kind:`message`,T:Ir,oneof:`message`},{no:26,name:`subscribed_audio_codec_update`,kind:`message`,T:hr,oneof:`message`},{no:27,name:`publish_data_track_response`,kind:`message`,T:In,oneof:`message`},{no:28,name:`unpublish_data_track_response`,kind:`message`,T:Rn,oneof:`message`},{no:29,name:`data_track_subscriber_handles`,kind:`message`,T:zn,oneof:`message`}]),Nn=F.makeMessageType(`livekit.SimulcastCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`cid`,kind:`scalar`,T:9},{no:4,name:`layers`,kind:`message`,T:qt,repeated:!0},{no:5,name:`video_layer_mode`,kind:`enum`,T:F.getEnumType(Jt)}]),Pn=F.makeMessageType(`livekit.AddTrackRequest`,()=>[{no:1,name:`cid`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`type`,kind:`enum`,T:F.getEnumType(Tt)},{no:4,name:`width`,kind:`scalar`,T:13},{no:5,name:`height`,kind:`scalar`,T:13},{no:6,name:`muted`,kind:`scalar`,T:8},{no:7,name:`disable_dtx`,kind:`scalar`,T:8},{no:8,name:`source`,kind:`enum`,T:F.getEnumType(Et)},{no:9,name:`layers`,kind:`message`,T:qt,repeated:!0},{no:10,name:`simulcast_codecs`,kind:`message`,T:Nn,repeated:!0},{no:11,name:`sid`,kind:`scalar`,T:9},{no:12,name:`stereo`,kind:`scalar`,T:8},{no:13,name:`disable_red`,kind:`scalar`,T:8},{no:14,name:`encryption`,kind:`enum`,T:F.getEnumType(Ht)},{no:15,name:`stream`,kind:`scalar`,T:9},{no:16,name:`backup_codec_policy`,kind:`enum`,T:F.getEnumType(wt)},{no:17,name:`audio_features`,kind:`enum`,T:F.getEnumType(Nt),repeated:!0},{no:18,name:`packet_trailer_features`,kind:`enum`,T:F.getEnumType(Pt),repeated:!0}]),Fn=F.makeMessageType(`livekit.PublishDataTrackRequest`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`encryption`,kind:`enum`,T:F.getEnumType(Ht)}]),In=F.makeMessageType(`livekit.PublishDataTrackResponse`,()=>[{no:1,name:`info`,kind:`message`,T:Gt}]),Ln=F.makeMessageType(`livekit.UnpublishDataTrackRequest`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13}]),Rn=F.makeMessageType(`livekit.UnpublishDataTrackResponse`,()=>[{no:1,name:`info`,kind:`message`,T:Gt}]),zn=F.makeMessageType(`livekit.DataTrackSubscriberHandles`,()=>[{no:1,name:`sub_handles`,kind:`map`,K:13,V:{kind:`message`,T:Bn}}]),Bn=F.makeMessageType(`livekit.DataTrackSubscriberHandles.PublishedDataTrack`,()=>[{no:1,name:`publisher_identity`,kind:`scalar`,T:9},{no:2,name:`publisher_sid`,kind:`scalar`,T:9},{no:3,name:`track_sid`,kind:`scalar`,T:9}],{localName:`DataTrackSubscriberHandles_PublishedDataTrack`}),Vn=F.makeMessageType(`livekit.TrickleRequest`,()=>[{no:1,name:`candidateInit`,kind:`scalar`,T:9},{no:2,name:`target`,kind:`enum`,T:F.getEnumType(On)},{no:3,name:`final`,kind:`scalar`,T:8}]),Hn=F.makeMessageType(`livekit.MuteTrackRequest`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`muted`,kind:`scalar`,T:8}]),Un=F.makeMessageType(`livekit.JoinResponse`,()=>[{no:1,name:`room`,kind:`message`,T:Ft},{no:2,name:`participant`,kind:`message`,T:Rt},{no:3,name:`other_participants`,kind:`message`,T:Rt,repeated:!0},{no:4,name:`server_version`,kind:`scalar`,T:9},{no:5,name:`ice_servers`,kind:`message`,T:ar,repeated:!0},{no:6,name:`subscriber_primary`,kind:`scalar`,T:8},{no:7,name:`alternative_url`,kind:`scalar`,T:9},{no:8,name:`client_configuration`,kind:`message`,T:_n},{no:9,name:`server_region`,kind:`scalar`,T:9},{no:10,name:`ping_timeout`,kind:`scalar`,T:5},{no:11,name:`ping_interval`,kind:`scalar`,T:5},{no:12,name:`server_info`,kind:`message`,T:fn},{no:13,name:`sif_trailer`,kind:`scalar`,T:12},{no:14,name:`enabled_publish_codecs`,kind:`message`,T:It,repeated:!0},{no:15,name:`fast_publish`,kind:`scalar`,T:8}]),Wn=F.makeMessageType(`livekit.ReconnectResponse`,()=>[{no:1,name:`ice_servers`,kind:`message`,T:ar,repeated:!0},{no:2,name:`client_configuration`,kind:`message`,T:_n},{no:3,name:`server_info`,kind:`message`,T:fn},{no:4,name:`last_message_seq`,kind:`scalar`,T:13}]),Gn=F.makeMessageType(`livekit.TrackPublishedResponse`,()=>[{no:1,name:`cid`,kind:`scalar`,T:9},{no:2,name:`track`,kind:`message`,T:Wt}]),Kn=F.makeMessageType(`livekit.TrackUnpublishedResponse`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9}]),qn=F.makeMessageType(`livekit.SessionDescription`,()=>[{no:1,name:`type`,kind:`scalar`,T:9},{no:2,name:`sdp`,kind:`scalar`,T:9},{no:3,name:`id`,kind:`scalar`,T:13},{no:4,name:`mid_to_track_id`,kind:`map`,K:9,V:{kind:`scalar`,T:9}}]),Jn=F.makeMessageType(`livekit.ParticipantUpdate`,()=>[{no:1,name:`participants`,kind:`message`,T:Rt,repeated:!0}]),Yn=F.makeMessageType(`livekit.UpdateSubscription`,()=>[{no:1,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`subscribe`,kind:`scalar`,T:8},{no:3,name:`participant_tracks`,kind:`message`,T:dn,repeated:!0}]),Xn=F.makeMessageType(`livekit.UpdateDataSubscription`,()=>[{no:1,name:`updates`,kind:`message`,T:Zn,repeated:!0}]),Zn=F.makeMessageType(`livekit.UpdateDataSubscription.Update`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribe`,kind:`scalar`,T:8},{no:3,name:`options`,kind:`message`,T:Kt}],{localName:`UpdateDataSubscription_Update`}),Qn=F.makeMessageType(`livekit.UpdateTrackSettings`,()=>[{no:1,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:3,name:`disabled`,kind:`scalar`,T:8},{no:4,name:`quality`,kind:`enum`,T:F.getEnumType(Dt)},{no:5,name:`width`,kind:`scalar`,T:13},{no:6,name:`height`,kind:`scalar`,T:13},{no:7,name:`fps`,kind:`scalar`,T:13},{no:8,name:`priority`,kind:`scalar`,T:13}]),$n=F.makeMessageType(`livekit.UpdateLocalAudioTrack`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`features`,kind:`enum`,T:F.getEnumType(Nt),repeated:!0}]),er=F.makeMessageType(`livekit.UpdateLocalVideoTrack`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`width`,kind:`scalar`,T:13},{no:3,name:`height`,kind:`scalar`,T:13}]),tr=F.makeMessageType(`livekit.LeaveRequest`,()=>[{no:1,name:`can_reconnect`,kind:`scalar`,T:8},{no:2,name:`reason`,kind:`enum`,T:F.getEnumType(At)},{no:3,name:`action`,kind:`enum`,T:F.getEnumType(nr)},{no:4,name:`regions`,kind:`message`,T:Er}]),nr=F.makeEnum(`livekit.LeaveRequest.Action`,[{no:0,name:`DISCONNECT`},{no:1,name:`RESUME`},{no:2,name:`RECONNECT`}]),rr=F.makeMessageType(`livekit.UpdateVideoLayers`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`layers`,kind:`message`,T:qt,repeated:!0}]),ir=F.makeMessageType(`livekit.UpdateParticipantMetadata`,()=>[{no:1,name:`metadata`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:4,name:`request_id`,kind:`scalar`,T:13}]),ar=F.makeMessageType(`livekit.ICEServer`,()=>[{no:1,name:`urls`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`username`,kind:`scalar`,T:9},{no:3,name:`credential`,kind:`scalar`,T:9}]),or=F.makeMessageType(`livekit.SpeakersChanged`,()=>[{no:1,name:`speakers`,kind:`message`,T:en,repeated:!0}]),sr=F.makeMessageType(`livekit.RoomUpdate`,()=>[{no:1,name:`room`,kind:`message`,T:Ft}]),cr=F.makeMessageType(`livekit.ConnectionQualityInfo`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`quality`,kind:`enum`,T:F.getEnumType(Ot)},{no:3,name:`score`,kind:`scalar`,T:2}]),lr=F.makeMessageType(`livekit.ConnectionQualityUpdate`,()=>[{no:1,name:`updates`,kind:`message`,T:cr,repeated:!0}]),ur=F.makeMessageType(`livekit.StreamStateInfo`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sid`,kind:`scalar`,T:9},{no:3,name:`state`,kind:`enum`,T:F.getEnumType(kn)}]),dr=F.makeMessageType(`livekit.StreamStateUpdate`,()=>[{no:1,name:`stream_states`,kind:`message`,T:ur,repeated:!0}]),fr=F.makeMessageType(`livekit.SubscribedQuality`,()=>[{no:1,name:`quality`,kind:`enum`,T:F.getEnumType(Dt)},{no:2,name:`enabled`,kind:`scalar`,T:8}]),pr=F.makeMessageType(`livekit.SubscribedCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`qualities`,kind:`message`,T:fr,repeated:!0}]),mr=F.makeMessageType(`livekit.SubscribedQualityUpdate`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribed_qualities`,kind:`message`,T:fr,repeated:!0},{no:3,name:`subscribed_codecs`,kind:`message`,T:pr,repeated:!0}]),hr=F.makeMessageType(`livekit.SubscribedAudioCodecUpdate`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribed_audio_codecs`,kind:`message`,T:Dn,repeated:!0}]),gr=F.makeMessageType(`livekit.TrackPermission`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`all_tracks`,kind:`scalar`,T:8},{no:3,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`participant_identity`,kind:`scalar`,T:9}]),_r=F.makeMessageType(`livekit.SubscriptionPermission`,()=>[{no:1,name:`all_participants`,kind:`scalar`,T:8},{no:2,name:`track_permissions`,kind:`message`,T:gr,repeated:!0}]),vr=F.makeMessageType(`livekit.SubscriptionPermissionUpdate`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sid`,kind:`scalar`,T:9},{no:3,name:`allowed`,kind:`scalar`,T:8}]),yr=F.makeMessageType(`livekit.RoomMovedResponse`,()=>[{no:1,name:`room`,kind:`message`,T:Ft},{no:2,name:`token`,kind:`scalar`,T:9},{no:3,name:`participant`,kind:`message`,T:Rt},{no:4,name:`other_participants`,kind:`message`,T:Rt,repeated:!0}]),br=F.makeMessageType(`livekit.SyncState`,()=>[{no:1,name:`answer`,kind:`message`,T:qn},{no:2,name:`subscription`,kind:`message`,T:Yn},{no:3,name:`publish_tracks`,kind:`message`,T:Gn,repeated:!0},{no:4,name:`data_channels`,kind:`message`,T:Sr,repeated:!0},{no:5,name:`offer`,kind:`message`,T:qn},{no:6,name:`track_sids_disabled`,kind:`scalar`,T:9,repeated:!0},{no:7,name:`datachannel_receive_states`,kind:`message`,T:xr,repeated:!0},{no:8,name:`publish_data_tracks`,kind:`message`,T:In,repeated:!0}]),xr=F.makeMessageType(`livekit.DataChannelReceiveState`,()=>[{no:1,name:`publisher_sid`,kind:`scalar`,T:9},{no:2,name:`last_seq`,kind:`scalar`,T:13}]),Sr=F.makeMessageType(`livekit.DataChannelInfo`,()=>[{no:1,name:`label`,kind:`scalar`,T:9},{no:2,name:`id`,kind:`scalar`,T:13},{no:3,name:`target`,kind:`enum`,T:F.getEnumType(On)}]),Cr=F.makeMessageType(`livekit.SimulateScenario`,()=>[{no:1,name:`speaker_update`,kind:`scalar`,T:5,oneof:`scenario`},{no:2,name:`node_failure`,kind:`scalar`,T:8,oneof:`scenario`},{no:3,name:`migration`,kind:`scalar`,T:8,oneof:`scenario`},{no:4,name:`server_leave`,kind:`scalar`,T:8,oneof:`scenario`},{no:5,name:`switch_candidate_protocol`,kind:`enum`,T:F.getEnumType(An),oneof:`scenario`},{no:6,name:`subscriber_bandwidth`,kind:`scalar`,T:3,oneof:`scenario`},{no:7,name:`disconnect_signal_on_resume`,kind:`scalar`,T:8,oneof:`scenario`},{no:8,name:`disconnect_signal_on_resume_no_messages`,kind:`scalar`,T:8,oneof:`scenario`},{no:9,name:`leave_request_full_reconnect`,kind:`scalar`,T:8,oneof:`scenario`}]),wr=F.makeMessageType(`livekit.Ping`,()=>[{no:1,name:`timestamp`,kind:`scalar`,T:3},{no:2,name:`rtt`,kind:`scalar`,T:3}]),Tr=F.makeMessageType(`livekit.Pong`,()=>[{no:1,name:`last_ping_timestamp`,kind:`scalar`,T:3},{no:2,name:`timestamp`,kind:`scalar`,T:3}]),Er=F.makeMessageType(`livekit.RegionSettings`,()=>[{no:1,name:`regions`,kind:`message`,T:Dr,repeated:!0}]),Dr=F.makeMessageType(`livekit.RegionInfo`,()=>[{no:1,name:`region`,kind:`scalar`,T:9},{no:2,name:`url`,kind:`scalar`,T:9},{no:3,name:`distance`,kind:`scalar`,T:3}]),Or=F.makeMessageType(`livekit.SubscriptionResponse`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`err`,kind:`enum`,T:F.getEnumType(Mt)}]),kr=F.makeMessageType(`livekit.RequestResponse`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:13},{no:2,name:`reason`,kind:`enum`,T:F.getEnumType(Ar)},{no:3,name:`message`,kind:`scalar`,T:9},{no:4,name:`trickle`,kind:`message`,T:Vn,oneof:`request`},{no:5,name:`add_track`,kind:`message`,T:Pn,oneof:`request`},{no:6,name:`mute`,kind:`message`,T:Hn,oneof:`request`},{no:7,name:`update_metadata`,kind:`message`,T:ir,oneof:`request`},{no:8,name:`update_audio_track`,kind:`message`,T:$n,oneof:`request`},{no:9,name:`update_video_track`,kind:`message`,T:er,oneof:`request`},{no:10,name:`publish_data_track`,kind:`message`,T:Fn,oneof:`request`},{no:11,name:`unpublish_data_track`,kind:`message`,T:Ln,oneof:`request`}]),Ar=F.makeEnum(`livekit.RequestResponse.Reason`,[{no:0,name:`OK`},{no:1,name:`NOT_FOUND`},{no:2,name:`NOT_ALLOWED`},{no:3,name:`LIMIT_EXCEEDED`},{no:4,name:`QUEUED`},{no:5,name:`UNSUPPORTED_TYPE`},{no:6,name:`UNCLASSIFIED_ERROR`},{no:7,name:`INVALID_HANDLE`},{no:8,name:`INVALID_NAME`},{no:9,name:`DUPLICATE_HANDLE`},{no:10,name:`DUPLICATE_NAME`}]),jr=F.makeMessageType(`livekit.TrackSubscribed`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9}]),Mr=F.makeMessageType(`livekit.ConnectionSettings`,()=>[{no:1,name:`auto_subscribe`,kind:`scalar`,T:8},{no:2,name:`adaptive_stream`,kind:`scalar`,T:8},{no:3,name:`subscriber_allow_pause`,kind:`scalar`,T:8,opt:!0},{no:4,name:`disable_ice_lite`,kind:`scalar`,T:8},{no:5,name:`auto_subscribe_data_track`,kind:`scalar`,T:8,opt:!0}]),Nr=F.makeMessageType(`livekit.JoinRequest`,()=>[{no:1,name:`client_info`,kind:`message`,T:mn},{no:2,name:`connection_settings`,kind:`message`,T:Mr},{no:3,name:`metadata`,kind:`scalar`,T:9},{no:4,name:`participant_attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:5,name:`add_track_requests`,kind:`message`,T:Pn,repeated:!0},{no:6,name:`publisher_offer`,kind:`message`,T:qn},{no:7,name:`reconnect`,kind:`scalar`,T:8},{no:8,name:`reconnect_reason`,kind:`enum`,T:F.getEnumType(jt)},{no:9,name:`participant_sid`,kind:`scalar`,T:9},{no:10,name:`sync_state`,kind:`message`,T:br}]),Pr=F.makeMessageType(`livekit.WrappedJoinRequest`,()=>[{no:1,name:`compression`,kind:`enum`,T:F.getEnumType(Fr)},{no:2,name:`join_request`,kind:`scalar`,T:12}]),Fr=F.makeEnum(`livekit.WrappedJoinRequest.Compression`,[{no:0,name:`NONE`},{no:1,name:`GZIP`}]),Ir=F.makeMessageType(`livekit.MediaSectionsRequirement`,()=>[{no:1,name:`num_audios`,kind:`scalar`,T:13},{no:2,name:`num_videos`,kind:`scalar`,T:13}]);function Lr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Rr={exports:{}},zr=Rr.exports,Br;function Vr(){return Br?Rr.exports:(Br=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})(zr,function(){var e=function(){},t=`undefined`,n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=[`trace`,`debug`,`info`,`warn`,`error`],i={},a=null;function o(e,t){var n=e[t];if(typeof n.bind==`function`)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch{return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(r){return r===`debug`&&(r=`log`),typeof console===t?!1:r===`trace`&&n?s:console[r]===void 0?console.log===void 0?e:o(console,`log`):o(console,r)}function l(){for(var n=this.getLevel(),i=0;i=0&&t<=o.levels.SILENT)return t;throw TypeError(`log.setLevel() called with invalid level: `+e)}o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=n||d,o.getLevel=function(){return u??c??s},o.setLevel=function(e,t){return u=g(e),t!==!1&&p(u),l.call(o)},o.setDefaultLevel=function(e){c=g(e),m()||o.setLevel(e,!1)},o.resetLevel=function(){u=null,h(),l.call(o)},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)},o.rebuild=function(){if(a!==o&&(s=g(a.getLevel())),l.call(o),a===o)for(var e in i)i[e].rebuild()},s=g(a?a.getLevel():`WARN`);var _=m();_!=null&&(u=g(_)),l.call(o)}a=new f,a.getLogger=function(e){if(typeof e!=`symbol`&&typeof e!=`string`||e===``)throw TypeError(`You must supply a name when creating a logger.`);var t=i[e];return t||=i[e]=new f(e,a.methodFactory),t};var p=typeof window===t?void 0:window.log;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return i},a.default=a,a})})(Rr),Rr.exports)}var Hr=Vr(),Ur;(function(e){e[e.trace=0]=`trace`,e[e.debug=1]=`debug`,e[e.info=2]=`info`,e[e.warn=3]=`warn`,e[e.error=4]=`error`,e[e.silent=5]=`silent`})(Ur||={});var Wr;(function(e){e.Default=`livekit`,e.Room=`livekit-room`,e.TokenSource=`livekit-token-source`,e.Participant=`livekit-participant`,e.Track=`livekit-track`,e.Publication=`livekit-track-publication`,e.Engine=`livekit-engine`,e.Signal=`livekit-signal`,e.PCManager=`livekit-pc-manager`,e.PCTransport=`livekit-pc-transport`,e.E2EE=`lk-e2ee`,e.DataTracks=`livekit-data-tracks`})(Wr||={});var I=Hr.getLogger(Wr.Default);Object.values(Wr).map(e=>Hr.getLogger(e)),I.setDefaultLevel(Ur.info);function Gr(e,t){let n=Hr.getLogger(e);return n.setDefaultLevel(I.getLevel()),t?Kr(n,t):n}function Kr(e,t){let n=n=>(r,i)=>{let a=t(),o=a||i?Object.assign(Object.assign({},a),i):void 0;e[n](r,o)},r=Object.create(e);return r.trace=n(`trace`),r.debug=n(`debug`),r.info=n(`info`),r.warn=n(`warn`),r.error=n(`error`),r}var qr=Hr.getLogger(Wr.E2EE),Jr=7e3,Yr=[0,300,4*300,9*300,16*300,Jr,Jr,Jr,Jr,Jr],Xr=class{constructor(e){this._retryDelays=e===void 0?Yr:[...e]}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;let t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}};function Zr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function $r(e){return this instanceof $r?(this.v=e,this):new $r(e)}function ei(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof $r?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ti(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:$r(e[r](t)),done:!1}:i?i(t):t}:i}}function ni(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Qr==`function`?Qr(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}var ri={exports:{}},ii;function ai(){if(ii)return ri.exports;ii=1;var e=typeof Reflect==`object`?Reflect:null,t=e&&typeof e.apply==`function`?e.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},n=e&&typeof e.ownKeys==`function`?e.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function r(e){console&&console.warn&&console.warn(e)}var i=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}ri.exports=a,ri.exports.once=_,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if(typeof e!=`number`||e<0||i(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);o=e}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||i(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function c(e){return e._maxListeners===void 0?a.defaultMaxListeners:e._maxListeners}a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var n=[],r=1;r0&&(o=n[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)t(c,this,n);else for(var l=c.length,u=m(c,l),r=0;r0&&l.length>a&&!l.warned){l.warned=!0;var u=Error(`Possible EventEmitter memory leak detected. `+l.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);u.name=`MaxListenersExceededWarning`,u.emitter=e,u.type=t,u.count=l.length,r(u)}return e}a.prototype.addListener=function(e,t){return l(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return l(this,e,t,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}a.prototype.once=function(e,t){return s(t),this.on(e,d(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,d(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,i,a,o;if(s(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():h(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r=0;r--)this.removeListener(e,t[r]);return this};function f(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?g(i):m(i,i.length)}a.prototype.listeners=function(e){return f(this,e,!0)},a.prototype.rawListeners=function(e){return f(this,e,!1)},a.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p;function p(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function m(e,t){for(var n=Array(t),r=0;r=n&&parseFloat(r[n],10)}function di(e,t,n){if(!e.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,`addEventListener`).writable){mi(`Unable to polyfill events`);return}let r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);let a=e=>{let t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,a),i.apply(this,[e,a])};let a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t]||!this._eventMap[t].has(n))return a.apply(this,arguments);let r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[e,r])},Object.defineProperty(r,`on`+t,{get(){return this[`_on`+t]},set(e){this[`_on`+t]&&(this.removeEventListener(t,this[`_on`+t]),delete this[`_on`+t]),e&&this.addEventListener(t,this[`_on`+t]=e)},enumerable:!0,configurable:!0})}function fi(e){return typeof e==`boolean`?(ci=e,e?`adapter.js logging disabled`:`adapter.js logging enabled`):Error(`Argument type: `+typeof e+`. Please use a boolean.`)}function pi(e){return typeof e==`boolean`?(li=!e,`adapter.js deprecation warnings `+(e?`disabled`:`enabled`)):Error(`Argument type: `+typeof e+`. Please use a boolean.`)}function mi(){if(typeof window==`object`){if(ci)return;typeof console<`u`&&typeof console.log==`function`&&console.log.apply(console,arguments)}}function hi(e,t){li&&console.warn(e+` is deprecated, please use `+t+` instead.`)}function gi(e){let t={browser:null,version:null};if(e===void 0||!e.navigator||!e.navigator.userAgent)return t.browser=`Not a browser.`,t;let{navigator:n}=e;if(n.userAgentData&&n.userAgentData.brands){let e=n.userAgentData.brands.find(e=>e.brand===`Chromium`);if(e)return{browser:`chrome`,version:parseInt(e.version,10)}}if(n.mozGetUserMedia)t.browser=`firefox`,t.version=parseInt(ui(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection)t.browser=`chrome`,t.version=parseInt(ui(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else if(e.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser=`safari`,t.version=parseInt(ui(n.userAgent,/AppleWebKit\/(\d+)\./,1)),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&`currentDirection`in e.RTCRtpTransceiver.prototype,t._safariVersion=ui(n.userAgent,/Version\/(\d+(\.?\d+))/,1);else return t.browser=`Not a supported browser.`,t;return t}function _i(e){return Object.prototype.toString.call(e)===`[object Object]`}function vi(e){return _i(e)?Object.keys(e).reduce(function(t,n){let r=_i(e[n]),i=r?vi(e[n]):e[n],a=r&&!Object.keys(i).length;return i===void 0||a?t:Object.assign(t,{[n]:i})},{}):e}function yi(e,t,n){!t||n.has(t.id)||(n.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith(`Id`)?yi(e,e.get(t[r]),n):r.endsWith(`Ids`)&&t[r].forEach(t=>{yi(e,e.get(t),n)})}))}function bi(e,t,n){let r=n?`outbound-rtp`:`inbound-rtp`,i=new Map;if(t===null)return i;let a=[];return e.forEach(e=>{e.type===`track`&&e.trackIdentifier===t.id&&a.push(e)}),a.forEach(t=>{e.forEach(n=>{n.type===r&&n.trackId===t.id&&yi(e,n,i)})}),i}var xi=mi;function Si(e,t){let n=e&&e.navigator;if(!n.mediaDevices)return;let r=function(e){if(typeof e!=`object`||e.mandatory||e.optional)return e;let t={};return Object.keys(e).forEach(n=>{if(n===`require`||n===`advanced`||n===`mediaSource`)return;let r=typeof e[n]==`object`?e[n]:{ideal:e[n]};r.exact!==void 0&&typeof r.exact==`number`&&(r.min=r.max=r.exact);let i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):t===`deviceId`?`sourceId`:t};if(r.ideal!==void 0){t.optional=t.optional||[];let e={};typeof r.ideal==`number`?(e[i(`min`,n)]=r.ideal,t.optional.push(e),e={},e[i(`max`,n)]=r.ideal,t.optional.push(e)):(e[i(``,n)]=r.ideal,t.optional.push(e))}r.exact!==void 0&&typeof r.exact!=`number`?(t.mandatory=t.mandatory||{},t.mandatory[i(``,n)]=r.exact):[`min`,`max`].forEach(e=>{r[e]!==void 0&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if(e=JSON.parse(JSON.stringify(e)),e&&typeof e.audio==`object`){let t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),t(e.audio,`autoGainControl`,`googAutoGainControl`),t(e.audio,`noiseSuppression`,`googNoiseSuppression`),e.audio=r(e.audio)}if(e&&typeof e.video==`object`){let a=e.video.facingMode;a&&=typeof a==`object`?a:{ideal:a};let o=t.version<66;if(a&&(a.exact===`user`||a.exact===`environment`||a.ideal===`user`||a.ideal===`environment`)&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!o)){delete e.video.facingMode;let t;if(a.exact===`environment`||a.ideal===`environment`?t=[`back`,`rear`]:(a.exact===`user`||a.ideal===`user`)&&(t=[`front`]),t)return n.mediaDevices.enumerateDevices().then(n=>{n=n.filter(e=>e.kind===`videoinput`);let o=n.find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!o&&n.length&&t.includes(`back`)&&(o=n[n.length-1]),o&&(e.video.deviceId=a.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=r(e.video),xi(`chrome: `+JSON.stringify(e)),i(e)})}e.video=r(e.video)}return xi(`chrome: `+JSON.stringify(e)),i(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:`NotAllowedError`,PermissionDismissedError:`NotAllowedError`,InvalidStateError:`NotAllowedError`,DevicesNotFoundError:`NotFoundError`,ConstraintNotSatisfiedError:`OverconstrainedError`,TrackStartError:`NotReadableError`,MediaDeviceFailedDueToShutdown:`NotAllowedError`,MediaDeviceKillSwitchOn:`NotAllowedError`,TabCaptureError:`AbortError`,ScreenCaptureError:`AbortError`,DeviceCaptureError:`AbortError`}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&`: `)+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,e=>{n.webkitGetUserMedia(e,t,e=>{r&&r(a(e))})})}.bind(n),n.mediaDevices.getUserMedia){let e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException(``,`NotFoundError`);return e},e=>Promise.reject(a(e))))}}}function Ci(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function wi(e,t){if(!(t.version>102))if(typeof e==`object`&&e.RTCPeerConnection&&!(`ontrack`in e.RTCPeerConnection.prototype)){Object.defineProperty(e.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});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener(`addtrack`,n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.track.id):{track:n.track};let i=new Event(`track`);i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}),t.stream.getTracks().forEach(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.id):{track:n};let i=new Event(`track`);i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})},this.addEventListener(`addstream`,this._ontrackpoly)),t.apply(this,arguments)}}else di(e,`track`,e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Ti(e){if(typeof e==`object`&&e.RTCPeerConnection&&!(`getSenders`in e.RTCPeerConnection.prototype)&&`createDTMFSender`in e.RTCPeerConnection.prototype){let t=function(e,t){return{track:t,get dtmf(){return this._dtmf===void 0&&(t.kind===`audio`?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};let n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};let r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);let t=this._senders.indexOf(e);t!==-1&&this._senders.splice(t,1)}}let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{let t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if(typeof e==`object`&&e.RTCPeerConnection&&`getSenders`in e.RTCPeerConnection.prototype&&`createDTMFSender`in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!(`dtmf`in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.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 Ei(e,t){if(t.version>=67||!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!(`getStats`in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){let e=this;return this._pc.getStats().then(t=>bi(t,e.track,!0))}}if(!(`getStats`in e.RTCRtpReceiver.prototype)){let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),di(e,`track`,e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){let e=this;return this._pc.getStats().then(t=>bi(t,e.track,!1))}}if(!(`getStats`in e.RTCRtpSender.prototype&&`getStats`in e.RTCRtpReceiver.prototype))return;let n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){let e=arguments[0],t,n,r;return this.getSenders().forEach(n=>{n.track===e&&(t?r=!0:t=n)}),this.getReceivers().forEach(t=>(t.track===e&&(n?r=!0:n=t),t.track===e)),r||t&&n?Promise.reject(new DOMException(`There are more than one sender or receiver for the track.`,`InvalidAccessError`)):t?t.getStats():n?n.getStats():Promise.reject(new DOMException(`There is no sender or receiver for the track.`,`InvalidAccessError`))}return n.apply(this,arguments)}}function Di(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};let r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?this._shimmedLocalStreams[n.id].indexOf(r)===-1&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException(`Track already exists.`,`InvalidAccessError`)});let t=this.getSenders();n.apply(this,arguments);let r=this.getSenders().filter(e=>t.indexOf(e)===-1);this._shimmedLocalStreams[e.id]=[e].concat(r)};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};let i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{let n=this._shimmedLocalStreams[t].indexOf(e);n!==-1&&this._shimmedLocalStreams[t].splice(n,1),this._shimmedLocalStreams[t].length===1&&delete this._shimmedLocalStreams[t]}),i.apply(this,arguments)}}function Oi(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Di(e);let n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){let e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};let r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException(`Track already exists.`,`InvalidAccessError`)}),!this._reverseStreams[t.id]){let n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};let i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if(this.signalingState===`closed`)throw new DOMException(`The RTCPeerConnection's signalingState is 'closed'.`,`InvalidStateError`);let r=[].slice.call(arguments,1);if(r.length!==1||!r[0].getTracks().find(e=>e===t))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(e=>e.track===t))throw new DOMException(`Track already exists.`,`InvalidAccessError`);this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};let i=this._streams[n.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event(`negotiationneeded`))});else{let r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find(e=>e.track===t)};function a(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{let r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,`g`),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{let r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,`g`),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}[`createOffer`,`createAnswer`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){let e=arguments;return arguments.length&&typeof arguments[0]==`function`?n.apply(this,[t=>{let n=a(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then(e=>a(this,e))}};e.RTCPeerConnection.prototype[t]=r[t]});let s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type||(arguments[0]=o(this,arguments[0])),s.apply(this,arguments)};let c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,`localDescription`);Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){let e=c.get.apply(this);return e.type===``?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if(this.signalingState===`closed`)throw new DOMException(`The RTCPeerConnection's signalingState is 'closed'.`,`InvalidStateError`);if(!e._pc)throw new DOMException(`Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.`,`TypeError`);if(e._pc!==this)throw new DOMException(`Sender was not created by this connection.`,`InvalidAccessError`);this._streams=this._streams||{};let t;Object.keys(this._streams).forEach(n=>{this._streams[n].getTracks().find(t=>e.track===t)&&(t=this._streams[n])}),t&&(t.getTracks().length===1?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event(`negotiationneeded`)))}}function ki(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&[`setLocalDescription`,`setRemoteDescription`,`addIceCandidate`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t===`addIceCandidate`?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]})}function Ai(e,t){t.version>102||di(e,`negotiationneeded`,e=>{let n=e.target;if(!((t.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics===`plan-b`)&&n.signalingState!==`stable`))return e})}var ji=Object.freeze({__proto__:null,fixNegotiationNeeded:Ai,shimAddTrackRemoveTrack:Oi,shimAddTrackRemoveTrackWithNative:Di,shimGetSendersWithDtmf:Ti,shimGetUserMedia:Si,shimMediaStream:Ci,shimOnTrack:wi,shimPeerConnection:ki,shimSenderReceiverGetStats:Ei});function Mi(e,t){let n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){hi(`navigator.getUserMedia`,`navigator.mediaDevices.getUserMedia`),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&`autoGainControl`in n.mediaDevices.getSupportedConstraints())){let e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return typeof n==`object`&&typeof n.audio==`object`&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,`autoGainControl`,`mozAutoGainControl`),e(n.audio,`noiseSuppression`,`mozNoiseSuppression`)),t(n)},r&&r.prototype.getSettings){let t=r.prototype.getSettings;r.prototype.getSettings=function(){let n=t.apply(this,arguments);return e(n,`mozAutoGainControl`,`autoGainControl`),e(n,`mozNoiseSuppression`,`noiseSuppression`),n}}if(r&&r.prototype.applyConstraints){let t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return this.kind===`audio`&&typeof n==`object`&&(n=JSON.parse(JSON.stringify(n)),e(n,`autoGainControl`,`mozAutoGainControl`),e(n,`noiseSuppression`,`mozNoiseSuppression`)),t.apply(this,[n])}}}}function Ni(e,t){e.navigator.mediaDevices&&`getDisplayMedia`in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){let e=new DOMException(`getDisplayMedia without video constraints is undefined`);return e.name=`NotFoundError`,e.code=8,Promise.reject(e)}return n.video===!0?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}function Pi(e){typeof e==`object`&&e.RTCTrackEvent&&`receiver`in e.RTCTrackEvent.prototype&&!(`transceiver`in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Fi(e,t){typeof e!=`object`||!(e.RTCPeerConnection||e.mozRTCPeerConnection)||(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&[`setLocalDescription`,`setRemoteDescription`,`addIceCandidate`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t===`addIceCandidate`?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function Ii(e,t){if(typeof e!=`object`||!(e.RTCPeerConnection||e.mozRTCPeerConnection)||t.version>=151)return;let n={inboundrtp:`inbound-rtp`,outboundrtp:`outbound-rtp`,candidatepair:`candidate-pair`,localcandidate:`local-candidate`,remotecandidate:`remote-candidate`},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[e,i,a]=arguments;return this.signalingState===`closed`?Promise.resolve(new Map):r.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=n[e.type]||e.type})}catch(t){if(t.name!==`TypeError`)throw t;e.forEach((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(i,a)}}function Li(e){if(!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&`getStats`in e.RTCRtpSender.prototype)return;let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Ri(e){if(!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&`getStats`in e.RTCRtpReceiver.prototype)return;let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),di(e,`track`,e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function zi(e){!e.RTCPeerConnection||`removeStream`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){hi(`removeStream`,`removeTrack`),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Bi(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Vi(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;e===void 0&&(e=[]),e=[...e];let n=e.length>0;n&&e.forEach(e=>{if(`rid`in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw TypeError(`Invalid RID value provided.`);if(`scaleResolutionDownBy`in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw RangeError(`scale_resolution_down_by must be >= 1.0`);if(`maxFramerate`in e&&!(parseFloat(e.maxFramerate)>=0))throw RangeError(`max_framerate must be >= 0.0`)});let r=t.apply(this,arguments);if(n){let{sender:t}=r,n=t.getParameters();(!(`encodings`in n)||n.encodings.length===1&&Object.keys(n.encodings[0]).length===0)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return r})}function Hi(e){if(!(typeof e==`object`&&e.RTCRtpSender))return;let t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){let e=t.apply(this,arguments);return`encodings`in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ui(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.createOffer;e.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 Wi(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.createAnswer;e.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)}}var Gi=Object.freeze({__proto__:null,shimAddTransceiver:Vi,shimCreateAnswer:Wi,shimCreateOffer:Ui,shimGetDisplayMedia:Ni,shimGetParameters:Hi,shimGetStats:Ii,shimGetUserMedia:Mi,shimOnTrack:Pi,shimPeerConnection:Fi,shimRTCDataChannel:Bi,shimReceiverGetStats:Ri,shimRemoveStream:zi,shimSenderGetStats:Li});function Ki(e){if(!(typeof e!=`object`||!e.RTCPeerConnection)){if(`getLocalStreams`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||=[],this._localStreams}),!(`addStream`in e.RTCPeerConnection.prototype)){let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||=[],this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(n=>t.call(this,n,e)),e.getVideoTracks().forEach(n=>t.call(this,n,e))},e.RTCPeerConnection.prototype.addTrack=function(e){var n=[...arguments].slice(1);return n&&n.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}`removeStream`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||=[];let t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);let n=e.getTracks();this.getSenders().forEach(e=>{n.includes(e.track)&&this.removeTrack(e)})})}}function qi(e){if(!(typeof e!=`object`||!e.RTCPeerConnection)&&(`getRemoteStreams`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!(`onaddstream`in e.RTCPeerConnection.prototype))){Object.defineProperty(e.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=e=>{e.streams.forEach(e=>{if(this._remoteStreams||=[],this._remoteStreams.includes(e))return;this._remoteStreams.push(e);let t=new Event(`addstream`);t.stream=e,this.dispatchEvent(t)})})}});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){let e=this;return this._onaddstreampoly||this.addEventListener(`track`,this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||=[],e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);let n=new Event(`addstream`);n.stream=t,e.dispatchEvent(n)})}),t.apply(e,arguments)}}}function Ji(e){if(typeof e!=`object`||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){let r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){let n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){let r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){let r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){let r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function Yi(e){let t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){let e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(Xi(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function Xi(e){return e&&e.video!==void 0?Object.assign({},e,{video:vi(e.video)}):e}function Zi(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){let t=[];for(let n=0;ne.receiver.track.kind===`audio`);e.offerToReceiveAudio===!1&&t?t.direction===`sendrecv`?t.setDirection?t.setDirection(`sendonly`):t.direction=`sendonly`:t.direction===`recvonly`&&(t.setDirection?t.setDirection(`inactive`):t.direction=`inactive`):e.offerToReceiveAudio===!0&&!t&&this.addTransceiver(`audio`,{direction:`recvonly`}),e.offerToReceiveVideo!==void 0&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);let n=this.getTransceivers().find(e=>e.receiver.track.kind===`video`);e.offerToReceiveVideo===!1&&n?n.direction===`sendrecv`?n.setDirection?n.setDirection(`sendonly`):n.direction=`sendonly`:n.direction===`recvonly`&&(n.setDirection?n.setDirection(`inactive`):n.direction=`inactive`):e.offerToReceiveVideo===!0&&!n&&this.addTransceiver(`video`,{direction:`recvonly`})}return t.apply(this,arguments)}}function ea(e){typeof e!=`object`||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ta=Object.freeze({__proto__:null,shimAudioContext:ea,shimCallbacksAPI:Ji,shimConstraints:Xi,shimCreateOfferLegacy:$i,shimGetUserMedia:Yi,shimLocalStreamsAPI:Ki,shimRTCIceServerUrls:Zi,shimRemoteStreamsAPI:qi,shimTrackEventTransceiver:Qi}),na={exports:{}},ra;function ia(){return ra?na.exports:(ra=1,(function(e){let t={};t.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(` +`).map(e=>e.trim())},t.splitSections=function(e){return e.split(` +m=`).map((e,t)=>(t>0?`m=`+e:e).trim()+`\r +`)},t.getDescription=function(e){let n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){let n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter(e=>e.indexOf(n)===0)},t.parseCandidate=function(e){let t;t=e.indexOf(`a=candidate:`)===0?e.substring(12).split(` `):e.substring(10).split(` `);let n={foundation:t[0],component:{1:`rtp`,2:`rtcp`}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e0?t[0].split(`/`)[1]:`sendrecv`,uri:t[1],attributes:t.slice(2).join(` `)}},t.writeExtmap=function(e){return`a=extmap:`+(e.id||e.preferredId)+(e.direction&&e.direction!==`sendrecv`?`/`+e.direction:``)+` `+e.uri+(e.attributes?` `+e.attributes:``)+`\r +`},t.parseFmtp=function(e){let t={},n,r=e.substring(e.indexOf(` `)+1).split(`;`);for(let e=0;e{e.parameters[t]===void 0?r.push(t):r.push(t+`=`+e.parameters[t])}),t+=`a=fmtp:`+n+` `+r.join(`;`)+`\r +`}return t},t.parseRtcpFb=function(e){let t=e.substring(e.indexOf(` `)+1).split(` `);return{type:t.shift(),parameter:t.join(` `)}},t.writeRtcpFb=function(e){let t=``,n=e.payloadType;return e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(e=>{t+=`a=rtcp-fb:`+n+` `+e.type+(e.parameter&&e.parameter.length?` `+e.parameter:``)+`\r +`}),t},t.parseSsrcMedia=function(e){let t=e.indexOf(` `),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(`:`,t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){let t=e.substring(13).split(` `);return{semantics:t.shift(),ssrcs:t.map(e=>parseInt(e,10))}},t.getMid=function(e){let n=t.matchPrefix(e,`a=mid:`)[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){let t=e.substring(14).split(` `);return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:`auto`,fingerprints:t.matchPrefix(e+n,`a=fingerprint:`).map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n=`a=setup:`+t+`\r +`;return e.fingerprints.forEach(e=>{n+=`a=fingerprint:`+e.algorithm+` `+e.value+`\r +`}),n},t.parseCryptoLine=function(e){let t=e.substring(9).split(` `);return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.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 +`},t.parseCryptoKeyParams=function(e){if(e.indexOf(`inline:`)!==0)return null;let t=e.substring(7).split(`|`);return{keyMethod:`inline`,keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(`:`)[0]:void 0,mkiLength:t[2]?t[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,n){return t.matchPrefix(e+n,`a=crypto:`).map(t.parseCryptoLine)},t.getIceParameters=function(e,n){let r=t.matchPrefix(e+n,`a=ice-ufrag:`)[0],i=t.matchPrefix(e+n,`a=ice-pwd:`)[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t=`a=ice-ufrag:`+e.usernameFragment+`\r +a=ice-pwd:`+e.password+`\r +`;return e.iceLite&&(t+=`a=ice-lite\r +`),t},t.parseRtpParameters=function(e){let n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(` `);n.profile=r[2];for(let i=3;i{n.headerExtensions.push(t.parseExtmap(e))});let i=t.matchPrefix(e,`a=rtcp-fb:* `).map(t.parseRtcpFb);return n.codecs.forEach(e=>{i.forEach(t=>{e.rtcpFeedback.find(e=>e.type===t.type&&e.parameter===t.parameter)||e.rtcpFeedback.push(t)})}),n},t.writeRtpDescription=function(e,n){let r=``;r+=`m=`+e+` `,r+=n.codecs.length>0?`9`:`0`,r+=` `+(n.profile||`UDP/TLS/RTP/SAVPF`)+` `,r+=n.codecs.map(e=>e.preferredPayloadType===void 0?e.payloadType:e.preferredPayloadType).join(` `)+`\r +`,r+=`c=IN IP4 0.0.0.0\r +`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r +`,n.codecs.forEach(e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)});let i=0;return n.codecs.forEach(e=>{e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+=`a=maxptime:`+i+`\r +`),n.headerExtensions&&n.headerExtensions.forEach(e=>{r+=t.writeExtmap(e)}),r},t.parseRtpEncodingParameters=function(e){let n=[],r=t.parseRtpParameters(e),i=r.fecMechanisms.indexOf(`RED`)!==-1,a=r.fecMechanisms.indexOf(`ULPFEC`)!==-1,o=t.matchPrefix(e,`a=ssrc:`).map(e=>t.parseSsrcMedia(e)).filter(e=>e.attribute===`cname`),s=o.length>0&&o[0].ssrc,c,l=t.matchPrefix(e,`a=ssrc-group:FID`).map(e=>e.substring(17).split(` `).map(e=>parseInt(e,10)));l.length>0&&l[0].length>1&&l[0][0]===s&&(c=l[0][1]),r.codecs.forEach(e=>{if(e.name.toUpperCase()===`RTX`&&e.parameters.apt){let t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&c&&(t.rtx={ssrc:c}),n.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:s,mechanism:a?`red+ulpfec`:`red`},n.push(t))}}),n.length===0&&s&&n.push({ssrc:s});let u=t.matchPrefix(e,`b=`);return u.length&&(u=u[0].indexOf(`b=TIAS:`)===0?parseInt(u[0].substring(7),10):u[0].indexOf(`b=AS:`)===0?parseInt(u[0].substring(5),10)*1e3*.95-2e3*8:void 0,n.forEach(e=>{e.maxBitrate=u})),n},t.parseRtcpParameters=function(e){let n={},r=t.matchPrefix(e,`a=ssrc:`).map(e=>t.parseSsrcMedia(e)).filter(e=>e.attribute===`cname`)[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);let i=t.matchPrefix(e,`a=rtcp-rsize`);return n.reducedSize=i.length>0,n.compound=i.length===0,n.mux=t.matchPrefix(e,`a=rtcp-mux`).length>0,n},t.writeRtcpParameters=function(e){let t=``;return e.reducedSize&&(t+=`a=rtcp-rsize\r +`),e.mux&&(t+=`a=rtcp-mux\r +`),e.ssrc!==void 0&&e.cname&&(t+=`a=ssrc:`+e.ssrc+` cname:`+e.cname+`\r +`),t},t.parseMsid=function(e){let n,r=t.matchPrefix(e,`a=msid:`);if(r.length===1)return n=r[0].substring(7).split(` `),{stream:n[0],track:n[1]};let i=t.matchPrefix(e,`a=ssrc:`).map(e=>t.parseSsrcMedia(e)).filter(e=>e.attribute===`msid`);if(i.length>0)return n=i[0].value.split(` `),{stream:n[0],track:n[1]}},t.parseSctpDescription=function(e){let n=t.parseMLine(e),r=t.matchPrefix(e,`a=max-message-size:`),i;r.length>0&&(i=parseInt(r[0].substring(19),10)),isNaN(i)&&(i=65536);let a=t.matchPrefix(e,`a=sctp-port:`);if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:n.fmt,maxMessageSize:i};let o=t.matchPrefix(e,`a=sctpmap:`);if(o.length>0){let e=o[0].substring(10).split(` `);return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let n=[];return n=e.protocol===`DTLS/SCTP`?[`m=`+e.kind+` 9 `+e.protocol+` `+t.port+`\r +`,`c=IN IP4 0.0.0.0\r +`,`a=sctpmap:`+t.port+` `+t.protocol+` 65535\r +`]:[`m=`+e.kind+` 9 `+e.protocol+` `+t.protocol+`\r +`,`c=IN IP4 0.0.0.0\r +`,`a=sctp-port:`+t.port+`\r +`],t.maxMessageSize!==void 0&&n.push(`a=max-message-size:`+t.maxMessageSize+`\r +`),n.join(``)},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){let i,a=n===void 0?2:n;return i=e||t.generateSessionId(),`v=0\r +o=`+(r||`thisisadapterortc`)+` `+i+` `+a+` IN IP4 127.0.0.1\r +s=-\r +t=0 0\r +`},t.getDirection=function(e,n){let r=t.splitLines(e);for(let e=0;e(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:`false`}),t))}function la(e){!e.RTCIceCandidate||e.RTCIceCandidate&&`relayProtocol`in e.RTCIceCandidate.prototype||di(e,`icecandidate`,e=>{if(e.candidate){let t=oa.parseCandidate(e.candidate.candidate);t.type===`relay`&&(e.candidate.relayProtocol={0:`tls`,1:`tcp`,2:`udp`}[t.priority>>24])}return e})}function ua(e,t){if(!e.RTCPeerConnection)return;`sctp`in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});let n=function(e){if(!e||!e.sdp)return!1;let t=oa.splitSections(e.sdp);return t.shift(),t.some(e=>{let t=oa.parseMLine(e);return t&&t.kind===`application`&&t.protocol.indexOf(`SCTP`)!==-1})},r=function(e){let t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(t===null||t.length<2)return-1;let n=parseInt(t[1],10);return n===n?n:-1},i=function(e){let n=65536;return t.browser===`firefox`&&(n=t.version<57?e===-1?16384:2147483637:t.version<60?t.version===57?65535:65536:2147483637),n},a=function(e,n){let r=65536;t.browser===`firefox`&&t.version===57&&(r=65535);let i=oa.matchPrefix(e.sdp,`a=max-message-size:`);return i.length>0?r=parseInt(i[0].substring(19),10):t.browser===`firefox`&&n!==-1&&(r=2147483637),r},o=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser===`chrome`&&t.version>=76){let{sdpSemantics:e}=this.getConfiguration();e===`plan-b`&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){let e=r(arguments[0]),t=i(e),n=a(arguments[0],e),o;o=t===0&&n===0?1/0:t===0||n===0?Math.max(t,n):Math.min(t,n);let s={};Object.defineProperty(s,"maxMessageSize",{get(){return o}}),this._sctp=s}return o.apply(this,arguments)}}function da(e,t){if(!(e.RTCPeerConnection&&`createDataChannel`in e.RTCPeerConnection.prototype)||t.browser===`chrome`&&t.version>149||t.browser===`firefox`&&t.version>60)return;function n(e,t){let n=e.send;e.send=function(){let r=arguments[0],i=r.length||r.size||r.byteLength;if(e.readyState===`open`&&t.sctp&&i>t.sctp.maxMessageSize)throw TypeError(`Message too large (can send a maximum of `+t.sctp.maxMessageSize+` bytes)`);return n.apply(e,arguments)}}let r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){let e=r.apply(this,arguments);return n(e,this),e},di(e,`datachannel`,e=>(n(e.channel,e.target),e))}function fa(e){if(!e.RTCPeerConnection||`connectionState`in e.RTCPeerConnection.prototype)return;let t=e.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=>{let n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{let t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;let n=new Event(`connectionstatechange`,e);t.dispatchEvent(n)}return e},this.addEventListener(`iceconnectionstatechange`,this._connectionstatechangepoly)),n.apply(this,arguments)}})}function pa(e,t){if(!e.RTCPeerConnection||t.browser===`chrome`&&t.version>=71||t.browser===`safari`&&t._safariVersion>=13.1)return;let n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&t.sdp.indexOf(` +a=extmap-allow-mixed`)!==-1){let n=t.sdp.split(` +`).filter(e=>e.trim()!==`a=extmap-allow-mixed`).join(` +`);e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function ma(e,t){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;let n=e.RTCPeerConnection.prototype.addIceCandidate;!n||n.length===0||(e.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():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function ha(e,t){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;let n=e.RTCPeerConnection.prototype.setLocalDescription;!n||n.length===0||(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if(typeof e!=`object`||e.type&&e.sdp)return n.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case`stable`:case`have-local-offer`:case`have-remote-pranswer`:e.type=`offer`;break;default:e.type=`answer`;break}return e.sdp||e.type!==`offer`&&e.type!==`answer`?n.apply(this,[e]):(e.type===`offer`?this.createOffer:this.createAnswer).apply(this).then(e=>n.apply(this,[e]))})}var ga=Object.freeze({__proto__:null,removeExtmapAllowMixed:pa,shimAddIceCandidateNullOrEmpty:ma,shimConnectionState:fa,shimMaxMessageSize:ua,shimParameterlessSetLocalDescription:ha,shimRTCIceCandidate:ca,shimRTCIceCandidateRelayProtocol:la,shimSendThrowTypeError:da});function _a(){let{window:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=mi,r=gi(e),i={browserDetails:r,commonShim:ga,extractVersion:ui,disableLog:fi,disableWarnings:pi,sdp:sa};switch(r.browser){case`chrome`:if(!ji||!ki||!t.shimChrome)return n(`Chrome shim is not included in this adapter release.`),i;if(r.version===null)return n(`Chrome shim can not determine version, not shimming.`),i;n(`adapter.js shimming chrome.`),i.browserShim=ji,ma(e,r),ha(e),Si(e,r),Ci(e),ki(e,r),wi(e,r),Oi(e,r),Ti(e),Ei(e,r),Ai(e,r),ca(e),la(e),fa(e),ua(e,r),da(e,r),pa(e,r);break;case`firefox`:if(!Gi||!Fi||!t.shimFirefox)return n(`Firefox shim is not included in this adapter release.`),i;n(`adapter.js shimming firefox.`),i.browserShim=Gi,ma(e,r),ha(e),Mi(e,r),Fi(e,r),Ii(e,r),Pi(e),zi(e),Li(e),Ri(e),Bi(e),Vi(e),Hi(e),Ui(e),Wi(e),ca(e),fa(e),ua(e,r),da(e,r);break;case`safari`:if(!ta||!t.shimSafari)return n(`Safari shim is not included in this adapter release.`),i;n(`adapter.js shimming safari.`),i.browserShim=ta,ma(e,r),ha(e),Zi(e),$i(e),Ji(e),Ki(e),qi(e),Qi(e),Yi(e),ea(e),ca(e),la(e),ua(e,r),da(e,r),pa(e,r);break;default:n(`Unsupported browser!`);break}return i}_a({window:typeof window>`u`?void 0:window});var va,ya,ba=class extends (ya=Promise){constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}};va=ba,ba.resolve=e=>Reflect.get(ya,`resolve`,va).call(va,e);var xa=/version\/(\d+(\.?_?\d+)+)/i,Sa;function Ca(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e===void 0&&typeof navigator>`u`)return;let n=(e??navigator.userAgent).toLowerCase();return(Sa===void 0||t)&&(Sa=wa.find(e=>{let{test:t}=e;return t.test(n)})?.describe(n)),Sa}var wa=[{test:/firefox|iceweasel|fxios/i,describe(e){return{name:`Firefox`,version:Ta(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes(`fxios`)?`iOS`:void 0,osVersion:Ea(e)}}},{test:/chrom|crios|crmo/i,describe(e){return{name:`Chrome`,version:Ta(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes(`crios`)?`iOS`:void 0,osVersion:Ea(e)}}},{test:/safari|applewebkit/i,describe(e){return{name:`Safari`,version:Ta(xa,e),os:e.includes(`mobile/`)?`iOS`:`macOS`,osVersion:Ea(e)}}}];function Ta(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t.match(e);return r&&r.length>=n&&r[n]||``}function Ea(e){return e.includes(`mac os`)?Ta(/\(.+?(\d+_\d+(:?_\d+)?)/,e,1).replace(/_/g,`.`):void 0}var Da=`2.19.1`,Oa=class extends Error{constructor(e,t,n){super(t||`an error has occurred`),this.name=`LiveKitError`,this.code=e,n?.cause!==void 0&&(this.cause=n?.cause)}},ka=class extends Oa{},Aa;(function(e){e[e.NotAllowed=0]=`NotAllowed`,e[e.ServerUnreachable=1]=`ServerUnreachable`,e[e.InternalError=2]=`InternalError`,e[e.Cancelled=3]=`Cancelled`,e[e.LeaveRequest=4]=`LeaveRequest`,e[e.Timeout=5]=`Timeout`,e[e.WebSocket=6]=`WebSocket`,e[e.ServiceNotFound=7]=`ServiceNotFound`})(Aa||={});var R=class e extends ka{constructor(e,t,n,r){super(1,e),this.name=`ConnectionError`,this.status=n,this.reason=t,this.context=r,this.reasonName=Aa[t]}static notAllowed(t,n,r){return new e(t,Aa.NotAllowed,n,r)}static timeout(t){return new e(t,Aa.Timeout)}static leaveRequest(t,n){return new e(t,Aa.LeaveRequest,void 0,n)}static internal(t,n){return new e(t,Aa.InternalError,void 0,n)}static cancelled(t){return new e(t,Aa.Cancelled)}static serverUnreachable(t,n){return new e(t,Aa.ServerUnreachable,n)}static websocket(t,n,r){return new e(t,Aa.WebSocket,n,r)}static serviceNotFound(t,n){return new e(t,Aa.ServiceNotFound,void 0,n)}},ja=class extends Oa{constructor(e){super(21,e??`device is unsupported`),this.name=`DeviceUnsupportedError`}},Ma=class extends Oa{constructor(e){super(20,e??`track is invalid`),this.name=`TrackInvalidError`}},Na=class extends Oa{constructor(e){super(10,e??`unsupported server`),this.name=`UnsupportedServer`}},Pa=class extends Oa{constructor(e){super(12,e??`unexpected connection state`),this.name=`UnexpectedConnectionState`}},Fa=class extends Oa{constructor(e){super(13,e??`unable to negotiate`),this.name=`NegotiationError`}},Ia=class extends Oa{constructor(e,t){super(15,e),this.name=`PublishTrackError`,this.status=t}},La=class extends ka{constructor(e,t){super(15,e),this.name=`SignalRequestError`,this.reason=t,this.reasonName=typeof t==`string`?t:Ar[t]}},Ra;(function(e){e[e.AlreadyOpened=0]=`AlreadyOpened`,e[e.AbnormalEnd=1]=`AbnormalEnd`,e[e.DecodeFailed=2]=`DecodeFailed`,e[e.LengthExceeded=3]=`LengthExceeded`,e[e.Incomplete=4]=`Incomplete`,e[e.HandlerAlreadyRegistered=7]=`HandlerAlreadyRegistered`,e[e.EncryptionTypeMismatch=8]=`EncryptionTypeMismatch`})(Ra||={});var za=class extends ka{constructor(e,t){super(16,e),this.name=`DataStreamError`,this.reason=t,this.reasonName=Ra[t]}},Ba=class extends Oa{constructor(e){super(18,e),this.name=`SignalReconnectError`}},Va;(function(e){e.PermissionDenied=`PermissionDenied`,e.NotFound=`NotFound`,e.DeviceInUse=`DeviceInUse`,e.Other=`Other`})(Va||={}),(function(e){function t(t){if(t&&`name`in t)return t.name===`NotFoundError`||t.name===`DevicesNotFoundError`?e.NotFound:t.name===`NotAllowedError`||t.name===`PermissionDeniedError`?e.PermissionDenied:t.name===`NotReadableError`||t.name===`TrackStartError`?e.DeviceInUse:e.Other}e.getFailure=t})(Va||={});var Ha=class{};Ha.setTimeout=function(){return setTimeout(...arguments)},Ha.setInterval=function(){return setInterval(...arguments)},Ha.clearTimeout=function(){return clearTimeout(...arguments)},Ha.clearInterval=function(){return clearInterval(...arguments)};var z;(function(e){e.Connected=`connected`,e.Reconnecting=`reconnecting`,e.SignalReconnecting=`signalReconnecting`,e.Reconnected=`reconnected`,e.Disconnected=`disconnected`,e.ConnectionStateChanged=`connectionStateChanged`,e.Moved=`moved`,e.MediaDevicesChanged=`mediaDevicesChanged`,e.ParticipantConnected=`participantConnected`,e.ParticipantDisconnected=`participantDisconnected`,e.TrackPublished=`trackPublished`,e.TrackSubscribed=`trackSubscribed`,e.TrackSubscriptionFailed=`trackSubscriptionFailed`,e.TrackUnpublished=`trackUnpublished`,e.TrackUnsubscribed=`trackUnsubscribed`,e.TrackMuted=`trackMuted`,e.TrackUnmuted=`trackUnmuted`,e.LocalTrackPublished=`localTrackPublished`,e.LocalTrackUnpublished=`localTrackUnpublished`,e.LocalAudioSilenceDetected=`localAudioSilenceDetected`,e.ActiveSpeakersChanged=`activeSpeakersChanged`,e.ParticipantMetadataChanged=`participantMetadataChanged`,e.ParticipantNameChanged=`participantNameChanged`,e.ParticipantAttributesChanged=`participantAttributesChanged`,e.ParticipantActive=`participantActive`,e.RoomMetadataChanged=`roomMetadataChanged`,e.DataReceived=`dataReceived`,e.SipDTMFReceived=`sipDTMFReceived`,e.TranscriptionReceived=`transcriptionReceived`,e.ConnectionQualityChanged=`connectionQualityChanged`,e.TrackStreamStateChanged=`trackStreamStateChanged`,e.TrackSubscriptionPermissionChanged=`trackSubscriptionPermissionChanged`,e.TrackSubscriptionStatusChanged=`trackSubscriptionStatusChanged`,e.AudioPlaybackStatusChanged=`audioPlaybackChanged`,e.VideoPlaybackStatusChanged=`videoPlaybackChanged`,e.MediaDevicesError=`mediaDevicesError`,e.ParticipantPermissionsChanged=`participantPermissionsChanged`,e.SignalConnected=`signalConnected`,e.RecordingStatusChanged=`recordingStatusChanged`,e.ParticipantEncryptionStatusChanged=`participantEncryptionStatusChanged`,e.EncryptionError=`encryptionError`,e.DCBufferStatusChanged=`dcBufferStatusChanged`,e.ActiveDeviceChanged=`activeDeviceChanged`,e.ChatMessage=`chatMessage`,e.LocalTrackSubscribed=`localTrackSubscribed`,e.MetricsReceived=`metricsReceived`,e.DataTrackPublished=`dataTrackPublished`,e.DataTrackUnpublished=`dataTrackUnpublished`,e.LocalDataTrackPublished=`localDataTrackPublished`,e.LocalDataTrackUnpublished=`localDataTrackUnpublished`})(z||={});var B;(function(e){e.TrackPublished=`trackPublished`,e.TrackSubscribed=`trackSubscribed`,e.TrackSubscriptionFailed=`trackSubscriptionFailed`,e.TrackUnpublished=`trackUnpublished`,e.TrackUnsubscribed=`trackUnsubscribed`,e.TrackMuted=`trackMuted`,e.TrackUnmuted=`trackUnmuted`,e.LocalTrackPublished=`localTrackPublished`,e.LocalTrackUnpublished=`localTrackUnpublished`,e.LocalTrackCpuConstrained=`localTrackCpuConstrained`,e.LocalSenderCreated=`localSenderCreated`,e.ParticipantMetadataChanged=`participantMetadataChanged`,e.ParticipantNameChanged=`participantNameChanged`,e.DataReceived=`dataReceived`,e.SipDTMFReceived=`sipDTMFReceived`,e.TranscriptionReceived=`transcriptionReceived`,e.IsSpeakingChanged=`isSpeakingChanged`,e.ConnectionQualityChanged=`connectionQualityChanged`,e.TrackStreamStateChanged=`trackStreamStateChanged`,e.TrackSubscriptionPermissionChanged=`trackSubscriptionPermissionChanged`,e.TrackSubscriptionStatusChanged=`trackSubscriptionStatusChanged`,e.TrackCpuConstrained=`trackCpuConstrained`,e.MediaDevicesError=`mediaDevicesError`,e.AudioStreamAcquired=`audioStreamAcquired`,e.ParticipantPermissionsChanged=`participantPermissionsChanged`,e.PCTrackAdded=`pcTrackAdded`,e.AttributesChanged=`attributesChanged`,e.LocalTrackSubscribed=`localTrackSubscribed`,e.ChatMessage=`chatMessage`,e.Active=`active`})(B||={});var V;(function(e){e.TransportsCreated=`transportsCreated`,e.Connected=`connected`,e.Disconnected=`disconnected`,e.Resuming=`resuming`,e.Resumed=`resumed`,e.Restarting=`restarting`,e.Restarted=`restarted`,e.SignalResumed=`signalResumed`,e.SignalRestarted=`signalRestarted`,e.Closing=`closing`,e.MediaTrackAdded=`mediaTrackAdded`,e.ActiveSpeakersUpdate=`activeSpeakersUpdate`,e.DataPacketReceived=`dataPacketReceived`,e.RTPVideoMapUpdate=`rtpVideoMapUpdate`,e.DCBufferStatusChanged=`dcBufferStatusChanged`,e.ParticipantUpdate=`participantUpdate`,e.RoomUpdate=`roomUpdate`,e.SpeakersChanged=`speakersChanged`,e.StreamStateChanged=`streamStateChanged`,e.ConnectionQualityUpdate=`connectionQualityUpdate`,e.SubscriptionError=`subscriptionError`,e.SubscriptionPermissionUpdate=`subscriptionPermissionUpdate`,e.RemoteMute=`remoteMute`,e.SubscribedQualityUpdate=`subscribedQualityUpdate`,e.LocalTrackUnpublished=`localTrackUnpublished`,e.LocalTrackSubscribed=`localTrackSubscribed`,e.Offline=`offline`,e.SignalRequestResponse=`signalRequestResponse`,e.SignalConnected=`signalConnected`,e.RoomMoved=`roomMoved`,e.PublishDataTrackResponse=`publishDataTrackResponse`,e.UnPublishDataTrackResponse=`unPublishDataTrackResponse`,e.DataTrackSubscriberHandles=`dataTrackSubscriberHandles`,e.DataTrackPacketReceived=`dataTrackPacketReceived`,e.Joined=`joined`,e.TokenRefreshed=`tokenRefreshed`,e.ServerRegionsReported=`serverRegionsReported`})(V||={});var H;(function(e){e.Message=`message`,e.Muted=`muted`,e.Unmuted=`unmuted`,e.Restarted=`restarted`,e.Ended=`ended`,e.Subscribed=`subscribed`,e.Unsubscribed=`unsubscribed`,e.CpuConstrained=`cpuConstrained`,e.UpdateSettings=`updateSettings`,e.UpdateSubscription=`updateSubscription`,e.AudioPlaybackStarted=`audioPlaybackStarted`,e.AudioPlaybackFailed=`audioPlaybackFailed`,e.AudioSilenceDetected=`audioSilenceDetected`,e.VisibilityChanged=`visibilityChanged`,e.VideoDimensionsChanged=`videoDimensionsChanged`,e.VideoPlaybackStarted=`videoPlaybackStarted`,e.VideoPlaybackFailed=`videoPlaybackFailed`,e.ElementAttached=`elementAttached`,e.ElementDetached=`elementDetached`,e.UpstreamPaused=`upstreamPaused`,e.UpstreamResumed=`upstreamResumed`,e.SubscriptionPermissionChanged=`subscriptionPermissionChanged`,e.SubscriptionStatusChanged=`subscriptionStatusChanged`,e.SubscriptionFailed=`subscriptionFailed`,e.TrackProcessorUpdate=`trackProcessorUpdate`,e.AudioTrackFeatureUpdate=`audioTrackFeatureUpdate`,e.TranscriptionReceived=`transcriptionReceived`,e.TimeSyncUpdate=`timeSyncUpdate`,e.PreConnectBufferFlushed=`preConnectBufferFlushed`})(H||={});function Ua(e){return e===void 0?e:typeof structuredClone==`function`?typeof e==`object`&&e?structuredClone(Object.assign({},e)):structuredClone(e):JSON.parse(JSON.stringify(e))}var Wa=class{constructor(e,t,n,r,i){if(typeof e==`object`)this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else if(t!==void 0&&n!==void 0)this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:n,maxFramerate:r,priority:i};else throw TypeError(`Unsupported options: provide at least width, height and maxBitrate`)}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}},Ga=[`vp8`,`h264`],Ka=[`vp8`,`h264`,`vp9`,`av1`,`h265`];function qa(e){return!!Ga.find(t=>t===e)}var Ja=qa,Ya;(function(e){e[e.PREFER_REGRESSION=0]=`PREFER_REGRESSION`,e[e.SIMULCAST=1]=`SIMULCAST`,e[e.REGRESSION=2]=`REGRESSION`})(Ya||={});var Xa;(function(e){e.telephone={maxBitrate:12e3},e.speech={maxBitrate:24e3},e.music={maxBitrate:48e3},e.musicStereo={maxBitrate:64e3},e.musicHighQuality={maxBitrate:96e3},e.musicHighQualityStereo={maxBitrate:128e3}})(Xa||={});var Za={h90:new Wa(160,90,9e4,20),h180:new Wa(320,180,16e4,20),h216:new Wa(384,216,18e4,20),h360:new Wa(640,360,45e4,20),h540:new Wa(960,540,8e5,25),h720:new Wa(1280,720,17e5,30),h1080:new Wa(1920,1080,3e6,30),h1440:new Wa(2560,1440,5e6,30),h2160:new Wa(3840,2160,8e6,30)},Qa={h120:new Wa(160,120,7e4,20),h180:new Wa(240,180,125e3,20),h240:new Wa(320,240,14e4,20),h360:new Wa(480,360,33e4,20),h480:new Wa(640,480,5e5,20),h540:new Wa(720,540,6e5,25),h720:new Wa(960,720,13e5,30),h1080:new Wa(1440,1080,23e5,30),h1440:new Wa(1920,1440,38e5,30)},$a={h360fps3:new Wa(640,360,2e5,3,`medium`),h360fps15:new Wa(640,360,4e5,15,`medium`),h720fps5:new Wa(1280,720,8e5,5,`medium`),h720fps15:new Wa(1280,720,15e5,15,`medium`),h720fps30:new Wa(1280,720,2e6,30,`medium`),h1080fps15:new Wa(1920,1080,25e5,15,`medium`),h1080fps30:new Wa(1920,1080,5e6,30,`medium`),original:new Wa(0,0,7e6,30,`medium`)};function eo(e,t,n){var r,i;let{optionsWithoutProcessor:a,audioProcessor:o,videoProcessor:s}=mo(e??{}),c=t?.processor,l=n?.processor,u=a??{};return u.audio===!0&&(u.audio={}),u.video===!0&&(u.video={}),u.audio&&(to(u.audio,t),(r=u.audio).deviceId??(r.deviceId={ideal:`default`}),(o||c)&&(u.audio.processor=o??c)),u.video&&(to(u.video,n),(i=u.video).deviceId??(i.deviceId={ideal:`default`}),(s||l)&&(u.video.processor=s??l)),u}function to(e,t){return Object.keys(t).forEach(n=>{e[n]===void 0&&(e[n]=t[n])}),e}function no(e){var t,n;let r={};if(e.video)if(typeof e.video==`object`){let n={},i=n,a=e.video;Object.keys(a).forEach(e=>{switch(e){case`resolution`:to(i,a.resolution);break;default:i[e]=a[e]}}),r.video=n,(t=r.video).deviceId??(t.deviceId={ideal:`default`})}else r.video=e.video?{deviceId:{ideal:`default`}}:!1;else r.video=!1;return e.audio?typeof e.audio==`object`?(r.audio=e.audio,(n=r.audio).deviceId??(n.deviceId={ideal:`default`})):r.audio={deviceId:{ideal:`default`}}:r.audio=!1,r}function ro(e){return L(this,arguments,void 0,function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){let n=io();if(n){let r=n.createAnalyser();r.fftSize=2048;let i=r.frequencyBinCount,a=new Uint8Array(i);n.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(r),yield Eo(t),r.getByteTimeDomainData(a);let o=a.some(e=>e!==128&&e!==0);return n.close(),!o}return!1}()})}function io(){let e=typeof window<`u`&&(window.AudioContext||window.webkitAudioContext);if(e){let t=new e({latencyHint:`interactive`});if(t.state===`suspended`&&typeof window<`u`&&window.document?.body){let e=()=>L(this,void 0,void 0,function*(){var n;try{t.state===`suspended`&&(yield t.resume())}catch(e){console.warn(`Error trying to auto-resume audio context`,e)}finally{(n=window.document.body)==null||n.removeEventListener(`click`,e)}});t.addEventListener(`statechange`,()=>{var n;t.state===`closed`&&((n=window.document.body)==null||n.removeEventListener(`click`,e))}),window.document.body.addEventListener(`click`,e)}return t}}function ao(e){return e===`audioinput`?U.Source.Microphone:e===`videoinput`?U.Source.Camera:U.Source.Unknown}function oo(e){if(e===U.Source.Microphone)return`audioinput`;if(e===U.Source.Camera)return`videoinput`}function so(e){let t=e.video??!0;return e.resolution&&e.resolution.width>0&&e.resolution.height>0&&(t=typeof t==`boolean`?{}:t,t=Lo()?Object.assign(Object.assign({},t),{width:{max:e.resolution.width},height:{max:e.resolution.height},frameRate:e.resolution.frameRate}):Object.assign(Object.assign({},t),{width:{ideal:e.resolution.width},height:{ideal:e.resolution.height},frameRate:e.resolution.frameRate})),{audio:e.audio??!1,video:t,controller:e.controller,selfBrowserSurface:e.selfBrowserSurface,surfaceSwitching:e.surfaceSwitching,systemAudio:e.systemAudio,preferCurrentTab:e.preferCurrentTab}}function co(e){return e.split(`/`)[1].toLowerCase()}function lo(e){let t=[];return e.forEach(e=>{e.track!==void 0&&t.push(new Gn({cid:e.track.mediaStreamID,track:e.trackInfo}))}),t}function uo(e){return`mediaStreamTrack`in e?{trackID:e.sid,source:e.source,muted:e.isMuted,enabled:e.mediaStreamTrack.enabled,kind:e.kind,streamID:e.mediaStreamID,streamTrackID:e.mediaStreamTrack.id}:{trackID:e.trackSid,enabled:e.isEnabled,muted:e.isMuted,trackInfo:Object.assign({mimeType:e.mimeType,name:e.trackName,encrypted:e.isEncrypted,kind:e.kind,source:e.source},e.track?uo(e.track):{})}}function fo(){return typeof RTCRtpReceiver<`u`&&typeof RTCRtpReceiver.prototype.getSynchronizationSources==`function`}function po(e,t){e===void 0&&(e={}),t===void 0&&(t={});let n=[...Object.keys(t),...Object.keys(e)],r={};for(let i of n)e[i]!==t[i]&&(r[i]=t[i]??``);return r}function mo(e){let t=Object.assign({},e),n,r;return typeof t.audio==`object`&&t.audio.processor&&(n=t.audio.processor,t.audio=Object.assign(Object.assign({},t.audio),{processor:void 0})),typeof t.video==`object`&&t.video.processor&&(r=t.video.processor,t.video=Object.assign(Object.assign({},t.video),{processor:void 0})),{audioProcessor:n,videoProcessor:r,optionsWithoutProcessor:Ua(t)}}function ho(e){switch(e){case Et.CAMERA:return U.Source.Camera;case Et.MICROPHONE:return U.Source.Microphone;case Et.SCREEN_SHARE:return U.Source.ScreenShare;case Et.SCREEN_SHARE_AUDIO:return U.Source.ScreenShareAudio;default:return U.Source.Unknown}}function go(e,t){return e.width*e.heighte.quality===t)}var vo=5e3,yo=[],bo;(function(e){e[e.LOW=0]=`LOW`,e[e.MEDIUM=1]=`MEDIUM`,e[e.HIGH=2]=`HIGH`})(bo||={});var U=class e extends oi.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.attachedElements=[],this.isMuted=!1,this._streamState=e.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=I,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState===`hidden`?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),vo):this.handleAppVisibilityChanged()},this.log=Gr(r.loggerName??Wr.Track),this.loggerContextCb=r.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=t,this._mediaStreamID=t.id,this.source=e.Source.Unknown}get logContext(){return Object.assign(Object.assign({},this.loggerContextCb?.call(this)),uo(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(t){let n=`audio`;this.kind===e.Kind.Video&&(n=`video`),this.attachedElements.length===0&&this.kind===e.Kind.Video&&this.addAppVisibilityListener(),t||(n===`audio`&&(yo.forEach(e=>{e.parentElement===null&&!t&&(t=e)}),t&&yo.splice(yo.indexOf(t),1)),t||=document.createElement(n)),this.attachedElements.includes(t)||this.attachedElements.push(t),xo(this.mediaStreamTrack,t);let r=t.srcObject.getTracks(),i=r.some(e=>e.kind===`audio`);return t.play().then(()=>{this.emit(i?H.AudioPlaybackStarted:H.VideoPlaybackStarted)}).catch(e=>{e.name===`NotAllowedError`?this.emit(i?H.AudioPlaybackFailed:H.VideoPlaybackFailed,e):e.name===`AbortError`?I.debug(`${i?`audio`:`video`} playback aborted, likely due to new play request`):I.warn(`could not playback ${i?`audio`:`video`}`,e),i&&t&&r.some(e=>e.kind===`video`)&&e.name===`NotAllowedError`&&(t.muted=!0,t.play().catch(()=>{}))}),this.emit(H.ElementAttached,t),t}detach(e){try{if(e){So(this.mediaStreamTrack,e);let t=this.attachedElements.indexOf(e);return t>=0&&(this.attachedElements.splice(t,1),this.recycleElement(e),this.emit(H.ElementDetached,e)),e}let t=[];return this.attachedElements.forEach(e=>{So(this.mediaStreamTrack,e),t.push(e),this.recycleElement(e),this.emit(H.ElementDetached,e)}),this.attachedElements=[],t}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Gr(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),yo.forEach(e=>{e.parentElement||(t=!1)}),t&&yo.push(e)}}handleAppVisibilityChanged(){return L(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState===`hidden`,!this.isInBackground&&this.kind===e.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Uo()?(this.isInBackground=document.visibilityState===`hidden`,document.addEventListener(`visibilitychange`,this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Uo()&&document.removeEventListener(`visibilitychange`,this.appVisibilityChangedListener)}};function xo(e,t){let n;n=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream;let r;r=e.kind===`audio`?n.getAudioTracks():n.getVideoTracks(),r.includes(e)||(r.forEach(e=>{n.removeTrack(e)}),n.addTrack(e)),(!Lo()||!(t instanceof HTMLVideoElement))&&(t.autoplay=!0),t.muted=n.getAudioTracks().length===0,t instanceof HTMLVideoElement&&(t.playsInline=!0),t.srcObject!==n&&(t.srcObject=n,(Lo()||Po())&&t instanceof HTMLVideoElement&&setTimeout(()=>{t.srcObject=n,t.play().catch(()=>{})},0))}function So(e,t){if(t.srcObject instanceof MediaStream){let n=t.srcObject;n.removeTrack(e),n.getTracks().length>0?t.srcObject=n:t.srcObject=null}}(function(e){let t;(function(e){e.Audio=`audio`,e.Video=`video`,e.Unknown=`unknown`})(t=e.Kind||={});let n;(function(e){e.Camera=`camera`,e.Microphone=`microphone`,e.ScreenShare=`screen_share`,e.ScreenShareAudio=`screen_share_audio`,e.Unknown=`unknown`})(n=e.Source||={});let r;(function(e){e.Active=`active`,e.Paused=`paused`,e.Unknown=`unknown`})(r=e.StreamState||={});function i(e){switch(e){case t.Audio:return Tt.AUDIO;case t.Video:return Tt.VIDEO;default:return Tt.DATA}}e.kindToProto=i;function a(e){switch(e){case Tt.AUDIO:return t.Audio;case Tt.VIDEO:return t.Video;default:return t.Unknown}}e.kindFromProto=a;function o(e){switch(e){case n.Camera:return Et.CAMERA;case n.Microphone:return Et.MICROPHONE;case n.ScreenShare:return Et.SCREEN_SHARE;case n.ScreenShareAudio:return Et.SCREEN_SHARE_AUDIO;default:return Et.UNKNOWN}}e.sourceToProto=o;function s(e){switch(e){case Et.CAMERA:return n.Camera;case Et.MICROPHONE:return n.Microphone;case Et.SCREEN_SHARE:return n.ScreenShare;case Et.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}}e.sourceFromProto=s;function c(e){switch(e){case kn.ACTIVE:return r.Active;case kn.PAUSED:return r.Paused;default:return r.Unknown}}e.streamStateFromProto=c})(U||={});var Co=`|`,wo=`https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension`;function To(e){let t=e.split(Co);return t.length>1?[t[0],e.substr(t[0].length+1)]:[e,``]}function Eo(e){return new ba(t=>Ha.setTimeout(t,e))}function Do(){return`addTransceiver`in RTCPeerConnection.prototype}function Oo(){return`addTrack`in RTCPeerConnection.prototype}function ko(){if(!(`getCapabilities`in RTCRtpSender)||Lo()||Po())return!1;let e=RTCRtpSender.getCapabilities(`video`),t=!1;if(e){for(let n of e.codecs)if(n.mimeType.toLowerCase()===`video/av1`){t=!0;break}}return t}function Ao(){if(!(`getCapabilities`in RTCRtpSender)||Po())return!1;if(Lo()){let e=Ca();if(e?.version&&Xo(e.version,`16`)<0||e?.os===`iOS`&&e?.osVersion&&Xo(e.osVersion,`16`)<0)return!1}let e=RTCRtpSender.getCapabilities(`video`),t=!1;if(e){for(let n of e.codecs)if(n.mimeType.toLowerCase()===`video/vp9`){t=!0;break}}return t}function jo(e){return e===`av1`||e===`vp9`}function Mo(e){return!document||Ro()?!1:(e||=document.createElement(`audio`),`setSinkId`in e)}function No(){return typeof RTCPeerConnection>`u`?!1:Do()||Oo()}function Po(){return Ca()?.name===`Firefox`}function Fo(){let e=Ca();return!!e&&e.name===`Chrome`&&e.os!==`iOS`}function Io(){return typeof window<`u`&&window.RTCRtpScriptTransform!==void 0&&!Fo()}function Lo(){return Ca()?.name===`Safari`}function Ro(){let e=Ca();return e?.name===`Safari`||e?.os===`iOS`}function zo(){let e=Ca();return e?.name===`Safari`&&e.version.startsWith(`17.`)||e?.os===`iOS`&&!!e?.osVersion&&Xo(e.osVersion,`17`)>=0}function Bo(e){return e||=Ca(),e?.name===`Safari`&&Xo(e.version,`18.3`)>0||e?.os===`iOS`&&!!e?.osVersion&&Xo(e.osVersion,`18.3`)>0}function Vo(){return Uo()?navigator.userAgentData?.mobile??/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function Ho(){let e=Ca(),t=`17.2`;if(e)return e.name!==`Safari`&&e.os!==`iOS`||e.os===`iOS`&&e.osVersion&&Xo(e.osVersion,t)>=0?!0:e.name===`Safari`&&Xo(e.version,t)>=0}function Uo(){return typeof document<`u`}function Wo(){return navigator.product==`ReactNative`}function Go(e){return e.hostname.endsWith(`.livekit.cloud`)||e.hostname.endsWith(`.livekit.run`)}function Ko(e){return Go(e)?e.hostname.split(`.`)[0]:null}function qo(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function Jo(){if(!Wo())return;let e=qo();if(e)return e.platform}function Yo(){if(Uo())return window.devicePixelRatio;if(Wo()){let e=qo();if(e)return e.devicePixelRatio}return 1}function Xo(e,t){let n=e.split(`.`),r=t.split(`.`),i=Math.min(n.length,r.length);for(let e=0;ea)return 1;if(t($o||=new ResizeObserver(Zo),$o),ts=null,ns=()=>(ts||=new IntersectionObserver(Qo,{root:null,rootMargin:`0px`}),ts);function rs(e){let t=new mn({capabilities:e,sdk:hn.JS,protocol:17,clientProtocol:1,version:Da});return Wo()&&(t.os=Jo()??``),t}function is(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=document.createElement(`canvas`);i.width=e,i.height=t;let a=i.getContext(`2d`);a?.fillRect(0,0,i.width,i.height),r&&a&&(a.beginPath(),a.arc(e/2,t/2,50,0,Math.PI*2,!0),a.closePath(),a.fillStyle=`grey`,a.fill());let[o]=i.captureStream().getTracks();if(!o)throw Error(`Could not get empty media stream video track`);return o.enabled=n,o}var as;function os(){if(!as){let e=new AudioContext,t=e.createOscillator(),n=e.createGain();n.gain.setValueAtTime(0,0);let r=e.createMediaStreamDestination();if(t.connect(n),n.connect(r),t.start(),[as]=r.stream.getAudioTracks(),!as)throw Error(`Could not get empty media stream audio track`);as.enabled=!1}return as.clone()}var ss=class{get isResolved(){return this._isResolved}constructor(e,t){this._isResolved=!1,this.onFinally=t,this.promise=new Promise((t,n)=>L(this,void 0,void 0,function*(){this.resolve=t,this.reject=n,e&&(yield e(t,n))})).finally(()=>{var e;this._isResolved=!0,(e=this.onFinally)==null||e.call(this)})}};function cs(e){return Ka.includes(e)}function ls(e){if(typeof e==`string`||typeof e==`number`)return e;if(Array.isArray(e))return e[0];if(e.exact!==void 0)return Array.isArray(e.exact)?e.exact[0]:e.exact;if(e.ideal!==void 0)return Array.isArray(e.ideal)?e.ideal[0]:e.ideal;throw Error(`could not unwrap constraint`)}function us(e){return e.startsWith(`http`)?e.replace(/^(http)/,`ws`):e}function ds(e){return e.startsWith(`ws`)?e.replace(/^(ws)/,`http`):e}function fs(e,t){return e.segments.map(e=>{let{id:n,text:r,language:i,startTime:a,endTime:o,final:s}=e,c=t.get(n)??Date.now(),l=Date.now();return s?t.delete(n):t.set(n,c),{id:n,text:r,startTime:Number.parseInt(a.toString()),endTime:Number.parseInt(o.toString()),final:s,language:i,firstReceivedTime:c,lastReceivedTime:l}})}function ps(e){let{id:t,timestamp:n,message:r,editTimestamp:i}=e;return{id:t,timestamp:Number.parseInt(n.toString()),editTimestamp:i?Number.parseInt(i.toString()):void 0,message:r}}function ms(e){switch(e.reason){case Aa.LeaveRequest:return e.context;case Aa.Cancelled:return At.CLIENT_INITIATED;case Aa.NotAllowed:return At.USER_REJECTED;case Aa.ServerUnreachable:return At.JOIN_FAILURE;default:return At.UNKNOWN_REASON}}function hs(e){return e===void 0?void 0:Number(e)}function gs(e){return e===void 0?void 0:BigInt(e)}function _s(e){return!!e&&!(e instanceof MediaStreamTrack)&&e.isLocal}function vs(e){return!!e&&e.kind==U.Kind.Audio}function ys(e){return!!e&&e.kind==U.Kind.Video}function bs(e){return _s(e)&&ys(e)}function xs(e){return _s(e)&&vs(e)}function Ss(e){return!!e&&!e.isLocal}function Cs(e){return!!e&&!e.isLocal}function ws(e){return Ss(e)&&ys(e)}function Ts(e){return e.isLocal}function Es(e,t){let n=[],r=new TextEncoder().encode(e);for(;r.length>t;){let e=t;for(;e>0;){let t=r[e];if(t!==void 0&&(t&192)!=128)break;e--}n.push(r.slice(0,e)),r=r.slice(e)}return r.length>0&&n.push(r),n}function Ds(e){let t=e.get(`Cache-Control`);if(t){let e=t.match(/(?:^|[,\s])max-age=(\d+)/)?.[1];if(e)return parseInt(e,10)}}function Os(){return typeof CompressionStream<`u`}function ks(){return Os()&&!Po()}function As(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=js(e,t);return n?r:Ps(r,`v1`)}function js(e,t){let n=new URL(us(e));return t.forEach((e,t)=>{n.searchParams.set(t,e)}),Ps(n,`rtc`)}function Ms(e){return Ps(new URL(ds(e)),`validate`)}function Ns(e){return e.endsWith(`/`)?e:`${e}/`}function Ps(e,t){return e.pathname=`${Ns(e.pathname)}${t}`,e}function Fs(e){if(typeof e==`string`)return Mn.fromJson(JSON.parse(e),{ignoreUnknownFields:!0});if(e instanceof ArrayBuffer)return Mn.fromBinary(new Uint8Array(e));throw Error(`could not decode websocket message: ${typeof e}`)}function Is(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Unknown reason`;if(!(e instanceof AbortSignal))return t;let n=e.reason;switch(typeof n){case`string`:return n;case`object`:return n instanceof Error?n.message:t;default:return`toString`in n?n.toString():t}}var Ls=`lk_e2ee`,Rs;(function(e){e.SetKey=`setKey`,e.RatchetRequest=`ratchetRequest`,e.KeyRatcheted=`keyRatcheted`})(Rs||={});var zs;(function(e){e.KeyRatcheted=`keyRatcheted`})(zs||={});var Bs;(function(e){e.ParticipantEncryptionStatusChanged=`participantEncryptionStatusChanged`,e.EncryptionError=`encryptionError`})(Bs||={});var Vs;(function(e){e.Error=`cryptorError`})(Vs||={});function Hs(){return Ws()||Us()}function Us(){return typeof window<`u`&&window.RTCRtpScriptTransform!==void 0}function Ws(){return typeof window<`u`&&window.RTCRtpSender!==void 0&&window.RTCRtpSender.prototype.createEncodedStreams!==void 0}function Gs(e){if(e.value?.case!==`sipDtmf`&&e.value?.case!==`metrics`&&e.value?.case!==`speaker`&&e.value?.case!==`transcription`&&e.value?.case!==`encryptedPacket`)return new Qt({value:e.value})}oi.EventEmitter;var Ks;(function(e){e[e.InvalidKey=0]=`InvalidKey`,e[e.MissingKey=1]=`MissingKey`,e[e.InternalError=2]=`InternalError`})(Ks||={});function qs(){return Io()}function Js(e){return!!e?.worker&&(Ws()||qs())}function Ys(e){return!!(e?.timestamp||e?.frameId)}function Xs(e){let t=[];return e?.timestamp&&t.push(Pt.PTF_USER_TIMESTAMP),e?.frameId&&t.push(Pt.PTF_FRAME_ID),t}function Zs(e){if(!e||e.length===0)return;let t={};return e.includes(Pt.PTF_USER_TIMESTAMP)&&(t.timestamp=!0),e.includes(Pt.PTF_FRAME_ID)&&(t.frameId=!0),t.timestamp||t.frameId?t:void 0}function Qs(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:50,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,i=n.isImmediate??!1,a=n.callback??!1,o=n.maxWait,s=Date.now(),c=[];function l(){if(o!==void 0){let e=Date.now()-s;if(e+t>=o)return o-e}return t}let u=function(){var t=[...arguments];let n=this;return new Promise((o,u)=>{let d=function(){if(r=void 0,s=Date.now(),!i){let r=e.apply(n,t);a&&a(r),c.forEach(e=>{let{resolve:t}=e;return t(r)}),c=[]}},f=i&&r===void 0;if(r!==void 0&&Ha.clearTimeout(r),r=Ha.setTimeout(d,l()),f){let r=e.apply(n,t);return a&&a(r),o(r)}c.push({resolve:o,reject:u})})};return u.cancel=function(e){r!==void 0&&Ha.clearTimeout(r),c.forEach(t=>{let{reject:n}=t;return n(e)}),c=[]},u}var $s=2e3;function ec(e,t){if(!t)return 0;let n,r;return`bytesReceived`in e?(n=e.bytesReceived,r=t.bytesReceived):`bytesSent`in e&&(n=e.bytesSent,r=t.bytesSent),n===void 0||r===void 0||e.timestamp===void 0||t.timestamp===void 0?0:(n-r)*8*1e3/(e.timestamp-t.timestamp)}var tc=class extends U{constructor(e,t,n,r,i){super(e,n,i),this.sid=t,this.receiver=r}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?H.Muted:H.Unmuted,this))}setMediaStream(e){this.mediaStream=e;let t=n=>{n.track===this._mediaStreamTrack&&(e.removeEventListener(`removetrack`,t),this.receiver&&`playoutDelayHint`in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(H.Ended,this))};e.addEventListener(`removetrack`,t)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return L(this,void 0,void 0,function*(){if(this.receiver?.getStats)return yield this.receiver.getStats()})}setPlayoutDelay(e){this.receiver?`playoutDelayHint`in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn(`Playout delay not supported in this browser`):this.log.warn(`Cannot set playout delay, track already ended`)}getPlayoutDelay(){if(this.receiver){if(`playoutDelayHint`in this.receiver)return this.receiver.playoutDelayHint;this.log.warn(`Playout delay not supported in this browser`)}else this.log.warn(`Cannot get playout delay, track already ended`);return 0}startMonitor(){this.monitorInterval||=setInterval(()=>this.monitorReceiver(),$s),fo()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){let e=()=>{this.timeSyncHandle=requestAnimationFrame(()=>e());let t=this.receiver?.getSynchronizationSources()[0];if(t){let{timestamp:e,rtpTimestamp:n}=t;n&&this.rtpTimestamp!==n&&(this.emit(H.TimeSyncUpdate,{timestamp:e,rtpTimestamp:n}),this.rtpTimestamp=n)}};e()}},nc=100,rc=class extends tc{constructor(e,t,n,r,i){super(e,t,U.Kind.Video,n,i),this.elementInfos=[],this.monitorReceiver=()=>L(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}let e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=ec(e,this.prevStats)),this.prevStats=e}),this.debouncedHandleResize=Qs(()=>{this.updateDimensions()},nc),this.adaptiveStreamSettings=r}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}lookupFrameMetadata(e){let{rtpTimestamp:t}=e;return this.packetTrailerExtractor?.lookupMetadata(t)}setStreamState(e){super.setStreamState(e),this.log.debug(`setStreamState`,e),this.isAdaptiveStream&&e===U.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?So(this._mediaStreamTrack,t):xo(this._mediaStreamTrack,t)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(t=>t.element===e)===void 0){let t=new ic(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(t=>t===e)===void 0?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn(`visibility resize observer not triggered`,this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream){this.log.warn(`stopObservingElementInfo ignored`,this.logContext);return}let t=this.elementInfos.filter(t=>t===e);for(let e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter(t=>t!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){if(e)return this.stopObservingElement(e),super.detach(e);let t=super.detach();for(let e of t)this.stopObservingElement(e);return t}getDecoderImplementation(){return this.prevStats?.decoderImplementation}getReceiverStats(){return L(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;let e=yield this.receiver.getStats(),t,n=``,r=new Map;return e.forEach(e=>{e.type===`inbound-rtp`?(n=e.codecId,t={type:`video`,streamId:e.id,framesDecoded:e.framesDecoded,framesDropped:e.framesDropped,framesReceived:e.framesReceived,packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,frameWidth:e.frameWidth,frameHeight:e.frameHeight,pliCount:e.pliCount,firCount:e.firCount,nackCount:e.nackCount,jitter:e.jitter,timestamp:e.timestamp,bytesReceived:e.bytesReceived,decoderImplementation:e.decoderImplementation}):e.type===`codec`&&r.set(e.id,e)}),t&&n!==``&&r.get(n)&&(t.mimeType=r.get(n).mimeType),t})}stopObservingElement(e){let t=this.elementInfos.filter(t=>t.element===e);for(let e of t)this.stopObservingElementInfo(e)}handleAppVisibilityChanged(){let e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return L(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(e){let t=this.elementInfos.reduce((e,t)=>Math.max(e,t.visibilityChangedAt||0),0),n=this.adaptiveStreamSettings?.pauseVideoInBackground??!0?this.isInBackground:!1,r=this.elementInfos.some(e=>e.pictureInPicture),i=this.elementInfos.some(e=>e.visible)&&!n||r;if(!(this.lastVisible===i&&!e)){if(!i&&Date.now()-t{this.updateVisibility()},nc);return}this.lastVisible=i,this.emit(H.VisibilityChanged,i,this)}}updateDimensions(){let e=0,t=0,n=this.getPixelDensity();for(let r of this.elementInfos){let i=r.width()*n,a=r.height()*n;i+a>e+t&&(e=i,t=a)}this.lastDimensions?.width===e&&this.lastDimensions?.height===t||(this.lastDimensions={width:e,height:t},this.emit(H.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){let e=this.adaptiveStreamSettings?.pixelDensity;return e===`screen`?Yo():e||(Yo()>2?2:1)}},ic=class{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=e=>{var t;let{target:n,isIntersecting:r}=e;n===this.element&&(this.isIntersecting=r,this.isPiP=ac(this.element),this.visibilityChangedAt=Date.now(),(t=this.handleVisibilityChanged)==null||t.call(this))},this.onEnterPiP=()=>{var e;(e=window.documentPictureInPicture?.window)==null||e.addEventListener(`pagehide`,this.onLeavePiP),queueMicrotask(()=>{requestAnimationFrame(()=>{var e;this.isPiP=ac(this.element),(e=this.handleVisibilityChanged)==null||e.call(this)})})},this.onLeavePiP=()=>{var e;this.isPiP=ac(this.element),(e=this.handleVisibilityChanged)==null||e.call(this)},this.element=e,this.isIntersecting=t??oc(e),this.isPiP=Uo()&&ac(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t;this.isIntersecting=oc(this.element),this.isPiP=ac(this.element),this.element.handleResize=()=>{var e;(e=this.handleResize)==null||e.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,ns().observe(this.element),es().observe(this.element),this.element.addEventListener(`enterpictureinpicture`,this.onEnterPiP),this.element.addEventListener(`leavepictureinpicture`,this.onLeavePiP),(e=window.documentPictureInPicture)==null||e.addEventListener(`enter`,this.onEnterPiP),(t=window.documentPictureInPicture?.window)==null||t.addEventListener(`pagehide`,this.onLeavePiP)}stopObserving(){var e,t,n,r;(e=ns())==null||e.unobserve(this.element),(t=es())==null||t.unobserve(this.element),this.element.removeEventListener(`enterpictureinpicture`,this.onEnterPiP),this.element.removeEventListener(`leavepictureinpicture`,this.onLeavePiP),(n=window.documentPictureInPicture)==null||n.removeEventListener(`enter`,this.onEnterPiP),(r=window.documentPictureInPicture?.window)==null||r.removeEventListener(`pagehide`,this.onLeavePiP)}};function ac(e){return document.pictureInPictureElement===e?!0:window.documentPictureInPicture?.window?oc(e,window.documentPictureInPicture?.window):!1}function oc(e,t){let n=t||window,r=e.offsetTop,i=e.offsetLeft,a=e.offsetWidth,o=e.offsetHeight,{hidden:s}=e,{display:c}=getComputedStyle(e);for(;e.offsetParent;)e=e.offsetParent,r+=e.offsetTop,i+=e.offsetLeft;return rn.pageYOffset&&i+a>n.pageXOffset&&!s&&c!==`none`}var sc=class extends oi.EventEmitter{constructor(e,t){super(),this.decryptDataRequests=new Map,this.encryptDataRequests=new Map,this.onWorkerMessage=e=>{let{kind:t,data:n}=e.data;switch(t){case`error`:if(I.error(n.error.message),n.uuid){let e=this.decryptDataRequests.get(n.uuid);if(e?.reject){e.reject(n.error);break}let t=this.encryptDataRequests.get(n.uuid);if(t?.reject){t.reject(n.error);break}}this.emit(Bs.EncryptionError,n.error,n.participantIdentity);break;case`initAck`:n.enabled&&this.keyProvider.getKeys().forEach(e=>{this.postKey(e,!1)});break;case`enable`:if(n.enabled&&this.keyProvider.getKeys().forEach(e=>{this.postKey(e,!1)}),this.encryptionEnabled!==n.enabled&&n.participantIdentity===this.room?.localParticipant.identity)this.emit(Bs.ParticipantEncryptionStatusChanged,n.enabled,this.room.localParticipant),this.encryptionEnabled=n.enabled;else if(n.participantIdentity){let e=this.room?.getParticipantByIdentity(n.participantIdentity);if(!e)throw TypeError(`couldn't set encryption status, participant not found${n.participantIdentity}`);this.emit(Bs.ParticipantEncryptionStatusChanged,n.enabled,e)}break;case`ratchetKey`:this.keyProvider.emit(Rs.KeyRatcheted,n.ratchetResult,n.participantIdentity,n.keyIndex);break;case`decryptDataResponse`:let e=this.decryptDataRequests.get(n.uuid);e?.resolve&&e.resolve(n);break;case`encryptDataResponse`:let t=this.encryptDataRequests.get(n.uuid);t?.resolve&&t.resolve(n);break;case`packetTrailerMetadata`:this.handlePacketTrailerMetadata(n.trackId,n.rtpTimestamp,n.ssrc,n.metadata);break}},this.onWorkerError=e=>{I.error(`e2ee worker encountered an error:`,{error:e.error}),this.emit(Bs.EncryptionError,e.error,void 0)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1,this.dataChannelEncryptionEnabled=t}get isEnabled(){return this.encryptionEnabled}get isDataChannelEncryptionEnabled(){return this.isEnabled&&this.dataChannelEncryptionEnabled}setup(e){if(!Hs())throw new ja(`tried to setup end-to-end encryption on an unsupported browser`);if(I.info(`setting up e2ee`),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);let t={kind:`init`,data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:qr.getLevel()}};this.worker&&(I.info(`initializing worker`,{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){I.debug(`set e2ee to ${e} for participant ${t}`),this.postEnable(e,t)}setSifTrailer(e){!e||e.length===0?I.warn(`ignoring server sent trailer as it's empty`):this.postSifTrailer(e)}handlePacketTrailerMetadata(e,t,n,r){if(this.room){for(let i of[this.room.localParticipant,...this.room.remoteParticipants.values()])for(let a of i.trackPublications.values())if(a.track&&a.track.mediaStreamID===e&&a.track instanceof rc&&a.track.packetTrailerExtractor){a.track.packetTrailerExtractor.storeMetadata(t,n,r);return}}}setupEngine(e){e.on(V.RTPVideoMapUpdate,e=>{this.postRTPMap(e)})}setupEventListeners(e,t){e.on(z.TrackPublished,(e,t)=>this.setParticipantCryptorEnabled(e.trackInfo.encryption!==Ht.NONE,t.identity)),e.on(z.ConnectionStateChanged,t=>{t===$d.Connected&&e.remoteParticipants.forEach(e=>{e.trackPublications.forEach(t=>{this.setParticipantCryptorEnabled(t.trackInfo.encryption!==Ht.NONE,e.identity)})})}).on(z.TrackUnsubscribed,(e,t,n)=>{var r;let i={kind:`removeTransform`,data:{participantIdentity:n.identity,trackId:e.mediaStreamID}};(r=this.worker)==null||r.postMessage(i)}).on(z.TrackSubscribed,(e,t,n)=>{this.setupE2EEReceiver(e,n.identity,t.trackInfo)}).on(z.SignalConnected,()=>{if(!this.room)throw TypeError(`expected room to be present on signal connect`);let e=t.getLatestManuallySetKeyIndex();t.getKeys().forEach(t=>{this.postKey(t,e===(t.keyIndex??0))}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(B.LocalSenderCreated,(e,t)=>L(this,void 0,void 0,function*(){this.setupE2EESender(t,e)})),e.localParticipant.on(B.LocalTrackPublished,e=>{if(!ys(e.track)||!Ro())return;let t={kind:`updateCodec`,data:{trackId:e.track.mediaStreamID,codec:co(e.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity,hasPacketTrailer:!1}};this.worker.postMessage(t)}),t.on(Rs.SetKey,(e,t)=>this.postKey(e,t??!0)).on(Rs.RatchetRequest,(e,t)=>this.postRatchetRequest(e,t))}encryptData(e){return L(this,void 0,void 0,function*(){if(!this.worker)throw Error(`could not encrypt data, worker is missing`);let t=crypto.randomUUID(),n={kind:`encryptDataRequest`,data:{uuid:t,payload:e,participantIdentity:this.room.localParticipant.identity}},r=new ss;return r.onFinally=()=>{this.encryptDataRequests.delete(t)},this.encryptDataRequests.set(t,r),this.worker.postMessage(n),r.promise})}handleEncryptedData(e,t,n,r){if(!this.worker)throw Error(`could not handle encrypted data, worker is missing`);let i=crypto.randomUUID(),a={kind:`decryptDataRequest`,data:{uuid:i,payload:e,iv:t,participantIdentity:n,keyIndex:r}},o=new ss;return o.onFinally=()=>{this.decryptDataRequests.delete(i)},this.decryptDataRequests.set(i,o),this.worker.postMessage(a),o.promise}postRatchetRequest(e,t){if(!this.worker)throw Error(`could not ratchet key, worker is missing`);let n={kind:`ratchetRequest`,data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(n)}postKey(e,t){let{key:n,participantIdentity:r,keyIndex:i}=e;if(!this.worker)throw Error(`could not set key, worker is missing`);let a={kind:`setKey`,data:{participantIdentity:r,isPublisher:r===this.room?.localParticipant.identity,key:n,keyIndex:i,updateCurrentKeyIndex:t}};this.worker.postMessage(a)}postEnable(e,t){if(this.worker){let n={kind:`enable`,data:{enabled:e,participantIdentity:t}};this.worker.postMessage(n)}else throw ReferenceError(`failed to enable e2ee, worker is not ready`)}postRTPMap(e){if(!this.worker)throw TypeError(`could not post rtp map, worker is missing`);if(!this.room?.localParticipant.identity)throw TypeError(`could not post rtp map, local participant identity is missing`);let t={kind:`setRTPMap`,data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(t)}postSifTrailer(e){if(!this.worker)throw Error(`could not post SIF trailer, worker is missing`);let t={kind:`setSifTrailer`,data:{trailer:e}};this.worker.postMessage(t)}setupE2EEReceiver(e,t,n){if(!e.receiver)return;if(!n?.mimeType||n.mimeType===``)throw TypeError(`MimeType missing from trackInfo, cannot set up E2EE cryptor`);let r=e.kind===`video`&&!!n.packetTrailerFeatures&&n.packetTrailerFeatures.length>0;this.handleReceiver(e.receiver,e.mediaStreamID,t,e.kind===`video`?co(n.mimeType):void 0,r)}setupE2EESender(e,t){if(!_s(e)||!t){t||I.warn(`early return because sender is not ready`);return}this.handleSender(t,e.mediaStreamID,void 0,ys(e)?e.publishOptions?.packetTrailer:void 0)}handleReceiver(e,t,n,r,i){return L(this,void 0,void 0,function*(){if(this.worker){if(Io()){let a={kind:`decode`,participantIdentity:n,trackId:t,codec:r,hasPacketTrailer:i};e.transform=new RTCRtpScriptTransform(this.worker,a)}else{if(Ls in e&&r){let e={kind:`updateCodec`,data:{trackId:t,codec:r,participantIdentity:n,hasPacketTrailer:i}};this.worker.postMessage(e);return}let a=e.writableStream,o=e.readableStream;if(!a||!o){let t=e.createEncodedStreams();e.writableStream=t.writable,a=t.writable,e.readableStream=t.readable,o=t.readable}let s={kind:`decode`,data:{readableStream:o,writableStream:a,trackId:t,codec:r,participantIdentity:n,isReuse:Ls in e,hasPacketTrailer:i}};this.worker.postMessage(s,[o,a])}e[Ls]=!0}})}handleSender(e,t,n,r){if(!(Ls in e||!this.worker)){if(!this.room?.localParticipant.identity||this.room.localParticipant.identity===``)throw TypeError(`local identity needs to be known in order to set up encrypted sender`);if(Io()){I.info(`initialize script transform`);let i={kind:`encode`,participantIdentity:this.room.localParticipant.identity,trackId:t,codec:n,hasPacketTrailer:Ys(r),packetTrailer:r};e.transform=new RTCRtpScriptTransform(this.worker,i)}else{I.info(`initialize encoded streams`);let i=e.createEncodedStreams(),a={kind:`encode`,data:{readableStream:i.readable,writableStream:i.writable,codec:n,trackId:t,participantIdentity:this.room.localParticipant.identity,isReuse:!1,hasPacketTrailer:Ys(r),packetTrailer:r}};this.worker.postMessage(a,[i.readable,i.writable])}e[Ls]=!0}}},cc=300,lc=class{constructor(){this.metadataMap=new Map,this.activeSsrc=0}storeMetadata(e,t,n){for(this.activeSsrc!==0&&this.activeSsrc!==t&&this.metadataMap.clear(),this.activeSsrc=t;this.metadataMap.size>=cc;){let e=this.metadataMap.keys().next().value;this.metadataMap.delete(e)}this.metadataMap.set(e,n)}lookupMetadata(e){return this.metadataMap.get(e)}dispose(){this.metadataMap.clear(),this.activeSsrc=0}},uc=class{constructor(e){this.extractors=new Map,this.workerPipelines=new Map,this.onWorkerMessage=e=>{let t=e.data;if(t.kind===`metadata`){let e=this.extractors.get(t.data.trackId);e&&e.storeMetadata(t.data.rtpTimestamp,t.data.ssrc,t.data.metadata)}},this.onWorkerError=e=>{I.error(`packet trailer worker encountered an error:`,{error:e.error})},this.worker=e?.worker}setup(e){e!==this.room&&(this.room=e,this.worker&&(this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage({kind:`init`})),e.on(z.TrackSubscribed,(e,t,n)=>{e.kind===`video`&&this.setupReceiver(e,t.trackInfo)}).on(z.TrackUnsubscribed,e=>{this.teardownTrack(e)}).on(z.Disconnected,()=>{this.cleanup()}))}setupReceiver(e,t){let n=e.receiver;if(!n)return;if(!(t?.packetTrailerFeatures&&t.packetTrailerFeatures.length>0)){this.room?.hasE2EESetup||this.setupPassthroughReceiver(n,e.mediaStreamID);return}if(!Js(this.worker?{worker:this.worker}:void 0)&&!this.room?.hasE2EESetup){I.warn(`packet trailer transform not supported; skipping extraction`);return}let r=new lc,i=e.mediaStreamID;this.extractors.set(i,r),e.packetTrailerExtractor=r,!this.room?.hasE2EESetup&&this.setupWorkerReceiver(n,i,!0)}setupPassthroughReceiver(e,t){if(qs()){`transform`in e&&(e.transform=null);return}if(this.worker&&Js({worker:this.worker})&&!this.workerPipelines.has(e)){this.setupWorkerReceiver(e,t,!1);return}this.worker&&this.workerPipelines.has(e)&&this.setupWorkerReceiver(e,t,!1)}setupWorkerReceiver(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=this.worker;if(!r)return;if(qs()){e.transform=new RTCRtpScriptTransform(r,{kind:`decode`,trackId:t});return}let i=this.workerPipelines.get(e);if(i){let a={kind:`updateTrackId`,data:{oldTrackId:i,newTrackId:t,hasPacketTrailer:n}};r.postMessage(a),this.workerPipelines.set(e,t);return}if(!(`createEncodedStreams`in e)){I.warn(`createEncodedStreams not supported`);return}let a;try{a=e.createEncodedStreams()}catch(e){I.warn(`failed to create encoded streams`,{error:e});return}let o={kind:`decode`,data:{readableStream:a.readable,writableStream:a.writable,trackId:t,hasPacketTrailer:n}};r.postMessage(o,[a.readable,a.writable]),this.workerPipelines.set(e,t)}teardownTrack(e){let t=e.mediaStreamID,n=this.extractors.get(t);n&&(n.dispose(),this.extractors.delete(t)),e instanceof rc&&(e.packetTrailerExtractor=void 0)}cleanup(){var e;for(let e of this.extractors.values())e.dispose();this.extractors.clear(),this.workerPipelines.clear(),(e=this.worker)==null||e.terminate()}},dc=500,fc=15e3,pc=class e{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||=new e,this._instance}addFailedConnectionAttempt(e){let t=Ko(new URL(e));if(!t)return;let n=this.failedConnectionAttempts.get(t)??0;this.failedConnectionAttempts.set(t,n+1),this.backOffPromises.set(t,Eo(Math.min(dc*2**n,fc)))}getBackOffPromise(e){let t=new URL(e),n=t&&Ko(t);return n&&this.backOffPromises.get(n)||Promise.resolve()}resetFailedConnectionAttempts(e){let t=new URL(e),n=t&&Ko(t);n&&(this.failedConnectionAttempts.set(n,0),this.backOffPromises.set(n,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}};pc._instance=null;var mc=`default`,hc=class e{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new e),this.instance}get previousDevices(){return this._previousDevices}getDevices(t){return L(this,arguments,void 0,function(t){var n=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){if(e.userMediaPromiseMap?.size>0){I.debug(`awaiting getUserMedia promise`);try{t?yield e.userMediaPromiseMap.get(t):yield Promise.all(e.userMediaPromiseMap.values())}catch{I.warn(`error waiting for media permissons`)}}let i=yield navigator.mediaDevices.enumerateDevices();if(r&&!(Lo()&&n.hasDeviceInUse(t))&&(i.filter(e=>e.kind===t).length===0||i.some(e=>{let n=e.label===``,r=t?e.kind===t:!0;return n&&r}))){let e={video:t!==`audioinput`&&t!==`audiooutput`,audio:t!==`videoinput`&&{deviceId:{ideal:`default`}}},n=yield navigator.mediaDevices.getUserMedia(e);i=yield navigator.mediaDevices.enumerateDevices(),n.getTracks().forEach(e=>{e.stop()})}return n._previousDevices=i,t&&(i=i.filter(e=>e.kind===t)),i}()})}normalizeDeviceId(e,t,n){return L(this,void 0,void 0,function*(){if(t!==mc)return t;let r=yield this.getDevices(e),i=r.find(e=>e.deviceId===mc);if(!i){I.warn(`could not reliably determine default device`);return}let a=r.find(e=>e.deviceId!==mc&&e.groupId===(n??i.groupId));if(!a){I.warn(`could not reliably determine default device`);return}return a?.deviceId})}hasDeviceInUse(t){return t?e.userMediaPromiseMap.has(t):e.userMediaPromiseMap.size>0}};hc.mediaDeviceKinds=[`audioinput`,`audiooutput`,`videoinput`],hc.userMediaPromiseMap=new Map;var gc=65535,_c=4294967295,vc=class e{static u16(t){return new e(t,gc)}static u32(t){return new e(t,_c)}constructor(e,t){if(this.value=e,e<0)throw Error(`WrapAroundUnsignedInt: cannot faithfully represent an integer smaller than 0`);if(t>2**53-1)throw Error(`WrapAroundUnsignedInt: cannot faithfully represent an integer bigger than MAX_SAFE_INTEGER.`);this.maxSize=t,this.clamp()}clamp(){for(;this.value>this.maxSize;)this.value-=this.maxSize+1;for(;this.value<0;)this.value+=this.maxSize+1}clone(){return new e(this.value,this.maxSize)}update(e){this.value=e(this.value),this.clamp()}increment(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(t=>t+e)}decrement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(t=>t-e)}getThenIncrement(){let t=this.value;return this.increment(),new e(t,this.maxSize)}isBefore(e){let t=this.value>>>0,n=(e.value>>>0)-t>>>0;return n!==0&&ngc)throw Cc.tooLarge();return e}},Tc=class{constructor(){this.value=0}get(){return this.value+=1,this.value>gc?null:this.value}reset(){this.value=0}},Ec={from(e){return{sid:e.sid,pubHandle:e.pubHandle,name:e.name,usesE2ee:e.encryption!==Ht.NONE}},toProtobuf(e){return new Gt({sid:e.sid,pubHandle:e.pubHandle,name:e.name,encryption:e.usesE2ee?Ht.GCM:Ht.NONE})}},Dc;(function(e){e[e.WAITING=0]=`WAITING`,e[e.RUNNING=1]=`RUNNING`,e[e.COMPLETED=2]=`COMPLETED`})(Dc||={});var Oc=class{constructor(){this.pendingTasks=new Map,this.taskMutex=new i,this.nextTaskIndex=0}run(e){return L(this,void 0,void 0,function*(){let t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:Dc.WAITING};this.pendingTasks.set(t.id,t);let n=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=Dc.RUNNING,yield e()}finally{t.status=Dc.COMPLETED,this.pendingTasks.delete(t.id),n()}})}flush(){return L(this,void 0,void 0,function*(){return this.run(()=>L(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}},kc=class{get readyState(){return this.ws.readyState}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t.signal?.aborted)throw new DOMException(`This operation was aborted`,`AbortError`);this.url=e;let n=new WebSocket(e,t.protocols??[]);n.binaryType=`arraybuffer`,this.ws=n;let r=function(){let{closeCode:e,reason:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return n.close(e,t)};this.opened=new ba((e,t)=>{let i=()=>{t(R.websocket(`Encountered websocket error during connection establishment`))};n.onopen=()=>{e({readable:new ReadableStream({start(e){n.onmessage=t=>{let{data:n}=t;return e.enqueue(n)},n.onerror=t=>e.error(t)},cancel:r}),writable:new WritableStream({write(e){n.send(e)},abort(){n.close()},close:r}),protocol:n.protocol,extensions:n.extensions}),n.removeEventListener(`error`,i)},n.addEventListener(`error`,i)}),this.closed=new ba((e,t)=>{let r=()=>L(this,void 0,void 0,function*(){let r=new ba(e=>{n.readyState!==WebSocket.CLOSED&&n.addEventListener(`close`,t=>{e(t)},{once:!0})}),i=yield ba.race([Eo(250),r]);i?e(i):t(R.websocket(`Encountered unspecified websocket error without a timely close event`))});n.onclose=t=>{let{code:i,reason:a}=t;e({closeCode:i,reason:a}),n.removeEventListener(`error`,r)},n.addEventListener(`error`,r)}),t.signal&&(t.signal.onabort=()=>n.close()),this.close=r}},Ac=[`syncState`,`trickle`,`offer`,`answer`,`simulate`,`leave`];function jc(e){let t=Ac.indexOf(e.case)>=0;return I.trace(`request allowed to bypass queue:`,{canPass:t,req:e}),t}var Mc;(function(e){e[e.CONNECTING=0]=`CONNECTING`,e[e.CONNECTED=1]=`CONNECTED`,e[e.RECONNECTING=2]=`RECONNECTING`,e[e.DISCONNECTING=3]=`DISCONNECTING`,e[e.DISCONNECTED=4]=`DISCONNECTED`})(Mc||={});var Nc=250,Pc=class{get currentState(){return this.state}get isDisconnected(){return this.state===Mc.DISCONNECTING||this.state===Mc.DISCONNECTED}get isEstablishingConnection(){return this.state===Mc.CONNECTING||this.state===Mc.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.rtt=0,this.state=Mc.DISCONNECTED,this.log=I,this._requestId=0,this.useV0SignalPath=!1,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0,this.onMediaSectionsRequirement=void 0},this.loggerContextCb=t.loggerContextCb,this.log=Gr(t.loggerName??Wr.Signal,()=>this.logContext),this.useJSON=e,this.requestQueue=new Oc,this.queuedRequests=[],this.closingLock=new i,this.connectionLock=new i,this.state=Mc.DISCONNECTED}get logContext(){return this.loggerContextCb?.call(this)??{}}join(e,t,n,r){return L(this,arguments,void 0,function(e,t,n,r){var i=this;let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,o=arguments.length>5?arguments[5]:void 0;return function*(){return i.state=Mc.CONNECTING,i.options=n,yield i.connect(e,t,n,r,a,o)}()})}reconnect(e,t,n,r){return L(this,void 0,void 0,function*(){if(!this.options){this.log.warn(`attempted to reconnect without signal options being set, ignoring`);return}return this.state=Mc.RECONNECTING,this.clearPingInterval(),yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:n,reconnectReason:r}),void 0,this.useV0SignalPath)})}connect(e,t,n,r){return L(this,arguments,void 0,function(e,t,n,r){var i=this;let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,o=arguments.length>5?arguments[5]:void 0;return function*(){let s=yield i.connectionLock.lock();i.connectOptions=n,i.useV0SignalPath=a;let c=rs(n.clientInfoCapabilities),l=As(e,a?Lc(t,c,n):yield Rc(t,c,n,o),a).toString(),u=Ms(l).toString();return new Promise((e,t)=>L(i,void 0,void 0,function*(){try{let i=!1,a=e=>L(this,void 0,void 0,function*(){if(i)return;i=!0;let n=Is(e instanceof Event?e.currentTarget:e,`Abort handler called`);this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(n)).catch(e=>{this.log.error(e),this.close()}):this.close(),o(),t(R.cancelled(n))});r?.addEventListener(`abort`,a);let o=()=>{clearTimeout(s),r?.removeEventListener(`abort`,a)},s=setTimeout(()=>{a(R.timeout(`room connection has timed out (signal)`))},n.websocketTimeout),c=(e,t)=>{this.handleSignalConnected(e,s,t)},d=new URL(l);d.searchParams.has(`access_token`)&&d.searchParams.set(`access_token`,``),this.log.info(`signal connecting to ${d}`,{reconnect:n.reconnect,reconnectReason:n.reconnectReason}),this.ws&&(yield this.close(!1)),this.ws=new kc(l);try{this.ws.closed.then(e=>{this.isEstablishingConnection&&t(R.internal(`Websocket got closed during a (re)connection attempt: ${e.reason}`)),e.closeCode!==1e3&&(this.log.warn(`websocket closed`,{reason:e.reason,code:e.closeCode,wasClean:e.closeCode===1e3,state:this.state}),this.state===Mc.CONNECTED&&this.handleOnClose(e.reason??`Unexpected WS error`))}).catch(e=>{this.isEstablishingConnection&&t(R.internal(`Websocket error during a (re)connection attempt: ${e}`))});let r=yield this.ws.opened.catch(e=>L(this,void 0,void 0,function*(){if(this.state!==Mc.CONNECTED){this.state=Mc.DISCONNECTED,clearTimeout(s),t(yield this.handleConnectionError(e,u));return}this.handleWSError(e),t(e)}));if(clearTimeout(s),!r)return;let i=r.readable.getReader();this.streamWriter=r.writable.getWriter();let a=yield i.read();if(i.releaseLock(),!a.value)throw R.internal(`no message received as first message`);let o=Fs(a.value),l=this.validateFirstMessage(o,n.reconnect??!1);if(!l.isValid){t(l.error);return}o.message?.case===`join`&&(this.pingTimeoutDuration=o.message.value.pingTimeout,this.pingIntervalDuration=o.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&this.log.debug(`ping config`,{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration}),this.onJoined&&this.onJoined(o.message.value)),c(r,l.shouldProcessFirstMessage?o:void 0),e(l.response)}catch(e){t(e)}finally{o()}}finally{s()}}))}()})}startReadingLoop(e,t){return L(this,void 0,void 0,function*(){for(t&&this.handleSignalResponse(t);;){this.signalLatency&&(yield Eo(this.signalLatency));let{done:t,value:n}=yield e.read();if(t)break;let r=Fs(n);this.handleSignalResponse(r)}})}close(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Close method called on signal client`;return function*(){if([Mc.DISCONNECTING||Mc.DISCONNECTED].includes(e.state)){e.log.debug(`ignoring signal close as it's already in disconnecting state`);return}let r=yield e.closingLock.lock();try{if(e.clearPingInterval(),t&&(e.state=Mc.DISCONNECTING),e.ws){e.ws.close({closeCode:1e3,reason:n});let t=e.ws.closed;e.ws=void 0,e.streamWriter=void 0,yield Promise.race([t,Eo(Nc)])}}catch(t){e.log.debug(`websocket error while closing`,{error:t})}finally{t&&(e.state=Mc.DISCONNECTED),r()}}()})}sendOffer(e,t){this.log.debug(`sending offer`,{offerSdp:e.sdp}),this.sendRequest({case:`offer`,value:Ic(e,t)})}sendAnswer(e,t){return this.log.debug(`sending answer`,{answerSdp:e.sdp}),this.sendRequest({case:`answer`,value:Ic(e,t)})}sendIceCandidate(e,t){return this.log.debug(`sending ice candidate`,{candidate:e}),this.sendRequest({case:`trickle`,value:new Vn({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:`mute`,value:new Hn({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:`addTrack`,value:e})}sendUpdateLocalMetadata(e,t){return L(this,arguments,void 0,function(e,t){var n=this;let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){let i=n.getNextRequestId();return yield n.sendRequest({case:`updateMetadata`,value:new ir({requestId:i,metadata:e,name:t,attributes:r})}),i}()})}sendUpdateTrackSettings(e){this.sendRequest({case:`trackSetting`,value:e})}sendUpdateSubscription(e){return this.sendRequest({case:`subscription`,value:e})}sendSyncState(e){return this.sendRequest({case:`syncState`,value:e})}sendUpdateVideoLayers(e,t){return this.sendRequest({case:`updateLayers`,value:new rr({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:`subscriptionPermission`,value:new _r({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:`simulate`,value:e})}sendPing(){return Promise.all([this.sendRequest({case:`ping`,value:A.parse(Date.now())}),this.sendRequest({case:`pingReq`,value:new wr({timestamp:A.parse(Date.now()),rtt:A.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:`updateAudioTrack`,value:new $n({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:`leave`,value:new tr({reason:At.CLIENT_INITIATED,action:nr.DISCONNECT})})}sendPublishDataTrackRequest(e,t,n){return this.sendRequest({case:`publishDataTrackRequest`,value:new Fn({pubHandle:e,name:t,encryption:n?Ht.GCM:Ht.NONE})})}sendUnPublishDataTrackRequest(e){return this.sendRequest({case:`unpublishDataTrackRequest`,value:new Ln({pubHandle:e})})}sendUpdateDataSubscription(e,t){return this.sendRequest({case:`updateDataSubscription`,value:new Xn({updates:[new Zn({trackSid:e,subscribe:t})]})})}sendRequest(e){return L(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!n&&!jc(e)&&t.state===Mc.RECONNECTING){t.queuedRequests.push(()=>L(t,void 0,void 0,function*(){yield this.sendRequest(e,!0)}));return}if(n||(yield t.requestQueue.flush()),t.signalLatency&&(yield Eo(t.signalLatency)),t.isDisconnected){t.log.debug(`skipping signal request (type: ${e.case}) - SignalClient disconnected`);return}if(!t.streamWriter){t.log.error(`cannot send signal request before connected, type: ${e?.case}`);return}let r=new jn({message:e});try{t.useJSON?yield t.streamWriter.write(r.toJsonString()):yield t.streamWriter.write(r.toBinary().buffer)}catch(e){t.log.error(`error sending signal message`,{error:e})}}()})}handleSignalResponse(e){let t=e.message;if(t==null){this.log.debug(`received unsupported message`);return}let n=!1;if(t.case===`answer`){let e=Fc(t.value);this.onAnswer&&this.onAnswer(e,t.value.id,t.value.midToTrackId)}else if(t.case===`offer`){let e=Fc(t.value);this.onOffer&&this.onOffer(e,t.value.id,t.value.midToTrackId)}else if(t.case===`trickle`){let e=JSON.parse(t.value.candidateInit);this.onTrickle&&this.onTrickle(e,t.value.target)}else t.case===`update`?this.onParticipantUpdate&&this.onParticipantUpdate(t.value.participants??[]):t.case===`trackPublished`?this.onLocalTrackPublished&&this.onLocalTrackPublished(t.value):t.case===`speakersChanged`?this.onSpeakersChanged&&this.onSpeakersChanged(t.value.speakers??[]):t.case===`leave`?this.onLeave&&this.onLeave(t.value):t.case===`mute`?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(t.value.sid,t.value.muted):t.case===`roomUpdate`?this.onRoomUpdate&&t.value.room&&this.onRoomUpdate(t.value.room):t.case===`connectionQuality`?this.onConnectionQuality&&this.onConnectionQuality(t.value):t.case===`streamStateUpdate`?this.onStreamStateUpdate&&this.onStreamStateUpdate(t.value):t.case===`subscribedQualityUpdate`?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(t.value):t.case===`subscriptionPermissionUpdate`?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(t.value):t.case===`refreshToken`?this.onTokenRefresh&&this.onTokenRefresh(t.value):t.case===`trackUnpublished`?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(t.value):t.case===`subscriptionResponse`?this.onSubscriptionError&&this.onSubscriptionError(t.value):t.case===`pong`||(t.case===`pongResp`?(this.rtt=Date.now()-Number.parseInt(t.value.lastPingTimestamp.toString()),this.resetPingTimeout(),n=!0):t.case===`requestResponse`?this.onRequestResponse&&this.onRequestResponse(t.value):t.case===`trackSubscribed`?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(t.value.trackSid):t.case===`roomMoved`?(this.onTokenRefresh&&this.onTokenRefresh(t.value.token),this.onRoomMoved&&this.onRoomMoved(t.value)):t.case===`mediaSectionsRequirement`?this.onMediaSectionsRequirement&&this.onMediaSectionsRequirement(t.value):t.case===`publishDataTrackResponse`?this.onPublishDataTrackResponse&&this.onPublishDataTrackResponse(t.value):t.case===`unpublishDataTrackResponse`?this.onUnPublishDataTrackResponse&&this.onUnPublishDataTrackResponse(t.value):t.case===`dataTrackSubscriberHandles`?this.onDataTrackSubscriberHandles&&this.onDataTrackSubscriberHandles(t.value):this.log.debug(`unsupported message`,{msgCase:t.case}));n||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){let e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return L(this,void 0,void 0,function*(){if(this.state===Mc.DISCONNECTED)return;let t=this.onClose;yield this.close(void 0,e),this.log.info(`websocket connection closed: ${e}`,{reason:e}),t&&t(e)})}handleWSError(e){this.log.error(`websocket error`,{error:e})}resetPingTimeout(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn(`ping timeout duration not set`);return}this.pingTimeout=Ha.setTimeout(()=>{this.log.warn(`ping timeout triggered. last pong received at: ${new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()}`),this.handleOnClose(`ping timeout`)},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&Ha.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn(`ping interval duration not set`);return}this.log.debug(`start ping interval`),this.pingInterval=Ha.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug(`clearing ping interval`),this.clearPingTimeout(),this.pingInterval&&Ha.clearInterval(this.pingInterval)}handleSignalConnected(e,t,n){this.state=Mc.CONNECTED,this.log.info(`signal connected`),clearTimeout(t),this.startPingInterval(),this.startReadingLoop(e.readable.getReader(),n)}validateFirstMessage(e,t){return e.message?.case===`join`?{isValid:!0,response:e.message.value}:this.state===Mc.RECONNECTING&&e.message?.case!==`leave`?e.message?.case===`reconnect`?{isValid:!0,response:e.message.value}:(this.log.debug(`declaring signal reconnected without reconnect response received`),{isValid:!0,response:void 0,shouldProcessFirstMessage:!0}):this.isEstablishingConnection&&e.message?.case===`leave`?{isValid:!1,error:R.leaveRequest(`Received leave request while trying to (re)connect`,e.message.value.reason)}:t?{isValid:!1,error:R.internal(`Unexpected first message`)}:{isValid:!1,error:R.internal(`did not receive join response, got ${e.message?.case} instead`)}}handleConnectionError(e,t){return L(this,void 0,void 0,function*(){try{let n=yield fetch(t);switch(n.status){case 404:let e=yield n.text();return e.includes(`requested room does not exist`)?R.notAllowed(e,n.status):R.serviceNotFound(`v1 RTC path not found. Consider upgrading your LiveKit server version`,`v0-rtc`);case 401:case 403:let t=yield n.text();return R.notAllowed(t,n.status);default:break}return e instanceof R?e:R.internal(`Encountered unknown websocket error during connection: ${e}`,{status:n.status,statusText:n.statusText})}catch(e){return e instanceof R?e:R.serverUnreachable(e instanceof Error?e.message:`server was not reachable`)}})}};function Fc(e){let t={type:`offer`,sdp:e.sdp};switch(e.type){case`answer`:case`offer`:case`pranswer`:case`rollback`:t.type=e.type;break}return t}function Ic(e,t){return new qn({sdp:e.sdp,type:e.type,id:t})}function Lc(e,t,n){let r=new URLSearchParams;return r.set(`access_token`,e),n.reconnect&&(r.set(`reconnect`,`1`),n.sid&&r.set(`sid`,n.sid)),r.set(`auto_subscribe`,n.autoSubscribe?`1`:`0`),r.set(`sdk`,Wo()?`reactnative`:`js`),r.set(`version`,t.version),r.set(`protocol`,t.protocol.toString()),r.set(`client_protocol`,t.clientProtocol.toString()),t.deviceModel&&r.set(`device_model`,t.deviceModel),t.os&&r.set(`os`,t.os),t.osVersion&&r.set(`os_version`,t.osVersion),t.browser&&r.set(`browser`,t.browser),t.browserVersion&&r.set(`browser_version`,t.browserVersion),n.adaptiveStream&&r.set(`adaptive_stream`,`1`),n.reconnectReason&&r.set(`reconnect_reason`,n.reconnectReason.toString()),navigator.connection?.type&&r.set(`network`,navigator.connection.type),r}function Rc(e,t,n,r){return L(this,void 0,void 0,function*(){let i=new URLSearchParams;i.set(`access_token`,e);let a=new Nr({clientInfo:t,connectionSettings:new Mr({autoSubscribe:!!n.autoSubscribe,adaptiveStream:!!n.adaptiveStream}),reconnect:!!n.reconnect,participantSid:n.sid?n.sid:void 0,publisherOffer:r});n.reconnectReason&&(a.reconnectReason=n.reconnectReason);let o=a.toBinary(),s,c;if(Os()){let e=new CompressionStream(`gzip`),t=e.writable.getWriter();t.write(new Uint8Array(o)),t.close();let n=[],r=e.readable.getReader();for(;;){let{done:e,value:t}=yield r.read();if(e)break;n.push(t)}let i=n.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),l=0;for(let e of n)a.set(e,l),l+=e.length;s=a,c=Fr.GZIP}else s=o,c=Fr.NONE;let l=new Pr({joinRequest:s,compression:c}).toBinary();return i.set(`join_request`,(e=>{let t=Array.from(e,e=>String.fromCodePoint(e)).join(``);return btoa(t)})(l).replace(/\+/g,`-`).replace(/\//g,`_`)),i})}var zc=class{constructor(){this.buffer=[],this._totalSize=0}push(e){this.buffer.push(e),this._totalSize+=e.data.byteLength}pop(){let e=this.buffer.shift();return e&&(this._totalSize-=e.data.byteLength),e}getAll(){return this.buffer.slice()}popToSequence(e){for(;this.buffer.length>0&&this.buffer[0].sequence<=e;)this.pop()}alignBufferedAmount(e){for(;this.buffer.length>0;){let t=this.buffer[0];if(this._totalSize-t.data.byteLength<=e)break;this.pop()}}get length(){return this.buffer.length}},Bc=class{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,t){let n=Date.now();n-this._lastCleanup>this.ttl/2&&this.cleanup();let r=n+this.ttl;return this._map.set(e,{value:t,expiresAt:r}),this}get(e){let t=this._map.get(e);if(t){if(t.expiresAt=Date.now()&&e(n.value,t,this.asValueMap())}map(e){this.cleanup();let t=[],n=this.asValueMap();for(let[r,i]of n.entries())t.push(e(i,r,n));return t}asValueMap(){let e=new Map;for(let[t,n]of this._map.entries())n.expiresAt>=Date.now()&&e.set(t,n.value);return e}},Vc={},Hc={},Uc={exports:{}},Wc;function Gc(){if(Wc)return Uc.exports;Wc=1;var e=Uc.exports={v:[{name:`version`,reg:/^(\d*)$/}],o:[{name:`origin`,reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:[`username`,`sessionId`,`sessionVersion`,`netType`,`ipVer`,`address`],format:`%s %s %d %s IP%d %s`}],s:[{name:`name`}],i:[{name:`description`}],u:[{name:`uri`}],e:[{name:`email`}],p:[{name:`phone`}],z:[{name:`timezones`}],r:[{name:`repeats`}],t:[{name:`timing`,reg:/^(\d*) (\d*)/,names:[`start`,`stop`],format:`%d %d`}],c:[{name:`connection`,reg:/^IN IP(\d) (\S*)/,names:[`version`,`ip`],format:`IN IP%d %s`}],b:[{push:`bandwidth`,reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:[`type`,`limit`],format:`%s:%s`}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:[`type`,`port`,`protocol`,`payloads`],format:`%s %d %s %s`}],a:[{push:`rtp`,reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:[`payload`,`codec`,`rate`,`encoding`],format:function(e){return e.encoding?`rtpmap:%d %s/%s/%s`:e.rate?`rtpmap:%d %s/%s`:`rtpmap:%d %s`}},{push:`fmtp`,reg:/^fmtp:(\d*) ([\S| ]*)/,names:[`payload`,`config`],format:`fmtp:%d %s`},{name:`control`,reg:/^control:(.*)/,format:`control:%s`},{name:`rtcp`,reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:[`port`,`netType`,`ipVer`,`address`],format:function(e){return e.address==null?`rtcp:%d`:`rtcp:%d %s IP%d %s`}},{push:`rtcpFbTrrInt`,reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:[`payload`,`value`],format:`rtcp-fb:%s trr-int %d`},{push:`rtcpFb`,reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:[`payload`,`type`,`subtype`],format:function(e){return e.subtype==null?`rtcp-fb:%s %s`:`rtcp-fb:%s %s %s`}},{push:`ext`,reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:[`value`,`direction`,`encrypt-uri`,`uri`,`config`],format:function(e){return`extmap:%d`+(e.direction?`/%s`:`%v`)+(e[`encrypt-uri`]?` %s`:`%v`)+` %s`+(e.config?` %s`:``)}},{name:`extmapAllowMixed`,reg:/^(extmap-allow-mixed)/},{push:`crypto`,reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:[`id`,`suite`,`config`,`sessionConfig`],format:function(e){return e.sessionConfig==null?`crypto:%d %s %s`:`crypto:%d %s %s %s`}},{name:`setup`,reg:/^setup:(\w*)/,format:`setup:%s`},{name:`connectionType`,reg:/^connection:(new|existing)/,format:`connection:%s`},{name:`mid`,reg:/^mid:([^\s]*)/,format:`mid:%s`},{name:`msid`,reg:/^msid:(.*)/,format:`msid:%s`},{name:`ptime`,reg:/^ptime:(\d*(?:\.\d*)*)/,format:`ptime:%d`},{name:`maxptime`,reg:/^maxptime:(\d*(?:\.\d*)*)/,format:`maxptime:%d`},{name:`direction`,reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:`icelite`,reg:/^(ice-lite)/},{name:`iceUfrag`,reg:/^ice-ufrag:(\S*)/,format:`ice-ufrag:%s`},{name:`icePwd`,reg:/^ice-pwd:(\S*)/,format:`ice-pwd:%s`},{name:`fingerprint`,reg:/^fingerprint:(\S*) (\S*)/,names:[`type`,`hash`],format:`fingerprint:%s %s`},{push:`candidates`,reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:[`foundation`,`component`,`transport`,`priority`,`ip`,`port`,`type`,`raddr`,`rport`,`tcptype`,`generation`,`network-id`,`network-cost`],format:function(e){var t=`candidate:%s %d %s %d %s %d typ %s`;return t+=e.raddr==null?`%v%v`:` raddr %s rport %d`,t+=e.tcptype==null?`%v`:` tcptype %s`,e.generation!=null&&(t+=` generation %d`),t+=e[`network-id`]==null?`%v`:` network-id %d`,t+=e[`network-cost`]==null?`%v`:` network-cost %d`,t}},{name:`endOfCandidates`,reg:/^(end-of-candidates)/},{name:`remoteCandidates`,reg:/^remote-candidates:(.*)/,format:`remote-candidates:%s`},{name:`iceOptions`,reg:/^ice-options:(\S*)/,format:`ice-options:%s`},{push:`ssrcs`,reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:[`id`,`attribute`,`value`],format:function(e){var t=`ssrc:%d`;return e.attribute!=null&&(t+=` %s`,e.value!=null&&(t+=`:%s`)),t}},{push:`ssrcGroups`,reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:[`semantics`,`ssrcs`],format:`ssrc-group:%s %s`},{name:`msidSemantic`,reg:/^msid-semantic:\s?(\w*) (\S*)/,names:[`semantic`,`token`],format:`msid-semantic: %s %s`},{push:`groups`,reg:/^group:(\w*) (.*)/,names:[`type`,`mids`],format:`group:%s %s`},{name:`rtcpMux`,reg:/^(rtcp-mux)/},{name:`rtcpRsize`,reg:/^(rtcp-rsize)/},{name:`sctpmap`,reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:[`sctpmapNumber`,`app`,`maxMessageSize`],format:function(e){return e.maxMessageSize==null?`sctpmap:%s %s`:`sctpmap:%s %s %s`}},{name:`xGoogleFlag`,reg:/^x-google-flag:([^\s]*)/,format:`x-google-flag:%s`},{push:`rids`,reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:[`id`,`direction`,`params`],format:function(e){return e.params?`rid:%s %s %s`:`rid:%s %s`}},{push:`imageattrs`,reg:RegExp(`^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?`),names:[`pt`,`dir1`,`attrs1`,`dir2`,`attrs2`],format:function(e){return`imageattr:%s %s %s`+(e.dir2?` %s %s`:``)}},{name:`simulcast`,reg:RegExp(`^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$`),names:[`dir1`,`list1`,`dir2`,`list2`],format:function(e){return`simulcast:%s %s`+(e.dir2?` %s %s`:``)}},{name:`simulcast_03`,reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:[`value`],format:`simulcast: %s`},{name:`framerate`,reg:/^framerate:(\d+(?:$|\.\d+))/,format:`framerate:%s`},{name:`sourceFilter`,reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:[`filterMode`,`netType`,`addressTypes`,`destAddress`,`srcList`],format:`source-filter: %s %s %s %s %s`},{name:`bundleOnly`,reg:/^(bundle-only)/},{name:`label`,reg:/^label:(.+)/,format:`label:%s`},{name:`sctpPort`,reg:/^sctp-port:(\d+)$/,format:`sctp-port:%s`},{name:`maxMessageSize`,reg:/^max-message-size:(\d+)$/,format:`max-message-size:%s`},{push:`tsRefClocks`,reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:[`clksrc`,`clksrcExt`],format:function(e){return`ts-refclk:%s`+(e.clksrcExt==null?``:`=%s`)}},{name:`mediaClk`,reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:[`id`,`mediaClockName`,`mediaClockValue`,`rateNumerator`,`rateDenominator`],format:function(e){var t=`mediaclk:`;return t+=e.id==null?`%v%s`:`id=%s %s`,t+=e.mediaClockValue==null?``:`=%s`,t+=e.rateNumerator==null?``:` rate=%s`,t+=e.rateDenominator==null?``:`/%s`,t}},{name:`keywords`,reg:/^keywds:(.+)$/,format:`keywds:%s`},{name:`content`,reg:/^content:(.+)/,format:`content:%s`},{name:`bfcpFloorCtrl`,reg:/^floorctrl:(c-only|s-only|c-s)/,format:`floorctrl:%s`},{name:`bfcpConfId`,reg:/^confid:(\d+)/,format:`confid:%s`},{name:`bfcpUserId`,reg:/^userid:(\d+)/,format:`userid:%s`},{name:`bfcpFloorId`,reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:[`id`,`mStream`],format:`floorid:%s mstrm:%s`},{push:`invalid`,names:[`value`]}]};return Object.keys(e).forEach(function(t){e[t].forEach(function(e){e.reg||=/(.*)/,e.format||=`%s`})}),Uc.exports}var Kc;function qc(){return Kc?Hc:(Kc=1,(function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(` `).map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(` `).map(t),i=0;i=i)return e;var t=r[n];switch(n+=1,e){case`%%`:return`%`;case`%s`:return String(t);case`%d`:return Number(t);case`%v`:return``}})},r=function(e,t,r){var i=t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format,a=[e+`=`+i];if(t.names)for(var o=0;o1&&arguments[1]!==void 0?arguments[1]:{};super(),this.log=I,this.ddExtID=0,this.latestOfferId=0,this.latestAcknowledgedOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=Qs(e=>L(this,void 0,void 0,function*(){this.emit(nl.NegotiationStarted);try{yield this.createAndSendOffer()}catch(t){if(e)e(t);else throw t}}),tl),this.close=()=>{this._pc&&=(this.pendingInitialOffer=void 0,this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,null)},this.log=Gr(t.loggerName??Wr.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC(),this.offerLock=new i}createPC(){let e=new RTCPeerConnection(this.config);return e.onicecandidate=e=>{var t;e.candidate&&((t=this.onIceCandidate)==null||t.call(this,e.candidate))},e.onicecandidateerror=e=>{var t;(t=this.onIceCandidateError)==null||t.call(this,e)},e.oniceconnectionstatechange=()=>{var t;(t=this.onIceConnectionStateChange)==null||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;(t=this.onSignalingStatechange)==null||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;(t=this.onConnectionStateChange)==null||t.call(this,e.connectionState)},e.ondatachannel=e=>{var t;(t=this.onDataChannel)==null||t.call(this,e)},e.ontrack=e=>{var t;(t=this.onTrack)==null||t.call(this,e)},e}get logContext(){var e;return Object.assign({},(e=this.loggerOptions).loggerContextCb?.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState===`connected`||this.pc.iceConnectionState===`completed`)}addIceCandidate(e){return L(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e,t){return L(this,void 0,void 0,function*(){if(e.type===`answer`&&this.latestOfferId>0&&t>0&&t!==this.latestOfferId)return this.log.warn(`ignoring answer for old offer`,Object.assign(Object.assign({},this.logContext),{offerId:t,latestOfferId:this.latestOfferId})),!1;let n;if(e.type===`offer`){let{stereoMids:t,nackMids:n}=al(e);this.remoteStereoMids=t,this.remoteNackMids=n}else if(e.type===`answer`){if(this.pendingInitialOffer&&this._pc){let e=this.pendingInitialOffer;this.pendingInitialOffer=void 0;let t=$c.parse(e.sdp??``);t.media.forEach(e=>{ol(e)}),this.log.debug(`setting pending initial offer before processing answer`,this.logContext),yield this.setMungedSDP(e,$c.write(t))}let t=$c.parse(e.sdp??``);t.media.forEach(e=>{let t=sl(e.mid);e.type===`audio`&&this.trackBitrates.some(n=>{if(!n.transceiver||t!=n.transceiver.mid)return!1;let r=0;if(e.rtp.some(e=>e.codec.toUpperCase()===n.codec.toUpperCase()?(r=e.payload,!0):!1),r===0)return!0;let i=!1;for(let t of e.fmtp)if(t.payload===r){t.config=t.config.split(`;`).filter(e=>!e.includes(`maxaveragebitrate`)).join(`;`),n.maxbr>0&&(t.config+=`;maxaveragebitrate=${n.maxbr*1e3}`),i=!0;break}return i||n.maxbr>0&&e.fmtp.push({payload:r,config:`maxaveragebitrate=${n.maxbr*1e3}`}),!0})}),n=$c.write(t)}return yield this.setMungedSDP(e,n,!0),this.pendingCandidates.forEach(e=>{this.pc.addIceCandidate(e)}),this.pendingCandidates=[],this.restartingIce=!1,e.type===`answer`&&(this.latestAcknowledgedOfferId=t,this.emit(nl.OfferAnswered,t)),this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type===`answer`&&(this.emit(nl.NegotiationComplete),e.sdp&&$c.parse(e.sdp).media.forEach(e=>{e.type===`video`&&this.emit(nl.RTPVideoPayloadTypes,e.rtp)})),!0})}createInitialOffer(){return L(this,void 0,void 0,function*(){let e=yield this.offerLock.lock();try{if(this.pc.signalingState!==`stable`){this.log.warn(`signaling state is not stable, cannot create initial offer`,this.logContext);return}let e=this.latestOfferId+1;this.latestOfferId=e;let t=yield this.pc.createOffer();this.pendingInitialOffer={sdp:t.sdp,type:t.type};let n=$c.parse(t.sdp??``);return n.media.forEach(e=>{ol(e)}),t.sdp=$c.write(n),{offer:t,offerId:e}}finally{e()}})}createAndSendOffer(e){return L(this,void 0,void 0,function*(){let t=yield this.offerLock.lock();try{if(this.onOffer===void 0)return;if(e?.iceRestart&&(this.log.debug(`restarting ICE`,this.logContext),this.restartingIce=!0),this._pc&&(this._pc.signalingState===`have-local-offer`||this.pendingInitialOffer)){let t=this._pc.remoteDescription;if(e?.iceRestart&&t)yield this._pc.setRemoteDescription(t);else{this.renegotiate=!0,this.log.debug(`requesting renegotiation`,Object.assign({},this.logContext));return}}else if(!this._pc||this._pc.signalingState===`closed`){this.log.warn(`could not createOffer with closed peer connection`,this.logContext);return}this.log.debug(`starting to negotiate`,this.logContext);let t=this.latestOfferId+1;this.latestOfferId=t;let n=yield this.pc.createOffer(e);this.log.debug(`original offer`,Object.assign({sdp:n.sdp},this.logContext));let r=$c.parse(n.sdp??``);if(r.media.forEach(e=>{ol(e),e.type===`audio`?il(e,[`all`],[]):e.type===`video`&&this.trackBitrates.some(t=>{if(!e.msid||!t.cid||!e.msid.includes(t.cid))return!1;let n=0;if(e.rtp.some(e=>e.codec.toUpperCase()===t.codec.toUpperCase()?(n=e.payload,!0):!1),n===0||(jo(t.codec)&&!Lo()&&this.ensureVideoDDExtensionForSVC(e,r),!jo(t.codec)))return!0;let i=Math.round(t.maxbr*el);for(let t of e.fmtp)if(t.payload===n){t.config.includes(`x-google-start-bitrate`)||(t.config+=`;x-google-start-bitrate=${i}`);break}return!0})}),this.latestOfferId>t){this.log.warn(`latestOfferId mismatch`,Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:t}));return}yield this.setMungedSDP(n,$c.write(r)),this.onOffer(n,this.latestOfferId)}finally{t()}})}createAndSetAnswer(){return L(this,void 0,void 0,function*(){let e=yield this.pc.createAnswer(),t=$c.parse(e.sdp??``);return t.media.forEach(e=>{ol(e),e.type===`audio`&&il(e,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(e,$c.write(t)),e})}createDataChannel(e,t){return this.pc.createDataChannel(e,t)}addTransceiver(e,t){return this.pc.addTransceiver(e,t)}addTransceiverOfKind(e,t){return this.pc.addTransceiver(e,t)}addTrack(e){if(!this._pc)throw new Pa(`PC closed, cannot add track`);return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){if(!this._pc)throw new Pa(`PC closed, cannot configure`);return this._pc?.setConfiguration(e)}canRemoveTrack(){return!!this._pc?.removeTrack}removeTrack(e){return this._pc?.removeTrack(e)}getConnectionState(){return this._pc?.connectionState??`closed`}getICEConnectionState(){return this._pc?.iceConnectionState??`closed`}getSignallingState(){return this._pc?.signalingState??`closed`}getTransceivers(){return this._pc?.getTransceivers()??[]}getSenders(){return this._pc?.getSenders()??[]}getLocalDescription(){return this._pc?.localDescription}getRemoteDescription(){return this.pc?.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return L(this,void 0,void 0,function*(){if(!this._pc)return;let e=``,t=new Map,n=new Map;if((yield this._pc.getStats()).forEach(r=>{switch(r.type){case`transport`:e=r.selectedCandidatePairId;break;case`candidate-pair`:e===``&&r.selected&&(e=r.id),t.set(r.id,r);break;case`remote-candidate`:n.set(r.id,`${r.address}:${r.port}`);break}}),e===``)return;let r=t.get(e)?.remoteCandidateId;if(r!==void 0)return n.get(r)})}setMungedSDP(e,t,n){return L(this,void 0,void 0,function*(){let r=e.sdp;if(t){e.sdp=t;try{this.log.debug(`setting munged ${n?`remote`:`local`} description`,this.logContext),n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(n){this.log.warn(`not able to set ${e.type}, falling back to unmodified sdp`,Object.assign(Object.assign({},this.logContext),{error:n,mungedSdp:t,originalSdp:r})),e.sdp=r}}try{n?yield this._pc?.setRemoteDescription(e):yield this._pc?.setLocalDescription(e)}catch(i){let a=`unknown error`;i instanceof Error?a=i.message:typeof i==`string`&&(a=i);let o={error:a,sdp:e.sdp};throw t&&t!==r&&(o.mungedSdp=t),!n&&this.pc.remoteDescription&&(o.remoteSdp=this.pc.remoteDescription),this.log.error(`unable to set ${e.type}`,Object.assign(Object.assign({},this.logContext),{fields:o})),new Fa(a)}})}ensureVideoDDExtensionForSVC(e,t){var n;if(!e.ext?.some(e=>e.uri===wo)){if(this.ddExtID===0){let e=0;t.media.forEach(t=>{var n;(n=t.ext)==null||n.forEach(t=>{t.value>e&&(e=t.value)})}),this.ddExtID=e+1}(n=e.ext)==null||n.push({value:this.ddExtID,uri:wo})}}};function il(e,t,n){let r=sl(e.mid),i=0;e.rtp.some(e=>e.codec===`opus`?(i=e.payload,!0):!1),i>0&&(e.rtcpFb||=[],n.includes(r)&&!e.rtcpFb.some(e=>e.payload===i&&e.type===`nack`)&&e.rtcpFb.push({payload:i,type:`nack`}),(t.includes(r)||t.length===1&&t[0]===`all`)&&e.fmtp.some(e=>e.payload===i?(e.config.includes(`stereo=1`)||(e.config+=`;stereo=1`),!0):!1))}function al(e){let t=[],n=[],r=$c.parse(e.sdp??``),i=0;return r.media.forEach(e=>{let r=sl(e.mid);e.type===`audio`&&(e.rtp.some(e=>e.codec===`opus`?(i=e.payload,!0):!1),e.rtcpFb?.some(e=>e.payload===i&&e.type===`nack`)&&n.push(r),e.fmtp.some(e=>e.payload===i?(e.config.includes(`sprop-stereo=1`)&&t.push(r),!0):!1))}),{stereoMids:t,nackMids:n}}function ol(e){if(e.connection){let t=e.connection.ip.indexOf(`:`)>=0;(e.connection.version===4&&t||e.connection.version===6&&!t)&&(e.connection.ip=`0.0.0.0`,e.connection.version=4)}}function sl(e){return typeof e==`number`?e.toFixed(0):e}var cl=`vp8`,ll={audioPreset:Xa.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:$a.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:cl,backupCodec:!0,preConnectBuffer:!1},ul={deviceId:{ideal:`default`},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},dl={deviceId:{ideal:`default`},resolution:Za.h720.resolution},fl={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new Xr,disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},pl={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3},ml;(function(e){e[e.NEW=0]=`NEW`,e[e.CONNECTING=1]=`CONNECTING`,e[e.CONNECTED=2]=`CONNECTED`,e[e.FAILED=3]=`FAILED`,e[e.CLOSING=4]=`CLOSING`,e[e.CLOSED=5]=`CLOSED`})(ml||={});var hl=class{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}get mode(){return this._mode}constructor(e,t,n){this.peerConnectionTimeout=pl.peerConnectionTimeout,this.log=I,this.updateState=()=>{var e;let t=this.state,n=this.requiredTransports.map(e=>e.getConnectionState());n.every(e=>e===`connected`)?this.state=ml.CONNECTED:n.some(e=>e===`failed`)?this.state=ml.FAILED:n.some(e=>e===`connecting`)?this.state=ml.CONNECTING:n.every(e=>e===`closed`)?this.state=ml.CLOSED:n.some(e=>e===`closed`)?this.state=ml.CLOSING:n.every(e=>e===`new`)&&(this.state=ml.NEW),t!==this.state&&(this.log.debug(`pc state change: from ${ml[t]} to ${ml[this.state]}`,this.logContext),(e=this.onStateChange)==null||e.call(this,this.state,this.publisher.getConnectionState(),this.subscriber?.getConnectionState()))},this.log=Gr(t.loggerName??Wr.PCManager),this.loggerOptions=t,this.isPublisherConnectionRequired=e!==`subscriber-primary`,this.isSubscriberConnectionRequired=e===`subscriber-primary`,this.publisher=new rl(n,t),this._mode=e,e!==`publisher-only`&&(this.subscriber=new rl(n,t),this.subscriber.onConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.subscriber.onIceCandidate=e=>{var t;(t=this.onIceCandidate)==null||t.call(this,e,On.SUBSCRIBER)},this.subscriber.onDataChannel=e=>{var t;(t=this.onDataChannel)==null||t.call(this,e)},this.subscriber.onTrack=e=>{var t;(t=this.onTrack)==null||t.call(this,e)}),this.publisher.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=e=>{var t;(t=this.onIceCandidate)==null||t.call(this,e,On.PUBLISHER)},this.publisher.onTrack=e=>{var t;(t=this.onTrack)==null||t.call(this,e)},this.publisher.onOffer=(e,t)=>{var n;(n=this.onPublisherOffer)==null||n.call(this,e,t)},this.state=ml.NEW,this.connectionLock=new i,this.remoteOfferLock=new i}get logContext(){var e;return Object.assign({},(e=this.loggerOptions).loggerContextCb?.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e,t){return this.publisher.setRemoteDescription(e,t)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return L(this,void 0,void 0,function*(){if(this.publisher&&this.publisher.getSignallingState()!==`closed`){let e=this.publisher;for(let t of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(t)}catch(e){this.log.warn(`could not removeTrack`,Object.assign(Object.assign({},this.logContext),{error:e}))}}yield Promise.all([this.publisher.close(),this.subscriber?.close()]),this.updateState()})}triggerIceRestart(){return L(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return L(this,void 0,void 0,function*(){t===On.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber?.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,t){return L(this,void 0,void 0,function*(){this.log.debug(`received server offer`,Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber?.getSignallingState().toString()}));let n=yield this.remoteOfferLock.lock();try{return(yield this.subscriber?.setRemoteDescription(e,t))?yield this.subscriber?.createAndSetAnswer():void 0}finally{n()}})}updateConfiguration(e,t){var n;this.publisher.setConfiguration(e),(n=this.subscriber)==null||n.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){return L(this,void 0,void 0,function*(){let n=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!==`connected`&&this.publisher.getConnectionState()!==`connecting`&&(this.log.debug(`negotiation required, start negotiating`,this.logContext),this.publisher.negotiate()),yield Promise.all(this.requiredTransports?.map(n=>this.ensureTransportConnected(n,e,t)))}finally{n()}})}negotiate(e){return L(this,void 0,void 0,function*(){return new ba((t,n)=>{let r=this.publisher.latestOfferId;if(this.publisher.latestAcknowledgedOfferId>r){this.log.debug(`negotiation already handled in more recent acknowledged offer`,this.logContext),t();return}let i=!1,a=()=>{i||(i=!0,clearTimeout(c),this.publisher.off(nl.OfferAnswered,o),e.signal.removeEventListener(`abort`,s))},o=e=>{e>r&&(a(),t())},s=()=>{a(),n(new Fa(`negotiation aborted`))},c=setTimeout(()=>{a(),n(new Fa(`negotiation timed out`))},this.peerConnectionTimeout);e.signal.addEventListener(`abort`,s),this.publisher.on(nl.OfferAnswered,o),this.publisher.negotiate(e=>{a(),e instanceof Error?n(e):n(Error(String(e)))})})})}addPublisherTransceiver(e,t){return this.publisher.addTransceiver(e,t)}addPublisherTransceiverOfKind(e,t){return this.publisher.addTransceiverOfKind(e,t)}getMidForReceiver(e){return(this.subscriber?this.subscriber.getTransceivers():this.publisher.getTransceivers()).find(t=>t.receiver===e)?.mid}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,t){return this.publisher.createDataChannel(e,t)}getConnectedAddress(e){return e===On.PUBLISHER||e===On.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){let e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&this.subscriber&&e.push(this.subscriber),e}ensureTransportConnected(e,t){return L(this,arguments,void 0,function(e,t){var n=this;let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(e.getConnectionState()!==`connected`)return new Promise((e,i)=>L(n,void 0,void 0,function*(){let n=()=>{this.log.warn(`abort transport connection`,this.logContext),Ha.clearTimeout(a),i(R.cancelled(`room connection has been cancelled`))};t?.signal.aborted&&n(),t?.signal.addEventListener(`abort`,n);let a=Ha.setTimeout(()=>{t?.signal.removeEventListener(`abort`,n),i(R.internal(`could not establish pc connection`))},r);for(;this.state!==ml.CONNECTED;)if(yield Eo(50),t?.signal.aborted){i(R.cancelled(`room connection has been cancelled`));return}Ha.clearTimeout(a),t?.signal.removeEventListener(`abort`,n),e()}))}()})}},gl=typeof MediaRecorder<`u`,_l=gl?MediaRecorder:class{constructor(){throw Error(`MediaRecorder is not available in this environment`)}},vl=class extends _l{constructor(e,t){if(!gl)throw Error(`MediaRecorder is not available in this environment`);super(new MediaStream([e.mediaStreamTrack]),t);let n,r,i=()=>r===void 0,a=()=>{this.removeEventListener(`dataavailable`,n),this.removeEventListener(`stop`,a),this.removeEventListener(`error`,o),r?.close(),r=void 0},o=e=>{r?.error(e),this.removeEventListener(`dataavailable`,n),this.removeEventListener(`stop`,a),this.removeEventListener(`error`,o),r=void 0};this.byteStream=new ReadableStream({start:e=>{r=e,n=t=>L(this,void 0,void 0,function*(){let n;if(t.data.arrayBuffer){let e=yield t.data.arrayBuffer();n=new Uint8Array(e)}else if(t.data.byteArray)n=t.data.byteArray;else throw Error(`no data available!`);i()||e.enqueue(n)}),this.addEventListener(`dataavailable`,n)},cancel:()=>{a()}}),this.addEventListener(`stop`,a),this.addEventListener(`error`,o)}};function yl(){return gl}var bl=1e3,xl=1e4,Sl=class extends U{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,a=arguments.length>4?arguments[4]:void 0;super(e,t,a),this.manuallyStopped=!1,this.pendingDeviceChange=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug(`track mute bounce got cancelled by an unmute event`,this.logContext)),this.debouncedTrackMuteHandler=Qs(()=>L(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>L(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel(`unmute`),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener(`mute`,this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener(`unmute`,this.handleTrackUnmuteEvent),this.emit(H.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new i,this.pauseUpstreamLock=new i,this.trackChangeLock=new i,this.trackChangeLock.lock().then(t=>L(this,void 0,void 0,function*(){try{yield this.setMediaStreamTrack(e,!0)}finally{t()}})),this._constraints=e.getConstraints(),n&&(this._constraints=n)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==U.Kind.Video)return;let{width:e,height:t}=this._mediaStreamTrack.getSettings();if(e&&t)return{width:e,height:t}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){return this.processor?.processedTrack??this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,t,n){return L(this,void 0,void 0,function*(){if(e===this._mediaStreamTrack&&!t)return;this._mediaStreamTrack&&(this.attachedElements.forEach(e=>{So(this._mediaStreamTrack,e)}),this.debouncedTrackMuteHandler.cancel(`new-track`),this._mediaStreamTrack.removeEventListener(`ended`,this.handleEnded),this._mediaStreamTrack.removeEventListener(`mute`,this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener(`unmute`,this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener(`ended`,this.handleEnded),e.addEventListener(`mute`,this.handleTrackMuteEvent),e.addEventListener(`unmute`,this.handleTrackUnmuteEvent),this._constraints=e.getConstraints());let r;if(this.processor&&e){if(this.log.debug(`restarting processor`,this.logContext),this.kind===`unknown`)throw TypeError(`cannot set processor on track of unknown kind`);this.processorElement&&(xo(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement,localTrack:this}),r=this.processor.processedTrack}this.sender&&this.sender.transport?.state!==`closed`&&(yield this.sender.replaceTrack(r??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=n?!0:!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(t=>{xo(r??e,t)}))})}waitForDimensions(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bl;return function*(){if(e.kind===U.Kind.Audio)throw Error(`cannot get dimensions for audio tracks`);Ca()?.os===`iOS`&&(yield Eo(10));let n=Date.now();for(;Date.now()-n0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===U.Source.ScreenShare)return;let{deviceId:n,groupId:r}=e._mediaStreamTrack.getSettings(),i=e.kind===U.Kind.Audio?`audioinput`:`videoinput`;return t?hc.getInstance().normalizeDeviceId(i,n,r):n}()})}mute(){return L(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return L(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return L(this,void 0,void 0,function*(){let n=yield this.trackChangeLock.lock();try{if(!this.sender)throw new Ma(`unable to replace an unpublished track`);let n,r;typeof t==`boolean`?n=t:t!==void 0&&(n=t.userProvidedTrack,r=t.stopProcessor),this.providedByUser=n??!0,this.log.debug(`replace MediaStreamTrack`,this.logContext),yield this.setMediaStreamTrack(e),r&&this.processor&&(yield this.internalStopProcessor())}finally{n()}return yield this.onSenderTrackSwapped(),this})}onSenderTrackSwapped(){return L(this,void 0,void 0,function*(){})}restart(e,t){return L(this,void 0,void 0,function*(){this.manuallyStopped=!1;let n=yield this.trackChangeLock.lock();try{e||=this._constraints;let{deviceId:n,facingMode:r}=e,i=Zr(e,[`deviceId`,`facingMode`]);this.log.debug(`restarting track with constraints`,Object.assign(Object.assign({},this.logContext),{constraints:e}));let a={audio:!1,video:!1};this.kind===U.Kind.Video?a.video=n||r?{deviceId:n,facingMode:r}:!0:a.audio=n?Object.assign({deviceId:n},i):!0,this.attachedElements.forEach(e=>{So(this.mediaStreamTrack,e)}),this._mediaStreamTrack.removeEventListener(`ended`,this.handleEnded),this._mediaStreamTrack.stop();let o=(yield navigator.mediaDevices.getUserMedia(a)).getTracks()[0];return this.kind===U.Kind.Video&&(yield o.applyConstraints(i)),o.addEventListener(`ended`,this.handleEnded),this.log.debug(`re-acquired MediaStreamTrack`,this.logContext),yield this.setMediaStreamTrack(o,!1,t),this._constraints=e,this.pendingDeviceChange=!1,this.emit(H.Restarted,this),this.manuallyStopped&&(this.log.warn(`track was stopped during a restart, stopping restarted track`,this.logContext),this.stop()),this}finally{n()}})}setTrackMuted(e){this.log.debug(`setting ${this.kind} track ${e?`muted`:`unmuted`}`,this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?H.Muted:H.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!==`live`||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){let e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return L(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Vo()&&(this.log.debug(`visibility changed, is in Background: ${this.isInBackground}`,this.logContext),!this.isInBackground&&this.needsReAcquisition&&!this.isUserProvided&&!this.isMuted&&(this.log.debug(`track needs to be reacquired, restarting ${this.source}`,this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener(`ended`,this.handleEnded),this._mediaStreamTrack.removeEventListener(`mute`,this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener(`unmute`,this.handleTrackUnmuteEvent),(e=this.processor)==null||e.destroy(),this.processor=void 0}pauseUpstream(){return L(this,void 0,void 0,function*(){let e=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn(`unable to pause upstream for an unpublished track`,this.logContext);return}this._isUpstreamPaused=!0,this.emit(H.UpstreamPaused,this);let e=Ca();if(e?.name===`Safari`&&Xo(e.version,`12.0`)<0)throw new ja(`pauseUpstream is not supported on Safari < 12.`);this.sender.transport?.state!==`closed`&&(yield this.sender.replaceTrack(null))}finally{e()}})}resumeUpstream(){return L(this,void 0,void 0,function*(){let e=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn(`unable to resume upstream for an unpublished track`,this.logContext);return}this._isUpstreamPaused=!1,this.emit(H.UpstreamResumed,this),this.sender.transport?.state!==`closed`&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{e()}})}getRTCStatsReport(){return L(this,void 0,void 0,function*(){if(this.sender?.getStats)return yield this.sender.getStats()})}setProcessor(e){return L(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){let r=yield t.trackChangeLock.lock();try{t.log.debug(`setting up processor`,t.logContext);let r=document.createElement(t.kind),i={kind:t.kind,track:t._mediaStreamTrack,element:r,audioContext:t.audioContext,localTrack:t};if(yield e.init(i),t.log.debug(`processor initialized`,t.logContext),t.processor&&(yield t.internalStopProcessor()),t.kind===`unknown`)throw TypeError(`cannot set processor on track of unknown kind`);if(xo(t._mediaStreamTrack,r),r.muted=!0,r.play().catch(e=>{e instanceof DOMException&&e.name===`AbortError`?(t.log.warn(`failed to play processor element, retrying`,Object.assign(Object.assign({},t.logContext),{error:e})),setTimeout(()=>{r.play().catch(e=>{t.log.error(`failed to play processor element`,Object.assign(Object.assign({},t.logContext),{err:e}))})},100)):t.log.error(`failed to play processor element`,Object.assign(Object.assign({},t.logContext),{error:e}))}),t.processor=e,t.processorElement=r,t.processor.processedTrack){for(let e of t.attachedElements)e!==t.processorElement&&n&&(So(t._mediaStreamTrack,e),xo(t.processor.processedTrack,e));yield t.sender?.replaceTrack(t.processor.processedTrack)}t.emit(H.TrackProcessorUpdate,t.processor)}finally{r()}yield t.onSenderTrackSwapped()}()})}getProcessor(){return this.processor}stopProcessor(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){let n=yield e.trackChangeLock.lock();try{yield e.internalStopProcessor(t)}finally{n()}yield e.onSenderTrackSwapped()}()})}internalStopProcessor(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var n,r;e.processor&&(e.log.debug(`stopping processor`,e.logContext),(n=e.processor.processedTrack)==null||n.stop(),yield e.processor.destroy(),e.processor=void 0,t||((r=e.processorElement)==null||r.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(H.TrackProcessorUpdate))}()})}startPreConnectBuffer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!yl()){this.log.warn(`MediaRecorder is not available, cannot start preconnect buffer`,this.logContext);return}if(this.localTrackRecorder){this.log.warn(`preconnect buffer already started`);return}else{let e=`audio/webm;codecs=opus`;MediaRecorder.isTypeSupported(e)||(e=`video/mp4`),this.localTrackRecorder=new vl(this,{mimeType:e})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn(`preconnect buffer timed out, stopping recording automatically`,this.logContext),this.stopPreConnectBuffer()},xl)}stopPreConnectBuffer(){clearTimeout(this.autoStopPreConnectBuffer),this.localTrackRecorder&&=(this.localTrackRecorder.stop(),void 0)}getPreConnectBuffer(){return this.localTrackRecorder?.byteStream}getPreConnectBufferMimeType(){return this.localTrackRecorder?.mimeType}},Cl=class extends Sl{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;super(e,U.Kind.Audio,t,n,i),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>L(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let e;try{e=yield this.getSenderStats()}catch(e){this.log.error(`could not get audio sender stats`,Object.assign(Object.assign({},this.logContext),{error:e}));return}e&&this.prevStats&&(this._currentBitrate=ec(e,this.prevStats)),this.prevStats=e}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug(`Krisp noise filter enabled`,this.logContext),this.emit(H.AudioTrackFeatureUpdate,this,Nt.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug(`Krisp noise filter disabled`,this.logContext),this.emit(H.AudioTrackFeatureUpdate,this,Nt.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=r,this.checkForSilence()}mute(){let e=Object.create(null,{mute:{get:()=>super.mute}});return L(this,void 0,void 0,function*(){let t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug(`Track already muted`,this.logContext),this):(this.source===U.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug(`stopping mic track`,this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){let e=Object.create(null,{unmute:{get:()=>super.unmute}});return L(this,void 0,void 0,function*(){let t=yield this.muteLock.lock();try{return this.isMuted?(this.source===U.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState===`ended`||this.pendingDeviceChange)&&!this.isUserProvided&&(this.log.debug(`reacquiring mic track`,this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug(`Track already unmuted`,this.logContext),this)}finally{t()}})}restartTrack(e){return L(this,void 0,void 0,function*(){let t;if(e){let n=no({audio:e});typeof n.audio!=`boolean`&&(t=n.audio)}yield this.restart(t)})}restart(e,t){let n=Object.create(null,{restart:{get:()=>super.restart}});return L(this,void 0,void 0,function*(){let r=yield n.restart.call(this,e,t);return this.checkForSilence(),r})}startMonitor(){Uo()&&(this.monitorInterval||=setInterval(()=>{this.monitorSender()},$s))}setProcessor(e){return L(this,void 0,void 0,function*(){let t=yield this.trackChangeLock.lock();try{if(!Wo()&&!this.audioContext)throw Error(`Audio context needs to be set on LocalAudioTrack in order to enable processors`);this.processor&&(yield this.internalStopProcessor());let t={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext,localTrack:this};this.log.debug(`setting up audio processor ${e.name}`,this.logContext),yield e.init(t),this.processor=e,this.processor.processedTrack&&(yield this.sender?.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener(`enable-lk-krisp-noise-filter`,this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener(`disable-lk-krisp-noise-filter`,this.handleKrispNoiseFilterDisable)),this.emit(H.TrackProcessorUpdate,this.processor)}finally{t()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return L(this,void 0,void 0,function*(){if(!this.sender?.getStats)return;let e=yield this.sender.getStats(),t;return e.forEach(e=>{e.type===`outbound-rtp`&&(t={type:`audio`,streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})}),t})}checkForSilence(){return L(this,void 0,void 0,function*(){let e=yield ro(this);return e&&(this.isMuted||this.log.debug(`silence detected on local audio track`,this.logContext),this.emit(H.AudioSilenceDetected)),e})}};function wl(e,t,n){switch(e.kind){case`audio`:return new Cl(e,t,!1,void 0,n);case`video`:return new Hl(e,t,!1,n);default:throw new Ma(`unsupported track type: ${e.kind}`)}}var Tl=Object.values(Za),El=Object.values(Qa),Dl=Object.values($a),Ol=[Za.h180,Za.h360],kl=[Qa.h180,Qa.h360],Al=e=>[{scaleResolutionDownBy:2,fps:e.encoding.maxFramerate}].map(t=>new Wa(Math.floor(e.width/t.scaleResolutionDownBy),Math.floor(e.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(e.encoding.maxBitrate/(t.scaleResolutionDownBy**2*((e.encoding.maxFramerate??30)/(t.fps??30))))),t.fps,e.encoding.priority)),jl=[`q`,`h`,`f`];function Ml(e,t,n,r){let i=r?.videoEncoding;e&&(i=r?.screenShareEncoding);let a=r?.simulcast,o=r?.scalabilityMode,s=r?.videoCodec;if(!i&&!a&&!o||!t||!n)return[{}];i||(i=Pl(e,t,n,s),I.debug(`using video encoding`,i));let c=i.maxFramerate,l=new Wa(t,n,i.maxBitrate,i.maxFramerate,i.priority);if(o&&jo(s)){let e=new zl(o),t=[];if(e.spatial>3)throw Error(`unsupported scalabilityMode: ${o}`);let n=Ca();if(Ro()||Wo()||n?.name===`Chrome`&&Xo(n?.version,`113`)<0){let r=e.suffix==`h`?2:3,a=Bo(n);for(let n=0;n0){let e=u[0];u.length>1&&([,d]=u);let r=Math.max(t,n);if(r>=960&&d)return Ll(t,n,[e,d,l],c);if(r>=480)return Ll(t,n,[e,l],c)}return Ll(t,n,[l])}function Nl(e,t,n){if(!n.backupCodec||n.backupCodec===!0||n.backupCodec.codec===n.videoCodec)return;t!==n.backupCodec.codec&&I.warn(`requested a different codec than specified as backup`,{serverRequested:t,backup:n.backupCodec.codec}),n.videoCodec=t,n.videoEncoding=n.backupCodec.encoding;let r=e.mediaStreamTrack.getSettings(),i=r.width??e.dimensions?.width,a=r.height??e.dimensions?.height;return e.source===U.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),Ml(e.source===U.Source.ScreenShare,i,a,n)}function Pl(e,t,n,r){let i=Fl(e,t,n),{encoding:a}=i[0],o=Math.max(t,n);for(let e=0;e=o)break}if(r)switch(r){case`av1`:case`h265`:a=Object.assign({},a),a.maxBitrate*=.7;break;case`vp9`:a=Object.assign({},a),a.maxBitrate*=.85;break}return a}function Fl(e,t,n){if(e)return Dl;let r=t>n?t/n:n/t;return Math.abs(r-16/9)r?n/r:r/n;return Math.abs(i-16/9){if(a>=jl.length)return;let o=Math.min(e,t),s={rid:jl[a],scaleResolutionDownBy:Math.max(1,o/Math.min(n.width,n.height)),maxBitrate:n.encoding.maxBitrate},c=r&&n.encoding.maxFramerate?Math.min(r,n.encoding.maxFramerate):n.encoding.maxFramerate;c&&(s.maxFramerate=c);let l=Ca(),u=l?.name===`Firefox`&&l.os!==`iOS`||a===0;n.encoding.priority&&u&&(s.priority=n.encoding.priority,s.networkPriority=n.encoding.priority),i.push(s)}),Wo()&&Jo()===`ios`){let e;i.forEach(t=>{e?t.maxFramerate&&t.maxFramerate>e&&(e=t.maxFramerate):e=t.maxFramerate});let t=!0;i.forEach(n=>{n.maxFramerate!=e&&(t&&(t=!1,I.info(`Simulcast on iOS React-Native requires all encodings to share the same framerate.`)),I.info(`Setting framerate of encoding "${n.rid??``}" to ${e}`),n.maxFramerate=e)})}return i}function Rl(e){if(e)return e.sort((e,t)=>{let{encoding:n}=e,{encoding:r}=t;return n.maxBitrate>r.maxBitrate?1:n.maxBitrater.maxFramerate?1:-1:0})}var zl=class{constructor(e){let t=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!t)throw Error(`invalid scalability mode`);if(this.spatial=parseInt(t[1]),this.temporal=parseInt(t[2]),t.length>3)switch(t[3]){case`h`:case`_KEY`:case`_KEY_SHIFT`:this.suffix=t[3]}}toString(){return`L${this.spatial}T${this.temporal}${this.suffix??``}`}};function Bl(e){return e.source===U.Source.ScreenShare||e.constraints.height&&ls(e.constraints.height)>=1080?`maintain-resolution`:`balanced`}var Vl=5e3,Hl=class extends Sl{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0;super(e,U.Kind.Video,t,n,r),this.simulcastCodecs=new Map,this.degradationPreference=`balanced`,this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>L(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let e;try{e=yield this.getSenderStats()}catch(e){this.log.error(`could not get video sender stats`,Object.assign(Object.assign({},this.logContext),{error:e}));return}let t=new Map(e.map(e=>[e.rid,e])),n=e.some(e=>e.qualityLimitationReason===`cpu`);if(n!==this.isCpuConstrained&&(this.isCpuConstrained=n,this.isCpuConstrained&&this.emit(H.CpuConstrained)),this.prevStats){let e=0;t.forEach((t,n)=>{let r=this.prevStats?.get(n);e+=ec(t,r)}),this._currentBitrate=e}this.prevStats=t}),this.senderLock=new i}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){if(this.signalClient=e,!Uo())return;let t=this.sender?.getParameters();t&&(this.encodings=t.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},$s))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){let e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return L(this,void 0,void 0,function*(){var t,n,r,i;yield e.pauseUpstream.call(this);try{for(var a=!0,o=ni(this.simulcastCodecs.values()),s;s=yield o.next(),t=s.done,!t;a=!0)i=s.value,a=!1,yield i.sender?.replaceTrack(null)}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}})}resumeUpstream(){let e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return L(this,void 0,void 0,function*(){var t,n,r,i;yield e.resumeUpstream.call(this);try{for(var a=!0,o=ni(this.simulcastCodecs.values()),s;s=yield o.next(),t=s.done,!t;a=!0){i=s.value,a=!1;let e=i;yield e.sender?.replaceTrack(e.mediaStreamTrack)}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}})}mute(){let e=Object.create(null,{mute:{get:()=>super.mute}});return L(this,void 0,void 0,function*(){let t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug(`Track already muted`,this.logContext),this):(this.source===U.Source.Camera&&!this.isUserProvided&&(this.log.debug(`stopping camera track`,this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){let e=Object.create(null,{unmute:{get:()=>super.unmute}});return L(this,void 0,void 0,function*(){let t=yield this.muteLock.lock();try{return this.isMuted?(this.source===U.Source.Camera&&!this.isUserProvided&&(this.log.debug(`reacquiring camera track`,this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug(`Track already unmuted`,this.logContext),this)}finally{t()}})}setTrackMuted(e){super.setTrackMuted(e);for(let t of this.simulcastCodecs.values())t.mediaStreamTrack.enabled=!e}getSenderStats(){return L(this,void 0,void 0,function*(){if(!this.sender?.getStats)return[];let e=[],t=yield this.sender.getStats();return t.forEach(n=>{if(n.type===`outbound-rtp`){let r={type:`video`,streamId:n.id,frameHeight:n.frameHeight,frameWidth:n.frameWidth,framesPerSecond:n.framesPerSecond,framesSent:n.framesSent,firCount:n.firCount,pliCount:n.pliCount,nackCount:n.nackCount,packetsSent:n.packetsSent,bytesSent:n.bytesSent,qualityLimitationReason:n.qualityLimitationReason,qualityLimitationDurations:n.qualityLimitationDurations,qualityLimitationResolutionChanges:n.qualityLimitationResolutionChanges,rid:n.rid??n.id,retransmittedPacketsSent:n.retransmittedPacketsSent,targetBitrate:n.targetBitrate,timestamp:n.timestamp},i=t.get(n.remoteId);i&&(r.jitter=i.jitter,r.packetsLost=i.packetsLost,r.roundTripTime=i.roundTripTime),e.push(r)}}),e.sort((e,t)=>(t.frameWidth??0)-(e.frameWidth??0)),e})}setPublishingQuality(e){let t=[];for(let n=bo.LOW;n<=bo.HIGH;n+=1)t.push(new fr({quality:n,enabled:n<=e}));this.log.debug(`setting publishing quality. max quality ${e}`,this.logContext),this.setPublishingLayers(jo(this.codec),t)}restartTrack(e){return L(this,void 0,void 0,function*(){var t,n,r,i;let a;if(e){let t=no({video:e});typeof t.video!=`boolean`&&(a=t.video)}yield this.restart(a),this.isCpuConstrained=!1;try{for(var o=!0,s=ni(this.simulcastCodecs.values()),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;e.sender&&e.sender.transport?.state!==`closed`&&(e.mediaStreamTrack=this.mediaStreamTrack.clone(),yield e.sender.replaceTrack(e.mediaStreamTrack))}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&(yield r.call(s))}finally{if(n)throw n.error}}yield this.onSenderTrackSwapped()})}onSenderTrackSwapped(){return L(this,void 0,void 0,function*(){yield this.refreshSenderEncodings()})}refreshSenderEncodings(){return L(this,void 0,void 0,function*(){if(!this.sender||!this.publishOptions||this.optimizeForPerformance)return;let e=yield this.senderLock.lock();try{let e;try{e=yield this.waitForDimensions()}catch(e){this.log.warn(`could not determine new track dimensions, skipping encoding recompute`,Object.assign(Object.assign({},this.logContext),{error:e}));return}if(this.lastEncodedDimensions&&this.lastEncodedDimensions.width===e.width&&this.lastEncodedDimensions.height===e.height)return;let t=Ml(this.source===U.Source.ScreenShare,e.width,e.height,Object.assign({},this.publishOptions));yield this.applyEncodingsToSender(this.sender,t),this.encodings=t,this.lastEncodedDimensions=e;for(let[e,t]of this.simulcastCodecs){if(!t.sender||t.sender.transport?.state===`closed`||!qa(e))continue;let n=Object.assign({},this.publishOptions),r=Nl(this,e,n);r&&(yield this.applyEncodingsToSender(t.sender,r),t.encodings=r)}}catch(e){this.log.warn(`failed to apply recomputed encodings`,Object.assign(Object.assign({},this.logContext),{error:e}))}finally{e()}})}applyEncodingsToSender(e,t){return L(this,void 0,void 0,function*(){let n=e.getParameters();!n.encodings||n.encodings.length!==t.length||(n.encodings.forEach((e,n)=>{if(e.active===!1)return;let r=t[n];r.scaleResolutionDownBy!==void 0&&(e.scaleResolutionDownBy=r.scaleResolutionDownBy),r.maxBitrate!==void 0&&(e.maxBitrate=r.maxBitrate),r.maxFramerate!==void 0&&(e.maxFramerate=r.maxFramerate),r.priority!==void 0&&(e.priority=r.priority,e.networkPriority=r.priority)}),this.log.debug(`updating sender encodings after track restart`,Object.assign(Object.assign({},this.logContext),{encodings:n.encodings})),yield e.setParameters(n))})}setProcessor(e){let t=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return L(this,arguments,void 0,function(e){var n=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var i,a,o,s;if(yield t.setProcessor.call(n,e,r),n.processor?.processedTrack)try{for(var c=!0,l=ni(n.simulcastCodecs.values()),u;u=yield l.next(),i=u.done,!i;c=!0)s=u.value,c=!1,yield s.sender?.replaceTrack(n.processor.processedTrack)}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield o.call(l))}finally{if(a)throw a.error}}}()})}setDegradationPreference(e){return L(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug(`setting degradationPreference to ${e}`,this.logContext);let t=this.sender.getParameters();t.degradationPreference=e,this.sender.setParameters(t)}catch(e){this.log.warn(`failed to set degradationPreference`,Object.assign({error:e},this.logContext))}})}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e)){this.log.error(`${e} already added, skipping adding simulcast codec`,this.logContext);return}let n={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,n),n}setSimulcastTrackSender(e,t){let n=this.simulcastCodecs.get(e);n&&(n.sender=t,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},Vl))}setPublishingCodecs(e){return L(this,void 0,void 0,function*(){var t,n,r,i,a,o,s;if(this.log.debug(`setting publishing codecs`,Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(jo(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;let c=[];try{for(t=!0,n=ni(e);r=yield n.next(),i=r.done,!i;t=!0){s=r.value,t=!1;let e=s;if(!this.codec||this.codec===e.codec)yield this.setPublishingLayers(jo(e.codec),e.qualities);else{let t=this.simulcastCodecs.get(e.codec);if(this.log.debug(`try setPublishingCodec for ${e.codec}`,Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:t})),!t||!t.sender){for(let t of e.qualities)if(t.enabled){c.push(e.codec);break}}else t.encodings&&(this.log.debug(`try setPublishingLayersForSender ${e.codec}`,this.logContext),yield Ul(t.sender,t.encodings,e.qualities,this.senderLock,jo(e.codec),this.log,this.logContext))}}}catch(e){a={error:e}}finally{try{!t&&!i&&(o=n.return)&&(yield o.call(n))}finally{if(a)throw a.error}}return c})}setPublishingLayers(e,t){return L(this,void 0,void 0,function*(){if(this.optimizeForPerformance){this.log.info(`skipping setPublishingLayers due to optimized publishing performance`,Object.assign(Object.assign({},this.logContext),{qualities:t}));return}this.log.debug(`setting publishing layers`,Object.assign(Object.assign({},this.logContext),{qualities:t})),!(!this.sender||!this.encodings)&&(yield Ul(this.sender,this.encodings,t,this.senderLock,e,this.log,this.logContext))})}prioritizePerformance(){return L(this,void 0,void 0,function*(){if(!this.sender)throw Error(`sender not found`);let e=yield this.senderLock.lock();try{this.optimizeForPerformance=!0;let e=this.sender.getParameters();e.encodings=e.encodings.map((e,t)=>Object.assign(Object.assign({},e),{active:t===0,scaleResolutionDownBy:Math.max(1,Math.ceil((this.mediaStreamTrack.getSettings().height??360)/360)),scalabilityMode:t===0&&jo(this.codec)?`L1T3`:void 0,maxFramerate:t===0?15:0,maxBitrate:t===0?e.maxBitrate:0})),this.log.debug(`setting performance optimised encodings`,Object.assign(Object.assign({},this.logContext),{encodings:e.encodings})),this.encodings=e.encodings,yield this.sender.setParameters(e)}catch(e){this.log.error(`failed to set performance optimised encodings`,Object.assign(Object.assign({},this.logContext),{error:e})),this.optimizeForPerformance=!1}finally{e()}})}handleAppVisibilityChanged(){let e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return L(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Vo()&&this.isInBackground&&this.source===U.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}};function Ul(e,t,n,r,i,a,o){return L(this,void 0,void 0,function*(){let s=yield r.lock();a.debug(`setPublishingLayersForSender`,Object.assign(Object.assign({},o),{sender:e,qualities:n,senderEncodings:t}));try{let r=e.getParameters(),{encodings:s}=r;if(!s)return;if(s.length!==t.length){a.warn(`cannot set publishing layers, encodings mismatch`,Object.assign(Object.assign({},o),{encodings:s,senderEncodings:t}));return}let c=!1;i&&n.some(e=>e.enabled)&&n.forEach(e=>e.enabled=!0),s.forEach((e,r)=>{let i=e.rid??``;i===``&&(i=`q`);let s=Wl(i),l=n.find(e=>e.quality===s);l&&e.active!==l.enabled&&(c=!0,e.active=l.enabled,a.debug(`setting layer ${l.quality} to ${e.active?`enabled`:`disabled`}`,o),Po()&&(l.enabled?(e.scaleResolutionDownBy=t[r].scaleResolutionDownBy,e.maxBitrate=t[r].maxBitrate,e.maxFrameRate=t[r].maxFrameRate):(e.scaleResolutionDownBy=4,e.maxBitrate=10,e.maxFrameRate=2)))}),c&&(r.encodings=s,a.debug(`setting encodings`,Object.assign(Object.assign({},o),{encodings:r.encodings})),yield e.setParameters(r))}finally{s()}})}function Wl(e){switch(e){case`f`:return bo.HIGH;case`h`:return bo.MEDIUM;case`q`:return bo.LOW;default:return bo.HIGH}}function Gl(e,t,n,r){if(!n)return[new qt({quality:bo.HIGH,width:e,height:t,bitrate:0,ssrc:0})];if(r){let r=n[0].scalabilityMode,i=new zl(r),a=[],o=i.suffix==`h`?1.5:2,s=i.suffix==`h`?2:3;for(let r=0;r{let r=n.scaleResolutionDownBy??1;return new qt({quality:Wl(n.rid??``),width:Math.ceil(e/r),height:Math.ceil(t/r),bitrate:n.maxBitrate??0,ssrc:0})})}var Kl=`_lossy`,ql=`_reliable`,Jl=`_data_track`,Yl=2*1e3,Xl=`leave-reconnect`,Zl=3e4,Ql=8*1024,$l=256*1024,eu=3,tu=3,nu;(function(e){e[e.New=0]=`New`,e[e.Connected=1]=`Connected`,e[e.Disconnected=2]=`Disconnected`,e[e.Reconnecting=3]=`Reconnecting`,e[e.Closed=4]=`Closed`})(nu||={});var ru;(function(e){e[e.RELIABLE=0]=`RELIABLE`,e[e.LOSSY=1]=`LOSSY`,e[e.DATA_TRACK_LOSSY=2]=`DATA_TRACK_LOSSY`})(ru||={});var iu=class extends oi.EventEmitter{get isClosed(){return this._isClosed}get isNewlyCreated(){return this._isNewlyCreated}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=pl.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=nu.New,this._isClosed=!0,this._isNewlyCreated=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.shouldFailOnV1Path=!1,this.log=I,this.reliableDataSequence=1,this.reliableMessageBuffer=new zc,this.reliableReceivedState=new Bc(Zl),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.bufferStatusLowClosingFuture=new ss,this.handleDataChannel=e=>L(this,[e],void 0,function(e){var t=this;let{channel:n}=e;return function*(){if(!n)return;let e;if(n.label===ql)t.reliableDCSub=n,e=t.handleDataMessage;else if(n.label===Kl)t.lossyDCSub=n,e=t.handleDataMessage;else if(n.label===Jl)t.dataTrackDCSub=n,e=t.handleDataTrackMessage;else return;t.log.debug(`on data channel ${n.id}, ${n.label}`),n.onmessage=e}()}),this.handleDataMessage=e=>L(this,void 0,void 0,function*(){let t=yield this.dataProcessLock.lock();try{let t;if(e.data instanceof ArrayBuffer)t=e.data;else if(e.data instanceof Blob)t=yield e.data.arrayBuffer();else{this.log.error(`unsupported data type`,{data:e.data});return}let n=Yt.fromBinary(new Uint8Array(t));if(n.sequence>0&&n.participantSid!==``){let e=this.reliableReceivedState.get(n.participantSid);if(e&&n.sequence<=e)return;this.reliableReceivedState.set(n.participantSid,n.sequence)}if(n.value?.case===`speaker`)this.emit(V.ActiveSpeakersUpdate,n.value.value.speakers);else if(n.value?.case===`encryptedPacket`){if(!this.e2eeManager){this.log.error(`Received encrypted packet but E2EE not set up`);return}let e=yield this.e2eeManager?.handleEncryptedData(n.value.value.encryptedValue,n.value.value.iv,n.participantIdentity,n.value.value.keyIndex),t=new Yt({value:Qt.fromBinary(e.payload).value,participantIdentity:n.participantIdentity,participantSid:n.participantSid});t.value?.case===`user`&&au(t,t.value.value),this.emit(V.DataPacketReceived,t,n.value.value.encryptionType)}else n.value?.case===`user`&&au(n,n.value.value),this.emit(V.DataPacketReceived,n,Ht.NONE)}finally{t()}}),this.handleDataTrackMessage=e=>L(this,void 0,void 0,function*(){let t;if(e.data instanceof ArrayBuffer)t=e.data;else if(e.data instanceof Blob)t=yield e.data.arrayBuffer();else{this.log.error(`unsupported data type`,{data:e.data});return}this.emit(`dataTrackPacketReceived`,new Uint8Array(t))}),this.handleDataError=e=>{let t=e.currentTarget.maxRetransmits===0?`lossy`:`reliable`;if(e instanceof ErrorEvent&&e.error){let{error:n}=e.error;this.log.error(`DataChannel error on ${t}: ${e.message}`,{error:n})}else this.log.error(`Unknown DataChannel error on ${t}`,{event:e})},this.handleBufferedAmountLow=e=>{this.updateAndEmitDCBufferStatus(e)},this.handleDisconnect=(e,t)=>{if(this._isClosed)return;this.log.warn(`${e} disconnected`),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());let n=e=>{this.log.warn(`could not recover connection after ${this.reconnectAttempts} attempts, ${e}ms. giving up`),this.emit(V.Disconnected),this.close()},r=Date.now()-this.reconnectStart,i=this.getNextRetryDelay({elapsedMs:r,retryCount:this.reconnectAttempts});if(i===null){n(r);return}e===Xl&&(i=0),this.log.debug(`reconnecting in ${i}ms`),this.clearReconnectTimeout(),this.token&&this.emit(V.TokenRefreshed,this.token),this.reconnectTimeout=Ha.setTimeout(()=>this.attemptReconnect(t).finally(()=>this.reconnectTimeout=void 0),i)},this.waitForRestarted=()=>new Promise((e,t)=>{this.pcState===nu.Connected&&e();let n=()=>{this.off(V.Disconnected,r),e()},r=()=>{this.off(V.Restarted,n),t()};this.once(V.Restarted,n),this.once(V.Disconnected,r)}),this.updateAndEmitDCBufferStatus=e=>{if(e===ru.RELIABLE){let t=this.dataChannelForKind(e);t&&this.reliableMessageBuffer.alignBufferedAmount(t.bufferedAmount)}let t=this.isBufferStatusLow(e);t!==void 0&&t!==this.dcBufferStatus.get(e)&&(this.dcBufferStatus.set(e,t),this.emit(V.DCBufferStatusChanged,t,e))},this.isBufferStatusLow=e=>{let t=this.dataChannelForKind(e);if(t)return t.bufferedAmount<=t.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>L(this,void 0,void 0,function*(){this.url&&(yield fetch(ds(this.url),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1))&&(this.log.info(`detected network reconnected`),(this.client.currentState===Mc.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===Mc.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(jt.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>L(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(ds(this.url),{method:`HEAD`}),Eo(4e3).then(()=>Promise.reject())])}catch{window.navigator.onLine===!1&&(this.log.info(`detected network interruption`),this.isWaitingForNetworkReconnect=!0)}}),this.log=Gr(e.loggerName??Wr.Engine,()=>this.logContext),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Pc(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new i,this.dataProcessLock=new i,this.dcBufferStatus=new Map([[ru.RELIABLE,!0],[ru.LOSSY,!0],[ru.DATA_TRACK_LOSSY,!0]]),this.client.onParticipantUpdate=e=>this.emit(V.ParticipantUpdate,e),this.client.onConnectionQuality=e=>this.emit(V.ConnectionQualityUpdate,e),this.client.onRoomUpdate=e=>this.emit(V.RoomUpdate,e),this.client.onSubscriptionError=e=>this.emit(V.SubscriptionError,e),this.client.onSubscriptionPermissionUpdate=e=>this.emit(V.SubscriptionPermissionUpdate,e),this.client.onSpeakersChanged=e=>this.emit(V.SpeakersChanged,e),this.client.onStreamStateUpdate=e=>this.emit(V.StreamStateChanged,e),this.client.onRequestResponse=e=>this.emit(V.SignalRequestResponse,e),this.client.onParticipantUpdate=e=>this.emit(V.ParticipantUpdate,e),this.client.onJoined=e=>this.emit(V.Joined,e),this.on(V.Closing,()=>{var e,t;(t=(e=this.bufferStatusLowClosingFuture).reject)==null||t.call(e,new Pa(`engine closed`))}),this.bufferStatusLowClosingFuture.promise.catch(()=>{})}get logContext(){return{room:this.latestJoinResponse?.room?.name,roomID:this.latestJoinResponse?.room?.sid,participant:this.latestJoinResponse?.participant?.identity,participantID:this.participantSid}}join(e,t,n,r){return L(this,arguments,void 0,function(e,t,n,r){var i=this;let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return function*(){var o;i._isNewlyCreated=!1,i.url=e,i.token=t,i.signalOpts=n,i.maxJoinAttempts=n.maxRetries;try{i.joinAttempts+=1,i.setupSignalClientCallbacks();let s;if(!a&&ks()){i.pcManager||(yield i.configure(),i.createDataChannels(),i.addMediaSections(eu,tu));let e=yield i.pcManager?.publisher.createInitialOffer();e&&(s=Ic(e.offer,e.offerId))}if(r?.aborted)throw R.cancelled(`Connection aborted`);if(!a&&i.shouldFailOnV1Path)throw i.shouldFailOnV1Path=!1,R.serviceNotFound(`Simulated v1 path failure`,`v0-rtc`);let c=yield i.client.join(e,t,n,r,a,s);i._isClosed=!1,i.latestJoinResponse=c,i.participantSid=c.participant?.sid,i.subscriberPrimary=c.subscriberPrimary,!a&&ks()?(o=i.pcManager)==null||o.updateConfiguration(i.makeRTCConfiguration(c)):(i.pcManager||(yield i.configure(c,!a)),(!i.subscriberPrimary||c.fastPublish)&&i.negotiate().catch(e=>{i.log.error(e)})),i.registerOnLineListener(),i.clientConfiguration=c.clientConfiguration,i.emit(V.SignalConnected,c);let l=c.serverInfo;return l||={version:c.serverVersion,region:c.serverRegion},i.log.info(`connected to Livekit Server ${Object.entries(l).map(e=>{let[t,n]=e;return`${t}: ${n}`}).join(`, `)}`),{joinResponse:c,serverInfo:l}}catch(o){if(o instanceof R){if(o.reason===Aa.ServerUnreachable){if(i.log.warn(`Couldn't connect to server, attempt ${i.joinAttempts} of ${i.maxJoinAttempts}`),i.joinAttempts{e&&(e.close(),e.onbufferedamountlow=null,e.onclose=null,e.onclosing=null,e.onerror=null,e.onmessage=null,e.onopen=null)};e(this.lossyDC),e(this.lossyDCSub),e(this.reliableDC),e(this.reliableDCSub),e(this.dataTrackDC),e(this.dataTrackDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0,this.dataTrackDC=void 0,this.dataTrackDCSub=void 0,this.reliableMessageBuffer=new zc,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupLossyDataStats(){this.lossyDataStatByterate=0,this.lossyDataStatCurrentBytes=0,this.lossyDataStatInterval&&=(clearInterval(this.lossyDataStatInterval),void 0),this.lossyDataDropCount=0}cleanupClient(){return L(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks();for(let e of Object.keys(this.pendingTrackResolvers))this.pendingTrackResolvers[e].reject();this.pendingTrackResolvers={}})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new Ma(`a track with the same ID has already been published`);return new Promise((t,n)=>{let r=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],n(R.timeout(`publication of local track timed out, no response from server`))},1e4);this.pendingTrackResolvers[e.cid]={resolve:e=>{clearTimeout(r),t(e)},reject:()=>{clearTimeout(r),n(Error(`Cancelled publication by calling unpublish`))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){let{reject:t}=this.pendingTrackResolvers[e.track.id];t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(e){this.log.warn(`failed to remove track`,{error:e})}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){return this.reliableDCSub?.readyState}getConnectedServerAddress(){return L(this,void 0,void 0,function*(){return this.pcManager?.getConnectedAddress()})}setRegionStrategy(e){this.regionStrategy=e}configure(e,t){return L(this,void 0,void 0,function*(){if(!(this.pcManager&&this.pcManager.currentState!==ml.NEW)){if(e){this.participantSid=e.participant?.sid;let n=this.makeRTCConfiguration(e);this.pcManager=new hl(t?`publisher-only`:e.subscriberPrimary?`subscriber-primary`:`publisher-primary`,this.loggerOptions,n)}else{let e=this.makeRTCConfiguration();this.pcManager=new hl(`publisher-only`,this.loggerOptions,e)}this.emit(V.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(e,t)=>{this.client.sendIceCandidate(e,t)},this.pcManager.onPublisherOffer=(e,t)=>{this.client.sendOffer(e,t)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(e,t,n)=>L(this,void 0,void 0,function*(){if(this.log.debug(`primary PC state changed ${e}`),[`closed`,`disconnected`,`failed`].includes(t)&&(this.publisherConnectionPromise=void 0),e===ml.CONNECTED){let e=this.pcState===nu.New;this.pcState=nu.Connected,e&&this.emit(V.Connected,this.latestJoinResponse)}else e===ml.FAILED&&(this.pcState===nu.Connected||this.pcState===nu.Reconnecting)&&(this.pcState=nu.Disconnected,this.handleDisconnect(`peerconnection failed`,n===`failed`?jt.RR_SUBSCRIBER_FAILED:jt.RR_PUBLISHER_FAILED));let r=this.client.isDisconnected||this.client.currentState===Mc.RECONNECTING,i=[ml.FAILED,ml.CLOSING,ml.CLOSED].includes(e);r&&i&&!this._isClosed&&this.emit(V.Offline)}),this.pcManager.onTrack=e=>{e.streams.length!==0&&this.emit(V.MediaTrackAdded,e.track,e.streams[0],e.receiver)}}})}setupSignalClientCallbacks(){this.client.onAnswer=(e,t,n)=>L(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug(`received server answer`,{RTCSdpType:e.type,sdp:e.sdp,midToTrackId:n}),this.midToTrackId=n,yield this.pcManager.setPublisherAnswer(e,t))}),this.client.onTrickle=(e,t)=>{this.pcManager&&(this.log.debug(`got ICE candidate from peer`,{candidate:e,target:t}),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=(e,t,n)=>L(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=t,!this.pcManager)return;this.midToTrackId=n;let r=yield this.pcManager.createSubscriberAnswerFromOffer(e,t);r&&this.client.sendAnswer(r,t)}),this.client.onLocalTrackPublished=e=>{if(this.log.debug(`received trackPublishedResponse`,{cid:e.cid,track:e.track?.sid}),!this.pendingTrackResolvers[e.cid]){this.log.error(`missing track resolver for ${e.cid}`,{cid:e.cid});return}let{resolve:t}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],t(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(V.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(V.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e,this.emit(V.TokenRefreshed,e)},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(V.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(V.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{this.participantSid=e.participant?.sid,this.latestJoinResponse&&(this.latestJoinResponse.room=e.room),this.emit(V.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{this.addMediaSections(e.numAudios,e.numVideos),this.negotiate()},this.client.onPublishDataTrackResponse=e=>{this.emit(V.PublishDataTrackResponse,e)},this.client.onUnPublishDataTrackResponse=e=>{this.emit(V.UnPublishDataTrackResponse,e)},this.client.onDataTrackSubscriberHandles=e=>{this.emit(V.DataTrackSubscriberHandles,e)},this.client.onClose=()=>{this.handleDisconnect(`signal`,jt.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.info(`client leave request received (action=${e?.action})`,{reason:e?.reason}),e.regions&&(this.log.debug(`updating regions`),this.emit(V.ServerRegionsReported,e.regions)),e.action){case nr.DISCONNECT:this.emit(V.Disconnected,e?.reason),this.close();break;case nr.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Xl);break;case nr.RESUME:this.handleDisconnect(Xl)}}}makeRTCConfiguration(e){let t=Object.assign({},this.rtcConfig);if((this.signalOpts?.e2eeEnabled||this.options.packetTrailer?.worker&&!qs())&&Ws()&&(this.log.debug(`E2EE - setting up transports with insertable streams`),t.encodedInsertableStreams=!0),t.sdpSemantics=`unified-plan`,t.continualGatheringPolicy=`gather_continually`,!e)return t;if(e.iceServers&&!t.iceServers){let n=[];e.iceServers.forEach(e=>{let t={urls:e.urls};e.username&&(t.username=e.username),e.credential&&(t.credential=e.credential),n.push(t)}),t.iceServers=n}return e.clientConfiguration&&e.clientConfiguration.forceRelay===kt.ENABLED&&(t.iceTransportPolicy=`relay`),t}addMediaSections(e,t){var n,r;let i={direction:`recvonly`};for(let t=0;tthis.handleBufferedAmountLow(ru.LOSSY),this.reliableDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(ru.RELIABLE),this.dataTrackDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(ru.DATA_TRACK_LOSSY),this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;let e=this.dataChannelForKind(ru.LOSSY);if(e){let t=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(t,Ql),$l)}},1e3))}createSender(e,t,n){return L(this,void 0,void 0,function*(){let r;if(Do())r=yield this.createTransceiverRTCRtpSender(e,t,n);else if(Oo())this.log.warn(`using add-track fallback`),r=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Pa(`Required webRTC APIs not supported on this device`);return this.setupPacketTrailerSender(r,t),r})}createSimulcastSender(e,t,n,r){return L(this,void 0,void 0,function*(){let i;if(Do())i=yield this.createSimulcastTransceiverSender(e,t,n,r);else if(Oo())this.log.debug(`using add-track fallback`),i=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Pa(`Cannot stream on this device`);return i&&this.setupPacketTrailerSender(i,n),i})}setupPacketTrailerSender(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.options.packetTrailer?.worker||this.signalOpts?.e2eeEnabled)return;let n=t.packetTrailer,r=Ys(n);if(qs()){r&&(e.transform=new RTCRtpScriptTransform(this.options.packetTrailer.worker,{kind:`encode`,packetTrailer:n}));return}if(!Js(this.options.packetTrailer)||!(`createEncodedStreams`in e)){r&&this.log.warn(`packet trailer transform not supported; skipping write`,this.logContext);return}let{readable:i,writable:a}=e.createEncodedStreams();r?this.options.packetTrailer.worker.postMessage({kind:`encode`,data:{readableStream:i,writableStream:a,packetTrailer:n}},[i,a]):i.pipeTo(a)}createTransceiverRTCRtpSender(e,t,n){return L(this,void 0,void 0,function*(){if(!this.pcManager)throw new Pa(`publisher is closed`);let r=[];e.mediaStream&&r.push(e.mediaStream),ys(e)&&(e.codec=t.videoCodec);let i={direction:`sendonly`,streams:r};return n&&(i.sendEncodings=n),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,i)).sender})}createSimulcastTransceiverSender(e,t,n,r){return L(this,void 0,void 0,function*(){if(!this.pcManager)throw new Pa(`publisher is closed`);let i={direction:`sendonly`};r&&(i.sendEncodings=r);let a=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,i);if(n.videoCodec)return e.setSimulcastTrackSender(n.videoCodec,a.sender),a.sender})}createRTCRtpSender(e){return L(this,void 0,void 0,function*(){if(!this.pcManager)throw new Pa(`publisher is closed`);return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return L(this,void 0,void 0,function*(){if(!this._isClosed){if(this.attemptingReconnect){this.log.warn(`already attempting reconnect, returning early`);return}(this.clientConfiguration?.resumeConnection===kt.DISABLED||(this.pcManager?.currentState??ml.NEW)===ml.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(e){this.reconnectAttempts+=1;let t=!0;e instanceof Pa?(this.log.debug(`received unrecoverable error`,{error:e}),t=!1):e instanceof Ba||(this.fullReconnectOnNext=!0),t?this.handleDisconnect(`reconnect`,jt.RR_UNKNOWN):(this.log.info(`could not recover connection after ${this.reconnectAttempts} attempts, ${Date.now()-this.reconnectStart}ms. giving up`),this.emit(V.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(e){this.log.warn(`encountered error in reconnect policy`,{error:e})}return null}restartConnection(e){return L(this,void 0,void 0,function*(){var t,n;try{if(!this.url||!this.token)throw new Pa(`could not reconnect, url or token not saved`);this.log.info(`reconnecting, attempt: ${this.reconnectAttempts}`),this.emit(V.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let n;try{if(!this.signalOpts)throw this.log.warn(`attempted connection restart, without signal options present`),new Ba;n=(yield this.join(e??this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)).joinResponse}catch(e){throw e instanceof R&&e.reason===Aa.NotAllowed?new Pa(`could not reconnect, token might be expired`):new Ba}if(this.shouldFailNext)throw this.shouldFailNext=!1,Error(`simulated failure`);if(this.client.setReconnected(),this.emit(V.SignalRestarted,n),yield this.waitForPCReconnected(),this.client.currentState!==Mc.CONNECTED)throw new Ba(`Signal connection got severed during reconnect`);(t=this.regionStrategy)==null||t.resetAttempts(),this.emit(V.Restarted)}catch(e){let t=yield this.regionStrategy?.getNextUrl();if(t){yield this.restartConnection(t);return}else throw(n=this.regionStrategy)==null||n.resetAttempts(),e}})}resumeConnection(e){return L(this,void 0,void 0,function*(){if(!this.url||!this.token)throw new Pa(`could not reconnect, url or token not saved`);if(!this.pcManager)throw new Pa(`publisher and subscriber connections unset`);this.log.info(`resuming signal connection, attempt ${this.reconnectAttempts}`),this.emit(V.Resuming);let t;try{this.setupSignalClientCallbacks(),t=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(e){let t=``;throw e instanceof Error&&(t=e.message,this.log.error(e.message,{error:e})),e instanceof R&&e.reason===Aa.NotAllowed?new Pa(`could not reconnect, token might be expired`):e instanceof R&&e.reason===Aa.LeaveRequest?e:new Ba(t)}if(this.emit(V.SignalResumed),t){let e=this.makeRTCConfiguration(t);this.pcManager.updateConfiguration(e),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=t.serverInfo)}else this.log.warn(`Did not receive reconnect response`);if(this.shouldFailNext)throw this.shouldFailNext=!1,Error(`simulated failure`);if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==Mc.CONNECTED)throw new Ba(`Signal connection got severed during reconnect`);this.client.setReconnected(),this.reliableDC?.readyState===`open`&&this.reliableDC.id===null&&this.createDataChannels(),t?.lastMessageSeq&&this.resendReliableMessagesForResume(t.lastMessageSeq),this.emit(V.Resumed)})}waitForPCInitialConnection(e,t){return L(this,void 0,void 0,function*(){if(!this.pcManager)throw new Pa(`PC manager is closed`);yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return L(this,void 0,void 0,function*(){this.pcState=nu.Reconnecting,this.log.debug(`waiting for peer connection to reconnect`);try{if(yield Eo(Yl),!this.pcManager)throw new Pa(`PC manager is closed`);yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=nu.Connected}catch(e){throw this.pcState=nu.Disconnected,R.internal(`could not establish PC connection, ${e.message}`)}})}publishRpcAck(e,t){return L(this,void 0,void 0,function*(){let n=new Yt({destinationIdentities:[e],kind:Xt.RELIABLE,value:{case:`rpcAck`,value:new cn({requestId:t})}});yield this.sendDataPacket(n,ru.RELIABLE)})}sendDataPacket(e,t){return L(this,void 0,void 0,function*(){if(yield this.ensurePublisherConnected(t),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){let t=Gs(e);if(t){let n=yield this.e2eeManager.encryptData(t.toBinary());e.value={case:`encryptedPacket`,value:new Zt({encryptedValue:n.payload,iv:n.iv,keyIndex:n.keyIndex})}}}t===ru.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);let n=e.toBinary();switch(t){case ru.LOSSY:case ru.DATA_TRACK_LOSSY:return this.sendLossyBytes(n,t);case ru.RELIABLE:let r=this.dataChannelForKind(t);if(r){if(yield this.waitForBufferStatusLow(t),this.reliableMessageBuffer.push({data:n,sequence:e.sequence}),this.attemptingReconnect)return;r.send(n)}this.updateAndEmitDCBufferStatus(t);break}})}sendLossyBytes(e,t){return L(this,arguments,void 0,function(e,t){var n=this;let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`drop`;return function*(){yield n.ensurePublisherConnected(t);let i=n.dataChannelForKind(t);if(i){if(!n.isBufferStatusLow(t))switch(r){case`wait`:yield n.waitForBufferStatusLow(t);break;case`drop`:n.lossyDataDropCount+=1,n.lossyDataDropCount%100==0&&n.log.warn(`dropping lossy data channel messages, total dropped: ${n.lossyDataDropCount}`);return}if(n.lossyDataStatCurrentBytes+=e.byteLength,n.attemptingReconnect)return;i.send(e)}n.updateAndEmitDCBufferStatus(t)}()})}resendReliableMessagesForResume(e){return L(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(ru.RELIABLE);let t=this.dataChannelForKind(ru.RELIABLE);t&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(e=>{t.send(e.data)})),this.updateAndEmitDCBufferStatus(ru.RELIABLE)})}waitForBufferStatusLow(e){return L(this,void 0,void 0,function*(){return new ba((t,n)=>L(this,void 0,void 0,function*(){if(this.isClosed&&n(new Pa(`engine closed`)),this.isBufferStatusLow(e))t();else{let r=this.dataChannelForKind(e);if(!r){n(new Pa(`DataChannel not found, kind: ${e}`));return}this.bufferStatusLowClosingFuture.promise.catch(e=>n(e)),r.addEventListener(`bufferedamountlow`,()=>t(),{once:!0})}}))})}ensureDataTransportConnected(e){return L(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){if(!t.pcManager)throw new Pa(`PC manager is closed`);let r=n?t.pcManager.subscriber:t.pcManager.publisher,i=n?`Subscriber`:`Publisher`;if(!r)throw R.internal(`${i} connection not set`);let a=!1;if(!n&&!t.dataChannelForKind(e,n)&&(t.createDataChannels(),a=!0),!a&&!n&&!t.pcManager.publisher.isICEConnected&&t.pcManager.publisher.getICEConnectionState()!==`checking`&&(a=!0),a&&t.negotiate().catch(e=>{t.log.error(e)}),t.dataChannelForKind(e,n)?.readyState===`open`)return;let o=new Date().getTime()+t.peerConnectionTimeout;for(;new Date().getTime()L(this,void 0,void 0,function*(){if(!this.pcManager){t(new Fa(`PC manager is closed`));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&!this.dataTrackDC&&this.createDataChannels();let n=new AbortController,r=()=>{n.abort(),this.log.debug(`engine disconnected while negotiation was ongoing`),e()};this.isClosed&&t(new Fa(`cannot negotiate on closed engine`)),this.on(V.Closing,r),this.on(V.Restarting,r),this.pcManager.publisher.once(nl.RTPVideoPayloadTypes,e=>{let t=new Map;e.forEach(e=>{let n=e.codec.toLowerCase();cs(n)&&t.set(e.payload,n)}),this.emit(V.RTPVideoMapUpdate,t)});try{yield this.pcManager.negotiate(n),e()}catch(r){if(n.signal.aborted){e();return}r instanceof Fa&&(this.fullReconnectOnNext=!0),this.handleDisconnect(`negotiation`,jt.RR_UNKNOWN),r instanceof Error?t(r):t(Error(String(r)))}finally{this.off(V.Closing,r),this.off(V.Restarting,r)}}))})}dataChannelForKind(e,t){switch(e){case ru.RELIABLE:return t?this.reliableDCSub:this.reliableDC;case ru.LOSSY:return t?this.lossyDCSub:this.lossyDC;case ru.DATA_TRACK_LOSSY:return t?this.dataTrackDCSub:this.dataTrackDC}}sendSyncState(e,t,n){if(!this.pcManager){this.log.warn(`sync state cannot be sent without peer connection setup`);return}let r=this.pcManager.publisher.getLocalDescription(),i=this.pcManager.publisher.getRemoteDescription(),a=this.pcManager.subscriber?.getRemoteDescription(),o=this.pcManager.subscriber?.getLocalDescription(),s=this.signalOpts?.autoSubscribe??!0,c=[],l=[];e.forEach(e=>{e.isDesired!==s&&c.push(e.trackSid),e.isEnabled||l.push(e.trackSid)}),this.client.sendSyncState(new br({answer:this.pcManager.mode===`publisher-only`?i?Ic({sdp:i.sdp,type:i.type}):void 0:o?Ic({sdp:o.sdp,type:o.type}):void 0,offer:this.pcManager.mode===`publisher-only`?r?Ic({sdp:r.sdp,type:r.type}):void 0:a?Ic({sdp:a.sdp,type:a.type}):void 0,subscription:new Yn({trackSids:c,subscribe:!s,participantTracks:[]}),publishTracks:lo(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:l,datachannelReceiveStates:this.reliableReceivedState.map((e,t)=>new xr({publisherSid:t,lastSeq:e})),publishDataTracks:n.map(e=>new In({info:Ec.toProtobuf(e)}))}))}failNext(){this.shouldFailNext=!0}failNextV1Path(){this.shouldFailOnV1Path=!0}dataChannelsInfo(){let e=[],t=(t,n)=>{t?.id!==void 0&&t.id!==null&&e.push(new Sr({label:t.label,id:t.id,target:n}))};return t(this.dataChannelForKind(ru.LOSSY),On.PUBLISHER),t(this.dataChannelForKind(ru.RELIABLE),On.PUBLISHER),t(this.dataChannelForKind(ru.LOSSY,!0),On.SUBSCRIBER),t(this.dataChannelForKind(ru.RELIABLE,!0),On.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&Ha.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Uo()&&(window.addEventListener(`online`,this.handleBrowserOnLine),window.addEventListener(`offline`,this.handleBrowserOffline))}deregisterOnLineListener(){Uo()&&(window.removeEventListener(`online`,this.handleBrowserOnLine),window.removeEventListener(`offline`,this.handleBrowserOffline))}getTrackIdForReceiver(e){let t=this.pcManager?.getMidForReceiver(e);if(t){let e=Object.entries(this.midToTrackId).find(e=>{let[n]=e;return n===t});if(e)return e[1]}}};function au(e,t){let n=e.participantIdentity?e.participantIdentity:t.participantIdentity;e.participantIdentity=n,t.participantIdentity=n;let r=e.destinationIdentities.length===0?t.destinationIdentities:e.destinationIdentities;e.destinationIdentities=r,t.destinationIdentities=r}var ou=5e3,su=3e4,cu=class e{static fetchRegionSettings(t,n,r){return L(this,void 0,void 0,function*(){let i=yield e.fetchLock.lock();try{let e=yield fetch(`${lu(t)}/regions`,{headers:{authorization:`Bearer ${n}`},signal:r});if(e.ok){let t=Ds(e.headers),n=t?t*1e3:ou;return{regionSettings:yield e.json(),updatedAtInMs:Date.now(),maxAgeInMs:n}}else if(e.status===401)throw R.notAllowed(`Could not fetch region settings: ${e.statusText}`,e.status);else throw R.internal(`Could not fetch region settings: ${e.statusText}`)}catch(e){throw e instanceof R?e:r?.aborted?R.cancelled(`Region fetching was aborted`):R.serverUnreachable(`Could not fetch region settings, ${e instanceof Error?`${e.name}: ${e.message}`:e}`)}finally{i()}})}static scheduleRefetch(t,n,r){return L(this,void 0,void 0,function*(){let i=e.settingsTimeouts.get(t.hostname);clearTimeout(i),e.settingsTimeouts.set(t.hostname,setTimeout(()=>L(this,void 0,void 0,function*(){try{let r=yield e.fetchRegionSettings(t,n);e.updateCachedRegionSettings(t,n,r)}catch(i){if(i instanceof R&&i.reason===Aa.NotAllowed){I.debug(`token is not valid, cancelling auto region refresh`);return}I.debug(`auto refetching of region settings failed`,{error:i}),e.scheduleRefetch(t,n,r)}}),r))})}static updateCachedRegionSettings(t,n,r){e.cache.set(t.hostname,r),e.scheduleRefetch(t,n,r.maxAgeInMs)}static stopRefetch(t){let n=e.settingsTimeouts.get(t);n&&(clearTimeout(n),e.settingsTimeouts.delete(t))}static scheduleCleanup(t){let n=e.connectionTrackers.get(t);n&&(n.cleanupTimeout&&clearTimeout(n.cleanupTimeout),n.cleanupTimeout=setTimeout(()=>{let n=e.connectionTrackers.get(t);n&&n.connectionCount===0&&(I.debug(`stopping region refetch after disconnect delay`,{hostname:t}),e.stopRefetch(t)),n&&(n.cleanupTimeout=void 0)},su))}static cancelCleanup(t){let n=e.connectionTrackers.get(t);n?.cleanupTimeout&&(clearTimeout(n.cleanupTimeout),n.cleanupTimeout=void 0)}notifyConnected(){let t=this.serverUrl.hostname,n=e.connectionTrackers.get(t);n||(n={connectionCount:0},e.connectionTrackers.set(t,n)),n.connectionCount++,e.cancelCleanup(t)}notifyDisconnected(){let t=this.serverUrl.hostname,n=e.connectionTrackers.get(t);n&&(n.connectionCount=Math.max(0,n.connectionCount-1),n.connectionCount===0&&e.scheduleCleanup(t))}constructor(e,t){this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=t}updateToken(t){this.token=t;let n=this.getServerUrl(),r=e.cache.get(n.hostname);e.scheduleRefetch(this.serverUrl,this.token,r?.maxAgeInMs??ou)}isCloud(){return Go(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(t){return L(this,void 0,void 0,function*(){return e.fetchRegionSettings(this.serverUrl,this.token,t)})}getNextBestRegionUrl(t){return L(this,void 0,void 0,function*(){if(!this.isCloud())throw Error(`region availability is only supported for LiveKit Cloud domains`);let n=e.cache.get(this.serverUrl.hostname);(!n||Date.now()-n.updatedAtInMs>n.maxAgeInMs)&&(n=yield this.fetchRegionSettings(t),e.updateCachedRegionSettings(this.serverUrl,this.token,n));let r=n.regionSettings.regions.filter(e=>!this.attemptedRegions.find(t=>t.url===e.url));if(r.length>0){let e=r[0];return this.attemptedRegions.push(e),I.debug(`next region: ${e.region}`),e.url}else return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(t){e.updateCachedRegionSettings(this.serverUrl,this.token,t)}};cu.cache=new Map,cu.settingsTimeouts=new Map,cu.connectionTrackers=new Map,cu.fetchLock=new i;function lu(e){return`${e.protocol.replace(`ws`,`http`)}//${e.host}/settings`}var uu=class{get info(){return this._info}validateBytesReceived(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(!(typeof this.totalByteSize!=`number`||this.totalByteSize===0)){if(e&&this.bytesReceivedthis.totalByteSize)throw new za(`Extra chunk(s) received - expected ${this.totalByteSize} bytes of data total, received ${this.bytesReceived} bytes`,Ra.LengthExceeded)}}constructor(e,t,n){this.reader=t,this.totalByteSize=n,this._info=e,this.bytesReceived=0}},du=class extends uu{handleChunkReceived(e){var t;this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();let n=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)==null||t.call(this,n)}[Symbol.asyncIterator](){let e=this.reader.getReader();e.closed.catch(()=>{});let t=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>L(this,void 0,void 0,function*(){try{let t=this.signal;if(t?.aborted)throw t.reason;let n=yield new Promise((n,r)=>{if(t){let i=()=>r(t.reason);t.addEventListener(`abort`,i,{once:!0}),e.read().then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}else e.read().then(n,r)});return n.done?(this.validateBytesReceived(!0),{done:!0,value:void 0}):(this.handleChunkReceived(n.value),{done:!1,value:n.value.content})}catch(e){throw t(),e}}),return(){return L(this,void 0,void 0,function*(){return t(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function*(){var n,r,i,a;let o=new Set,s=t.signal?e.withAbortSignal(t.signal):e;try{for(var c=!0,l=ni(s),u;u=yield l.next(),n=u.done,!n;c=!0){a=u.value,c=!1;let e=a;o.add(e)}}catch(e){r={error:e}}finally{try{!c&&!n&&(i=l.return)&&(yield i.call(l))}finally{if(r)throw r.error}}return Array.from(o)}()})}},fu=class extends uu{constructor(e,t,n){super(e,t,n),this.receivedChunks=new Map}handleChunkReceived(e){var t;let n=hs(e.chunkIndex),r=this.receivedChunks.get(n);if(r&&r.version>e.version)return;this.receivedChunks.set(n,e),this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();let i=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)==null||t.call(this,i)}[Symbol.asyncIterator](){let e=this.reader.getReader();e.closed.catch(()=>{});let t=new TextDecoder(`utf-8`,{fatal:!0}),n=this.signal,r=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>L(this,void 0,void 0,function*(){try{if(n?.aborted)throw n.reason;let r=yield new Promise((t,r)=>{if(n){let i=()=>r(n.reason);n.addEventListener(`abort`,i,{once:!0}),e.read().then(t,r).finally(()=>{n.removeEventListener(`abort`,i)})}else e.read().then(t,r)});if(r.done)return this.validateBytesReceived(!0),{done:!0,value:void 0};{this.handleChunkReceived(r.value);let e;try{e=t.decode(r.value.content)}catch(e){throw new za(`Cannot decode datastream chunk ${r.value.chunkIndex} as text: ${e}`,Ra.DecodeFailed)}return{done:!1,value:e}}}catch(e){throw r(),e}}),return(){return L(this,void 0,void 0,function*(){return r(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return L(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function*(){var n,r,i,a;let o=``,s=t.signal?e.withAbortSignal(t.signal):e;try{for(var c=!0,l=ni(s),u;u=yield l.next(),n=u.done,!n;c=!0)a=u.value,c=!1,o+=a}catch(e){r={error:e}}finally{try{!c&&!n&&(i=l.return)&&(yield i.call(l))}finally{if(r)throw r.error}}return o}()})}},pu=class{constructor(){this.log=I,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.isConnected=!1,this.bufferedPackets=[]}setConnected(e){this.isConnected=e,e&&this.flushBufferedPackets()}flushBufferedPackets(){let e=this.bufferedPackets;this.bufferedPackets=[];for(let{packet:t,encryptionType:n}of e)this.handleDataStreamPacket(t,n)}registerTextStreamHandler(e,t){if(this.textStreamHandlers.has(e))throw new za(`A text stream handler for topic "${e}" has already been set.`,Ra.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new za(`A byte stream handler for topic "${e}" has already been set.`,Ra.HandlerAlreadyRegistered);this.byteStreamHandlers.set(e,t)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}clearControllers(){this.byteStreamControllers.clear(),this.textStreamControllers.clear(),this.bufferedPackets=[]}validateParticipantHasNoActiveDataStreams(e){let t=Array.from(this.textStreamControllers.entries()).filter(t=>t[1].sendingParticipantIdentity===e),n=Array.from(this.byteStreamControllers.entries()).filter(t=>t[1].sendingParticipantIdentity===e);if(t.length>0||n.length>0){let r=new za(`Participant ${e} unexpectedly disconnected in the middle of sending data`,Ra.AbnormalEnd);for(let[e,t]of n)t.controller.error(r),this.byteStreamControllers.delete(e);for(let[e,n]of t)n.controller.error(r),this.textStreamControllers.delete(e)}}handleDataStreamPacket(e,t){if(!this.isConnected){this.bufferedPackets.push({packet:e,encryptionType:t});return}switch(e.value.case){case`streamHeader`:return this.handleStreamHeader(e.value.value,e.participantIdentity,t);case`streamChunk`:return this.handleStreamChunk(e.value.value,t);case`streamTrailer`:return this.handleStreamTrailer(e.value.value,t);default:throw Error(`DataPacket of value "${e.value.case}" is not data stream related!`)}}handleStreamHeader(e,t,n){if(e.contentHeader.case===`byteHeader`){let r=this.byteStreamHandlers.get(e.topic);if(!r){this.log.debug(`ignoring incoming byte stream due to no handler for topic`,e.topic);return}let i,a={id:e.streamId,name:e.contentHeader.value.name??`unknown`,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:hs(e.timestamp),attributes:e.attributes,encryptionType:n};r(new du(a,new ReadableStream({start:n=>{if(i=n,this.textStreamControllers.has(e.streamId))throw new za(`A data stream read is already in progress for a stream with id ${e.streamId}.`,Ra.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:a,controller:i,startTime:Date.now(),sendingParticipantIdentity:t})}}),hs(e.totalLength)),{identity:t})}else if(e.contentHeader.case===`textHeader`){let r=this.textStreamHandlers.get(e.topic);if(!r){this.log.debug(`ignoring incoming text stream due to no handler for topic`,e.topic);return}let i,a={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes,encryptionType:n,attachedStreamIds:e.contentHeader.value.attachedStreamIds};r(new fu(a,new ReadableStream({start:n=>{if(i=n,this.textStreamControllers.has(e.streamId))throw new za(`A data stream read is already in progress for a stream with id ${e.streamId}.`,Ra.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:a,controller:i,startTime:Date.now(),sendingParticipantIdentity:t})}}),hs(e.totalLength)),{identity:t})}}handleStreamChunk(e,t){let n=this.byteStreamControllers.get(e.streamId);n&&(n.info.encryptionType===t?e.content.length>0&&n.controller.enqueue(e):(n.controller.error(new za(`Encryption type mismatch for stream ${e.streamId}. Expected ${t}, got ${n.info.encryptionType}`,Ra.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId)));let r=this.textStreamControllers.get(e.streamId);r&&(r.info.encryptionType===t?e.content.length>0&&r.controller.enqueue(e):(r.controller.error(new za(`Encryption type mismatch for stream ${e.streamId}. Expected ${t}, got ${r.info.encryptionType}`,Ra.EncryptionTypeMismatch)),this.textStreamControllers.delete(e.streamId)))}handleStreamTrailer(e,t){let n=this.textStreamControllers.get(e.streamId);n&&(n.info.encryptionType===t?(n.info.attributes=Object.assign(Object.assign({},n.info.attributes),e.attributes),n.controller.close(),this.textStreamControllers.delete(e.streamId)):n.controller.error(new za(`Encryption type mismatch for stream ${e.streamId}. Expected ${t}, got ${n.info.encryptionType}`,Ra.EncryptionTypeMismatch)));let r=this.byteStreamControllers.get(e.streamId);r&&(r.info.encryptionType===t?(r.info.attributes=Object.assign(Object.assign({},r.info.attributes),e.attributes),r.controller.close()):r.controller.error(new za(`Encryption type mismatch for stream ${e.streamId}. Expected ${t}, got ${r.info.encryptionType}`,Ra.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId))}},mu=class{constructor(e,t,n){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=n,this.info=t}write(e){return this.defaultWriter.write(e)}close(){return L(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)==null||e.call(this)})}},hu=class extends mu{},gu=class extends mu{},_u=15e3,vu=class{constructor(e,t){this.engine=e,this.log=t}setupEngine(e){this.engine=e}sendText(e,t){return L(this,void 0,void 0,function*(){let n=crypto.randomUUID(),r=new TextEncoder().encode(e).byteLength,i=(t?.attachments)?.map(()=>crypto.randomUUID()),a=Array(i?i.length+1:1).fill(0),o=(e,n)=>{var r;a[n]=e;let i=a.reduce((e,t)=>e+t,0);(r=t?.onProgress)==null||r.call(t,i)},s=yield this.streamText({streamId:n,totalSize:r,destinationIdentities:t?.destinationIdentities,topic:t?.topic,attachedStreamIds:i,attributes:t?.attributes});return yield s.write(e),o(1,0),yield s.close(),t?.attachments&&i&&(yield Promise.all(t.attachments.map((e,n)=>L(this,void 0,void 0,function*(){return this._sendFile(i[n],e,{topic:t.topic,mimeType:e.type,onProgress:e=>{o(e,n+1)}})})))),s.info})}streamText(e){return L(this,void 0,void 0,function*(){let t=e?.streamId??crypto.randomUUID(),n={id:t,mimeType:`text/plain`,timestamp:Date.now(),topic:e?.topic??``,size:e?.totalSize,attributes:e?.attributes,encryptionType:this.engine.e2eeManager?.isDataChannelEncryptionEnabled?Ht.GCM:Ht.NONE,attachedStreamIds:e?.attachedStreamIds},r=new wn({streamId:t,mimeType:n.mimeType,topic:n.topic,timestamp:gs(n.timestamp),totalLength:gs(n.size),attributes:n.attributes,contentHeader:{case:`textHeader`,value:new Sn({version:e?.version,attachedStreamIds:n.attachedStreamIds,replyToStreamId:e?.replyToStreamId,operationType:e?.type===`update`?xn.UPDATE:xn.CREATE})}}),i=e?.destinationIdentities,a=new Yt({destinationIdentities:i,value:{case:`streamHeader`,value:r}});yield this.engine.sendDataPacket(a,ru.RELIABLE);let o=0,s=this.engine,c=new WritableStream({write(e){return L(this,void 0,void 0,function*(){for(let n of Es(e,_u)){let e=new Yt({destinationIdentities:i,value:{case:`streamChunk`,value:new Tn({content:n,streamId:t,chunkIndex:gs(o)})}});yield s.sendDataPacket(e,ru.RELIABLE),o+=1}})},close(){return L(this,void 0,void 0,function*(){let e=new Yt({destinationIdentities:i,value:{case:`streamTrailer`,value:new En({streamId:t})}});yield s.sendDataPacket(e,ru.RELIABLE)})},abort(e){console.log(`Sink error:`,e)}}),l=()=>L(this,void 0,void 0,function*(){yield u.close()});s.once(V.Closing,l);let u=new hu(c,n,()=>this.engine.off(V.Closing,l));return u})}sendFile(e,t){return L(this,void 0,void 0,function*(){let n=crypto.randomUUID();return yield this._sendFile(n,e,t),{id:n}})}_sendFile(e,t,n){return L(this,void 0,void 0,function*(){let r=yield this.streamBytes({streamId:e,totalSize:t.size,name:t.name,mimeType:n?.mimeType??t.type,topic:n?.topic,destinationIdentities:n?.destinationIdentities}),i=t.stream().getReader();for(;;){let{done:e,value:t}=yield i.read();if(e)break;yield r.write(t)}return yield r.close(),r.info})}streamBytes(e){return L(this,void 0,void 0,function*(){let t=e?.streamId??crypto.randomUUID(),n=e?.destinationIdentities,r={id:t,mimeType:e?.mimeType??`application/octet-stream`,topic:e?.topic??``,timestamp:Date.now(),attributes:e?.attributes,size:e?.totalSize,name:e?.name??`unknown`,encryptionType:this.engine.e2eeManager?.isDataChannelEncryptionEnabled?Ht.GCM:Ht.NONE},a=new Yt({destinationIdentities:n,value:{case:`streamHeader`,value:new wn({totalLength:gs(r.size),mimeType:r.mimeType,streamId:t,topic:r.topic,timestamp:gs(Date.now()),attributes:r.attributes,contentHeader:{case:`byteHeader`,value:new Cn({name:r.name})}})}});yield this.engine.sendDataPacket(a,ru.RELIABLE);let o=0,s=new i,c=this.engine,l=this.log;return new gu(new WritableStream({write(e){return L(this,void 0,void 0,function*(){let r=yield s.lock(),i=0;try{for(;i{for(let e of n)e()};return e.forEach((e,i)=>{let a=()=>{t.abort(e.reason),r()};e.addEventListener(`abort`,a),n[i]=()=>e.removeEventListener(`abort`,a)}),t.signal}function bu(e){let t=new AbortController;return setTimeout(()=>{t.abort(new DOMException(`signal timed out after ${e} ms`,`TimeoutError`))},e),t.signal}var xu=1,Su=2,Cu=4,wu=8,Tu=0,Eu=12,Du=5,Ou=7,ku=3,Au=3,ju=2,Mu=1,Nu=0,Pu=3,Fu=2,Iu=2,Lu=1,Ru=0,zu;(function(e){e[e.TooShort=0]=`TooShort`,e[e.HeaderOverrun=1]=`HeaderOverrun`,e[e.MissingExtWords=2]=`MissingExtWords`,e[e.UnsupportedVersion=3]=`UnsupportedVersion`,e[e.InvalidHandle=4]=`InvalidHandle`,e[e.MalformedExt=5]=`MalformedExt`})(zu||={});var Bu=class e extends ka{constructor(e,t,n){super(19,e,n),this.name=`DataTrackDeserializeError`,this.reason=t,this.reasonName=zu[t]}static tooShort(){return new e(`Too short to contain a valid header`,zu.TooShort)}static headerOverrun(){return new e(`Header exceeds total packet length`,zu.HeaderOverrun)}static missingExtWords(){return new e(`Extension word indicator is missing`,zu.MissingExtWords)}static unsupportedVersion(t){return new e(`Unsupported version ${t}`,zu.UnsupportedVersion)}static invalidHandle(t){return new e(`invalid track handle: ${t.message}`,zu.InvalidHandle,{cause:t})}static malformedExt(t){return new e(`Extension with tag ${t} is malformed`,zu.MalformedExt)}},Vu;(function(e){e[e.TooSmallForHeader=0]=`TooSmallForHeader`,e[e.TooSmallForPayload=1]=`TooSmallForPayload`})(Vu||={});var Hu=class e extends ka{constructor(e,t,n){super(19,e,n),this.name=`DataTrackSerializeError`,this.reason=t,this.reasonName=Vu[t]}static tooSmallForHeader(){return new e(`Buffer cannot fit header`,Vu.TooSmallForHeader)}static tooSmallForPayload(){return new e(`Buffer cannot fit payload`,Vu.TooSmallForPayload)}},Uu=class{toBinary(){let e=this.toBinaryLengthBytes(),t=new ArrayBuffer(e),n=new DataView(t),r=this.toBinaryInto(n);if(e!==r)throw Error(`${this.constructor.name}.toBinary: written bytes (${r} bytes) not equal to allocated array buffer length (${e} bytes).`);return new Uint8Array(t)}},Wu;(function(e){e[e.UserTimestamp=2]=`UserTimestamp`,e[e.E2ee=1]=`E2ee`})(Wu||={});var Gu=class extends Uu{},Ku=class e extends Gu{constructor(e){super(),this.timestamp=e}toBinaryLengthBytes(){return 2+e.lengthBytes}toBinaryInto(t){let n=0;t.setUint8(n,e.tag),n+=xu,t.setUint8(n,e.lengthBytes),n+=xu,t.setBigUint64(n,this.timestamp),n+=wu;let r=this.toBinaryLengthBytes();if(n!==r)throw Error(`DataTrackUserTimestampExtension.toBinaryInto: Wrote ${n} bytes but expected length was ${r} bytes`);return n}toJSON(){return{tag:e.tag,lengthBytes:e.lengthBytes,timestamp:this.timestamp}}};Ku.tag=Wu.UserTimestamp,Ku.lengthBytes=8;var qu=class e extends Gu{constructor(e,t){super(),this.keyIndex=e,this.iv=t}toBinaryLengthBytes(){return 2+e.lengthBytes}toBinaryInto(t){let n=0;t.setUint8(n,e.tag),n+=xu,t.setUint8(n,e.lengthBytes),n+=xu,t.setUint8(n,this.keyIndex),n+=xu;for(let e=0;e0&&arguments[0]!==void 0?arguments[0]:{};super(),this.userTimestamp=e.userTimestamp,this.e2ee=e.e2ee}toBinaryLengthBytes(){let e=0;return this.userTimestamp&&(e+=this.userTimestamp.toBinaryLengthBytes()),this.e2ee&&(e+=this.e2ee.toBinaryLengthBytes()),e}toBinaryInto(e){let t=0;if(this.e2ee){let n=this.e2ee.toBinaryInto(e);t+=n}if(this.userTimestamp){let n=this.userTimestamp.toBinaryInto(new DataView(e.buffer,e.byteOffset+t));t+=n}let n=this.toBinaryLengthBytes();if(t!==n)throw Error(`DataTrackExtensions.toBinaryInto: Wrote ${t} bytes but expected length was ${n} bytes`);return t}static fromBinary(t){let n=xc(t),r,i,a=0;for(;n.byteLength-a>=2;){let e=n.getUint8(a);a+=xu;let t=n.getUint8(a);if(a+=xu,e!==Ru)switch(e){case Wu.UserTimestamp:if(n.byteLength-a{}),t}catch(e){throw e}}setPipelineOptions(e){this.manager.setPipelineOptions(this.info.sid,e)}},$u=class e extends Uu{constructor(e){super(),this.marker=e.marker,this.trackHandle=e.trackHandle,this.sequence=e.sequence,this.frameNumber=e.frameNumber,this.timestamp=e.timestamp,this.extensions=e.extensions??new Ju}extensionsMetrics(){let e=this.extensions.toBinaryLengthBytes(),t=Math.ceil((Fu+e)/4);return{lengthBytes:e,lengthWords:t,paddingLengthBytes:t*4-Fu-e}}toBinaryLengthBytes(){let{lengthBytes:e,paddingLengthBytes:t}=this.extensionsMetrics(),n=Eu;return e>0&&(n+=Fu+e+t),n}toBinaryInto(e){if(e.byteLength0&&(t|=1<0){let t=i-1;e.setUint16(o,t),o+=Su;let n=this.extensions.toBinaryInto(new DataView(e.buffer,e.byteOffset+o));o+=n;for(let t=0;t>Du&Ou;if(a>Tu)throw Bu.unsupportedVersion(a);let o;switch(i>>ku&Au){case ju:o=ed.Start;break;case Mu:o=ed.Final;break;case Pu:o=ed.Single;break;case Nu:default:o=ed.Inter;break}let s=(i>>Iu&Lu)>0;r+=xu;let c;try{c=wc.fromNumber(n.getUint16(r))}catch(e){throw e instanceof Cc&&(e.isReason(Sc.Reserved)||e.isReason(Sc.TooLarge))?Bu.invalidHandle(e):e}r+=Su;let l=vc.u16(n.getUint16(r));r+=Su;let u=vc.u16(n.getUint16(r));r+=Su;let d=yc.fromRtpTicks(n.getUint32(r));r+=Cu;let f=new Ju;if(s){if(n.byteLength-rn.byteLength)throw Bu.headerOverrun();let i=new DataView(n.buffer,n.byteOffset+r,t),[a,o]=Ju.fromBinary(i);f=a,r+=o}return[new e({marker:o,trackHandle:c,sequence:l,frameNumber:u,timestamp:d,extensions:f}),r]}toJSON(){return{marker:this.marker,trackHandle:this.trackHandle,sequence:this.sequence.value,frameNumber:this.frameNumber.value,timestamp:this.timestamp.asTicks(),extensions:this.extensions.toJSON()}}},ed;(function(e){e[e.Start=0]=`Start`,e[e.Inter=1]=`Inter`,e[e.Final=2]=`Final`,e[e.Single=3]=`Single`})(ed||={});var td=class e extends Uu{constructor(e,t){super(),this.header=e,this.payload=t}toBinaryLengthBytes(){return this.header.toBinaryLengthBytes()+this.payload.byteLength}toBinaryInto(e){let t=0,n=this.header.toBinaryInto(e);if(t+=n,e.byteLength-t=n){let n=this.peekOldestPartialFrameNumber();if(typeof n!=`number`)throw Error(`Depacketizer.frameFromSingle: no oldest frame number found, but partials.size is ${this.partials.size}.`);if(this.partials.delete(n),t?.throwOnInterruption)throw rd.interrupted(n,e.header.frameNumber.value);nd.warn(`Data track frame ${n} was interrupted by single-packet frame ${e.header.frameNumber.value}, dropping.`)}return{payload:e.payload,extensions:e.header.extensions}}beginPartial(e,t){if(e.header.marker!==ed.Start)throw Error(`Depacketizer.beginPartial: packet.header.marker was not FrameMarker.Start, found ${e.header.marker}.`);let n=e.header.sequence,r=e.header.frameNumber.value,i={startSequence:n,extensions:e.header.extensions,payloads:new Map([[n.value,e.payload]])},a=t?.maxPartialFrames??1;for(;this.partials.size>=a;){let e=this.peekOldestPartialFrameNumber();if(typeof e!=`number`)break;if(this.partials.delete(e),t?.throwOnInterruption)throw rd.interrupted(e,r);nd.warn(`Data track partials full (max ${a}), evicted oldest frame ${e} to make room for new frame ${r}.`)}return this.partials.set(r,i),null}pushToPartial(t){if(t.header.marker!==ed.Inter&&t.header.marker!==ed.Final)throw Error(`Depacketizer.pushToPartial: packet.header.marker was not FrameMarker.Inter or FrameMarker.Final, found ${t.header.marker}.`);let n=t.header.frameNumber.value,r=this.partials.get(n);if(!r)throw this.partials.delete(n),rd.unknownFrame(n);if(r.payloads.size>=e.MAX_BUFFER_PACKETS)throw this.partials.delete(n),rd.bufferFull(n);return r.payloads.has(t.header.sequence.value)&&nd.warn(`Data track frame ${n} received duplicate packet for sequence ${t.header.sequence.value}, so replacing with newly received packet.`),r.payloads.set(t.header.sequence.value,t.payload),t.header.marker===ed.Final?this.finalize(n,r,t.header.sequence.value):null}finalize(e,t,n){let r=t.payloads.size,i=0;for(let e of t.payloads.values())i+=e.length;let a=new Uint8Array(i),o=t.startSequence.clone(),s=0;for(;;){let r=t.payloads.get(o.value);if(!r)break;t.payloads.delete(o.value);let i=a.length-s;if(r.length>i)throw Error(`Depacketizer.finalize: Expected at least ${r.length} more bytes left in the payload buffer, only got ${i} bytes.`);if(a.set(r,s),s+=r.length,o.value!=n){o.increment();continue}return this.partials.delete(e),{payload:a,extensions:t.extensions}}throw this.partials.delete(e),rd.incomplete(e,r,n-t.startSequence.value+1)}};ad.MAX_BUFFER_PACKETS=128;var od;(function(e){e[e.Unpublished=0]=`Unpublished`,e[e.Timeout=1]=`Timeout`,e[e.Disconnected=2]=`Disconnected`,e[e.Cancelled=4]=`Cancelled`})(od||={});var sd=class e extends ka{constructor(e,t,n){super(22,e,n),this.name=`DataTrackSubscribeError`,this.reason=t,this.reasonName=od[t]}static unpublished(){return new e(`The track has been unpublished and is no longer available`,od.Unpublished)}static timeout(){return new e(`Request to subscribe to data track timed-out`,od.Timeout)}static disconnected(){return new e(`Cannot subscribe to data track when disconnected`,od.Disconnected)}static cancelled(){return new e(`Subscription to data track cancelled by caller`,od.Cancelled)}},cd=Gr(Wr.DataTracks),ld=class{constructor(e){let t=e.e2eeManager!==null;if(e.info.usesE2ee!==t)throw Error(`IncomingDataTrackPipeline: DataTrackInfo.usesE2ee must match presence of decryptionProvider`);let n=new ad;this.publisherIdentity=e.publisherIdentity,this.e2eeManager=e.e2eeManager??null,this.depacketizer=n,this.options=e.pipelineOptions??{}}updateE2eeManager(e){this.e2eeManager=e}setOptions(e){this.options=e}processPacket(e){return L(this,void 0,void 0,function*(){let t=this.depacketize(e);return t&&(yield this.decryptIfNeeded(t))||null})}depacketize(e){let t;try{t=this.depacketizer.push(e,{throwOnInterruption:!1,maxPartialFrames:this.options.maxPartialFrames})}catch(e){return cd.warn(`Data frame depacketize error: ${e}`),null}return t}decryptIfNeeded(e){return L(this,void 0,void 0,function*(){let t=this.e2eeManager;if(!t)return e;let n=e.extensions?.e2ee??null;if(!n)return cd.error(`Missing E2EE meta`),null;let r;try{r=yield t.handleEncryptedData(e.payload,n.iv,this.publisherIdentity,n.keyIndex)}catch(e){return cd.error(`Error decrypting packet: ${e}`),null}return e.payload=r.payload,e})}},ud=Gr(Wr.DataTracks),dd=1e4,fd=16,pd=class extends oi.EventEmitter{constructor(e){super(),this.descriptors=new Map,this.subscriptionHandles=new Map,this.e2eeManager=e?.e2eeManager??null}updateE2eeManager(e){this.e2eeManager=e;for(let t of this.descriptors.values())t.subscription.type===`active`&&t.subscription.pipeline.updateE2eeManager(e)}setPipelineOptions(e,t){let n=this.descriptors.get(e);if(!n){ud.warn(`Unknown track ${e}, cannot set pipeline options.`);return}n.pipelineOptions=t,n.subscription.type===`active`&&n.subscription.pipeline.setOptions(t)}openSubscriptionStream(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:fd,r=null,i=new ss,a=()=>{t?.removeEventListener(`abort`,s)},o=()=>{if(a(),!r){ud.warn(`ReadableStream subscribed to ${e} was not started.`);return}let t=this.descriptors.get(e);if(!t){ud.warn(`Unknown track ${e}, skipping cancel...`);return}if(t.subscription.type!==`active`){ud.warn(`Subscription for track ${e} is not active, skipping cancel...`);return}t.subscription.streamControllers.delete(r),t.subscription.streamControllers.size===0&&this.unSubscribeRequest(t.info.sid)},s=()=>{var t;if(!r)return;let n=this.descriptors.get(e);n?.subscription.type===`active`&&n.subscription.streamControllers.delete(r),r.error(sd.cancelled()),(t=i.reject)==null||t.call(i,sd.cancelled()),o()};return[new ReadableStream({start:n=>{r=n,this.subscribeRequest(e,t).then(()=>L(this,void 0,void 0,function*(){var r,o,c;let l=this.descriptors.get(e);if(!l){ud.error(`Unknown track ${e}`);let t=sd.disconnected();n.error(t),(r=i.reject)==null||r.call(i,t);return}if(l.subscription.type!==`active`){ud.error(`Subscription for track ${e} is not active`);let t=sd.disconnected();n.error(t),(o=i.reject)==null||o.call(i,t);return}if(t?.aborted){s();return}t?.addEventListener(`abort`,s),l.subscription.streamControllers.set(n,a),(c=i.resolve)==null||c.call(i)})).catch(e=>{var t;n.error(e),(t=i.reject)==null||t.call(i,e)})},cancel:()=>{o()}},new CountQueuingStrategy({highWaterMark:n})),i.promise]}subscribeRequest(e,t){return L(this,void 0,void 0,function*(){let n=this.descriptors.get(e);if(!n)throw Error(`Cannot subscribe to unknown track`);let r=(t,n,r)=>L(this,void 0,void 0,function*(){if(t.subscription.type===`active`)return;if(t.subscription.type!==`pending`)throw Error(`Descriptor for track ${e} is not pending, found ${t.subscription.type}`);let i=yu([n,r].filter(e=>e!==void 0)),a=new ss;t.subscription.completionFuture.promise.then(()=>a.resolve?.call(a)).catch(e=>a.reject?.call(a,e));let o=()=>{var e;if(t.subscription.type===`pending`){if(--t.subscription.pendingRequestCount,r?.aborted){t.subscription.cancel();return}if(t.subscription.pendingRequestCount<=0){t.subscription.cancel();return}(e=a.reject)==null||e.call(a,sd.cancelled())}};i.aborted&&o(),i.addEventListener(`abort`,o),yield a.promise,i.removeEventListener(`abort`,o)});switch(n.subscription.type){case`none`:{n.subscription={type:`pending`,completionFuture:new ss,pendingRequestCount:1,cancel:()=>{var t,r;let a=n.subscription;n.subscription={type:`none`},this.emit(`sfuUpdateSubscription`,{sid:e,subscribe:!1}),a.type===`pending`&&((r=(t=a.completionFuture).reject)==null||r.call(t,i.aborted?sd.timeout():sd.cancelled()))}},this.emit(`sfuUpdateSubscription`,{sid:e,subscribe:!0});let i=bu(dd);yield r(n,t,i);return}case`pending`:n.subscription.pendingRequestCount+=1,yield r(n,t);return;case`active`:return}})}querySubscribed(){return L(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).filter(e=>e.subscription.type===`active`).map(e=>[e.info,e.publisherIdentity])})}unSubscribeRequest(e){let t=this.descriptors.get(e);if(!t)throw Error(`Cannot subscribe to unknown track`);if(t.subscription.type!==`active`){ud.warn(`Unexpected descriptor state in unSubscribeRequest, expected active, found ${t.subscription?.type}`);return}this.closeStreamControllers(t.subscription.streamControllers,e);let n=t.subscription;t.subscription={type:`none`},this.subscriptionHandles.delete(n.subcriptionHandle),this.emit(`sfuUpdateSubscription`,{sid:e,subscribe:!1})}closeStreamControllers(e,t){for(let[n,r]of e){r();try{n.close()}catch(e){ud.warn(`Failed to close readable stream for track ${t}: ${e}`)}}}receiveSfuPublicationUpdates(e){return L(this,void 0,void 0,function*(){if(e.size===0)return;let t=new Map;for(let[n,r]of e.entries()){let e=new Set;for(let t of r)e.add(t.sid),!this.descriptors.has(t.sid)&&(yield this.handleTrackPublished(n,t));t.set(n,e)}for(let[e,n]of t.entries()){let t=Array.from(this.descriptors.entries()).filter(t=>{let[n,r]=t;return r.publisherIdentity===e}).map(e=>{let[t]=e;return t}).filter(e=>!n.has(e));for(let e of t)this.handleTrackUnpublished(e)}})}queryPublications(){return L(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).map(e=>e.info)})}handleTrackPublished(e,t){return L(this,void 0,void 0,function*(){if(this.descriptors.has(t.sid)){ud.error(`Existing descriptor for track ${t.sid}`);return}let n={info:t,publisherIdentity:e,subscription:{type:`none`},pipelineOptions:{}};this.descriptors.set(n.info.sid,n);let r=new Qu(n.info,this,{publisherIdentity:e});this.emit(`trackPublished`,{track:r})})}handleTrackUnpublished(e){let t=this.descriptors.get(e);if(!t){ud.error(`Unknown track ${e}`);return}this.descriptors.delete(e),t.subscription.type===`active`&&(this.closeStreamControllers(t.subscription.streamControllers,e),this.subscriptionHandles.delete(t.subscription.subcriptionHandle)),this.emit(`trackUnpublished`,{sid:e,publisherIdentity:t.publisherIdentity})}receivedSfuSubscriberHandles(e){for(let[t,n]of e.entries())this.registerSubscriberHandle(t,n)}registerSubscriberHandle(e,t){var n,r;let i=this.descriptors.get(t);if(!i){ud.error(`Unknown track ${t}`);return}switch(i.subscription.type){case`none`:ud.warn(`No subscription for ${t}`);return;case`active`:i.subscription.subcriptionHandle=e,this.subscriptionHandles.set(e,t);return;case`pending`:{let a=new ld({info:i.info,publisherIdentity:i.publisherIdentity,e2eeManager:this.e2eeManager,pipelineOptions:i.pipelineOptions}),o=i.subscription;i.subscription={type:`active`,subcriptionHandle:e,pipeline:a,streamControllers:new Map},this.subscriptionHandles.set(e,t),(r=(n=o.completionFuture).resolve)==null||r.call(n)}}}packetReceived(e){return L(this,void 0,void 0,function*(){let t;try{[t]=td.fromBinary(e)}catch(e){ud.error(`Failed to deserialize packet: ${e}`);return}let n=this.subscriptionHandles.get(t.header.trackHandle);if(!n){ud.warn(`Unknown subscriber handle ${t.header.trackHandle}`);return}let r=this.descriptors.get(n);if(!r){ud.error(`Missing descriptor for track ${n}`);return}if(r.subscription.type!==`active`){ud.warn(`Received packet for track ${n} without active subscription`);return}let i=yield r.subscription.pipeline.processPacket(t);if(i)for(let e of r.subscription.streamControllers.keys()){if(e.desiredSize!==null&&e.desiredSize<=0){ud.warn(`Cannot send frame to subscribers: readable stream is full (desiredSize is ${e.desiredSize}). To increase this threshold, set a higher 'options.highWaterMark' when calling .subscribe().`);continue}let t=Yu.lossyIntoFrame(i);e.enqueue(t)}})}resendSubscriptionUpdates(){for(let[e,t]of this.descriptors)t.subscription.type!==`none`&&this.emit(`sfuUpdateSubscription`,{sid:e,subscribe:!0})}handleRemoteParticipantDisconnected(e){var t,n;for(let r of this.descriptors.values())if(r.publisherIdentity===e)switch(r.subscription.type){case`none`:break;case`pending`:(n=(t=r.subscription.completionFuture).reject)==null||n.call(t,sd.disconnected());break;case`active`:this.unSubscribeRequest(r.info.sid);break}}reset(){var e,t;for(let n of this.descriptors.values())this.emit(`trackUnpublished`,{sid:n.info.sid,publisherIdentity:n.publisherIdentity}),n.subscription.type===`pending`&&((t=(e=n.subscription.completionFuture).reject)==null||t.call(e,sd.disconnected())),n.subscription.type===`active`&&this.closeStreamControllers(n.subscription.streamControllers,n.info.sid);this.descriptors.clear(),this.subscriptionHandles.clear()}},md=class e extends ka{constructor(e,t,n){super(19,e,n),this.name=`DataTrackPacketizerError`,this.reason=t,this.reasonName=hd[t]}static mtuTooShort(){return new e(`MTU is too short to send frame`,hd.MtuTooShort)}},hd;(function(e){e[e.MtuTooShort=0]=`MtuTooShort`})(hd||={});var gd=class e{constructor(e,t){this.sequence=vc.u16(0),this.frameNumber=vc.u16(0),this.clock=bc.rtpStartingNow(yc.rtpRandom()),this.handle=e,this.mtuSizeBytes=t}static computeFrameMarker(e,t){return t<=1?ed.Single:e===0?ed.Start:e===t-1?ed.Final:ed.Inter}*packetize(t,n){let r=this.frameNumber.getThenIncrement(),i={marker:ed.Inter,trackHandle:this.handle,sequence:vc.u16(0),frameNumber:r,timestamp:n?.now??this.clock.now(),extensions:t.extensions},a=new $u(i).toBinaryLengthBytes();if(a>=this.mtuSizeBytes)throw md.mtuTooShort();let o=this.mtuSizeBytes-a,s=Math.ceil(t.payload.byteLength/o);for(let n=0,r=0;r{var e,t;(t=(e=this.flushedFuture).resolve)==null||t.call(e),this.manager.off(`packetsFlushedChange`,this.handleManagerPacketsFlushedChange),this.manager.off(`reset`,this.handleManagerReset)},this.handleManagerPacketsFlushedChange=e=>{var t,n;this.isFlushed=e.isFlushed,e.isFlushed&&((n=(t=this.flushedFuture).resolve)==null||n.call(t),this.flushedFuture=new ss)},this.options=e,this.manager=t,this.log=Gr(Wr.DataTracks),this.manager.on(`packetsFlushedChange`,this.handleManagerPacketsFlushedChange),this.manager.on(`reset`,this.handleManagerReset)}static withExplicitHandle(t,n,r){let i=new e(t,n);return i.handle=r,i}get info(){let e=this.descriptor;if(e?.type===`active`)return e.info}get descriptor(){return this.handle?this.manager.getDescriptor(this.handle):null}publish(e){return L(this,void 0,void 0,function*(){try{this.handle=yield this.manager.publishRequest(this.options,e)}catch(e){throw e}})}isPublished(){return this.descriptor?.type===`active`&&this.descriptor.publishState!==`unpublished`}tryPush(e){if(!this.handle)throw bd.trackUnpublished();let t=Yu.from(e);try{return this.manager.tryProcessAndSend(this.handle,t)}catch(e){throw e}}flush(){return L(this,void 0,void 0,function*(){if(!this.isFlushed)return this.flushedFuture.promise})}unpublish(){return L(this,void 0,void 0,function*(){if(!this.handle){I.warn(`Data track "${this.options.name}" is not published, so unpublishing has no effect.`);return}try{yield this.manager.unpublishRequest(this.handle)}catch(e){throw e}})}},wd=class e{constructor(t){this.e2eeManager=t.e2eeManager,this.packetizer=new gd(t.info.pubHandle,e.TRANSPORT_MTU_BYTES)}updateE2eeManager(e){this.e2eeManager=e}processFrame(e){return ei(this,arguments,function*(){let t=yield $r(this.encryptIfNeeded(e));try{yield $r(yield*ti(ni(this.packetizer.packetize(t))))}catch(e){throw e instanceof md?Sd.packetizer(e):e}})}encryptIfNeeded(e){return L(this,void 0,void 0,function*(){if(!this.e2eeManager)return e;let t;try{t=yield this.e2eeManager.encryptData(e.payload)}catch(e){throw Sd.encryption(e)}return e.payload=t.payload,e.extensions.e2ee=new qu(t.keyIndex,t.iv),e})}};wd.TRANSPORT_MTU_BYTES=16e3;var Td=Gr(Wr.DataTracks),Ed={pending(){return{type:`pending`,completionFuture:new ss}},active(e,t){return{type:`active`,info:e,publishState:`published`,pipeline:new wd({info:e,e2eeManager:t}),unpublishingFuture:new ss}}},Dd=1e4,Od=class e extends oi.EventEmitter{constructor(e){super(),this.handleAllocator=new Tc,this.descriptors=new Map,this.inFlightPacketCounter=new Map,this.e2eeManager=e?.e2eeManager??null}static withDescriptors(t){let n=new e;return n.descriptors=t,n}updateE2eeManager(e){this.e2eeManager=e;for(let t of this.descriptors.values())t.type===`active`&&t.pipeline.updateE2eeManager(e)}getDescriptor(e){return this.descriptors.get(e)??null}tryProcessAndSend(e,t){return L(this,void 0,void 0,function*(){var n,r,i,a;let o=this.getDescriptor(e);if(o?.type!==`active`||o.publishState===`unpublished`)throw bd.trackUnpublished();if(o.publishState===`republishing`)throw bd.dropped(`Data track republishing`);try{try{for(var s=!0,c=ni(o.pipeline.processFrame(t)),l;l=yield c.next(),n=l.done,!n;s=!0){a=l.value,s=!1;let t=a,n=this.inFlightPacketCounter.get(e)??0;this.inFlightPacketCounter.set(e,n+1),n===0&&this.emit(`packetsFlushedChange`,{handle:e,isFlushed:!1}),this.emit(`packetAvailable`,{handle:e,bytes:t.toBinary()})}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}}catch(e){throw bd.dropped(e)}})}handlePacketSendComplete(e){let t=(this.inFlightPacketCounter.get(e)??0)-1;t<0&&(Td.warn(`OutgoingDataTrackManager.handlePacketSendComplete: inFlightPacketCounter was decremented below 0 (got ${this.inFlightPacketCounter} - resetting to 0. Were more packets send than were emitted?`),t=0),this.inFlightPacketCounter.set(e,t),t===0&&this.emit(`packetsFlushedChange`,{handle:e,isFlushed:!0})}publishRequest(e,t){return L(this,void 0,void 0,function*(){let n=this.handleAllocator.get();if(!n)throw vd.limitReached();let r=bu(Dd),i=t?yu([t,r]):r;if(this.descriptors.has(n))throw Error(`Descriptor for handle already exists`);let a=Ed.pending();this.descriptors.set(n,a);let o=()=>{var e,t;let i=this.descriptors.get(n);if(!i){Td.warn(`No descriptor for ${n}`);return}this.descriptors.delete(n),this.emit(`sfuUnpublishRequest`,{handle:n}),i.type===`pending`&&((t=(e=i.completionFuture).reject)==null||t.call(e,r.aborted?vd.timeout():vd.cancelled()))};return i.aborted?(o(),a.completionFuture.promise.then(()=>n)):(i.addEventListener(`abort`,o),this.emit(`sfuPublishRequest`,{handle:n,name:e.name,usesE2ee:this.e2eeManager!==null}),yield a.completionFuture.promise,i.removeEventListener(`abort`,o),this.emit(`trackPublished`,{track:Cd.withExplicitHandle(e,this,n)}),n)})}queryPublished(){return Array.from(this.descriptors.values()).filter(e=>e.type===`active`).map(e=>e.info)}unpublishRequest(e){return L(this,void 0,void 0,function*(){let t=this.descriptors.get(e);if(!t){Td.warn(`No descriptor for ${e}`);return}if(t.type!==`active`){Td.warn(`Track ${e} not active`);return}this.emit(`sfuUnpublishRequest`,{handle:e}),yield t.unpublishingFuture.promise,this.inFlightPacketCounter.delete(e),this.emit(`trackUnpublished`,{sid:t.info.sid})})}receivedSfuPublishResponse(e,t){var n,r,i,a;let o=this.descriptors.get(e);if(!o){Td.warn(`No descriptor for ${e}`);return}switch(this.descriptors.delete(e),o.type){case`pending`:if(t.type===`ok`){let e=t.data,i=e.usesE2ee?this.e2eeManager:null;this.descriptors.set(e.pubHandle,Ed.active(e,i)),(r=(n=o.completionFuture).resolve)==null||r.call(n)}else (a=(i=o.completionFuture).reject)==null||a.call(i,t.error);return;case`active`:if(o.publishState!==`republishing`){Td.warn(`Track ${e} already active`);return}if(t.type===`error`){Td.warn(`Republish failed for track ${e}`);return}Td.debug(`Track ${e} republished`),o.info.sid=t.data.sid,o.publishState=`published`,this.descriptors.set(o.info.pubHandle,o)}}receivedSfuUnpublishResponse(e){var t,n;let r=this.descriptors.get(e);if(!r){Td.warn(`No descriptor for ${e}`);return}if(this.descriptors.delete(e),r.type!==`active`){Td.warn(`Track ${e} not active`);return}r.publishState=`unpublished`,(n=(t=r.unpublishingFuture).resolve)==null||n.call(t)}sfuWillRepublishTracks(){var e,t;for(let[n,r]of this.descriptors.entries())switch(r.type){case`pending`:this.descriptors.delete(n),(t=(e=r.completionFuture).reject)==null||t.call(e,vd.disconnected());break;case`active`:r.publishState=`republishing`,this.emit(`sfuPublishRequest`,{handle:r.info.pubHandle,name:r.info.name,usesE2ee:r.info.usesE2ee})}}reset(){return L(this,void 0,void 0,function*(){var e,t,n,r;this.handleAllocator.reset();for(let i of this.descriptors.values())switch(i.type){case`pending`:(t=(e=i.completionFuture).reject)==null||t.call(e,vd.disconnected());break;case`active`:(r=(n=i.unpublishingFuture).resolve)==null||r.call(n),yield this.unpublishRequest(i.info.pubHandle);break}this.descriptors.clear(),this.inFlightPacketCounter.clear(),this.emit(`reset`)})}},kd=class e extends Error{constructor(t,n,r,i){super(n),this.code=t,this.message=Ld(n,e.MAX_MESSAGE_BYTES),this.data=r?Ld(r,e.MAX_DATA_BYTES):void 0,i?.cause!==void 0&&(this.cause=i?.cause)}static fromProto(t){return new e(t.code,t.message,t.data)}toProto(){return new un({code:this.code,message:this.message,data:this.data})}static builtIn(t,n,r){return new e(e.ErrorCode[t],e.ErrorMessage[t],n,r)}};kd.MAX_MESSAGE_BYTES=256,kd.MAX_DATA_BYTES=15360,kd.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404},kd.ErrorMessage={APPLICATION_ERROR:`Application error in method handler`,CONNECTION_TIMEOUT:`Connection timeout`,RESPONSE_TIMEOUT:`Response timeout`,RECIPIENT_DISCONNECTED:`Recipient disconnected`,RESPONSE_PAYLOAD_TOO_LARGE:`Response payload too large`,SEND_FAILED:`Failed to send`,UNSUPPORTED_METHOD:`Method not supported at destination`,RECIPIENT_NOT_FOUND:`Recipient not found`,REQUEST_PAYLOAD_TOO_LARGE:`Request payload too large`,UNSUPPORTED_SERVER:`RPC not supported by server`,UNSUPPORTED_VERSION:`Unsupported RPC version`};var Ad=15360,jd=`lk.rpc_request`,Md=`lk.rpc_response`,Nd;(function(e){e.RPC_REQUEST_ID=`lk.rpc_request_id`,e.RPC_REQUEST_METHOD=`lk.rpc_request_method`,e.RPC_REQUEST_RESPONSE_TIMEOUT_MS=`lk.rpc_request_response_timeout_ms`,e.RPC_REQUEST_VERSION=`lk.rpc_request_version`})(Nd||={});var Pd=1,Fd=2;function Id(e){return new TextEncoder().encode(e).length}function Ld(e,t){if(Id(e)<=t)return e;let n=0,r=e.length,i=new TextEncoder;for(;nAd&&e<1)throw kd.builtIn(`REQUEST_PAYLOAD_TOO_LARGE`);let o=t.getServerVersion();if(o&&Xo(o,`1.8.0`)<0)throw kd.builtIn(`UNSUPPORTED_SERVER`);let s=Math.max(a,8e3),c=crypto.randomUUID(),l=new ss,u=setTimeout(()=>{var e;t.pendingAcks.delete(c),(e=l.reject)==null||e.call(l,kd.builtIn(`CONNECTION_TIMEOUT`)),t.pendingResponses.delete(c),clearTimeout(d)},7e3);t.pendingAcks.set(c,{resolve:()=>{clearTimeout(u)},participantIdentity:n}),t.pendingResponses.set(c,{completionFuture:l,participantIdentity:n}),yield t.publishRpcRequest(n,c,r,i,s,e);let d=setTimeout(()=>{var e;t.pendingResponses.delete(c),(e=l.reject)==null||e.call(l,kd.builtIn(`RESPONSE_TIMEOUT`))},a);return[c,l.promise.finally(()=>{clearTimeout(d),t.pendingAcks.has(c)&&(t.log.warn(`RPC response received before ack`,c),t.pendingAcks.delete(c),clearTimeout(u))})]}()})}publishRpcRequest(e,t,n,r,i,a){return L(this,void 0,void 0,function*(){if(a>=1){let a=yield this.outgoingDataStreamManager.streamText({topic:jd,destinationIdentities:[e],attributes:{[Nd.RPC_REQUEST_ID]:t,[Nd.RPC_REQUEST_METHOD]:n,[Nd.RPC_REQUEST_RESPONSE_TIMEOUT_MS]:`${i}`,[Nd.RPC_REQUEST_VERSION]:`${Fd}`}});yield a.write(r),yield a.close();return}this.emit(`sendDataPacket`,{packet:new Yt({destinationIdentities:[e],kind:Xt.RELIABLE,value:{case:`rpcRequest`,value:new sn({id:t,method:n,payload:r,responseTimeoutMs:i,version:Pd})}})})})}handleIncomingDataStream(e,t,n){return L(this,void 0,void 0,function*(){let r=n[Nd.RPC_REQUEST_ID];if(!r){this.log.warn(`RPC data stream malformed: ${Nd.RPC_REQUEST_ID} not set.`);return}let i=this.pendingResponses.get(r);if(i&&i.participantIdentity!==t){this.log.warn(`RPC response stream for ${r} arrived from unexpected sender ${t}, expected ${i.participantIdentity}. Ignoring.`);return}let a;try{a=yield e.readAll()}catch(e){this.log.warn(`Error reading RPC response payload: ${e}`),this.handleIncomingRpcResponseFailure(r,kd.builtIn(`APPLICATION_ERROR`,`Error reading RPC response payload`,{cause:e}));return}this.handleIncomingRpcResponseSuccess(r,a)})}handleIncomingRpcResponseSuccess(e,t){var n,r;let i=this.pendingResponses.get(e);i?((r=(n=i.completionFuture).resolve)==null||r.call(n,t),this.pendingResponses.delete(e)):this.log.error(`Response received for unexpected RPC request`,e)}handleIncomingRpcResponseFailure(e,t){var n,r;let i=this.pendingResponses.get(e);i?((r=(n=i.completionFuture).reject)==null||r.call(n,t),this.pendingResponses.delete(e)):this.log.error(`Response received for unexpected RPC request`,e)}handleIncomingRpcAck(e){let t=this.pendingAcks.get(e);t?(t.resolve(),this.pendingAcks.delete(e)):this.log.error(`Ack received for unexpected RPC request: ${e}`)}handleParticipantDisconnected(e){var t;for(let[t,{participantIdentity:n}]of this.pendingAcks)n===e&&this.pendingAcks.delete(t);for(let[n,{participantIdentity:r,completionFuture:i}]of this.pendingResponses)r===e&&((t=i.reject)==null||t.call(i,kd.builtIn(`RECIPIENT_DISCONNECTED`)),this.pendingResponses.delete(n))}},zd=class extends si{constructor(e,t,n){super(),this.rpcHandlers=new Map,this.log=e,this.outgoingDataStreamManager=t,this.getRemoteParticipantClientProtocol=n}registerRpcMethod(e,t){if(this.rpcHandlers.has(e))throw Error(`RPC handler already registered for method ${e}, unregisterRpcMethod before trying to register again`);this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,t){return L(this,void 0,void 0,function*(){if(this.publishRpcAck(e,t.id),t.version!==1){this.publishRpcResponsePacket(e,t.id,null,kd.builtIn(`UNSUPPORTED_VERSION`));return}let n=this.rpcHandlers.get(t.method);if(!n){this.publishRpcResponsePacket(e,t.id,null,kd.builtIn(`UNSUPPORTED_METHOD`));return}let r;try{r=yield n({requestId:t.id,callerIdentity:e,payload:t.payload,responseTimeout:t.responseTimeoutMs})}catch(n){let r;n instanceof kd?r=n:(this.log.warn(`Uncaught error returned by RPC handler for ${t.method}. Returning APPLICATION_ERROR instead.`,n),r=kd.builtIn(`APPLICATION_ERROR`,`Uncaught error: ${n?.message??n}`,{cause:n})),this.publishRpcResponsePacket(e,t.id,null,r);return}yield this.publishRpcResponse(e,t.id,r??``)})}handleIncomingDataStream(e,t,n){return L(this,void 0,void 0,function*(){let r=n[Nd.RPC_REQUEST_ID],i=n[Nd.RPC_REQUEST_METHOD],a=parseInt(n[Nd.RPC_REQUEST_RESPONSE_TIMEOUT_MS],10),o=parseInt(n[Nd.RPC_REQUEST_VERSION],10);if(!r||!i||Number.isNaN(a)||Number.isNaN(o)){this.log.warn(`RPC data stream malformed: ${Nd.RPC_REQUEST_ID} / ${Nd.RPC_REQUEST_METHOD} / ${Nd.RPC_REQUEST_RESPONSE_TIMEOUT_MS} / ${Nd.RPC_REQUEST_VERSION} not set.`),this.publishRpcResponsePacket(t,r,null,kd.builtIn(`APPLICATION_ERROR`,`RPC data stream malformed`));return}if(this.publishRpcAck(t,r),o!==Fd){this.publishRpcResponsePacket(t,r,null,kd.builtIn(`UNSUPPORTED_VERSION`));return}let s;try{s=yield e.readAll()}catch(e){this.log.warn(`Error reading RPC request payload: ${e}`),this.publishRpcResponsePacket(t,r,null,kd.builtIn(`APPLICATION_ERROR`,`Error reading RPC request payload`,{cause:e}));return}let c=this.rpcHandlers.get(i);if(!c){this.publishRpcResponsePacket(t,r,null,kd.builtIn(`UNSUPPORTED_METHOD`));return}let l;try{l=yield c({requestId:r,callerIdentity:t,payload:s,responseTimeout:a})}catch(e){let n;e instanceof kd?n=e:(this.log.warn(`Uncaught error returned by RPC handler for ${i}. Returning APPLICATION_ERROR instead.`,e),n=kd.builtIn(`APPLICATION_ERROR`)),this.publishRpcResponsePacket(t,r,null,n);return}yield this.publishRpcResponse(t,r,l??``)})}publishRpcAck(e,t){this.emit(`sendDataPacket`,{packet:new Yt({destinationIdentities:[e],kind:Xt.RELIABLE,value:{case:`rpcAck`,value:new cn({requestId:t})}})})}publishRpcResponsePacket(e,t,n,r){this.emit(`sendDataPacket`,{packet:new Yt({destinationIdentities:[e],kind:Xt.RELIABLE,value:{case:`rpcResponse`,value:new ln({requestId:t,value:r?{case:`error`,value:r.toProto()}:{case:`payload`,value:n??``}})}})})}publishRpcResponse(e,t,n){return L(this,void 0,void 0,function*(){if(this.getRemoteParticipantClientProtocol(e)>=1){let r=yield this.outgoingDataStreamManager.streamText({topic:Md,destinationIdentities:[e],attributes:{[Nd.RPC_REQUEST_ID]:t}});yield r.write(n),yield r.close();return}if(Id(n)>Ad){this.log.warn(`RPC Response payload too large for request ${t}. To send larger responses, consider updating the sending client.`),this.publishRpcResponsePacket(e,t,null,kd.builtIn(`RESPONSE_PAYLOAD_TOO_LARGE`));return}this.publishRpcResponsePacket(e,t,n,null)})}},Bd=class extends tc{constructor(e,t,n,r,i,a){super(e,t,U.Kind.Audio,n,a),this.monitorReceiver=()=>L(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}let e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=ec(e,this.prevStats)),this.prevStats=e}),this.audioContext=r,this.webAudioPluginNodes=[],i&&(this.sinkId=i.deviceId)}setVolume(e){var t;for(let n of this.attachedElements)this.audioContext?(t=this.gainNode)==null||t.gain.setTargetAtTime(e,0,.1):n.volume=e;Wo()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(Wo())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return L(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(Mo(t))return t.setSinkId(e)}))})}attach(e){let t=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Mo(e)&&e.setSinkId(this.sinkId).catch(e=>{this.log.error(`Failed to set sink id on remote audio track`,e,this.logContext)}),this.audioContext&&t&&(this.log.debug(`using audio context mapping`,this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,t){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(t.srcObject);let n=this.sourceNode;this.webAudioPluginNodes.forEach(e=>{n.connect(e),n=e}),this.gainNode=e.createGain(),n.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!==`running`&&e.resume().then(()=>{e.state!==`running`&&this.emit(H.AudioPlaybackFailed,Error(`Audio Context couldn't be started automatically`))}).catch(e=>{this.emit(H.AudioPlaybackFailed,e)})}disconnectWebAudio(){var e,t;(e=this.gainNode)==null||e.disconnect(),(t=this.sourceNode)==null||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return L(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;let e=yield this.receiver.getStats(),t;return e.forEach(e=>{e.type===`inbound-rtp`&&(t={type:`audio`,streamId:e.id,timestamp:e.timestamp,jitter:e.jitter,bytesReceived:e.bytesReceived,concealedSamples:e.concealedSamples,concealmentEvents:e.concealmentEvents,silentConcealedSamples:e.silentConcealedSamples,silentConcealmentEvents:e.silentConcealmentEvents,totalAudioEnergy:e.totalAudioEnergy,totalSamplesDuration:e.totalSamplesDuration})}),t})}},Vd=class extends oi.EventEmitter{constructor(e,t,n,r){super(),this.metadataMuted=!1,this.encryption=Ht.NONE,this.log=I,this.handleMuted=()=>{this.emit(H.Muted)},this.handleUnmuted=()=>{this.emit(H.Unmuted)},this.log=Gr(r?.loggerName??Wr.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=n,this.source=U.Source.Unknown}setTrack(e){this.track&&(this.track.off(H.Muted,this.handleMuted),this.track.off(H.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(H.Muted,this.handleMuted),e.on(H.Unmuted,this.handleUnmuted))}get logContext(){return Object.assign(Object.assign({},this.loggerContextCb?.call(this)),uo(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==Ht.NONE}get audioTrack(){if(vs(this.track))return this.track}get videoTrack(){if(ys(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=U.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===U.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug(`update publication info`,Object.assign(Object.assign({},this.logContext),{info:e}))}};(function(e){(function(e){e.Desired=`desired`,e.Subscribed=`subscribed`,e.Unsubscribed=`unsubscribed`})(e.SubscriptionStatus||={}),(function(e){e.Allowed=`allowed`,e.NotAllowed=`not_allowed`})(e.PermissionStatus||={})})(Vd||={});var Hd=class extends Vd{get isUpstreamPaused(){return this.track?.isUpstreamPaused}constructor(e,t,n,r){super(e,t.sid,t.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(H.Ended)},this.handleCpuConstrained=()=>{this.track&&ys(this.track)&&this.emit(H.CpuConstrained,this.track)},this.updateInfo(t),this.setTrack(n)}setTrack(e){this.track&&(this.track.off(H.Ended,this.handleTrackEnded),this.track.off(H.CpuConstrained,this.handleCpuConstrained)),super.setTrack(e),e&&(e.on(H.Ended,this.handleTrackEnded),e.on(H.CpuConstrained,this.handleCpuConstrained))}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return L(this,void 0,void 0,function*(){return this.track?.mute()})}unmute(){return L(this,void 0,void 0,function*(){return this.track?.unmute()})}pauseUpstream(){return L(this,void 0,void 0,function*(){yield this.track?.pauseUpstream()})}resumeUpstream(){return L(this,void 0,void 0,function*(){yield this.track?.resumeUpstream()})}getTrackFeatures(){if(vs(this.track)){let e=this.track.getSourceTrackSettings(),t=new Set;return e.autoGainControl&&t.add(Nt.TF_AUTO_GAIN_CONTROL),e.echoCancellation&&t.add(Nt.TF_ECHO_CANCELLATION),e.noiseSuppression&&t.add(Nt.TF_NOISE_SUPPRESSION),e.channelCount&&e.channelCount>1&&t.add(Nt.TF_STEREO),this.options?.dtx||t.add(Nt.TF_NO_DTX),this.track.enhancedNoiseCancellation&&t.add(Nt.TF_ENHANCED_NOISE_CANCELLATION),Array.from(t.values())}else return[]}};function Ud(e,t){return L(this,void 0,void 0,function*(){e??={};let n=!1,{audioProcessor:r,videoProcessor:i,optionsWithoutProcessor:a}=mo(e),o=a.audio,s=a.video;if(r&&typeof a.audio==`object`&&(a.audio.processor=r),i&&typeof a.video==`object`&&(a.video.processor=i),e.audio&&typeof a.audio==`object`&&typeof a.audio.deviceId==`string`){let e=a.audio.deviceId;a.audio.deviceId={exact:e},n=!0,o=Object.assign(Object.assign({},a.audio),{deviceId:{ideal:e}})}if(a.video&&typeof a.video==`object`&&typeof a.video.deviceId==`string`){let e=a.video.deviceId;a.video.deviceId={exact:e},n=!0,s=Object.assign(Object.assign({},a.video),{deviceId:{ideal:e}})}a.audio===!0?a.audio={deviceId:`default`}:typeof a.audio==`object`&&a.audio!==null&&(a.audio=Object.assign(Object.assign({},a.audio),{deviceId:a.audio.deviceId||`default`})),a.video===!0?a.video={deviceId:`default`}:typeof a.video==`object`&&!a.video.deviceId&&(a.video.deviceId=`default`);let c=no(eo(a,ul,dl)),l=navigator.mediaDevices.getUserMedia(c);a.audio&&(hc.userMediaPromiseMap.set(`audioinput`,l),l.catch(()=>hc.userMediaPromiseMap.delete(`audioinput`))),a.video&&(hc.userMediaPromiseMap.set(`videoinput`,l),l.catch(()=>hc.userMediaPromiseMap.delete(`videoinput`)));try{let e=yield l;return yield Promise.all(e.getTracks().map(n=>L(this,void 0,void 0,function*(){let a=n.kind===`audio`,o,s=a?c.audio:c.video;typeof s!=`boolean`&&(o=s);let l=n.getSettings().deviceId;o?.deviceId&&ls(o.deviceId)!==l?o.deviceId=l:o||={deviceId:l};let u=wl(n,o,t);return u.kind===U.Kind.Video?u.source=U.Source.Camera:u.kind===U.Kind.Audio&&(u.source=U.Source.Microphone),u.mediaStream=e,vs(u)&&r?yield u.setProcessor(r):ys(u)&&i&&(yield u.setProcessor(i)),u})))}catch(r){if(!n)throw r;return Ud(Object.assign(Object.assign({},e),{audio:o,video:s}),t)}})}var Wd;(function(e){e.Excellent=`excellent`,e.Good=`good`,e.Poor=`poor`,e.Lost=`lost`,e.Unknown=`unknown`})(Wd||={});function Gd(e){switch(e){case Ot.EXCELLENT:return Wd.Excellent;case Ot.GOOD:return Wd.Good;case Ot.POOR:return Wd.Poor;case Ot.LOST:return Wd.Lost;default:return Wd.Unknown}}var Kd=class extends oi.EventEmitter{get logContext(){var e;return Object.assign({},((e=this.loggerOptions)?.loggerContextCb)?.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){return this.permissions?.agent||this.kind===Bt.AGENT}get isActive(){return this.participantInfo?.state===zt.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Bt.STANDARD;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Wd.Unknown,this.log=I,this.loggerOptions=a,this.log=Gr(a?.loggerName??Wr.Participant,()=>this.logContext),this.setMaxListeners(100),this.sid=e,this.identity=t,this.name=n,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=o,this._attributes=i??{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(let[,t]of this.trackPublications)if(t.source===e)return t}getTrackPublicationByName(e){for(let[,t]of this.trackPublications)if(t.trackName===e)return t}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new ss,this.once(B.Active,()=>{var e,t;(t=(e=this.activeFuture)?.resolve)==null||t.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){return!(this.getTrackPublication(U.Source.Camera)?.isMuted??!0)}get isMicrophoneEnabled(){return!(this.getTrackPublication(U.Source.Microphone)?.isMuted??!0)}get isScreenShareEnabled(){return!!this.getTrackPublication(U.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===zt.ACTIVE&&this.participantInfo?.state!==zt.ACTIVE&&this.emit(B.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){let t=this.metadata!==e,n=this.metadata;this.metadata=e,t&&this.emit(B.ParticipantMetadataChanged,n)}_setName(e){let t=this.name!==e;this.name=e,t&&this.emit(B.ParticipantNameChanged,e)}_setAttributes(e){let t=po(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(B.AttributesChanged,t)}setPermissions(e){let t=this.permissions,n=e.canPublish!==this.permissions?.canPublish||e.canSubscribe!==this.permissions?.canSubscribe||e.canPublishData!==this.permissions?.canPublishData||e.hidden!==this.permissions?.hidden||e.recorder!==this.permissions?.recorder||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((e,t)=>e!==this.permissions?.canPublishSources[t])||e.canSubscribeMetrics!==this.permissions?.canSubscribeMetrics;return this.permissions=e,n&&this.emit(B.ParticipantPermissionsChanged,t),n}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(B.IsSpeakingChanged,e))}setConnectionQuality(e){let t=this._connectionQuality;this._connectionQuality=Gd(e),t!==this._connectionQuality&&this.emit(B.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,t;this.activeFuture&&=((t=(e=this.activeFuture).reject)==null||t.call(e,Error(`Participant disconnected`)),void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(t=>vs(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on(H.Muted,()=>{this.emit(B.TrackMuted,e)}),e.on(H.Unmuted,()=>{this.emit(B.TrackUnmuted,e)});let t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case U.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case U.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}};function qd(e){if(!e.participantSid&&!e.participantIdentity)throw Error(`Invalid track permission, must provide at least one of participantIdentity and participantSid`);return new gr({participantIdentity:e.participantIdentity??``,participantSid:e.participantSid??``,allTracks:e.allowAll??!1,trackSids:e.allowedTrackSids||[]})}var Jd=class extends Kd{constructor(e,t,n,r,a,o,s,c){super(e,t,void 0,void 0,void 0,{loggerName:r.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=Ht.NONE,this.e2eeStateMutex=new i,this.enabledPublishVideoCodecs=[],this.handleReconnecting=()=>{this.reconnectFuture||=new ss},this.handleReconnected=()=>{var e,t;(t=(e=this.reconnectFuture)?.resolve)==null||t.call(e),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleClosing=()=>{var e,t,n,r,i,a;this.reconnectFuture&&=(this.reconnectFuture.promise.catch(e=>this.log.warn(e.message)),(t=(e=this.reconnectFuture)?.reject)==null||t.call(e,Error(`Got disconnected during reconnection attempt`)),void 0),this.signalConnectedFuture&&=((r=(n=this.signalConnectedFuture).reject)==null||r.call(n,Error(`Got disconnected without signal connected`)),void 0),(a=(i=this.activeAgentFuture)?.reject)==null||a.call(i,Error(`Got disconnected without active agent present`)),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=e=>{var t,n;e.participant&&this.updateInfo(e.participant),this.signalConnectedFuture||=new ss,(n=(t=this.signalConnectedFuture).resolve)==null||n.call(t)},this.handleSignalRequestResponse=e=>{let{requestId:t,reason:n,message:r}=e,i=this.pendingSignalRequests.get(t);switch(i&&(n!==Ar.OK&&i.reject(new La(r,n)),this.pendingSignalRequests.delete(t)),e.request.case){case`publishDataTrack`:{let t;switch(e.reason){case Ar.NOT_ALLOWED:t=vd.notAllowed(e.message);break;case Ar.DUPLICATE_NAME:t=vd.duplicateName(e.message);break;case Ar.INVALID_NAME:t=vd.invalidName(e.message);break;case Ar.LIMIT_EXCEEDED:t=vd.limitReached(e.message);break;default:t=vd.unknown(e.reason,e.message);break}this.roomOutgoingDataTrackManager.receivedSfuPublishResponse(e.request.value.pubHandle,{type:`error`,error:t});break}}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug(`updating track subscription permissions`,{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions}),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(e=>qd(e)))},this.onTrackUnmuted=e=>{this.onTrackMuted(e,e.isUpstreamPaused)},this.onTrackMuted=(e,t)=>{if(t===void 0&&(t=!0),!e.sid){this.log.error(`could not update mute status for unpublished track`,uo(e));return}this.engine.updateMuteStatus(e.sid,t)},this.onTrackUpstreamPaused=e=>{this.log.debug(`upstream paused`,uo(e)),this.onTrackMuted(e,!0)},this.onTrackUpstreamResumed=e=>{this.log.debug(`upstream resumed`,uo(e)),this.onTrackMuted(e,e.isMuted)},this.onTrackFeatureUpdate=e=>{let t=this.audioTrackPublications.get(e.sid);if(!t){this.log.warn(`Could not update local audio track settings, missing publication for track ${e.sid}`);return}this.engine.client.sendUpdateLocalAudioTrack(t.trackSid,t.getTrackFeatures())},this.onTrackCpuConstrained=(e,t)=>{this.log.debug(`track cpu constrained`,uo(t)),this.emit(B.LocalTrackCpuConstrained,e,t)},this.handleSubscribedQualityUpdate=e=>L(this,void 0,void 0,function*(){var t,n,r,i;if(!this.roomOptions?.dynacast)return;let a=this.videoTrackPublications.get(e.trackSid);if(!a){this.log.warn(`received subscribed quality update for unknown track`,{trackSid:e.trackSid});return}if(!a.videoTrack)return;let o=yield a.videoTrack.setPublishingCodecs(e.subscribedCodecs);try{for(var s=!0,c=ni(o),l;l=yield c.next(),t=l.done,!t;s=!0){i=l.value,s=!1;let e=i;Ja(e)&&(this.log.debug(`publish ${e} for ${a.videoTrack.sid}`,uo(a)),yield this.publishAdditionalCodecForTrack(a.videoTrack,e,a.options))}}catch(e){n={error:e}}finally{try{!s&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(n)throw n.error}}}),this.handleLocalTrackUnpublished=e=>{let t=this.trackPublications.get(e.trackSid);if(!t){this.log.warn(`received unpublished event for unknown track`,{trackSid:e.trackSid});return}this.unpublishTrack(t.track)},this.handleTrackEnded=e=>L(this,void 0,void 0,function*(){if(e.source===U.Source.ScreenShare||e.source===U.Source.ScreenShareAudio)this.log.debug(`unpublishing local track due to TrackEnded`,uo(e)),this.unpublishTrack(e);else if(e.isUserProvided)yield e.mute();else if(xs(e)||bs(e))try{if(Uo())try{let t=yield navigator==null?void 0:navigator.permissions.query({name:e.source===U.Source.Camera?`camera`:`microphone`});if(t&&t.state===`denied`)throw this.log.warn(`user has revoked access to ${e.source}`,uo(e)),t.onchange=()=>{t.state!==`denied`&&(e.isMuted||e.restartTrack(),t.onchange=null)},Error(`GetUserMedia Permission denied`)}catch{}e.isMuted||(this.log.debug(`track ended, attempting to use a different device`,uo(e)),xs(e)?yield e.restartTrack({deviceId:`default`}):yield e.restartTrack())}catch{this.log.warn(`could not restart track, muting instead`,uo(e)),yield e.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=n,this.roomOptions=r,this.setupEngine(n),this.activeDeviceMap=new Map([[`audioinput`,`default`],[`videoinput`,`default`],[`audiooutput`,`default`]]),this.pendingSignalRequests=new Map,this.roomOutgoingDataStreamManager=a,this.roomOutgoingDataTrackManager=o,this.rpcClientManager=s,this.rpcServerManager=c}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Ht.NONE}getTrackPublication(e){let t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){let t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(e){this.engine=e,this.engine.on(V.RemoteMute,(e,t)=>{let n=this.trackPublications.get(e);!n||!n.track||(t?n.mute():n.unmute())}),this.signalConnectedFuture?.isResolved&&(this.signalConnectedFuture=void 0),this.engine.on(V.Connected,this.handleReconnected).on(V.SignalConnected,this.handleSignalConnected).on(V.SignalRestarted,this.handleReconnected).on(V.SignalResumed,this.handleReconnected).on(V.Restarting,this.handleReconnecting).on(V.Resuming,this.handleReconnecting).on(V.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(V.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(V.Closing,this.handleClosing).on(V.SignalRequestResponse,this.handleSignalRequestResponse)}setMetadata(e){return L(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return L(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return L(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return L(this,arguments,void 0,function(e){var t=this;let{metadata:n,name:r,attributes:i}=e;return function*(){return new ba((e,a)=>L(t,void 0,void 0,function*(){try{let t=!1,o=yield this.engine.client.sendUpdateLocalMetadata(n??this.metadata??``,r??this.name??``,i),s=performance.now();for(this.pendingSignalRequests.set(o,{resolve:e,reject:e=>{a(e),t=!0},values:{name:r,metadata:n,attributes:i}});performance.now()-s<5e3&&!t;){if((!r||this.name===r)&&(!n||this.metadata===n)&&(!i||Object.entries(i).every(e=>{let[t,n]=e;return this.attributes[t]===n||n===``&&!this.attributes[t]}))){this.pendingSignalRequests.delete(o),e();return}yield Eo(50)}a(new La(`Request to update local metadata timed out`,`TimeoutError`))}catch(e){e instanceof Error?a(e):a(Error(String(e)))}}))}()})}setCameraEnabled(e,t,n){return this.setTrackEnabled(U.Source.Camera,e,t,n)}setMicrophoneEnabled(e,t,n){return this.setTrackEnabled(U.Source.Microphone,e,t,n)}setScreenShareEnabled(e,t,n){return this.setTrackEnabled(U.Source.ScreenShare,e,t,n)}setE2EEEnabled(e){return L(this,void 0,void 0,function*(){let t=yield this.e2eeStateMutex.lock();try{if(this.encryptionType=e?Ht.GCM:Ht.NONE,yield Promise.all(this.pendingPublishPromises.values()),this.trackPublications.size===0||Array.from(this.trackPublications.values()).every(t=>t.isEncrypted===e))return;yield this.republishAllTracks(void 0,!1)}finally{t()}})}setTrackEnabled(e,t,n,r){return L(this,void 0,void 0,function*(){this.log.debug(`setTrackEnabled`,{source:e,enabled:t}),this.republishPromise&&(yield this.republishPromise);let i=this.getTrackPublication(e);if(t)if(i)yield i.unmute();else{let t;if(this.pendingPublishing.has(e)){let t=yield this.waitForPendingPublicationOfSource(e);return t||this.log.info(`waiting for pending publication promise timed out`,{source:e}),yield t?.unmute(),t}this.pendingPublishing.add(e);try{switch(e){case U.Source.Camera:t=yield this.createTracks({video:n??!0});break;case U.Source.Microphone:t=yield this.createTracks({audio:n??!0});break;case U.Source.ScreenShare:t=yield this.createScreenTracks(Object.assign({},n));break;default:throw new Ma(e)}}catch(n){throw t?.forEach(e=>{e.stop()}),n instanceof Error&&this.emit(B.MediaDevicesError,n,oo(e)),this.pendingPublishing.delete(e),n}for(let r of t){let t=Object.assign(Object.assign({},this.roomOptions.publishDefaults),n);e===U.Source.Microphone&&vs(r)&&t.preConnectBuffer&&(this.log.info(`starting preconnect buffer for microphone`),r.startPreConnectBuffer())}try{let e=[];for(let n of t)this.log.info(`publishing track`,uo(n)),e.push(this.publishTrack(n,r));let n=yield Promise.all(e);[i]=n}catch(e){throw t?.forEach(e=>{e.stop()}),e}finally{this.pendingPublishing.delete(e)}}else if(!i?.track&&this.pendingPublishing.has(e)&&(i=yield this.waitForPendingPublicationOfSource(e),i||this.log.info(`waiting for pending publication promise timed out`,{source:e})),i&&i.track)if(e===U.Source.ScreenShare){let e=[this.unpublishTrack(i.track)],t=this.getTrackPublication(U.Source.ScreenShareAudio);t&&t.track&&e.push(this.unpublishTrack(t.track)),[i]=yield Promise.all(e)}else yield i.mute();return i})}enableCameraAndMicrophone(){return L(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(U.Source.Camera)||this.pendingPublishing.has(U.Source.Microphone))){this.pendingPublishing.add(U.Source.Camera),this.pendingPublishing.add(U.Source.Microphone);try{let e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(e=>this.publishTrack(e)))}finally{this.pendingPublishing.delete(U.Source.Camera),this.pendingPublishing.delete(U.Source.Microphone)}}})}createTracks(e){return L(this,void 0,void 0,function*(){e??={};let t=eo(e,this.roomOptions?.audioCaptureDefaults,this.roomOptions?.videoCaptureDefaults);try{return(yield Ud(t,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(e=>(vs(e)&&(this.microphoneError=void 0,e.setAudioContext(this.audioContext),e.source=U.Source.Microphone,this.emit(B.AudioStreamAcquired)),ys(e)&&(this.cameraError=void 0,e.source=U.Source.Camera),e))}catch(t){throw t instanceof Error&&(e.audio&&(this.microphoneError=t),e.video&&(this.cameraError=t)),t}})}createScreenTracks(e){return L(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new ja(`getDisplayMedia not supported`);e.resolution===void 0&&!zo()&&(e.resolution=$a.h1080fps30.resolution);let t=so(e),n=yield navigator.mediaDevices.getDisplayMedia(t),r=n.getVideoTracks();if(r.length===0)throw new Ma(`no video track found`);let i=new Hl(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});i.source=U.Source.ScreenShare,e.contentHint&&(i.mediaStreamTrack.contentHint=e.contentHint);let a=[i];if(n.getAudioTracks().length>0){this.emit(B.AudioStreamAcquired);let e=new Cl(n.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});e.source=U.Source.ScreenShareAudio,a.push(e)}return a})}publishTrack(e,t){return L(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,t)})}waitForNextEngineRestart(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:15e3;return new Promise((t,n)=>{let r=()=>{clearTimeout(o),this.engine.off(V.Restarted,i),this.engine.off(V.Closing,a)},i=()=>{r(),t()},a=()=>{r(),n(Error(`engine closed before restart completed`))},o=setTimeout(()=>{r(),n(Error(`timed out waiting for engine restart`))},e);this.engine.once(V.Restarted,i),this.engine.once(V.Closing,a)})}publishOrRepublishTrack(e,t){return L(this,arguments,void 0,function(e,t){var n=this;let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;return function*(){xs(e)&&e.setAudioContext(n.audioContext),yield n.reconnectFuture?.promise,n.republishPromise&&!r&&(yield n.republishPromise),_s(e)&&n.pendingPublishPromises.has(e)&&(yield n.pendingPublishPromises.get(e));let a;if(e instanceof MediaStreamTrack)a=e.getConstraints();else{a=e.constraints;let t;switch(e.source){case U.Source.Microphone:t=`audioinput`;break;case U.Source.Camera:t=`videoinput`}t&&n.activeDeviceMap.has(t)&&(a=Object.assign(Object.assign({},a),{deviceId:n.activeDeviceMap.get(t)}))}if(e instanceof MediaStreamTrack)switch(e.kind){case`audio`:e=new Cl(e,a,!0,n.audioContext,{loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});break;case`video`:e=new Hl(e,a,!0,{loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});break;default:throw new Ma(`unsupported MediaStreamTrack kind ${e.kind}`)}else e.updateLoggerOptions({loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});let o;if(n.trackPublications.forEach(t=>{t.track&&t.track===e&&(o=t)}),o)return n.log.warn(`track has already been published, skipping`,uo(o)),o;let s=Object.assign(Object.assign({},n.roomOptions.publishDefaults),t),c=`channelCount`in e.mediaStreamTrack.getSettings()&&e.mediaStreamTrack.getSettings().channelCount===2||e.mediaStreamTrack.getConstraints().channelCount===2,l=s.forceStereo??c;l&&(s.dtx===void 0&&n.log.debug(`Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.`,uo(e)),s.red===void 0&&n.log.debug(`Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.`),s.dtx??=!1,s.red??=!1),!Ho()&&n.roomOptions.e2ee&&(n.log.info(`End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2`),s.simulcast=!1),s.source&&(e.source=s.source);let u=new Promise((t,r)=>L(n,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Mc.CONNECTED){this.log.debug(`deferring track publication until signal is connected`,{track:uo(e)});let n=!1,i=setTimeout(()=>{n=!0,e.stop(),r(new Ia(`publishing rejected as engine not connected within timeout`,408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(i),n)return;t(yield this.publish(e,s,l))}else try{t(yield this.publish(e,s,l))}catch(e){r(e)}}catch(e){r(e)}}));n.pendingPublishPromises.set(e,u);try{return yield u}catch(a){if(!i&&a instanceof Fa)return n.log.warn(`negotiation due to track publish failed, retrying after reconnect`,{error:a}),n.pendingPublishPromises.delete(e),yield n.waitForNextEngineRestart(),yield n.publishOrRepublishTrack(e,t,r,!0);throw a}finally{n.pendingPublishPromises.delete(e)}}()})}waitUntilEngineConnected(){return this.signalConnectedFuture||=new ss,this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn(`no permissions present for publishing track`,uo(e)),!1;let{canPublish:t,canPublishSources:n}=this.permissions;return t&&(n.length===0||n.map(e=>ho(e)).includes(e.source))?!0:(this.log.warn(`insufficient permissions to publish`,uo(e)),!1)}publish(e,t,n){return L(this,void 0,void 0,function*(){if(!this.hasPermissionsToPublish(e))throw new Ia(`failed to publish track, insufficient permissions`,403);Array.from(this.trackPublications.values()).find(t=>_s(e)&&t.source===e.source)&&e.source!==U.Source.Unknown&&this.log.info(`publishing a second track with the same source: ${e.source}`,uo(e)),t.stopMicTrackOnMute&&vs(e)&&(e.stopOnMute=!0),e.source===U.Source.ScreenShare&&Po()&&(t.simulcast=!1),t.videoCodec===`av1`&&!ko()&&(t.videoCodec=void 0),t.videoCodec===`vp9`&&!Ao()&&(t.videoCodec=void 0),t.videoCodec===void 0&&(t.videoCodec=cl),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(e=>t.videoCodec===co(e.mime))||(t.videoCodec=co(this.enabledPublishVideoCodecs[0].mime)));let r=t.videoCodec;e.on(H.Muted,this.onTrackMuted),e.on(H.Unmuted,this.onTrackUnmuted),e.on(H.Ended,this.handleTrackEnded),e.on(H.UpstreamPaused,this.onTrackUpstreamPaused),e.on(H.UpstreamResumed,this.onTrackUpstreamResumed),e.on(H.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);let i=[],a=!(t.dtx??!0),o=e.getSourceTrackSettings();o.autoGainControl&&i.push(Nt.TF_AUTO_GAIN_CONTROL),o.echoCancellation&&i.push(Nt.TF_ECHO_CANCELLATION),o.noiseSuppression&&i.push(Nt.TF_NOISE_SUPPRESSION),o.channelCount&&o.channelCount>1&&i.push(Nt.TF_STEREO),a&&i.push(Nt.TF_NO_DTX),xs(e)&&e.hasPreConnectBuffer&&i.push(Nt.TF_PRECONNECT_BUFFER);let s=this.normalizeRequestedPacketTrailerOptions(e,t),c=new Pn({cid:e.mediaStreamTrack.id,name:t.name,type:U.kindToProto(e.kind),muted:e.isMuted,source:U.sourceToProto(e.source),disableDtx:a,encryption:this.encryptionType,stereo:n,disableRed:this.isE2EEEnabled||!(t.red??!0),stream:t?.stream,backupCodecPolicy:t?.backupCodecPolicy,audioFeatures:i,packetTrailerFeatures:s}),l;if(e.kind===U.Kind.Video){let n;try{n=yield e.waitForDimensions()}catch{let t=this.roomOptions.videoCaptureDefaults?.resolution??Za.h720.resolution;n={width:t.width,height:t.height},this.log.error(`could not determine track dimensions, using defaults`,Object.assign(Object.assign({},uo(e)),{dims:n}))}c.width=n.width,c.height=n.height,bs(e)&&(jo(r)&&(e.source===U.Source.ScreenShare&&(t.scalabilityMode=`L1T3`,`contentHint`in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=`motion`,this.log.debug(`forcing contentHint to motion for screenshare with SVC codecs`,uo(e)))),t.scalabilityMode=t.scalabilityMode??`L3T3_KEY`),c.simulcastCodecs=[new Nn({codec:r,cid:e.mediaStreamTrack.id})],t.backupCodec===!0&&(t.backupCodec={codec:cl}),t.backupCodec&&r!==t.backupCodec.codec&&c.encryption===Ht.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),c.simulcastCodecs.push(new Nn({codec:t.backupCodec.codec,cid:``})))),l=Ml(e.source===U.Source.ScreenShare,c.width,c.height,t),c.layers=Gl(c.width,c.height,l,jo(t.videoCodec))}else e.kind===U.Kind.Audio&&(l=[{maxBitrate:t.audioPreset?.maxBitrate,priority:t.audioPreset?.priority??`high`,networkPriority:t.audioPreset?.priority??`high`}]);if(!this.engine||this.engine.isClosed)throw new Pa(`cannot publish track when not connected`);let u=()=>L(this,void 0,void 0,function*(){if(!this.engine.pcManager)throw new Pa(`pcManager is not ready`);if(e.sender=yield this.engine.createSender(e,t,l),bs(e)&&(e.publishOptions=t),this.emit(B.LocalSenderCreated,e.sender,e),bs(e)&&(t.degradationPreference??=Bl(e),e.setDegradationPreference(t.degradationPreference)),l)if(Po()&&e.kind===U.Kind.Audio){let t;for(let n of this.engine.pcManager.publisher.getTransceivers())if(n.sender===e.sender){t=n;break}t&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:t,codec:`opus`,maxbr:l[0]?.maxBitrate?l[0].maxBitrate/1e3:0})}else e.codec&&jo(e.codec)&&l[0]?.maxBitrate&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:c.cid,codec:e.codec,maxbr:l[0].maxBitrate/1e3});yield this.engine.negotiate()}),d,f=new Promise((t,n)=>L(this,void 0,void 0,function*(){try{d=yield this.engine.addTrack(c),t(d)}catch(t){if(e.sender&&this.engine.pcManager?.publisher){try{this.engine.pcManager.publisher.removeTrack(e.sender)}catch(e){this.log.error(e)}yield this.engine.negotiate().catch(t=>{this.log.error(`failed to negotiate after removing track due to failed add track request`,Object.assign(Object.assign({},uo(e)),{error:t}))})}n(t)}}));if(this.enabledPublishVideoCodecs.length>0&&s.length===0)d=(yield Promise.all([f,u()]))[0];else{d=yield f;let n;if(d.codecs.forEach(e=>{n===void 0&&(n=e.mimeType)}),n&&e.kind===U.Kind.Video){let i=co(n);i!==r&&(this.log.debug(`falling back to server selected codec`,Object.assign(Object.assign({},uo(e)),{codec:i})),t.videoCodec=i,l=Ml(e.source===U.Source.ScreenShare,c.width,c.height,t))}yield u()}let p=new Hd(e.kind,d,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(p.on(H.CpuConstrained,e=>this.onTrackCpuConstrained(e,p)),p.options=t,e.sid=d.sid,bs(e)&&(e.publishOptions=t,c.width&&c.height&&(e.lastEncodedDimensions={width:c.width,height:c.height})),this.log.debug(`publishing ${e.kind} with encodings`,{encodings:l,trackInfo:d}),bs(e)?e.startMonitor(this.engine.client):xs(e)&&e.startMonitor(),this.addTrackPublication(p),this.emit(B.LocalTrackPublished,p),xs(e)&&d.audioFeatures.includes(Nt.TF_PRECONNECT_BUFFER)){let t=e.getPreConnectBuffer(),n=e.getPreConnectBufferMimeType();this.on(B.LocalTrackSubscribed,t=>{if(t.trackSid===d.sid){if(!e.hasPreConnectBuffer){this.log.warn(`subscribe event came to late, buffer already closed`);return}this.log.debug(`finished recording preconnect buffer`,uo(e)),e.stopPreConnectBuffer()}}),t&&new Promise((r,i)=>L(this,void 0,void 0,function*(){var a,s,c,l;try{this.log.debug(`waiting for agent`,uo(e));let m=setTimeout(()=>{i(Error(`agent not active within 10 seconds`))},1e4),h=yield this.waitUntilActiveAgentPresent();clearTimeout(m),this.log.debug(`sending preconnect buffer`,uo(e));let g=yield this.streamBytes({name:`preconnect-buffer`,mimeType:n,topic:`lk.agent.pre-connect-audio-buffer`,destinationIdentities:[h.identity],attributes:{trackId:p.trackSid,sampleRate:String(o.sampleRate??`48000`),channels:String(o.channelCount??`1`)}});try{for(var u=!0,d=ni(t),f;f=yield d.next(),a=f.done,!a;u=!0){l=f.value,u=!1;let e=l;yield g.write(e)}}catch(e){s={error:e}}finally{try{!u&&!a&&(c=d.return)&&(yield c.call(d))}finally{if(s)throw s.error}}yield g.close(),r()}catch(e){i(e)}})).then(()=>{this.log.debug(`preconnect buffer sent successfully`,uo(e))}).catch(t=>{this.log.error(`error sending preconnect buffer`,Object.assign(Object.assign({},uo(e)),{error:t}))})}return p})}canPublishPacketTrailer(){return!!(this.roomOptions.e2ee||this.roomOptions.encryption||Js(this.roomOptions.packetTrailer))}normalizeRequestedPacketTrailerOptions(e,t){if(e.kind!==U.Kind.Video||!Ys(t.packetTrailer))return t.packetTrailer=void 0,[];if(!this.canPublishPacketTrailer())return this.log.warn(`packet trailer transform not supported; not advertising features`,Object.assign(Object.assign({},this.logContext),uo(e))),t.packetTrailer=void 0,[];let n=Xs(t.packetTrailer);return t.packetTrailer=Zs(n),n}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,n){return L(this,void 0,void 0,function*(){if(this.encryptionType!==Ht.NONE)return;let r;if(this.trackPublications.forEach(t=>{t.track&&t.track===e&&(r=t)}),!r)throw new Ma(`track is not published`);if(!bs(e))throw new Ma(`track is not a video track`);let i=Object.assign(Object.assign({},this.roomOptions?.publishDefaults),n),a=Nl(e,t,i);if(!a){this.log.info(`backup codec has been disabled, ignoring request to add additional codec for track`,uo(e));return}let o=e.addSimulcastTrack(t,a);if(!o)return;let s=this.normalizeRequestedPacketTrailerOptions(e,i),c=new Pn({cid:o.mediaStreamTrack.id,type:U.kindToProto(e.kind),muted:e.isMuted,source:U.sourceToProto(e.source),sid:e.sid,packetTrailerFeatures:s,simulcastCodecs:[{codec:i.videoCodec,cid:o.mediaStreamTrack.id}]});if(c.layers=Gl(c.width,c.height,a),!this.engine||this.engine.isClosed)throw new Pa(`cannot publish track when not connected`);let l=(yield Promise.all([this.engine.addTrack(c),L(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,o,i,a),yield this.engine.negotiate()})]))[0];this.log.debug(`published ${t} for track ${e.sid}`,{encodings:a,trackInfo:l})})}unpublishTrack(e,t){return L(this,void 0,void 0,function*(){if(_s(e)){let t=this.pendingPublishPromises.get(e);t&&(this.log.debug(`awaiting publish promise before attempting to unpublish`,uo(e)),yield t)}let n=this.getPublicationForTrack(e),r=n?uo(n):void 0;if(this.log.info(`unpublishing track`,r),!n||!n.track){this.log.warn(`track was not unpublished because no publication was found`,r);return}e=n.track,e.off(H.Muted,this.onTrackMuted),e.off(H.Unmuted,this.onTrackUnmuted),e.off(H.Ended,this.handleTrackEnded),e.off(H.UpstreamPaused,this.onTrackUpstreamPaused),e.off(H.UpstreamResumed,this.onTrackUpstreamResumed),e.off(H.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),t===void 0&&(t=this.roomOptions?.stopLocalTrackOnUnpublish??!0),t?e.stop():e.stopMonitor();let i=!1,a=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentStatethis.unpublishTrack(e)))).filter(e=>!!e)})}republishAllTracks(e){return L(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){t.republishPromise&&(yield t.republishPromise),t.republishPromise=new ba((r,i)=>L(t,void 0,void 0,function*(){try{let t=[];this.trackPublications.forEach(n=>{n.track&&(e&&(n.options=Object.assign(Object.assign({},n.options),e)),t.push(n))}),yield Promise.all(t.map(e=>L(this,void 0,void 0,function*(){let t=e.track;yield this.unpublishTrack(t,!1),n&&!t.isMuted&&t.source!==U.Source.ScreenShare&&t.source!==U.Source.ScreenShareAudio&&(xs(t)||bs(t))&&!t.isUserProvided&&(this.log.debug(`restarting existing track`,{track:e.trackSid}),yield t.restartTrack()),yield this.publishOrRepublishTrack(t,e.options,!0)}))),r()}catch(e){e instanceof Error?i(e):i(Error(String(e)))}finally{this.republishPromise=void 0}})),yield t.republishPromise}()})}publishData(e){return L(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){let r=n.reliable?ru.RELIABLE:ru.LOSSY,i=n.reliable?Xt.RELIABLE:Xt.LOSSY,a=n.destinationIdentities,o=n.topic,s=new Yt({kind:i,value:{case:`user`,value:new tn({participantIdentity:t.identity,payload:e,destinationIdentities:a,topic:o})}});yield t.engine.sendDataPacket(s,r)}()})}publishDtmf(e,t){return L(this,void 0,void 0,function*(){let n=new Yt({kind:Xt.RELIABLE,value:{case:`sipDtmf`,value:new nn({code:e,digit:t})}});yield this.engine.sendDataPacket(n,ru.RELIABLE)})}sendChatMessage(e,t){return L(this,void 0,void 0,function*(){let n={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:t?.attachments},r=new Yt({value:{case:`chatMessage`,value:new on(Object.assign(Object.assign({},n),{timestamp:A.parse(n.timestamp)}))}});return yield this.engine.sendDataPacket(r,ru.RELIABLE),this.emit(B.ChatMessage,n),n})}editChatMessage(e,t){return L(this,void 0,void 0,function*(){let n=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),r=new Yt({value:{case:`chatMessage`,value:new on(Object.assign(Object.assign({},n),{timestamp:A.parse(n.timestamp),editTimestamp:A.parse(n.editTimestamp)}))}});return yield this.engine.sendDataPacket(r,ru.RELIABLE),this.emit(B.ChatMessage,n),n})}sendText(e,t){return L(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,t)})}streamText(e){return L(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,t){return L(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,t)})}streamBytes(e){return L(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){return this.rpcClientManager.performRpc(e).then(e=>{let[t,n]=e;return n})}registerRpcMethod(e,t){this.rpcServerManager.registerRpcMethod(e,t)}unregisterRpcMethod(e){this.rpcServerManager.unregisterRpcMethod(e)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(e=>e.mime.split(`/`)[0].toLowerCase()===`video`)}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(e=>{let t=this.trackPublications.get(e.sid);if(t){let n=t.isMuted||(t.track?.isUpstreamPaused??!1);n!==e.muted&&(this.log.debug(`updating server mute state after reconcile`,Object.assign(Object.assign({},uo(t)),{mutedOnServer:n})),this.engine.client.sendMuteTrack(e.sid,n))}}),!0):!1}setActiveAgent(e){var t,n,r,i;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?(n=(t=this.activeAgentFuture)?.resolve)==null||n.call(t,e):(i=(r=this.activeAgentFuture)?.reject)==null||i.call(r,Error(`Agent disconnected`)),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||=new ss,this.activeAgentFuture.promise)}getPublicationForTrack(e){let t;return this.trackPublications.forEach(n=>{let r=n.track;r&&(e instanceof MediaStreamTrack?(xs(r)||bs(r))&&r.mediaStreamTrack===e&&(t=n):e===r&&(t=n))}),t}waitForPendingPublicationOfSource(e){return L(this,void 0,void 0,function*(){let t=Date.now();for(;Date.now(){let[n]=t;return n.source===e});if(t)return t[1];yield Eo(20)}})}publishDataTrack(e){return L(this,void 0,void 0,function*(){let t=new Cd(e,this.roomOutgoingDataTrackManager);return yield t.publish(),t})}},Yd=class extends DOMException{constructor(e,t){super(e,`AbortError`),this.reason=t}},Xd=class extends Map{constructor(){super(...arguments),this.pending=new Map}set(e,t){var n;super.set(e,t);let r=this.pending?.get(e);if(r){for(let e of r)e.isResolved||(n=e.resolve)==null||n.call(e,t);this.pending.delete(e)}return this}get[Symbol.toStringTag](){return`DeferrableMap`}getDeferred(e,t){return L(this,void 0,void 0,function*(){let n=this.get(e);if(n!==void 0)return n;if(t?.aborted)throw new Yd(`The operation was aborted.`,t.reason);let r=new ss(void 0,()=>{let t=this.pending.get(e);if(!t)return;let n=t.indexOf(r);n!==-1&&t.splice(n,1),t.length===0&&this.pending.delete(e)}),i=this.pending.get(e);if(i?i.push(r):this.pending.set(e,[r]),t){let e=()=>{var e;r.isResolved||(e=r.reject)==null||e.call(r,new Yd(`The operation was aborted.`,t.reason))};t.addEventListener(`abort`,e,{once:!0}),r.promise.finally(()=>{t.removeEventListener(`abort`,e)})}return r.promise})}},Zd=class extends Vd{constructor(e,t,n,r){super(e,t.sid,t.name,r),this.track=void 0,this.allowed=!0,this.requestedDisabled=void 0,this.visible=!0,this.handleEnded=e=>{this.setTrack(void 0),this.emit(H.Ended,e)},this.handleVisibilityChange=e=>{this.log.debug(`adaptivestream video visibility ${this.trackSid}, visible=${e}`,this.logContext),this.visible=e,this.emitTrackUpdate()},this.handleVideoDimensionsChange=e=>{this.log.debug(`adaptivestream video dimensions ${e.width}x${e.height}`,this.logContext),this.videoDimensionsAdaptiveStream=e,this.emitTrackUpdate()},this.subscribed=n,this.updateInfo(t)}setSubscribed(e){let t=this.subscriptionStatus,n=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);let r=new Yn({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new dn({participantSid:``,trackSids:[this.trackSid]})]});this.emit(H.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return this.subscribed===!1?Vd.SubscriptionStatus.Unsubscribed:super.isSubscribed?Vd.SubscriptionStatus.Subscribed:Vd.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Vd.PermissionStatus.Allowed:Vd.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return this.requestedDisabled===void 0?this.isAdaptiveStream?this.visible:!0:!this.requestedDisabled}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.requestedDisabled===!e||(this.requestedDisabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.requestedMaxQuality===e||(this.requestedMaxQuality=e,this.requestedVideoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){this.isManualOperationAllowed()&&(this.requestedVideoDimensions?.width===e.width&&this.requestedVideoDimensions?.height===e.height||(ws(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&ws(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.requestedMaxQuality??bo.HIGH}setTrack(e){let t=this.subscriptionStatus,n=this.permissionStatus,r=this.track;r!==e&&(r&&(r.off(H.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(H.VisibilityChanged,this.handleVisibilityChange),r.off(H.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(H.Unsubscribed,r)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(H.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(H.VisibilityChanged,this.handleVisibilityChange),e.on(H.Ended,this.handleEnded),this.emit(H.Subscribed,e)),this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t))}setAllowed(e){let t=this.subscriptionStatus,n=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(e){this.emit(H.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);let t=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):t!==e.muted&&this.emit(e.muted?H.Muted:H.Unmuted)}emitSubscriptionUpdateIfChanged(e){let t=this.subscriptionStatus;e!==t&&this.emit(H.SubscriptionStatusChanged,t,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(H.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.isDesired?!0:(this.log.warn(`cannot update track settings when not subscribed`,this.logContext),!1)}get isAdaptiveStream(){return ws(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){let e=new Qn({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===U.Kind.Video){let t=this.requestedVideoDimensions;if(this.videoDimensionsAdaptiveStream!==void 0)if(t)go(this.videoDimensionsAdaptiveStream,t)&&(this.log.debug(`using adaptive stream dimensions instead of requested`,Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream);else if(this.requestedMaxQuality!==void 0&&this.trackInfo){let e=_o(this.trackInfo,this.requestedMaxQuality);e&&go(this.videoDimensionsAdaptiveStream,e)&&(this.log.debug(`using adaptive stream dimensions instead of max quality layer`,Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream)}else this.log.debug(`using adaptive stream dimensions`,Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream;t?(e.width=Math.ceil(t.width),e.height=Math.ceil(t.height)):this.requestedMaxQuality===void 0?(this.log.debug(`using default quality`,Object.assign(Object.assign({},this.logContext),{quality:bo.HIGH})),e.quality=bo.HIGH):(this.log.debug(`using requested max quality`,Object.assign(Object.assign({},this.logContext),{quality:this.requestedMaxQuality})),e.quality=this.requestedMaxQuality)}this.emit(H.UpdateSettings,e)}},Qd=class e extends Kd{static fromParticipantInfo(t,n,r,i){return new e(t,n.sid,n.identity,n.name,n.metadata,n.attributes,r,n.kind,n.dataTracks.map(e=>new Qu(Ec.from(e),i,{publisherIdentity:n.identity})),n.clientProtocol)}get logContext(){return Object.assign(Object.assign({},super.logContext),{remoteParticipantID:this.sid,remoteParticipant:this.identity})}constructor(e,t,n,r,i,a,o){let s=arguments.length>7&&arguments[7]!==void 0?arguments[7]:Bt.STANDARD,c=arguments.length>8&&arguments[8]!==void 0?arguments[8]:[],l=arguments.length>9&&arguments[9]!==void 0?arguments[9]:0;super(t,n||``,r,i,a,o,s),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.dataTracks=new Xd(c.map(e=>[e.info.name,e])),this.volumeMap=new Map,this.clientProtocol=l}addTrackPublication(e){super.addTrackPublication(e),e.on(H.UpdateSettings,t=>{this.log.debug(`send update settings`,Object.assign(Object.assign(Object.assign({},this.logContext),uo(e)),{settings:t})),this.signalClient.sendUpdateTrackSettings(t)}),e.on(H.UpdateSubscription,e=>{e.participantTracks.forEach(e=>{e.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(e)}),e.on(H.SubscriptionPermissionChanged,t=>{this.emit(B.TrackSubscriptionPermissionChanged,e,t)}),e.on(H.SubscriptionStatusChanged,t=>{this.emit(B.TrackSubscriptionStatusChanged,e,t)}),e.on(H.Subscribed,t=>{this.emit(B.TrackSubscribed,t,e)}),e.on(H.Unsubscribed,t=>{this.emit(B.TrackUnsubscribed,t,e)}),e.on(H.SubscriptionFailed,t=>{this.emit(B.TrackSubscriptionFailed,e.trackSid,t)})}getTrackPublication(e){let t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){let t=super.getTrackPublicationByName(e);if(t)return t}setVolume(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:U.Source.Microphone;this.volumeMap.set(t,e);let n=this.getTrackPublication(t);n&&n.track&&n.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:U.Source.Microphone,t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,t,n,r,i,a){let o=this.getTrackPublicationBySid(t);if(o||t.startsWith(`TR`)||this.trackPublications.forEach(t=>{!o&&e.kind===t.kind.toString()&&(o=t)}),!o){if(a===0){this.log.error(`could not find published track`,Object.assign(Object.assign({},this.logContext),{trackSid:t})),this.emit(B.TrackSubscriptionFailed,t);return}a===void 0&&(a=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,t,n,r,i,a-1)},150);return}if(e.readyState===`ended`){this.log.error(`unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()`,Object.assign(Object.assign({},this.logContext),uo(o))),this.emit(B.TrackSubscriptionFailed,t);return}let s=e.kind===`video`,c;return c=s?new rc(e,t,r,i):new Bd(e,t,r,this.audioContext,this.audioOutput),c.source=o.source,c.isMuted=o.isMuted,c.setMediaStream(n),c.start(),o.setTrack(c),this.volumeMap.has(o.source)&&Ss(c)&&vs(c)&&c.setVolume(this.volumeMap.get(o.source)),o}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;let t=new Map,n=new Map;return e.tracks.forEach(e=>{let r=this.getTrackPublicationBySid(e.sid);if(r)r.updateInfo(e);else{let t=U.kindFromProto(e.type);if(!t)return;r=new Zd(t,e,this.signalClient.connectOptions?.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:this.loggerOptions?.loggerName}),r.updateInfo(e),n.set(e.sid,r);let i=Array.from(this.trackPublications.values()).find(e=>e.source===r?.source);i&&r.source!==U.Source.Unknown&&this.log.debug(`received a second track publication for ${this.identity} with the same source: ${r.source}`,Object.assign(Object.assign({},this.logContext),{oldTrack:uo(i),newTrack:uo(r)})),this.addTrackPublication(r)}t.set(e.sid,r)}),this.trackPublications.forEach(e=>{t.has(e.trackSid)||(this.log.trace(`detected removed track on remote participant, unpublishing`,Object.assign(Object.assign({},this.logContext),uo(e))),this.unpublishTrack(e.trackSid,!0))}),n.forEach(e=>{this.emit(B.TrackPublished,e)}),!0}unpublishTrack(e,t){let n=this.trackPublications.get(e);if(!n)return;let{track:r}=n;switch(r&&(r.stop(),n.setTrack(void 0)),this.trackPublications.delete(e),n.kind){case U.Kind.Audio:this.audioTrackPublications.delete(e);break;case U.Kind.Video:this.videoTrackPublications.delete(e);break}t&&this.emit(B.TrackUnpublished,n)}setAudioOutput(e){return L(this,void 0,void 0,function*(){this.audioOutput=e;let t=[];this.audioTrackPublications.forEach(n=>{vs(n.track)&&Ss(n.track)&&t.push(n.track.setSinkId(e.deviceId??`default`))}),yield Promise.all(t)})}addRemoteDataTrack(e){this.dataTracks.set(e.info.name,e)}removeRemoteDataTrack(e){for(let[t,n]of this.dataTracks.entries())e===n.info.sid&&this.dataTracks.delete(t)}emit(e){var t=[...arguments].slice(1);return this.log.trace(`participant event`,Object.assign(Object.assign({},this.logContext),{event:e,args:t})),super.emit(e,...t)}},$d;(function(e){e.Disconnected=`disconnected`,e.Connecting=`connecting`,e.Connected=`connected`,e.Reconnecting=`reconnecting`,e.SignalReconnecting=`signalReconnecting`})($d||={});var ef=4*1e3,tf=class e extends oi.EventEmitter{get hasE2EESetup(){return this.e2eeManager!==void 0}constructor(t){var n,r,a;if(super(),n=this,this.state=$d.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.e2eeStateMutex=new i,this.isVideoPlaybackBlocked=!1,this.log=I,this.bufferedEvents=[],this.isResuming=!1,this.connect=(e,t,n)=>L(this,void 0,void 0,function*(){if(!No())throw Wo()?Error(`WebRTC isn't detected, have you called registerGlobals?`):Error(`LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.`);let r=yield this.disconnectLock.lock();if(this.state===$d.Connected)return this.log.info(`already connected to room ${this.name}`),r(),Promise.resolve();if(this.connectFuture)return r(),this.connectFuture.promise;this.setAndEmitConnectionState($d.Connecting),this.regionUrlProvider?.getServerUrl().toString()!==Ns(e)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),Go(new URL(e))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new cu(e,t):this.regionUrlProvider.updateToken(t),this.regionUrlProvider.fetchRegionSettings().then(e=>{var t;(t=this.regionUrlProvider)==null||t.setServerReportedRegions(e)}).catch(e=>{this.log.warn(`could not fetch region settings`,{error:e})}));let i=(a,o,s)=>L(this,void 0,void 0,function*(){this.abortController&&this.abortController.abort();let c=new AbortController;this.abortController=c,r?.();try{if(yield pc.getInstance().getBackOffPromise(e),c.signal.aborted)throw R.cancelled(`Connection attempt aborted`);yield this.attemptConnection(s??e,t,n,c),this.abortController=void 0,a()}catch(t){if(this.regionUrlProvider&&t instanceof R&&t.reason!==Aa.Cancelled&&t.reason!==Aa.NotAllowed){let n=null;try{this.log.debug(`Fetching next region`),n=yield this.regionUrlProvider.getNextBestRegionUrl(this.abortController?.signal)}catch(e){if(e instanceof R&&(e.status===401||e.reason===Aa.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),o(e);return}}[Aa.InternalError,Aa.ServerUnreachable,Aa.Timeout].includes(t.reason)&&(this.log.debug(`Adding failed connection attempt to back off`),pc.getInstance().addFailedConnectionAttempt(e)),n&&!this.abortController?.signal.aborted?(this.log.info(`Initial connection failed with ConnectionError: ${t.message}. Retrying with another region: ${n}`),this.recreateEngine(!0),yield i(a,o,n)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,ms(t)),o(t))}else{let e=At.UNKNOWN_REASON;t instanceof R&&(e=ms(t)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e),o(t)}}}),a=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new ss((e,t)=>{i(e,t,a)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(e,t,n,r,i,a)=>L(this,void 0,void 0,function*(){let{joinResponse:o,serverInfo:s}=yield n.join(e,t,{autoSubscribe:r.autoSubscribe,adaptiveStream:typeof i.adaptiveStream==`object`?!0:i.adaptiveStream,clientInfoCapabilities:Js(i.packetTrailer)||this.e2eeManager?[gn.CAP_PACKET_TRAILER]:void 0,maxRetries:r.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:r.websocketTimeout},a.signal,!i.singlePeerConnection);if(this.serverInfo=s,!s.version)throw new Na(`unknown server version`);return s.version===`0.15.1`&&this.options.dynacast&&(this.log.debug(`disabling dynacast due to server version`),i.dynacast=!1),o}),this.applyJoinResponse=e=>{let t=e.participant;if(this.localParticipant.sid=t.sid,this.localParticipant.identity=t.identity,this.localParticipant.setEnabledPublishCodecs(e.enabledPublishCodecs),this.e2eeManager)try{this.e2eeManager.setSifTrailer(e.sifTrailer)}catch(e){this.log.error(e instanceof Error?e.message:`Could not set SifTrailer`,{error:e})}this.handleParticipantUpdates([t,...e.otherParticipants]),e.room&&this.handleRoomUpdate(e.room)},this.attemptConnection=(e,t,n,r)=>L(this,void 0,void 0,function*(){this.state===$d.Reconnecting||this.isResuming||this.engine?.pendingReconnect?(this.log.info(`Reconnection attempt replaced by new connection attempt`),this.recreateEngine(!0)):this.maybeCreateEngine(),this.regionUrlProvider?.isCloud()&&this.engine.setRegionStrategy(this.createRegionStrategy()),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},pl),n),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{let n=yield this.connectSignal(e,t,this.engine,this.connOptions,this.options,r);this.applyJoinResponse(n),this.setupLocalParticipantEvents(),this.emit(z.SignalConnected)}catch(e){yield this.engine.close(),this.recreateEngine();let t=r.signal.aborted?R.cancelled(`Signal connection aborted`):R.serverUnreachable(`could not establish signal connection`);throw e instanceof Error&&(t.message=`${t.message}: ${e.message}`),e instanceof R&&(t.reason=e.reason,t.status=e.status),this.log.debug(`error trying to establish signal connection`,{error:e}),t}if(r.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),R.cancelled(`Connection attempt aborted`);try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,r)}catch(e){throw yield this.engine.close(),this.recreateEngine(),e}Uo()&&this.options.disconnectOnPageLeave&&(window.addEventListener(`pagehide`,this.onPageLeave),window.addEventListener(`beforeunload`,this.onPageLeave)),Uo()&&window.addEventListener(`freeze`,this.onPageLeave),this.setAndEmitConnectionState($d.Connected),this.emit(z.Connected),pc.getInstance().resetFailedConnectionAttempts(e),this.registerConnectionReconcile(),this.regionUrlProvider&&this.regionUrlProvider.notifyConnected()}),this.disconnect=function(){return L(n,[...arguments],void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var n,r,i;let a=yield e.disconnectLock.lock();try{if(e.state===$d.Disconnected){e.log.debug(`already disconnected`);return}if(e.log.info(`disconnect from room`),e.state===$d.Connecting||e.state===$d.Reconnecting||e.isResuming){let t=`Abort connection attempt due to user initiated disconnect`;e.log.warn(t),(n=e.abortController)==null||n.abort(t),(i=(r=e.connectFuture)?.reject)==null||i.call(r,R.cancelled(`Client initiated disconnect`)),e.connectFuture=void 0}e.engine&&(e.engine.client.isDisconnected||(yield e.engine.client.sendLeave()),yield e.engine.close()),e.handleDisconnect(t,At.CLIENT_INITIATED),e.engine=void 0}finally{a()}}()})},this.onPageLeave=()=>L(this,void 0,void 0,function*(){this.log.info(`Page leave detected, disconnecting`),yield this.disconnect()}),this.startAudio=()=>L(this,void 0,void 0,function*(){let e=[],t=Ca();if(t&&t.os===`iOS`){let t=`livekit-dummy-audio-el`,n=document.getElementById(t);if(!n){n=document.createElement(`audio`),n.id=t,n.autoplay=!0,n.hidden=!0;let e=os();e.enabled=!0;let r=new MediaStream([e]);n.srcObject=r,document.addEventListener(`visibilitychange`,()=>{n&&(n.srcObject=document.hidden?null:r,document.hidden||(this.log.debug(`page visible again, triggering startAudio to resume playback and update playback status`),this.startAudio()))}),document.body.append(n),this.once(z.Disconnected,()=>{n?.remove(),n=null})}e.push(n)}this.remoteParticipants.forEach(t=>{t.audioTrackPublications.forEach(t=>{t.track&&t.track.attachedElements.forEach(t=>{e.push(t)})})});try{yield Promise.all([this.acquireAudioContext(),...e.map(e=>(e.muted=!1,e.play()))]),this.handleAudioPlaybackStarted()}catch(e){throw this.handleAudioPlaybackFailed(e),e}}),this.startVideo=()=>L(this,void 0,void 0,function*(){let e=[];for(let t of this.remoteParticipants.values())t.videoTrackPublications.forEach(t=>{var n;(n=t.track)==null||n.attachedElements.forEach(t=>{e.includes(t)||e.push(t)})});yield Promise.all(e.map(e=>e.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(e=>{e.name===`NotAllowedError`?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler")})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(let e of this.remoteParticipants.values())this.handleParticipantDisconnected(e.identity,e);this.setAndEmitConnectionState($d.Reconnecting)&&this.emit(z.Reconnecting)},this.handleRestarted=()=>{this.outgoingDataTrackManager.sfuWillRepublishTracks(),this.incomingDataTrackManager.resendSubscriptionUpdates()},this.handleSignalRestarted=e=>L(this,void 0,void 0,function*(){this.log.debug(`signal reconnected to server, region ${e.serverRegion}`,{region:e.serverRegion}),this.bufferedEvents=[],this.applyJoinResponse(e);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(e){this.log.error(`error trying to re-publish tracks after reconnection`,{error:e})}try{yield this.engine.waitForRestarted(),this.log.debug(`fully reconnected to server`,{region:e.serverRegion})}catch{return}this.setAndEmitConnectionState($d.Connected),this.emit(z.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=e=>{for(let t of e){if(t.identity===this.localParticipant.identity){this.localParticipant.updateInfo(t);continue}t.identity===``&&(t.identity=this.sidToIdentity.get(t.sid)??``);let e=this.remoteParticipants.get(t.identity);t.state===zt.DISCONNECTED?this.handleParticipantDisconnected(t.identity,e):this.getOrCreateParticipant(t.identity,t)}let t=new Map(e.filter(e=>e.identity!==this.localParticipant.identity).map(e=>[e.identity,e.dataTracks.map(e=>Ec.from(e))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(t)},this.handleActiveSpeakersUpdate=e=>{let t=[],n={};e.forEach(e=>{if(n[e.sid]=!0,e.sid===this.localParticipant.sid)this.localParticipant.audioLevel=e.level,this.localParticipant.setIsSpeaking(!0),t.push(this.localParticipant);else{let n=this.getRemoteParticipantBySid(e.sid);n&&(n.audioLevel=e.level,n.setIsSpeaking(!0),t.push(n))}}),n[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(e=>{n[e.sid]||(e.audioLevel=0,e.setIsSpeaking(!1))}),this.activeSpeakers=t,this.emitWhenConnected(z.ActiveSpeakersChanged,t)},this.handleSpeakersChanged=e=>{let t=new Map;this.activeSpeakers.forEach(e=>{let n=this.remoteParticipants.get(e.identity);n&&n.sid!==e.sid||t.set(e.sid,e)}),e.forEach(e=>{let n=this.getRemoteParticipantBySid(e.sid);e.sid===this.localParticipant.sid&&(n=this.localParticipant),n&&(n.audioLevel=e.level,n.setIsSpeaking(e.active),e.active?t.set(e.sid,n):t.delete(e.sid))});let n=Array.from(t.values());n.sort((e,t)=>t.audioLevel-e.audioLevel),this.activeSpeakers=n,this.emitWhenConnected(z.ActiveSpeakersChanged,n)},this.handleStreamStateUpdate=e=>{e.streamStates.forEach(e=>{let t=this.getRemoteParticipantBySid(e.participantSid);if(!t)return;let n=t.getTrackPublicationBySid(e.trackSid);if(!n||!n.track)return;let r=U.streamStateFromProto(e.state);n.track.setStreamState(r),r!==n.track.streamState&&(t.emit(B.TrackStreamStateChanged,n,n.track.streamState),this.emitWhenConnected(z.TrackStreamStateChanged,n,n.track.streamState,t))})},this.handleSubscriptionPermissionUpdate=e=>{let t=this.getRemoteParticipantBySid(e.participantSid);if(!t)return;let n=t.getTrackPublicationBySid(e.trackSid);n&&n.setAllowed(e.allowed)},this.handleSubscriptionError=e=>{let t=Array.from(this.remoteParticipants.values()).find(t=>t.trackPublications.has(e.trackSid));if(!t)return;let n=t.getTrackPublicationBySid(e.trackSid);n&&n.setSubscriptionError(e.err)},this.handleDataPacket=(e,t)=>{let n=this.remoteParticipants.get(e.participantIdentity);if(e.value.case===`user`)this.handleUserPacket(n,e.value.value,e.kind,t);else if(e.value.case===`transcription`)this.handleTranscription(n,e.value.value);else if(e.value.case===`sipDtmf`)this.handleSipDtmf(n,e.value.value);else if(e.value.case===`chatMessage`)this.handleChatMessage(n,e.value.value);else if(e.value.case===`metrics`)this.handleMetrics(e.value.value,n);else if(e.value.case===`streamHeader`||e.value.case===`streamChunk`||e.value.case===`streamTrailer`)this.handleDataStream(e,t);else if(e.value.case===`rpcRequest`){let t=e.value.value;this.rpcServerManager.handleIncomingRpcRequest(e.participantIdentity,t)}else if(e.value.case===`rpcResponse`){let t=e.value.value;switch(t.value.case){case`payload`:this.rpcClientManager.handleIncomingRpcResponseSuccess(t.requestId,t.value.value);break;case`error`:this.rpcClientManager.handleIncomingRpcResponseFailure(t.requestId,kd.fromProto(t.value.value));break;default:this.log.warn(`Unknown rpcResponse.value.case: ${t.value.case}`,this.logContext);break}}else e.value.case===`rpcAck`&&this.rpcClientManager.handleIncomingRpcAck(e.value.value.requestId)},this.handleUserPacket=(e,t,n,r)=>{this.emit(z.DataReceived,t.payload,e,n,t.topic,r),e?.emit(B.DataReceived,t.payload,n,r)},this.handleSipDtmf=(e,t)=>{this.emit(z.SipDTMFReceived,t,e),e?.emit(B.SipDTMFReceived,t)},this.handleTranscription=(e,t)=>{let n=t.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(t.transcribedParticipantIdentity),r=n?.trackPublications.get(t.trackId),i=fs(t,this.transcriptionReceivedTimes);r?.emit(H.TranscriptionReceived,i),n?.emit(B.TranscriptionReceived,i,r),this.emit(z.TranscriptionReceived,i,n,r)},this.handleChatMessage=(e,t)=>{let n=ps(t);this.emit(z.ChatMessage,n,e)},this.handleMetrics=(e,t)=>{this.emit(z.MetricsReceived,e,t)},this.handleDataStream=(e,t)=>{this.incomingDataStreamManager.handleDataStreamPacket(e,t)},this.bufferedSegments=new Map,this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(z.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=e=>{this.log.warn(`could not playback audio`,{error:e}),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(z.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(z.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(z.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>L(this,void 0,void 0,function*(){Ca()?.os!==`iOS`&&(yield this.selectDefaultDevices()),this.emit(z.MediaDevicesChanged)}),this.handleRoomUpdate=e=>{let t=this.roomInfo;this.roomInfo=e,t&&t.metadata!==e.metadata&&this.emitWhenConnected(z.RoomMetadataChanged,e.metadata),t?.activeRecording!==e.activeRecording&&this.emitWhenConnected(z.RecordingStatusChanged,e.activeRecording)},this.handleConnectionQualityUpdate=e=>{e.updates.forEach(e=>{if(e.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(e.quality);return}let t=this.getRemoteParticipantBySid(e.participantSid);t&&t.setConnectionQuality(e.quality)})},this.getRemoteParticipantClientProtocol=e=>this.remoteParticipants.get(e)?.clientProtocol??0,this.onLocalParticipantMetadataChanged=e=>{this.emit(z.ParticipantMetadataChanged,e,this.localParticipant)},this.onLocalParticipantNameChanged=e=>{this.emit(z.ParticipantNameChanged,e,this.localParticipant)},this.onLocalAttributesChanged=e=>{this.emit(z.ParticipantAttributesChanged,e,this.localParticipant)},this.onLocalTrackMuted=e=>{this.emit(z.TrackMuted,e,this.localParticipant)},this.onLocalTrackUnmuted=e=>{this.emit(z.TrackUnmuted,e,this.localParticipant)},this.onTrackProcessorUpdate=e=>{var t;(t=e?.onPublish)==null||t.call(e,this)},this.onLocalTrackPublished=e=>L(this,void 0,void 0,function*(){var t,n,r,i;(t=e.track)==null||t.on(H.TrackProcessorUpdate,this.onTrackProcessorUpdate),(n=e.track)==null||n.on(H.Restarted,this.onLocalTrackRestarted),(i=(r=e.track?.getProcessor())?.onPublish)==null||i.call(r,this),this.emit(z.LocalTrackPublished,e,this.localParticipant),xs(e.track)&&(yield e.track.checkForSilence())&&this.emit(z.LocalAudioSilenceDetected,e);let a=yield e.track?.getDeviceId(!1),o=oo(e.source);o&&a&&a!==this.localParticipant.activeDeviceMap.get(o)&&(this.localParticipant.activeDeviceMap.set(o,a),this.emit(z.ActiveDeviceChanged,o,a))}),this.onLocalTrackUnpublished=e=>{var t,n;(t=e.track)==null||t.off(H.TrackProcessorUpdate,this.onTrackProcessorUpdate),(n=e.track)==null||n.off(H.Restarted,this.onLocalTrackRestarted),this.emit(z.LocalTrackUnpublished,e,this.localParticipant)},this.onLocalTrackRestarted=e=>L(this,void 0,void 0,function*(){let t=yield e.getDeviceId(!1),n=oo(e.source);n&&t&&t!==this.localParticipant.activeDeviceMap.get(n)&&(this.log.debug(`local track restarted, setting ${n} ${t} active`),this.localParticipant.activeDeviceMap.set(n,t),this.emit(z.ActiveDeviceChanged,n,t))}),this.onLocalConnectionQualityChanged=e=>{this.emit(z.ConnectionQualityChanged,e,this.localParticipant)},this.onMediaDevicesError=(e,t)=>{this.emit(z.MediaDevicesError,e,t)},this.onLocalParticipantPermissionsChanged=e=>{this.emit(z.ParticipantPermissionsChanged,e,this.localParticipant)},this.onLocalChatMessageSent=e=>{this.emit(z.ChatMessage,e,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},fl),t),this.log=Gr(this.options.loggerName??Wr.Room,()=>this.logContext),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},ul),t?.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},dl),t?.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},ll),t?.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new pu,this.outgoingDataStreamManager=new vu(this.engine,this.log),this.incomingDataTrackManager=new pd({e2eeManager:this.e2eeManager}),this.incomingDataTrackManager.on(`sfuUpdateSubscription`,e=>{this.engine.client.sendUpdateDataSubscription(e.sid,e.subscribe)}).on(`trackPublished`,e=>{var t;e.track.publisherIdentity!==this.localParticipant.identity&&(this.emit(z.DataTrackPublished,e.track),(t=this.remoteParticipants.get(e.track.publisherIdentity))==null||t.addRemoteDataTrack(e.track))}).on(`trackUnpublished`,e=>{var t;e.publisherIdentity!==this.localParticipant.identity&&(this.emit(z.DataTrackUnpublished,e.sid),(t=this.remoteParticipants.get(e.publisherIdentity))==null||t.removeRemoteDataTrack(e.sid))}),this.outgoingDataTrackManager=new Od({e2eeManager:this.e2eeManager}),this.outgoingDataTrackManager.on(`sfuPublishRequest`,e=>{this.engine.client.sendPublishDataTrackRequest(e.handle,e.name,e.usesE2ee)}).on(`sfuUnpublishRequest`,e=>{this.engine.client.sendUnPublishDataTrackRequest(e.handle)}).on(`trackPublished`,e=>{this.emit(z.LocalDataTrackPublished,e.track)}).on(`trackUnpublished`,e=>{this.emit(z.LocalDataTrackUnpublished,e.sid)}).on(`packetAvailable`,e=>{let{handle:t,bytes:n}=e;this.engine.sendLossyBytes(n,ru.DATA_TRACK_LOSSY,`wait`).finally(()=>this.outgoingDataTrackManager.handlePacketSendComplete(t))}),this.registerRpcDataStreamHandler(),this.rpcClientManager=new Rd(this.log,this.outgoingDataStreamManager,this.getRemoteParticipantClientProtocol,()=>this.engine.latestJoinResponse?.serverInfo?.version),this.rpcClientManager.on(`sendDataPacket`,e=>{let{packet:t}=e;var n;(n=this.engine)==null||n.sendDataPacket(t,ru.RELIABLE)}),this.rpcServerManager=new zd(this.log,this.outgoingDataStreamManager,this.getRemoteParticipantClientProtocol),this.rpcServerManager.on(`sendDataPacket`,e=>{let{packet:t}=e;var n;(n=this.engine)==null||n.sendDataPacket(t,ru.RELIABLE)}),this.disconnectLock=new i,this.localParticipant=new Jd(``,``,this.engine,this.options,this.outgoingDataStreamManager,this.outgoingDataTrackManager,this.rpcClientManager,this.rpcServerManager),this.setupPacketTrailer(),(this.options.e2ee||this.options.encryption)&&this.setupE2EE(),this.engine.e2eeManager=this.e2eeManager,this.incomingDataTrackManager.updateE2eeManager(this.e2eeManager??null),this.outgoingDataTrackManager.updateE2eeManager(this.e2eeManager??null),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set(`videoinput`,ls(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set(`audioinput`,ls(this.options.audioCaptureDefaults.deviceId)),this.options.audioOutput?.deviceId&&this.switchActiveDevice(`audiooutput`,ls(this.options.audioOutput.deviceId)).catch(e=>this.log.warn(`Could not set audio output: ${e.message}`)),Uo()){let t=new AbortController,n;if(e.cleanupRegistry){let r=new WeakRef(this);n=()=>{let e=r.deref();e&&e.handleDeviceChange()},e.cleanupRegistry.register(this,()=>{t.abort()})}else n=this.handleDeviceChange;(a=(r=navigator.mediaDevices)?.addEventListener)==null||a.call(r,`devicechange`,n,{signal:t.signal})}}registerTextStreamHandler(e,t){return this.incomingDataStreamManager.registerTextStreamHandler(e,t)}unregisterTextStreamHandler(e){return this.incomingDataStreamManager.unregisterTextStreamHandler(e)}registerByteStreamHandler(e,t){return this.incomingDataStreamManager.registerByteStreamHandler(e,t)}unregisterByteStreamHandler(e){return this.incomingDataStreamManager.unregisterByteStreamHandler(e)}registerRpcMethod(e,t){this.rpcServerManager.registerRpcMethod(e,t)}unregisterRpcMethod(e){this.rpcServerManager.unregisterRpcMethod(e)}setE2EEEnabled(e){return L(this,void 0,void 0,function*(){let t=yield this.e2eeStateMutex.lock();try{if(this.e2eeManager)this.isE2EEEnabled!==e&&(yield this.localParticipant.setE2EEEnabled(e),this.localParticipant.identity!==``&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity));else throw Error(`e2ee not configured, please set e2ee settings within the room options`)}finally{t()}})}setupE2EE(){var e,t;let n=!!this.options.encryption,r=this.options.encryption||this.options.e2ee;r&&(`e2eeManager`in r?(this.e2eeManager=r.e2eeManager,this.e2eeManager.isDataChannelEncryptionEnabled=n):this.e2eeManager=new sc(r,n),this.e2eeManager.on(Bs.ParticipantEncryptionStatusChanged,(e,t)=>{Ts(t)&&(this.isE2EEEnabled=e),this.emit(z.ParticipantEncryptionStatusChanged,e,t)}),this.e2eeManager.on(Bs.EncryptionError,(e,t)=>{let n=t?this.getParticipantByIdentity(t):void 0;this.emit(z.EncryptionError,e,n)}),(e=this.e2eeManager)==null||e.setup(this),(t=this.e2eeManager)==null||t.setupEngine(this.engine))}setupPacketTrailer(){this.packetTrailerManager=new uc(this.options.packetTrailer),this.packetTrailerManager.setup(this)}get logContext(){return{room:this.name,roomID:this.roomInfo?.sid,participant:this.localParticipant?.identity,participantID:this.localParticipant?.sid}}get isRecording(){return this.roomInfo?.activeRecording??!1}getSid(){return this.state===$d.Disconnected?ba.resolve(``):this.roomInfo&&this.roomInfo.sid!==``?ba.resolve(this.roomInfo.sid):new ba((e,t)=>{let n=t=>{t.sid!==``&&(this.engine.off(V.RoomUpdate,n),e(t.sid))};this.engine.on(V.RoomUpdate,n),this.once(z.Disconnected,()=>{this.engine.off(V.RoomUpdate,n),t(new Pa(`Room disconnected before room server id was available`))})})}get name(){return this.roomInfo?.name??``}get metadata(){return this.roomInfo?.metadata}get numParticipants(){return this.roomInfo?.numParticipants??0}get numPublishers(){return this.roomInfo?.numPublishers??0}maybeCreateEngine(){this.engine&&(this.engine.isNewlyCreated||!this.engine.isClosed)||(this.engine=new iu(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(V.ParticipantUpdate,this.handleParticipantUpdates).on(V.RoomUpdate,this.handleRoomUpdate).on(V.SpeakersChanged,this.handleSpeakersChanged).on(V.StreamStateChanged,this.handleStreamStateUpdate).on(V.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(V.SubscriptionError,this.handleSubscriptionError).on(V.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(V.MediaTrackAdded,(e,t,n)=>{this.onTrackAdded(e,t,n)}).on(V.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(V.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(V.DataPacketReceived,this.handleDataPacket).on(V.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.debug(`Resuming signal connection`),this.setAndEmitConnectionState($d.SignalReconnecting)&&this.emit(z.SignalReconnecting)}).on(V.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.debug(`Resumed signal connection`),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState($d.Connected)&&this.emit(z.Reconnected)}).on(V.SignalResumed,()=>{this.bufferedEvents=[],(this.state===$d.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(V.Restarting,this.handleRestarting).on(V.Restarted,this.handleRestarted).on(V.SignalRestarted,this.handleSignalRestarted).on(V.Offline,()=>{this.setAndEmitConnectionState($d.Reconnecting)&&this.emit(z.Reconnecting)}).on(V.DCBufferStatusChanged,(e,t)=>{this.emit(z.DCBufferStatusChanged,e,t)}).on(V.LocalTrackSubscribed,e=>{this.handleLocalTrackSubscribed(e)}).on(V.RoomMoved,e=>{this.log.debug(`room moved`,e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((e,t)=>{this.handleParticipantDisconnected(t,e)}),this.emit(z.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}).on(V.PublishDataTrackResponse,e=>{if(!e.info){this.log.warn(`received PublishDataTrackResponse, but event.info was ${e.info}, so skipping.`);return}this.outgoingDataTrackManager.receivedSfuPublishResponse(e.info.pubHandle,{type:`ok`,data:{sid:e.info.sid,pubHandle:e.info.pubHandle,name:e.info.name,usesE2ee:e.info.encryption!==Ht.NONE}})}).on(V.UnPublishDataTrackResponse,e=>{if(!e.info){this.log.warn(`received UnPublishDataTrackResponse, but event.info was ${e.info}, so skipping.`);return}this.outgoingDataTrackManager.receivedSfuUnpublishResponse(e.info.pubHandle)}).on(V.DataTrackSubscriberHandles,e=>{let t=new Map(Object.entries(e.subHandles).map(e=>{let[t,n]=e;return[parseInt(t,10),n.trackSid]}));this.incomingDataTrackManager.receivedSfuSubscriberHandles(t)}).on(V.DataTrackPacketReceived,e=>{try{this.incomingDataTrackManager.packetReceived(e)}catch(e){throw e}}).on(V.Joined,e=>{let t=new Map(e.otherParticipants.map(e=>[e.identity,e.dataTracks.map(e=>Ec.from(e))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(t)}).on(V.TokenRefreshed,e=>{var t;(t=this.regionUrlProvider)==null||t.updateToken(e)}).on(V.ServerRegionsReported,e=>{var t;(t=this.regionUrlProvider)==null||t.setServerReportedRegions({regionSettings:e,updatedAtInMs:Date.now(),maxAgeInMs:ou})}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine),this.outgoingDataStreamManager&&this.outgoingDataStreamManager.setupEngine(this.engine))}createRegionStrategy(){return{getNextUrl:e=>L(this,void 0,void 0,function*(){return this.regionUrlProvider?this.regionUrlProvider.getNextBestRegionUrl(e):null}),resetAttempts:()=>this.regionUrlProvider?.resetAttempts()}}static getLocalDevices(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return hc.getInstance().getDevices(e,t)}prepareConnection(e,t){return L(this,void 0,void 0,function*(){if(this.state===$d.Disconnected){this.log.debug(`prepareConnection to ${e}`);try{if(Go(new URL(e))&&t){this.regionUrlProvider=new cu(e,t);let n=yield this.regionUrlProvider.getNextBestRegionUrl();n&&this.state===$d.Disconnected&&(this.regionUrl=n,yield fetch(ds(n),{method:`HEAD`}),this.log.debug(`prepared connection to ${n}`))}else yield fetch(ds(e),{method:`HEAD`})}catch(e){this.log.warn(`could not prepare connection`,{error:e})}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return L(this,void 0,void 0,function*(){let n=()=>L(this,void 0,void 0,function*(){}),r;switch(e){case`signal-reconnect`:yield this.engine.client.handleOnClose(`simulate disconnect`);break;case`fail-on-v1-path`:this.engine.failNextV1Path();break;case`speaker`:r=new Cr({scenario:{case:`speakerUpdate`,value:3}});break;case`node-failure`:r=new Cr({scenario:{case:`nodeFailure`,value:!0}});break;case`server-leave`:r=new Cr({scenario:{case:`serverLeave`,value:!0}});break;case`migration`:r=new Cr({scenario:{case:`migration`,value:!0}});break;case`resume-reconnect`:this.engine.failNext(),yield this.engine.client.handleOnClose(`simulate resume-disconnect`);break;case`disconnect-signal-on-resume`:n=()=>L(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose(`simulate resume-disconnect`)}),r=new Cr({scenario:{case:`disconnectSignalOnResume`,value:!0}});break;case`disconnect-signal-on-resume-no-messages`:n=()=>L(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose(`simulate resume-disconnect`)}),r=new Cr({scenario:{case:`disconnectSignalOnResumeNoMessages`,value:!0}});break;case`full-reconnect`:this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose(`simulate full-reconnect`);break;case`force-tcp`:case`force-tls`:r=new Cr({scenario:{case:`switchCandidateProtocol`,value:e===`force-tls`?2:1}}),n=()=>L(this,void 0,void 0,function*(){let e=this.engine.client.onLeave;e&&e(new tr({reason:At.CLIENT_INITIATED,action:nr.RECONNECT}))});break;case`subscriber-bandwidth`:if(t===void 0||typeof t!=`number`)throw Error(`subscriber-bandwidth requires a number as argument`);r=new Cr({scenario:{case:`subscriberBandwidth`,value:gs(t)}});break;case`leave-full-reconnect`:r=new Cr({scenario:{case:`leaveRequestFullReconnect`,value:!0}})}r&&(yield this.engine.client.sendSimulateScenario(r),yield n())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,t){return L(this,arguments,void 0,function(e,t){var n=this;let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return function*(){var i,a;let o=!0,s=!1,c=r?{exact:t}:t;if(e===`audioinput`){s=n.localParticipant.audioTrackPublications.size===0;let t=n.getActiveDevice(e)??n.options.audioCaptureDefaults.deviceId;n.options.audioCaptureDefaults.deviceId=c;let r=Array.from(n.localParticipant.audioTrackPublications.values()).filter(e=>e.source===U.Source.Microphone);try{o=(yield Promise.all(r.map(e=>e.audioTrack?.setDeviceId(c)))).every(e=>e===!0)}catch(e){throw n.options.audioCaptureDefaults.deviceId=t,e}let i=r.some(e=>e.track?.isMuted??!1);o&&i&&(s=!0)}else if(e===`videoinput`){s=n.localParticipant.videoTrackPublications.size===0;let t=n.getActiveDevice(e)??n.options.videoCaptureDefaults.deviceId;n.options.videoCaptureDefaults.deviceId=c;let r=Array.from(n.localParticipant.videoTrackPublications.values()).filter(e=>e.source===U.Source.Camera);try{o=(yield Promise.all(r.map(e=>e.videoTrack?.setDeviceId(c)))).every(e=>e===!0)}catch(e){throw n.options.videoCaptureDefaults.deviceId=t,e}let i=r.some(e=>e.track?.isMuted??!1);o&&i&&(s=!0)}else if(e===`audiooutput`){if(s=!0,!Mo()&&!n.options.webAudioMix||n.options.webAudioMix&&n.audioContext&&!(`setSinkId`in n.audioContext))throw Error(`cannot switch audio output, the current browser does not support it`);n.options.webAudioMix&&(t=(yield hc.getInstance().normalizeDeviceId(`audiooutput`,t))??``),(a=n.options).audioOutput??(a.audioOutput={});let r=n.getActiveDevice(e)??n.options.audioOutput.deviceId;n.options.audioOutput.deviceId=t;try{n.options.webAudioMix&&((i=n.audioContext)==null||i.setSinkId(t)),yield Promise.all(Array.from(n.remoteParticipants.values()).map(e=>e.setAudioOutput({deviceId:t})))}catch(e){throw n.options.audioOutput.deviceId=r,e}}return s&&(n.localParticipant.activeDeviceMap.set(e,t),n.emit(z.ActiveDeviceChanged,e,t)),o}()})}setupLocalParticipantEvents(){this.localParticipant.on(B.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(B.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(B.AttributesChanged,this.onLocalAttributesChanged).on(B.TrackMuted,this.onLocalTrackMuted).on(B.TrackUnmuted,this.onLocalTrackUnmuted).on(B.LocalTrackPublished,this.onLocalTrackPublished).on(B.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(B.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(B.MediaDevicesError,this.onMediaDevicesError).on(B.AudioStreamAcquired,this.startAudio).on(B.ChatMessage,this.onLocalChatMessageSent).on(B.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(e){let t=this.engine;e&&t&&!t.client.isDisconnected?t.client.sendLeave().finally(()=>t.close()):t?.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,t,n){if(this.state===$d.Connecting||this.state===$d.Reconnecting){let r=()=>{this.log.debug(`deferring on track for later`,{mediaTrackId:e.id,mediaStreamId:t.id,tracksInStream:t.getTracks().map(e=>e.id)}),this.onTrackAdded(e,t,n),i()},i=()=>{this.off(z.Reconnected,r),this.off(z.Connected,r),this.off(z.Disconnected,i)};this.once(z.Reconnected,r),this.once(z.Connected,r),this.once(z.Disconnected,i);return}if(this.state===$d.Disconnected){this.log.warn(`skipping incoming track after Room disconnected`);return}if(e.readyState===`ended`){this.log.debug(`skipping incoming track as it already ended`);return}let r=To(t.id),i=r[0],a=r[1],o=e.id;if(a&&a.startsWith(`TR`)&&(o=a),i===this.localParticipant.sid){this.log.warn(`tried to create RemoteParticipant for local participant`);return}let s=Array.from(this.remoteParticipants.values()).find(e=>e.sid===i);if(!s){i.startsWith(`PA`)&&this.log.error(`Tried to add a track for a participant, that's not present. Sid: ${i}`);return}if(!o.startsWith(`TR`)){let e=this.engine.getTrackIdForReceiver(n);if(!e){this.log.error(`Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ${i}`);return}o=e}o.startsWith(`TR`)||this.log.warn(`Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ${i}, streamId: ${a}, trackId: ${o}`,{remoteParticipantID:i,streamId:a,trackId:o});let c;this.options.adaptiveStream&&(c=typeof this.options.adaptiveStream==`object`?this.options.adaptiveStream:{});let l=s.addSubscribedMediaTrack(e,o,t,n,c);l?.isEncrypted&&!this.e2eeManager&&this.emit(z.EncryptionError,Error(`Encrypted ${l.source} track received from participant ${s.sid}, but room does not have encryption enabled!`))}handleLocalTrackSubscribed(e){let t=()=>this.localParticipant.getTrackPublications().find(t=>{let{trackSid:n}=t;return n===e}),n=t();if(n){this.emitLocalTrackSubscribed(n);return}this.log.debug(`deferring LocalTrackSubscribed, publication not yet available`,{subscribedSid:e});let r,i=t=>{t.trackSid===e&&(a(),this.emitLocalTrackSubscribed(t))},a=()=>{clearTimeout(r),this.localParticipant.off(B.LocalTrackPublished,i),this.off(z.Disconnected,a)};this.localParticipant.on(B.LocalTrackPublished,i),this.once(z.Disconnected,a),r=setTimeout(()=>{a();let n=t();n?this.emitLocalTrackSubscribed(n):this.log.warn(`could not find local track publication for LocalTrackSubscribed event after timeout`,{subscribedSid:e})},1e4)}emitLocalTrackSubscribed(e){this.localParticipant.emit(B.LocalTrackSubscribed,e),this.emitWhenConnected(z.LocalTrackSubscribed,e,this.localParticipant)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1?arguments[1]:void 0;var n,r;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.incomingDataStreamManager.clearControllers(),this.incomingDataTrackManager.reset(),this.outgoingDataTrackManager.reset(),this.state!==$d.Disconnected){this.regionUrl=void 0,this.regionUrlProvider&&this.regionUrlProvider.notifyDisconnected();try{this.remoteParticipants.forEach(e=>{e.trackPublications.forEach(t=>{e.unpublishTrack(t.trackSid)})}),this.localParticipant.trackPublications.forEach(t=>{var n,r,i;t.track&&this.localParticipant.unpublishTrack(t.track,e),e?((n=t.track)==null||n.detach(),(r=t.track)==null||r.stop()):(i=t.track)==null||i.stopMonitor()}),this.localParticipant.off(B.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(B.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(B.AttributesChanged,this.onLocalAttributesChanged).off(B.TrackMuted,this.onLocalTrackMuted).off(B.TrackUnmuted,this.onLocalTrackUnmuted).off(B.LocalTrackPublished,this.onLocalTrackPublished).off(B.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(B.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(B.MediaDevicesError,this.onMediaDevicesError).off(B.AudioStreamAcquired,this.startAudio).off(B.ChatMessage,this.onLocalChatMessageSent).off(B.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&typeof this.options.webAudioMix==`boolean`&&(this.audioContext.close(),this.audioContext=void 0),Uo()&&(window.removeEventListener(`beforeunload`,this.onPageLeave),window.removeEventListener(`pagehide`,this.onPageLeave),window.removeEventListener(`freeze`,this.onPageLeave),(r=(n=navigator.mediaDevices)?.removeEventListener)==null||r.call(n,`devicechange`,this.handleDeviceChange))}finally{this.setAndEmitConnectionState($d.Disconnected),this.emit(z.Disconnected,t)}}}handleParticipantDisconnected(e,t){this.remoteParticipants.delete(e),t&&(this.incomingDataStreamManager.validateParticipantHasNoActiveDataStreams(e),this.incomingDataTrackManager.handleRemoteParticipantDisconnected(e),t.trackPublications.forEach(e=>{t.unpublishTrack(e.trackSid,!0)}),this.emit(z.ParticipantDisconnected,t),t.setDisconnected(),this.rpcClientManager.handleParticipantDisconnected(t.identity))}selectDefaultDevices(){return L(this,void 0,void 0,function*(){let e=hc.getInstance().previousDevices,t=yield hc.getInstance().getDevices(void 0,!1),n=Ca();if(n?.name===`Chrome`&&n.os!==`iOS`)for(let n of t){let t=e.find(e=>e.deviceId===n.deviceId);t&&t.label!==``&&t.kind===n.kind&&t.label!==n.label&&this.getActiveDevice(n.kind)==="default"&&this.emit(z.ActiveDeviceChanged,n.kind,n.deviceId)}for(let n of[`audiooutput`,`audioinput`,`videoinput`]){let r=ao(n),i=this.localParticipant.getTrackPublication(r);if(i&&i.track?.isUserProvided)continue;let a=t.filter(e=>e.kind===n),o=this.getActiveDevice(n);if(o===e.filter(e=>e.kind===n)[0]?.deviceId&&a.length>0&&a[0]?.deviceId!==o){yield this.switchActiveDevice(n,a[0].deviceId);continue}n===`audioinput`&&!Ro()||n===`videoinput`||a.length>0&&!a.find(e=>e.deviceId===this.getActiveDevice(n))&&(n!==`audiooutput`||!Ro())&&(yield this.switchActiveDevice(n,a[0].deviceId))}})}acquireAudioContext(){return L(this,void 0,void 0,function*(){if(typeof this.options.webAudioMix!=`boolean`&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state===`closed`)&&(this.audioContext=io()??void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(e=>e.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state===`suspended`)try{yield Promise.race([this.audioContext.resume(),Eo(200)])}catch(e){this.log.warn(`Could not resume audio context`,{error:e})}let e=this.audioContext?.state===`running`;e!==this.canPlaybackAudio&&(this.audioEnabled=e,this.emit(z.AudioPlaybackStatusChanged,e))})}createParticipant(e,t){let n;return n=t?Qd.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName},this.incomingDataTrackManager):new Qd(this.engine.client,``,e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&n.setAudioContext(this.audioContext),this.options.audioOutput?.deviceId&&n.setAudioOutput(this.options.audioOutput).catch(e=>this.log.warn(`Could not set audio output: ${e.message}`)),n}getOrCreateParticipant(e,t){if(this.remoteParticipants.has(e)){let n=this.remoteParticipants.get(e);return t&&n.updateInfo(t)&&this.sidToIdentity.set(t.sid,t.identity),n}let n=this.createParticipant(e,t);return this.remoteParticipants.set(e,n),this.sidToIdentity.set(t.sid,t.identity),this.emitWhenConnected(z.ParticipantConnected,n),n.on(B.TrackPublished,e=>{this.emitWhenConnected(z.TrackPublished,e,n)}).on(B.TrackSubscribed,(e,t)=>{e.kind===U.Kind.Audio?(e.on(H.AudioPlaybackStarted,this.handleAudioPlaybackStarted),e.on(H.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):e.kind===U.Kind.Video&&(e.on(H.VideoPlaybackFailed,this.handleVideoPlaybackFailed),e.on(H.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emitWhenConnected(z.TrackSubscribed,e,t,n)}).on(B.TrackUnpublished,e=>{this.emit(z.TrackUnpublished,e,n)}).on(B.TrackUnsubscribed,(e,t)=>{this.emit(z.TrackUnsubscribed,e,t,n)}).on(B.TrackMuted,e=>{this.emitWhenConnected(z.TrackMuted,e,n)}).on(B.TrackUnmuted,e=>{this.emitWhenConnected(z.TrackUnmuted,e,n)}).on(B.ParticipantMetadataChanged,e=>{this.emitWhenConnected(z.ParticipantMetadataChanged,e,n)}).on(B.ParticipantNameChanged,e=>{this.emitWhenConnected(z.ParticipantNameChanged,e,n)}).on(B.AttributesChanged,e=>{this.emitWhenConnected(z.ParticipantAttributesChanged,e,n)}).on(B.ConnectionQualityChanged,e=>{this.emitWhenConnected(z.ConnectionQualityChanged,e,n)}).on(B.ParticipantPermissionsChanged,e=>{this.emitWhenConnected(z.ParticipantPermissionsChanged,e,n)}).on(B.TrackSubscriptionStatusChanged,(e,t)=>{this.emitWhenConnected(z.TrackSubscriptionStatusChanged,e,t,n)}).on(B.TrackSubscriptionFailed,(e,t)=>{this.emit(z.TrackSubscriptionFailed,e,n,t)}).on(B.TrackSubscriptionPermissionChanged,(e,t)=>{this.emitWhenConnected(z.TrackSubscriptionPermissionChanged,e,t,n)}).on(B.Active,()=>{this.emitWhenConnected(z.ParticipantActive,n),n.kind===Bt.AGENT&&this.localParticipant.setActiveAgent(n)}),t&&n.updateInfo(t),n}sendSyncState(){let e=Array.from(this.remoteParticipants.values()).reduce((e,t)=>(e.push(...t.getTrackPublications()),e),[]),t=this.localParticipant.getTrackPublications(),n=this.outgoingDataTrackManager.queryPublished();this.engine.sendSyncState(e,t,n)}updateSubscriptions(){for(let e of this.remoteParticipants.values())for(let t of e.videoTrackPublications.values())t.isSubscribed&&Cs(t)&&t.emitTrackUpdate()}getRemoteParticipantBySid(e){let t=this.sidToIdentity.get(e);if(t)return this.remoteParticipants.get(t)}registerRpcDataStreamHandler(){this.incomingDataStreamManager.registerTextStreamHandler(jd,(e,t)=>L(this,[e,t],void 0,function(e,t){var n=this;let{identity:r}=t;return function*(){let t=e.info.attributes??{};yield n.rpcServerManager.handleIncomingDataStream(e,r,t)}()})),this.incomingDataStreamManager.registerTextStreamHandler(Md,(e,t)=>L(this,[e,t],void 0,function(e,t){var n=this;let{identity:r}=t;return function*(){let t=e.info.attributes??{};yield n.rpcClientManager.handleIncomingDataStream(e,r,t)}()}))}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=Ha.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn(`detected connection state mismatch`,{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnectedOrConnecting:this.engine.verifyTransport()}:void 0}),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,At.STATE_MISMATCH))):e=0},ef)}clearConnectionReconcile(){this.connectionReconcileInterval&&Ha.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.log.info(`connection state changed: ${this.state} -> ${e}`),this.state=e,this.incomingDataStreamManager.setConnected(e===$d.Connected),this.emit(z.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[t,n]=e;this.emit(t,...n)}),this.bufferedEvents=[]}emitWhenConnected(e){var t=[...arguments].slice(1);if(this.state===$d.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,t]);else if(this.state===$d.Connected)return this.emit(e,...t);return!1}simulateParticipants(e){return L(this,void 0,void 0,function*(){let t=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),n=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Ft({sid:`RM_SIMULATED`,name:`simulated-room`,emptyTimeout:0,maxParticipants:0,creationTime:A.parse(new Date().getTime()),metadata:``,numParticipants:1,numPublishers:1,turnPassword:``,enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new Rt({identity:`simulated-local`,name:`local-name`})),this.setupLocalParticipantEvents(),this.emit(z.SignalConnected),this.emit(z.Connected),this.setAndEmitConnectionState($d.Connected),t.video){let e=new Hd(U.Kind.Video,new Wt({source:Et.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:Tt.AUDIO,name:`video-dummy`}),new Hl(t.useRealTracks&&window.navigator.mediaDevices?.getUserMedia?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:is(160*(n.aspectRatios[0]??1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(e),this.localParticipant.emit(B.LocalTrackPublished,e)}if(t.audio){let e=new Hd(U.Kind.Audio,new Wt({source:Et.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:Tt.AUDIO}),new Cl(t.useRealTracks&&navigator.mediaDevices?.getUserMedia?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:os(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(e),this.localParticipant.emit(B.LocalTrackPublished,e)}for(let e=0;ee!==void 0);(e===z.TrackSubscribed||e===z.TrackUnsubscribed)&&this.log.trace(`subscribe trace: ${e}`,{event:e,args:n}),this.log.debug(`room event ${e}`,{event:e,args:n})}return super.emit(e,...t)}};tf.cleanupRegistry=typeof FinalizationRegistry<`u`&&typeof WeakRef<`u`&&new FinalizationRegistry(e=>{e()});function nf(e){return e.map(e=>{if(e)return Array.isArray(e)?nf(e):typeof e==`object`?`logContext`in e?e.logContext:void 0:e})}var rf;(function(e){e[e.IDLE=0]=`IDLE`,e[e.RUNNING=1]=`RUNNING`,e[e.SKIPPED=2]=`SKIPPED`,e[e.SUCCESS=3]=`SUCCESS`,e[e.FAILED=4]=`FAILED`})(rf||={}),oi.EventEmitter,oi.EventEmitter;function af(e,t,n){return(t=sf(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function of(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function sf(e){var t=of(e,`string`);return typeof t==`symbol`?t:t+``}new TextEncoder,new TextDecoder;var cf=class extends Error{constructor(e,t){var n;super(e,t),af(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};af(cf,`code`,`ERR_JOSE_GENERIC`),af(class extends cf{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),af(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),af(this,`claim`,void 0),af(this,`reason`,void 0),af(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}},`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),af(class extends cf{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),af(this,`code`,`ERR_JWT_EXPIRED`),af(this,`claim`,void 0),af(this,`reason`,void 0),af(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}},`code`,`ERR_JWT_EXPIRED`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}},`code`,`ERR_JOSE_ALG_NOT_ALLOWED`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}},`code`,`ERR_JOSE_NOT_SUPPORTED`),af(class extends cf{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,t=arguments.length>1?arguments[1]:void 0;super(e,t),af(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JWS_INVALID`)}},`code`,`ERR_JWS_INVALID`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JWT_INVALID`)}},`code`,`ERR_JWT_INVALID`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`),af(class extends cf{constructor(){super(...arguments),af(this,`code`,`ERR_JWKS_INVALID`)}},`code`,`ERR_JWKS_INVALID`),af(class extends cf{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,t=arguments.length>1?arguments[1]:void 0;super(e,t),af(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}},`code`,`ERR_JWKS_NO_MATCHING_KEY`),af(class extends cf{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,t=arguments.length>1?arguments[1]:void 0;super(e,t),af(this,Symbol.asyncIterator,void 0),af(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}},`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`),af(class extends cf{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,t=arguments.length>1?arguments[1]:void 0;super(e,t),af(this,`code`,`ERR_JWKS_TIMEOUT`)}},`code`,`ERR_JWKS_TIMEOUT`),af(class extends cf{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,t=arguments.length>1?arguments[1]:void 0;super(e,t),af(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}},`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var lf=`attached`,uf=1e3,df=1001,ff=1002,pf=1003,mf=1004,hf=1005,gf=1006,_f=1007,vf=1008,yf=1009,bf=1010,xf=1011,Sf=1012,Cf=1013,wf=1014,Tf=1015,Ef=1016,Df=1017,Of=1018,kf=1020,Af=35902,jf=35899,Mf=1021,Nf=1022,Pf=1023,Ff=1026,If=1027,Lf=1028,Rf=1029,zf=1030,Bf=1031,Vf=1033,Hf=33776,Uf=33777,Wf=33778,Gf=33779,Kf=35840,qf=35841,Jf=35842,Yf=35843,Xf=36196,Zf=37492,Qf=37496,$f=37488,ep=37489,tp=37490,np=37491,rp=37808,ip=37809,ap=37810,op=37811,sp=37812,cp=37813,lp=37814,up=37815,dp=37816,fp=37817,pp=37818,mp=37819,hp=37820,gp=37821,_p=36492,vp=36494,yp=36495,bp=36283,xp=36284,Sp=36285,Cp=36286,wp=2300,Tp=2301,Ep=2302,Dp=2303,Op=2400,kp=2401,Ap=2402,jp=2500,Mp=3200,Np=`srgb`,Pp=`srgb-linear`,Fp=`linear`,Ip=`srgb`,Lp=7680,Rp=35044,zp=2e3;function Bp(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Vp(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Hp(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Up(){let e=Hp(`canvas`);return e.style.display=`block`,e}var Wp={},Gp=null;function Kp(...e){let t=`THREE.`+e.shift();Gp?Gp(`log`,t,...e):console.log(t,...e)}function qp(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function W(...e){e=qp(e);let t=`THREE.`+e.shift();if(Gp)Gp(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function G(...e){e=qp(e);let t=`THREE.`+e.shift();if(Gp)Gp(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Jp(...e){let t=e.join(` `);t in Wp||(Wp[t]=!0,W(...e))}function Yp(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Xp={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Zp=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+Qp[e>>16&255]+Qp[e>>24&255]+`-`+Qp[t&255]+Qp[t>>8&255]+`-`+Qp[t>>16&15|64]+Qp[t>>24&255]+`-`+Qp[n&63|128]+Qp[n>>8&255]+`-`+Qp[n>>16&255]+Qp[n>>24&255]+Qp[r&255]+Qp[r>>8&255]+Qp[r>>16&255]+Qp[r>>24&255]).toLowerCase()}function rm(e,t,n){return Math.max(t,Math.min(n,e))}function im(e,t){return(e%t+t)%t}function am(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function om(e,t,n){return e===t?0:(n-e)/(t-e)}function sm(e,t,n){return(1-n)*e+n*t}function cm(e,t,n,r){return sm(e,t,1-Math.exp(-n*r))}function lm(e,t=1){return t-Math.abs(im(e,t*2)-t)}function um(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function dm(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function fm(e,t){return e+Math.floor(Math.random()*(t-e+1))}function pm(e,t){return e+Math.random()*(t-e)}function mm(e){return e*(.5-Math.random())}function hm(e){e!==void 0&&($p=e);let t=$p+=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 gm(e){return e*em}function _m(e){return e*tm}function vm(e){return(e&e-1)==0&&e!==0}function ym(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function bm(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function xm(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:W(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Sm(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function Cm(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var wm={DEG2RAD:em,RAD2DEG:tm,generateUUID:nm,clamp:rm,euclideanModulo:im,mapLinear:am,inverseLerp:om,lerp:sm,damp:cm,pingpong:lm,smoothstep:um,smootherstep:dm,randInt:fm,randFloat:pm,randFloatSpread:mm,seededRandom:hm,degToRad:gm,radToDeg:_m,isPowerOfTwo:vm,ceilPowerOfTwo:ym,floorPowerOfTwo:bm,setQuaternionFromProperEuler:xm,normalize:Cm,denormalize:Sm},K=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=rm(this.x,e.x,t.x),this.y=rm(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=rm(this.x,e,t),this.y=rm(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(rm(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rm(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Tm=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:W(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(rm(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},q=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Dm.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Dm.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=rm(this.x,e.x,t.x),this.y=rm(this.y,e.y,t.y),this.z=rm(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=rm(this.x,e,t),this.y=rm(this.y,e,t),this.z=rm(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(rm(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Em.copy(this).projectOnVector(e),this.sub(Em)}reflect(e){return this.sub(Em.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(rm(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Em=new q,Dm=new Tm,J=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Om.makeScale(e,t)),this}rotate(e){return this.premultiply(Om.makeRotation(-e)),this}translate(e,t){return this.premultiply(Om.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Om=new J,km=new J().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Am=new J().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jm(){let e={enabled:!0,workingColorSpace:Pp,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Mm(e.r),e.g=Mm(e.g),e.b=Mm(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Nm(e.r),e.g=Nm(e.g),e.b=Nm(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Fp:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Jp(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Jp(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Pp]:{primaries:t,whitePoint:r,transfer:Fp,toXYZ:km,fromXYZ:Am,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Np},outputColorSpaceConfig:{drawingBufferColorSpace:Np}},[Np]:{primaries:t,whitePoint:r,transfer:Ip,toXYZ:km,fromXYZ:Am,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Np}}}),e}var Y=jm();function Mm(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Nm(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Pm,Fm=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Pm===void 0&&(Pm=Hp(`canvas`)),Pm.width=e.width,Pm.height=e.height;let t=Pm.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Pm}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Hp(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Bm).x}get height(){return this.source.getSize(Bm).y}get depth(){return this.source.getSize(Bm).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){W(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){W(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case uf:e.x-=Math.floor(e.x);break;case df:e.x=e.x<0?0:1;break;case ff:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case uf:e.y-=Math.floor(e.y);break;case df:e.y=e.y<0?0:1;break;case ff:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Vm.DEFAULT_IMAGE=null,Vm.DEFAULT_MAPPING=300,Vm.DEFAULT_ANISOTROPY=1;var Hm=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xh)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new bh;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ch={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wh={h:0,s:0,l:0},Th={h:0,s:0,l:0};function Eh(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Z=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Np){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Y.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Y.workingColorSpace){return this.r=e,this.g=t,this.b=n,Y.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Y.workingColorSpace){if(e=im(e,1),t=rm(t,0,1),n=rm(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Eh(i,r,e+1/3),this.g=Eh(i,r,e),this.b=Eh(i,r,e-1/3)}return Y.colorSpaceToWorking(this,r),this}setStyle(e,t=Np){function n(t){t!==void 0&&parseFloat(t)<1&&W(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:W(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);W(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Np){let n=Ch[e.toLowerCase()];return n===void 0?W(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Mm(e.r),this.g=Mm(e.g),this.b=Mm(e.b),this}copyLinearToSRGB(e){return this.r=Nm(e.r),this.g=Nm(e.g),this.b=Nm(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Np){return Y.workingToColorSpace(Dh.copy(this),e),Math.round(rm(Dh.r*255,0,255))*65536+Math.round(rm(Dh.g*255,0,255))*256+Math.round(rm(Dh.b*255,0,255))}getHexString(e=Np){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Y.workingColorSpace){Y.workingToColorSpace(Dh.copy(this),t);let n=Dh.r,r=Dh.g,i=Dh.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Ah=new q,jh=new q,Mh=new q,Nh=new q,Ph=new q,Fh=new q,Ih=new q,Lh=new q,Rh=new q,zh=new q,Bh=new Hm,Vh=new Hm,Hh=new Hm,Uh=class e{constructor(e=new q,t=new q,n=new q){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ah.subVectors(e,t),r.cross(Ah);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Ah.subVectors(r,t),jh.subVectors(n,t),Mh.subVectors(e,t);let a=Ah.dot(Ah),o=Ah.dot(jh),s=Ah.dot(Mh),c=jh.dot(jh),l=jh.dot(Mh),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Nh)===null?!1:Nh.x>=0&&Nh.y>=0&&Nh.x+Nh.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Nh)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Nh.x),s.addScaledVector(a,Nh.y),s.addScaledVector(o,Nh.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Bh.setScalar(0),Vh.setScalar(0),Hh.setScalar(0),Bh.fromBufferAttribute(e,t),Vh.fromBufferAttribute(e,n),Hh.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Bh,i.x),a.addScaledVector(Vh,i.y),a.addScaledVector(Hh,i.z),a}static isFrontFacing(e,t,n,r){return Ah.subVectors(n,t),jh.subVectors(e,t),Ah.cross(jh).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ah.subVectors(this.c,this.b),jh.subVectors(this.a,this.b),Ah.cross(jh).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Ph.subVectors(r,n),Fh.subVectors(i,n),Lh.subVectors(e,n);let s=Ph.dot(Lh),c=Fh.dot(Lh);if(s<=0&&c<=0)return t.copy(n);Rh.subVectors(e,r);let l=Ph.dot(Rh),u=Fh.dot(Rh);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Ph,a);zh.subVectors(e,i);let f=Ph.dot(zh),p=Fh.dot(zh);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Fh,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ih.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ih,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Ph,a).addScaledVector(Fh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Wh=class{constructor(e=new q(1/0,1/0,1/0),t=new q(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kh),Kh.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eg),tg.subVectors(this.max,eg),Jh.subVectors(e.a,eg),Yh.subVectors(e.b,eg),Xh.subVectors(e.c,eg),Zh.subVectors(Yh,Jh),Qh.subVectors(Xh,Yh),$h.subVectors(Jh,Xh);let t=[0,-Zh.z,Zh.y,0,-Qh.z,Qh.y,0,-$h.z,$h.y,Zh.z,0,-Zh.x,Qh.z,0,-Qh.x,$h.z,0,-$h.x,-Zh.y,Zh.x,0,-Qh.y,Qh.x,0,-$h.y,$h.x,0];return!ig(t,Jh,Yh,Xh,tg)||(t=[1,0,0,0,1,0,0,0,1],!ig(t,Jh,Yh,Xh,tg))?!1:(ng.crossVectors(Zh,Qh),t=[ng.x,ng.y,ng.z],ig(t,Jh,Yh,Xh,tg))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kh).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Gh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gh),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Gh=[new q,new q,new q,new q,new q,new q,new q,new q],Kh=new q,qh=new Wh,Jh=new q,Yh=new q,Xh=new q,Zh=new q,Qh=new q,$h=new q,eg=new q,tg=new q,ng=new q,rg=new q;function ig(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){rg.fromArray(e,a);let o=i.x*Math.abs(rg.x)+i.y*Math.abs(rg.y)+i.z*Math.abs(rg.z),s=t.dot(rg),c=n.dot(rg),l=r.dot(rg);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var ag=new q,og=new K,sg=0,cg=class extends Zp{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:sg++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Rp,this.updateRanges=[],this.gpuType=Tf,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;pg.subVectors(e,this.center);let t=pg.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(pg,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(mg.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(pg.copy(e.center).add(mg)),this.expandByPoint(pg.copy(e.center).sub(mg))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},gg=0,_g=new X,vg=new yh,yg=new q,bg=new Wh,xg=new Wh,Sg=new q,Cg=class e extends Zp{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gg++}),this.uuid=nm(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bp(e)?ug:lg)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new J().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _g.makeRotationFromQuaternion(e),this.applyMatrix4(_g),this}rotateX(e){return _g.makeRotationX(e),this.applyMatrix4(_g),this}rotateY(e){return _g.makeRotationY(e),this.applyMatrix4(_g),this}rotateZ(e){return _g.makeRotationZ(e),this.applyMatrix4(_g),this}translate(e,t,n){return _g.makeTranslation(e,t,n),this.applyMatrix4(_g),this}scale(e,t,n){return _g.makeScale(e,t,n),this.applyMatrix4(_g),this}lookAt(e){return vg.lookAt(e),vg.updateMatrix(),this.applyMatrix4(vg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(yg).negate(),this.translate(yg.x,yg.y,yg.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&W(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wh);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){G(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){W(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){W(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Eg=new q,Dg=new q,Og=new q,kg=new q,Ag=new q,jg=new q,Mg=new q,Ng=class{constructor(e=new q,t=new q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Eg)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Eg.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Eg.copy(this.origin).addScaledVector(this.direction,t),Eg.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Dg.copy(e).add(t).multiplyScalar(.5),Og.copy(t).sub(e).normalize(),kg.copy(this.origin).sub(Dg);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Og),o=kg.dot(this.direction),s=-kg.dot(Og),c=kg.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Dg).addScaledVector(Og,d),f}intersectSphere(e,t){Eg.subVectors(e.center,this.origin);let n=Eg.dot(this.direction),r=Eg.dot(Eg)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Eg)!==null}intersectTriangle(e,t,n,r,i){Ag.subVectors(t,e),jg.subVectors(n,e),Mg.crossVectors(Ag,jg);let a=this.direction.dot(Mg),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;kg.subVectors(this.origin,e);let s=o*this.direction.dot(jg.crossVectors(kg,jg));if(s<0)return null;let c=o*this.direction.dot(Ag.cross(kg));if(c<0||s+c>a)return null;let l=-o*kg.dot(Mg);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Pg=class extends Tg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Z(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nh,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Fg=new X,Ig=new Ng,Lg=new hg,Rg=new q,zg=new q,Bg=new q,Vg=new q,Hg=new q,Ug=new q,Wg=new q,Gg=new q,Kg=class extends yh{constructor(e=new Cg,t=new Pg){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Fg.copy(i).invert(),Ig.copy(e.ray).applyMatrix4(Fg),!(n.boundingBox!==null&&Ig.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ig)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:Gg.clone(),object:e}}function Jg(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,zg),e.getVertexPosition(c,Bg),e.getVertexPosition(l,Vg);let u=qg(e,t,n,r,zg,Bg,Vg,Wg);if(u){let e=new q;Uh.getBarycoord(Wg,zg,Bg,Vg,e),i&&(u.uv=Uh.getInterpolatedAttribute(i,s,c,l,e,new K)),a&&(u.uv1=Uh.getInterpolatedAttribute(a,s,c,l,e,new K)),o&&(u.normal=Uh.getInterpolatedAttribute(o,s,c,l,e,new q),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new q,materialIndex:0};Uh.getNormal(zg,Bg,Vg,t.normal),u.face=t,u.barycoord=e}return u}var Yg=new Hm,Xg=new Hm,Zg=new Hm,Qg=new Hm,$g=new X,e_=new q,t_=new hg,n_=new X,r_=new Ng,i_=class extends Kg{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=lf,this.bindMatrix=new X,this.bindMatrixInverse=new X,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Wh),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||f_.getNormalMatrix(e),r=this.coplanarPoint(u_).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},m_=new hg,h_=new K(.5,.5),g_=new q,__=class{constructor(e=new p_,t=new p_,n=new p_,r=new p_,i=new p_,a=new p_){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=zp,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),m_.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),m_.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(m_)}intersectsSprite(e){return m_.center.set(0,0,0),m_.radius=.7071067811865476+h_.distanceTo(e.center),m_.applyMatrix4(e.matrixWorld),this.intersectsSphere(m_)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,g_.y=r.normal.y>0?e.max.y:e.min.y,g_.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(g_)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},v_=class extends Tg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Z(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},y_=new q,b_=new q,x_=new X,S_=new Ng,C_=new hg,w_=new q,T_=new q,E_=class extends yh{constructor(e=new Cg,t=new v_){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;w_.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(w_);if(!(ct.far))return{distance:c,point:T_.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var O_=new q,k_=new q,A_=class extends E_{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new dg(u,3)),this.setAttribute(`normal`,new dg(d,3)),this.setAttribute(`uv`,new dg(f,2));function _(){let a=new q,_=new q,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new K,m=new q,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return B_(a,o,n,s,c,l,0),o}function R_(e,t,n,r,i){let a;if(i===hv(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=fv(i/r|0,e[i],e[i+1],a);return a&&iv(a,a.next)&&(pv(a),a=a.next),a}function z_(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(iv(n,n.next)||rv(n.prev,n,n.next)===0)){if(pv(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function B_(e,t,n,r,i,a,o){if(!e)return;!o&&a&&X_(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?H_(e,r,i,a):V_(e)){t.push(c.i,e.i,l.i),pv(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=U_(z_(e),t),B_(e,t,n,r,i,a,2)):o===2&&W_(e,t,n,r,i,a):B_(z_(e),t,n,r,i,a,1);break}}}function V_(e){let t=e.prev,n=e,r=e.next;if(rv(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&tv(i,s,a,c,o,l,m.x,m.y)&&rv(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function H_(e,t,n,r){let i=e.prev,a=e,o=e.next;if(rv(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Q_(p,m,t,n,r),v=Q_(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&tv(s,u,c,d,l,f,y.x,y.y)&&rv(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&tv(s,u,c,d,l,f,b.x,b.y)&&rv(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&tv(s,u,c,d,l,f,y.x,y.y)&&rv(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&tv(s,u,c,d,l,f,b.x,b.y)&&rv(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function U_(e,t){let n=e;do{let r=n.prev,i=n.next.next;!iv(r,i)&&av(r,n,n.next,i)&&lv(r,i)&&lv(i,r)&&(t.push(r.i,n.i,i.i),pv(n),pv(n.next),n=e=i),n=n.next}while(n!==e);return z_(n)}function W_(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&nv(o,e)){let s=dv(o,e);o=z_(o,o.next),s=z_(s,s.next),B_(o,t,n,r,i,a,0),B_(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function G_(e,t,n,r){let i=[];for(let n=0,a=t.length;n=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x=n.x&&n.x>=c&&r!==n.x&&ev(io.x||n.x===o.x&&Y_(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Y_(e,t){return rv(e.prev,e,t.prev)<0&&rv(t.next,e,e.next)<0}function X_(e,t,n,r){let i=e;do i.z===0&&(i.z=Q_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Z_(i)}function Z_(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function Q_(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function $_(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function tv(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&ev(e,t,n,r,i,a,o,s)}function nv(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!cv(e,t)&&(lv(e,t)&&lv(t,e)&&uv(e,t)&&(rv(e.prev,e,t.prev)||rv(e,t.prev,t))||iv(e,t)&&rv(e.prev,e,e.next)>0&&rv(t.prev,t,t.next)>0)}function rv(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function iv(e,t){return e.x===t.x&&e.y===t.y}function av(e,t,n,r){let i=sv(rv(e,t,n)),a=sv(rv(e,t,r)),o=sv(rv(n,r,e)),s=sv(rv(n,r,t));return!!(i!==a&&o!==s||i===0&&ov(e,n,t)||a===0&&ov(e,r,t)||o===0&&ov(n,e,r)||s===0&&ov(n,t,r))}function ov(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sv(e){return e>0?1:e<0?-1:0}function cv(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&av(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function lv(e,t){return rv(e.prev,e,e.next)<0?rv(e,t,e.next)>=0&&rv(e,e.prev,t)>=0:rv(e,t,e.prev)<0||rv(e,e.next,t)<0}function uv(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function dv(e,t){let n=mv(e.i,e.x,e.y),r=mv(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function fv(e,t,n,r){let i=mv(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function pv(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function mv(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function hv(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function yv(e,t){for(let n=0;n0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},jv=class extends Av{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Mv=class extends Tg{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new Z(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nh,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Nv=class extends Tg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new Z(16777215),this.specular=new Z(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nh,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Pv=class extends Tg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new Z(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nh,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Fv=class extends Tg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=Mp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Iv=class extends Tg{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Lv(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Rv(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function zv(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Bv(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}var Vv=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(G(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(G(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){G(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){G(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Vp(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){G(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Ep,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Kv.prototype.ValueTypeName=``,Kv.prototype.TimeBufferType=Float32Array,Kv.prototype.ValueBufferType=Float32Array,Kv.prototype.DefaultInterpolation=Tp;var qv=class extends Kv{constructor(e,t,n){super(e,t,n)}};qv.prototype.ValueTypeName=`bool`,qv.prototype.ValueBufferType=Array,qv.prototype.DefaultInterpolation=wp,qv.prototype.InterpolantFactoryMethodLinear=void 0,qv.prototype.InterpolantFactoryMethodSmooth=void 0;var Jv=class extends Kv{constructor(e,t,n,r){super(e,t,n,r)}};Jv.prototype.ValueTypeName=`color`;var Yv=class extends Kv{constructor(e,t,n,r){super(e,t,n,r)}};Yv.prototype.ValueTypeName=`number`;var Xv=class extends Vv{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Tm.slerpFlat(i,0,a,c-o,a,c,s);return i}},Zv=class extends Kv{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Xv(this.times,this.values,this.getValueSize(),e)}};Zv.prototype.ValueTypeName=`quaternion`,Zv.prototype.InterpolantFactoryMethodSmooth=void 0;var Qv=class extends Kv{constructor(e,t,n){super(e,t,n)}};Qv.prototype.ValueTypeName=`string`,Qv.prototype.ValueBufferType=Array,Qv.prototype.DefaultInterpolation=wp,Qv.prototype.InterpolantFactoryMethodLinear=void 0,Qv.prototype.InterpolantFactoryMethodSmooth=void 0;var $v=class extends Kv{constructor(e,t,n,r){super(e,t,n,r)}};$v.prototype.ValueTypeName=`vector`;var ey=class{constructor(e=``,t=-1,n=[],r=jp){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=nm(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(ny(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(Kv.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(W(`AnimationClip: parseAnimation() is deprecated and will be removed with r185`),!e)return G(`AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];Bv(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e{t&&t(i),this.manager.itemEnd(e)},0);return}if(cy[e]!==void 0){cy[e].push({onLoad:t,onProgress:n,onError:r});return}cy[e]=[],cy[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&W(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=cy[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{e.error(t)})}}});return new Response(c)}else throw new ly(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{ry.add(`file:${e}`,t);let n=cy[e];delete cy[e];for(let e=0,r=n.length;e{let n=cy[e];if(n===void 0)throw this.manager.itemError(e),t;delete cy[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},dy=new WeakMap,fy=class extends sy{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=ry.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=dy.get(a);e===void 0&&(e=[],dy.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=Hp(`img`);function s(){l(),t&&t(this);let n=dy.get(this)||[];for(let e=0;ee.start-t.start);let t=0;for(let e=1;e 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,envmap_fragment:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,envmap_vertex:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,skinning_vertex:`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,skinnormal_vertex:`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,distance_vert:`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},$={common:{diffuse:{value:new Z(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new J},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new J}},envmap:{envMap:{value:null},envMapRotation:{value:new J},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new J}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new J}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new J},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new J},normalScale:{value:new K(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new J},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new J}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new J}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new J}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Z(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new q},probesMax:{value:new q},probesResolution:{value:new q}},points:{diffuse:{value:new Z(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0},uvTransform:{value:new J}},sprite:{diffuse:{value:new Z(16777215)},opacity:{value:1},center:{value:new K(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new J},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0}}},cb={basic:{uniforms:Cv([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.fog]),vertexShader:Q.meshbasic_vert,fragmentShader:Q.meshbasic_frag},lambert:{uniforms:Cv([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new Z(0)},envMapIntensity:{value:1}}]),vertexShader:Q.meshlambert_vert,fragmentShader:Q.meshlambert_frag},phong:{uniforms:Cv([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new Z(0)},specular:{value:new Z(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Q.meshphong_vert,fragmentShader:Q.meshphong_frag},standard:{uniforms:Cv([$.common,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.roughnessmap,$.metalnessmap,$.fog,$.lights,{emissive:{value:new Z(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Q.meshphysical_vert,fragmentShader:Q.meshphysical_frag},toon:{uniforms:Cv([$.common,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.gradientmap,$.fog,$.lights,{emissive:{value:new Z(0)}}]),vertexShader:Q.meshtoon_vert,fragmentShader:Q.meshtoon_frag},matcap:{uniforms:Cv([$.common,$.bumpmap,$.normalmap,$.displacementmap,$.fog,{matcap:{value:null}}]),vertexShader:Q.meshmatcap_vert,fragmentShader:Q.meshmatcap_frag},points:{uniforms:Cv([$.points,$.fog]),vertexShader:Q.points_vert,fragmentShader:Q.points_frag},dashed:{uniforms:Cv([$.common,$.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Q.linedashed_vert,fragmentShader:Q.linedashed_frag},depth:{uniforms:Cv([$.common,$.displacementmap]),vertexShader:Q.depth_vert,fragmentShader:Q.depth_frag},normal:{uniforms:Cv([$.common,$.bumpmap,$.normalmap,$.displacementmap,{opacity:{value:1}}]),vertexShader:Q.meshnormal_vert,fragmentShader:Q.meshnormal_frag},sprite:{uniforms:Cv([$.sprite,$.fog]),vertexShader:Q.sprite_vert,fragmentShader:Q.sprite_frag},background:{uniforms:{uvTransform:{value:new J},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Q.background_vert,fragmentShader:Q.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new J}},vertexShader:Q.backgroundCube_vert,fragmentShader:Q.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Q.cube_vert,fragmentShader:Q.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Q.equirect_vert,fragmentShader:Q.equirect_frag},distance:{uniforms:Cv([$.common,$.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Q.distance_vert,fragmentShader:Q.distance_frag},shadow:{uniforms:Cv([$.lights,$.fog,{color:{value:new Z(0)},opacity:{value:1}}]),vertexShader:Q.shadow_vert,fragmentShader:Q.shadow_frag}};cb.physical={uniforms:Cv([cb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new J},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new J},clearcoatNormalScale:{value:new K(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new J},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new J},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new J},sheen:{value:0},sheenColor:{value:new Z(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new J},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new J},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new J},transmissionSamplerSize:{value:new K},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new J},attenuationDistance:{value:0},attenuationColor:{value:new Z(0)},specularColor:{value:new Z(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new J},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new J},anisotropyVector:{value:new K},anisotropyMap:{value:null},anisotropyMapTransform:{value:new J}}]),vertexShader:Q.meshphysical_vert,fragmentShader:Q.meshphysical_frag};var lb={r:0,b:0,g:0},ub=new X,db=new J;db.set(-1,0,0,0,1,0,0,0,1);function fb(e,t,n,r,i,a){let o=new Z(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new Kg(new F_(1,1,1),new Av({name:`BackgroundCubeMaterial`,uniforms:Sv(cb.backgroundCube.uniforms),vertexShader:cb.backgroundCube.vertexShader,fragmentShader:cb.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(ub.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(db),l.material.toneMapped=Y.getTransfer(i.colorSpace)!==Ip,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new Kg(new bv(2,2),new Av({name:`BackgroundMaterial`,uniforms:Sv(cb.background.uniforms),vertexShader:cb.background.vertexShader,fragmentShader:cb.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=Y.getTransfer(i.colorSpace)!==Ip,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(lb,Ev(e)),n.buffers.color.setClear(lb.r,lb.g,lb.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function pb(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(W(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&W(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function gb(e){let t=this,n=null,r=0,i=!1,a=!1,o=new p_,s=new J,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Fb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Pb(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Fb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Pb());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;jb(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,xb)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-_b?n-d+_b:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,jb(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,xb),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,jb(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,xb)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&G(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*yb-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):yb;m>yb&&W(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${yb}`);let h=[],g=0;for(let e=0;e_-_b?r-_+_b:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,xb)}};function kb(e){let t=[],n=[],r=[],i=e,a=e-_b+1+vb.length;for(let o=0;oe-_b?s=vb[o-e+_b-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Cg;h.setAttribute(`position`,new cg(f,3)),h.setAttribute(`uv`,new cg(p,2)),h.setAttribute(`faceIndex`,new cg(m,1)),r.push(new Kg(h,null)),i>_b&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function Ab(e,t,n){let r=new Wm(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function jb(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Mb(e,t,n){return new Av({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:bb,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ib(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1})}function Nb(e,t,n){let r=new Float32Array(yb),i=new q(0,1,0);return new Av({name:`SphericalGaussianBlur`,defines:{n:yb,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ib(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function Pb(){return new Av({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:Ib(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function Fb(){return new Av({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ib(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function Ib(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}var Lb=class extends Wm{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new j_(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new F_(5,5,5),i=new Av({name:`CubemapFromEquirect`,uniforms:Sv(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Kg(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=gf),new By(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function Rb(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new Lb(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new Ob(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new Ob(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function zb(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&Jp(`WebGLRenderer: `+e+` extension not supported.`),t}}}function Bb(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?ug:lg)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Gm(h,p,m,u);g.type=Tf,g.needsUpdate=!0;let _=f*4;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),l=new Kg(s,c),u=new Ny(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,g=[],_=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&g[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e0)return e;let i=t*n,a=Qb[i];if(a===void 0&&(a=new Float32Array(i),Qb[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function ix(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function eS(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var tS=37297,nS=0;function rS(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}var iS=new J;function aS(e){Y._getMatrix(iS,Y.workingColorSpace,e);let t=`mat3( ${iS.elements.map(e=>e.toFixed(4))} )`;switch(Y.getTransfer(e)){case Fp:return[t,`LinearTransferOETF`];case Ip:return[t,`sRGBTransferOETF`];default:return W(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function oS(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+rS(e.getShaderSource(t),r)}else return i}function sS(e,t){let n=aS(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var cS={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function lS(e,t){let n=cS[t];return n===void 0?(W(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var uS=new q;function dS(){return Y.getLuminanceCoefficients(uS),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${uS.x.toFixed(4)}, ${uS.y.toFixed(4)}, ${uS.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function fS(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(hS).join(` +`)}function pS(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function mS(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function yS(e){return e.replace(vS,xS)}var bS=new Map;function xS(e,t){let n=Q[t];if(n===void 0){let e=bS.get(t);if(e!==void 0)n=Q[e],W(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return yS(n)}var SS=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function CS(e){return e.replace(SS,wS)}function wS(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(hS).join(` +`),_.length>0&&(_+=` +`)):(g=[TS(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(hS).join(` +`),_=[TS(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Q.tonemapping_pars_fragment,n.toneMapping===0?``:lS(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Q.colorspace_pars_fragment,sS(`linearToOutputTexel`,n.outputColorSpace),dS(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(hS).join(` +`)),o=yS(o),o=gS(o,n),o=_S(o,n),s=yS(s),s=gS(s,n),s=_S(s,n),o=CS(o),s=CS(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=eS(i,i.VERTEX_SHADER,y),S=eS(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=oS(i,x,`vertex`),n=oS(i,S,`fragment`);G(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+o+` +`+e+` +`+n)}else o===``?(s===``||c===``)&&(u=!1):W(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new $x(i,h),T=mS(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,tS)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=nS++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var IS=0,LS=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new RS(e),t.set(e,n)),n}},RS=class{constructor(e){this.id=IS++,this.code=e,this.usedTimes=0}};function zS(e){return e===1030||e===37490||e===36285}function BS(e,t,n,r,i,a){let o=new rh,s=new LS,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&W(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,ee,k;if(C){let e=cb[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),ee=s.getVertexShaderID(i),k=s.getFragmentShaderID(i);let te=e.getRenderTarget(),ne=e.state.buffers.depth.getReversed(),re=h.isInstancedMesh===!0,ie=h.isBatchedMesh===!0,A=!!i.map,j=!!i.matcap,ae=!!x,oe=!!i.aoMap,se=!!i.lightMap,ce=!!i.bumpMap,le=!!i.normalMap,ue=!!i.displacementMap,de=!!i.emissiveMap,fe=!!i.metalnessMap,pe=!!i.roughnessMap,me=i.anisotropy>0,he=i.clearcoat>0,ge=i.dispersion>0,_e=i.iridescence>0,ve=i.sheen>0,ye=i.transmission>0,be=me&&!!i.anisotropyMap,xe=he&&!!i.clearcoatMap,Se=he&&!!i.clearcoatNormalMap,M=he&&!!i.clearcoatRoughnessMap,Ce=_e&&!!i.iridescenceMap,we=_e&&!!i.iridescenceThicknessMap,Te=ve&&!!i.sheenColorMap,N=ve&&!!i.sheenRoughnessMap,Ee=!!i.specularMap,P=!!i.specularColorMap,De=!!i.specularIntensityMap,Oe=ye&&!!i.transmissionMap,ke=ye&&!!i.thicknessMap,Ae=!!i.gradientMap,je=!!i.alphaMap,Me=i.alphaTest>0,Ne=!!i.alphaHash,Pe=!!i.extensions,Fe=0;i.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Fe=e.toneMapping);let Ie={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:ee,customFragmentShaderID:k,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:ie,batchingColor:ie&&h._colorsTexture!==null,instancing:re,instancingColor:re&&h.instanceColor!==null,instancingMorph:re&&h.morphTexture!==null,outputColorSpace:te===null?e.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:Y.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:A,matcap:j,envMap:ae,envMapMode:ae&&x.mapping,envMapCubeUVHeight:S,aoMap:oe,lightMap:se,bumpMap:ce,normalMap:le,displacementMap:ue,emissiveMap:de,normalMapObjectSpace:le&&i.normalMapType===1,normalMapTangentSpace:le&&i.normalMapType===0,packedNormalMap:le&&i.normalMapType===0&&zS(i.normalMap.format),metalnessMap:fe,roughnessMap:pe,anisotropy:me,anisotropyMap:be,clearcoat:he,clearcoatMap:xe,clearcoatNormalMap:Se,clearcoatRoughnessMap:M,dispersion:ge,iridescence:_e,iridescenceMap:Ce,iridescenceThicknessMap:we,sheen:ve,sheenColorMap:Te,sheenRoughnessMap:N,specularMap:Ee,specularColorMap:P,specularIntensityMap:De,transmission:ye,transmissionMap:Oe,thicknessMap:ke,gradientMap:Ae,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:je,alphaTest:Me,alphaHash:Ne,combine:i.combine,mapUv:A&&m(i.map.channel),aoMapUv:oe&&m(i.aoMap.channel),lightMapUv:se&&m(i.lightMap.channel),bumpMapUv:ce&&m(i.bumpMap.channel),normalMapUv:le&&m(i.normalMap.channel),displacementMapUv:ue&&m(i.displacementMap.channel),emissiveMapUv:de&&m(i.emissiveMap.channel),metalnessMapUv:fe&&m(i.metalnessMap.channel),roughnessMapUv:pe&&m(i.roughnessMap.channel),anisotropyMapUv:be&&m(i.anisotropyMap.channel),clearcoatMapUv:xe&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:Se&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:M&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:Ce&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:we&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:Te&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:N&&m(i.sheenRoughnessMap.channel),specularMapUv:Ee&&m(i.specularMap.channel),specularColorMapUv:P&&m(i.specularColorMap.channel),specularIntensityMapUv:De&&m(i.specularIntensityMap.channel),transmissionMapUv:Oe&&m(i.transmissionMap.channel),thicknessMapUv:ke&&m(i.thicknessMap.channel),alphaMapUv:je&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(le||me),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(A||je),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&le===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ne,skinning:h.isSkinnedMesh===!0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Fe,decodeVideoTexture:A&&i.map.isVideoTexture===!0&&Y.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:de&&i.emissiveMap.isVideoTexture===!0&&Y.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Pe&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Pe&&i.extensions.multiDraw===!0||ie)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ie.vertexUv1s=c.has(1),Ie.vertexUv2s=c.has(2),Ie.vertexUv3s=c.has(3),c.clear(),Ie}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=cb[t];n=Dv.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new FS(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function VS(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function HS(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function US(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function WS(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||HS),r.length>1&&r.sort(t||US),i.length>1&&i.sort(t||US)}function d(){for(let n=t,r=e.length;n=r.length?(i=new WS,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function KS(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new q,color:new Z};break;case`SpotLight`:n={position:new q,direction:new q,color:new Z,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new q,color:new Z,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new q,skyColor:new Z,groundColor:new Z};break;case`RectAreaLight`:n={color:new Z,position:new q,halfWidth:new q,halfHeight:new q};break}return e[t.id]=n,n}}}function qS(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var JS=0;function YS(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function XS(e){let t=new KS,n=qS(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new q);let i=new q,a=new X,o=new X;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(YS);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=$.LTC_FLOAT_1,r.rectAreaLTC2=$.LTC_FLOAT_2):(r.rectAreaLTC1=$.LTC_HALF_1,r.rectAreaLTC2=$.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=JS++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new ZS(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var $S=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,eC=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,tC=[new q(1,0,0),new q(-1,0,0),new q(0,1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1)],nC=[new q(0,-1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1),new q(0,-1,0),new q(0,-1,0)],rC=new X,iC=new q,aC=new q;function oC(e,t,n){let r=new __,i=new K,a=new K,o=new Hm,s=new Fv,c=new Iv,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Av({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new K},radius:{value:4}},vertexShader:$S,fragmentShader:eC}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Cg;m.setAttribute(`position`,new cg(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Kg(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(W(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){W(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Wm(i.x,i.y,{format:zf,type:Ef,minFilter:gf,magFilter:gf,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new M_(i.x,i.y,Tf),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Ff,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=pf,d.map.depthTexture.magFilter=pf}else l.isPointLight?(d.map=new Lb(i.x),d.map.depthTexture=new N_(i.x,wf)):(d.map=new Wm(i.x,i.y),d.map.depthTexture=new M_(i.x,i.y,wf)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Ff,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=gf,d.map.depthTexture.magFilter=gf):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=pf,d.map.depthTexture.magFilter=pf);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(ie=parseFloat(/^WebGL (\d)/.exec(A)[1]),re=ie>=1);let j=null,ae={},oe=e.getParameter(e.SCISSOR_BOX),se=e.getParameter(e.VIEWPORT),ce=new Hm().fromArray(oe),le=new Hm().fromArray(se);function ue(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new K,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):Hp(`canvas`)}function g(e,t,n){let r=1,i=P(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),W(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&W(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];W(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||W(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?Fp:Y.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,W(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function D(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&W(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function re(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function ie(t,i){let a=r.get(t);if(t.isVideoTexture&&N(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)W(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)W(`WebGLRenderer: Texture marked for update but image is incomplete`);else{pe(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function A(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){pe(a,t,i);return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function j(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){pe(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ae(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){me(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let oe={[uf]:e.REPEAT,[df]:e.CLAMP_TO_EDGE,[ff]:e.MIRRORED_REPEAT},se={[pf]:e.NEAREST,[mf]:e.NEAREST_MIPMAP_NEAREST,[hf]:e.NEAREST_MIPMAP_LINEAR,[gf]:e.LINEAR,[_f]:e.LINEAR_MIPMAP_NEAREST,[vf]:e.LINEAR_MIPMAP_LINEAR},ce={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function le(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&W(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,oe[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,oe[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,oe[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,se[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,se[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ce[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function ue(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=re(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function de(e,t,n){return Math.floor(Math.floor(e/n)/t)}function fe(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=ib(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0);else W(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=ib(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w)if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}let r=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,r,i,a,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=P(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=P(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),Te(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,we(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ge(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;Te(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,we(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,we(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)_e(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?_e(i.__webglFramebuffer[0],t,0):_e(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),ge(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),ge(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ye(t,n,i){let a=r.get(t);n!==void 0&&he(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&ve(t)}function be(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&Te(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(Te(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function N(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Ee(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Y.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&W(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):G(`WebGLTextures: Unsupported texture color space:`,n)),t}function P(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=ne,this.resetTextureUnits=ee,this.getTextureUnits=k,this.setTextureUnits=te,this.setTexture2D=ie,this.setTexture2DArray=A,this.setTexture3D=j,this.setTextureCube=ae,this.rebindTextures=ye,this.setupRenderTarget=be,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=Ce,this.setupDepthRenderbuffer=ve,this.setupFrameBufferTexture=he,this.useMultisampledRTT=Te,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function lC(e,t){function n(n,r=``){let i,a=Y.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var uC=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,dC=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,fC=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new P_(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Av({vertexShader:uC,fragmentShader:dC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kg(new bv(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pC=class extends Zp{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new fC,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new K,C=null,w=new Oy;w.viewport=new Hm;let T=new Oy;T.viewport=new Hm;let E=[w,T],D=new Vy,O=null,ee=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Sh,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Sh,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Sh,b[e]=t),t.getHandSpace()};function k(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function te(){r.removeEventListener(`select`,k),r.removeEventListener(`selectstart`,k),r.removeEventListener(`selectend`,k),r.removeEventListener(`squeeze`,k),r.removeEventListener(`squeezestart`,k),r.removeEventListener(`squeezeend`,k),r.removeEventListener(`end`,te),r.removeEventListener(`inputsourceschange`,ne);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let re=new q,ie=new q;function A(e,t,n){re.setFromMatrixPosition(t.matrixWorld),ie.setFromMatrixPosition(n.matrixWorld);let r=re.distanceTo(ie),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function j(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||ee!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,ee=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;j(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(mC.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(hC),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function _C(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?W(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):W(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var vC=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),yC=null;function bC(){return yC===null&&(yC=new o_(vC,16,16,zf,Ef),yC.name=`DFG_LUT`,yC.minFilter=gf,yC.magFilter=gf,yC.wrapS=df,yC.wrapT=df,yC.generateMipmaps=!1,yC.needsUpdate=!0),yC}var xC=class{constructor(e={}){let{canvas:t=Up(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=yf}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([Vf,Bf,Rf]),g=new Set([yf,wf,Sf,kf,Df,Of]),_=new Uint32Array(4),v=new Int32Array(4),y=new q,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null;this._outputColorSpace=Np;let O=0,ee=0,k=null,te=-1,ne=null,re=new Hm,ie=new Hm,A=null,j=new Z(0),ae=0,oe=t.width,se=t.height,ce=1,le=null,ue=null,de=new Hm(0,0,oe,se),fe=new Hm(0,0,oe,se),pe=!1,me=new __,he=!1,ge=!1,_e=new X,ve=new q,ye=new Hm,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},xe=!1;function Se(){return k===null?ce:1}let M=n;function Ce(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r184`),t.addEventListener(`webglcontextlost`,qe,!1),t.addEventListener(`webglcontextrestored`,Je,!1),t.addEventListener(`webglcontextcreationerror`,Ye,!1),M===null){let t=`webgl2`;if(M=Ce(t,e),M===null)throw Ce(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw G(`WebGLRenderer: `+e.message),e}let we,Te,N,Ee,P,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We;function Ge(){we=new zb(M),we.init(),He=new lC(M,we),Te=new hb(M,we,e,He),N=new sC(M,we),Te.reversedDepthBuffer&&d&&N.buffers.depth.setReversed(!0),Ee=new Hb(M),P=new VS,De=new cC(M,we,N,P,Te,He,Ee),Oe=new Rb(T),ke=new sb(M),Ue=new pb(M,ke),Ae=new Bb(M,ke,Ee,Ue),je=new Wb(M,Ae,ke,Ue,Ee),ze=new Ub(M,Te,De),Ie=new gb(P),Me=new BS(T,Oe,we,Te,Ue,Ie),Ne=new gC(T,P),Pe=new GS,Fe=new QS(we),Re=new fb(T,Oe,N,je,p,s),Le=new oC(T,je,Te),We=new _C(M,Ee,Te,N),Be=new mb(M,we,Ee),Ve=new Vb(M,we,Ee),Ee.programs=Me.programs,T.capabilities=Te,T.extensions=we,T.properties=P,T.renderLists=Pe,T.shadowMap=Le,T.state=N,T.info=Ee}Ge(),m!==1009&&(w=new Kb(m,t.width,t.height,r,i));let Ke=new pC(T,M);this.xr=Ke,this.getContext=function(){return M},this.getContextAttributes=function(){return M.getContextAttributes()},this.forceContextLoss=function(){let e=we.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=we.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return ce},this.setPixelRatio=function(e){e!==void 0&&(ce=e,this.setSize(oe,se,!1))},this.getSize=function(e){return e.set(oe,se)},this.setSize=function(e,n,r=!0){if(Ke.isPresenting){W(`WebGLRenderer: Can't change size while VR device is presenting.`);return}oe=e,se=n,t.width=Math.floor(e*ce),t.height=Math.floor(n*ce),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(oe*ce,se*ce).floor()},this.setDrawingBufferSize=function(e,n,r){oe=e,se=n,ce=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){G(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){P.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}we.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let et=null;function tt(e){et&&et(e)}function nt(){it.stop()}function rt(){it.start()}let it=new ob;it.setAnimationLoop(tt),typeof self<`u`&&it.setContext(self),this.setAnimationLoop=function(e){et=e,Ke.setAnimationLoop(e),e===null?it.stop():it.start()},Ke.addEventListener(`sessionstart`,nt),Ke.addEventListener(`sessionend`,rt),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){G(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ke.enabled===!0&&Ke.isPresenting===!0,r=w!==null&&(k===null||n)&&w.begin(T,k);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(t),t=Ke.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,k),x=Fe.get(e,C.length),x.init(t),x.state.textureUnits=De.getTextureUnits(),C.push(x),_e.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),me.setFromProjectionMatrix(_e,zp,t.reversedDepth),ge=this.localClippingEnabled,he=Ie.init(this.clippingPlanes,ge),b=Pe.get(e,S.length),b.init(),S.push(b),Ke.enabled===!0&&Ke.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&at(e,t,-1/0,T.sortObjects)}at(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(le,ue),xe=Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1,xe&&Re.addToRenderList(b,e),this.info.render.frame++,he===!0&&Ie.beginShadows();let i=x.state.shadowsArray;if(Le.render(i,e,t),he===!0&&Ie.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&st(n,r,e,t),xe&&Re.render(e),ot(b,e,t)}k!==null&&ee===0&&(De.updateMultisampleRenderTarget(k),De.updateRenderTargetMipmap(k)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Ue.resetDefaultState(),te=-1,ne=null,C.pop(),C.length>0?(x=C[C.length-1],De.setTextureUnits(x.state.textureUnits),he===!0&&Ie.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function at(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||me.intersectsSprite(e)){r&&ye.setFromMatrixPosition(e.matrixWorld).applyMatrix4(_e);let t=je.update(e),i=e.material;i.visible&&b.push(e,t,i,n,ye.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||me.intersectsObject(e))){let t=je.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ye.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ye.copy(e.boundingSphere.center)),ye.applyMatrix4(e.matrixWorld).applyMatrix4(_e)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&ct(i,t,n),a.length>0&&ct(a,t,n),o.length>0&&ct(o,t,n),N.buffers.depth.setTest(!0),N.buffers.depth.setMask(!0),N.buffers.color.setMask(!0),N.setPolygonOffset(!1)}function st(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=we.has(`EXT_color_buffer_half_float`)||we.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new Wm(1,1,{generateMipmaps:!0,type:e?Ef:yf,minFilter:vf,samples:Math.max(4,Te.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Y.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||re;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(j),ae=T.getClearAlpha(),ae<1&&T.setClearColor(16777215,.5),T.clear(),xe&&Re.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),he===!0&&Ie.setGlobalState(T.clippingPlanes,r),ct(e,n,r),De.updateMultisampleRenderTarget(a),De.updateRenderTargetMipmap(a),we.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function dt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=$x.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function ft(e,t){let n=P.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function pt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=P.get(r),y=x.state.lights;if(he===!0&&(ge===!0||e!==ne)){let t=e===ne&&r.id===te;Ie.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ie.numPlanes||v.numIntersection!==Ie.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=ut(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),ee=v.uniforms;if(N.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==te&&(te=r.id,w=!0),v.needsLights){let e=pt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ne!==e){N.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(M,`projectionMatrix`,e.projectionMatrix),O.setValue(M,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(M,ve.setFromMatrixPosition(e.matrixWorld)),Te.logarithmicDepthBuffer&&O.setValue(M,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(M,`isOrthographic`,e.isOrthographicCamera===!0),ne!==e&&(ne=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(M,`directionalShadowMap`,y.state.directionalShadowMap,De),y.state.spotShadowMap.length>0&&O.setValue(M,`spotShadowMap`,y.state.spotShadowMap,De),y.state.pointShadowMap.length>0&&O.setValue(M,`pointShadowMap`,y.state.pointShadowMap,De)),i.isSkinnedMesh){O.setOptional(M,i,`bindMatrix`),O.setOptional(M,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(M,`boneTexture`,e.boneTexture,De))}i.isBatchedMesh&&(O.setOptional(M,i,`batchingTexture`),O.setValue(M,`batchingTexture`,i._matricesTexture,De),O.setOptional(M,i,`batchingIdTexture`),O.setValue(M,`batchingIdTexture`,i._indirectTexture,De),O.setOptional(M,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(M,`batchingColorTexture`,i._colorsTexture,De));let re=n.morphAttributes;if((re.position!==void 0||re.normal!==void 0||re.color!==void 0)&&ze.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(M,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(ee.envMapIntensity.value=t.environmentIntensity),ee.dfgLUT!==void 0&&(ee.dfgLUT.value=bC()),w){if(O.setValue(M,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&ht(ee,E),a&&r.fog===!0&&Ne.refreshFogUniforms(ee,a),Ne.refreshMaterialUniforms(ee,r,ce,se,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;ee.probesSH.value=e.texture,ee.probesMin.value.copy(e.boundingBox.min),ee.probesMax.value.copy(e.boundingBox.max),ee.probesResolution.value.copy(e.resolution)}$x.upload(M,dt(v),ee,De)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&($x.upload(M,dt(v),ee,De),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(M,`center`,i.center),O.setValue(M,`modelViewMatrix`,i.modelViewMatrix),O.setValue(M,`normalMatrix`,i.normalMatrix),O.setValue(M,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&De.useMultisampledRTT(e)===!1?P.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,re.copy(e.viewport),ie.copy(e.scissor),A=e.scissorTest}else re.copy(de).multiplyScalar(ce).floor(),ie.copy(fe).multiplyScalar(ce).floor(),A=pe;if(n!==0&&(r=_t),N.bindFramebuffer(M.FRAMEBUFFER,r)&&N.drawBuffers(e,r),N.viewport(re),N.scissor(ie),N.setScissorTest(A),i){let r=P.get(e.texture);M.framebufferTexture2D(M.FRAMEBUFFER,M.COLOR_ATTACHMENT0,M.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&M.readBuffer(M.COLOR_ATTACHMENT0+s),!Te.textureFormatReadable(c)){G(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!Te.textureTypeReadable(l)){G(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&M.readPixels(t,n,r,i,He.convert(c),He.convert(l),a)}finally{let e=k===null?null:P.get(k).__webglFramebuffer;N.bindFramebuffer(M.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=P.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){N.bindFramebuffer(M.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&M.readBuffer(M.COLOR_ATTACHMENT0+s),!Te.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Te.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=M.createBuffer();M.bindBuffer(M.PIXEL_PACK_BUFFER,d),M.bufferData(M.PIXEL_PACK_BUFFER,a.byteLength,M.STREAM_READ),M.readPixels(t,n,r,i,He.convert(l),He.convert(u),0);let f=k===null?null:P.get(k).__webglFramebuffer;N.bindFramebuffer(M.FRAMEBUFFER,f);let p=M.fenceSync(M.SYNC_GPU_COMMANDS_COMPLETE,0);return M.flush(),await Yp(M,p,4),M.bindBuffer(M.PIXEL_PACK_BUFFER,d),M.getBufferSubData(M.PIXEL_PACK_BUFFER,0,a),M.deleteBuffer(d),M.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;De.setTexture2D(e,0),M.copyTexSubImage2D(M.TEXTURE_2D,n,0,0,o,s,i,a),N.unbindTexture()};let vt=M.createFramebuffer(),F=M.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=He.convert(t.format),_=He.convert(t.type),v;t.isData3DTexture?(De.setTexture3D(t,0),v=M.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(De.setTexture2DArray(t,0),v=M.TEXTURE_2D_ARRAY):(De.setTexture2D(t,0),v=M.TEXTURE_2D),N.activeTexture(M.TEXTURE0),N.pixelStorei(M.UNPACK_FLIP_Y_WEBGL,t.flipY),N.pixelStorei(M.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),N.pixelStorei(M.UNPACK_ALIGNMENT,t.unpackAlignment);let y=N.getParameter(M.UNPACK_ROW_LENGTH),b=N.getParameter(M.UNPACK_IMAGE_HEIGHT),x=N.getParameter(M.UNPACK_SKIP_PIXELS),S=N.getParameter(M.UNPACK_SKIP_ROWS),C=N.getParameter(M.UNPACK_SKIP_IMAGES);N.pixelStorei(M.UNPACK_ROW_LENGTH,h.width),N.pixelStorei(M.UNPACK_IMAGE_HEIGHT,h.height),N.pixelStorei(M.UNPACK_SKIP_PIXELS,l),N.pixelStorei(M.UNPACK_SKIP_ROWS,u),N.pixelStorei(M.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=P.get(e),r=P.get(t),h=P.get(n.__renderTarget),g=P.get(r.__renderTarget);N.bindFramebuffer(M.READ_FRAMEBUFFER,h.__webglFramebuffer),N.bindFramebuffer(M.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n>5&31)/31,a=(e>>10&31)/31)}for(let c=1;c<=3;c++){let l=n+c*12,u=e*3*3+(c-1)*3;p[u]=t.getFloat32(l,!0),p[u+1]=t.getFloat32(l+4,!0),p[u+2]=t.getFloat32(l+8,!0),m[u]=d,m[u+1]=f,m[u+2]=g,o&&(h.setRGB(r,i,a,Np),s[u]=h.r,s[u+1]=h.g,s[u+2]=h.b)}}return f.setAttribute(`position`,new cg(p,3)),f.setAttribute(`normal`,new cg(m,3)),o&&(f.setAttribute(`color`,new cg(s,3)),f.hasColors=!0,f.alpha=d),f}function i(e){let t=new Cg,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,i=/solid\s(.+)/,a=0,o=RegExp(`vertex[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,`g`),s=RegExp(`normal[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,`g`),c=[],l=[],u=[],d=new q,f,p=0,m=0,h=0;for(;(f=n.exec(e))!==null;){m=h;let e=f[0],n=(f=i.exec(e))===null?``:f[1];for(u.push(n);(f=r.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=s.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=o.exec(n))!==null;)c.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),l.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let g=m,_=h-m;t.userData.groupNames=u,t.addGroup(g,_,p),p++}return t.setAttribute(`position`,new dg(c,3)),t.setAttribute(`normal`,new dg(l,3)),t}function a(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function o(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n256||e.colormap_size!==24||e.colormap_type!==1)throw Error(`THREE.TGALoader: Invalid type colormap data for indexed type.`);break;case f:case p:case h:case g:if(e.colormap_type)throw Error(`THREE.TGALoader: Invalid type colormap data for colormap type.`);break;case u:throw Error(`THREE.TGALoader: No data.`);default:throw Error(`THREE.TGALoader: Invalid type `+e.image_type)}if(e.width<=0||e.height<=0)throw Error(`THREE.TGALoader: Invalid image size.`);if(e.pixel_size!==8&&e.pixel_size!==16&&e.pixel_size!==24&&e.pixel_size!==32)throw Error(`THREE.TGALoader: Invalid pixel size `+e.pixel_size)}function n(e,t,n,r,i){let a,o,s=n.pixel_size>>3,c=n.width*n.height*s;if(t&&(o=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){a=new Uint8Array(c);let e,t,n,o=0,l=new Uint8Array(s);for(;o>7,e[(u+f*d)*4+1]=(c&992)>>2,e[(u+f*d)*4+2]=(c&31)<<3,e[(u+f*d)*4+3]=c&32768?0:255;return e}function a(e,t,n,r,i,a,o,s){let c=0,l,u,d=T.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=3)e[(l+d*u)*4+3]=255,e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+1]=s[c+1],e[(l+d*u)*4+0]=s[c+2];return e}function o(e,t,n,r,i,a,o,s){let c=0,l,u,d=T.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=4)e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+1]=s[c+1],e[(l+d*u)*4+0]=s[c+2],e[(l+d*u)*4+3]=s[c+3];return e}function s(e,t,n,r,i,a,o,s){let c,l=0,u,d,f=T.width;for(d=t;d!==r;d+=n)for(u=i;u!==o;u+=a,l++)c=s[l],e[(u+f*d)*4+0]=c,e[(u+f*d)*4+1]=c,e[(u+f*d)*4+2]=c,e[(u+f*d)*4+3]=255;return e}function c(e,t,n,r,i,a,o,s){let c=0,l,u,d=T.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=2)e[(l+d*u)*4+0]=s[c+0],e[(l+d*u)*4+1]=s[c+0],e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+3]=s[c+1];return e}function l(e,t,n,l,u){let d,f,p,m,h,g;switch((T.flags&_)>>v){default:case x:d=0,p=1,h=t,f=0,m=1,g=n;break;case y:d=0,p=1,h=t,f=n-1,m=-1,g=-1;break;case S:d=t-1,p=-1,h=-1,f=0,m=1,g=n;break;case b:d=t-1,p=-1,h=-1,f=n-1,m=-1,g=-1;break}if(O)switch(T.pixel_size){case 8:s(e,f,m,g,d,p,h,l);break;case 16:c(e,f,m,g,d,p,h,l);break;default:throw Error(`THREE.TGALoader: Format not supported.`)}else switch(T.pixel_size){case 8:r(e,f,m,g,d,p,h,l,u);break;case 16:i(e,f,m,g,d,p,h,l);break;case 24:a(e,f,m,g,d,p,h,l);break;case 32:o(e,f,m,g,d,p,h,l);break;default:throw Error(`THREE.TGALoader: Format not supported.`)}return e}let u=0,d=1,f=2,p=3,m=9,h=10,g=11,_=48,v=4,y=0,b=1,x=2,S=3;if(e.length<19)throw Error(`THREE.TGALoader: Not enough data to contain header.`);let C=0,w=new Uint8Array(e),T={id_length:w[C++],colormap_type:w[C++],image_type:w[C++],colormap_index:w[C++]|w[C++]<<8,colormap_length:w[C++]|w[C++]<<8,colormap_size:w[C++],origin:[w[C++]|w[C++]<<8,w[C++]|w[C++]<<8],width:w[C++]|w[C++]<<8,height:w[C++]|w[C++]<<8,pixel_size:w[C++],flags:w[C++]};if(t(T),T.id_length+C>e.length)throw Error(`THREE.TGALoader: No data.`);C+=T.id_length;let E=!1,D=!1,O=!1;switch(T.image_type){case 9:E=!0,D=!0;break;case 1:D=!0;break;case 10:E=!0;break;case 2:break;case 11:E=!0,O=!0;break;case 3:O=!0;break}let ee=new Uint8Array(T.width*T.height*4),k=n(E,D,T,C,w);return l(ee,T.width,T.height,k.pixel_data,k.palettes),{data:ee,width:T.width,height:T.height,flipY:!0,generateMipmaps:!0,minFilter:vf}}};function wC(e,t){let n=[],r=e.childNodes;for(let e=0,i=r.length;eparseInt(e))}function OC(e){return e.substring(1)}var kC=class{constructor(){this.count=0}generateId(){return`three_default_`+ this.count++}parse(e){if(e.length===0)return null;let t=new DOMParser().parseFromString(e,`application/xml`),n=wC(t,`COLLADA`)[0],r=t.getElementsByTagName(`parsererror`)[0];if(r!==void 0){let e=wC(r,`div`)[0],t;return t=e?e.textContent:this.parserErrorToText(r),console.error(`THREE.ColladaLoader: Failed to parse collada file. +`,t),null}let i=n.getAttribute(`version`);console.debug(`THREE.ColladaLoader: File version`,i);let a=this.parseAsset(wC(n,`asset`)[0]),o={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{},joints:{}};return this.library=o,this.collada=n,this.parseLibrary(n,`library_animations`,`animation`,this.parseAnimation.bind(this)),this.parseLibrary(n,`library_animation_clips`,`animation_clip`,this.parseAnimationClip.bind(this)),this.parseLibrary(n,`library_controllers`,`controller`,this.parseController.bind(this)),this.parseLibrary(n,`library_images`,`image`,this.parseImage.bind(this)),this.parseLibrary(n,`library_effects`,`effect`,this.parseEffect.bind(this)),this.parseLibrary(n,`library_materials`,`material`,this.parseMaterial.bind(this)),this.parseLibrary(n,`library_cameras`,`camera`,this.parseCamera.bind(this)),this.parseLibrary(n,`library_lights`,`light`,this.parseLight.bind(this)),this.parseLibrary(n,`library_geometries`,`geometry`,this.parseGeometry.bind(this)),this.parseLibrary(n,`library_nodes`,`node`,this.parseNode.bind(this)),this.parseLibrary(n,`library_visual_scenes`,`visual_scene`,this.parseVisualScene.bind(this)),this.parseLibrary(n,`library_joints`,`joint`,this.parseLibraryJoint.bind(this)),this.parseLibrary(n,`library_kinematics_models`,`kinematics_model`,this.parseKinematicsModel.bind(this)),this.parseLibrary(n,`library_physics_models`,`physics_model`,this.parsePhysicsModel.bind(this)),this.parseLibrary(n,`scene`,`instance_kinematics_scene`,this.parseKinematicsScene.bind(this)),{library:o,asset:a,collada:n}}parserErrorToText(e){let t=[],n=[e];for(;n.length;){let e=n.shift();e.nodeType===Node.TEXT_NODE?t.push(e.textContent):(t.push(` +`),n.push(...e.childNodes))}return t.join(``).trim()}parseAsset(e){return{unit:this.parseAssetUnit(wC(e,`unit`)[0]),upAxis:this.parseAssetUpAxis(wC(e,`up_axis`)[0])}}parseAssetUnit(e){return e!==void 0&&e.hasAttribute(`meter`)===!0?parseFloat(e.getAttribute(`meter`)):1}parseAssetUpAxis(e){return e===void 0?`Y_UP`:e.textContent}parseLibrary(e,t,n,r){let i=wC(e,t)[0];if(i!==void 0){let e=wC(i,n);for(let t=0;t0?n+a:n;t.inputs[o]={id:e,offset:i},t.stride=Math.max(t.stride,i+1),n===`TEXCOORD`&&(t.hasUV=!0);break;case`vcount`:t.vcount=DC(r.textContent);break;case`p`:t.p=DC(r.textContent);break}}return t.type===`polygons`&&(t.vcount=[t.p.length/t.stride]),t}parseLibraryJoint(e){this.library.joints[e.getAttribute(`id`)]=this.parseKinematicsJoint(e)}parseKinematicsModel(e){let t={name:e.getAttribute(`name`)||``,joints:{},links:[]};for(let n=0;n=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}parseKinematicsLink(e){let t={sid:e.getAttribute(`sid`),name:e.getAttribute(`name`)||``,attachments:[],transforms:[]};for(let n=0;n0&&u.dot(l)<0&&(l.x=-l.x,l.y=-l.y,l.z=-l.z,l.w=-l.w),u.copy(l),f.push(l.x,l.y,l.z,l.w)}let m=new Zv(e.uuid+`.quaternion`,s,f);this.applyInterpolation(m,p),a.push(m)}buildScaleTrack(e,t,n,r){if(t.default&&t.default.stride===3){let n=t.default,i=Array.from(n.times),a=Array.from(n.values),o=new $v(e.uuid+`.scale`,i,a),s=this.getInterpolationInfo(t);this.applyInterpolation(o,s,t),r.push(o);return}let i=this.getTimesForAllAxes(t);if(i.length===0)return;let a=[],o=this.getInterpolationInfo(t);for(let e=0;ee-t),t}getValueAtTime(e,t,n){if(!e)return n;let r=e.times,i=e.values,a=e.interpolation;for(let n=0;nt){if(n===0)return i[0];let o=n-1,s=n,c=r[o],l=r[s],u=i[o],d=i[s],f=a?a[o]:`LINEAR`;return f===`STEP`?u:f===`BEZIER`&&e.inTangent&&e.outTangent?this.evaluateBezierComponent(e,o,s,c,l,t):u+(t-c)/(l-c)*(d-u)}}return i[i.length-1]}evaluateBezierComponent(e,t,n,r,i,a){let o=e.values,s=e.inTangent,c=e.outTangent,l=e.inTangentStride||1,u=o[t],d=o[n],f,p,m,h;l===2?(f=c[t*2],p=c[t*2+1],m=s[n*2],h=s[n*2+1]):(f=r+(i-r)/3,p=c[t],m=i-(i-r)/3,h=s[n]);let g=(a-r)/(i-r);for(let e=0;e<8;e++){let e=g*g,t=e*g,n=1-g,o=n*n,s=o*n*r+3*o*g*f+3*n*e*m+t*i,c=3*o*(f-r)+6*n*g*(m-f)+3*e*(i-m);if(Math.abs(c)<1e-10)break;let l=s-a;if(Math.abs(l)<1e-10)break;g-=l/c,g=Math.max(0,Math.min(1,g))}let _=g*g,v=_*g,y=1-g,b=y*y;return b*y*u+3*b*g*p+3*y*_*h+v*d}getInterpolationInfo(e){let t=[`X`,`Y`,`Z`,`ANGLE`,`default`],n=null,r=!0;for(let i of t){let t=e[i];if(!t||!t.interpolation)continue;let a=t.interpolation;for(let e=0;ee.time-t.time);for(let e=0;e<16;e++)this.transformAnimationData(n,e,t.elements[e]);return n}createKeyframeTracks(e,t){let n=e.keyframes,r=e.name,i=[],a=[],o=[],s=[],c=this.position,l=this.quaternion,u=this.scale,d=this.matrix;for(let e=0,t=n.length;e0&&t.push(new $v(r+`.position`,i,a)),o.length>0&&t.push(new Zv(r+`.quaternion`,i,o)),s.length>0&&t.push(new $v(r+`.scale`,i,s)),t}transformAnimationData(e,t,n){let r,i=!0,a,o;for(a=0,o=e.length;a=0;){let r=e[t];if(r.value[n]!==null)return r;t--}return null}getNext(e,t,n){for(;t>>0)+2);switch(n=n.toLowerCase(),n){case`tga`:t=this.tgaLoader;break;default:t=this.textureLoader}return t}buildMaterial(e){let t=this.getEffect(e.url),n=t.profile.technique,r;switch(n.type){case`phong`:case`blinn`:r=new Nv;break;case`lambert`:r=new Pv;break;default:r=new Pg;break}r.name=e.name||``;let i=this;function a(e,n=null){let r=t.profile.samplers[e.id],a=null;if(r!==void 0){let e=t.profile.surfaces[r.source];a=i.getImage(e.init_from)}else console.warn(`THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).`),a=i.getImage(e.id);if(a!==null){let t=i.getTextureLoader(a);if(t!==void 0){let r=t.load(a),o=e.extra;if(o!==void 0&&o.technique!==void 0&&i.isEmpty(o.technique)===!1){let e=o.technique;r.wrapS=e.wrapU?uf:df,r.wrapT=e.wrapV?uf:df,r.offset.set(e.offsetU||0,e.offsetV||0),r.repeat.set(e.repeatU||1,e.repeatV||1)}else r.wrapS=uf,r.wrapT=uf;return n!==null&&(r.colorSpace=n),r}else return console.warn(`THREE.ColladaLoader: Loader for texture %s not found.`,a),null}else return console.warn(`THREE.ColladaLoader: Couldn't create texture with ID:`,e.id),null}let o=n.parameters;for(let e in o){let t=o[e];switch(e){case`diffuse`:t.color&&r.color.fromArray(t.color),t.texture&&(r.map=a(t.texture,Np));break;case`specular`:t.color&&r.specular&&r.specular.fromArray(t.color),t.texture&&(r.specularMap=a(t.texture));break;case`bump`:t.texture&&(r.normalMap=a(t.texture));break;case`ambient`:t.texture&&(r.lightMap=a(t.texture,Np));break;case`shininess`:t.float&&r.shininess&&(r.shininess=t.float);break;case`emission`:t.color&&r.emissive&&r.emissive.fromArray(t.color),t.texture&&(r.emissiveMap=a(t.texture,Np));break}}Y.colorSpaceToWorking(r.color,Np),r.specular&&Y.colorSpaceToWorking(r.specular,Np),r.emissive&&Y.colorSpaceToWorking(r.emissive,Np);let s=o.transparent,c=o.transparency;if(c===void 0&&s&&(c={float:1}),s===void 0&&c&&(s={opaque:`A_ONE`,data:{color:[1,1,1,1]}}),s&&c)if(s.data.texture)r.transparent=!0;else{let e=s.data.color;switch(s.opaque){case`A_ONE`:r.opacity=e[3]*c.float;break;case`RGB_ZERO`:r.opacity=1-e[0]*c.float;break;case`A_ZERO`:r.opacity=1-e[3]*c.float;break;case`RGB_ONE`:r.opacity=e[0]*c.float;break;default:console.warn(`THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.`,s.opaque)}r.opacity<1&&(r.transparent=!0)}if(n.extra!==void 0&&n.extra.technique!==void 0){let e=n.extra.technique;for(let t in e){let n=e[t];switch(t){case`double_sided`:r.side=n===1?2:0;break;case`bump`:r.normalMap=a(n.texture),r.normalScale=new K(1,1);break}}}return r}getMaterial(e){return this.getBuild(this.library.materials[e],this.buildMaterial.bind(this))}buildCamera(e){let t;switch(e.optics.technique){case`perspective`:t=new Oy(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case`orthographic`:let n=e.optics.parameters.ymag,r=e.optics.parameters.xmag,i=e.optics.parameters.aspect_ratio;r=r===void 0?n*i:r,n=n===void 0?r/i:n,r*=.5,n*=.5,t=new Ny(-r,r,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new Oy;break}return t.name=e.name||``,t}getCamera(e){let t=this.library.cameras[e];return t===void 0?(console.warn(`THREE.ColladaLoader: Couldn't find camera with ID:`,e),null):this.getBuild(t,this.buildCamera.bind(this))}buildLight(e){let t;switch(e.technique){case`directional`:t=new Fy;break;case`point`:t=new My;break;case`spot`:t=new Ay;break;case`ambient`:t=new Iy;break}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),e.parameters.falloffAngle&&(t.angle=wm.degToRad(e.parameters.falloffAngle)),t}getLight(e){let t=this.library.lights[e];return t===void 0?(console.warn(`THREE.ColladaLoader: Couldn't find light with ID:`,e),null):this.getBuild(t,this.buildLight.bind(this))}groupPrimitives(e){let t={};for(let n=0;n0&&t0&&d.setAttribute(`position`,new dg(i.array,i.stride)),a.array.length>0&&d.setAttribute(`normal`,new dg(a.array,a.stride)),c.array.length>0&&d.setAttribute(`color`,new dg(c.array,c.stride)),o.array.length>0&&d.setAttribute(`uv`,new dg(o.array,o.stride)),s.array.length>0&&d.setAttribute(`uv1`,new dg(s.array,s.stride)),l.array.length>0&&d.setAttribute(`skinIndex`,new dg(l.array,l.stride)),u.array.length>0&&d.setAttribute(`skinWeight`,new dg(u.array,u.stride)),r.data=d,r.type=e[0].type,r.materialKeys=f,r}buildGeometryData(e,t,n,r,i=!1){let a=e.p,o=e.stride,s=e.vcount,c=this.tempColor;function l(e){let t=a[e+n]*d,o=t+d;for(;t4){let t=[];for(let r=0;rMath.abs(r.y)&&Math.abs(r.x)>Math.abs(r.z))for(let e=0;eMath.abs(r.z))for(let e=0;er.limits.max||t0&&c.dot(s)<0&&(s.x=-s.x,s.y=-s.y,s.z=-s.z,s.w=-s.w),c.copy(s),l.push(s.x,s.y,s.z,s.w)}let d=new Zv(e.uuid+`.quaternion`,a,l);this.applyInterpolation(d,u),r.push(d)}buildHierarchyScaleTrack(e,t,n,r){if(t.default&&t.default.stride===3){let n=t.default,i=new $v(e.uuid+`.scale`,Array.from(n.times),Array.from(n.values)),a=this.getInterpolationInfo(t);this.applyInterpolation(i,a,t),r.push(i);return}let i=this.getTimesForAllAxes(t);if(i.length===0)return;let a=[],o=this.getInterpolationInfo(t);for(let e=0;ee===null?null:parseFloat(e)),(!this.origPosition||!this.origQuaternion)&&(this.origPosition=this.position.clone(),this.origQuaternion=this.quaternion.clone());let t=!1;switch(this.mimicJoints.forEach(n=>{t=n.updateFromMimickedJoint(...e)||t}),this.jointType){case`fixed`:return t;case`continuous`:case`revolute`:{let n=e[0];return n==null||n===this.jointValue[0]?t:(!this.ignoreLimits&&this.jointType===`revolute`&&(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.quaternion.setFromAxisAngle(this.axis,n).premultiply(this.origQuaternion),this.jointValue[0]===n?t:(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0))}case`prismatic`:{let n=e[0];return n==null||n===this.jointValue[0]?t:(this.ignoreLimits||(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.position.copy(this.origPosition),MC.copy(this.axis).applyEuler(this.rotation),this.position.addScaledVector(MC,n),this.jointValue[0]===n?t:(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0))}case`floating`:return this.jointValue.every((t,n)=>e[n]===t||e[n]===null)?t:(this.jointValue[0]=e[0]===null?this.jointValue[0]:e[0],this.jointValue[1]=e[1]===null?this.jointValue[1]:e[1],this.jointValue[2]=e[2]===null?this.jointValue[2]:e[2],this.jointValue[3]=e[3]===null?this.jointValue[3]:e[3],this.jointValue[4]=e[4]===null?this.jointValue[4]:e[4],this.jointValue[5]=e[5]===null?this.jointValue[5]:e[5],FC.compose(this.origPosition,this.origQuaternion,LC),IC.setFromEuler(NC.set(this.jointValue[3],this.jointValue[4],this.jointValue[5],`XYZ`)),RC.set(this.jointValue[0],this.jointValue[1],this.jointValue[2]),PC.compose(RC,IC,LC),FC.premultiply(PC),this.position.setFromMatrixPosition(FC),this.rotation.setFromRotationMatrix(FC),this.matrixWorldNeedsUpdate=!0,!0);case`planar`:return this.jointValue.every((t,n)=>e[n]===t||e[n]===null)?t:(this.jointValue[0]=e[0]===null?this.jointValue[0]:e[0],this.jointValue[1]=e[1]===null?this.jointValue[1]:e[1],this.jointValue[2]=e[2]===null?this.jointValue[2]:e[2],FC.compose(this.origPosition,this.origQuaternion,LC),IC.setFromAxisAngle(this.axis,this.jointValue[2]),RC.set(this.jointValue[0],this.jointValue[1],0),PC.compose(RC,IC,LC),FC.premultiply(PC),this.position.setFromMatrixPosition(FC),this.rotation.setFromRotationMatrix(FC),this.matrixWorldNeedsUpdate=!0,!0)}return t}},WC=class extends UC{constructor(...e){super(...e),this.type=`URDFMimicJoint`,this.mimicJoint=null,this.offset=0,this.multiplier=1}updateFromMimickedJoint(...e){let t=e.map(e=>e===null?null:e*this.multiplier+this.offset);return super.setJointValue(...t)}copy(e,t){return super.copy(e,t),this.mimicJoint=e.mimicJoint,this.offset=e.offset,this.multiplier=e.multiplier,this}},GC=class extends HC{constructor(...e){super(...e),this.isURDFRobot=!0,this.urdfNode=null,this.urdfRobotNode=null,this.robotName=null,this.links=null,this.joints=null,this.colliders=null,this.visual=null,this.frames=null}copy(e,t){super.copy(e,t),this.urdfRobotNode=e.urdfRobotNode,this.robotName=e.robotName,this.links={},this.joints={},this.colliders={},this.visual={},this.traverse(t=>{t.isURDFJoint&&t.urdfName in e.joints&&(this.joints[t.urdfName]=t),t.isURDFLink&&t.urdfName in e.links&&(this.links[t.urdfName]=t),t.isURDFCollider&&t.urdfName in e.colliders&&(this.colliders[t.urdfName]=t),t.isURDFVisual&&t.urdfName in e.visual&&(this.visual[t.urdfName]=t)});for(let e in this.joints)this.joints[e].mimicJoints=this.joints[e].mimicJoints.map(e=>this.joints[e.name]);return this.frames={...this.colliders,...this.visual,...this.links,...this.joints},this}getFrame(e){return this.frames[e]}setJointValue(e,...t){let n=this.joints[e];return n?n.setJointValue(...t):!1}setJointValues(e){let t=!1;for(let n in e){let r=e[n];t=Array.isArray(r)?this.setJointValue(n,...r)||t:this.setJointValue(n,r)||t}return t}},KC=new Tm,qC=new nh;function JC(e){return e?e.trim().split(/\s+/g).map(e=>parseFloat(e)):[0,0,0]}function YC(e,t,n=!1){n||e.rotation.set(0,0,0),qC.set(t[0],t[1],t[2],`ZYX`),KC.setFromEuler(qC),KC.multiply(e.quaternion),e.quaternion.copy(KC)}var XC=class{constructor(e){this.manager=e||oy,this.loadMeshCb=this.defaultMeshLoader.bind(this),this.parseVisual=!0,this.parseCollision=!1,this.packages=``,this.workingPath=``,this.fetchOptions={}}loadAsync(e){return new Promise((t,n)=>{this.load(e,t,null,n)})}load(e,t,n,r){let i=this.manager,a=Ly.extractUrlBase(e),o=this.manager.resolveURL(e);i.itemStart(o),fetch(o,this.fetchOptions).then(e=>{if(e.ok)return n&&n(null),e.text();throw Error(`URDFLoader: Failed to load url '${o}' with error code ${e.status} : ${e.statusText}.`)}).then(e=>{t(this.parse(e,this.workingPath||a)),i.itemEnd(o)}).catch(e=>{r?r(e):console.error(`URDFLoader: Error loading file.`,e),i.itemError(o),i.itemEnd(o)})}parse(e,t=this.workingPath){let n=this.packages,r=this.loadMeshCb,i=this.parseVisual,a=this.parseCollision,o=this.manager,s={},c={},l={};function u(e){if(!/^package:\/\//.test(e))return t?t+e:e;let[r,i]=e.replace(/^package:\/\//,``).split(/\/(.+)/);if(typeof n==`string`)return n.endsWith(r)?n+`/`+i:n+`/`+r+`/`+i;if(typeof n==`function`)return n(r)+`/`+i;if(typeof n==`object`)return r in n?n[r]+`/`+i:(console.error(`URDFLoader : ${r} not found in provided package list.`),null)}function d(e){let t;return t=e instanceof Document?[...e.children]:e instanceof Element?[e]:[...new DOMParser().parseFromString(e,`text/xml`).children],f(t.filter(e=>e.nodeName===`robot`).pop())}function f(e){let t=[...e.children],n=t.filter(e=>e.nodeName.toLowerCase()===`link`),r=t.filter(e=>e.nodeName.toLowerCase()===`joint`),i=t.filter(e=>e.nodeName.toLowerCase()===`material`),a=new GC;a.robotName=e.getAttribute(`name`),a.urdfRobotNode=e,i.forEach(e=>{let t=e.getAttribute(`name`);l[t]=h(e)});let o={},u={};n.forEach(t=>{let n=t.getAttribute(`name`);s[n]=m(t,o,u,e.querySelector(`child[link="${n}"]`)===null?a:null)}),r.forEach(e=>{let t=e.getAttribute(`name`);c[t]=p(e)}),a.joints=c,a.links=s,a.colliders=u,a.visual=o;let d=Object.values(c);return d.forEach(e=>{e instanceof WC&&c[e.mimicJoint].mimicJoints.push(e)}),d.forEach(e=>{let t=new Set,n=e=>{if(t.has(e))throw Error(`URDFLoader: Detected an infinite loop of mimic joints.`);t.add(e),e.mimicJoints.forEach(e=>{n(e)})};n(e)}),a.frames={...u,...o,...s,...c},a}function p(e){let t=[...e.children],n=e.getAttribute(`type`),r,i=t.find(e=>e.nodeName.toLowerCase()===`mimic`);i?(r=new WC,r.mimicJoint=i.getAttribute(`joint`),r.multiplier=parseFloat(i.getAttribute(`multiplier`)||1),r.offset=parseFloat(i.getAttribute(`offset`)||0)):r=new UC,r.urdfNode=e,r.name=e.getAttribute(`name`),r.urdfName=r.name,r.jointType=n;let a=null,o=null,c=[0,0,0],l=[0,0,0];t.forEach(e=>{let t=e.nodeName.toLowerCase();t===`origin`?(c=JC(e.getAttribute(`xyz`)),l=JC(e.getAttribute(`rpy`))):t===`child`?o=s[e.getAttribute(`link`)]:t===`parent`?a=s[e.getAttribute(`link`)]:t===`limit`&&(r.limit.lower=parseFloat(e.getAttribute(`lower`)||r.limit.lower),r.limit.upper=parseFloat(e.getAttribute(`upper`)||r.limit.upper),r.limit.effort=parseFloat(e.getAttribute(`effort`)||r.limit.effort),r.limit.velocity=parseFloat(e.getAttribute(`velocity`)||r.limit.velocity))}),a.add(r),r.add(o),YC(r,l),r.position.set(c[0],c[1],c[2]);let u=t.filter(e=>e.nodeName.toLowerCase()===`axis`)[0];if(u){let e=u.getAttribute(`xyz`).split(/\s+/g).map(e=>parseFloat(e));r.axis=new q(e[0],e[1],e[2]),r.axis.normalize()}return r}function m(e,t,n,r=null){r===null&&(r=new HC);let o=[...e.children];r.name=e.getAttribute(`name`),r.urdfName=r.name,r.urdfNode=e;let s=o.find(e=>e.nodeName.toLowerCase()===`inertial`);return s&&[...s.children].forEach(e=>{let t=e.nodeName.toLowerCase();t===`origin`?(r.inertial.origin.xyz=JC(e.getAttribute(`xyz`)),r.inertial.origin.rpy=JC(e.getAttribute(`rpy`))):t===`mass`?r.inertial.mass=parseFloat(e.getAttribute(`value`))||0:t===`inertia`&&(r.inertial.inertia.ixx=parseFloat(e.getAttribute(`ixx`))||0,r.inertial.inertia.ixy=parseFloat(e.getAttribute(`ixy`))||0,r.inertial.inertia.ixz=parseFloat(e.getAttribute(`ixz`))||0,r.inertial.inertia.iyy=parseFloat(e.getAttribute(`iyy`))||0,r.inertial.inertia.iyz=parseFloat(e.getAttribute(`iyz`))||0,r.inertial.inertia.izz=parseFloat(e.getAttribute(`izz`))||0)}),i&&o.filter(e=>e.nodeName.toLowerCase()===`visual`).forEach(e=>{let n=g(e,l);if(r.add(n),e.hasAttribute(`name`)){let r=e.getAttribute(`name`);n.name=r,n.urdfName=r,t[r]=n}}),a&&o.filter(e=>e.nodeName.toLowerCase()===`collision`).forEach(e=>{let t=g(e);if(r.add(t),e.hasAttribute(`name`)){let r=e.getAttribute(`name`);t.name=r,t.urdfName=r,n[r]=t}}),r}function h(e){let t=[...e.children],n=new Nv;return n.name=e.getAttribute(`name`)||``,t.forEach(e=>{let t=e.nodeName.toLowerCase();if(t===`color`){let t=e.getAttribute(`rgba`).split(/\s/g).map(e=>parseFloat(e));n.color.setRGB(t[0],t[1],t[2]),n.opacity=t[3],n.transparent=t[3]<1,n.depthWrite=!n.transparent}else if(t===`texture`){let t=e.getAttribute(`filename`);if(t){let e=new my(o),r=u(t);n.map=e.load(r),n.map.colorSpace=Np}}}),n}function g(e,t={}){let n=e.nodeName.toLowerCase()===`collision`,i=[...e.children],a=null,s=i.filter(e=>e.nodeName.toLowerCase()===`material`)[0];if(s){let e=s.getAttribute(`name`);a=e&&e in t?t[e]:h(s)}else a=new Nv;let c=n?new BC:new VC;return c.urdfNode=e,i.forEach(e=>{let t=e.nodeName.toLowerCase();if(t===`geometry`){let t=e.children[0].nodeName.toLowerCase();if(t===`mesh`){let t=u(e.children[0].getAttribute(`filename`));if(t!==null){let n=e.children[0].getAttribute(`scale`);if(n){let e=JC(n);c.scale.set(e[0],e[1],e[2])}r(t,o,(e,t)=>{t?console.error(`URDFLoader: Error loading mesh.`,t):e&&(e instanceof Kg&&(e.material=a),e.position.set(0,0,0),e.quaternion.identity(),c.add(e))})}}else if(t===`box`){let t=new Kg;t.geometry=new F_(1,1,1),t.material=a;let n=JC(e.children[0].getAttribute(`size`));t.scale.set(n[0],n[1],n[2]),c.add(t)}else if(t===`sphere`){let t=new Kg;t.geometry=new xv(1,30,30),t.material=a;let n=parseFloat(e.children[0].getAttribute(`radius`))||0;t.scale.set(n,n,n),c.add(t)}else if(t===`cylinder`){let t=new Kg;t.geometry=new I_(1,1,1,30),t.material=a;let n=parseFloat(e.children[0].getAttribute(`radius`))||0,r=parseFloat(e.children[0].getAttribute(`length`))||0;t.scale.set(n,r,n),t.rotation.set(Math.PI/2,0,0),c.add(t)}}else if(t===`origin`){let t=JC(e.getAttribute(`xyz`)),n=JC(e.getAttribute(`rpy`));c.position.set(t[0],t[1],t[2]),c.rotation.set(0,0,0),YC(c,n)}}),c}return d(e)}defaultMeshLoader(e,t,n){/\.stl$/i.test(e)?new SC(t).load(e,e=>{n(new Kg(e,new Nv))},null,e=>n(null,e)):/\.dae$/i.test(e)?new jC(t).load(e,e=>n(e.scene),null,e=>n(null,e)):console.warn(`URDFLoader: Could not load model at ${e}.\nNo loader available`)}},ZC=`/robot-3d/reachy-mini.urdf`,QC=`/moves/reachy-moves.json`,$C=-Math.PI/2,ew=(e,t,n)=>e+(t-e)*n,tw=(e,t)=>e+Math.random()*(t-e),nw=.06,rw=1,iw=3.5,aw=.35,ow=.12,sw=null;function cw(){return sw||(sw=fetch(QC).then(e=>e.json()).then(e=>(e.idx=Object.fromEntries(e.cols.map((e,t)=>[e,t])),e.reactions=Object.keys(e.moves).filter(t=>e.moves[t].kind===`emotion`),e.dances=Object.keys(e.moves).filter(t=>e.moves[t].kind===`dance`),e)).catch(e=>(console.warn(`Reachy moves failed to load (reactions disabled)`,e),null)),sw)}var lw=Math.PI/180,uw=Math.PI*2,dw=.005,fw=.1,pw=15*lw,mw=.5,hw=7*lw,gw=1.6,_w=6*lw,vw=.06,yw=.08,bw=.32,xw={pitch:[3.5*lw,1.2],yaw:[6*lw,.45],roll:[2*lw,.8],x:[.0045,.3],y:[.00375,.4],z:[.00225,.22]},Sw=null;function Cw(){return Sw||=ww()}function ww(){return new Promise((e,t)=>{let n=new ay,r=new XC(n);r.loadMeshCb=(e,t,n)=>{new SC(t).load(e,e=>{e.computeVertexNormals(),n(new Kg(e,new Mv({color:10133931,metalness:.35,roughness:.55})))},void 0,e=>n(null,e))};let i=null;n.onLoad=()=>{i&&e(i)},r.load(ZC,e=>{i=e},void 0,t)})}async function Tw(){return(await Cw()).clone()}var Ew=class{constructor(e,{accent:t=`#c98a3c`}={}){this.container=e,this.accent=new Z(t),this.level=0,this._targetLevel=0,this._t=0,this._clock=new nb,this._disposed=!1,this._move=null,this._nextReactAt=tw(.5,2.5),cw().then(e=>this._lib=e);let n=e.clientWidth||320,r=e.clientHeight||240;this.scene=new kh,this.camera=new Oy(35,n/r,.01,100),this.renderer=new xC({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(n,r),e.appendChild(this.renderer.domElement),this._addLights(),this._ro=new ResizeObserver(()=>this._resize()),this._ro.observe(e),this._raf=requestAnimationFrame(this._tick),this._loadRobot()}_addLights(){this.scene.add(new gy(16777215,3354667,1.1));let e=new Fy(16774112,1.4);e.position.set(1.5,2,1.2),this.scene.add(e);let t=new Fy(this.accent.clone(),.6);t.position.set(-1.5,.5,-1.5),this.scene.add(t)}async _loadRobot(){let e;try{e=await Cw()}catch(e){console.error(`Failed to load Reachy URDF`,e);return}if(!this._disposed){this.robot=e.clone(),this.robot.rotation.x=-Math.PI/2,this.pivot=new bh,this.pivot.rotation.y=$C,this.pivot.add(this.robot),this.scene.add(this.pivot),this._frameCamera(),this._rest={};for(let e of[`left_antenna`,`right_antenna`,`yaw_body`]){let t=this.robot.joints?.[e];this._rest[e]=t?t.angle??0:0}this.head=this.robot.links?.xl_330||null,this.head&&(this.pivot.updateMatrixWorld(!0),this._headRestPos=this.head.position.clone(),this._parentWorldQuatInv=this.head.parent.getWorldQuaternion(new Tm).invert(),this._headRestWorldQuat=this.head.getWorldQuaternion(new Tm)),this._seed=Math.random()*uw,this._euler=new nh,this._q=new Tm,this._qLocal=new Tm,this._tmp=new q}}_frameCamera(){this.pivot.updateMatrixWorld(!0);let e=new Wh().setFromObject(this.robot),t=e.getSize(new q),n=e.getCenter(new q);this._center=n;let r=Math.max(t.x,t.y,t.z)*.5/Math.tan(this.camera.fov*Math.PI/360);this._camDist=r*1.5,this._lookAt=n.clone().add(new q(0,t.y*.12,0)),this.camera.position.set(n.x,this._lookAt.y,n.z+this._camDist),this.camera.lookAt(this._lookAt)}setLevel(e){this._targetLevel=Math.max(0,Math.min(1,e))}_setJoint(e,t){this.robot?.setJointValue?.(e,t)}_startReaction(e){let t=this._lib,n=t.dances.length&&Math.random()n.length-2&&(a=n.length-2);let o=n[a],s=n[a+1]||o,c=Math.min(1,Math.max(0,i-a)),l=e=>{let t=r[e];return o[t]+(s[t]-o[t])*c};return{x:l(`x`),y:l(`y`),z:l(`z`),roll:l(`roll`),pitch:l(`pitch`),yaw:l(`yaw`),antL:l(`antL`),antR:l(`antR`),bodyYaw:l(`bodyYaw`)}}_tick=()=>{if(this._disposed)return;this._raf=requestAnimationFrame(this._tick);let e=Math.min(this._clock.getDelta(),.1);this._t+=e;let t=this._t,n=this._targetLevel>this.level?yw:bw;this.level+=(this._targetLevel-this.level)*(1-Math.exp(-e/n));let r=this.level;if(this.robot&&this._rest){let e=this._seed,n=this._targetLevel>nw;this._lib&&(n?(this._move=null,this._nextReactAt=t+tw(rw,iw)):(this._move&&t-this._move.start>=this._move.dur&&(this._move=null),!this._move&&t>=this._nextReactAt&&this._startReaction(t)));let i=0,a=dw*Math.sin(uw*fw*t),o=0,s=0,c=0,l=0,u=pw*Math.sin(uw*mw*t),d=this._rest.left_antenna+u,f=this._rest.right_antenna-u,p=this._rest.yaw_body+_w*Math.sin(uw*vw*t+e)*(1-.6*r);if(this._move){let e=t-this._move.start,n=this._sampleMove(this._move.data,e),r=Math.min(1,e/aw),u=this._move.dur-e;u.001){c+=xw.pitch[0]*r*Math.sin(uw*xw.pitch[1]*t+e),l+=xw.yaw[0]*r*Math.sin(uw*xw.yaw[1]*t+e+1.3),s+=xw.roll[0]*r*Math.sin(uw*xw.roll[1]*t+e+2.6),i+=xw.x[0]*r*Math.sin(uw*xw.x[1]*t+e+.7),a+=xw.y[0]*r*Math.sin(uw*xw.y[1]*t+e+1.9),o+=xw.z[0]*r*Math.sin(uw*xw.z[1]*t+e+3.1);let n=hw*r*Math.sin(uw*gw*t+e);d+=n,f-=n}this.head&&(this._euler.set(c,l,s,`XYZ`),this._q.setFromEuler(this._euler),this._qLocal.copy(this._parentWorldQuatInv).multiply(this._q).multiply(this._headRestWorldQuat),this.head.quaternion.copy(this._qLocal),this._tmp.set(i,a,o).applyQuaternion(this._parentWorldQuatInv),this.head.position.copy(this._headRestPos).add(this._tmp)),this._setJoint(`left_antenna`,d),this._setJoint(`right_antenna`,f),this._setJoint(`yaw_body`,p)}this.renderer.render(this.scene,this.camera)};_resize(){let e=this.container.clientWidth,t=this.container.clientHeight;!e||!t||(this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t))}dispose(){this._disposed=!0,cancelAnimationFrame(this._raf),this._ro.disconnect(),this.renderer.dispose(),this.renderer.domElement.remove()}},Dw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`},Ow=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},kw=new Ny(-1,1,1,-1,0,1),Aw=new class extends Cg{constructor(){super(),this.setAttribute(`position`,new dg([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new dg([0,2,0,0,2,0],2))}},jw=class{constructor(e){this._mesh=new Kg(Aw,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,kw)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Mw=class extends Ow{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Av?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Dv.clone(e.uniforms),this.material=new Av({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new jw(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},Nw=class extends Ow{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},Pw=class extends Ow{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},Fw=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new K);this._width=n.width,this._height=n.height,t=new Wm(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ef}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Mw(Dw),this.copyPass.material.blending=0,this.timer=new Hy}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t + + varying vec2 vUv; + + uniform sampler2D colorTexture; + uniform vec2 invSize; + uniform vec2 direction; + uniform float gaussianCoefficients[KERNEL_RADIUS]; + + void main() { + + float weightSum = gaussianCoefficients[0]; + vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; + + for ( int i = 1; i < KERNEL_RADIUS; i ++ ) { + + float x = float( i ); + float w = gaussianCoefficients[i]; + vec2 uvOffset = direction * invSize * x; + vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; + vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; + diffuseSum += ( sample1 + sample2 ) * w; + + } + + gl_FragColor = vec4( diffuseSum, 1.0 ); + + }`})}_getCompositeMaterial(e){return new Av({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + varying vec2 vUv; + + uniform sampler2D blurTexture1; + uniform sampler2D blurTexture2; + uniform sampler2D blurTexture3; + uniform sampler2D blurTexture4; + uniform sampler2D blurTexture5; + uniform float bloomStrength; + uniform float bloomRadius; + uniform float bloomFactors[NUM_MIPS]; + uniform vec3 bloomTintColors[NUM_MIPS]; + + float lerpBloomFactor( const in float factor ) { + + float mirrorFactor = 1.2 - factor; + return mix( factor, mirrorFactor, bloomRadius ); + + } + + void main() { + + // 3.0 for backwards compatibility with previous alpha-based intensity + vec3 bloom = 3.0 * bloomStrength * ( + lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb + ); + + float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) ); + gl_FragColor = vec4( bloom, bloomAlpha ); + + }`})}};Rw.BlurDirectionX=new K(1,0),Rw.BlurDirectionY=new K(0,1);var zw=4843208,Bw=7109631,Vw=Math.PI*2,Hw=(e,t,n)=>e+(t-e)*n,Uw=class{constructor(e){this.container=e,this._disposed=!1,this._t=0,this._clock=new nb,this._mx=.35,this._my=-.2,this._lx=0,this._ly=0;let t=e.clientWidth||window.innerWidth,n=e.clientHeight||window.innerHeight;this.scene=new kh,this.scene.fog=new Oh(329485,.11),this.camera=new Oy(38,t/n,.01,100),this.camera.position.set(0,.05,1),this.renderer=new xC({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(t,n),e.appendChild(this.renderer.domElement),this.composer=new Fw(this.renderer),this.composer.addPass(new Iw(this.scene,this.camera)),this.bloom=new Rw(new K(t,n),.62,.6,.04),this.composer.addPass(this.bloom),this._addGrid(),this._onMove=e=>{this._mx=e.clientX/window.innerWidth*2-1,this._my=e.clientY/window.innerHeight*2-1},window.addEventListener(`pointermove`,this._onMove),this._ro=new ResizeObserver(()=>this._resize()),this._ro.observe(e),this._raf=requestAnimationFrame(this._tick),this._load()}_addGrid(){let e=new rb(6,36,Bw,Bw);e.material.transparent=!0,e.material.opacity=.22,e.position.set(.1,-.32,-.2),this.scene.add(e),this._grid=e}async _load(){let e;try{e=await Tw()}catch(e){console.warn(`hero: robot load failed`,e);return}if(this._disposed)return;e.traverse(e=>{e.isMesh&&(e.material=new Pg({color:zw,wireframe:!0,transparent:!0,opacity:.7}))}),e.rotation.x=-Math.PI/2,this.pivot=new bh,this.pivot.rotation.y=-Math.PI/2,this.pivot.add(e),this.scene.add(this.pivot),this.robot=e,this.pivot.updateMatrixWorld(!0);let t=new Wh().setFromObject(e),n=t.getSize(new q),r=t.getCenter(new q),i=Math.max(n.x,n.y,n.z)*.5,a=i/Math.tan(this.camera.fov*Math.PI/360)*1.45;this._look=r.clone().add(new q(-i*.95,i*.95,0)),this.camera.position.set(r.x,this._look.y,r.z+a),this.camera.lookAt(this._look),this._grid.position.y=t.min.y-.02,this.head=e.links?.xl_330||null,this.head&&(this._headRestPos=this.head.position.clone(),this._parentWorldQuatInv=this.head.parent.getWorldQuaternion(new Tm).invert(),this._headRestWorldQuat=this.head.getWorldQuaternion(new Tm),this._restAntL=(this.head.parent,0)),this._euler=new nh,this._q=new Tm,this._qLocal=new Tm,this._tmp=new q}_tick=()=>{if(this._disposed)return;this._raf=requestAnimationFrame(this._tick);let e=Math.min(this._clock.getDelta(),.05);this._t+=e;let t=this._t;if(this._lx=Hw(this._lx,this._mx,1-Math.exp(-e/.18)),this._ly=Hw(this._ly,this._my,1-Math.exp(-e/.18)),this.robot&&this.head){let e=.005*Math.sin(Vw*.12*t),n=this._lx*.75,r=this._ly*.5,i=-this._lx*.12;this._euler.set(r,n,i,`XYZ`),this._q.setFromEuler(this._euler),this._qLocal.copy(this._parentWorldQuatInv).multiply(this._q).multiply(this._headRestWorldQuat),this.head.quaternion.copy(this._qLocal),this._tmp.set(0,e,0).applyQuaternion(this._parentWorldQuatInv),this.head.position.copy(this._headRestPos).add(this._tmp);let a=.26*Math.sin(Vw*.5*t)+Math.abs(this._lx)*.2;this.robot.setJointValue?.(`left_antenna`,a),this.robot.setJointValue?.(`right_antenna`,-a),this.pivot.rotation.y=-Math.PI/2+this._lx*.18}this.composer.render()};_resize(){let e=this.container.clientWidth,t=this.container.clientHeight;!e||!t||(this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.composer.setSize(e,t),this.bloom.setSize(e,t))}dispose(){this._disposed=!0,cancelAnimationFrame(this._raf),this._ro.disconnect(),window.removeEventListener(`pointermove`,this._onMove),this.composer.dispose?.(),this.renderer.dispose(),this.renderer.domElement.remove()}},Ww=document.getElementById(`lobby`),Gw=document.getElementById(`stage`),Kw=document.getElementById(`grid`),qw=document.getElementById(`spotlight`),Jw=document.getElementById(`spotMain`),Yw=document.getElementById(`spotStrip`),Xw=document.getElementById(`join`),Zw=document.getElementById(`demo`),Qw=document.getElementById(`status`),$w=new Map,eT=null,tT=null,nT=!1,rT=`grid`,iT=null,aT=new Uw(document.getElementById(`hero3d`));function oT(e,t){if(document.hidden)return t();let n=new Map(e.map(e=>[e,e.getBoundingClientRect()]));t();for(let t of e){let e=n.get(t),r=t.getBoundingClientRect();if(!e.width||!r.width)continue;let i=e.left-r.left,a=e.top-r.top,o=e.width/r.width,s=e.height/r.height;Math.abs(i)<1&&Math.abs(a)<1&&Math.abs(o-1)<.01||t.animate([{transform:`translate(${i}px, ${a}px) scale(${o}, ${s})`},{transform:`none`}],{duration:420,easing:`cubic-bezier(.4, 0, .2, 1)`})}}function sT(e=!0){let t=[...$w.values()].map(e=>e.el),n=()=>{if(rT===`spotlight`){Kw.classList.add(`hidden`),qw.classList.remove(`hidden`);let e=$w.has(iT)?iT:$w.keys().next().value;for(let[t,n]of $w)n.el.classList.toggle(`active`,t===e),(t===e?Jw:Yw).appendChild(n.el)}else{qw.classList.add(`hidden`),Kw.classList.remove(`hidden`);let e=Math.max($w.size,1);Kw.style.gridTemplateColumns=`repeat(${Math.ceil(Math.sqrt(e))}, minmax(0, 1fr))`;for(let e of $w.values())e.el.classList.remove(`active`),Kw.appendChild(e.el)}};e?oT(t,n):n()}function cT(e){e!==iT&&(iT=e,rT===`spotlight`&&sT(!0))}async function lT(e,t){let n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t||{})});if(!n.ok)throw Error(`${e} -> ${n.status}`);return n.json()}function uT(e){try{return e.metadata?JSON.parse(e.metadata):{}}catch{return{}}}function dT(e){if($w.has(e.identity))return $w.get(e.identity);let t=uT(e),n=t.color||`#c98a3c`,r=document.createElement(`div`);r.className=`card`,r.style.setProperty(`--accent`,n),r.innerHTML=` +
+
+
+ + + +
`,r.querySelector(`.name`).textContent=e.name||e.identity,r.querySelector(`.persona`).textContent=t.persona||``,(rT===`spotlight`?Yw:Kw).appendChild(r);let i={el:r,twin:new Ew(r.querySelector(`.twin`),{accent:n}),analyser:null,data:null,level:0};return $w.set(e.identity,i),sT(!0),i}function fT(e){let t=$w.get(e);t&&(t.twin.dispose(),t.el.remove(),$w.delete(e),e===iT&&(iT=null),sT(!0))}function pT(e,t){let n=dT(t),r=e.attach();r.classList.add(`hidden-audio`),document.body.appendChild(r),eT||=new AudioContext;let i=eT.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])),a=eT.createAnalyser();a.fftSize=256,i.connect(a),n.analyser=a,n.data=new Uint8Array(a.fftSize)}function mT(){requestAnimationFrame(mT);let e=null,t=0;for(let[n,r]of $w){if(!r.analyser)continue;r.analyser.getByteTimeDomainData(r.data);let i=0;for(let e=0;e.04),r.twin.level>t&&(t=r.twin.level,e=n)}e&&t>.06&&cT(e)}async function hT(){Xw.disabled=!0,Qw.textContent=`connecting…`;try{let{token:e,url:t}=await lT(`/api/token`,{name:`Audience`});tT=new tf,tT.on(z.TrackSubscribed,(e,t,n)=>{e.kind===U.Kind.Audio&&pT(e,n)}).on(z.ParticipantDisconnected,e=>fT(e.identity)).on(z.Disconnected,()=>{Qw.textContent=`disconnected`}),await tT.connect(t,e),await tT.startAudio();for(let e of tT.remoteParticipants.values())for(let t of e.trackPublications.values())t.track&&t.kind===U.Kind.Audio&&pT(t.track,e);nT=!0,aT&&=(aT.dispose(),null),Ww.classList.add(`hidden`),Gw.classList.remove(`hidden`),Qw.textContent=`live in "${tT.name}"`,mT()}catch(e){Qw.textContent=`error: ${e.message}`,Xw.disabled=!1}}var gT=document.getElementById(`demo2`),_T=document.getElementById(`chaos`),vT=document.getElementById(`chaos2`);async function yT(e,t,n){let r=[e,Zw,gT,_T,vT].filter(Boolean);r.forEach(e=>e.disabled=!0),e.textContent=`starting…`;try{nT||await hT(),rT=t.includes(`groupchat`)?`spotlight`:`grid`,iT=null,sT(!1),await lT(t,{}),e.textContent=`${n} running`}catch(t){e.textContent=`${n} failed`,Qw.textContent=`error: ${t.message}`}finally{r.forEach(e=>e.disabled=!1)}}Xw.addEventListener(`click`,hT),Zw.addEventListener(`click`,()=>yT(Zw,`/api/demo`,`podcast`)),gT.addEventListener(`click`,()=>yT(gT,`/api/demo`,`podcast`)),_T.addEventListener(`click`,()=>yT(_T,`/api/groupchat`,`group chat`)),vT.addEventListener(`click`,()=>yT(vT,`/api/groupchat`,`group chat`)); \ No newline at end of file diff --git a/frontend/dist/index.html b/frontend/dist/index.html new file mode 100644 index 0000000000000000000000000000000000000000..c5a8b4c97bb7aa56c52356aa4560a7882a6d132f --- /dev/null +++ b/frontend/dist/index.html @@ -0,0 +1,46 @@ + + + + + + Small Talk · an AI-to-AI robot podcast + + + + + +
+
+
+
+
SMALL TALK
+

The robots are
talking back.

+

+ An AI-to-AI podcast hosted by Reachy Minis — live over WebRTC, each with + its own voice, personality, and a 3D digital twin that emotes as it speaks. +

+
+ + + +
+
+
+
+ + + + + diff --git a/frontend/dist/moves/reachy-moves.json b/frontend/dist/moves/reachy-moves.json new file mode 100644 index 0000000000000000000000000000000000000000..97ffda6d664b859dc5bd4e9291a9ea743f691e60 --- /dev/null +++ b/frontend/dist/moves/reachy-moves.json @@ -0,0 +1 @@ +{"fps":33,"cols":["t","x","y","z","roll","pitch","yaw","antL","antR","bodyYaw"],"moves":{"yes1":{"kind":"emotion","duration":3.411,"frames":[[0.0,-0.0013,-0.0069,0.02,0.0508,0.0578,-0.1307,-0.1692,0.3677,0.0],[0.03,-0.0013,-0.0072,0.02,0.0507,0.0576,-0.1303,-0.1692,0.3677,0.0],[0.061,-0.0012,-0.0068,0.02,0.0504,0.0576,-0.1302,-0.1692,0.3677,0.0],[0.091,-0.0011,-0.0062,0.02,0.0506,0.0575,-0.1302,-0.1692,0.3677,0.0],[0.121,-0.0011,-0.006,0.02,0.051,0.0576,-0.1301,-0.1692,0.3677,0.0],[0.152,-0.001,-0.0062,0.02,0.0518,0.058,-0.1299,-0.1692,0.3677,0.0],[0.182,-0.0009,-0.0065,0.02,0.0519,0.0578,-0.1296,-0.1692,0.3677,0.0],[0.212,-0.001,-0.0067,0.02,0.0522,0.0577,-0.1293,-0.1692,0.3677,0.0],[0.242,-0.0011,-0.0072,0.02,0.0522,0.0575,-0.1288,-0.1692,0.3677,0.0],[0.273,-0.0012,-0.0076,0.02,0.052,0.0573,-0.1283,-0.1692,0.3677,0.0],[0.303,-0.0011,-0.0076,0.02,0.0523,0.0572,-0.1283,-0.1692,0.3677,0.0],[0.333,-0.0008,-0.0075,0.02,0.0529,0.0571,-0.1282,-0.1692,0.3677,0.0],[0.364,-0.0011,-0.0073,0.02,0.0531,0.0567,-0.1282,-0.1692,0.3677,0.0],[0.394,-0.0011,-0.0079,0.02,0.0536,0.0565,-0.128,-0.1692,0.3677,0.0],[0.424,-0.0012,-0.0084,0.02,0.0535,0.0563,-0.1277,-0.1692,0.3677,0.0],[0.455,-0.0012,-0.0085,0.02,0.0534,0.0561,-0.1278,-0.1692,0.3677,0.0],[0.485,-0.0015,-0.0086,0.02,0.0536,0.0554,-0.1283,-0.1692,0.3677,0.0],[0.515,-0.0013,-0.0075,0.02,0.0529,0.0561,-0.1287,-0.1692,0.3677,0.0],[0.545,-0.0011,-0.0065,0.02,0.053,0.0567,-0.1288,-0.1692,0.3677,0.0],[0.576,-0.0009,-0.0063,0.02,0.0527,0.0572,-0.1289,-0.1692,0.3677,0.0],[0.606,-0.0007,-0.0058,0.02,0.052,0.0576,-0.1291,-0.1692,0.3677,0.0],[0.636,-0.0006,-0.0054,0.02,0.0512,0.0577,-0.129,-0.1692,0.3677,0.0],[0.667,-0.0006,-0.0065,0.02,0.0509,0.0577,-0.1287,-0.1692,0.3677,0.0],[0.697,-0.0005,-0.0061,0.02,0.0509,0.0579,-0.1289,-0.1692,0.3677,0.0],[0.727,-0.0006,-0.0051,0.02,0.051,0.0582,-0.1292,-0.1692,0.3677,0.0],[0.758,-0.0006,-0.0048,0.02,0.0507,0.0591,-0.1294,-0.1692,0.3677,0.0],[0.788,-0.0005,-0.0047,0.02,0.0502,0.0596,-0.1297,-0.1692,0.3677,0.0],[0.818,-0.0007,-0.0067,0.02,0.0502,0.0597,-0.1289,-0.1692,0.3677,0.0],[0.848,-0.0006,-0.0068,0.02,0.0507,0.0597,-0.1285,-0.1692,0.3677,0.0],[0.879,-0.0009,-0.0067,0.02,0.0507,0.0596,-0.1284,-0.1692,0.3677,0.0],[0.909,-0.0007,-0.0059,0.02,0.0511,0.0594,-0.1285,-0.1692,0.3677,0.0],[0.939,-0.0007,-0.0061,0.02,0.0517,0.059,-0.1281,-0.1692,0.3677,0.0],[0.97,-0.0007,-0.0059,0.02,0.0521,0.0577,-0.1283,-0.1692,0.3677,0.0],[1.0,-0.0008,-0.0056,0.02,0.0524,0.0561,-0.1276,-0.1692,0.3677,0.0],[1.03,-0.0009,-0.0058,0.02,0.0531,0.0544,-0.1261,-0.1225,0.2901,0.0],[1.061,-0.001,-0.0065,0.02,0.0539,0.0534,-0.1245,-0.0456,0.2324,0.0],[1.091,-0.0011,-0.0062,0.02,0.0541,0.053,-0.1236,-0.0363,0.2487,0.0],[1.121,-0.0013,-0.0057,0.02,0.0527,0.052,-0.1226,-0.0993,0.3299,0.0],[1.152,-0.0013,-0.0057,0.02,0.0513,0.0521,-0.1204,-0.2009,0.432,0.0],[1.182,-0.0012,-0.0057,0.02,0.0514,0.0547,-0.1191,-0.2849,0.4987,0.0],[1.212,-0.0008,-0.0081,0.02,0.0524,0.0624,-0.1167,-0.3056,0.4937,0.0],[1.242,-0.0003,-0.009,0.02,0.051,0.0811,-0.115,-0.2517,0.4198,0.0],[1.273,0.001,-0.0078,0.02,0.0494,0.1064,-0.1166,-0.1532,0.3177,0.0],[1.303,0.0028,-0.007,0.02,0.0481,0.1422,-0.1229,-0.0626,0.2424,0.0],[1.333,0.0052,-0.0085,0.02,0.0487,0.1866,-0.1317,-0.031,0.236,0.0],[1.364,0.0075,-0.01,0.02,0.0536,0.2305,-0.1383,-0.0749,0.3017,0.0],[1.394,0.0094,-0.0105,0.02,0.0554,0.2763,-0.1417,-0.1704,0.4033,0.0],[1.424,0.0108,-0.0106,0.02,0.0562,0.3077,-0.1434,-0.2652,0.4856,0.0],[1.455,0.011,-0.0107,0.02,0.0564,0.3132,-0.1407,-0.3075,0.5033,0.0],[1.485,0.0102,-0.0088,0.02,0.0568,0.2864,-0.134,-0.2741,0.4469,0.0],[1.515,0.0083,-0.0081,0.02,0.0551,0.2348,-0.1282,-0.1838,0.3472,0.0],[1.545,0.0062,-0.0075,0.02,0.0516,0.1749,-0.1233,-0.0843,0.2587,0.0],[1.576,0.0041,-0.0076,0.02,0.0496,0.1428,-0.1189,-0.0323,0.2298,0.0],[1.606,0.0032,-0.0089,0.02,0.0489,0.1603,-0.1155,-0.0547,0.2763,0.0],[1.636,0.0035,-0.0105,0.02,0.0491,0.2076,-0.1124,-0.14,0.3729,0.0],[1.667,0.0047,-0.0112,0.02,0.0508,0.2622,-0.1137,-0.2408,0.4666,0.0],[1.697,0.0066,-0.012,0.02,0.0498,0.325,-0.1179,-0.3027,0.5062,0.0],[1.727,0.0083,-0.0116,0.02,0.0468,0.366,-0.1217,-0.2916,0.4702,0.0],[1.758,0.0087,-0.0112,0.02,0.0478,0.378,-0.1191,-0.2136,0.3781,0.0],[1.788,0.0091,-0.0101,0.02,0.0473,0.367,-0.1198,-0.1112,0.2803,0.0],[1.818,0.0082,-0.0091,0.02,0.0461,0.3318,-0.1196,-0.0406,0.2303,0.0],[1.848,0.0067,-0.0088,0.02,0.0459,0.2951,-0.1158,-0.0403,0.2554,0.0],[1.879,0.0055,-0.0085,0.02,0.0493,0.266,-0.1121,-0.1104,0.3421,0.0],[1.909,0.0045,-0.0077,0.02,0.0518,0.2389,-0.1133,-0.2131,0.4429,0.0],[1.939,0.0041,-0.0085,0.02,0.0521,0.2296,-0.1157,-0.2913,0.5024,0.0],[1.97,0.0047,-0.0097,0.02,0.053,0.2515,-0.1191,-0.303,0.4883,0.0],[2.0,0.0064,-0.0108,0.02,0.0464,0.3088,-0.1234,-0.2413,0.4081,0.0],[2.03,0.0083,-0.011,0.02,0.0402,0.3708,-0.1267,-0.1404,0.3059,0.0],[2.061,0.0091,-0.011,0.02,0.0371,0.3927,-0.1253,-0.0549,0.2374,0.0],[2.091,0.0099,-0.0105,0.02,0.0369,0.3927,-0.1205,-0.032,0.2401,0.0],[2.121,0.0099,-0.0095,0.02,0.0363,0.3927,-0.118,-0.0843,0.3127,0.0],[2.152,0.0093,-0.0084,0.02,0.04,0.3872,-0.116,-0.1828,0.4154,0.0],[2.182,0.0081,-0.0078,0.02,0.0432,0.339,-0.1162,-0.2238,0.4223,0.0],[2.212,0.0067,-0.0072,0.02,0.0416,0.2948,-0.1199,-0.2238,0.4223,0.0],[2.242,0.0063,-0.0074,0.02,0.0467,0.248,-0.1269,-0.2238,0.4223,0.0],[2.273,0.0067,-0.0081,0.02,0.0504,0.2258,-0.1359,-0.2238,0.4223,0.0],[2.303,0.0077,-0.0092,0.02,0.0475,0.2524,-0.1379,-0.2238,0.4223,0.0],[2.333,0.0082,-0.0107,0.02,0.0328,0.3361,-0.1271,-0.2238,0.4223,0.0],[2.364,0.0086,-0.0095,0.02,0.0234,0.3923,-0.1225,-0.2238,0.4223,0.0],[2.394,0.0096,-0.0106,0.02,0.0178,0.3927,-0.1186,-0.2238,0.4223,0.0],[2.424,0.0103,-0.01,0.02,0.0165,0.3927,-0.117,-0.2238,0.4223,0.0],[2.455,0.0106,-0.0098,0.02,0.0153,0.3927,-0.1142,-0.2238,0.4223,0.0],[2.485,0.0107,-0.0096,0.02,0.0138,0.3927,-0.1138,-0.2238,0.4223,0.0],[2.515,0.0101,-0.0093,0.02,0.0164,0.3927,-0.1103,-0.2238,0.4223,0.0],[2.545,0.0093,-0.0087,0.02,0.0225,0.3927,-0.1078,-0.2238,0.4223,0.0],[2.576,0.0081,-0.0078,0.02,0.0407,0.3885,-0.1104,-0.2238,0.4223,0.0],[2.606,0.0068,-0.0072,0.02,0.0548,0.2929,-0.1124,-0.2238,0.4223,0.0],[2.636,0.0057,-0.0067,0.02,0.0585,0.2159,-0.11,-0.2238,0.4223,0.0],[2.667,0.0049,-0.0067,0.02,0.0598,0.1542,-0.1103,-0.2238,0.4223,0.0],[2.697,0.0052,-0.0067,0.02,0.066,0.1005,-0.1119,-0.2238,0.4223,0.0],[2.727,0.0058,-0.0069,0.02,0.0687,0.055,-0.1099,-0.2238,0.4223,0.0],[2.758,0.0066,-0.0071,0.02,0.0666,0.0259,-0.1086,-0.2238,0.4223,0.0],[2.788,0.0041,-0.0059,0.02,0.0663,-0.0071,-0.1089,-0.2238,0.4223,0.0],[2.818,0.0041,-0.0062,0.02,0.067,-0.0277,-0.1084,-0.2238,0.4223,0.0],[2.848,0.0045,-0.0062,0.02,0.0683,-0.0371,-0.1112,-0.2238,0.4223,0.0],[2.879,0.0053,-0.0059,0.02,0.0684,-0.0452,-0.1128,-0.2238,0.4223,0.0],[2.909,0.0056,-0.0059,0.02,0.0709,-0.0478,-0.1148,-0.2238,0.4223,0.0],[2.939,0.0061,-0.0054,0.02,0.0734,-0.0463,-0.1183,-0.2238,0.4223,0.0],[2.97,0.0064,-0.0051,0.02,0.0751,-0.0442,-0.1214,-0.2238,0.4223,0.0],[3.0,0.0066,-0.005,0.02,0.0771,-0.0397,-0.1237,-0.2238,0.4223,0.0],[3.03,0.0069,-0.0048,0.02,0.0777,-0.034,-0.1255,-0.2238,0.4223,0.0],[3.061,0.007,-0.0046,0.02,0.0788,-0.0294,-0.1271,-0.2238,0.4223,0.0],[3.091,0.0072,-0.0042,0.02,0.0803,-0.0242,-0.129,-0.2238,0.4223,0.0],[3.121,0.0074,-0.004,0.02,0.081,-0.0192,-0.1316,-0.2238,0.4223,0.0],[3.152,0.0074,-0.0045,0.02,0.0822,-0.0163,-0.1332,-0.2238,0.4223,0.0],[3.182,0.0075,-0.0044,0.02,0.0828,-0.0144,-0.1344,-0.2238,0.4223,0.0],[3.212,0.0075,-0.0045,0.02,0.0835,-0.0128,-0.1353,-0.2238,0.4223,0.0],[3.242,0.0077,-0.0045,0.02,0.0845,-0.0111,-0.1357,-0.2238,0.4223,0.0],[3.273,0.0077,-0.0048,0.02,0.0856,-0.0094,-0.1364,-0.2238,0.4223,0.0],[3.303,0.0079,-0.0048,0.02,0.0864,-0.0067,-0.1369,-0.2238,0.4223,0.0],[3.333,0.0079,-0.0051,0.02,0.0876,-0.0038,-0.1373,-0.2238,0.4223,0.0],[3.364,0.0079,-0.0053,0.02,0.0892,-0.0005,-0.1378,-0.2238,0.4223,0.0],[3.394,0.008,-0.0052,0.02,0.0915,0.0034,-0.1385,-0.2238,0.4223,0.0]]},"understanding1":{"kind":"emotion","duration":3.954,"frames":[[0.0,-0.0012,-0.0178,0.02,0.0986,-0.0584,0.0029,-0.1204,0.1251,-0.0183],[0.03,-0.0013,-0.0161,0.02,0.0963,-0.0579,0.0042,-0.1204,0.1251,-0.0183],[0.061,-0.0012,-0.0159,0.02,0.0942,-0.0577,0.0055,-0.1204,0.1251,-0.0183],[0.091,-0.001,-0.0156,0.02,0.0932,-0.0573,0.0049,-0.1204,0.1251,-0.0183],[0.121,-0.0008,-0.0144,0.02,0.0931,-0.0598,0.002,-0.1204,0.1251,-0.0183],[0.152,-0.0007,-0.0136,0.02,0.0931,-0.0599,0.0018,-0.1204,0.1251,-0.0183],[0.182,-0.0005,-0.0128,0.02,0.0924,-0.0599,0.0014,-0.1204,0.1251,-0.0183],[0.212,-0.0005,-0.013,0.02,0.0929,-0.0595,0.0038,-0.1204,0.1251,-0.0183],[0.242,-0.0007,-0.0124,0.02,0.0924,-0.061,0.0063,-0.1204,0.1251,-0.0183],[0.273,-0.001,-0.0154,0.02,0.0935,-0.0603,0.0095,-0.1204,0.1251,-0.0183],[0.303,-0.0012,-0.0145,0.02,0.0928,-0.0614,0.0106,-0.1204,0.1251,-0.0183],[0.333,-0.0015,-0.0166,0.02,0.0936,-0.061,0.0151,-0.1204,0.1251,-0.0183],[0.364,-0.0019,-0.0179,0.02,0.0953,-0.0644,0.0208,-0.1204,0.1251,-0.0183],[0.394,-0.0018,-0.0179,0.02,0.0953,-0.0691,0.0241,-0.1204,0.1251,-0.0183],[0.424,-0.0015,-0.017,0.02,0.095,-0.0725,0.0263,-0.1204,0.1251,-0.0183],[0.455,-0.0014,-0.0198,0.02,0.0961,-0.0721,0.0313,-0.1204,0.1251,-0.0183],[0.485,-0.0014,-0.0208,0.02,0.0953,-0.0748,0.0342,-0.1204,0.1251,-0.0183],[0.515,-0.001,-0.0182,0.02,0.0927,-0.0788,0.0342,-0.1204,0.1251,-0.0183],[0.545,-0.0002,-0.017,0.02,0.091,-0.0819,0.0345,-0.1204,0.1251,-0.0183],[0.576,0.0001,-0.016,0.02,0.0907,-0.0833,0.0349,-0.1204,0.1251,-0.0183],[0.606,0.0004,-0.0149,0.02,0.0904,-0.084,0.0341,-0.1204,0.1251,-0.0183],[0.636,0.0006,-0.0149,0.02,0.0919,-0.0827,0.0347,-0.1204,0.1251,-0.0183],[0.667,0.0006,-0.0137,0.02,0.0923,-0.0832,0.0336,-0.1204,0.1251,-0.0183],[0.697,0.0005,-0.0153,0.02,0.0946,-0.0808,0.035,-0.1204,0.1251,-0.0183],[0.727,0.0006,-0.0142,0.02,0.095,-0.0807,0.0342,-0.1204,0.1251,-0.0183],[0.758,0.0009,-0.0124,0.02,0.0948,-0.081,0.0328,-0.1204,0.1251,-0.0183],[0.788,0.001,-0.0121,0.02,0.0952,-0.0806,0.032,-0.1204,0.1251,-0.0183],[0.818,0.0012,-0.0109,0.02,0.0967,-0.0789,0.0314,-0.1204,0.1251,-0.0183],[0.848,0.0014,-0.01,0.02,0.0996,-0.0763,0.0312,-0.1204,0.1251,-0.0183],[0.879,0.0012,-0.0124,0.02,0.1036,-0.0712,0.0339,-0.1204,0.1251,-0.0183],[0.909,0.0008,-0.0137,0.02,0.1057,-0.0686,0.0356,-0.1204,0.1251,-0.0183],[0.939,0.0006,-0.0132,0.02,0.1058,-0.0689,0.0354,-0.1204,0.1251,-0.0183],[0.97,0.0006,-0.0145,0.02,0.1078,-0.0673,0.0372,-0.1204,0.1251,-0.0183],[1.0,0.0001,-0.0161,0.02,0.1087,-0.0672,0.0388,-0.1204,0.1251,-0.0183],[1.03,-0.0002,-0.016,0.02,0.1083,-0.0691,0.0387,-0.1204,0.1251,-0.0183],[1.061,-0.0,-0.0151,0.02,0.1077,-0.0709,0.0389,-0.1204,0.1251,-0.0183],[1.091,-0.0,-0.0146,0.02,0.1071,-0.0726,0.0391,-0.1204,0.1251,-0.0183],[1.121,-0.0003,-0.0167,0.02,0.1086,-0.0729,0.0426,-0.1204,0.1251,-0.0183],[1.152,-0.001,-0.0188,0.02,0.11,-0.0726,0.0464,-0.1204,0.1251,-0.0183],[1.182,-0.0013,-0.0179,0.02,0.1098,-0.0737,0.0469,-0.1204,0.1251,-0.0183],[1.212,-0.0015,-0.017,0.02,0.11,-0.0742,0.0471,-0.1204,0.1251,-0.0183],[1.242,-0.0015,-0.0173,0.02,0.1132,-0.0695,0.0479,-0.1204,0.1251,-0.0183],[1.273,-0.0019,-0.0184,0.02,0.1156,-0.0623,0.0458,-0.13,0.1251,-0.0183],[1.303,-0.0023,-0.0209,0.02,0.1193,-0.0554,0.0465,-0.1491,0.1251,-0.0183],[1.333,-0.0027,-0.0217,0.02,0.1175,-0.0692,0.0553,-0.1683,0.1251,-0.0183],[1.364,-0.0027,-0.0205,0.02,0.1165,-0.066,0.0515,-0.1874,0.1251,-0.0183],[1.394,-0.0023,-0.0202,0.02,0.116,-0.0605,0.0483,-0.2066,0.1251,-0.0183],[1.424,-0.0019,-0.0191,0.02,0.1173,-0.0553,0.0452,-0.2258,0.1251,-0.0183],[1.455,-0.0014,-0.0181,0.02,0.1183,-0.05,0.0419,-0.2452,0.1311,-0.0183],[1.485,-0.0006,-0.0162,0.02,0.1186,-0.0445,0.0383,-0.2829,0.1931,-0.0183],[1.515,-0.0004,-0.0181,0.02,0.1229,-0.032,0.0369,-0.3531,0.2981,-0.0183],[1.545,-0.0001,-0.0192,0.02,0.1266,-0.02,0.0359,-0.4314,0.4166,-0.0183],[1.576,0.0003,-0.0203,0.02,0.1342,0.0,0.033,-0.5081,0.536,-0.0183],[1.606,0.0004,-0.0225,0.02,0.1437,0.0296,0.0327,-0.5672,0.6551,-0.0183],[1.636,0.0006,-0.0237,0.02,0.1517,0.0617,0.0315,-0.5865,0.7296,-0.0183],[1.667,0.0015,-0.0207,0.02,0.1574,0.0988,0.0298,-0.5865,0.7296,-0.0183],[1.697,0.002,-0.0194,0.02,0.1605,0.1207,0.0302,-0.5865,0.7296,-0.0183],[1.727,0.0021,-0.0186,0.02,0.1601,0.11,0.0323,-0.5865,0.7296,-0.0183],[1.758,0.002,-0.0172,0.02,0.1555,0.0847,0.0344,-0.5865,0.7296,-0.0183],[1.788,0.0016,-0.0195,0.02,0.144,0.0427,0.0442,-0.5865,0.7296,-0.0183],[1.818,0.0013,-0.0197,0.02,0.132,0.0068,0.0469,-0.5865,0.698,-0.0183],[1.848,0.0018,-0.0198,0.02,0.1302,0.0076,0.0444,-0.5741,0.6111,-0.0183],[1.879,0.0018,-0.0221,0.02,0.1402,0.0363,0.0427,-0.5324,0.492,-0.0183],[1.909,0.0021,-0.0209,0.02,0.1518,0.0711,0.0359,-0.4616,0.3641,-0.0183],[1.939,0.003,-0.0185,0.02,0.1649,0.1108,0.028,-0.383,0.2392,-0.0183],[1.97,0.0034,-0.0171,0.02,0.1669,0.1223,0.0293,-0.3162,0.2068,-0.0183],[2.0,0.0029,-0.016,0.02,0.1647,0.1103,0.0308,-0.313,0.2068,-0.0183],[2.03,0.0024,-0.0152,0.02,0.1597,0.0893,0.0297,-0.313,0.2068,-0.0183],[2.061,0.0026,-0.0147,0.02,0.1556,0.0762,0.025,-0.313,0.2068,-0.0183],[2.091,0.0034,-0.0143,0.02,0.1745,0.1169,0.0261,-0.313,0.2068,-0.0183],[2.121,0.0047,-0.0137,0.02,0.1878,0.1809,0.0274,-0.313,0.2068,-0.0183],[2.152,0.0051,-0.0128,0.02,0.194,0.216,0.0278,-0.313,0.2068,-0.0183],[2.182,0.0045,-0.0116,0.02,0.1926,0.2231,0.0299,-0.313,0.2068,-0.0183],[2.212,0.004,-0.0117,0.02,0.1926,0.1955,0.0314,-0.313,0.2131,-0.0183],[2.242,0.0037,-0.0113,0.02,0.1859,0.159,0.0294,-0.3297,0.2507,-0.0183],[2.273,0.0036,-0.0118,0.02,0.1791,0.1367,0.0302,-0.3934,0.3037,-0.0183],[2.303,0.0042,-0.012,0.02,0.1812,0.1293,0.0337,-0.4615,0.3574,-0.0183],[2.333,0.004,-0.0121,0.02,0.1883,0.1383,0.039,-0.4771,0.3713,-0.0183],[2.364,0.0028,-0.016,0.02,0.1908,0.1318,0.0433,-0.4771,0.3713,-0.0183],[2.394,0.002,-0.0162,0.02,0.1858,0.1088,0.0431,-0.4771,0.3713,-0.0183],[2.424,0.0017,-0.0158,0.02,0.18,0.0919,0.0417,-0.4771,0.3713,-0.0183],[2.455,0.0016,-0.0159,0.02,0.1669,0.0634,0.04,-0.4771,0.3713,-0.0183],[2.485,-0.0007,-0.0185,0.02,0.1488,0.0196,0.0373,-0.4771,0.3713,-0.0183],[2.515,-0.0022,-0.018,0.02,0.1403,-0.0077,0.0387,-0.4771,0.3713,-0.0183],[2.545,-0.0015,-0.0176,0.02,0.1372,-0.0255,0.032,-0.4698,0.3548,-0.0183],[2.576,-0.001,-0.0179,0.02,0.1312,-0.0517,0.0276,-0.4282,0.2874,-0.0183],[2.606,-0.0017,-0.0176,0.02,0.1222,-0.079,0.0297,-0.3408,0.1697,-0.0183],[2.636,-0.0015,-0.0168,0.02,0.1182,-0.1042,0.0331,-0.2301,0.0422,-0.0183],[2.667,-0.0007,-0.0163,0.02,0.1155,-0.1317,0.0272,-0.2013,-0.0051,-0.0183],[2.697,-0.0005,-0.0185,0.02,0.1158,-0.1477,0.0278,-0.2013,-0.0051,-0.0183],[2.727,-0.0011,-0.0206,0.02,0.1148,-0.1615,0.0332,-0.2013,-0.0051,-0.0183],[2.758,-0.001,-0.0206,0.02,0.1092,-0.1709,0.0363,-0.2013,-0.0051,-0.0183],[2.788,-0.0001,-0.0166,0.02,0.099,-0.1866,0.0362,-0.2013,-0.0051,-0.0183],[2.818,0.0,-0.0147,0.02,0.0821,-0.2125,0.0351,-0.2013,-0.0051,-0.0183],[2.848,-0.0006,-0.0136,0.02,0.0676,-0.244,0.0431,-0.2013,-0.0051,-0.0183],[2.879,-0.0009,-0.0134,0.02,0.0588,-0.2608,0.0512,-0.2013,-0.0051,-0.0183],[2.909,-0.001,-0.0161,0.02,0.0592,-0.2535,0.0537,-0.2013,-0.0051,-0.0183],[2.939,-0.001,-0.0167,0.02,0.057,-0.2492,0.0522,-0.2013,-0.0051,-0.0183],[2.97,-0.0019,-0.0182,0.02,0.0682,-0.2275,0.056,-0.2013,-0.0051,-0.0183],[3.0,-0.0021,-0.0173,0.02,0.0921,-0.1784,0.0569,-0.2013,-0.0051,-0.0183],[3.03,-0.0013,-0.014,0.02,0.105,-0.1493,0.0551,-0.2013,-0.0051,-0.0183],[3.061,-0.0013,-0.0149,0.02,0.1021,-0.1586,0.0591,-0.2013,-0.0051,-0.0183],[3.091,-0.0017,-0.0153,0.02,0.0909,-0.1771,0.0605,-0.2013,-0.0051,-0.0183],[3.121,-0.0018,-0.0148,0.02,0.0809,-0.1869,0.0564,-0.2013,-0.0051,-0.0183],[3.152,-0.0019,-0.013,0.02,0.0746,-0.1979,0.0544,-0.2013,-0.0051,-0.0183],[3.182,-0.0026,-0.0131,0.02,0.0644,-0.2258,0.0572,-0.2013,-0.0051,-0.0183],[3.212,-0.003,-0.0149,0.02,0.0557,-0.2421,0.0589,-0.2013,-0.0051,-0.0183],[3.242,-0.0028,-0.018,0.02,0.0527,-0.239,0.0565,-0.2013,-0.0051,-0.0183],[3.273,-0.0041,-0.0212,0.02,0.0549,-0.2329,0.0591,-0.2013,-0.0051,-0.0183],[3.303,-0.0054,-0.0212,0.02,0.0597,-0.2332,0.0658,-0.2013,-0.0051,-0.0183],[3.333,-0.0057,-0.0235,0.02,0.0635,-0.2328,0.0692,-0.2013,-0.0051,-0.0183],[3.364,-0.0046,-0.0249,0.02,0.0588,-0.2273,0.0656,-0.2013,-0.0051,-0.0183],[3.394,-0.0047,-0.0252,0.02,0.0518,-0.2343,0.0694,-0.2013,-0.0051,-0.0183],[3.424,-0.0063,-0.0252,0.02,0.0484,-0.2545,0.082,-0.2013,-0.0051,-0.0183],[3.455,-0.0069,-0.0251,0.02,0.0498,-0.26,0.0899,-0.2013,-0.0051,-0.0183],[3.485,-0.0059,-0.025,0.02,0.0547,-0.2446,0.0811,-0.2013,-0.0051,-0.0183],[3.515,-0.005,-0.0254,0.02,0.0561,-0.2276,0.0736,-0.2013,-0.0051,-0.0183],[3.545,-0.0053,-0.0257,0.02,0.0534,-0.231,0.0758,-0.2013,-0.0051,-0.0183],[3.576,-0.0051,-0.0254,0.02,0.0545,-0.2351,0.0795,-0.2013,-0.0051,-0.0183],[3.606,-0.0054,-0.0269,0.02,0.0575,-0.2279,0.0772,-0.2013,-0.0051,-0.0183],[3.636,-0.005,-0.0263,0.02,0.0588,-0.2187,0.0749,-0.2013,-0.0051,-0.0183],[3.667,-0.005,-0.0252,0.02,0.0582,-0.2188,0.0769,-0.2013,-0.0051,-0.0183],[3.697,-0.0042,-0.0218,0.02,0.0591,-0.2178,0.0768,-0.2013,-0.0051,-0.0183],[3.727,-0.0033,-0.0188,0.02,0.0617,-0.2124,0.0727,-0.2013,-0.0051,-0.0183],[3.758,-0.0027,-0.0175,0.02,0.0664,-0.2053,0.0709,-0.2013,-0.0051,-0.0183],[3.788,-0.0028,-0.0168,0.02,0.071,-0.1987,0.0703,-0.2013,-0.0051,-0.0183],[3.818,-0.0026,-0.0167,0.02,0.0744,-0.1922,0.0692,-0.2013,-0.0051,-0.0183],[3.848,-0.002,-0.0145,0.02,0.0767,-0.1872,0.067,-0.2013,-0.0051,-0.0183],[3.879,-0.0015,-0.0131,0.02,0.079,-0.1828,0.0651,-0.2013,-0.0051,-0.0183],[3.909,-0.0011,-0.0123,0.02,0.0809,-0.1803,0.0641,-0.2013,-0.0051,-0.0183],[3.939,-0.001,-0.0142,0.02,0.0838,-0.1763,0.0645,-0.2013,-0.0051,-0.0183]]},"attentive1":{"kind":"emotion","duration":4.287,"frames":[[0.0,-0.0033,-0.0052,0.0065,-0.0336,-0.3061,0.0414,-0.5098,0.647,0.0185],[0.03,-0.0033,-0.0051,0.0064,-0.0336,-0.3066,0.0418,-0.5098,0.6534,0.0185],[0.061,-0.003,-0.0048,0.006,-0.0314,-0.3026,0.0419,-0.5098,0.668,0.0185],[0.091,-0.0031,-0.0046,0.0054,-0.0258,-0.2812,0.0419,-0.5098,0.6826,0.0185],[0.121,-0.0034,-0.0044,0.0046,-0.0144,-0.2411,0.0411,-0.5098,0.6869,0.0185],[0.152,-0.0037,-0.0042,0.0045,-0.0141,-0.2283,0.0401,-0.5098,0.6869,0.0185],[0.182,-0.0036,-0.0045,0.0049,-0.024,-0.2463,0.0427,-0.5098,0.6869,0.0185],[0.212,-0.0034,-0.0049,0.0052,-0.034,-0.2688,0.0444,-0.5098,0.6869,0.0185],[0.242,-0.0034,-0.0051,0.0054,-0.039,-0.2871,0.0468,-0.5098,0.6869,0.0185],[0.273,-0.0033,-0.0052,0.0056,-0.0411,-0.2979,0.0482,-0.5098,0.6869,0.0185],[0.303,-0.0032,-0.0051,0.0056,-0.0408,-0.3021,0.0477,-0.5098,0.6876,0.0185],[0.333,-0.0033,-0.005,0.0056,-0.0387,-0.2997,0.0474,-0.5098,0.7158,0.0185],[0.364,-0.0031,-0.0049,0.0055,-0.0369,-0.3014,0.0483,-0.5098,0.7587,0.0185],[0.394,-0.0029,-0.0048,0.0054,-0.0382,-0.3117,0.0489,-0.5098,0.8041,0.0185],[0.424,-0.003,-0.0045,0.0055,-0.0391,-0.3264,0.0512,-0.5098,0.8488,0.0185],[0.455,-0.0031,-0.0042,0.0057,-0.0414,-0.3429,0.0556,-0.5098,0.8862,0.0185],[0.485,-0.003,-0.0042,0.0057,-0.04,-0.3524,0.0583,-0.5098,0.8908,0.0185],[0.515,-0.0029,-0.0041,0.0057,-0.0412,-0.3637,0.0605,-0.5098,0.8908,0.0185],[0.545,-0.0032,-0.0042,0.0061,-0.0457,-0.3749,0.0602,-0.5098,0.8908,0.0185],[0.576,-0.0033,-0.0045,0.0059,-0.0432,-0.3585,0.0552,-0.5098,0.8908,0.0185],[0.606,-0.0038,-0.0044,0.0056,-0.0374,-0.3289,0.0507,-0.5098,0.8908,0.0185],[0.636,-0.0042,-0.004,0.0054,-0.0317,-0.3019,0.0509,-0.5098,0.8908,0.0185],[0.667,-0.0043,-0.0037,0.0046,-0.02,-0.2597,0.0482,-0.5098,0.8908,0.0185],[0.697,-0.0044,-0.0034,0.0041,-0.0132,-0.2225,0.0427,-0.5098,0.8908,0.0185],[0.727,-0.0046,-0.0031,0.0044,-0.0095,-0.201,0.0375,-0.5098,0.8908,0.0185],[0.758,-0.0048,-0.003,0.0044,-0.0086,-0.1851,0.0348,-0.5085,0.8908,0.0185],[0.788,-0.0049,-0.003,0.0043,-0.0086,-0.1638,0.03,-0.4901,0.8908,0.0185],[0.818,-0.0054,-0.0029,0.0044,-0.006,-0.1437,0.0258,-0.4636,0.8898,0.0185],[0.848,-0.0056,-0.0027,0.0045,-0.0025,-0.1301,0.0243,-0.4329,0.8632,0.0185],[0.879,-0.0057,-0.003,0.005,-0.0021,-0.126,0.0239,-0.3932,0.792,0.0185],[0.909,-0.0057,-0.0033,0.0052,-0.0026,-0.1236,0.0238,-0.3339,0.7133,0.0185],[0.939,-0.0059,-0.0033,0.0054,-0.0011,-0.1149,0.0229,-0.2561,0.6342,0.0185],[0.97,-0.0062,-0.0031,0.0053,0.0017,-0.1013,0.0201,-0.181,0.5555,0.0185],[1.0,-0.0062,-0.0033,0.0056,0.0028,-0.0956,0.0203,-0.158,0.4934,0.0185],[1.03,-0.0062,-0.0034,0.0057,0.0022,-0.0948,0.0193,-0.158,0.4818,0.0185],[1.061,-0.0063,-0.0034,0.0059,-0.0001,-0.0967,0.0182,-0.158,0.4818,0.0185],[1.091,-0.0061,-0.0036,0.0063,-0.0087,-0.1253,0.024,-0.158,0.4818,0.0185],[1.121,-0.0056,-0.0043,0.0067,-0.0179,-0.1618,0.0295,-0.158,0.4818,0.0185],[1.152,-0.0053,-0.0048,0.0067,-0.0253,-0.1889,0.0346,-0.158,0.4818,0.0185],[1.182,-0.0052,-0.0051,0.0071,-0.0324,-0.2182,0.0424,-0.158,0.4818,0.0185],[1.212,-0.0051,-0.0051,0.0073,-0.0361,-0.2355,0.0464,-0.158,0.4818,0.0185],[1.242,-0.0049,-0.0051,0.0075,-0.0412,-0.2555,0.0501,-0.158,0.4818,0.0185],[1.273,-0.0047,-0.0052,0.0076,-0.0431,-0.2673,0.0526,-0.158,0.4818,0.0185],[1.303,-0.0046,-0.0053,0.0076,-0.0442,-0.2749,0.054,-0.158,0.4818,0.0185],[1.333,-0.0046,-0.0051,0.0076,-0.0439,-0.2723,0.0531,-0.158,0.4818,0.0185],[1.364,-0.0047,-0.0049,0.0075,-0.0431,-0.2677,0.0509,-0.1595,0.4818,0.0185],[1.394,-0.0049,-0.0045,0.0071,-0.0352,-0.2478,0.0473,-0.1781,0.4846,0.0185],[1.424,-0.0053,-0.004,0.0064,-0.0247,-0.2136,0.0412,-0.2172,0.513,0.0185],[1.455,-0.0057,-0.0035,0.0061,-0.0168,-0.1869,0.0374,-0.272,0.5635,0.0185],[1.485,-0.0059,-0.0032,0.0058,-0.009,-0.1566,0.0341,-0.3266,0.6185,0.0185],[1.515,-0.0062,-0.0031,0.0057,-0.0055,-0.1368,0.0305,-0.3366,0.6638,0.0185],[1.545,-0.0064,-0.0029,0.0056,-0.0017,-0.1232,0.0285,-0.3366,0.6673,0.0185],[1.576,-0.0066,-0.0029,0.0054,-0.002,-0.1196,0.0283,-0.3366,0.6673,0.0185],[1.606,-0.0065,-0.0032,0.0059,-0.0093,-0.1349,0.0303,-0.3366,0.6673,0.0185],[1.636,-0.0063,-0.0037,0.0063,-0.0203,-0.1578,0.0327,-0.3366,0.6673,0.0185],[1.667,-0.0061,-0.0042,0.0067,-0.0305,-0.1761,0.0343,-0.3366,0.6673,0.0185],[1.697,-0.006,-0.0045,0.0069,-0.038,-0.1906,0.0355,-0.3366,0.6673,0.0185],[1.727,-0.0058,-0.0045,0.0066,-0.034,-0.1837,0.0353,-0.3366,0.6701,0.0185],[1.758,-0.0061,-0.0039,0.006,-0.0183,-0.1507,0.0334,-0.3366,0.6944,0.0185],[1.788,-0.0064,-0.0035,0.0054,-0.0043,-0.1239,0.0334,-0.3366,0.7359,0.0185],[1.818,-0.0065,-0.0032,0.0052,0.0036,-0.1089,0.0337,-0.3366,0.7905,0.0185],[1.848,-0.0066,-0.003,0.0051,0.0053,-0.1053,0.0339,-0.3366,0.8546,0.0185],[1.879,-0.0063,-0.0033,0.0055,-0.004,-0.1243,0.0362,-0.3366,0.921,0.0185],[1.909,-0.0057,-0.0038,0.0061,-0.021,-0.1604,0.0382,-0.3366,0.9653,0.0185],[1.939,-0.0053,-0.0043,0.0063,-0.0308,-0.1873,0.0404,-0.3366,0.9666,0.0185],[1.97,-0.0051,-0.0046,0.0061,-0.033,-0.1921,0.0401,-0.3398,0.9666,0.0185],[2.0,-0.0052,-0.0043,0.0059,-0.0253,-0.1788,0.0396,-0.3629,0.9666,0.0185],[2.03,-0.0054,-0.0038,0.0055,-0.0133,-0.1584,0.0405,-0.398,0.9666,0.0185],[2.061,-0.0057,-0.0033,0.005,-0.0013,-0.1321,0.0401,-0.4371,0.9666,0.0185],[2.091,-0.006,-0.003,0.0046,0.0078,-0.109,0.0404,-0.4766,0.9666,0.0185],[2.121,-0.006,-0.0031,0.0047,0.0033,-0.1138,0.0407,-0.5262,0.9666,0.0185],[2.152,-0.0058,-0.0033,0.005,-0.0078,-0.1309,0.0391,-0.5815,0.9666,0.0185],[2.182,-0.0056,-0.0035,0.0054,-0.0165,-0.147,0.0388,-0.6001,0.9666,0.0185],[2.212,-0.0055,-0.0035,0.0059,-0.027,-0.1709,0.0392,-0.6001,0.9666,0.0185],[2.242,-0.0054,-0.0039,0.0061,-0.0331,-0.1862,0.0394,-0.6001,0.9666,0.0185],[2.273,-0.0052,-0.0041,0.006,-0.0368,-0.1935,0.0392,-0.6001,0.9666,0.0185],[2.303,-0.0053,-0.0041,0.0062,-0.0409,-0.2033,0.0401,-0.6001,0.9666,0.0185],[2.333,-0.0053,-0.0042,0.0067,-0.0501,-0.2254,0.0413,-0.6001,0.9666,0.0185],[2.364,-0.0053,-0.0044,0.0073,-0.0544,-0.2411,0.0427,-0.6001,0.9666,0.0185],[2.394,-0.0055,-0.0045,0.0078,-0.0576,-0.2585,0.0447,-0.6001,0.9666,0.0185],[2.424,-0.0054,-0.0042,0.0081,-0.059,-0.2807,0.0487,-0.6001,0.9666,0.0185],[2.455,-0.0053,-0.0043,0.0082,-0.06,-0.2959,0.051,-0.6001,0.9666,0.0185],[2.485,-0.0053,-0.0044,0.0084,-0.0577,-0.3044,0.0521,-0.6001,0.9666,0.0185],[2.515,-0.0054,-0.0044,0.0085,-0.0566,-0.3064,0.0524,-0.5932,0.9666,0.0185],[2.545,-0.0055,-0.0044,0.0086,-0.0556,-0.3088,0.0527,-0.5661,0.9666,0.0185],[2.576,-0.0054,-0.0043,0.0086,-0.0551,-0.3083,0.0519,-0.5032,0.9638,0.0185],[2.606,-0.0054,-0.0042,0.0084,-0.0548,-0.3083,0.0518,-0.4245,0.9439,0.0185],[2.636,-0.0054,-0.0042,0.0083,-0.0541,-0.3075,0.0517,-0.3458,0.9021,0.0185],[2.667,-0.0054,-0.0042,0.0083,-0.054,-0.3065,0.0514,-0.2698,0.8502,0.0185],[2.697,-0.0054,-0.0043,0.0083,-0.0536,-0.3068,0.0511,-0.2429,0.8075,0.0185],[2.727,-0.0053,-0.0044,0.0085,-0.053,-0.3062,0.0507,-0.2429,0.8075,0.0185],[2.758,-0.0053,-0.0044,0.0083,-0.0528,-0.3059,0.0505,-0.2429,0.8075,0.0185],[2.788,-0.0051,-0.0046,0.0082,-0.0524,-0.3038,0.05,-0.2429,0.8075,0.0185],[2.818,-0.0051,-0.0047,0.0081,-0.0516,-0.2982,0.049,-0.2429,0.8075,0.0185],[2.848,-0.0053,-0.0046,0.0081,-0.0494,-0.292,0.0486,-0.2429,0.8075,0.0185],[2.879,-0.0053,-0.0045,0.0081,-0.047,-0.2816,0.0481,-0.2429,0.8004,0.0185],[2.909,-0.0053,-0.0045,0.0079,-0.044,-0.2703,0.0474,-0.2429,0.7754,0.0185],[2.939,-0.0053,-0.0045,0.0077,-0.0401,-0.2545,0.0461,-0.2429,0.7392,0.0185],[2.97,-0.0055,-0.0043,0.0075,-0.0372,-0.2398,0.0433,-0.2429,0.7005,0.0185],[3.0,-0.0056,-0.0039,0.0071,-0.0341,-0.2251,0.0406,-0.2429,0.6626,0.0185],[3.03,-0.0058,-0.0038,0.007,-0.0305,-0.2132,0.0386,-0.2429,0.6542,0.0185],[3.061,-0.0058,-0.0038,0.0066,-0.0267,-0.2021,0.037,-0.2429,0.6542,0.0185],[3.091,-0.0059,-0.0037,0.0065,-0.025,-0.1967,0.0361,-0.2429,0.6542,0.0185],[3.121,-0.0058,-0.0038,0.0066,-0.0221,-0.1879,0.0345,-0.2429,0.6542,0.0185],[3.152,-0.0058,-0.0038,0.0066,-0.0197,-0.1796,0.033,-0.2429,0.6542,0.0185],[3.182,-0.006,-0.0037,0.0066,-0.0173,-0.1733,0.0319,-0.2429,0.6542,0.0185],[3.212,-0.006,-0.0036,0.0063,-0.0132,-0.1615,0.0295,-0.2422,0.6542,0.0185],[3.242,-0.0062,-0.0036,0.0062,-0.0106,-0.1502,0.0271,-0.2226,0.6542,0.0185],[3.273,-0.0063,-0.0034,0.006,-0.0063,-0.1339,0.0248,-0.1777,0.6542,0.0185],[3.303,-0.0064,-0.0033,0.006,-0.005,-0.1261,0.0239,-0.1358,0.6542,0.0185],[3.333,-0.0066,-0.0031,0.006,-0.0049,-0.1246,0.0234,-0.1296,0.6542,0.0185],[3.364,-0.0065,-0.003,0.0059,-0.0032,-0.1177,0.0226,-0.1296,0.6542,0.0185],[3.394,-0.0066,-0.0029,0.0057,-0.0015,-0.1112,0.0222,-0.1296,0.6542,0.0185],[3.424,-0.0066,-0.0029,0.0056,-0.0011,-0.1101,0.0224,-0.1296,0.6542,0.0185],[3.455,-0.0066,-0.0029,0.0056,-0.0011,-0.1095,0.0222,-0.1296,0.6542,0.0185],[3.485,-0.0067,-0.0029,0.0057,-0.0007,-0.1081,0.0217,-0.1296,0.6542,0.0185],[3.515,-0.0067,-0.0028,0.0056,-0.0001,-0.1081,0.0216,-0.1296,0.6542,0.0185],[3.545,-0.0065,-0.0028,0.0056,0.0004,-0.1076,0.0213,-0.1296,0.6542,0.0185],[3.576,-0.0064,-0.0029,0.0055,0.0009,-0.1065,0.0212,-0.1296,0.6542,0.0185],[3.606,-0.0063,-0.0029,0.0054,0.0008,-0.1074,0.0216,-0.1296,0.6603,0.0185],[3.636,-0.0062,-0.003,0.0054,-0.0008,-0.1118,0.0225,-0.1296,0.6833,0.0185],[3.667,-0.006,-0.0034,0.0059,-0.0081,-0.1438,0.0306,-0.1296,0.72,0.0185],[3.697,-0.0058,-0.004,0.0066,-0.0192,-0.1917,0.038,-0.1296,0.7599,0.0185],[3.727,-0.0056,-0.0044,0.0068,-0.0251,-0.2177,0.0425,-0.1296,0.7989,0.0185],[3.758,-0.0052,-0.0047,0.0067,-0.0271,-0.2312,0.0447,-0.1296,0.8052,0.0185],[3.788,-0.0049,-0.0048,0.0062,-0.0216,-0.2178,0.0434,-0.1296,0.8052,0.0185],[3.818,-0.0051,-0.0042,0.0054,-0.0066,-0.1822,0.0411,-0.1296,0.8052,0.0185],[3.848,-0.0057,-0.0036,0.005,0.0067,-0.1461,0.0447,-0.1296,0.8052,0.0185],[3.879,-0.006,-0.0031,0.0049,0.0095,-0.1325,0.0463,-0.1296,0.8052,0.0185],[3.909,-0.006,-0.003,0.0048,0.0089,-0.1238,0.0466,-0.1296,0.8052,0.0185],[3.939,-0.0058,-0.0034,0.0052,-0.0042,-0.1443,0.047,-0.1296,0.8052,0.0185],[3.97,-0.0055,-0.004,0.0061,-0.025,-0.1921,0.0525,-0.1296,0.8052,0.0185],[4.0,-0.0049,-0.0048,0.0068,-0.0428,-0.2339,0.0543,-0.1296,0.8052,0.0185],[4.03,-0.0049,-0.0051,0.0071,-0.0473,-0.2502,0.055,-0.1296,0.8052,0.0185],[4.061,-0.0047,-0.0052,0.0071,-0.0466,-0.2546,0.0541,-0.1296,0.8052,0.0185],[4.091,-0.0047,-0.0049,0.0066,-0.0356,-0.2343,0.0512,-0.1296,0.8052,0.0185],[4.121,-0.0051,-0.0044,0.0061,-0.0212,-0.2015,0.0479,-0.1296,0.8052,0.0185],[4.152,-0.0053,-0.004,0.0057,-0.0114,-0.1783,0.0474,-0.1296,0.8052,0.0185],[4.182,-0.0051,-0.0039,0.006,-0.016,-0.186,0.0483,-0.1296,0.8052,0.0185],[4.212,-0.0046,-0.0043,0.0064,-0.0317,-0.2158,0.0487,-0.1296,0.8052,0.0185],[4.242,-0.0041,-0.0049,0.007,-0.0443,-0.2455,0.05,-0.1296,0.8052,0.0185],[4.273,-0.0038,-0.0052,0.0073,-0.0502,-0.2637,0.0512,-0.1296,0.8052,0.0185]]},"attentive2":{"kind":"emotion","duration":6.0,"frames":[[0.0,-0.0038,-0.0063,0.0042,-0.0714,-0.0546,0.1065,-0.5828,0.7437,0.0185],[0.03,-0.0037,-0.0063,0.0039,-0.0622,-0.053,0.1059,-0.6052,0.7626,0.0185],[0.061,-0.0036,-0.0062,0.0038,-0.0497,-0.052,0.1066,-0.6162,0.7694,0.0185],[0.091,-0.0038,-0.0058,0.0037,-0.0397,-0.0508,0.1064,-0.6144,0.7634,0.0185],[0.121,-0.004,-0.0054,0.0038,-0.0261,-0.049,0.1064,-0.6002,0.7453,0.0185],[0.152,-0.004,-0.005,0.0036,-0.0111,-0.0477,0.1068,-0.5748,0.7166,0.0185],[0.182,-0.0039,-0.0048,0.0034,0.003,-0.047,0.1064,-0.5413,0.6809,0.0185],[0.212,-0.0039,-0.0047,0.0033,0.0217,-0.0478,0.1061,-0.5008,0.639,0.0185],[0.242,-0.0041,-0.0042,0.0034,0.0403,-0.0483,0.105,-0.4583,0.5969,0.0185],[0.273,-0.0041,-0.0036,0.0034,0.0641,-0.0499,0.1038,-0.418,0.5579,0.0185],[0.303,-0.0039,-0.0034,0.0035,0.0894,-0.0528,0.1032,-0.3829,0.5255,0.0185],[0.333,-0.0039,-0.0035,0.0037,0.105,-0.0557,0.1021,-0.3566,0.5026,0.0185],[0.364,-0.0034,-0.0044,0.0043,0.1168,-0.0581,0.1014,-0.3413,0.4912,0.0185],[0.394,-0.0036,-0.0042,0.0045,0.1296,-0.0588,0.1002,-0.3384,0.4925,0.0185],[0.424,-0.0037,-0.004,0.0046,0.144,-0.0608,0.1001,-0.3481,0.5063,0.0185],[0.455,-0.0031,-0.0049,0.0054,0.1549,-0.0633,0.1001,-0.3696,0.5314,0.0185],[0.485,-0.0032,-0.0048,0.0056,0.1652,-0.0641,0.1,-0.401,0.5654,0.0185],[0.515,-0.003,-0.0052,0.0058,0.1767,-0.0642,0.1006,-0.4392,0.6052,0.0185],[0.545,-0.0029,-0.0054,0.006,0.1865,-0.0654,0.1011,-0.4811,0.6473,0.0185],[0.576,-0.003,-0.0052,0.006,0.196,-0.0651,0.1011,-0.5225,0.6879,0.0185],[0.606,-0.0032,-0.0047,0.0058,0.2026,-0.0653,0.1007,-0.5599,0.7231,0.0185],[0.636,-0.0031,-0.0046,0.0059,0.2047,-0.0651,0.0995,-0.5898,0.7498,0.0185],[0.667,-0.0032,-0.0041,0.0054,0.2066,-0.0647,0.0982,-0.6093,0.7655,0.0185],[0.697,-0.0031,-0.0043,0.0052,0.2064,-0.0633,0.0975,-0.6169,0.7689,0.0185],[0.727,-0.0033,-0.0039,0.0047,0.2064,-0.0629,0.0967,-0.6118,0.7596,0.0185],[0.758,-0.0034,-0.0033,0.0044,0.2096,-0.0589,0.0963,-0.5944,0.7385,0.0185],[0.788,-0.0034,-0.003,0.0042,0.2096,-0.057,0.0959,-0.5663,0.7074,0.0185],[0.818,-0.0034,-0.0026,0.0036,0.2096,-0.0554,0.095,-0.5305,0.6694,0.0185],[0.848,-0.0033,-0.0024,0.0032,0.2092,-0.0542,0.0945,-0.4894,0.6276,0.0185],[0.879,-0.0033,-0.0021,0.0028,0.2078,-0.0533,0.0938,-0.4473,0.5861,0.0185],[0.909,-0.0036,-0.0018,0.0026,0.2044,-0.0526,0.0926,-0.4081,0.5486,0.0185],[0.939,-0.0031,-0.0027,0.0029,0.202,-0.0524,0.0922,-0.3751,0.5184,0.0185],[0.97,-0.0031,-0.0026,0.0029,0.1983,-0.0515,0.0912,-0.3515,0.4984,0.0185],[1.0,-0.0027,-0.0033,0.003,0.1964,-0.0515,0.0912,-0.3394,0.4904,0.0185],[1.03,-0.0027,-0.0035,0.0033,0.195,-0.0513,0.0912,-0.3398,0.4951,0.0185],[1.061,-0.0025,-0.0041,0.0037,0.1933,-0.0514,0.0913,-0.3527,0.512,0.0185],[1.091,-0.0026,-0.0038,0.0036,0.1907,-0.0543,0.091,-0.3772,0.5397,0.0185],[1.121,-0.0027,-0.0038,0.0037,0.1858,-0.0583,0.0907,-0.4101,0.5755,0.0185],[1.152,-0.0024,-0.0045,0.0043,0.1795,-0.064,0.0913,-0.4505,0.6163,0.0185],[1.182,-0.0025,-0.0049,0.0049,0.1691,-0.0691,0.0906,-0.4923,0.6584,0.0185],[1.212,-0.0029,-0.0046,0.0049,0.158,-0.0725,0.0895,-0.5328,0.6978,0.0185],[1.242,-0.0028,-0.0045,0.005,0.1488,-0.0758,0.0913,-0.5687,0.7311,0.0185],[1.273,-0.0027,-0.0046,0.0054,0.1415,-0.0792,0.0943,-0.596,0.755,0.0185],[1.303,-0.0027,-0.0049,0.0058,0.136,-0.0821,0.0951,-0.6125,0.7676,0.0185],[1.333,-0.0028,-0.0047,0.006,0.1316,-0.092,0.0975,-0.6167,0.7676,0.0185],[1.364,-0.0029,-0.0046,0.0061,0.1273,-0.1015,0.0992,-0.6083,0.7551,0.0185],[1.394,-0.0031,-0.0044,0.0062,0.1204,-0.1132,0.0998,-0.5879,0.7311,0.0185],[1.424,-0.0029,-0.0047,0.0069,0.1155,-0.132,0.1015,-0.5574,0.6978,0.0185],[1.455,-0.0031,-0.0044,0.0067,0.1125,-0.1405,0.1017,-0.5198,0.6585,0.0185],[1.485,-0.0031,-0.0043,0.0067,0.1065,-0.1498,0.1021,-0.4781,0.6164,0.0185],[1.515,-0.0031,-0.0042,0.0068,0.1044,-0.1587,0.1028,-0.4365,0.5756,0.0185],[1.545,-0.0031,-0.004,0.0068,0.1048,-0.1635,0.1029,-0.3986,0.5397,0.0185],[1.576,-0.0031,-0.0036,0.0066,0.1088,-0.1693,0.1034,-0.3679,0.5121,0.0185],[1.606,-0.003,-0.0031,0.0062,0.1139,-0.1739,0.1043,-0.3471,0.4951,0.0185],[1.636,-0.0026,-0.0038,0.0065,0.1205,-0.1791,0.1062,-0.3382,0.4904,0.0185],[1.667,-0.0025,-0.0035,0.0063,0.1301,-0.1834,0.1071,-0.3421,0.4984,0.0185],[1.697,-0.0022,-0.0034,0.0064,0.1425,-0.1906,0.1076,-0.3582,0.5184,0.0185],[1.727,-0.0021,-0.0033,0.0062,0.1587,-0.1958,0.1073,-0.3852,0.5486,0.0185],[1.758,-0.0018,-0.0034,0.0063,0.1757,-0.201,0.1055,-0.4207,0.586,0.0185],[1.788,-0.0016,-0.0034,0.0061,0.1896,-0.2035,0.1037,-0.4614,0.6276,0.0185],[1.818,-0.0013,-0.0036,0.0062,0.2029,-0.2055,0.1024,-0.5033,0.6693,0.0185],[1.848,-0.0012,-0.0033,0.0062,0.2099,-0.2058,0.1011,-0.5428,0.7073,0.0185],[1.879,-0.0008,-0.0036,0.006,0.2125,-0.2083,0.1004,-0.5768,0.7384,0.0185],[1.909,-0.0008,-0.0034,0.0061,0.2066,-0.2114,0.0975,-0.6015,0.7596,0.0185],[1.939,-0.0008,-0.0033,0.0059,0.2029,-0.2116,0.0959,-0.6149,0.7689,0.0185],[1.97,-0.0007,-0.0032,0.0057,0.2001,-0.2049,0.0951,-0.6157,0.7655,0.0185],[2.0,-0.0008,-0.0032,0.0057,0.1976,-0.1972,0.0943,-0.604,0.7498,0.0185],[2.03,-0.001,-0.0028,0.0055,0.1975,-0.1839,0.0943,-0.5808,0.7231,0.0185],[2.061,-0.001,-0.0029,0.005,0.1897,-0.1614,0.0932,-0.5482,0.688,0.0185],[2.091,-0.0015,-0.0024,0.0042,0.1785,-0.138,0.0938,-0.5083,0.6474,0.0185],[2.121,-0.0018,-0.0017,0.0036,0.1589,-0.1145,0.0949,-0.4669,0.6053,0.0185],[2.152,-0.0021,-0.0014,0.0032,0.1439,-0.1024,0.0944,-0.4259,0.5654,0.0185],[2.182,-0.0024,-0.0011,0.0028,0.1284,-0.0892,0.0944,-0.3896,0.5314,0.0185],[2.212,-0.0026,-0.0011,0.0025,0.1011,-0.0775,0.0926,-0.3612,0.5064,0.0185],[2.242,-0.0028,-0.001,0.0026,0.0828,-0.0694,0.091,-0.3434,0.4925,0.0185],[2.273,-0.003,-0.001,0.0027,0.0661,-0.0647,0.0885,-0.3379,0.4912,0.0185],[2.303,-0.0029,-0.0011,0.0026,0.0544,-0.0632,0.0875,-0.3451,0.5026,0.0185],[2.333,-0.003,-0.001,0.0027,0.0401,-0.0601,0.0853,-0.3643,0.5255,0.0185],[2.364,-0.0033,-0.0011,0.003,0.0187,-0.0611,0.0822,-0.3939,0.5579,0.0185],[2.394,-0.0035,-0.0012,0.0035,0.002,-0.0624,0.0807,-0.4311,0.5969,0.0185],[2.424,-0.0035,-0.0015,0.0036,-0.0081,-0.062,0.0791,-0.4722,0.6388,0.0185],[2.455,-0.0036,-0.0018,0.0039,-0.0282,-0.0639,0.0777,-0.5142,0.68,0.0185],[2.485,-0.0039,-0.0017,0.0042,-0.0461,-0.0626,0.0763,-0.5528,0.7166,0.0185],[2.515,-0.004,-0.0016,0.0044,-0.0612,-0.0617,0.0746,-0.5844,0.7452,0.0185],[2.545,-0.0041,-0.0018,0.0047,-0.0835,-0.0599,0.0724,-0.6064,0.7634,0.0185],[2.576,-0.004,-0.002,0.0045,-0.0985,-0.059,0.0715,-0.6164,0.7693,0.0185],[2.606,-0.0042,-0.0021,0.0048,-0.1158,-0.0576,0.0697,-0.6139,0.7626,0.0185],[2.636,-0.0043,-0.0023,0.0051,-0.1287,-0.0579,0.07,-0.599,0.7438,0.0185],[2.667,-0.0045,-0.0023,0.0053,-0.151,-0.0566,0.0694,-0.5729,0.7145,0.0185],[2.697,-0.0043,-0.0024,0.0053,-0.1636,-0.0562,0.0701,-0.5381,0.6776,0.0185],[2.727,-0.0044,-0.0028,0.0049,-0.1729,-0.0542,0.0707,-0.4978,0.6362,0.0185],[2.758,-0.0045,-0.0027,0.0052,-0.1834,-0.0553,0.0721,-0.4559,0.5944,0.0185],[2.788,-0.0046,-0.0027,0.0054,-0.1902,-0.0546,0.0737,-0.4153,0.5556,0.0185],[2.818,-0.0046,-0.0027,0.0055,-0.1933,-0.0516,0.075,-0.3811,0.5237,0.0185],[2.848,-0.0044,-0.0025,0.005,-0.1942,-0.0496,0.0763,-0.3553,0.5015,0.0185],[2.879,-0.0043,-0.0028,0.0049,-0.1973,-0.049,0.0777,-0.3407,0.4909,0.0185],[2.909,-0.0042,-0.0026,0.0049,-0.1986,-0.0464,0.0795,-0.3386,0.493,0.0185],[2.939,-0.0043,-0.0026,0.0048,-0.202,-0.0425,0.0809,-0.3491,0.5075,0.0185],[2.97,-0.0042,-0.0027,0.005,-0.213,-0.0392,0.0821,-0.3713,0.5332,0.0185],[3.0,-0.0041,-0.003,0.0048,-0.2267,-0.0331,0.0841,-0.4032,0.5677,0.0185],[3.03,-0.004,-0.0031,0.0047,-0.237,-0.0294,0.0849,-0.4417,0.6079,0.0185],[3.061,-0.004,-0.0034,0.0047,-0.2453,-0.029,0.0867,-0.4836,0.6499,0.0185],[3.091,-0.0041,-0.0036,0.005,-0.2522,-0.0269,0.0873,-0.5249,0.6902,0.0185],[3.121,-0.0039,-0.0038,0.0051,-0.2536,-0.0265,0.088,-0.562,0.725,0.0185],[3.152,-0.0039,-0.004,0.005,-0.2582,-0.0267,0.0884,-0.5912,0.7511,0.0185],[3.182,-0.004,-0.004,0.0051,-0.2607,-0.0254,0.0886,-0.6101,0.7661,0.0185],[3.212,-0.0041,-0.0038,0.0049,-0.2625,-0.0245,0.0882,-0.6169,0.7687,0.0185],[3.242,-0.0042,-0.0038,0.005,-0.2626,-0.0247,0.0881,-0.6111,0.7587,0.0185],[3.273,-0.0041,-0.0042,0.005,-0.2626,-0.0278,0.0885,-0.593,0.7369,0.0185],[3.303,-0.0041,-0.0044,0.0052,-0.263,-0.0361,0.0918,-0.5643,0.7053,0.0185],[3.333,-0.0041,-0.0043,0.0054,-0.2626,-0.0443,0.0947,-0.5279,0.6669,0.0185],[3.364,-0.004,-0.0045,0.0055,-0.262,-0.0539,0.0975,-0.4866,0.625,0.0185],[3.394,-0.004,-0.0044,0.0055,-0.2635,-0.0583,0.0991,-0.4449,0.5837,0.0185],[3.424,-0.004,-0.0045,0.0054,-0.2637,-0.0606,0.0996,-0.4058,0.5464,0.0185],[3.455,-0.004,-0.0043,0.0057,-0.2623,-0.0662,0.1008,-0.3733,0.5169,0.0185],[3.485,-0.0037,-0.0046,0.0057,-0.2575,-0.0712,0.1019,-0.3504,0.4976,0.0185],[3.515,-0.0035,-0.0046,0.0057,-0.2511,-0.0686,0.1019,-0.339,0.4903,0.0185],[3.545,-0.0037,-0.0043,0.0055,-0.2473,-0.071,0.1024,-0.3403,0.4958,0.0185],[3.576,-0.0036,-0.0044,0.0055,-0.2447,-0.0777,0.1054,-0.354,0.5134,0.0185],[3.606,-0.0034,-0.0045,0.0053,-0.2435,-0.0835,0.1066,-0.379,0.5417,0.0185],[3.636,-0.0033,-0.0046,0.0053,-0.2428,-0.0907,0.107,-0.4129,0.5779,0.0185],[3.667,-0.0033,-0.0048,0.0054,-0.2424,-0.1,0.1082,-0.4528,0.619,0.0185],[3.697,-0.0031,-0.005,0.0056,-0.2433,-0.1134,0.1133,-0.4948,0.661,0.0185],[3.727,-0.003,-0.0051,0.0057,-0.2418,-0.1221,0.1172,-0.5354,0.7001,0.0185],[3.758,-0.0028,-0.0051,0.0057,-0.2415,-0.1301,0.1195,-0.5706,0.7328,0.0185],[3.788,-0.0027,-0.0052,0.0057,-0.2386,-0.1351,0.1201,-0.5973,0.7562,0.0185],[3.818,-0.0027,-0.005,0.0057,-0.2388,-0.1429,0.1231,-0.6131,0.768,0.0185],[3.848,-0.0027,-0.005,0.0058,-0.2411,-0.1549,0.1281,-0.6166,0.7673,0.0185],[3.879,-0.0026,-0.0049,0.0058,-0.2409,-0.1608,0.1319,-0.6073,0.7539,0.0185],[3.909,-0.0026,-0.0047,0.0056,-0.2406,-0.1675,0.1338,-0.5863,0.7293,0.0185],[3.939,-0.0025,-0.0045,0.0054,-0.2366,-0.1679,0.1334,-0.5553,0.6956,0.0185],[3.97,-0.0027,-0.0041,0.0048,-0.2323,-0.1512,0.1294,-0.5172,0.6559,0.0185],[4.0,-0.0029,-0.0037,0.0041,-0.221,-0.1204,0.1201,-0.4755,0.6138,0.0185],[4.03,-0.0033,-0.0033,0.0038,-0.21,-0.0914,0.108,-0.434,0.5733,0.0185],[4.061,-0.0034,-0.0031,0.0033,-0.1966,-0.0678,0.1008,-0.3965,0.5378,0.0185],[4.091,-0.0035,-0.003,0.003,-0.183,-0.044,0.0937,-0.3662,0.5107,0.0185],[4.121,-0.0038,-0.003,0.0031,-0.1766,-0.0284,0.0872,-0.3463,0.4945,0.0185],[4.152,-0.0041,-0.003,0.0032,-0.17,-0.0174,0.084,-0.3381,0.4905,0.0185],[4.182,-0.0044,-0.0032,0.0033,-0.1706,-0.0067,0.0809,-0.3427,0.4993,0.0185],[4.212,-0.0047,-0.0034,0.0035,-0.1694,0.0058,0.0774,-0.3596,0.52,0.0185],[4.242,-0.0049,-0.0034,0.0035,-0.1698,0.0169,0.0744,-0.3873,0.5507,0.0185],[4.273,-0.0049,-0.0035,0.0036,-0.1707,0.0176,0.0739,-0.4232,0.5886,0.0185],[4.303,-0.0049,-0.0037,0.0038,-0.1718,0.0157,0.0741,-0.4639,0.6302,0.0185],[4.333,-0.005,-0.0037,0.0039,-0.1714,0.0154,0.0747,-0.5059,0.6718,0.0185],[4.364,-0.0052,-0.0037,0.0041,-0.1735,0.0132,0.0762,-0.5453,0.7096,0.0185],[4.394,-0.0053,-0.0039,0.0045,-0.181,-0.0005,0.0824,-0.5786,0.7401,0.0185],[4.424,-0.0049,-0.0042,0.0045,-0.1839,-0.027,0.0939,-0.6026,0.7605,0.0185],[4.455,-0.0048,-0.0042,0.0045,-0.1887,-0.0494,0.102,-0.6153,0.769,0.0185],[4.485,-0.0045,-0.0042,0.0048,-0.1853,-0.0687,0.1089,-0.6153,0.7649,0.0185],[4.515,-0.0045,-0.0039,0.005,-0.1795,-0.0798,0.1126,-0.6029,0.7484,0.0185],[4.545,-0.0043,-0.0039,0.005,-0.1809,-0.0909,0.1152,-0.5789,0.7211,0.0185],[4.576,-0.004,-0.004,0.0049,-0.1816,-0.1064,0.1199,-0.5458,0.6855,0.0185],[4.606,-0.0038,-0.004,0.0048,-0.1783,-0.1117,0.1219,-0.5063,0.6448,0.0185],[4.636,-0.0039,-0.0039,0.0049,-0.18,-0.1107,0.1214,-0.4643,0.6027,0.0185],[4.667,-0.004,-0.0037,0.0047,-0.179,-0.104,0.12,-0.4234,0.5631,0.0185],[4.697,-0.0043,-0.0034,0.0044,-0.1772,-0.0902,0.1156,-0.3875,0.5296,0.0185],[4.727,-0.0045,-0.0033,0.0042,-0.1737,-0.0748,0.1114,-0.3598,0.5052,0.0185],[4.758,-0.0048,-0.0031,0.0039,-0.1692,-0.0593,0.1068,-0.3428,0.4921,0.0185],[4.788,-0.0049,-0.003,0.004,-0.1699,-0.0577,0.1061,-0.338,0.4916,0.0185],[4.818,-0.0049,-0.0032,0.0043,-0.1755,-0.0739,0.112,-0.346,0.5037,0.0185],[4.848,-0.0045,-0.0035,0.0045,-0.1794,-0.093,0.1198,-0.3659,0.5272,0.0185],[4.879,-0.0043,-0.0036,0.0046,-0.1833,-0.1152,0.1288,-0.396,0.5601,0.0185],[4.909,-0.0042,-0.0039,0.0051,-0.1839,-0.1384,0.1349,-0.4337,0.5994,0.0185],[4.939,-0.0041,-0.0039,0.0052,-0.1825,-0.1527,0.1399,-0.4751,0.6414,0.0185],[4.97,-0.004,-0.0037,0.0051,-0.1757,-0.1549,0.1409,-0.5169,0.6824,0.0185],[5.0,-0.0041,-0.0033,0.005,-0.171,-0.1488,0.1397,-0.555,0.7186,0.0185],[5.03,-0.004,-0.0032,0.0051,-0.1706,-0.1537,0.141,-0.5861,0.7467,0.0185],[5.061,-0.0037,-0.0034,0.0049,-0.1694,-0.1575,0.1422,-0.6073,0.7641,0.0185],[5.091,-0.0038,-0.0033,0.0048,-0.1669,-0.1528,0.1414,-0.6166,0.7693,0.0185],[5.121,-0.0041,-0.0031,0.0048,-0.1635,-0.1443,0.1392,-0.6134,0.7618,0.0185],[5.152,-0.0044,-0.0028,0.0048,-0.1607,-0.1351,0.1362,-0.5976,0.7422,0.0185],[5.182,-0.0047,-0.0024,0.0046,-0.1532,-0.1183,0.1313,-0.5709,0.7124,0.0185],[5.212,-0.0049,-0.0019,0.0041,-0.1452,-0.0961,0.1272,-0.5357,0.6751,0.0185],[5.242,-0.005,-0.0019,0.004,-0.1394,-0.0862,0.1269,-0.4952,0.6336,0.0185],[5.273,-0.0051,-0.0016,0.0039,-0.1226,-0.0751,0.1277,-0.4532,0.5918,0.0185],[5.303,-0.005,-0.0016,0.0037,-0.1077,-0.0738,0.1323,-0.4132,0.5534,0.0185],[5.333,-0.0046,-0.0016,0.0036,-0.0902,-0.0861,0.1418,-0.3792,0.522,0.0185],[5.364,-0.0045,-0.0018,0.0035,-0.0691,-0.0938,0.149,-0.354,0.5004,0.0185],[5.394,-0.0045,-0.0016,0.003,-0.0437,-0.0918,0.1535,-0.3402,0.4906,0.0185],[5.424,-0.0044,-0.0016,0.0027,-0.0207,-0.0869,0.1572,-0.3388,0.4935,0.0185],[5.455,-0.0041,-0.0022,0.0031,-0.0021,-0.0844,0.1581,-0.35,0.5088,0.0185],[5.485,-0.0043,-0.0023,0.0034,0.0099,-0.0798,0.1565,-0.3729,0.5351,0.0185],[5.515,-0.0044,-0.0022,0.0033,0.0208,-0.0695,0.154,-0.4053,0.57,0.0185],[5.545,-0.0042,-0.0025,0.0032,0.0318,-0.0568,0.1507,-0.4444,0.6104,0.0185],[5.576,-0.0044,-0.0022,0.0029,0.0432,-0.0456,0.1469,-0.4865,0.6526,0.0185],[5.606,-0.0045,-0.0022,0.0031,0.0486,-0.0388,0.1442,-0.5274,0.6926,0.0185],[5.636,-0.0046,-0.0024,0.0034,0.0578,-0.0278,0.1422,-0.564,0.7268,0.0185],[5.667,-0.0045,-0.0031,0.0041,0.0638,-0.018,0.1412,-0.5929,0.7524,0.0185],[5.697,-0.0046,-0.003,0.0042,0.067,-0.0125,0.1407,-0.611,0.7667,0.0185],[5.727,-0.0045,-0.0032,0.0039,0.067,-0.007,0.1407,-0.617,0.7685,0.0185],[5.758,-0.0044,-0.0032,0.0039,0.0642,-0.0072,0.1403,-0.6104,0.7577,0.0185],[5.788,-0.0044,-0.0031,0.0039,0.0621,-0.0034,0.1407,-0.5915,0.7352,0.0185],[5.818,-0.0044,-0.0028,0.0035,0.0588,0.0003,0.1436,-0.5623,0.7031,0.0185],[5.848,-0.0044,-0.0025,0.0032,0.0603,-0.0046,0.1529,-0.5254,0.6643,0.0185],[5.879,-0.0043,-0.0025,0.0029,0.0665,-0.0192,0.167,-0.5,0.6523,0.0185],[5.909,-0.0041,-0.0027,0.0027,0.0669,-0.0322,0.176,-0.5,0.6523,0.0185],[5.939,-0.0041,-0.0027,0.0024,0.0639,-0.0422,0.1859,-0.5,0.6523,0.0185],[5.97,-0.0042,-0.0024,0.0021,0.0603,-0.0462,0.1907,-0.5,0.6523,0.0185]]},"surprised1":{"kind":"emotion","duration":2.485,"frames":[[0.0,-0.0115,-0.0026,0.0127,0.018,-0.0809,-0.1469,0.048,0.3717,-0.1459],[0.03,-0.0113,-0.0027,0.0126,0.0176,-0.0807,-0.1471,0.048,0.3717,-0.1459],[0.061,-0.0113,-0.0028,0.0126,0.0175,-0.0803,-0.147,0.048,0.3717,-0.1459],[0.091,-0.0115,-0.0029,0.0127,0.0178,-0.08,-0.1468,0.048,0.3717,-0.1459],[0.121,-0.0116,-0.0032,0.0129,0.018,-0.0798,-0.1469,0.048,0.3717,-0.1459],[0.152,-0.0117,-0.0034,0.0131,0.018,-0.0796,-0.1468,0.048,0.3717,-0.1459],[0.182,-0.0119,-0.0037,0.0132,0.018,-0.0793,-0.147,0.048,0.3717,-0.1459],[0.212,-0.012,-0.0039,0.0133,0.0183,-0.0789,-0.1469,0.048,0.3717,-0.1459],[0.242,-0.0117,-0.0038,0.0133,0.0181,-0.0787,-0.1468,0.048,0.3717,-0.1459],[0.273,-0.0116,-0.0037,0.0132,0.0182,-0.0785,-0.1468,0.048,0.3717,-0.1459],[0.303,-0.0113,-0.0033,0.0129,0.018,-0.0789,-0.1467,0.048,0.3717,-0.1459],[0.333,-0.0113,-0.0033,0.0128,0.0178,-0.0788,-0.1468,0.048,0.3717,-0.1459],[0.364,-0.0112,-0.003,0.0128,0.0176,-0.0785,-0.1468,0.048,0.3717,-0.1459],[0.394,-0.0111,-0.003,0.0126,0.0176,-0.0786,-0.147,0.048,0.3717,-0.1459],[0.424,-0.0109,-0.0027,0.0125,0.0171,-0.0787,-0.1469,0.048,0.3717,-0.1459],[0.455,-0.0108,-0.0026,0.0123,0.017,-0.0786,-0.1469,0.048,0.3717,-0.1459],[0.485,-0.0108,-0.0025,0.0123,0.0172,-0.0786,-0.1467,0.048,0.3717,-0.1459],[0.515,-0.0109,-0.0025,0.0124,0.0172,-0.0789,-0.1466,0.048,0.3717,-0.1459],[0.545,-0.011,-0.0027,0.0125,0.0175,-0.0787,-0.1466,0.048,0.3717,-0.1459],[0.576,-0.0109,-0.0027,0.0125,0.0177,-0.0786,-0.1465,0.048,0.3717,-0.1459],[0.606,-0.0108,-0.0025,0.0123,0.0179,-0.0786,-0.1465,0.048,0.3717,-0.1459],[0.636,-0.0109,-0.0025,0.0123,0.0176,-0.0789,-0.1463,0.048,0.3717,-0.1459],[0.667,-0.0109,-0.0025,0.0123,0.0175,-0.079,-0.1461,0.048,0.3717,-0.1459],[0.697,-0.0106,-0.0023,0.0122,0.0176,-0.0786,-0.1462,0.048,0.3717,-0.1459],[0.727,-0.0106,-0.0023,0.0122,0.0171,-0.0784,-0.1466,0.048,0.3717,-0.1459],[0.758,-0.0107,-0.0024,0.0123,0.0166,-0.0786,-0.1464,0.048,0.3717,-0.1459],[0.788,-0.0106,-0.0024,0.0123,0.0167,-0.0788,-0.1464,0.048,0.3717,-0.1459],[0.818,-0.0106,-0.0023,0.0122,0.0167,-0.0788,-0.146,0.048,0.3717,-0.1459],[0.848,-0.0105,-0.0023,0.0122,0.0167,-0.0789,-0.1459,0.048,0.3717,-0.1459],[0.879,-0.0106,-0.0024,0.0123,0.0166,-0.0786,-0.1458,0.035,0.3717,-0.1459],[0.909,-0.0104,-0.0023,0.0122,0.0163,-0.0779,-0.1457,-0.0116,0.3793,-0.1459],[0.939,-0.0101,-0.0024,0.0123,0.0166,-0.0764,-0.1456,-0.1129,0.5123,-0.1459],[0.97,-0.0096,-0.0027,0.0123,0.0171,-0.0736,-0.146,-0.3048,0.7499,-0.1459],[1.0,-0.0088,-0.0031,0.0123,0.0183,-0.0701,-0.1455,-0.5392,0.9862,-0.1459],[1.03,-0.0074,-0.0043,0.0124,0.0197,-0.066,-0.1486,-0.7761,1.225,-0.1459],[1.061,-0.0042,-0.0071,0.0127,0.0205,-0.0708,-0.162,-1.0107,1.4614,-0.1459],[1.091,0.0007,-0.0115,0.0127,0.0185,-0.0713,-0.1854,-1.2456,1.6982,-0.1459],[1.121,0.0064,-0.0179,0.0119,0.0086,-0.0586,-0.2104,-1.4802,1.9346,-0.1459],[1.152,0.0111,-0.0243,0.0109,-0.0133,-0.0466,-0.2351,-1.7057,2.0804,-0.1459],[1.182,0.014,-0.027,0.0101,-0.0188,-0.0473,-0.2528,-1.7375,2.0804,-0.1459],[1.212,0.0148,-0.0295,0.0102,-0.0196,-0.0547,-0.258,-1.7375,2.0804,-0.1459],[1.242,0.0156,-0.0292,0.0099,-0.0193,-0.0601,-0.2575,-1.7375,2.0804,-0.1459],[1.273,0.0149,-0.0293,0.0097,-0.0208,-0.0628,-0.2554,-1.7375,2.0804,-0.1459],[1.303,0.0152,-0.028,0.0086,-0.022,-0.0635,-0.2579,-1.7375,2.0804,-0.1459],[1.333,0.0155,-0.0267,0.0077,-0.0243,-0.0658,-0.2603,-1.7375,2.0804,-0.1459],[1.364,0.0158,-0.0263,0.0078,-0.0263,-0.0687,-0.2589,-1.7375,2.0804,-0.1459],[1.394,0.0164,-0.0261,0.0078,-0.0273,-0.0711,-0.2585,-1.7375,2.0804,-0.1459],[1.424,0.0158,-0.0258,0.0077,-0.0286,-0.0737,-0.2606,-1.7375,2.0804,-0.1459],[1.455,0.0156,-0.0258,0.0079,-0.0291,-0.0754,-0.2609,-1.7375,2.0804,-0.1459],[1.485,0.0154,-0.0255,0.008,-0.0297,-0.0764,-0.2602,-1.7375,2.0804,-0.1459],[1.515,0.0156,-0.0253,0.008,-0.0296,-0.0762,-0.2607,-1.7375,2.0804,-0.1459],[1.545,0.0158,-0.0249,0.0078,-0.0297,-0.0753,-0.262,-1.7375,2.0804,-0.1459],[1.576,0.0161,-0.0242,0.0075,-0.0291,-0.0757,-0.2611,-1.7375,2.0804,-0.1459],[1.606,0.0158,-0.0245,0.0076,-0.029,-0.0771,-0.261,-1.7375,2.0113,-0.1459],[1.636,0.0159,-0.0246,0.0074,-0.0293,-0.0756,-0.262,-1.7075,1.8259,-0.1459],[1.667,0.0161,-0.0245,0.0074,-0.0305,-0.0748,-0.2642,-1.5458,1.6342,-0.1459],[1.697,0.0161,-0.0242,0.0075,-0.0305,-0.0744,-0.2648,-1.3088,1.4418,-0.1459],[1.727,0.0164,-0.0233,0.0072,-0.0288,-0.0739,-0.2639,-1.0719,1.2495,-0.1459],[1.758,0.015,-0.0223,0.0075,-0.0223,-0.0686,-0.2613,-0.8355,1.0576,-0.1459],[1.788,0.012,-0.019,0.0085,-0.0115,-0.0491,-0.2471,-0.5985,0.8652,-0.1459],[1.818,0.0087,-0.0154,0.0097,-0.0035,-0.0363,-0.2251,-0.3623,0.6734,-0.1459],[1.848,0.0067,-0.0123,0.0103,-0.0051,-0.0301,-0.212,-0.1296,0.4816,-0.1459],[1.879,0.0038,-0.0096,0.0107,-0.0049,-0.0176,-0.1994,-0.0106,0.3682,-0.1459],[1.909,0.0015,-0.0078,0.0111,-0.003,-0.0076,-0.1859,-0.0106,0.3682,-0.1459],[1.939,-0.0004,-0.0072,0.0114,-0.0033,-0.0005,-0.1753,-0.0106,0.3682,-0.1459],[1.97,-0.0022,-0.008,0.0123,-0.0055,-0.0018,-0.169,-0.0106,0.3682,-0.1459],[2.0,-0.0036,-0.0083,0.0128,-0.0044,-0.0019,-0.1572,-0.0106,0.3682,-0.1459],[2.03,-0.0044,-0.0082,0.0137,-0.0007,-0.0014,-0.1434,-0.0106,0.3682,-0.1459],[2.061,-0.0053,-0.0079,0.0144,0.002,-0.002,-0.1359,-0.0106,0.3682,-0.1459],[2.091,-0.0062,-0.0088,0.0147,0.002,-0.0053,-0.1324,-0.0106,0.3682,-0.1459],[2.121,-0.0074,-0.0089,0.0152,-0.0003,-0.0097,-0.1242,-0.0106,0.3682,-0.1459],[2.152,-0.009,-0.0092,0.0161,-0.0009,-0.0097,-0.1151,-0.0106,0.3682,-0.1459],[2.182,-0.0103,-0.0091,0.0164,0.0003,-0.0079,-0.1092,-0.0106,0.3682,-0.1459],[2.212,-0.0113,-0.0095,0.0163,-0.0016,-0.0079,-0.1076,-0.0106,0.3682,-0.1459],[2.242,-0.0124,-0.0096,0.0161,-0.0039,-0.0064,-0.1092,-0.0106,0.3682,-0.1459],[2.273,-0.0129,-0.0084,0.0163,-0.0039,-0.0034,-0.1061,-0.0106,0.3682,-0.1459],[2.303,-0.0132,-0.0081,0.0162,-0.002,0.0019,-0.1039,-0.0106,0.3682,-0.1459],[2.333,-0.0133,-0.0081,0.0162,-0.001,0.0023,-0.1022,-0.0106,0.3682,-0.1459],[2.364,-0.0138,-0.0078,0.0157,0.0011,0.0005,-0.0959,-0.0106,0.3682,-0.1459],[2.394,-0.0139,-0.0081,0.0157,0.0038,0.0021,-0.0939,-0.0106,0.3682,-0.1459],[2.424,-0.0133,-0.0075,0.0159,0.0041,0.0023,-0.0926,-0.0106,0.3682,-0.1459],[2.455,-0.0129,-0.0072,0.0158,0.0051,0.0014,-0.0902,-0.0106,0.3682,-0.1459],[2.485,-0.0128,-0.0073,0.0155,0.006,0.0012,-0.0896,-0.0106,0.3682,-0.1459]]},"thoughtful1":{"kind":"emotion","duration":5.917,"frames":[[0.0,-0.0071,-0.0064,0.0145,-0.0013,-0.0101,0.067,-0.167,0.2537,0.0],[0.03,-0.0071,-0.0063,0.0145,-0.0012,-0.0101,0.0667,-0.167,0.2537,0.0],[0.061,-0.0071,-0.0061,0.0144,-0.0014,-0.0106,0.0665,-0.167,0.2537,0.0],[0.091,-0.0071,-0.0062,0.0145,-0.0015,-0.0112,0.0668,-0.167,0.2537,0.0],[0.121,-0.0071,-0.006,0.0144,-0.0013,-0.0109,0.067,-0.167,0.2537,0.0],[0.152,-0.0071,-0.0059,0.0144,-0.0016,-0.0107,0.0668,-0.167,0.2537,0.0],[0.182,-0.0072,-0.0056,0.014,-0.0014,-0.0101,0.067,-0.167,0.2537,0.0],[0.212,-0.0074,-0.0057,0.0141,-0.0016,-0.0077,0.0674,-0.167,0.2537,0.0],[0.242,-0.0077,-0.0059,0.0143,-0.0027,-0.0063,0.0681,-0.167,0.2537,0.0],[0.273,-0.0073,-0.0054,0.014,-0.0045,-0.0097,0.0651,-0.167,0.2537,0.0],[0.303,-0.007,-0.0055,0.0137,-0.0031,-0.0144,0.0621,-0.167,0.2537,0.0],[0.333,-0.0068,-0.0052,0.0134,-0.0025,-0.0165,0.0609,-0.167,0.2537,0.0],[0.364,-0.0069,-0.0049,0.0135,-0.0029,-0.0164,0.0609,-0.167,0.2537,0.0],[0.394,-0.007,-0.0049,0.0137,-0.0047,-0.0167,0.0611,-0.167,0.2537,0.0],[0.424,-0.0069,-0.0046,0.0137,-0.0073,-0.0188,0.0614,-0.167,0.2537,0.0],[0.455,-0.0068,-0.0047,0.0137,-0.0105,-0.0257,0.0622,-0.167,0.2537,0.0],[0.485,-0.0067,-0.0045,0.0135,-0.0126,-0.0325,0.063,-0.167,0.2537,0.0],[0.515,-0.0065,-0.0043,0.0134,-0.0127,-0.0341,0.0627,-0.167,0.2537,0.0],[0.545,-0.0063,-0.0045,0.0135,-0.0125,-0.0334,0.0623,-0.167,0.2537,0.0],[0.576,-0.0061,-0.0042,0.0135,-0.0128,-0.0326,0.0625,-0.167,0.2537,0.0],[0.606,-0.006,-0.0041,0.0133,-0.0131,-0.0315,0.0625,-0.167,0.2537,0.0],[0.636,-0.0059,-0.0041,0.0133,-0.0134,-0.0306,0.0622,-0.167,0.2537,0.0],[0.667,-0.0058,-0.004,0.0133,-0.013,-0.0296,0.0614,-0.167,0.2537,0.0],[0.697,-0.0058,-0.0041,0.0132,-0.0133,-0.029,0.0613,-0.167,0.2537,0.0],[0.727,-0.0058,-0.0041,0.0133,-0.0142,-0.029,0.0612,-0.167,0.2537,0.0],[0.758,-0.0058,-0.0042,0.0135,-0.015,-0.0296,0.0609,-0.167,0.2537,0.0],[0.788,-0.0057,-0.0045,0.0139,-0.0153,-0.0291,0.0599,-0.167,0.2537,0.0],[0.818,-0.0056,-0.005,0.0137,-0.0165,-0.0294,0.0588,-0.167,0.2537,0.0],[0.848,-0.0057,-0.0051,0.0139,-0.0186,-0.0313,0.0587,-0.167,0.2537,0.0],[0.879,-0.0057,-0.0051,0.014,-0.0208,-0.034,0.059,-0.167,0.2537,0.0],[0.909,-0.0055,-0.0044,0.0139,-0.0225,-0.0365,0.0582,-0.167,0.2537,0.0],[0.939,-0.0053,-0.0042,0.0139,-0.0258,-0.0427,0.0559,-0.167,0.2537,0.0],[0.97,-0.0051,-0.004,0.0138,-0.0307,-0.0502,0.0554,-0.167,0.2537,0.0],[1.0,-0.0048,-0.0039,0.0134,-0.0356,-0.0566,0.0557,-0.167,0.2537,0.0],[1.03,-0.0044,-0.0036,0.0133,-0.0406,-0.0702,0.0526,-0.167,0.2537,0.0],[1.061,-0.0038,-0.0034,0.0132,-0.0477,-0.0858,0.0487,-0.167,0.2537,0.0],[1.091,-0.0032,-0.0034,0.0131,-0.0544,-0.0994,0.0455,-0.167,0.2537,0.0],[1.121,-0.0026,-0.0033,0.013,-0.0616,-0.1134,0.0428,-0.167,0.2537,0.0],[1.152,-0.0021,-0.0032,0.0129,-0.0659,-0.1208,0.0405,-0.167,0.2537,0.0],[1.182,-0.0015,-0.0032,0.0128,-0.069,-0.1252,0.0387,-0.167,0.2537,0.0],[1.212,-0.0011,-0.0031,0.0127,-0.0739,-0.1337,0.0361,-0.167,0.2537,0.0],[1.242,-0.0004,-0.002,0.0123,-0.0793,-0.141,0.0348,-0.167,0.2537,0.0],[1.273,-0.0,-0.002,0.0123,-0.0843,-0.1497,0.0346,-0.167,0.2537,0.0],[1.303,0.0003,-0.0019,0.0124,-0.0898,-0.1591,0.0349,-0.167,0.2537,0.0],[1.333,0.0006,-0.0018,0.0125,-0.0951,-0.1668,0.0355,-0.167,0.2537,0.0],[1.364,0.001,-0.0013,0.0119,-0.101,-0.1765,0.0349,-0.167,0.2537,0.0],[1.394,0.0014,-0.0009,0.0112,-0.1084,-0.1851,0.0351,-0.167,0.2537,0.0],[1.424,0.0017,-0.0003,0.0106,-0.1149,-0.1913,0.0351,-0.167,0.2537,0.0],[1.455,0.0022,-0.0,0.0102,-0.1199,-0.1985,0.0348,-0.167,0.2537,0.0],[1.485,0.0025,0.0005,0.0097,-0.1214,-0.2026,0.0338,-0.167,0.2537,0.0],[1.515,0.003,0.0008,0.0095,-0.1266,-0.2116,0.0322,-0.167,0.2537,0.0],[1.545,0.0031,0.0013,0.0097,-0.1395,-0.2251,0.03,-0.167,0.2537,0.0],[1.576,0.0033,0.0015,0.0097,-0.1486,-0.2329,0.0296,-0.167,0.2537,0.0],[1.606,0.0035,0.0014,0.0093,-0.1509,-0.2361,0.029,-0.167,0.2537,0.0],[1.636,0.0039,0.0018,0.0088,-0.1519,-0.2416,0.0271,-0.167,0.2537,0.0],[1.667,0.0042,0.0021,0.0085,-0.1533,-0.2453,0.0263,-0.167,0.2537,0.0],[1.697,0.0042,0.0021,0.0086,-0.1542,-0.2452,0.0258,-0.167,0.2537,0.0],[1.727,0.0043,0.0023,0.0085,-0.155,-0.2469,0.0241,-0.167,0.2537,0.0],[1.758,0.0044,0.0028,0.0083,-0.1586,-0.2508,0.0217,-0.167,0.2537,0.0],[1.788,0.0045,0.0032,0.0082,-0.1607,-0.2502,0.0204,-0.167,0.2537,0.0],[1.818,0.0045,0.0035,0.008,-0.1621,-0.2511,0.0168,-0.167,0.2537,0.0],[1.848,0.0046,0.0041,0.0079,-0.1627,-0.2557,0.0131,-0.167,0.2537,0.0],[1.879,0.0045,0.0045,0.0078,-0.1618,-0.2571,0.0112,-0.167,0.2537,0.0],[1.909,0.0046,0.0051,0.0078,-0.1658,-0.2667,0.0092,-0.167,0.2537,0.0],[1.939,0.0049,0.0056,0.0077,-0.169,-0.2752,0.0088,-0.167,0.2537,0.0],[1.97,0.0053,0.0061,0.0076,-0.1694,-0.28,0.0088,-0.167,0.2537,0.0],[2.0,0.0049,0.0057,0.0077,-0.1691,-0.281,0.009,-0.167,0.2537,0.0],[2.03,0.0051,0.0064,0.0075,-0.168,-0.2821,0.0096,-0.167,0.2537,0.0],[2.061,0.0051,0.0069,0.0073,-0.1712,-0.2896,0.0084,-0.167,0.2537,0.0],[2.091,0.005,0.0075,0.0069,-0.174,-0.2932,0.0076,-0.167,0.2537,0.0],[2.121,0.0052,0.0077,0.0066,-0.1734,-0.293,0.0084,-0.167,0.2537,0.0],[2.152,0.005,0.0073,0.0065,-0.172,-0.2917,0.0095,-0.167,0.2537,0.0],[2.182,0.0051,0.0074,0.0061,-0.1699,-0.2866,0.0103,-0.167,0.2537,0.0],[2.212,0.0053,0.0075,0.0059,-0.1692,-0.2853,0.0105,-0.167,0.2537,0.0],[2.242,0.0045,0.0076,0.0065,-0.1703,-0.2872,0.0094,-0.167,0.2537,0.0],[2.273,0.0046,0.0078,0.0062,-0.1692,-0.288,0.0099,-0.167,0.2537,0.0],[2.303,0.0045,0.0085,0.0057,-0.1704,-0.2889,0.0103,-0.167,0.2537,0.0],[2.333,0.0045,0.0086,0.0053,-0.1776,-0.3031,0.0126,-0.167,0.2537,0.0],[2.364,0.0044,0.0089,0.0053,-0.1854,-0.318,0.0167,-0.167,0.2537,0.0],[2.394,0.0041,0.0093,0.0053,-0.1936,-0.3314,0.0212,-0.167,0.2537,0.0],[2.424,0.004,0.01,0.0048,-0.1989,-0.3436,0.0243,-0.167,0.2537,0.0],[2.455,0.0041,0.0103,0.0041,-0.2025,-0.3566,0.0279,-0.167,0.2537,0.0],[2.485,0.0047,0.0104,0.0035,-0.2035,-0.3678,0.0313,-0.167,0.2537,0.0],[2.515,0.0051,0.011,0.0032,-0.2063,-0.372,0.0344,-0.167,0.2537,0.0],[2.545,0.0054,0.0102,0.0029,-0.2091,-0.3644,0.0354,-0.167,0.2537,0.0],[2.576,0.0064,0.0092,0.0025,-0.2019,-0.3508,0.0292,-0.167,0.2537,0.0],[2.606,0.0074,0.0088,0.0021,-0.1899,-0.343,0.0237,-0.167,0.2537,0.0],[2.636,0.0082,0.0088,0.0017,-0.1801,-0.3356,0.0196,-0.167,0.2537,0.0],[2.667,0.0086,0.0088,0.0015,-0.1788,-0.331,0.0179,-0.167,0.2537,0.0],[2.697,0.0086,0.0087,0.0022,-0.1792,-0.3319,0.0159,-0.167,0.2537,0.0],[2.727,0.0083,0.0095,0.0025,-0.1851,-0.3417,0.0188,-0.167,0.2537,0.0],[2.758,0.0076,0.0097,0.0028,-0.19,-0.3556,0.0212,-0.167,0.2537,0.0],[2.788,0.0073,0.0102,0.0025,-0.1953,-0.3672,0.0238,-0.167,0.2537,0.0],[2.818,0.0065,0.0092,0.0031,-0.1961,-0.3727,0.0268,-0.167,0.2537,0.0],[2.848,0.0059,0.0087,0.0035,-0.1974,-0.3768,0.0292,-0.167,0.2537,0.0],[2.879,0.0057,0.0086,0.0035,-0.2003,-0.3814,0.0295,-0.167,0.2537,0.0],[2.909,0.0058,0.0081,0.0037,-0.2017,-0.3823,0.0281,-0.167,0.2537,0.0],[2.939,0.0063,0.0087,0.0033,-0.2015,-0.381,0.0259,-0.167,0.2537,0.0],[2.97,0.0075,0.0085,0.0028,-0.1946,-0.3745,0.0193,-0.167,0.2537,0.0],[3.0,0.0089,0.0084,0.0022,-0.1797,-0.3617,0.0121,-0.167,0.2537,0.0],[3.03,0.0099,0.0084,0.0016,-0.1723,-0.353,0.0087,-0.167,0.2537,0.0],[3.061,0.01,0.0086,0.0018,-0.1735,-0.351,0.009,-0.167,0.2537,0.0],[3.091,0.0102,0.009,0.0018,-0.1742,-0.3471,0.0088,-0.167,0.2537,0.0],[3.121,0.0106,0.0103,0.0011,-0.1759,-0.3479,0.01,-0.167,0.2537,0.0],[3.152,0.0099,0.0107,0.0019,-0.1797,-0.3594,0.016,-0.167,0.2537,0.0],[3.182,0.0091,0.011,0.0026,-0.1859,-0.3706,0.0218,-0.167,0.2537,0.0],[3.212,0.0088,0.011,0.003,-0.1874,-0.377,0.0249,-0.167,0.2537,0.0],[3.242,0.0087,0.0108,0.0033,-0.1877,-0.3825,0.0274,-0.167,0.2537,0.0],[3.273,0.0082,0.0104,0.0036,-0.1894,-0.3871,0.0294,-0.167,0.2537,0.0],[3.303,0.007,0.0088,0.004,-0.1886,-0.3864,0.0295,-0.167,0.2537,0.0],[3.333,0.0074,0.0083,0.0039,-0.1865,-0.3773,0.0248,-0.167,0.2537,0.0],[3.364,0.0078,0.0103,0.0024,-0.1798,-0.3656,0.019,-0.167,0.2537,0.0],[3.394,0.0083,0.0111,0.0017,-0.1722,-0.3577,0.0158,-0.167,0.2537,0.0],[3.424,0.009,0.0108,0.0014,-0.1687,-0.351,0.0113,-0.167,0.2537,0.0],[3.455,0.0095,0.0107,0.0011,-0.1704,-0.3496,0.009,-0.167,0.2537,0.0],[3.485,0.0098,0.0099,0.0015,-0.1712,-0.3496,0.0088,-0.167,0.2537,0.0],[3.515,0.0097,0.0099,0.0017,-0.1735,-0.3547,0.0116,-0.167,0.2537,0.0],[3.545,0.0091,0.0112,0.0016,-0.1767,-0.3635,0.0158,-0.167,0.2537,0.0],[3.576,0.0084,0.0119,0.0017,-0.1818,-0.3749,0.0223,-0.167,0.2537,0.0],[3.606,0.0078,0.0129,0.0017,-0.1862,-0.3827,0.0261,-0.167,0.2537,0.0],[3.636,0.0074,0.0128,0.0021,-0.1855,-0.3863,0.0284,-0.167,0.2537,0.0],[3.667,0.0073,0.0126,0.0023,-0.1851,-0.3872,0.0293,-0.167,0.2537,0.0],[3.697,0.0067,0.0131,0.0017,-0.1851,-0.3826,0.0255,-0.167,0.2537,0.0],[3.727,0.0073,0.0135,0.0009,-0.1856,-0.3752,0.0215,-0.167,0.2537,0.0],[3.758,0.0078,0.0123,0.0012,-0.1798,-0.365,0.0161,-0.167,0.2537,0.0],[3.788,0.0086,0.012,0.0009,-0.1698,-0.3497,0.0079,-0.167,0.2537,0.0],[3.818,0.0094,0.0115,0.0005,-0.1642,-0.34,0.0014,-0.167,0.2537,0.0],[3.848,0.0098,0.0113,0.0004,-0.1651,-0.3373,0.0,-0.167,0.2537,0.0],[3.879,0.01,0.0106,0.0011,-0.1655,-0.3352,0.0001,-0.167,0.2537,0.0],[3.909,0.0102,0.0105,0.0012,-0.1659,-0.3356,-0.0001,-0.167,0.2537,0.0],[3.939,0.0096,0.0108,0.0013,-0.1664,-0.344,0.0034,-0.167,0.2537,0.0],[3.97,0.009,0.0109,0.002,-0.1696,-0.3555,0.0096,-0.167,0.2537,0.0],[4.0,0.0082,0.011,0.0024,-0.1738,-0.364,0.0138,-0.167,0.2537,0.0],[4.03,0.0075,0.011,0.0028,-0.1761,-0.3713,0.0172,-0.167,0.2537,0.0],[4.061,0.0073,0.0108,0.0033,-0.1793,-0.3801,0.0204,-0.167,0.2537,0.0],[4.091,0.0065,0.0112,0.0031,-0.183,-0.3853,0.0215,-0.167,0.2537,0.0],[4.121,0.0067,0.0117,0.0026,-0.1839,-0.384,0.0196,-0.167,0.2537,0.0],[4.152,0.0072,0.0113,0.0024,-0.1836,-0.3786,0.0153,-0.167,0.2537,0.0],[4.182,0.0078,0.0105,0.0026,-0.1784,-0.366,0.0075,-0.167,0.2537,0.0],[4.212,0.0085,0.0097,0.0027,-0.1729,-0.3568,0.0016,-0.167,0.2537,0.0],[4.242,0.0092,0.0095,0.0023,-0.167,-0.3496,-0.0035,-0.167,0.2537,0.0],[4.273,0.0096,0.0098,0.0021,-0.1675,-0.3459,-0.005,-0.167,0.2537,0.0],[4.303,0.0096,0.0102,0.002,-0.1658,-0.3458,-0.0048,-0.167,0.2537,0.0],[4.333,0.0095,0.0103,0.0022,-0.1659,-0.3481,-0.0027,-0.167,0.2537,0.0],[4.364,0.0093,0.0109,0.0021,-0.1683,-0.3534,0.0014,-0.167,0.2537,0.0],[4.394,0.0087,0.0107,0.0027,-0.1725,-0.3625,0.007,-0.167,0.2537,0.0],[4.424,0.0078,0.0093,0.0035,-0.1748,-0.3687,0.0109,-0.167,0.2537,0.0],[4.455,0.0078,0.0081,0.0037,-0.1756,-0.3678,0.0104,-0.167,0.2537,0.0],[4.485,0.008,0.0092,0.003,-0.1756,-0.3636,0.006,-0.167,0.2537,0.0],[4.515,0.0084,0.0089,0.0029,-0.1711,-0.3563,0.0018,-0.167,0.2537,0.0],[4.545,0.0086,0.0088,0.003,-0.1679,-0.351,-0.0,-0.167,0.2537,0.0],[4.576,0.0084,0.0075,0.0033,-0.1629,-0.3419,-0.0021,-0.167,0.2537,0.0],[4.606,0.0086,0.0071,0.0033,-0.1553,-0.3344,-0.004,-0.167,0.2537,0.0],[4.636,0.0086,0.0077,0.0035,-0.1509,-0.3283,-0.0032,-0.167,0.2537,0.0],[4.667,0.0085,0.0083,0.0034,-0.1461,-0.3193,-0.0011,-0.167,0.2537,0.0],[4.697,0.0083,0.0081,0.0036,-0.1419,-0.3138,-0.0002,-0.167,0.2537,0.0],[4.727,0.0081,0.0077,0.004,-0.1353,-0.3049,-0.0014,-0.167,0.2537,0.0],[4.758,0.008,0.007,0.0041,-0.1277,-0.2972,-0.0028,-0.167,0.2537,0.0],[4.788,0.0077,0.0067,0.0047,-0.1206,-0.2921,-0.0031,-0.167,0.2537,0.0],[4.818,0.0073,0.0065,0.0053,-0.1122,-0.2819,-0.0038,-0.167,0.2537,0.0],[4.848,0.007,0.0061,0.0057,-0.102,-0.2724,-0.0056,-0.167,0.2537,0.0],[4.879,0.0067,0.0059,0.0061,-0.0937,-0.2674,-0.0089,-0.167,0.2537,0.0],[4.909,0.0066,0.0054,0.0067,-0.0852,-0.2604,-0.0105,-0.167,0.2537,0.0],[4.939,0.0063,0.0051,0.0071,-0.0788,-0.2559,-0.0113,-0.167,0.2537,0.0],[4.97,0.0062,0.0054,0.0073,-0.0725,-0.2517,-0.0121,-0.167,0.2537,0.0],[5.0,0.0061,0.0059,0.0072,-0.0652,-0.2438,-0.0135,-0.167,0.2537,0.0],[5.03,0.0057,0.0055,0.0077,-0.0569,-0.2374,-0.0131,-0.167,0.2537,0.0],[5.061,0.0054,0.0053,0.0086,-0.048,-0.2302,-0.0127,-0.167,0.2537,0.0],[5.091,0.0051,0.0053,0.0091,-0.0395,-0.2209,-0.0133,-0.167,0.2537,0.0],[5.121,0.0048,0.0046,0.0095,-0.0319,-0.2136,-0.0131,-0.167,0.2537,0.0],[5.152,0.0045,0.0044,0.0098,-0.0235,-0.2034,-0.0131,-0.167,0.2537,0.0],[5.182,0.0042,0.0042,0.01,-0.0136,-0.1931,-0.0133,-0.167,0.2537,0.0],[5.212,0.0041,0.0044,0.0108,-0.0052,-0.1834,-0.0114,-0.167,0.2537,0.0],[5.242,0.0042,0.004,0.0108,0.0046,-0.1707,-0.0102,-0.167,0.2537,0.0],[5.273,0.0045,0.0033,0.011,0.0127,-0.1589,-0.0106,-0.167,0.2537,0.0],[5.303,0.0044,0.0037,0.0115,0.0182,-0.1507,-0.0107,-0.167,0.2537,0.0],[5.333,0.0045,0.0029,0.0124,0.0241,-0.1398,-0.0112,-0.167,0.2537,0.0],[5.364,0.0046,0.0026,0.0123,0.0286,-0.1273,-0.0121,-0.167,0.2537,0.0],[5.394,0.0048,0.0024,0.0122,0.0297,-0.1203,-0.0128,-0.167,0.2537,0.0],[5.424,0.0049,0.002,0.0122,0.0297,-0.114,-0.0142,-0.167,0.2537,0.0],[5.455,0.005,0.0022,0.0128,0.0297,-0.1078,-0.0163,-0.167,0.2537,0.0],[5.485,0.005,0.0021,0.0133,0.0303,-0.1005,-0.0181,-0.167,0.2537,0.0],[5.515,0.005,0.0018,0.0136,0.0311,-0.0954,-0.0187,-0.167,0.2537,0.0],[5.545,0.0048,0.002,0.0136,0.0324,-0.09,-0.0178,-0.167,0.2537,0.0],[5.576,0.0043,0.0019,0.0138,0.0346,-0.0858,-0.018,-0.167,0.2537,0.0],[5.606,0.0037,0.0021,0.014,0.0349,-0.0846,-0.0174,-0.167,0.2537,0.0],[5.636,0.003,0.003,0.0143,0.0368,-0.0811,-0.0146,-0.167,0.2537,0.0],[5.667,0.0022,0.0033,0.0144,0.0398,-0.0767,-0.0127,-0.167,0.2537,0.0],[5.697,0.0016,0.0039,0.0143,0.041,-0.0728,-0.0127,-0.167,0.2537,0.0],[5.727,0.0007,0.0037,0.0144,0.0433,-0.0678,-0.0123,-0.167,0.2537,0.0],[5.758,-0.0001,0.0033,0.0148,0.0459,-0.062,-0.0126,-0.167,0.2537,0.0],[5.788,-0.0009,0.0033,0.015,0.0463,-0.0579,-0.0136,-0.167,0.2537,0.0],[5.818,-0.0014,0.0031,0.0153,0.0434,-0.0571,-0.0152,-0.167,0.2537,0.0],[5.848,-0.002,0.0028,0.0154,0.0432,-0.0514,-0.0163,-0.167,0.2537,0.0],[5.879,-0.0026,0.0024,0.0154,0.0435,-0.0453,-0.0166,-0.167,0.2537,0.0],[5.909,-0.0033,0.0021,0.0155,0.0428,-0.0414,-0.0151,-0.167,0.2537,0.0]]},"laughing2":{"kind":"emotion","duration":2.928,"frames":[[0.0,-0.0106,-0.0069,0.0067,0.1177,0.0964,0.1447,0.0985,-0.0985,0.1477],[0.03,-0.0112,-0.0069,0.0075,0.1125,0.0835,0.1473,0.0985,-0.0985,0.1477],[0.061,-0.0123,-0.0067,0.0085,0.0963,0.0609,0.1453,0.0985,-0.0985,0.1477],[0.091,-0.0127,-0.0063,0.0088,0.0828,0.051,0.1441,0.0985,-0.0985,0.1477],[0.121,-0.012,-0.0066,0.0084,0.0782,0.0515,0.1461,0.0985,-0.0985,0.1477],[0.152,-0.0107,-0.0071,0.0074,0.0881,0.0578,0.1528,0.0985,-0.0985,0.1477],[0.182,-0.0102,-0.0072,0.0067,0.1006,0.0665,0.1578,0.0985,-0.0985,0.1477],[0.212,-0.0098,-0.0077,0.0068,0.1041,0.0679,0.1594,0.0985,-0.0985,0.1477],[0.242,-0.0097,-0.0079,0.007,0.1048,0.0681,0.1588,0.0985,-0.0985,0.1477],[0.273,-0.0099,-0.0078,0.0073,0.1023,0.0678,0.1562,0.0985,-0.0985,0.1477],[0.303,-0.0102,-0.0078,0.0079,0.0957,0.0657,0.1534,0.0985,-0.0985,0.1477],[0.333,-0.0108,-0.0075,0.0087,0.0879,0.0648,0.1522,0.0985,-0.0985,0.1477],[0.364,-0.0111,-0.0072,0.0092,0.0796,0.0615,0.1534,0.0985,-0.0985,0.1477],[0.394,-0.0115,-0.0069,0.0098,0.07,0.0534,0.1582,0.0985,-0.0985,0.1477],[0.424,-0.0119,-0.0065,0.0102,0.0636,0.0517,0.1611,0.0985,-0.0985,0.1477],[0.455,-0.0117,-0.0063,0.0105,0.0603,0.0541,0.1593,0.1043,-0.1343,0.1477],[0.485,-0.0116,-0.0061,0.0109,0.0587,0.05,0.1615,0.186,-0.2043,0.1477],[0.515,-0.0117,-0.0061,0.0114,0.0566,0.0463,0.1636,0.22,-0.2165,0.1477],[0.545,-0.0115,-0.0063,0.0119,0.0562,0.0481,0.1666,0.1874,-0.1641,0.1477],[0.576,-0.0114,-0.0067,0.0121,0.0579,0.0529,0.1667,0.1062,-0.0758,0.1477],[0.606,-0.0112,-0.0067,0.0121,0.0614,0.0581,0.1665,0.0207,-0.0,0.1477],[0.636,-0.011,-0.0067,0.0115,0.071,0.0746,0.1643,-0.0221,0.0219,0.1477],[0.667,-0.0108,-0.0065,0.0103,0.0869,0.0992,0.1583,0.0012,-0.0221,0.1477],[0.697,-0.0104,-0.0069,0.0094,0.0997,0.1171,0.1536,0.0774,-0.1078,0.1477],[0.727,-0.0093,-0.0074,0.008,0.1164,0.1325,0.1546,0.1652,-0.1884,0.1477],[0.758,-0.0085,-0.008,0.0071,0.13,0.1452,0.1559,0.2166,-0.2198,0.1477],[0.788,-0.0078,-0.0085,0.007,0.1376,0.1448,0.1572,0.2035,-0.185,0.1477],[0.818,-0.0076,-0.0089,0.0074,0.1364,0.1421,0.1563,0.1327,-0.1027,0.1477],[0.848,-0.0087,-0.0083,0.0088,0.1218,0.1247,0.1547,0.0434,-0.0183,0.1477],[0.879,-0.0096,-0.0078,0.0102,0.1064,0.1077,0.1531,-0.0159,0.0223,0.1477],[0.909,-0.0095,-0.0079,0.0102,0.0938,0.1115,0.1496,-0.0125,-0.0032,0.1477],[0.939,-0.0088,-0.0083,0.0089,0.0948,0.1299,0.1476,0.0516,-0.0808,0.1477],[0.97,-0.0074,-0.009,0.007,0.1172,0.1505,0.148,0.1415,-0.1682,0.1477],[1.0,-0.0061,-0.0096,0.0057,0.1437,0.1658,0.1477,0.2079,-0.2173,0.1477],[1.03,-0.0057,-0.01,0.0063,0.155,0.1693,0.1513,0.2141,-0.2015,0.1477],[1.061,-0.0065,-0.0095,0.0077,0.1455,0.1561,0.155,0.1576,-0.1294,0.1477],[1.091,-0.0074,-0.0087,0.0092,0.1221,0.1382,0.1549,0.0689,-0.0404,0.1477],[1.121,-0.0078,-0.0086,0.0092,0.0987,0.1369,0.1545,-0.0039,0.0168,0.1477],[1.152,-0.0074,-0.0095,0.0083,0.096,0.1428,0.1567,-0.0205,0.0109,0.1477],[1.182,-0.0062,-0.0102,0.0066,0.1173,0.1586,0.1598,0.0281,-0.0549,0.1477],[1.212,-0.0053,-0.0104,0.0058,0.1407,0.174,0.1619,0.1151,-0.1445,0.1477],[1.242,-0.0059,-0.0099,0.0072,0.1402,0.1683,0.1657,0.1931,-0.209,0.1477],[1.273,-0.0077,-0.0085,0.0089,0.1232,0.1472,0.1673,0.2193,-0.2131,0.1477],[1.303,-0.0076,-0.0083,0.0088,0.1067,0.1364,0.1641,0.1795,-0.1545,0.1477],[1.333,-0.0077,-0.0083,0.0085,0.0894,0.1373,0.1608,0.0953,-0.0652,0.1477],[1.364,-0.007,-0.009,0.0074,0.0926,0.1482,0.159,0.0129,0.0058,0.1477],[1.394,-0.0054,-0.0094,0.0057,0.1172,0.1672,0.1602,-0.0227,0.0197,0.1477],[1.424,-0.0048,-0.0098,0.0052,0.1379,0.1768,0.1662,0.0074,-0.0304,0.1477],[1.455,-0.0057,-0.0097,0.0065,0.1408,0.1635,0.1771,0.0881,-0.1186,0.1477],[1.485,-0.007,-0.0091,0.0083,0.1254,0.1345,0.1824,0.1741,-0.1953,0.1477],[1.515,-0.0083,-0.0081,0.0092,0.1021,0.1131,0.1826,0.2186,-0.219,0.1477],[1.545,-0.0087,-0.0078,0.0092,0.0801,0.1091,0.1799,0.1974,-0.1769,0.1477],[1.576,-0.0069,-0.0091,0.0081,0.0888,0.1297,0.178,0.1221,-0.0918,0.1477],[1.606,-0.0046,-0.01,0.0057,0.122,0.1646,0.1739,0.034,-0.0104,0.1477],[1.636,-0.0042,-0.0105,0.0059,0.1422,0.1765,0.1767,-0.019,0.0228,0.1477],[1.667,-0.0062,-0.0097,0.0079,0.1301,0.1494,0.1893,-0.0076,-0.0103,0.1477],[1.697,-0.0079,-0.0086,0.0091,0.1076,0.119,0.1967,0.0617,-0.0917,0.1477],[1.727,-0.008,-0.0087,0.0087,0.087,0.1181,0.1942,0.151,-0.1768,0.1477],[1.758,-0.007,-0.0087,0.0068,0.0913,0.147,0.1861,0.212,-0.2192,0.1477],[1.788,-0.0049,-0.009,0.005,0.1241,0.1792,0.1834,0.2106,-0.1954,0.1477],[1.818,-0.0046,-0.0092,0.0056,0.1394,0.1856,0.1906,0.1477,-0.1187,0.1477],[1.848,-0.0062,-0.009,0.007,0.1281,0.171,0.1958,0.0581,-0.0309,0.1477],[1.879,-0.0066,-0.0099,0.0079,0.1087,0.1609,0.1896,-0.0097,0.02,0.1477],[1.909,-0.0055,-0.0108,0.0072,0.1041,0.1697,0.1789,-0.0182,0.006,0.1477],[1.939,-0.0036,-0.0114,0.0054,0.1378,0.1985,0.1762,0.0371,-0.0651,0.1477],[1.97,-0.0031,-0.0109,0.0049,0.1661,0.2113,0.1822,0.1259,-0.1545,0.1477],[2.0,-0.0044,-0.0102,0.006,0.1588,0.1964,0.19,0.1997,-0.2133,0.1477],[2.03,-0.005,-0.0106,0.0064,0.1415,0.1866,0.1872,0.2183,-0.2093,0.1477],[2.061,-0.0041,-0.012,0.0058,0.1438,0.2021,0.1769,0.1899,-0.19,0.1477],[2.091,-0.0036,-0.0117,0.0041,0.1688,0.2169,0.1833,0.1899,-0.19,0.1477],[2.121,-0.0046,-0.0108,0.0052,0.1779,0.2095,0.1997,0.1899,-0.19,0.1477],[2.152,-0.0056,-0.0111,0.0065,0.1622,0.1925,0.2001,0.1899,-0.19,0.1477],[2.182,-0.0053,-0.0112,0.0068,0.1528,0.1848,0.193,0.1899,-0.19,0.1477],[2.212,-0.0048,-0.0113,0.0065,0.1515,0.1788,0.1906,0.1899,-0.19,0.1477],[2.242,-0.0056,-0.0107,0.0075,0.1385,0.1552,0.202,0.1899,-0.19,0.1477],[2.273,-0.0062,-0.0111,0.0083,0.1182,0.1376,0.2045,0.1899,-0.19,0.1477],[2.303,-0.005,-0.0117,0.0074,0.1285,0.1571,0.1957,0.1899,-0.19,0.1477],[2.333,-0.0025,-0.0125,0.0056,0.1666,0.1944,0.1926,0.1899,-0.19,0.1477],[2.364,-0.0031,-0.012,0.0063,0.1706,0.1901,0.1978,0.1899,-0.19,0.1477],[2.394,-0.0037,-0.0122,0.0075,0.1537,0.1689,0.2007,0.1899,-0.19,0.1477],[2.424,-0.0029,-0.0128,0.0067,0.1518,0.1792,0.1902,0.1899,-0.19,0.1477],[2.455,-0.0017,-0.0132,0.0053,0.1687,0.2082,0.1753,0.1899,-0.19,0.1477],[2.485,-0.0013,-0.0129,0.0054,0.1773,0.2144,0.1767,0.1899,-0.19,0.1477],[2.515,-0.0009,-0.0127,0.0045,0.1757,0.22,0.1779,0.1899,-0.19,0.1477],[2.545,-0.0008,-0.012,0.0034,0.1755,0.2281,0.1768,0.1899,-0.19,0.1477],[2.576,-0.0018,-0.0117,0.0045,0.1705,0.2186,0.183,0.1899,-0.19,0.1477],[2.606,-0.0038,-0.0109,0.0055,0.1622,0.1929,0.1979,0.1899,-0.19,0.1477],[2.636,-0.0044,-0.011,0.0063,0.1604,0.1841,0.2002,0.1899,-0.19,0.1477],[2.667,-0.0026,-0.012,0.0054,0.1761,0.2055,0.19,0.1899,-0.19,0.1477],[2.697,-0.0011,-0.0126,0.0048,0.1793,0.2181,0.1831,0.1899,-0.19,0.1477],[2.727,-0.0014,-0.0127,0.0055,0.1614,0.1965,0.1845,0.1899,-0.19,0.1477],[2.758,-0.002,-0.0128,0.0065,0.1501,0.1744,0.1882,0.1899,-0.19,0.1477],[2.788,-0.0022,-0.0124,0.0071,0.1486,0.1634,0.1882,0.1899,-0.19,0.1477],[2.818,-0.0028,-0.0123,0.0083,0.1434,0.1474,0.1913,0.1899,-0.19,0.1477],[2.848,-0.0031,-0.0119,0.0088,0.1368,0.1253,0.1955,0.1899,-0.19,0.1477],[2.879,-0.0029,-0.0119,0.0086,0.1326,0.1123,0.1944,0.1899,-0.19,0.1477],[2.909,-0.0031,-0.0113,0.0088,0.1294,0.1052,0.1937,0.1899,-0.19,0.1477]]},"curious1":{"kind":"emotion","duration":6.0,"frames":[[0.0,-0.0103,0.0035,0.0045,0.0663,0.0293,0.085,0.0931,0.2297,0.1454],[0.03,-0.0102,0.0032,0.0046,0.0638,0.0277,0.0896,0.0931,0.2297,0.1454],[0.061,-0.0101,0.0032,0.0044,0.062,0.0263,0.0922,0.0931,0.2297,0.1454],[0.091,-0.0101,0.0042,0.0038,0.059,0.0231,0.095,0.0931,0.2297,0.1454],[0.121,-0.0101,0.0039,0.004,0.0559,0.0206,0.1009,0.0931,0.2297,0.1454],[0.152,-0.01,0.0038,0.004,0.0538,0.0202,0.1068,0.0931,0.2297,0.1454],[0.182,-0.01,0.0038,0.0039,0.0522,0.02,0.1124,0.0931,0.2297,0.1454],[0.212,-0.01,0.0037,0.0039,0.0514,0.0206,0.1171,0.0931,0.2297,0.1454],[0.242,-0.0101,0.0039,0.0039,0.0514,0.021,0.1211,0.0931,0.2297,0.1454],[0.273,-0.01,0.0038,0.0039,0.051,0.0207,0.1223,0.0931,0.2297,0.1454],[0.303,-0.0098,0.0049,0.0032,0.0498,0.0176,0.1173,0.0931,0.2297,0.1454],[0.333,-0.0099,0.0056,0.0029,0.0479,0.0144,0.1158,0.0931,0.2297,0.1454],[0.364,-0.0097,0.0066,0.0026,0.0458,0.0104,0.1187,0.0931,0.2297,0.1454],[0.394,-0.0093,0.0068,0.0025,0.0426,0.0038,0.1286,0.0931,0.2297,0.1454],[0.424,-0.0086,0.0065,0.0023,0.0341,-0.0056,0.15,0.0931,0.2297,0.1454],[0.455,-0.0085,0.0067,0.0021,0.0291,-0.0041,0.1741,0.0931,0.2297,0.1454],[0.485,-0.009,0.0079,0.0019,0.0232,-0.0009,0.191,0.0931,0.2297,0.1454],[0.515,-0.0091,0.0079,0.002,0.0159,-0.0002,0.1928,0.0931,0.2297,0.1454],[0.545,-0.0088,0.008,0.0015,0.0098,-0.0035,0.1954,0.0931,0.2297,0.1454],[0.576,-0.0086,0.0078,0.0013,0.0058,-0.0096,0.2025,0.0931,0.2297,0.1454],[0.606,-0.0089,0.0077,0.0015,0.004,-0.0118,0.21,0.0931,0.2297,0.1454],[0.636,-0.0091,0.0079,0.0017,0.0039,-0.0125,0.2182,0.0931,0.2297,0.1454],[0.667,-0.0089,0.0081,0.0015,0.0027,-0.0146,0.2164,0.0931,0.2297,0.1454],[0.697,-0.0089,0.0078,0.0015,-0.0016,-0.0213,0.2191,0.0931,0.2297,0.1454],[0.727,-0.009,0.0078,0.0015,-0.0091,-0.0302,0.2306,0.0931,0.2297,0.1454],[0.758,-0.0091,0.009,0.0011,-0.0118,-0.0304,0.2412,0.0931,0.2475,0.1454],[0.788,-0.0094,0.0101,0.0007,-0.0127,-0.0324,0.2575,0.0931,0.2835,0.1454],[0.818,-0.0094,0.0102,0.0007,-0.0151,-0.0322,0.2791,0.0931,0.3292,0.1454],[0.848,-0.0092,0.0104,0.0013,-0.0192,-0.0332,0.3052,0.0931,0.382,0.1454],[0.879,-0.0096,0.0109,0.0006,-0.0205,-0.0358,0.324,0.0931,0.4361,0.1454],[0.909,-0.01,0.0096,0.0009,-0.0212,-0.04,0.3347,0.0931,0.4921,0.1454],[0.939,-0.0101,0.01,0.0006,-0.0213,-0.0451,0.3464,0.0931,0.5483,0.1454],[0.97,-0.0103,0.0099,0.0009,-0.0201,-0.0475,0.3593,0.0931,0.6046,0.1454],[1.0,-0.0103,0.0105,0.0009,-0.0212,-0.05,0.3711,0.0931,0.6609,0.1454],[1.03,-0.0108,0.0101,0.0017,-0.0264,-0.053,0.3805,0.0931,0.7171,0.1454],[1.061,-0.0108,0.0091,0.0025,-0.0311,-0.0545,0.3928,0.0931,0.7734,0.1454],[1.091,-0.011,0.0087,0.0024,-0.0349,-0.0534,0.4083,0.0931,0.8284,0.1454],[1.121,-0.0112,0.0083,0.0028,-0.0371,-0.0506,0.4268,0.0931,0.8836,0.1454],[1.152,-0.0118,0.0093,0.0026,-0.0394,-0.0533,0.4454,0.0931,0.9384,0.1454],[1.182,-0.0122,0.0101,0.0029,-0.0418,-0.0599,0.4686,0.0931,0.9933,0.1454],[1.212,-0.0122,0.0104,0.0023,-0.0432,-0.065,0.4902,0.0931,1.0484,0.1454],[1.242,-0.0124,0.0105,0.0023,-0.0449,-0.0648,0.5075,0.0931,1.1035,0.1454],[1.273,-0.0126,0.0097,0.0031,-0.045,-0.0706,0.5328,0.0931,1.1583,0.1454],[1.303,-0.0133,0.009,0.0039,-0.05,-0.0742,0.5512,0.0931,1.2036,0.1454],[1.333,-0.0138,0.0085,0.0044,-0.0612,-0.08,0.572,0.0931,1.2437,0.1454],[1.364,-0.014,0.0081,0.0043,-0.0631,-0.0819,0.5959,0.0931,1.2839,0.1454],[1.394,-0.0143,0.0081,0.0045,-0.0653,-0.0836,0.6147,0.0931,1.3239,0.1454],[1.424,-0.0151,0.008,0.005,-0.0697,-0.0842,0.6331,0.0931,1.3411,0.1454],[1.455,-0.0154,0.0076,0.0055,-0.071,-0.0872,0.6541,0.0931,1.3411,0.1454],[1.485,-0.0157,0.0077,0.0053,-0.0724,-0.0883,0.6676,0.0931,1.3411,0.1454],[1.515,-0.016,0.0078,0.0052,-0.073,-0.0891,0.6785,0.0931,1.3411,0.1454],[1.545,-0.0163,0.007,0.0056,-0.078,-0.0911,0.6851,0.0931,1.3411,0.1454],[1.576,-0.0165,0.007,0.0056,-0.0825,-0.0951,0.689,0.0931,1.3411,0.1454],[1.606,-0.0164,0.0071,0.0057,-0.0854,-0.0969,0.6909,0.0931,1.3411,0.1454],[1.636,-0.0165,0.0074,0.0055,-0.0884,-0.0995,0.6952,0.0931,1.3411,0.1454],[1.667,-0.0167,0.0079,0.0054,-0.091,-0.1007,0.6972,0.0931,1.3411,0.1454],[1.697,-0.0167,0.0081,0.0055,-0.096,-0.1051,0.7014,0.0931,1.3411,0.1454],[1.727,-0.0168,0.0079,0.0054,-0.1017,-0.1102,0.7049,0.0931,1.3411,0.1454],[1.758,-0.0169,0.0081,0.0052,-0.1057,-0.1125,0.7077,0.0931,1.3411,0.1454],[1.788,-0.0168,0.0083,0.0052,-0.1063,-0.113,0.71,0.0931,1.3411,0.1454],[1.818,-0.0169,0.0088,0.0051,-0.1073,-0.1136,0.7093,0.0931,1.3411,0.1454],[1.848,-0.0168,0.0092,0.005,-0.1078,-0.1149,0.7104,0.0931,1.3411,0.1454],[1.879,-0.0168,0.0096,0.0045,-0.1102,-0.1164,0.711,0.0931,1.3411,0.1454],[1.909,-0.0167,0.0098,0.0042,-0.1093,-0.1153,0.711,0.0931,1.3411,0.1454],[1.939,-0.0168,0.0099,0.0042,-0.1098,-0.1158,0.7104,0.0931,1.3411,0.1454],[1.97,-0.0168,0.0099,0.0042,-0.1102,-0.1171,0.7116,0.0931,1.3411,0.1454],[2.0,-0.0166,0.0095,0.0044,-0.1104,-0.118,0.7126,0.0931,1.3411,0.1454],[2.03,-0.0165,0.0091,0.0045,-0.1091,-0.1168,0.7124,0.0931,1.3411,0.1454],[2.061,-0.0165,0.0087,0.0047,-0.109,-0.1162,0.7112,0.0931,1.3411,0.1454],[2.091,-0.0166,0.0083,0.005,-0.11,-0.1163,0.7093,0.0931,1.3411,0.1454],[2.121,-0.0166,0.0084,0.005,-0.1087,-0.1156,0.7087,0.0931,1.3411,0.1454],[2.152,-0.0167,0.0086,0.005,-0.1076,-0.1144,0.7078,0.0931,1.3411,0.1454],[2.182,-0.0166,0.0084,0.0052,-0.1068,-0.1135,0.7069,0.0931,1.3411,0.1454],[2.212,-0.0167,0.0087,0.005,-0.1073,-0.1134,0.7052,0.0931,1.3411,0.1454],[2.242,-0.0166,0.0089,0.0046,-0.1066,-0.1129,0.704,0.0931,1.3411,0.1454],[2.273,-0.0166,0.009,0.0046,-0.106,-0.1122,0.7029,0.0931,1.3411,0.1454],[2.303,-0.0166,0.009,0.0049,-0.1055,-0.1113,0.7017,0.0931,1.3199,0.1454],[2.333,-0.0166,0.0083,0.0052,-0.1051,-0.111,0.7005,0.0931,1.2769,0.1454],[2.364,-0.0165,0.0088,0.0049,-0.1053,-0.1108,0.6992,0.0931,1.215,0.1454],[2.394,-0.0165,0.0082,0.0051,-0.1048,-0.1108,0.6995,0.0931,1.1452,0.1454],[2.424,-0.0166,0.0082,0.005,-0.1054,-0.1113,0.6982,0.0931,1.0687,0.1454],[2.455,-0.0166,0.0083,0.0052,-0.105,-0.1103,0.6961,0.0931,0.9827,0.1454],[2.485,-0.0166,0.0085,0.005,-0.1047,-0.1093,0.6932,0.0931,0.8869,0.1454],[2.515,-0.0164,0.0084,0.0049,-0.1036,-0.1086,0.6914,0.0931,0.7898,0.1454],[2.545,-0.0164,0.0086,0.0049,-0.1031,-0.1076,0.6904,0.0931,0.6928,0.1454],[2.576,-0.0166,0.0092,0.0047,-0.1031,-0.1072,0.6899,0.0931,0.5954,0.1454],[2.606,-0.0165,0.0094,0.0047,-0.1019,-0.1061,0.689,0.0931,0.4989,0.1454],[2.636,-0.0164,0.0091,0.0047,-0.1004,-0.1052,0.6887,0.0931,0.401,0.1454],[2.667,-0.0163,0.0088,0.0048,-0.1,-0.1053,0.688,0.0931,0.3039,0.1454],[2.697,-0.0164,0.0082,0.0052,-0.1002,-0.1055,0.6856,0.0931,0.2351,0.1454],[2.727,-0.0165,0.008,0.0054,-0.1028,-0.1078,0.6749,0.0931,0.2351,0.1454],[2.758,-0.0164,0.0079,0.0059,-0.1017,-0.1086,0.6511,0.0931,0.2351,0.1454],[2.788,-0.0162,0.0079,0.0067,-0.0882,-0.1082,0.6086,0.0931,0.2351,0.1454],[2.818,-0.0159,0.0088,0.0073,-0.077,-0.1075,0.545,0.0931,0.2351,0.1454],[2.848,-0.0155,0.0091,0.0076,-0.0667,-0.1077,0.4968,0.0931,0.2351,0.1454],[2.879,-0.015,0.0101,0.0073,-0.0574,-0.1112,0.4627,0.0931,0.2351,0.1454],[2.909,-0.015,0.0102,0.0073,-0.0525,-0.1135,0.4395,0.0931,0.2351,0.1454],[2.939,-0.0153,0.011,0.0067,-0.0415,-0.1127,0.41,0.0931,0.2351,0.1454],[2.97,-0.0154,0.0116,0.0065,-0.0284,-0.1151,0.3735,0.0931,0.2351,0.1454],[3.0,-0.0155,0.0127,0.0058,-0.0141,-0.1147,0.343,0.0931,0.2351,0.1454],[3.03,-0.0156,0.0133,0.0053,-0.0004,-0.1157,0.316,0.0931,0.2351,0.1454],[3.061,-0.0154,0.0136,0.005,0.0116,-0.1193,0.2883,0.0931,0.2351,0.1454],[3.091,-0.0155,0.0138,0.0048,0.0226,-0.1187,0.2589,0.0931,0.2351,0.1454],[3.121,-0.0152,0.012,0.0058,0.032,-0.1176,0.239,0.0931,0.2351,0.1454],[3.152,-0.0152,0.0124,0.0055,0.0367,-0.1174,0.2209,0.0931,0.2351,0.1454],[3.182,-0.015,0.0134,0.0047,0.0432,-0.1191,0.1994,0.0931,0.2351,0.1454],[3.212,-0.0147,0.0143,0.0043,0.0486,-0.1191,0.182,0.0931,0.2351,0.1454],[3.242,-0.0144,0.0138,0.0046,0.052,-0.1196,0.1709,0.0931,0.2351,0.1454],[3.273,-0.0139,0.0132,0.0048,0.0575,-0.1187,0.1597,0.0931,0.2351,0.1454],[3.303,-0.0138,0.0132,0.0049,0.0622,-0.1154,0.145,0.0931,0.2351,0.1454],[3.333,-0.0139,0.0138,0.0047,0.0671,-0.1126,0.1298,0.0931,0.2351,0.1454],[3.364,-0.0135,0.0138,0.0049,0.0706,-0.1109,0.1185,0.0931,0.2351,0.1454],[3.394,-0.0131,0.0136,0.0048,0.0741,-0.1101,0.1059,0.0931,0.2351,0.1454],[3.424,-0.0127,0.0135,0.0044,0.0774,-0.1076,0.0895,0.0931,0.2351,0.1454],[3.455,-0.0124,0.0135,0.0046,0.0805,-0.1042,0.0719,0.0931,0.2351,0.1454],[3.485,-0.0119,0.0136,0.0048,0.084,-0.1034,0.0565,0.0931,0.2351,0.1454],[3.515,-0.0112,0.0136,0.0049,0.0853,-0.1038,0.0434,0.0931,0.2351,0.1454],[3.545,-0.0109,0.0128,0.0047,0.0865,-0.0995,0.0287,0.0931,0.2351,0.1454],[3.576,-0.0104,0.0126,0.0045,0.0895,-0.0974,0.0073,0.0912,0.2351,0.1454],[3.606,-0.01,0.0126,0.0047,0.0913,-0.0935,-0.0178,0.0665,0.2351,0.1454],[3.636,-0.0098,0.0125,0.0047,0.0945,-0.0894,-0.0411,0.0181,0.2351,0.1454],[3.667,-0.0094,0.0123,0.0047,0.0957,-0.0855,-0.0617,-0.0528,0.2351,0.1454],[3.697,-0.009,0.0117,0.0048,0.0967,-0.0809,-0.082,-0.1371,0.2351,0.1454],[3.727,-0.0086,0.0113,0.005,0.1008,-0.0806,-0.0997,-0.2312,0.2351,0.1454],[3.758,-0.0086,0.0111,0.0056,0.1064,-0.0805,-0.1156,-0.3308,0.2351,0.1454],[3.788,-0.0085,0.0113,0.0059,0.1087,-0.0808,-0.1306,-0.4322,0.2351,0.1454],[3.818,-0.0081,0.0114,0.0058,0.1196,-0.0741,-0.1504,-0.5341,0.2351,0.1454],[3.848,-0.0079,0.0112,0.0058,0.1275,-0.0644,-0.1724,-0.6368,0.2351,0.1454],[3.879,-0.0083,0.0114,0.0062,0.1359,-0.0552,-0.199,-0.7406,0.2351,0.1454],[3.909,-0.0083,0.0115,0.0066,0.147,-0.0474,-0.23,-0.8439,0.2351,0.1454],[3.939,-0.0083,0.0116,0.0065,0.1589,-0.0384,-0.2609,-0.9465,0.2351,0.1454],[3.97,-0.0083,0.0113,0.0066,0.1711,-0.029,-0.29,-1.0504,0.2351,0.1454],[4.0,-0.0082,0.011,0.007,0.1857,-0.0242,-0.3228,-1.1528,0.2351,0.1454],[4.03,-0.0086,0.0111,0.0071,0.1987,-0.0216,-0.3638,-1.2538,0.2351,0.1454],[4.061,-0.0082,0.011,0.0074,0.2145,-0.0195,-0.3892,-1.3529,0.2351,0.1454],[4.091,-0.008,0.0107,0.0076,0.2267,-0.021,-0.4134,-1.4406,0.2351,0.1454],[4.121,-0.0083,0.0108,0.0083,0.2351,-0.0206,-0.44,-1.4835,0.2351,0.1454],[4.152,-0.0082,0.0115,0.0081,0.2428,-0.0104,-0.4703,-1.4835,0.2351,0.1454],[4.182,-0.0083,0.0116,0.008,0.2472,-0.0003,-0.4879,-1.4835,0.2351,0.1454],[4.212,-0.0081,0.0119,0.0079,0.254,0.0019,-0.4967,-1.4835,0.2351,0.1454],[4.242,-0.0079,0.0122,0.0077,0.2579,-0.0007,-0.509,-1.4835,0.2351,0.1454],[4.273,-0.0083,0.0129,0.0079,0.2569,0.0103,-0.5342,-1.4835,0.2351,0.1454],[4.303,-0.0084,0.0135,0.0079,0.2572,0.0196,-0.5591,-1.4835,0.2351,0.1454],[4.333,-0.0084,0.0138,0.0078,0.2582,0.0244,-0.583,-1.4835,0.2351,0.1454],[4.364,-0.0082,0.0141,0.0077,0.2578,0.0257,-0.6049,-1.4835,0.2351,0.1454],[4.394,-0.0081,0.0148,0.0077,0.2592,0.0312,-0.6242,-1.4835,0.2351,0.1454],[4.424,-0.0083,0.0158,0.0073,0.2592,0.0457,-0.6547,-1.4835,0.2351,0.1454],[4.455,-0.0084,0.0166,0.0072,0.2604,0.0541,-0.6818,-1.4835,0.2351,0.1454],[4.485,-0.0084,0.0169,0.0071,0.2635,0.0555,-0.7101,-1.4835,0.2351,0.1454],[4.515,-0.008,0.0176,0.0061,0.2639,0.0673,-0.7419,-1.4835,0.2351,0.1454],[4.545,-0.0079,0.018,0.0058,0.2633,0.079,-0.7613,-1.4835,0.2351,0.1454],[4.576,-0.0082,0.0184,0.0063,0.2645,0.0801,-0.7756,-1.4835,0.2351,0.1454],[4.606,-0.0082,0.0182,0.0065,0.2647,0.0782,-0.78,-1.4835,0.2351,0.1454],[4.636,-0.0079,0.0178,0.0064,0.264,0.0782,-0.7825,-1.4835,0.2351,0.1454],[4.667,-0.0079,0.0181,0.0062,0.2634,0.0787,-0.7854,-1.4835,0.2351,0.1454],[4.697,-0.0078,0.0178,0.0065,0.2618,0.0779,-0.7854,-1.4835,0.2351,0.1454],[4.727,-0.0079,0.0176,0.0067,0.2597,0.0772,-0.7854,-1.4835,0.2351,0.1454],[4.758,-0.0076,0.0177,0.0066,0.2582,0.0759,-0.7854,-1.4835,0.2351,0.1454],[4.788,-0.0077,0.0175,0.0064,0.2568,0.0758,-0.7854,-1.4835,0.2351,0.1454],[4.818,-0.0077,0.0165,0.0074,0.2568,0.0752,-0.7854,-1.4835,0.2351,0.1454],[4.848,-0.0077,0.0166,0.0074,0.2556,0.0753,-0.7854,-1.4835,0.2351,0.1454],[4.879,-0.0077,0.0164,0.0072,0.2521,0.0726,-0.7795,-1.4835,0.2351,0.1454],[4.909,-0.0076,0.0165,0.0071,0.2485,0.0678,-0.7694,-1.4835,0.2351,0.1454],[4.939,-0.0078,0.0165,0.0072,0.2441,0.0622,-0.7548,-1.4835,0.2351,0.1454],[4.97,-0.0075,0.0162,0.0074,0.236,0.0522,-0.7251,-1.4835,0.2351,0.1454],[5.0,-0.0075,0.0154,0.0074,0.2288,0.044,-0.7041,-1.4835,0.2351,0.1454],[5.03,-0.0075,0.0154,0.0073,0.2243,0.0388,-0.6825,-1.4835,0.2351,0.1454],[5.061,-0.0071,0.0154,0.0072,0.2188,0.0338,-0.6515,-1.4835,0.2351,0.1454],[5.091,-0.0074,0.0154,0.0072,0.2117,0.0291,-0.6265,-1.4835,0.2351,0.1454],[5.121,-0.0076,0.0155,0.0072,0.2075,0.026,-0.5962,-1.4835,0.2351,0.1454],[5.152,-0.0076,0.0154,0.0069,0.2031,0.0254,-0.5609,-1.4835,0.2351,0.1454],[5.182,-0.0076,0.0142,0.007,0.1962,0.0139,-0.5199,-1.4835,0.2351,0.1454],[5.212,-0.0078,0.0135,0.0069,0.1877,0.0033,-0.4797,-1.4705,0.2351,0.1454],[5.242,-0.0081,0.0128,0.0069,0.1808,-0.0065,-0.4406,-1.4261,0.2351,0.1454],[5.273,-0.0086,0.0125,0.0067,0.1795,-0.0056,-0.4057,-1.3604,0.2351,0.1454],[5.303,-0.0087,0.012,0.0065,0.176,-0.0049,-0.3735,-1.2916,0.2351,0.1454],[5.333,-0.0088,0.0112,0.0064,0.1689,-0.0127,-0.3287,-1.2231,0.2351,0.1454],[5.364,-0.0095,0.0106,0.0065,0.1634,-0.0219,-0.2858,-1.1526,0.2351,0.1454],[5.394,-0.0099,0.0097,0.0065,0.1565,-0.036,-0.2519,-1.0728,0.2351,0.1454],[5.424,-0.01,0.0089,0.0062,0.1511,-0.0456,-0.2259,-0.9817,0.2351,0.1454],[5.455,-0.0102,0.0086,0.0059,0.1403,-0.0482,-0.1965,-0.8799,0.2351,0.1454],[5.485,-0.0106,0.0075,0.0059,0.1293,-0.0533,-0.1681,-0.7768,0.2351,0.1454],[5.515,-0.0106,0.0077,0.0057,0.1253,-0.0518,-0.1509,-0.6734,0.2351,0.1454],[5.545,-0.0102,0.007,0.0056,0.1237,-0.0482,-0.1324,-0.5698,0.2351,0.1454],[5.576,-0.0105,0.0063,0.0062,0.1168,-0.0508,-0.1118,-0.4727,0.2351,0.1454],[5.606,-0.0106,0.0061,0.0062,0.1074,-0.0544,-0.0769,-0.4437,0.2351,0.1454],[5.636,-0.0105,0.0057,0.0062,0.1025,-0.0483,-0.0528,-0.4437,0.2351,0.1454],[5.667,-0.0104,0.006,0.0062,0.0937,-0.0476,-0.0312,-0.4437,0.2351,0.1454],[5.697,-0.0102,0.0061,0.0061,0.0851,-0.0477,-0.0004,-0.4437,0.2351,0.1454],[5.727,-0.0101,0.0065,0.0059,0.0788,-0.0426,0.0222,-0.4437,0.2351,0.1454],[5.758,-0.0098,0.0051,0.0066,0.0704,-0.0399,0.047,-0.4437,0.2351,0.1454],[5.788,-0.0098,0.0055,0.0063,0.0631,-0.0344,0.0727,-0.434,0.2351,0.1454],[5.818,-0.0098,0.0059,0.006,0.0552,-0.0248,0.0958,-0.3655,0.2351,0.1454],[5.848,-0.0098,0.0061,0.0058,0.0507,-0.0171,0.1172,-0.2436,0.2351,0.1454],[5.879,-0.0097,0.0062,0.0059,0.0473,-0.012,0.1363,-0.1062,0.2351,0.1454],[5.909,-0.0095,0.0061,0.0058,0.0422,-0.0095,0.1514,-0.0456,0.2351,0.1454],[5.939,-0.0094,0.0062,0.0058,0.0405,-0.0075,0.1717,-0.0456,0.2351,0.1454],[5.97,-0.0096,0.0064,0.0059,0.0386,-0.0037,0.1934,-0.0456,0.2351,0.1454]]},"cheerful1":{"kind":"emotion","duration":2.808,"frames":[[0.0,-0.0134,-0.0045,0.02,-0.0361,0.0113,0.1588,-0.213,0.5258,0.0672],[0.03,-0.0132,-0.0044,0.02,-0.0357,0.0114,0.1589,-0.213,0.5258,0.0672],[0.061,-0.0132,-0.0045,0.02,-0.037,0.0114,0.1584,-0.213,0.5258,0.0672],[0.091,-0.0131,-0.0046,0.02,-0.0366,0.0113,0.1581,-0.213,0.5258,0.0672],[0.121,-0.0131,-0.0046,0.02,-0.0339,0.011,0.1587,-0.213,0.5258,0.0672],[0.152,-0.0131,-0.0047,0.02,-0.0316,0.0109,0.159,-0.213,0.5258,0.0672],[0.182,-0.0132,-0.0049,0.02,-0.0292,0.0097,0.1594,-0.213,0.5258,0.0672],[0.212,-0.0133,-0.0046,0.02,-0.0265,0.0086,0.1604,-0.213,0.5258,0.0672],[0.242,-0.0132,-0.0045,0.02,-0.0251,0.008,0.1606,-0.213,0.5258,0.0672],[0.273,-0.0129,-0.0048,0.02,-0.0218,0.007,0.1616,-0.213,0.5258,0.0672],[0.303,-0.0128,-0.0047,0.02,-0.0156,0.0055,0.1631,-0.213,0.5258,0.0672],[0.333,-0.0129,-0.0046,0.02,-0.0117,0.0031,0.1646,-0.213,0.5258,0.0672],[0.364,-0.013,-0.0045,0.02,-0.0068,0.0002,0.1659,-0.213,0.5258,0.0672],[0.394,-0.0131,-0.0045,0.02,0.0001,-0.0023,0.1676,-0.213,0.5258,0.0672],[0.424,-0.0129,-0.0046,0.02,0.0151,-0.0046,0.1706,-0.213,0.5258,0.0672],[0.455,-0.0129,-0.004,0.02,0.0441,-0.0102,0.1753,-0.213,0.5258,0.0672],[0.485,-0.0129,-0.0037,0.02,0.0849,-0.019,0.1787,-0.213,0.5258,0.0672],[0.515,-0.0129,-0.0033,0.02,0.1426,-0.034,0.1819,-0.213,0.5258,0.0672],[0.545,-0.013,-0.0026,0.02,0.2136,-0.0534,0.1847,-0.213,0.5258,0.0603],[0.576,-0.0133,-0.0018,0.02,0.2831,-0.0736,0.1854,-0.213,0.5258,0.0156],[0.606,-0.0134,-0.0014,0.02,0.3442,-0.0914,0.1817,-0.213,0.5258,-0.0595],[0.636,-0.0132,-0.0014,0.02,0.3917,-0.1087,0.1747,-0.213,0.5258,-0.1413],[0.667,-0.0134,-0.0016,0.02,0.427,-0.1164,0.1718,-0.213,0.5258,-0.2174],[0.697,-0.0134,-0.0026,0.02,0.4543,-0.1222,0.1702,-0.213,0.5258,-0.2897],[0.727,-0.0135,-0.0025,0.02,0.4687,-0.1258,0.1684,-0.213,0.5258,-0.3489],[0.758,-0.0134,-0.0029,0.02,0.4621,-0.1216,0.1687,-0.213,0.5258,-0.3887],[0.788,-0.0132,-0.0034,0.02,0.4376,-0.1159,0.1688,-0.213,0.5258,-0.4291],[0.818,-0.013,-0.0041,0.02,0.3994,-0.1067,0.1722,-0.213,0.5258,-0.459],[0.848,-0.0131,-0.0041,0.02,0.3466,-0.0947,0.178,-0.213,0.5258,-0.4572],[0.879,-0.0129,-0.0042,0.02,0.281,-0.0802,0.1854,-0.213,0.5258,-0.4284],[0.909,-0.0125,-0.0055,0.02,0.2162,-0.0625,0.1905,-0.213,0.5258,-0.373],[0.939,-0.0128,-0.0057,0.02,0.1493,-0.0411,0.192,-0.213,0.5258,-0.2988],[0.97,-0.0131,-0.0057,0.02,0.0819,-0.0189,0.1919,-0.213,0.5258,-0.2216],[1.0,-0.0134,-0.006,0.02,0.0027,0.0058,0.1902,-0.213,0.5258,-0.1496],[1.03,-0.0133,-0.0066,0.02,-0.0783,0.0262,0.183,-0.213,0.5258,-0.0772],[1.061,-0.0134,-0.0073,0.02,-0.1592,0.0452,0.1759,-0.213,0.5258,-0.0086],[1.091,-0.0138,-0.0076,0.02,-0.2391,0.0668,0.1678,-0.213,0.5258,0.0576],[1.121,-0.014,-0.0078,0.02,-0.3211,0.0848,0.1567,-0.213,0.5258,0.0998],[1.152,-0.0139,-0.0086,0.02,-0.3845,0.1004,0.1461,-0.213,0.5258,0.1083],[1.182,-0.0138,-0.0094,0.02,-0.4253,0.1116,0.1385,-0.213,0.5258,0.1083],[1.212,-0.0139,-0.0098,0.02,-0.4487,0.1173,0.1368,-0.213,0.5258,0.1083],[1.242,-0.0139,-0.0098,0.02,-0.4579,0.1196,0.1369,-0.213,0.5258,0.1083],[1.273,-0.014,-0.0099,0.02,-0.4461,0.1178,0.1399,-0.213,0.5258,0.1083],[1.303,-0.0138,-0.0098,0.02,-0.4211,0.1116,0.1462,-0.213,0.5258,0.1083],[1.333,-0.0136,-0.0095,0.02,-0.3847,0.1033,0.1538,-0.213,0.5258,0.0962],[1.364,-0.0137,-0.0087,0.02,-0.3406,0.091,0.1623,-0.213,0.5258,0.043],[1.394,-0.0136,-0.0084,0.02,-0.2878,0.0785,0.1701,-0.213,0.5258,-0.0324],[1.424,-0.0134,-0.0086,0.02,-0.2292,0.064,0.1782,-0.213,0.5258,-0.1077],[1.455,-0.0133,-0.0075,0.02,-0.1717,0.0474,0.1874,-0.213,0.5258,-0.169],[1.485,-0.0131,-0.0069,0.02,-0.1033,0.0324,0.1966,-0.213,0.5258,-0.1899],[1.515,-0.013,-0.0055,0.02,-0.0226,0.0145,0.2052,-0.213,0.5258,-0.1899],[1.545,-0.0131,-0.0046,0.02,0.0539,-0.0047,0.2129,-0.213,0.5258,-0.1899],[1.576,-0.013,-0.004,0.02,0.1294,-0.0263,0.2169,-0.213,0.5258,-0.1899],[1.606,-0.013,-0.0031,0.02,0.2048,-0.0438,0.218,-0.213,0.5258,-0.1899],[1.636,-0.013,-0.0026,0.02,0.265,-0.0564,0.2192,-0.213,0.5258,-0.1899],[1.667,-0.013,-0.0024,0.02,0.3118,-0.0693,0.2169,-0.213,0.5258,-0.1899],[1.697,-0.0131,-0.002,0.02,0.338,-0.0778,0.2142,-0.213,0.5258,-0.1899],[1.727,-0.0131,-0.0021,0.02,0.3391,-0.0806,0.2106,-0.213,0.5258,-0.1899],[1.758,-0.0132,-0.0025,0.02,0.321,-0.0782,0.2085,-0.213,0.5258,-0.1899],[1.788,-0.0132,-0.0027,0.02,0.3006,-0.0736,0.2079,-0.213,0.5258,-0.1899],[1.818,-0.0129,-0.003,0.02,0.2755,-0.0653,0.2081,-0.213,0.5258,-0.1899],[1.848,-0.0127,-0.0033,0.02,0.2477,-0.0595,0.208,-0.213,0.5258,-0.1899],[1.879,-0.0125,-0.0038,0.02,0.2058,-0.052,0.2071,-0.213,0.5258,-0.1899],[1.909,-0.0125,-0.0041,0.02,0.1413,-0.0329,0.2066,-0.213,0.5258,-0.1668],[1.939,-0.0122,-0.0052,0.02,0.0678,-0.0089,0.2016,-0.213,0.5258,-0.1175],[1.97,-0.0118,-0.0061,0.02,-0.0097,0.0126,0.1911,-0.213,0.5258,-0.0683],[2.0,-0.0119,-0.0071,0.02,-0.0835,0.0329,0.1779,-0.213,0.5258,-0.0568],[2.03,-0.0121,-0.008,0.02,-0.1447,0.051,0.1655,-0.213,0.5258,-0.0568],[2.061,-0.0123,-0.0084,0.02,-0.1865,0.0599,0.1566,-0.213,0.5258,-0.0568],[2.091,-0.0125,-0.0081,0.02,-0.2002,0.0612,0.1546,-0.213,0.5258,-0.0568],[2.121,-0.0122,-0.0079,0.02,-0.2006,0.0591,0.155,-0.213,0.5258,-0.0568],[2.152,-0.0124,-0.0075,0.02,-0.1974,0.0548,0.1584,-0.213,0.5258,-0.0568],[2.182,-0.0127,-0.0073,0.02,-0.1926,0.0497,0.1609,-0.213,0.5258,-0.0568],[2.212,-0.0128,-0.0073,0.02,-0.1894,0.0486,0.1632,-0.213,0.5258,-0.0568],[2.242,-0.013,-0.0069,0.02,-0.1866,0.0468,0.1669,-0.213,0.5258,-0.0568],[2.273,-0.0131,-0.0069,0.02,-0.1758,0.0434,0.1732,-0.213,0.5258,-0.0568],[2.303,-0.0134,-0.0063,0.02,-0.1661,0.0375,0.1842,-0.213,0.5258,-0.0568],[2.333,-0.0137,-0.0057,0.02,-0.1522,0.0327,0.1961,-0.213,0.5258,-0.0568],[2.364,-0.0143,-0.0057,0.02,-0.1367,0.0316,0.2079,-0.213,0.5258,-0.0568],[2.394,-0.0144,-0.0052,0.02,-0.1161,0.0263,0.2267,-0.213,0.5258,-0.0568],[2.424,-0.0145,-0.0051,0.02,-0.0941,0.0176,0.2435,-0.213,0.5258,-0.0568],[2.455,-0.0141,-0.0058,0.02,-0.0744,0.0082,0.2622,-0.213,0.5258,-0.0568],[2.485,-0.0141,-0.0063,0.02,-0.0613,0.0063,0.2815,-0.213,0.5258,-0.0568],[2.515,-0.0143,-0.0067,0.02,-0.0453,0.0055,0.2945,-0.213,0.5258,-0.0568],[2.545,-0.0145,-0.007,0.02,-0.0371,0.0029,0.3049,-0.213,0.5258,-0.0568],[2.576,-0.0143,-0.0082,0.02,-0.0344,-0.0015,0.3196,-0.213,0.5258,-0.0568],[2.606,-0.0143,-0.0086,0.02,-0.0308,-0.002,0.3253,-0.213,0.5258,-0.0568],[2.636,-0.0145,-0.0092,0.02,-0.0324,-0.0014,0.3268,-0.213,0.5258,-0.0568],[2.667,-0.0146,-0.0096,0.02,-0.0375,-0.005,0.3328,-0.213,0.5258,-0.0568],[2.697,-0.0148,-0.0099,0.02,-0.0351,-0.0053,0.3373,-0.213,0.5258,-0.0568],[2.727,-0.0148,-0.0104,0.02,-0.0321,-0.0049,0.3375,-0.213,0.5258,-0.0568],[2.758,-0.0148,-0.0112,0.02,-0.0311,-0.004,0.332,-0.213,0.5258,-0.0568],[2.788,-0.0148,-0.012,0.02,-0.0291,-0.003,0.3155,-0.213,0.5258,-0.0568]]},"amazed1":{"kind":"emotion","duration":3.432,"frames":[[0.0,-0.0016,0.0021,0.0054,-0.259,0.0202,-0.0304,-0.3318,0.7662,0.0],[0.03,-0.0017,0.002,0.0055,-0.2693,0.0251,-0.0303,-0.3318,0.7985,0.0],[0.061,-0.0018,0.0016,0.0056,-0.281,0.0286,-0.0311,-0.3318,0.832,0.0],[0.091,-0.002,0.0013,0.0057,-0.2948,0.0328,-0.0321,-0.3318,0.8658,0.0],[0.121,-0.0022,0.001,0.0059,-0.3091,0.0371,-0.033,-0.3318,0.8994,0.0],[0.152,-0.0025,0.001,0.006,-0.321,0.0413,-0.0339,-0.3318,0.9331,0.0],[0.182,-0.0026,0.0007,0.0063,-0.3323,0.0452,-0.0348,-0.3318,0.9669,0.0],[0.212,-0.0026,0.0005,0.0063,-0.3456,0.0504,-0.0367,-0.3318,1.0006,0.0],[0.242,-0.0028,0.0004,0.0061,-0.356,0.0543,-0.0389,-0.3318,1.0343,0.0],[0.273,-0.0029,0.0001,0.0062,-0.3633,0.0571,-0.04,-0.3318,1.0679,0.0],[0.303,-0.0032,0.0,0.0066,-0.3715,0.0596,-0.0417,-0.3318,1.1017,0.0],[0.333,-0.0033,-0.0001,0.0067,-0.3798,0.0625,-0.0431,-0.3318,1.1354,0.0],[0.364,-0.0033,-0.0001,0.0067,-0.3889,0.0659,-0.0452,-0.3318,1.1691,0.0],[0.394,-0.0035,-0.0003,0.0068,-0.3978,0.0688,-0.0467,-0.3318,1.2028,0.0],[0.424,-0.0037,-0.0002,0.0067,-0.4052,0.0717,-0.0473,-0.3318,1.2363,0.0],[0.455,-0.0039,-0.0002,0.0068,-0.4126,0.0748,-0.0477,-0.3318,1.2701,0.0],[0.485,-0.0041,-0.0,0.0067,-0.4216,0.0777,-0.0484,-0.3318,1.3037,0.0],[0.515,-0.0042,0.0,0.0067,-0.4301,0.081,-0.0499,-0.3318,1.3383,0.0],[0.545,-0.0043,0.0,0.0067,-0.4381,0.0846,-0.0522,-0.3318,1.3737,0.0],[0.576,-0.0044,-0.0001,0.0067,-0.4458,0.0866,-0.0544,-0.3318,1.4092,0.0],[0.606,-0.0044,-0.0001,0.0067,-0.4486,0.088,-0.0557,-0.3318,1.4463,0.0],[0.636,-0.0044,-0.0003,0.0068,-0.4523,0.0876,-0.0584,-0.3318,1.4844,0.0],[0.667,-0.0044,-0.0006,0.0069,-0.4616,0.0873,-0.0612,-0.3318,1.5226,0.0],[0.697,-0.0043,-0.0007,0.0069,-0.4676,0.0876,-0.064,-0.3318,1.5605,0.0],[0.727,-0.0042,-0.0008,0.0067,-0.4677,0.0882,-0.0644,-0.3318,1.5885,0.0],[0.758,-0.0042,-0.0007,0.0067,-0.4664,0.0879,-0.0638,-0.3318,1.5885,0.0],[0.788,-0.0042,-0.0005,0.0067,-0.4643,0.0885,-0.0624,-0.3318,1.5885,0.0],[0.818,-0.0042,-0.0003,0.0068,-0.4597,0.0874,-0.0604,-0.3318,1.5885,0.0],[0.848,-0.0043,-0.0002,0.0068,-0.4565,0.0883,-0.0566,-0.3318,1.5885,0.0],[0.879,-0.0044,-0.0001,0.0066,-0.4552,0.0879,-0.0547,-0.3318,1.5885,0.0],[0.909,-0.0044,-0.0,0.0065,-0.4539,0.0876,-0.0546,-0.3318,1.5885,0.0],[0.939,-0.0044,-0.0001,0.0067,-0.4518,0.086,-0.0542,-0.3318,1.5885,0.0],[0.97,-0.0043,0.0,0.0068,-0.4502,0.0863,-0.0535,-0.3318,1.5885,0.0],[1.0,-0.0043,0.0,0.0067,-0.4498,0.0876,-0.0531,-0.3318,1.5885,0.0],[1.03,-0.0043,-0.0001,0.0066,-0.4494,0.0891,-0.053,-0.3318,1.5885,0.0],[1.061,-0.0044,-0.0002,0.0067,-0.4472,0.089,-0.0531,-0.3318,1.5885,0.0],[1.091,-0.0044,0.0,0.0066,-0.4448,0.0894,-0.053,-0.3318,1.5885,0.0],[1.121,-0.0043,0.0001,0.0065,-0.4427,0.0899,-0.053,-0.3318,1.5885,0.0],[1.152,-0.0044,0.0002,0.0065,-0.4411,0.0904,-0.0533,-0.3318,1.5885,0.0],[1.182,-0.0042,-0.0001,0.0066,-0.4402,0.0907,-0.0538,-0.3318,1.5885,0.0],[1.212,-0.0043,-0.0,0.0066,-0.4386,0.0904,-0.0539,-0.3318,1.5885,0.0],[1.242,-0.0043,-0.0,0.0066,-0.4371,0.0897,-0.054,-0.3318,1.5885,0.0],[1.273,-0.0043,0.0002,0.0065,-0.434,0.0887,-0.0543,-0.3318,1.5885,0.0],[1.303,-0.0042,0.0004,0.0064,-0.4243,0.0882,-0.0537,-0.3318,1.5885,0.0],[1.333,-0.0041,0.0006,0.0062,-0.4113,0.0871,-0.0513,-0.3318,1.5885,0.0],[1.364,-0.0039,0.0008,0.0061,-0.3951,0.0897,-0.0494,-0.3318,1.5885,0.0],[1.394,-0.0039,0.0008,0.0059,-0.3822,0.0962,-0.0482,-0.3318,1.5885,0.0],[1.424,-0.0041,0.001,0.0058,-0.3739,0.1014,-0.0461,-0.3318,1.5885,0.0],[1.455,-0.0041,0.0011,0.0055,-0.3637,0.1086,-0.0449,-0.3318,1.5885,0.0],[1.485,-0.0041,0.0011,0.0053,-0.353,0.1151,-0.0433,-0.3318,1.5885,0.0],[1.515,-0.0041,0.0012,0.0052,-0.343,0.1171,-0.0418,-0.3318,1.5885,0.0],[1.545,-0.0041,0.0011,0.0051,-0.3367,0.12,-0.0411,-0.3318,1.5885,0.0],[1.576,-0.0042,0.0011,0.0051,-0.3324,0.1225,-0.0404,-0.3318,1.5885,0.0],[1.606,-0.0043,0.001,0.0051,-0.3296,0.1239,-0.04,-0.3318,1.5885,0.0],[1.636,-0.0045,0.0009,0.0055,-0.3276,0.117,-0.0363,-0.3318,1.5885,0.0],[1.667,-0.0046,0.0007,0.0056,-0.3252,0.1126,-0.0333,-0.3318,1.5885,0.0],[1.697,-0.0046,0.0007,0.0058,-0.3222,0.1026,-0.028,-0.3318,1.5885,0.0],[1.727,-0.0047,0.0007,0.006,-0.3207,0.0932,-0.0238,-0.3318,1.5885,0.0],[1.758,-0.0047,0.0007,0.0059,-0.3208,0.0885,-0.0208,-0.3318,1.5885,0.0],[1.788,-0.0048,0.0007,0.006,-0.3219,0.0768,-0.0143,-0.3318,1.5885,0.0],[1.818,-0.0049,0.0006,0.0063,-0.3209,0.0642,-0.0082,-0.3318,1.5885,0.0],[1.848,-0.0049,0.0007,0.0064,-0.3191,0.054,-0.0033,-0.3318,1.5885,0.0],[1.879,-0.0048,0.0008,0.0066,-0.3155,0.042,0.002,-0.3318,1.5885,0.0],[1.909,-0.0049,0.0006,0.0069,-0.3114,0.0228,0.0099,-0.3318,1.5885,0.0],[1.939,-0.0048,0.0007,0.0069,-0.3088,0.0118,0.0143,-0.3318,1.5885,0.0],[1.97,-0.0049,0.0007,0.0071,-0.3079,-0.0005,0.0191,-0.3318,1.5885,0.0],[2.0,-0.0049,0.0007,0.0072,-0.3052,-0.0112,0.0236,-0.3318,1.5885,0.0],[2.03,-0.0049,0.001,0.0072,-0.3028,-0.0135,0.0254,-0.3318,1.5885,0.0],[2.061,-0.005,0.0011,0.0075,-0.2975,-0.0269,0.0299,-0.3318,1.5885,0.0],[2.091,-0.005,0.0011,0.0074,-0.295,-0.0362,0.0342,-0.3318,1.5885,0.0],[2.121,-0.0051,0.0011,0.0075,-0.2949,-0.043,0.0367,-0.3318,1.5885,0.0],[2.152,-0.0052,0.0011,0.0075,-0.2946,-0.0507,0.0404,-0.3318,1.5885,0.0],[2.182,-0.0053,0.0011,0.0075,-0.2948,-0.058,0.044,-0.3318,1.5885,0.0],[2.212,-0.0052,0.0011,0.0074,-0.2955,-0.0613,0.0457,-0.3318,1.5885,0.0],[2.242,-0.0051,0.001,0.0073,-0.2958,-0.0638,0.0473,-0.3318,1.5885,0.0],[2.273,-0.0052,0.0011,0.0072,-0.2953,-0.064,0.0475,-0.3318,1.5885,0.0],[2.303,-0.0051,0.0009,0.0073,-0.2944,-0.0612,0.0475,-0.3318,1.5885,0.0],[2.333,-0.0052,0.0009,0.0073,-0.2937,-0.0597,0.0477,-0.3318,1.5885,0.0],[2.364,-0.0053,0.0011,0.0073,-0.2907,-0.0578,0.0464,-0.3318,1.5885,0.0],[2.394,-0.0053,0.0011,0.0072,-0.2883,-0.0564,0.0458,-0.3318,1.5885,0.0],[2.424,-0.0052,0.0011,0.0071,-0.2856,-0.0548,0.0458,-0.3318,1.5885,0.0],[2.455,-0.0051,0.0011,0.0068,-0.2815,-0.0535,0.0462,-0.3318,1.5885,0.0],[2.485,-0.0052,0.0012,0.0069,-0.2717,-0.0567,0.0474,-0.3318,1.5885,0.0],[2.515,-0.005,0.0015,0.0068,-0.2569,-0.0579,0.0485,-0.3318,1.5885,0.0],[2.545,-0.0048,0.0017,0.0063,-0.2345,-0.059,0.0512,-0.3318,1.5885,0.0],[2.576,-0.0046,0.0017,0.006,-0.2102,-0.0612,0.0539,-0.3318,1.5885,0.0],[2.606,-0.0043,0.0018,0.0059,-0.1989,-0.0622,0.0589,-0.3318,1.5885,0.0],[2.636,-0.0041,0.0018,0.0058,-0.1896,-0.0633,0.0656,-0.3318,1.5885,0.0],[2.667,-0.0041,0.0017,0.0058,-0.1789,-0.0656,0.0689,-0.3318,1.5885,0.0],[2.697,-0.004,0.0016,0.0056,-0.1735,-0.0668,0.0724,-0.3318,1.5885,0.0],[2.727,-0.0041,0.0016,0.0054,-0.1697,-0.0668,0.0763,-0.3318,1.5885,0.0],[2.758,-0.0039,0.0017,0.0053,-0.1643,-0.0672,0.0792,-0.3318,1.5804,0.0],[2.788,-0.0039,0.0018,0.0052,-0.1528,-0.068,0.0817,-0.3318,1.5592,0.0],[2.818,-0.0039,0.0018,0.0049,-0.145,-0.069,0.0847,-0.3318,1.5288,0.0],[2.848,-0.0036,0.0018,0.0047,-0.1339,-0.0704,0.0883,-0.3318,1.4842,0.0],[2.879,-0.0037,0.0017,0.0048,-0.1264,-0.0711,0.0898,-0.3318,1.4281,0.0],[2.909,-0.0035,0.0014,0.005,-0.1202,-0.0713,0.0912,-0.3318,1.3662,0.0],[2.939,-0.0034,0.0014,0.0049,-0.108,-0.0711,0.0934,-0.3318,1.2987,0.0],[2.97,-0.0033,0.0015,0.0048,-0.0975,-0.0712,0.0956,-0.3318,1.2303,0.0],[3.0,-0.0032,0.0013,0.0045,-0.0932,-0.0704,0.0984,-0.3318,1.1625,0.0],[3.03,-0.0032,0.0013,0.0046,-0.09,-0.067,0.0999,-0.3318,1.0937,0.0],[3.061,-0.0031,0.0012,0.0048,-0.0851,-0.0618,0.1006,-0.3318,1.0267,0.0],[3.091,-0.003,0.0012,0.0047,-0.0805,-0.054,0.1004,-0.3318,0.9609,0.0],[3.121,-0.0028,0.0011,0.0044,-0.0772,-0.0472,0.1009,-0.3318,0.8952,0.0],[3.152,-0.0027,0.0011,0.0044,-0.0759,-0.0418,0.1035,-0.3318,0.8291,0.0],[3.182,-0.0027,0.0012,0.0044,-0.0732,-0.0358,0.1061,-0.3318,0.7636,0.0],[3.212,-0.0026,0.0014,0.0041,-0.0657,-0.0315,0.111,-0.3318,0.6986,0.0],[3.242,-0.0024,0.0016,0.0037,-0.0589,-0.0276,0.1163,-0.3318,0.6852,0.0],[3.273,-0.0021,0.0015,0.0032,-0.0492,-0.0232,0.1228,-0.3318,0.6852,0.0],[3.303,-0.002,0.0017,0.003,-0.0402,-0.0199,0.1275,-0.3318,0.6852,0.0],[3.333,-0.0018,0.0017,0.0028,-0.0318,-0.0178,0.1332,-0.3318,0.6852,0.0],[3.364,-0.0016,0.0015,0.0026,-0.0266,-0.0144,0.1371,-0.3318,0.6852,0.0],[3.394,-0.0014,0.0013,0.0027,-0.0229,-0.0096,0.1394,-0.3318,0.6852,0.0],[3.424,-0.001,0.0011,0.0025,-0.0196,-0.0049,0.1432,-0.3318,0.6852,0.0]]},"welcoming1":{"kind":"emotion","duration":3.462,"frames":[[0.0,-0.0066,-0.0108,0.01,0.0487,-0.0946,-0.0186,-0.1371,0.0794,0.0],[0.03,-0.0066,-0.0111,0.0101,0.0493,-0.0941,-0.0187,-0.1371,0.0794,0.0],[0.061,-0.0065,-0.0111,0.0103,0.0499,-0.094,-0.0199,-0.1371,0.0794,0.0],[0.091,-0.0063,-0.0105,0.01,0.0505,-0.0938,-0.0211,-0.1371,0.0794,0.0],[0.121,-0.0063,-0.0104,0.01,0.05,-0.0936,-0.0211,-0.1371,0.0794,0.0],[0.152,-0.0062,-0.0102,0.01,0.0497,-0.0931,-0.0209,-0.1371,0.0794,0.0],[0.182,-0.0062,-0.0105,0.0101,0.0497,-0.0924,-0.0204,-0.1371,0.0794,0.0],[0.212,-0.0061,-0.0101,0.0099,0.0497,-0.0926,-0.02,-0.1371,0.0794,0.0],[0.242,-0.006,-0.0103,0.0102,0.0494,-0.0926,-0.0194,-0.1371,0.0794,0.0],[0.273,-0.0059,-0.0101,0.01,0.049,-0.0924,-0.0185,-0.1371,0.0794,0.0],[0.303,-0.0059,-0.0103,0.0102,0.049,-0.092,-0.0177,-0.1371,0.0794,0.0],[0.333,-0.0058,-0.0105,0.0104,0.0491,-0.0912,-0.0165,-0.1371,0.0794,0.0],[0.364,-0.0057,-0.0103,0.0104,0.0481,-0.0908,-0.0151,-0.1371,0.0794,0.0],[0.394,-0.0057,-0.0101,0.0102,0.0475,-0.0906,-0.014,-0.1371,0.0794,0.0],[0.424,-0.0057,-0.0099,0.01,0.0472,-0.0905,-0.0131,-0.1371,0.0794,0.0],[0.455,-0.0057,-0.0097,0.01,0.0467,-0.09,-0.0126,-0.1371,0.0794,0.0],[0.485,-0.0057,-0.0104,0.0103,0.0461,-0.0893,-0.0117,-0.1371,0.0794,0.0],[0.515,-0.0057,-0.01,0.01,0.0457,-0.0883,-0.0111,-0.1371,0.0794,0.0],[0.545,-0.0057,-0.0095,0.0096,0.0452,-0.0874,-0.011,-0.1371,0.0794,0.0],[0.576,-0.0058,-0.0095,0.0095,0.0445,-0.0874,-0.0112,-0.1371,0.0794,0.0],[0.606,-0.0059,-0.0094,0.0094,0.0443,-0.0871,-0.0109,-0.1371,0.0794,0.0],[0.636,-0.0061,-0.0095,0.0093,0.0436,-0.0871,-0.0114,-0.1371,0.0794,0.0],[0.667,-0.0062,-0.0099,0.0093,0.0437,-0.087,-0.0113,-0.1371,0.0794,0.0],[0.697,-0.0063,-0.01,0.0093,0.044,-0.0865,-0.0111,-0.1371,0.0794,0.0],[0.727,-0.0064,-0.0104,0.0095,0.044,-0.0861,-0.0109,-0.1371,0.0794,0.0],[0.758,-0.0066,-0.0109,0.0097,0.0438,-0.0856,-0.0103,-0.1371,0.0794,0.0],[0.788,-0.0068,-0.0112,0.0098,0.0435,-0.0842,-0.0095,-0.1371,0.0794,0.0],[0.818,-0.0068,-0.0111,0.0097,0.0428,-0.0831,-0.0091,-0.1371,0.0794,0.0],[0.848,-0.0067,-0.0103,0.0094,0.0423,-0.0829,-0.0096,-0.1371,0.0794,0.0],[0.879,-0.0065,-0.01,0.0092,0.0421,-0.0853,-0.0124,-0.1371,0.0794,0.0],[0.909,-0.0065,-0.0099,0.0091,0.0423,-0.0857,-0.0125,-0.1371,0.0794,0.0],[0.939,-0.0065,-0.01,0.0091,0.0429,-0.0869,-0.0128,-0.1371,0.0794,0.0],[0.97,-0.0065,-0.0105,0.0094,0.0432,-0.0895,-0.0145,-0.1371,0.0794,0.0],[1.0,-0.0065,-0.0103,0.0095,0.0443,-0.091,-0.0149,-0.1371,0.0794,0.0],[1.03,-0.0064,-0.0104,0.0097,0.0455,-0.0928,-0.0158,-0.1371,0.0794,0.0],[1.061,-0.0063,-0.0103,0.0096,0.0454,-0.0928,-0.0153,-0.1371,0.0794,0.0],[1.091,-0.0063,-0.0108,0.0098,0.045,-0.0933,-0.0157,-0.1371,0.0794,0.0],[1.121,-0.0062,-0.0106,0.01,0.0443,-0.0934,-0.0155,-0.1371,0.0794,0.0],[1.152,-0.0062,-0.0109,0.0104,0.0452,-0.0947,-0.0158,-0.1371,0.0794,0.0],[1.182,-0.0062,-0.0116,0.0108,0.0459,-0.0953,-0.016,-0.1371,0.0794,0.0],[1.212,-0.0062,-0.0119,0.011,0.0475,-0.0956,-0.0162,-0.1371,0.0794,0.0],[1.242,-0.0061,-0.0117,0.011,0.0511,-0.096,-0.0161,-0.1371,0.0794,0.0],[1.273,-0.006,-0.0113,0.011,0.0577,-0.0973,-0.0165,-0.1371,0.0794,0.0],[1.303,-0.0058,-0.0116,0.011,0.0679,-0.0977,-0.0159,-0.1371,0.0794,0.0],[1.333,-0.0056,-0.0118,0.0109,0.0847,-0.0979,-0.0151,-0.1371,0.0794,0.0],[1.364,-0.0055,-0.012,0.0108,0.1023,-0.0991,-0.0167,-0.1371,0.0794,0.0],[1.394,-0.0054,-0.0123,0.0109,0.1182,-0.1004,-0.0184,-0.1371,0.0794,0.0],[1.424,-0.0051,-0.0119,0.0106,0.1342,-0.1005,-0.0198,-0.1402,0.0898,0.0],[1.455,-0.0048,-0.0117,0.0103,0.1528,-0.0996,-0.0201,-0.1713,0.1272,0.0],[1.485,-0.0045,-0.0112,0.0099,0.1748,-0.0999,-0.0199,-0.2269,0.1989,0.0],[1.515,-0.0041,-0.0105,0.0093,0.2026,-0.1,-0.0175,-0.3082,0.3186,0.0],[1.545,-0.0034,-0.0097,0.0084,0.2385,-0.0999,-0.0131,-0.4257,0.4708,0.0],[1.576,-0.0026,-0.0089,0.0075,0.2762,-0.1003,-0.0091,-0.5678,0.6285,0.0],[1.606,-0.0022,-0.0082,0.0069,0.2999,-0.0994,-0.0084,-0.7188,0.786,0.0],[1.636,-0.0019,-0.0079,0.0066,0.3129,-0.0979,-0.0084,-0.8704,0.9438,0.0],[1.667,-0.0016,-0.0078,0.0061,0.3173,-0.0957,-0.0088,-1.0218,1.0995,0.0],[1.697,-0.0015,-0.008,0.006,0.3191,-0.0925,-0.0085,-1.1633,1.1659,0.0],[1.727,-0.0014,-0.0083,0.0062,0.321,-0.0908,-0.0088,-1.1769,1.1659,0.0],[1.758,-0.0014,-0.0085,0.0064,0.3208,-0.0913,-0.01,-1.1769,1.1659,0.0],[1.788,-0.0013,-0.0085,0.0064,0.3129,-0.093,-0.0116,-1.1769,1.1659,0.0],[1.818,-0.0012,-0.0091,0.0067,0.2938,-0.0939,-0.0117,-1.1769,1.1659,0.0],[1.848,-0.0011,-0.0098,0.0074,0.2625,-0.0968,-0.0131,-1.1769,1.1659,0.0],[1.879,-0.0009,-0.0109,0.0079,0.2142,-0.1031,-0.0208,-1.1769,1.1659,0.0],[1.909,-0.0008,-0.0118,0.0084,0.1532,-0.1061,-0.029,-1.1769,1.1659,0.0],[1.939,-0.0008,-0.0128,0.0087,0.0965,-0.1021,-0.0338,-1.1769,1.1659,0.0],[1.97,-0.0007,-0.0134,0.009,0.0481,-0.096,-0.0364,-1.1769,1.1659,0.0],[2.0,-0.0005,-0.0138,0.0089,0.0033,-0.0932,-0.04,-1.1769,1.1599,0.0],[2.03,-0.0005,-0.0142,0.0093,-0.0389,-0.0931,-0.0433,-1.1207,1.0683,0.0],[2.061,-0.0003,-0.0145,0.0096,-0.078,-0.089,-0.0452,-0.9706,0.9114,0.0],[2.091,-0.0003,-0.015,0.0096,-0.1119,-0.0835,-0.0444,-0.8125,0.7533,0.0],[2.121,-0.0,-0.0155,0.0097,-0.1442,-0.0814,-0.0451,-0.6581,0.5989,0.0],[2.152,0.0002,-0.0162,0.0095,-0.1767,-0.08,-0.0484,-0.5248,0.5107,0.0],[2.182,0.0004,-0.0164,0.0095,-0.205,-0.0802,-0.0503,-0.4359,0.5107,0.0],[2.212,0.0005,-0.0167,0.0096,-0.2265,-0.084,-0.0518,-0.3499,0.5107,0.0],[2.242,0.0007,-0.0172,0.0094,-0.2436,-0.086,-0.0519,-0.3157,0.5107,0.0],[2.273,0.0008,-0.0177,0.0095,-0.2552,-0.0882,-0.0531,-0.3157,0.5107,0.0],[2.303,0.0011,-0.0179,0.0093,-0.2661,-0.0938,-0.0537,-0.3157,0.5107,0.0],[2.333,0.0014,-0.0183,0.0094,-0.2739,-0.0988,-0.0528,-0.3157,0.5107,0.0],[2.364,0.0016,-0.0187,0.0091,-0.2836,-0.1016,-0.0528,-0.3157,0.5107,0.0],[2.394,0.0017,-0.0187,0.0092,-0.293,-0.1035,-0.0541,-0.3157,0.5107,0.0],[2.424,0.0019,-0.0188,0.009,-0.2991,-0.1043,-0.0548,-0.3157,0.5107,0.0],[2.455,0.0019,-0.0192,0.0091,-0.3016,-0.1037,-0.0543,-0.3157,0.5107,0.0],[2.485,0.002,-0.0191,0.0091,-0.3013,-0.1032,-0.054,-0.3157,0.5107,0.0],[2.515,0.002,-0.0196,0.009,-0.302,-0.1027,-0.0544,-0.3157,0.5107,0.0],[2.545,0.0018,-0.0198,0.0092,-0.305,-0.1021,-0.0553,-0.3157,0.5107,0.0],[2.576,0.0018,-0.02,0.0092,-0.3067,-0.1012,-0.0556,-0.3157,0.5107,0.0],[2.606,0.0019,-0.0198,0.0091,-0.309,-0.1015,-0.0563,-0.3157,0.5107,0.0],[2.636,0.002,-0.0198,0.009,-0.3121,-0.1005,-0.0566,-0.3157,0.5107,0.0],[2.667,0.002,-0.0197,0.0087,-0.3141,-0.0991,-0.0563,-0.3157,0.5107,0.0],[2.697,0.002,-0.0195,0.0088,-0.3124,-0.0987,-0.0566,-0.3157,0.5107,0.0],[2.727,0.0021,-0.0192,0.0086,-0.3076,-0.0975,-0.0565,-0.3157,0.5107,0.0],[2.758,0.0024,-0.0185,0.0081,-0.2954,-0.0963,-0.0546,-0.3157,0.5107,0.0],[2.788,0.0024,-0.0184,0.0077,-0.27,-0.0954,-0.0511,-0.3157,0.5107,0.0],[2.818,0.0024,-0.0176,0.0076,-0.2249,-0.0982,-0.0471,-0.3157,0.5107,0.0],[2.848,0.0028,-0.0162,0.0078,-0.1747,-0.1022,-0.0434,-0.3157,0.5107,0.0],[2.879,0.003,-0.0155,0.0073,-0.1363,-0.1031,-0.0436,-0.3157,0.5107,0.0],[2.909,0.003,-0.0154,0.0071,-0.104,-0.103,-0.0453,-0.3157,0.5107,0.0],[2.939,0.0031,-0.0154,0.0073,-0.0772,-0.1041,-0.0456,-0.3157,0.5107,0.0],[2.97,0.0031,-0.015,0.0077,-0.0575,-0.104,-0.0465,-0.3157,0.5107,0.0],[3.0,0.003,-0.0154,0.0079,-0.037,-0.1042,-0.0464,-0.3157,0.5107,0.0],[3.03,0.0031,-0.0153,0.0075,-0.0227,-0.1042,-0.0458,-0.3157,0.5107,0.0],[3.061,0.003,-0.0157,0.0078,-0.0131,-0.1031,-0.0456,-0.3157,0.5107,0.0],[3.091,0.0028,-0.0155,0.0082,-0.0048,-0.1021,-0.0456,-0.3157,0.5107,0.0],[3.121,0.0027,-0.0152,0.0085,0.0019,-0.1012,-0.0457,-0.3157,0.5107,0.0],[3.152,0.0027,-0.0154,0.0084,0.0075,-0.0996,-0.0455,-0.3157,0.5107,0.0],[3.182,0.0027,-0.0153,0.0082,0.0131,-0.0979,-0.0453,-0.3157,0.5107,0.0],[3.212,0.0023,-0.0156,0.0084,0.0226,-0.0966,-0.0438,-0.3157,0.5107,0.0],[3.242,0.0021,-0.0151,0.0087,0.0328,-0.0952,-0.0418,-0.3157,0.5107,0.0],[3.273,0.0018,-0.0147,0.0089,0.0427,-0.0925,-0.0403,-0.3157,0.5107,0.0],[3.303,0.0017,-0.0146,0.0088,0.0506,-0.0911,-0.0382,-0.3157,0.5107,0.0],[3.333,0.0015,-0.0144,0.0085,0.0557,-0.0897,-0.0368,-0.3157,0.5107,0.0],[3.364,0.0011,-0.0145,0.0087,0.06,-0.0882,-0.0346,-0.3157,0.5107,0.0],[3.394,0.0009,-0.0136,0.0087,0.0644,-0.0884,-0.033,-0.3157,0.5107,0.0],[3.424,0.0006,-0.0139,0.0088,0.0674,-0.0897,-0.0314,-0.3157,0.5107,0.0],[3.455,0.0,-0.0138,0.0089,0.0663,-0.0935,-0.0294,-0.3157,0.5107,0.0]]},"confused1":{"kind":"emotion","duration":6.0,"frames":[[0.0,-0.0064,-0.0036,0.02,-0.0947,0.022,-0.1699,-0.0113,0.0975,-0.0051],[0.03,-0.0064,-0.0035,0.02,-0.0951,0.0213,-0.1714,-0.0113,0.0975,-0.0051],[0.061,-0.0063,-0.0035,0.02,-0.0952,0.0213,-0.1727,-0.0113,0.0975,-0.0051],[0.091,-0.0065,-0.0032,0.02,-0.0952,0.0215,-0.1742,-0.0113,0.0975,-0.0051],[0.121,-0.0065,-0.003,0.02,-0.0949,0.0224,-0.1753,-0.0113,0.0975,-0.0051],[0.152,-0.0067,-0.0028,0.02,-0.096,0.0222,-0.1775,-0.0113,0.0975,-0.0051],[0.182,-0.0068,-0.0027,0.02,-0.0954,0.0235,-0.18,-0.0113,0.0975,-0.0051],[0.212,-0.0068,-0.0026,0.02,-0.0956,0.0236,-0.1821,-0.0113,0.0975,-0.0051],[0.242,-0.0068,-0.0024,0.02,-0.0957,0.0234,-0.1851,-0.0113,0.0975,-0.0051],[0.273,-0.007,-0.0018,0.02,-0.095,0.0247,-0.189,-0.0113,0.0975,-0.0051],[0.303,-0.0071,-0.0016,0.02,-0.0943,0.0253,-0.1917,-0.0113,0.0975,-0.0051],[0.333,-0.0072,-0.0014,0.02,-0.0933,0.0265,-0.1934,-0.0113,0.0975,-0.0051],[0.364,-0.0073,-0.001,0.02,-0.0928,0.0281,-0.195,-0.0113,0.0975,-0.0051],[0.394,-0.0075,-0.0004,0.02,-0.0931,0.0282,-0.1961,-0.0113,0.0975,-0.0051],[0.424,-0.0076,-0.0003,0.02,-0.0923,0.0283,-0.1976,-0.0113,0.107,-0.0051],[0.455,-0.0076,-0.0002,0.02,-0.0913,0.0281,-0.1986,-0.0113,0.1268,-0.0051],[0.485,-0.0077,0.0002,0.02,-0.0901,0.0284,-0.2,-0.0121,0.1494,-0.0051],[0.515,-0.0078,0.0003,0.02,-0.0899,0.0281,-0.2028,-0.0244,0.1739,-0.0051],[0.545,-0.0058,-0.0051,0.02,-0.0899,0.0301,-0.1953,-0.0453,0.2062,-0.0051],[0.576,-0.0063,-0.0045,0.02,-0.0896,0.0305,-0.1981,-0.0796,0.2448,-0.0051],[0.606,-0.0065,-0.0039,0.02,-0.0888,0.0316,-0.2026,-0.1233,0.2853,-0.0051],[0.636,-0.0067,-0.0034,0.02,-0.0891,0.0318,-0.2089,-0.1717,0.326,-0.0051],[0.667,-0.0068,-0.0028,0.02,-0.0878,0.032,-0.2126,-0.2251,0.3679,-0.0051],[0.697,-0.0067,-0.0023,0.02,-0.0867,0.0323,-0.2159,-0.2826,0.4115,-0.0051],[0.727,-0.0069,-0.0016,0.02,-0.0872,0.0335,-0.2199,-0.3425,0.4568,-0.0051],[0.758,-0.0072,-0.0009,0.02,-0.0866,0.0339,-0.2215,-0.4024,0.5022,-0.0051],[0.788,-0.0072,-0.0003,0.02,-0.0859,0.0337,-0.2236,-0.462,0.5508,-0.0051],[0.818,-0.0071,-0.0003,0.02,-0.0849,0.0336,-0.2272,-0.5218,0.6007,-0.0051],[0.848,-0.0071,-0.0001,0.02,-0.0842,0.0347,-0.2321,-0.5816,0.6506,-0.0051],[0.879,-0.0073,0.0002,0.02,-0.0831,0.0338,-0.234,-0.6415,0.7006,-0.0051],[0.909,-0.0074,0.0005,0.02,-0.0823,0.0335,-0.2328,-0.7012,0.7505,-0.0051],[0.939,-0.0075,0.0007,0.02,-0.0818,0.0336,-0.2327,-0.7606,0.8019,-0.0051],[0.97,-0.0074,0.0007,0.02,-0.0808,0.0338,-0.2329,-0.8205,0.857,-0.0051],[1.0,-0.0074,0.001,0.02,-0.0817,0.0332,-0.2349,-0.8805,0.9138,-0.0051],[1.03,-0.0075,0.0012,0.02,-0.0816,0.0322,-0.2374,-0.9404,0.9705,-0.0051],[1.061,-0.0077,0.0014,0.02,-0.0808,0.0328,-0.2377,-1.0001,1.0269,-0.0051],[1.091,-0.0076,0.0017,0.02,-0.0804,0.032,-0.2406,-1.06,1.0842,-0.0051],[1.121,-0.0076,0.002,0.02,-0.0794,0.0309,-0.2433,-1.1197,1.1418,-0.0051],[1.152,-0.0077,0.0022,0.02,-0.078,0.0313,-0.2435,-1.1793,1.2001,-0.0051],[1.182,-0.0077,0.0021,0.02,-0.0788,0.0313,-0.2446,-1.2391,1.2591,-0.0051],[1.212,-0.0076,0.0021,0.02,-0.0792,0.0314,-0.2465,-1.2992,1.319,-0.0051],[1.242,-0.0076,0.0021,0.02,-0.0778,0.0318,-0.2464,-1.3589,1.3794,-0.0051],[1.273,-0.0075,0.0019,0.02,-0.0775,0.0321,-0.2458,-1.4185,1.44,-0.0051],[1.303,-0.0077,0.0022,0.02,-0.078,0.0319,-0.2467,-1.4784,1.5014,-0.0051],[1.333,-0.0078,0.0025,0.02,-0.0776,0.0329,-0.2477,-1.5381,1.5629,-0.0051],[1.364,-0.0079,0.0027,0.02,-0.0767,0.0333,-0.2486,-1.5981,1.6245,-0.0051],[1.394,-0.0079,0.0029,0.02,-0.0754,0.0327,-0.2505,-1.658,1.6857,-0.0051],[1.424,-0.0081,0.0034,0.02,-0.075,0.0318,-0.2533,-1.7177,1.7469,-0.0051],[1.455,-0.0082,0.0037,0.02,-0.074,0.0338,-0.2555,-1.7774,1.8082,-0.0051],[1.485,-0.0082,0.0041,0.02,-0.0727,0.0343,-0.2607,-1.8363,1.8693,-0.0051],[1.515,-0.0083,0.0043,0.02,-0.0722,0.0325,-0.2657,-1.8821,1.9298,-0.0051],[1.545,-0.0084,0.0046,0.02,-0.071,0.0323,-0.2675,-1.9011,1.9826,-0.0051],[1.576,-0.0085,0.0052,0.02,-0.0706,0.0328,-0.2691,-1.9011,2.0108,-0.0051],[1.606,-0.0087,0.0056,0.02,-0.0708,0.0329,-0.271,-1.9011,2.0108,-0.0051],[1.636,-0.0087,0.0058,0.02,-0.0699,0.033,-0.2723,-1.9011,2.0108,-0.0051],[1.667,-0.0086,0.0062,0.02,-0.0708,0.0321,-0.2779,-1.9011,2.0108,-0.0051],[1.697,-0.0087,0.0067,0.02,-0.071,0.032,-0.2829,-1.9011,2.0108,-0.0051],[1.727,-0.0087,0.007,0.02,-0.071,0.0337,-0.2858,-1.9011,2.0108,-0.0051],[1.758,-0.0088,0.0072,0.02,-0.072,0.0355,-0.2905,-1.9011,2.0108,-0.0051],[1.788,-0.0088,0.0072,0.02,-0.0722,0.0374,-0.2946,-1.9011,2.0108,-0.0051],[1.818,-0.0086,0.007,0.02,-0.0717,0.0371,-0.2957,-1.9011,2.0108,-0.0051],[1.848,-0.0084,0.0068,0.02,-0.071,0.0385,-0.2968,-1.9011,2.0108,-0.0051],[1.879,-0.0085,0.0073,0.02,-0.0716,0.0372,-0.3007,-1.9011,2.0108,-0.0051],[1.909,-0.0085,0.0074,0.02,-0.0707,0.0369,-0.3016,-1.9011,2.0108,-0.0051],[1.939,-0.0085,0.0077,0.02,-0.0702,0.038,-0.302,-1.9011,2.0108,-0.0051],[1.97,-0.0085,0.0079,0.02,-0.0699,0.039,-0.304,-1.9011,2.0108,-0.0051],[2.0,-0.0084,0.008,0.02,-0.069,0.0389,-0.3053,-1.9011,2.0108,-0.0051],[2.03,-0.0086,0.0083,0.02,-0.0687,0.0396,-0.3054,-1.9011,2.0108,-0.0051],[2.061,-0.0086,0.0086,0.02,-0.0681,0.0417,-0.3059,-1.9011,2.0108,-0.0051],[2.091,-0.0087,0.0089,0.02,-0.0683,0.0417,-0.3081,-1.9011,2.0108,-0.0051],[2.121,-0.0088,0.0092,0.02,-0.0677,0.0423,-0.3078,-1.9011,2.0108,-0.0233],[2.152,-0.0086,0.0091,0.02,-0.0673,0.0442,-0.3073,-1.9011,2.0108,-0.0556],[2.182,-0.0086,0.0092,0.02,-0.0672,0.0459,-0.3067,-1.9011,2.0108,-0.1031],[2.212,-0.0069,0.0048,0.02,-0.0667,0.0489,-0.2994,-1.9011,2.0108,-0.1566],[2.242,-0.0067,0.0038,0.02,-0.0678,0.0483,-0.2991,-1.9011,2.0108,-0.2117],[2.273,-0.0069,0.0041,0.02,-0.0686,0.0481,-0.3006,-1.9011,2.0108,-0.2699],[2.303,-0.0071,0.0044,0.02,-0.0681,0.0497,-0.3006,-1.9011,2.0108,-0.3308],[2.333,-0.0069,0.0047,0.02,-0.0678,0.0508,-0.3104,-1.9011,2.0108,-0.3918],[2.364,-0.0068,0.0051,0.02,-0.0687,0.0508,-0.3232,-1.9011,2.0108,-0.4504],[2.394,-0.0068,0.0053,0.02,-0.0714,0.049,-0.3368,-1.9011,2.0108,-0.5074],[2.424,-0.0069,0.0059,0.02,-0.079,0.0463,-0.3598,-1.9011,2.0108,-0.5623],[2.455,-0.007,0.0061,0.02,-0.0899,0.0486,-0.3805,-1.9011,2.0108,-0.6148],[2.485,-0.0069,0.0073,0.02,-0.0906,0.0516,-0.3986,-1.9011,2.0108,-0.6635],[2.515,-0.0064,0.0082,0.02,-0.0895,0.0524,-0.4202,-1.9011,2.0108,-0.7089],[2.545,-0.0063,0.0093,0.0196,-0.0961,0.0519,-0.4455,-1.9011,2.0108,-0.7535],[2.576,-0.0064,0.0102,0.0192,-0.1024,0.0564,-0.4697,-1.9011,2.0108,-0.7977],[2.606,-0.0063,0.011,0.0189,-0.1072,0.0584,-0.4965,-1.9011,2.0108,-0.8385],[2.636,-0.0059,0.0119,0.0182,-0.1141,0.0569,-0.5247,-1.9011,2.0108,-0.8754],[2.667,-0.0057,0.013,0.0175,-0.1176,0.0503,-0.5459,-1.9011,2.0108,-0.9099],[2.697,-0.0057,0.0135,0.017,-0.1271,0.0475,-0.5759,-1.9011,2.0108,-0.9439],[2.727,-0.0055,0.0134,0.0167,-0.1388,0.0439,-0.6114,-1.9011,2.0108,-0.9769],[2.758,-0.0056,0.0139,0.0166,-0.1463,0.038,-0.6321,-1.9011,2.0108,-1.0078],[2.788,-0.0052,0.0145,0.0158,-0.1516,0.0306,-0.6504,-1.9011,2.0108,-1.022],[2.818,-0.0051,0.0147,0.0153,-0.1633,0.0199,-0.6704,-1.9011,2.0108,-1.022],[2.848,-0.0054,0.0153,0.0151,-0.1727,0.0116,-0.6893,-1.9011,2.0108,-1.022],[2.879,-0.0055,0.0156,0.0147,-0.1813,0.0077,-0.706,-1.9011,2.0108,-1.022],[2.909,-0.0055,0.0159,0.0143,-0.1934,-0.0034,-0.7283,-1.9011,2.0108,-1.022],[2.939,-0.0056,0.0163,0.0142,-0.1991,-0.0127,-0.7375,-1.9011,2.0108,-1.022],[2.97,-0.0058,0.0169,0.0139,-0.2023,-0.0179,-0.7493,-1.9011,2.0108,-1.022],[3.0,-0.006,0.0171,0.0139,-0.2064,-0.029,-0.7666,-1.9011,2.0108,-1.022],[3.03,-0.0064,0.0172,0.0141,-0.2092,-0.0358,-0.7771,-1.9011,2.0108,-1.022],[3.061,-0.0065,0.0175,0.0139,-0.214,-0.0412,-0.7854,-1.9011,2.0108,-1.022],[3.091,-0.0064,0.0178,0.0135,-0.2158,-0.0457,-0.7854,-1.9011,2.0108,-1.022],[3.121,-0.0066,0.0181,0.0135,-0.2153,-0.0483,-0.7854,-1.9011,2.0108,-1.022],[3.152,-0.0068,0.0184,0.0133,-0.2156,-0.0498,-0.7854,-1.9011,2.0108,-1.022],[3.182,-0.007,0.0186,0.0131,-0.2165,-0.0492,-0.7854,-1.9011,2.0108,-1.022],[3.212,-0.007,0.0183,0.0133,-0.2164,-0.0478,-0.7854,-1.9011,2.0108,-1.022],[3.242,-0.0069,0.018,0.0135,-0.2143,-0.0434,-0.7854,-1.9011,2.0108,-1.022],[3.273,-0.0069,0.0179,0.0134,-0.2152,-0.0412,-0.7854,-1.9011,2.0108,-1.022],[3.303,-0.007,0.0177,0.0136,-0.2154,-0.0416,-0.7854,-1.9011,2.0108,-1.022],[3.333,-0.0072,0.0179,0.0138,-0.2139,-0.0416,-0.7854,-1.9011,2.0108,-1.022],[3.364,-0.0072,0.0177,0.0139,-0.2124,-0.04,-0.7854,-1.9011,2.0108,-1.022],[3.394,-0.0073,0.0175,0.014,-0.2118,-0.0389,-0.7854,-1.9011,2.0108,-1.022],[3.424,-0.0074,0.0173,0.0142,-0.2107,-0.0371,-0.7854,-1.9011,2.0108,-1.022],[3.455,-0.0075,0.0174,0.0142,-0.2104,-0.0361,-0.7854,-1.9011,2.0108,-1.0082],[3.485,-0.0076,0.0175,0.0142,-0.21,-0.035,-0.7854,-1.9011,2.0108,-0.9751],[3.515,-0.0076,0.0175,0.0142,-0.2088,-0.0332,-0.7854,-1.9011,2.0108,-0.9327],[3.545,-0.0076,0.0175,0.0144,-0.2075,-0.0311,-0.7854,-1.9011,2.0108,-0.8836],[3.576,-0.0076,0.0173,0.0145,-0.2072,-0.0309,-0.7854,-1.9011,2.0108,-0.8301],[3.606,-0.0075,0.0174,0.0145,-0.204,-0.0289,-0.7777,-1.9011,2.0108,-0.7726],[3.636,-0.0075,0.0173,0.0147,-0.1996,-0.0218,-0.7612,-1.9011,2.0108,-0.7158],[3.667,-0.0076,0.0171,0.0151,-0.1991,-0.0195,-0.7386,-1.9011,2.0108,-0.6599],[3.697,-0.0074,0.0169,0.016,-0.1932,-0.0186,-0.6844,-1.9011,2.0108,-0.6071],[3.727,-0.0072,0.0161,0.0165,-0.1868,-0.0073,-0.6184,-1.9011,2.0108,-0.5557],[3.758,-0.0068,0.0152,0.0174,-0.1797,-0.0057,-0.5539,-1.9011,2.0108,-0.5061],[3.788,-0.0067,0.0136,0.0185,-0.1697,0.0067,-0.4751,-1.9011,2.0108,-0.4576],[3.818,-0.0064,0.0119,0.0192,-0.1551,0.0166,-0.3985,-1.9011,2.0108,-0.4093],[3.848,-0.006,0.0106,0.0198,-0.1417,0.0156,-0.3352,-1.9011,2.0108,-0.361],[3.879,-0.0056,0.0095,0.0199,-0.1221,0.0174,-0.2686,-1.9011,2.0108,-0.3125],[3.909,-0.0053,0.008,0.02,-0.1042,0.0234,-0.2104,-1.9011,2.0108,-0.2637],[3.939,-0.0055,0.0067,0.02,-0.0907,0.0126,-0.1606,-1.9011,2.0108,-0.2142],[3.97,-0.0054,0.0055,0.02,-0.0683,0.0161,-0.1091,-1.9011,2.0108,-0.1641],[4.0,-0.0055,0.0046,0.02,-0.0502,0.0192,-0.0677,-1.9011,2.0108,-0.1139],[4.03,-0.0058,0.0038,0.02,-0.0368,0.0135,-0.028,-1.9011,2.0108,-0.0638],[4.061,-0.0062,0.0032,0.02,-0.0112,0.0107,0.0204,-1.9011,2.0108,-0.014],[4.091,-0.0061,0.0009,0.02,0.0102,0.004,0.0619,-1.9011,2.0108,0.0359],[4.121,-0.0059,-0.0006,0.02,0.0285,-0.0032,0.0964,-1.9011,2.0108,0.0856],[4.152,-0.0061,-0.0014,0.02,0.0484,-0.0055,0.1304,-1.9011,2.0108,0.1354],[4.182,-0.0073,0.0003,0.02,0.0693,-0.0061,0.166,-1.9011,2.0108,0.1842],[4.212,-0.0079,0.0018,0.02,0.092,-0.0048,0.1984,-1.9011,2.0108,0.2332],[4.242,-0.0084,0.0025,0.02,0.1146,-0.007,0.2285,-1.9011,2.0108,0.2812],[4.273,-0.0087,0.0029,0.02,0.1392,-0.0103,0.2632,-1.9011,2.0108,0.3292],[4.303,-0.0095,0.0036,0.02,0.1679,-0.0149,0.3044,-1.9011,2.0108,0.3773],[4.333,-0.01,0.0036,0.02,0.1934,-0.0243,0.3427,-1.9011,2.0108,0.4254],[4.364,-0.0103,0.0036,0.02,0.216,-0.029,0.38,-1.9011,2.0108,0.4737],[4.394,-0.0109,0.0041,0.02,0.2452,-0.0396,0.4199,-1.9011,2.0108,0.5218],[4.424,-0.0116,0.0043,0.02,0.2702,-0.0531,0.4575,-1.9011,2.0108,0.5695],[4.455,-0.0127,0.0046,0.02,0.2893,-0.0594,0.4954,-1.9011,2.0108,0.6173],[4.485,-0.0136,0.0054,0.02,0.3054,-0.0652,0.5241,-1.9011,2.0108,0.6633],[4.515,-0.0137,0.0048,0.02,0.3251,-0.0742,0.5503,-1.9011,2.0108,0.702],[4.545,-0.014,0.0049,0.02,0.3449,-0.0822,0.5752,-1.9011,2.0108,0.7305],[4.576,-0.0143,0.0055,0.02,0.3532,-0.081,0.584,-1.9011,2.0108,0.7332],[4.606,-0.0143,0.0052,0.02,0.3557,-0.0762,0.5885,-1.9011,2.0108,0.7332],[4.636,-0.0152,0.0056,0.02,0.3602,-0.0606,0.5889,-1.9011,2.0108,0.7332],[4.667,-0.0151,0.0053,0.02,0.3635,-0.0431,0.5897,-1.9011,2.0108,0.7332],[4.697,-0.0145,0.0057,0.02,0.3587,-0.0356,0.5799,-1.9011,2.0108,0.7332],[4.727,-0.0142,0.0059,0.02,0.3535,-0.0232,0.5722,-1.9011,2.0108,0.7332],[4.758,-0.014,0.0058,0.02,0.3601,-0.0249,0.5762,-1.9011,2.0108,0.7332],[4.788,-0.0137,0.0059,0.02,0.3641,-0.0291,0.5784,-1.9011,2.0108,0.7332],[4.818,-0.0133,0.0055,0.02,0.3615,-0.0279,0.5763,-1.9011,2.0108,0.7332],[4.848,-0.0133,0.0054,0.02,0.3605,-0.025,0.5732,-1.9011,2.0108,0.7332],[4.879,-0.0132,0.0058,0.02,0.3596,-0.0238,0.5724,-1.9011,2.0108,0.7332],[4.909,-0.013,0.0061,0.02,0.3587,-0.0222,0.5711,-1.9011,2.0108,0.7332],[4.939,-0.0127,0.0064,0.02,0.3531,-0.0165,0.5646,-1.9011,2.0108,0.7332],[4.97,-0.0125,0.0069,0.02,0.3442,-0.0112,0.5582,-1.9011,2.0108,0.7332],[5.0,-0.0125,0.007,0.02,0.3409,-0.0095,0.5562,-1.9011,2.0108,0.7332],[5.03,-0.0125,0.0077,0.02,0.3435,-0.0141,0.559,-1.9011,2.0108,0.7332],[5.061,-0.0123,0.0077,0.02,0.3433,-0.0182,0.5599,-1.9011,2.0108,0.7332],[5.091,-0.0123,0.0077,0.02,0.3408,-0.0176,0.5567,-1.9011,2.0108,0.7332],[5.121,-0.0124,0.0077,0.02,0.3371,-0.0174,0.5527,-1.9011,2.0108,0.7332],[5.152,-0.0124,0.0077,0.02,0.3321,-0.0149,0.5469,-1.9011,2.0108,0.7296],[5.182,-0.0121,0.0076,0.02,0.33,-0.015,0.5414,-1.9011,2.0108,0.7145],[5.212,-0.0118,0.0075,0.02,0.3228,-0.013,0.5274,-1.9011,2.0108,0.6952],[5.242,-0.0118,0.0071,0.02,0.3124,-0.0064,0.5117,-1.9011,2.0108,0.6694],[5.273,-0.0115,0.0072,0.02,0.3085,-0.0069,0.5016,-1.9011,2.0108,0.6375],[5.303,-0.0114,0.0071,0.02,0.3033,-0.0073,0.4954,-1.9011,2.0108,0.6021],[5.333,-0.0112,0.0068,0.02,0.3024,-0.007,0.4939,-1.9011,2.0108,0.5629],[5.364,-0.0114,0.0064,0.02,0.3027,-0.0103,0.4948,-1.9011,2.0108,0.5185],[5.394,-0.0114,0.0058,0.02,0.2994,-0.0137,0.4923,-1.9011,2.0108,0.4717],[5.424,-0.0115,0.0065,0.02,0.2942,-0.0152,0.4837,-1.9011,2.0108,0.4253],[5.455,-0.0111,0.0063,0.02,0.2873,-0.0153,0.4545,-1.9011,2.0108,0.3804],[5.485,-0.0106,0.0069,0.02,0.2716,-0.0036,0.4082,-1.9011,2.0108,0.3364],[5.515,-0.01,0.0068,0.02,0.2554,0.0152,0.36,-1.9011,2.0108,0.2942],[5.545,-0.0092,0.0074,0.02,0.2406,0.026,0.3007,-1.9011,2.0108,0.2533],[5.576,-0.0084,0.0066,0.02,0.2162,0.0264,0.254,-1.9011,2.0108,0.2126],[5.606,-0.0076,0.0058,0.02,0.205,0.0366,0.2181,-1.9011,2.0108,0.1724],[5.636,-0.0072,0.0054,0.02,0.1928,0.0516,0.1734,-1.9011,2.0108,0.1326],[5.667,-0.0068,0.0047,0.02,0.174,0.0537,0.1337,-1.9011,2.0108,0.0929],[5.697,-0.0062,0.0041,0.02,0.1607,0.0573,0.1006,-1.9011,2.0108,0.053],[5.727,-0.006,0.0046,0.02,0.1473,0.0666,0.0648,-1.9011,2.0108,0.0141],[5.758,-0.0056,0.0046,0.02,0.1268,0.0706,0.0236,-1.9011,2.0108,-0.0171],[5.788,-0.0057,0.0052,0.02,0.1016,0.0696,-0.0073,-1.9011,2.0108,-0.0279],[5.818,-0.0055,0.0054,0.02,0.0917,0.0721,-0.0284,-1.9011,2.0108,-0.0279],[5.848,-0.0052,0.006,0.02,0.0776,0.078,-0.062,-1.9011,2.0108,-0.0279],[5.879,-0.0051,0.0058,0.02,0.0549,0.0712,-0.0908,-1.9011,2.0108,-0.0279],[5.909,-0.0052,0.0059,0.02,0.0464,0.0742,-0.1077,-1.9011,2.0108,-0.0279],[5.939,-0.0052,0.0061,0.02,0.0336,0.0742,-0.1299,-1.9011,2.0108,-0.0279],[5.97,-0.0054,0.0065,0.02,0.0189,0.0676,-0.1502,-1.9011,2.0108,-0.0279]]},"enthusiastic1":{"kind":"emotion","duration":2.727,"frames":[[0.0,-0.0091,-0.0071,0.0092,0.0803,-0.0347,0.0667,-0.3695,0.5743,0.1619],[0.03,-0.0085,-0.0067,0.0091,0.0801,-0.035,0.0661,-0.3695,0.5743,0.1619],[0.061,-0.0078,-0.0065,0.0091,0.0801,-0.0346,0.066,-0.3695,0.5743,0.1619],[0.091,-0.0073,-0.0062,0.0087,0.0807,-0.0344,0.0652,-0.3695,0.5743,0.1619],[0.121,-0.007,-0.0062,0.0085,0.081,-0.0352,0.0652,-0.3695,0.5743,0.1619],[0.152,-0.0066,-0.006,0.0083,0.0814,-0.0352,0.0652,-0.3695,0.5743,0.1619],[0.182,-0.0064,-0.0056,0.0086,0.0816,-0.0353,0.0645,-0.3695,0.5743,0.1619],[0.212,-0.0063,-0.0057,0.0085,0.0819,-0.0352,0.064,-0.3695,0.5743,0.1619],[0.242,-0.0062,-0.0057,0.0082,0.082,-0.0356,0.0638,-0.3695,0.5743,0.1619],[0.273,-0.0061,-0.0056,0.0081,0.0821,-0.036,0.0633,-0.3695,0.5743,0.1619],[0.303,-0.006,-0.0056,0.008,0.082,-0.0355,0.0629,-0.3695,0.5743,0.1619],[0.333,-0.0057,-0.0053,0.0079,0.0817,-0.0354,0.0624,-0.3695,0.5743,0.1619],[0.364,-0.0057,-0.0054,0.0079,0.0819,-0.0357,0.0621,-0.3695,0.5743,0.1619],[0.394,-0.0057,-0.0053,0.008,0.082,-0.036,0.0615,-0.3695,0.5743,0.1619],[0.424,-0.0065,-0.006,0.0082,0.0823,-0.0362,0.0628,-0.3292,0.5011,0.1619],[0.455,-0.0121,-0.0093,0.0099,0.0842,-0.0359,0.0699,-0.2406,0.4246,0.1619],[0.485,-0.0118,-0.009,0.0099,0.084,-0.0356,0.0695,-0.1968,0.4008,0.1619],[0.515,-0.0109,-0.0084,0.0099,0.0838,-0.0352,0.0689,-0.2153,0.4393,0.1619],[0.545,-0.0101,-0.0081,0.0098,0.0838,-0.0353,0.0687,-0.2886,0.5258,0.1619],[0.576,-0.0098,-0.0079,0.0095,0.0833,-0.0359,0.0687,-0.391,0.6296,0.1619],[0.606,-0.0097,-0.0072,0.0101,0.0768,-0.0444,0.0696,-0.4853,0.7136,0.1619],[0.636,-0.0096,-0.0061,0.0119,0.0678,-0.0664,0.0713,-0.5385,0.748,0.1619],[0.667,-0.009,-0.0048,0.0142,0.0598,-0.0925,0.0703,-0.5316,0.7205,0.1619],[0.697,-0.0085,-0.0036,0.017,0.0285,-0.1388,0.0765,-0.4669,0.6409,0.1619],[0.727,-0.0076,-0.0028,0.0195,-0.0077,-0.1767,0.0807,-0.3675,0.5376,0.1619],[0.758,-0.007,-0.0028,0.02,-0.0163,-0.1892,0.0786,-0.2688,0.4474,0.1619],[0.788,-0.0063,-0.0023,0.02,0.0,-0.1795,0.07,-0.2061,0.4024,0.1619],[0.818,-0.0058,-0.0033,0.02,0.0108,-0.1689,0.0628,-0.2015,0.4186,0.1619],[0.848,-0.0054,-0.0049,0.0173,0.0225,-0.1461,0.057,-0.2568,0.4903,0.1619],[0.879,-0.0063,-0.0069,0.0114,0.0295,-0.0792,0.0479,-0.3522,0.5918,0.1619],[0.909,-0.0075,-0.0081,0.0056,0.057,-0.0246,0.0469,-0.4537,0.6871,0.1619],[0.939,-0.0081,-0.0085,0.0019,0.0817,0.0055,0.0597,-0.5253,0.7422,0.1619],[0.97,-0.0083,-0.0089,-0.0006,0.0953,0.0266,0.07,-0.5413,0.7375,0.1619],[1.0,-0.0085,-0.0088,-0.0009,0.095,0.0336,0.069,-0.4962,0.6747,0.1619],[1.03,-0.0088,-0.0089,0.0008,0.0822,0.0231,0.0655,-0.406,0.5761,0.1619],[1.061,-0.0091,-0.0084,0.0048,0.0638,0.0011,0.06,-0.303,0.4768,0.1619],[1.091,-0.0084,-0.0078,0.0094,0.037,-0.0694,0.064,-0.2233,0.4123,0.1619],[1.121,-0.0076,-0.0075,0.0125,0.0186,-0.1199,0.0703,-0.1959,0.4055,0.1619],[1.152,-0.0079,-0.0071,0.015,0.0178,-0.1462,0.0737,-0.2305,0.4588,0.1619],[1.182,-0.0077,-0.0069,0.0156,0.0278,-0.1542,0.0746,-0.3145,0.5533,0.1619],[1.212,-0.007,-0.0071,0.0143,0.0397,-0.1496,0.0759,-0.4178,0.6551,0.1619],[1.242,-0.0073,-0.0082,0.011,0.039,-0.1282,0.0825,-0.5043,0.7283,0.1619],[1.273,-0.0078,-0.0092,0.0066,0.0497,-0.0844,0.0786,-0.5426,0.7465,0.1619],[1.303,-0.0079,-0.01,0.0035,0.0617,-0.0678,0.0798,-0.5192,0.7034,0.1619],[1.333,-0.0083,-0.0101,0.0017,0.0665,-0.0633,0.082,-0.4423,0.6143,0.1619],[1.364,-0.0089,-0.01,0.0012,0.0698,-0.0601,0.0802,-0.3395,0.5109,0.1619],[1.394,-0.0092,-0.0098,0.0025,0.0646,-0.0639,0.0809,-0.2477,0.4301,0.1619],[1.424,-0.0094,-0.0089,0.006,0.0447,-0.0866,0.0826,-0.1988,0.4006,0.1619],[1.455,-0.0093,-0.0085,0.0091,0.0301,-0.1163,0.0831,-0.2109,0.433,0.1619],[1.485,-0.0078,-0.0078,0.0116,0.0246,-0.1395,0.081,-0.2795,0.5158,0.1619],[1.515,-0.0078,-0.0074,0.0138,0.0253,-0.145,0.0784,-0.3799,0.6193,0.1619],[1.545,-0.0075,-0.0072,0.0141,0.0311,-0.1395,0.0801,-0.477,0.7068,0.1619],[1.576,-0.0071,-0.0076,0.0128,0.051,-0.1259,0.0818,-0.5355,0.7472,0.1619],[1.606,-0.0077,-0.0084,0.0095,0.0652,-0.0948,0.0879,-0.535,0.7259,0.1619],[1.636,-0.0088,-0.009,0.0048,0.0969,-0.0436,0.093,-0.4754,0.6506,0.1619],[1.667,-0.0095,-0.0092,0.0006,0.1354,-0.0358,0.0843,-0.3781,0.5482,0.1619],[1.697,-0.0108,-0.0096,-0.0018,0.1424,-0.0238,0.0753,-0.2778,0.455,0.1619],[1.727,-0.0118,-0.0101,-0.0034,0.1411,-0.0068,0.0782,-0.21,0.4042,0.1619],[1.758,-0.0121,-0.0101,-0.0032,0.1318,-0.0144,0.0812,-0.199,0.4141,0.1619],[1.788,-0.0127,-0.01,-0.0011,0.1148,-0.0338,0.0816,-0.2488,0.4811,0.1619],[1.818,-0.0123,-0.0098,0.0014,0.0953,-0.0552,0.0872,-0.3418,0.5812,0.1619],[1.848,-0.0116,-0.0095,0.0045,0.0692,-0.0695,0.0926,-0.4442,0.6789,0.1619],[1.879,-0.0106,-0.009,0.008,0.0431,-0.0948,0.0929,-0.5204,0.7394,0.1619],[1.909,-0.0096,-0.0088,0.0096,0.0289,-0.1146,0.0997,-0.5427,0.741,0.1619],[1.939,-0.0094,-0.0084,0.011,0.0224,-0.1066,0.0974,-0.5033,0.6832,0.1619],[1.97,-0.009,-0.0077,0.0121,0.0254,-0.1009,0.0928,-0.4163,0.5867,0.1619],[2.0,-0.0091,-0.0076,0.0126,0.0315,-0.0921,0.0875,-0.3126,0.4857,0.1619],[2.03,-0.0093,-0.0072,0.0132,0.0323,-0.0843,0.0833,-0.2291,0.4162,0.1619],[2.061,-0.0094,-0.0069,0.0136,0.0335,-0.0814,0.0839,-0.1956,0.403,0.1619],[2.091,-0.0099,-0.0069,0.0137,0.0364,-0.0733,0.0849,-0.2239,0.4508,0.1619],[2.121,-0.0102,-0.0069,0.0133,0.0388,-0.0585,0.0835,-0.3043,0.5426,0.1619],[2.152,-0.0099,-0.0067,0.0129,0.041,-0.0439,0.0821,-0.408,0.6457,0.1619],[2.182,-0.0095,-0.0062,0.0127,0.0438,-0.0348,0.0824,-0.4977,0.7235,0.1619],[2.212,-0.0092,-0.0061,0.0123,0.0461,-0.0272,0.0827,-0.5419,0.748,0.1619],[2.242,-0.0091,-0.0061,0.012,0.0475,-0.0193,0.08,-0.5248,0.7108,0.1619],[2.273,-0.0088,-0.0059,0.0119,0.0522,-0.0135,0.0788,-0.4521,0.6248,0.1619],[2.303,-0.0082,-0.0059,0.0116,0.0561,-0.011,0.0765,-0.3501,0.5208,0.1619],[2.333,-0.008,-0.0056,0.0116,0.0581,-0.0088,0.0725,-0.2549,0.4358,0.1619],[2.364,-0.0134,-0.0094,0.0131,0.0632,-0.0062,0.0773,-0.2006,0.4002,0.1619],[2.394,-0.0135,-0.0093,0.0132,0.0686,-0.0047,0.075,-0.206,0.4264,0.1619],[2.424,-0.0134,-0.0091,0.0134,0.0707,-0.0041,0.0737,-0.223,0.4278,0.1619],[2.455,-0.0129,-0.0091,0.0131,0.074,-0.0035,0.0708,-0.223,0.4278,0.1619],[2.485,-0.0121,-0.0088,0.0131,0.0746,-0.0036,0.0688,-0.223,0.4278,0.1619],[2.515,-0.0117,-0.0087,0.013,0.0762,-0.0046,0.0676,-0.223,0.4278,0.1619],[2.545,-0.0108,-0.0083,0.0125,0.0766,-0.0052,0.0648,-0.223,0.4278,0.1619],[2.576,-0.0104,-0.0081,0.0122,0.0765,-0.0052,0.0614,-0.223,0.4278,0.1619],[2.606,-0.0096,-0.0077,0.012,0.0777,-0.0065,0.0598,-0.223,0.4278,0.1619],[2.636,-0.0089,-0.0075,0.012,0.0783,-0.008,0.0569,-0.223,0.4278,0.1619],[2.667,-0.0081,-0.0071,0.0115,0.077,-0.0091,0.0533,-0.223,0.4278,0.1619],[2.697,-0.0075,-0.0068,0.0113,0.0771,-0.009,0.0498,-0.223,0.4278,0.1619]]},"proud1":{"kind":"emotion","duration":3.773,"frames":[[0.0,-0.0048,-0.0112,0.0021,-0.0501,-0.0222,0.3264,0.0,0.0,0.3141],[0.03,-0.0047,-0.0112,0.002,-0.0516,-0.0214,0.3264,0.0,0.0,0.3141],[0.061,-0.0048,-0.0111,0.0019,-0.0518,-0.0212,0.3261,0.0,0.0,0.3141],[0.091,-0.0048,-0.0114,0.0021,-0.0506,-0.0216,0.3266,0.0,0.0,0.3141],[0.121,-0.0048,-0.0115,0.0021,-0.0474,-0.0226,0.327,0.0,0.0,0.3141],[0.152,-0.0049,-0.0113,0.002,-0.0438,-0.0236,0.3267,0.0,0.0,0.3141],[0.182,-0.0048,-0.0112,0.0019,-0.0407,-0.024,0.3258,0.0,0.0,0.3141],[0.212,-0.0048,-0.0116,0.0021,-0.0387,-0.0242,0.3252,0.0,0.0,0.3141],[0.242,-0.0048,-0.0115,0.0018,-0.0371,-0.0249,0.3247,0.0,0.0,0.3141],[0.273,-0.0048,-0.0113,0.0018,-0.0359,-0.0256,0.324,0.0,0.0,0.3141],[0.303,-0.0047,-0.0114,0.0019,-0.0351,-0.0257,0.3235,0.0,0.0,0.3141],[0.333,-0.0048,-0.0113,0.0019,-0.0353,-0.026,0.3232,0.0,0.0,0.3141],[0.364,-0.0049,-0.0115,0.0021,-0.0363,-0.0257,0.3223,0.0,0.0,0.3141],[0.394,-0.0049,-0.012,0.0021,-0.0382,-0.0253,0.321,0.0,0.0,0.3141],[0.424,-0.005,-0.0122,0.0022,-0.0418,-0.0251,0.3197,0.0,0.0,0.3141],[0.455,-0.0049,-0.0118,0.0019,-0.047,-0.0243,0.3173,0.0,0.0,0.3141],[0.485,-0.005,-0.0117,0.0019,-0.0534,-0.0231,0.3156,0.0,0.0,0.3141],[0.515,-0.005,-0.0114,0.0018,-0.0578,-0.022,0.3142,0.0,0.0,0.3141],[0.545,-0.0049,-0.011,0.0018,-0.0619,-0.0209,0.3123,0.0,0.0,0.3141],[0.576,-0.0049,-0.0111,0.0018,-0.0655,-0.0201,0.3117,0.0,0.0,0.3141],[0.606,-0.0049,-0.0111,0.0017,-0.0679,-0.0195,0.3108,0.0,0.0,0.3141],[0.636,-0.0049,-0.011,0.0016,-0.0694,-0.0193,0.3097,0.0,0.0,0.3141],[0.667,-0.0049,-0.0109,0.0017,-0.0706,-0.019,0.3087,0.0,0.0,0.3141],[0.697,-0.0049,-0.0112,0.0018,-0.0723,-0.0189,0.3075,0.0,0.0,0.3141],[0.727,-0.0049,-0.011,0.0017,-0.0742,-0.0183,0.3061,0.0,0.0,0.3141],[0.758,-0.005,-0.0109,0.0017,-0.0764,-0.0174,0.3042,0.0,0.0,0.3141],[0.788,-0.005,-0.0112,0.0019,-0.0778,-0.0167,0.3029,0.0,0.0,0.3141],[0.818,-0.0049,-0.0109,0.0019,-0.0787,-0.0162,0.3023,0.0,0.0,0.3141],[0.848,-0.005,-0.0112,0.0019,-0.0803,-0.0157,0.3006,0.0,0.0,0.3141],[0.879,-0.005,-0.011,0.0018,-0.0828,-0.0152,0.2985,0.0,0.0,0.3141],[0.909,-0.005,-0.0108,0.0018,-0.0843,-0.0148,0.2971,0.0,0.0,0.3141],[0.939,-0.005,-0.0109,0.0019,-0.0866,-0.0145,0.2954,0.0,0.0,0.3141],[0.97,-0.005,-0.0112,0.002,-0.0889,-0.0135,0.2934,0.0,0.0,0.3141],[1.0,-0.005,-0.0112,0.0021,-0.091,-0.0123,0.2911,0.0,0.0,0.3141],[1.03,-0.005,-0.0108,0.002,-0.0916,-0.0119,0.29,0.0,0.0,0.3141],[1.061,-0.005,-0.0109,0.002,-0.0916,-0.011,0.2886,0.0,0.0,0.3141],[1.091,-0.0049,-0.011,0.002,-0.0922,-0.0103,0.2865,0.0,0.0,0.3141],[1.121,-0.005,-0.0105,0.0019,-0.0932,-0.0098,0.2851,-0.0102,-0.0458,0.3141],[1.152,-0.005,-0.0108,0.0021,-0.0934,-0.0091,0.2843,-0.0824,-0.1729,0.3141],[1.182,-0.0049,-0.0106,0.002,-0.0938,-0.0086,0.2829,-0.2087,-0.3047,0.3141],[1.212,-0.0049,-0.0109,0.002,-0.0935,-0.0081,0.2818,-0.3404,-0.4364,0.3141],[1.242,-0.0047,-0.0109,0.0019,-0.0935,-0.0076,0.2812,-0.4715,-0.5675,0.3141],[1.273,-0.0049,-0.0111,0.0021,-0.0936,-0.008,0.2805,-0.6035,-0.6991,0.3141],[1.303,-0.005,-0.011,0.0023,-0.0923,-0.0083,0.28,-0.7058,-0.7493,0.3141],[1.333,-0.0049,-0.0109,0.0022,-0.0879,-0.0093,0.2801,-0.7058,-0.7493,0.3141],[1.364,-0.0047,-0.0109,0.0018,-0.0815,-0.0107,0.2799,-0.7058,-0.7493,0.3141],[1.394,-0.0047,-0.0113,0.0017,-0.0714,-0.0146,0.2796,-0.7058,-0.7493,0.3141],[1.424,-0.0046,-0.0112,0.0016,-0.0586,-0.0201,0.2795,-0.7058,-0.7493,0.3141],[1.455,-0.0045,-0.0109,0.0015,-0.0443,-0.0255,0.2795,-0.7058,-0.7073,0.3141],[1.485,-0.0044,-0.0104,0.0017,-0.0329,-0.029,0.2803,-0.6646,-0.5808,0.3141],[1.515,-0.0041,-0.0104,0.0012,-0.0194,-0.0335,0.2812,-0.5609,-0.4493,0.3141],[1.545,-0.0039,-0.0108,0.0008,-0.0033,-0.0395,0.2799,-0.4344,-0.3181,0.3141],[1.576,-0.0037,-0.0104,0.0007,0.0093,-0.0438,0.278,-0.3071,-0.1866,0.3141],[1.606,-0.0034,-0.0104,0.0006,0.0275,-0.0506,0.2769,-0.1796,-0.0551,0.3141],[1.636,-0.0032,-0.0102,0.0008,0.045,-0.0561,0.2747,-0.0522,0.0764,0.3141],[1.667,-0.0031,-0.0102,0.0007,0.0547,-0.0595,0.2724,0.0748,0.2078,0.3141],[1.697,-0.0028,-0.0101,0.0004,0.0617,-0.062,0.2702,0.1666,0.302,0.3141],[1.727,-0.0028,-0.0102,0.0004,0.0608,-0.0629,0.2676,0.1719,0.3066,0.3141],[1.758,-0.0027,-0.0106,0.0002,0.0533,-0.0631,0.2635,0.1719,0.3066,0.3141],[1.788,-0.0025,-0.011,0.0003,0.0417,-0.063,0.258,0.1719,0.3066,0.3141],[1.818,-0.0024,-0.0114,0.0007,0.0205,-0.06,0.2547,0.1719,0.3066,0.3141],[1.848,-0.0022,-0.0112,0.0009,-0.0246,-0.05,0.2544,0.1719,0.3066,0.3141],[1.879,-0.002,-0.0117,0.001,-0.069,-0.0395,0.2569,0.1533,0.2772,0.3141],[1.909,-0.0019,-0.0116,0.0006,-0.0913,-0.0333,0.2555,0.0511,0.1505,0.3141],[1.939,-0.002,-0.0114,0.0009,-0.1202,-0.0279,0.2574,-0.0804,0.0191,0.3141],[1.97,-0.002,-0.0111,0.0012,-0.1374,-0.0254,0.2556,-0.212,-0.1126,0.3141],[2.0,-0.0017,-0.011,0.0011,-0.1438,-0.0232,0.2565,-0.3435,-0.2441,0.3141],[2.03,-0.0016,-0.0111,0.0008,-0.146,-0.0224,0.2549,-0.4745,-0.3732,0.3141],[2.061,-0.0016,-0.0107,0.0008,-0.1439,-0.0225,0.2533,-0.517,-0.3828,0.3141],[2.091,-0.0017,-0.0106,0.0011,-0.1381,-0.0236,0.2525,-0.517,-0.3828,0.3141],[2.121,-0.0016,-0.0106,0.0011,-0.1283,-0.0256,0.2524,-0.517,-0.3828,0.3141],[2.152,-0.0015,-0.0105,0.0005,-0.1165,-0.0287,0.2525,-0.517,-0.3828,0.3141],[2.182,-0.0014,-0.0102,0.0004,-0.1046,-0.0317,0.2526,-0.517,-0.3828,0.3141],[2.212,-0.0014,-0.0102,0.0006,-0.0935,-0.0347,0.2524,-0.5037,-0.359,0.3141],[2.242,-0.0014,-0.0102,0.0008,-0.0859,-0.0384,0.251,-0.4281,-0.2468,0.3141],[2.273,-0.0013,-0.0104,0.0003,-0.0813,-0.042,0.2499,-0.3003,-0.1155,0.3141],[2.303,-0.0012,-0.0106,-0.0002,-0.0751,-0.0467,0.2496,-0.169,0.0158,0.3141],[2.333,-0.0011,-0.0103,-0.0002,-0.054,-0.0547,0.2465,-0.0372,0.1476,0.3141],[2.364,-0.0009,-0.01,-0.0004,-0.0369,-0.0606,0.2441,0.0937,0.2785,0.3141],[2.394,-0.0008,-0.01,-0.0004,-0.0289,-0.0658,0.2436,0.2253,0.4101,0.3141],[2.424,-0.0008,-0.0099,-0.0006,-0.0205,-0.0697,0.2428,0.3566,0.5414,0.3141],[2.455,-0.0008,-0.01,-0.0005,-0.0168,-0.0708,0.242,0.488,0.6728,0.3141],[2.485,-0.0007,-0.0099,-0.0004,-0.0146,-0.0714,0.242,0.559,0.7346,0.3141],[2.515,-0.0005,-0.0101,-0.0005,-0.0056,-0.0765,0.2425,0.559,0.7343,0.3141],[2.545,-0.0004,-0.0103,-0.0005,0.0046,-0.0818,0.242,0.559,0.7343,0.3141],[2.576,-0.0005,-0.0103,-0.0007,0.0062,-0.0838,0.2424,0.559,0.7343,0.3141],[2.606,-0.0005,-0.0106,-0.0005,0.0075,-0.0832,0.242,0.5439,0.729,0.3141],[2.636,-0.0004,-0.0103,-0.0002,0.0126,-0.0845,0.2419,0.4431,0.6611,0.3141],[2.667,-0.0003,-0.0101,-0.0004,0.0186,-0.088,0.2415,0.3117,0.5296,0.3141],[2.697,-0.0001,-0.0101,-0.0005,0.0265,-0.09,0.2416,0.1802,0.3982,0.3141],[2.727,0.0001,-0.0113,-0.0001,0.037,-0.0932,0.2421,0.0487,0.2667,0.3141],[2.758,-0.0001,-0.011,-0.0,0.0444,-0.0963,0.2413,-0.047,0.1505,0.3141],[2.788,-0.0002,-0.0108,0.0003,0.0464,-0.0974,0.2414,-0.047,0.1505,0.3141],[2.818,-0.0001,-0.0123,0.0007,0.0442,-0.0966,0.241,-0.047,0.1505,0.3141],[2.848,-0.0002,-0.0122,0.0007,0.0419,-0.0957,0.2407,-0.047,0.1505,0.3141],[2.879,-0.0002,-0.0119,0.0003,0.0393,-0.0954,0.2402,-0.047,0.1505,0.3141],[2.909,-0.0002,-0.0115,0.0002,0.032,-0.0948,0.2408,-0.047,0.1505,0.3141],[2.939,-0.0002,-0.0109,0.0006,0.0023,-0.088,0.2422,-0.047,0.1505,0.3141],[2.97,-0.0001,-0.0114,0.0006,-0.04,-0.0741,0.2451,-0.047,0.1505,0.3141],[3.0,-0.0003,-0.0133,0.0004,-0.0842,-0.0578,0.2481,-0.047,0.1505,0.3141],[3.03,-0.0007,-0.0135,0.0004,-0.1195,-0.0471,0.251,-0.047,0.1505,0.3141],[3.061,-0.0006,-0.013,0.0006,-0.1406,-0.0415,0.2521,-0.047,0.1505,0.3141],[3.091,-0.0005,-0.0127,0.0005,-0.1454,-0.0393,0.2524,-0.047,0.1505,0.3141],[3.121,-0.0005,-0.0121,0.0003,-0.1485,-0.0382,0.2524,-0.047,0.1505,0.3141],[3.152,-0.0005,-0.0119,0.0003,-0.1501,-0.0387,0.2517,-0.047,0.1505,0.3141],[3.182,-0.0007,-0.0116,0.0007,-0.1497,-0.0398,0.2522,-0.047,0.1505,0.3141],[3.212,-0.0006,-0.0115,0.0006,-0.1464,-0.0406,0.2521,-0.047,0.1505,0.3141],[3.242,-0.0006,-0.0116,0.0002,-0.1432,-0.0416,0.2515,-0.047,0.1505,0.3141],[3.273,-0.0008,-0.0115,0.0001,-0.1413,-0.0432,0.2507,-0.047,0.1505,0.3141],[3.303,-0.0008,-0.0109,0.0004,-0.1401,-0.044,0.2502,-0.047,0.1505,0.3141],[3.333,-0.0008,-0.0107,0.0004,-0.1387,-0.0436,0.2495,-0.047,0.1505,0.3141],[3.364,-0.0009,-0.0111,0.0003,-0.1394,-0.0436,0.2497,-0.047,0.1505,0.3141],[3.394,-0.0009,-0.0111,-0.0001,-0.1396,-0.043,0.2491,-0.047,0.1505,0.3141],[3.424,-0.0009,-0.0108,0.0,-0.1391,-0.0431,0.249,-0.047,0.1505,0.3141],[3.455,-0.0009,-0.0109,0.0004,-0.139,-0.0429,0.2488,-0.047,0.1505,0.3141],[3.485,-0.0008,-0.0109,0.0003,-0.1392,-0.0423,0.2488,-0.047,0.1505,0.3141],[3.515,-0.0008,-0.0107,0.0001,-0.1386,-0.0425,0.2488,-0.047,0.1505,0.3141],[3.545,-0.0008,-0.0108,0.0003,-0.138,-0.0433,0.249,-0.047,0.1505,0.3141],[3.576,-0.0009,-0.011,0.0002,-0.1346,-0.0439,0.249,-0.047,0.1505,0.3141],[3.606,-0.001,-0.0112,0.0002,-0.13,-0.0447,0.2487,-0.047,0.1505,0.3141],[3.636,-0.0009,-0.0107,-0.0001,-0.1245,-0.0463,0.2491,-0.047,0.1505,0.3141],[3.667,-0.0009,-0.0105,-0.0001,-0.1172,-0.0483,0.2497,-0.047,0.1505,0.3141],[3.697,-0.0009,-0.0105,0.0,-0.1086,-0.0506,0.2507,-0.047,0.1505,0.3141],[3.727,-0.0008,-0.0103,-0.0002,-0.0989,-0.0523,0.2515,-0.047,0.1505,0.3141],[3.758,-0.0009,-0.0103,-0.0004,-0.0923,-0.0538,0.2523,-0.047,0.1505,0.3141]]},"no1":{"kind":"emotion","duration":2.697,"frames":[[0.0,-0.0071,-0.0034,0.0055,0.0352,0.1358,0.2482,0.0042,0.21,0.3141],[0.03,-0.007,-0.0033,0.0056,0.0355,0.1358,0.248,0.0042,0.21,0.3141],[0.061,-0.007,-0.0033,0.0055,0.0357,0.1357,0.2479,0.0042,0.21,0.3141],[0.091,-0.0069,-0.0032,0.0054,0.0359,0.1362,0.2478,0.0042,0.21,0.3141],[0.121,-0.0068,-0.0034,0.0055,0.0361,0.1363,0.2478,0.0042,0.21,0.3141],[0.152,-0.0068,-0.0036,0.0056,0.0363,0.1364,0.2474,0.0042,0.21,0.3141],[0.182,-0.0067,-0.0035,0.0057,0.0365,0.1367,0.2471,0.0042,0.21,0.3141],[0.212,-0.0065,-0.0034,0.0056,0.0366,0.1369,0.2472,0.0042,0.21,0.3141],[0.242,-0.0066,-0.0035,0.0055,0.0366,0.1372,0.2471,0.0042,0.21,0.3141],[0.273,-0.0065,-0.0034,0.0056,0.0366,0.1376,0.2468,0.0042,0.21,0.3141],[0.303,-0.0065,-0.0033,0.0055,0.0366,0.1376,0.2464,0.0042,0.21,0.3141],[0.333,-0.0064,-0.0032,0.0054,0.0365,0.1377,0.2467,0.0042,0.2092,0.3141],[0.364,-0.0063,-0.0031,0.0054,0.0367,0.138,0.2466,0.0049,0.1595,0.3141],[0.394,-0.0062,-0.0031,0.0053,0.0363,0.1383,0.2467,0.0276,0.0573,0.3141],[0.424,-0.0063,-0.0029,0.0052,0.0357,0.1382,0.2467,0.0905,-0.0477,0.3141],[0.455,-0.0063,-0.0028,0.0053,0.0359,0.1387,0.2469,0.1927,-0.1534,0.3141],[0.485,-0.0062,-0.0026,0.0051,0.036,0.1387,0.2469,0.2977,-0.2584,0.3141],[0.515,-0.0061,-0.0028,0.0053,0.0357,0.1389,0.2468,0.403,-0.3636,0.3141],[0.545,-0.0061,-0.003,0.0055,0.0356,0.1389,0.2469,0.508,-0.4687,0.3141],[0.576,-0.006,-0.0033,0.0056,0.0353,0.1392,0.2467,0.6116,-0.5541,0.3141],[0.606,-0.0059,-0.0034,0.0056,0.0357,0.1391,0.2466,0.6336,-0.5496,0.3141],[0.636,-0.0059,-0.0032,0.0054,0.036,0.1395,0.2463,0.6336,-0.5496,0.3141],[0.667,-0.006,-0.0032,0.0055,0.0362,0.1395,0.2466,0.6336,-0.5496,0.3141],[0.697,-0.006,-0.0032,0.0055,0.0361,0.1394,0.2472,0.6336,-0.5496,0.3141],[0.727,-0.0059,-0.0031,0.0055,0.036,0.1398,0.2476,0.6336,-0.5496,0.3141],[0.758,-0.006,-0.0031,0.0053,0.036,0.14,0.2482,0.6336,-0.5496,0.3141],[0.788,-0.0061,-0.0031,0.0056,0.0345,0.1408,0.252,0.6336,-0.5496,0.3141],[0.818,-0.0061,-0.0034,0.0057,0.0315,0.1428,0.2596,0.6336,-0.5496,0.3141],[0.848,-0.0058,-0.0039,0.0053,0.0249,0.1468,0.277,0.6336,-0.5496,0.3141],[0.879,-0.0055,-0.0046,0.0047,0.0116,0.1641,0.3208,0.6336,-0.5496,0.3141],[0.909,-0.0057,-0.0052,0.0048,-0.0019,0.1824,0.3612,0.6336,-0.5496,0.3141],[0.939,-0.0058,-0.0061,0.0056,-0.0074,0.1939,0.3799,0.6336,-0.5496,0.3141],[0.97,-0.0053,-0.007,0.0056,-0.009,0.204,0.4001,0.6336,-0.5496,0.3141],[1.0,-0.005,-0.0086,0.0052,-0.0143,0.2068,0.4173,0.6336,-0.5496,0.3141],[1.03,-0.0049,-0.0092,0.0052,-0.0168,0.2096,0.4324,0.6336,-0.5496,0.3141],[1.061,-0.005,-0.0088,0.0058,-0.014,0.2168,0.423,0.6336,-0.5496,0.3141],[1.091,-0.0052,-0.0083,0.0063,-0.0081,0.2233,0.3985,0.6336,-0.5496,0.3141],[1.121,-0.0053,-0.0073,0.0062,0.003,0.2325,0.3493,0.6336,-0.5496,0.3141],[1.152,-0.0055,-0.006,0.0059,0.0183,0.2479,0.2856,0.6336,-0.5496,0.3141],[1.182,-0.0052,-0.0055,0.0057,0.0357,0.2485,0.2368,0.6336,-0.5496,0.3141],[1.212,-0.0051,-0.0047,0.0053,0.0425,0.2538,0.1912,0.6336,-0.5496,0.3141],[1.242,-0.0051,-0.0044,0.005,0.0501,0.2571,0.1554,0.6336,-0.5496,0.3141],[1.273,-0.0051,-0.0036,0.0041,0.0612,0.262,0.1259,0.6336,-0.5496,0.3141],[1.303,-0.0051,-0.0038,0.0035,0.0696,0.2614,0.1216,0.6336,-0.5496,0.3141],[1.333,-0.0047,-0.0043,0.0029,0.0694,0.2556,0.1468,0.6336,-0.5496,0.3141],[1.364,-0.0044,-0.0056,0.0023,0.0597,0.2448,0.207,0.6336,-0.5496,0.3141],[1.394,-0.0044,-0.0062,0.0019,0.0466,0.2319,0.2794,0.6336,-0.5496,0.3141],[1.424,-0.004,-0.0073,0.0022,0.0355,0.2185,0.3217,0.6336,-0.5496,0.3141],[1.455,-0.0033,-0.0083,0.0022,0.029,0.2154,0.354,0.6336,-0.5496,0.3141],[1.485,-0.0033,-0.0087,0.002,0.0302,0.2195,0.3625,0.6336,-0.5496,0.3141],[1.515,-0.0036,-0.0081,0.0022,0.0352,0.2314,0.3403,0.6336,-0.5496,0.3141],[1.545,-0.004,-0.0067,0.0025,0.044,0.2523,0.2817,0.6336,-0.5496,0.3141],[1.576,-0.0041,-0.0056,0.0026,0.0568,0.2602,0.2293,0.6336,-0.5496,0.3141],[1.606,-0.0041,-0.0045,0.0025,0.0652,0.2646,0.1881,0.6336,-0.5496,0.3141],[1.636,-0.004,-0.0034,0.0021,0.067,0.2645,0.154,0.6336,-0.5496,0.3141],[1.667,-0.004,-0.0027,0.0018,0.0672,0.2624,0.1486,0.6336,-0.5496,0.3141],[1.697,-0.0038,-0.0026,0.0016,0.0663,0.2583,0.1602,0.6336,-0.5496,0.3141],[1.727,-0.0036,-0.0031,0.0014,0.0623,0.2495,0.1884,0.6336,-0.5496,0.3141],[1.758,-0.0032,-0.0049,0.0011,0.0537,0.2309,0.2751,0.6336,-0.5496,0.3141],[1.788,-0.0029,-0.007,0.0009,0.0399,0.2192,0.357,0.6336,-0.5496,0.3141],[1.818,-0.0025,-0.0081,0.0012,0.0288,0.2125,0.3863,0.6336,-0.5496,0.3141],[1.848,-0.0023,-0.0089,0.0015,0.026,0.2138,0.403,0.6336,-0.5496,0.3141],[1.879,-0.0024,-0.0092,0.0019,0.0228,0.2133,0.415,0.6336,-0.5496,0.3141],[1.909,-0.0024,-0.0089,0.002,0.0235,0.2224,0.4033,0.6336,-0.5496,0.3141],[1.939,-0.0023,-0.0081,0.0022,0.0302,0.2339,0.3632,0.6336,-0.5496,0.3141],[1.97,-0.0032,-0.0063,0.0025,0.0422,0.2536,0.3033,0.6336,-0.5496,0.3141],[2.0,-0.0039,-0.0036,0.0025,0.0546,0.2695,0.2265,0.6336,-0.5496,0.3141],[2.03,-0.0035,-0.0025,0.0026,0.0693,0.2688,0.1911,0.6336,-0.5496,0.3141],[2.061,-0.0031,-0.0021,0.0027,0.0726,0.2655,0.1619,0.6336,-0.5496,0.3141],[2.091,-0.0028,-0.0032,0.0027,0.0698,0.2581,0.1691,0.6336,-0.5496,0.3141],[2.121,-0.0023,-0.0044,0.0027,0.064,0.244,0.2052,0.6336,-0.5496,0.3141],[2.152,-0.0017,-0.0057,0.0027,0.0559,0.2273,0.2604,0.6336,-0.5496,0.3141],[2.182,-0.0015,-0.0068,0.0025,0.047,0.2114,0.3198,0.6336,-0.5496,0.3141],[2.212,-0.0012,-0.0079,0.0025,0.0426,0.2023,0.3573,0.6336,-0.5496,0.3141],[2.242,-0.001,-0.0081,0.0024,0.0387,0.2033,0.3739,0.6336,-0.5496,0.3141],[2.273,-0.0017,-0.0075,0.0027,0.0441,0.2154,0.3621,0.6336,-0.5496,0.3141],[2.303,-0.0023,-0.0062,0.0029,0.0532,0.2324,0.33,0.6336,-0.5496,0.3141],[2.333,-0.0027,-0.0045,0.0028,0.0616,0.2454,0.2743,0.6336,-0.5496,0.3141],[2.364,-0.003,-0.0029,0.0026,0.0708,0.2535,0.2228,0.6336,-0.5496,0.3141],[2.394,-0.0034,-0.0024,0.0027,0.0768,0.2584,0.2104,0.6336,-0.5496,0.3141],[2.424,-0.0037,-0.0026,0.0027,0.0757,0.2619,0.2053,0.6336,-0.5496,0.3141],[2.455,-0.0036,-0.0026,0.003,0.075,0.2574,0.2085,0.6336,-0.5496,0.3141],[2.485,-0.0035,-0.0026,0.003,0.0748,0.2411,0.2311,0.6336,-0.5496,0.3141],[2.515,-0.0034,-0.0031,0.0034,0.0744,0.2267,0.2606,0.6336,-0.5496,0.3141],[2.545,-0.0036,-0.0032,0.0037,0.0725,0.2179,0.2758,0.6336,-0.5496,0.3141],[2.576,-0.0042,-0.0035,0.0046,0.0707,0.2119,0.2783,0.6336,-0.5496,0.3141],[2.606,-0.0046,-0.0041,0.0053,0.0706,0.2097,0.2754,0.6336,-0.5496,0.3141],[2.636,-0.005,-0.0043,0.0059,0.0708,0.2049,0.2717,0.6336,-0.5496,0.3141],[2.667,-0.0057,-0.0037,0.0062,0.0692,0.2001,0.2681,0.6336,-0.5496,0.3141],[2.697,-0.0059,-0.0033,0.0064,0.069,0.197,0.2665,0.6336,-0.5496,0.3141]]},"inquiring1":{"kind":"emotion","duration":2.154,"frames":[[0.0,-0.0084,-0.0005,0.0063,-0.0078,-0.0573,0.1113,-0.2171,0.2915,0.121],[0.03,-0.0086,-0.0005,0.0062,-0.0083,-0.0603,0.1113,-0.2171,0.2915,0.121],[0.061,-0.0086,-0.0005,0.0062,-0.0082,-0.0606,0.1112,-0.2171,0.2915,0.121],[0.091,-0.0087,-0.0005,0.0062,-0.0081,-0.0609,0.1113,-0.2171,0.2915,0.121],[0.121,-0.0087,-0.0003,0.0061,-0.0078,-0.0599,0.1116,-0.2171,0.2915,0.121],[0.152,-0.0085,-0.0003,0.0062,-0.0072,-0.0576,0.1113,-0.2171,0.2915,0.121],[0.182,-0.0085,-0.0003,0.0061,-0.0071,-0.0565,0.1109,-0.2171,0.2915,0.121],[0.212,-0.0084,-0.0002,0.0059,-0.007,-0.0542,0.1104,-0.2171,0.2915,0.121],[0.242,-0.0083,-0.0002,0.0058,-0.0067,-0.0522,0.1101,-0.2171,0.2915,0.121],[0.273,-0.0083,-0.0006,0.0061,-0.0064,-0.0498,0.1091,-0.2171,0.2915,0.121],[0.303,-0.0084,-0.0003,0.006,-0.0066,-0.0486,0.1083,-0.2171,0.2915,0.121],[0.333,-0.0087,-0.0001,0.006,-0.0078,-0.049,0.1067,-0.2171,0.2915,0.121],[0.364,-0.0091,-0.0,0.0061,-0.0097,-0.0491,0.104,-0.2171,0.2915,0.121],[0.394,-0.0096,0.0,0.0063,-0.0116,-0.0484,0.0991,-0.2171,0.2915,0.121],[0.424,-0.0101,0.0,0.0065,-0.0129,-0.0476,0.0958,-0.2171,0.2915,0.121],[0.455,-0.0104,0.0002,0.0066,-0.0127,-0.0452,0.0942,-0.2171,0.2915,0.121],[0.485,-0.0105,0.0005,0.0066,-0.0119,-0.0431,0.0936,-0.2171,0.2915,0.121],[0.515,-0.0107,0.0007,0.0065,-0.0112,-0.0409,0.0928,-0.2171,0.2915,0.121],[0.545,-0.0108,0.0008,0.0065,-0.0112,-0.0399,0.0913,-0.2171,0.2915,0.121],[0.576,-0.0112,0.0008,0.0067,-0.0112,-0.039,0.0906,-0.2171,0.2915,0.121],[0.606,-0.0116,0.0007,0.0067,-0.011,-0.0382,0.0903,-0.2171,0.2915,0.121],[0.636,-0.0121,0.0009,0.0067,-0.011,-0.0374,0.0896,-0.2192,0.3072,0.121],[0.667,-0.0123,0.0009,0.0068,-0.0111,-0.0402,0.0902,-0.2685,0.3839,0.121],[0.697,-0.0117,0.0006,0.0066,-0.0109,-0.0483,0.0945,-0.3822,0.5282,0.121],[0.727,-0.0103,0.0002,0.0062,-0.0106,-0.0539,0.0971,-0.539,0.6859,0.121],[0.758,-0.0083,-0.0003,0.0059,-0.0088,-0.0548,0.0972,-0.6963,0.8432,0.121],[0.788,-0.0056,-0.0007,0.0057,-0.0075,-0.0554,0.0956,-0.8538,0.9601,0.121],[0.818,-0.0021,-0.0015,0.0055,-0.0178,-0.0696,0.086,-0.9825,0.9601,0.121],[0.848,-0.0004,-0.0024,0.0058,-0.0336,-0.0942,0.0783,-0.9885,0.9601,0.121],[0.879,-0.0004,-0.0028,0.007,-0.0538,-0.1329,0.0712,-0.9885,0.9601,0.121],[0.909,-0.0018,-0.0027,0.0086,-0.0705,-0.1882,0.0712,-0.9885,0.9601,0.121],[0.939,-0.003,-0.0018,0.0087,-0.0781,-0.2191,0.0753,-0.9885,0.9601,0.121],[0.97,-0.0046,-0.0014,0.0084,-0.0823,-0.2327,0.078,-0.9885,0.9601,0.121],[1.0,-0.0061,-0.0008,0.0084,-0.0805,-0.2264,0.0802,-0.9885,0.9575,0.121],[1.03,-0.007,-0.0001,0.0079,-0.0704,-0.1888,0.0781,-0.986,0.9014,0.121],[1.061,-0.0072,0.0005,0.0071,-0.0564,-0.1302,0.0741,-0.9304,0.759,0.121],[1.091,-0.0066,0.0013,0.0064,-0.0439,-0.0904,0.0749,-0.7824,0.6099,0.121],[1.121,-0.005,0.0012,0.0055,-0.0365,-0.0629,0.073,-0.6244,0.4606,0.121],[1.152,-0.0032,0.0,0.0055,-0.0352,-0.0704,0.0726,-0.4675,0.3187,0.121],[1.182,-0.0019,-0.0008,0.006,-0.0411,-0.1,0.0722,-0.3752,0.2913,0.121],[1.212,-0.0016,-0.0011,0.0073,-0.0523,-0.144,0.071,-0.3752,0.2913,0.121],[1.242,-0.0024,-0.0015,0.0092,-0.0692,-0.23,0.0757,-0.3752,0.2913,0.121],[1.273,-0.0042,-0.0013,0.0106,-0.078,-0.3227,0.0892,-0.3752,0.2913,0.121],[1.303,-0.0046,-0.0016,0.0112,-0.0787,-0.3788,0.1016,-0.3752,0.2913,0.121],[1.333,-0.0042,-0.002,0.0112,-0.0858,-0.3927,0.1018,-0.3752,0.2913,0.121],[1.364,-0.0061,-0.0018,0.0113,-0.0911,-0.3927,0.0996,-0.3752,0.2913,0.121],[1.394,-0.0064,-0.0017,0.0112,-0.0987,-0.3927,0.0931,-0.3752,0.2913,0.121],[1.424,-0.0062,-0.001,0.0103,-0.0986,-0.3927,0.0936,-0.3752,0.2913,0.121],[1.455,-0.0056,0.0001,0.0088,-0.0936,-0.3927,0.0934,-0.3752,0.2913,0.121],[1.485,-0.005,0.0009,0.0076,-0.0888,-0.3811,0.0891,-0.3752,0.2913,0.121],[1.515,-0.0048,0.0018,0.0064,-0.0849,-0.3297,0.084,-0.3752,0.2913,0.121],[1.545,-0.0044,0.0027,0.0051,-0.0782,-0.2729,0.0808,-0.3752,0.2913,0.121],[1.576,-0.0042,0.0032,0.0049,-0.0716,-0.2313,0.0767,-0.3752,0.2913,0.121],[1.606,-0.004,0.0034,0.0048,-0.0656,-0.2036,0.0759,-0.3752,0.2913,0.121],[1.636,-0.0037,0.0034,0.0048,-0.0618,-0.1795,0.0741,-0.3752,0.2913,0.121],[1.667,-0.0037,0.003,0.0051,-0.0605,-0.1637,0.0706,-0.3752,0.2913,0.121],[1.697,-0.0039,0.0025,0.0056,-0.0592,-0.1513,0.0689,-0.3752,0.2913,0.121],[1.727,-0.004,0.0019,0.0063,-0.0575,-0.1385,0.0678,-0.3752,0.2913,0.121],[1.758,-0.0041,0.0016,0.0065,-0.0554,-0.1241,0.0658,-0.3752,0.2913,0.121],[1.788,-0.0043,0.0015,0.0065,-0.0515,-0.1107,0.0655,-0.3752,0.2913,0.121],[1.818,-0.0045,0.0014,0.0066,-0.0483,-0.1011,0.0651,-0.3752,0.2913,0.121],[1.848,-0.0047,0.0013,0.0068,-0.045,-0.0899,0.0645,-0.3752,0.2913,0.121],[1.879,-0.0049,0.0014,0.0068,-0.0417,-0.0781,0.0635,-0.3752,0.2913,0.121],[1.909,-0.005,0.0013,0.0071,-0.0378,-0.0666,0.0629,-0.3752,0.2913,0.121],[1.939,-0.0047,0.0011,0.0071,-0.0343,-0.055,0.0618,-0.3752,0.2913,0.121],[1.97,-0.0046,0.0009,0.0072,-0.0319,-0.0419,0.0597,-0.3752,0.2913,0.121],[2.0,-0.0046,0.0011,0.0073,-0.0305,-0.0316,0.0584,-0.3752,0.2913,0.121],[2.03,-0.0048,0.0011,0.0075,-0.0298,-0.0247,0.0574,-0.3752,0.2913,0.121],[2.061,-0.0052,0.0012,0.0077,-0.0292,-0.019,0.0566,-0.3752,0.2913,0.121],[2.091,-0.0055,0.0011,0.0077,-0.0283,-0.0162,0.0565,-0.3752,0.2913,0.121],[2.121,-0.006,0.0009,0.0077,-0.0282,-0.0142,0.0561,-0.3752,0.2913,0.121],[2.152,-0.0064,0.0011,0.0078,-0.0285,-0.012,0.0558,-0.3752,0.2913,0.121]]},"dizzy_spin":{"kind":"dance","duration":2.105,"frames":[[0.0,0.0,0.0,0.0,0.0,0.2618,0.0,0.0,0.0,0.0],[0.03,0.0,0.0,0.0,0.0236,0.2607,-0.0,0.0709,-0.0709,0.0],[0.061,0.0,0.0,0.0,0.0471,0.2575,0.0,0.1413,-0.1413,0.0],[0.091,0.0,0.0,0.0,0.0702,0.2522,-0.0,0.2105,-0.2105,0.0],[0.121,0.0,0.0,0.0,0.0927,0.2449,-0.0,0.278,-0.278,0.0],[0.152,0.0,0.0,0.0,0.1144,0.2355,0.0,0.3432,-0.3432,0.0],[0.182,0.0,0.0,0.0,0.1352,0.2242,0.0,0.4056,-0.4056,0.0],[0.212,0.0,0.0,0.0,0.1549,0.2111,0.0,0.4647,-0.4647,0.0],[0.242,0.0,0.0,0.0,0.1733,0.1962,0.0,0.52,-0.52,0.0],[0.273,0.0,0.0,0.0,0.1903,0.1798,0.0,0.571,-0.571,0.0],[0.303,0.0,0.0,0.0,0.2058,0.1618,-0.0,0.6174,-0.6174,0.0],[0.333,0.0,0.0,0.0,0.2196,0.1426,0.0,0.6587,-0.6587,0.0],[0.364,0.0,0.0,0.0,0.2315,0.1222,0.0,0.6946,-0.6946,0.0],[0.394,0.0,0.0,0.0,0.2416,0.1008,0.0,0.7249,-0.7249,0.0],[0.424,0.0,0.0,0.0,0.2497,0.0785,0.0,0.7492,-0.7492,0.0],[0.455,0.0,0.0,0.0,0.2558,0.0556,0.0,0.7674,-0.7674,0.0],[0.485,0.0,0.0,0.0,0.2598,0.0323,-0.0,0.7794,-0.7794,0.0],[0.515,0.0,0.0,0.0,0.2617,0.0087,-0.0,0.785,-0.785,0.0],[0.545,0.0,0.0,0.0,0.2614,-0.0149,0.0,0.7841,-0.7841,0.0],[0.576,0.0,0.0,0.0,0.259,-0.0385,0.0,0.7769,-0.7769,0.0],[0.606,0.0,0.0,0.0,0.2544,-0.0617,0.0,0.7633,-0.7633,0.0],[0.636,0.0,0.0,0.0,0.2478,-0.0844,-0.0,0.7434,-0.7434,0.0],[0.667,0.0,0.0,0.0,0.2392,-0.1065,0.0,0.7175,-0.7175,0.0],[0.697,0.0,0.0,0.0,0.2286,-0.1276,0.0,0.6857,-0.6857,0.0],[0.727,0.0,0.0,0.0,0.2161,-0.1478,0.0,0.6483,-0.6483,0.0],[0.758,0.0,0.0,0.0,0.2019,-0.1667,0.0,0.6056,-0.6056,0.0],[0.788,0.0,0.0,0.0,0.186,-0.1842,0.0,0.558,-0.558,0.0],[0.818,0.0,0.0,0.0,0.1686,-0.2003,0.0,0.5058,-0.5058,0.0],[0.848,0.0,0.0,0.0,0.1498,-0.2147,0.0,0.4495,-0.4495,0.0],[0.879,0.0,0.0,0.0,0.1298,-0.2273,0.0,0.3895,-0.3895,0.0],[0.909,0.0,0.0,0.0,0.1088,-0.2381,0.0,0.3263,-0.3263,0.0],[0.939,0.0,0.0,0.0,0.0868,-0.247,-0.0,0.2604,-0.2604,0.0],[0.97,0.0,0.0,0.0,0.0641,-0.2538,-0.0,0.1924,-0.1924,0.0],[1.0,0.0,0.0,0.0,0.041,-0.2586,-0.0,0.1229,-0.1229,0.0],[1.03,0.0,0.0,0.0,0.0174,-0.2612,0.0,0.0523,-0.0523,0.0],[1.061,0.0,0.0,0.0,-0.0062,-0.2617,0.0,-0.0187,0.0187,0.0],[1.091,0.0,0.0,0.0,-0.0298,-0.2601,0.0,-0.0895,0.0895,0.0],[1.121,0.0,0.0,0.0,-0.0532,-0.2563,0.0,-0.1596,0.1596,0.0],[1.152,0.0,0.0,0.0,-0.0761,-0.2505,-0.0,-0.2284,0.2284,0.0],[1.182,0.0,0.0,0.0,-0.0985,-0.2426,0.0,-0.2954,0.2954,0.0],[1.212,0.0,0.0,0.0,-0.12,-0.2327,0.0,-0.3599,0.3599,0.0],[1.242,0.0,0.0,0.0,-0.1405,-0.2209,0.0,-0.4215,0.4215,0.0],[1.273,0.0,0.0,0.0,-0.1599,-0.2073,0.0,-0.4796,0.4796,0.0],[1.303,0.0,0.0,0.0,-0.1779,-0.192,0.0,-0.5338,0.5338,0.0],[1.333,0.0,0.0,0.0,-0.1946,-0.1752,0.0,-0.5837,0.5837,0.0],[1.364,0.0,0.0,0.0,-0.2096,-0.1569,0.0,-0.6287,0.6287,0.0],[1.394,0.0,0.0,0.0,-0.2229,-0.1373,0.0,-0.6687,0.6687,0.0],[1.424,0.0,0.0,0.0,-0.2344,-0.1166,-0.0,-0.7032,0.7032,0.0],[1.455,0.0,0.0,0.0,-0.244,-0.095,0.0,-0.7319,0.7319,0.0],[1.485,0.0,0.0,0.0,-0.2515,-0.0726,0.0,-0.7546,0.7546,0.0],[1.515,0.0,0.0,0.0,-0.2571,-0.0495,0.0,-0.7712,0.7712,0.0],[1.545,0.0,0.0,0.0,-0.2605,-0.0261,0.0,-0.7815,0.7815,0.0],[1.576,0.0,0.0,0.0,-0.2618,-0.0025,0.0,-0.7854,0.7854,0.0],[1.606,0.0,0.0,0.0,-0.2609,0.0212,0.0,-0.7828,0.7828,0.0],[1.636,0.0,0.0,0.0,-0.258,0.0446,0.0,-0.7739,0.7739,0.0],[1.667,0.0,0.0,0.0,-0.2529,0.0678,-0.0,-0.7586,0.7586,0.0],[1.697,0.0,0.0,0.0,-0.2457,0.0903,-0.0,-0.7372,0.7372,0.0],[1.727,0.0,0.0,0.0,-0.2366,0.1121,-0.0,-0.7097,0.7097,0.0],[1.758,0.0,0.0,0.0,-0.2255,0.1331,-0.0,-0.6764,0.6764,0.0],[1.788,0.0,0.0,0.0,-0.2125,0.1529,0.0,-0.6376,0.6376,0.0],[1.818,0.0,0.0,0.0,-0.1979,0.1714,0.0,-0.5936,0.5936,0.0],[1.848,0.0,0.0,0.0,-0.1816,0.1886,0.0,-0.5447,0.5447,0.0],[1.879,0.0,0.0,0.0,-0.1638,0.2042,0.0,-0.4914,0.4914,0.0],[1.909,0.0,0.0,0.0,-0.1447,0.2182,-0.0,-0.434,0.434,0.0],[1.939,0.0,0.0,0.0,-0.1244,0.2304,0.0,-0.3731,0.3731,0.0],[1.97,0.0,0.0,0.0,-0.1031,0.2407,0.0,-0.3092,0.3092,0.0],[2.0,0.0,0.0,0.0,-0.0809,0.249,-0.0,-0.2427,0.2427,0.0],[2.03,0.0,0.0,0.0,-0.0581,0.2553,0.0,-0.1742,0.1742,0.0],[2.061,0.0,0.0,0.0,-0.0348,0.2595,-0.0,-0.1044,0.1044,0.0],[2.091,0.0,0.0,0.0,-0.0112,0.2616,0.0,-0.0336,0.0336,0.0]]},"headbanger_combo":{"kind":"dance","duration":2.105,"frames":[[0.0,0.0,0.0,0.0088,0.0,0.0,0.0,0.0,0.0,0.0],[0.03,0.0,0.0,0.0125,0.0,0.1853,0.0,0.2471,0.2471,0.0],[0.061,0.0,0.0,0.0146,0.0,0.3466,0.0,0.4622,0.4622,0.0],[0.091,0.0,0.0,0.0148,0.0,0.4631,0.0,0.6175,0.6175,0.0],[0.121,0.0,0.0,0.0131,0.0,0.5196,0.0,0.6928,0.6928,0.0],[0.152,0.0,0.0,0.0097,0.0,0.5088,0.0,0.6785,0.6785,0.0],[0.182,0.0,0.0,0.005,0.0,0.4322,0.0,0.5763,0.5763,0.0],[0.212,0.0,0.0,-0.0003,0.0,0.2996,0.0,0.3995,0.3995,0.0],[0.242,0.0,0.0,-0.0056,0.0,0.1283,0.0,0.171,0.171,0.0],[0.273,0.0,0.0,-0.0101,0.0,-0.0597,0.0,-0.0796,-0.0796,0.0],[0.303,0.0,0.0,-0.0134,0.0,-0.2399,0.0,-0.3199,-0.3199,0.0],[0.333,0.0,0.0,-0.0149,0.0,-0.3891,0.0,-0.5188,-0.5188,0.0],[0.364,0.0,0.0,-0.0145,0.0,-0.4879,0.0,-0.6506,-0.6506,0.0],[0.394,0.0,0.0,-0.0122,0.0,-0.5236,0.0,-0.6981,-0.6981,0.0],[0.424,0.0,0.0,-0.0083,0.0,-0.4915,0.0,-0.6553,-0.6553,0.0],[0.455,0.0,0.0,-0.0034,0.0,-0.3957,0.0,-0.5276,-0.5276,0.0],[0.485,0.0,0.0,0.002,0.0,-0.2487,0.0,-0.3317,-0.3317,0.0],[0.515,0.0,0.0,0.0071,0.0,-0.0696,0.0,-0.0928,-0.0928,0.0],[0.545,0.0,0.0,0.0113,0.0,0.1186,0.0,0.1581,0.1581,0.0],[0.576,0.0,0.0,0.0141,0.0,0.2914,0.0,0.3886,0.3886,0.0],[0.606,0.0,0.0,0.015,0.0,0.4265,0.0,0.5687,0.5687,0.0],[0.636,0.0,0.0,0.014,0.0,0.5064,0.0,0.6752,0.6752,0.0],[0.667,0.0,0.0,0.0111,0.0,0.5207,0.0,0.6943,0.6943,0.0],[0.697,0.0,0.0,0.0069,0.0,0.4677,0.0,0.6235,0.6235,0.0],[0.727,0.0,0.0,0.0017,0.0,0.354,0.0,0.4721,0.4721,0.0],[0.758,0.0,0.0,-0.0037,0.0,0.1946,0.0,0.2595,0.2595,0.0],[0.788,0.0,0.0,-0.0086,0.0,0.01,0.0,0.0133,0.0133,0.0],[0.818,0.0,0.0,-0.0124,0.0,-0.176,0.0,-0.2346,-0.2346,0.0],[0.848,0.0,0.0,-0.0146,0.0,-0.3391,0.0,-0.4521,-0.4521,0.0],[0.879,0.0,0.0,-0.0149,0.0,-0.4584,0.0,-0.6111,-0.6111,0.0],[0.909,0.0,0.0,-0.0133,0.0,-0.5183,0.0,-0.691,-0.691,0.0],[0.939,0.0,0.0,-0.0099,0.0,-0.5111,0.0,-0.6815,-0.6815,0.0],[0.97,0.0,0.0,-0.0053,0.0,-0.4378,0.0,-0.5837,-0.5837,0.0],[1.0,0.0,0.0,-0.0,0.0,-0.3078,0.0,-0.4104,-0.4104,0.0],[1.03,0.0,0.0,0.0053,0.0,-0.1379,0.0,-0.1839,-0.1839,0.0],[1.061,0.0,0.0,0.0099,0.0,0.0498,0.0,0.0664,0.0664,0.0],[1.091,0.0,0.0,0.0133,0.0,0.231,0.0,0.308,0.308,0.0],[1.121,0.0,0.0,0.0149,0.0,0.3824,0.0,0.5098,0.5098,0.0],[1.152,0.0,0.0,0.0146,0.0,0.4842,0.0,0.6456,0.6456,0.0],[1.182,0.0,0.0,0.0124,0.0,0.5234,0.0,0.6978,0.6978,0.0],[1.212,0.0,0.0,0.0086,0.0,0.4948,0.0,0.6597,0.6597,0.0],[1.242,0.0,0.0,0.0037,0.0,0.4022,0.0,0.5362,0.5362,0.0],[1.273,0.0,0.0,-0.0017,0.0,0.2575,0.0,0.3433,0.3433,0.0],[1.303,0.0,0.0,-0.0069,0.0,0.0794,0.0,0.1059,0.1059,0.0],[1.333,0.0,0.0,-0.0111,0.0,-0.1089,0.0,-0.1451,-0.1451,0.0],[1.364,0.0,0.0,-0.014,0.0,-0.2831,0.0,-0.3774,-0.3774,0.0],[1.394,0.0,0.0,-0.015,0.0,-0.4207,0.0,-0.5609,-0.5609,0.0],[1.424,0.0,0.0,-0.0141,0.0,-0.5038,0.0,-0.6717,-0.6717,0.0],[1.455,0.0,0.0,-0.0113,0.0,-0.5217,0.0,-0.6956,-0.6956,0.0],[1.485,0.0,0.0,-0.0071,0.0,-0.4721,0.0,-0.6294,-0.6294,0.0],[1.515,0.0,0.0,-0.002,0.0,-0.3613,0.0,-0.4818,-0.4818,0.0],[1.545,0.0,0.0,0.0034,0.0,-0.2038,0.0,-0.2718,-0.2718,0.0],[1.576,0.0,0.0,0.0083,0.0,-0.0199,0.0,-0.0266,-0.0266,0.0],[1.606,0.0,0.0,0.0122,0.0,0.1665,0.0,0.222,0.222,0.0],[1.636,0.0,0.0,0.0145,0.0,0.3314,0.0,0.4419,0.4419,0.0],[1.667,0.0,0.0,0.0149,0.0,0.4534,0.0,0.6046,0.6046,0.0],[1.697,0.0,0.0,0.0134,0.0,0.5168,0.0,0.689,0.689,0.0],[1.727,0.0,0.0,0.0101,0.0,0.5132,0.0,0.6842,0.6842,0.0],[1.758,0.0,0.0,0.0056,0.0,0.4432,0.0,0.5909,0.5909,0.0],[1.788,0.0,0.0,0.0003,0.0,0.3158,0.0,0.421,0.421,0.0],[1.818,0.0,0.0,-0.005,0.0,0.1475,0.0,0.1967,0.1967,0.0],[1.848,0.0,0.0,-0.0097,0.0,-0.0398,0.0,-0.0531,-0.0531,0.0],[1.879,0.0,0.0,-0.0131,0.0,-0.222,0.0,-0.296,-0.296,0.0],[1.909,0.0,0.0,-0.0148,0.0,-0.3755,0.0,-0.5007,-0.5007,0.0],[1.939,0.0,0.0,-0.0146,0.0,-0.4803,0.0,-0.6404,-0.6404,0.0],[1.97,0.0,0.0,-0.0125,0.0,-0.523,0.0,-0.6973,-0.6973,0.0],[2.0,0.0,0.0,-0.0088,0.0,-0.498,0.0,-0.664,-0.664,0.0],[2.03,0.0,0.0,-0.004,0.0,-0.4085,0.0,-0.5446,-0.5446,0.0],[2.061,0.0,0.0,0.0014,0.0,-0.2661,0.0,-0.3548,-0.3548,0.0],[2.091,0.0,0.0,0.0066,0.0,-0.0893,0.0,-0.119,-0.119,0.0]]},"groovy_sway_and_roll":{"kind":"dance","duration":2.105,"frames":[[0.0,0.0,0.0,0.0,0.2618,0.0,0.0,0.0,0.0,0.0],[0.03,0.0,0.0054,0.0,0.2575,0.0,0.0,0.1413,-0.1413,0.0],[0.061,0.0,0.0106,0.0,0.2449,0.0,0.0,0.278,-0.278,0.0],[0.091,0.0,0.0155,0.0,0.2242,0.0,0.0,0.4056,-0.4056,0.0],[0.121,0.0,0.0199,0.0,0.1962,0.0,0.0,0.52,-0.52,0.0],[0.152,0.0,0.0236,0.0,0.1618,0.0,0.0,0.6174,-0.6174,0.0],[0.182,0.0,0.0265,0.0,0.1222,0.0,0.0,0.6946,-0.6946,0.0],[0.212,0.0,0.0286,0.0,0.0785,0.0,0.0,0.7492,-0.7492,0.0],[0.242,0.0,0.0298,0.0,0.0323,0.0,0.0,0.7794,-0.7794,0.0],[0.273,0.0,0.03,0.0,-0.0149,0.0,0.0,0.7841,-0.7841,0.0],[0.303,0.0,0.0292,0.0,-0.0617,0.0,0.0,0.7633,-0.7633,0.0],[0.333,0.0,0.0274,0.0,-0.1065,0.0,0.0,0.7175,-0.7175,0.0],[0.364,0.0,0.0248,0.0,-0.1478,0.0,0.0,0.6483,-0.6483,0.0],[0.394,0.0,0.0213,0.0,-0.1842,0.0,0.0,0.558,-0.558,0.0],[0.424,0.0,0.0172,0.0,-0.2147,0.0,0.0,0.4495,-0.4495,0.0],[0.455,0.0,0.0125,0.0,-0.2381,0.0,0.0,0.3263,-0.3263,0.0],[0.485,0.0,0.0073,0.0,-0.2538,0.0,0.0,0.1924,-0.1924,0.0],[0.515,0.0,0.002,0.0,-0.2612,0.0,0.0,0.0523,-0.0523,0.0],[0.545,0.0,-0.0034,0.0,-0.2601,0.0,0.0,-0.0895,0.0895,0.0],[0.576,0.0,-0.0087,0.0,-0.2505,0.0,0.0,-0.2284,0.2284,0.0],[0.606,0.0,-0.0137,0.0,-0.2327,0.0,0.0,-0.3599,0.3599,0.0],[0.636,0.0,-0.0183,0.0,-0.2073,0.0,0.0,-0.4796,0.4796,0.0],[0.667,0.0,-0.0223,0.0,-0.1752,0.0,0.0,-0.5837,0.5837,0.0],[0.697,0.0,-0.0255,0.0,-0.1373,0.0,0.0,-0.6687,0.6687,0.0],[0.727,0.0,-0.028,0.0,-0.095,0.0,0.0,-0.7319,0.7319,0.0],[0.758,0.0,-0.0295,0.0,-0.0495,0.0,0.0,-0.7712,0.7712,0.0],[0.788,0.0,-0.03,0.0,-0.0025,0.0,0.0,-0.7854,0.7854,0.0],[0.818,0.0,-0.0296,0.0,0.0446,0.0,0.0,-0.7739,0.7739,0.0],[0.848,0.0,-0.0282,0.0,0.0903,0.0,0.0,-0.7372,0.7372,0.0],[0.879,0.0,-0.0258,0.0,0.1331,0.0,0.0,-0.6764,0.6764,0.0],[0.909,0.0,-0.0227,0.0,0.1714,0.0,0.0,-0.5936,0.5936,0.0],[0.939,0.0,-0.0188,0.0,0.2042,0.0,0.0,-0.4914,0.4914,0.0],[0.97,0.0,-0.0143,0.0,0.2304,0.0,0.0,-0.3731,0.3731,0.0],[1.0,0.0,-0.0093,0.0,0.249,0.0,0.0,-0.2427,0.2427,0.0],[1.03,0.0,-0.004,0.0,0.2595,0.0,0.0,-0.1044,0.1044,0.0],[1.061,0.0,0.0014,0.0,0.2615,0.0,0.0,0.0374,-0.0374,0.0],[1.091,0.0,0.0068,0.0,0.255,0.0,0.0,0.1779,-0.1779,0.0],[1.121,0.0,0.0119,0.0,0.2402,0.0,0.0,0.3126,-0.3126,0.0],[1.152,0.0,0.0167,0.0,0.2175,0.0,0.0,0.4371,-0.4371,0.0],[1.182,0.0,0.0209,0.0,0.1877,0.0,0.0,0.5474,-0.5474,0.0],[1.212,0.0,0.0244,0.0,0.1519,0.0,0.0,0.6398,-0.6398,0.0],[1.242,0.0,0.0272,0.0,0.111,0.0,0.0,0.7113,-0.7113,0.0],[1.273,0.0,0.029,0.0,0.0666,0.0,0.0,0.7596,-0.7596,0.0],[1.303,0.0,0.0299,0.0,0.0199,0.0,0.0,0.7831,-0.7831,0.0],[1.333,0.0,0.0298,0.0,-0.0274,0.0,0.0,0.7811,-0.7811,0.0],[1.364,0.0,0.0288,0.0,-0.0738,0.0,0.0,0.7536,-0.7536,0.0],[1.394,0.0,0.0268,0.0,-0.1177,0.0,0.0,0.7015,-0.7015,0.0],[1.424,0.0,0.0239,0.0,-0.1579,0.0,0.0,0.6265,-0.6265,0.0],[1.455,0.0,0.0203,0.0,-0.1929,0.0,0.0,0.5311,-0.5311,0.0],[1.485,0.0,0.016,0.0,-0.2216,0.0,0.0,0.4183,-0.4183,0.0],[1.515,0.0,0.0111,0.0,-0.243,0.0,0.0,0.2919,-0.2919,0.0],[1.545,0.0,0.006,0.0,-0.2566,0.0,0.0,0.156,-0.156,0.0],[1.576,0.0,0.0006,0.0,-0.2618,0.0,0.0,0.015,-0.015,0.0],[1.606,0.0,-0.0048,0.0,-0.2584,0.0,0.0,-0.1266,0.1266,0.0],[1.636,0.0,-0.0101,0.0,-0.2466,0.0,0.0,-0.2639,0.2639,0.0],[1.667,0.0,-0.015,0.0,-0.2267,0.0,0.0,-0.3927,0.3927,0.0],[1.697,0.0,-0.0194,0.0,-0.1995,0.0,0.0,-0.5087,0.5087,0.0],[1.727,0.0,-0.0232,0.0,-0.1657,0.0,0.0,-0.608,0.608,0.0],[1.758,0.0,-0.0263,0.0,-0.1266,0.0,0.0,-0.6875,0.6875,0.0],[1.788,0.0,-0.0284,0.0,-0.0833,0.0,0.0,-0.7446,0.7446,0.0],[1.818,0.0,-0.0297,0.0,-0.0373,0.0,0.0,-0.7774,0.7774,0.0],[1.848,0.0,-0.03,0.0,0.01,0.0,0.0,-0.7848,0.7848,0.0],[1.879,0.0,-0.0293,0.0,0.0569,0.0,0.0,-0.7666,0.7666,0.0],[1.909,0.0,-0.0276,0.0,0.1019,0.0,0.0,-0.7234,0.7234,0.0],[1.939,0.0,-0.0251,0.0,0.1436,0.0,0.0,-0.6566,0.6566,0.0],[1.97,0.0,-0.0217,0.0,0.1807,0.0,0.0,-0.5684,0.5684,0.0],[2.0,0.0,-0.0176,0.0,0.2118,0.0,0.0,-0.4616,0.4616,0.0],[2.03,0.0,-0.013,0.0,0.236,0.0,0.0,-0.3398,0.3398,0.0],[2.061,0.0,-0.0079,0.0,0.2526,0.0,0.0,-0.2069,0.2069,0.0],[2.091,0.0,-0.0026,0.0,0.2608,0.0,0.0,-0.0672,0.0672,0.0]]},"yeah_nod":{"kind":"dance","duration":2.105,"frames":[[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.03,0.0,0.0,0.0,0.0,0.0147,0.0,0.1235,0.1235,0.0],[0.061,0.0,0.0,0.0,0.0,0.0526,0.0,0.2311,0.2311,0.0],[0.091,0.0,0.0,0.0,0.0,0.1043,0.0,0.3087,0.3087,0.0],[0.121,0.0,0.0,0.0,0.0,0.1604,0.0,0.3464,0.3464,0.0],[0.152,0.0,0.0,0.0,0.0,0.2116,0.0,0.3392,0.3392,0.0],[0.182,0.0,0.0,0.0,0.0,0.2485,0.0,0.2881,0.2881,0.0],[0.212,0.0,0.0,0.0,0.0,0.0,0.0,0.1998,0.1998,0.0],[0.242,0.0,0.0,0.0,0.0,0.0,0.0,0.0855,0.0855,0.0],[0.273,0.0,0.0,0.0,0.0,0.0019,0.0,-0.0398,-0.0398,0.0],[0.303,0.0,0.0,0.0,0.0,0.0292,0.0,-0.16,-0.16,0.0],[0.333,0.0,0.0,0.0,0.0,0.0764,0.0,-0.2594,-0.2594,0.0],[0.364,0.0,0.0,0.0,0.0,0.1282,0.0,-0.3253,-0.3253,0.0],[0.394,0.0,0.0,0.0,0.0,0.1689,0.0,-0.3491,-0.3491,0.0],[0.424,0.0,0.0,0.0,0.0,0.0,0.0,-0.3276,-0.3276,0.0],[0.455,0.0,0.0,0.0,0.0,0.0,0.0,-0.2638,-0.2638,0.0],[0.485,0.0,0.0,0.0,0.0,0.0,0.0,-0.1658,-0.1658,0.0],[0.515,0.0,0.0,0.0,0.0,0.0,0.0,-0.0464,-0.0464,0.0],[0.545,0.0,0.0,0.0,0.0,0.0061,0.0,0.0791,0.0791,0.0],[0.576,0.0,0.0,0.0,0.0,0.0365,0.0,0.1943,0.1943,0.0],[0.606,0.0,0.0,0.0,0.0,0.0842,0.0,0.2843,0.2843,0.0],[0.636,0.0,0.0,0.0,0.0,0.1398,0.0,0.3376,0.3376,0.0],[0.667,0.0,0.0,0.0,0.0,0.1939,0.0,0.3472,0.3472,0.0],[0.697,0.0,0.0,0.0,0.0,0.2372,0.0,0.3118,0.3118,0.0],[0.727,0.0,0.0,0.0,0.0,0.2602,0.0,0.236,0.236,0.0],[0.758,0.0,0.0,0.0,0.0,0.0,0.0,0.1297,0.1297,0.0],[0.788,0.0,0.0,0.0,0.0,0.0,0.0,0.0066,0.0066,0.0],[0.818,0.0,0.0,0.0,0.0,0.016,0.0,-0.1173,-0.1173,0.0],[0.848,0.0,0.0,0.0,0.0,0.0577,0.0,-0.2261,-0.2261,0.0],[0.879,0.0,0.0,0.0,0.0,0.1096,0.0,-0.3056,-0.3056,0.0],[0.909,0.0,0.0,0.0,0.0,0.1562,0.0,-0.3455,-0.3455,0.0],[0.939,0.0,0.0,0.0,0.0,0.1819,0.0,-0.3407,-0.3407,0.0],[0.97,0.0,0.0,0.0,0.0,0.0,0.0,-0.2918,-0.2918,0.0],[1.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.2052,-0.2052,0.0],[1.03,0.0,0.0,0.0,0.0,0.0,0.0,-0.0919,-0.0919,0.0],[1.061,0.0,0.0,0.0,0.0,0.0011,0.0,0.0332,0.0332,0.0],[1.091,0.0,0.0,0.0,0.0,0.0228,0.0,0.154,0.154,0.0],[1.121,0.0,0.0,0.0,0.0,0.0652,0.0,0.2549,0.2549,0.0],[1.152,0.0,0.0,0.0,0.0,0.119,0.0,0.3228,0.3228,0.0],[1.182,0.0,0.0,0.0,0.0,0.1748,0.0,0.3489,0.3489,0.0],[1.212,0.0,0.0,0.0,0.0,0.2231,0.0,0.3299,0.3299,0.0],[1.242,0.0,0.0,0.0,0.0,0.2547,0.0,0.2681,0.2681,0.0],[1.273,0.0,0.0,0.0,0.0,0.0,0.0,0.1716,0.1716,0.0],[1.303,0.0,0.0,0.0,0.0,0.0,0.0,0.053,0.053,0.0],[1.333,0.0,0.0,0.0,0.0,0.0063,0.0,-0.0726,-0.0726,0.0],[1.364,0.0,0.0,0.0,0.0,0.0403,0.0,-0.1887,-0.1887,0.0],[1.394,0.0,0.0,0.0,0.0,0.0902,0.0,-0.2804,-0.2804,0.0],[1.424,0.0,0.0,0.0,0.0,0.1406,0.0,-0.3358,-0.3358,0.0],[1.455,0.0,0.0,0.0,0.0,0.1758,0.0,-0.3478,-0.3478,0.0],[1.485,0.0,0.0,0.0,0.0,0.0,0.0,-0.3147,-0.3147,0.0],[1.515,0.0,0.0,0.0,0.0,0.0,0.0,-0.2409,-0.2409,0.0],[1.545,0.0,0.0,0.0,0.0,0.0,0.0,-0.1359,-0.1359,0.0],[1.576,0.0,0.0,0.0,0.0,0.0,0.0,-0.0133,-0.0133,0.0],[1.606,0.0,0.0,0.0,0.0,0.0119,0.0,0.111,0.111,0.0],[1.636,0.0,0.0,0.0,0.0,0.0478,0.0,0.221,0.221,0.0],[1.667,0.0,0.0,0.0,0.0,0.0985,0.0,0.3023,0.3023,0.0],[1.697,0.0,0.0,0.0,0.0,0.1546,0.0,0.3445,0.3445,0.0],[1.727,0.0,0.0,0.0,0.0,0.2067,0.0,0.3421,0.3421,0.0],[1.758,0.0,0.0,0.0,0.0,0.2456,0.0,0.2954,0.2954,0.0],[1.788,0.0,0.0,0.0,0.0,0.2618,0.0,0.2105,0.2105,0.0],[1.818,0.0,0.0,0.0,0.0,0.0,0.0,0.0983,0.0983,0.0],[1.848,0.0,0.0,0.0,0.0,0.0009,0.0,-0.0266,-0.0266,0.0],[1.879,0.0,0.0,0.0,0.0,0.0251,0.0,-0.148,-0.148,0.0],[1.909,0.0,0.0,0.0,0.0,0.071,0.0,-0.2503,-0.2503,0.0],[1.939,0.0,0.0,0.0,0.0,0.123,0.0,-0.3202,-0.3202,0.0],[1.97,0.0,0.0,0.0,0.0,0.1656,0.0,-0.3487,-0.3487,0.0],[2.0,0.0,0.0,0.0,0.0,0.1833,0.0,-0.332,-0.332,0.0],[2.03,0.0,0.0,0.0,0.0,0.0,0.0,-0.2723,-0.2723,0.0],[2.061,0.0,0.0,0.0,0.0,0.0,0.0,-0.1774,-0.1774,0.0],[2.091,0.0,0.0,0.0,0.0,0.0,0.0,-0.0595,-0.0595,0.0]]},"uh_huh_tilt":{"kind":"dance","duration":2.105,"frames":[[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.03,0.0,0.0,0.0,0.0471,0.0471,0.0,0.1413,-0.1413,0.0],[0.061,0.0,0.0,0.0,0.0927,0.0927,0.0,0.278,-0.278,0.0],[0.091,0.0,0.0,0.0,0.1352,0.1352,0.0,0.4056,-0.4056,0.0],[0.121,0.0,0.0,0.0,0.1733,0.1733,0.0,0.52,-0.52,0.0],[0.152,0.0,0.0,0.0,0.2058,0.2058,0.0,0.6174,-0.6174,0.0],[0.182,0.0,0.0,0.0,0.2315,0.2315,0.0,0.6946,-0.6946,0.0],[0.212,0.0,0.0,0.0,0.2497,0.2497,-0.0,0.7492,-0.7492,0.0],[0.242,0.0,0.0,0.0,0.2598,0.2598,-0.0,0.7794,-0.7794,0.0],[0.273,0.0,0.0,0.0,0.2614,0.2614,0.0,0.7841,-0.7841,0.0],[0.303,0.0,0.0,0.0,0.2544,0.2544,0.0,0.7633,-0.7633,0.0],[0.333,0.0,0.0,0.0,0.2392,0.2392,0.0,0.7175,-0.7175,0.0],[0.364,0.0,0.0,0.0,0.2161,0.2161,0.0,0.6483,-0.6483,0.0],[0.394,0.0,0.0,0.0,0.186,0.186,0.0,0.558,-0.558,0.0],[0.424,0.0,0.0,0.0,0.1498,0.1498,0.0,0.4495,-0.4495,0.0],[0.455,0.0,0.0,0.0,0.1088,0.1088,0.0,0.3263,-0.3263,0.0],[0.485,0.0,0.0,0.0,0.0641,0.0641,-0.0,0.1924,-0.1924,0.0],[0.515,0.0,0.0,0.0,0.0174,0.0174,-0.0,0.0523,-0.0523,0.0],[0.545,0.0,0.0,0.0,-0.0298,-0.0298,0.0,-0.0895,0.0895,0.0],[0.576,0.0,0.0,0.0,-0.0761,-0.0761,0.0,-0.2284,0.2284,0.0],[0.606,0.0,0.0,0.0,-0.12,-0.12,0.0,-0.3599,0.3599,0.0],[0.636,0.0,0.0,0.0,-0.1599,-0.1599,-0.0,-0.4796,0.4796,0.0],[0.667,0.0,0.0,0.0,-0.1946,-0.1946,-0.0,-0.5837,0.5837,0.0],[0.697,0.0,0.0,0.0,-0.2229,-0.2229,-0.0,-0.6687,0.6687,0.0],[0.727,0.0,0.0,0.0,-0.244,-0.244,0.0,-0.7319,0.7319,0.0],[0.758,0.0,0.0,0.0,-0.2571,-0.2571,0.0,-0.7712,0.7712,0.0],[0.788,0.0,0.0,0.0,-0.2618,-0.2618,0.0,-0.7854,0.7854,0.0],[0.818,0.0,0.0,0.0,-0.258,-0.258,0.0,-0.7739,0.7739,0.0],[0.848,0.0,0.0,0.0,-0.2457,-0.2457,-0.0,-0.7372,0.7372,0.0],[0.879,0.0,0.0,0.0,-0.2255,-0.2255,-0.0,-0.6764,0.6764,0.0],[0.909,0.0,0.0,0.0,-0.1979,-0.1979,0.0,-0.5936,0.5936,0.0],[0.939,0.0,0.0,0.0,-0.1638,-0.1638,-0.0,-0.4914,0.4914,0.0],[0.97,0.0,0.0,0.0,-0.1244,-0.1244,0.0,-0.3731,0.3731,0.0],[1.0,0.0,0.0,0.0,-0.0809,-0.0809,0.0,-0.2427,0.2427,0.0],[1.03,0.0,0.0,0.0,-0.0348,-0.0348,0.0,-0.1044,0.1044,0.0],[1.061,0.0,0.0,0.0,0.0125,0.0125,-0.0,0.0374,-0.0374,0.0],[1.091,0.0,0.0,0.0,0.0593,0.0593,0.0,0.1779,-0.1779,0.0],[1.121,0.0,0.0,0.0,0.1042,0.1042,0.0,0.3126,-0.3126,0.0],[1.152,0.0,0.0,0.0,0.1457,0.1457,-0.0,0.4371,-0.4371,0.0],[1.182,0.0,0.0,0.0,0.1825,0.1825,0.0,0.5474,-0.5474,0.0],[1.212,0.0,0.0,0.0,0.2133,0.2133,0.0,0.6398,-0.6398,0.0],[1.242,0.0,0.0,0.0,0.2371,0.2371,-0.0,0.7113,-0.7113,0.0],[1.273,0.0,0.0,0.0,0.2532,0.2532,0.0,0.7596,-0.7596,0.0],[1.303,0.0,0.0,0.0,0.261,0.261,0.0,0.7831,-0.7831,0.0],[1.333,0.0,0.0,0.0,0.2604,0.2604,0.0,0.7811,-0.7811,0.0],[1.364,0.0,0.0,0.0,0.2512,0.2512,0.0,0.7536,-0.7536,0.0],[1.394,0.0,0.0,0.0,0.2338,0.2338,0.0,0.7015,-0.7015,0.0],[1.424,0.0,0.0,0.0,0.2088,0.2088,0.0,0.6265,-0.6265,0.0],[1.455,0.0,0.0,0.0,0.177,0.177,-0.0,0.5311,-0.5311,0.0],[1.485,0.0,0.0,0.0,0.1394,0.1394,0.0,0.4183,-0.4183,0.0],[1.515,0.0,0.0,0.0,0.0973,0.0973,0.0,0.2919,-0.2919,0.0],[1.545,0.0,0.0,0.0,0.052,0.052,0.0,0.156,-0.156,0.0],[1.576,0.0,0.0,0.0,0.005,0.005,-0.0,0.015,-0.015,0.0],[1.606,0.0,0.0,0.0,-0.0422,-0.0422,0.0,-0.1266,0.1266,0.0],[1.636,0.0,0.0,0.0,-0.088,-0.088,0.0,-0.2639,0.2639,0.0],[1.667,0.0,0.0,0.0,-0.1309,-0.1309,0.0,-0.3927,0.3927,0.0],[1.697,0.0,0.0,0.0,-0.1696,-0.1696,0.0,-0.5087,0.5087,0.0],[1.727,0.0,0.0,0.0,-0.2027,-0.2027,-0.0,-0.608,0.608,0.0],[1.758,0.0,0.0,0.0,-0.2292,-0.2292,0.0,-0.6875,0.6875,0.0],[1.788,0.0,0.0,0.0,-0.2482,-0.2482,-0.0,-0.7446,0.7446,0.0],[1.818,0.0,0.0,0.0,-0.2591,-0.2591,-0.0,-0.7774,0.7774,0.0],[1.848,0.0,0.0,0.0,-0.2616,-0.2616,0.0,-0.7848,0.7848,0.0],[1.879,0.0,0.0,0.0,-0.2555,-0.2555,0.0,-0.7666,0.7666,0.0],[1.909,0.0,0.0,0.0,-0.2411,-0.2411,0.0,-0.7234,0.7234,0.0],[1.939,0.0,0.0,0.0,-0.2189,-0.2189,-0.0,-0.6566,0.6566,0.0],[1.97,0.0,0.0,0.0,-0.1895,-0.1895,0.0,-0.5684,0.5684,0.0],[2.0,0.0,0.0,0.0,-0.1539,-0.1539,0.0,-0.4616,0.4616,0.0],[2.03,0.0,0.0,0.0,-0.1133,-0.1133,0.0,-0.3398,0.3398,0.0],[2.061,0.0,0.0,0.0,-0.069,-0.069,-0.0,-0.2069,0.2069,0.0],[2.091,0.0,0.0,0.0,-0.0224,-0.0224,0.0,-0.0672,0.0672,0.0]]}}} \ No newline at end of file diff --git a/frontend/dist/robot-3d/meshes/5w_speaker.stl b/frontend/dist/robot-3d/meshes/5w_speaker.stl new file mode 100644 index 0000000000000000000000000000000000000000..00a29236bdb8101ddee079de562870f3a5877e12 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/5w_speaker.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89c220ac5fa6dd559fcd2f3faccb7197904ab6b882ccf5d2ad04b17a09d58b98 +size 229884 diff --git a/frontend/dist/robot-3d/meshes/antenna.stl b/frontend/dist/robot-3d/meshes/antenna.stl new file mode 100644 index 0000000000000000000000000000000000000000..ebaf6395ed1a0b79029a99b13d533f99871d75e5 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/antenna.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01f894d2eb9cdc94e7c45944cabb6fa84074e33fb45c3ab9974744bc0e43a9cb +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/antenna_body_3dprint.stl b/frontend/dist/robot-3d/meshes/antenna_body_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..57603870b064c815155ec0a14b722b374291a492 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/antenna_body_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f760ace60b1a368ba7c51bcd01a152a85e66a587fb24d55886cb9d9ffb9008f +size 241784 diff --git a/frontend/dist/robot-3d/meshes/antenna_holder_l_3dprint.stl b/frontend/dist/robot-3d/meshes/antenna_holder_l_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..1307d1989abeb277c9e7cc6bf5c7077c5f876a17 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/antenna_holder_l_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c2f0efae648fa0174dbc374fb63f4b48f55dea18f16f407540d255d8c91a426 +size 449784 diff --git a/frontend/dist/robot-3d/meshes/antenna_holder_r_3dprint.stl b/frontend/dist/robot-3d/meshes/antenna_holder_r_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..6320e62278b058b6349e38392804b5683374c5d5 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/antenna_holder_r_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7cd59ec8fd200294880c062b9190f223eb7fc7c207caecbb5de28fd4accbbe1 +size 465984 diff --git a/frontend/dist/robot-3d/meshes/antenna_interface_3dprint.stl b/frontend/dist/robot-3d/meshes/antenna_interface_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..15b32f15011a3154fc5c832e7573d6dfac98b538 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/antenna_interface_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:662384ed2de2c37fff6d5bab1ba0ccb76ee03f5d1680043d255e33e879b481bb +size 179984 diff --git a/frontend/dist/robot-3d/meshes/arducam.stl b/frontend/dist/robot-3d/meshes/arducam.stl new file mode 100644 index 0000000000000000000000000000000000000000..40bd218a8f79b1b3f786a2658cb667550c64c3c3 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/arducam.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dedb2f78b82216790ad43483c832744b86108dfab076a0f21938e6931beb1927 +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/b3b_eh.stl b/frontend/dist/robot-3d/meshes/b3b_eh.stl new file mode 100644 index 0000000000000000000000000000000000000000..fba886caadd77070fc58c1611683b49c30463611 Binary files /dev/null and b/frontend/dist/robot-3d/meshes/b3b_eh.stl differ diff --git a/frontend/dist/robot-3d/meshes/b3b_eh_1.stl b/frontend/dist/robot-3d/meshes/b3b_eh_1.stl new file mode 100644 index 0000000000000000000000000000000000000000..c26342b080fbea59c2742ad64ba916f1d6609da6 Binary files /dev/null and b/frontend/dist/robot-3d/meshes/b3b_eh_1.stl differ diff --git a/frontend/dist/robot-3d/meshes/bearing_85x110x13.stl b/frontend/dist/robot-3d/meshes/bearing_85x110x13.stl new file mode 100644 index 0000000000000000000000000000000000000000..abbeb37f153878d6b7cfa032bf1d06c34b8d3e61 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/bearing_85x110x13.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f79e3b8a1cf2da7be17907f6761acfa202fab9f759da196431712b7e20938fed +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/big_lens_d40.stl b/frontend/dist/robot-3d/meshes/big_lens_d40.stl new file mode 100644 index 0000000000000000000000000000000000000000..afa5536066cdf16c9d355babcf7782f4a2a4a54b --- /dev/null +++ b/frontend/dist/robot-3d/meshes/big_lens_d40.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4df711c8e29a677f62622d57c5cac01257ae9a44f46adb67fefb54b8fe52a6eb +size 151284 diff --git a/frontend/dist/robot-3d/meshes/body_down_3dprint.stl b/frontend/dist/robot-3d/meshes/body_down_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..03cab0fe177a5db289bfc900b50bc0bf62ef7ce4 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/body_down_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:737e674299655be49d6b37a196d21cf8b9fd95c2837667cf4e4ed8bc4a8e89fa +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/body_foot_3dprint.stl b/frontend/dist/robot-3d/meshes/body_foot_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..b7f445658c9b885ba1f1de7f643bb4c8759b6ce1 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/body_foot_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f021859da8f2b5dd663f36b7f4dd9b5e1c52485556a106b1ad66a3fed83281b8 +size 639584 diff --git a/frontend/dist/robot-3d/meshes/body_top_3dprint.stl b/frontend/dist/robot-3d/meshes/body_top_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..aae367ae2dea5adaf7e6c3b041e0207a2e1af2cb --- /dev/null +++ b/frontend/dist/robot-3d/meshes/body_top_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:60f406a0ff783d18bd20c0441d1e03243d11403a71e7f37ee6aa444da9110039 +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/body_turning_3dprint.stl b/frontend/dist/robot-3d/meshes/body_turning_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..aff15d1a3cf5bee1f753c06915ff76a8d92e4cc0 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/body_turning_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:805db06f0b88bd1d2bef6bd9c5b8afeaa364681fa8eff02465ceb14298283ae6 +size 393084 diff --git a/frontend/dist/robot-3d/meshes/bts2_m2_6x8.stl b/frontend/dist/robot-3d/meshes/bts2_m2_6x8.stl new file mode 100644 index 0000000000000000000000000000000000000000..c9d6877ca329f3ed698cc3fbc48bda60958d1304 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/bts2_m2_6x8.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303a706276ef0a3dcf8b6deeabf73969d2c48cb6628209bf0fed825b622deccb +size 269184 diff --git a/frontend/dist/robot-3d/meshes/dc15_a01_case_b_dummy.stl b/frontend/dist/robot-3d/meshes/dc15_a01_case_b_dummy.stl new file mode 100644 index 0000000000000000000000000000000000000000..be16e3d867aeec0cd64d95ff10324f7b57d0da17 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/dc15_a01_case_b_dummy.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b108f9390168a9052b408b292e316112f28e11d5ca51e28a374f29ce9ef2790 +size 248884 diff --git a/frontend/dist/robot-3d/meshes/dc15_a01_case_f_dummy.stl b/frontend/dist/robot-3d/meshes/dc15_a01_case_f_dummy.stl new file mode 100644 index 0000000000000000000000000000000000000000..5a208745ff57e7141d5fcb3d2c71e4c4c22fc2b1 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/dc15_a01_case_f_dummy.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ba4e280134154b64d2c5dd2f78f95c27e682a69e77f47895ac1fb3221d8c296 +size 326984 diff --git a/frontend/dist/robot-3d/meshes/dc15_a01_case_m_dummy.stl b/frontend/dist/robot-3d/meshes/dc15_a01_case_m_dummy.stl new file mode 100644 index 0000000000000000000000000000000000000000..409e7a8400b24fa00e323e2c9f73c22d78129a95 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/dc15_a01_case_m_dummy.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:716c7f05cb780b5eb1dc7e614b8376e587683f2922fcb386d0b8152a73b5af68 +size 162184 diff --git a/frontend/dist/robot-3d/meshes/dc15_a01_horn_dummy.stl b/frontend/dist/robot-3d/meshes/dc15_a01_horn_dummy.stl new file mode 100644 index 0000000000000000000000000000000000000000..a793ae59c5c0487bbcc0b51aba7762d399e20186 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/dc15_a01_horn_dummy.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8990dd416d5d6603e10b6d0fd05d8f552ef045fcebdcdeebf589d881c0185fd +size 445084 diff --git a/frontend/dist/robot-3d/meshes/dc15_a01_led_cap2_dummy.stl b/frontend/dist/robot-3d/meshes/dc15_a01_led_cap2_dummy.stl new file mode 100644 index 0000000000000000000000000000000000000000..5d371106480f1372c55da144f656036535003da5 Binary files /dev/null and b/frontend/dist/robot-3d/meshes/dc15_a01_led_cap2_dummy.stl differ diff --git a/frontend/dist/robot-3d/meshes/glasses_dolder_3dprint.stl b/frontend/dist/robot-3d/meshes/glasses_dolder_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..ca722275ff1e16fbd72ca3fe4a9fe2d5539cdd0b --- /dev/null +++ b/frontend/dist/robot-3d/meshes/glasses_dolder_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92f37eb75055678325c86ee614e3aef8aaa2bbdbaba518824045818edff3c1b9 +size 607884 diff --git a/frontend/dist/robot-3d/meshes/head_back_3dprint.stl b/frontend/dist/robot-3d/meshes/head_back_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..1c2b622228c14066b4053559d0f5abe9f25604a8 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/head_back_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:724385740aee0c18d3ccfe5df1b79049ff84c736cf652b53f5625ac5cc83c95c +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/head_front_3dprint.stl b/frontend/dist/robot-3d/meshes/head_front_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..cc5c788ebfeae6dc88330dfa1b59bd7f12fb9895 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/head_front_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b4938a455866612ec3915da422d5e01037844fb3424c55200eea8e056363f81 +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/head_mic_3dprint.stl b/frontend/dist/robot-3d/meshes/head_mic_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..7ac015f5fa2974656990060c12f699c40b624008 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/head_mic_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac3f4978f945345336481bde7b87aea91aeb97c3ce7e9433df8340923f5665bd +size 662084 diff --git a/frontend/dist/robot-3d/meshes/lens_cap_d30_3dprint.stl b/frontend/dist/robot-3d/meshes/lens_cap_d30_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..f4041bc93e20a82af29afd5fa69bd6af7fe09c32 Binary files /dev/null and b/frontend/dist/robot-3d/meshes/lens_cap_d30_3dprint.stl differ diff --git a/frontend/dist/robot-3d/meshes/lens_cap_d40_3dprint.stl b/frontend/dist/robot-3d/meshes/lens_cap_d40_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..a2084b06864b6400c59cac9fdd16de62ab8bda74 Binary files /dev/null and b/frontend/dist/robot-3d/meshes/lens_cap_d40_3dprint.stl differ diff --git a/frontend/dist/robot-3d/meshes/m12_fisheye_lens_1_8mm.stl b/frontend/dist/robot-3d/meshes/m12_fisheye_lens_1_8mm.stl new file mode 100644 index 0000000000000000000000000000000000000000..4ee95bc2115804d7426f64d015b8ab1eeb86858a --- /dev/null +++ b/frontend/dist/robot-3d/meshes/m12_fisheye_lens_1_8mm.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf2e973bd164cd66b747f16e0ad6c4aafc9492e0b053fd40c283f4beba1b6015 +size 259284 diff --git a/frontend/dist/robot-3d/meshes/mp01062_stewart_arm_3.stl b/frontend/dist/robot-3d/meshes/mp01062_stewart_arm_3.stl new file mode 100644 index 0000000000000000000000000000000000000000..4fd08b227327003a45bf104d95377eb3c24602ac --- /dev/null +++ b/frontend/dist/robot-3d/meshes/mp01062_stewart_arm_3.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b64f2de2a35b6feb9ed8ef728219f1a9600dfe6fcb70256a2e555cd6c49401e +size 155584 diff --git a/frontend/dist/robot-3d/meshes/neck_reference_3dprint.stl b/frontend/dist/robot-3d/meshes/neck_reference_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..4452bc3d51019dbe7f420ff854a0f3226d6762c7 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/neck_reference_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e619d224f39690c029b9e44bee7882e3650a8828e554d25c469bce3ab371ce5 +size 605084 diff --git a/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10.stl b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10.stl new file mode 100644 index 0000000000000000000000000000000000000000..a0f51417e2d4e782a557a9d604bb4698a14e129b --- /dev/null +++ b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3e9d4bddfe4a99c206feba0fe648c1e5caf0aefca6347c7a91ff8f425b58d35 +size 253184 diff --git a/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_1.stl b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_1.stl new file mode 100644 index 0000000000000000000000000000000000000000..f58ca0991a755c8e6960a392c0c5dcf151207344 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_1.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9cd84a44f18b39aae56220bfcdfdbf8e39a809c57e4d07c3d7a718c7ab5669e +size 253184 diff --git a/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_2.stl b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_2.stl new file mode 100644 index 0000000000000000000000000000000000000000..9a284934b4a1faf77ea41e7d4581f7776624a515 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_2.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ceba1b5c64923e7b29c5a686d753748b8a99496890ebe850694cba50d306d690 +size 253184 diff --git a/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_3.stl b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_3.stl new file mode 100644 index 0000000000000000000000000000000000000000..e6535203c2c91a6b4920769a140c428760629940 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/phs_1_7x20_5_dc10_3.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b446022c08e14a7d7e18ddfc5a5e979347abe1f3165d7d161b630f107964b26 +size 253184 diff --git a/frontend/dist/robot-3d/meshes/pp01102_arducam_carter.stl b/frontend/dist/robot-3d/meshes/pp01102_arducam_carter.stl new file mode 100644 index 0000000000000000000000000000000000000000..866f890e8e519bdc0f08e10fe5d9f1a76e580522 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/pp01102_arducam_carter.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edc115b09647cafaf2fd023cd940817b54c33ce04496e586fe9031bd7582c5c6 +size 109484 diff --git a/frontend/dist/robot-3d/meshes/small_lens_d30.stl b/frontend/dist/robot-3d/meshes/small_lens_d30.stl new file mode 100644 index 0000000000000000000000000000000000000000..8094f7e32450ded9ed331ccd7bbb17c5e4a806b0 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/small_lens_d30.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3f62174bc76b85b39e7835fc9e005fabde685677576c6c1e40753417fa922ec +size 158484 diff --git a/frontend/dist/robot-3d/meshes/stewart_link_ball.stl b/frontend/dist/robot-3d/meshes/stewart_link_ball.stl new file mode 100644 index 0000000000000000000000000000000000000000..1a9a1ea300afff8876d32f887b84d0d6784c54b6 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/stewart_link_ball.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d24b6357fe780b9f54a550278fded8886524b732e2ec7765eeed1a8eee0e94bd +size 194484 diff --git a/frontend/dist/robot-3d/meshes/stewart_link_ball__2.stl b/frontend/dist/robot-3d/meshes/stewart_link_ball__2.stl new file mode 100644 index 0000000000000000000000000000000000000000..24023fd4e3c3ca9000ffbb92ce8b56021836b330 --- /dev/null +++ b/frontend/dist/robot-3d/meshes/stewart_link_ball__2.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25041196fb7b87a0118d1b283e97bcd56a961aafd08527f1408cc23077e77285 +size 194484 diff --git a/frontend/dist/robot-3d/meshes/stewart_link_rod.stl b/frontend/dist/robot-3d/meshes/stewart_link_rod.stl new file mode 100644 index 0000000000000000000000000000000000000000..6401019dc983f1bd1fa464c1c28dd14a6df0847a --- /dev/null +++ b/frontend/dist/robot-3d/meshes/stewart_link_rod.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93ee70960df8d3a5b5ffa373d11438f0fc415d98d554d4a5e773d004fed40081 +size 1048584 diff --git a/frontend/dist/robot-3d/meshes/stewart_main_plate_3dprint.stl b/frontend/dist/robot-3d/meshes/stewart_main_plate_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..48a9f748b94c160d548f11c9eaaa4e67823ddffc --- /dev/null +++ b/frontend/dist/robot-3d/meshes/stewart_main_plate_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cfd8e409542b60a8b32579275633aa16ad2b4ffdc68ed5820c4810951f43f0f +size 340584 diff --git a/frontend/dist/robot-3d/meshes/stewart_tricap_3dprint.stl b/frontend/dist/robot-3d/meshes/stewart_tricap_3dprint.stl new file mode 100644 index 0000000000000000000000000000000000000000..3c6c794fe86bf0a939248998b3711134abcfe7fb --- /dev/null +++ b/frontend/dist/robot-3d/meshes/stewart_tricap_3dprint.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2b3dc47028ade99f0d6d671548b3fe3c4a83a3c7e8c26b2ade8d492e8e85156 +size 333184 diff --git a/frontend/dist/robot-3d/reachy-mini.urdf b/frontend/dist/robot-3d/reachy-mini.urdf new file mode 100644 index 0000000000000000000000000000000000000000..dd4a87c49bf41ccd57876170b95019203a643a08 --- /dev/null +++ b/frontend/dist/robot-3d/reachy-mini.urdf @@ -0,0 +1,3282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages.txt b/packages.txt new file mode 100644 index 0000000000000000000000000000000000000000..20645e641240cb419f5fc66c14c1447e91daf669 --- /dev/null +++ b/packages.txt @@ -0,0 +1 @@ +ffmpeg diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..4eb4db94f1f00a8e9736081615089d4152e3a59d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +gradio==6.17.3 +livekit>=1.0 +livekit-api>=1.0 +numpy>=1.26 +python-dotenv>=1.0 +python-multipart>=0.0.9 diff --git a/samples/ada-1.wav b/samples/ada-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..4152ef4f96ad71f77720f4c8334b5eb42219f197 --- /dev/null +++ b/samples/ada-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2886f74507bd01be0baf2d64fc0cc1a9fdfdbab105f11a7cbe9b871ae37964e +size 449358 diff --git a/samples/ada-2.wav b/samples/ada-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..371f0d02e301b0bcd0ab471a66fb1fe856592154 --- /dev/null +++ b/samples/ada-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:846044d8a35abccd3f8ffd2aa88f211c4f49a05cae27761c7b4d0cf111c521d3 +size 414798 diff --git a/samples/ada-3.wav b/samples/ada-3.wav new file mode 100644 index 0000000000000000000000000000000000000000..a507fc0f7f1d2cf67797d5fea419a39d6535b74d --- /dev/null +++ b/samples/ada-3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fd3ad6369ccaa867a7c6136fb1d04f845d11d8d70a1ccd9a4bae7b26469394d +size 499278 diff --git a/samples/batman-1.wav b/samples/batman-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..a398e08f1611e88854d7d8c0072a1fe328a5d3e3 --- /dev/null +++ b/samples/batman-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03f43db976cb3f32eb6006fc1dfe116b09ec7a4f0068a0f984990105dbe321af +size 308038 diff --git a/samples/batman-2.wav b/samples/batman-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..4cbf84c675a98df2d473c33c5040dd484333507c --- /dev/null +++ b/samples/batman-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ad9058bf286cb2568d675039367844e074c279a50e399a5ac22014108400cc2 +size 376826 diff --git a/samples/bode-1.wav b/samples/bode-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..bab1f2afb7009805eb3ff4a58c233cf2db042d82 --- /dev/null +++ b/samples/bode-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9310674de0128ee1beb8156b9dcc611982e466f917a99afc70b09ac6f728ebce +size 449358 diff --git a/samples/bode-2.wav b/samples/bode-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..3b48e3884c75f8b5ef572f3bb9f02ab1a0dbadd3 --- /dev/null +++ b/samples/bode-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:530bcc69454c4fe3d0ecea9d63c306828839a87a9fe0eb2296d5ff88e84af231 +size 468558 diff --git a/samples/bode-3.wav b/samples/bode-3.wav new file mode 100644 index 0000000000000000000000000000000000000000..6f173333b1a7c2634a7c38e978153d9eba1c56f9 --- /dev/null +++ b/samples/bode-3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de6daf8610947b4980743521bea29470092517cd41351405da218caf2d2555c1 +size 414798 diff --git a/samples/jack-1.wav b/samples/jack-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..dfd9d2829f5bfc3495253a7325e7a61dd6a42045 --- /dev/null +++ b/samples/jack-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87aad8e8f3cc5546dc6d900cf9c021a9c4f1c1a8b24a197de4678a907a38636f +size 449358 diff --git a/samples/jack-2.wav b/samples/jack-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..c60ab7a00ffc8870ee92c0fb9038649d17930fc8 --- /dev/null +++ b/samples/jack-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:018561a934b3e619f5c9dc6144682e8adc5affe1b626f7d7ef99057104becfae +size 487758 diff --git a/samples/jarvis-1.wav b/samples/jarvis-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..970fdf4fb028d04aa5336174c44e9cca1cb71211 --- /dev/null +++ b/samples/jarvis-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8639cec8d000d11b42eb039a87f2515a265fe141c7680202cec7a1b516822523 +size 368718 diff --git a/samples/jarvis-2.wav b/samples/jarvis-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..ff65d48e01b61ecf23383fce2f012dd3614d5b7f --- /dev/null +++ b/samples/jarvis-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e358bff7959b5780e8de47c88c9afa57746a2daf39c6c6c2c6a7d4a89d0b9498 +size 311118 diff --git a/samples/surfer-1.wav b/samples/surfer-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..624dddf0092935d13c9331ce5bffb221813e3b03 --- /dev/null +++ b/samples/surfer-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7089108a6562ca369364b0584a3487030ca1215e601dddb76836cbc731d02ee4 +size 322638 diff --git a/samples/surfer-2.wav b/samples/surfer-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..5fbcd1d47047d8cd16bef825cb9b3b1f792a3c5d --- /dev/null +++ b/samples/surfer-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6c1c58a7a42f9207d5d52dd45e2482781c624c8ff8160d4c90ed55ff640df50 +size 245838 diff --git a/samples/yoda-1.wav b/samples/yoda-1.wav new file mode 100644 index 0000000000000000000000000000000000000000..444b18111386d257b3b08dfe275247eeb4d6c055 --- /dev/null +++ b/samples/yoda-1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83b56c48823075c1c68f69d8bab342ab7a673b9e35a09d0c0eaf78e70f357fa0 +size 514638 diff --git a/samples/yoda-2.wav b/samples/yoda-2.wav new file mode 100644 index 0000000000000000000000000000000000000000..9a869ea348c350ea786eec0f35b03146ebf12223 --- /dev/null +++ b/samples/yoda-2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3fb0d44271887fd95fa086d9f8d9eaba813ec325e5483152f3483a2b66242b3c +size 322638