@burdenoff/fe-libs 2026.1009.2 → 2026.1010.1

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.
Files changed (51) hide show
  1. package/dist/shared/assistant/appControls/languages.d.ts +2 -0
  2. package/dist/shared/assistant/appControls/languages.js +8 -5
  3. package/dist/shared/assistant/index.d.ts +18 -0
  4. package/dist/shared/assistant/localUiCommands.d.ts +33 -0
  5. package/dist/shared/assistant/localUiCommands.js +159 -88
  6. package/dist/shared/assistant/localeCommands/active.d.ts +19 -0
  7. package/dist/shared/assistant/localeCommands/active.js +25 -0
  8. package/dist/shared/assistant/localeCommands/assent.d.ts +25 -0
  9. package/dist/shared/assistant/localeCommands/assent.js +78 -0
  10. package/dist/shared/assistant/localeCommands/engine.d.ts +89 -0
  11. package/dist/shared/assistant/localeCommands/engine.js +351 -0
  12. package/dist/shared/assistant/localeCommands/evaluate.d.ts +77 -0
  13. package/dist/shared/assistant/localeCommands/evaluate.js +180 -0
  14. package/dist/shared/assistant/localeCommands/fold.d.ts +17 -0
  15. package/dist/shared/assistant/localeCommands/fold.js +66 -0
  16. package/dist/shared/assistant/localeCommands/frames.d.ts +23 -0
  17. package/dist/shared/assistant/localeCommands/frames.js +150 -0
  18. package/dist/shared/assistant/localeCommands/gate.d.ts +37 -0
  19. package/dist/shared/assistant/localeCommands/gate.js +137 -0
  20. package/dist/shared/assistant/localeCommands/languageNames.d.ts +11 -0
  21. package/dist/shared/assistant/localeCommands/languageNames.js +53 -0
  22. package/dist/shared/assistant/localeCommands/nameForms.d.ts +21 -0
  23. package/dist/shared/assistant/localeCommands/nameForms.js +44 -0
  24. package/dist/shared/assistant/localeCommands/normalise.d.ts +49 -0
  25. package/dist/shared/assistant/localeCommands/normalise.js +87 -0
  26. package/dist/shared/assistant/localeCommands/symbols.d.ts +8 -0
  27. package/dist/shared/assistant/localeCommands/symbols.js +6 -0
  28. package/dist/shared/assistant/localeCommands/tables/ar.d.ts +10 -0
  29. package/dist/shared/assistant/localeCommands/tables/ar.js +343 -0
  30. package/dist/shared/assistant/localeCommands/tables/en.d.ts +12 -0
  31. package/dist/shared/assistant/localeCommands/tables/en.js +28 -0
  32. package/dist/shared/assistant/localeCommands/tables/es.d.ts +7 -0
  33. package/dist/shared/assistant/localeCommands/tables/es.js +356 -0
  34. package/dist/shared/assistant/localeCommands/tables/hi.d.ts +9 -0
  35. package/dist/shared/assistant/localeCommands/tables/hi.js +495 -0
  36. package/dist/shared/assistant/localeCommands/tables/ta.d.ts +10 -0
  37. package/dist/shared/assistant/localeCommands/tables/ta.js +429 -0
  38. package/dist/shared/assistant/localeCommands/tables/zh.d.ts +9 -0
  39. package/dist/shared/assistant/localeCommands/tables/zh.js +402 -0
  40. package/dist/shared/assistant/localeCommands/types.d.ts +172 -0
  41. package/dist/shared/assistant/localeCommands/types.js +19 -0
  42. package/dist/shared/assistant/ui/AssistantChatArea.js +1340 -1330
  43. package/dist/shared/assistant/uiActions/linkContext.d.ts +20 -1
  44. package/dist/shared/assistant/uiActions/linkContext.js +39 -21
  45. package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts +6 -0
  46. package/dist/shared/assistant/uiActions/offerYesOnSurface.js +1 -1
  47. package/dist/shared/assistant/writeReplyBinder.d.ts +1 -1
  48. package/dist/shared/assistant/writeReplySend.d.ts +16 -0
  49. package/dist/shared/assistant/writeReplySend.js +23 -1
  50. package/dist/shared-assistant.js +55 -37
  51. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ import { effectiveManifest as e, isEnabled as t } from "./gate.js";
