diff --git a/.gitattributes b/.gitattributes index 3b8dec6aa65abb11bcf9465878fe288f84bcd05a..0e19adf09bb3b973d4d0171728271f6cac9554d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -37,3 +37,30 @@ default_voices/AmericanFemale.mp3 filter=lfs diff=lfs merge=lfs -text default_voices/AmericanMale.mp3 filter=lfs diff=lfs merge=lfs -text default_voices/BritishFemale.mp3 filter=lfs diff=lfs merge=lfs -text zonos3/vendor/nemo_text_processing/text_normalization/en/data/number/cardinal_number_name.far filter=lfs diff=lfs merge=lfs -text +default_voices/English/Cillian_en-Irish_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Imogen_en-British_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Jett_en-energetic_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Morgana_en-witch_F_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/English/Rupert_en-British_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Sakura_en-anime_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Savannah_en-American_F_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/English/Thaddeus_en-announcervoice_M_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/English/Willow_en-asrm_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/English/Wyatt_en-American_M_1.ogg filter=lfs diff=lfs merge=lfs -text +default_voices/French/Gaspard_fr_M_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/German/Liesel_de_F_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/German/Wolfgang_de_M_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/Hindi/Ananya_hi_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Hindi/Arjun_hi_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Italian/Ginevra_it_F_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/Italian/Lorenzo_it_M_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/Korean/Minjun_ko_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Korean/Seoyeon_ko_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Mandarin[[:space:]]Chinese/Haoran_zh-energetic_M_1.mp3 filter=lfs diff=lfs merge=lfs -text +default_voices/Mandarin[[:space:]]Chinese/Meilin_zh-energetic_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Portuguese/Leonor_pt_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Portuguese/Thiago_pt_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Spanish/Rodrigo_es_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Spanish/Ximena_es_F_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Telugu/Chaitanya_te_M_1.wav filter=lfs diff=lfs merge=lfs -text +default_voices/Telugu/Sravya_te_F_1.wav filter=lfs diff=lfs merge=lfs -text diff --git a/app.py b/app.py index f1aa0db0a1cc7cf8f5e481830aec75c76b387e1a..0c2b056e893f3f9d72ad78dd23fd258c8f6c279e 100644 --- a/app.py +++ b/app.py @@ -62,7 +62,7 @@ from zonos3.server.capabilities import ( CapabilityFacts, capabilities_document, condition_spec, - decoder_capability, + decoder_capabilities, dual_codec_hop, ) from zonos3.server.errors import call as edit_errors @@ -74,7 +74,7 @@ from zonos3.server.schemas import ( PhonemizeRequest, SpeakerCreateRequest, ) -from zonos3.server.speech import check_format, prefix_stream_supported, speech_headers +from zonos3.server.speech import check_format, prefix_stream_supported, resolve_decoder, speech_headers from zonos3.server.studio import resolve_studio_file, studio_cache_control from zonos3.server.voices import ( DefaultVoice, @@ -155,6 +155,8 @@ ASSETS.normalizer().warmup() # --------------------------------------------------------------------------------------------- capabilities +# The Space decodes with the codec's default decoder only (zonos3.reference.synth): a request's `decoder` may name it. +DECODERS = [matched_codec.decoder_id(CONFIG.audio_codec)] EDIT_MODEL = EditModel.from_config( CONFIG, hop=int(matched_codec.entry(CONFIG.audio_codec)["hop"]), @@ -167,6 +169,7 @@ def capabilities() -> dict: LoRA and the gold lexicon; no plugins, no project store.""" c = CONFIG modes = list(CONTEXT.speaker_modes) + decoder, decoders = decoder_capabilities(c.audio_codec, DECODERS) return capabilities_document( CapabilityFacts( text_tokenizer_spec=CONTEXT.text_tokenizer_spec or None, @@ -183,7 +186,8 @@ def capabilities() -> dict: silence_hop=dual_codec_hop(c.audio_codec), tag_cfg_available=True, tag_cfg_trained=trained_on_tags(resolve_dir_or_local(SPACE_LM)), - decoder=decoder_capability(c.audio_codec), + decoder=decoder, + decoders=decoders, condition_tokens=None if c.condition_count == 0 else condition_spec( @@ -737,7 +741,8 @@ class SpaceEditEngine: hidden_delta=delta, ) - async def decode(self, codes: np.ndarray) -> np.ndarray: + async def decode(self, codes: np.ndarray, decoder: str | None) -> np.ndarray: + # the edit route checked `decoder`: the default (DECODERS) or None return await edit_call(EDIT_REQUEST.get()[0], "decode", codes=np.asarray(codes)) @@ -779,7 +784,12 @@ async def edit_align(req: EditAlignRequest, request: Request): @app.post("/v2/edit") async def edit(req: EditRequest, request: Request): """Regenerate the edited regions of recorded speech (the edit LoRA on); unedited codec frames are kept exactly.""" - return await edit_route(request, lambda rt: rt.edit(req)) + + async def run(rt): + resolve_decoder(req.decoder, DECODERS) # 400 for an id this Space does not serve + return await rt.edit(req) + + return await edit_route(request, run) @app.get("/v2/capabilities") @@ -890,6 +900,7 @@ async def generate( 16-bit WAV).""" try: check_format(bool(req.stream), req.format) + decoder = resolve_decoder(req.decoder, DECODERS) body = await prepare(req.model_dump(), normalize_session_id(x_tts_session_id)) except ValueError as exc: raise HTTPException(status_code=400, detail=str(exc)) from exc @@ -906,7 +917,11 @@ async def generate( raise HTTPException(status_code=400 if kind == "invalid" else 500, detail=payload) seed, reading = payload headers = speech_headers( - fmt=req.format, seed=seed, control_spans=bool(req.control_spans), follows_reading=bool(reading) + fmt=req.format, + seed=seed, + control_spans=bool(req.control_spans), + follows_reading=bool(reading), + decoder=decoder, ) if req.stream: # a failure mid-take ends the stream: the status line is already sent return StreamingResponse( diff --git a/default_voices/English/Cillian_en-Irish_M_1.codes.npy b/default_voices/English/Cillian_en-Irish_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..caea1949be1f0c5fbf37fa2d8cb005622964e618 --- /dev/null +++ b/default_voices/English/Cillian_en-Irish_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dadae1124c63cda7a0627fd282d54aa255a8800155eae1b9da54b08b345c2f10 +size 5928 diff --git a/default_voices/English/Cillian_en-Irish_M_1.embedding.npy b/default_voices/English/Cillian_en-Irish_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..1f13ba7b9f31bbb7ae9b3bded3f08c192b3beb8c --- /dev/null +++ b/default_voices/English/Cillian_en-Irish_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3125fae2f679fb5c8128d308ddd02986fd7d914975d17cc6dadf9eb130b1061 +size 896 diff --git a/default_voices/English/Cillian_en-Irish_M_1.wav b/default_voices/English/Cillian_en-Irish_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..a0357b3daee30be79fabb672f2a07092eb9a5940 --- /dev/null +++ b/default_voices/English/Cillian_en-Irish_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d43eda64c4928dfb30ecf547e4a00100b8f83ed0eb5c1e07116725794da72ea2 +size 852644 diff --git a/default_voices/English/Imogen_en-British_F_1.codes.npy b/default_voices/English/Imogen_en-British_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..dc617c561eefd6488a0b1665418b9b491836bc8d --- /dev/null +++ b/default_voices/English/Imogen_en-British_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c906f6c405c9078607fe9c54cf1b71ef0e112839490499e34bf8791ed1ad7e86 +size 7728 diff --git a/default_voices/English/Imogen_en-British_F_1.embedding.npy b/default_voices/English/Imogen_en-British_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..cdd610f83ccd9a7f74450516233bd81722f354ac --- /dev/null +++ b/default_voices/English/Imogen_en-British_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:683424b91faeade48c8a92e05e1c3679366abbba443ef62eccba8dc40de48e9e +size 896 diff --git a/default_voices/English/Imogen_en-British_F_1.wav b/default_voices/English/Imogen_en-British_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..9b0aa2216fb3d51f7f08f9319e8acaa8f2d66ab6 --- /dev/null +++ b/default_voices/English/Imogen_en-British_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dde4691a6ccd95f4928fbbc4e2d49089824b264575bc0bf0ac4986dd2f8082c5 +size 1117244 diff --git a/default_voices/English/Jett_en-energetic_M_1.codes.npy b/default_voices/English/Jett_en-energetic_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..ddb65521df5c47b513f215a4959e76f6910661f9 --- /dev/null +++ b/default_voices/English/Jett_en-energetic_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f32e946509673ae422c37cc9b79957cb569f212360745f9110d343f6f1f9f2c +size 6608 diff --git a/default_voices/English/Jett_en-energetic_M_1.embedding.npy b/default_voices/English/Jett_en-energetic_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..75fe426b10bfde91fe83c0b3811b392fd8eadfe5 --- /dev/null +++ b/default_voices/English/Jett_en-energetic_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:624b749d220dac7fdcda479b1964cb8f7de58c838c1357f2f0161dac06e34f48 +size 896 diff --git a/default_voices/English/Jett_en-energetic_M_1.wav b/default_voices/English/Jett_en-energetic_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..7f6e9b52ca5296fde3846fb1436a0bfb71c86a0d --- /dev/null +++ b/default_voices/English/Jett_en-energetic_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:107c8350f191d47401da6844158528d0f493cbf46be4dee6bb81dd71bc052619 +size 952604 diff --git a/default_voices/English/Morgana_en-witch_F_1.codes.npy b/default_voices/English/Morgana_en-witch_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..2cdd9341832bcd2b4b5ad93c7f7be35c63b5b990 --- /dev/null +++ b/default_voices/English/Morgana_en-witch_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f60227a9f7cdc6ce696548f4c28c199d3f5afeadf7317a1bde132575a1ed731 +size 12448 diff --git a/default_voices/English/Morgana_en-witch_F_1.embedding.npy b/default_voices/English/Morgana_en-witch_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..8671c2114bc5bfb18d83670f28cb3ba0b338b637 --- /dev/null +++ b/default_voices/English/Morgana_en-witch_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a817387697c43138639aa1e52a9e42d9f3a629655e0faea5ac8565eb8e57c091 +size 896 diff --git a/default_voices/English/Morgana_en-witch_F_1.mp3 b/default_voices/English/Morgana_en-witch_F_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..5364a53463212237eee08d5027a2c37d50cfebf0 --- /dev/null +++ b/default_voices/English/Morgana_en-witch_F_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fec617ca7a4044f930c108ded0daf814ca93e61d97a7df626373aa182240ece +size 329812 diff --git a/default_voices/English/Rupert_en-British_M_1.codes.npy b/default_voices/English/Rupert_en-British_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..17dcdc3d9db449dc0bd44691fcab253c20be624f --- /dev/null +++ b/default_voices/English/Rupert_en-British_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abf42171c7402fea5888ec350a50b64fd78777e44d7caf665c04e4e2b629fc79 +size 8048 diff --git a/default_voices/English/Rupert_en-British_M_1.embedding.npy b/default_voices/English/Rupert_en-British_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..4d29433a1eee6225edf53d7e3abaac9f0353b416 --- /dev/null +++ b/default_voices/English/Rupert_en-British_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c68e699376dbafdc1ab0fadc133f48e7df9cb33b3a7b80b05f42c5c0aad8fa7 +size 896 diff --git a/default_voices/English/Rupert_en-British_M_1.wav b/default_voices/English/Rupert_en-British_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..a1a46bd19f71bc483e1dbbfd26764fb62f0d6e80 --- /dev/null +++ b/default_voices/English/Rupert_en-British_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3743b94cfc35c004fb5c2bcc9c2a537b605e3e15d4677e2b5b811bc18d95151e +size 1164284 diff --git a/default_voices/English/Sakura_en-anime_F_1.codes.npy b/default_voices/English/Sakura_en-anime_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..f2044c7eb91b8b8fe1e79420cd34bc4ff86ba2fd --- /dev/null +++ b/default_voices/English/Sakura_en-anime_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b8c8288b45e1a3ff5aa3adc05a4af386f5889e9ab47902ff36f9daa8900ded2 +size 9168 diff --git a/default_voices/English/Sakura_en-anime_F_1.embedding.npy b/default_voices/English/Sakura_en-anime_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..4705c78ae92ff261e95f7afd90cce9b9e10decd4 --- /dev/null +++ b/default_voices/English/Sakura_en-anime_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:daf3e82d2e6f2ce2fe90c73473a312a721295ae7f85763f99c87ee2f861063a9 +size 896 diff --git a/default_voices/English/Sakura_en-anime_F_1.wav b/default_voices/English/Sakura_en-anime_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..03ba61bdd9a9dbbca9c2f78a87e99871571733e3 --- /dev/null +++ b/default_voices/English/Sakura_en-anime_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01e8f47241546efd1223bd1cac09ea81f1d9ae2cf3148260f37413f05db40229 +size 1328924 diff --git a/default_voices/English/Savannah_en-American_F_1.codes.npy b/default_voices/English/Savannah_en-American_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..de5d99cd545914328947b5e6e1b5d648063af5c2 --- /dev/null +++ b/default_voices/English/Savannah_en-American_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6e450fea8fa521c6be32b64fc61f48d6f9fd8301fe5759abd2315ce6ac946fb +size 6968 diff --git a/default_voices/English/Savannah_en-American_F_1.embedding.npy b/default_voices/English/Savannah_en-American_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..b8d478227a96ede89bb99a32ea01acf1686ee285 --- /dev/null +++ b/default_voices/English/Savannah_en-American_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd81587e66f96fb62da47ef13d5d867de464ca386a83f01b4403cdd19629ca6c +size 896 diff --git a/default_voices/English/Savannah_en-American_F_1.mp3 b/default_voices/English/Savannah_en-American_F_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..4d29c41b0af4ab4bfaeab66b5256ae820536ee35 --- /dev/null +++ b/default_voices/English/Savannah_en-American_F_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8d5eaf8f6c18a0a3b452652da62d821f819d4e95f6347aa29986a503e219d14 +size 183527 diff --git a/default_voices/English/Thaddeus_en-announcervoice_M_1.codes.npy b/default_voices/English/Thaddeus_en-announcervoice_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..63c4a8b3a621d23a1a35d10c23190641bdc29ef2 --- /dev/null +++ b/default_voices/English/Thaddeus_en-announcervoice_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c76de5bf16fd10282fced313c6c00a03fa2150b1df4c2382e19c6cbad65f179 +size 9368 diff --git a/default_voices/English/Thaddeus_en-announcervoice_M_1.embedding.npy b/default_voices/English/Thaddeus_en-announcervoice_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..1157f327e02d6509275e8df150aa716449e783f2 --- /dev/null +++ b/default_voices/English/Thaddeus_en-announcervoice_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc8e21356730988aa20da70123991404345e0bdbfe3afe31e6371d8d93095461 +size 896 diff --git a/default_voices/English/Thaddeus_en-announcervoice_M_1.mp3 b/default_voices/English/Thaddeus_en-announcervoice_M_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..535a4f2e756c5612c1d2d4cb34cefead60a28b37 --- /dev/null +++ b/default_voices/English/Thaddeus_en-announcervoice_M_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7fc96a18645b129b1e55659379ba796f5cfd70a800068b977d37f1254e93c52 +size 247474 diff --git a/default_voices/English/Willow_en-asrm_F_1.codes.npy b/default_voices/English/Willow_en-asrm_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..2013b28868bbae0b6e5cf62f0bad73fc6c55ae98 --- /dev/null +++ b/default_voices/English/Willow_en-asrm_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29ca4c14c16bb09b2bc48bb93f2d5a56327558d64271e54ebd1f713a4204905b +size 15048 diff --git a/default_voices/English/Willow_en-asrm_F_1.embedding.npy b/default_voices/English/Willow_en-asrm_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..876e2b26c5f65d74bbdbe78bb5194d6a2eba1070 --- /dev/null +++ b/default_voices/English/Willow_en-asrm_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ebb84309f21f1dcbe6371e2355dc98f8ee3d0aee5850c305d06a73fe0a7c222 +size 896 diff --git a/default_voices/English/Willow_en-asrm_F_1.wav b/default_voices/English/Willow_en-asrm_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..6fe08b9e567b2a842f2a23e04f8abae3499f6f0a --- /dev/null +++ b/default_voices/English/Willow_en-asrm_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a7574e4b91794390867027eb5c2c2a12f6cef557fc7d804b45f985144a50e5e +size 2193284 diff --git a/default_voices/English/Wyatt_en-American_M_1.codes.npy b/default_voices/English/Wyatt_en-American_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..fe7a4ace704badd4adb74aa5e2673ab0ca475f5e --- /dev/null +++ b/default_voices/English/Wyatt_en-American_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a854f9b66eefa9203a9f752c2a1ec808345b4d72ac34f8547ee776c58e4b72f +size 10248 diff --git a/default_voices/English/Wyatt_en-American_M_1.embedding.npy b/default_voices/English/Wyatt_en-American_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..921f4a78256265a482a9e3b77315d283fff74d24 --- /dev/null +++ b/default_voices/English/Wyatt_en-American_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b39d377b653ebaca6bbd4ecd13c382fe16d81f0cfae27217d9b626e5589a0511 +size 896 diff --git a/default_voices/English/Wyatt_en-American_M_1.ogg b/default_voices/English/Wyatt_en-American_M_1.ogg new file mode 100644 index 0000000000000000000000000000000000000000..6270fbf65e394ac9c10dca0fc5f4e5a66359a846 --- /dev/null +++ b/default_voices/English/Wyatt_en-American_M_1.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92c17f6eff4c9612ece96f0efae6f74f8e6b381f8c851ce739cdf0854a5a5831 +size 147400 diff --git a/default_voices/French/Gaspard_fr_M_1.codes.npy b/default_voices/French/Gaspard_fr_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..4d2ff3bdde469bbf30576d96b077b36d7698ec21 --- /dev/null +++ b/default_voices/French/Gaspard_fr_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34293ea302d3a47c17ab2f8514fb3a3354dc4ad695581d9b2f93fb37476ee1f7 +size 11488 diff --git a/default_voices/French/Gaspard_fr_M_1.embedding.npy b/default_voices/French/Gaspard_fr_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..abfe47d70ee675c56022c81827bcae4beacb1ff5 --- /dev/null +++ b/default_voices/French/Gaspard_fr_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e19a9a545af6a263c00b997368d8396ff8abc761b53dce2a6d4df735f0766e9 +size 896 diff --git a/default_voices/French/Gaspard_fr_M_1.mp3 b/default_voices/French/Gaspard_fr_M_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..810b988fd7948429884a6eca555c36f7eac88fe2 --- /dev/null +++ b/default_voices/French/Gaspard_fr_M_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b353c4f7cccb9ffd335dde8428cae212373db2cf9c7018afc22cbb8f3d6c949a +size 303899 diff --git a/default_voices/German/Liesel_de_F_1.codes.npy b/default_voices/German/Liesel_de_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..d62fd1f381037c01a0dc19983af6ad877387154a --- /dev/null +++ b/default_voices/German/Liesel_de_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6952aa3383e1181610b3b88115ff2fa20a2a2da0686c9b19f2cf0f57f96ab92e +size 6928 diff --git a/default_voices/German/Liesel_de_F_1.embedding.npy b/default_voices/German/Liesel_de_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..0dcae442d4c1aa6fcc89932ab0355c83726eb94d --- /dev/null +++ b/default_voices/German/Liesel_de_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d44e40f8c1f43fcabaabf301e14bfc48325bf4596cb04e076d662d8b2724c5d +size 896 diff --git a/default_voices/German/Liesel_de_F_1.mp3 b/default_voices/German/Liesel_de_F_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..2f867b17e59dedade064ae5ea7246d46a4ea17f1 --- /dev/null +++ b/default_voices/German/Liesel_de_F_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a8909ca74065967d74534f438fcd15b770fc2ec55d2cbe217836a720cfff091 +size 182273 diff --git a/default_voices/German/Wolfgang_de_M_1.codes.npy b/default_voices/German/Wolfgang_de_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..43300e7972337a22556f1fbc14b53e432f02a66c --- /dev/null +++ b/default_voices/German/Wolfgang_de_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:553a4dd74cc650ea333c49033f5b459e1faa7244cfa4185862cce1a223fe41e1 +size 7488 diff --git a/default_voices/German/Wolfgang_de_M_1.embedding.npy b/default_voices/German/Wolfgang_de_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..a6c13b43dff6f3731b049ded26caab918135674e --- /dev/null +++ b/default_voices/German/Wolfgang_de_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a0e305b2789f79b843d96628b275b5d8f3f877f89c80e87fe57bf6078901467 +size 896 diff --git a/default_voices/German/Wolfgang_de_M_1.mp3 b/default_voices/German/Wolfgang_de_M_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..bc3a985c2aba3ce64f378648a24e10b159897e2a --- /dev/null +++ b/default_voices/German/Wolfgang_de_M_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ca32af842970e58c2769f1a191438f44b36e721071e058ed51a8c2febb2f261 +size 196483 diff --git a/default_voices/Hindi/Ananya_hi_F_1.codes.npy b/default_voices/Hindi/Ananya_hi_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..f62a54922826e0bfc98f78b966dbe889aef84857 --- /dev/null +++ b/default_voices/Hindi/Ananya_hi_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85288fd646bb836b2424faad617d13f311c4ce129a48d7f9577bbfe29df9aa5b +size 7768 diff --git a/default_voices/Hindi/Ananya_hi_F_1.embedding.npy b/default_voices/Hindi/Ananya_hi_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..93bea48002970de357c5f9291db6b0e76024d1fb --- /dev/null +++ b/default_voices/Hindi/Ananya_hi_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7acf756273d86131de701d51b25a7e0b3323d724b7e98a0c890fcf176f85a14 +size 896 diff --git a/default_voices/Hindi/Ananya_hi_F_1.wav b/default_voices/Hindi/Ananya_hi_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..9a5d8c4682eca8e6944f52eaaa0c8772a4ae0cde --- /dev/null +++ b/default_voices/Hindi/Ananya_hi_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c0417c4f1a76d3290281c932a35b5b25b8e4cfe9acb328e24abf68b7f232840 +size 1123124 diff --git a/default_voices/Hindi/Arjun_hi_M_1.codes.npy b/default_voices/Hindi/Arjun_hi_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..aa4f5879c59754392f545a2af43ccb864cf6697a --- /dev/null +++ b/default_voices/Hindi/Arjun_hi_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dec52799002595008cf710381b5eb5f2acf0edd82fb28636c1bbef4aba9df618 +size 7128 diff --git a/default_voices/Hindi/Arjun_hi_M_1.embedding.npy b/default_voices/Hindi/Arjun_hi_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..a0484aa4ebc17f3a9eea865f3a7139f708404ded --- /dev/null +++ b/default_voices/Hindi/Arjun_hi_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cb0eb4cc81b79acadedb173e1fbbc0203bf71ea9ae66e56bd76393386f25815 +size 896 diff --git a/default_voices/Hindi/Arjun_hi_M_1.wav b/default_voices/Hindi/Arjun_hi_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..0b96ec58e36eeb250fa4a0e941019621f2d7d327 --- /dev/null +++ b/default_voices/Hindi/Arjun_hi_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:760b13421993d4d453cf9c3ce789da2425922c54a483a1e1d2daff3a226a6043 +size 1029044 diff --git a/default_voices/Italian/Ginevra_it_F_1.codes.npy b/default_voices/Italian/Ginevra_it_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..91fdf1c82b8dd56391e95cd5c83f4ba94b8f99fb --- /dev/null +++ b/default_voices/Italian/Ginevra_it_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91e5f1a6ccc71d55840e4277a4f00c900e01e446e956949a5651c2e5657f2d4f +size 6808 diff --git a/default_voices/Italian/Ginevra_it_F_1.embedding.npy b/default_voices/Italian/Ginevra_it_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..aec377f7acfac99d7291086aa545e197b5335197 --- /dev/null +++ b/default_voices/Italian/Ginevra_it_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:950ecf44f57fd053effd83c65f7f35059df0dcd1bb99dbc197b6649507171621 +size 896 diff --git a/default_voices/Italian/Ginevra_it_F_1.mp3 b/default_voices/Italian/Ginevra_it_F_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..7a1ec31196747542c0b9127d2f272a2026e7240d --- /dev/null +++ b/default_voices/Italian/Ginevra_it_F_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8dc9a8ebaa97b6c9a32aab707f1384a37d275e9a001029fedbfe7897a92514d9 +size 179347 diff --git a/default_voices/Italian/Lorenzo_it_M_1.codes.npy b/default_voices/Italian/Lorenzo_it_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..652c6ab3b0206b4cc6af4ec85e81b7cea9a56830 --- /dev/null +++ b/default_voices/Italian/Lorenzo_it_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e25cc35719d796ba7ace4a0ec563d159cfe31e978f78098b126b2a8c7f3fbc02 +size 7488 diff --git a/default_voices/Italian/Lorenzo_it_M_1.embedding.npy b/default_voices/Italian/Lorenzo_it_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..3a5ad500e72832e9f83b6787565124ce50f9cb87 --- /dev/null +++ b/default_voices/Italian/Lorenzo_it_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a355bb33b907130985b74eae3fa05e4aa19d7fe7233f26c0416afad0726c2367 +size 896 diff --git a/default_voices/Italian/Lorenzo_it_M_1.mp3 b/default_voices/Italian/Lorenzo_it_M_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..50ad8ae5aa90b234b243e01ad503856cd3c3f64d --- /dev/null +++ b/default_voices/Italian/Lorenzo_it_M_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be0f69f123a15d1c7c1100abf94c6f1c649034f16239f2926a87f20550d2ebcb +size 196483 diff --git a/default_voices/Korean/Minjun_ko_M_1.codes.npy b/default_voices/Korean/Minjun_ko_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..16421b9ee9fcd33be1f4cedd2aa38888a16e5874 --- /dev/null +++ b/default_voices/Korean/Minjun_ko_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b40a0d108b5188be2fb8695eb0f28b5a6f16c4dd485fba4ab82876b46e79522 +size 7288 diff --git a/default_voices/Korean/Minjun_ko_M_1.embedding.npy b/default_voices/Korean/Minjun_ko_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..d061dd4b5576c83fcb8878176db1f4f48dfb975e --- /dev/null +++ b/default_voices/Korean/Minjun_ko_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab3d9c60c3f36080fd7e9eebd20c8ece42059236dd83f19980e5e4dbca94fc4e +size 896 diff --git a/default_voices/Korean/Minjun_ko_M_1.wav b/default_voices/Korean/Minjun_ko_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..0fb74b715dd76131b5e0cb0b8cb2e2f040e3e05e --- /dev/null +++ b/default_voices/Korean/Minjun_ko_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1c1e59241314afe001d565ab4e0c92224f598f6bbc1e4aaaac2ce5b036d16aa +size 1052564 diff --git a/default_voices/Korean/Seoyeon_ko_F_1.codes.npy b/default_voices/Korean/Seoyeon_ko_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..9602313d4f036596632a2311afcb8a9ac4a354d6 --- /dev/null +++ b/default_voices/Korean/Seoyeon_ko_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6ca0cb788e610d56b02824108aa7c54e115bdab1eaeca81330b1475f6de9d15 +size 7048 diff --git a/default_voices/Korean/Seoyeon_ko_F_1.embedding.npy b/default_voices/Korean/Seoyeon_ko_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..c5910a8e8505215a45248ace72fba1cea616f0f2 --- /dev/null +++ b/default_voices/Korean/Seoyeon_ko_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dddb6aa68c3febe83ca656c959f4d78246c72e011cde72c3745d1a46a37d8345 +size 896 diff --git a/default_voices/Korean/Seoyeon_ko_F_1.wav b/default_voices/Korean/Seoyeon_ko_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..4df539aca7e22f904b944cce6c0a9a38cfa3c88b --- /dev/null +++ b/default_voices/Korean/Seoyeon_ko_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:558801500e68ee38fabca81c12fe2f7ec763e989e94430b3573be3df2e0ebf30 +size 1017284 diff --git a/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.codes.npy b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..e21b1f382a77943ee8bc41d394e883ed6958ac92 --- /dev/null +++ b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:033e6e1acb03cacf2dc9278f752c43774224747e3aa91882113422ab35dbfbb6 +size 6608 diff --git a/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.embedding.npy b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..2be500d11f859dd80709bf87c9dc4da7630515eb --- /dev/null +++ b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b056f91bcbf4ffda432459f8c6a80b37cdc98cd82fd296e29cf2584325809c6c +size 896 diff --git a/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.mp3 b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..50b4fa73a2749a706893e066e5c8e51e3fb86983 --- /dev/null +++ b/default_voices/Mandarin Chinese/Haoran_zh-energetic_M_1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddd027b458401d46f893d51e42cbd0c7d9634592a7401a43127c1a639215d6be +size 173914 diff --git a/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.codes.npy b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..80d3b46d8ea4c18f2fe837ddd563c6833a32b70c --- /dev/null +++ b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a3b3aef695ca75788eea98d94d8580d2147c783f427e08cf4ed2d66ecf5c4c6 +size 6888 diff --git a/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.embedding.npy b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..abd3a15322b931f3577892005cbeab5ccffe30a9 --- /dev/null +++ b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8430a2852291d874f327666d05bd15ee854a009cc54b9d3cdba9005d6bc7f59b +size 896 diff --git a/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.wav b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..c9a136199bc27b1f200396deea6bb1e99c174eab --- /dev/null +++ b/default_voices/Mandarin Chinese/Meilin_zh-energetic_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4200f7e397be1ff2a5dac9169daba8338af911e12cf47e925999016d65969612 +size 993764 diff --git a/default_voices/Portuguese/Leonor_pt_F_1.codes.npy b/default_voices/Portuguese/Leonor_pt_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..b6b757c4f900ac178e754ef8d343a5c569a3be73 --- /dev/null +++ b/default_voices/Portuguese/Leonor_pt_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56f4c8d2d6f856305e250966710fa7669244ef1d86ffd82659ade969755c7f88 +size 7448 diff --git a/default_voices/Portuguese/Leonor_pt_F_1.embedding.npy b/default_voices/Portuguese/Leonor_pt_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..90e575bda94727597a9607a39750871da0ae4d5b --- /dev/null +++ b/default_voices/Portuguese/Leonor_pt_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4074805d713ac20444253f1b98f814b7f27c43b6ab29bb2f0feeaaae8f7e4b2 +size 896 diff --git a/default_voices/Portuguese/Leonor_pt_F_1.wav b/default_voices/Portuguese/Leonor_pt_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..e9a1fb35730eb513c5b28851f8e44dd8fff11a2f --- /dev/null +++ b/default_voices/Portuguese/Leonor_pt_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cb21b761a7c808b2552451485ca14b32529b68294ef4b478c96665cabc8fcd1 +size 1076084 diff --git a/default_voices/Portuguese/Thiago_pt_M_1.codes.npy b/default_voices/Portuguese/Thiago_pt_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..2e81ca3ba731ef659fc1e2c47410ee8420750355 --- /dev/null +++ b/default_voices/Portuguese/Thiago_pt_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b63efbc88127b88ad89740eed377a0f1600c4e2ae0deb030e574f8b7b9c6c667 +size 8848 diff --git a/default_voices/Portuguese/Thiago_pt_M_1.embedding.npy b/default_voices/Portuguese/Thiago_pt_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..78663a9f553cdcb5f40b317e2aa1d7653b37334d --- /dev/null +++ b/default_voices/Portuguese/Thiago_pt_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd1eee487091ef60636fe08cbafc15133c34a3f697629e1057e749c5b9893dc0 +size 896 diff --git a/default_voices/Portuguese/Thiago_pt_M_1.wav b/default_voices/Portuguese/Thiago_pt_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..b630f1e1b166fd5a31b8e902123f72055dbca947 --- /dev/null +++ b/default_voices/Portuguese/Thiago_pt_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2c02110a5f10765a9bf9c533a6cbf25bb39fca3bf23023f58b70a3a67fe89d2 +size 1281884 diff --git a/default_voices/README.md b/default_voices/README.md new file mode 100644 index 0000000000000000000000000000000000000000..78b590b33ecd7651c0cb404550b03fa75b772b8d --- /dev/null +++ b/default_voices/README.md @@ -0,0 +1,82 @@ +# Default voices + +Each clip ships with its reference codes (`.codes.npy`, int32 `[frames, 10]`) and speaker embedding +(`.embedding.npy`, float32 `[192]`), so servers use them without the encoders. Pass this folder as +`--tts-default-voices-dir`; the ids below are those of `GET /v2/speakers`. + +## English + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Cillian | Irish | male | `default_2c5123a959875341` | +| Imogen | British | female | `default_b78b28baf5c31a1d` | +| Jett | energetic | male | `default_c95cf57259ed7313` | +| Morgana | witch | female | `default_40a3ba1017bfb68a` | +| Rupert | British | male | `default_3765f0d1140c05c0` | +| Sakura | anime | female | `default_c5e098c322aae901` | +| Savannah | American | female | `default_de4d191ca7574982` | +| Thaddeus | announcer | male | `default_3c00e421e684f949` | +| Willow | ASMR | female | `default_940eaff39a929da0` | +| Wyatt | American | male | `default_34370fd91e3484ef` | + +## French + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Gaspard | — | male | `default_517319c805b927e9` | + +## German + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Liesel | — | female | `default_09d206a5b067ae71` | +| Wolfgang | — | male | `default_ec650ef042ed1f14` | + +## Hindi + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Ananya | — | female | `default_f76cf78a50cf8496` | +| Arjun | — | male | `default_849a62ace1f85759` | + +## Italian + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Ginevra | — | female | `default_792987ff6236e50d` | +| Lorenzo | — | male | `default_ccb71e6596453e72` | + +## Korean + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Minjun | — | male | `default_aa6e36b246dc01f9` | +| Seoyeon | — | female | `default_b7a257a5b1478493` | + +## Mandarin Chinese + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Haoran | energetic | male | `default_d8a9b688b64e638d` | +| Meilin | energetic | female | `default_eaee7325255d4783` | + +## Portuguese + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Leonor | — | female | `default_e11f53895cad62fa` | +| Thiago | — | male | `default_4562e98e005b69cc` | + +## Spanish + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Rodrigo | — | male | `default_87250baa043e5bba` | +| Ximena | — | female | `default_43e790fc116fd62a` | + +## Telugu + +| Voice | Style | Gender | Id | +|---|---|---|---| +| Chaitanya | — | male | `default_26fb443b7759bce0` | +| Sravya | — | female | `default_c3bb44b62cf13a5c` | diff --git a/default_voices/Spanish/Rodrigo_es_M_1.codes.npy b/default_voices/Spanish/Rodrigo_es_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..c6a017443005bd0eb9af7e9b39a3b1d7aa5f11d0 --- /dev/null +++ b/default_voices/Spanish/Rodrigo_es_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d6ff61ab49a2f3cfeb116afa80adcc33290cd5c7d7cb4c50181f4359c52b1c0 +size 6408 diff --git a/default_voices/Spanish/Rodrigo_es_M_1.embedding.npy b/default_voices/Spanish/Rodrigo_es_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..925b63ef08d127275695231cda09a4f00df77316 --- /dev/null +++ b/default_voices/Spanish/Rodrigo_es_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0305b7ab40d5d4a1df07ed7aa1c164f64ede1ac4b6250fa56383b4c3ae03e1e1 +size 896 diff --git a/default_voices/Spanish/Rodrigo_es_M_1.wav b/default_voices/Spanish/Rodrigo_es_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..a32099d399427861f6b88d0eb87f1122cafb88b3 --- /dev/null +++ b/default_voices/Spanish/Rodrigo_es_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2559c50978b50ad660b82528558047a684b1ff6d3c91dd59691a3c0c13c4eaf5 +size 923204 diff --git a/default_voices/Spanish/Ximena_es_F_1.codes.npy b/default_voices/Spanish/Ximena_es_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..2a26e00300eea6da608c1692ca081b2723c0359d --- /dev/null +++ b/default_voices/Spanish/Ximena_es_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b571c52d7543867bb2299e0626cea9d6f6c6c9a3bffabc85570baf08897dafb9 +size 7968 diff --git a/default_voices/Spanish/Ximena_es_F_1.embedding.npy b/default_voices/Spanish/Ximena_es_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..c7098dcd92def5a8902ab4c3a69ca2a8e8d8ea2f --- /dev/null +++ b/default_voices/Spanish/Ximena_es_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9cc1284c52003705619b37f2c25c59e170d2c70650af39e5692b2fe91782bd6 +size 896 diff --git a/default_voices/Spanish/Ximena_es_F_1.wav b/default_voices/Spanish/Ximena_es_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..cb5d7ff4ece58bf7bde05208ee5dceff38db0c74 --- /dev/null +++ b/default_voices/Spanish/Ximena_es_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b029ff5ef03907d401d92d9fe037d14ea6eb363c0d4e78512fc13c7b6eedfc0 +size 1152524 diff --git a/default_voices/Telugu/Chaitanya_te_M_1.codes.npy b/default_voices/Telugu/Chaitanya_te_M_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..17a12ece83fcc04a35371862f8178c6fdf0999d8 --- /dev/null +++ b/default_voices/Telugu/Chaitanya_te_M_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7003a4812a759171470f3187955e1b5c27f37bd449eb4bc012d7ac8620d0e9f7 +size 6368 diff --git a/default_voices/Telugu/Chaitanya_te_M_1.embedding.npy b/default_voices/Telugu/Chaitanya_te_M_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..85c6a5bfda9ee412c99285415d0cbf9068856c84 --- /dev/null +++ b/default_voices/Telugu/Chaitanya_te_M_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca818012cf5656d12eb3bccdfad4086831a6a892f8e7bf2277ca11bf921e5eb7 +size 896 diff --git a/default_voices/Telugu/Chaitanya_te_M_1.wav b/default_voices/Telugu/Chaitanya_te_M_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..9b8796a9cc77710265a623305e5ad3c4251628a1 --- /dev/null +++ b/default_voices/Telugu/Chaitanya_te_M_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:327c73a145533f1cb874736e9194048a22a43a10e74c7b9b8c354306068c54b0 +size 917324 diff --git a/default_voices/Telugu/Sravya_te_F_1.codes.npy b/default_voices/Telugu/Sravya_te_F_1.codes.npy new file mode 100644 index 0000000000000000000000000000000000000000..a9118e45d06cf6355789322625a6fa95c825e689 --- /dev/null +++ b/default_voices/Telugu/Sravya_te_F_1.codes.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e938016bb413c48bb5deb0bf80515f646bd5b7374f5bfb4d616a8ba3e254f373 +size 6928 diff --git a/default_voices/Telugu/Sravya_te_F_1.embedding.npy b/default_voices/Telugu/Sravya_te_F_1.embedding.npy new file mode 100644 index 0000000000000000000000000000000000000000..3d97b979df67c697d241511505cc6a580957f17e --- /dev/null +++ b/default_voices/Telugu/Sravya_te_F_1.embedding.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a62e330ccfe900dbc4caac3e57d661adf284da8c967072dbe91bab154df79c0f +size 896 diff --git a/default_voices/Telugu/Sravya_te_F_1.wav b/default_voices/Telugu/Sravya_te_F_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..d6dca208add9b9c3a1b6b8e00a6b815380f8a1fa --- /dev/null +++ b/default_voices/Telugu/Sravya_te_F_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:931ba97b7fd35bd808d32e4bf082c07da1fe7a813e469336d6eeeac83e7a42a8 +size 999644 diff --git a/studio/assets/chrome-CQ3XA7_n.js b/studio/assets/chrome-CvZYAiOI.js similarity index 96% rename from studio/assets/chrome-CQ3XA7_n.js rename to studio/assets/chrome-CvZYAiOI.js index c30098f49d6a819e6cc8ad9522f5096dcb1fc710..ff66c248bab5c53902a96c74d6bd33309d3d2690 100644 --- a/studio/assets/chrome-CQ3XA7_n.js +++ b/studio/assets/chrome-CvZYAiOI.js @@ -1 +1 @@ -import{c as e,d as t,f as n,l as r,p as i,u as a}from"./web-engine-DLmQsyPj.js";var o=`http://www.w3.org/2000/svg`;function s(e,t,n,r,i,a=!1){let s=document.createElementNS(o,`svg`);s.setAttribute(`class`,e),s.setAttribute(`viewBox`,t),r!==null&&s.setAttribute(`width`,String(r)),s.setAttribute(`height`,String(i)),s.setAttribute(`aria-hidden`,`true`);for(let e of n){let t=document.createElementNS(o,`path`);t.setAttribute(`d`,e),a?(t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`1.8`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`)):t.setAttribute(`fill`,`currentColor`),s.append(t)}return s}function c(t,n,i=t.dataset.icon,a=16){t.replaceChildren(...i?[s(`icon`,`0 0 24 24`,[r[i]],a,a,!e[i])]:[],n)}function l(e){document.querySelector(`.brand`).prepend(s(`z-mark`,t,a,22,3608/224),s(`z-word`,i,n,null,11));for(let e of document.querySelectorAll(`[data-icon]`))c(e,e.textContent.trim());let r=document.getElementById(`theme`),o=()=>{let e=document.documentElement.dataset.theme===`light`;c(r,``,e?`moon`:`sun`),r.title=e?`Dark theme`:`Light theme`,r.setAttribute(`aria-label`,e?`Switch to the dark theme`:`Switch to the light theme`)};r.addEventListener(`click`,()=>{let t=document.documentElement.dataset.theme!==`light`;t?document.documentElement.dataset.theme=`light`:delete document.documentElement.dataset.theme,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,t?`#f5f3ee`:`#0a0a0a`);try{localStorage.setItem(`zvs.theme`,JSON.stringify(t?`light`:`dark`))}catch{}o(),e?.()}),o()}export{c as n,l as t}; \ No newline at end of file +import{c as e,d as t,f as n,l as r,p as i,u as a}from"./web-engine-BJErJyzx.js";var o=`http://www.w3.org/2000/svg`;function s(e,t,n,r,i,a=!1){let s=document.createElementNS(o,`svg`);s.setAttribute(`class`,e),s.setAttribute(`viewBox`,t),r!==null&&s.setAttribute(`width`,String(r)),s.setAttribute(`height`,String(i)),s.setAttribute(`aria-hidden`,`true`);for(let e of n){let t=document.createElementNS(o,`path`);t.setAttribute(`d`,e),a?(t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`1.8`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`)):t.setAttribute(`fill`,`currentColor`),s.append(t)}return s}function c(t,n,i=t.dataset.icon,a=16){t.replaceChildren(...i?[s(`icon`,`0 0 24 24`,[r[i]],a,a,!e[i])]:[],n)}function l(e){document.querySelector(`.brand`).prepend(s(`z-mark`,t,a,22,3608/224),s(`z-word`,i,n,null,11));for(let e of document.querySelectorAll(`[data-icon]`))c(e,e.textContent.trim());let r=document.getElementById(`theme`),o=()=>{let e=document.documentElement.dataset.theme===`light`;c(r,``,e?`moon`:`sun`),r.title=e?`Dark theme`:`Light theme`,r.setAttribute(`aria-label`,e?`Switch to the dark theme`:`Switch to the light theme`)};r.addEventListener(`click`,()=>{let t=document.documentElement.dataset.theme!==`light`;t?document.documentElement.dataset.theme=`light`:delete document.documentElement.dataset.theme,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,t?`#f5f3ee`:`#0a0a0a`);try{localStorage.setItem(`zvs.theme`,JSON.stringify(t?`light`:`dark`))}catch{}o(),e?.()}),o()}export{c as n,l as t}; \ No newline at end of file diff --git a/studio/assets/index-6Z58oLwF.js b/studio/assets/index-CqBOQLX2.js similarity index 89% rename from studio/assets/index-6Z58oLwF.js rename to studio/assets/index-CqBOQLX2.js index ac5041701e794c1b82dec5db135c79e6ce211dc9..1df32d7d0d765799a9a950246e8112028d80afdb 100644 --- a/studio/assets/index-6Z58oLwF.js +++ b/studio/assets/index-CqBOQLX2.js @@ -1 +1 @@ -import{o as e}from"./web-engine-DLmQsyPj.js";import{t}from"./chrome-CQ3XA7_n.js";if(t(),location.search)for(let e of document.querySelectorAll(`a[data-keep-query]`))e.search=location.search;async function n(){let t=document.getElementById(`server-line`),n=document.getElementById(`choice-lite`);t.textContent=`Checking for a server…`;let r=(new URLSearchParams(location.search).get(`server`)||``).replace(/\/+$/,``),i=r||location.origin,a=new AbortController,o=setTimeout(()=>a.abort(),3e3);try{let e=await fetch(`${r}/v2/capabilities`,{signal:a.signal,headers:{accept:`application/json`}});if(e.ok&&/json/.test(e.headers.get(`content-type`)??``)){t.textContent=await fetch(`${r}/v2/controls`,{signal:a.signal,headers:{accept:`application/json`}}).then(e=>e.ok,()=>!1)?`Server: ${i}`:`Server: ${i} · controls not applied`;return}}catch{}finally{clearTimeout(o)}await e()?t.textContent=`No server · Voice Studio and Voice Cloning run in this browser (≈1.9 GB download once)`:(t.textContent=`No server · Voice Studio opens with demo audio · Voice Cloning unavailable`,n.setAttribute(`aria-disabled`,`true`),n.setAttribute(`title`,`Needs a ZONOS server, or a browser with WebGPU and the in-browser engine`))}n(); \ No newline at end of file +import{o as e}from"./web-engine-BJErJyzx.js";import{t}from"./chrome-CvZYAiOI.js";if(t(),location.search)for(let e of document.querySelectorAll(`a[data-keep-query]`))e.search=location.search;async function n(){let t=document.getElementById(`server-line`),n=document.getElementById(`choice-lite`);t.textContent=`Checking for a server…`;let r=(new URLSearchParams(location.search).get(`server`)||``).replace(/\/+$/,``),i=r||location.origin,a=new AbortController,o=setTimeout(()=>a.abort(),3e3);try{let e=await fetch(`${r}/v2/capabilities`,{signal:a.signal,headers:{accept:`application/json`}});if(e.ok&&/json/.test(e.headers.get(`content-type`)??``)){t.textContent=await fetch(`${r}/v2/controls`,{signal:a.signal,headers:{accept:`application/json`}}).then(e=>e.ok,()=>!1)?`Server: ${i}`:`Server: ${i} · controls not applied`;return}}catch{}finally{clearTimeout(o)}await e()?t.textContent=`No server · Voice Studio and Voice Cloning run in this browser (≈1.9 GB download once)`:(t.textContent=`No server · Voice Studio opens with demo audio · Voice Cloning unavailable`,n.setAttribute(`aria-disabled`,`true`),n.setAttribute(`title`,`Needs a ZONOS server, or a browser with WebGPU and the in-browser engine`))}n(); \ No newline at end of file diff --git a/studio/assets/lite-BlIlrHSF.js b/studio/assets/lite-BJyQJ1Te.js similarity index 99% rename from studio/assets/lite-BlIlrHSF.js rename to studio/assets/lite-BJyQJ1Te.js index 4d3b56bc9b795e8fb5217ae3f18303109d1cfab7..0873ec0fa4204b9130acafbcf4c0bfa6e8188dec 100644 --- a/studio/assets/lite-BlIlrHSF.js +++ b/studio/assets/lite-BJyQJ1Te.js @@ -1 +1 @@ -import{a as e,i as t,n,o as r,r as i,t as a}from"./web-engine-DLmQsyPj.js";import{C as o,S as s,a as c,b as ee,c as l,f as te,g as ne,h as re,m as ie,n as ae,s as oe,t as se,x as ce}from"./latin-500-DPgjq1zP.js";import{n as u,t as le}from"./chrome-CQ3XA7_n.js";var d=44100,ue=new URLSearchParams(location.search),f=ue.get(`api`)||`auto`,p=(ue.get(`server`)||``).replace(/\/+$/,``);f===`web`&&n();var de=`zonos3.lite.session`,fe=(()=>{try{let e=sessionStorage.getItem(de);if(e)return e;let t=ie();return sessionStorage.setItem(de,t),t}catch{return ie()}})(),{client:m,headers:h,ok:g}=te({baseUrl:p,session:()=>fe,fetch:t}),_=()=>g(m.GET(`/v2/capabilities`));async function pe(e){return await i(e),{kind:`web`,caps:await _()}}async function me({download:e,confirmWeb:t}){if(f===`web`)return pe(e);try{return{kind:`live`,caps:await _()}}catch(n){if(f===`live`||n instanceof l&&n.status===403||!await r()||t&&!await t())throw n;return pe(e)}}var he=r,ge=async()=>(await g(m.GET(`/v2/speakers`))).speakers,_e=e=>g(m.POST(`/v2/speakers`,{body:e}));async function ve(e){let t=await g(m.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e}}}));return Float32Array.from(t.embedding)}async function ye(e){let n=await t(`${p}/v2/speakers/${encodeURIComponent(e)}/preview`,{headers:h()});if(!n.ok)throw await re(n);return n.blob()}async function be(e,n,r){let i=await t(`${p}/v2/generate`,{method:`POST`,headers:h({"Content-Type":`application/json`}),body:JSON.stringify(e),signal:r});if(!i.ok)throw await re(i);if(!i.body)throw new l(i.status,`The response has no body`);let a=i.headers.get(`X-Seed`);return await ne(i.body,n),{seed:a}}var xe=class{sampleRate;ctx=null;out=null;next=0;t0=NaN;pending=[];pendingLength=0;sources=new Set;constructor(e){this.sampleRate=e}async begin(){this.stop(),this.ctx??=new AudioContext,this.ctx.state!==`running`&&await this.ctx.resume(),this.out=this.ctx.createGain(),this.out.connect(this.ctx.destination),this.next=0,this.t0=NaN}push(e){this.pending.push(e),this.pendingLength+=e.length,this.pendingLength>=this.sampleRate/10&&this.flush()}flush(){let{ctx:e,out:t}=this;if(!e||!t||!this.pendingLength)return;let n=e.createBuffer(1,this.pendingLength,this.sampleRate),r=n.getChannelData(0),i=0;for(let e of this.pending)r.set(e,i),i+=e.length;this.pending=[],this.pendingLength=0;let a=e.createBufferSource();a.buffer=n,a.connect(t);let o=Math.max(this.next,e.currentTime+.05);a.start(o),Number.isNaN(this.t0)?this.t0=o:this.t0+=o-this.next,this.next=o+n.duration,this.sources.add(a),a.onended=()=>this.sources.delete(a)}async play(e,t){await this.begin();let n=Math.min(e.length-1,Math.max(0,Math.round(t*this.sampleRate)));this.push(e.subarray(n)),this.flush(),this.t0-=n/this.sampleRate}position(){return!this.ctx||!this.sources.size||Number.isNaN(this.t0)?null:Math.max(0,this.ctx.currentTime-this.t0)}stop(){for(let e of this.sources)e.stop();this.sources.clear(),this.out?.disconnect(),this.out=null,this.pending=[],this.pendingLength=0}};function v(e){switch(e.source){case`default`:return e.library;case`clip`:return e.clip?.speaker??null;case`embedding`:return e.fileVoice}}function y(e){return e.generating?{ok:!1,why:``}:e.text.trim()?v(e)?{ok:!0,cloneFirst:!1}:e.source===`clip`?e.clip?{ok:!0,cloneFirst:!0}:{ok:!1,why:`Record or upload a clip first`}:e.source===`embedding`?{ok:!1,why:`Open a voice file first`}:{ok:!1,why:`Pick a voice first`}:{ok:!1,why:`Type something to say`}}function Se(e,t){if(!e)return null;let n=e/t;return n<2?`Too short: record at least 2 s`:n>30?`Clip is ${Math.round(n)} s; use up to 30 s`:null}var b=e=>document.getElementById(e),x={backend:b(`backend`),backendNote:b(`backend-note`),studioLink:b(`studio-link`),notice:b(`notice`),download:b(`download`),consent:b(`consent`),consentYes:b(`consent-yes`),consentRetry:b(`consent-retry`),sections:document.querySelectorAll(`main section:not(#consent)`),sources:document.querySelectorAll(`input[name="source"]`),panels:{default:b(`panel-default`),clip:b(`panel-clip`),embedding:b(`panel-embedding`)},voiceSelect:b(`voice-select`),clipPick:b(`clip-pick`),clipPlay:b(`clip-play`),clipFile:b(`clip-file`),record:b(`record`),recordLevel:b(`record-level`),clipState:b(`clip-state`),clipLabel:b(`clip-label`),clipUpload:b(`clip-upload`),embeddingPick:b(`embedding-pick`),embeddingFile:b(`embedding-file`),embeddingState:b(`embedding-state`),embeddingLabel:b(`embedding-label`),embeddingUpload:b(`embedding-upload`),voiceError:b(`voice-error`),voice:b(`voice`),voiceLabel:b(`voice-label`),voiceMeta:b(`voice-meta`),preview:b(`preview`),downloadEmbedding:b(`download-embedding`),form:b(`generate-form`),text:b(`text`),language:b(`language`),seed:b(`seed`),generate:b(`generate`),stop:b(`stop`),status:b(`generate-status`),why:b(`generate-why`),seedUse:b(`seed-use`),error:b(`generate-error`),result:b(`result`),wave:b(`wave`),play:b(`play`),resultDownload:b(`result-download`),resultMeta:b(`result-meta`),takes:b(`takes`)};le(()=>{P=-1,I()});var S=[],C=null,w=`default`,T=null,E=null,D=null,O=new xe(d),k=new Audio,A=``,j=()=>({source:w,library:C,clip:T,fileVoice:E,text:x.text.value,generating:!!D}),M=new Float32Array(d*8),N=0,P=-1,F=0,Ce=x.wave.querySelector(`canvas`),we=x.wave.querySelector(`.wave-head`);function Te(e){if(N+e.length>M.length){let t=new Float32Array(Math.max(M.length*2,N+e.length));t.set(M.subarray(0,N)),M=t}M.set(e,N),N+=e.length}function Ee(){F=0,P!==N&&(se(Ce,M.subarray(0,N),x.wave.clientWidth,72,getComputedStyle(x.wave).color),P=N);let e=O.position(),t=e!==null&&e*44100{P=-1,I()}).observe(x.wave);var L=e=>e instanceof Error?e.message:String(e);function R(e,t){e.textContent=t??``,e.hidden=!t}var z=e=>`${(e/d).toFixed(1)} s`;function B(e){if(x.download.hidden=!e,!e)return;let t=Math.round(e.fraction*100);x.download.setAttribute(`aria-valuenow`,String(t)),x.download.setAttribute(`aria-valuetext`,`${e.label}: ${t}%, ${e.detail}`),x.download.setAttribute(`aria-label`,e.label),x.download.querySelector(`.dl-label`).textContent=e.label,x.download.querySelector(`.dl-pct`).textContent=`${t}%`,x.download.querySelector(`.dl-fill`).style.width=`${e.fraction*100}%`,x.download.querySelector(`.dl-detail`).textContent=e.detail}function De(e){R(x.notice,e),x.notice.classList.add(`bad`);for(let e of document.querySelectorAll(`main section:not(#consent) input, main section:not(#consent) button, main section:not(#consent) select, main section:not(#consent) textarea`))e.disabled=!0}function Oe(){x.voiceSelect.replaceChildren();let e=[[`Library`,S.filter(e=>e.scope==="default")],[`Your voices (this tab)`,S.filter(e=>e.scope===`session`)]];for(let[t,n]of e){if(!n.length)continue;let e=document.createElement(`optgroup`);e.label=t;for(let t of n)e.append(new Option(t.label,t.id,!1,t.id===C?.id));x.voiceSelect.append(e)}S.length||x.voiceSelect.append(new Option(`No voice can be used from an embedding`,``,!0,!0)),x.voiceSelect.disabled=!S.length}async function V(e){S=(await ge()).filter(e=>e.speaker_modes.includes(`embedding`)),e&&!S.some(t=>t.id===e.id)&&S.push(e),C=(e?.scope==="default"?e:null)??S.find(e=>e.id===C?.id)??S.find(e=>e.scope==="default")??S[0]??null,Oe(),H()}function H(){let e=v(j());if(k.pause(),x.voice.hidden=!e,e){w==="default"&&(x.voiceSelect.value=e.id),x.voiceLabel.textContent=e.label;let t=e.scope==="default"?`library voice`:`this tab`,n=e.source_type===`audio`?`from a clip`:`from a voice file`;x.voiceMeta.textContent=`(${t}, ${n})`,x.voiceMeta.title=e.embedding_dim?`${e.embedding_dim}-dimensional voice embedding`:``,x.preview.hidden=!e.has_preview,u(x.preview,`Play preview`,`play`)}Y()}function ke(e){w=e;for(let[t,n]of Object.entries(x.panels))n.hidden=t!==e;R(x.voiceError,null),H()}async function U(e,t,n){let r=e.textContent;e.disabled=!0,e.classList.add(`is-busy`),u(e,t),R(x.voiceError,null);try{await n()}catch(e){R(x.voiceError,L(e))}finally{u(e,r),e.classList.remove(`is-busy`),e.disabled=!1,B(null)}}var W=e=>e.replace(/\.[^.]+$/,``),G=``,K=new Audio;function q(e,t){T=e;let n=e?Se(e.samples,d):null,r=!!e&&e.samples>0&&e.samples<220500&&!n;x.clipState.textContent=n??(r?`${t} · under 5 s: a longer clip clones better`:t),x.clipState.classList.toggle(`is-warn`,r||!!n),n&&(T=null),x.clipUpload.disabled=!T||!!T.speaker,T&&!x.clipLabel.value.trim()&&(x.clipLabel.placeholder=W(T.name)),K.pause(),G&&URL.revokeObjectURL(G),G=e?URL.createObjectURL(e.blob):``,x.clipPlay.hidden=!e,u(x.clipPlay,`Play`,`play`),H()}x.clipPlay.addEventListener(`click`,()=>{if(!K.paused)return K.pause();K.src=G,K.play()}),K.addEventListener(`play`,()=>u(x.clipPlay,`Stop`,`stop`)),K.addEventListener(`pause`,()=>u(x.clipPlay,`Play`,`play`)),K.addEventListener(`ended`,()=>u(x.clipPlay,`Play`,`play`));async function Ae(e,t){try{let n=await new OfflineAudioContext(1,1,d).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(n.length);for(let e=0;et.style.width=`${Math.round(e*100)}%`);x.recordLevel.hidden=!1;let r=new MediaRecorder(e),i=[],a=performance.now(),o=()=>{let e=Math.floor((performance.now()-a)/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} / 0:30`},s=setInterval(()=>x.clipState.textContent=`Recording… ${o()}`,250),c=setTimeout(()=>J?.stop(),3e4);r.ondataavailable=e=>i.push(e.data),r.onstop=async()=>{clearInterval(s),clearTimeout(c),n.stop(),x.recordLevel.hidden=!0,e.getTracks().forEach(e=>e.stop()),J=null,x.record.classList.remove(`is-recording`),u(x.record,`Record`),x.record.setAttribute(`aria-pressed`,`false`);let t=await Ae(new Blob(i,{type:r.mimeType}),`recording`);x.clipFile.value=``,q({...t,speaker:null},`Recording ready${t.samples?` (${z(t.samples)})`:``}`)},J={stop:()=>r.state===`recording`&&r.stop()},r.start(),x.record.classList.add(`is-recording`),x.record.replaceChildren(Object.assign(document.createElement(`span`),{className:`rec-dot`}),`Stop recording`),x.record.setAttribute(`aria-pressed`,`true`),x.clipState.textContent=`Recording… 0:00 / 0:30`}function Y(){let e=y(j());x.generate.disabled=!e.ok,R(x.why,e.ok?null:e.why||null)}x.text.addEventListener(`input`,Y),x.text.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Ie())});var Ne=5,X=[];function Pe(){let e=X.slice(1);x.takes.hidden=!e.length,x.takes.replaceChildren(...e.map((e,t)=>{let n=document.createElement(`li`);n.className=`take-row`;let r=Object.assign(document.createElement(`button`),{type:`button`,className:`icon-btn sm`,title:`Play this take`});r.dataset.icon=`play`,u(r,``,`play`,14),r.setAttribute(`aria-label`,`Play take ${X.length-1-t}`),r.addEventListener(`click`,()=>{k.pause(),O.play(e.pcm,0).then(I)});let i=Object.assign(document.createElement(`span`),{className:`meta`,textContent:`${e.label} · ${z(e.pcm.length)} · ${e.text.length>48?`${e.text.slice(0,48)}…`:e.text}`});i.title=e.seed?`seed ${e.seed}`:``;let a=Object.assign(document.createElement(`a`),{className:`btn sm ghost`,href:e.url,download:`${o(e.label)}${e.seed?`-seed${e.seed}`:``}.wav`,textContent:`Download`});return n.append(r,i,a),n}))}function Fe(e,t,n,r){let i=URL.createObjectURL(new Blob([oe(e,d)],{type:`audio/wav`}));X.unshift({pcm:e,seed:t,text:n,url:i,label:r});for(let e of X.splice(Ne))URL.revokeObjectURL(e.url);return Pe(),i}async function Ie(){if(!y(j()).ok)return Y();let e=x.text.value.trim(),t=new AbortController;D=t,Y(),x.stop.hidden=!1,R(x.error,null),k.pause();let n=v(j());try{n||=(x.status.textContent=`Cloning the clip…`,await je())}catch(e){D=null,x.stop.hidden=!0,x.status.textContent=``,R(x.error,L(e)),Y();return}let r={text:e,language:x.language.value,speaker_mode:`embedding`,speaker_embedding_id:n.id,stream:!0,format:`pcm`};x.seed.value!==``&&(r.seed=Number(x.seed.value)),x.status.textContent=`Generating…`,N=0,P=-1,x.result.hidden=!1,x.wave.classList.add(`is-busy`),x.resultDownload.hidden=!0,x.resultMeta.textContent=``,I();let i=performance.now(),a=0;try{await O.begin();let{seed:s}=await be(r,e=>{a||=performance.now(),Te(e),O.push(e),x.status.textContent=`Playing while generating… ${z(N)}`},t.signal);if(O.flush(),!N)throw new l(200,`The server returned no audio.`);let c=Fe(M.slice(0,N),s,e,n.label);x.resultDownload.href=c,x.resultDownload.download=`${o(n.label)}${s?`-seed${s}`:``}.wav`,x.resultDownload.hidden=!1,x.resultMeta.textContent=z(N),x.resultMeta.title=`seed ${s??`unknown`} · first audio after ${((a-i)/1e3).toFixed(2)} s`,x.seedUse.hidden=s==null,x.result.dataset.samples=String(N),x.result.dataset.seed=s??``,x.status.textContent=`Done: ${z(N)} of audio.`}catch(e){O.stop(),t.signal.aborted?x.status.textContent=`Stopped.`:(x.status.textContent=``,R(x.error,L(e))),x.result.hidden=!N}finally{D=null,x.wave.classList.remove(`is-busy`),x.stop.hidden=!0,Y(),B(null),I()}}async function Z(e){N&&!D&&(k.pause(),await O.play(M.subarray(0,N),e*N/d),I())}function Le(){if(O.position()===null)return void Z(0);O.stop(),I()}x.play.addEventListener(`click`,Le),x.wave.addEventListener(`pointerdown`,e=>{let t=x.wave.getBoundingClientRect();Z(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}),x.wave.addEventListener(`keydown`,e=>{if(N){if(e.key===` `)e.preventDefault(),Le();else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=N/d;Z(Math.max(0,Math.min(t,(O.position()??0)+(e.key===`ArrowLeft`?-1:1)))/t)}}});for(let e of x.sources)e.addEventListener(`change`,()=>e.checked&&ke(e.value));x.voiceSelect.addEventListener(`change`,()=>{C=S.find(e=>e.id===x.voiceSelect.value)??null,H()}),x.clipPick.addEventListener(`click`,()=>x.clipFile.click()),x.clipFile.addEventListener(`change`,async()=>{let e=x.clipFile.files?.[0];if(!e)return q(null,``);x.clipState.textContent=`Reading…`;let t=await Ae(e,e.name);q({...t,speaker:null},`${e.name}${t.samples?` (${z(t.samples)})`:``}`)}),x.record.addEventListener(`click`,()=>void Me()),x.clipUpload.addEventListener(`click`,()=>U(x.clipUpload,`Cloning…`,async()=>{await je(),x.clipLabel.value=``})),x.embeddingPick.addEventListener(`click`,()=>x.embeddingFile.click());var Re=2e6;x.embeddingFile.addEventListener(`change`,()=>{let e=x.embeddingFile.files?.[0];R(x.voiceError,null);let t=e&&(!/\.np[yz]$/i.test(e.name)||e.size>Re)?`Couldn’t read this voice file: it must be a .npy or .npz under 2 MB`:null;t&&(x.embeddingFile.value=``,R(x.voiceError,t));let n=e&&!t;x.embeddingUpload.disabled=!n,x.embeddingState.textContent=n?e.name:``,n&&(x.embeddingLabel.placeholder=W(e.name))}),x.embeddingUpload.addEventListener(`click`,()=>U(x.embeddingUpload,`Opening…`,async()=>{let e=x.embeddingFile.files?.[0];if(!e)return;let t;try{t=await _e({label:x.embeddingLabel.value.trim()||W(e.name),speaker_embedding_base64:ee(await e.arrayBuffer()),speaker_embedding_name:e.name})}catch(e){throw e instanceof l&&e.status===400?Error(`Couldn’t read this voice file: ${e.detail}`):e}E=t,await V(t),x.embeddingFile.value=``,x.embeddingLabel.value=``,x.embeddingState.textContent=`Opened “${t.label}”`,x.embeddingUpload.disabled=!0})),x.preview.addEventListener(`click`,()=>{let e=v(j());if(!e)return;if(!k.paused)return k.pause();let t=e.id;U(x.preview,`Loading…`,async()=>{k.dataset.id!==t&&(A&&URL.revokeObjectURL(A),A=URL.createObjectURL(await ye(t)),k.src=A,k.dataset.id=t),await k.play()}).then(()=>k.paused||Q(!0))});function Q(e){u(x.preview,e?`Stop preview`:`Play preview`,e?`stop`:`play`),x.preview.classList.toggle(`is-playing`,e)}k.addEventListener(`play`,()=>Q(!0)),k.addEventListener(`pause`,()=>Q(!1)),x.downloadEmbedding.addEventListener(`click`,()=>{let e=v(j());e&&U(x.downloadEmbedding,`Downloading…`,async()=>{ce(s(await ve(e.id)),`${o(e.label)}.npy`,`application/octet-stream`)})}),x.form.addEventListener(`submit`,e=>{e.preventDefault(),Ie()}),x.stop.addEventListener(`click`,()=>{D?.abort(),O.stop()}),x.seedUse.addEventListener(`click`,()=>{x.seed.value=x.result.dataset.seed??``,x.seed.closest(`details`)?.setAttribute(`open`,``),x.seed.focus()});function $(e){R(x.notice,e?`Connecting…`:null),e||B(null);for(let t of x.sections)t.inert=e}function ze(){R(x.notice,null),x.consent.hidden=!1,x.consentYes.focus();let{promise:e,resolve:t}=Promise.withResolvers();return x.consentYes.addEventListener(`click`,()=>t(!0),{once:!0}),x.consentRetry.addEventListener(`click`,()=>location.reload(),{once:!0}),e.finally(()=>{x.consent.hidden=!0,R(x.notice,`Starting the in-browser engine…`)})}async function Be(t){$(!1);let r=e();De(r?`The in-browser engine couldn’t start: ${L(t)}`:`Can’t reach the server at ${p||location.origin}: ${L(t)}`);let i=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm`,textContent:`Try again`});if(i.addEventListener(`click`,()=>location.reload()),x.notice.append(` `,i),!r&&await he()){let e=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm primary`,textContent:`Run in this browser`});e.addEventListener(`click`,()=>{n();let e=new URL(location.href);e.searchParams.set(`api`,`web`),location.href=e.toString()}),x.notice.append(` `,e)}}async function Ve(){p&&(x.studioLink.search=`?server=${encodeURIComponent(p)}`),Y(),$(!0);let e;try{e=await me({download:e=>{R(x.notice,null),B(e)},confirmWeb:ze})}catch(e){await Be(e);return}$(!1);let{kind:t,caps:n}=e;x.backend.hidden=!1,x.backend.querySelector(`.pill-text`).textContent=t===`web`?`In this browser`:`Server`;let r=t===`web`?`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`:`Connected to ${p||location.origin}: that server renders every voice.`;if(x.backend.title=r,x.backend.classList.add(`pill-${t}`),x.backend.addEventListener(`click`,()=>{let e=x.backendNote.hidden;R(x.backendNote,e?r:null),x.backend.setAttribute(`aria-expanded`,String(e))}),t===`web`&&(x.studioLink.search=p?`?api=web&server=${encodeURIComponent(p)}`:`?api=web`,a(e=>B(e.fraction>=1?null:e))),!n.speaker_modes.includes(`embedding`))return De(`This server can’t clone from a voice file: its model has no voice-embedding input.`);let i=n.text_norm_languages.length?n.text_norm_languages:[`en_us`];for(let e of i)x.language.append(new Option(c(e),e,!1,e===`en_us`));n.speaker_audio_upload||(x.clipUpload.disabled=!0,x.clipState.textContent=`This server doesn’t take clip uploads.`,x.clipFile.disabled=x.clipPick.disabled=x.record.disabled=!0),typeof MediaRecorder<`u`&&navigator.mediaDevices?.getUserMedia||(x.record.hidden=!0);try{await V()}catch(e){R(x.voiceError,`Couldn’t list voices: ${L(e)}`)}}Ve(); \ No newline at end of file +import{a as e,i as t,n,o as r,r as i,t as a}from"./web-engine-BJErJyzx.js";import{C as o,S as s,a as c,b as ee,c as l,f as te,g as ne,h as re,m as ie,n as ae,s as oe,t as se,x as ce}from"./latin-500-DPgjq1zP.js";import{n as u,t as le}from"./chrome-CvZYAiOI.js";var d=44100,ue=new URLSearchParams(location.search),f=ue.get(`api`)||`auto`,p=(ue.get(`server`)||``).replace(/\/+$/,``);f===`web`&&n();var de=`zonos3.lite.session`,fe=(()=>{try{let e=sessionStorage.getItem(de);if(e)return e;let t=ie();return sessionStorage.setItem(de,t),t}catch{return ie()}})(),{client:m,headers:h,ok:g}=te({baseUrl:p,session:()=>fe,fetch:t}),_=()=>g(m.GET(`/v2/capabilities`));async function pe(e){return await i(e),{kind:`web`,caps:await _()}}async function me({download:e,confirmWeb:t}){if(f===`web`)return pe(e);try{return{kind:`live`,caps:await _()}}catch(n){if(f===`live`||n instanceof l&&n.status===403||!await r()||t&&!await t())throw n;return pe(e)}}var he=r,ge=async()=>(await g(m.GET(`/v2/speakers`))).speakers,_e=e=>g(m.POST(`/v2/speakers`,{body:e}));async function ve(e){let t=await g(m.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e}}}));return Float32Array.from(t.embedding)}async function ye(e){let n=await t(`${p}/v2/speakers/${encodeURIComponent(e)}/preview`,{headers:h()});if(!n.ok)throw await re(n);return n.blob()}async function be(e,n,r){let i=await t(`${p}/v2/generate`,{method:`POST`,headers:h({"Content-Type":`application/json`}),body:JSON.stringify(e),signal:r});if(!i.ok)throw await re(i);if(!i.body)throw new l(i.status,`The response has no body`);let a=i.headers.get(`X-Seed`);return await ne(i.body,n),{seed:a}}var xe=class{sampleRate;ctx=null;out=null;next=0;t0=NaN;pending=[];pendingLength=0;sources=new Set;constructor(e){this.sampleRate=e}async begin(){this.stop(),this.ctx??=new AudioContext,this.ctx.state!==`running`&&await this.ctx.resume(),this.out=this.ctx.createGain(),this.out.connect(this.ctx.destination),this.next=0,this.t0=NaN}push(e){this.pending.push(e),this.pendingLength+=e.length,this.pendingLength>=this.sampleRate/10&&this.flush()}flush(){let{ctx:e,out:t}=this;if(!e||!t||!this.pendingLength)return;let n=e.createBuffer(1,this.pendingLength,this.sampleRate),r=n.getChannelData(0),i=0;for(let e of this.pending)r.set(e,i),i+=e.length;this.pending=[],this.pendingLength=0;let a=e.createBufferSource();a.buffer=n,a.connect(t);let o=Math.max(this.next,e.currentTime+.05);a.start(o),Number.isNaN(this.t0)?this.t0=o:this.t0+=o-this.next,this.next=o+n.duration,this.sources.add(a),a.onended=()=>this.sources.delete(a)}async play(e,t){await this.begin();let n=Math.min(e.length-1,Math.max(0,Math.round(t*this.sampleRate)));this.push(e.subarray(n)),this.flush(),this.t0-=n/this.sampleRate}position(){return!this.ctx||!this.sources.size||Number.isNaN(this.t0)?null:Math.max(0,this.ctx.currentTime-this.t0)}stop(){for(let e of this.sources)e.stop();this.sources.clear(),this.out?.disconnect(),this.out=null,this.pending=[],this.pendingLength=0}};function v(e){switch(e.source){case`default`:return e.library;case`clip`:return e.clip?.speaker??null;case`embedding`:return e.fileVoice}}function y(e){return e.generating?{ok:!1,why:``}:e.text.trim()?v(e)?{ok:!0,cloneFirst:!1}:e.source===`clip`?e.clip?{ok:!0,cloneFirst:!0}:{ok:!1,why:`Record or upload a clip first`}:e.source===`embedding`?{ok:!1,why:`Open a voice file first`}:{ok:!1,why:`Pick a voice first`}:{ok:!1,why:`Type something to say`}}function Se(e,t){if(!e)return null;let n=e/t;return n<2?`Too short: record at least 2 s`:n>30?`Clip is ${Math.round(n)} s; use up to 30 s`:null}var b=e=>document.getElementById(e),x={backend:b(`backend`),backendNote:b(`backend-note`),studioLink:b(`studio-link`),notice:b(`notice`),download:b(`download`),consent:b(`consent`),consentYes:b(`consent-yes`),consentRetry:b(`consent-retry`),sections:document.querySelectorAll(`main section:not(#consent)`),sources:document.querySelectorAll(`input[name="source"]`),panels:{default:b(`panel-default`),clip:b(`panel-clip`),embedding:b(`panel-embedding`)},voiceSelect:b(`voice-select`),clipPick:b(`clip-pick`),clipPlay:b(`clip-play`),clipFile:b(`clip-file`),record:b(`record`),recordLevel:b(`record-level`),clipState:b(`clip-state`),clipLabel:b(`clip-label`),clipUpload:b(`clip-upload`),embeddingPick:b(`embedding-pick`),embeddingFile:b(`embedding-file`),embeddingState:b(`embedding-state`),embeddingLabel:b(`embedding-label`),embeddingUpload:b(`embedding-upload`),voiceError:b(`voice-error`),voice:b(`voice`),voiceLabel:b(`voice-label`),voiceMeta:b(`voice-meta`),preview:b(`preview`),downloadEmbedding:b(`download-embedding`),form:b(`generate-form`),text:b(`text`),language:b(`language`),seed:b(`seed`),generate:b(`generate`),stop:b(`stop`),status:b(`generate-status`),why:b(`generate-why`),seedUse:b(`seed-use`),error:b(`generate-error`),result:b(`result`),wave:b(`wave`),play:b(`play`),resultDownload:b(`result-download`),resultMeta:b(`result-meta`),takes:b(`takes`)};le(()=>{P=-1,I()});var S=[],C=null,w=`default`,T=null,E=null,D=null,O=new xe(d),k=new Audio,A=``,j=()=>({source:w,library:C,clip:T,fileVoice:E,text:x.text.value,generating:!!D}),M=new Float32Array(d*8),N=0,P=-1,F=0,Ce=x.wave.querySelector(`canvas`),we=x.wave.querySelector(`.wave-head`);function Te(e){if(N+e.length>M.length){let t=new Float32Array(Math.max(M.length*2,N+e.length));t.set(M.subarray(0,N)),M=t}M.set(e,N),N+=e.length}function Ee(){F=0,P!==N&&(se(Ce,M.subarray(0,N),x.wave.clientWidth,72,getComputedStyle(x.wave).color),P=N);let e=O.position(),t=e!==null&&e*44100{P=-1,I()}).observe(x.wave);var L=e=>e instanceof Error?e.message:String(e);function R(e,t){e.textContent=t??``,e.hidden=!t}var z=e=>`${(e/d).toFixed(1)} s`;function B(e){if(x.download.hidden=!e,!e)return;let t=Math.round(e.fraction*100);x.download.setAttribute(`aria-valuenow`,String(t)),x.download.setAttribute(`aria-valuetext`,`${e.label}: ${t}%, ${e.detail}`),x.download.setAttribute(`aria-label`,e.label),x.download.querySelector(`.dl-label`).textContent=e.label,x.download.querySelector(`.dl-pct`).textContent=`${t}%`,x.download.querySelector(`.dl-fill`).style.width=`${e.fraction*100}%`,x.download.querySelector(`.dl-detail`).textContent=e.detail}function De(e){R(x.notice,e),x.notice.classList.add(`bad`);for(let e of document.querySelectorAll(`main section:not(#consent) input, main section:not(#consent) button, main section:not(#consent) select, main section:not(#consent) textarea`))e.disabled=!0}function Oe(){x.voiceSelect.replaceChildren();let e=[[`Library`,S.filter(e=>e.scope==="default")],[`Your voices (this tab)`,S.filter(e=>e.scope===`session`)]];for(let[t,n]of e){if(!n.length)continue;let e=document.createElement(`optgroup`);e.label=t;for(let t of n)e.append(new Option(t.label,t.id,!1,t.id===C?.id));x.voiceSelect.append(e)}S.length||x.voiceSelect.append(new Option(`No voice can be used from an embedding`,``,!0,!0)),x.voiceSelect.disabled=!S.length}async function V(e){S=(await ge()).filter(e=>e.speaker_modes.includes(`embedding`)),e&&!S.some(t=>t.id===e.id)&&S.push(e),C=(e?.scope==="default"?e:null)??S.find(e=>e.id===C?.id)??S.find(e=>e.scope==="default")??S[0]??null,Oe(),H()}function H(){let e=v(j());if(k.pause(),x.voice.hidden=!e,e){w==="default"&&(x.voiceSelect.value=e.id),x.voiceLabel.textContent=e.label;let t=e.scope==="default"?`library voice`:`this tab`,n=e.source_type===`audio`?`from a clip`:`from a voice file`;x.voiceMeta.textContent=`(${t}, ${n})`,x.voiceMeta.title=e.embedding_dim?`${e.embedding_dim}-dimensional voice embedding`:``,x.preview.hidden=!e.has_preview,u(x.preview,`Play preview`,`play`)}Y()}function ke(e){w=e;for(let[t,n]of Object.entries(x.panels))n.hidden=t!==e;R(x.voiceError,null),H()}async function U(e,t,n){let r=e.textContent;e.disabled=!0,e.classList.add(`is-busy`),u(e,t),R(x.voiceError,null);try{await n()}catch(e){R(x.voiceError,L(e))}finally{u(e,r),e.classList.remove(`is-busy`),e.disabled=!1,B(null)}}var W=e=>e.replace(/\.[^.]+$/,``),G=``,K=new Audio;function q(e,t){T=e;let n=e?Se(e.samples,d):null,r=!!e&&e.samples>0&&e.samples<220500&&!n;x.clipState.textContent=n??(r?`${t} · under 5 s: a longer clip clones better`:t),x.clipState.classList.toggle(`is-warn`,r||!!n),n&&(T=null),x.clipUpload.disabled=!T||!!T.speaker,T&&!x.clipLabel.value.trim()&&(x.clipLabel.placeholder=W(T.name)),K.pause(),G&&URL.revokeObjectURL(G),G=e?URL.createObjectURL(e.blob):``,x.clipPlay.hidden=!e,u(x.clipPlay,`Play`,`play`),H()}x.clipPlay.addEventListener(`click`,()=>{if(!K.paused)return K.pause();K.src=G,K.play()}),K.addEventListener(`play`,()=>u(x.clipPlay,`Stop`,`stop`)),K.addEventListener(`pause`,()=>u(x.clipPlay,`Play`,`play`)),K.addEventListener(`ended`,()=>u(x.clipPlay,`Play`,`play`));async function Ae(e,t){try{let n=await new OfflineAudioContext(1,1,d).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(n.length);for(let e=0;et.style.width=`${Math.round(e*100)}%`);x.recordLevel.hidden=!1;let r=new MediaRecorder(e),i=[],a=performance.now(),o=()=>{let e=Math.floor((performance.now()-a)/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} / 0:30`},s=setInterval(()=>x.clipState.textContent=`Recording… ${o()}`,250),c=setTimeout(()=>J?.stop(),3e4);r.ondataavailable=e=>i.push(e.data),r.onstop=async()=>{clearInterval(s),clearTimeout(c),n.stop(),x.recordLevel.hidden=!0,e.getTracks().forEach(e=>e.stop()),J=null,x.record.classList.remove(`is-recording`),u(x.record,`Record`),x.record.setAttribute(`aria-pressed`,`false`);let t=await Ae(new Blob(i,{type:r.mimeType}),`recording`);x.clipFile.value=``,q({...t,speaker:null},`Recording ready${t.samples?` (${z(t.samples)})`:``}`)},J={stop:()=>r.state===`recording`&&r.stop()},r.start(),x.record.classList.add(`is-recording`),x.record.replaceChildren(Object.assign(document.createElement(`span`),{className:`rec-dot`}),`Stop recording`),x.record.setAttribute(`aria-pressed`,`true`),x.clipState.textContent=`Recording… 0:00 / 0:30`}function Y(){let e=y(j());x.generate.disabled=!e.ok,R(x.why,e.ok?null:e.why||null)}x.text.addEventListener(`input`,Y),x.text.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Ie())});var Ne=5,X=[];function Pe(){let e=X.slice(1);x.takes.hidden=!e.length,x.takes.replaceChildren(...e.map((e,t)=>{let n=document.createElement(`li`);n.className=`take-row`;let r=Object.assign(document.createElement(`button`),{type:`button`,className:`icon-btn sm`,title:`Play this take`});r.dataset.icon=`play`,u(r,``,`play`,14),r.setAttribute(`aria-label`,`Play take ${X.length-1-t}`),r.addEventListener(`click`,()=>{k.pause(),O.play(e.pcm,0).then(I)});let i=Object.assign(document.createElement(`span`),{className:`meta`,textContent:`${e.label} · ${z(e.pcm.length)} · ${e.text.length>48?`${e.text.slice(0,48)}…`:e.text}`});i.title=e.seed?`seed ${e.seed}`:``;let a=Object.assign(document.createElement(`a`),{className:`btn sm ghost`,href:e.url,download:`${o(e.label)}${e.seed?`-seed${e.seed}`:``}.wav`,textContent:`Download`});return n.append(r,i,a),n}))}function Fe(e,t,n,r){let i=URL.createObjectURL(new Blob([oe(e,d)],{type:`audio/wav`}));X.unshift({pcm:e,seed:t,text:n,url:i,label:r});for(let e of X.splice(Ne))URL.revokeObjectURL(e.url);return Pe(),i}async function Ie(){if(!y(j()).ok)return Y();let e=x.text.value.trim(),t=new AbortController;D=t,Y(),x.stop.hidden=!1,R(x.error,null),k.pause();let n=v(j());try{n||=(x.status.textContent=`Cloning the clip…`,await je())}catch(e){D=null,x.stop.hidden=!0,x.status.textContent=``,R(x.error,L(e)),Y();return}let r={text:e,language:x.language.value,speaker_mode:`embedding`,speaker_embedding_id:n.id,stream:!0,format:`pcm`};x.seed.value!==``&&(r.seed=Number(x.seed.value)),x.status.textContent=`Generating…`,N=0,P=-1,x.result.hidden=!1,x.wave.classList.add(`is-busy`),x.resultDownload.hidden=!0,x.resultMeta.textContent=``,I();let i=performance.now(),a=0;try{await O.begin();let{seed:s}=await be(r,e=>{a||=performance.now(),Te(e),O.push(e),x.status.textContent=`Playing while generating… ${z(N)}`},t.signal);if(O.flush(),!N)throw new l(200,`The server returned no audio.`);let c=Fe(M.slice(0,N),s,e,n.label);x.resultDownload.href=c,x.resultDownload.download=`${o(n.label)}${s?`-seed${s}`:``}.wav`,x.resultDownload.hidden=!1,x.resultMeta.textContent=z(N),x.resultMeta.title=`seed ${s??`unknown`} · first audio after ${((a-i)/1e3).toFixed(2)} s`,x.seedUse.hidden=s==null,x.result.dataset.samples=String(N),x.result.dataset.seed=s??``,x.status.textContent=`Done: ${z(N)} of audio.`}catch(e){O.stop(),t.signal.aborted?x.status.textContent=`Stopped.`:(x.status.textContent=``,R(x.error,L(e))),x.result.hidden=!N}finally{D=null,x.wave.classList.remove(`is-busy`),x.stop.hidden=!0,Y(),B(null),I()}}async function Z(e){N&&!D&&(k.pause(),await O.play(M.subarray(0,N),e*N/d),I())}function Le(){if(O.position()===null)return void Z(0);O.stop(),I()}x.play.addEventListener(`click`,Le),x.wave.addEventListener(`pointerdown`,e=>{let t=x.wave.getBoundingClientRect();Z(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}),x.wave.addEventListener(`keydown`,e=>{if(N){if(e.key===` `)e.preventDefault(),Le();else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=N/d;Z(Math.max(0,Math.min(t,(O.position()??0)+(e.key===`ArrowLeft`?-1:1)))/t)}}});for(let e of x.sources)e.addEventListener(`change`,()=>e.checked&&ke(e.value));x.voiceSelect.addEventListener(`change`,()=>{C=S.find(e=>e.id===x.voiceSelect.value)??null,H()}),x.clipPick.addEventListener(`click`,()=>x.clipFile.click()),x.clipFile.addEventListener(`change`,async()=>{let e=x.clipFile.files?.[0];if(!e)return q(null,``);x.clipState.textContent=`Reading…`;let t=await Ae(e,e.name);q({...t,speaker:null},`${e.name}${t.samples?` (${z(t.samples)})`:``}`)}),x.record.addEventListener(`click`,()=>void Me()),x.clipUpload.addEventListener(`click`,()=>U(x.clipUpload,`Cloning…`,async()=>{await je(),x.clipLabel.value=``})),x.embeddingPick.addEventListener(`click`,()=>x.embeddingFile.click());var Re=2e6;x.embeddingFile.addEventListener(`change`,()=>{let e=x.embeddingFile.files?.[0];R(x.voiceError,null);let t=e&&(!/\.np[yz]$/i.test(e.name)||e.size>Re)?`Couldn’t read this voice file: it must be a .npy or .npz under 2 MB`:null;t&&(x.embeddingFile.value=``,R(x.voiceError,t));let n=e&&!t;x.embeddingUpload.disabled=!n,x.embeddingState.textContent=n?e.name:``,n&&(x.embeddingLabel.placeholder=W(e.name))}),x.embeddingUpload.addEventListener(`click`,()=>U(x.embeddingUpload,`Opening…`,async()=>{let e=x.embeddingFile.files?.[0];if(!e)return;let t;try{t=await _e({label:x.embeddingLabel.value.trim()||W(e.name),speaker_embedding_base64:ee(await e.arrayBuffer()),speaker_embedding_name:e.name})}catch(e){throw e instanceof l&&e.status===400?Error(`Couldn’t read this voice file: ${e.detail}`):e}E=t,await V(t),x.embeddingFile.value=``,x.embeddingLabel.value=``,x.embeddingState.textContent=`Opened “${t.label}”`,x.embeddingUpload.disabled=!0})),x.preview.addEventListener(`click`,()=>{let e=v(j());if(!e)return;if(!k.paused)return k.pause();let t=e.id;U(x.preview,`Loading…`,async()=>{k.dataset.id!==t&&(A&&URL.revokeObjectURL(A),A=URL.createObjectURL(await ye(t)),k.src=A,k.dataset.id=t),await k.play()}).then(()=>k.paused||Q(!0))});function Q(e){u(x.preview,e?`Stop preview`:`Play preview`,e?`stop`:`play`),x.preview.classList.toggle(`is-playing`,e)}k.addEventListener(`play`,()=>Q(!0)),k.addEventListener(`pause`,()=>Q(!1)),x.downloadEmbedding.addEventListener(`click`,()=>{let e=v(j());e&&U(x.downloadEmbedding,`Downloading…`,async()=>{ce(s(await ve(e.id)),`${o(e.label)}.npy`,`application/octet-stream`)})}),x.form.addEventListener(`submit`,e=>{e.preventDefault(),Ie()}),x.stop.addEventListener(`click`,()=>{D?.abort(),O.stop()}),x.seedUse.addEventListener(`click`,()=>{x.seed.value=x.result.dataset.seed??``,x.seed.closest(`details`)?.setAttribute(`open`,``),x.seed.focus()});function $(e){R(x.notice,e?`Connecting…`:null),e||B(null);for(let t of x.sections)t.inert=e}function ze(){R(x.notice,null),x.consent.hidden=!1,x.consentYes.focus();let{promise:e,resolve:t}=Promise.withResolvers();return x.consentYes.addEventListener(`click`,()=>t(!0),{once:!0}),x.consentRetry.addEventListener(`click`,()=>location.reload(),{once:!0}),e.finally(()=>{x.consent.hidden=!0,R(x.notice,`Starting the in-browser engine…`)})}async function Be(t){$(!1);let r=e();De(r?`The in-browser engine couldn’t start: ${L(t)}`:`Can’t reach the server at ${p||location.origin}: ${L(t)}`);let i=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm`,textContent:`Try again`});if(i.addEventListener(`click`,()=>location.reload()),x.notice.append(` `,i),!r&&await he()){let e=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm primary`,textContent:`Run in this browser`});e.addEventListener(`click`,()=>{n();let e=new URL(location.href);e.searchParams.set(`api`,`web`),location.href=e.toString()}),x.notice.append(` `,e)}}async function Ve(){p&&(x.studioLink.search=`?server=${encodeURIComponent(p)}`),Y(),$(!0);let e;try{e=await me({download:e=>{R(x.notice,null),B(e)},confirmWeb:ze})}catch(e){await Be(e);return}$(!1);let{kind:t,caps:n}=e;x.backend.hidden=!1,x.backend.querySelector(`.pill-text`).textContent=t===`web`?`In this browser`:`Server`;let r=t===`web`?`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`:`Connected to ${p||location.origin}: that server renders every voice.`;if(x.backend.title=r,x.backend.classList.add(`pill-${t}`),x.backend.addEventListener(`click`,()=>{let e=x.backendNote.hidden;R(x.backendNote,e?r:null),x.backend.setAttribute(`aria-expanded`,String(e))}),t===`web`&&(x.studioLink.search=p?`?api=web&server=${encodeURIComponent(p)}`:`?api=web`,a(e=>B(e.fraction>=1?null:e))),!n.speaker_modes.includes(`embedding`))return De(`This server can’t clone from a voice file: its model has no voice-embedding input.`);let i=n.text_norm_languages.length?n.text_norm_languages:[`en_us`];for(let e of i)x.language.append(new Option(c(e),e,!1,e===`en_us`));n.speaker_audio_upload||(x.clipUpload.disabled=!0,x.clipState.textContent=`This server doesn’t take clip uploads.`,x.clipFile.disabled=x.clipPick.disabled=x.record.disabled=!0),typeof MediaRecorder<`u`&&navigator.mediaDevices?.getUserMedia||(x.record.hidden=!0);try{await V()}catch(e){R(x.voiceError,`Couldn’t list voices: ${L(e)}`)}}Ve(); \ No newline at end of file diff --git a/studio/assets/studio-0qrBnVUE.js b/studio/assets/studio-0qrBnVUE.js new file mode 100644 index 0000000000000000000000000000000000000000..ff0e51ba4bb50082c8b8d517990b4aff9963ca12 --- /dev/null +++ b/studio/assets/studio-0qrBnVUE.js @@ -0,0 +1,3 @@ +import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./web-engine-BJErJyzx.js";import{C as p,S as m,_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,m as T,n as E,o as D,p as O,r as ee,s as te,t as ne,u as re,v as ie,x as ae,y as oe}from"./latin-500-DPgjq1zP.js";var k,se,ce,le,ue,de,fe,pe,me,he,ge,_e=Symbol.for(`pv`),ve={},ye=[],be=/^m(i|n|o|s|text|space)$/,xe=Array.isArray,Se=ye.slice,Ce=Object.assign;function we(e){e&&e.parentNode&&e.remove()}function Te(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?Se.call(arguments,2):n),Ee(e,o,r,i,null)}function Ee(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:_e,__v:i||++se,__i:-1,__u:0};return!i&&k.vnode&&k.vnode(a),a}function A(e){return e.children}function De(e,t){this.props=e,this.context=t,this.__g=0}function Oe(e,t){if(t==null)return e.__&&Oe(e.__,e.__i+1);for(var n;tt&&le.sort(fe),e=le.shift(),t=le.length,8&e.__g&&ke(e)}finally{(de=le.length)&&(ue||queueMicrotask)(Me)}}function Ne(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||ye,v=t.length;for(c=Pe(n,t,_,c,v),d=0;dc?g--:g++,_=1)):(~l||(i>m?g--:i>1]+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i=n.__.length&&n.__.push({}),n.__[e]}function j(e){return nt=1,pt(Ct,e)}function pt(e,t,n){var r=ft(Ze++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ct(void 0,t),function(e){var t=(r.__N||r.__)[0],n=r.t(t,e);tt(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Qe,!Qe.__f)){Qe.__f=!0;var i=Qe.shouldComponentUpdate;Qe.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,tt(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function M(e,t){var n=ft(Ze++,3);!at.__s&&St(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,Qe.__H.__h.push(n))}function mt(e,t){var n=ft(Ze++,4);!at.__s&&St(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,Qe.__h.push(n))}function N(e){return nt=5,ht(function(){return{current:e}},[])}function ht(e,t){var n=ft(Ze++,7);return St(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function gt(){var e;do{for(;e=it.shift();)try{bt(e)}catch(t){at.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=rt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(bt),t.__h.some(xt),t.__h=[]}catch(n){t.__h=[],at.__e(n,e.__v)}}}while(it.length)}at.__b=function(e){Qe=null,ot&&ot(e)},at.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),dt&&dt(e,t)},at.__r=function(e){st&&st(e),Ze=0;var t=(Qe=e.__c).__H;t&&($e==Qe?Qe.__h=[]:(t.__h.some(bt),t.__h.some(xt),Ze=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),$e=Qe},at.diffed=function(e){ct&&ct(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&yt(rt.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),$e=Qe=null},at.__c=function(e,t){t.some(function(e){try{e.__h.some(bt),e.__h=e.__h.filter(function(e){return!e.__||xt(e)})}catch(t){e.__h=[function(){throw t}]}}),lt&<(e,t)},at.unmount=function(e){ut&&ut(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,yt(it.push(r))}else bt(r)}catch(e){t=e}}),r.__H=void 0,t&&at.__e(t,r.__v))};var _t=typeof requestAnimationFrame==`function`;function vt(e){var t,n=function(){clearTimeout(r),_t&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);_t&&(t=requestAnimationFrame(n))}function yt(e){e!=1&&et==at.requestAnimationFrame||((et=at.requestAnimationFrame)||vt)(gt)}function bt(e){var t=Qe,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Qe=t}function xt(e){var t=Qe;e.__c=e.__(),Qe=t}function St(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!tt(t,e[n])})}function Ct(e,t){return typeof t==`function`?t(e):t}var wt={bundle:`studio_mect60k_x10`,embedding_dim:192,sets:{identity:{space:`raw`,modes:[`embedding`]},pitch:{space:`raw`,modes:[`embedding`]},accents_en:{space:`raw`,modes:[`embedding`]},accents_l1:{space:`raw`,modes:[`embedding`]},mandarin:{space:`raw`,modes:[`embedding`]},mandarin_hidden:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:15},texture:{space:`raw`,modes:[`embedding`]},room:{space:`raw`,modes:[`embedding`]},delivery:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},expressive:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},disfluency:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},mood:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19,calibration:{default:{valence:4,arousal:4,dominance:4,loudness:2,tempo:4,clarity:2,articulation:4},by_speaker:{},global_default:4}},emotions:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},emphasis_nv_nodur:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19}},directions:JSON.parse(`{"identity.gender":{"set":"identity","space":"raw","kind":"axis","norm":1.8763585090637207,"vector":[-0.145351,-0.037236,-0.231615,0.059623,-0.097463,-0.00438,-0.181256,-0.116112,0.006489,-0.066279,0.028154,-0.106317,-0.027322,-0.212539,0.074007,-0.172004,-0.016244,0.022171,-0.02436,-0.032008,0.004273,0.28592,-0.07487,-0.15942,0.06589,-0.030751,-0.168631,-0.081957,0.10407,0.100738,0.046116,-0.164522,-0.220581,0.284002,-0.196593,-0.085911,-0.01733,0.051308,0.07358,-0.129117,-0.03565,0.011623,-0.023857,-0.121824,0.023647,0.059977,0.331674,-0.03843,0.117079,-0.21018,0.195277,0.076132,-0.362561,-0.006322,-0.067303,0.011311,-0.225437,-0.035123,-0.071207,-0.032307,-0.03488,0.010383,0.067187,-0.092007,0.00216,-0.128227,-0.026748,-0.028467,-0.054922,-0.017777,-0.026001,-0.122082,-0.078555,0.118478,-0.018181,-0.390988,-0.024415,-0.007154,-0.182323,0.043611,0.024019,-0.148823,0.162163,-0.025151,0.189669,-0.083816,-0.327505,0.201499,-0.075665,-0.120443,0.236674,0.178995,-0.150236,0.229471,0.041385,-0.083846,0.164945,0.054651,0.305891,-0.09558,0.013738,-0.07623,-0.074258,0.063161,0.409077,0.068216,-0.135241,-0.024092,0.172651,0.273456,-0.221107,0.073845,0.000888,-0.196625,0.07575,-0.104654,-0.267578,-0.049794,0.13935,0.046093,-0.095611,-0.256105,-0.034189,-0.02879,-0.054839,-0.025545,-0.312504,-0.196937,0.058863,-0.025349,-0.146385,-0.015737,-0.05319,0.004336,0.155696,-0.039206,0.104365,0.026833,-0.044261,-0.009651,0.080538,-0.077517,0.01453,0.19844,-0.125283,0.234411,-0.123545,0.025533,-0.274192,-0.102795,0.147485,0.113269,0.06415,0.159278,0.024446,0.101267,-0.013436,-0.062379,0.233837,-0.195027,0.058858,-0.038064,-0.296664,-0.058662,0.145565,0.04023,0.177497,0.126765,-0.016302,-0.068889,-0.112941,0.000617,-0.074929,-0.024181,0.000709,0.169394,0.113144,-0.004877,-0.023614,-0.003327,-0.153569,-0.084833,-0.278179,-0.12704,0.015236,0.095529,-0.021818,0.152511,-0.101873,-0.152081,0.056203,0.052118]},"identity.age":{"set":"identity","space":"raw","kind":"axis","norm":1.2692716121673584,"vector":[-0.063163,0.025715,0.001118,-0.092943,-0.034933,-0.125913,0.012225,-0.00077,0.111829,-0.102742,-0.156968,-0.099157,-0.176265,-0.086085,0.037962,0.017417,0.090115,-0.033372,-0.074908,0.034763,-0.134577,-0.055955,-0.075105,-0.235013,-0.08009,-0.140841,0.022327,0.064326,-0.124652,-0.027546,-0.015516,0.143755,-0.081223,0.025154,0.101718,-0.018844,-0.003391,-0.109003,0.064622,-0.038087,0.017236,0.089364,-0.088411,-0.111307,-0.049177,0.013226,-0.038468,0.110437,-0.125002,0.002466,-0.060498,0.09326,-0.028549,-0.079882,0.013101,0.055996,0.015359,0.028079,0.229802,0.037334,0.087794,0.052627,0.121179,0.049674,0.039604,-0.177045,0.041455,0.065995,-0.02798,-0.026789,0.067736,-0.081227,-0.018426,0.052456,0.129375,-0.06956,-0.154618,0.094061,0.059635,-0.111231,-0.01689,-0.071005,0.082152,0.080971,-0.083226,0.08902,0.012294,0.140885,0.10317,-0.000385,0.120876,0.105215,0.089404,-0.07404,-0.082182,0.178104,-0.089479,0.016035,-0.062066,0.180699,-0.183151,0.063574,-0.034293,0.005246,-0.075163,0.051745,-0.228758,0.211571,-0.152502,-0.114202,-0.051652,-0.094758,0.183702,0.03155,-0.130021,-0.035248,-0.035422,0.11291,-0.118178,0.067327,0.017983,0.040879,0.128024,-0.044943,0.041002,-0.008232,-0.140447,-0.024046,0.105641,-0.063415,0.193576,0.024707,-0.11114,-0.058181,0.003658,0.019778,0.066323,0.045554,-0.150524,0.021908,0.183713,0.10898,-0.13902,-0.049086,-0.011006,-0.042131,0.02226,0.041943,-0.06328,-0.094408,0.004867,0.056636,-0.076927,0.062896,0.03928,-0.025153,0.011934,0.013235,-0.020326,0.044762,-0.035037,0.079239,-0.061671,0.063522,-0.00436,0.027616,-0.01906,-0.077974,-0.145151,0.252324,-0.042447,-0.090825,-0.010541,-0.012627,0.021808,0.077044,-0.044493,-0.038466,-0.106325,0.123089,0.031957,-0.034745,-0.065978,0.004073,-0.147551,0.042621,-0.014006,0.107974,-0.084259,-0.03464,0.044585,-0.275069]},"pitch.pitch":{"set":"pitch","space":"raw","kind":"axis","norm":0.7707383632659912,"vector":[-0.035456,-0.073794,-0.066747,-0.055367,0.005182,0.001163,0.075087,-0.014287,0.074419,-0.04765,-0.000435,0.05539,-0.002838,-0.001866,-0.007643,-0.019338,-0.113357,0.050418,-0.02785,-0.016621,-0.071575,-0.05209,0.063654,-0.018215,0.117463,0.059105,-0.065627,-0.023973,-0.020141,0.023111,0.103773,0.008534,-0.054626,0.052509,-0.020274,-0.064354,0.062204,0.033091,0.036008,0.052448,-0.063354,-0.083312,-0.000944,0.03266,0.035353,-0.047979,-0.049719,-0.012441,0.13676,-0.01006,0.015244,-0.03394,-0.008387,-0.051855,-0.019421,-0.064304,0.092926,-0.035068,-0.005127,-0.018303,0.074784,-0.004466,0.019366,-0.072268,-0.019801,-0.049896,0.000948,-0.043075,-0.010631,0.077308,-0.079053,0.033575,-0.085403,-0.081065,-0.024808,0.03599,-0.009064,-0.123303,-0.008879,0.000743,0.008401,0.004593,0.041746,-0.040566,0.055092,-0.017771,-0.100209,0.101322,-0.08772,0.067747,0.018121,-0.013698,-0.048914,0.088937,-0.020136,-0.101609,0.060011,0.047623,-0.031592,0.015499,-0.022134,0.123246,0.095097,-0.086202,-0.082677,-0.138884,0.013366,0.02652,0.098987,-0.004062,0.037981,-0.052589,-0.041336,0.031374,-0.001853,-0.029814,-0.016809,0.053698,-0.045353,0.062656,0.011208,0.043389,0.052102,0.162222,-0.099118,-0.062044,-0.039297,0.017345,-0.029279,0.094712,-0.006497,0.013958,0.018832,0.031753,-0.017383,0.071593,0.006318,0.054897,0.153091,0.044923,-0.040949,-0.030165,0.006404,0.002695,-0.003254,0.010518,-0.003883,0.018283,-0.002353,-0.02878,0.102114,-0.020522,0.00704,0.008226,-0.077554,0.061714,0.042735,-0.071792,-0.024929,0.060258,0.072032,0.055215,-0.083507,0.049271,-0.025117,-0.017864,-0.054783,0.041294,0.013468,0.053336,-0.046224,-0.05835,0.027689,-0.077863,0.061828,-0.121625,-0.038384,-0.068991,0.012205,0.08206,0.022452,-0.062281,0.011651,0.025772,-0.021956,0.012874,0.038269,0.03907,0.027826,0.028469,0.032512,0.022173]},"pitch.pitch_range":{"set":"pitch","space":"raw","kind":"axis","norm":0.5263656377792358,"vector":[-0.051322,0.011261,-0.021033,0.033204,0.002038,-0.046124,-0.013902,0.014066,0.072799,-0.065736,0.020775,-0.055353,-0.023786,-0.046455,0.004645,-0.002261,0.033407,-0.035266,-0.008787,0.039011,-0.010103,-0.026044,-0.08473,0.003239,-0.003864,-0.087572,0.061388,0.097881,0.028623,-0.029111,-0.003515,-0.016582,0.004541,0.000962,-0.004749,0.032266,0.03232,0.09381,-7.6e-05,-0.014506,-0.018217,0.022726,0.042261,-0.009174,0.038367,-0.047544,-0.042362,0.031818,-0.026594,-0.002025,-0.012863,0.045951,-0.004664,0.012374,-0.08765,0.0326,-0.056736,-0.017662,0.033801,-0.002818,-0.012227,-0.023888,0.032046,0.00791,-0.022499,-0.023092,-0.005985,-0.023223,-0.0039,-0.005383,0.004148,0.07646,-0.002578,0.010453,0.10306,-0.051988,0.005755,-0.039343,0.074246,-0.030741,-0.008567,-0.039663,0.008626,0.063158,0.009291,-0.003988,-0.00103,-0.040765,0.030876,-0.018829,-0.036452,0.065377,0.013529,0.0064,0.015996,0.038127,0.002603,0.01372,0.034977,0.022849,-0.025725,-0.023018,-0.052385,0.060743,-0.021379,0.018388,0.006304,0.032753,-0.055439,-0.074826,0.016163,-0.043093,0.04005,0.002804,-0.004096,0.060912,-0.061796,-0.037294,0.053518,0.078981,-0.011803,0.001715,-0.001898,-0.009334,0.05115,-0.010233,0.019631,-0.074158,-0.013502,-0.014347,0.098901,0.053461,0.051008,0.03192,-0.018099,0.024168,-0.023063,0.003663,-0.045126,0.039596,0.005756,-0.012701,-0.029812,-0.026187,0.071812,-0.024783,-0.035268,-0.05735,-0.052686,-0.065566,-0.000607,0.089317,0.009077,0.025068,-0.011178,-0.030508,-0.00865,0.045101,-0.023662,0.036244,-0.042542,-0.0551,-0.030425,-0.031683,-0.033685,-0.018356,-0.028677,0.022078,-0.017927,0.032608,-0.011809,-0.024077,-0.009228,-0.013655,-0.043765,-0.002104,-0.040811,0.01291,-0.046852,-0.02188,0.014881,0.025999,0.042839,-0.003209,0.022273,-0.035194,0.070249,-0.008531,-0.009852,0.023761,-0.010462,-0.03714]},"accents_en.british":{"set":"accents_en","space":"raw","kind":"named","norm":1.646016001701355,"vector":[-0.022339,-0.285003,0.031311,0.189842,0.036687,0.040312,-0.047964,0.036006,-0.041669,-0.201873,-0.094198,0.118696,0.040038,0.091439,-0.085005,0.190276,-0.138965,-0.321542,-0.092957,0.240308,-0.021151,-0.096758,-0.027554,-0.124645,0.05587,-0.083096,0.100615,-0.115498,0.07502,-0.281517,0.012712,-0.336685,-0.017609,0.040503,0.17216,0.037001,-0.036805,0.139876,0.127155,0.095273,-0.080436,0.078894,-0.163015,0.002001,-0.108771,-0.192278,-0.252098,0.026945,-0.076806,-0.072829,0.112576,-0.065247,0.254067,-0.207468,0.119722,-0.032825,-0.12768,0.022235,-0.0789,-0.041156,0.213258,0.00023,-0.001934,-0.082781,-0.103124,-0.029441,-0.051975,0.100977,0.009053,-0.115025,0.139497,0.201752,0.056401,-0.041064,0.023667,0.007775,-0.014908,0.068105,0.219601,0.070988,-0.213847,-0.109308,-0.038541,-0.127689,-0.208104,0.024503,-0.062413,-0.140138,0.003794,-0.030369,0.083621,-0.023283,0.086397,-0.103356,-0.017941,0.062643,0.002479,-0.178283,0.229584,-0.117903,-0.070644,0.081242,-0.118112,0.019497,-0.017851,-0.277422,0.101999,-0.049567,0.05012,0.024149,-0.12871,0.000872,0.039609,0.111971,-0.338037,0.113934,0.007461,-0.142536,0.014817,0.058449,-0.016407,0.164828,0.097083,0.166427,0.108926,-0.040193,0.15058,0.053644,0.081356,-0.069371,-0.046198,0.15662,0.013524,-0.062948,-0.083032,0.245468,-0.058217,-0.11444,0.207264,-0.084702,0.024228,-0.112412,-0.051458,0.026169,-0.039526,0.186085,-0.171223,-0.020853,0.069641,0.056344,-0.03032,-0.081166,-0.003098,0.19999,-0.096896,-0.08671,-0.05667,0.059684,-0.021692,0.037009,-0.009625,-0.102626,-0.157979,-0.023599,-0.112832,0.147422,-0.014994,-0.076816,0.018263,-0.024264,-0.062778,-0.14319,0.077452,-0.082209,-0.009312,0.084287,-0.261282,0.024318,0.01213,-0.109042,0.063652,0.292007,-0.056212,-0.138875,0.155889,0.097981,0.000508,-0.038531,-0.046817,-0.129606,0.069177,0.081733]},"accents_en.american":{"set":"accents_en","space":"raw","kind":"named","norm":1.646016001701355,"vector":[0.022339,0.285003,-0.031311,-0.189842,-0.036687,-0.040312,0.047964,-0.036006,0.041669,0.201873,0.094198,-0.118696,-0.040038,-0.091439,0.085005,-0.190276,0.138965,0.321542,0.092957,-0.240308,0.021151,0.096758,0.027554,0.124645,-0.05587,0.083096,-0.100615,0.115498,-0.07502,0.281517,-0.012712,0.336685,0.017609,-0.040503,-0.17216,-0.037001,0.036805,-0.139876,-0.127155,-0.095273,0.080436,-0.078894,0.163015,-0.002001,0.108771,0.192278,0.252098,-0.026945,0.076806,0.072829,-0.112576,0.065247,-0.254067,0.207468,-0.119722,0.032825,0.12768,-0.022235,0.0789,0.041156,-0.213258,-0.00023,0.001934,0.082781,0.103124,0.029441,0.051975,-0.100977,-0.009053,0.115025,-0.139497,-0.201752,-0.056401,0.041064,-0.023667,-0.007775,0.014908,-0.068105,-0.219601,-0.070988,0.213847,0.109308,0.038541,0.127689,0.208104,-0.024503,0.062413,0.140138,-0.003794,0.030369,-0.083621,0.023283,-0.086397,0.103356,0.017941,-0.062643,-0.002479,0.178283,-0.229584,0.117903,0.070644,-0.081242,0.118112,-0.019497,0.017851,0.277422,-0.101999,0.049567,-0.05012,-0.024149,0.12871,-0.000872,-0.039609,-0.111971,0.338037,-0.113934,-0.007461,0.142536,-0.014817,-0.058449,0.016407,-0.164828,-0.097083,-0.166427,-0.108926,0.040193,-0.15058,-0.053644,-0.081356,0.069371,0.046198,-0.15662,-0.013524,0.062948,0.083032,-0.245468,0.058217,0.11444,-0.207264,0.084702,-0.024228,0.112412,0.051458,-0.026169,0.039526,-0.186085,0.171223,0.020853,-0.069641,-0.056344,0.03032,0.081166,0.003098,-0.19999,0.096896,0.08671,0.05667,-0.059684,0.021692,-0.037009,0.009625,0.102626,0.157979,0.023599,0.112832,-0.147422,0.014994,0.076816,-0.018263,0.024264,0.062778,0.14319,-0.077452,0.082209,0.009312,-0.084287,0.261282,-0.024318,-0.01213,0.109042,-0.063652,-0.292007,0.056212,0.138875,-0.155889,-0.097981,-0.000508,0.038531,0.046817,0.129606,-0.069177,-0.081733]},"accents_en.scottish":{"set":"accents_en","space":"raw","kind":"named","norm":1.5993952751159668,"vector":[0.023044,-0.292152,0.083201,0.171497,0.074376,-0.032092,-0.009564,0.066545,-0.091342,-0.186126,-0.062248,0.089452,0.049849,0.197755,-0.049626,0.101676,-0.11466,-0.174779,-0.073255,0.118672,0.03332,-0.214,-0.013037,-0.164662,0.028858,-0.15183,0.108331,-0.191683,-0.036848,-0.184475,0.011906,-0.294046,-0.095363,0.040104,0.168272,0.022068,-0.082319,0.125902,0.057118,0.040786,-0.035154,0.05359,-0.192648,0.051702,-0.012257,-0.172657,-0.264824,0.027778,-0.096675,-0.048947,0.041727,-0.046524,0.285394,-0.223751,0.182209,-0.064925,-0.085722,-0.00507,-0.062273,-0.016637,0.238698,0.066183,0.01825,-0.068078,-0.07158,0.019382,-0.11971,0.090722,-0.034263,-0.183731,0.150524,0.178186,0.061624,-0.120047,0.034812,-0.02156,-0.132952,0.044345,0.264546,-0.000975,-0.182584,-0.078513,0.106223,-0.288324,-0.22504,0.053875,-0.104003,-0.043741,0.082283,-0.100788,0.006423,-0.058727,0.061482,-0.068307,-0.006949,0.10035,-0.013768,-0.202153,0.211064,-0.009171,-0.087958,0.042153,-0.107705,0.057232,-0.025099,-0.204364,0.074695,-0.131771,0.033892,0.077428,-0.182679,-0.065133,-0.019932,0.044552,-0.281493,0.131391,-0.004712,-0.144976,0.005822,0.048555,0.024558,0.144996,0.12236,0.171664,0.113711,0.037777,0.172753,0.058663,0.096942,-0.037692,-0.110044,0.017605,0.058249,-0.100404,-0.098809,0.200898,0.041245,-0.055047,0.089675,-0.14675,0.035656,-0.105808,-0.056788,0.002884,-0.006989,0.093857,-0.071874,0.031808,0.077554,0.107543,0.049787,-0.012125,0.031894,0.118719,-0.020575,-0.054211,-0.01034,0.052236,-0.086494,0.085015,0.101921,-0.066426,-0.155461,-0.043998,-0.078471,0.084417,-0.019423,-0.118028,-0.002183,0.015779,-0.026406,-0.304605,0.147595,-0.104432,0.017476,0.085557,-0.198707,-0.057574,-0.014618,-0.079898,0.028981,0.235765,-0.026519,-0.056621,0.201614,0.030617,0.059268,-0.046761,-0.041409,-0.119244,0.039725,0.045946]},"accents_en.irish":{"set":"accents_en","space":"raw","kind":"named","norm":1.4670429229736328,"vector":[0.112914,-0.288503,0.123549,0.210479,-0.035706,0.031258,-0.043036,0.017812,-0.044327,-0.17898,-0.004128,-0.043491,-0.012307,0.144079,-0.003556,0.112919,-0.098779,-0.188798,-0.028431,0.149651,0.043098,-0.09098,-0.004057,-0.109849,0.082469,0.013699,0.13549,-0.172739,-0.029849,-0.11439,-0.00855,-0.229456,-0.101228,0.190561,0.163376,0.068981,-0.073224,0.099852,0.098766,0.056437,-0.07942,0.009266,-0.191077,-0.013076,-0.087438,-0.03254,-0.238442,-0.189772,-0.115622,0.046546,0.072217,0.008084,0.200424,-0.244457,0.085477,-0.095188,0.012642,-0.027875,-0.070255,-0.063618,0.193425,-0.004022,0.05745,-0.008042,-0.038141,0.035261,-0.077346,0.101824,-0.012823,-0.184287,0.100374,0.194136,0.012189,-0.040289,-0.017836,-0.164719,-0.051997,0.074528,0.122257,-0.097913,-0.234352,-0.054286,-0.030428,-0.194777,-0.251735,0.006673,-0.039853,-0.005002,-0.051096,0.03027,0.071149,-0.101141,0.062956,-0.159008,0.004876,0.07655,0.023467,-0.164275,0.085357,-0.06257,-0.11929,0.023224,-0.048246,0.125983,0.036135,-0.205689,0.157869,-0.112496,0.110528,-0.080345,-0.089801,-0.106967,-0.00756,0.116242,-0.311712,0.081058,0.015956,-0.078374,-0.043582,0.0111,0.040816,0.116711,0.084771,-0.042012,0.167865,0.002513,0.139373,0.00988,0.145686,-0.023848,0.008932,0.122489,0.061347,-0.125978,-0.046024,0.204228,0.011953,-0.064352,0.064368,-0.179718,0.043863,-0.086587,-0.022887,-0.033303,0.056002,0.126262,-0.106404,0.003204,0.097228,0.069307,-0.011616,-0.004846,0.044604,-0.032369,-0.073001,0.051816,-0.070641,0.023064,-0.078643,0.012483,0.026347,-0.075117,-0.160035,-0.019511,-0.083507,0.15098,-0.021395,-0.071549,0.042357,0.021167,-0.034591,-0.198281,0.121783,-0.099499,-0.065079,0.027349,-0.098088,-0.14644,-0.032513,-0.067703,0.012306,0.170408,0.026491,-0.041375,0.182731,0.016732,-0.003258,0.045784,-0.011716,-0.144588,0.005471,0.136491]},"accents_en.australian":{"set":"accents_en","space":"raw","kind":"named","norm":1.6846641302108765,"vector":[-0.007695,-0.278172,0.013884,0.246978,0.037174,0.160327,0.075142,0.047884,0.098446,-0.235003,0.096621,0.023848,-0.042491,0.039472,-0.068406,0.286346,-0.11535,-0.335535,-0.118049,0.274944,-0.044243,-0.160417,-0.06314,-0.133093,-0.052953,-0.061814,0.028925,-0.25995,0.15828,-0.091182,-0.123988,-0.22506,0.008495,0.046644,0.114385,-0.044431,-0.012692,0.24542,0.116404,0.05385,-0.023916,0.109304,-0.021269,-0.053271,-0.001686,-0.108392,-0.299342,0.200249,-0.046739,0.059194,-0.026303,-0.047883,0.223979,-0.180332,0.168434,-0.021314,-0.138181,-0.142385,-0.072969,-0.019889,0.304511,0.08234,0.057797,-0.117814,-0.141828,0.112812,-0.048017,0.060297,0.01633,-0.14722,0.211483,0.243502,0.032984,-0.120496,0.107789,0.023353,0.018736,0.264582,0.182204,-0.01306,-0.00896,-0.106163,0.022881,0.018087,-0.201058,0.032274,0.014522,-0.113582,0.18317,-0.130339,0.050278,0.077079,0.165134,-0.045839,0.094605,0.037653,-0.018598,-0.142169,0.247129,-0.105078,-0.112243,0.015588,0.111147,0.034932,0.023732,-0.014794,0.125039,-0.140065,0.006379,-0.111336,-0.103555,0.072096,0.058954,0.092662,-0.282096,0.074661,0.025196,-0.134496,0.094676,0.092313,0.05649,0.001555,0.080696,0.131897,0.149897,0.025836,0.076886,0.083283,0.122535,-0.002167,-0.022216,0.146606,-0.069963,0.000344,-0.064966,0.173815,-0.053506,-0.080162,0.035035,-0.209768,0.023279,0.032713,0.081107,0.157242,-0.020422,0.103779,0.002353,0.044934,0.120347,0.036426,-0.025068,-0.013699,0.117546,0.091756,-0.108593,-0.120202,0.053543,0.000113,-0.0941,-0.013238,0.079136,-0.1444,-0.035133,-0.037077,-0.133846,0.183572,-0.092085,0.06309,-0.032678,-0.006531,0.018559,-0.247599,0.054414,-0.061243,-0.003818,0.071411,-0.239277,-0.100306,0.054286,-0.092112,0.006612,0.043902,-0.103129,-0.013931,0.257252,-0.051029,0.113547,0.034633,-0.155639,-0.243929,-0.067737,-0.008848]},"accents_en.indian":{"set":"accents_en","space":"raw","kind":"named","norm":1.933874249458313,"vector":[0.00436,0.092828,-0.069635,0.071136,-0.224593,0.09125,-0.017307,0.020625,0.185765,-0.075261,0.232219,0.170147,-0.065187,-0.031745,-0.090065,-0.064402,-0.283637,-0.32792,0.056361,0.247934,-0.146895,-0.014416,0.278522,0.025978,0.110245,0.087921,-0.068149,-0.043693,-0.00171,-0.150115,0.112889,-0.303988,-0.002665,0.049015,0.113694,-0.002281,0.055028,-0.137578,0.154721,0.071739,-0.132274,-0.222059,-0.055155,0.025725,-0.115241,-0.372144,-0.106872,-0.055753,-0.0156,0.053752,-0.089669,-0.034551,0.036048,-0.165935,0.081965,-0.137037,0.028333,0.036282,-0.063178,-0.029807,-0.097787,0.016003,0.03903,-0.180499,-0.09086,-0.17875,0.016707,-0.01799,0.072163,0.045484,0.070579,0.117365,-0.179399,0.069404,-0.27063,0.064462,0.149797,0.164635,0.032486,-0.107199,-0.065146,-0.160601,0.078129,0.057178,-0.040345,-0.104663,0.08582,-0.103677,-0.26575,-0.264641,0.006651,-0.019728,0.104824,-0.041191,0.226018,-0.087756,-0.112727,0.064183,0.165045,-0.021376,0.145753,0.148586,0.074481,-0.208569,-0.179818,-0.171522,0.264164,-0.044008,-0.078227,0.109992,-0.048938,-0.066293,-0.104992,-0.259558,-0.247443,-0.166443,0.048606,0.189554,-0.07696,-0.298702,0.079173,0.222133,0.027272,0.366583,-0.300184,-0.097105,0.028803,0.131934,0.003759,0.093682,0.070849,0.152828,-0.079334,-0.135283,-0.032495,-0.028527,0.066308,-0.03268,0.064852,0.307689,-0.017315,0.014299,0.11187,0.102381,0.09115,0.189907,-0.092809,-0.018404,-0.005354,0.082899,0.113987,0.12021,-0.179296,-0.025989,-0.019416,-0.095439,-0.206092,0.003457,0.1424,0.055848,0.009751,0.141483,-0.016243,0.15107,-0.175047,0.208715,0.008203,0.085683,-0.068767,0.131283,0.071338,-0.081451,-0.031294,0.081905,0.342687,-0.349862,-0.187669,-0.122154,0.056816,-0.075294,-0.096732,-0.057691,-0.014655,0.024322,0.269092,0.048213,-0.115802,0.046878,-0.012264,0.302853,-0.040437,0.33656]},"accents_en.welsh":{"set":"accents_en","space":"raw","kind":"named","norm":1.694260597229004,"vector":[0.060475,-0.354795,0.094562,0.223344,0.099176,0.029016,-0.110509,0.094177,0.063953,-0.215364,-0.117466,0.079404,0.053945,0.035562,0.009083,0.165794,-0.188765,-0.277147,-0.053333,0.17091,-0.055522,-0.126165,-0.029533,-0.106574,0.093718,-0.144952,0.080175,-0.101265,-0.052188,-0.360145,0.119174,-0.367237,-0.102235,0.018869,0.215145,0.081955,-0.063505,0.157351,0.142444,0.035971,0.0005,0.031688,-0.224493,0.035911,-0.026497,-0.224869,-0.268054,0.014149,-0.124744,-0.002643,0.004274,0.013977,0.162404,-0.22435,0.168999,0.017316,-0.131785,-0.012556,-0.060306,-0.047108,0.151576,-0.00897,0.024123,-0.078259,-0.124082,-0.059194,-0.060608,0.061142,-0.060785,-0.221216,0.130401,0.106442,0.064561,-0.119549,0.000321,0.03247,0.00969,0.071011,0.307679,0.066499,-0.185005,-0.126146,0.033073,-0.139965,-0.194154,0.026519,-0.046439,-0.126857,0.053441,-0.10234,0.042318,0.012843,0.070723,-0.050615,-0.04188,0.105883,0.034226,-0.126476,0.295436,-0.100279,-0.088505,0.0877,-0.100424,0.062165,0.039249,-0.177247,0.164702,-0.053907,0.088089,0.009261,-0.161421,-0.05451,0.004319,0.018246,-0.303708,0.042372,0.032325,-0.128738,0.057058,0.138396,-0.050542,0.077175,0.064944,0.159746,0.060279,0.050578,0.167126,0.015214,0.084983,-0.143182,-0.083774,0.081754,-0.014158,-0.01867,-0.098089,0.241168,0.054232,-0.027664,0.20721,-0.051159,0.089749,-0.076306,-0.077432,0.031934,-0.062203,0.051907,-0.232544,-0.05789,0.062775,0.078592,0.007815,-0.135678,0.046334,0.216673,-0.070312,-0.069758,-0.071957,0.090035,0.088826,0.09923,0.073589,-0.119095,-0.182358,-0.044265,-0.02437,0.15339,-0.047237,-0.131812,0.057849,0.045745,-0.036157,-0.135939,0.109621,-0.153439,-0.00268,0.204364,-0.182643,0.028083,-0.017993,-0.055048,0.084101,0.221275,0.001879,-0.155352,0.156973,0.092431,-0.013467,-0.061855,-0.051937,-0.07169,0.074366,0.05273]},"accents_l1.hin":{"set":"accents_l1","space":"raw","kind":"named","norm":1.8782426118850708,"vector":[-0.094225,0.151835,-0.129535,0.065107,-0.105491,-0.00168,-0.15273,0.029907,0.11913,-0.01346,0.177429,0.227382,-0.0984,0.023968,-0.105918,-0.190556,-0.13237,-0.304372,0.006561,0.077153,-0.177968,0.028584,0.194302,0.106413,-0.067094,-0.070858,-0.232981,-0.149926,-0.006173,0.143425,0.15934,-0.306085,0.031721,0.117237,-0.026764,-0.276625,0.029025,-0.312908,0.206962,0.104329,-0.165987,-0.014829,-0.286857,0.067007,-0.088537,-0.265737,-0.209024,0.089309,-0.107002,0.028646,-0.216459,-0.077135,-0.044335,0.074444,0.118911,-0.229572,0.048048,-0.012638,-0.056322,-0.069222,0.02065,0.090223,0.106631,-0.04368,0.0179,-0.200746,-0.090526,-0.050903,0.030384,0.111177,-0.044847,0.114831,-0.010722,0.013626,-0.22479,0.023448,0.097951,0.164729,-0.065722,0.041569,-0.04603,0.0415,0.065391,0.120592,-0.030759,-0.153817,0.113332,-0.219933,-0.303453,-0.25829,-0.019367,-0.04546,0.099142,-0.126884,0.270919,0.088352,-0.068963,0.100242,0.144169,-0.029835,0.251837,0.045053,0.142726,-0.059155,-0.127593,-0.08634,0.148536,0.04472,-0.163799,0.112296,-0.0918,0.009659,0.126371,-0.119861,-0.11657,-0.172284,0.108316,0.073385,-0.05166,-0.231619,0.124314,0.152126,0.00894,0.270903,-0.294978,0.004823,0.023585,0.041462,-0.078208,0.133836,0.090383,0.054082,-0.031477,0.109584,-0.060389,-0.331568,-0.041049,0.119172,0.089826,0.118803,0.006947,0.066277,0.173377,0.048587,-0.029941,0.222556,0.152578,-0.07901,0.175203,0.169953,0.107714,0.136261,-0.054712,-0.005679,0.063173,-0.128332,0.057855,-0.152021,0.05535,0.019668,-0.105389,0.181435,-0.080934,0.116777,-0.26991,0.149057,0.09735,0.058562,-0.146572,0.04678,0.152678,-0.038713,-0.178031,0.085387,0.137005,-0.235554,-0.116681,-0.136726,-0.021232,-0.130438,-0.087804,-0.121391,-0.028483,0.071053,0.011862,0.028273,-0.047307,0.011668,0.116069,0.309512,-0.034415,0.30539]},"accents_l1.spa":{"set":"accents_l1","space":"raw","kind":"named","norm":1.7367653846740723,"vector":[0.104951,0.091091,0.106259,-0.087729,-0.093172,-0.039638,-0.200943,0.098313,-0.121983,-0.10485,0.087534,0.091034,0.020255,-0.072376,-0.010385,-0.337513,-0.00323,-0.161034,0.007606,-0.067034,-0.012409,-0.089056,-0.050393,0.011805,-0.111692,0.002431,0.061583,-0.229874,0.018766,0.063596,0.10948,-0.258169,-0.187802,0.282621,0.085445,-0.024165,-0.129536,0.032212,0.044188,-0.001981,0.002593,-0.143405,-0.027832,0.106866,-0.033388,-0.116122,0.141888,-0.042374,-0.037783,0.301924,0.136818,-0.204755,0.067152,-0.161611,0.067861,0.013071,0.247737,0.216722,0.186936,-0.195568,-0.120664,0.056905,0.022897,0.279555,0.219549,-0.125912,-0.043327,0.079356,-0.0882,0.185005,0.183207,-0.054426,0.084593,0.039233,0.010782,0.076853,0.02487,-0.075078,0.150331,0.081899,-0.236374,0.052506,-0.210462,-0.044586,0.165465,-0.038659,-0.111865,-0.022555,0.111221,-0.054686,-0.025149,-0.072712,0.135321,0.080741,0.001625,-0.066074,0.010451,-0.118236,-0.088448,-0.053581,0.164743,0.041839,0.039843,-0.232835,-0.17292,-0.044589,0.200029,0.116178,-0.033614,0.155122,-0.184718,-0.053132,-0.094628,0.17148,0.207594,-0.119302,-0.053668,0.201353,0.01441,-0.167783,-0.015924,0.194219,-0.015568,0.08815,0.033146,0.025938,0.027589,-0.17195,-0.266149,-0.059472,-0.042021,0.117095,0.121079,-0.013266,0.05941,-0.151384,-0.043579,0.043525,0.332219,0.050505,-0.081072,-0.08301,-0.152383,4.8e-05,-0.04277,-0.032155,-0.062277,0.227797,0.004109,0.012486,0.101669,-0.041417,-0.269481,0.120793,0.015077,-0.026926,-0.220254,-0.061897,-0.044823,-0.070967,-0.060718,-0.161895,-0.022258,0.128124,0.060351,-0.001168,-0.091418,-0.07821,0.11174,-0.153104,-0.234126,-0.037324,-0.21066,-0.09612,-0.109222,-0.165936,-0.10653,0.184289,0.115555,-0.003269,-0.072691,0.225059,0.08047,-0.001912,-0.13926,0.228173,0.034965,-0.033024,0.142239,0.106291,-0.004304,-0.061155]},"accents_l1.fra":{"set":"accents_l1","space":"raw","kind":"named","norm":1.6489053964614868,"vector":[0.115509,0.038507,-0.160571,0.25168,-0.051832,0.107176,-0.03402,0.111554,0.059468,0.047998,-0.216811,0.095619,0.174813,-0.114702,-0.016257,-0.041247,-0.013407,-0.109322,0.110724,-0.120842,0.025099,0.02148,0.186918,0.16602,0.016177,0.045616,0.001491,-0.221922,-0.021058,-0.11744,0.113733,0.020966,0.155126,0.060634,-0.057596,-0.134142,0.072875,-0.015265,0.065835,0.17433,0.119547,-0.011138,-0.041188,0.017808,-0.108685,-0.133808,0.130006,0.139981,-0.052548,-0.25166,0.076716,-0.164455,0.04736,-0.227469,-0.088013,0.024109,0.087894,0.129126,-0.144786,-0.031429,0.128994,-0.24508,0.074436,0.110569,0.070163,0.04782,-0.101337,-0.018511,-0.010367,0.14907,-0.163573,-0.244627,0.0894,0.159082,-0.022087,0.006962,-0.011341,-0.04758,0.287671,0.209201,-0.159891,0.090563,-0.101242,0.037082,0.128318,0.020943,-0.001625,-0.117067,-0.11728,0.003637,-0.023457,-0.191505,-0.012673,-0.068353,0.055023,-0.076684,0.033972,0.02061,0.036431,-0.008467,0.163513,0.133359,-0.113535,-0.213873,0.039598,-0.106536,-0.087595,0.118244,0.011141,0.112163,0.057786,0.173337,0.149979,0.09155,0.061845,0.08135,-0.07402,0.143203,-0.306345,-0.1834,-0.131197,0.142349,0.090068,0.092271,0.088442,-0.108649,0.064914,0.054956,0.153627,-0.183952,0.029093,-0.166048,0.032106,-0.038668,0.004344,0.099334,-0.116082,0.049551,0.18065,0.119916,-0.141589,0.05386,-0.231389,-0.160251,0.094769,0.169656,-0.186086,0.07167,-0.142253,-0.05449,0.098469,0.040925,-0.137791,-0.083095,-0.045016,-0.197182,0.047242,0.079559,-0.021982,-0.042712,0.092767,0.011881,-0.125262,-0.012448,-0.248309,0.158571,0.129386,-0.14982,0.032726,-0.080698,-0.020177,0.077189,0.071099,-0.076078,-0.102284,0.003153,-0.140547,0.113916,0.029267,0.004357,0.088647,0.195567,0.121169,-0.033094,0.13348,0.334481,0.063542,-0.043432,-0.214439,-0.026025,0.051357,0.106763]},"accents_l1.por":{"set":"accents_l1","space":"raw","kind":"named","norm":2.014261245727539,"vector":[-0.100812,0.017003,-0.034826,0.078753,-0.226473,0.095865,0.17389,0.219609,0.032725,-0.185002,-0.12371,-0.164098,0.000854,0.086512,-0.187086,-0.06754,0.157488,-0.354299,0.267604,0.25612,0.081776,0.121603,0.122849,0.281027,-0.092778,-0.121131,0.094879,0.016269,0.122235,0.177247,0.206468,-0.065542,0.018701,0.148402,-0.069173,0.047242,0.140724,0.023863,0.038621,0.187887,-0.109225,0.037449,0.008506,-0.11513,-0.096509,-0.189576,-0.074924,0.050807,-0.042718,0.051166,-0.102043,-0.054831,0.296724,-0.053582,0.203142,-0.025412,0.123474,0.160658,0.165817,-0.016487,0.03842,-0.131921,0.098869,0.115782,-0.105006,0.06991,-0.199714,0.097892,0.098166,0.098476,-0.078738,0.044093,0.082882,0.077323,0.14976,-0.013769,-0.310724,0.190738,-0.053454,0.310025,0.110981,-0.037471,0.102896,-0.267101,0.176047,-0.202169,-0.068164,-0.315148,0.105866,0.161726,0.123961,0.018754,0.120184,-0.050051,-0.115797,-0.084834,0.194959,0.112649,-0.068095,0.050965,0.228357,0.167572,-0.022281,0.044085,-0.367158,0.025941,-0.041875,-0.071769,-0.0448,0.099745,-0.20262,0.248151,-0.340965,-0.317965,0.083766,0.107991,-0.055458,0.153145,-0.088231,-0.129318,-0.126382,0.148352,-0.074072,0.190273,0.035193,-0.205094,0.112132,0.11042,-0.226285,0.119514,-0.083516,-0.106852,0.004924,-0.090829,0.205825,-0.180005,0.10648,0.176769,0.141944,0.220179,-0.103902,0.299889,-0.000528,-0.327567,0.019057,0.133145,-0.089708,0.32744,-0.029253,0.122318,0.200325,-0.308726,-0.057072,0.062486,-0.039971,-0.28528,-0.039549,0.125938,0.0445,0.031343,-0.010496,-0.036801,0.139572,-0.010853,-0.089886,0.01621,-0.084709,-0.197868,0.07372,-0.106435,-0.086518,0.057655,-0.113408,0.058852,0.109403,0.290679,0.097085,-0.193347,0.02052,-0.029414,0.079284,-0.061789,-0.192752,0.021153,-0.05053,-0.062003,0.027503,0.079905,0.103406,-0.093572,0.065346,0.183084]},"accents_l1.deu":{"set":"accents_l1","space":"raw","kind":"named","norm":1.6574718952178955,"vector":[-0.043598,-0.098169,-0.117312,0.07139,-0.187312,0.041628,-0.046844,0.077625,-0.0469,-0.030087,-0.222882,-0.034036,0.262849,0.027338,-0.034683,0.049392,-0.199782,-0.167664,0.066731,-0.041143,0.106481,0.026782,0.033265,0.060859,-0.015291,0.078738,0.00231,-0.012382,0.213001,0.106451,0.177929,-0.204868,0.071414,0.144864,0.155355,-0.210804,0.134587,0.014555,0.069829,0.294278,-0.055753,0.32343,-0.150776,0.001277,-0.077078,-0.198439,-0.099315,-0.049742,-0.327732,-0.06215,0.034353,0.092132,0.003278,0.028828,0.250488,-0.078833,0.049585,-0.041154,-0.182181,-0.157864,0.015911,-0.094506,0.175586,-0.052266,0.044649,-0.035933,-0.020739,-0.099406,-0.0708,0.000316,0.159915,-0.059067,0.190649,-0.012559,0.082592,-0.062674,-0.071291,0.112676,-0.010579,-0.009479,-0.172996,0.051345,0.017159,0.116334,0.00912,-0.032782,0.070822,0.000954,0.087546,0.072727,-0.149909,-0.305828,-0.122101,-0.197533,-0.01262,0.044901,-0.050557,0.073383,0.089414,-0.079069,0.040026,0.170764,-0.027728,0.018143,0.003977,-0.225383,0.099071,-0.046793,0.109662,-0.129803,-0.07886,-0.078636,0.219003,0.044963,-0.182177,-0.194169,0.195214,0.119118,-0.054094,-0.16163,-0.010922,0.032327,-0.213021,0.131629,0.08005,-0.157101,0.165039,-0.040727,-0.003726,-4.1e-05,0.032403,0.160945,0.10347,-0.105637,-0.094965,0.040496,0.069824,-0.058771,0.215605,-0.050139,-0.133273,-0.055626,-0.064415,0.011034,-0.055728,0.207378,-0.018428,0.166948,0.197471,0.092526,-0.042815,-0.024116,-0.144826,0.116607,-0.037198,0.097356,0.114991,-0.067035,0.13789,-0.191385,-0.09471,0.02987,-0.041058,0.033097,-0.181533,0.049522,0.086443,-0.112731,-0.006196,0.166906,0.199148,0.018381,0.02635,0.057679,0.084065,-0.046447,-0.138167,-0.06657,0.006681,0.07469,0.096037,0.11112,-0.194324,0.164853,-0.092011,0.129038,0.01858,-0.042009,0.267593,0.056378,0.057179,0.194923]},"accents_l1.vie":{"set":"accents_l1","space":"raw","kind":"named","norm":2.456273317337036,"vector":[-0.040002,-0.124399,0.011896,-0.031328,-0.060366,0.09168,-0.140528,0.029977,-0.090046,0.092357,-0.19447,-0.047248,0.263782,-0.297212,-0.237761,0.152095,-0.095702,0.143766,0.050433,-0.011179,-0.135305,0.061567,-0.040078,0.062069,0.201743,0.058567,0.278546,-0.354333,0.278096,-0.248364,0.164983,-0.036523,0.056232,-0.119196,0.212248,0.059116,-0.237471,0.433277,0.089501,-0.168109,-0.138989,-0.192355,-0.016931,0.16527,-0.138694,-0.088397,-0.057442,0.235376,0.023462,0.097965,-0.2656,0.032417,0.068134,-0.252127,-0.25955,-0.166268,-0.028892,-0.137361,-0.07305,0.143639,0.115673,0.058465,0.16315,-0.061318,0.00874,-0.219711,-0.093293,-0.024424,-0.19323,0.234176,-0.019696,0.030946,0.095592,0.43669,-0.358631,0.099751,0.027851,0.137731,0.292976,0.254556,-0.052255,-0.120845,0.099451,-0.112632,0.044819,-0.130072,0.083409,0.039474,-0.109658,0.096242,0.004124,0.066536,0.222425,0.182229,0.01202,-0.444215,-0.073449,-0.033145,0.123663,-0.112223,0.090396,0.225505,0.121975,-0.135919,-0.286924,-0.186591,-0.098809,-0.030442,-0.354396,-0.237069,0.031201,-0.054415,0.132087,0.064697,-0.200812,-0.006694,-0.150939,0.199007,0.268932,-0.138518,-0.477976,0.090728,-0.407483,0.282547,0.26904,-0.213917,0.0042,0.166542,0.322277,0.063617,-0.021601,0.040327,-0.004625,0.172052,0.027953,-0.069982,0.170849,-0.27351,0.229908,-0.048806,0.033829,-0.014826,-0.069856,0.119321,0.150564,0.227009,-0.047318,-0.081505,0.110572,0.017432,0.372051,-0.07643,0.118523,0.232678,-0.168794,-0.06651,0.097068,0.019367,0.109237,-0.28086,0.101595,0.126061,0.16428,0.056158,0.051296,-0.203903,-0.093538,-0.079762,-0.141886,-0.238244,0.09055,-0.330764,-0.187544,0.535157,0.068228,-0.194882,-0.072766,0.16877,0.028804,0.112215,0.200202,-0.074342,0.142503,-0.2868,-0.030393,0.32365,0.054822,-0.36891,0.26923,0.168037,0.175113,0.170413]},"accents_l1.pol":{"set":"accents_l1","space":"raw","kind":"named","norm":2.0049545764923096,"vector":[-0.067265,0.041187,-0.009787,0.231494,-0.061184,-0.076705,0.056669,0.079162,0.019501,-0.094284,0.066569,-0.005773,-0.062537,-0.088377,-0.256142,-0.158953,-0.083487,-0.181476,0.160367,0.095784,-0.223042,0.187359,-0.010428,0.110976,-0.006285,-0.106128,0.09748,-0.045717,-0.047229,-0.091015,0.002253,-0.058513,-0.045056,-0.014487,0.043954,-0.035951,-0.121327,-0.259681,0.159674,0.187271,-0.194086,0.112725,-0.025465,0.015127,-0.079332,-0.127029,-0.121465,-0.162006,-0.045483,-0.161442,0.393578,0.110825,0.242772,-0.066652,0.211705,0.215946,0.189611,0.215137,-0.243735,-0.025649,0.146631,0.076317,-0.203267,0.178443,-0.168335,0.012395,-0.213131,0.12464,-0.111582,-0.02739,0.004428,-0.144905,-0.047377,0.006164,0.122846,0.148752,-0.079989,-0.06785,0.011903,0.16646,0.069677,-0.047263,-0.011463,-0.125506,-0.139637,1.1e-05,-0.02989,-0.046004,-0.180761,0.298389,-0.169275,-0.299105,-0.129774,-0.19746,0.063007,-0.172101,-0.209841,-0.015476,0.207686,0.106864,0.148681,0.069929,-0.178195,0.059254,0.028915,-0.318549,0.166088,-0.139615,0.094639,0.345918,-0.036714,-0.035771,-0.194695,-0.262483,-0.197437,0.13041,0.015033,0.054145,0.018529,-0.018074,0.066383,-0.032786,-0.151817,0.06871,-0.144296,-0.10766,0.155008,-0.08432,-0.034763,-0.140136,-0.031141,0.142162,0.096067,-0.074982,-0.023889,-0.082486,-0.079129,0.057738,0.201016,0.022429,0.019423,0.113524,0.011063,-0.246979,-0.116292,0.18057,0.007041,0.195234,0.244772,0.013859,0.081929,-0.159551,-0.152018,-0.112372,0.078805,0.132142,-0.039858,0.344959,-0.052119,-0.009558,-0.151263,-0.044588,-0.071237,0.016419,-0.220376,0.086139,-0.119338,-0.204006,-0.178274,0.164933,-0.301662,0.328862,0.308037,0.028542,-0.007733,0.23975,0.009719,-0.086828,0.081061,0.138821,0.068025,0.027214,-0.26744,-0.097091,-0.117777,0.23313,-0.099161,-0.025128,0.353466,0.083421,-0.005488,0.213405]},"mandarin.cmn":{"set":"mandarin","space":"raw","kind":"named","norm":2.2392897605895996,"vector":[-0.108921,0.179436,-0.056175,0.149681,0.074374,0.004598,-0.210753,0.172479,-0.095906,0.073419,-0.52727,0.023121,0.046068,-0.118781,-0.103468,0.026372,0.09888,0.105814,0.199207,-0.132635,0.005809,0.024837,0.246593,-0.148914,0.239629,0.151292,0.259535,-0.038289,0.092368,-0.230129,0.216822,0.055858,0.0504,-0.016959,0.221458,-0.026729,-0.35489,-0.166528,-0.22054,0.025003,-0.15038,-0.102777,-0.15435,-0.005949,-0.303966,0.030525,-0.016874,0.070823,0.114853,-0.04406,0.099661,0.0554,0.09686,0.086749,0.291011,-0.073136,0.063492,0.102796,-0.256854,0.172562,-0.061355,-0.023175,-0.041036,0.153263,-0.314487,-0.414374,-0.165353,0.198917,-0.086636,0.021892,-0.066041,0.334383,-0.084622,-0.036695,0.060188,0.065045,0.106868,-0.071376,0.131824,0.187437,0.138082,0.15153,0.282983,-0.00293,0.094376,0.002887,-0.031482,0.131883,0.021088,0.599586,-0.060694,-0.470855,-0.088902,-0.082736,-0.094124,-0.179759,0.022545,-0.04753,0.123937,-0.126462,0.000696,0.107905,-0.370273,-0.226093,0.041209,-0.273463,0.213751,-0.009449,0.044847,0.226086,0.168232,-0.017015,-0.020135,0.050181,0.117171,0.212604,0.123792,0.304786,0.278175,-0.031998,-0.228931,0.3672,-0.062848,0.202046,0.014029,-0.166645,-0.071658,-0.034519,-0.158137,0.084577,0.109019,-0.078561,0.126726,0.096855,0.171669,0.075721,0.023424,0.192717,-0.037947,0.071555,0.238061,-0.117358,0.133697,-0.060448,0.125752,0.112059,0.015337,-0.044663,0.106007,0.042954,0.207788,0.162861,-0.277972,-0.019787,-0.105007,0.141428,-0.058199,0.106688,0.107803,-0.115172,0.162839,0.001784,0.07614,-0.023433,0.080253,-0.044697,-0.115972,0.216828,-0.3987,-0.103421,-0.079469,-0.049993,0.149027,0.097345,0.135518,-0.059948,-0.068269,0.11921,-0.007921,-0.253867,0.04294,-0.034677,0.076789,-0.042709,-0.131624,-0.046917,-0.083043,0.059513,0.108337,-0.005547,-0.005535,0.408018]},"mandarin_hidden.cmn":{"set":"mandarin_hidden","space":"attnres_source","kind":"named","norm":0.1931123286485672},"texture.deep":{"set":"texture","space":"raw","kind":"named","norm":0.5765019655227661,"vector":[0.083126,-0.045712,-0.017391,0.054447,-0.036644,0.094359,0.039225,0.018366,-0.049822,0.042236,-0.022708,0.086714,-0.051443,0.033203,0.038265,0.066979,0.041173,-0.0696,0.063549,0.050545,0.086386,0.029497,0.018932,-0.059825,0.012129,-0.017476,0.033982,-0.023535,0.072473,0.01062,-0.010011,-0.06258,0.010724,0.051904,0.08113,-0.000474,0.084091,-0.005664,0.006943,-0.021175,-0.017186,-0.051237,-0.0616,-0.01165,-0.078765,0.015776,-0.015119,-0.008418,-0.07564,-0.008493,-0.015476,-0.060928,0.027622,0.015555,-0.011469,-0.029694,-0.00515,0.035405,-0.054176,0.012599,-0.049803,0.01412,0.026686,-0.038096,0.006708,0.014931,-0.015362,-0.017396,0.016301,0.012914,0.0168,-0.02456,-0.005179,-0.030171,-0.053464,0.012638,0.001154,0.029079,0.037603,-0.072364,-0.039374,0.010471,-0.040323,0.001509,-0.057212,-0.029364,0.097043,0.038886,-0.001757,-0.022528,-0.007795,-0.001465,-0.009863,0.004376,0.023051,-0.003054,-0.061738,-0.07792,0.052716,0.034359,-0.023657,0.017522,-0.096672,-0.034705,-0.003885,-0.056338,0.02083,-0.051279,-0.000467,0.03135,0.006482,-0.000501,-0.028434,0.070274,-0.066485,-0.018159,-0.02857,0.008601,0.022389,-0.079885,0.001989,0.025994,-0.012721,0.02944,0.023831,0.036364,0.062109,0.030506,0.017527,0.049844,0.010251,-0.00989,-0.028422,-0.112894,-0.014337,-0.017284,0.045302,0.021164,-0.044467,0.031952,0.002537,-0.003394,-0.036872,-0.017349,0.017776,0.084397,0.005436,-0.006043,0.029127,-0.033116,-0.019236,-0.045881,0.015544,-0.013371,0.001535,-0.03273,-0.056219,0.056899,0.047787,-0.027682,-0.033093,-0.05848,0.046142,-0.04319,-0.019661,-0.001283,-0.015441,-0.0089,-0.063832,-0.004348,-0.01032,-0.035887,0.026605,0.083559,0.022334,-0.029244,0.054297,-0.021758,-0.031615,-0.014108,0.013379,0.05469,0.037378,-0.054634,-0.084277,0.052846,0.009512,0.026596,0.064852,0.074309,0.040135,-0.006674]},"texture.shrill":{"set":"texture","space":"raw","kind":"named","norm":0.8610222935676575,"vector":[-0.098653,0.009054,0.024251,-0.000411,0.097319,-0.119844,0.052241,0.035051,-0.033395,-0.053334,0.079231,0.036811,-0.001601,-0.096567,0.055255,0.11393,-0.052505,-0.01044,0.027828,-0.107887,-0.010773,-0.030229,0.06564,0.005204,-0.031196,-0.049469,0.017056,0.018619,0.020536,-0.031092,0.046057,0.12704,-0.075975,0.049727,-0.084056,0.057581,0.118865,-0.058827,-0.084911,-0.038951,-0.050325,0.039242,0.075422,0.022394,0.037402,-0.00203,0.016731,0.155318,-0.050363,-0.057559,-0.083531,0.185809,-0.003126,0.036968,-0.036165,0.055198,0.002201,0.019557,0.006437,0.004961,-0.119474,0.012583,-0.075672,0.007093,-0.062574,-0.06776,0.064586,-0.033154,0.092652,0.019823,0.006172,-0.099495,0.038915,0.020797,0.037523,0.080855,-0.042341,0.013091,-0.024503,0.107024,0.058971,-0.051407,-0.038371,0.099842,0.061988,0.10151,-0.019261,-0.009971,0.087239,-0.066048,-0.079678,-0.061469,0.009372,0.046328,0.048333,-0.036662,0.018121,0.031716,-0.080007,-0.046029,-0.00927,0.056084,0.125268,-0.04909,-0.040304,-0.035325,0.023225,-0.019084,0.022515,0.061024,-0.048631,0.07648,-0.003508,-0.057736,0.048207,-0.039867,0.035856,0.043669,0.011207,-0.037977,0.02429,0.125379,0.018345,0.018366,-0.008902,0.062721,-0.012487,0.070354,0.014256,-0.102934,0.016914,0.044755,0.066846,0.003536,-0.05631,-0.069875,-0.105981,0.043863,0.046924,0.08626,-0.082402,0.038941,0.031398,-0.108944,-0.077302,-0.052728,-0.051737,0.031155,-0.059068,-0.005026,0.09985,0.03296,-0.077844,-0.052673,0.086899,0.006912,-0.027177,-0.032418,-0.018329,0.053857,-0.068661,0.088618,0.015753,0.012106,-0.097819,0.077293,0.032636,0.038249,-0.061784,0.052473,-0.039944,0.077104,-0.063031,-0.095209,0.064915,0.041918,0.093121,-0.019221,-0.030222,0.098023,-0.049959,0.008883,-0.001809,-0.016198,0.012604,-0.166197,-0.055203,0.024572,-0.099663,0.09575,-0.008484,0.097987]},"texture.husky":{"set":"texture","space":"raw","kind":"named","norm":0.5867545008659363,"vector":[-0.012865,0.008702,0.003436,-0.059771,0.005715,-0.0056,0.024584,0.013027,0.037862,0.029546,0.000119,-0.011109,-0.059532,0.04348,-0.067457,-0.098879,-0.031263,0.089543,0.018105,-0.082176,-0.019187,-0.081391,0.016701,-0.054115,-0.068344,0.080218,0.026,0.016464,0.004014,0.086359,-0.062569,0.097602,-0.000514,0.01939,0.055375,0.001868,-0.029587,0.067839,0.047989,0.012201,0.0246,-0.003119,-0.005984,0.006094,0.008807,0.010757,0.040537,-0.001475,-0.009215,-0.027148,0.008808,0.041048,0.062132,0.047891,0.021092,0.005458,-0.022269,-0.066923,-0.025565,0.008435,-0.044487,0.045132,-0.029178,0.096975,-0.024089,0.005102,-0.002072,0.052551,-0.007714,0.061235,-0.113777,-0.025175,0.055726,0.059166,0.055428,0.034267,-0.028021,-0.034168,-0.008317,-0.016875,-0.000382,-0.004168,0.108518,-0.006408,-0.003944,-0.005309,-0.012223,0.017367,0.005839,-0.005568,-0.020073,-0.019414,-0.032067,0.002113,0.061265,-0.026636,-0.003597,0.020499,-0.020529,0.092878,-0.007648,-0.058361,-0.014731,-0.048676,0.01898,0.001536,-0.000799,-0.102327,-0.034742,-0.038589,0.010441,-0.00299,-0.033432,0.036758,0.042131,0.077872,0.018446,-0.022485,0.009454,0.026158,-0.016507,0.011723,0.000734,-0.000568,-0.038512,-0.009226,-0.077665,-0.077423,0.042179,-0.007771,-0.010986,-0.006622,-0.018958,-0.003475,-0.005826,-0.079692,0.047934,-0.022862,0.029211,-0.031157,-0.080047,0.016227,0.004492,0.021157,0.002594,0.000903,-0.018801,-0.052594,-0.002335,0.028961,-0.018517,-0.049509,-0.016673,0.006102,0.064718,0.013813,0.102432,-0.013218,-0.085613,0.024788,-0.026293,0.029965,0.017895,0.064067,-0.018363,-0.021045,0.035567,0.089336,0.023795,-0.025847,-0.017816,-0.0126,0.007557,0.001342,0.063813,0.008054,0.028761,-0.069351,-0.059975,-0.029312,-0.014047,-0.055836,0.061972,-0.044773,-0.015325,0.051106,0.017663,-0.082316,0.064866,-0.007112,-0.01927,0.031878]},"texture.raspy":{"set":"texture","space":"raw","kind":"named","norm":0.8753706216812134,"vector":[-0.092398,-0.02677,0.081344,-0.047812,0.133046,-0.073512,-0.106196,-0.042104,0.073107,-0.072423,-0.007399,-0.014431,0.06011,-0.071407,-0.038047,0.00144,0.05813,0.008853,0.041383,-0.045762,-0.095648,-0.119133,0.101911,0.060218,0.08053,-0.030274,0.078624,-0.000682,-0.091644,0.021918,0.040492,0.049786,-0.03015,-0.089655,-0.136242,-0.028479,0.028101,-0.052077,-0.09728,-0.105621,-0.016268,0.105676,0.128658,-0.006713,-0.000705,-0.041877,0.068387,0.121586,0.008839,0.017397,-0.06695,0.040385,0.015007,-0.05746,-0.035755,0.045878,-0.020322,-0.017258,0.095756,-0.109928,0.096122,0.010556,-0.058936,-0.018009,0.009618,0.06393,0.072172,0.010503,-0.033164,0.058032,-0.026321,0.051657,-0.106598,0.029662,-0.035419,0.016221,-0.01695,0.021889,0.016688,0.012881,-0.010214,-0.007853,0.105066,0.021938,0.034985,-0.022989,-0.108163,-0.035223,-0.018776,-0.075593,-0.000149,0.05457,-0.138321,0.066466,-0.056444,-0.018794,0.007677,0.041173,-0.044656,-0.045846,0.056377,0.017029,0.112195,0.041297,-0.047653,-0.040934,-0.02063,-0.054233,-0.052923,0.012896,0.036572,-0.055062,-0.016789,-0.080007,-0.042612,-0.059866,0.031132,0.032522,-0.031955,0.063381,0.095577,-0.018347,0.111427,-0.082832,-0.009695,0.01364,0.002462,-0.099292,-0.035972,-0.097658,0.100292,0.029022,0.032916,0.104702,0.024413,-0.016036,0.04683,-0.009893,0.140884,0.018811,-0.079367,-0.006411,0.10319,-0.035481,-0.004863,-0.116295,-0.004071,-0.092441,-0.013564,-0.041573,-0.020493,0.085256,-0.004645,0.085102,0.010701,-0.010648,0.035097,0.032456,-0.085029,0.033068,0.121562,-0.002625,-0.00905,0.108339,0.158697,-0.112402,0.051404,-0.06231,0.030721,0.041516,0.021032,0.048058,0.025799,-0.045712,-0.006257,0.029005,-0.017559,-0.022676,0.130153,0.143652,0.047394,-0.11211,-0.03784,0.036218,-0.022704,0.005754,-0.046474,0.00232,0.068843,0.088426,0.034422,-0.028863]},"texture.soft":{"set":"texture","space":"raw","kind":"named","norm":0.7225086092948914,"vector":[-0.022581,0.048497,0.009645,-0.034167,-0.071143,0.09039,0.029504,0.018821,0.004282,-0.032923,-0.03254,-0.012492,-0.035304,-0.019366,-0.047357,0.029816,0.034786,0.030787,-0.012025,-0.003484,0.060754,0.075089,0.009377,0.033661,0.07154,0.068848,0.012758,-0.047444,0.018573,0.066384,0.00821,-0.070244,-0.004644,0.005762,0.040515,0.028509,0.000754,-0.040578,0.0285,0.046505,-0.015826,-0.060852,0.010011,0.006128,-0.032981,-0.007516,-0.027463,-0.04623,0.092011,-0.099987,-0.006327,-0.0322,-0.023095,0.004132,-0.001978,-0.048155,0.024987,-0.036444,-0.018999,0.022598,-0.013956,0.035982,-0.026813,0.080011,-0.001209,0.046725,0.00241,0.065849,-0.018658,-0.006923,-0.082582,0.041318,0.033578,0.004113,0.12285,-0.051225,0.033,-0.103849,0.066899,-0.065938,-0.068368,0.110516,-0.045341,0.041681,-0.110907,-0.05415,0.045645,-0.047693,-0.015158,0.002301,0.013445,0.003221,-0.094491,-0.030312,-0.075158,-0.023127,0.059785,-0.059902,0.10828,0.04404,-0.028868,-0.040204,-0.065322,-0.000812,0.035203,-0.050535,-0.053905,0.038224,-0.032828,0.020952,0.000917,-0.036852,0.089435,0.04008,-0.000223,0.01986,-0.042147,0.075887,-0.04691,-0.084628,0.081204,-0.085366,-0.014952,0.096323,-0.078878,-0.067478,0.052828,0.034458,-0.028256,0.054944,-0.036492,-0.077631,-0.00922,-0.061608,-0.015295,0.003234,0.072703,0.063035,0.045604,0.000176,-0.025424,0.00147,0.02204,0.075071,-0.025946,0.046041,0.011387,-0.038102,0.004798,-0.111264,-0.067917,-0.060007,0.08019,-0.028107,-0.023298,-0.027478,0.008483,0.033274,0.089311,-0.056846,0.100519,0.000336,0.041367,0.102614,0.040712,-0.050218,-0.0448,-0.010167,0.015068,-0.017708,0.019157,-0.005602,-0.015173,0.140312,-0.11762,-0.047762,0.057787,-0.014361,0.016412,-0.051089,0.058757,-0.006512,0.044152,0.104587,0.003494,0.010016,0.039835,0.025743,0.053947,0.024962,-0.029353,-0.150157]},"texture.authoritative":{"set":"texture","space":"raw","kind":"named","norm":0.650662362575531,"vector":[-0.021544,-0.031176,-0.029746,0.043648,-0.026964,0.047561,0.022202,0.003552,-0.055207,0.058843,-0.048238,0.082407,0.032682,0.042862,0.027981,0.088302,0.113783,-0.078386,0.046562,0.07237,0.084582,0.013473,-0.018486,-0.080347,0.050792,-0.02907,-0.01658,-0.017982,-0.011607,-0.005825,-0.016126,-0.034737,0.011105,0.042589,0.005386,-0.019292,0.119889,-0.02651,-0.040299,-0.05889,-0.01154,-0.012935,0.021431,-0.045239,-0.076065,-0.002908,0.001959,0.022954,-0.064545,0.026657,-0.030851,-0.074362,-0.064186,0.028752,-0.021603,-0.020301,0.03841,-0.014195,0.018374,-0.031265,0.023558,0.011848,-0.005673,0.007499,0.018472,-0.004734,-0.02651,-0.045357,-0.032103,0.074639,0.085738,0.009879,-0.010263,-0.038301,-0.13952,0.021744,0.004596,-0.004325,-0.00123,-0.035793,-0.019835,0.056687,-0.043295,-0.021021,-0.072403,-0.036784,0.083073,0.009151,-0.033435,-0.028014,0.085543,0.075176,0.001515,0.021391,-0.04863,0.038573,-0.022534,-0.078085,0.025446,0.021201,-0.041863,0.078832,-0.086905,0.029698,-0.034002,0.042367,-0.044087,-0.035893,0.004022,-0.006143,0.002639,-0.068009,-0.049847,0.084119,-0.006074,-0.02646,-0.007624,0.006164,-0.02231,-0.01434,0.058355,-0.013306,-0.005005,-0.008609,0.033602,0.086293,0.086059,0.062236,-0.043199,0.039368,0.034871,0.009702,0.035218,-0.025623,-0.012909,-0.000289,0.050414,0.034219,-0.020719,-0.021962,0.06134,-0.012887,-0.032978,-0.038832,0.013642,0.057895,-0.007708,0.030843,0.024465,0.007944,-0.01521,-0.086025,-0.027524,-0.011879,-0.035908,-0.024519,-0.054647,0.066189,0.02461,0.017895,-0.005192,-0.076882,-0.00434,-0.087648,0.072733,-0.034244,-0.021197,-0.074429,-0.128978,-0.024668,-0.04784,-0.033604,0.078224,0.055429,-0.047149,-0.101401,0.019592,-0.011416,-0.01113,-0.051286,0.074644,0.084582,-0.017746,0.013242,-0.005499,0.021313,-0.028765,0.075278,-0.029408,0.038199,0.031545,-0.065174]},"room.clean":{"set":"room","space":"raw","kind":"axis","norm":0.26050034165382385,"vector":[0.008446,-0.006763,0.002374,-0.019937,0.013268,0.021444,-0.00173,0.028674,-0.021066,-0.017813,0.00474,-0.005991,0.040936,-0.022033,-0.004508,0.009992,-0.009938,-0.01025,0.004168,0.034515,0.041322,-0.029185,-0.031095,-0.049074,0.016056,-0.004164,0.018537,0.016167,-0.014862,-0.000452,0.025788,0.011977,5.3e-05,-0.045829,0.03336,0.012984,0.016565,-0.001852,-0.014461,0.015867,-0.004298,-0.00565,-0.002065,0.009444,0.00635,0.036433,-0.012858,-0.024583,0.016854,-0.016745,0.04549,-0.0045,-0.00768,0.013906,0.000939,0.000514,0.007036,-0.012695,0.008017,-0.010422,-0.021269,-0.02938,0.023065,0.006935,-0.029682,0.002094,-0.002672,-0.015993,0.0046,0.007213,0.007137,-0.0034,0.005338,0.012029,-0.001766,0.008287,0.003137,-0.01076,0.02153,-0.005671,-0.008523,-0.03248,0.028715,-0.005016,0.005573,0.050045,-0.007985,0.018657,-0.011294,-0.00929,0.015441,-0.015257,0.008809,0.00277,0.029603,0.016845,-0.006066,0.030769,0.023431,0.0053,-0.03517,-0.022757,-0.013964,-0.003792,0.019678,0.019728,-0.045376,-0.0075,0.018464,0.017806,0.023565,0.01459,-0.024504,-0.004677,-0.000444,-0.026329,0.019151,-0.017053,-0.024676,-0.000948,0.014518,-0.012129,-0.00595,0.0017,-0.005849,-0.010866,-0.015445,-0.00229,-0.010988,0.058286,-0.004359,0.004769,-0.009167,0.011633,-0.037229,-0.006214,-0.012306,0.036522,0.026994,-0.009355,0.011591,-0.021807,0.018366,0.001452,0.030551,0.009937,0.040415,0.00887,-0.015715,-0.008278,0.004932,-0.002585,0.013071,-0.00515,0.000439,0.007853,0.004122,-0.011491,-0.020314,-0.01901,-0.009357,-0.002129,0.003209,0.0117,0.012296,0.017162,0.026123,0.01011,0.025436,0.012608,-0.017024,-0.000516,-0.022972,-0.023079,0.001656,-0.003542,0.01395,0.015549,0.007971,-0.005955,-0.024876,-0.011921,0.006332,-0.029368,-0.011594,0.005296,0.001081,-0.025453,0.024447,-0.032683,-0.023743,-0.010056]},"delivery.whisper":{"set":"delivery","space":"attnres_source","kind":"named","norm":0.04050905257463455},"delivery.loud":{"set":"delivery","space":"attnres_source","kind":"named","norm":0.017280371859669685},"delivery.tempo":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.027876699343323708},"delivery.pitch":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.03443121165037155},"delivery.conversational":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.015663625672459602},"expressive.expressive":{"set":"expressive","space":"attnres_source","kind":"axis","norm":0.00408494146540761},"disfluency.disfluent":{"set":"disfluency","space":"attnres_source","kind":"axis","norm":0.007459484040737152},"mood.valence":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.arousal":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.dominance":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.loudness":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.tempo":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.clarity":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.articulation":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"emotions.angry":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.024435274302959442},"emotions.sad":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016339104622602463},"emotions.happy":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019105473533272743},"emotions.fearful":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.020554088056087494},"emotions.disgusted":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.02019648253917694},"emotions.surprised":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019633101299405098},"emotions.adoring":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016284888610243797},"emotions.confused":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.02608228661119938},"emotions.content":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.013912038877606392},"emotions.cute":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.027364306151866913},"emotions.desirous":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01784827746450901},"emotions.disappointed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016322800889611244},"emotions.distressed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01893770880997181},"emotions.embarrassed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.018894311040639877},"emotions.ecstatic":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.025073491036891937},"emotions.guilty":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01523954700678587},"emotions.interested":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019086483865976334},"emotions.pained":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.020709918811917305},"emotions.proud":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016622088849544525},"emotions.realizing":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01693662442266941},"emotions.relieved":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01731547713279724},"emotions.serene":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.015665732324123383},"emotions.scared":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01219755969941616},"emphasis_nv_nodur.emphasis":{"set":"emphasis_nv_nodur","space":"attnres_source","kind":"named","norm":0.008683149702847004}}`),timing:{"delivery.tempo":[[-4,2.881],[-2,2.212],[-1,1.451],[0,1],[1,.779],[2,.63],[4,.549]],"delivery.conversational":[[-4,.958],[-2,.981],[-1,.99],[0,1],[1,1.008],[2,1.065],[4,1.172]],"delivery.whisper":[[0,1],[1,1.076],[2,1.121],[4,1.104]],"delivery.loud":[[0,1],[1,.988],[2,.955],[4,.945]],"disfluency.disfluent":[[-8,.903],[-4,.938],[0,1],[4,1.122],[8,1.323],[16,1.908],[32,2.754]],"expressive.expressive":[[-16,.835],[-8,.891],[-4,.957],[0,1],[4,1.062],[8,1.208],[16,1.497]]},ui:JSON.parse(`{"groups":[{"id":"who","label":"Who","hue":"c1"},{"id":"accent","label":"Accent","hue":"c2"},{"id":"texture","label":"Texture","hue":"c3"},{"id":"room","label":"Room","hue":"c4"},{"id":"delivery","label":"Delivery","hue":"c5"},{"id":"mood","label":"Mood","hue":"c6"}],"controls":[{"id":"gender","group":"who","label":"Gender","type":"bipolar","poles":["masculine","feminine"],"map":{"-":{"identity.gender":-1},"+":{"identity.gender":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.894],[1.0,0.689],[2.0,0.561],[3.0,0.473]],"effect":"±2 flips the gender of every release voice; identity drops to ~0.5"},{"id":"age","group":"who","label":"Age","type":"bipolar","poles":["younger","older"],"map":{"-":{"identity.age":-1},"+":{"identity.age":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.894],[1.0,0.818],[2.0,0.689],[3.0,0.589]],"effect":"±2 moves apparent age by 10-30 years; at −3 male voices start to read female"},{"id":"pitch","group":"who","label":"Pitch","type":"bipolar","poles":["lower","higher"],"map":{"-":{"pitch.pitch":-1},"+":{"pitch.pitch":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[1.0,0.903],[2.0,0.845],[3.0,0.749]],"effect":"±2: about −20 / +40 Hz at the same gender; +3 can flip a female voice"},{"id":"range","group":"who","label":"Intonation","type":"bipolar","poles":["monotone","varied"],"map":{"-":{"pitch.pitch_range":-1},"+":{"pitch.pitch_range":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[1.0,0.914],[2.0,0.892],[3.0,0.86]],"effect":"±2: F0 spread 2.9 → 2.1 / 4.4 semitones at the same pitch level"},{"id":"deep","group":"texture","label":"Deep","type":"unipolar","map":{"+":{"texture.deep":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.901],[4.0,0.808]],"effect":"×4: deeper and huskier, F0 −17 Hz"},{"id":"bright","group":"texture","label":"Bright","type":"unipolar","map":{"+":{"texture.shrill":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.867],[4.0,0.695]],"effect":"×4: shriller, F0 +40 Hz"},{"id":"husky","group":"texture","label":"Husky","type":"unipolar","map":{"+":{"texture.husky":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.905],[4.0,0.85]],"effect":"×4: husky 0.18 → 0.33"},{"id":"raspy","group":"texture","label":"Raspy","type":"unipolar","map":{"+":{"texture.raspy":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.852],[4.0,0.643]],"effect":"×4: raspy 0.06 → 0.34; changes the voice the most"},{"id":"soft","group":"texture","label":"Soft","type":"unipolar","map":{"+":{"texture.soft":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.881],[4.0,0.761]],"effect":"×4: softer and 7.5 dB quieter"},{"id":"authority","group":"texture","label":"Authority","type":"unipolar","map":{"+":{"texture.authoritative":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.875],[4.0,0.765]],"effect":"×4: authoritative 0.54 → 0.78"},{"id":"room","group":"room","label":"Room","type":"bipolar","poles":["phone","studio"],"map":{"-":{"room.clean":-1},"+":{"room.clean":1}},"range":[-4,6],"safe":[-2,4],"collapse":[-6,null],"spannable":false,"identity":[[0.0,0.946],[2.0,0.904],[4.0,0.86],[8.0,0.685]],"effect":"speech over the noise floor 40 dB → 28 (−2) / 58 (+4)"},{"id":"projection","group":"delivery","label":"Projection","type":"bipolar","poles":["whisper","loud"],"map":{"-":{"delivery.whisper":1},"+":{"delivery.loud":1}},"range":[-3,4],"safe":[-1.5,2],"collapse":[-3,null],"spannable":true,"identity":[[0.0,0.946],[1.0,0.9005000000000001],[2.0,0.8160000000000001],[4.0,0.6665]],"effect":"whisper ×2 halves voicing (7% WER); loud ×2 +7 dB, ×4 +16 dB"},{"id":"pace","group":"delivery","label":"Pace","type":"bipolar","poles":["slower","faster"],"map":{"-":{"delivery.tempo":-1},"+":{"delivery.tempo":1}},"range":[-3,3],"safe":[-2,2],"collapse":[-3,null],"spannable":true,"identity":[[0.0,0.946],[1.0,0.907],[2.0,0.866],[4.0,0.753]],"effect":"−1: ×1.45 longer, +2: ×0.63; fast is also louder and higher"},{"id":"chatty","group":"delivery","label":"Read ↔ chatty","type":"bipolar","poles":["read","chatty"],"map":{"-":{"delivery.conversational":-1},"+":{"delivery.conversational":1}},"range":[-5,5],"safe":[-4,4],"collapse":null,"spannable":true,"identity":[[0.0,0.946],[1.0,0.918],[2.0,0.919],[4.0,0.899]],"effect":"+4: spontaneous (hesitation 0.10 → 0.26, less enunciated); −4: careful reading"},{"id":"hesitant","group":"delivery","label":"Hesitation","type":"bipolar","poles":["fluent","hesitant"],"map":{"-":{"disfluency.disfluent":-1},"+":{"disfluency.disfluent":1}},"range":[-8,20],"safe":[-8,8],"collapse":[null,24],"spannable":true,"identity":[[0.0,0.946],[4.0,0.918],[8.0,0.911],[16.0,0.88],[32.0,0.785]],"effect":"+8: pauses and blocks (0.10 → 0.21), ×1.3 longer; +16 drops words"},{"id":"lively","group":"delivery","label":"Liveliness","type":"bipolar","poles":["flat","lively"],"map":{"-":{"expressive.expressive":-1},"+":{"expressive.expressive":1}},"range":[-16,16],"safe":[-8,8],"collapse":null,"spannable":true,"identity":[[0.0,0.946],[4.0,0.917],[8.0,0.908],[16.0,0.865]],"effect":"+8: F0 spread 2.9 → 4.3 st, higher and slower"},{"id":"emphasis","group":"delivery","label":"Emphasis","type":"unipolar","map":{"+":{"emphasis_nv_nodur.emphasis":4.0,"mood.arousal":1.0}},"range":[0,6],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.9],[3,0.892],[4,0.889],[4.5,0.889],[5,0.888],[6,0.886]],"effect":"×4.5 on one word: +6.0 st F0 peak, +65 ms, +1.6 dB; the most prominent word of the line 2 → 36% (middle / final words); the word after +0.5 dB, +2.2 st","default":4.5,"span_gate":{"lead":0.0,"lag":0.0},"span_only":true},{"id":"valence","group":"mood","label":"Valence","type":"bipolar","poles":["negative","positive"],"map":{"-":{"mood.valence":-1},"+":{"mood.valence":1}},"range":[-6,6],"safe":[-4,4],"collapse":null,"spannable":true,"identity":null,"effect":"seed dose 4 (emotion axes, L9.attn)"},{"id":"arousal","group":"mood","label":"Arousal","type":"bipolar","poles":["calm","excited"],"map":{"-":{"mood.arousal":-1},"+":{"mood.arousal":1}},"range":[-6,6],"safe":[-4,4],"collapse":null,"spannable":true,"identity":null,"effect":"seed dose 4 (emotion axes, L9.attn)"},{"id":"angry","group":"mood","label":"Angry","type":"unipolar","map":{"+":{"emotions.angry":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.785],[6,0.606],[8,0.515]],"effect":"×4: heard as angry on 17% of renders (from 0%; MSP-Podcast); more aroused (+0.35 MSP), WER 3.6%"},{"id":"happy","group":"mood","label":"Happy","type":"unipolar","map":{"+":{"emotions.happy":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.867],[6,0.74],[8,0.594]],"effect":"×4: heard as happy on 62 / 58% of renders (from 21 / 15%; emotion2vec / MSP-Podcast); more aroused (+0.17 MSP), WER 2.5%"},{"id":"sad","group":"mood","label":"Sad","type":"unipolar","map":{"+":{"emotions.sad":1}},"range":[0,8],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.899],[6,0.866],[8,0.823]],"effect":"×6: heard as sad on 29 / 12% of renders (from 2 / 0%; MSP-Podcast / emotion2vec); less aroused (−0.15 MSP), WER 2.1%"},{"id":"calm","group":"mood","label":"Calm","type":"unipolar","map":{"+":{"emotions.serene":1}},"range":[0,8],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.899],[6,0.863],[8,0.786]],"effect":"×4: heard as calm on 94% of renders (from 77%; ParaSpeechCLAP); less aroused (−0.14 MSP), WER 0.9%"},{"id":"scared","group":"mood","label":"Scared","type":"unipolar","map":{"+":{"emotions.scared":1}},"range":[0,14],"safe":[0,12],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[10,0.818],[12,0.778],[14,0.734],[16,0.711]],"effect":"×12: heard as fearful on 8% of renders (from 0%; emotion2vec); more aroused (+0.11 MSP), WER 1.5%"},{"id":"confused","group":"mood","label":"Confused","type":"unipolar","map":{"+":{"emotions.confused":1}},"range":[0,4],"safe":[0,3],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[2,0.913],[3,0.877],[4,0.796],[6,0.531],[8,0.375]],"effect":"×3: confused ranks 19 → 10 of 21 styles (ParaSpeechCLAP); less aroused (−0.03 MSP), WER 3.4%"}],"accents":[{"id":"american","label":"North America","tab":"english","region":"north_america","strength":"strong","map":{"accents_en.american":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.854],[1.5,0.808],[2.0,0.758]],"effect":"×1: North America 19 → 44% (British voices 75-88%)"},{"id":"british","label":"England","tab":"english","region":"england","strength":"strong","map":{"accents_en.british":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.871],[1.5,0.84],[2.0,0.804]],"effect":"×1.5: English 40 → 69%"},{"id":"scottish","label":"Scotland","tab":"english","region":"scotland","strength":"faint","map":{"accents_en.scottish":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.873],[1.5,0.822],[2.0,0.749]],"effect":"×1.5: Scottish 0 → 19%"},{"id":"irish","label":"Ireland","tab":"english","region":"ireland","strength":"faint","map":{"accents_en.irish":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.895],[1.5,0.851],[2.0,0.821]],"effect":"×1.5: Irish 0 → 17% (strong on some voices)"},{"id":"welsh","label":"Wales","tab":"english","region":"wales","strength":"strong","map":{"accents_en.welsh":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.866],[1.5,0.813],[2.0,0.762]],"effect":"×1.5: Welsh 19 → 60%; slows speech"},{"id":"australian","label":"Australia","tab":"english","region":"australia","strength":"strong","map":{"accents_en.australian":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.869],[1.5,0.816],[2.0,0.775]],"effect":"×1.5: Oceania 8 → 44%"},{"id":"indian","label":"India","tab":"english","region":"india","strength":"strong","map":{"accents_en.indian":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.806],[1.5,0.702],[2.0,0.616]],"effect":"×1.5: South Asia 0 → 79%"},{"id":"hin","label":"Hindi","tab":"world","region":"india","strength":"strong","map":{"accents_l1.hin":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: South Asia 82% (LoRA 58%)"},{"id":"spa","label":"Spanish","tab":"world","region":"spain","strength":"strong","map":{"accents_l1.spa":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1: Romance 69% (LoRA 70%)"},{"id":"fra","label":"French","tab":"world","region":"france","strength":"strong","map":{"accents_l1.fra":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Romance 65% (LoRA 64%)"},{"id":"por","label":"Portuguese","tab":"world","region":"portugal","strength":"strong","map":{"accents_l1.por":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1: Romance 66% (LoRA 64%)"},{"id":"deu","label":"German","tab":"world","region":"germany","strength":"strong","map":{"accents_l1.deu":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Germanic 42% (LoRA 24%)"},{"id":"vie","label":"Vietnamese","tab":"world","region":"vietnam","strength":"faint","map":{"accents_l1.vie":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Southeast Asia 21% (LoRA 17%)"},{"id":"pol","label":"Polish","tab":"world","region":"poland","strength":"faint","map":{"accents_l1.pol":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Slavic 20% (LoRA 15%)"},{"id":"mandarin","label":"Mandarin","tab":"world","region":"china","strength":"strong","map":{"mandarin.cmn":1,"mandarin_hidden.cmn":0.3333333333333333},"range":[0,1.5],"safe":[0,1.5],"identity":[[0.0,0.95],[1.0,0.71],[1.5,0.54]],"effect":"embedding ×1.5 + hidden ×0.5: East Asia 58% at 1.8% WER"}],"presets":{"BBC newsreader":{"accent:british":1.5,"authority":3,"room":2},"Elderly Scottish narrator":{"age":1.5,"accent:scottish":1.5,"deep":2,"range":-1},"Young Australian":{"age":-1.5,"accent:australian":1.5,"range":1},"Gravelly old man":{"gender":-1,"age":2,"raspy":3,"deep":2},"Soft-spoken Irish woman":{"gender":1,"accent:irish":1.5,"soft":3},"Indian English caller":{"accent:indian":1.5,"room":-2},"Chatty podcaster":{"chatty":3,"room":1,"lively":4},"Late-night radio":{"deep":2,"room":3,"pace":-0.8,"projection":-0.6}},"who":{"gender":{"control":"gender","logit_per_dose":1.31,"clip_logit":3.0},"age":{"control":"age","center_years":42.0,"years_per_dose":8.7},"landmarks":{"American Female":{"female":0.9944,"age":29.1},"American Male":{"female":0.0013,"age":52.4},"Australian Female":{"female":0.9968,"age":36.1},"British Female":{"female":0.9991,"age":52.6},"British Male":{"female":0.0099,"age":32.1},"David Attenborough":{"female":0.009,"age":72.5},"Dwarkesh":{"female":0.0022,"age":20.4},"German Accent Male":{"female":0.0121,"age":68.4},"Obama Yelling":{"female":0.0151,"age":55.7},"Obama":{"female":0.0018,"age":59.2},"Scottish Female":{"female":0.9992,"age":57.0},"Skyler":{"female":0.9921,"age":23.8}},"note":"audeering/wav2vec2-large-robust-24-ft-age-gender on the first 20 s of each release default voice: P(female) = female/(female+male), age in years. Dose calibration from eval_sweep.json (six voices, embedding mode): 1.31 logits of P(female) per gender dose, 8.7 years per age dose (median per-voice slopes)."},"moods":[{"id":"angry","label":"Angry","control":"angry","valence":0.21,"arousal":1.0,"dose":4,"effect":"×4: heard as angry on 17% of renders (from 0%; MSP-Podcast); more aroused (+0.35 MSP), WER 3.6%"},{"id":"happy","label":"Happy","control":"happy","valence":0.28,"arousal":0.86,"dose":4,"effect":"×4: heard as happy on 62 / 58% of renders (from 21 / 15%; emotion2vec / MSP-Podcast); more aroused (+0.17 MSP), WER 2.5%"},{"id":"sad","label":"Sad","control":"sad","valence":-0.32,"arousal":-0.74,"dose":6,"effect":"×6: heard as sad on 29 / 12% of renders (from 2 / 0%; MSP-Podcast / emotion2vec); less aroused (−0.15 MSP), WER 2.1%"},{"id":"calm","label":"Calm","control":"calm","valence":-0.28,"arousal":-0.69,"dose":4,"effect":"×4: heard as calm on 94% of renders (from 77%; ParaSpeechCLAP); less aroused (−0.14 MSP), WER 0.9%"},{"id":"scared","label":"Scared","control":"scared","valence":-0.09,"arousal":0.53,"dose":12,"effect":"×12: heard as fearful on 8% of renders (from 0%; emotion2vec); more aroused (+0.11 MSP), WER 1.5%"},{"id":"confused","label":"Confused","control":"confused","valence":-0.12,"arousal":-0.15,"dose":3,"effect":"×3: confused ranks 19 → 10 of 21 styles (ParaSpeechCLAP); less aroused (−0.03 MSP), WER 3.4%"}],"preview_text":"Hello there. It's lovely to finally meet you, how have you been?","request_defaults":{"speaker_mode":"embedding","stream_decode":"prefix"},"identity_threshold":0.8}`)},Tt=`opus_dual_3n_600k_sched600k_r4096_step600000`,Et=`hf://Zyphra/ZONOS3_Mini_release_ckpts/autoencoder/heads`,Dt=[{id:`keep2_plain`,kind:`istft_mr`,label:`Multi-resolution iSTFT head + linear STFT loss, KEEP-2 pruned decoder (istft_head_a_20261002/full-unfreezeall-mr-drop30-4x10-50k, final step 50,000); causal, fp32`,checkpoint:`${Et}/keep2_plain/step_0050000.pt`,expect_step:5e4,headroom_db:3,causal:!0,codec:Tt},{id:`full_mr`,kind:`istft_mr`,label:`Multi-resolution iSTFT head + linear STFT loss, decoder.0-8 unfrozen (istft_head_a_20261002/full-unfreezeall-mr-50k, final step 50,000; release copy = step + trainable state); causal, fp32`,checkpoint:`${Et}/full_mr/step_0050000.pt`,expect_step:5e4,headroom_db:3,causal:!0,codec:Tt}],Ot={note:`Default release voices with the raw-direction doses their synthetic fixture embeddings carry (embedding = seeded base orthogonal to every raw direction + Σ dose·vector). Gender and age come from ui.who's measured landmarks. Used when the server has no /v2/speakers/{id}/embedding, and as the speaker list when no server answers.`,voices:[{label:`American Female`,priors:{"pitch.pitch":.3}},{label:`American Male`,priors:{}},{label:`Australian Female`,priors:{"accents_en.australian":.8}},{label:`British Female`,priors:{"accents_en.british":.9}},{label:`British Male`,priors:{"accents_en.british":.9,"pitch.pitch":-.8}},{label:`David Attenborough`,priors:{"accents_en.british":1,"texture.raspy":1}},{label:`Dwarkesh`,priors:{"pitch.pitch_range":.6}},{label:`German Accent Male`,priors:{"accents_l1.deu":.9}},{label:`Obama`,priors:{"texture.deep":1.5}},{label:`Obama Yelling`,priors:{"room.clean":-1.5}},{label:`Scottish Female`,priors:{"accents_en.scottish":1,"pitch.pitch":.9}},{label:`Skyler`,priors:{"texture.shrill":.8}}]},P=(e,t,n)=>en?n:e;function kt(e,t){let n=0;for(let r=0;rMath.sqrt(kt(e,e));function jt(e,t){if(!e.length)return 1;if(t<=e[0][0])return e[0][1];for(let n=1;n>>0}function Nt(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Pt(e){let t=Math.max(e(),1e-12);return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e())}function Ft(e,t=1){let n=e.toFixed(t);return e>0?`+${n}`:n===(-0).toFixed(t)?0 .toFixed(t):n}var It=()=>Math.random().toString(36).slice(2,10),Lt=3.3,Rt=new Map(Ot.voices.map(e=>[e.label,e.priors])),zt=null,Bt=[];function Vt(e){if(zt===e)return Bt;Bt=[];for(let t of Object.values(e.directions)){if(!t.vector)continue;let e=Float64Array.from(t.vector);for(let t of Bt){let n=kt(e,t);for(let r=0;r1e-6&&Bt.push(e.map(e=>e/n))}return zt=e,Bt}function Ht(e,t,n){let r=Nt(Mt(t)),i=e.embedding_dim??0,a=new Float64Array(i);for(let e=0;e({id:`fixture_${p(t.label)}`,label:t.label,source_type:`audio`,scope:`default`,is_default:!0,original_name:`${t.label.replaceAll(` `,``)}.mp3`,created_at:0,has_preview:!0,speaker_modes:[`embedding`,`reference`],embedding_dim:e.embedding_dim,transcript:null,disabled_controls:[]}))}function Wt(e,t){let n=e.collapse;return n&&(n[0]!=null&&t<=n[0]||n[1]!=null&&t>=n[1])?`collapse`:t>=e.safe[0]-1e-9&&t<=e.safe[1]+1e-9?`safe`:`strong`}function Gt(e,t,n){if(t&&n)for(let[r,i]of Object.entries(t))e[r]=(e[r]??0)+i*n}function Kt(e,t,n={}){return t>0?Gt(n,e.map[`+`],t):t<0&&Gt(n,e.map[`-`],-t),n}function qt(e,t,n){let r=e.directions[t];return!!r&&(e.sets[r.set]?.modes??[]).includes(n)}function Jt(e,t,n){return(`type`in t?[t.map[`+`],t.map[`-`]]:[t.map]).every(t=>!t||Object.keys(t).every(t=>qt(e,t,n)))}function Yt(e,t,n,r){let i={};for(let n of e.ui.controls){let a=t[n.id]??0;a&&!n.span_only&&Jt(e,n,r)&&Kt(n,a,i)}for(let t of e.ui.accents){let a=n[t.id]??0;a&&Jt(e,t,r)&&Gt(i,t.map,a)}for(let e of Object.keys(i))i[e]=Math.round(i[e]*1e4)/1e4,i[e]||delete i[e];return i}function Xt(e){let t={},n={};for(let[r,i]of Object.entries(e))r.startsWith(`accent:`)?n[r.slice(7)]=i:t[r]=i;return{values:t,accents:n}}var Zt=[[0,.95],[1,.87],[1.5,.76],[2,.68]];function Qt(e,t){return jt(e,t)/(jt(e,0)||1)}function $t(e,t,n,r){let i=.95;for(let n of e.ui.controls){let a=t[n.id]??0;a&&n.identity&&Jt(e,n,r)&&(i*=Qt(n.identity,Math.abs(a)))}for(let t of e.ui.accents){let a=n[t.id]??0;a&&Jt(e,t,r)&&(i*=Qt(t.identity??Zt,a))}return P(i,0,1)}function en(e,t){return e=t+.1?`Same person`:`Close`}function tn(e){return e>=.65?`leans feminine`:e<=.35?`leans masculine`:`neutral`}function nn(e){return[{id:`phone`,label:e.poles?.[0]??`phone`,at:e.safe[0]},{id:`podcast`,label:`podcast`,at:Math.round(e.safe[1]/4*10)/10},{id:`studio`,label:e.poles?.[1]??`studio`,at:e.safe[1]}]}function rn(e,t){let n=1;for(let[r,i]of Object.entries(e.timing??{})){let e=t[r];e&&(n*=jt(i,e))}return n}function an(e,t,n){let r=Float32Array.from(t),i=!1;for(let[t,a]of Object.entries(n)){let n=e.directions[t]?.vector;if(n&&e.directions[t].space===`raw`&&a){for(let e=0;e0||!/^[aeiouy]/i.test(e),pause:t===o-1?.035:0,stress:t===0?1:.55+.3*r()})}}return n}var ln=e=>1/(1+Math.exp(-e));function un(e,t,n){let r=e.directions[n]?.vector;if(!r)return 0;let i=0,a=0;for(let e=0;eun(e,r,t),a=i(`identity.gender`),o=i(`identity.age`),s=i(`pitch.pitch`),c=i(`pitch.pitch_range`),l=i(`texture.deep`),u=i(`texture.shrill`),d=i(`texture.husky`),f=i(`texture.raspy`),p=i(`texture.soft`),m=i(`texture.authoritative`),h=i(`room.clean`),g=1,_=1,v=0;for(let[t,n]of Object.entries(e.directions)){if(n.space!==`raw`||!/^(accents_|mandarin\.)/.test(t))continue;let e=i(t);if(Math.abs(e)<.05)continue;let r=Mt(t);g*=1+e*((r&255)/255-.5)*.12,_*=1+e*((r>>8&255)/255-.5)*.14,t.startsWith(`accents_en`)||(v+=Math.abs(e)*.3)}let y=ln(a*1.8),b=108*2**(y*.9+s*.11+u*.06-l*.05-Math.max(o,0)*.04+Math.max(-o,0)*.03),x=(1+.17*y-.02*l+.02*u-.015*o)*1,S=2.6*(1+.3*c),C=.04+.07*Math.max(d,0)+.02*Math.max(p,0),w=.06*Math.max(f,0)+.01*Math.max(o,0),T=.9+.05*Math.max(p,0)-.03*Math.max(m,0),E=-1.9*Math.max(p,0)+.5*Math.max(m,0),D=cn(t.text,Mt(t.text)),O=Nt(t.seed*7919+13),ee=r=>{let i={};for(let[t,r]of Object.entries(n))e.directions[t]?.space!==`raw`&&(i[t]=r);for(let e of t.spans??[])if(r>=e.start&&r{let n=e.ui.controls.find(e=>e.id===t.control);return!n||[`angry`,`happy`,`sad`].includes(t.control)||!t.dose?[]:Object.entries(n.map[`+`]).map(([e,n])=>({dir:e,val:t.valence*6*n/t.dose,aro:t.arousal*6*n/t.dose}))});D.forEach((e,t)=>{let n=ee(e.start+e.end>>1),r=e=>n[e]??0,i=ie.reduce((e,t)=>e+t.val*r(t.dir),0),a=ie.reduce((e,t)=>e+t.aro*r(t.dir),0),o=r(`delivery.tempo`)+.06*(r(`mood.arousal`)+a)-.08*r(`emotions.sad`),s=o>=0?1+.3*o:1/(1+.45*-o),c=r(`delivery.conversational`),l=Math.max(r(`disfluency.disfluent`),0),u=r(`expressive.expressive`),d=Math.max(r(`delivery.whisper`),0),f=Math.max(r(`delivery.loud`),0),p=r(`mood.valence`)+i,m=r(`mood.arousal`)+a,h=Math.max(r(`emotions.angry`),0),y=Math.max(r(`emotions.happy`),0),w=Math.max(r(`emotions.sad`),0),ae=re/s*(1+.012*u)*(e.stress>.9?1.12:.92);ae*=1+(O()-.5)*(.12+.03*Math.max(c,0))*(1-P(v,0,.8)),l>0&&O()<.03*l&&(ae*=1.4+.05*l);let oe=t/Math.max(1,D.length-1),k=S*(1+.06*u+.15*m+.15*y-.12*w-.05*Math.max(c,0))*((e.stress-.7)*1.4+(O()-.5)*.6)-2.2*oe+.8*f+.25*u+.3*p+1.2*y-w+.5*h,se=b*2**(k/12),ce=sn[e.vowel]??sn.a,le=x*(1+.015*p+.02*f);te.push({t0:ne,dur:ae,f0:se,slope:(O()-.5)*.08-.04*oe,f:[ce[0]*le*g,ce[1]*le*_,ce[2]*le],voiced:P(1-.3*d,.04,1),gain:10**((E+3.5*f-4.5*d+.6*c+1*m+2*h-1.5*w)/20),tilt:P(T-.06*f-.05*h+.04*d,.55,.995),breath:C+.12*d+.03*h,onset:e.onset}),ne+=ae+e.pause*(1/Math.sqrt(s))+(l>0&&O()<.02*l?.18+.2*O():0)});let ae=Math.ceil((ne+.25)*on),oe=new Float32Array(ae),k=[];for(let e of t.text.matchAll(/[^\s]+/g)){let t=e.index??0,n=t+e[0].length,r=D.map((e,r)=>e.start>=t&&e.starte>=0);if(!r.length)continue;let i=te[r[0]],a=te[r[r.length-1]];k.push({word:e[0],start:i.t0,end:a.t0+a.dur})}let se=0,ce=[new Float64Array(2),new Float64Array(2),new Float64Array(2)],le=0,ue=te[0]?.f.slice()??[500,1500,2500];for(let e of te){let t=Math.floor(e.t0*on),n=Math.floor(e.dur*on),r=[0,0,0].map(()=>({b1:0,b2:0,a0:0}));for(let i=0;i=1&&--se;let c=2*se-1;if(se1-s){let e=(se-1)/s;c-=e*e+e+e+1}let l=w>.02&&se<.5&&Math.floor(i*s)&1?1-w*2:1;le=e.tilt*le+(1-e.tilt)*c*l;let u=O()*2-1,d=Math.min(1,i/(.018*on))*Math.min(1,(n-i)/(.04*on)),f=(le*6*e.voiced+u*(e.breath+(1-e.voiced)*.5))*d,p=0,m=[1,.55,.28];for(let e=0;e<3;e++){let t=r[e].a0*f+r[e].b1*ce[e][0]+r[e].b2*ce[e][1];ce[e][1]=ce[e][0],ce[e][0]=t,p+=t*m[e]}e.onset&&i<.03*on&&(p+=u*.05*(1-i/(.03*on))),oe[t+i]+=p*e.gain}}let de=1e-6;for(let e=0;e=0?40+4.5*h:40+6*h)/20),me=P(-h/2,0,1),he=0,ge=0,_e=0,ve=Math.exp(-2*Math.PI*320/on),ye=Math.exp(-2*Math.PI*3400/on),be=Nt(t.seed+1);for(let e=0;e0&&(he=ve*(he+t-ge),ge=t,_e=ye*_e+(1-ye)*he,t=t*(1-me)+Math.tanh(_e*2.2)*.6*me),oe[e]=Math.tanh((t+(be()*2-1)*pe)*1.4)/1.4}return{pcm:oe,words:k}}function fn(e,t,n){if(t===n)return e;let r=new Float32Array(Math.round(e.length*n/t)),i=t/n;for(let t=0;tfn(e.pcm,e.sr,n)),i=Math.round(t*n),a=r.reduce((e,t)=>e+t.length,0)+i*Math.max(0,r.length-1),o=new Float32Array(a),s=0;return r.forEach((e,t)=>{o.set(e,s),s+=e.length+(t\\`,`ʡ`],[`!\\`,`ǃ`],[`|\\`,`ǀ`],[`|\\|\\`,`ǁ`],[`=\\`,`ǂ`],[`:`,`ː`],[`:\\`,`ˑ`],[`_>`,`ʼ`],[`_?\\`,`ˤ`],[`_G`,`ˠ`],[`_h`,`ʰ`],[`_j`,`ʲ`],[`'`,`ʲ`],[`_l`,`ˡ`],[`_n`,`ⁿ`],[`_w`,`ʷ`],["`",`˞`],[`_T`,`˥`],[`_H`,`˦`],[`_M`,`˧`],[`_L`,`˨`],[`_B`,`˩`],[`_"`,`̈`],[`_+`,`̟`],[`_-`,`̠`],[`_/`,`̌`],[`_R`,`̌`],[`_0`,`̥`],[`=`,`̩`],[`_=`,`̩`],[`_\\`,`̂`],[`_F`,`̂`],[`_^`,`̯`],[`_}`,`̚`],[`~`,`̃`],[`_~`,`̃`],[`_A`,`̘`],[`_a`,`̺`],[`_c`,`̜`],[`_d`,`̪`],[`_e`,`̴`],[`_k`,`̰`],[`_m`,`̻`],[`_N`,`̼`],[`_O`,`̹`],[`_o`,`̞`],[`_q`,`̙`],[`_r`,`̝`],[`_t`,`̤`],[`_v`,`̬`],[`_X`,`̆`],[`_x`,`̽`],[`_`,`͡`],[`"`,``],[`%`,``],[`.`,``],[`-\\`,``],[` `,``]],gn=new Map(hn),_n=new Map;for(let[e,t]of hn)t&&!_n.has(t)&&_n.set(t,e);var vn=Math.max(...hn.map(([e])=>e.length)),yn=/[ˈˌ.\s‿]/gu;function bn(e){let t=``;for(let n=0;n0&&!gn.has(e.slice(n,n+r));)r--;r?(t+=gn.get(e.slice(n,n+r)),n+=r):t+=e[n++]}return t.normalize(`NFC`).replace(yn,``)}function xn(e){let t=[];for(let n of e.normalize(`NFC`).replace(yn,``)){let e=_n.get(n);if(e!==void 0)t.push(e);else for(let e of n.normalize(`NFD`))t.push(_n.get(e)??e)}let n=``;return t.forEach((e,r)=>{if(e===`_`){let n=`_`+t.slice(r+1,r+vn).join(``);for(let t=Math.min(vn,n.length);t>1;t--)if(gn.has(n.slice(0,t))){e=`͡`;break}}n+=e}),n}function Sn(e,t){let n=t?new Set(t.symbols):null,r=[],i=[],a=0;for(;a=0&&s!n.has(e)):[],d={start:a,end:o+1,body:c,ipa:l,unknown:u,empty:!l};r.push(d),d.empty?i.push({at:a,text:`“()” at ${a+1} is empty`}):u.length&&i.push({at:a,text:`(${c}): no token on this model for ${u.map(e=>`“${e}”`).join(` `)}`}),a=o+1}return{groups:r,issues:i}}function Cn(e,t){if(!t)return null;let{issues:n}=Sn(e,t);return n.length?`Pronunciation: ${n.map(e=>e.text).join(`; `)}.`:null}function wn(e,t){if(!t)return{text:e,map:e=>e};let{groups:n}=Sn(e,t);if(!n.length)return{text:e,map:e=>e};let r=``,i=0,a=[];for(let o of n){o.start>i&&(a.push({d0:i,d1:o.start,s0:r.length,s1:r.length+o.start-i,group:!1}),r+=e.slice(i,o.start));let n=o.empty?e.slice(o.start,o.end):t.open_marker+o.ipa+t.close_marker;a.push({d0:o.start,d1:o.end,s0:r.length,s1:r.length+n.length,group:!o.empty}),r+=n,i=o.end}return a.push({d0:i,d1:e.length,s0:r.length,s1:r.length+e.length-i,group:!1}),r+=e.slice(i),{text:r,map:(e,t)=>{for(let n of a)if(!(en.d1))return n.group?e===n.d0?n.s0:e===n.d1?n.s1:t<0?n.s0:n.s1:n.s0+(e-n.d0);return r.length}}}var Tn={ʃ:`sh`,ʒ:`zh`,θ:`th`,ð:`th`,ŋ:`ng`,ʧ:`ch`,ʤ:`j`,ə:`i`,ɪ:`i`,i:`ee`,ɛ:`e`,æ:`a`,ɑ:`a`,ɒ:`o`,ɔ:`o`,ʊ:`u`,u:`oo`,ʌ:`u`,ɜ:`er`,ɝ:`er`,ɚ:`er`,ɹ:`r`,ɾ:`t`,j:`y`,ɡ:`g`,ɫ:`l`,ʔ:``,ɐ:`a`,ø:`eu`,œ:`eu`,y:`u`};function En(e){let t=``;for(let n of e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/t͡?ʃ/g,`ʧ`).replace(/d͡?ʒ/g,`ʤ`)){let e=Tn[n];e===void 0?/[a-z]/.test(n)&&(t+=n):t+=e}return t||`uh`}function Dn(e,t=[]){let{groups:n}=Sn(e,null),r=``,i=0;return n.forEach((n,a)=>{n.empty||(r+=e.slice(i,n.start)+(t[a]?.trim()||En(n.ipa)),i=n.end)}),r+e.slice(i)}var On=[`laugh`,`breath`,`sigh`,`cough`,`panting`,`shouting`,`crying`],kn=[`shouting`,`crying`],An={laugh:{label:`laugh`,weak:!1,note:`a laugh; clearest with tag strength above 1`},breath:{label:`breath`,weak:!1,note:`an audible breath`},sigh:{label:`sigh`,weak:!1,note:`a sigh`},cough:{label:`cough`,weak:!0,note:`weak: the model barely reacts to it (measured ≈ no effect)`},panting:{label:`panting`,weak:!1,note:`panting breaths`},shouting:{label:`shouting`,weak:!0,note:`weak: measured no better than without the tag`},crying:{label:`crying`,weak:!0,note:`weak: measured no better than without the tag`}},jn=/<(\/?)([a-z]+)\s*(\/?)>/g,Mn=new Set(On);function Nn(e,t=Mn){let n=[],r=[],i=[],a=[];for(let o of e.matchAll(jn)){let[e,s,c,l]=o;if(!t.has(c)||s&&l)continue;let u={start:o.index,end:o.index+e.length,name:c,kind:l?`point`:s?`close`:`open`};if(u.kind===`point`)n.push(u);else if(u.kind===`open`)a.push(u);else{let e=a.findLastIndex(e=>e.name===u.name);if(e<0){i.push({at:u.start,text:` closes no <${u.name}>`});continue}let[t]=a.splice(e,1);n.push(t,u),r.push({name:u.name,open:t,close:u})}}for(let e of a)i.push({at:e.start,text:`<${e.name}> is never closed`});return n.sort((e,t)=>e.start-t.start),{tokens:n,spans:r,issues:i}}var Pn=e=>Nn(e).tokens.length>0;function Fn(e){let{tokens:t}=Nn(e);if(!t.length)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start),r=i.end;return(n+e.slice(r)).replace(/ {2,}/g,` `).replace(/ ([,.!?;:])/g,`$1`).trim()}var In=e=>!!e&&/[\p{L}\p{N}'’)]/u.test(e);function Ln(e,t,n){let r=`<${n}/>`,i=In(e[t-1])||/[,.!?;:]/.test(e[t-1]??``)?` `:``,a=In(e[t])?` `:``,o=i+r+a;return{start:t,end:t,insert:o,caret:t+o.length}}function Rn(e,t,n){let r=Math.max(0,Math.min(t,n)),i=Math.min(e.length,Math.max(t,n));for(;rr&&/\s/.test(e[i-1]);)i--;for(;r>0&&In(e[r-1]);)r--;for(;i${e.slice(i,a)}`;return{start:i,end:a,insert:o,caret:i+o.length}}var Bn=e=>e.replace(/ {2,}/g,` `).replace(/^ | $/g,``);function Vn(e,t){let{spans:n}=Nn(e),r=t.kind===`point`?null:n.find(e=>e.open.start===t.start||e.close.start===t.start);return Bn(r?e.slice(0,r.open.start)+e.slice(r.open.end,r.close.start)+e.slice(r.close.end):e.slice(0,t.start)+e.slice(t.end))}function Hn(e,t){let n=e.slice(t.open.end,t.close.start);return e.slice(0,t.open.start)+`<${t.name}/> `+n.replace(/^ /,``)+e.slice(t.close.end)}function Un(e,t){let n=e.slice(0,t.start)+e.slice(t.end),r=t.start,i=r;for(;i${n.slice(a,o)}`+n.slice(o))}var Wn=/[\u2018\u2019\u201b\u02bc]/g,Gn=/[^\p{L}\p{N}']+/gu,Kn=/[\u3005\u3007\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\u3040-\u30ff\u31f0-\u31ff\uff66-\uff9f]+/gu,qn=new Intl.Segmenter(`und`,{granularity:`word`}),Jn=/[\p{L}\p{N}']/u;function Yn(e){let t=[];for(let n of e.matchAll(Kn))for(let e of qn.segment(n[0]))e.isWordLike&&t.push(n.index+e.index);return t}function Xn(e){return e.replace(Wn,`'`).replace(/_/g,` `).toUpperCase().replace(Gn,` `).trim().split(/\s+/).filter(Boolean).flatMap(e=>{let t=new Set([0,e.length,...Yn(e)]);for(let n of e.matchAll(Kn))t.add(n.index+n[0].length);let n=[...t].sort((e,t)=>e-t);return n.slice(1).map((t,r)=>e.slice(n[r],t))})}function Zn(e,t){let n=new Set(Yn(e));for(let t of e.matchAll(Kn)){let r=t.index+t[0].length,i=e.slice(r).search(Jn);i>=0&&n.add(r+i)}let r=[...new Set([0,...n,e.length])].sort((e,t)=>e-t),i=[];for(let n=0;n+1e.startsWith(Qn),nr=``,rr=e=>e.startsWith(nr);function ir(e,t){let n=new Map;for(let t of Nn(e).tokens)n.set(t.start,{end:t.end,token:nr+e.slice(t.start,t.end)});if(t)for(let t of Sn(e,null).groups)t.empty||n.set(t.start,{end:t.end,token:Qn+t.ipa+$n});if(e.includes(Qn))for(let t of e.matchAll(er))n.set(t.index??0,{end:(t.index??0)+t[0].length,token:t[0]});if(!n.size)return[...e.matchAll(/\S+/g)].flatMap(e=>Zn(e[0],e.index??0));let r=[],i=0;for(;ie.tokens)}function or(e){return ir(e,!1).map(t=>e.slice(t.from,t.to))}function sr(e,t){let n=new Map;t.forEach((e,t)=>{let r=n.get(e);r?r.push(t):n.set(e,[t])});let r=(t,r,i,a)=>{let o=t,s=i,c=0,l=new Map;for(let u=t;u=a)break;let e=(l.get(r-1)??0)+1;t.set(r,e),e>c&&(o=u-e+1,s=r-e+1,c=e)}l=t}return[o,s,c]},i=[],a=[[0,e.length,0,t.length]];for(;a.length;){let[e,t,n,o]=a.pop(),[s,c,l]=r(e,t,n,o);l&&(i.push([s,c,l]),ee[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let o=[],[s,c,l]=[0,0,0];for(let[e,t,n]of i)s+l===e&&c+l===t?l+=n:(l&&o.push([s,c,l]),[s,c,l]=[e,t,n]);l&&o.push([s,c,l]),o.push([e.length,t.length,0]);let u=new Int32Array(e.length).fill(-1),d=[],f=0,p=0;for(let[e,t,n]of o){(f=0&&(i[e]=!1);for(let t of n)for(let n=0;t.i1+ne.tokens.map(()=>[e.from,e.to]))}function ur(e,t,n,r,i,a,o){let s=n===null?0:(Math.min(n,e)+e)/2,c=r===null?o/a:(t+Math.max(r,t))/2,l=Math.floor(Math.max(e-i,s)*a+1e-6);n!==null&&l/ar+1e-6&&(u=Math.max(Math.floor(r*a+1e-6),Math.round(t*a))),l=Math.min(o-1,Math.max(0,l)),[l,Math.max(l+1,Math.min(o,u))]}function dr(e,t,n){let r=n.minGapFrames??5,i=e.flatMap(e=>e.tokens.map(t=>({t,w:e}))),a=i.map(e=>e.t),o=ar(t,n.groups),s=Math.ceil(n.duration*n.frameRate-1e-6),{changes:c,equalMap:l}=sr(a,o),u=lr(t,n.groups),d=[],f=[];for(let e of c){let{i1:a,i2:o,j1:c,j2:l}=e,p,m,h,g;if(a!==o){p=i[a].w.start,m=i[o-1].w.end;for(let e=a-1;e>=0&&!h;e--)i[e].w!==i[a].w&&(h=i[e].w);for(let e=o;e0?i[a-1].w:void 0,g=ae.tokens.forEach(()=>a.push(t)));let o=lr(n,r),s=[];for(let i of e){let e=pr(a.slice(i.i1,i.i2),e=>e,e=>t[e].word),c=e=>n.slice(e[0],e[1]),l=pr(o.slice(i.j1,i.j2),e=>e[0],r?e=>c(e).replace(/\(([^()]*)\)/g,(e,t)=>`/${bn(t)}/`):c);i.i1!==i.i2&&i.j1!==i.j2?s.push(`${e} → ${l}`):i.j1===i.j2?i.i1!==i.i2&&s.push(`− ${e}`):s.push(`+ ${l}`)}let c=s.join(` · `);return c.length>i?c.slice(0,i-1)+`…`:c}function hr(e,t){if(e===t)return 1;let n=e.length,r=t.length;if(!n||!r)return 0;let i=Array.from({length:r+1},(e,t)=>t);for(let a=1;a<=n;a++){let n=[a];for(let o=1;o<=r;o++)n[o]=Math.min(i[o]+1,n[o-1]+1,i[o-1]+(e[a-1]===t[o-1]?0:1));i=n}return 1-i[r]/Math.max(n,r)}var gr=.6;function _r(e,t,n){if(n=n.filter(t=>!rr(e[t])),!n.length)return[];let r=ar(t),{equalMap:i}=sr(e,r),a=new Set;for(let e of i)e>=0&&a.add(e);let o=n.every(t=>e[t].length<=2),s=[];for(let t of n){if(i[t]>=0||!o&&e[t].length<=2)continue;let n=0;for(let e=t-1;e>=0;e--)if(i[e]>=0){n=i[e]+1;break}let c=r.length;for(let n=t+1;n=0){c=i[n];break}let l=-1,u=gr,d=tr(e[t]);for(let i=n;i=u&&(u=n,l=i)}l>=0?a.add(l):s.push(t)}return s}function vr(e,t,n,r=!1){let i=e.flatMap(e=>e.tokens.map(()=>e)),{equalMap:a}=sr(e.flatMap(e=>e.tokens),ar(t,r));return n.map(e=>{let t=new Set;for(let n of e.changes)for(let e=n.j1;e{let i=(n.start+n.end)/2;i>=e.start&&i=0&&t.add(a[r])}),[...t].sort((e,t)=>e-t)})}function yr(e,t,n,r){let i=(t,n)=>{if(t<=0)return 0;if(t>=r)return r;let i=e.findIndex(e=>e.start=0){let t=e[i+n],a=n<0?e[i].start:e[i].end;return t?(a+(n<0?t.end:t.start))/2:n<0?0:r}let a=e.filter(e=>e.end<=t).pop(),o=e.find(e=>e.start>=t);return a&&o?(a.end+o.start)/2:t},a=[];for(let[e,r]of t){let t=i(e-n,-1),o=i(r+n,1),s=a[a.length-1];s&&t<=s[1]?s[1]=Math.max(s[1],o):a.push([t,o])}return a}var br=44100,xr=new Map,Sr=new Map,Cr=e=>Math.round(e*1e3);function wr(e,t){let n=Cr(t);return e.get(n)??e.get(n-1)??e.get(n+1)}var Tr=/\ue000([^\ue000\ue001]*)\ue001/g,Er=e=>e.replace(Tr,(e,t)=>En(t));function Dr(e,t,n){let r=e=>Er(e).replace(/[\ue000\ue001]/g,``);xr.set(Cr(e.length/t),{...n,text:r(n.text),words:n.words.map(e=>({...e,word:r(e.word)})).filter(e=>e.word)})}function Or(e){let t;try{t=D(h(e))}catch{throw new v(400,`audio_base64 could not be decoded (the fixture reads WAV only).`)}return{...t,duration:t.pcm.length/t.sr}}function kr(e,t){let{promise:n,resolve:r,reject:i}=Promise.withResolvers();t?.aborted&&i(new DOMException(`Aborted`,`AbortError`));let a=setTimeout(r,e);return t?.addEventListener(`abort`,()=>{clearTimeout(a),i(new DOMException(`Aborted`,`AbortError`))}),n}var Ar=(e,t)=>e.map((e,n)=>({word:e.word,start:jr(e.start),end:jr(e.end),confidence:t(n),tokens:ar(e.word)})),jr=e=>Math.round(e*1e3)/1e3;function Mr(e,t,n){let r=Math.round(t*.01),i=Math.floor(e.length/r),a=new Float32Array(i),o=1e-6;for(let t=0;tc&&a[l]ar(e).join(``).length+.6),f=d.reduce((e,t)=>e+t,0),p=[c],m=0;for(let e=0;e{let n=p[t],r=p[t+1];for(;nn+2&&a[r-1]s);return{word:e,start:jr(n*.01),end:jr(r*.01),confidence:Math.round((.55+.4*(i/Math.max(1,r-n)))*100)/100,tokens:ar(e)}})}var Nr=`so this is a quick recording to try the editor and see how it copes when a few words change in the middle of a sentence then I keep talking for a little while longer so there is enough audio to work with and maybe a second idea at the end`,Pr={a:`the`,the:`a`,to:`too`,for:`four`,I:`eye`,when:`then`,how:`now`,read:`red`,line:`lime`,short:`sort`,sound:`found`},Fr=e=>{if(!ee.includes(e))throw new v(400,`Speech editing does not serve language '${e}' (supported: ${ee.join(`, `)}).`)},Ir=e=>new v(503,`Speech recognition is not available on this server: ${e}`),Lr=!1;async function Rr(e){Lr||=(await kr(2500,e),!0)}async function zr(e,t,n=`en_us`,r){if(!e.edit_transcribe)throw Ir(`send the transcript to /v2/edit/align instead`);Fr(n),await Rr();let{pcm:i,sr:a,duration:o}=Or(t);if(o>150)throw new v(400,`Alignment supports clips up to 150 s (this one is ${o.toFixed(1)} s).`);await kr(500+o*40,r);let s=wr(xr,o),c;if(s){let e=Nt(Mt(s.text)),t=Math.floor(e()*s.words.length);c=Ar(s.words,n=>n===t?.34:.88+e()*.11).map((e,n)=>{if(n!==t)return e;let r=e.word.replace(/[^\p{L}']/gu,``),i=Pr[r]??Pr[r.toLowerCase()]??r.slice(0,Math.max(1,r.length-1));return{...e,word:e.word.replace(r,i),tokens:ar(i)}})}else{let e=Math.max(2,Math.round(o*2.6)),t=Nr.split(` `);c=Mr(i,a,Array.from({length:e},(e,n)=>t[n%t.length]).join(` `))}let l=c.map(e=>e.word).join(` `);return Sr.set(Cr(o),c),{text:l,duration:jr(o),words:c}}async function Br(e,t,n=`en_us`,r){Fr(n);let{pcm:i,sr:a,duration:o}=Or(e);if(o>150)throw new v(400,`Alignment supports clips up to 150 s (this one is ${o.toFixed(1)} s).`);if(!ar(t).length)throw new v(400,`text has no words to align.`);await kr(300+o*25,r);let s=wr(xr,o),c=or(t.trim()),l;return l=s&&s.words.length===c.length?Ar(s.words,()=>.95).map((e,t)=>({...e,word:c[t],tokens:ar(c[t])})):Mr(i,a,t.trim()),Sr.set(Cr(o),l),{text:t.trim(),duration:jr(o),words:l}}function Vr(e,t,n,r){if(n.original_words){if(!n.original_text)throw new v(400,`original_words requires original_text.`);if(n.original_words.flatMap(e=>e.tokens??ar(e.word)).join(` `)!==ar(n.original_text).join(` `))throw new v(400,`original_words do not spell original_text.`);n.original_words.forEach((e,t)=>{if(!(Number.isFinite(e.start)&&Number.isFinite(e.end)&&e.startr+.001)throw new v(400,`original_words[${t}] is outside the clip.`);if(t&&e.startt.edit_max_spans)throw new v(400,`At most ${t.edit_max_spans} spans per edit (got ${i.length}).`);if(r>t.edit_max_seconds)throw new v(400,`Edits support clips up to ${t.edit_max_seconds} s (this one is ${r.toFixed(1)} s).`);if(i.forEach(([e,t],n)=>{if(!(e>=0&&t>e&&t<=r+.001))throw new v(400,`span ${n} [${e}, ${t}] is outside the audio (0..${r.toFixed(2)} s).`);if(n&&e4)throw new v(400,`num_takes must be 1-4.`);for(let t of[n.controls,...n.region_controls??[]])for(let r of Object.keys(t??{})){let t=e.directions[r];if(!t)throw new v(400,`Unknown control direction '${r}'.`);if(t.space===`raw`&&n.speaker_embedding===!1)throw new v(400,`Control ${r} moves the speaker embedding and needs speaker_embedding.`)}}function Hr(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n??{}))t[e]=(t[e]??0)+r;return t}function Ur(e,t,n,r){let i=e.flatMap(e=>e.tokens.map(()=>e)),{equalMap:a}=sr(e.flatMap(e=>e.tokens),ar(t)),o=lr(t),s=-1,c=o.length;i.forEach((e,t)=>{let i=(e.start+e.end)/2;i=0&&(s=a[t]),i>r&&a[t]>=0&&c===o.length&&(c=a[t])});let l=[],u=-1;for(let e=s+1;et[n]?.ipa===e[1]?t[n++]:{ipa:e[1],heard:null})}async function Kr(e,t,n,r){if(n.verify&&!t.edit_transcribe)throw Ir(`set verify to false`);Fr(n.language??`en_us`),n.verify&&await Rr(r);let i=Or(n.audio_base64);Vr(e,t,n,i.duration);let a=t.edit_frame_rate,o=(n.spans??[]).map(([e,t])=>[Math.floor(e*a)/a,Math.min(i.duration,Math.ceil(t*a)/a)]),s=n.original_words?n.original_words.map(e=>({word:e.word,start:e.start,end:e.end,confidence:1,tokens:e.tokens??ar(e.word)})):wr(Sr,i.duration)??(await Br(n.audio_base64,n.original_text||n.target_text)).words,c=i.duration>(n.max_context_seconds??16)?yr(s,o,n.context_seconds??4,i.duration).map(([e,t])=>[jr(e),jr(t)]):[],l=wr(xr,i.duration),u=l?.embedding??Ht(e,`edit-${Cr(i.duration)}`,``),d=fn(i.pcm,i.sr,br),f=n.num_takes??1,p=n.seed??Math.floor(Math.random()*1e5);await kr(700+320*f+o.length*150,r);let m=o.map(([e,t])=>Ur(s,n.target_text,e,t)),h=e=>ar(e).filter(e=>!rr(e)).join(``).replace(/[\ue000\ue001]/g,``).length,g=o.map(([e,t],n)=>{let r=s.filter(n=>(n.start+n.end)/2>=e&&(n.start+n.end)/2e.word).join(` `);return jr((t-e)*(h(m[n])/Math.max(1,h(r)||h(m[n]))))}),v=ar(n.target_text),y=[];for(let t=0;t{let _=Math.round(t*br),v=Math.round(o*br),y=d.subarray(x,_),w=S/br-x/br;for(let e of s){let n=(e.start+e.end)/2;n>=x/br&&ne[1]);if(ee)E=new Float32Array(Math.round(br*.07));else if(T){let t=Fn(T),i=dn(e,{text:O?`${t} ${t} ${t}`:t,embedding:u,controls:Hr(l?.controls,n.controls,n.region_controls?.[p]),seed:r}),a=Math.max(0,Math.round(((i.words[0]?.start??.1)-.05)*br)),o=Math.min(i.pcm.length,Math.round(((i.words[i.words.length-1]?.end??0)+.06)*br));E=i.pcm.slice(a,Math.max(a+1,o)),D=i.words.map(e=>({...e,start:e.start-a/br,end:e.end-a/br}))}else E=new Float32Array(Math.round(br*(.08+.06*i())));let ne=(S-C)/br;for(let e of D)g.push({word:e.word,start:jr(ne+e.start),end:jr(ne+e.end),confidence:.9,tokens:ar(e.word)});let re=g.length-D.length;for(let e of te){let t=En(e),n=g.findIndex((e,n)=>n>=re&&e.word.replace(/[^\p{L}']/gu,``)===t);b.push({ipa:e,at:ee?-1:n}),n>=0&&(re=n+1)}a.push(E),S+=E.length-C,c.push([jr(Math.max(0,ne)),jr(ne+E.length/br)]),f.push(jr(E.length/br)),h.push(!O),x=v});let w=S/br-x/br;for(let e of s)(e.start+e.end)/2>=x/br&&g.push({...e,start:jr(Math.max(x/br,e.start)+w),end:jr(e.end+w)});a.push(d.subarray(x));let T=Wr(a,C),E=g.map(e=>e.word),D=g.map((e,t)=>c.some(([t,n])=>e.start>=t-.001&&e.end<=n+.001)?t:-1).filter(e=>e>=0);if(D.length&&Mt(`asr${r}`)%3==0){let e=D[Math.floor(i()*D.length)];E[e]=Pr[E[e].replace(/[^\p{L}']/gu,``)]??`uh`}else if(D.length&&r%13==3){let e=D[D.length-1];E[e]=E[e].replace(/[aeiou](?=[^aeiou]*$)/i,e=>e.toLowerCase()===`e`?`a`:`e`)}let O=E.join(` `).replace(/[^\p{L}\p{N}'\s]/gu,``).toLowerCase(),ee=ar(O),ne=cr(v,ee).filter(Boolean).length,re=Math.round(Math.max(ne,Math.abs(v.length-ee.length))/Math.max(1,v.length)*1e3)/1e3;Dr(T,br,{text:Er(n.target_text.trim()),words:g,embedding:u,controls:l?.controls}),Sr.set(Cr(T.length/br),g),y.push({seed:r,audio_base64:_(te(T,br).buffer),duration:jr(T.length/br),edited_regions:c,fill_seconds:f,stopped:h,verify:n.verify?{asr_text:O,wer:re,cer:Math.round(re*600)/1e3,...n.target_text.includes(``)?{groups:Gr(n.target_text,b.map(e=>({ipa:e.ipa,heard:e.at>=0&&E[e.at].replace(/[^\p{L}\p{N}']/gu,``).toLowerCase()||null})))}:{}}:null,words:n.verify?g:null})}return{sample_rate:br,original_text:n.original_text??s.map(e=>e.word).join(` `),target_text:n.target_text.trim(),words:s,spans:o,contexts:c.length?c:null,expected_seconds:n.original_text?g:null,takes:y}}var qr={siobhan:`ʃəvɔːn`,worcestershire:`wʊstɚʃɚ`,hello:`həloʊ`,there:`ðɛɹ`,how:`haʊ`,are:`ɑɹ`,you:`ju`,today:`tədeɪ`,welcome:`wɛlkəm`,back:`bæk`,to:`tu`,the:`ðə`,late:`leɪt`,show:`ʃoʊ`,tonight:`tənaɪt`,story:`stɔɹi`,starts:`stɑɹts`,somewhere:`sʌmwɛɹ`,quiet:`kwaɪət`,little:`lɪtəl`,after:`æftɚ`,midnight:`mɪdnaɪt`,good:`ɡʊd`,evening:`ivnɪŋ`,and:`ænd`,lovely:`lʌvli`,finally:`faɪnəli`,meet:`mit`,been:`bɪn`,caramel:`kɛɹəmɛl`,nike:`naɪki`,gnocchi:`njɑki`,quinoa:`kinwɑ`,tsk:`ǀ`,brr:`ʙ`},Jr={read:`ɹid`,live:`lɪv`,lead:`lid`,wind:`wɪnd`,tear:`tɛɹ`,bass:`beɪs`,gif:`ɡɪf`,route:`ɹut`},Yr=[[/^tch/,`tʃ`],[/^ch/,`tʃ`],[/^sh/,`ʃ`],[/^th/,`θ`],[/^ng/,`ŋ`],[/^ph/,`f`],[/^ck/,`k`],[/^qu/,`kw`],[/^ee/,`i`],[/^ea/,`i`],[/^oo/,`u`],[/^ou/,`aʊ`],[/^ow/,`aʊ`],[/^ai/,`eɪ`],[/^ay/,`eɪ`],[/^oa/,`oʊ`],[/^igh/,`aɪ`],[/^a/,`æ`],[/^e/,`ɛ`],[/^i/,`ɪ`],[/^o/,`ɑ`],[/^u/,`ʌ`],[/^y$/,`i`],[/^y/,`j`],[/^c(?=[eiy])/,`s`],[/^c/,`k`],[/^g(?=[eiy])/,`dʒ`],[/^g/,`ɡ`],[/^j/,`dʒ`],[/^q/,`k`],[/^r/,`ɹ`],[/^x/,`ks`],[/^([bdfhklmnpstvwz])\1?/,`$1`]];function Xr(e){let t=e.toLowerCase().replace(/[^a-z]/g,``),n=``;for(;t;){let e=Yr.find(([e])=>e.test(t));if(!e){t=t.slice(1);continue}let r=t.match(e[0]);n+=e[1].replace(`$1`,r[1]??``),t=t.slice(r[0].length)}return n}function Zr(e){let{promise:t,resolve:n}=Promise.withResolvers();return setTimeout(n,e),t}async function Qr(e,t,n,r){if(!e.phonemize_enabled)throw new v(404,`This server has no pronunciation lexicon.`);if(!e.phonemize_languages.includes(n))throw new v(400,`No pronunciation lexicon for ${n}.`);await Zr(120);let i=r&&e.phonemize_guess_languages.includes(n),a=e.phoneme_tokens?new Set(e.phoneme_tokens.symbols):null,o=[];for(let e of t.matchAll(/([\p{L}']+)|([^\p{L}']+)/gu)){if(e[2]){o.push({text:e[2],ipa:null,status:null});continue}let t=e[1],n=t.toLowerCase(),r,s=null;qr[n]?[r,s]=[`ok`,qr[n]]:Jr[n]?[r,s]=i?[`guessed`,Jr[n]]:[`ambiguous`,null]:t.length===1&&!/[aiAI]/.test(t)?r=`skipped`:i?[r,s]=[`guessed`,Xr(t)]:r=`unknown`,s&&a&&![...s].every(e=>a.has(e))&&([r,s]=[`unsupported`,null]),o.push({text:t,status:r,ipa:s})}return{language:n,segments:o}}function $r(e,t){let n=t?.open_marker??``,r=t?.close_marker??``;if(!e.includes(n)&&!e.includes(r))return;if(!t)throw new v(400,`This checkpoint has no phoneme tokens: remove the U+E000 / U+E001 pronunciation groups`);let i=new Set(t.symbols),a=0;for(;a=0?e.slice(t+1,o):``;if(o<0||!s||s.includes(n))throw new v(400,`Pronunciation groups: Unbalanced or empty phoneme group`);let c=[...new Set(s)].filter(e=>!i.has(e));if(c.length)throw new v(400,`Pronunciation groups: Phones outside the inventory: ${JSON.stringify(c.sort())}`);a=o+1}}var ei=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ti(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=new Uint32Array(64),r=e.length,i=r-r%64,a=new Uint8Array(r%64<56?64:128);a.set(e.subarray(i)),a[r-i]=128;let o=new DataView(a.buffer);o.setUint32(a.length-8,Math.floor(r/536870912)),o.setUint32(a.length-4,r<<3>>>0);let s=(e,r)=>{for(let t=0;t<16;t++){let i=r+t*4;n[t]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}for(let e=16;e<64;e++){let t=n[e-15],r=n[e-2],i=(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,a=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10;n[e]=n[e-16]+i+n[e-7]+a|0}let i=t[0],a=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7];for(let e=0;e<64;e++){let t=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),r=d+t+(c&l^~c&u)+ei[e]+n[e]|0,f=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&a^i&o^a&o)|0;d=u,u=l,l=c,c=s+r|0,s=o,o=a,a=i,i=r+f|0}t[0]+=i,t[1]+=a,t[2]+=o,t[3]+=s,t[4]+=c,t[5]+=l,t[6]+=u,t[7]+=d};for(let t=0;te.toString(16).padStart(8,`0`)).join(``)}var ni=e=>/^[0-9a-f]{64}$/.test(e);async function ri(e){if(!globalThis.crypto?.subtle)return ti(e);let t=new Uint8Array(await crypto.subtle.digest(`SHA-256`,e));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function ii(e){let t=597399067,n=2869860233,r=951274213,i=2716044179,a=(e,t)=>e<>>32-t,o=e.length,s=o>>>4,c=e.byteOffset%4==0?new Uint32Array(e.buffer,e.byteOffset,s*4):new Uint32Array(e.slice(0,s*16).buffer),l=0,u=0,d=0,f=0;for(let e=0;e=p;t--)m[t-p>>>2]^=e[t]<<(t-p&3)*8;let h=o&15;h>12&&(f^=Math.imul(a(Math.imul(m[3],i),18),t)),h>8&&(d^=Math.imul(a(Math.imul(m[2],r),17),i)),h>4&&(u^=Math.imul(a(Math.imul(m[1],n),16),r)),h>0&&(l^=Math.imul(a(Math.imul(m[0],t),15),n)),l^=o,u^=o,d^=o,f^=o,l=l+u+d+f|0,u=u+l|0,d=d+l|0,f=f+l|0;let g=e=>(e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e^e>>>16);return l=g(l),u=g(u),d=g(d),f=g(f),l=l+u+d+f|0,u=u+l|0,d=d+l|0,f=f+l|0,[l,u,d,f].map(e=>(e>>>0).toString(16).padStart(8,`0`)).join(``)}function ai(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e.onsuccess=()=>n(e.result),e.onerror=()=>r(e.error),t}function oi(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e.oncomplete=()=>n(),e.onerror=()=>r(e.error),e.onabort=()=>r(e.error??new DOMException(`Transaction aborted`,`AbortError`)),t}function si(e,t,n){let{promise:r,resolve:i,reject:a}=Promise.withResolvers();if(typeof indexedDB>`u`)return a(Error(`This browser has no IndexedDB`)),r;let o=indexedDB.open(e,t);return o.onupgradeneeded=()=>n(o.result),o.onsuccess=()=>i(o.result),o.onerror=()=>a(o.error),o.onblocked=()=>a(Error(`Another tab holds an older version of the studio’s storage open: close it and reload`)),r}var ci=class extends Error{status;detail;body;constructor(e,t,n={}){super(t),this.status=e,this.detail=t,this.body=n}},li=null,ui=()=>li??=si(`zvs-fixture-server`,1,e=>{e.createObjectStore(`projects`,{keyPath:`id`}),e.createObjectStore(`media`,{keyPath:`hash`})}),di=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/,fi=/^[0-9a-f]{64}$/;function pi(e){if(!di.test(e))throw new ci(400,`invalid project id`)}var mi=e=>Object.keys(e?.media??{}),hi=(e,t)=>mi(e).reduce((e,n)=>e+(t.get(n)??0),0),gi=async e=>new Map((await ai(e.objectStore(`media`).getAll())).map(e=>[e.hash,e.size]));async function _i(){let e=(await ui()).transaction([`projects`,`media`]),[t,n]=await Promise.all([ai(e.objectStore(`projects`).getAll()),gi(e)]);return t.map(e=>({id:e.id,name:e.name,updated_at:e.updated_at,revision:e.revision,bytes:e.json.length,media_bytes:hi(e.data,n),summary:e.data.summary??null})).sort((e,t)=>(t.updated_at??0)-(e.updated_at??0))}async function vi(e){pi(e);let t=(await ui()).transaction([`projects`,`media`]),[n,r]=await Promise.all([ai(t.objectStore(`projects`).get(e)),gi(t)]);if(!n)throw new ci(404,`no such project`);return{id:n.id,name:n.name,revision:n.revision,updated_at:n.updated_at,media_bytes:hi(n.data,r),data:JSON.parse(n.json)}}async function yi(e,t){pi(e);let n=JSON.stringify(t.data),r=(await ui()).transaction([`projects`,`media`],`readwrite`),[i,a]=await Promise.all([ai(r.objectStore(`projects`).get(e)),Promise.all(mi(t.data).map(async e=>await ai(r.objectStore(`media`).getKey(e))===void 0?e:null))]),o=i?.revision??null;if(o!==(t.base_revision??null))throw r.abort(),new ci(409,`the project changed since base_revision`,{revision:o});let s=a.filter(e=>!!e);if(s.length)throw r.abort(),new ci(400,`missing media: ${s.join(`, `)}`,{missing:s});let c={id:e,name:t.name,revision:(o??0)+1,updated_at:Date.now(),data:null,json:n};return r.objectStore(`projects`).put({...c,data:t.data}),await oi(r),{id:e,revision:c.revision,updated_at:c.updated_at}}async function bi(e){pi(e);let t=(await ui()).transaction(`projects`,`readwrite`);t.objectStore(`projects`).delete(e),await oi(t)}async function xi(e){if(!fi.test(e))throw new ci(400,`invalid hash`);return await ai((await ui()).transaction(`media`).objectStore(`media`).getKey(e))!==void 0}async function Si(e){if(!fi.test(e))throw new ci(400,`invalid hash`);let t=await ai((await ui()).transaction(`media`).objectStore(`media`).get(e));if(!t)throw new ci(404,`no such media`);return t.blob}async function Ci(e,t){if(!fi.test(e))throw new ci(400,`invalid hash`);let n=new Uint8Array(await t.arrayBuffer());if(await ri(n)!==e)throw new ci(400,`content does not match its hash`);let r=(await ui()).transaction(`media`,`readwrite`);r.objectStore(`media`).put({hash:e,size:n.byteLength,blob:new Blob([n],{type:t.type})}),await oi(r)}function wi(e,t){let{tokens:n,spans:r}=Nn(e);if(!n.length)return{text:e,spans:t??[],points:[],regions:[],tagged:!1};let i=new Int32Array(e.length+1),a=``,o=0;for(let t=0;t=n[o].end;)o++;o=n[o].start||(a+=e[t])}return i[e.length]=a.length,{text:a,spans:(t??[]).map(e=>({...e,start:i[e.start],end:i[e.end]})).filter(e=>e.end>e.start),points:n.filter(e=>e.kind===`point`).map(e=>({at:i[e.start],name:e.name})),regions:r.map(e=>({start:i[e.open.end],end:i[e.close.start],name:e.name})),tagged:!0}}function Ti(e){let t=e>>>0||1;return()=>(t=t*1664525+1013904223>>>0)/2**32*2-1}function Ei(e,t,n,r){let i=Ti(r),a=e=>new Float32Array(Math.round(e*t)),o=(e,n,r,a,o,s=0)=>{let c=0,l=Math.exp(-2*Math.PI*o/t),u=Math.round(n*t),d=Math.round(r*t);for(let n=0;n/[\p{L}']/u.test(e[0])).map(e=>e.index??0),c=[...r.text.matchAll(/[^\s]+/g)].filter(e=>/[\p{L}']/u.test(e[0])).map(e=>(e.index??0)+e[0].length),l=e=>{let t=.05;for(let r=0;rt>=e.start&&c[n]<=e.end+1?n:-1).filter(e=>e>=0&&e({t:l(e.at),s:Ei(e.name,t,o,a+n*97)})).sort((e,t)=>e.t-t.t);if(!d.length)return{pcm:u,words:n};let f=d.reduce((e,t)=>e+t.s.length,0),p=new Float32Array(u.length+f),m=0,h=0,g=0,_=n.map(e=>({...e}));for(let e of d){let n=Math.min(u.length,Math.max(m,Math.round(e.t*t)));p.set(u.subarray(m,n),h),h+=n-m,m=n,p.set(e.s,h),h+=e.s.length;let r=e.s.length/t;for(let t of _)t.start>=e.t-1e-6+g&&(t.start+=r,t.end+=r);g+=r}return p.set(u.subarray(m),h),{pcm:p,words:_}}var Oi={phoneme_tokens:{open_marker:``,close_marker:``,symbols:`a.b.c.d.e.f.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.².³.¹.ã.ä.æ.ç.ï.ð.õ.ø.ħ.ĩ.ŋ.œ.ũ.ɐ.ɑ.ɒ.ɓ.ɔ.ɕ.ɖ.ɗ.ɘ.ə.ɚ.ɛ.ɜ.ɝ.ɟ.ɡ.ɣ.ɤ.ɥ.ɦ.ɧ.ɨ.ɪ.ɫ.ɭ.ɯ.ɰ.ɱ.ɲ.ɳ.ɴ.ɵ.ɸ.ɹ.ɻ.ɽ.ɾ.ʀ.ʁ.ʂ.ʃ.ʈ.ʉ.ʊ.ʋ.ʌ.ʍ.ʎ.ʏ.ʐ.ʑ.ʒ.ʔ.ʕ.ʝ.ʰ.ʱ.ʲ.ʷ.ʼ.ˀ.ː.ˣ.ˤ.˥.˦.˧.˨.˩.̃.̊.̍.̚.̝.̞.̟.̠.̥.̩.̪.̯.̹.͈.͡.β.θ.χ.ᵝ.ẽ.ỹ.⁴.⁵.⁻.⁽.⁾`.split(`.`)},phonemize_enabled:!0,phonemize_languages:[`en_us`,`en_gb`],phonemize_guess_languages:[`en_us`]},ki={keep2_plain:`Fast (keep2)`,full_mr:`Full-size`},Ai=e=>ki[e]??e;function ji(e,t){return t&&t!==e[0]?.id&&e.some(e=>e.id===t)?t:null}function Mi(e,t){return`Unknown decoder '${e}'; this server serves: ${t.map(e=>e.id).join(`, `)}.`}var Ni=Symbol.for(`preact-signals`);function Pi(){if(Bi>1)Bi--;else{var e,t=!1;for((function(){var e=Wi;for(Wi=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();zi!==void 0;){var n=zi;for(zi=void 0,Vi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ji(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Vi=0,Bi--,t)throw e}}function Fi(e){if(Bi>0)return e();Ui=++Hi,Bi++;try{return e()}finally{Pi()}}var Ii,Li=void 0;function Ri(e){var t=Li,n=Ii;Li=void 0,Ii=void 0;try{return e()}finally{Li=t,Ii=n}}var zi=void 0,Bi=0,Vi=0,Hi=0,Ui=0,Wi=void 0,Gi=0;function Ki(e){if(Li!==void 0){var t=e.n;if(t===void 0||t.t!==Li)return t={i:0,S:e,p:Li.s,n:void 0,t:Li,e:void 0,x:void 0,r:t},Li.s!==void 0&&(Li.s.n=t),Li.s=t,e.n=t,32&Li.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Li.s,t.n=void 0,Li.s.n=t,Li.s=t),t}}function qi(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}qi.prototype.brand=Ni,qi.prototype.h=function(){return!0},qi.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ri(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},qi.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ri(function(){var e;(e=t.Z)==null||e.call(t)}))}},qi.prototype.subscribe=function(e){var t=this;return na(function(){var n=t.value;Ri(function(){return e(n)})},{name:`sub`})},qi.prototype.valueOf=function(){return this.value},qi.prototype.toString=function(){return this.value+``},qi.prototype.toJSON=function(){return this.value},qi.prototype.peek=function(){var e=this;return Ri(function(){return e.value})},Object.defineProperty(qi.prototype,"value",{get:function(){var e=Ki(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Vi>100)throw Error(`Cycle detected`);(function(e){Bi!==0&&Vi===0&&e.l!==Ui&&(e.l=Ui,Wi={S:e,v:e.v,i:e.i,o:Wi})})(this),this.v=e,this.i++,Gi++,Bi++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pi()}}}});function F(e,t){return new qi(e,t)}function Ji(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Yi(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Xi(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Zi(e,t){qi.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Gi-1,this.f=4}Zi.prototype=new qi,Zi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Gi))return!0;if(this.g=Gi,this.f|=1,this.i>0&&!Ji(this))return this.f&=-2,!0;var e=Li;try{Yi(this),Li=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Li=e,Xi(this),this.f&=-2,!0},Zi.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}qi.prototype.S.call(this,e)},Zi.prototype.U=function(e){if(this.t!==void 0&&(qi.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Zi.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Zi.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ki(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function I(e,t){return new Zi(e,t)}function Qi(e){var t=e.j;if(e.j=void 0,typeof t==`function`){Bi++;var n=Li;Li=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,$i(e),t}finally{Li=n,Pi()}}}function $i(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Qi(e)}function ea(e){if(Li!==this)throw Error(`Out-of-order effect`);Xi(this),Li=e,this.f&=-2;try{8&this.f&&$i(this)}finally{Pi()}}function ta(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ii&&Ii.push(this)}ta.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.j=t)}finally{e()}},ta.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Qi(this),Yi(this),Bi++;var e=Li;return Li=this,ea.bind(this,e)},ta.prototype.N=function(){2&this.f||(this.f|=2,this.u=zi,zi=this)},ta.prototype.d=function(){this.f|=8,1&this.f||$i(this)},ta.prototype.dispose=function(){this.d()};function na(e,t){var n=new ta(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ra,ia,aa=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,oa=[];na(function(){ra=this.N})();function sa(e,t){k[e]=t.bind(null,k[e]||function(){})}function ca(e){if(ia){var t=ia;ia=void 0,t()}ia=e&&e.S()}function la(e){var t=this,n=e.data,r=da(n);r.name=`ReactiveDom`,r.value=n;var i=ht(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=I(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=I(function(){return!Array.isArray(i.value)&&!ce(i.value)}),o=na(function(){if(this.N=ma,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}la.displayName=`ReactiveTextNode`,Object.defineProperties(qi.prototype,{constructor:{configurable:!0,value:Te(A,null).constructor},type:{configurable:!0,value:la},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),sa(`__b`,function(e,t){if(ca(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof qi&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),sa(`__r`,function(e,t){if(e(t),t.type!==A){ca();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return na(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;aa&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),ca(n)}}),sa(`__e`,function(e,t,n,r){ca(),e(t,n,r)}),sa(`diffed`,function(e,t){ca();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=ua(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function ua(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=F(n);return{o:function(e,t){a.value=e,r=t},d:na(function(){this.N=ma;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}sa(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),sa(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),De.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function da(e,t){return ht(function(){return F(e,t)},[])}var fa=function(e){queueMicrotask(function(){queueMicrotask(e)})};function pa(){Fi(function(){for(var e;e=oa.shift();)ra.call(e)})}function ma(){oa.push(this)===1&&(k.requestAnimationFrame||fa)(pa)}var ha={language:`en_us`,voiceMode:`embedding`,tagStrength:1.5,decoder:null};function ga(e){return{voices:e.voices.length,cast:e.cast.personas.length,lines:e.direct.script.lines.length,takes:Object.values(e.direct.takes).reduce((e,t)=>e+t.length,0),versions:e.edit.doc?.versions.length??0}}function _a(e,t){if(!t.size)return e;let n=[...t.keys()].map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`));return e.replace(RegExp(`(?t.get(e))}var L=F(null),va=F(null),ya=F(null),ba=F(`Opening the studio…`),xa=F(null),Sa=F(ha),R=I(()=>L.value.spec),Ca=I(()=>L.value?.pron.phoneme_tokens??null),wa=I(()=>({phonemeTokens:Ca.value,tags:L.value?.tags??null,tagStrength:Sa.value.tagStrength,decoder:ji(L.value?.decoders??[],Sa.value.decoder)})),Ta=I(()=>new Map(R.value.ui.controls.map(e=>[e.id,e]))),Ea=I(()=>{let e=new Map;return R.value.ui.groups.forEach((t,n)=>e.set(t.id,t.hue??`c${n+1}`)),e});function Da(e){return`var(--${Ea.value.get(e)??`c1`})`}var Oa=[`cast`,`direct`,`edit`],ka=location.hash.slice(1)===`scene`?`direct`:location.hash.slice(1),Aa=F(Oa.includes(ka)?ka:`cast`),ja=F(null),Ma=F(!1),Na=F(!1),Pa=F(null),Fa=F(null),Ia=F([]),La=0,Ra=new Map,za=new Map,Ba=!1;function Va(e,t){clearTimeout(Ra.get(e)),za.set(e,Date.now()+t),Ba||Ra.set(e,window.setTimeout(()=>Ha(e),t))}function Ha(e){clearTimeout(Ra.get(e)),Ra.delete(e),za.delete(e),Ia.value=Ia.value.filter(t=>t.id!==e)}function Ua(e){if(e===Ba)return;if(Ba=e,e){for(let e of Ra.values())clearTimeout(e);Ra.clear();return}let t=Date.now();for(let[e,n]of za)Ra.set(e,window.setTimeout(()=>Ha(e),Math.max(1e3,n-t)))}function z(e,t=`info`,n){let r=t===`error`?15e3:n?8e3:3500,i=Ia.value.find(n=>n.text===e&&n.kind===t);if(i)return Ia.value=Ia.value.map(e=>e===i?{...e,action:n}:e),Va(i.id,r),i.id;let a=++La,o=Ia.value.slice(0,-2);for(let e of o)clearTimeout(Ra.get(e.id)),Ra.delete(e.id),za.delete(e.id);return Ia.value=[...Ia.value.slice(-2),{id:a,text:e,kind:t,action:n}],Va(a,r),a}var Wa=e=>!!e?.source_type?.startsWith(`embedding`),Ga=new URLSearchParams(location.search),Ka=Ga.get(`api`)||`auto`,qa=(Ga.get(`server`)||``).replace(/\/+$/,``);Ka===`web`&&o();var Ja=44100;function Ya(){let e=localStorage.getItem(`zvs.session`);return e||(e=T(),localStorage.setItem(`zvs.session`,e)),e}var{client:Xa,headers:Za,ok:Qa,send:$a}=b({baseUrl:qa,session:Ya,fetch:i}),eo=null,to=wt;function no(){if(!eo)throw Error(`api.connect() has not run`);return eo}var ro={speech_editing:!0,edit_transcribe:!0,edit_max_spans:3,edit_frame_rate:15,edit_max_seconds:150,edit_align_max_seconds:150,fixture:!0},io={...ro,speech_editing:!1,edit_transcribe:!1,fixture:!1};function ao(e,t){let n=Ga.get(`edit`);if(n===`0`||n===`off`)return{...io,fixture:e!==`live`};let r=!/^(0|off)$/.test(Ga.get(`edit_transcribe`)??``);return n===`fixture`||e===`offline`?{...ro,edit_transcribe:r}:t?{speech_editing:t.speech_editing,edit_transcribe:t.edit_transcribe&&r,edit_max_spans:t.edit_max_spans,edit_frame_rate:t.edit_frame_rate??ro.edit_frame_rate,edit_max_seconds:t.edit_max_seconds,edit_align_max_seconds:t.edit_align_max_seconds,fixture:!1}:io}var oo={...Oi,fixture:!0},so={phoneme_tokens:null,phonemize_enabled:!1,phonemize_languages:[],phonemize_guess_languages:[],fixture:!1};function co(e,t){let n=Ga.get(`phon`);return n===`0`||n===`off`?{...so,fixture:e!==`live`}:n===`fixture`||e===`offline`?oo:t?{phoneme_tokens:t.phoneme_tokens,phonemize_enabled:t.phonemize_enabled,phonemize_languages:t.phonemize_languages,phonemize_guess_languages:t.phonemize_guess_languages,fixture:!1}:so}var lo={tags:[`laugh`,`breath`,`sigh`,`cough`,`panting`,`shouting`,`crying`],min_scale:1,max_scale:4,default_scale:1,fixture:!0};function uo(e,t){let n=Ga.get(`nv`);return n===`0`||n===`off`?null:n===`fixture`||e===`offline`?lo:!t?.available||!t.trained?null:{tags:t.tags.length?t.tags:lo.tags,min_scale:t.min_scale,max_scale:t.max_scale,default_scale:t.default_scale,fixture:!1}}var fo={max_media_bytes:2e9,max_project_bytes:2e7,fixture:!0};function po(e){let t=Ga.get(`projects`);return t===`fixture`?fo:t===`browser`||t===`0`||!e?.enabled?null:{max_media_bytes:e.max_media_bytes,max_project_bytes:e.max_project_bytes,fixture:!1}}var mo=()=>qa||location.origin;async function ho(e){return ba.value=`Loading the in-browser engine…`,await l(e=>ya.value=e),ya.value=null,ba.value=`Starting the voice engine…`,d(e=>xa.value=e.fraction>=1?null:e),e(`web`,await vo())}async function go(e={}){let t=async(e,t)=>{let n=e===`offline`?null:await Qa(Xa.GET(`/v2/capabilities`)).catch(()=>null),r=e===`web`?`live`:e;return eo={kind:e,server:qa,spec:t,steering:e!==`fixture`,edit:ao(r,n),pron:co(r,n),projects:po(n?.projects),tags:uo(r,n?.tag_cfg),decoders:e===`offline`?Dt:n?.decoders??[]}};if(Ka===`offline`)return t(`offline`,to);if(Ka===`web`)return ho(t);ba.value=`Connecting to ${mo()}…`;try{return await t(`live`,await vo())}catch(n){if(Ka===`live`)throw n;return n instanceof v&&n.status===404||Ka===`fixture`?t(`fixture`,to):Ka===`auto`&&await s()&&(!e.confirmWeb||await e.confirmWeb())?(o(),ho(t)):t(`offline`,to)}}var _o=s;async function vo(){if(Ka===`fixture`)throw new v(404,`fixture forced`);return await Qa(Xa.GET(`/v2/controls`))}var yo=new Map,bo=(e,t,n)=>({id:`local_${p(e)}_${Date.now().toString(36)}`,label:e,source_type:t,scope:`session`,is_default:!1,original_name:n,created_at:Date.now()/1e3,has_preview:t===`audio`,speaker_modes:t===`audio`?[`embedding`,`reference`]:[`embedding`],embedding_dim:no().spec.embedding_dim,transcript:null,disabled_controls:[]});async function xo(){return no().kind===`offline`?[...Ut(no().spec).map(e=>({...e,transcript:/Skyler|Yelling/.test(e.label)?null:Co(e)})),...[...yo.values()].map(e=>e.speaker)]:(await Qa(Xa.GET(`/v2/speakers`))).speakers}async function So(e){let t=no();if(t.kind!==`offline`)try{let t=await Qa(Xa.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e.id}}}));return{embedding:Float32Array.from(t.embedding),synthetic:!1}}catch(e){if(!(e instanceof v)||e.status!==404||t.kind===`live`||t.kind===`web`)throw e}return{embedding:yo.get(e.id)?.embedding??Ht(t.spec,e.id,e.label),synthetic:t.kind!==`offline`}}var Co=e=>`Hi, I'm ${e.label}. This is how I sound when I read a short line.`;async function wo(e){if(no().kind===`offline`){let{embedding:t}=await So(e),n=Co(e),{pcm:r,words:i}=dn(no().spec,{text:n,embedding:t,seed:7});return Dr(r,Ja,{text:n,words:i,embedding:t}),te(r,Ja).buffer}let t=await i(`${qa}/v2/speakers/${encodeURIComponent(e.id)}/preview`,{headers:Za()});if(!t.ok)throw await S(t);return t.arrayBuffer()}async function To(e,t,n){if(no().kind===`offline`){let t=bo(e,`audio`,n);return yo.set(t.id,{speaker:t}),t}let r={label:e,speaker_audio_base64:await ie(t),speaker_audio_name:n};return Qa(Xa.POST(`/v2/speakers`,{body:r}))}async function Eo(e,t){let n=`${p(e)}.npy`;if(no().kind===`offline`){let r=bo(e,`embedding`,n);return yo.set(r.id,{speaker:r,embedding:t.slice()}),r}let r={label:e,speaker_embedding_base64:await oe(m(t),`application/octet-stream`),speaker_embedding_name:n};return Qa(Xa.POST(`/v2/speakers`,{body:r}))}var Do=new Set([`en_us`,`fr_fr`]);async function Oo(e,t={}){let n=no(),r=performance.now(),a={stream:!0,...e};if(n.steering||(delete a.controls,delete a.control_spans),a.control_spans?.length||delete a.control_span_follow,(!n.tags||(a.tag_cfg_scale??1)<=1)&&delete a.tag_cfg_scale,n.kind===`offline`||n.tags?.fixture)return ko(a,t,r);let o=await i(`${qa}/v2/generate`,{method:`POST`,headers:Za({"Content-Type":`application/json`}),body:JSON.stringify(a),signal:t.signal});if(!o.ok)throw await S(o);let s=a.control_spans?.length?o.headers.get(`X-Control-Span-Follow`)===`reading`?`reading`:`rate`:void 0,c=o.headers.get(`X-Decoder`),l=Number(o.headers.get(`X-Audio-Sample-Rate`))||44100;if(!o.body)throw new v(502,`Empty audio stream`);let u=[],d=0,f=0;await x(o.body,e=>{u.push(e),d+=e.length,t.onChunk?.(e,l)},()=>{f||=performance.now()-r});let p=new Float32Array(d),m=0;for(let e of u)p.set(e,m),m+=e.length;return{pcm:p,sr:l,ttfbMs:f,totalMs:performance.now()-r,...s?{spanFollow:s}:{},...c?{decoder:c}:{}}}async function ko(e,t,n){let r=no();$r(e.text,r.pron.phoneme_tokens);let i=Ao(e.decoder),a=(await xo()).find(t=>t.id===e.speaker_embedding_id);if(!a)throw new v(400,`Unknown speaker_embedding_id '${e.speaker_embedding_id}'`);let o=e.controls??{};for(let t of[...Object.keys(o),...(e.control_spans??[]).flatMap(e=>Object.keys(e.controls))]){let n=r.spec.directions[t];if(!n)throw new v(400,`Unknown control direction '${t}'`);let i=e.speaker_mode??`embedding`;if(!r.spec.sets[n.set]?.modes.includes(i))throw new v(400,`Control '${t}' moves the speaker embedding and needs speaker_mode=embedding.`)}for(let t of e.control_spans??[]){if(Object.keys(t.controls).some(e=>r.spec.directions[e].space===`raw`))throw new v(400,`control_spans take hidden-space directions only.`);if(!(t.start>=0&&t.end>t.start&&t.end<=e.text.length))throw new v(400,`control_spans [${t.start}, ${t.end}) is outside the text.`)}let s=[...e.control_spans??[]].sort((e,t)=>e.start-t.start);for(let e=1;e1){if(!l?.tagged)throw new v(400,`tag_cfg_scale > 1 needs a recognized nonverbal tag in the text.`);if((e.speaker_cfg_scale??1)!==1)throw new v(400,`tag_cfg_scale cannot be combined with speaker_cfg_scale ≠ 1.`)}let{embedding:u}=await So(a),d=l??{text:e.text,spans:e.control_spans??void 0},f=dn(r.spec,{text:d.text,embedding:u,controls:o,spans:d.spans,seed:e.seed??0}),{pcm:p,words:m}=l?Di(f.pcm,Ja,f.words,l,c,e.seed??0):f;Dr(p,Ja,{text:d.text,words:m,embedding:u,controls:o});let h=e=>{let{promise:n,resolve:r,reject:i}=Promise.withResolvers(),a=setTimeout(r,e);return t.signal?.addEventListener(`abort`,()=>{clearTimeout(a),i(new DOMException(`Aborted`,`AbortError`))}),n};await h(220+Math.random()*180);let g=performance.now()-n,_=Math.round(Ja*.4);for(let e=0;et.id===e))throw new v(400,Mi(e,t));return e??t[0]?.id}function jo(e,t=`en_us`,n){return no().edit.fixture?zr(no().edit,e,t,n):Qa(Xa.POST(`/v2/edit/transcribe`,{body:{audio_base64:e,language:t},signal:n}))}function Mo(e,t,n=`en_us`,r){return no().edit.fixture?Br(e,t,n,r):Qa(Xa.POST(`/v2/edit/align`,{body:{audio_base64:e,text:t,language:n},signal:r}))}async function No(e,t){if(no().edit.fixture){let n=no().pron.phoneme_tokens;if($r(e.target_text,n),/[\ue000\ue001]/.test(e.original_text??``))throw new v(400,`original_text describes the recorded audio: it cannot hold pronunciation groups.`);return Ao(e.decoder),Kr(no().spec,no().edit,e,t)}return Qa(Xa.POST(`/v2/edit`,{body:e,signal:t}))}function Po(e,t,n=!0){let r=no();return r.pron.fixture?Qr(r.pron,e,t,n):Qa(Xa.POST(`/v2/phonemize`,{body:{text:e,language:t,guess:n}}))}var Fo=()=>no().projects?.fixture===!0;async function Io(e){try{return await e()}catch(e){throw e instanceof ci?e.status===409?new re(e.body.revision??null):e.body.missing?new w(e.body.missing):new v(e.status,e.detail):e}}var Lo=e=>({params:{path:{project_id:e}}}),Ro=e=>`${qa}/v2/media/${encodeURIComponent(e)}`;function zo(){return Fo()?Io(_i):Qa(Xa.GET(`/v2/projects`))}function Bo(e){return Fo()?Io(()=>vi(e)):Qa(Xa.GET(`/v2/projects/{project_id}`,Lo(e)))}async function Vo(e,t){if(Fo())return Io(()=>yi(e,t));let{response:n,text:r}=await $a(Xa.PUT(`/v2/projects/{project_id}`,{...Lo(e),body:t}));if(n.ok)return y(n.status,r);let i={};try{i=JSON.parse(r)??{}}catch{}throw n.status===409?new re(i.revision??null):n.status===400&&i.missing?new w(i.missing):O(n.status,n.statusText,r)}async function Ho(e){if(Fo())return Io(()=>bi(e));let{response:t,text:n}=await $a(Xa.DELETE(`/v2/projects/{project_id}`,Lo(e)));if(!t.ok&&t.status!==404)throw O(t.status,t.statusText,n)}async function Uo(e){if(Fo())return Io(()=>xi(e));let t=await i(Ro(e),{method:`HEAD`,headers:Za()});if(t.status===404)return!1;if(!t.ok)throw await S(t);return!0}async function Wo(e,t){if(Fo())return Io(()=>Si(e));let n=await i(Ro(e),{headers:Za()});if(!n.ok)throw await S(n);let r=await n.blob();return t&&r.type!==t?new Blob([r],{type:t}):r}async function Go(e,t){if(Fo())return Io(()=>Ci(e,t));let n=await i(Ro(e),{method:`PUT`,headers:Za({"Content-Type":t.type||`application/octet-stream`}),body:t});if(!n.ok)throw await S(n)}function Ko(e){return e}function qo(e){if(e==null)return Ko;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;ct.properties?.name===e);if(!t)return[];let n=t.geometry;return n.type===`Polygon`?[n.coordinates[0]]:n.type===`MultiPolygon`?n.coordinates.map(e=>e[0]):[]}function is(e,t){let n=[];for(let r=0;r=0&&n.push(i),o>=0!=s>=0){let e=o/(o-s);n.push([i[0]+(a[0]-i[0])*e,i[1]+(a[1]-i[1])*e])}}return n}var as=(e,...t)=>e.map(e=>t.reduce((e,t)=>is(e,t),e)).filter(e=>e.length>=3),os=(e,t)=>n=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),ss=[-3.4,54.95],cs=[-2,55.8],ls=[-2.65,51.6],us=[-3.1,53.45];function ds(e){if(![`England`,`Scotland`,`Wales`,`Northern Ireland`].includes(e))return rs(e);let t=rs(`United Kingdom`),n=e=>e.every(([e,t])=>e<-5.4&&t>53.8&&t<55.4);if(e===`Northern Ireland`)return t.filter(n);let r=t.filter(e=>!n(e)),i=os(ss,cs);if(e===`Scotland`)return as(r,i);let a=as(r,e=>-i(e)),o=os(ls,us);return e===`Wales`?as(a,o,e=>Math.min(e[1]-51.38,53.45-e[1])):[...as(a,e=>-o(e)),...as(a,o,e=>51.38-e[1]),...as(a,o,e=>e[1]-53.45)]}var fs=e=>180/Math.PI*Math.log(Math.tan(Math.PI/4+Math.max(-85,Math.min(85,e))*Math.PI/360));function ps(e){let[t,n,r,i]=e.bbox,[a,o,s,c]=e.rect,l=fs(n),u=fs(i),d=Math.min(s/(r-t),c/(u-l)),f=a+(s-(r-t)*d)/2,p=o+(c-(u-l)*d)/2;return([e,n])=>[f+(e-t)*d,p+(u-fs(n))*d]}function ms(e,[t,n,r,i]){return[e=>e[0]-t,e=>t+r-e[0],e=>e[1]-n,e=>n+i-e[1]].reduce((e,t)=>is(e,t),e)}var hs=e=>e.map(e=>`M`+e.map(([e,t])=>`${e.toFixed(1)},${t.toFixed(1)}`).join(`L`)+`Z`).join(``);function gs(e,[t,n]){let r=!1;for(let i of e)for(let e=0,a=i.length-1;en!=l>n&&t<(c-o)*(n-s)/(l-s)+o&&(r=!r)}return r}function _s(e,[t,n]){let r=1/0;for(let i of e)for(let e=0,a=i.length-1;eo&&(o=u,a=l)}return{pole:a,inradius:Math.max(o,4)}}function ys(e,[t,n,r,i]){return e.some(e=>e.some(([e,a])=>e>=t-5&&e<=r+5&&a>=n-5&&a<=i+5))}var bs=new Map;function xs(e,t){let n=`${e}|${t.join(`,`)}`,r=bs.get(n);if(r)return r;let i=es[e]??{home:[500,900],panels:[],regions:{}},a=[];for(let e of i.panels){let t=ps(e),n=ns.flatMap(e=>rs(e.properties?.name??``)).filter(t=>ys([t],e.bbox)).map(n=>ms(n.map(t),e.rect)).filter(e=>e.length>=3);a.push({panel:e.id,path:hs(n)})}let o={},s=[];for(let e of t){let t=i.regions[e];if(!t){s.push(e);continue}let n=[];for(let e of i.panels){let r=ps(e);for(let i of t)for(let t of ds(i)){if(!ys([t],e.bbox))continue;let i=ms(t.map(r),e.rect);i.length>=3&&n.push(i)}}n.length?o[e]={id:e,polys:n,path:hs(n),...vs(n)}:s.push(e)}s.forEach((e,t)=>{let n=[$o/(s.length+1)*(t+1),920],r=Array.from({length:24},(e,t)=>[n[0]+Math.cos(t/24*Math.PI*2)*34,n[1]+Math.sin(t/24*Math.PI*2)*26]);o[e]={id:e,polys:[r],path:hs([r]),pole:n,inradius:26}});let c={panels:i.panels,context:a,regions:o,home:i.home};return bs.set(n,c),c}var Ss=.2;function Cs(e,t){let n=_s(e.polys,t);return gs(e.polys,t)?Ss+.8*Math.min(1,n/e.inradius):Ss*Math.max(0,1-n/18)}function ws(e){return[...new Set(e.map(e=>e.tab))]}function Ts(e,t){return xs(e,[...new Set(t.filter(t=>t.tab===e).map(e=>e.region))])}function Es(e=`english`,t=[]){let[n,r]=Ts(e,t).home;return{tab:e,x:n,y:r}}function Ds(e,t,n){let r=t.regions[e.region];return r?Math.round(e.range[1]*Cs(r,n)*20)/20:0}function Os(e,t){let n=Ts(e.tab,t),r={};for(let i of t){if(i.tab!==e.tab)continue;let t=Ds(i,n,[e.x,e.y]);t>0&&(r[i.id]=t)}return r}function ks(e,t,n){let r=Ts(e.tab,n),i=r.regions[e.region];if(!i)return Es(e.tab,n);let[a,o]=r.home,s=e=>[i.pole[0]+(a-i.pole[0])*e,i.pole[1]+(o-i.pole[1])*e],c=0,l=1;for(let n=0;n<30;n++){let n=(c+l)/2;Ds(e,r,s(n))>=t?c=n:l=n}let[u,d]=s(c);return{tab:e.tab,x:u,y:d}}function As(e,t,n=`english`){let r=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1])[0],i=r&&t.find(e=>e.id===r[0]);return i?ks(i,r[1],t):Es(n,t)}var js=class{limit;state;canUndo=F(!1);canRedo=F(!1);past=[];future=[];gesture=null;constructor(e,t=200){this.limit=t,this.state=F(e)}begin(){this.gesture===null&&(this.gesture=this.state.value)}set(e){this.state.value=e}end(){let e=this.gesture;this.gesture=null,e!==null&&e!==this.state.value&&(this.past.push(e),this.past.length>this.limit&&this.past.shift(),this.future=[],this.sync())}apply(e){this.begin(),this.set(e),this.end()}undo(){this.end();let e=this.past.pop();e!==void 0&&(this.future.push(this.state.value),this.state.value=e,this.sync())}redo(){this.end();let e=this.future.pop();e!==void 0&&(this.past.push(this.state.value),this.state.value=e,this.sync())}reset(e){this.past=[],this.future=[],this.gesture=null,this.state.value=e,this.sync()}patch(e){this.gesture===null&&(this.state.value=e)}sync(){this.canUndo.value=this.past.length>0,this.canRedo.value=this.future.length>0}},B=F(null),Ms=F(0),Ns=null,Ps=null,Fs=[],Is=0,Ls=0,Rs=null;function zs(){return Ns||(Ns=new AudioContext({latencyHint:`interactive`}),Ps=Ns.createGain(),Ps.gain.value=.9,Ps.connect(Ns.destination)),Ns.state===`suspended`&&Ns.resume(),{ctx:Ns,out:Ps}}function Bs(){let e=B.value;e&&Ns&&(Ms.value=Math.max(0,Math.min(e.duration,Ns.currentTime-e.t0)),Is=requestAnimationFrame(Bs))}function Vs(e,t){B.value=e,Rs=t??null,cancelAnimationFrame(Is),Is=requestAnimationFrame(Bs)}function Hs(e){clearTimeout(Ls);let t=Math.max(0,(e-Ns.currentTime)*1e3)+30;Ls=window.setTimeout(()=>Us(),t)}function Us(){clearTimeout(Ls),cancelAnimationFrame(Is);let e=Rs;Rs=null,B.value=null,Ms.value=0,e?.()}function Ws(){for(let e of Fs)try{e.stop()}catch{}Fs=[],B.value&&Us()}function Gs(e,t){let{ctx:n}=zs(),r=n.createBuffer(1,Math.max(1,e.length),t);return r.copyToChannel(e,0),r}function Ks(e,t,n,r=0,i,a){Ws();let{ctx:o,out:s}=zs(),c=o.createBufferSource();c.buffer=Gs(t,n),c.connect(s);let l=o.currentTime+.02,u=t.length/n,d=Math.max(0,Math.min(r,u)),f=Math.max(d,Math.min(a??u,u));c.start(l,d,f-d),Fs=[c],Vs({id:e,t0:l-d,duration:u,streaming:!1},i),Hs(l+f-d)}function qs(e){return B.value?.id===e}function Js(e,t,n,r){qs(e)?Ws():t&&Ks(e,t,n,0,r)}function Ys(e,t){Ws();let{ctx:n,out:r}=zs(),i=n.currentTime+.08,a=i,o=!1;Vs({id:e,t0:a,duration:0,streaming:!0});let s=()=>B.value?.id===e&&B.value.t0===a;return{id:e,push(e){if(!s()||!e.length)return;let c=n.createBufferSource();c.buffer=Gs(e,t),c.connect(r);let l=Math.max(i,n.currentTime+.01);c.start(l),i=l+e.length/t,Fs.push(c),B.value={...B.value,duration:i-a},o&&Hs(i)},end(){o=!0,s()&&(B.value={...B.value,streaming:!1},Hs(i))}}}async function Xs(e){let{ctx:t}=zs(),n=await t.decodeAudioData(e.slice(0)),r=new Float32Array(n.length);for(let e=0;eArray.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.keys(e).sort().map(n=>[n,t(e[n])])):e;return JSON.stringify(t(e))}function ic(e){return $s.get(rc(e))}function ac(e,t){for($s.delete(e),$s.set(e,t);$s.size>Qs;)$s.delete($s.keys().next().value)}function oc(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers(),i=()=>{e?.removeEventListener(`abort`,a),tc++,n()},a=()=>{let e=nc.indexOf(i);e>=0&&nc.splice(e,1),r(new DOMException(`Aborted`,`AbortError`))};return e?.aborted?a():tc{await oc(t.signal);try{let r=await Oo(e,t);return ac(n,r),r}catch(t){throw uc(t)&&dc?.(e.speaker_embedding_id??``),t}finally{sc()}})();ec.set(n,a);try{return await a}finally{ec.get(n)===a&&ec.delete(n)}}var lc=e=>e instanceof DOMException&&e.name===`AbortError`,uc=e=>e instanceof v&&(e.status===400||e.status===404)&&/unknown (voice|speaker)/i.test(e.detail),dc=null;function fc(e){dc=e}function V(e){return e instanceof Error?e.message:String(e)}var H=F([]),pc=F(null),mc=F(!1),hc=new Map,gc=new Map,_c=F(0),vc=F(!1),yc=F({});async function bc(){mc.value=!0;try{H.value=await xo(),pc.value=null}catch(e){pc.value=V(e)}finally{mc.value=!1}}function xc(e){return _c.value,e&&hc.get(e)||null}function Sc(e,t=!1){let n=hc.get(e.id);if(n)return Promise.resolve(n);if(t&&yc.value[e.id]){let t={...yc.value};delete t[e.id],yc.value=t}let r=gc.get(e.id);return r||(r=So(e).then(({embedding:t,synthetic:n})=>(hc.set(e.id,t),n&&(vc.value=!0),_c.value++,t)).catch(t=>(yc.value={...yc.value,[e.id]:V(t)},null)).finally(()=>gc.delete(e.id)),gc.set(e.id,r)),r}function Cc(){for(let e of H.value)Sc(e)}var wc=new Map,Tc=F(null);async function Ec(e){let t=`clip:${e.id}`;if(qs(t))return Ws();let n=wc.get(e.id);if(!n){Tc.value=e.id;try{n=await Xs(await wo(e)),wc.set(e.id,n)}catch(t){z(`Couldn't play ${e.label}: ${V(t)}`,`error`);return}finally{Tc.value=null}}Ks(t,n.pcm,n.sr)}var Dc=F(!1);async function Oc(e,t,n,r=!1){Dc.value=!0;try{let i,a;try{({pcm:i,sr:a}=await Xs(await e.arrayBuffer()))}catch{return z(`That file isn’t audio the browser can read (try WAV or MP3)`,`error`),null}let o=i.length/a;if(o<2)return z(`Too short: record at least 2 s`,`error`),null;if(o>60)return z(`Clip is ${Math.round(o)} s; the limit is 60 s`,`error`),null;let s=await Ac(t,te(i,a).buffer,n.replace(/\.[^.]+$/,``)+`.wav`);return await bc(),z(r?`Added ${s.label} and made it the base voice`:`Added “${s.label}” to your voices`,`ok`),(o<5||o>30)&&z(`Clip is ${Math.round(o)} s; 5–30 s of clean speech clones best`),s}catch(e){return z(`Upload failed: ${V(e)}`,`error`),null}finally{Dc.value=!1}}var kc=F([]);async function Ac(e,t,n){let r=await To(e,new Blob([t],{type:`audio/wav`}),n);return kc.value=[...kc.value,{id:r.id,label:r.label,clip:t}],r}async function jc(e,t){let n=await Eo(e,t);return kc.value=[...kc.value,{id:n.id,label:n.label,embedding:t.slice()}],n}var Mc=F(null),Nc=F(0),Pc=F(null);async function Fc(){if(!navigator.mediaDevices?.getUserMedia){z(`Recording needs HTTPS (or localhost)`,`error`);return}let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){z(e instanceof DOMException&&(e.name===`NotAllowedError`||e.name===`SecurityError`)?`Allow the microphone in the browser’s site settings`:`Microphone unavailable: ${V(e)}`,`error`);return}let t=E(e,e=>Nc.value=e),n=new MediaRecorder(e),r=[];n.ondataavailable=e=>r.push(e.data),n.onstop=async()=>{t.stop(),e.getTracks().forEach(e=>e.stop()),Mc.value=null;let i=new Blob(r,{type:n.mimeType});try{let{pcm:e,sr:t}=await Xs(await i.arrayBuffer()),n=e.length/t;if(n<2){z(`Too short: record at least 2 s`,`error`);return}Pc.value={blob:i,pcm:e,sr:t,seconds:n}}catch(e){z(`Couldn’t read the recording: ${V(e)}`,`error`)}},n.start();let i=setTimeout(()=>n.state===`recording`&&n.stop(),3e4);Mc.value={started:Date.now(),stop:()=>{clearTimeout(i),n.state===`recording`&&n.stop()}}}async function Ic(){let e=Pc.value;if(!e)return null;Pc.value=null;let t=new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return Oc(e.blob,`Recording ${t}`,`recording.webm`,!0)}function Lc(e,t){let n=t.trim();n&&(kc.value=kc.value.map(t=>t.id===e?{...t,label:n}:t),H.value=H.value.map(t=>t.id===e?{...t,label:n}:t))}function Rc(e){let t=kc.value.find(t=>t.id===e),n=H.value.find(t=>t.id===e);if(!n)return null;let r=kc.value.indexOf(t),i=H.value.indexOf(n);return kc.value=kc.value.filter(t=>t.id!==e),H.value=H.value.filter(t=>t.id!==e),()=>{t&&!kc.value.some(t=>t.id===e)&&(kc.value=[...kc.value.slice(0,r),t,...kc.value.slice(r)]),H.value.some(t=>t.id===e)||(H.value=[...H.value.slice(0,i),n,...H.value.slice(i)])}}var zc=F([]);function Bc(e){zc.value=[...zc.value.filter(t=>t.id!==e.id),e]}function Vc(e){let t=zc.value.findIndex(t=>t.id===e);if(t<0)return null;let n=zc.value[t];return zc.value=zc.value.filter(t=>t.id!==e),{persona:n,index:t}}function Hc(e,t){let n=zc.value.filter(t=>t.id!==e.id);zc.value=[...n.slice(0,t),e,...n.slice(t)]}function Uc(e,t){let n=t.trim();n&&(zc.value=zc.value.map(t=>t.id===e?{...t,name:n}:t))}var Wc=(e=`embedding`)=>({baseId:``,mode:e,values:{},pin:Es()}),U=new js(Wc()),W=U.state,Gc=(e,t)=>Os(t.pin,e.ui.accents),Kc=(e,t)=>Yt(e,t.values,Gc(e,t),t.mode),qc=I(()=>Gc(R.value,W.value)),Jc=I(()=>Kc(R.value,W.value)),Yc=I(()=>$t(R.value,W.value.values,qc.value,W.value.mode)),Xc=I(()=>H.value.find(e=>e.id===W.value.baseId)??null),Zc=I(()=>xc(W.value.baseId)),Qc=I(()=>{let e=Zc.value;return e&&W.value.mode===`embedding`?an(R.value,e,Jc.value):null}),$c=I(()=>!Wa(Xc.value));function el(e,t){let n=R.value.ui.controls.find(t=>t.id===e);if(!n)return;let r=W.value;U.set({...r,values:{...r.values,[e]:Math.round(P(t,n.range[0],n.range[1])*100)/100}})}function tl(e){U.set({...W.value,pin:e})}function nl(e){let t=W.value;if(e===t.baseId&&!Object.values(t.values).some(Boolean)&&!Object.keys(Gc(R.value,t)).length)return;let n=H.value.find(e=>e.id===t.baseId);U.apply({baseId:e,mode:Wa(H.value.find(t=>t.id===e))?`embedding`:Wa(n)?Sa.value.voiceMode:t.mode,values:{},pin:Es(t.pin.tab)})}var rl=(e=W.value)=>Object.values(e.values).some(Boolean)||Object.keys(Gc(R.value,e)).length>0;function il(e,t){let n=W.value;if(e===n.baseId&&!rl(n))return;let r=rl(n);if(nl(e),!r)return;let i=H.value.find(t=>t.id===e)?.label??`this voice`;z(`Starting from ${t===`clip`?`the new clip`:i}; your moves were cleared`,`info`,{label:`Undo`,run:()=>U.undo()})}function al(e,t){e===`reference`&&t===`embedding`&&z(`Switched to Designable`)}function ol(e){e!==W.value.mode&&U.apply({...W.value,mode:e})}function sl(e){let t=R.value.ui.presets[e];if(!t)return;let{values:n,accents:r}=Xt(t),i=W.value;U.apply({...i,mode:`embedding`,values:n,pin:As(r,R.value.ui.accents,i.pin.tab)}),rl(i)&&z(`Applied ${e}; your moves were replaced`,`info`,{label:`Undo`,run:()=>U.undo()}),al(i.mode,`embedding`)}function cl(){let e=W.value,t=ml();U.apply(t),z(`Rolled on ${H.value.find(e=>e.id===t.baseId)?.label??`a voice`}`,`info`,{label:`Undo`,run:()=>U.undo()}),al(e.mode,t.mode)}function ll(){let e=W.value,t=R.value,n={};for(let[r,i]of Object.entries(e.values)){let a=t.ui.controls.find(e=>e.id===r);a&&!Jt(t,a,e.mode)&&(n[r]=i)}let r=t.ui.accents.some(n=>Jt(t,n,e.mode));rl(e)&&(U.apply({...e,values:n,pin:r?Es(e.pin.tab):e.pin}),z(`Controls reset`,`info`,{label:`Undo`,run:()=>U.undo()}))}var ul=(e,t)=>e[Math.floor(t()*e.length)];function dl(e,t,n){let[r,i]=e.safe;return Math.round((r+(i-r)*t())*n*10)/10}var fl={who:!0,texture:!0,room:!0};function pl(e,t,n){let r=[...e];for(let e=0;ee.is_default),r={};for(let n of t.ui.controls)n.group===`who`&&(r[n.id]=dl(n,e,.5));let i=t.ui.controls.filter(e=>fl[e.group]&&e.group!==`who`);for(let t of pl(i,1+Math.floor(e()*2),e))r[t.id]=dl(t,e,.5);let a=Es(W.value.pin.tab);if(e()<.33){let n=ul(t.ui.accents,e);a=ks(n,n.safe[1]*(.3+.4*e()),t.ui.accents)}return{baseId:(ul(n,e)??H.value[0])?.id??W.value.baseId,mode:`embedding`,values:r,pin:a}}function hl(e,t,n){let r=n-t;return e.type===`bipolar`&&e.poles?`${r>0?e.poles[1]:e.poles[0]} ${Math.abs(r).toFixed(1)}`:`${e.label.toLowerCase()} ${Ft(r)}`}function gl(e){let t=Object.entries(e).sort((e,t)=>t[1]-e[1])[0];return t?`${R.value.ui.accents.find(e=>e.id===t[0])?.label??t[0]} ${t[1].toFixed(1)}`:`no accent`}function _l(e,t=5,n=Math.random){let r=R.value,i=r.ui.controls.filter(t=>!t.span_only&&Jt(r,t,e.mode)),a=r.ui.accents.filter(t=>Jt(r,t,e.mode)),o=[];for(let s=0;s{let r=t.value;clearTimeout(n),n=window.setTimeout(()=>{try{localStorage.setItem(vl+e,JSON.stringify(r))}catch{}},300)})}var xl=4321;function Sl(e,t,n){let r=0;for(;re<=r?e:e>=a?e+(n.length-t.length):i?o:r;return e.map(e=>({...e,start:s(e.start,!1),end:s(e.end,!0)})).filter(e=>e.end>e.start)}function Cl(e,t,n){if(!n)return t;let r={...t};for(let t of e.ui.controls){let e=n[t.id];e&&(r[t.id]=P((r[t.id]??0)+e,t.range[0],t.range[1]))}return r}function wl(e,t,n){return!/\S/.test(e.slice(0,t))&&!/\S/.test(e.slice(n))&&/\S\s+\S/.test(e)}function Tl(e,t,n,r=!1){let i={};for(let a of e.ui.controls){let o=t.values[a.id];o&&a.spannable&&!(r&&a.span_only)&&Jt(e,a,n.mode)&&Kt(a,o,i)}return i}function El(e,t,n,r,i=e=>e){let a=[];for(let o of[...t??[]].sort((e,t)=>e.start-t.start)){let t=Tl(e,o,n,wl(r,o.start,o.end)),s=i(P(o.start,0,r.length),-1),c=i(P(o.end,0,r.length),1),l=a[a.length-1];l&&ss&&Object.keys(t).length&&a.push({start:s,end:c,controls:t})}return a}function Dl(e,t,n,r,i,a={}){let o=wn(r,t.phonemeTokens),s={...e.ui.request_defaults,text:o.text,seed:i,speaker_embedding_id:n.baseId,speaker_mode:n.mode};if(a.language&&a.language!==`en_us`&&(s.language=a.language),t.decoder&&(s.decoder=t.decoder),a.unsteered)return s;let c=t.tags,l=t.tagStrength;c&&l>1&&Pn(r)&&(s.tag_cfg_scale=Math.round(P(l,Math.max(1,c.min_scale),c.max_scale)*100)/100,s.speaker_cfg_scale=1);let u=Yt(e,Cl(e,n.values,a.extra),Os(n.pin,e.ui.accents),n.mode);Object.keys(u).length&&(s.controls=u);let d=El(e,a.spans,n,r,o.map);return d.length&&(s.control_spans=d,s.control_span_follow=`reading`,a.spanRate&&(s.control_span_rate=Math.round(a.spanRate*1e3)/1e3)),s}var Ol=250,kl=F(`A`),Al=F(yl(`autoplay`,!0));bl(`autoplay`,Al);var jl=F(yl(`autoRender`,!0));bl(`autoRender`,jl);var Ml=F(``),Nl=F(!1),Pl=I(()=>{let e=Ml.value.trim();return Nl.value?e:e||R.value.ui.preview_text}),Fl=F({status:`idle`,key:``,a:null,partial:null,error:null}),Il=F({key:``,take:null,error:null}),Ll=`preview:A`,Rl=`preview:B`,zl=0,Bl=null,Vl=null,Hl=null,Ul=!1,Wl=!1,Gl=!1;function Kl(){Wl=!0,queueMicrotask(()=>Wl=!1)}function ql(){return kl.value!==`A`||!(Al.value||Ul)?!1:(Ul=!1,!0)}function Jl(e){ql()&&Ks(Ll,e.pcm,e.sr)}async function Yl(e,t){Bl?.abort();let n=Bl=new AbortController;Fl.value={...Fl.value,status:`rendering`,key:t,partial:null,error:null};let r=null,i=[],a=0;try{let o=await cc(e,{signal:n.signal,onChunk:(e,t)=>{if(n.signal.aborted)return;!r&&ql()&&(r=Ys(Ll,t)),r?.push(e),i.push(e),a+=e.length;let o=new Float32Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;Fl.value={...Fl.value,partial:o}}});if(n.signal.aborted)return;r?.end(),Fl.value={status:`ready`,key:t,a:o,partial:null,error:null},Xl()}catch(e){if(lc(e)||n.signal.aborted)return;Ul=!1,qs(`preview:A`)&&Ws(),Fl.value={...Fl.value,status:`error`,partial:null,error:V(e)}}}async function Xl(){let e=Hl;if(!e)return;let t=rc(e);if((Il.value.key!==t||!Il.value.take&&!Il.value.error)&&(Il.value={key:t,take:ic(e)??null,error:null},!Il.value.take))try{let n=await cc(e);Il.value.key===t&&(Il.value={key:t,take:n,error:null})}catch(e){Il.value.key===t&&!lc(e)&&(Il.value={key:t,take:null,error:V(e)})}}function Zl(){Il.value={key:``,take:null,error:null},Xl()}function Ql(e){clearTimeout(zl);let t=ic(Vl);if(t){Bl?.abort(),Fl.value={status:`ready`,key:e,a:t,partial:null,error:null},Jl(t),Xl();return}Fl.value={...Fl.value,status:`waiting`,key:e,error:null};let n=Vl;zl=window.setTimeout(()=>void Yl(n,e),Ol)}function $l(e){clearTimeout(zl),Bl?.abort(),Ul=!1;let t=ic(Vl);Fl.value=t?{status:`ready`,key:e,a:t,partial:null,error:null}:{...Fl.value,status:`idle`,key:e,partial:null,error:null}}function eu(){Wl=!0,Gl=jl.peek(),na(()=>{let e=W.value,t=Pl.value,n=R.value,r=jl.value;if(!e.baseId||!t)return;let i=Cn(t,Ca.value);if(i){Ri(()=>{Vl=Hl=null,clearTimeout(zl),Bl?.abort(),Fl.value={...Fl.value,status:`error`,key:``,partial:null,error:i}});return}let a=Sa.value.language;Vl=Dl(n,wa.value,e,t,xl,{language:a}),Hl=Dl(n,wa.value,e,t,xl,{unsteered:!0,language:a}),Ri(()=>{let e=rc(Vl),t=Fl.value,n=r&&!Wl,i=r&&!Gl;Gl=r,(e!==t.key||n&&i&&(t.status===`idle`||t.status===`error`))&&(e!==t.key&&!Wl&&(kl.value=`A`),n?Ql(e):$l(e))})}),Wl=!1}function tu(){let e=W.value,t=Dl(R.value,wa.value,e,Pl.value,xl,{language:Sa.value.language});Fl.value={...Fl.value,key:``},Yl(t,rc(t))}function nu(e){if(e===`A`)return iu();kl.value=`B`;let t=Il.value.take;t?Ks(Rl,t.pcm,t.sr):Xl().then(()=>Il.value.take&&kl.value===`B`&&Ks(`preview:B`,Il.value.take.pcm,Il.value.take.sr))}function ru(){qs(`preview:A`)||qs(`preview:B`)?Ws():nu(kl.value)}function iu(){kl.value=`A`;let e=Fl.value;if(e.status===`ready`&&e.a)return Ks(Ll,e.a.pcm,e.a.sr);Vl?(Ul=!0,e.status!==`rendering`&&(clearTimeout(zl),Yl(Vl,rc(Vl)))):W.value.baseId||z(`Pick a voice first`)}var au=Symbol.for(`pv`),ou=0;Array.isArray;function G(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:au,__v:--ou,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),k.vnode&&k.vnode(l),l}function su({d:e}){let t=Math.round(e.fraction*100);return G(`div`,{class:`dl`,role:`progressbar`,"aria-label":e.label,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t,"aria-valuetext":`${t}% · ${e.detail}`,children:[G(`div`,{class:`dl-head`,children:[G(`span`,{class:`dl-label`,children:e.label}),G(`span`,{class:`dl-pct`,children:[t,`%`]})]}),G(`div`,{class:`dl-track`,children:G(`div`,{class:`dl-fill`,style:{width:`${e.fraction*100}%`}})}),G(`span`,{class:`dl-detail`,children:e.detail})]})}function K({name:e,size:n=16,filled:r,title:i}){let o=r??!!t[e];return G(`svg`,{class:`icon`,width:n,height:n,viewBox:`0 0 24 24`,"aria-hidden":i?void 0:`true`,role:i?`img`:void 0,children:[i&&G(`title`,{children:i}),G(`path`,{d:a[e]??``,fill:o?`currentColor`:`none`,stroke:o?`none`:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}var cu=Uint8Array,lu=Uint16Array,uu=Int32Array,du=new cu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fu=new cu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),pu=new cu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mu=function(e,t){for(var n=new lu(31),r=0;r<31;++r)n[r]=t+=1<>1|(Su&21845)<<1;Cu=(Cu&52428)>>2|(Cu&13107)<<2,Cu=(Cu&61680)>>4|(Cu&3855)<<4,xu[Su]=((Cu&65280)>>8|(Cu&255)<<8)>>1}for(var wu=(function(e,t,n){for(var r=e.length,i=0,a=new lu(t);i>c]=l}else for(s=new lu(r),i=0;i>15-e[i]);return s}),Tu=new cu(288),Su=0;Su<144;++Su)Tu[Su]=8;for(var Su=144;Su<256;++Su)Tu[Su]=9;for(var Su=256;Su<280;++Su)Tu[Su]=7;for(var Su=280;Su<288;++Su)Tu[Su]=8;for(var Eu=new cu(32),Su=0;Su<32;++Su)Eu[Su]=5;var Du=wu(Tu,9,0),Ou=wu(Tu,9,1),ku=wu(Eu,5,0),Au=wu(Eu,5,1),ju=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},Mu=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Nu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Pu=function(e){return(e+7)/8|0},Fu=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new cu(e.subarray(t,n))},Iu=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Lu=function(e,t,n){var r=Error(t||Iu[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Lu),!n)throw r;return r},Ru=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new cu(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new cu(i*3));var l=function(e){var t=n.length;if(e>t){var r=new cu(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=Mu(e,d,1);var v=Mu(e,d+1,3);if(d+=3,!v){var y=Pu(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Lu(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=Ou,m=Au,h=9,g=5;else if(v==2){var S=Mu(e,d,31)+257,C=Mu(e,d+10,15)+4,w=S+Mu(e,d+5,31)+1;d+=14;for(var T=new cu(w),E=new cu(19),D=0;D>4;if(y<16)T[D++]=y;else{var re=0,ie=0;for(y==16?(ie=3+Mu(e,d,3),d+=2,re=T[D-1]):y==17?(ie=3+Mu(e,d,7),d+=3):y==18&&(ie=11+Mu(e,d,127),d+=7);ie--;)T[D++]=re}}var ae=T.subarray(0,S),oe=T.subarray(S);h=ju(ae),g=ju(oe),p=wu(ae,h,1),m=wu(oe,g,1)}else Lu(1);if(d>_){c&&Lu(0);break}}s&&l(f+131072);for(var k=(1<>4;if(d+=re&15,d>_){c&&Lu(0);break}if(re||Lu(2),le<256)n[f++]=le;else if(le==256){ce=d,p=null;break}else{var ue=le-254;if(le>264){var D=le-257,de=du[D];ue=Mu(e,d,(1<>4;fe||Lu(3),d+=fe&15;var oe=yu[pe];if(pe>3){var de=fu[pe];oe+=Nu(e,d)&(1<_){c&&Lu(0);break}s&&l(f+131072);var me=f+ue;if(f>8},Bu=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Vu=function(e,t){for(var n=[],r=0;rf&&(f=a[r].s);var p=new lu(f+1),m=Hu(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<t)h+=_-(1<>=g;h>0;){var y=a[r].s;p[y]=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new cu(p),l:m}},Hu=function(e,t,n){return e.s==-1?Math.max(Hu(e.l,t,n+1),Hu(e.r,t,n+1)):t[e.s]=n},Uu=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new lu(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Wu=function(e,t){for(var n=0,r=0;r>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a4&&!E[pu[O-1]];--O);var ee=l+5<<3,te=Wu(i,Tu)+Wu(a,Eu)+o,ne=Wu(i,f)+Wu(a,h)+o+14+3*O+Wu(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&ee<=te&&ee<=ne)return Gu(t,u,e.subarray(c,c+l));var re,ie,ae,oe;if(zu(t,u,1+(ne15&&(zu(t,u,le[w]>>5&127),u+=le[w]>>12)}}else re=Du,ie=Tu,ae=ku,oe=Eu;for(var w=0;w255){var ue=de>>18&31;Bu(t,u,re[ue+257]),u+=ie[ue+257],ue>7&&(zu(t,u,de>>23&31),u+=du[ue]);var fe=de&31;Bu(t,u,ae[fe]),u+=oe[fe],fe>3&&(Bu(t,u,de>>5&8191),u+=fu[fe])}else Bu(t,u,re[de]),u+=ie[de]}return Bu(t,u,re[256]),u+ie[256]},qu=new uu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ju=new cu(0),Yu=function(e,t,n,r,i,a){var o=a.z||e.length,s=new cu(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=qu[t-1],f=d>>13,p=d&8191,m=(1<7e3||E>24576)&&(re>423||!l)){u=Ku(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var ie=0;ie<286;++ie)x[ie]=0;for(var ie=0;ie<30;++ie)S[ie]=0}var ae=2,oe=0,k=p,se=te-ne&32767;if(re>2&&ee==y(T-se))for(var ce=Math.min(f,re)-1,le=Math.min(32767,T),ue=Math.min(258,re);se<=le&&--k&&te!=ne;){if(e[T+ae]==e[T+ae-se]){for(var de=0;deae){if(ae=de,oe=se,de>ce)break;for(var fe=Math.min(se,de-2),pe=0,ie=0;iepe&&(pe=he,ne=me)}}}te=ne,ne=h[te],se+=te-ne&32767}if(oe){b[E++]=268435456|_u[ae]<<18|bu[oe];var ge=_u[ae]&31,_e=bu[oe]&31;w+=du[ge]+fu[_e],++x[257+ge],++S[_e],D=T+ae,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T=o&&(c[u/8|0]=l,ve=o),u=Gu(c,u+1,e.subarray(T,ve))}a.i=o}return Fu(s,0,r+Pu(u)+i)},Xu=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),Zu=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r>>8;e=n},d:function(){return~e}}},Qu=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new cu(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return Yu(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},$u=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},ed=function(e,t){return e[t]|e[t+1]<<8},td=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},nd=function(e,t){return td(e,t)+td(e,t+4)*4294967296},rd=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function id(e,t){return Qu(e,t||{},0,0)}function ad(e,t){return Ru(e,{i:2},t&&t.out,t&&t.dictionary)}var od=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=$u(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,s]:(n[o+=`/`]=[new cu(0),s],od(a,o,n,r))}},sd=typeof TextEncoder<`u`&&new TextEncoder,cd=typeof TextDecoder<`u`&&new TextDecoder;try{cd.decode(Ju,{stream:!0})}catch{}var ld=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Fu(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function ud(e,t){if(t){for(var n=new cu(e.length),r=0;r>1)),o=0,s=function(e){a[o++]=e},r=0;ra.length){var c=new cu(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return Fu(a,0,o)}function dd(e,t){if(t){for(var n=``,r=0;r65535&&Lu(9),t+=r+4}return t},gd=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=hd(l);rd(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&Lu(10),rd(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(rd(e,t,n.crc),rd(e,t+4,a<0?-a-2:a),rd(e,t+8,n.size)),rd(e,t+12,c),rd(e,t+14,d),t+=16,o!=null&&(rd(e,t,u),rd(e,t+6,n.attrs),rd(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;rd(e,t,+m),rd(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},_d=function(e,t,n,r,i){rd(e,t,101010256),rd(e,t+8,n),rd(e,t+10,n),rd(e,t+12,r),rd(e,t+16,i)};function vd(e,t){t||={};var n={},r=[];od(e,``,n,t);var i=0,a=0;for(var o in n){var s=n[o],c=s[0],l=s[1],u=l.level==0?0:8,d=ud(o),f=d.length,p=l.comment,m=p&&ud(p),h=m&&m.length,g=hd(l.extra);f>65535&&Lu(11);var _=u?id(c,l):c,v=_.length,y=Zu();y.p(c),r.push($u(l,{size:c.length,crc:y.d(),c:_,f:d,m,u:f!=o.length||m&&p.length!=h,o:i,compression:u})),i+=30+f+g+v,a+=76+2*(f+g)+(h||0)+v}for(var b=new cu(a+22),x=i,S=a-i,C=0;C65558)&&Lu(13);var i=ed(e,r+8);if(!i)return{};var a=td(e,r+16),o=td(e,r-20)==117853008;if(o){var s=td(e,r-12);o=td(e,s)==101075792,o&&(i=td(e,s+32),a=td(e,s+48))}for(var c=t&&t.filter,l=0;l({id:It(),text:e,spans:[],...t?{voice:t}:{}});function xd(e,t={}){let n=e.split(/\n+/);return(t.sentences===!1?n:n.flatMap(e=>e.split(/(?<=[.!?…])\s+(?=\S)/))).map(e=>e.trim()).filter(Boolean)}function Sd(e,t){let n=new Map;for(let t of e)n.set(t.text,[...n.get(t.text)??[],t]);let r=new Set;return{lines:t.map(e=>{let t=n.get(e)?.shift()??null;return t&&r.add(t.id),t}).map((n,i)=>{if(n)return n;let a=t[i],o=e[i];return o&&!r.has(o.id)?(r.add(o.id),{...o,text:a,spans:Sl(o.spans,o.text,a)}):bd(a)}),dropped:e.filter(e=>!r.has(e.id))}}function Cd(e,t,n={}){return e.text===t.text?e.speaker_embedding_id!==t.speaker_embedding_id||e.speaker_mode!==t.speaker_mode?`voice changed`:(e.language??`en_us`)===(t.language??`en_us`)?JSON.stringify(e.control_spans??[])===JSON.stringify(t.control_spans??[])?JSON.stringify(e.controls??{})===JSON.stringify(t.controls??{})?e.tag_cfg_scale===t.tag_cfg_scale?(e.decoder??null)===(t.decoder??null)?null:`decoder changed`:`tag strength changed`:n.voiceEdited?`voice edited`:`baseline changed`:`painting changed`:`language changed`:`text changed`}var wd=15,Td=()=>({lines:[],baseline:{},voice:null,gap:.35}),Ed=new js(Td()),q=Ed.state,J=F({}),Dd=F({}),Od=F({}),kd=F([]),Ad=F(null),jd=I(()=>Ad.value!==null),Md=F(null),Nd=I(()=>{let e=q.value.voice;return e&&zc.value.find(t=>t.id===e)?.design||W.value});function Pd(e){return e.voice??q.value.voice}function Fd(e){let t=Pd(e);return t&&zc.value.find(e=>e.id===t)?.design||W.value}var Id=e=>Ed.set(e(q.value)),Ld=e=>Ed.apply(e(q.value));function Rd(e,t){Ld(n=>({...n,lines:n.lines.map(n=>n.id===e?{...n,text:t,spans:Sl(n.spans,n.text,t)}:n)})),Od.value[e]&&(Od.value={...Od.value,[e]:null})}function zd(e){let{lines:t}=Sd(q.value.lines,e);Ld(e=>({...e,lines:t}))}function Bd(e){let t=q.value.lines.filter(t=>t.voice===e).map(e=>e.id);return Ld(t=>({...t,voice:t.voice===e?null:t.voice,lines:t.lines.map(t=>t.voice===e?{...t,voice:null}:t)})),t}function Vd(e,t,n){let r=new Set(e);Ld(e=>({...e,voice:n===void 0?e.voice:n,lines:e.lines.map(e=>r.has(e.id)?{...e,voice:t}:e)}))}function Hd(e,t=``,n){let r=bd(t,n);return Ld(t=>{let n=[...t.lines],i=e?n.findIndex(t=>t.id===e)+1:n.length;return n.splice(i,0,r),{...t,lines:n}}),r.id}function Ud(e){let t=q.value.lines.findIndex(t=>t.id===e);if(t<0)return null;let n=q.value.lines[t],r=J.value[e]??[];return Ld(t=>({...t,lines:t.lines.filter(t=>t.id!==e)})),{line:n,index:t,takes:r}}function Wd(e,t,n){Ld(n=>{let r=n.lines.filter(t=>t.id!==e.id),i=Math.min(t,r.length);return{...n,lines:[...r.slice(0,i),e,...r.slice(i)]}}),n.length&&(J.value={...J.value,[e.id]:n})}function Gd(e,t){Ld(n=>{let r=[...n.lines],i=r.findIndex(t=>t.id===e),a=i+t;return i<0||a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,lines:r})})}function Kd(e){Ld(t=>({...t,voice:e}))}function qd(e,t){Ld(n=>({...n,lines:n.lines.map(n=>n.id===e?{...n,voice:t}:n)}))}var Jd=[0,1.5];function Yd(e,t){Ed.patch({...q.value,voiceColors:{...q.value.voiceColors,[e]:t}})}function Xd(e,t){Id(n=>({...n,baseline:{...n.baseline,[e]:Math.round(t*100)/100}}))}function Zd(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function Qd(e){let t=e.map(e=>({...e,values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e))})).filter(e=>e.end>e.start&&Object.keys(e.values).length).sort((e,t)=>e.start-t.start),n=[];for(let e of t){let t=n[n.length-1];t&&t.end===e.start&&Zd(t.values,e.values)?n[n.length-1]={...t,end:e.end}:n.push(e)}return n}function $d(e,t,n,r,i){let a=[],o=[];for(let r of e){if(r.end<=t||r.start>=n){a.push(r);continue}r.startn&&a.push({...r,id:It(),start:n});let e={...r,start:Math.max(r.start,t),end:Math.min(r.end,n)};o.push(e)}o.sort((e,t)=>e.start-t.start);let s=t,c=[];for(let e of o)e.start>s&&c.push({id:It(),start:s,end:e.start,values:{}}),c.push(e),s=e.end;s({...a,lines:a.lines.map(a=>a.id===e?{...a,spans:$d(a.spans,t,n,r,i)}:a)}))}function tf(e,t){return e.spans.find(e=>t>=e.start&&tr>=e.start&&rr>=e.start&&rt.text===e.text),r=n[n.length-1],i=Sa.value.language,a=r?.audio.spanFollow===`reading`&&(r.request.language??`en_us`)===i,o=r&&!a?nf(r):void 0;return Dl(R.value,wa.value,Fd(e),e.text,t,{extra:q.value.baseline,spans:e.spans,spanRate:o,language:i})}var af=new Map;function of(e){af.get(e)?.abort()}async function sf(e,t){let n=q.value.lines.find(t=>t.id===e);if(!n||!n.text.trim())return!1;let r=Cn(n.text,Ca.value);if(r)return Od.value={...Od.value,[e]:r},!1;af.get(e)?.abort();let i=new AbortController;af.set(e,i),t?.addEventListener(`abort`,()=>i.abort(),{once:!0}),t?.aborted&&i.abort();let a=(J.value[e]??[]).length?Math.floor(Math.random()*1e6):xl;Dd.value={...Dd.value,[e]:!0},Od.value={...Od.value,[e]:null};try{let t=rf(n,a),r=await cc(t,{signal:i.signal}),o=J.value[e]??[],s={id:It(),text:n.text,seed:a,request:t,audio:r,createdAt:Date.now(),starred:!0},c=[...o.map(e=>e.starred?{...e,starred:!1}:e),s];return J.value={...J.value,[e]:c},kd.value.includes(e)&&(kd.value=kd.value.filter(t=>t!==e)),!0}catch(t){return lc(t)||(Od.value={...Od.value,[e]:V(t)},kd.value.includes(e)||(kd.value=[...kd.value,e])),!1}finally{af.get(e)===i&&af.delete(e),Dd.value={...Dd.value,[e]:!1}}}var cf=F(null),lf=null;function uf(){lf?.abort()}async function df(e){if(!e.length)return;lf?.abort();let t=new AbortController;lf=t,cf.value={total:e.length,done:0,failed:0},await Promise.all(e.map(async e=>{let n=await sf(e,t.signal),r=cf.value;r&&lf===t&&(cf.value={...r,done:r.done+1,failed:r.failed+(n||t.signal.aborted?0:1)})})),lf===t&&(lf=null,cf.value=null)}function ff(e,t){J.value={...J.value,[e]:(J.value[e]??[]).map(e=>({...e,starred:e.id===t}))}}function pf(e,t){let n=J.value[e]??[],r=n.findIndex(e=>e.id===t);if(r<0)return null;let i=n[r],a=n.filter(e=>e.id!==t);return a.length&&!a.some(e=>e.starred)&&(a[a.length-1]={...a[a.length-1],starred:!0}),J.value={...J.value,[e]:a},{take:i,index:r,wasStarred:i.starred}}function mf(e,t,n,r){let i=(J.value[e]??[]).filter(e=>e.id!==t.id).map(e=>r?{...e,starred:!1}:e),a=Math.min(n,i.length);J.value={...J.value,[e]:[...i.slice(0,a),{...t,starred:r},...i.slice(a)]}}function hf(e,t){let n=(J.value[e]??[]).map(e=>({...e,starred:!1}));return J.value={...J.value,[e]:[...n,{...t,starred:!0}]},n.length+1}var gf=I(()=>q.value.lines.map(e=>{let t=J.value[e.id]??[];return{line:e,take:t.find(e=>e.starred)??t[t.length-1]??null}}));function _f(e,t){return bf(e,t)!==null}var vf=F(0);na(()=>{L.value,wa.value,Sa.value.language,W.value,zc.value,q.value.baseline,q.value.voice,Ri(()=>vf.value++)});var yf=new WeakMap;function bf(e,t){let n=vf.value,r=yf.get(t);if(r&&r.line===e&&r.context===n)return r.reason;let i;if(t.edited)i=t.text===e.text?null:`text changed`;else{let n=rf(e,t.seed),r=e=>({...e,control_span_rate:void 0,control_span_follow:void 0}),a=r(t.request),o=r(n),s=a.controls??{},c=o.controls??{},l=[...new Set([...Object.keys(s),...Object.keys(c)])].filter(e=>s[e]!==c[e]),u=new Set(Object.keys(Yt(R.value,q.value.baseline,{},Fd(e).mode)));i=Cd(a,o,{voiceEdited:l.length>0&&l.some(e=>!u.has(e))})??(JSON.stringify(a)===JSON.stringify(o)?null:`settings changed`)}return yf.set(t,{line:e,context:n,reason:i}),i}var xf=I(()=>gf.value.flatMap(({line:e,take:t})=>t&&_f(e,t)?[e]:[])),Sf=0,Cf=!1;function wf(){Cf=!0,queueMicrotask(()=>Cf=!1)}na(()=>{let e=xf.value.length;Ri(()=>{let t=e>Sf&&e-Sf>=2;Sf=e,t&&!Cf&&z(`${e} lines now differ from their keepers`,`info`,{label:`Regenerate`,run:()=>void Tf()})})});function Tf(){return df(xf.value.map(e=>e.id))}var Ef=I(()=>{let e=q.value.gap,t=[],n=0;for(let[r,{line:i,take:a}]of gf.value.entries()){let o=a?a.audio.pcm.length/a.audio.sr:Math.max(.8,i.text.length/15),s=r?n+e:0;t.push({line:i,take:a,start:s,duration:o}),n=s+o}return{clips:t,total:n}});function Df(){let e=gf.value.flatMap(({take:e})=>e?[e.audio]:[]);return e.length?pn(e,q.value.gap):null}var Of=`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function kf(e,t){let n=[...t.querySelectorAll(Of)].filter(e=>e.offsetParent!==null);if(!n.length)return;let r=n.indexOf(document.activeElement);e.preventDefault(),n[e.shiftKey?r<=0?n.length-1:r-1:r===n.length-1?0:r+1].focus()}function Af(e,t){(t&&e.querySelector(`${t} button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)||e.querySelector(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`))?.focus({preventScroll:!0})}function jf(e,t){return n=>{if(n.stopPropagation(),n.key===`Escape`)n.preventDefault(),t();else if(n.key===`Tab`){let t=e();t&&kf(n,t)}}}var Mf=F(null);function Nf(e,t={}){Mf.value?.resolve(!1);let{promise:n,resolve:r}=Promise.withResolvers();return Mf.value={...t,text:e,resolve:r},n}function Pf(){let e=Mf.value;return e?G(Ff,{q:e}):null}function Ff({q:e}){let t=N(null),n=N(null),r=t=>{Mf.peek()===e&&(Mf.value=null,e.resolve(t))};return mt(()=>{let e=document.activeElement,t=Ma.peek();return Ma.value=!0,n.current?.focus({preventScroll:!0}),()=>{Ma.value=t,e?.isConnected&&e.focus({preventScroll:!0})}},[]),G(`div`,{class:`confirm-backdrop`,onClick:e=>e.target===e.currentTarget&&r(!1),children:G(`div`,{ref:t,class:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-text`,onKeyDown:jf(()=>t.current,()=>r(!1)),children:[e.title&&G(`h2`,{id:`confirm-title`,children:e.title}),G(`p`,{id:`confirm-text`,class:e.title?void 0:`confirm-only`,children:e.text}),G(`div`,{class:`confirm-actions`,children:[G(`button`,{ref:n,class:`btn sm ghost`,onClick:()=>r(!1),children:`Cancel`}),G(`button`,{class:`btn sm ${e.danger?`proj-danger`:`primary`}`,onClick:()=>r(!0),children:e.ok??`Continue`})]})]})})}var If=new js(null),Lf=If.state,Y=I(()=>Lf.value?Lf.value.versions[Lf.value.current]:null),Rf=F(``),zf=F([]),Bf=!1,Vf=F(!1),Hf=F({}),Uf=F(new Map),Wf=I(()=>Sp.value&&Uf.value.get(Sp.value)||null);function Gf(e){let t=new Map(Uf.value),n=e?.versionId??Sp.value;n&&(e?t.set(n,e):t.delete(n),Uf.value=t)}var Kf=F(`version`),X=F(null),qf=F(null),Jf=F(!1),Yf=F(0),Xf=F(null),Zf=F(`start`),Qf=F(yl(`edit.takes`,2));bl(`edit.takes`,Qf);var $f=F(yl(`edit.margin`,.08));bl(`edit.margin`,$f);var ep=F(null),tp=F(yl(`edit.context`,4));bl(`edit.context`,tp);var np=I(()=>L.value.edit),rp=I(()=>!!L.value?.edit.speech_editing),ip=I(()=>!!L.value?.edit.edit_transcribe),ap=I(()=>Math.min(np.value.edit_max_seconds,np.value.edit_align_max_seconds)),op=I(()=>np.value.edit_frame_rate||15),sp=I(()=>R.value.ui.controls.filter(e=>e.spannable)),cp=I(()=>{let e=Wf.value;return e&&e.versionId===Y.value?.id?e.takes[e.selected]??null:null}),lp=I(()=>{let e=Kf.value===`take`?cp.value:null,t=Y.value;return e?{kind:`take`,id:`edit:take:${e.id}`,pcm:e.pcm,sr:e.sr,duration:e.pcm.length/e.sr,words:e.words??[],label:e.label}:t?{kind:`version`,id:`edit:v:${t.id}`,pcm:t.pcm,sr:t.sr,duration:t.pcm.length/t.sr,words:t.words,label:t.label}:null}),up=I(()=>rp.value&&!!Ca.value),dp=I(()=>!!Y.value&&!Y.value.transcript),fp=I(()=>up.value&&!Vf.value?Cn(Rf.value,Ca.value):null),pp=I(()=>{let e=zf.value.length,t=np.value.edit_max_spans;return e>t?`Too many separate changes (${e}). One generation handles at most ${t} regions: make fewer changes, move them closer, or remove a manual region.`:null}),mp=e=>e/op.value;async function hp(e,t){return _(te(e,t).buffer)}var gp=F({}),_p=(e,t)=>`${e.kind}:${e.label}:${t.toFixed(2)}`,vp=!1,yp=e=>vp||!ip.value?e:`${e} (the server's first use loads speech recognition: about half a minute)`,bp=F(``);async function xp(e,t,n,r,i){let a=!!r&&Sn(r,null).groups.length>0,o=(a?``:r?.trim())??``,s=!o&&ip.value,c=ap.value,l=t.length/n;if(l>c)return z(`Editing opens clips up to ${Math.round(c)} s (this one is ${l.toFixed(1)} s).`,`error`,{label:`Open the first ${Math.round(c)} s`,run:()=>void xp(e,t.slice(0,Math.floor((c-.05)*n)),n,r,i)}),!1;if(l<.3)return z(`That clip is too short to edit.`,`error`),!1;if(X.value)return!1;let u=Lf.value;if(u&&(u.versions.length>1||Cp.value||Uf.value.size>0)&&!await Nf(`Opening another clip closes “${u.name}” — unsaved text, regions and takes are lost. Continue?`,{ok:`Open`,danger:!0}))return!1;bp.value=a?Dn(r):``;let d=Sa.value.language,f=i??gp.value[_p(e,l)]??(ee.includes(d)?d:`en_us`);$p=new AbortController,X.value={label:o?`Aligning the transcript…`:s?yp(`Transcribing…`):`Opening…`,started:performance.now()},qf.value=null,Aa.value=`edit`;try{let r=await hp(t,n),i=o?await Mo(r,o,f,$p.signal):s?await jo(r,f,$p.signal):{text:``,duration:l,words:[]};s&&(vp=!0);let a={id:It(),label:`Original`,pcm:t,sr:n,b64:r,duration:i.duration||l,transcript:i.text,words:i.words,alignedWords:i.words,automatic:s};return Ws(),Uf.value=new Map,If.reset({name:e.label,source:e,language:f,versions:[a],current:0}),gp.value={...gp.value,[_p(e,l)]:f},!0}catch(e){return lc(e)?z(`Cancelled`):z(`Couldn’t open the clip: ${V(e)}`,`error`),!1}finally{X.value=null,$p=null}}var Sp=I(()=>Y.value?.id??null);na(()=>{Sp.value;let e=Ri(()=>Y.value);Ri(()=>{Xf.value=null,qf.value=null,Kf.value=`version`,Vf.value=!!e&&!e.transcript,Yf.value=0,Bf=!1,zf.value=[],Rf.value=e?.transcript??``,e&&Up()})});var Cp=I(()=>{let e=Y.value;return!!e&&(Rf.value.trim()!==(e.transcript??``).trim()||zf.value.length>0)}),wp=null;na(()=>{let e=Y.value,t=e?.words??null;t&&wp&&t!==wp&&Ri(()=>Sp.value)===e.id&&Ri(()=>Up()),wp=t});var Tp=.04,Ep=.002,Dp=F(yl(`edit.preroll`,!1));bl(`edit.preroll`,Dp);var Op=(e,t)=>!t||Math.abs(e.start-t.start)>1e-4||Math.abs(e.end-t.end)>1e-4,kp=I(()=>{let e=Y.value;return e?e.words.filter((t,n)=>Op(t,e.alignedWords[n])).length:0}),Ap=e=>{let t=Y.value;return!!t&&Op(t.words[e],t.alignedWords[e])};function jp(e){let t=Lf.value;t&&If.set({...t,versions:t.versions.map((n,r)=>r===t.current?{...n,words:e}:n)})}function Mp(e,t,n,r=!1){let i=Y.value;if(!i||!i.words[e])return;let a=i.words.map(e=>({...e})),o=a[e],s=a[e-1],c=a[e+1];if(t===`start`){let e=!r&&s&&Math.abs(s.end-o.start)Math.round(e*1e4)/1e4,Pp={begin:()=>If.begin(),end:()=>If.end()},Fp=0;function Ip(e){let t=Xf.value,n=Y.value;if(t===null||!n)return;If.begin();let r=n.words[t];Mp(t,Zf.value,(Zf.value===`start`?r.start:r.end)+e),clearTimeout(Fp),Fp=window.setTimeout(()=>If.end(),700)}function Lp(){let e=Lf.value,t=Y.value;e&&t&&kp.value&&(If.apply({...e,versions:e.versions.map((t,n)=>n===e.current?{...t,words:t.alignedWords}:t)}),z(`Word timings reset to the alignment`))}function Rp(e){let t=lp.value,n=t?.words[e];t&&n&&Ks(t.id,t.pcm,t.sr,Math.max(0,n.start-(Dp.value?.3:0)),void 0,n.end)}var zp=I(()=>{let e=Y.value;return!e||e.duration<=16?[]:yr(e.words,zf.value.map(e=>[mp(e.start),mp(e.end)]),tp.value,e.duration)}),Bp=(e,t)=>Math.max(0,Math.min(e.end,t.end)-Math.max(e.start,t.start));function Vp(e){let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start||e.end-t.end)){let e=t[t.length-1];if(e&&n.start-e.end<5){let r=Object.keys(e.values).length>=Object.keys(n.values).length;t[t.length-1]={...e,end:Math.max(e.end,n.end),changes:[...e.changes,...n.changes],manual:e.manual||n.manual,values:r?e.values:n.values,edited:e.edited||n.edited,mergedFrom:(e.mergedFrom??1)+(n.mergedFrom??1)}}else t.push({...n,mergedFrom:void 0})}return t}function Hp(e){let t=Y.value,n=zf.value.find(t=>t.id===e);if(!t||!n||!n.changes.length)return;let r=dr(t.words,Rf.value,{duration:t.duration,frameRate:op.value,marginSeconds:$f.value,groups:up.value}),i=t.words.flatMap(e=>e.tokens.map(()=>e)),a=Rf.value;for(let e of[...n.changes].sort((e,t)=>t.j1-e.j1)){let t=e.j1e.j1?r.owners[e.j2-1][1]:t,o=[...new Set(i.slice(e.i1,e.i2))].map(e=>e.word),s=e.j1===e.j2&&t>0&&t({id:It(),start:e.start,end:e.end,changes:e.changes,manual:!1,values:{}})),...n.filter(e=>e.manual).map(e=>({...e}))]);for(let e of r){if(Object.keys(e.values).length)continue;let t=null;for(let r of n)Bp(r,e)>(t?Bp(t,e):0)&&(t=r);t&&(e.values=t.values)}zf.value=r}function Wp(e){Rf.value=e,Up()}function Gp(e,t){let n=Y.value;if(!n)return;let r=Math.min(e,t),i=Math.max(e,t);for(let e of n.words)e.starte.end<=r+1e-6).pop(),s=n.words.find(e=>e.start>=i-1e-6),[c,l]=ur(r,i,o?o.end:null,s?s.start:null,$f.value,op.value,a);zf.value=Vp([...zf.value,{id:It(),start:c,end:l,changes:[],manual:!0,values:{}}])}function Kp(e,t,n){let r=Y.value;if(!r)return;let i=Math.ceil(r.duration*op.value);zf.value=Vp(zf.value.map(r=>{if(r.id!==e)return r;r.manual||(Bf=!0);let a=P(Math.round(t*op.value),0,i-1);return{...r,start:a,end:P(Math.round(n*op.value),a+1,i),edited:!0}}))}function qp(e){zf.value=zf.value.filter(t=>t.id!==e)}function Jp(e,t,n){zf.value=zf.value.map(r=>{if(r.id!==e)return r;let i={...r.values,[t]:Math.round(n*100)/100};return i[t]||delete i[t],{...r,values:i}})}function Yp(e){zf.value=zf.value.map(t=>t.id===e?{...t,values:{}}:t)}function Xp(e,t){let n={...Hf.value,[e]:Math.round(t*100)/100};n[e]||delete n[e],Hf.value=n}function Zp(e){let t=Y.value;if(e.manual&&!e.changes.length){let n=mp(e.start),r=mp(e.end),i=(t?.words??[]).filter(e=>(e.start+e.end)/2>=n&&(e.start+e.end)/2e.word.replace(/^[^\p{L}\p{N}']+|[^\p{L}\p{N}']+$/gu,``));return i.length?`re-say “${i.join(` `)}”`:`re-say this stretch`}return t&&mr(e.changes,t.words,Rf.value,up.value)||`changed`}function Qp(e){let t={};for(let n of sp.value){let r=e[n.id];r&&Kt(n,r,t)}for(let e of Object.keys(t))t[e]=Math.round(t[e]*1e4)/1e4;return Object.keys(t).length?t:null}var $p=null;function em(e,t){let{pcm:n,sr:r}=D(h(e.audio_base64));return{id:It(),label:t,seed:e.seed,pcm:n,sr:r,b64:e.audio_base64,duration:e.duration,edited:e.edited_regions,fill:e.fill_seconds,stopped:e.stopped,verify:e.verify&&{...e.verify,groups:e.verify.groups?.map(e=>({...e,heard:e.heard?.toLowerCase()??null}))},words:e.words,contexts:[],direction:``,expected:[]}}function tm(e){return sp.value.filter(t=>e[t.id]).map(t=>{let n=e[t.id];return`${t.type===`bipolar`&&t.poles?t.poles[n<0?0:1]:t.label.toLowerCase()} ×${+Math.abs(n).toFixed(2)}`}).join(`, `)}function nm(e,t){let n=e.map((e,n)=>Object.keys(e.values).length?`r${t[n]+1} ${tm(e.values)}`:``).filter(Boolean);return Object.keys(Hf.value).length&&n.push(`all ${tm(Hf.value)}`),n.join(` · `)}var rm=I(()=>zf.value.some(e=>Object.keys(e.values).length)||Object.keys(Hf.value).length>0);function im(e,t){if(!e.verify)return t.spans.map(()=>[]);let n=lr(t.target,t.groups);return t.spans.map((r,i)=>{let a=[];for(let r of _r(t.targetTokens,e.verify.asr_text,t.wants[i]??[])){let e=n[r],i=e?t.target.slice(e[0],e[1]).replace(/^[^\p{L}\p{N}']+|[^\p{L}\p{N}']+$/gu,``):t.targetTokens[r].toLowerCase();a[a.length-1]!==i&&a.push(i)}return a})}function am(e,t){let{spans:n,changes:r,manual:i}=t,a=[];return im(e,t).forEach((e,t)=>e.length&&a.push({region:t,text:`Region ${t+1}: words not heard: ${e.join(`, `)}.`,unheard:!0})),n.forEach(([n,o],s)=>{let c=o-n,l=e.fill[s]??0,u=s+1,d=e.expected[s],f=r[s]??[],p=f.length>0&&f.every(e=>e.i1===e.i2&&Array.from({length:e.j2-e.j1},(n,r)=>t.targetTokens[e.j1+r]).every(rr));if(e.stopped[s]===!1)a.push({region:s,text:`Region ${u} never stopped (it ran out of room); this take is probably broken.`});else if(p)return;else d!=null&&d>0?l<.5*d?a.push({region:s,text:`Region ${u} came out ${l.toFixed(2)} s for about ${d.toFixed(2)} s of words: words were probably skipped.`}):l>2.5*d+1&&a.push({region:s,text:`Region ${u} came out ${l.toFixed(1)} s for about ${d.toFixed(1)} s of words: it probably ran on past them.`}):l>Math.max(3*c,c+3)?a.push({region:s,text:`Region ${u} came out ${(l/c).toFixed(0)}× longer than the original (${l.toFixed(1)} s): it probably ran on past the new words.`}):(r[s]??[]).some(e=>e.j2>e.j1)&&l<.15?a.push({region:s,text:`Region ${u} came out nearly empty (${l.toFixed(2)} s): the new words were probably dropped.`}):i[s]&&!(r[s]??[]).length&&l<.6*c&&a.push({region:s,text:`Region ${u} came out ${Math.round((1-l/c)*100)}% shorter than the words it re-says (${c.toFixed(2)} → ${l.toFixed(2)} s): words were probably skipped.`})}),a}function om(e,t,n=0){let r=e=>{let n=am(e,t);return[+!!n.some(e=>e.unheard),+!!n.some(e=>!e.unheard),e.verify?.wer??1/0]},i=(e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],a=n;for(let t=n+1;t!!Y.value&&!Vf.value&&zf.value.length>0&&!pp.value&&!fp.value&&!!Rf.value.trim()&&!X.value);function cm(e,t){let n=op.value,r=Math.round(e*n),i=Math.abs(e*n-r)<.02?r:e*n;return Math.round((i+t*.001)/n*1e6)/1e6}function lm(e,t,n,r=e.b64,i=e.transcript,a){up.value&&(t=wn(t,Ca.value).text);let o={audio_base64:r,original_text:i,...a?{original_words:a.map(e=>({word:e.word,start:e.start,end:e.end,tokens:e.tokens}))}:{},target_text:t,spans:n.map(e=>[cm(e.start,1),cm(e.end,-1)]),margin_seconds:$f.value,num_takes:Qf.value,verify:ip.value,seed:ep.value,language:Lf.value?.language??`en_us`};tp.value!==4&&(o.context_seconds=tp.value);let s=wa.value.decoder;s&&(o.decoder=s);let c=Qp(Hf.value);c&&(o.controls=c);let l=n.map(e=>Qp(e.values));return l.some(Boolean)&&(o.region_controls=l),o}async function um(){if(X.value)return dm();let e=Y.value;if(!e||!sm.value)return;let t=zf.value,n=Rf.value.trim(),r=lm(e,n,t.map(e=>({start:mp(e.start),end:mp(e.end),values:e.values})),e.b64,e.transcript,kp.value?e.words:void 0);$p=new AbortController,X.value={label:yp(`Generating ${r.num_takes} take${r.num_takes===1?``:`s`}…`),started:performance.now()},qf.value=null,Ws();try{let i=await No(r,$p.signal);r.verify&&(vp=!0);let a=i.contexts??[],o=i.takes.map((e,n)=>{let r=em(e,`Take ${n+1}`);return r.direction=nm(t,t.map((e,t)=>t)),r.expected=i.expected_seconds??[],r.contexts=a.map(([e,t])=>[hm(e,i.spans,r.edited),hm(t,i.spans,r.edited)]),r}),s=t.map(e=>e.changes),c=t.map(e=>e.manual),l=up.value,u=l?n:i.target_text||n,d={spans:i.spans,changes:s,manual:c,target:u,targetTokens:ar(u,l),wants:vr(e.words,u,t.map(e=>({start:mp(e.start),end:mp(e.end),changes:e.changes})),l),groups:l};Gf({versionId:e.id,...d,contexts:a,takes:o,selected:om(o,d)}),Kf.value=`take`,Yf.value=0}catch(e){lc(e)||(qf.value=V(e),Jf.value=e instanceof v&&e.status<500)}finally{X.value=null,$p=null}}function dm(){$p?.abort()}function fm(e){dm(),bp.value=``,Uf.value=new Map,If.reset(e)}async function pm(e){let t=Wf.value,n=cp.value,r=Y.value;if(!t||!n||!r||X.value)return;let i=zf.value[e],a=lm(r,t.target,[{start:n.edited[e][0],end:n.edited[e][1],values:i?.values??{}}],n.b64,ym(t,n));$p=new AbortController,X.value={label:yp(`Regenerating region ${e+1}…`),started:performance.now()},qf.value=null,Ws();try{let r=await No(a,$p.signal);a.verify&&(vp=!0);let o=r.takes.map((t,a)=>{let o=em(t,`${n.label} · region ${e+1} retry ${a+1}`),[s,c]=t.edited_regions[0],l=c-s-(n.edited[e][1]-n.edited[e][0]);return o.edited=n.edited.map((t,n)=>nr===e?t.fill_seconds[0]:n),o.stopped=n.stopped.map((n,r)=>r===e?t.stopped[0]:n),o.direction=nm([{values:i?.values??{}}],[e])||`r${e+1} undirected`,o.expected=n.edited.map((t,i)=>i===e?r.expected_seconds?.[0]??null:n.expected[i]??null),o.contexts=(r.contexts??[]).map(([e,t])=>[hm(e,n.edited,o.edited),hm(t,n.edited,o.edited)]),o}),s=[...t.takes,...o];Gf({...t,takes:s,selected:om(s,t,t.takes.length)}),Kf.value=`take`}catch(e){lc(e)||(qf.value=V(e),Jf.value=e instanceof v&&e.status<500)}finally{X.value=null,$p=null}}function mm(e){let t=Wf.value;if(!t||!t.takes[e])return;let n=B.value,r=n?Ms.value:Yf.value,i=Kf.value===`take`;Gf({...t,selected:e}),Kf.value=`take`;let a=t.takes[e],o=hm(r,i?t.takes[t.selected]?.edited??t.spans:t.spans,a.edited);Yf.value=o,n&&Ks(`edit:take:${a.id}`,a.pcm,a.sr,o)}function hm(e,t,n){let r=0;for(let i=0;i=e.duration-.05?0:Yf.value)}}function vm(e){let t=lp.value,n=cp.value,r=zf.value[e];if(!t)return;let i=t.kind===`take`&&n?n.edited[e]:r?[mp(r.start),mp(r.end)]:null;i&&Ks(t.id,t.pcm,t.sr,Math.max(0,i[0]-1),void 0,Math.min(t.duration,i[1]+.5))}function ym(e,t){return e.groups?Dn(e.target,(t.verify?.groups??[]).map(e=>e.heard)):e.target}async function bm(){let e=Wf.value,t=cp.value,n=Lf.value,r=Y.value;if(!e||!t||!n||!r||X.value)return;let i=n.versions.length-1-n.current;if(!(i>0&&!await Nf(i===1?`Keeping replaces v${n.current+1}. Continue?`:`Keeping replaces v${n.current+1}–v${n.versions.length-1}. Continue?`,{ok:`Keep`,danger:!0}))){$p=new AbortController,X.value={label:`Keeping the take…`,started:performance.now()};try{let i=ym(e,t),a=i===e.target&&t.words?t.words:(await Mo(t.b64,i,n.language,$p.signal)).words,o=mr(e.changes.flat(),r.words,e.target,e.groups)||(e.manual.some(Boolean)?`regenerated`:`edit`),s={id:It(),label:o,pcm:t.pcm,sr:t.sr,b64:t.b64,duration:t.duration,transcript:i,words:a,alignedWords:a,automatic:!1,...i===e.target?{}:{display:e.target}};Ws(),If.apply({...n,versions:[...n.versions.slice(0,n.current+1),s],current:n.current+1});let c=(t.verify?.groups??[]).map(e=>e.heard??`?`);z(i===e.target?`Kept ${t.label.toLowerCase()} as v${n.current+1}`:`Kept ${t.label.toLowerCase()} as v${n.current+1}; its transcript spells the pronunciations as heard (${c.join(`, `)||`guessed`})`,`ok`,{label:`Undo`,run:()=>{Ws(),If.undo()}})}catch(e){lc(e)?z(`Cancelled`):z(`Couldn’t keep the take: ${V(e)}`,`error`)}finally{X.value=null,$p=null}}}async function xm(){return!Cp.value||Nf(`Changing the version discards your unsaved text and regions. Continue?`,{ok:`Continue`,danger:!0})}async function Sm(e){let t=Lf.value;t&&e!==t.current&&t.versions[e]&&await xm()&&(Ws(),If.apply({...t,current:e}))}async function Cm(){If.canUndo.value&&await xm()&&(Ws(),If.undo())}async function wm(){If.canRedo.value&&await xm()&&(Ws(),If.redo())}var Tm=null;async function Em(e){if(X.value||!e&&dp.value)return;if(e){Tm=Rf.value,Vf.value=!0;return}let t=Y.value,n=Tm!==null&&Tm!==(t?.transcript??``);(!n||await Nf(`Leave the transcript fix? Your edited words are kept.`,{ok:`Leave`}))&&(Vf.value=!1,Rf.value=n?Tm:t?.transcript??``,Tm=null,Up())}function Dm(){let e=Lf.value,t=Y.value;e&&t&&t.automatic&&If.apply({...e,versions:e.versions.map((t,n)=>n===e.current?{...t,automatic:!1}:t)})}async function Om(e){let t=Lf.value,n=Y.value;if(!t||!n||X.value||e===t.language)return;let r=_p(t.source,t.versions[0].pcm.length/t.versions[0].sr);if(!n.transcript){If.apply({...t,language:e}),gp.value={...gp.value,[r]:e};return}if(!await xm())return;let i=n.automatic&&ip.value;$p=new AbortController,X.value={label:i?yp(`Transcribing…`):`Aligning the transcript…`,started:performance.now()};try{let a=i?await jo(n.b64,e,$p.signal):await Mo(n.b64,n.transcript,e,$p.signal);i&&(vp=!0);let o={...n,id:It(),transcript:a.text,words:a.words,alignedWords:a.words};If.apply({...t,language:e,versions:t.versions.map((e,n)=>n===t.current?o:e)}),gp.value={...gp.value,[r]:e},z(`${i?`Transcribed`:`Aligned`} in ${g(e)}`,`ok`)}catch(t){lc(t)?z(`Cancelled`):z(`Couldn’t switch to ${g(e)}: ${V(t)}`,`error`)}finally{X.value=null,$p=null}}async function km(e){let t=Lf.value,n=Y.value;if(!t||!n||!e.trim())return;let r=!n.transcript,i=Tm!==null&&Tm!==(n.transcript??``)?Tm:null;$p=new AbortController,X.value={label:r?`Aligning the transcript…`:`Re-aligning…`,started:performance.now()};try{let a=await Mo(n.b64,e.trim(),t.language,$p.signal),o={...n,id:It(),transcript:a.text,words:a.words,alignedWords:a.words,automatic:!1};If.apply({...t,versions:t.versions.map((e,n)=>n===t.current?o:e)}),Tm=null,i&&(Rf.value=i,Up()),z(r?`Transcript aligned: edit the words to change the speech`:`Transcript corrected and re-aligned`,`ok`)}catch(e){lc(e)?z(`Cancelled`):z(`Couldn’t ${r?`align`:`re-align`}: ${V(e)}`,`error`)}finally{X.value=null,$p=null}}var Am=I(()=>{let e=Lf.value?.source;if(!e||e.kind!==`take`||!e.lineId||!e.takeId)return null;let t=q.value.lines.find(t=>t.id===e.lineId),n=J.value[e.lineId]?.find(t=>t.id===e.takeId);return t&&n?{line:t,take:n}:null}),jm=I(()=>{let e=Lf.value;return!!e&&e.current>0&&e.source.kind===`take`&&!!Am.value});async function Mm(){let e=Lf.value,t=Y.value,n=Am.value;if(!e||!t||!n||!jm.value)return;let{line:r}=n,i={pcm:t.pcm,sr:t.sr,ttfbMs:0,totalMs:0},a=t.display??t.transcript;z(`Added to Direct as take ${hf(r.id,{id:It(),text:a,seed:0,request:rf(r,0),audio:i,createdAt:Date.now(),starred:!0,edited:!0})}`,`ok`,{label:`Go to Direct`,run:()=>Aa.value=`direct`}),r.text!==a&&await Nf(`Also change the line's text to “${a}”?`,{ok:`Change the text`})&&Rd(r.id,a)}var Nm=F(null),Pm=F(0);async function Fm(){if(Nm.value)return Nm.value.stop();let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return z(`Microphone unavailable: ${V(e)}`,`error`)}let t=E(e,e=>Pm.value=e),n=new MediaRecorder(e),r=[];n.ondataavailable=e=>r.push(e.data),n.onstop=async()=>{t.stop(),e.getTracks().forEach(e=>e.stop()),Nm.value=null;try{let{pcm:e,sr:t}=await Xs(await new Blob(r,{type:n.mimeType}).arrayBuffer());await xp({kind:`recording`,label:`Recording ${new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`},e,t)}catch(e){z(`Couldn’t read the recording: ${V(e)}`,`error`)}},n.start();let i=Math.min(120,ap.value),a=setTimeout(()=>n.state===`recording`&&n.stop(),i*1e3);Nm.value={started:Date.now(),stop:()=>{clearTimeout(a),n.state===`recording`&&n.stop()}}}async function Im(e){try{let{pcm:t,sr:n}=await Xs(await e.arrayBuffer());await xp({kind:`upload`,label:e.name.replace(/\.[^.]+$/,``)},t,n)}catch(t){z(`Couldn’t read ${e.name}: ${V(t)}`,`error`)}}var Lm=`application/x-float32`,Rm=new Map,zm=new WeakMap;function Bm(e,t){zm.set(e,t)}var Vm=class{info={};pending=new Map;hit(e,t){let n=zm.get(e),r=n===void 0?void 0:Rm.get(n)??this.pending.get(n)?.size;return n===void 0||r===void 0?null:(this.info[n]={type:t,size:r},n)}add(e,t,n){let r=ti(n);return zm.set(e,r),this.info[r]={type:t,size:n.byteLength},!Rm.has(r)&&!this.pending.has(r)&&this.pending.set(r,new Blob([n],{type:t})),r}audio(e,t,n){return this.hit(e,`audio/wav`)??this.add(e,`audio/wav`,n?new Uint8Array(n()):te(e,t))}wav(e){return this.hit(e,`audio/wav`)??this.add(e,`audio/wav`,new Uint8Array(e))}embedding(e){return this.hit(e,`application/x-float32`)??this.add(e,`application/x-float32`,new Uint8Array(e.slice().buffer))}},Hm={gender:{control:`gender`,logit_per_dose:1.31,clip_logit:3},age:{control:`age`,center_years:42,years_per_dose:8.7},landmarks:{}},Um=I(()=>R.value.ui.who??Hm),Wm=F({}),Gm=e=>Math.log(Math.max(1e-6,e)/Math.max(1e-6,1-e));function Km(e,t){let n=Um.value;return{x:Math.max(-n.gender.clip_logit,Math.min(n.gender.clip_logit,Gm(e)))/n.gender.logit_per_dose,y:(t-n.age.center_years)/n.age.years_per_dose,measured:!0}}function qm(e){if(!e)return{x:0,y:0,measured:!1};let t=Um.value.landmarks[e.label];return t?Km(t.female,t.age):Wm.value[e.id]??{x:0,y:0,measured:!1}}var Jm=e=>Um.value.age.center_years+e*Um.value.age.years_per_dose,Ym=e=>(e-Um.value.age.center_years)/Um.value.age.years_per_dose,Xm=e=>1/(1+Math.exp(-e*Um.value.gender.logit_per_dose)),Zm=I(()=>{let e=Um.value.gender.clip_logit/Um.value.gender.logit_per_dose+1.1;return{x:[-e,e],y:[Ym(14),Ym(84)]}});function Qm(e,t,n,r){let i=qm(t);Wm.value={...Wm.value,[e.id]:{x:i.x+n,y:i.y+r,measured:i.measured,from:t?.label}}}function $m(e,t){let n=e.lines.map(({id:e,text:t,spans:n,voice:r})=>({id:e,text:t,spans:n,...r?{voice:r}:{}})),r=(t?.lines??[]).map(({id:e,characterId:t,text:n})=>({id:e,text:n,spans:[],voice:t}));return{...e,lines:[...n,...r],gap:e.gap??t?.gap??.35}}function eh(e,t){let n=Date.now();return{schema:1,id:e.id,name:e.name,createdAt:n,updatedAt:n,settings:t,voices:[],cast:{design:Wc(t.voiceMode),personas:[],origins:{},previewText:``},direct:{script:Td(),takes:{}},edit:{doc:null,clipLanguages:{}},media:{}}}var th=[`design`,`cast`,`voiceOrigins`,`previewText`,`script`,`scene`,`edit.languages`,`pron.language`];function nh(e){let t=eh(e,{...ha,language:yl(`pron.language`,`en_us`)});return{...t,cast:{design:yl(`design`,t.cast.design),personas:yl(`cast`,[]),origins:yl(`voiceOrigins`,{}),previewText:yl(`previewText`,``)},direct:{script:$m(yl(`script`,t.direct.script),yl(`scene`,void 0)),takes:{}},edit:{doc:null,clipLanguages:yl(`edit.languages`,{})}}}async function rh(e,t){let n=({pcm:e,sr:n,...r})=>({...r,media:t.audio(e,n)}),r=Lf.value,i=r&&{...r,versions:r.versions.map(({pcm:e,sr:n,b64:r,...i})=>({...i,media:t.audio(e,n,()=>h(r))}))},a=q.value,o=J.value,s={schema:1,id:e.id,name:e.name,createdAt:e.createdAt,updatedAt:e.updatedAt,settings:Sa.value,voices:kc.value.map(e=>({id:e.id,label:e.label,kind:e.clip?`clip`:`embedding`,media:e.clip?t.wav(e.clip):t.embedding(e.embedding)})),cast:{design:W.value,personas:zc.value,origins:Wm.value,previewText:Ml.value},direct:{script:a,takes:Object.fromEntries(a.lines.filter(e=>o[e.id]?.length).map(e=>[e.id,o[e.id].map(e=>({...e,audio:n(e.audio)}))]))},edit:{doc:i,clipLanguages:gp.value},media:t.info};return{...s,summary:ga(s)}}async function ih(e,t){let n=new Map,r=e=>{let r=n.get(e);return r||(r=t(e).then(e=>e.arrayBuffer()).then(t=>{let n=D(t);return Bm(n.pcm,e),{...n,bytes:t}}),n.set(e,r)),r},i=async({media:e,...t})=>{let{pcm:n,sr:i}=await r(e);return{...t,pcm:n,sr:i}},a=await Promise.all(e.voices.map(async e=>{let n=await(await t(e.media)).arrayBuffer();if(e.kind===`clip`)return Bm(n,e.media),{id:e.id,label:e.label,clip:n};let r=new Float32Array(n);return Bm(r,e.media),{id:e.id,label:e.label,embedding:r}})),o=Object.fromEntries(await Promise.all(Object.entries(e.direct.takes).map(async([e,t])=>[e,await Promise.all(t.map(async e=>({...e,audio:await i(e.audio)})))]))),s=await Promise.all(Object.entries(e.scene?.renders??{}).map(async([e,t])=>[e,await i(t.audio)])),c=e.edit.doc,l=[`take`,`voice`,`upload`,`recording`],u=c&&{...c,source:l.includes(c.source.kind)?c.source:{kind:`upload`,label:c.source.label},versions:await Promise.all(c.versions.map(async({media:e,...t})=>{let{pcm:n,sr:i,bytes:a}=await r(e);return{...t,pcm:n,sr:i,b64:_(a)}}))},d=$m(e.direct.script,e.scene?.scene);return()=>Fi(()=>{Ws(),Kl(),wf(),kd.value=[],Sa.value={...ha,...e.settings},kc.value=a,U.reset(e.cast.design),zc.value=e.cast.personas,Wm.value=e.cast.origins,Ml.value=e.cast.previewText,Nl.value=!1,Ed.reset(d);let t=s.flatMap(([e,t])=>{let n=d.lines.find(t=>t.id===e);return n?[[e,[{id:It(),text:n.text,seed:0,request:rf(n,0),audio:t,createdAt:Date.now(),starred:!0,edited:!0}]]]:[]});J.value={...o,...Object.fromEntries(t)},Dd.value={},Od.value={},gp.value=e.edit.clipLanguages,fm(u)})}function ah(e){let t=new Map,n=(e,n)=>e&&t.set(e,(t.get(e)??new Set).add(n));n(e.cast.design.baseId,`the Cast bench`);for(let t of e.cast.personas)n(t.design.baseId,`cast member “${t.name}”`);return t}function oh(e,t,n,r=Date.now()){let i=Object.values(e.media);return{id:e.id,name:e.name,createdAt:e.createdAt,updatedAt:e.updatedAt,openedAt:r,size:t.length+i.reduce((e,t)=>e+t.size,0),summary:e.summary??ga(e),revision:n}}var sh=class e{db;kind=`browser`;constructor(e){this.db=e}static async open(t){let n=await si(`zvs-projects`,1,e=>{e.createObjectStore(`meta`,{keyPath:`id`}),e.createObjectStore(`docs`),e.createObjectStore(`media`,{keyPath:`hash`})});if(t){let e=await ai(n.transaction(`media`).objectStore(`media`).getAll());for(let t of e)Rm.set(t.hash,t.size)}return new e(n)}static async count(){try{if(indexedDB.databases&&!(await indexedDB.databases()).some(e=>e.name===`zvs-projects`))return 0;let t=await e.open(!1),n=(await t.list()).length;return t.db.close(),n}catch{return 0}}tx(e,t=`readonly`){return this.db.transaction(e,t)}async list(){return(await ai(this.tx([`meta`]).objectStore(`meta`).getAll())).map(e=>({...e,revision:e.revision??null,summary:e.summary??null}))}async read(e){let t=this.tx([`docs`,`meta`]),[n,r]=await Promise.all([ai(t.objectStore(`docs`).get(e)),ai(t.objectStore(`meta`).get(e))]);if(n===void 0)throw Error(`the project is missing from this browser’s storage`);return{json:n,revision:r?.revision??null}}async media(e){let t=await ai(this.tx([`media`]).objectStore(`media`).get(e));if(!t)throw Error(`An audio file of this project is missing from this browser (${e.slice(0,8)}…)`);return t.blob}async write(e,t,n,r){let i=this.tx([`media`,`docs`,`meta`],`readwrite`),a=await ai(i.objectStore(`meta`).get(e.id)),o=a?.revision??null;if(o!==r)throw i.abort(),new re(o);let s={...oh(e,t,(typeof o==`number`?o:0)+1,a?.openedAt),media:Object.keys(e.media)};for(let[e,t]of n)Rm.has(e)||i.objectStore(`media`).put({hash:e,type:t.type,size:t.size,blob:t});i.objectStore(`docs`).put(t,e.id),i.objectStore(`meta`).put(s),await oi(i);for(let[e,t]of n)Rm.set(e,t.size);let{media:c,...l}=s;return a?.media.some(t=>!(t in e.media))&&await this.sweep(),l}async remove(e){let t=this.tx([`docs`,`meta`],`readwrite`);t.objectStore(`docs`).delete(e),t.objectStore(`meta`).delete(e),await oi(t),await this.sweep()}async opened(e){let t=this.tx([`meta`],`readwrite`),n=t.objectStore(`meta`),r=await ai(n.get(e.id));r&&n.put({...r,openedAt:e.openedAt}),await oi(t)}async sweep(){let e=this.tx([`meta`,`media`],`readwrite`),[t,n]=await Promise.all([ai(e.objectStore(`meta`).getAll()),ai(e.objectStore(`media`).getAllKeys())]),r=new Set(t.flatMap(e=>e.media)),i=n.filter(e=>!r.has(e));for(let t of i)e.objectStore(`media`).delete(t);await oi(e);for(let e of i)Rm.delete(e)}},ch=e=>typeof e==`number`?e<0xe8d4a51000?e*1e3:e:e&&Date.parse(e)||Date.now(),lh=e=>!!e&&typeof e==`object`&&typeof e.takes==`number`;function uh(e){let t=ch(e.updated_at);return{id:e.id,name:e.name??e.id,createdAt:t,updatedAt:t,openedAt:t,size:(e.bytes??0)+(e.media_bytes??0),summary:lh(e.summary)?e.summary:null,revision:e.revision}}var dh=class{kind=`server`;async list(){return(await zo()).map(uh)}async read(e){let t=await Bo(e),n=JSON.stringify(t.data);for(let[e,n]of Object.entries(t.data.media??{}))Rm.set(e,n.size);return{json:n,revision:t.revision}}media(e){return Wo(e)}async write(e,t,n,r){for(let[e,t]of n)await Uo(e)||await Go(e,t),Rm.set(e,t.size);let i=()=>Vo(e.id,{name:e.name,data:e,base_revision:r}),a;try{a=await i()}catch(e){if(!(e instanceof w))throw e;for(let t of e.missing)Rm.delete(t);if(!e.missing.every(e=>n.has(e)))throw e;for(let t of e.missing)await Go(t,n.get(t));a=await i()}return{...oh(e,t,a.revision),updatedAt:ch(a.updated_at)}}remove(e){return Ho(e)}async opened(){}};async function fh(e,t){let n=new Map;for(let[r,i]of t){if(ni(r)){n.set(r,i);continue}let t=await ri(new Uint8Array(await i.arrayBuffer()));e=e.split(`"${r}"`).join(`"${t}"`),n.set(t,i)}return{json:e,media:n}}async function ph(e,t){return ni(e)?await ri(t)===e:ii(t)===e}var mh=F([]),Z=F(null),Q=F(`saved`),hh=F(null),gh=F(!1),_h=F(null),vh=F(0),yh=F(!1),bh=F(null),xh=F({reRegistered:[],issues:[]}),Sh=F(null),Ch=F(!1),wh=F(!1),Th=`zvs.project`,Eh=800,Dh=`Untitled project`,Oh=`This project was changed elsewhere (another tab or browser) since you opened it. Reload it, or keep your version as a copy.`,kh=`This project was deleted elsewhere (another tab or browser). Keep your version as a copy to go on with it.`,$=null,Ah=new Map,jh=``,Mh=0,Nh=Promise.resolve();function Ph(e){let t=Nh.then(e);return Nh=t.catch(()=>void 0),t}function Fh(e){return e<1e6?`${Math.round(e/1e3)} kB`:e<1e9?`${(e/1e6).toFixed(+(e<1e7))} MB`:`${(e/1e9).toFixed(1)} GB`}var Ih=()=>$?.kind===`server`?`on the server`:`in this browser`;function Lh(e){mh.value=[...e].sort((e,t)=>t.openedAt-e.openedAt)}var Rh=e=>Lh([...mh.value.filter(t=>t.id!==e.id),e]);async function zh(){if($)try{let e=await $.list(),t=Z.value;Lh(t?[...e.filter(e=>e.id!==t.id),t]:e)}catch(e){z(`Couldn’t list the projects: ${V(e)}`,`error`)}}async function Bh(e,t=JSON.stringify(e),n=new Map){return e.summary||(e.summary=ga(e),t=JSON.stringify(e)),Rh(await Ph(()=>$.write(e,t,n,null))),e.id}async function Vh(){if($?.kind!==`browser`)return void(Sh.value=null);try{let e=await navigator.storage?.estimate();e&&(Sh.value={usage:e.usage??0,quota:e.quota??0})}catch{}}function Hh(e){if(e instanceof re){clearTimeout(Mh),gh.value=e.revision===null,Q.value=`conflict`,hh.value=gh.value?kh:Oh;return}let t=Sh.value,n=e instanceof DOMException&&e.name===`QuotaExceededError`?`Browser storage is full${t?` (${Fh(t.usage)} of ${Fh(t.quota)})`:``}: delete or export projects you don’t need. Your work stays open in this tab.`:`Couldn’t save the project ${Ih()} (${V(e)}). Your work stays open in this tab.`;hh.value!==n&&z(n,`error`),Q.value=`error`,hh.value=n}async function Uh(e=!1){let t=Z.value;if(t&&$&&Q.value!==`conflict`)try{let e=new Vm,n=await Wh(t,e),r=JSON.stringify({...n,updatedAt:0});if(r===jh){Q.value===`saving`&&(Q.value=`saved`);return}Q.value=`saving`,n.updatedAt=Date.now();let i=JSON.stringify(n),a={...await $.write(n,i,e.pending,t.revision),openedAt:t.openedAt};jh=r,Z.value=Z.value===t?a:Z.value&&{...Z.value,revision:a.revision},Rh(Z.value??a),Q.value=`saved`,hh.value=null,Xh(n),Vh()}catch(t){if(t instanceof w&&!e)return Uh(!0);Hh(t)}}async function Wh(e,t){let n=await rh(e,t);return Ah.size?JSON.parse(_a(JSON.stringify(n),Ah)):n}function Gh(){return clearTimeout(Mh),Mh=0,Ph(()=>Uh())}function Kh(){Z.value&&$&&Q.value!==`conflict`&&(clearTimeout(Mh),Mh=window.setTimeout(()=>void Gh(),Eh))}na(()=>{W.value,zc.value,Wm.value,Ml.value,q.value,J.value,Lf.value,gp.value,Sa.value,kc.value,Ri(Kh)});var qh=0;fc(()=>{Date.now()-qh<1e4||(qh=Date.now(),z(`The server restarted and forgot this voice`,`error`,{label:`Reopen project`,run:()=>void(Q.value===`conflict`?fg():Gh().then(fg))}))}),addEventListener(`visibilitychange`,()=>document.visibilityState===`hidden`&&Mh&&void Gh()),addEventListener(`pagehide`,()=>Mh&&void Gh()),addEventListener(`beforeunload`,e=>{let t=Q.value;(Mh||t===`saving`||t===`error`||t===`conflict`||t===`off`&&Z.value||rg())&&e.preventDefault()});async function Jh(e){let t=new Set(H.value.map(e=>e.id)),n=new Map,r=[],i=[];for(let a of e.voices)if(!t.has(a.id))try{let e=await $.media(a.media),t=a.kind===`clip`?await To(a.label,e,`${p(a.label)}.wav`):await Eo(a.label,new Float32Array(await e.arrayBuffer()));n.set(a.id,t.id),r.push(a.label)}catch(e){i.push(`“${a.label}”: ${V(e)}`)}let a=new Set(e.voices.map(e=>e.id));for(let[n,r]of ah(e))!t.has(n)&&!a.has(n)&&i.push(`the voice used by ${[...r].join(`, `)}: it is gone from the server, and the project holds no clip or embedding to recreate it`);return n.size?(await bc(),{doc:JSON.parse(_a(JSON.stringify(e),n)),map:n,reRegistered:r,issues:i}):{doc:e,map:n,reRegistered:r,issues:i}}var Yh=new Set;async function Xh(e){let t=Z.value?.id,n=new Set(kc.value.map(e=>e.id));for(let r of ah(e).keys()){let e=H.value.find(e=>e.id===r);if(!(!e||e.is_default||n.has(r)||Yh.has(r))){Yh.add(r);try{let n;if(Wa(e)){let{embedding:t,synthetic:i}=await So(e);if(i)continue;n={id:r,label:e.label,embedding:t}}else n={id:r,label:e.label,clip:await wo(e)};Z.value?.id===t&&(kc.value=[...kc.value,n])}catch{}}}}function Zh(){let e=H.value,t=W.value.baseId;if(e.some(e=>e.id===t))return;let n=e.find(e=>e.is_default)??e[0];n&&(U.reset({...W.value,baseId:n.id,mode:Wa(n)?`embedding`:Sa.value.voiceMode}),t&&z(`Bench switched to ${n.label} because its voice is gone from the server`))}function Qh(){let e=new Set(mh.value.map(e=>e.name));if(!e.has(Dh))return Dh;for(let t=2;;t++)if(!e.has(`${Dh} ${t}`))return`${Dh} ${t}`}async function $h(e,t){let{json:n,revision:r}=await $.read(e),i=JSON.parse(n);if(i.schema>1)throw Error(`it was saved by a newer version of the studio`);await bc();let{doc:a,map:o,reRegistered:s,issues:c}=pc.value?{doc:i,map:new Map,reRegistered:[],issues:[`Couldn’t list voices: ${pc.value}`]}:await Jh(i),l=await ih(a,e=>$.media(e)),u=oh(a,n,r);clearTimeout(Mh),Fi(()=>{t&&(L.value=t),l(),Z.value=u}),Ah=new Map([...o].map(([e,t])=>[t,e])),jh=JSON.stringify({...i,updatedAt:0}),Q.value=`saved`,hh.value=null,xh.value={reRegistered:s,issues:c},localStorage.setItem(Th,e),Zh(),Rh(u),await Ph(()=>$.opened(u)),c.length&&z(`${c.length===1?`A voice`:`${c.length} voices`} of “${i.name}” couldn’t be restored: see Projects for details.`,`error`),Xh(a),Vh()}async function eg(e,t){$=null,Q.value=`off`,hh.value=`Projects can’t be stored ${e.projects?`on the server`:`in this browser`} (${V(t)}): work in this tab is not saved.`,z(hh.value,`error`);let n=nh({id:It(),name:Dh}),r=await ih(n,()=>Promise.reject(Error(`no storage`)));Fi(()=>{L.value=e,r(),Z.value=oh(n,``,null)}),Zh()}async function tg(e){try{$=e.projects?new dh:await sh.open(!0),_h.value=$.kind,Lh(await $.list())}catch(t){return eg(e,t)}$.kind===`server`&&(vh.value=await sh.count(),vh.value&&z(`${vh.value===1?`A project is`:`${vh.value} projects are`} still saved in this browser only: move ${vh.value===1?`it`:`them`} to the server from Projects.`));let t=localStorage.getItem(Th);try{let n=new URLSearchParams(location.search).get(`project`),r=(mh.value.find(e=>e.id===n)??mh.value.find(e=>e.id===t)??mh.value[0])?.id;if(!r){r=await Bh(nh({id:It(),name:Dh}));for(let e of th)localStorage.removeItem(`zvs.${e}`)}await $h(r,e)}catch(t){z(`Couldn’t open the last project (${V(t)}); started a new one.`,`error`);try{await $h(await Bh(eh({id:It(),name:Dh},Sa.value)),e)}catch(t){await eg(e,t)}}finally{L.value||=e}}function ng(){return X.value?`the Edit screen`:Dc.value?`the voice upload`:null}function rg(){return Cp.value||Uf.value.size>0?`unsaved text, regions or takes in Edit`:jd.value?`script text changes in Direct`:null}async function ig(){if(!$)return z(hh.value??`Projects are unavailable.`,`error`),!1;let e=ng();if(e)return z(`Wait for ${e} to finish (or cancel it) before switching projects.`,`error`),!1;let t=rg();return t&&!await Nf(`Switching projects discards your ${t}. Continue?`,{ok:`Discard`,danger:!0})?!1:(Ad.value=null,await Gh(),Q.value===`conflict`?(z(`This project changed elsewhere: reload it or keep yours as a copy before switching.`,`error`),!1):Q.value!==`error`||(z(`The open project couldn’t be saved, so it stays open: ${$.kind===`server`?`check the connection to the server`:`free some space (delete or export projects)`} and try again.`,`error`),!1))}async function ag(e){if(!wh.value){wh.value=!0;try{if(!await ig())return;await $h(await e()),Ch.value=!1}catch(e){z(`Couldn’t open the project: ${V(e)}`,`error`)}finally{wh.value=!1}}}async function og(e){if(e!==Z.value?.id)return ag(async()=>e);Ch.value=!1}function sg(e=Qh()){return ag(()=>Bh(eh({id:It(),name:e},Sa.value)))}async function cg(e,t){let{json:n,revision:r}=await $.read(e),i=t(JSON.parse(n));return $.write(i,JSON.stringify(i),new Map,r)}async function lg(e,t){t=t.trim();let n=mh.value.find(t=>t.id===e);if(t&&n&&t!==n.name&&$){if(e===Z.value?.id)return Z.value={...Z.value,name:t},Rh(Z.value),Kh();try{Rh({...await Ph(()=>cg(e,e=>({...e,name:t}))),openedAt:n.openedAt})}catch(e){z(`Couldn’t rename the project: ${V(e)}`,`error`)}}}async function ug(e){if($)try{e===Z.value?.id&&await Gh();let t=JSON.parse((await $.read(e)).json),n=Date.now(),r={...t,id:It(),name:`${t.name} (copy)`,createdAt:n,updatedAt:n};await Bh(r),z(`Duplicated as “${r.name}”`,`ok`)}catch(e){z(`Couldn’t duplicate the project: ${V(e)}`,`error`)}}async function dg(e){if(!$)return;let t=e===Z.value?.id;if(t&&ng())return z(`Wait for ${ng()} to finish before deleting the open project.`,`error`);let n=mh.value.find(t=>t.id===e)?.name??`the project`;t&&(clearTimeout(Mh),Z.value=null);try{if(await Ph(()=>$.remove(e)),Lh(mh.value.filter(t=>t.id!==e)),z(`Deleted “${n}”`),t){let e=mh.value[0];await $h(e?e.id:await Bh(eh({id:It(),name:Dh},Sa.value)))}}catch(e){z(`Couldn’t delete the project: ${V(e)}`,`error`)}Vh()}async function fg(){let e=Z.value;if(e&&$&&!wh.value){wh.value=!0;try{await $h(e.id),z(`Reloaded “${e.name}”`,`ok`)}catch(e){z(`Couldn’t reload the project: ${V(e)}`,`error`)}finally{wh.value=!1}}}async function pg(){let e=Z.value;if(e&&$)try{let t=Date.now(),n={...e,id:It(),name:`${e.name} (copy)`,createdAt:t,updatedAt:t,revision:null},r=new Vm,i=await Wh(n,r),a=JSON.stringify(i),o=await Ph(()=>$.write(i,a,r.pending,null));Z.value=o,Rh(o),jh=JSON.stringify({...i,updatedAt:0}),Q.value=`saved`,hh.value=null,localStorage.setItem(Th,o.id),z(`Your version is now “${o.name}”`,`ok`),zh()}catch(e){z(`Couldn’t save your version as a copy: ${V(e)}`,`error`)}}var mg={"audio/wav":`wav`,[Lm]:`f32`},hg=(e,t)=>`media/${e}.${mg[t]??(t.split(`/`)[1]?.replace(/[^a-z0-9]/g,``)||`bin`)}`;async function gg(e){if($)try{e===Z.value?.id&&await Gh();let{json:t}=await $.read(e),n=JSON.parse(t),r={"project.json":[ud(t),{level:6}]};for(let[e,t]of Object.entries(n.media))r[hg(e,t.type)]=[new Uint8Array(await(await $.media(e)).arrayBuffer()),{level:0}];let i=vd(r,{mtime:n.updatedAt});ae(i.buffer,`${p(n.name)}.voice-studio.zip`,`application/zip`),z(`Exported “${n.name}”`,`ok`)}catch(e){z(`Couldn’t export the project: ${V(e)}`,`error`)}}async function _g(e){if(!$)return z(hh.value??`Projects are unavailable.`,`error`);let t=L.value?.projects,n=t?t.max_project_bytes+t.max_media_bytes:0;if(n&&e.size>n)return z(`Too big: ${Fh(e.size)}, limit ${Fh(n)}`,`error`);let r=z(`Importing ${e.name}…`);try{let t;try{t=yd(new Uint8Array(await e.arrayBuffer()))}catch{throw Error(`Not a Voice Studio project file (not a zip)`)}if(!t[`project.json`])throw Error(`Not a Voice Studio project file`);let n;try{n=JSON.parse(dd(t[`project.json`]))}catch{throw Error(`Not a Voice Studio project file`)}if(typeof n.schema!=`number`||typeof n.id!=`string`||!n.media)throw Error(`Not a Voice Studio project file`);if(n.schema>1)throw Error(`It was saved by a newer version of the studio`);let i=new Map;for(let[e,r]of Object.entries(t)){let t=/^media\/([0-9a-f]{32}|[0-9a-f]{64})\./.exec(e)?.[1];if(t){if(!await ph(t,r))throw Error(`An audio file inside is damaged (${e})`);i.set(t,new Blob([r],{type:n.media[t]?.type??``}))}}let a=Object.keys(n.media).filter(e=>!i.has(e)).length;if(a)throw Error(`${a} audio file${a===1?` is`:`s are`} missing from the file`);let o=await fh(dd(t[`project.json`]),i),s=o.json,c=JSON.parse(s);mh.value.some(e=>e.id===c.id)&&(c.id=It(),c.name=`${c.name} (imported)`,s=JSON.stringify(c)),await Bh(c,s,o.media),Ha(r),z(`Imported “${c.name}”`,`ok`),await og(c.id)}catch(t){Ha(r),z(`Couldn’t import ${e.name}: ${V(t)}`,`error`)}}async function vg(){if($?.kind!==`server`||yh.value)return;yh.value=!0;let e=0;try{let t=await sh.open(!1),n=await t.list();bh.value={done:0,total:n.length};for(let r of n){let{json:i}=await t.read(r.id),a=JSON.parse(i),o=new Map;for(let e of Object.keys(a.media))o.set(e,await t.media(e));let s=await fh(i,o),c=s.json,l=JSON.parse(c);mh.value.some(e=>e.id===l.id)&&(l.id=It(),l.name=`${l.name} (moved)`,c=JSON.stringify(l)),await Bh(l,c,s.media),await t.remove(r.id),e++,vh.value--,bh.value={done:e,total:n.length}}z(`Moved ${e} project${e===1?``:`s`} to the server`,`ok`)}catch(t){z(`Moved ${e}; couldn’t move the rest: ${V(t)}`,`error`)}finally{yh.value=!1,bh.value=null,zh()}}function yg(e){Sa.value={...Sa.value,...e},e.voiceMode&&e.voiceMode!==W.value.mode&&!Wa(Xc.value)&&ol(e.voiceMode)}function bg(){return jh=``,Gh()}var xg=`cubic-bezier(0.2, 0.7, 0.2, 1)`,Sg=()=>matchMedia(`(prefers-reduced-motion: reduce)`).matches;function Cg(e,t){return`translate(${e.left-t.left}px, ${e.top-t.top}px) scale(${e.width/t.width}, ${e.height/t.height})`}function wg({family:e,title:t,origin:n,returnFocus:r,onClose:i,aside:a,strip:o,children:s}){let c=N(null),l=N(null),u=N(!1),d=N(!1),f=`card-modal-${e}`;mt(()=>{let e=c.current;return Ma.value=!0,Sg()||(e.animate([{transform:Cg(n.getBoundingClientRect(),e.getBoundingClientRect())},{transform:`none`}],{duration:300,easing:xg}),e.querySelector(`.card-modal-inner`)?.animate([{opacity:0},{opacity:1}],{duration:180,delay:120,easing:`ease-out`,fill:`backwards`}),l.current.animate([{opacity:0},{opacity:1}],{duration:220,easing:`ease-out`})),Af(e,`.card-modal-body`),()=>{Ma.value=!1}},[]);let p=()=>{if(u.current)return;u.current=!0;let e=()=>{i(),r.focus({preventScroll:!0})},t=c.current;if(!t||Sg())return e();t.querySelector(`.card-modal-inner`)?.animate([{opacity:1},{opacity:0}],{duration:120,fill:`forwards`}),l.current.animate([{opacity:1},{opacity:0}],{duration:240,fill:`forwards`}),t.animate([{transform:`none`},{transform:Cg(n.getBoundingClientRect(),t.getBoundingClientRect())}],{duration:240,easing:xg,fill:`forwards`}).finished.then(e,e)},m=jf(()=>c.current,p);return G(`div`,{ref:l,class:`card-modal-backdrop`,onPointerDown:e=>d.current=e.target===l.current,onClick:e=>{d.current&&e.target===l.current&&p(),d.current=!1},children:G(`div`,{ref:c,class:`card-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,style:{"--fam":Da(e)},onKeyDown:m,children:G(`div`,{class:`card-modal-inner`,children:[G(`header`,{class:`card-modal-head`,children:[G(`h2`,{id:f,children:[G(`span`,{class:`fam-dot`}),t]}),a&&G(`div`,{class:`card-modal-aside`,children:a}),G(`button`,{class:`icon-btn`,onClick:p,"aria-label":`Close ${t}`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),o&&G(`div`,{class:`card-modal-strip`,children:o}),G(`div`,{class:`card-modal-body`,children:s})]})})})}var Tg=`button, input, select, textarea, a, summary, label, [role="slider"], .slider-track, .panel-lock`;function Eg({family:e,title:t,aside:n,locked:r,class:i,onExpand:a,whole:o,children:s}){let c=N(null),l=N(null),u=N(null),d=!!a&&!!o,f=a&&{tabIndex:0,role:`button`,"aria-haspopup":`dialog`,"aria-label":`${t}: open larger`,title:`Open larger`},p=e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),a(c.current,e.currentTarget))};return G(`section`,{ref:c,class:`panel${r?` is-locked`:``}${a?` is-expandable`:``}${d?` is-whole`:``}${i?` ${i}`:``}`,style:e?{"--fam":Da(e)}:void 0,"aria-label":d?void 0:t,...d?f:{},onKeyDown:d?p:void 0,onPointerDown:a?e=>{let t=e.target;u.current=e.button===0&&(d||t.closest(`.panel-head`)||!t.closest(Tg))?{x:e.clientX,y:e.clientY}:null}:void 0,onClick:a?e=>{let t=u.current;u.current=null,t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<6&&a(c.current,d?c.current:l.current)}:void 0,children:[G(`div`,{ref:l,class:`panel-head`,...a&&!d?f:{},onKeyDown:a&&!d?p:void 0,children:[G(`h3`,{children:[e&&G(`span`,{class:`fam-dot`}),t]}),n&&G(`div`,{class:`panel-aside`,children:n}),a&&G(`span`,{class:`panel-expand`,"aria-hidden":`true`,children:G(K,{name:`expand`,size:14})})]}),G(`div`,{class:`panel-body`,inert:r||d?!0:void 0,children:s}),r&&G(`div`,{class:`panel-lock`,children:r})]})}var Dg=matchMedia(`(max-width: 760px)`),Og=F(Dg.matches);Dg.addEventListener(`change`,e=>Og.value=e.matches);var kg=F(yl(`rails`,{}));bl(`rails`,kg);var Ag=F(null),jg=null;function Mg(){Ag.value=null,jg?.focus({preventScroll:!0}),jg=null}function Ng(e){Og.peek()?(jg=document.activeElement,Ag.value=e):kg.peek()[e]!==!1&&(kg.value={...kg.peek(),[e]:!1})}function Pg({id:e,side:t,title:n,children:r,defaultFolded:i=!1}){let a=N(null),o=kg.value[e]??i,s=Og.value,c=s&&Ag.value===e;M(()=>()=>{Ag.peek()===e&&(Ag.value=null)},[]),M(()=>{if(!c)return;a.current?.querySelector(`.rail-drawer-head button`)?.focus({preventScroll:!0});let e=e=>{e.key!==`Escape`||e.defaultPrevented||Ma.peek()||(e.preventDefault(),Mg())};window.addEventListener(`keydown`,e);let t=a.current?.parentElement,n=t?[...t.children].filter(e=>e!==a.current&&!e.classList.contains(`rail-scrim`)):[];for(let e of n)e.setAttribute(`inert`,``);return()=>{window.removeEventListener(`keydown`,e);for(let e of n)e.removeAttribute(`inert`)}},[c]);let l=c?jf(()=>a.current,Mg):void 0,u=t===`left`?o?`right`:`left`:o?`left`:`right`;return G(A,{children:[G(`div`,{ref:a,id:`rail-${e}`,class:`rail-box is-${t}${o?` is-folded`:``}${c?` is-open`:``}`,role:c?`dialog`:void 0,"aria-label":c?n:void 0,"aria-modal":c?`true`:void 0,inert:s&&!c?!0:void 0,onKeyDown:l,children:[G(`div`,{class:`rail-drawer-head`,children:[G(`h3`,{children:n}),G(`button`,{class:`icon-btn`,onClick:Mg,"aria-label":`Close ${n}`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`button`,{class:`rail-fold`,onClick:()=>kg.value={...kg.value,[e]:!o},"aria-expanded":!o,"aria-label":o?`Show ${n}`:`Hide ${n}`,title:o?`Show ${n}`:`Hide ${n}`,children:[G(K,{name:u,size:14}),o&&G(`span`,{class:`rail-fold-label`,children:n})]}),r]}),c&&G(`div`,{class:`rail-scrim`,onClick:Mg})]})}function Fg({id:e,title:t,icon:n}){let r=Ag.value===e;return G(`button`,{class:`btn sm rail-toggle${r?` is-on`:``}`,"aria-expanded":r,"aria-controls":`rail-${e}`,onClick:t=>{jg=t.currentTarget,Ag.value=r?null:e},children:[G(K,{name:n,size:14}),` `,t]})}function Ig({children:e}){return Og.value?G(`div`,{class:`rail-bar`,children:e}):null}function Lg(e,t,n,r=e.currentTarget){if(e.button!==0)return;e.preventDefault();let i=e.currentTarget;i.setPointerCapture?.(e.pointerId);let a=e=>{let n=r.getBoundingClientRect();t((e.clientX-n.left)/(n.width||1),(e.clientY-n.top)/(n.height||1),e)},o=e=>a(e),s=()=>{i.removeEventListener(`pointermove`,o),i.removeEventListener(`pointerup`,s),i.removeEventListener(`pointercancel`,s),n?.()};i.addEventListener(`pointermove`,o),i.addEventListener(`pointerup`,s),i.addEventListener(`pointercancel`,s),a(e)}var Rg={english:`English accents`,world:`Other languages`};function zg({large:e}){let t=R.value.ui.accents,n=ws(t),r=W.value.pin,[i,a]=j(n.includes(r.tab)?r.tab:n[0]);M(()=>{n.includes(r.tab)&&a(r.tab)},[r.tab]);let o=N(null),s=N(0);M(()=>()=>clearTimeout(s.current),[]);let c=Da(`accent`),l=Ts(i,t),u=qc.value,d=t.filter(e=>e.tab===i),f=r.tab===i,[p,m]=l.home,h=Object.entries(u).map(([e,n])=>({a:t.find(t=>t.id===e),v:n})).filter(e=>e.a).sort((e,t)=>t.v-e.v),g=h[0],_=(e,t)=>tl({tab:i,x:P(e*$o,6,$o-6),y:P(t*960,6,954)}),v=e=>{let n=e.shiftKey?40:10,a=f?r:Es(i,t),o=e.key===`ArrowRight`?n:e.key===`ArrowLeft`?-n:0,c=e.key===`ArrowDown`?n:e.key===`ArrowUp`?-n:0;e.key===`Home`||e.key===`0`||e.key===`Delete`||e.key===`Backspace`?(e.preventDefault(),U.apply({...W.value,pin:Es(i,t)})):(o||c)&&(e.preventDefault(),s.current||U.begin(),clearTimeout(s.current),tl({tab:i,x:P(a.x+o,6,$o-6),y:P(a.y+c,6,954)}),s.current=window.setTimeout(()=>{s.current=0,U.end()},400))},y=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=n.indexOf(i),r=n[(t+(e.key===`ArrowRight`?1:n.length-1))%n.length];a(r),e.currentTarget.querySelector(`#atlas-tab-${r}`)?.focus()},b=g?`${g.a.label} ${g.v.toFixed(2)}${Wt(g.a,g.v)===`safe`?``:` · strong`}`:``,x=r.x>$o-300;return G(`div`,{class:`atlas${e?` is-large`:``}`,style:{"--fam":c},children:[G(`div`,{class:`atlas-tabs`,role:`tablist`,"aria-label":`Accent maps`,onKeyDown:y,children:[n.map(e=>G(`button`,{id:`atlas-tab-${e}`,role:`tab`,"aria-selected":e===i,"aria-controls":`atlas-panel-${e}`,tabIndex:e===i?0:-1,class:`tab${e===i?` is-on`:``}`,onClick:()=>a(e),children:[Rg[e]??e,r.tab===e&&h.length>0&&G(`span`,{class:`fam-dot`})]})),G(`div`,{class:`atlas-readout`,title:h.map(({a:e,v:t})=>`${e.label} ${t.toFixed(2)}`).join(` + `),children:!f&&h.length>0?G(`span`,{class:`muted`,children:[`Dragging here replaces `,Rg[r.tab]??r.tab]}):h.length?G(`span`,{class:`muted`,children:h.map(({a:e,v:t})=>`${e.label} ${t.toFixed(2)}`).join(` + `)}):G(`span`,{class:`muted`,children:`no accent`})}),G(`button`,{class:`link home-btn`,onClick:()=>U.apply({...W.value,pin:Es(i,t)}),title:`Back home: no accent`,children:[G(K,{name:`home`,size:14}),` home`]})]}),G(`svg`,{ref:o,id:`atlas-panel-${i}`,class:`atlas-map`,viewBox:`0 0 ${$o} 960`,role:`slider`,tabIndex:0,"aria-label":`${Rg[i]??i} map. Drag the pin into a region; deeper is stronger, borders blend. Arrow keys move it, Home returns.`,"aria-valuetext":h.length?h.map(e=>`${e.a.label} ${e.v.toFixed(2)}`).join(`, `):`no accent`,onKeyDown:v,onPointerDown:e=>{U.begin(),Lg(e,_,()=>U.end(),o.current)},children:[G(`defs`,{children:l.panels.map(e=>G(`clipPath`,{id:`clip-${i}-${e.id}`,children:G(`rect`,{x:e.rect[0],y:e.rect[1],width:e.rect[2],height:e.rect[3],rx:`14`})}))}),l.panels.map(e=>G(`g`,{class:`atlas-panel`,children:[G(`rect`,{class:`panel-sea`,x:e.rect[0],y:e.rect[1],width:e.rect[2],height:e.rect[3],rx:`14`}),G(`path`,{class:`land`,d:l.context.find(t=>t.panel===e.id)?.path,"clip-path":`url(#clip-${i}-${e.id})`}),G(`text`,{class:`panel-label`,x:e.rect[0]+12,y:e.rect[1]+e.rect[3]-12,children:e.label})]})),d.map(e=>{let t=l.regions[e.region];if(!t)return null;let n=f?u[e.id]??0:0;return G(`g`,{class:`region strength-${e.strength}${n>0?` is-active`:``}`,style:{"--w":String(n/e.range[1])},children:[G(`title`,{children:`${e.label} — ${e.strength}${e.effect?`: ${e.effect}`:``}`}),G(`path`,{class:`region-shape`,d:t.path})]})}),d.map(e=>{let n=l.regions[e.region];if(!n)return null;let r=d.filter(t=>t.region===e.region).length>1?t.filter(t=>t.region===e.region&&t.tab===i).map(e=>e.label).join(` / `):e.label,a=r.length*7.6;return G(`text`,{class:`region-label strength-${e.strength}`,x:P(n.pole[0],a+4,$o-a-4),y:n.pole[1]+9,children:r})}),G(`g`,{class:`home`,transform:`translate(${p},${m})`,children:[G(`circle`,{r:`26`}),G(`text`,{y:`56`,children:`home · no accent`})]}),f&&G(`g`,{class:`pin`,transform:`translate(${r.x},${r.y})`,children:[G(`path`,{d:`M0,0 C-15,-21 -21,-33 -21,-45 A21,21 0 1 1 21,-45 C21,-33 15,-21 0,0Z`}),G(`circle`,{cy:`-45`,r:`7`}),g&&G(`g`,{class:`pin-tag zone-${Wt(g.a,g.v)}`,transform:`translate(${x?-30:30},-45)`,children:[G(`rect`,{x:x?-b.length*16-24:0,y:`-25`,width:b.length*16+24,height:`50`,rx:`25`}),G(`text`,{x:x?-12:12,y:`10`,"text-anchor":x?`end`:`start`,children:b})]})]})]})]})}var Bg=e=>!!e.dataTransfer?.types.includes(`Files`);function Vg({label:e,hint:t,icon:n=`upload`,busy:r,onFile:i}){let[a,o]=j(!1),s=N(0),c=N({busy:r,onFile:i});return c.current={busy:r,onFile:i},M(()=>{let e=e=>{Bg(e)&&(s.current++,o(!0))},t=e=>{Bg(e)&&(s.current=Math.max(0,s.current-1),s.current||o(!1))},n=e=>{Bg(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=c.current.busy?`none`:`copy`)},r=e=>{if(!Bg(e))return;e.preventDefault(),s.current=0,o(!1);let t=e.dataTransfer.files[0];t&&!c.current.busy&&c.current.onFile(t)};return window.addEventListener(`dragenter`,e),window.addEventListener(`dragleave`,t),window.addEventListener(`dragover`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragenter`,e),window.removeEventListener(`dragleave`,t),window.removeEventListener(`dragover`,n),window.removeEventListener(`drop`,r)}},[]),a?Xe(G(`div`,{class:`file-drop${r?` is-busy`:``}`,"aria-hidden":`true`,children:G(`div`,{class:`file-drop-card`,children:[G(K,{name:n,size:30}),G(`b`,{children:r??e}),t&&!r&&G(`span`,{class:`muted small`,children:t})]})}),document.body):null}var Hg={saved:`All changes saved`,saving:`Saving…`,error:`Not saved`,conflict:`Changed elsewhere`,off:`Not saved — storage unavailable`},Ug={saved:``,saving:`Saving…`,error:`Not saved`,conflict:`Changed elsewhere`,off:`Not saved — storage unavailable`};function Wg(e){let t=(Date.now()-e)/1e3;return t<60?`just now`:t<3600?`${Math.round(t/60)} min ago`:t<86400?`${Math.round(t/3600)} h ago`:t<604800?`${Math.round(t/86400)} d ago`:new Date(e).toLocaleDateString()}function Gg(e){if(!e)return`project`;let t=(e,t,n=`${t}s`)=>e?[`${e} ${e===1?t:n}`]:[];return[...t(e.cast,`cast member`),...t(e.takes,`take`),...t(e.versions,`edit version`)].join(` · `)||`empty`}function Kg(){let e=document.createElement(`input`);e.type=`file`,e.accept=`.zip,application/zip`,e.onchange=()=>e.files?.[0]&&void _g(e.files[0]),e.click()}function qg(){let e=Q.value;return Z.value?G(`span`,{class:`proj-dot is-${e}`,role:`img`,"aria-label":Hg[e],title:hh.value??Hg[e],children:e===`conflict`?`!`:``}):null}function Jg(){let e=Q.value;return G(A,{children:[Ug[e]&&G(`span`,{class:`proj-state is-${e}`,children:Ug[e]}),G(`span`,{class:`sr-only`,"aria-live":`polite`,children:Hg[e]})]})}function Yg({value:e,label:t,onDone:n}){let r=N(null),i=N(!1);mt(()=>{r.current.focus(),r.current.select()},[]);let a=e=>{i.current||(i.current=!0,n(e))};return G(`input`,{ref:r,class:`input proj-name-input`,value:e,"aria-label":t,maxLength:80,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?a(e.currentTarget.value):e.key===`Escape`&&a(null)},onBlur:e=>a(e.currentTarget.value)})}function Xg(){let[e,t]=j(!1),n=N(null),r=N(null),i=N(null),[a,o]=j(null),s=!!a,c=e=>{let t=r.current?.getBoundingClientRect();o(e&&t?{top:`${t.bottom+6}px`,left:`${t.left}px`}:null)},l=Z.value,u=(e=!0)=>{c(!1),e&&r.current?.focus()};M(()=>{if(!s)return;i.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>!n.current?.contains(e.target)&&!i.current?.contains(e.target)&&c(!1);return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s]);let d=e=>()=>{u(!1),e()},f=e=>{e.stopPropagation();let t=[...i.current.querySelectorAll(`[role="menuitem"]:not([disabled])`)],n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)u();else if(e.key===`Tab`)return u(!1);else return;e.preventDefault()},p=mh.value.filter(e=>e.id!==l?.id).slice(0,5),m=Q.value===`off`;return G(`div`,{ref:n,class:`proj-switch`,children:[e&&l?G(Yg,{value:l.name,label:`Project name`,onDone:e=>{t(!1),e&&lg(l.id,e),r.current?.focus()}}):G(`button`,{ref:r,class:`proj-trigger`,"aria-haspopup":`menu`,"aria-expanded":s,disabled:!l,onClick:()=>c(!s),"aria-label":`Project: ${l?.name??`opening`}`,title:`${l?.name??`Project`} · ${hh.value??Hg[Q.value]}`,children:[G(qg,{}),G(`span`,{class:`proj-trigger-name`,children:l?.name??`Opening…`}),G(Jg,{}),G(K,{name:`down`,size:12})]}),Q.value===`conflict`&&G(Zg,{}),a&&l&&Xe(G(`div`,{ref:i,class:`proj-menu`,role:`menu`,"aria-label":`Project`,style:a,onKeyDown:f,children:[G(`p`,{class:`proj-menu-status${Q.value===`error`||Q.value===`conflict`||m?` is-bad`:``}`,children:hh.value??Hg[Q.value]}),Q.value===`error`&&G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void bg()),children:[G(K,{name:`refresh`,size:14}),` Try saving again`]}),Q.value===`conflict`&&G(A,{children:[!gh.value&&G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void fg()),children:[G(K,{name:`refresh`,size:14}),` Reload (drop my changes)`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void pg()),children:[G(K,{name:`copy`,size:14}),` Keep mine as a copy`]})]}),p.length>0&&G(`div`,{role:`group`,"aria-label":`Recent projects`,class:`proj-menu-group`,children:[G(`span`,{class:`proj-menu-label`,children:`Recent`}),p.map(e=>G(`button`,{role:`menuitem`,class:`proj-item`,disabled:wh.value,onClick:d(()=>void og(e.id)),children:[G(`span`,{class:`proj-item-name`,children:e.name}),G(`span`,{class:`proj-item-meta`,children:[`edited `,Wg(e.updatedAt)]})]},e.id))]}),G(`div`,{role:`separator`,class:`proj-sep`}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m||wh.value,onClick:d(()=>void sg().then(()=>t(!0))),children:[G(K,{name:`plus`,size:14}),` New project`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>t(!0)),disabled:m,children:[G(K,{name:`edit`,size:14}),` Rename…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>Na.value=!0),children:[G(K,{name:`gear`,size:14}),` Project settings…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(()=>void ug(l.id)),children:[G(K,{name:`copy`,size:14}),` Duplicate`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(()=>void gg(l.id)),children:[G(K,{name:`download`,size:14}),` Export…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(Kg),children:[G(K,{name:`upload`,size:14}),` Import…`]}),G(`div`,{role:`separator`,class:`proj-sep`}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>Ch.value=!0),children:`All projects…`})]}),document.body)]})}function Zg(){return Xe(G(`div`,{class:`proj-conflict`,role:`alert`,children:[G(K,{name:`alert`,size:16}),G(`span`,{children:hh.value}),!gh.value&&G(`button`,{class:`btn sm`,disabled:wh.value,onClick:()=>void fg(),children:`Reload`}),G(`button`,{class:`btn sm primary`,onClick:()=>void pg(),children:`Keep mine as a copy`})]}),document.body)}function Qg(){return Ch.value?G($g,{}):null}function $g(){let[e,t]=j(``),[n,r]=j(null),[i,a]=j(null),o=N(null),s=N(!1);mt(()=>{let e=document.activeElement;return Ma.value=!0,zh(),o.current.querySelector(`.proj-search`)?.focus(),()=>{Ma.value=!1,(e?.isConnected?e:document.querySelector(`.proj-trigger`))?.focus()}},[]);let c=()=>Ch.value=!1,l=e.trim().toLowerCase(),u=l?mh.value.filter(e=>e.name.toLowerCase().includes(l)):mh.value,d=mh.value.reduce((e,t)=>e+t.size,0),f=Sh.value;return G(`div`,{class:`proj-backdrop`,onPointerDown:e=>s.current=e.target===e.currentTarget,onClick:e=>{s.current&&e.target===e.currentTarget&&c(),s.current=!1},children:G(`div`,{ref:o,class:`proj-launcher`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`proj-title`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?(e.preventDefault(),i?a(null):c()):e.key===`Tab`&&kf(e,o.current)},children:[G(`header`,{class:`proj-head`,children:[G(`h2`,{id:`proj-title`,children:`Projects`}),G(`span`,{class:`proj-head-note`,children:_h.value===`server`?`Shared on the server: everyone with the studio link sees these`:`Saved in this browser · move them with Export / Import`}),G(`button`,{class:`icon-btn`,onClick:c,"aria-label":`Close projects`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`div`,{class:`proj-tools`,children:[G(`input`,{class:`input proj-search`,type:`search`,placeholder:`Search projects`,"aria-label":`Search projects`,value:e,onInput:e=>t(e.currentTarget.value)}),G(`button`,{class:`btn sm`,disabled:Q.value===`off`,onClick:Kg,children:[G(K,{name:`upload`,size:14}),` Import…`]}),G(`button`,{class:`btn primary sm`,disabled:Q.value===`off`||wh.value,onClick:()=>void sg().then(()=>r(Z.value?.id??null)),children:[G(K,{name:`plus`,size:14}),` New project`]})]}),_h.value===`server`&&vh.value>0&&G(`div`,{class:`proj-move`,children:[G(`span`,{children:[vh.value===1?`A project is`:`${vh.value} projects are`,` still saved in this browser only.`]}),G(`button`,{class:`btn sm primary`,disabled:yh.value,onClick:async()=>{let e=vh.value;await Nf(`Move ${e===1?`this project`:`${e} projects`} to the shared server? Everyone with the studio link will see ${e===1?`it`:`them`}; the browser ${e===1?`copy is`:`copies are`} removed.`,{ok:`Move`})&&vg()},children:[G(K,{name:`upload`,size:14}),` `,bh.value?`Moving ${bh.value.done+1} of ${bh.value.total}…`:yh.value?`Moving…`:`Move ${vh.value===1?`it`:`all ${vh.value}`} to the server`]})]}),G(`ul`,{class:`proj-list`,"aria-label":`Projects`,"aria-busy":wh.value,children:[u.map(e=>G(e_,{p:e,renaming:n===e.id,confirming:i===e.id,onRename:r,onConfirm:a},e.id)),!u.length&&G(`li`,{class:`proj-none`,children:l?`No project matches “${e.trim()}”.`:`No saved projects.`})]}),G(n_,{}),G(`footer`,{class:`proj-foot`,children:f&&f.quota?G(A,{children:[G(`span`,{children:[`Site storage (includes cached models): `,Fh(f.usage),` of `,Fh(f.quota),` used`]}),G(`span`,{class:`proj-meter`,role:`meter`,"aria-label":`Site storage used`,"aria-valuemin":0,"aria-valuemax":f.quota,"aria-valuenow":f.usage,"aria-valuetext":`${Fh(f.usage)} of ${Fh(f.quota)}`,children:G(`span`,{style:{width:`${Math.min(100,100*f.usage/f.quota)}%`}})})]}):G(`span`,{children:[`Projects use about `,Fh(d),_h.value===`server`?` on the server`:``,` (shared audio counted in each)`]})})]})})}function e_({p:e,renaming:t,confirming:n,onRename:r,onConfirm:i}){let a=e.id===Z.value?.id,o=Q.value===`off`;return G(`li`,{class:`proj-row${a?` is-open`:``}`,children:[t?G(`div`,{class:`proj-row-main`,children:G(Yg,{value:e.name,label:`Rename ${e.name}`,onDone:t=>{r(null),t&&lg(e.id,t)}})}):G(`button`,{class:`proj-row-main`,"aria-current":a?`true`:void 0,disabled:wh.value,onClick:()=>void og(e.id),title:a?`The open project`:`Open ${e.name}`,children:[G(`span`,{class:`proj-row-name`,children:[e.name,a&&G(`span`,{class:`tag`,children:`open`})]}),G(`span`,{class:`proj-row-meta`,children:[Gg(e.summary),` · `,Fh(e.size),` · edited `,Wg(e.updatedAt)]})]}),G(`div`,{class:`proj-row-actions`,children:[G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>r(e.id),"aria-label":`Rename ${e.name}`,title:`Rename`,children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>void ug(e.id),"aria-label":`Duplicate ${e.name}`,title:`Duplicate`,children:G(K,{name:`copy`,size:14})}),G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>void gg(e.id),"aria-label":`Export ${e.name}`,title:`Export (zip)`,children:G(K,{name:`download`,size:14})}),G(`button`,{class:`icon-btn sm proj-del`,disabled:o,onClick:()=>i(e.id),"aria-label":`Delete ${e.name}`,title:`Delete`,children:G(K,{name:`trash`,size:14})})]}),n&&G(t_,{p:e,onDone:()=>i(null)})]})}function t_({p:e,onDone:t}){let n=N(null);return mt(()=>n.current.focus(),[]),G(`div`,{class:`proj-confirm`,role:`alertdialog`,"aria-label":`Delete ${e.name}?`,"aria-describedby":`proj-confirm-${e.id}`,children:[G(`span`,{id:`proj-confirm-${e.id}`,children:[`Delete “`,e.name,`”`,_h.value===`server`?` for everyone`:` and its audio (unless another project shares it)`,`? This can’t be undone`,e.id===Z.value?.id?`; another project opens`:``,`.`]}),G(`button`,{ref:n,class:`btn sm ghost`,onClick:t,children:`Cancel`}),G(`button`,{class:`btn sm proj-danger`,onClick:()=>{t(),dg(e.id)},children:`Delete`})]})}function n_(){let e=Z.value;return e?G(`section`,{class:`proj-current`,"aria-label":`${e.name}: save state`,children:G(`div`,{class:`proj-current-head`,children:[G(`h3`,{children:e.name}),G(`span`,{class:`proj-current-state`,children:[G(qg,{}),` `,hh.value??Hg[Q.value]]}),Q.value===`error`&&G(`button`,{class:`btn sm`,onClick:()=>void bg(),children:`Try again`}),Q.value===`conflict`&&G(A,{children:[!gh.value&&G(`button`,{class:`btn sm`,disabled:wh.value,onClick:()=>void fg(),children:`Reload`}),G(`button`,{class:`btn sm`,onClick:()=>void pg(),children:`Keep mine as a copy`})]}),G(`button`,{class:`btn sm`,onClick:()=>Na.value=!0,children:[G(K,{name:`gear`,size:13}),` Project settings…`]})]})}):null}var r_=F(yl(`theme`,matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`));bl(`theme`,r_);var i_={dark:`#0a0a0a`,light:`#f5f3ee`};na(()=>{r_.value===`light`?document.documentElement.dataset.theme=`light`:delete document.documentElement.dataset.theme,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,i_[r_.value])}),addEventListener(`storage`,e=>{if(e.key===`zvs.theme`&&e.newValue)try{let t=JSON.parse(e.newValue);(t===`dark`||t===`light`)&&(r_.value=t)}catch{}});var a_=()=>r_.value=r_.value===`dark`?`light`:`dark`;function o_(e,t=1){r_.value;let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(n);if(!r)return n||`currentColor`;let i=parseInt(r[1],16),a=(r[2]?parseInt(r[2],16)/255:1)*t;return`rgba(${i>>16}, ${i>>8&255}, ${i&255}, ${+a.toFixed(3)})`}function s_({pcm:e,color:t=`var(--text)`,playId:n,height:r=56,busy:i,length:a,onSeek:o,label:s}){let c=N(null),[l,u]=j(0),[d,f]=j(`currentColor`);M(()=>{let e=c.current,t=new ResizeObserver(([e])=>u(Math.round(e.contentRect.width)));return t.observe(e),()=>t.disconnect()},[]);let p=r_.value;M(()=>{f(getComputedStyle(c.current).color)},[t,p]),M(()=>{c.current&&l&&ne(c.current,e,l,r,d,a)},[e,l,r,d,a]);let m=B.value,h=n&&m?.id===n&&m.duration?Math.min(100,Ms.value/m.duration*100):null;return G(`div`,{class:`wave${i?` is-busy`:``}${o?` is-seekable`:``}`,style:{height:`${r}px`,color:t},onPointerDown:o?e=>{let t=e.currentTarget.getBoundingClientRect();o(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}:void 0,role:s?`img`:void 0,"aria-label":s,children:[G(`canvas`,{ref:c,style:{width:`100%`,height:`${r}px`}}),h!==null&&G(`div`,{class:`wave-head`,style:{left:`${h}%`}})]})}var c_=e=>!!e?.startsWith(`Pronunciation:`),l_=I(()=>!!Ca.value),u_=I(()=>l_.value&&!!L.value?.pron.phonemize_enabled),d_=I(()=>L.value?.pron.phonemize_languages??[]),f_=F(Sa.value.language);na(()=>void(f_.value=Sa.value.language));var p_=I(()=>d_.value.includes(f_.value)?f_.value:d_.value.includes(`en_us`)?`en_us`:d_.value[0]??`en_us`),m_=F({}),h_=F(!1);async function g_(e,t,n){if(n<=t)return z(`Select the words to pronounce first.`),null;let r=p_.value,i=e.slice(t,n).split(/(\([^()]*\))/);h_.value=!0;try{let a=(await Promise.all(i.map(async(e,t)=>t%2==1||!e.trim()?[{text:e,status:null,ipa:null}]:(await Po(e,r,!0)).segments))).flat(),o={...m_.value},s=a.map(e=>{if(!e.ipa||e.status!==`ok`&&e.status!==`guessed`)return e.text;let t=xn(e.ipa);return e.status===`guessed`?o[t]=e.text:delete o[t],`(${t})`}).join(``);m_.value=o;let c=e=>a.filter(t=>t.status===e).map(e=>e.text),l=c(`ok`).length+c(`guessed`).length,u=[];c(`ambiguous`).length&&u.push(`several pronunciations: ${c(`ambiguous`).join(`, `)}`),c(`unknown`).length&&u.push(`not in the lexicon: ${c(`unknown`).join(`, `)}`),c(`skipped`).length&&u.push(`no reading on its own: ${c(`skipped`).join(`, `)}`),c(`unsupported`).length&&u.push(`symbols this model has no token for: ${c(`unsupported`).join(`, `)}`);let d=c(`guessed`).length?` Guessed by rule, check: ${c(`guessed`).join(`, `)}.`:``;z(`Pronounced ${l} word${l===1?``:`s`} (${g(r)}).${d}${u.length?` Left as text (${u.join(`; `)}): write their X-SAMPA by hand.`:``}`,u.length||d?`info`:`ok`);let f=e.slice(0,t)+s+e.slice(n);return l?f:null}catch(e){return z(`Couldn’t look up pronunciations: ${V(e)}`,`error`),null}finally{h_.value=!1}}function __(e,t,n,r){e.focus(),e.setSelectionRange(t,n),document.execCommand(`insertText`,!1,r)||(e.setRangeText(r,t,n,`end`),e.dispatchEvent(new Event(`input`,{bubbles:!0})))}function v_({input:e,onDone:t}){return u_.value?G(`button`,{class:`icon-btn sm pron-btn`,disabled:h_.value,onMouseDown:e=>e.preventDefault(),onClick:async()=>{let n=e();if(!n)return;let r=n.selectionStart??0,i=n.selectionEnd??0,a=n.value,o=await g_(a,r,i);if(o===null||n.value!==a)return;let s=a.length-i;__(n,r,i,o.slice(r,o.length-s)),t?.()},"aria-label":`Pronounce the selected words`,title:`Pronounce…: look up the selected words in the ${g(p_.value)} lexicon and write them as X-SAMPA`,children:G(`span`,{"aria-hidden":`true`,class:`pron-btn-glyph`,children:`/ə/`})}):null}var y_=F(null);function b_(e,t,n){let r=e.getBoundingClientRect();y_.value={x:r.left,y:r.bottom+6,...t,replace:n,returnFocus:e}}function x_(){let e=y_.value;return e?G(S_,{st:e},`${e.start}:${e.body}:${e.x}:${e.y}`):null}function S_({st:e}){let[t,n]=j(e.body),r=N(null),i=N(null),a=N(()=>{});M(()=>{requestAnimationFrame(()=>i.current?.select());let e=e=>!r.current?.contains(e.target)&&a.current();return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]);let o=Ca.value,s=new Set(o?.symbols??[]),c=bn(t),l=[...c].filter(e=>!s.has(e)),u=()=>{let e=y_.value?.returnFocus;y_.value=null,e?.focus?.()},d=()=>{if(!c||l.length)return;let n=`(${t.trim()})`;if(e.replace(e.start,e.end,n),m_.value[t.trim()]!==void 0||m_.value[e.body]!==void 0){let{[e.body]:n,[t.trim()]:r,...i}=m_.value;m_.value=i}u()};a.current=()=>{if(t.trim()===e.body)return u();if(c&&!l.length)return d();let n=r.current?.querySelector(`.pron-warn, .pron-ipa`);n?.classList.add(`is-flash`),setTimeout(()=>n?.classList.remove(`is-flash`),900),i.current?.focus()};let f=P(e.x,12,window.innerWidth-352),p=e.y+220>window.innerHeight?Math.max(12,e.y-250):e.y;return G(`div`,{ref:r,class:`pron-editor`,style:{left:`${f}px`,top:`${p}px`},role:`dialog`,"aria-label":`Edit pronunciation`,children:[G(`label`,{class:`pron-field`,children:[G(`span`,{class:`eyebrow`,children:`X-SAMPA`}),G(`input`,{ref:i,class:`input mono`,value:t,spellcheck:!1,"aria-describedby":`pron-ipa`,onInput:e=>n(e.currentTarget.value.replace(/[()]/g,``)),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())}})]}),G(`div`,{class:`pron-ipa`,id:`pron-ipa`,"aria-live":`polite`,children:[G(`span`,{class:`eyebrow`,children:`IPA sent`}),G(`span`,{class:`pron-ipa-symbols`,children:c?[...c].map(e=>G(`span`,{class:s.has(e)?``:`is-bad`,title:s.has(e)?`${e} has a token`:`no token for ${e} (U+${e.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)})`,children:e})):G(`span`,{class:`muted`,children:`empty`})})]}),l.length>0&&G(`p`,{class:`pron-warn`,children:[`No token on this model for `,[...new Set(l)].map(e=>`“${e}”`).join(` `),`: the server would refuse it.`]}),m_.value[e.body]&&G(`p`,{class:`pron-check`,children:[`Guessed by rule for “`,m_.value[e.body],`”: check it and save to confirm.`]}),G(`p`,{class:`hint`,children:`“_” ties (t_S = t͡ʃ); stress " % and dots are dropped. Symbols without an X-SAMPA spelling are typed as-is.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm ghost`,onClick:u,children:`Cancel`}),G(`button`,{class:`btn sm primary`,disabled:!c||l.length>0,onClick:d,children:`Save`})]})]})}function C_({text:e,replace:t,issuesOnly:n}){let r=Ca.value,i=Sn(e,r);return r?!i.issues.length&&(n||!i.groups.length)?null:G(`span`,{class:`pron-marks`,"aria-label":`Pronunciations`,children:[i.groups.filter(e=>!e.empty&&!n).map(e=>{let n=m_.value[e.body];return G(`button`,{class:`pron-chip${e.unknown.length?` is-bad`:``}${n?` is-check`:``}`,title:`(${e.body}) → ${e.ipa}${n?` · guessed for “${n}”, check it`:``}${e.unknown.length?` · no token for ${e.unknown.join(` `)}`:``}${t?` · click to edit`:``}`,disabled:!t,onClick:n=>t&&b_(n.currentTarget,e,t),children:[G(`span`,{class:`pron-chip-ipa`,children:e.ipa}),n&&G(`span`,{class:`pron-chip-check`,children:`check`})]})}),i.issues.filter(e=>n||!i.groups.some(t=>t.start===e.at&&t.unknown.length&&!t.empty)).map(e=>G(`span`,{class:`pron-issue`,role:`note`,children:[G(K,{name:`x`,size:10}),` `,e.text]}))]}):i.groups.length?G(`span`,{class:`pron-marks`,children:G(`span`,{class:`pron-off`,title:`This server reads parentheses as plain text: it has no pronunciation input`,children:`( ) read as text`})}):null}function w_(){return L.value?l_.value?G(`div`,{class:`pron-help`,children:[G(`p`,{class:`hint`,children:[`Write a pronunciation in X-SAMPA between parentheses: “I met `,G(`span`,{class:`mono`,children:`(S@vQn)`}),`” reads `,G(`span`,{class:`mono`,children:`ʃəvɒn`}),`.`,u_.value?` Or select words and press /ə/ to look them up.`:``]}),u_.value&&d_.value.length>1&&G(`label`,{class:`pron-lang`,title:`Where /ə/ looks words up. It follows the project language until you pick another here (for this session)`,children:[`lexicon (for /ə/ lookups) · `,p_.value===Sa.value.language?`follows language`:`overridden`,G(`select`,{class:`input`,value:p_.value,onChange:e=>f_.value=e.currentTarget.value,"aria-label":`Pronunciation lexicon language`,children:d_.value.map(e=>G(`option`,{value:e,children:g(e)}))})]})]}):G(`div`,{class:`hint pron-help`,children:G(`p`,{children:`This server has no pronunciation lexicon: parentheses are read as text.`})}):null}var T_=I(()=>!!L.value?.tags),E_=e=>`<${e}/>: ${An[e].note}`,D_=F(null);function O_(e,t=!1){let n=e.selectionStart??e.value.length,r=e.selectionEnd??n,i=e.getBoundingClientRect();D_.value={x:i.left,y:i.bottom+6,text:e.value,start:n,end:r,apply:t=>{__(e,t.start,t.end,t.insert),e.setSelectionRange(t.caret,t.caret)},literal:t?()=>__(e,n,r,`<`):null,returnFocus:e}}function k_(e,t,n,r,i){D_.value={x:e.left,y:e.bottom+6,text:t,start:n,end:r,apply:e=>i(t.slice(0,e.start)+e.insert+t.slice(e.end)),literal:null,returnFocus:null}}addEventListener(`keydown`,e=>{let t=e.target;e.key!==`<`||e.metaKey||e.ctrlKey||e.altKey||!T_.value||(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.hasAttribute(`data-tags`)&&(e.preventDefault(),O_(t,!0))},!0);function A_(){let e=D_.value;return e?G(j_,{st:e},`${e.x}:${e.y}:${e.start}:${e.end}`):null}function j_({st:e}){let t=N(null),n=e.end>e.start&&/\S/.test(e.text.slice(e.start,e.end)),r=new Set(L.value?.tags?.tags??On);mt(()=>{t.current?.querySelector(`button:not([disabled])`)?.focus();let e=e=>!t.current?.contains(e.target)&&i(!1);return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]);let i=(t=!0)=>{D_.value=null,t&&e.returnFocus?.focus()},a=t=>{i(),e.apply(Ln(e.text,e.start,t))},o=t=>{let n=zn(e.text,e.start,e.end,t);i(),n&&e.apply(n)},s=n=>{n.stopPropagation();let r=[...t.current.querySelectorAll(`button:not([disabled])`)],a=r.indexOf(document.activeElement),o=e=>r[(e+r.length)%r.length]?.focus();if(n.key===`ArrowDown`||n.key===`ArrowRight`)o(a+1);else if(n.key===`ArrowUp`||n.key===`ArrowLeft`)o(a-1);else if(n.key===`Home`)o(0);else if(n.key===`End`)o(r.length-1);else if(n.key===`Escape`)i(),e.literal?.();else if(n.key===`Tab`)return i();else if(/^[a-z]$/.test(n.key)){let e=a+1;[...r.slice(e),...r.slice(0,e)].find(e=>e.dataset.tag?.startsWith(n.key))?.focus()}else return;n.preventDefault()},c=P(e.x,12,window.innerWidth-332),l=e.y+230>window.innerHeight?Math.max(12,e.y-280):e.y;return G(`div`,{ref:t,class:`tag-palette`,style:{left:`${c}px`,top:`${l}px`},role:`dialog`,"aria-label":`Nonverbal tags`,onKeyDown:s,children:[G(`span`,{class:`eyebrow`,children:`At the caret`}),G(`div`,{class:`tag-palette-row`,role:`group`,"aria-label":`Point tags`,children:On.filter(e=>r.has(e)).map(e=>G(`button`,{class:`tag-pick${An[e].weak?` is-weak`:``}`,"data-tag":e,onClick:()=>a(e),title:E_(e),children:[e,An[e].weak&&G(`span`,{class:`tag-weak`,children:`weak`})]},e))}),G(`span`,{class:`eyebrow`,children:`Over the selected words`}),G(`div`,{class:`tag-palette-row`,role:`group`,"aria-label":`Span tags`,children:kn.filter(e=>r.has(e)).map(e=>G(`button`,{class:`tag-pick is-span is-weak`,"data-tag":`${e} span`,disabled:!n,onClick:()=>o(e),title:n?`<${e}>…: ${An[e].note}`:`Select words first`,children:[`‹`,e,`›`,G(`span`,{class:`tag-weak`,children:`weak`})]},e))}),G(`p`,{class:`hint`,children:[`Type a letter to jump · Esc `,e.literal?`types “<”`:`closes`]})]})}function M_({input:e}){return T_.value?G(`button`,{class:`icon-btn sm nv-btn`,onMouseDown:e=>e.preventDefault(),onClick:()=>{let t=e();t&&O_(t)},"aria-label":`Insert a nonverbal tag`,title:`Nonverbal tag (type “<” in the text)`,children:G(`span`,{"aria-hidden":`true`,class:`nv-btn-glyph`,children:`‹›`})}):null}function N_(e,t,n){return n?Hn(e,n):Un(e,t)}function P_({text:e,replace:t}){let n=Nn(e);return!n.tokens.length&&!n.issues.length?null:T_.value?G(`span`,{class:`tag-marks`,"aria-label":`Nonverbal tags`,children:[n.tokens.filter(e=>e.kind!==`close`).map(r=>{let i=n.spans.find(e=>e.open.start===r.start),a=i?e.slice(i.open.end,i.close.start).trim():``,o=t?N_(e,r,i):null;return G(`span`,{class:`tag-chip${i?` is-span`:``}${An[r.name].weak?` is-weak`:``}`,title:`${i?`<${r.name}> over “${a}”`:`<${r.name}/>`}: ${An[r.name].note}`,children:[G(`span`,{class:`tag-chip-name`,children:i?`‹${r.name}› ${a.length>18?`${a.slice(0,17)}…`:a}`:r.name}),t&&o!==null&&G(`button`,{class:`tag-chip-act`,onClick:()=>t(o),"aria-label":i?`Make <${r.name}> a point tag`:`Make <${r.name}/> a span over the next word`,title:i?`Make it a point tag`:`Make it a span over the next word`,children:`⇄`}),t&&G(`button`,{class:`tag-chip-act`,onClick:()=>t(Vn(e,r)),"aria-label":`Remove the ${r.name} tag`,title:`Remove the tag`,children:G(K,{name:`x`,size:10})})]},r.start)}),n.issues.map(e=>G(`span`,{class:`tag-issue`,role:`note`,children:[e.text,` (read as text)`]},e.at))]}):n.tokens.length?G(`span`,{class:`tag-marks`,children:G(`span`,{class:`tag-off`,title:`The model this server runs wasn’t trained on nonverbal tags (or the server has no tag support): the markup is read as text.`,children:`‹tags› read as text`})}):null}function F_({text:e,children:t,block:n}){let[r,i]=j(!1),a=N(null),[o,s]=j({}),c=T_.value&&!r&&Nn(e).tokens.length>0;return mt(()=>{if(!c)return;let e=a.current?.querySelector(`input, textarea`);if(!e)return;let t=getComputedStyle(e),n=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),r=e instanceof HTMLInputElement?`${n}px`:t.lineHeight;s({padding:t.padding,font:t.font,lineHeight:r,letterSpacing:t.letterSpacing})},[c]),G(`span`,{ref:a,class:`tag-field${n?` is-block`:``}${c?` is-viewing`:``}`,onFocusIn:()=>i(!0),onFocusOut:()=>i(!1),children:[t,c&&G(`span`,{class:`tag-view`,style:o,"aria-hidden":`true`,children:G(I_,{text:e})})]})}function I_({text:e}){let{tokens:t,spans:n}=Nn(e),r=[],i=0;for(let a of t){if(a.start>i){let t=n.find(e=>i>=e.open.end&&i1?`tag guidance ${e.tag_cfg_scale} on · voice guidance off`:null}function R_(e){requestAnimationFrame(()=>{let t=document.querySelector(e);t&&(t.scrollIntoView({block:`nearest`}),t.classList.add(`is-flash`),setTimeout(()=>t.classList.remove(`is-flash`),1200))})}function z_(){let e=kl.value,t=B.value?.id===Ll,n=B.value?.id===Rl;return G(`div`,{class:`ab`,role:`group`,"aria-label":`A/B`,children:[G(`button`,{class:`ab-btn${e===`A`?` is-on`:``}${t?` is-playing`:``}`,onClick:()=>t?Ws():nu(`A`),title:`Your design (A)`,children:[G(`b`,{children:`A`}),` design`]}),G(`button`,{class:`ab-btn${e===`B`?` is-on`:``}${n?` is-playing`:``}`,onClick:()=>n?Ws():nu(`B`),title:`The unsteered voice (B)`,children:[G(`b`,{children:`B`}),` original`]})]})}function B_(){let e=Fl.value,t=e.a;return e.status===`waiting`?`waiting…`:e.status===`rendering`?`rendering…`:e.status===`idle`?t?`${(t.pcm.length/t.sr).toFixed(1)} s`:W.value.baseId?`Press Speak to hear it`:``:e.status===`error`?``:t?`${(t.pcm.length/t.sr).toFixed(1)} s`:``}function V_(){let e=Fl.value.a;return e?`Clip length ${(e.pcm.length/e.sr).toFixed(1)} s · first audio after ${Math.round(e.ttfbMs)} ms`:`Clip length`}function H_(){let e=Il.value.error;return kl.value!==`B`||!e?null:G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t render the original voice`}),G(`span`,{children:e}),G(`button`,{class:`btn sm`,onClick:Zl,children:[G(K,{name:`refresh`,size:14}),` Retry`]})]})}function U_(){return G(`div`,{class:`mode preview-toggles`,role:`group`,"aria-label":`Preview settings`,children:[G(`button`,{class:`mode-btn${jl.value?` is-on`:``}`,"aria-pressed":jl.value,onClick:()=>jl.value=!jl.value,title:jl.value?`Auto: renders on every change (click to render only on Speak)`:`Renders only on Speak (click to render on every change)`,children:[G(K,{name:`wand`,size:12}),` Auto`]}),G(`button`,{class:`mode-btn${Al.value?` is-on`:``}`,"aria-pressed":Al.value,onClick:()=>Al.value=!Al.value,title:Al.value?`Play: new takes play by themselves (click to keep them quiet)`:`New takes wait for Speak (click to play them by themselves)`,children:[G(K,{name:`speaker`,size:12}),` Play`]})]})}function W_(){let e=Fl.value,t=Il.value,n=kl.value===`A`,r=n?Ll:Rl,i=n?e.a:t.take;return G(s_,{pcm:n?e.status===`rendering`&&e.partial?e.partial:e.a?.pcm:t.take?.pcm,color:n?`var(--o)`:`var(--text-2)`,playId:r,busy:n?e.status===`waiting`||e.status===`rendering`:!t.take&&!t.error,height:40,label:n?`Designed voice waveform`:`Original voice waveform`,onSeek:e=>i&&Ks(r,i.pcm,i.sr,e*(i.pcm.length/i.sr))})}function G_(){let e=Fl.value;return G(`div`,{class:`preview-strip`,"aria-label":`Preview`,children:[G(z_,{}),G(W_,{}),G(`span`,{class:`metrics${e.status===`rendering`||e.status===`waiting`?` is-busy`:``}`,"aria-live":`polite`,children:e.status===`error`?G(`span`,{class:`error-line`,children:c_(e.error)?`not rendered: fix the pronunciation`:e.error}):B_()})]})}function K_(e){Nl.value=!0,Ml.value=e}function q_(){Ng(`cast-library`),Og.peek()||requestAnimationFrame(()=>document.querySelector(`.voice.is-on .voice-name, .voices .voice-name`)?.focus({preventScroll:!1}))}function J_(){let e=Xc.value?.label;return G(`button`,{class:`btn sm voice-chip${e?``:` primary`}`,onClick:q_,title:e?`Change the voice`:`Pick a voice to start`,"aria-haspopup":`true`,children:[G(K,{name:`mic`,size:12}),` `,G(`span`,{class:`voice-chip-label`,children:e??`Pick a voice`}),` `,G(K,{name:`down`,size:10})]})}function Y_(){let e=Fl.value,t=e.a,n=kl.value===`A`?t:Il.value.take,[r,i]=j(null),a=N(null),o=L.value?.kind===`fixture`,s=r??Pl.value,c=B.value?.id===Ll,l=e.status===`waiting`||e.status===`rendering`,u=()=>{let e=a.current?.value??s;e!==Pl.value&&K_(e),i(null),iu()},d=!W.value.baseId,f=e.status===`idle`&&!!t,p=e.status===`error`;return G(`section`,{class:`speak${f||p?` is-stale`:``}`,"aria-label":`Speak`,children:[G(`div`,{class:`speak-text`,children:[G(F_,{text:s,block:!0,children:G(`textarea`,{ref:a,class:`speak-area`,rows:2,value:s,placeholder:R.value.ui.preview_text,"aria-label":`Text to speak`,"data-tags":!0,onInput:e=>i(e.currentTarget.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),u())},onBlur:e=>{if(e.relatedTarget?.closest?.(`.tag-palette, .speak-go`))return;let t=e.currentTarget.value;t!==Pl.value&&K_(t),i(null)}})}),G(`div`,{class:`speak-tools`,children:[G(v_,{input:()=>a.current}),G(M_,{input:()=>a.current})]})]}),G(C_,{text:s,replace:(e,t,n)=>{i(null),K_(s.slice(0,e)+n+s.slice(t))}}),G(P_,{text:s,replace:e=>{i(null),K_(e)}}),G(`div`,{class:`speak-bar`,children:[G(J_,{}),G(`button`,{class:`btn primary speak-go${l?` is-busy`:``}`,disabled:d||!s.trim(),onClick:()=>c?Ws():u(),title:d?`Pick a voice first`:f?`The voice changed since this take: render it again (Enter in the text box)`:`Speak this text (Enter in the text box)`,children:[G(K,{name:c?`stop`:`play`,size:14}),` `,c?`Stop`:l?`Rendering…`:f?`Speak again`:`Speak`]}),!d&&G(W_,{}),G(z_,{}),G(U_,{}),G(`span`,{class:`metrics`,title:V_(),children:B_()}),G(`button`,{class:`icon-btn`,disabled:!n,onClick:()=>n&&mn(n.pcm,n.sr,`${Xc.value?.label??`voice`}-${kl.value===`A`?`design`:`original`}`),title:`Export ${kl.value} as WAV`,"aria-label":`Export ${kl.value} as WAV`,children:G(K,{name:`download`})})]}),!t&&!l&&!p&&!Og.value&&G(`p`,{class:`hint speak-first`,children:`Pick a voice · type a line · Speak · then shape it below`}),p&&c_(e.error)&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Fix the pronunciation marked above`}),G(`span`,{children:e.error})]}),p&&!c_(e.error)&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t render`}),G(`span`,{children:e.error}),G(`button`,{class:`btn sm`,onClick:tu,children:[G(K,{name:`refresh`,size:14}),` Retry`]})]}),G(H_,{}),o&&G(`p`,{class:`note`,children:`This server can’t apply controls yet: A and B both play the base voice.`})]})}function X_(e){let t=R.value,n=[];for(let[r,i]of Object.entries(e)){if(!i)continue;if(r.startsWith(`accent:`)){let e=t.ui.accents.find(e=>e.id===r.slice(7));n.push(`${e?.label??r.slice(7)} accent`);continue}let e=Ta.value.get(r);e&&(e.type===`bipolar`&&e.poles?n.push(e.poles[i<0?0:1].toLowerCase()):n.push(`more ${e.label.toLowerCase()}`))}return n.join(`, `)||`the plain voice`}function Z_(){let e=Object.keys(R.value.ui.presets),t=W.value,n=e=>{let{values:n,accents:r}=Xt(R.value.ui.presets[e]),i=As(r,R.value.ui.accents,t.pin.tab);return[...new Set([...Object.keys(n),...Object.keys(t.values).filter(e=>t.values[e])])].every(e=>(n[e]??0)===(t.values[e]??0))&&Math.hypot(i.x-t.pin.x,i.y-t.pin.y)<1&&i.tab===t.pin.tab};return e.length?G(`section`,{class:`monitor-card`,"aria-label":`Starting points`,children:[G(`header`,{class:`monitor-head`,children:G(`h3`,{children:`Starting points`})}),G(`div`,{class:`persona-chips`,children:e.map(e=>G(`button`,{class:`persona-chip${n(e)?` is-on`:``}`,"aria-pressed":n(e),onClick:()=>sl(e),title:X_(R.value.ui.presets[e]),children:e}))})]}):null}var Q_=F([]),$_=F(null),ev=null;function tv(){ev?.abort();let e=ev=new AbortController,t=W.value;$_.value=t,Q_.value=_l(t).map(e=>({...e,id:It(),audio:null,error:null,busy:!0}));for(let t of Q_.value)cc(Dl(R.value,wa.value,t.design,Pl.value,xl,{language:Sa.value.language}),{signal:e.signal}).then(e=>Q_.value=Q_.value.map(n=>n.id===t.id?{...n,audio:e,busy:!1}:n)).catch(e=>!lc(e)&&(Q_.value=Q_.value.map(n=>n.id===t.id?{...n,error:V(e),busy:!1}:n)))}function nv(){let e=Q_.value,t=W.value,n=e.find(e=>e.design===t)??null,r=$_.value!==null&&$_.value!==t&&!n,i=e.filter(e=>e.busy).length,a=e.length>0&&e.every(e=>e.error);return G(`section`,{class:`monitor-card`,"aria-label":`Variations`,children:[G(`header`,{class:`monitor-head`,children:[G(`h3`,{children:`Voices near this one`}),G(`button`,{class:`btn sm`,onClick:tv,disabled:!t.baseId||i>0,title:`Renders five takes`,children:[G(K,{name:`dice`,size:14}),` `,i?`Rendering ${e.length-i}/${e.length}…`:e.length?`Five more`:`Find five`]})]}),u()&&G(`p`,{class:`hint`,children:`Counts against your GPU quota`}),e.length?a?G(`div`,{class:`error-line`,children:[`Couldn’t render: `,e[0].error,` `,G(`button`,{class:`link`,onClick:tv,children:`Retry`})]}):G(`ul`,{class:`tiles${r?` is-stale`:``}`,children:e.map(e=>{let t=`var:${e.id}`,r=B.value?.id===t;return G(`li`,{class:`tile${e===n?` is-current`:``}`,children:[G(`button`,{class:`play-mini${r?` is-playing`:``}${e.busy?` is-busy`:``}`,disabled:!e.audio,onClick:()=>e.audio&&Js(t,e.audio.pcm,e.audio.sr),"aria-label":`Play variation: ${e.changes.join(`, `)}`,children:G(K,{name:r?`stop`:`play`,size:12})}),G(`button`,{class:`tile-body`,"aria-current":e===n?`true`:void 0,onClick:()=>{e!==n&&(U.apply(e.design),e.audio&&Ks(t,e.audio.pcm,e.audio.sr),z(`Stepped to: ${e.changes.join(` · `)}`,`info`,{label:`Undo`,run:()=>U.undo()}))},title:e===n?`The voice on the bench`:`Step to this voice (undo with ⌘Z)`,children:[G(`span`,{class:`tile-changes`,children:e.changes.join(` · `)}),e.error?G(`span`,{class:`error-line small`,children:e.error}):G(s_,{pcm:e.audio?.pcm,color:`var(--o)`,playId:t,height:22,busy:e.busy})]})]})})}):G(`p`,{class:`muted small`,children:`Five small, safe moves around this voice, rendered side by side. Click one to step there.`}),r&&e.length>0&&G(`p`,{class:`note`,children:`You moved since these were found; they still sit around the earlier voice.`})]})}function rv(e){let t=new Set(zc.value.map(e=>e.name));if(!t.has(e))return e;for(let n=2;;n++)if(!t.has(`${e} ${n}`))return`${e} ${n}`}function iv(){let[e,t]=j(``),[n,r]=j(``),[i,a]=j(!1),o=W.value,s=L.value,c=yc.value[o.baseId],l=o.mode===`embedding`&&!!Qc.value&&(s.kind===`offline`||!vc.value)&&s.steering,u=o.mode===`embedding`?s.steering?vc.value?`Not available with this server’s placeholder voices.`:c?`Couldn't fetch this voice's embedding: ${c}`:Qc.value?null:`Waiting for the base voice…`:`This server can’t apply controls yet, so there is no shaped voice to save.`:`Exact clones are already in Your voices.`,d=e.trim()||`${Xc.value?.label??`Voice`} variant`,f=()=>{let e=rv(d),i={id:It(),name:e,design:structuredClone(o),signature:n.trim()||Pl.value,createdAt:Date.now()};Bc(i),z(`“${e}” joined your cast`,`ok`),t(``),r(``),R_(`[data-persona="${i.id}"]`)},p=async()=>{if(Qc.value){a(!0);try{let e=await jc(d,Qc.value),t=Um.value;Qm(e,Xc.value,o.values[t.gender.control]??0,o.values[t.age.control]??0),await bc(),z(`Saved “${e.label}” as a voice`,`ok`),R_(`[data-voice="${e.id}"]`)}catch(e){z(`Couldn’t save the voice: ${V(e)}`,`error`)}finally{a(!1)}}};return G(`section`,{class:`monitor-card save save-panel`,"aria-label":`Save this voice`,children:[G(`header`,{class:`monitor-head`,children:G(`h3`,{children:`Save this voice`})}),G(`form`,{class:`col gap-s`,onSubmit:e=>{e.preventDefault(),o.baseId&&f()},children:[G(`input`,{class:`input`,placeholder:d,value:e,onInput:e=>t(e.currentTarget.value),"aria-label":`Name`}),G(`input`,{class:`input`,placeholder:`Signature line: what this voice says when loaded (optional)`,value:n,onInput:e=>r(e.currentTarget.value),"aria-label":`Signature line`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{type:`submit`,class:`btn primary`,disabled:!o.baseId,title:`Keeps the whole design (voice, accent, delivery, mood) in this project's cast, for Direct's lines`,children:[G(K,{name:`plus`,size:14}),` Add to cast `,G(`span`,{class:`muted`,children:`(use in Direct)`})]}),G(`button`,{type:`button`,class:`btn`,onClick:()=>void p(),disabled:!l||i,title:u??`Keeps the identity you shaped as a new voice in Your voices (delivery and mood stay in the cast member)`,children:[G(K,{name:`save`,size:14}),` `,i?`Saving…`:`Save to Your voices`]})]})]}),u&&G(`p`,{class:`hint`,children:[u,c&&G(A,{children:[` · `,G(`button`,{class:`link`,onClick:()=>Xc.value&&void Sc(Xc.value,!0),children:`Retry`})]})]})]})}async function av(e){let t=q.value,n=t.lines.filter(t=>t.voice===e.id).length+ +(t.voice===e.id);if(n>0&&!await Nf(`${n} line${n===1?` speaks`:`s speak`} as ${e.name}. Remove it? They will fall back to the script voice.`,{ok:`Remove`,danger:!0}))return;let r=t.voice===e.id,i=n>0?Bd(e.id):[],a=Vc(e.id);a&&z(`Removed “${e.name}”`,`info`,{label:`Undo`,run:()=>{Hc(a.persona,a.index),(i.length||r)&&Vd(i,e.id,r?e.id:void 0)}})}async function ov(e){let t=q.value,n=t.lines.filter(t=>t.voice===e.id).length+ +(t.voice===e.id);if(n>0&&!await Nf(`${n} line${n===1?` speaks`:`s speak`} as ${e.label}. Remove it? They will fall back to the default voice.`,{ok:`Remove`,danger:!0}))return;let r=t.voice===e.id,i=n>0?Bd(e.id):[],a=W.value.baseId===e.id,o=Rc(e.id);o&&z(`Removed “${e.label}” from this project`,`info`,{label:`Undo`,run:()=>{o(),(i.length||r)&&Vd(i,e.id,r?e.id:void 0),a&&il(e.id,`library`)}})}function sv({s:e,own:t}){let n=W.value.baseId===e.id,r=B.value?.id===`clip:${e.id}`,i=Tc.value===e.id,[a,o]=j(!1);return G(`li`,{class:`voice${n?` is-on`:``}`,"data-voice":e.id,children:[G(`button`,{class:`play-mini${r?` is-playing`:``}${i?` is-busy`:``}`,onClick:()=>void Ec(e),disabled:e.has_preview===!1,"aria-label":`${r?`Stop`:`Play`} ${e.label}'s reference clip`,title:e.has_preview===!1?`No reference clip (designed voice)`:`Reference clip`,children:G(K,{name:r?`stop`:`play`,size:12})}),a?G(Yg,{value:e.label,label:`Rename ${e.label}`,onDone:t=>{o(!1),t&&Lc(e.id,t)}}):G(`button`,{class:`voice-name`,onClick:()=>il(e.id,`library`),"aria-pressed":n,title:n?`Current base voice`:`Use as the base voice`,children:[G(`span`,{class:`voice-label`,children:e.label}),Wa(e)&&G(`span`,{class:`tag`,children:`designed`})]}),t&&G(A,{children:[G(`button`,{class:`icon-btn sm`,"aria-label":`Rename ${e.label}`,title:`Rename (in this project)`,onClick:()=>o(!0),children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,"aria-label":`Remove ${e.label}`,title:`Removes it from this project (the server keeps it for this session)`,onClick:()=>void ov(e),children:G(K,{name:`trash`,size:14})})]})]})}function cv(){let e=Pc.value;if(!e)return null;let t=`clip:pending`,n=B.value?.id===t,r=async()=>{let e=await Ic();e&&(il(e.id,`clip`),Sc(e),R_(`[data-voice="${e.id}"]`))};return G(`div`,{class:`pending-clip`,role:`group`,"aria-label":`Your recording`,children:[G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`play-mini${n?` is-playing`:``}`,onClick:()=>Js(t,e.pcm,e.sr),"aria-label":n?`Stop`:`Play the recording`,children:G(K,{name:n?`stop`:`play`,size:12})}),G(s_,{pcm:e.pcm,color:`var(--o)`,playId:t,height:28,label:`Recording waveform`,onSeek:n=>Ks(t,e.pcm,e.sr,n*e.seconds)}),G(`span`,{class:`metrics`,children:[e.seconds.toFixed(1),` s`]})]}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm primary`,disabled:Dc.value,onClick:()=>void r(),children:[G(K,{name:`plus`,size:12}),` Use`]}),G(`button`,{class:`btn sm`,onClick:()=>(qs(t)&&Ws(),Pc.value=null),children:`Discard`}),e.seconds<5&&G(`span`,{class:`hint`,children:`Short: 5–30 s clones best`})]})]})}function lv(){let e=Mc.value,[,t]=j(0);if(M(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),250);return()=>clearInterval(n)},[e]),e){let t=Math.floor((Date.now()-e.started)/1e3);return G(`button`,{class:`btn btn-rec is-recording`,onClick:e.stop,title:`Recording stops by itself at 30 s`,children:[G(`span`,{class:`rec-dot`}),` Stop · 0:`,String(t).padStart(2,`0`),` / 0:`,30,G(`span`,{class:`rec-level`,"aria-hidden":`true`,children:G(`span`,{style:{width:`${Math.round(Nc.value*100)}%`}})})]})}return G(`button`,{class:`btn btn-rec`,disabled:Dc.value||!!Pc.value,onClick:()=>void Fc(),title:`Record 5-30 s of clean speech to clone a voice`,children:[G(K,{name:`mic`}),` Record`]})}function uv(e){H.value.find(t=>t.id===e.design.baseId)||z(`${e.name}'s voice is gone from the server; pick a base voice`,`error`),U.apply(structuredClone(e.design));let t=e.signature.trim(),n=Pl.value.trim();t&&(!n||n===t)?(n!==t&&K_(t),z(`Loaded ${e.name}`,`info`,{label:`Undo`,run:()=>U.undo()})):z(`Loaded ${e.name}`,`info`,t?{label:`Use its line`,run:()=>K_(t)}:{label:`Undo`,run:()=>U.undo()})}function dv({p:e}){let t=H.value.find(t=>t.id===e.design.baseId),[n,r]=j(!1);return G(`li`,{class:`voice persona${t?``:` is-missing`}`,"data-persona":e.id,children:[n?G(Yg,{value:e.name,label:`Rename ${e.name}`,onDone:t=>{r(!1),t&&Uc(e.id,t)}}):G(`button`,{class:`voice-name`,onClick:()=>uv(e),title:t?`Load ${e.name} onto the bench`:`${e.name}'s base voice is gone from the server`,children:[e.name,G(`span`,{class:`sub`,children:t?.label??`voice unavailable`})]}),G(`button`,{class:`icon-btn sm`,"aria-label":`Rename ${e.name}`,title:`Rename`,onClick:()=>r(!0),children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,"aria-label":`Remove ${e.name}`,title:`Remove from cast`,onClick:()=>void av(e),children:G(K,{name:`trash`,size:14})})]})}async function fv(e){let t=await Oc(e,e.name.replace(/\.[^.]+$/,``),e.name,!0);t&&(il(t.id,`clip`),Sc(t),R_(`[data-voice="${t.id}"]`))}function pv(){let e=N(null),t=H.value.filter(e=>e.is_default),n=H.value.filter(e=>!e.is_default);return G(`aside`,{class:`rail`,"aria-label":`Voice library`,children:[G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Voices`}),pc.value?G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t load the voices`}),G(`span`,{children:pc.value}),G(`button`,{class:`btn sm`,onClick:()=>void bc(),children:[G(K,{name:`refresh`,size:14}),` Retry`]})]}):mc.value&&!t.length?G(`p`,{class:`muted`,children:`Loading voices…`}):G(`ul`,{class:`voices`,children:t.map(e=>G(sv,{s:e},e.id))})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Your voices`}),n.length?G(`ul`,{class:`voices`,children:n.map(e=>G(sv,{s:e,own:!0},e.id))}):G(`p`,{class:`muted small`,children:`Upload, drop or record a clip to clone a voice. Designed voices you save appear here too.`}),G(cv,{}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn`,disabled:Dc.value,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`}),` `,Dc.value?`Uploading…`:`Upload`]}),G(lv,{}),G(`input`,{ref:e,type:`file`,accept:`audio/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&fv(t)}})]})]}),G(`div`,{class:`rail-section grow`,children:[G(`h4`,{children:`Your cast`}),zc.value.length?G(`ul`,{class:`voices`,children:zc.value.map(e=>G(dv,{p:e},e.id))}):G(`p`,{class:`muted small`,children:`Design a voice, then “Save to cast” to keep it for Direct (each line can use its own voice).`})]}),G(Vg,{label:`Drop to clone this voice`,hint:`An audio clip of 5–30 s of clean speech`,busy:Dc.value?`Wait for the current upload…`:null,onFile:e=>void fv(e)})]})}var mv={strong:`strong`,collapse:`may glitch`},hv=(e,t,n)=>(P(n,e,t)-e)/(t-e||1)*100;function gv(e){let t=e.range[1]-e.range[0];return t>12?.5:t>5?.1:.05}function _v({control:e,value:t,color:n,disabled:r,vertical:i,bare:a,label:o,compact:s,detailed:c,format:l=Ft,onStart:u,onChange:d,onEnd:f}){let[p,m]=e.range,h=Wt(e,t),g=gv(e),_=e=>Math.round(P(e,p,m)/g)*g,v=hv(p,m,0),y=hv(p,m,t),b=[];e.safe[0]>p&&b.push({from:0,to:hv(p,m,e.safe[0]),cls:`strong`}),e.safe[1]p&&b.push({from:0,to:hv(p,m,e.collapse[0]),cls:`collapse`}),e.collapse?.[1]!=null&&e.collapse[1]{let n=null,r=e.shiftKey?5:1;e.key===`ArrowRight`||e.key===`ArrowUp`?n=t+g*2*r:e.key===`ArrowLeft`||e.key===`ArrowDown`?n=t-g*2*r:e.key===`Home`?n=p:e.key===`End`?n=m:(e.key===`0`||e.key===`Delete`||e.key===`Backspace`)&&(n=0),n!==null&&(e.preventDefault(),u?.(),d(_(n)),f?.())},w=e.type===`bipolar`&&e.poles?`${e.poles[0]} ↔ ${e.poles[1]}`:null,T=[s?w:null,e.effect,`range ${p}…${m} · natural ${e.safe[0]}…${e.safe[1]}`].filter(Boolean).join(` · `);return G(`div`,{class:`slider${i?` is-vertical`:``}${s?` is-compact`:``}${c?` is-detailed`:``}${r?` is-disabled`:``} zone-${h}`,style:{"--fam":n},title:T,children:[s&&G(`span`,{class:`slider-label`,children:o??e.label}),!a&&!s&&G(`div`,{class:`slider-head`,children:[G(`span`,{class:`slider-label`,children:o??e.label}),G(`span`,{class:`slider-value`,children:[mv[h]&&G(`span`,{class:`zone-tag zone-${h}`,children:mv[h]}),l(t)]})]}),G(`div`,{class:`slider-track`,role:`slider`,tabIndex:r?-1:0,"aria-label":o??e.label,"aria-valuemin":p,"aria-valuemax":m,"aria-valuenow":t,"aria-valuetext":`${l(t)}${mv[h]?` (${mv[h]})`:``}`,"aria-orientation":i?`vertical`:`horizontal`,"aria-disabled":r,onKeyDown:r?void 0:C,onDblClick:r?void 0:()=>(u?.(),d(0),f?.()),onPointerDown:r?void 0:e=>{u?.(),Lg(e,(e,t)=>d(_(p+(i?1-t:e)*(m-p))),f)},children:[G(`div`,{class:`slider-rail`}),b.map(e=>G(`div`,{class:`slider-band band-${e.cls}`,style:{[x]:`${e.from}%`,[S]:`${e.to-e.from}%`}})),G(`div`,{class:`slider-fill`,style:{[x]:`${Math.min(v,y)}%`,[S]:`${Math.abs(y-v)}%`}}),p<0&&G(`div`,{class:`slider-zero`,style:{[x]:`${v}%`}}),G(`div`,{class:`slider-thumb`,style:{[x]:`${y}%`}})]}),s&&G(`span`,{class:`slider-value`,children:[mv[h]&&G(`span`,{class:`zone-tag zone-${h}`,children:mv[h]}),l(t)]}),!a&&!s&&e.type===`bipolar`&&e.poles&&G(`div`,{class:`slider-poles`,children:[G(`span`,{children:e.poles[0]}),G(`span`,{children:e.poles[1]})]}),c&&G(`p`,{class:`slider-effect`,children:[e.effect&&G(`span`,{children:e.effect}),G(`span`,{class:`slider-ranges`,children:[`natural `,Ft(e.safe[0]),`…`,Ft(e.safe[1]),(e.safe[0]>p||e.safe[1]Math.max(.5,Math.round(e*2)/2),yv=I(()=>{let[e,t]=R.value.ui.controls.filter(e=>e.group===`mood`&&e.type===`bipolar`);return e&&t?{x:e,y:t}:null}),bv=I(()=>{let e=new Map((R.value.ui.moods??[]).map(e=>[e.control,e])),t=R.value.ui.controls.filter(e=>e.group===`mood`&&e.type===`unipolar`).map(t=>{let n=e.get(t.id),r=n&&Number.isFinite(n.valence)&&Number.isFinite(n.arousal)?{valence:n.valence,arousal:n.arousal}:null;return{control:t,label:n?.label??t.label,at:r,dose:n?.dose&&n.dose>0?n.dose:vv(t.safe[1]*.5),effect:n?.effect??t.effect??``}});return t.every(e=>e.at)?t.sort((e,t)=>t.at.arousal-e.at.arousal):t}),xv=I(()=>new Set(bv.value.map(e=>e.control.id))),Sv=e=>`×${+e.toFixed(e%1?1:0)}`,Cv=e=>`strength ${+e.toFixed(e%1?1:0)}`;function wv(e,t){return`${e.label}${e.effect?`: ${e.effect}`:``} · default ${Cv(e.dose)}${t>0?` · now ${Cv(t)} (click to remove)`:` (click to add)`}`}function Tv(e,t){let n=e.values[t.control.id]??0;e.begin(),e.set(t.control.id,n>0?0:t.dose),e.end()}function Ev({m:e,values:t,onPick:n}){let r=t[e.control.id]??0;return G(`button`,{class:`chip mood-chip${r>0?` is-on`:``} zone-${Wt(e.control,r)}`,"aria-pressed":r>0,title:wv(e,r),onClick:()=>n(e),children:[e.label,r>0&&G(`b`,{children:Sv(r)})]})}function Dv({values:e,onPick:t}){let n=bv.value;return n.length?G(`div`,{class:`chips mood-chips`,style:{"--fam":Da(`mood`)},role:`group`,"aria-label":`Moods`,children:n.map(n=>G(Ev,{m:n,values:e,onPick:t}))}):null}var Ov=e=>({x:(e.at.valence+1)/2,y:(1-e.at.arousal)/2});function kv(e,t,n){let r=10/t,i=e=>({x:Math.min(1-r,Math.max(r,e.x)),y:Math.min(1-r,Math.max(r,e.y))}),a=e.map(e=>i(Ov(e))),o=n/t;for(let e=0;e<40;e++){let e=!1;for(let t=0;t=o)continue;c<1e-6&&(r=0,s=1,c=1);let l=(o-Math.hypot(a[n].x-a[t].x,a[n].y-a[t].y))/2+1e-4;a[t]=i({x:a[t].x-r/c*l,y:a[t].y-s/c*l}),a[n]=i({x:a[n].x+r/c*l,y:a[n].y+s/c*l}),e=!0}if(!e)break}return new Map(e.map((e,t)=>[e.control.id,a[t]]))}function Av(e,t,n,r,i,a){let o=new Map,s=i+4,c=[...a,...e.map(e=>({x:t.get(e.control.id).x*r-5,y:t.get(e.control.id).y*r-5,w:10,h:10}))],l=e=>e.x<1||e.y<1||e.x+e.w>r-1||e.y+e.h>r-1||c.some(t=>e.xNumber((n[t.control.id]??0)>0)-Number((n[e.control.id]??0)>0));for(let e of u){let{x:a,y:u}=t.get(e.control.id),d=a*r,f=u*r,p=n[e.control.id]??0,m=(e.label.length+(p>0?Sv(p).length+1:0))*i*.6+6,h=[[`r`,{x:d+5+1,y:f-s/2,w:m,h:s}],[`l`,{x:d-5-1-m,y:f-s/2,w:m,h:s}],[`u`,{x:d-m/2,y:f-5-s,w:m,h:s}],[`d`,{x:d-m/2,y:f+5,w:m,h:s}],[`dr`,{x:d+5,y:f+5-2,w:m,h:s}],[`dl`,{x:d-5-m,y:f+5-2,w:m,h:s}]].find(([,e])=>!l(e));o.set(e.control.id,h?h[0]:`hidden`),h&&c.push(h[1])}return o}function jv(e){let[t,n]=j(0);return mt(()=>{let t=e.current;if(!t)return;n(t.clientWidth);let r=new ResizeObserver(()=>n(t.clientWidth));return r.observe(t),()=>r.disconnect()},[e.current]),t}function Mv(e,t){return Math.min(Math.abs(e)>1e-6?.48/Math.abs(e):1/0,Math.abs(t)>1e-6?.48/Math.abs(t):1/0)}function Nv(e,t,n){let{x:r,y:i}=Ov(e),a=r-.5,o=i-.5,s=a*a+o*o,c=s>.0025?((t-.5)*a+(n-.5)*o)/s:Math.hypot(t-.5,n-.5)/.3,l=e.control;return Math.round(Math.min(l.range[1],Math.max(0,c*e.dose))*10)/10}function Pv({b:e,pad:t,width:n,font:r,blocked:i,preview:a}){let o=bv.value.filter(e=>e.at);if(!o.length||!n)return null;let s=kv(o,n,r+6),c=Av(o,s,e.values,n,r,i),l=(e,n)=>{let r=Ov(e),[i,a]={ArrowRight:[1,0],ArrowLeft:[-1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[n],s=null,c=1/0;for(let t of o){if(t===e)continue;let n=Ov(t),o=(n.x-r.x)*i+(n.y-r.y)*a;if(o<=1e-6)continue;let l=o+2*Math.abs((n.x-r.x)*a-(n.y-r.y)*i);l{r.stopPropagation(),r.currentTarget.focus();let a=null,o=!1;Lg(r,(t,r)=>{if(!a)return void(a=[t,r]);!o&&Math.hypot(t-a[0],r-a[1])<.025||(o||(o=!0,e.begin()),e.set(n.control.id,Nv(n,t,r)))},()=>{o?e.end():i&&Tv(e,n)},t.current??void 0)},d=o.filter(t=>(e.values[t.control.id]??0)>0);return G(A,{children:[G(`svg`,{class:`mlm-rays`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[o.map(e=>{let t=Ov(e),r=s.get(e.control.id);return Math.hypot(t.x-r.x,t.y-r.y)*n>2?G(`line`,{x1:t.x*100,y1:t.y*100,x2:r.x*100,y2:r.y*100,class:`mlm-leader`,"vector-effect":`non-scaling-stroke`}):null}),d.map(e=>{let{x:t,y:n}=Ov(e),r=Mv(t-.5,n-.5),i=Math.min(r,e.control.safe[1]/e.dose);return G(`g`,{children:[G(`line`,{x1:`50`,y1:`50`,x2:50+(t-.5)*100*i,y2:50+(n-.5)*100*i,class:`mlm-ray`,"vector-effect":`non-scaling-stroke`}),i{let n=e.values[t.control.id]??0,{x:r,y:i}=s.get(t.control.id),o=c.get(t.control.id)??`hidden`;return a?G(`span`,{class:`mlm is-preview side-${o}${n>0?` is-on zone-${Wt(t.control,n)}`:``}`,style:{left:`${r*100}%`,top:`${i*100}%`,"--glow":Math.min(1.4,n/t.dose)},"aria-hidden":`true`,children:[G(`span`,{class:`mlm-dot`}),G(`span`,{class:`mlm-label`,children:[t.label,n>0&&G(`b`,{class:`mlm-dose`,children:[` `,Sv(n)]})]})]}):G(`button`,{"data-mood":t.control.id,class:`mlm side-${o}${n>0?` is-on zone-${Wt(t.control,n)}`:``}`,style:{left:`${r*100}%`,top:`${i*100}%`,"--glow":Math.min(1.4,n/t.dose)},"aria-pressed":n>0,"aria-label":`${t.label}${n>0?`, ${Sv(n)}`:``}`,title:wv(t,n),onPointerDown:e=>u(t,e,!0),onClick:n=>n.detail===0&&Tv(e,t),onKeyDown:r=>{if(r.key.startsWith(`Arrow`))return void(r.preventDefault(),r.stopPropagation(),l(t,r.key));let i=r.key===`+`||r.key===`=`||r.key===`]`?.5:r.key===`-`||r.key===`[`?-.5:0;i?(r.preventDefault(),r.stopPropagation(),e.begin(),e.set(t.control.id,Math.min(t.control.range[1],Math.max(0,Math.round((n+i)*10)/10))),e.end()):(r.key===`Delete`||r.key===`Backspace`)&&(r.preventDefault(),r.stopPropagation(),n&&(e.begin(),e.set(t.control.id,0),e.end()))},children:[G(`span`,{class:`mlm-dot`}),G(`span`,{class:`mlm-label`,children:[t.label,n>0&&G(`b`,{class:`mlm-dose`,children:[` `,Sv(n)]})]})]})}),d.map(t=>{let r=e.values[t.control.id]??0,{x:i,y:a}=Ov(t),o=Math.min(r/t.dose,Mv(i-.5,a-.5)),c=.5+(i-.5)*o,l=.5+(a-.5)*o,d=s.get(t.control.id);return Math.hypot(c-d.x,l-d.y)*n<9?null:G(`span`,{class:`mlm-handle zone-${Wt(t.control,r)}`,style:{left:`${c*100}%`,top:`${l*100}%`},title:`${t.label} ${Sv(r)}: drag along the line for strength`,onPointerDown:e=>u(t,e,!1),children:G(`span`,{class:`mlm-handle-tag`,children:Sv(r)})})})]})}var Fv={phone:`M7 3h4l1 5-2.5 1.5a11 11 0 0 0 5 5L16 12l5 1v4a2 2 0 0 1-2 2A16 16 0 0 1 5 5a2 2 0 0 1 2-2z`,podcast:`M12 3a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM6 11a6 6 0 0 0 12 0M12 17v4M9 21h6`,studio:`M4 9v6M8 6v12M12 3v18M16 7v10M20 10v4`};function Iv({b:e,large:t}){let n=R.value.ui.controls.find(e=>e.group===`room`);if(!n)return null;let r=Da(`room`),i=e.values[n.id]??0,[a,o]=n.range,s=nn(n),c=s.reduce((e,t)=>Math.abs(t.at-i)G(`button`,{class:`room-scene${Math.abs(c.at-i)<.6&&c.id===r.id?` is-on`:``}`,style:{left:`${(r.at-a)/(o-a)*100}%`},onClick:()=>(e.begin(),e.set(n.id,r.at),e.end()),title:`${r.label} (${r.at>0?`+`:``}${r.at})`,children:[G(`svg`,{viewBox:`0 0 24 24`,width:t?34:18,height:t?34:18,"aria-hidden":`true`,children:G(`path`,{d:Fv[r.id],fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})}),G(`span`,{class:`room-scene-label`,children:r.label}),t&&G(`span`,{class:`room-scene-at`,children:[r.at>0?`+`:``,r.at]})]}))}),t?G(_v,{control:n,value:i,color:r,label:`Room`,detailed:!0,onStart:e.begin,onChange:t=>e.set(n.id,t),onEnd:e.end}):G(_v,{control:n,value:i,color:r,label:`Room`,bare:!0,onStart:e.begin,onChange:t=>e.set(n.id,t),onEnd:e.end}),!t&&G(`div`,{class:`room-read`,children:[G(`span`,{children:n.poles?.[0]??`phone`}),G(`b`,{children:[i>0?`+`:``,i.toFixed(1)]}),G(`span`,{children:n.poles?.[1]??`studio`})]})]})}function Lv({group:e,b:t,only:n,compact:r,detailed:i}){let a=Da(e),o=R.value.ui.controls.filter(t=>t.group===e&&!t.span_only&&(!n||n(t)));return G(`div`,{class:`slider-group${i?` is-detailed`:``}`,children:o.map(e=>G(_v,{control:e,value:t.values[e.id]??0,color:a,compact:r,detailed:i,onStart:t.begin,onChange:n=>t.set(e.id,n),onEnd:t.end},e.id))})}function Rv({b:e,compact:t,large:n,padOpens:r}){let i=yv.value,a=i?.x,o=i?.y,s=bv.value,c=N(null),l=jv(c),u=Da(`mood`),d=a?e.values[a.id]??0:0,f=o?e.values[o.id]??0:0,p=a?(d-a.range[0])/(a.range[1]-a.range[0])*100:50,m=o?(1-(f-o.range[0])/(o.range[1]-o.range[0]))*100:50,h=a?Wt(a,d):`safe`,g=o?Wt(o,f):`safe`,_=a&&o&&{left:`${(a.safe[0]-a.range[0])/(a.range[1]-a.range[0])*100}%`,width:`${(a.safe[1]-a.safe[0])/(a.range[1]-a.range[0])*100}%`,top:`${(1-(o.safe[1]-o.range[0])/(o.range[1]-o.range[0]))*100}%`,height:`${(o.safe[1]-o.safe[0])/(o.range[1]-o.range[0])*100}%`},v=s.some(e=>e.at),y=n||!v,b=n?12:11,x=y&&l?[0,1].flatMap(e=>[0,1].map(t=>({x:e?l-64:0,y:t?l-20:0,w:64,h:20}))):[];n&&l&&x.push({x:0,y:l/2-24,w:70,h:20},{x:l-70,y:l/2-24,w:70,h:20});let S=s.filter(t=>(e.values[t.control.id]??0)>0),C=t=>Tv(e,t);return G(`div`,{class:`mood${t?` is-compact`:``}${n?` is-large`:``}${v?` has-landmarks`:``}${r?` pad-opens`:``}`,style:{"--fam":u},children:[a&&o&&G(`div`,{ref:c,class:`mood-pad zone-${h===`safe`&&g===`safe`?`safe`:`strong`}`,role:`group`,"aria-label":`Mood pad: ${a.label} (x) and ${o.label} (y)${v?`, with measured moods as landmarks`:``}`,inert:r?!0:void 0,onDblClick:t=>!t.target.closest(`.mlm, .mlm-handle`)&&(e.begin(),e.set(a.id,0),e.set(o.id,0),e.end()),onPointerDown:t=>{t.detail===2||t.target.closest(`.mlm, .mlm-handle`)||(e.begin(),Lg(t,(t,n)=>{e.set(a.id,Math.round((a.range[0]+P(t,0,1)*(a.range[1]-a.range[0]))*10)/10),e.set(o.id,Math.round((o.range[1]-P(n,0,1)*(o.range[1]-o.range[0]))*10)/10)},e.end))},children:[_&&G(`div`,{class:`mood-safe`,style:_}),y&&G(A,{children:[G(`span`,{class:`q q-tl`,children:`tense`}),G(`span`,{class:`q q-tr`,children:`excited`}),G(`span`,{class:`q q-bl`,children:`low`}),G(`span`,{class:`q q-br`,children:`content`})]}),G(`span`,{class:`mood-axis-x`}),G(`span`,{class:`mood-axis-y`}),G(Pv,{b:e,pad:c,width:l,font:b,blocked:x,preview:r}),G(`span`,{class:`mood-dot`,style:{left:`${p}%`,top:`${m}%`},role:`slider`,tabIndex:0,"aria-label":`${a.label} (x) and ${o.label} (y)`,"aria-valuetext":`${a.label} ${d.toFixed(1)}, ${o.label} ${f.toFixed(1)}`,title:`${a.label} × ${o.label}: drag anywhere on the pad, arrow keys to nudge, 0 or Delete to reset. Double-click the pad to reset.`,onKeyDown:t=>{if(t.key===`0`||t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),e.begin(),e.set(a.id,0),e.set(o.id,0),e.end();return}let n=t.shiftKey?1:.25,r=t.key===`ArrowRight`?n:t.key===`ArrowLeft`?-n:0,i=t.key===`ArrowUp`?n:t.key===`ArrowDown`?-n:0;(r||i)&&(t.preventDefault(),e.begin(),e.set(a.id,d+r),e.set(o.id,f+i),e.end())}}),n&&G(A,{children:[G(`span`,{class:`mp mp-l`,children:a.poles?.[0]??`−`}),G(`span`,{class:`mp mp-r`,children:a.poles?.[1]??`+`})]})]}),n?G(`div`,{class:`mood-detail`,children:[[a,o].filter(e=>!!e).map(t=>G(_v,{control:t,value:e.values[t.id]??0,color:u,detailed:!0,onStart:e.begin,onChange:n=>e.set(t.id,n),onEnd:e.end},t.id)),G(`h4`,{class:`eyebrow`,children:`Moods`}),G(Dv,{values:e.values,onPick:C}),S.length>0&&G(`h4`,{class:`eyebrow`,children:[`Strength`,S.length>1?` · the doses add up`:``]}),S.map(t=>G(_v,{control:t.control,value:e.values[t.control.id]??0,color:u,detailed:!0,onStart:e.begin,onChange:n=>e.set(t.control.id,n),onEnd:e.end},t.control.id)),v&&G(`p`,{class:`hint`,children:`Landmarks sit where each mood measured at its default dose. Click one to add it, click again to remove; drag it or its handle along the line for strength. Arrow keys move between moods, + / − change the dose.`})]}):G(A,{children:[G(Dv,{values:e.values,onPick:C}),t&&G(`p`,{class:`hint mood-hint`,children:r?`Click the pad to open the mood controls`:`Dot = overall tone · chips add named moods`})]}),!t&&!n&&a&&o&&G(`p`,{class:`hint`,children:[a.label,` `,d.toFixed(1),` · `,o.label,` `,f.toFixed(1)]})]})}var zv=320,Bv=zv/2,Vv=112;function Hv({large:e}){let t=R.value.ui.controls.filter(e=>e.group===`texture`),n=N(null),[r,i]=j(null),a=Da(`texture`),o=W.value.values,s=t.length;if(!s)return null;let c=e=>-Math.PI/2+e/s*Math.PI*2,l=(e,t)=>[Bv+Math.cos(c(e))*Vv*t,Bv+Math.sin(c(e))*Vv*t],u=e=>P((o[t[e].id]??0)/t[e].range[1],0,1),d=t.map((e,t)=>l(t,u(t)).map(e=>e.toFixed(1)).join(`,`)).join(` `),f=(e,r)=>{let a=n.current.getBoundingClientRect(),o=(e.clientX-a.left)/a.width*zv-Bv,s=(e.clientY-a.top)/a.height*zv-Bv,l=r;if(l===void 0){let e=Math.atan2(s,o),n=0,r=9;t.forEach((t,i)=>{let a=Math.abs(Math.atan2(Math.sin(e-c(i)),Math.cos(e-c(i))));a{let n=e*zv-Bv,r=t*zv-Bv,i=n*Math.cos(c(l))+r*Math.sin(c(l));el(u.id,Math.round(P(i/Vv,0,1)*u.range[1]*10)/10)},()=>U.end(),n.current)},p=[.25,.5,.75,1],m=t.map((e,t)=>l(t,P(e.safe[1]/e.range[1],0,1)).join(`,`)).join(` `);return G(`div`,{class:`radar${e?` is-large`:``}`,style:{"--fam":a},children:[G(`svg`,{ref:n,class:`radar-svg`,viewBox:`0 0 ${zv} ${zv}`,onPointerDown:e=>f(e),"aria-hidden":`true`,children:[p.map(e=>G(`circle`,{class:`radar-ring`,cx:Bv,cy:Bv,r:Vv*e})),G(`polygon`,{class:`radar-safe`,points:m}),t.map((t,n)=>{let[i,a]=l(n,1),[s,c]=l(n,1.2),u=o[t.id]??0,d=P(t.safe[1]/t.range[1],0,1),f=t.collapse?.[1]==null?1:P(t.collapse[1]/t.range[1],0,1),[p,m]=l(n,d),[h,g]=l(n,f);return G(`g`,{children:[G(`line`,{class:`radar-spoke`,x1:Bv,y1:Bv,x2:i,y2:a}),e&&G(A,{children:[G(`line`,{class:`spoke-safe`,x1:Bv,y1:Bv,x2:p,y2:m}),G(`line`,{class:`spoke-strong`,x1:p,y1:m,x2:h,y2:g}),f<1&&G(`line`,{class:`spoke-collapse`,x1:h,y1:g,x2:i,y2:a})]}),G(`text`,{class:`radar-label${r===t.id?` is-on`:``}`,x:s,y:c+4,children:[t.label,e&&G(`tspan`,{class:`radar-value zone-${Wt(t,u)}`,children:` ${u.toFixed(1)}`})]})]})}),G(`polygon`,{class:`radar-shape`,points:d}),t.map((e,t)=>{let[n,r]=l(t,u(t));return G(`circle`,{class:`radar-handle zone-${Wt(e,o[e.id]??0)}`,cx:n,cy:r,r:`7`,onPointerDown:e=>(e.stopPropagation(),f(e,t))})})]}),e&&G(`div`,{class:`radar-detail`,children:t.map(e=>G(`div`,{class:`radar-row${r===e.id?` is-on`:``}`,onFocusIn:()=>i(e.id),onPointerEnter:()=>i(e.id),children:G(_v,{control:e,value:o[e.id]??0,color:a,detailed:!0,onStart:()=>U.begin(),onChange:t=>el(e.id,t),onEnd:()=>U.end()})}))})]})}var Uv=420,Wv=420,Gv=42,Kv=12,qv=6.3,Jv=`pitch`;function Yv(e,t,n){let r=R.value,i=W.value,a=(n,a)=>$t(r,{...i.values,[e]:n,[t]:a},qc.value,i.mode);if(a(0,0)=n)r=i;else for(let e=0;e<22;e++){let e=(r+i)/2;a(e*Math.cos(t),e*Math.sin(t))>=n?r=e:i=e}o.push([r*Math.cos(t),r*Math.sin(t)])}return o}var Xv=(e,t)=>e.x({x:e.x-5,y:e.y-5,w:10,h:10}));for(let i of e){let e=i.text.length*qv,a=i.x0?`start`:`end`,box:{x:a>0?i.x+8:i.x-8-e,y:i.y-7,w:e,h:13}},{dx:-9*a,dy:4,anchor:a>0?`end`:`start`,box:{x:a>0?i.x-8-e:i.x+8,y:i.y-7,w:e,h:13}},{dx:0,dy:-10,anchor:`middle`,box:{x:i.x-e/2,y:i.y-20,w:e,h:13}},{dx:0,dy:17,anchor:`middle`,box:{x:i.x-e/2,y:i.y+6,w:e,h:13}}].find(e=>e.box.x>=Gv&&e.box.x+e.box.w<=408&&e.box.y>=Kv&&e.box.y+e.box.h<=394&&!t.some(t=>Xv(t,e.box))&&!r.some(t=>Xv(t,e.box)));o&&t.push(o.box),n.set(i.id,o?{dx:o.dx,dy:o.dy,anchor:o.anchor}:null)}return n}function Qv({large:e}){let t=N(null),n=Um.value,r=Ta.value.get(n.gender.control),i=Ta.value.get(n.age.control),a=Ta.value.get(Jv),o=W.value,s=Da(`who`);if(M(()=>{let e=t.current;if(!e||!a)return;let n=0,r=t=>{if(t.deltaY===0||document.activeElement!==e&&!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),U.begin();let r=.1*P(Math.abs(t.deltaY)/50,.5,3);el(a.id,(W.value.values[a.id]??0)+(t.deltaY<0?r:-r)),clearTimeout(n),n=window.setTimeout(()=>U.end(),400)};return e.addEventListener(`wheel`,r,{passive:!1}),()=>e.removeEventListener(`wheel`,r)},[a]),!r||!i)return G(`p`,{class:`muted`,children:`This voice bundle has no gender / age controls.`});let{x:[c,l],y:[u,d]}=Zm.value,f=e=>Gv+(e-c)/(l-c)*366,p=e=>Kv+(d-e)/(d-u)*382,m=e=>P(e,c,l),h=e=>P(e,u,d),g=qm(Xc.value),_=o.values[r.id]??0,v=o.values[i.id]??0,y=g.x+_,b=g.y+v,x=yl||bd,S=R.value.ui.identity_threshold??.8,C=Yv(r.id,i.id,S),w=en(Yc.value,S),T=w===`New person`,E=H.value.filter(e=>e.id!==o.baseId).map(e=>({s:e,spot:qm(e)})).filter(e=>e.spot.measured||e.spot.from),D=Xc.value?.label??`base`,O=[{x:f(m(g.x))-D.length*qv/2,y:p(h(g.y))-24,w:D.length*qv,h:13}],ee=Zv(E.map(e=>({id:e.s.id,x:f(m(e.spot.x)),y:p(h(e.spot.y)),text:e.s.label})),O),te=(e,t)=>{let n=c+(e*Uv-Gv)/366*(l-c),a=d-(t*Wv-Kv)/382*(d-u),o=W.value;U.set({...o,values:{...o.values,[r.id]:Math.round(P(n-g.x,r.range[0],r.range[1])*20)/20,[i.id]:Math.round(P(a-g.y,i.range[0],i.range[1])*20)/20}})},ne=e=>{let t=e.shiftKey?.5:.1,n=e.key===`ArrowRight`?t:e.key===`ArrowLeft`?-t:0,a=e.key===`ArrowUp`?t:e.key===`ArrowDown`?-t:0,o=e.key===`0`||e.key===`Delete`||e.key===`Backspace`;(n||a||o)&&(e.preventDefault(),U.begin(),el(r.id,o?0:_+n),el(i.id,o?0:v+a),U.end())},re=[];for(let e=Math.ceil(Jm(u)/10)*10;e<=Jm(d);e+=10)re.push(e);let ie=[.1,.5,.9].map(e=>({p:e,x:Math.log(e/(1-e))/n.gender.logit_per_dose})),ae={x:[g.x+r.safe[0],g.x+r.safe[1]],y:[g.y+i.safe[0],g.y+i.safe[1]]},oe=Math.round(Jm(b)),k=Xm(y);return G(`div`,{class:`who${e?` is-large`:``}`,style:{"--fam":s},children:[G(`div`,{class:`who-main`,children:[G(`svg`,{ref:t,class:`who-map${T?` is-outside`:``}`,viewBox:`0 0 ${Uv} ${Wv}`,role:`slider`,tabIndex:0,"aria-label":`Who map: masculine to feminine (x), age in years (y). Arrow keys move; scroll while focused (or with ⌘ / Ctrl) changes pitch.`,"aria-valuetext":`${r.label} ${_.toFixed(1)}, ${i.label} ${v.toFixed(1)} (about ${oe} years)`,onKeyDown:ne,onPointerDown:e=>{e.target.closest(`.landmark`)||(U.begin(),Lg(e,te,()=>U.end(),t.current))},children:[G(`rect`,{class:`who-bg`,x:Gv,y:Kv,width:366,height:382,rx:`12`}),re.map(e=>G(`g`,{class:`tick`,children:[G(`line`,{class:`grid`,x1:Gv,x2:408,y1:p(Ym(e)),y2:p(Ym(e))}),G(`text`,{x:36,y:p(Ym(e))+4,"text-anchor":`end`,children:e})]})),ie.map(e=>G(`g`,{class:`tick`,children:G(`line`,{class:e.p===.5?`axis`:`grid`,x1:f(e.x),x2:f(e.x),y1:Kv,y2:394})})),G(`text`,{class:`pole`,x:48,y:412,children:[`← `,r.poles?.[0]??`masculine`]}),G(`text`,{class:`pole`,x:f(0),y:412,"text-anchor":`middle`,children:`neutral`}),G(`text`,{class:`pole`,x:402,y:412,"text-anchor":`end`,children:[r.poles?.[1]??`feminine`,` →`]}),G(`text`,{class:`pole axis-title`,x:9,y:14,transform:`rotate(-90 9 14)`,"text-anchor":`end`,children:`age (years)`}),G(`rect`,{class:`who-safe`,x:f(m(ae.x[0])),y:p(h(ae.y[1])),width:f(m(ae.x[1]))-f(m(ae.x[0])),height:p(h(ae.y[0]))-p(h(ae.y[1])),rx:`10`}),C&&G(`path`,{class:`identity-ring`,d:`M${C.map(([e,t])=>`${f(m(g.x+e)).toFixed(1)},${p(h(g.y+t)).toFixed(1)}`).join(`L`)}Z`}),E.map(({s:e,spot:t})=>{let n=ee.get(e.id),r=()=>il(e.id,`map`);return G(`g`,{class:`landmark${n?``:` is-quiet`}`,transform:`translate(${f(m(t.x))},${p(h(t.y))})`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r())},role:`button`,tabIndex:0,"aria-label":`Switch base voice to ${e.label}`,children:[G(`title`,{children:`${e.label}${t.measured?``:` (saved from `+t.from+`)`} — click to make it the base voice`}),G(`circle`,{class:`landmark-hit`,r:`14`}),G(`circle`,{r:`5`}),G(`text`,{x:n?.dx??9,y:n?.dy??4,"text-anchor":n?.anchor??`start`,children:e.label})]})}),G(`line`,{class:`who-tether`,x1:f(m(g.x)),y1:p(h(g.y)),x2:f(m(y)),y2:p(h(b))}),G(`g`,{class:`origin${g.measured?``:` is-unmeasured`}`,transform:`translate(${f(m(g.x))},${p(h(g.y))})`,children:[G(`circle`,{r:`7`}),G(`text`,{y:`-12`,children:D})]}),G(`g`,{class:`who-dot${x?` is-off`:``}`,transform:`translate(${f(m(y))},${p(h(b))})`,children:[G(`circle`,{class:`halo`,r:`16`}),G(`circle`,{r:`9`})]})]}),a&&G(`div`,{class:`who-rail`,children:[G(_v,{control:a,value:o.values[a.id]??0,color:s,vertical:!0,bare:!0,onStart:()=>U.begin(),onChange:e=>el(a.id,e),onEnd:()=>U.end()}),G(`span`,{class:`rail-label`,title:a.effect,children:[a.label,G(`br`,{}),G(`b`,{children:(o.values[a.id]??0).toFixed(1)})]})]})]}),G(`div`,{class:`who-status${T?` is-outside`:``}`,"aria-live":`polite`,title:`Identity estimate ${Yc.value.toFixed(2)} · P(female) ${k.toFixed(2)}${n.note?` · ${n.note}`:``}`,children:[T?G(`b`,{children:`New person`}):w===`Close`?G(`b`,{children:[`Close to `,D]}):G(`span`,{children:[`Still `,D]}),G(`span`,{children:[`≈`,oe,` years · `,tn(k)]}),(g.from||!g.measured)&&G(`span`,{class:`muted`,children:g.from?`placed from ${g.from} + its saved moves`:`position not measured: starts at the centre`})]}),R.value.ui.controls.filter(e=>e.group===`who`&&![r.id,i.id,`pitch`].includes(e.id)).map(e=>G(_v,{control:e,value:o.values[e.id]??0,color:s,compact:!0,onStart:()=>U.begin(),onChange:t=>el(e.id,t),onEnd:()=>U.end()},e.id))]})}var $v=e=>`${e>0?`+`:e<0?`−`:``}${Math.abs(e).toFixed(1)}`,ey=e=>Math.abs(e??0)>1e-6;function ty(){let e=Um.value,t=W.value,n=Ta.value.get(e.gender.control),r=Ta.value.get(e.age.control),i=Xc.value?.label??`Pick a voice`,a=qm(Xc.value),o=a.x+(n?t.values[n.id]??0:0),s=a.y+(r?t.values[r.id]??0:0),c=t.values.pitch??0,l=en(Yc.value,R.value.ui.identity_threshold??.8),u=l===`New person`;return G(`div`,{class:`tile-sum`,title:`Identity estimate ${Yc.value.toFixed(2)}${n&&r?` · P(female) ${Xm(o).toFixed(2)}`:``}`,children:[G(`b`,{class:`tile-main`,children:i}),n&&r&&G(A,{children:[G(`span`,{children:[`≈`,Math.round(Jm(s)),` years`]}),G(`span`,{children:tn(Xm(o))})]}),G(`span`,{class:u?`tile-warn`:`muted`,children:u?l:ey(c)?`pitch ${$v(c)}`:l})]})}function ny(){let e=R.value.ui.accents,t=Object.entries(qc.value).map(([t,n])=>({a:e.find(e=>e.id===t),v:n})).filter(e=>e.a&&e.v>0).sort((e,t)=>t.v-e.v),n=t[0];if(!n)return G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:`No accent`}),G(`span`,{class:`muted`,children:`pin at home`})]});let r=Wt(n.a,n.v)!==`safe`;return G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:n.a.label}),G(`span`,{class:r?`tile-warn`:void 0,children:[n.v.toFixed(2),r?` · strong`:``]}),t.length>1&&G(`span`,{class:`muted`,children:[`+ `,t.slice(1).map(e=>e.a.label).join(`, `)]})]})}function ry(){let e=R.value.ui.controls.find(e=>e.group===`room`);if(!e)return G(`span`,{class:`muted`,children:`No room control`});let t=W.value.values[e.id]??0,[n,r]=e.range,i=nn(e),a=i.reduce((e,n)=>Math.abs(n.at-t)t.group===`delivery`&&!t.span_only&&ey(e[t.id]));return t.length?G(`div`,{class:`tile-sum`,children:[t.slice(0,3).map(t=>G(`span`,{class:`tile-kv`,children:[G(`span`,{children:t.label}),G(`b`,{children:$v(e[t.id]??0)})]},t.id)),t.length>3&&G(`span`,{class:`muted`,children:[`+`,t.length-3,` more`]})]}):G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:`Neutral`}),G(`span`,{class:`muted`,children:`no delivery moves`})]})}function ay(){let e=W.value.values,t=yv.value,n=bv.value.filter(t=>(e[t.control.id]??0)>0),r=t=>((e[t.id]??0)-t.range[0])/(t.range[1]-t.range[0]);return G(`div`,{class:`tile-mood`,children:[t&&G(`span`,{class:`tile-pad`,"aria-hidden":`true`,children:G(`i`,{style:{left:`${r(t.x)*100}%`,top:`${(1-r(t.y))*100}%`}})}),G(`div`,{class:`tile-sum`,children:[n.length?n.slice(0,3).map(e=>G(`span`,{children:e.label},e.control.id)):t&&(ey(e[t.x.id])||ey(e[t.y.id]))?G(A,{children:[G(`span`,{children:[t.x.label,` `,$v(e[t.x.id]??0)]}),G(`span`,{children:[t.y.label,` `,$v(e[t.y.id]??0)]})]}):G(`b`,{class:`tile-main`,children:`Neutral`}),n.length>3&&G(`span`,{class:`muted`,children:[`+`,n.length-3,` more`]})]})]})}var oy=()=>({values:W.value.values,begin:()=>U.begin(),set:el,end:()=>U.end()});function sy(){let e=Yc.value,t=R.value.ui.identity_threshold??.8;if(W.value.mode===`reference`)return G(`div`,{class:`identity-meter`,title:`Keep as is sends the recording itself: the identity is the recording's`,children:[G(`span`,{class:`eyebrow`,children:`identity`}),G(`span`,{class:`identity-caption`,children:`Same person (the recording)`})]});let n=en(e,t);return G(`div`,{class:`identity-meter${n===`New person`?` is-new`:``}`,title:`Identity estimate ${e.toFixed(2)} · below ${t.toFixed(2)} reads as a different person. Product of each control’s measured identity curve: an estimate, not a measurement.`,children:[G(`span`,{class:`eyebrow`,children:`identity`}),G(`div`,{class:`meter`,children:[G(`div`,{class:`meter-fill`,style:{width:`${e*100}%`}}),G(`div`,{class:`meter-mark`,style:{left:`${t*100}%`}})]}),G(`span`,{class:`identity-caption`,children:G(`b`,{children:n})})]})}function cy(e){if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=[...e.currentTarget.querySelectorAll(`[role="radio"]:not([disabled])`)],n=t.indexOf(document.activeElement);if(n<0||t.length<2)return;e.preventDefault();let r=t[(n+(e.key===`ArrowRight`?1:t.length-1))%t.length];r.focus(),r.click()}function ly(){return Og.value?G(`button`,{class:`icon-btn`,"aria-label":`Save this voice`,title:`Save this voice`,onClick:()=>{Ng(`cast-monitor`),requestAnimationFrame(()=>{let e=document.getElementById(`rail-cast-monitor`);e&&Af(e,`.save-panel`)})},children:G(K,{name:`save`,size:16})}):null}function uy(){let e=W.value.mode===`reference`;return G(`div`,{class:`bench-head`,id:`bench-head`,children:[G(`div`,{class:`bench-title`,children:[G(`span`,{class:`eyebrow`,children:`Shape the voice`}),G(`h2`,{title:Xc.value?.label,children:Xc.value?.label??`Pick a voice`})]}),G(`div`,{class:`mode-wrap`,children:[G(`div`,{class:`mode`,role:`radiogroup`,"aria-label":`Voice mode`,onKeyDown:cy,children:[G(`button`,{role:`radio`,"aria-checked":!e,class:`mode-btn${e?``:` is-on`}`,onClick:()=>ol(`embedding`),title:`Shape it: who, accent and texture change the person`,children:`Shape it`}),G(`button`,{role:`radio`,"aria-checked":e,class:`mode-btn${e?` is-on`:``}`,disabled:!$c.value,onClick:()=>ol(`reference`),title:$c.value?`Keep as is: the recording itself; only delivery and mood change`:`This voice was saved without a recording, so there is nothing to keep as is`,children:`Keep as is`})]}),!$c.value&&G(`span`,{class:`hint`,children:`Keep as is needs a recording; this voice was saved without one.`})]}),G(sy,{}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn`,onClick:cl,title:`A random new person: base voice, who, a touch of texture or room (delivery and mood stay as they are)`,children:[G(K,{name:`dice`,size:14}),` Roll a voice`]}),G(`button`,{class:`icon-btn`,onClick:ll,title:e?`Reset delivery and mood (Who, Accent, Texture and Room are kept for Shape it)`:`Reset: back to the plain base voice`,"aria-label":`Reset the controls`,children:G(K,{name:`refresh`,size:16})}),G(ly,{})]})]})}var dy={who:`Who`,accent:`Accent`,texture:`Texture`,room:`Room`,delivery:`Delivery`,mood:`Mood`},fy=[`who`,`accent`,`texture`,`room`],py=G(A,{children:[G(`b`,{children:`Keep as is copies the recording.`}),G(`span`,{children:`Delivery and mood still work; Who, Accent, Texture and Room don’t. Switch to Shape it to change them; your moves here are kept.`}),G(`button`,{class:`btn sm`,onClick:()=>ol(`embedding`),children:`Switch to Shape it`})]}),my=G(`button`,{class:`link`,onClick:()=>document.getElementById(`bench-head`)?.scrollIntoView({block:`center`,behavior:`smooth`}),children:[G(`b`,{children:`Keep as is`}),` · change`]});function hy(){let e=!!Fl.value.a||zc.value.length>0,t=N(e);return M(()=>{e&&!t.current&&Ng(`cast-monitor`),t.current=e},[e]),e}function gy(){let e=hy();M(()=>(ja.value=U,Fa.value=ru,()=>{ja.value=null,Fa.value=null}),[]);let t=oy(),n=Og.value,r=W.value.mode===`reference`?py:void 0,[i,a]=j(null),o=e=>(t,n)=>a({id:e,card:t,returnTo:n});M(()=>{i&&r&&fy.includes(i.id)&&a(null)},[!!r]);let s=(e,t,n=!0)=>{let i=n&&r?my:void 0;return G(Eg,{family:e,title:dy[e],class:`cast-tile`,locked:i,onExpand:i?void 0:o(e),whole:!0,children:t})};return G(`div`,{class:`cast`,children:[G(Pg,{id:`cast-library`,side:`left`,title:`Voices`,children:G(pv,{})}),G(`section`,{class:`bench`,"aria-label":`Voice bench`,children:[G(Ig,{children:[G(Fg,{id:`cast-library`,title:`Voices`,icon:`mic`}),G(Fg,{id:`cast-monitor`,title:`More`,icon:`sliders`})]}),G(Y_,{}),n?G(A,{children:[G(uy,{}),G(`div`,{class:`cast-tiles`,children:[s(`who`,G(ty,{})),s(`accent`,G(ny,{})),s(`texture`,G(Hv,{})),s(`room`,G(ry,{})),s(`delivery`,G(iy,{}),!1),s(`mood`,G(ay,{}),!1)]})]}):G(A,{children:[G(uy,{}),G(`div`,{class:`hero`,children:[G(Eg,{family:`who`,title:`Who`,locked:r,onExpand:r?void 0:o(`who`),aside:G(`span`,{class:`hint`,title:`Drag the dot to move gender / age; scroll while the map has focus (or with ⌘ / Ctrl) for pitch; click a voice to start from it`,children:`drag the dot · scroll for pitch`}),children:G(Qv,{})}),G(Eg,{family:`accent`,title:`Accent`,locked:r,onExpand:r?void 0:o(`accent`),aside:G(`span`,{class:`hint`,children:`drag into a region · deeper = stronger`}),children:G(zg,{})})]}),G(`div`,{class:`strip`,children:[G(Eg,{family:`texture`,title:`Texture`,locked:r,onExpand:r?void 0:o(`texture`),whole:!0,children:G(Hv,{})}),G(Eg,{family:`room`,title:`Room`,locked:r,onExpand:r?void 0:o(`room`),children:G(Iv,{b:t})}),G(Eg,{family:`delivery`,title:`Delivery`,onExpand:o(`delivery`),children:G(Lv,{group:`delivery`,b:t,compact:!0})}),G(Eg,{family:`mood`,title:`Mood`,onExpand:o(`mood`),children:G(Rv,{b:t,compact:!0,padOpens:!0})})]})]})]}),G(Pg,{id:`cast-monitor`,side:`right`,title:`More`,defaultFolded:!e,children:G(`aside`,{class:`monitor`,"aria-label":`Monitor`,children:G(`div`,{class:`monitor-scroll`,children:[G(Z_,{}),G(nv,{}),G(iv,{})]})})}),i&&G(wg,{family:i.id,title:dy[i.id],origin:i.card,returnFocus:i.returnTo,onClose:()=>a(null),aside:G(sy,{}),strip:G(G_,{}),children:i.id===`who`?G(Qv,{large:!0}):i.id===`accent`?G(zg,{large:!0}):i.id===`texture`?G(Hv,{large:!0}):i.id===`room`?G(Iv,{b:t,large:!0}):i.id===`delivery`?G(Lv,{group:`delivery`,b:t,detailed:!0}):G(Rv,{b:t,large:!0})},i.id)]})}var _y=/^(checkbox|radio|range|button|submit|reset|file|color)$/i;function vy(e){let t=e;return!t||typeof t.tagName!=`string`?!1:t.isContentEditable||t.tagName===`TEXTAREA`||t.tagName===`SELECT`?!0:t.tagName===`INPUT`&&!_y.test(t.type)}var yy=`script`,by=[`chatty`,`arousal`,`pace`],xy={chatty:`Read ↔ chatty`,arousal:`Energy`,pace:`Pace`},Sy=[`var(--c1)`,`var(--c2)`,`var(--c6)`,`var(--c3)`,`var(--c5)`,`var(--c4)`];function Cy(e){if(!e)return`var(--text-3)`;let t=q.value.voiceColors?.[e];if(t)return t;let n=new Set(Object.values(q.value.voiceColors??{}));return Sy.find(e=>!n.has(e))??Sy[Object.keys(q.value.voiceColors??{}).length%Sy.length]}na(()=>{let e=q.value,t=new Set;e.voice&&t.add(e.voice);for(let n of e.lines)n.voice&&t.add(n.voice);for(let n of t)e.voiceColors?.[n]||Yd(n,Cy(n))});var wy=e=>e?zc.value.find(t=>t.id===e)?.name??`(removed voice)`:H.value.find(e=>e.id===W.value.baseId)?.label??`Voice`,Ty=F(null);function Ey(){let e=Df();if(!e)return z(`Render some lines first: each line’s keeper plays in order.`);let t=gf.value.filter(e=>!e.take).length;t&&z(`${t} line${t===1?``:`s`} without a take ${t===1?`is`:`are`} skipped`),Ks(yy,e.pcm,e.sr)}function Dy(){let e=Df();if(!e)return z(`Nothing rendered yet.`);mn(e.pcm,e.sr,p(Z.value?.name??`script`));let t=gf.value.filter(e=>!e.take).length;t&&z(`Exported ${gf.value.length-t} lines; ${t} without a take were skipped.`)}function Oy(e){let t=q.value.gap,n=0;for(let r of Ef.value.clips)if(r.take){if(r.line.id===e)return n;n+=r.duration+t}return null}function ky(){if(B.value?.id!==yy)return null;let e=Ms.value,t=q.value.gap,n=0;for(let r of Ef.value.clips)if(r.take){if(e{let e=ky()?.lineId??null;Md.peek()!==e&&(Md.value=e)});function Ay(){let e={id:It(),name:wy(null),design:structuredClone(W.value),signature:``,createdAt:Date.now()};Bc(e),z(`Added ${e.name} to the cast`,`ok`)}function jy(e){let t=new Set;for(let[n,r]of Object.entries(e)){let e=Ta.value.get(n);e&&r&&t.add(e.group)}if(t.size)return[...t].map((e,t)=>`linear-gradient(${Da(e)}, ${Da(e)}) 0 calc(100% - ${t*4}px) / 100% 2px no-repeat`).join(`, `)}function My(e,t,n){let r=e=>/[\p{L}\p{N}'’]/u.test(e),i=t,a=n;for(;i>0&&r(e[i-1])&&r(e[i]??``);)i--;for(;a{let r=(t.nodeType===Node.TEXT_NODE?t.parentElement:t)?.closest(`[data-start]`);return r?r.dataset.end?Number(n?r.dataset.end:r.dataset.start):Number(r.dataset.start)+(t.nodeType===Node.TEXT_NODE?n:0):t===e&&n?2**53-1:0},i=r(n.startContainer,n.startOffset),a=r(n.endContainer,n.endOffset);return{start:Math.min(i,a),end:Math.max(i,a),rect:n.getBoundingClientRect()}}function Fy({line:e}){let t=N(null),n=new Set([0,e.text.length]);for(let t of e.spans)n.add(t.start),n.add(t.end);let r=Ca.value?Sn(e.text,Ca.value).groups.filter(e=>!e.empty):[];for(let e of r)n.add(e.start),n.add(e.end);let i=T_.value?Nn(e.text):null;for(let e of i?.tokens??[])n.add(e.start),n.add(e.end);let a=(t,n,r)=>Rd(e.id,e.text.slice(0,t)+r+e.text.slice(n)),o=[...n].sort((e,t)=>e-t),s=Ty.value?.lineId===e.id?Ty.value:null,c=(t,n)=>{let[r,i]=My(e.text,t,Math.min(n,e.text.length));Ty.value={lineId:e.id,start:r,end:i}},l=e=>{let n=Py(t.current);n&&n.end>n.start?c(n.start,n.end):e||(Ty.value=null)};M(()=>{if(!s)return;let n=()=>{let n=Py(t.current);if(n&&n.end>n.start&&(n.start!==s.start||n.end!==s.end)){let[t,r]=My(e.text,n.start,Math.min(n.end,e.text.length));(t!==s.start||r!==s.end)&&(Ty.value={...s,start:t,end:r})}};return document.addEventListener(`selectionchange`,n),()=>document.removeEventListener(`selectionchange`,n)},[s?.lineId,s?.start,s?.end,e.text]);let[u,d]=j(null);M(()=>d(null),[e.text]);let f=Ny(e.text),p=e=>{d(e);let n=t.current,r=window.getSelection();if(!n||!r)return;if(!e)return r.removeAllRanges();let i=[...n.querySelectorAll(`.seg[data-start]`)].filter(e=>!e.dataset.end),a=e=>{for(let t of i){let n=Number(t.dataset.start),r=t.firstChild;if(!r||r.nodeType!==Node.TEXT_NODE)continue;let i=r.textContent?.length??0;if(e>=n&&e<=n+i)return{node:r,offset:e-n}}return null},o=a(e[0]),s=a(e[1]);if(!o||!s)return;let c=document.createRange();c.setStart(o.node,o.offset),c.setEnd(s.node,s.offset),r.removeAllRanges(),r.addRange(c)};return G(`div`,{ref:t,class:`line-text`,"data-line":e.id,tabIndex:0,"aria-label":`Line text: ${e.text}. Shift with the arrow keys selects words; Enter paints them.`,onMouseUp:()=>l(),onTouchEnd:()=>setTimeout(()=>l(!0),50),onKeyDown:e=>{if(e.target!==t.current||!f.length)return;if(e.key===`Escape`&&u){e.preventDefault(),p(null);return}if(e.key===`Enter`&&u){e.preventDefault(),c(u[0],u[1]);return}if(!e.shiftKey||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let n=f.findIndex(e=>u&&e[0]>=u[0]),r=u?f.findLastIndex(e=>e[1]<=u[1]):-1,i=u?n:e.key===`ArrowRight`?0:f.length-1,a=u?r:i;u&&(e.key===`ArrowRight`?a=Math.min(f.length-1,a+1):i=Math.max(0,i-1)),p([f[i][0],f[a][1]])},onBlur:()=>u&&d(null),children:o.slice(0,-1).map((t,n)=>{let l=o[n+1],u=i?.tokens.find(e=>e.start===t);if(u)return u.kind===`close`?G(`span`,{"data-start":t,"data-end":l,class:`seg tag-close`,"aria-hidden":`true`}):G(`span`,{"data-start":t,"data-end":l,class:`seg tag-inline${u.kind===`open`?` is-span`:``}${An[u.name].weak?` is-weak`:``}`,title:`<${u.name}${u.kind===`point`?`/`:``}>: ${An[u.name].note}`,children:u.kind===`open`?`‹${u.name}›`:u.name});let d=i?.spans.find(e=>t>=e.open.end&&tt>=e.start&&t=s.start&&l<=s.end,m=r.find(e=>t>=e.start&&t`${Ta.value.get(e)?.label??e} ${t>0?`+`:``}${t}`).join(` · `):``;return G(`span`,{"data-start":t,"data-ipa":m&&l===m.end?`${m.ipa}${h?` · check`:``}`:void 0,class:`seg${d?` tag-words is-${d.name}`:``}${f?` is-painted`:``}${p?` is-picked`:``}${m?` is-pron`:``}${m?.unknown.length?` is-pron-bad`:``}${h?` is-pron-check`:``}`,style:f?{background:jy(f.values)}:void 0,onClick:m?e=>{window.getSelection()?.isCollapsed&&(Ty.value=null,b_(e.currentTarget,m,a))}:f?()=>{window.getSelection()?.isCollapsed&&c(f.start,f.end)}:void 0,title:m?`(${m.body}) → ${m.ipa}${h?` · guessed for “${h}”, check it`:``}${m.unknown.length?` · no token for ${m.unknown.join(` `)}`:``} · click to edit${g?` · ${g}`:``}`:g||void 0,children:e.text.slice(t,l)})})})}function Iy(e){Ty.value={lineId:e.id,start:0,end:e.text.length}}function Ly(){let e=Ty.value,t=N(null),n=()=>Ty.value=null;if(M(()=>{if(!e)return;let n=e=>{!t.current?.contains(e.target)&&!e.target.closest?.(`.line-text`)&&(Ty.value=null)};return window.addEventListener(`pointerdown`,n),()=>window.removeEventListener(`pointerdown`,n)},[!!e]),M(()=>{if(!e)return;let n=e.lineId;return Ma.value=!0,Af(t.current,`.brushbar-body`),Og.value&&document.querySelector(`.line-text[data-line="${n}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`}),()=>{Ma.value=!1,document.querySelector(`.line-text[data-line="${n}"]`)?.focus({preventScroll:!0})}},[e?.lineId]),!e)return null;let r=q.value.lines.find(t=>t.id===e.lineId);if(!r)return null;let i=tf(r,e.start),a=new Set;for(let t=e.start+1;tEd.begin(),set:(t,n)=>{let i=Ta.value.get(t);i&&ef(r.id,e.start,e.end,t,Math.round(P(n,i.range[0],i.range[1])*100)/100)},end:()=>Ed.end()},s=wl(r.text,e.start,e.end),c=R.value.ui.controls.filter(e=>e.spannable&&e.group!==`mood`&&!(s&&e.span_only)),l=R.value.ui.controls.some(e=>e.spannable&&e.group===`mood`),u=R.value.ui.groups.filter(e=>R.value.ui.controls.some(t=>t.group===e.id&&t.spannable));return G(`div`,{ref:t,class:`brushbar${Og.value?``:` is-anchored`}`,role:`dialog`,"aria-modal":`true`,"aria-label":`Delivery brushes`,onKeyDown:jf(()=>t.current,n),children:[G(`header`,{children:[G(`span`,{class:`eyebrow`,children:[`Paint “`,r.text.slice(e.start,e.end),`”`]}),u_.value&&G(`button`,{class:`btn sm ghost`,disabled:h_.value,onClick:async()=>{let t=await g_(r.text,e.start,e.end);t!==null&&(Rd(r.id,t),Ty.value=null)},title:`Look up these words in the ${g(p_.value)} lexicon and write them as X-SAMPA pronunciations (undo: ⌘Z)`,children:`/ə/ Pronounce`}),T_.value&&G(`button`,{class:`btn sm ghost`,onClick:t=>{let n=t.currentTarget.getBoundingClientRect();Ty.value=null,k_(n,r.text,e.start,e.end,e=>Rd(r.id,e))},title:`A nonverbal tag: at the start of the selection, or around its words`,children:`‹› Tag`}),G(`button`,{class:`btn sm ghost`,onClick:()=>(Ed.begin(),ef(r.id,e.start,e.end,null,0),Ed.end()),title:`Remove every painted value from these words`,children:`Clear paint`}),G(`button`,{class:`icon-btn sm`,onClick:n,"aria-label":`Close brushes`,title:`Close (Esc)`,children:G(K,{name:`x`,size:14})})]}),G(`div`,{class:`legend brushbar-legend`,"aria-hidden":`true`,children:u.map(e=>G(`span`,{class:`legend-item`,children:[G(`i`,{style:{background:Da(e.id)}}),e.label]}))}),G(`div`,{class:`brushbar-body`,children:[G(`div`,{class:`brush-sliders`,children:c.map(e=>G(`div`,{class:a.has(e.id)?`slider-wrap is-mixed`:void 0,title:a.has(e.id)?`Mixed: these words carry different values; moving the slider sets them all`:void 0,children:G(_v,{control:e,value:i[e.id]??0,color:Da(e.group),label:a.has(e.id)?`${e.label} · mixed`:void 0,onStart:o.begin,onChange:t=>o.set(e.id,t),onEnd:o.end})},e.id))}),l&&G(Rv,{b:o,compact:!0})]})]})}var Ry=new Set;function zy({line:e}){let t=J.value[e.id]??[],n=t.filter(e=>!Ry.has(e.id)&&Date.now()-e.createdAt<3e3).map(e=>e.id);M(()=>{let e=t[t.length-1],r=e&&!Ry.has(e.id)&&n.includes(e.id);for(let e of t)Ry.add(e.id);r&&Al.value&&!cf.peek()&&!B.peek()&&Ks(`take:${e.id}`,e.audio.pcm,e.audio.sr)},[t.length]);let r=B.value?.id===`cmp:${e.id}`?Hy(e.id):null;if(!t.length)return null;let i=L.value?.decoders??[];return G(`ul`,{class:`takes`,"aria-label":`Takes`,children:[t.map((t,a)=>{let o=`take:${t.id}`,s=B.value?.id===o||r===t.id,c=bf(e,t),l=t.audio.decoder??t.request.decoder,u=l&&(i.length>1||l!==i[0]?.id)?`Decoder ${Ai(l)}`:null;return G(`li`,{class:`take${t.starred?` is-starred`:``}${c?` is-stale`:``}${n.includes(t.id)?` is-flash`:``}${s?` is-playing`:``}`,children:[G(`button`,{class:`take-play`,onClick:()=>Js(o,t.audio.pcm,t.audio.sr),"aria-label":`${s?`Stop`:`Play`} take ${a+1}`,title:[c?`Rendered before the ${c.replace(` changed`,``)} changed`:`Seed ${t.seed}`,u,t.audio.spanFollow?Uy[t.audio.spanFollow]:null].filter(Boolean).join(` · `),children:[G(`span`,{class:`take-n`,children:a+1}),G(s_,{pcm:t.audio.pcm,color:t.starred?`var(--o)`:`var(--text-2)`,playId:o,height:22})]}),c&&G(`span`,{class:`chip take-stale`,title:`The line changed since this take was rendered; Regenerate makes a fresh one`,children:c}),L_(t.request)&&G(`span`,{class:`take-follow is-tags`,title:`${L_(t.request)}: the server takes one guidance per render`,"aria-label":L_(t.request),children:`tags`}),G(`button`,{class:`icon-btn sm star${t.starred?` is-on`:``}`,onClick:()=>ff(e.id,t.id),"aria-label":`Make take ${a+1} the keeper`,"aria-pressed":t.starred,title:`Script plays this one`,children:G(K,{name:`star`,size:13,filled:t.starred})}),rp.value&&G(`button`,{class:`icon-btn sm`,onClick:()=>void xp({kind:`take`,label:`Line ${q.value.lines.indexOf(e)+1} · take ${a+1}`,lineId:e.id,takeId:t.id},t.audio.pcm,t.audio.sr,t.text),"aria-label":`Edit the words of take ${a+1}`,title:`Edit the words of this take (Edit screen)`,children:G(K,{name:`edit-speech`,size:12})}),G(`button`,{class:`icon-btn sm`,onClick:()=>{let n=pf(e.id,t.id);n&&z(`Take ${a+1} deleted`,`info`,{label:`Undo`,run:()=>mf(e.id,n.take,n.index,n.wasStarred)})},"aria-label":`Delete take ${a+1}`,title:`Delete this take`,children:G(K,{name:`x`,size:12})})]})}),t.length>1&&G(Wy,{lineId:e.id})]})}var By=.6;function Vy(e){let t=J.value[e]??[],n=t.find(e=>e.starred)??t[0],r=[...t].reverse().find(e=>e!==n);return n&&r?[n,r]:null}function Hy(e){let t=Vy(e);if(!t)return null;let[n,r]=t;return Ms.value{if(i)return Ws();let{pcm:e,sr:t}=pn([a.audio,o.audio],By);Ks(r,e,t)},title:`Play take ${t.indexOf(a)+1} (keeper) then take ${t.indexOf(o)+1}`,children:[G(K,{name:i?`stop`:`play`,size:12}),` Keeper vs take `,t.indexOf(o)+1]})})}function Gy(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}function Ky({line:e,n:t,count:n}){let r=Md.value===e.id,i=N(null),[a,o]=j(Zy.peek()===e.id),[s,c]=j(e.text),[l,u]=j(!1),d=Dd.value[e.id],f=Od.value[e.id],p=J.value[e.id]??[],m=p.find(e=>e.starred)??p[p.length-1],h=m?bf(e,m):null,g=!!h,_=Pd(e);M(()=>{a&&i.current&&(Gy(i.current),i.current.focus(),i.current.setSelectionRange(i.current.value.length,i.current.value.length))},[a]);let v=()=>{c(e.text),u(!1),o(!0)},y=(t,n=!1)=>{let r=Zy.peek()===e.id;if(r&&(Zy.value=null),n)r&&!e.text.trim()&&Ud(e.id),o(!1);else if(t.trim())t!==e.text&&Rd(e.id,t),o(!1);else{if(r||!e.text.trim())return Ud(e.id);u(!0)}};return G(`li`,{class:`line${r?` is-playing`:``}`,style:{"--voice":Cy(_)},children:[G(`span`,{class:`line-n`,children:t}),G(`div`,{class:`line-main`,children:[a?G(A,{children:[G(`div`,{class:`line-edit-row`,children:[G(`textarea`,{ref:i,class:`input line-edit`,rows:1,value:s,"data-tags":!0,placeholder:`What do they say?`,"aria-label":`Line ${t} text`,"aria-invalid":l||void 0,onInput:e=>{let t=e.currentTarget;c(t.value),t.value.trim()&&u(!1),Gy(t)},onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)?(e.preventDefault(),y(e.currentTarget.value)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y(``,!0))},onBlur:t=>{if(t.relatedTarget?.closest?.(`.tag-palette, .pron-editor`))return;let n=t.currentTarget.value;if(!n.trim()&&e.text.trim()&&Zy.peek()!==e.id)return y(``,!0);y(n)}}),G(v_,{input:()=>i.current}),G(M_,{input:()=>i.current})]}),G(`p`,{class:`hint line-edit-hint${l?` is-bad`:``}`,children:l?`Text can’t be empty — Esc to cancel or delete the line`:`Enter saves · Esc cancels`}),G(C_,{text:s}),G(P_,{text:s})]}):G(`div`,{onDblClick:v,children:[G(Fy,{line:e}),G(C_,{text:e.text,issuesOnly:!0}),G(P_,{text:e.text,replace:t=>Rd(e.id,t)})]}),G(zy,{line:e}),Ty.value?.lineId===e.id&&!Og.value&&G(Ly,{}),f&&G(`div`,{class:`error-line`,role:`alert`,children:c_(f)?`Not rendered: fix the pronunciation marked above.`:G(A,{children:[`Render failed: `,f,` `,G(`button`,{class:`link`,onClick:()=>void sf(e.id),children:`Retry`})]})})]}),G(`div`,{class:`line-actions`,children:[G(`select`,{class:`input line-voice`,value:e.voice??``,onChange:t=>qd(e.id,t.currentTarget.value||null),"aria-label":`Voice for line ${t}`,title:`Speaks as ${wy(_)}`,children:[G(`option`,{value:``,children:[`Default · `,wy(q.value.voice)]}),e.voice&&!zc.value.some(t=>t.id===e.voice)&&G(`option`,{value:e.voice,children:`(voice unavailable)`}),zc.value.map(e=>G(`option`,{value:e.id,children:e.name}))]}),G(`button`,{class:`btn sm${d?` is-busy`:``}${g?` is-stale`:``}`,onClick:()=>d?of(e.id):void sf(e.id),disabled:!d&&!e.text.trim(),title:d?`Stop rendering this line`:g?`The ${h.replace(` changed`,``)} changed since this take: render a fresh one`:p.length?`Render another take (new seed)`:`Render this line`,children:d?`Cancel`:g?G(A,{children:[G(K,{name:`refresh`,size:13}),` Regenerate`]}):p.length?`New take`:`Render`}),G(`div`,{class:`line-tools`,children:[G(`button`,{class:`icon-btn sm`,onClick:v,"aria-label":`Edit line ${t}`,title:`Edit text (paint stays on its words) · double-click the line`,children:G(K,{name:`edit`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:!e.text.trim(),onClick:()=>Iy(e),"aria-label":`Paint delivery onto line ${t}`,title:`Paint delivery onto this line (or select words in it)`,children:G(K,{name:`brush`,size:13})}),G(`button`,{class:`icon-btn sm`,onClick:()=>Zy.value=Hd(e.id,``,e.voice),"aria-label":`Add a line below line ${t}`,title:`Add a line below`,children:G(K,{name:`plus`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:t===1,onClick:()=>Gd(e.id,-1),"aria-label":`Move line ${t} up`,title:`Move up`,children:G(K,{name:`up`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:t===n,onClick:()=>Gd(e.id,1),"aria-label":`Move line ${t} down`,title:`Move down`,children:G(K,{name:`down`,size:13})}),G(`button`,{class:`icon-btn sm`,onClick:()=>{let n=Ud(e.id);n&&z(`Line ${t} deleted`,`info`,{label:`Undo`,run:()=>Wd(n.line,n.index,n.takes)})},"aria-label":`Delete line ${t}`,title:`Delete line`,children:G(K,{name:`trash`,size:13})})]})]})]})}var qy=()=>q.value.lines.map(e=>e.text).join(` +`);async function Jy(){(!jd.value||await Nf(`Discard your script text changes?`,{ok:`Discard`,danger:!0}))&&(Ad.value=null,Xy.value=!1)}function Yy(){let e=q.value.lines.length===0,t=Ad.value??qy(),n=async()=>{let n=xd(t,{sentences:e}),{dropped:r}=Sd(q.value.lines,n),i=r.reduce((e,t)=>e+(J.value[t.id]?.length??0),0);r.length&&i&&!await Nf(`${r.length} line${r.length===1?``:`s`} will be removed with ${i} take${i===1?``:`s`}. Apply anyway?`,{ok:`Apply`,danger:!0})||(zd(n),Ad.value=null,Xy.value=!1)};return G(`div`,{class:`script-text`,children:[G(`textarea`,{class:`input`,rows:10,value:t,"data-tags":!0,onInput:e=>{let t=e.currentTarget.value;Ad.value=t===qy()?null:t},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n())},"aria-label":`Script text`,placeholder:e?`Paste or type the script`:void 0}),G(`p`,{class:`hint`,children:[e?`The script is split at line breaks and sentence ends.`:`One line per row. Rows you leave unchanged keep their paint, voice and takes.`,` ⌘↵ applies.`]}),G(`button`,{class:`btn primary`,onClick:()=>void n(),children:`Apply script`})]})}var Xy=F(Ad.peek()!==null),Zy=F(null);function Qy(){let e=q.value,t=Nd.value,n=H.value.find(e=>e.id===t.baseId),r={values:e.baseline,begin:()=>Ed.begin(),set:(e,t)=>{let n=Ta.value.get(e);n&&Xd(e,P(t,n.range[0],n.range[1]))},end:()=>Ed.end()},i=zc.value;return G(`aside`,{class:`rail direct-rail`,"aria-label":`Voices and performance`,children:[G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Default voice`}),G(`select`,{class:`input`,value:e.voice??``,onChange:e=>Kd(e.currentTarget.value||null),"aria-label":`Default voice for this script`,children:[G(`option`,{value:``,children:[H.value.find(e=>e.id===W.value.baseId)?.label??`—`,` (from Cast)`]}),i.map(e=>G(`option`,{value:e.id,children:e.name}))]}),G(`p`,{class:`hint`,children:[n?.label??`No voice`,` · `,t.mode===`reference`?`kept as is`:`shaped`,`. Lines use the default voice unless they pick their own. Change a voice’s identity in Cast; here only delivery and mood paint onto words.`]}),G(`div`,{class:`voice-adds`,children:[i.map(t=>G(`button`,{class:`btn ghost sm`,style:{"--voice":Cy(t.id)},onClick:()=>Zy.value=Hd(e.lines[e.lines.length-1]?.id??null,``,t.id),title:`Add a line spoken by ${t.name}`,children:[G(`span`,{class:`voice-dot`}),` `,t.name,` says…`]})),!i.length&&G(A,{children:[G(`button`,{class:`btn ghost sm`,style:{"--voice":Cy(null)},disabled:!W.value.baseId,onClick:()=>Zy.value=Hd(e.lines[e.lines.length-1]?.id??null,``),title:W.value.baseId?`Add a line spoken by the default voice`:`Pick a voice in Cast first`,children:[G(`span`,{class:`voice-dot`}),` `,wy(null),` says…`]}),G(`button`,{class:`btn sm voice-bench`,onClick:Ay,disabled:!W.value.baseId,title:W.value.baseId?`Save the Cast voice as a cast member, so lines can pick it`:`Pick a voice in Cast first`,children:[G(K,{name:`plus`,size:13}),` Add this voice to the cast`]}),!W.value.baseId&&G(`p`,{class:`hint`,children:`Pick a voice in Cast first.`})]})]}),G(`p`,{class:`hint`,children:[`Language `,g(Sa.value.language),` · tag strength `,L.value?.tags?Sa.value.tagStrength>1?Sa.value.tagStrength.toFixed(1):`off`:`n/a`,(L.value?.decoders.length??0)>1&&` · decoder ${Ai(wa.value.decoder??L.value.decoders[0].id)}`,` —`,` `,G(`button`,{class:`link`,onClick:()=>Na.value=!0,children:`Project settings`})]})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Baseline performance`}),by.map(e=>Ta.value.get(e)).filter(e=>!!e).map(t=>G(_v,{control:t,value:e.baseline[t.id]??0,color:Da(t.group),label:xy[t.id],onStart:r.begin,onChange:e=>r.set(t.id,e),onEnd:r.end},t.id))]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Pronunciation`}),G(w_,{})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Brushes`}),G(`p`,{class:`hint`,children:`Select words in a line to paint delivery onto them (or use the brush in the line’s tools for the whole line). Click painted words to change or clear them. Underlines show what is painted:`}),G(`div`,{class:`legend`,children:R.value.ui.groups.filter(e=>R.value.ui.controls.some(t=>t.group===e.id&&t.spannable)).map(e=>G(`span`,{class:`legend-item`,children:[G(`i`,{style:{background:Da(e.id)}}),e.label]}))})]})]})}function $y(){let e=kd.value[0],t=e&&document.querySelector(`.line-text[data-line="${e}"]`)?.closest(`.line`);t&&(t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`is-flash`),setTimeout(()=>t.classList.remove(`is-flash`),1200))}function eb({bar:e}){let t=q.value,n=gf.value.filter(e=>e.take).length,r=t.lines.filter(e=>e.text.trim()&&!(J.value[e.id]??[]).length),i=xf.value.length,a=kd.value.filter(e=>t.lines.some(t=>t.id===e)).length,o=cf.value,s=!!o||Object.values(Dd.value).some(Boolean),c=B.value?.id===yy;return t.lines.length?G(`div`,{class:e?`transport`:`col gap-s`,children:[o?G(`div`,{class:`render-progress`,"aria-live":`polite`,children:[G(`span`,{children:[`Rendering `,o.done,`/`,o.total,o.failed?` · ${o.failed} failed`:``]}),G(`button`,{class:`btn sm`,onClick:uf,children:`Cancel`})]}):G(A,{children:[i>0&&G(`button`,{class:`btn primary`,disabled:s,onClick:()=>void Tf(),title:`Settings or a voice changed since these lines’ keepers: render a new take of each`,children:[G(K,{name:`refresh`,size:14}),` Regenerate `,i,` changed`]}),r.length>0&&G(`button`,{class:`btn`,disabled:s,onClick:()=>void df(r.map(e=>e.id)),title:`Render every line that has no take yet`,children:[G(K,{name:`wand`,size:14}),` Render `,r.length,` missing`]})]}),G(`button`,{class:`btn${i||r.length?``:` primary`}`,disabled:!n,onClick:()=>c?Ws():Ey(),title:n?void 0:`Render a line first`,children:[G(K,{name:c?`stop`:`play`,size:14}),` `,c?`Stop`:`Play script`]}),a>0&&!o&&G(`p`,{class:`hint is-bad transport-failed`,children:[a,` failed ·`,` `,G(`button`,{class:`link`,onClick:$y,children:`Show`})]})]}):null}function tb(){let e=q.value,t=gf.value.filter(e=>e.take).length,n={id:`gap`,group:`timing`,label:`Gap between lines`,type:`unipolar`,map:{"+":{}},range:Jd,safe:Jd,collapse:null,spannable:!1,identity:null};return G(`aside`,{class:`rail direct-side`,"aria-label":Og.value?`Export`:`Script`,children:[!Og.value&&G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Script`}),e.lines.length>0&&G(`p`,{class:`hint`,children:[t,`/`,e.lines.length,` lines have a take. Play and export use each line’s keeper.`]}),G(eb,{})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Export`}),G(`button`,{class:`btn`,disabled:!t,onClick:Dy,title:t?`Save the script as ${p(Z.value?.name??`script`)}.wav`:`Render a line first`,children:[G(K,{name:`download`,size:14}),` Export WAV`]})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Timing`}),G(_v,{control:n,value:e.gap,color:`var(--text-2)`,compact:!0,format:e=>`${e.toFixed(2)} s`,onStart:()=>Ed.begin(),onChange:e=>Ed.set({...q.value,gap:Math.round(e*100)/100}),onEnd:()=>Ed.end()}),G(`p`,{class:`hint`,children:`Silence between lines when the script plays or exports.`})]})]})}function nb(){let{clips:e,total:t}=Ef.value;if(!e.length)return null;let n=ky()?.t??null,r=[...new Set(e.map(e=>Pd(e.line)))],i=e=>`${e/(t||1)*100}%`;return G(`section`,{class:`timeline`,"aria-label":`Timeline`,children:[G(`div`,{class:`timeline-head`,children:[G(`span`,{class:`eyebrow`,children:`Timeline`}),G(`span`,{class:`muted small`,children:[t.toFixed(1),` s`,e.some(e=>!e.take)&&` (estimated until rendered)`]})]}),G(`div`,{class:`lanes`,children:[r.map(t=>{let r=Cy(t);return G(`div`,{class:`lane`,style:{"--voice":r},children:[G(`span`,{class:`lane-name`,title:wy(t),children:wy(t)}),G(`div`,{class:`lane-track`,children:e.filter(e=>Pd(e.line)===t).map(e=>G(`button`,{class:`clip${e.take?``:` is-pending`}${!e.take&&n!==null?` is-skipped`:``}`,style:{left:i(e.start),width:i(e.duration)},title:e.take?e.line.text:`Not rendered · ${e.line.text} (click to render)`,"aria-label":`Line ${q.value.lines.indexOf(e.line)+1}: ${e.line.text}${e.take?``:` (not rendered: click to render)`}`,onClick:()=>{if(!e.take)return void sf(e.line.id);if(B.value?.id===yy){let t=Df(),n=Oy(e.line.id);t&&n!==null&&Ks(yy,t.pcm,t.sr,n)}else Js(`take:${e.take.id}`,e.take.audio.pcm,e.take.audio.sr)},children:e.take?G(s_,{pcm:e.take.audio.pcm,color:r,height:28}):G(`span`,{children:[G(`i`,{class:`clip-est`,children:`Not rendered`}),` · `,e.line.text]})},e.line.id))})]},t??``)}),n!==null&&G(`div`,{class:`timeline-head-line`,style:{left:`calc(var(--lane-name) + (100% - var(--lane-name)) * ${n/(t||1)})`}})]})]})}function rb(e){if(e.metaKey||e.ctrlKey||e.altKey||vy(e.target)||Ma.value)return!1;if(e.key===`r`||e.key===`R`){let t=e.target?.closest?.(`.line`)?.querySelector(`.line-text`)?.dataset.line;return t?(e.preventDefault(),sf(t),!0):!1}if(e.key===`s`||e.key===`S`){let t=B.value,n=t?.id.startsWith(`take:`)?t.id.slice(5):null;if(!n)return!1;let r=Object.keys(J.value).find(e=>J.value[e].some(e=>e.id===n));return r?(e.preventDefault(),ff(r,n),z(`Keeper: the script plays this take`),!0):!1}return!1}function ib(){M(()=>(ja.value=Ed,Fa.value=Ey,Pa.value=rb,Ad.peek()!==null&&(Xy.value=!0),()=>{ja.value=null,Fa.value=null,Pa.value=null,Ty.value=null}),[]);let e=q.value.lines,t=Og.value;return G(`div`,{class:`direct`,children:[G(Pg,{id:`direct-voices`,side:`left`,title:`Voices`,children:G(Qy,{})}),G(`section`,{class:`script`,"aria-label":`Lines`,children:[G(Ig,{children:[G(Fg,{id:`direct-voices`,title:`Voices`,icon:`mic`}),G(Fg,{id:`direct-script`,title:`Export`,icon:`download`})]}),G(`header`,{class:`screen-head`,children:[G(`div`,{children:[G(`span`,{class:`eyebrow`,children:`Direct`}),G(`h2`,{children:`Script`})]}),G(`button`,{class:`btn ghost`,onClick:()=>Xy.value?void Jy():Xy.value=!0,children:[G(K,{name:Xy.value?`x`:`edit`,size:14}),` `,Xy.value?jd.value?`Cancel`:`Back to lines`:`Edit as text`]})]}),Xy.value?G(Yy,{}):e.length?G(`ol`,{class:`lines`,children:e.map((t,n)=>G(Ky,{line:t,n:n+1,count:e.length},t.id))}):G(`div`,{class:`empty`,children:[G(K,{name:`edit`,size:26}),G(`h3`,{children:`No lines yet`}),G(`p`,{children:`Paste a script, or add lines one by one; each line is rendered and directed on its own, in its own voice.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>Xy.value=!0,children:[G(K,{name:`edit`,size:14}),` Paste a script`]}),G(`button`,{class:`btn`,onClick:()=>Zy.value=Hd(null,``),children:[G(K,{name:`plus`,size:14}),` Add a line`]})]})]}),!Xy.value&&e.length>0&&G(A,{children:[G(`button`,{class:`btn ghost add-line`,onClick:()=>Zy.value=Hd(null,``),children:[G(K,{name:`plus`,size:14}),` Add line`]}),G(nb,{}),t&&G(eb,{bar:!0})]})]}),G(Pg,{id:`direct-script`,side:`right`,title:t?`Export`:`Script`,children:G(tb,{})}),t&&G(Ly,{})]})}var ab=e=>Math.max(.5,Math.round(e*2)/2);function ob(e,t){let n=(e,n)=>t.has(n.toLowerCase())?`${n} · ${e.label.toLowerCase()}`:n;return e.flatMap(e=>e.type===`bipolar`&&e.poles?[{control:e,label:n(e,e.poles[0]),value:-ab(Math.abs(e.safe[0])*.65)},{control:e,label:n(e,e.poles[1]),value:ab(e.safe[1]*.6)}]:[{control:e,label:e.label.toLowerCase(),value:ab(e.safe[1]*.5)}])}function sb({values:e,set:t,clear:n,name:r}){let i=sp.value,a=xv.value,o=ob(i.filter(e=>!a.has(e.id)),new Set(bv.value.map(e=>e.label.toLowerCase()))),s=i.filter(t=>!a.has(t.id)||e[t.id]),c=i.filter(t=>e[t.id]);return G(`div`,{class:`direction`,children:[G(`div`,{class:`direction-chips`,role:`group`,"aria-label":`Direction for ${r}`,children:[o.map(n=>{let r=e[n.control.id]??0,i=r!==0&&Math.sign(r)===Math.sign(n.value);return G(`button`,{class:`chip dchip${i?` is-on`:``}`,style:{"--fam":Da(n.control.group)},"aria-pressed":i,title:`${n.control.label} · strength ${Math.abs(n.value)}${n.control.effect?` · ${n.control.effect}`:``}`,onClick:()=>t(n.control.id,i?0:n.value),children:[n.label,i&&G(`b`,{children:[`×`,+Math.abs(r).toFixed(2)]})]})}),G(Dv,{values:e,onPick:n=>t(n.control.id,(e[n.control.id]??0)>0?0:n.dose)}),n&&c.length>0&&G(`button`,{class:`link dclear`,onClick:n,children:`clear`})]}),G(`details`,{class:`pro direction-fine`,children:[G(`summary`,{children:c.length?`Fine-tune ${c.map(e=>e.label.toLowerCase()).join(`, `)}`:`Fine-tune strength`}),G(`div`,{class:`direction-sliders`,children:s.map(n=>G(_v,{control:n,value:e[n.id]??0,color:Da(n.group),detailed:!0,onChange:e=>t(n.id,e)},n.id))})]})]})}var cb=150,lb=4,ub=256,db=[.1,.25,.5,1,2,5,10,30,60];function fb(e){let t=Math.ceil(e.length/ub),n=new Float32Array(t),r=new Float32Array(t);for(let i=0;ia&&(a=r)}n[i]=t,r[i]=a}return{min:n,max:r}}var pb=e=>typeof e.confidence==`number`&&e.confidence<.5,mb=e=>typeof e.confidence==`number`?` · confidence ${e.confidence.toFixed(2)}`:``,hb=e=>{let t=Math.floor(e/60);return`${t}:${(e-t*60).toFixed(2).padStart(5,`0`)}`};function gb(e){let t=N(null),n=N(null),[r,i]=j(800),[a,o]=j(0),[s,c]=j(null),[l,u]=j(null),d=N(null),f=e.pcm.length/e.sr,p=ht(()=>fb(e.pcm),[e.pcm]),m=r/Math.max(.5,f)*e.zoom,h=Math.max(r,Math.ceil(f*m)),g=r_.value,_=ht(()=>({wave:o_(`--text-2`),dim:o_(`--text-3`),line:o_(`--line`),text:o_(`--text-2`)}),[g]);M(()=>{let e=t.current,n=new ResizeObserver(([e])=>i(Math.max(200,Math.round(e.contentRect.width))));n.observe(e);let r=0,a=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>o(e.scrollLeft))};e.addEventListener(`scroll`,a,{passive:!0});let s=t=>{if(t.ctrlKey||t.metaKey){t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.left;d.current={t:(e.scrollLeft+r)/v.current,x:r},b.current(P(y.current*Math.exp(-t.deltaY*.0025),1,64))}else y.current>1&&Math.abs(t.deltaY)>Math.abs(t.deltaX)&&(t.preventDefault(),e.scrollLeft+=t.deltaY)};return e.addEventListener(`wheel`,s,{passive:!1}),()=>{n.disconnect(),e.removeEventListener(`scroll`,a),e.removeEventListener(`wheel`,s)}},[]);let v=N(m);v.current=m;let y=N(e.zoom);y.current=e.zoom;let b=N(e.setZoom);b.current=e.setZoom,mt(()=>{let e=t.current,n=d.current??{t:(e.scrollLeft+r/2)/v.current,x:r/2};e.scrollLeft=P(n.t*m-n.x,0,Math.max(0,h-r)),d.current=null,o(e.scrollLeft)},[m]),M(()=>{let n=e.zoomTo;if(!n)return;let i=Math.max(.3,n.e-n.s),a=P(f/i,1,64);if(d.current={t:(n.s+n.e)/2,x:r/2},e.setZoom(a),a===e.zoom){let e=t.current;e.scrollLeft=P((n.s+n.e)/2*m-r/2,0,Math.max(0,h-r))}},[e.zoomTo?.n]),M(()=>{let t=n.current;if(!t)return;let i=window.devicePixelRatio||1;t.width=Math.round(r*i),t.height=Math.round(cb*i);let o=t.getContext(`2d`);o.setTransform(i,0,0,i,0,0),o.clearRect(0,0,r,cb);let s=_,c=a/m,l=db.find(e=>e*m>=70)??120;o.font=`11px "JetBrains Mono", ui-monospace, Menlo, monospace`,o.fillStyle=s.dim,o.strokeStyle=s.line,o.lineWidth=1;for(let e=Math.floor(c/l)*l;e<=c+r/m;e+=l){let t=Math.round(e*m-a)+.5;o.beginPath(),o.moveTo(t,11),o.lineTo(t,cb),o.globalAlpha=.35,o.stroke(),o.globalAlpha=1,o.fillText(l<1?`${e.toFixed(l<.5?2:1)}s`:hb(e).replace(/\.\d+$/,``),t+3,10)}let u=.05;for(let e=0;e=e.pcm.length)break;let i=0,s=0;if(r-ns&&(s=n)}else for(let e=Math.floor(n/ub);es&&(s=p.max[e]);let c=83-Math.max(.5,s*d*63),l=83-Math.min(-.5,i*d*63);o.fillRect(t,c,1,l-c)}},[p,m,a,r,_]);let x=B.value?.id===e.playId?Ms.value:null;M(()=>{if(x===null)return;let e=t.current,n=x*m;(ne.scrollLeft+r-24)&&(e.scrollLeft=P(n-r*.15,0,Math.max(0,h-r)))},[x!==null&&Math.floor(x*m/(r*.5))]);let S=e=>P((e-t.current.getBoundingClientRect().left+t.current.scrollLeft)/m,0,f),C=t=>{if(t.button!==0||t.target.closest(`.ew-word, .ew-edge, .ew-words`))return;let n=t.currentTarget;n.setPointerCapture(t.pointerId);let r=t.clientX,i=S(r),a=!1,o=t=>{!a&&Math.abs(t.clientX-r){n.removeEventListener(`pointermove`,o),n.removeEventListener(`pointerup`,l),n.removeEventListener(`pointercancel`,u),c(null)},l=t=>{if(s(),a&&e.editable){let n=S(t.clientX);Math.abs(n-i)*m>=lb&&e.onCreate(Math.min(i,n),Math.max(i,n))}else a||e.onSeek(i)},u=()=>s();n.addEventListener(`pointermove`,o),n.addEventListener(`pointerup`,l),n.addEventListener(`pointercancel`,u)},w=(t,n,r)=>{if(t.button!==0||!e.editable)return;t.stopPropagation();let i=t.currentTarget;i.setPointerCapture(t.pointerId);let a={kind:r,id:n.id,a:n.start,b:n.end},o=e=>{let t=S(e.clientX);a=r===`start`?{...a,a:Math.min(t,n.end-.07)}:{...a,b:Math.max(t,n.start+.07)},c(a)},s=()=>{i.removeEventListener(`pointermove`,o),i.removeEventListener(`pointerup`,l),i.removeEventListener(`pointercancel`,u),c(null)},l=()=>{s(),(a.a!==n.start||a.b!==n.end)&&e.onEdges(n.id,a.a,a.b)},u=()=>s();i.addEventListener(`pointermove`,o),i.addEventListener(`pointerup`,l),i.addEventListener(`pointercancel`,u)},T=(t,n,r)=>{let i=e.timing;if(t.button!==0||!i)return;t.stopPropagation(),t.preventDefault();let a=t.currentTarget;a.setPointerCapture(t.pointerId);let o=e.words[n];i.onEdge(n,r,r===`start`?o.start:o.end,`begin`,t.altKey),u({i:n,edge:r});let s=r===`start`?o.start:o.end,c=e=>{s=S(e.clientX),i.onEdge(n,r,s,`move`,e.altKey)},l=()=>{a.removeEventListener(`pointermove`,c),a.removeEventListener(`pointerup`,d),a.removeEventListener(`pointercancel`,f),u(null)},d=e=>{l(),i.onEdge(n,r,S(e.clientX),`end`,e.altKey)},f=()=>{l(),i.onEdge(n,r,s,`end`,!1)};a.addEventListener(`pointermove`,c),a.addEventListener(`pointerup`,d),a.addEventListener(`pointercancel`,f)},E=a/m-1,D=(a+r)/m+1,O=e.words.filter(e=>e.end>=E&&e.start<=D),ee=new Set,te=-1/0;for(let e of O){let t=e.start*m;tG(`div`,{class:`ew-context${e.contextsEstimated?` is-estimate`:``}`,style:{left:`${t*m}px`,width:`${Math.max(2,(n-t)*m)}px`},title:`Model context ${hb(t)}–${hb(n)}: ${e.contextsEstimated?`the stretch the model will hear (estimate)`:`the audio the model listened to for this edit`}`,children:G(`span`,{children:e.contextsEstimated?`model context · est.`:`model context`})})),G(`canvas`,{ref:n,class:`ew-canvas`,style:{width:`${r}px`,height:`${cb}px`,left:`${a}px`},"aria-hidden":`true`}),e.overlays.map(([e,t],n)=>G(`div`,{class:`ew-overlay`,style:{left:`${e*m}px`,width:`${Math.max(2,(t-e)*m)}px`},title:`Region ${n+1} in this take`,children:G(`span`,{class:`ew-n`,children:n+1})})),e.regions.map(t=>{let n=s&&s.id===t.id?s:null,r=n?n.a:t.start,i=n?n.b:t.end;return G(`div`,{class:`ew-region${t.manual?` is-manual`:``}${t.directed?` is-directed`:``}${t.ghost?` is-ghost`:``}${e.focusRegion===t.id?` is-focus`:``}`,style:{left:`${r*m}px`,width:`${Math.max(3,(i-r)*m)}px`},children:[G(`span`,{class:`ew-n`,children:t.n}),e.editable&&G(A,{children:[G(`span`,{class:`ew-edge ew-edge-s`,onPointerDown:e=>w(e,t,`start`),title:`Drag to move the start`}),G(`span`,{class:`ew-edge ew-edge-e`,onPointerDown:e=>w(e,t,`end`),title:`Drag to move the end`})]})]})}),s?.kind===`new`&&G(`div`,{class:`ew-region is-new`,style:{left:`${Math.min(s.a,s.b)*m}px`,width:`${Math.abs(s.b-s.a)*m}px`}}),G(`div`,{class:`ew-cursor`,style:{left:`${e.cursor*m}px`}}),x!==null&&G(`div`,{class:`ew-head`,style:{left:`${x*m}px`}}),e.timing?G(`div`,{class:`ew-words is-timing`,role:`group`,"aria-label":`Word timings: drag word edges to correct them`,children:[O.map(t=>{let n=e.words.indexOf(t),r=e.timing,i=r.selected===n,a=Math.max(2,(t.end-t.start)*m),o=l?.i===n?l.edge:i?r.edge:null;return G(`div`,{class:`ew-wblock${i?` is-sel`:``}${r.adjusted(n)?` is-adjusted`:``}${pb(t)?` is-low`:``}${x!==null&&x>=t.start&&xe.onWord(n),children:a>14||i?t.word:``}),G(`span`,{class:`ew-wedge ew-wedge-s${o===`start`?` is-active`:``}`,onPointerDown:e=>T(e,n,`start`),"aria-hidden":`true`}),G(`span`,{class:`ew-wedge ew-wedge-e${o===`end`?` is-active`:``}`,onPointerDown:e=>T(e,n,`end`),"aria-hidden":`true`})]})}),l&&(()=>{let t=e.timing.selected??l.i,n=e.words[t];if(!n)return null;let r=e.timing.edge===`start`?n.start:n.end;return G(`div`,{class:`ew-readout`,style:{left:`${r*m}px`},"aria-live":`polite`,children:[n.word,` `,e.timing.edge===`start`?`start`:`end`,` `,hb(r),` · `,Math.round((n.end-n.start)*1e3),` ms`]})})()]}):G(`div`,{class:`ew-words`,children:O.map(t=>{let n=e.words.indexOf(t),r=t.start*m,i=Math.max(10,(t.end-t.start)*m);return G(`button`,{class:`ew-word${ee.has(t)?` is-quiet`:``}${pb(t)?` is-low`:``}${x!==null&&x>=t.start&&xe.onWord(n),tabIndex:0,children:t.word})})})]})})})}var _b=F(1),vb=F(null),yb=F(null),bb=null;function xb(){requestAnimationFrame(()=>document.querySelector(`.ew-wblock.is-sel .ew-wlabel`)?.focus({preventScroll:!1}))}function Sb(e){let t=e.metaKey||e.ctrlKey;if(t&&e.key===`Enter`)return e.preventDefault(),um(),!0;let n=e.target,r=n?.getAttribute?.(`role`),i=!!n?.closest?.(`.ew-wlabel`);if(t||e.altKey||vy(e.target)&&!(e.key===`Tab`&&i)||!Y.value)return!1;let a=lp.value,o=Xf.value;if(o!==null&&a?.kind===`version`&&r!==`slider`){let t=Y.value.words.length;switch(e.key){case`ArrowLeft`:case`ArrowRight`:return!vy(e.target)&&(e.preventDefault(),Ip((e.key===`ArrowLeft`?-1:1)*(e.shiftKey?.05:.01)),!0);case`Tab`:return i?(e.preventDefault(),Xf.value=P(o+(e.shiftKey?-1:1),0,t-1),xb(),!0):!1;case`,`:case`.`:return!vy(e.target)&&(Zf.value=e.key===`,`?`start`:`end`,!0);case`Enter`:return!vy(e.target)&&(e.preventDefault(),Rp(o),!0);case`Escape`:return Xf.value=null,!0}}if(vy(e.target))return!1;switch(e.key){case` `:return e.target instanceof HTMLButtonElement||r===`slider`||r===`button`?!1:(e.preventDefault(),_m(),!0);case`a`:case`b`:return r===`slider`?!1:e.key===`b`&&!cp.value?(z(`Generate takes first`),!0):(gm(e.key===`a`?`version`:`take`),!0);case`k`:return cp.value?(bm(),!0):(z(`Generate takes first`),!0);case`[`:return r!==`slider`&&(_b.value=P(_b.value/1.6,1,64),!0);case`]`:return r!==`slider`&&(_b.value=P(_b.value*1.6,1,64),!0);case`0`:return r!==`slider`&&(_b.value=1,!0);case`ArrowLeft`:case`ArrowRight`:{if(r===`slider`||!a)return!1;e.preventDefault();let t=B.value?.id===a.id,n=P((t?Ms.value:Yf.value)+(e.key===`ArrowLeft`?-1:1),0,a.duration);return Yf.value=n,t&&Ks(a.id,a.pcm,a.sr,n),!0}}return!1}var Cb=F(null);async function wb(e){let t=H.value.find(t=>t.id===e);if(t){Cb.value=e;try{let{pcm:e,sr:n}=await Xs(await wo(t));await xp({kind:`voice`,label:t.label},e,n,t.transcript)&&Mg()}catch(e){z(`Couldn’t load ${t.label}: ${e instanceof Error?e.message:e}`,`error`)}finally{Cb.value=null}}}async function Tb(e,t,n){let r=J.value[e]?.[n];r&&await xp({kind:`take`,label:`Line ${t+1} · take ${n+1}`,lineId:e,takeId:r.id},r.audio.pcm,r.audio.sr,r.text)&&Mg()}function Eb(){let e=N(null),t=Nm.value,[,n]=j(0);M(()=>{if(!t)return;let e=setInterval(()=>n(e=>e+1),250);return()=>clearInterval(e)},[t]);let r=q.value.lines.flatMap((e,t)=>(J.value[e.id]??[]).map((n,r)=>({l:e,i:t,t:n,k:r}))),i=H.value.filter(e=>e.has_preview!==!1),a=!!X.value;return G(`div`,{class:`rail-section edit-sources`,children:[G(`h4`,{children:`Open audio`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm`,disabled:a,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`,size:13}),` Upload`]}),G(`button`,{class:`btn sm btn-rec${t?` is-recording`:``}`,disabled:a&&!t,onClick:()=>void Fm(),children:t?G(A,{children:[G(`span`,{class:`rec-dot`}),` Stop · `,Math.floor((Date.now()-t.started)/1e3),` / `,Math.round(Math.min(120,ap.value)),` s`,G(`span`,{class:`rec-level`,"aria-hidden":`true`,children:G(`span`,{style:{width:`${Math.round(Pm.value*100)}%`}})})]}):G(A,{children:[G(K,{name:`mic`,size:13}),` Record`]})}),G(`input`,{ref:e,type:`file`,accept:`audio/*,video/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&Im(t)}})]}),G(`p`,{class:`hint`,children:[`Clips up to `,Math.round(ap.value),` s.`]}),G(`details`,{class:`src-group`,open:!!r.length,children:[G(`summary`,{children:[`Direct takes `,r.length?G(`b`,{children:r.length}):null]}),r.length?G(`ul`,{class:`src-list`,children:r.map(({l:e,i:t,t:n,k:r})=>G(`li`,{children:G(`button`,{class:`src-item`,disabled:a,title:n.text,onClick:()=>void Tb(e.id,t,r),children:[G(`span`,{class:`src-n`,children:[t+1,`.`,r+1]}),G(`span`,{class:`src-text`,children:n.text}),n.starred&&G(K,{name:`star`,size:11,filled:!0})]})}))}):G(`p`,{class:`muted small`,children:`Render takes in Direct; each one can be opened here.`})]}),G(`details`,{class:`src-group`,open:i.length>0,children:[G(`summary`,{children:[`Voice clips `,i.length?G(`b`,{children:i.length}):null]}),G(`ul`,{class:`src-list`,children:i.map(e=>G(`li`,{children:G(`button`,{class:`src-item${Cb.value===e.id?` is-busy`:``}`,disabled:a,onClick:()=>void wb(e.id),title:e.transcript?`Transcript: ${e.transcript}`:ip.value?`No transcript: it will be transcribed`:`No transcript: this server can’t transcribe, so you type what the clip says`,children:[G(`span`,{class:`src-text`,children:e.label}),G(`span`,{class:`tag`,children:e.transcript?`text`:ip.value?`auto`:`needs text`})]})}))})]})]})}function Db(){let e=Lf.value;return e?G(`div`,{class:`rail-section grow`,children:[G(`h4`,{children:`Versions`}),G(`ol`,{class:`versions`,children:e.versions.map((t,n)=>{let r=`edit:v:${t.id}`,i=B.value?.id===r;return G(`li`,{class:`version-row${n===e.current?` is-current`:``}${n>e.current?` is-future`:``}`,children:[G(`button`,{class:`version-main`,onClick:()=>void Sm(n),"aria-current":n===e.current,title:n===e.current?`Current version`:`Step to this version`,children:[G(`span`,{class:`badge`,children:[`v`,n]}),G(`span`,{class:`version-label`,children:t.label}),G(`span`,{class:`mono muted`,children:[(t.pcm.length/t.sr).toFixed(1),` s`]})]}),G(`button`,{class:`play-mini${i?` is-playing`:``}`,onClick:()=>Js(r,t.pcm,t.sr),"aria-label":`Play version ${n}`,children:G(K,{name:i?`stop`:`play`,size:11})})]})})}),G(`p`,{class:`hint`,children:`Keep a take to add a version; ⌘Z / ⇧⌘Z step through them.`})]}):null}function Ob({value:e}){let t=Y.value,n=up.value,r=ht(()=>dr(t.words,e,{duration:t.duration,frameRate:op.value,marginSeconds:$f.value,groups:n}),[t,e,n]),i=[],a=new Map,o=0;for(let e of r.regions)for(let t of e.changes)if(t.j1===t.j2)i.push({from:r.deletionPoints[o++],to:0,type:`del`});else for(let e=t.j1;ee.from-t.from||(e.type===`del`?-1:1));let s=[],c=0;for(let t of i)t.fromt.transcript||bp.value,[a,o]=j(i);M(()=>o(i()),[t.id,n]);let s=n?a:Rf.value;M(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${Math.max(64,t.scrollHeight)}px`)},[s,n]),M(()=>{r&&e.current?.focus()},[t.id,r]);let c=!!X.value;return G(`section`,{class:`ed-text-card`,"aria-label":`Transcript`,children:[G(`header`,{class:`ed-text-head`,children:[r||n?G(`div`,{class:`segctl`,role:`tablist`,"aria-label":`Transcript mode`,children:[G(`button`,{role:`tab`,"aria-selected":!n,class:`seg-btn${n?``:` is-on`}`,onClick:()=>void Em(!1),disabled:r,title:r?`Type what the clip says first: edits are planned against it`:void 0,children:`Edit the words`}),G(`button`,{role:`tab`,"aria-selected":n,class:`seg-btn${n?` is-on`:``}`,onClick:()=>void Em(!0),disabled:c,title:r?`Type what is said in the clip; the audio is aligned to it`:`Correct what was actually said; the audio is re-aligned to it`,children:r?`Type what the clip says`:`Fix the transcript`})]}):G(A,{children:[G(`h3`,{class:`ed-text-title`,children:`Edit the words`}),!t.automatic&&G(`button`,{class:`link`,onClick:()=>void Em(!0),disabled:c,title:`Correct what was actually said; the audio is re-aligned to it`,children:`Fix the transcript`})]}),!n&&Rf.value!==t.transcript&&G(`button`,{class:`link`,onClick:()=>{let e=Rf.value;Wp(t.transcript),z(`Text reverted to the transcript`,`info`,{label:`Undo`,run:()=>Wp(e)})},title:`Back to the transcript of this version`,children:[G(K,{name:`undo`,size:13}),` revert text`]})]}),r&&G(`div`,{class:`ed-banner`,role:`note`,children:G(`span`,{children:[ip.value?`No words were recognized in this clip. `:`This server can’t transcribe speech. `,G(`b`,{children:`Type exactly what the clip says`}),` (play it to check), then use it: edits are planned against it.`]})}),!n&&t.automatic&&G(`div`,{class:`ed-banner ed-check`,role:`note`,children:[G(`span`,{children:[G(`b`,{children:`Transcribed automatically`}),` — check it: play the clip and read along.`]}),G(`button`,{class:`btn sm primary`,onClick:Dm,disabled:c,children:`Looks right`}),G(`button`,{class:`btn sm`,onClick:()=>void Em(!0),disabled:c,children:`Fix it`})]}),G(`div`,{class:`ed-editor${n?` is-fix`:``}`,children:[!n&&G(Ob,{value:s}),G(`textarea`,{ref:e,class:`ed-area`,value:s,spellcheck:!1,"data-tags":!n||void 0,"aria-label":r?`What the clip says`:n?`Correct transcript of the audio`:`Edited transcript: change the words to change the speech`,placeholder:r?`Type what is said in the clip…`:void 0,onInput:e=>{let t=e.currentTarget.value;n?o(t):Wp(t)},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.blur()}})]}),!n&&(up.value||T_.value)&&G(`div`,{class:`ed-pron`,children:[up.value&&G(v_,{input:()=>e.current}),G(M_,{input:()=>e.current}),up.value&&G(C_,{text:s,replace:(e,t,n)=>Wp(s.slice(0,e)+n+s.slice(t))}),G(P_,{text:s,replace:e=>Wp(e)})]}),n&&G(`div`,{class:`ed-fix-bar`,children:[G(`span`,{class:`hint`,children:r?`Type what is said in the audio, word for word.`:`Type what is actually said in the audio. Low-confidence words are underlined in the waveform’s word lane.`}),!r&&G(`button`,{class:`btn sm ghost`,onClick:()=>void Em(!1),children:`Cancel`}),G(`button`,{class:`btn sm primary`,disabled:c||!a.trim()||a.trim()===t.transcript,onClick:()=>void km(a),children:`Use this transcript`})]})]})}var Ab=F(null);function jb(){let e=zf.value,t=Wf.value,n=cp.value,r=!!t&&t.target!==Rf.value.trim(),i=t&&n&&!r&&t.spans.length===e.length?im(n,t):null,a=pp.value,o=e.reduce((e,t)=>e+mp(t.end-t.start),0);return G(`section`,{class:`ed-regions`,"aria-label":`Regions`,children:[G(`header`,{class:`ed-sub-head`,children:[G(`h3`,{children:`Regions`}),G(`span`,{class:`ed-count${a?` is-error`:``}`,children:[e.length,`/`,np.value.edit_max_spans,` · `,o.toFixed(1),` s to regenerate`]})]}),a&&G(`p`,{class:`error-box`,role:`alert`,children:a}),r&&t&&t.takes.length>0&&G(`p`,{class:`note`,children:`The takes were made from earlier text; generate again for this one.`}),e.length?G(`ol`,{class:`region-list`,children:e.map((e,t)=>{let r=mp(e.start),a=mp(e.end),o=t>=np.value.edit_max_spans;return G(`li`,{class:`region-row${e.manual?` is-manual`:``}${o?` is-over`:``}${yb.value===e.id?` is-focus`:``}`,onPointerEnter:()=>yb.value=e.id,onPointerLeave:()=>yb.value=null,children:[G(`div`,{class:`region-line`,children:[G(`span`,{class:`badge region-n`,children:t+1}),G(`span`,{class:`mono region-time`,children:[hb(r),`–`,hb(a)]}),G(`span`,{class:`region-sum`,title:Zp(e),children:Zp(e)}),G(`button`,{class:`icon-btn sm`,onClick:()=>vm(t),"aria-label":`Play around region ${t+1}`,title:`Play with 1 s of pre-roll`,children:G(K,{name:`play`,size:12})}),G(`button`,{class:`icon-btn sm`,onClick:()=>vb.value={s:r-1,e:a+1,n:Date.now()},"aria-label":`Zoom to region ${t+1}`,title:`Zoom to this region`,children:G(K,{name:`expand`,size:12})}),e.manual&&G(`button`,{class:`icon-btn sm`,onClick:()=>qp(e.id),"aria-label":`Remove region ${t+1}`,title:`Remove this region`,children:G(K,{name:`x`,size:12})}),e.changes.length>0&&G(`button`,{class:`link`,onClick:()=>Hp(e.id),title:`Put the original words back into the text`,children:`revert these words`})]}),(e.edited||e.mergedFrom)&&G(`p`,{class:`region-note`,children:[e.edited?`edges moved by hand`:``,e.edited&&e.mergedFrom?` · `:``,e.mergedFrom?`merged from ${e.mergedFrom} regions`:``]}),i?.[t]?.length?G(`p`,{class:`region-unheard`,role:`note`,children:[`Not heard in `,n.label.toLowerCase(),`: `,G(`b`,{children:i[t].join(`, `)})]}):null,G(`div`,{class:`region-dir`,children:Ab.value===e.id?G(A,{children:[G(`div`,{class:`region-dir-head`,children:[G(`span`,{class:`muted small`,children:[`How region `,t+1,` sounds`]}),G(`button`,{class:`link`,onClick:()=>Ab.value=null,children:`Done`})]}),G(sb,{name:`region ${t+1}`,values:e.values,set:(t,n)=>Jp(e.id,t,n),clear:()=>Yp(e.id)})]}):G(`div`,{class:`region-dir-sum`,children:[G(`span`,{class:`muted small`,children:[`How it sounds: `,tm(e.values)||(rm.value&&Object.keys(Hf.value).length?`as all changes`:`as the voice says it`)]}),G(`button`,{class:`link`,onClick:()=>Ab.value=e.id,children:`Edit`})]})})]})})}):G(`p`,{class:`ed-regions-empty`,children:[G(`b`,{children:`Change words`}),`, or `,G(`b`,{children:`drag across the waveform`}),` to re-say a stretch as it is. Then pick how it should sound: whisper, slower, angry…`]})]})}function Mb(){let e=X.value,[,t]=j(0);if(M(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),100);return()=>clearInterval(n)},[e]),!e)return null;let n=(performance.now()-e.started)/1e3;return G(`div`,{class:`ed-busy-row`,role:`status`,"aria-live":`polite`,children:[G(`span`,{class:`loader sm`}),G(`span`,{class:`ed-status is-busy`,children:[e.label,` `,n.toFixed(1),` s`]}),G(`button`,{class:`btn sm`,onClick:dm,children:[G(K,{name:`x`,size:13}),` Cancel`]})]})}function Nb(){let e=X.value,t=Qf.value,n=!!e&&/Generating|Regenerating/.test(e.label),r=(Y.value?.duration??0)>16;return G(`section`,{class:`ed-generate`,"aria-label":`Generate`,children:[G(`div`,{class:`ed-all`,children:[G(`span`,{class:`ed-all-label`,children:`All changes sound:`}),G(sb,{name:`all changes`,values:Hf.value,set:Xp,clear:()=>Hf.value={}})]}),G(`details`,{class:`pro ed-advanced`,children:[G(`summary`,{children:`Advanced`}),G(`div`,{class:`ed-pro-row`,children:[G(`label`,{class:`ed-seed`,title:`A fixed seed repeats a take's randomness; empty picks one each time`,children:[`Seed`,G(`input`,{type:`number`,class:`input`,placeholder:`random`,value:ep.value??``,onChange:e=>{let t=e.currentTarget.value;ep.value=t===``?null:Math.max(0,Math.floor(Number(t)))}})]}),G(`label`,{title:`Each change is widened by this much on both sides so the join sounds smooth`,children:[`Blend around the change`,G(`input`,{type:`number`,class:`input`,min:0,max:.4,step:.02,value:$f.value,onChange:e=>{$f.value=P(Number(e.currentTarget.value)||0,0,.4),Up()}}),`s`]}),r&&G(`label`,{title:`Long clips are edited on a window around the changes; this is how much audio the model listens to on each side`,children:[`Audio the model listens to`,G(`input`,{type:`number`,class:`input`,min:2,max:8,step:.5,value:tp.value,onChange:e=>tp.value=P(Number(e.currentTarget.value)||4,2,8)}),`s per side`]})]})]}),G(`div`,{class:`ed-gen-row`,children:[G(`div`,{class:`segctl`,role:`radiogroup`,"aria-label":`Number of takes`,children:[1,2,3,4].map(e=>G(`button`,{role:`radio`,"aria-checked":t===e,class:`seg-btn${t===e?` is-on`:``}`,onClick:()=>Qf.value=e,children:e}))}),G(`span`,{class:`muted small`,children:[`take`,t>1?`s`:``]}),G(`span`,{class:`grow`}),G(`button`,{class:`btn primary${n?` is-busy`:``}`,disabled:n||!sm.value,onClick:()=>void um(),title:fp.value?`Fix the pronunciation first: ${fp.value.replace(/^Pronunciation: /,``)}`:`Generate (⌘↵ / Ctrl+Enter)`,children:[G(K,{name:`wand`,size:14}),` `,n?`Generating…`:`Generate ${t} take${t>1?`s`:``}`,!n&&rm.value&&G(`span`,{class:`gen-directed`,children:` · directed`})]})]}),qf.value&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:Jf.value?`The server refused this edit`:`Generation failed`}),G(`span`,{children:qf.value})]})]})}function Pb(){let e=Wf.value,t=Y.value;if(!e||!t||e.versionId!==t.id)return G(`div`,{class:`takes-empty`,children:[G(K,{name:`wand`,size:20}),G(`p`,{children:ip.value?`Takes appear here. Each one is checked by speech recognition; the closest to your text is picked for you.`:`Takes appear here. Listen to each one and keep the best (this server can’t check takes with speech recognition).`})]});let n=ar(e.target,e.groups).filter(e=>!rr(e)),r=e.groups?Sn(e.target,null).groups.filter(e=>!e.empty):[],i=om(e.takes,e);return G(`ol`,{class:`take-cards`,children:e.takes.map((t,a)=>{let o=`edit:take:${t.id}`,s=B.value?.id===o,c=e.selected===a,l=t.verify?.wer??null,u=t.verify?t.verify.asr_text.split(/\s+/).filter(Boolean):[],d=t.verify?ar(t.verify.asr_text):[],f=u.length===d.length?cr(n,d):null,m=am(t,e),h=t.verify?im(t,e).flat():null,g=t.verify?h.length?[`Missing: ${h.join(`, `)}`,`warn`,`Words of your text speech recognition did not hear in this take`]:[`All words heard`,`ok`,`Speech recognition heard every word of your text`]:[`Not checked`,`muted`,`No speech recognition on this server: listen to it`];return G(`li`,{class:`take-card${c?` is-selected`:``}`,children:[G(`button`,{class:`take-card-head`,onClick:()=>mm(a),"aria-pressed":c,title:`Select (A/B compares it with the version)`,children:[G(`b`,{children:t.label}),G(`span`,{class:`badge verdict is-${g[1]}`,title:g[2],children:g[0]}),a===i&&l!==null&&G(`span`,{class:`badge badge-best`,children:`best match`})]}),G(`div`,{class:`take-wave`,onClick:()=>mm(a),children:G(s_,{pcm:t.pcm,color:c?`var(--o)`:`var(--text-2)`,playId:o,height:34})}),t.verify&&G(`p`,{class:`take-asr`,title:`What speech recognition heard; differences from your text are marked`,children:f?u.map((e,t)=>G(A,{children:[G(`span`,{class:f[t]?`asr-wrong`:``,children:e}),` `]})):t.verify.asr_text}),r.length>0&&t.verify&&G(`p`,{class:`take-heard`,title:`What speech recognition wrote where each pronunciation is (any word counts as said)`,children:r.map((e,n)=>{let r=t.verify.groups?.[n]?.heard;return G(`span`,{class:`take-heard-item${r?``:` is-missing`}`,children:[G(`span`,{class:`mono`,children:[`(`,e.body,`)`]}),` `,r?G(A,{children:[`heard as ‘`,r,`’`]}):`nothing recognized there`]})})}),G(`p`,{class:`take-dir${t.direction?``:` is-none`}`,title:`How this take was directed`,children:t.direction||`no direction: as the voice says it`}),m.map(e=>G(`p`,{class:`warn-line`,children:e.text})),G(`div`,{class:`take-actions`,children:[G(`button`,{class:`play-mini${s?` is-playing`:``}`,onClick:()=>(mm(a),Js(o,t.pcm,t.sr)),"aria-label":`Play ${t.label}`,children:G(K,{name:s?`stop`:`play`,size:11})}),e.spans.map((e,t)=>G(`button`,{class:`btn sm ghost`,onClick:()=>(mm(a),gm(`take`),vm(t)),title:`Play change ${t+1} of this take with pre-roll`,children:[G(K,{name:`play`,size:11}),` Play change `,t+1]})),G(`span`,{class:`grow`}),c&&e.spans.map((e,t)=>G(`button`,{class:`btn sm ghost`,disabled:!!X.value,onClick:()=>void pm(t),title:`Regenerate only change ${t+1} of this take`,children:[G(K,{name:`refresh`,size:12}),` Redo change `,t+1]})),G(`button`,{class:`icon-btn sm`,onClick:()=>mn(t.pcm,t.sr,`${p(Lf.value?.name??`edit`)}-${p(t.label)}`),"aria-label":`Export ${t.label} as WAV`,title:`Export ${t.label.replace(`Take `,`take `)}`,children:G(K,{name:`download`,size:13})}),G(`button`,{class:`btn sm primary`,disabled:!!X.value,onClick:()=>(mm(a),void bm()),title:`Keep: becomes the new version (K)`,children:`Keep`})]}),G(`details`,{class:`pro take-details`,children:[G(`summary`,{children:`Details`}),G(`p`,{class:`mono small`,children:[l===null?``:`Word error ${Math.round(l*100)}% · `,`seed `,t.seed,e.spans.map(([e,n],r)=>` · change ${r+1}: ${(n-e).toFixed(2)} → ${(t.fill[r]??0).toFixed(2)} s`).join(``)]}),G(`button`,{class:`link`,onClick:()=>ep.value=t.seed,title:`Generate again with this take's seed (Advanced → Seed)`,children:`Reuse seed`})]})]})})})}function Fb(){let e=L.value;return G(`div`,{class:`empty`,children:[G(K,{name:`edit-speech`,size:28}),G(`h2`,{children:`This server can’t edit speech`}),G(`p`,{children:`Changing words in a recording needs a server with the speech-editing model. Cast and Direct work as usual.`}),G(`details`,{class:`pro`,children:[G(`summary`,{children:`For whoever runs the server`}),G(`p`,{children:[e.kind!==`fixture`&&e.kind!==`offline`?`${e.server||location.origin} reports speech_editing: false. `:`Fixture mode: started with ?edit=0. `,`The studio README (“Edit”) lists what the server needs to edit speech.`]})]})]})}function Ib(){let e=N(null);return X.value?G(`div`,{class:`empty`,children:G(Mb,{})}):G(`div`,{class:`empty`,children:[G(K,{name:`edit-speech`,size:26}),G(`h3`,{children:`Open a clip to edit`}),G(`p`,{children:`Change the words of a recording; only the changed stretch is regenerated.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`,size:14}),` Upload`]}),G(`button`,{class:`btn`,onClick:()=>void Fm(),children:[G(K,{name:`mic`,size:14}),` Record`]}),G(`button`,{class:`btn`,onClick:()=>Ng(`edit-sources`),children:[G(K,{name:`film`,size:14}),` Choose a take or voice`]}),G(`input`,{ref:e,type:`file`,accept:`audio/*,video/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&Im(t)}})]})]})}function Lb(){let e=Y.value,t=Lf.value,n=lp.value,r=N(null),i=n?.kind===`take`;if(M(()=>{i&&requestAnimationFrame(()=>document.querySelector(`.take-card.is-selected`)?.scrollIntoView({block:`nearest`,behavior:`smooth`}))},[i,Wf.value?.selected]),!e||!t||!n)return G(Ib,{});let a=cp.value,o=i?n.label:t.current===0?`Original`:`v${t.current}`,s=B.value?.id===n.id,c=!i&&!Vf.value;return G(`div`,{class:`ed-work`,children:[G(`header`,{class:`screen-head ed-head`,children:[G(`div`,{class:`ed-title`,children:[G(`span`,{class:`eyebrow`,children:{take:`Direct take`,voice:`Voice clip`,upload:`Upload`,recording:`Recording`}[t.source.kind]}),G(`h2`,{title:t.name,children:t.name})]}),G(`label`,{class:`ed-lang-wrap`,children:[G(`span`,{class:`muted small`,children:`clip language`}),G(`select`,{class:`input ed-lang`,value:t.language,disabled:!!X.value,onChange:e=>{let n=e.currentTarget,r=n.value;n.value=t.language,Om(r)},"aria-label":`Language of the clip`,title:ip.value?`The clip's language: transcription, alignment and the take check use its speech model (the first use of a language loads it, about half a minute)`:`The clip's language: alignment uses it (switching aligns the transcript again)`,children:ee.map(e=>G(`option`,{value:e,children:g(e)}))})]}),G(`div`,{class:`ab`,role:`group`,"aria-label":`Compare`,children:[G(`button`,{class:`ab-btn${i?``:` is-on`}`,onClick:()=>gm(`version`),title:`The current version (A)`,children:[G(`b`,{children:`A`}),` `,t.current===0?`Original`:`v${t.current}`]}),G(`button`,{class:`ab-btn${i?` is-on`:``}`,disabled:!a,onClick:()=>gm(`take`),title:`The selected take (B)`,children:[G(`b`,{children:`B`}),` `,a?a.label:`Take`]})]}),G(`button`,{class:`btn sm`,onClick:_m,title:`Play / pause (Space)`,children:[G(K,{name:s?`stop`:`play`,size:13}),` `,s?`Pause`:`Play`]}),G(`span`,{class:`mono ed-time`,children:[hb(s?Ms.value:Yf.value),` / `,hb(n.duration)]}),G(`div`,{class:`ed-zoom`,role:`group`,"aria-label":`Zoom`,children:[G(`button`,{class:`icon-btn sm`,onClick:()=>_b.value=P(_b.value/1.6,1,64),"aria-label":`Zoom out ([)`,title:`Zoom out ([)`,children:`−`}),G(`button`,{class:`icon-btn sm`,onClick:()=>_b.value=P(_b.value*1.6,1,64),"aria-label":`Zoom in (])`,title:`Zoom in (]) · ⌘/Ctrl+wheel`,children:`+`}),G(`button`,{class:`btn sm ghost`,onClick:()=>_b.value=1,title:`Fit (0)`,children:`fit`})]}),G(`span`,{class:`grow`}),t.current>0&&t.source.kind===`take`&&G(`button`,{class:`btn sm`,disabled:!jm.value,onClick:()=>void Mm(),title:jm.value?`Add this version to the Direct line as a new keeper take`:`The original take is gone from Direct`,children:[G(K,{name:`undo`,size:13}),` Send back to Direct`]}),G(`button`,{class:`btn sm`,onClick:()=>mn(n.pcm,n.sr,`${p(t.name)}-${i?p(n.label):`v${t.current}`}`),"aria-label":`Export ${o} as WAV`,title:`Save ${o} as a WAV file`,children:[G(K,{name:`download`,size:13}),` Export `,o]})]}),i&&a&&G(`div`,{class:`ed-compare-strip`,role:`status`,children:[G(`span`,{children:[`Comparing `,G(`b`,{children:a.label}),` with `,t.current===0?`the original`:`v${t.current}`]}),G(`button`,{class:`link`,onClick:()=>gm(`version`),children:[`Back to `,t.current===0?`the original`:`v${t.current}`]})]}),G(Mb,{}),G(`div`,{class:`ed-wave-card${i?` is-take`:``}`,children:[G(`div`,{class:`ed-wave-label`,children:[i?G(`span`,{children:[G(`b`,{children:n.label}),` · green = regenerated`]}):G(`span`,{children:[G(`b`,{children:t.current===0?`Original`:`v${t.current} ${e.label}`}),` · orange = will be regenerated`]}),G(`span`,{class:`ed-timing-tools`,children:[!i&&!Vf.value&&G(A,{children:[Xf.value!==null&&n.words[Xf.value]?G(`span`,{class:`ed-readout`,role:`status`,children:[`Editing “`,n.words[Xf.value].word,`” · ←/→ nudge · Esc done`]}):G(`span`,{class:`muted`,children:kp.value?`${kp.value} timing${kp.value===1?``:`s`} adjusted`:``}),G(`label`,{class:`toggle`,title:`Start word playback 0.3 s early`,children:[G(`input`,{type:`checkbox`,checked:Dp.value,onChange:e=>Dp.value=e.currentTarget.checked}),G(`span`,{children:`pre-roll`})]}),kp.value>0&&G(`button`,{class:`link`,onClick:Lp,title:`Back to the alignment's word timings (undoable)`,children:`Reset timings`})]}),G(`span`,{class:`muted`,children:[e.duration.toFixed(1),` s original`]})]})]}),G(`p`,{class:`hint ed-word-hint`,children:c?`Drag on the waveform to re-say a stretch · drag a word’s edge to fix its timing`:i?`Word timings: switch to A to edit`:`Word timings: finish the transcript first`}),G(gb,{pcm:n.pcm,sr:n.sr,words:n.words,regions:zf.value.map((e,t)=>({id:e.id,start:mp(e.start),end:mp(e.end),n:t+1,manual:e.manual,directed:Object.keys(e.values).length>0,ghost:i})),overlays:i&&a?a.edited:[],contexts:i&&a?a.contexts:Wf.value?.versionId===e.id&&Wf.value.contexts.length?Wf.value.contexts:zp.value,contextsEstimated:!i&&!(Wf.value?.versionId===e.id&&Wf.value.contexts.length),timing:c?{selected:Xf.value,edge:Zf.value,adjusted:Ap,onEdge:(t,n,r,i,a)=>{if(i===`begin`){Pp.begin(),Xf.value=t,Zf.value=n,bb={i:t,edge:n,t0:r,decided:!1};return}let o=bb??{i:t,edge:n,t0:r,decided:!0};if(!o.decided&&a&&Math.abs(r-o.t0)>.002){let t=e.words;o.edge===`start`&&ro.t0&&t[o.i+1]&&Math.abs(t[o.i+1].start-t[o.i].end)<.002&&Object.assign(o,{i:o.i+1,edge:`start`}),o.decided=!0,Xf.value=o.i,Zf.value=o.edge}Mp(o.i,o.edge,r,a),i===`end`&&(Pp.end(),bb=null)}}:void 0,editable:!i&&!Vf.value,playId:n.id,cursor:Yf.value,zoom:_b.value,setZoom:e=>_b.value=e,onSeek:e=>{Yf.value=e,B.value?.id===n.id&&Ks(n.id,n.pcm,n.sr,e)},onCreate:Gp,onEdges:Kp,onWord:t=>{let a=n.words[t];if(c){Xf.value=t,Rp(t),xb();return}if(a&&Ks(n.id,n.pcm,n.sr,Math.max(0,a.start-.05),void 0,a.end+.05),i||Vf.value||!r.current)return;let o=dr(e.words,Rf.value,{duration:e.duration,frameRate:op.value,marginSeconds:$f.value,groups:up.value}),s=0;for(let n=0;n=0?o.owners[l]:null;u&&(r.current.focus(),r.current.setSelectionRange(u[0],u[1]))},focusRegion:yb.value,zoomTo:vb.value})]}),G(`div`,{class:`ed-columns`,children:[G(`div`,{class:`ed-left`,children:[G(kb,{area:r}),G(jb,{}),G(Nb,{})]}),G(`aside`,{class:`ed-takes`,"aria-label":`Takes`,children:[G(`header`,{class:`ed-sub-head`,children:[G(`h3`,{children:`Takes`}),a&&G(`span`,{class:`muted small`,children:Kf.value===`take`?`comparing (B)`:`press B to compare`})]}),Wf.value&&Wf.value.versionId===e.id&&G(`p`,{class:`hint`,children:`Takes aren’t saved until you keep one.`}),G(Pb,{})]})]})]})}function Rb(){let e=L.value.edit.speech_editing;return M(()=>{ja.value=If,Fa.value=_m,Pa.value=e?Sb:null;let t=e=>{Xf.peek()!==null&&!e.target.closest?.(`.ew-words, .ed-timing-tools`)&&(Xf.value=null)},n=e=>{Xf.peek()!==null&&e.target.matches?.(`textarea`)&&(Xf.value=null)};return document.addEventListener(`pointerdown`,t),document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`focusin`,n),ja.value=null,Fa.value=null,Pa.value=null,Ws()}},[e]),e?G(`div`,{class:`edit`,children:[G(Pg,{id:`edit-sources`,side:`left`,title:`Sources`,children:G(`aside`,{class:`rail edit-rail`,"aria-label":`Sources and versions`,children:[G(Eb,{}),G(Db,{})]})}),G(Ig,{children:G(Fg,{id:`edit-sources`,title:`Sources`,icon:`film`})}),G(Lb,{}),G(Vg,{label:`Drop to edit this clip`,hint:`An audio or video file; only the words you change are regenerated`,busy:X.value?`Wait for the current step…`:null,onFile:e=>void Im(e)})]}):G(Fb,{})}function zb({size:e=22}){return G(`svg`,{class:`z-mark`,width:e,height:e*164/224,viewBox:n,"aria-hidden":`true`,children:f.map(e=>G(`path`,{d:e,fill:`currentColor`}))})}function Bb({height:e=12}){return G(`svg`,{class:`z-word`,height:e,viewBox:c,role:`img`,"aria-label":`Zyphra`,children:r.map(e=>G(`path`,{d:e,fill:`currentColor`}))})}function Vb(){let e=L.value?.decoders??[];if(e.length<2)return null;let t=wa.value.decoder??e[0].id;return G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Decoder`}),G(`select`,{class:`input`,value:t,title:e.find(e=>e.id===t)?.label,onChange:t=>yg({decoder:t.currentTarget.value===e[0].id?null:t.currentTarget.value}),"aria-describedby":`settings-decoder-hint`,children:e.map((e,t)=>G(`option`,{value:e.id,title:e.label,children:[Ai(e.id),t===0?` (default)`:``]},e.id))}),G(`span`,{class:`hint`,id:`settings-decoder-hint`,children:`What turns the model’s codes into sound, for every render (Cast previews, Direct lines, Edit takes). Fast (keep2) runs a pruned decoder; Full-size runs all of its layers (heavier). Direct takes rendered with another decoder read as stale.`})]})}function Hb(){let e=Na.value,t=N(null);mt(()=>{if(!e)return;let n=document.activeElement;return Ma.value=!0,t.current?.querySelector(`select`)?.focus({preventScroll:!0}),()=>{Ma.value=!1,(n?.isConnected?n:document.querySelector(`.proj-trigger`))?.focus({preventScroll:!0})}},[e]);let n=Z.value;if(!e||!n)return null;let r=()=>Na.value=!1,i=Sa.value,a=L.value?.tags,o=xh.value;return G(`div`,{class:`sheet-backdrop`,onClick:r,children:G(`div`,{ref:t,class:`sheet settings-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,onClick:e=>e.stopPropagation(),onKeyDown:jf(()=>t.current,r),children:[G(`header`,{class:`sheet-head`,children:[G(`h2`,{id:`settings-title`,children:`Project settings`}),G(`button`,{class:`icon-btn`,onClick:r,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`p`,{class:`muted small`,children:n.name}),G(`div`,{class:`settings-grid`,children:[G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Language`}),G(`select`,{class:`input`,value:i.language,onChange:e=>yg({language:e.currentTarget.value}),"aria-describedby":`settings-lang-hint`,children:Object.entries(C).map(([e,t])=>G(`option`,{value:e,children:t},e))}),G(`span`,{class:`hint`,id:`settings-lang-hint`,children:`Direct lines and the Cast preview render in it: numbers and abbreviations are read in this language, and painted words follow the reading where the server can. New Edit clips and pronunciation lookups start in it.`})]}),G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Voice mode`}),G(`select`,{class:`input`,value:i.voiceMode,onChange:e=>yg({voiceMode:e.currentTarget.value}),"aria-describedby":`settings-mode-hint`,children:[G(`option`,{value:`embedding`,children:`Designable`}),G(`option`,{value:`reference`,children:`Exact clone`})]}),G(`span`,{class:`hint`,id:`settings-mode-hint`,children:`How the Cast bench starts when a recorded voice is picked: designable (its embedding, every control works) or an exact clone of the clip (delivery and mood only).`})]}),a&&G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Tag strength`}),G(`span`,{class:`settings-range`,children:[G(`input`,{type:`range`,min:Math.max(1,a.min_scale),max:a.max_scale,step:.1,value:i.tagStrength,onInput:e=>yg({tagStrength:Number(e.currentTarget.value)}),"aria-valuetext":i.tagStrength>1?`${i.tagStrength.toFixed(1)}, tag guidance on`:`1, off`,"aria-describedby":`settings-tags-hint`}),G(`span`,{class:`mono`,children:i.tagStrength>1?i.tagStrength.toFixed(1):`off`})]}),G(`span`,{class:`hint`,id:`settings-tags-hint`,children:`Guidance for lines with nonverbal tags (laugh, sigh…): stronger makes the tags louder. On those lines it replaces voice guidance (the server allows one at a time); 1 turns it off.`})]}),G(Vb,{})]}),o.reRegistered.length>0&&G(`p`,{class:`proj-note`,children:[`Restored after a server restart: `,o.reRegistered.join(`, `),`.`]}),o.issues.length>0&&G(`ul`,{class:`proj-issues`,"aria-label":`Voices that couldn’t be restored`,children:o.issues.map(e=>G(`li`,{children:[`Couldn’t restore `,e]},e))})]})})}var Ub=F(!1),Wb=F(!1),Gb=F(null),Kb={live:`Server`,web:`In this browser`,fixture:`Server · controls off`,offline:`Demo audio`};function qb(e){switch(e.kind){case`web`:return`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`;case`live`:return`A ZONOS server renders every voice; controls and painted words are applied there.`;case`fixture`:return`This server can’t apply controls: renders are sent without them, so you hear each base voice as is.${vc.value?` Its voice embeddings are stand-ins, so saving shaped voices is off.`:``}`;default:return`Demo audio: no ZONOS server answered. Voices and takes are placeholders made in this browser (a babbling synthesizer that follows every control).`}}function Jb({menuitem:e}){let t=L.value;return t?G(`button`,{class:`pill pill-${t.kind}${e?` proj-item`:``}`,role:e?`menuitem`:void 0,"aria-haspopup":`dialog`,"aria-expanded":Wb.value,onClick:()=>Wb.value=!Wb.value,title:`What this studio is connected to`,id:`backend-pill`,children:[G(`span`,{class:`pill-dot`}),G(`span`,{class:`pill-text`,children:Kb[t.kind]})]}):null}var Yb=e=>e?`yes`:`no`;function Xb(){let e=L.value,t=Wb.value,n=N(null),[r,i]=j(null);if(mt(()=>{if(!t)return i(null);let e=document.getElementById(`backend-pill`)?.getBoundingClientRect();i(e?{top:`${e.bottom+6}px`,right:`${Math.max(8,window.innerWidth-e.right)}px`}:{top:`60px`,right:`12px`})},[t]),M(()=>{if(!t||!r)return;let e=document.activeElement,i=e=>{!n.current?.contains(e.target)&&!e.target.closest?.(`#backend-pill`)&&(Wb.value=!1)};return document.addEventListener(`pointerdown`,i),n.current&&Af(n.current),()=>{document.removeEventListener(`pointerdown`,i),e?.focus({preventScroll:!0})}},[t,!!r]),!e||!t||!r)return null;let a=[[`Server`,e.kind===`web`?`this browser`:e.kind===`offline`?`none`:e.server||location.origin],[`Voice bundle`,e.spec.bundle],[`Speech editing`,Yb(e.edit.speech_editing)],[`Speech recognition`,Yb(e.edit.edit_transcribe)],[`Pronunciation input`,Yb(!!e.pron.phoneme_tokens)],[`Nonverbal tags`,Yb(!!e.tags)],[`Projects on the server`,Yb(!!e.projects)]];return Xe(G(`div`,{ref:n,class:`backend-panel`,role:`dialog`,"aria-label":`Connection`,style:r,onKeyDown:jf(()=>n.current,()=>Wb.value=!1),children:[G(`header`,{children:[G(`b`,{children:Kb[e.kind]}),G(`button`,{class:`icon-btn sm`,onClick:()=>Wb.value=!1,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`,size:13})})]}),G(`p`,{children:qb(e)}),G(`dl`,{children:a.map(([e,t])=>G(A,{children:[G(`dt`,{children:e}),G(`dd`,{children:t})]},e))})]}),document.body)}var Zb=`zvs.bannerDismissed`,Qb=F(sessionStorage.getItem(Zb)===`1`);function $b(){let e=L.value;return!e||e.kind!==`offline`&&e.kind!==`fixture`||Qb.value?null:G(`div`,{class:`backend-banner`,role:`status`,children:[G(K,{name:`alert`,size:14}),G(`span`,{children:e.kind===`offline`?`Demo audio: no ZONOS server answered — voices and takes are placeholders.`:`This server can’t apply controls: you hear each base voice as is.`}),G(`button`,{class:`link`,onClick:()=>Wb.value=!0,children:`details`}),G(`button`,{class:`link`,onClick:()=>{sessionStorage.setItem(Zb,`1`),Qb.value=!0},children:`Dismiss for this session`})]})}function ex({onSettings:e}){let[t,n]=j(!1),r=N(null),i=N(null),a=N(null);M(()=>{if(!t)return;i.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>!r.current?.contains(e.target)&&n(!1);return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]);let o=(e=!0)=>{n(!1),e&&a.current?.focus()},s=e=>()=>{o(!1),e()};return G(`div`,{ref:r,class:`top-menu`,children:[G(`button`,{ref:a,class:`icon-btn`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(!t),"aria-label":`More`,title:`More`,children:G(K,{name:`more`})}),t&&G(`div`,{ref:i,class:`top-menu-list`,role:`menu`,"aria-label":`More`,onKeyDown:e=>{e.stopPropagation();let t=[...i.current.querySelectorAll(`[role="menuitem"]:not([disabled])`)],n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)o();else if(e.key===`Tab`)return o(!1);else return;e.preventDefault()},children:[G(Jb,{menuitem:!0}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(e),children:[G(K,{name:`gear`,size:14}),` Project settings…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(a_),children:[G(K,{name:r_.value===`dark`?`sun`:`moon`,size:14}),` `,r_.value===`dark`?`Light theme`:`Dark theme`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(()=>Ub.value=!0),children:[G(`span`,{class:`top-menu-key`,children:`?`}),` Keyboard shortcuts`]})]})]})}var tx=[[`Space`,`play / stop`],[`↵ · ⇧↵`,`Cast: speak the text · new line in it`],[`A / B`,`hear the design / the original voice (Cast)`],[`⌘Z / Ctrl+Z`,`undo`],[`⇧⌘Z / Ctrl+Y`,`redo`],[`1 2 3`,`Cast, Direct, Edit`],[`Arrows`,`nudge the focused control (⇧ for more)`],[`Home / End`,`a slider to its minimum / maximum`],[`0 / Delete`,`reset the focused control`],[`double-click`,`reset a slider or the mood pad`],[`scroll on the Who map`,`pitch (the map focused, or with ⌘ / Ctrl)`],[`+ − Delete`,`a mood landmark: stronger, weaker, off`],[`(S@vQn)`,`X-SAMPA pronunciation in a line (phoneme-token checkpoints); click its IPA chip to edit`],[`/ə/`,`look up the selected words’ pronunciations`],[`<`,`in a text field: nonverbal tag palette (point tag at the caret, span tag around the selected words; NV checkpoint)`],[`‹› Tag`,`Direct: tag the selected words from the paint bar`],[`?`,`this sheet`]],nx=[[`Space`,`play / stop the script`],[`R`,`render the focused line`],[`S`,`star the playing take (the script plays it)`],[`⌘↵ / Ctrl+Enter`,`save the line text while editing`],[`↵ (line text focused)`,`paint the selected words · ⇧← / ⇧→ extend the selection`]],rx=[[`Space`,`play / pause from the cursor`],[`A / B`,`the version / the selected take`],[`⌘↵ / Ctrl+Enter`,`generate takes (also while typing)`],[`K`,`keep the selected take as a new version`],[`⌘Z / ⇧⌘Z`,`step through versions`],[`[ / ] · 0`,`zoom the waveform out / in · fit`],[`⌘-wheel`,`zoom around the pointer`],[`← / →`,`move the cursor 1 s`],[`click a word`,`select it and hear it (pre-roll optional)`],[`← / → (word selected)`,`nudge its edge 10 ms · ⇧ 50 ms`],[`, / .`,`start / end edge of the selected word`],[`Tab / ⇧Tab`,`next / previous word (from the transcript or a word)`],[`↵ · Esc`,`play the word · done`],[`⌥-drag an edge`,`open a gap at a shared boundary`]];function ix(){let e=Ub.value,t=N(null);if(mt(()=>{if(!e)return;let n=document.activeElement;return Ma.value=!0,t.current&&Af(t.current),()=>{Ma.value=!1,(n?.isConnected?n:document.querySelector(`#keys-btn`))?.focus({preventScroll:!0})}},[e]),!e)return null;let n=()=>Ub.value=!1;return G(`div`,{class:`sheet-backdrop`,onClick:n,children:G(`div`,{ref:t,class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,onClick:e=>e.stopPropagation(),onKeyDown:jf(()=>t.current,n),children:[G(`header`,{class:`sheet-head`,children:[G(`h2`,{children:`Keyboard`}),G(`button`,{class:`icon-btn`,onClick:n,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`dl`,{children:tx.map(([e,t])=>G(A,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))}),G(`h3`,{class:`sheet-sub`,children:`Direct`}),G(`dl`,{children:nx.map(([e,t])=>G(A,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))}),G(`h3`,{class:`sheet-sub`,children:`Edit`}),G(`dl`,{children:rx.map(([e,t])=>G(A,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))})]})})}var ax=1e4;function ox(e){let t=new URL(location.href);for(let[n,r]of Object.entries(e))t.searchParams.set(n,r);location.href=t.toString()}function sx(){let[t,n]=j(!1),[r,i]=j(``),[a,o]=j(!1),s=Gb.value,c=va.value;if(M(()=>{let e=setTimeout(()=>n(!0),ax);return()=>clearTimeout(e)},[]),M(()=>{(c||s)&&_o().then(o)},[!!c,!!s]),s)return G(`div`,{class:`empty boot-consent`,role:`dialog`,"aria-labelledby":`boot-consent-title`,children:[G(`h2`,{id:`boot-consent-title`,children:`No server answered`}),G(`p`,{children:`Run the voice engine in this browser? Download ≈ 1.9 GB once; cached in this browser.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>s(!0),children:`Run in this browser`}),G(`button`,{class:`btn`,onClick:()=>location.reload(),children:`Retry the server`}),G(`button`,{class:`btn ghost`,onClick:()=>s(!1),children:`Try it with demo audio`})]})]});if(c){let t=e();return G(`div`,{class:`empty boot-error`,children:[G(`h2`,{children:t?`The in-browser engine couldn’t start`:`Can’t reach the studio server`}),G(`p`,{class:`error-line`,children:[t?``:`Tried ${mo()}: `,c]}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>location.reload(),children:`Try again`}),G(`button`,{class:`btn`,onClick:()=>ox({api:`offline`}),children:`Work offline`}),a&&!t&&G(`button`,{class:`btn`,onClick:()=>ox({api:`web`}),children:`Run in this browser`})]}),G(`form`,{class:`boot-server`,onSubmit:e=>{e.preventDefault(),r.trim()&&ox({api:`live`,server:r.trim()})},children:[G(`label`,{children:[`Server URL`,G(`input`,{class:`input`,type:`url`,placeholder:`https://host:port`,value:r,onInput:e=>i(e.currentTarget.value)})]}),G(`button`,{class:`btn sm`,type:`submit`,disabled:!r.trim(),children:`Connect`})]})]})}let l=ya.value;return G(`div`,{class:`empty`,children:[l?G(su,{d:l}):G(`div`,{class:`loader`}),G(`p`,{children:l&&l.fraction>=1?`Starting the voice engine…`:ba.value}),t&&!l&&G(`p`,{class:`muted small`,children:[`Still waiting for `,mo(),`.`,` `,G(`button`,{class:`link`,onClick:()=>location.reload(),children:`Retry`})]})]})}async function cx(){let e;try{e=await go({confirmWeb:()=>{let{promise:e,resolve:t}=Promise.withResolvers();return Gb.value=e=>{Gb.value=null,t(e)},e}})}catch(e){va.value=e instanceof Error?e.message:String(e);return}ba.value=`Loading voices…`,await bc(),await tg(e),Cc(),eu()}var lx=[{id:`cast`,label:`Cast`,hint:`find or design a voice`},{id:`direct`,label:`Direct`,hint:`perform a script with one or more voices`},{id:`edit`,label:`Edit`,hint:`change words in recorded speech`}];function ux(e){if(!Ma.value&&!Ub.value&&Pa.value?.(e))return;let t=e.metaKey||e.ctrlKey;if(t&&e.key.toLowerCase()===`z`&&!vy(e.target)){e.preventDefault(),Aa.value===`edit`?e.shiftKey?wm():Cm():e.shiftKey?ja.value?.redo():ja.value?.undo();return}if(t&&e.key.toLowerCase()===`y`&&!vy(e.target)){e.preventDefault(),Aa.value===`edit`?wm():ja.value?.redo();return}if(t||e.altKey||vy(e.target))return;let n=e.target?.getAttribute?.(`role`);if(e.key===` `&&!(e.target instanceof HTMLButtonElement)&&n!==`slider`&&n!==`button`)e.preventDefault(),B.value?Ws():Fa.value?.();else if(Aa.value===`cast`&&(e.key===`a`||e.key===`b`))nu(e.key===`a`?`A`:`B`);else if(e.key===`?`&&!Ma.value)Ub.value=!Ub.value;else if(e.key===`Escape`){if(e.defaultPrevented)return;Wb.value&&=(e.preventDefault(),!1)}else/^[1-3]$/.test(e.key)&&!Ma.value&&(Aa.value=lx[Number(e.key)-1].id)}function dx(e){if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=lx[(lx.findIndex(e=>e.id===Aa.value)+(e.key===`ArrowRight`?1:lx.length-1))%lx.length];Aa.value=t.id,e.currentTarget.querySelector(`[data-act="${t.id}"]`)?.focus()}function fx(){`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data?.type===`zvs-update`&&z(`A new version is ready`,`info`,{label:`Reload`,run:()=>location.reload()})})}function px({t:e}){return G(`div`,{class:`toast toast-${e.kind}`,role:e.kind===`error`?`alert`:void 0,children:[G(`span`,{class:`toast-text`,children:e.text}),e.action&&G(`button`,{class:`link toast-action`,onClick:()=>{Ha(e.id),e.action.run()},children:e.action.label}),G(`button`,{class:`icon-btn sm toast-x`,onClick:()=>Ha(e.id),"aria-label":`Dismiss`,children:G(K,{name:`x`,size:12})})]})}function mx(){M(()=>(cx(),fx(),window.addEventListener(`keydown`,ux),()=>window.removeEventListener(`keydown`,ux)),[]),M(()=>{let e=()=>{let e=location.hash.slice(1),t=e===`scene`?`direct`:e;lx.some(e=>e.id===t)?(Aa.value=t,e!==t&&history.replaceState(null,``,`#${t}`)):history.replaceState(null,``,`#${Aa.value}`)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),M(()=>{location.hash.slice(1)!==Aa.value&&history.replaceState(null,``,`#${Aa.value}`)},[Aa.value]);let e=ja.value;return G(`div`,{class:`app`,children:[G(`header`,{class:`topbar`,children:[G(`div`,{class:`brand`,"aria-label":`Zyphra Voice Studio`,children:[G(zb,{size:22}),G(Bb,{height:11}),G(`span`,{class:`brand-sep`,"aria-hidden":`true`}),G(`span`,{class:`brand-product`,children:`Voice Studio`})]}),G(Xg,{}),G(`nav`,{class:`acts`,role:`tablist`,"aria-label":`Acts`,onKeyDown:dx,children:lx.map((e,t)=>G(`button`,{role:`tab`,"data-act":e.id,"aria-selected":Aa.value===e.id,"aria-controls":`stage`,tabIndex:Aa.value===e.id?0:-1,class:`act${Aa.value===e.id?` is-on`:``}`,onClick:()=>Aa.value=e.id,title:`${e.hint} (${t+1})`,children:[G(`span`,{class:`act-n`,children:t+1}),e.label]}))}),G(`div`,{class:`topbar-right`,children:[!Og.value&&G(Jb,{}),G(`button`,{class:`icon-btn`,disabled:!e?.canUndo.value,onClick:()=>e?.undo(),title:`Undo (⌘Z / Ctrl+Z)`,"aria-label":`Undo`,children:G(K,{name:`undo`})}),G(`button`,{class:`icon-btn`,disabled:!e?.canRedo.value,onClick:()=>e?.redo(),title:`Redo (⇧⌘Z / Ctrl+Y)`,"aria-label":`Redo`,children:G(K,{name:`redo`})}),Og.value?G(ex,{onSettings:()=>Na.value=!0}):G(A,{children:[G(`button`,{class:`icon-btn`,onClick:a_,title:r_.value===`dark`?`Light theme`:`Dark theme`,"aria-label":r_.value===`dark`?`Switch to the light theme`:`Switch to the dark theme`,children:G(K,{name:r_.value===`dark`?`sun`:`moon`})}),G(`button`,{id:`keys-btn`,class:`icon-btn`,onClick:()=>Ub.value=!Ub.value,title:`Keyboard shortcuts (?)`,"aria-label":`Keyboard shortcuts`,children:`?`})]})]})]}),G($b,{}),G(`main`,{class:`stage`,id:`stage`,children:L.value?Aa.value===`cast`?G(gy,{}):Aa.value===`direct`?G(ib,{}):G(Rb,{}):G(sx,{})}),G(`div`,{class:`toasts`,onPointerEnter:()=>Ua(!0),onPointerLeave:()=>Ua(!1),children:[xa.value&&G(`div`,{class:`toast toast-dl`,children:G(su,{d:xa.value})}),G(`div`,{class:`toasts-live`,"aria-live":`polite`,children:Ia.value.filter(e=>e.kind!==`error`).map(e=>G(px,{t:e},e.id))}),G(`div`,{class:`toasts-live`,"aria-live":`assertive`,children:Ia.value.filter(e=>e.kind===`error`).map(e=>G(px,{t:e},e.id))})]}),G(ix,{}),G(Xb,{}),G(Hb,{}),G(x_,{}),G(A_,{}),G(Qg,{}),G(Pf,{})]})}Je(G(mx,{}),document.getElementById(`app`)),`serviceWorker`in navigator&&addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{scope:`/`}).catch(()=>{})}); \ No newline at end of file diff --git a/studio/assets/studio-CUnPlHU1.js b/studio/assets/studio-CUnPlHU1.js deleted file mode 100644 index 3f95bd3ae152599ffa7b287633c040b971c0edef..0000000000000000000000000000000000000000 --- a/studio/assets/studio-CUnPlHU1.js +++ /dev/null @@ -1,3 +0,0 @@ -import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./web-engine-DLmQsyPj.js";import{C as p,S as m,_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,m as T,n as E,o as D,p as O,r as ee,s as te,t as ne,u as re,v as ie,x as k,y as ae}from"./latin-500-DPgjq1zP.js";var A,oe,se,ce,le,ue,de,fe,pe,me,he,ge=Symbol.for(`pv`),_e={},ve=[],ye=/^m(i|n|o|s|text|space)$/,be=Array.isArray,xe=ve.slice,Se=Object.assign;function Ce(e){e&&e.parentNode&&e.remove()}function we(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?xe.call(arguments,2):n),Te(e,o,r,i,null)}function Te(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:ge,__v:i||++oe,__i:-1,__u:0};return!i&&A.vnode&&A.vnode(a),a}function j(e){return e.children}function Ee(e,t){this.props=e,this.context=t,this.__g=0}function De(e,t){if(t==null)return e.__&&De(e.__,e.__i+1);for(var n;tt&&ce.sort(de),e=ce.shift(),t=ce.length,8&e.__g&&Oe(e)}finally{(ue=ce.length)&&(le||queueMicrotask)(je)}}function Me(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||ve,v=t.length;for(c=Ne(n,t,_,c,v),d=0;dc?g--:g++,_=1)):(~l||(i>m?g--:i>1]+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i=n.__.length&&n.__.push({}),n.__[e]}function M(e){return tt=1,ft(St,e)}function ft(e,t,n){var r=dt(Xe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):St(void 0,t),function(e){var t=(r.__N||r.__)[0],n=r.t(t,e);et(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ze,!Ze.__f)){Ze.__f=!0;var i=Ze.shouldComponentUpdate;Ze.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,et(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function N(e,t){var n=dt(Xe++,3);!it.__s&&xt(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,Ze.__H.__h.push(n))}function pt(e,t){var n=dt(Xe++,4);!it.__s&&xt(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,Ze.__h.push(n))}function P(e){return tt=5,mt(function(){return{current:e}},[])}function mt(e,t){var n=dt(Xe++,7);return xt(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function ht(){var e;do{for(;e=rt.shift();)try{yt(e)}catch(t){it.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=nt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(yt),t.__h.some(bt),t.__h=[]}catch(n){t.__h=[],it.__e(n,e.__v)}}}while(rt.length)}it.__b=function(e){Ze=null,at&&at(e)},it.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ut&&ut(e,t)},it.__r=function(e){ot&&ot(e),Xe=0;var t=(Ze=e.__c).__H;t&&(Qe==Ze?Ze.__h=[]:(t.__h.some(yt),t.__h.some(bt),Xe=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Qe=Ze},it.diffed=function(e){st&&st(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&vt(nt.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Qe=Ze=null},it.__c=function(e,t){t.some(function(e){try{e.__h.some(yt),e.__h=e.__h.filter(function(e){return!e.__||bt(e)})}catch(t){e.__h=[function(){throw t}]}}),ct&&ct(e,t)},it.unmount=function(e){lt&<(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,vt(rt.push(r))}else yt(r)}catch(e){t=e}}),r.__H=void 0,t&&it.__e(t,r.__v))};var gt=typeof requestAnimationFrame==`function`;function _t(e){var t,n=function(){clearTimeout(r),gt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);gt&&(t=requestAnimationFrame(n))}function vt(e){e!=1&&$e==it.requestAnimationFrame||(($e=it.requestAnimationFrame)||_t)(ht)}function yt(e){var t=Ze,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Ze=t}function bt(e){var t=Ze;e.__c=e.__(),Ze=t}function xt(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!et(t,e[n])})}function St(e,t){return typeof t==`function`?t(e):t}var Ct={bundle:`studio_mect60k_x10`,embedding_dim:192,sets:{identity:{space:`raw`,modes:[`embedding`]},pitch:{space:`raw`,modes:[`embedding`]},accents_en:{space:`raw`,modes:[`embedding`]},accents_l1:{space:`raw`,modes:[`embedding`]},mandarin:{space:`raw`,modes:[`embedding`]},mandarin_hidden:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:15},texture:{space:`raw`,modes:[`embedding`]},room:{space:`raw`,modes:[`embedding`]},delivery:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},expressive:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},disfluency:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},mood:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19,calibration:{default:{valence:4,arousal:4,dominance:4,loudness:2,tempo:4,clarity:2,articulation:4},by_speaker:{},global_default:4}},emotions:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19},emphasis_nv_nodur:{space:`attnres_source`,modes:[`embedding`,`reference`],source_index:19}},directions:JSON.parse(`{"identity.gender":{"set":"identity","space":"raw","kind":"axis","norm":1.8763585090637207,"vector":[-0.145351,-0.037236,-0.231615,0.059623,-0.097463,-0.00438,-0.181256,-0.116112,0.006489,-0.066279,0.028154,-0.106317,-0.027322,-0.212539,0.074007,-0.172004,-0.016244,0.022171,-0.02436,-0.032008,0.004273,0.28592,-0.07487,-0.15942,0.06589,-0.030751,-0.168631,-0.081957,0.10407,0.100738,0.046116,-0.164522,-0.220581,0.284002,-0.196593,-0.085911,-0.01733,0.051308,0.07358,-0.129117,-0.03565,0.011623,-0.023857,-0.121824,0.023647,0.059977,0.331674,-0.03843,0.117079,-0.21018,0.195277,0.076132,-0.362561,-0.006322,-0.067303,0.011311,-0.225437,-0.035123,-0.071207,-0.032307,-0.03488,0.010383,0.067187,-0.092007,0.00216,-0.128227,-0.026748,-0.028467,-0.054922,-0.017777,-0.026001,-0.122082,-0.078555,0.118478,-0.018181,-0.390988,-0.024415,-0.007154,-0.182323,0.043611,0.024019,-0.148823,0.162163,-0.025151,0.189669,-0.083816,-0.327505,0.201499,-0.075665,-0.120443,0.236674,0.178995,-0.150236,0.229471,0.041385,-0.083846,0.164945,0.054651,0.305891,-0.09558,0.013738,-0.07623,-0.074258,0.063161,0.409077,0.068216,-0.135241,-0.024092,0.172651,0.273456,-0.221107,0.073845,0.000888,-0.196625,0.07575,-0.104654,-0.267578,-0.049794,0.13935,0.046093,-0.095611,-0.256105,-0.034189,-0.02879,-0.054839,-0.025545,-0.312504,-0.196937,0.058863,-0.025349,-0.146385,-0.015737,-0.05319,0.004336,0.155696,-0.039206,0.104365,0.026833,-0.044261,-0.009651,0.080538,-0.077517,0.01453,0.19844,-0.125283,0.234411,-0.123545,0.025533,-0.274192,-0.102795,0.147485,0.113269,0.06415,0.159278,0.024446,0.101267,-0.013436,-0.062379,0.233837,-0.195027,0.058858,-0.038064,-0.296664,-0.058662,0.145565,0.04023,0.177497,0.126765,-0.016302,-0.068889,-0.112941,0.000617,-0.074929,-0.024181,0.000709,0.169394,0.113144,-0.004877,-0.023614,-0.003327,-0.153569,-0.084833,-0.278179,-0.12704,0.015236,0.095529,-0.021818,0.152511,-0.101873,-0.152081,0.056203,0.052118]},"identity.age":{"set":"identity","space":"raw","kind":"axis","norm":1.2692716121673584,"vector":[-0.063163,0.025715,0.001118,-0.092943,-0.034933,-0.125913,0.012225,-0.00077,0.111829,-0.102742,-0.156968,-0.099157,-0.176265,-0.086085,0.037962,0.017417,0.090115,-0.033372,-0.074908,0.034763,-0.134577,-0.055955,-0.075105,-0.235013,-0.08009,-0.140841,0.022327,0.064326,-0.124652,-0.027546,-0.015516,0.143755,-0.081223,0.025154,0.101718,-0.018844,-0.003391,-0.109003,0.064622,-0.038087,0.017236,0.089364,-0.088411,-0.111307,-0.049177,0.013226,-0.038468,0.110437,-0.125002,0.002466,-0.060498,0.09326,-0.028549,-0.079882,0.013101,0.055996,0.015359,0.028079,0.229802,0.037334,0.087794,0.052627,0.121179,0.049674,0.039604,-0.177045,0.041455,0.065995,-0.02798,-0.026789,0.067736,-0.081227,-0.018426,0.052456,0.129375,-0.06956,-0.154618,0.094061,0.059635,-0.111231,-0.01689,-0.071005,0.082152,0.080971,-0.083226,0.08902,0.012294,0.140885,0.10317,-0.000385,0.120876,0.105215,0.089404,-0.07404,-0.082182,0.178104,-0.089479,0.016035,-0.062066,0.180699,-0.183151,0.063574,-0.034293,0.005246,-0.075163,0.051745,-0.228758,0.211571,-0.152502,-0.114202,-0.051652,-0.094758,0.183702,0.03155,-0.130021,-0.035248,-0.035422,0.11291,-0.118178,0.067327,0.017983,0.040879,0.128024,-0.044943,0.041002,-0.008232,-0.140447,-0.024046,0.105641,-0.063415,0.193576,0.024707,-0.11114,-0.058181,0.003658,0.019778,0.066323,0.045554,-0.150524,0.021908,0.183713,0.10898,-0.13902,-0.049086,-0.011006,-0.042131,0.02226,0.041943,-0.06328,-0.094408,0.004867,0.056636,-0.076927,0.062896,0.03928,-0.025153,0.011934,0.013235,-0.020326,0.044762,-0.035037,0.079239,-0.061671,0.063522,-0.00436,0.027616,-0.01906,-0.077974,-0.145151,0.252324,-0.042447,-0.090825,-0.010541,-0.012627,0.021808,0.077044,-0.044493,-0.038466,-0.106325,0.123089,0.031957,-0.034745,-0.065978,0.004073,-0.147551,0.042621,-0.014006,0.107974,-0.084259,-0.03464,0.044585,-0.275069]},"pitch.pitch":{"set":"pitch","space":"raw","kind":"axis","norm":0.7707383632659912,"vector":[-0.035456,-0.073794,-0.066747,-0.055367,0.005182,0.001163,0.075087,-0.014287,0.074419,-0.04765,-0.000435,0.05539,-0.002838,-0.001866,-0.007643,-0.019338,-0.113357,0.050418,-0.02785,-0.016621,-0.071575,-0.05209,0.063654,-0.018215,0.117463,0.059105,-0.065627,-0.023973,-0.020141,0.023111,0.103773,0.008534,-0.054626,0.052509,-0.020274,-0.064354,0.062204,0.033091,0.036008,0.052448,-0.063354,-0.083312,-0.000944,0.03266,0.035353,-0.047979,-0.049719,-0.012441,0.13676,-0.01006,0.015244,-0.03394,-0.008387,-0.051855,-0.019421,-0.064304,0.092926,-0.035068,-0.005127,-0.018303,0.074784,-0.004466,0.019366,-0.072268,-0.019801,-0.049896,0.000948,-0.043075,-0.010631,0.077308,-0.079053,0.033575,-0.085403,-0.081065,-0.024808,0.03599,-0.009064,-0.123303,-0.008879,0.000743,0.008401,0.004593,0.041746,-0.040566,0.055092,-0.017771,-0.100209,0.101322,-0.08772,0.067747,0.018121,-0.013698,-0.048914,0.088937,-0.020136,-0.101609,0.060011,0.047623,-0.031592,0.015499,-0.022134,0.123246,0.095097,-0.086202,-0.082677,-0.138884,0.013366,0.02652,0.098987,-0.004062,0.037981,-0.052589,-0.041336,0.031374,-0.001853,-0.029814,-0.016809,0.053698,-0.045353,0.062656,0.011208,0.043389,0.052102,0.162222,-0.099118,-0.062044,-0.039297,0.017345,-0.029279,0.094712,-0.006497,0.013958,0.018832,0.031753,-0.017383,0.071593,0.006318,0.054897,0.153091,0.044923,-0.040949,-0.030165,0.006404,0.002695,-0.003254,0.010518,-0.003883,0.018283,-0.002353,-0.02878,0.102114,-0.020522,0.00704,0.008226,-0.077554,0.061714,0.042735,-0.071792,-0.024929,0.060258,0.072032,0.055215,-0.083507,0.049271,-0.025117,-0.017864,-0.054783,0.041294,0.013468,0.053336,-0.046224,-0.05835,0.027689,-0.077863,0.061828,-0.121625,-0.038384,-0.068991,0.012205,0.08206,0.022452,-0.062281,0.011651,0.025772,-0.021956,0.012874,0.038269,0.03907,0.027826,0.028469,0.032512,0.022173]},"pitch.pitch_range":{"set":"pitch","space":"raw","kind":"axis","norm":0.5263656377792358,"vector":[-0.051322,0.011261,-0.021033,0.033204,0.002038,-0.046124,-0.013902,0.014066,0.072799,-0.065736,0.020775,-0.055353,-0.023786,-0.046455,0.004645,-0.002261,0.033407,-0.035266,-0.008787,0.039011,-0.010103,-0.026044,-0.08473,0.003239,-0.003864,-0.087572,0.061388,0.097881,0.028623,-0.029111,-0.003515,-0.016582,0.004541,0.000962,-0.004749,0.032266,0.03232,0.09381,-7.6e-05,-0.014506,-0.018217,0.022726,0.042261,-0.009174,0.038367,-0.047544,-0.042362,0.031818,-0.026594,-0.002025,-0.012863,0.045951,-0.004664,0.012374,-0.08765,0.0326,-0.056736,-0.017662,0.033801,-0.002818,-0.012227,-0.023888,0.032046,0.00791,-0.022499,-0.023092,-0.005985,-0.023223,-0.0039,-0.005383,0.004148,0.07646,-0.002578,0.010453,0.10306,-0.051988,0.005755,-0.039343,0.074246,-0.030741,-0.008567,-0.039663,0.008626,0.063158,0.009291,-0.003988,-0.00103,-0.040765,0.030876,-0.018829,-0.036452,0.065377,0.013529,0.0064,0.015996,0.038127,0.002603,0.01372,0.034977,0.022849,-0.025725,-0.023018,-0.052385,0.060743,-0.021379,0.018388,0.006304,0.032753,-0.055439,-0.074826,0.016163,-0.043093,0.04005,0.002804,-0.004096,0.060912,-0.061796,-0.037294,0.053518,0.078981,-0.011803,0.001715,-0.001898,-0.009334,0.05115,-0.010233,0.019631,-0.074158,-0.013502,-0.014347,0.098901,0.053461,0.051008,0.03192,-0.018099,0.024168,-0.023063,0.003663,-0.045126,0.039596,0.005756,-0.012701,-0.029812,-0.026187,0.071812,-0.024783,-0.035268,-0.05735,-0.052686,-0.065566,-0.000607,0.089317,0.009077,0.025068,-0.011178,-0.030508,-0.00865,0.045101,-0.023662,0.036244,-0.042542,-0.0551,-0.030425,-0.031683,-0.033685,-0.018356,-0.028677,0.022078,-0.017927,0.032608,-0.011809,-0.024077,-0.009228,-0.013655,-0.043765,-0.002104,-0.040811,0.01291,-0.046852,-0.02188,0.014881,0.025999,0.042839,-0.003209,0.022273,-0.035194,0.070249,-0.008531,-0.009852,0.023761,-0.010462,-0.03714]},"accents_en.british":{"set":"accents_en","space":"raw","kind":"named","norm":1.646016001701355,"vector":[-0.022339,-0.285003,0.031311,0.189842,0.036687,0.040312,-0.047964,0.036006,-0.041669,-0.201873,-0.094198,0.118696,0.040038,0.091439,-0.085005,0.190276,-0.138965,-0.321542,-0.092957,0.240308,-0.021151,-0.096758,-0.027554,-0.124645,0.05587,-0.083096,0.100615,-0.115498,0.07502,-0.281517,0.012712,-0.336685,-0.017609,0.040503,0.17216,0.037001,-0.036805,0.139876,0.127155,0.095273,-0.080436,0.078894,-0.163015,0.002001,-0.108771,-0.192278,-0.252098,0.026945,-0.076806,-0.072829,0.112576,-0.065247,0.254067,-0.207468,0.119722,-0.032825,-0.12768,0.022235,-0.0789,-0.041156,0.213258,0.00023,-0.001934,-0.082781,-0.103124,-0.029441,-0.051975,0.100977,0.009053,-0.115025,0.139497,0.201752,0.056401,-0.041064,0.023667,0.007775,-0.014908,0.068105,0.219601,0.070988,-0.213847,-0.109308,-0.038541,-0.127689,-0.208104,0.024503,-0.062413,-0.140138,0.003794,-0.030369,0.083621,-0.023283,0.086397,-0.103356,-0.017941,0.062643,0.002479,-0.178283,0.229584,-0.117903,-0.070644,0.081242,-0.118112,0.019497,-0.017851,-0.277422,0.101999,-0.049567,0.05012,0.024149,-0.12871,0.000872,0.039609,0.111971,-0.338037,0.113934,0.007461,-0.142536,0.014817,0.058449,-0.016407,0.164828,0.097083,0.166427,0.108926,-0.040193,0.15058,0.053644,0.081356,-0.069371,-0.046198,0.15662,0.013524,-0.062948,-0.083032,0.245468,-0.058217,-0.11444,0.207264,-0.084702,0.024228,-0.112412,-0.051458,0.026169,-0.039526,0.186085,-0.171223,-0.020853,0.069641,0.056344,-0.03032,-0.081166,-0.003098,0.19999,-0.096896,-0.08671,-0.05667,0.059684,-0.021692,0.037009,-0.009625,-0.102626,-0.157979,-0.023599,-0.112832,0.147422,-0.014994,-0.076816,0.018263,-0.024264,-0.062778,-0.14319,0.077452,-0.082209,-0.009312,0.084287,-0.261282,0.024318,0.01213,-0.109042,0.063652,0.292007,-0.056212,-0.138875,0.155889,0.097981,0.000508,-0.038531,-0.046817,-0.129606,0.069177,0.081733]},"accents_en.american":{"set":"accents_en","space":"raw","kind":"named","norm":1.646016001701355,"vector":[0.022339,0.285003,-0.031311,-0.189842,-0.036687,-0.040312,0.047964,-0.036006,0.041669,0.201873,0.094198,-0.118696,-0.040038,-0.091439,0.085005,-0.190276,0.138965,0.321542,0.092957,-0.240308,0.021151,0.096758,0.027554,0.124645,-0.05587,0.083096,-0.100615,0.115498,-0.07502,0.281517,-0.012712,0.336685,0.017609,-0.040503,-0.17216,-0.037001,0.036805,-0.139876,-0.127155,-0.095273,0.080436,-0.078894,0.163015,-0.002001,0.108771,0.192278,0.252098,-0.026945,0.076806,0.072829,-0.112576,0.065247,-0.254067,0.207468,-0.119722,0.032825,0.12768,-0.022235,0.0789,0.041156,-0.213258,-0.00023,0.001934,0.082781,0.103124,0.029441,0.051975,-0.100977,-0.009053,0.115025,-0.139497,-0.201752,-0.056401,0.041064,-0.023667,-0.007775,0.014908,-0.068105,-0.219601,-0.070988,0.213847,0.109308,0.038541,0.127689,0.208104,-0.024503,0.062413,0.140138,-0.003794,0.030369,-0.083621,0.023283,-0.086397,0.103356,0.017941,-0.062643,-0.002479,0.178283,-0.229584,0.117903,0.070644,-0.081242,0.118112,-0.019497,0.017851,0.277422,-0.101999,0.049567,-0.05012,-0.024149,0.12871,-0.000872,-0.039609,-0.111971,0.338037,-0.113934,-0.007461,0.142536,-0.014817,-0.058449,0.016407,-0.164828,-0.097083,-0.166427,-0.108926,0.040193,-0.15058,-0.053644,-0.081356,0.069371,0.046198,-0.15662,-0.013524,0.062948,0.083032,-0.245468,0.058217,0.11444,-0.207264,0.084702,-0.024228,0.112412,0.051458,-0.026169,0.039526,-0.186085,0.171223,0.020853,-0.069641,-0.056344,0.03032,0.081166,0.003098,-0.19999,0.096896,0.08671,0.05667,-0.059684,0.021692,-0.037009,0.009625,0.102626,0.157979,0.023599,0.112832,-0.147422,0.014994,0.076816,-0.018263,0.024264,0.062778,0.14319,-0.077452,0.082209,0.009312,-0.084287,0.261282,-0.024318,-0.01213,0.109042,-0.063652,-0.292007,0.056212,0.138875,-0.155889,-0.097981,-0.000508,0.038531,0.046817,0.129606,-0.069177,-0.081733]},"accents_en.scottish":{"set":"accents_en","space":"raw","kind":"named","norm":1.5993952751159668,"vector":[0.023044,-0.292152,0.083201,0.171497,0.074376,-0.032092,-0.009564,0.066545,-0.091342,-0.186126,-0.062248,0.089452,0.049849,0.197755,-0.049626,0.101676,-0.11466,-0.174779,-0.073255,0.118672,0.03332,-0.214,-0.013037,-0.164662,0.028858,-0.15183,0.108331,-0.191683,-0.036848,-0.184475,0.011906,-0.294046,-0.095363,0.040104,0.168272,0.022068,-0.082319,0.125902,0.057118,0.040786,-0.035154,0.05359,-0.192648,0.051702,-0.012257,-0.172657,-0.264824,0.027778,-0.096675,-0.048947,0.041727,-0.046524,0.285394,-0.223751,0.182209,-0.064925,-0.085722,-0.00507,-0.062273,-0.016637,0.238698,0.066183,0.01825,-0.068078,-0.07158,0.019382,-0.11971,0.090722,-0.034263,-0.183731,0.150524,0.178186,0.061624,-0.120047,0.034812,-0.02156,-0.132952,0.044345,0.264546,-0.000975,-0.182584,-0.078513,0.106223,-0.288324,-0.22504,0.053875,-0.104003,-0.043741,0.082283,-0.100788,0.006423,-0.058727,0.061482,-0.068307,-0.006949,0.10035,-0.013768,-0.202153,0.211064,-0.009171,-0.087958,0.042153,-0.107705,0.057232,-0.025099,-0.204364,0.074695,-0.131771,0.033892,0.077428,-0.182679,-0.065133,-0.019932,0.044552,-0.281493,0.131391,-0.004712,-0.144976,0.005822,0.048555,0.024558,0.144996,0.12236,0.171664,0.113711,0.037777,0.172753,0.058663,0.096942,-0.037692,-0.110044,0.017605,0.058249,-0.100404,-0.098809,0.200898,0.041245,-0.055047,0.089675,-0.14675,0.035656,-0.105808,-0.056788,0.002884,-0.006989,0.093857,-0.071874,0.031808,0.077554,0.107543,0.049787,-0.012125,0.031894,0.118719,-0.020575,-0.054211,-0.01034,0.052236,-0.086494,0.085015,0.101921,-0.066426,-0.155461,-0.043998,-0.078471,0.084417,-0.019423,-0.118028,-0.002183,0.015779,-0.026406,-0.304605,0.147595,-0.104432,0.017476,0.085557,-0.198707,-0.057574,-0.014618,-0.079898,0.028981,0.235765,-0.026519,-0.056621,0.201614,0.030617,0.059268,-0.046761,-0.041409,-0.119244,0.039725,0.045946]},"accents_en.irish":{"set":"accents_en","space":"raw","kind":"named","norm":1.4670429229736328,"vector":[0.112914,-0.288503,0.123549,0.210479,-0.035706,0.031258,-0.043036,0.017812,-0.044327,-0.17898,-0.004128,-0.043491,-0.012307,0.144079,-0.003556,0.112919,-0.098779,-0.188798,-0.028431,0.149651,0.043098,-0.09098,-0.004057,-0.109849,0.082469,0.013699,0.13549,-0.172739,-0.029849,-0.11439,-0.00855,-0.229456,-0.101228,0.190561,0.163376,0.068981,-0.073224,0.099852,0.098766,0.056437,-0.07942,0.009266,-0.191077,-0.013076,-0.087438,-0.03254,-0.238442,-0.189772,-0.115622,0.046546,0.072217,0.008084,0.200424,-0.244457,0.085477,-0.095188,0.012642,-0.027875,-0.070255,-0.063618,0.193425,-0.004022,0.05745,-0.008042,-0.038141,0.035261,-0.077346,0.101824,-0.012823,-0.184287,0.100374,0.194136,0.012189,-0.040289,-0.017836,-0.164719,-0.051997,0.074528,0.122257,-0.097913,-0.234352,-0.054286,-0.030428,-0.194777,-0.251735,0.006673,-0.039853,-0.005002,-0.051096,0.03027,0.071149,-0.101141,0.062956,-0.159008,0.004876,0.07655,0.023467,-0.164275,0.085357,-0.06257,-0.11929,0.023224,-0.048246,0.125983,0.036135,-0.205689,0.157869,-0.112496,0.110528,-0.080345,-0.089801,-0.106967,-0.00756,0.116242,-0.311712,0.081058,0.015956,-0.078374,-0.043582,0.0111,0.040816,0.116711,0.084771,-0.042012,0.167865,0.002513,0.139373,0.00988,0.145686,-0.023848,0.008932,0.122489,0.061347,-0.125978,-0.046024,0.204228,0.011953,-0.064352,0.064368,-0.179718,0.043863,-0.086587,-0.022887,-0.033303,0.056002,0.126262,-0.106404,0.003204,0.097228,0.069307,-0.011616,-0.004846,0.044604,-0.032369,-0.073001,0.051816,-0.070641,0.023064,-0.078643,0.012483,0.026347,-0.075117,-0.160035,-0.019511,-0.083507,0.15098,-0.021395,-0.071549,0.042357,0.021167,-0.034591,-0.198281,0.121783,-0.099499,-0.065079,0.027349,-0.098088,-0.14644,-0.032513,-0.067703,0.012306,0.170408,0.026491,-0.041375,0.182731,0.016732,-0.003258,0.045784,-0.011716,-0.144588,0.005471,0.136491]},"accents_en.australian":{"set":"accents_en","space":"raw","kind":"named","norm":1.6846641302108765,"vector":[-0.007695,-0.278172,0.013884,0.246978,0.037174,0.160327,0.075142,0.047884,0.098446,-0.235003,0.096621,0.023848,-0.042491,0.039472,-0.068406,0.286346,-0.11535,-0.335535,-0.118049,0.274944,-0.044243,-0.160417,-0.06314,-0.133093,-0.052953,-0.061814,0.028925,-0.25995,0.15828,-0.091182,-0.123988,-0.22506,0.008495,0.046644,0.114385,-0.044431,-0.012692,0.24542,0.116404,0.05385,-0.023916,0.109304,-0.021269,-0.053271,-0.001686,-0.108392,-0.299342,0.200249,-0.046739,0.059194,-0.026303,-0.047883,0.223979,-0.180332,0.168434,-0.021314,-0.138181,-0.142385,-0.072969,-0.019889,0.304511,0.08234,0.057797,-0.117814,-0.141828,0.112812,-0.048017,0.060297,0.01633,-0.14722,0.211483,0.243502,0.032984,-0.120496,0.107789,0.023353,0.018736,0.264582,0.182204,-0.01306,-0.00896,-0.106163,0.022881,0.018087,-0.201058,0.032274,0.014522,-0.113582,0.18317,-0.130339,0.050278,0.077079,0.165134,-0.045839,0.094605,0.037653,-0.018598,-0.142169,0.247129,-0.105078,-0.112243,0.015588,0.111147,0.034932,0.023732,-0.014794,0.125039,-0.140065,0.006379,-0.111336,-0.103555,0.072096,0.058954,0.092662,-0.282096,0.074661,0.025196,-0.134496,0.094676,0.092313,0.05649,0.001555,0.080696,0.131897,0.149897,0.025836,0.076886,0.083283,0.122535,-0.002167,-0.022216,0.146606,-0.069963,0.000344,-0.064966,0.173815,-0.053506,-0.080162,0.035035,-0.209768,0.023279,0.032713,0.081107,0.157242,-0.020422,0.103779,0.002353,0.044934,0.120347,0.036426,-0.025068,-0.013699,0.117546,0.091756,-0.108593,-0.120202,0.053543,0.000113,-0.0941,-0.013238,0.079136,-0.1444,-0.035133,-0.037077,-0.133846,0.183572,-0.092085,0.06309,-0.032678,-0.006531,0.018559,-0.247599,0.054414,-0.061243,-0.003818,0.071411,-0.239277,-0.100306,0.054286,-0.092112,0.006612,0.043902,-0.103129,-0.013931,0.257252,-0.051029,0.113547,0.034633,-0.155639,-0.243929,-0.067737,-0.008848]},"accents_en.indian":{"set":"accents_en","space":"raw","kind":"named","norm":1.933874249458313,"vector":[0.00436,0.092828,-0.069635,0.071136,-0.224593,0.09125,-0.017307,0.020625,0.185765,-0.075261,0.232219,0.170147,-0.065187,-0.031745,-0.090065,-0.064402,-0.283637,-0.32792,0.056361,0.247934,-0.146895,-0.014416,0.278522,0.025978,0.110245,0.087921,-0.068149,-0.043693,-0.00171,-0.150115,0.112889,-0.303988,-0.002665,0.049015,0.113694,-0.002281,0.055028,-0.137578,0.154721,0.071739,-0.132274,-0.222059,-0.055155,0.025725,-0.115241,-0.372144,-0.106872,-0.055753,-0.0156,0.053752,-0.089669,-0.034551,0.036048,-0.165935,0.081965,-0.137037,0.028333,0.036282,-0.063178,-0.029807,-0.097787,0.016003,0.03903,-0.180499,-0.09086,-0.17875,0.016707,-0.01799,0.072163,0.045484,0.070579,0.117365,-0.179399,0.069404,-0.27063,0.064462,0.149797,0.164635,0.032486,-0.107199,-0.065146,-0.160601,0.078129,0.057178,-0.040345,-0.104663,0.08582,-0.103677,-0.26575,-0.264641,0.006651,-0.019728,0.104824,-0.041191,0.226018,-0.087756,-0.112727,0.064183,0.165045,-0.021376,0.145753,0.148586,0.074481,-0.208569,-0.179818,-0.171522,0.264164,-0.044008,-0.078227,0.109992,-0.048938,-0.066293,-0.104992,-0.259558,-0.247443,-0.166443,0.048606,0.189554,-0.07696,-0.298702,0.079173,0.222133,0.027272,0.366583,-0.300184,-0.097105,0.028803,0.131934,0.003759,0.093682,0.070849,0.152828,-0.079334,-0.135283,-0.032495,-0.028527,0.066308,-0.03268,0.064852,0.307689,-0.017315,0.014299,0.11187,0.102381,0.09115,0.189907,-0.092809,-0.018404,-0.005354,0.082899,0.113987,0.12021,-0.179296,-0.025989,-0.019416,-0.095439,-0.206092,0.003457,0.1424,0.055848,0.009751,0.141483,-0.016243,0.15107,-0.175047,0.208715,0.008203,0.085683,-0.068767,0.131283,0.071338,-0.081451,-0.031294,0.081905,0.342687,-0.349862,-0.187669,-0.122154,0.056816,-0.075294,-0.096732,-0.057691,-0.014655,0.024322,0.269092,0.048213,-0.115802,0.046878,-0.012264,0.302853,-0.040437,0.33656]},"accents_en.welsh":{"set":"accents_en","space":"raw","kind":"named","norm":1.694260597229004,"vector":[0.060475,-0.354795,0.094562,0.223344,0.099176,0.029016,-0.110509,0.094177,0.063953,-0.215364,-0.117466,0.079404,0.053945,0.035562,0.009083,0.165794,-0.188765,-0.277147,-0.053333,0.17091,-0.055522,-0.126165,-0.029533,-0.106574,0.093718,-0.144952,0.080175,-0.101265,-0.052188,-0.360145,0.119174,-0.367237,-0.102235,0.018869,0.215145,0.081955,-0.063505,0.157351,0.142444,0.035971,0.0005,0.031688,-0.224493,0.035911,-0.026497,-0.224869,-0.268054,0.014149,-0.124744,-0.002643,0.004274,0.013977,0.162404,-0.22435,0.168999,0.017316,-0.131785,-0.012556,-0.060306,-0.047108,0.151576,-0.00897,0.024123,-0.078259,-0.124082,-0.059194,-0.060608,0.061142,-0.060785,-0.221216,0.130401,0.106442,0.064561,-0.119549,0.000321,0.03247,0.00969,0.071011,0.307679,0.066499,-0.185005,-0.126146,0.033073,-0.139965,-0.194154,0.026519,-0.046439,-0.126857,0.053441,-0.10234,0.042318,0.012843,0.070723,-0.050615,-0.04188,0.105883,0.034226,-0.126476,0.295436,-0.100279,-0.088505,0.0877,-0.100424,0.062165,0.039249,-0.177247,0.164702,-0.053907,0.088089,0.009261,-0.161421,-0.05451,0.004319,0.018246,-0.303708,0.042372,0.032325,-0.128738,0.057058,0.138396,-0.050542,0.077175,0.064944,0.159746,0.060279,0.050578,0.167126,0.015214,0.084983,-0.143182,-0.083774,0.081754,-0.014158,-0.01867,-0.098089,0.241168,0.054232,-0.027664,0.20721,-0.051159,0.089749,-0.076306,-0.077432,0.031934,-0.062203,0.051907,-0.232544,-0.05789,0.062775,0.078592,0.007815,-0.135678,0.046334,0.216673,-0.070312,-0.069758,-0.071957,0.090035,0.088826,0.09923,0.073589,-0.119095,-0.182358,-0.044265,-0.02437,0.15339,-0.047237,-0.131812,0.057849,0.045745,-0.036157,-0.135939,0.109621,-0.153439,-0.00268,0.204364,-0.182643,0.028083,-0.017993,-0.055048,0.084101,0.221275,0.001879,-0.155352,0.156973,0.092431,-0.013467,-0.061855,-0.051937,-0.07169,0.074366,0.05273]},"accents_l1.hin":{"set":"accents_l1","space":"raw","kind":"named","norm":1.8782426118850708,"vector":[-0.094225,0.151835,-0.129535,0.065107,-0.105491,-0.00168,-0.15273,0.029907,0.11913,-0.01346,0.177429,0.227382,-0.0984,0.023968,-0.105918,-0.190556,-0.13237,-0.304372,0.006561,0.077153,-0.177968,0.028584,0.194302,0.106413,-0.067094,-0.070858,-0.232981,-0.149926,-0.006173,0.143425,0.15934,-0.306085,0.031721,0.117237,-0.026764,-0.276625,0.029025,-0.312908,0.206962,0.104329,-0.165987,-0.014829,-0.286857,0.067007,-0.088537,-0.265737,-0.209024,0.089309,-0.107002,0.028646,-0.216459,-0.077135,-0.044335,0.074444,0.118911,-0.229572,0.048048,-0.012638,-0.056322,-0.069222,0.02065,0.090223,0.106631,-0.04368,0.0179,-0.200746,-0.090526,-0.050903,0.030384,0.111177,-0.044847,0.114831,-0.010722,0.013626,-0.22479,0.023448,0.097951,0.164729,-0.065722,0.041569,-0.04603,0.0415,0.065391,0.120592,-0.030759,-0.153817,0.113332,-0.219933,-0.303453,-0.25829,-0.019367,-0.04546,0.099142,-0.126884,0.270919,0.088352,-0.068963,0.100242,0.144169,-0.029835,0.251837,0.045053,0.142726,-0.059155,-0.127593,-0.08634,0.148536,0.04472,-0.163799,0.112296,-0.0918,0.009659,0.126371,-0.119861,-0.11657,-0.172284,0.108316,0.073385,-0.05166,-0.231619,0.124314,0.152126,0.00894,0.270903,-0.294978,0.004823,0.023585,0.041462,-0.078208,0.133836,0.090383,0.054082,-0.031477,0.109584,-0.060389,-0.331568,-0.041049,0.119172,0.089826,0.118803,0.006947,0.066277,0.173377,0.048587,-0.029941,0.222556,0.152578,-0.07901,0.175203,0.169953,0.107714,0.136261,-0.054712,-0.005679,0.063173,-0.128332,0.057855,-0.152021,0.05535,0.019668,-0.105389,0.181435,-0.080934,0.116777,-0.26991,0.149057,0.09735,0.058562,-0.146572,0.04678,0.152678,-0.038713,-0.178031,0.085387,0.137005,-0.235554,-0.116681,-0.136726,-0.021232,-0.130438,-0.087804,-0.121391,-0.028483,0.071053,0.011862,0.028273,-0.047307,0.011668,0.116069,0.309512,-0.034415,0.30539]},"accents_l1.spa":{"set":"accents_l1","space":"raw","kind":"named","norm":1.7367653846740723,"vector":[0.104951,0.091091,0.106259,-0.087729,-0.093172,-0.039638,-0.200943,0.098313,-0.121983,-0.10485,0.087534,0.091034,0.020255,-0.072376,-0.010385,-0.337513,-0.00323,-0.161034,0.007606,-0.067034,-0.012409,-0.089056,-0.050393,0.011805,-0.111692,0.002431,0.061583,-0.229874,0.018766,0.063596,0.10948,-0.258169,-0.187802,0.282621,0.085445,-0.024165,-0.129536,0.032212,0.044188,-0.001981,0.002593,-0.143405,-0.027832,0.106866,-0.033388,-0.116122,0.141888,-0.042374,-0.037783,0.301924,0.136818,-0.204755,0.067152,-0.161611,0.067861,0.013071,0.247737,0.216722,0.186936,-0.195568,-0.120664,0.056905,0.022897,0.279555,0.219549,-0.125912,-0.043327,0.079356,-0.0882,0.185005,0.183207,-0.054426,0.084593,0.039233,0.010782,0.076853,0.02487,-0.075078,0.150331,0.081899,-0.236374,0.052506,-0.210462,-0.044586,0.165465,-0.038659,-0.111865,-0.022555,0.111221,-0.054686,-0.025149,-0.072712,0.135321,0.080741,0.001625,-0.066074,0.010451,-0.118236,-0.088448,-0.053581,0.164743,0.041839,0.039843,-0.232835,-0.17292,-0.044589,0.200029,0.116178,-0.033614,0.155122,-0.184718,-0.053132,-0.094628,0.17148,0.207594,-0.119302,-0.053668,0.201353,0.01441,-0.167783,-0.015924,0.194219,-0.015568,0.08815,0.033146,0.025938,0.027589,-0.17195,-0.266149,-0.059472,-0.042021,0.117095,0.121079,-0.013266,0.05941,-0.151384,-0.043579,0.043525,0.332219,0.050505,-0.081072,-0.08301,-0.152383,4.8e-05,-0.04277,-0.032155,-0.062277,0.227797,0.004109,0.012486,0.101669,-0.041417,-0.269481,0.120793,0.015077,-0.026926,-0.220254,-0.061897,-0.044823,-0.070967,-0.060718,-0.161895,-0.022258,0.128124,0.060351,-0.001168,-0.091418,-0.07821,0.11174,-0.153104,-0.234126,-0.037324,-0.21066,-0.09612,-0.109222,-0.165936,-0.10653,0.184289,0.115555,-0.003269,-0.072691,0.225059,0.08047,-0.001912,-0.13926,0.228173,0.034965,-0.033024,0.142239,0.106291,-0.004304,-0.061155]},"accents_l1.fra":{"set":"accents_l1","space":"raw","kind":"named","norm":1.6489053964614868,"vector":[0.115509,0.038507,-0.160571,0.25168,-0.051832,0.107176,-0.03402,0.111554,0.059468,0.047998,-0.216811,0.095619,0.174813,-0.114702,-0.016257,-0.041247,-0.013407,-0.109322,0.110724,-0.120842,0.025099,0.02148,0.186918,0.16602,0.016177,0.045616,0.001491,-0.221922,-0.021058,-0.11744,0.113733,0.020966,0.155126,0.060634,-0.057596,-0.134142,0.072875,-0.015265,0.065835,0.17433,0.119547,-0.011138,-0.041188,0.017808,-0.108685,-0.133808,0.130006,0.139981,-0.052548,-0.25166,0.076716,-0.164455,0.04736,-0.227469,-0.088013,0.024109,0.087894,0.129126,-0.144786,-0.031429,0.128994,-0.24508,0.074436,0.110569,0.070163,0.04782,-0.101337,-0.018511,-0.010367,0.14907,-0.163573,-0.244627,0.0894,0.159082,-0.022087,0.006962,-0.011341,-0.04758,0.287671,0.209201,-0.159891,0.090563,-0.101242,0.037082,0.128318,0.020943,-0.001625,-0.117067,-0.11728,0.003637,-0.023457,-0.191505,-0.012673,-0.068353,0.055023,-0.076684,0.033972,0.02061,0.036431,-0.008467,0.163513,0.133359,-0.113535,-0.213873,0.039598,-0.106536,-0.087595,0.118244,0.011141,0.112163,0.057786,0.173337,0.149979,0.09155,0.061845,0.08135,-0.07402,0.143203,-0.306345,-0.1834,-0.131197,0.142349,0.090068,0.092271,0.088442,-0.108649,0.064914,0.054956,0.153627,-0.183952,0.029093,-0.166048,0.032106,-0.038668,0.004344,0.099334,-0.116082,0.049551,0.18065,0.119916,-0.141589,0.05386,-0.231389,-0.160251,0.094769,0.169656,-0.186086,0.07167,-0.142253,-0.05449,0.098469,0.040925,-0.137791,-0.083095,-0.045016,-0.197182,0.047242,0.079559,-0.021982,-0.042712,0.092767,0.011881,-0.125262,-0.012448,-0.248309,0.158571,0.129386,-0.14982,0.032726,-0.080698,-0.020177,0.077189,0.071099,-0.076078,-0.102284,0.003153,-0.140547,0.113916,0.029267,0.004357,0.088647,0.195567,0.121169,-0.033094,0.13348,0.334481,0.063542,-0.043432,-0.214439,-0.026025,0.051357,0.106763]},"accents_l1.por":{"set":"accents_l1","space":"raw","kind":"named","norm":2.014261245727539,"vector":[-0.100812,0.017003,-0.034826,0.078753,-0.226473,0.095865,0.17389,0.219609,0.032725,-0.185002,-0.12371,-0.164098,0.000854,0.086512,-0.187086,-0.06754,0.157488,-0.354299,0.267604,0.25612,0.081776,0.121603,0.122849,0.281027,-0.092778,-0.121131,0.094879,0.016269,0.122235,0.177247,0.206468,-0.065542,0.018701,0.148402,-0.069173,0.047242,0.140724,0.023863,0.038621,0.187887,-0.109225,0.037449,0.008506,-0.11513,-0.096509,-0.189576,-0.074924,0.050807,-0.042718,0.051166,-0.102043,-0.054831,0.296724,-0.053582,0.203142,-0.025412,0.123474,0.160658,0.165817,-0.016487,0.03842,-0.131921,0.098869,0.115782,-0.105006,0.06991,-0.199714,0.097892,0.098166,0.098476,-0.078738,0.044093,0.082882,0.077323,0.14976,-0.013769,-0.310724,0.190738,-0.053454,0.310025,0.110981,-0.037471,0.102896,-0.267101,0.176047,-0.202169,-0.068164,-0.315148,0.105866,0.161726,0.123961,0.018754,0.120184,-0.050051,-0.115797,-0.084834,0.194959,0.112649,-0.068095,0.050965,0.228357,0.167572,-0.022281,0.044085,-0.367158,0.025941,-0.041875,-0.071769,-0.0448,0.099745,-0.20262,0.248151,-0.340965,-0.317965,0.083766,0.107991,-0.055458,0.153145,-0.088231,-0.129318,-0.126382,0.148352,-0.074072,0.190273,0.035193,-0.205094,0.112132,0.11042,-0.226285,0.119514,-0.083516,-0.106852,0.004924,-0.090829,0.205825,-0.180005,0.10648,0.176769,0.141944,0.220179,-0.103902,0.299889,-0.000528,-0.327567,0.019057,0.133145,-0.089708,0.32744,-0.029253,0.122318,0.200325,-0.308726,-0.057072,0.062486,-0.039971,-0.28528,-0.039549,0.125938,0.0445,0.031343,-0.010496,-0.036801,0.139572,-0.010853,-0.089886,0.01621,-0.084709,-0.197868,0.07372,-0.106435,-0.086518,0.057655,-0.113408,0.058852,0.109403,0.290679,0.097085,-0.193347,0.02052,-0.029414,0.079284,-0.061789,-0.192752,0.021153,-0.05053,-0.062003,0.027503,0.079905,0.103406,-0.093572,0.065346,0.183084]},"accents_l1.deu":{"set":"accents_l1","space":"raw","kind":"named","norm":1.6574718952178955,"vector":[-0.043598,-0.098169,-0.117312,0.07139,-0.187312,0.041628,-0.046844,0.077625,-0.0469,-0.030087,-0.222882,-0.034036,0.262849,0.027338,-0.034683,0.049392,-0.199782,-0.167664,0.066731,-0.041143,0.106481,0.026782,0.033265,0.060859,-0.015291,0.078738,0.00231,-0.012382,0.213001,0.106451,0.177929,-0.204868,0.071414,0.144864,0.155355,-0.210804,0.134587,0.014555,0.069829,0.294278,-0.055753,0.32343,-0.150776,0.001277,-0.077078,-0.198439,-0.099315,-0.049742,-0.327732,-0.06215,0.034353,0.092132,0.003278,0.028828,0.250488,-0.078833,0.049585,-0.041154,-0.182181,-0.157864,0.015911,-0.094506,0.175586,-0.052266,0.044649,-0.035933,-0.020739,-0.099406,-0.0708,0.000316,0.159915,-0.059067,0.190649,-0.012559,0.082592,-0.062674,-0.071291,0.112676,-0.010579,-0.009479,-0.172996,0.051345,0.017159,0.116334,0.00912,-0.032782,0.070822,0.000954,0.087546,0.072727,-0.149909,-0.305828,-0.122101,-0.197533,-0.01262,0.044901,-0.050557,0.073383,0.089414,-0.079069,0.040026,0.170764,-0.027728,0.018143,0.003977,-0.225383,0.099071,-0.046793,0.109662,-0.129803,-0.07886,-0.078636,0.219003,0.044963,-0.182177,-0.194169,0.195214,0.119118,-0.054094,-0.16163,-0.010922,0.032327,-0.213021,0.131629,0.08005,-0.157101,0.165039,-0.040727,-0.003726,-4.1e-05,0.032403,0.160945,0.10347,-0.105637,-0.094965,0.040496,0.069824,-0.058771,0.215605,-0.050139,-0.133273,-0.055626,-0.064415,0.011034,-0.055728,0.207378,-0.018428,0.166948,0.197471,0.092526,-0.042815,-0.024116,-0.144826,0.116607,-0.037198,0.097356,0.114991,-0.067035,0.13789,-0.191385,-0.09471,0.02987,-0.041058,0.033097,-0.181533,0.049522,0.086443,-0.112731,-0.006196,0.166906,0.199148,0.018381,0.02635,0.057679,0.084065,-0.046447,-0.138167,-0.06657,0.006681,0.07469,0.096037,0.11112,-0.194324,0.164853,-0.092011,0.129038,0.01858,-0.042009,0.267593,0.056378,0.057179,0.194923]},"accents_l1.vie":{"set":"accents_l1","space":"raw","kind":"named","norm":2.456273317337036,"vector":[-0.040002,-0.124399,0.011896,-0.031328,-0.060366,0.09168,-0.140528,0.029977,-0.090046,0.092357,-0.19447,-0.047248,0.263782,-0.297212,-0.237761,0.152095,-0.095702,0.143766,0.050433,-0.011179,-0.135305,0.061567,-0.040078,0.062069,0.201743,0.058567,0.278546,-0.354333,0.278096,-0.248364,0.164983,-0.036523,0.056232,-0.119196,0.212248,0.059116,-0.237471,0.433277,0.089501,-0.168109,-0.138989,-0.192355,-0.016931,0.16527,-0.138694,-0.088397,-0.057442,0.235376,0.023462,0.097965,-0.2656,0.032417,0.068134,-0.252127,-0.25955,-0.166268,-0.028892,-0.137361,-0.07305,0.143639,0.115673,0.058465,0.16315,-0.061318,0.00874,-0.219711,-0.093293,-0.024424,-0.19323,0.234176,-0.019696,0.030946,0.095592,0.43669,-0.358631,0.099751,0.027851,0.137731,0.292976,0.254556,-0.052255,-0.120845,0.099451,-0.112632,0.044819,-0.130072,0.083409,0.039474,-0.109658,0.096242,0.004124,0.066536,0.222425,0.182229,0.01202,-0.444215,-0.073449,-0.033145,0.123663,-0.112223,0.090396,0.225505,0.121975,-0.135919,-0.286924,-0.186591,-0.098809,-0.030442,-0.354396,-0.237069,0.031201,-0.054415,0.132087,0.064697,-0.200812,-0.006694,-0.150939,0.199007,0.268932,-0.138518,-0.477976,0.090728,-0.407483,0.282547,0.26904,-0.213917,0.0042,0.166542,0.322277,0.063617,-0.021601,0.040327,-0.004625,0.172052,0.027953,-0.069982,0.170849,-0.27351,0.229908,-0.048806,0.033829,-0.014826,-0.069856,0.119321,0.150564,0.227009,-0.047318,-0.081505,0.110572,0.017432,0.372051,-0.07643,0.118523,0.232678,-0.168794,-0.06651,0.097068,0.019367,0.109237,-0.28086,0.101595,0.126061,0.16428,0.056158,0.051296,-0.203903,-0.093538,-0.079762,-0.141886,-0.238244,0.09055,-0.330764,-0.187544,0.535157,0.068228,-0.194882,-0.072766,0.16877,0.028804,0.112215,0.200202,-0.074342,0.142503,-0.2868,-0.030393,0.32365,0.054822,-0.36891,0.26923,0.168037,0.175113,0.170413]},"accents_l1.pol":{"set":"accents_l1","space":"raw","kind":"named","norm":2.0049545764923096,"vector":[-0.067265,0.041187,-0.009787,0.231494,-0.061184,-0.076705,0.056669,0.079162,0.019501,-0.094284,0.066569,-0.005773,-0.062537,-0.088377,-0.256142,-0.158953,-0.083487,-0.181476,0.160367,0.095784,-0.223042,0.187359,-0.010428,0.110976,-0.006285,-0.106128,0.09748,-0.045717,-0.047229,-0.091015,0.002253,-0.058513,-0.045056,-0.014487,0.043954,-0.035951,-0.121327,-0.259681,0.159674,0.187271,-0.194086,0.112725,-0.025465,0.015127,-0.079332,-0.127029,-0.121465,-0.162006,-0.045483,-0.161442,0.393578,0.110825,0.242772,-0.066652,0.211705,0.215946,0.189611,0.215137,-0.243735,-0.025649,0.146631,0.076317,-0.203267,0.178443,-0.168335,0.012395,-0.213131,0.12464,-0.111582,-0.02739,0.004428,-0.144905,-0.047377,0.006164,0.122846,0.148752,-0.079989,-0.06785,0.011903,0.16646,0.069677,-0.047263,-0.011463,-0.125506,-0.139637,1.1e-05,-0.02989,-0.046004,-0.180761,0.298389,-0.169275,-0.299105,-0.129774,-0.19746,0.063007,-0.172101,-0.209841,-0.015476,0.207686,0.106864,0.148681,0.069929,-0.178195,0.059254,0.028915,-0.318549,0.166088,-0.139615,0.094639,0.345918,-0.036714,-0.035771,-0.194695,-0.262483,-0.197437,0.13041,0.015033,0.054145,0.018529,-0.018074,0.066383,-0.032786,-0.151817,0.06871,-0.144296,-0.10766,0.155008,-0.08432,-0.034763,-0.140136,-0.031141,0.142162,0.096067,-0.074982,-0.023889,-0.082486,-0.079129,0.057738,0.201016,0.022429,0.019423,0.113524,0.011063,-0.246979,-0.116292,0.18057,0.007041,0.195234,0.244772,0.013859,0.081929,-0.159551,-0.152018,-0.112372,0.078805,0.132142,-0.039858,0.344959,-0.052119,-0.009558,-0.151263,-0.044588,-0.071237,0.016419,-0.220376,0.086139,-0.119338,-0.204006,-0.178274,0.164933,-0.301662,0.328862,0.308037,0.028542,-0.007733,0.23975,0.009719,-0.086828,0.081061,0.138821,0.068025,0.027214,-0.26744,-0.097091,-0.117777,0.23313,-0.099161,-0.025128,0.353466,0.083421,-0.005488,0.213405]},"mandarin.cmn":{"set":"mandarin","space":"raw","kind":"named","norm":2.2392897605895996,"vector":[-0.108921,0.179436,-0.056175,0.149681,0.074374,0.004598,-0.210753,0.172479,-0.095906,0.073419,-0.52727,0.023121,0.046068,-0.118781,-0.103468,0.026372,0.09888,0.105814,0.199207,-0.132635,0.005809,0.024837,0.246593,-0.148914,0.239629,0.151292,0.259535,-0.038289,0.092368,-0.230129,0.216822,0.055858,0.0504,-0.016959,0.221458,-0.026729,-0.35489,-0.166528,-0.22054,0.025003,-0.15038,-0.102777,-0.15435,-0.005949,-0.303966,0.030525,-0.016874,0.070823,0.114853,-0.04406,0.099661,0.0554,0.09686,0.086749,0.291011,-0.073136,0.063492,0.102796,-0.256854,0.172562,-0.061355,-0.023175,-0.041036,0.153263,-0.314487,-0.414374,-0.165353,0.198917,-0.086636,0.021892,-0.066041,0.334383,-0.084622,-0.036695,0.060188,0.065045,0.106868,-0.071376,0.131824,0.187437,0.138082,0.15153,0.282983,-0.00293,0.094376,0.002887,-0.031482,0.131883,0.021088,0.599586,-0.060694,-0.470855,-0.088902,-0.082736,-0.094124,-0.179759,0.022545,-0.04753,0.123937,-0.126462,0.000696,0.107905,-0.370273,-0.226093,0.041209,-0.273463,0.213751,-0.009449,0.044847,0.226086,0.168232,-0.017015,-0.020135,0.050181,0.117171,0.212604,0.123792,0.304786,0.278175,-0.031998,-0.228931,0.3672,-0.062848,0.202046,0.014029,-0.166645,-0.071658,-0.034519,-0.158137,0.084577,0.109019,-0.078561,0.126726,0.096855,0.171669,0.075721,0.023424,0.192717,-0.037947,0.071555,0.238061,-0.117358,0.133697,-0.060448,0.125752,0.112059,0.015337,-0.044663,0.106007,0.042954,0.207788,0.162861,-0.277972,-0.019787,-0.105007,0.141428,-0.058199,0.106688,0.107803,-0.115172,0.162839,0.001784,0.07614,-0.023433,0.080253,-0.044697,-0.115972,0.216828,-0.3987,-0.103421,-0.079469,-0.049993,0.149027,0.097345,0.135518,-0.059948,-0.068269,0.11921,-0.007921,-0.253867,0.04294,-0.034677,0.076789,-0.042709,-0.131624,-0.046917,-0.083043,0.059513,0.108337,-0.005547,-0.005535,0.408018]},"mandarin_hidden.cmn":{"set":"mandarin_hidden","space":"attnres_source","kind":"named","norm":0.1931123286485672},"texture.deep":{"set":"texture","space":"raw","kind":"named","norm":0.5765019655227661,"vector":[0.083126,-0.045712,-0.017391,0.054447,-0.036644,0.094359,0.039225,0.018366,-0.049822,0.042236,-0.022708,0.086714,-0.051443,0.033203,0.038265,0.066979,0.041173,-0.0696,0.063549,0.050545,0.086386,0.029497,0.018932,-0.059825,0.012129,-0.017476,0.033982,-0.023535,0.072473,0.01062,-0.010011,-0.06258,0.010724,0.051904,0.08113,-0.000474,0.084091,-0.005664,0.006943,-0.021175,-0.017186,-0.051237,-0.0616,-0.01165,-0.078765,0.015776,-0.015119,-0.008418,-0.07564,-0.008493,-0.015476,-0.060928,0.027622,0.015555,-0.011469,-0.029694,-0.00515,0.035405,-0.054176,0.012599,-0.049803,0.01412,0.026686,-0.038096,0.006708,0.014931,-0.015362,-0.017396,0.016301,0.012914,0.0168,-0.02456,-0.005179,-0.030171,-0.053464,0.012638,0.001154,0.029079,0.037603,-0.072364,-0.039374,0.010471,-0.040323,0.001509,-0.057212,-0.029364,0.097043,0.038886,-0.001757,-0.022528,-0.007795,-0.001465,-0.009863,0.004376,0.023051,-0.003054,-0.061738,-0.07792,0.052716,0.034359,-0.023657,0.017522,-0.096672,-0.034705,-0.003885,-0.056338,0.02083,-0.051279,-0.000467,0.03135,0.006482,-0.000501,-0.028434,0.070274,-0.066485,-0.018159,-0.02857,0.008601,0.022389,-0.079885,0.001989,0.025994,-0.012721,0.02944,0.023831,0.036364,0.062109,0.030506,0.017527,0.049844,0.010251,-0.00989,-0.028422,-0.112894,-0.014337,-0.017284,0.045302,0.021164,-0.044467,0.031952,0.002537,-0.003394,-0.036872,-0.017349,0.017776,0.084397,0.005436,-0.006043,0.029127,-0.033116,-0.019236,-0.045881,0.015544,-0.013371,0.001535,-0.03273,-0.056219,0.056899,0.047787,-0.027682,-0.033093,-0.05848,0.046142,-0.04319,-0.019661,-0.001283,-0.015441,-0.0089,-0.063832,-0.004348,-0.01032,-0.035887,0.026605,0.083559,0.022334,-0.029244,0.054297,-0.021758,-0.031615,-0.014108,0.013379,0.05469,0.037378,-0.054634,-0.084277,0.052846,0.009512,0.026596,0.064852,0.074309,0.040135,-0.006674]},"texture.shrill":{"set":"texture","space":"raw","kind":"named","norm":0.8610222935676575,"vector":[-0.098653,0.009054,0.024251,-0.000411,0.097319,-0.119844,0.052241,0.035051,-0.033395,-0.053334,0.079231,0.036811,-0.001601,-0.096567,0.055255,0.11393,-0.052505,-0.01044,0.027828,-0.107887,-0.010773,-0.030229,0.06564,0.005204,-0.031196,-0.049469,0.017056,0.018619,0.020536,-0.031092,0.046057,0.12704,-0.075975,0.049727,-0.084056,0.057581,0.118865,-0.058827,-0.084911,-0.038951,-0.050325,0.039242,0.075422,0.022394,0.037402,-0.00203,0.016731,0.155318,-0.050363,-0.057559,-0.083531,0.185809,-0.003126,0.036968,-0.036165,0.055198,0.002201,0.019557,0.006437,0.004961,-0.119474,0.012583,-0.075672,0.007093,-0.062574,-0.06776,0.064586,-0.033154,0.092652,0.019823,0.006172,-0.099495,0.038915,0.020797,0.037523,0.080855,-0.042341,0.013091,-0.024503,0.107024,0.058971,-0.051407,-0.038371,0.099842,0.061988,0.10151,-0.019261,-0.009971,0.087239,-0.066048,-0.079678,-0.061469,0.009372,0.046328,0.048333,-0.036662,0.018121,0.031716,-0.080007,-0.046029,-0.00927,0.056084,0.125268,-0.04909,-0.040304,-0.035325,0.023225,-0.019084,0.022515,0.061024,-0.048631,0.07648,-0.003508,-0.057736,0.048207,-0.039867,0.035856,0.043669,0.011207,-0.037977,0.02429,0.125379,0.018345,0.018366,-0.008902,0.062721,-0.012487,0.070354,0.014256,-0.102934,0.016914,0.044755,0.066846,0.003536,-0.05631,-0.069875,-0.105981,0.043863,0.046924,0.08626,-0.082402,0.038941,0.031398,-0.108944,-0.077302,-0.052728,-0.051737,0.031155,-0.059068,-0.005026,0.09985,0.03296,-0.077844,-0.052673,0.086899,0.006912,-0.027177,-0.032418,-0.018329,0.053857,-0.068661,0.088618,0.015753,0.012106,-0.097819,0.077293,0.032636,0.038249,-0.061784,0.052473,-0.039944,0.077104,-0.063031,-0.095209,0.064915,0.041918,0.093121,-0.019221,-0.030222,0.098023,-0.049959,0.008883,-0.001809,-0.016198,0.012604,-0.166197,-0.055203,0.024572,-0.099663,0.09575,-0.008484,0.097987]},"texture.husky":{"set":"texture","space":"raw","kind":"named","norm":0.5867545008659363,"vector":[-0.012865,0.008702,0.003436,-0.059771,0.005715,-0.0056,0.024584,0.013027,0.037862,0.029546,0.000119,-0.011109,-0.059532,0.04348,-0.067457,-0.098879,-0.031263,0.089543,0.018105,-0.082176,-0.019187,-0.081391,0.016701,-0.054115,-0.068344,0.080218,0.026,0.016464,0.004014,0.086359,-0.062569,0.097602,-0.000514,0.01939,0.055375,0.001868,-0.029587,0.067839,0.047989,0.012201,0.0246,-0.003119,-0.005984,0.006094,0.008807,0.010757,0.040537,-0.001475,-0.009215,-0.027148,0.008808,0.041048,0.062132,0.047891,0.021092,0.005458,-0.022269,-0.066923,-0.025565,0.008435,-0.044487,0.045132,-0.029178,0.096975,-0.024089,0.005102,-0.002072,0.052551,-0.007714,0.061235,-0.113777,-0.025175,0.055726,0.059166,0.055428,0.034267,-0.028021,-0.034168,-0.008317,-0.016875,-0.000382,-0.004168,0.108518,-0.006408,-0.003944,-0.005309,-0.012223,0.017367,0.005839,-0.005568,-0.020073,-0.019414,-0.032067,0.002113,0.061265,-0.026636,-0.003597,0.020499,-0.020529,0.092878,-0.007648,-0.058361,-0.014731,-0.048676,0.01898,0.001536,-0.000799,-0.102327,-0.034742,-0.038589,0.010441,-0.00299,-0.033432,0.036758,0.042131,0.077872,0.018446,-0.022485,0.009454,0.026158,-0.016507,0.011723,0.000734,-0.000568,-0.038512,-0.009226,-0.077665,-0.077423,0.042179,-0.007771,-0.010986,-0.006622,-0.018958,-0.003475,-0.005826,-0.079692,0.047934,-0.022862,0.029211,-0.031157,-0.080047,0.016227,0.004492,0.021157,0.002594,0.000903,-0.018801,-0.052594,-0.002335,0.028961,-0.018517,-0.049509,-0.016673,0.006102,0.064718,0.013813,0.102432,-0.013218,-0.085613,0.024788,-0.026293,0.029965,0.017895,0.064067,-0.018363,-0.021045,0.035567,0.089336,0.023795,-0.025847,-0.017816,-0.0126,0.007557,0.001342,0.063813,0.008054,0.028761,-0.069351,-0.059975,-0.029312,-0.014047,-0.055836,0.061972,-0.044773,-0.015325,0.051106,0.017663,-0.082316,0.064866,-0.007112,-0.01927,0.031878]},"texture.raspy":{"set":"texture","space":"raw","kind":"named","norm":0.8753706216812134,"vector":[-0.092398,-0.02677,0.081344,-0.047812,0.133046,-0.073512,-0.106196,-0.042104,0.073107,-0.072423,-0.007399,-0.014431,0.06011,-0.071407,-0.038047,0.00144,0.05813,0.008853,0.041383,-0.045762,-0.095648,-0.119133,0.101911,0.060218,0.08053,-0.030274,0.078624,-0.000682,-0.091644,0.021918,0.040492,0.049786,-0.03015,-0.089655,-0.136242,-0.028479,0.028101,-0.052077,-0.09728,-0.105621,-0.016268,0.105676,0.128658,-0.006713,-0.000705,-0.041877,0.068387,0.121586,0.008839,0.017397,-0.06695,0.040385,0.015007,-0.05746,-0.035755,0.045878,-0.020322,-0.017258,0.095756,-0.109928,0.096122,0.010556,-0.058936,-0.018009,0.009618,0.06393,0.072172,0.010503,-0.033164,0.058032,-0.026321,0.051657,-0.106598,0.029662,-0.035419,0.016221,-0.01695,0.021889,0.016688,0.012881,-0.010214,-0.007853,0.105066,0.021938,0.034985,-0.022989,-0.108163,-0.035223,-0.018776,-0.075593,-0.000149,0.05457,-0.138321,0.066466,-0.056444,-0.018794,0.007677,0.041173,-0.044656,-0.045846,0.056377,0.017029,0.112195,0.041297,-0.047653,-0.040934,-0.02063,-0.054233,-0.052923,0.012896,0.036572,-0.055062,-0.016789,-0.080007,-0.042612,-0.059866,0.031132,0.032522,-0.031955,0.063381,0.095577,-0.018347,0.111427,-0.082832,-0.009695,0.01364,0.002462,-0.099292,-0.035972,-0.097658,0.100292,0.029022,0.032916,0.104702,0.024413,-0.016036,0.04683,-0.009893,0.140884,0.018811,-0.079367,-0.006411,0.10319,-0.035481,-0.004863,-0.116295,-0.004071,-0.092441,-0.013564,-0.041573,-0.020493,0.085256,-0.004645,0.085102,0.010701,-0.010648,0.035097,0.032456,-0.085029,0.033068,0.121562,-0.002625,-0.00905,0.108339,0.158697,-0.112402,0.051404,-0.06231,0.030721,0.041516,0.021032,0.048058,0.025799,-0.045712,-0.006257,0.029005,-0.017559,-0.022676,0.130153,0.143652,0.047394,-0.11211,-0.03784,0.036218,-0.022704,0.005754,-0.046474,0.00232,0.068843,0.088426,0.034422,-0.028863]},"texture.soft":{"set":"texture","space":"raw","kind":"named","norm":0.7225086092948914,"vector":[-0.022581,0.048497,0.009645,-0.034167,-0.071143,0.09039,0.029504,0.018821,0.004282,-0.032923,-0.03254,-0.012492,-0.035304,-0.019366,-0.047357,0.029816,0.034786,0.030787,-0.012025,-0.003484,0.060754,0.075089,0.009377,0.033661,0.07154,0.068848,0.012758,-0.047444,0.018573,0.066384,0.00821,-0.070244,-0.004644,0.005762,0.040515,0.028509,0.000754,-0.040578,0.0285,0.046505,-0.015826,-0.060852,0.010011,0.006128,-0.032981,-0.007516,-0.027463,-0.04623,0.092011,-0.099987,-0.006327,-0.0322,-0.023095,0.004132,-0.001978,-0.048155,0.024987,-0.036444,-0.018999,0.022598,-0.013956,0.035982,-0.026813,0.080011,-0.001209,0.046725,0.00241,0.065849,-0.018658,-0.006923,-0.082582,0.041318,0.033578,0.004113,0.12285,-0.051225,0.033,-0.103849,0.066899,-0.065938,-0.068368,0.110516,-0.045341,0.041681,-0.110907,-0.05415,0.045645,-0.047693,-0.015158,0.002301,0.013445,0.003221,-0.094491,-0.030312,-0.075158,-0.023127,0.059785,-0.059902,0.10828,0.04404,-0.028868,-0.040204,-0.065322,-0.000812,0.035203,-0.050535,-0.053905,0.038224,-0.032828,0.020952,0.000917,-0.036852,0.089435,0.04008,-0.000223,0.01986,-0.042147,0.075887,-0.04691,-0.084628,0.081204,-0.085366,-0.014952,0.096323,-0.078878,-0.067478,0.052828,0.034458,-0.028256,0.054944,-0.036492,-0.077631,-0.00922,-0.061608,-0.015295,0.003234,0.072703,0.063035,0.045604,0.000176,-0.025424,0.00147,0.02204,0.075071,-0.025946,0.046041,0.011387,-0.038102,0.004798,-0.111264,-0.067917,-0.060007,0.08019,-0.028107,-0.023298,-0.027478,0.008483,0.033274,0.089311,-0.056846,0.100519,0.000336,0.041367,0.102614,0.040712,-0.050218,-0.0448,-0.010167,0.015068,-0.017708,0.019157,-0.005602,-0.015173,0.140312,-0.11762,-0.047762,0.057787,-0.014361,0.016412,-0.051089,0.058757,-0.006512,0.044152,0.104587,0.003494,0.010016,0.039835,0.025743,0.053947,0.024962,-0.029353,-0.150157]},"texture.authoritative":{"set":"texture","space":"raw","kind":"named","norm":0.650662362575531,"vector":[-0.021544,-0.031176,-0.029746,0.043648,-0.026964,0.047561,0.022202,0.003552,-0.055207,0.058843,-0.048238,0.082407,0.032682,0.042862,0.027981,0.088302,0.113783,-0.078386,0.046562,0.07237,0.084582,0.013473,-0.018486,-0.080347,0.050792,-0.02907,-0.01658,-0.017982,-0.011607,-0.005825,-0.016126,-0.034737,0.011105,0.042589,0.005386,-0.019292,0.119889,-0.02651,-0.040299,-0.05889,-0.01154,-0.012935,0.021431,-0.045239,-0.076065,-0.002908,0.001959,0.022954,-0.064545,0.026657,-0.030851,-0.074362,-0.064186,0.028752,-0.021603,-0.020301,0.03841,-0.014195,0.018374,-0.031265,0.023558,0.011848,-0.005673,0.007499,0.018472,-0.004734,-0.02651,-0.045357,-0.032103,0.074639,0.085738,0.009879,-0.010263,-0.038301,-0.13952,0.021744,0.004596,-0.004325,-0.00123,-0.035793,-0.019835,0.056687,-0.043295,-0.021021,-0.072403,-0.036784,0.083073,0.009151,-0.033435,-0.028014,0.085543,0.075176,0.001515,0.021391,-0.04863,0.038573,-0.022534,-0.078085,0.025446,0.021201,-0.041863,0.078832,-0.086905,0.029698,-0.034002,0.042367,-0.044087,-0.035893,0.004022,-0.006143,0.002639,-0.068009,-0.049847,0.084119,-0.006074,-0.02646,-0.007624,0.006164,-0.02231,-0.01434,0.058355,-0.013306,-0.005005,-0.008609,0.033602,0.086293,0.086059,0.062236,-0.043199,0.039368,0.034871,0.009702,0.035218,-0.025623,-0.012909,-0.000289,0.050414,0.034219,-0.020719,-0.021962,0.06134,-0.012887,-0.032978,-0.038832,0.013642,0.057895,-0.007708,0.030843,0.024465,0.007944,-0.01521,-0.086025,-0.027524,-0.011879,-0.035908,-0.024519,-0.054647,0.066189,0.02461,0.017895,-0.005192,-0.076882,-0.00434,-0.087648,0.072733,-0.034244,-0.021197,-0.074429,-0.128978,-0.024668,-0.04784,-0.033604,0.078224,0.055429,-0.047149,-0.101401,0.019592,-0.011416,-0.01113,-0.051286,0.074644,0.084582,-0.017746,0.013242,-0.005499,0.021313,-0.028765,0.075278,-0.029408,0.038199,0.031545,-0.065174]},"room.clean":{"set":"room","space":"raw","kind":"axis","norm":0.26050034165382385,"vector":[0.008446,-0.006763,0.002374,-0.019937,0.013268,0.021444,-0.00173,0.028674,-0.021066,-0.017813,0.00474,-0.005991,0.040936,-0.022033,-0.004508,0.009992,-0.009938,-0.01025,0.004168,0.034515,0.041322,-0.029185,-0.031095,-0.049074,0.016056,-0.004164,0.018537,0.016167,-0.014862,-0.000452,0.025788,0.011977,5.3e-05,-0.045829,0.03336,0.012984,0.016565,-0.001852,-0.014461,0.015867,-0.004298,-0.00565,-0.002065,0.009444,0.00635,0.036433,-0.012858,-0.024583,0.016854,-0.016745,0.04549,-0.0045,-0.00768,0.013906,0.000939,0.000514,0.007036,-0.012695,0.008017,-0.010422,-0.021269,-0.02938,0.023065,0.006935,-0.029682,0.002094,-0.002672,-0.015993,0.0046,0.007213,0.007137,-0.0034,0.005338,0.012029,-0.001766,0.008287,0.003137,-0.01076,0.02153,-0.005671,-0.008523,-0.03248,0.028715,-0.005016,0.005573,0.050045,-0.007985,0.018657,-0.011294,-0.00929,0.015441,-0.015257,0.008809,0.00277,0.029603,0.016845,-0.006066,0.030769,0.023431,0.0053,-0.03517,-0.022757,-0.013964,-0.003792,0.019678,0.019728,-0.045376,-0.0075,0.018464,0.017806,0.023565,0.01459,-0.024504,-0.004677,-0.000444,-0.026329,0.019151,-0.017053,-0.024676,-0.000948,0.014518,-0.012129,-0.00595,0.0017,-0.005849,-0.010866,-0.015445,-0.00229,-0.010988,0.058286,-0.004359,0.004769,-0.009167,0.011633,-0.037229,-0.006214,-0.012306,0.036522,0.026994,-0.009355,0.011591,-0.021807,0.018366,0.001452,0.030551,0.009937,0.040415,0.00887,-0.015715,-0.008278,0.004932,-0.002585,0.013071,-0.00515,0.000439,0.007853,0.004122,-0.011491,-0.020314,-0.01901,-0.009357,-0.002129,0.003209,0.0117,0.012296,0.017162,0.026123,0.01011,0.025436,0.012608,-0.017024,-0.000516,-0.022972,-0.023079,0.001656,-0.003542,0.01395,0.015549,0.007971,-0.005955,-0.024876,-0.011921,0.006332,-0.029368,-0.011594,0.005296,0.001081,-0.025453,0.024447,-0.032683,-0.023743,-0.010056]},"delivery.whisper":{"set":"delivery","space":"attnres_source","kind":"named","norm":0.04050905257463455},"delivery.loud":{"set":"delivery","space":"attnres_source","kind":"named","norm":0.017280371859669685},"delivery.tempo":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.027876699343323708},"delivery.pitch":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.03443121165037155},"delivery.conversational":{"set":"delivery","space":"attnres_source","kind":"axis","norm":0.015663625672459602},"expressive.expressive":{"set":"expressive","space":"attnres_source","kind":"axis","norm":0.00408494146540761},"disfluency.disfluent":{"set":"disfluency","space":"attnres_source","kind":"axis","norm":0.007459484040737152},"mood.valence":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.arousal":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.dominance":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.loudness":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.tempo":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.clarity":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"mood.articulation":{"set":"mood","space":"attnres_source","kind":"axis","norm":0.01920250803232193},"emotions.angry":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.024435274302959442},"emotions.sad":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016339104622602463},"emotions.happy":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019105473533272743},"emotions.fearful":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.020554088056087494},"emotions.disgusted":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.02019648253917694},"emotions.surprised":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019633101299405098},"emotions.adoring":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016284888610243797},"emotions.confused":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.02608228661119938},"emotions.content":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.013912038877606392},"emotions.cute":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.027364306151866913},"emotions.desirous":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01784827746450901},"emotions.disappointed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016322800889611244},"emotions.distressed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01893770880997181},"emotions.embarrassed":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.018894311040639877},"emotions.ecstatic":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.025073491036891937},"emotions.guilty":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01523954700678587},"emotions.interested":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.019086483865976334},"emotions.pained":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.020709918811917305},"emotions.proud":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.016622088849544525},"emotions.realizing":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01693662442266941},"emotions.relieved":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01731547713279724},"emotions.serene":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.015665732324123383},"emotions.scared":{"set":"emotions","space":"attnres_source","kind":"named","norm":0.01219755969941616},"emphasis_nv_nodur.emphasis":{"set":"emphasis_nv_nodur","space":"attnres_source","kind":"named","norm":0.008683149702847004}}`),timing:{"delivery.tempo":[[-4,2.881],[-2,2.212],[-1,1.451],[0,1],[1,.779],[2,.63],[4,.549]],"delivery.conversational":[[-4,.958],[-2,.981],[-1,.99],[0,1],[1,1.008],[2,1.065],[4,1.172]],"delivery.whisper":[[0,1],[1,1.076],[2,1.121],[4,1.104]],"delivery.loud":[[0,1],[1,.988],[2,.955],[4,.945]],"disfluency.disfluent":[[-8,.903],[-4,.938],[0,1],[4,1.122],[8,1.323],[16,1.908],[32,2.754]],"expressive.expressive":[[-16,.835],[-8,.891],[-4,.957],[0,1],[4,1.062],[8,1.208],[16,1.497]]},ui:JSON.parse(`{"groups":[{"id":"who","label":"Who","hue":"c1"},{"id":"accent","label":"Accent","hue":"c2"},{"id":"texture","label":"Texture","hue":"c3"},{"id":"room","label":"Room","hue":"c4"},{"id":"delivery","label":"Delivery","hue":"c5"},{"id":"mood","label":"Mood","hue":"c6"}],"controls":[{"id":"gender","group":"who","label":"Gender","type":"bipolar","poles":["masculine","feminine"],"map":{"-":{"identity.gender":-1},"+":{"identity.gender":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.894],[1.0,0.689],[2.0,0.561],[3.0,0.473]],"effect":"±2 flips the gender of every release voice; identity drops to ~0.5"},{"id":"age","group":"who","label":"Age","type":"bipolar","poles":["younger","older"],"map":{"-":{"identity.age":-1},"+":{"identity.age":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.894],[1.0,0.818],[2.0,0.689],[3.0,0.589]],"effect":"±2 moves apparent age by 10-30 years; at −3 male voices start to read female"},{"id":"pitch","group":"who","label":"Pitch","type":"bipolar","poles":["lower","higher"],"map":{"-":{"pitch.pitch":-1},"+":{"pitch.pitch":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[1.0,0.903],[2.0,0.845],[3.0,0.749]],"effect":"±2: about −20 / +40 Hz at the same gender; +3 can flip a female voice"},{"id":"range","group":"who","label":"Intonation","type":"bipolar","poles":["monotone","varied"],"map":{"-":{"pitch.pitch_range":-1},"+":{"pitch.pitch_range":1}},"range":[-3,3],"safe":[-2,2],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[1.0,0.914],[2.0,0.892],[3.0,0.86]],"effect":"±2: F0 spread 2.9 → 2.1 / 4.4 semitones at the same pitch level"},{"id":"deep","group":"texture","label":"Deep","type":"unipolar","map":{"+":{"texture.deep":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.901],[4.0,0.808]],"effect":"×4: deeper and huskier, F0 −17 Hz"},{"id":"bright","group":"texture","label":"Bright","type":"unipolar","map":{"+":{"texture.shrill":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.867],[4.0,0.695]],"effect":"×4: shriller, F0 +40 Hz"},{"id":"husky","group":"texture","label":"Husky","type":"unipolar","map":{"+":{"texture.husky":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.905],[4.0,0.85]],"effect":"×4: husky 0.18 → 0.33"},{"id":"raspy","group":"texture","label":"Raspy","type":"unipolar","map":{"+":{"texture.raspy":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.852],[4.0,0.643]],"effect":"×4: raspy 0.06 → 0.34; changes the voice the most"},{"id":"soft","group":"texture","label":"Soft","type":"unipolar","map":{"+":{"texture.soft":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.881],[4.0,0.761]],"effect":"×4: softer and 7.5 dB quieter"},{"id":"authority","group":"texture","label":"Authority","type":"unipolar","map":{"+":{"texture.authoritative":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":false,"identity":[[0.0,0.946],[2.0,0.875],[4.0,0.765]],"effect":"×4: authoritative 0.54 → 0.78"},{"id":"room","group":"room","label":"Room","type":"bipolar","poles":["phone","studio"],"map":{"-":{"room.clean":-1},"+":{"room.clean":1}},"range":[-4,6],"safe":[-2,4],"collapse":[-6,null],"spannable":false,"identity":[[0.0,0.946],[2.0,0.904],[4.0,0.86],[8.0,0.685]],"effect":"speech over the noise floor 40 dB → 28 (−2) / 58 (+4)"},{"id":"projection","group":"delivery","label":"Projection","type":"bipolar","poles":["whisper","loud"],"map":{"-":{"delivery.whisper":1},"+":{"delivery.loud":1}},"range":[-3,4],"safe":[-1.5,2],"collapse":[-3,null],"spannable":true,"identity":[[0.0,0.946],[1.0,0.9005000000000001],[2.0,0.8160000000000001],[4.0,0.6665]],"effect":"whisper ×2 halves voicing (7% WER); loud ×2 +7 dB, ×4 +16 dB"},{"id":"pace","group":"delivery","label":"Pace","type":"bipolar","poles":["slower","faster"],"map":{"-":{"delivery.tempo":-1},"+":{"delivery.tempo":1}},"range":[-3,3],"safe":[-2,2],"collapse":[-3,null],"spannable":true,"identity":[[0.0,0.946],[1.0,0.907],[2.0,0.866],[4.0,0.753]],"effect":"−1: ×1.45 longer, +2: ×0.63; fast is also louder and higher"},{"id":"chatty","group":"delivery","label":"Read ↔ chatty","type":"bipolar","poles":["read","chatty"],"map":{"-":{"delivery.conversational":-1},"+":{"delivery.conversational":1}},"range":[-5,5],"safe":[-4,4],"collapse":null,"spannable":true,"identity":[[0.0,0.946],[1.0,0.918],[2.0,0.919],[4.0,0.899]],"effect":"+4: spontaneous (hesitation 0.10 → 0.26, less enunciated); −4: careful reading"},{"id":"hesitant","group":"delivery","label":"Hesitation","type":"bipolar","poles":["fluent","hesitant"],"map":{"-":{"disfluency.disfluent":-1},"+":{"disfluency.disfluent":1}},"range":[-8,20],"safe":[-8,8],"collapse":[null,24],"spannable":true,"identity":[[0.0,0.946],[4.0,0.918],[8.0,0.911],[16.0,0.88],[32.0,0.785]],"effect":"+8: pauses and blocks (0.10 → 0.21), ×1.3 longer; +16 drops words"},{"id":"lively","group":"delivery","label":"Liveliness","type":"bipolar","poles":["flat","lively"],"map":{"-":{"expressive.expressive":-1},"+":{"expressive.expressive":1}},"range":[-16,16],"safe":[-8,8],"collapse":null,"spannable":true,"identity":[[0.0,0.946],[4.0,0.917],[8.0,0.908],[16.0,0.865]],"effect":"+8: F0 spread 2.9 → 4.3 st, higher and slower"},{"id":"emphasis","group":"delivery","label":"Emphasis","type":"unipolar","map":{"+":{"emphasis_nv_nodur.emphasis":4.0,"mood.arousal":1.0}},"range":[0,6],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.9],[3,0.892],[4,0.889],[4.5,0.889],[5,0.888],[6,0.886]],"effect":"×4.5 on one word: +6.0 st F0 peak, +65 ms, +1.6 dB; the most prominent word of the line 2 → 36% (middle / final words); the word after +0.5 dB, +2.2 st","default":4.5,"span_gate":{"lead":0.0,"lag":0.0},"span_only":true},{"id":"valence","group":"mood","label":"Valence","type":"bipolar","poles":["negative","positive"],"map":{"-":{"mood.valence":-1},"+":{"mood.valence":1}},"range":[-6,6],"safe":[-4,4],"collapse":null,"spannable":true,"identity":null,"effect":"seed dose 4 (emotion axes, L9.attn)"},{"id":"arousal","group":"mood","label":"Arousal","type":"bipolar","poles":["calm","excited"],"map":{"-":{"mood.arousal":-1},"+":{"mood.arousal":1}},"range":[-6,6],"safe":[-4,4],"collapse":null,"spannable":true,"identity":null,"effect":"seed dose 4 (emotion axes, L9.attn)"},{"id":"angry","group":"mood","label":"Angry","type":"unipolar","map":{"+":{"emotions.angry":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.785],[6,0.606],[8,0.515]],"effect":"×4: heard as angry on 17% of renders (from 0%; MSP-Podcast); more aroused (+0.35 MSP), WER 3.6%"},{"id":"happy","group":"mood","label":"Happy","type":"unipolar","map":{"+":{"emotions.happy":1}},"range":[0,6],"safe":[0,4],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.867],[6,0.74],[8,0.594]],"effect":"×4: heard as happy on 62 / 58% of renders (from 21 / 15%; emotion2vec / MSP-Podcast); more aroused (+0.17 MSP), WER 2.5%"},{"id":"sad","group":"mood","label":"Sad","type":"unipolar","map":{"+":{"emotions.sad":1}},"range":[0,8],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.899],[6,0.866],[8,0.823]],"effect":"×6: heard as sad on 29 / 12% of renders (from 2 / 0%; MSP-Podcast / emotion2vec); less aroused (−0.15 MSP), WER 2.1%"},{"id":"calm","group":"mood","label":"Calm","type":"unipolar","map":{"+":{"emotions.serene":1}},"range":[0,8],"safe":[0,6],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[4,0.899],[6,0.863],[8,0.786]],"effect":"×4: heard as calm on 94% of renders (from 77%; ParaSpeechCLAP); less aroused (−0.14 MSP), WER 0.9%"},{"id":"scared","group":"mood","label":"Scared","type":"unipolar","map":{"+":{"emotions.scared":1}},"range":[0,14],"safe":[0,12],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[10,0.818],[12,0.778],[14,0.734],[16,0.711]],"effect":"×12: heard as fearful on 8% of renders (from 0%; emotion2vec); more aroused (+0.11 MSP), WER 1.5%"},{"id":"confused","group":"mood","label":"Confused","type":"unipolar","map":{"+":{"emotions.confused":1}},"range":[0,4],"safe":[0,3],"collapse":null,"spannable":true,"identity":[[0.0,0.945],[2,0.913],[3,0.877],[4,0.796],[6,0.531],[8,0.375]],"effect":"×3: confused ranks 19 → 10 of 21 styles (ParaSpeechCLAP); less aroused (−0.03 MSP), WER 3.4%"}],"accents":[{"id":"american","label":"North America","tab":"english","region":"north_america","strength":"strong","map":{"accents_en.american":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.854],[1.5,0.808],[2.0,0.758]],"effect":"×1: North America 19 → 44% (British voices 75-88%)"},{"id":"british","label":"England","tab":"english","region":"england","strength":"strong","map":{"accents_en.british":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.871],[1.5,0.84],[2.0,0.804]],"effect":"×1.5: English 40 → 69%"},{"id":"scottish","label":"Scotland","tab":"english","region":"scotland","strength":"faint","map":{"accents_en.scottish":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.873],[1.5,0.822],[2.0,0.749]],"effect":"×1.5: Scottish 0 → 19%"},{"id":"irish","label":"Ireland","tab":"english","region":"ireland","strength":"faint","map":{"accents_en.irish":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.895],[1.5,0.851],[2.0,0.821]],"effect":"×1.5: Irish 0 → 17% (strong on some voices)"},{"id":"welsh","label":"Wales","tab":"english","region":"wales","strength":"strong","map":{"accents_en.welsh":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.866],[1.5,0.813],[2.0,0.762]],"effect":"×1.5: Welsh 19 → 60%; slows speech"},{"id":"australian","label":"Australia","tab":"english","region":"australia","strength":"strong","map":{"accents_en.australian":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.869],[1.5,0.816],[2.0,0.775]],"effect":"×1.5: Oceania 8 → 44%"},{"id":"indian","label":"India","tab":"english","region":"india","strength":"strong","map":{"accents_en.indian":1},"range":[0,2],"safe":[0,1.5],"identity":[[0.0,0.943],[1.0,0.806],[1.5,0.702],[2.0,0.616]],"effect":"×1.5: South Asia 0 → 79%"},{"id":"hin","label":"Hindi","tab":"world","region":"india","strength":"strong","map":{"accents_l1.hin":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: South Asia 82% (LoRA 58%)"},{"id":"spa","label":"Spanish","tab":"world","region":"spain","strength":"strong","map":{"accents_l1.spa":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1: Romance 69% (LoRA 70%)"},{"id":"fra","label":"French","tab":"world","region":"france","strength":"strong","map":{"accents_l1.fra":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Romance 65% (LoRA 64%)"},{"id":"por","label":"Portuguese","tab":"world","region":"portugal","strength":"strong","map":{"accents_l1.por":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1: Romance 66% (LoRA 64%)"},{"id":"deu","label":"German","tab":"world","region":"germany","strength":"strong","map":{"accents_l1.deu":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Germanic 42% (LoRA 24%)"},{"id":"vie","label":"Vietnamese","tab":"world","region":"vietnam","strength":"faint","map":{"accents_l1.vie":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Southeast Asia 21% (LoRA 17%)"},{"id":"pol","label":"Polish","tab":"world","region":"poland","strength":"faint","map":{"accents_l1.pol":1},"range":[0,2],"safe":[0,1.5],"identity":null,"effect":"×1.5: Slavic 20% (LoRA 15%)"},{"id":"mandarin","label":"Mandarin","tab":"world","region":"china","strength":"strong","map":{"mandarin.cmn":1,"mandarin_hidden.cmn":0.3333333333333333},"range":[0,1.5],"safe":[0,1.5],"identity":[[0.0,0.95],[1.0,0.71],[1.5,0.54]],"effect":"embedding ×1.5 + hidden ×0.5: East Asia 58% at 1.8% WER"}],"presets":{"BBC newsreader":{"accent:british":1.5,"authority":3,"room":2},"Elderly Scottish narrator":{"age":1.5,"accent:scottish":1.5,"deep":2,"range":-1},"Young Australian":{"age":-1.5,"accent:australian":1.5,"range":1},"Gravelly old man":{"gender":-1,"age":2,"raspy":3,"deep":2},"Soft-spoken Irish woman":{"gender":1,"accent:irish":1.5,"soft":3},"Indian English caller":{"accent:indian":1.5,"room":-2},"Chatty podcaster":{"chatty":3,"room":1,"lively":4},"Late-night radio":{"deep":2,"room":3,"pace":-0.8,"projection":-0.6}},"who":{"gender":{"control":"gender","logit_per_dose":1.31,"clip_logit":3.0},"age":{"control":"age","center_years":42.0,"years_per_dose":8.7},"landmarks":{"American Female":{"female":0.9944,"age":29.1},"American Male":{"female":0.0013,"age":52.4},"Australian Female":{"female":0.9968,"age":36.1},"British Female":{"female":0.9991,"age":52.6},"British Male":{"female":0.0099,"age":32.1},"David Attenborough":{"female":0.009,"age":72.5},"Dwarkesh":{"female":0.0022,"age":20.4},"German Accent Male":{"female":0.0121,"age":68.4},"Obama Yelling":{"female":0.0151,"age":55.7},"Obama":{"female":0.0018,"age":59.2},"Scottish Female":{"female":0.9992,"age":57.0},"Skyler":{"female":0.9921,"age":23.8}},"note":"audeering/wav2vec2-large-robust-24-ft-age-gender on the first 20 s of each release default voice: P(female) = female/(female+male), age in years. Dose calibration from eval_sweep.json (six voices, embedding mode): 1.31 logits of P(female) per gender dose, 8.7 years per age dose (median per-voice slopes)."},"moods":[{"id":"angry","label":"Angry","control":"angry","valence":0.21,"arousal":1.0,"dose":4,"effect":"×4: heard as angry on 17% of renders (from 0%; MSP-Podcast); more aroused (+0.35 MSP), WER 3.6%"},{"id":"happy","label":"Happy","control":"happy","valence":0.28,"arousal":0.86,"dose":4,"effect":"×4: heard as happy on 62 / 58% of renders (from 21 / 15%; emotion2vec / MSP-Podcast); more aroused (+0.17 MSP), WER 2.5%"},{"id":"sad","label":"Sad","control":"sad","valence":-0.32,"arousal":-0.74,"dose":6,"effect":"×6: heard as sad on 29 / 12% of renders (from 2 / 0%; MSP-Podcast / emotion2vec); less aroused (−0.15 MSP), WER 2.1%"},{"id":"calm","label":"Calm","control":"calm","valence":-0.28,"arousal":-0.69,"dose":4,"effect":"×4: heard as calm on 94% of renders (from 77%; ParaSpeechCLAP); less aroused (−0.14 MSP), WER 0.9%"},{"id":"scared","label":"Scared","control":"scared","valence":-0.09,"arousal":0.53,"dose":12,"effect":"×12: heard as fearful on 8% of renders (from 0%; emotion2vec); more aroused (+0.11 MSP), WER 1.5%"},{"id":"confused","label":"Confused","control":"confused","valence":-0.12,"arousal":-0.15,"dose":3,"effect":"×3: confused ranks 19 → 10 of 21 styles (ParaSpeechCLAP); less aroused (−0.03 MSP), WER 3.4%"}],"preview_text":"Hello there. It's lovely to finally meet you, how have you been?","request_defaults":{"speaker_mode":"embedding","stream_decode":"prefix"},"identity_threshold":0.8}`)},wt={note:`Default release voices with the raw-direction doses their synthetic fixture embeddings carry (embedding = seeded base orthogonal to every raw direction + Σ dose·vector). Gender and age come from ui.who's measured landmarks. Used when the server has no /v2/speakers/{id}/embedding, and as the speaker list when no server answers.`,voices:[{label:`American Female`,priors:{"pitch.pitch":.3}},{label:`American Male`,priors:{}},{label:`Australian Female`,priors:{"accents_en.australian":.8}},{label:`British Female`,priors:{"accents_en.british":.9}},{label:`British Male`,priors:{"accents_en.british":.9,"pitch.pitch":-.8}},{label:`David Attenborough`,priors:{"accents_en.british":1,"texture.raspy":1}},{label:`Dwarkesh`,priors:{"pitch.pitch_range":.6}},{label:`German Accent Male`,priors:{"accents_l1.deu":.9}},{label:`Obama`,priors:{"texture.deep":1.5}},{label:`Obama Yelling`,priors:{"room.clean":-1.5}},{label:`Scottish Female`,priors:{"accents_en.scottish":1,"pitch.pitch":.9}},{label:`Skyler`,priors:{"texture.shrill":.8}}]},F=(e,t,n)=>en?n:e;function Tt(e,t){let n=0;for(let r=0;rMath.sqrt(Tt(e,e));function Dt(e,t){if(!e.length)return 1;if(t<=e[0][0])return e[0][1];for(let n=1;n>>0}function kt(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function At(e){let t=Math.max(e(),1e-12);return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e())}function jt(e,t=1){let n=e.toFixed(t);return e>0?`+${n}`:n===(-0).toFixed(t)?0 .toFixed(t):n}var Mt=()=>Math.random().toString(36).slice(2,10),Nt=3.3,Pt=new Map(wt.voices.map(e=>[e.label,e.priors])),Ft=null,It=[];function Lt(e){if(Ft===e)return It;It=[];for(let t of Object.values(e.directions)){if(!t.vector)continue;let e=Float64Array.from(t.vector);for(let t of It){let n=Tt(e,t);for(let r=0;r1e-6&&It.push(e.map(e=>e/n))}return Ft=e,It}function Rt(e,t,n){let r=kt(Ot(t)),i=e.embedding_dim??0,a=new Float64Array(i);for(let e=0;e({id:`fixture_${p(t.label)}`,label:t.label,source_type:`audio`,scope:`default`,is_default:!0,original_name:`${t.label.replaceAll(` `,``)}.mp3`,created_at:0,has_preview:!0,speaker_modes:[`embedding`,`reference`],embedding_dim:e.embedding_dim,transcript:null,disabled_controls:[]}))}function Bt(e,t){let n=e.collapse;return n&&(n[0]!=null&&t<=n[0]||n[1]!=null&&t>=n[1])?`collapse`:t>=e.safe[0]-1e-9&&t<=e.safe[1]+1e-9?`safe`:`strong`}function Vt(e,t,n){if(t&&n)for(let[r,i]of Object.entries(t))e[r]=(e[r]??0)+i*n}function Ht(e,t,n={}){return t>0?Vt(n,e.map[`+`],t):t<0&&Vt(n,e.map[`-`],-t),n}function Ut(e,t,n){let r=e.directions[t];return!!r&&(e.sets[r.set]?.modes??[]).includes(n)}function Wt(e,t,n){return(`type`in t?[t.map[`+`],t.map[`-`]]:[t.map]).every(t=>!t||Object.keys(t).every(t=>Ut(e,t,n)))}function Gt(e,t,n,r){let i={};for(let n of e.ui.controls){let a=t[n.id]??0;a&&!n.span_only&&Wt(e,n,r)&&Ht(n,a,i)}for(let t of e.ui.accents){let a=n[t.id]??0;a&&Wt(e,t,r)&&Vt(i,t.map,a)}for(let e of Object.keys(i))i[e]=Math.round(i[e]*1e4)/1e4,i[e]||delete i[e];return i}function Kt(e){let t={},n={};for(let[r,i]of Object.entries(e))r.startsWith(`accent:`)?n[r.slice(7)]=i:t[r]=i;return{values:t,accents:n}}var qt=[[0,.95],[1,.87],[1.5,.76],[2,.68]];function Jt(e,t){return Dt(e,t)/(Dt(e,0)||1)}function Yt(e,t,n,r){let i=.95;for(let n of e.ui.controls){let a=t[n.id]??0;a&&n.identity&&Wt(e,n,r)&&(i*=Jt(n.identity,Math.abs(a)))}for(let t of e.ui.accents){let a=n[t.id]??0;a&&Wt(e,t,r)&&(i*=Jt(t.identity??qt,a))}return F(i,0,1)}function Xt(e,t){return e=t+.1?`Same person`:`Close`}function Zt(e){return e>=.65?`leans feminine`:e<=.35?`leans masculine`:`neutral`}function Qt(e){return[{id:`phone`,label:e.poles?.[0]??`phone`,at:e.safe[0]},{id:`podcast`,label:`podcast`,at:Math.round(e.safe[1]/4*10)/10},{id:`studio`,label:e.poles?.[1]??`studio`,at:e.safe[1]}]}function $t(e,t){let n=1;for(let[r,i]of Object.entries(e.timing??{})){let e=t[r];e&&(n*=Dt(i,e))}return n}function en(e,t,n){let r=Float32Array.from(t),i=!1;for(let[t,a]of Object.entries(n)){let n=e.directions[t]?.vector;if(n&&e.directions[t].space===`raw`&&a){for(let e=0;e0||!/^[aeiouy]/i.test(e),pause:t===o-1?.035:0,stress:t===0?1:.55+.3*r()})}}return n}var an=e=>1/(1+Math.exp(-e));function on(e,t,n){let r=e.directions[n]?.vector;if(!r)return 0;let i=0,a=0;for(let e=0;eon(e,r,t),a=i(`identity.gender`),o=i(`identity.age`),s=i(`pitch.pitch`),c=i(`pitch.pitch_range`),l=i(`texture.deep`),u=i(`texture.shrill`),d=i(`texture.husky`),f=i(`texture.raspy`),p=i(`texture.soft`),m=i(`texture.authoritative`),h=i(`room.clean`),g=1,_=1,v=0;for(let[t,n]of Object.entries(e.directions)){if(n.space!==`raw`||!/^(accents_|mandarin\.)/.test(t))continue;let e=i(t);if(Math.abs(e)<.05)continue;let r=Ot(t);g*=1+e*((r&255)/255-.5)*.12,_*=1+e*((r>>8&255)/255-.5)*.14,t.startsWith(`accents_en`)||(v+=Math.abs(e)*.3)}let y=an(a*1.8),b=108*2**(y*.9+s*.11+u*.06-l*.05-Math.max(o,0)*.04+Math.max(-o,0)*.03),x=(1+.17*y-.02*l+.02*u-.015*o)*1,S=2.6*(1+.3*c),C=.04+.07*Math.max(d,0)+.02*Math.max(p,0),w=.06*Math.max(f,0)+.01*Math.max(o,0),T=.9+.05*Math.max(p,0)-.03*Math.max(m,0),E=-1.9*Math.max(p,0)+.5*Math.max(m,0),D=rn(t.text,Ot(t.text)),O=kt(t.seed*7919+13),ee=r=>{let i={};for(let[t,r]of Object.entries(n))e.directions[t]?.space!==`raw`&&(i[t]=r);for(let e of t.spans??[])if(r>=e.start&&r{let n=e.ui.controls.find(e=>e.id===t.control);return!n||[`angry`,`happy`,`sad`].includes(t.control)||!t.dose?[]:Object.entries(n.map[`+`]).map(([e,n])=>({dir:e,val:t.valence*6*n/t.dose,aro:t.arousal*6*n/t.dose}))});D.forEach((e,t)=>{let n=ee(e.start+e.end>>1),r=e=>n[e]??0,i=ie.reduce((e,t)=>e+t.val*r(t.dir),0),a=ie.reduce((e,t)=>e+t.aro*r(t.dir),0),o=r(`delivery.tempo`)+.06*(r(`mood.arousal`)+a)-.08*r(`emotions.sad`),s=o>=0?1+.3*o:1/(1+.45*-o),c=r(`delivery.conversational`),l=Math.max(r(`disfluency.disfluent`),0),u=r(`expressive.expressive`),d=Math.max(r(`delivery.whisper`),0),f=Math.max(r(`delivery.loud`),0),p=r(`mood.valence`)+i,m=r(`mood.arousal`)+a,h=Math.max(r(`emotions.angry`),0),y=Math.max(r(`emotions.happy`),0),w=Math.max(r(`emotions.sad`),0),k=re/s*(1+.012*u)*(e.stress>.9?1.12:.92);k*=1+(O()-.5)*(.12+.03*Math.max(c,0))*(1-F(v,0,.8)),l>0&&O()<.03*l&&(k*=1.4+.05*l);let ae=t/Math.max(1,D.length-1),A=S*(1+.06*u+.15*m+.15*y-.12*w-.05*Math.max(c,0))*((e.stress-.7)*1.4+(O()-.5)*.6)-2.2*ae+.8*f+.25*u+.3*p+1.2*y-w+.5*h,oe=b*2**(A/12),se=nn[e.vowel]??nn.a,ce=x*(1+.015*p+.02*f);te.push({t0:ne,dur:k,f0:oe,slope:(O()-.5)*.08-.04*ae,f:[se[0]*ce*g,se[1]*ce*_,se[2]*ce],voiced:F(1-.3*d,.04,1),gain:10**((E+3.5*f-4.5*d+.6*c+1*m+2*h-1.5*w)/20),tilt:F(T-.06*f-.05*h+.04*d,.55,.995),breath:C+.12*d+.03*h,onset:e.onset}),ne+=k+e.pause*(1/Math.sqrt(s))+(l>0&&O()<.02*l?.18+.2*O():0)});let k=Math.ceil((ne+.25)*tn),ae=new Float32Array(k),A=[];for(let e of t.text.matchAll(/[^\s]+/g)){let t=e.index??0,n=t+e[0].length,r=D.map((e,r)=>e.start>=t&&e.starte>=0);if(!r.length)continue;let i=te[r[0]],a=te[r[r.length-1]];A.push({word:e[0],start:i.t0,end:a.t0+a.dur})}let oe=0,se=[new Float64Array(2),new Float64Array(2),new Float64Array(2)],ce=0,le=te[0]?.f.slice()??[500,1500,2500];for(let e of te){let t=Math.floor(e.t0*tn),n=Math.floor(e.dur*tn),r=[0,0,0].map(()=>({b1:0,b2:0,a0:0}));for(let i=0;i=1&&--oe;let c=2*oe-1;if(oe1-s){let e=(oe-1)/s;c-=e*e+e+e+1}let l=w>.02&&oe<.5&&Math.floor(i*s)&1?1-w*2:1;ce=e.tilt*ce+(1-e.tilt)*c*l;let u=O()*2-1,d=Math.min(1,i/(.018*tn))*Math.min(1,(n-i)/(.04*tn)),f=(ce*6*e.voiced+u*(e.breath+(1-e.voiced)*.5))*d,p=0,m=[1,.55,.28];for(let e=0;e<3;e++){let t=r[e].a0*f+r[e].b1*se[e][0]+r[e].b2*se[e][1];se[e][1]=se[e][0],se[e][0]=t,p+=t*m[e]}e.onset&&i<.03*tn&&(p+=u*.05*(1-i/(.03*tn))),ae[t+i]+=p*e.gain}}let ue=1e-6;for(let e=0;e=0?40+4.5*h:40+6*h)/20),pe=F(-h/2,0,1),me=0,he=0,ge=0,_e=Math.exp(-2*Math.PI*320/tn),ve=Math.exp(-2*Math.PI*3400/tn),ye=kt(t.seed+1);for(let e=0;e0&&(me=_e*(me+t-he),he=t,ge=ve*ge+(1-ve)*me,t=t*(1-pe)+Math.tanh(ge*2.2)*.6*pe),ae[e]=Math.tanh((t+(ye()*2-1)*fe)*1.4)/1.4}return{pcm:ae,words:A}}function cn(e,t,n){if(t===n)return e;let r=new Float32Array(Math.round(e.length*n/t)),i=t/n;for(let t=0;tcn(e.pcm,e.sr,n)),i=Math.round(t*n),a=r.reduce((e,t)=>e+t.length,0)+i*Math.max(0,r.length-1),o=new Float32Array(a),s=0;return r.forEach((e,t)=>{o.set(e,s),s+=e.length+(t\\`,`ʡ`],[`!\\`,`ǃ`],[`|\\`,`ǀ`],[`|\\|\\`,`ǁ`],[`=\\`,`ǂ`],[`:`,`ː`],[`:\\`,`ˑ`],[`_>`,`ʼ`],[`_?\\`,`ˤ`],[`_G`,`ˠ`],[`_h`,`ʰ`],[`_j`,`ʲ`],[`'`,`ʲ`],[`_l`,`ˡ`],[`_n`,`ⁿ`],[`_w`,`ʷ`],["`",`˞`],[`_T`,`˥`],[`_H`,`˦`],[`_M`,`˧`],[`_L`,`˨`],[`_B`,`˩`],[`_"`,`̈`],[`_+`,`̟`],[`_-`,`̠`],[`_/`,`̌`],[`_R`,`̌`],[`_0`,`̥`],[`=`,`̩`],[`_=`,`̩`],[`_\\`,`̂`],[`_F`,`̂`],[`_^`,`̯`],[`_}`,`̚`],[`~`,`̃`],[`_~`,`̃`],[`_A`,`̘`],[`_a`,`̺`],[`_c`,`̜`],[`_d`,`̪`],[`_e`,`̴`],[`_k`,`̰`],[`_m`,`̻`],[`_N`,`̼`],[`_O`,`̹`],[`_o`,`̞`],[`_q`,`̙`],[`_r`,`̝`],[`_t`,`̤`],[`_v`,`̬`],[`_X`,`̆`],[`_x`,`̽`],[`_`,`͡`],[`"`,``],[`%`,``],[`.`,``],[`-\\`,``],[` `,``]],fn=new Map(dn),pn=new Map;for(let[e,t]of dn)t&&!pn.has(t)&&pn.set(t,e);var mn=Math.max(...dn.map(([e])=>e.length)),hn=/[ˈˌ.\s‿]/gu;function gn(e){let t=``;for(let n=0;n0&&!fn.has(e.slice(n,n+r));)r--;r?(t+=fn.get(e.slice(n,n+r)),n+=r):t+=e[n++]}return t.normalize(`NFC`).replace(hn,``)}function _n(e){let t=[];for(let n of e.normalize(`NFC`).replace(hn,``)){let e=pn.get(n);if(e!==void 0)t.push(e);else for(let e of n.normalize(`NFD`))t.push(pn.get(e)??e)}let n=``;return t.forEach((e,r)=>{if(e===`_`){let n=`_`+t.slice(r+1,r+mn).join(``);for(let t=Math.min(mn,n.length);t>1;t--)if(fn.has(n.slice(0,t))){e=`͡`;break}}n+=e}),n}function vn(e,t){let n=t?new Set(t.symbols):null,r=[],i=[],a=0;for(;a=0&&s!n.has(e)):[],d={start:a,end:o+1,body:c,ipa:l,unknown:u,empty:!l};r.push(d),d.empty?i.push({at:a,text:`“()” at ${a+1} is empty`}):u.length&&i.push({at:a,text:`(${c}): no token on this model for ${u.map(e=>`“${e}”`).join(` `)}`}),a=o+1}return{groups:r,issues:i}}function yn(e,t){if(!t)return null;let{issues:n}=vn(e,t);return n.length?`Pronunciation: ${n.map(e=>e.text).join(`; `)}.`:null}function bn(e,t){if(!t)return{text:e,map:e=>e};let{groups:n}=vn(e,t);if(!n.length)return{text:e,map:e=>e};let r=``,i=0,a=[];for(let o of n){o.start>i&&(a.push({d0:i,d1:o.start,s0:r.length,s1:r.length+o.start-i,group:!1}),r+=e.slice(i,o.start));let n=o.empty?e.slice(o.start,o.end):t.open_marker+o.ipa+t.close_marker;a.push({d0:o.start,d1:o.end,s0:r.length,s1:r.length+n.length,group:!o.empty}),r+=n,i=o.end}return a.push({d0:i,d1:e.length,s0:r.length,s1:r.length+e.length-i,group:!1}),r+=e.slice(i),{text:r,map:(e,t)=>{for(let n of a)if(!(en.d1))return n.group?e===n.d0?n.s0:e===n.d1?n.s1:t<0?n.s0:n.s1:n.s0+(e-n.d0);return r.length}}}var xn={ʃ:`sh`,ʒ:`zh`,θ:`th`,ð:`th`,ŋ:`ng`,ʧ:`ch`,ʤ:`j`,ə:`i`,ɪ:`i`,i:`ee`,ɛ:`e`,æ:`a`,ɑ:`a`,ɒ:`o`,ɔ:`o`,ʊ:`u`,u:`oo`,ʌ:`u`,ɜ:`er`,ɝ:`er`,ɚ:`er`,ɹ:`r`,ɾ:`t`,j:`y`,ɡ:`g`,ɫ:`l`,ʔ:``,ɐ:`a`,ø:`eu`,œ:`eu`,y:`u`};function Sn(e){let t=``;for(let n of e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/t͡?ʃ/g,`ʧ`).replace(/d͡?ʒ/g,`ʤ`)){let e=xn[n];e===void 0?/[a-z]/.test(n)&&(t+=n):t+=e}return t||`uh`}function Cn(e,t=[]){let{groups:n}=vn(e,null),r=``,i=0;return n.forEach((n,a)=>{n.empty||(r+=e.slice(i,n.start)+(t[a]?.trim()||Sn(n.ipa)),i=n.end)}),r+e.slice(i)}var wn=[`laugh`,`breath`,`sigh`,`cough`,`panting`,`shouting`,`crying`],Tn=[`shouting`,`crying`],En={laugh:{label:`laugh`,weak:!1,note:`a laugh; clearest with tag strength above 1`},breath:{label:`breath`,weak:!1,note:`an audible breath`},sigh:{label:`sigh`,weak:!1,note:`a sigh`},cough:{label:`cough`,weak:!0,note:`weak: the model barely reacts to it (measured ≈ no effect)`},panting:{label:`panting`,weak:!1,note:`panting breaths`},shouting:{label:`shouting`,weak:!0,note:`weak: measured no better than without the tag`},crying:{label:`crying`,weak:!0,note:`weak: measured no better than without the tag`}},Dn=/<(\/?)([a-z]+)\s*(\/?)>/g,On=new Set(wn);function kn(e,t=On){let n=[],r=[],i=[],a=[];for(let o of e.matchAll(Dn)){let[e,s,c,l]=o;if(!t.has(c)||s&&l)continue;let u={start:o.index,end:o.index+e.length,name:c,kind:l?`point`:s?`close`:`open`};if(u.kind===`point`)n.push(u);else if(u.kind===`open`)a.push(u);else{let e=a.findLastIndex(e=>e.name===u.name);if(e<0){i.push({at:u.start,text:` closes no <${u.name}>`});continue}let[t]=a.splice(e,1);n.push(t,u),r.push({name:u.name,open:t,close:u})}}for(let e of a)i.push({at:e.start,text:`<${e.name}> is never closed`});return n.sort((e,t)=>e.start-t.start),{tokens:n,spans:r,issues:i}}var An=e=>kn(e).tokens.length>0;function jn(e){let{tokens:t}=kn(e);if(!t.length)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start),r=i.end;return(n+e.slice(r)).replace(/ {2,}/g,` `).replace(/ ([,.!?;:])/g,`$1`).trim()}var Mn=e=>!!e&&/[\p{L}\p{N}'’)]/u.test(e);function Nn(e,t,n){let r=`<${n}/>`,i=Mn(e[t-1])||/[,.!?;:]/.test(e[t-1]??``)?` `:``,a=Mn(e[t])?` `:``,o=i+r+a;return{start:t,end:t,insert:o,caret:t+o.length}}function Pn(e,t,n){let r=Math.max(0,Math.min(t,n)),i=Math.min(e.length,Math.max(t,n));for(;rr&&/\s/.test(e[i-1]);)i--;for(;r>0&&Mn(e[r-1]);)r--;for(;i${e.slice(i,a)}`;return{start:i,end:a,insert:o,caret:i+o.length}}var In=e=>e.replace(/ {2,}/g,` `).replace(/^ | $/g,``);function Ln(e,t){let{spans:n}=kn(e),r=t.kind===`point`?null:n.find(e=>e.open.start===t.start||e.close.start===t.start);return In(r?e.slice(0,r.open.start)+e.slice(r.open.end,r.close.start)+e.slice(r.close.end):e.slice(0,t.start)+e.slice(t.end))}function Rn(e,t){let n=e.slice(t.open.end,t.close.start);return e.slice(0,t.open.start)+`<${t.name}/> `+n.replace(/^ /,``)+e.slice(t.close.end)}function zn(e,t){let n=e.slice(0,t.start)+e.slice(t.end),r=t.start,i=r;for(;i${n.slice(a,o)}`+n.slice(o))}var Bn=/[\u2018\u2019\u201b\u02bc]/g,Vn=/[^\p{L}\p{N}']+/gu,Hn=/[\u3005\u3007\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\u3040-\u30ff\u31f0-\u31ff\uff66-\uff9f]+/gu,Un=new Intl.Segmenter(`und`,{granularity:`word`}),Wn=/[\p{L}\p{N}']/u;function Gn(e){let t=[];for(let n of e.matchAll(Hn))for(let e of Un.segment(n[0]))e.isWordLike&&t.push(n.index+e.index);return t}function Kn(e){return e.replace(Bn,`'`).replace(/_/g,` `).toUpperCase().replace(Vn,` `).trim().split(/\s+/).filter(Boolean).flatMap(e=>{let t=new Set([0,e.length,...Gn(e)]);for(let n of e.matchAll(Hn))t.add(n.index+n[0].length);let n=[...t].sort((e,t)=>e-t);return n.slice(1).map((t,r)=>e.slice(n[r],t))})}function qn(e,t){let n=new Set(Gn(e));for(let t of e.matchAll(Hn)){let r=t.index+t[0].length,i=e.slice(r).search(Wn);i>=0&&n.add(r+i)}let r=[...new Set([0,...n,e.length])].sort((e,t)=>e-t),i=[];for(let n=0;n+1e.startsWith(Jn),Qn=``,$n=e=>e.startsWith(Qn);function er(e,t){let n=new Map;for(let t of kn(e).tokens)n.set(t.start,{end:t.end,token:Qn+e.slice(t.start,t.end)});if(t)for(let t of vn(e,null).groups)t.empty||n.set(t.start,{end:t.end,token:Jn+t.ipa+Yn});if(e.includes(Jn))for(let t of e.matchAll(Xn))n.set(t.index??0,{end:(t.index??0)+t[0].length,token:t[0]});if(!n.size)return[...e.matchAll(/\S+/g)].flatMap(e=>qn(e[0],e.index??0));let r=[],i=0;for(;ie.tokens)}function nr(e){return er(e,!1).map(t=>e.slice(t.from,t.to))}function rr(e,t){let n=new Map;t.forEach((e,t)=>{let r=n.get(e);r?r.push(t):n.set(e,[t])});let r=(t,r,i,a)=>{let o=t,s=i,c=0,l=new Map;for(let u=t;u=a)break;let e=(l.get(r-1)??0)+1;t.set(r,e),e>c&&(o=u-e+1,s=r-e+1,c=e)}l=t}return[o,s,c]},i=[],a=[[0,e.length,0,t.length]];for(;a.length;){let[e,t,n,o]=a.pop(),[s,c,l]=r(e,t,n,o);l&&(i.push([s,c,l]),ee[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let o=[],[s,c,l]=[0,0,0];for(let[e,t,n]of i)s+l===e&&c+l===t?l+=n:(l&&o.push([s,c,l]),[s,c,l]=[e,t,n]);l&&o.push([s,c,l]),o.push([e.length,t.length,0]);let u=new Int32Array(e.length).fill(-1),d=[],f=0,p=0;for(let[e,t,n]of o){(f=0&&(i[e]=!1);for(let t of n)for(let n=0;t.i1+ne.tokens.map(()=>[e.from,e.to]))}function or(e,t,n,r,i,a,o){let s=n===null?0:(Math.min(n,e)+e)/2,c=r===null?o/a:(t+Math.max(r,t))/2,l=Math.floor(Math.max(e-i,s)*a+1e-6);n!==null&&l/ar+1e-6&&(u=Math.max(Math.floor(r*a+1e-6),Math.round(t*a))),l=Math.min(o-1,Math.max(0,l)),[l,Math.max(l+1,Math.min(o,u))]}function sr(e,t,n){let r=n.minGapFrames??5,i=e.flatMap(e=>e.tokens.map(t=>({t,w:e}))),a=i.map(e=>e.t),o=tr(t,n.groups),s=Math.ceil(n.duration*n.frameRate-1e-6),{changes:c,equalMap:l}=rr(a,o),u=ar(t,n.groups),d=[],f=[];for(let e of c){let{i1:a,i2:o,j1:c,j2:l}=e,p,m,h,g;if(a!==o){p=i[a].w.start,m=i[o-1].w.end;for(let e=a-1;e>=0&&!h;e--)i[e].w!==i[a].w&&(h=i[e].w);for(let e=o;e0?i[a-1].w:void 0,g=ae.tokens.forEach(()=>a.push(t)));let o=ar(n,r),s=[];for(let i of e){let e=lr(a.slice(i.i1,i.i2),e=>e,e=>t[e].word),c=e=>n.slice(e[0],e[1]),l=lr(o.slice(i.j1,i.j2),e=>e[0],r?e=>c(e).replace(/\(([^()]*)\)/g,(e,t)=>`/${gn(t)}/`):c);i.i1!==i.i2&&i.j1!==i.j2?s.push(`${e} → ${l}`):i.j1===i.j2?i.i1!==i.i2&&s.push(`− ${e}`):s.push(`+ ${l}`)}let c=s.join(` · `);return c.length>i?c.slice(0,i-1)+`…`:c}function dr(e,t){if(e===t)return 1;let n=e.length,r=t.length;if(!n||!r)return 0;let i=Array.from({length:r+1},(e,t)=>t);for(let a=1;a<=n;a++){let n=[a];for(let o=1;o<=r;o++)n[o]=Math.min(i[o]+1,n[o-1]+1,i[o-1]+(e[a-1]===t[o-1]?0:1));i=n}return 1-i[r]/Math.max(n,r)}var fr=.6;function pr(e,t,n){if(n=n.filter(t=>!$n(e[t])),!n.length)return[];let r=tr(t),{equalMap:i}=rr(e,r),a=new Set;for(let e of i)e>=0&&a.add(e);let o=n.every(t=>e[t].length<=2),s=[];for(let t of n){if(i[t]>=0||!o&&e[t].length<=2)continue;let n=0;for(let e=t-1;e>=0;e--)if(i[e]>=0){n=i[e]+1;break}let c=r.length;for(let n=t+1;n=0){c=i[n];break}let l=-1,u=fr,d=Zn(e[t]);for(let i=n;i=u&&(u=n,l=i)}l>=0?a.add(l):s.push(t)}return s}function mr(e,t,n,r=!1){let i=e.flatMap(e=>e.tokens.map(()=>e)),{equalMap:a}=rr(e.flatMap(e=>e.tokens),tr(t,r));return n.map(e=>{let t=new Set;for(let n of e.changes)for(let e=n.j1;e{let i=(n.start+n.end)/2;i>=e.start&&i=0&&t.add(a[r])}),[...t].sort((e,t)=>e-t)})}function hr(e,t,n,r){let i=(t,n)=>{if(t<=0)return 0;if(t>=r)return r;let i=e.findIndex(e=>e.start=0){let t=e[i+n],a=n<0?e[i].start:e[i].end;return t?(a+(n<0?t.end:t.start))/2:n<0?0:r}let a=e.filter(e=>e.end<=t).pop(),o=e.find(e=>e.start>=t);return a&&o?(a.end+o.start)/2:t},a=[];for(let[e,r]of t){let t=i(e-n,-1),o=i(r+n,1),s=a[a.length-1];s&&t<=s[1]?s[1]=Math.max(s[1],o):a.push([t,o])}return a}var gr=44100,_r=new Map,vr=new Map,yr=e=>Math.round(e*1e3);function br(e,t){let n=yr(t);return e.get(n)??e.get(n-1)??e.get(n+1)}var xr=/\ue000([^\ue000\ue001]*)\ue001/g,Sr=e=>e.replace(xr,(e,t)=>Sn(t));function Cr(e,t,n){let r=e=>Sr(e).replace(/[\ue000\ue001]/g,``);_r.set(yr(e.length/t),{...n,text:r(n.text),words:n.words.map(e=>({...e,word:r(e.word)})).filter(e=>e.word)})}function wr(e){let t;try{t=D(h(e))}catch{throw new v(400,`audio_base64 could not be decoded (the fixture reads WAV only).`)}return{...t,duration:t.pcm.length/t.sr}}function Tr(e,t){let{promise:n,resolve:r,reject:i}=Promise.withResolvers();t?.aborted&&i(new DOMException(`Aborted`,`AbortError`));let a=setTimeout(r,e);return t?.addEventListener(`abort`,()=>{clearTimeout(a),i(new DOMException(`Aborted`,`AbortError`))}),n}var Er=(e,t)=>e.map((e,n)=>({word:e.word,start:Dr(e.start),end:Dr(e.end),confidence:t(n),tokens:tr(e.word)})),Dr=e=>Math.round(e*1e3)/1e3;function Or(e,t,n){let r=Math.round(t*.01),i=Math.floor(e.length/r),a=new Float32Array(i),o=1e-6;for(let t=0;tc&&a[l]tr(e).join(``).length+.6),f=d.reduce((e,t)=>e+t,0),p=[c],m=0;for(let e=0;e{let n=p[t],r=p[t+1];for(;nn+2&&a[r-1]s);return{word:e,start:Dr(n*.01),end:Dr(r*.01),confidence:Math.round((.55+.4*(i/Math.max(1,r-n)))*100)/100,tokens:tr(e)}})}var kr=`so this is a quick recording to try the editor and see how it copes when a few words change in the middle of a sentence then I keep talking for a little while longer so there is enough audio to work with and maybe a second idea at the end`,Ar={a:`the`,the:`a`,to:`too`,for:`four`,I:`eye`,when:`then`,how:`now`,read:`red`,line:`lime`,short:`sort`,sound:`found`},jr=e=>{if(!ee.includes(e))throw new v(400,`Speech editing does not serve language '${e}' (supported: ${ee.join(`, `)}).`)},Mr=e=>new v(503,`Speech recognition is not available on this server: ${e}`),Nr=!1;async function Pr(e){Nr||=(await Tr(2500,e),!0)}async function Fr(e,t,n=`en_us`,r){if(!e.edit_transcribe)throw Mr(`send the transcript to /v2/edit/align instead`);jr(n),await Pr();let{pcm:i,sr:a,duration:o}=wr(t);if(o>150)throw new v(400,`Alignment supports clips up to 150 s (this one is ${o.toFixed(1)} s).`);await Tr(500+o*40,r);let s=br(_r,o),c;if(s){let e=kt(Ot(s.text)),t=Math.floor(e()*s.words.length);c=Er(s.words,n=>n===t?.34:.88+e()*.11).map((e,n)=>{if(n!==t)return e;let r=e.word.replace(/[^\p{L}']/gu,``),i=Ar[r]??Ar[r.toLowerCase()]??r.slice(0,Math.max(1,r.length-1));return{...e,word:e.word.replace(r,i),tokens:tr(i)}})}else{let e=Math.max(2,Math.round(o*2.6)),t=kr.split(` `);c=Or(i,a,Array.from({length:e},(e,n)=>t[n%t.length]).join(` `))}let l=c.map(e=>e.word).join(` `);return vr.set(yr(o),c),{text:l,duration:Dr(o),words:c}}async function Ir(e,t,n=`en_us`,r){jr(n);let{pcm:i,sr:a,duration:o}=wr(e);if(o>150)throw new v(400,`Alignment supports clips up to 150 s (this one is ${o.toFixed(1)} s).`);if(!tr(t).length)throw new v(400,`text has no words to align.`);await Tr(300+o*25,r);let s=br(_r,o),c=nr(t.trim()),l;return l=s&&s.words.length===c.length?Er(s.words,()=>.95).map((e,t)=>({...e,word:c[t],tokens:tr(c[t])})):Or(i,a,t.trim()),vr.set(yr(o),l),{text:t.trim(),duration:Dr(o),words:l}}function Lr(e,t,n,r){if(n.original_words){if(!n.original_text)throw new v(400,`original_words requires original_text.`);if(n.original_words.flatMap(e=>e.tokens??tr(e.word)).join(` `)!==tr(n.original_text).join(` `))throw new v(400,`original_words do not spell original_text.`);n.original_words.forEach((e,t)=>{if(!(Number.isFinite(e.start)&&Number.isFinite(e.end)&&e.startr+.001)throw new v(400,`original_words[${t}] is outside the clip.`);if(t&&e.startt.edit_max_spans)throw new v(400,`At most ${t.edit_max_spans} spans per edit (got ${i.length}).`);if(r>t.edit_max_seconds)throw new v(400,`Edits support clips up to ${t.edit_max_seconds} s (this one is ${r.toFixed(1)} s).`);if(i.forEach(([e,t],n)=>{if(!(e>=0&&t>e&&t<=r+.001))throw new v(400,`span ${n} [${e}, ${t}] is outside the audio (0..${r.toFixed(2)} s).`);if(n&&e4)throw new v(400,`num_takes must be 1-4.`);for(let t of[n.controls,...n.region_controls??[]])for(let r of Object.keys(t??{})){let t=e.directions[r];if(!t)throw new v(400,`Unknown control direction '${r}'.`);if(t.space===`raw`&&n.speaker_embedding===!1)throw new v(400,`Control ${r} moves the speaker embedding and needs speaker_embedding.`)}}function Rr(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n??{}))t[e]=(t[e]??0)+r;return t}function zr(e,t,n,r){let i=e.flatMap(e=>e.tokens.map(()=>e)),{equalMap:a}=rr(e.flatMap(e=>e.tokens),tr(t)),o=ar(t),s=-1,c=o.length;i.forEach((e,t)=>{let i=(e.start+e.end)/2;i=0&&(s=a[t]),i>r&&a[t]>=0&&c===o.length&&(c=a[t])});let l=[],u=-1;for(let e=s+1;et[n]?.ipa===e[1]?t[n++]:{ipa:e[1],heard:null})}async function Hr(e,t,n,r){if(n.verify&&!t.edit_transcribe)throw Mr(`set verify to false`);jr(n.language??`en_us`),n.verify&&await Pr(r);let i=wr(n.audio_base64);Lr(e,t,n,i.duration);let a=t.edit_frame_rate,o=(n.spans??[]).map(([e,t])=>[Math.floor(e*a)/a,Math.min(i.duration,Math.ceil(t*a)/a)]),s=n.original_words?n.original_words.map(e=>({word:e.word,start:e.start,end:e.end,confidence:1,tokens:e.tokens??tr(e.word)})):br(vr,i.duration)??(await Ir(n.audio_base64,n.original_text||n.target_text)).words,c=i.duration>(n.max_context_seconds??16)?hr(s,o,n.context_seconds??4,i.duration).map(([e,t])=>[Dr(e),Dr(t)]):[],l=br(_r,i.duration),u=l?.embedding??Rt(e,`edit-${yr(i.duration)}`,``),d=cn(i.pcm,i.sr,gr),f=n.num_takes??1,p=n.seed??Math.floor(Math.random()*1e5);await Tr(700+320*f+o.length*150,r);let m=o.map(([e,t])=>zr(s,n.target_text,e,t)),h=e=>tr(e).filter(e=>!$n(e)).join(``).replace(/[\ue000\ue001]/g,``).length,g=o.map(([e,t],n)=>{let r=s.filter(n=>(n.start+n.end)/2>=e&&(n.start+n.end)/2e.word).join(` `);return Dr((t-e)*(h(m[n])/Math.max(1,h(r)||h(m[n]))))}),v=tr(n.target_text),y=[];for(let t=0;t{let _=Math.round(t*gr),v=Math.round(o*gr),y=d.subarray(x,_),w=S/gr-x/gr;for(let e of s){let n=(e.start+e.end)/2;n>=x/gr&&ne[1]);if(ee)E=new Float32Array(Math.round(gr*.07));else if(T){let t=jn(T),i=sn(e,{text:O?`${t} ${t} ${t}`:t,embedding:u,controls:Rr(l?.controls,n.controls,n.region_controls?.[p]),seed:r}),a=Math.max(0,Math.round(((i.words[0]?.start??.1)-.05)*gr)),o=Math.min(i.pcm.length,Math.round(((i.words[i.words.length-1]?.end??0)+.06)*gr));E=i.pcm.slice(a,Math.max(a+1,o)),D=i.words.map(e=>({...e,start:e.start-a/gr,end:e.end-a/gr}))}else E=new Float32Array(Math.round(gr*(.08+.06*i())));let ne=(S-C)/gr;for(let e of D)g.push({word:e.word,start:Dr(ne+e.start),end:Dr(ne+e.end),confidence:.9,tokens:tr(e.word)});let re=g.length-D.length;for(let e of te){let t=Sn(e),n=g.findIndex((e,n)=>n>=re&&e.word.replace(/[^\p{L}']/gu,``)===t);b.push({ipa:e,at:ee?-1:n}),n>=0&&(re=n+1)}a.push(E),S+=E.length-C,c.push([Dr(Math.max(0,ne)),Dr(ne+E.length/gr)]),f.push(Dr(E.length/gr)),h.push(!O),x=v});let w=S/gr-x/gr;for(let e of s)(e.start+e.end)/2>=x/gr&&g.push({...e,start:Dr(Math.max(x/gr,e.start)+w),end:Dr(e.end+w)});a.push(d.subarray(x));let T=Br(a,C),E=g.map(e=>e.word),D=g.map((e,t)=>c.some(([t,n])=>e.start>=t-.001&&e.end<=n+.001)?t:-1).filter(e=>e>=0);if(D.length&&Ot(`asr${r}`)%3==0){let e=D[Math.floor(i()*D.length)];E[e]=Ar[E[e].replace(/[^\p{L}']/gu,``)]??`uh`}else if(D.length&&r%13==3){let e=D[D.length-1];E[e]=E[e].replace(/[aeiou](?=[^aeiou]*$)/i,e=>e.toLowerCase()===`e`?`a`:`e`)}let O=E.join(` `).replace(/[^\p{L}\p{N}'\s]/gu,``).toLowerCase(),ee=tr(O),ne=ir(v,ee).filter(Boolean).length,re=Math.round(Math.max(ne,Math.abs(v.length-ee.length))/Math.max(1,v.length)*1e3)/1e3;Cr(T,gr,{text:Sr(n.target_text.trim()),words:g,embedding:u,controls:l?.controls}),vr.set(yr(T.length/gr),g),y.push({seed:r,audio_base64:_(te(T,gr).buffer),duration:Dr(T.length/gr),edited_regions:c,fill_seconds:f,stopped:h,verify:n.verify?{asr_text:O,wer:re,cer:Math.round(re*600)/1e3,...n.target_text.includes(``)?{groups:Vr(n.target_text,b.map(e=>({ipa:e.ipa,heard:e.at>=0&&E[e.at].replace(/[^\p{L}\p{N}']/gu,``).toLowerCase()||null})))}:{}}:null,words:n.verify?g:null})}return{sample_rate:gr,original_text:n.original_text??s.map(e=>e.word).join(` `),target_text:n.target_text.trim(),words:s,spans:o,contexts:c.length?c:null,expected_seconds:n.original_text?g:null,takes:y}}var Ur={siobhan:`ʃəvɔːn`,worcestershire:`wʊstɚʃɚ`,hello:`həloʊ`,there:`ðɛɹ`,how:`haʊ`,are:`ɑɹ`,you:`ju`,today:`tədeɪ`,welcome:`wɛlkəm`,back:`bæk`,to:`tu`,the:`ðə`,late:`leɪt`,show:`ʃoʊ`,tonight:`tənaɪt`,story:`stɔɹi`,starts:`stɑɹts`,somewhere:`sʌmwɛɹ`,quiet:`kwaɪət`,little:`lɪtəl`,after:`æftɚ`,midnight:`mɪdnaɪt`,good:`ɡʊd`,evening:`ivnɪŋ`,and:`ænd`,lovely:`lʌvli`,finally:`faɪnəli`,meet:`mit`,been:`bɪn`,caramel:`kɛɹəmɛl`,nike:`naɪki`,gnocchi:`njɑki`,quinoa:`kinwɑ`,tsk:`ǀ`,brr:`ʙ`},Wr={read:`ɹid`,live:`lɪv`,lead:`lid`,wind:`wɪnd`,tear:`tɛɹ`,bass:`beɪs`,gif:`ɡɪf`,route:`ɹut`},Gr=[[/^tch/,`tʃ`],[/^ch/,`tʃ`],[/^sh/,`ʃ`],[/^th/,`θ`],[/^ng/,`ŋ`],[/^ph/,`f`],[/^ck/,`k`],[/^qu/,`kw`],[/^ee/,`i`],[/^ea/,`i`],[/^oo/,`u`],[/^ou/,`aʊ`],[/^ow/,`aʊ`],[/^ai/,`eɪ`],[/^ay/,`eɪ`],[/^oa/,`oʊ`],[/^igh/,`aɪ`],[/^a/,`æ`],[/^e/,`ɛ`],[/^i/,`ɪ`],[/^o/,`ɑ`],[/^u/,`ʌ`],[/^y$/,`i`],[/^y/,`j`],[/^c(?=[eiy])/,`s`],[/^c/,`k`],[/^g(?=[eiy])/,`dʒ`],[/^g/,`ɡ`],[/^j/,`dʒ`],[/^q/,`k`],[/^r/,`ɹ`],[/^x/,`ks`],[/^([bdfhklmnpstvwz])\1?/,`$1`]];function Kr(e){let t=e.toLowerCase().replace(/[^a-z]/g,``),n=``;for(;t;){let e=Gr.find(([e])=>e.test(t));if(!e){t=t.slice(1);continue}let r=t.match(e[0]);n+=e[1].replace(`$1`,r[1]??``),t=t.slice(r[0].length)}return n}function qr(e){let{promise:t,resolve:n}=Promise.withResolvers();return setTimeout(n,e),t}async function Jr(e,t,n,r){if(!e.phonemize_enabled)throw new v(404,`This server has no pronunciation lexicon.`);if(!e.phonemize_languages.includes(n))throw new v(400,`No pronunciation lexicon for ${n}.`);await qr(120);let i=r&&e.phonemize_guess_languages.includes(n),a=e.phoneme_tokens?new Set(e.phoneme_tokens.symbols):null,o=[];for(let e of t.matchAll(/([\p{L}']+)|([^\p{L}']+)/gu)){if(e[2]){o.push({text:e[2],ipa:null,status:null});continue}let t=e[1],n=t.toLowerCase(),r,s=null;Ur[n]?[r,s]=[`ok`,Ur[n]]:Wr[n]?[r,s]=i?[`guessed`,Wr[n]]:[`ambiguous`,null]:t.length===1&&!/[aiAI]/.test(t)?r=`skipped`:i?[r,s]=[`guessed`,Kr(t)]:r=`unknown`,s&&a&&![...s].every(e=>a.has(e))&&([r,s]=[`unsupported`,null]),o.push({text:t,status:r,ipa:s})}return{language:n,segments:o}}function Yr(e,t){let n=t?.open_marker??``,r=t?.close_marker??``;if(!e.includes(n)&&!e.includes(r))return;if(!t)throw new v(400,`This checkpoint has no phoneme tokens: remove the U+E000 / U+E001 pronunciation groups`);let i=new Set(t.symbols),a=0;for(;a=0?e.slice(t+1,o):``;if(o<0||!s||s.includes(n))throw new v(400,`Pronunciation groups: Unbalanced or empty phoneme group`);let c=[...new Set(s)].filter(e=>!i.has(e));if(c.length)throw new v(400,`Pronunciation groups: Phones outside the inventory: ${JSON.stringify(c.sort())}`);a=o+1}}var Xr=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Zr(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=new Uint32Array(64),r=e.length,i=r-r%64,a=new Uint8Array(r%64<56?64:128);a.set(e.subarray(i)),a[r-i]=128;let o=new DataView(a.buffer);o.setUint32(a.length-8,Math.floor(r/536870912)),o.setUint32(a.length-4,r<<3>>>0);let s=(e,r)=>{for(let t=0;t<16;t++){let i=r+t*4;n[t]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}for(let e=16;e<64;e++){let t=n[e-15],r=n[e-2],i=(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,a=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10;n[e]=n[e-16]+i+n[e-7]+a|0}let i=t[0],a=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7];for(let e=0;e<64;e++){let t=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),r=d+t+(c&l^~c&u)+Xr[e]+n[e]|0,f=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&a^i&o^a&o)|0;d=u,u=l,l=c,c=s+r|0,s=o,o=a,a=i,i=r+f|0}t[0]+=i,t[1]+=a,t[2]+=o,t[3]+=s,t[4]+=c,t[5]+=l,t[6]+=u,t[7]+=d};for(let t=0;te.toString(16).padStart(8,`0`)).join(``)}var Qr=e=>/^[0-9a-f]{64}$/.test(e);async function $r(e){if(!globalThis.crypto?.subtle)return Zr(e);let t=new Uint8Array(await crypto.subtle.digest(`SHA-256`,e));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function ei(e){let t=597399067,n=2869860233,r=951274213,i=2716044179,a=(e,t)=>e<>>32-t,o=e.length,s=o>>>4,c=e.byteOffset%4==0?new Uint32Array(e.buffer,e.byteOffset,s*4):new Uint32Array(e.slice(0,s*16).buffer),l=0,u=0,d=0,f=0;for(let e=0;e=p;t--)m[t-p>>>2]^=e[t]<<(t-p&3)*8;let h=o&15;h>12&&(f^=Math.imul(a(Math.imul(m[3],i),18),t)),h>8&&(d^=Math.imul(a(Math.imul(m[2],r),17),i)),h>4&&(u^=Math.imul(a(Math.imul(m[1],n),16),r)),h>0&&(l^=Math.imul(a(Math.imul(m[0],t),15),n)),l^=o,u^=o,d^=o,f^=o,l=l+u+d+f|0,u=u+l|0,d=d+l|0,f=f+l|0;let g=e=>(e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e^e>>>16);return l=g(l),u=g(u),d=g(d),f=g(f),l=l+u+d+f|0,u=u+l|0,d=d+l|0,f=f+l|0,[l,u,d,f].map(e=>(e>>>0).toString(16).padStart(8,`0`)).join(``)}function ti(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e.onsuccess=()=>n(e.result),e.onerror=()=>r(e.error),t}function ni(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e.oncomplete=()=>n(),e.onerror=()=>r(e.error),e.onabort=()=>r(e.error??new DOMException(`Transaction aborted`,`AbortError`)),t}function ri(e,t,n){let{promise:r,resolve:i,reject:a}=Promise.withResolvers();if(typeof indexedDB>`u`)return a(Error(`This browser has no IndexedDB`)),r;let o=indexedDB.open(e,t);return o.onupgradeneeded=()=>n(o.result),o.onsuccess=()=>i(o.result),o.onerror=()=>a(o.error),o.onblocked=()=>a(Error(`Another tab holds an older version of the studio’s storage open: close it and reload`)),r}var ii=class extends Error{status;detail;body;constructor(e,t,n={}){super(t),this.status=e,this.detail=t,this.body=n}},ai=null,oi=()=>ai??=ri(`zvs-fixture-server`,1,e=>{e.createObjectStore(`projects`,{keyPath:`id`}),e.createObjectStore(`media`,{keyPath:`hash`})}),si=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/,ci=/^[0-9a-f]{64}$/;function li(e){if(!si.test(e))throw new ii(400,`invalid project id`)}var ui=e=>Object.keys(e?.media??{}),di=(e,t)=>ui(e).reduce((e,n)=>e+(t.get(n)??0),0),fi=async e=>new Map((await ti(e.objectStore(`media`).getAll())).map(e=>[e.hash,e.size]));async function pi(){let e=(await oi()).transaction([`projects`,`media`]),[t,n]=await Promise.all([ti(e.objectStore(`projects`).getAll()),fi(e)]);return t.map(e=>({id:e.id,name:e.name,updated_at:e.updated_at,revision:e.revision,bytes:e.json.length,media_bytes:di(e.data,n),summary:e.data.summary??null})).sort((e,t)=>(t.updated_at??0)-(e.updated_at??0))}async function mi(e){li(e);let t=(await oi()).transaction([`projects`,`media`]),[n,r]=await Promise.all([ti(t.objectStore(`projects`).get(e)),fi(t)]);if(!n)throw new ii(404,`no such project`);return{id:n.id,name:n.name,revision:n.revision,updated_at:n.updated_at,media_bytes:di(n.data,r),data:JSON.parse(n.json)}}async function hi(e,t){li(e);let n=JSON.stringify(t.data),r=(await oi()).transaction([`projects`,`media`],`readwrite`),[i,a]=await Promise.all([ti(r.objectStore(`projects`).get(e)),Promise.all(ui(t.data).map(async e=>await ti(r.objectStore(`media`).getKey(e))===void 0?e:null))]),o=i?.revision??null;if(o!==(t.base_revision??null))throw r.abort(),new ii(409,`the project changed since base_revision`,{revision:o});let s=a.filter(e=>!!e);if(s.length)throw r.abort(),new ii(400,`missing media: ${s.join(`, `)}`,{missing:s});let c={id:e,name:t.name,revision:(o??0)+1,updated_at:Date.now(),data:null,json:n};return r.objectStore(`projects`).put({...c,data:t.data}),await ni(r),{id:e,revision:c.revision,updated_at:c.updated_at}}async function gi(e){li(e);let t=(await oi()).transaction(`projects`,`readwrite`);t.objectStore(`projects`).delete(e),await ni(t)}async function _i(e){if(!ci.test(e))throw new ii(400,`invalid hash`);return await ti((await oi()).transaction(`media`).objectStore(`media`).getKey(e))!==void 0}async function vi(e){if(!ci.test(e))throw new ii(400,`invalid hash`);let t=await ti((await oi()).transaction(`media`).objectStore(`media`).get(e));if(!t)throw new ii(404,`no such media`);return t.blob}async function yi(e,t){if(!ci.test(e))throw new ii(400,`invalid hash`);let n=new Uint8Array(await t.arrayBuffer());if(await $r(n)!==e)throw new ii(400,`content does not match its hash`);let r=(await oi()).transaction(`media`,`readwrite`);r.objectStore(`media`).put({hash:e,size:n.byteLength,blob:new Blob([n],{type:t.type})}),await ni(r)}function bi(e,t){let{tokens:n,spans:r}=kn(e);if(!n.length)return{text:e,spans:t??[],points:[],regions:[],tagged:!1};let i=new Int32Array(e.length+1),a=``,o=0;for(let t=0;t=n[o].end;)o++;o=n[o].start||(a+=e[t])}return i[e.length]=a.length,{text:a,spans:(t??[]).map(e=>({...e,start:i[e.start],end:i[e.end]})).filter(e=>e.end>e.start),points:n.filter(e=>e.kind===`point`).map(e=>({at:i[e.start],name:e.name})),regions:r.map(e=>({start:i[e.open.end],end:i[e.close.start],name:e.name})),tagged:!0}}function xi(e){let t=e>>>0||1;return()=>(t=t*1664525+1013904223>>>0)/2**32*2-1}function Si(e,t,n,r){let i=xi(r),a=e=>new Float32Array(Math.round(e*t)),o=(e,n,r,a,o,s=0)=>{let c=0,l=Math.exp(-2*Math.PI*o/t),u=Math.round(n*t),d=Math.round(r*t);for(let n=0;n/[\p{L}']/u.test(e[0])).map(e=>e.index??0),c=[...r.text.matchAll(/[^\s]+/g)].filter(e=>/[\p{L}']/u.test(e[0])).map(e=>(e.index??0)+e[0].length),l=e=>{let t=.05;for(let r=0;rt>=e.start&&c[n]<=e.end+1?n:-1).filter(e=>e>=0&&e({t:l(e.at),s:Si(e.name,t,o,a+n*97)})).sort((e,t)=>e.t-t.t);if(!d.length)return{pcm:u,words:n};let f=d.reduce((e,t)=>e+t.s.length,0),p=new Float32Array(u.length+f),m=0,h=0,g=0,_=n.map(e=>({...e}));for(let e of d){let n=Math.min(u.length,Math.max(m,Math.round(e.t*t)));p.set(u.subarray(m,n),h),h+=n-m,m=n,p.set(e.s,h),h+=e.s.length;let r=e.s.length/t;for(let t of _)t.start>=e.t-1e-6+g&&(t.start+=r,t.end+=r);g+=r}return p.set(u.subarray(m),h),{pcm:p,words:_}}var wi={phoneme_tokens:{open_marker:``,close_marker:``,symbols:`a.b.c.d.e.f.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.².³.¹.ã.ä.æ.ç.ï.ð.õ.ø.ħ.ĩ.ŋ.œ.ũ.ɐ.ɑ.ɒ.ɓ.ɔ.ɕ.ɖ.ɗ.ɘ.ə.ɚ.ɛ.ɜ.ɝ.ɟ.ɡ.ɣ.ɤ.ɥ.ɦ.ɧ.ɨ.ɪ.ɫ.ɭ.ɯ.ɰ.ɱ.ɲ.ɳ.ɴ.ɵ.ɸ.ɹ.ɻ.ɽ.ɾ.ʀ.ʁ.ʂ.ʃ.ʈ.ʉ.ʊ.ʋ.ʌ.ʍ.ʎ.ʏ.ʐ.ʑ.ʒ.ʔ.ʕ.ʝ.ʰ.ʱ.ʲ.ʷ.ʼ.ˀ.ː.ˣ.ˤ.˥.˦.˧.˨.˩.̃.̊.̍.̚.̝.̞.̟.̠.̥.̩.̪.̯.̹.͈.͡.β.θ.χ.ᵝ.ẽ.ỹ.⁴.⁵.⁻.⁽.⁾`.split(`.`)},phonemize_enabled:!0,phonemize_languages:[`en_us`,`en_gb`],phonemize_guess_languages:[`en_us`]},Ti=Symbol.for(`preact-signals`);function Ei(){if(Mi>1)Mi--;else{var e,t=!1;for((function(){var e=Ii;for(Ii=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();ji!==void 0;){var n=ji;for(ji=void 0,Ni++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Bi(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Ni=0,Mi--,t)throw e}}function Di(e){if(Mi>0)return e();Fi=++Pi,Mi++;try{return e()}finally{Ei()}}var Oi,ki=void 0;function Ai(e){var t=ki,n=Oi;ki=void 0,Oi=void 0;try{return e()}finally{ki=t,Oi=n}}var ji=void 0,Mi=0,Ni=0,Pi=0,Fi=0,Ii=void 0,Li=0;function Ri(e){if(ki!==void 0){var t=e.n;if(t===void 0||t.t!==ki)return t={i:0,S:e,p:ki.s,n:void 0,t:ki,e:void 0,x:void 0,r:t},ki.s!==void 0&&(ki.s.n=t),ki.s=t,e.n=t,32&ki.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ki.s,t.n=void 0,ki.s.n=t,ki.s=t),t}}function zi(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}zi.prototype.brand=Ti,zi.prototype.h=function(){return!0},zi.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ai(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},zi.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ai(function(){var e;(e=t.Z)==null||e.call(t)}))}},zi.prototype.subscribe=function(e){var t=this;return Ji(function(){var n=t.value;Ai(function(){return e(n)})},{name:`sub`})},zi.prototype.valueOf=function(){return this.value},zi.prototype.toString=function(){return this.value+``},zi.prototype.toJSON=function(){return this.value},zi.prototype.peek=function(){var e=this;return Ai(function(){return e.value})},Object.defineProperty(zi.prototype,"value",{get:function(){var e=Ri(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ni>100)throw Error(`Cycle detected`);(function(e){Mi!==0&&Ni===0&&e.l!==Fi&&(e.l=Fi,Ii={S:e,v:e.v,i:e.i,o:Ii})})(this),this.v=e,this.i++,Li++,Mi++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ei()}}}});function I(e,t){return new zi(e,t)}function Bi(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Vi(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Hi(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Ui(e,t){zi.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Li-1,this.f=4}Ui.prototype=new zi,Ui.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Li))return!0;if(this.g=Li,this.f|=1,this.i>0&&!Bi(this))return this.f&=-2,!0;var e=ki;try{Vi(this),ki=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ki=e,Hi(this),this.f&=-2,!0},Ui.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}zi.prototype.S.call(this,e)},Ui.prototype.U=function(e){if(this.t!==void 0&&(zi.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Ui.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Ui.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ri(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function L(e,t){return new Ui(e,t)}function Wi(e){var t=e.j;if(e.j=void 0,typeof t==`function`){Mi++;var n=ki;ki=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Gi(e),t}finally{ki=n,Ei()}}}function Gi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Wi(e)}function Ki(e){if(ki!==this)throw Error(`Out-of-order effect`);Hi(this),ki=e,this.f&=-2;try{8&this.f&&Gi(this)}finally{Ei()}}function qi(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Oi&&Oi.push(this)}qi.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.j=t)}finally{e()}},qi.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Wi(this),Vi(this),Mi++;var e=ki;return ki=this,Ki.bind(this,e)},qi.prototype.N=function(){2&this.f||(this.f|=2,this.u=ji,ji=this)},qi.prototype.d=function(){this.f|=8,1&this.f||Gi(this)},qi.prototype.dispose=function(){this.d()};function Ji(e,t){var n=new qi(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Yi,Xi,Zi=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Qi=[];Ji(function(){Yi=this.N})();function $i(e,t){A[e]=t.bind(null,A[e]||function(){})}function ea(e){if(Xi){var t=Xi;Xi=void 0,t()}Xi=e&&e.S()}function ta(e){var t=this,n=e.data,r=ra(n);r.name=`ReactiveDom`,r.value=n;var i=mt(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=L(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=L(function(){return!Array.isArray(i.value)&&!se(i.value)}),o=Ji(function(){if(this.N=oa,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}ta.displayName=`ReactiveTextNode`,Object.defineProperties(zi.prototype,{constructor:{configurable:!0,value:we(j,null).constructor},type:{configurable:!0,value:ta},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),$i(`__b`,function(e,t){if(ea(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof zi&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),$i(`__r`,function(e,t){if(e(t),t.type!==j){ea();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return Ji(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;Zi&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),ea(n)}}),$i(`__e`,function(e,t,n,r){ea(),e(t,n,r)}),$i(`diffed`,function(e,t){ea();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=na(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function na(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=I(n);return{o:function(e,t){a.value=e,r=t},d:Ji(function(){this.N=oa;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}$i(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),$i(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),Ee.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function ra(e,t){return mt(function(){return I(e,t)},[])}var ia=function(e){queueMicrotask(function(){queueMicrotask(e)})};function aa(){Di(function(){for(var e;e=Qi.shift();)Yi.call(e)})}function oa(){Qi.push(this)===1&&(A.requestAnimationFrame||ia)(aa)}var sa={language:`en_us`,voiceMode:`embedding`,tagStrength:1.5};function ca(e){return{voices:e.voices.length,cast:e.cast.personas.length,lines:e.direct.script.lines.length,takes:Object.values(e.direct.takes).reduce((e,t)=>e+t.length,0),versions:e.edit.doc?.versions.length??0}}function la(e,t){if(!t.size)return e;let n=[...t.keys()].map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`));return e.replace(RegExp(`(?t.get(e))}var ua=I(null),da=I(null),fa=I(null),pa=I(`Opening the studio…`),ma=I(null),ha=I(sa),R=L(()=>ua.value.spec),ga=L(()=>ua.value?.pron.phoneme_tokens??null),_a=L(()=>({phonemeTokens:ga.value,tags:ua.value?.tags??null,tagStrength:ha.value.tagStrength})),va=L(()=>new Map(R.value.ui.controls.map(e=>[e.id,e]))),ya=L(()=>{let e=new Map;return R.value.ui.groups.forEach((t,n)=>e.set(t.id,t.hue??`c${n+1}`)),e});function ba(e){return`var(--${ya.value.get(e)??`c1`})`}var xa=[`cast`,`direct`,`edit`],Sa=location.hash.slice(1)===`scene`?`direct`:location.hash.slice(1),Ca=I(xa.includes(Sa)?Sa:`cast`),wa=I(null),Ta=I(!1),Ea=I(!1),Da=I(null),Oa=I(null),ka=I([]),Aa=0,ja=new Map,Ma=new Map,Na=!1;function Pa(e,t){clearTimeout(ja.get(e)),Ma.set(e,Date.now()+t),Na||ja.set(e,window.setTimeout(()=>Fa(e),t))}function Fa(e){clearTimeout(ja.get(e)),ja.delete(e),Ma.delete(e),ka.value=ka.value.filter(t=>t.id!==e)}function Ia(e){if(e===Na)return;if(Na=e,e){for(let e of ja.values())clearTimeout(e);ja.clear();return}let t=Date.now();for(let[e,n]of Ma)ja.set(e,window.setTimeout(()=>Fa(e),Math.max(1e3,n-t)))}function z(e,t=`info`,n){let r=t===`error`?15e3:n?8e3:3500,i=ka.value.find(n=>n.text===e&&n.kind===t);if(i)return ka.value=ka.value.map(e=>e===i?{...e,action:n}:e),Pa(i.id,r),i.id;let a=++Aa,o=ka.value.slice(0,-2);for(let e of o)clearTimeout(ja.get(e.id)),ja.delete(e.id),Ma.delete(e.id);return ka.value=[...ka.value.slice(-2),{id:a,text:e,kind:t,action:n}],Pa(a,r),a}var La=e=>!!e?.source_type?.startsWith(`embedding`),Ra=new URLSearchParams(location.search),za=Ra.get(`api`)||`auto`,Ba=(Ra.get(`server`)||``).replace(/\/+$/,``);za===`web`&&o();var Va=44100;function Ha(){let e=localStorage.getItem(`zvs.session`);return e||(e=T(),localStorage.setItem(`zvs.session`,e)),e}var{client:Ua,headers:Wa,ok:Ga,send:Ka}=b({baseUrl:Ba,session:Ha,fetch:i}),qa=null,Ja=Ct;function Ya(){if(!qa)throw Error(`api.connect() has not run`);return qa}var Xa={speech_editing:!0,edit_transcribe:!0,edit_max_spans:3,edit_frame_rate:15,edit_max_seconds:150,edit_align_max_seconds:150,fixture:!0},Za={...Xa,speech_editing:!1,edit_transcribe:!1,fixture:!1};function Qa(e,t){let n=Ra.get(`edit`);if(n===`0`||n===`off`)return{...Za,fixture:e!==`live`};let r=!/^(0|off)$/.test(Ra.get(`edit_transcribe`)??``);return n===`fixture`||e===`offline`?{...Xa,edit_transcribe:r}:t?{speech_editing:t.speech_editing,edit_transcribe:t.edit_transcribe&&r,edit_max_spans:t.edit_max_spans,edit_frame_rate:t.edit_frame_rate??Xa.edit_frame_rate,edit_max_seconds:t.edit_max_seconds,edit_align_max_seconds:t.edit_align_max_seconds,fixture:!1}:Za}var $a={...wi,fixture:!0},eo={phoneme_tokens:null,phonemize_enabled:!1,phonemize_languages:[],phonemize_guess_languages:[],fixture:!1};function to(e,t){let n=Ra.get(`phon`);return n===`0`||n===`off`?{...eo,fixture:e!==`live`}:n===`fixture`||e===`offline`?$a:t?{phoneme_tokens:t.phoneme_tokens,phonemize_enabled:t.phonemize_enabled,phonemize_languages:t.phonemize_languages,phonemize_guess_languages:t.phonemize_guess_languages,fixture:!1}:eo}var no={tags:[`laugh`,`breath`,`sigh`,`cough`,`panting`,`shouting`,`crying`],min_scale:1,max_scale:4,default_scale:1,fixture:!0};function ro(e,t){let n=Ra.get(`nv`);return n===`0`||n===`off`?null:n===`fixture`||e===`offline`?no:!t?.available||!t.trained?null:{tags:t.tags.length?t.tags:no.tags,min_scale:t.min_scale,max_scale:t.max_scale,default_scale:t.default_scale,fixture:!1}}var io={max_media_bytes:2e9,max_project_bytes:2e7,fixture:!0};function ao(e){let t=Ra.get(`projects`);return t===`fixture`?io:t===`browser`||t===`0`||!e?.enabled?null:{max_media_bytes:e.max_media_bytes,max_project_bytes:e.max_project_bytes,fixture:!1}}var oo=()=>Ba||location.origin;async function so(e){return pa.value=`Loading the in-browser engine…`,await l(e=>fa.value=e),fa.value=null,pa.value=`Starting the voice engine…`,d(e=>ma.value=e.fraction>=1?null:e),e(`web`,await uo())}async function co(e={}){let t=async(e,t)=>{let n=e===`offline`?null:await Ga(Ua.GET(`/v2/capabilities`)).catch(()=>null),r=e===`web`?`live`:e;return qa={kind:e,server:Ba,spec:t,steering:e!==`fixture`,edit:Qa(r,n),pron:to(r,n),projects:ao(n?.projects),tags:ro(r,n?.tag_cfg)}};if(za===`offline`)return t(`offline`,Ja);if(za===`web`)return so(t);pa.value=`Connecting to ${oo()}…`;try{return await t(`live`,await uo())}catch(n){if(za===`live`)throw n;return n instanceof v&&n.status===404||za===`fixture`?t(`fixture`,Ja):za===`auto`&&await s()&&(!e.confirmWeb||await e.confirmWeb())?(o(),so(t)):t(`offline`,Ja)}}var lo=s;async function uo(){if(za===`fixture`)throw new v(404,`fixture forced`);return await Ga(Ua.GET(`/v2/controls`))}var fo=new Map,po=(e,t,n)=>({id:`local_${p(e)}_${Date.now().toString(36)}`,label:e,source_type:t,scope:`session`,is_default:!1,original_name:n,created_at:Date.now()/1e3,has_preview:t===`audio`,speaker_modes:t===`audio`?[`embedding`,`reference`]:[`embedding`],embedding_dim:Ya().spec.embedding_dim,transcript:null,disabled_controls:[]});async function mo(){return Ya().kind===`offline`?[...zt(Ya().spec).map(e=>({...e,transcript:/Skyler|Yelling/.test(e.label)?null:go(e)})),...[...fo.values()].map(e=>e.speaker)]:(await Ga(Ua.GET(`/v2/speakers`))).speakers}async function ho(e){let t=Ya();if(t.kind!==`offline`)try{let t=await Ga(Ua.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e.id}}}));return{embedding:Float32Array.from(t.embedding),synthetic:!1}}catch(e){if(!(e instanceof v)||e.status!==404||t.kind===`live`||t.kind===`web`)throw e}return{embedding:fo.get(e.id)?.embedding??Rt(t.spec,e.id,e.label),synthetic:t.kind!==`offline`}}var go=e=>`Hi, I'm ${e.label}. This is how I sound when I read a short line.`;async function _o(e){if(Ya().kind===`offline`){let{embedding:t}=await ho(e),n=go(e),{pcm:r,words:i}=sn(Ya().spec,{text:n,embedding:t,seed:7});return Cr(r,Va,{text:n,words:i,embedding:t}),te(r,Va).buffer}let t=await i(`${Ba}/v2/speakers/${encodeURIComponent(e.id)}/preview`,{headers:Wa()});if(!t.ok)throw await S(t);return t.arrayBuffer()}async function vo(e,t,n){if(Ya().kind===`offline`){let t=po(e,`audio`,n);return fo.set(t.id,{speaker:t}),t}let r={label:e,speaker_audio_base64:await ie(t),speaker_audio_name:n};return Ga(Ua.POST(`/v2/speakers`,{body:r}))}async function yo(e,t){let n=`${p(e)}.npy`;if(Ya().kind===`offline`){let r=po(e,`embedding`,n);return fo.set(r.id,{speaker:r,embedding:t.slice()}),r}let r={label:e,speaker_embedding_base64:await ae(m(t),`application/octet-stream`),speaker_embedding_name:n};return Ga(Ua.POST(`/v2/speakers`,{body:r}))}var bo=new Set([`en_us`,`fr_fr`]);async function xo(e,t={}){let n=Ya(),r=performance.now(),a={stream:!0,...e};if(n.steering||(delete a.controls,delete a.control_spans),a.control_spans?.length||delete a.control_span_follow,(!n.tags||(a.tag_cfg_scale??1)<=1)&&delete a.tag_cfg_scale,n.kind===`offline`||n.tags?.fixture)return So(a,t,r);let o=await i(`${Ba}/v2/generate`,{method:`POST`,headers:Wa({"Content-Type":`application/json`}),body:JSON.stringify(a),signal:t.signal});if(!o.ok)throw await S(o);let s=a.control_spans?.length?o.headers.get(`X-Control-Span-Follow`)===`reading`?`reading`:`rate`:void 0,c=Number(o.headers.get(`X-Audio-Sample-Rate`))||44100;if(!o.body)throw new v(502,`Empty audio stream`);let l=[],u=0,d=0;await x(o.body,e=>{l.push(e),u+=e.length,t.onChunk?.(e,c)},()=>{d||=performance.now()-r});let f=new Float32Array(u),p=0;for(let e of l)f.set(e,p),p+=e.length;return{pcm:f,sr:c,ttfbMs:d,totalMs:performance.now()-r,...s?{spanFollow:s}:{}}}async function So(e,t,n){let r=Ya();Yr(e.text,r.pron.phoneme_tokens);let i=(await mo()).find(t=>t.id===e.speaker_embedding_id);if(!i)throw new v(400,`Unknown speaker_embedding_id '${e.speaker_embedding_id}'`);let a=e.controls??{};for(let t of[...Object.keys(a),...(e.control_spans??[]).flatMap(e=>Object.keys(e.controls))]){let n=r.spec.directions[t];if(!n)throw new v(400,`Unknown control direction '${t}'`);let i=e.speaker_mode??`embedding`;if(!r.spec.sets[n.set]?.modes.includes(i))throw new v(400,`Control '${t}' moves the speaker embedding and needs speaker_mode=embedding.`)}for(let t of e.control_spans??[]){if(Object.keys(t.controls).some(e=>r.spec.directions[e].space===`raw`))throw new v(400,`control_spans take hidden-space directions only.`);if(!(t.start>=0&&t.end>t.start&&t.end<=e.text.length))throw new v(400,`control_spans [${t.start}, ${t.end}) is outside the text.`)}let o=[...e.control_spans??[]].sort((e,t)=>e.start-t.start);for(let e=1;e1){if(!c?.tagged)throw new v(400,`tag_cfg_scale > 1 needs a recognized nonverbal tag in the text.`);if((e.speaker_cfg_scale??1)!==1)throw new v(400,`tag_cfg_scale cannot be combined with speaker_cfg_scale ≠ 1.`)}let{embedding:l}=await ho(i),u=c??{text:e.text,spans:e.control_spans??void 0},d=sn(r.spec,{text:u.text,embedding:l,controls:a,spans:u.spans,seed:e.seed??0}),{pcm:f,words:p}=c?Ci(d.pcm,Va,d.words,c,s,e.seed??0):d;Cr(f,Va,{text:u.text,words:p,embedding:l,controls:a});let m=e=>{let{promise:n,resolve:r,reject:i}=Promise.withResolvers(),a=setTimeout(r,e);return t.signal?.addEventListener(`abort`,()=>{clearTimeout(a),i(new DOMException(`Aborted`,`AbortError`))}),n};await m(220+Math.random()*180);let h=performance.now()-n,g=Math.round(Va*.4);for(let e=0;eYa().projects?.fixture===!0;async function Oo(e){try{return await e()}catch(e){throw e instanceof ii?e.status===409?new re(e.body.revision??null):e.body.missing?new w(e.body.missing):new v(e.status,e.detail):e}}var ko=e=>({params:{path:{project_id:e}}}),Ao=e=>`${Ba}/v2/media/${encodeURIComponent(e)}`;function jo(){return Do()?Oo(pi):Ga(Ua.GET(`/v2/projects`))}function Mo(e){return Do()?Oo(()=>mi(e)):Ga(Ua.GET(`/v2/projects/{project_id}`,ko(e)))}async function No(e,t){if(Do())return Oo(()=>hi(e,t));let{response:n,text:r}=await Ka(Ua.PUT(`/v2/projects/{project_id}`,{...ko(e),body:t}));if(n.ok)return y(n.status,r);let i={};try{i=JSON.parse(r)??{}}catch{}throw n.status===409?new re(i.revision??null):n.status===400&&i.missing?new w(i.missing):O(n.status,n.statusText,r)}async function Po(e){if(Do())return Oo(()=>gi(e));let{response:t,text:n}=await Ka(Ua.DELETE(`/v2/projects/{project_id}`,ko(e)));if(!t.ok&&t.status!==404)throw O(t.status,t.statusText,n)}async function Fo(e){if(Do())return Oo(()=>_i(e));let t=await i(Ao(e),{method:`HEAD`,headers:Wa()});if(t.status===404)return!1;if(!t.ok)throw await S(t);return!0}async function Io(e,t){if(Do())return Oo(()=>vi(e));let n=await i(Ao(e),{headers:Wa()});if(!n.ok)throw await S(n);let r=await n.blob();return t&&r.type!==t?new Blob([r],{type:t}):r}async function Lo(e,t){if(Do())return Oo(()=>yi(e,t));let n=await i(Ao(e),{method:`PUT`,headers:Wa({"Content-Type":t.type||`application/octet-stream`}),body:t});if(!n.ok)throw await S(n)}function Ro(e){return e}function zo(e){if(e==null)return Ro;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;ct.properties?.name===e);if(!t)return[];let n=t.geometry;return n.type===`Polygon`?[n.coordinates[0]]:n.type===`MultiPolygon`?n.coordinates.map(e=>e[0]):[]}function Xo(e,t){let n=[];for(let r=0;r=0&&n.push(i),o>=0!=s>=0){let e=o/(o-s);n.push([i[0]+(a[0]-i[0])*e,i[1]+(a[1]-i[1])*e])}}return n}var Zo=(e,...t)=>e.map(e=>t.reduce((e,t)=>Xo(e,t),e)).filter(e=>e.length>=3),Qo=(e,t)=>n=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),$o=[-3.4,54.95],es=[-2,55.8],ts=[-2.65,51.6],ns=[-3.1,53.45];function rs(e){if(![`England`,`Scotland`,`Wales`,`Northern Ireland`].includes(e))return Yo(e);let t=Yo(`United Kingdom`),n=e=>e.every(([e,t])=>e<-5.4&&t>53.8&&t<55.4);if(e===`Northern Ireland`)return t.filter(n);let r=t.filter(e=>!n(e)),i=Qo($o,es);if(e===`Scotland`)return Zo(r,i);let a=Zo(r,e=>-i(e)),o=Qo(ts,ns);return e===`Wales`?Zo(a,o,e=>Math.min(e[1]-51.38,53.45-e[1])):[...Zo(a,e=>-o(e)),...Zo(a,o,e=>51.38-e[1]),...Zo(a,o,e=>e[1]-53.45)]}var is=e=>180/Math.PI*Math.log(Math.tan(Math.PI/4+Math.max(-85,Math.min(85,e))*Math.PI/360));function as(e){let[t,n,r,i]=e.bbox,[a,o,s,c]=e.rect,l=is(n),u=is(i),d=Math.min(s/(r-t),c/(u-l)),f=a+(s-(r-t)*d)/2,p=o+(c-(u-l)*d)/2;return([e,n])=>[f+(e-t)*d,p+(u-is(n))*d]}function os(e,[t,n,r,i]){return[e=>e[0]-t,e=>t+r-e[0],e=>e[1]-n,e=>n+i-e[1]].reduce((e,t)=>Xo(e,t),e)}var ss=e=>e.map(e=>`M`+e.map(([e,t])=>`${e.toFixed(1)},${t.toFixed(1)}`).join(`L`)+`Z`).join(``);function cs(e,[t,n]){let r=!1;for(let i of e)for(let e=0,a=i.length-1;en!=l>n&&t<(c-o)*(n-s)/(l-s)+o&&(r=!r)}return r}function ls(e,[t,n]){let r=1/0;for(let i of e)for(let e=0,a=i.length-1;eo&&(o=u,a=l)}return{pole:a,inradius:Math.max(o,4)}}function ds(e,[t,n,r,i]){return e.some(e=>e.some(([e,a])=>e>=t-5&&e<=r+5&&a>=n-5&&a<=i+5))}var fs=new Map;function ps(e,t){let n=`${e}|${t.join(`,`)}`,r=fs.get(n);if(r)return r;let i=Ko[e]??{home:[500,900],panels:[],regions:{}},a=[];for(let e of i.panels){let t=as(e),n=Jo.flatMap(e=>Yo(e.properties?.name??``)).filter(t=>ds([t],e.bbox)).map(n=>os(n.map(t),e.rect)).filter(e=>e.length>=3);a.push({panel:e.id,path:ss(n)})}let o={},s=[];for(let e of t){let t=i.regions[e];if(!t){s.push(e);continue}let n=[];for(let e of i.panels){let r=as(e);for(let i of t)for(let t of rs(i)){if(!ds([t],e.bbox))continue;let i=os(t.map(r),e.rect);i.length>=3&&n.push(i)}}n.length?o[e]={id:e,polys:n,path:ss(n),...us(n)}:s.push(e)}s.forEach((e,t)=>{let n=[Go/(s.length+1)*(t+1),920],r=Array.from({length:24},(e,t)=>[n[0]+Math.cos(t/24*Math.PI*2)*34,n[1]+Math.sin(t/24*Math.PI*2)*26]);o[e]={id:e,polys:[r],path:ss([r]),pole:n,inradius:26}});let c={panels:i.panels,context:a,regions:o,home:i.home};return fs.set(n,c),c}var ms=.2;function hs(e,t){let n=ls(e.polys,t);return cs(e.polys,t)?ms+.8*Math.min(1,n/e.inradius):ms*Math.max(0,1-n/18)}function gs(e){return[...new Set(e.map(e=>e.tab))]}function _s(e,t){return ps(e,[...new Set(t.filter(t=>t.tab===e).map(e=>e.region))])}function vs(e=`english`,t=[]){let[n,r]=_s(e,t).home;return{tab:e,x:n,y:r}}function ys(e,t,n){let r=t.regions[e.region];return r?Math.round(e.range[1]*hs(r,n)*20)/20:0}function bs(e,t){let n=_s(e.tab,t),r={};for(let i of t){if(i.tab!==e.tab)continue;let t=ys(i,n,[e.x,e.y]);t>0&&(r[i.id]=t)}return r}function xs(e,t,n){let r=_s(e.tab,n),i=r.regions[e.region];if(!i)return vs(e.tab,n);let[a,o]=r.home,s=e=>[i.pole[0]+(a-i.pole[0])*e,i.pole[1]+(o-i.pole[1])*e],c=0,l=1;for(let n=0;n<30;n++){let n=(c+l)/2;ys(e,r,s(n))>=t?c=n:l=n}let[u,d]=s(c);return{tab:e.tab,x:u,y:d}}function Ss(e,t,n=`english`){let r=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1])[0],i=r&&t.find(e=>e.id===r[0]);return i?xs(i,r[1],t):vs(n,t)}var Cs=class{limit;state;canUndo=I(!1);canRedo=I(!1);past=[];future=[];gesture=null;constructor(e,t=200){this.limit=t,this.state=I(e)}begin(){this.gesture===null&&(this.gesture=this.state.value)}set(e){this.state.value=e}end(){let e=this.gesture;this.gesture=null,e!==null&&e!==this.state.value&&(this.past.push(e),this.past.length>this.limit&&this.past.shift(),this.future=[],this.sync())}apply(e){this.begin(),this.set(e),this.end()}undo(){this.end();let e=this.past.pop();e!==void 0&&(this.future.push(this.state.value),this.state.value=e,this.sync())}redo(){this.end();let e=this.future.pop();e!==void 0&&(this.past.push(this.state.value),this.state.value=e,this.sync())}reset(e){this.past=[],this.future=[],this.gesture=null,this.state.value=e,this.sync()}patch(e){this.gesture===null&&(this.state.value=e)}sync(){this.canUndo.value=this.past.length>0,this.canRedo.value=this.future.length>0}},B=I(null),ws=I(0),Ts=null,Es=null,Ds=[],Os=0,ks=0,As=null;function js(){return Ts||(Ts=new AudioContext({latencyHint:`interactive`}),Es=Ts.createGain(),Es.gain.value=.9,Es.connect(Ts.destination)),Ts.state===`suspended`&&Ts.resume(),{ctx:Ts,out:Es}}function Ms(){let e=B.value;e&&Ts&&(ws.value=Math.max(0,Math.min(e.duration,Ts.currentTime-e.t0)),Os=requestAnimationFrame(Ms))}function Ns(e,t){B.value=e,As=t??null,cancelAnimationFrame(Os),Os=requestAnimationFrame(Ms)}function Ps(e){clearTimeout(ks);let t=Math.max(0,(e-Ts.currentTime)*1e3)+30;ks=window.setTimeout(()=>Fs(),t)}function Fs(){clearTimeout(ks),cancelAnimationFrame(Os);let e=As;As=null,B.value=null,ws.value=0,e?.()}function Is(){for(let e of Ds)try{e.stop()}catch{}Ds=[],B.value&&Fs()}function Ls(e,t){let{ctx:n}=js(),r=n.createBuffer(1,Math.max(1,e.length),t);return r.copyToChannel(e,0),r}function Rs(e,t,n,r=0,i,a){Is();let{ctx:o,out:s}=js(),c=o.createBufferSource();c.buffer=Ls(t,n),c.connect(s);let l=o.currentTime+.02,u=t.length/n,d=Math.max(0,Math.min(r,u)),f=Math.max(d,Math.min(a??u,u));c.start(l,d,f-d),Ds=[c],Ns({id:e,t0:l-d,duration:u,streaming:!1},i),Ps(l+f-d)}function zs(e){return B.value?.id===e}function Bs(e,t,n,r){zs(e)?Is():t&&Rs(e,t,n,0,r)}function Vs(e,t){Is();let{ctx:n,out:r}=js(),i=n.currentTime+.08,a=i,o=!1;Ns({id:e,t0:a,duration:0,streaming:!0});let s=()=>B.value?.id===e&&B.value.t0===a;return{id:e,push(e){if(!s()||!e.length)return;let c=n.createBufferSource();c.buffer=Ls(e,t),c.connect(r);let l=Math.max(i,n.currentTime+.01);c.start(l),i=l+e.length/t,Ds.push(c),B.value={...B.value,duration:i-a},o&&Ps(i)},end(){o=!0,s()&&(B.value={...B.value,streaming:!1},Ps(i))}}}async function Hs(e){let{ctx:t}=js(),n=await t.decodeAudioData(e.slice(0)),r=new Float32Array(n.length);for(let e=0;eArray.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.keys(e).sort().map(n=>[n,t(e[n])])):e;return JSON.stringify(t(e))}function Xs(e){return Gs.get(Ys(e))}function Zs(e,t){for(Gs.delete(e),Gs.set(e,t);Gs.size>Ws;)Gs.delete(Gs.keys().next().value)}function Qs(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers(),i=()=>{e?.removeEventListener(`abort`,a),qs++,n()},a=()=>{let e=Js.indexOf(i);e>=0&&Js.splice(e,1),r(new DOMException(`Aborted`,`AbortError`))};return e?.aborted?a():qs{await Qs(t.signal);try{let r=await xo(e,t);return Zs(n,r),r}catch(t){throw nc(t)&&rc?.(e.speaker_embedding_id??``),t}finally{$s()}})();Ks.set(n,a);try{return await a}finally{Ks.get(n)===a&&Ks.delete(n)}}var tc=e=>e instanceof DOMException&&e.name===`AbortError`,nc=e=>e instanceof v&&(e.status===400||e.status===404)&&/unknown (voice|speaker)/i.test(e.detail),rc=null;function ic(e){rc=e}function V(e){return e instanceof Error?e.message:String(e)}var H=I([]),ac=I(null),oc=I(!1),sc=new Map,cc=new Map,lc=I(0),uc=I(!1),dc=I({});async function fc(){oc.value=!0;try{H.value=await mo(),ac.value=null}catch(e){ac.value=V(e)}finally{oc.value=!1}}function pc(e){return lc.value,e&&sc.get(e)||null}function mc(e,t=!1){let n=sc.get(e.id);if(n)return Promise.resolve(n);if(t&&dc.value[e.id]){let t={...dc.value};delete t[e.id],dc.value=t}let r=cc.get(e.id);return r||(r=ho(e).then(({embedding:t,synthetic:n})=>(sc.set(e.id,t),n&&(uc.value=!0),lc.value++,t)).catch(t=>(dc.value={...dc.value,[e.id]:V(t)},null)).finally(()=>cc.delete(e.id)),cc.set(e.id,r)),r}function hc(){for(let e of H.value)mc(e)}var gc=new Map,_c=I(null);async function vc(e){let t=`clip:${e.id}`;if(zs(t))return Is();let n=gc.get(e.id);if(!n){_c.value=e.id;try{n=await Hs(await _o(e)),gc.set(e.id,n)}catch(t){z(`Couldn't play ${e.label}: ${V(t)}`,`error`);return}finally{_c.value=null}}Rs(t,n.pcm,n.sr)}var yc=I(!1);async function bc(e,t,n,r=!1){yc.value=!0;try{let i,a;try{({pcm:i,sr:a}=await Hs(await e.arrayBuffer()))}catch{return z(`That file isn’t audio the browser can read (try WAV or MP3)`,`error`),null}let o=i.length/a;if(o<2)return z(`Too short: record at least 2 s`,`error`),null;if(o>60)return z(`Clip is ${Math.round(o)} s; the limit is 60 s`,`error`),null;let s=await Sc(t,te(i,a).buffer,n.replace(/\.[^.]+$/,``)+`.wav`);return await fc(),z(r?`Added ${s.label} and made it the base voice`:`Added “${s.label}” to your voices`,`ok`),(o<5||o>30)&&z(`Clip is ${Math.round(o)} s; 5–30 s of clean speech clones best`),s}catch(e){return z(`Upload failed: ${V(e)}`,`error`),null}finally{yc.value=!1}}var xc=I([]);async function Sc(e,t,n){let r=await vo(e,new Blob([t],{type:`audio/wav`}),n);return xc.value=[...xc.value,{id:r.id,label:r.label,clip:t}],r}async function Cc(e,t){let n=await yo(e,t);return xc.value=[...xc.value,{id:n.id,label:n.label,embedding:t.slice()}],n}var wc=I(null),Tc=I(0),Ec=I(null);async function Dc(){if(!navigator.mediaDevices?.getUserMedia){z(`Recording needs HTTPS (or localhost)`,`error`);return}let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){z(e instanceof DOMException&&(e.name===`NotAllowedError`||e.name===`SecurityError`)?`Allow the microphone in the browser’s site settings`:`Microphone unavailable: ${V(e)}`,`error`);return}let t=E(e,e=>Tc.value=e),n=new MediaRecorder(e),r=[];n.ondataavailable=e=>r.push(e.data),n.onstop=async()=>{t.stop(),e.getTracks().forEach(e=>e.stop()),wc.value=null;let i=new Blob(r,{type:n.mimeType});try{let{pcm:e,sr:t}=await Hs(await i.arrayBuffer()),n=e.length/t;if(n<2){z(`Too short: record at least 2 s`,`error`);return}Ec.value={blob:i,pcm:e,sr:t,seconds:n}}catch(e){z(`Couldn’t read the recording: ${V(e)}`,`error`)}},n.start();let i=setTimeout(()=>n.state===`recording`&&n.stop(),3e4);wc.value={started:Date.now(),stop:()=>{clearTimeout(i),n.state===`recording`&&n.stop()}}}async function Oc(){let e=Ec.value;if(!e)return null;Ec.value=null;let t=new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return bc(e.blob,`Recording ${t}`,`recording.webm`,!0)}function kc(e,t){let n=t.trim();n&&(xc.value=xc.value.map(t=>t.id===e?{...t,label:n}:t),H.value=H.value.map(t=>t.id===e?{...t,label:n}:t))}function Ac(e){let t=xc.value.find(t=>t.id===e),n=H.value.find(t=>t.id===e);if(!n)return null;let r=xc.value.indexOf(t),i=H.value.indexOf(n);return xc.value=xc.value.filter(t=>t.id!==e),H.value=H.value.filter(t=>t.id!==e),()=>{t&&!xc.value.some(t=>t.id===e)&&(xc.value=[...xc.value.slice(0,r),t,...xc.value.slice(r)]),H.value.some(t=>t.id===e)||(H.value=[...H.value.slice(0,i),n,...H.value.slice(i)])}}var jc=I([]);function Mc(e){jc.value=[...jc.value.filter(t=>t.id!==e.id),e]}function Nc(e){let t=jc.value.findIndex(t=>t.id===e);if(t<0)return null;let n=jc.value[t];return jc.value=jc.value.filter(t=>t.id!==e),{persona:n,index:t}}function Pc(e,t){let n=jc.value.filter(t=>t.id!==e.id);jc.value=[...n.slice(0,t),e,...n.slice(t)]}function Fc(e,t){let n=t.trim();n&&(jc.value=jc.value.map(t=>t.id===e?{...t,name:n}:t))}var Ic=(e=`embedding`)=>({baseId:``,mode:e,values:{},pin:vs()}),U=new Cs(Ic()),W=U.state,Lc=(e,t)=>bs(t.pin,e.ui.accents),Rc=(e,t)=>Gt(e,t.values,Lc(e,t),t.mode),zc=L(()=>Lc(R.value,W.value)),Bc=L(()=>Rc(R.value,W.value)),Vc=L(()=>Yt(R.value,W.value.values,zc.value,W.value.mode)),Hc=L(()=>H.value.find(e=>e.id===W.value.baseId)??null),Uc=L(()=>pc(W.value.baseId)),Wc=L(()=>{let e=Uc.value;return e&&W.value.mode===`embedding`?en(R.value,e,Bc.value):null}),Gc=L(()=>!La(Hc.value));function Kc(e,t){let n=R.value.ui.controls.find(t=>t.id===e);if(!n)return;let r=W.value;U.set({...r,values:{...r.values,[e]:Math.round(F(t,n.range[0],n.range[1])*100)/100}})}function qc(e){U.set({...W.value,pin:e})}function Jc(e){let t=W.value;if(e===t.baseId&&!Object.values(t.values).some(Boolean)&&!Object.keys(Lc(R.value,t)).length)return;let n=H.value.find(e=>e.id===t.baseId);U.apply({baseId:e,mode:La(H.value.find(t=>t.id===e))?`embedding`:La(n)?ha.value.voiceMode:t.mode,values:{},pin:vs(t.pin.tab)})}var Yc=(e=W.value)=>Object.values(e.values).some(Boolean)||Object.keys(Lc(R.value,e)).length>0;function Xc(e,t){let n=W.value;if(e===n.baseId&&!Yc(n))return;let r=Yc(n);if(Jc(e),!r)return;let i=H.value.find(t=>t.id===e)?.label??`this voice`;z(`Starting from ${t===`clip`?`the new clip`:i}; your moves were cleared`,`info`,{label:`Undo`,run:()=>U.undo()})}function Zc(e,t){e===`reference`&&t===`embedding`&&z(`Switched to Designable`)}function Qc(e){e!==W.value.mode&&U.apply({...W.value,mode:e})}function $c(e){let t=R.value.ui.presets[e];if(!t)return;let{values:n,accents:r}=Kt(t),i=W.value;U.apply({...i,mode:`embedding`,values:n,pin:Ss(r,R.value.ui.accents,i.pin.tab)}),Yc(i)&&z(`Applied ${e}; your moves were replaced`,`info`,{label:`Undo`,run:()=>U.undo()}),Zc(i.mode,`embedding`)}function el(){let e=W.value,t=ol();U.apply(t),z(`Rolled on ${H.value.find(e=>e.id===t.baseId)?.label??`a voice`}`,`info`,{label:`Undo`,run:()=>U.undo()}),Zc(e.mode,t.mode)}function tl(){let e=W.value,t=R.value,n={};for(let[r,i]of Object.entries(e.values)){let a=t.ui.controls.find(e=>e.id===r);a&&!Wt(t,a,e.mode)&&(n[r]=i)}let r=t.ui.accents.some(n=>Wt(t,n,e.mode));Yc(e)&&(U.apply({...e,values:n,pin:r?vs(e.pin.tab):e.pin}),z(`Controls reset`,`info`,{label:`Undo`,run:()=>U.undo()}))}var nl=(e,t)=>e[Math.floor(t()*e.length)];function rl(e,t,n){let[r,i]=e.safe;return Math.round((r+(i-r)*t())*n*10)/10}var il={who:!0,texture:!0,room:!0};function al(e,t,n){let r=[...e];for(let e=0;ee.is_default),r={};for(let n of t.ui.controls)n.group===`who`&&(r[n.id]=rl(n,e,.5));let i=t.ui.controls.filter(e=>il[e.group]&&e.group!==`who`);for(let t of al(i,1+Math.floor(e()*2),e))r[t.id]=rl(t,e,.5);let a=vs(W.value.pin.tab);if(e()<.33){let n=nl(t.ui.accents,e);a=xs(n,n.safe[1]*(.3+.4*e()),t.ui.accents)}return{baseId:(nl(n,e)??H.value[0])?.id??W.value.baseId,mode:`embedding`,values:r,pin:a}}function sl(e,t,n){let r=n-t;return e.type===`bipolar`&&e.poles?`${r>0?e.poles[1]:e.poles[0]} ${Math.abs(r).toFixed(1)}`:`${e.label.toLowerCase()} ${jt(r)}`}function cl(e){let t=Object.entries(e).sort((e,t)=>t[1]-e[1])[0];return t?`${R.value.ui.accents.find(e=>e.id===t[0])?.label??t[0]} ${t[1].toFixed(1)}`:`no accent`}function ll(e,t=5,n=Math.random){let r=R.value,i=r.ui.controls.filter(t=>!t.span_only&&Wt(r,t,e.mode)),a=r.ui.accents.filter(t=>Wt(r,t,e.mode)),o=[];for(let s=0;s{let r=t.value;clearTimeout(n),n=window.setTimeout(()=>{try{localStorage.setItem(ul+e,JSON.stringify(r))}catch{}},300)})}var pl=4321;function ml(e,t,n){let r=0;for(;re<=r?e:e>=a?e+(n.length-t.length):i?o:r;return e.map(e=>({...e,start:s(e.start,!1),end:s(e.end,!0)})).filter(e=>e.end>e.start)}function hl(e,t,n){if(!n)return t;let r={...t};for(let t of e.ui.controls){let e=n[t.id];e&&(r[t.id]=F((r[t.id]??0)+e,t.range[0],t.range[1]))}return r}function gl(e,t,n){return!/\S/.test(e.slice(0,t))&&!/\S/.test(e.slice(n))&&/\S\s+\S/.test(e)}function _l(e,t,n,r=!1){let i={};for(let a of e.ui.controls){let o=t.values[a.id];o&&a.spannable&&!(r&&a.span_only)&&Wt(e,a,n.mode)&&Ht(a,o,i)}return i}function vl(e,t,n,r,i=e=>e){let a=[];for(let o of[...t??[]].sort((e,t)=>e.start-t.start)){let t=_l(e,o,n,gl(r,o.start,o.end)),s=i(F(o.start,0,r.length),-1),c=i(F(o.end,0,r.length),1),l=a[a.length-1];l&&ss&&Object.keys(t).length&&a.push({start:s,end:c,controls:t})}return a}function yl(e,t,n,r,i,a={}){let o=bn(r,t.phonemeTokens),s={...e.ui.request_defaults,text:o.text,seed:i,speaker_embedding_id:n.baseId,speaker_mode:n.mode};if(a.language&&a.language!==`en_us`&&(s.language=a.language),a.unsteered)return s;let c=t.tags,l=t.tagStrength;c&&l>1&&An(r)&&(s.tag_cfg_scale=Math.round(F(l,Math.max(1,c.min_scale),c.max_scale)*100)/100,s.speaker_cfg_scale=1);let u=Gt(e,hl(e,n.values,a.extra),bs(n.pin,e.ui.accents),n.mode);Object.keys(u).length&&(s.controls=u);let d=vl(e,a.spans,n,r,o.map);return d.length&&(s.control_spans=d,s.control_span_follow=`reading`,a.spanRate&&(s.control_span_rate=Math.round(a.spanRate*1e3)/1e3)),s}var bl=250,xl=I(`A`),Sl=I(dl(`autoplay`,!0));fl(`autoplay`,Sl);var Cl=I(dl(`autoRender`,!0));fl(`autoRender`,Cl);var wl=I(``),Tl=I(!1),El=L(()=>{let e=wl.value.trim();return Tl.value?e:e||R.value.ui.preview_text}),Dl=I({status:`idle`,key:``,a:null,partial:null,error:null}),Ol=I({key:``,take:null,error:null}),kl=`preview:A`,Al=`preview:B`,jl=0,Ml=null,Nl=null,Pl=null,Fl=!1,Il=!1,Ll=!1;function Rl(){Il=!0,queueMicrotask(()=>Il=!1)}function zl(){return xl.value!==`A`||!(Sl.value||Fl)?!1:(Fl=!1,!0)}function Bl(e){zl()&&Rs(kl,e.pcm,e.sr)}async function Vl(e,t){Ml?.abort();let n=Ml=new AbortController;Dl.value={...Dl.value,status:`rendering`,key:t,partial:null,error:null};let r=null,i=[],a=0;try{let o=await ec(e,{signal:n.signal,onChunk:(e,t)=>{if(n.signal.aborted)return;!r&&zl()&&(r=Vs(kl,t)),r?.push(e),i.push(e),a+=e.length;let o=new Float32Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;Dl.value={...Dl.value,partial:o}}});if(n.signal.aborted)return;r?.end(),Dl.value={status:`ready`,key:t,a:o,partial:null,error:null},Hl()}catch(e){if(tc(e)||n.signal.aborted)return;Fl=!1,zs(`preview:A`)&&Is(),Dl.value={...Dl.value,status:`error`,partial:null,error:V(e)}}}async function Hl(){let e=Pl;if(!e)return;let t=Ys(e);if((Ol.value.key!==t||!Ol.value.take&&!Ol.value.error)&&(Ol.value={key:t,take:Xs(e)??null,error:null},!Ol.value.take))try{let n=await ec(e);Ol.value.key===t&&(Ol.value={key:t,take:n,error:null})}catch(e){Ol.value.key===t&&!tc(e)&&(Ol.value={key:t,take:null,error:V(e)})}}function Ul(){Ol.value={key:``,take:null,error:null},Hl()}function Wl(e){clearTimeout(jl);let t=Xs(Nl);if(t){Ml?.abort(),Dl.value={status:`ready`,key:e,a:t,partial:null,error:null},Bl(t),Hl();return}Dl.value={...Dl.value,status:`waiting`,key:e,error:null};let n=Nl;jl=window.setTimeout(()=>void Vl(n,e),bl)}function Gl(e){clearTimeout(jl),Ml?.abort(),Fl=!1;let t=Xs(Nl);Dl.value=t?{status:`ready`,key:e,a:t,partial:null,error:null}:{...Dl.value,status:`idle`,key:e,partial:null,error:null}}function Kl(){Il=!0,Ll=Cl.peek(),Ji(()=>{let e=W.value,t=El.value,n=R.value,r=Cl.value;if(!e.baseId||!t)return;let i=yn(t,ga.value);if(i){Ai(()=>{Nl=Pl=null,clearTimeout(jl),Ml?.abort(),Dl.value={...Dl.value,status:`error`,key:``,partial:null,error:i}});return}let a=ha.value.language;Nl=yl(n,_a.value,e,t,pl,{language:a}),Pl=yl(n,_a.value,e,t,pl,{unsteered:!0,language:a}),Ai(()=>{let e=Ys(Nl),t=Dl.value,n=r&&!Il,i=r&&!Ll;Ll=r,(e!==t.key||n&&i&&(t.status===`idle`||t.status===`error`))&&(e!==t.key&&!Il&&(xl.value=`A`),n?Wl(e):Gl(e))})}),Il=!1}function ql(){let e=W.value,t=yl(R.value,_a.value,e,El.value,pl,{language:ha.value.language});Dl.value={...Dl.value,key:``},Vl(t,Ys(t))}function Jl(e){if(e===`A`)return Xl();xl.value=`B`;let t=Ol.value.take;t?Rs(Al,t.pcm,t.sr):Hl().then(()=>Ol.value.take&&xl.value===`B`&&Rs(`preview:B`,Ol.value.take.pcm,Ol.value.take.sr))}function Yl(){zs(`preview:A`)||zs(`preview:B`)?Is():Jl(xl.value)}function Xl(){xl.value=`A`;let e=Dl.value;if(e.status===`ready`&&e.a)return Rs(kl,e.a.pcm,e.a.sr);Nl?(Fl=!0,e.status!==`rendering`&&(clearTimeout(jl),Vl(Nl,Ys(Nl)))):W.value.baseId||z(`Pick a voice first`)}var Zl=Symbol.for(`pv`),Ql=0;Array.isArray;function G(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:Zl,__v:--Ql,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),A.vnode&&A.vnode(l),l}function $l({d:e}){let t=Math.round(e.fraction*100);return G(`div`,{class:`dl`,role:`progressbar`,"aria-label":e.label,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t,"aria-valuetext":`${t}% · ${e.detail}`,children:[G(`div`,{class:`dl-head`,children:[G(`span`,{class:`dl-label`,children:e.label}),G(`span`,{class:`dl-pct`,children:[t,`%`]})]}),G(`div`,{class:`dl-track`,children:G(`div`,{class:`dl-fill`,style:{width:`${e.fraction*100}%`}})}),G(`span`,{class:`dl-detail`,children:e.detail})]})}function K({name:e,size:n=16,filled:r,title:i}){let o=r??!!t[e];return G(`svg`,{class:`icon`,width:n,height:n,viewBox:`0 0 24 24`,"aria-hidden":i?void 0:`true`,role:i?`img`:void 0,children:[i&&G(`title`,{children:i}),G(`path`,{d:a[e]??``,fill:o?`currentColor`:`none`,stroke:o?`none`:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}var eu=Uint8Array,tu=Uint16Array,nu=Int32Array,ru=new eu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),iu=new eu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),au=new eu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ou=function(e,t){for(var n=new tu(31),r=0;r<31;++r)n[r]=t+=1<>1|(mu&21845)<<1;hu=(hu&52428)>>2|(hu&13107)<<2,hu=(hu&61680)>>4|(hu&3855)<<4,pu[mu]=((hu&65280)>>8|(hu&255)<<8)>>1}for(var gu=(function(e,t,n){for(var r=e.length,i=0,a=new tu(t);i>c]=l}else for(s=new tu(r),i=0;i>15-e[i]);return s}),_u=new eu(288),mu=0;mu<144;++mu)_u[mu]=8;for(var mu=144;mu<256;++mu)_u[mu]=9;for(var mu=256;mu<280;++mu)_u[mu]=7;for(var mu=280;mu<288;++mu)_u[mu]=8;for(var vu=new eu(32),mu=0;mu<32;++mu)vu[mu]=5;var yu=gu(_u,9,0),bu=gu(_u,9,1),xu=gu(vu,5,0),Su=gu(vu,5,1),Cu=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},wu=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Tu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Eu=function(e){return(e+7)/8|0},Du=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new eu(e.subarray(t,n))},Ou=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],ku=function(e,t,n){var r=Error(t||Ou[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ku),!n)throw r;return r},Au=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new eu(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new eu(i*3));var l=function(e){var t=n.length;if(e>t){var r=new eu(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=wu(e,d,1);var v=wu(e,d+1,3);if(d+=3,!v){var y=Eu(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&ku(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=bu,m=Su,h=9,g=5;else if(v==2){var S=wu(e,d,31)+257,C=wu(e,d+10,15)+4,w=S+wu(e,d+5,31)+1;d+=14;for(var T=new eu(w),E=new eu(19),D=0;D>4;if(y<16)T[D++]=y;else{var re=0,ie=0;for(y==16?(ie=3+wu(e,d,3),d+=2,re=T[D-1]):y==17?(ie=3+wu(e,d,7),d+=3):y==18&&(ie=11+wu(e,d,127),d+=7);ie--;)T[D++]=re}}var k=T.subarray(0,S),ae=T.subarray(S);h=Cu(k),g=Cu(ae),p=gu(k,h,1),m=gu(ae,g,1)}else ku(1);if(d>_){c&&ku(0);break}}s&&l(f+131072);for(var A=(1<>4;if(d+=re&15,d>_){c&&ku(0);break}if(re||ku(2),ce<256)n[f++]=ce;else if(ce==256){se=d,p=null;break}else{var le=ce-254;if(ce>264){var D=ce-257,ue=ru[D];le=wu(e,d,(1<>4;de||ku(3),d+=de&15;var ae=du[fe];if(fe>3){var ue=iu[fe];ae+=Tu(e,d)&(1<_){c&&ku(0);break}s&&l(f+131072);var pe=f+le;if(f>8},Mu=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Nu=function(e,t){for(var n=[],r=0;rf&&(f=a[r].s);var p=new tu(f+1),m=Pu(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<t)h+=_-(1<>=g;h>0;){var y=a[r].s;p[y]=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new eu(p),l:m}},Pu=function(e,t,n){return e.s==-1?Math.max(Pu(e.l,t,n+1),Pu(e.r,t,n+1)):t[e.s]=n},Fu=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new tu(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Iu=function(e,t){for(var n=0,r=0;r>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a4&&!E[au[O-1]];--O);var ee=l+5<<3,te=Iu(i,_u)+Iu(a,vu)+o,ne=Iu(i,f)+Iu(a,h)+o+14+3*O+Iu(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&ee<=te&&ee<=ne)return Lu(t,u,e.subarray(c,c+l));var re,ie,k,ae;if(ju(t,u,1+(ne15&&(ju(t,u,ce[w]>>5&127),u+=ce[w]>>12)}}else re=yu,ie=_u,k=xu,ae=vu;for(var w=0;w255){var le=ue>>18&31;Mu(t,u,re[le+257]),u+=ie[le+257],le>7&&(ju(t,u,ue>>23&31),u+=ru[le]);var de=ue&31;Mu(t,u,k[de]),u+=ae[de],de>3&&(Mu(t,u,ue>>5&8191),u+=iu[de])}else Mu(t,u,re[ue]),u+=ie[ue]}return Mu(t,u,re[256]),u+ie[256]},zu=new nu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bu=new eu(0),Vu=function(e,t,n,r,i,a){var o=a.z||e.length,s=new eu(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=zu[t-1],f=d>>13,p=d&8191,m=(1<7e3||E>24576)&&(re>423||!l)){u=Ru(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var ie=0;ie<286;++ie)x[ie]=0;for(var ie=0;ie<30;++ie)S[ie]=0}var k=2,ae=0,A=p,oe=te-ne&32767;if(re>2&&ee==y(T-oe))for(var se=Math.min(f,re)-1,ce=Math.min(32767,T),le=Math.min(258,re);oe<=ce&&--A&&te!=ne;){if(e[T+k]==e[T+k-oe]){for(var ue=0;uek){if(k=ue,ae=oe,ue>se)break;for(var de=Math.min(oe,ue-2),fe=0,ie=0;iefe&&(fe=me,ne=pe)}}}te=ne,ne=h[te],oe+=te-ne&32767}if(ae){b[E++]=268435456|lu[k]<<18|fu[ae];var he=lu[k]&31,ge=fu[ae]&31;w+=ru[he]+iu[ge],++x[257+he],++S[ge],D=T+k,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T=o&&(c[u/8|0]=l,_e=o),u=Lu(c,u+1,e.subarray(T,_e))}a.i=o}return Du(s,0,r+Eu(u)+i)},Hu=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),Uu=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r>>8;e=n},d:function(){return~e}}},Wu=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new eu(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return Vu(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},Gu=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},Ku=function(e,t){return e[t]|e[t+1]<<8},qu=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ju=function(e,t){return qu(e,t)+qu(e,t+4)*4294967296},Yu=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Xu(e,t){return Wu(e,t||{},0,0)}function Zu(e,t){return Au(e,{i:2},t&&t.out,t&&t.dictionary)}var Qu=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=Gu(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,s]:(n[o+=`/`]=[new eu(0),s],Qu(a,o,n,r))}},$u=typeof TextEncoder<`u`&&new TextEncoder,ed=typeof TextDecoder<`u`&&new TextDecoder;try{ed.decode(Bu,{stream:!0})}catch{}var td=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Du(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function nd(e,t){if(t){for(var n=new eu(e.length),r=0;r>1)),o=0,s=function(e){a[o++]=e},r=0;ra.length){var c=new eu(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return Du(a,0,o)}function rd(e,t){if(t){for(var n=``,r=0;r65535&&ku(9),t+=r+4}return t},cd=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=sd(l);Yu(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&ku(10),Yu(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Yu(e,t,n.crc),Yu(e,t+4,a<0?-a-2:a),Yu(e,t+8,n.size)),Yu(e,t+12,c),Yu(e,t+14,d),t+=16,o!=null&&(Yu(e,t,u),Yu(e,t+6,n.attrs),Yu(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;Yu(e,t,+m),Yu(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},ld=function(e,t,n,r,i){Yu(e,t,101010256),Yu(e,t+8,n),Yu(e,t+10,n),Yu(e,t+12,r),Yu(e,t+16,i)};function ud(e,t){t||={};var n={},r=[];Qu(e,``,n,t);var i=0,a=0;for(var o in n){var s=n[o],c=s[0],l=s[1],u=l.level==0?0:8,d=nd(o),f=d.length,p=l.comment,m=p&&nd(p),h=m&&m.length,g=sd(l.extra);f>65535&&ku(11);var _=u?Xu(c,l):c,v=_.length,y=Uu();y.p(c),r.push(Gu(l,{size:c.length,crc:y.d(),c:_,f:d,m,u:f!=o.length||m&&p.length!=h,o:i,compression:u})),i+=30+f+g+v,a+=76+2*(f+g)+(h||0)+v}for(var b=new eu(a+22),x=i,S=a-i,C=0;C65558)&&ku(13);var i=Ku(e,r+8);if(!i)return{};var a=qu(e,r+16),o=qu(e,r-20)==117853008;if(o){var s=qu(e,r-12);o=qu(e,s)==101075792,o&&(i=qu(e,s+32),a=qu(e,s+48))}for(var c=t&&t.filter,l=0;l({id:Mt(),text:e,spans:[],...t?{voice:t}:{}});function pd(e,t={}){let n=e.split(/\n+/);return(t.sentences===!1?n:n.flatMap(e=>e.split(/(?<=[.!?…])\s+(?=\S)/))).map(e=>e.trim()).filter(Boolean)}function md(e,t){let n=new Map;for(let t of e)n.set(t.text,[...n.get(t.text)??[],t]);let r=new Set;return{lines:t.map(e=>{let t=n.get(e)?.shift()??null;return t&&r.add(t.id),t}).map((n,i)=>{if(n)return n;let a=t[i],o=e[i];return o&&!r.has(o.id)?(r.add(o.id),{...o,text:a,spans:ml(o.spans,o.text,a)}):fd(a)}),dropped:e.filter(e=>!r.has(e.id))}}function hd(e,t,n={}){return e.text===t.text?e.speaker_embedding_id!==t.speaker_embedding_id||e.speaker_mode!==t.speaker_mode?`voice changed`:(e.language??`en_us`)===(t.language??`en_us`)?JSON.stringify(e.control_spans??[])===JSON.stringify(t.control_spans??[])?JSON.stringify(e.controls??{})===JSON.stringify(t.controls??{})?e.tag_cfg_scale===t.tag_cfg_scale?null:`tag strength changed`:n.voiceEdited?`voice edited`:`baseline changed`:`painting changed`:`language changed`:`text changed`}var gd=15,_d=()=>({lines:[],baseline:{},voice:null,gap:.35}),vd=new Cs(_d()),q=vd.state,J=I({}),yd=I({}),bd=I({}),xd=I([]),Sd=I(null),Cd=L(()=>Sd.value!==null),wd=I(null),Td=L(()=>{let e=q.value.voice;return e&&jc.value.find(t=>t.id===e)?.design||W.value});function Ed(e){return e.voice??q.value.voice}function Dd(e){let t=Ed(e);return t&&jc.value.find(e=>e.id===t)?.design||W.value}var Od=e=>vd.set(e(q.value)),kd=e=>vd.apply(e(q.value));function Ad(e,t){kd(n=>({...n,lines:n.lines.map(n=>n.id===e?{...n,text:t,spans:ml(n.spans,n.text,t)}:n)})),bd.value[e]&&(bd.value={...bd.value,[e]:null})}function jd(e){let{lines:t}=md(q.value.lines,e);kd(e=>({...e,lines:t}))}function Md(e){let t=q.value.lines.filter(t=>t.voice===e).map(e=>e.id);return kd(t=>({...t,voice:t.voice===e?null:t.voice,lines:t.lines.map(t=>t.voice===e?{...t,voice:null}:t)})),t}function Nd(e,t,n){let r=new Set(e);kd(e=>({...e,voice:n===void 0?e.voice:n,lines:e.lines.map(e=>r.has(e.id)?{...e,voice:t}:e)}))}function Pd(e,t=``,n){let r=fd(t,n);return kd(t=>{let n=[...t.lines],i=e?n.findIndex(t=>t.id===e)+1:n.length;return n.splice(i,0,r),{...t,lines:n}}),r.id}function Fd(e){let t=q.value.lines.findIndex(t=>t.id===e);if(t<0)return null;let n=q.value.lines[t],r=J.value[e]??[];return kd(t=>({...t,lines:t.lines.filter(t=>t.id!==e)})),{line:n,index:t,takes:r}}function Id(e,t,n){kd(n=>{let r=n.lines.filter(t=>t.id!==e.id),i=Math.min(t,r.length);return{...n,lines:[...r.slice(0,i),e,...r.slice(i)]}}),n.length&&(J.value={...J.value,[e.id]:n})}function Ld(e,t){kd(n=>{let r=[...n.lines],i=r.findIndex(t=>t.id===e),a=i+t;return i<0||a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,lines:r})})}function Rd(e){kd(t=>({...t,voice:e}))}function zd(e,t){kd(n=>({...n,lines:n.lines.map(n=>n.id===e?{...n,voice:t}:n)}))}var Bd=[0,1.5];function Vd(e,t){vd.patch({...q.value,voiceColors:{...q.value.voiceColors,[e]:t}})}function Hd(e,t){Od(n=>({...n,baseline:{...n.baseline,[e]:Math.round(t*100)/100}}))}function Ud(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function Wd(e){let t=e.map(e=>({...e,values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e))})).filter(e=>e.end>e.start&&Object.keys(e.values).length).sort((e,t)=>e.start-t.start),n=[];for(let e of t){let t=n[n.length-1];t&&t.end===e.start&&Ud(t.values,e.values)?n[n.length-1]={...t,end:e.end}:n.push(e)}return n}function Gd(e,t,n,r,i){let a=[],o=[];for(let r of e){if(r.end<=t||r.start>=n){a.push(r);continue}r.startn&&a.push({...r,id:Mt(),start:n});let e={...r,start:Math.max(r.start,t),end:Math.min(r.end,n)};o.push(e)}o.sort((e,t)=>e.start-t.start);let s=t,c=[];for(let e of o)e.start>s&&c.push({id:Mt(),start:s,end:e.start,values:{}}),c.push(e),s=e.end;s({...a,lines:a.lines.map(a=>a.id===e?{...a,spans:Gd(a.spans,t,n,r,i)}:a)}))}function qd(e,t){return e.spans.find(e=>t>=e.start&&tr>=e.start&&rr>=e.start&&rt.text===e.text),r=n[n.length-1],i=ha.value.language,a=r?.audio.spanFollow===`reading`&&(r.request.language??`en_us`)===i,o=r&&!a?Jd(r):void 0;return yl(R.value,_a.value,Dd(e),e.text,t,{extra:q.value.baseline,spans:e.spans,spanRate:o,language:i})}var Xd=new Map;function Zd(e){Xd.get(e)?.abort()}async function Qd(e,t){let n=q.value.lines.find(t=>t.id===e);if(!n||!n.text.trim())return!1;let r=yn(n.text,ga.value);if(r)return bd.value={...bd.value,[e]:r},!1;Xd.get(e)?.abort();let i=new AbortController;Xd.set(e,i),t?.addEventListener(`abort`,()=>i.abort(),{once:!0}),t?.aborted&&i.abort();let a=(J.value[e]??[]).length?Math.floor(Math.random()*1e6):pl;yd.value={...yd.value,[e]:!0},bd.value={...bd.value,[e]:null};try{let t=Yd(n,a),r=await ec(t,{signal:i.signal}),o=J.value[e]??[],s={id:Mt(),text:n.text,seed:a,request:t,audio:r,createdAt:Date.now(),starred:!0},c=[...o.map(e=>e.starred?{...e,starred:!1}:e),s];return J.value={...J.value,[e]:c},xd.value.includes(e)&&(xd.value=xd.value.filter(t=>t!==e)),!0}catch(t){return tc(t)||(bd.value={...bd.value,[e]:V(t)},xd.value.includes(e)||(xd.value=[...xd.value,e])),!1}finally{Xd.get(e)===i&&Xd.delete(e),yd.value={...yd.value,[e]:!1}}}var $d=I(null),ef=null;function tf(){ef?.abort()}async function nf(e){if(!e.length)return;ef?.abort();let t=new AbortController;ef=t,$d.value={total:e.length,done:0,failed:0},await Promise.all(e.map(async e=>{let n=await Qd(e,t.signal),r=$d.value;r&&ef===t&&($d.value={...r,done:r.done+1,failed:r.failed+(n||t.signal.aborted?0:1)})})),ef===t&&(ef=null,$d.value=null)}function rf(e,t){J.value={...J.value,[e]:(J.value[e]??[]).map(e=>({...e,starred:e.id===t}))}}function af(e,t){let n=J.value[e]??[],r=n.findIndex(e=>e.id===t);if(r<0)return null;let i=n[r],a=n.filter(e=>e.id!==t);return a.length&&!a.some(e=>e.starred)&&(a[a.length-1]={...a[a.length-1],starred:!0}),J.value={...J.value,[e]:a},{take:i,index:r,wasStarred:i.starred}}function of(e,t,n,r){let i=(J.value[e]??[]).filter(e=>e.id!==t.id).map(e=>r?{...e,starred:!1}:e),a=Math.min(n,i.length);J.value={...J.value,[e]:[...i.slice(0,a),{...t,starred:r},...i.slice(a)]}}function sf(e,t){let n=(J.value[e]??[]).map(e=>({...e,starred:!1}));return J.value={...J.value,[e]:[...n,{...t,starred:!0}]},n.length+1}var cf=L(()=>q.value.lines.map(e=>{let t=J.value[e.id]??[];return{line:e,take:t.find(e=>e.starred)??t[t.length-1]??null}}));function lf(e,t){return ff(e,t)!==null}var uf=I(0);Ji(()=>{ua.value,_a.value,ha.value.language,W.value,jc.value,q.value.baseline,q.value.voice,Ai(()=>uf.value++)});var df=new WeakMap;function ff(e,t){let n=uf.value,r=df.get(t);if(r&&r.line===e&&r.context===n)return r.reason;let i;if(t.edited)i=t.text===e.text?null:`text changed`;else{let n=Yd(e,t.seed),r=e=>({...e,control_span_rate:void 0,control_span_follow:void 0}),a=r(t.request),o=r(n),s=a.controls??{},c=o.controls??{},l=[...new Set([...Object.keys(s),...Object.keys(c)])].filter(e=>s[e]!==c[e]),u=new Set(Object.keys(Gt(R.value,q.value.baseline,{},Dd(e).mode)));i=hd(a,o,{voiceEdited:l.length>0&&l.some(e=>!u.has(e))})??(JSON.stringify(a)===JSON.stringify(o)?null:`settings changed`)}return df.set(t,{line:e,context:n,reason:i}),i}var pf=L(()=>cf.value.flatMap(({line:e,take:t})=>t&&lf(e,t)?[e]:[])),mf=0,hf=!1;function gf(){hf=!0,queueMicrotask(()=>hf=!1)}Ji(()=>{let e=pf.value.length;Ai(()=>{let t=e>mf&&e-mf>=2;mf=e,t&&!hf&&z(`${e} lines now differ from their keepers`,`info`,{label:`Regenerate`,run:()=>void _f()})})});function _f(){return nf(pf.value.map(e=>e.id))}var vf=L(()=>{let e=q.value.gap,t=[],n=0;for(let[r,{line:i,take:a}]of cf.value.entries()){let o=a?a.audio.pcm.length/a.audio.sr:Math.max(.8,i.text.length/15),s=r?n+e:0;t.push({line:i,take:a,start:s,duration:o}),n=s+o}return{clips:t,total:n}});function yf(){let e=cf.value.flatMap(({take:e})=>e?[e.audio]:[]);return e.length?ln(e,q.value.gap):null}var bf=`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function xf(e,t){let n=[...t.querySelectorAll(bf)].filter(e=>e.offsetParent!==null);if(!n.length)return;let r=n.indexOf(document.activeElement);e.preventDefault(),n[e.shiftKey?r<=0?n.length-1:r-1:r===n.length-1?0:r+1].focus()}function Sf(e,t){(t&&e.querySelector(`${t} button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)||e.querySelector(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`))?.focus({preventScroll:!0})}function Cf(e,t){return n=>{if(n.stopPropagation(),n.key===`Escape`)n.preventDefault(),t();else if(n.key===`Tab`){let t=e();t&&xf(n,t)}}}var wf=I(null);function Tf(e,t={}){wf.value?.resolve(!1);let{promise:n,resolve:r}=Promise.withResolvers();return wf.value={...t,text:e,resolve:r},n}function Ef(){let e=wf.value;return e?G(Df,{q:e}):null}function Df({q:e}){let t=P(null),n=P(null),r=t=>{wf.peek()===e&&(wf.value=null,e.resolve(t))};return pt(()=>{let e=document.activeElement,t=Ta.peek();return Ta.value=!0,n.current?.focus({preventScroll:!0}),()=>{Ta.value=t,e?.isConnected&&e.focus({preventScroll:!0})}},[]),G(`div`,{class:`confirm-backdrop`,onClick:e=>e.target===e.currentTarget&&r(!1),children:G(`div`,{ref:t,class:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-text`,onKeyDown:Cf(()=>t.current,()=>r(!1)),children:[e.title&&G(`h2`,{id:`confirm-title`,children:e.title}),G(`p`,{id:`confirm-text`,class:e.title?void 0:`confirm-only`,children:e.text}),G(`div`,{class:`confirm-actions`,children:[G(`button`,{ref:n,class:`btn sm ghost`,onClick:()=>r(!1),children:`Cancel`}),G(`button`,{class:`btn sm ${e.danger?`proj-danger`:`primary`}`,onClick:()=>r(!0),children:e.ok??`Continue`})]})]})})}var Of=new Cs(null),kf=Of.state,Y=L(()=>kf.value?kf.value.versions[kf.value.current]:null),Af=I(``),jf=I([]),Mf=!1,Nf=I(!1),Pf=I({}),Ff=I(new Map),If=L(()=>mp.value&&Ff.value.get(mp.value)||null);function Lf(e){let t=new Map(Ff.value),n=e?.versionId??mp.value;n&&(e?t.set(n,e):t.delete(n),Ff.value=t)}var Rf=I(`version`),X=I(null),zf=I(null),Bf=I(!1),Vf=I(0),Hf=I(null),Uf=I(`start`),Wf=I(dl(`edit.takes`,2));fl(`edit.takes`,Wf);var Gf=I(dl(`edit.margin`,.08));fl(`edit.margin`,Gf);var Kf=I(null),qf=I(dl(`edit.context`,4));fl(`edit.context`,qf);var Jf=L(()=>ua.value.edit),Yf=L(()=>!!ua.value?.edit.speech_editing),Xf=L(()=>!!ua.value?.edit.edit_transcribe),Zf=L(()=>Math.min(Jf.value.edit_max_seconds,Jf.value.edit_align_max_seconds)),Qf=L(()=>Jf.value.edit_frame_rate||15),$f=L(()=>R.value.ui.controls.filter(e=>e.spannable)),ep=L(()=>{let e=If.value;return e&&e.versionId===Y.value?.id?e.takes[e.selected]??null:null}),tp=L(()=>{let e=Rf.value===`take`?ep.value:null,t=Y.value;return e?{kind:`take`,id:`edit:take:${e.id}`,pcm:e.pcm,sr:e.sr,duration:e.pcm.length/e.sr,words:e.words??[],label:e.label}:t?{kind:`version`,id:`edit:v:${t.id}`,pcm:t.pcm,sr:t.sr,duration:t.pcm.length/t.sr,words:t.words,label:t.label}:null}),np=L(()=>Yf.value&&!!ga.value),rp=L(()=>!!Y.value&&!Y.value.transcript),ip=L(()=>np.value&&!Nf.value?yn(Af.value,ga.value):null),ap=L(()=>{let e=jf.value.length,t=Jf.value.edit_max_spans;return e>t?`Too many separate changes (${e}). One generation handles at most ${t} regions: make fewer changes, move them closer, or remove a manual region.`:null}),op=e=>e/Qf.value;async function sp(e,t){return _(te(e,t).buffer)}var cp=I({}),lp=(e,t)=>`${e.kind}:${e.label}:${t.toFixed(2)}`,up=!1,dp=e=>up||!Xf.value?e:`${e} (the server's first use loads speech recognition: about half a minute)`,fp=I(``);async function pp(e,t,n,r,i){let a=!!r&&vn(r,null).groups.length>0,o=(a?``:r?.trim())??``,s=!o&&Xf.value,c=Zf.value,l=t.length/n;if(l>c)return z(`Editing opens clips up to ${Math.round(c)} s (this one is ${l.toFixed(1)} s).`,`error`,{label:`Open the first ${Math.round(c)} s`,run:()=>void pp(e,t.slice(0,Math.floor((c-.05)*n)),n,r,i)}),!1;if(l<.3)return z(`That clip is too short to edit.`,`error`),!1;if(X.value)return!1;let u=kf.value;if(u&&(u.versions.length>1||hp.value||Ff.value.size>0)&&!await Tf(`Opening another clip closes “${u.name}” — unsaved text, regions and takes are lost. Continue?`,{ok:`Open`,danger:!0}))return!1;fp.value=a?Cn(r):``;let d=ha.value.language,f=i??cp.value[lp(e,l)]??(ee.includes(d)?d:`en_us`);Gp=new AbortController,X.value={label:o?`Aligning the transcript…`:s?dp(`Transcribing…`):`Opening…`,started:performance.now()},zf.value=null,Ca.value=`edit`;try{let r=await sp(t,n),i=o?await wo(r,o,f,Gp.signal):s?await Co(r,f,Gp.signal):{text:``,duration:l,words:[]};s&&(up=!0);let a={id:Mt(),label:`Original`,pcm:t,sr:n,b64:r,duration:i.duration||l,transcript:i.text,words:i.words,alignedWords:i.words,automatic:s};return Is(),Ff.value=new Map,Of.reset({name:e.label,source:e,language:f,versions:[a],current:0}),cp.value={...cp.value,[lp(e,l)]:f},!0}catch(e){return tc(e)?z(`Cancelled`):z(`Couldn’t open the clip: ${V(e)}`,`error`),!1}finally{X.value=null,Gp=null}}var mp=L(()=>Y.value?.id??null);Ji(()=>{mp.value;let e=Ai(()=>Y.value);Ai(()=>{Hf.value=null,zf.value=null,Rf.value=`version`,Nf.value=!!e&&!e.transcript,Vf.value=0,Mf=!1,jf.value=[],Af.value=e?.transcript??``,e&&Fp()})});var hp=L(()=>{let e=Y.value;return!!e&&(Af.value.trim()!==(e.transcript??``).trim()||jf.value.length>0)}),gp=null;Ji(()=>{let e=Y.value,t=e?.words??null;t&&gp&&t!==gp&&Ai(()=>mp.value)===e.id&&Ai(()=>Fp()),gp=t});var _p=.04,vp=.002,yp=I(dl(`edit.preroll`,!1));fl(`edit.preroll`,yp);var bp=(e,t)=>!t||Math.abs(e.start-t.start)>1e-4||Math.abs(e.end-t.end)>1e-4,xp=L(()=>{let e=Y.value;return e?e.words.filter((t,n)=>bp(t,e.alignedWords[n])).length:0}),Sp=e=>{let t=Y.value;return!!t&&bp(t.words[e],t.alignedWords[e])};function Cp(e){let t=kf.value;t&&Of.set({...t,versions:t.versions.map((n,r)=>r===t.current?{...n,words:e}:n)})}function wp(e,t,n,r=!1){let i=Y.value;if(!i||!i.words[e])return;let a=i.words.map(e=>({...e})),o=a[e],s=a[e-1],c=a[e+1];if(t===`start`){let e=!r&&s&&Math.abs(s.end-o.start)Math.round(e*1e4)/1e4,Ep={begin:()=>Of.begin(),end:()=>Of.end()},Dp=0;function Op(e){let t=Hf.value,n=Y.value;if(t===null||!n)return;Of.begin();let r=n.words[t];wp(t,Uf.value,(Uf.value===`start`?r.start:r.end)+e),clearTimeout(Dp),Dp=window.setTimeout(()=>Of.end(),700)}function kp(){let e=kf.value,t=Y.value;e&&t&&xp.value&&(Of.apply({...e,versions:e.versions.map((t,n)=>n===e.current?{...t,words:t.alignedWords}:t)}),z(`Word timings reset to the alignment`))}function Ap(e){let t=tp.value,n=t?.words[e];t&&n&&Rs(t.id,t.pcm,t.sr,Math.max(0,n.start-(yp.value?.3:0)),void 0,n.end)}var jp=L(()=>{let e=Y.value;return!e||e.duration<=16?[]:hr(e.words,jf.value.map(e=>[op(e.start),op(e.end)]),qf.value,e.duration)}),Mp=(e,t)=>Math.max(0,Math.min(e.end,t.end)-Math.max(e.start,t.start));function Np(e){let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start||e.end-t.end)){let e=t[t.length-1];if(e&&n.start-e.end<5){let r=Object.keys(e.values).length>=Object.keys(n.values).length;t[t.length-1]={...e,end:Math.max(e.end,n.end),changes:[...e.changes,...n.changes],manual:e.manual||n.manual,values:r?e.values:n.values,edited:e.edited||n.edited,mergedFrom:(e.mergedFrom??1)+(n.mergedFrom??1)}}else t.push({...n,mergedFrom:void 0})}return t}function Pp(e){let t=Y.value,n=jf.value.find(t=>t.id===e);if(!t||!n||!n.changes.length)return;let r=sr(t.words,Af.value,{duration:t.duration,frameRate:Qf.value,marginSeconds:Gf.value,groups:np.value}),i=t.words.flatMap(e=>e.tokens.map(()=>e)),a=Af.value;for(let e of[...n.changes].sort((e,t)=>t.j1-e.j1)){let t=e.j1e.j1?r.owners[e.j2-1][1]:t,o=[...new Set(i.slice(e.i1,e.i2))].map(e=>e.word),s=e.j1===e.j2&&t>0&&t({id:Mt(),start:e.start,end:e.end,changes:e.changes,manual:!1,values:{}})),...n.filter(e=>e.manual).map(e=>({...e}))]);for(let e of r){if(Object.keys(e.values).length)continue;let t=null;for(let r of n)Mp(r,e)>(t?Mp(t,e):0)&&(t=r);t&&(e.values=t.values)}jf.value=r}function Ip(e){Af.value=e,Fp()}function Lp(e,t){let n=Y.value;if(!n)return;let r=Math.min(e,t),i=Math.max(e,t);for(let e of n.words)e.starte.end<=r+1e-6).pop(),s=n.words.find(e=>e.start>=i-1e-6),[c,l]=or(r,i,o?o.end:null,s?s.start:null,Gf.value,Qf.value,a);jf.value=Np([...jf.value,{id:Mt(),start:c,end:l,changes:[],manual:!0,values:{}}])}function Rp(e,t,n){let r=Y.value;if(!r)return;let i=Math.ceil(r.duration*Qf.value);jf.value=Np(jf.value.map(r=>{if(r.id!==e)return r;r.manual||(Mf=!0);let a=F(Math.round(t*Qf.value),0,i-1);return{...r,start:a,end:F(Math.round(n*Qf.value),a+1,i),edited:!0}}))}function zp(e){jf.value=jf.value.filter(t=>t.id!==e)}function Bp(e,t,n){jf.value=jf.value.map(r=>{if(r.id!==e)return r;let i={...r.values,[t]:Math.round(n*100)/100};return i[t]||delete i[t],{...r,values:i}})}function Vp(e){jf.value=jf.value.map(t=>t.id===e?{...t,values:{}}:t)}function Hp(e,t){let n={...Pf.value,[e]:Math.round(t*100)/100};n[e]||delete n[e],Pf.value=n}function Up(e){let t=Y.value;if(e.manual&&!e.changes.length){let n=op(e.start),r=op(e.end),i=(t?.words??[]).filter(e=>(e.start+e.end)/2>=n&&(e.start+e.end)/2e.word.replace(/^[^\p{L}\p{N}']+|[^\p{L}\p{N}']+$/gu,``));return i.length?`re-say “${i.join(` `)}”`:`re-say this stretch`}return t&&ur(e.changes,t.words,Af.value,np.value)||`changed`}function Wp(e){let t={};for(let n of $f.value){let r=e[n.id];r&&Ht(n,r,t)}for(let e of Object.keys(t))t[e]=Math.round(t[e]*1e4)/1e4;return Object.keys(t).length?t:null}var Gp=null;function Kp(e,t){let{pcm:n,sr:r}=D(h(e.audio_base64));return{id:Mt(),label:t,seed:e.seed,pcm:n,sr:r,b64:e.audio_base64,duration:e.duration,edited:e.edited_regions,fill:e.fill_seconds,stopped:e.stopped,verify:e.verify&&{...e.verify,groups:e.verify.groups?.map(e=>({...e,heard:e.heard?.toLowerCase()??null}))},words:e.words,contexts:[],direction:``,expected:[]}}function qp(e){return $f.value.filter(t=>e[t.id]).map(t=>{let n=e[t.id];return`${t.type===`bipolar`&&t.poles?t.poles[n<0?0:1]:t.label.toLowerCase()} ×${+Math.abs(n).toFixed(2)}`}).join(`, `)}function Jp(e,t){let n=e.map((e,n)=>Object.keys(e.values).length?`r${t[n]+1} ${qp(e.values)}`:``).filter(Boolean);return Object.keys(Pf.value).length&&n.push(`all ${qp(Pf.value)}`),n.join(` · `)}var Yp=L(()=>jf.value.some(e=>Object.keys(e.values).length)||Object.keys(Pf.value).length>0);function Xp(e,t){if(!e.verify)return t.spans.map(()=>[]);let n=ar(t.target,t.groups);return t.spans.map((r,i)=>{let a=[];for(let r of pr(t.targetTokens,e.verify.asr_text,t.wants[i]??[])){let e=n[r],i=e?t.target.slice(e[0],e[1]).replace(/^[^\p{L}\p{N}']+|[^\p{L}\p{N}']+$/gu,``):t.targetTokens[r].toLowerCase();a[a.length-1]!==i&&a.push(i)}return a})}function Zp(e,t){let{spans:n,changes:r,manual:i}=t,a=[];return Xp(e,t).forEach((e,t)=>e.length&&a.push({region:t,text:`Region ${t+1}: words not heard: ${e.join(`, `)}.`,unheard:!0})),n.forEach(([n,o],s)=>{let c=o-n,l=e.fill[s]??0,u=s+1,d=e.expected[s],f=r[s]??[],p=f.length>0&&f.every(e=>e.i1===e.i2&&Array.from({length:e.j2-e.j1},(n,r)=>t.targetTokens[e.j1+r]).every($n));if(e.stopped[s]===!1)a.push({region:s,text:`Region ${u} never stopped (it ran out of room); this take is probably broken.`});else if(p)return;else d!=null&&d>0?l<.5*d?a.push({region:s,text:`Region ${u} came out ${l.toFixed(2)} s for about ${d.toFixed(2)} s of words: words were probably skipped.`}):l>2.5*d+1&&a.push({region:s,text:`Region ${u} came out ${l.toFixed(1)} s for about ${d.toFixed(1)} s of words: it probably ran on past them.`}):l>Math.max(3*c,c+3)?a.push({region:s,text:`Region ${u} came out ${(l/c).toFixed(0)}× longer than the original (${l.toFixed(1)} s): it probably ran on past the new words.`}):(r[s]??[]).some(e=>e.j2>e.j1)&&l<.15?a.push({region:s,text:`Region ${u} came out nearly empty (${l.toFixed(2)} s): the new words were probably dropped.`}):i[s]&&!(r[s]??[]).length&&l<.6*c&&a.push({region:s,text:`Region ${u} came out ${Math.round((1-l/c)*100)}% shorter than the words it re-says (${c.toFixed(2)} → ${l.toFixed(2)} s): words were probably skipped.`})}),a}function Qp(e,t,n=0){let r=e=>{let n=Zp(e,t);return[+!!n.some(e=>e.unheard),+!!n.some(e=>!e.unheard),e.verify?.wer??1/0]},i=(e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],a=n;for(let t=n+1;t!!Y.value&&!Nf.value&&jf.value.length>0&&!ap.value&&!ip.value&&!!Af.value.trim()&&!X.value);function em(e,t){let n=Qf.value,r=Math.round(e*n),i=Math.abs(e*n-r)<.02?r:e*n;return Math.round((i+t*.001)/n*1e6)/1e6}function tm(e,t,n,r=e.b64,i=e.transcript,a){np.value&&(t=bn(t,ga.value).text);let o={audio_base64:r,original_text:i,...a?{original_words:a.map(e=>({word:e.word,start:e.start,end:e.end,tokens:e.tokens}))}:{},target_text:t,spans:n.map(e=>[em(e.start,1),em(e.end,-1)]),margin_seconds:Gf.value,num_takes:Wf.value,verify:Xf.value,seed:Kf.value,language:kf.value?.language??`en_us`};qf.value!==4&&(o.context_seconds=qf.value);let s=Wp(Pf.value);s&&(o.controls=s);let c=n.map(e=>Wp(e.values));return c.some(Boolean)&&(o.region_controls=c),o}async function nm(){if(X.value)return rm();let e=Y.value;if(!e||!$p.value)return;let t=jf.value,n=Af.value.trim(),r=tm(e,n,t.map(e=>({start:op(e.start),end:op(e.end),values:e.values})),e.b64,e.transcript,xp.value?e.words:void 0);Gp=new AbortController,X.value={label:dp(`Generating ${r.num_takes} take${r.num_takes===1?``:`s`}…`),started:performance.now()},zf.value=null,Is();try{let i=await To(r,Gp.signal);r.verify&&(up=!0);let a=i.contexts??[],o=i.takes.map((e,n)=>{let r=Kp(e,`Take ${n+1}`);return r.direction=Jp(t,t.map((e,t)=>t)),r.expected=i.expected_seconds??[],r.contexts=a.map(([e,t])=>[sm(e,i.spans,r.edited),sm(t,i.spans,r.edited)]),r}),s=t.map(e=>e.changes),c=t.map(e=>e.manual),l=np.value,u=l?n:i.target_text||n,d={spans:i.spans,changes:s,manual:c,target:u,targetTokens:tr(u,l),wants:mr(e.words,u,t.map(e=>({start:op(e.start),end:op(e.end),changes:e.changes})),l),groups:l};Lf({versionId:e.id,...d,contexts:a,takes:o,selected:Qp(o,d)}),Rf.value=`take`,Vf.value=0}catch(e){tc(e)||(zf.value=V(e),Bf.value=e instanceof v&&e.status<500)}finally{X.value=null,Gp=null}}function rm(){Gp?.abort()}function im(e){rm(),fp.value=``,Ff.value=new Map,Of.reset(e)}async function am(e){let t=If.value,n=ep.value,r=Y.value;if(!t||!n||!r||X.value)return;let i=jf.value[e],a=tm(r,t.target,[{start:n.edited[e][0],end:n.edited[e][1],values:i?.values??{}}],n.b64,dm(t,n));Gp=new AbortController,X.value={label:dp(`Regenerating region ${e+1}…`),started:performance.now()},zf.value=null,Is();try{let r=await To(a,Gp.signal);a.verify&&(up=!0);let o=r.takes.map((t,a)=>{let o=Kp(t,`${n.label} · region ${e+1} retry ${a+1}`),[s,c]=t.edited_regions[0],l=c-s-(n.edited[e][1]-n.edited[e][0]);return o.edited=n.edited.map((t,n)=>nr===e?t.fill_seconds[0]:n),o.stopped=n.stopped.map((n,r)=>r===e?t.stopped[0]:n),o.direction=Jp([{values:i?.values??{}}],[e])||`r${e+1} undirected`,o.expected=n.edited.map((t,i)=>i===e?r.expected_seconds?.[0]??null:n.expected[i]??null),o.contexts=(r.contexts??[]).map(([e,t])=>[sm(e,n.edited,o.edited),sm(t,n.edited,o.edited)]),o}),s=[...t.takes,...o];Lf({...t,takes:s,selected:Qp(s,t,t.takes.length)}),Rf.value=`take`}catch(e){tc(e)||(zf.value=V(e),Bf.value=e instanceof v&&e.status<500)}finally{X.value=null,Gp=null}}function om(e){let t=If.value;if(!t||!t.takes[e])return;let n=B.value,r=n?ws.value:Vf.value,i=Rf.value===`take`;Lf({...t,selected:e}),Rf.value=`take`;let a=t.takes[e],o=sm(r,i?t.takes[t.selected]?.edited??t.spans:t.spans,a.edited);Vf.value=o,n&&Rs(`edit:take:${a.id}`,a.pcm,a.sr,o)}function sm(e,t,n){let r=0;for(let i=0;i=e.duration-.05?0:Vf.value)}}function um(e){let t=tp.value,n=ep.value,r=jf.value[e];if(!t)return;let i=t.kind===`take`&&n?n.edited[e]:r?[op(r.start),op(r.end)]:null;i&&Rs(t.id,t.pcm,t.sr,Math.max(0,i[0]-1),void 0,Math.min(t.duration,i[1]+.5))}function dm(e,t){return e.groups?Cn(e.target,(t.verify?.groups??[]).map(e=>e.heard)):e.target}async function fm(){let e=If.value,t=ep.value,n=kf.value,r=Y.value;if(!e||!t||!n||!r||X.value)return;let i=n.versions.length-1-n.current;if(!(i>0&&!await Tf(i===1?`Keeping replaces v${n.current+1}. Continue?`:`Keeping replaces v${n.current+1}–v${n.versions.length-1}. Continue?`,{ok:`Keep`,danger:!0}))){Gp=new AbortController,X.value={label:`Keeping the take…`,started:performance.now()};try{let i=dm(e,t),a=i===e.target&&t.words?t.words:(await wo(t.b64,i,n.language,Gp.signal)).words,o=ur(e.changes.flat(),r.words,e.target,e.groups)||(e.manual.some(Boolean)?`regenerated`:`edit`),s={id:Mt(),label:o,pcm:t.pcm,sr:t.sr,b64:t.b64,duration:t.duration,transcript:i,words:a,alignedWords:a,automatic:!1,...i===e.target?{}:{display:e.target}};Is(),Of.apply({...n,versions:[...n.versions.slice(0,n.current+1),s],current:n.current+1});let c=(t.verify?.groups??[]).map(e=>e.heard??`?`);z(i===e.target?`Kept ${t.label.toLowerCase()} as v${n.current+1}`:`Kept ${t.label.toLowerCase()} as v${n.current+1}; its transcript spells the pronunciations as heard (${c.join(`, `)||`guessed`})`,`ok`,{label:`Undo`,run:()=>{Is(),Of.undo()}})}catch(e){tc(e)?z(`Cancelled`):z(`Couldn’t keep the take: ${V(e)}`,`error`)}finally{X.value=null,Gp=null}}}async function pm(){return!hp.value||Tf(`Changing the version discards your unsaved text and regions. Continue?`,{ok:`Continue`,danger:!0})}async function mm(e){let t=kf.value;t&&e!==t.current&&t.versions[e]&&await pm()&&(Is(),Of.apply({...t,current:e}))}async function hm(){Of.canUndo.value&&await pm()&&(Is(),Of.undo())}async function gm(){Of.canRedo.value&&await pm()&&(Is(),Of.redo())}var _m=null;async function vm(e){if(X.value||!e&&rp.value)return;if(e){_m=Af.value,Nf.value=!0;return}let t=Y.value,n=_m!==null&&_m!==(t?.transcript??``);(!n||await Tf(`Leave the transcript fix? Your edited words are kept.`,{ok:`Leave`}))&&(Nf.value=!1,Af.value=n?_m:t?.transcript??``,_m=null,Fp())}function ym(){let e=kf.value,t=Y.value;e&&t&&t.automatic&&Of.apply({...e,versions:e.versions.map((t,n)=>n===e.current?{...t,automatic:!1}:t)})}async function bm(e){let t=kf.value,n=Y.value;if(!t||!n||X.value||e===t.language)return;let r=lp(t.source,t.versions[0].pcm.length/t.versions[0].sr);if(!n.transcript){Of.apply({...t,language:e}),cp.value={...cp.value,[r]:e};return}if(!await pm())return;let i=n.automatic&&Xf.value;Gp=new AbortController,X.value={label:i?dp(`Transcribing…`):`Aligning the transcript…`,started:performance.now()};try{let a=i?await Co(n.b64,e,Gp.signal):await wo(n.b64,n.transcript,e,Gp.signal);i&&(up=!0);let o={...n,id:Mt(),transcript:a.text,words:a.words,alignedWords:a.words};Of.apply({...t,language:e,versions:t.versions.map((e,n)=>n===t.current?o:e)}),cp.value={...cp.value,[r]:e},z(`${i?`Transcribed`:`Aligned`} in ${g(e)}`,`ok`)}catch(t){tc(t)?z(`Cancelled`):z(`Couldn’t switch to ${g(e)}: ${V(t)}`,`error`)}finally{X.value=null,Gp=null}}async function xm(e){let t=kf.value,n=Y.value;if(!t||!n||!e.trim())return;let r=!n.transcript,i=_m!==null&&_m!==(n.transcript??``)?_m:null;Gp=new AbortController,X.value={label:r?`Aligning the transcript…`:`Re-aligning…`,started:performance.now()};try{let a=await wo(n.b64,e.trim(),t.language,Gp.signal),o={...n,id:Mt(),transcript:a.text,words:a.words,alignedWords:a.words,automatic:!1};Of.apply({...t,versions:t.versions.map((e,n)=>n===t.current?o:e)}),_m=null,i&&(Af.value=i,Fp()),z(r?`Transcript aligned: edit the words to change the speech`:`Transcript corrected and re-aligned`,`ok`)}catch(e){tc(e)?z(`Cancelled`):z(`Couldn’t ${r?`align`:`re-align`}: ${V(e)}`,`error`)}finally{X.value=null,Gp=null}}var Sm=L(()=>{let e=kf.value?.source;if(!e||e.kind!==`take`||!e.lineId||!e.takeId)return null;let t=q.value.lines.find(t=>t.id===e.lineId),n=J.value[e.lineId]?.find(t=>t.id===e.takeId);return t&&n?{line:t,take:n}:null}),Cm=L(()=>{let e=kf.value;return!!e&&e.current>0&&e.source.kind===`take`&&!!Sm.value});async function wm(){let e=kf.value,t=Y.value,n=Sm.value;if(!e||!t||!n||!Cm.value)return;let{line:r}=n,i={pcm:t.pcm,sr:t.sr,ttfbMs:0,totalMs:0},a=t.display??t.transcript;z(`Added to Direct as take ${sf(r.id,{id:Mt(),text:a,seed:0,request:Yd(r,0),audio:i,createdAt:Date.now(),starred:!0,edited:!0})}`,`ok`,{label:`Go to Direct`,run:()=>Ca.value=`direct`}),r.text!==a&&await Tf(`Also change the line's text to “${a}”?`,{ok:`Change the text`})&&Ad(r.id,a)}var Tm=I(null),Em=I(0);async function Dm(){if(Tm.value)return Tm.value.stop();let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return z(`Microphone unavailable: ${V(e)}`,`error`)}let t=E(e,e=>Em.value=e),n=new MediaRecorder(e),r=[];n.ondataavailable=e=>r.push(e.data),n.onstop=async()=>{t.stop(),e.getTracks().forEach(e=>e.stop()),Tm.value=null;try{let{pcm:e,sr:t}=await Hs(await new Blob(r,{type:n.mimeType}).arrayBuffer());await pp({kind:`recording`,label:`Recording ${new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`},e,t)}catch(e){z(`Couldn’t read the recording: ${V(e)}`,`error`)}},n.start();let i=Math.min(120,Zf.value),a=setTimeout(()=>n.state===`recording`&&n.stop(),i*1e3);Tm.value={started:Date.now(),stop:()=>{clearTimeout(a),n.state===`recording`&&n.stop()}}}async function Om(e){try{let{pcm:t,sr:n}=await Hs(await e.arrayBuffer());await pp({kind:`upload`,label:e.name.replace(/\.[^.]+$/,``)},t,n)}catch(t){z(`Couldn’t read ${e.name}: ${V(t)}`,`error`)}}var km=`application/x-float32`,Am=new Map,jm=new WeakMap;function Mm(e,t){jm.set(e,t)}var Nm=class{info={};pending=new Map;hit(e,t){let n=jm.get(e),r=n===void 0?void 0:Am.get(n)??this.pending.get(n)?.size;return n===void 0||r===void 0?null:(this.info[n]={type:t,size:r},n)}add(e,t,n){let r=Zr(n);return jm.set(e,r),this.info[r]={type:t,size:n.byteLength},!Am.has(r)&&!this.pending.has(r)&&this.pending.set(r,new Blob([n],{type:t})),r}audio(e,t,n){return this.hit(e,`audio/wav`)??this.add(e,`audio/wav`,n?new Uint8Array(n()):te(e,t))}wav(e){return this.hit(e,`audio/wav`)??this.add(e,`audio/wav`,new Uint8Array(e))}embedding(e){return this.hit(e,`application/x-float32`)??this.add(e,`application/x-float32`,new Uint8Array(e.slice().buffer))}},Pm={gender:{control:`gender`,logit_per_dose:1.31,clip_logit:3},age:{control:`age`,center_years:42,years_per_dose:8.7},landmarks:{}},Fm=L(()=>R.value.ui.who??Pm),Im=I({}),Lm=e=>Math.log(Math.max(1e-6,e)/Math.max(1e-6,1-e));function Rm(e,t){let n=Fm.value;return{x:Math.max(-n.gender.clip_logit,Math.min(n.gender.clip_logit,Lm(e)))/n.gender.logit_per_dose,y:(t-n.age.center_years)/n.age.years_per_dose,measured:!0}}function zm(e){if(!e)return{x:0,y:0,measured:!1};let t=Fm.value.landmarks[e.label];return t?Rm(t.female,t.age):Im.value[e.id]??{x:0,y:0,measured:!1}}var Bm=e=>Fm.value.age.center_years+e*Fm.value.age.years_per_dose,Vm=e=>(e-Fm.value.age.center_years)/Fm.value.age.years_per_dose,Hm=e=>1/(1+Math.exp(-e*Fm.value.gender.logit_per_dose)),Um=L(()=>{let e=Fm.value.gender.clip_logit/Fm.value.gender.logit_per_dose+1.1;return{x:[-e,e],y:[Vm(14),Vm(84)]}});function Wm(e,t,n,r){let i=zm(t);Im.value={...Im.value,[e.id]:{x:i.x+n,y:i.y+r,measured:i.measured,from:t?.label}}}function Gm(e,t){let n=e.lines.map(({id:e,text:t,spans:n,voice:r})=>({id:e,text:t,spans:n,...r?{voice:r}:{}})),r=(t?.lines??[]).map(({id:e,characterId:t,text:n})=>({id:e,text:n,spans:[],voice:t}));return{...e,lines:[...n,...r],gap:e.gap??t?.gap??.35}}function Km(e,t){let n=Date.now();return{schema:1,id:e.id,name:e.name,createdAt:n,updatedAt:n,settings:t,voices:[],cast:{design:Ic(t.voiceMode),personas:[],origins:{},previewText:``},direct:{script:_d(),takes:{}},edit:{doc:null,clipLanguages:{}},media:{}}}var qm=[`design`,`cast`,`voiceOrigins`,`previewText`,`script`,`scene`,`edit.languages`,`pron.language`];function Jm(e){let t=Km(e,{...sa,language:dl(`pron.language`,`en_us`)});return{...t,cast:{design:dl(`design`,t.cast.design),personas:dl(`cast`,[]),origins:dl(`voiceOrigins`,{}),previewText:dl(`previewText`,``)},direct:{script:Gm(dl(`script`,t.direct.script),dl(`scene`,void 0)),takes:{}},edit:{doc:null,clipLanguages:dl(`edit.languages`,{})}}}async function Ym(e,t){let n=({pcm:e,sr:n,...r})=>({...r,media:t.audio(e,n)}),r=kf.value,i=r&&{...r,versions:r.versions.map(({pcm:e,sr:n,b64:r,...i})=>({...i,media:t.audio(e,n,()=>h(r))}))},a=q.value,o=J.value,s={schema:1,id:e.id,name:e.name,createdAt:e.createdAt,updatedAt:e.updatedAt,settings:ha.value,voices:xc.value.map(e=>({id:e.id,label:e.label,kind:e.clip?`clip`:`embedding`,media:e.clip?t.wav(e.clip):t.embedding(e.embedding)})),cast:{design:W.value,personas:jc.value,origins:Im.value,previewText:wl.value},direct:{script:a,takes:Object.fromEntries(a.lines.filter(e=>o[e.id]?.length).map(e=>[e.id,o[e.id].map(e=>({...e,audio:n(e.audio)}))]))},edit:{doc:i,clipLanguages:cp.value},media:t.info};return{...s,summary:ca(s)}}async function Xm(e,t){let n=new Map,r=e=>{let r=n.get(e);return r||(r=t(e).then(e=>e.arrayBuffer()).then(t=>{let n=D(t);return Mm(n.pcm,e),{...n,bytes:t}}),n.set(e,r)),r},i=async({media:e,...t})=>{let{pcm:n,sr:i}=await r(e);return{...t,pcm:n,sr:i}},a=await Promise.all(e.voices.map(async e=>{let n=await(await t(e.media)).arrayBuffer();if(e.kind===`clip`)return Mm(n,e.media),{id:e.id,label:e.label,clip:n};let r=new Float32Array(n);return Mm(r,e.media),{id:e.id,label:e.label,embedding:r}})),o=Object.fromEntries(await Promise.all(Object.entries(e.direct.takes).map(async([e,t])=>[e,await Promise.all(t.map(async e=>({...e,audio:await i(e.audio)})))]))),s=await Promise.all(Object.entries(e.scene?.renders??{}).map(async([e,t])=>[e,await i(t.audio)])),c=e.edit.doc,l=[`take`,`voice`,`upload`,`recording`],u=c&&{...c,source:l.includes(c.source.kind)?c.source:{kind:`upload`,label:c.source.label},versions:await Promise.all(c.versions.map(async({media:e,...t})=>{let{pcm:n,sr:i,bytes:a}=await r(e);return{...t,pcm:n,sr:i,b64:_(a)}}))},d=Gm(e.direct.script,e.scene?.scene);return()=>Di(()=>{Is(),Rl(),gf(),xd.value=[],ha.value={...sa,...e.settings},xc.value=a,U.reset(e.cast.design),jc.value=e.cast.personas,Im.value=e.cast.origins,wl.value=e.cast.previewText,Tl.value=!1,vd.reset(d);let t=s.flatMap(([e,t])=>{let n=d.lines.find(t=>t.id===e);return n?[[e,[{id:Mt(),text:n.text,seed:0,request:Yd(n,0),audio:t,createdAt:Date.now(),starred:!0,edited:!0}]]]:[]});J.value={...o,...Object.fromEntries(t)},yd.value={},bd.value={},cp.value=e.edit.clipLanguages,im(u)})}function Zm(e){let t=new Map,n=(e,n)=>e&&t.set(e,(t.get(e)??new Set).add(n));n(e.cast.design.baseId,`the Cast bench`);for(let t of e.cast.personas)n(t.design.baseId,`cast member “${t.name}”`);return t}function Qm(e,t,n,r=Date.now()){let i=Object.values(e.media);return{id:e.id,name:e.name,createdAt:e.createdAt,updatedAt:e.updatedAt,openedAt:r,size:t.length+i.reduce((e,t)=>e+t.size,0),summary:e.summary??ca(e),revision:n}}var $m=class e{db;kind=`browser`;constructor(e){this.db=e}static async open(t){let n=await ri(`zvs-projects`,1,e=>{e.createObjectStore(`meta`,{keyPath:`id`}),e.createObjectStore(`docs`),e.createObjectStore(`media`,{keyPath:`hash`})});if(t){let e=await ti(n.transaction(`media`).objectStore(`media`).getAll());for(let t of e)Am.set(t.hash,t.size)}return new e(n)}static async count(){try{if(indexedDB.databases&&!(await indexedDB.databases()).some(e=>e.name===`zvs-projects`))return 0;let t=await e.open(!1),n=(await t.list()).length;return t.db.close(),n}catch{return 0}}tx(e,t=`readonly`){return this.db.transaction(e,t)}async list(){return(await ti(this.tx([`meta`]).objectStore(`meta`).getAll())).map(e=>({...e,revision:e.revision??null,summary:e.summary??null}))}async read(e){let t=this.tx([`docs`,`meta`]),[n,r]=await Promise.all([ti(t.objectStore(`docs`).get(e)),ti(t.objectStore(`meta`).get(e))]);if(n===void 0)throw Error(`the project is missing from this browser’s storage`);return{json:n,revision:r?.revision??null}}async media(e){let t=await ti(this.tx([`media`]).objectStore(`media`).get(e));if(!t)throw Error(`An audio file of this project is missing from this browser (${e.slice(0,8)}…)`);return t.blob}async write(e,t,n,r){let i=this.tx([`media`,`docs`,`meta`],`readwrite`),a=await ti(i.objectStore(`meta`).get(e.id)),o=a?.revision??null;if(o!==r)throw i.abort(),new re(o);let s={...Qm(e,t,(typeof o==`number`?o:0)+1,a?.openedAt),media:Object.keys(e.media)};for(let[e,t]of n)Am.has(e)||i.objectStore(`media`).put({hash:e,type:t.type,size:t.size,blob:t});i.objectStore(`docs`).put(t,e.id),i.objectStore(`meta`).put(s),await ni(i);for(let[e,t]of n)Am.set(e,t.size);let{media:c,...l}=s;return a?.media.some(t=>!(t in e.media))&&await this.sweep(),l}async remove(e){let t=this.tx([`docs`,`meta`],`readwrite`);t.objectStore(`docs`).delete(e),t.objectStore(`meta`).delete(e),await ni(t),await this.sweep()}async opened(e){let t=this.tx([`meta`],`readwrite`),n=t.objectStore(`meta`),r=await ti(n.get(e.id));r&&n.put({...r,openedAt:e.openedAt}),await ni(t)}async sweep(){let e=this.tx([`meta`,`media`],`readwrite`),[t,n]=await Promise.all([ti(e.objectStore(`meta`).getAll()),ti(e.objectStore(`media`).getAllKeys())]),r=new Set(t.flatMap(e=>e.media)),i=n.filter(e=>!r.has(e));for(let t of i)e.objectStore(`media`).delete(t);await ni(e);for(let e of i)Am.delete(e)}},eh=e=>typeof e==`number`?e<0xe8d4a51000?e*1e3:e:e&&Date.parse(e)||Date.now(),th=e=>!!e&&typeof e==`object`&&typeof e.takes==`number`;function nh(e){let t=eh(e.updated_at);return{id:e.id,name:e.name??e.id,createdAt:t,updatedAt:t,openedAt:t,size:(e.bytes??0)+(e.media_bytes??0),summary:th(e.summary)?e.summary:null,revision:e.revision}}var rh=class{kind=`server`;async list(){return(await jo()).map(nh)}async read(e){let t=await Mo(e),n=JSON.stringify(t.data);for(let[e,n]of Object.entries(t.data.media??{}))Am.set(e,n.size);return{json:n,revision:t.revision}}media(e){return Io(e)}async write(e,t,n,r){for(let[e,t]of n)await Fo(e)||await Lo(e,t),Am.set(e,t.size);let i=()=>No(e.id,{name:e.name,data:e,base_revision:r}),a;try{a=await i()}catch(e){if(!(e instanceof w))throw e;for(let t of e.missing)Am.delete(t);if(!e.missing.every(e=>n.has(e)))throw e;for(let t of e.missing)await Lo(t,n.get(t));a=await i()}return{...Qm(e,t,a.revision),updatedAt:eh(a.updated_at)}}remove(e){return Po(e)}async opened(){}};async function ih(e,t){let n=new Map;for(let[r,i]of t){if(Qr(r)){n.set(r,i);continue}let t=await $r(new Uint8Array(await i.arrayBuffer()));e=e.split(`"${r}"`).join(`"${t}"`),n.set(t,i)}return{json:e,media:n}}async function ah(e,t){return Qr(e)?await $r(t)===e:ei(t)===e}var oh=I([]),Z=I(null),Q=I(`saved`),sh=I(null),ch=I(!1),lh=I(null),uh=I(0),dh=I(!1),fh=I(null),ph=I({reRegistered:[],issues:[]}),mh=I(null),hh=I(!1),gh=I(!1),_h=`zvs.project`,vh=800,yh=`Untitled project`,bh=`This project was changed elsewhere (another tab or browser) since you opened it. Reload it, or keep your version as a copy.`,xh=`This project was deleted elsewhere (another tab or browser). Keep your version as a copy to go on with it.`,$=null,Sh=new Map,Ch=``,wh=0,Th=Promise.resolve();function Eh(e){let t=Th.then(e);return Th=t.catch(()=>void 0),t}function Dh(e){return e<1e6?`${Math.round(e/1e3)} kB`:e<1e9?`${(e/1e6).toFixed(+(e<1e7))} MB`:`${(e/1e9).toFixed(1)} GB`}var Oh=()=>$?.kind===`server`?`on the server`:`in this browser`;function kh(e){oh.value=[...e].sort((e,t)=>t.openedAt-e.openedAt)}var Ah=e=>kh([...oh.value.filter(t=>t.id!==e.id),e]);async function jh(){if($)try{let e=await $.list(),t=Z.value;kh(t?[...e.filter(e=>e.id!==t.id),t]:e)}catch(e){z(`Couldn’t list the projects: ${V(e)}`,`error`)}}async function Mh(e,t=JSON.stringify(e),n=new Map){return e.summary||(e.summary=ca(e),t=JSON.stringify(e)),Ah(await Eh(()=>$.write(e,t,n,null))),e.id}async function Nh(){if($?.kind!==`browser`)return void(mh.value=null);try{let e=await navigator.storage?.estimate();e&&(mh.value={usage:e.usage??0,quota:e.quota??0})}catch{}}function Ph(e){if(e instanceof re){clearTimeout(wh),ch.value=e.revision===null,Q.value=`conflict`,sh.value=ch.value?xh:bh;return}let t=mh.value,n=e instanceof DOMException&&e.name===`QuotaExceededError`?`Browser storage is full${t?` (${Dh(t.usage)} of ${Dh(t.quota)})`:``}: delete or export projects you don’t need. Your work stays open in this tab.`:`Couldn’t save the project ${Oh()} (${V(e)}). Your work stays open in this tab.`;sh.value!==n&&z(n,`error`),Q.value=`error`,sh.value=n}async function Fh(e=!1){let t=Z.value;if(t&&$&&Q.value!==`conflict`)try{let e=new Nm,n=await Ih(t,e),r=JSON.stringify({...n,updatedAt:0});if(r===Ch){Q.value===`saving`&&(Q.value=`saved`);return}Q.value=`saving`,n.updatedAt=Date.now();let i=JSON.stringify(n),a={...await $.write(n,i,e.pending,t.revision),openedAt:t.openedAt};Ch=r,Z.value=Z.value===t?a:Z.value&&{...Z.value,revision:a.revision},Ah(Z.value??a),Q.value=`saved`,sh.value=null,Hh(n),Nh()}catch(t){if(t instanceof w&&!e)return Fh(!0);Ph(t)}}async function Ih(e,t){let n=await Ym(e,t);return Sh.size?JSON.parse(la(JSON.stringify(n),Sh)):n}function Lh(){return clearTimeout(wh),wh=0,Eh(()=>Fh())}function Rh(){Z.value&&$&&Q.value!==`conflict`&&(clearTimeout(wh),wh=window.setTimeout(()=>void Lh(),vh))}Ji(()=>{W.value,jc.value,Im.value,wl.value,q.value,J.value,kf.value,cp.value,ha.value,xc.value,Ai(Rh)});var zh=0;ic(()=>{Date.now()-zh<1e4||(zh=Date.now(),z(`The server restarted and forgot this voice`,`error`,{label:`Reopen project`,run:()=>void(Q.value===`conflict`?ig():Lh().then(ig))}))}),addEventListener(`visibilitychange`,()=>document.visibilityState===`hidden`&&wh&&void Lh()),addEventListener(`pagehide`,()=>wh&&void Lh()),addEventListener(`beforeunload`,e=>{let t=Q.value;(wh||t===`saving`||t===`error`||t===`conflict`||t===`off`&&Z.value||Yh())&&e.preventDefault()});async function Bh(e){let t=new Set(H.value.map(e=>e.id)),n=new Map,r=[],i=[];for(let a of e.voices)if(!t.has(a.id))try{let e=await $.media(a.media),t=a.kind===`clip`?await vo(a.label,e,`${p(a.label)}.wav`):await yo(a.label,new Float32Array(await e.arrayBuffer()));n.set(a.id,t.id),r.push(a.label)}catch(e){i.push(`“${a.label}”: ${V(e)}`)}let a=new Set(e.voices.map(e=>e.id));for(let[n,r]of Zm(e))!t.has(n)&&!a.has(n)&&i.push(`the voice used by ${[...r].join(`, `)}: it is gone from the server, and the project holds no clip or embedding to recreate it`);return n.size?(await fc(),{doc:JSON.parse(la(JSON.stringify(e),n)),map:n,reRegistered:r,issues:i}):{doc:e,map:n,reRegistered:r,issues:i}}var Vh=new Set;async function Hh(e){let t=Z.value?.id,n=new Set(xc.value.map(e=>e.id));for(let r of Zm(e).keys()){let e=H.value.find(e=>e.id===r);if(!(!e||e.is_default||n.has(r)||Vh.has(r))){Vh.add(r);try{let n;if(La(e)){let{embedding:t,synthetic:i}=await ho(e);if(i)continue;n={id:r,label:e.label,embedding:t}}else n={id:r,label:e.label,clip:await _o(e)};Z.value?.id===t&&(xc.value=[...xc.value,n])}catch{}}}}function Uh(){let e=H.value,t=W.value.baseId;if(e.some(e=>e.id===t))return;let n=e.find(e=>e.is_default)??e[0];n&&(U.reset({...W.value,baseId:n.id,mode:La(n)?`embedding`:ha.value.voiceMode}),t&&z(`Bench switched to ${n.label} because its voice is gone from the server`))}function Wh(){let e=new Set(oh.value.map(e=>e.name));if(!e.has(yh))return yh;for(let t=2;;t++)if(!e.has(`${yh} ${t}`))return`${yh} ${t}`}async function Gh(e,t){let{json:n,revision:r}=await $.read(e),i=JSON.parse(n);if(i.schema>1)throw Error(`it was saved by a newer version of the studio`);await fc();let{doc:a,map:o,reRegistered:s,issues:c}=ac.value?{doc:i,map:new Map,reRegistered:[],issues:[`Couldn’t list voices: ${ac.value}`]}:await Bh(i),l=await Xm(a,e=>$.media(e)),u=Qm(a,n,r);clearTimeout(wh),Di(()=>{t&&(ua.value=t),l(),Z.value=u}),Sh=new Map([...o].map(([e,t])=>[t,e])),Ch=JSON.stringify({...i,updatedAt:0}),Q.value=`saved`,sh.value=null,ph.value={reRegistered:s,issues:c},localStorage.setItem(_h,e),Uh(),Ah(u),await Eh(()=>$.opened(u)),c.length&&z(`${c.length===1?`A voice`:`${c.length} voices`} of “${i.name}” couldn’t be restored: see Projects for details.`,`error`),Hh(a),Nh()}async function Kh(e,t){$=null,Q.value=`off`,sh.value=`Projects can’t be stored ${e.projects?`on the server`:`in this browser`} (${V(t)}): work in this tab is not saved.`,z(sh.value,`error`);let n=Jm({id:Mt(),name:yh}),r=await Xm(n,()=>Promise.reject(Error(`no storage`)));Di(()=>{ua.value=e,r(),Z.value=Qm(n,``,null)}),Uh()}async function qh(e){try{$=e.projects?new rh:await $m.open(!0),lh.value=$.kind,kh(await $.list())}catch(t){return Kh(e,t)}$.kind===`server`&&(uh.value=await $m.count(),uh.value&&z(`${uh.value===1?`A project is`:`${uh.value} projects are`} still saved in this browser only: move ${uh.value===1?`it`:`them`} to the server from Projects.`));let t=localStorage.getItem(_h);try{let n=new URLSearchParams(location.search).get(`project`),r=(oh.value.find(e=>e.id===n)??oh.value.find(e=>e.id===t)??oh.value[0])?.id;if(!r){r=await Mh(Jm({id:Mt(),name:yh}));for(let e of qm)localStorage.removeItem(`zvs.${e}`)}await Gh(r,e)}catch(t){z(`Couldn’t open the last project (${V(t)}); started a new one.`,`error`);try{await Gh(await Mh(Km({id:Mt(),name:yh},ha.value)),e)}catch(t){await Kh(e,t)}}finally{ua.value||=e}}function Jh(){return X.value?`the Edit screen`:yc.value?`the voice upload`:null}function Yh(){return hp.value||Ff.value.size>0?`unsaved text, regions or takes in Edit`:Cd.value?`script text changes in Direct`:null}async function Xh(){if(!$)return z(sh.value??`Projects are unavailable.`,`error`),!1;let e=Jh();if(e)return z(`Wait for ${e} to finish (or cancel it) before switching projects.`,`error`),!1;let t=Yh();return t&&!await Tf(`Switching projects discards your ${t}. Continue?`,{ok:`Discard`,danger:!0})?!1:(Sd.value=null,await Lh(),Q.value===`conflict`?(z(`This project changed elsewhere: reload it or keep yours as a copy before switching.`,`error`),!1):Q.value!==`error`||(z(`The open project couldn’t be saved, so it stays open: ${$.kind===`server`?`check the connection to the server`:`free some space (delete or export projects)`} and try again.`,`error`),!1))}async function Zh(e){if(!gh.value){gh.value=!0;try{if(!await Xh())return;await Gh(await e()),hh.value=!1}catch(e){z(`Couldn’t open the project: ${V(e)}`,`error`)}finally{gh.value=!1}}}async function Qh(e){if(e!==Z.value?.id)return Zh(async()=>e);hh.value=!1}function $h(e=Wh()){return Zh(()=>Mh(Km({id:Mt(),name:e},ha.value)))}async function eg(e,t){let{json:n,revision:r}=await $.read(e),i=t(JSON.parse(n));return $.write(i,JSON.stringify(i),new Map,r)}async function tg(e,t){t=t.trim();let n=oh.value.find(t=>t.id===e);if(t&&n&&t!==n.name&&$){if(e===Z.value?.id)return Z.value={...Z.value,name:t},Ah(Z.value),Rh();try{Ah({...await Eh(()=>eg(e,e=>({...e,name:t}))),openedAt:n.openedAt})}catch(e){z(`Couldn’t rename the project: ${V(e)}`,`error`)}}}async function ng(e){if($)try{e===Z.value?.id&&await Lh();let t=JSON.parse((await $.read(e)).json),n=Date.now(),r={...t,id:Mt(),name:`${t.name} (copy)`,createdAt:n,updatedAt:n};await Mh(r),z(`Duplicated as “${r.name}”`,`ok`)}catch(e){z(`Couldn’t duplicate the project: ${V(e)}`,`error`)}}async function rg(e){if(!$)return;let t=e===Z.value?.id;if(t&&Jh())return z(`Wait for ${Jh()} to finish before deleting the open project.`,`error`);let n=oh.value.find(t=>t.id===e)?.name??`the project`;t&&(clearTimeout(wh),Z.value=null);try{if(await Eh(()=>$.remove(e)),kh(oh.value.filter(t=>t.id!==e)),z(`Deleted “${n}”`),t){let e=oh.value[0];await Gh(e?e.id:await Mh(Km({id:Mt(),name:yh},ha.value)))}}catch(e){z(`Couldn’t delete the project: ${V(e)}`,`error`)}Nh()}async function ig(){let e=Z.value;if(e&&$&&!gh.value){gh.value=!0;try{await Gh(e.id),z(`Reloaded “${e.name}”`,`ok`)}catch(e){z(`Couldn’t reload the project: ${V(e)}`,`error`)}finally{gh.value=!1}}}async function ag(){let e=Z.value;if(e&&$)try{let t=Date.now(),n={...e,id:Mt(),name:`${e.name} (copy)`,createdAt:t,updatedAt:t,revision:null},r=new Nm,i=await Ih(n,r),a=JSON.stringify(i),o=await Eh(()=>$.write(i,a,r.pending,null));Z.value=o,Ah(o),Ch=JSON.stringify({...i,updatedAt:0}),Q.value=`saved`,sh.value=null,localStorage.setItem(_h,o.id),z(`Your version is now “${o.name}”`,`ok`),jh()}catch(e){z(`Couldn’t save your version as a copy: ${V(e)}`,`error`)}}var og={"audio/wav":`wav`,[km]:`f32`},sg=(e,t)=>`media/${e}.${og[t]??(t.split(`/`)[1]?.replace(/[^a-z0-9]/g,``)||`bin`)}`;async function cg(e){if($)try{e===Z.value?.id&&await Lh();let{json:t}=await $.read(e),n=JSON.parse(t),r={"project.json":[nd(t),{level:6}]};for(let[e,t]of Object.entries(n.media))r[sg(e,t.type)]=[new Uint8Array(await(await $.media(e)).arrayBuffer()),{level:0}];let i=ud(r,{mtime:n.updatedAt});k(i.buffer,`${p(n.name)}.voice-studio.zip`,`application/zip`),z(`Exported “${n.name}”`,`ok`)}catch(e){z(`Couldn’t export the project: ${V(e)}`,`error`)}}async function lg(e){if(!$)return z(sh.value??`Projects are unavailable.`,`error`);let t=ua.value?.projects,n=t?t.max_project_bytes+t.max_media_bytes:0;if(n&&e.size>n)return z(`Too big: ${Dh(e.size)}, limit ${Dh(n)}`,`error`);let r=z(`Importing ${e.name}…`);try{let t;try{t=dd(new Uint8Array(await e.arrayBuffer()))}catch{throw Error(`Not a Voice Studio project file (not a zip)`)}if(!t[`project.json`])throw Error(`Not a Voice Studio project file`);let n;try{n=JSON.parse(rd(t[`project.json`]))}catch{throw Error(`Not a Voice Studio project file`)}if(typeof n.schema!=`number`||typeof n.id!=`string`||!n.media)throw Error(`Not a Voice Studio project file`);if(n.schema>1)throw Error(`It was saved by a newer version of the studio`);let i=new Map;for(let[e,r]of Object.entries(t)){let t=/^media\/([0-9a-f]{32}|[0-9a-f]{64})\./.exec(e)?.[1];if(t){if(!await ah(t,r))throw Error(`An audio file inside is damaged (${e})`);i.set(t,new Blob([r],{type:n.media[t]?.type??``}))}}let a=Object.keys(n.media).filter(e=>!i.has(e)).length;if(a)throw Error(`${a} audio file${a===1?` is`:`s are`} missing from the file`);let o=await ih(rd(t[`project.json`]),i),s=o.json,c=JSON.parse(s);oh.value.some(e=>e.id===c.id)&&(c.id=Mt(),c.name=`${c.name} (imported)`,s=JSON.stringify(c)),await Mh(c,s,o.media),Fa(r),z(`Imported “${c.name}”`,`ok`),await Qh(c.id)}catch(t){Fa(r),z(`Couldn’t import ${e.name}: ${V(t)}`,`error`)}}async function ug(){if($?.kind!==`server`||dh.value)return;dh.value=!0;let e=0;try{let t=await $m.open(!1),n=await t.list();fh.value={done:0,total:n.length};for(let r of n){let{json:i}=await t.read(r.id),a=JSON.parse(i),o=new Map;for(let e of Object.keys(a.media))o.set(e,await t.media(e));let s=await ih(i,o),c=s.json,l=JSON.parse(c);oh.value.some(e=>e.id===l.id)&&(l.id=Mt(),l.name=`${l.name} (moved)`,c=JSON.stringify(l)),await Mh(l,c,s.media),await t.remove(r.id),e++,uh.value--,fh.value={done:e,total:n.length}}z(`Moved ${e} project${e===1?``:`s`} to the server`,`ok`)}catch(t){z(`Moved ${e}; couldn’t move the rest: ${V(t)}`,`error`)}finally{dh.value=!1,fh.value=null,jh()}}function dg(e){ha.value={...ha.value,...e},e.voiceMode&&e.voiceMode!==W.value.mode&&!La(Hc.value)&&Qc(e.voiceMode)}function fg(){return Ch=``,Lh()}var pg=`cubic-bezier(0.2, 0.7, 0.2, 1)`,mg=()=>matchMedia(`(prefers-reduced-motion: reduce)`).matches;function hg(e,t){return`translate(${e.left-t.left}px, ${e.top-t.top}px) scale(${e.width/t.width}, ${e.height/t.height})`}function gg({family:e,title:t,origin:n,returnFocus:r,onClose:i,aside:a,strip:o,children:s}){let c=P(null),l=P(null),u=P(!1),d=P(!1),f=`card-modal-${e}`;pt(()=>{let e=c.current;return Ta.value=!0,mg()||(e.animate([{transform:hg(n.getBoundingClientRect(),e.getBoundingClientRect())},{transform:`none`}],{duration:300,easing:pg}),e.querySelector(`.card-modal-inner`)?.animate([{opacity:0},{opacity:1}],{duration:180,delay:120,easing:`ease-out`,fill:`backwards`}),l.current.animate([{opacity:0},{opacity:1}],{duration:220,easing:`ease-out`})),Sf(e,`.card-modal-body`),()=>{Ta.value=!1}},[]);let p=()=>{if(u.current)return;u.current=!0;let e=()=>{i(),r.focus({preventScroll:!0})},t=c.current;if(!t||mg())return e();t.querySelector(`.card-modal-inner`)?.animate([{opacity:1},{opacity:0}],{duration:120,fill:`forwards`}),l.current.animate([{opacity:1},{opacity:0}],{duration:240,fill:`forwards`}),t.animate([{transform:`none`},{transform:hg(n.getBoundingClientRect(),t.getBoundingClientRect())}],{duration:240,easing:pg,fill:`forwards`}).finished.then(e,e)},m=Cf(()=>c.current,p);return G(`div`,{ref:l,class:`card-modal-backdrop`,onPointerDown:e=>d.current=e.target===l.current,onClick:e=>{d.current&&e.target===l.current&&p(),d.current=!1},children:G(`div`,{ref:c,class:`card-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,style:{"--fam":ba(e)},onKeyDown:m,children:G(`div`,{class:`card-modal-inner`,children:[G(`header`,{class:`card-modal-head`,children:[G(`h2`,{id:f,children:[G(`span`,{class:`fam-dot`}),t]}),a&&G(`div`,{class:`card-modal-aside`,children:a}),G(`button`,{class:`icon-btn`,onClick:p,"aria-label":`Close ${t}`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),o&&G(`div`,{class:`card-modal-strip`,children:o}),G(`div`,{class:`card-modal-body`,children:s})]})})})}var _g=`button, input, select, textarea, a, summary, label, [role="slider"], .slider-track, .panel-lock`;function vg({family:e,title:t,aside:n,locked:r,class:i,onExpand:a,whole:o,children:s}){let c=P(null),l=P(null),u=P(null),d=!!a&&!!o,f=a&&{tabIndex:0,role:`button`,"aria-haspopup":`dialog`,"aria-label":`${t}: open larger`,title:`Open larger`},p=e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),a(c.current,e.currentTarget))};return G(`section`,{ref:c,class:`panel${r?` is-locked`:``}${a?` is-expandable`:``}${d?` is-whole`:``}${i?` ${i}`:``}`,style:e?{"--fam":ba(e)}:void 0,"aria-label":d?void 0:t,...d?f:{},onKeyDown:d?p:void 0,onPointerDown:a?e=>{let t=e.target;u.current=e.button===0&&(d||t.closest(`.panel-head`)||!t.closest(_g))?{x:e.clientX,y:e.clientY}:null}:void 0,onClick:a?e=>{let t=u.current;u.current=null,t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<6&&a(c.current,d?c.current:l.current)}:void 0,children:[G(`div`,{ref:l,class:`panel-head`,...a&&!d?f:{},onKeyDown:a&&!d?p:void 0,children:[G(`h3`,{children:[e&&G(`span`,{class:`fam-dot`}),t]}),n&&G(`div`,{class:`panel-aside`,children:n}),a&&G(`span`,{class:`panel-expand`,"aria-hidden":`true`,children:G(K,{name:`expand`,size:14})})]}),G(`div`,{class:`panel-body`,inert:r||d?!0:void 0,children:s}),r&&G(`div`,{class:`panel-lock`,children:r})]})}var yg=matchMedia(`(max-width: 760px)`),bg=I(yg.matches);yg.addEventListener(`change`,e=>bg.value=e.matches);var xg=I(dl(`rails`,{}));fl(`rails`,xg);var Sg=I(null),Cg=null;function wg(){Sg.value=null,Cg?.focus({preventScroll:!0}),Cg=null}function Tg(e){bg.peek()?(Cg=document.activeElement,Sg.value=e):xg.peek()[e]!==!1&&(xg.value={...xg.peek(),[e]:!1})}function Eg({id:e,side:t,title:n,children:r,defaultFolded:i=!1}){let a=P(null),o=xg.value[e]??i,s=bg.value,c=s&&Sg.value===e;N(()=>()=>{Sg.peek()===e&&(Sg.value=null)},[]),N(()=>{if(!c)return;a.current?.querySelector(`.rail-drawer-head button`)?.focus({preventScroll:!0});let e=e=>{e.key!==`Escape`||e.defaultPrevented||Ta.peek()||(e.preventDefault(),wg())};window.addEventListener(`keydown`,e);let t=a.current?.parentElement,n=t?[...t.children].filter(e=>e!==a.current&&!e.classList.contains(`rail-scrim`)):[];for(let e of n)e.setAttribute(`inert`,``);return()=>{window.removeEventListener(`keydown`,e);for(let e of n)e.removeAttribute(`inert`)}},[c]);let l=c?Cf(()=>a.current,wg):void 0,u=t===`left`?o?`right`:`left`:o?`left`:`right`;return G(j,{children:[G(`div`,{ref:a,id:`rail-${e}`,class:`rail-box is-${t}${o?` is-folded`:``}${c?` is-open`:``}`,role:c?`dialog`:void 0,"aria-label":c?n:void 0,"aria-modal":c?`true`:void 0,inert:s&&!c?!0:void 0,onKeyDown:l,children:[G(`div`,{class:`rail-drawer-head`,children:[G(`h3`,{children:n}),G(`button`,{class:`icon-btn`,onClick:wg,"aria-label":`Close ${n}`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`button`,{class:`rail-fold`,onClick:()=>xg.value={...xg.value,[e]:!o},"aria-expanded":!o,"aria-label":o?`Show ${n}`:`Hide ${n}`,title:o?`Show ${n}`:`Hide ${n}`,children:[G(K,{name:u,size:14}),o&&G(`span`,{class:`rail-fold-label`,children:n})]}),r]}),c&&G(`div`,{class:`rail-scrim`,onClick:wg})]})}function Dg({id:e,title:t,icon:n}){let r=Sg.value===e;return G(`button`,{class:`btn sm rail-toggle${r?` is-on`:``}`,"aria-expanded":r,"aria-controls":`rail-${e}`,onClick:t=>{Cg=t.currentTarget,Sg.value=r?null:e},children:[G(K,{name:n,size:14}),` `,t]})}function Og({children:e}){return bg.value?G(`div`,{class:`rail-bar`,children:e}):null}function kg(e,t,n,r=e.currentTarget){if(e.button!==0)return;e.preventDefault();let i=e.currentTarget;i.setPointerCapture?.(e.pointerId);let a=e=>{let n=r.getBoundingClientRect();t((e.clientX-n.left)/(n.width||1),(e.clientY-n.top)/(n.height||1),e)},o=e=>a(e),s=()=>{i.removeEventListener(`pointermove`,o),i.removeEventListener(`pointerup`,s),i.removeEventListener(`pointercancel`,s),n?.()};i.addEventListener(`pointermove`,o),i.addEventListener(`pointerup`,s),i.addEventListener(`pointercancel`,s),a(e)}var Ag={english:`English accents`,world:`Other languages`};function jg({large:e}){let t=R.value.ui.accents,n=gs(t),r=W.value.pin,[i,a]=M(n.includes(r.tab)?r.tab:n[0]);N(()=>{n.includes(r.tab)&&a(r.tab)},[r.tab]);let o=P(null),s=P(0);N(()=>()=>clearTimeout(s.current),[]);let c=ba(`accent`),l=_s(i,t),u=zc.value,d=t.filter(e=>e.tab===i),f=r.tab===i,[p,m]=l.home,h=Object.entries(u).map(([e,n])=>({a:t.find(t=>t.id===e),v:n})).filter(e=>e.a).sort((e,t)=>t.v-e.v),g=h[0],_=(e,t)=>qc({tab:i,x:F(e*Go,6,Go-6),y:F(t*960,6,954)}),v=e=>{let n=e.shiftKey?40:10,a=f?r:vs(i,t),o=e.key===`ArrowRight`?n:e.key===`ArrowLeft`?-n:0,c=e.key===`ArrowDown`?n:e.key===`ArrowUp`?-n:0;e.key===`Home`||e.key===`0`||e.key===`Delete`||e.key===`Backspace`?(e.preventDefault(),U.apply({...W.value,pin:vs(i,t)})):(o||c)&&(e.preventDefault(),s.current||U.begin(),clearTimeout(s.current),qc({tab:i,x:F(a.x+o,6,Go-6),y:F(a.y+c,6,954)}),s.current=window.setTimeout(()=>{s.current=0,U.end()},400))},y=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=n.indexOf(i),r=n[(t+(e.key===`ArrowRight`?1:n.length-1))%n.length];a(r),e.currentTarget.querySelector(`#atlas-tab-${r}`)?.focus()},b=g?`${g.a.label} ${g.v.toFixed(2)}${Bt(g.a,g.v)===`safe`?``:` · strong`}`:``,x=r.x>Go-300;return G(`div`,{class:`atlas${e?` is-large`:``}`,style:{"--fam":c},children:[G(`div`,{class:`atlas-tabs`,role:`tablist`,"aria-label":`Accent maps`,onKeyDown:y,children:[n.map(e=>G(`button`,{id:`atlas-tab-${e}`,role:`tab`,"aria-selected":e===i,"aria-controls":`atlas-panel-${e}`,tabIndex:e===i?0:-1,class:`tab${e===i?` is-on`:``}`,onClick:()=>a(e),children:[Ag[e]??e,r.tab===e&&h.length>0&&G(`span`,{class:`fam-dot`})]})),G(`div`,{class:`atlas-readout`,title:h.map(({a:e,v:t})=>`${e.label} ${t.toFixed(2)}`).join(` + `),children:!f&&h.length>0?G(`span`,{class:`muted`,children:[`Dragging here replaces `,Ag[r.tab]??r.tab]}):h.length?G(`span`,{class:`muted`,children:h.map(({a:e,v:t})=>`${e.label} ${t.toFixed(2)}`).join(` + `)}):G(`span`,{class:`muted`,children:`no accent`})}),G(`button`,{class:`link home-btn`,onClick:()=>U.apply({...W.value,pin:vs(i,t)}),title:`Back home: no accent`,children:[G(K,{name:`home`,size:14}),` home`]})]}),G(`svg`,{ref:o,id:`atlas-panel-${i}`,class:`atlas-map`,viewBox:`0 0 ${Go} 960`,role:`slider`,tabIndex:0,"aria-label":`${Ag[i]??i} map. Drag the pin into a region; deeper is stronger, borders blend. Arrow keys move it, Home returns.`,"aria-valuetext":h.length?h.map(e=>`${e.a.label} ${e.v.toFixed(2)}`).join(`, `):`no accent`,onKeyDown:v,onPointerDown:e=>{U.begin(),kg(e,_,()=>U.end(),o.current)},children:[G(`defs`,{children:l.panels.map(e=>G(`clipPath`,{id:`clip-${i}-${e.id}`,children:G(`rect`,{x:e.rect[0],y:e.rect[1],width:e.rect[2],height:e.rect[3],rx:`14`})}))}),l.panels.map(e=>G(`g`,{class:`atlas-panel`,children:[G(`rect`,{class:`panel-sea`,x:e.rect[0],y:e.rect[1],width:e.rect[2],height:e.rect[3],rx:`14`}),G(`path`,{class:`land`,d:l.context.find(t=>t.panel===e.id)?.path,"clip-path":`url(#clip-${i}-${e.id})`}),G(`text`,{class:`panel-label`,x:e.rect[0]+12,y:e.rect[1]+e.rect[3]-12,children:e.label})]})),d.map(e=>{let t=l.regions[e.region];if(!t)return null;let n=f?u[e.id]??0:0;return G(`g`,{class:`region strength-${e.strength}${n>0?` is-active`:``}`,style:{"--w":String(n/e.range[1])},children:[G(`title`,{children:`${e.label} — ${e.strength}${e.effect?`: ${e.effect}`:``}`}),G(`path`,{class:`region-shape`,d:t.path})]})}),d.map(e=>{let n=l.regions[e.region];if(!n)return null;let r=d.filter(t=>t.region===e.region).length>1?t.filter(t=>t.region===e.region&&t.tab===i).map(e=>e.label).join(` / `):e.label,a=r.length*7.6;return G(`text`,{class:`region-label strength-${e.strength}`,x:F(n.pole[0],a+4,Go-a-4),y:n.pole[1]+9,children:r})}),G(`g`,{class:`home`,transform:`translate(${p},${m})`,children:[G(`circle`,{r:`26`}),G(`text`,{y:`56`,children:`home · no accent`})]}),f&&G(`g`,{class:`pin`,transform:`translate(${r.x},${r.y})`,children:[G(`path`,{d:`M0,0 C-15,-21 -21,-33 -21,-45 A21,21 0 1 1 21,-45 C21,-33 15,-21 0,0Z`}),G(`circle`,{cy:`-45`,r:`7`}),g&&G(`g`,{class:`pin-tag zone-${Bt(g.a,g.v)}`,transform:`translate(${x?-30:30},-45)`,children:[G(`rect`,{x:x?-b.length*16-24:0,y:`-25`,width:b.length*16+24,height:`50`,rx:`25`}),G(`text`,{x:x?-12:12,y:`10`,"text-anchor":x?`end`:`start`,children:b})]})]})]})]})}var Mg=e=>!!e.dataTransfer?.types.includes(`Files`);function Ng({label:e,hint:t,icon:n=`upload`,busy:r,onFile:i}){let[a,o]=M(!1),s=P(0),c=P({busy:r,onFile:i});return c.current={busy:r,onFile:i},N(()=>{let e=e=>{Mg(e)&&(s.current++,o(!0))},t=e=>{Mg(e)&&(s.current=Math.max(0,s.current-1),s.current||o(!1))},n=e=>{Mg(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=c.current.busy?`none`:`copy`)},r=e=>{if(!Mg(e))return;e.preventDefault(),s.current=0,o(!1);let t=e.dataTransfer.files[0];t&&!c.current.busy&&c.current.onFile(t)};return window.addEventListener(`dragenter`,e),window.addEventListener(`dragleave`,t),window.addEventListener(`dragover`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragenter`,e),window.removeEventListener(`dragleave`,t),window.removeEventListener(`dragover`,n),window.removeEventListener(`drop`,r)}},[]),a?Ye(G(`div`,{class:`file-drop${r?` is-busy`:``}`,"aria-hidden":`true`,children:G(`div`,{class:`file-drop-card`,children:[G(K,{name:n,size:30}),G(`b`,{children:r??e}),t&&!r&&G(`span`,{class:`muted small`,children:t})]})}),document.body):null}var Pg={saved:`All changes saved`,saving:`Saving…`,error:`Not saved`,conflict:`Changed elsewhere`,off:`Not saved — storage unavailable`},Fg={saved:``,saving:`Saving…`,error:`Not saved`,conflict:`Changed elsewhere`,off:`Not saved — storage unavailable`};function Ig(e){let t=(Date.now()-e)/1e3;return t<60?`just now`:t<3600?`${Math.round(t/60)} min ago`:t<86400?`${Math.round(t/3600)} h ago`:t<604800?`${Math.round(t/86400)} d ago`:new Date(e).toLocaleDateString()}function Lg(e){if(!e)return`project`;let t=(e,t,n=`${t}s`)=>e?[`${e} ${e===1?t:n}`]:[];return[...t(e.cast,`cast member`),...t(e.takes,`take`),...t(e.versions,`edit version`)].join(` · `)||`empty`}function Rg(){let e=document.createElement(`input`);e.type=`file`,e.accept=`.zip,application/zip`,e.onchange=()=>e.files?.[0]&&void lg(e.files[0]),e.click()}function zg(){let e=Q.value;return Z.value?G(`span`,{class:`proj-dot is-${e}`,role:`img`,"aria-label":Pg[e],title:sh.value??Pg[e],children:e===`conflict`?`!`:``}):null}function Bg(){let e=Q.value;return G(j,{children:[Fg[e]&&G(`span`,{class:`proj-state is-${e}`,children:Fg[e]}),G(`span`,{class:`sr-only`,"aria-live":`polite`,children:Pg[e]})]})}function Vg({value:e,label:t,onDone:n}){let r=P(null),i=P(!1);pt(()=>{r.current.focus(),r.current.select()},[]);let a=e=>{i.current||(i.current=!0,n(e))};return G(`input`,{ref:r,class:`input proj-name-input`,value:e,"aria-label":t,maxLength:80,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?a(e.currentTarget.value):e.key===`Escape`&&a(null)},onBlur:e=>a(e.currentTarget.value)})}function Hg(){let[e,t]=M(!1),n=P(null),r=P(null),i=P(null),[a,o]=M(null),s=!!a,c=e=>{let t=r.current?.getBoundingClientRect();o(e&&t?{top:`${t.bottom+6}px`,left:`${t.left}px`}:null)},l=Z.value,u=(e=!0)=>{c(!1),e&&r.current?.focus()};N(()=>{if(!s)return;i.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>!n.current?.contains(e.target)&&!i.current?.contains(e.target)&&c(!1);return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s]);let d=e=>()=>{u(!1),e()},f=e=>{e.stopPropagation();let t=[...i.current.querySelectorAll(`[role="menuitem"]:not([disabled])`)],n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)u();else if(e.key===`Tab`)return u(!1);else return;e.preventDefault()},p=oh.value.filter(e=>e.id!==l?.id).slice(0,5),m=Q.value===`off`;return G(`div`,{ref:n,class:`proj-switch`,children:[e&&l?G(Vg,{value:l.name,label:`Project name`,onDone:e=>{t(!1),e&&tg(l.id,e),r.current?.focus()}}):G(`button`,{ref:r,class:`proj-trigger`,"aria-haspopup":`menu`,"aria-expanded":s,disabled:!l,onClick:()=>c(!s),"aria-label":`Project: ${l?.name??`opening`}`,title:`${l?.name??`Project`} · ${sh.value??Pg[Q.value]}`,children:[G(zg,{}),G(`span`,{class:`proj-trigger-name`,children:l?.name??`Opening…`}),G(Bg,{}),G(K,{name:`down`,size:12})]}),Q.value===`conflict`&&G(Ug,{}),a&&l&&Ye(G(`div`,{ref:i,class:`proj-menu`,role:`menu`,"aria-label":`Project`,style:a,onKeyDown:f,children:[G(`p`,{class:`proj-menu-status${Q.value===`error`||Q.value===`conflict`||m?` is-bad`:``}`,children:sh.value??Pg[Q.value]}),Q.value===`error`&&G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void fg()),children:[G(K,{name:`refresh`,size:14}),` Try saving again`]}),Q.value===`conflict`&&G(j,{children:[!ch.value&&G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void ig()),children:[G(K,{name:`refresh`,size:14}),` Reload (drop my changes)`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>void ag()),children:[G(K,{name:`copy`,size:14}),` Keep mine as a copy`]})]}),p.length>0&&G(`div`,{role:`group`,"aria-label":`Recent projects`,class:`proj-menu-group`,children:[G(`span`,{class:`proj-menu-label`,children:`Recent`}),p.map(e=>G(`button`,{role:`menuitem`,class:`proj-item`,disabled:gh.value,onClick:d(()=>void Qh(e.id)),children:[G(`span`,{class:`proj-item-name`,children:e.name}),G(`span`,{class:`proj-item-meta`,children:[`edited `,Ig(e.updatedAt)]})]},e.id))]}),G(`div`,{role:`separator`,class:`proj-sep`}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m||gh.value,onClick:d(()=>void $h().then(()=>t(!0))),children:[G(K,{name:`plus`,size:14}),` New project`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>t(!0)),disabled:m,children:[G(K,{name:`edit`,size:14}),` Rename…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>Ea.value=!0),children:[G(K,{name:`gear`,size:14}),` Project settings…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(()=>void ng(l.id)),children:[G(K,{name:`copy`,size:14}),` Duplicate`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(()=>void cg(l.id)),children:[G(K,{name:`download`,size:14}),` Export…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,disabled:m,onClick:d(Rg),children:[G(K,{name:`upload`,size:14}),` Import…`]}),G(`div`,{role:`separator`,class:`proj-sep`}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:d(()=>hh.value=!0),children:`All projects…`})]}),document.body)]})}function Ug(){return Ye(G(`div`,{class:`proj-conflict`,role:`alert`,children:[G(K,{name:`alert`,size:16}),G(`span`,{children:sh.value}),!ch.value&&G(`button`,{class:`btn sm`,disabled:gh.value,onClick:()=>void ig(),children:`Reload`}),G(`button`,{class:`btn sm primary`,onClick:()=>void ag(),children:`Keep mine as a copy`})]}),document.body)}function Wg(){return hh.value?G(Gg,{}):null}function Gg(){let[e,t]=M(``),[n,r]=M(null),[i,a]=M(null),o=P(null),s=P(!1);pt(()=>{let e=document.activeElement;return Ta.value=!0,jh(),o.current.querySelector(`.proj-search`)?.focus(),()=>{Ta.value=!1,(e?.isConnected?e:document.querySelector(`.proj-trigger`))?.focus()}},[]);let c=()=>hh.value=!1,l=e.trim().toLowerCase(),u=l?oh.value.filter(e=>e.name.toLowerCase().includes(l)):oh.value,d=oh.value.reduce((e,t)=>e+t.size,0),f=mh.value;return G(`div`,{class:`proj-backdrop`,onPointerDown:e=>s.current=e.target===e.currentTarget,onClick:e=>{s.current&&e.target===e.currentTarget&&c(),s.current=!1},children:G(`div`,{ref:o,class:`proj-launcher`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`proj-title`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?(e.preventDefault(),i?a(null):c()):e.key===`Tab`&&xf(e,o.current)},children:[G(`header`,{class:`proj-head`,children:[G(`h2`,{id:`proj-title`,children:`Projects`}),G(`span`,{class:`proj-head-note`,children:lh.value===`server`?`Shared on the server: everyone with the studio link sees these`:`Saved in this browser · move them with Export / Import`}),G(`button`,{class:`icon-btn`,onClick:c,"aria-label":`Close projects`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`div`,{class:`proj-tools`,children:[G(`input`,{class:`input proj-search`,type:`search`,placeholder:`Search projects`,"aria-label":`Search projects`,value:e,onInput:e=>t(e.currentTarget.value)}),G(`button`,{class:`btn sm`,disabled:Q.value===`off`,onClick:Rg,children:[G(K,{name:`upload`,size:14}),` Import…`]}),G(`button`,{class:`btn primary sm`,disabled:Q.value===`off`||gh.value,onClick:()=>void $h().then(()=>r(Z.value?.id??null)),children:[G(K,{name:`plus`,size:14}),` New project`]})]}),lh.value===`server`&&uh.value>0&&G(`div`,{class:`proj-move`,children:[G(`span`,{children:[uh.value===1?`A project is`:`${uh.value} projects are`,` still saved in this browser only.`]}),G(`button`,{class:`btn sm primary`,disabled:dh.value,onClick:async()=>{let e=uh.value;await Tf(`Move ${e===1?`this project`:`${e} projects`} to the shared server? Everyone with the studio link will see ${e===1?`it`:`them`}; the browser ${e===1?`copy is`:`copies are`} removed.`,{ok:`Move`})&&ug()},children:[G(K,{name:`upload`,size:14}),` `,fh.value?`Moving ${fh.value.done+1} of ${fh.value.total}…`:dh.value?`Moving…`:`Move ${uh.value===1?`it`:`all ${uh.value}`} to the server`]})]}),G(`ul`,{class:`proj-list`,"aria-label":`Projects`,"aria-busy":gh.value,children:[u.map(e=>G(Kg,{p:e,renaming:n===e.id,confirming:i===e.id,onRename:r,onConfirm:a},e.id)),!u.length&&G(`li`,{class:`proj-none`,children:l?`No project matches “${e.trim()}”.`:`No saved projects.`})]}),G(Jg,{}),G(`footer`,{class:`proj-foot`,children:f&&f.quota?G(j,{children:[G(`span`,{children:[`Site storage (includes cached models): `,Dh(f.usage),` of `,Dh(f.quota),` used`]}),G(`span`,{class:`proj-meter`,role:`meter`,"aria-label":`Site storage used`,"aria-valuemin":0,"aria-valuemax":f.quota,"aria-valuenow":f.usage,"aria-valuetext":`${Dh(f.usage)} of ${Dh(f.quota)}`,children:G(`span`,{style:{width:`${Math.min(100,100*f.usage/f.quota)}%`}})})]}):G(`span`,{children:[`Projects use about `,Dh(d),lh.value===`server`?` on the server`:``,` (shared audio counted in each)`]})})]})})}function Kg({p:e,renaming:t,confirming:n,onRename:r,onConfirm:i}){let a=e.id===Z.value?.id,o=Q.value===`off`;return G(`li`,{class:`proj-row${a?` is-open`:``}`,children:[t?G(`div`,{class:`proj-row-main`,children:G(Vg,{value:e.name,label:`Rename ${e.name}`,onDone:t=>{r(null),t&&tg(e.id,t)}})}):G(`button`,{class:`proj-row-main`,"aria-current":a?`true`:void 0,disabled:gh.value,onClick:()=>void Qh(e.id),title:a?`The open project`:`Open ${e.name}`,children:[G(`span`,{class:`proj-row-name`,children:[e.name,a&&G(`span`,{class:`tag`,children:`open`})]}),G(`span`,{class:`proj-row-meta`,children:[Lg(e.summary),` · `,Dh(e.size),` · edited `,Ig(e.updatedAt)]})]}),G(`div`,{class:`proj-row-actions`,children:[G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>r(e.id),"aria-label":`Rename ${e.name}`,title:`Rename`,children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>void ng(e.id),"aria-label":`Duplicate ${e.name}`,title:`Duplicate`,children:G(K,{name:`copy`,size:14})}),G(`button`,{class:`icon-btn sm`,disabled:o,onClick:()=>void cg(e.id),"aria-label":`Export ${e.name}`,title:`Export (zip)`,children:G(K,{name:`download`,size:14})}),G(`button`,{class:`icon-btn sm proj-del`,disabled:o,onClick:()=>i(e.id),"aria-label":`Delete ${e.name}`,title:`Delete`,children:G(K,{name:`trash`,size:14})})]}),n&&G(qg,{p:e,onDone:()=>i(null)})]})}function qg({p:e,onDone:t}){let n=P(null);return pt(()=>n.current.focus(),[]),G(`div`,{class:`proj-confirm`,role:`alertdialog`,"aria-label":`Delete ${e.name}?`,"aria-describedby":`proj-confirm-${e.id}`,children:[G(`span`,{id:`proj-confirm-${e.id}`,children:[`Delete “`,e.name,`”`,lh.value===`server`?` for everyone`:` and its audio (unless another project shares it)`,`? This can’t be undone`,e.id===Z.value?.id?`; another project opens`:``,`.`]}),G(`button`,{ref:n,class:`btn sm ghost`,onClick:t,children:`Cancel`}),G(`button`,{class:`btn sm proj-danger`,onClick:()=>{t(),rg(e.id)},children:`Delete`})]})}function Jg(){let e=Z.value;return e?G(`section`,{class:`proj-current`,"aria-label":`${e.name}: save state`,children:G(`div`,{class:`proj-current-head`,children:[G(`h3`,{children:e.name}),G(`span`,{class:`proj-current-state`,children:[G(zg,{}),` `,sh.value??Pg[Q.value]]}),Q.value===`error`&&G(`button`,{class:`btn sm`,onClick:()=>void fg(),children:`Try again`}),Q.value===`conflict`&&G(j,{children:[!ch.value&&G(`button`,{class:`btn sm`,disabled:gh.value,onClick:()=>void ig(),children:`Reload`}),G(`button`,{class:`btn sm`,onClick:()=>void ag(),children:`Keep mine as a copy`})]}),G(`button`,{class:`btn sm`,onClick:()=>Ea.value=!0,children:[G(K,{name:`gear`,size:13}),` Project settings…`]})]})}):null}var Yg=I(dl(`theme`,matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`));fl(`theme`,Yg);var Xg={dark:`#0a0a0a`,light:`#f5f3ee`};Ji(()=>{Yg.value===`light`?document.documentElement.dataset.theme=`light`:delete document.documentElement.dataset.theme,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,Xg[Yg.value])}),addEventListener(`storage`,e=>{if(e.key===`zvs.theme`&&e.newValue)try{let t=JSON.parse(e.newValue);(t===`dark`||t===`light`)&&(Yg.value=t)}catch{}});var Zg=()=>Yg.value=Yg.value===`dark`?`light`:`dark`;function Qg(e,t=1){Yg.value;let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(n);if(!r)return n||`currentColor`;let i=parseInt(r[1],16),a=(r[2]?parseInt(r[2],16)/255:1)*t;return`rgba(${i>>16}, ${i>>8&255}, ${i&255}, ${+a.toFixed(3)})`}function $g({pcm:e,color:t=`var(--text)`,playId:n,height:r=56,busy:i,length:a,onSeek:o,label:s}){let c=P(null),[l,u]=M(0),[d,f]=M(`currentColor`);N(()=>{let e=c.current,t=new ResizeObserver(([e])=>u(Math.round(e.contentRect.width)));return t.observe(e),()=>t.disconnect()},[]);let p=Yg.value;N(()=>{f(getComputedStyle(c.current).color)},[t,p]),N(()=>{c.current&&l&&ne(c.current,e,l,r,d,a)},[e,l,r,d,a]);let m=B.value,h=n&&m?.id===n&&m.duration?Math.min(100,ws.value/m.duration*100):null;return G(`div`,{class:`wave${i?` is-busy`:``}${o?` is-seekable`:``}`,style:{height:`${r}px`,color:t},onPointerDown:o?e=>{let t=e.currentTarget.getBoundingClientRect();o(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}:void 0,role:s?`img`:void 0,"aria-label":s,children:[G(`canvas`,{ref:c,style:{width:`100%`,height:`${r}px`}}),h!==null&&G(`div`,{class:`wave-head`,style:{left:`${h}%`}})]})}var e_=e=>!!e?.startsWith(`Pronunciation:`),t_=L(()=>!!ga.value),n_=L(()=>t_.value&&!!ua.value?.pron.phonemize_enabled),r_=L(()=>ua.value?.pron.phonemize_languages??[]),i_=I(ha.value.language);Ji(()=>void(i_.value=ha.value.language));var a_=L(()=>r_.value.includes(i_.value)?i_.value:r_.value.includes(`en_us`)?`en_us`:r_.value[0]??`en_us`),o_=I({}),s_=I(!1);async function c_(e,t,n){if(n<=t)return z(`Select the words to pronounce first.`),null;let r=a_.value,i=e.slice(t,n).split(/(\([^()]*\))/);s_.value=!0;try{let a=(await Promise.all(i.map(async(e,t)=>t%2==1||!e.trim()?[{text:e,status:null,ipa:null}]:(await Eo(e,r,!0)).segments))).flat(),o={...o_.value},s=a.map(e=>{if(!e.ipa||e.status!==`ok`&&e.status!==`guessed`)return e.text;let t=_n(e.ipa);return e.status===`guessed`?o[t]=e.text:delete o[t],`(${t})`}).join(``);o_.value=o;let c=e=>a.filter(t=>t.status===e).map(e=>e.text),l=c(`ok`).length+c(`guessed`).length,u=[];c(`ambiguous`).length&&u.push(`several pronunciations: ${c(`ambiguous`).join(`, `)}`),c(`unknown`).length&&u.push(`not in the lexicon: ${c(`unknown`).join(`, `)}`),c(`skipped`).length&&u.push(`no reading on its own: ${c(`skipped`).join(`, `)}`),c(`unsupported`).length&&u.push(`symbols this model has no token for: ${c(`unsupported`).join(`, `)}`);let d=c(`guessed`).length?` Guessed by rule, check: ${c(`guessed`).join(`, `)}.`:``;z(`Pronounced ${l} word${l===1?``:`s`} (${g(r)}).${d}${u.length?` Left as text (${u.join(`; `)}): write their X-SAMPA by hand.`:``}`,u.length||d?`info`:`ok`);let f=e.slice(0,t)+s+e.slice(n);return l?f:null}catch(e){return z(`Couldn’t look up pronunciations: ${V(e)}`,`error`),null}finally{s_.value=!1}}function l_(e,t,n,r){e.focus(),e.setSelectionRange(t,n),document.execCommand(`insertText`,!1,r)||(e.setRangeText(r,t,n,`end`),e.dispatchEvent(new Event(`input`,{bubbles:!0})))}function u_({input:e,onDone:t}){return n_.value?G(`button`,{class:`icon-btn sm pron-btn`,disabled:s_.value,onMouseDown:e=>e.preventDefault(),onClick:async()=>{let n=e();if(!n)return;let r=n.selectionStart??0,i=n.selectionEnd??0,a=n.value,o=await c_(a,r,i);if(o===null||n.value!==a)return;let s=a.length-i;l_(n,r,i,o.slice(r,o.length-s)),t?.()},"aria-label":`Pronounce the selected words`,title:`Pronounce…: look up the selected words in the ${g(a_.value)} lexicon and write them as X-SAMPA`,children:G(`span`,{"aria-hidden":`true`,class:`pron-btn-glyph`,children:`/ə/`})}):null}var d_=I(null);function f_(e,t,n){let r=e.getBoundingClientRect();d_.value={x:r.left,y:r.bottom+6,...t,replace:n,returnFocus:e}}function p_(){let e=d_.value;return e?G(m_,{st:e},`${e.start}:${e.body}:${e.x}:${e.y}`):null}function m_({st:e}){let[t,n]=M(e.body),r=P(null),i=P(null),a=P(()=>{});N(()=>{requestAnimationFrame(()=>i.current?.select());let e=e=>!r.current?.contains(e.target)&&a.current();return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]);let o=ga.value,s=new Set(o?.symbols??[]),c=gn(t),l=[...c].filter(e=>!s.has(e)),u=()=>{let e=d_.value?.returnFocus;d_.value=null,e?.focus?.()},d=()=>{if(!c||l.length)return;let n=`(${t.trim()})`;if(e.replace(e.start,e.end,n),o_.value[t.trim()]!==void 0||o_.value[e.body]!==void 0){let{[e.body]:n,[t.trim()]:r,...i}=o_.value;o_.value=i}u()};a.current=()=>{if(t.trim()===e.body)return u();if(c&&!l.length)return d();let n=r.current?.querySelector(`.pron-warn, .pron-ipa`);n?.classList.add(`is-flash`),setTimeout(()=>n?.classList.remove(`is-flash`),900),i.current?.focus()};let f=F(e.x,12,window.innerWidth-352),p=e.y+220>window.innerHeight?Math.max(12,e.y-250):e.y;return G(`div`,{ref:r,class:`pron-editor`,style:{left:`${f}px`,top:`${p}px`},role:`dialog`,"aria-label":`Edit pronunciation`,children:[G(`label`,{class:`pron-field`,children:[G(`span`,{class:`eyebrow`,children:`X-SAMPA`}),G(`input`,{ref:i,class:`input mono`,value:t,spellcheck:!1,"aria-describedby":`pron-ipa`,onInput:e=>n(e.currentTarget.value.replace(/[()]/g,``)),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())}})]}),G(`div`,{class:`pron-ipa`,id:`pron-ipa`,"aria-live":`polite`,children:[G(`span`,{class:`eyebrow`,children:`IPA sent`}),G(`span`,{class:`pron-ipa-symbols`,children:c?[...c].map(e=>G(`span`,{class:s.has(e)?``:`is-bad`,title:s.has(e)?`${e} has a token`:`no token for ${e} (U+${e.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)})`,children:e})):G(`span`,{class:`muted`,children:`empty`})})]}),l.length>0&&G(`p`,{class:`pron-warn`,children:[`No token on this model for `,[...new Set(l)].map(e=>`“${e}”`).join(` `),`: the server would refuse it.`]}),o_.value[e.body]&&G(`p`,{class:`pron-check`,children:[`Guessed by rule for “`,o_.value[e.body],`”: check it and save to confirm.`]}),G(`p`,{class:`hint`,children:`“_” ties (t_S = t͡ʃ); stress " % and dots are dropped. Symbols without an X-SAMPA spelling are typed as-is.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm ghost`,onClick:u,children:`Cancel`}),G(`button`,{class:`btn sm primary`,disabled:!c||l.length>0,onClick:d,children:`Save`})]})]})}function h_({text:e,replace:t,issuesOnly:n}){let r=ga.value,i=vn(e,r);return r?!i.issues.length&&(n||!i.groups.length)?null:G(`span`,{class:`pron-marks`,"aria-label":`Pronunciations`,children:[i.groups.filter(e=>!e.empty&&!n).map(e=>{let n=o_.value[e.body];return G(`button`,{class:`pron-chip${e.unknown.length?` is-bad`:``}${n?` is-check`:``}`,title:`(${e.body}) → ${e.ipa}${n?` · guessed for “${n}”, check it`:``}${e.unknown.length?` · no token for ${e.unknown.join(` `)}`:``}${t?` · click to edit`:``}`,disabled:!t,onClick:n=>t&&f_(n.currentTarget,e,t),children:[G(`span`,{class:`pron-chip-ipa`,children:e.ipa}),n&&G(`span`,{class:`pron-chip-check`,children:`check`})]})}),i.issues.filter(e=>n||!i.groups.some(t=>t.start===e.at&&t.unknown.length&&!t.empty)).map(e=>G(`span`,{class:`pron-issue`,role:`note`,children:[G(K,{name:`x`,size:10}),` `,e.text]}))]}):i.groups.length?G(`span`,{class:`pron-marks`,children:G(`span`,{class:`pron-off`,title:`This server reads parentheses as plain text: it has no pronunciation input`,children:`( ) read as text`})}):null}function g_(){return ua.value?t_.value?G(`div`,{class:`pron-help`,children:[G(`p`,{class:`hint`,children:[`Write a pronunciation in X-SAMPA between parentheses: “I met `,G(`span`,{class:`mono`,children:`(S@vQn)`}),`” reads `,G(`span`,{class:`mono`,children:`ʃəvɒn`}),`.`,n_.value?` Or select words and press /ə/ to look them up.`:``]}),n_.value&&r_.value.length>1&&G(`label`,{class:`pron-lang`,title:`Where /ə/ looks words up. It follows the project language until you pick another here (for this session)`,children:[`lexicon (for /ə/ lookups) · `,a_.value===ha.value.language?`follows language`:`overridden`,G(`select`,{class:`input`,value:a_.value,onChange:e=>i_.value=e.currentTarget.value,"aria-label":`Pronunciation lexicon language`,children:r_.value.map(e=>G(`option`,{value:e,children:g(e)}))})]})]}):G(`div`,{class:`hint pron-help`,children:G(`p`,{children:`This server has no pronunciation lexicon: parentheses are read as text.`})}):null}var __=L(()=>!!ua.value?.tags),v_=e=>`<${e}/>: ${En[e].note}`,y_=I(null);function b_(e,t=!1){let n=e.selectionStart??e.value.length,r=e.selectionEnd??n,i=e.getBoundingClientRect();y_.value={x:i.left,y:i.bottom+6,text:e.value,start:n,end:r,apply:t=>{l_(e,t.start,t.end,t.insert),e.setSelectionRange(t.caret,t.caret)},literal:t?()=>l_(e,n,r,`<`):null,returnFocus:e}}function x_(e,t,n,r,i){y_.value={x:e.left,y:e.bottom+6,text:t,start:n,end:r,apply:e=>i(t.slice(0,e.start)+e.insert+t.slice(e.end)),literal:null,returnFocus:null}}addEventListener(`keydown`,e=>{let t=e.target;e.key!==`<`||e.metaKey||e.ctrlKey||e.altKey||!__.value||(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.hasAttribute(`data-tags`)&&(e.preventDefault(),b_(t,!0))},!0);function S_(){let e=y_.value;return e?G(C_,{st:e},`${e.x}:${e.y}:${e.start}:${e.end}`):null}function C_({st:e}){let t=P(null),n=e.end>e.start&&/\S/.test(e.text.slice(e.start,e.end)),r=new Set(ua.value?.tags?.tags??wn);pt(()=>{t.current?.querySelector(`button:not([disabled])`)?.focus();let e=e=>!t.current?.contains(e.target)&&i(!1);return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]);let i=(t=!0)=>{y_.value=null,t&&e.returnFocus?.focus()},a=t=>{i(),e.apply(Nn(e.text,e.start,t))},o=t=>{let n=Fn(e.text,e.start,e.end,t);i(),n&&e.apply(n)},s=n=>{n.stopPropagation();let r=[...t.current.querySelectorAll(`button:not([disabled])`)],a=r.indexOf(document.activeElement),o=e=>r[(e+r.length)%r.length]?.focus();if(n.key===`ArrowDown`||n.key===`ArrowRight`)o(a+1);else if(n.key===`ArrowUp`||n.key===`ArrowLeft`)o(a-1);else if(n.key===`Home`)o(0);else if(n.key===`End`)o(r.length-1);else if(n.key===`Escape`)i(),e.literal?.();else if(n.key===`Tab`)return i();else if(/^[a-z]$/.test(n.key)){let e=a+1;[...r.slice(e),...r.slice(0,e)].find(e=>e.dataset.tag?.startsWith(n.key))?.focus()}else return;n.preventDefault()},c=F(e.x,12,window.innerWidth-332),l=e.y+230>window.innerHeight?Math.max(12,e.y-280):e.y;return G(`div`,{ref:t,class:`tag-palette`,style:{left:`${c}px`,top:`${l}px`},role:`dialog`,"aria-label":`Nonverbal tags`,onKeyDown:s,children:[G(`span`,{class:`eyebrow`,children:`At the caret`}),G(`div`,{class:`tag-palette-row`,role:`group`,"aria-label":`Point tags`,children:wn.filter(e=>r.has(e)).map(e=>G(`button`,{class:`tag-pick${En[e].weak?` is-weak`:``}`,"data-tag":e,onClick:()=>a(e),title:v_(e),children:[e,En[e].weak&&G(`span`,{class:`tag-weak`,children:`weak`})]},e))}),G(`span`,{class:`eyebrow`,children:`Over the selected words`}),G(`div`,{class:`tag-palette-row`,role:`group`,"aria-label":`Span tags`,children:Tn.filter(e=>r.has(e)).map(e=>G(`button`,{class:`tag-pick is-span is-weak`,"data-tag":`${e} span`,disabled:!n,onClick:()=>o(e),title:n?`<${e}>…: ${En[e].note}`:`Select words first`,children:[`‹`,e,`›`,G(`span`,{class:`tag-weak`,children:`weak`})]},e))}),G(`p`,{class:`hint`,children:[`Type a letter to jump · Esc `,e.literal?`types “<”`:`closes`]})]})}function w_({input:e}){return __.value?G(`button`,{class:`icon-btn sm nv-btn`,onMouseDown:e=>e.preventDefault(),onClick:()=>{let t=e();t&&b_(t)},"aria-label":`Insert a nonverbal tag`,title:`Nonverbal tag (type “<” in the text)`,children:G(`span`,{"aria-hidden":`true`,class:`nv-btn-glyph`,children:`‹›`})}):null}function T_(e,t,n){return n?Rn(e,n):zn(e,t)}function E_({text:e,replace:t}){let n=kn(e);return!n.tokens.length&&!n.issues.length?null:__.value?G(`span`,{class:`tag-marks`,"aria-label":`Nonverbal tags`,children:[n.tokens.filter(e=>e.kind!==`close`).map(r=>{let i=n.spans.find(e=>e.open.start===r.start),a=i?e.slice(i.open.end,i.close.start).trim():``,o=t?T_(e,r,i):null;return G(`span`,{class:`tag-chip${i?` is-span`:``}${En[r.name].weak?` is-weak`:``}`,title:`${i?`<${r.name}> over “${a}”`:`<${r.name}/>`}: ${En[r.name].note}`,children:[G(`span`,{class:`tag-chip-name`,children:i?`‹${r.name}› ${a.length>18?`${a.slice(0,17)}…`:a}`:r.name}),t&&o!==null&&G(`button`,{class:`tag-chip-act`,onClick:()=>t(o),"aria-label":i?`Make <${r.name}> a point tag`:`Make <${r.name}/> a span over the next word`,title:i?`Make it a point tag`:`Make it a span over the next word`,children:`⇄`}),t&&G(`button`,{class:`tag-chip-act`,onClick:()=>t(Ln(e,r)),"aria-label":`Remove the ${r.name} tag`,title:`Remove the tag`,children:G(K,{name:`x`,size:10})})]},r.start)}),n.issues.map(e=>G(`span`,{class:`tag-issue`,role:`note`,children:[e.text,` (read as text)`]},e.at))]}):n.tokens.length?G(`span`,{class:`tag-marks`,children:G(`span`,{class:`tag-off`,title:`The model this server runs wasn’t trained on nonverbal tags (or the server has no tag support): the markup is read as text.`,children:`‹tags› read as text`})}):null}function D_({text:e,children:t,block:n}){let[r,i]=M(!1),a=P(null),[o,s]=M({}),c=__.value&&!r&&kn(e).tokens.length>0;return pt(()=>{if(!c)return;let e=a.current?.querySelector(`input, textarea`);if(!e)return;let t=getComputedStyle(e),n=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),r=e instanceof HTMLInputElement?`${n}px`:t.lineHeight;s({padding:t.padding,font:t.font,lineHeight:r,letterSpacing:t.letterSpacing})},[c]),G(`span`,{ref:a,class:`tag-field${n?` is-block`:``}${c?` is-viewing`:``}`,onFocusIn:()=>i(!0),onFocusOut:()=>i(!1),children:[t,c&&G(`span`,{class:`tag-view`,style:o,"aria-hidden":`true`,children:G(O_,{text:e})})]})}function O_({text:e}){let{tokens:t,spans:n}=kn(e),r=[],i=0;for(let a of t){if(a.start>i){let t=n.find(e=>i>=e.open.end&&i1?`tag guidance ${e.tag_cfg_scale} on · voice guidance off`:null}function A_(e){requestAnimationFrame(()=>{let t=document.querySelector(e);t&&(t.scrollIntoView({block:`nearest`}),t.classList.add(`is-flash`),setTimeout(()=>t.classList.remove(`is-flash`),1200))})}function j_(){let e=xl.value,t=B.value?.id===kl,n=B.value?.id===Al;return G(`div`,{class:`ab`,role:`group`,"aria-label":`A/B`,children:[G(`button`,{class:`ab-btn${e===`A`?` is-on`:``}${t?` is-playing`:``}`,onClick:()=>t?Is():Jl(`A`),title:`Your design (A)`,children:[G(`b`,{children:`A`}),` design`]}),G(`button`,{class:`ab-btn${e===`B`?` is-on`:``}${n?` is-playing`:``}`,onClick:()=>n?Is():Jl(`B`),title:`The unsteered voice (B)`,children:[G(`b`,{children:`B`}),` original`]})]})}function M_(){let e=Dl.value,t=e.a;return e.status===`waiting`?`waiting…`:e.status===`rendering`?`rendering…`:e.status===`idle`?t?`${(t.pcm.length/t.sr).toFixed(1)} s`:W.value.baseId?`Press Speak to hear it`:``:e.status===`error`?``:t?`${(t.pcm.length/t.sr).toFixed(1)} s`:``}function N_(){let e=Dl.value.a;return e?`Clip length ${(e.pcm.length/e.sr).toFixed(1)} s · first audio after ${Math.round(e.ttfbMs)} ms`:`Clip length`}function P_(){let e=Ol.value.error;return xl.value!==`B`||!e?null:G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t render the original voice`}),G(`span`,{children:e}),G(`button`,{class:`btn sm`,onClick:Ul,children:[G(K,{name:`refresh`,size:14}),` Retry`]})]})}function F_(){return G(`div`,{class:`mode preview-toggles`,role:`group`,"aria-label":`Preview settings`,children:[G(`button`,{class:`mode-btn${Cl.value?` is-on`:``}`,"aria-pressed":Cl.value,onClick:()=>Cl.value=!Cl.value,title:Cl.value?`Auto: renders on every change (click to render only on Speak)`:`Renders only on Speak (click to render on every change)`,children:[G(K,{name:`wand`,size:12}),` Auto`]}),G(`button`,{class:`mode-btn${Sl.value?` is-on`:``}`,"aria-pressed":Sl.value,onClick:()=>Sl.value=!Sl.value,title:Sl.value?`Play: new takes play by themselves (click to keep them quiet)`:`New takes wait for Speak (click to play them by themselves)`,children:[G(K,{name:`speaker`,size:12}),` Play`]})]})}function I_(){let e=Dl.value,t=Ol.value,n=xl.value===`A`,r=n?kl:Al,i=n?e.a:t.take;return G($g,{pcm:n?e.status===`rendering`&&e.partial?e.partial:e.a?.pcm:t.take?.pcm,color:n?`var(--o)`:`var(--text-2)`,playId:r,busy:n?e.status===`waiting`||e.status===`rendering`:!t.take&&!t.error,height:40,label:n?`Designed voice waveform`:`Original voice waveform`,onSeek:e=>i&&Rs(r,i.pcm,i.sr,e*(i.pcm.length/i.sr))})}function L_(){let e=Dl.value;return G(`div`,{class:`preview-strip`,"aria-label":`Preview`,children:[G(j_,{}),G(I_,{}),G(`span`,{class:`metrics${e.status===`rendering`||e.status===`waiting`?` is-busy`:``}`,"aria-live":`polite`,children:e.status===`error`?G(`span`,{class:`error-line`,children:e_(e.error)?`not rendered: fix the pronunciation`:e.error}):M_()})]})}function R_(e){Tl.value=!0,wl.value=e}function z_(){Tg(`cast-library`),bg.peek()||requestAnimationFrame(()=>document.querySelector(`.voice.is-on .voice-name, .voices .voice-name`)?.focus({preventScroll:!1}))}function B_(){let e=Hc.value?.label;return G(`button`,{class:`btn sm voice-chip${e?``:` primary`}`,onClick:z_,title:e?`Change the voice`:`Pick a voice to start`,"aria-haspopup":`true`,children:[G(K,{name:`mic`,size:12}),` `,G(`span`,{class:`voice-chip-label`,children:e??`Pick a voice`}),` `,G(K,{name:`down`,size:10})]})}function V_(){let e=Dl.value,t=e.a,n=xl.value===`A`?t:Ol.value.take,[r,i]=M(null),a=P(null),o=ua.value?.kind===`fixture`,s=r??El.value,c=B.value?.id===kl,l=e.status===`waiting`||e.status===`rendering`,u=()=>{let e=a.current?.value??s;e!==El.value&&R_(e),i(null),Xl()},d=!W.value.baseId,f=e.status===`idle`&&!!t,p=e.status===`error`;return G(`section`,{class:`speak${f||p?` is-stale`:``}`,"aria-label":`Speak`,children:[G(`div`,{class:`speak-text`,children:[G(D_,{text:s,block:!0,children:G(`textarea`,{ref:a,class:`speak-area`,rows:2,value:s,placeholder:R.value.ui.preview_text,"aria-label":`Text to speak`,"data-tags":!0,onInput:e=>i(e.currentTarget.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),u())},onBlur:e=>{if(e.relatedTarget?.closest?.(`.tag-palette, .speak-go`))return;let t=e.currentTarget.value;t!==El.value&&R_(t),i(null)}})}),G(`div`,{class:`speak-tools`,children:[G(u_,{input:()=>a.current}),G(w_,{input:()=>a.current})]})]}),G(h_,{text:s,replace:(e,t,n)=>{i(null),R_(s.slice(0,e)+n+s.slice(t))}}),G(E_,{text:s,replace:e=>{i(null),R_(e)}}),G(`div`,{class:`speak-bar`,children:[G(B_,{}),G(`button`,{class:`btn primary speak-go${l?` is-busy`:``}`,disabled:d||!s.trim(),onClick:()=>c?Is():u(),title:d?`Pick a voice first`:f?`The voice changed since this take: render it again (Enter in the text box)`:`Speak this text (Enter in the text box)`,children:[G(K,{name:c?`stop`:`play`,size:14}),` `,c?`Stop`:l?`Rendering…`:f?`Speak again`:`Speak`]}),!d&&G(I_,{}),G(j_,{}),G(F_,{}),G(`span`,{class:`metrics`,title:N_(),children:M_()}),G(`button`,{class:`icon-btn`,disabled:!n,onClick:()=>n&&un(n.pcm,n.sr,`${Hc.value?.label??`voice`}-${xl.value===`A`?`design`:`original`}`),title:`Export ${xl.value} as WAV`,"aria-label":`Export ${xl.value} as WAV`,children:G(K,{name:`download`})})]}),!t&&!l&&!p&&!bg.value&&G(`p`,{class:`hint speak-first`,children:`Pick a voice · type a line · Speak · then shape it below`}),p&&e_(e.error)&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Fix the pronunciation marked above`}),G(`span`,{children:e.error})]}),p&&!e_(e.error)&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t render`}),G(`span`,{children:e.error}),G(`button`,{class:`btn sm`,onClick:ql,children:[G(K,{name:`refresh`,size:14}),` Retry`]})]}),G(P_,{}),o&&G(`p`,{class:`note`,children:`This server can’t apply controls yet: A and B both play the base voice.`})]})}function H_(e){let t=R.value,n=[];for(let[r,i]of Object.entries(e)){if(!i)continue;if(r.startsWith(`accent:`)){let e=t.ui.accents.find(e=>e.id===r.slice(7));n.push(`${e?.label??r.slice(7)} accent`);continue}let e=va.value.get(r);e&&(e.type===`bipolar`&&e.poles?n.push(e.poles[i<0?0:1].toLowerCase()):n.push(`more ${e.label.toLowerCase()}`))}return n.join(`, `)||`the plain voice`}function U_(){let e=Object.keys(R.value.ui.presets),t=W.value,n=e=>{let{values:n,accents:r}=Kt(R.value.ui.presets[e]),i=Ss(r,R.value.ui.accents,t.pin.tab);return[...new Set([...Object.keys(n),...Object.keys(t.values).filter(e=>t.values[e])])].every(e=>(n[e]??0)===(t.values[e]??0))&&Math.hypot(i.x-t.pin.x,i.y-t.pin.y)<1&&i.tab===t.pin.tab};return e.length?G(`section`,{class:`monitor-card`,"aria-label":`Starting points`,children:[G(`header`,{class:`monitor-head`,children:G(`h3`,{children:`Starting points`})}),G(`div`,{class:`persona-chips`,children:e.map(e=>G(`button`,{class:`persona-chip${n(e)?` is-on`:``}`,"aria-pressed":n(e),onClick:()=>$c(e),title:H_(R.value.ui.presets[e]),children:e}))})]}):null}var W_=I([]),G_=I(null),K_=null;function q_(){K_?.abort();let e=K_=new AbortController,t=W.value;G_.value=t,W_.value=ll(t).map(e=>({...e,id:Mt(),audio:null,error:null,busy:!0}));for(let t of W_.value)ec(yl(R.value,_a.value,t.design,El.value,pl,{language:ha.value.language}),{signal:e.signal}).then(e=>W_.value=W_.value.map(n=>n.id===t.id?{...n,audio:e,busy:!1}:n)).catch(e=>!tc(e)&&(W_.value=W_.value.map(n=>n.id===t.id?{...n,error:V(e),busy:!1}:n)))}function J_(){let e=W_.value,t=W.value,n=e.find(e=>e.design===t)??null,r=G_.value!==null&&G_.value!==t&&!n,i=e.filter(e=>e.busy).length,a=e.length>0&&e.every(e=>e.error);return G(`section`,{class:`monitor-card`,"aria-label":`Variations`,children:[G(`header`,{class:`monitor-head`,children:[G(`h3`,{children:`Voices near this one`}),G(`button`,{class:`btn sm`,onClick:q_,disabled:!t.baseId||i>0,title:`Renders five takes`,children:[G(K,{name:`dice`,size:14}),` `,i?`Rendering ${e.length-i}/${e.length}…`:e.length?`Five more`:`Find five`]})]}),u()&&G(`p`,{class:`hint`,children:`Counts against your GPU quota`}),e.length?a?G(`div`,{class:`error-line`,children:[`Couldn’t render: `,e[0].error,` `,G(`button`,{class:`link`,onClick:q_,children:`Retry`})]}):G(`ul`,{class:`tiles${r?` is-stale`:``}`,children:e.map(e=>{let t=`var:${e.id}`,r=B.value?.id===t;return G(`li`,{class:`tile${e===n?` is-current`:``}`,children:[G(`button`,{class:`play-mini${r?` is-playing`:``}${e.busy?` is-busy`:``}`,disabled:!e.audio,onClick:()=>e.audio&&Bs(t,e.audio.pcm,e.audio.sr),"aria-label":`Play variation: ${e.changes.join(`, `)}`,children:G(K,{name:r?`stop`:`play`,size:12})}),G(`button`,{class:`tile-body`,"aria-current":e===n?`true`:void 0,onClick:()=>{e!==n&&(U.apply(e.design),e.audio&&Rs(t,e.audio.pcm,e.audio.sr),z(`Stepped to: ${e.changes.join(` · `)}`,`info`,{label:`Undo`,run:()=>U.undo()}))},title:e===n?`The voice on the bench`:`Step to this voice (undo with ⌘Z)`,children:[G(`span`,{class:`tile-changes`,children:e.changes.join(` · `)}),e.error?G(`span`,{class:`error-line small`,children:e.error}):G($g,{pcm:e.audio?.pcm,color:`var(--o)`,playId:t,height:22,busy:e.busy})]})]})})}):G(`p`,{class:`muted small`,children:`Five small, safe moves around this voice, rendered side by side. Click one to step there.`}),r&&e.length>0&&G(`p`,{class:`note`,children:`You moved since these were found; they still sit around the earlier voice.`})]})}function Y_(e){let t=new Set(jc.value.map(e=>e.name));if(!t.has(e))return e;for(let n=2;;n++)if(!t.has(`${e} ${n}`))return`${e} ${n}`}function X_(){let[e,t]=M(``),[n,r]=M(``),[i,a]=M(!1),o=W.value,s=ua.value,c=dc.value[o.baseId],l=o.mode===`embedding`&&!!Wc.value&&(s.kind===`offline`||!uc.value)&&s.steering,u=o.mode===`embedding`?s.steering?uc.value?`Not available with this server’s placeholder voices.`:c?`Couldn't fetch this voice's embedding: ${c}`:Wc.value?null:`Waiting for the base voice…`:`This server can’t apply controls yet, so there is no shaped voice to save.`:`Exact clones are already in Your voices.`,d=e.trim()||`${Hc.value?.label??`Voice`} variant`,f=()=>{let e=Y_(d),i={id:Mt(),name:e,design:structuredClone(o),signature:n.trim()||El.value,createdAt:Date.now()};Mc(i),z(`“${e}” joined your cast`,`ok`),t(``),r(``),A_(`[data-persona="${i.id}"]`)},p=async()=>{if(Wc.value){a(!0);try{let e=await Cc(d,Wc.value),t=Fm.value;Wm(e,Hc.value,o.values[t.gender.control]??0,o.values[t.age.control]??0),await fc(),z(`Saved “${e.label}” as a voice`,`ok`),A_(`[data-voice="${e.id}"]`)}catch(e){z(`Couldn’t save the voice: ${V(e)}`,`error`)}finally{a(!1)}}};return G(`section`,{class:`monitor-card save save-panel`,"aria-label":`Save this voice`,children:[G(`header`,{class:`monitor-head`,children:G(`h3`,{children:`Save this voice`})}),G(`form`,{class:`col gap-s`,onSubmit:e=>{e.preventDefault(),o.baseId&&f()},children:[G(`input`,{class:`input`,placeholder:d,value:e,onInput:e=>t(e.currentTarget.value),"aria-label":`Name`}),G(`input`,{class:`input`,placeholder:`Signature line: what this voice says when loaded (optional)`,value:n,onInput:e=>r(e.currentTarget.value),"aria-label":`Signature line`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{type:`submit`,class:`btn primary`,disabled:!o.baseId,title:`Keeps the whole design (voice, accent, delivery, mood) in this project's cast, for Direct's lines`,children:[G(K,{name:`plus`,size:14}),` Add to cast `,G(`span`,{class:`muted`,children:`(use in Direct)`})]}),G(`button`,{type:`button`,class:`btn`,onClick:()=>void p(),disabled:!l||i,title:u??`Keeps the identity you shaped as a new voice in Your voices (delivery and mood stay in the cast member)`,children:[G(K,{name:`save`,size:14}),` `,i?`Saving…`:`Save to Your voices`]})]})]}),u&&G(`p`,{class:`hint`,children:[u,c&&G(j,{children:[` · `,G(`button`,{class:`link`,onClick:()=>Hc.value&&void mc(Hc.value,!0),children:`Retry`})]})]})]})}async function Z_(e){let t=q.value,n=t.lines.filter(t=>t.voice===e.id).length+ +(t.voice===e.id);if(n>0&&!await Tf(`${n} line${n===1?` speaks`:`s speak`} as ${e.name}. Remove it? They will fall back to the script voice.`,{ok:`Remove`,danger:!0}))return;let r=t.voice===e.id,i=n>0?Md(e.id):[],a=Nc(e.id);a&&z(`Removed “${e.name}”`,`info`,{label:`Undo`,run:()=>{Pc(a.persona,a.index),(i.length||r)&&Nd(i,e.id,r?e.id:void 0)}})}async function Q_(e){let t=q.value,n=t.lines.filter(t=>t.voice===e.id).length+ +(t.voice===e.id);if(n>0&&!await Tf(`${n} line${n===1?` speaks`:`s speak`} as ${e.label}. Remove it? They will fall back to the default voice.`,{ok:`Remove`,danger:!0}))return;let r=t.voice===e.id,i=n>0?Md(e.id):[],a=W.value.baseId===e.id,o=Ac(e.id);o&&z(`Removed “${e.label}” from this project`,`info`,{label:`Undo`,run:()=>{o(),(i.length||r)&&Nd(i,e.id,r?e.id:void 0),a&&Xc(e.id,`library`)}})}function $_({s:e,own:t}){let n=W.value.baseId===e.id,r=B.value?.id===`clip:${e.id}`,i=_c.value===e.id,[a,o]=M(!1);return G(`li`,{class:`voice${n?` is-on`:``}`,"data-voice":e.id,children:[G(`button`,{class:`play-mini${r?` is-playing`:``}${i?` is-busy`:``}`,onClick:()=>void vc(e),disabled:e.has_preview===!1,"aria-label":`${r?`Stop`:`Play`} ${e.label}'s reference clip`,title:e.has_preview===!1?`No reference clip (designed voice)`:`Reference clip`,children:G(K,{name:r?`stop`:`play`,size:12})}),a?G(Vg,{value:e.label,label:`Rename ${e.label}`,onDone:t=>{o(!1),t&&kc(e.id,t)}}):G(`button`,{class:`voice-name`,onClick:()=>Xc(e.id,`library`),"aria-pressed":n,title:n?`Current base voice`:`Use as the base voice`,children:[G(`span`,{class:`voice-label`,children:e.label}),La(e)&&G(`span`,{class:`tag`,children:`designed`})]}),t&&G(j,{children:[G(`button`,{class:`icon-btn sm`,"aria-label":`Rename ${e.label}`,title:`Rename (in this project)`,onClick:()=>o(!0),children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,"aria-label":`Remove ${e.label}`,title:`Removes it from this project (the server keeps it for this session)`,onClick:()=>void Q_(e),children:G(K,{name:`trash`,size:14})})]})]})}function ev(){let e=Ec.value;if(!e)return null;let t=`clip:pending`,n=B.value?.id===t,r=async()=>{let e=await Oc();e&&(Xc(e.id,`clip`),mc(e),A_(`[data-voice="${e.id}"]`))};return G(`div`,{class:`pending-clip`,role:`group`,"aria-label":`Your recording`,children:[G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`play-mini${n?` is-playing`:``}`,onClick:()=>Bs(t,e.pcm,e.sr),"aria-label":n?`Stop`:`Play the recording`,children:G(K,{name:n?`stop`:`play`,size:12})}),G($g,{pcm:e.pcm,color:`var(--o)`,playId:t,height:28,label:`Recording waveform`,onSeek:n=>Rs(t,e.pcm,e.sr,n*e.seconds)}),G(`span`,{class:`metrics`,children:[e.seconds.toFixed(1),` s`]})]}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm primary`,disabled:yc.value,onClick:()=>void r(),children:[G(K,{name:`plus`,size:12}),` Use`]}),G(`button`,{class:`btn sm`,onClick:()=>(zs(t)&&Is(),Ec.value=null),children:`Discard`}),e.seconds<5&&G(`span`,{class:`hint`,children:`Short: 5–30 s clones best`})]})]})}function tv(){let e=wc.value,[,t]=M(0);if(N(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),250);return()=>clearInterval(n)},[e]),e){let t=Math.floor((Date.now()-e.started)/1e3);return G(`button`,{class:`btn btn-rec is-recording`,onClick:e.stop,title:`Recording stops by itself at 30 s`,children:[G(`span`,{class:`rec-dot`}),` Stop · 0:`,String(t).padStart(2,`0`),` / 0:`,30,G(`span`,{class:`rec-level`,"aria-hidden":`true`,children:G(`span`,{style:{width:`${Math.round(Tc.value*100)}%`}})})]})}return G(`button`,{class:`btn btn-rec`,disabled:yc.value||!!Ec.value,onClick:()=>void Dc(),title:`Record 5-30 s of clean speech to clone a voice`,children:[G(K,{name:`mic`}),` Record`]})}function nv(e){H.value.find(t=>t.id===e.design.baseId)||z(`${e.name}'s voice is gone from the server; pick a base voice`,`error`),U.apply(structuredClone(e.design));let t=e.signature.trim(),n=El.value.trim();t&&(!n||n===t)?(n!==t&&R_(t),z(`Loaded ${e.name}`,`info`,{label:`Undo`,run:()=>U.undo()})):z(`Loaded ${e.name}`,`info`,t?{label:`Use its line`,run:()=>R_(t)}:{label:`Undo`,run:()=>U.undo()})}function rv({p:e}){let t=H.value.find(t=>t.id===e.design.baseId),[n,r]=M(!1);return G(`li`,{class:`voice persona${t?``:` is-missing`}`,"data-persona":e.id,children:[n?G(Vg,{value:e.name,label:`Rename ${e.name}`,onDone:t=>{r(!1),t&&Fc(e.id,t)}}):G(`button`,{class:`voice-name`,onClick:()=>nv(e),title:t?`Load ${e.name} onto the bench`:`${e.name}'s base voice is gone from the server`,children:[e.name,G(`span`,{class:`sub`,children:t?.label??`voice unavailable`})]}),G(`button`,{class:`icon-btn sm`,"aria-label":`Rename ${e.name}`,title:`Rename`,onClick:()=>r(!0),children:G(K,{name:`edit`,size:14})}),G(`button`,{class:`icon-btn sm`,"aria-label":`Remove ${e.name}`,title:`Remove from cast`,onClick:()=>void Z_(e),children:G(K,{name:`trash`,size:14})})]})}async function iv(e){let t=await bc(e,e.name.replace(/\.[^.]+$/,``),e.name,!0);t&&(Xc(t.id,`clip`),mc(t),A_(`[data-voice="${t.id}"]`))}function av(){let e=P(null),t=H.value.filter(e=>e.is_default),n=H.value.filter(e=>!e.is_default);return G(`aside`,{class:`rail`,"aria-label":`Voice library`,children:[G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Voices`}),ac.value?G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:`Couldn’t load the voices`}),G(`span`,{children:ac.value}),G(`button`,{class:`btn sm`,onClick:()=>void fc(),children:[G(K,{name:`refresh`,size:14}),` Retry`]})]}):oc.value&&!t.length?G(`p`,{class:`muted`,children:`Loading voices…`}):G(`ul`,{class:`voices`,children:t.map(e=>G($_,{s:e},e.id))})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Your voices`}),n.length?G(`ul`,{class:`voices`,children:n.map(e=>G($_,{s:e,own:!0},e.id))}):G(`p`,{class:`muted small`,children:`Upload, drop or record a clip to clone a voice. Designed voices you save appear here too.`}),G(ev,{}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn`,disabled:yc.value,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`}),` `,yc.value?`Uploading…`:`Upload`]}),G(tv,{}),G(`input`,{ref:e,type:`file`,accept:`audio/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&iv(t)}})]})]}),G(`div`,{class:`rail-section grow`,children:[G(`h4`,{children:`Your cast`}),jc.value.length?G(`ul`,{class:`voices`,children:jc.value.map(e=>G(rv,{p:e},e.id))}):G(`p`,{class:`muted small`,children:`Design a voice, then “Save to cast” to keep it for Direct (each line can use its own voice).`})]}),G(Ng,{label:`Drop to clone this voice`,hint:`An audio clip of 5–30 s of clean speech`,busy:yc.value?`Wait for the current upload…`:null,onFile:e=>void iv(e)})]})}var ov={strong:`strong`,collapse:`may glitch`},sv=(e,t,n)=>(F(n,e,t)-e)/(t-e||1)*100;function cv(e){let t=e.range[1]-e.range[0];return t>12?.5:t>5?.1:.05}function lv({control:e,value:t,color:n,disabled:r,vertical:i,bare:a,label:o,compact:s,detailed:c,format:l=jt,onStart:u,onChange:d,onEnd:f}){let[p,m]=e.range,h=Bt(e,t),g=cv(e),_=e=>Math.round(F(e,p,m)/g)*g,v=sv(p,m,0),y=sv(p,m,t),b=[];e.safe[0]>p&&b.push({from:0,to:sv(p,m,e.safe[0]),cls:`strong`}),e.safe[1]p&&b.push({from:0,to:sv(p,m,e.collapse[0]),cls:`collapse`}),e.collapse?.[1]!=null&&e.collapse[1]{let n=null,r=e.shiftKey?5:1;e.key===`ArrowRight`||e.key===`ArrowUp`?n=t+g*2*r:e.key===`ArrowLeft`||e.key===`ArrowDown`?n=t-g*2*r:e.key===`Home`?n=p:e.key===`End`?n=m:(e.key===`0`||e.key===`Delete`||e.key===`Backspace`)&&(n=0),n!==null&&(e.preventDefault(),u?.(),d(_(n)),f?.())},w=e.type===`bipolar`&&e.poles?`${e.poles[0]} ↔ ${e.poles[1]}`:null,T=[s?w:null,e.effect,`range ${p}…${m} · natural ${e.safe[0]}…${e.safe[1]}`].filter(Boolean).join(` · `);return G(`div`,{class:`slider${i?` is-vertical`:``}${s?` is-compact`:``}${c?` is-detailed`:``}${r?` is-disabled`:``} zone-${h}`,style:{"--fam":n},title:T,children:[s&&G(`span`,{class:`slider-label`,children:o??e.label}),!a&&!s&&G(`div`,{class:`slider-head`,children:[G(`span`,{class:`slider-label`,children:o??e.label}),G(`span`,{class:`slider-value`,children:[ov[h]&&G(`span`,{class:`zone-tag zone-${h}`,children:ov[h]}),l(t)]})]}),G(`div`,{class:`slider-track`,role:`slider`,tabIndex:r?-1:0,"aria-label":o??e.label,"aria-valuemin":p,"aria-valuemax":m,"aria-valuenow":t,"aria-valuetext":`${l(t)}${ov[h]?` (${ov[h]})`:``}`,"aria-orientation":i?`vertical`:`horizontal`,"aria-disabled":r,onKeyDown:r?void 0:C,onDblClick:r?void 0:()=>(u?.(),d(0),f?.()),onPointerDown:r?void 0:e=>{u?.(),kg(e,(e,t)=>d(_(p+(i?1-t:e)*(m-p))),f)},children:[G(`div`,{class:`slider-rail`}),b.map(e=>G(`div`,{class:`slider-band band-${e.cls}`,style:{[x]:`${e.from}%`,[S]:`${e.to-e.from}%`}})),G(`div`,{class:`slider-fill`,style:{[x]:`${Math.min(v,y)}%`,[S]:`${Math.abs(y-v)}%`}}),p<0&&G(`div`,{class:`slider-zero`,style:{[x]:`${v}%`}}),G(`div`,{class:`slider-thumb`,style:{[x]:`${y}%`}})]}),s&&G(`span`,{class:`slider-value`,children:[ov[h]&&G(`span`,{class:`zone-tag zone-${h}`,children:ov[h]}),l(t)]}),!a&&!s&&e.type===`bipolar`&&e.poles&&G(`div`,{class:`slider-poles`,children:[G(`span`,{children:e.poles[0]}),G(`span`,{children:e.poles[1]})]}),c&&G(`p`,{class:`slider-effect`,children:[e.effect&&G(`span`,{children:e.effect}),G(`span`,{class:`slider-ranges`,children:[`natural `,jt(e.safe[0]),`…`,jt(e.safe[1]),(e.safe[0]>p||e.safe[1]Math.max(.5,Math.round(e*2)/2),dv=L(()=>{let[e,t]=R.value.ui.controls.filter(e=>e.group===`mood`&&e.type===`bipolar`);return e&&t?{x:e,y:t}:null}),fv=L(()=>{let e=new Map((R.value.ui.moods??[]).map(e=>[e.control,e])),t=R.value.ui.controls.filter(e=>e.group===`mood`&&e.type===`unipolar`).map(t=>{let n=e.get(t.id),r=n&&Number.isFinite(n.valence)&&Number.isFinite(n.arousal)?{valence:n.valence,arousal:n.arousal}:null;return{control:t,label:n?.label??t.label,at:r,dose:n?.dose&&n.dose>0?n.dose:uv(t.safe[1]*.5),effect:n?.effect??t.effect??``}});return t.every(e=>e.at)?t.sort((e,t)=>t.at.arousal-e.at.arousal):t}),pv=L(()=>new Set(fv.value.map(e=>e.control.id))),mv=e=>`×${+e.toFixed(e%1?1:0)}`,hv=e=>`strength ${+e.toFixed(e%1?1:0)}`;function gv(e,t){return`${e.label}${e.effect?`: ${e.effect}`:``} · default ${hv(e.dose)}${t>0?` · now ${hv(t)} (click to remove)`:` (click to add)`}`}function _v(e,t){let n=e.values[t.control.id]??0;e.begin(),e.set(t.control.id,n>0?0:t.dose),e.end()}function vv({m:e,values:t,onPick:n}){let r=t[e.control.id]??0;return G(`button`,{class:`chip mood-chip${r>0?` is-on`:``} zone-${Bt(e.control,r)}`,"aria-pressed":r>0,title:gv(e,r),onClick:()=>n(e),children:[e.label,r>0&&G(`b`,{children:mv(r)})]})}function yv({values:e,onPick:t}){let n=fv.value;return n.length?G(`div`,{class:`chips mood-chips`,style:{"--fam":ba(`mood`)},role:`group`,"aria-label":`Moods`,children:n.map(n=>G(vv,{m:n,values:e,onPick:t}))}):null}var bv=e=>({x:(e.at.valence+1)/2,y:(1-e.at.arousal)/2});function xv(e,t,n){let r=10/t,i=e=>({x:Math.min(1-r,Math.max(r,e.x)),y:Math.min(1-r,Math.max(r,e.y))}),a=e.map(e=>i(bv(e))),o=n/t;for(let e=0;e<40;e++){let e=!1;for(let t=0;t=o)continue;c<1e-6&&(r=0,s=1,c=1);let l=(o-Math.hypot(a[n].x-a[t].x,a[n].y-a[t].y))/2+1e-4;a[t]=i({x:a[t].x-r/c*l,y:a[t].y-s/c*l}),a[n]=i({x:a[n].x+r/c*l,y:a[n].y+s/c*l}),e=!0}if(!e)break}return new Map(e.map((e,t)=>[e.control.id,a[t]]))}function Sv(e,t,n,r,i,a){let o=new Map,s=i+4,c=[...a,...e.map(e=>({x:t.get(e.control.id).x*r-5,y:t.get(e.control.id).y*r-5,w:10,h:10}))],l=e=>e.x<1||e.y<1||e.x+e.w>r-1||e.y+e.h>r-1||c.some(t=>e.xNumber((n[t.control.id]??0)>0)-Number((n[e.control.id]??0)>0));for(let e of u){let{x:a,y:u}=t.get(e.control.id),d=a*r,f=u*r,p=n[e.control.id]??0,m=(e.label.length+(p>0?mv(p).length+1:0))*i*.6+6,h=[[`r`,{x:d+5+1,y:f-s/2,w:m,h:s}],[`l`,{x:d-5-1-m,y:f-s/2,w:m,h:s}],[`u`,{x:d-m/2,y:f-5-s,w:m,h:s}],[`d`,{x:d-m/2,y:f+5,w:m,h:s}],[`dr`,{x:d+5,y:f+5-2,w:m,h:s}],[`dl`,{x:d-5-m,y:f+5-2,w:m,h:s}]].find(([,e])=>!l(e));o.set(e.control.id,h?h[0]:`hidden`),h&&c.push(h[1])}return o}function Cv(e){let[t,n]=M(0);return pt(()=>{let t=e.current;if(!t)return;n(t.clientWidth);let r=new ResizeObserver(()=>n(t.clientWidth));return r.observe(t),()=>r.disconnect()},[e.current]),t}function wv(e,t){return Math.min(Math.abs(e)>1e-6?.48/Math.abs(e):1/0,Math.abs(t)>1e-6?.48/Math.abs(t):1/0)}function Tv(e,t,n){let{x:r,y:i}=bv(e),a=r-.5,o=i-.5,s=a*a+o*o,c=s>.0025?((t-.5)*a+(n-.5)*o)/s:Math.hypot(t-.5,n-.5)/.3,l=e.control;return Math.round(Math.min(l.range[1],Math.max(0,c*e.dose))*10)/10}function Ev({b:e,pad:t,width:n,font:r,blocked:i,preview:a}){let o=fv.value.filter(e=>e.at);if(!o.length||!n)return null;let s=xv(o,n,r+6),c=Sv(o,s,e.values,n,r,i),l=(e,n)=>{let r=bv(e),[i,a]={ArrowRight:[1,0],ArrowLeft:[-1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[n],s=null,c=1/0;for(let t of o){if(t===e)continue;let n=bv(t),o=(n.x-r.x)*i+(n.y-r.y)*a;if(o<=1e-6)continue;let l=o+2*Math.abs((n.x-r.x)*a-(n.y-r.y)*i);l{r.stopPropagation(),r.currentTarget.focus();let a=null,o=!1;kg(r,(t,r)=>{if(!a)return void(a=[t,r]);!o&&Math.hypot(t-a[0],r-a[1])<.025||(o||(o=!0,e.begin()),e.set(n.control.id,Tv(n,t,r)))},()=>{o?e.end():i&&_v(e,n)},t.current??void 0)},d=o.filter(t=>(e.values[t.control.id]??0)>0);return G(j,{children:[G(`svg`,{class:`mlm-rays`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[o.map(e=>{let t=bv(e),r=s.get(e.control.id);return Math.hypot(t.x-r.x,t.y-r.y)*n>2?G(`line`,{x1:t.x*100,y1:t.y*100,x2:r.x*100,y2:r.y*100,class:`mlm-leader`,"vector-effect":`non-scaling-stroke`}):null}),d.map(e=>{let{x:t,y:n}=bv(e),r=wv(t-.5,n-.5),i=Math.min(r,e.control.safe[1]/e.dose);return G(`g`,{children:[G(`line`,{x1:`50`,y1:`50`,x2:50+(t-.5)*100*i,y2:50+(n-.5)*100*i,class:`mlm-ray`,"vector-effect":`non-scaling-stroke`}),i{let n=e.values[t.control.id]??0,{x:r,y:i}=s.get(t.control.id),o=c.get(t.control.id)??`hidden`;return a?G(`span`,{class:`mlm is-preview side-${o}${n>0?` is-on zone-${Bt(t.control,n)}`:``}`,style:{left:`${r*100}%`,top:`${i*100}%`,"--glow":Math.min(1.4,n/t.dose)},"aria-hidden":`true`,children:[G(`span`,{class:`mlm-dot`}),G(`span`,{class:`mlm-label`,children:[t.label,n>0&&G(`b`,{class:`mlm-dose`,children:[` `,mv(n)]})]})]}):G(`button`,{"data-mood":t.control.id,class:`mlm side-${o}${n>0?` is-on zone-${Bt(t.control,n)}`:``}`,style:{left:`${r*100}%`,top:`${i*100}%`,"--glow":Math.min(1.4,n/t.dose)},"aria-pressed":n>0,"aria-label":`${t.label}${n>0?`, ${mv(n)}`:``}`,title:gv(t,n),onPointerDown:e=>u(t,e,!0),onClick:n=>n.detail===0&&_v(e,t),onKeyDown:r=>{if(r.key.startsWith(`Arrow`))return void(r.preventDefault(),r.stopPropagation(),l(t,r.key));let i=r.key===`+`||r.key===`=`||r.key===`]`?.5:r.key===`-`||r.key===`[`?-.5:0;i?(r.preventDefault(),r.stopPropagation(),e.begin(),e.set(t.control.id,Math.min(t.control.range[1],Math.max(0,Math.round((n+i)*10)/10))),e.end()):(r.key===`Delete`||r.key===`Backspace`)&&(r.preventDefault(),r.stopPropagation(),n&&(e.begin(),e.set(t.control.id,0),e.end()))},children:[G(`span`,{class:`mlm-dot`}),G(`span`,{class:`mlm-label`,children:[t.label,n>0&&G(`b`,{class:`mlm-dose`,children:[` `,mv(n)]})]})]})}),d.map(t=>{let r=e.values[t.control.id]??0,{x:i,y:a}=bv(t),o=Math.min(r/t.dose,wv(i-.5,a-.5)),c=.5+(i-.5)*o,l=.5+(a-.5)*o,d=s.get(t.control.id);return Math.hypot(c-d.x,l-d.y)*n<9?null:G(`span`,{class:`mlm-handle zone-${Bt(t.control,r)}`,style:{left:`${c*100}%`,top:`${l*100}%`},title:`${t.label} ${mv(r)}: drag along the line for strength`,onPointerDown:e=>u(t,e,!1),children:G(`span`,{class:`mlm-handle-tag`,children:mv(r)})})})]})}var Dv={phone:`M7 3h4l1 5-2.5 1.5a11 11 0 0 0 5 5L16 12l5 1v4a2 2 0 0 1-2 2A16 16 0 0 1 5 5a2 2 0 0 1 2-2z`,podcast:`M12 3a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM6 11a6 6 0 0 0 12 0M12 17v4M9 21h6`,studio:`M4 9v6M8 6v12M12 3v18M16 7v10M20 10v4`};function Ov({b:e,large:t}){let n=R.value.ui.controls.find(e=>e.group===`room`);if(!n)return null;let r=ba(`room`),i=e.values[n.id]??0,[a,o]=n.range,s=Qt(n),c=s.reduce((e,t)=>Math.abs(t.at-i)G(`button`,{class:`room-scene${Math.abs(c.at-i)<.6&&c.id===r.id?` is-on`:``}`,style:{left:`${(r.at-a)/(o-a)*100}%`},onClick:()=>(e.begin(),e.set(n.id,r.at),e.end()),title:`${r.label} (${r.at>0?`+`:``}${r.at})`,children:[G(`svg`,{viewBox:`0 0 24 24`,width:t?34:18,height:t?34:18,"aria-hidden":`true`,children:G(`path`,{d:Dv[r.id],fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})}),G(`span`,{class:`room-scene-label`,children:r.label}),t&&G(`span`,{class:`room-scene-at`,children:[r.at>0?`+`:``,r.at]})]}))}),t?G(lv,{control:n,value:i,color:r,label:`Room`,detailed:!0,onStart:e.begin,onChange:t=>e.set(n.id,t),onEnd:e.end}):G(lv,{control:n,value:i,color:r,label:`Room`,bare:!0,onStart:e.begin,onChange:t=>e.set(n.id,t),onEnd:e.end}),!t&&G(`div`,{class:`room-read`,children:[G(`span`,{children:n.poles?.[0]??`phone`}),G(`b`,{children:[i>0?`+`:``,i.toFixed(1)]}),G(`span`,{children:n.poles?.[1]??`studio`})]})]})}function kv({group:e,b:t,only:n,compact:r,detailed:i}){let a=ba(e),o=R.value.ui.controls.filter(t=>t.group===e&&!t.span_only&&(!n||n(t)));return G(`div`,{class:`slider-group${i?` is-detailed`:``}`,children:o.map(e=>G(lv,{control:e,value:t.values[e.id]??0,color:a,compact:r,detailed:i,onStart:t.begin,onChange:n=>t.set(e.id,n),onEnd:t.end},e.id))})}function Av({b:e,compact:t,large:n,padOpens:r}){let i=dv.value,a=i?.x,o=i?.y,s=fv.value,c=P(null),l=Cv(c),u=ba(`mood`),d=a?e.values[a.id]??0:0,f=o?e.values[o.id]??0:0,p=a?(d-a.range[0])/(a.range[1]-a.range[0])*100:50,m=o?(1-(f-o.range[0])/(o.range[1]-o.range[0]))*100:50,h=a?Bt(a,d):`safe`,g=o?Bt(o,f):`safe`,_=a&&o&&{left:`${(a.safe[0]-a.range[0])/(a.range[1]-a.range[0])*100}%`,width:`${(a.safe[1]-a.safe[0])/(a.range[1]-a.range[0])*100}%`,top:`${(1-(o.safe[1]-o.range[0])/(o.range[1]-o.range[0]))*100}%`,height:`${(o.safe[1]-o.safe[0])/(o.range[1]-o.range[0])*100}%`},v=s.some(e=>e.at),y=n||!v,b=n?12:11,x=y&&l?[0,1].flatMap(e=>[0,1].map(t=>({x:e?l-64:0,y:t?l-20:0,w:64,h:20}))):[];n&&l&&x.push({x:0,y:l/2-24,w:70,h:20},{x:l-70,y:l/2-24,w:70,h:20});let S=s.filter(t=>(e.values[t.control.id]??0)>0),C=t=>_v(e,t);return G(`div`,{class:`mood${t?` is-compact`:``}${n?` is-large`:``}${v?` has-landmarks`:``}${r?` pad-opens`:``}`,style:{"--fam":u},children:[a&&o&&G(`div`,{ref:c,class:`mood-pad zone-${h===`safe`&&g===`safe`?`safe`:`strong`}`,role:`group`,"aria-label":`Mood pad: ${a.label} (x) and ${o.label} (y)${v?`, with measured moods as landmarks`:``}`,inert:r?!0:void 0,onDblClick:t=>!t.target.closest(`.mlm, .mlm-handle`)&&(e.begin(),e.set(a.id,0),e.set(o.id,0),e.end()),onPointerDown:t=>{t.detail===2||t.target.closest(`.mlm, .mlm-handle`)||(e.begin(),kg(t,(t,n)=>{e.set(a.id,Math.round((a.range[0]+F(t,0,1)*(a.range[1]-a.range[0]))*10)/10),e.set(o.id,Math.round((o.range[1]-F(n,0,1)*(o.range[1]-o.range[0]))*10)/10)},e.end))},children:[_&&G(`div`,{class:`mood-safe`,style:_}),y&&G(j,{children:[G(`span`,{class:`q q-tl`,children:`tense`}),G(`span`,{class:`q q-tr`,children:`excited`}),G(`span`,{class:`q q-bl`,children:`low`}),G(`span`,{class:`q q-br`,children:`content`})]}),G(`span`,{class:`mood-axis-x`}),G(`span`,{class:`mood-axis-y`}),G(Ev,{b:e,pad:c,width:l,font:b,blocked:x,preview:r}),G(`span`,{class:`mood-dot`,style:{left:`${p}%`,top:`${m}%`},role:`slider`,tabIndex:0,"aria-label":`${a.label} (x) and ${o.label} (y)`,"aria-valuetext":`${a.label} ${d.toFixed(1)}, ${o.label} ${f.toFixed(1)}`,title:`${a.label} × ${o.label}: drag anywhere on the pad, arrow keys to nudge, 0 or Delete to reset. Double-click the pad to reset.`,onKeyDown:t=>{if(t.key===`0`||t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),e.begin(),e.set(a.id,0),e.set(o.id,0),e.end();return}let n=t.shiftKey?1:.25,r=t.key===`ArrowRight`?n:t.key===`ArrowLeft`?-n:0,i=t.key===`ArrowUp`?n:t.key===`ArrowDown`?-n:0;(r||i)&&(t.preventDefault(),e.begin(),e.set(a.id,d+r),e.set(o.id,f+i),e.end())}}),n&&G(j,{children:[G(`span`,{class:`mp mp-l`,children:a.poles?.[0]??`−`}),G(`span`,{class:`mp mp-r`,children:a.poles?.[1]??`+`})]})]}),n?G(`div`,{class:`mood-detail`,children:[[a,o].filter(e=>!!e).map(t=>G(lv,{control:t,value:e.values[t.id]??0,color:u,detailed:!0,onStart:e.begin,onChange:n=>e.set(t.id,n),onEnd:e.end},t.id)),G(`h4`,{class:`eyebrow`,children:`Moods`}),G(yv,{values:e.values,onPick:C}),S.length>0&&G(`h4`,{class:`eyebrow`,children:[`Strength`,S.length>1?` · the doses add up`:``]}),S.map(t=>G(lv,{control:t.control,value:e.values[t.control.id]??0,color:u,detailed:!0,onStart:e.begin,onChange:n=>e.set(t.control.id,n),onEnd:e.end},t.control.id)),v&&G(`p`,{class:`hint`,children:`Landmarks sit where each mood measured at its default dose. Click one to add it, click again to remove; drag it or its handle along the line for strength. Arrow keys move between moods, + / − change the dose.`})]}):G(j,{children:[G(yv,{values:e.values,onPick:C}),t&&G(`p`,{class:`hint mood-hint`,children:r?`Click the pad to open the mood controls`:`Dot = overall tone · chips add named moods`})]}),!t&&!n&&a&&o&&G(`p`,{class:`hint`,children:[a.label,` `,d.toFixed(1),` · `,o.label,` `,f.toFixed(1)]})]})}var jv=320,Mv=jv/2,Nv=112;function Pv({large:e}){let t=R.value.ui.controls.filter(e=>e.group===`texture`),n=P(null),[r,i]=M(null),a=ba(`texture`),o=W.value.values,s=t.length;if(!s)return null;let c=e=>-Math.PI/2+e/s*Math.PI*2,l=(e,t)=>[Mv+Math.cos(c(e))*Nv*t,Mv+Math.sin(c(e))*Nv*t],u=e=>F((o[t[e].id]??0)/t[e].range[1],0,1),d=t.map((e,t)=>l(t,u(t)).map(e=>e.toFixed(1)).join(`,`)).join(` `),f=(e,r)=>{let a=n.current.getBoundingClientRect(),o=(e.clientX-a.left)/a.width*jv-Mv,s=(e.clientY-a.top)/a.height*jv-Mv,l=r;if(l===void 0){let e=Math.atan2(s,o),n=0,r=9;t.forEach((t,i)=>{let a=Math.abs(Math.atan2(Math.sin(e-c(i)),Math.cos(e-c(i))));a{let n=e*jv-Mv,r=t*jv-Mv,i=n*Math.cos(c(l))+r*Math.sin(c(l));Kc(u.id,Math.round(F(i/Nv,0,1)*u.range[1]*10)/10)},()=>U.end(),n.current)},p=[.25,.5,.75,1],m=t.map((e,t)=>l(t,F(e.safe[1]/e.range[1],0,1)).join(`,`)).join(` `);return G(`div`,{class:`radar${e?` is-large`:``}`,style:{"--fam":a},children:[G(`svg`,{ref:n,class:`radar-svg`,viewBox:`0 0 ${jv} ${jv}`,onPointerDown:e=>f(e),"aria-hidden":`true`,children:[p.map(e=>G(`circle`,{class:`radar-ring`,cx:Mv,cy:Mv,r:Nv*e})),G(`polygon`,{class:`radar-safe`,points:m}),t.map((t,n)=>{let[i,a]=l(n,1),[s,c]=l(n,1.2),u=o[t.id]??0,d=F(t.safe[1]/t.range[1],0,1),f=t.collapse?.[1]==null?1:F(t.collapse[1]/t.range[1],0,1),[p,m]=l(n,d),[h,g]=l(n,f);return G(`g`,{children:[G(`line`,{class:`radar-spoke`,x1:Mv,y1:Mv,x2:i,y2:a}),e&&G(j,{children:[G(`line`,{class:`spoke-safe`,x1:Mv,y1:Mv,x2:p,y2:m}),G(`line`,{class:`spoke-strong`,x1:p,y1:m,x2:h,y2:g}),f<1&&G(`line`,{class:`spoke-collapse`,x1:h,y1:g,x2:i,y2:a})]}),G(`text`,{class:`radar-label${r===t.id?` is-on`:``}`,x:s,y:c+4,children:[t.label,e&&G(`tspan`,{class:`radar-value zone-${Bt(t,u)}`,children:` ${u.toFixed(1)}`})]})]})}),G(`polygon`,{class:`radar-shape`,points:d}),t.map((e,t)=>{let[n,r]=l(t,u(t));return G(`circle`,{class:`radar-handle zone-${Bt(e,o[e.id]??0)}`,cx:n,cy:r,r:`7`,onPointerDown:e=>(e.stopPropagation(),f(e,t))})})]}),e&&G(`div`,{class:`radar-detail`,children:t.map(e=>G(`div`,{class:`radar-row${r===e.id?` is-on`:``}`,onFocusIn:()=>i(e.id),onPointerEnter:()=>i(e.id),children:G(lv,{control:e,value:o[e.id]??0,color:a,detailed:!0,onStart:()=>U.begin(),onChange:t=>Kc(e.id,t),onEnd:()=>U.end()})}))})]})}var Fv=420,Iv=420,Lv=42,Rv=12,zv=6.3,Bv=`pitch`;function Vv(e,t,n){let r=R.value,i=W.value,a=(n,a)=>Yt(r,{...i.values,[e]:n,[t]:a},zc.value,i.mode);if(a(0,0)=n)r=i;else for(let e=0;e<22;e++){let e=(r+i)/2;a(e*Math.cos(t),e*Math.sin(t))>=n?r=e:i=e}o.push([r*Math.cos(t),r*Math.sin(t)])}return o}var Hv=(e,t)=>e.x({x:e.x-5,y:e.y-5,w:10,h:10}));for(let i of e){let e=i.text.length*zv,a=i.x0?`start`:`end`,box:{x:a>0?i.x+8:i.x-8-e,y:i.y-7,w:e,h:13}},{dx:-9*a,dy:4,anchor:a>0?`end`:`start`,box:{x:a>0?i.x-8-e:i.x+8,y:i.y-7,w:e,h:13}},{dx:0,dy:-10,anchor:`middle`,box:{x:i.x-e/2,y:i.y-20,w:e,h:13}},{dx:0,dy:17,anchor:`middle`,box:{x:i.x-e/2,y:i.y+6,w:e,h:13}}].find(e=>e.box.x>=Lv&&e.box.x+e.box.w<=408&&e.box.y>=Rv&&e.box.y+e.box.h<=394&&!t.some(t=>Hv(t,e.box))&&!r.some(t=>Hv(t,e.box)));o&&t.push(o.box),n.set(i.id,o?{dx:o.dx,dy:o.dy,anchor:o.anchor}:null)}return n}function Wv({large:e}){let t=P(null),n=Fm.value,r=va.value.get(n.gender.control),i=va.value.get(n.age.control),a=va.value.get(Bv),o=W.value,s=ba(`who`);if(N(()=>{let e=t.current;if(!e||!a)return;let n=0,r=t=>{if(t.deltaY===0||document.activeElement!==e&&!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),U.begin();let r=.1*F(Math.abs(t.deltaY)/50,.5,3);Kc(a.id,(W.value.values[a.id]??0)+(t.deltaY<0?r:-r)),clearTimeout(n),n=window.setTimeout(()=>U.end(),400)};return e.addEventListener(`wheel`,r,{passive:!1}),()=>e.removeEventListener(`wheel`,r)},[a]),!r||!i)return G(`p`,{class:`muted`,children:`This voice bundle has no gender / age controls.`});let{x:[c,l],y:[u,d]}=Um.value,f=e=>Lv+(e-c)/(l-c)*366,p=e=>Rv+(d-e)/(d-u)*382,m=e=>F(e,c,l),h=e=>F(e,u,d),g=zm(Hc.value),_=o.values[r.id]??0,v=o.values[i.id]??0,y=g.x+_,b=g.y+v,x=yl||bd,S=R.value.ui.identity_threshold??.8,C=Vv(r.id,i.id,S),w=Xt(Vc.value,S),T=w===`New person`,E=H.value.filter(e=>e.id!==o.baseId).map(e=>({s:e,spot:zm(e)})).filter(e=>e.spot.measured||e.spot.from),D=Hc.value?.label??`base`,O=[{x:f(m(g.x))-D.length*zv/2,y:p(h(g.y))-24,w:D.length*zv,h:13}],ee=Uv(E.map(e=>({id:e.s.id,x:f(m(e.spot.x)),y:p(h(e.spot.y)),text:e.s.label})),O),te=(e,t)=>{let n=c+(e*Fv-Lv)/366*(l-c),a=d-(t*Iv-Rv)/382*(d-u),o=W.value;U.set({...o,values:{...o.values,[r.id]:Math.round(F(n-g.x,r.range[0],r.range[1])*20)/20,[i.id]:Math.round(F(a-g.y,i.range[0],i.range[1])*20)/20}})},ne=e=>{let t=e.shiftKey?.5:.1,n=e.key===`ArrowRight`?t:e.key===`ArrowLeft`?-t:0,a=e.key===`ArrowUp`?t:e.key===`ArrowDown`?-t:0,o=e.key===`0`||e.key===`Delete`||e.key===`Backspace`;(n||a||o)&&(e.preventDefault(),U.begin(),Kc(r.id,o?0:_+n),Kc(i.id,o?0:v+a),U.end())},re=[];for(let e=Math.ceil(Bm(u)/10)*10;e<=Bm(d);e+=10)re.push(e);let ie=[.1,.5,.9].map(e=>({p:e,x:Math.log(e/(1-e))/n.gender.logit_per_dose})),k={x:[g.x+r.safe[0],g.x+r.safe[1]],y:[g.y+i.safe[0],g.y+i.safe[1]]},ae=Math.round(Bm(b)),A=Hm(y);return G(`div`,{class:`who${e?` is-large`:``}`,style:{"--fam":s},children:[G(`div`,{class:`who-main`,children:[G(`svg`,{ref:t,class:`who-map${T?` is-outside`:``}`,viewBox:`0 0 ${Fv} ${Iv}`,role:`slider`,tabIndex:0,"aria-label":`Who map: masculine to feminine (x), age in years (y). Arrow keys move; scroll while focused (or with ⌘ / Ctrl) changes pitch.`,"aria-valuetext":`${r.label} ${_.toFixed(1)}, ${i.label} ${v.toFixed(1)} (about ${ae} years)`,onKeyDown:ne,onPointerDown:e=>{e.target.closest(`.landmark`)||(U.begin(),kg(e,te,()=>U.end(),t.current))},children:[G(`rect`,{class:`who-bg`,x:Lv,y:Rv,width:366,height:382,rx:`12`}),re.map(e=>G(`g`,{class:`tick`,children:[G(`line`,{class:`grid`,x1:Lv,x2:408,y1:p(Vm(e)),y2:p(Vm(e))}),G(`text`,{x:36,y:p(Vm(e))+4,"text-anchor":`end`,children:e})]})),ie.map(e=>G(`g`,{class:`tick`,children:G(`line`,{class:e.p===.5?`axis`:`grid`,x1:f(e.x),x2:f(e.x),y1:Rv,y2:394})})),G(`text`,{class:`pole`,x:48,y:412,children:[`← `,r.poles?.[0]??`masculine`]}),G(`text`,{class:`pole`,x:f(0),y:412,"text-anchor":`middle`,children:`neutral`}),G(`text`,{class:`pole`,x:402,y:412,"text-anchor":`end`,children:[r.poles?.[1]??`feminine`,` →`]}),G(`text`,{class:`pole axis-title`,x:9,y:14,transform:`rotate(-90 9 14)`,"text-anchor":`end`,children:`age (years)`}),G(`rect`,{class:`who-safe`,x:f(m(k.x[0])),y:p(h(k.y[1])),width:f(m(k.x[1]))-f(m(k.x[0])),height:p(h(k.y[0]))-p(h(k.y[1])),rx:`10`}),C&&G(`path`,{class:`identity-ring`,d:`M${C.map(([e,t])=>`${f(m(g.x+e)).toFixed(1)},${p(h(g.y+t)).toFixed(1)}`).join(`L`)}Z`}),E.map(({s:e,spot:t})=>{let n=ee.get(e.id),r=()=>Xc(e.id,`map`);return G(`g`,{class:`landmark${n?``:` is-quiet`}`,transform:`translate(${f(m(t.x))},${p(h(t.y))})`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r())},role:`button`,tabIndex:0,"aria-label":`Switch base voice to ${e.label}`,children:[G(`title`,{children:`${e.label}${t.measured?``:` (saved from `+t.from+`)`} — click to make it the base voice`}),G(`circle`,{class:`landmark-hit`,r:`14`}),G(`circle`,{r:`5`}),G(`text`,{x:n?.dx??9,y:n?.dy??4,"text-anchor":n?.anchor??`start`,children:e.label})]})}),G(`line`,{class:`who-tether`,x1:f(m(g.x)),y1:p(h(g.y)),x2:f(m(y)),y2:p(h(b))}),G(`g`,{class:`origin${g.measured?``:` is-unmeasured`}`,transform:`translate(${f(m(g.x))},${p(h(g.y))})`,children:[G(`circle`,{r:`7`}),G(`text`,{y:`-12`,children:D})]}),G(`g`,{class:`who-dot${x?` is-off`:``}`,transform:`translate(${f(m(y))},${p(h(b))})`,children:[G(`circle`,{class:`halo`,r:`16`}),G(`circle`,{r:`9`})]})]}),a&&G(`div`,{class:`who-rail`,children:[G(lv,{control:a,value:o.values[a.id]??0,color:s,vertical:!0,bare:!0,onStart:()=>U.begin(),onChange:e=>Kc(a.id,e),onEnd:()=>U.end()}),G(`span`,{class:`rail-label`,title:a.effect,children:[a.label,G(`br`,{}),G(`b`,{children:(o.values[a.id]??0).toFixed(1)})]})]})]}),G(`div`,{class:`who-status${T?` is-outside`:``}`,"aria-live":`polite`,title:`Identity estimate ${Vc.value.toFixed(2)} · P(female) ${A.toFixed(2)}${n.note?` · ${n.note}`:``}`,children:[T?G(`b`,{children:`New person`}):w===`Close`?G(`b`,{children:[`Close to `,D]}):G(`span`,{children:[`Still `,D]}),G(`span`,{children:[`≈`,ae,` years · `,Zt(A)]}),(g.from||!g.measured)&&G(`span`,{class:`muted`,children:g.from?`placed from ${g.from} + its saved moves`:`position not measured: starts at the centre`})]}),R.value.ui.controls.filter(e=>e.group===`who`&&![r.id,i.id,`pitch`].includes(e.id)).map(e=>G(lv,{control:e,value:o.values[e.id]??0,color:s,compact:!0,onStart:()=>U.begin(),onChange:t=>Kc(e.id,t),onEnd:()=>U.end()},e.id))]})}var Gv=e=>`${e>0?`+`:e<0?`−`:``}${Math.abs(e).toFixed(1)}`,Kv=e=>Math.abs(e??0)>1e-6;function qv(){let e=Fm.value,t=W.value,n=va.value.get(e.gender.control),r=va.value.get(e.age.control),i=Hc.value?.label??`Pick a voice`,a=zm(Hc.value),o=a.x+(n?t.values[n.id]??0:0),s=a.y+(r?t.values[r.id]??0:0),c=t.values.pitch??0,l=Xt(Vc.value,R.value.ui.identity_threshold??.8),u=l===`New person`;return G(`div`,{class:`tile-sum`,title:`Identity estimate ${Vc.value.toFixed(2)}${n&&r?` · P(female) ${Hm(o).toFixed(2)}`:``}`,children:[G(`b`,{class:`tile-main`,children:i}),n&&r&&G(j,{children:[G(`span`,{children:[`≈`,Math.round(Bm(s)),` years`]}),G(`span`,{children:Zt(Hm(o))})]}),G(`span`,{class:u?`tile-warn`:`muted`,children:u?l:Kv(c)?`pitch ${Gv(c)}`:l})]})}function Jv(){let e=R.value.ui.accents,t=Object.entries(zc.value).map(([t,n])=>({a:e.find(e=>e.id===t),v:n})).filter(e=>e.a&&e.v>0).sort((e,t)=>t.v-e.v),n=t[0];if(!n)return G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:`No accent`}),G(`span`,{class:`muted`,children:`pin at home`})]});let r=Bt(n.a,n.v)!==`safe`;return G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:n.a.label}),G(`span`,{class:r?`tile-warn`:void 0,children:[n.v.toFixed(2),r?` · strong`:``]}),t.length>1&&G(`span`,{class:`muted`,children:[`+ `,t.slice(1).map(e=>e.a.label).join(`, `)]})]})}function Yv(){let e=R.value.ui.controls.find(e=>e.group===`room`);if(!e)return G(`span`,{class:`muted`,children:`No room control`});let t=W.value.values[e.id]??0,[n,r]=e.range,i=Qt(e),a=i.reduce((e,n)=>Math.abs(n.at-t)t.group===`delivery`&&!t.span_only&&Kv(e[t.id]));return t.length?G(`div`,{class:`tile-sum`,children:[t.slice(0,3).map(t=>G(`span`,{class:`tile-kv`,children:[G(`span`,{children:t.label}),G(`b`,{children:Gv(e[t.id]??0)})]},t.id)),t.length>3&&G(`span`,{class:`muted`,children:[`+`,t.length-3,` more`]})]}):G(`div`,{class:`tile-sum`,children:[G(`b`,{class:`tile-main`,children:`Neutral`}),G(`span`,{class:`muted`,children:`no delivery moves`})]})}function Zv(){let e=W.value.values,t=dv.value,n=fv.value.filter(t=>(e[t.control.id]??0)>0),r=t=>((e[t.id]??0)-t.range[0])/(t.range[1]-t.range[0]);return G(`div`,{class:`tile-mood`,children:[t&&G(`span`,{class:`tile-pad`,"aria-hidden":`true`,children:G(`i`,{style:{left:`${r(t.x)*100}%`,top:`${(1-r(t.y))*100}%`}})}),G(`div`,{class:`tile-sum`,children:[n.length?n.slice(0,3).map(e=>G(`span`,{children:e.label},e.control.id)):t&&(Kv(e[t.x.id])||Kv(e[t.y.id]))?G(j,{children:[G(`span`,{children:[t.x.label,` `,Gv(e[t.x.id]??0)]}),G(`span`,{children:[t.y.label,` `,Gv(e[t.y.id]??0)]})]}):G(`b`,{class:`tile-main`,children:`Neutral`}),n.length>3&&G(`span`,{class:`muted`,children:[`+`,n.length-3,` more`]})]})]})}var Qv=()=>({values:W.value.values,begin:()=>U.begin(),set:Kc,end:()=>U.end()});function $v(){let e=Vc.value,t=R.value.ui.identity_threshold??.8;if(W.value.mode===`reference`)return G(`div`,{class:`identity-meter`,title:`Keep as is sends the recording itself: the identity is the recording's`,children:[G(`span`,{class:`eyebrow`,children:`identity`}),G(`span`,{class:`identity-caption`,children:`Same person (the recording)`})]});let n=Xt(e,t);return G(`div`,{class:`identity-meter${n===`New person`?` is-new`:``}`,title:`Identity estimate ${e.toFixed(2)} · below ${t.toFixed(2)} reads as a different person. Product of each control’s measured identity curve: an estimate, not a measurement.`,children:[G(`span`,{class:`eyebrow`,children:`identity`}),G(`div`,{class:`meter`,children:[G(`div`,{class:`meter-fill`,style:{width:`${e*100}%`}}),G(`div`,{class:`meter-mark`,style:{left:`${t*100}%`}})]}),G(`span`,{class:`identity-caption`,children:G(`b`,{children:n})})]})}function ey(e){if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=[...e.currentTarget.querySelectorAll(`[role="radio"]:not([disabled])`)],n=t.indexOf(document.activeElement);if(n<0||t.length<2)return;e.preventDefault();let r=t[(n+(e.key===`ArrowRight`?1:t.length-1))%t.length];r.focus(),r.click()}function ty(){return bg.value?G(`button`,{class:`icon-btn`,"aria-label":`Save this voice`,title:`Save this voice`,onClick:()=>{Tg(`cast-monitor`),requestAnimationFrame(()=>{let e=document.getElementById(`rail-cast-monitor`);e&&Sf(e,`.save-panel`)})},children:G(K,{name:`save`,size:16})}):null}function ny(){let e=W.value.mode===`reference`;return G(`div`,{class:`bench-head`,id:`bench-head`,children:[G(`div`,{class:`bench-title`,children:[G(`span`,{class:`eyebrow`,children:`Shape the voice`}),G(`h2`,{title:Hc.value?.label,children:Hc.value?.label??`Pick a voice`})]}),G(`div`,{class:`mode-wrap`,children:[G(`div`,{class:`mode`,role:`radiogroup`,"aria-label":`Voice mode`,onKeyDown:ey,children:[G(`button`,{role:`radio`,"aria-checked":!e,class:`mode-btn${e?``:` is-on`}`,onClick:()=>Qc(`embedding`),title:`Shape it: who, accent and texture change the person`,children:`Shape it`}),G(`button`,{role:`radio`,"aria-checked":e,class:`mode-btn${e?` is-on`:``}`,disabled:!Gc.value,onClick:()=>Qc(`reference`),title:Gc.value?`Keep as is: the recording itself; only delivery and mood change`:`This voice was saved without a recording, so there is nothing to keep as is`,children:`Keep as is`})]}),!Gc.value&&G(`span`,{class:`hint`,children:`Keep as is needs a recording; this voice was saved without one.`})]}),G($v,{}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn`,onClick:el,title:`A random new person: base voice, who, a touch of texture or room (delivery and mood stay as they are)`,children:[G(K,{name:`dice`,size:14}),` Roll a voice`]}),G(`button`,{class:`icon-btn`,onClick:tl,title:e?`Reset delivery and mood (Who, Accent, Texture and Room are kept for Shape it)`:`Reset: back to the plain base voice`,"aria-label":`Reset the controls`,children:G(K,{name:`refresh`,size:16})}),G(ty,{})]})]})}var ry={who:`Who`,accent:`Accent`,texture:`Texture`,room:`Room`,delivery:`Delivery`,mood:`Mood`},iy=[`who`,`accent`,`texture`,`room`],ay=G(j,{children:[G(`b`,{children:`Keep as is copies the recording.`}),G(`span`,{children:`Delivery and mood still work; Who, Accent, Texture and Room don’t. Switch to Shape it to change them; your moves here are kept.`}),G(`button`,{class:`btn sm`,onClick:()=>Qc(`embedding`),children:`Switch to Shape it`})]}),oy=G(`button`,{class:`link`,onClick:()=>document.getElementById(`bench-head`)?.scrollIntoView({block:`center`,behavior:`smooth`}),children:[G(`b`,{children:`Keep as is`}),` · change`]});function sy(){let e=!!Dl.value.a||jc.value.length>0,t=P(e);return N(()=>{e&&!t.current&&Tg(`cast-monitor`),t.current=e},[e]),e}function cy(){let e=sy();N(()=>(wa.value=U,Oa.value=Yl,()=>{wa.value=null,Oa.value=null}),[]);let t=Qv(),n=bg.value,r=W.value.mode===`reference`?ay:void 0,[i,a]=M(null),o=e=>(t,n)=>a({id:e,card:t,returnTo:n});N(()=>{i&&r&&iy.includes(i.id)&&a(null)},[!!r]);let s=(e,t,n=!0)=>{let i=n&&r?oy:void 0;return G(vg,{family:e,title:ry[e],class:`cast-tile`,locked:i,onExpand:i?void 0:o(e),whole:!0,children:t})};return G(`div`,{class:`cast`,children:[G(Eg,{id:`cast-library`,side:`left`,title:`Voices`,children:G(av,{})}),G(`section`,{class:`bench`,"aria-label":`Voice bench`,children:[G(Og,{children:[G(Dg,{id:`cast-library`,title:`Voices`,icon:`mic`}),G(Dg,{id:`cast-monitor`,title:`More`,icon:`sliders`})]}),G(V_,{}),n?G(j,{children:[G(ny,{}),G(`div`,{class:`cast-tiles`,children:[s(`who`,G(qv,{})),s(`accent`,G(Jv,{})),s(`texture`,G(Pv,{})),s(`room`,G(Yv,{})),s(`delivery`,G(Xv,{}),!1),s(`mood`,G(Zv,{}),!1)]})]}):G(j,{children:[G(ny,{}),G(`div`,{class:`hero`,children:[G(vg,{family:`who`,title:`Who`,locked:r,onExpand:r?void 0:o(`who`),aside:G(`span`,{class:`hint`,title:`Drag the dot to move gender / age; scroll while the map has focus (or with ⌘ / Ctrl) for pitch; click a voice to start from it`,children:`drag the dot · scroll for pitch`}),children:G(Wv,{})}),G(vg,{family:`accent`,title:`Accent`,locked:r,onExpand:r?void 0:o(`accent`),aside:G(`span`,{class:`hint`,children:`drag into a region · deeper = stronger`}),children:G(jg,{})})]}),G(`div`,{class:`strip`,children:[G(vg,{family:`texture`,title:`Texture`,locked:r,onExpand:r?void 0:o(`texture`),whole:!0,children:G(Pv,{})}),G(vg,{family:`room`,title:`Room`,locked:r,onExpand:r?void 0:o(`room`),children:G(Ov,{b:t})}),G(vg,{family:`delivery`,title:`Delivery`,onExpand:o(`delivery`),children:G(kv,{group:`delivery`,b:t,compact:!0})}),G(vg,{family:`mood`,title:`Mood`,onExpand:o(`mood`),children:G(Av,{b:t,compact:!0,padOpens:!0})})]})]})]}),G(Eg,{id:`cast-monitor`,side:`right`,title:`More`,defaultFolded:!e,children:G(`aside`,{class:`monitor`,"aria-label":`Monitor`,children:G(`div`,{class:`monitor-scroll`,children:[G(U_,{}),G(J_,{}),G(X_,{})]})})}),i&&G(gg,{family:i.id,title:ry[i.id],origin:i.card,returnFocus:i.returnTo,onClose:()=>a(null),aside:G($v,{}),strip:G(L_,{}),children:i.id===`who`?G(Wv,{large:!0}):i.id===`accent`?G(jg,{large:!0}):i.id===`texture`?G(Pv,{large:!0}):i.id===`room`?G(Ov,{b:t,large:!0}):i.id===`delivery`?G(kv,{group:`delivery`,b:t,detailed:!0}):G(Av,{b:t,large:!0})},i.id)]})}var ly=/^(checkbox|radio|range|button|submit|reset|file|color)$/i;function uy(e){let t=e;return!t||typeof t.tagName!=`string`?!1:t.isContentEditable||t.tagName===`TEXTAREA`||t.tagName===`SELECT`?!0:t.tagName===`INPUT`&&!ly.test(t.type)}var dy=`script`,fy=[`chatty`,`arousal`,`pace`],py={chatty:`Read ↔ chatty`,arousal:`Energy`,pace:`Pace`},my=[`var(--c1)`,`var(--c2)`,`var(--c6)`,`var(--c3)`,`var(--c5)`,`var(--c4)`];function hy(e){if(!e)return`var(--text-3)`;let t=q.value.voiceColors?.[e];if(t)return t;let n=new Set(Object.values(q.value.voiceColors??{}));return my.find(e=>!n.has(e))??my[Object.keys(q.value.voiceColors??{}).length%my.length]}Ji(()=>{let e=q.value,t=new Set;e.voice&&t.add(e.voice);for(let n of e.lines)n.voice&&t.add(n.voice);for(let n of t)e.voiceColors?.[n]||Vd(n,hy(n))});var gy=e=>e?jc.value.find(t=>t.id===e)?.name??`(removed voice)`:H.value.find(e=>e.id===W.value.baseId)?.label??`Voice`,_y=I(null);function vy(){let e=yf();if(!e)return z(`Render some lines first: each line’s keeper plays in order.`);let t=cf.value.filter(e=>!e.take).length;t&&z(`${t} line${t===1?``:`s`} without a take ${t===1?`is`:`are`} skipped`),Rs(dy,e.pcm,e.sr)}function yy(){let e=yf();if(!e)return z(`Nothing rendered yet.`);un(e.pcm,e.sr,p(Z.value?.name??`script`));let t=cf.value.filter(e=>!e.take).length;t&&z(`Exported ${cf.value.length-t} lines; ${t} without a take were skipped.`)}function by(e){let t=q.value.gap,n=0;for(let r of vf.value.clips)if(r.take){if(r.line.id===e)return n;n+=r.duration+t}return null}function xy(){if(B.value?.id!==dy)return null;let e=ws.value,t=q.value.gap,n=0;for(let r of vf.value.clips)if(r.take){if(e{let e=xy()?.lineId??null;wd.peek()!==e&&(wd.value=e)});function Sy(){let e={id:Mt(),name:gy(null),design:structuredClone(W.value),signature:``,createdAt:Date.now()};Mc(e),z(`Added ${e.name} to the cast`,`ok`)}function Cy(e){let t=new Set;for(let[n,r]of Object.entries(e)){let e=va.value.get(n);e&&r&&t.add(e.group)}if(t.size)return[...t].map((e,t)=>`linear-gradient(${ba(e)}, ${ba(e)}) 0 calc(100% - ${t*4}px) / 100% 2px no-repeat`).join(`, `)}function wy(e,t,n){let r=e=>/[\p{L}\p{N}'’]/u.test(e),i=t,a=n;for(;i>0&&r(e[i-1])&&r(e[i]??``);)i--;for(;a{let r=(t.nodeType===Node.TEXT_NODE?t.parentElement:t)?.closest(`[data-start]`);return r?r.dataset.end?Number(n?r.dataset.end:r.dataset.start):Number(r.dataset.start)+(t.nodeType===Node.TEXT_NODE?n:0):t===e&&n?2**53-1:0},i=r(n.startContainer,n.startOffset),a=r(n.endContainer,n.endOffset);return{start:Math.min(i,a),end:Math.max(i,a),rect:n.getBoundingClientRect()}}function Dy({line:e}){let t=P(null),n=new Set([0,e.text.length]);for(let t of e.spans)n.add(t.start),n.add(t.end);let r=ga.value?vn(e.text,ga.value).groups.filter(e=>!e.empty):[];for(let e of r)n.add(e.start),n.add(e.end);let i=__.value?kn(e.text):null;for(let e of i?.tokens??[])n.add(e.start),n.add(e.end);let a=(t,n,r)=>Ad(e.id,e.text.slice(0,t)+r+e.text.slice(n)),o=[...n].sort((e,t)=>e-t),s=_y.value?.lineId===e.id?_y.value:null,c=(t,n)=>{let[r,i]=wy(e.text,t,Math.min(n,e.text.length));_y.value={lineId:e.id,start:r,end:i}},l=e=>{let n=Ey(t.current);n&&n.end>n.start?c(n.start,n.end):e||(_y.value=null)};N(()=>{if(!s)return;let n=()=>{let n=Ey(t.current);if(n&&n.end>n.start&&(n.start!==s.start||n.end!==s.end)){let[t,r]=wy(e.text,n.start,Math.min(n.end,e.text.length));(t!==s.start||r!==s.end)&&(_y.value={...s,start:t,end:r})}};return document.addEventListener(`selectionchange`,n),()=>document.removeEventListener(`selectionchange`,n)},[s?.lineId,s?.start,s?.end,e.text]);let[u,d]=M(null);N(()=>d(null),[e.text]);let f=Ty(e.text),p=e=>{d(e);let n=t.current,r=window.getSelection();if(!n||!r)return;if(!e)return r.removeAllRanges();let i=[...n.querySelectorAll(`.seg[data-start]`)].filter(e=>!e.dataset.end),a=e=>{for(let t of i){let n=Number(t.dataset.start),r=t.firstChild;if(!r||r.nodeType!==Node.TEXT_NODE)continue;let i=r.textContent?.length??0;if(e>=n&&e<=n+i)return{node:r,offset:e-n}}return null},o=a(e[0]),s=a(e[1]);if(!o||!s)return;let c=document.createRange();c.setStart(o.node,o.offset),c.setEnd(s.node,s.offset),r.removeAllRanges(),r.addRange(c)};return G(`div`,{ref:t,class:`line-text`,"data-line":e.id,tabIndex:0,"aria-label":`Line text: ${e.text}. Shift with the arrow keys selects words; Enter paints them.`,onMouseUp:()=>l(),onTouchEnd:()=>setTimeout(()=>l(!0),50),onKeyDown:e=>{if(e.target!==t.current||!f.length)return;if(e.key===`Escape`&&u){e.preventDefault(),p(null);return}if(e.key===`Enter`&&u){e.preventDefault(),c(u[0],u[1]);return}if(!e.shiftKey||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let n=f.findIndex(e=>u&&e[0]>=u[0]),r=u?f.findLastIndex(e=>e[1]<=u[1]):-1,i=u?n:e.key===`ArrowRight`?0:f.length-1,a=u?r:i;u&&(e.key===`ArrowRight`?a=Math.min(f.length-1,a+1):i=Math.max(0,i-1)),p([f[i][0],f[a][1]])},onBlur:()=>u&&d(null),children:o.slice(0,-1).map((t,n)=>{let l=o[n+1],u=i?.tokens.find(e=>e.start===t);if(u)return u.kind===`close`?G(`span`,{"data-start":t,"data-end":l,class:`seg tag-close`,"aria-hidden":`true`}):G(`span`,{"data-start":t,"data-end":l,class:`seg tag-inline${u.kind===`open`?` is-span`:``}${En[u.name].weak?` is-weak`:``}`,title:`<${u.name}${u.kind===`point`?`/`:``}>: ${En[u.name].note}`,children:u.kind===`open`?`‹${u.name}›`:u.name});let d=i?.spans.find(e=>t>=e.open.end&&tt>=e.start&&t=s.start&&l<=s.end,m=r.find(e=>t>=e.start&&t`${va.value.get(e)?.label??e} ${t>0?`+`:``}${t}`).join(` · `):``;return G(`span`,{"data-start":t,"data-ipa":m&&l===m.end?`${m.ipa}${h?` · check`:``}`:void 0,class:`seg${d?` tag-words is-${d.name}`:``}${f?` is-painted`:``}${p?` is-picked`:``}${m?` is-pron`:``}${m?.unknown.length?` is-pron-bad`:``}${h?` is-pron-check`:``}`,style:f?{background:Cy(f.values)}:void 0,onClick:m?e=>{window.getSelection()?.isCollapsed&&(_y.value=null,f_(e.currentTarget,m,a))}:f?()=>{window.getSelection()?.isCollapsed&&c(f.start,f.end)}:void 0,title:m?`(${m.body}) → ${m.ipa}${h?` · guessed for “${h}”, check it`:``}${m.unknown.length?` · no token for ${m.unknown.join(` `)}`:``} · click to edit${g?` · ${g}`:``}`:g||void 0,children:e.text.slice(t,l)})})})}function Oy(e){_y.value={lineId:e.id,start:0,end:e.text.length}}function ky(){let e=_y.value,t=P(null),n=()=>_y.value=null;if(N(()=>{if(!e)return;let n=e=>{!t.current?.contains(e.target)&&!e.target.closest?.(`.line-text`)&&(_y.value=null)};return window.addEventListener(`pointerdown`,n),()=>window.removeEventListener(`pointerdown`,n)},[!!e]),N(()=>{if(!e)return;let n=e.lineId;return Ta.value=!0,Sf(t.current,`.brushbar-body`),bg.value&&document.querySelector(`.line-text[data-line="${n}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`}),()=>{Ta.value=!1,document.querySelector(`.line-text[data-line="${n}"]`)?.focus({preventScroll:!0})}},[e?.lineId]),!e)return null;let r=q.value.lines.find(t=>t.id===e.lineId);if(!r)return null;let i=qd(r,e.start),a=new Set;for(let t=e.start+1;tvd.begin(),set:(t,n)=>{let i=va.value.get(t);i&&Kd(r.id,e.start,e.end,t,Math.round(F(n,i.range[0],i.range[1])*100)/100)},end:()=>vd.end()},s=gl(r.text,e.start,e.end),c=R.value.ui.controls.filter(e=>e.spannable&&e.group!==`mood`&&!(s&&e.span_only)),l=R.value.ui.controls.some(e=>e.spannable&&e.group===`mood`),u=R.value.ui.groups.filter(e=>R.value.ui.controls.some(t=>t.group===e.id&&t.spannable));return G(`div`,{ref:t,class:`brushbar${bg.value?``:` is-anchored`}`,role:`dialog`,"aria-modal":`true`,"aria-label":`Delivery brushes`,onKeyDown:Cf(()=>t.current,n),children:[G(`header`,{children:[G(`span`,{class:`eyebrow`,children:[`Paint “`,r.text.slice(e.start,e.end),`”`]}),n_.value&&G(`button`,{class:`btn sm ghost`,disabled:s_.value,onClick:async()=>{let t=await c_(r.text,e.start,e.end);t!==null&&(Ad(r.id,t),_y.value=null)},title:`Look up these words in the ${g(a_.value)} lexicon and write them as X-SAMPA pronunciations (undo: ⌘Z)`,children:`/ə/ Pronounce`}),__.value&&G(`button`,{class:`btn sm ghost`,onClick:t=>{let n=t.currentTarget.getBoundingClientRect();_y.value=null,x_(n,r.text,e.start,e.end,e=>Ad(r.id,e))},title:`A nonverbal tag: at the start of the selection, or around its words`,children:`‹› Tag`}),G(`button`,{class:`btn sm ghost`,onClick:()=>(vd.begin(),Kd(r.id,e.start,e.end,null,0),vd.end()),title:`Remove every painted value from these words`,children:`Clear paint`}),G(`button`,{class:`icon-btn sm`,onClick:n,"aria-label":`Close brushes`,title:`Close (Esc)`,children:G(K,{name:`x`,size:14})})]}),G(`div`,{class:`legend brushbar-legend`,"aria-hidden":`true`,children:u.map(e=>G(`span`,{class:`legend-item`,children:[G(`i`,{style:{background:ba(e.id)}}),e.label]}))}),G(`div`,{class:`brushbar-body`,children:[G(`div`,{class:`brush-sliders`,children:c.map(e=>G(`div`,{class:a.has(e.id)?`slider-wrap is-mixed`:void 0,title:a.has(e.id)?`Mixed: these words carry different values; moving the slider sets them all`:void 0,children:G(lv,{control:e,value:i[e.id]??0,color:ba(e.group),label:a.has(e.id)?`${e.label} · mixed`:void 0,onStart:o.begin,onChange:t=>o.set(e.id,t),onEnd:o.end})},e.id))}),l&&G(Av,{b:o,compact:!0})]})]})}var Ay=new Set;function jy({line:e}){let t=J.value[e.id]??[],n=t.filter(e=>!Ay.has(e.id)&&Date.now()-e.createdAt<3e3).map(e=>e.id);N(()=>{let e=t[t.length-1],r=e&&!Ay.has(e.id)&&n.includes(e.id);for(let e of t)Ay.add(e.id);r&&Sl.value&&!$d.peek()&&!B.peek()&&Rs(`take:${e.id}`,e.audio.pcm,e.audio.sr)},[t.length]);let r=B.value?.id===`cmp:${e.id}`?Py(e.id):null;return t.length?G(`ul`,{class:`takes`,"aria-label":`Takes`,children:[t.map((t,i)=>{let a=`take:${t.id}`,o=B.value?.id===a||r===t.id,s=ff(e,t);return G(`li`,{class:`take${t.starred?` is-starred`:``}${s?` is-stale`:``}${n.includes(t.id)?` is-flash`:``}${o?` is-playing`:``}`,children:[G(`button`,{class:`take-play`,onClick:()=>Bs(a,t.audio.pcm,t.audio.sr),"aria-label":`${o?`Stop`:`Play`} take ${i+1}`,title:[s?`Rendered before the ${s.replace(` changed`,``)} changed`:`Seed ${t.seed}`,t.audio.spanFollow?Fy[t.audio.spanFollow]:null].filter(Boolean).join(` · `),children:[G(`span`,{class:`take-n`,children:i+1}),G($g,{pcm:t.audio.pcm,color:t.starred?`var(--o)`:`var(--text-2)`,playId:a,height:22})]}),s&&G(`span`,{class:`chip take-stale`,title:`The line changed since this take was rendered; Regenerate makes a fresh one`,children:s}),k_(t.request)&&G(`span`,{class:`take-follow is-tags`,title:`${k_(t.request)}: the server takes one guidance per render`,"aria-label":k_(t.request),children:`tags`}),G(`button`,{class:`icon-btn sm star${t.starred?` is-on`:``}`,onClick:()=>rf(e.id,t.id),"aria-label":`Make take ${i+1} the keeper`,"aria-pressed":t.starred,title:`Script plays this one`,children:G(K,{name:`star`,size:13,filled:t.starred})}),Yf.value&&G(`button`,{class:`icon-btn sm`,onClick:()=>void pp({kind:`take`,label:`Line ${q.value.lines.indexOf(e)+1} · take ${i+1}`,lineId:e.id,takeId:t.id},t.audio.pcm,t.audio.sr,t.text),"aria-label":`Edit the words of take ${i+1}`,title:`Edit the words of this take (Edit screen)`,children:G(K,{name:`edit-speech`,size:12})}),G(`button`,{class:`icon-btn sm`,onClick:()=>{let n=af(e.id,t.id);n&&z(`Take ${i+1} deleted`,`info`,{label:`Undo`,run:()=>of(e.id,n.take,n.index,n.wasStarred)})},"aria-label":`Delete take ${i+1}`,title:`Delete this take`,children:G(K,{name:`x`,size:12})})]})}),t.length>1&&G(Iy,{lineId:e.id})]}):null}var My=.6;function Ny(e){let t=J.value[e]??[],n=t.find(e=>e.starred)??t[0],r=[...t].reverse().find(e=>e!==n);return n&&r?[n,r]:null}function Py(e){let t=Ny(e);if(!t)return null;let[n,r]=t;return ws.value{if(i)return Is();let{pcm:e,sr:t}=ln([a.audio,o.audio],My);Rs(r,e,t)},title:`Play take ${t.indexOf(a)+1} (keeper) then take ${t.indexOf(o)+1}`,children:[G(K,{name:i?`stop`:`play`,size:12}),` Keeper vs take `,t.indexOf(o)+1]})})}function Ly(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}function Ry({line:e,n:t,count:n}){let r=wd.value===e.id,i=P(null),[a,o]=M(Uy.peek()===e.id),[s,c]=M(e.text),[l,u]=M(!1),d=yd.value[e.id],f=bd.value[e.id],p=J.value[e.id]??[],m=p.find(e=>e.starred)??p[p.length-1],h=m?ff(e,m):null,g=!!h,_=Ed(e);N(()=>{a&&i.current&&(Ly(i.current),i.current.focus(),i.current.setSelectionRange(i.current.value.length,i.current.value.length))},[a]);let v=()=>{c(e.text),u(!1),o(!0)},y=(t,n=!1)=>{let r=Uy.peek()===e.id;if(r&&(Uy.value=null),n)r&&!e.text.trim()&&Fd(e.id),o(!1);else if(t.trim())t!==e.text&&Ad(e.id,t),o(!1);else{if(r||!e.text.trim())return Fd(e.id);u(!0)}};return G(`li`,{class:`line${r?` is-playing`:``}`,style:{"--voice":hy(_)},children:[G(`span`,{class:`line-n`,children:t}),G(`div`,{class:`line-main`,children:[a?G(j,{children:[G(`div`,{class:`line-edit-row`,children:[G(`textarea`,{ref:i,class:`input line-edit`,rows:1,value:s,"data-tags":!0,placeholder:`What do they say?`,"aria-label":`Line ${t} text`,"aria-invalid":l||void 0,onInput:e=>{let t=e.currentTarget;c(t.value),t.value.trim()&&u(!1),Ly(t)},onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)?(e.preventDefault(),y(e.currentTarget.value)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y(``,!0))},onBlur:t=>{if(t.relatedTarget?.closest?.(`.tag-palette, .pron-editor`))return;let n=t.currentTarget.value;if(!n.trim()&&e.text.trim()&&Uy.peek()!==e.id)return y(``,!0);y(n)}}),G(u_,{input:()=>i.current}),G(w_,{input:()=>i.current})]}),G(`p`,{class:`hint line-edit-hint${l?` is-bad`:``}`,children:l?`Text can’t be empty — Esc to cancel or delete the line`:`Enter saves · Esc cancels`}),G(h_,{text:s}),G(E_,{text:s})]}):G(`div`,{onDblClick:v,children:[G(Dy,{line:e}),G(h_,{text:e.text,issuesOnly:!0}),G(E_,{text:e.text,replace:t=>Ad(e.id,t)})]}),G(jy,{line:e}),_y.value?.lineId===e.id&&!bg.value&&G(ky,{}),f&&G(`div`,{class:`error-line`,role:`alert`,children:e_(f)?`Not rendered: fix the pronunciation marked above.`:G(j,{children:[`Render failed: `,f,` `,G(`button`,{class:`link`,onClick:()=>void Qd(e.id),children:`Retry`})]})})]}),G(`div`,{class:`line-actions`,children:[G(`select`,{class:`input line-voice`,value:e.voice??``,onChange:t=>zd(e.id,t.currentTarget.value||null),"aria-label":`Voice for line ${t}`,title:`Speaks as ${gy(_)}`,children:[G(`option`,{value:``,children:[`Default · `,gy(q.value.voice)]}),e.voice&&!jc.value.some(t=>t.id===e.voice)&&G(`option`,{value:e.voice,children:`(voice unavailable)`}),jc.value.map(e=>G(`option`,{value:e.id,children:e.name}))]}),G(`button`,{class:`btn sm${d?` is-busy`:``}${g?` is-stale`:``}`,onClick:()=>d?Zd(e.id):void Qd(e.id),disabled:!d&&!e.text.trim(),title:d?`Stop rendering this line`:g?`The ${h.replace(` changed`,``)} changed since this take: render a fresh one`:p.length?`Render another take (new seed)`:`Render this line`,children:d?`Cancel`:g?G(j,{children:[G(K,{name:`refresh`,size:13}),` Regenerate`]}):p.length?`New take`:`Render`}),G(`div`,{class:`line-tools`,children:[G(`button`,{class:`icon-btn sm`,onClick:v,"aria-label":`Edit line ${t}`,title:`Edit text (paint stays on its words) · double-click the line`,children:G(K,{name:`edit`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:!e.text.trim(),onClick:()=>Oy(e),"aria-label":`Paint delivery onto line ${t}`,title:`Paint delivery onto this line (or select words in it)`,children:G(K,{name:`brush`,size:13})}),G(`button`,{class:`icon-btn sm`,onClick:()=>Uy.value=Pd(e.id,``,e.voice),"aria-label":`Add a line below line ${t}`,title:`Add a line below`,children:G(K,{name:`plus`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:t===1,onClick:()=>Ld(e.id,-1),"aria-label":`Move line ${t} up`,title:`Move up`,children:G(K,{name:`up`,size:13})}),G(`button`,{class:`icon-btn sm`,disabled:t===n,onClick:()=>Ld(e.id,1),"aria-label":`Move line ${t} down`,title:`Move down`,children:G(K,{name:`down`,size:13})}),G(`button`,{class:`icon-btn sm`,onClick:()=>{let n=Fd(e.id);n&&z(`Line ${t} deleted`,`info`,{label:`Undo`,run:()=>Id(n.line,n.index,n.takes)})},"aria-label":`Delete line ${t}`,title:`Delete line`,children:G(K,{name:`trash`,size:13})})]})]})]})}var zy=()=>q.value.lines.map(e=>e.text).join(` -`);async function By(){(!Cd.value||await Tf(`Discard your script text changes?`,{ok:`Discard`,danger:!0}))&&(Sd.value=null,Hy.value=!1)}function Vy(){let e=q.value.lines.length===0,t=Sd.value??zy(),n=async()=>{let n=pd(t,{sentences:e}),{dropped:r}=md(q.value.lines,n),i=r.reduce((e,t)=>e+(J.value[t.id]?.length??0),0);r.length&&i&&!await Tf(`${r.length} line${r.length===1?``:`s`} will be removed with ${i} take${i===1?``:`s`}. Apply anyway?`,{ok:`Apply`,danger:!0})||(jd(n),Sd.value=null,Hy.value=!1)};return G(`div`,{class:`script-text`,children:[G(`textarea`,{class:`input`,rows:10,value:t,"data-tags":!0,onInput:e=>{let t=e.currentTarget.value;Sd.value=t===zy()?null:t},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n())},"aria-label":`Script text`,placeholder:e?`Paste or type the script`:void 0}),G(`p`,{class:`hint`,children:[e?`The script is split at line breaks and sentence ends.`:`One line per row. Rows you leave unchanged keep their paint, voice and takes.`,` ⌘↵ applies.`]}),G(`button`,{class:`btn primary`,onClick:()=>void n(),children:`Apply script`})]})}var Hy=I(Sd.peek()!==null),Uy=I(null);function Wy(){let e=q.value,t=Td.value,n=H.value.find(e=>e.id===t.baseId),r={values:e.baseline,begin:()=>vd.begin(),set:(e,t)=>{let n=va.value.get(e);n&&Hd(e,F(t,n.range[0],n.range[1]))},end:()=>vd.end()},i=jc.value;return G(`aside`,{class:`rail direct-rail`,"aria-label":`Voices and performance`,children:[G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Default voice`}),G(`select`,{class:`input`,value:e.voice??``,onChange:e=>Rd(e.currentTarget.value||null),"aria-label":`Default voice for this script`,children:[G(`option`,{value:``,children:[H.value.find(e=>e.id===W.value.baseId)?.label??`—`,` (from Cast)`]}),i.map(e=>G(`option`,{value:e.id,children:e.name}))]}),G(`p`,{class:`hint`,children:[n?.label??`No voice`,` · `,t.mode===`reference`?`kept as is`:`shaped`,`. Lines use the default voice unless they pick their own. Change a voice’s identity in Cast; here only delivery and mood paint onto words.`]}),G(`div`,{class:`voice-adds`,children:[i.map(t=>G(`button`,{class:`btn ghost sm`,style:{"--voice":hy(t.id)},onClick:()=>Uy.value=Pd(e.lines[e.lines.length-1]?.id??null,``,t.id),title:`Add a line spoken by ${t.name}`,children:[G(`span`,{class:`voice-dot`}),` `,t.name,` says…`]})),!i.length&&G(j,{children:[G(`button`,{class:`btn ghost sm`,style:{"--voice":hy(null)},disabled:!W.value.baseId,onClick:()=>Uy.value=Pd(e.lines[e.lines.length-1]?.id??null,``),title:W.value.baseId?`Add a line spoken by the default voice`:`Pick a voice in Cast first`,children:[G(`span`,{class:`voice-dot`}),` `,gy(null),` says…`]}),G(`button`,{class:`btn sm voice-bench`,onClick:Sy,disabled:!W.value.baseId,title:W.value.baseId?`Save the Cast voice as a cast member, so lines can pick it`:`Pick a voice in Cast first`,children:[G(K,{name:`plus`,size:13}),` Add this voice to the cast`]}),!W.value.baseId&&G(`p`,{class:`hint`,children:`Pick a voice in Cast first.`})]})]}),G(`p`,{class:`hint`,children:[`Language `,g(ha.value.language),` · tag strength `,ua.value?.tags?ha.value.tagStrength>1?ha.value.tagStrength.toFixed(1):`off`:`n/a`,` —`,` `,G(`button`,{class:`link`,onClick:()=>Ea.value=!0,children:`Project settings`})]})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Baseline performance`}),fy.map(e=>va.value.get(e)).filter(e=>!!e).map(t=>G(lv,{control:t,value:e.baseline[t.id]??0,color:ba(t.group),label:py[t.id],onStart:r.begin,onChange:e=>r.set(t.id,e),onEnd:r.end},t.id))]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Pronunciation`}),G(g_,{})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Brushes`}),G(`p`,{class:`hint`,children:`Select words in a line to paint delivery onto them (or use the brush in the line’s tools for the whole line). Click painted words to change or clear them. Underlines show what is painted:`}),G(`div`,{class:`legend`,children:R.value.ui.groups.filter(e=>R.value.ui.controls.some(t=>t.group===e.id&&t.spannable)).map(e=>G(`span`,{class:`legend-item`,children:[G(`i`,{style:{background:ba(e.id)}}),e.label]}))})]})]})}function Gy(){let e=xd.value[0],t=e&&document.querySelector(`.line-text[data-line="${e}"]`)?.closest(`.line`);t&&(t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`is-flash`),setTimeout(()=>t.classList.remove(`is-flash`),1200))}function Ky({bar:e}){let t=q.value,n=cf.value.filter(e=>e.take).length,r=t.lines.filter(e=>e.text.trim()&&!(J.value[e.id]??[]).length),i=pf.value.length,a=xd.value.filter(e=>t.lines.some(t=>t.id===e)).length,o=$d.value,s=!!o||Object.values(yd.value).some(Boolean),c=B.value?.id===dy;return t.lines.length?G(`div`,{class:e?`transport`:`col gap-s`,children:[o?G(`div`,{class:`render-progress`,"aria-live":`polite`,children:[G(`span`,{children:[`Rendering `,o.done,`/`,o.total,o.failed?` · ${o.failed} failed`:``]}),G(`button`,{class:`btn sm`,onClick:tf,children:`Cancel`})]}):G(j,{children:[i>0&&G(`button`,{class:`btn primary`,disabled:s,onClick:()=>void _f(),title:`Settings or a voice changed since these lines’ keepers: render a new take of each`,children:[G(K,{name:`refresh`,size:14}),` Regenerate `,i,` changed`]}),r.length>0&&G(`button`,{class:`btn`,disabled:s,onClick:()=>void nf(r.map(e=>e.id)),title:`Render every line that has no take yet`,children:[G(K,{name:`wand`,size:14}),` Render `,r.length,` missing`]})]}),G(`button`,{class:`btn${i||r.length?``:` primary`}`,disabled:!n,onClick:()=>c?Is():vy(),title:n?void 0:`Render a line first`,children:[G(K,{name:c?`stop`:`play`,size:14}),` `,c?`Stop`:`Play script`]}),a>0&&!o&&G(`p`,{class:`hint is-bad transport-failed`,children:[a,` failed ·`,` `,G(`button`,{class:`link`,onClick:Gy,children:`Show`})]})]}):null}function qy(){let e=q.value,t=cf.value.filter(e=>e.take).length,n={id:`gap`,group:`timing`,label:`Gap between lines`,type:`unipolar`,map:{"+":{}},range:Bd,safe:Bd,collapse:null,spannable:!1,identity:null};return G(`aside`,{class:`rail direct-side`,"aria-label":bg.value?`Export`:`Script`,children:[!bg.value&&G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Script`}),e.lines.length>0&&G(`p`,{class:`hint`,children:[t,`/`,e.lines.length,` lines have a take. Play and export use each line’s keeper.`]}),G(Ky,{})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Export`}),G(`button`,{class:`btn`,disabled:!t,onClick:yy,title:t?`Save the script as ${p(Z.value?.name??`script`)}.wav`:`Render a line first`,children:[G(K,{name:`download`,size:14}),` Export WAV`]})]}),G(`div`,{class:`rail-section`,children:[G(`h4`,{children:`Timing`}),G(lv,{control:n,value:e.gap,color:`var(--text-2)`,compact:!0,format:e=>`${e.toFixed(2)} s`,onStart:()=>vd.begin(),onChange:e=>vd.set({...q.value,gap:Math.round(e*100)/100}),onEnd:()=>vd.end()}),G(`p`,{class:`hint`,children:`Silence between lines when the script plays or exports.`})]})]})}function Jy(){let{clips:e,total:t}=vf.value;if(!e.length)return null;let n=xy()?.t??null,r=[...new Set(e.map(e=>Ed(e.line)))],i=e=>`${e/(t||1)*100}%`;return G(`section`,{class:`timeline`,"aria-label":`Timeline`,children:[G(`div`,{class:`timeline-head`,children:[G(`span`,{class:`eyebrow`,children:`Timeline`}),G(`span`,{class:`muted small`,children:[t.toFixed(1),` s`,e.some(e=>!e.take)&&` (estimated until rendered)`]})]}),G(`div`,{class:`lanes`,children:[r.map(t=>{let r=hy(t);return G(`div`,{class:`lane`,style:{"--voice":r},children:[G(`span`,{class:`lane-name`,title:gy(t),children:gy(t)}),G(`div`,{class:`lane-track`,children:e.filter(e=>Ed(e.line)===t).map(e=>G(`button`,{class:`clip${e.take?``:` is-pending`}${!e.take&&n!==null?` is-skipped`:``}`,style:{left:i(e.start),width:i(e.duration)},title:e.take?e.line.text:`Not rendered · ${e.line.text} (click to render)`,"aria-label":`Line ${q.value.lines.indexOf(e.line)+1}: ${e.line.text}${e.take?``:` (not rendered: click to render)`}`,onClick:()=>{if(!e.take)return void Qd(e.line.id);if(B.value?.id===dy){let t=yf(),n=by(e.line.id);t&&n!==null&&Rs(dy,t.pcm,t.sr,n)}else Bs(`take:${e.take.id}`,e.take.audio.pcm,e.take.audio.sr)},children:e.take?G($g,{pcm:e.take.audio.pcm,color:r,height:28}):G(`span`,{children:[G(`i`,{class:`clip-est`,children:`Not rendered`}),` · `,e.line.text]})},e.line.id))})]},t??``)}),n!==null&&G(`div`,{class:`timeline-head-line`,style:{left:`calc(var(--lane-name) + (100% - var(--lane-name)) * ${n/(t||1)})`}})]})]})}function Yy(e){if(e.metaKey||e.ctrlKey||e.altKey||uy(e.target)||Ta.value)return!1;if(e.key===`r`||e.key===`R`){let t=e.target?.closest?.(`.line`)?.querySelector(`.line-text`)?.dataset.line;return t?(e.preventDefault(),Qd(t),!0):!1}if(e.key===`s`||e.key===`S`){let t=B.value,n=t?.id.startsWith(`take:`)?t.id.slice(5):null;if(!n)return!1;let r=Object.keys(J.value).find(e=>J.value[e].some(e=>e.id===n));return r?(e.preventDefault(),rf(r,n),z(`Keeper: the script plays this take`),!0):!1}return!1}function Xy(){N(()=>(wa.value=vd,Oa.value=vy,Da.value=Yy,Sd.peek()!==null&&(Hy.value=!0),()=>{wa.value=null,Oa.value=null,Da.value=null,_y.value=null}),[]);let e=q.value.lines,t=bg.value;return G(`div`,{class:`direct`,children:[G(Eg,{id:`direct-voices`,side:`left`,title:`Voices`,children:G(Wy,{})}),G(`section`,{class:`script`,"aria-label":`Lines`,children:[G(Og,{children:[G(Dg,{id:`direct-voices`,title:`Voices`,icon:`mic`}),G(Dg,{id:`direct-script`,title:`Export`,icon:`download`})]}),G(`header`,{class:`screen-head`,children:[G(`div`,{children:[G(`span`,{class:`eyebrow`,children:`Direct`}),G(`h2`,{children:`Script`})]}),G(`button`,{class:`btn ghost`,onClick:()=>Hy.value?void By():Hy.value=!0,children:[G(K,{name:Hy.value?`x`:`edit`,size:14}),` `,Hy.value?Cd.value?`Cancel`:`Back to lines`:`Edit as text`]})]}),Hy.value?G(Vy,{}):e.length?G(`ol`,{class:`lines`,children:e.map((t,n)=>G(Ry,{line:t,n:n+1,count:e.length},t.id))}):G(`div`,{class:`empty`,children:[G(K,{name:`edit`,size:26}),G(`h3`,{children:`No lines yet`}),G(`p`,{children:`Paste a script, or add lines one by one; each line is rendered and directed on its own, in its own voice.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>Hy.value=!0,children:[G(K,{name:`edit`,size:14}),` Paste a script`]}),G(`button`,{class:`btn`,onClick:()=>Uy.value=Pd(null,``),children:[G(K,{name:`plus`,size:14}),` Add a line`]})]})]}),!Hy.value&&e.length>0&&G(j,{children:[G(`button`,{class:`btn ghost add-line`,onClick:()=>Uy.value=Pd(null,``),children:[G(K,{name:`plus`,size:14}),` Add line`]}),G(Jy,{}),t&&G(Ky,{bar:!0})]})]}),G(Eg,{id:`direct-script`,side:`right`,title:t?`Export`:`Script`,children:G(qy,{})}),t&&G(ky,{})]})}var Zy=e=>Math.max(.5,Math.round(e*2)/2);function Qy(e,t){let n=(e,n)=>t.has(n.toLowerCase())?`${n} · ${e.label.toLowerCase()}`:n;return e.flatMap(e=>e.type===`bipolar`&&e.poles?[{control:e,label:n(e,e.poles[0]),value:-Zy(Math.abs(e.safe[0])*.65)},{control:e,label:n(e,e.poles[1]),value:Zy(e.safe[1]*.6)}]:[{control:e,label:e.label.toLowerCase(),value:Zy(e.safe[1]*.5)}])}function $y({values:e,set:t,clear:n,name:r}){let i=$f.value,a=pv.value,o=Qy(i.filter(e=>!a.has(e.id)),new Set(fv.value.map(e=>e.label.toLowerCase()))),s=i.filter(t=>!a.has(t.id)||e[t.id]),c=i.filter(t=>e[t.id]);return G(`div`,{class:`direction`,children:[G(`div`,{class:`direction-chips`,role:`group`,"aria-label":`Direction for ${r}`,children:[o.map(n=>{let r=e[n.control.id]??0,i=r!==0&&Math.sign(r)===Math.sign(n.value);return G(`button`,{class:`chip dchip${i?` is-on`:``}`,style:{"--fam":ba(n.control.group)},"aria-pressed":i,title:`${n.control.label} · strength ${Math.abs(n.value)}${n.control.effect?` · ${n.control.effect}`:``}`,onClick:()=>t(n.control.id,i?0:n.value),children:[n.label,i&&G(`b`,{children:[`×`,+Math.abs(r).toFixed(2)]})]})}),G(yv,{values:e,onPick:n=>t(n.control.id,(e[n.control.id]??0)>0?0:n.dose)}),n&&c.length>0&&G(`button`,{class:`link dclear`,onClick:n,children:`clear`})]}),G(`details`,{class:`pro direction-fine`,children:[G(`summary`,{children:c.length?`Fine-tune ${c.map(e=>e.label.toLowerCase()).join(`, `)}`:`Fine-tune strength`}),G(`div`,{class:`direction-sliders`,children:s.map(n=>G(lv,{control:n,value:e[n.id]??0,color:ba(n.group),detailed:!0,onChange:e=>t(n.id,e)},n.id))})]})]})}var eb=150,tb=4,nb=256,rb=[.1,.25,.5,1,2,5,10,30,60];function ib(e){let t=Math.ceil(e.length/nb),n=new Float32Array(t),r=new Float32Array(t);for(let i=0;ia&&(a=r)}n[i]=t,r[i]=a}return{min:n,max:r}}var ab=e=>typeof e.confidence==`number`&&e.confidence<.5,ob=e=>typeof e.confidence==`number`?` · confidence ${e.confidence.toFixed(2)}`:``,sb=e=>{let t=Math.floor(e/60);return`${t}:${(e-t*60).toFixed(2).padStart(5,`0`)}`};function cb(e){let t=P(null),n=P(null),[r,i]=M(800),[a,o]=M(0),[s,c]=M(null),[l,u]=M(null),d=P(null),f=e.pcm.length/e.sr,p=mt(()=>ib(e.pcm),[e.pcm]),m=r/Math.max(.5,f)*e.zoom,h=Math.max(r,Math.ceil(f*m)),g=Yg.value,_=mt(()=>({wave:Qg(`--text-2`),dim:Qg(`--text-3`),line:Qg(`--line`),text:Qg(`--text-2`)}),[g]);N(()=>{let e=t.current,n=new ResizeObserver(([e])=>i(Math.max(200,Math.round(e.contentRect.width))));n.observe(e);let r=0,a=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>o(e.scrollLeft))};e.addEventListener(`scroll`,a,{passive:!0});let s=t=>{if(t.ctrlKey||t.metaKey){t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.left;d.current={t:(e.scrollLeft+r)/v.current,x:r},b.current(F(y.current*Math.exp(-t.deltaY*.0025),1,64))}else y.current>1&&Math.abs(t.deltaY)>Math.abs(t.deltaX)&&(t.preventDefault(),e.scrollLeft+=t.deltaY)};return e.addEventListener(`wheel`,s,{passive:!1}),()=>{n.disconnect(),e.removeEventListener(`scroll`,a),e.removeEventListener(`wheel`,s)}},[]);let v=P(m);v.current=m;let y=P(e.zoom);y.current=e.zoom;let b=P(e.setZoom);b.current=e.setZoom,pt(()=>{let e=t.current,n=d.current??{t:(e.scrollLeft+r/2)/v.current,x:r/2};e.scrollLeft=F(n.t*m-n.x,0,Math.max(0,h-r)),d.current=null,o(e.scrollLeft)},[m]),N(()=>{let n=e.zoomTo;if(!n)return;let i=Math.max(.3,n.e-n.s),a=F(f/i,1,64);if(d.current={t:(n.s+n.e)/2,x:r/2},e.setZoom(a),a===e.zoom){let e=t.current;e.scrollLeft=F((n.s+n.e)/2*m-r/2,0,Math.max(0,h-r))}},[e.zoomTo?.n]),N(()=>{let t=n.current;if(!t)return;let i=window.devicePixelRatio||1;t.width=Math.round(r*i),t.height=Math.round(eb*i);let o=t.getContext(`2d`);o.setTransform(i,0,0,i,0,0),o.clearRect(0,0,r,eb);let s=_,c=a/m,l=rb.find(e=>e*m>=70)??120;o.font=`11px "JetBrains Mono", ui-monospace, Menlo, monospace`,o.fillStyle=s.dim,o.strokeStyle=s.line,o.lineWidth=1;for(let e=Math.floor(c/l)*l;e<=c+r/m;e+=l){let t=Math.round(e*m-a)+.5;o.beginPath(),o.moveTo(t,11),o.lineTo(t,eb),o.globalAlpha=.35,o.stroke(),o.globalAlpha=1,o.fillText(l<1?`${e.toFixed(l<.5?2:1)}s`:sb(e).replace(/\.\d+$/,``),t+3,10)}let u=.05;for(let e=0;e=e.pcm.length)break;let i=0,s=0;if(r-ns&&(s=n)}else for(let e=Math.floor(n/nb);es&&(s=p.max[e]);let c=83-Math.max(.5,s*d*63),l=83-Math.min(-.5,i*d*63);o.fillRect(t,c,1,l-c)}},[p,m,a,r,_]);let x=B.value?.id===e.playId?ws.value:null;N(()=>{if(x===null)return;let e=t.current,n=x*m;(ne.scrollLeft+r-24)&&(e.scrollLeft=F(n-r*.15,0,Math.max(0,h-r)))},[x!==null&&Math.floor(x*m/(r*.5))]);let S=e=>F((e-t.current.getBoundingClientRect().left+t.current.scrollLeft)/m,0,f),C=t=>{if(t.button!==0||t.target.closest(`.ew-word, .ew-edge, .ew-words`))return;let n=t.currentTarget;n.setPointerCapture(t.pointerId);let r=t.clientX,i=S(r),a=!1,o=t=>{!a&&Math.abs(t.clientX-r){n.removeEventListener(`pointermove`,o),n.removeEventListener(`pointerup`,l),n.removeEventListener(`pointercancel`,u),c(null)},l=t=>{if(s(),a&&e.editable){let n=S(t.clientX);Math.abs(n-i)*m>=tb&&e.onCreate(Math.min(i,n),Math.max(i,n))}else a||e.onSeek(i)},u=()=>s();n.addEventListener(`pointermove`,o),n.addEventListener(`pointerup`,l),n.addEventListener(`pointercancel`,u)},w=(t,n,r)=>{if(t.button!==0||!e.editable)return;t.stopPropagation();let i=t.currentTarget;i.setPointerCapture(t.pointerId);let a={kind:r,id:n.id,a:n.start,b:n.end},o=e=>{let t=S(e.clientX);a=r===`start`?{...a,a:Math.min(t,n.end-.07)}:{...a,b:Math.max(t,n.start+.07)},c(a)},s=()=>{i.removeEventListener(`pointermove`,o),i.removeEventListener(`pointerup`,l),i.removeEventListener(`pointercancel`,u),c(null)},l=()=>{s(),(a.a!==n.start||a.b!==n.end)&&e.onEdges(n.id,a.a,a.b)},u=()=>s();i.addEventListener(`pointermove`,o),i.addEventListener(`pointerup`,l),i.addEventListener(`pointercancel`,u)},T=(t,n,r)=>{let i=e.timing;if(t.button!==0||!i)return;t.stopPropagation(),t.preventDefault();let a=t.currentTarget;a.setPointerCapture(t.pointerId);let o=e.words[n];i.onEdge(n,r,r===`start`?o.start:o.end,`begin`,t.altKey),u({i:n,edge:r});let s=r===`start`?o.start:o.end,c=e=>{s=S(e.clientX),i.onEdge(n,r,s,`move`,e.altKey)},l=()=>{a.removeEventListener(`pointermove`,c),a.removeEventListener(`pointerup`,d),a.removeEventListener(`pointercancel`,f),u(null)},d=e=>{l(),i.onEdge(n,r,S(e.clientX),`end`,e.altKey)},f=()=>{l(),i.onEdge(n,r,s,`end`,!1)};a.addEventListener(`pointermove`,c),a.addEventListener(`pointerup`,d),a.addEventListener(`pointercancel`,f)},E=a/m-1,D=(a+r)/m+1,O=e.words.filter(e=>e.end>=E&&e.start<=D),ee=new Set,te=-1/0;for(let e of O){let t=e.start*m;tG(`div`,{class:`ew-context${e.contextsEstimated?` is-estimate`:``}`,style:{left:`${t*m}px`,width:`${Math.max(2,(n-t)*m)}px`},title:`Model context ${sb(t)}–${sb(n)}: ${e.contextsEstimated?`the stretch the model will hear (estimate)`:`the audio the model listened to for this edit`}`,children:G(`span`,{children:e.contextsEstimated?`model context · est.`:`model context`})})),G(`canvas`,{ref:n,class:`ew-canvas`,style:{width:`${r}px`,height:`${eb}px`,left:`${a}px`},"aria-hidden":`true`}),e.overlays.map(([e,t],n)=>G(`div`,{class:`ew-overlay`,style:{left:`${e*m}px`,width:`${Math.max(2,(t-e)*m)}px`},title:`Region ${n+1} in this take`,children:G(`span`,{class:`ew-n`,children:n+1})})),e.regions.map(t=>{let n=s&&s.id===t.id?s:null,r=n?n.a:t.start,i=n?n.b:t.end;return G(`div`,{class:`ew-region${t.manual?` is-manual`:``}${t.directed?` is-directed`:``}${t.ghost?` is-ghost`:``}${e.focusRegion===t.id?` is-focus`:``}`,style:{left:`${r*m}px`,width:`${Math.max(3,(i-r)*m)}px`},children:[G(`span`,{class:`ew-n`,children:t.n}),e.editable&&G(j,{children:[G(`span`,{class:`ew-edge ew-edge-s`,onPointerDown:e=>w(e,t,`start`),title:`Drag to move the start`}),G(`span`,{class:`ew-edge ew-edge-e`,onPointerDown:e=>w(e,t,`end`),title:`Drag to move the end`})]})]})}),s?.kind===`new`&&G(`div`,{class:`ew-region is-new`,style:{left:`${Math.min(s.a,s.b)*m}px`,width:`${Math.abs(s.b-s.a)*m}px`}}),G(`div`,{class:`ew-cursor`,style:{left:`${e.cursor*m}px`}}),x!==null&&G(`div`,{class:`ew-head`,style:{left:`${x*m}px`}}),e.timing?G(`div`,{class:`ew-words is-timing`,role:`group`,"aria-label":`Word timings: drag word edges to correct them`,children:[O.map(t=>{let n=e.words.indexOf(t),r=e.timing,i=r.selected===n,a=Math.max(2,(t.end-t.start)*m),o=l?.i===n?l.edge:i?r.edge:null;return G(`div`,{class:`ew-wblock${i?` is-sel`:``}${r.adjusted(n)?` is-adjusted`:``}${ab(t)?` is-low`:``}${x!==null&&x>=t.start&&xe.onWord(n),children:a>14||i?t.word:``}),G(`span`,{class:`ew-wedge ew-wedge-s${o===`start`?` is-active`:``}`,onPointerDown:e=>T(e,n,`start`),"aria-hidden":`true`}),G(`span`,{class:`ew-wedge ew-wedge-e${o===`end`?` is-active`:``}`,onPointerDown:e=>T(e,n,`end`),"aria-hidden":`true`})]})}),l&&(()=>{let t=e.timing.selected??l.i,n=e.words[t];if(!n)return null;let r=e.timing.edge===`start`?n.start:n.end;return G(`div`,{class:`ew-readout`,style:{left:`${r*m}px`},"aria-live":`polite`,children:[n.word,` `,e.timing.edge===`start`?`start`:`end`,` `,sb(r),` · `,Math.round((n.end-n.start)*1e3),` ms`]})})()]}):G(`div`,{class:`ew-words`,children:O.map(t=>{let n=e.words.indexOf(t),r=t.start*m,i=Math.max(10,(t.end-t.start)*m);return G(`button`,{class:`ew-word${ee.has(t)?` is-quiet`:``}${ab(t)?` is-low`:``}${x!==null&&x>=t.start&&xe.onWord(n),tabIndex:0,children:t.word})})})]})})})}var lb=I(1),ub=I(null),db=I(null),fb=null;function pb(){requestAnimationFrame(()=>document.querySelector(`.ew-wblock.is-sel .ew-wlabel`)?.focus({preventScroll:!1}))}function mb(e){let t=e.metaKey||e.ctrlKey;if(t&&e.key===`Enter`)return e.preventDefault(),nm(),!0;let n=e.target,r=n?.getAttribute?.(`role`),i=!!n?.closest?.(`.ew-wlabel`);if(t||e.altKey||uy(e.target)&&!(e.key===`Tab`&&i)||!Y.value)return!1;let a=tp.value,o=Hf.value;if(o!==null&&a?.kind===`version`&&r!==`slider`){let t=Y.value.words.length;switch(e.key){case`ArrowLeft`:case`ArrowRight`:return!uy(e.target)&&(e.preventDefault(),Op((e.key===`ArrowLeft`?-1:1)*(e.shiftKey?.05:.01)),!0);case`Tab`:return i?(e.preventDefault(),Hf.value=F(o+(e.shiftKey?-1:1),0,t-1),pb(),!0):!1;case`,`:case`.`:return!uy(e.target)&&(Uf.value=e.key===`,`?`start`:`end`,!0);case`Enter`:return!uy(e.target)&&(e.preventDefault(),Ap(o),!0);case`Escape`:return Hf.value=null,!0}}if(uy(e.target))return!1;switch(e.key){case` `:return e.target instanceof HTMLButtonElement||r===`slider`||r===`button`?!1:(e.preventDefault(),lm(),!0);case`a`:case`b`:return r===`slider`?!1:e.key===`b`&&!ep.value?(z(`Generate takes first`),!0):(cm(e.key===`a`?`version`:`take`),!0);case`k`:return ep.value?(fm(),!0):(z(`Generate takes first`),!0);case`[`:return r!==`slider`&&(lb.value=F(lb.value/1.6,1,64),!0);case`]`:return r!==`slider`&&(lb.value=F(lb.value*1.6,1,64),!0);case`0`:return r!==`slider`&&(lb.value=1,!0);case`ArrowLeft`:case`ArrowRight`:{if(r===`slider`||!a)return!1;e.preventDefault();let t=B.value?.id===a.id,n=F((t?ws.value:Vf.value)+(e.key===`ArrowLeft`?-1:1),0,a.duration);return Vf.value=n,t&&Rs(a.id,a.pcm,a.sr,n),!0}}return!1}var hb=I(null);async function gb(e){let t=H.value.find(t=>t.id===e);if(t){hb.value=e;try{let{pcm:e,sr:n}=await Hs(await _o(t));await pp({kind:`voice`,label:t.label},e,n,t.transcript)&&wg()}catch(e){z(`Couldn’t load ${t.label}: ${e instanceof Error?e.message:e}`,`error`)}finally{hb.value=null}}}async function _b(e,t,n){let r=J.value[e]?.[n];r&&await pp({kind:`take`,label:`Line ${t+1} · take ${n+1}`,lineId:e,takeId:r.id},r.audio.pcm,r.audio.sr,r.text)&&wg()}function vb(){let e=P(null),t=Tm.value,[,n]=M(0);N(()=>{if(!t)return;let e=setInterval(()=>n(e=>e+1),250);return()=>clearInterval(e)},[t]);let r=q.value.lines.flatMap((e,t)=>(J.value[e.id]??[]).map((n,r)=>({l:e,i:t,t:n,k:r}))),i=H.value.filter(e=>e.has_preview!==!1),a=!!X.value;return G(`div`,{class:`rail-section edit-sources`,children:[G(`h4`,{children:`Open audio`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn sm`,disabled:a,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`,size:13}),` Upload`]}),G(`button`,{class:`btn sm btn-rec${t?` is-recording`:``}`,disabled:a&&!t,onClick:()=>void Dm(),children:t?G(j,{children:[G(`span`,{class:`rec-dot`}),` Stop · `,Math.floor((Date.now()-t.started)/1e3),` / `,Math.round(Math.min(120,Zf.value)),` s`,G(`span`,{class:`rec-level`,"aria-hidden":`true`,children:G(`span`,{style:{width:`${Math.round(Em.value*100)}%`}})})]}):G(j,{children:[G(K,{name:`mic`,size:13}),` Record`]})}),G(`input`,{ref:e,type:`file`,accept:`audio/*,video/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&Om(t)}})]}),G(`p`,{class:`hint`,children:[`Clips up to `,Math.round(Zf.value),` s.`]}),G(`details`,{class:`src-group`,open:!!r.length,children:[G(`summary`,{children:[`Direct takes `,r.length?G(`b`,{children:r.length}):null]}),r.length?G(`ul`,{class:`src-list`,children:r.map(({l:e,i:t,t:n,k:r})=>G(`li`,{children:G(`button`,{class:`src-item`,disabled:a,title:n.text,onClick:()=>void _b(e.id,t,r),children:[G(`span`,{class:`src-n`,children:[t+1,`.`,r+1]}),G(`span`,{class:`src-text`,children:n.text}),n.starred&&G(K,{name:`star`,size:11,filled:!0})]})}))}):G(`p`,{class:`muted small`,children:`Render takes in Direct; each one can be opened here.`})]}),G(`details`,{class:`src-group`,open:i.length>0,children:[G(`summary`,{children:[`Voice clips `,i.length?G(`b`,{children:i.length}):null]}),G(`ul`,{class:`src-list`,children:i.map(e=>G(`li`,{children:G(`button`,{class:`src-item${hb.value===e.id?` is-busy`:``}`,disabled:a,onClick:()=>void gb(e.id),title:e.transcript?`Transcript: ${e.transcript}`:Xf.value?`No transcript: it will be transcribed`:`No transcript: this server can’t transcribe, so you type what the clip says`,children:[G(`span`,{class:`src-text`,children:e.label}),G(`span`,{class:`tag`,children:e.transcript?`text`:Xf.value?`auto`:`needs text`})]})}))})]})]})}function yb(){let e=kf.value;return e?G(`div`,{class:`rail-section grow`,children:[G(`h4`,{children:`Versions`}),G(`ol`,{class:`versions`,children:e.versions.map((t,n)=>{let r=`edit:v:${t.id}`,i=B.value?.id===r;return G(`li`,{class:`version-row${n===e.current?` is-current`:``}${n>e.current?` is-future`:``}`,children:[G(`button`,{class:`version-main`,onClick:()=>void mm(n),"aria-current":n===e.current,title:n===e.current?`Current version`:`Step to this version`,children:[G(`span`,{class:`badge`,children:[`v`,n]}),G(`span`,{class:`version-label`,children:t.label}),G(`span`,{class:`mono muted`,children:[(t.pcm.length/t.sr).toFixed(1),` s`]})]}),G(`button`,{class:`play-mini${i?` is-playing`:``}`,onClick:()=>Bs(r,t.pcm,t.sr),"aria-label":`Play version ${n}`,children:G(K,{name:i?`stop`:`play`,size:11})})]})})}),G(`p`,{class:`hint`,children:`Keep a take to add a version; ⌘Z / ⇧⌘Z step through them.`})]}):null}function bb({value:e}){let t=Y.value,n=np.value,r=mt(()=>sr(t.words,e,{duration:t.duration,frameRate:Qf.value,marginSeconds:Gf.value,groups:n}),[t,e,n]),i=[],a=new Map,o=0;for(let e of r.regions)for(let t of e.changes)if(t.j1===t.j2)i.push({from:r.deletionPoints[o++],to:0,type:`del`});else for(let e=t.j1;ee.from-t.from||(e.type===`del`?-1:1));let s=[],c=0;for(let t of i)t.fromt.transcript||fp.value,[a,o]=M(i);N(()=>o(i()),[t.id,n]);let s=n?a:Af.value;N(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${Math.max(64,t.scrollHeight)}px`)},[s,n]),N(()=>{r&&e.current?.focus()},[t.id,r]);let c=!!X.value;return G(`section`,{class:`ed-text-card`,"aria-label":`Transcript`,children:[G(`header`,{class:`ed-text-head`,children:[r||n?G(`div`,{class:`segctl`,role:`tablist`,"aria-label":`Transcript mode`,children:[G(`button`,{role:`tab`,"aria-selected":!n,class:`seg-btn${n?``:` is-on`}`,onClick:()=>void vm(!1),disabled:r,title:r?`Type what the clip says first: edits are planned against it`:void 0,children:`Edit the words`}),G(`button`,{role:`tab`,"aria-selected":n,class:`seg-btn${n?` is-on`:``}`,onClick:()=>void vm(!0),disabled:c,title:r?`Type what is said in the clip; the audio is aligned to it`:`Correct what was actually said; the audio is re-aligned to it`,children:r?`Type what the clip says`:`Fix the transcript`})]}):G(j,{children:[G(`h3`,{class:`ed-text-title`,children:`Edit the words`}),!t.automatic&&G(`button`,{class:`link`,onClick:()=>void vm(!0),disabled:c,title:`Correct what was actually said; the audio is re-aligned to it`,children:`Fix the transcript`})]}),!n&&Af.value!==t.transcript&&G(`button`,{class:`link`,onClick:()=>{let e=Af.value;Ip(t.transcript),z(`Text reverted to the transcript`,`info`,{label:`Undo`,run:()=>Ip(e)})},title:`Back to the transcript of this version`,children:[G(K,{name:`undo`,size:13}),` revert text`]})]}),r&&G(`div`,{class:`ed-banner`,role:`note`,children:G(`span`,{children:[Xf.value?`No words were recognized in this clip. `:`This server can’t transcribe speech. `,G(`b`,{children:`Type exactly what the clip says`}),` (play it to check), then use it: edits are planned against it.`]})}),!n&&t.automatic&&G(`div`,{class:`ed-banner ed-check`,role:`note`,children:[G(`span`,{children:[G(`b`,{children:`Transcribed automatically`}),` — check it: play the clip and read along.`]}),G(`button`,{class:`btn sm primary`,onClick:ym,disabled:c,children:`Looks right`}),G(`button`,{class:`btn sm`,onClick:()=>void vm(!0),disabled:c,children:`Fix it`})]}),G(`div`,{class:`ed-editor${n?` is-fix`:``}`,children:[!n&&G(bb,{value:s}),G(`textarea`,{ref:e,class:`ed-area`,value:s,spellcheck:!1,"data-tags":!n||void 0,"aria-label":r?`What the clip says`:n?`Correct transcript of the audio`:`Edited transcript: change the words to change the speech`,placeholder:r?`Type what is said in the clip…`:void 0,onInput:e=>{let t=e.currentTarget.value;n?o(t):Ip(t)},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.blur()}})]}),!n&&(np.value||__.value)&&G(`div`,{class:`ed-pron`,children:[np.value&&G(u_,{input:()=>e.current}),G(w_,{input:()=>e.current}),np.value&&G(h_,{text:s,replace:(e,t,n)=>Ip(s.slice(0,e)+n+s.slice(t))}),G(E_,{text:s,replace:e=>Ip(e)})]}),n&&G(`div`,{class:`ed-fix-bar`,children:[G(`span`,{class:`hint`,children:r?`Type what is said in the audio, word for word.`:`Type what is actually said in the audio. Low-confidence words are underlined in the waveform’s word lane.`}),!r&&G(`button`,{class:`btn sm ghost`,onClick:()=>void vm(!1),children:`Cancel`}),G(`button`,{class:`btn sm primary`,disabled:c||!a.trim()||a.trim()===t.transcript,onClick:()=>void xm(a),children:`Use this transcript`})]})]})}var Sb=I(null);function Cb(){let e=jf.value,t=If.value,n=ep.value,r=!!t&&t.target!==Af.value.trim(),i=t&&n&&!r&&t.spans.length===e.length?Xp(n,t):null,a=ap.value,o=e.reduce((e,t)=>e+op(t.end-t.start),0);return G(`section`,{class:`ed-regions`,"aria-label":`Regions`,children:[G(`header`,{class:`ed-sub-head`,children:[G(`h3`,{children:`Regions`}),G(`span`,{class:`ed-count${a?` is-error`:``}`,children:[e.length,`/`,Jf.value.edit_max_spans,` · `,o.toFixed(1),` s to regenerate`]})]}),a&&G(`p`,{class:`error-box`,role:`alert`,children:a}),r&&t&&t.takes.length>0&&G(`p`,{class:`note`,children:`The takes were made from earlier text; generate again for this one.`}),e.length?G(`ol`,{class:`region-list`,children:e.map((e,t)=>{let r=op(e.start),a=op(e.end),o=t>=Jf.value.edit_max_spans;return G(`li`,{class:`region-row${e.manual?` is-manual`:``}${o?` is-over`:``}${db.value===e.id?` is-focus`:``}`,onPointerEnter:()=>db.value=e.id,onPointerLeave:()=>db.value=null,children:[G(`div`,{class:`region-line`,children:[G(`span`,{class:`badge region-n`,children:t+1}),G(`span`,{class:`mono region-time`,children:[sb(r),`–`,sb(a)]}),G(`span`,{class:`region-sum`,title:Up(e),children:Up(e)}),G(`button`,{class:`icon-btn sm`,onClick:()=>um(t),"aria-label":`Play around region ${t+1}`,title:`Play with 1 s of pre-roll`,children:G(K,{name:`play`,size:12})}),G(`button`,{class:`icon-btn sm`,onClick:()=>ub.value={s:r-1,e:a+1,n:Date.now()},"aria-label":`Zoom to region ${t+1}`,title:`Zoom to this region`,children:G(K,{name:`expand`,size:12})}),e.manual&&G(`button`,{class:`icon-btn sm`,onClick:()=>zp(e.id),"aria-label":`Remove region ${t+1}`,title:`Remove this region`,children:G(K,{name:`x`,size:12})}),e.changes.length>0&&G(`button`,{class:`link`,onClick:()=>Pp(e.id),title:`Put the original words back into the text`,children:`revert these words`})]}),(e.edited||e.mergedFrom)&&G(`p`,{class:`region-note`,children:[e.edited?`edges moved by hand`:``,e.edited&&e.mergedFrom?` · `:``,e.mergedFrom?`merged from ${e.mergedFrom} regions`:``]}),i?.[t]?.length?G(`p`,{class:`region-unheard`,role:`note`,children:[`Not heard in `,n.label.toLowerCase(),`: `,G(`b`,{children:i[t].join(`, `)})]}):null,G(`div`,{class:`region-dir`,children:Sb.value===e.id?G(j,{children:[G(`div`,{class:`region-dir-head`,children:[G(`span`,{class:`muted small`,children:[`How region `,t+1,` sounds`]}),G(`button`,{class:`link`,onClick:()=>Sb.value=null,children:`Done`})]}),G($y,{name:`region ${t+1}`,values:e.values,set:(t,n)=>Bp(e.id,t,n),clear:()=>Vp(e.id)})]}):G(`div`,{class:`region-dir-sum`,children:[G(`span`,{class:`muted small`,children:[`How it sounds: `,qp(e.values)||(Yp.value&&Object.keys(Pf.value).length?`as all changes`:`as the voice says it`)]}),G(`button`,{class:`link`,onClick:()=>Sb.value=e.id,children:`Edit`})]})})]})})}):G(`p`,{class:`ed-regions-empty`,children:[G(`b`,{children:`Change words`}),`, or `,G(`b`,{children:`drag across the waveform`}),` to re-say a stretch as it is. Then pick how it should sound: whisper, slower, angry…`]})]})}function wb(){let e=X.value,[,t]=M(0);if(N(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),100);return()=>clearInterval(n)},[e]),!e)return null;let n=(performance.now()-e.started)/1e3;return G(`div`,{class:`ed-busy-row`,role:`status`,"aria-live":`polite`,children:[G(`span`,{class:`loader sm`}),G(`span`,{class:`ed-status is-busy`,children:[e.label,` `,n.toFixed(1),` s`]}),G(`button`,{class:`btn sm`,onClick:rm,children:[G(K,{name:`x`,size:13}),` Cancel`]})]})}function Tb(){let e=X.value,t=Wf.value,n=!!e&&/Generating|Regenerating/.test(e.label),r=(Y.value?.duration??0)>16;return G(`section`,{class:`ed-generate`,"aria-label":`Generate`,children:[G(`div`,{class:`ed-all`,children:[G(`span`,{class:`ed-all-label`,children:`All changes sound:`}),G($y,{name:`all changes`,values:Pf.value,set:Hp,clear:()=>Pf.value={}})]}),G(`details`,{class:`pro ed-advanced`,children:[G(`summary`,{children:`Advanced`}),G(`div`,{class:`ed-pro-row`,children:[G(`label`,{class:`ed-seed`,title:`A fixed seed repeats a take's randomness; empty picks one each time`,children:[`Seed`,G(`input`,{type:`number`,class:`input`,placeholder:`random`,value:Kf.value??``,onChange:e=>{let t=e.currentTarget.value;Kf.value=t===``?null:Math.max(0,Math.floor(Number(t)))}})]}),G(`label`,{title:`Each change is widened by this much on both sides so the join sounds smooth`,children:[`Blend around the change`,G(`input`,{type:`number`,class:`input`,min:0,max:.4,step:.02,value:Gf.value,onChange:e=>{Gf.value=F(Number(e.currentTarget.value)||0,0,.4),Fp()}}),`s`]}),r&&G(`label`,{title:`Long clips are edited on a window around the changes; this is how much audio the model listens to on each side`,children:[`Audio the model listens to`,G(`input`,{type:`number`,class:`input`,min:2,max:8,step:.5,value:qf.value,onChange:e=>qf.value=F(Number(e.currentTarget.value)||4,2,8)}),`s per side`]})]})]}),G(`div`,{class:`ed-gen-row`,children:[G(`div`,{class:`segctl`,role:`radiogroup`,"aria-label":`Number of takes`,children:[1,2,3,4].map(e=>G(`button`,{role:`radio`,"aria-checked":t===e,class:`seg-btn${t===e?` is-on`:``}`,onClick:()=>Wf.value=e,children:e}))}),G(`span`,{class:`muted small`,children:[`take`,t>1?`s`:``]}),G(`span`,{class:`grow`}),G(`button`,{class:`btn primary${n?` is-busy`:``}`,disabled:n||!$p.value,onClick:()=>void nm(),title:ip.value?`Fix the pronunciation first: ${ip.value.replace(/^Pronunciation: /,``)}`:`Generate (⌘↵ / Ctrl+Enter)`,children:[G(K,{name:`wand`,size:14}),` `,n?`Generating…`:`Generate ${t} take${t>1?`s`:``}`,!n&&Yp.value&&G(`span`,{class:`gen-directed`,children:` · directed`})]})]}),zf.value&&G(`div`,{class:`error-box`,role:`alert`,children:[G(`b`,{children:Bf.value?`The server refused this edit`:`Generation failed`}),G(`span`,{children:zf.value})]})]})}function Eb(){let e=If.value,t=Y.value;if(!e||!t||e.versionId!==t.id)return G(`div`,{class:`takes-empty`,children:[G(K,{name:`wand`,size:20}),G(`p`,{children:Xf.value?`Takes appear here. Each one is checked by speech recognition; the closest to your text is picked for you.`:`Takes appear here. Listen to each one and keep the best (this server can’t check takes with speech recognition).`})]});let n=tr(e.target,e.groups).filter(e=>!$n(e)),r=e.groups?vn(e.target,null).groups.filter(e=>!e.empty):[],i=Qp(e.takes,e);return G(`ol`,{class:`take-cards`,children:e.takes.map((t,a)=>{let o=`edit:take:${t.id}`,s=B.value?.id===o,c=e.selected===a,l=t.verify?.wer??null,u=t.verify?t.verify.asr_text.split(/\s+/).filter(Boolean):[],d=t.verify?tr(t.verify.asr_text):[],f=u.length===d.length?ir(n,d):null,m=Zp(t,e),h=t.verify?Xp(t,e).flat():null,g=t.verify?h.length?[`Missing: ${h.join(`, `)}`,`warn`,`Words of your text speech recognition did not hear in this take`]:[`All words heard`,`ok`,`Speech recognition heard every word of your text`]:[`Not checked`,`muted`,`No speech recognition on this server: listen to it`];return G(`li`,{class:`take-card${c?` is-selected`:``}`,children:[G(`button`,{class:`take-card-head`,onClick:()=>om(a),"aria-pressed":c,title:`Select (A/B compares it with the version)`,children:[G(`b`,{children:t.label}),G(`span`,{class:`badge verdict is-${g[1]}`,title:g[2],children:g[0]}),a===i&&l!==null&&G(`span`,{class:`badge badge-best`,children:`best match`})]}),G(`div`,{class:`take-wave`,onClick:()=>om(a),children:G($g,{pcm:t.pcm,color:c?`var(--o)`:`var(--text-2)`,playId:o,height:34})}),t.verify&&G(`p`,{class:`take-asr`,title:`What speech recognition heard; differences from your text are marked`,children:f?u.map((e,t)=>G(j,{children:[G(`span`,{class:f[t]?`asr-wrong`:``,children:e}),` `]})):t.verify.asr_text}),r.length>0&&t.verify&&G(`p`,{class:`take-heard`,title:`What speech recognition wrote where each pronunciation is (any word counts as said)`,children:r.map((e,n)=>{let r=t.verify.groups?.[n]?.heard;return G(`span`,{class:`take-heard-item${r?``:` is-missing`}`,children:[G(`span`,{class:`mono`,children:[`(`,e.body,`)`]}),` `,r?G(j,{children:[`heard as ‘`,r,`’`]}):`nothing recognized there`]})})}),G(`p`,{class:`take-dir${t.direction?``:` is-none`}`,title:`How this take was directed`,children:t.direction||`no direction: as the voice says it`}),m.map(e=>G(`p`,{class:`warn-line`,children:e.text})),G(`div`,{class:`take-actions`,children:[G(`button`,{class:`play-mini${s?` is-playing`:``}`,onClick:()=>(om(a),Bs(o,t.pcm,t.sr)),"aria-label":`Play ${t.label}`,children:G(K,{name:s?`stop`:`play`,size:11})}),e.spans.map((e,t)=>G(`button`,{class:`btn sm ghost`,onClick:()=>(om(a),cm(`take`),um(t)),title:`Play change ${t+1} of this take with pre-roll`,children:[G(K,{name:`play`,size:11}),` Play change `,t+1]})),G(`span`,{class:`grow`}),c&&e.spans.map((e,t)=>G(`button`,{class:`btn sm ghost`,disabled:!!X.value,onClick:()=>void am(t),title:`Regenerate only change ${t+1} of this take`,children:[G(K,{name:`refresh`,size:12}),` Redo change `,t+1]})),G(`button`,{class:`icon-btn sm`,onClick:()=>un(t.pcm,t.sr,`${p(kf.value?.name??`edit`)}-${p(t.label)}`),"aria-label":`Export ${t.label} as WAV`,title:`Export ${t.label.replace(`Take `,`take `)}`,children:G(K,{name:`download`,size:13})}),G(`button`,{class:`btn sm primary`,disabled:!!X.value,onClick:()=>(om(a),void fm()),title:`Keep: becomes the new version (K)`,children:`Keep`})]}),G(`details`,{class:`pro take-details`,children:[G(`summary`,{children:`Details`}),G(`p`,{class:`mono small`,children:[l===null?``:`Word error ${Math.round(l*100)}% · `,`seed `,t.seed,e.spans.map(([e,n],r)=>` · change ${r+1}: ${(n-e).toFixed(2)} → ${(t.fill[r]??0).toFixed(2)} s`).join(``)]}),G(`button`,{class:`link`,onClick:()=>Kf.value=t.seed,title:`Generate again with this take's seed (Advanced → Seed)`,children:`Reuse seed`})]})]})})})}function Db(){let e=ua.value;return G(`div`,{class:`empty`,children:[G(K,{name:`edit-speech`,size:28}),G(`h2`,{children:`This server can’t edit speech`}),G(`p`,{children:`Changing words in a recording needs a server with the speech-editing model. Cast and Direct work as usual.`}),G(`details`,{class:`pro`,children:[G(`summary`,{children:`For whoever runs the server`}),G(`p`,{children:[e.kind!==`fixture`&&e.kind!==`offline`?`${e.server||location.origin} reports speech_editing: false. `:`Fixture mode: started with ?edit=0. `,`The studio README (“Edit”) lists what the server needs to edit speech.`]})]})]})}function Ob(){let e=P(null);return X.value?G(`div`,{class:`empty`,children:G(wb,{})}):G(`div`,{class:`empty`,children:[G(K,{name:`edit-speech`,size:26}),G(`h3`,{children:`Open a clip to edit`}),G(`p`,{children:`Change the words of a recording; only the changed stretch is regenerated.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>e.current?.click(),children:[G(K,{name:`upload`,size:14}),` Upload`]}),G(`button`,{class:`btn`,onClick:()=>void Dm(),children:[G(K,{name:`mic`,size:14}),` Record`]}),G(`button`,{class:`btn`,onClick:()=>Tg(`edit-sources`),children:[G(K,{name:`film`,size:14}),` Choose a take or voice`]}),G(`input`,{ref:e,type:`file`,accept:`audio/*,video/*`,hidden:!0,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&Om(t)}})]})]})}function kb(){let e=Y.value,t=kf.value,n=tp.value,r=P(null),i=n?.kind===`take`;if(N(()=>{i&&requestAnimationFrame(()=>document.querySelector(`.take-card.is-selected`)?.scrollIntoView({block:`nearest`,behavior:`smooth`}))},[i,If.value?.selected]),!e||!t||!n)return G(Ob,{});let a=ep.value,o=i?n.label:t.current===0?`Original`:`v${t.current}`,s=B.value?.id===n.id,c=!i&&!Nf.value;return G(`div`,{class:`ed-work`,children:[G(`header`,{class:`screen-head ed-head`,children:[G(`div`,{class:`ed-title`,children:[G(`span`,{class:`eyebrow`,children:{take:`Direct take`,voice:`Voice clip`,upload:`Upload`,recording:`Recording`}[t.source.kind]}),G(`h2`,{title:t.name,children:t.name})]}),G(`label`,{class:`ed-lang-wrap`,children:[G(`span`,{class:`muted small`,children:`clip language`}),G(`select`,{class:`input ed-lang`,value:t.language,disabled:!!X.value,onChange:e=>{let n=e.currentTarget,r=n.value;n.value=t.language,bm(r)},"aria-label":`Language of the clip`,title:Xf.value?`The clip's language: transcription, alignment and the take check use its speech model (the first use of a language loads it, about half a minute)`:`The clip's language: alignment uses it (switching aligns the transcript again)`,children:ee.map(e=>G(`option`,{value:e,children:g(e)}))})]}),G(`div`,{class:`ab`,role:`group`,"aria-label":`Compare`,children:[G(`button`,{class:`ab-btn${i?``:` is-on`}`,onClick:()=>cm(`version`),title:`The current version (A)`,children:[G(`b`,{children:`A`}),` `,t.current===0?`Original`:`v${t.current}`]}),G(`button`,{class:`ab-btn${i?` is-on`:``}`,disabled:!a,onClick:()=>cm(`take`),title:`The selected take (B)`,children:[G(`b`,{children:`B`}),` `,a?a.label:`Take`]})]}),G(`button`,{class:`btn sm`,onClick:lm,title:`Play / pause (Space)`,children:[G(K,{name:s?`stop`:`play`,size:13}),` `,s?`Pause`:`Play`]}),G(`span`,{class:`mono ed-time`,children:[sb(s?ws.value:Vf.value),` / `,sb(n.duration)]}),G(`div`,{class:`ed-zoom`,role:`group`,"aria-label":`Zoom`,children:[G(`button`,{class:`icon-btn sm`,onClick:()=>lb.value=F(lb.value/1.6,1,64),"aria-label":`Zoom out ([)`,title:`Zoom out ([)`,children:`−`}),G(`button`,{class:`icon-btn sm`,onClick:()=>lb.value=F(lb.value*1.6,1,64),"aria-label":`Zoom in (])`,title:`Zoom in (]) · ⌘/Ctrl+wheel`,children:`+`}),G(`button`,{class:`btn sm ghost`,onClick:()=>lb.value=1,title:`Fit (0)`,children:`fit`})]}),G(`span`,{class:`grow`}),t.current>0&&t.source.kind===`take`&&G(`button`,{class:`btn sm`,disabled:!Cm.value,onClick:()=>void wm(),title:Cm.value?`Add this version to the Direct line as a new keeper take`:`The original take is gone from Direct`,children:[G(K,{name:`undo`,size:13}),` Send back to Direct`]}),G(`button`,{class:`btn sm`,onClick:()=>un(n.pcm,n.sr,`${p(t.name)}-${i?p(n.label):`v${t.current}`}`),"aria-label":`Export ${o} as WAV`,title:`Save ${o} as a WAV file`,children:[G(K,{name:`download`,size:13}),` Export `,o]})]}),i&&a&&G(`div`,{class:`ed-compare-strip`,role:`status`,children:[G(`span`,{children:[`Comparing `,G(`b`,{children:a.label}),` with `,t.current===0?`the original`:`v${t.current}`]}),G(`button`,{class:`link`,onClick:()=>cm(`version`),children:[`Back to `,t.current===0?`the original`:`v${t.current}`]})]}),G(wb,{}),G(`div`,{class:`ed-wave-card${i?` is-take`:``}`,children:[G(`div`,{class:`ed-wave-label`,children:[i?G(`span`,{children:[G(`b`,{children:n.label}),` · green = regenerated`]}):G(`span`,{children:[G(`b`,{children:t.current===0?`Original`:`v${t.current} ${e.label}`}),` · orange = will be regenerated`]}),G(`span`,{class:`ed-timing-tools`,children:[!i&&!Nf.value&&G(j,{children:[Hf.value!==null&&n.words[Hf.value]?G(`span`,{class:`ed-readout`,role:`status`,children:[`Editing “`,n.words[Hf.value].word,`” · ←/→ nudge · Esc done`]}):G(`span`,{class:`muted`,children:xp.value?`${xp.value} timing${xp.value===1?``:`s`} adjusted`:``}),G(`label`,{class:`toggle`,title:`Start word playback 0.3 s early`,children:[G(`input`,{type:`checkbox`,checked:yp.value,onChange:e=>yp.value=e.currentTarget.checked}),G(`span`,{children:`pre-roll`})]}),xp.value>0&&G(`button`,{class:`link`,onClick:kp,title:`Back to the alignment's word timings (undoable)`,children:`Reset timings`})]}),G(`span`,{class:`muted`,children:[e.duration.toFixed(1),` s original`]})]})]}),G(`p`,{class:`hint ed-word-hint`,children:c?`Drag on the waveform to re-say a stretch · drag a word’s edge to fix its timing`:i?`Word timings: switch to A to edit`:`Word timings: finish the transcript first`}),G(cb,{pcm:n.pcm,sr:n.sr,words:n.words,regions:jf.value.map((e,t)=>({id:e.id,start:op(e.start),end:op(e.end),n:t+1,manual:e.manual,directed:Object.keys(e.values).length>0,ghost:i})),overlays:i&&a?a.edited:[],contexts:i&&a?a.contexts:If.value?.versionId===e.id&&If.value.contexts.length?If.value.contexts:jp.value,contextsEstimated:!i&&!(If.value?.versionId===e.id&&If.value.contexts.length),timing:c?{selected:Hf.value,edge:Uf.value,adjusted:Sp,onEdge:(t,n,r,i,a)=>{if(i===`begin`){Ep.begin(),Hf.value=t,Uf.value=n,fb={i:t,edge:n,t0:r,decided:!1};return}let o=fb??{i:t,edge:n,t0:r,decided:!0};if(!o.decided&&a&&Math.abs(r-o.t0)>.002){let t=e.words;o.edge===`start`&&ro.t0&&t[o.i+1]&&Math.abs(t[o.i+1].start-t[o.i].end)<.002&&Object.assign(o,{i:o.i+1,edge:`start`}),o.decided=!0,Hf.value=o.i,Uf.value=o.edge}wp(o.i,o.edge,r,a),i===`end`&&(Ep.end(),fb=null)}}:void 0,editable:!i&&!Nf.value,playId:n.id,cursor:Vf.value,zoom:lb.value,setZoom:e=>lb.value=e,onSeek:e=>{Vf.value=e,B.value?.id===n.id&&Rs(n.id,n.pcm,n.sr,e)},onCreate:Lp,onEdges:Rp,onWord:t=>{let a=n.words[t];if(c){Hf.value=t,Ap(t),pb();return}if(a&&Rs(n.id,n.pcm,n.sr,Math.max(0,a.start-.05),void 0,a.end+.05),i||Nf.value||!r.current)return;let o=sr(e.words,Af.value,{duration:e.duration,frameRate:Qf.value,marginSeconds:Gf.value,groups:np.value}),s=0;for(let n=0;n=0?o.owners[l]:null;u&&(r.current.focus(),r.current.setSelectionRange(u[0],u[1]))},focusRegion:db.value,zoomTo:ub.value})]}),G(`div`,{class:`ed-columns`,children:[G(`div`,{class:`ed-left`,children:[G(xb,{area:r}),G(Cb,{}),G(Tb,{})]}),G(`aside`,{class:`ed-takes`,"aria-label":`Takes`,children:[G(`header`,{class:`ed-sub-head`,children:[G(`h3`,{children:`Takes`}),a&&G(`span`,{class:`muted small`,children:Rf.value===`take`?`comparing (B)`:`press B to compare`})]}),If.value&&If.value.versionId===e.id&&G(`p`,{class:`hint`,children:`Takes aren’t saved until you keep one.`}),G(Eb,{})]})]})]})}function Ab(){let e=ua.value.edit.speech_editing;return N(()=>{wa.value=Of,Oa.value=lm,Da.value=e?mb:null;let t=e=>{Hf.peek()!==null&&!e.target.closest?.(`.ew-words, .ed-timing-tools`)&&(Hf.value=null)},n=e=>{Hf.peek()!==null&&e.target.matches?.(`textarea`)&&(Hf.value=null)};return document.addEventListener(`pointerdown`,t),document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`focusin`,n),wa.value=null,Oa.value=null,Da.value=null,Is()}},[e]),e?G(`div`,{class:`edit`,children:[G(Eg,{id:`edit-sources`,side:`left`,title:`Sources`,children:G(`aside`,{class:`rail edit-rail`,"aria-label":`Sources and versions`,children:[G(vb,{}),G(yb,{})]})}),G(Og,{children:G(Dg,{id:`edit-sources`,title:`Sources`,icon:`film`})}),G(kb,{}),G(Ng,{label:`Drop to edit this clip`,hint:`An audio or video file; only the words you change are regenerated`,busy:X.value?`Wait for the current step…`:null,onFile:e=>void Om(e)})]}):G(Db,{})}function jb({size:e=22}){return G(`svg`,{class:`z-mark`,width:e,height:e*164/224,viewBox:n,"aria-hidden":`true`,children:f.map(e=>G(`path`,{d:e,fill:`currentColor`}))})}function Mb({height:e=12}){return G(`svg`,{class:`z-word`,height:e,viewBox:c,role:`img`,"aria-label":`Zyphra`,children:r.map(e=>G(`path`,{d:e,fill:`currentColor`}))})}function Nb(){let e=Ea.value,t=P(null);pt(()=>{if(!e)return;let n=document.activeElement;return Ta.value=!0,t.current?.querySelector(`select`)?.focus({preventScroll:!0}),()=>{Ta.value=!1,(n?.isConnected?n:document.querySelector(`.proj-trigger`))?.focus({preventScroll:!0})}},[e]);let n=Z.value;if(!e||!n)return null;let r=()=>Ea.value=!1,i=ha.value,a=ua.value?.tags,o=ph.value;return G(`div`,{class:`sheet-backdrop`,onClick:r,children:G(`div`,{ref:t,class:`sheet settings-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,onClick:e=>e.stopPropagation(),onKeyDown:Cf(()=>t.current,r),children:[G(`header`,{class:`sheet-head`,children:[G(`h2`,{id:`settings-title`,children:`Project settings`}),G(`button`,{class:`icon-btn`,onClick:r,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`p`,{class:`muted small`,children:n.name}),G(`div`,{class:`settings-grid`,children:[G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Language`}),G(`select`,{class:`input`,value:i.language,onChange:e=>dg({language:e.currentTarget.value}),"aria-describedby":`settings-lang-hint`,children:Object.entries(C).map(([e,t])=>G(`option`,{value:e,children:t},e))}),G(`span`,{class:`hint`,id:`settings-lang-hint`,children:`Direct lines and the Cast preview render in it: numbers and abbreviations are read in this language, and painted words follow the reading where the server can. New Edit clips and pronunciation lookups start in it.`})]}),G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Voice mode`}),G(`select`,{class:`input`,value:i.voiceMode,onChange:e=>dg({voiceMode:e.currentTarget.value}),"aria-describedby":`settings-mode-hint`,children:[G(`option`,{value:`embedding`,children:`Designable`}),G(`option`,{value:`reference`,children:`Exact clone`})]}),G(`span`,{class:`hint`,id:`settings-mode-hint`,children:`How the Cast bench starts when a recorded voice is picked: designable (its embedding, every control works) or an exact clone of the clip (delivery and mood only).`})]}),a&&G(`label`,{class:`settings-row`,children:[G(`span`,{children:`Tag strength`}),G(`span`,{class:`settings-range`,children:[G(`input`,{type:`range`,min:Math.max(1,a.min_scale),max:a.max_scale,step:.1,value:i.tagStrength,onInput:e=>dg({tagStrength:Number(e.currentTarget.value)}),"aria-valuetext":i.tagStrength>1?`${i.tagStrength.toFixed(1)}, tag guidance on`:`1, off`,"aria-describedby":`settings-tags-hint`}),G(`span`,{class:`mono`,children:i.tagStrength>1?i.tagStrength.toFixed(1):`off`})]}),G(`span`,{class:`hint`,id:`settings-tags-hint`,children:`Guidance for lines with nonverbal tags (laugh, sigh…): stronger makes the tags louder. On those lines it replaces voice guidance (the server allows one at a time); 1 turns it off.`})]})]}),o.reRegistered.length>0&&G(`p`,{class:`proj-note`,children:[`Restored after a server restart: `,o.reRegistered.join(`, `),`.`]}),o.issues.length>0&&G(`ul`,{class:`proj-issues`,"aria-label":`Voices that couldn’t be restored`,children:o.issues.map(e=>G(`li`,{children:[`Couldn’t restore `,e]},e))})]})})}var Pb=I(!1),Fb=I(!1),Ib=I(null),Lb={live:`Server`,web:`In this browser`,fixture:`Server · controls off`,offline:`Demo audio`};function Rb(e){switch(e.kind){case`web`:return`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`;case`live`:return`A ZONOS server renders every voice; controls and painted words are applied there.`;case`fixture`:return`This server can’t apply controls: renders are sent without them, so you hear each base voice as is.${uc.value?` Its voice embeddings are stand-ins, so saving shaped voices is off.`:``}`;default:return`Demo audio: no ZONOS server answered. Voices and takes are placeholders made in this browser (a babbling synthesizer that follows every control).`}}function zb({menuitem:e}){let t=ua.value;return t?G(`button`,{class:`pill pill-${t.kind}${e?` proj-item`:``}`,role:e?`menuitem`:void 0,"aria-haspopup":`dialog`,"aria-expanded":Fb.value,onClick:()=>Fb.value=!Fb.value,title:`What this studio is connected to`,id:`backend-pill`,children:[G(`span`,{class:`pill-dot`}),G(`span`,{class:`pill-text`,children:Lb[t.kind]})]}):null}var Bb=e=>e?`yes`:`no`;function Vb(){let e=ua.value,t=Fb.value,n=P(null),[r,i]=M(null);if(pt(()=>{if(!t)return i(null);let e=document.getElementById(`backend-pill`)?.getBoundingClientRect();i(e?{top:`${e.bottom+6}px`,right:`${Math.max(8,window.innerWidth-e.right)}px`}:{top:`60px`,right:`12px`})},[t]),N(()=>{if(!t||!r)return;let e=document.activeElement,i=e=>{!n.current?.contains(e.target)&&!e.target.closest?.(`#backend-pill`)&&(Fb.value=!1)};return document.addEventListener(`pointerdown`,i),n.current&&Sf(n.current),()=>{document.removeEventListener(`pointerdown`,i),e?.focus({preventScroll:!0})}},[t,!!r]),!e||!t||!r)return null;let a=[[`Server`,e.kind===`web`?`this browser`:e.kind===`offline`?`none`:e.server||location.origin],[`Voice bundle`,e.spec.bundle],[`Speech editing`,Bb(e.edit.speech_editing)],[`Speech recognition`,Bb(e.edit.edit_transcribe)],[`Pronunciation input`,Bb(!!e.pron.phoneme_tokens)],[`Nonverbal tags`,Bb(!!e.tags)],[`Projects on the server`,Bb(!!e.projects)]];return Ye(G(`div`,{ref:n,class:`backend-panel`,role:`dialog`,"aria-label":`Connection`,style:r,onKeyDown:Cf(()=>n.current,()=>Fb.value=!1),children:[G(`header`,{children:[G(`b`,{children:Lb[e.kind]}),G(`button`,{class:`icon-btn sm`,onClick:()=>Fb.value=!1,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`,size:13})})]}),G(`p`,{children:Rb(e)}),G(`dl`,{children:a.map(([e,t])=>G(j,{children:[G(`dt`,{children:e}),G(`dd`,{children:t})]},e))})]}),document.body)}var Hb=`zvs.bannerDismissed`,Ub=I(sessionStorage.getItem(Hb)===`1`);function Wb(){let e=ua.value;return!e||e.kind!==`offline`&&e.kind!==`fixture`||Ub.value?null:G(`div`,{class:`backend-banner`,role:`status`,children:[G(K,{name:`alert`,size:14}),G(`span`,{children:e.kind===`offline`?`Demo audio: no ZONOS server answered — voices and takes are placeholders.`:`This server can’t apply controls: you hear each base voice as is.`}),G(`button`,{class:`link`,onClick:()=>Fb.value=!0,children:`details`}),G(`button`,{class:`link`,onClick:()=>{sessionStorage.setItem(Hb,`1`),Ub.value=!0},children:`Dismiss for this session`})]})}function Gb({onSettings:e}){let[t,n]=M(!1),r=P(null),i=P(null),a=P(null);N(()=>{if(!t)return;i.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>!r.current?.contains(e.target)&&n(!1);return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]);let o=(e=!0)=>{n(!1),e&&a.current?.focus()},s=e=>()=>{o(!1),e()};return G(`div`,{ref:r,class:`top-menu`,children:[G(`button`,{ref:a,class:`icon-btn`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(!t),"aria-label":`More`,title:`More`,children:G(K,{name:`more`})}),t&&G(`div`,{ref:i,class:`top-menu-list`,role:`menu`,"aria-label":`More`,onKeyDown:e=>{e.stopPropagation();let t=[...i.current.querySelectorAll(`[role="menuitem"]:not([disabled])`)],n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)o();else if(e.key===`Tab`)return o(!1);else return;e.preventDefault()},children:[G(zb,{menuitem:!0}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(e),children:[G(K,{name:`gear`,size:14}),` Project settings…`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(Zg),children:[G(K,{name:Yg.value===`dark`?`sun`:`moon`,size:14}),` `,Yg.value===`dark`?`Light theme`:`Dark theme`]}),G(`button`,{role:`menuitem`,class:`proj-item`,onClick:s(()=>Pb.value=!0),children:[G(`span`,{class:`top-menu-key`,children:`?`}),` Keyboard shortcuts`]})]})]})}var Kb=[[`Space`,`play / stop`],[`↵ · ⇧↵`,`Cast: speak the text · new line in it`],[`A / B`,`hear the design / the original voice (Cast)`],[`⌘Z / Ctrl+Z`,`undo`],[`⇧⌘Z / Ctrl+Y`,`redo`],[`1 2 3`,`Cast, Direct, Edit`],[`Arrows`,`nudge the focused control (⇧ for more)`],[`Home / End`,`a slider to its minimum / maximum`],[`0 / Delete`,`reset the focused control`],[`double-click`,`reset a slider or the mood pad`],[`scroll on the Who map`,`pitch (the map focused, or with ⌘ / Ctrl)`],[`+ − Delete`,`a mood landmark: stronger, weaker, off`],[`(S@vQn)`,`X-SAMPA pronunciation in a line (phoneme-token checkpoints); click its IPA chip to edit`],[`/ə/`,`look up the selected words’ pronunciations`],[`<`,`in a text field: nonverbal tag palette (point tag at the caret, span tag around the selected words; NV checkpoint)`],[`‹› Tag`,`Direct: tag the selected words from the paint bar`],[`?`,`this sheet`]],qb=[[`Space`,`play / stop the script`],[`R`,`render the focused line`],[`S`,`star the playing take (the script plays it)`],[`⌘↵ / Ctrl+Enter`,`save the line text while editing`],[`↵ (line text focused)`,`paint the selected words · ⇧← / ⇧→ extend the selection`]],Jb=[[`Space`,`play / pause from the cursor`],[`A / B`,`the version / the selected take`],[`⌘↵ / Ctrl+Enter`,`generate takes (also while typing)`],[`K`,`keep the selected take as a new version`],[`⌘Z / ⇧⌘Z`,`step through versions`],[`[ / ] · 0`,`zoom the waveform out / in · fit`],[`⌘-wheel`,`zoom around the pointer`],[`← / →`,`move the cursor 1 s`],[`click a word`,`select it and hear it (pre-roll optional)`],[`← / → (word selected)`,`nudge its edge 10 ms · ⇧ 50 ms`],[`, / .`,`start / end edge of the selected word`],[`Tab / ⇧Tab`,`next / previous word (from the transcript or a word)`],[`↵ · Esc`,`play the word · done`],[`⌥-drag an edge`,`open a gap at a shared boundary`]];function Yb(){let e=Pb.value,t=P(null);if(pt(()=>{if(!e)return;let n=document.activeElement;return Ta.value=!0,t.current&&Sf(t.current),()=>{Ta.value=!1,(n?.isConnected?n:document.querySelector(`#keys-btn`))?.focus({preventScroll:!0})}},[e]),!e)return null;let n=()=>Pb.value=!1;return G(`div`,{class:`sheet-backdrop`,onClick:n,children:G(`div`,{ref:t,class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,onClick:e=>e.stopPropagation(),onKeyDown:Cf(()=>t.current,n),children:[G(`header`,{class:`sheet-head`,children:[G(`h2`,{children:`Keyboard`}),G(`button`,{class:`icon-btn`,onClick:n,"aria-label":`Close`,title:`Close (Esc)`,children:G(K,{name:`x`})})]}),G(`dl`,{children:Kb.map(([e,t])=>G(j,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))}),G(`h3`,{class:`sheet-sub`,children:`Direct`}),G(`dl`,{children:qb.map(([e,t])=>G(j,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))}),G(`h3`,{class:`sheet-sub`,children:`Edit`}),G(`dl`,{children:Jb.map(([e,t])=>G(j,{children:[G(`dt`,{children:G(`kbd`,{children:e})}),G(`dd`,{children:t})]},e))})]})})}var Xb=1e4;function Zb(e){let t=new URL(location.href);for(let[n,r]of Object.entries(e))t.searchParams.set(n,r);location.href=t.toString()}function Qb(){let[t,n]=M(!1),[r,i]=M(``),[a,o]=M(!1),s=Ib.value,c=da.value;if(N(()=>{let e=setTimeout(()=>n(!0),Xb);return()=>clearTimeout(e)},[]),N(()=>{(c||s)&&lo().then(o)},[!!c,!!s]),s)return G(`div`,{class:`empty boot-consent`,role:`dialog`,"aria-labelledby":`boot-consent-title`,children:[G(`h2`,{id:`boot-consent-title`,children:`No server answered`}),G(`p`,{children:`Run the voice engine in this browser? Download ≈ 1.9 GB once; cached in this browser.`}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>s(!0),children:`Run in this browser`}),G(`button`,{class:`btn`,onClick:()=>location.reload(),children:`Retry the server`}),G(`button`,{class:`btn ghost`,onClick:()=>s(!1),children:`Try it with demo audio`})]})]});if(c){let t=e();return G(`div`,{class:`empty boot-error`,children:[G(`h2`,{children:t?`The in-browser engine couldn’t start`:`Can’t reach the studio server`}),G(`p`,{class:`error-line`,children:[t?``:`Tried ${oo()}: `,c]}),G(`div`,{class:`row gap-s`,children:[G(`button`,{class:`btn primary`,onClick:()=>location.reload(),children:`Try again`}),G(`button`,{class:`btn`,onClick:()=>Zb({api:`offline`}),children:`Work offline`}),a&&!t&&G(`button`,{class:`btn`,onClick:()=>Zb({api:`web`}),children:`Run in this browser`})]}),G(`form`,{class:`boot-server`,onSubmit:e=>{e.preventDefault(),r.trim()&&Zb({api:`live`,server:r.trim()})},children:[G(`label`,{children:[`Server URL`,G(`input`,{class:`input`,type:`url`,placeholder:`https://host:port`,value:r,onInput:e=>i(e.currentTarget.value)})]}),G(`button`,{class:`btn sm`,type:`submit`,disabled:!r.trim(),children:`Connect`})]})]})}let l=fa.value;return G(`div`,{class:`empty`,children:[l?G($l,{d:l}):G(`div`,{class:`loader`}),G(`p`,{children:l&&l.fraction>=1?`Starting the voice engine…`:pa.value}),t&&!l&&G(`p`,{class:`muted small`,children:[`Still waiting for `,oo(),`.`,` `,G(`button`,{class:`link`,onClick:()=>location.reload(),children:`Retry`})]})]})}async function $b(){let e;try{e=await co({confirmWeb:()=>{let{promise:e,resolve:t}=Promise.withResolvers();return Ib.value=e=>{Ib.value=null,t(e)},e}})}catch(e){da.value=e instanceof Error?e.message:String(e);return}pa.value=`Loading voices…`,await fc(),await qh(e),hc(),Kl()}var ex=[{id:`cast`,label:`Cast`,hint:`find or design a voice`},{id:`direct`,label:`Direct`,hint:`perform a script with one or more voices`},{id:`edit`,label:`Edit`,hint:`change words in recorded speech`}];function tx(e){if(!Ta.value&&!Pb.value&&Da.value?.(e))return;let t=e.metaKey||e.ctrlKey;if(t&&e.key.toLowerCase()===`z`&&!uy(e.target)){e.preventDefault(),Ca.value===`edit`?e.shiftKey?gm():hm():e.shiftKey?wa.value?.redo():wa.value?.undo();return}if(t&&e.key.toLowerCase()===`y`&&!uy(e.target)){e.preventDefault(),Ca.value===`edit`?gm():wa.value?.redo();return}if(t||e.altKey||uy(e.target))return;let n=e.target?.getAttribute?.(`role`);if(e.key===` `&&!(e.target instanceof HTMLButtonElement)&&n!==`slider`&&n!==`button`)e.preventDefault(),B.value?Is():Oa.value?.();else if(Ca.value===`cast`&&(e.key===`a`||e.key===`b`))Jl(e.key===`a`?`A`:`B`);else if(e.key===`?`&&!Ta.value)Pb.value=!Pb.value;else if(e.key===`Escape`){if(e.defaultPrevented)return;Fb.value&&=(e.preventDefault(),!1)}else/^[1-3]$/.test(e.key)&&!Ta.value&&(Ca.value=ex[Number(e.key)-1].id)}function nx(e){if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=ex[(ex.findIndex(e=>e.id===Ca.value)+(e.key===`ArrowRight`?1:ex.length-1))%ex.length];Ca.value=t.id,e.currentTarget.querySelector(`[data-act="${t.id}"]`)?.focus()}function rx(){`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data?.type===`zvs-update`&&z(`A new version is ready`,`info`,{label:`Reload`,run:()=>location.reload()})})}function ix({t:e}){return G(`div`,{class:`toast toast-${e.kind}`,role:e.kind===`error`?`alert`:void 0,children:[G(`span`,{class:`toast-text`,children:e.text}),e.action&&G(`button`,{class:`link toast-action`,onClick:()=>{Fa(e.id),e.action.run()},children:e.action.label}),G(`button`,{class:`icon-btn sm toast-x`,onClick:()=>Fa(e.id),"aria-label":`Dismiss`,children:G(K,{name:`x`,size:12})})]})}function ax(){N(()=>($b(),rx(),window.addEventListener(`keydown`,tx),()=>window.removeEventListener(`keydown`,tx)),[]),N(()=>{let e=()=>{let e=location.hash.slice(1),t=e===`scene`?`direct`:e;ex.some(e=>e.id===t)?(Ca.value=t,e!==t&&history.replaceState(null,``,`#${t}`)):history.replaceState(null,``,`#${Ca.value}`)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),N(()=>{location.hash.slice(1)!==Ca.value&&history.replaceState(null,``,`#${Ca.value}`)},[Ca.value]);let e=wa.value;return G(`div`,{class:`app`,children:[G(`header`,{class:`topbar`,children:[G(`div`,{class:`brand`,"aria-label":`Zyphra Voice Studio`,children:[G(jb,{size:22}),G(Mb,{height:11}),G(`span`,{class:`brand-sep`,"aria-hidden":`true`}),G(`span`,{class:`brand-product`,children:`Voice Studio`})]}),G(Hg,{}),G(`nav`,{class:`acts`,role:`tablist`,"aria-label":`Acts`,onKeyDown:nx,children:ex.map((e,t)=>G(`button`,{role:`tab`,"data-act":e.id,"aria-selected":Ca.value===e.id,"aria-controls":`stage`,tabIndex:Ca.value===e.id?0:-1,class:`act${Ca.value===e.id?` is-on`:``}`,onClick:()=>Ca.value=e.id,title:`${e.hint} (${t+1})`,children:[G(`span`,{class:`act-n`,children:t+1}),e.label]}))}),G(`div`,{class:`topbar-right`,children:[!bg.value&&G(zb,{}),G(`button`,{class:`icon-btn`,disabled:!e?.canUndo.value,onClick:()=>e?.undo(),title:`Undo (⌘Z / Ctrl+Z)`,"aria-label":`Undo`,children:G(K,{name:`undo`})}),G(`button`,{class:`icon-btn`,disabled:!e?.canRedo.value,onClick:()=>e?.redo(),title:`Redo (⇧⌘Z / Ctrl+Y)`,"aria-label":`Redo`,children:G(K,{name:`redo`})}),bg.value?G(Gb,{onSettings:()=>Ea.value=!0}):G(j,{children:[G(`button`,{class:`icon-btn`,onClick:Zg,title:Yg.value===`dark`?`Light theme`:`Dark theme`,"aria-label":Yg.value===`dark`?`Switch to the light theme`:`Switch to the dark theme`,children:G(K,{name:Yg.value===`dark`?`sun`:`moon`})}),G(`button`,{id:`keys-btn`,class:`icon-btn`,onClick:()=>Pb.value=!Pb.value,title:`Keyboard shortcuts (?)`,"aria-label":`Keyboard shortcuts`,children:`?`})]})]})]}),G(Wb,{}),G(`main`,{class:`stage`,id:`stage`,children:ua.value?Ca.value===`cast`?G(cy,{}):Ca.value===`direct`?G(Xy,{}):G(Ab,{}):G(Qb,{})}),G(`div`,{class:`toasts`,onPointerEnter:()=>Ia(!0),onPointerLeave:()=>Ia(!1),children:[ma.value&&G(`div`,{class:`toast toast-dl`,children:G($l,{d:ma.value})}),G(`div`,{class:`toasts-live`,"aria-live":`polite`,children:ka.value.filter(e=>e.kind!==`error`).map(e=>G(ix,{t:e},e.id))}),G(`div`,{class:`toasts-live`,"aria-live":`assertive`,children:ka.value.filter(e=>e.kind===`error`).map(e=>G(ix,{t:e},e.id))})]}),G(Yb,{}),G(Vb,{}),G(Nb,{}),G(p_,{}),G(S_,{}),G(Wg,{}),G(Ef,{})]})}qe(G(ax,{}),document.getElementById(`app`)),`serviceWorker`in navigator&&addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{scope:`/`}).catch(()=>{})}); \ No newline at end of file diff --git a/studio/assets/web-engine-DLmQsyPj.js b/studio/assets/web-engine-BJErJyzx.js similarity index 93% rename from studio/assets/web-engine-DLmQsyPj.js rename to studio/assets/web-engine-BJErJyzx.js index bca7fb1b5ace7445e0891305029a80ec50382b08..6d0073757b7bdde2a0bba7f3aa99b57028777bff 100644 --- a/studio/assets/web-engine-DLmQsyPj.js +++ b/studio/assets/web-engine-BJErJyzx.js @@ -1 +1 @@ -(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=[`M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z`,`M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z`,`M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z`],t=`0 0 224 164`,n=[`M465.55,213.433L465.55,200L208.302,200L208.302,217.413L423.297,217.413L200.017,386.567L200.017,400L457.265,400L457.265,382.587L242.271,382.587L465.55,213.433Z`,`M851.628,200L816.003,200L707.884,287.313L599.766,200L564.141,200L687.586,299.751C689.243,302.736 693.386,310.448 693.386,320.398L693.386,400L721.969,400L721.969,320.398C721.969,310.448 725.697,302.985 727.768,299.751L851.628,200Z`,`M1108.047,200L969.688,200L969.688,400L998.686,400L998.686,308.458C998.686,306.219 1000.343,303.483 1011.527,303.483L1107.633,303.483C1154.857,303.483 1193.382,280.348 1193.382,251.99C1193.382,223.632 1155.271,200.249 1108.047,200ZM1009.87,286.318C1005.728,286.318 1002.414,286.567 998.686,287.065L998.686,217.662L1107.633,217.662C1139.116,217.662 1164.799,233.333 1164.799,252.239C1164.799,271.144 1139.116,286.318 1107.633,286.318L1009.87,286.318Z`,`M1524.365,400L1524.365,200L1495.368,200L1495.368,276.617C1495.368,283.831 1480.041,285.821 1466.785,285.821L1362.809,285.821C1351.21,285.821 1340.44,286.816 1334.226,289.552L1334.226,200L1305.229,200L1305.229,400L1334.226,400L1334.226,312.687C1334.226,306.716 1349.139,303.483 1362.809,303.483L1468.442,303.483C1479.212,303.234 1489.569,302.488 1494.954,300L1494.954,400L1524.365,400Z`,`M1894.702,400L1829.665,311.443C1823.037,302.239 1819.309,301.493 1819.309,301.493C1854.934,297.015 1884.76,275.622 1884.76,251.741C1884.76,223.383 1846.235,200 1799.011,200L1661.067,200L1661.067,400L1690.064,400L1690.064,308.458C1690.064,306.219 1691.721,303.483 1702.906,303.483L1777.056,303.483C1777.47,303.483 1791.555,302.985 1798.183,312.189L1862.805,400L1894.702,400ZM1689.65,286.816L1689.65,217.413L1798.597,217.413C1830.08,217.413 1855.763,232.836 1855.763,251.741C1855.763,270.647 1830.08,286.07 1798.597,286.07L1700.835,286.07C1696.692,286.07 1693.378,286.318 1689.65,286.816Z`,`M2030.575,400L2067.029,337.065C2067.443,336.567 2073.657,328.109 2095.612,328.109L2156.921,328.109C2167.691,328.109 2176.39,327.363 2184.261,325.622L2227.343,400L2257.583,400L2141.593,200L2116.739,200L2000.335,400L2030.575,400ZM2129.166,230.597L2175.147,309.453C2172.662,309.95 2166.862,310.945 2157.335,310.945L2096.026,310.945C2091.055,310.945 2086.913,311.194 2082.356,311.692L2129.166,230.597Z`],r=`200 200 2058 200`,i={play:`M7 4.5v15l12-7.5z`,stop:`M6 6h12v12H6z`,dice:`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm3 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm8 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm-4-3.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,star:`M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.9L12 16.9l-5.3 2.8 1-5.9-4.2-4.1 5.9-.8z`,trash:`M5 7h14M10 7V4.5h4V7m-7 0 1 13h8l1-13`,plus:`M12 5v14M5 12h14`,upload:`M12 16V4m0 0L7 9m5-5 5 5M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3`,mic:`M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3`,undo:`M9 7 4 12l5 5M4 12h11a5 5 0 0 1 0 10h-2`,redo:`M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10h2`,refresh:`M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6`,x:`M6 6l12 12M18 6 6 18`,save:`M5 4h11l3 3v13H5zM8 4v5h7V4M8 20v-6h8v6`,download:`M12 4v12m0 0-5-5m5 5 5-5M4 20h16`,up:`M6 15l6-6 6 6`,down:`M6 9l6 6 6-6`,edit:`M4 20h4L19 9l-4-4L4 16zM14 6l4 4`,"edit-speech":`M6 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM6 14a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM20 5 8.5 13M20 19 8.5 11M12 12h2`,home:`M4 11 12 4l8 7v9h-5v-6H9v6H4z`,copy:`M9 9h10v11H9zM5 15V4h10`,wand:`M5 19 15 9m2-5v3m0 0v3m0-3h3m-3 0h-3M6 5v2m0 0v2m0-2h2m-2 0H4`,expand:`M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5`,sliders:`M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4`,globe:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z`,film:`M4 5h16v14H4zM8 5v14M16 5v14M4 9h4M4 15h4M16 9h4M16 15h4`,sun:`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8zM12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`,moon:`M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z`,alert:`M12 3.5 2.5 20h19zM12 10v4.5M12 17.2v.1`,left:`M15 6l-6 6 6 6`,right:`M9 6l6 6-6 6`,more:`M5 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,speaker:`M4 9h4l5-4v14l-5-4H4zM16 9a4 4 0 0 1 0 6M18.5 6.5a7.5 7.5 0 0 1 0 11`,brush:`M15 4l5 5-8 8-5-5zM7 12l5 5-2 2a3 3 0 0 1-4.2 0l-1.6-1.6a3 3 0 0 1 0-4.2z`,gear:`M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7zM12 2.5v2.3M12 19.2v2.3M2.5 12h2.3M19.2 12h2.3M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6`},a={play:!0,stop:!0,dice:!0,more:!0},o=`supports-zerogpu-headers`,s=`zerogpu-headers`,c=/^\/v2\/generate$/,l=typeof window<`u`&&window.parent!==window&&location.hostname.endsWith(`.hf.space`)?`https://huggingface.co`:null,u=!1;l&&(window.addEventListener(`message`,e=>{e.origin===l&&e.data===o&&(u=!0)}),window.parent.postMessage(o,l));var d=()=>u;function f(){if(!l||!u)return Promise.resolve(null);let{promise:e,resolve:t}=Promise.withResolvers(),n=new MessageChannel,r=e=>{clearTimeout(i),n.port1.close(),t(e)},i=setTimeout(()=>r(null),5e3);return n.port1.onmessage=({data:e})=>r(e&&typeof e==`object`?e:null),window.parent.postMessage(s,l,[n.port2]),e}async function p(e,t){if(!u)return t;let n=typeof e==`string`?e:e instanceof URL?e.href:e.url;if(!c.test(new URL(n,location.href).pathname))return t;let r=await f();if(!r)return t;let i=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));for(let[e,t]of Object.entries(r))i.set(e,t);return{...t,headers:i}}var m=new URLSearchParams(location.search).get(`engine`)||`/web-engine/engine.js`,h=null,g=()=>h??=import(m),_=!1,v=()=>_;function y(){_=!0}var b=(e,t)=>_?g().then(n=>n.localFetch(e,t)):p(e,t).then(t=>fetch(e,t)),x=1e6,S=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(e/x))} MB`;function C(e){if(e<5)return`a few seconds left`;if(e<60)return`about ${Math.ceil(e/5)*5} s left`;let t=Math.floor(e/60),n=Math.round(e%60/10)*10;return`about ${n&&t<10?`${t} min ${n} s`:`${Math.round(e/60)} min`} left`}function w(){let e=``,t=[];return n=>{let r=n.models.join(`+`);r!==e&&(e=r,t=[]);let i=performance.now();for(t.push({t:i,fetched:n.fetched});t.length>2&&i-t[1].t>8e3;)t.shift();let a=(i-t[0].t)/1e3,o=a>=2?(n.fetched-t[0].fetched)/a:0,s=Math.max(0,n.total-n.loaded),c=[`${S(n.loaded)} of ${S(n.total)}`];return o>.05*x&&s>0&&c.push(`${(o/x).toFixed(o>=10*x?0:1)} MB/s`,C(s/o)),{label:`${n.fetched>0?`Downloading`:`Loading`} ${n.models.map(E).join(` + `)}`,fraction:n.total?Math.min(1,n.loaded/n.total):0,detail:c.join(` · `)}}}var T={backbone:`voice model`,zac:`audio codec`,encoder:`voice encoder`,encoders:`voice encoders`},E=e=>T[e]??e;async function D(e){_=!0;let{engine:t}=await g(),n=w();await t.init(t=>e(n(t)))}async function O(e){let{engine:t}=await g(),n=w();t.onEncoderProgress(t=>e(n(t)))}var k=async()=>`gpu`in navigator&&await fetch(m,{method:`HEAD`}).then(e=>e.ok,()=>!1);export{v as a,a as c,t as d,n as f,b as i,i as l,y as n,k as o,r as p,D as r,d as s,O as t,e as u}; \ No newline at end of file +(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=[`M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z`,`M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z`,`M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z`],t=`0 0 224 164`,n=[`M465.55,213.433L465.55,200L208.302,200L208.302,217.413L423.297,217.413L200.017,386.567L200.017,400L457.265,400L457.265,382.587L242.271,382.587L465.55,213.433Z`,`M851.628,200L816.003,200L707.884,287.313L599.766,200L564.141,200L687.586,299.751C689.243,302.736 693.386,310.448 693.386,320.398L693.386,400L721.969,400L721.969,320.398C721.969,310.448 725.697,302.985 727.768,299.751L851.628,200Z`,`M1108.047,200L969.688,200L969.688,400L998.686,400L998.686,308.458C998.686,306.219 1000.343,303.483 1011.527,303.483L1107.633,303.483C1154.857,303.483 1193.382,280.348 1193.382,251.99C1193.382,223.632 1155.271,200.249 1108.047,200ZM1009.87,286.318C1005.728,286.318 1002.414,286.567 998.686,287.065L998.686,217.662L1107.633,217.662C1139.116,217.662 1164.799,233.333 1164.799,252.239C1164.799,271.144 1139.116,286.318 1107.633,286.318L1009.87,286.318Z`,`M1524.365,400L1524.365,200L1495.368,200L1495.368,276.617C1495.368,283.831 1480.041,285.821 1466.785,285.821L1362.809,285.821C1351.21,285.821 1340.44,286.816 1334.226,289.552L1334.226,200L1305.229,200L1305.229,400L1334.226,400L1334.226,312.687C1334.226,306.716 1349.139,303.483 1362.809,303.483L1468.442,303.483C1479.212,303.234 1489.569,302.488 1494.954,300L1494.954,400L1524.365,400Z`,`M1894.702,400L1829.665,311.443C1823.037,302.239 1819.309,301.493 1819.309,301.493C1854.934,297.015 1884.76,275.622 1884.76,251.741C1884.76,223.383 1846.235,200 1799.011,200L1661.067,200L1661.067,400L1690.064,400L1690.064,308.458C1690.064,306.219 1691.721,303.483 1702.906,303.483L1777.056,303.483C1777.47,303.483 1791.555,302.985 1798.183,312.189L1862.805,400L1894.702,400ZM1689.65,286.816L1689.65,217.413L1798.597,217.413C1830.08,217.413 1855.763,232.836 1855.763,251.741C1855.763,270.647 1830.08,286.07 1798.597,286.07L1700.835,286.07C1696.692,286.07 1693.378,286.318 1689.65,286.816Z`,`M2030.575,400L2067.029,337.065C2067.443,336.567 2073.657,328.109 2095.612,328.109L2156.921,328.109C2167.691,328.109 2176.39,327.363 2184.261,325.622L2227.343,400L2257.583,400L2141.593,200L2116.739,200L2000.335,400L2030.575,400ZM2129.166,230.597L2175.147,309.453C2172.662,309.95 2166.862,310.945 2157.335,310.945L2096.026,310.945C2091.055,310.945 2086.913,311.194 2082.356,311.692L2129.166,230.597Z`],r=`200 200 2058 200`,i={play:`M7 4.5v15l12-7.5z`,stop:`M6 6h12v12H6z`,dice:`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm3 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm8 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm-4-3.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,star:`M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.9L12 16.9l-5.3 2.8 1-5.9-4.2-4.1 5.9-.8z`,trash:`M5 7h14M10 7V4.5h4V7m-7 0 1 13h8l1-13`,plus:`M12 5v14M5 12h14`,upload:`M12 16V4m0 0L7 9m5-5 5 5M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3`,mic:`M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3`,undo:`M9 7 4 12l5 5M4 12h11a5 5 0 0 1 0 10h-2`,redo:`M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10h2`,refresh:`M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6`,x:`M6 6l12 12M18 6 6 18`,save:`M5 4h11l3 3v13H5zM8 4v5h7V4M8 20v-6h8v6`,download:`M12 4v12m0 0-5-5m5 5 5-5M4 20h16`,up:`M6 15l6-6 6 6`,down:`M6 9l6 6 6-6`,edit:`M4 20h4L19 9l-4-4L4 16zM14 6l4 4`,"edit-speech":`M6 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM6 14a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM20 5 8.5 13M20 19 8.5 11M12 12h2`,home:`M4 11 12 4l8 7v9h-5v-6H9v6H4z`,copy:`M9 9h10v11H9zM5 15V4h10`,wand:`M5 19 15 9m2-5v3m0 0v3m0-3h3m-3 0h-3M6 5v2m0 0v2m0-2h2m-2 0H4`,expand:`M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5`,sliders:`M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4`,globe:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z`,film:`M4 5h16v14H4zM8 5v14M16 5v14M4 9h4M4 15h4M16 9h4M16 15h4`,sun:`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8zM12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`,moon:`M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z`,alert:`M12 3.5 2.5 20h19zM12 10v4.5M12 17.2v.1`,left:`M15 6l-6 6 6 6`,right:`M9 6l6 6-6 6`,more:`M5 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,speaker:`M4 9h4l5-4v14l-5-4H4zM16 9a4 4 0 0 1 0 6M18.5 6.5a7.5 7.5 0 0 1 0 11`,brush:`M15 4l5 5-8 8-5-5zM7 12l5 5-2 2a3 3 0 0 1-4.2 0l-1.6-1.6a3 3 0 0 1 0-4.2z`,gear:`M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7zM12 2.5v2.3M12 19.2v2.3M2.5 12h2.3M19.2 12h2.3M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6`},a={play:!0,stop:!0,dice:!0,more:!0},o=`supports-zerogpu-headers`,s=`zerogpu-headers`,c=/^\/v2\/generate$/,l=typeof window<`u`&&window.parent!==window&&location.hostname.endsWith(`.hf.space`)?`https://huggingface.co`:null,u=!1;l&&(window.addEventListener(`message`,e=>{e.origin===l&&e.data===o&&(u=!0)}),window.parent.postMessage(o,l));var d=()=>u;function f(){if(!l||!u)return Promise.resolve(null);let{promise:e,resolve:t}=Promise.withResolvers(),n=new MessageChannel,r=e=>{clearTimeout(i),n.port1.close(),t(e)},i=setTimeout(()=>r(null),5e3);return n.port1.onmessage=({data:e})=>r(e&&typeof e==`object`?e:null),window.parent.postMessage(s,l,[n.port2]),e}async function p(e,t){if(!u)return t;let n=typeof e==`string`?e:e instanceof URL?e.href:e.url;if(!c.test(new URL(n,location.href).pathname))return t;let r=await f();if(!r)return t;let i=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));for(let[e,t]of Object.entries(r))i.set(e,t);return{...t,headers:i}}var m=new URLSearchParams(location.search).get(`engine`)||`/web-engine/engine.js`,h=null,g=()=>h??=import(m),_=!1,v=()=>_;function y(){_=!0}var b=(e,t)=>_?g().then(n=>n.localFetch(e,t)):p(e,t).then(t=>fetch(e,t)),x=1e6,S=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(e/x))} MB`;function C(e){if(e<5)return`a few seconds left`;if(e<60)return`about ${Math.ceil(e/5)*5} s left`;let t=Math.floor(e/60),n=Math.round(e%60/10)*10;return`about ${n&&t<10?`${t} min ${n} s`:`${Math.round(e/60)} min`} left`}function w(){let e=``,t=[];return n=>{let r=n.models.join(`+`);r!==e&&(e=r,t=[]);let i=performance.now();for(t.push({t:i,fetched:n.fetched});t.length>2&&i-t[1].t>8e3;)t.shift();let a=(i-t[0].t)/1e3,o=a>=2?(n.fetched-t[0].fetched)/a:0,s=Math.max(0,n.total-n.loaded),c=[`${S(n.loaded)} of ${S(n.total)}`];return o>.05*x&&s>0&&c.push(`${(o/x).toFixed(o>=10*x?0:1)} MB/s`,C(s/o)),{label:`${n.fetched>0?`Downloading`:`Loading`} ${n.models.map(E).join(` + `)}`,fraction:n.total?Math.min(1,n.loaded/n.total):0,detail:c.join(` · `)}}}var T={backbone:`voice model`,zac:`audio codec`,"zac-full_mr":`full-size audio decoder`,encoder:`voice encoder`,encoders:`voice encoders`},E=e=>T[e]??e;async function D(e){_=!0;let{engine:t}=await g(),n=w();await t.init(t=>e(n(t)))}async function O(e){let{engine:t}=await g(),n=w();t.onEncoderProgress(t=>e(n(t)))}var k=async()=>`gpu`in navigator&&await fetch(m,{method:`HEAD`}).then(e=>e.ok,()=>!1);export{v as a,a as c,t as d,n as f,b as i,i as l,y as n,k as o,r as p,D as r,d as s,O as t,e as u}; \ No newline at end of file diff --git a/studio/index.html b/studio/index.html index 21561d99e179ffbd83c9b5a0616a557cfe6e0ff8..f6a491a13dbf835bc8b2efe58e8b0626d35577d9 100644 --- a/studio/index.html +++ b/studio/index.html @@ -7,9 +7,9 @@ Zyphra Voice - - - + + + diff --git a/studio/lite.html b/studio/lite.html index 0403c3794d8e8f2383b2136c683f1f846d67dc6e..3937de01ca449af1472c812ebf4262d0ce9fcc0e 100644 --- a/studio/lite.html +++ b/studio/lite.html @@ -7,10 +7,10 @@ Zyphra Voice Cloning - - + + - + diff --git a/studio/studio.html b/studio/studio.html index 278459c0bfd70a454ed169d3b3e55c1e9a23e7bd..3f663bb3b870518f6e5228773f8e362a79a926f6 100644 --- a/studio/studio.html +++ b/studio/studio.html @@ -10,8 +10,8 @@ - - + + diff --git a/studio/sw.js b/studio/sw.js index 3fe528520b7c4a13f65e450934bf75c771bd109e..690a36024943c4330cc3f2aa761b892ada375c57 100644 --- a/studio/sw.js +++ b/studio/sw.js @@ -14,7 +14,7 @@ // cache under it). clients.claim on activate only takes over pages nothing controls yet (the first visit), which then // read this version's cache; a cache miss still falls back to the network. -const VERSION = "a8c24f17068f"; +const VERSION = "140f404d91d3"; const PRECACHE = [ "/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2", "/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2", @@ -29,9 +29,9 @@ const PRECACHE = [ "/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff", "/assets/latin-500-DKfSw4PI.css", "/assets/latin-500-DPgjq1zP.js", - "/assets/studio-CUnPlHU1.js", + "/assets/studio-0qrBnVUE.js", "/assets/studio-Cxzv5JLi.css", - "/assets/web-engine-DLmQsyPj.js", + "/assets/web-engine-BJErJyzx.js", "/assets/web-engine-xKv10YAh.css", "/studio.html", "/theme-boot.js" diff --git a/zonos3/reference/synth.py b/zonos3/reference/synth.py index 2548e16aa1ccb69e9ad51adebb7af2bd531e58ff..70cfdc04eccadd71c13597e3309d106cbdc47ae0 100644 --- a/zonos3/reference/synth.py +++ b/zonos3/reference/synth.py @@ -88,11 +88,13 @@ class ReferenceAssets: self._normalizer = load_normalizer(warmup=False) return self._normalizer - def decoder(self, codec: str, device: torch.device): - """The matched codec's iSTFT decoder on ``device`` (zonos3.tokenizer.matched_codec).""" - key = (codec, str(device)) + def decoder(self, codec: str, device: torch.device, decoder: str | None = None): + """A matched codec's iSTFT decoder (``decoder``: its id, None = the codec's default) on ``device`` + (zonos3.tokenizer.matched_codec).""" + from zonos3.tokenizer import matched_codec + + key = (codec, matched_codec.decoder_id(codec, decoder), str(device)) if key not in self._decoders: - from zonos3.tokenizer import matched_codec from zonos3.utils.hashing import sha256_file from zonos3.utils.release import resolve_file @@ -100,7 +102,7 @@ class ReferenceAssets: actual = sha256_file(resolve_file(entry["checkpoint"])) if actual != entry["checkpoint_sha256"]: raise ValueError(f"codec generator checkpoint sha256 {actual} != {entry['checkpoint_sha256']}") - self._decoders[key] = matched_codec.load_model(codec, device) + self._decoders[key] = matched_codec.load_model(codec, device, decoder=key[1]) return self._decoders[key] def speaker_encoder(self, codec: str | None, dim: int, device: torch.device): @@ -569,14 +571,14 @@ def generate_rows( # ----------------------------------------------------------------------------------------------------- decoding -def _codec_decode(lm: Zonos3LM, assets: ReferenceAssets, device): - """The checkpoint's matched codec on undelayed codes [frames, n_codebooks] -> float32 PCM (ValueError for codes - outside the codebook).""" +def _codec_decode(lm: Zonos3LM, assets: ReferenceAssets, device, decoder: str | None): + """The checkpoint's matched codec through its decoder ``decoder`` (None = the default) on undelayed codes + [frames, n_codebooks] -> float32 PCM (ValueError for codes outside the codebook).""" from zonos3.tokenizer.matched_codec import decode_model, entry c = lm.config codec = entry(c.audio_codec) - model = assets.decoder(c.audio_codec, torch.device(device)) + model = assets.decoder(c.audio_codec, torch.device(device), decoder) def decode(codes: np.ndarray) -> np.ndarray: codes = torch.as_tensor(codes, dtype=torch.int64) @@ -602,14 +604,15 @@ def decode_rows( eos_frame: int | None, context_codes: torch.Tensor | None, device, + decoder: str | None = None, ) -> np.ndarray: - """End-of-stream decode of TTSVocoderManager.decode_frames / _decode_final (a whole-mode StreamDecoder): the - prefill rows open the stream, the EOS boundary is the earliest of the aligned EOS frame and every row's EOA column, - the last overlap rows of the prefill are re-decoded with the rest, and the reference tail is decoded as left - context at the stream start.""" + """End-of-stream decode of TTSVocoderManager.decode_frames / _decode_final (a whole-mode StreamDecoder) through the + decoder ``decoder`` (None = the default): the prefill rows open the stream, the EOS boundary is the earliest of the + aligned EOS frame and every row's EOA column, the last overlap rows of the prefill are re-decoded with the rest, and + the reference tail is decoded as left context at the stream start.""" c = lm.config - decoder = StreamDecoder( - _codec_decode(lm, assets, device), + whole = StreamDecoder( + _codec_decode(lm, assets, device, decoder), n_codebooks=c.n_codebooks, audio_pad_id=c.audio_pad_id, hop=_codec_hop(lm), @@ -618,8 +621,8 @@ def decode_rows( mode="whole", ) for row in rows: - decoder.push(row, eos_frame) - return decoder.finish() + whole.push(row, eos_frame) + return whole.finish() class _Emit: @@ -648,11 +651,13 @@ class _Emit: return np.concatenate(self.parts) if self.parts else np.zeros(0, dtype=np.float32) -def output_gain(codec: str, headroom_db: float | None) -> float: +def output_gain(codec: str, headroom_db: float | None, decoder: str | None = None) -> float: + """The output gain of ``headroom_db``, None = the headroom of the codec's decoder ``decoder`` (None = the default; + 0 dB without a matched codec).""" if headroom_db is None: from zonos3.tokenizer.matched_codec import codec_names, decoder_headroom_db - headroom_db = decoder_headroom_db(codec) if codec in codec_names() else 0.0 + headroom_db = decoder_headroom_db(codec, decoder) if codec in codec_names() else 0.0 return float(10.0 ** (-float(headroom_db) / 20.0)) @@ -739,14 +744,14 @@ def synthesize( plan.follow_tokens, plan.schedule[:, 3:], FollowConfig(lead=float(lead), lag=float(lag)) ) text_start, text_len = locate_text_span(plan.cond.input_ids, c.n_codebooks) - gain = output_gain(c.audio_codec, req.headroom_db) + gain = output_gain(c.audio_codec, req.headroom_db, req.decoder) prefix = emit = on_row = None if on_audio is not None and plan.laci is None and req.stream_decode != "whole": from zonos3.codec.istft_head_a_20261002.stream import ISTFTStream prefix = StreamDecoder( - _codec_decode(lm, assets, device), - stream=ISTFTStream(assets.decoder(c.audio_codec, torch.device(device))), + _codec_decode(lm, assets, device, req.decoder), + stream=ISTFTStream(assets.decoder(c.audio_codec, torch.device(device), req.decoder)), n_codebooks=c.n_codebooks, audio_pad_id=c.audio_pad_id, hop=_codec_hop(lm), @@ -795,6 +800,7 @@ def synthesize( eos_frame=eos_frame, context_codes=plan.context_codes, device=device, + decoder=req.decoder, ) pcm = fade_out(output_pcm(pcm, gain), float(req.fade_out_ms)).astype(np.float32) if on_audio is not None: diff --git a/zonos3/registries/codec_registry.json b/zonos3/registries/codec_registry.json new file mode 100644 index 0000000000000000000000000000000000000000..e30b7a18e87feb853ce4bdbef42083f5af37413f --- /dev/null +++ b/zonos3/registries/codec_registry.json @@ -0,0 +1,62 @@ +{ + "3n_600k_sched600k_r4096": { + "key": "3n_600k_sched600k_r4096", + "codec": "opus_dual_3n_600k_sched600k_r4096_step600000", + "family": "dual", + "codebooks": 10, + "hop": 2940, + "frame_rate": 15.0, + "max_tokens": 450, + "codec_step": 600000, + "checkpoint": "hf://Zyphra/ZONOS3-Mini/autoencoder/generator.pt", + "checkpoint_sha256": "75a587a3eda9ca3d345f0c305756a7ff8619b01685c261b08ae243c69c2caf9a", + "teacher": "hf://Zyphra/ZONOS3-Mini/autoencoder/teacher", + "tag": "3n_600k_sched600k_r4096_attnres_800m50k", + "codebook_sizes": [ + 4096, + 4096, + 4096, + 4096, + 4096, + 4096, + 4096, + 4096, + 4096, + 4096 + ], + "silence_frame": [ + 1918, + 746, + 3544, + 234, + 1267, + 2914, + 3944, + 2849, + 326, + 1337 + ], + "decoder_default": "keep2_plain", + "decoders": { + "keep2_plain": { + "kind": "istft_mr", + "label": "Multi-resolution iSTFT head + linear STFT loss, KEEP-2 pruned decoder (istft_head_a_20261002/full-unfreezeall-mr-drop30-4x10-50k, job 73313, final step 50,000: decoder.0 keeps layers 0+31, decoder.2/4/6/8 keep 0+11, cold-crop recipe; release copy = step + trainable state); causal, fp32", + "campaign": "hf://Zyphra/ZONOS3-Mini/autoencoder/heads/keep2_plain", + "config": "config_full_unfreezeall_mr_drop30_4x10.json", + "checkpoint": "step_0050000.pt", + "expect_step": 50000, + "headroom_db": 3.0 + }, + "full_mr": { + "kind": "istft_mr", + "label": "Multi-resolution iSTFT head + linear STFT loss, decoder.0-8 unfrozen (istft_head_a_20261002/full-unfreezeall-mr-50k, final step 50,000; release copy = step + trainable state); causal, fp32", + "campaign": "hf://Zyphra/ZONOS3-Mini/autoencoder/heads/full_mr", + "config": "config_full_unfreezeall_mr.json", + "checkpoint": "step_0050000.pt", + "expect_step": 50000, + "headroom_db": 3.0 + } + }, + "_decoders_note": "the 600k conv-tail decoder of generator.pt is NOT used for decoding (its encoder/quantizer still initialise the kept decoder stages and encode reference clips)" + } +} diff --git a/zonos3/registries/codec_registry_keep2_plain.json b/zonos3/registries/codec_registry_keep2_plain.json deleted file mode 100644 index 25ac20a3cf8e6a8c53fe14d682fb19cf0684d113..0000000000000000000000000000000000000000 --- a/zonos3/registries/codec_registry_keep2_plain.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "3n_600k_sched600k_r4096": { - "key": "3n_600k_sched600k_r4096", - "codec": "opus_dual_3n_600k_sched600k_r4096_step600000", - "family": "dual", - "codebooks": 10, - "hop": 2940, - "frame_rate": 15.0, - "max_tokens": 450, - "codec_step": 600000, - "checkpoint": "hf://Zyphra/ZONOS3-Mini/autoencoder/generator.pt", - "checkpoint_sha256": "75a587a3eda9ca3d345f0c305756a7ff8619b01685c261b08ae243c69c2caf9a", - "teacher": "hf://Zyphra/ZONOS3-Mini/autoencoder/teacher", - "tag": "3n_600k_sched600k_r4096_attnres_800m50k", - "codebook_sizes": [ - 4096, - 4096, - 4096, - 4096, - 4096, - 4096, - 4096, - 4096, - 4096, - 4096 - ], - "silence_frame": [ - 1918, - 746, - 3544, - 234, - 1267, - 2914, - 3944, - 2849, - 326, - 1337 - ], - "decoder": { - "kind": "istft_mr", - "label": "Multi-resolution iSTFT head + linear STFT loss, KEEP-2 pruned decoder (istft_head_a_20261002/full-unfreezeall-mr-drop30-4x10-50k, job 73313, final step 50,000: decoder.0 keeps layers 0+31, decoder.2/4/6/8 keep 0+11, cold-crop recipe; release copy = step + trainable state); causal, fp32", - "campaign": "hf://Zyphra/ZONOS3-Mini/autoencoder/heads/keep2_plain", - "config": "config_full_unfreezeall_mr_drop30_4x10.json", - "checkpoint": "step_0050000.pt", - "expect_step": 50000, - "headroom_db": 3.0, - "_note": "the 600k conv-tail decoder of generator.pt is NOT used for decoding (its encoder/quantizer still initialise the kept decoder stages and encode reference clips)" - } - } -} diff --git a/zonos3/server/capabilities.py b/zonos3/server/capabilities.py index 89d7c02dd570131567148f58896964b2df5e3bea..7b02e2c9b756d7400784f7a62a7a11af3b709f15 100644 --- a/zonos3/server/capabilities.py +++ b/zonos3/server/capabilities.py @@ -40,7 +40,8 @@ class CapabilityFacts: silence_hop: int | None # the codec's hop when codec-matched silence frames can be prefilled, else None tag_cfg_available: bool tag_cfg_trained: bool # zonos3.tts.markup.trained_on_tags - decoder: dict | None # the audio decoder (decoder_capability for the matched codecs) + decoder: dict | None # the default audio decoder (decoder_capabilities for the matched codecs) + decoders: list[dict] # every decoder a request may pick, the default first condition_tokens: dict | None # condition_spec; None without condition rows speaker_audio_upload: bool # uploaded clips can condition (an encoder for them is loaded) speaker_cfg_available: bool @@ -123,17 +124,20 @@ def tag_cfg_capabilities(available: bool, trained: bool) -> dict: } -def decoder_capability(audio_codec: str) -> dict | None: - """The audio decoder behind a matched codec (the causal iSTFT head), with its default headroom; None otherwise.""" - from zonos3.tokenizer.matched_codec import codec_names, decoder_info +def decoder_capabilities(audio_codec: str, served=None) -> tuple[dict | None, list[dict]]: + """(Capabilities.decoder, Capabilities.decoders) of a matched codec: its default iSTFT head with its headroom, and + every decoder a request may pick (``served``: those ids, default first; None = every registry decoder). Not a + matched codec: (None, []); a broken registry entry: ({codec, error}, []).""" + from zonos3.tokenizer.matched_codec import codec_names, decoder_ids, decoder_info codec = str(audio_codec) if codec not in codec_names(): - return None + return None, [] try: - return dict(decoder_info(codec), codec=codec) + infos = [dict(decoder_info(codec, name), codec=codec) for name in (served or decoder_ids(codec))] except Exception as exc: # noqa: BLE001 - return {"codec": codec, "error": str(exc)} + return {"codec": codec, "error": str(exc)}, [] + return infos[0], infos def phoneme_capabilities(text_tokenizer_spec: dict | None, lexicon) -> dict: @@ -189,6 +193,7 @@ def capabilities_document(f: CapabilityFacts) -> dict: "speaker_modes": modes, "speaker_mode_default": modes[0] if modes else None, "decoder": f.decoder, + "decoders": list(f.decoders), "condition_tokens": f.condition_tokens, "speaker_audio_upload": f.speaker_audio_upload, "speaker_cfg_supported": cfg, diff --git a/zonos3/server/edit.py b/zonos3/server/edit.py index 7aa6f44128742c313807852f2684af373100d418..0c769a4ee37d59ea34889dbb200f58d249fd5e27 100644 --- a/zonos3/server/edit.py +++ b/zonos3/server/edit.py @@ -1,17 +1,22 @@ """The speech-editing routes of the Python servers (/v2/edit/transcribe, /v2/edit/align, /v2/edit) over the server's -``zonos3.tts.edit_runtime.EditRuntime``; the HTTP mapping of its errors is ``zonos3.server.errors``.""" +``zonos3.tts.edit_runtime.EditRuntime``; the HTTP mapping of its errors is ``zonos3.server.errors``. An edit's +``decoder`` is checked against the server's decoders (``decoders()``: the ids of Capabilities.decoders) first.""" from __future__ import annotations -from typing import Callable +from typing import Callable, Sequence from fastapi import APIRouter from zonos3.server.errors import call from zonos3.server.schemas import EditAlignRequest, EditRequest, EditTranscribeRequest +from zonos3.server.speech import resolve_decoder -def make_router(get_runtime: Callable[[], "EditRuntime"]) -> APIRouter: # noqa: F821 +def make_router( + get_runtime: Callable[[], "EditRuntime"], # noqa: F821 + decoders: Callable[[], Sequence[str]], +) -> APIRouter: router = APIRouter() @router.post("/v2/edit/transcribe") @@ -29,6 +34,11 @@ def make_router(get_runtime: Callable[[], "EditRuntime"]) -> APIRouter: # noqa: @router.post("/v2/edit") async def edit(req: EditRequest): """Regenerate the edited regions of recorded speech; unedited codec frames are kept exactly.""" - return await call(get_runtime().edit(req)) + + async def run(): + resolve_decoder(req.decoder, decoders()) # 400 for an id this server does not serve + return await get_runtime().edit(req) + + return await call(run()) return router diff --git a/zonos3/server/middleware.py b/zonos3/server/middleware.py index bd040919b60022eaf46fe364949720800928a96e..4c0fef1eab88f2ee86fc9bc934de5d5f5351f3b5 100644 --- a/zonos3/server/middleware.py +++ b/zonos3/server/middleware.py @@ -17,6 +17,7 @@ EXPOSED_HEADERS: tuple[str, ...] = ( "X-Audio-Format", "X-Control-Span-Follow", "X-Seed", + "X-Decoder", ) diff --git a/zonos3/server/schemas.py b/zonos3/server/schemas.py index d1e0e6595a53b4d9ac73c3c3a7aaebfe30a04f0d..ce2b1925357c48ca86439fafa1f0587a93813bc9 100644 --- a/zonos3/server/schemas.py +++ b/zonos3/server/schemas.py @@ -69,7 +69,9 @@ class GenerationOptions(_Strict): # Condition rows of the cond3 finetunes: bucket ids per name or raw values mapped through the checkpoint's edges. condition_buckets: ConditionBuckets = None condition_values: ConditionValues = None - headroom_db: Annotated[float, Field(ge=0.0, le=24.0)] | None = None # None = the decoder's registry value + headroom_db: Annotated[float, Field(ge=0.0, le=24.0)] | None = None # None = the chosen decoder's registry value + # The audio decoder by id (Capabilities.decoders; None = the server default): an id the server does not serve: 400. + decoder: str | None = None speaker_audio_base64: str | None = None speaker_audio_name: str | None = None # Pre-encoded reference prefix codes [[cb0..cbN], ...] for raw-reference checkpoints. @@ -222,6 +224,8 @@ class EditRequest(_Strict): verify: bool = False # Tag CFG is not offered for edits: any value other than 1.0 is refused (400) rather than ignored. tag_cfg_scale: float = 1.0 + # The audio decoder of the edited clip by id (Capabilities.decoders; None = the server default; unknown: 400). + decoder: str | None = None # ------------------------------------------------------------------------------------------------------- projects diff --git a/zonos3/server/speech.py b/zonos3/server/speech.py index 124eb2ce0264b558a14e4efd82248efd1f59dee2..d26a0908e3fa8477260b000871c8ab131d5dd57a 100644 --- a/zonos3/server/speech.py +++ b/zonos3/server/speech.py @@ -1,5 +1,5 @@ -"""The speech responses of the Python servers (/v2/generate, /v1/audio/speech): the stream-decode rule, the format -check and the response headers.""" +"""The speech responses of the Python servers (/v2/generate, /v1/audio/speech): the stream-decode rule, the decoder +choice, the format check and the response headers.""" from __future__ import annotations @@ -39,21 +39,37 @@ def resolve_stream_decode(value: str | None, *, streaming: bool, prefix_supporte return value +def resolve_decoder(value: str | None, served) -> str | None: + """A request's ``decoder``: None = the server default (``served[0]``; None when the codec has no decoder), else one + of ``served`` (the ids of Capabilities.decoders, default first); ValueError (HTTP 400) for any other id.""" + served = list(served) + if value is None: + return served[0] if served else None + if value not in served: + raise ValueError(f"Unknown decoder '{value}'; this server serves: {', '.join(served)}.") + return value + + def check_format(stream: bool, fmt: str) -> None: """A 16-bit WAV is buffered: ValueError (HTTP 400) for format=wav on a streamed response.""" if stream and fmt == "wav": raise ValueError("format=wav needs stream=false") -def speech_headers(*, fmt: str, seed: int, control_spans: bool, follows_reading: bool) -> dict[str, str]: - """The headers of a speech response: its audio format, the seed it sampled with and, with ``control_spans``, - whether the painted spans follow the reading (``follows_reading``) or the speaking rate.""" +def speech_headers( + *, fmt: str, seed: int, control_spans: bool, follows_reading: bool, decoder: str | None +) -> dict[str, str]: + """The headers of a speech response: its audio format, the seed it sampled with, the decoder that made the audio + and, with ``control_spans``, whether the painted spans follow the reading (``follows_reading``) or the speaking + rate.""" headers = { "X-Audio-Sample-Rate": str(SAMPLE_RATE), "X-Audio-Channels": "1", "X-Audio-Format": "pcm16" if fmt == "wav" else "float32", "X-Seed": str(seed), } + if decoder is not None: + headers["X-Decoder"] = decoder if control_spans: headers["X-Control-Span-Follow"] = "reading" if follows_reading else "rate" return headers diff --git a/zonos3/tokenizer/matched_codec.py b/zonos3/tokenizer/matched_codec.py index 2779b7f2953492ce2b26c0f9bc9cdc7dbc16f64b..8fe65b2f94d6cf8a1fa3c019bb29afc4fe4ee02d 100644 --- a/zonos3/tokenizer/matched_codec.py +++ b/zonos3/tokenizer/matched_codec.py @@ -1,9 +1,11 @@ """Decode the frozen codec used to tokenize each matched LM's training data. -Decoding goes through the causal multi-resolution iSTFT head declared by the registry entry's ``decoder`` block: the -KEEP-2 pruned head (``codec_registry_keep2_plain.json``, istft_head_a_20261002 full-unfreezeall-mr-drop30-4x10). -The 600k conv-tail decoder is never used. The 600k generator.pt only supplies the frozen encoder/quantizer and the -initial decoder stages that the head checkpoint then overrides.""" +Decoding goes through a causal multi-resolution iSTFT head declared in the registry entry's ``decoders`` +(``codec_registry.json``, istft_head_a_20261002), keyed by decoder id: ``keep2_plain`` (the default, +``decoder_default``: the KEEP-2 pruned head, full-unfreezeall-mr-drop30-4x10) and ``full_mr`` (the full-size head, +full-unfreezeall-mr). The heads share the codec, its frame rate and codebooks and differ only in layer counts. The 600k +conv-tail decoder is never used. The 600k generator.pt only supplies the frozen encoder/quantizer and the initial +decoder stages that the head checkpoint then overrides. ``decoder=None`` is the codec's default decoder everywhere.""" import functools import json @@ -16,7 +18,7 @@ import torch from zonos3.utils.hashing import sha256_file from zonos3.utils.release import hf_join, resolve_file -REGISTRY = Path(__file__).resolve().parents[1] / "registries" / "codec_registry_keep2_plain.json" +REGISTRY = Path(__file__).resolve().parents[1] / "registries" / "codec_registry.json" _CACHE = {} _INFO = {} _GRAPHS = {} @@ -38,22 +40,61 @@ def entry(codec): return values[0] -def decoder_spec(codec): - """The registry's decoder block; every matched codec must declare a causal iSTFT decoder (no conv-tail fallback).""" - e = entry(codec) - spec = e.get("decoder") - if not spec or spec.get("kind") != "istft_mr": - raise RuntimeError(f"matched codec {codec!r} declares no iSTFT decoder; the conv-tail decoder is disabled") +def decoder_ids(codec): + """The ids of the codec's decoders, its default (``decoder_default``) first, then the registry order.""" + decoders = entry(codec).get("decoders") or {} + default = entry(codec).get("decoder_default") + if not decoders or default not in decoders: + raise RuntimeError( + f"matched codec {codec!r} declares no default iSTFT decoder; the conv-tail decoder is disabled" + ) + return [default, *(name for name in decoders if name != default)] + + +def decoder_id(codec, decoder=None): + """``decoder`` (None = the codec's default) checked against the codec's decoders (ValueError when unknown).""" + ids = decoder_ids(codec) + if decoder is None: + return ids[0] + if decoder not in ids: + raise ValueError(f"matched codec {codec!r} has no decoder {decoder!r} (decoders: {', '.join(ids)})") + return decoder + + +def served_decoders(codec, wanted=None): + """The decoder ids a server serves: ``wanted`` (a server flag's ids; None = every decoder of the codec), the + codec's default first when it is among them, else the first wanted; ValueError for an id the codec lacks.""" + ids = decoder_ids(codec) + if wanted is None: + return ids + wanted = list(dict.fromkeys(str(name).strip() for name in wanted if str(name).strip())) + if not wanted: + raise ValueError(f"no decoder given (matched codec {codec!r} has {', '.join(ids)})") + for name in wanted: + decoder_id(codec, name) + return sorted(wanted, key=lambda name: name != ids[0]) + + +def decoder_spec(codec, decoder=None): + """A registry decoder block; every matched codec decoder must be a causal iSTFT head (no conv-tail fallback).""" + name = decoder_id(codec, decoder) + spec = entry(codec)["decoders"][name] + if spec.get("kind") != "istft_mr": + raise RuntimeError( + f"decoder {name!r} of matched codec {codec!r} is no iSTFT head; the conv-tail decoder is disabled" + ) return spec -def decoder_headroom_db(codec): - return float(decoder_spec(codec).get("headroom_db", 0.0)) +def decoder_headroom_db(codec, decoder=None): + return float(decoder_spec(codec, decoder).get("headroom_db", 0.0)) -def decoder_info(codec): - spec = decoder_spec(codec) +def decoder_info(codec, decoder=None): + name = decoder_id(codec, decoder) + spec = decoder_spec(codec, name) info = { + "id": name, "kind": spec["kind"], "label": spec.get("label"), "checkpoint": hf_join(spec["campaign"], spec["checkpoint"]), @@ -61,15 +102,16 @@ def decoder_info(codec): "headroom_db": float(spec.get("headroom_db", 0.0)), "causal": True, } - info.update(_INFO.get(codec, {})) + info.update(_INFO.get((codec, name), {})) return info -def load_model(codec, device, prune=True): +def load_model(codec, device, prune=True, decoder=None): """Build the iSTFT-head decoder exactly as the listening viewer's decode.py does: ISTFTCodec(cfg['model'], cfg['head']), pretrained generator weights, then the run's trainable state (decoder stages + head) from the pinned checkpoint.""" e = entry(codec) - spec = decoder_spec(codec) + name = decoder_id(codec, decoder) + spec = decoder_spec(codec, name) from zonos3.codec.istft_head_a_20261002.model import ISTFTCodec campaign = spec["campaign"] @@ -99,7 +141,7 @@ def load_model(codec, device, prune=True): model.eval().requires_grad_(False) if prune: prune_model(model, e) - _INFO[codec] = { + _INFO[codec, name] = { "step": int(state["step"]), "checkpoint_bytes": checkpoint.stat().st_size, "checkpoint_mtime": time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(checkpoint.stat().st_mtime)), @@ -141,42 +183,42 @@ def decode_model(model, codes, e): return audio.float().squeeze(1).cpu() -def _key(codec): - return codec, os.environ.get("ZONOS3_AUDIO_CODEC_DEVICE", "cuda:0") +def _key(codec, decoder): + return codec, decoder_id(codec, decoder), os.environ.get("ZONOS3_AUDIO_CODEC_DEVICE", "cuda:0") -def _model(codec): - """The codec's decoder on ZONOS3_AUDIO_CODEC_DEVICE (default cuda:0), loaded once after the checkpoint's sha256.""" +def _model(codec, decoder=None): + """A decoder of the codec on ZONOS3_AUDIO_CODEC_DEVICE (default cuda:0), loaded once after the checkpoint's sha256.""" e = entry(codec) - key = _key(codec) + key = _key(codec, decoder) if key not in _CACHE: actual = sha256_file(resolve_file(e["checkpoint"])) assert actual == e["checkpoint_sha256"], ("generator checkpoint sha256", actual, e["checkpoint_sha256"]) - _CACHE[key] = load_model(codec, key[1]) + _CACHE[key] = load_model(codec, key[2], decoder=key[1]) return _CACHE[key] -def decode(codes, codec): +def decode(codes, codec, decoder=None): e = entry(codec) if codes.ndim != 3 or codes.shape[-1] != e["codebooks"] or bool(((codes < 0) | (codes >= 4096)).any()): raise ValueError("Invalid matched codec tokens") - return decode_model(_model(codec), codes, e) + return decode_model(_model(codec, decoder), codes, e) -def stream(codec): +def stream(codec, decoder=None): """A fresh stateful decoder (ISTFTStream) on the cached model: decode(codes [n, codebooks]) -> final samples, flush(). - It replays the CUDA graphs captured by ``capture_stream_graphs`` for matching chunk shapes.""" + It replays the CUDA graphs captured by ``capture_stream_graphs`` for that decoder and matching chunk shapes.""" from zonos3.codec.istft_head_a_20261002.stream import ISTFTStream - return ISTFTStream(_model(codec), graphs=_GRAPHS.get(_key(codec))) + return ISTFTStream(_model(codec, decoder), graphs=_GRAPHS.get(_key(codec, decoder))) -def capture_stream_graphs(codec, chunks) -> None: +def capture_stream_graphs(codec, chunks, decoder=None) -> None: """CUDA-graph the chunk shapes of a stream decoding ``chunks`` frames per call from the start (bit-identical to - the eager decode; a no-op unless the codec runs on CUDA).""" + the eager decode; a no-op unless the codec runs on CUDA). Each decoder keeps its own graphs.""" from zonos3.codec.istft_head_a_20261002.stream import ChunkGraphs - model = _model(codec) + model = _model(codec, decoder) if next(model.parameters()).device.type != "cuda": return - _GRAPHS.setdefault(_key(codec), ChunkGraphs()).capture(model, chunks) + _GRAPHS.setdefault(_key(codec, decoder), ChunkGraphs()).capture(model, chunks) diff --git a/zonos3/tts/edit_runtime.py b/zonos3/tts/edit_runtime.py index 28c6b033b478752dd457079c8c0036baa7614814..02858a394c64b4ce9f41e3828069ef2dfaeceec3 100644 --- a/zonos3/tts/edit_runtime.py +++ b/zonos3/tts/edit_runtime.py @@ -124,8 +124,9 @@ class EditEngine(Protocol): """The generated delay-stacked rows ``[n, n_codebooks]`` without the finishing row, and the aligned EOS frame (-1 = none), of one region.""" - async def decode(self, codes: np.ndarray) -> np.ndarray: - """Float32 44.1 kHz audio (with the server's output gain) of ordinary codes ``[frames, n_codebooks]``.""" + async def decode(self, codes: np.ndarray, decoder: str | None) -> np.ndarray: + """Float32 44.1 kHz audio (with the decoder's output gain) of ordinary codes ``[frames, n_codebooks]`` through + the decoder ``decoder`` (an id the route checked; None = the server default).""" def edit_capabilities(model: EditModel, available: bool, transcribe: bool) -> dict: @@ -440,7 +441,7 @@ class EditRuntime: window_fills.append(np.asarray(fill, dtype=np.int32)) fills[region], stopped[region] = window_fills[-1], ended spliced = np.asarray(splice_edit(codes, spans, fills), dtype=np.int32) - edited = np.asarray(await self.engine.decode(spliced), dtype=np.float32) + edited = np.asarray(await self.engine.decode(spliced, req.decoder), dtype=np.float32) verify, take_words = None, None if req.verify: import soundfile as sf diff --git a/zonos3/tts/plan.py b/zonos3/tts/plan.py index 6ab0fe6d499d1d1469aa9c583196569b2df0ac75..27ecf3cf236b629f829e7f6d70f9d747601c14c2 100644 --- a/zonos3/tts/plan.py +++ b/zonos3/tts/plan.py @@ -66,6 +66,7 @@ GENERATE_DEFAULTS: dict = { "condition_buckets": None, "condition_values": None, "headroom_db": None, + "decoder": None, "speaker_audio_base64": None, "speaker_audio_name": None, "speaker_reference_codes": None, diff --git a/zonos3/workers/pyhost.py b/zonos3/workers/pyhost.py index 1b6eb027a47c9f96a31ed371b59e5cee16314713..0f430a9dbdadc7cb6c3a6516f83b5c0d986ccebd 100644 --- a/zonos3/workers/pyhost.py +++ b/zonos3/workers/pyhost.py @@ -39,7 +39,7 @@ process), answered ``{"call": N, "status": "ok", ...}`` or ``{"call": N, "status encode {audio, max_seconds} -> {codes: [[int] * K] * T} check {target_text, doses, condition_buckets, condition_values} -> {raw: [id]} fill {every FillJob field} -> {rows: [[int] * K] * n, eos_frame (-1: none)} - decode {codes, out} -> {}; float32 44.1 kHz WAV at out + decode {codes, out, decoder} -> {}; float32 44.1 kHz WAV at out (decoder: id, null = default) laci_takes {takes: [{request: GenerateRequest body, target_frames, adjust_rate, scale: {edges, first, bucket, doses: {"": dose}} | null, out}], session} -> {takes: [{audio: bool, record: LACI record}]}; WAV at out if audio @@ -187,10 +187,10 @@ class RpcEditEngine: reply = await self.pipe.call("fill", **payload) return np.asarray(reply["rows"], dtype=np.int64).reshape(-1, self.model.n_codebooks), int(reply["eos_frame"]) - async def decode(self, codes: np.ndarray) -> np.ndarray: + async def decode(self, codes: np.ndarray, decoder: str | None) -> np.ndarray: with tempfile.TemporaryDirectory(prefix="zonos3-pyhost-") as tmp: out = os.path.join(tmp, "decoded.wav") - await self.pipe.call("decode", codes=np.asarray(codes).tolist(), out=out) + await self.pipe.call("decode", codes=np.asarray(codes).tolist(), out=out, decoder=decoder) return read_wav(out)