@burdenoff/fe-libs 2026.1117.6 → 2026.1117.8

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.
@@ -0,0 +1,4 @@
1
+ export declare function configureFirstClipPrefetch(options: {
2
+ enabled: boolean;
3
+ } | null): void;
4
+ export declare function firstClipPrefetchEnabled(): boolean;
@@ -0,0 +1,9 @@
1
+ // src/shared/assistant/voice/firstClipPrefetchConfig.ts
2
+ var e = !1;
3
+ function t(t) {
4
+ e = t?.enabled === !0;
5
+ }
6
+ function n() {
7
+ return e;
8
+ }
9
+ export { t as configureFirstClipPrefetch, n as firstClipPrefetchEnabled };
@@ -157,4 +157,22 @@ export declare function containsCjk(text: string): boolean;
157
157
  export declare function chunkForSpeech(text: string, maxChars?: number, cjkMaxChars?: number, options?: {
158
158
  firstChunkMaxChars?: number;
159
159
  packFirstChunk?: boolean;
160
+ /** P1: lead with a first sentence this long even when the reply fits one chunk. */
161
+ leadSentenceMinChars?: number;
160
162
  }): string[];
163
+ /**
164
+ * ★ P1 (BOFF-12936): the first sentence long enough to lead a reply on its own
165
+ * when its clip is fetched early (see `chunkForSpeech`). About 2.5 s of speech:
166
+ * the clip after it (~1.1 s to synthesise) is ready before it ends.
167
+ */
168
+ export declare const FIRST_CLIP_LEAD_MIN_CHARS = 40;
169
+ /**
170
+ * ★ P1 (BOFF-12936): the first chunk of an answer still being written, once it
171
+ * can no longer change: the answer's first sentence is complete (more text
172
+ * follows it), and the first chunk lies within that sentence. Null until then.
173
+ * `options` must be the ones the finished answer will be chunked with.
174
+ */
175
+ export declare function settledFirstChunk(partial: string, options: {
176
+ firstChunkMaxChars?: number;
177
+ leadSentenceMinChars?: number;
178
+ }): string | null;
@@ -31,15 +31,15 @@ function l(e, t) {
31
31
  }
32
32
  return n ? v(t.linkTo, { site: n }) : t.link;
33
33
  }
34
- var u = /^\s{0,3}(?:`{3,}|~{3,})/, d = /^\s{0,3}#{1,6}\s+(.*)$/, ee = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/, f = /^\s{0,3}(?:>\s?)+/, p = /^(\s*)(?:[-*+]|(\d{1,9})[.)])\s+/, m = /^\[[ xX]\]\s*/, h = /[.!?…⋯:;。!?;.।॥۔؟؛]$/, g = /^\s{0,3}=+\s*$/, _ = /^(?: {4}|\t)/;
34
+ var u = /^\s{0,3}(?:`{3,}|~{3,})/, ee = /^\s{0,3}#{1,6}\s+(.*)$/, d = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/, f = /^\s{0,3}(?:>\s?)+/, p = /^(\s*)(?:[-*+]|(\d{1,9})[.)])\s+/, m = /^\[[ xX]\]\s*/, h = /[.!?…⋯:;。!?;.।॥۔؟؛]$/, g = /^\s{0,3}=+\s*$/, _ = /^(?: {4}|\t)/;
35
35
  function v(e, t) {
36
36
  return Object.entries(t).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), e);
37
37
  }
