@pie-qti/player-elements 0.1.23 → 0.1.25
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/dist/ItemToolBar-d36g3aw4-B6TGPyKt.js +3079 -0
- package/dist/ItemToolBar-d36g3aw4-B6TGPyKt.js.map +1 -0
- package/dist/ar-SA-BDmOol_3.js +854 -0
- package/dist/ar-SA-BDmOol_3.js.map +1 -0
- package/dist/{define-CqE08oOW.js → define-D80uAEx4.js} +2891 -4399
- package/dist/define-D80uAEx4.js.map +1 -0
- package/dist/dist-BSG0NOza.js +229 -0
- package/dist/dist-BSG0NOza.js.map +1 -0
- package/dist/{dist-CsEP48m1.js → dist-C8BDh5vZ.js} +1129 -760
- package/dist/dist-C8BDh5vZ.js.map +1 -0
- package/dist/dist-CQel8-vi.js +2507 -0
- package/dist/dist-CQel8-vi.js.map +1 -0
- package/dist/{dist-DQ_jFQFX.js → dist-L-bDDBry.js} +231 -147
- package/dist/dist-L-bDDBry.js.map +1 -0
- package/dist/{element-DU-n15ch.js → element-C5rTAwch.js} +2 -2
- package/dist/{element-DU-n15ch.js.map → element-C5rTAwch.js.map} +1 -1
- package/dist/{element-class-DBV-1lkb-BeszDwN_.js → element-class-B_qAd8ET-DGj15cBY.js} +4404 -3503
- package/dist/element-class-B_qAd8ET-DGj15cBY.js.map +1 -0
- package/dist/elements/BaseSvelteMountElement.d.ts +1 -0
- package/dist/elements/QtiAssessmentPlayerElement.d.ts +1 -0
- package/dist/elements.js +3 -3
- package/dist/es-ES-C98YtDtb.js +802 -0
- package/dist/es-ES-C98YtDtb.js.map +1 -0
- package/dist/fr-FR-CrmmiRPf.js +802 -0
- package/dist/fr-FR-CrmmiRPf.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/item-toolbar-element-BgqPFwsS.js +1990 -0
- package/dist/item-toolbar-element-BgqPFwsS.js.map +1 -0
- package/dist/{types-BFOGFD4R.js → language-tags-BwFWXo71.js} +24 -3
- package/dist/language-tags-BwFWXo71.js.map +1 -0
- package/dist/nl-NL-BRA_1Wcl.js +507 -0
- package/dist/nl-NL-BRA_1Wcl.js.map +1 -0
- package/dist/nl-NL-CAR7pgVz.js +802 -0
- package/dist/nl-NL-CAR7pgVz.js.map +1 -0
- package/dist/pie-DwmznDHb.js +363 -0
- package/dist/pie-DwmznDHb.js.map +1 -0
- package/dist/pie-assessment-toolkit-Cruxm385.js +5 -0
- package/dist/pie-assessment-toolkit-Cruxm385.js.map +1 -0
- package/dist/pie-assessment-toolkit-DJfg6laX.js +5 -0
- package/dist/pie-assessment-toolkit-DJfg6laX.js.map +1 -0
- package/dist/{pie-assessment-toolkit-element-BGOTMhdG.js → pie-assessment-toolkit-element-CT5UuvVY.js} +1679 -1245
- package/dist/pie-assessment-toolkit-element-CT5UuvVY.js.map +1 -0
- package/dist/pie-tool-calculator-Crfk-IZe.js +378 -0
- package/dist/pie-tool-calculator-Crfk-IZe.js.map +1 -0
- package/dist/{root-Dqg3cyBt.js → provider-gBXlGb0d.js} +4 -44
- package/dist/provider-gBXlGb0d.js.map +1 -0
- package/dist/register-players.js +1 -1
- package/dist/register.js +10603 -10162
- package/dist/register.js.map +1 -1
- package/dist/{resolveItems-DhQQhD2k.js → resolveItems-CNMvD8LP.js} +2 -2
- package/dist/{resolveItems-DhQQhD2k.js.map → resolveItems-CNMvD8LP.js.map} +1 -1
- package/dist/ro-RO-DTZbhL0e.js +802 -0
- package/dist/ro-RO-DTZbhL0e.js.map +1 -0
- package/dist/root-dCY6j_Hh.js +47 -0
- package/dist/root-dCY6j_Hh.js.map +1 -0
- package/dist/tag-names-DZGvnAgd.js +2495 -0
- package/dist/tag-names-DZGvnAgd.js.map +1 -0
- package/dist/th-TH-aqlT_oK3.js +802 -0
- package/dist/th-TH-aqlT_oK3.js.map +1 -0
- package/dist/tool-tts-inline-k3hLJUfp.js +4447 -0
- package/dist/tool-tts-inline-k3hLJUfp.js.map +1 -0
- package/dist/zh-CN-DCqaRRhU.js +802 -0
- package/dist/zh-CN-DCqaRRhU.js.map +1 -0
- package/package.json +8 -8
- package/dist/define-CqE08oOW.js.map +0 -1
- package/dist/dist-B1Rc9Jhz.js +0 -220
- package/dist/dist-B1Rc9Jhz.js.map +0 -1
- package/dist/dist-CQEJemjs.js +0 -5061
- package/dist/dist-CQEJemjs.js.map +0 -1
- package/dist/dist-CsEP48m1.js.map +0 -1
- package/dist/dist-DQ_jFQFX.js.map +0 -1
- package/dist/element-class-DBV-1lkb-BeszDwN_.js.map +0 -1
- package/dist/item-toolbar-element-iE73NEkH.js +0 -1922
- package/dist/item-toolbar-element-iE73NEkH.js.map +0 -1
- package/dist/pie-assessment-toolkit-element-BGOTMhdG.js.map +0 -1
- package/dist/pie-tool-calculator-CkQb5qxg.js +0 -2243
- package/dist/pie-tool-calculator-CkQb5qxg.js.map +0 -1
- package/dist/root-Dqg3cyBt.js.map +0 -1
- package/dist/tool-tts-inline-CA3VjWU4.js +0 -3670
- package/dist/tool-tts-inline-CA3VjWU4.js.map +0 -1
- package/dist/types-BFOGFD4R.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { o as e } from "./rolldown-runtime-CEFd7nDs.js";
|
|
2
|
-
import {
|
|
3
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
4
|
-
var
|
|
2
|
+
import { a as t, i as n, n as r, r as i } from "./language-tags-BwFWXo71.js";
|
|
3
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/context/assessment-toolkit-context.js
|
|
4
|
+
var a = n(Symbol.for("pie.assessmentToolkit.runtimeContext"));
|
|
5
5
|
n(Symbol.for("pie.assessmentToolkit.hostRuntimeContext"));
|
|
6
|
-
var
|
|
6
|
+
var o = n(Symbol.for("pie.assessmentToolkit.shellContext")), s = n(Symbol.for("pie.assessmentToolkit.regionScopeContext"));
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
9
|
-
function
|
|
8
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/context/runtime-context-consumer.js
|
|
9
|
+
function c(e, n, r) {
|
|
10
10
|
let i = !1, a = new t(e, {
|
|
11
11
|
context: n,
|
|
12
12
|
subscribe: !0,
|
|
@@ -30,19 +30,19 @@ function o(e, n, r) {
|
|
|
30
30
|
globalThis.clearInterval(c), e.removeEventListener("context-provider", o), a.disconnect();
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function l(e, t) {
|
|
34
|
+
return c(e, a, t);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function u(e, t) {
|
|
37
|
+
return c(e, o, t);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function d(e, t) {
|
|
40
|
+
return c(e, s, t);
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
44
|
-
var
|
|
45
|
-
function
|
|
43
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/catalog-owner.js
|
|
44
|
+
var f = (e) => Array.isArray(e) && e.length > 0;
|
|
45
|
+
function p(e) {
|
|
46
46
|
return e.kind === "passage" ? {
|
|
47
47
|
ownerKind: "passage",
|
|
48
48
|
assessmentId: e.assessmentId,
|
|
@@ -56,17 +56,17 @@ function d(e) {
|
|
|
56
56
|
canonicalItemId: e.canonicalItemId || e.itemId
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function m(e, t) {
|
|
60
60
|
if (!e) return [];
|
|
61
|
-
let n =
|
|
62
|
-
if (
|
|
61
|
+
let n = p(t), r = [];
|
|
62
|
+
if (f(e.accessibilityCatalogs) && r.push({
|
|
63
63
|
context: n,
|
|
64
64
|
catalogs: e.accessibilityCatalogs
|
|
65
|
-
}),
|
|
65
|
+
}), f(e.config?.extractedCatalogs) && r.push({
|
|
66
66
|
context: n,
|
|
67
67
|
catalogs: e.config.extractedCatalogs
|
|
68
68
|
}), t.kind === "passage" || n.ownerKind !== "itemModel") return r;
|
|
69
|
-
for (let t of e.config?.models ?? [])
|
|
69
|
+
for (let t of e.config?.models ?? []) f(t.accessibilityCatalogs) && r.push({
|
|
70
70
|
context: {
|
|
71
71
|
...n,
|
|
72
72
|
modelId: t.id
|
|
@@ -76,18 +76,18 @@ function f(e, t) {
|
|
|
76
76
|
return r;
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
80
|
-
function p(e, t) {
|
|
81
|
-
return s(e, t);
|
|
82
|
-
}
|
|
83
|
-
function m(e, t) {
|
|
84
|
-
return c(e, t);
|
|
85
|
-
}
|
|
79
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/runtime/tool-host-contract.js
|
|
86
80
|
function h(e, t) {
|
|
87
81
|
return l(e, t);
|
|
88
82
|
}
|
|
83
|
+
function ee(e, t) {
|
|
84
|
+
return u(e, t);
|
|
85
|
+
}
|
|
86
|
+
function te(e, t) {
|
|
87
|
+
return d(e, t);
|
|
88
|
+
}
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
90
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/SSMLExtractor.js
|
|
91
91
|
var g = /* @__PURE__ */ new Set([
|
|
92
92
|
"speak",
|
|
93
93
|
"break",
|
|
@@ -103,7 +103,7 @@ var g = /* @__PURE__ */ new Set([
|
|
|
103
103
|
"voice",
|
|
104
104
|
"audio",
|
|
105
105
|
"lexicon"
|
|
106
|
-
]),
|
|
106
|
+
]), _ = /* @__PURE__ */ new Set([
|
|
107
107
|
"script",
|
|
108
108
|
"style",
|
|
109
109
|
"iframe",
|
|
@@ -112,7 +112,7 @@ var g = /* @__PURE__ */ new Set([
|
|
|
112
112
|
"foreignobject",
|
|
113
113
|
"noscript",
|
|
114
114
|
"template"
|
|
115
|
-
]),
|
|
115
|
+
]), ne = /* @__PURE__ */ new Set([
|
|
116
116
|
"alphabet",
|
|
117
117
|
"ph",
|
|
118
118
|
"time",
|
|
@@ -129,14 +129,14 @@ var g = /* @__PURE__ */ new Set([
|
|
|
129
129
|
"lang",
|
|
130
130
|
"gender",
|
|
131
131
|
"src"
|
|
132
|
-
]),
|
|
132
|
+
]), re = /* @__PURE__ */ new Set([
|
|
133
133
|
"break",
|
|
134
134
|
"mark",
|
|
135
135
|
"lexicon"
|
|
136
136
|
]);
|
|
137
|
-
function
|
|
137
|
+
function ie(e) {
|
|
138
138
|
let t = e;
|
|
139
|
-
for (let e of
|
|
139
|
+
for (let e of re) {
|
|
140
140
|
let n = RegExp(`<${e}\\b([^>/]*?)\\s*/>`, "gi");
|
|
141
141
|
t = t.replace(n, (t, n) => {
|
|
142
142
|
let r = n ? n.replace(/\s+$/, "") : "";
|
|
@@ -145,7 +145,7 @@ function ne(e) {
|
|
|
145
145
|
}
|
|
146
146
|
return t;
|
|
147
147
|
}
|
|
148
|
-
var
|
|
148
|
+
var ae = [
|
|
149
149
|
/^localhost$/i,
|
|
150
150
|
/^127(?:\.\d{1,3}){3}$/,
|
|
151
151
|
/^0(?:\.\d{1,3}){3}$/,
|
|
@@ -161,7 +161,7 @@ var re = [
|
|
|
161
161
|
/^metadata\.azure\.internal$/i,
|
|
162
162
|
/^metadata\.packet\.net$/i
|
|
163
163
|
];
|
|
164
|
-
function
|
|
164
|
+
function oe(e) {
|
|
165
165
|
if (typeof e != "string" || e.length === 0) return !1;
|
|
166
166
|
let t;
|
|
167
167
|
try {
|
|
@@ -171,52 +171,52 @@ function ie(e) {
|
|
|
171
171
|
}
|
|
172
172
|
if (t.protocol !== "http:" && t.protocol !== "https:") return !1;
|
|
173
173
|
let n = t.hostname.replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
174
|
-
return !
|
|
174
|
+
return !ae.some((e) => e.test(n));
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function se(e) {
|
|
177
177
|
let t = Array.from(e.children);
|
|
178
178
|
for (let n of t) {
|
|
179
179
|
let t = n.tagName.toLowerCase();
|
|
180
|
-
if (
|
|
180
|
+
if (_.has(t)) {
|
|
181
181
|
n.remove();
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
if (
|
|
184
|
+
if (se(n), !g.has(t)) {
|
|
185
185
|
let t = e.ownerDocument.createTextNode(n.textContent ?? "");
|
|
186
186
|
n.replaceWith(t);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
let n = Array.from(e.attributes).map((e) => e.name);
|
|
190
|
-
for (let t of n)
|
|
190
|
+
for (let t of n) ne.has(t.toLowerCase()) || e.removeAttribute(t);
|
|
191
191
|
if (e.tagName.toLowerCase() === "audio") {
|
|
192
192
|
let t = e.getAttribute("src");
|
|
193
|
-
t !== null && !
|
|
193
|
+
t !== null && !oe(t) && e.removeAttribute("src");
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
let t = e.tagName.toLowerCase(), n = Array.from(e.attributes).filter((e) =>
|
|
198
|
-
if (
|
|
196
|
+
function ce(e) {
|
|
197
|
+
let t = e.tagName.toLowerCase(), n = Array.from(e.attributes).filter((e) => ne.has(e.name.toLowerCase())).map((e) => ` ${e.name}="${ue(e.value)}"`).join("");
|
|
198
|
+
if (re.has(t)) return `<${t}${n}/>`;
|
|
199
199
|
let r = [];
|
|
200
200
|
for (let t of Array.from(e.childNodes)) if (t.nodeType === 3) r.push(v(t.nodeValue ?? ""));
|
|
201
201
|
else if (t.nodeType === 1) {
|
|
202
202
|
let e = t, n = e.tagName.toLowerCase();
|
|
203
|
-
if (
|
|
204
|
-
g.has(n) ? r.push(
|
|
203
|
+
if (_.has(n)) continue;
|
|
204
|
+
g.has(n) ? r.push(ce(e)) : r.push(v(e.textContent ?? ""));
|
|
205
205
|
}
|
|
206
206
|
return `<${t}${n}>${r.join("")}</${t}>`;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function le(e) {
|
|
209
209
|
let t = String(e || "").trim();
|
|
210
210
|
if (!t || !t.includes("<") || typeof DOMParser > "u") return e;
|
|
211
|
-
let n = new DOMParser().parseFromString(
|
|
212
|
-
if (r) return
|
|
211
|
+
let n = new DOMParser().parseFromString(ie(t), "text/html"), r = n.querySelector("speak");
|
|
212
|
+
if (r) return se(r), ce(r);
|
|
213
213
|
let i = n.createElement("speak");
|
|
214
214
|
for (let e of Array.from(n.body.childNodes)) i.appendChild(e);
|
|
215
|
-
return
|
|
215
|
+
return se(i), Array.from(i.childNodes).map((e) => {
|
|
216
216
|
if (e.nodeType === 3) return v(e.nodeValue ?? "");
|
|
217
217
|
if (e.nodeType === 1) {
|
|
218
218
|
let t = e;
|
|
219
|
-
return g.has(t.tagName.toLowerCase()) ?
|
|
219
|
+
return g.has(t.tagName.toLowerCase()) ? ce(t) : v(t.textContent ?? "");
|
|
220
220
|
}
|
|
221
221
|
return "";
|
|
222
222
|
}).join("");
|
|
@@ -224,12 +224,12 @@ function se(e) {
|
|
|
224
224
|
function v(e) {
|
|
225
225
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function ue(e) {
|
|
228
228
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
229
229
|
}
|
|
230
230
|
//#endregion
|
|
231
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
232
|
-
var
|
|
231
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/AccessibilityCatalogResolver.js
|
|
232
|
+
var de = /* @__PURE__ */ new Set([
|
|
233
233
|
"spoken",
|
|
234
234
|
"sign-language",
|
|
235
235
|
"transcript",
|
|
@@ -238,39 +238,39 @@ var le = /* @__PURE__ */ new Set([
|
|
|
238
238
|
"simplified-language",
|
|
239
239
|
"audio-description",
|
|
240
240
|
"extended-description"
|
|
241
|
-
]),
|
|
242
|
-
function
|
|
243
|
-
return
|
|
241
|
+
]), fe = "ext:";
|
|
242
|
+
function pe(e) {
|
|
243
|
+
return de.has(e) ? !0 : e.startsWith(fe) && e.length > 4;
|
|
244
244
|
}
|
|
245
|
-
var
|
|
246
|
-
function
|
|
245
|
+
var me = /* @__PURE__ */ new Set();
|
|
246
|
+
function y(e, t = /* @__PURE__ */ new Set()) {
|
|
247
247
|
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === void 0) return e;
|
|
248
248
|
if (typeof e != "object") throw TypeError("catalog cards must contain JSON-compatible values");
|
|
249
249
|
if (t.has(e)) throw TypeError("catalog cards must not contain cycles");
|
|
250
250
|
t.add(e);
|
|
251
251
|
try {
|
|
252
|
-
if (Array.isArray(e)) return Object.freeze(e.map((e) =>
|
|
252
|
+
if (Array.isArray(e)) return Object.freeze(e.map((e) => y(e, t)));
|
|
253
253
|
let n = Object.getPrototypeOf(e);
|
|
254
254
|
if (n !== Object.prototype && n !== null) throw TypeError("catalog cards must contain only plain objects and arrays");
|
|
255
255
|
let r = {};
|
|
256
|
-
for (let [n, i] of Object.entries(e)) r[n] =
|
|
256
|
+
for (let [n, i] of Object.entries(e)) r[n] = y(i, t);
|
|
257
257
|
return Object.freeze(r);
|
|
258
258
|
} finally {
|
|
259
259
|
t.delete(e);
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function he(e, t, n) {
|
|
263
263
|
let r = `${t}|${e}`;
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
let i = `${Array.from(
|
|
264
|
+
if (me.has(r)) return;
|
|
265
|
+
me.add(r);
|
|
266
|
+
let i = `${Array.from(de).join(", ")}, or an "${fe}" prefixed vendor extension`;
|
|
267
267
|
if (t === "card") {
|
|
268
268
|
console.warn(`[AccessibilityCatalogResolver] catalog "${n}" has a card of unknown type "${e}"; it is stored but no reader asks for that type, so the alternate will never be shown. Expected one of: ${i}.`);
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
console.warn(`[AccessibilityCatalogResolver] lookup for unknown catalog type "${e}" on "${n}" cannot match any card. Expected one of: ${i}.`);
|
|
272
272
|
}
|
|
273
|
-
var
|
|
273
|
+
var ge = (e) => e.payload === void 0 ? "content" : "payload", _e = class {
|
|
274
274
|
assessmentCatalogs = /* @__PURE__ */ new Map();
|
|
275
275
|
itemCatalogs = /* @__PURE__ */ new Map();
|
|
276
276
|
scopedCatalogs = /* @__PURE__ */ new Map();
|
|
@@ -349,9 +349,9 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
registerOwner(e) {
|
|
352
|
-
let { owner: t, entity: n } = e, r =
|
|
352
|
+
let { owner: t, entity: n } = e, r = p(t), i = [], a = [];
|
|
353
353
|
try {
|
|
354
|
-
a =
|
|
354
|
+
a = m(n, t);
|
|
355
355
|
} catch (e) {
|
|
356
356
|
console.warn("[AccessibilityCatalogResolver] A mounted content owner could not be traversed for catalogs; the primary content remains available.", e);
|
|
357
357
|
}
|
|
@@ -396,7 +396,7 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
396
396
|
return this.itemCatalogs.has(e) || this.assessmentCatalogs.has(e) || Array.from(this.scopedCatalogs.values()).some((t) => t.catalogs.has(e));
|
|
397
397
|
}
|
|
398
398
|
getAlternative(e, t) {
|
|
399
|
-
|
|
399
|
+
pe(t.type) || he(t.type, "lookup", e);
|
|
400
400
|
let n = t.context ? this.scopedCatalogs.get(this.getOwnerKey(t.context))?.catalogs.get(e) : null;
|
|
401
401
|
if (n) {
|
|
402
402
|
let r = this.findMatchingCard(n, t);
|
|
@@ -434,7 +434,7 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
434
434
|
ensureSpokenSanitized(e) {
|
|
435
435
|
let t = this.sanitizedSpokenCache.get(e);
|
|
436
436
|
if (t !== void 0) return t;
|
|
437
|
-
let n =
|
|
437
|
+
let n = le(e);
|
|
438
438
|
return this.sanitizedSpokenCache.set(e, n), n;
|
|
439
439
|
}
|
|
440
440
|
getOwnerKey(e) {
|
|
@@ -471,7 +471,7 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
471
471
|
for (let [r, i] of n) for (let n of i.cards) try {
|
|
472
472
|
t.push(Object.freeze({
|
|
473
473
|
catalogId: r,
|
|
474
|
-
card:
|
|
474
|
+
card: y(n)
|
|
475
475
|
}));
|
|
476
476
|
} catch (t) {
|
|
477
477
|
let n = `${this.getOwnerKey(e)}\u0000${r}`;
|
|
@@ -488,20 +488,22 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
488
488
|
sanitizeCatalogs(e) {
|
|
489
489
|
return e.map((e) => ({
|
|
490
490
|
...e,
|
|
491
|
-
cards: e.cards.map((t) => (
|
|
491
|
+
cards: e.cards.map((t) => (pe(t.catalog) || he(t.catalog, "card", e.identifier), {
|
|
492
492
|
...t,
|
|
493
|
-
content: t.catalog === "spoken" && t.content !== void 0 ?
|
|
493
|
+
content: t.catalog === "spoken" && t.content !== void 0 ? le(t.content) : t.content
|
|
494
494
|
}))
|
|
495
495
|
}));
|
|
496
496
|
}
|
|
497
497
|
findMatchingCard(e, t) {
|
|
498
|
-
let { type: n, language:
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
let { type: n, language: a, useFallback: o = !0, form: s } = t, c = [], l = (e) => {
|
|
499
|
+
for (let t of r(e)) c.push((e) => i(e.language) === t);
|
|
500
|
+
};
|
|
501
|
+
a && l(a), o && (l(this.defaultLanguage), c.push(() => !0));
|
|
502
|
+
for (let t of c) {
|
|
501
503
|
let r = e.cards.filter((e) => e.catalog === n && t(e));
|
|
502
504
|
if (r.length !== 0) {
|
|
503
|
-
if (
|
|
504
|
-
let e = r.find((e) =>
|
|
505
|
+
if (s) {
|
|
506
|
+
let e = r.find((e) => ge(e) === s);
|
|
505
507
|
if (e) return e;
|
|
506
508
|
}
|
|
507
509
|
return r[0];
|
|
@@ -510,13 +512,13 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
510
512
|
return null;
|
|
511
513
|
}
|
|
512
514
|
getAllAlternatives(e) {
|
|
513
|
-
let t = [], n = /* @__PURE__ */ new Set(), r = (r,
|
|
514
|
-
let
|
|
515
|
-
n.has(
|
|
516
|
-
},
|
|
517
|
-
if (
|
|
518
|
-
let
|
|
519
|
-
if (
|
|
515
|
+
let t = [], n = /* @__PURE__ */ new Set(), r = (r, a) => {
|
|
516
|
+
let o = `${r.catalog}|${i(r.language)}|${ge(r)}`;
|
|
517
|
+
n.has(o) || (n.add(o), t.push(this.resolveCard(e, r, a)));
|
|
518
|
+
}, a = this.itemCatalogs.get(e);
|
|
519
|
+
if (a) for (let e of a.cards) r(e, "item");
|
|
520
|
+
let o = this.assessmentCatalogs.get(e);
|
|
521
|
+
if (o) for (let e of o.cards) r(e, "assessment");
|
|
520
522
|
for (let [t, n] of this.scopedCatalogEntries()) if (t === e) for (let e of n.cards) r(e, "item");
|
|
521
523
|
return t;
|
|
522
524
|
}
|
|
@@ -557,7 +559,7 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
557
559
|
destroy() {
|
|
558
560
|
this.reset();
|
|
559
561
|
}
|
|
560
|
-
},
|
|
562
|
+
}, ve = class {
|
|
561
563
|
elementStates = /* @__PURE__ */ new Map();
|
|
562
564
|
listeners = /* @__PURE__ */ new Set();
|
|
563
565
|
onStateChange = null;
|
|
@@ -625,7 +627,7 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
625
627
|
clearAll() {
|
|
626
628
|
this.elementStates.clear(), this._notifyListeners(), this._notifyStateChange();
|
|
627
629
|
}
|
|
628
|
-
},
|
|
630
|
+
}, ye = class {
|
|
629
631
|
serialize(e, t) {
|
|
630
632
|
return {
|
|
631
633
|
startContainer: this.getNodePath(e.startContainer, t),
|
|
@@ -689,15 +691,15 @@ var he = (e) => e.payload === void 0 ? "content" : "payload", ge = class {
|
|
|
689
691
|
deserializeMany(e, t) {
|
|
690
692
|
return e.map((e) => this.deserialize(e, t));
|
|
691
693
|
}
|
|
692
|
-
},
|
|
694
|
+
}, b;
|
|
693
695
|
(function(e) {
|
|
694
696
|
e.TTS_WORD = "tts-word", e.TTS_SENTENCE = "tts-sentence", e.ANNOTATION = "annotation";
|
|
695
|
-
})(
|
|
696
|
-
var
|
|
697
|
+
})(b ||= {});
|
|
698
|
+
var x;
|
|
697
699
|
(function(e) {
|
|
698
700
|
e.YELLOW = "yellow", e.GREEN = "green", e.BLUE = "blue", e.PINK = "pink", e.ORANGE = "orange", e.UNDERLINE = "underline";
|
|
699
|
-
})(
|
|
700
|
-
var
|
|
701
|
+
})(x ||= {});
|
|
702
|
+
var be = class e {
|
|
701
703
|
config;
|
|
702
704
|
ttsWordHighlight = null;
|
|
703
705
|
ttsSentenceHighlight = null;
|
|
@@ -711,7 +713,7 @@ var ye = class e {
|
|
|
711
713
|
themeObserver = null;
|
|
712
714
|
explicitTTSColorOverride = null;
|
|
713
715
|
constructor(e = {}) {
|
|
714
|
-
if (this.config = e, this.rangeSerializer = new
|
|
716
|
+
if (this.config = e, this.rangeSerializer = new ye(), typeof CSS > "u" || !("highlights" in CSS)) {
|
|
715
717
|
console.warn("CSS Custom Highlight API not supported (SSR or unsupported browser)");
|
|
716
718
|
return;
|
|
717
719
|
}
|
|
@@ -827,7 +829,7 @@ var ye = class e {
|
|
|
827
829
|
}
|
|
828
830
|
i > d && (d = i, u = e);
|
|
829
831
|
}
|
|
830
|
-
let f = Math.max(.24, Math.min(.85, u * .55)), p = Math.max(.55, Math.min(.95, u + .2)), m = Math.max(.22, Math.min(.6, u * .45)), h = s,
|
|
832
|
+
let f = Math.max(.24, Math.min(.85, u * .55)), p = Math.max(.55, Math.min(.95, u + .2)), m = Math.max(.22, Math.min(.6, u * .45)), h = s, ee = this.blend(h, o, p), te = this.contrastRatio(ee, o), g = this.relativeLuminance(o) > .45 ? [
|
|
831
833
|
0,
|
|
832
834
|
0,
|
|
833
835
|
0
|
|
@@ -835,7 +837,7 @@ var ye = class e {
|
|
|
835
837
|
255,
|
|
836
838
|
255,
|
|
837
839
|
255
|
|
838
|
-
], _ =
|
|
840
|
+
], _ = te >= 1.35 ? h : g;
|
|
839
841
|
return {
|
|
840
842
|
wordHighlight: `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${u})`,
|
|
841
843
|
sentenceHighlight: `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${f})`,
|
|
@@ -851,7 +853,7 @@ var ye = class e {
|
|
|
851
853
|
initializeHighlights() {
|
|
852
854
|
if (this.supported) {
|
|
853
855
|
this.ttsWordHighlight = new Highlight(), this.ttsSentenceHighlight = new Highlight(), CSS.highlights.set("tts-word", this.ttsWordHighlight), CSS.highlights.set("tts-sentence", this.ttsSentenceHighlight);
|
|
854
|
-
for (let e of Object.values(
|
|
856
|
+
for (let e of Object.values(x)) {
|
|
855
857
|
let t = new Highlight();
|
|
856
858
|
this.colorHighlights.set(e, t), CSS.highlights.set(`annotation-${e}`, t);
|
|
857
859
|
}
|
|
@@ -929,11 +931,11 @@ var ye = class e {
|
|
|
929
931
|
clearTTS() {
|
|
930
932
|
this.clearTTSWord(), this.clearTTSSentence();
|
|
931
933
|
}
|
|
932
|
-
addAnnotation(e, t =
|
|
934
|
+
addAnnotation(e, t = x.YELLOW) {
|
|
933
935
|
let n = `annotation-${this.nextAnnotationId++}`, r = e.cloneRange(), i = {
|
|
934
936
|
id: n,
|
|
935
937
|
range: r,
|
|
936
|
-
type:
|
|
938
|
+
type: b.ANNOTATION,
|
|
937
939
|
color: t,
|
|
938
940
|
timestamp: Date.now()
|
|
939
941
|
};
|
|
@@ -991,29 +993,29 @@ var ye = class e {
|
|
|
991
993
|
}
|
|
992
994
|
return n;
|
|
993
995
|
}
|
|
994
|
-
highlightRange(e, t, n =
|
|
996
|
+
highlightRange(e, t, n = x.YELLOW) {
|
|
995
997
|
if (this.supported) switch (t) {
|
|
996
|
-
case
|
|
997
|
-
case
|
|
998
|
-
let n = t ===
|
|
999
|
-
if (n && (n.clear(), n.add(e), t ===
|
|
998
|
+
case b.TTS_WORD:
|
|
999
|
+
case b.TTS_SENTENCE: {
|
|
1000
|
+
let n = t === b.TTS_WORD ? this.ttsWordHighlight : this.ttsSentenceHighlight;
|
|
1001
|
+
if (n && (n.clear(), n.add(e), t === b.TTS_WORD)) {
|
|
1000
1002
|
for (let e of this.ttsWordElementHighlights) e.removeAttribute("data-pie-tts-word-element");
|
|
1001
1003
|
this.ttsWordElementHighlights.clear(), this.highlightTTSWordElementFallbacks([e]);
|
|
1002
1004
|
}
|
|
1003
1005
|
break;
|
|
1004
1006
|
}
|
|
1005
|
-
case
|
|
1007
|
+
case b.ANNOTATION: this.addAnnotation(e, n);
|
|
1006
1008
|
}
|
|
1007
1009
|
}
|
|
1008
1010
|
clearHighlights(e) {
|
|
1009
1011
|
if (this.supported) switch (e) {
|
|
1010
|
-
case
|
|
1012
|
+
case b.TTS_WORD:
|
|
1011
1013
|
this.clearTTSWord();
|
|
1012
1014
|
break;
|
|
1013
|
-
case
|
|
1015
|
+
case b.TTS_SENTENCE:
|
|
1014
1016
|
this.clearTTSSentence();
|
|
1015
1017
|
break;
|
|
1016
|
-
case
|
|
1018
|
+
case b.ANNOTATION: this.clearAnnotations();
|
|
1017
1019
|
}
|
|
1018
1020
|
}
|
|
1019
1021
|
clearAll() {
|
|
@@ -1038,111 +1040,105 @@ var ye = class e {
|
|
|
1038
1040
|
}, this.applyAdaptiveTTSStyle());
|
|
1039
1041
|
}
|
|
1040
1042
|
destroy() {
|
|
1041
|
-
|
|
1042
|
-
if (this.clearTTS(), this.clearAnnotations(), typeof document < "u") {
|
|
1043
|
-
let e = document.getElementById("pie-highlight-styles");
|
|
1044
|
-
e && e.remove();
|
|
1045
|
-
}
|
|
1046
|
-
this.themeObserver?.disconnect(), this.themeObserver = null;
|
|
1047
|
-
}
|
|
1043
|
+
this.supported && (this.clearTTS(), this.clearAnnotations(), this.themeObserver?.disconnect(), this.themeObserver = null);
|
|
1048
1044
|
}
|
|
1049
1045
|
};
|
|
1050
1046
|
//#endregion
|
|
1051
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1052
|
-
function
|
|
1047
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/utils/logger.js
|
|
1048
|
+
function xe(e) {
|
|
1053
1049
|
return (...t) => {
|
|
1054
1050
|
console.debug(`[${e}]`, ...t);
|
|
1055
1051
|
};
|
|
1056
1052
|
}
|
|
1057
1053
|
//#endregion
|
|
1058
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1059
|
-
var
|
|
1054
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/tool-config-defaults.js
|
|
1055
|
+
var Se = {
|
|
1060
1056
|
assessment: [],
|
|
1061
1057
|
section: [],
|
|
1062
1058
|
item: [],
|
|
1063
1059
|
passage: [],
|
|
1064
1060
|
rubric: [],
|
|
1065
1061
|
element: []
|
|
1066
|
-
},
|
|
1067
|
-
section: [...
|
|
1068
|
-
item: [...
|
|
1069
|
-
passage: [...
|
|
1062
|
+
}, Ce = {
|
|
1063
|
+
section: [...Se.section],
|
|
1064
|
+
item: [...Se.item],
|
|
1065
|
+
passage: [...Se.passage]
|
|
1070
1066
|
};
|
|
1071
|
-
function
|
|
1067
|
+
function S(e) {
|
|
1072
1068
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1073
1069
|
}
|
|
1074
|
-
function
|
|
1070
|
+
function C(e, t) {
|
|
1075
1071
|
if (e == null) return [];
|
|
1076
1072
|
if (!Array.isArray(e)) throw Error(`Invalid tools config at "${t}": expected an array of tool ids.`);
|
|
1077
1073
|
if (e.find((e) => typeof e != "string") !== void 0) throw Error(`Invalid tools config at "${t}": all entries must be strings.`);
|
|
1078
1074
|
return e;
|
|
1079
1075
|
}
|
|
1080
|
-
function
|
|
1076
|
+
function we(e) {
|
|
1081
1077
|
if (e != null) {
|
|
1082
|
-
if (!
|
|
1078
|
+
if (!S(e)) throw Error("Invalid tools config at \"placement\": expected an object with section/item/passage arrays.");
|
|
1083
1079
|
return e;
|
|
1084
1080
|
}
|
|
1085
1081
|
}
|
|
1086
|
-
function
|
|
1082
|
+
function Te(e) {
|
|
1087
1083
|
if (e != null) {
|
|
1088
|
-
if (!
|
|
1084
|
+
if (!S(e)) throw Error("Invalid tools config at \"policy\": expected an object with allowed/blocked arrays.");
|
|
1089
1085
|
return e;
|
|
1090
1086
|
}
|
|
1091
1087
|
}
|
|
1092
|
-
function
|
|
1088
|
+
function Ee(e, t) {
|
|
1093
1089
|
if (t == null) return;
|
|
1094
|
-
if (!
|
|
1090
|
+
if (!S(t)) throw Error(`Invalid tools config at "providers.${e}": expected an object.`);
|
|
1095
1091
|
let n = t, r = (e) => e === "polly" || e === "google" || e === "custom";
|
|
1096
1092
|
if ("enabled" in n && n.enabled !== void 0 && typeof n.enabled != "boolean") throw Error(`Invalid tools config at "providers.${e}.enabled": expected a boolean.`);
|
|
1097
|
-
if ("settings" in n && n.settings !== void 0 && !
|
|
1098
|
-
if ("provider" in n && n.provider !== void 0 && !
|
|
1093
|
+
if ("settings" in n && n.settings !== void 0 && !S(n.settings)) throw Error(`Invalid tools config at "providers.${e}.settings": expected an object.`);
|
|
1094
|
+
if ("provider" in n && n.provider !== void 0 && !S(n.provider) && !(e === "textToSpeech" && r(n.provider))) throw Error(`Invalid tools config at "providers.${e}.provider": expected an object.`);
|
|
1099
1095
|
return n;
|
|
1100
1096
|
}
|
|
1101
|
-
function
|
|
1097
|
+
function De(e) {
|
|
1102
1098
|
if (e == null) return {};
|
|
1103
|
-
if (!
|
|
1099
|
+
if (!S(e)) throw Error("Invalid tools config at \"providers\": expected an object keyed by tool id.");
|
|
1104
1100
|
let t = {};
|
|
1105
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
1101
|
+
for (let [n, r] of Object.entries(e)) t[n] = Ee(n, r);
|
|
1106
1102
|
return t;
|
|
1107
1103
|
}
|
|
1108
|
-
function
|
|
1104
|
+
function Oe(e) {
|
|
1109
1105
|
return e.trim() || "";
|
|
1110
1106
|
}
|
|
1111
|
-
function
|
|
1107
|
+
function w(e) {
|
|
1112
1108
|
if (!e || e.length === 0) return [];
|
|
1113
1109
|
let t = /* @__PURE__ */ new Set();
|
|
1114
1110
|
for (let n of e) {
|
|
1115
1111
|
if (typeof n != "string") throw Error("Invalid tools config: tool list entries must be strings.");
|
|
1116
|
-
let e =
|
|
1112
|
+
let e = Oe(n);
|
|
1117
1113
|
e && t.add(e);
|
|
1118
1114
|
}
|
|
1119
1115
|
return Array.from(t);
|
|
1120
1116
|
}
|
|
1121
|
-
function
|
|
1117
|
+
function ke(e, t) {
|
|
1122
1118
|
if (e != null) {
|
|
1123
1119
|
if (e === "on" || e === "off") return e;
|
|
1124
1120
|
throw Error(`Invalid tools config at "${t}": expected "on" or "off", got ${JSON.stringify(e)}.`);
|
|
1125
1121
|
}
|
|
1126
1122
|
}
|
|
1127
|
-
function
|
|
1128
|
-
if (e != null && !
|
|
1129
|
-
let t =
|
|
1123
|
+
function Ae(e) {
|
|
1124
|
+
if (e != null && !S(e)) throw Error("Invalid tools config: expected an object with \"policy\", \"placement\", and \"providers\".");
|
|
1125
|
+
let t = Te(e?.policy), n = we(e?.placement), r = De(e?.providers), i = ke(e?.pnpEnforcement, "pnpEnforcement"), a = {
|
|
1130
1126
|
policy: {
|
|
1131
|
-
allowed: C(
|
|
1132
|
-
blocked: C(
|
|
1127
|
+
allowed: w(C(t?.allowed, "policy.allowed")),
|
|
1128
|
+
blocked: w(C(t?.blocked, "policy.blocked"))
|
|
1133
1129
|
},
|
|
1134
1130
|
placement: {
|
|
1135
|
-
section: C(
|
|
1136
|
-
item: C(
|
|
1137
|
-
passage: C(
|
|
1131
|
+
section: w(C(n?.section, "placement.section")).length ? w(C(n?.section, "placement.section")) : [...Ce.section],
|
|
1132
|
+
item: w(C(n?.item, "placement.item")).length ? w(C(n?.item, "placement.item")) : [...Ce.item],
|
|
1133
|
+
passage: w(C(n?.passage, "placement.passage")).length ? w(C(n?.passage, "placement.passage")) : [...Ce.passage]
|
|
1138
1134
|
},
|
|
1139
1135
|
providers: r
|
|
1140
1136
|
};
|
|
1141
1137
|
return i && (a.pnpEnforcement = i), a;
|
|
1142
1138
|
}
|
|
1143
1139
|
//#endregion
|
|
1144
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1145
|
-
var
|
|
1140
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/ToolRegistry.js
|
|
1141
|
+
var je = [
|
|
1146
1142
|
"assessment",
|
|
1147
1143
|
"section",
|
|
1148
1144
|
"item",
|
|
@@ -1150,10 +1146,10 @@ var Ae = [
|
|
|
1150
1146
|
"rubric",
|
|
1151
1147
|
"element"
|
|
1152
1148
|
];
|
|
1153
|
-
function
|
|
1149
|
+
function T(e, t) {
|
|
1154
1150
|
if (typeof e != "string" || e.trim().length === 0) throw Error(`Invalid tool registration: "${t}" must be a non-empty string.`);
|
|
1155
1151
|
}
|
|
1156
|
-
var
|
|
1152
|
+
var Me = [
|
|
1157
1153
|
{
|
|
1158
1154
|
pattern: /<script\b/i,
|
|
1159
1155
|
reason: "contains a <script> tag"
|
|
@@ -1171,19 +1167,19 @@ var je = [
|
|
|
1171
1167
|
reason: "contains a <foreignObject> element"
|
|
1172
1168
|
}
|
|
1173
1169
|
];
|
|
1174
|
-
function
|
|
1170
|
+
function Ne(e, t, n) {
|
|
1175
1171
|
let r = t.trimStart(), i = r.toLowerCase().startsWith("<svg"), a = /^https?:/i.test(r);
|
|
1176
1172
|
if (/^data:/i.test(r)) throw Error(`Invalid tool registration "${e}": "${n}" may not be a data: URL.`);
|
|
1177
1173
|
if (!(!i && !a)) {
|
|
1178
|
-
for (let { pattern: r, reason: i } of
|
|
1174
|
+
for (let { pattern: r, reason: i } of Me) if (r.test(t)) throw Error(`Invalid tool registration "${e}": "${n}" ${i}. Inline SVG icons must not include scriptable content.`);
|
|
1179
1175
|
}
|
|
1180
1176
|
}
|
|
1181
|
-
function
|
|
1182
|
-
|
|
1177
|
+
function Pe(e) {
|
|
1178
|
+
T(e.toolId, "toolId"), T(e.name, "name"), T(e.description, "description");
|
|
1183
1179
|
let t = e.activation === "region";
|
|
1184
1180
|
if ((!t || e.icon !== void 0) && typeof e.icon != "string" && typeof e.icon != "function") throw Error(`Invalid tool registration "${e.toolId}": "icon" must be a string or function.`);
|
|
1185
|
-
if (typeof e.icon == "string" &&
|
|
1186
|
-
let n = e.supportedLevels.find((e) => !
|
|
1181
|
+
if (typeof e.icon == "string" && Ne(e.toolId, e.icon, "icon"), !Array.isArray(e.supportedLevels) || e.supportedLevels.length === 0) throw Error(`Invalid tool registration "${e.toolId}": "supportedLevels" must be a non-empty array.`);
|
|
1182
|
+
let n = e.supportedLevels.find((e) => !je.includes(e));
|
|
1187
1183
|
if (n) throw Error(`Invalid tool registration "${e.toolId}": unsupported level "${n}".`);
|
|
1188
1184
|
if (e.activation !== void 0 && e.activation !== "toolbar-toggle" && e.activation !== "selection-gateway" && e.activation !== "region") throw Error(`Invalid tool registration "${e.toolId}": unsupported activation "${String(e.activation)}".`);
|
|
1189
1185
|
if (e.surfaces !== void 0 && (!Array.isArray(e.surfaces) || e.surfaces.some((e) => typeof e != "string" || e.trim().length === 0))) throw Error(`Invalid tool registration "${e.toolId}": "surfaces" must be an array of non-empty strings.`);
|
|
@@ -1198,6 +1194,7 @@ function Ne(e) {
|
|
|
1198
1194
|
if (e.pnpSupportIds !== void 0 && (!Array.isArray(e.pnpSupportIds) || e.pnpSupportIds.some((e) => typeof e != "string" || e.trim().length === 0))) throw Error(`Invalid tool registration "${e.toolId}": "pnpSupportIds" must be an array of non-empty strings.`);
|
|
1199
1195
|
if (e.activation !== "region" && typeof e.isVisibleInContext != "function") throw Error(`Invalid tool registration "${e.toolId}": "isVisibleInContext" must be a function.`);
|
|
1200
1196
|
if (e.isVisibleInContext !== void 0 && typeof e.isVisibleInContext != "function") throw Error(`Invalid tool registration "${e.toolId}": "isVisibleInContext" must be a function when present.`);
|
|
1197
|
+
if (e.isApplicableToContent !== void 0 && typeof e.isApplicableToContent != "function") throw Error(`Invalid tool registration "${e.toolId}": "isApplicableToContent" must be a function when present.`);
|
|
1201
1198
|
if (e.requiresAuthoredContent !== void 0) {
|
|
1202
1199
|
if (typeof e.requiresAuthoredContent != "object" || e.requiresAuthoredContent === null || typeof e.requiresAuthoredContent.resolve != "function") throw Error(`Invalid tool registration "${e.toolId}": "requiresAuthoredContent" must be an object with a "resolve" function.`);
|
|
1203
1200
|
if (!e.pnpSupportIds?.length) throw Error(`Invalid tool registration "${e.toolId}": "requiresAuthoredContent" requires at least one entry in "pnpSupportIds", which is what a host filters a default grant list on.`);
|
|
@@ -1206,7 +1203,7 @@ function Ne(e) {
|
|
|
1206
1203
|
if (typeof e.renderToolbar != "function") throw Error(`Invalid tool registration "${e.toolId}": "renderToolbar" must be a function.`);
|
|
1207
1204
|
} else if (!t) throw Error(`Invalid tool registration "${e.toolId}": "renderToolbar" must be a function.`);
|
|
1208
1205
|
}
|
|
1209
|
-
var
|
|
1206
|
+
var Fe = class {
|
|
1210
1207
|
tools = /* @__PURE__ */ new Map();
|
|
1211
1208
|
pnpIndex = /* @__PURE__ */ new Map();
|
|
1212
1209
|
componentOverrides = {};
|
|
@@ -1229,13 +1226,13 @@ var Pe = class {
|
|
|
1229
1226
|
};
|
|
1230
1227
|
}
|
|
1231
1228
|
normalizeToolId(e) {
|
|
1232
|
-
return
|
|
1229
|
+
return Oe(e);
|
|
1233
1230
|
}
|
|
1234
1231
|
normalizeToolIds(e) {
|
|
1235
1232
|
return e.map((e) => this.normalizeToolId(e));
|
|
1236
1233
|
}
|
|
1237
1234
|
register(e) {
|
|
1238
|
-
if (
|
|
1235
|
+
if (Pe(e), this.tools.has(e.toolId)) throw Error(`Tool '${e.toolId}' is already registered`);
|
|
1239
1236
|
if (this.tools.set(e.toolId, e), e.pnpSupportIds) for (let t of e.pnpSupportIds) this.pnpIndex.has(t) || this.pnpIndex.set(t, /* @__PURE__ */ new Set()), this.pnpIndex.get(t).add(e.toolId);
|
|
1240
1237
|
this.emitChange({
|
|
1241
1238
|
kind: "register",
|
|
@@ -1243,7 +1240,7 @@ var Pe = class {
|
|
|
1243
1240
|
});
|
|
1244
1241
|
}
|
|
1245
1242
|
override(e) {
|
|
1246
|
-
if (
|
|
1243
|
+
if (Pe(e), !this.tools.has(e.toolId)) throw Error(`Cannot override non-existent tool '${e.toolId}'`);
|
|
1247
1244
|
let t = this.tools.get(e.toolId);
|
|
1248
1245
|
if (t.pnpSupportIds) for (let n of t.pnpSupportIds) this.pnpIndex.get(n)?.delete(e.toolId);
|
|
1249
1246
|
if (this.tools.set(e.toolId, e), e.pnpSupportIds) for (let t of e.pnpSupportIds) this.pnpIndex.has(t) || this.pnpIndex.set(t, /* @__PURE__ */ new Set()), this.pnpIndex.get(t).add(e.toolId);
|
|
@@ -1313,6 +1310,16 @@ var Pe = class {
|
|
|
1313
1310
|
}
|
|
1314
1311
|
return n;
|
|
1315
1312
|
}
|
|
1313
|
+
isApplicableToAnyContext(e, t) {
|
|
1314
|
+
let n = this.get(e);
|
|
1315
|
+
return !n?.isApplicableToContent || t.length === 0 || t.some((t) => {
|
|
1316
|
+
try {
|
|
1317
|
+
return n.isApplicableToContent?.(t) ?? !0;
|
|
1318
|
+
} catch (t) {
|
|
1319
|
+
return console.error(`Error evaluating applicability for tool '${e}':`, t), !0;
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1316
1323
|
getToolMetadata() {
|
|
1317
1324
|
return this.getAllTools().map((e) => ({
|
|
1318
1325
|
toolId: e.toolId,
|
|
@@ -1350,7 +1357,7 @@ var Pe = class {
|
|
|
1350
1357
|
}
|
|
1351
1358
|
setToolModuleLoaders(e) {
|
|
1352
1359
|
let t = Object.entries(e).filter((e) => e[1] !== void 0);
|
|
1353
|
-
for (let [e, n] of t) if (
|
|
1360
|
+
for (let [e, n] of t) if (T(e, "tool module loader id"), typeof n != "function") throw Error(`Invalid tool module loader for "${e}": expected a function.`);
|
|
1354
1361
|
let n = [];
|
|
1355
1362
|
for (let [e, r] of t) this.moduleLoaders.get(e) !== r && (this.moduleLoaders.set(e, r), n.push(e));
|
|
1356
1363
|
n.length > 0 && this.emitChange({
|
|
@@ -1408,10 +1415,63 @@ var Pe = class {
|
|
|
1408
1415
|
}
|
|
1409
1416
|
});
|
|
1410
1417
|
}
|
|
1418
|
+
}, Ie = class {
|
|
1419
|
+
targets = /* @__PURE__ */ new Set();
|
|
1420
|
+
changeListeners = /* @__PURE__ */ new Set();
|
|
1421
|
+
registerTarget(e) {
|
|
1422
|
+
return this.targets.add(e), this.notifyChange(), () => {
|
|
1423
|
+
this.targets.delete(e) && this.notifyChange();
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
canRequest(e, t) {
|
|
1427
|
+
return this.findTarget(e, t) !== null;
|
|
1428
|
+
}
|
|
1429
|
+
request(e) {
|
|
1430
|
+
let t = this.findTarget(e.toolId, e.level);
|
|
1431
|
+
if (!t) return !1;
|
|
1432
|
+
try {
|
|
1433
|
+
t.open(e.toolId, e.params);
|
|
1434
|
+
} catch (t) {
|
|
1435
|
+
return console.error(`[ToolRequestRegistry] Target failed to open "${e.toolId}":`, t), !1;
|
|
1436
|
+
}
|
|
1437
|
+
return !0;
|
|
1438
|
+
}
|
|
1439
|
+
onTargetsChange(e) {
|
|
1440
|
+
return this.changeListeners.add(e), () => {
|
|
1441
|
+
this.changeListeners.delete(e);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
findTarget(e, t) {
|
|
1445
|
+
let n = this.findTargetAtLevel(e, t ?? "section");
|
|
1446
|
+
if (n || t !== void 0) return n;
|
|
1447
|
+
for (let t of this.targets) if (t.level !== "section" && this.hostsTool(t, e)) return t;
|
|
1448
|
+
return null;
|
|
1449
|
+
}
|
|
1450
|
+
findTargetAtLevel(e, t) {
|
|
1451
|
+
for (let n of this.targets) if (n.level === t && this.hostsTool(n, e)) return n;
|
|
1452
|
+
return null;
|
|
1453
|
+
}
|
|
1454
|
+
hostsTool(e, t) {
|
|
1455
|
+
try {
|
|
1456
|
+
return e.hostsTool(t) === !0;
|
|
1457
|
+
} catch (n) {
|
|
1458
|
+
return console.warn(`[ToolRequestRegistry] Target at level "${e.level}" failed the host check for "${t}":`, n), !1;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
notifyChange() {
|
|
1462
|
+
for (let e of this.changeListeners) try {
|
|
1463
|
+
e();
|
|
1464
|
+
} catch (e) {
|
|
1465
|
+
console.warn("[ToolRequestRegistry] Target change listener threw:", e);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
dispose() {
|
|
1469
|
+
this.targets.clear(), this.changeListeners.clear();
|
|
1470
|
+
}
|
|
1411
1471
|
};
|
|
1412
1472
|
//#endregion
|
|
1413
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1414
|
-
function
|
|
1473
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/framework-error.js
|
|
1474
|
+
function Le(e) {
|
|
1415
1475
|
return {
|
|
1416
1476
|
kind: e.kind,
|
|
1417
1477
|
severity: e.severity ?? "error",
|
|
@@ -1422,9 +1482,9 @@ function Fe(e) {
|
|
|
1422
1482
|
cause: e.cause
|
|
1423
1483
|
};
|
|
1424
1484
|
}
|
|
1425
|
-
function
|
|
1485
|
+
function Re(e) {
|
|
1426
1486
|
let t = e.error instanceof Error && e.error.message.trim().length > 0 ? e.error.message : String(e.error || "Unknown framework error");
|
|
1427
|
-
return
|
|
1487
|
+
return Le({
|
|
1428
1488
|
kind: e.kind,
|
|
1429
1489
|
source: e.source,
|
|
1430
1490
|
message: t,
|
|
@@ -1432,7 +1492,7 @@ function Ie(e) {
|
|
|
1432
1492
|
cause: e.error
|
|
1433
1493
|
});
|
|
1434
1494
|
}
|
|
1435
|
-
var
|
|
1495
|
+
var ze = {
|
|
1436
1496
|
"coordinator-ready": "coordinator-init",
|
|
1437
1497
|
"state-load": "tool-state-load",
|
|
1438
1498
|
"state-save": "tool-state-save",
|
|
@@ -1442,9 +1502,9 @@ var Le = {
|
|
|
1442
1502
|
"section-controller-init": "section-controller-init",
|
|
1443
1503
|
"section-controller-dispose": "section-controller-dispose"
|
|
1444
1504
|
};
|
|
1445
|
-
function
|
|
1446
|
-
let t =
|
|
1447
|
-
return
|
|
1505
|
+
function Be(e) {
|
|
1506
|
+
let t = ze[e.context.phase];
|
|
1507
|
+
return Re({
|
|
1448
1508
|
kind: t,
|
|
1449
1509
|
source: e.context.providerId ? `pie-toolkit-coordinator/${e.context.providerId}` : `pie-toolkit-coordinator:${e.context.phase}`,
|
|
1450
1510
|
error: e.error,
|
|
@@ -1452,22 +1512,22 @@ function Re(e) {
|
|
|
1452
1512
|
});
|
|
1453
1513
|
}
|
|
1454
1514
|
//#endregion
|
|
1455
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1456
|
-
var
|
|
1457
|
-
function
|
|
1458
|
-
return e === "off" || e === "warn" || e === "error" ? e :
|
|
1515
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/tool-config-validation.js
|
|
1516
|
+
var Ve = "error";
|
|
1517
|
+
function He(e) {
|
|
1518
|
+
return e === "off" || e === "warn" || e === "error" ? e : Ve;
|
|
1459
1519
|
}
|
|
1460
|
-
function
|
|
1520
|
+
function E(e) {
|
|
1461
1521
|
return e;
|
|
1462
1522
|
}
|
|
1463
|
-
function
|
|
1523
|
+
function Ue(e) {
|
|
1464
1524
|
return e ? new Map(e.getAllTools().slice().sort((e, t) => e.toolId.localeCompare(t.toolId)).map((e) => [e.toolId, e])) : /* @__PURE__ */ new Map();
|
|
1465
1525
|
}
|
|
1466
|
-
function
|
|
1526
|
+
function We(e, t, n, r) {
|
|
1467
1527
|
if (!t || !n?.provider?.sanitizeConfig) return t;
|
|
1468
1528
|
try {
|
|
1469
1529
|
let i = n.provider.sanitizeConfig(t);
|
|
1470
|
-
return !i || typeof i != "object" || Array.isArray(i) ? (r.push(
|
|
1530
|
+
return !i || typeof i != "object" || Array.isArray(i) ? (r.push(E({
|
|
1471
1531
|
code: "tools.providerSanitizeFailed",
|
|
1472
1532
|
severity: "error",
|
|
1473
1533
|
path: `providers.${e}`,
|
|
@@ -1476,7 +1536,7 @@ function He(e, t, n, r) {
|
|
|
1476
1536
|
toolId: e
|
|
1477
1537
|
})), t) : i;
|
|
1478
1538
|
} catch (n) {
|
|
1479
|
-
return r.push(
|
|
1539
|
+
return r.push(E({
|
|
1480
1540
|
code: "tools.providerSanitizeFailed",
|
|
1481
1541
|
severity: "error",
|
|
1482
1542
|
path: `providers.${e}`,
|
|
@@ -1486,11 +1546,11 @@ function He(e, t, n, r) {
|
|
|
1486
1546
|
})), t;
|
|
1487
1547
|
}
|
|
1488
1548
|
}
|
|
1489
|
-
function
|
|
1549
|
+
function Ge(e, t, n, r) {
|
|
1490
1550
|
if (!(!t || !n?.provider?.validateConfig)) try {
|
|
1491
1551
|
let i = n.provider.validateConfig(t);
|
|
1492
1552
|
if (!Array.isArray(i)) {
|
|
1493
|
-
r.push(
|
|
1553
|
+
r.push(E({
|
|
1494
1554
|
code: "tools.invalidProviderValidation",
|
|
1495
1555
|
severity: "error",
|
|
1496
1556
|
path: `providers.${e}`,
|
|
@@ -1507,7 +1567,7 @@ function Ue(e, t, n, r) {
|
|
|
1507
1567
|
toolId: t.toolId || e
|
|
1508
1568
|
});
|
|
1509
1569
|
} catch (t) {
|
|
1510
|
-
r.push(
|
|
1570
|
+
r.push(E({
|
|
1511
1571
|
code: "tools.providerValidateFailed",
|
|
1512
1572
|
severity: "error",
|
|
1513
1573
|
path: `providers.${e}`,
|
|
@@ -1517,7 +1577,7 @@ function Ue(e, t, n, r) {
|
|
|
1517
1577
|
}));
|
|
1518
1578
|
}
|
|
1519
1579
|
}
|
|
1520
|
-
function
|
|
1580
|
+
function Ke(e, t, n) {
|
|
1521
1581
|
if (t.size !== 0) for (let r of [
|
|
1522
1582
|
"section",
|
|
1523
1583
|
"item",
|
|
@@ -1525,7 +1585,7 @@ function We(e, t, n) {
|
|
|
1525
1585
|
]) for (let i of e.placement[r]) {
|
|
1526
1586
|
let e = t.get(i);
|
|
1527
1587
|
if (!e) {
|
|
1528
|
-
n.push(
|
|
1588
|
+
n.push(E({
|
|
1529
1589
|
code: "tools.unknownToolId",
|
|
1530
1590
|
severity: "error",
|
|
1531
1591
|
path: `placement.${r}`,
|
|
@@ -1535,7 +1595,7 @@ function We(e, t, n) {
|
|
|
1535
1595
|
continue;
|
|
1536
1596
|
}
|
|
1537
1597
|
if (e.activation === "region") {
|
|
1538
|
-
n.push(
|
|
1598
|
+
n.push(E({
|
|
1539
1599
|
code: "tools.unplaceableActivation",
|
|
1540
1600
|
severity: "error",
|
|
1541
1601
|
path: `placement.${r}`,
|
|
@@ -1545,7 +1605,7 @@ function We(e, t, n) {
|
|
|
1545
1605
|
continue;
|
|
1546
1606
|
}
|
|
1547
1607
|
let a = e.supportedLevels.includes(r), o = r === "item" && e.supportedLevels.includes("section");
|
|
1548
|
-
!a && !o && n.push(
|
|
1608
|
+
!a && !o && n.push(E({
|
|
1549
1609
|
code: "tools.unsupportedLevel",
|
|
1550
1610
|
severity: "error",
|
|
1551
1611
|
path: `placement.${r}`,
|
|
@@ -1554,16 +1614,16 @@ function We(e, t, n) {
|
|
|
1554
1614
|
}));
|
|
1555
1615
|
}
|
|
1556
1616
|
}
|
|
1557
|
-
function
|
|
1617
|
+
function qe(e, t, n) {
|
|
1558
1618
|
if (t.size !== 0) {
|
|
1559
|
-
for (let r of e.policy.allowed || []) t.has(r) || n.push(
|
|
1619
|
+
for (let r of e.policy.allowed || []) t.has(r) || n.push(E({
|
|
1560
1620
|
code: "tools.unknownToolId",
|
|
1561
1621
|
severity: "error",
|
|
1562
1622
|
path: "policy.allowed",
|
|
1563
1623
|
message: `Unknown tool id "${r}" in policy.allowed.`,
|
|
1564
1624
|
toolId: r
|
|
1565
1625
|
}));
|
|
1566
|
-
for (let r of e.policy.blocked || []) t.has(r) || n.push(
|
|
1626
|
+
for (let r of e.policy.blocked || []) t.has(r) || n.push(E({
|
|
1567
1627
|
code: "tools.unknownToolId",
|
|
1568
1628
|
severity: "error",
|
|
1569
1629
|
path: "policy.blocked",
|
|
@@ -1572,8 +1632,8 @@ function Ge(e, t, n) {
|
|
|
1572
1632
|
}));
|
|
1573
1633
|
}
|
|
1574
1634
|
}
|
|
1575
|
-
function
|
|
1576
|
-
n && r.push(
|
|
1635
|
+
function Je(e, t, n, r) {
|
|
1636
|
+
n && r.push(E({
|
|
1577
1637
|
code: "tools.removedProviderKey",
|
|
1578
1638
|
severity: "error",
|
|
1579
1639
|
path: "providers.tts",
|
|
@@ -1581,7 +1641,7 @@ function Ke(e, t, n, r) {
|
|
|
1581
1641
|
providerId: "tts",
|
|
1582
1642
|
toolId: "textToSpeech"
|
|
1583
1643
|
}));
|
|
1584
|
-
for (let n of Object.keys(e.providers).sort()) t.size === 0 || t.has(n) || r.push(
|
|
1644
|
+
for (let n of Object.keys(e.providers).sort()) t.size === 0 || t.has(n) || r.push(E({
|
|
1585
1645
|
code: "tools.unknownProviderKey",
|
|
1586
1646
|
severity: "error",
|
|
1587
1647
|
path: `providers.${n}`,
|
|
@@ -1590,19 +1650,19 @@ function Ke(e, t, n, r) {
|
|
|
1590
1650
|
toolId: n
|
|
1591
1651
|
}));
|
|
1592
1652
|
}
|
|
1593
|
-
function
|
|
1653
|
+
function Ye(e, t) {
|
|
1594
1654
|
if (e.length !== 0) for (let n of e) {
|
|
1595
1655
|
let e = `[tool-config-validation:${t}]`;
|
|
1596
1656
|
console.warn(`${e} ${n.path} - ${n.message}`);
|
|
1597
1657
|
}
|
|
1598
1658
|
}
|
|
1599
|
-
function
|
|
1659
|
+
function Xe(e, t) {
|
|
1600
1660
|
let n = e.map((e) => `- ${e.path}: ${e.message}`).join("\n");
|
|
1601
1661
|
throw Error(`[tool-config-validation:${t}] Invalid tools config:\n${n}`);
|
|
1602
1662
|
}
|
|
1603
|
-
function
|
|
1604
|
-
let n =
|
|
1605
|
-
i.size === 0 && s && o.push(
|
|
1663
|
+
function D(e, t = {}) {
|
|
1664
|
+
let n = He(t.strictness), r = t.source ?? "tools", i = Ue(t.toolRegistry), a = Ae(e), o = [], s = Object.values(a.placement).some((e) => e.length > 0) || Object.keys(a.providers).length > 0 || (a.policy.allowed?.length ?? 0) > 0 || (a.policy.blocked?.length ?? 0) > 0;
|
|
1665
|
+
i.size === 0 && s && o.push(E({
|
|
1606
1666
|
code: "tools.registryUnavailable",
|
|
1607
1667
|
severity: "warning",
|
|
1608
1668
|
path: "tools",
|
|
@@ -1615,15 +1675,15 @@ function E(e, t = {}) {
|
|
|
1615
1675
|
continue;
|
|
1616
1676
|
}
|
|
1617
1677
|
let t = i.get(e);
|
|
1618
|
-
l[e] =
|
|
1678
|
+
l[e] = We(e, l[e], t, o), Ge(e, l[e], t, o);
|
|
1619
1679
|
}
|
|
1620
1680
|
let u = {
|
|
1621
1681
|
...a,
|
|
1622
1682
|
providers: l
|
|
1623
1683
|
};
|
|
1624
|
-
|
|
1684
|
+
Ke(u, i, o), qe(u, i, o), Je(u, i, c, o), c && Xe(o.filter((e) => e.code === "tools.removedProviderKey"), r), n === "warn" && Ye(o, r);
|
|
1625
1685
|
let d = o.filter((e) => e.severity === "error");
|
|
1626
|
-
return n === "error" && d.length > 0 &&
|
|
1686
|
+
return n === "error" && d.length > 0 && Xe(d, r), n === "error" && d.length === 0 && Ye(o, r), {
|
|
1627
1687
|
config: u,
|
|
1628
1688
|
diagnostics: o
|
|
1629
1689
|
};
|
|
@@ -1743,34 +1803,37 @@ Object.values({
|
|
|
1743
1803
|
}
|
|
1744
1804
|
}).flatMap((e) => Object.values(e));
|
|
1745
1805
|
//#endregion
|
|
1746
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1747
|
-
var
|
|
1806
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/catalog-media.js
|
|
1807
|
+
var Ze = /^[a-z][a-z0-9+.-]*:/i, Qe = /* @__PURE__ */ new Set([
|
|
1748
1808
|
"http:",
|
|
1749
1809
|
"https:",
|
|
1750
1810
|
"data:",
|
|
1751
1811
|
"blob:"
|
|
1752
1812
|
]);
|
|
1753
|
-
function
|
|
1813
|
+
function $e(e) {
|
|
1814
|
+
return e !== void 0 && e !== 1;
|
|
1815
|
+
}
|
|
1816
|
+
function et(e) {
|
|
1754
1817
|
if (typeof e != "string") return !1;
|
|
1755
1818
|
let t = e.trim();
|
|
1756
1819
|
if (!t) return !1;
|
|
1757
|
-
if (t.startsWith("//") || !
|
|
1820
|
+
if (t.startsWith("//") || !Ze.test(t)) return !0;
|
|
1758
1821
|
let n = t.slice(0, t.indexOf(":") + 1).toLowerCase();
|
|
1759
|
-
return
|
|
1822
|
+
return Qe.has(n);
|
|
1760
1823
|
}
|
|
1761
|
-
function
|
|
1824
|
+
function tt(e) {
|
|
1762
1825
|
if (!Array.isArray(e)) return [];
|
|
1763
1826
|
let t = [];
|
|
1764
1827
|
for (let n of e) {
|
|
1765
1828
|
if (!n || typeof n != "object") continue;
|
|
1766
1829
|
let e = n;
|
|
1767
|
-
if (!
|
|
1830
|
+
if (!et(e.src)) continue;
|
|
1768
1831
|
let r = { src: e.src.trim() };
|
|
1769
1832
|
typeof e.type == "string" && e.type.trim() && (r.type = e.type.trim()), Number.isFinite(e.width) && (r.width = e.width), Number.isFinite(e.height) && (r.height = e.height), !t.some((e) => e.src === r.src) && t.push(r);
|
|
1770
1833
|
}
|
|
1771
1834
|
return t;
|
|
1772
1835
|
}
|
|
1773
|
-
function
|
|
1836
|
+
function nt(e) {
|
|
1774
1837
|
if (!e || typeof e != "object") return;
|
|
1775
1838
|
let t = e, n = Number(t.startSeconds);
|
|
1776
1839
|
if (!Number.isFinite(n) || n < 0) return;
|
|
@@ -1780,44 +1843,61 @@ function $e(e) {
|
|
|
1780
1843
|
endSeconds: r
|
|
1781
1844
|
};
|
|
1782
1845
|
}
|
|
1783
|
-
function
|
|
1846
|
+
function rt(e) {
|
|
1784
1847
|
if (typeof e == "string") return e.trim() || void 0;
|
|
1785
1848
|
}
|
|
1786
|
-
|
|
1849
|
+
var it = 100, at = 1;
|
|
1850
|
+
function ot(e, t, n) {
|
|
1851
|
+
if (!t) return () => {};
|
|
1852
|
+
let { startSeconds: r, endSeconds: i } = t, a;
|
|
1853
|
+
r > 0 && (a = () => {
|
|
1854
|
+
e.currentTime < r && (e.currentTime = r);
|
|
1855
|
+
}, e.readyState >= at ? a() : e.addEventListener("loadedmetadata", a));
|
|
1856
|
+
let o, s;
|
|
1857
|
+
return i !== void 0 && (o = () => {
|
|
1858
|
+
e.currentTime >= i && n();
|
|
1859
|
+
}, e.addEventListener("timeupdate", o), s = setInterval(() => {
|
|
1860
|
+
e.paused || o?.();
|
|
1861
|
+
}, it)), () => {
|
|
1862
|
+
a && e.removeEventListener("loadedmetadata", a), o && e.removeEventListener("timeupdate", o), s !== void 0 && clearInterval(s);
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
function st(e, t) {
|
|
1787
1866
|
if (!t || e.includes("#")) return e;
|
|
1788
1867
|
let n = t.endSeconds === void 0 ? "" : `,${t.endSeconds}`;
|
|
1789
1868
|
return `${e}#t=${t.startSeconds}${n}`;
|
|
1790
1869
|
}
|
|
1791
1870
|
//#endregion
|
|
1792
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1793
|
-
function
|
|
1871
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/spoken-audio-cards.js
|
|
1872
|
+
function ct(e) {
|
|
1794
1873
|
if (!e) return null;
|
|
1795
1874
|
let t = e.payload;
|
|
1796
1875
|
if (!t || typeof t != "object") return null;
|
|
1797
1876
|
let n = t.media;
|
|
1798
1877
|
if (!n || typeof n != "object") return console.warn("[spoken-audio] card carries a `payload` with no `media`; recorded speech needs `media.sources`, so this card is ignored and read-aloud falls back to the script or generated speech"), null;
|
|
1878
|
+
if ($e(n.version)) return console.warn(`[spoken-audio] card's media declares version ${String(n.version)}, which this build does not render; the card is ignored and read-aloud falls back to the script or generated speech`), null;
|
|
1799
1879
|
if (n.kind !== void 0 && n.kind !== "audio") return console.warn(`[spoken-audio] card's media is kind "${n.kind}", not "audio"; a spoken card carries recorded speech, so this card is ignored`), null;
|
|
1800
|
-
let r =
|
|
1880
|
+
let r = tt(n.sources);
|
|
1801
1881
|
return r.length === 0 ? (console.warn("[spoken-audio] card's `media.sources` yielded no usable URL; read-aloud falls back to the script or generated speech"), null) : {
|
|
1802
1882
|
sources: r,
|
|
1803
|
-
fragment:
|
|
1804
|
-
label:
|
|
1883
|
+
fragment: nt(t.fragment),
|
|
1884
|
+
label: rt(n.label)
|
|
1805
1885
|
};
|
|
1806
1886
|
}
|
|
1807
1887
|
//#endregion
|
|
1808
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
1809
|
-
var
|
|
1888
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/services/ToolCoordinator.js
|
|
1889
|
+
var O = xe("ToolCoordinator"), k;
|
|
1810
1890
|
(function(e) {
|
|
1811
1891
|
e[e.BASE = 0] = "BASE", e[e.TOOL = 1e3] = "TOOL", e[e.MODAL = 2e3] = "MODAL", e[e.CONTROL = 3e3] = "CONTROL", e[e.HIGHLIGHT = 4e3] = "HIGHLIGHT";
|
|
1812
|
-
})(
|
|
1813
|
-
var
|
|
1892
|
+
})(k ||= {});
|
|
1893
|
+
var lt = class {
|
|
1814
1894
|
config;
|
|
1815
1895
|
tools = /* @__PURE__ */ new Map();
|
|
1816
1896
|
layerCounters = /* @__PURE__ */ new Map();
|
|
1817
1897
|
listeners = /* @__PURE__ */ new Set();
|
|
1818
1898
|
visibilityState = /* @__PURE__ */ new Map();
|
|
1819
1899
|
constructor(e = {}) {
|
|
1820
|
-
this.config = e, this.layerCounters.set(
|
|
1900
|
+
this.config = e, this.layerCounters.set(k.BASE, 0), this.layerCounters.set(k.TOOL, 0), this.layerCounters.set(k.MODAL, 0), this.layerCounters.set(k.CONTROL, 0), this.layerCounters.set(k.HIGHLIGHT, 0);
|
|
1821
1901
|
}
|
|
1822
1902
|
subscribe(e) {
|
|
1823
1903
|
return this.listeners.add(e), () => {
|
|
@@ -1827,14 +1907,14 @@ var rt = class {
|
|
|
1827
1907
|
notifyListeners() {
|
|
1828
1908
|
this.listeners.forEach((e) => e());
|
|
1829
1909
|
}
|
|
1830
|
-
registerTool(e, t, n, r =
|
|
1831
|
-
if (
|
|
1910
|
+
registerTool(e, t, n, r = k.MODAL) {
|
|
1911
|
+
if (O("registerTool called:", {
|
|
1832
1912
|
id: e,
|
|
1833
1913
|
name: t,
|
|
1834
1914
|
hasElement: !!n,
|
|
1835
1915
|
layer: r
|
|
1836
1916
|
}), this.tools.has(e)) {
|
|
1837
|
-
|
|
1917
|
+
O(`Tool ${e} is already registered`);
|
|
1838
1918
|
return;
|
|
1839
1919
|
}
|
|
1840
1920
|
let i = this.visibilityState.get(e) ?? !1;
|
|
@@ -1846,7 +1926,7 @@ var rt = class {
|
|
|
1846
1926
|
layer: r,
|
|
1847
1927
|
isVisible: i,
|
|
1848
1928
|
baseZIndex: r
|
|
1849
|
-
}),
|
|
1929
|
+
}), O("Tool registered without element:", e);
|
|
1850
1930
|
return;
|
|
1851
1931
|
}
|
|
1852
1932
|
let a = r + this.getNextLayerOffset(r);
|
|
@@ -1860,7 +1940,7 @@ var rt = class {
|
|
|
1860
1940
|
isVisible: i,
|
|
1861
1941
|
baseZIndex: a,
|
|
1862
1942
|
mouseDownHandler: o
|
|
1863
|
-
}), i && this.bringToFront(n),
|
|
1943
|
+
}), i && this.bringToFront(n), O("Tool registered with element:", e);
|
|
1864
1944
|
}
|
|
1865
1945
|
unregisterTool(e) {
|
|
1866
1946
|
let t = this.tools.get(e);
|
|
@@ -1872,7 +1952,7 @@ var rt = class {
|
|
|
1872
1952
|
showTool(e) {
|
|
1873
1953
|
let t = this.tools.get(e);
|
|
1874
1954
|
if (!t) {
|
|
1875
|
-
|
|
1955
|
+
O(`Tool ${e} not found`);
|
|
1876
1956
|
return;
|
|
1877
1957
|
}
|
|
1878
1958
|
t.element && (t.element.style.display = "", this.bringToFront(t.element)), t.isVisible = !0, this.visibilityState.set(e, !0), this.notifyListeners();
|
|
@@ -1880,19 +1960,19 @@ var rt = class {
|
|
|
1880
1960
|
hideTool(e) {
|
|
1881
1961
|
let t = this.tools.get(e);
|
|
1882
1962
|
if (!t) {
|
|
1883
|
-
|
|
1963
|
+
O(`Tool ${e} not found`);
|
|
1884
1964
|
return;
|
|
1885
1965
|
}
|
|
1886
1966
|
t.element && (t.element.style.display = "none"), t.isVisible = !1, this.visibilityState.set(e, !1), this.notifyListeners();
|
|
1887
1967
|
}
|
|
1888
1968
|
toggleTool(e) {
|
|
1889
|
-
|
|
1969
|
+
O("toggleTool called for:", e);
|
|
1890
1970
|
let t = this.tools.get(e);
|
|
1891
1971
|
if (!t) {
|
|
1892
|
-
|
|
1972
|
+
O(`Tool ${e} not found. Registered tools:`, Array.from(this.tools.keys()));
|
|
1893
1973
|
return;
|
|
1894
1974
|
}
|
|
1895
|
-
|
|
1975
|
+
O("Tool found, current visibility:", t.isVisible), t.isVisible ? this.hideTool(e) : this.showTool(e);
|
|
1896
1976
|
}
|
|
1897
1977
|
isToolVisible(e) {
|
|
1898
1978
|
let t = this.tools.get(e);
|
|
@@ -1925,7 +2005,7 @@ var rt = class {
|
|
|
1925
2005
|
updateToolElement(e, t) {
|
|
1926
2006
|
let n = this.tools.get(e);
|
|
1927
2007
|
if (!n) {
|
|
1928
|
-
|
|
2008
|
+
O(`Tool ${e} not found`);
|
|
1929
2009
|
return;
|
|
1930
2010
|
}
|
|
1931
2011
|
n.element && n.mouseDownHandler && n.element.removeEventListener("mousedown", n.mouseDownHandler);
|
|
@@ -1955,7 +2035,7 @@ var rt = class {
|
|
|
1955
2035
|
layer: e.layer
|
|
1956
2036
|
}));
|
|
1957
2037
|
}
|
|
1958
|
-
},
|
|
2038
|
+
}, ut = class {
|
|
1959
2039
|
listeners = /* @__PURE__ */ new Set();
|
|
1960
2040
|
subscribeFrameworkErrors(e) {
|
|
1961
2041
|
this.listeners.add(e);
|
|
@@ -1978,7 +2058,7 @@ var rt = class {
|
|
|
1978
2058
|
getListenerCount() {
|
|
1979
2059
|
return this.listeners.size;
|
|
1980
2060
|
}
|
|
1981
|
-
},
|
|
2061
|
+
}, A = (e, t) => {
|
|
1982
2062
|
let n = t?.useSentenceSegmenter !== !1;
|
|
1983
2063
|
try {
|
|
1984
2064
|
if (!n) throw Error("Segmenter disabled by policy");
|
|
@@ -2003,10 +2083,10 @@ var rt = class {
|
|
|
2003
2083
|
text: e,
|
|
2004
2084
|
offset: 0
|
|
2005
2085
|
}];
|
|
2006
|
-
},
|
|
2086
|
+
}, dt = 5e3, ft = 2e3, pt = (e) => String(e || "").trim().toLowerCase(), mt = () => pt((typeof navigator < "u" ? navigator.language || navigator.languages?.[0] : "") || "en-US"), ht = (e, t) => {
|
|
2007
2087
|
if (t) return e.find((e) => e.voiceURI === t) || e.find((e) => e.name === t) || null;
|
|
2008
|
-
let n =
|
|
2009
|
-
let t =
|
|
2088
|
+
let n = mt(), r = n.split("-")[0] || "en", i = (e) => {
|
|
2089
|
+
let t = pt(e.lang);
|
|
2010
2090
|
return t === n || t.startsWith(`${r}-`);
|
|
2011
2091
|
}, a = [
|
|
2012
2092
|
(e) => e.localService && i(e),
|
|
@@ -2020,14 +2100,14 @@ var rt = class {
|
|
|
2020
2100
|
if (n) return n;
|
|
2021
2101
|
}
|
|
2022
2102
|
return e[0] || null;
|
|
2023
|
-
},
|
|
2103
|
+
}, gt = (e) => !e.default, j = class {
|
|
2024
2104
|
providerId = "browser";
|
|
2025
2105
|
providerName = "Browser Speech Synthesis";
|
|
2026
2106
|
version = "1.0.0";
|
|
2027
2107
|
async initialize(e) {
|
|
2028
2108
|
if (typeof window > "u") throw Error("BrowserTTSProvider requires browser environment");
|
|
2029
2109
|
if (!("speechSynthesis" in window)) throw Error("Browser does not support Speech Synthesis API");
|
|
2030
|
-
return new
|
|
2110
|
+
return new _t(e);
|
|
2031
2111
|
}
|
|
2032
2112
|
supportsFeature(e) {
|
|
2033
2113
|
return !0;
|
|
@@ -2044,7 +2124,7 @@ var rt = class {
|
|
|
2044
2124
|
};
|
|
2045
2125
|
}
|
|
2046
2126
|
destroy() {}
|
|
2047
|
-
},
|
|
2127
|
+
}, _t = class {
|
|
2048
2128
|
utterance = null;
|
|
2049
2129
|
config = null;
|
|
2050
2130
|
_isPlaying = !1;
|
|
@@ -2075,7 +2155,7 @@ var rt = class {
|
|
|
2075
2155
|
f();
|
|
2076
2156
|
}
|
|
2077
2157
|
};
|
|
2078
|
-
l = () => d(!1), this.settlePendingVoiceWait = l, c = setTimeout(() => d(!1, /* @__PURE__ */ Error(`Configured browser voice "${t}" could not be resolved because the browser did not publish its voice inventory within ${
|
|
2158
|
+
l = () => d(!1), this.settlePendingVoiceWait = l, c = setTimeout(() => d(!1, /* @__PURE__ */ Error(`Configured browser voice "${t}" could not be resolved because the browser did not publish its voice inventory within ${ft / 1e3} seconds.`)), ft), a ? i.addEventListener("voiceschanged", p) : i.onvoiceschanged = m, f();
|
|
2079
2159
|
});
|
|
2080
2160
|
}
|
|
2081
2161
|
async resolveBrowserVoice(e) {
|
|
@@ -2091,7 +2171,7 @@ var rt = class {
|
|
|
2091
2171
|
shouldContinue: !1,
|
|
2092
2172
|
voice: null
|
|
2093
2173
|
};
|
|
2094
|
-
let r =
|
|
2174
|
+
let r = ht(n, t || void 0);
|
|
2095
2175
|
if (t && !r) throw Error(`Configured browser voice "${t}" is unavailable. Select a voice exposed by this browser using its voiceURI or name.`);
|
|
2096
2176
|
return {
|
|
2097
2177
|
shouldContinue: !0,
|
|
@@ -2162,7 +2242,7 @@ var rt = class {
|
|
|
2162
2242
|
}
|
|
2163
2243
|
segmentSentences(e) {
|
|
2164
2244
|
let t = this.getSegmentationPolicy();
|
|
2165
|
-
return
|
|
2245
|
+
return A(e, {
|
|
2166
2246
|
locale: t.locale,
|
|
2167
2247
|
useSentenceSegmenter: t.useSentenceSegmenter
|
|
2168
2248
|
});
|
|
@@ -2178,7 +2258,7 @@ var rt = class {
|
|
|
2178
2258
|
return;
|
|
2179
2259
|
}
|
|
2180
2260
|
let o = new SpeechSynthesisUtterance(e);
|
|
2181
|
-
this.utterance = o, r &&
|
|
2261
|
+
this.utterance = o, r && gt(r) && (o.voice = r), this.config?.rate && (o.rate = this.config.rate), this.config?.pitch && (o.pitch = this.config.pitch);
|
|
2182
2262
|
let s = !1, c = !1, l = null, u = null, d = () => {
|
|
2183
2263
|
this.utterance === o && (this.utterance = null);
|
|
2184
2264
|
}, f = () => {
|
|
@@ -2187,7 +2267,7 @@ var rt = class {
|
|
|
2187
2267
|
o.onstart = null, o.onend = null, o.onerror = null, o.onpause = null, o.onresume = null, o.onboundary = null;
|
|
2188
2268
|
}, m = (e, t) => {
|
|
2189
2269
|
c || (c = !0, f(), p(), d(), u && this.settlePendingChunk === u && (this.settlePendingChunk = null), n === this.speakRunId && (this._isPlaying = !1, this._isPaused = !1), t ? a(t) : i(e));
|
|
2190
|
-
}, h = (e) => /* @__PURE__ */ Error(e === "ended" ? "Browser speech synthesis ended before audio started. The browser speech engine may be unavailable or stuck; try another voice or restart the browser." : `Browser speech synthesis did not start within ${
|
|
2270
|
+
}, h = (e) => /* @__PURE__ */ Error(e === "ended" ? "Browser speech synthesis ended before audio started. The browser speech engine may be unavailable or stuck; try another voice or restart the browser." : `Browser speech synthesis did not start within ${dt / 1e3} seconds. The browser speech engine may be unavailable or stuck; try another voice or restart the browser.`);
|
|
2191
2271
|
u = () => m(!1), this.settlePendingChunk = u, o.onstart = () => {
|
|
2192
2272
|
if (n !== this.speakRunId) {
|
|
2193
2273
|
m(!1);
|
|
@@ -2229,7 +2309,7 @@ var rt = class {
|
|
|
2229
2309
|
console.log("[BrowserProvider] Calling onWordBoundary with word:", c, "at position:", l), this.onWordBoundary(c, l, s);
|
|
2230
2310
|
}, l = setTimeout(() => {
|
|
2231
2311
|
c || s || n !== this.speakRunId || (m(!1, h("timedOut")), speechSynthesis.cancel());
|
|
2232
|
-
},
|
|
2312
|
+
}, dt);
|
|
2233
2313
|
try {
|
|
2234
2314
|
speechSynthesis.speak(o);
|
|
2235
2315
|
} catch (e) {
|
|
@@ -2260,7 +2340,7 @@ var rt = class {
|
|
|
2260
2340
|
});
|
|
2261
2341
|
}
|
|
2262
2342
|
onWordBoundary;
|
|
2263
|
-
},
|
|
2343
|
+
}, M = (e) => e.trim().replace(/\s+/g, " "), vt = () => /[\p{L}]+|\d+(?:\.\d+)?|[±√=+\-*/()²³^×÷≤≥≠≈<>|%°'′\u2062]/gu, yt = (e) => {
|
|
2264
2344
|
if (e.hidden || e.tagName?.toLowerCase() === "mjx-assistive-mml" || e.getAttribute("aria-hidden") === "true" || e.hasAttribute("inert")) return !0;
|
|
2265
2345
|
let t = e.classList;
|
|
2266
2346
|
if (t?.contains("sr-only") || t?.contains("pie-sr-only") || t?.contains("visually-hidden")) return !0;
|
|
@@ -2271,28 +2351,28 @@ var rt = class {
|
|
|
2271
2351
|
if ((t.position === "absolute" || t.position === "fixed") && i && (t.overflow === "hidden" || a) || t.opacity === "0" && i) return !0;
|
|
2272
2352
|
}
|
|
2273
2353
|
return !1;
|
|
2274
|
-
},
|
|
2354
|
+
}, bt = (e, t) => {
|
|
2275
2355
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
2276
2356
|
for (; n;) {
|
|
2277
|
-
if (
|
|
2357
|
+
if (yt(n)) return !0;
|
|
2278
2358
|
if (t && n === t) break;
|
|
2279
2359
|
n = n.parentElement;
|
|
2280
2360
|
}
|
|
2281
2361
|
return !1;
|
|
2282
|
-
},
|
|
2283
|
-
let t = e.getAttribute?.(
|
|
2362
|
+
}, xt = "data-tts-suppress", St = /* @__PURE__ */ new Set(["computer-read-aloud", "all"]), Ct = /* @__PURE__ */ new Set([...St, "screen-reader"]), wt = /* @__PURE__ */ new Set(), Tt = (e) => {
|
|
2363
|
+
let t = e.getAttribute?.(xt);
|
|
2284
2364
|
if (t == null) return !1;
|
|
2285
2365
|
let n = t.trim().toLowerCase();
|
|
2286
|
-
return
|
|
2287
|
-
},
|
|
2366
|
+
return St.has(n) ? !0 : !Ct.has(n) && (wt.has(n) || (wt.add(n), console.warn(`[tts] ${xt}="${t}" is not one of ${Array.from(Ct).join(", ")}; suppressing read-aloud for this content anyway, because a suppression attribute that fails open would leak the answer to items where reading is the construct. Correct the value to silence this.`)), !0);
|
|
2367
|
+
}, Et = (e, t) => {
|
|
2288
2368
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
2289
2369
|
for (; n;) {
|
|
2290
|
-
if (
|
|
2370
|
+
if (Tt(n)) return !0;
|
|
2291
2371
|
if (t && n === t) break;
|
|
2292
2372
|
n = n.parentElement;
|
|
2293
2373
|
}
|
|
2294
2374
|
return !1;
|
|
2295
|
-
}, N = (e, t) =>
|
|
2375
|
+
}, N = (e, t) => bt(e, t) || Et(e), Dt = (e, t) => {
|
|
2296
2376
|
if (typeof document > "u" || typeof document.createTreeWalker != "function" || typeof NodeFilter > "u" || typeof e.intersectsNode != "function") return {
|
|
2297
2377
|
text: e.toString(),
|
|
2298
2378
|
filtered: !1
|
|
@@ -2313,7 +2393,7 @@ var rt = class {
|
|
|
2313
2393
|
text: n.join(""),
|
|
2314
2394
|
filtered: r
|
|
2315
2395
|
};
|
|
2316
|
-
},
|
|
2396
|
+
}, Ot = (e, t, n) => {
|
|
2317
2397
|
if (!e || !t || /\s/.test(e) || /\s/.test(t)) return !1;
|
|
2318
2398
|
let r = n?.boundarySpacingMode ?? "segmenterPreferred";
|
|
2319
2399
|
if (r === "none") return !1;
|
|
@@ -2337,7 +2417,7 @@ var rt = class {
|
|
|
2337
2417
|
let d = u;
|
|
2338
2418
|
if (d.parentElement && !N(d, e)) {
|
|
2339
2419
|
let e = d.textContent || "", l = e.match(/\S/), u = l ? l[0] : null;
|
|
2340
|
-
!a && !o &&
|
|
2420
|
+
!a && !o && Ot(c, u, t) && (r.push(" "), s && n.set(i, s), i++, o = !0);
|
|
2341
2421
|
for (let t = 0; t < e.length; t++) {
|
|
2342
2422
|
let l = e[t], u = /\s/.test(l);
|
|
2343
2423
|
a ? u || (a = !1, r.push(l), n.set(i, {
|
|
@@ -2369,7 +2449,7 @@ var rt = class {
|
|
|
2369
2449
|
text: d,
|
|
2370
2450
|
map: n
|
|
2371
2451
|
};
|
|
2372
|
-
},
|
|
2452
|
+
}, kt = /* @__PURE__ */ new Set([
|
|
2373
2453
|
"speak",
|
|
2374
2454
|
"p",
|
|
2375
2455
|
"s",
|
|
@@ -2378,20 +2458,20 @@ var rt = class {
|
|
|
2378
2458
|
"say-as",
|
|
2379
2459
|
"voice",
|
|
2380
2460
|
"lang"
|
|
2381
|
-
]),
|
|
2461
|
+
]), At = /* @__PURE__ */ new Set(["audio", "phoneme"]), jt = (e) => e.replace(/"/g, "\"").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/ /g, "\xA0").replace(/ /g, "\xA0").replace(/&/g, "&"), F = (e, t, n) => {
|
|
2382
2462
|
for (let r = 0; r < t.length; r++) e.push({
|
|
2383
2463
|
char: t[r],
|
|
2384
2464
|
rawOffset: n === null ? null : n + r
|
|
2385
2465
|
});
|
|
2386
|
-
},
|
|
2466
|
+
}, Mt = (e, t, n) => {
|
|
2387
2467
|
let r = t.slice(n).match(/^&(quot|apos|lt|gt|nbsp|amp|#160);/i);
|
|
2388
|
-
return r ? (F(e,
|
|
2389
|
-
},
|
|
2468
|
+
return r ? (F(e, jt(r[0]), n), r[0].length) : 0;
|
|
2469
|
+
}, Nt = (e) => {
|
|
2390
2470
|
e.push({
|
|
2391
2471
|
char: " ",
|
|
2392
2472
|
rawOffset: null
|
|
2393
2473
|
});
|
|
2394
|
-
},
|
|
2474
|
+
}, Pt = (e) => {
|
|
2395
2475
|
let t = /* @__PURE__ */ new Map(), n = [], r = !0;
|
|
2396
2476
|
for (let i of e) {
|
|
2397
2477
|
if (/\s/.test(i.char)) {
|
|
@@ -2406,16 +2486,16 @@ var rt = class {
|
|
|
2406
2486
|
text: n.join(""),
|
|
2407
2487
|
rawToSpokenOffsetMap: t
|
|
2408
2488
|
};
|
|
2409
|
-
},
|
|
2489
|
+
}, Ft = (e) => e.match(/^<\/?\s*([A-Za-z0-9:-]+)/)?.[1]?.toLowerCase() || "", It = (e, t) => {
|
|
2410
2490
|
let n = RegExp(`${t}\\s*=\\s*("([^"]*)"|'([^']*)')`, "i"), r = e.match(n);
|
|
2411
|
-
return
|
|
2412
|
-
},
|
|
2491
|
+
return jt(r?.[2] ?? r?.[3] ?? "") || null;
|
|
2492
|
+
}, Lt = (e) => {
|
|
2413
2493
|
let t = [], n = !1, r = !1, i = 0;
|
|
2414
2494
|
for (; i < e.length;) {
|
|
2415
2495
|
let a = e[i];
|
|
2416
2496
|
if (a !== "<") {
|
|
2417
2497
|
if (a === "&") {
|
|
2418
|
-
let n =
|
|
2498
|
+
let n = Mt(t, e, i);
|
|
2419
2499
|
if (n > 0) {
|
|
2420
2500
|
i += n;
|
|
2421
2501
|
continue;
|
|
@@ -2430,9 +2510,9 @@ var rt = class {
|
|
|
2430
2510
|
continue;
|
|
2431
2511
|
}
|
|
2432
2512
|
r = !0;
|
|
2433
|
-
let s = e.slice(i, o + 1), c =
|
|
2513
|
+
let s = e.slice(i, o + 1), c = Ft(s), l = /^<\s*\//.test(s), u = /\/\s*>$/.test(s);
|
|
2434
2514
|
if (!l && c === "sub") {
|
|
2435
|
-
let r =
|
|
2515
|
+
let r = It(s, "alias");
|
|
2436
2516
|
if (!r) {
|
|
2437
2517
|
n = !0, i = o + 1;
|
|
2438
2518
|
continue;
|
|
@@ -2443,23 +2523,23 @@ var rt = class {
|
|
|
2443
2523
|
continue;
|
|
2444
2524
|
}
|
|
2445
2525
|
if (!l && c === "break") {
|
|
2446
|
-
|
|
2526
|
+
Nt(t), i = o + 1;
|
|
2447
2527
|
continue;
|
|
2448
2528
|
}
|
|
2449
|
-
if (!l &&
|
|
2529
|
+
if (!l && At.has(c) && (n = !0, u)) {
|
|
2450
2530
|
i = o + 1;
|
|
2451
2531
|
continue;
|
|
2452
2532
|
}
|
|
2453
|
-
c && !
|
|
2533
|
+
c && !kt.has(c) && !At.has(c) && c !== "break" && c !== "sub" && (n = !0), !l && (c === "p" || c === "s") && Nt(t), i = o + 1;
|
|
2454
2534
|
}
|
|
2455
|
-
let a =
|
|
2535
|
+
let a = Pt(t);
|
|
2456
2536
|
return {
|
|
2457
|
-
spokenText:
|
|
2537
|
+
spokenText: M(a.text),
|
|
2458
2538
|
rawToSpokenOffsetMap: a.rawToSpokenOffsetMap,
|
|
2459
2539
|
unsupportedSemantic: n,
|
|
2460
2540
|
hasMarkup: r
|
|
2461
2541
|
};
|
|
2462
|
-
},
|
|
2542
|
+
}, Rt = vt(), zt = /* @__PURE__ */ new Map([
|
|
2463
2543
|
["zero", "0"],
|
|
2464
2544
|
["one", "1"],
|
|
2465
2545
|
["two", "2"],
|
|
@@ -2471,7 +2551,7 @@ var rt = class {
|
|
|
2471
2551
|
["eight", "8"],
|
|
2472
2552
|
["nine", "9"],
|
|
2473
2553
|
["ten", "10"]
|
|
2474
|
-
]),
|
|
2554
|
+
]), Bt = [
|
|
2475
2555
|
{
|
|
2476
2556
|
phrase: [
|
|
2477
2557
|
"plus",
|
|
@@ -2546,9 +2626,9 @@ var rt = class {
|
|
|
2546
2626
|
visible: "+",
|
|
2547
2627
|
score: 5
|
|
2548
2628
|
}
|
|
2549
|
-
],
|
|
2629
|
+
], Vt = (e) => {
|
|
2550
2630
|
let t = [];
|
|
2551
|
-
for (let n of e.matchAll(
|
|
2631
|
+
for (let n of e.matchAll(Rt)) {
|
|
2552
2632
|
let e = n[0], r = n.index ?? 0;
|
|
2553
2633
|
t.push({
|
|
2554
2634
|
text: e,
|
|
@@ -2558,16 +2638,16 @@ var rt = class {
|
|
|
2558
2638
|
});
|
|
2559
2639
|
}
|
|
2560
2640
|
return t;
|
|
2561
|
-
},
|
|
2641
|
+
}, Ht = (e) => zt.get(e.normalized) || e.normalized, Ut = (e, t) => {
|
|
2562
2642
|
let n = [];
|
|
2563
2643
|
for (let r = 0; r < e.length; r++) {
|
|
2564
|
-
for (let i = 0; i < t.length; i++)
|
|
2644
|
+
for (let i = 0; i < t.length; i++) Ht(e[r]) === Ht(t[i]) && n.push({
|
|
2565
2645
|
spokenStartToken: r,
|
|
2566
2646
|
spokenEndToken: r + 1,
|
|
2567
2647
|
visibleToken: i,
|
|
2568
2648
|
score: 10
|
|
2569
2649
|
});
|
|
2570
|
-
for (let i of
|
|
2650
|
+
for (let i of Bt) {
|
|
2571
2651
|
let a = e.slice(r, r + i.phrase.length);
|
|
2572
2652
|
if (a.length === i.phrase.length && a.every((e, t) => e.normalized === i.phrase[t])) for (let e = 0; e < t.length; e++) t[e].normalized === i.visible && n.push({
|
|
2573
2653
|
spokenStartToken: r,
|
|
@@ -2578,8 +2658,8 @@ var rt = class {
|
|
|
2578
2658
|
}
|
|
2579
2659
|
}
|
|
2580
2660
|
return n;
|
|
2581
|
-
},
|
|
2582
|
-
let n =
|
|
2661
|
+
}, Wt = (e, t) => {
|
|
2662
|
+
let n = Ut(e, t).sort((n, r) => e[n.spokenStartToken].start - e[r.spokenStartToken].start || t[n.visibleToken].start - t[r.visibleToken].start), r = Array(n.length).fill(0), i = Array(n.length).fill(-1);
|
|
2583
2663
|
for (let e = 0; e < n.length; e++) {
|
|
2584
2664
|
let t = n[e];
|
|
2585
2665
|
r[e] = t.score;
|
|
@@ -2606,12 +2686,12 @@ var rt = class {
|
|
|
2606
2686
|
score: n.score
|
|
2607
2687
|
};
|
|
2608
2688
|
});
|
|
2609
|
-
},
|
|
2689
|
+
}, Gt = (e, t, n) => {
|
|
2610
2690
|
if (e.length === 0) return 0;
|
|
2611
2691
|
let r = e.length / Math.max(1, Math.min(t.length, n.length)), i = e.reduce((e, t) => e + t.score, 0) / e.length / 10;
|
|
2612
2692
|
return Math.min(1, r * i);
|
|
2613
|
-
},
|
|
2614
|
-
let t =
|
|
2693
|
+
}, Kt = (e) => {
|
|
2694
|
+
let t = Lt(e.speechText), n = M(e.visibleText), r = t.spokenText, i = Vt(r), a = Vt(n), o = t.unsupportedSemantic ? [] : Wt(i, a), s = Gt(o, i, a), c = r === n && r.length > 0, l = o.length === 1 && o[0].score === 10 && i.length <= 2 && a.length <= 2, u = t.unsupportedSemantic ? "region-fallback" : c ? "exact-word" : (o.length >= 2 || l) && s >= .12 ? "anchor-span" : "region-fallback", d = t.unsupportedSemantic ? "unsupported" : t.hasMarkup ? "raw-ssml" : "plain-spoken-text";
|
|
2615
2695
|
return {
|
|
2616
2696
|
speechText: e.speechText,
|
|
2617
2697
|
spokenText: r,
|
|
@@ -2624,16 +2704,16 @@ var rt = class {
|
|
|
2624
2704
|
visibleTokens: a,
|
|
2625
2705
|
rawToSpokenOffsetMap: t.rawToSpokenOffsetMap
|
|
2626
2706
|
};
|
|
2627
|
-
},
|
|
2707
|
+
}, qt = (e, t) => e.find((e) => e.start <= t && t < e.end) || null, Jt = (e) => {
|
|
2628
2708
|
if (!e || /^<[^>]+>$/.test(e.trim())) return null;
|
|
2629
|
-
let t =
|
|
2630
|
-
return t ?
|
|
2631
|
-
},
|
|
2632
|
-
let r =
|
|
2709
|
+
let t = Vt(e)[0];
|
|
2710
|
+
return t ? zt.get(t.normalized) || t.normalized : null;
|
|
2711
|
+
}, Yt = (e, t, n) => {
|
|
2712
|
+
let r = Jt(n);
|
|
2633
2713
|
if (!t || !r) return !1;
|
|
2634
|
-
let i =
|
|
2635
|
-
return i ?
|
|
2636
|
-
},
|
|
2714
|
+
let i = qt(e.spokenTokens, t.start);
|
|
2715
|
+
return i ? Ht(i) === r : !1;
|
|
2716
|
+
}, Xt = (e, t) => {
|
|
2637
2717
|
let n = e.rawToSpokenOffsetMap.get(t);
|
|
2638
2718
|
if (n !== void 0) return n;
|
|
2639
2719
|
for (let n = t; n < e.speechText.length; n++) {
|
|
@@ -2642,36 +2722,36 @@ var rt = class {
|
|
|
2642
2722
|
if (e.speechText[n] === ">") break;
|
|
2643
2723
|
}
|
|
2644
2724
|
return null;
|
|
2645
|
-
},
|
|
2646
|
-
let r =
|
|
2725
|
+
}, Zt = (e, t, n) => {
|
|
2726
|
+
let r = Xt(e, t);
|
|
2647
2727
|
if (r === null) return null;
|
|
2648
|
-
let i =
|
|
2728
|
+
let i = Xt(e, Math.max(t, t + n - 1)), a = qt(e.spokenTokens, r), o = i !== null && i >= r ? i - r + 1 : a ? a.end - r : n;
|
|
2649
2729
|
return {
|
|
2650
2730
|
start: r,
|
|
2651
2731
|
length: Math.max(1, o)
|
|
2652
2732
|
};
|
|
2653
|
-
},
|
|
2733
|
+
}, Qt = (e, t, n) => {
|
|
2654
2734
|
if (t < 0 || t >= e.spokenText.length) return null;
|
|
2655
|
-
let r =
|
|
2735
|
+
let r = qt(e.spokenTokens, t);
|
|
2656
2736
|
return r ? {
|
|
2657
2737
|
start: t,
|
|
2658
2738
|
length: Math.min(n, r.end - t)
|
|
2659
2739
|
} : null;
|
|
2660
|
-
},
|
|
2740
|
+
}, $t = (e, t, n = 1, r) => {
|
|
2661
2741
|
if (e.boundaryOffsetMode === "unsupported" || !Number.isFinite(t)) return null;
|
|
2662
2742
|
let i = Math.max(1, Number.isFinite(n) ? n : 1);
|
|
2663
2743
|
if (r && /^<[^>]+>$/.test(r.trim())) return null;
|
|
2664
2744
|
if (e.boundaryOffsetMode === "raw-ssml") {
|
|
2665
|
-
let n =
|
|
2745
|
+
let n = Zt(e, t, i), a = Qt(e, t, i);
|
|
2666
2746
|
if (r) {
|
|
2667
|
-
if (
|
|
2668
|
-
if (
|
|
2669
|
-
if (
|
|
2747
|
+
if (Yt(e, n, r)) return n;
|
|
2748
|
+
if (Yt(e, a, r)) return a;
|
|
2749
|
+
if (Jt(r)) return null;
|
|
2670
2750
|
}
|
|
2671
2751
|
return n || a;
|
|
2672
2752
|
}
|
|
2673
|
-
return
|
|
2674
|
-
},
|
|
2753
|
+
return Qt(e, t, i) || Zt(e, t, i);
|
|
2754
|
+
}, en = (e, t) => {
|
|
2675
2755
|
if (e.playbackMode === "region-fallback") return null;
|
|
2676
2756
|
let n = e.anchors.find((e) => e.spokenStart <= t && t < e.spokenEnd);
|
|
2677
2757
|
if (n) return {
|
|
@@ -2693,7 +2773,7 @@ var rt = class {
|
|
|
2693
2773
|
start: Math.min(r.visibleStart, i.visibleStart),
|
|
2694
2774
|
end: Math.max(r.visibleEnd, i.visibleEnd)
|
|
2695
2775
|
} : null;
|
|
2696
|
-
},
|
|
2776
|
+
}, tn = /* @__PURE__ */ new Map([
|
|
2697
2777
|
["+", ["plus"]],
|
|
2698
2778
|
["-", ["minus", "negative"]],
|
|
2699
2779
|
["−", ["minus", "negative"]],
|
|
@@ -2717,12 +2797,12 @@ var rt = class {
|
|
|
2717
2797
|
["•", ["times"]],
|
|
2718
2798
|
["·", ["times"]],
|
|
2719
2799
|
["", ["times", "multiplied by"]]
|
|
2720
|
-
]),
|
|
2800
|
+
]), nn = /* @__PURE__ */ new Map([
|
|
2721
2801
|
["", "function-application"],
|
|
2722
2802
|
["", "implicit-multiply"],
|
|
2723
2803
|
["", "invisible-separator"],
|
|
2724
2804
|
["", "invisible-plus"]
|
|
2725
|
-
]),
|
|
2805
|
+
]), rn = /* @__PURE__ */ new Map([["2", ["squared"]], ["3", ["cubed"]]]), an = /* @__PURE__ */ new Map([
|
|
2726
2806
|
["msqrt", "radical"],
|
|
2727
2807
|
["mroot", "radical"],
|
|
2728
2808
|
["msub", "subscript"],
|
|
@@ -2732,11 +2812,11 @@ var rt = class {
|
|
|
2732
2812
|
["munderover", "underoverscript"],
|
|
2733
2813
|
["mmultiscripts", "multiscript"],
|
|
2734
2814
|
["menclose", "enclosure"]
|
|
2735
|
-
]),
|
|
2815
|
+
]), on = (e) => e.replace(/\s+/g, " ").trim(), I = (e) => (e.localName || e.tagName || "").toLowerCase(), sn = (e) => e.nodeType === Node.ELEMENT_NODE, L = (e) => Array.from(e.childNodes).filter(sn), cn = (e) => on(e.textContent || ""), R = (e, t) => ({
|
|
2736
2816
|
type: "element-range",
|
|
2737
2817
|
quality: t,
|
|
2738
2818
|
element: e
|
|
2739
|
-
}),
|
|
2819
|
+
}), ln = (e) => {
|
|
2740
2820
|
switch (e) {
|
|
2741
2821
|
case "mi": return "identifier";
|
|
2742
2822
|
case "mn": return "number";
|
|
@@ -2746,15 +2826,15 @@ var rt = class {
|
|
|
2746
2826
|
case "mspace": return "space";
|
|
2747
2827
|
default: return "unknown";
|
|
2748
2828
|
}
|
|
2749
|
-
},
|
|
2750
|
-
let t = e.normalized ??
|
|
2829
|
+
}, un = (e, t) => t === "operator" ? e === "−" ? "-" : e : e.toLowerCase(), dn = (e, t, n) => n === "fraction" ? ["over", "divided by"] : n === "superscript" ? rn.get(e) ?? [] : e === "|" ? ["absolute value"] : t === "operator" && tn.get(e) || [], z = (e) => {
|
|
2830
|
+
let t = e.normalized ?? un(e.text, e.kind || "unknown");
|
|
2751
2831
|
return {
|
|
2752
2832
|
id: `math-token-${e.state.nextId++}`,
|
|
2753
2833
|
kind: e.kind,
|
|
2754
2834
|
role: e.role,
|
|
2755
2835
|
text: e.text,
|
|
2756
2836
|
normalized: t,
|
|
2757
|
-
spokenAliases:
|
|
2837
|
+
spokenAliases: dn(e.text, e.kind, e.role),
|
|
2758
2838
|
sourceElement: e.sourceElement,
|
|
2759
2839
|
path: e.path,
|
|
2760
2840
|
target: e.target || R(e.sourceElement, "element-range"),
|
|
@@ -2762,9 +2842,9 @@ var rt = class {
|
|
|
2762
2842
|
};
|
|
2763
2843
|
}, B = (e, t, n = "tokens") => {
|
|
2764
2844
|
e[n].push(t);
|
|
2765
|
-
},
|
|
2845
|
+
}, fn = (e, t, n) => {
|
|
2766
2846
|
L(e).forEach((e, r) => V(e, t, `${n}/${I(e)}[${r}]`));
|
|
2767
|
-
},
|
|
2847
|
+
}, pn = (e, t, n) => {
|
|
2768
2848
|
let r = L(e);
|
|
2769
2849
|
r[0] && V(r[0], t, `${n}/numerator`), B(t, z({
|
|
2770
2850
|
state: t,
|
|
@@ -2775,7 +2855,7 @@ var rt = class {
|
|
|
2775
2855
|
path: n,
|
|
2776
2856
|
target: R(e, "element-range")
|
|
2777
2857
|
})), r[1] && V(r[1], t, `${n}/denominator`);
|
|
2778
|
-
},
|
|
2858
|
+
}, mn = (e, t, n) => {
|
|
2779
2859
|
let r = e.getAttribute("open") || "(", i = e.getAttribute("close") || ")";
|
|
2780
2860
|
B(t, z({
|
|
2781
2861
|
state: t,
|
|
@@ -2785,7 +2865,7 @@ var rt = class {
|
|
|
2785
2865
|
sourceElement: e,
|
|
2786
2866
|
path: `${n}/open`,
|
|
2787
2867
|
target: R(e, "element-range")
|
|
2788
|
-
})),
|
|
2868
|
+
})), fn(e, t, n), B(t, z({
|
|
2789
2869
|
state: t,
|
|
2790
2870
|
kind: "operator",
|
|
2791
2871
|
role: i === "|" ? "absolute-value-fence" : "close-fence",
|
|
@@ -2794,13 +2874,13 @@ var rt = class {
|
|
|
2794
2874
|
path: `${n}/close`,
|
|
2795
2875
|
target: R(e, "element-range")
|
|
2796
2876
|
}));
|
|
2797
|
-
},
|
|
2877
|
+
}, hn = (e, t, n) => {
|
|
2798
2878
|
let r = L(e);
|
|
2799
2879
|
r[0] && V(r[0], t, `${n}/base`);
|
|
2800
2880
|
let i = r[1];
|
|
2801
2881
|
if (!i) return;
|
|
2802
|
-
let a =
|
|
2803
|
-
if (
|
|
2882
|
+
let a = cn(i);
|
|
2883
|
+
if (rn.has(a)) {
|
|
2804
2884
|
B(t, z({
|
|
2805
2885
|
state: t,
|
|
2806
2886
|
kind: "structure",
|
|
@@ -2814,18 +2894,18 @@ var rt = class {
|
|
|
2814
2894
|
return;
|
|
2815
2895
|
}
|
|
2816
2896
|
V(i, t, `${n}/exponent`);
|
|
2817
|
-
},
|
|
2897
|
+
}, gn = (e, t, n, r) => {
|
|
2818
2898
|
B(t, z({
|
|
2819
2899
|
state: t,
|
|
2820
2900
|
kind: "structure",
|
|
2821
2901
|
role: r,
|
|
2822
|
-
text:
|
|
2902
|
+
text: cn(e) || r,
|
|
2823
2903
|
normalized: `\u0000${r}`,
|
|
2824
2904
|
sourceElement: e,
|
|
2825
2905
|
path: n,
|
|
2826
2906
|
target: R(e, "element-range")
|
|
2827
2907
|
}));
|
|
2828
|
-
},
|
|
2908
|
+
}, _n = (e, t, n) => {
|
|
2829
2909
|
let r = 0;
|
|
2830
2910
|
for (let i of L(e)) (I(i) === "mtr" || I(i) === "mlabeledtr") && (r++, B(t, z({
|
|
2831
2911
|
state: t,
|
|
@@ -2837,10 +2917,10 @@ var rt = class {
|
|
|
2837
2917
|
path: `${n}/row[${r}]`,
|
|
2838
2918
|
target: R(i, "region-fallback")
|
|
2839
2919
|
}), "layoutTargets")), V(i, t, `${n}/${I(i)}[${r}]`);
|
|
2840
|
-
},
|
|
2841
|
-
let r =
|
|
2920
|
+
}, vn = (e, t, n) => {
|
|
2921
|
+
let r = cn(e);
|
|
2842
2922
|
if (!r) return;
|
|
2843
|
-
let i =
|
|
2923
|
+
let i = ln(I(e)), a = i === "operator" ? nn.get(r) : void 0, o = a ?? (i === "operator" && (r === "(" || r === ")") ? "grouping-fence" : i);
|
|
2844
2924
|
B(t, z({
|
|
2845
2925
|
state: t,
|
|
2846
2926
|
kind: i,
|
|
@@ -2870,19 +2950,19 @@ var rt = class {
|
|
|
2870
2950
|
case "mtext":
|
|
2871
2951
|
case "ms":
|
|
2872
2952
|
case "mspace":
|
|
2873
|
-
|
|
2953
|
+
vn(e, t, n);
|
|
2874
2954
|
return;
|
|
2875
2955
|
case "mfrac":
|
|
2876
|
-
|
|
2956
|
+
pn(e, t, n);
|
|
2877
2957
|
return;
|
|
2878
2958
|
case "msup":
|
|
2879
|
-
|
|
2959
|
+
hn(e, t, n);
|
|
2880
2960
|
return;
|
|
2881
2961
|
case "mfenced":
|
|
2882
|
-
|
|
2962
|
+
mn(e, t, n);
|
|
2883
2963
|
return;
|
|
2884
2964
|
case "mtable":
|
|
2885
|
-
|
|
2965
|
+
_n(e, t, n);
|
|
2886
2966
|
return;
|
|
2887
2967
|
case "mphantom": return;
|
|
2888
2968
|
case "maction": {
|
|
@@ -2891,15 +2971,15 @@ var rt = class {
|
|
|
2891
2971
|
return;
|
|
2892
2972
|
}
|
|
2893
2973
|
default: {
|
|
2894
|
-
let i =
|
|
2974
|
+
let i = an.get(r);
|
|
2895
2975
|
if (i) {
|
|
2896
|
-
|
|
2976
|
+
gn(e, t, n, i);
|
|
2897
2977
|
return;
|
|
2898
2978
|
}
|
|
2899
|
-
|
|
2979
|
+
fn(e, t, n);
|
|
2900
2980
|
}
|
|
2901
2981
|
}
|
|
2902
|
-
},
|
|
2982
|
+
}, yn = (e) => {
|
|
2903
2983
|
let t = {
|
|
2904
2984
|
tokens: [],
|
|
2905
2985
|
layoutTargets: [],
|
|
@@ -2910,7 +2990,7 @@ var rt = class {
|
|
|
2910
2990
|
layoutTargets: t.layoutTargets,
|
|
2911
2991
|
expressionTarget: R(e, "region-fallback")
|
|
2912
2992
|
};
|
|
2913
|
-
},
|
|
2993
|
+
}, bn = (e) => e.boundary && e.alignment.segments.find((t) => t.speechTokenIds.includes(e.boundary.token.id))?.target || null, xn = .95, Sn = (e) => {
|
|
2914
2994
|
let t = [], n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
2915
2995
|
let r = e.toLowerCase().trim().split(/\s+/).filter(Boolean);
|
|
2916
2996
|
if (r.length === 0) return;
|
|
@@ -2920,7 +3000,7 @@ var rt = class {
|
|
|
2920
3000
|
r(e.normalized);
|
|
2921
3001
|
for (let t of e.spokenAliases) r(t);
|
|
2922
3002
|
return t;
|
|
2923
|
-
},
|
|
3003
|
+
}, Cn = (e, t, n) => {
|
|
2924
3004
|
let r = 0;
|
|
2925
3005
|
for (let i of n) {
|
|
2926
3006
|
if (i.length <= r) continue;
|
|
@@ -2935,12 +3015,12 @@ var rt = class {
|
|
|
2935
3015
|
n && (r = i.length);
|
|
2936
3016
|
}
|
|
2937
3017
|
return r;
|
|
2938
|
-
},
|
|
3018
|
+
}, wn = (e, t) => {
|
|
2939
3019
|
let n = [], r = 0;
|
|
2940
3020
|
for (let i of t) {
|
|
2941
|
-
let t =
|
|
3021
|
+
let t = Sn(i);
|
|
2942
3022
|
if (i.optional) {
|
|
2943
|
-
let a =
|
|
3023
|
+
let a = Cn(e, r, t);
|
|
2944
3024
|
a > 0 && (n.push({
|
|
2945
3025
|
speechTokens: e.slice(r, r + a),
|
|
2946
3026
|
math: i
|
|
@@ -2948,7 +3028,7 @@ var rt = class {
|
|
|
2948
3028
|
continue;
|
|
2949
3029
|
}
|
|
2950
3030
|
for (; r < e.length;) {
|
|
2951
|
-
let a =
|
|
3031
|
+
let a = Cn(e, r, t);
|
|
2952
3032
|
if (a > 0) {
|
|
2953
3033
|
n.push({
|
|
2954
3034
|
speechTokens: e.slice(r, r + a),
|
|
@@ -2960,23 +3040,23 @@ var rt = class {
|
|
|
2960
3040
|
}
|
|
2961
3041
|
}
|
|
2962
3042
|
return n;
|
|
2963
|
-
},
|
|
3043
|
+
}, Tn = (e, t, n) => {
|
|
2964
3044
|
let r = n.filter((e) => !e.optional).length, i = e.filter((e) => !e.math.optional).length, a = e.reduce((e, t) => e + t.speechTokens.length, 0);
|
|
2965
3045
|
return r > 0 && i === r && a === t.length;
|
|
2966
|
-
},
|
|
3046
|
+
}, En = (e) => e.map(({ speechTokens: e, math: t }) => ({
|
|
2967
3047
|
speechTokenIds: e.map((e) => e.id),
|
|
2968
3048
|
mathTokenIds: [t.id],
|
|
2969
3049
|
score: 1,
|
|
2970
3050
|
confidence: 1,
|
|
2971
3051
|
target: t.target
|
|
2972
|
-
})),
|
|
2973
|
-
let t = e.minExactWordConfidence ??
|
|
3052
|
+
})), Dn = (e) => {
|
|
3053
|
+
let t = e.minExactWordConfidence ?? xn, n = wn(e.speech.tokens, e.math.tokens), r = +!!Tn(n, e.speech.tokens, e.math.tokens);
|
|
2974
3054
|
return {
|
|
2975
|
-
segments: r >= t ?
|
|
3055
|
+
segments: r >= t ? En(n) : [],
|
|
2976
3056
|
confidence: r,
|
|
2977
3057
|
fallbackTarget: e.math.expressionTarget
|
|
2978
3058
|
};
|
|
2979
|
-
},
|
|
3059
|
+
}, On = vt(), kn = /* @__PURE__ */ new Map([
|
|
2980
3060
|
["zero", "0"],
|
|
2981
3061
|
["one", "1"],
|
|
2982
3062
|
["two", "2"],
|
|
@@ -2988,17 +3068,17 @@ var rt = class {
|
|
|
2988
3068
|
["eight", "8"],
|
|
2989
3069
|
["nine", "9"],
|
|
2990
3070
|
["ten", "10"]
|
|
2991
|
-
]),
|
|
3071
|
+
]), An = (e) => {
|
|
2992
3072
|
let t = e.toLowerCase();
|
|
2993
|
-
return
|
|
2994
|
-
},
|
|
3073
|
+
return kn.get(t) || t;
|
|
3074
|
+
}, jn = (e) => {
|
|
2995
3075
|
let t = [];
|
|
2996
|
-
for (let n of e.matchAll(
|
|
3076
|
+
for (let n of e.matchAll(On)) {
|
|
2997
3077
|
let e = n[0], r = n.index ?? 0;
|
|
2998
3078
|
t.push({
|
|
2999
3079
|
id: `speech-token-${t.length}`,
|
|
3000
3080
|
text: e,
|
|
3001
|
-
normalized:
|
|
3081
|
+
normalized: An(e),
|
|
3002
3082
|
start: r,
|
|
3003
3083
|
end: r + e.length,
|
|
3004
3084
|
sourceStart: r,
|
|
@@ -3008,21 +3088,21 @@ var rt = class {
|
|
|
3008
3088
|
}
|
|
3009
3089
|
return t;
|
|
3010
3090
|
}, H = (e) => {
|
|
3011
|
-
let t =
|
|
3091
|
+
let t = Lt(e.speechText);
|
|
3012
3092
|
return {
|
|
3013
3093
|
speechText: e.speechText,
|
|
3014
3094
|
spokenText: t.spokenText,
|
|
3015
|
-
tokens:
|
|
3095
|
+
tokens: jn(t.spokenText),
|
|
3016
3096
|
rawToSpokenOffsetMap: t.rawToSpokenOffsetMap,
|
|
3017
3097
|
boundaryOffsetSpace: t.unsupportedSemantic ? "unsupported" : t.hasMarkup ? "raw-ssml" : "plain-spoken-text",
|
|
3018
3098
|
unsupportedSemantic: t.unsupportedSemantic,
|
|
3019
3099
|
hasMarkup: t.hasMarkup
|
|
3020
3100
|
};
|
|
3021
|
-
},
|
|
3101
|
+
}, Mn = (e) => {
|
|
3022
3102
|
if (!e || /^<[^>]+>$/.test(e.trim())) return null;
|
|
3023
|
-
let t = e.match(
|
|
3024
|
-
return t?.[0] ?
|
|
3025
|
-
},
|
|
3103
|
+
let t = e.match(On);
|
|
3104
|
+
return t?.[0] ? An(t[0]) : null;
|
|
3105
|
+
}, Nn = (e, t) => e.find((e) => e.start <= t && t < e.end) || null, Pn = (e, t) => {
|
|
3026
3106
|
let n = e.rawToSpokenOffsetMap.get(t);
|
|
3027
3107
|
if (n !== void 0) return n;
|
|
3028
3108
|
for (let n = t; n < e.speechText.length; n++) {
|
|
@@ -3031,57 +3111,57 @@ var rt = class {
|
|
|
3031
3111
|
if (e.speechText[n] === ">") break;
|
|
3032
3112
|
}
|
|
3033
3113
|
return null;
|
|
3034
|
-
},
|
|
3114
|
+
}, Fn = (e, t, n) => {
|
|
3035
3115
|
if (t === null) return null;
|
|
3036
|
-
let r =
|
|
3116
|
+
let r = Nn(e.tokens, t);
|
|
3037
3117
|
return r ? {
|
|
3038
3118
|
token: r,
|
|
3039
3119
|
start: t,
|
|
3040
3120
|
length: Math.max(1, Math.min(n, r.end - t)),
|
|
3041
3121
|
confidence: .75
|
|
3042
3122
|
} : null;
|
|
3043
|
-
},
|
|
3044
|
-
let n =
|
|
3123
|
+
}, In = (e, t) => {
|
|
3124
|
+
let n = Mn(t);
|
|
3045
3125
|
return !!(e && n && e.token.normalized === n);
|
|
3046
|
-
},
|
|
3126
|
+
}, Ln = (e) => {
|
|
3047
3127
|
if (e.tokenization.boundaryOffsetSpace === "unsupported" || !Number.isFinite(e.position) || e.boundaryWord && /^<[^>]+>$/.test(e.boundaryWord.trim())) return null;
|
|
3048
|
-
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n =
|
|
3049
|
-
return
|
|
3128
|
+
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n = Fn(e.tokenization, Pn(e.tokenization, e.position), t), r = Fn(e.tokenization, e.position >= 0 && e.position < e.tokenization.spokenText.length ? e.position : null, t);
|
|
3129
|
+
return In(n, e.boundaryWord) ? {
|
|
3050
3130
|
...n,
|
|
3051
3131
|
confidence: 1
|
|
3052
|
-
} :
|
|
3132
|
+
} : In(r, e.boundaryWord) ? {
|
|
3053
3133
|
...r,
|
|
3054
3134
|
confidence: 1
|
|
3055
|
-
} : e.boundaryWord &&
|
|
3056
|
-
},
|
|
3135
|
+
} : e.boundaryWord && Mn(e.boundaryWord) ? null : e.tokenization.boundaryOffsetSpace === "raw-ssml" ? n || r : r || n;
|
|
3136
|
+
}, Rn = (e) => {
|
|
3057
3137
|
if (e.tokenization.boundaryOffsetSpace === "unsupported" || !Number.isFinite(e.position) || e.boundaryWord && /^<[^>]+>$/.test(e.boundaryWord.trim())) return null;
|
|
3058
|
-
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n =
|
|
3059
|
-
return
|
|
3138
|
+
let t = Math.max(1, Number.isFinite(e.length) ? e.length : 1), n = Fn(e.tokenization, e.position >= 0 && e.position < e.tokenization.spokenText.length ? e.position : null, t);
|
|
3139
|
+
return In(n, e.boundaryWord) ? {
|
|
3060
3140
|
...n,
|
|
3061
3141
|
confidence: 1
|
|
3062
|
-
} : e.boundaryWord &&
|
|
3063
|
-
},
|
|
3064
|
-
let t = H({ speechText: e.speechText }), n =
|
|
3142
|
+
} : e.boundaryWord && Mn(e.boundaryWord) ? null : n;
|
|
3143
|
+
}, U = (e) => {
|
|
3144
|
+
let t = H({ speechText: e.speechText }), n = yn(e.mathElement);
|
|
3065
3145
|
return {
|
|
3066
3146
|
speech: t,
|
|
3067
3147
|
math: n,
|
|
3068
|
-
result:
|
|
3148
|
+
result: Dn({
|
|
3069
3149
|
speech: t,
|
|
3070
3150
|
math: n
|
|
3071
3151
|
})
|
|
3072
3152
|
};
|
|
3073
|
-
},
|
|
3074
|
-
let n =
|
|
3153
|
+
}, zn = (e, t) => {
|
|
3154
|
+
let n = Rn({
|
|
3075
3155
|
tokenization: e.speech,
|
|
3076
3156
|
position: t.position,
|
|
3077
3157
|
length: t.length,
|
|
3078
3158
|
boundaryWord: t.boundaryWord
|
|
3079
3159
|
});
|
|
3080
|
-
return
|
|
3160
|
+
return bn({
|
|
3081
3161
|
alignment: e.result,
|
|
3082
3162
|
boundary: n
|
|
3083
3163
|
});
|
|
3084
|
-
},
|
|
3164
|
+
}, Bn = (e, t) => {
|
|
3085
3165
|
if (!t.boundaryWord || /^<[^>]+>$/.test(t.boundaryWord.trim())) return null;
|
|
3086
3166
|
let n = H({ speechText: t.boundaryWord }).tokens[0];
|
|
3087
3167
|
if (!n) return null;
|
|
@@ -3090,44 +3170,44 @@ var rt = class {
|
|
|
3090
3170
|
return e.normalized.toLowerCase() === t || e.spokenAliases.some((e) => e.toLowerCase() === t);
|
|
3091
3171
|
});
|
|
3092
3172
|
return r.length === 1 ? r[0].target : null;
|
|
3093
|
-
},
|
|
3173
|
+
}, Vn = "http://www.w3.org/1998/Math/MathML", Hn = /* @__PURE__ */ new Set(/* @__PURE__ */ "math.maction.menclose.merror.mfenced.mfrac.mi.mmultiscripts.mn.mo.mover.mpadded.mphantom.mprescripts.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msubsup.msup.mtable.mtd.mtext.mtr.munder.munderover.none.semantics.annotation.annotation-xml".split(".")), Un = /* @__PURE__ */ new Set(/* @__PURE__ */ "accent.accentunder.align.bevelled.class.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.encoding.fence.height.href.id.largeop.length.linethickness.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.width.xmlns.xml:lang".split(".")), Wn = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), Gn = (e) => Wn(e).replace(/"/g, """), Kn = (e, t) => {
|
|
3094
3174
|
let n = e.toLowerCase(), r = t.trim().toLowerCase();
|
|
3095
|
-
return !!(n.startsWith("on") || !
|
|
3096
|
-
},
|
|
3175
|
+
return !!(n.startsWith("on") || !Un.has(n) || r.includes("javascript:") || r.includes("data:text/html"));
|
|
3176
|
+
}, qn = (e) => {
|
|
3097
3177
|
let t = e.localName.toLowerCase();
|
|
3098
|
-
if (!
|
|
3178
|
+
if (!Hn.has(t)) return !1;
|
|
3099
3179
|
let n = e.namespaceURI;
|
|
3100
|
-
return !n || n ===
|
|
3101
|
-
},
|
|
3102
|
-
if (e.nodeType === Node.TEXT_NODE) return
|
|
3180
|
+
return !n || n === Vn || n === "http://www.w3.org/1999/xhtml";
|
|
3181
|
+
}, Jn = (e) => {
|
|
3182
|
+
if (e.nodeType === Node.TEXT_NODE) return Wn(e.textContent || "");
|
|
3103
3183
|
if (e.nodeType === Node.COMMENT_NODE) return "";
|
|
3104
3184
|
if (e.nodeType !== Node.ELEMENT_NODE) return null;
|
|
3105
3185
|
let t = e;
|
|
3106
|
-
if (!
|
|
3186
|
+
if (!qn(t)) return null;
|
|
3107
3187
|
let n = t.localName.toLowerCase(), r = [];
|
|
3108
3188
|
for (let e of Array.from(t.attributes)) {
|
|
3109
3189
|
let t = e.name.toLowerCase();
|
|
3110
|
-
if (!
|
|
3111
|
-
if (t === "xmlns" && e.value !==
|
|
3112
|
-
r.push(`${t}="${
|
|
3190
|
+
if (!Kn(t, e.value)) {
|
|
3191
|
+
if (t === "xmlns" && e.value !== Vn) return null;
|
|
3192
|
+
r.push(`${t}="${Gn(e.value)}"`);
|
|
3113
3193
|
}
|
|
3114
3194
|
}
|
|
3115
|
-
n === "math" && !r.some((e) => e.startsWith("xmlns=")) && r.unshift(`xmlns="${
|
|
3195
|
+
n === "math" && !r.some((e) => e.startsWith("xmlns=")) && r.unshift(`xmlns="${Vn}"`);
|
|
3116
3196
|
let i = [];
|
|
3117
3197
|
for (let e of Array.from(t.childNodes)) {
|
|
3118
|
-
let t =
|
|
3198
|
+
let t = Jn(e);
|
|
3119
3199
|
if (t === null) return null;
|
|
3120
3200
|
i.push(t);
|
|
3121
3201
|
}
|
|
3122
3202
|
return `<${n}${r.length > 0 ? ` ${r.join(" ")}` : ""}>${i.join("")}</${n}>`;
|
|
3123
|
-
},
|
|
3203
|
+
}, Yn = (e) => typeof DOMParser < "u" ? new DOMParser().parseFromString(e, "application/xml") : null, Xn = (e) => {
|
|
3124
3204
|
let t = String(e || "").trim();
|
|
3125
3205
|
if (!t) return null;
|
|
3126
|
-
let n =
|
|
3206
|
+
let n = Yn(t);
|
|
3127
3207
|
if (!n || n.getElementsByTagName("parsererror").length > 0) return null;
|
|
3128
3208
|
let r = n.documentElement;
|
|
3129
|
-
return !r || r.localName.toLowerCase() !== "math" ? null :
|
|
3130
|
-
},
|
|
3209
|
+
return !r || r.localName.toLowerCase() !== "math" ? null : Jn(r);
|
|
3210
|
+
}, Zn = (e) => ({
|
|
3131
3211
|
chars: [],
|
|
3132
3212
|
map: /* @__PURE__ */ new Map(),
|
|
3133
3213
|
position: 0,
|
|
@@ -3135,28 +3215,28 @@ var rt = class {
|
|
|
3135
3215
|
lastCharWasWhitespace: !1,
|
|
3136
3216
|
lastMapped: null,
|
|
3137
3217
|
options: e
|
|
3138
|
-
}),
|
|
3218
|
+
}), Qn = (e) => e.classList?.contains("MathJax") || e.tagName?.toLowerCase() === "mjx-container", $n = (e) => e.tagName?.toLowerCase() === "mjx-assistive-mml", er = (e) => {
|
|
3139
3219
|
let t = e.tagName?.toLowerCase();
|
|
3140
3220
|
return t === "annotation" || t === "annotation-xml";
|
|
3141
|
-
},
|
|
3221
|
+
}, tr = (e) => {
|
|
3142
3222
|
let t = e.getAttribute("data-mathml");
|
|
3143
3223
|
return t && t.trim() ? t : null;
|
|
3144
|
-
},
|
|
3145
|
-
if (e.tagName.toLowerCase() === "math") return
|
|
3146
|
-
let t =
|
|
3224
|
+
}, nr = (e) => e.querySelector("mjx-assistive-mml math")?.outerHTML || null, rr = (e) => {
|
|
3225
|
+
if (e.tagName.toLowerCase() === "math") return Xn(e.outerHTML);
|
|
3226
|
+
let t = tr(e);
|
|
3147
3227
|
if (t) {
|
|
3148
|
-
let e =
|
|
3228
|
+
let e = Xn(t);
|
|
3149
3229
|
if (e) return e;
|
|
3150
3230
|
}
|
|
3151
|
-
if (
|
|
3152
|
-
let t =
|
|
3231
|
+
if (Qn(e)) {
|
|
3232
|
+
let t = nr(e);
|
|
3153
3233
|
if (t) {
|
|
3154
|
-
let e =
|
|
3234
|
+
let e = Xn(t);
|
|
3155
3235
|
if (e) return e;
|
|
3156
3236
|
}
|
|
3157
3237
|
}
|
|
3158
3238
|
return null;
|
|
3159
|
-
},
|
|
3239
|
+
}, ir = /* @__PURE__ */ new Set([
|
|
3160
3240
|
"P",
|
|
3161
3241
|
"H1",
|
|
3162
3242
|
"H2",
|
|
@@ -3172,7 +3252,7 @@ var rt = class {
|
|
|
3172
3252
|
"FIGCAPTION",
|
|
3173
3253
|
"LABEL",
|
|
3174
3254
|
"BUTTON"
|
|
3175
|
-
]),
|
|
3255
|
+
]), ar = /* @__PURE__ */ new Set([
|
|
3176
3256
|
"heading",
|
|
3177
3257
|
"listitem",
|
|
3178
3258
|
"option",
|
|
@@ -3181,50 +3261,50 @@ var rt = class {
|
|
|
3181
3261
|
"cell",
|
|
3182
3262
|
"columnheader",
|
|
3183
3263
|
"rowheader"
|
|
3184
|
-
]),
|
|
3264
|
+
]), or = (e, t) => {
|
|
3185
3265
|
let n = e.parentElement, r = null;
|
|
3186
3266
|
for (; n && n !== t;) {
|
|
3187
3267
|
let e = (n.getAttribute("role") || "").toLowerCase(), t = n.tagName.toUpperCase();
|
|
3188
|
-
if (
|
|
3268
|
+
if (ir.has(t) || ar.has(e)) {
|
|
3189
3269
|
r = n;
|
|
3190
3270
|
break;
|
|
3191
3271
|
}
|
|
3192
3272
|
n = n.parentElement;
|
|
3193
3273
|
}
|
|
3194
3274
|
return r || t;
|
|
3195
|
-
},
|
|
3275
|
+
}, sr = (e) => !!(typeof e.querySelector == "function" && e.querySelector("math, [data-mathml], .MathJax, mjx-container, mjx-assistive-mml")) || e.tagName?.toLowerCase() === "math" || e.hasAttribute?.("data-mathml") || Qn(e), W = (e, t, n) => {
|
|
3196
3276
|
/[.,;:!?]/.test(t) && e.chars.length > 0 && e.chars[e.chars.length - 1] === " " && (e.chars.pop(), e.position--, e.map.delete(e.position)), e.chars.push(t), n ? (e.map.set(e.position, n), e.lastMapped = n) : e.lastMapped && e.map.set(e.position, e.lastMapped), e.position++;
|
|
3197
|
-
},
|
|
3277
|
+
}, cr = (e, t) => {
|
|
3198
3278
|
if (e.inLeadingWhitespace || e.lastCharWasWhitespace || e.chars.length === 0) return !1;
|
|
3199
3279
|
let n = e.chars[e.chars.length - 1];
|
|
3200
|
-
return
|
|
3201
|
-
},
|
|
3280
|
+
return Ot(n, t, e.options);
|
|
3281
|
+
}, lr = (e, t) => {
|
|
3202
3282
|
let n = t.textContent || "", r = !1;
|
|
3203
3283
|
for (let i = 0; i < n.length; i++) {
|
|
3204
3284
|
let a = n[i], o = /\s/.test(a);
|
|
3205
3285
|
if (e.inLeadingWhitespace) {
|
|
3206
|
-
o || (e.inLeadingWhitespace = !1,
|
|
3286
|
+
o || (e.inLeadingWhitespace = !1, W(e, a, {
|
|
3207
3287
|
node: t,
|
|
3208
3288
|
offset: i
|
|
3209
3289
|
}), r = !0, e.lastCharWasWhitespace = !1);
|
|
3210
3290
|
continue;
|
|
3211
3291
|
}
|
|
3212
3292
|
if (o) {
|
|
3213
|
-
e.lastCharWasWhitespace ||
|
|
3293
|
+
e.lastCharWasWhitespace || W(e, " ", {
|
|
3214
3294
|
node: t,
|
|
3215
3295
|
offset: i
|
|
3216
3296
|
}), e.lastCharWasWhitespace = !0;
|
|
3217
3297
|
continue;
|
|
3218
3298
|
}
|
|
3219
|
-
!r &&
|
|
3299
|
+
!r && cr(e, a) && W(e, " ", {
|
|
3220
3300
|
node: t,
|
|
3221
3301
|
offset: i
|
|
3222
|
-
}),
|
|
3302
|
+
}), W(e, a, {
|
|
3223
3303
|
node: t,
|
|
3224
3304
|
offset: i
|
|
3225
3305
|
}), r = !0, e.lastCharWasWhitespace = !1;
|
|
3226
3306
|
}
|
|
3227
|
-
},
|
|
3307
|
+
}, ur = (e, t) => {
|
|
3228
3308
|
for (let n = 0; n < t.text.length; n++) {
|
|
3229
3309
|
let r = t.text[n], i = /\s/.test(r), a = t.map.get(n) || null, o = a?.node || e.lastMapped?.node || null, s = a?.offset ?? e.lastMapped?.offset ?? 0, c = a ? {
|
|
3230
3310
|
node: a.node,
|
|
@@ -3238,10 +3318,10 @@ var rt = class {
|
|
|
3238
3318
|
e.inLeadingWhitespace = !1;
|
|
3239
3319
|
}
|
|
3240
3320
|
if (i) {
|
|
3241
|
-
e.lastCharWasWhitespace ||
|
|
3321
|
+
e.lastCharWasWhitespace || W(e, " ", c), e.lastCharWasWhitespace = !0;
|
|
3242
3322
|
continue;
|
|
3243
3323
|
}
|
|
3244
|
-
n === 0 &&
|
|
3324
|
+
n === 0 && cr(e, r) && W(e, " ", c), W(e, r, c), e.lastCharWasWhitespace = !1, a ? (e.map.set(e.position - 1, {
|
|
3245
3325
|
node: a.node,
|
|
3246
3326
|
offset: a.offset
|
|
3247
3327
|
}), e.lastMapped = {
|
|
@@ -3252,7 +3332,7 @@ var rt = class {
|
|
|
3252
3332
|
offset: s
|
|
3253
3333
|
});
|
|
3254
3334
|
}
|
|
3255
|
-
},
|
|
3335
|
+
}, dr = (e) => {
|
|
3256
3336
|
if (typeof DOMParser > "u") return "";
|
|
3257
3337
|
let t = new DOMParser().parseFromString(e, "application/xml");
|
|
3258
3338
|
if (t.getElementsByTagName("parsererror").length > 0) return "";
|
|
@@ -3264,36 +3344,36 @@ var rt = class {
|
|
|
3264
3344
|
}
|
|
3265
3345
|
if (e.nodeType !== 1) return;
|
|
3266
3346
|
let t = e;
|
|
3267
|
-
if (!
|
|
3347
|
+
if (!er(t)) for (let e of Array.from(t.childNodes)) r(e);
|
|
3268
3348
|
};
|
|
3269
|
-
return r(t.documentElement),
|
|
3270
|
-
},
|
|
3271
|
-
let r =
|
|
3349
|
+
return r(t.documentElement), M(n.join(" "));
|
|
3350
|
+
}, fr = (e, t, n) => {
|
|
3351
|
+
let r = Zn(n), i = (t) => {
|
|
3272
3352
|
if (N(t, e)) return;
|
|
3273
3353
|
if (t.nodeType === 3) {
|
|
3274
|
-
|
|
3354
|
+
lr(r, t);
|
|
3275
3355
|
return;
|
|
3276
3356
|
}
|
|
3277
3357
|
if (t.nodeType !== 1) return;
|
|
3278
3358
|
let n = t;
|
|
3279
|
-
if (!(
|
|
3359
|
+
if (!($n(n) || er(n))) for (let e of Array.from(n.childNodes)) i(e);
|
|
3280
3360
|
};
|
|
3281
|
-
i(e),
|
|
3282
|
-
let a =
|
|
3361
|
+
i(e), pr(r);
|
|
3362
|
+
let a = M(r.chars.join(""));
|
|
3283
3363
|
if (a) return {
|
|
3284
3364
|
text: a,
|
|
3285
3365
|
map: r.map
|
|
3286
3366
|
};
|
|
3287
|
-
let o =
|
|
3367
|
+
let o = dr(t);
|
|
3288
3368
|
return o ? {
|
|
3289
3369
|
text: o,
|
|
3290
3370
|
map: /* @__PURE__ */ new Map()
|
|
3291
3371
|
} : P(e, n);
|
|
3292
|
-
},
|
|
3372
|
+
}, pr = (e) => {
|
|
3293
3373
|
for (; e.chars.length > 0 && /\s/.test(e.chars[e.chars.length - 1]);) e.chars.pop(), e.position--, e.map.delete(e.position);
|
|
3294
|
-
},
|
|
3295
|
-
let n =
|
|
3296
|
-
let e =
|
|
3374
|
+
}, mr = (e, t) => {
|
|
3375
|
+
let n = Zn(t), r = [], i = 0, a, o = !1, s = () => {
|
|
3376
|
+
let e = M(n.chars.slice(i, n.chars.length).join(""));
|
|
3297
3377
|
e && r.push({
|
|
3298
3378
|
type: "text",
|
|
3299
3379
|
text: e,
|
|
@@ -3302,19 +3382,19 @@ var rt = class {
|
|
|
3302
3382
|
}, c = (l) => {
|
|
3303
3383
|
if (N(l, e)) return;
|
|
3304
3384
|
if (l.nodeType === Node.TEXT_NODE) {
|
|
3305
|
-
let t =
|
|
3306
|
-
a && t !== a && s(), a = t,
|
|
3385
|
+
let t = or(l, e);
|
|
3386
|
+
a && t !== a && s(), a = t, lr(n, l);
|
|
3307
3387
|
return;
|
|
3308
3388
|
}
|
|
3309
3389
|
if (l.nodeType !== Node.ELEMENT_NODE) return;
|
|
3310
3390
|
let u = l;
|
|
3311
|
-
if (
|
|
3312
|
-
let d =
|
|
3391
|
+
if ($n(u)) return;
|
|
3392
|
+
let d = rr(u);
|
|
3313
3393
|
if (d) {
|
|
3314
3394
|
s();
|
|
3315
|
-
let e =
|
|
3316
|
-
|
|
3317
|
-
let a =
|
|
3395
|
+
let e = fr(u, d, t);
|
|
3396
|
+
ur(n, e);
|
|
3397
|
+
let a = M(e.text);
|
|
3318
3398
|
r.push({
|
|
3319
3399
|
type: "math",
|
|
3320
3400
|
mathml: d,
|
|
@@ -3326,7 +3406,7 @@ var rt = class {
|
|
|
3326
3406
|
for (let e of Array.from(u.childNodes)) c(e);
|
|
3327
3407
|
};
|
|
3328
3408
|
for (let t of Array.from(e.childNodes)) c(t);
|
|
3329
|
-
|
|
3409
|
+
pr(n), s();
|
|
3330
3410
|
let l = n.chars.join("");
|
|
3331
3411
|
for (; n.map.has(l.length);) n.map.delete(l.length);
|
|
3332
3412
|
return {
|
|
@@ -3335,8 +3415,8 @@ var rt = class {
|
|
|
3335
3415
|
chunks: r,
|
|
3336
3416
|
containsMathMarkup: o
|
|
3337
3417
|
};
|
|
3338
|
-
},
|
|
3339
|
-
if (
|
|
3418
|
+
}, G = (e, t) => {
|
|
3419
|
+
if (!sr(e)) {
|
|
3340
3420
|
let { text: n, map: r } = P(e, t);
|
|
3341
3421
|
return {
|
|
3342
3422
|
visibleText: n,
|
|
@@ -3348,46 +3428,46 @@ var rt = class {
|
|
|
3348
3428
|
containsMathMarkup: !1
|
|
3349
3429
|
};
|
|
3350
3430
|
}
|
|
3351
|
-
return
|
|
3352
|
-
},
|
|
3431
|
+
return mr(e, t);
|
|
3432
|
+
}, hr = null, gr = Promise.resolve(), _r = (e) => (e || "en").split("-")[0].toLowerCase() || "en", vr = async () => (hr ||= import("./sre-BD1SyGce.js").then((t) => /* @__PURE__ */ e(t.default, 1)).then((e) => {
|
|
3353
3433
|
let t = e.default || e;
|
|
3354
3434
|
if (!t || typeof t.toSpeech != "function") throw Error("speech-rule-engine did not expose toSpeech");
|
|
3355
3435
|
return t;
|
|
3356
|
-
}),
|
|
3357
|
-
if (!
|
|
3358
|
-
let t =
|
|
3436
|
+
}), hr), yr = (e) => e === "en" ? "clearspeak" : "mathspeak", br = (e) => !!e && typeof e == "object" && !Array.isArray(e), xr = (e) => typeof e == "string" && e.trim() ? e.trim() : void 0, K = (e) => {
|
|
3437
|
+
if (!br(e)) return;
|
|
3438
|
+
let t = xr(e.domain), n = xr(e.style), r = br(e.engineOptions) ? e.engineOptions : void 0;
|
|
3359
3439
|
if (!(!t && !n && !r)) return {
|
|
3360
3440
|
...t ? { domain: t } : {},
|
|
3361
3441
|
...n ? { style: n } : {},
|
|
3362
3442
|
...r ? { engineOptions: r } : {}
|
|
3363
3443
|
};
|
|
3364
|
-
},
|
|
3365
|
-
let i =
|
|
3444
|
+
}, Sr = async (e, t, n, r) => {
|
|
3445
|
+
let i = _r(t), a = K(r);
|
|
3366
3446
|
await e.setupEngine?.({
|
|
3367
3447
|
...a?.engineOptions || {},
|
|
3368
3448
|
locale: i,
|
|
3369
|
-
domain: a?.domain ||
|
|
3449
|
+
domain: a?.domain || yr(i),
|
|
3370
3450
|
...a?.style ? { style: a.style } : {},
|
|
3371
3451
|
modality: "speech",
|
|
3372
3452
|
markup: n
|
|
3373
3453
|
}), await e.engineReady?.();
|
|
3374
|
-
},
|
|
3375
|
-
let t =
|
|
3376
|
-
return
|
|
3377
|
-
},
|
|
3454
|
+
}, Cr = async (e) => {
|
|
3455
|
+
let t = gr.then(e, e);
|
|
3456
|
+
return gr = t.then(() => void 0, () => void 0), t;
|
|
3457
|
+
}, wr = async (e, t, n, r, i) => Cr(async () => (await Sr(e, n, r, i), e.toSpeech(t))), Tr = (e) => e.replace(/^\s*<\?xml[^>]*\?>\s*/i, ""), Er = async (e, t, n, r) => {
|
|
3378
3458
|
try {
|
|
3379
|
-
let i =
|
|
3459
|
+
let i = Tr(await wr(e, t, n, "ssml", r));
|
|
3380
3460
|
return i.includes("<speak") ? i : null;
|
|
3381
3461
|
} catch (e) {
|
|
3382
3462
|
return console.debug("[TTSService] Math SSML generation failed; using plain", { message: e instanceof Error ? e.message : String(e) }), null;
|
|
3383
3463
|
}
|
|
3384
|
-
},
|
|
3464
|
+
}, Dr = async (e, t = {}) => {
|
|
3385
3465
|
if (!e.some((e) => e.type === "math")) return {
|
|
3386
|
-
speechText:
|
|
3466
|
+
speechText: M(e.map((e) => e.type === "text" ? e.text : e.fallbackText).join(" ")),
|
|
3387
3467
|
usedMathSpeech: !1,
|
|
3388
3468
|
usedFallback: !1
|
|
3389
3469
|
};
|
|
3390
|
-
let n = null, r = !1, i = !1, a = t.loadSre ||
|
|
3470
|
+
let n = null, r = !1, i = !1, a = t.loadSre || vr, o = [];
|
|
3391
3471
|
for (let s of e) {
|
|
3392
3472
|
if (s.type === "text") {
|
|
3393
3473
|
o.push(s.text);
|
|
@@ -3395,7 +3475,7 @@ var rt = class {
|
|
|
3395
3475
|
}
|
|
3396
3476
|
try {
|
|
3397
3477
|
n ||= await a();
|
|
3398
|
-
let e =
|
|
3478
|
+
let e = M(await wr(n, s.mathml, t.language, "none", t.mathSpeech));
|
|
3399
3479
|
if (e) {
|
|
3400
3480
|
o.push(e), r = !0;
|
|
3401
3481
|
continue;
|
|
@@ -3405,14 +3485,14 @@ var rt = class {
|
|
|
3405
3485
|
i = !0, console.debug("[TTSService] Math speech generation failed; using visible fallback", { message: e instanceof Error ? e.message : String(e) }), o.push(s.fallbackText);
|
|
3406
3486
|
}
|
|
3407
3487
|
}
|
|
3408
|
-
let s =
|
|
3409
|
-
return t.produceSsml && n && r && e.length === 1 && e[0].type === "math" && (c = await
|
|
3488
|
+
let s = M(o.join(" ")), c;
|
|
3489
|
+
return t.produceSsml && n && r && e.length === 1 && e[0].type === "math" && (c = await Er(n, e[0].mathml, t.language, t.mathSpeech) ?? void 0), {
|
|
3410
3490
|
speechText: s,
|
|
3411
3491
|
usedMathSpeech: r,
|
|
3412
3492
|
usedFallback: i,
|
|
3413
3493
|
ssml: c
|
|
3414
3494
|
};
|
|
3415
|
-
},
|
|
3495
|
+
}, Or = (e, t) => Dr([e], t), kr = (e) => (e || "en").split("-")[0].toLowerCase() || "en", Ar = /* @__PURE__ */ new Set([
|
|
3416
3496
|
"H1",
|
|
3417
3497
|
"H2",
|
|
3418
3498
|
"H3",
|
|
@@ -3422,18 +3502,18 @@ var rt = class {
|
|
|
3422
3502
|
"LI",
|
|
3423
3503
|
"LABEL",
|
|
3424
3504
|
"BUTTON"
|
|
3425
|
-
]),
|
|
3505
|
+
]), jr = /* @__PURE__ */ new Set([
|
|
3426
3506
|
"heading",
|
|
3427
3507
|
"listitem",
|
|
3428
3508
|
"option",
|
|
3429
3509
|
"radio"
|
|
3430
|
-
]),
|
|
3510
|
+
]), Mr = (e) => {
|
|
3431
3511
|
if (e.type !== "text" || !e.sourceElement) return !1;
|
|
3432
3512
|
let t = e.sourceElement.tagName.toUpperCase(), n = (e.sourceElement.getAttribute("role") || "").toLowerCase();
|
|
3433
|
-
return
|
|
3434
|
-
},
|
|
3435
|
-
let t = e.resolveMathSpeech ??
|
|
3436
|
-
let t =
|
|
3513
|
+
return Ar.has(t) || jr.has(n);
|
|
3514
|
+
}, Nr = async (e) => {
|
|
3515
|
+
let t = e.resolveMathSpeech ?? Or, { visibleText: n } = e, r = [], i = 0, a = (e) => {
|
|
3516
|
+
let t = M(e), r = n.indexOf(t, i), a = r >= 0 ? r : i, o = a + t.length;
|
|
3437
3517
|
return i = o, {
|
|
3438
3518
|
start: a,
|
|
3439
3519
|
end: o
|
|
@@ -3442,12 +3522,12 @@ var rt = class {
|
|
|
3442
3522
|
for (let n = 0; n < e.chunks.length; n++) {
|
|
3443
3523
|
let i = e.chunks[n];
|
|
3444
3524
|
if (i.type === "text") {
|
|
3445
|
-
let t =
|
|
3525
|
+
let t = Mr(i) ? [{
|
|
3446
3526
|
text: i.text,
|
|
3447
3527
|
offset: 0
|
|
3448
|
-
}] :
|
|
3528
|
+
}] : A(i.text, { locale: e.language });
|
|
3449
3529
|
for (let e of t) {
|
|
3450
|
-
let t =
|
|
3530
|
+
let t = M(e.text);
|
|
3451
3531
|
if (!t) continue;
|
|
3452
3532
|
let i = a(t);
|
|
3453
3533
|
r.push({
|
|
@@ -3482,37 +3562,37 @@ var rt = class {
|
|
|
3482
3562
|
}
|
|
3483
3563
|
return {
|
|
3484
3564
|
segments: r,
|
|
3485
|
-
locale:
|
|
3565
|
+
locale: kr(e.language),
|
|
3486
3566
|
visibleText: n,
|
|
3487
|
-
plainSpeechText:
|
|
3567
|
+
plainSpeechText: M(o.join(" "))
|
|
3488
3568
|
};
|
|
3489
|
-
},
|
|
3490
|
-
let t = Math.max(1, e.maxEntries ??
|
|
3569
|
+
}, Pr = (e) => (e || "en").split("-")[0].toLowerCase() || "en", Fr = "sre-v1", Ir = 256, Lr = (e) => Array.isArray(e) ? `array:[${e.map(Lr).join(",")}]` : e && typeof e == "object" ? `object:{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${JSON.stringify(e)}:${Lr(t)}`).join(",")}}` : e === null ? "null:null" : e === void 0 ? "undefined:" : typeof e == "function" ? `function:${e.name || "anonymous"}` : typeof e == "symbol" ? `symbol:${String(e)}` : typeof e == "bigint" ? `bigint:${e.toString()}` : typeof e == "number" ? Number.isFinite(e) ? `number:${e}` : `number:${String(e)}` : `${typeof e}:${JSON.stringify(e)}`, Rr = (e, t, n, r) => `${Fr}\u0000${Pr(e)}\u0000${t ? "ssml" : "plain"}\u0000${Lr(n ?? null)}\u0000${r}`, zr = (e = {}) => {
|
|
3570
|
+
let t = Math.max(1, e.maxEntries ?? Ir), n = e.resolve ?? ((e, t) => Dr([e], t)), r = /* @__PURE__ */ new Map(), i = (e, n) => {
|
|
3491
3571
|
for (r.delete(e), r.set(e, n); r.size > t;) {
|
|
3492
3572
|
let e = r.keys().next().value;
|
|
3493
3573
|
e !== void 0 && r.delete(e);
|
|
3494
3574
|
}
|
|
3495
3575
|
};
|
|
3496
3576
|
return async (e, a) => {
|
|
3497
|
-
let o =
|
|
3577
|
+
let o = K(a.mathSpeech), s = a.produceSsml === !0, c = Rr(a.language, s, o, e.mathml), l = r.get(c);
|
|
3498
3578
|
if (l) return r.delete(c), r.set(c, l), l;
|
|
3499
3579
|
let u = await n(e, {
|
|
3500
3580
|
...a,
|
|
3501
3581
|
mathSpeech: o
|
|
3502
3582
|
});
|
|
3503
|
-
return s && u.ssml && t > 1 && i(
|
|
3583
|
+
return s && u.ssml && t > 1 && i(Rr(a.language, !1, o, e.mathml), {
|
|
3504
3584
|
speechText: u.speechText,
|
|
3505
3585
|
usedMathSpeech: u.usedMathSpeech,
|
|
3506
3586
|
usedFallback: u.usedFallback
|
|
3507
3587
|
}), i(c, u), u;
|
|
3508
3588
|
};
|
|
3509
|
-
},
|
|
3589
|
+
}, Br = (e) => !e || /^<[^>]+>$/.test(e.trim()) ? null : H({ speechText: e }).tokens[0]?.normalized || null, Vr = (e, t) => {
|
|
3510
3590
|
let n = H({ speechText: e.speechText });
|
|
3511
3591
|
if (!Number.isFinite(t.position)) return {
|
|
3512
3592
|
boundary: null,
|
|
3513
3593
|
spokenText: n.spokenText
|
|
3514
3594
|
};
|
|
3515
|
-
let r =
|
|
3595
|
+
let r = Ln({
|
|
3516
3596
|
tokenization: n,
|
|
3517
3597
|
position: t.position,
|
|
3518
3598
|
length: t.length,
|
|
@@ -3525,8 +3605,8 @@ var rt = class {
|
|
|
3525
3605
|
} : null,
|
|
3526
3606
|
spokenText: n.spokenText
|
|
3527
3607
|
};
|
|
3528
|
-
},
|
|
3529
|
-
let n =
|
|
3608
|
+
}, Hr = (e, t, n) => !n || H({ speechText: e }).tokens.find((e) => e.start <= t && t < e.end)?.normalized === n, Ur = (e, t) => {
|
|
3609
|
+
let n = Br(t.word);
|
|
3530
3610
|
if (e.id !== t.chunkId) return {
|
|
3531
3611
|
chunkId: t.chunkId,
|
|
3532
3612
|
normalizedWord: n,
|
|
@@ -3544,12 +3624,12 @@ var rt = class {
|
|
|
3544
3624
|
reason: "boundary offset space is unsupported"
|
|
3545
3625
|
};
|
|
3546
3626
|
let r, i;
|
|
3547
|
-
if (e.catalogAlignment) r =
|
|
3627
|
+
if (e.catalogAlignment) r = $t(e.catalogAlignment, t.position, t.length, t.word), i = e.catalogAlignment.spokenText;
|
|
3548
3628
|
else {
|
|
3549
|
-
let n =
|
|
3629
|
+
let n = Vr(e, t);
|
|
3550
3630
|
r = n.boundary, i = n.spokenText;
|
|
3551
3631
|
}
|
|
3552
|
-
return r ?
|
|
3632
|
+
return r ? Hr(i, r.start, n) ? {
|
|
3553
3633
|
chunkId: e.id,
|
|
3554
3634
|
normalizedWord: n,
|
|
3555
3635
|
chunkSpokenStart: r.start,
|
|
@@ -3571,7 +3651,7 @@ var rt = class {
|
|
|
3571
3651
|
confidence: 0,
|
|
3572
3652
|
reason: "could not resolve provider boundary to chunk speech"
|
|
3573
3653
|
};
|
|
3574
|
-
},
|
|
3654
|
+
}, q = (e) => e.semanticTarget ? {
|
|
3575
3655
|
activeTarget: e.semanticTarget,
|
|
3576
3656
|
regionTarget: e.regionTarget,
|
|
3577
3657
|
quality: e.semanticTarget.quality === "exact-word" ? "exact-word" : e.semanticTarget.quality === "expression" ? "expression" : "semantic-token",
|
|
@@ -3589,12 +3669,12 @@ var rt = class {
|
|
|
3589
3669
|
quality: "region",
|
|
3590
3670
|
confidence: e.confidence,
|
|
3591
3671
|
reason: e.reason
|
|
3592
|
-
},
|
|
3672
|
+
}, Wr = /* @__PURE__ */ new Map([
|
|
3593
3673
|
["mi", "mjx-mi"],
|
|
3594
3674
|
["mn", "mjx-mn"],
|
|
3595
3675
|
["mo", "mjx-mo"],
|
|
3596
3676
|
["mtext", "mjx-mtext"]
|
|
3597
|
-
]),
|
|
3677
|
+
]), Gr = "mi,mn,mo,mtext", Kr = "mjx-mi,mjx-mn,mjx-mo,mjx-mtext", qr = [
|
|
3598
3678
|
"mjx-mfrac",
|
|
3599
3679
|
"mjx-msqrt",
|
|
3600
3680
|
"mjx-mroot",
|
|
@@ -3602,55 +3682,55 @@ var rt = class {
|
|
|
3602
3682
|
"mjx-munder",
|
|
3603
3683
|
"mjx-mover",
|
|
3604
3684
|
"mjx-munderover"
|
|
3605
|
-
].join(","),
|
|
3685
|
+
].join(","), Jr = (e) => e.type === "text-range" ? e.node.parentElement : e.element, J = (e) => {
|
|
3606
3686
|
let t = e;
|
|
3607
3687
|
for (; t;) {
|
|
3608
3688
|
if (t.localName?.toLowerCase() === "mjx-container") return t;
|
|
3609
3689
|
t = t.parentElement;
|
|
3610
3690
|
}
|
|
3611
3691
|
return null;
|
|
3612
|
-
},
|
|
3692
|
+
}, Yr = (e) => !e || J(e) ? !1 : !bt(e), Xr = (e) => {
|
|
3613
3693
|
let t = e.getBoundingClientRect?.();
|
|
3614
3694
|
return !!(t && t.width > 0 && t.height > 0);
|
|
3615
|
-
},
|
|
3695
|
+
}, Zr = (e) => {
|
|
3616
3696
|
let t = e;
|
|
3617
3697
|
for (; t;) {
|
|
3618
3698
|
if (t.localName?.toLowerCase() === "math") return t;
|
|
3619
3699
|
t = t.parentElement;
|
|
3620
3700
|
}
|
|
3621
3701
|
return null;
|
|
3622
|
-
},
|
|
3702
|
+
}, Qr = (e, t) => {
|
|
3623
3703
|
if (e.length === 0 || e.length !== t.length) return !1;
|
|
3624
3704
|
for (let n = 0; n < e.length; n += 1) {
|
|
3625
|
-
let r =
|
|
3705
|
+
let r = Wr.get(e[n].localName.toLowerCase());
|
|
3626
3706
|
if (!r || t[n].localName.toLowerCase() !== r) return !1;
|
|
3627
3707
|
}
|
|
3628
3708
|
return !0;
|
|
3629
|
-
},
|
|
3630
|
-
if (!e || !
|
|
3631
|
-
let n =
|
|
3709
|
+
}, $r = (e, t) => {
|
|
3710
|
+
if (!e || !Wr.has(e.localName.toLowerCase()) || t.querySelector(qr)) return null;
|
|
3711
|
+
let n = Zr(e), r = t.querySelector("mjx-math");
|
|
3632
3712
|
if (!n || !r) return null;
|
|
3633
|
-
let i = Array.from(n.querySelectorAll(
|
|
3713
|
+
let i = Array.from(n.querySelectorAll(Gr)), a = i.indexOf(e);
|
|
3634
3714
|
if (a < 0) return null;
|
|
3635
|
-
let o = Array.from(r.querySelectorAll(
|
|
3636
|
-
if (!
|
|
3715
|
+
let o = Array.from(r.querySelectorAll(Kr));
|
|
3716
|
+
if (!Qr(i, o)) return null;
|
|
3637
3717
|
let s = o[a];
|
|
3638
|
-
return !s || !
|
|
3639
|
-
},
|
|
3640
|
-
let t =
|
|
3718
|
+
return !s || !Xr(s) ? null : s;
|
|
3719
|
+
}, ei = (e) => {
|
|
3720
|
+
let t = J(e);
|
|
3641
3721
|
if (t) {
|
|
3642
|
-
if (t.querySelector(
|
|
3643
|
-
let n =
|
|
3722
|
+
if (t.querySelector(qr)) return "expression";
|
|
3723
|
+
let n = Zr(e) ?? e, r = t.querySelector("mjx-math");
|
|
3644
3724
|
if (!r) return "expression";
|
|
3645
|
-
let i = Array.from(n.querySelectorAll(
|
|
3646
|
-
return
|
|
3725
|
+
let i = Array.from(n.querySelectorAll(Gr)), a = Array.from(r.querySelectorAll(Kr));
|
|
3726
|
+
return Qr(i, a) && a.some((e) => Xr(e)) ? "token" : "expression";
|
|
3647
3727
|
}
|
|
3648
|
-
let n =
|
|
3649
|
-
return Array.from(n.querySelectorAll(
|
|
3650
|
-
},
|
|
3651
|
-
let t =
|
|
3728
|
+
let n = Zr(e) ?? e;
|
|
3729
|
+
return Array.from(n.querySelectorAll(Gr)).some((e) => !bt(e)) ? "token" : "expression";
|
|
3730
|
+
}, Y = (e) => {
|
|
3731
|
+
let t = Jr(e), n = J(t);
|
|
3652
3732
|
if (n) {
|
|
3653
|
-
let e =
|
|
3733
|
+
let e = $r(t, n);
|
|
3654
3734
|
return e ? {
|
|
3655
3735
|
type: "element",
|
|
3656
3736
|
quality: "semantic-token",
|
|
@@ -3661,35 +3741,35 @@ var rt = class {
|
|
|
3661
3741
|
element: n
|
|
3662
3742
|
};
|
|
3663
3743
|
}
|
|
3664
|
-
return e.type === "text-range" ?
|
|
3744
|
+
return e.type === "text-range" ? Yr(e.node.parentElement) ? {
|
|
3665
3745
|
type: "text-range",
|
|
3666
3746
|
quality: "semantic-token",
|
|
3667
3747
|
node: e.node,
|
|
3668
3748
|
startOffset: e.startOffset,
|
|
3669
3749
|
endOffset: e.endOffset
|
|
3670
|
-
} : null :
|
|
3750
|
+
} : null : Yr(e.element) ? {
|
|
3671
3751
|
type: "element",
|
|
3672
3752
|
quality: e.quality === "region-fallback" ? "expression" : "semantic-token",
|
|
3673
3753
|
element: e.element
|
|
3674
3754
|
} : null;
|
|
3675
|
-
},
|
|
3755
|
+
}, ti = Y, ni = () => {
|
|
3676
3756
|
let e = /* @__PURE__ */ new WeakMap();
|
|
3677
3757
|
return (t) => {
|
|
3678
|
-
let n =
|
|
3679
|
-
if (!n || !r) return
|
|
3758
|
+
let n = Jr(t), r = J(n);
|
|
3759
|
+
if (!n || !r) return Y(t);
|
|
3680
3760
|
if (e.has(n)) return e.get(n) ?? null;
|
|
3681
|
-
let i =
|
|
3761
|
+
let i = Y(t);
|
|
3682
3762
|
return e.set(n, i), i;
|
|
3683
3763
|
};
|
|
3684
|
-
},
|
|
3764
|
+
}, ri = (e, t, n, r = e.mathAlignments, i = ti) => {
|
|
3685
3765
|
if (t.chunkSpokenStart === null || t.chunkSpokenEnd === null) return null;
|
|
3686
3766
|
let a = null;
|
|
3687
3767
|
for (let e of r) {
|
|
3688
|
-
let r =
|
|
3768
|
+
let r = zn(e.alignment, {
|
|
3689
3769
|
position: t.chunkSpokenStart,
|
|
3690
3770
|
length: Math.max(1, t.chunkSpokenEnd - t.chunkSpokenStart),
|
|
3691
3771
|
boundaryWord: n.word
|
|
3692
|
-
}) ||
|
|
3772
|
+
}) || Bn(e.alignment, { boundaryWord: n.word });
|
|
3693
3773
|
if (!r) continue;
|
|
3694
3774
|
let o = i(r);
|
|
3695
3775
|
if (o) {
|
|
@@ -3698,7 +3778,7 @@ var rt = class {
|
|
|
3698
3778
|
}
|
|
3699
3779
|
}
|
|
3700
3780
|
return a;
|
|
3701
|
-
},
|
|
3781
|
+
}, ii = (e, t, n) => {
|
|
3702
3782
|
if (!e || typeof document > "u" || n <= t) return null;
|
|
3703
3783
|
let r = e.get(t), i = e.get(Math.max(t, n - 1));
|
|
3704
3784
|
if (!r) return null;
|
|
@@ -3709,17 +3789,17 @@ var rt = class {
|
|
|
3709
3789
|
} catch {
|
|
3710
3790
|
return null;
|
|
3711
3791
|
}
|
|
3712
|
-
},
|
|
3792
|
+
}, ai = (e, t) => {
|
|
3713
3793
|
if (!e.catalogAlignment || t.chunkSpokenStart === null) return null;
|
|
3714
|
-
let n =
|
|
3794
|
+
let n = en(e.catalogAlignment, t.chunkSpokenStart);
|
|
3715
3795
|
if (!n) return null;
|
|
3716
|
-
let r =
|
|
3796
|
+
let r = ii(e.visibleMap, n.start, n.end);
|
|
3717
3797
|
return r ? {
|
|
3718
3798
|
type: "range",
|
|
3719
3799
|
quality: e.catalogAlignment.playbackMode === "exact-word" ? "exact-word" : "semantic-token",
|
|
3720
3800
|
range: r
|
|
3721
3801
|
} : null;
|
|
3722
|
-
},
|
|
3802
|
+
}, oi = (e) => e.regionRange ? {
|
|
3723
3803
|
type: "range",
|
|
3724
3804
|
quality: "region",
|
|
3725
3805
|
range: e.regionRange
|
|
@@ -3727,43 +3807,43 @@ var rt = class {
|
|
|
3727
3807
|
type: "element",
|
|
3728
3808
|
quality: "region",
|
|
3729
3809
|
element: e.regionElement
|
|
3730
|
-
} : null,
|
|
3810
|
+
} : null, si = (e, t = e.chunk.mathAlignments) => {
|
|
3731
3811
|
if (t.length !== 1) return null;
|
|
3732
3812
|
let n = t[0]?.alignment.result.fallbackTarget;
|
|
3733
3813
|
return n ? e.renderedMathTargetResolver(n) : null;
|
|
3734
|
-
},
|
|
3814
|
+
}, ci = (e, t) => e ? t.mathAlignments.filter(({ element: t }) => {
|
|
3735
3815
|
try {
|
|
3736
3816
|
return e.type === "range" ? e.range.intersectsNode(t) : e.type === "element" ? e.element === t || e.element.contains(t) : e.node.parentElement?.contains(t) || !1;
|
|
3737
3817
|
} catch {
|
|
3738
3818
|
return !1;
|
|
3739
3819
|
}
|
|
3740
|
-
}) : t.mathAlignments,
|
|
3820
|
+
}) : t.mathAlignments, li = () => ({
|
|
3741
3821
|
activeTarget: null,
|
|
3742
3822
|
regionTarget: null,
|
|
3743
3823
|
quality: "region",
|
|
3744
3824
|
confidence: 0,
|
|
3745
3825
|
reason: "boundary chunk id was not found"
|
|
3746
|
-
}),
|
|
3826
|
+
}), ui = (e) => e.length === 1 ? e[0].element : null, di = (e, t) => t.length > 0 && t.every(({ element: t }) => e.mathCapabilityByElement.get(t) === "token"), fi = 3, pi = (e, t, n) => {
|
|
3747
3827
|
if (!t || t.type !== "range") return !1;
|
|
3748
3828
|
let { startContainer: r, endContainer: i } = t.range;
|
|
3749
|
-
return r === i && r.nodeType ===
|
|
3750
|
-
},
|
|
3829
|
+
return r === i && r.nodeType === fi ? !1 : n.some(({ element: t }) => e.mathCapabilityByElement.get(t) === "token" && t.contains(r) && t.contains(i));
|
|
3830
|
+
}, mi = (e, t) => ({
|
|
3751
3831
|
chunk: e,
|
|
3752
|
-
regionTarget:
|
|
3753
|
-
renderedMathTargetResolver:
|
|
3754
|
-
mathCapabilityByElement: new Map(e.mathAlignments.map(({ element: e }) => [e, t ?
|
|
3832
|
+
regionTarget: oi(e),
|
|
3833
|
+
renderedMathTargetResolver: ni(),
|
|
3834
|
+
mathCapabilityByElement: new Map(e.mathAlignments.map(({ element: e }) => [e, t ? ei(e) : "expression"])),
|
|
3755
3835
|
heldTokenByElement: /* @__PURE__ */ new Map()
|
|
3756
|
-
}),
|
|
3757
|
-
let t = e.mathTokenHighlighting !== !1, n = new Map(e.chunks.map((e) => [e.id,
|
|
3836
|
+
}), hi = (e) => {
|
|
3837
|
+
let t = e.mathTokenHighlighting !== !1, n = new Map(e.chunks.map((e) => [e.id, mi(e, t)]));
|
|
3758
3838
|
return {
|
|
3759
3839
|
chunks: e.chunks,
|
|
3760
3840
|
resolveInitial(e) {
|
|
3761
3841
|
let t = n.get(e);
|
|
3762
|
-
if (!t) return
|
|
3842
|
+
if (!t) return li();
|
|
3763
3843
|
let r = t.chunk.mathAlignments, i = r.length === 1 ? r[0].element : null, a = i ? t.mathCapabilityByElement.get(i) : null;
|
|
3764
|
-
return
|
|
3844
|
+
return q(a === "expression" ? {
|
|
3765
3845
|
semanticTarget: null,
|
|
3766
|
-
expressionTarget:
|
|
3846
|
+
expressionTarget: si(t),
|
|
3767
3847
|
regionTarget: t.regionTarget,
|
|
3768
3848
|
confidence: .5,
|
|
3769
3849
|
reason: "initial expression (sticky expression mode)"
|
|
@@ -3777,11 +3857,11 @@ var rt = class {
|
|
|
3777
3857
|
},
|
|
3778
3858
|
resolveBoundary(e) {
|
|
3779
3859
|
let r = n.get(e.chunkId);
|
|
3780
|
-
if (!r) return
|
|
3781
|
-
let { chunk: i } = r, a =
|
|
3860
|
+
if (!r) return li();
|
|
3861
|
+
let { chunk: i } = r, a = Ur(i, e), o = ai(i, a), s = ci(o, i), c = (!o || s.length > 0 ? ri(i, a, e, s, r.renderedMathTargetResolver) : null) || null, l = t && c && c.quality !== "expression" ? c : null, u = c && c.quality === "expression" ? c : null;
|
|
3782
3862
|
if (l) {
|
|
3783
|
-
let e =
|
|
3784
|
-
return e && r.heldTokenByElement.set(e, l),
|
|
3863
|
+
let e = ui(s);
|
|
3864
|
+
return e && r.heldTokenByElement.set(e, l), q({
|
|
3785
3865
|
semanticTarget: l,
|
|
3786
3866
|
expressionTarget: null,
|
|
3787
3867
|
regionTarget: r.regionTarget,
|
|
@@ -3789,16 +3869,16 @@ var rt = class {
|
|
|
3789
3869
|
reason: a.reason
|
|
3790
3870
|
});
|
|
3791
3871
|
}
|
|
3792
|
-
if (o && (t ? !
|
|
3872
|
+
if (o && (t ? !pi(r, o, s) : s.length === 0)) return q({
|
|
3793
3873
|
semanticTarget: o,
|
|
3794
3874
|
expressionTarget: null,
|
|
3795
3875
|
regionTarget: r.regionTarget,
|
|
3796
3876
|
confidence: a.confidence,
|
|
3797
3877
|
reason: a.reason
|
|
3798
3878
|
});
|
|
3799
|
-
if (
|
|
3800
|
-
let e =
|
|
3801
|
-
return
|
|
3879
|
+
if (di(r, s)) {
|
|
3880
|
+
let e = ui(s), t = e ? r.heldTokenByElement.get(e) ?? null : null;
|
|
3881
|
+
return q({
|
|
3802
3882
|
semanticTarget: t,
|
|
3803
3883
|
expressionTarget: null,
|
|
3804
3884
|
regionTarget: r.regionTarget,
|
|
@@ -3806,19 +3886,19 @@ var rt = class {
|
|
|
3806
3886
|
reason: t ? "hold last token (sticky token mode)" : "region (sticky token mode, awaiting first token)"
|
|
3807
3887
|
});
|
|
3808
3888
|
}
|
|
3809
|
-
return
|
|
3889
|
+
return q({
|
|
3810
3890
|
semanticTarget: null,
|
|
3811
|
-
expressionTarget: u ??
|
|
3891
|
+
expressionTarget: u ?? si(r, s),
|
|
3812
3892
|
regionTarget: r.regionTarget,
|
|
3813
3893
|
confidence: a.confidence,
|
|
3814
3894
|
reason: a.reason
|
|
3815
3895
|
});
|
|
3816
3896
|
}
|
|
3817
3897
|
};
|
|
3818
|
-
},
|
|
3898
|
+
}, gi = (e) => e.alignment?.boundaryOffsetMode ? e.alignment.boundaryOffsetMode : e.mathAlignment?.speech.boundaryOffsetSpace || "plain-spoken-text", _i = (e) => e.mathAlignments?.length ? e.mathAlignments : e.mathAlignment && e.sourceElement ? [{
|
|
3819
3899
|
element: e.sourceElement,
|
|
3820
3900
|
alignment: e.mathAlignment
|
|
3821
|
-
}] : [],
|
|
3901
|
+
}] : [], vi = (e) => (e.chunks && e.chunks.length ? e.chunks : [{
|
|
3822
3902
|
speechText: e.speechText || "",
|
|
3823
3903
|
visibleText: e.visibleText || e.speechText || "",
|
|
3824
3904
|
sourceElement: e.sourceElement || e.contentRoot,
|
|
@@ -3835,9 +3915,9 @@ var rt = class {
|
|
|
3835
3915
|
regionRange: t.regionRange,
|
|
3836
3916
|
visibleMap: t.visibleMap,
|
|
3837
3917
|
catalogAlignment: t.alignment,
|
|
3838
|
-
mathAlignments:
|
|
3839
|
-
offsetSpace:
|
|
3840
|
-
})),
|
|
3918
|
+
mathAlignments: _i(t),
|
|
3919
|
+
offsetSpace: gi(t)
|
|
3920
|
+
})), yi = [
|
|
3841
3921
|
"[data-pie-tts-region]",
|
|
3842
3922
|
"[data-catalog-region]",
|
|
3843
3923
|
"li",
|
|
@@ -3847,18 +3927,18 @@ var rt = class {
|
|
|
3847
3927
|
"[role='group']",
|
|
3848
3928
|
"[role='region']",
|
|
3849
3929
|
"div"
|
|
3850
|
-
].join(","),
|
|
3851
|
-
let n = e.closest(
|
|
3930
|
+
].join(","), bi = (e, t) => {
|
|
3931
|
+
let n = e.closest(yi);
|
|
3852
3932
|
return n && t.contains(n) ? n : e;
|
|
3853
|
-
},
|
|
3933
|
+
}, xi = (e, t, n) => {
|
|
3854
3934
|
let r = /* @__PURE__ */ new Map();
|
|
3855
3935
|
for (let i = t; i < n; i++) {
|
|
3856
3936
|
let n = e.get(i);
|
|
3857
3937
|
n && r.set(i - t, n);
|
|
3858
3938
|
}
|
|
3859
3939
|
return r;
|
|
3860
|
-
},
|
|
3861
|
-
let t =
|
|
3940
|
+
}, Si = async (e) => {
|
|
3941
|
+
let t = G(e.contentRoot, e.textProcessingOptions), n = await Nr({
|
|
3862
3942
|
chunks: t.chunks,
|
|
3863
3943
|
visibleText: t.visibleText,
|
|
3864
3944
|
language: e.language,
|
|
@@ -3876,8 +3956,8 @@ var rt = class {
|
|
|
3876
3956
|
segment: n,
|
|
3877
3957
|
anchor: {
|
|
3878
3958
|
sourceElement: r,
|
|
3879
|
-
regionElement:
|
|
3880
|
-
visibleMap:
|
|
3959
|
+
regionElement: bi(r, e.contentRoot),
|
|
3960
|
+
visibleMap: xi(t.map, n.visibleSpan.start, n.visibleSpan.end)
|
|
3881
3961
|
}
|
|
3882
3962
|
};
|
|
3883
3963
|
}
|
|
@@ -3897,8 +3977,8 @@ var rt = class {
|
|
|
3897
3977
|
containsMathMarkup: t.containsMathMarkup,
|
|
3898
3978
|
visibleText: t.visibleText
|
|
3899
3979
|
};
|
|
3900
|
-
},
|
|
3901
|
-
let n =
|
|
3980
|
+
}, Ci = (e, t) => {
|
|
3981
|
+
let n = Kt({
|
|
3902
3982
|
speechText: e.spokenText,
|
|
3903
3983
|
visibleText: e.spokenText
|
|
3904
3984
|
});
|
|
@@ -3907,13 +3987,13 @@ var rt = class {
|
|
|
3907
3987
|
visibleText: e.visibleText,
|
|
3908
3988
|
sourceElement: t.sourceElement,
|
|
3909
3989
|
regionElement: t.regionElement,
|
|
3910
|
-
regionRange:
|
|
3990
|
+
regionRange: ii(t.visibleMap, 0, e.visibleText.length) ?? void 0,
|
|
3911
3991
|
speechMatchesVisibleText: !0,
|
|
3912
3992
|
playbackMode: n.playbackMode,
|
|
3913
3993
|
alignment: n,
|
|
3914
3994
|
visibleMap: t.visibleMap
|
|
3915
3995
|
};
|
|
3916
|
-
},
|
|
3996
|
+
}, wi = (e, t) => {
|
|
3917
3997
|
let n = t.sourceElement;
|
|
3918
3998
|
return {
|
|
3919
3999
|
speechText: e.spokenText,
|
|
@@ -3921,12 +4001,12 @@ var rt = class {
|
|
|
3921
4001
|
sourceElement: n,
|
|
3922
4002
|
regionElement: t.regionElement,
|
|
3923
4003
|
speechMatchesVisibleText: e.spokenText === e.fallbackText,
|
|
3924
|
-
mathAlignment: n ?
|
|
4004
|
+
mathAlignment: n ? U({
|
|
3925
4005
|
mathElement: n,
|
|
3926
4006
|
speechText: e.spokenText
|
|
3927
4007
|
}) : void 0
|
|
3928
4008
|
};
|
|
3929
|
-
},
|
|
4009
|
+
}, Ti = (e, t, n) => {
|
|
3930
4010
|
let r = t.sourceElement;
|
|
3931
4011
|
return {
|
|
3932
4012
|
speechText: n,
|
|
@@ -3934,17 +4014,17 @@ var rt = class {
|
|
|
3934
4014
|
sourceElement: r,
|
|
3935
4015
|
regionElement: t.regionElement,
|
|
3936
4016
|
speechMatchesVisibleText: !1,
|
|
3937
|
-
mathAlignment: r ?
|
|
4017
|
+
mathAlignment: r ? U({
|
|
3938
4018
|
mathElement: r,
|
|
3939
4019
|
speechText: n
|
|
3940
4020
|
}) : void 0,
|
|
3941
|
-
plainFallback:
|
|
4021
|
+
plainFallback: wi(e, t)
|
|
3942
4022
|
};
|
|
3943
|
-
},
|
|
4023
|
+
}, Ei = (e, t = {}) => e.items.map(({ segment: e, anchor: n }) => e.kind === "prose" ? Ci(e, n) : t.format === "ssml" && e.ssml ? Ti(e, n, e.ssml) : wi(e, n)), Di = "pie-tts-control-handoff", X;
|
|
3944
4024
|
(function(e) {
|
|
3945
4025
|
e.IDLE = "idle", e.LOADING = "loading", e.PLAYING = "playing", e.PAUSED = "paused", e.ERROR = "error";
|
|
3946
4026
|
})(X ||= {});
|
|
3947
|
-
var
|
|
4027
|
+
var Oi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOffset === t.startOffset && e.endContainer === t.endContainer && e.endOffset === t.endOffset, ki = (e, t) => e === t ? !0 : !e || !t || e.type !== t.type || e.quality !== t.quality ? !1 : e.type === "range" && t.type === "range" ? Oi(e.range, t.range) : e.type === "element" && t.type === "element" ? e.element === t.element : e.type === "text-range" && t.type === "text-range" && e.node === t.node && e.startOffset === t.startOffset && e.endOffset === t.endOffset, Ai = class e {
|
|
3948
4028
|
currentProvider = null;
|
|
3949
4029
|
provider = null;
|
|
3950
4030
|
highlightCoordinator = null;
|
|
@@ -3976,7 +4056,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
3976
4056
|
activeHighlightMode = "word";
|
|
3977
4057
|
lastRenderedRegionTarget = null;
|
|
3978
4058
|
telemetryReporter = null;
|
|
3979
|
-
generatedMathSpeechResolver =
|
|
4059
|
+
generatedMathSpeechResolver = zr();
|
|
3980
4060
|
static debugEnabled = (() => {
|
|
3981
4061
|
try {
|
|
3982
4062
|
if (typeof process < "u" && process.env?.PIE_TTS_DEBUG === "1") return !0;
|
|
@@ -4105,7 +4185,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4105
4185
|
let i = n?.resolveWordRange?.(e, t);
|
|
4106
4186
|
if (i && this.isRangeWithinScope(i, r)) return {
|
|
4107
4187
|
range: i,
|
|
4108
|
-
remapped: !
|
|
4188
|
+
remapped: !Oi(e, i)
|
|
4109
4189
|
};
|
|
4110
4190
|
} catch {}
|
|
4111
4191
|
return {
|
|
@@ -4172,7 +4252,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4172
4252
|
return;
|
|
4173
4253
|
}
|
|
4174
4254
|
} catch {}
|
|
4175
|
-
this.highlightCoordinator.highlightRange(e,
|
|
4255
|
+
this.highlightCoordinator.highlightRange(e, b.TTS_WORD, x.YELLOW);
|
|
4176
4256
|
}
|
|
4177
4257
|
}
|
|
4178
4258
|
paintTTSSentenceRanges(e) {
|
|
@@ -4201,7 +4281,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4201
4281
|
}
|
|
4202
4282
|
getMathSpeechOptions() {
|
|
4203
4283
|
let e = (this.ttsConfig.providerOptions || {}).mathSpeech;
|
|
4204
|
-
return
|
|
4284
|
+
return K(e);
|
|
4205
4285
|
}
|
|
4206
4286
|
buildPositionMap(t, n, r) {
|
|
4207
4287
|
this.normalizedToDOM.clear();
|
|
@@ -4267,7 +4347,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4267
4347
|
return e.includes("<") ? /<\s*break\b|<\s*speak\b|<\s*prosody\b|<\s*p\b|<\s*s\b/i.test(e) : !1;
|
|
4268
4348
|
}
|
|
4269
4349
|
isElementHidden(e) {
|
|
4270
|
-
return
|
|
4350
|
+
return yt(e);
|
|
4271
4351
|
}
|
|
4272
4352
|
getBoundaryStrength(e) {
|
|
4273
4353
|
let t = Number(e.getAttribute("data-tts-break-ms"));
|
|
@@ -4318,7 +4398,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4318
4398
|
let n = /* @__PURE__ */ new Map(), { map: r } = P(e, this.getTextProcessingOptions()), i = this.createNodeStartOffsets(r), a = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), o = a.nextNode(), s = null;
|
|
4319
4399
|
for (; o;) {
|
|
4320
4400
|
let t = o, r = t.parentElement;
|
|
4321
|
-
if (r && !this.isElementHidden(r) && !
|
|
4401
|
+
if (r && !this.isElementHidden(r) && !Et(t)) {
|
|
4322
4402
|
let r = this.getBoundaryAnchor(t, e), a = i.get(t);
|
|
4323
4403
|
r && a !== void 0 && r.anchor !== s && a > 0 && (n.set(a, Math.max(n.get(a) || 0, r.units)), s = r.anchor);
|
|
4324
4404
|
}
|
|
@@ -4353,7 +4433,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4353
4433
|
}), r.filter((e) => e.text.trim().length > 0);
|
|
4354
4434
|
}
|
|
4355
4435
|
segmentSentences(e) {
|
|
4356
|
-
return
|
|
4436
|
+
return A(e, { locale: this.ttsConfig.providerOptions?.locale || void 0 });
|
|
4357
4437
|
}
|
|
4358
4438
|
createSeekSegmentsFromText(e) {
|
|
4359
4439
|
return this.segmentSentences(e).map((e) => {
|
|
@@ -4397,7 +4477,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4397
4477
|
createSeekSegmentsFromSpeechChunks(e) {
|
|
4398
4478
|
let t = 0;
|
|
4399
4479
|
return e.map((e) => {
|
|
4400
|
-
let n =
|
|
4480
|
+
let n = M(e.plainFallback?.speechText || (this.hasExplicitBreakSemantics(e.speechText) ? e.visibleText : e.speechText) || e.visibleText) || e.visibleText || "", r = {
|
|
4401
4481
|
text: n,
|
|
4402
4482
|
startOffset: t,
|
|
4403
4483
|
pauseMsAfter: 0
|
|
@@ -4538,7 +4618,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4538
4618
|
}
|
|
4539
4619
|
async switchProviderToBrowser(e, t) {
|
|
4540
4620
|
if (!this.currentProvider) return !1;
|
|
4541
|
-
let n = new
|
|
4621
|
+
let n = new j(), r = this.currentProvider.providerId, i = {};
|
|
4542
4622
|
this.ttsConfig.rate !== void 0 && (i.rate = this.ttsConfig.rate), this.ttsConfig.pitch !== void 0 && (i.pitch = this.ttsConfig.pitch), this.ttsConfig.mathTokenHighlighting !== void 0 && (i.mathTokenHighlighting = this.ttsConfig.mathTokenHighlighting);
|
|
4543
4623
|
let a = t?.operation || "tts-initialize", o = t?.contentToSpeak ?? "", s = o.replace(/\s+/g, " ").trim().slice(0, 120), c = o.length > 0 ? {
|
|
4544
4624
|
textLength: o.length,
|
|
@@ -4591,7 +4671,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4591
4671
|
}, "updateSettings" in this.provider && typeof this.provider.updateSettings == "function" && await this.provider.updateSettings({ providerOptions: i });
|
|
4592
4672
|
}
|
|
4593
4673
|
async resolveSpeechContent(e, t) {
|
|
4594
|
-
let n =
|
|
4674
|
+
let n = M(e);
|
|
4595
4675
|
if (t?.ignoreCatalogs) return {
|
|
4596
4676
|
contentToSpeak: n,
|
|
4597
4677
|
speechText: n,
|
|
@@ -4612,7 +4692,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4612
4692
|
form: "content"
|
|
4613
4693
|
}), r = e?.content;
|
|
4614
4694
|
if (e && r !== void 0) {
|
|
4615
|
-
let i = t?.contentElement &&
|
|
4695
|
+
let i = t?.contentElement && G(t.contentElement, this.getTextProcessingOptions(t.language)).visibleText || n, a = M(r);
|
|
4616
4696
|
return this.debugLog(`[TTSService] Using catalog content for "${t.catalogId}" (${e.language})`), {
|
|
4617
4697
|
contentToSpeak: r,
|
|
4618
4698
|
speechText: r,
|
|
@@ -4645,7 +4725,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4645
4725
|
if (!this.catalogResolver) return null;
|
|
4646
4726
|
let r = this.collectCatalogSpeechChunks(e, n);
|
|
4647
4727
|
if (!r.some((e) => e.sourceElement)) return null;
|
|
4648
|
-
let i =
|
|
4728
|
+
let i = M(r.map((e) => e.speechText).join(" ")), a = G(e, this.getTextProcessingOptions(n.language)).visibleText || t;
|
|
4649
4729
|
return {
|
|
4650
4730
|
contentToSpeak: i,
|
|
4651
4731
|
speechText: i,
|
|
@@ -4661,7 +4741,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4661
4741
|
}
|
|
4662
4742
|
collectCatalogSpeechChunks(e, t) {
|
|
4663
4743
|
let n = [], r = "", i = () => {
|
|
4664
|
-
let e =
|
|
4744
|
+
let e = M(r);
|
|
4665
4745
|
r = "", e && n.push({
|
|
4666
4746
|
speechText: e,
|
|
4667
4747
|
visibleText: e,
|
|
@@ -4679,7 +4759,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4679
4759
|
}, i = this.catalogResolver.getAlternative(n, {
|
|
4680
4760
|
...r,
|
|
4681
4761
|
form: "payload"
|
|
4682
|
-
}), a = i?.payload ?
|
|
4762
|
+
}), a = i?.payload ? ct({ payload: i.payload }) ?? void 0 : void 0, o = this.catalogResolver.getAlternative(n, {
|
|
4683
4763
|
...r,
|
|
4684
4764
|
form: "content"
|
|
4685
4765
|
})?.content;
|
|
@@ -4690,7 +4770,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4690
4770
|
}, o = (e, n) => {
|
|
4691
4771
|
let r = s(e);
|
|
4692
4772
|
if (r.length !== 1) return null;
|
|
4693
|
-
let i = r[0], a =
|
|
4773
|
+
let i = r[0], a = G(i, this.getTextProcessingOptions(t.language)).visibleText || M(i.textContent || ""), o = (e) => M(e).replace(/\s+/g, "");
|
|
4694
4774
|
return o(a) === o(n) ? i : null;
|
|
4695
4775
|
}, s = (e) => {
|
|
4696
4776
|
let t = Array.from(e.querySelectorAll("math"));
|
|
@@ -4705,16 +4785,16 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4705
4785
|
let u = l, d = a(u);
|
|
4706
4786
|
if (d) {
|
|
4707
4787
|
i();
|
|
4708
|
-
let r =
|
|
4709
|
-
let e = d.script, t =
|
|
4788
|
+
let r = G(u, this.getTextProcessingOptions(t.language)), a = r.visibleText || M(u.textContent || ""), c = bi(u, e), l = d.script === void 0 ? null : (() => {
|
|
4789
|
+
let e = d.script, t = Kt({
|
|
4710
4790
|
speechText: e,
|
|
4711
4791
|
visibleText: a
|
|
4712
|
-
}), n = o(u, a), i = n ?
|
|
4792
|
+
}), n = o(u, a), i = n ? U({
|
|
4713
4793
|
mathElement: n,
|
|
4714
4794
|
speechText: e
|
|
4715
4795
|
}) : void 0, l = i ? void 0 : s(u).map((t) => ({
|
|
4716
4796
|
element: t,
|
|
4717
|
-
alignment:
|
|
4797
|
+
alignment: U({
|
|
4718
4798
|
mathElement: t,
|
|
4719
4799
|
speechText: e
|
|
4720
4800
|
})
|
|
@@ -4724,7 +4804,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4724
4804
|
visibleText: a,
|
|
4725
4805
|
sourceElement: u,
|
|
4726
4806
|
regionElement: c,
|
|
4727
|
-
speechMatchesVisibleText:
|
|
4807
|
+
speechMatchesVisibleText: M(e) === a,
|
|
4728
4808
|
playbackMode: t.playbackMode,
|
|
4729
4809
|
alignment: t,
|
|
4730
4810
|
mathAlignment: i,
|
|
@@ -4760,7 +4840,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4760
4840
|
return !e || e.providerId?.toLowerCase() === "browser" ? "plain" : e.getCapabilities?.().supportsSSML ? "ssml" : "plain";
|
|
4761
4841
|
}
|
|
4762
4842
|
async resolveGeneratedSpeechContent(e, t, n) {
|
|
4763
|
-
let r = this.resolveGeneratedPlaybackFormat(), { plan: i, containsMathMarkup: a, visibleText: o } = await
|
|
4843
|
+
let r = this.resolveGeneratedPlaybackFormat(), { plan: i, containsMathMarkup: a, visibleText: o } = await Si({
|
|
4764
4844
|
contentRoot: e,
|
|
4765
4845
|
language: n,
|
|
4766
4846
|
mathSpeech: this.getMathSpeechOptions(),
|
|
@@ -4777,7 +4857,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4777
4857
|
containsMathMarkup: !1,
|
|
4778
4858
|
speechMatchesVisibleText: !0
|
|
4779
4859
|
};
|
|
4780
|
-
let c =
|
|
4860
|
+
let c = Ei(i, { format: r }), l = i.plainSpeechText;
|
|
4781
4861
|
return {
|
|
4782
4862
|
contentToSpeak: l,
|
|
4783
4863
|
speechText: l,
|
|
@@ -4832,19 +4912,19 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4832
4912
|
let t = e.regionElement || e.sourceElement;
|
|
4833
4913
|
if (!(!t && !e.regionRange || !this.highlightCoordinator)) try {
|
|
4834
4914
|
if (this.lastRenderedRegionTarget = null, e.regionRange) {
|
|
4835
|
-
this.highlightCoordinator.clearHighlights?.(
|
|
4915
|
+
this.highlightCoordinator.clearHighlights?.(b.TTS_WORD), this.paintTTSSentenceRanges([e.regionRange]);
|
|
4836
4916
|
return;
|
|
4837
4917
|
}
|
|
4838
4918
|
if (!t) return;
|
|
4839
4919
|
let n = document.createRange();
|
|
4840
|
-
n.selectNodeContents(t), this.highlightCoordinator.clearHighlights?.(
|
|
4920
|
+
n.selectNodeContents(t), this.highlightCoordinator.clearHighlights?.(b.TTS_WORD), this.paintTTSSentenceRanges([n]);
|
|
4841
4921
|
} catch {}
|
|
4842
4922
|
}
|
|
4843
4923
|
highlightCatalogActiveRange(e) {
|
|
4844
4924
|
this.highlightCoordinator && this.paintTTSWordRange(this.resolveWordHighlightRange(e).range);
|
|
4845
4925
|
}
|
|
4846
4926
|
highlightRenderableRegionTarget(e) {
|
|
4847
|
-
if (!(!this.highlightCoordinator || !e || typeof document > "u") && !(!this.highlightTargetResolverProvider &&
|
|
4927
|
+
if (!(!this.highlightCoordinator || !e || typeof document > "u") && !(!this.highlightTargetResolverProvider && ki(this.lastRenderedRegionTarget, e))) try {
|
|
4848
4928
|
let t = document.createRange();
|
|
4849
4929
|
if (e.type === "element") t.selectNodeContents(e.element);
|
|
4850
4930
|
else if (e.type === "range") {
|
|
@@ -4857,7 +4937,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4857
4937
|
highlightRenderableActiveTarget(e) {
|
|
4858
4938
|
if (!this.highlightCoordinator || typeof document > "u") return;
|
|
4859
4939
|
if (!e) {
|
|
4860
|
-
this.highlightCoordinator.clearHighlights(
|
|
4940
|
+
this.highlightCoordinator.clearHighlights(b.TTS_WORD);
|
|
4861
4941
|
return;
|
|
4862
4942
|
}
|
|
4863
4943
|
if (e.type === "text-range") {
|
|
@@ -4900,11 +4980,11 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4900
4980
|
async playRecordedAudio(e, t) {
|
|
4901
4981
|
if (typeof document > "u") throw Error("[tts] no document available to play recorded audio");
|
|
4902
4982
|
let n = e.sources[0], r = document.createElement("audio");
|
|
4903
|
-
r.preload = "auto", r.src =
|
|
4983
|
+
r.preload = "auto", r.src = st(n.src, e.fragment), r.playbackRate = this.normalizePlaybackRate(Number(this.ttsConfig.rate || 1)), await new Promise((i, a) => {
|
|
4904
4984
|
let o, s = !1, c = !1, l = () => {
|
|
4905
4985
|
c || s || (s = !0, t?.());
|
|
4906
4986
|
}, u = () => {
|
|
4907
|
-
r.removeEventListener("ended", d), r.removeEventListener("error", f), r.removeEventListener("playing", l), o
|
|
4987
|
+
r.removeEventListener("ended", d), r.removeEventListener("error", f), r.removeEventListener("playing", l), o?.(), this.activeRecordedAudio?.element === r && (this.activeRecordedAudio = null);
|
|
4908
4988
|
}, d = () => {
|
|
4909
4989
|
c || (c = !0, u(), i());
|
|
4910
4990
|
}, f = () => {
|
|
@@ -4915,11 +4995,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4915
4995
|
cancel: () => {
|
|
4916
4996
|
c || (c = !0, u(), r.pause(), i());
|
|
4917
4997
|
}
|
|
4918
|
-
}, r.addEventListener("ended", d), r.addEventListener("error", f), r.addEventListener("playing", l);
|
|
4919
|
-
let p = e.fragment?.endSeconds;
|
|
4920
|
-
p !== void 0 && (o = setInterval(() => {
|
|
4921
|
-
r.currentTime >= p && d();
|
|
4922
|
-
}, 100)), Promise.resolve(r.play()).then(l).catch(f);
|
|
4998
|
+
}, r.addEventListener("ended", d), r.addEventListener("error", f), r.addEventListener("playing", l), o = ot(r, e.fragment, d), Promise.resolve(r.play()).then(l).catch(f);
|
|
4923
4999
|
}).finally(() => {
|
|
4924
5000
|
this.activeRecordedAudio?.element === r && (this.activeRecordedAudio = null), r.pause(), r.removeAttribute("src");
|
|
4925
5001
|
});
|
|
@@ -4938,10 +5014,10 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
4938
5014
|
});
|
|
4939
5015
|
return;
|
|
4940
5016
|
}
|
|
4941
|
-
let n = e.regionElement || e.sourceElement || this.currentContentElement, r = n ?
|
|
5017
|
+
let n = e.regionElement || e.sourceElement || this.currentContentElement, r = n ? vi({
|
|
4942
5018
|
contentRoot: n,
|
|
4943
5019
|
chunks: [e]
|
|
4944
|
-
})[0] : null, i = this.ttsConfig.mathTokenHighlighting !== !1, a = r ?
|
|
5020
|
+
})[0] : null, i = this.ttsConfig.mathTokenHighlighting !== !1, a = r ? hi({
|
|
4945
5021
|
chunks: [r],
|
|
4946
5022
|
mathTokenHighlighting: i
|
|
4947
5023
|
}) : null;
|
|
@@ -5001,7 +5077,7 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5001
5077
|
}
|
|
5002
5078
|
async speakRange(e, t) {
|
|
5003
5079
|
if (!this.provider) throw Error("TTS service not initialized");
|
|
5004
|
-
if (
|
|
5080
|
+
if (Et(e.commonAncestorContainer)) {
|
|
5005
5081
|
console.warn("[tts] selection lies inside content marked not-to-be-spoken; nothing was spoken. Selecting a node and pressing read-aloud must not become a way around suppression.");
|
|
5006
5082
|
return;
|
|
5007
5083
|
}
|
|
@@ -5011,14 +5087,14 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5011
5087
|
n = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
5012
5088
|
}
|
|
5013
5089
|
if (!n) return;
|
|
5014
|
-
let r =
|
|
5090
|
+
let r = Dt(e, n), i = r.text.trim();
|
|
5015
5091
|
if (!i) {
|
|
5016
5092
|
r.filtered && console.warn("[tts] every part of the selection is either hidden or marked not-to-be-spoken; nothing was spoken.");
|
|
5017
5093
|
return;
|
|
5018
5094
|
}
|
|
5019
5095
|
let a = document.createRange();
|
|
5020
5096
|
a.selectNodeContents(n), a.setEnd(e.startContainer, e.startOffset);
|
|
5021
|
-
let o =
|
|
5097
|
+
let o = Dt(a, n).text, s = M(o), c = s.length + (/\s$/.test(o) && s ? 1 : 0);
|
|
5022
5098
|
this.debugLog("[TTSService] speakRange offset calculation:", {
|
|
5023
5099
|
selectedText: i,
|
|
5024
5100
|
textBeforeRange: o.substring(0, 100),
|
|
@@ -5063,10 +5139,10 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5063
5139
|
}
|
|
5064
5140
|
else await this.speakWithPlan(i, r, { highlightMode: this.activeHighlightMode });
|
|
5065
5141
|
if (r !== this.speakRunId) return;
|
|
5066
|
-
this.setState(X.IDLE), this.clearHighlightsAndTracking()
|
|
5142
|
+
this.setState(X.IDLE), this.clearHighlightsAndTracking();
|
|
5067
5143
|
} catch (e) {
|
|
5068
5144
|
if (r !== this.speakRunId) return;
|
|
5069
|
-
throw this.lastError = e instanceof Error ? e.message : String(e), this.setState(X.ERROR), this.clearHighlightsAndTracking(),
|
|
5145
|
+
throw this.lastError = e instanceof Error ? e.message : String(e), this.setState(X.ERROR), this.clearHighlightsAndTracking(), e;
|
|
5070
5146
|
} finally {
|
|
5071
5147
|
this.clearPlaybackStartBarrier(a);
|
|
5072
5148
|
}
|
|
@@ -5122,10 +5198,10 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5122
5198
|
await this.seekBy(-t);
|
|
5123
5199
|
}
|
|
5124
5200
|
stop() {
|
|
5125
|
-
this.provider && (this.speakRunId += 1, this.clearPlaybackStartBarrier(), this.cancelRecordedAudio(), this.provider.onWordBoundary = void 0, this.provider.stop(), this.
|
|
5201
|
+
this.provider && (this.speakRunId += 1, this.clearPlaybackStartBarrier(), this.cancelRecordedAudio(), this.provider.onWordBoundary = void 0, this.provider.stop(), this.setState(X.IDLE), this.currentText = null, this.highlightCoordinator && this.highlightCoordinator.clearTTS(), this.lastRenderedRegionTarget = null, this.currentContentElement = null, this.normalizedToDOM.clear(), this.currentBoundaryOffset = 0, this.activeWordBoundaryOffset = 0, this.seekSegments = [], this.playbackChunks = [], this.sentenceHighlightSegments = [], this.currentSeekSegmentIndex = 0, this.activeSentenceStartOffset = null, this.activePlaybackRate = null);
|
|
5126
5202
|
}
|
|
5127
5203
|
requestControlHandoff() {
|
|
5128
|
-
typeof window > "u" || window.dispatchEvent(new CustomEvent(
|
|
5204
|
+
typeof window > "u" || window.dispatchEvent(new CustomEvent(Di, { detail: { source: "host" } }));
|
|
5129
5205
|
}
|
|
5130
5206
|
isPlaying() {
|
|
5131
5207
|
return this.state === X.PLAYING;
|
|
@@ -5195,14 +5271,14 @@ var xi = (e, t) => e === t || e.startContainer === t.startContainer && e.startOf
|
|
|
5195
5271
|
state: e
|
|
5196
5272
|
});
|
|
5197
5273
|
}
|
|
5198
|
-
},
|
|
5274
|
+
}, ji = /* @__PURE__ */ new Set([
|
|
5199
5275
|
"reserved-row",
|
|
5200
5276
|
"expanding-row",
|
|
5201
5277
|
"floating-overlay",
|
|
5202
5278
|
"left-aligned"
|
|
5203
|
-
]),
|
|
5279
|
+
]), Mi = (e) => e && typeof e == "object" ? e : {}, Ni = (e) => e === "polly" || e === "google" || e === "server", Z = (e, t) => e === void 0 ? t : e, Pi = (e, t = "left-aligned") => typeof e == "string" && ji.has(e) ? e : t;
|
|
5204
5280
|
Object.freeze([.8, 1.25]);
|
|
5205
|
-
var
|
|
5281
|
+
var Fi = Object.freeze([
|
|
5206
5282
|
{
|
|
5207
5283
|
rate: .8,
|
|
5208
5284
|
label: "Slow",
|
|
@@ -5219,21 +5295,21 @@ var Oi = Object.freeze([
|
|
|
5219
5295
|
label: "Fast",
|
|
5220
5296
|
ariaLabel: "Fast speed"
|
|
5221
5297
|
}
|
|
5222
|
-
]),
|
|
5298
|
+
]), Ii = (e) => {
|
|
5223
5299
|
if (!(typeof e != "number" || !Number.isFinite(e) || e <= 0)) return Math.round(e * 100) / 100;
|
|
5224
|
-
},
|
|
5300
|
+
}, Li = (e) => {
|
|
5225
5301
|
if (typeof e != "string") return;
|
|
5226
5302
|
let t = e.trim();
|
|
5227
5303
|
return t.length ? t : void 0;
|
|
5228
|
-
},
|
|
5229
|
-
let t = Array.isArray(e) ? e : [...
|
|
5304
|
+
}, Ri = (e) => `${e}x`, zi = (e, t) => e.toLowerCase() === "normal" ? "Normal speed" : t ? `Speed ${e}` : `${e} speed`, Bi = (e, t, n) => t ? t.toLowerCase().includes(e.toLowerCase()) ? t : `${e} ${t}` : zi(e, n), Vi = (e) => {
|
|
5305
|
+
let t = Array.isArray(e) ? e : [...Fi];
|
|
5230
5306
|
if (t.length === 0) return [];
|
|
5231
5307
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5232
5308
|
for (let e of t) {
|
|
5233
|
-
let t =
|
|
5309
|
+
let t = Mi(e), i = Ii(typeof e == "number" ? e : t.rate);
|
|
5234
5310
|
if (i === void 0 || n.has(i)) continue;
|
|
5235
5311
|
n.add(i);
|
|
5236
|
-
let a = i === 1 ? "Normal" :
|
|
5312
|
+
let a = i === 1 ? "Normal" : Ri(i), o = typeof e == "number" ? a : Li(t.label) || a, s = typeof e == "number" ? i === 1 ? "Normal speed" : zi(o, !0) : Bi(o, Li(t.ariaLabel), o === a);
|
|
5237
5313
|
r.push({
|
|
5238
5314
|
rate: i,
|
|
5239
5315
|
label: o,
|
|
@@ -5242,7 +5318,7 @@ var Oi = Object.freeze([
|
|
|
5242
5318
|
requestedDefault: t.default === !0 || t.isDefault === !0
|
|
5243
5319
|
});
|
|
5244
5320
|
}
|
|
5245
|
-
if (!r.length) return
|
|
5321
|
+
if (!r.length) return Vi(Fi);
|
|
5246
5322
|
if (!n.has(1)) {
|
|
5247
5323
|
let e = {
|
|
5248
5324
|
rate: 1,
|
|
@@ -5264,12 +5340,12 @@ Object.freeze([
|
|
|
5264
5340
|
1,
|
|
5265
5341
|
1.25
|
|
5266
5342
|
]);
|
|
5267
|
-
var
|
|
5343
|
+
var Hi = (e) => {
|
|
5268
5344
|
let t = {
|
|
5269
5345
|
...e,
|
|
5270
|
-
layoutMode:
|
|
5346
|
+
layoutMode: Pi(e.layoutMode)
|
|
5271
5347
|
}, n = e.backend || "browser";
|
|
5272
|
-
if (!
|
|
5348
|
+
if (!Ni(n)) return t;
|
|
5273
5349
|
let r = {
|
|
5274
5350
|
...t,
|
|
5275
5351
|
apiEndpoint: Z(t.apiEndpoint, "/api/tts"),
|
|
@@ -5290,14 +5366,14 @@ var Fi = (e) => {
|
|
|
5290
5366
|
...r,
|
|
5291
5367
|
defaultVoice: Z(r.defaultVoice, "en-US-Wavenet-A")
|
|
5292
5368
|
} : r;
|
|
5293
|
-
},
|
|
5294
|
-
let t =
|
|
5295
|
-
return
|
|
5369
|
+
}, Ui = (e) => {
|
|
5370
|
+
let t = Mi(e), n = Mi(t.settings);
|
|
5371
|
+
return Hi({
|
|
5296
5372
|
...t,
|
|
5297
5373
|
...n
|
|
5298
5374
|
});
|
|
5299
|
-
},
|
|
5300
|
-
let t =
|
|
5375
|
+
}, Wi = (e) => e.backend || "browser", Gi = (e, t) => t === "polly" || t === "google" ? t : e.serverProvider || e.provider, Ki = (e, t) => e.transportMode || (t === "custom" ? "custom" : "pie"), qi = (e) => {
|
|
5376
|
+
let t = Wi(e), n = Gi(e, t), r = Ki(e, n), i = K(e.mathSpeech);
|
|
5301
5377
|
return {
|
|
5302
5378
|
voice: e.defaultVoice,
|
|
5303
5379
|
rate: e.rate,
|
|
@@ -5323,8 +5399,8 @@ var Fi = (e) => {
|
|
|
5323
5399
|
validateEndpoint: e.validateEndpoint,
|
|
5324
5400
|
...typeof e.mathTokenHighlighting == "boolean" ? { mathTokenHighlighting: e.mathTokenHighlighting } : {}
|
|
5325
5401
|
};
|
|
5326
|
-
},
|
|
5327
|
-
switch (
|
|
5402
|
+
}, Ji = (e) => Pi(e.layoutMode), Yi = (e) => {
|
|
5403
|
+
switch (Ji(e)) {
|
|
5328
5404
|
case "reserved-row": return {
|
|
5329
5405
|
mount: "before-buttons",
|
|
5330
5406
|
controlsRow: {
|
|
@@ -5358,7 +5434,7 @@ var Fi = (e) => {
|
|
|
5358
5434
|
headerOverlay: { expandWhenToolActive: !0 }
|
|
5359
5435
|
};
|
|
5360
5436
|
}
|
|
5361
|
-
},
|
|
5437
|
+
}, Xi = class {
|
|
5362
5438
|
providers = /* @__PURE__ */ new Map();
|
|
5363
5439
|
configs = /* @__PURE__ */ new Map();
|
|
5364
5440
|
initialized = /* @__PURE__ */ new Map();
|
|
@@ -5504,8 +5580,127 @@ var Fi = (e) => {
|
|
|
5504
5580
|
let e = Array.from(this.providers.keys());
|
|
5505
5581
|
await Promise.all(e.map((e) => this.unregister(e))), console.log("[ToolProviderRegistry] Registry destroyed");
|
|
5506
5582
|
}
|
|
5507
|
-
},
|
|
5508
|
-
|
|
5583
|
+
}, Zi = class {
|
|
5584
|
+
category = "calculator";
|
|
5585
|
+
calculatorProvider = null;
|
|
5586
|
+
initializationPromise = null;
|
|
5587
|
+
lifecycleGeneration = 0;
|
|
5588
|
+
async emitTelemetry(e, t, n) {
|
|
5589
|
+
try {
|
|
5590
|
+
await e.onTelemetry?.(t, n);
|
|
5591
|
+
} catch (e) {
|
|
5592
|
+
console.warn(`[${this.providerName}] telemetry callback failed:`, e);
|
|
5593
|
+
}
|
|
5594
|
+
}
|
|
5595
|
+
async initialize(e = {}) {
|
|
5596
|
+
if (this.calculatorProvider) return;
|
|
5597
|
+
if (this.initializationPromise) return this.initializationPromise;
|
|
5598
|
+
let t = ++this.lifecycleGeneration, n = this.initializeProvider(e, t);
|
|
5599
|
+
this.initializationPromise = n;
|
|
5600
|
+
try {
|
|
5601
|
+
await n;
|
|
5602
|
+
} finally {
|
|
5603
|
+
this.initializationPromise === n && (this.initializationPromise = null);
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
async initializeProvider(e, t) {
|
|
5607
|
+
let n = this.getDefinition(), r = Date.now();
|
|
5608
|
+
await this.emitTelemetry(e, "pie-tool-library-load-start", {
|
|
5609
|
+
toolId: "calculator",
|
|
5610
|
+
operation: n.moduleImportOperation,
|
|
5611
|
+
backend: n.backend
|
|
5612
|
+
});
|
|
5613
|
+
let i;
|
|
5614
|
+
try {
|
|
5615
|
+
i = await n.loadProvider(), await this.emitTelemetry(e, "pie-tool-library-load-success", {
|
|
5616
|
+
toolId: "calculator",
|
|
5617
|
+
operation: n.moduleImportOperation,
|
|
5618
|
+
backend: n.backend,
|
|
5619
|
+
duration: Date.now() - r
|
|
5620
|
+
});
|
|
5621
|
+
} catch (t) {
|
|
5622
|
+
throw await this.emitTelemetry(e, "pie-tool-library-load-error", {
|
|
5623
|
+
toolId: "calculator",
|
|
5624
|
+
operation: n.moduleImportOperation,
|
|
5625
|
+
backend: n.backend,
|
|
5626
|
+
duration: Date.now() - r,
|
|
5627
|
+
errorType: "ToolLibraryLoadError",
|
|
5628
|
+
message: t instanceof Error ? t.message : String(t)
|
|
5629
|
+
}), Error(n.initializationErrorMessage, { cause: t });
|
|
5630
|
+
}
|
|
5631
|
+
if (t !== this.lifecycleGeneration) throw Error(`${this.providerName} initialization was cancelled`);
|
|
5632
|
+
let a = new i();
|
|
5633
|
+
try {
|
|
5634
|
+
if (await a.initialize(e), t !== this.lifecycleGeneration) throw Error(`${this.providerName} initialization was cancelled`);
|
|
5635
|
+
this.calculatorProvider = a;
|
|
5636
|
+
} catch (e) {
|
|
5637
|
+
throw a.destroy(), Error(n.initializationErrorMessage, { cause: e });
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
async createInstance() {
|
|
5641
|
+
if (!this.calculatorProvider) throw Error(`[${this.providerName}] Provider not initialized. Call initialize() first.`);
|
|
5642
|
+
return this.calculatorProvider;
|
|
5643
|
+
}
|
|
5644
|
+
isReady() {
|
|
5645
|
+
return this.calculatorProvider !== null;
|
|
5646
|
+
}
|
|
5647
|
+
destroy() {
|
|
5648
|
+
this.lifecycleGeneration += 1, this.initializationPromise = null, this.calculatorProvider?.destroy(), this.calculatorProvider = null;
|
|
5649
|
+
}
|
|
5650
|
+
}, Qi = class extends Zi {
|
|
5651
|
+
providerId = "cortex-calculator";
|
|
5652
|
+
providerName = "PIE Open-Source Calculator";
|
|
5653
|
+
version = "1";
|
|
5654
|
+
requiresAuth = !1;
|
|
5655
|
+
getDefinition() {
|
|
5656
|
+
return {
|
|
5657
|
+
backend: "cortex",
|
|
5658
|
+
moduleImportOperation: "cortex-provider-module-import",
|
|
5659
|
+
loadProvider: async () => (await import("./pie-assessment-toolkit-DJfg6laX.js")).CortexCalculatorProvider,
|
|
5660
|
+
initializationErrorMessage: "Failed to initialize the PIE open-source calculator provider. Confirm that this browser supports module workers and that the bundled worker assets are available."
|
|
5661
|
+
};
|
|
5662
|
+
}
|
|
5663
|
+
getCapabilities() {
|
|
5664
|
+
return {
|
|
5665
|
+
supportsOffline: !0,
|
|
5666
|
+
requiresAuth: !1,
|
|
5667
|
+
maxInstances: null,
|
|
5668
|
+
features: {
|
|
5669
|
+
basic: !0,
|
|
5670
|
+
scientific: !0,
|
|
5671
|
+
graphing: !0,
|
|
5672
|
+
fourFunction: !0
|
|
5673
|
+
}
|
|
5674
|
+
};
|
|
5675
|
+
}
|
|
5676
|
+
}, $i = class extends Zi {
|
|
5677
|
+
providerId = "geogebra-calculator";
|
|
5678
|
+
providerName = "GeoGebra Calculator";
|
|
5679
|
+
version = "6";
|
|
5680
|
+
requiresAuth = !1;
|
|
5681
|
+
getDefinition() {
|
|
5682
|
+
return {
|
|
5683
|
+
backend: "geogebra",
|
|
5684
|
+
moduleImportOperation: "geogebra-provider-module-import",
|
|
5685
|
+
loadProvider: async () => (await import("./pie-assessment-toolkit-Cruxm385.js")).GeoGebraCalculatorProvider,
|
|
5686
|
+
initializationErrorMessage: "Failed to initialize GeoGebra calculator provider. Confirm that the deployment may load GeoGebra and that its script URL is reachable."
|
|
5687
|
+
};
|
|
5688
|
+
}
|
|
5689
|
+
getCapabilities() {
|
|
5690
|
+
return {
|
|
5691
|
+
supportsOffline: !1,
|
|
5692
|
+
requiresAuth: !1,
|
|
5693
|
+
maxInstances: null,
|
|
5694
|
+
features: {
|
|
5695
|
+
basic: !0,
|
|
5696
|
+
scientific: !0,
|
|
5697
|
+
graphing: !0,
|
|
5698
|
+
fourFunction: !1
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
}
|
|
5702
|
+
}, ea = (e) => `No assessment is bound, so no policy source could grant "${e}"`;
|
|
5703
|
+
function ta(e, t, n, r) {
|
|
5509
5704
|
return {
|
|
5510
5705
|
featureId: e,
|
|
5511
5706
|
granted: !1,
|
|
@@ -5518,7 +5713,7 @@ function Wi(e, t, n, r) {
|
|
|
5518
5713
|
assessmentBound: r.assessmentBound
|
|
5519
5714
|
};
|
|
5520
5715
|
}
|
|
5521
|
-
function
|
|
5716
|
+
function na(e, t, n) {
|
|
5522
5717
|
let r = t.decisions[0], i = Array.from(t.perToolFlags.values())[0], a = r?.action === "enable", o = r?.reason ?? `Feature "${e}" not configured`;
|
|
5523
5718
|
return {
|
|
5524
5719
|
featureId: e,
|
|
@@ -5527,15 +5722,15 @@ function Gi(e, t, n) {
|
|
|
5527
5722
|
rule: r?.rule ?? "pnp-support",
|
|
5528
5723
|
precedence: r?.precedence ?? 6,
|
|
5529
5724
|
sourceType: r?.sourceType ?? "system",
|
|
5530
|
-
reason: n.assessmentBound || a ? o :
|
|
5725
|
+
reason: n.assessmentBound || a ? o : ea(e),
|
|
5531
5726
|
required: !!i?.required,
|
|
5532
5727
|
parameters: i?.settings,
|
|
5533
5728
|
assessmentBound: n.assessmentBound
|
|
5534
5729
|
};
|
|
5535
5730
|
}
|
|
5536
5731
|
//#endregion
|
|
5537
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5538
|
-
var
|
|
5732
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/provenance.js
|
|
5733
|
+
var ra = class {
|
|
5539
5734
|
provenance;
|
|
5540
5735
|
stepCounter = 0;
|
|
5541
5736
|
constructor(e) {
|
|
@@ -5645,12 +5840,12 @@ var Ki = class {
|
|
|
5645
5840
|
return this;
|
|
5646
5841
|
}
|
|
5647
5842
|
build() {
|
|
5648
|
-
for (let e of this.provenance.features.values()) e.explanation =
|
|
5843
|
+
for (let e of this.provenance.features.values()) e.explanation = ia(e);
|
|
5649
5844
|
for (let e of this.provenance.features.values()) this.provenance.summary.totalFeatures++, e.finalState === "enabled" ? this.provenance.summary.enabled++ : e.finalState === "blocked" ? this.provenance.summary.blocked++ : this.provenance.summary.notConfigured++;
|
|
5650
5845
|
return this.provenance;
|
|
5651
5846
|
}
|
|
5652
5847
|
};
|
|
5653
|
-
function
|
|
5848
|
+
function ia(e) {
|
|
5654
5849
|
if (!e.winningDecision) {
|
|
5655
5850
|
if (e.finalState === "advisory-only") {
|
|
5656
5851
|
let t = e.allDecisions.find((e) => e.action === "advisory");
|
|
@@ -5668,9 +5863,9 @@ function qi(e) {
|
|
|
5668
5863
|
return r;
|
|
5669
5864
|
}
|
|
5670
5865
|
//#endregion
|
|
5671
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5672
|
-
function
|
|
5673
|
-
let { request: t, tools: n, pnpPolicy: r, customSources: i, contextId: a } = e, o = new
|
|
5866
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/compose-decision.js
|
|
5867
|
+
function aa(e) {
|
|
5868
|
+
let { request: t, tools: n, pnpPolicy: r, customSources: i, contextId: a } = e, o = new ra(a);
|
|
5674
5869
|
o.addSource("host", {
|
|
5675
5870
|
id: t.scope.scopeId,
|
|
5676
5871
|
name: `${t.level}:${t.scope.scopeId}`,
|
|
@@ -5679,7 +5874,7 @@ function Ji(e) {
|
|
|
5679
5874
|
policy: n.policy
|
|
5680
5875
|
}
|
|
5681
5876
|
});
|
|
5682
|
-
let s =
|
|
5877
|
+
let s = w(n.placement[t.level]), c = w(n.policy.allowed), l = new Set(w(n.policy.blocked)), u = [];
|
|
5683
5878
|
for (let e of s) u.push(e), o.addDecision({
|
|
5684
5879
|
precedence: 0,
|
|
5685
5880
|
rule: "placement-membership",
|
|
@@ -5734,11 +5929,18 @@ function Ji(e) {
|
|
|
5734
5929
|
reason: e.reason,
|
|
5735
5930
|
value: e.value
|
|
5736
5931
|
});
|
|
5932
|
+
for (let e of m.unmappedSupportIds) d.push({
|
|
5933
|
+
code: "tool-policy.unknownSupportId",
|
|
5934
|
+
level: t.level,
|
|
5935
|
+
toolId: e,
|
|
5936
|
+
message: `No registered tool claims PNP support id "${e}"; it was carried through as a feature id and matched nothing. Expected an AfA 3.0 / QTI 3.0 access feature id.`,
|
|
5937
|
+
source: "pnp.pnp-support"
|
|
5938
|
+
});
|
|
5737
5939
|
u = u.filter((e) => !m.blockedToolIds.has(e));
|
|
5738
5940
|
for (let e of Array.from(f.keys())) m.blockedToolIds.has(e) && f.delete(e);
|
|
5739
5941
|
for (let e of m.mandatedToolIds) {
|
|
5740
5942
|
if (p.has(e)) continue;
|
|
5741
|
-
let r = m.perToolFlags.get(e)?.rule ?? "required-tool", i =
|
|
5943
|
+
let r = m.perToolFlags.get(e)?.rule ?? "required-tool", i = oa(e, {
|
|
5742
5944
|
placement: s,
|
|
5743
5945
|
allowed: c,
|
|
5744
5946
|
blocked: l,
|
|
@@ -5810,7 +6012,7 @@ function Ji(e) {
|
|
|
5810
6012
|
}
|
|
5811
6013
|
for (let e of r) s.has(e) || f.delete(e);
|
|
5812
6014
|
}
|
|
5813
|
-
let h = new Set(u),
|
|
6015
|
+
let h = new Set(u), ee = u.map((e) => {
|
|
5814
6016
|
let t = m?.perToolFlags.get(e);
|
|
5815
6017
|
return {
|
|
5816
6018
|
toolId: e,
|
|
@@ -5821,12 +6023,12 @@ function Ji(e) {
|
|
|
5821
6023
|
};
|
|
5822
6024
|
});
|
|
5823
6025
|
return o.reconcileFinalStates(h), {
|
|
5824
|
-
visibleTools:
|
|
6026
|
+
visibleTools: ee,
|
|
5825
6027
|
diagnostics: d,
|
|
5826
6028
|
provenance: o.build()
|
|
5827
6029
|
};
|
|
5828
6030
|
}
|
|
5829
|
-
function
|
|
6031
|
+
function oa(e, t) {
|
|
5830
6032
|
return t.placement.includes(e) ? t.providers?.[e]?.enabled === !1 ? {
|
|
5831
6033
|
hostRule: "provider-disabled",
|
|
5832
6034
|
hostValue: !1
|
|
@@ -5845,8 +6047,8 @@ function Yi(e, t) {
|
|
|
5845
6047
|
};
|
|
5846
6048
|
}
|
|
5847
6049
|
//#endregion
|
|
5848
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5849
|
-
function
|
|
6050
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/core/pnp-policy-inputs.js
|
|
6051
|
+
function sa(e) {
|
|
5850
6052
|
if (!e) return !1;
|
|
5851
6053
|
let t = e.personalNeedsProfile;
|
|
5852
6054
|
if (t && (Array.isArray(t.supports) && t.supports.length > 0 || Array.isArray(t.prohibitedSupports) && t.prohibitedSupports.length > 0 || Array.isArray(t.activateAtInit) && t.activateAtInit.length > 0)) return !0;
|
|
@@ -5862,16 +6064,16 @@ function Xi(e) {
|
|
|
5862
6064
|
}
|
|
5863
6065
|
return !1;
|
|
5864
6066
|
}
|
|
5865
|
-
function
|
|
6067
|
+
function ca(e) {
|
|
5866
6068
|
let t = e?.settings;
|
|
5867
6069
|
return t ? !!(Array.isArray(t.requiredTools) && t.requiredTools.length > 0 || Array.isArray(t.restrictedTools) && t.restrictedTools.length > 0 || t.toolParameters && typeof t.toolParameters == "object" && Object.keys(t.toolParameters).length > 0) : !1;
|
|
5868
6070
|
}
|
|
5869
|
-
function
|
|
5870
|
-
return
|
|
6071
|
+
function la(e) {
|
|
6072
|
+
return sa(e.assessment) || ca(e.currentItemRef) ? "on" : "off";
|
|
5871
6073
|
}
|
|
5872
6074
|
//#endregion
|
|
5873
|
-
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.
|
|
5874
|
-
var
|
|
6075
|
+
//#region ../../node_modules/.bun/@pie-players+pie-assessment-toolkit@0.3.73+4df9da1290a48f6a/node_modules/@pie-players/pie-assessment-toolkit/dist/policy/sources/PnpPolicySource.js
|
|
6076
|
+
var ua = class {
|
|
5875
6077
|
id = "pnp";
|
|
5876
6078
|
toolRegistry;
|
|
5877
6079
|
constructor(e) {
|
|
@@ -5893,6 +6095,7 @@ var $i = class {
|
|
|
5893
6095
|
mandatedToolIds: /* @__PURE__ */ new Set(),
|
|
5894
6096
|
perToolFlags: /* @__PURE__ */ new Map(),
|
|
5895
6097
|
decisions: [],
|
|
6098
|
+
unmappedSupportIds: /* @__PURE__ */ new Set(),
|
|
5896
6099
|
sources: {}
|
|
5897
6100
|
};
|
|
5898
6101
|
return (i?.districtPolicy || i?.testAdministration) && (o.sources.assessment = {
|
|
@@ -5920,7 +6123,7 @@ var $i = class {
|
|
|
5920
6123
|
}
|
|
5921
6124
|
resolveSupport(e, t, n) {
|
|
5922
6125
|
if (t.districtPolicy?.blockedTools?.includes(e)) {
|
|
5923
|
-
let r = this.mapSupportToToolId(e);
|
|
6126
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5924
6127
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
5925
6128
|
precedence: 1,
|
|
5926
6129
|
rule: "district-block",
|
|
@@ -5933,7 +6136,7 @@ var $i = class {
|
|
|
5933
6136
|
return;
|
|
5934
6137
|
}
|
|
5935
6138
|
if (t.testAdmin?.toolOverrides?.[e] === !1) {
|
|
5936
|
-
let r = this.mapSupportToToolId(e);
|
|
6139
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5937
6140
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
5938
6141
|
precedence: 2,
|
|
5939
6142
|
rule: "test-admin-override",
|
|
@@ -5946,7 +6149,7 @@ var $i = class {
|
|
|
5946
6149
|
return;
|
|
5947
6150
|
}
|
|
5948
6151
|
if (t.itemSettings?.restrictedTools?.includes(e)) {
|
|
5949
|
-
let r = this.mapSupportToToolId(e);
|
|
6152
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5950
6153
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
5951
6154
|
precedence: 3,
|
|
5952
6155
|
rule: "item-restriction",
|
|
@@ -5959,7 +6162,7 @@ var $i = class {
|
|
|
5959
6162
|
return;
|
|
5960
6163
|
}
|
|
5961
6164
|
if (t.itemSettings?.requiredTools?.includes(e)) {
|
|
5962
|
-
let r = this.mapSupportToToolId(e);
|
|
6165
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5963
6166
|
n.mandatedToolIds.add(r), n.perToolFlags.set(r, {
|
|
5964
6167
|
required: !0,
|
|
5965
6168
|
alwaysAvailable: !1,
|
|
@@ -5978,7 +6181,7 @@ var $i = class {
|
|
|
5978
6181
|
return;
|
|
5979
6182
|
}
|
|
5980
6183
|
if (t.districtPolicy?.requiredTools?.includes(e)) {
|
|
5981
|
-
let r = this.mapSupportToToolId(e);
|
|
6184
|
+
let r = this.mapSupportToToolId(e, n);
|
|
5982
6185
|
n.mandatedToolIds.add(r), n.perToolFlags.set(r, {
|
|
5983
6186
|
required: !0,
|
|
5984
6187
|
alwaysAvailable: !1,
|
|
@@ -5997,7 +6200,7 @@ var $i = class {
|
|
|
5997
6200
|
return;
|
|
5998
6201
|
}
|
|
5999
6202
|
if (t.pnp?.prohibitedSupports?.includes(e)) {
|
|
6000
|
-
let r = this.mapSupportToToolId(e);
|
|
6203
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6001
6204
|
n.blockedToolIds.add(r), n.decisions.push({
|
|
6002
6205
|
precedence: 6,
|
|
6003
6206
|
rule: "pnp-prohibited",
|
|
@@ -6010,7 +6213,7 @@ var $i = class {
|
|
|
6010
6213
|
return;
|
|
6011
6214
|
}
|
|
6012
6215
|
if (t.pnp?.supports?.includes(e)) {
|
|
6013
|
-
let r = this.mapSupportToToolId(e);
|
|
6216
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6014
6217
|
n.perToolFlags.set(r, {
|
|
6015
6218
|
required: !1,
|
|
6016
6219
|
alwaysAvailable: !0,
|
|
@@ -6028,7 +6231,7 @@ var $i = class {
|
|
|
6028
6231
|
});
|
|
6029
6232
|
return;
|
|
6030
6233
|
}
|
|
6031
|
-
let r = this.mapSupportToToolId(e);
|
|
6234
|
+
let r = this.mapSupportToToolId(e, n);
|
|
6032
6235
|
n.decisions.push({
|
|
6033
6236
|
precedence: 6,
|
|
6034
6237
|
rule: "pnp-support",
|
|
@@ -6039,14 +6242,14 @@ var $i = class {
|
|
|
6039
6242
|
value: { supportId: e }
|
|
6040
6243
|
});
|
|
6041
6244
|
}
|
|
6042
|
-
mapSupportToToolId(e) {
|
|
6043
|
-
let
|
|
6044
|
-
return
|
|
6245
|
+
mapSupportToToolId(e, t) {
|
|
6246
|
+
let n = this.toolRegistry.getToolsByPNPSupport(e);
|
|
6247
|
+
return n.size === 0 ? (this.toolRegistry.getAllTools().length > 0 && t.unmappedSupportIds.add(e), e) : Array.from(n)[0];
|
|
6045
6248
|
}
|
|
6046
6249
|
resolveToolSettings(e, t) {
|
|
6047
6250
|
return t.itemSettings?.toolParameters?.[e] ?? t.toolConfigs?.[e];
|
|
6048
6251
|
}
|
|
6049
|
-
},
|
|
6252
|
+
}, da = Ae({
|
|
6050
6253
|
policy: {
|
|
6051
6254
|
allowed: [],
|
|
6052
6255
|
blocked: []
|
|
@@ -6057,7 +6260,7 @@ var $i = class {
|
|
|
6057
6260
|
passage: []
|
|
6058
6261
|
},
|
|
6059
6262
|
providers: {}
|
|
6060
|
-
}),
|
|
6263
|
+
}), fa = class {
|
|
6061
6264
|
toolRegistry;
|
|
6062
6265
|
contextId;
|
|
6063
6266
|
pnpPolicySource;
|
|
@@ -6069,9 +6272,9 @@ var $i = class {
|
|
|
6069
6272
|
pnpEnforcement;
|
|
6070
6273
|
disposed = !1;
|
|
6071
6274
|
constructor(e) {
|
|
6072
|
-
this.toolRegistry = e.toolRegistry, this.contextId = e.contextId ?? "tool-policy", this.pnpPolicySource = new
|
|
6275
|
+
this.toolRegistry = e.toolRegistry, this.contextId = e.contextId ?? "tool-policy", this.pnpPolicySource = new ua(this.toolRegistry), this.customSources = e.customSources ? [...e.customSources] : [];
|
|
6073
6276
|
let t = e.inputs ?? {};
|
|
6074
|
-
this.tools = t.tools ??
|
|
6277
|
+
this.tools = t.tools ?? da, this.assessment = t.assessment ?? null, this.currentItemRef = t.currentItemRef ?? null, this.pnpEnforcement = t.pnpEnforcement ?? la({
|
|
6075
6278
|
assessment: this.assessment,
|
|
6076
6279
|
currentItemRef: this.currentItemRef
|
|
6077
6280
|
});
|
|
@@ -6079,7 +6282,7 @@ var $i = class {
|
|
|
6079
6282
|
decide(e) {
|
|
6080
6283
|
this.assertNotDisposed();
|
|
6081
6284
|
let t = e.scope.scopeId ? `${this.contextId}:${e.level}:${e.scope.scopeId}` : `${this.contextId}:${e.level}`;
|
|
6082
|
-
return
|
|
6285
|
+
return aa({
|
|
6083
6286
|
request: e,
|
|
6084
6287
|
tools: this.tools,
|
|
6085
6288
|
pnpPolicy: {
|
|
@@ -6093,16 +6296,16 @@ var $i = class {
|
|
|
6093
6296
|
});
|
|
6094
6297
|
}
|
|
6095
6298
|
decideFeature(e) {
|
|
6096
|
-
return this.assertNotDisposed(), this.hostFeatureGate(e) ||
|
|
6299
|
+
return this.assertNotDisposed(), this.hostFeatureGate(e) || na(e, this.pnpPolicySource.resolveFeature(e, {
|
|
6097
6300
|
assessment: this.assessment ?? void 0,
|
|
6098
6301
|
currentItemRef: this.currentItemRef ?? void 0
|
|
6099
6302
|
}), { assessmentBound: this.assessment !== null });
|
|
6100
6303
|
}
|
|
6101
6304
|
hostFeatureGate(e) {
|
|
6102
|
-
let t = { assessmentBound: this.assessment !== null }, n =
|
|
6103
|
-
if (n.includes(e)) return
|
|
6104
|
-
let r =
|
|
6105
|
-
return r.length > 0 && !r.includes(e) ?
|
|
6305
|
+
let t = { assessmentBound: this.assessment !== null }, n = w(this.tools.policy.blocked);
|
|
6306
|
+
if (n.includes(e)) return ta(e, "host-blocked", n, t);
|
|
6307
|
+
let r = w(this.tools.policy.allowed);
|
|
6308
|
+
return r.length > 0 && !r.includes(e) ? ta(e, "host-allowlist", r, t) : null;
|
|
6106
6309
|
}
|
|
6107
6310
|
getVisibleToolIds(e, t) {
|
|
6108
6311
|
return this.decide({
|
|
@@ -6117,7 +6320,7 @@ var $i = class {
|
|
|
6117
6320
|
this.assertNotDisposed();
|
|
6118
6321
|
let t = !1, n = !1;
|
|
6119
6322
|
if ("tools" in e) {
|
|
6120
|
-
let n = e.tools ??
|
|
6323
|
+
let n = e.tools ?? da;
|
|
6121
6324
|
Object.is(this.tools, n) || (this.tools = n, t = !0);
|
|
6122
6325
|
}
|
|
6123
6326
|
if ("assessment" in e) {
|
|
@@ -6175,7 +6378,15 @@ var $i = class {
|
|
|
6175
6378
|
assertNotDisposed() {
|
|
6176
6379
|
if (this.disposed) throw Error("ToolPolicyEngine has been disposed.");
|
|
6177
6380
|
}
|
|
6178
|
-
},
|
|
6381
|
+
}, Q = class extends Error {
|
|
6382
|
+
constructor() {
|
|
6383
|
+
super("ToolkitCoordinator has been disposed."), this.name = "ToolkitCoordinatorDisposedError";
|
|
6384
|
+
}
|
|
6385
|
+
}, pa = class extends Error {
|
|
6386
|
+
constructor() {
|
|
6387
|
+
super("Section controller acquisition was retired during initialization."), this.name = "SectionControllerRetiredError";
|
|
6388
|
+
}
|
|
6389
|
+
}, $ = (e) => !!e && typeof e == "object" && !Array.isArray(e), ma = (e, t, n) => {
|
|
6179
6390
|
let r = {
|
|
6180
6391
|
...t,
|
|
6181
6392
|
...n
|
|
@@ -6187,20 +6398,23 @@ var $i = class {
|
|
|
6187
6398
|
...t.settings.mathSpeech,
|
|
6188
6399
|
...n.settings.mathSpeech
|
|
6189
6400
|
})), r;
|
|
6190
|
-
},
|
|
6401
|
+
}, ha = [
|
|
6191
6402
|
"item-selected",
|
|
6192
6403
|
"item-session-data-changed",
|
|
6193
6404
|
"item-session-meta-changed",
|
|
6194
6405
|
"item-complete-changed",
|
|
6195
6406
|
"content-loaded",
|
|
6196
6407
|
"item-player-error"
|
|
6197
|
-
],
|
|
6408
|
+
], ga = [
|
|
6198
6409
|
"section-navigation-change",
|
|
6199
6410
|
"section-session-applied",
|
|
6200
6411
|
"section-loading-complete",
|
|
6201
6412
|
"section-items-complete-changed",
|
|
6202
|
-
"section-error"
|
|
6203
|
-
|
|
6413
|
+
"section-error",
|
|
6414
|
+
"timed-media-cue-changed",
|
|
6415
|
+
"timed-media-policy-degraded",
|
|
6416
|
+
"timed-media-invalid"
|
|
6417
|
+
], _a = class e {
|
|
6204
6418
|
assessmentId;
|
|
6205
6419
|
config;
|
|
6206
6420
|
ttsService;
|
|
@@ -6222,9 +6436,11 @@ var $i = class {
|
|
|
6222
6436
|
toolRegistry;
|
|
6223
6437
|
toolContextResolvers = /* @__PURE__ */ new Map();
|
|
6224
6438
|
toolContextResolverChangeListeners = /* @__PURE__ */ new Set();
|
|
6439
|
+
toolRequests = new Ie();
|
|
6225
6440
|
sectionControllers = /* @__PURE__ */ new Map();
|
|
6226
6441
|
sectionControllerKeys = /* @__PURE__ */ new Map();
|
|
6227
|
-
|
|
6442
|
+
sectionControllerInitEntries = /* @__PURE__ */ new Map();
|
|
6443
|
+
sectionControllerDisposePromises = /* @__PURE__ */ new Map();
|
|
6228
6444
|
sectionPersistenceStrategies = /* @__PURE__ */ new Map();
|
|
6229
6445
|
sectionControllerLifecycleListeners = /* @__PURE__ */ new Set();
|
|
6230
6446
|
activeSubscriptions = /* @__PURE__ */ new Map();
|
|
@@ -6233,13 +6449,15 @@ var $i = class {
|
|
|
6233
6449
|
telemetryListeners = /* @__PURE__ */ new Set();
|
|
6234
6450
|
frameworkErrorBus;
|
|
6235
6451
|
ownsFrameworkErrorBus;
|
|
6452
|
+
frameworkErrorHookUnsubscribe = null;
|
|
6453
|
+
disposePromise = null;
|
|
6236
6454
|
policyEngine;
|
|
6237
6455
|
pnpEnforcementOverride = null;
|
|
6238
6456
|
boundAssessment = null;
|
|
6239
6457
|
boundCurrentItemRef = null;
|
|
6240
6458
|
reportedUnboundFeaturePolicy = !1;
|
|
6241
6459
|
static resolveConfig(e) {
|
|
6242
|
-
let t =
|
|
6460
|
+
let t = He(e.toolConfigStrictness), n = e.toolRegistry ?? new Fe(), r = e.deferToolConfigValidation === !0 ? Ae(e.tools) : D(e.tools, {
|
|
6243
6461
|
strictness: t,
|
|
6244
6462
|
source: "ToolkitCoordinator.init",
|
|
6245
6463
|
toolRegistry: n
|
|
@@ -6271,7 +6489,7 @@ var $i = class {
|
|
|
6271
6489
|
constructor(t) {
|
|
6272
6490
|
if (!t.assessmentId) throw Error("ToolkitCoordinator requires assessmentId in config");
|
|
6273
6491
|
let n = e.resolveConfig(t);
|
|
6274
|
-
this.assessmentId = n.assessmentId, this.config = n, this.toolRegistry = n.toolRegistry ?? new
|
|
6492
|
+
this.assessmentId = n.assessmentId, this.config = n, this.toolRegistry = n.toolRegistry ?? new Fe(), this.installToolContextResolvers(n.toolContextResolvers), this.hooks = n.hooks ?? {}, this.lazyInit = t.lazyInit === !0, this.pnpEnforcementOverride = this.resolveConfiguredPnpEnforcement(), this.frameworkErrorBus = t.frameworkErrorBus ?? new ut(), this.ownsFrameworkErrorBus = !t.frameworkErrorBus, this.subscribeFrameworkErrorHookAdapters(), this.toolCoordinator = new lt(), this.highlightCoordinator = new be(), this.elementToolStateStore = new ve(), this.catalogResolver = new _e(n.accessibility?.catalogs || [], n.accessibility?.language || "en-US"), this.toolProviderRegistry = new Xi(), this._registerToolProviders(), this.ttsService = new Ai(), this.setupStatePersistenceHooks(), this.policyEngine = new fa({
|
|
6275
6493
|
toolRegistry: this.toolRegistry,
|
|
6276
6494
|
contextId: `toolkit-coordinator:${this.assessmentId}`,
|
|
6277
6495
|
inputs: {
|
|
@@ -6281,11 +6499,14 @@ var $i = class {
|
|
|
6281
6499
|
pnpEnforcement: this.resolveEffectivePnpEnforcement()
|
|
6282
6500
|
}
|
|
6283
6501
|
}), this.lazyInit || this.waitUntilReady().catch((e) => {
|
|
6284
|
-
console.error("[ToolkitCoordinator] Failed eager initialization:", e), this.handleError(e, { phase: "coordinator-ready" });
|
|
6502
|
+
e instanceof Q || (console.error("[ToolkitCoordinator] Failed eager initialization:", e), this.handleError(e, { phase: "coordinator-ready" }));
|
|
6285
6503
|
});
|
|
6286
6504
|
}
|
|
6505
|
+
assertNotDisposed() {
|
|
6506
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6507
|
+
}
|
|
6287
6508
|
subscribeFrameworkErrorHookAdapters() {
|
|
6288
|
-
this.frameworkErrorBus.subscribeFrameworkErrors((e) => {
|
|
6509
|
+
this.frameworkErrorHookUnsubscribe = this.frameworkErrorBus.subscribeFrameworkErrors((e) => {
|
|
6289
6510
|
let t = this.hooks.onFrameworkError;
|
|
6290
6511
|
if (t) try {
|
|
6291
6512
|
t(e);
|
|
@@ -6318,7 +6539,7 @@ var $i = class {
|
|
|
6318
6539
|
}
|
|
6319
6540
|
}
|
|
6320
6541
|
handleError(e, t) {
|
|
6321
|
-
let n =
|
|
6542
|
+
let n = Be({
|
|
6322
6543
|
error: e,
|
|
6323
6544
|
context: t
|
|
6324
6545
|
});
|
|
@@ -6381,8 +6602,9 @@ var $i = class {
|
|
|
6381
6602
|
let e = this.hooks.loadToolState;
|
|
6382
6603
|
if (e) try {
|
|
6383
6604
|
let t = await e();
|
|
6384
|
-
t && typeof t == "object" && this.elementToolStateStore.loadState(t), this.stateLoaded = !0, await this.emitTelemetry("pie-toolkit-tool-state-loaded", { hasState: !!t });
|
|
6605
|
+
this.assertNotDisposed(), t && typeof t == "object" && this.elementToolStateStore.loadState(t), this.stateLoaded = !0, await this.emitTelemetry("pie-toolkit-tool-state-loaded", { hasState: !!t });
|
|
6385
6606
|
} catch (e) {
|
|
6607
|
+
if (e instanceof Q) throw e;
|
|
6386
6608
|
this.handleError(e, { phase: "state-load" });
|
|
6387
6609
|
}
|
|
6388
6610
|
})().finally(() => {
|
|
@@ -6456,16 +6678,20 @@ var $i = class {
|
|
|
6456
6678
|
}
|
|
6457
6679
|
}
|
|
6458
6680
|
async ensureProviderReady(e) {
|
|
6681
|
+
this.assertNotDisposed();
|
|
6459
6682
|
let t = this.providerInitPromises.get(e);
|
|
6460
6683
|
if (t) return t;
|
|
6461
6684
|
let n = (async () => {
|
|
6462
|
-
let t = await this.toolProviderRegistry.getProvider(e, !1)
|
|
6685
|
+
let t = await this.toolProviderRegistry.getProvider(e, !1);
|
|
6686
|
+
this.assertNotDisposed();
|
|
6687
|
+
let n = {
|
|
6463
6688
|
providerId: e,
|
|
6464
6689
|
providerName: t.providerName
|
|
6465
6690
|
};
|
|
6466
6691
|
try {
|
|
6467
|
-
return await this.hooks.onProviderInitStart?.(e, n), await this.toolProviderRegistry.initialize(e), await this.hooks.onProviderReady?.(e, n), await this.emitTelemetry("pie-toolkit-provider-ready", { providerId: e }), t;
|
|
6692
|
+
return await this.hooks.onProviderInitStart?.(e, n), this.assertNotDisposed(), await this.toolProviderRegistry.initialize(e), this.assertNotDisposed(), await this.hooks.onProviderReady?.(e, n), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-provider-ready", { providerId: e }), this.assertNotDisposed(), t;
|
|
6468
6693
|
} catch (t) {
|
|
6694
|
+
if (t instanceof Q) throw t;
|
|
6469
6695
|
let n = t instanceof Error ? t : Error(String(t));
|
|
6470
6696
|
throw this.handleError(n, {
|
|
6471
6697
|
phase: "provider-init",
|
|
@@ -6478,7 +6704,7 @@ var $i = class {
|
|
|
6478
6704
|
return this.providerInitPromises.set(e, n), n;
|
|
6479
6705
|
}
|
|
6480
6706
|
setHooks(e) {
|
|
6481
|
-
Object.assign(this.hooks, e), this.setupStatePersistenceHooks(), e.onCoordinatorReady && this.isReady() && Promise.resolve(e.onCoordinatorReady(this)).catch((e) => {
|
|
6707
|
+
Object.assign(this.hooks, e), this.setupStatePersistenceHooks(), this.disposePromise === null && e.onCoordinatorReady && this.isReady() && Promise.resolve(e.onCoordinatorReady(this)).catch((e) => {
|
|
6482
6708
|
this.handleError(e, { phase: "coordinator-ready" });
|
|
6483
6709
|
});
|
|
6484
6710
|
}
|
|
@@ -6600,14 +6826,14 @@ var $i = class {
|
|
|
6600
6826
|
}
|
|
6601
6827
|
subscribeItemEvents(e) {
|
|
6602
6828
|
return this.subscribeSectionEvents({
|
|
6603
|
-
eventTypes: e.eventTypes ||
|
|
6829
|
+
eventTypes: e.eventTypes || ha,
|
|
6604
6830
|
itemIds: e.itemIds,
|
|
6605
6831
|
listener: e.listener
|
|
6606
6832
|
});
|
|
6607
6833
|
}
|
|
6608
6834
|
subscribeSectionLifecycleEvents(e) {
|
|
6609
6835
|
return this.subscribeSectionEvents({
|
|
6610
|
-
eventTypes: e.eventTypes ||
|
|
6836
|
+
eventTypes: e.eventTypes || ga,
|
|
6611
6837
|
listener: e.listener
|
|
6612
6838
|
});
|
|
6613
6839
|
}
|
|
@@ -6617,6 +6843,7 @@ var $i = class {
|
|
|
6617
6843
|
};
|
|
6618
6844
|
}
|
|
6619
6845
|
async getOrCreateSectionController(e) {
|
|
6846
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6620
6847
|
let t = {
|
|
6621
6848
|
assessmentId: this.assessmentId,
|
|
6622
6849
|
sectionId: e.sectionId,
|
|
@@ -6629,23 +6856,36 @@ var $i = class {
|
|
|
6629
6856
|
input: e.input,
|
|
6630
6857
|
updateExisting: e.updateExisting
|
|
6631
6858
|
});
|
|
6632
|
-
if (r)
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6859
|
+
if (r) {
|
|
6860
|
+
if (this.disposePromise !== null) throw new Q();
|
|
6861
|
+
return r;
|
|
6862
|
+
}
|
|
6863
|
+
let i = this.sectionControllerDisposePromises.get(n);
|
|
6864
|
+
if (i && await Promise.allSettled([i]), this.disposePromise !== null) throw new Q();
|
|
6865
|
+
let a = this.sectionControllerInitEntries.get(n);
|
|
6866
|
+
if (a) return a.promise;
|
|
6867
|
+
let o = {
|
|
6868
|
+
retired: !1,
|
|
6869
|
+
candidateClaimed: !1
|
|
6870
|
+
}, s = this.initializeNewSectionController({
|
|
6636
6871
|
args: e,
|
|
6637
6872
|
key: t,
|
|
6638
|
-
mapKey: n
|
|
6873
|
+
mapKey: n,
|
|
6874
|
+
token: o
|
|
6639
6875
|
}).catch((t) => {
|
|
6640
6876
|
throw this.handleSectionControllerInitError(t, e), t;
|
|
6641
6877
|
}).finally(() => {
|
|
6642
|
-
this.
|
|
6878
|
+
this.sectionControllerInitEntries.get(n)?.token === o && this.sectionControllerInitEntries.delete(n);
|
|
6643
6879
|
});
|
|
6644
|
-
return this.
|
|
6880
|
+
return this.sectionControllerInitEntries.set(n, {
|
|
6881
|
+
key: t,
|
|
6882
|
+
token: o,
|
|
6883
|
+
promise: s
|
|
6884
|
+
}), s;
|
|
6645
6885
|
}
|
|
6646
6886
|
async resolveExistingSectionController(e) {
|
|
6647
6887
|
let t = this.sectionControllers.get(e.mapKey);
|
|
6648
|
-
if (t
|
|
6888
|
+
if (t && (this.sectionControllerKeys.set(e.mapKey, e.key), e.updateExisting !== !1 && await t.updateInput?.(e.input), this.sectionControllers.get(e.mapKey) === t)) return this.setActiveCohortIfLatestRequest(e.mapKey), t;
|
|
6649
6889
|
}
|
|
6650
6890
|
createSectionControllerContext(e) {
|
|
6651
6891
|
return {
|
|
@@ -6658,30 +6898,70 @@ var $i = class {
|
|
|
6658
6898
|
let t = this.createSectionControllerContext({
|
|
6659
6899
|
key: e.key,
|
|
6660
6900
|
input: e.args.input
|
|
6661
|
-
}), n = await this.resolveSectionPersistence(t)
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
context: t
|
|
6665
|
-
}), await i.initialize?.(e.args.input), await i.hydrate?.(), await this.finalizeSectionControllerReady({
|
|
6901
|
+
}), n = await this.resolveSectionPersistence(t);
|
|
6902
|
+
if (this.disposePromise !== null || e.token.retired) throw this.sectionPersistenceStrategies.get(e.mapKey) === n && this.sectionPersistenceStrategies.delete(e.mapKey), this.createSectionControllerRetirementError();
|
|
6903
|
+
let r = { createDefaultController: e.args.createDefaultController }, i = await this.hooks.createSectionController?.(t, r) ?? await r.createDefaultController(), a = {
|
|
6666
6904
|
mapKey: e.mapKey,
|
|
6667
6905
|
key: e.key,
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6906
|
+
controller: i,
|
|
6907
|
+
persistence: n,
|
|
6908
|
+
token: e.token
|
|
6909
|
+
};
|
|
6910
|
+
try {
|
|
6911
|
+
return await this.retireUnpublishedSectionControllerIfNeeded(a), await i.configureSessionPersistence?.({
|
|
6912
|
+
strategy: n,
|
|
6913
|
+
context: t
|
|
6914
|
+
}), await this.retireUnpublishedSectionControllerIfNeeded(a), await i.initialize?.(e.args.input), await this.retireUnpublishedSectionControllerIfNeeded(a), await i.hydrate?.(), await this.finalizeSectionControllerReady({
|
|
6915
|
+
...a,
|
|
6916
|
+
context: t
|
|
6917
|
+
}), i;
|
|
6918
|
+
} catch (e) {
|
|
6919
|
+
throw await this.cleanupUnpublishedSectionController(a), e;
|
|
6920
|
+
}
|
|
6921
|
+
}
|
|
6922
|
+
createSectionControllerRetirementError() {
|
|
6923
|
+
return this.disposePromise === null ? new pa() : new Q();
|
|
6924
|
+
}
|
|
6925
|
+
async retireUnpublishedSectionControllerIfNeeded(e) {
|
|
6926
|
+
if (!(this.disposePromise === null && !e.token.retired)) throw await this.cleanupUnpublishedSectionController(e), this.createSectionControllerRetirementError();
|
|
6927
|
+
}
|
|
6928
|
+
async cleanupUnpublishedSectionController(e) {
|
|
6929
|
+
if (!e.token.candidateClaimed) {
|
|
6930
|
+
e.token.candidateClaimed = !0;
|
|
6931
|
+
try {
|
|
6932
|
+
await e.controller.dispose?.();
|
|
6933
|
+
} catch (t) {
|
|
6934
|
+
this.handleError(t, {
|
|
6935
|
+
phase: "section-controller-dispose",
|
|
6936
|
+
details: {
|
|
6937
|
+
sectionId: e.key.sectionId,
|
|
6938
|
+
attemptId: e.key.attemptId
|
|
6939
|
+
}
|
|
6940
|
+
});
|
|
6941
|
+
} finally {
|
|
6942
|
+
this.sectionPersistenceStrategies.get(e.mapKey) === e.persistence && this.sectionPersistenceStrategies.delete(e.mapKey);
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
retirePublishedSectionControllerIfNeeded(e) {
|
|
6947
|
+
if (this.disposePromise !== null && !e.token.retired && this.disposeSectionController({
|
|
6948
|
+
sectionId: e.key.sectionId,
|
|
6949
|
+
attemptId: e.key.attemptId
|
|
6950
|
+
}), e.token.retired) throw this.createSectionControllerRetirementError();
|
|
6671
6951
|
}
|
|
6672
6952
|
async finalizeSectionControllerReady(e) {
|
|
6673
|
-
this.sectionControllers.set(e.mapKey, e.controller), this.sectionControllerKeys.set(e.mapKey, e.key), this.setActiveCohortIfLatestRequest(e.mapKey), this.emitSectionControllerLifecycle({
|
|
6953
|
+
await this.retireUnpublishedSectionControllerIfNeeded(e), this.sectionControllers.set(e.mapKey, e.controller), this.sectionControllerKeys.set(e.mapKey, e.key), e.token.candidateClaimed = !0, this.setActiveCohortIfLatestRequest(e.mapKey), this.emitSectionControllerLifecycle({
|
|
6674
6954
|
type: "ready",
|
|
6675
6955
|
key: e.key,
|
|
6676
6956
|
controller: e.controller
|
|
6677
|
-
}), await this.hooks.onSectionControllerReady?.(e.context, e.controller), await this.emitTelemetry("pie-toolkit-section-controller-ready", {
|
|
6957
|
+
}), await this.hooks.onSectionControllerReady?.(e.context, e.controller), this.retirePublishedSectionControllerIfNeeded(e), await this.emitTelemetry("pie-toolkit-section-controller-ready", {
|
|
6678
6958
|
assessmentId: e.key.assessmentId,
|
|
6679
6959
|
sectionId: e.key.sectionId,
|
|
6680
6960
|
attemptId: e.key.attemptId
|
|
6681
|
-
});
|
|
6961
|
+
}), this.retirePublishedSectionControllerIfNeeded(e);
|
|
6682
6962
|
}
|
|
6683
6963
|
handleSectionControllerInitError(e, t) {
|
|
6684
|
-
this.handleError(e, {
|
|
6964
|
+
e instanceof Q || e instanceof pa || this.handleError(e, {
|
|
6685
6965
|
phase: "section-controller-init",
|
|
6686
6966
|
details: {
|
|
6687
6967
|
sectionId: t.sectionId,
|
|
@@ -6689,57 +6969,126 @@ var $i = class {
|
|
|
6689
6969
|
}
|
|
6690
6970
|
});
|
|
6691
6971
|
}
|
|
6692
|
-
|
|
6972
|
+
disposeSectionController(e) {
|
|
6693
6973
|
let t = {
|
|
6694
6974
|
assessmentId: this.assessmentId,
|
|
6695
6975
|
sectionId: e.sectionId,
|
|
6696
6976
|
attemptId: e.attemptId
|
|
6697
|
-
}, n = this.getSectionControllerMapKey(t), r = this.
|
|
6698
|
-
|
|
6699
|
-
this.
|
|
6700
|
-
|
|
6977
|
+
}, n = this.getSectionControllerMapKey(t), r = this.sectionControllerInitEntries.get(n);
|
|
6978
|
+
r && (r.token.retired = !0);
|
|
6979
|
+
let i = this.sectionControllers.get(n);
|
|
6980
|
+
if (!i) {
|
|
6981
|
+
let e = this.sectionControllerDisposePromises.get(n);
|
|
6982
|
+
if (e) return e;
|
|
6983
|
+
if (!r) return Promise.resolve();
|
|
6984
|
+
let t = Promise.allSettled([r.promise]).then(() => void 0);
|
|
6985
|
+
return this.trackSectionControllerDisposal(n, t);
|
|
6986
|
+
}
|
|
6987
|
+
let a = this.sectionPersistenceStrategies.get(n);
|
|
6988
|
+
this.clearActiveCohortIfMatches(n), this.sectionControllers.get(n) === i && (this.sectionControllers.delete(n), this.sectionControllerKeys.delete(n), this.sectionPersistenceStrategies.delete(n), this.emitSectionControllerLifecycle({
|
|
6989
|
+
type: "disposed",
|
|
6990
|
+
key: t
|
|
6991
|
+
}));
|
|
6992
|
+
let o = this.createSectionControllerContext({
|
|
6701
6993
|
key: t,
|
|
6702
6994
|
input: void 0
|
|
6703
|
-
})
|
|
6995
|
+
}), s = this.disposeSectionControllerEntry({
|
|
6996
|
+
args: e,
|
|
6997
|
+
key: t,
|
|
6998
|
+
context: o,
|
|
6999
|
+
controller: i,
|
|
7000
|
+
persistenceStrategy: a
|
|
7001
|
+
}), c = r ? Promise.allSettled([r.promise]).then(() => s) : s;
|
|
7002
|
+
return this.trackSectionControllerDisposal(n, c);
|
|
7003
|
+
}
|
|
7004
|
+
trackSectionControllerDisposal(e, t) {
|
|
7005
|
+
this.sectionControllerDisposePromises.set(e, t);
|
|
7006
|
+
let n = () => {
|
|
7007
|
+
this.sectionControllerDisposePromises.get(e) === t && this.sectionControllerDisposePromises.delete(e);
|
|
7008
|
+
};
|
|
7009
|
+
return t.then(n, n), t;
|
|
7010
|
+
}
|
|
7011
|
+
async disposeSectionControllerEntry(e) {
|
|
6704
7012
|
try {
|
|
6705
7013
|
await this.runSectionControllerDisposePipeline({
|
|
6706
|
-
key:
|
|
6707
|
-
context:
|
|
6708
|
-
controller:
|
|
6709
|
-
persistBeforeDispose: e.persistBeforeDispose
|
|
7014
|
+
key: e.key,
|
|
7015
|
+
context: e.context,
|
|
7016
|
+
controller: e.controller,
|
|
7017
|
+
persistBeforeDispose: e.args.persistBeforeDispose
|
|
6710
7018
|
});
|
|
6711
7019
|
} catch (t) {
|
|
6712
7020
|
this.handleError(t, {
|
|
6713
7021
|
phase: "section-controller-dispose",
|
|
6714
7022
|
details: {
|
|
6715
|
-
sectionId: e.sectionId,
|
|
6716
|
-
attemptId: e.attemptId
|
|
7023
|
+
sectionId: e.args.sectionId,
|
|
7024
|
+
attemptId: e.args.attemptId
|
|
6717
7025
|
}
|
|
6718
7026
|
});
|
|
6719
7027
|
} finally {
|
|
6720
7028
|
await this.finalizeSectionControllerDispose({
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
clearPersistence: e.clearPersistence
|
|
7029
|
+
context: e.context,
|
|
7030
|
+
persistenceStrategy: e.persistenceStrategy,
|
|
7031
|
+
clearPersistence: e.args.clearPersistence
|
|
6725
7032
|
});
|
|
6726
7033
|
}
|
|
6727
7034
|
}
|
|
6728
7035
|
async runSectionControllerDisposePipeline(e) {
|
|
6729
|
-
|
|
7036
|
+
let t = [];
|
|
7037
|
+
if (e.persistBeforeDispose !== !1) try {
|
|
7038
|
+
await e.controller.persist?.();
|
|
7039
|
+
} catch (e) {
|
|
7040
|
+
t.push(e);
|
|
7041
|
+
}
|
|
7042
|
+
try {
|
|
7043
|
+
await e.controller.dispose?.();
|
|
7044
|
+
} catch (e) {
|
|
7045
|
+
t.push(e);
|
|
7046
|
+
}
|
|
7047
|
+
if (t.length === 1) throw t[0];
|
|
7048
|
+
if (t.length > 1) throw AggregateError(t, "Section controller persistence and disposal both failed.");
|
|
7049
|
+
await this.hooks.onSectionControllerDispose?.(e.context, e.controller), await this.emitTelemetry("pie-toolkit-section-controller-disposed", {
|
|
6730
7050
|
assessmentId: e.key.assessmentId,
|
|
6731
7051
|
sectionId: e.key.sectionId,
|
|
6732
7052
|
attemptId: e.key.attemptId
|
|
6733
7053
|
});
|
|
6734
7054
|
}
|
|
6735
7055
|
async finalizeSectionControllerDispose(e) {
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
7056
|
+
e.clearPersistence && await e.persistenceStrategy?.clearSession?.(e.context);
|
|
7057
|
+
}
|
|
7058
|
+
dispose() {
|
|
7059
|
+
return this.disposePromise ||= Promise.resolve().then(() => this.disposeOwnedResources()), this.disposePromise;
|
|
7060
|
+
}
|
|
7061
|
+
async disposeOwnedResources() {
|
|
7062
|
+
let e = [], t = async (t) => {
|
|
7063
|
+
try {
|
|
7064
|
+
await t();
|
|
7065
|
+
} catch (t) {
|
|
7066
|
+
e.push(t);
|
|
7067
|
+
}
|
|
7068
|
+
};
|
|
7069
|
+
await this.waitForAdmittedInitialization();
|
|
7070
|
+
let n = /* @__PURE__ */ new Map();
|
|
7071
|
+
for (let [e, t] of this.sectionControllerInitEntries) n.set(e, t.key);
|
|
7072
|
+
for (let [e, t] of this.sectionControllerKeys) n.set(e, t);
|
|
7073
|
+
for (let e of n.values()) this.disposeSectionController({
|
|
7074
|
+
sectionId: e.sectionId,
|
|
7075
|
+
attemptId: e.attemptId
|
|
7076
|
+
});
|
|
7077
|
+
await Promise.allSettled(Array.from(this.sectionControllerDisposePromises.values())), this.sectionControllers.clear(), this.sectionControllerKeys.clear(), this.sectionControllerInitEntries.clear(), this.sectionPersistenceStrategies.clear();
|
|
7078
|
+
for (let e of this.activeSubscriptions.values()) await t(() => e.unsubscribeCurrent?.()), e.unsubscribeCurrent = null;
|
|
7079
|
+
this.activeSubscriptions.clear(), this.activeCohortMapKey = null, this.latestRequestedActiveCohortMapKey = null, await t(() => this.ttsService.stop()), await t(() => this.toolProviderRegistry.destroy()), await t(() => this.highlightCoordinator.destroy());
|
|
7080
|
+
for (let e of this.toolCoordinator.getRegisteredTools()) await t(() => this.toolCoordinator.releaseTool(e));
|
|
7081
|
+
if (await t(() => this.catalogResolver.destroy()), await t(() => this.toolRequests.dispose()), await t(() => this.policyEngine.dispose()), this.toolContextResolvers.clear(), this.toolContextResolverChangeListeners.clear(), this.sectionControllerLifecycleListeners.clear(), this.telemetryListeners.clear(), this.frameworkErrorHookUnsubscribe?.(), this.frameworkErrorHookUnsubscribe = null, this.ownsFrameworkErrorBus && this.frameworkErrorBus.dispose(), e.length === 1) throw e[0];
|
|
7082
|
+
if (e.length > 1) throw AggregateError(e, "ToolkitCoordinator cleanup failed for multiple owned resources.");
|
|
7083
|
+
}
|
|
7084
|
+
async waitForAdmittedInitialization() {
|
|
7085
|
+
let e = /* @__PURE__ */ new Set();
|
|
7086
|
+
this.coordinatorReadyPromise && e.add(this.coordinatorReadyPromise), this.ttsInitPromise && e.add(this.ttsInitPromise), this.ttsReconfigurePromise && e.add(this.ttsReconfigurePromise);
|
|
7087
|
+
for (let t of this.providerInitPromises.values()) e.add(t);
|
|
7088
|
+
await Promise.allSettled(e);
|
|
6740
7089
|
}
|
|
6741
7090
|
async ensureTTSReady(e) {
|
|
6742
|
-
if (await this.waitForPendingTTSReconfigure(), !this.ttsInitialized) return this.ttsInitPromise ||= this._initializeTTS(e).finally(() => {
|
|
7091
|
+
if (this.assertNotDisposed(), await this.waitForPendingTTSReconfigure(), this.assertNotDisposed(), !this.ttsInitialized) return this.ttsInitPromise ||= this._initializeTTS(e).then(() => this.assertNotDisposed()).finally(() => {
|
|
6743
7092
|
this.ttsInitPromise = void 0;
|
|
6744
7093
|
}), this.ttsInitPromise;
|
|
6745
7094
|
}
|
|
@@ -6749,11 +7098,11 @@ var $i = class {
|
|
|
6749
7098
|
}
|
|
6750
7099
|
async _initializeTTS(e) {
|
|
6751
7100
|
if (this.ttsInitialized) return;
|
|
6752
|
-
let t =
|
|
7101
|
+
let t = Ui(this.resolveTTSToolConfig(e)), n = Wi(t), r = qi(t);
|
|
6753
7102
|
if (await this.hooks.onBeforeTTSInit?.({
|
|
6754
7103
|
phase: "tts-init",
|
|
6755
7104
|
details: { backend: n }
|
|
6756
|
-
}), await this.emitTelemetry("pie-toolkit-tts-init-start", { backend: n }), await this.emitTelemetry("pie-tool-init-start", {
|
|
7105
|
+
}), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-tts-init-start", { backend: n }), await this.emitTelemetry("pie-tool-init-start", {
|
|
6757
7106
|
toolId: "textToSpeech",
|
|
6758
7107
|
operation: "tts-init",
|
|
6759
7108
|
backend: n
|
|
@@ -6767,6 +7116,7 @@ var $i = class {
|
|
|
6767
7116
|
}), console.log("[ToolkitCoordinator] TTS initialized via ToolProviderRegistry");
|
|
6768
7117
|
return;
|
|
6769
7118
|
} catch (e) {
|
|
7119
|
+
if (e instanceof Q) throw e;
|
|
6770
7120
|
let t = e instanceof Error ? e : Error(String(e));
|
|
6771
7121
|
await this.emitTelemetry("pie-tool-init-error", {
|
|
6772
7122
|
toolId: "textToSpeech",
|
|
@@ -6786,7 +7136,7 @@ var $i = class {
|
|
|
6786
7136
|
reason: t.message
|
|
6787
7137
|
}), console.warn("[ToolkitCoordinator] Failed to initialize TTS via registry, falling back to browser provider:", t);
|
|
6788
7138
|
}
|
|
6789
|
-
let i = new
|
|
7139
|
+
let i = new j();
|
|
6790
7140
|
try {
|
|
6791
7141
|
await this.initializeTTSService(i, r), await this.emitTelemetry("pie-toolkit-tts-init-success", { provider: "browser-fallback" }), await this.emitTelemetry("pie-tool-init-success", {
|
|
6792
7142
|
toolId: "textToSpeech",
|
|
@@ -6795,6 +7145,7 @@ var $i = class {
|
|
|
6795
7145
|
provider: "browser-fallback"
|
|
6796
7146
|
});
|
|
6797
7147
|
} catch (e) {
|
|
7148
|
+
if (e instanceof Q) throw e;
|
|
6798
7149
|
let t = e instanceof Error ? e : Error(String(e));
|
|
6799
7150
|
throw this.handleError(t, { phase: "tts-init" }), await this.emitTelemetry("pie-toolkit-tts-init-error", { message: t.message }), await this.emitTelemetry("pie-tool-init-error", {
|
|
6800
7151
|
toolId: "textToSpeech",
|
|
@@ -6821,7 +7172,7 @@ var $i = class {
|
|
|
6821
7172
|
...t,
|
|
6822
7173
|
providerOptions: n
|
|
6823
7174
|
};
|
|
6824
|
-
await this.ttsService.initialize(e, r), await this.ensureBrowserVoicesReady(e), this.ttsService.setCatalogResolver(this.catalogResolver), this.ttsInitialized = !0, await this.hooks.onTTSReady?.();
|
|
7175
|
+
await this.ttsService.initialize(e, r), await this.ensureBrowserVoicesReady(e), this.assertNotDisposed(), this.ttsService.setCatalogResolver(this.catalogResolver), this.ttsInitialized = !0, await this.hooks.onTTSReady?.(), this.assertNotDisposed();
|
|
6825
7176
|
}
|
|
6826
7177
|
async ensureBrowserVoicesReady(e, t = 1200) {
|
|
6827
7178
|
if (e.providerId !== "browser" || typeof window > "u" || !("speechSynthesis" in window)) return;
|
|
@@ -6855,10 +7206,10 @@ var $i = class {
|
|
|
6855
7206
|
return this.ensureProviderReady(e);
|
|
6856
7207
|
}
|
|
6857
7208
|
async waitUntilReady() {
|
|
6858
|
-
if (!this.isReady()) return this.coordinatorReadyPromise ||= (async () => {
|
|
6859
|
-
await this.ensureStateLoaded();
|
|
7209
|
+
if (this.assertNotDisposed(), !this.isReady()) return this.coordinatorReadyPromise ||= (async () => {
|
|
7210
|
+
await this.ensureStateLoaded(), this.assertNotDisposed();
|
|
6860
7211
|
let e = this.getTTSConfigFromProviders();
|
|
6861
|
-
e?.enabled !== !1 && await this.ensureTTSReady(e), this.coordinatorReadyNotified || (this.coordinatorReadyNotified = !0, await this.hooks.onCoordinatorReady?.(this), await this.emitTelemetry("pie-toolkit-coordinator-ready", { assessmentId: this.assessmentId }));
|
|
7212
|
+
e?.enabled !== !1 && await this.ensureTTSReady(e), this.assertNotDisposed(), this.coordinatorReadyNotified || (this.coordinatorReadyNotified = !0, await this.hooks.onCoordinatorReady?.(this), this.assertNotDisposed(), await this.emitTelemetry("pie-toolkit-coordinator-ready", { assessmentId: this.assessmentId }));
|
|
6862
7213
|
})().finally(() => {
|
|
6863
7214
|
this.coordinatorReadyPromise = void 0;
|
|
6864
7215
|
}), this.coordinatorReadyPromise;
|
|
@@ -6912,15 +7263,15 @@ var $i = class {
|
|
|
6912
7263
|
updateToolConfig(e, t) {
|
|
6913
7264
|
this.assertCanonicalToolId(e);
|
|
6914
7265
|
let n = this.getToolConfig(e) || {};
|
|
6915
|
-
this.config.tools || (this.config.tools =
|
|
7266
|
+
this.config.tools || (this.config.tools = D(void 0, {
|
|
6916
7267
|
strictness: this.config.toolConfigStrictness ?? "error",
|
|
6917
7268
|
source: "ToolkitCoordinator.updateToolConfig",
|
|
6918
7269
|
toolRegistry: this.toolRegistry
|
|
6919
7270
|
}).config), this.config.tools.providers || (this.config.tools.providers = {});
|
|
6920
7271
|
let r = {
|
|
6921
7272
|
...this.config.tools.providers || {},
|
|
6922
|
-
[e]:
|
|
6923
|
-
}, i =
|
|
7273
|
+
[e]: ma(e, n, t)
|
|
7274
|
+
}, i = D({
|
|
6924
7275
|
...this.config.tools,
|
|
6925
7276
|
providers: r
|
|
6926
7277
|
}, {
|
|
@@ -6934,7 +7285,7 @@ var $i = class {
|
|
|
6934
7285
|
this.updateToolsPlacement({ [e]: [...t] });
|
|
6935
7286
|
}
|
|
6936
7287
|
updateToolsPlacement(e) {
|
|
6937
|
-
this.config.tools || (this.config.tools =
|
|
7288
|
+
this.config.tools || (this.config.tools = D(void 0, {
|
|
6938
7289
|
strictness: this.config.toolConfigStrictness ?? "error",
|
|
6939
7290
|
source: "ToolkitCoordinator.updateToolsPlacement",
|
|
6940
7291
|
toolRegistry: this.toolRegistry
|
|
@@ -6947,7 +7298,7 @@ var $i = class {
|
|
|
6947
7298
|
section: [...e.section ?? t.section ?? []],
|
|
6948
7299
|
item: [...e.item ?? t.item ?? []],
|
|
6949
7300
|
passage: [...e.passage ?? t.passage ?? []]
|
|
6950
|
-
}, r =
|
|
7301
|
+
}, r = D({
|
|
6951
7302
|
...this.config.tools,
|
|
6952
7303
|
placement: n
|
|
6953
7304
|
}, {
|
|
@@ -7033,8 +7384,25 @@ var $i = class {
|
|
|
7033
7384
|
this.toolContextResolverChangeListeners.delete(e);
|
|
7034
7385
|
};
|
|
7035
7386
|
}
|
|
7387
|
+
registerToolRequestTarget(e) {
|
|
7388
|
+
return this.toolRequests.registerTarget(e);
|
|
7389
|
+
}
|
|
7390
|
+
requestTool(e) {
|
|
7391
|
+
return this.assertCanonicalToolId(e.toolId), this.toolRequests.request(e);
|
|
7392
|
+
}
|
|
7393
|
+
canRequestTool(e, t) {
|
|
7394
|
+
try {
|
|
7395
|
+
this.assertCanonicalToolId(e);
|
|
7396
|
+
} catch {
|
|
7397
|
+
return !1;
|
|
7398
|
+
}
|
|
7399
|
+
return this.toolRequests.canRequest(e, t);
|
|
7400
|
+
}
|
|
7401
|
+
onToolRequestTargetsChange(e) {
|
|
7402
|
+
return this.toolRequests.onTargetsChange(e);
|
|
7403
|
+
}
|
|
7036
7404
|
resolveEffectivePnpEnforcement() {
|
|
7037
|
-
return this.pnpEnforcementOverride === null ?
|
|
7405
|
+
return this.pnpEnforcementOverride === null ? la({
|
|
7038
7406
|
assessment: this.boundAssessment,
|
|
7039
7407
|
currentItemRef: this.boundCurrentItemRef
|
|
7040
7408
|
}) : this.pnpEnforcementOverride;
|
|
@@ -7043,12 +7411,13 @@ var $i = class {
|
|
|
7043
7411
|
return this.config.tools?.pnpEnforcement ?? null;
|
|
7044
7412
|
}
|
|
7045
7413
|
_applyToolConfigChange(e, t) {
|
|
7046
|
-
switch (e) {
|
|
7414
|
+
if (this.disposePromise === null) switch (e) {
|
|
7047
7415
|
case "textToSpeech": {
|
|
7048
7416
|
let e = this._reconfigureTTSProvider();
|
|
7049
7417
|
this.ttsReconfigurePromise = e, e.finally(() => {
|
|
7050
7418
|
this.ttsReconfigurePromise === e && (this.ttsReconfigurePromise = void 0);
|
|
7051
7419
|
}), e.then(async () => {
|
|
7420
|
+
if (this.disposePromise !== null) return;
|
|
7052
7421
|
let e = this.getTTSConfigFromProviders();
|
|
7053
7422
|
!this.lazyInit && e?.enabled !== !1 && await this.ensureTTSReady(e);
|
|
7054
7423
|
});
|
|
@@ -7061,27 +7430,27 @@ var $i = class {
|
|
|
7061
7430
|
try {
|
|
7062
7431
|
this.ttsService.stop();
|
|
7063
7432
|
} catch {}
|
|
7064
|
-
this.toolProviderRegistry.has("tts") && await this.toolProviderRegistry.unregister("tts");
|
|
7433
|
+
if (this.toolProviderRegistry.has("tts") && await this.toolProviderRegistry.unregister("tts"), this.disposePromise !== null) return;
|
|
7065
7434
|
let e = this.getProviderDescriptorTools().find((e) => e.toolId === "textToSpeech");
|
|
7066
7435
|
e && await this.registerProviderFromTool(e);
|
|
7067
7436
|
}
|
|
7068
|
-
},
|
|
7437
|
+
}, va = /* @__PURE__ */ new Set([
|
|
7069
7438
|
"assessment",
|
|
7070
7439
|
"section",
|
|
7071
7440
|
"item",
|
|
7072
7441
|
"passage",
|
|
7073
7442
|
"rubric"
|
|
7074
7443
|
]);
|
|
7075
|
-
function
|
|
7076
|
-
return
|
|
7444
|
+
function ya(e) {
|
|
7445
|
+
return va.has(e);
|
|
7077
7446
|
}
|
|
7078
|
-
function
|
|
7447
|
+
function ba(e, t, n) {
|
|
7079
7448
|
let r = e.trim(), i = n.trim();
|
|
7080
7449
|
if (!r || !i) throw Error("Tool instance ids require non-empty tool and scope ids");
|
|
7081
|
-
if (!
|
|
7450
|
+
if (!ya(t)) throw Error(`Unknown tool scope level '${t}'. Register custom levels with registerToolScopeLevel().`);
|
|
7082
7451
|
return `${r}:${t}:${i}`;
|
|
7083
7452
|
}
|
|
7084
7453
|
//#endregion
|
|
7085
|
-
export {
|
|
7454
|
+
export { o as C, s as S, Fe as _, Zi as a, ee as b, Vi as c, Yi as d, Ji as f, j as g, Di as h, Qi as i, Gi as l, Ki as m, _a as n, qi as o, Ui as p, $i as r, Pi as s, ba as t, Wi as u, te as v, p as x, h as y };
|
|
7086
7455
|
|
|
7087
|
-
//# sourceMappingURL=dist-
|
|
7456
|
+
//# sourceMappingURL=dist-C8BDh5vZ.js.map
|