@readium/speech 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { DecorationController as si, DirectCommsChannel as ai, Decorator as ri } from "@readium/decorator";
1
+ import { DecorationController as ci, DirectCommsChannel as ui, Decorator as hi } from "@readium/decorator";
2
2
  export * from "@readium/decorator";
3
- import { LocatorText as oi, LocatorLocations as li, Locator as ci } from "@readium/shared";
4
- import { Locator as or, LocatorLocations as lr, LocatorText as cr } from "@readium/shared";
5
- import { startsWithBindingPunct as ue, ssmlTextEscape as z, BINDING_PUNCT_CLASS as ie, ssmlAttrEscape as on } from "@readium/helpers";
6
- import ui from "i18next";
7
- import { decodeTextref as Ct, combineDomRangeTextrefs as hi, substitutedOwnSelector as di, isAriaSubstituted as he } from "@readium/guided-navigation";
8
- import { DomRange as gi, DomRangePoint as Et } from "@readium/shared/html";
9
- const C = (n) => {
3
+ import { LocatorText as di, LocatorLocations as gi, Locator as fi } from "@readium/shared";
4
+ import { Locator as gr, LocatorLocations as fr, LocatorText as pr } from "@readium/shared";
5
+ import { startsWithBindingPunct as he, ssmlTextEscape as T, BINDING_PUNCT_CLASS as se, ssmlAttrEscape as ln } from "@readium/helpers";
6
+ import pi from "i18next";
7
+ import { decodeTextref as Et, combineDomRangeTextrefs as mi, substitutedOwnSelector as vi, isAriaSubstituted as de } from "@readium/guided-navigation";
8
+ import { DomRange as yi, DomRangePoint as Rt } from "@readium/shared/html";
9
+ const k = (n) => {
10
10
  if (!n) return ["", void 0];
11
11
  const e = n.replace(/_/g, "-");
12
12
  try {
@@ -23,19 +23,19 @@ const C = (n) => {
23
23
  ];
24
24
  }
25
25
  }, nt = (n, e) => {
26
- const t = e.toLowerCase().replace(/_/g, "-"), [i] = C(e), s = Object.entries(n);
26
+ const t = e.toLowerCase().replace(/_/g, "-"), [i] = k(e), s = Object.entries(n);
27
27
  for (const a of [t, i]) {
28
28
  const r = s.find(([o]) => o.toLowerCase().replace(/_/g, "-") === a);
29
29
  if (r) return r[1];
30
30
  }
31
- }, Ce = (n, e) => {
32
- const t = e.toLowerCase().replace(/_/g, "-"), [i] = C(e);
31
+ }, cn = (n, e) => {
32
+ const t = e.toLowerCase().replace(/_/g, "-"), [i] = k(e);
33
33
  let s;
34
34
  for (const a of [i, t])
35
35
  for (const [r, o] of Object.entries(n))
36
36
  r.toLowerCase().replace(/_/g, "-") === a && (s ??= /* @__PURE__ */ new Set(), o.forEach((l) => s.add(l)));
37
37
  return s && [...s];
38
- }, T = {
38
+ }, U = {
39
39
  ar: {
40
40
  defaultRegion: "SA",
41
41
  availableRegions: [
@@ -422,16 +422,16 @@ const C = (n) => {
422
422
  ],
423
423
  testUtterance: "你好,我叫 {name},係越中文聲。"
424
424
  }
425
- }, Ve = /* @__PURE__ */ new Map(), fi = /* @__PURE__ */ Object.assign({ "../../json/ar.json": () => import("./ar-BGKtJRyt.js"), "../../json/bg.json": () => import("./bg-D9Q1JriY.js"), "../../json/bho.json": () => import("./bho-CpuLBMN3.js"), "../../json/bn.json": () => import("./bn-Bpn_lzoe.js"), "../../json/ca.json": () => import("./ca-5hzouNcE.js"), "../../json/cmn.json": () => import("./cmn-DlnYMCd8.js"), "../../json/cs.json": () => import("./cs-CDpMkMNO.js"), "../../json/da.json": () => import("./da-XWCfWAwB.js"), "../../json/de.json": () => import("./de-DU0USiOh.js"), "../../json/el.json": () => import("./el-ClBwbIAW.js"), "../../json/en.json": () => import("./en-l3wcpTw3.js"), "../../json/es.json": () => import("./es-DwOFJY07.js"), "../../json/eu.json": () => import("./eu-DxWirHU-.js"), "../../json/fa.json": () => import("./fa-Ml9KtIw1.js"), "../../json/fi.json": () => import("./fi-Dk-5Fhhl.js"), "../../json/fr.json": () => import("./fr-MfhjukJ4.js"), "../../json/gl.json": () => import("./gl-DwtzWds9.js"), "../../json/he.json": () => import("./he-CfajFNE_.js"), "../../json/hi.json": () => import("./hi-pv2ttBoh.js"), "../../json/hr.json": () => import("./hr-MRApcEKR.js"), "../../json/hu.json": () => import("./hu-DGRDZdHH.js"), "../../json/id.json": () => import("./id-DZUuUiTG.js"), "../../json/it.json": () => import("./it-DJUYnjyj.js"), "../../json/ja.json": () => import("./ja-BpFcZRMu.js"), "../../json/kk.json": () => import("./kk-C480t1iH.js"), "../../json/kn.json": () => import("./kn-BVqs26qv.js"), "../../json/ko.json": () => import("./ko-TNoPZd6N.js"), "../../json/mr.json": () => import("./mr-DstAHTvT.js"), "../../json/ms.json": () => import("./ms-BceBSD-j.js"), "../../json/nb.json": () => import("./nb-CwPbwG-i.js"), "../../json/nl.json": () => import("./nl-BmW-Dmw5.js"), "../../json/pl.json": () => import("./pl-CH8qoDu8.js"), "../../json/pt.json": () => import("./pt-CjCENn24.js"), "../../json/ro.json": () => import("./ro-BlJN7qkA.js"), "../../json/ru.json": () => import("./ru-udzq1D5e.js"), "../../json/sk.json": () => import("./sk-VAEHsTWJ.js"), "../../json/sl.json": () => import("./sl-DaZQ1gp0.js"), "../../json/sv.json": () => import("./sv-CicHwXe4.js"), "../../json/ta.json": () => import("./ta-CvpRY89g.js"), "../../json/te.json": () => import("./te-D5TcdW9V.js"), "../../json/th.json": () => import("./th-CYakoFVa.js"), "../../json/tr.json": () => import("./tr-BfYrcAz7.js"), "../../json/uk.json": () => import("./uk-BVs6lQbX.js"), "../../json/vi.json": () => import("./vi-DP1xN9KL.js"), "../../json/wuu.json": () => import("./wuu-C6uQvT6g.js"), "../../json/yue.json": () => import("./yue-C8kEWdfv.js") });
426
- async function pi(n) {
425
+ }, xe = /* @__PURE__ */ new Map(), Si = /* @__PURE__ */ Object.assign({ "../../json/ar.json": () => import("./ar-BGKtJRyt.js"), "../../json/bg.json": () => import("./bg-D9Q1JriY.js"), "../../json/bho.json": () => import("./bho-CpuLBMN3.js"), "../../json/bn.json": () => import("./bn-Bpn_lzoe.js"), "../../json/ca.json": () => import("./ca-5hzouNcE.js"), "../../json/cmn.json": () => import("./cmn-DlnYMCd8.js"), "../../json/cs.json": () => import("./cs-CDpMkMNO.js"), "../../json/da.json": () => import("./da-XWCfWAwB.js"), "../../json/de.json": () => import("./de-DU0USiOh.js"), "../../json/el.json": () => import("./el-ClBwbIAW.js"), "../../json/en.json": () => import("./en-l3wcpTw3.js"), "../../json/es.json": () => import("./es-DwOFJY07.js"), "../../json/eu.json": () => import("./eu-DxWirHU-.js"), "../../json/fa.json": () => import("./fa-Ml9KtIw1.js"), "../../json/fi.json": () => import("./fi-Dk-5Fhhl.js"), "../../json/fr.json": () => import("./fr-MfhjukJ4.js"), "../../json/gl.json": () => import("./gl-DwtzWds9.js"), "../../json/he.json": () => import("./he-CfajFNE_.js"), "../../json/hi.json": () => import("./hi-pv2ttBoh.js"), "../../json/hr.json": () => import("./hr-MRApcEKR.js"), "../../json/hu.json": () => import("./hu-DGRDZdHH.js"), "../../json/id.json": () => import("./id-DZUuUiTG.js"), "../../json/it.json": () => import("./it-DJUYnjyj.js"), "../../json/ja.json": () => import("./ja-BpFcZRMu.js"), "../../json/kk.json": () => import("./kk-C480t1iH.js"), "../../json/kn.json": () => import("./kn-BVqs26qv.js"), "../../json/ko.json": () => import("./ko-TNoPZd6N.js"), "../../json/mr.json": () => import("./mr-DstAHTvT.js"), "../../json/ms.json": () => import("./ms-BceBSD-j.js"), "../../json/nb.json": () => import("./nb-CwPbwG-i.js"), "../../json/nl.json": () => import("./nl-BmW-Dmw5.js"), "../../json/pl.json": () => import("./pl-CH8qoDu8.js"), "../../json/pt.json": () => import("./pt-CjCENn24.js"), "../../json/ro.json": () => import("./ro-BlJN7qkA.js"), "../../json/ru.json": () => import("./ru-udzq1D5e.js"), "../../json/sk.json": () => import("./sk-VAEHsTWJ.js"), "../../json/sl.json": () => import("./sl-DaZQ1gp0.js"), "../../json/sv.json": () => import("./sv-CicHwXe4.js"), "../../json/ta.json": () => import("./ta-CvpRY89g.js"), "../../json/te.json": () => import("./te-D5TcdW9V.js"), "../../json/th.json": () => import("./th-CYakoFVa.js"), "../../json/tr.json": () => import("./tr-BfYrcAz7.js"), "../../json/uk.json": () => import("./uk-BVs6lQbX.js"), "../../json/vi.json": () => import("./vi-DP1xN9KL.js"), "../../json/wuu.json": () => import("./wuu-C6uQvT6g.js"), "../../json/yue.json": () => import("./yue-C8kEWdfv.js") });
426
+ async function bi(n) {
427
427
  try {
428
- const e = n.split("-")[0], t = fi[`../../json/${e}.json`];
428
+ const e = n.split("-")[0], t = Si[`../../json/${e}.json`];
429
429
  if (!t)
430
430
  throw new Error(`No voice data found for language: ${n}`);
431
431
  const s = (await t()).default;
432
432
  return {
433
433
  ...s,
434
- voices: s.voices.map(yi)
434
+ voices: s.voices.map(Ci)
435
435
  };
436
436
  } catch (e) {
437
437
  return console.warn(`Failed to load voice data for ${n}:`, e), {
@@ -442,14 +442,14 @@ async function pi(n) {
442
442
  };
443
443
  }
444
444
  }
445
- function Rt(n) {
446
- return Ve.has(n) || Ve.set(n, pi(n)), Ve.get(n);
445
+ function It(n) {
446
+ return xe.has(n) || xe.set(n, bi(n)), xe.get(n);
447
447
  }
448
- const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "apple"], yi = (n) => ({
448
+ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "apple"], Ci = (n) => ({
449
449
  ...n,
450
- quality: n.quality?.filter((e) => mi.includes(e)),
451
- localizedName: n.localizedName && vi.includes(n.localizedName) ? n.localizedName : void 0
452
- }), ae = {
450
+ quality: n.quality?.filter((e) => wi.includes(e)),
451
+ localizedName: n.localizedName && ki.includes(n.localizedName) ? n.localizedName : void 0
452
+ }), re = {
453
453
  cmn: "cmn",
454
454
  "cmn-CN": "cmn-CN",
455
455
  "cmn-TW": "cmn-TW",
@@ -461,29 +461,29 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
461
461
  "zh-HK": "yue-HK",
462
462
  wuu: "wuu",
463
463
  "wuu-CN": "wuu-CN"
464
- }, x = (n) => {
464
+ }, V = (n) => {
465
465
  if (!n) return "";
466
466
  let e = n.toLowerCase().replace(/_/g, "-");
467
467
  if (/\w{2,3}-\w{2,3}/.test(e)) {
468
468
  const [t, i] = e.split("-");
469
469
  e = `${t.toLowerCase()}-${i.toUpperCase()}`;
470
470
  }
471
- return ae[e] || e;
471
+ return re[e] || e;
472
472
  }, je = async (n) => {
473
473
  if (!n) return [];
474
474
  try {
475
- const e = x(n);
475
+ const e = V(n);
476
476
  try {
477
- const i = await Rt(e);
477
+ const i = await It(e);
478
478
  if (i?.voices?.length)
479
479
  return i.voices;
480
480
  } catch (i) {
481
481
  console.warn(`Failed to load voices for ${e}:`, i);
482
482
  }
483
- const [t] = C(e);
483
+ const [t] = k(e);
484
484
  if (t !== e)
485
485
  try {
486
- const i = await Rt(t);
486
+ const i = await It(t);
487
487
  if (i?.voices?.length)
488
488
  return i.voices;
489
489
  } catch (i) {
@@ -502,39 +502,39 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
502
502
  } catch {
503
503
  return n.toUpperCase();
504
504
  }
505
- }, It = (n) => {
505
+ }, Pt = (n) => {
506
506
  if (!n) return "";
507
507
  try {
508
- const e = x(n), t = T[e];
508
+ const e = V(n), t = U[e];
509
509
  if (t?.testUtterance)
510
510
  return t.testUtterance;
511
- if (e in ae) {
512
- const s = ae[e];
513
- if (s && T[s]?.testUtterance)
514
- return T[s].testUtterance;
511
+ if (e in re) {
512
+ const s = re[e];
513
+ if (s && U[s]?.testUtterance)
514
+ return U[s].testUtterance;
515
515
  }
516
- const [i] = C(e);
517
- return i !== e && T[i]?.testUtterance ? T[i].testUtterance : "";
516
+ const [i] = k(e);
517
+ return i !== e && U[i]?.testUtterance ? U[i].testUtterance : "";
518
518
  } catch (e) {
519
519
  return console.error(`Error in getTestUtterance for ${n}:`, e), "";
520
520
  }
521
- }, Ee = (n) => {
521
+ }, Re = (n) => {
522
522
  if (!n) return "";
523
523
  try {
524
- const e = x(n), t = T[e];
524
+ const e = V(n), t = U[e];
525
525
  if (t?.defaultRegion)
526
526
  return `${e}-${t.defaultRegion}`;
527
- if (e in ae) {
528
- const s = ae[e];
527
+ if (e in re) {
528
+ const s = re[e];
529
529
  if (s) {
530
- const a = T[s];
530
+ const a = U[s];
531
531
  if (a?.defaultRegion)
532
532
  return `${s}-${a.defaultRegion}`;
533
533
  }
534
534
  }
535
- const [i] = C(e);
535
+ const [i] = k(e);
536
536
  if (i !== e) {
537
- const s = T[i];
537
+ const s = U[i];
538
538
  if (s?.defaultRegion)
539
539
  return `${i}-${s.defaultRegion}`;
540
540
  }
@@ -542,17 +542,17 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
542
542
  } catch (e) {
543
543
  return console.error(`Failed to get default region for ${n}:`, e), "";
544
544
  }
545
- }, Re = (n) => {
545
+ }, Ie = (n) => {
546
546
  if (!n?.length) return [];
547
547
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
548
548
  for (const [s, a] of n.entries()) {
549
549
  if (!a) continue;
550
- const r = x(a), [o, l] = C(r);
550
+ const r = V(a), [o, l] = k(r);
551
551
  l && (e.add(l), i.has(l) || i.set(l, s)), t.has(o) || t.set(o, /* @__PURE__ */ new Set()), l && t.get(o).add(l);
552
552
  }
553
553
  return Array.from(t.entries()).map(([s, a]) => {
554
554
  const r = new Set(
555
- T[s]?.availableRegions || []
555
+ U[s]?.availableRegions || []
556
556
  ), o = Array.from(a), l = Array.from(e).filter(
557
557
  (u) => r.has(u) && !o.includes(u)
558
558
  ), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u, g) => {
@@ -560,7 +560,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
560
560
  return d - h;
561
561
  });
562
562
  if (c.length === 0) {
563
- const u = Ee(s), [, g] = C(u);
563
+ const u = Re(s), [, g] = k(u);
564
564
  g && c.push(g);
565
565
  }
566
566
  return {
@@ -568,11 +568,11 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
568
568
  regions: c
569
569
  };
570
570
  });
571
- }, W = async (n) => {
571
+ }, H = async (n) => {
572
572
  const e = /* @__PURE__ */ new Map();
573
573
  for (const i of n) {
574
574
  if (i.source !== "json") continue;
575
- const [s] = C(i.language);
575
+ const [s] = k(i.language);
576
576
  e.has(s) || e.set(s, []), e.get(s).push(i);
577
577
  }
578
578
  const t = /* @__PURE__ */ new Map();
@@ -590,14 +590,14 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
590
590
  a.size > 0 && t.set(i, a);
591
591
  }
592
592
  return t;
593
- }, Si = {
593
+ }, Ei = {
594
594
  veryLow: 1,
595
595
  low: 2,
596
596
  normal: 3,
597
597
  high: 4,
598
598
  veryHigh: 5
599
- }, ve = (n) => n ? Si[n] ?? 0 : 0, G = (n, e, t, i) => {
600
- const s = ve(n.quality), a = ve(e.quality);
599
+ }, Se = (n) => n ? Ei[n] ?? 0 : 0, $ = (n, e, t, i) => {
600
+ const s = Se(n.quality), a = Se(e.quality);
601
601
  if (t && i && n.source === "json" && e.source === "json") {
602
602
  const r = t.get(i);
603
603
  if (r) {
@@ -607,38 +607,38 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
607
607
  }
608
608
  }
609
609
  return a !== s ? a - s : n.name.localeCompare(e.name);
610
- }, Ie = (n, e) => {
610
+ }, Pe = (n, e) => {
611
611
  const t = new Map(e.map((a) => [a.baseLang, a])), i = /* @__PURE__ */ new Map(), s = [];
612
612
  for (const a of n) {
613
- const [r] = C(a.language);
613
+ const [r] = k(a.language);
614
614
  t.get(r) ? (i.has(r) || i.set(r, []), i.get(r).push(a)) : s.push(a);
615
615
  }
616
616
  return { voicesByLang: i, otherLangVoices: s };
617
- }, ln = (n, e, t, i) => {
618
- const [, s] = C(n.language), [, a] = C(e.language), r = s && t.regions.includes(s), o = a && t.regions.includes(a);
617
+ }, un = (n, e, t, i) => {
618
+ const [, s] = k(n.language), [, a] = k(e.language), r = s && t.regions.includes(s), o = a && t.regions.includes(a);
619
619
  if (r && o) {
620
620
  const d = t.regions.indexOf(s), h = t.regions.indexOf(a);
621
- return d === h ? G(n, e, i, t.baseLang) : d - h;
621
+ return d === h ? $(n, e, i, t.baseLang) : d - h;
622
622
  }
623
623
  if (r) return -1;
624
624
  if (o) return 1;
625
- const l = Ee(t.baseLang), [, c] = C(l), u = !!c && s === c, g = !!c && a === c;
625
+ const l = Re(t.baseLang), [, c] = k(l), u = !!c && s === c, g = !!c && a === c;
626
626
  if (u && !g) return -1;
627
627
  if (!u && g) return 1;
628
628
  if (s && a) {
629
629
  const d = s.localeCompare(a);
630
- return d !== 0 ? d : G(n, e, i, t.baseLang);
631
- }
632
- return s ? -1 : a ? 1 : G(n, e, i, t.baseLang);
633
- }, bi = async (n, e, t) => {
634
- const i = t ?? await W(n);
635
- n.sort((s, a) => ln(s, a, e, i));
636
- }, cn = (n, e, t) => {
637
- const [i] = C(n.language), [s] = C(e.language), a = De(i).toLowerCase(), r = De(s).toLowerCase(), o = a.localeCompare(r);
630
+ return d !== 0 ? d : $(n, e, i, t.baseLang);
631
+ }
632
+ return s ? -1 : a ? 1 : $(n, e, i, t.baseLang);
633
+ }, Ri = async (n, e, t) => {
634
+ const i = t ?? await H(n);
635
+ n.sort((s, a) => un(s, a, e, i));
636
+ }, hn = (n, e, t) => {
637
+ const [i] = k(n.language), [s] = k(e.language), a = De(i).toLowerCase(), r = De(s).toLowerCase(), o = a.localeCompare(r);
638
638
  if (o !== 0)
639
639
  return o;
640
640
  if (i === s) {
641
- const l = Ee(i), [, c] = C(n.language), [, u] = C(e.language), g = l && c === l.split("-")[1], d = l && u === l.split("-")[1];
641
+ const l = Re(i), [, c] = k(n.language), [, u] = k(e.language), g = l && c === l.split("-")[1], d = l && u === l.split("-")[1];
642
642
  if (g && !d) return -1;
643
643
  if (!g && d) return 1;
644
644
  if (c && u) {
@@ -646,36 +646,36 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
646
646
  if (h !== 0)
647
647
  return h;
648
648
  }
649
- return c && !u ? -1 : !c && u ? 1 : G(n, e, t, i);
649
+ return c && !u ? -1 : !c && u ? 1 : $(n, e, t, i);
650
650
  }
651
- return G(n, e, t, i);
651
+ return $(n, e, t, i);
652
652
  }, Fe = async (n, e) => {
653
- const t = e ?? await W(n);
654
- n.sort((i, s) => cn(i, s, t));
655
- }, un = async (n, e) => {
653
+ const t = e ?? await H(n);
654
+ n.sort((i, s) => hn(i, s, t));
655
+ }, dn = async (n, e) => {
656
656
  if (!e?.length) return [];
657
- const t = Re(n || []), { voicesByLang: i, otherLangVoices: s } = Ie(e, t), a = await W(e), r = [];
657
+ const t = Ie(n || []), { voicesByLang: i, otherLangVoices: s } = Pe(e, t), a = await H(e), r = [];
658
658
  for (const o of t) {
659
659
  const l = i.get(o.baseLang);
660
- l && (await bi(l, o, a), r.push(...l));
660
+ l && (await Ri(l, o, a), r.push(...l));
661
661
  }
662
662
  return await Fe(s, a), r.push(...s), r;
663
- }, hn = async (n, e) => {
663
+ }, gn = async (n, e) => {
664
664
  if (!e.length) return null;
665
- const [t] = Re([n]), { voicesByLang: i, otherLangVoices: s } = Ie(e, [t]), a = i.get(t.baseLang), r = a?.length ? a : s, o = await W(e), l = a?.length ? (c, u) => ln(c, u, t, o) : (c, u) => cn(c, u, o);
665
+ const [t] = Ie([n]), { voicesByLang: i, otherLangVoices: s } = Pe(e, [t]), a = i.get(t.baseLang), r = a?.length ? a : s, o = await H(e), l = a?.length ? (c, u) => un(c, u, t, o) : (c, u) => hn(c, u, o);
666
666
  return r.reduce((c, u) => l(u, c) < 0 ? u : c);
667
667
  }, it = (n, e) => {
668
668
  const t = n.filter((i) => i.controls?.boundary !== !1 === e);
669
669
  return t.length > 0 ? t : n;
670
- }, wi = [{ name: "Albert", nativeID: ["com.apple.speech.synthesis.voice.Albert"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bad News", nativeID: ["com.apple.speech.synthesis.voice.BadNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Mauvaises nouvelles", "Malas noticias", "Brutte notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bahh", nativeID: ["com.apple.speech.synthesis.voice.Bahh"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bells", nativeID: ["com.apple.speech.synthesis.voice.Bells"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Cloches", "Campanas", "Campane"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Boing", nativeID: ["com.apple.speech.synthesis.voice.Boing"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bubbles", nativeID: ["com.apple.speech.synthesis.voice.Bubbles"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bulles", "Burbujas", "Bollicine"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Cellos", nativeID: ["com.apple.speech.synthesis.voice.Cellos"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Violoncelles", "Violonchelos", "Violoncelli"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Good News", nativeID: ["com.apple.speech.synthesis.voice.GoodNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bonnes nouvelles", "Buenas noticias", "Buone notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jester", nativeID: ["com.apple.speech.synthesis.voice.Hysterical"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bouffon", "Bufón", "Giullare"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Organ", nativeID: ["com.apple.speech.synthesis.voice.Organ"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Orgue", "Órgano", "Organo"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Superstar", nativeID: ["com.apple.speech.synthesis.voice.Princess"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Superestrella"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Trinoids", nativeID: ["com.apple.speech.synthesis.voice.Trinoids"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Trinoïdes"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Whisper", nativeID: ["com.apple.speech.synthesis.voice.Whisper"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Murmure", "Susurro", "Sussurro"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Wobble", nativeID: ["com.apple.speech.synthesis.voice.Deranged"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Zarvox", nativeID: ["com.apple.speech.synthesis.voice.Zarvox"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }], ki = {
671
- voices: wi
672
- }, Ci = [{ name: "Eddy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Flo", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandma", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandpa", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jacques", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Reed", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Rocko", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Sandy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Shelley", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Fred", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Junior", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Kathy", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Ralph", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "eSpeak Arabic", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ar", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bulgarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bg", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bengali", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Catalan", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ca", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Chinese (Mandarin, latin as English)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cmn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Czech", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cs", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Danish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "da", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak German", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "de", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Greek", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "el", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Spanish (Spain)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "es", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Estonian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "et", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Finnish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "fi", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Gujarati", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "gu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Croatian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Hungarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Indonesian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "id", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Italian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "it", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Kannada", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "kn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Korean", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ko", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Lithuanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lt", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Latvian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malayalm", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ml", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Marathi", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "mr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malay", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ms", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Norwegian Bokmål", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "nb", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Polish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Portuguese (Brazil)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pt-br", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Romanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ro", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Russian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ru", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovak", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sk", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovenian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Serbian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swedish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swahili", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sw", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Tamil", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ta", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Telugu", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "te", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Turkish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "tr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Vietnamese (Northern)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "vi", os: ["ChromeOS"], preloaded: !0 }], Ei = {
673
- voices: Ci
674
- }, Ri = ki, Ii = Ei, _e = (n, e) => Ri.voices.some(
670
+ }, Ii = [{ name: "Albert", nativeID: ["com.apple.speech.synthesis.voice.Albert"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bad News", nativeID: ["com.apple.speech.synthesis.voice.BadNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Mauvaises nouvelles", "Malas noticias", "Brutte notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bahh", nativeID: ["com.apple.speech.synthesis.voice.Bahh"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bells", nativeID: ["com.apple.speech.synthesis.voice.Bells"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Cloches", "Campanas", "Campane"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Boing", nativeID: ["com.apple.speech.synthesis.voice.Boing"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bubbles", nativeID: ["com.apple.speech.synthesis.voice.Bubbles"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bulles", "Burbujas", "Bollicine"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Cellos", nativeID: ["com.apple.speech.synthesis.voice.Cellos"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Violoncelles", "Violonchelos", "Violoncelli"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Good News", nativeID: ["com.apple.speech.synthesis.voice.GoodNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bonnes nouvelles", "Buenas noticias", "Buone notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jester", nativeID: ["com.apple.speech.synthesis.voice.Hysterical"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bouffon", "Bufón", "Giullare"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Organ", nativeID: ["com.apple.speech.synthesis.voice.Organ"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Orgue", "Órgano", "Organo"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Superstar", nativeID: ["com.apple.speech.synthesis.voice.Princess"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Superestrella"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Trinoids", nativeID: ["com.apple.speech.synthesis.voice.Trinoids"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Trinoïdes"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Whisper", nativeID: ["com.apple.speech.synthesis.voice.Whisper"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Murmure", "Susurro", "Sussurro"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Wobble", nativeID: ["com.apple.speech.synthesis.voice.Deranged"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Zarvox", nativeID: ["com.apple.speech.synthesis.voice.Zarvox"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }], Pi = {
671
+ voices: Ii
672
+ }, Ai = [{ name: "Eddy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Flo", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandma", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandpa", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jacques", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Reed", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Rocko", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Sandy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Shelley", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Fred", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Junior", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Kathy", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Ralph", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "eSpeak Arabic", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ar", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bulgarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bg", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bengali", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Catalan", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ca", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Chinese (Mandarin, latin as English)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cmn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Czech", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cs", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Danish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "da", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak German", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "de", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Greek", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "el", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Spanish (Spain)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "es", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Estonian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "et", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Finnish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "fi", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Gujarati", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "gu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Croatian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Hungarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Indonesian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "id", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Italian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "it", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Kannada", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "kn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Korean", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ko", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Lithuanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lt", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Latvian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malayalm", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ml", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Marathi", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "mr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malay", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ms", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Norwegian Bokmål", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "nb", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Polish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Portuguese (Brazil)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pt-br", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Romanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ro", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Russian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ru", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovak", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sk", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovenian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Serbian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swedish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swahili", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sw", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Tamil", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ta", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Telugu", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "te", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Turkish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "tr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Vietnamese (Northern)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "vi", os: ["ChromeOS"], preloaded: !0 }], Li = {
673
+ voices: Ai
674
+ }, Oi = Pi, Vi = Li, _e = (n, e) => Oi.voices.some(
675
675
  (t) => n.includes(t.name) || e && t.nativeID?.some((i) => e.includes(i)) || t.altNames?.some((i) => n.includes(i))
676
- ), $e = (n, e) => Ii.voices.some(
676
+ ), $e = (n, e) => Vi.voices.some(
677
677
  (t) => n.includes(t.name)
678
- ) || e === "veryLow", Pt = (n) => n?.length ? n.filter((e) => !(e.isNovelty || _e(e.name, e.voiceURI))) : [], At = (n) => n?.length ? n.filter((e) => !$e(e.name, e.quality)) : [], Pi = (n, e) => {
678
+ ) || e === "veryLow", At = (n) => n?.length ? n.filter((e) => !(e.isNovelty || _e(e.name, e.voiceURI))) : [], Lt = (n) => n?.length ? n.filter((e) => !$e(e.name, e.quality)) : [], xi = (n, e) => {
679
679
  const t = Array.isArray(e) ? e : [e];
680
680
  return n.filter((i) => t.some((s) => {
681
681
  const a = s.toLowerCase(), r = i.language?.toLowerCase(), o = i.altLanguage?.toLowerCase();
@@ -684,17 +684,17 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
684
684
  const [l] = a.split("-");
685
685
  return r && r.startsWith(l) || o && o.startsWith(l);
686
686
  }));
687
- }, Ai = { ar: { normal: "محسن", high: "استثنائي" }, ca: { normal: "millorada", high: "prèmium" }, "cmn-CN": { normal: "优化音质", high: "高音质" }, "cmn-TW": { normal: "增強音質", high: "高音質" }, cs: { normal: "vylepšená verze", high: "prémiový" }, da: { normal: "forbedret", high: "høj kvalitet" }, de: { normal: "erweitert", high: "premium" }, el: { normal: "βελτιωμένη", high: "υψηλής ποιότητας" }, en: { normal: "Enhanced", high: "Premium" }, es: { normal: "mejorada", high: "premium" }, fi: { normal: "parannettu", high: "korkealaatuinen" }, fr: { normal: "premium", high: "de qualité" }, he: { normal: "משופר", high: "פרימיום" }, hi: { normal: "बेहतर", high: "प्रीमियम" }, hr: { normal: "poboljšani", high: "vrhunski" }, hu: { normal: "továbbfejlesztett", high: "prémium" }, id: { normal: "Ditingkatkan", high: "Premium" }, it: { normal: "ottimizzata", high: "premium" }, ja: { normal: "拡張", high: "プレミアム" }, ko: { normal: "고품질", high: "프리미엄" }, ms: { normal: "Dipertingkat", high: "Premium" }, nb: { normal: "forbedret", high: "premium" }, nl: { normal: "verbeterd", high: "premium" }, pl: { normal: "rozszerzony", high: "premium" }, pt: { normal: "melhorada", high: "premium" }, ro: { normal: "îmbunătățită", high: "premium" }, ru: { normal: "улучшенный", high: "высшее качество" }, sk: { normal: "vylepšený", high: "prémiový" }, sl: { normal: "izboljšano", high: "prvovrsten" }, sv: { normal: "förbättrad", high: "premium" }, th: { normal: "คุณภาพสูง", high: "คุณภาพสูง" }, tr: { normal: "Geliştirilmiş", high: "Yüksek Kaliteli" }, uk: { normal: "вдосконалений", high: "високої якості" }, vi: { normal: "Nâng cao", high: "Cao cấp" } }, Li = {
688
- quality: Ai
687
+ }, Ui = { ar: { normal: "محسن", high: "استثنائي" }, ca: { normal: "millorada", high: "prèmium" }, "cmn-CN": { normal: "优化音质", high: "高音质" }, "cmn-TW": { normal: "增強音質", high: "高音質" }, cs: { normal: "vylepšená verze", high: "prémiový" }, da: { normal: "forbedret", high: "høj kvalitet" }, de: { normal: "erweitert", high: "premium" }, el: { normal: "βελτιωμένη", high: "υψηλής ποιότητας" }, en: { normal: "Enhanced", high: "Premium" }, es: { normal: "mejorada", high: "premium" }, fi: { normal: "parannettu", high: "korkealaatuinen" }, fr: { normal: "premium", high: "de qualité" }, he: { normal: "משופר", high: "פרימיום" }, hi: { normal: "बेहतर", high: "प्रीमियम" }, hr: { normal: "poboljšani", high: "vrhunski" }, hu: { normal: "továbbfejlesztett", high: "prémium" }, id: { normal: "Ditingkatkan", high: "Premium" }, it: { normal: "ottimizzata", high: "premium" }, ja: { normal: "拡張", high: "プレミアム" }, ko: { normal: "고품질", high: "프리미엄" }, ms: { normal: "Dipertingkat", high: "Premium" }, nb: { normal: "forbedret", high: "premium" }, nl: { normal: "verbeterd", high: "premium" }, pl: { normal: "rozszerzony", high: "premium" }, pt: { normal: "melhorada", high: "premium" }, ro: { normal: "îmbunătățită", high: "premium" }, ru: { normal: "улучшенный", high: "высшее качество" }, sk: { normal: "vylepšený", high: "prémiový" }, sl: { normal: "izboljšano", high: "prvovrsten" }, sv: { normal: "förbättrad", high: "premium" }, th: { normal: "คุณภาพสูง", high: "คุณภาพสูง" }, tr: { normal: "Geliştirilmiş", high: "Yüksek Kaliteli" }, uk: { normal: "вдосконалений", high: "високої якості" }, vi: { normal: "Nâng cao", high: "Cao cấp" } }, Ti = {
688
+ quality: Ui
689
689
  }, qe = {
690
- apple: Li.quality
690
+ apple: Ti.quality
691
691
  // android: androidQualities.quality
692
- }, Oi = (n, e, t) => {
692
+ }, zi = (n, e, t) => {
693
693
  if (!n) return;
694
694
  const i = Array.isArray(t) ? t : t ? [t] : [];
695
695
  for (const s of i)
696
696
  if (s && qe[s]) {
697
- const a = qe[s], r = C(e)[0], o = a[e] || a[r];
697
+ const a = qe[s], r = k(e)[0], o = a[e] || a[r];
698
698
  if (o) {
699
699
  const l = n.toLowerCase(), { normal: c, high: u } = o;
700
700
  if (u && l.includes(u.toLowerCase()))
@@ -703,7 +703,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
703
703
  return "normal";
704
704
  }
705
705
  }
706
- }, xi = (n, e) => {
706
+ }, Ni = (n, e) => {
707
707
  const t = qe[e];
708
708
  if (t)
709
709
  for (const [i, { high: s, normal: a }] of Object.entries(t)) {
@@ -711,7 +711,7 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
711
711
  if (r && o)
712
712
  return i;
713
713
  }
714
- }, Vi = {
714
+ }, Mi = {
715
715
  low: {
716
716
  values: ["super-compact", "compact"],
717
717
  quality: "low"
@@ -724,27 +724,27 @@ const mi = ["veryLow", "low", "normal", "high", "veryHigh"], vi = ["android", "a
724
724
  values: ["premium"],
725
725
  quality: "high"
726
726
  }
727
- }, Lt = (n) => {
727
+ }, Ot = (n) => {
728
728
  if (!n) return;
729
729
  const t = n.toLowerCase().split(/[._-]/);
730
- for (const i of Object.values(Vi))
730
+ for (const i of Object.values(Mi))
731
731
  if (i.values.some((s) => t.includes(s)))
732
732
  return i.quality;
733
733
  };
734
- function Ui(n, e) {
734
+ function Bi(n, e) {
735
735
  if (n.name === n.originalName) return n;
736
736
  if (e.name === e.originalName) return e;
737
737
  const t = [n.originalName, ...n.altNames || []], i = [e.originalName, ...e.altNames || []], s = t.findIndex((r) => i.includes(r)), a = i.findIndex((r) => t.includes(r));
738
738
  return s === -1 && a === -1 || s !== -1 && (a === -1 || s <= a) ? n : e;
739
739
  }
740
- function Ti(n, e) {
740
+ function ji(n, e) {
741
741
  if (!n.altNames && !e.altNames)
742
742
  return !1;
743
743
  const t = n.originalName, i = e.originalName, s = n.altNames || [], a = e.altNames || [];
744
744
  return a.includes(t) || s.includes(i) ? !0 : s.filter((o) => a.includes(o)).length > 0;
745
745
  }
746
- const dn = () => {
747
- const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), i = () => /kaios/i.test(e), s = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => typeof window.GestureEvent < "u" || /safari/i.test(e);
746
+ const fn = () => {
747
+ const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), i = () => /kaios/i.test(e), s = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => /AppleWebKit/i.test(e) && !/Chrome|Chromium|Edg\/|OPR|Android/i.test(e);
748
748
  return {
749
749
  isAndroid: t(),
750
750
  isFirefox: s() || i(),
@@ -752,7 +752,7 @@ const dn = () => {
752
752
  isKaiOS: i()
753
753
  };
754
754
  };
755
- class k {
755
+ class C {
756
756
  static instance;
757
757
  static initializationPromise = null;
758
758
  systemLocale;
@@ -766,7 +766,7 @@ class k {
766
766
  constructor() {
767
767
  if (typeof window > "u" || !window.speechSynthesis)
768
768
  throw new Error("Web Speech API is not available in this environment");
769
- this.systemLocale = navigator.languages?.[0]?.split("-")[0] || "en", this.isAndroid = dn().isAndroid;
769
+ this.systemLocale = navigator.languages?.[0]?.split("-")[0] || "en", this.isAndroid = fn().isAndroid;
770
770
  }
771
771
  /**
772
772
  * Initialize voice manager, or broaden an already-initialized singleton to
@@ -781,20 +781,20 @@ class k {
781
781
  * @returns Promise that resolves with the WebSpeechVoiceManager instance
782
782
  */
783
783
  static async initialize(e) {
784
- if (k.instance?.isInitialized) {
785
- const t = k.instance;
784
+ if (C.instance?.isInitialized) {
785
+ const t = C.instance;
786
786
  return e?.languages && e.languages.length > 0 && await t.broadenLanguages(e.languages), t;
787
787
  }
788
- return k.initializationPromise || (k.initializationPromise = (async () => {
788
+ return C.initializationPromise || (C.initializationPromise = (async () => {
789
789
  try {
790
- const t = new k();
791
- k.instance = t, t.browserVoices = await t.getBrowserVoices(e?.maxTimeout, e?.interval), t.updateSystemLocale(t.browserVoices);
790
+ const t = new C();
791
+ C.instance = t, t.browserVoices = await t.getBrowserVoices(e?.maxTimeout, e?.interval), t.updateSystemLocale(t.browserVoices);
792
792
  let i = t.browserVoices;
793
- return e?.languages && e.languages.length > 0 ? (i = t.filterBrowserVoicesByLanguages(t.browserVoices, e.languages), t.scopedLanguages = k.toBaseLangSet(e.languages)) : t.scopedLanguages = null, t.voices = await t.parseToReadiumSpeechVoices(i), t.isInitialized = !0, t;
793
+ return e?.languages && e.languages.length > 0 ? (i = t.filterBrowserVoicesByLanguages(t.browserVoices, e.languages), t.scopedLanguages = C.toBaseLangSet(e.languages)) : t.scopedLanguages = null, t.voices = await t.parseToReadiumSpeechVoices(i), t.isInitialized = !0, t;
794
794
  } catch (t) {
795
- throw k.initializationPromise = null, console.error("Failed to initialize WebSpeechVoiceManager:", t), t;
795
+ throw C.initializationPromise = null, console.error("Failed to initialize WebSpeechVoiceManager:", t), t;
796
796
  }
797
- })()), k.initializationPromise;
797
+ })()), C.initializationPromise;
798
798
  }
799
799
  /**
800
800
  * Filter browser voices based on preferred languages
@@ -802,10 +802,10 @@ class k {
802
802
  */
803
803
  filterBrowserVoicesByLanguages(e, t) {
804
804
  if (!t?.length) return e;
805
- const i = k.toBaseLangSet(t);
805
+ const i = C.toBaseLangSet(t);
806
806
  return e.filter((s) => {
807
807
  if (!s?.lang) return !1;
808
- const a = x(s.lang), [r] = k.extractLangRegionFromBCP47(a);
808
+ const a = V(s.lang), [r] = C.extractLangRegionFromBCP47(a);
809
809
  return i.has(r);
810
810
  });
811
811
  }
@@ -816,7 +816,7 @@ class k {
816
816
  static toBaseLangSet(e) {
817
817
  return new Set(
818
818
  e.map((t) => {
819
- const i = x(t), [s] = k.extractLangRegionFromBCP47(i);
819
+ const i = V(t), [s] = C.extractLangRegionFromBCP47(i);
820
820
  return s;
821
821
  })
822
822
  );
@@ -829,7 +829,7 @@ class k {
829
829
  */
830
830
  async broadenLanguages(e) {
831
831
  if (this.scopedLanguages === null) return;
832
- const i = [...k.toBaseLangSet(e)].filter((o) => !this.scopedLanguages.has(o));
832
+ const i = [...C.toBaseLangSet(e)].filter((o) => !this.scopedLanguages.has(o));
833
833
  if (i.length === 0) return;
834
834
  const s = i.filter((o) => this.broadenPromises.has(o)), a = i.filter((o) => !this.broadenPromises.has(o));
835
835
  let r;
@@ -847,7 +847,7 @@ class k {
847
847
  * @returns A tuple of [language, region] where language is lowercase and region is UPPERCASE
848
848
  */
849
849
  static extractLangRegionFromBCP47(e) {
850
- return C(e);
850
+ return k(e);
851
851
  }
852
852
  /**
853
853
  * Clean voice name by removing specific formatting
@@ -886,7 +886,7 @@ class k {
886
886
  */
887
887
  updateSystemLocale(e) {
888
888
  if (!e?.length) return;
889
- const t = e.map((s) => s.name), i = xi(t, "apple");
889
+ const t = e.map((s) => s.name), i = Ni(t, "apple");
890
890
  i && (this.systemLocale = i);
891
891
  }
892
892
  /**
@@ -895,15 +895,15 @@ class k {
895
895
  * @private
896
896
  */
897
897
  inferVoiceQuality(e, t, i) {
898
- const s = e.voiceURI ? Lt(e.voiceURI) : void 0;
898
+ const s = e.voiceURI ? Ot(e.voiceURI) : void 0;
899
899
  if (s) return s;
900
900
  if (t?.nativeID && Array.isArray(t.nativeID))
901
901
  for (const a of t.nativeID) {
902
- const r = Lt(a);
902
+ const r = Ot(a);
903
903
  if (r) return r;
904
904
  }
905
905
  if (t?.localizedName && e.voiceURI && e.lang) {
906
- const a = Oi(
906
+ const a = zi(
907
907
  e.voiceURI,
908
908
  this.systemLocale,
909
909
  t.localizedName
@@ -937,12 +937,12 @@ class k {
937
937
  const s = `${i.language.toLowerCase()}_${this.normalizeVoiceName(i.name)}`, a = t.get(s);
938
938
  if (!a)
939
939
  t.set(s, i);
940
- else if (Ti(i, a)) {
941
- const r = Ui(i, a);
940
+ else if (ji(i, a)) {
941
+ const r = Bi(i, a);
942
942
  t.set(s, r);
943
943
  } else {
944
- const r = ve(a.quality);
945
- ve(i.quality) >= r && t.set(s, i);
944
+ const r = Se(a.quality);
945
+ Se(i.quality) >= r && t.set(s, i);
946
946
  }
947
947
  }
948
948
  return Array.from(t.values());
@@ -954,11 +954,11 @@ class k {
954
954
  */
955
955
  getTestUtterance(e) {
956
956
  if (!e) return "";
957
- const t = It(e);
957
+ const t = Pt(e);
958
958
  if (t) return t;
959
- const [i] = k.extractLangRegionFromBCP47(e);
959
+ const [i] = C.extractLangRegionFromBCP47(e);
960
960
  if (i && i !== e) {
961
- const s = It(i);
961
+ const s = Pt(i);
962
962
  if (s) return s;
963
963
  }
964
964
  return "";
@@ -999,7 +999,7 @@ class k {
999
999
  countLanguages(e, t) {
1000
1000
  const i = /* @__PURE__ */ new Map();
1001
1001
  for (const s of e) {
1002
- const a = x(s).split("-")[0];
1002
+ const a = V(s).split("-")[0];
1003
1003
  i.set(a, (i.get(a) ?? 0) + 1);
1004
1004
  }
1005
1005
  return [...i].map(([s, a]) => ({ code: s, label: De(s, t), count: a }));
@@ -1015,11 +1015,11 @@ class k {
1015
1015
  throw new Error("WebSpeechVoiceManager not initialized. Call initialize() first.");
1016
1016
  const s = i ?? this.voices, a = t ? this.filterVoices(t, s) : s, r = [], o = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
1017
1017
  for (const c of a) {
1018
- const [, u] = k.extractLangRegionFromBCP47(c.language);
1018
+ const [, u] = C.extractLangRegionFromBCP47(c.language);
1019
1019
  u && l.set(u, (l.get(u) || 0) + 1);
1020
1020
  }
1021
1021
  for (const c of a) {
1022
- const [, u] = k.extractLangRegionFromBCP47(c.language);
1022
+ const [, u] = C.extractLangRegionFromBCP47(c.language);
1023
1023
  if (u && !o.has(u)) {
1024
1024
  let g = c.language;
1025
1025
  try {
@@ -1082,7 +1082,7 @@ class k {
1082
1082
  const t = this.countVoiceDuplicates(e);
1083
1083
  return await Promise.all(
1084
1084
  e.filter((s) => s?.name && s?.lang).map(async (s) => {
1085
- const a = x(s.lang), [r] = k.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(s.name), l = `${s.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
1085
+ const a = V(s.lang), [r] = C.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(s.name), l = `${s.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
1086
1086
  let u = await je(a);
1087
1087
  (!u || u.length === 0) && (u = await je(r));
1088
1088
  const g = this.findMatchingJsonVoice(u, o), d = this.inferVoiceQuality(s, g, c), h = this.isAndroid ? { ...g?.controls, boundary: !1 } : g?.controls;
@@ -1138,13 +1138,13 @@ class k {
1138
1138
  ...e
1139
1139
  // Let explicit options override the defaults
1140
1140
  };
1141
- if (s.languages && (i = Pi(i, s.languages)), s.source && (i = i.filter((a) => a.source === s.source)), s.gender && (i = i.filter((a) => a.gender === s.gender)), s.quality) {
1141
+ if (s.languages && (i = xi(i, s.languages)), s.source && (i = i.filter((a) => a.source === s.source)), s.gender && (i = i.filter((a) => a.gender === s.gender)), s.quality) {
1142
1142
  const a = Array.isArray(s.quality) ? s.quality : [s.quality];
1143
1143
  i = i.filter((r) => r.quality && a.includes(r.quality));
1144
1144
  }
1145
1145
  return s.offlineOnly && (i = i.filter((a) => a.offlineAvailability === !0)), s.provider && (i = i.filter(
1146
1146
  (a) => a.provider?.toLowerCase() === s.provider?.toLowerCase()
1147
- )), s.excludeNovelty && (i = Pt(i)), s.excludeVeryLowQuality && (i = At(i)), s.removeDuplicates && (i = this.removeDuplicates(i)), i;
1147
+ )), s.excludeNovelty && (i = At(i)), s.excludeVeryLowQuality && (i = Lt(i)), s.removeDuplicates && (i = this.removeDuplicates(i)), i;
1148
1148
  }
1149
1149
  /**
1150
1150
  * Filter out novelty voices
@@ -1153,7 +1153,7 @@ class k {
1153
1153
  */
1154
1154
  filterOutNoveltyVoices(e) {
1155
1155
  const t = e ?? this.voices;
1156
- return Pt(t);
1156
+ return At(t);
1157
1157
  }
1158
1158
  /**
1159
1159
  * Filter out very low quality voices
@@ -1162,7 +1162,7 @@ class k {
1162
1162
  */
1163
1163
  filterOutVeryLowQualityVoices(e) {
1164
1164
  const t = e ?? this.voices;
1165
- return At(t);
1165
+ return Lt(t);
1166
1166
  }
1167
1167
  /**
1168
1168
  * Sort voices by quality, respecting JSON name order, then alphabetically for undefined/null quality
@@ -1172,17 +1172,17 @@ class k {
1172
1172
  async sortVoicesByQuality(e) {
1173
1173
  const t = e || this.voices;
1174
1174
  if (!t?.length) return [];
1175
- const i = await W(t);
1176
- return [...t].sort((s, a) => G(s, a, i));
1175
+ const i = await H(t);
1176
+ return [...t].sort((s, a) => $(s, a, i));
1177
1177
  }
1178
1178
  /**
1179
1179
  * Sort regions by default then alphabetically, sort voices by quality
1180
1180
  */
1181
1181
  static async sortByDefaultRegion(e, t) {
1182
- const i = await W(e), s = Ee(t);
1182
+ const i = await H(e), s = Re(t);
1183
1183
  e.sort((a, r) => {
1184
- const [, o] = k.extractLangRegionFromBCP47(a.language), [, l] = k.extractLangRegionFromBCP47(r.language), c = s && o === s.split("-")[1], u = s && l === s.split("-")[1];
1185
- return c && !u ? -1 : !c && u ? 1 : G(a, r, i, t);
1184
+ const [, o] = C.extractLangRegionFromBCP47(a.language), [, l] = C.extractLangRegionFromBCP47(r.language), c = s && o === s.split("-")[1], u = s && l === s.split("-")[1];
1185
+ return c && !u ? -1 : !c && u ? 1 : $(a, r, i, t);
1186
1186
  });
1187
1187
  }
1188
1188
  /**
@@ -1198,10 +1198,10 @@ class k {
1198
1198
  const l = [...i];
1199
1199
  return await Fe(l), l;
1200
1200
  }
1201
- const s = Re(e), { voicesByLang: a, otherLangVoices: r } = Ie(i, s), o = [];
1201
+ const s = Ie(e), { voicesByLang: a, otherLangVoices: r } = Pe(i, s), o = [];
1202
1202
  for (const l of s) {
1203
1203
  const c = a.get(l.baseLang);
1204
- c && (await k.sortByDefaultRegion(c, l.baseLang), o.push(...c));
1204
+ c && (await C.sortByDefaultRegion(c, l.baseLang), o.push(...c));
1205
1205
  }
1206
1206
  return await Fe(r), o.push(...r), o;
1207
1207
  }
@@ -1212,7 +1212,7 @@ class k {
1212
1212
  * @returns Sorted array of voices
1213
1213
  */
1214
1214
  async sortVoicesByRegions(e, t) {
1215
- return un(e, t || this.voices);
1215
+ return dn(e, t || this.voices);
1216
1216
  }
1217
1217
  /**
1218
1218
  * Group voices by the specified criteria
@@ -1226,7 +1226,7 @@ class k {
1226
1226
  let r = "Unknown";
1227
1227
  switch (e) {
1228
1228
  case "languages":
1229
- r = k.extractLangRegionFromBCP47(a.language)[0];
1229
+ r = C.extractLangRegionFromBCP47(a.language)[0];
1230
1230
  break;
1231
1231
  case "gender":
1232
1232
  r = a.gender || "unknown";
@@ -1235,7 +1235,7 @@ class k {
1235
1235
  r = a.quality || "unknown";
1236
1236
  break;
1237
1237
  case "region":
1238
- const [, o] = k.extractLangRegionFromBCP47(a.language);
1238
+ const [, o] = C.extractLangRegionFromBCP47(a.language);
1239
1239
  r = o || "unknown";
1240
1240
  break;
1241
1241
  }
@@ -1244,10 +1244,10 @@ class k {
1244
1244
  return i;
1245
1245
  }
1246
1246
  }
1247
- const gn = (n, e) => {
1248
- const [t, i] = C(e), [s, a] = C(n.language);
1247
+ const pn = (n, e) => {
1248
+ const [t, i] = k(e), [s, a] = k(n.language);
1249
1249
  return s === t && (!i || a === i);
1250
- }, Ge = (n, e) => !!n && C(n.language)[0] === C(e)[0], zi = ["webKit", "moz", "ms", "o"], Ni = [
1250
+ }, Ge = (n, e) => !!n && k(n.language)[0] === k(e)[0], Di = ["webKit", "moz", "ms", "o"], Fi = [
1251
1251
  "boundary",
1252
1252
  "end",
1253
1253
  "error",
@@ -1255,10 +1255,10 @@ const gn = (n, e) => {
1255
1255
  "pause",
1256
1256
  "resume",
1257
1257
  "start"
1258
- ], Mi = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, te = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], Bi = (n) => typeof window < "u" && n in window, ji = (n) => {
1259
- const e = Mi(n), t = zi.map((s) => `${s}${e}`), i = [n, e].concat(t).find(Bi);
1258
+ ], _i = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, ne = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], $i = (n) => typeof window < "u" && n in window, qi = (n) => {
1259
+ const e = _i(n), t = Di.map((s) => `${s}${e}`), i = [n, e].concat(t).find($i);
1260
1260
  return i && typeof window < "u" ? window[i] : void 0;
1261
- }, Di = () => {
1261
+ }, Gi = () => {
1262
1262
  const n = {};
1263
1263
  [
1264
1264
  "speechSynthesis",
@@ -1267,15 +1267,15 @@ const gn = (n, e) => {
1267
1267
  "speechSynthesisEvent",
1268
1268
  "speechSynthesisErrorEvent"
1269
1269
  ].forEach((t) => {
1270
- n[t] = ji(t);
1271
- }), n.onvoiceschanged = te(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = te(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = te(n.speechSynthesis, "paused");
1272
- const e = n.speechSynthesisUtterance ? te(n.speechSynthesisUtterance, "prototype") : !1;
1273
- return Ni.forEach((t) => {
1270
+ n[t] = qi(t);
1271
+ }), n.onvoiceschanged = ne(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = ne(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = ne(n.speechSynthesis, "paused");
1272
+ const e = n.speechSynthesisUtterance ? ne(n.speechSynthesisUtterance, "prototype") : !1;
1273
+ return Fi.forEach((t) => {
1274
1274
  const i = `on${t}`;
1275
- n[i] = e && n.speechSynthesisUtterance ? te(n.speechSynthesisUtterance.prototype, i) : !1;
1275
+ n[i] = e && n.speechSynthesisUtterance ? ne(n.speechSynthesisUtterance.prototype, i) : !1;
1276
1276
  }), n;
1277
1277
  };
1278
- class Pe {
1278
+ class Ae {
1279
1279
  listeners = /* @__PURE__ */ new Map();
1280
1280
  on(e, t) {
1281
1281
  return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t), () => {
@@ -1300,46 +1300,46 @@ class Pe {
1300
1300
  this.listeners.clear();
1301
1301
  }
1302
1302
  }
1303
- const me = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1304
- function H(n, e, t, i) {
1303
+ const ye = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
1304
+ function q(n, e, t, i) {
1305
1305
  return Number.isFinite(n) ? Math.max(e, Math.min(t, n)) : i;
1306
1306
  }
1307
- const He = "\\p{Ps}\\p{Pi}¿¡", Fi = new RegExp(`^[${He}]`, "u"), _i = new RegExp("^\\p{P}$", "u");
1308
- function $i(n) {
1309
- return Fi.test(n);
1307
+ const He = "\\p{Ps}\\p{Pi}¿¡", Hi = new RegExp(`^[${He}]`, "u"), Ki = new RegExp("^\\p{P}$", "u");
1308
+ function Wi(n) {
1309
+ return Hi.test(n);
1310
1310
  }
1311
- function qi(n) {
1312
- return _i.test(n);
1311
+ function Qi(n) {
1312
+ return Ki.test(n);
1313
1313
  }
1314
- function fn(n) {
1314
+ function mn(n) {
1315
1315
  return n.replace(/[<>]/g, "​");
1316
1316
  }
1317
- function Gi(n) {
1317
+ function Ji(n) {
1318
1318
  return n.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&nbsp;/g, " ").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-fA-F]+);/g, (e, t) => String.fromCodePoint(parseInt(t, 16)));
1319
1319
  }
1320
- const Hi = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1321
- function Ki(n) {
1322
- return n.replace(Hi, (t, i, s) => {
1320
+ const Zi = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
1321
+ function Xi(n) {
1322
+ return n.replace(Zi, (t, i, s) => {
1323
1323
  const a = s.slice(i + t.length);
1324
- return a.length === 0 || ue(a) ? "" : " ";
1324
+ return a.length === 0 || he(a) ? "" : " ";
1325
1325
  }).replace(/ {2,}/g, " ").trim();
1326
1326
  }
1327
- function Wi(n) {
1327
+ function Yi(n) {
1328
1328
  return n.includes("<");
1329
1329
  }
1330
1330
  function st(n) {
1331
1331
  if (n === void 0) return;
1332
1332
  const e = {};
1333
1333
  if (n.language !== void 0 && (e.language = n.language), n.ssml) {
1334
- const t = Ki(n.ssml);
1335
- Wi(t) && (e.ssml = t);
1334
+ const t = Xi(n.ssml);
1335
+ Yi(t) && (e.ssml = t);
1336
1336
  }
1337
1337
  return n.plain && (e.plain = n.plain), e.plain || e.ssml ? e : void 0;
1338
1338
  }
1339
- function M(n) {
1340
- return pn(n).plain;
1339
+ function N(n) {
1340
+ return vn(n).plain;
1341
1341
  }
1342
- function pn(n) {
1342
+ function vn(n) {
1343
1343
  let e = "";
1344
1344
  const t = [];
1345
1345
  let i = !1, s = 0;
@@ -1347,7 +1347,7 @@ function pn(n) {
1347
1347
  const o = n[s];
1348
1348
  if (o === "<") {
1349
1349
  const c = n.indexOf(">", s), u = c === -1 ? "" : n.slice(c + 1);
1350
- s = c === -1 ? n.length : c + 1, !i && e.length > 0 && u.length > 0 && !ue(u) && (e += " ", t.push(s), i = !0);
1350
+ s = c === -1 ? n.length : c + 1, !i && e.length > 0 && u.length > 0 && !he(u) && (e += " ", t.push(s), i = !0);
1351
1351
  continue;
1352
1352
  }
1353
1353
  const l = n.startsWith("&lt;", s) ? "<" : n.startsWith("&gt;", s) ? ">" : n.startsWith("&amp;", s) ? "&" : void 0;
@@ -1367,7 +1367,7 @@ function pn(n) {
1367
1367
  for (; r > a && /\s/.test(e[r - 1]); ) r--;
1368
1368
  return { plain: e.slice(a, r), map: t.slice(a, r) };
1369
1369
  }
1370
- function Ot(n, e) {
1370
+ function Vt(n, e) {
1371
1371
  let t = 0, i = n.length;
1372
1372
  for (; t < i; ) {
1373
1373
  const s = t + i >> 1;
@@ -1376,26 +1376,26 @@ function Ot(n, e) {
1376
1376
  return t;
1377
1377
  }
1378
1378
  const xt = /* @__PURE__ */ new WeakMap();
1379
- function Qi(n) {
1379
+ function es(n) {
1380
1380
  return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1381
1381
  }
1382
- function Ji(n) {
1383
- const e = Qi(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", i = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1382
+ function ts(n) {
1383
+ const e = es(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", i = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
1384
1384
  return `${t}${e}${i}`;
1385
1385
  }
1386
- function Zi(n, e) {
1386
+ function ns(n, e) {
1387
1387
  if (typeof e == "string")
1388
- return { regex: new RegExp(Ji(n), "g"), replace: e };
1388
+ return { regex: new RegExp(ts(n), "g"), replace: e };
1389
1389
  const t = e.pattern.flags.includes("g") ? e.pattern.flags : `${e.pattern.flags}g`;
1390
1390
  return { regex: new RegExp(e.pattern.source, t), replace: e.replace };
1391
1391
  }
1392
- function Xi(n) {
1392
+ function is(n) {
1393
1393
  let e = xt.get(n);
1394
- return e || (e = Object.entries(n).map(([t, i]) => Zi(t, i)), xt.set(n, e)), e;
1394
+ return e || (e = Object.entries(n).map(([t, i]) => ns(t, i)), xt.set(n, e)), e;
1395
1395
  }
1396
- function mn(n, e) {
1396
+ function yn(n, e) {
1397
1397
  const t = [];
1398
- for (const a of Xi(e))
1398
+ for (const a of is(e))
1399
1399
  for (const r of n.matchAll(a.regex)) {
1400
1400
  const o = r.index, l = typeof a.replace == "string" ? a.replace : a.replace(...r);
1401
1401
  t.push({ start: o, end: o + r[0].length, replacement: l });
@@ -1407,11 +1407,11 @@ function mn(n, e) {
1407
1407
  a.start < s || (i.push(a), s = a.end);
1408
1408
  return i;
1409
1409
  }
1410
- function Yi(n, e) {
1410
+ function ss(n, e) {
1411
1411
  let t = "";
1412
1412
  const i = [];
1413
1413
  let s = 0;
1414
- for (const a of mn(n, e)) {
1414
+ for (const a of yn(n, e)) {
1415
1415
  for (; s < a.start; )
1416
1416
  t += n[s], i.push(s), s++;
1417
1417
  for (let r = 0; r < a.replacement.length; r++)
@@ -1422,34 +1422,34 @@ function Yi(n, e) {
1422
1422
  t += n[s], i.push(s), s++;
1423
1423
  return { text: t, map: i };
1424
1424
  }
1425
- function Vt(n, e) {
1425
+ function Ut(n, e) {
1426
1426
  return n.length ? e <= 0 ? n[0] : e >= n.length ? n[n.length - 1] + 1 : n[e] : e;
1427
1427
  }
1428
- const es = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1429
- function Ut(n) {
1428
+ const as = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
1429
+ function Tt(n) {
1430
1430
  return n.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
1431
1431
  }
1432
- function vn(n) {
1432
+ function Sn(n) {
1433
1433
  const e = [];
1434
- for (const t of n.matchAll(es))
1435
- t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: Ut(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: Ut(t[0]) });
1434
+ for (const t of n.matchAll(as))
1435
+ t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: Tt(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: Tt(t[0]) });
1436
1436
  return e;
1437
1437
  }
1438
- function ts(n, e) {
1439
- const t = vn(n);
1438
+ function rs(n, e) {
1439
+ const t = Sn(n);
1440
1440
  let i = "", s = !1;
1441
1441
  const a = [], r = t.map(() => []);
1442
1442
  t.forEach((b, P) => {
1443
1443
  if (b.kind === "selfClosing") return;
1444
1444
  const A = b.kind === "paired" ? b.innerText : b.text;
1445
- if (!s && i.length > 0 && A.length > 0 && !ue(A) && !/^\s/.test(A)) {
1445
+ if (!s && i.length > 0 && A.length > 0 && !he(A) && !/^\s/.test(A)) {
1446
1446
  const I = i.length;
1447
1447
  i += " ", r[P].push(a.length), a.push({ start: I, end: I + 1, atomIndex: -1 }), s = !0;
1448
1448
  }
1449
1449
  const E = i.length;
1450
1450
  i += A, r[P].push(a.length), a.push({ start: E, end: i.length, atomIndex: P }), A.length > 0 && (s = /\s$/.test(A));
1451
1451
  });
1452
- const o = mn(i, e);
1452
+ const o = yn(i, e);
1453
1453
  let l = "", c = "";
1454
1454
  const u = [];
1455
1455
  let g = -2, d = "", h = 0;
@@ -1472,19 +1472,19 @@ function ts(n, e) {
1472
1472
  for (; I < E.end; ) {
1473
1473
  const R = h < o.length ? o[h] : void 0;
1474
1474
  if (R && R.start <= I && R.end > I) {
1475
- const U = R.start === I, F = R.end > E.end;
1476
- if (U) {
1475
+ const B = R.start === I, ee = R.end > E.end;
1476
+ if (B) {
1477
1477
  c += R.replacement;
1478
- for (let _ = 0; _ < R.replacement.length; _++) u.push(R.start);
1479
- E.atomIndex === -1 || F ? (f(), l += z(R.replacement)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += z(R.replacement));
1478
+ for (let j = 0; j < R.replacement.length; j++) u.push(R.start);
1479
+ E.atomIndex === -1 || ee ? (f(), l += T(R.replacement)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += T(R.replacement));
1480
1480
  }
1481
1481
  I = Math.min(R.end, E.end), R.end <= E.end && h++;
1482
1482
  continue;
1483
1483
  }
1484
- const xe = R ? Math.min(R.start, E.end) : E.end, D = i.slice(I, xe);
1485
- c += D;
1486
- for (let U = 0; U < D.length; U++) u.push(I + U);
1487
- E.atomIndex === -1 ? (f(), l += z(D)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += z(D)), I = xe;
1484
+ const X = R ? Math.min(R.start, E.end) : E.end, Y = i.slice(I, X);
1485
+ c += Y;
1486
+ for (let B = 0; B < Y.length; B++) u.push(I + B);
1487
+ E.atomIndex === -1 ? (f(), l += T(Y)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += T(Y)), I = X;
1488
1488
  }
1489
1489
  }
1490
1490
  }
@@ -1500,24 +1500,24 @@ function ts(n, e) {
1500
1500
  const w = i.slice(p, m), y = u.slice(S, v).map((b) => Math.min(Math.max(b - p, 0), Math.max(w.length - 1, 0)));
1501
1501
  return { ssml: l, plain: w, map: y };
1502
1502
  }
1503
- const yn = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1504
- function Sn(n) {
1505
- return new RegExp(yn).test(n);
1503
+ const bn = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
1504
+ function wn(n) {
1505
+ return new RegExp(bn).test(n);
1506
1506
  }
1507
- function Tt(n) {
1507
+ function zt(n) {
1508
1508
  return n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/ {2,}/g, " ");
1509
1509
  }
1510
- const ns = new RegExp(
1511
- `\\s+|[${He}]+|[${ie}]+|[^\\s${He}${ie}]+`,
1510
+ const os = new RegExp(
1511
+ `\\s+|[${He}]+|[${se}]+|[^\\s${He}${se}]+`,
1512
1512
  "gu"
1513
1513
  );
1514
1514
  function Ue(n) {
1515
1515
  const e = [];
1516
- for (const [t] of n.matchAll(ns))
1517
- /^\s/.test(t) ? e.push({ kind: "space" }) : $i(t) ? e.push({ kind: "open", text: t }) : ue(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1516
+ for (const [t] of n.matchAll(os))
1517
+ /^\s/.test(t) ? e.push({ kind: "space" }) : Wi(t) ? e.push({ kind: "open", text: t }) : he(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
1518
1518
  return e;
1519
1519
  }
1520
- function is(n) {
1520
+ function ls(n) {
1521
1521
  let e = "", t = !1;
1522
1522
  for (const i of n) {
1523
1523
  if (i.kind === "space") {
@@ -1528,12 +1528,12 @@ function is(n) {
1528
1528
  }
1529
1529
  return e;
1530
1530
  }
1531
- function ss(n) {
1531
+ function cs(n) {
1532
1532
  let e = n.length;
1533
1533
  for (; e > 0 && (n[e - 1].kind === "space" || n[e - 1].kind === "open"); ) e--;
1534
1534
  return n.slice(e).some((t) => t.kind === "open") ? n.splice(e) : [];
1535
1535
  }
1536
- function as(n) {
1536
+ function us(n) {
1537
1537
  let e = 0;
1538
1538
  for (; e < n.length && (n[e].kind === "space" || n[e].kind === "close"); ) e++;
1539
1539
  return n.slice(0, e).some((t) => t.kind === "close") ? n.splice(0, e) : [];
@@ -1541,42 +1541,42 @@ function as(n) {
1541
1541
  function at(n, e) {
1542
1542
  const t = [];
1543
1543
  let i = 0;
1544
- for (const r of n.matchAll(yn))
1544
+ for (const r of n.matchAll(bn))
1545
1545
  t.push({
1546
- tokens: Ue(Tt(n.slice(i, r.index))),
1546
+ tokens: Ue(zt(n.slice(i, r.index))),
1547
1547
  language: e,
1548
1548
  tagged: !1
1549
- }), t.push({ tokens: Ue(M(r[2])), language: r[1], tagged: !0 }), i = r.index + r[0].length;
1549
+ }), t.push({ tokens: Ue(N(r[2])), language: r[1], tagged: !0 }), i = r.index + r[0].length;
1550
1550
  t.push({
1551
- tokens: Ue(Tt(n.slice(i))),
1551
+ tokens: Ue(zt(n.slice(i))),
1552
1552
  language: e,
1553
1553
  tagged: !1
1554
1554
  });
1555
1555
  for (let r = 0; r < t.length - 1; r++)
1556
- !t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...ss(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...as(t[r + 1].tokens));
1556
+ !t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...cs(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...us(t[r + 1].tokens));
1557
1557
  const s = [];
1558
1558
  let a = 0;
1559
1559
  for (const r of t) {
1560
- const o = is(r.tokens);
1560
+ const o = ls(r.tokens);
1561
1561
  o && (s.push({ plain: o, language: r.language, start: a, end: a + o.length }), a += o.length);
1562
1562
  }
1563
1563
  return s;
1564
1564
  }
1565
- const bn = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
1566
- function rs(n) {
1567
- return new RegExp(bn).test(n);
1565
+ const kn = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
1566
+ function hs(n) {
1567
+ return new RegExp(kn).test(n);
1568
1568
  }
1569
- function os(n) {
1569
+ function ds(n) {
1570
1570
  const e = [];
1571
1571
  let t = 0;
1572
- for (const s of n.matchAll(bn)) {
1572
+ for (const s of n.matchAll(kn)) {
1573
1573
  const a = n.slice(t, s.index).trim();
1574
1574
  a && e.push({ ssml: a }), e.push({ placeholderId: s[1] }), t = s.index + s[0].length;
1575
1575
  }
1576
1576
  const i = n.slice(t).trim();
1577
1577
  return i && e.push({ ssml: i }), e;
1578
1578
  }
1579
- class zt {
1579
+ class Nt {
1580
1580
  speechSynthesis;
1581
1581
  speechSynthesisUtterance;
1582
1582
  currentVoice = null;
@@ -1585,7 +1585,7 @@ class zt {
1585
1585
  currentUtterances = [];
1586
1586
  currentUtteranceIndex = 0;
1587
1587
  playbackState = "idle";
1588
- events = new Pe();
1588
+ events = new Ae();
1589
1589
  voiceManager = null;
1590
1590
  defaultVoice = null;
1591
1591
  // Keyed by `${language}:${needsBoundary}` — the boundary requirement rides in the key
@@ -1608,6 +1608,8 @@ class zt {
1608
1608
  maxLengthExceeded = "warn";
1609
1609
  utterancesBeingCancelled = !1;
1610
1610
  // Flag to track if utterances are being cancelled
1611
+ hasCancelledInTask = !1;
1612
+ // Safari: cancel() stopped speech in the current task
1611
1613
  lacksNativePauseEvents = !1;
1612
1614
  // Google and Chrome OS voices never fire onpause/onresume
1613
1615
  // Playback parameters
@@ -1617,16 +1619,17 @@ class zt {
1617
1619
  features;
1618
1620
  patches;
1619
1621
  constructor() {
1620
- if (this.features = Di(), this.patches = dn(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1622
+ if (this.features = Gi(), this.patches = fn(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
1621
1623
  throw new Error("Web Speech API is not available in this environment");
1622
1624
  this.speechSynthesis = this.features.speechSynthesis, this.speechSynthesisUtterance = this.features.speechSynthesisUtterance;
1623
1625
  }
1624
1626
  // From Easy Speech,
1625
1627
  // Check infinity pattern for long texts (except on problematic platforms)
1626
1628
  // Skip resume infinity for Microsoft Natural voices as they have different behavior
1629
+ // Only for voices without pause events (Chrome's Google voices, which cut off long texts): others would report each pause/resume
1627
1630
  shouldUseResumeInfinity() {
1628
1631
  const e = this.speakingVoice ?? this.currentVoice, t = !!(e?.name && typeof e.name == "string" && e.name.toLocaleLowerCase().includes("(natural)"));
1629
- return this.patches.isAndroid !== !0 && !this.patches.isFirefox && !this.patches.isSafari && !t;
1632
+ return this.patches.isAndroid !== !0 && !this.patches.isFirefox && !this.patches.isSafari && !t && this.lacksNativePauseEvents;
1630
1633
  }
1631
1634
  // Creates a new SpeechSynthesisUtterance using detected constructor
1632
1635
  createUtterance(e) {
@@ -1638,7 +1641,7 @@ class zt {
1638
1641
  return !1;
1639
1642
  this.maxLengthExceeded = a;
1640
1643
  try {
1641
- this.voiceManager = await k.initialize({
1644
+ this.voiceManager = await C.initialize({
1642
1645
  languages: t,
1643
1646
  maxTimeout: i,
1644
1647
  interval: s
@@ -1692,7 +1695,7 @@ class zt {
1692
1695
  const i = this.getCurrentVoiceForUtterance(this.currentVoice);
1693
1696
  if (!e.language)
1694
1697
  return i;
1695
- const s = x(e.language);
1698
+ const s = V(e.language);
1696
1699
  if (Ge(i, s))
1697
1700
  return i;
1698
1701
  const a = i?.controls?.boundary !== !1, r = this.languageCacheKey(s, a);
@@ -1707,7 +1710,7 @@ class zt {
1707
1710
  return t;
1708
1711
  const i = this.unloadedOwnVoiceLanguage(e);
1709
1712
  if (i) {
1710
- await k.initialize({ languages: [i] }), this.loadedOwnVoiceLanguages.add(i);
1713
+ await C.initialize({ languages: [i] }), this.loadedOwnVoiceLanguages.add(i);
1711
1714
  const s = this.voiceForUtteranceSync(e);
1712
1715
  if (s !== void 0) return s;
1713
1716
  }
@@ -1719,11 +1722,11 @@ class zt {
1719
1722
  if (!this.voiceManager)
1720
1723
  return;
1721
1724
  const t = this.getCurrentVoiceForUtterance(this.currentVoice), i = t?.controls?.boundary !== !1, s = new Set(
1722
- e.filter((l) => !this.ownVoice(l)).map((l) => l.language).filter((l) => !!l).map((l) => x(l)).filter((l) => !Ge(t, l)).filter((l) => !this.languageVoiceCache.has(this.languageCacheKey(l, i)))
1725
+ e.filter((l) => !this.ownVoice(l)).map((l) => l.language).filter((l) => !!l).map((l) => V(l)).filter((l) => !Ge(t, l)).filter((l) => !this.languageVoiceCache.has(this.languageCacheKey(l, i)))
1723
1726
  ), a = [...s].filter((l) => this.warmingLanguages.has(this.languageCacheKey(l, i))), o = [...s].filter((l) => !this.warmingLanguages.has(this.languageCacheKey(l, i))).map((l) => {
1724
1727
  const c = this.languageCacheKey(l, i), u = (async () => {
1725
- await k.initialize({ languages: [l] });
1726
- const g = this.voices.filter((p) => gn(p, l)), d = it(g, i), f = (await this.voiceManager.sortVoicesByQuality(d))[0] ?? null;
1728
+ await C.initialize({ languages: [l] });
1729
+ const g = this.voices.filter((p) => pn(p, l)), d = it(g, i), f = (await this.voiceManager.sortVoicesByQuality(d))[0] ?? null;
1727
1730
  this.languageVoiceCache.set(c, f), f || this.emitEvent({ type: "languagefallback", detail: { language: l, reason: "no-matching-voice" } });
1728
1731
  })();
1729
1732
  return this.warmingLanguages.set(c, u.finally(() => this.warmingLanguages.delete(c))), this.warmingLanguages.get(c);
@@ -1743,12 +1746,12 @@ class zt {
1743
1746
  toPlainText(e) {
1744
1747
  return e.map((t) => ({
1745
1748
  ...t,
1746
- plain: t.plain ?? (t.ssml ? M(Gi(t.ssml)) : "")
1749
+ plain: t.plain ?? (t.ssml ? N(Ji(t.ssml)) : "")
1747
1750
  }));
1748
1751
  }
1749
1752
  // Queue Management
1750
1753
  loadUtterances(e, t) {
1751
- this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = me(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1754
+ this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = ye(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
1752
1755
  }
1753
1756
  // Voice Configuration
1754
1757
  async setVoice(e) {
@@ -1784,71 +1787,97 @@ class zt {
1784
1787
  console.warn("No utterances loaded");
1785
1788
  return;
1786
1789
  }
1787
- this.cancelCurrentSpeech();
1790
+ this.patches.isSafari && this.speakGeneration++, this.cancelCurrentSpeech();
1788
1791
  const t = ++this.speakGeneration;
1789
- this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length && (this.currentUtteranceIndex = 0), this.speakCurrentUtterance(t);
1792
+ if (this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length && (this.currentUtteranceIndex = 0), this.patches.isSafari && this.hasCancelledInTask) {
1793
+ this.speakNextTask(t, 1);
1794
+ return;
1795
+ }
1796
+ this.speakCurrentUtterance(t);
1790
1797
  }
1791
1798
  cancelCurrentSpeech() {
1792
1799
  this.patches.isFirefox && this.speechSynthesis.speaking && (this.utterancesBeingCancelled = !0, setTimeout(() => {
1793
1800
  this.utterancesBeingCancelled = !1;
1794
- }, 100)), this.speechSynthesis.cancel();
1801
+ }, 100)), this.patches.isSafari && this.speechSynthesis.speaking && (this.hasCancelledInTask = !0, setTimeout(() => {
1802
+ this.hasCancelledInTask = !1;
1803
+ }, 0)), this.speechSynthesis.cancel();
1795
1804
  }
1796
- async speakCurrentUtterance(e) {
1805
+ // Safari: `unstartedRetries` is how many more times to speak it if Safari ends it without starting it, as it can right after cancel()
1806
+ speakNextTask(e, t) {
1807
+ setTimeout(() => {
1808
+ e === this.speakGeneration && this.speakCurrentUtterance(e, t);
1809
+ }, 0);
1810
+ }
1811
+ async speakCurrentUtterance(e, t) {
1797
1812
  if (this.currentUtteranceIndex >= this.currentUtterances.length) {
1798
1813
  this.setState("idle"), this.emitEvent({ type: "end" });
1799
1814
  return;
1800
1815
  }
1801
- const t = this.currentUtterances[this.currentUtteranceIndex], i = t.plain ?? "";
1802
- this.validateText(i);
1803
- const s = this.createUtterance(fn(i)), a = await this.voiceForUtterance(t);
1804
- if (e === this.speakGeneration) {
1805
- if (this.lacksNativePauseEvents = !1, this.speakingVoice = a, a && this.voiceManager) {
1806
- const r = this.voiceManager.convertToSpeechSynthesisVoice(a);
1807
- r && (s.voice = r, s.lang = r.lang, this.lacksNativePauseEvents = r.name.startsWith("Google") || r.name.startsWith("Chrome OS"));
1816
+ const i = this.currentUtterances[this.currentUtteranceIndex], s = i.plain ?? "";
1817
+ this.validateText(s);
1818
+ const a = this.createUtterance(mn(s)), r = await this.voiceForUtterance(i);
1819
+ if (e !== this.speakGeneration)
1820
+ return;
1821
+ if (this.lacksNativePauseEvents = !1, this.speakingVoice = r, r && this.voiceManager) {
1822
+ const l = this.voiceManager.convertToSpeechSynthesisVoice(r);
1823
+ l && (a.voice = l, a.lang = l.lang, this.lacksNativePauseEvents = l.name.startsWith("Google") || l.name.startsWith("Chrome OS"));
1824
+ }
1825
+ i.language && (a.lang = i.language), a.rate = this.rate, a.pitch = this.pitch, a.volume = this.volume;
1826
+ let o = !1;
1827
+ a.onstart = () => {
1828
+ if (o = !0, e !== this.speakGeneration) return;
1829
+ this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: r } }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(a);
1830
+ }, a.onend = () => {
1831
+ if (this.utterancesBeingCancelled) {
1832
+ this.utterancesBeingCancelled = !1;
1833
+ return;
1808
1834
  }
1809
- t.language && (s.lang = t.language), s.rate = this.rate, s.pitch = this.pitch, s.volume = this.volume, s.onstart = () => {
1810
- if (e !== this.speakGeneration) return;
1811
- this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: a } }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(s);
1812
- }, s.onend = () => {
1813
- if (this.utterancesBeingCancelled) {
1814
- this.utterancesBeingCancelled = !1;
1815
- return;
1816
- }
1817
- e === this.speakGeneration && this.playbackState !== "idle" && (this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" }));
1818
- }, s.onerror = (r) => {
1819
- if (e !== this.speakGeneration || r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1820
- return;
1821
- this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.setState("idle"), ["synthesis-unavailable", "audio-hardware", "voice-unavailable"].includes(r.error) && (console.log("[ENGINE] fatal error detected, resetting index to 0"), this.currentUtteranceIndex = 0), r.error === "interrupted" || r.error === "canceled" ? this.emitEvent({ type: "stop" }) : this.emitEvent({
1822
- type: "error",
1823
- detail: {
1824
- error: r.error,
1825
- // Preserve original error type
1826
- message: `Speech synthesis error: ${r.error}`
1835
+ if (e === this.speakGeneration && this.playbackState !== "idle") {
1836
+ if (t !== void 0 && !o) {
1837
+ if (this.playbackState === "paused") {
1838
+ this.pausedAtUtteranceIndex = null;
1839
+ return;
1827
1840
  }
1828
- });
1829
- }, s.onpause = () => {
1830
- e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
1831
- }, s.onresume = () => {
1832
- e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
1833
- }, s.onboundary = (r) => {
1834
- e === this.speakGeneration && this.emitEvent({
1835
- type: "boundary",
1836
- detail: {
1837
- charIndex: r.charIndex,
1838
- charLength: r.charLength,
1839
- elapsedTime: r.elapsedTime,
1840
- name: r.name
1841
+ if (this.playbackState === "playing" && t > 0) {
1842
+ this.speakNextTask(e, t - 1);
1843
+ return;
1841
1844
  }
1842
- });
1843
- }, s.onmark = (r) => {
1844
- e === this.speakGeneration && this.emitEvent({
1845
- type: "mark",
1846
- detail: {
1847
- name: r.name
1848
- }
1849
- });
1850
- }, this.speechSynthesis.speak(s);
1851
- }
1845
+ }
1846
+ this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" });
1847
+ }
1848
+ }, a.onerror = (l) => {
1849
+ if (e !== this.speakGeneration || l.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
1850
+ return;
1851
+ this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.setState("idle"), ["synthesis-unavailable", "audio-hardware", "voice-unavailable"].includes(l.error) && (console.log("[ENGINE] fatal error detected, resetting index to 0"), this.currentUtteranceIndex = 0), l.error === "interrupted" || l.error === "canceled" ? this.emitEvent({ type: "stop" }) : this.emitEvent({
1852
+ type: "error",
1853
+ detail: {
1854
+ error: l.error,
1855
+ // Preserve original error type
1856
+ message: `Speech synthesis error: ${l.error}`
1857
+ }
1858
+ });
1859
+ }, a.onpause = () => {
1860
+ e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
1861
+ }, a.onresume = () => {
1862
+ e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
1863
+ }, a.onboundary = (l) => {
1864
+ e === this.speakGeneration && this.emitEvent({
1865
+ type: "boundary",
1866
+ detail: {
1867
+ charIndex: l.charIndex,
1868
+ charLength: l.charLength,
1869
+ elapsedTime: l.elapsedTime,
1870
+ name: l.name
1871
+ }
1872
+ });
1873
+ }, a.onmark = (l) => {
1874
+ e === this.speakGeneration && this.emitEvent({
1875
+ type: "mark",
1876
+ detail: {
1877
+ name: l.name
1878
+ }
1879
+ });
1880
+ }, this.speechSynthesis.speak(a);
1852
1881
  }
1853
1882
  startResumeInfinity(e) {
1854
1883
  this.shouldUseResumeInfinity() && (this.resumeInfinityTimer = window.setTimeout(() => {
@@ -1873,21 +1902,21 @@ class zt {
1873
1902
  }
1874
1903
  // Playback Parameters
1875
1904
  setRate(e) {
1876
- const t = H(e, 0.1, 10, this.rate);
1905
+ const t = q(e, 0.1, 10, this.rate);
1877
1906
  t !== this.rate && (this.rate = t, this.scheduleRestartIfSpeaking());
1878
1907
  }
1879
1908
  getRate() {
1880
1909
  return this.rate;
1881
1910
  }
1882
1911
  setPitch(e) {
1883
- const t = H(e, 0, 2, this.pitch);
1912
+ const t = q(e, 0, 2, this.pitch);
1884
1913
  t !== this.pitch && (this.pitch = t, this.scheduleRestartIfSpeaking());
1885
1914
  }
1886
1915
  getPitch() {
1887
1916
  return this.pitch;
1888
1917
  }
1889
1918
  setVolume(e) {
1890
- const t = H(e, 0, 1, this.volume);
1919
+ const t = q(e, 0, 1, this.volume);
1891
1920
  t !== this.volume && (this.volume = t, this.scheduleRestartIfSpeaking());
1892
1921
  }
1893
1922
  getVolume() {
@@ -1952,27 +1981,27 @@ class zt {
1952
1981
  this.stop(), this.stopResumeInfinity(), this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.speakingVoice = null, this.voiceManager = null, this.defaultVoice = null, this.languageVoiceCache.clear(), this.warmingLanguages.clear(), this.initialized = !1;
1953
1982
  }
1954
1983
  }
1955
- class Wa {
1984
+ class er {
1956
1985
  id = "webspeech";
1957
1986
  name = "Web Speech API";
1958
1987
  voiceEngine = null;
1959
1988
  // No cache to bypass here — local API, no network cost to re-checking.
1960
1989
  async getVoices() {
1961
- return this.voiceEngine || (this.voiceEngine = new zt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1990
+ return this.voiceEngine || (this.voiceEngine = new Nt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
1962
1991
  }
1963
1992
  async createEngine(e) {
1964
- const t = new zt();
1993
+ const t = new Nt();
1965
1994
  return await t.initialize(), e && await t.setVoice(e), t;
1966
1995
  }
1967
1996
  async destroy() {
1968
1997
  this.voiceEngine && (await this.voiceEngine.destroy(), this.voiceEngine = null);
1969
1998
  }
1970
1999
  }
1971
- function wn(n, e) {
2000
+ function Cn(n, e) {
1972
2001
  const t = [];
1973
2002
  let i = -1, s = -1;
1974
2003
  const a = () => {
1975
- i !== -1 && (t.push({ text: ls(n, i, s), offset: n[i].offset }), i = -1, s = -1);
2004
+ i !== -1 && (t.push({ text: gs(n, i, s), offset: n[i].offset }), i = -1, s = -1);
1976
2005
  };
1977
2006
  for (let r = 0; r < n.length; r++) {
1978
2007
  const o = n[r];
@@ -1985,14 +2014,14 @@ function wn(n, e) {
1985
2014
  }
1986
2015
  return a(), t;
1987
2016
  }
1988
- function ls(n, e, t) {
2017
+ function gs(n, e, t) {
1989
2018
  const i = n[e], s = n[t];
1990
2019
  return i === s ? i.text : n.slice(e, t + 1).map((a) => a.text).join("");
1991
2020
  }
1992
- const kn = new RegExp(
1993
- `[^${ie}]*[${ie}]+\\s*|[^${ie}]+$`,
2021
+ const En = new RegExp(
2022
+ `[^${se}]*[${se}]+\\s*|[^${se}]+$`,
1994
2023
  "gu"
1995
- ), cs = /\S+\s*|\s+/g;
2024
+ ), fs = /\S+\s*|\s+/g;
1996
2025
  function rt(n, e, t) {
1997
2026
  const i = [];
1998
2027
  for (const s of n.matchAll(t))
@@ -2002,7 +2031,7 @@ function rt(n, e, t) {
2002
2031
  function ot(n, e) {
2003
2032
  if (n.text.length <= e || n.atomic)
2004
2033
  return [n];
2005
- const t = rt(n.text, n.offset, cs);
2034
+ const t = rt(n.text, n.offset, fs);
2006
2035
  if (t.length > 1)
2007
2036
  return t.flatMap((r) => ot(r, e));
2008
2037
  const i = [];
@@ -2011,23 +2040,23 @@ function ot(n, e) {
2011
2040
  a.length > 0 && a.length + r.length > e && (i.push({ text: a, offset: s, atomic: !1 }), s += a.length, a = ""), a += r;
2012
2041
  return a.length > 0 && i.push({ text: a, offset: s, atomic: !1 }), i;
2013
2042
  }
2014
- function us(n, e) {
2043
+ function ps(n, e) {
2015
2044
  if (n.length <= e)
2016
2045
  return [{ text: n, offset: 0 }];
2017
- const i = rt(n, 0, kn).flatMap((s) => ot(s, e));
2018
- return wn(i, e);
2046
+ const i = rt(n, 0, En).flatMap((s) => ot(s, e));
2047
+ return Cn(i, e);
2019
2048
  }
2020
- const hs = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
2021
- function ds(n, e) {
2049
+ const ms = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
2050
+ function vs(n, e) {
2022
2051
  if (n.length <= e)
2023
2052
  return [{ text: n, offset: 0 }];
2024
2053
  const t = [];
2025
- for (const s of n.matchAll(hs))
2026
- s[0][0] === "<" ? t.push({ text: s[0], offset: s.index, atomic: !0 }) : t.push(...rt(s[0], s.index, kn));
2054
+ for (const s of n.matchAll(ms))
2055
+ s[0][0] === "<" ? t.push({ text: s[0], offset: s.index, atomic: !0 }) : t.push(...rt(s[0], s.index, En));
2027
2056
  const i = t.flatMap((s) => ot(s, e));
2028
- return wn(i, e);
2057
+ return Cn(i, e);
2029
2058
  }
2030
- const gs = {
2059
+ const ys = {
2031
2060
  wav: "audio/wav",
2032
2061
  mp3: "audio/mpeg",
2033
2062
  opus: "audio/ogg",
@@ -2037,31 +2066,31 @@ const gs = {
2037
2066
  webm: "audio/webm",
2038
2067
  m4a: "audio/mp4"
2039
2068
  };
2040
- function fs(n) {
2041
- return gs[n] ?? `audio/${n}`;
2069
+ function Ss(n) {
2070
+ return ys[n] ?? `audio/${n}`;
2042
2071
  }
2043
- const ps = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], ms = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
2044
- function vs(n, e, t) {
2045
- const i = (o) => t(fs(o)) !== "", s = n.formats.filter(i);
2072
+ const bs = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], ws = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
2073
+ function ks(n, e, t) {
2074
+ const i = (o) => t(Ss(o)) !== "", s = n.formats.filter(i);
2046
2075
  if (e.preferredFormat && s.includes(e.preferredFormat))
2047
2076
  return e.preferredFormat;
2048
- const a = e.strategy === "bandwidth" ? ms : ps, r = [...a, ...s.filter((o) => !a.includes(o))];
2077
+ const a = e.strategy === "bandwidth" ? ws : bs, r = [...a, ...s.filter((o) => !a.includes(o))];
2049
2078
  for (const o of r)
2050
2079
  if (s.includes(o))
2051
2080
  return o;
2052
2081
  return n.default;
2053
2082
  }
2054
- const ys = /* @__PURE__ */ new Set(["wav", "flac"]), Ss = {
2083
+ const Cs = /* @__PURE__ */ new Set(["wav", "flac"]), Es = {
2055
2084
  mp3: 48e3,
2056
2085
  opus: 24e3,
2057
2086
  aac: 48e3,
2058
2087
  ogg: 48e3,
2059
2088
  webm: 32e3
2060
2089
  };
2061
- function bs(n, e, t) {
2062
- return ys.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Ss[n] : void 0;
2090
+ function Rs(n, e, t) {
2091
+ return Cs.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Es[n] : void 0;
2063
2092
  }
2064
- function Cn(n, e) {
2093
+ function Rn(n, e) {
2065
2094
  return {
2066
2095
  source: "server",
2067
2096
  label: n.name,
@@ -2076,7 +2105,7 @@ function Cn(n, e) {
2076
2105
  controls: e
2077
2106
  };
2078
2107
  }
2079
- class re extends Error {
2108
+ class oe extends Error {
2080
2109
  status;
2081
2110
  type;
2082
2111
  title;
@@ -2085,26 +2114,26 @@ class re extends Error {
2085
2114
  super(e), this.name = "SpeechServerError", this.status = t.status, this.type = t.type, this.title = t.title, this.instance = t.instance;
2086
2115
  }
2087
2116
  }
2088
- class En extends re {
2117
+ class In extends oe {
2089
2118
  constructor(e) {
2090
2119
  super(e, { status: 408, type: "https://readium.org/speech-server/error#stall", title: "Synthesis Stalled" }), this.name = "SpeechServerStallError";
2091
2120
  }
2092
2121
  }
2093
- class Rn extends Error {
2122
+ class Pn extends Error {
2094
2123
  constructor(e) {
2095
2124
  super(e), this.name = "SpeechServerAudioDecodeError";
2096
2125
  }
2097
2126
  }
2098
- class In extends Error {
2127
+ class An extends Error {
2099
2128
  constructor(e) {
2100
2129
  super(e), this.name = "SpeechServerNetworkError";
2101
2130
  }
2102
2131
  }
2103
- async function se(n) {
2132
+ async function ae(n) {
2104
2133
  if ((n.headers.get("content-type") ?? "").includes("application/problem+json"))
2105
2134
  try {
2106
2135
  const t = await n.json();
2107
- return new re(t.detail || t.title || `Request failed with status ${n.status}`, {
2136
+ return new oe(t.detail || t.title || `Request failed with status ${n.status}`, {
2108
2137
  status: t.status ?? n.status,
2109
2138
  type: t.type,
2110
2139
  title: t.title,
@@ -2112,25 +2141,25 @@ async function se(n) {
2112
2141
  });
2113
2142
  } catch {
2114
2143
  }
2115
- return new re(`Request failed with status ${n.status}`, { status: n.status });
2144
+ return new oe(`Request failed with status ${n.status}`, { status: n.status });
2116
2145
  }
2117
- const ws = 3, ks = 400;
2118
- function Cs(n) {
2146
+ const Is = 3, Ps = 400;
2147
+ function As(n) {
2119
2148
  const e = atob(n), t = new Uint8Array(e.length);
2120
2149
  for (let i = 0; i < e.length; i++)
2121
2150
  t[i] = e.charCodeAt(i);
2122
2151
  return t.buffer;
2123
2152
  }
2124
- function Es(n) {
2125
- return H(n, 0.25, 4, 1);
2153
+ function Ls(n) {
2154
+ return q(n, 0.25, 4, 1);
2126
2155
  }
2127
- function ge(n) {
2156
+ function pe(n) {
2128
2157
  return n?.plain ?? n?.ssml ?? void 0;
2129
2158
  }
2130
- function Nt(n) {
2131
- return n instanceof En ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof re ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Rn ? { message: n.message, recoverable: !1 } : n instanceof In ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2159
+ function Mt(n) {
2160
+ return n instanceof In ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof oe ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Pn ? { message: n.message, recoverable: !1 } : n instanceof An ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
2132
2161
  }
2133
- class Rs {
2162
+ class Os {
2134
2163
  endpoints;
2135
2164
  fetchImpl;
2136
2165
  currentVoice = null;
@@ -2145,7 +2174,7 @@ class Rs {
2145
2174
  currentUtterances = [];
2146
2175
  currentUtteranceIndex = 0;
2147
2176
  playbackState = "idle";
2148
- events = new Pe();
2177
+ events = new Ae();
2149
2178
  speakGeneration = 0;
2150
2179
  loadGeneration = 0;
2151
2180
  // Rolling buffer of upcoming utterances' audio, fetched one at a time via prefetchChainTail.
@@ -2174,7 +2203,7 @@ class Rs {
2174
2203
  pitch = 1;
2175
2204
  volume = 1;
2176
2205
  constructor(e) {
2177
- this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? ws, this.readyBufferChars = e.readyBufferChars ?? ks, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2206
+ this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Is, this.readyBufferChars = e.readyBufferChars ?? Ps, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
2178
2207
  }
2179
2208
  // Lets a provider that already fetched /voices seed this engine without a second request.
2180
2209
  setAvailableVoices(e) {
@@ -2184,7 +2213,7 @@ class Rs {
2184
2213
  async initialize() {
2185
2214
  this.initializing = (async () => {
2186
2215
  const e = await this.getAvailableVoices(), t = typeof navigator < "u" && navigator.languages?.length ? [...navigator.languages] : ["en"];
2187
- return this.defaultVoice = (await un(t, e))[0] ?? null, !0;
2216
+ return this.defaultVoice = (await dn(t, e))[0] ?? null, !0;
2188
2217
  })();
2189
2218
  try {
2190
2219
  return await this.initializing;
@@ -2198,17 +2227,17 @@ class Rs {
2198
2227
  try {
2199
2228
  return await this.fetchImpl(e, t);
2200
2229
  } catch (i) {
2201
- throw i instanceof TypeError ? new In(i.message) : i;
2230
+ throw i instanceof TypeError ? new An(i.message) : i;
2202
2231
  }
2203
2232
  }
2204
2233
  loadUtterances(e, t) {
2205
- this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = me(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2234
+ this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = ye(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
2206
2235
  }
2207
2236
  // Buffers enough utterances ahead of currentUtteranceIndex to cover readyBufferChars before
2208
2237
  // declaring "ready", so playback doesn't catch up to an empty prefetch cache right away —
2209
2238
  // starting from wherever playback will actually resume, not always utterance 0.
2210
2239
  async bufferUntilReady(e) {
2211
- const t = me(this.currentUtteranceIndex, this.currentUtterances.length), i = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), s = [];
2240
+ const t = ye(this.currentUtteranceIndex, this.currentUtterances.length), i = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), s = [];
2212
2241
  for (let a = t; a <= i; a++) {
2213
2242
  this.queuePrefetch(a);
2214
2243
  const r = this.prefetchCache.get(a);
@@ -2223,10 +2252,10 @@ class Rs {
2223
2252
  indexCoveringChars(e, t) {
2224
2253
  if (this.currentUtterances.length === 0)
2225
2254
  return -1;
2226
- const i = me(t, this.currentUtterances.length);
2255
+ const i = ye(t, this.currentUtterances.length);
2227
2256
  let s = 0;
2228
2257
  for (let a = i; a < this.currentUtterances.length; a++)
2229
- if (s += (ge(this.currentUtterances[a]) ?? "").length, s >= e)
2258
+ if (s += (pe(this.currentUtterances[a]) ?? "").length, s >= e)
2230
2259
  return a;
2231
2260
  return this.currentUtterances.length - 1;
2232
2261
  }
@@ -2240,12 +2269,12 @@ class Rs {
2240
2269
  const i = this.currentVoice ?? this.defaultVoice;
2241
2270
  if (!e?.language || this.voices.length === 0 || Ge(i, e.language))
2242
2271
  return i;
2243
- const s = x(e.language), a = i?.controls?.boundary !== !1, r = `${s}:${a}`;
2272
+ const s = V(e.language), a = i?.controls?.boundary !== !1, r = `${s}:${a}`;
2244
2273
  let o = this.languageVoiceCache.get(r);
2245
2274
  return o || (o = this.pickLanguageVoice(s, a), this.languageVoiceCache.set(r, o)), await o ?? i;
2246
2275
  }
2247
2276
  async pickLanguageVoice(e, t) {
2248
- const i = this.voices.filter((a) => gn(a, e)), s = i.length > 0 ? await hn(e, it(i, t)) : null;
2277
+ const i = this.voices.filter((a) => pn(a, e)), s = i.length > 0 ? await gn(e, it(i, t)) : null;
2249
2278
  return s || this.emitEvent({ type: "languagefallback", detail: { language: e, reason: "no-matching-voice" } }), s;
2250
2279
  }
2251
2280
  setVoice(e) {
@@ -2282,9 +2311,9 @@ class Rs {
2282
2311
  async fetchVoices() {
2283
2312
  const [e, t] = await Promise.all([this.fetchNetwork(this.endpoints.voices), this.getServiceInfo()]);
2284
2313
  if (!e.ok)
2285
- throw await se(e);
2314
+ throw await ae(e);
2286
2315
  const i = await e.json(), s = new Map(t.providers.map((a) => [a.id, a.controls]));
2287
- return this.voices = i.map((a) => Cn(a, s.get(a.provider))), this.voices;
2316
+ return this.voices = i.map((a) => Rn(a, s.get(a.provider))), this.voices;
2288
2317
  }
2289
2318
  // Cached after the first successful fetch; a failed fetch isn't cached, so the next
2290
2319
  // synthesize() call retries rather than being stuck on a transient network error.
@@ -2296,7 +2325,7 @@ class Rs {
2296
2325
  async fetchServiceInfo() {
2297
2326
  const e = await this.fetchNetwork(this.endpoints.service);
2298
2327
  if (!e.ok)
2299
- throw await se(e);
2328
+ throw await ae(e);
2300
2329
  return e.json();
2301
2330
  }
2302
2331
  speak(e) {
@@ -2328,7 +2357,7 @@ class Rs {
2328
2357
  return;
2329
2358
  this.isSpeakingInternal = !1, this.setState("idle"), this.emitEvent({
2330
2359
  type: "error",
2331
- detail: Nt(i)
2360
+ detail: Mt(i)
2332
2361
  });
2333
2362
  }
2334
2363
  }
@@ -2375,7 +2404,7 @@ class Rs {
2375
2404
  this.liveControllers.forEach((e) => e.abort()), this.liveControllers.clear();
2376
2405
  }
2377
2406
  async synthesizeStream(e, t) {
2378
- const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = ge(i) ?? "", o = s ? pn(r).map : void 0, l = ge(this.currentUtterances[e - 1]), c = ge(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = vs(u.output, this.formatOptions, this.canPlayType), d = navigator.connection, h = bs(g, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
2407
+ const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = pe(i) ?? "", o = s ? vn(r).map : void 0, l = pe(this.currentUtterances[e - 1]), c = pe(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = ks(u.output, this.formatOptions, this.canPlayType), d = navigator.connection, h = Rs(g, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
2379
2408
  if (r.length <= u.limits.maxTextLength) {
2380
2409
  const v = new AbortController();
2381
2410
  return (t ? this.activeControllers : this.liveControllers).add(v), [{
@@ -2384,7 +2413,7 @@ class Rs {
2384
2413
  }];
2385
2414
  }
2386
2415
  if (this.overLengthText === "error")
2387
- throw new re(
2416
+ throw new oe(
2388
2417
  `Text exceeds this server's maximum length of ${u.limits.maxTextLength} characters`,
2389
2418
  {
2390
2419
  status: 413,
@@ -2392,7 +2421,7 @@ class Rs {
2392
2421
  title: "Payload Too Large"
2393
2422
  }
2394
2423
  );
2395
- const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ? ds(r, f) : us(r, f), m = [];
2424
+ const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ? vs(r, f) : ps(r, f), m = [];
2396
2425
  let S = Promise.resolve();
2397
2426
  for (let v = 0; v < p.length; v++) {
2398
2427
  const w = v === 0 ? l : p[v - 1].text, y = v === p.length - 1 ? c : p[v + 1].text, b = p[v], P = new AbortController();
@@ -2412,7 +2441,7 @@ class Rs {
2412
2441
  headers: { "Content-Type": "application/json" },
2413
2442
  body: JSON.stringify({
2414
2443
  id: t.id,
2415
- text: a ? i : fn(i),
2444
+ text: a ? i : mn(i),
2416
2445
  ssml: a,
2417
2446
  language: o,
2418
2447
  voice: h?.identifier ?? h?.name,
@@ -2424,13 +2453,13 @@ class Rs {
2424
2453
  signal: d.signal
2425
2454
  });
2426
2455
  if (!f.ok)
2427
- throw await se(f);
2428
- const p = await f.json(), m = Cs(p.audio);
2456
+ throw await ae(f);
2457
+ const p = await f.json(), m = As(p.audio);
2429
2458
  let S;
2430
2459
  try {
2431
2460
  S = await this.ensureAudioContext().decodeAudioData(m);
2432
2461
  } catch {
2433
- throw new Rn("Audio playback failed");
2462
+ throw new Pn("Audio playback failed");
2434
2463
  }
2435
2464
  return { audioBuffer: S, format: p.format, boundaries: p.boundaries, textOffset: s, ssmlMap: r };
2436
2465
  } finally {
@@ -2451,7 +2480,7 @@ class Rs {
2451
2480
  const s = i + this.timeoutMs;
2452
2481
  return new Promise((a, r) => {
2453
2482
  const o = setTimeout(() => {
2454
- t.abort(), r(new En(`No audio chunk arrived within ${s.toFixed(0)}ms of the playback buffer running dry`));
2483
+ t.abort(), r(new In(`No audio chunk arrived within ${s.toFixed(0)}ms of the playback buffer running dry`));
2455
2484
  }, s);
2456
2485
  e.then(
2457
2486
  (l) => {
@@ -2468,7 +2497,7 @@ class Rs {
2468
2497
  const s = await this.awaitWithStallDeadline(e[0].promise, e[0].controller, 0);
2469
2498
  if (t !== this.speakGeneration)
2470
2499
  return;
2471
- const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 : Es(this.rate);
2500
+ const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 : Ls(this.rate);
2472
2501
  this.scheduledChunks = [], this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: i } });
2473
2502
  let c = a.currentTime, u = null;
2474
2503
  const g = (d) => {
@@ -2482,7 +2511,7 @@ class Rs {
2482
2511
  const f = Math.max(0, (c - a.currentTime) * 1e3);
2483
2512
  h = await this.awaitWithStallDeadline(e[d].promise, e[d].controller, f);
2484
2513
  } catch (f) {
2485
- t === this.speakGeneration && this.emitEvent({ type: "error", detail: Nt(f) });
2514
+ t === this.speakGeneration && this.emitEvent({ type: "error", detail: Mt(f) });
2486
2515
  return;
2487
2516
  }
2488
2517
  if (t !== this.speakGeneration)
@@ -2513,7 +2542,7 @@ class Rs {
2513
2542
  let r = a, o = s.charLength;
2514
2543
  if (t.chunk.ssmlMap) {
2515
2544
  const l = t.chunk.ssmlMap;
2516
- r = Ot(l, a), o = Math.max(0, Ot(l, a + s.charLength) - r);
2545
+ r = Vt(l, a), o = Math.max(0, Vt(l, a + s.charLength) - r);
2517
2546
  }
2518
2547
  this.emitEvent({
2519
2548
  type: "boundary",
@@ -2557,21 +2586,21 @@ class Rs {
2557
2586
  this.speakGeneration++, this.loadGeneration++, this.stopAudio(), this.abortLiveControllers(), this.clearPrefetchCache(), this.isSpeakingInternal = !1, this.restartOnResume = !1, this.currentUtteranceIndex = 0, this.setState("idle"), this.emitEvent({ type: "stop" });
2558
2587
  }
2559
2588
  setRate(e) {
2560
- const t = H(e, 0.1, 10, this.rate);
2589
+ const t = q(e, 0.1, 10, this.rate);
2561
2590
  t !== this.rate && (this.rate = t, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2562
2591
  }
2563
2592
  getRate() {
2564
2593
  return this.rate;
2565
2594
  }
2566
2595
  setPitch(e) {
2567
- const t = H(e, 0, 2, this.pitch);
2596
+ const t = q(e, 0, 2, this.pitch);
2568
2597
  t !== this.pitch && (this.pitch = t, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
2569
2598
  }
2570
2599
  getPitch() {
2571
2600
  return this.pitch;
2572
2601
  }
2573
2602
  setVolume(e) {
2574
- const t = H(e, 0, 1, this.volume);
2603
+ const t = q(e, 0, 1, this.volume);
2575
2604
  t !== this.volume && (this.volume = t, this.masterGain && (this.masterGain.gain.value = this.volume));
2576
2605
  }
2577
2606
  getVolume() {
@@ -2633,7 +2662,7 @@ class Rs {
2633
2662
  this.stop(), await this.audioContext?.close(), this.audioContext = null, this.masterGain = null, this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.defaultVoice = null, this.voices = [], this.voicesRequest = null, this.languageVoiceCache.clear();
2634
2663
  }
2635
2664
  }
2636
- class Qa {
2665
+ class tr {
2637
2666
  id = "speech-server";
2638
2667
  name = "Readium Speech Server";
2639
2668
  options;
@@ -2650,24 +2679,24 @@ class Qa {
2650
2679
  this.fetchImpl(this.options.endpoints.service)
2651
2680
  ]);
2652
2681
  if (!t.ok)
2653
- throw await se(t);
2682
+ throw await ae(t);
2654
2683
  if (!i.ok)
2655
- throw await se(i);
2684
+ throw await ae(i);
2656
2685
  const s = await t.json(), a = await i.json(), r = new Map(a.providers.map((o) => [o.id, o.controls]));
2657
- return this.voices = s.map((o) => Cn(o, r.get(o.provider))), this.voices;
2686
+ return this.voices = s.map((o) => Rn(o, r.get(o.provider))), this.voices;
2658
2687
  }
2659
2688
  async createEngine(e) {
2660
- const t = new Rs(this.options);
2689
+ const t = new Os(this.options);
2661
2690
  return this.voices.length > 0 && t.setAvailableVoices(this.voices), e && t.setVoice(e), t;
2662
2691
  }
2663
2692
  async destroy() {
2664
2693
  this.voices = [];
2665
2694
  }
2666
2695
  }
2667
- function Is(n) {
2696
+ function Vs(n) {
2668
2697
  return n.detail?.recoverable === !0;
2669
2698
  }
2670
- const Ps = 3e4, As = [
2699
+ const xs = 3e4, Us = [
2671
2700
  "start",
2672
2701
  "pause",
2673
2702
  "resume",
@@ -2682,7 +2711,7 @@ const Ps = 3e4, As = [
2682
2711
  "voiceschanged",
2683
2712
  "languagefallback"
2684
2713
  ];
2685
- class Ls {
2714
+ class Ts {
2686
2715
  activeEngine;
2687
2716
  primaryProvider;
2688
2717
  fallbackProvider;
@@ -2714,10 +2743,10 @@ class Ls {
2714
2743
  teardownEpoch = 0;
2715
2744
  // Bumped by every loadUtterances() call, so startEngineWhenReady() can tell its queue is stale.
2716
2745
  loadToken = 0;
2717
- events = new Pe();
2746
+ events = new Ae();
2718
2747
  unbindActiveEngine = null;
2719
2748
  constructor(e) {
2720
- this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? Ps, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2749
+ this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? xs, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
2721
2750
  }
2722
2751
  async initialize() {
2723
2752
  return this.activeEngine.initialize?.();
@@ -2811,13 +2840,13 @@ class Ls {
2811
2840
  this.events.emit(e.type, e);
2812
2841
  }
2813
2842
  bindActiveEngine() {
2814
- const e = this.activeEngine, t = As.map((i) => e.on(i, (s) => {
2843
+ const e = this.activeEngine, t = Us.map((i) => e.on(i, (s) => {
2815
2844
  this.emitEvent(s), this.maybeRecoverNow();
2816
2845
  }));
2817
2846
  t.push(e.on("error", (i) => this.handleError(i))), this.unbindActiveEngine = () => t.forEach((i) => i());
2818
2847
  }
2819
2848
  handleError(e) {
2820
- if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Is(e)) {
2849
+ if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Vs(e)) {
2821
2850
  this.emitEvent(e);
2822
2851
  return;
2823
2852
  }
@@ -2909,14 +2938,14 @@ class Ls {
2909
2938
  async pickBestFallbackVoice(e, t, i) {
2910
2939
  const s = await this.fallbackProvider.getVoices(), r = typeof navigator < "u" && navigator.onLine === !0 ? s : s.filter((f) => f.offlineAvailability === !0);
2911
2940
  if (r.length === 0) return null;
2912
- const [o] = Re([e]), { voicesByLang: l } = Ie(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], d = g.length > 0 ? g : u, h = it(d, i);
2913
- return hn(e, h);
2941
+ const [o] = Ie([e]), { voicesByLang: l } = Pe(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], d = g.length > 0 ? g : u, h = it(d, i);
2942
+ return gn(e, h);
2914
2943
  }
2915
2944
  async destroy() {
2916
2945
  this.teardownEpoch++, this.healthCheckTimer !== null && (clearTimeout(this.healthCheckTimer), this.healthCheckTimer = null), this.unbindActiveEngine?.(), this.events.clear(), await this.activeEngine.destroy();
2917
2946
  }
2918
2947
  }
2919
- class Ja {
2948
+ class nr {
2920
2949
  id = "fallback";
2921
2950
  name = "Fallback";
2922
2951
  primary;
@@ -2944,7 +2973,7 @@ class Ja {
2944
2973
  throw i;
2945
2974
  return this.fallback.createEngine(e);
2946
2975
  }
2947
- return new Ls({
2976
+ return new Ts({
2948
2977
  primaryEngine: t,
2949
2978
  primaryProvider: this.primary,
2950
2979
  fallbackProvider: this.fallback,
@@ -2956,27 +2985,27 @@ class Ja {
2956
2985
  await Promise.all([this.primary.destroy(), this.fallback.destroy()]);
2957
2986
  }
2958
2987
  }
2959
- function Os(n) {
2960
- return new gi({
2961
- start: new Et(n.start),
2962
- end: n.end ? new Et(n.end) : void 0
2988
+ function zs(n) {
2989
+ return new yi({
2990
+ start: new Rt(n.start),
2991
+ end: n.end ? new Rt(n.end) : void 0
2963
2992
  });
2964
2993
  }
2965
- function xs(n, e = window) {
2966
- const { href: t, text: i, cssSelector: s, domRange: a, fragment: r } = n, o = i ? new oi(i) : void 0, l = s || a ? /* @__PURE__ */ new Map() : void 0;
2967
- l && (s && l.set("cssSelector", s), a && l.set("domRange", Os(a).serialize()));
2968
- const u = l !== void 0 || r !== void 0 ? new li({
2994
+ function Ns(n, e = window) {
2995
+ const { href: t, text: i, cssSelector: s, domRange: a, fragment: r } = n, o = i ? new di(i) : void 0, l = s || a ? /* @__PURE__ */ new Map() : void 0;
2996
+ l && (s && l.set("cssSelector", s), a && l.set("domRange", zs(a).serialize()));
2997
+ const u = l !== void 0 || r !== void 0 ? new gi({
2969
2998
  fragments: r ? [r] : void 0,
2970
2999
  otherLocations: l
2971
3000
  }) : void 0;
2972
- return new ci({
3001
+ return new fi({
2973
3002
  href: t ?? e.location.href,
2974
3003
  type: "text/html",
2975
3004
  text: o,
2976
3005
  locations: u
2977
3006
  });
2978
3007
  }
2979
- class Vs extends si {
3008
+ class Ms extends ci {
2980
3009
  constructor(e, t, i, s = {}) {
2981
3010
  super(e.host, s), this.channel = e, this.wnd = t, this.decorator = i;
2982
3011
  }
@@ -2992,7 +3021,7 @@ class Vs extends si {
2992
3021
  e.map(({ id: i, style: s, ...a }) => ({
2993
3022
  id: i,
2994
3023
  style: s,
2995
- locator: xs(a, this.wnd)
3024
+ locator: Ns(a, this.wnd)
2996
3025
  })),
2997
3026
  t
2998
3027
  );
@@ -3001,12 +3030,12 @@ class Vs extends si {
3001
3030
  super.destroy(), this.decorator.unmount(this.wnd, this.channel.frame), this.channel.frame.destroy();
3002
3031
  }
3003
3032
  }
3004
- function Za(n = window, e = {}) {
3005
- const t = new ai(), i = new ri();
3006
- return i.mount(n, t.frame), new Vs(t, n, i, e);
3033
+ function ir(n = window, e = {}) {
3034
+ const t = new ui(), i = new hi();
3035
+ return i.mount(n, t.frame), new Ms(t, n, i, e);
3007
3036
  }
3008
- const Pn = (n) => n.voiceURI ?? n.identifier ?? n.name;
3009
- class Xa {
3037
+ const Ln = (n) => n.voiceURI ?? n.identifier ?? n.name;
3038
+ class sr {
3010
3039
  providers = /* @__PURE__ */ new Map();
3011
3040
  register(e) {
3012
3041
  if (this.providers.has(e.id))
@@ -3046,7 +3075,7 @@ class Xa {
3046
3075
  return t;
3047
3076
  }
3048
3077
  }
3049
- const Ae = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), ye = Ae(0, 5e3, 100), Se = Ae(0.1, 10, 0.1), be = Ae(0, 2, 0.1), we = Ae(0, 1, 0.05), lt = Object.freeze(["none", "few", "some", "most", "custom"]), ct = Object.freeze(["none", "block-level", "always"]), ut = Object.freeze(["plain", "ssml"]), ht = Object.freeze(["none", "utterance", "block"]), dt = Object.freeze(["structure", "sentence"]), Mt = Object.freeze([
3078
+ const Le = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), be = Le(0, 5e3, 100), we = Le(0.1, 10, 0.1), ke = Le(0, 2, 0.1), Ce = Le(0, 1, 0.05), lt = Object.freeze(["none", "few", "some", "most", "custom"]), ct = Object.freeze(["none", "block-level", "always"]), ut = Object.freeze(["plain", "ssml"]), ht = Object.freeze(["none", "utterance", "block"]), dt = Object.freeze(["structure", "sentence"]), Bt = Object.freeze([
3050
3079
  "format",
3051
3080
  "inlineContextualization",
3052
3081
  "verbosity",
@@ -3056,13 +3085,13 @@ const Ae = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t })
3056
3085
  "languageOverrides",
3057
3086
  "segmentation"
3058
3087
  ]);
3059
- function Us(n) {
3088
+ function Bs(n) {
3060
3089
  return n == null || typeof n == "boolean" ? n : void 0;
3061
3090
  }
3062
3091
  function O(n, e) {
3063
3092
  return n == null || e.includes(n) ? n : void 0;
3064
3093
  }
3065
- function N(n, e) {
3094
+ function z(n, e) {
3066
3095
  if (n == null) return n;
3067
3096
  if (typeof n != "number" || Number.isNaN(n)) return;
3068
3097
  const t = Math.min(...e), i = Math.max(...e);
@@ -3073,13 +3102,13 @@ function gt(n) {
3073
3102
  if (!(typeof n != "object" || Array.isArray(n)))
3074
3103
  return Object.values(n).every((e) => typeof e == "string") ? { ...n } : void 0;
3075
3104
  }
3076
- function An(n) {
3105
+ function On(n) {
3077
3106
  return typeof n == "string" ? n : gt(n);
3078
3107
  }
3079
- function K(n) {
3108
+ function G(n) {
3080
3109
  return n == null ? n : Array.isArray(n) && n.every((e) => typeof e == "string") ? [...n] : void 0;
3081
3110
  }
3082
- class Ts {
3111
+ class js {
3083
3112
  format;
3084
3113
  inlineContextualization;
3085
3114
  verbosity;
@@ -3095,10 +3124,10 @@ class Ts {
3095
3124
  pitch;
3096
3125
  volume;
3097
3126
  constructor(e = {}) {
3098
- this.format = O(e.format, ut) ?? "plain", this.inlineContextualization = K(e.inlineContextualization) ?? [], this.verbosity = O(e.verbosity, lt) ?? "few", this.skip = K(e.skip) ?? [], this.contextualize = K(e.contextualize) ?? [], this.language = O(e.language, ct) ?? "block-level", this.languageOverrides = gt(e.languageOverrides) ?? {}, this.segmentation = O(e.segmentation, dt) ?? "structure", this.voice = An(e.voice) ?? null, this.pauseDuration = N(e.pauseDuration, ye.range) ?? 300, this.autoPause = O(e.autoPause, ht) ?? "none", this.rate = N(e.rate, Se.range) ?? 1, this.pitch = N(e.pitch, be.range) ?? 1, this.volume = N(e.volume, we.range) ?? 1;
3127
+ this.format = O(e.format, ut) ?? "plain", this.inlineContextualization = G(e.inlineContextualization) ?? [], this.verbosity = O(e.verbosity, lt) ?? "few", this.skip = G(e.skip) ?? [], this.contextualize = G(e.contextualize) ?? [], this.language = O(e.language, ct) ?? "block-level", this.languageOverrides = gt(e.languageOverrides) ?? {}, this.segmentation = O(e.segmentation, dt) ?? "structure", this.voice = On(e.voice) ?? null, this.pauseDuration = z(e.pauseDuration, be.range) ?? 300, this.autoPause = O(e.autoPause, ht) ?? "none", this.rate = z(e.rate, we.range) ?? 1, this.pitch = z(e.pitch, ke.range) ?? 1, this.volume = z(e.volume, Ce.range) ?? 1;
3099
3128
  }
3100
3129
  }
3101
- class oe {
3130
+ class le {
3102
3131
  format;
3103
3132
  inlineContextualization;
3104
3133
  verbosity;
@@ -3114,16 +3143,16 @@ class oe {
3114
3143
  pitch;
3115
3144
  volume;
3116
3145
  constructor(e = {}) {
3117
- this.format = O(e.format, ut), this.inlineContextualization = K(e.inlineContextualization), this.verbosity = O(e.verbosity, lt), this.skip = K(e.skip), this.contextualize = K(e.contextualize), this.language = O(e.language, ct), this.languageOverrides = gt(e.languageOverrides), this.segmentation = O(e.segmentation, dt), this.voice = An(e.voice), this.pauseDuration = N(e.pauseDuration, ye.range), this.autoPause = O(e.autoPause, ht), this.rate = N(e.rate, Se.range), this.pitch = N(e.pitch, be.range), this.volume = N(e.volume, we.range);
3146
+ this.format = O(e.format, ut), this.inlineContextualization = G(e.inlineContextualization), this.verbosity = O(e.verbosity, lt), this.skip = G(e.skip), this.contextualize = G(e.contextualize), this.language = O(e.language, ct), this.languageOverrides = gt(e.languageOverrides), this.segmentation = O(e.segmentation, dt), this.voice = On(e.voice), this.pauseDuration = z(e.pauseDuration, be.range), this.autoPause = O(e.autoPause, ht), this.rate = z(e.rate, we.range), this.pitch = z(e.pitch, ke.range), this.volume = z(e.volume, Ce.range);
3118
3147
  }
3119
3148
  merging(e) {
3120
3149
  const t = { ...this };
3121
3150
  for (const i of Object.keys(e))
3122
3151
  e[i] !== void 0 && (t[i] = e[i]);
3123
- return new oe(t);
3152
+ return new le(t);
3124
3153
  }
3125
3154
  }
3126
- class Q {
3155
+ class K {
3127
3156
  _value;
3128
3157
  _effectiveValue;
3129
3158
  _isEffective;
@@ -3152,7 +3181,7 @@ class Q {
3152
3181
  this._value = null, this._onChange(this._value);
3153
3182
  }
3154
3183
  }
3155
- class ne extends Q {
3184
+ class ie extends K {
3156
3185
  _supportedValues;
3157
3186
  constructor({
3158
3187
  initialValue: e = null,
@@ -3175,9 +3204,9 @@ class ne extends Q {
3175
3204
  return this._supportedValues;
3176
3205
  }
3177
3206
  }
3178
- class Ya extends Q {
3207
+ class ar extends K {
3179
3208
  set value(e) {
3180
- if (e != null && Us(e) === void 0)
3209
+ if (e != null && Bs(e) === void 0)
3181
3210
  throw new Error(`Value '${String(e)}' is not a boolean.`);
3182
3211
  this._value = e, this._onChange(this._value);
3183
3212
  }
@@ -3185,9 +3214,9 @@ class Ya extends Q {
3185
3214
  return this._value;
3186
3215
  }
3187
3216
  }
3188
- class Te extends Q {
3217
+ class Te extends K {
3189
3218
  set value(e) {
3190
- if (e != null && K(e) === void 0)
3219
+ if (e != null && G(e) === void 0)
3191
3220
  throw new Error(`Value '${String(e)}' is not an array of strings.`);
3192
3221
  this._value = e, this._onChange(this._value);
3193
3222
  }
@@ -3195,7 +3224,7 @@ class Te extends Q {
3195
3224
  return this._value;
3196
3225
  }
3197
3226
  }
3198
- class fe extends Q {
3227
+ class me extends K {
3199
3228
  _supportedRange;
3200
3229
  _step;
3201
3230
  _decimals;
@@ -3210,7 +3239,7 @@ class fe extends Q {
3210
3239
  super({ initialValue: e, effectiveValue: t, isEffective: i, onChange: s }), this._supportedRange = a, this._step = r, this._decimals = this._step.toString().includes(".") ? this._step.toString().split(".")[1].length : 0;
3211
3240
  }
3212
3241
  set value(e) {
3213
- if (e != null && N(e, this._supportedRange) === void 0)
3242
+ if (e != null && z(e, this._supportedRange) === void 0)
3214
3243
  throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);
3215
3244
  this._value = e, this._onChange(this._value);
3216
3245
  }
@@ -3239,7 +3268,7 @@ class fe extends Q {
3239
3268
  return e.toString();
3240
3269
  }
3241
3270
  }
3242
- class Bt {
3271
+ class jt {
3243
3272
  preferences;
3244
3273
  settings;
3245
3274
  // Cloned rather than aliased: edits made through this editor's setters
@@ -3247,12 +3276,12 @@ class Bt {
3247
3276
  // once explicitly passed to submitPreferences() — discarding the editor
3248
3277
  // without submitting must leave the navigator untouched.
3249
3278
  constructor(e, t) {
3250
- this.preferences = new oe({ ...e }), this.settings = t;
3279
+ this.preferences = new le({ ...e }), this.settings = t;
3251
3280
  }
3252
3281
  // Explicit `null`s, not `undefined` — merging() skips `undefined` fields,
3253
3282
  // so only `null` actually clears them once submitted.
3254
3283
  clear() {
3255
- this.preferences = new oe({
3284
+ this.preferences = new le({
3256
3285
  format: null,
3257
3286
  inlineContextualization: null,
3258
3287
  verbosity: null,
@@ -3273,7 +3302,7 @@ class Bt {
3273
3302
  this.preferences[e] = t;
3274
3303
  }
3275
3304
  get format() {
3276
- return new ne({
3305
+ return new ie({
3277
3306
  initialValue: this.preferences.format,
3278
3307
  effectiveValue: this.settings.format,
3279
3308
  isEffective: this.preferences.format != null,
@@ -3290,7 +3319,7 @@ class Bt {
3290
3319
  });
3291
3320
  }
3292
3321
  get verbosity() {
3293
- return new ne({
3322
+ return new ie({
3294
3323
  initialValue: this.preferences.verbosity,
3295
3324
  effectiveValue: this.settings.verbosity,
3296
3325
  isEffective: this.preferences.verbosity != null,
@@ -3315,7 +3344,7 @@ class Bt {
3315
3344
  });
3316
3345
  }
3317
3346
  get language() {
3318
- return new ne({
3347
+ return new ie({
3319
3348
  initialValue: this.preferences.language,
3320
3349
  effectiveValue: this.settings.language,
3321
3350
  isEffective: this.preferences.language != null,
@@ -3324,7 +3353,7 @@ class Bt {
3324
3353
  });
3325
3354
  }
3326
3355
  get languageOverrides() {
3327
- return new Q({
3356
+ return new K({
3328
3357
  initialValue: this.preferences.languageOverrides,
3329
3358
  effectiveValue: this.settings.languageOverrides,
3330
3359
  isEffective: this.preferences.languageOverrides != null,
@@ -3332,7 +3361,7 @@ class Bt {
3332
3361
  });
3333
3362
  }
3334
3363
  get segmentation() {
3335
- return new ne({
3364
+ return new ie({
3336
3365
  initialValue: this.preferences.segmentation,
3337
3366
  effectiveValue: this.settings.segmentation,
3338
3367
  isEffective: this.preferences.segmentation != null,
@@ -3341,7 +3370,7 @@ class Bt {
3341
3370
  });
3342
3371
  }
3343
3372
  get voice() {
3344
- return new Q({
3373
+ return new K({
3345
3374
  initialValue: this.preferences.voice,
3346
3375
  effectiveValue: this.settings.voice,
3347
3376
  isEffective: this.preferences.voice != null,
@@ -3349,17 +3378,17 @@ class Bt {
3349
3378
  });
3350
3379
  }
3351
3380
  get pauseDuration() {
3352
- return new fe({
3381
+ return new me({
3353
3382
  initialValue: this.preferences.pauseDuration,
3354
3383
  effectiveValue: this.settings.pauseDuration,
3355
3384
  isEffective: this.preferences.pauseDuration != null,
3356
3385
  onChange: (e) => this.updatePreference("pauseDuration", e ?? null),
3357
- supportedRange: ye.range,
3358
- step: ye.step
3386
+ supportedRange: be.range,
3387
+ step: be.step
3359
3388
  });
3360
3389
  }
3361
3390
  get autoPause() {
3362
- return new ne({
3391
+ return new ie({
3363
3392
  initialValue: this.preferences.autoPause,
3364
3393
  effectiveValue: this.settings.autoPause,
3365
3394
  isEffective: this.preferences.autoPause != null,
@@ -3368,38 +3397,38 @@ class Bt {
3368
3397
  });
3369
3398
  }
3370
3399
  get rate() {
3371
- return new fe({
3400
+ return new me({
3372
3401
  initialValue: this.preferences.rate,
3373
3402
  effectiveValue: this.settings.rate,
3374
3403
  isEffective: this.preferences.rate != null,
3375
3404
  onChange: (e) => this.updatePreference("rate", e ?? null),
3376
- supportedRange: Se.range,
3377
- step: Se.step
3405
+ supportedRange: we.range,
3406
+ step: we.step
3378
3407
  });
3379
3408
  }
3380
3409
  get pitch() {
3381
- return new fe({
3410
+ return new me({
3382
3411
  initialValue: this.preferences.pitch,
3383
3412
  effectiveValue: this.settings.pitch,
3384
3413
  isEffective: this.preferences.pitch != null,
3385
3414
  onChange: (e) => this.updatePreference("pitch", e ?? null),
3386
- supportedRange: be.range,
3387
- step: be.step
3415
+ supportedRange: ke.range,
3416
+ step: ke.step
3388
3417
  });
3389
3418
  }
3390
3419
  get volume() {
3391
- return new fe({
3420
+ return new me({
3392
3421
  initialValue: this.preferences.volume,
3393
3422
  effectiveValue: this.settings.volume,
3394
3423
  isEffective: this.preferences.volume != null,
3395
3424
  onChange: (e) => this.updatePreference("volume", e ?? null),
3396
- supportedRange: we.range,
3397
- step: we.step
3425
+ supportedRange: Ce.range,
3426
+ step: Ce.step
3398
3427
  });
3399
3428
  }
3400
3429
  }
3401
- const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3402
- ...Ln,
3430
+ const Vn = ["audio", "figure", "image", "math", "table", "video"], xn = [
3431
+ ...Vn,
3403
3432
  "blockquote",
3404
3433
  "chapter",
3405
3434
  "cover",
@@ -3412,8 +3441,8 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3412
3441
  "rowheader",
3413
3442
  "subtitle",
3414
3443
  "tip"
3415
- ], zs = [
3416
- ...On,
3444
+ ], Ds = [
3445
+ ...xn,
3417
3446
  "abstract",
3418
3447
  "acknowledgments",
3419
3448
  "afterword",
@@ -3457,7 +3486,7 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3457
3486
  "separator",
3458
3487
  "summary",
3459
3488
  "term"
3460
- ], Ns = {
3489
+ ], Fs = {
3461
3490
  none: /* @__PURE__ */ new Set([
3462
3491
  "aside",
3463
3492
  "audio",
@@ -3525,28 +3554,28 @@ const Ln = ["audio", "figure", "image", "math", "table", "video"], On = [
3525
3554
  "toc"
3526
3555
  ]),
3527
3556
  most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
3528
- }, Ms = {
3557
+ }, _s = {
3529
3558
  none: /* @__PURE__ */ new Set(),
3530
- few: new Set(Ln),
3531
- some: new Set(On),
3532
- most: new Set(zs)
3559
+ few: new Set(Vn),
3560
+ some: new Set(xn),
3561
+ most: new Set(Ds)
3533
3562
  }, Ke = {
3534
3563
  table: { few: "inline", some: "block", most: "block" }
3535
3564
  };
3536
- function pe(n) {
3565
+ function ve(n) {
3537
3566
  const e = {};
3538
3567
  for (const t of Object.keys(Ke))
3539
3568
  e[t] = Ke[t]?.[n] ?? "inline";
3540
3569
  return e;
3541
3570
  }
3542
- const Bs = {
3543
- none: pe("none"),
3544
- few: pe("few"),
3545
- some: pe("some"),
3546
- most: pe("most")
3547
- }, er = Object.keys(Ke);
3548
- function js(n, e) {
3549
- const t = n === "custom" ? {} : Bs[n];
3571
+ const $s = {
3572
+ none: ve("none"),
3573
+ few: ve("few"),
3574
+ some: ve("some"),
3575
+ most: ve("most")
3576
+ }, rr = Object.keys(Ke);
3577
+ function qs(n, e) {
3578
+ const t = n === "custom" ? {} : $s[n];
3550
3579
  if (!e) return t;
3551
3580
  const i = { ...t };
3552
3581
  for (const s of Object.keys(e)) {
@@ -3555,10 +3584,10 @@ function js(n, e) {
3555
3584
  }
3556
3585
  return i;
3557
3586
  }
3558
- const Ds = (n, e) => {
3587
+ const Gs = (n, e) => {
3559
3588
  if (!e || typeof n == "string") return n;
3560
- const [t] = C(e.language);
3561
- return !t || n && nt(n, t) !== void 0 ? n : { ...n, [t]: Pn(e) };
3589
+ const [t] = k(e.language);
3590
+ return !t || n && nt(n, t) !== void 0 ? n : { ...n, [t]: Ln(e) };
3562
3591
  };
3563
3592
  class ze {
3564
3593
  format;
@@ -3579,36 +3608,36 @@ class ze {
3579
3608
  * @param engineVoice The engine's voice, which `voice` falls back to: when unset, or for its language in a record without it.
3580
3609
  */
3581
3610
  constructor(e, t, i) {
3582
- this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...Ns[this.verbosity]], this.contextualize = [...Ms[this.verbosity]]), this.language = e.language ?? t.language, this.languageOverrides = e.languageOverrides ?? t.languageOverrides, this.segmentation = e.segmentation ?? t.segmentation, this.voice = Ds(e.voice ?? t.voice, i), this.pauseDuration = e.pauseDuration ?? t.pauseDuration, this.autoPause = e.autoPause ?? t.autoPause, this.rate = e.rate ?? t.rate, this.pitch = e.pitch ?? t.pitch, this.volume = e.volume ?? t.volume;
3611
+ this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...Fs[this.verbosity]], this.contextualize = [..._s[this.verbosity]]), this.language = e.language ?? t.language, this.languageOverrides = e.languageOverrides ?? t.languageOverrides, this.segmentation = e.segmentation ?? t.segmentation, this.voice = Gs(e.voice ?? t.voice, i), this.pauseDuration = e.pauseDuration ?? t.pauseDuration, this.autoPause = e.autoPause ?? t.autoPause, this.rate = e.rate ?? t.rate, this.pitch = e.pitch ?? t.pitch, this.volume = e.volume ?? t.volume;
3583
3612
  }
3584
3613
  }
3585
- const jt = /* @__PURE__ */ new WeakMap(), xn = /* @__PURE__ */ new WeakMap();
3586
- function Dt(n, e) {
3587
- xn.set(n, e);
3614
+ const Dt = /* @__PURE__ */ new WeakMap(), Un = /* @__PURE__ */ new WeakMap();
3615
+ function Ft(n, e) {
3616
+ Un.set(n, e);
3588
3617
  }
3589
- const Vn = /* @__PURE__ */ new WeakSet();
3590
- function Ft(n) {
3591
- return Vn.add(n), n;
3618
+ const Tn = /* @__PURE__ */ new WeakSet();
3619
+ function _t(n) {
3620
+ return Tn.add(n), n;
3592
3621
  }
3593
- function Fs(n, e, t) {
3594
- const i = xn.get(n);
3622
+ function Hs(n, e, t) {
3623
+ const i = Un.get(n);
3595
3624
  if (i) {
3596
- const u = Vt(i.map, e), g = Vt(i.map, e + t);
3625
+ const u = Ut(i.map, e), g = Ut(i.map, e + t);
3597
3626
  e = u, t = Math.max(0, g - u);
3598
3627
  }
3599
- const s = n.offsets, a = !n.plain && !!n.ssml, r = i?.plain ?? n.plain ?? (n.ssml ? M(n.ssml) : "");
3628
+ const s = n.offsets, a = !n.plain && !!n.ssml, r = i?.plain ?? n.plain ?? (n.ssml ? N(n.ssml) : "");
3600
3629
  if (!s?.length || !r) return;
3601
- const o = jt.get(n), l = o !== void 0 && e >= o.cursor;
3630
+ const o = Dt.get(n), l = o !== void 0 && e >= o.cursor;
3602
3631
  let c = l ? o.cursor : 0;
3603
3632
  for (let u = l ? o.pieceIndex : 0; u < s.length; u++) {
3604
- const g = s[u], d = g.locate.text?.highlight, h = d ? a ? M(d) : d : r.slice(c);
3633
+ const g = s[u], d = g.locate.text?.highlight, h = d ? a ? N(d) : d : r.slice(c);
3605
3634
  if (!h) continue;
3606
3635
  const f = r.indexOf(h, c);
3607
3636
  if (f === -1) continue;
3608
3637
  const p = f + h.length;
3609
3638
  if (e >= f && e < p) {
3610
- if (Vn.has(g.locate)) return;
3611
- jt.set(n, { pieceIndex: u, cursor: c });
3639
+ if (Tn.has(g.locate)) return;
3640
+ Dt.set(n, { pieceIndex: u, cursor: c });
3612
3641
  const m = e - f, S = h.substring(m, Math.min(m + t, h.length));
3613
3642
  return { locate: {
3614
3643
  ...g.locate,
@@ -3623,13 +3652,13 @@ function Fs(n, e, t) {
3623
3652
  c = p;
3624
3653
  }
3625
3654
  }
3626
- function _s(n, e) {
3655
+ function Ks(n, e) {
3627
3656
  return e === "sentence" && n.offsets?.length ? n.offsets.map((t) => t.locate) : n.locate ? [n.locate] : [];
3628
3657
  }
3629
- function V(n) {
3658
+ function x(n) {
3630
3659
  return { pattern: new RegExp(`(\\d+)\\s?u${n}\\b`, "g"), replace: (e, t) => `${t}µ${n}` };
3631
3660
  }
3632
- const $s = {
3661
+ const Ws = {
3633
3662
  "1/4": "¼",
3634
3663
  "1/2": "½",
3635
3664
  "3/4": "¾",
@@ -3649,8 +3678,8 @@ const $s = {
3649
3678
  "5/8": "⅝",
3650
3679
  "7/8": "⅞",
3651
3680
  "0/3": "↉"
3652
- }, qs = {
3653
- ...$s,
3681
+ }, Qs = {
3682
+ ...Ws,
3654
3683
  // Rejects "(c)" directly preceded by "(a)"/"(b)" (a lettered list, not a copyright notice).
3655
3684
  "(c)": { pattern: new RegExp("(?<!\\([ab]\\)\\s{0,3})\\(c\\)", "g"), replace: "©" },
3656
3685
  "(C)": { pattern: new RegExp("(?<!\\([AB]\\)\\s{0,3})\\(C\\)", "g"), replace: "©" },
@@ -3660,37 +3689,37 @@ const $s = {
3660
3689
  "(TM)": "™",
3661
3690
  deg: { pattern: /(\d+)\s?deg\b/g, replace: (n, e) => `${e}°` },
3662
3691
  x: { pattern: /(\d+)\s?[xX]\s?(?=\d)/g, replace: (n, e) => `${e}×` },
3663
- ug: V("g"),
3664
- um: V("m"),
3665
- us: V("s"),
3666
- uL: V("L"),
3667
- uF: V("F"),
3668
- uA: V("A"),
3669
- uV: V("V"),
3670
- uW: V("W"),
3671
- uN: V("N"),
3672
- umol: V("mol"),
3692
+ ug: x("g"),
3693
+ um: x("m"),
3694
+ us: x("s"),
3695
+ uL: x("L"),
3696
+ uF: x("F"),
3697
+ uA: x("A"),
3698
+ uV: x("V"),
3699
+ uW: x("W"),
3700
+ uN: x("N"),
3701
+ umol: x("mol"),
3673
3702
  "->": "→",
3674
3703
  "<-": "←",
3675
3704
  // Reversed from every other entry: engines pattern-match the ASCII foot/inch
3676
3705
  // convention for pronunciation, but drop the real prime marks silently.
3677
3706
  "′": "'",
3678
3707
  "″": '"'
3679
- }, Gs = { contextualizations: { abstract: { block: { start: "Start of the abstract.", end: "End of the abstract." } }, acknowledgments: { block: { start: "Start of the acknowledgments.", end: "End of the acknowledgments." } }, afterword: { block: { start: "Start of the afterword.", end: "End of the afterword." } }, appendix: { block: { start: "Start of the appendix.", end: "End of the appendix." } }, aside: { block: { start: "Start of the aside.", end: "End of the aside." } }, audio: { inline: { labelled: "Audio with a label: {{ description }}", unlabelled: "Audio with no label." } }, bibliography: { block: { start: "Start of the bibliography.", end: "End of the bibliography." } }, blockquote: { inline: "Blockquote." }, cell: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, chapter: { block: { start: "Start of the chapter.", end: "End of the chapter." } }, colophon: { inline: "Colophon." }, complementary: { block: { start: "Start of the complementary content.", end: "End of the complementary content." } }, conclusion: { block: { start: "Start of the conclusion.", end: "End of the conclusion." } }, cover: { inline: { labelled: "Cover with a label: {{ description }}", unlabelled: "Cover with no label." } }, credit: { inline: "Credit." }, credits: { block: { start: "Start of the credits.", end: "End of the credits." } }, dedication: { inline: "Dedication." }, definition: { inline: "Definition." }, details: { block: { start: "Start of the disclosure.", end: "End of the disclosure." } }, endnotes: { block: { start: "Start of the endnotes.", end: "End of the endnotes." } }, epigraph: { inline: "Epigraph." }, epilogue: { block: { start: "Start of the epilogue.", end: "End of the epilogue." } }, errata: { block: { start: "Start of the errata.", end: "End of the errata." } }, example: { block: { start: "Start of the example.", end: "End of the example." } }, figure: { inline: "Figure: {{ description }}" }, footnote: { block: { start: "Start of the footnote.", end: "End of the footnote." } }, foreword: { block: { start: "Start of the foreword.", end: "End of the foreword." } }, glossary: { block: { start: "Start of the glossary.", end: "End of the glossary." } }, heading1: { inline: "Heading level 1." }, heading2: { inline: "Heading level 2." }, heading3: { inline: "Heading level 3." }, heading4: { inline: "Heading level 4." }, heading5: { inline: "Heading level 5." }, heading6: { inline: "Heading level 6." }, image: { inline: { labelled: "Image with a label: {{ description }}", unlabelled: "Image with no label." } }, index: { block: { start: "Start of the index.", end: "End of the index." } }, introduction: { block: { start: "Start of the introduction.", end: "End of the introduction." } }, list: { block: { start: "Start of the list.", end: "End of the list." } }, listItem: { inline: "List item." }, math: { inline: { labelled: "{{ description }}", unlabelled: "Math formula with no label." } }, notice: { inline: "Notice." }, pagebreak: { inline: "Pagebreak.", number: "Page {{ number }}" }, pagelist: { block: { start: "Start of the page list.", end: "End of the page list." } }, part: { inline: "Part." }, preface: { block: { start: "Start of the preface.", end: "End of the preface." } }, prologue: { block: { start: "Start of the prologue.", end: "End of the prologue." } }, pullquote: { inline: "Pullquote." }, qna: { block: { start: "Start of the questions and answers.", end: "End of the questions and answers." } }, row: { inline: "Row: {{ count }}" }, rowheader: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, separator: { inline: "Separator." }, subtitle: { inline: "Subtitle." }, summary: { inline: "Summary." }, table: { block: { end: "End of the table.", start: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." } }, inline: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." }, parts: { columns_one: "1 column", columns_other: "{{ count }} columns", lines_one: "1 line", lines_other: "{{ count }} lines" } }, term: { inline: "Term." }, tip: { inline: "Tip." }, video: { inline: { labelled: "Video with a label: {{ description }}", unlabelled: "Video with no label." } } } }, Hs = {
3680
- speech: Gs
3681
- }, Un = Hs.speech.contextualizations, We = { en: Un }, Tn = {};
3682
- function Ks(n) {
3683
- return We[n] || Tn[n] ? n : "en";
3708
+ }, Js = { contextualizations: { abstract: { block: { start: "Start of the abstract.", end: "End of the abstract." } }, acknowledgments: { block: { start: "Start of the acknowledgments.", end: "End of the acknowledgments." } }, afterword: { block: { start: "Start of the afterword.", end: "End of the afterword." } }, appendix: { block: { start: "Start of the appendix.", end: "End of the appendix." } }, aside: { block: { start: "Start of the aside.", end: "End of the aside." } }, audio: { inline: { labelled: "Audio with a label: {{ description }}", unlabelled: "Audio with no label." } }, bibliography: { block: { start: "Start of the bibliography.", end: "End of the bibliography." } }, blockquote: { inline: "Blockquote." }, cell: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, chapter: { block: { start: "Start of the chapter.", end: "End of the chapter." } }, colophon: { inline: "Colophon." }, complementary: { block: { start: "Start of the complementary content.", end: "End of the complementary content." } }, conclusion: { block: { start: "Start of the conclusion.", end: "End of the conclusion." } }, cover: { inline: { labelled: "Cover with a label: {{ description }}", unlabelled: "Cover with no label." } }, credit: { inline: "Credit." }, credits: { block: { start: "Start of the credits.", end: "End of the credits." } }, dedication: { inline: "Dedication." }, definition: { inline: "Definition." }, details: { block: { start: "Start of the disclosure.", end: "End of the disclosure." } }, endnotes: { block: { start: "Start of the endnotes.", end: "End of the endnotes." } }, epigraph: { inline: "Epigraph." }, epilogue: { block: { start: "Start of the epilogue.", end: "End of the epilogue." } }, errata: { block: { start: "Start of the errata.", end: "End of the errata." } }, example: { block: { start: "Start of the example.", end: "End of the example." } }, figure: { inline: "Figure: {{ description }}" }, footnote: { block: { start: "Start of the footnote.", end: "End of the footnote." } }, foreword: { block: { start: "Start of the foreword.", end: "End of the foreword." } }, glossary: { block: { start: "Start of the glossary.", end: "End of the glossary." } }, heading1: { inline: "Heading level 1." }, heading2: { inline: "Heading level 2." }, heading3: { inline: "Heading level 3." }, heading4: { inline: "Heading level 4." }, heading5: { inline: "Heading level 5." }, heading6: { inline: "Heading level 6." }, image: { inline: { labelled: "Image with a label: {{ description }}", unlabelled: "Image with no label." } }, index: { block: { start: "Start of the index.", end: "End of the index." } }, introduction: { block: { start: "Start of the introduction.", end: "End of the introduction." } }, list: { block: { start: "Start of the list.", end: "End of the list." } }, listItem: { inline: "List item." }, math: { inline: { labelled: "{{ description }}", unlabelled: "Math formula with no label." } }, notice: { inline: "Notice." }, pagebreak: { inline: "Pagebreak.", number: "Page {{ number }}" }, pagelist: { block: { start: "Start of the page list.", end: "End of the page list." } }, part: { inline: "Part." }, preface: { block: { start: "Start of the preface.", end: "End of the preface." } }, prologue: { block: { start: "Start of the prologue.", end: "End of the prologue." } }, pullquote: { inline: "Pullquote." }, qna: { block: { start: "Start of the questions and answers.", end: "End of the questions and answers." } }, row: { inline: "Row: {{ count }}" }, rowheader: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, separator: { inline: "Separator." }, subtitle: { inline: "Subtitle." }, summary: { inline: "Summary." }, table: { block: { end: "End of the table.", start: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." } }, inline: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." }, parts: { columns_one: "1 column", columns_other: "{{ count }} columns", lines_one: "1 line", lines_other: "{{ count }} lines" } }, term: { inline: "Term." }, tip: { inline: "Tip." }, video: { inline: { labelled: "Video with a label: {{ description }}", unlabelled: "Video with no label." } } } }, Zs = {
3709
+ speech: Js
3710
+ }, zn = Zs.speech.contextualizations, We = { en: zn }, Nn = {};
3711
+ function Xs(n) {
3712
+ return We[n] || Nn[n] ? n : "en";
3684
3713
  }
3685
- async function Ws(n) {
3714
+ async function Ys(n) {
3686
3715
  const e = We[n];
3687
3716
  if (e) return e;
3688
- const t = Tn[n];
3689
- if (!t) return Un;
3717
+ const t = Nn[n];
3718
+ if (!t) return zn;
3690
3719
  const i = (await t()).speech.contextualizations;
3691
3720
  return We[n] = i, i;
3692
3721
  }
3693
- const Qs = {
3722
+ const ea = {
3694
3723
  de: ["A.", "A.M.", "Abs.", "Abt.", "Abw.", "Adj.", "Adr.", "Akt.", "Allg.", "Alt.", "App.", "Apr.", "Art.", "Aug.", "Ausg.", "Ausschl.", "B.", "Bed.", "Ben.", "Ber.", "Best.", "Bibl.", "C.", "Ca.", "Chin.", "Chr.", "Co.", "D.", "D. h.", "Dat.", "Dez.", "Di.", "Dim.", "Dipl.-Ing.", "Dipl.-Kfm.", "Dir.", "Do.", "Dr.", "Dtzd.", "Einh.", "Erf.", "Evtl.", "F.", "F.f.", "Fa.", "Fam.", "Feb.", "Fn.", "Folg.", "Forts. f.", "Fr.", "Frl.", "G.", "Gebr.", "Gem.", "Geograph.", "Ges.", "Gesch.", "Ggf.", "Hbf.", "Hptst.", "Hr.", "Hrn.", "Hrsg.", "I.", "Inc.", "Ing.", "Inh.", "Int.", "J.", "J.D.", "Jahrh.", "Jan.", "Jr.", "Kap.", "Kfm.", "Kl.", "Konv.", "Kop.", "L.", "Ltd.", "M.", "Max.", "Mi.", "Min.", "Mind.", "Mio.", "Mo.", "Mod.", "Mrd.", "Msp.", "N.", "Nov.", "Nr.", "O.", "Obj.", "Okt.", "Op.", "P.", "P.M.", "PIN.", "Pfd.", "Phys.", "Port.", "Prot.", "Proz.", "Qu.", "R.", "Rd.", "Reg.", "Reg.-Bez.", "Rel.", "Rep.", "S.A.", "Sa.", "Schr.", "Sek.", "Sep.", "Sept.", "So.", "Spezif.", "St.", "StR.", "Std.", "Str.", "T.", "Tel.", "Temp.", "Test.", "Trans.", "Tägl.", "U.", "U. U.", "U.S.", "U.S.A.", "U.U.", "Urspr.", "Ursprüngl.", "Verf.", "Vgl.", "W.", "Wg.", "Y.", "Z.", "Z. B.", "Z. Zt.", "Ztr.", "a.D.", "a.M.", "a.Rh.", "a.a.O.", "a.a.S.", "am.", "amtl.", "b.", "beil.", "d.J.", "d.Ä.", "e.V.", "e.Wz.", "e.h.", "ehem.", "eigtl.", "einschl.", "entspr.", "erw.", "ev.", "evtl.", "exkl.", "frz.", "geb.", "gedr.", "gek.", "gesch.", "gest.", "ggf.", "ggfs.", "hpts.", "i.A.", "i.B.", "i.H.", "i.J.", "i.R.", "i.V.", "inkl.", "jew.", "jhrl.", "k. u. k.", "k.u.k.", "kath.", "kfm.", "kgl.", "led.", "m.E.", "m.W.", "mtl.", "möbl.", "n. Chr.", "n.u.Z.", "näml.", "o.A.", "o.B.", "o.g.", "od.", "p.Adr.", "r.", "röm.", "röm.-kath.", "s.", "s.a.", "schles.", "schweiz.", "schwäb.", "sog.", "südd.", "tägl.", "u.", "u. Z.", "u.A.w.g.", "u.U.", "u.a.", "u.v.a.", "u.Ä.", "u.ä.", "v. Chr.", "v. H.", "v. u. Z.", "v.Chr.", "v.H.", "v.R.w.", "v.T.", "v.u.Z.", "verh.", "verw.", "vgl.", "z.", "z.B.", "z.Hd.", "z.Z.", "zzgl.", "österr."],
3695
3724
  en: ["A.D.", "A.I.", "A.M.", "A.S.", "AA.", "AB.", "Abs.", "Adj.", "Adv.", "Alt.", "Approx.", "Aug.", "B.V.", "C.F.", "C.O.D.", "Capt.", "Col.", "Comm.", "Conn.", "Cont.", "D.A.", "D.C.", "DC.", "DR.", "Dec.", "Def.", "Dept.", "Diff.", "Dr.", "E.G.", "E.g.", "Ed.", "Est.", "Etc.", "Ex.", "Exec.", "Feb.", "Fn.", "Fri.", "Hon.B.A.", "I.", "I.D.", "I.T.", "I.e.", "J.B.", "J.D.", "J.K.", "Jan.", "Jun.", "K.R.", "L.A.", "L.P.", "Lev.", "Lib.", "Lt.", "Lt.Cdr.", "M.", "M.I.T.", "M.R.", "M.T.", "MR.", "Maj.", "Mar.", "Mart.", "Mb.", "Md.", "Mgr.", "Min.", "Misc.", "Mr.", "Mrs.", "Ms.", "Mt.", "N.V.", "N.Y.", "Nov.", "Nr.", "Num.", "Op.", "Org.", "P.M.", "P.O.", "P.V.", "PP.", "Ph.D.", "Phys.", "Prof.", "Pvt.", "R.L.", "R.T.", "Rep.", "Rev.", "S.A.", "S.A.R.", "S.E.", "S.p.A.", "Sep.", "Sept.", "Sgt.", "Sq.", "St.", "U.S.", "U.S.A.", "U.S.C.", "VS.", "Yr.", "a.m.", "d.", "dr.", "exec.", "pp.", "vs."],
3696
3725
  es: ["A.C.", "AA.", "All.", "Ant.", "Av.", "Avda.", "Bien.", "C.", "C.P.", "C.S.", "C.V.", "CA.", "Col.", "Comm.", "Corp.", "Cía.", "D.", "DC.", "Da.", "Desc.", "Desv.", "Dr.", "Dra.", "Drs.", "Dto.", "Dª.", "Dña.", "Em.", "Emm.", "Exc.", "Excma.", "Excmas.", "Excmo.", "Excmos.", "Exma.", "Exmas.", "Exmo.", "Exmos.", "FF.CC.", "Fabric.", "Fr.", "H.P.", "Id.", "Ilma.", "Ilmas.", "Ilmo.", "Ilmos.", "Inc.", "JJ.OO.", "K.", "Kit.", "Korn.", "L.", "Lcda.", "Lcdo.", "Lda.", "Ldo.", "Lic.", "Ltd.", "Ltda.", "Ltdo.", "M.", "MM.", "Mons.", "Mr.", "Mrs.", "O.M.", "PP.", "R.D.", "R.U.", "RAM.", "RR.HH.", "Rdo.", "Rdos.", "Reg.", "Rev.", "Rol.", "Rvdmo.", "Rvdmos.", "Rvdo.", "Rvdos.", "SA.", "SS.AA.", "SS.MM.", "Sdad.", "Seg.", "Sol.", "Sr.", "Sra.", "Sras.", "Sres.", "Srta.", "Srtas.", "Sta.", "Sto.", "Trab.", "U.S.", "U.S.A.", "Var.", "Vda.", "a. C.", "a. e. c.", "abr.", "afma.", "afmas.", "afmo.", "afmos.", "ago.", "bco.", "bol.", "c/c.", "cap.", "cf.", "cfr.", "col.", "d. C.", "depto.", "deptos.", "dic.", "doc.", "dom.", "dpto.", "dptos.", "dtor.", "e. c.", "e.g.", "ed.", "ej.", "ene.", "feb.", "fig.", "figs.", "fund.", "hnos.", "jue.", "jul.", "jun.", "licda.", "licdo.", "lun.", "mar.", "may.", "mié.", "ms.", "mss.", "mtro.", "nov.", "ntra.", "ntro.", "oct.", "p.ej.", "prof.", "prov.", "sept.", "sras.", "sres.", "srs.", "ss.", "sáb.", "trad.", "v.gr.", "vid.", "vie.", "vs."],
@@ -3705,34 +3734,34 @@ function Ne(n, e, t) {
3705
3734
  for (; i > e && /\s/.test(n[i - 1]); ) i--;
3706
3735
  return i;
3707
3736
  }
3708
- const Js = /[\s([{"'“‘]/;
3709
- function Zs(n, e) {
3737
+ const ta = /[\s([{"'“‘]/;
3738
+ function na(n, e) {
3710
3739
  for (const t of e) {
3711
3740
  if (n.length < t.length || !n.endsWith(t)) continue;
3712
3741
  const i = n.length - t.length - 1;
3713
- if (i < 0 || Js.test(n[i])) return !0;
3742
+ if (i < 0 || ta.test(n[i])) return !0;
3714
3743
  }
3715
3744
  return !1;
3716
3745
  }
3717
- function Xs(n) {
3746
+ function ia(n) {
3718
3747
  let e = 0;
3719
3748
  for (const t of n)
3720
3749
  if (new RegExp("\\p{L}", "u").test(t) && e++, e >= 2) return !0;
3721
3750
  return !1;
3722
3751
  }
3723
- function Ys(n) {
3752
+ function sa(n) {
3724
3753
  return /\.{3,}$/.test(n);
3725
3754
  }
3726
- function ea(n, e, t, i) {
3755
+ function aa(n, e, t, i) {
3727
3756
  if (i === "“") return !0;
3728
3757
  if (i !== '"') return !1;
3729
3758
  let s = 0;
3730
3759
  for (let a = e; a < t; a++) n[a] === '"' && s++;
3731
3760
  return s % 2 === 1;
3732
3761
  }
3733
- const ta = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3734
- function na(n, e) {
3735
- const t = [...n.matchAll(ta)].map((s) => s.index + s[0].length);
3762
+ const ra = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
3763
+ function oa(n, e) {
3764
+ const t = [...n.matchAll(ra)].map((s) => s.index + s[0].length);
3736
3765
  if (t.length === 0) return e;
3737
3766
  const i = [];
3738
3767
  for (const s of e) {
@@ -3743,20 +3772,42 @@ function na(n, e) {
3743
3772
  }
3744
3773
  return i;
3745
3774
  }
3746
- function ia(n, e, t) {
3747
- const i = na(n, e).map((a) => ({ ...a }));
3775
+ const la = { "»": "«", "«": "»", "›": "‹", "‹": "›" };
3776
+ function ca(n, e) {
3777
+ const t = [], i = /* @__PURE__ */ new Map();
3778
+ let s = 0;
3779
+ const a = (r, o) => {
3780
+ for (; s < r; s++) i.set(n[s], (i.get(n[s]) ?? 0) + 1);
3781
+ return i.get(o) ?? 0;
3782
+ };
3783
+ for (const r of e) {
3784
+ const o = { ...r }, l = t[t.length - 1];
3785
+ let c = o.start;
3786
+ for (; l && c < o.end; ) {
3787
+ for (; c < o.end && /\s/.test(n[c]); ) c++;
3788
+ const u = la[n[c]];
3789
+ if (u === void 0 || a(l.end, u) <= a(l.end, n[c])) break;
3790
+ for (c++; c < o.end && /\s/.test(n[c]); ) c++;
3791
+ l.end = o.start = c;
3792
+ }
3793
+ o.start < o.end ? t.push(o) : l && (l.end = o.end);
3794
+ }
3795
+ return t;
3796
+ }
3797
+ function ua(n, e, t) {
3798
+ const i = ca(n, oa(n, e));
3748
3799
  for (let a = 0; a < i.length - 1; a++) {
3749
3800
  const r = Ne(n, i[a].start, i[a].end);
3750
3801
  if (r !== i[a].end || r <= i[a].start) continue;
3751
3802
  const o = n[r - 1];
3752
- ea(n, i[a].start, r, o) && (i[a].end -= 1, i[a + 1].start -= 1);
3803
+ aa(n, i[a].start, r, o) && (i[a].end -= 1, i[a + 1].start -= 1);
3753
3804
  }
3754
3805
  const s = [];
3755
3806
  for (const a of i) {
3756
3807
  let r = a;
3757
3808
  for (; s.length > 0; ) {
3758
3809
  const o = s[s.length - 1], l = Ne(n, o.start, o.end), c = n.slice(o.start, l);
3759
- if (!Zs(c, t) && Xs(c) && !Ys(c)) break;
3810
+ if (!na(c, t) && ia(c) && !sa(c)) break;
3760
3811
  s.pop(), r = { start: o.start, end: r.end };
3761
3812
  }
3762
3813
  s.push(r);
@@ -3766,17 +3817,29 @@ function ia(n, e, t) {
3766
3817
  return { text: n.slice(a.start, r), start: a.start, end: a.end, contentEnd: r };
3767
3818
  });
3768
3819
  }
3769
- const _t = /* @__PURE__ */ new Map();
3770
- function sa(n) {
3771
- let e = _t.get(n);
3772
- return e || (e = new Intl.Segmenter(n, { granularity: "sentence" }), _t.set(n, e)), e;
3820
+ const $t = /* @__PURE__ */ new Map();
3821
+ function Mn(n) {
3822
+ let e = $t.get(n);
3823
+ if (!e) {
3824
+ try {
3825
+ const [t, i] = k(n), s = i ? `${t}-${i}` : t;
3826
+ e = { segmenter: new Intl.Segmenter(s, { granularity: "sentence" }), language: n };
3827
+ } catch {
3828
+ e = { segmenter: new Intl.Segmenter("en", { granularity: "sentence" }), language: "en" };
3829
+ }
3830
+ $t.set(n, e);
3831
+ }
3832
+ return e;
3833
+ }
3834
+ function ha(n) {
3835
+ return Mn(n).language;
3773
3836
  }
3774
- async function aa(n, e, t) {
3837
+ async function Bn(n, e, t) {
3775
3838
  if (e === "") return [];
3776
- const s = [...sa(n).segment(e)].map((o) => ({ start: o.index, end: o.index + o.segment.length })), a = Ce(Qs, n) ?? [], r = t ? [...a, ...t] : a;
3777
- return ia(e, s, r);
3839
+ const { segmenter: i, language: s } = Mn(n), r = [...i.segment(e)].map((c) => ({ start: c.index, end: c.index + c.segment.length })), o = cn(ea, s) ?? [], l = t ? [...o, ...t] : o;
3840
+ return ua(e, r, l);
3778
3841
  }
3779
- const tr = [
3842
+ const or = [
3780
3843
  "aside",
3781
3844
  "audio",
3782
3845
  "bibliography",
@@ -3802,7 +3865,7 @@ const tr = [
3802
3865
  "table",
3803
3866
  "toc",
3804
3867
  "video"
3805
- ], ra = [
3868
+ ], da = [
3806
3869
  // Headings
3807
3870
  "heading1",
3808
3871
  "heading2",
@@ -3860,50 +3923,50 @@ const tr = [
3860
3923
  "section",
3861
3924
  "summary",
3862
3925
  "tip"
3863
- ], oa = {
3926
+ ], ga = {
3864
3927
  footnote: { drops: ["aside"], unconditional: !0 },
3865
3928
  cover: { drops: ["image"] },
3866
3929
  pullquote: { drops: ["blockquote", "aside"] },
3867
3930
  epigraph: { drops: ["blockquote"] }
3868
- }, la = ["noteref", "pagebreak"], ca = ["audio", "video", "image", "figure", "math", "table", "cover"], ua = ["cell", "rowheader"], ha = ["separator"], $t = new Set(ra), zn = new Set(la), da = new Set(ca), Nn = new Set(ua), ga = new Set(ha);
3869
- function fa(n, e) {
3870
- const t = ui.createInstance();
3931
+ }, fa = ["noteref", "pagebreak"], pa = ["audio", "video", "image", "figure", "math", "table", "cover"], ma = ["cell", "rowheader"], va = ["separator"], qt = new Set(da), jn = new Set(fa), ya = new Set(pa), Dn = new Set(ma), Sa = new Set(va);
3932
+ function ba(n, e) {
3933
+ const t = pi.createInstance();
3871
3934
  return t.init({
3872
3935
  lng: n,
3873
3936
  resources: { [n]: { translation: e } },
3874
3937
  interpolation: { escapeValue: !1 }
3875
3938
  }), t;
3876
3939
  }
3877
- function pa(n, e, t) {
3940
+ function wa(n, e, t) {
3878
3941
  if (!e) return n;
3879
3942
  const i = { ...n };
3880
3943
  for (const s of Object.keys(e))
3881
3944
  i[s] = t(n[s], e[s]);
3882
3945
  return i;
3883
3946
  }
3884
- function Mn(n, e) {
3947
+ function Fn(n, e) {
3885
3948
  if (typeof e == "string" || typeof n != "object") return e;
3886
3949
  const t = { ...n };
3887
3950
  for (const i of Object.keys(e))
3888
- t[i] = Mn(n[i], e[i]);
3951
+ t[i] = Fn(n[i], e[i]);
3889
3952
  return t;
3890
3953
  }
3891
- function ma(n, e) {
3892
- return pa(n, e, Mn);
3954
+ function ka(n, e) {
3955
+ return wa(n, e, Fn);
3893
3956
  }
3894
- function Bn(n, e = [], t = /* @__PURE__ */ new Map()) {
3957
+ function _n(n, e = [], t = /* @__PURE__ */ new Map()) {
3895
3958
  for (const i of n)
3896
- t.set(i, e), i.children && Bn(i.children, [i, ...e], t);
3959
+ t.set(i, e), i.children && _n(i.children, [i, ...e], t);
3897
3960
  return t;
3898
3961
  }
3899
- async function jn(n, e) {
3900
- const t = e.contextualizationLocale ?? "en", i = ma(
3901
- await Ws(t),
3962
+ async function $n(n, e) {
3963
+ const t = e.contextualizationLocale ?? "en", i = ka(
3964
+ await Ys(t),
3902
3965
  e.contextualization?.contextualizations
3903
3966
  );
3904
3967
  return {
3905
- i18n: fa(t, i),
3906
- contextualizationLanguage: Ks(t),
3968
+ i18n: ba(t, i),
3969
+ contextualizationLanguage: Xs(t),
3907
3970
  skip: new Set(e.skip ?? []),
3908
3971
  contextualize: new Set(e.contextualize ?? []),
3909
3972
  contextualizationShapes: e.contextualization?.shapes ?? {},
@@ -3912,109 +3975,113 @@ async function jn(n, e) {
3912
3975
  inlineContextualization: new Set(e.inlineContextualization ?? []),
3913
3976
  language: e.language ?? "block-level",
3914
3977
  languageOverrides: e.languageOverrides ?? {},
3978
+ contentLanguage: e.contentLanguage,
3915
3979
  segmentation: e.segmentation?.mode ?? "structure",
3916
3980
  // segmentSentences() already applies builtInSuppressions internally
3917
3981
  // (Intl.Segmenter has no built-in equivalent of its own) — this is only
3918
3982
  // the caller's own additive extras, per `SegmentationOptions.suppressions`.
3919
3983
  segmentationSuppressions: e.segmentation?.suppressions ?? {},
3920
- segmenter: e.segmentation?.segmenter ?? aa,
3984
+ segmenter: e.segmentation?.segmenter ?? Bn,
3921
3985
  // Per-key override, not an additive union — each key holds one whole rule.
3922
- substitutions: { ...qs, ...e.substitutions },
3986
+ substitutions: { ...Qs, ...e.substitutions },
3923
3987
  blockStarts: /* @__PURE__ */ new Set(),
3924
3988
  tableRowNumbers: /* @__PURE__ */ new Map(),
3925
3989
  tableCellHeaders: /* @__PURE__ */ new Map(),
3926
3990
  synthetic: /* @__PURE__ */ new Set(),
3927
- ancestorChains: Bn(n),
3991
+ ancestorChains: _n(n),
3928
3992
  pendingRange: /* @__PURE__ */ new Map(),
3929
3993
  edgeSubstitutedLocate: /* @__PURE__ */ new WeakMap(),
3930
3994
  placeholderPieces: /* @__PURE__ */ new Map()
3931
3995
  };
3932
3996
  }
3933
- const va = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
3934
- function Dn(n) {
3935
- return n.replace(va, "$1");
3997
+ const Ca = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
3998
+ function qn(n) {
3999
+ return n.replace(Ca, "$1");
3936
4000
  }
3937
- function j(n, e) {
4001
+ function Gn(n, e) {
3938
4002
  return n === void 0 ? void 0 : nt(e, n) ?? n;
3939
4003
  }
4004
+ function M(n, e) {
4005
+ return Gn(e.language === "none" ? e.contentLanguage : n ?? e.contentLanguage, e.languageOverrides);
4006
+ }
3940
4007
  function ft(n, e) {
3941
4008
  return n === e || n !== void 0 && e !== void 0 && n.toLowerCase() === e.toLowerCase();
3942
4009
  }
3943
4010
  function Qe(n, e) {
3944
- return C(n)[0] === C(e)[0];
4011
+ return k(n)[0] === k(e)[0];
3945
4012
  }
3946
4013
  function Je(n, e, t, i) {
3947
4014
  const { language: s } = e;
3948
- return s === void 0 ? !0 : _n(e, t) ? !i && n.content !== void 0 && !Qe(n.content, s) ? !1 : (n.entry = s, !0) : n.content !== void 0 && !ft(n.content, s) || !i && n.entry !== void 0 && !Qe(s, n.entry) ? !1 : (n.content = s, !0);
4015
+ return s === void 0 ? !0 : Kn(e, t) ? !i && n.content !== void 0 && !Qe(n.content, s) ? !1 : (n.entry = s, !0) : n.content !== void 0 && !ft(n.content, s) || !i && n.entry !== void 0 && !Qe(s, n.entry) ? !1 : (n.content = s, !0);
3949
4016
  }
3950
- function Fn(n, e, t) {
4017
+ function Hn(n, e, t) {
3951
4018
  const i = {};
3952
4019
  for (const s of n)
3953
4020
  if (!Je(i, s, e, t)) return null;
3954
4021
  return i.content ?? i.entry;
3955
4022
  }
3956
- function ya(n, e) {
3957
- return Fn(n, e, !1);
4023
+ function Ea(n, e) {
4024
+ return Hn(n, e, !1);
3958
4025
  }
3959
- function _n(n, e) {
4026
+ function Kn(n, e) {
3960
4027
  return e.synthetic.has(n) && ft(n.language, e.contextualizationLanguage);
3961
4028
  }
3962
- function $n(n, e) {
3963
- return Fn(n, e, e.format === "ssml");
4029
+ function Wn(n, e) {
4030
+ return Hn(n, e, e.format === "ssml");
3964
4031
  }
3965
- function qn(n, e, t) {
4032
+ function Qn(n, e, t) {
3966
4033
  const i = n.ssml ?? "";
3967
- return !e || !n.language || !_n(n, t) || Qe(n.language, e) ? i : `<lang xml:lang="${on(n.language)}">${i}</lang>`;
4034
+ return !e || !n.language || !Kn(n, t) || Qe(n.language, e) ? i : `<lang xml:lang="${ln(n.language)}">${i}</lang>`;
3968
4035
  }
3969
- function Gn(n, e) {
4036
+ function Jn(n, e) {
3970
4037
  const t = e.format === "ssml", i = [];
3971
4038
  let s = 0, a = {};
3972
4039
  return n.forEach((r, o) => {
3973
4040
  Je(a, r, e, t) || (i.push([s, o]), s = o, a = {}, Je(a, r, e, t));
3974
4041
  }), n.length > 0 && i.push([s, n.length]), i;
3975
4042
  }
3976
- function Hn(n, e) {
4043
+ function Zn(n, e) {
3977
4044
  return n.replace(/<lang xml:lang="([^"]*)">/g, (t, i) => {
3978
- const s = j(i, e);
4045
+ const s = Gn(i, e);
3979
4046
  return s === i ? t : `<lang xml:lang="${s}">`;
3980
4047
  });
3981
4048
  }
3982
- function J(n) {
4049
+ function W(n) {
3983
4050
  return n.role ? [...n.role] : [];
3984
4051
  }
3985
4052
  function Ze(n) {
3986
4053
  return n.role?.has("math") ? void 0 : n.text;
3987
4054
  }
3988
- function Le(n) {
4055
+ function Oe(n) {
3989
4056
  const e = n.description?.text;
3990
4057
  if (e)
3991
- return e.plain ?? (e.ssml !== void 0 ? M(e.ssml) : void 0);
4058
+ return e.plain ?? (e.ssml !== void 0 ? N(e.ssml) : void 0);
3992
4059
  }
3993
- function Kn(n) {
4060
+ function Xn(n) {
3994
4061
  return n.description?.text?.language;
3995
4062
  }
3996
- function X(n, e) {
4063
+ function J(n, e) {
3997
4064
  const t = n.cssSelector ?? n.domRange?.start.cssSelector;
3998
4065
  if (!t) return { ...n, text: { highlight: e } };
3999
4066
  const i = { cssSelector: t, text: { highlight: e } };
4000
4067
  return n.href !== void 0 && (i.href = n.href), i;
4001
4068
  }
4002
4069
  function L(n, e) {
4003
- const t = Ct(n);
4070
+ const t = Et(n);
4004
4071
  if (t) return { own: !0, ref: t };
4005
4072
  for (const i of e.get(n) ?? []) {
4006
- const s = Ct(i);
4073
+ const s = Et(i);
4007
4074
  if (s) return { own: !1, ref: s };
4008
4075
  }
4009
4076
  }
4010
4077
  function pt(n, e) {
4011
4078
  if (n)
4012
- return n.own ? n.ref : X(n.ref, e);
4079
+ return n.own ? n.ref : J(n.ref, e);
4013
4080
  }
4014
4081
  function mt(n, e, t) {
4015
- return (n && e ? hi(n.ref, e.ref) : void 0) ?? t;
4082
+ return (n && e ? mi(n.ref, e.ref) : void 0) ?? t;
4016
4083
  }
4017
- function Wn(n, e, t) {
4084
+ function Yn(n, e, t) {
4018
4085
  const { ancestorChains: i } = t, s = /* @__PURE__ */ new Map();
4019
4086
  for (const a of e)
4020
4087
  a && !Array.isArray(a) && s.set(a, (s.get(a) ?? 0) + 1);
@@ -4030,16 +4097,16 @@ function Wn(n, e, t) {
4030
4097
  const g = { ...a, locate: u.ref };
4031
4098
  if (!t.synthetic.has(a)) {
4032
4099
  const d = t.pendingRange.get(a), h = d !== void 0 || c && (s.get(c) ?? 0) > 1;
4033
- g.locate = u.own && !h ? u.ref : X(u.ref, l), g.offsets = [{ start: d?.start ?? 0, end: d?.end ?? l.length, locate: g.locate }];
4100
+ g.locate = u.own && !h ? u.ref : J(u.ref, l), g.offsets = [{ start: d?.start ?? 0, end: d?.end ?? l.length, locate: g.locate }];
4034
4101
  }
4035
4102
  return g;
4036
4103
  });
4037
4104
  }
4038
4105
  function vt(n) {
4039
4106
  const e = st(Ze(n));
4040
- return e ? e.plain ?? (e.ssml ? M(e.ssml) : "") : "";
4107
+ return e ? e.plain ?? (e.ssml ? N(e.ssml) : "") : "";
4041
4108
  }
4042
- function Sa(n) {
4109
+ function Ra(n) {
4043
4110
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
4044
4111
  let i = 0, s;
4045
4112
  return n.forEach((a, r) => {
@@ -4056,159 +4123,152 @@ function Sa(n) {
4056
4123
  });
4057
4124
  }), { lines: n.length, columns: i, rowNumbers: e, cellHeaders: t };
4058
4125
  }
4059
- function Qn(n, e) {
4060
- const t = e.format === "ssml" ? { ssml: z(n) } : { plain: n };
4126
+ function ei(n, e) {
4127
+ const t = e.format === "ssml" ? { ssml: T(n) } : { plain: n };
4061
4128
  return e.synthetic.add(t), t;
4062
4129
  }
4063
- function B(n, e) {
4064
- const t = Qn(n, e);
4065
- return e.language !== "none" && (t.language = e.contextualizationLanguage), t;
4130
+ function D(n, e) {
4131
+ const t = ei(n, e), i = e.language === "none" ? M(void 0, e) : e.contextualizationLanguage;
4132
+ return i && (t.language = i), t;
4066
4133
  }
4067
4134
  function Xe(n, e, t) {
4068
- const i = Qn(n, t);
4069
- if (t.language !== "none") {
4070
- const s = j(Kn(e), t.languageOverrides);
4071
- s && (i.language = s);
4072
- }
4073
- return i;
4135
+ const i = ei(n, t), s = M(Xn(e), t);
4136
+ return s && (i.language = s), i;
4074
4137
  }
4075
- function q(n, e, t, i) {
4138
+ function _(n, e, t, i) {
4076
4139
  n.push(...i);
4077
4140
  for (let s = 0; s < i.length; s++) e.push(t);
4078
4141
  }
4079
4142
  function Ye(n, e, t, i, s, a, r) {
4080
- r ? (s.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), q(n, e, a[0] ?? i, [r])) : (n.push(...s), e.push(...a));
4143
+ r ? (s.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), _(n, e, a[0] ?? i, [r])) : (n.push(...s), e.push(...a));
4081
4144
  }
4082
- function Z(n, e, t, i) {
4145
+ function Q(n, e, t, i) {
4083
4146
  const s = t ? `${e}.${t}` : void 0;
4084
4147
  if (s && n.i18n.exists(s)) return n.i18n.t(s, i);
4085
4148
  if (n.i18n.exists(e)) return n.i18n.t(e, i);
4086
4149
  }
4087
4150
  function yt(n, e) {
4088
- return Nn.has(n) ? !0 : e.contextualize.has(n);
4151
+ return Dn.has(n) ? !0 : e.contextualize.has(n);
4089
4152
  }
4090
- function Jn(n, e, t) {
4153
+ function ti(n, e, t) {
4091
4154
  return e.some((i) => {
4092
- const s = oa[i];
4155
+ const s = ga[i];
4093
4156
  return s?.drops.includes(n) ? s.unconditional || yt(i, t) : !1;
4094
4157
  });
4095
4158
  }
4096
- function le(n, e, t, i, s) {
4159
+ function ce(n, e, t, i, s) {
4097
4160
  const a = e.lastIndexOf(t);
4098
4161
  if (a === -1) return;
4099
4162
  const r = L(i, s.ancestorChains);
4100
4163
  if (!r) return;
4101
- const o = X(r.ref, t);
4164
+ const o = J(r.ref, t);
4102
4165
  n.offsets = [{ start: a, end: a + t.length, locate: o }], n.locate = r.own ? r.ref : o;
4103
4166
  }
4104
4167
  function Me(n, e, t, i, s, a) {
4105
4168
  const r = a?.value;
4106
4169
  if (r !== void 0 && r === vt(t)) {
4107
- if (i.language !== "none") {
4108
- const l = j(t.text?.language, i.languageOverrides);
4109
- l && (n.language = l);
4110
- }
4111
- i.synthetic.delete(n), le(n, e, r, t, i);
4170
+ const l = M(t.text?.language, i);
4171
+ l && (n.language = l), i.synthetic.delete(n), ce(n, e, r, t, i);
4112
4172
  return;
4113
4173
  }
4114
4174
  const o = a?.description;
4115
- o !== void 0 && o === Le(t) && (s === "figure" || s === "table") && le(n, e, o, t, i);
4175
+ o !== void 0 && o === Oe(t) && (s === "figure" || s === "table") && ce(n, e, o, t, i);
4116
4176
  }
4117
- function qt(n, e, t, i, s, a, r, o) {
4177
+ function Gt(n, e, t, i, s, a, r, o) {
4118
4178
  if (!yt(s, i)) return;
4119
4179
  if ((i.i18n.exists(`${s}.block.start`) || i.i18n.exists(`${s}.block.end`)) && i.contextualizationShapes[s] !== "inline") {
4120
4180
  const c = a === "before" ? `${s}.block.start` : `${s}.block.end`;
4121
- q(n, e, t, Ht(c, r, o, t, s, i));
4181
+ _(n, e, t, Kt(c, r, o, t, s, i));
4122
4182
  return;
4123
4183
  }
4124
- a === "before" && q(n, e, t, Ht(`${s}.inline`, r, o, t, s, i));
4184
+ a === "before" && _(n, e, t, Kt(`${s}.inline`, r, o, t, s, i));
4125
4185
  }
4126
- const Gt = "\0";
4127
- function Ht(n, e, t, i, s, a) {
4128
- const r = Z(a, n, e, t);
4186
+ const Ht = "\0";
4187
+ function Kt(n, e, t, i, s, a) {
4188
+ const r = Q(a, n, e, t);
4129
4189
  if (!r) return [];
4130
- const o = t?.description, l = a.language !== "none" && o !== void 0 && o === Le(i) ? j(Kn(i), a.languageOverrides) : void 0, c = l ? Z(a, n, e, { ...t, description: Gt })?.split(Gt) : void 0;
4190
+ const o = t?.description, l = a.language !== "none" && o !== void 0 && o === Oe(i) ? M(Xn(i), a) : void 0, c = l ? Q(a, n, e, { ...t, description: Ht })?.split(Ht) : void 0;
4131
4191
  if (!l || !c || c.length < 2) {
4132
- const d = B(r, a);
4192
+ const d = D(r, a);
4133
4193
  return Me(d, r, i, a, s, t), [d];
4134
4194
  }
4135
- if (C(l)[0] === C(a.contextualizationLanguage)[0]) {
4136
- const d = B(r, a);
4195
+ if (k(l)[0] === k(a.contextualizationLanguage)[0]) {
4196
+ const d = D(r, a);
4137
4197
  return d.language = l, Me(d, r, i, a, s, t), [d];
4138
4198
  }
4139
- const u = `<lang xml:lang="${on(l)}">${z(o)}</lang>`, g = c.map((d) => z(d)).join(u);
4199
+ const u = `<lang xml:lang="${ln(l)}">${T(o)}</lang>`, g = c.map((d) => T(d)).join(u);
4140
4200
  if (a.format === "ssml") {
4141
- const d = B(r, a);
4201
+ const d = D(r, a);
4142
4202
  return d.ssml = g, Me(d, r, i, a, s, t), [d];
4143
4203
  }
4144
4204
  return at(g, a.contextualizationLanguage).map((d) => {
4145
- if (d.language !== l) return B(d.plain, a);
4205
+ if (d.language !== l) return D(d.plain, a);
4146
4206
  const h = Xe(d.plain, i, a);
4147
- return (s === "figure" || s === "table") && le(h, d.plain, o, i, a), h;
4207
+ return (s === "figure" || s === "table") && ce(h, d.plain, o, i, a), h;
4148
4208
  });
4149
4209
  }
4150
- function Kt(n, e, t, i) {
4210
+ function Wt(n, e, t, i) {
4151
4211
  const s = `${e}.parts.${t}`;
4152
4212
  return n.i18n.exists(s, { count: i }) ? n.i18n.t(s, { count: i }) : String(i);
4153
4213
  }
4154
- function ba(n) {
4155
- const e = Le(n);
4214
+ function Ia(n) {
4215
+ const e = Oe(n);
4156
4216
  return e === void 0 ? { variantKey: "unlabelled" } : { variantKey: "labelled", params: { description: e } };
4157
4217
  }
4158
- function Wt(n, e) {
4218
+ function Qt(n, e) {
4159
4219
  const t = e.tableCellHeaders.get(n);
4160
4220
  return {
4161
4221
  variantKey: t !== void 0 ? "withHeader" : "withoutHeader",
4162
4222
  params: { header: t ?? "", value: vt(n) }
4163
4223
  };
4164
4224
  }
4165
- const wa = {
4225
+ const Pa = {
4166
4226
  table: (n, e) => {
4167
- const t = (n.children ?? []).filter((s) => s.role?.has("row")), i = Sa(t);
4227
+ const t = (n.children ?? []).filter((s) => s.role?.has("row")), i = Ra(t);
4168
4228
  for (const [s, a] of i.rowNumbers) e.tableRowNumbers.set(s, a);
4169
4229
  for (const [s, a] of i.cellHeaders) e.tableCellHeaders.set(s, a);
4170
4230
  return {
4171
4231
  params: {
4172
- lines: Kt(e, "table", "lines", i.lines),
4173
- columns: Kt(e, "table", "columns", i.columns)
4232
+ lines: Wt(e, "table", "lines", i.lines),
4233
+ columns: Wt(e, "table", "columns", i.columns)
4174
4234
  }
4175
4235
  };
4176
4236
  },
4177
4237
  row: (n, e) => ({ params: { count: String(e.tableRowNumbers.get(n) ?? "") } }),
4178
- cell: Wt,
4179
- rowheader: Wt
4238
+ cell: Qt,
4239
+ rowheader: Qt
4180
4240
  };
4181
- function Qt(n, e, t) {
4182
- const i = ba(e);
4241
+ function Jt(n, e, t) {
4242
+ const i = Ia(e);
4183
4243
  let s = i.variantKey, a = i.params;
4184
- const r = wa[n]?.(e, t);
4244
+ const r = Pa[n]?.(e, t);
4185
4245
  r && (r.variantKey && (s = r.variantKey), a = { ...a, ...r.params });
4186
4246
  const o = t.contextualizationParams?.(n, e);
4187
4247
  return o && (a = { ...a, ...o }), { variantKey: s, params: a };
4188
4248
  }
4189
- function ke(n, e = n) {
4249
+ function Ee(n, e = n) {
4190
4250
  let t = "", i = "";
4191
4251
  const s = [];
4192
4252
  return n.forEach((a, r) => {
4193
4253
  const o = e[r];
4194
- if (o.length === 1 && qi(o) && i.endsWith(o)) {
4254
+ if (o.length === 1 && Qi(o) && i.endsWith(o)) {
4195
4255
  s.push({ start: t.length, end: t.length });
4196
4256
  return;
4197
4257
  }
4198
- i && !ue(o) && !/\s$/.test(i) && !/^\s/.test(o) && (t += " ", i += " ");
4258
+ i && !he(o) && !/\s$/.test(i) && !/^\s/.test(o) && (t += " ", i += " ");
4199
4259
  const l = t.length;
4200
4260
  t += a, i += o, s.push({ start: l, end: t.length });
4201
4261
  }), { joined: t, ranges: s };
4202
4262
  }
4203
- function Oe(n, e) {
4204
- const t = di(n), i = L(n, e.ancestorChains)?.ref;
4263
+ function Ve(n, e) {
4264
+ const t = vi(n), i = L(n, e.ancestorChains)?.ref;
4205
4265
  if (t) {
4206
4266
  const s = { cssSelector: t };
4207
- return i?.href !== void 0 && (s.href = i.href), Ft(s);
4267
+ return i?.href !== void 0 && (s.href = i.href), _t(s);
4208
4268
  }
4209
- return i && Ft(i);
4269
+ return i && _t(i);
4210
4270
  }
4211
- function Zn(n, e, t) {
4271
+ function ni(n, e, t) {
4212
4272
  const i = [];
4213
4273
  return n.forEach((s, a) => {
4214
4274
  if (s.offsets) {
@@ -4222,17 +4282,17 @@ function Zn(n, e, t) {
4222
4282
  if (!o) return;
4223
4283
  const l = t.format === "ssml" ? s.ssml : s.plain;
4224
4284
  if (!l) return;
4225
- const c = t.pendingRange.get(s), u = he(r) ? Oe(r, t) ?? o.ref : X(o.ref, l);
4285
+ const c = t.pendingRange.get(s), u = de(r) ? Ve(r, t) ?? o.ref : J(o.ref, l);
4226
4286
  i.push({ start: c?.start ?? 0, end: c?.end ?? l.length, locate: u });
4227
4287
  }), i;
4228
4288
  }
4229
- function Jt(n, e, t, i) {
4289
+ function Zt(n, e, t, i) {
4230
4290
  const s = i.edgeSubstitutedLocate.get(n);
4231
4291
  if (s) return s[t];
4232
- if (!(!e || Array.isArray(e) || !he(e)))
4233
- return Oe(e, i);
4292
+ if (!(!e || Array.isArray(e) || !de(e)))
4293
+ return Ve(e, i);
4234
4294
  }
4235
- function ka(n, e, t) {
4295
+ function Aa(n, e, t) {
4236
4296
  const i = n.map((l, c) => {
4237
4297
  if (l.locate) return l.locate;
4238
4298
  if (t.synthetic.has(l)) return;
@@ -4240,7 +4300,7 @@ function ka(n, e, t) {
4240
4300
  if (!u || Array.isArray(u)) return;
4241
4301
  const g = t.format === "ssml" ? l.ssml : l.plain;
4242
4302
  if (g)
4243
- return he(u) ? L(u, t.ancestorChains) && Oe(u, t) : pt(L(u, t.ancestorChains), g);
4303
+ return de(u) ? L(u, t.ancestorChains) && Ve(u, t) : pt(L(u, t.ancestorChains), g);
4244
4304
  }), s = i.findIndex((l) => l !== void 0);
4245
4305
  if (s === -1) return;
4246
4306
  let a = i.length - 1;
@@ -4260,30 +4320,30 @@ function St(n, e, t) {
4260
4320
  p && (i.push(p), s.push(f), a.push(e[h]));
4261
4321
  }
4262
4322
  if (i.length === 0) return;
4263
- const r = $n(s, t);
4323
+ const r = Wn(s, t);
4264
4324
  if (r === null) return;
4265
- const { joined: o } = ke(t.format === "ssml" ? s.map((h) => qn(h, r, t)) : i), l = t.format === "ssml" ? { ssml: o } : { plain: o };
4325
+ const { joined: o } = Ee(t.format === "ssml" ? s.map((h) => Qn(h, r, t)) : i), l = t.format === "ssml" ? { ssml: o } : { plain: o };
4266
4326
  r && (l.language = r), n.some((h) => t.synthetic.has(h)) && t.synthetic.add(l);
4267
- const c = Zn(s, a, t);
4327
+ const c = ni(s, a, t);
4268
4328
  c.length > 0 && (l.offsets = c);
4269
- const u = ka(s, a, t);
4329
+ const u = Aa(s, a, t);
4270
4330
  u && (l.locate = u);
4271
- const g = Jt(s[0], a[0], "leading", t), d = Jt(s[s.length - 1], a[s.length - 1], "trailing", t);
4331
+ const g = Zt(s[0], a[0], "leading", t), d = Zt(s[s.length - 1], a[s.length - 1], "trailing", t);
4272
4332
  return (g || d) && t.edgeSubstitutedLocate.set(l, { leading: g, trailing: d }), l;
4273
4333
  }
4274
- function Xn(n, e, t, i) {
4275
- if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && Sn(n.ssml))
4334
+ function ii(n, e, t, i) {
4335
+ if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && wn(n.ssml))
4276
4336
  return at(n.ssml, n.language).map((r) => {
4277
- const o = { plain: r.plain }, l = j(r.language, i.languageOverrides);
4337
+ const o = { plain: r.plain }, l = M(r.language, i);
4278
4338
  return l && (o.language = l), i.pendingRange.set(o, { start: r.start, end: r.end }), o;
4279
4339
  });
4280
- const s = {}, a = j(n.language, i.languageOverrides);
4281
- return a && (s.language = a), e === "ssml" ? s.ssml = n.ssml ? Hn(n.ssml, i.languageOverrides) : z(n.plain ?? "") : s.plain = n.plain ?? M(n.ssml ?? ""), (t === "block-level" || t === "none") && (s.ssml && (s.ssml = Dn(s.ssml)), t === "none" && delete s.language), [s];
4340
+ const s = {}, a = M(n.language, i);
4341
+ return a && (s.language = a), e === "ssml" ? s.ssml = n.ssml ? Zn(n.ssml, i.languageOverrides) : T(n.plain ?? "") : s.plain = n.plain ?? N(n.ssml ?? ""), (t === "block-level" || t === "none") && s.ssml && (s.ssml = qn(s.ssml)), [s];
4282
4342
  }
4283
- function de(n, e) {
4343
+ function ge(n, e) {
4284
4344
  return e !== "ssml" ? n : n.replace(/<[^>]+>/g, "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
4285
4345
  }
4286
- const Zt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Ca = "[\\u0374\\u02B9\\u0384']", Be = "[\\u05D0-\\u05EA]", Xt = "[\\u0400-\\u0481\\u048A-\\u04FF]", Ea = [
4346
+ const Xt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", La = "[\\u0374\\u02B9\\u0384']", Be = "[\\u05D0-\\u05EA]", Yt = "[\\u0400-\\u0481\\u048A-\\u04FF]", Oa = [
4287
4347
  new RegExp("^\\p{Nd}+$", "u"),
4288
4348
  new RegExp("^\\p{Nl}+$", "u"),
4289
4349
  /^(?=[MDCLXVI])M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i,
@@ -4291,151 +4351,151 @@ const Zt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Ca = "[\\u0374\\u0
4291
4351
  /^[፩-፼]+$/u,
4292
4352
  new RegExp(`^${Be}[\\u05F3']$`, "u"),
4293
4353
  new RegExp(`^${Be}+[\\u05F4"]${Be}$`, "u"),
4294
- new RegExp(`^(?:\\u0375${Zt})*${Zt}+${Ca}$`, "u"),
4354
+ new RegExp(`^(?:\\u0375${Xt})*${Xt}+${La}$`, "u"),
4295
4355
  /^(?:[Ա-Ֆա-և]̅)+$/u,
4296
- new RegExp(`^\\u0482?${Xt}+\\u0483${Xt}*$`, "u")
4356
+ new RegExp(`^\\u0482?${Yt}+\\u0483${Yt}*$`, "u")
4297
4357
  ];
4298
- function Ra(n) {
4358
+ function Va(n) {
4299
4359
  const e = n.trim();
4300
- return e.length > 0 && Ea.some((t) => t.test(e));
4360
+ return e.length > 0 && Oa.some((t) => t.test(e));
4301
4361
  }
4302
- function Yt(n, e) {
4303
- return e.skip.size > 0 && n.some((t) => e.skip.has(t) && !Jn(t, n, e));
4362
+ function en(n, e) {
4363
+ return e.skip.size > 0 && n.some((t) => e.skip.has(t) && !ti(t, n, e));
4304
4364
  }
4305
- function Ia(n, e) {
4365
+ function xa(n, e) {
4306
4366
  const t = st(n.text);
4307
4367
  if (!t) return [];
4308
- const i = t.plain ?? M(t.ssml ?? "");
4309
- if (Ra(i)) {
4310
- const s = Z(e, "pagebreak.number", void 0, { number: i.trim() });
4311
- if (s !== void 0) return [B(s, e)];
4368
+ const i = t.plain ?? N(t.ssml ?? "");
4369
+ if (Va(i)) {
4370
+ const s = Q(e, "pagebreak.number", void 0, { number: i.trim() });
4371
+ if (s !== void 0) return [D(s, e)];
4312
4372
  }
4313
- return Xn(t, e.format, e.language, e);
4373
+ return ii(t, e.format, e.language, e);
4314
4374
  }
4315
- function en(n) {
4375
+ function tn(n) {
4316
4376
  n.plain !== void 0 && (n.plain += "."), n.ssml !== void 0 && (n.ssml += ".");
4317
4377
  }
4318
- function Pa(n, e) {
4319
- const t = Ia(n, e);
4378
+ function Ua(n, e) {
4379
+ const t = xa(n, e);
4320
4380
  if (!e.contextualize.has("pagebreak")) return t;
4321
- const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", s = Z(e, i);
4381
+ const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", s = Q(e, i);
4322
4382
  if (s === void 0) return t;
4323
- const a = B(s, e);
4383
+ const a = D(s, e);
4324
4384
  if (t.length === 0) return [a];
4325
4385
  const r = St([a, ...t], [void 0, ...t.map(() => n)], e);
4326
- return r ? (en(r), [r]) : (en(t[t.length - 1]), [a, ...t]);
4386
+ return r ? (tn(r), [r]) : (tn(t[t.length - 1]), [a, ...t]);
4327
4387
  }
4328
- function Aa(n, e) {
4329
- return J(n).some((t) => zn.has(t) && !e.inlineContextualization.has(t));
4388
+ function Ta(n, e) {
4389
+ return W(n).some((t) => jn.has(t) && !e.inlineContextualization.has(t));
4330
4390
  }
4331
- function La(n, e, t, i, s, a, r) {
4332
- const o = n.text?.language, l = j(o, s.languageOverrides), c = new Map((n.children ?? []).map((m) => [m.id, m])), u = [], g = [], d = [], h = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = s.segmentation === "sentence";
4333
- for (const m of os(e)) {
4391
+ function za(n, e, t, i, s, a, r) {
4392
+ const o = n.text?.language, l = M(o, s), c = new Map((n.children ?? []).map((m) => [m.id, m])), u = [], g = [], d = [], h = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = s.segmentation === "sentence";
4393
+ for (const m of ds(e)) {
4334
4394
  if (m.placeholderId !== void 0) {
4335
4395
  const v = c.get(m.placeholderId);
4336
4396
  if (!v) continue;
4337
- if (Aa(v, s)) {
4397
+ if (Ta(v, s)) {
4338
4398
  if (d.push(v), p) {
4339
4399
  const w = u.length;
4340
4400
  et(v, u, g, s, d.length === 1 && (a || r)), u.slice(w).forEach((y) => f.add(y));
4341
4401
  }
4342
4402
  } else {
4343
4403
  const w = u.length;
4344
- et(v, u, g, s, a), J(v).some((y) => zn.has(y)) && u.slice(w).forEach((y) => h.add(y));
4404
+ et(v, u, g, s, a), W(v).some((y) => jn.has(y)) && u.slice(w).forEach((y) => h.add(y));
4345
4405
  }
4346
4406
  continue;
4347
4407
  }
4348
4408
  if (!m.ssml) continue;
4349
- if (s.format === "plain" && s.language !== "block-level" && s.language !== "none" && Sn(m.ssml)) {
4409
+ if (s.format === "plain" && s.language !== "block-level" && s.language !== "none" && wn(m.ssml)) {
4350
4410
  for (const v of at(m.ssml, o)) {
4351
- const w = { plain: v.plain }, y = j(v.language, s.languageOverrides);
4411
+ const w = { plain: v.plain }, y = M(v.language, s);
4352
4412
  y && (w.language = y), u.push(w), g.push(n);
4353
4413
  }
4354
4414
  continue;
4355
4415
  }
4356
4416
  const S = {};
4357
- l && (S.language = l), s.format === "ssml" ? S.ssml = Hn(m.ssml, s.languageOverrides) : S.plain = M(m.ssml), (s.language === "block-level" || s.language === "none") && (S.ssml && (S.ssml = Dn(S.ssml)), s.language === "none" && delete S.language), u.push(S), g.push(n);
4417
+ l && (S.language = l), s.format === "ssml" ? S.ssml = Zn(m.ssml, s.languageOverrides) : S.plain = N(m.ssml), (s.language === "block-level" || s.language === "none") && S.ssml && (S.ssml = qn(S.ssml)), u.push(S), g.push(n);
4358
4418
  }
4359
4419
  if (p && d.length + h.size > 0)
4360
4420
  return u.forEach((m) => {
4361
4421
  const S = h.has(m) ? "inline" : f.has(m) ? "after" : void 0;
4362
4422
  s.placeholderPieces.set(m, { node: n, placement: S });
4363
4423
  }), Ye(t, i, s, n, u, g, void 0), [];
4364
- for (const [m, S] of Gn(u, s)) {
4424
+ for (const [m, S] of Jn(u, s)) {
4365
4425
  const v = u.slice(m, S), w = g.slice(m, S), y = v.length > 1 ? St(v, w, s) : void 0;
4366
4426
  Ye(t, i, s, n, v, w, y);
4367
4427
  }
4368
4428
  return d;
4369
4429
  }
4370
4430
  function et(n, e, t, i, s) {
4371
- const a = J(n), r = Le(n);
4372
- if (Yt(a, i)) return;
4373
- const o = a.some((h) => $t.has(h)), l = o && !s, c = e.length, u = a.filter(
4374
- (h) => h !== "footnote" && h !== "pagebreak" && !Jn(h, a, i)
4375
- ), g = a.some((h) => da.has(h) && i.contextualize.has(h)), d = a.includes("table") && r !== void 0 && !g;
4431
+ const a = W(n), r = Oe(n);
4432
+ if (en(a, i)) return;
4433
+ const o = a.some((h) => qt.has(h)), l = o && !s, c = e.length, u = a.filter(
4434
+ (h) => h !== "footnote" && h !== "pagebreak" && !ti(h, a, i)
4435
+ ), g = a.some((h) => ya.has(h) && i.contextualize.has(h)), d = a.includes("table") && r !== void 0 && !g;
4376
4436
  if (d) {
4377
4437
  const h = Xe(r, n, i);
4378
- le(h, r, r, n, i), q(e, t, n, [h]);
4438
+ ce(h, r, r, n, i), _(e, t, n, [h]);
4379
4439
  }
4380
4440
  for (const h of u) {
4381
4441
  if (h === "figure" && r === void 0) continue;
4382
- const { variantKey: f, params: p } = Qt(h, n, i);
4383
- qt(e, t, n, i, h, "before", f, p);
4442
+ const { variantKey: f, params: p } = Jt(h, n, i);
4443
+ Gt(e, t, n, i, h, "before", f, p);
4384
4444
  }
4385
4445
  if (a.includes("noteref"))
4386
4446
  for (const h of n.children ?? []) {
4387
- const f = J(h);
4388
- if (!Yt(f, i))
4447
+ const f = W(h);
4448
+ if (!en(f, i))
4389
4449
  if (f.includes("footnote")) {
4390
- const p = i.contextualize.has("footnote"), m = i.i18n.exists("footnote.block.start") || i.i18n.exists("footnote.block.end"), S = f.some((I) => $t.has(I)) && !s && !i.inlineContextualization.has("noteref"), v = p ? Z(i, m ? "footnote.block.start" : "footnote.inline") : void 0, w = p && (v !== void 0 || m), y = [], b = [];
4391
- v !== void 0 && (y.push(B(v, i)), b.push(h));
4450
+ const p = i.contextualize.has("footnote"), m = i.i18n.exists("footnote.block.start") || i.i18n.exists("footnote.block.end"), S = f.some((I) => qt.has(I)) && !s && !i.inlineContextualization.has("noteref"), v = p ? Q(i, m ? "footnote.block.start" : "footnote.inline") : void 0, w = p && (v !== void 0 || m), y = [], b = [];
4451
+ v !== void 0 && (y.push(D(v, i)), b.push(h));
4392
4452
  const P = [], A = [];
4393
- if ($([h], P, A, i, s || S), S && P.length > 0 && i.blockStarts.add(P[0]), y.push(...P), b.push(...A), w && m) {
4394
- const I = Z(i, "footnote.block.end");
4395
- I !== void 0 && (y.push(B(I, i)), b.push(h));
4453
+ if (F([h], P, A, i, s || S), S && P.length > 0 && i.blockStarts.add(P[0]), y.push(...P), b.push(...A), w && m) {
4454
+ const I = Q(i, "footnote.block.end");
4455
+ I !== void 0 && (y.push(D(I, i)), b.push(h));
4396
4456
  }
4397
4457
  const E = w && y.length > 1 ? St(y, b, i) : void 0;
4398
4458
  Ye(e, t, i, h, y, b, E);
4399
4459
  } else
4400
- $([h], e, t, i, s);
4460
+ F([h], e, t, i, s);
4401
4461
  }
4402
- else if (!a.some((h) => ga.has(h))) {
4462
+ else if (!a.some((h) => Sa.has(h))) {
4403
4463
  const h = Ze(n)?.ssml;
4404
- if (h && rs(h)) {
4405
- const f = La(n, h, e, t, i, s, o);
4464
+ if (h && hs(h)) {
4465
+ const f = za(n, h, e, t, i, s, o);
4406
4466
  if (f.length > 0) {
4407
4467
  const p = s || o && e.length > c;
4408
- $(f, e, t, i, p);
4468
+ F(f, e, t, i, p);
4409
4469
  }
4410
4470
  } else if (a.includes("pagebreak")) {
4411
- if (q(e, t, n, Pa(n, i)), n.children) {
4471
+ if (_(e, t, n, Ua(n, i)), n.children) {
4412
4472
  const f = s || o && e.length > c;
4413
- $(n.children, e, t, i, f);
4473
+ F(n.children, e, t, i, f);
4414
4474
  }
4415
4475
  } else {
4416
- const p = a.some((m) => Nn.has(m) && yt(m, i)) ? void 0 : st(Ze(n));
4417
- if (p && q(e, t, n, Xn(p, i.format, i.language, i)), n.children) {
4476
+ const p = a.some((m) => Dn.has(m) && yt(m, i)) ? void 0 : st(Ze(n));
4477
+ if (p && _(e, t, n, ii(p, i.format, i.language, i)), n.children) {
4418
4478
  const m = s || o && e.length > c;
4419
- $(n.children, e, t, i, m);
4479
+ F(n.children, e, t, i, m);
4420
4480
  }
4421
4481
  }
4422
4482
  }
4423
4483
  if (l && e.length > c && i.blockStarts.add(e[c]), r !== void 0 && !g && !d) {
4424
4484
  const h = Xe(r, n, i);
4425
- a.includes("figure") && le(h, r, r, n, i), q(e, t, n, [h]);
4485
+ a.includes("figure") && ce(h, r, r, n, i), _(e, t, n, [h]);
4426
4486
  }
4427
4487
  for (const h of u) {
4428
4488
  if (h === "figure" && r === void 0) continue;
4429
- const { variantKey: f, params: p } = Qt(h, n, i);
4430
- qt(e, t, n, i, h, "after", f, p);
4489
+ const { variantKey: f, params: p } = Jt(h, n, i);
4490
+ Gt(e, t, n, i, h, "after", f, p);
4431
4491
  }
4432
4492
  }
4433
- function $(n, e, t, i, s) {
4493
+ function F(n, e, t, i, s) {
4434
4494
  n.forEach((a, r) => et(a, e, t, i, r === 0 ? s : !1));
4435
4495
  }
4436
- const Oa = vn;
4437
- async function Yn(n, e, t, i) {
4438
- const s = Oa(n);
4496
+ const Na = Sn;
4497
+ async function si(n, e, t, i) {
4498
+ const s = Na(n);
4439
4499
  let a = "";
4440
4500
  const r = [];
4441
4501
  for (const d of s)
@@ -4452,7 +4512,7 @@ async function Yn(n, e, t, i) {
4452
4512
  const S = o[u], v = Math.min(m, S.end), w = v >= S.end && u < o.length - 1;
4453
4513
  let y = d.slice(p - h, v - h);
4454
4514
  w && (y = y.replace(/[ \t\r\n]+$/, ""));
4455
- const b = z(y);
4515
+ const b = T(y);
4456
4516
  c += f ? f(b) : b, p = v, w && (l.push(c), c = "", u++);
4457
4517
  }
4458
4518
  }
@@ -4467,17 +4527,21 @@ async function Yn(n, e, t, i) {
4467
4527
  }
4468
4528
  }), c && l.push(c.replace(/[ \t\r\n]+$/, "")), l;
4469
4529
  }
4470
- async function xa(n, e) {
4471
- const t = n.language ?? "en", i = Ce(e.segmentationSuppressions, t), s = e.format === "ssml" ? n.ssml : n.plain;
4530
+ function bt(n, e) {
4531
+ const t = e.segmenter === Bn ? ha(n) : n;
4532
+ return cn(e.segmentationSuppressions, t);
4533
+ }
4534
+ async function Ma(n, e) {
4535
+ const t = n.language ?? "en", i = bt(t, e), s = e.format === "ssml" ? n.ssml : n.plain;
4472
4536
  if (!s) return;
4473
- const a = await e.segmenter(t, de(s, e.format), i);
4537
+ const a = await e.segmenter(t, ge(s, e.format), i);
4474
4538
  if (a.length <= 1) return;
4475
4539
  if (e.format !== "ssml") return a.map((o) => ({ text: o.text, start: o.start, end: o.contentEnd }));
4476
- const r = await Yn(s, t, e.segmenter, i);
4540
+ const r = await si(s, t, e.segmenter, i);
4477
4541
  if (r)
4478
4542
  return a.map((o, l) => ({ text: r[l], start: o.start, end: o.contentEnd }));
4479
4543
  }
4480
- const tn = /* @__PURE__ */ new Set([
4544
+ const nn = /* @__PURE__ */ new Set([
4481
4545
  "cell",
4482
4546
  "rowheader",
4483
4547
  "columnheader",
@@ -4492,26 +4556,26 @@ const tn = /* @__PURE__ */ new Set([
4492
4556
  "heading5",
4493
4557
  "heading6"
4494
4558
  ]);
4495
- function nn(n) {
4496
- return n ? J(Array.isArray(n) ? n[1] : n) : [];
4559
+ function sn(n) {
4560
+ return n ? W(Array.isArray(n) ? n[1] : n) : [];
4497
4561
  }
4498
- function sn(n, e, t) {
4562
+ function an(n, e, t) {
4499
4563
  const i = Array.isArray(n) ? n[e === "leading" ? 0 : 1] : n;
4500
- return (t.ancestorChains.get(i) ?? []).filter((s) => J(s).some((a) => a !== "presentation"));
4564
+ return (t.ancestorChains.get(i) ?? []).filter((s) => W(s).some((a) => a !== "presentation"));
4501
4565
  }
4502
- function Va(n, e) {
4566
+ function Ba(n, e) {
4503
4567
  return n.length === e.length && n.every((t, i) => t === e[i]);
4504
4568
  }
4505
- function an(n, e, t, i) {
4506
- return i.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && he(n);
4569
+ function rn(n, e, t, i) {
4570
+ return i.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && de(n);
4507
4571
  }
4508
- function Y(n, e) {
4572
+ function Z(n, e) {
4509
4573
  return e.placeholderPieces.get(n)?.placement === "inline";
4510
4574
  }
4511
- function Ua(n, e) {
4575
+ function ja(n, e) {
4512
4576
  return e.placeholderPieces.get(n)?.placement === "after";
4513
4577
  }
4514
- function ei(n, e, t, i) {
4578
+ function ai(n, e, t, i) {
4515
4579
  for (const { piece: s, source: a } of n.get(e) ?? [])
4516
4580
  t.push(s), i.push(a);
4517
4581
  n.delete(e);
@@ -4520,53 +4584,53 @@ function tt(n, e, t) {
4520
4584
  const i = t.placeholderPieces.get(n)?.node;
4521
4585
  return i !== void 0 && i === t.placeholderPieces.get(e)?.node;
4522
4586
  }
4523
- function Ta(n, e, t, i, s) {
4587
+ function Da(n, e, t, i, s) {
4524
4588
  const a = s.format === "ssml" ? n.ssml : n.plain, r = s.format === "ssml" ? t.ssml : t.plain;
4525
- return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || nn(e).some((o) => tn.has(o)) || nn(i).some((o) => tn.has(o)) || !Va(sn(e, "trailing", s), sn(i, "leading", s)) || an(e, n, "trailing", s) || an(i, t, "leading", s));
4589
+ return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || sn(e).some((o) => nn.has(o)) || sn(i).some((o) => nn.has(o)) || !Ba(an(e, "trailing", s), an(i, "leading", s)) || rn(e, n, "trailing", s) || rn(i, t, "leading", s));
4526
4590
  }
4527
- async function rn(n, e, t, i, s) {
4528
- const a = t.synthetic.has(n) ? void 0 : await xa(n, t);
4591
+ async function on(n, e, t, i, s) {
4592
+ const a = t.synthetic.has(n) ? void 0 : await Ma(n, t);
4529
4593
  if (!a) {
4530
4594
  i.push(n), s.push(e);
4531
4595
  return;
4532
4596
  }
4533
4597
  const r = t.blockStarts.has(n);
4534
4598
  r && t.blockStarts.delete(n);
4535
- const o = Array.isArray(e) ? void 0 : e, l = o ? L(o, t.ancestorChains) : void 0, c = o && he(o) ? Oe(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4599
+ const o = Array.isArray(e) ? void 0 : e, l = o ? L(o, t.ancestorChains) : void 0, c = o && de(o) ? Ve(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
4536
4600
  a.forEach(({ text: g, start: d, end: h }, f) => {
4537
4601
  const p = { ...n, [t.format]: g }, m = (f === 0 ? u?.leading : void 0) ?? (f === a.length - 1 ? u?.trailing : void 0) ?? c;
4538
4602
  if (m && l)
4539
4603
  p.locate = m, p.offsets = [{ start: d, end: h, locate: m }];
4540
4604
  else if (l) {
4541
- const S = t.format === "ssml" ? de(g, t.format) : g, v = X(l.ref, S);
4605
+ const S = t.format === "ssml" ? ge(g, t.format) : g, v = J(l.ref, S);
4542
4606
  p.locate = v, p.offsets = [{ start: d, end: h, locate: v }];
4543
4607
  }
4544
4608
  r && f === 0 && t.blockStarts.add(p), i.push(p), s.push(e);
4545
4609
  });
4546
4610
  }
4547
- function ce(n, e) {
4611
+ function ue(n, e) {
4548
4612
  let t = 0;
4549
4613
  for (; t < n.length - 1 && n[t + 1].start <= e; ) t++;
4550
4614
  return t;
4551
4615
  }
4552
- async function za(n, e, t, i) {
4553
- const s = n.map((c) => de(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = ke(s), o = await e.segmenter(t, a, i), l = new Array(n.length - 1).fill(!1);
4616
+ async function Fa(n, e, t, i) {
4617
+ const s = n.map((c) => ge(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = Ee(s), o = await e.segmenter(t, a, i), l = new Array(n.length - 1).fill(!1);
4554
4618
  for (const c of o) {
4555
- const u = ce(r, c.start), g = c.end > c.start ? ce(r, c.end - 1) : u;
4619
+ const u = ue(r, c.start), g = c.end > c.start ? ue(r, c.end - 1) : u;
4556
4620
  for (let d = u; d < g; d++) l[d] = !0;
4557
4621
  }
4558
4622
  return l;
4559
4623
  }
4560
- function Na(n, e, t) {
4624
+ function _a(n, e, t) {
4561
4625
  const i = [...e];
4562
4626
  return n.forEach((s, a) => {
4563
- if (!Y(s, t)) return;
4627
+ if (!Z(s, t)) return;
4564
4628
  const r = a > 0 && tt(n[a - 1], s, t), o = a < n.length - 1 && tt(s, n[a + 1], t);
4565
4629
  r && !i[a - 1] ? i[a - 1] = !0 : o && (i[a] = !0);
4566
4630
  }), i;
4567
4631
  }
4568
- function Ma(n, e, t, i, s) {
4569
- const a = (l) => Y(t[ce(i, l)], s), r = [];
4632
+ function $a(n, e, t, i, s) {
4633
+ const a = (l) => Z(t[ue(i, l)], s), r = [];
4570
4634
  let o;
4571
4635
  return e.forEach((l, c) => {
4572
4636
  o ??= l;
@@ -4574,75 +4638,75 @@ function Ma(n, e, t, i, s) {
4574
4638
  u && (a(l.contentEnd - 1) || a(u.start)) || (r.push({ text: n.slice(o.start, l.contentEnd), start: o.start, end: l.end, contentEnd: l.contentEnd }), o = void 0);
4575
4639
  }), r;
4576
4640
  }
4577
- function Ba(n, e, t, i, s, a, r) {
4641
+ function qa(n, e, t, i, s, a, r) {
4578
4642
  const o = [];
4579
4643
  for (let l = s; l <= a; l++) {
4580
- if (Y(n[l], r)) {
4581
- o.push(...Zn([n[l]], [e[l]], r));
4644
+ if (Z(n[l], r)) {
4645
+ o.push(...ni([n[l]], [e[l]], r));
4582
4646
  continue;
4583
4647
  }
4584
4648
  const c = L(e[l], r.ancestorChains);
4585
4649
  if (!c) continue;
4586
4650
  const u = t[l], g = Math.max(u.start, i.start), d = Math.min(u.end, l === a ? i.contentEnd : i.end);
4587
4651
  if (d <= g) continue;
4588
- const h = g - u.start, f = d - u.start, p = de(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = X(c.ref, p.slice(h, f));
4652
+ const h = g - u.start, f = d - u.start, p = ge(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = J(c.ref, p.slice(h, f));
4589
4653
  o.push({ start: h, end: f, locate: m });
4590
4654
  }
4591
4655
  return o;
4592
4656
  }
4593
- function ti(n, e) {
4594
- const t = ya(n, e);
4595
- return t !== null ? t ?? "en" : n.find((i) => !Y(i, e))?.language ?? n[0].language ?? "en";
4657
+ function ri(n, e) {
4658
+ const t = Ea(n, e);
4659
+ return t !== null ? t ?? "en" : n.find((i) => !Z(i, e))?.language ?? n[0].language ?? "en";
4596
4660
  }
4597
- function ja(n, e, t, i, s) {
4598
- const a = ce(t, n.start), r = n.end > n.start ? ce(t, n.end - 1) : a, o = Gn(e.slice(a, r + 1), s);
4661
+ function Ga(n, e, t, i, s) {
4662
+ const a = ue(t, n.start), r = n.end > n.start ? ue(t, n.end - 1) : a, o = Jn(e.slice(a, r + 1), s);
4599
4663
  return o.map(([l, c], u) => {
4600
- const g = a + l, d = a + c - 1, h = u === o.length - 1, f = u === 0 ? n.start : t[g].start, p = h ? n.contentEnd : t[d].end, m = h ? n.end : t[d + 1].start, S = $n(e.slice(g, d + 1), s) ?? void 0, v = { text: i.slice(f, p), start: f, end: m, contentEnd: p }, w = o.length > 1 && g === d && Y(e[g], s);
4664
+ const g = a + l, d = a + c - 1, h = u === o.length - 1, f = u === 0 ? n.start : t[g].start, p = h ? n.contentEnd : t[d].end, m = h ? n.end : t[d + 1].start, S = Wn(e.slice(g, d + 1), s) ?? void 0, v = { text: i.slice(f, p), start: f, end: m, contentEnd: p }, w = o.length > 1 && g === d && Z(e[g], s);
4601
4665
  return { boundary: v, startIdx: g, endIdx: d, language: S, sentenceEnd: h ? n.end : void 0, isolated: w };
4602
4666
  });
4603
4667
  }
4604
- async function Da(n, e, t, i, s, a) {
4605
- const r = ti(n, t), o = Ce(t.segmentationSuppressions, r), l = n.map((v) => de(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = ke(l), g = Ma(c, await t.segmenter(r, c, o), n, u, t), h = (g.length > 0 ? g : [{ text: c, start: 0, end: c.length, contentEnd: c.length }]).flatMap((v) => ja(v, n, u, c, t));
4668
+ async function Ha(n, e, t, i, s, a) {
4669
+ const r = ri(n, t), o = bt(r, t), l = n.map((v) => ge(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = Ee(l), g = $a(c, await t.segmenter(r, c, o), n, u, t), h = (g.length > 0 ? g : [{ text: c, start: 0, end: c.length, contentEnd: c.length }]).flatMap((v) => Ga(v, n, u, c, t));
4606
4670
  let f, p;
4607
4671
  if (t.format === "ssml") {
4608
4672
  const v = /* @__PURE__ */ new Map();
4609
4673
  for (const y of h) for (let b = y.startIdx; b <= y.endIdx; b++) v.set(b, y.language);
4610
- p = ke(n.map((y, b) => qn(y, v.get(b), t)), l).joined;
4674
+ p = Ee(n.map((y, b) => Qn(y, v.get(b), t)), l).joined;
4611
4675
  const w = h.map((y) => y.boundary);
4612
- f = h.length > 1 ? await Yn(p, r, async () => w, o) : void 0;
4676
+ f = h.length > 1 ? await si(p, r, async () => w, o) : void 0;
4613
4677
  }
4614
4678
  const m = new Set(n.filter((v) => t.blockStarts.has(v))), S = (v, w) => {
4615
4679
  if (v !== void 0)
4616
4680
  for (let y = 0; y < n.length; y++)
4617
- (u[y].end <= v || w === h.length - 1) && ei(a, y, i, s);
4681
+ (u[y].end <= v || w === h.length - 1) && ai(a, y, i, s);
4618
4682
  };
4619
4683
  h.forEach(({ boundary: v, startIdx: w, endIdx: y, language: b, sentenceEnd: P, isolated: A }, E) => {
4620
4684
  if (A) {
4621
4685
  i.push(n[w]), s.push(e[w]), S(P, E);
4622
4686
  return;
4623
4687
  }
4624
- const I = t.format === "ssml" ? f ? f[E] : p : v.text, R = { [t.format]: I };
4625
- t.language !== "none" && (R.language = b ?? "en"), n.slice(w, y + 1).filter((ee) => m.delete(ee)).length > 0 && t.blockStarts.add(R);
4626
- const D = Ba(n, e, u, v, w, y, t);
4627
- D.length > 0 && (R.offsets = D);
4628
- const U = [...Array(y - w + 1).keys()].map((ee) => w + ee).filter((ee) => !Y(n[ee], t)), F = U[0] ?? w, _ = U[U.length - 1] ?? y, bt = L(e[F], t.ancestorChains), wt = pt(bt, I), kt = F !== _ ? mt(bt, L(e[_], t.ancestorChains), wt) : wt;
4629
- kt && (R.locate = kt), i.push(R), s.push(F === _ ? e[F] : [e[F], e[_]]), S(P, E);
4688
+ const I = t.format === "ssml" ? f ? f[E] : p : v.text, R = { [t.format]: I }, X = t.language === "none" ? M(void 0, t) : b ?? "en";
4689
+ X && (R.language = X), n.slice(w, y + 1).filter((te) => m.delete(te)).length > 0 && t.blockStarts.add(R);
4690
+ const B = qa(n, e, u, v, w, y, t);
4691
+ B.length > 0 && (R.offsets = B);
4692
+ const ee = [...Array(y - w + 1).keys()].map((te) => w + te).filter((te) => !Z(n[te], t)), j = ee[0] ?? w, fe = ee[ee.length - 1] ?? y, wt = L(e[j], t.ancestorChains), kt = pt(wt, I), Ct = j !== fe ? mt(wt, L(e[fe], t.ancestorChains), kt) : kt;
4693
+ Ct && (R.locate = Ct), i.push(R), s.push(j === fe ? e[j] : [e[j], e[fe]]), S(P, E);
4630
4694
  });
4631
4695
  }
4632
- async function ni(n, e, t) {
4696
+ async function oi(n, e, t) {
4633
4697
  if (t.segmentation !== "sentence") return { out: n, sources: e };
4634
4698
  const i = [], s = [];
4635
4699
  let a = 0;
4636
4700
  for (; a < n.length; ) {
4637
4701
  let r = a;
4638
- for (; r + 1 < n.length && Ta(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4702
+ for (; r + 1 < n.length && Da(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
4639
4703
  if (r === a) {
4640
- await rn(n[a], e[a], t, i, s), a = r + 1;
4704
+ await on(n[a], e[a], t, i, s), a = r + 1;
4641
4705
  continue;
4642
4706
  }
4643
4707
  const o = [], l = [], c = /* @__PURE__ */ new Map();
4644
4708
  for (let f = a; f <= r; f++)
4645
- if (!Ua(n[f], t))
4709
+ if (!ja(n[f], t))
4646
4710
  o.push(n[f]), l.push(e[f]);
4647
4711
  else if (o.length === 0)
4648
4712
  i.push(n[f]), s.push(e[f]);
@@ -4654,16 +4718,16 @@ async function ni(n, e, t) {
4654
4718
  a = r + 1;
4655
4719
  continue;
4656
4720
  }
4657
- const u = ti(o, t), g = await za(o, t, u, Ce(t.segmentationSuppressions, u)), d = Na(o, g, t);
4721
+ const u = ri(o, t), g = await Fa(o, t, u, bt(u, t)), d = _a(o, g, t);
4658
4722
  let h = 0;
4659
4723
  for (let f = 0; f < o.length; f++)
4660
4724
  if (!(f < o.length - 1 && d[f])) {
4661
4725
  if (h === f)
4662
- await rn(o[h], l[h], t, i, s), ei(c, h, i, s);
4726
+ await on(o[h], l[h], t, i, s), ai(c, h, i, s);
4663
4727
  else {
4664
4728
  const p = /* @__PURE__ */ new Map();
4665
4729
  for (let m = h; m <= f; m++) c.has(m) && p.set(m - h, c.get(m));
4666
- await Da(o.slice(h, f + 1), l.slice(h, f + 1), t, i, s, p);
4730
+ await Ha(o.slice(h, f + 1), l.slice(h, f + 1), t, i, s, p);
4667
4731
  }
4668
4732
  h = f + 1;
4669
4733
  }
@@ -4671,40 +4735,40 @@ async function ni(n, e, t) {
4671
4735
  }
4672
4736
  return { out: i, sources: s };
4673
4737
  }
4674
- function ii(n, e) {
4738
+ function li(n, e) {
4675
4739
  return Object.keys(e.substitutions).length === 0 ? n : n.map((t) => {
4676
4740
  if (t.ssml) {
4677
- const { ssml: o, plain: l, map: c } = ts(t.ssml, e.substitutions);
4741
+ const { ssml: o, plain: l, map: c } = rs(t.ssml, e.substitutions);
4678
4742
  if (o === t.ssml) return t;
4679
4743
  const u = { ...t, ssml: o };
4680
- return Dt(u, { plain: l, map: c }), u;
4744
+ return Ft(u, { plain: l, map: c }), u;
4681
4745
  }
4682
4746
  const i = t.plain;
4683
4747
  if (!i) return t;
4684
- const { text: s, map: a } = Yi(i, e.substitutions);
4748
+ const { text: s, map: a } = ss(i, e.substitutions);
4685
4749
  if (s === i) return t;
4686
4750
  const r = { ...t, plain: s };
4687
- return Dt(r, { plain: i, map: a }), r;
4751
+ return Ft(r, { plain: i, map: a }), r;
4688
4752
  });
4689
4753
  }
4690
- async function nr(n, e = {}) {
4691
- const t = [], i = [], s = await jn(n, e);
4692
- $(n, t, i, s, !1);
4693
- const a = await ni(t, i, s);
4694
- return ii(Wn(a.out, a.sources, s), s);
4754
+ async function lr(n, e = {}) {
4755
+ const t = [], i = [], s = await $n(n, e);
4756
+ F(n, t, i, s, !1);
4757
+ const a = await oi(t, i, s);
4758
+ return li(Yn(a.out, a.sources, s), s);
4695
4759
  }
4696
- async function Fa(n, e = {}) {
4697
- const t = [], i = [], s = await jn(n, e);
4698
- $(n, t, i, s, !1);
4699
- const a = await ni(t, i, s), r = a.out.map((l) => s.blockStarts.has(l)), o = Wn(a.out, a.sources, s);
4700
- return { utterances: ii(o, s), sources: a.sources, blockStarts: r };
4760
+ async function Ka(n, e = {}) {
4761
+ const t = [], i = [], s = await $n(n, e);
4762
+ F(n, t, i, s, !1);
4763
+ const a = await oi(t, i, s), r = a.out.map((l) => s.blockStarts.has(l)), o = Yn(a.out, a.sources, s);
4764
+ return { utterances: li(o, s), sources: a.sources, blockStarts: r };
4701
4765
  }
4702
- class ir {
4766
+ class cr {
4703
4767
  engine;
4704
4768
  contentQueue = [];
4705
4769
  // `contentQueue` as loaded, before `voice` stamped it — re-stamped when that changes.
4706
4770
  loadedQueue = [];
4707
- events = new Pe();
4771
+ events = new Ae();
4708
4772
  // Navigator owns the state, not the engine
4709
4773
  navigatorState = "idle";
4710
4774
  // Scheduled by the "end" handler's pauseDuration delay — cleared on
@@ -4725,6 +4789,8 @@ class ir {
4725
4789
  // language, segmentation) a no-op on content loaded via loadContent() — prosody
4726
4790
  // fields (rate/pitch/volume/pauseDuration/autoPause) still apply.
4727
4791
  source;
4792
+ // The language of the loaded content as a whole, given with it.
4793
+ contentLanguage;
4728
4794
  // Parallel to `contentQueue`, from the extraction that produced it — lets
4729
4795
  // reextract() find where to resume after a reload (see resolveResumeIndex).
4730
4796
  contentSources = [];
@@ -4738,7 +4804,7 @@ class ir {
4738
4804
  // Index to speak() on the next play() when autoPause has stopped playback between utterances.
4739
4805
  pendingAutoPauseIndex = null;
4740
4806
  constructor(e, t = {}) {
4741
- this.engine = e, this._defaults = new Ts(t.defaults), this._preferences = new oe(t.preferences), this._settings = new ze(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4807
+ this.engine = e, this._defaults = new js(t.defaults), this._preferences = new le(t.preferences), this._settings = new ze(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
4742
4808
  }
4743
4809
  // Unlike pauseDuration/autoPause (read live off settings), the engine owns rate/pitch/volume and must be pushed.
4744
4810
  applyEngineParameters() {
@@ -4790,7 +4856,7 @@ class ir {
4790
4856
  this.setNavigatorState("ready"), this.emitEvent({ type: "ready" });
4791
4857
  }
4792
4858
  }), this.engine.on("boundary", (e) => {
4793
- const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.getCurrentContent(), a = s && typeof t == "number" && typeof i == "number" ? Fs(s, t, i) : void 0;
4859
+ const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.loadedQueue[this.getCurrentUtteranceIndex()], a = s && typeof t == "number" && typeof i == "number" ? Hs(s, t, i) : void 0;
4794
4860
  this.emitEvent(a ? { ...e, detail: { ...e.detail, ...a } } : e);
4795
4861
  }), this.engine.on("mark", (e) => {
4796
4862
  this.emitEvent(e);
@@ -4812,19 +4878,23 @@ class ir {
4812
4878
  return this.engine.getAvailableVoices();
4813
4879
  }
4814
4880
  // Content Management
4815
- loadContent(e) {
4881
+ loadContent(e, t = {}) {
4816
4882
  if (this.source)
4817
4883
  throw new Error("loadContent() cannot be used after loadGndContent() — the two are exclusive. Create a new navigator instance to switch content sources.");
4818
- this.setContentQueue(e);
4884
+ this.contentLanguage = t.language, this.setContentQueue(e);
4819
4885
  }
4820
- async loadGndContent(e) {
4821
- this.source = e, await this.reextract();
4886
+ async loadGndContent(e, t = {}) {
4887
+ this.source = e, this.contentLanguage = t.language, await this.reextract();
4822
4888
  }
4823
4889
  setContentQueue(e, t = null, i = null) {
4824
4890
  this.clearPendingAdvance(), this.pendingAutoPauseIndex = null, (this.navigatorState === "playing" || this.navigatorState === "paused") && this.engine.stop(), this.loadedQueue = Array.isArray(e) ? [...e] : [e];
4825
- const s = this.loadedQueue.map((a) => this.withVoice(a));
4891
+ const s = this.loadedQueue.map((a) => this.withVoice(this.withLanguage(a)));
4826
4892
  this.contentQueue = s, this.pendingResumeIndex = t, this.pendingResumeState = i, this.setNavigatorState("loading"), this.emitEvent({ type: "loading" }), this.engine.loadUtterances(s, t ?? void 0), this.emitContentChangeEvent({ content: s });
4827
4893
  }
4894
+ // The content's language when a loadContent() utterance has none; extraction applies it to loadGndContent()'s.
4895
+ withLanguage(e) {
4896
+ return this.source !== void 0 || this.contentLanguage === void 0 || e.language ? e : { ...e, language: this.contentLanguage };
4897
+ }
4828
4898
  // The utterance's own voice, else `voice`'s for its language.
4829
4899
  withVoice(e) {
4830
4900
  const t = this._settings.voice;
@@ -4835,17 +4905,18 @@ class ir {
4835
4905
  // Re-runs extraction from `this.source`, resuming near the old position if playback was underway.
4836
4906
  async reextract() {
4837
4907
  if (!this.source) return;
4838
- const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await Fa(this.source, {
4908
+ const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await Ka(this.source, {
4839
4909
  format: this._settings.format,
4840
4910
  inlineContextualization: this._settings.inlineContextualization,
4841
4911
  skip: this._settings.skip,
4842
4912
  contextualize: this._settings.contextualize,
4843
4913
  contextualization: {
4844
4914
  contextualizations: this.contextualizationOverrides?.contextualizations,
4845
- shapes: js(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4915
+ shapes: qs(this._settings.verbosity, this.contextualizationOverrides?.shapes),
4846
4916
  params: this.contextualizationOverrides?.params
4847
4917
  },
4848
4918
  language: this._settings.language,
4919
+ contentLanguage: this.contentLanguage,
4849
4920
  languageOverrides: this._settings.languageOverrides,
4850
4921
  segmentation: {
4851
4922
  mode: this._settings.segmentation,
@@ -4961,7 +5032,7 @@ class ir {
4961
5032
  // LocatorOptions there — and the same "resolve, then skip if there's nothing
4962
5033
  // to show" shape, since there's no raw engine event to fall back to unenriched.
4963
5034
  emitUtteranceBoundary(e) {
4964
- const t = this._settings.segmentation, i = _s(e, t);
5035
+ const t = this._settings.segmentation, i = Ks(e, t);
4965
5036
  if (!i.length) return;
4966
5037
  const s = t === "sentence" ? "sentence" : "structure";
4967
5038
  this.emitEvent({
@@ -4979,17 +5050,17 @@ class ir {
4979
5050
  }
4980
5051
  // Rebuilt, staged edits kept, once the engine's voice changes, e.g. when it picks its default after being read.
4981
5052
  get preferencesEditor() {
4982
- const e = this.engine.getCurrentVoice(), t = e ? Pn(e) : null;
4983
- return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new Bt(this._preferencesEditor?.preferences ?? this._preferences, this.settings), this.preferencesEditorEngineVoice = t), this._preferencesEditor;
5053
+ const e = this.engine.getCurrentVoice(), t = e ? Ln(e) : null;
5054
+ return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new jt(this._preferencesEditor?.preferences ?? this._preferences, this.settings), this.preferencesEditorEngineVoice = t), this._preferencesEditor;
4984
5055
  }
4985
5056
  async submitPreferences(e) {
4986
- !this.source && this.contentQueue.length > 0 && Mt.some((t) => e[t] !== void 0) && console.warn(
5057
+ !this.source && this.contentQueue.length > 0 && Bt.some((t) => e[t] !== void 0) && console.warn(
4987
5058
  "submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language, languageOverrides, segmentation) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."
4988
5059
  ), this._preferences = this._preferences.merging(e), await this.applyPreferences();
4989
5060
  }
4990
5061
  async applyPreferences() {
4991
5062
  const e = this._settings;
4992
- if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new Bt(this._preferences, this.settings)), Mt.some((t) => !this.sameSettingValue(e[t], this._settings[t])))
5063
+ if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new jt(this._preferences, this.settings)), Bt.some((t) => !this.sameSettingValue(e[t], this._settings[t])))
4993
5064
  await this.reextract();
4994
5065
  else if (this.loadedQueue.length > 0 && !this.sameSettingValue(e.voice, this._settings.voice)) {
4995
5066
  const { index: t, state: i } = this.resumeTarget();
@@ -5011,82 +5082,82 @@ class ir {
5011
5082
  }
5012
5083
  }
5013
5084
  export {
5014
- Ya as BooleanPreference,
5015
- ne as EnumPreference,
5016
- Ja as FallbackEngineProvider,
5017
- Ls as FallbackSpeechEngine,
5018
- or as Locator,
5019
- lr as LocatorLocations,
5020
- cr as LocatorText,
5021
- Q as Preference,
5022
- fe as RangePreference,
5023
- Vs as ReadiumSpeechDecorationController,
5024
- ir as ReadiumSpeechNavigator,
5025
- Xa as ReadiumSpeechProviderRegistry,
5026
- Ts as SpeechDefaults,
5027
- oe as SpeechPreferences,
5028
- Bt as SpeechPreferencesEditor,
5029
- Rn as SpeechServerAudioDecodeError,
5030
- Rs as SpeechServerEngine,
5031
- Qa as SpeechServerEngineProvider,
5032
- re as SpeechServerError,
5033
- In as SpeechServerNetworkError,
5034
- En as SpeechServerStallError,
5085
+ ar as BooleanPreference,
5086
+ ie as EnumPreference,
5087
+ nr as FallbackEngineProvider,
5088
+ Ts as FallbackSpeechEngine,
5089
+ gr as Locator,
5090
+ fr as LocatorLocations,
5091
+ pr as LocatorText,
5092
+ K as Preference,
5093
+ me as RangePreference,
5094
+ Ms as ReadiumSpeechDecorationController,
5095
+ cr as ReadiumSpeechNavigator,
5096
+ sr as ReadiumSpeechProviderRegistry,
5097
+ js as SpeechDefaults,
5098
+ le as SpeechPreferences,
5099
+ jt as SpeechPreferencesEditor,
5100
+ Pn as SpeechServerAudioDecodeError,
5101
+ Os as SpeechServerEngine,
5102
+ tr as SpeechServerEngineProvider,
5103
+ oe as SpeechServerError,
5104
+ An as SpeechServerNetworkError,
5105
+ In as SpeechServerStallError,
5035
5106
  ze as SpeechSettings,
5036
5107
  Te as StringArrayPreference,
5037
- zt as WebSpeechEngine,
5038
- Wa as WebSpeechEngineProvider,
5039
- k as WebSpeechVoiceManager,
5108
+ Nt as WebSpeechEngine,
5109
+ er as WebSpeechEngineProvider,
5110
+ C as WebSpeechVoiceManager,
5040
5111
  ht as autoPauseScopes,
5041
- ra as blockLevelRoles,
5042
- ae as chineseVariantMap,
5043
- us as chunkPlainText,
5044
- ds as chunkSsmlText,
5045
- cn as compareAlphabetically,
5046
- ln as compareByPreferredRegion,
5047
- Bs as contextualizationShapesAtVerbosity,
5048
- Ms as contextualizedAtVerbosity,
5049
- W as createJsonOrderMap,
5050
- xs as createLocator,
5051
- Un as defaultContextualizations,
5052
- C as extractLangRegionFromBCP47,
5053
- nr as extractUtterances,
5112
+ da as blockLevelRoles,
5113
+ re as chineseVariantMap,
5114
+ ps as chunkPlainText,
5115
+ vs as chunkSsmlText,
5116
+ hn as compareAlphabetically,
5117
+ un as compareByPreferredRegion,
5118
+ $s as contextualizationShapesAtVerbosity,
5119
+ _s as contextualizedAtVerbosity,
5120
+ H as createJsonOrderMap,
5121
+ Ns as createLocator,
5122
+ zn as defaultContextualizations,
5123
+ k as extractLangRegionFromBCP47,
5124
+ lr as extractUtterances,
5054
5125
  ut as extractionFormats,
5055
- Mt as extractionPreferenceKeys,
5126
+ Bt as extractionPreferenceKeys,
5056
5127
  it as filterByBoundarySupport,
5057
- Pi as filterByLanguages,
5058
- Pt as filterOutNoveltyVoices,
5059
- At as filterOutVeryLowQualityVoices,
5128
+ xi as filterByLanguages,
5129
+ At as filterOutNoveltyVoices,
5130
+ Lt as filterOutVeryLowQualityVoices,
5060
5131
  De as getLanguageDisplayName,
5061
- ve as getQualityValue,
5062
- Pn as getVoiceId,
5063
- Ie as groupVoicesByLanguage,
5064
- la as inlineContextualizationRoles,
5132
+ Se as getQualityValue,
5133
+ Ln as getVoiceId,
5134
+ Pe as groupVoicesByLanguage,
5135
+ fa as inlineContextualizationRoles,
5065
5136
  _e as isNoveltyVoice,
5066
- Is as isRecoverableFailure,
5137
+ Vs as isRecoverableFailure,
5067
5138
  $e as isVeryLowQualityVoice,
5068
5139
  ct as languageModes,
5069
- Cn as mapServerVoice,
5070
- fs as mimeTypeForFormat,
5071
- ye as pauseDurationRangeConfig,
5072
- hn as pickBestVoiceByRegion,
5073
- be as pitchRangeConfig,
5074
- Se as rateRangeConfig,
5075
- Fs as resolveBoundaryLocate,
5076
- _s as resolveUtteranceLocate,
5140
+ Rn as mapServerVoice,
5141
+ Ss as mimeTypeForFormat,
5142
+ be as pauseDurationRangeConfig,
5143
+ gn as pickBestVoiceByRegion,
5144
+ ke as pitchRangeConfig,
5145
+ we as rateRangeConfig,
5146
+ Hs as resolveBoundaryLocate,
5147
+ Ks as resolveUtteranceLocate,
5077
5148
  dt as segmentationModes,
5078
- bs as selectBitrate,
5079
- vs as selectFormat,
5080
- Za as setupDecorations,
5081
- er as shapeableRoles,
5082
- tr as skippableRoles,
5083
- Ns as skippedAtVerbosity,
5149
+ Rs as selectBitrate,
5150
+ ks as selectFormat,
5151
+ ir as setupDecorations,
5152
+ rr as shapeableRoles,
5153
+ or as skippableRoles,
5154
+ Fs as skippedAtVerbosity,
5084
5155
  Fe as sortAlphabetically,
5085
- bi as sortByPreferredRegion,
5086
- G as sortByQuality,
5087
- un as sortVoicesByRegions,
5088
- se as toSpeechServerError,
5156
+ Ri as sortByPreferredRegion,
5157
+ $ as sortByQuality,
5158
+ dn as sortVoicesByRegions,
5159
+ ae as toSpeechServerError,
5089
5160
  nt as valueForLanguage,
5090
5161
  lt as verbosityPresets,
5091
- we as volumeRangeConfig
5162
+ Ce as volumeRangeConfig
5092
5163
  };