38
- function y(e) {
38
+ function te(e) {
39
39
  let t = e.trim();
40
40
  return t.includes("|") && t.includes("-") && /^[\s:|-]+$/.test(t);
41
41
  }
42
- function b(e) {
42
+ function y(e) {
43
43
  let t = e.trim().replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
44
44
  for (let e = 0; e < t.length; e += 1) {
45
45
  let i = t[e];
@@ -47,7 +47,7 @@ function b(e) {
47
47
  }
48
48
  return n.push(r), n.map((e) => e.trim());
49
49
  }
50
- var x = {
50
+ var b = {
51
51
  "&amp;": " and ",
52
52
  "&lt;": " less than ",
53
53
  "&gt;": " greater than ",
@@ -55,86 +55,86 @@ var x = {
55
55
  "&#39;": "'",
56
56
  "&apos;": "'",
57
57
  "&nbsp;": " "
58
- }, S = "[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)+", C = RegExp(`<(?:mailto:)?(${S})>`, "g"), w = RegExp(`\\bmailto:(${S})`, "g"), T = new RegExp(S, "g");
59
- function E(e, t = "at", n = "dot") {
58
+ }, x = "[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)+", S = RegExp(`<(?:mailto:)?(${x})>`, "g"), C = RegExp(`\\bmailto:(${x})`, "g"), w = new RegExp(x, "g");
59
+ function T(e, t = "at", n = "dot") {
60
60
  return e.replace(/@/g, ` ${t} `).replace(/\./g, ` ${n} `).replace(/\s+/g, " ").trim();
61
61
  }
62
- var D = 57600, O = /[\ue121-\ue17e]/g, k = "", A = /\ue180/g, j = /[\ue100-\ue1ff]/g;
63
- function M(e, t) {
64
- let n = e.replace(j, "").replace(/\\[!-/:-@[-`{-~]|(`+)[^`]*?\1(?!`)/g, (e, t) => t ? e.replace(/\\/g, k) : e).replace(/\\([!-/:-@[-`{-~])/g, (e, t) => String.fromCharCode(D + t.charCodeAt(0)));
62
+ var E = 57600, D = /[\ue121-\ue17e]/g, O = "", k = /\ue180/g, A = /[\ue100-\ue1ff]/g;
63
+ function j(e, t) {
64
+ let n = e.replace(A, "").replace(/\\[!-/:-@[-`{-~]|(`+)[^`]*?\1(?!`)/g, (e, t) => t ? e.replace(/\\/g, O) : e).replace(/\\([!-/:-@[-`{-~])/g, (e, t) => String.fromCharCode(E + t.charCodeAt(0)));
65
65
  n = n.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.image} `), n = n.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/\[([^\]]*)\]\[[^\]]*\]/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/<(https?:\/\/[^>\s]+)>/g, (e, n) => ` ${l(n, t)} `), n = n.replace(/\bhttps?:\/\/\S+/g, (e) => {
66
66
  let n = e.replace(/[.,;:!?)\]]+$/, ""), r = e.slice(n.length).replace(/[)\]]/g, "");
67
67
  return ` ${l(n, t)}${r} `;
68
- }), n = n.replace(C, (e, n) => ` ${E(n, t.emailAt, t.emailDot)} `), n = n.replace(w, (e, n) => ` ${E(n, t.emailAt, t.emailDot)} `), n = n.replace(T, (e) => ` ${E(e, t.emailAt, t.emailDot)} `), n = n.replace(/`+([^`]*)`+/g, (e, t) => t), n = n.replace(/<\/?[a-zA-Z][^>]*>/g, " ");
69
- for (let [e, t] of Object.entries(x)) n = n.split(e).join(t);
70
- return n = n.replace(/(\*\*\*|___)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/(\*\*|__)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/~~(\S(?:[\s\S]*?\S)?)~~/g, "$1"), n = n.replace(/(^|[\s([{"'])\*(\S(?:[\s\S]*?\S)?)\*(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/(^|[\s([{"'])_(\S(?:[\s\S]*?\S)?)_(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/[\p{Extended_Pictographic}\uFE0F\u200D]/gu, " "), n = n.replace(/[•·▪▫◦‣⁃∙●○■□▶▸►➤➜→←↑↓⇒⇔★☆⭐✦✧✓✔✗✘✕✖]/gu, " "), n = n.replace(/(\d)?\s*[—–―]\s*(\d)?/g, (e, t, n) => t !== void 0 && n !== void 0 ? e : `${t ?? ""}, ${n ?? ""}`), n = n.replace(/\*{2,}/g, ""), n.replace(/\s+/g, " ").replace(/\s+([.,!?;:)\]}])/g, "$1").replace(/([([{])\s+/g, "$1").trim().replace(O, (e) => String.fromCharCode(e.charCodeAt(0) - D)).replace(A, "\\");
68
+ }), n = n.replace(S, (e, n) => ` ${T(n, t.emailAt, t.emailDot)} `), n = n.replace(C, (e, n) => ` ${T(n, t.emailAt, t.emailDot)} `), n = n.replace(w, (e) => ` ${T(e, t.emailAt, t.emailDot)} `), n = n.replace(/`+([^`]*)`+/g, (e, t) => t), n = n.replace(/<\/?[a-zA-Z][^>]*>/g, " ");
69
+ for (let [e, t] of Object.entries(b)) n = n.split(e).join(t);
70
+ return n = n.replace(/(\*\*\*|___)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/(\*\*|__)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/~~(\S(?:[\s\S]*?\S)?)~~/g, "$1"), n = n.replace(/(^|[\s([{"'])\*(\S(?:[\s\S]*?\S)?)\*(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/(^|[\s([{"'])_(\S(?:[\s\S]*?\S)?)_(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/[\p{Extended_Pictographic}\uFE0F\u200D]/gu, " "), n = n.replace(/[•·▪▫◦‣⁃∙●○■□▶▸►➤➜→←↑↓⇒⇔★☆⭐✦✧✓✔✗✘✕✖]/gu, " "), n = n.replace(/(\d)?\s*[—–―]\s*(\d)?/g, (e, t, n) => t !== void 0 && n !== void 0 ? e : `${t ?? ""}, ${n ?? ""}`), n = n.replace(/\*{2,}/g, ""), n.replace(/\s+/g, " ").replace(/\s+([.,!?;:)\]}])/g, "$1").replace(/([([{])\s+/g, "$1").trim().replace(D, (e) => String.fromCharCode(e.charCodeAt(0) - E)).replace(k, "\\");
71
71
  }
72
- function N(e) {
72
+ function M(e) {
73
73
  let t = e.trim();
74
74
  return t ? h.test(t) ? t : `${t}.` : "";
75
75
  }
76
- function P(e, t, n) {
76
+ function N(e, t, n) {
77
77
  if (e.length <= t) return e;
78
78
  let r = e.slice(0, t), i = Math.max(r.lastIndexOf(". "), r.lastIndexOf("\n")), a = r.lastIndexOf(" "), o = i > t * .5 ? i + 1 : a > 0 ? a : t;
79
79
  return `${r.slice(0, o).trim()}\n${n}`;
80
80
  }
81
- function F(e) {
81
+ function P(e) {
82
82
  let t = 0;
83
83
  for (let n of e) t += n === " " ? 4 : 1;
84
84
  return t;
85
85
  }
86
- function I(e, t) {
86
+ function F(e, t) {
87
87
  let n = e[e.length - 1];
88
88
  if (!n?.ordinal) return "";
89
89
  if (e.length === 1) return `${n.ordinal}. `;
90
90
  let r = e.map((e) => e.ordinal);
91
91
  return r.every((e) => !!e) ? `${r.join(".")}. ` : `${v(t.nestedItem, { ordinal: n.ordinal })}. `;
92
92
  }
93
- function L(t, n = {}) {
93
+ function I(t, n = {}) {
94
94
  let r = {
95
95
  ...e,
96
96
  ...n.labels
97
97
  }, i = n.maxChars ?? 8e3, a = n.maxSpokenTableRows ?? 3, o = n.locale ?? "en", s = 0;
98
98
  if (!t) return "";
99
- let l = t.replace(/\r\n?/g, "\n").split("\n"), h = [], x = [], S = 0;
100
- for (; S < l.length;) {
101
- let e = l[S].replace(f, ""), t = S === 0 || !l[S - 1].replace(f, "").trim();
99
+ let l = t.replace(/\r\n?/g, "\n").split("\n"), h = [], b = [], x = 0;
100
+ for (; x < l.length;) {
101
+ let e = l[x].replace(f, ""), t = x === 0 || !l[x - 1].replace(f, "").trim();
102
102
  if (u.test(e)) {
103
- for (S += 1; S < l.length && !u.test(l[S].replace(f, ""));) S += 1;
104
- S += 1, h.push(N(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
103
+ for (x += 1; x < l.length && !u.test(l[x].replace(f, ""));) x += 1;
104
+ x += 1, h.push(M(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
105
105
  continue;
106
106
  }
107
- if (t && x.length === 0 && e.trim() && _.test(e)) {
108
- for (S += 1; S < l.length;) {
109
- let e = l[S].replace(f, "");
107
+ if (t && b.length === 0 && e.trim() && _.test(e)) {
108
+ for (x += 1; x < l.length;) {
109
+ let e = l[x].replace(f, "");
110
110
  if (e.trim() && _.test(e)) {
111
- S += 1;
111
+ x += 1;
112
112
  continue;
113
113
  }
114
114
  if (e.trim()) break;
115
- let t = S;
115
+ let t = x;
116
116
  for (; t < l.length && !l[t].replace(f, "").trim();) t += 1;
117
117
  let n = t < l.length ? l[t].replace(f, "") : "";
118
118
  if (!n.trim() || !_.test(n)) break;
119
- S = t;
119
+ x = t;
120
120
  }
121
- h.push(N(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
121
+ h.push(M(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
122
122
  continue;
123
123
  }
124
- if (ee.test(e) || g.test(e)) {
125
- S += 1;
124
+ if (d.test(e) || g.test(e)) {
125
+ x += 1;
126
126
  continue;
127
127
  }
128
- let n = S + 1 < l.length ? l[S + 1].replace(f, "") : "";
129
- if (e.includes("|") && y(n)) {
130
- x.length = 0;
131
- let t = b(e).map((e) => M(e, r));
132
- S += 2;
128
+ let n = x + 1 < l.length ? l[x + 1].replace(f, "") : "";
129
+ if (e.includes("|") && te(n)) {
130
+ b.length = 0;
131
+ let t = y(e).map((e) => j(e, r));
132
+ x += 2;
133
133
  let n = [];
134
- for (; S < l.length;) {
135
- let e = l[S].replace(f, "");
134
+ for (; x < l.length;) {
135
+ let e = l[x].replace(f, "");
136
136
  if (!e.includes("|") || !e.trim()) break;
137
- n.push(b(e).map((e) => M(e, r))), S += 1;
137
+ n.push(y(e).map((e) => j(e, r))), x += 1;
138
138
  }
139
139
  if (n.length > a) {
140
140
  let e = c(t.slice(0, 5), o), i = v(r.largeTable, {
@@ -142,51 +142,51 @@ function L(t, n = {}) {
142
142
  columns: t.length,
143
143
  headers: e
144
144
  });
145
- h.push(N(e ? i : i.replace(/[\s::،,]+$/u, "")));
145
+ h.push(M(e ? i : i.replace(/[\s::،,]+$/u, "")));
146
146
  } else for (let e of n) {
147
147
  let n = e.map((e, n) => {
148
148
  if (!e) return "";
149
149
  let r = t[n];
150
150
  return r ? `${r}: ${e}` : e;
151
151
  }).filter(Boolean);
152
- n.length && h.push(N(n.join(", ")));
152
+ n.length && h.push(M(n.join(", ")));
153
153
  }
154
154
  continue;
155
155
  }
156
- if (S += 1, !e.trim()) continue;
157
- let i = d.exec(e);
156
+ if (x += 1, !e.trim()) continue;
157
+ let i = ee.exec(e);
158
158
  if (i) {
159
- x.length = 0;
160
- let e = M(i[1].replace(/\s+#+\s*$/, ""), r);
161
- e && h.push(N(e));
159
+ b.length = 0;
160
+ let e = j(i[1].replace(/\s+#+\s*$/, ""), r);
161
+ e && h.push(M(e));
162
162
  continue;
163
163
  }
164
- let C = p.exec(e), w = e, T = "";
165
- if (C) {
166
- w = e.slice(C[0].length).replace(m, "");
167
- let t = F(C[1]);
168
- for (; x.length > 0 && x[x.length - 1].indent >= t;) x.pop();
169
- x.push({
164
+ let S = p.exec(e), C = e, w = "";
165
+ if (S) {
166
+ C = e.slice(S[0].length).replace(m, "");
167
+ let t = P(S[1]);
168
+ for (; b.length > 0 && b[b.length - 1].indent >= t;) b.pop();
169
+ b.push({
170
170
  indent: t,
171
- ordinal: C[2] ?? null
172
- }), T = I(x, r);
173
- } else /^\s/.test(e) || (x.length = 0);
174
- if (!C && g.test(n)) {
175
- x.length = 0, S += 1;
176
- let t = M(e, r);
177
- t && h.push(N(t));
171
+ ordinal: S[2] ?? null
172
+ }), w = F(b, r);
173
+ } else /^\s/.test(e) || (b.length = 0);
174
+ if (!S && g.test(n)) {
175
+ b.length = 0, x += 1;
176
+ let t = j(e, r);
177
+ t && h.push(M(t));
178
178
  continue;
179
179
  }
180
- let E = M(w, r);
181
- E && h.push(N(`${T}${E}`));
180
+ let T = j(C, r);
181
+ T && h.push(M(`${w}${T}`));
182
182
  }
183
- return P(h.join("\n").replace(/\n{2,}/g, "\n").trim(), i, N(r.truncated));
183
+ return N(h.join("\n").replace(/\n{2,}/g, "\n").trim(), i, M(r.truncated));
184
184
  }
185
- var R = /* @__PURE__ */ new Set([
185
+ var L = /* @__PURE__ */ new Set([
186
186
  ".",
187
187
  "!",
188
188
  "?"
189
- ]), z = /* @__PURE__ */ new Set([
189
+ ]), R = /* @__PURE__ */ new Set([
190
190
  "。",
191
191
  "!",
192
192
  "?",
@@ -200,7 +200,7 @@ var R = /* @__PURE__ */ new Set([
200
200
  "۔",
201
201
  "؟",
202
202
  "؛"
203
- ]), B = /* @__PURE__ */ new Set([
203
+ ]), z = /* @__PURE__ */ new Set([
204
204
  "\"",
205
205
  "'",
206
206
  ")",
@@ -215,25 +215,25 @@ var R = /* @__PURE__ */ new Set([
215
215
  "』",
216
216
  "】",
217
217
  ")"
218
- ]), V = /* @__PURE__ */ new Set(/* @__PURE__ */ "i.e,e.g,etc,approx,vs,cf,viz,al,est,dept,fig,figs,ref,min,max,avg,qty,temp,mr,mrs,ms,dr,prof,sr,jr,st,inc,ltd,co,corp,univ,ca,kg,mg,gm,ha,cm,mm,km,ml,lb,oz,sq,hrs,wk,yr,mo,vol,pp".split(",")), H = /* @__PURE__ */ new Set([
218
+ ]), B = /* @__PURE__ */ new Set(/* @__PURE__ */ "i.e,e.g,etc,approx,vs,cf,viz,al,est,dept,fig,figs,ref,min,max,avg,qty,temp,mr,mrs,ms,dr,prof,sr,jr,st,inc,ltd,co,corp,univ,ca,kg,mg,gm,ha,cm,mm,km,ml,lb,oz,sq,hrs,wk,yr,mo,vol,pp".split(",")), V = /* @__PURE__ */ new Set([
219
219
  "no",
220
220
  "nos",
221
221
  "p",
222
222
  "ch",
223
223
  "sec",
224
224
  "art"
225
- ]), U = /^\d+(?:\.\d+)*$/, W = /^[A-Za-z]$/;
226
- function G(e, t, n) {
227
- for (let r = t; r < n; r += 1) if (z.has(e[r])) return !0;
225
+ ]), H = /^\d+(?:\.\d+)*$/, U = /^[A-Za-z]$/;
226
+ function W(e, t, n) {
227
+ for (let r = t; r < n; r += 1) if (R.has(e[r])) return !0;
228
228
  if (n < e.length && !/\s/.test(e[n])) return !1;
229
229
  if (e[t] !== ".") return !0;
230
230
  let r = e.slice(0, t), i = /(\S+)$/.exec(r)?.[1] ?? "";
231
231
  if (!i) return !0;
232
- if (U.test(i) && !r.slice(0, r.length - i.length).trim()) return !1;
232
+ if (H.test(i) && !r.slice(0, r.length - i.length).trim()) return !1;
233
233
  let a = i.toLowerCase();
234
- return W.test(i) || V.has(a) ? !1 : !H.has(a) || !/^\s*\d/.test(e.slice(n));
234
+ return U.test(i) || B.has(a) ? !1 : !V.has(a) || !/^\s*\d/.test(e.slice(n));
235
235
  }
236
- function K(e) {
236
+ function G(e) {
237
237
  let t = [];
238
238
  for (let n of e.split("\n")) {
239
239
  let e = n.trim();
@@ -241,14 +241,14 @@ function K(e) {
241
241
  let r = 0, i = 0;
242
242
  for (; i < e.length;) {
243
243
  let n = e[i];
244
- if (!R.has(n) && !z.has(n)) {
244
+ if (!L.has(n) && !R.has(n)) {
245
245
  i += 1;
246
246
  continue;
247
247
  }
248
248
  let a = i;
249
- for (; a < e.length && (R.has(e[a]) || z.has(e[a]));) a += 1;
250
- for (; a < e.length && B.has(e[a]);) a += 1;
251
- if (G(e, i, a)) {
249
+ for (; a < e.length && (L.has(e[a]) || R.has(e[a]));) a += 1;
250
+ for (; a < e.length && z.has(e[a]);) a += 1;
251
+ if (W(e, i, a)) {
252
252
  let n = e.slice(r, a).trim();
253
253
  n && t.push(n), r = a;
254
254
  }
@@ -259,38 +259,38 @@ function K(e) {
259
259
  }
260
260
  return t;
261
261
  }
262
- var q = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/, J = /[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff01-\uff9f]/, Y = /[、,,;;::。!?!?]/, X = /[A-Za-z0-9][A-Za-z0-9._,:%/+-]*[A-Za-z0-9%]|[\s\S]/gu;
263
- function Z(e) {
264
- return q.test(e);
262
+ var K = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/, q = /[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff01-\uff9f]/, J = /[、,,;;::。!?!?]/, Y = /[A-Za-z0-9][A-Za-z0-9._,:%/+-]*[A-Za-z0-9%]|[\s\S]/gu;
263
+ function X(e) {
264
+ return K.test(e);
265
265
  }
266
- function Q(e, t) {
266
+ function Z(e, t) {
267
267
  let n = `${e.slice(-1)}${t.slice(0, 1)}`;
268
- return J.test(n) ? `${e}${t}` : `${e} ${t}`;
268
+ return q.test(n) ? `${e}${t}` : `${e} ${t}`;
269
269
  }
270
- function $(e, t) {
270
+ function Q(e, t) {
271
271
  let n = t.trim();
272
272
  n && e.push(n);
273
273
  }
274
- function te(e, t) {
274
+ function ne(e, t) {
275
275
  let n = [], r = "", i = -1;
276
- for (let a of e.match(X) ?? []) {
276
+ for (let a of e.match(Y) ?? []) {
277
277
  if (r.length + a.length > t && r.trim()) {
278
278
  if (i > 0 && i < r.length && i >= t * .4) {
279
- $(n, r.slice(0, i));
279
+ Q(n, r.slice(0, i));
280
280
  let e = r.slice(i);
281
- e.trim().length + a.length > t ? ($(n, e), r = "") : r = e;
282
- } else $(n, r), r = "";
281
+ e.trim().length + a.length > t ? (Q(n, e), r = "") : r = e;
282
+ } else Q(n, r), r = "";
283
283
  i = -1;
284
284
  }
285
285
  if (a.length > t) {
286
- $(n, r), r = "", i = -1;
286
+ Q(n, r), r = "", i = -1;
287
287
  for (let e = 0; e < a.length; e += t) n.push(a.slice(e, e + t));
288
- } else r += a, Y.test(a) && (i = r.length);
288
+ } else r += a, J.test(a) && (i = r.length);
289
289
  }
290
- return $(n, r), n;
290
+ return Q(n, r), n;
291
291
  }
292
- function ne(e, t) {
293
- if (Z(e)) return te(e, t);
292
+ function re(e, t) {
293
+ if (X(e)) return ne(e, t);
294
294
  let n = [], r = "";
295
295
  for (let i of e.split(/\s+/)) if (i.length > t) {
296
296
  r &&= (n.push(r), "");
@@ -298,36 +298,42 @@ function ne(e, t) {
298
298
  } else r ? r.length + 1 + i.length <= t ? r = `${r} ${i}` : (n.push(r), r = i) : r = i;
299
299
  return r && n.push(r), n;
300
300
  }
301
- function re(e, t = 180, n = 40, r = {}) {
301
+ function $(e, t = 180, n = 40, r = {}) {
302
302
  let i = Math.max(1, t), a = Math.max(1, Math.min(n, i)), o = [], s = "", c = i;
303
- for (let t of K(e)) {
304
- let e = Z(t) ? a : i;
303
+ for (let t of G(e)) {
304
+ let e = X(t) ? a : i;
305
305
  if (t.length > e) {
306
- s &&= (o.push(s), ""), o.push(...ne(t, e)), c = i;
306
+ s &&= (o.push(s), ""), o.push(...re(t, e)), c = i;
307
307
  continue;
308
308
  }
309
309
  if (!s) {
310
310
  s = t, c = e;
311
311
  continue;
312
312
  }
313
- let n = Q(s, t), r = Math.min(c, e);
313
+ let n = Z(s, t), r = Math.min(c, e);
314
314
  n.length <= r ? (s = n, c = r) : (o.push(s), s = t, c = e);
315
315
  }
316
- if (s && o.push(s), o.length > 1 && !r.packFirstChunk) {
317
- let e = K(o[0]);
318
- if (e.length > 1) {
319
- let [t, ...n] = e;
320
- o.splice(0, 1, t, n.reduce((e, t) => Q(e, t)));
321
- }
316
+ s && o.push(s);
317
+ let l = o.length > 0 ? G(o[0]) : [];
318
+ if ((o.length > 1 || r.leadSentenceMinChars !== void 0 && (l[0] ?? "").length >= r.leadSentenceMinChars) && !r.packFirstChunk && l.length > 1) {
319
+ let [e, ...t] = l;
320
+ o.splice(0, 1, e, t.reduce((e, t) => Z(e, t)));
322
321
  }
323
322
  if (r.firstChunkMaxChars !== void 0 && o.length > 0) {
324
- let [e, t] = ie(o[0], r.firstChunkMaxChars);
323
+ let [e, t] = oe(o[0], r.firstChunkMaxChars);
325
324
  t && o.splice(0, 1, e, t);
326
325
  }
327
326
  return o;
328
327
  }
329
- function ie(e, t) {
330
- if (e.length <= t || Z(e)) return [e, null];
328
+ var ie = 40;
329
+ function ae(e, t) {
330
+ let n = G(e), r = n[0];
331
+ if (n.length < 2 || r === void 0) return null;
332
+ let i = $(e, 180, 40, t)[0];
333
+ return i !== void 0 && i !== "" && r.startsWith(i) ? i : null;
334
+ }
335
+ function oe(e, t) {
336
+ if (e.length <= t || X(e)) return [e, null];
331
337
  for (let n = Math.min(t, e.length - 1); n >= o; --n) {
332
338
  let t = e[n - 1], r = e[n];
333
339
  if (!("—–".includes(t) || ",;:".includes(t) && /\s/.test(r))) continue;
@@ -336,4 +342,4 @@ function ie(e, t) {
336
342
  }
337
343
  return [e, null];
338
344
  }
339
- export { e as DEFAULT_SPEAKABLE_LABELS, n as MAX_SPEAKABLE_CHARS, s as MAX_SPOKEN_TABLE_HEADERS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS, re as chunkForSpeech, Z as containsCjk, c as joinSpokenList, E as speakableEmail, l as speakableLink, b as splitTableRow, L as toSpeakableText };
345
+ export { e as DEFAULT_SPEAKABLE_LABELS, ie as FIRST_CLIP_LEAD_MIN_CHARS, n as MAX_SPEAKABLE_CHARS, s as MAX_SPOKEN_TABLE_HEADERS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS, $ as chunkForSpeech, X as containsCjk, c as joinSpokenList, ae as settledFirstChunk, T as speakableEmail, l as speakableLink, y as splitTableRow, I as toSpeakableText };