2
+ import { carriesSymbolOrEmoticon as n } from "./symbols.js";
3
+ import { foldText as r } from "./fold.js";
4
+ import { buildPrep as i, collapseRepeat as a, foldedList as o, removeFillers as s, stripEdges as c } from "./normalise.js";
5
+ import { LOCALE_TABLES as l, activeCommandLocales as u } from "./active.js";
6
+ //#region src/shared/assistant/localeCommands/assent.ts
7
+ var d = [
8
+ "no",
9
+ "nope",
10
+ "nah",
11
+ "not",
12
+ "never",
13
+ "dont",
14
+ "don",
15
+ "cancel",
16
+ "stop",
17
+ "wait",
18
+ "but",
19
+ "however",
20
+ "though",
21
+ "nothing"
22
+ ], f = /[?¿؟?]/u, p = 3, m = 6, h = /* @__PURE__ */ new Map();
23
+ function g(e) {
24
+ let t = h.get(e);
25
+ if (t) return t;
26
+ let n = l[e], r = {
27
+ locale: e,
28
+ prep: i(n, e),
29
+ tierA: new Set(o(n.yes.tierA, e)),
30
+ negation: new Set(o(n.yes.negation, e))
31
+ };
32
+ return h.set(e, r), r;
33
+ }
34
+ function _(e, t) {
35
+ let n = r(e, t.locale);
36
+ if (!n) return null;
37
+ let i = c(a(s(n, t.prep), t.prep.zh), t.prep.prefix, t.prep.suffix, t.prep.zh);
38
+ return i && i.length > 0 ? i : null;
39
+ }
40
+ function v(e, t) {
41
+ if (t.prep.zh) {
42
+ if (e.length > 6) return !1;
43
+ let n = Array(e.length + 1).fill(!1);
44
+ n[0] = !0;
45
+ for (let r = 0; r < e.length; r += 1) if (n[r]) for (let i of t.tierA) e.startsWith(i, r) && (n[r + i.length] = !0);
46
+ return n[e.length] === !0;
47
+ }
48
+ let n = e.split(" ");
49
+ if (n.length > 3) return !1;
50
+ let r = (e) => {
51
+ if (e === n.length) return !0;
52
+ for (let i = Math.min(3, n.length - e); i > 0; --i) if (t.tierA.has(n.slice(e, e + i).join(" ")) && r(e + i)) return !0;
53
+ return !1;
54
+ };
55
+ return r(0);
56
+ }
57
+ function y(i) {
58
+ if (i.leaveGuard !== !0 || typeof i.text != "string" || f.test(i.text) || n(i.text.normalize("NFKC").trim())) return !1;
59
+ let a = e(i.manifest), o = u({
60
+ ui: i.uiLocale,
61
+ input: i.inputLocale,
62
+ narrow: i.commandLocales,
63
+ manifest: a
64
+ }).filter((e) => t(a, e, "yes"));
65
+ if (o.length === 0) return !1;
66
+ let s = o.map(g), c = new Set(d);
67
+ for (let e of s) for (let t of e.negation) c.add(t);
68
+ for (let e of s) {
69
+ let t = r(i.text, e.locale);
70
+ if (!t || !e.prep.zh && t.split(" ").some((e) => c.has(e))) return !1;
71
+ }
72
+ return s.some((e) => {
73
+ let t = _(i.text, e);
74
+ return t !== null && v(t, e);
75
+ });
76
+ }
77
+ //#endregion
78
+ export { p as ASSENT_MAX_TOKENS, m as ASSENT_MAX_ZH_CHARS, y as offerAssentFor };
@@ -0,0 +1,89 @@
1
+ import { AppControlRequest } from '../appControls/grammar';
2
+ import { ControlSnapshot } from '../appControls/snapshot';
3
+ import { LocalDestination, ThemeRequest } from '../localUiCommands';
4
+ import { ChoiceRequest } from '../uiActions/deixis';
5
+ import { ClosedSlots, CompiledFrame } from './frames';
6
+ import { FoldLocale, PrepData } from './normalise';
7
+ import { CommandManifest, LocaleTable } from './types';
8
+ export interface CompiledControlPhrase {
9
+ frame: CompiledFrame;
10
+ weak: boolean;
11
+ }
12
+ export interface Compiled {
13
+ fold: FoldLocale;
14
+ zh: boolean;
15
+ prep: PrepData;
16
+ closed: ClosedSlots;
17
+ goto: Record<"go" | "open" | "show", CompiledFrame[]>;
18
+ ambiguous: Set<string>;
19
+ there: CompiledFrame[];
20
+ back: CompiledFrame[];
21
+ pick: CompiledFrame[];
22
+ language: CompiledFrame[];
23
+ theme: Array<{
24
+ frame: CompiledFrame;
25
+ family: "light" | "dark";
26
+ invert: boolean;
27
+ saysTheme: boolean;
28
+ }>;
29
+ controls: {
30
+ phrases: Record<"history" | "transcript" | "previewOpen" | "previewClose" | "newConversation" | "notifications" | "help" | "sidebarCollapse" | "sidebarExpand", CompiledControlPhrase[]>;
31
+ tab: CompiledFrame[];
32
+ filter: CompiledFrame[];
33
+ filterClear: CompiledFrame[];
34
+ sort: CompiledFrame[];
35
+ sortDirection: CompiledFrame[];
36
+ search: CompiledFrame[];
37
+ /** The search frames with `{q}` taken out: a verb on its own ("搜索") is never a query ("索"). */
38
+ searchVerbOnly: CompiledFrame[];
39
+ searchClear: CompiledFrame[];
40
+ };
41
+ }
42
+ /** @internal for the tests: the compiled form of a table (templates, closed slots). */
43
+ export declare function compileNative(table: LocaleTable): Compiled;
44
+ export type ControlIntent = {
45
+ request: AppControlRequest;
46
+ weak: boolean;
47
+ };
48
+ export interface LocaleIntents {
49
+ theme?: ThemeRequest;
50
+ back?: true;
51
+ pick?: ChoiceRequest;
52
+ there?: true;
53
+ goto?: {
54
+ destinations: LocalDestination[];
55
+ query: string;
56
+ };
57
+ control?: ControlIntent;
58
+ }
59
+ export interface LocaleRun {
60
+ /** `hi`, `ta`, … or `en` for the English additions. */
61
+ source: string;
62
+ intents: LocaleIntents;
63
+ }
64
+ export interface LocaleEngineInput {
65
+ /** The sentence with `normalize("NFKC")` and `trim()` applied, as the matcher holds it. */
66
+ said: string;
67
+ destinations: readonly LocalDestination[];
68
+ uiLocale?: string | undefined;
69
+ inputLocale?: string | undefined;
70
+ commandLocales?: readonly string[] | undefined;
71
+ manifest: CommandManifest;
72
+ themeWords?: "any" | "mode-only" | undefined;
73
+ /** An offered navigation context exists (the newest reply's links or list). */
74
+ navigation: boolean;
75
+ backRunnable: boolean;
76
+ controls?: ControlSnapshot | undefined;
77
+ }
78
+ /**
79
+ * Read one sentence with every active table. Empty when nothing is switched on.
80
+ * The caller maps each run's intents to a command and drops the result if two
81
+ * runs disagree.
82
+ */
83
+ export declare function matchLocaleIntents(input: LocaleEngineInput): LocaleRun[];
84
+ /**
85
+ * Could this sentence be "take me there" or a pick, in any active table? The
86
+ * panel builds the offered-navigation context (a parse of the newest reply) only
87
+ * for such a sentence, so an ordinary send never parses a reply.
88
+ */
89
+ export declare function mayBeThereOrPick(input: Omit<LocaleEngineInput, "destinations" | "controls">): boolean;
@@ -0,0 +1,351 @@
1
+ import { effectiveManifest as e, isEnabled as t } from "./gate.js";
2
+ import { foldText as n, foldWords as r } from "./fold.js";
3
+ import { closedSlot as i, compileFrame as a, matchFrame as o } from "./frames.js";
4
+ import { buildPrep as s, isQuestionText as c, normaliseSaid as l } from "./normalise.js";
5
+ import { languageNameMap as u } from "./languageNames.js";
6
+ import { LOCALE_TABLES as d, activeCommandLocales as f } from "./active.js";
7
+ import { ENGLISH_COMMAND_ADDITIONS as p } from "./tables/en.js";
8
+ //#region src/shared/assistant/localeCommands/engine.ts
9
+ var m = {
10
+ maxLength: 80,
11
+ courtesy: {
12
+ prefix: [
13
+ "please",
14
+ "pls",
15
+ "kindly",
16
+ "hey",
17
+ "hi"
18
+ ],
19
+ suffix: [
20
+ "please",
21
+ "pls",
22
+ "thanks",
23
+ "thank you",
24
+ "now"
25
+ ]
26
+ },
27
+ fillers: [
28
+ "um",
29
+ "uh",
30
+ "erm",
31
+ "er",
32
+ "hmm"
33
+ ],
34
+ compound: []
35
+ };
36
+ function h(e, t, n) {
37
+ let r = { p: i([[e.places, "place"]], n) };
38
+ if (t) {
39
+ let { pick: e, controls: a } = t;
40
+ r.o = i([...e.ordinals.map((e, t) => [e, t + 1]), [e.last, "last"]], n), r.n = i(e.numbers.map((e, t) => [e, t + 1]), n), r.d = i([[a.directions.asc, "asc"], [a.directions.desc, "desc"]], n);
41
+ }
42
+ return r;
43
+ }
44
+ var g = /* @__PURE__ */ new Map();
45
+ function _(e, t, r, i, o, c) {
46
+ let l = g.get(c);
47
+ if (l) return l;
48
+ let u = h(t, e, o), d = (e) => e.map((e) => a(e, o, u)), f = (e) => e.map((e) => ({
49
+ frame: a(e.template, o, u),
50
+ weak: e.weak === !0
51
+ })), p = () => [], m = e?.controls, _ = {
52
+ fold: o,
53
+ zh: o === "zh",
54
+ prep: s(i, o),
55
+ closed: u,
56
+ goto: {
57
+ go: d(t.go),
58
+ open: d(t.open),
59
+ show: d(t.show)
60
+ },
61
+ ambiguous: new Set(t.ambiguous.map((e) => b(n(e, o), o))),
62
+ there: d(e?.there ?? []),
63
+ back: d(e?.back ?? []),
64
+ pick: d(e?.pick.frames ?? []),
65
+ language: d(r),
66
+ theme: (e?.theme ?? []).map((e) => ({
67
+ frame: a(e.template, o, u),
68
+ family: e.family,
69
+ invert: e.invert === !0,
70
+ saysTheme: e.saysTheme === !0
71
+ })),
72
+ controls: {
73
+ phrases: {
74
+ history: m ? f(m.history) : p(),
75
+ transcript: m ? f(m.transcript) : p(),
76
+ previewOpen: m ? f(m.previewOpen) : p(),
77
+ previewClose: m ? f(m.previewClose) : p(),
78
+ newConversation: m ? f(m.newConversation) : p(),
79
+ notifications: m ? f(m.notifications) : p(),
80
+ help: m ? f(m.help) : p(),
81
+ sidebarCollapse: m ? f(m.sidebarCollapse) : p(),
82
+ sidebarExpand: m ? f(m.sidebarExpand) : p()
83
+ },
84
+ tab: d(m?.tab ?? []),
85
+ filter: d(m?.filter ?? []),
86
+ filterClear: d(m?.filterClear ?? []),
87
+ sort: d(m?.sort ?? []),
88
+ sortDirection: d(m?.sortDirection ?? []),
89
+ search: d(m?.search ?? []),
90
+ searchVerbOnly: d((m?.search ?? []).map((e) => e.replace(/\s*\{q\}\s*/g, "")).filter((e) => e.length > 0)),
91
+ searchClear: d(m?.searchClear ?? [])
92
+ }
93
+ };
94
+ return g.set(c, _), _;
95
+ }
96
+ function v(e) {
97
+ return _(e, e.goto, e.language, e, e.locale, `native:${e.locale}`);
98
+ }
99
+ function y(e) {
100
+ let t = e?.locale ?? "en", n = e ?? m;
101
+ return _(null, p.goto, p.language, {
102
+ ...n,
103
+ polite: void 0
104
+ }, t, `english:${t}`);
105
+ }
106
+ function b(e, t) {
107
+ return t === "es" ? e.replace(/^(?:el|la|los|las|un|una|unos|unas) (?=\S)/, "") : t === "ar" ? e.replace(/^(?:لل|ال)(?=\S{2})/, "") : e;
108
+ }
109
+ function x(e, t, r) {
110
+ let i = /* @__PURE__ */ new Map(), a = (e, r) => {
111
+ let a = b(n(e, t), t);
112
+ if (!a) return;
113
+ let o = i.get(a) ?? [];
114
+ o.some((e) => e.path === r.path) || o.push(r), i.set(a, o);
115
+ };
116
+ for (let t of e) {
117
+ a(t.label, t), t.context && a(`${t.context} ${t.label}`, t);
118
+ for (let e of r?.(t.label) ?? []) a(e, t);
119
+ }
120
+ return i;
121
+ }
122
+ function S(e, t, r) {
123
+ let i = b(e, r), a = t.filter((e) => b(n(e.label, r), r) === i);
124
+ return a.length === 1 ? a[0] ?? null : null;
125
+ }
126
+ function C(e, t) {
127
+ let n = b(e, t.fold);
128
+ if (t.zh) return [...t.ambiguous].some((e) => n.endsWith(e));
129
+ let r = n.split(" "), i = r[r.length - 1] ?? "", a = r.slice(-2).join(" ");
130
+ return t.ambiguous.has(i) || t.ambiguous.has(a);
131
+ }
132
+ function w(e, t, r) {
133
+ let i = /* @__PURE__ */ new Map(), a = "";
134
+ for (let s of [
135
+ "go",
136
+ "open",
137
+ "show"
138
+ ]) for (let c of e.goto[s]) for (let l of o(c, t)) {
139
+ let t = l.x;
140
+ if (!t) continue;
141
+ let o = r.get(b(t, e.fold));
142
+ if (o && !(s === "open" && l.p === void 0 && (C(t, e) || o.some((t) => C(n(t.label, e.fold), e))))) {
143
+ for (let e of o) i.set(e.path, e);
144
+ a = t;
145
+ }
146
+ }
147
+ return i.size === 0 ? null : {
148
+ destinations: [...i.values()],
149
+ query: a
150
+ };
151
+ }
152
+ function T(e, t, n) {
153
+ for (let r of e.theme) if (!(n === "mode-only" && r.saysTheme) && o(r.frame, t).length !== 0) return {
154
+ kind: "family",
155
+ family: r.invert ? r.family === "dark" ? "light" : "dark" : r.family
156
+ };
157
+ return null;
158
+ }
159
+ function E(e, t) {
160
+ let n = [];
161
+ for (let r of e.pick) for (let i of o(r, t)) {
162
+ let t = i.o ?? i.n, r = i.o === void 0 ? "n" : "o", a = t === void 0 ? void 0 : e.closed[r]?.get(t);
163
+ a === "last" ? n.push({ kind: "last" }) : typeof a == "number" && n.push({
164
+ kind: "ordinal",
165
+ position: a
166
+ });
167
+ }
168
+ let [r] = n;
169
+ return r && n.every((e) => JSON.stringify(e) === JSON.stringify(r)) ? r : null;
170
+ }
171
+ var D = (e, t) => e.some((e) => o(e, t).length > 0);
172
+ function O(e, t) {
173
+ let n = e.filter((e) => o(e.frame, t).length > 0);
174
+ return n.length === 0 ? null : { weak: n.every((e) => e.weak) };
175
+ }
176
+ var k = 60, A = 4;
177
+ function j(e, t, n) {
178
+ if (n.zh) return t;
179
+ let i = r(e, n.fold), a = i.flatMap((e, t) => e.folded.map((e) => ({
180
+ token: e,
181
+ owner: t
182
+ }))), o = t.split(" ");
183
+ for (let e = a.length - o.length; e >= 0; --e) {
184
+ if (!o.every((t, n) => a[e + n]?.token === t)) continue;
185
+ let t = a[e]?.owner, n = a[e + o.length - 1]?.owner;
186
+ if (t === void 0 || n === void 0 || a.filter((e) => e.owner >= t && e.owner <= n).length !== o.length) break;
187
+ return i.slice(t, n + 1).map((e) => e.said).join(" ");
188
+ }
189
+ return t;
190
+ }
191
+ function M(e, t) {
192
+ let n = t === void 0 ? void 0 : e.closed.d?.get(t);
193
+ return n === "asc" || n === "desc" ? n : null;
194
+ }
195
+ function N(e, t, r, i, a, s) {
196
+ let { registered: c } = i;
197
+ if (e.prep.compound.some((n) => e.zh ? t.includes(n) : ` ${t} `.includes(` ${n} `))) return null;
198
+ let l = [], u = (e, t) => l.push({
199
+ request: e,
200
+ weak: t
201
+ }), { phrases: d } = e.controls, f = (e, n, r) => {
202
+ if (!n) return;
203
+ let i = O(d[e], t);
204
+ i && u(r, i.weak);
205
+ };
206
+ if (f("notifications", c["header.notifications"], { control: "header.notifications" }), f("help", c["header.help"], { control: "header.help" }), f("sidebarCollapse", c.sidebar, {
207
+ control: "sidebar",
208
+ collapsed: !0
209
+ }), f("sidebarExpand", c.sidebar, {
210
+ control: "sidebar",
211
+ collapsed: !1
212
+ }), f("history", c["assistant.history"], { control: "assistant.history" }), f("transcript", c["assistant.transcript"], { control: "assistant.transcript" }), f("previewOpen", c["assistant.preview"], { control: "assistant.preview" }), f("previewClose", c["assistant.preview"], { control: "assistant.preview.close" }), f("newConversation", c["assistant.conversation.new"], { control: "assistant.conversation.new" }), c.language && e.language.length > 0) {
213
+ let r = new Set(a.map((t) => b(n(t.label, e.fold), e.fold)));
214
+ for (let n of e.language) for (let i of o(n, t)) {
215
+ let t = i.lang, n = t === void 0 ? void 0 : s.get(t);
216
+ n && t !== void 0 && !r.has(b(t, e.fold)) && u({
217
+ control: "language",
218
+ code: n
219
+ }, !1);
220
+ }
221
+ }
222
+ let p = i.page;
223
+ if (p) {
224
+ if (p.tabs.length > 0) for (let n of e.controls.tab) for (let r of o(n, t)) {
225
+ let t = r.x ? S(r.x, p.tabs, e.fold) : null;
226
+ t && u({
227
+ control: "page.tab",
228
+ name: t.label
229
+ }, !1);
230
+ }
231
+ if (p.filters.length > 0) {
232
+ D(e.controls.filterClear, t) && u({
233
+ control: "page.filter.clear",
234
+ filter: null
235
+ }, !1);
236
+ for (let n of e.controls.filter) for (let r of o(n, t)) {
237
+ if (!r.x) continue;
238
+ let t = p.filters.filter((t) => S(r.x, t.options, e.fold) !== null), [n] = t;
239
+ if (!n) continue;
240
+ let i = S(r.x, n.options, e.fold);
241
+ i && u({
242
+ control: "page.filter",
243
+ filter: t.length === 1 ? n.label : null,
244
+ option: i.label
245
+ }, !1);
246
+ }
247
+ }
248
+ if (p.sorts.length > 0) {
249
+ for (let n of e.controls.sort) for (let r of o(n, t)) {
250
+ let t = r.x ? S(r.x, p.sorts, e.fold) : null;
251
+ t && u({
252
+ control: "page.sort",
253
+ field: t.label,
254
+ direction: M(e, r.d)
255
+ }, !1);
256
+ }
257
+ for (let n of e.controls.sortDirection) for (let r of o(n, t)) {
258
+ let t = M(e, r.d);
259
+ t && u({
260
+ control: "page.sort",
261
+ field: null,
262
+ direction: t
263
+ }, !1);
264
+ }
265
+ }
266
+ if (p.searchable) {
267
+ D(e.controls.searchClear, t) && u({ control: "page.search.clear" }, !1);
268
+ let n = null, i = D(e.controls.searchVerbOnly, t);
269
+ for (let r of i ? [] : e.controls.search) for (let i of o(r, t)) {
270
+ let t = i.q?.trim() ?? "", r = e.zh ? 0 : t.split(" ").length;
271
+ !t || t.length > k || r > A || (n === null || t.length < n.length) && (n = t);
272
+ }
273
+ n !== null && u({
274
+ control: "page.search",
275
+ query: j(r, n, e)
276
+ }, !1);
277
+ }
278
+ }
279
+ let m = l.filter((e) => !e.weak), h = m.length > 0 ? m : l, [g] = h;
280
+ return g && h.every((e) => JSON.stringify(e) === JSON.stringify(g)) ? g : null;
281
+ }
282
+ function P(e, t, n, r, i, a, o) {
283
+ let s = {};
284
+ if (i.enabled("theme")) {
285
+ let n = T(e, r, t.themeWords);
286
+ n && (s.theme = n);
287
+ }
288
+ if (i.enabled("back") && t.backRunnable && D(e.back, r) && (s.back = !0), i.enabled("pick") && t.navigation) {
289
+ let t = E(e, r);
290
+ t && (s.pick = t);
291
+ }
292
+ if (i.enabled("there") && t.navigation && D(e.there, r) && (s.there = !0), i.enabled("goto")) {
293
+ let t = w(e, r, o);
294
+ t && (s.goto = t);
295
+ }
296
+ if (t.controls && (i.enabled("controls") || i.enabled("language"))) {
297
+ let o = N(e, r, n, t.controls, t.destinations, a);
298
+ o && (o.request.control === "language" ? i.enabled("language") : i.enabled("controls")) && (s.control = o);
299
+ }
300
+ return s;
301
+ }
302
+ function F(n) {
303
+ let r = e(n.manifest), i = f({
304
+ ui: n.uiLocale,
305
+ input: n.inputLocale,
306
+ narrow: n.commandLocales,
307
+ manifest: r
308
+ }), a = i.length > 0 && t(r, "en", "goto"), o = t(r, "en", "language");
309
+ if (i.length === 0 && !o) return [];
310
+ let s = c(n.said), p = i.map((e) => d[e]), m = n.controls?.languages ?? [], h = [], g = (e) => u({
311
+ tables: p,
312
+ appLanguages: m,
313
+ fold: e
314
+ });
315
+ for (let e of p) {
316
+ let i = v(e), a = l(n.said, i.prep, s);
317
+ if (a === null) continue;
318
+ let o = P(i, n, n.said, a, { enabled: (n) => t(r, e.locale, n) }, g(e.locale), x(n.destinations, e.locale, e.nameForms));
319
+ Object.keys(o).length > 0 && h.push({
320
+ source: e.locale,
321
+ intents: o
322
+ });
323
+ }
324
+ if (!s && (a || o)) {
325
+ let e = i.length > 0 ? p : [null];
326
+ for (let t of e) {
327
+ let e = y(t), r = l(n.said, e.prep, !1);
328
+ if (r === null) continue;
329
+ let i = P(e, n, n.said, r, { enabled: (e) => e === "goto" ? a : e === "language" ? o : !1 }, g(e.fold), x(n.destinations, e.fold));
330
+ Object.keys(i).length > 0 && h.push({
331
+ source: "en",
332
+ intents: i
333
+ });
334
+ }
335
+ }
336
+ return h;
337
+ }
338
+ function I(n) {
339
+ let r = e(n.manifest), i = f({
340
+ ui: n.uiLocale,
341
+ input: n.inputLocale,
342
+ narrow: n.commandLocales,
343
+ manifest: r
344
+ }), a = c(n.said);
345
+ return i.some((e) => {
346
+ let i = d[e], o = v(i), s = l(n.said, o.prep, a);
347
+ return s === null ? !1 : t(r, e, "there") && D(o.there, s) || t(r, e, "pick") && E(o, s) !== null;
348
+ });
349
+ }
350
+ //#endregion
351
+ export { v as compileNative, F as matchLocaleIntents, I as mayBeThereOrPick };
@@ -0,0 +1,77 @@
1
+ import { ControlSnapshot } from '../appControls/snapshot';
2
+ import { UiLanguage } from '../appControls/types';
3
+ import { LocalDestination, LocalUiCommand } from '../localUiCommands';
4
+ import { UiOfferYesState } from '../uiActions/uiOffers';
5
+ import { CommandManifest } from './types';
6
+ export interface EvalControls {
7
+ registered?: readonly string[];
8
+ languages?: readonly UiLanguage[];
9
+ sidebarEntries?: ControlSnapshot["sidebarEntries"];
10
+ page?: Partial<NonNullable<ControlSnapshot["page"]>> | null;
11
+ }
12
+ export interface EvalNavigation {
13
+ links?: readonly LocalDestination[];
14
+ unresolved?: number;
15
+ list?: readonly string[];
16
+ offered?: readonly string[];
17
+ }
18
+ export interface EvalYes {
19
+ offer?: UiOfferYesState;
20
+ pending?: number;
21
+ attachments?: boolean;
22
+ leaveGuard?: boolean;
23
+ }
24
+ export interface EvalItem {
25
+ id: string;
26
+ text: string;
27
+ uiLocale: string;
28
+ inputLocale?: string;
29
+ origin?: "typed" | "spoken";
30
+ family?: string;
31
+ sidebar?: readonly LocalDestination[];
32
+ controls?: EvalControls;
33
+ backRunnable?: boolean;
34
+ navigation?: EvalNavigation | null;
35
+ yes?: EvalYes;
36
+ themeWords?: "any" | "mode-only";
37
+ expected?: string | Record<string, unknown>;
38
+ }
39
+ export type EvalActual = {
40
+ result: "model";
41
+ plannedAs?: string;
42
+ } | ({
43
+ result: "command";
44
+ kind: string;
45
+ } & Record<string, unknown>);
46
+ export type EvalVerdict = "pass" | "false-match" | "wrong" | "miss" | "unscored";
47
+ export interface EvalResult {
48
+ id: string;
49
+ locale: string;
50
+ family: string;
51
+ actual: EvalActual;
52
+ expected?: string | Record<string, unknown>;
53
+ verdict: EvalVerdict;
54
+ }
55
+ /** A command as a flat, comparable record. */
56
+ export declare function describeCommand(command: LocalUiCommand | null): EvalActual;
57
+ /** What the shipping composition does with one item. */
58
+ export declare function actualOf(item: EvalItem, manifest: CommandManifest): EvalActual;
59
+ export declare function verdictOf(actual: EvalActual, expected: EvalItem["expected"]): EvalVerdict;
60
+ export declare function evaluateCommandItem(item: EvalItem, manifest?: CommandManifest): EvalResult;
61
+ export interface EvalCell {
62
+ locale: string;
63
+ family: string;
64
+ items: number;
65
+ positives: number;
66
+ negatives: number;
67
+ truePositives: number;
68
+ misses: number;
69
+ wrong: number;
70
+ falseMatches: number;
71
+ precision: number | null;
72
+ recall: number | null;
73
+ }
74
+ /** The scoreboard: per locale and family. `falseMatches` counts a wrong target too (G1). */
75
+ export declare function scoreboard(results: readonly EvalResult[]): EvalCell[];
76
+ /** The family names an item may be labelled with. */
77
+ export declare const EVAL_FAMILIES: readonly string[];