@orvain/utils 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +64 -0
  2. package/README.md +48 -2
  3. package/dist/a11y.d.cts +102 -0
  4. package/dist/a11y.d.ts +103 -0
  5. package/dist/breakpoints.d.cts +36 -0
  6. package/dist/breakpoints.d.ts +37 -0
  7. package/dist/calendar.d.cts +127 -0
  8. package/dist/calendar.d.ts +128 -0
  9. package/dist/chart/color.d.cts +72 -0
  10. package/dist/chart/color.d.ts +73 -0
  11. package/dist/chart/index.d.cts +2 -0
  12. package/dist/chart/index.d.ts +3 -0
  13. package/dist/chart/math.d.cts +66 -0
  14. package/dist/chart/math.d.ts +67 -0
  15. package/dist/chart-items/index.d.cts +64 -0
  16. package/dist/chart-items/index.d.ts +65 -0
  17. package/dist/codeTokenizer.d.cts +29 -0
  18. package/dist/codeTokenizer.d.ts +30 -0
  19. package/dist/cssModule.d.cts +12 -0
  20. package/dist/cssModule.d.ts +13 -0
  21. package/dist/dismiss.d.cts +40 -0
  22. package/dist/dismiss.d.ts +41 -0
  23. package/dist/floating.d.cts +137 -0
  24. package/dist/floating.d.ts +138 -0
  25. package/dist/formField.d.cts +58 -0
  26. package/dist/formField.d.ts +59 -0
  27. package/dist/helpers.d.cts +17 -0
  28. package/dist/helpers.d.ts +18 -0
  29. package/dist/index.cjs +11 -0
  30. package/dist/index.d.cts +17 -0
  31. package/dist/index.d.ts +18 -0
  32. package/dist/index.js +2819 -0
  33. package/dist/kanbanDnd.d.cts +71 -0
  34. package/dist/kanbanDnd.d.ts +72 -0
  35. package/dist/listNavigation.d.cts +36 -0
  36. package/dist/listNavigation.d.ts +37 -0
  37. package/dist/richText/blockquote.d.cts +11 -0
  38. package/dist/richText/blockquote.d.ts +12 -0
  39. package/dist/richText/editor.d.cts +117 -0
  40. package/dist/richText/editor.d.ts +118 -0
  41. package/dist/richText/index.d.cts +3 -0
  42. package/dist/richText/index.d.ts +4 -0
  43. package/dist/richText/model.d.cts +161 -0
  44. package/dist/richText/model.d.ts +162 -0
  45. package/dist/slider.d.cts +18 -0
  46. package/dist/slider.d.ts +19 -0
  47. package/dist/tree.d.cts +78 -0
  48. package/dist/tree.d.ts +79 -0
  49. package/dist/types.d.cts +22 -0
  50. package/dist/types.d.ts +23 -0
  51. package/package.json +56 -3
package/dist/index.js ADDED
@@ -0,0 +1,2819 @@
1
+ let Re = 0;
2
+ function fo(t = "orvain") {
3
+ return `${t}-${++Re}`;
4
+ }
5
+ const Ft = [
6
+ "a[href]",
7
+ "button:not([disabled])",
8
+ "input:not([disabled])",
9
+ "select:not([disabled])",
10
+ "textarea:not([disabled])",
11
+ '[tabindex]:not([tabindex="-1"])',
12
+ '[contenteditable="true"]'
13
+ ].join(", ");
14
+ function qt(t) {
15
+ return Array.from(t.querySelectorAll(Ft)).filter(
16
+ (e) => !e.closest("[hidden]") && !e.closest('[aria-hidden="true"]')
17
+ );
18
+ }
19
+ const Pe = "data-dialog-close", Ne = [
20
+ 'input:not([type="hidden"])',
21
+ "select",
22
+ "textarea",
23
+ '[contenteditable="true"]',
24
+ '[role="textbox"]',
25
+ '[role="searchbox"]',
26
+ '[role="combobox"]',
27
+ '[role="spinbutton"]'
28
+ ].join(", ");
29
+ function ee(t) {
30
+ return !t || t.matches(Ft) ? t : t.querySelector(Ft) ?? t;
31
+ }
32
+ function ho(t, e) {
33
+ const n = typeof e == "string" ? t.querySelector(e) : e, o = qt(t).filter(
34
+ (r) => !r.closest(`[${Pe}], [inert]`) && r.getAttribute("aria-disabled") !== "true"
35
+ ), i = ee(n ?? null) ?? ee(t.querySelector("[data-autofocus]")) ?? o.find((r) => r.matches(Ne)) ?? o[0] ?? t;
36
+ return i === t && !t.hasAttribute("tabindex") && t.setAttribute("tabindex", "-1"), i.focus(), i;
37
+ }
38
+ function mo(t) {
39
+ const e = (n) => {
40
+ if (n.key !== "Tab") return;
41
+ const o = qt(t);
42
+ if (o.length === 0) return;
43
+ const i = o[0], r = o[o.length - 1];
44
+ n.shiftKey ? document.activeElement === i && (n.preventDefault(), r.focus()) : document.activeElement === r && (n.preventDefault(), i.focus());
45
+ };
46
+ return t.addEventListener("keydown", e), () => t.removeEventListener("keydown", e);
47
+ }
48
+ function po(t, e = "polite") {
49
+ const n = `orvain-live-${e}`;
50
+ let o = document.getElementById(n);
51
+ o || (o = document.createElement("div"), o.id = n, o.setAttribute("aria-live", e), o.setAttribute("aria-atomic", "true"), o.setAttribute("aria-relevant", "additions"), Object.assign(o.style, {
52
+ position: "absolute",
53
+ width: "1px",
54
+ height: "1px",
55
+ padding: "0",
56
+ overflow: "hidden",
57
+ clip: "rect(0 0 0 0)",
58
+ whiteSpace: "nowrap",
59
+ border: "0"
60
+ }), document.body.appendChild(o)), o.textContent = "", requestAnimationFrame(() => {
61
+ o.textContent = t;
62
+ });
63
+ }
64
+ const _e = '[role="menuitem"]:not([aria-disabled="true"]):not(:disabled), [role="menuitemcheckbox"]:not([aria-disabled="true"]):not(:disabled), [role="menuitemradio"]:not([aria-disabled="true"]):not(:disabled)';
65
+ function Kt(t) {
66
+ return Array.from(t.querySelectorAll(_e)).filter(
67
+ (e) => e.closest('[role="menu"]') === t
68
+ );
69
+ }
70
+ function Be(t, e) {
71
+ const n = Kt(t), o = (e && n.includes(e) ? e : void 0) ?? n.find((i) => i.getAttribute("tabindex") === "0") ?? n[0];
72
+ return n.forEach((i) => i.setAttribute("tabindex", i === o ? "0" : "-1")), o;
73
+ }
74
+ function je(t, e) {
75
+ const n = Kt(t);
76
+ if (!n.length) return;
77
+ const o = e === "first" ? 0 : e === "last" ? n.length - 1 : (e + n.length) % n.length, i = n[o];
78
+ return Be(t, i), i == null || i.focus(), i;
79
+ }
80
+ function go(t, e) {
81
+ const n = Kt(e);
82
+ if (!n.length) return !1;
83
+ const o = n.indexOf(document.activeElement);
84
+ let i = null;
85
+ switch (t.key) {
86
+ case "ArrowDown":
87
+ i = o + 1;
88
+ break;
89
+ case "ArrowUp":
90
+ i = o < 0 ? n.length - 1 : o - 1;
91
+ break;
92
+ case "Home":
93
+ i = 0;
94
+ break;
95
+ case "End":
96
+ i = n.length - 1;
97
+ break;
98
+ default:
99
+ if (t.key.length === 1 && /\S/.test(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
100
+ const r = t.key.toLowerCase(), l = [...n.slice(o + 1), ...n.slice(0, o + 1)].find(
101
+ (a) => (a.getAttribute("aria-label") ?? a.textContent ?? "").trim().toLowerCase().startsWith(r)
102
+ );
103
+ l && (i = n.indexOf(l));
104
+ }
105
+ }
106
+ return i === null ? !1 : (t.preventDefault(), je(e, i), !0);
107
+ }
108
+ const Et = (t, e, n) => (t.x - n.x) * (e.y - n.y) - (e.x - n.x) * (t.y - n.y), qe = (t, e, n, o) => {
109
+ const i = Et(t, e, n), r = Et(t, n, o), s = Et(t, o, e);
110
+ return !((i < 0 || r < 0 || s < 0) && (i > 0 || r > 0 || s > 0));
111
+ };
112
+ function yo({
113
+ getSubmenuRect: t,
114
+ onActivate: e,
115
+ delay: n = 120,
116
+ aimDelay: o = 300
117
+ }) {
118
+ const i = [];
119
+ let r, s;
120
+ const l = () => {
121
+ const u = t(), c = i[i.length - 1], d = i[0];
122
+ if (!u || !c || !d || d === c) return !1;
123
+ const g = u.left >= c.x ? u.left : u.right;
124
+ return qe(c, d, { x: g, y: u.top }, { x: g, y: u.bottom });
125
+ }, a = () => {
126
+ r !== void 0 && clearTimeout(r), r = void 0;
127
+ }, f = () => {
128
+ a();
129
+ const u = i[i.length - 1];
130
+ r = setTimeout(
131
+ () => {
132
+ if (r = void 0, i[i.length - 1] !== u && l()) {
133
+ f();
134
+ return;
135
+ }
136
+ s !== void 0 && e(s), s = void 0;
137
+ },
138
+ l() ? o : n
139
+ );
140
+ };
141
+ return {
142
+ move: (u) => {
143
+ i.push({ x: u.clientX, y: u.clientY }), i.length > 4 && i.shift();
144
+ },
145
+ enter: (u) => {
146
+ s = u, f();
147
+ },
148
+ enterSubmenu: () => {
149
+ s = void 0, a();
150
+ },
151
+ cancel: a
152
+ };
153
+ }
154
+ function bo(t) {
155
+ const e = () => {
156
+ t.scrollLeft + t.clientWidth >= t.scrollWidth - 1 ? t.dataset.scrollEnd = "" : delete t.dataset.scrollEnd;
157
+ }, n = (i) => {
158
+ if (t.scrollWidth <= t.clientWidth || Math.abs(i.deltaY) <= Math.abs(i.deltaX)) return;
159
+ const r = t.scrollWidth - t.clientWidth, s = Math.max(0, Math.min(r, t.scrollLeft + i.deltaY));
160
+ s !== t.scrollLeft && (i.preventDefault(), t.scrollLeft = s);
161
+ };
162
+ e(), t.addEventListener("scroll", e, { passive: !0 }), t.addEventListener("wheel", n, { passive: !1 });
163
+ const o = typeof ResizeObserver < "u" ? new ResizeObserver(e) : null;
164
+ return o == null || o.observe(t), () => {
165
+ t.removeEventListener("scroll", e), t.removeEventListener("wheel", n), o == null || o.disconnect();
166
+ };
167
+ }
168
+ function xo(t) {
169
+ const e = () => {
170
+ const r = Math.abs(t.scrollLeft), s = t.scrollWidth - t.clientWidth;
171
+ t.toggleAttribute("data-more-start", r > 1), t.toggleAttribute("data-more-end", s - r > 1);
172
+ }, n = () => {
173
+ const { borderTopWidth: r, borderBottomWidth: s } = getComputedStyle(t), l = t.offsetHeight - t.clientHeight - parseFloat(r) - parseFloat(s);
174
+ t.style.setProperty("--scrollbar-size", `${Math.max(0, l)}px`), e();
175
+ };
176
+ n(), t.addEventListener("scroll", e, { passive: !0 });
177
+ const o = typeof ResizeObserver < "u" ? new ResizeObserver(n) : null;
178
+ o == null || o.observe(t);
179
+ const i = typeof MutationObserver < "u" ? new MutationObserver(n) : null;
180
+ return i == null || i.observe(t, { childList: !0 }), () => {
181
+ t.removeEventListener("scroll", e), o == null || o.disconnect(), i == null || i.disconnect(), t.style.removeProperty("--scrollbar-size");
182
+ };
183
+ }
184
+ function wo(t, e) {
185
+ if (t.altKey || t.ctrlKey || t.metaKey || t.shiftKey) return !1;
186
+ const n = t.key;
187
+ if (n !== "ArrowUp" && n !== "ArrowDown" && n !== "ArrowLeft" && n !== "ArrowRight") return !1;
188
+ const o = document.activeElement;
189
+ if (!o) return !1;
190
+ const i = (f) => qt(f).filter((u) => u.getClientRects().length > 0), r = e.findIndex((f) => f.contains(o));
191
+ if (r < 0) return !1;
192
+ const s = i(e[r]), l = s.indexOf(o);
193
+ if (l < 0) return !1;
194
+ let a;
195
+ if (n === "ArrowDown") a = s[l + 1];
196
+ else if (n === "ArrowUp") a = s[l - 1];
197
+ else {
198
+ const f = n === "ArrowRight" ? 1 : -1, u = o.getBoundingClientRect().top;
199
+ for (let c = r + f; c >= 0 && c < e.length && !a; c += f)
200
+ a = i(e[c]).reduce((m, g) => m ? Math.abs(g.getBoundingClientRect().top - u) < Math.abs(m.getBoundingClientRect().top - u) ? g : m : g, void 0);
201
+ }
202
+ return a ? (t.preventDefault(), a.focus(), !0) : !1;
203
+ }
204
+ function ko(...t) {
205
+ return t.filter(Boolean).join(" ");
206
+ }
207
+ function vo(t) {
208
+ return Object.entries(t);
209
+ }
210
+ function So(t, e) {
211
+ const n = { ...t };
212
+ return e.forEach((o) => delete n[o]), n;
213
+ }
214
+ function Ao(t, e, n) {
215
+ return Math.min(Math.max(t, e), n);
216
+ }
217
+ const Ke = {
218
+ js: "js",
219
+ mjs: "js",
220
+ cjs: "js",
221
+ jsx: "jsx",
222
+ ts: "ts",
223
+ mts: "ts",
224
+ cts: "ts",
225
+ tsx: "tsx",
226
+ html: "html",
227
+ htm: "html",
228
+ vue: "html",
229
+ svg: "html",
230
+ xml: "html",
231
+ css: "css",
232
+ scss: "css",
233
+ less: "css"
234
+ };
235
+ function Eo(t) {
236
+ var n;
237
+ if (!t) return "plain";
238
+ const e = ((n = t.split(".").pop()) == null ? void 0 : n.toLowerCase()) ?? "";
239
+ return Ke[e] ?? "plain";
240
+ }
241
+ const ze = /* @__PURE__ */ new Set([
242
+ "abstract",
243
+ "as",
244
+ "async",
245
+ "await",
246
+ "break",
247
+ "case",
248
+ "catch",
249
+ "class",
250
+ "const",
251
+ "continue",
252
+ "debugger",
253
+ "declare",
254
+ "default",
255
+ "delete",
256
+ "do",
257
+ "else",
258
+ "enum",
259
+ "export",
260
+ "extends",
261
+ "false",
262
+ "finally",
263
+ "for",
264
+ "from",
265
+ "function",
266
+ "get",
267
+ "if",
268
+ "implements",
269
+ "import",
270
+ "in",
271
+ "instanceof",
272
+ "interface",
273
+ "is",
274
+ "keyof",
275
+ "let",
276
+ "namespace",
277
+ "new",
278
+ "null",
279
+ "of",
280
+ "private",
281
+ "protected",
282
+ "public",
283
+ "readonly",
284
+ "return",
285
+ "satisfies",
286
+ "set",
287
+ "static",
288
+ "super",
289
+ "switch",
290
+ "this",
291
+ "throw",
292
+ "true",
293
+ "try",
294
+ "type",
295
+ "typeof",
296
+ "undefined",
297
+ "var",
298
+ "void",
299
+ "while",
300
+ "with",
301
+ "yield"
302
+ ]), Ue = /* @__PURE__ */ new Set([
303
+ "any",
304
+ "bigint",
305
+ "boolean",
306
+ "never",
307
+ "number",
308
+ "object",
309
+ "string",
310
+ "symbol",
311
+ "unknown"
312
+ ]);
313
+ function He() {
314
+ const t = [];
315
+ return { tokens: t, push: (n, o) => {
316
+ if (!n) return;
317
+ const i = t[t.length - 1];
318
+ i && i.type === o ? i.content += n : t.push({ content: n, type: o });
319
+ } };
320
+ }
321
+ const We = /[A-Za-z_$]/, Ye = /[\w$]/, Ge = /^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?n?)/;
322
+ function St(t, e) {
323
+ const n = t[e];
324
+ let o = e + 1;
325
+ for (; o < t.length; ) {
326
+ const i = t[o];
327
+ if (i === "\\") {
328
+ o += 2;
329
+ continue;
330
+ }
331
+ if (i === n) return o + 1;
332
+ if (i === `
333
+ ` && n !== "`") return o;
334
+ o += 1;
335
+ }
336
+ return o;
337
+ }
338
+ function ht(t, e, n, o = 0, i = !1) {
339
+ let r = o, s = 0, l = null;
340
+ const a = () => !l || l.type === "punctuation" && !/[)\]}]$/.test(l.content) || l.type === "keyword" && /^(return|yield|await|case|default|else|do|in|of|typeof|void|new)$/.test(l.content);
341
+ for (; r < t.length; ) {
342
+ const f = t[r], u = t[r + 1];
343
+ if (i && f === "}" && s === 0) return r;
344
+ if (/\s/.test(f)) {
345
+ let m = r + 1;
346
+ for (; m < t.length && /\s/.test(t[m]); ) m += 1;
347
+ e(t.slice(r, m), "plain"), r = m;
348
+ continue;
349
+ }
350
+ if (f === "/" && u === "/") {
351
+ let m = t.indexOf(`
352
+ `, r);
353
+ m === -1 && (m = t.length), e(t.slice(r, m), "comment"), r = m;
354
+ continue;
355
+ }
356
+ if (f === "/" && u === "*") {
357
+ let m = t.indexOf("*/", r + 2);
358
+ m = m === -1 ? t.length : m + 2, e(t.slice(r, m), "comment"), r = m;
359
+ continue;
360
+ }
361
+ if (f === '"' || f === "'" || f === "`") {
362
+ const m = St(t, r);
363
+ e(t.slice(r, m), "string"), l = { type: "string", content: "" }, r = m;
364
+ continue;
365
+ }
366
+ if (/\d/.test(f) || f === "." && u && /\d/.test(u)) {
367
+ const m = Ge.exec(t.slice(r)), g = m ? m[0].length : 1;
368
+ e(t.slice(r, r + g), "number"), l = { type: "number", content: "" }, r += g;
369
+ continue;
370
+ }
371
+ if (We.test(f)) {
372
+ let m = r + 1;
373
+ for (; m < t.length && Ye.test(t[m]); ) m += 1;
374
+ const g = t.slice(r, m);
375
+ let v = m;
376
+ for (; v < t.length && (t[v] === " " || t[v] === " "); ) v += 1;
377
+ let x;
378
+ ze.has(g) ? x = "keyword" : Ue.has(g) ? x = "builtin" : t[v] === "(" ? x = "function" : /^[A-Z]/.test(g) ? x = "type" : x = "variable", e(g, x), l = { type: x, content: g }, r = m;
379
+ continue;
380
+ }
381
+ if (n && f === "<" && u && /[A-Za-z>]/.test(u) && a()) {
382
+ r = Ve(t, r, e), l = { type: "punctuation", content: ")" };
383
+ continue;
384
+ }
385
+ f === "{" && (s += 1), f === "}" && (s -= 1);
386
+ let c = r + 1;
387
+ if (!/[(){}[\];,]/.test(f))
388
+ for (; c < t.length && /[=+\-*/%<>!&|^~?:.]/.test(t[c]) && !(t[c] === "/" && /[/*]/.test(t[c + 1] ?? "")); ) c += 1;
389
+ const d = t.slice(r, c);
390
+ e(d, "punctuation"), l = { type: "punctuation", content: d }, r = c;
391
+ }
392
+ return r;
393
+ }
394
+ function Ve(t, e, n) {
395
+ let o = e, i = 0;
396
+ for (; o < t.length; ) {
397
+ const r = t[o + 1] === "/";
398
+ n(r ? "</" : "<", "punctuation"), o += r ? 2 : 1;
399
+ let s = o;
400
+ for (; s < t.length && /[\w$.:-]/.test(t[s]); ) s += 1;
401
+ n(t.slice(o, s), "tag"), o = s;
402
+ let l = !1;
403
+ for (; o < t.length; ) {
404
+ const a = t[o];
405
+ if (/\s/.test(a)) {
406
+ let f = o + 1;
407
+ for (; f < t.length && /\s/.test(t[f]); ) f += 1;
408
+ n(t.slice(o, f), "plain"), o = f;
409
+ } else if (a === "/" && t[o + 1] === ">") {
410
+ n("/>", "punctuation"), o += 2, l = !0;
411
+ break;
412
+ } else if (a === ">") {
413
+ n(">", "punctuation"), o += 1;
414
+ break;
415
+ } else if (a === '"' || a === "'") {
416
+ const f = St(t, o);
417
+ n(t.slice(o, f), "string"), o = f;
418
+ } else if (a === "{")
419
+ n("{", "punctuation"), o = ht(t, n, !0, o + 1, !0), t[o] === "}" && (n("}", "punctuation"), o += 1);
420
+ else if (/[\w$-]/.test(a)) {
421
+ let f = o + 1;
422
+ for (; f < t.length && /[\w$:-]/.test(t[f]); ) f += 1;
423
+ n(t.slice(o, f), "attr"), o = f;
424
+ } else
425
+ n(a, "punctuation"), o += 1;
426
+ }
427
+ if (r ? i -= 1 : l || (i += 1), i <= 0) return o;
428
+ for (; o < t.length && t[o] !== "<"; ) {
429
+ if (t[o] === "{") {
430
+ n("{", "punctuation"), o = ht(t, n, !0, o + 1, !0), t[o] === "}" && (n("}", "punctuation"), o += 1);
431
+ continue;
432
+ }
433
+ let a = o;
434
+ for (; a < t.length && t[a] !== "<" && t[a] !== "{"; ) a += 1;
435
+ const f = t.slice(o, a), u = /^\s*/.exec(f)[0], c = /\s*$/.exec(f.slice(u.length))[0];
436
+ n(u, "plain"), n(f.slice(u.length, f.length - c.length), "text"), n(c, "plain"), o = a;
437
+ }
438
+ }
439
+ return o;
440
+ }
441
+ function pe(t, e, n = 0, o = t.length) {
442
+ let i = n, r = 0, s = !1, l = 0;
443
+ for (; i < o; ) {
444
+ const a = t[i], f = t[i + 1];
445
+ if (/\s/.test(a)) {
446
+ let u = i + 1;
447
+ for (; u < o && /\s/.test(t[u]); ) u += 1;
448
+ e(t.slice(i, u), "plain"), i = u;
449
+ continue;
450
+ }
451
+ if (a === "/" && f === "*") {
452
+ let u = t.indexOf("*/", i + 2);
453
+ u = u === -1 || u > o ? o : u + 2, e(t.slice(i, u), "comment"), i = u;
454
+ continue;
455
+ }
456
+ if (a === '"' || a === "'") {
457
+ const u = Math.min(St(t, i), o);
458
+ e(t.slice(i, u), "string"), i = u;
459
+ continue;
460
+ }
461
+ if (a === "@") {
462
+ let u = i + 1;
463
+ for (; u < o && /[\w-]/.test(t[u]); ) u += 1;
464
+ e(t.slice(i, u), "keyword"), i = u;
465
+ continue;
466
+ }
467
+ if (a === "{") {
468
+ r += 1, s = !1, e(a, "punctuation"), i += 1;
469
+ continue;
470
+ }
471
+ if (a === "}") {
472
+ r = Math.max(0, r - 1), s = !1, e(a, "punctuation"), i += 1;
473
+ continue;
474
+ }
475
+ if (a === "(" && !s) {
476
+ l += 1, e(a, "punctuation"), i += 1;
477
+ continue;
478
+ }
479
+ if (a === ")" && l > 0) {
480
+ l -= 1, s = !1, e(a, "punctuation"), i += 1;
481
+ continue;
482
+ }
483
+ if (a === ";") {
484
+ s = !1, e(a, "punctuation"), i += 1;
485
+ continue;
486
+ }
487
+ if ((r || l) && !s && /[\w-]/.test(a)) {
488
+ let u = i + 1;
489
+ for (; u < o && /[\w-]/.test(t[u]); ) u += 1;
490
+ let c = u;
491
+ for (; c < o && (t[c] === " " || t[c] === " "); ) c += 1;
492
+ if (t[c] === ":") {
493
+ e(t.slice(i, u), "attr"), e(t.slice(u, c), "plain"), e(":", "punctuation"), s = !0, i = c + 1;
494
+ continue;
495
+ }
496
+ }
497
+ if (s) {
498
+ if (a === "#" && f && /[\da-fA-F]/.test(f)) {
499
+ let u = i + 1;
500
+ for (; u < o && /[\da-fA-F]/.test(t[u]); ) u += 1;
501
+ e(t.slice(i, u), "number"), i = u;
502
+ continue;
503
+ }
504
+ if (/\d/.test(a) || (a === "." || a === "-") && f && /\d/.test(f)) {
505
+ const u = /^-?(?:\d+\.?\d*|\.\d+)(?:[a-zA-Z%]+)?/.exec(t.slice(i, o)), c = u ? u[0].length : 1;
506
+ e(t.slice(i, i + c), "number"), i += c;
507
+ continue;
508
+ }
509
+ if (/[A-Za-z_-]/.test(a)) {
510
+ let u = i + 1;
511
+ for (; u < o && /[\w-]/.test(t[u]); ) u += 1;
512
+ const c = t.slice(i, u);
513
+ e(c, t[u] === "(" ? "function" : c.startsWith("--") ? "variable" : "builtin"), i = u;
514
+ continue;
515
+ }
516
+ e(a, "punctuation"), i += 1;
517
+ continue;
518
+ }
519
+ if (a === ":") {
520
+ let u = i + 1;
521
+ for (; u < o && /[\w:-]/.test(t[u]); ) u += 1;
522
+ e(t.slice(i, u), "keyword"), i = u;
523
+ continue;
524
+ }
525
+ if (/[\w.#*-]/.test(a)) {
526
+ let u = i + 1;
527
+ for (; u < o && /[\w-]/.test(t[u]); ) u += 1;
528
+ e(t.slice(i, u), a === "." || a === "#" ? "type" : "tag"), i = u;
529
+ continue;
530
+ }
531
+ e(a, "punctuation"), i += 1;
532
+ }
533
+ }
534
+ function Xe(t, e) {
535
+ let n = 0;
536
+ for (; n < t.length; ) {
537
+ if (t.startsWith("<!--", n)) {
538
+ let l = t.indexOf("-->", n + 4);
539
+ l = l === -1 ? t.length : l + 3, e(t.slice(n, l), "comment"), n = l;
540
+ continue;
541
+ }
542
+ if (t[n] === "<" && /[A-Za-z/!]/.test(t[n + 1] ?? "")) {
543
+ const l = t[n + 1] === "/", a = l ? "</" : t[n + 1] === "!" ? "<!" : "<";
544
+ e(a, "punctuation"), n += a.length;
545
+ let f = n;
546
+ for (; f < t.length && /[\w:-]/.test(t[f]); ) f += 1;
547
+ const u = t.slice(n, f).toLowerCase();
548
+ for (e(t.slice(n, f), a === "<!" ? "keyword" : "tag"), n = f; n < t.length && t[n] !== ">"; ) {
549
+ const c = t[n];
550
+ if (/\s/.test(c)) {
551
+ let d = n + 1;
552
+ for (; d < t.length && /\s/.test(t[d]); ) d += 1;
553
+ e(t.slice(n, d), "plain"), n = d;
554
+ } else if (c === '"' || c === "'") {
555
+ const d = St(t, n);
556
+ e(t.slice(n, d), "string"), n = d;
557
+ } else if (c === "/" || c === "=")
558
+ e(c, "punctuation"), n += 1;
559
+ else {
560
+ let d = n + 1;
561
+ for (; d < t.length && !/[\s=>/"']/.test(t[d]); ) d += 1;
562
+ e(t.slice(n, d), t[n - 1] === "=" ? "string" : "attr"), n = d;
563
+ }
564
+ }
565
+ if (t[n] === ">" && (e(">", "punctuation"), n += 1), !l && (u === "script" || u === "style")) {
566
+ let c = t.toLowerCase().indexOf(`</${u}`, n);
567
+ c === -1 && (c = t.length), u === "style" ? pe(t, e, n, c) : ht(t.slice(0, c), e, !1, n), n = c;
568
+ }
569
+ continue;
570
+ }
571
+ let o = n;
572
+ for (; o < t.length && t[o] !== "<"; ) o += 1;
573
+ o === n && (o += 1);
574
+ const i = t.slice(n, o), r = /^\s*/.exec(i)[0], s = /\s*$/.exec(i.slice(r.length))[0];
575
+ e(r, "plain"), e(i.slice(r.length, i.length - s.length), "text"), e(s, "plain"), n = o;
576
+ }
577
+ }
578
+ function Ze(t) {
579
+ const e = [[]];
580
+ for (const n of t)
581
+ n.content.split(/\r?\n/).forEach((i, r) => {
582
+ r > 0 && e.push([]), i && e[e.length - 1].push({ ...n, content: i });
583
+ });
584
+ return e;
585
+ }
586
+ function Mo(t, e = "plain") {
587
+ const { tokens: n, push: o } = He();
588
+ switch (e) {
589
+ case "js":
590
+ case "ts":
591
+ ht(t, o, !1);
592
+ break;
593
+ case "jsx":
594
+ case "tsx":
595
+ ht(t, o, !0);
596
+ break;
597
+ case "css":
598
+ pe(t, o);
599
+ break;
600
+ case "html":
601
+ Xe(t, o);
602
+ break;
603
+ default:
604
+ o(t, "plain");
605
+ }
606
+ return Ze(n);
607
+ }
608
+ const Qe = [
609
+ "neutral",
610
+ "grey",
611
+ "blue",
612
+ "purple",
613
+ "yellow",
614
+ "orange",
615
+ "green",
616
+ "red"
617
+ ], Do = [
618
+ "blue-light",
619
+ "blue-lighter",
620
+ "blue-dark",
621
+ "yellow-light",
622
+ "orange-light",
623
+ "green-dark",
624
+ "green-darker"
625
+ ];
626
+ function kt(t, e = "fill") {
627
+ return `var(--orvain-chart-${e}-${t})`;
628
+ }
629
+ function To(t) {
630
+ return `var(--orvain-chart-caption-${t}, ${kt(t, "dot")})`;
631
+ }
632
+ function Lo(t = "solid") {
633
+ return t === "ghost20" ? 0.2 : t === "ghost8" ? 0.08 : 1;
634
+ }
635
+ function $o(t) {
636
+ const e = Qe.filter((o) => o !== "neutral"), n = (t % e.length + e.length) % e.length;
637
+ return e[n];
638
+ }
639
+ function Co(t, e = "--chart-color") {
640
+ return {
641
+ [e]: kt(t, "fill"),
642
+ [`${e}-subtle`]: kt(t, "accent"),
643
+ [`${e}-soft`]: kt(t, "soft")
644
+ };
645
+ }
646
+ function ge(t, e, n) {
647
+ return Math.min(n, Math.max(e, t));
648
+ }
649
+ function Io(t) {
650
+ return t.reduce((e, n) => e + (Number.isFinite(n.value) ? n.value : 0), 0);
651
+ }
652
+ function Fo(t) {
653
+ return t.reduce((e, n) => Number.isFinite(n.value) && n.value > e ? n.value : e, 0);
654
+ }
655
+ function Oo(t, e) {
656
+ return !e || !Number.isFinite(t) ? 0 : ge(t / e * 100, 0, 100);
657
+ }
658
+ function Ro(t) {
659
+ if (!(t > 0)) return 1;
660
+ const e = 10 ** Math.floor(Math.log10(t));
661
+ for (const n of [1, 2, 2.5, 5, 10])
662
+ if (t <= n * e) return n * e;
663
+ return 10 * e;
664
+ }
665
+ function Po(t, e = 4) {
666
+ const n = Math.max(1, Math.round(e));
667
+ return Array.from({ length: n + 1 }, (o, i) => t * i / n);
668
+ }
669
+ function No(t, e) {
670
+ const [n, o] = t, [i, r] = e, s = o - n || 1;
671
+ return (l) => i + (l - n) / s * (r - i);
672
+ }
673
+ function _o(t) {
674
+ let e = 0;
675
+ return t.map((n) => {
676
+ const o = e;
677
+ return e += Number.isFinite(n) && n > 0 ? n : 0, { start: o, end: e };
678
+ });
679
+ }
680
+ function yt(t, e, n, o) {
681
+ const i = (o - 90) * Math.PI / 180;
682
+ return { x: t + n * Math.cos(i), y: e + n * Math.sin(i) };
683
+ }
684
+ function Bo(t, e, n, o, i, r) {
685
+ const s = ge(r - i, 0, 359.999), l = i + s, a = s > 180 ? 1 : 0, f = yt(t, e, n, i), u = yt(t, e, n, l);
686
+ if (o <= 0)
687
+ return `M ${t} ${e} L ${f.x} ${f.y} A ${n} ${n} 0 ${a} 1 ${u.x} ${u.y} Z`;
688
+ const c = yt(t, e, o, l), d = yt(t, e, o, i);
689
+ return [
690
+ `M ${f.x} ${f.y}`,
691
+ `A ${n} ${n} 0 ${a} 1 ${u.x} ${u.y}`,
692
+ `L ${c.x} ${c.y}`,
693
+ `A ${o} ${o} 0 ${a} 0 ${d.x} ${d.y}`,
694
+ "Z"
695
+ ].join(" ");
696
+ }
697
+ function jo(t, e = (n) => String(n)) {
698
+ return t.map((n) => `${n.label} ${e(n.value)}`).join(", ");
699
+ }
700
+ function qo(t, e, n) {
701
+ if (n <= 0) return null;
702
+ switch (t) {
703
+ case "ArrowRight":
704
+ case "ArrowDown":
705
+ return Math.min(n - 1, e + 1);
706
+ case "ArrowLeft":
707
+ case "ArrowUp":
708
+ return Math.max(0, e - 1);
709
+ case "Home":
710
+ return 0;
711
+ case "End":
712
+ return n - 1;
713
+ default:
714
+ return null;
715
+ }
716
+ }
717
+ function Ko(t, e, n, o, i = !1) {
718
+ if (o <= 0 || n <= 0) return null;
719
+ const r = Math.floor(e / n), s = e % n, l = Math.min(o - 1, r * n + n - 1);
720
+ switch (t) {
721
+ case "ArrowRight":
722
+ return Math.min(e + 1, l);
723
+ case "ArrowLeft":
724
+ return s > 0 ? e - 1 : e;
725
+ case "ArrowDown":
726
+ return e + n < o ? e + n : e;
727
+ case "ArrowUp":
728
+ return e >= n ? e - n : e;
729
+ case "Home":
730
+ return i ? 0 : r * n;
731
+ case "End":
732
+ return i ? o - 1 : l;
733
+ case "PageUp":
734
+ return s;
735
+ case "PageDown":
736
+ return s + Math.floor((o - 1 - s) / n) * n;
737
+ default:
738
+ return null;
739
+ }
740
+ }
741
+ function zo(t, e) {
742
+ return !Number.isFinite(t) || !Number.isFinite(e) || e <= 0 ? 0 : Math.min(Math.max(t / e, 0), 1);
743
+ }
744
+ function Je(t) {
745
+ return t.reduce((e, n) => Number.isFinite(n) && n > 0 ? e + n : e, 0);
746
+ }
747
+ function Uo(t, e) {
748
+ const n = t.map((s) => Number.isFinite(s) && s > 0 ? s : 0), o = Je(n), i = e !== void 0 && Number.isFinite(e) && e > o ? e : o;
749
+ return i <= 0 ? { shares: n.map(() => 0), rest: 1, total: 0 } : { shares: n.map((s) => s / i), rest: Math.max(0, 1 - o / i), total: i };
750
+ }
751
+ function tn(t) {
752
+ return t.map((e, n) => `${n === 0 ? "M" : "L"}${M(e.x)} ${M(e.y)}`).join(" ");
753
+ }
754
+ function Ho(t) {
755
+ if (t.length === 0) return "";
756
+ const [e, ...n] = t;
757
+ let o = `M${M(e.x)} ${M(e.y)}`, i = e;
758
+ for (const r of n) {
759
+ const s = (r.x - i.x) / 3;
760
+ o += ` C${M(i.x + s)} ${M(i.y)} ${M(r.x - s)} ${M(r.y)} ${M(r.x)} ${M(r.y)}`, i = r;
761
+ }
762
+ return o;
763
+ }
764
+ function Wo(t, e) {
765
+ if (t.length === 0) return "";
766
+ const n = e / 2, o = t[0].x, i = t[t.length - 1].x, r = [];
767
+ for (const s of t)
768
+ r.push({ x: Math.max(o, s.x - n), y: s.y }), r.push({ x: Math.min(i, s.x + n), y: s.y });
769
+ return tn(r);
770
+ }
771
+ function Yo(t, e, n) {
772
+ if (!t || e.length === 0) return "";
773
+ const o = e[0], i = e[e.length - 1];
774
+ return `${t} L${M(i.x)} ${M(n)} L${M(o.x)} ${M(n)} Z`;
775
+ }
776
+ function Ot(t, e, n, o) {
777
+ return { x: t + n * Math.sin(o), y: e - n * Math.cos(o) };
778
+ }
779
+ function Go(t, e, n, o, i) {
780
+ const r = Math.min(Math.max(i - o, 0), Math.PI * 2 - 1e-4), s = Ot(t, e, n, o), l = Ot(t, e, n, o + r), a = r > Math.PI ? 1 : 0;
781
+ return `M${M(s.x)} ${M(s.y)} A${M(n)} ${M(n)} 0 ${a} 1 ${M(l.x)} ${M(l.y)}`;
782
+ }
783
+ function Vo(t, e, n, o, i, r, s = 0) {
784
+ const l = r - i;
785
+ if (l <= 0) return "";
786
+ const a = n - o, f = Math.max(0, Math.min(s, a / 2, l * o / 2)), u = f / n, c = f / o, d = (x, b) => Ot(t, e, x, b), m = (x) => `${M(x.x)} ${M(x.y)}`, g = l - 2 * u > Math.PI ? 1 : 0, v = l - 2 * c > Math.PI ? 1 : 0;
787
+ return [
788
+ `M${m(d(n - f, i))}`,
789
+ `Q${m(d(n, i))} ${m(d(n, i + u))}`,
790
+ `A${M(n)} ${M(n)} 0 ${g} 1 ${m(d(n, r - u))}`,
791
+ `Q${m(d(n, r))} ${m(d(n - f, r))}`,
792
+ `L${m(d(o + f, r))}`,
793
+ `Q${m(d(o, r))} ${m(d(o, r - c))}`,
794
+ `A${M(o)} ${M(o)} 0 ${v} 0 ${m(d(o, i + c))}`,
795
+ `Q${m(d(o, i))} ${m(d(o + f, i))}`,
796
+ "Z"
797
+ ].join(" ");
798
+ }
799
+ function Xo(t, e = 0) {
800
+ const n = Math.PI * 2, o = t.filter((s) => s > 0).length, i = n - (o > 1 ? e * o : 0);
801
+ let r = o > 1 ? e / 2 : 0;
802
+ return t.map((s) => {
803
+ if (s <= 0) return { start: r, end: r };
804
+ const l = r, a = l + s * i;
805
+ return r = a + (o > 1 ? e : 0), { start: l, end: a };
806
+ });
807
+ }
808
+ function M(t) {
809
+ return Math.round(t * 100) / 100;
810
+ }
811
+ const Rt = 864e5;
812
+ function U(t) {
813
+ return new Date(t.getFullYear(), t.getMonth(), t.getDate());
814
+ }
815
+ function X(t, e) {
816
+ return new Date(t.getFullYear(), t.getMonth(), t.getDate() + e);
817
+ }
818
+ function en(t) {
819
+ return new Date(t.getFullYear(), t.getMonth(), 1);
820
+ }
821
+ function Zo(t, e) {
822
+ return new Date(t.getFullYear(), t.getMonth() + e, 1);
823
+ }
824
+ function nn(t) {
825
+ return new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
826
+ }
827
+ function on(t, e) {
828
+ const n = new Date(t.getFullYear(), t.getMonth() + e, 1), o = new Date(n.getFullYear(), n.getMonth() + 1, 0).getDate();
829
+ return new Date(n.getFullYear(), n.getMonth(), Math.min(t.getDate(), o));
830
+ }
831
+ function Pt(t, e) {
832
+ return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
833
+ }
834
+ function rn(t, e) {
835
+ return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth();
836
+ }
837
+ function vt(t, e = 0) {
838
+ const n = U(t);
839
+ return X(n, -((n.getDay() - e + 7) % 7));
840
+ }
841
+ function ut(t) {
842
+ return U(t).getTime();
843
+ }
844
+ function ne(t, e) {
845
+ return ut(t) < ut(e);
846
+ }
847
+ function Qo(t, e, n) {
848
+ const o = ut(t);
849
+ return !!e && o < ut(e) || !!n && o > ut(n);
850
+ }
851
+ function Jo(t, e, n) {
852
+ return e && ne(t, e) ? U(e) : n && ne(n, t) ? U(n) : t;
853
+ }
854
+ function ti(t) {
855
+ return `${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`;
856
+ }
857
+ function ei(t, e, n = 0) {
858
+ if (e === "day") return [U(t)];
859
+ if (e === "week") {
860
+ const o = vt(t, n);
861
+ return Array.from({ length: 7 }, (i, r) => X(o, r));
862
+ }
863
+ return sn(t, n).flat();
864
+ }
865
+ function sn(t, e = 0, n = !1) {
866
+ return ln(t, e, n).map((o) => o.map((i) => i.date));
867
+ }
868
+ function ln(t, e = 0, n = !1) {
869
+ const o = en(t), i = nn(t), r = (o.getDay() - e + 7) % 7, s = n ? 42 : Math.ceil((r + i) / 7) * 7, l = [];
870
+ for (let a = 0; a < s; a += 1) {
871
+ a % 7 === 0 && l.push([]);
872
+ const f = a - r, u = new Date(t.getFullYear(), t.getMonth(), 1 + f);
873
+ l[l.length - 1].push({
874
+ date: u,
875
+ day: u.getDate(),
876
+ inMonth: f >= 0 && f < i,
877
+ trailing: f >= i
878
+ });
879
+ }
880
+ return l;
881
+ }
882
+ function ni(t, e, n) {
883
+ return e === "day" ? X(t, n) : e === "week" ? X(t, 7 * n) : on(t, n);
884
+ }
885
+ function oi(t = 0, e = "en-US", n = "short") {
886
+ const o = new Intl.DateTimeFormat(e, { weekday: n, timeZone: "UTC" }), i = Date.UTC(2025, 7, 3);
887
+ return Array.from(
888
+ { length: 7 },
889
+ (r, s) => o.format(new Date(i + (s + t) % 7 * Rt)).replace(/\./g, "")
890
+ );
891
+ }
892
+ function ii(t, e = "en-US") {
893
+ const n = new Intl.DateTimeFormat(e, { month: "long", year: "numeric" }).format(t);
894
+ return n.charAt(0).toLocaleUpperCase(e) + n.slice(1);
895
+ }
896
+ function Mt(t, e = "en-US") {
897
+ return new Intl.DateTimeFormat(e, { month: "short", day: "2-digit", year: "numeric" }).format(t);
898
+ }
899
+ function ri(t, e, n = "en-US", o = "—") {
900
+ if (t && e) return `${Mt(t, n)} – ${Mt(e, n)}`;
901
+ const i = t ?? e;
902
+ return i ? Mt(i, n) : o;
903
+ }
904
+ function si(t, e, n = "en-US", o = 0) {
905
+ if (e === "day")
906
+ return new Intl.DateTimeFormat(n, { month: "long", day: "numeric", year: "numeric" }).format(t);
907
+ if (e === "month")
908
+ return new Intl.DateTimeFormat(n, { month: "long", year: "numeric" }).format(t);
909
+ const i = vt(t, o), r = X(i, 6), s = new Intl.DateTimeFormat(n, { month: "short", day: "numeric" }), l = i.getMonth() === r.getMonth() ? String(r.getDate()) : s.format(r);
910
+ return `${s.format(i)} - ${l}, ${r.getFullYear()}`;
911
+ }
912
+ function li(t, e = "en-US") {
913
+ return new Intl.DateTimeFormat(e, { hour: "numeric" }).format(new Date(2025, 0, 1, t)).replace(/\s/g, "").toLowerCase();
914
+ }
915
+ function oe(t, e = "en-US") {
916
+ return new Intl.DateTimeFormat(e, { hour: "numeric", minute: "2-digit" }).format(t);
917
+ }
918
+ function ci(t, e = "en-US") {
919
+ if (Pt(t.start, new Date(t.end.getTime() - 1)))
920
+ return `${oe(t.start, e)} – ${oe(t.end, e)}`;
921
+ const n = new Intl.DateTimeFormat(e, {
922
+ month: "short",
923
+ day: "numeric",
924
+ hour: "numeric",
925
+ minute: "2-digit"
926
+ });
927
+ return `${n.format(t.start)} – ${n.format(t.end)}`;
928
+ }
929
+ function ai(t, e) {
930
+ const n = U(e).getTime(), o = X(e, 1).getTime();
931
+ return t.filter((i) => i.start.getTime() < o && i.end.getTime() > n).sort((i, r) => i.start.getTime() - r.start.getTime());
932
+ }
933
+ const ie = (t) => t.getHours() + t.getMinutes() / 60;
934
+ function ui(t, e, n = 0, o = 24, i = 0) {
935
+ if (e.length === 0) return [];
936
+ const r = U(e[0]).getTime(), s = X(e[e.length - 1], 1).getTime(), l = o - n, a = [];
937
+ for (const c of t) {
938
+ const d = c.start.getTime(), m = c.end.getTime();
939
+ if (m <= r || d >= s) continue;
940
+ const g = d < r ? e[0] : U(c.start), v = m > s ? e[e.length - 1] : U(new Date(m - 1)), x = Math.round((g.getTime() - r) / Rt), b = Math.round((v.getTime() - g.getTime()) / Rt) + 1, k = b > 1, E = d < r ? 0 : ie(c.start), $ = ie(new Date(m)) || 24, D = k ? $ > E ? $ : E + 1 : $, T = Math.min(Math.max(E - n, 0), l), C = Math.min(Math.max(D - n, 0), l);
941
+ a.push({
942
+ event: c,
943
+ dayIndex: x,
944
+ daySpan: b,
945
+ top: T,
946
+ height: Math.max(C - T, i),
947
+ lane: 0,
948
+ lanes: 1
949
+ });
950
+ }
951
+ a.sort((c, d) => c.top - d.top || d.height - c.height || c.dayIndex - d.dayIndex);
952
+ const f = (c, d) => c.dayIndex < d.dayIndex + d.daySpan && d.dayIndex < c.dayIndex + c.daySpan && c.top < d.top + d.height && d.top < c.top + c.height, u = [];
953
+ for (const c of a) {
954
+ const d = u.find((m) => m.some((g) => f(c, g)));
955
+ d ? d.push(c) : u.push([c]);
956
+ }
957
+ for (const c of u) {
958
+ const d = [];
959
+ for (const m of c) {
960
+ let g = d.findIndex((v) => v.every((x) => !f(x, m)));
961
+ g === -1 && (g = d.length, d.push([])), d[g].push(m), m.lane = g;
962
+ }
963
+ for (const m of c) m.lanes = d.length;
964
+ }
965
+ return a;
966
+ }
967
+ function fi(t) {
968
+ const e = [...t].sort((o, i) => o.top - i.top || i.height - o.height), n = [];
969
+ for (const o of e) {
970
+ const i = n[n.length - 1], r = i == null ? void 0 : i[0];
971
+ i && r && o.top < r.top + r.height ? i.push(o) : n.push([o]);
972
+ }
973
+ return n;
974
+ }
975
+ function di(t, e, n, o = 0) {
976
+ return n === "day" ? Pt(t, e) : n === "month" ? rn(t, e) : Pt(vt(t, o), vt(e, o));
977
+ }
978
+ function hi(t, e, n) {
979
+ const o = [], i = (r, s, l) => {
980
+ var u;
981
+ const a = l !== null && !!((u = n.hasAddRow) != null && u.call(n, l)), f = r.length + (a ? 1 : 0);
982
+ r.forEach((c, d) => {
983
+ var v;
984
+ const m = n.isExpandable(c), g = m && e.has(c.id);
985
+ o.push({
986
+ kind: "node",
987
+ id: c.id,
988
+ node: c,
989
+ parentId: l ? l.id : null,
990
+ level: s,
991
+ posinset: d + 1,
992
+ setsize: f,
993
+ expandable: m,
994
+ expanded: g,
995
+ disabled: !!((v = n.isDisabled) != null && v.call(n, c))
996
+ }), g && i(c.children ?? [], s + 1, c);
997
+ }), a && l && o.push({
998
+ kind: "add",
999
+ id: `${l.id}::add`,
1000
+ node: l,
1001
+ parentId: l.id,
1002
+ level: s,
1003
+ posinset: f,
1004
+ setsize: f,
1005
+ expandable: !1,
1006
+ expanded: !1
1007
+ });
1008
+ };
1009
+ return i(t, 1, null), o;
1010
+ }
1011
+ function mi(t) {
1012
+ const e = [], n = (o) => {
1013
+ for (const i of o)
1014
+ e.push(i.id), i.children && n(i.children);
1015
+ };
1016
+ return n(t), e;
1017
+ }
1018
+ function pi(t, e, n) {
1019
+ const o = (f) => f !== void 0 && !f.disabled, i = n.find(o), r = n.findIndex((f) => f.id === e);
1020
+ if (r < 0) return i ? { focus: i.id } : null;
1021
+ const s = n[r], l = (f, u) => {
1022
+ for (let c = f + u; c >= 0 && c < n.length; c += u)
1023
+ if (o(n[c])) return n[c].id;
1024
+ }, a = (f) => f !== void 0 ? { focus: f } : {};
1025
+ switch (t) {
1026
+ case "ArrowDown":
1027
+ return a(l(r, 1));
1028
+ case "ArrowUp":
1029
+ return a(l(r, -1));
1030
+ case "Home":
1031
+ return a(i == null ? void 0 : i.id);
1032
+ case "End":
1033
+ return a(l(n.length, -1));
1034
+ case "ArrowRight":
1035
+ if (!s.expandable || s.disabled) return {};
1036
+ if (!s.expanded) return { expand: [s.id] };
1037
+ {
1038
+ const f = n[r + 1];
1039
+ return f && f.parentId === s.id && o(f) ? { focus: f.id } : {};
1040
+ }
1041
+ case "ArrowLeft": {
1042
+ if (s.expandable && s.expanded && !s.disabled) return { collapse: s.id };
1043
+ const f = n.find((u) => u.id === s.parentId);
1044
+ return o(f) ? { focus: f.id } : {};
1045
+ }
1046
+ case "Enter":
1047
+ case " ":
1048
+ return s.disabled ? {} : { activate: s.id };
1049
+ case "*":
1050
+ return { expand: n.filter(
1051
+ (u) => u.kind === "node" && u.parentId === s.parentId && u.expandable && !u.expanded && !u.disabled
1052
+ ).map((u) => u.id) };
1053
+ default:
1054
+ return null;
1055
+ }
1056
+ }
1057
+ function gi(t = 500) {
1058
+ let e = "", n = 0;
1059
+ return function(i, r, s, l = (a) => a.node.label) {
1060
+ const a = Date.now();
1061
+ e = a - n > t ? i : e + i, n = a;
1062
+ const f = e.toLowerCase(), u = s.findIndex((d) => d.id === r), c = e.length === 1 ? 1 : 0;
1063
+ for (let d = 0; d < s.length; d++) {
1064
+ const m = s[(u + c + d + s.length) % s.length];
1065
+ if (!m.disabled && l(m).toLowerCase().startsWith(f)) return m.id;
1066
+ }
1067
+ return null;
1068
+ };
1069
+ }
1070
+ function yi(t) {
1071
+ return t.key.length === 1 && t.key !== " " && t.key !== "*" && !t.ctrlKey && !t.metaKey && !t.altKey;
1072
+ }
1073
+ const cn = {
1074
+ pickedUp: (t) => `Picked up ${t.card}. ${t.column}, position ${t.position} of ${t.total}. Use the arrow keys to move, Space to drop, Escape to cancel.`,
1075
+ moved: (t) => `${t.card}: ${t.column}, position ${t.position} of ${t.total}.`,
1076
+ dropped: (t) => t.column === t.fromColumn && t.position === t.fromPosition ? `${t.card} dropped back at ${t.column}, position ${t.position} of ${t.total}.` : `${t.card} dropped in ${t.column}, position ${t.position} of ${t.total}.`,
1077
+ cancelled: (t) => `Move cancelled. ${t.card} returned to ${t.fromColumn}, position ${t.fromPosition} of ${t.fromTotal}.`
1078
+ }, bi = "Use the arrow keys to move between cards. Press Space to pick up the card; while it is picked up, use the arrow keys to move it, Space to drop it and Escape to cancel.", an = "a[href], button, input, select, textarea, [contenteditable], [tabindex]", un = 6, fn = 300, bt = 48;
1079
+ function xi(t, e) {
1080
+ let n = e, o = null, i = "", r = null, s = { x: 0, y: 0 }, l = !1;
1081
+ const a = () => ({ ...cn, ...n.announcements }), f = (h) => {
1082
+ i = h === i ? `${h} ` : h, n.announce(i);
1083
+ }, u = () => Array.from(t.querySelectorAll("[data-kanban-column]")), c = (h) => Array.from(h.querySelectorAll("[data-kanban-card]")), d = (h, p) => c(h).filter((y) => y !== p), m = (h) => h.dataset.kanbanColumnLabel ?? h.dataset.kanbanColumn ?? "", g = (h) => h.dataset.kanbanCardLabel ?? h.dataset.kanbanCard ?? "", v = (h) => h.hasAttribute("data-kanban-handle") ? h : h.querySelector("[data-kanban-handle]"), x = (h) => {
1084
+ var p;
1085
+ return ((p = h.parentElement) == null ? void 0 : p.tagName) === "LI" ? h.parentElement : h;
1086
+ }, b = (h) => ({
1087
+ card: g(h.card),
1088
+ column: m(h.toColumn),
1089
+ position: h.index + 1,
1090
+ total: d(h.toColumn, h.card).length + 1,
1091
+ fromColumn: m(h.fromColumn),
1092
+ fromPosition: h.fromIndex + 1,
1093
+ fromTotal: h.fromTotal
1094
+ }), k = () => {
1095
+ t.querySelectorAll("[data-kanban-drop]").forEach((h) => h.removeAttribute("data-kanban-drop")), t.querySelectorAll("[data-kanban-drop-target]").forEach((h) => h.removeAttribute("data-kanban-drop-target"));
1096
+ }, E = (h) => {
1097
+ if (k(), h.toColumn.setAttribute("data-kanban-drop-target", ""), h.toColumn === h.fromColumn && h.index === h.fromIndex) return;
1098
+ const y = d(h.toColumn, h.card);
1099
+ h.index < y.length ? x(y[h.index]).setAttribute("data-kanban-drop", "before") : y.length > 0 && x(y[y.length - 1]).setAttribute("data-kanban-drop", "after");
1100
+ }, $ = (h, p) => {
1101
+ const y = h.closest("[data-kanban-column]"), w = h.dataset.kanbanCard;
1102
+ if (!y || !t.contains(y) || w == null) return !1;
1103
+ const A = c(y);
1104
+ return o = {
1105
+ mode: p,
1106
+ card: h,
1107
+ cardId: w,
1108
+ fromColumn: y,
1109
+ fromIndex: A.indexOf(h),
1110
+ fromTotal: A.length,
1111
+ toColumn: y,
1112
+ index: A.indexOf(h)
1113
+ }, t.setAttribute("data-kanban-dragging", p), h.setAttribute("data-kanban-lifted", p), E(o), f(a().pickedUp(b(o))), !0;
1114
+ }, D = (h) => {
1115
+ const p = o;
1116
+ if (!p) return;
1117
+ o = null, k(), t.removeAttribute("data-kanban-dragging"), p.card.removeAttribute("data-kanban-lifted"), Wt();
1118
+ const y = b(p);
1119
+ if (!h) {
1120
+ f(a().cancelled(y));
1121
+ return;
1122
+ }
1123
+ f(a().dropped(y));
1124
+ const w = p.fromColumn.dataset.kanbanColumn ?? "", A = p.toColumn.dataset.kanbanColumn ?? "";
1125
+ if (!(w === A && p.index === p.fromIndex) && (n.onMove({ cardId: p.cardId, fromColumn: w, toColumn: A, index: p.index, fromIndex: p.fromIndex }), p.mode === "keyboard")) {
1126
+ const P = (I) => {
1127
+ const j = `[data-kanban-card="${window.CSS.escape(p.cardId)}"]`, Z = t.querySelector(j), K = Z && v(Z);
1128
+ K && document.activeElement !== K && (F(K), K.focus({ preventScroll: !1 })), I > 0 && requestAnimationFrame(() => P(I - 1));
1129
+ };
1130
+ requestAnimationFrame(() => P(2));
1131
+ }
1132
+ }, T = (h, p) => {
1133
+ if (!o) return;
1134
+ const y = d(h, o.card).length, w = Math.max(0, Math.min(p, y));
1135
+ h === o.toColumn && w === o.index || (o.toColumn = h, o.index = w, E(o), f(a().moved(b(o))));
1136
+ }, C = (h) => c(h).map((p) => v(p)).filter((p) => p != null), F = (h) => {
1137
+ const p = h.closest("[data-kanban-column]");
1138
+ p && C(p).forEach((y) => y.setAttribute("tabindex", y === h ? "0" : "-1"));
1139
+ }, q = () => {
1140
+ u().forEach((h) => {
1141
+ const p = C(h), y = p.find((w) => w === document.activeElement) ?? p.find((w) => w.getAttribute("tabindex") === "0") ?? p[0];
1142
+ p.forEach((w) => w.setAttribute("tabindex", w === y ? "0" : "-1"));
1143
+ });
1144
+ }, _ = (h) => {
1145
+ h && (F(h), h.focus(), h.scrollIntoView({ block: "nearest", inline: "nearest" }));
1146
+ }, H = (h, p) => {
1147
+ const y = h.closest("[data-kanban-card]"), w = y == null ? void 0 : y.closest("[data-kanban-column]");
1148
+ if (!y || !w) return !1;
1149
+ const A = C(w), P = A.indexOf(h), I = {
1150
+ ArrowUp: A[P - 1],
1151
+ ArrowDown: A[P + 1],
1152
+ Home: A[0],
1153
+ End: A[A.length - 1]
1154
+ };
1155
+ if (p in I)
1156
+ return _(I[p]), !0;
1157
+ if (p === "ArrowLeft" || p === "ArrowRight") {
1158
+ const j = p === "ArrowRight" != (getComputedStyle(t).direction === "rtl") ? 1 : -1, Z = u();
1159
+ for (let K = Z.indexOf(w) + j; K >= 0 && K < Z.length; K += j) {
1160
+ const At = C(Z[K]);
1161
+ if (At.length) {
1162
+ _(At[Math.min(P, At.length - 1)]);
1163
+ break;
1164
+ }
1165
+ }
1166
+ return !0;
1167
+ }
1168
+ return !1;
1169
+ }, O = (h) => {
1170
+ var y;
1171
+ const p = h.target;
1172
+ (y = p.hasAttribute) != null && y.call(p, "data-kanban-handle") && F(p);
1173
+ }, L = new window.MutationObserver(() => {
1174
+ o || q();
1175
+ });
1176
+ L.observe(t, { childList: !0, subtree: !0 }), q();
1177
+ const S = (h) => {
1178
+ if ((o == null ? void 0 : o.mode) === "pointer") {
1179
+ h.key === "Escape" && (h.preventDefault(), D(!1));
1180
+ return;
1181
+ }
1182
+ const p = h.target;
1183
+ if (!o) {
1184
+ if (!p.hasAttribute("data-kanban-handle")) return;
1185
+ if (h.key !== " ") {
1186
+ !h.altKey && !h.ctrlKey && !h.metaKey && !h.shiftKey && H(p, h.key) && h.preventDefault();
1187
+ return;
1188
+ }
1189
+ const P = p.closest("[data-kanban-card]");
1190
+ if (!P) return;
1191
+ h.preventDefault(), l = !0, $(P, "keyboard");
1192
+ return;
1193
+ }
1194
+ const y = o, w = u(), A = w.indexOf(y.toColumn);
1195
+ switch (h.key) {
1196
+ case "ArrowUp":
1197
+ h.preventDefault(), T(y.toColumn, y.index - 1);
1198
+ break;
1199
+ case "ArrowDown":
1200
+ h.preventDefault(), T(y.toColumn, y.index + 1);
1201
+ break;
1202
+ case "ArrowLeft":
1203
+ case "ArrowRight": {
1204
+ h.preventDefault();
1205
+ const P = h.key === "ArrowRight" != (getComputedStyle(t).direction === "rtl") ? 1 : -1, I = w[A + P];
1206
+ I && (T(I, y.index), I.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" }));
1207
+ break;
1208
+ }
1209
+ case " ":
1210
+ case "Enter":
1211
+ h.preventDefault(), l = h.key === " ", D(!0);
1212
+ break;
1213
+ case "Escape":
1214
+ h.preventDefault(), D(!1);
1215
+ break;
1216
+ case "Tab":
1217
+ D(!1);
1218
+ break;
1219
+ }
1220
+ }, R = (h) => {
1221
+ h.key === " " && l && (h.preventDefault(), l = !1);
1222
+ }, B = (h) => {
1223
+ if ((o == null ? void 0 : o.mode) !== "keyboard") return;
1224
+ const p = h.relatedTarget;
1225
+ p && o.card.contains(p) || D(!1);
1226
+ }, G = (h, p) => {
1227
+ if (!o) return;
1228
+ const y = document.elementFromPoint(h, p);
1229
+ let w = (y == null ? void 0 : y.closest("[data-kanban-column]")) ?? null;
1230
+ if ((!w || !t.contains(w)) && (w = u().find((I) => {
1231
+ const j = I.getBoundingClientRect();
1232
+ return h >= j.left && h <= j.right;
1233
+ }) ?? null), !w) return;
1234
+ const A = d(w, o.card);
1235
+ let P = A.length;
1236
+ for (let I = 0; I < A.length; I += 1) {
1237
+ const j = A[I].getBoundingClientRect();
1238
+ if (p < j.top + j.height / 2) {
1239
+ P = I;
1240
+ break;
1241
+ }
1242
+ }
1243
+ T(w, P);
1244
+ };
1245
+ let V = null, ot = { x: 0, y: 0 }, it = 0;
1246
+ const Fe = (h) => {
1247
+ const p = h.getBoundingClientRect(), y = h.cloneNode(!0);
1248
+ y.removeAttribute("id"), y.querySelectorAll("[id]").forEach((w) => w.removeAttribute("id")), y.removeAttribute("tabindex"), y.querySelectorAll("[tabindex], a, button").forEach((w) => w.setAttribute("tabindex", "-1")), y.removeAttribute("data-kanban-card"), y.removeAttribute("data-kanban-handle"), y.setAttribute("aria-hidden", "true"), y.setAttribute("data-kanban-lifted", "preview"), Object.assign(y.style, {
1249
+ position: "fixed",
1250
+ left: "0px",
1251
+ top: "0px",
1252
+ width: `${p.width}px`,
1253
+ margin: "0",
1254
+ zIndex: "2147483000",
1255
+ pointerEvents: "none"
1256
+ }), document.body.appendChild(y), V = y;
1257
+ }, Ht = () => {
1258
+ V && (V.style.transform = `translate(${ot.x - s.x}px, ${ot.y - s.y}px)`);
1259
+ }, Wt = () => {
1260
+ V == null || V.remove(), V = null, cancelAnimationFrame(it), it = 0;
1261
+ }, Yt = () => {
1262
+ if (it = 0, (o == null ? void 0 : o.mode) !== "pointer") return;
1263
+ const h = t.getBoundingClientRect(), { x: p, y } = ot;
1264
+ let w = 0;
1265
+ if (p < h.left + bt ? w = -Math.ceil((bt - Math.max(0, p - h.left)) / 3) : p > h.right - bt && (w = Math.ceil((bt - Math.max(0, h.right - p)) / 3)), w !== 0) {
1266
+ const A = t.scrollLeft;
1267
+ t.scrollLeft += w, t.scrollLeft !== A && G(p, y);
1268
+ }
1269
+ it = requestAnimationFrame(Yt);
1270
+ }, Oe = () => {
1271
+ if (!r) return;
1272
+ const { card: h, x: p, y } = r, w = h.getBoundingClientRect();
1273
+ s = { x: p - w.left, y: y - w.top }, $(h, "pointer") && (Fe(h), ot = { x: p, y }, Ht(), it = requestAnimationFrame(Yt), rt = (A) => {
1274
+ A.preventDefault(), A.stopPropagation();
1275
+ });
1276
+ };
1277
+ let rt = null;
1278
+ const Gt = (h) => {
1279
+ if (o || !h.isPrimary || h.button !== 0) return;
1280
+ const p = h.target, y = p.closest("[data-kanban-card]");
1281
+ if (!y || !t.contains(y)) return;
1282
+ const w = p.closest(an);
1283
+ if (w && w !== y && !w.hasAttribute("data-kanban-handle")) return;
1284
+ const A = h.pointerType === "touch";
1285
+ r = { card: y, id: h.pointerId, x: h.clientX, y: h.clientY, touch: A, ready: !A, timer: null }, A && (r.timer = setTimeout(() => {
1286
+ r && (r.ready = !0);
1287
+ }, fn)), window.addEventListener("pointermove", Vt), window.addEventListener("pointerup", Xt), window.addEventListener("pointercancel", Zt);
1288
+ }, Vt = (h) => {
1289
+ if (r && h.pointerId === r.id && !o) {
1290
+ if (!(Math.hypot(h.clientX - r.x, h.clientY - r.y) > un)) return;
1291
+ if (!r.ready) {
1292
+ gt();
1293
+ return;
1294
+ }
1295
+ Oe();
1296
+ }
1297
+ (o == null ? void 0 : o.mode) === "pointer" && (ot = { x: h.clientX, y: h.clientY }, Ht(), G(h.clientX, h.clientY));
1298
+ }, gt = () => {
1299
+ r != null && r.timer && clearTimeout(r.timer), r = null, window.removeEventListener("pointermove", Vt), window.removeEventListener("pointerup", Xt), window.removeEventListener("pointercancel", Zt);
1300
+ }, Xt = () => {
1301
+ const h = (o == null ? void 0 : o.mode) === "pointer";
1302
+ if (gt(), !!h) {
1303
+ if (rt) {
1304
+ const p = rt;
1305
+ rt = null, window.addEventListener("click", p, { capture: !0, once: !0 }), setTimeout(() => window.removeEventListener("click", p, { capture: !0 }), 0);
1306
+ }
1307
+ D(!0);
1308
+ }
1309
+ }, Zt = () => {
1310
+ const h = (o == null ? void 0 : o.mode) === "pointer";
1311
+ gt(), rt = null, h && D(!1);
1312
+ }, Qt = (h) => {
1313
+ ((o == null ? void 0 : o.mode) === "pointer" || r != null && r.ready) && h.preventDefault();
1314
+ }, Jt = (h) => {
1315
+ (o || r != null && r.touch) && h.preventDefault();
1316
+ }, te = (h) => {
1317
+ var p, y;
1318
+ (y = (p = h.target) == null ? void 0 : p.closest) != null && y.call(p, "[data-kanban-card]") && h.preventDefault();
1319
+ };
1320
+ return t.addEventListener("keydown", S), t.addEventListener("keyup", R), t.addEventListener("focusout", B), t.addEventListener("focusin", O), t.addEventListener("pointerdown", Gt), t.addEventListener("touchmove", Qt, { passive: !1 }), t.addEventListener("contextmenu", Jt), t.addEventListener("dragstart", te), {
1321
+ update(h) {
1322
+ n = h;
1323
+ },
1324
+ destroy() {
1325
+ o && D(!1), gt(), t.removeEventListener("keydown", S), t.removeEventListener("keyup", R), t.removeEventListener("focusout", B), t.removeEventListener("focusin", O), L.disconnect(), Wt(), t.removeEventListener("pointerdown", Gt), t.removeEventListener("touchmove", Qt), t.removeEventListener("contextmenu", Jt), t.removeEventListener("dragstart", te);
1326
+ }
1327
+ };
1328
+ }
1329
+ const re = {
1330
+ top: "bottom",
1331
+ bottom: "top",
1332
+ left: "right",
1333
+ right: "left"
1334
+ }, se = { start: "end", center: "center", end: "start" }, st = (t) => t === "top" || t === "bottom";
1335
+ function dn(t, e) {
1336
+ return e === !1 ? [t] : Array.isArray(e) ? [t, ...e.filter((n) => n !== t)] : st(t) ? [t, re[t]] : [t, re[t], "bottom", "top"];
1337
+ }
1338
+ function hn(t, e, n, o = {}) {
1339
+ const i = o.side ?? "bottom", r = o.align ?? "start", s = o.offset ?? 0, l = o.padding ?? 8, a = o.shift ?? !0, f = n.left + n.width, u = n.top + n.height, c = (S) => S === "bottom" ? u - l - (t.top + t.height + s) : S === "top" ? t.top - s - (n.top + l) : S === "right" ? f - l - (t.left + t.width + s) : t.left - s - (n.left + l), d = (S) => st(S) ? e.height : e.width, m = dn(i, o.flip), g = m.find((S) => c(S) >= d(S)) ?? m.reduce((S, R) => c(R) > c(S) ? R : S);
1340
+ let v = st(g) === st(i) ? r : "center";
1341
+ const x = st(g), b = x ? t.left : t.top, k = x ? t.width : t.height, E = x ? e.width : e.height, $ = (x ? n.left : n.top) + l, D = (x ? f : u) - l, T = b + k / 2, C = (S) => {
1342
+ const R = x && o.rtl ? se[S] : S, B = o.anchorPoint;
1343
+ let G;
1344
+ return R === "center" ? G = T - E / 2 : R === "start" ? G = B != null ? T - B : b : G = B != null ? T + B - E : b + k - E, G + (o.crossOffset ?? 0);
1345
+ }, F = (S) => Math.max(0, $ - S) + Math.max(0, S + E - D);
1346
+ o.flipAlign && x && (v = [v, se[v], "center"].reduce((R, B) => F(C(B)) < F(C(R)) ? B : R));
1347
+ const q = C(v), _ = a ? E > D - $ ? $ : Math.max($, Math.min(q, D - E)) : q, H = x ? e.height : e.width;
1348
+ let O;
1349
+ if (g === "bottom" ? O = t.top + t.height + s : g === "top" ? O = t.top - s - H : g === "right" ? O = t.left + t.width + s : O = t.left - s - H, a === "both") {
1350
+ const S = (x ? n.top : n.left) + l, R = (x ? u : f) - l;
1351
+ O = H > R - S ? S : Math.max(S, Math.min(O, R - H));
1352
+ }
1353
+ let L = null;
1354
+ if (o.arrowInset != null) {
1355
+ const S = o.arrowInset;
1356
+ L = Math.max(S, Math.min(T - _, E - S));
1357
+ }
1358
+ return {
1359
+ x: Math.round(x ? _ : O),
1360
+ y: Math.round(x ? O : _),
1361
+ side: g,
1362
+ align: v,
1363
+ flipped: g !== i,
1364
+ shifted: Math.round(_) !== Math.round(q),
1365
+ arrow: L === null ? null : Math.round(L)
1366
+ };
1367
+ }
1368
+ const le = (t, e) => t === "inline-end" ? e ? "left" : "right" : t === "inline-start" ? e ? "right" : "left" : t, zt = (t) => "nodeType" in t ? t : t.contextElement ?? null;
1369
+ function mn(t) {
1370
+ const e = [];
1371
+ if (!t || typeof getComputedStyle > "u") return e;
1372
+ for (let n = t.parentElement; n && n !== document.documentElement; n = n.parentElement) {
1373
+ const o = getComputedStyle(n);
1374
+ /(auto|scroll|hidden|clip)/.test(`${o.overflow}${o.overflowX}${o.overflowY}`) && e.push(n);
1375
+ }
1376
+ return e;
1377
+ }
1378
+ function pn() {
1379
+ const t = document.documentElement;
1380
+ return { left: 0, top: 0, width: t.clientWidth || window.innerWidth, height: t.clientHeight || window.innerHeight };
1381
+ }
1382
+ function gn(t, e) {
1383
+ const n = pn();
1384
+ if (e !== "clippingAncestors") return n;
1385
+ let o = n.left, i = n.top, r = n.left + n.width, s = n.top + n.height;
1386
+ for (const l of mn(zt(t))) {
1387
+ const a = l.getBoundingClientRect();
1388
+ o = Math.max(o, a.left), i = Math.max(i, a.top), r = Math.min(r, a.right), s = Math.min(s, a.bottom);
1389
+ }
1390
+ return { left: o, top: i, width: Math.max(0, r - o), height: Math.max(0, s - i) };
1391
+ }
1392
+ function wi(t, e, n = {}) {
1393
+ const o = zt(t), i = n.rtl ?? (o ? getComputedStyle(o).direction === "rtl" : !1), r = t.getBoundingClientRect();
1394
+ e.style.setProperty("--ods-anchor-width", `${r.width}px`);
1395
+ const s = hn(
1396
+ { left: r.left, top: r.top, width: r.width, height: r.height },
1397
+ { width: e.offsetWidth, height: e.offsetHeight },
1398
+ gn(t, n.boundary),
1399
+ {
1400
+ ...n,
1401
+ rtl: i,
1402
+ side: le(n.side ?? "bottom", i),
1403
+ flip: typeof n.flip == "object" ? n.flip.map((l) => le(l, i)) : n.flip
1404
+ }
1405
+ );
1406
+ return e.style.left = `${s.x}px`, e.style.top = `${s.y}px`, e.dataset.side = s.side, s;
1407
+ }
1408
+ const Nt = "orvain:floating-update";
1409
+ function ki() {
1410
+ window.dispatchEvent(new Event(Nt));
1411
+ }
1412
+ function vi(t, e, n) {
1413
+ var l;
1414
+ let o = !0;
1415
+ const i = () => {
1416
+ o && n();
1417
+ };
1418
+ i(), window.addEventListener("scroll", i, { capture: !0, passive: !0 }), window.addEventListener("resize", i), window.addEventListener(Nt, i);
1419
+ const r = typeof ResizeObserver < "u" ? new ResizeObserver(i) : null, s = zt(t);
1420
+ return s && (r == null || r.observe(s)), r == null || r.observe(e), (l = document.fonts) == null || l.ready.then(i), () => {
1421
+ o = !1, r == null || r.disconnect(), window.removeEventListener("scroll", i, { capture: !0 }), window.removeEventListener("resize", i), window.removeEventListener(Nt, i);
1422
+ };
1423
+ }
1424
+ function ye(t) {
1425
+ try {
1426
+ return t.matches(":popover-open");
1427
+ } catch {
1428
+ return !1;
1429
+ }
1430
+ }
1431
+ function Si(t) {
1432
+ return typeof t.showPopover != "function" || !t.isConnected ? !1 : (t.getAttribute("popover") !== "manual" && t.setAttribute("popover", "manual"), ye(t) || t.showPopover(), !0);
1433
+ }
1434
+ function Ai(t) {
1435
+ ye(t) && typeof t.hidePopover == "function" && t.hidePopover(), t.removeAttribute("popover");
1436
+ }
1437
+ const W = {
1438
+ mobile: { min: 320, max: 767 },
1439
+ tablet: { min: 768, max: 1023 },
1440
+ desktop: { min: 1024, max: 3200 }
1441
+ }, Ei = {
1442
+ /** below tablet: 0–767 */
1443
+ mobile: `(max-width: ${W.mobile.max}px)`,
1444
+ /** tablet only: 768–1023 */
1445
+ tablet: `(min-width: ${W.tablet.min}px) and (max-width: ${W.tablet.max}px)`,
1446
+ /** tablet and up: ≥ 768 */
1447
+ tabletUp: `(min-width: ${W.tablet.min}px)`,
1448
+ /** below desktop: 0–1023 */
1449
+ belowDesktop: `(max-width: ${W.tablet.max}px)`,
1450
+ /** desktop: ≥ 1024 */
1451
+ desktop: `(min-width: ${W.desktop.min}px)`
1452
+ };
1453
+ function Mi(t) {
1454
+ return t >= W.desktop.min ? "desktop" : t >= W.tablet.min ? "tablet" : "mobile";
1455
+ }
1456
+ function lt(t, e, n, o) {
1457
+ const i = o > 0 ? o : 1, r = Math.round((t - e) / i) * i + e, s = (String(i).split(".")[1] ?? "").length;
1458
+ return Math.min(n, Math.max(e, Number(r.toFixed(s))));
1459
+ }
1460
+ function Di(t, e, n, o, i) {
1461
+ const r = e.width > 0 ? (t - e.left) / e.width : 0;
1462
+ return lt(n + Math.min(1, Math.max(0, r)) * (o - n), n, o, i);
1463
+ }
1464
+ function Ti(t, e, n, o, i) {
1465
+ const r = i > 0 ? i : 1, s = Math.max(r, (o - n) / 10);
1466
+ switch (t) {
1467
+ case "ArrowLeft":
1468
+ case "ArrowDown":
1469
+ return lt(e - r, n, o, r);
1470
+ case "ArrowRight":
1471
+ case "ArrowUp":
1472
+ return lt(e + r, n, o, r);
1473
+ case "PageDown":
1474
+ return lt(e - s, n, o, r);
1475
+ case "PageUp":
1476
+ return lt(e + s, n, o, r);
1477
+ case "Home":
1478
+ return n;
1479
+ case "End":
1480
+ return o;
1481
+ default:
1482
+ return null;
1483
+ }
1484
+ }
1485
+ const N = [];
1486
+ function yn(t, e) {
1487
+ for (const n of t.options.getElements())
1488
+ if (n && e.includes(n)) return !0;
1489
+ return !1;
1490
+ }
1491
+ function bn(t, e) {
1492
+ for (let n = t; n < N.length; n += 1)
1493
+ if (yn(N[n], e)) return !0;
1494
+ return !1;
1495
+ }
1496
+ function be(t, e) {
1497
+ const n = t.composedPath(), o = N.slice();
1498
+ for (let i = o.length - 1; i >= 0; i -= 1) {
1499
+ const r = o[i];
1500
+ if (!(e === "outside" ? r.options.outsidePress !== !1 : r.options.focusOut === !0)) continue;
1501
+ const l = N.indexOf(r);
1502
+ l === -1 || bn(l, n) || r.options.onDismiss(e, t);
1503
+ }
1504
+ }
1505
+ function xe(t) {
1506
+ be(t, "outside");
1507
+ }
1508
+ function we(t) {
1509
+ be(t, "focusout");
1510
+ }
1511
+ function ke(t) {
1512
+ if (t.key !== "Escape" || t.defaultPrevented || t.isComposing) return;
1513
+ const e = N[N.length - 1];
1514
+ !e || e.options.escapeKey === !1 || (t.preventDefault(), e.options.onDismiss("escape", t));
1515
+ }
1516
+ function xn() {
1517
+ document.addEventListener("pointerdown", xe, !0), document.addEventListener("focusin", we, !0), document.addEventListener("keydown", ke);
1518
+ }
1519
+ function wn() {
1520
+ document.removeEventListener("pointerdown", xe, !0), document.removeEventListener("focusin", we, !0), document.removeEventListener("keydown", ke);
1521
+ }
1522
+ function Li(t) {
1523
+ if (typeof document > "u") return () => {
1524
+ };
1525
+ const e = { options: t };
1526
+ return N.push(e), N.length === 1 && xn(), () => {
1527
+ const n = N.indexOf(e);
1528
+ n !== -1 && (N.splice(n, 1), N.length === 0 && wn());
1529
+ };
1530
+ }
1531
+ function xt(t, e, n, o, i) {
1532
+ for (let r = 0; r < t; r += 1) {
1533
+ let s = n + r * o;
1534
+ if (i) s = (s % t + t) % t;
1535
+ else if (s < 0 || s >= t) return -1;
1536
+ if (!e(s)) return s;
1537
+ }
1538
+ return -1;
1539
+ }
1540
+ function $i(t, e, n, o, i) {
1541
+ if (n <= 0) return -1;
1542
+ if (t === "first") return xt(n, o, 0, 1, !1);
1543
+ if (t === "last") return xt(n, o, n - 1, -1, !1);
1544
+ const r = t === "next" ? 1 : -1;
1545
+ if (e < 0 || e >= n)
1546
+ return xt(n, o, r === 1 ? 0 : n - 1, r, !1);
1547
+ const s = xt(n, o, e + r, r, i);
1548
+ return s === -1 ? e : s;
1549
+ }
1550
+ function Ci(t, e, n = !1, o = !0) {
1551
+ const i = e !== "horizontal", r = e !== "vertical";
1552
+ switch (t) {
1553
+ case "ArrowDown":
1554
+ return i ? "next" : null;
1555
+ case "ArrowUp":
1556
+ return i ? "prev" : null;
1557
+ case "ArrowRight":
1558
+ return r ? n ? "prev" : "next" : null;
1559
+ case "ArrowLeft":
1560
+ return r ? n ? "next" : "prev" : null;
1561
+ case "Home":
1562
+ return o ? "first" : null;
1563
+ case "End":
1564
+ return o ? "last" : null;
1565
+ default:
1566
+ return null;
1567
+ }
1568
+ }
1569
+ const kn = 500;
1570
+ function Ii(t = kn) {
1571
+ let e = "", n = -1 / 0;
1572
+ const o = (i = Date.now()) => e !== "" && i - n < t;
1573
+ return {
1574
+ active: o,
1575
+ reset() {
1576
+ e = "", n = -1 / 0;
1577
+ },
1578
+ handle(i, r, s, l, a, f = Date.now()) {
1579
+ if (i.length !== 1 || i === " " && !o(f)) return null;
1580
+ e = (o(f) ? e : "") + i.toLowerCase(), n = f;
1581
+ const u = e.split("").every((m) => m === e[0]), c = u ? e[0] : e, d = u ? r + 1 : Math.max(r, 0);
1582
+ for (let m = 0; m < s; m += 1) {
1583
+ const g = ((d + m) % s + s) % s;
1584
+ if (!a(g) && l(g).trim().toLowerCase().startsWith(c)) return g;
1585
+ }
1586
+ return -1;
1587
+ }
1588
+ };
1589
+ }
1590
+ function vn(t, e) {
1591
+ const n = t.relatedTarget;
1592
+ return !(n instanceof Node && e.contains(n));
1593
+ }
1594
+ function Fi(t) {
1595
+ let e = null, n = !1, o = !1, i;
1596
+ const r = () => e == null ? void 0 : e.ownerDocument, s = () => {
1597
+ var m;
1598
+ const d = (m = r()) == null ? void 0 : m.activeElement;
1599
+ return !!e && !!d && e.contains(d);
1600
+ }, l = () => {
1601
+ const d = r();
1602
+ d == null || d.removeEventListener("focusin", u, !0), d == null || d.removeEventListener("pointerdown", c, !0);
1603
+ }, a = (d) => {
1604
+ n && (n = !1, clearTimeout(i), l(), t(d));
1605
+ }, f = (d) => {
1606
+ clearTimeout(i), i = setTimeout(() => {
1607
+ o || s() || a(d);
1608
+ }, 0);
1609
+ };
1610
+ function u(d) {
1611
+ e && d.target instanceof Node && !e.contains(d.target) && a(d);
1612
+ }
1613
+ function c(d) {
1614
+ !e || d.target instanceof Node && e.contains(d.target) || f(new FocusEvent("blur", { relatedTarget: null }));
1615
+ }
1616
+ return {
1617
+ focusIn(d) {
1618
+ if (e = d, n) return;
1619
+ n = !0;
1620
+ const m = d.ownerDocument;
1621
+ m.addEventListener("focusin", u, !0), m.addEventListener("pointerdown", c, !0);
1622
+ },
1623
+ focusOut(d, m) {
1624
+ e = m, vn(d, m) && (d.relatedTarget == null ? f(d) : a(d));
1625
+ },
1626
+ pointerDown(d) {
1627
+ if (e = d, o) return;
1628
+ o = !0;
1629
+ const m = d.ownerDocument, g = () => {
1630
+ m.removeEventListener("pointerup", g, !0), m.removeEventListener("pointercancel", g, !0), setTimeout(() => {
1631
+ o = !1, n && !s() && a(new FocusEvent("blur", { relatedTarget: null }));
1632
+ }, 0);
1633
+ };
1634
+ m.addEventListener("pointerup", g, !0), m.addEventListener("pointercancel", g, !0);
1635
+ },
1636
+ dispose() {
1637
+ clearTimeout(i), l(), n = !1;
1638
+ }
1639
+ };
1640
+ }
1641
+ function Sn(t, e) {
1642
+ if (e) {
1643
+ const n = t.ownerDocument.getElementById(e);
1644
+ return n instanceof HTMLFormElement ? n : null;
1645
+ }
1646
+ return t.closest("form");
1647
+ }
1648
+ function Oi(t, e, n) {
1649
+ const o = Sn(t, e);
1650
+ return o ? (o.addEventListener("reset", n), () => o.removeEventListener("reset", n)) : () => {
1651
+ };
1652
+ }
1653
+ function An(t) {
1654
+ return t == null ? [""] : typeof t == "string" ? [t] : [...t];
1655
+ }
1656
+ function Ri(t) {
1657
+ return An(t).some((e) => e !== "");
1658
+ }
1659
+ const ft = (t) => String(t).padStart(2, "0");
1660
+ function Pi(t) {
1661
+ return !t || Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${ft(t.getMonth() + 1)}-${ft(t.getDate())}`;
1662
+ }
1663
+ function Ni(t, e, n) {
1664
+ const o = `${ft(t)}:${ft(e)}`;
1665
+ return n === void 0 ? o : `${o}:${ft(n)}`;
1666
+ }
1667
+ function _i(t, e) {
1668
+ return t.length === e.length && t.every((n, o) => Object.is(n, e[o]));
1669
+ }
1670
+ const ve = 24, En = 1, Se = ["bold", "italic", "underline"], Ae = ["color", "fontFamily", "fontSize"], Mn = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/, Dn = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d*\.?\d+)\s*)?\)$/, Tn = /^[a-z]{3,20}$/, Ln = /^[\w\s,'"-]{1,100}$/, $n = /^(\d{1,3}(?:\.\d{1,2})?)(px|pt|em|rem|%)$/, Cn = { px: 200, pt: 150, em: 12, rem: 12, "%": 1200 };
1671
+ function In(t) {
1672
+ const e = t.trim().toLowerCase();
1673
+ if (Mn.test(e)) return e.length === 4 ? `#${[...e.slice(1)].map((o) => o + o).join("")}` : e;
1674
+ const n = Dn.exec(e);
1675
+ if (n) {
1676
+ const o = [n[1], n[2], n[3]].map(Number);
1677
+ if (o.some((r) => r > 255)) return;
1678
+ const i = n[4] === void 0 ? 1 : Number(n[4]);
1679
+ return i >= 0 ? i >= 1 ? `#${o.map((r) => r.toString(16).padStart(2, "0")).join("")}` : `rgba(${o.join(", ")}, ${i})` : void 0;
1680
+ }
1681
+ return Tn.test(e) && e !== "expression" ? e : void 0;
1682
+ }
1683
+ function Fn(t) {
1684
+ const e = t.trim().replace(/\s+/g, " ");
1685
+ return e && Ln.test(e) ? e : void 0;
1686
+ }
1687
+ function On(t) {
1688
+ const e = $n.exec(t.trim().toLowerCase());
1689
+ if (!e) return;
1690
+ const n = Number(e[1]), o = e[2];
1691
+ return n > 0 && n <= (Cn[o] ?? 0) ? `${e[1]}${o}` : void 0;
1692
+ }
1693
+ const Rn = {
1694
+ color: In,
1695
+ fontFamily: Fn,
1696
+ fontSize: On
1697
+ };
1698
+ function Pn(t) {
1699
+ const e = /* @__PURE__ */ new Map();
1700
+ if (!t) return e;
1701
+ for (const n of t.split(";")) {
1702
+ const o = n.indexOf(":");
1703
+ o < 0 || e.set(n.slice(0, o).trim().toLowerCase(), n.slice(o + 1).trim());
1704
+ }
1705
+ return e;
1706
+ }
1707
+ function et(t, e, n, o) {
1708
+ const i = { align: t, runs: e };
1709
+ n && (i.quote = !0);
1710
+ const r = Math.min(Math.max(Math.trunc(o ?? 0), 0), En);
1711
+ return r && (i.indent = r), i;
1712
+ }
1713
+ const mt = (t, e) => et(t.align, e, t.quote, t.indent), Nn = /^(-?\d*\.?\d+)(px|pt|em|rem)$/, _n = { px: 1, pt: 4 / 3, em: 16, rem: 16 };
1714
+ function Bn(t, e) {
1715
+ var n;
1716
+ for (const o of ["margin-left", "margin-inline-start", "padding-left"]) {
1717
+ const i = Nn.exec(((n = t.get(o)) == null ? void 0 : n.trim().toLowerCase()) ?? "");
1718
+ if (i && Number(i[1]) * _n[i[2]] >= ve) return 1;
1719
+ }
1720
+ return /(?:^|\s)ql-indent-[1-9]/.test(e ?? "") ? 1 : 0;
1721
+ }
1722
+ function jn(t) {
1723
+ switch (t == null ? void 0 : t.trim().toLowerCase()) {
1724
+ case "left":
1725
+ case "start":
1726
+ return "left";
1727
+ case "center":
1728
+ return "center";
1729
+ case "right":
1730
+ case "end":
1731
+ return "right";
1732
+ default:
1733
+ return;
1734
+ }
1735
+ }
1736
+ function dt(t, e) {
1737
+ const n = { ...t };
1738
+ for (const o of Se)
1739
+ e[o] === !0 ? n[o] = !0 : e[o] === !1 && delete n[o];
1740
+ for (const o of Ae) {
1741
+ const i = e[o];
1742
+ if (i === null) delete n[o];
1743
+ else if (i !== void 0) {
1744
+ const r = Rn[o](i);
1745
+ r ? n[o] = r : delete n[o];
1746
+ }
1747
+ }
1748
+ return n;
1749
+ }
1750
+ function Ee(t, e) {
1751
+ return t.bold === e.bold && t.italic === e.italic && t.underline === e.underline && t.color === e.color && t.fontFamily === e.fontFamily && t.fontSize === e.fontSize;
1752
+ }
1753
+ const Me = /* @__PURE__ */ new Set([
1754
+ "address",
1755
+ "article",
1756
+ "aside",
1757
+ "blockquote",
1758
+ "caption",
1759
+ "dd",
1760
+ "details",
1761
+ "dialog",
1762
+ "div",
1763
+ "dl",
1764
+ "dt",
1765
+ "fieldset",
1766
+ "figcaption",
1767
+ "figure",
1768
+ "footer",
1769
+ "form",
1770
+ "h1",
1771
+ "h2",
1772
+ "h3",
1773
+ "h4",
1774
+ "h5",
1775
+ "h6",
1776
+ "header",
1777
+ "hgroup",
1778
+ "hr",
1779
+ "li",
1780
+ "main",
1781
+ "nav",
1782
+ "ol",
1783
+ "p",
1784
+ "pre",
1785
+ "section",
1786
+ "summary",
1787
+ "table",
1788
+ "tbody",
1789
+ "td",
1790
+ "tfoot",
1791
+ "th",
1792
+ "thead",
1793
+ "tr",
1794
+ "ul"
1795
+ ]), qn = /* @__PURE__ */ new Set([
1796
+ "applet",
1797
+ "area",
1798
+ "audio",
1799
+ "base",
1800
+ "button",
1801
+ "canvas",
1802
+ "embed",
1803
+ "frame",
1804
+ "frameset",
1805
+ "head",
1806
+ "iframe",
1807
+ "img",
1808
+ "input",
1809
+ "link",
1810
+ "map",
1811
+ "math",
1812
+ "meta",
1813
+ "noembed",
1814
+ "noframes",
1815
+ "noscript",
1816
+ "object",
1817
+ "optgroup",
1818
+ "option",
1819
+ "param",
1820
+ "picture",
1821
+ "plaintext",
1822
+ "portal",
1823
+ "script",
1824
+ "select",
1825
+ "source",
1826
+ "style",
1827
+ "svg",
1828
+ "template",
1829
+ "textarea",
1830
+ "title",
1831
+ "track",
1832
+ "video",
1833
+ "xml",
1834
+ "xmp"
1835
+ ]);
1836
+ function De(t, e, n, o) {
1837
+ const i = n.foreign === !0, r = [], s = [];
1838
+ let l = null, a = null;
1839
+ const f = (b) => {
1840
+ if (l) {
1841
+ if (l.length > 0 || b !== void 0 && l.owner === b) {
1842
+ if (a && a.open === l && a.start === l.length - 1) {
1843
+ const k = l.runs[l.runs.length - 1];
1844
+ k.text = k.text.slice(0, -1), k.text || l.runs.pop(), l.length -= 1, a.kind = "placeholder", a.length = 0;
1845
+ }
1846
+ i && Hn(l), r.push(et(l.align, l.runs, l.quote, l.indent));
1847
+ }
1848
+ l = null, a = null;
1849
+ }
1850
+ }, u = (b, k) => {
1851
+ l && l.length > 0 && f(), l = { ...b, runs: [], owner: k, length: 0 }, o && s.push({ node: k, kind: "block", block: -1, start: 0, length: 0, open: l });
1852
+ }, c = (b, k, E, $, D) => {
1853
+ l || (l = { ...E, runs: [], owner: null, length: 0 });
1854
+ const T = l.length, C = l.runs[l.runs.length - 1];
1855
+ if (C && Ee(C.marks, k) ? C.text += b : l.runs.push({ text: b, marks: k }), l.length += b.length, o || D === "br") {
1856
+ const F = { node: $, kind: D, block: -1, start: T, length: b.length, open: l };
1857
+ o && s.push(F), D === "br" && (a = F);
1858
+ }
1859
+ }, d = (b, k, E, $ = !1) => {
1860
+ const D = e.kind(b);
1861
+ if (D === "text") {
1862
+ let L = e.text(b).replace(/\r\n?/g, `
1863
+ `);
1864
+ if (i && (L = L.replace(/[\t\n\f ]+/g, " "), (!l || l.length === 0 || Un(l)) && (L = L.replace(/^ /, ""))), L = zn(L.replace(Kn, " ")), !L || (!l || $ && l.length === 0) && /^\s+$/.test(L)) return;
1865
+ c(L, k, E, b, "text");
1866
+ return;
1867
+ }
1868
+ if (D !== "element") return;
1869
+ const T = e.tag(b);
1870
+ if (qn.has(T)) return;
1871
+ if (T === "br") {
1872
+ c(`
1873
+ `, k, E, b, "br");
1874
+ return;
1875
+ }
1876
+ const C = Pn(e.attr(b, "style")), F = Me.has(T), q = T === "blockquote", _ = F ? {
1877
+ align: jn(C.get("text-align") ?? e.attr(b, "align")) ?? E.align,
1878
+ quote: E.quote || q,
1879
+ indent: Math.max(E.indent, Bn(C, e.attr(b, "class")))
1880
+ } : E, H = Wn(T, C, e, b, k, i);
1881
+ F && u(_, b);
1882
+ const O = e.children(b);
1883
+ for (let L = 0; L < O.length; L++) d(O[L], H, _, F ? q : $);
1884
+ F && f(b);
1885
+ }, m = e.children(t);
1886
+ for (let b = 0; b < m.length; b++) d(m[b], {}, { align: "left", quote: !1, indent: 0 });
1887
+ f();
1888
+ const g = /* @__PURE__ */ new Map();
1889
+ r.forEach((b, k) => g.set(b.runs, k));
1890
+ const v = new Array(s.length);
1891
+ let x = Math.max(r.length - 1, 0);
1892
+ for (let b = s.length - 1; b >= 0; b--) {
1893
+ const k = s[b], $ = (k.open ? g.get(k.open.runs) : void 0) ?? x;
1894
+ x = $, v[b] = { node: k.node, kind: k.kind, block: $, start: k.kind === "block" ? 0 : k.start, length: k.length };
1895
+ }
1896
+ return { doc: Ut(r), items: v };
1897
+ }
1898
+ const Kn = new RegExp(" ", "g");
1899
+ function zn(t) {
1900
+ let e = "";
1901
+ for (const n of t) {
1902
+ const o = n.charCodeAt(0);
1903
+ (o === 9 || o === 10 || o >= 32 && o !== 127) && (e += n);
1904
+ }
1905
+ return e;
1906
+ }
1907
+ function Un(t) {
1908
+ const e = t.runs[t.runs.length - 1];
1909
+ return !!e && e.text.endsWith(`
1910
+ `);
1911
+ }
1912
+ function Hn(t) {
1913
+ const e = t.runs[t.runs.length - 1];
1914
+ e && (e.text = e.text.replace(/ +$/, ""));
1915
+ }
1916
+ function Wn(t, e, n, o, i, r) {
1917
+ var u, c;
1918
+ const s = {};
1919
+ (t === "strong" || t === "b") && (s.bold = !0), (t === "em" || t === "i") && (s.italic = !0), (t === "u" || t === "ins") && (s.underline = !0);
1920
+ const l = e.get("font-weight");
1921
+ if (l) {
1922
+ const d = l.toLowerCase();
1923
+ d === "bold" || d === "bolder" || Number(d) >= 600 ? s.bold = !0 : (d === "normal" || d === "lighter" || Number(d) <= 500) && (s.bold = !1);
1924
+ }
1925
+ const a = (u = e.get("font-style")) == null ? void 0 : u.toLowerCase();
1926
+ a === "italic" || a === "oblique" ? s.italic = !0 : a === "normal" && (s.italic = !1);
1927
+ const f = (c = e.get("text-decoration-line") ?? e.get("text-decoration")) == null ? void 0 : c.toLowerCase();
1928
+ if (f != null && f.includes("underline") ? s.underline = !0 : f === "none" && (s.underline = !1), !r) {
1929
+ const d = e.get("color") ?? (t === "font" ? n.attr(o, "color") : null), m = e.get("font-family") ?? (t === "font" ? n.attr(o, "face") : null), g = e.get("font-size");
1930
+ d && (s.color = d), m && (s.fontFamily = m), g && (s.fontSize = g);
1931
+ }
1932
+ return Object.keys(s).length ? dt(i, s) : i;
1933
+ }
1934
+ function Ut(t) {
1935
+ return t.map((e) => {
1936
+ const n = [];
1937
+ for (const o of e.runs) {
1938
+ if (!o.text) continue;
1939
+ const i = n[n.length - 1];
1940
+ i && Ee(i.marks, o.marks) ? i.text += o.text : n.push({ text: o.text, marks: o.marks });
1941
+ }
1942
+ return mt(e, n);
1943
+ });
1944
+ }
1945
+ const Yn = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]), Gn = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "iframe", "noembed", "noframes", "noscript", "plaintext"]), Vn = {
1946
+ amp: "&",
1947
+ lt: "<",
1948
+ gt: ">",
1949
+ quot: '"',
1950
+ apos: "'",
1951
+ nbsp: " ",
1952
+ copy: "©",
1953
+ reg: "®",
1954
+ trade: "™",
1955
+ hellip: "…",
1956
+ mdash: "—",
1957
+ ndash: "–",
1958
+ lsquo: "‘",
1959
+ rsquo: "’",
1960
+ ldquo: "“",
1961
+ rdquo: "”",
1962
+ bull: "•",
1963
+ middot: "·"
1964
+ };
1965
+ function ce(t) {
1966
+ return t.includes("&") ? t.replace(/&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);?/gi, (e, n) => {
1967
+ if (n[0] === "#") {
1968
+ const o = n[1] === "x" || n[1] === "X" ? parseInt(n.slice(2), 16) : parseInt(n.slice(1), 10);
1969
+ return !o || o > 1114111 || o >= 55296 && o <= 57343 ? "�" : String.fromCodePoint(o);
1970
+ }
1971
+ return Vn[n.toLowerCase()] ?? e;
1972
+ }) : t;
1973
+ }
1974
+ const Dt = /<([a-zA-Z][^\s/>]*)/y, wt = /[\s/]*([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/y, Tt = /[\s/]*>/y, Lt = /<\/([a-zA-Z][^\s/>]*)[^>]*>/y;
1975
+ function Xn(t) {
1976
+ const e = { tag: "#root", attrs: {}, children: [] }, n = [e], o = () => n[n.length - 1], i = (l) => {
1977
+ l && o().children.push(ce(l));
1978
+ }, r = t.length;
1979
+ let s = 0;
1980
+ for (; s < r; ) {
1981
+ const l = t.indexOf("<", s);
1982
+ if (l < 0) {
1983
+ i(t.slice(s));
1984
+ break;
1985
+ }
1986
+ if (i(t.slice(s, l)), s = l, t.startsWith("<!--", s)) {
1987
+ const c = t.indexOf("-->", s + 4);
1988
+ s = c < 0 ? r : c + 3;
1989
+ continue;
1990
+ }
1991
+ const a = t[s + 1] ?? "";
1992
+ if (a === "!" || a === "?") {
1993
+ const c = t.indexOf(">", s);
1994
+ s = c < 0 ? r : c + 1;
1995
+ continue;
1996
+ }
1997
+ if (a === "/") {
1998
+ Lt.lastIndex = s;
1999
+ const c = Lt.exec(t);
2000
+ if (!c) {
2001
+ const m = t.indexOf(">", s);
2002
+ s = m < 0 ? r : m + 1;
2003
+ continue;
2004
+ }
2005
+ s = Lt.lastIndex;
2006
+ const d = c[1].toLowerCase();
2007
+ if (d === "br") {
2008
+ o().children.push({ tag: "br", attrs: {}, children: [] });
2009
+ continue;
2010
+ }
2011
+ for (let m = n.length - 1; m > 0; m--)
2012
+ if (n[m].tag === d) {
2013
+ n.length = m;
2014
+ break;
2015
+ }
2016
+ continue;
2017
+ }
2018
+ Dt.lastIndex = s;
2019
+ const f = Dt.exec(t);
2020
+ if (!f) {
2021
+ i("<"), s += 1;
2022
+ continue;
2023
+ }
2024
+ s = Dt.lastIndex;
2025
+ const u = { tag: f[1].toLowerCase(), attrs: {}, children: [] };
2026
+ for (; ; ) {
2027
+ if (Tt.lastIndex = s, Tt.test(t)) {
2028
+ s = Tt.lastIndex;
2029
+ break;
2030
+ }
2031
+ wt.lastIndex = s;
2032
+ const c = wt.exec(t);
2033
+ if (!c || wt.lastIndex === s) {
2034
+ s = r;
2035
+ break;
2036
+ }
2037
+ s = wt.lastIndex;
2038
+ const d = c[1].toLowerCase();
2039
+ d in u.attrs || (u.attrs[d] = ce(c[2] ?? c[3] ?? c[4] ?? ""));
2040
+ }
2041
+ if (Gn.has(u.tag)) {
2042
+ const c = t.toLowerCase().indexOf(`</${u.tag}`, s);
2043
+ s = c < 0 ? r : c, o().children.push(u);
2044
+ continue;
2045
+ }
2046
+ if (Me.has(u.tag)) {
2047
+ for (let c = n.length - 1; c > 0; c--)
2048
+ if (n[c].tag === "p") {
2049
+ n.length = c;
2050
+ break;
2051
+ }
2052
+ }
2053
+ o().children.push(u), Yn.has(u.tag) || n.push(u);
2054
+ }
2055
+ return e;
2056
+ }
2057
+ const Zn = {
2058
+ kind: (t) => typeof t == "string" ? "text" : "element",
2059
+ text: (t) => typeof t == "string" ? t : "",
2060
+ tag: (t) => typeof t == "string" ? "" : t.tag,
2061
+ attr: (t, e) => typeof t == "string" ? null : t.attrs[e] ?? null,
2062
+ children: (t) => typeof t == "string" ? [] : t.children
2063
+ }, Qn = {
2064
+ kind: (t) => t.nodeType === 3 ? "text" : t.nodeType === 1 ? "element" : "other",
2065
+ text: (t) => t.nodeValue ?? "",
2066
+ tag: (t) => t.localName,
2067
+ attr: (t, e) => t.getAttribute(e),
2068
+ children: (t) => t.childNodes
2069
+ };
2070
+ function J(t, e = {}) {
2071
+ return De(Xn(t), Zn, e, !1).doc;
2072
+ }
2073
+ function $t(t) {
2074
+ return De(t, Qn, {}, !0);
2075
+ }
2076
+ const Te = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Jn = (t) => Te(t).replace(/"/g, "&quot;");
2077
+ function to(t, e) {
2078
+ const n = [];
2079
+ t.text.split(`
2080
+ `).forEach((r, s) => {
2081
+ s > 0 && n.push(e.element("br", void 0, [])), r && n.push(e.text(r));
2082
+ });
2083
+ const { marks: o } = t, i = [
2084
+ o.color && `color: ${o.color}`,
2085
+ o.fontFamily && `font-family: ${o.fontFamily}`,
2086
+ o.fontSize && `font-size: ${o.fontSize}`
2087
+ ].filter(Boolean).join("; ");
2088
+ return i ? [e.element("span", i, n)] : n;
2089
+ }
2090
+ const eo = [
2091
+ ["bold", "strong"],
2092
+ ["italic", "em"],
2093
+ ["underline", "u"]
2094
+ ];
2095
+ function Le(t, e, n = 0) {
2096
+ const o = eo[n];
2097
+ if (!o) return t.flatMap((l) => to(l, e));
2098
+ const [i, r] = o, s = [];
2099
+ for (let l = 0; l < t.length; ) {
2100
+ const a = !!t[l].marks[i];
2101
+ let f = l;
2102
+ for (; f < t.length && !!t[f].marks[i] === a; ) f++;
2103
+ const u = Le(t.slice(l, f), e, n + 1);
2104
+ a ? s.push(e.element(r, void 0, u)) : s.push(...u), l = f;
2105
+ }
2106
+ return s;
2107
+ }
2108
+ function ae(t, e) {
2109
+ const n = $e(t), o = Le(t.runs, e);
2110
+ (n === "" || n.endsWith(`
2111
+ `)) && o.push(e.element("br", void 0, []));
2112
+ const i = [
2113
+ t.align !== "left" && `text-align: ${t.align}`,
2114
+ t.indent && `margin-left: ${t.indent * ve}px`
2115
+ ].filter(Boolean).join("; ");
2116
+ return e.element("p", i || void 0, o);
2117
+ }
2118
+ function no(t, e) {
2119
+ const n = t.length ? t : [Y()], o = [];
2120
+ for (let i = 0; i < n.length; ) {
2121
+ if (!n[i].quote) {
2122
+ o.push(ae(n[i++], e));
2123
+ continue;
2124
+ }
2125
+ const r = [];
2126
+ for (; i < n.length && n[i].quote; ) r.push(ae(n[i++], e));
2127
+ o.push(e.element("blockquote", void 0, r));
2128
+ }
2129
+ return o;
2130
+ }
2131
+ const oo = {
2132
+ element: (t, e, n) => t === "br" ? "<br>" : `<${t}${e ? ` style="${Jn(e)}"` : ""}>${n.join("")}</${t}>`,
2133
+ text: Te
2134
+ };
2135
+ function ct(t) {
2136
+ return no(t, oo).join("");
2137
+ }
2138
+ function at(t) {
2139
+ return io(t) ? "" : ct(t);
2140
+ }
2141
+ function io(t) {
2142
+ return t.length === 0 || t.length === 1 && t[0].runs.length === 0;
2143
+ }
2144
+ function Bi(t, e = {}) {
2145
+ return at(J(t, e));
2146
+ }
2147
+ function ji(t) {
2148
+ return _t(J(t));
2149
+ }
2150
+ function _t(t) {
2151
+ return t.map($e).join(`
2152
+ `);
2153
+ }
2154
+ const Y = (t = "left") => ({ align: t, runs: [] });
2155
+ function $e(t) {
2156
+ return t.runs.map((e) => e.text).join("");
2157
+ }
2158
+ function pt(t) {
2159
+ return t ? t.runs.reduce((e, n) => e + n.text.length, 0) : 0;
2160
+ }
2161
+ function Ce(t, e) {
2162
+ let n = 0;
2163
+ for (let o = 0; o < e.block && o < t.length; o++) n += pt(t[o]) + 1;
2164
+ return n + e.offset;
2165
+ }
2166
+ function z(t, e) {
2167
+ const n = t.length ? t : [Y()];
2168
+ let o = Math.max(0, e);
2169
+ for (let i = 0; i < n.length; i++) {
2170
+ const r = pt(n[i]);
2171
+ if (o <= r || i === n.length - 1) return { block: i, offset: Math.min(o, r) };
2172
+ o -= r + 1;
2173
+ }
2174
+ return { block: 0, offset: 0 };
2175
+ }
2176
+ function Q(t) {
2177
+ return Math.max(0, t.reduce((e, n) => e + pt(n) + 1, 0) - 1);
2178
+ }
2179
+ function tt(t, e) {
2180
+ const n = [], o = [];
2181
+ let i = 0;
2182
+ for (const r of t) {
2183
+ const s = i + r.text.length;
2184
+ s <= e ? n.push(r) : i >= e ? o.push(r) : (n.push({ text: r.text.slice(0, e - i), marks: r.marks }), o.push({ text: r.text.slice(e - i), marks: r.marks })), i = s;
2185
+ }
2186
+ return [n, o];
2187
+ }
2188
+ const nt = (t, e, n) => {
2189
+ const [o, i] = e <= n ? [e, n] : [n, e];
2190
+ return [z(t, o), z(t, i)];
2191
+ };
2192
+ function Ie(t, e, n) {
2193
+ const [o, i] = nt(t, e, n), r = [];
2194
+ for (let s = o.block; s <= i.block; s++) {
2195
+ const l = t[s] ?? Y();
2196
+ let a = l.runs;
2197
+ s === i.block && (a = tt(a, i.offset)[0]), s === o.block && (a = tt(a, o.offset)[1]), r.push(mt(l, a));
2198
+ }
2199
+ return r;
2200
+ }
2201
+ function ue(t, e, n, o) {
2202
+ const i = t.length ? t : [Y()], [r, s] = nt(i, e, n), l = i[r.block], a = i[s.block], f = tt(l.runs, r.offset)[0], u = tt(a.runs, s.offset)[1], c = o.length ? o : [Y()], d = c.map((x, b) => {
2203
+ const k = [...b === 0 ? f : [], ...x.runs];
2204
+ if (b === 0) return mt(l, k);
2205
+ const E = b === c.length - 1;
2206
+ return E && u.length > 0 ? mt(a, k) : et(
2207
+ E ? a.align : x.align,
2208
+ k,
2209
+ x.quote || l.quote && a.quote,
2210
+ Math.max(x.indent ?? 0, Math.min(l.indent ?? 0, a.indent ?? 0))
2211
+ );
2212
+ }), m = d[d.length - 1], g = { block: r.block + d.length - 1, offset: pt(m) };
2213
+ m.runs = [...m.runs, ...u];
2214
+ const v = Ut([...i.slice(0, r.block), ...d, ...i.slice(s.block + 1)]);
2215
+ return { doc: v, caret: Ce(v, g) };
2216
+ }
2217
+ function fe(t, e, n, o) {
2218
+ const [i, r] = nt(t, e, n);
2219
+ return Ut(
2220
+ t.map((s, l) => {
2221
+ if (l < i.block || l > r.block) return s;
2222
+ const a = l === i.block ? i.offset : 0, f = l === r.block ? r.offset : pt(s), [u, c] = tt(s.runs, a), [d, m] = tt(c, f - a);
2223
+ return mt(s, [...u, ...d.map((g) => ({ text: g.text, marks: o(g.marks) })), ...m]);
2224
+ })
2225
+ );
2226
+ }
2227
+ function ro(t, e, n, o) {
2228
+ const i = t.length ? t : [Y()], [r, s] = nt(i, e, n);
2229
+ return i.map(
2230
+ (l, a) => a < r.block || a > s.block ? l : et(o, l.runs, l.quote, l.indent)
2231
+ );
2232
+ }
2233
+ function so(t, e, n, o) {
2234
+ const i = t.length ? t : [Y()], [r, s] = nt(i, e, n);
2235
+ return i.map(
2236
+ (l, a) => a < r.block || a > s.block ? l : et(l.align, l.runs, o, l.indent)
2237
+ );
2238
+ }
2239
+ function lo(t, e, n, o) {
2240
+ const i = t.length ? t : [Y()], [r, s] = nt(i, e, n);
2241
+ return i.map((l, a) => {
2242
+ if (a < r.block || a > s.block) return l;
2243
+ const f = typeof o == "number" ? o : o(l.indent ?? 0);
2244
+ return et(l.align, l.runs, l.quote, f);
2245
+ });
2246
+ }
2247
+ function Bt(t, e) {
2248
+ const n = z(t, e), o = t[n.block];
2249
+ if (!o || o.runs.length === 0) return {};
2250
+ if (n.offset === 0) return o.runs[0].marks;
2251
+ let i = 0;
2252
+ for (const r of o.runs)
2253
+ if (i += r.text.length, i >= n.offset) return r.marks;
2254
+ return o.runs[o.runs.length - 1].marks;
2255
+ }
2256
+ function jt(t, e, n, o = null) {
2257
+ var v;
2258
+ const [i, r] = e <= n ? [e, n] : [n, e], s = z(t, i), l = z(t, r), a = ((v = t[s.block]) == null ? void 0 : v.align) ?? "left", f = t.slice(s.block, l.block + 1), u = f.length > 0 && f.every((x) => x.quote === !0), c = f.length ? Math.min(...f.map((x) => x.indent ?? 0)) : 0;
2259
+ let d = null;
2260
+ const m = /* @__PURE__ */ new Set();
2261
+ if (i !== r) {
2262
+ for (const x of Ie(t, i, r))
2263
+ for (const b of x.runs)
2264
+ if (b.text.replace(/\n/g, "")) {
2265
+ if (!d) {
2266
+ d = { ...b.marks };
2267
+ continue;
2268
+ }
2269
+ for (const k of Se) b.marks[k] || delete d[k];
2270
+ for (const k of Ae) d[k] !== b.marks[k] && m.add(k);
2271
+ }
2272
+ for (const x of m) d && delete d[x];
2273
+ }
2274
+ const g = d ?? dt(Bt(t, i), i === r && o ? o : {});
2275
+ return {
2276
+ bold: !!g.bold,
2277
+ italic: !!g.italic,
2278
+ underline: !!g.underline,
2279
+ align: a,
2280
+ quote: u,
2281
+ indent: c,
2282
+ color: g.color,
2283
+ fontFamily: g.fontFamily,
2284
+ fontSize: g.fontSize
2285
+ };
2286
+ }
2287
+ function qi(t, e = null) {
2288
+ const n = J(t), o = Q(n);
2289
+ return jt(n, o, o, e);
2290
+ }
2291
+ const de = "data-orvain-rich-text", co = 100, ao = 1e3, he = /* @__PURE__ */ new Set([
2292
+ "deleteContentBackward",
2293
+ "deleteWordBackward",
2294
+ "deleteSoftLineBackward",
2295
+ "deleteHardLineBackward"
2296
+ ]), me = /* @__PURE__ */ new Set([
2297
+ "deleteContentForward",
2298
+ "deleteWordForward",
2299
+ "deleteSoftLineForward",
2300
+ "deleteHardLineForward"
2301
+ ]), uo = /* @__PURE__ */ new Set([
2302
+ "insertOrderedList",
2303
+ "insertUnorderedList",
2304
+ "insertHorizontalRule",
2305
+ "insertLink",
2306
+ "insertFromPaste",
2307
+ "insertFromPasteAsQuotation",
2308
+ "insertFromDrop",
2309
+ "insertFromYank"
2310
+ ]), Ct = {
2311
+ formatBold: () => ["bold"],
2312
+ formatItalic: () => ["italic"],
2313
+ formatUnderline: () => ["underline"],
2314
+ formatJustifyLeft: () => ["align", "left"],
2315
+ formatJustifyCenter: () => ["align", "center"],
2316
+ formatJustifyRight: () => ["align", "right"]
2317
+ };
2318
+ class Ki {
2319
+ constructor(e, n = {}) {
2320
+ this.root = e, this.options = n, this.items = [], this.lastSelection = null, this.pendingAt = null, this.history = [], this.historyIndex = 0, this.lastEdit = null, this.composing = !1, this.compositionStart = null, this.dragRange = null, this.selectionStale = !1, this.formatKey = "", this.cleanup = [];
2321
+ const o = $t(e);
2322
+ this.doc = o.doc, this.items = o.items, e.innerHTML !== ct(this.doc) && this.render(), this.value = at(this.doc), this.pending = n.defaultMarks && Object.keys(n.defaultMarks).length ? { ...n.defaultMarks } : null, this.history = [{ html: this.value, selection: this.endSelection() }], this.formatKey = JSON.stringify(this.getFormat());
2323
+ const i = e.ownerDocument;
2324
+ this.listen(e, "beforeinput", (r) => this.onBeforeInput(r)), this.listen(e, "input", (r) => this.onInput(r)), this.listen(e, "keydown", (r) => this.onKeyDown(r)), this.listen(e, "paste", (r) => this.onPaste(r)), this.listen(e, "copy", (r) => this.onCopy(r, !1)), this.listen(e, "cut", (r) => this.onCopy(r, !0)), this.listen(e, "dragstart", (r) => this.onDragStart(r)), this.listen(e, "dragend", () => this.dragRange = null), this.listen(e, "drop", (r) => this.onDrop(r)), this.listen(e, "compositionstart", () => this.onCompositionStart()), this.listen(e, "compositionend", () => this.onCompositionEnd()), this.listen(i, "selectionchange", () => this.onSelectionChange());
2325
+ for (const r of ["keyup", "mouseup"]) this.listen(e, r, () => this.onSelectionChange());
2326
+ this.listen(e, "focus", () => this.onFocus());
2327
+ }
2328
+ destroy() {
2329
+ for (const e of this.cleanup.splice(0)) e();
2330
+ }
2331
+ /* ── Public API ─────────────────────────────────────────────── */
2332
+ /** The sanitized HTML value (`''` when empty). */
2333
+ getValue() {
2334
+ return this.value;
2335
+ }
2336
+ getText() {
2337
+ return _t(this.doc);
2338
+ }
2339
+ getFormat() {
2340
+ const e = this.currentSelection();
2341
+ if (!e) {
2342
+ const o = Q(this.doc);
2343
+ return jt(this.doc, o, o, this.pending);
2344
+ }
2345
+ const n = this.pendingApplies(e) ? this.pending : null;
2346
+ return jt(this.doc, e.anchor, e.focus, n);
2347
+ }
2348
+ /** Replaces the content from outside (a controlled value). Does not fire `onChange`. */
2349
+ setValue(e) {
2350
+ if (e === this.value) return;
2351
+ const n = J(e), o = at(n);
2352
+ if (o === this.value) return;
2353
+ const i = this.currentSelection();
2354
+ this.doc = n, this.value = o;
2355
+ const r = Q(this.doc), s = i ? { anchor: Math.min(i.anchor, r), focus: Math.min(i.focus, r) } : null, l = this.isFocused();
2356
+ this.render(l ? s : null), l || (this.selectionStale = !0), this.lastSelection = s, this.history = [{ html: this.value, selection: s ?? this.endSelection() }], this.historyIndex = 0, this.lastEdit = null, this.emitFormat();
2357
+ }
2358
+ /** Bold / italic / underline: toggles the selection, or the typing format at a caret. */
2359
+ toggleMark(e, n = {}) {
2360
+ const o = this.getFormat()[e];
2361
+ this.applyPatch({ [e]: !o }, n);
2362
+ }
2363
+ /** Colour, font family or size for the selection (or the typing format); `null` clears it. */
2364
+ applyStyle(e, n, o = {}) {
2365
+ this.applyPatch({ [e]: n }, o);
2366
+ }
2367
+ /** Aligns every paragraph the selection touches (the caret's paragraph when collapsed). */
2368
+ setAlign(e, n = {}) {
2369
+ const o = this.currentSelection() ?? this.endSelection();
2370
+ this.doc = ro(this.doc, o.anchor, o.focus, e), this.afterModelEdit(o, "other", n.focus === !0);
2371
+ }
2372
+ /** Quotes (or unquotes) every paragraph the selection touches. */
2373
+ setQuote(e, n = {}) {
2374
+ const o = this.currentSelection() ?? this.endSelection();
2375
+ this.doc = so(this.doc, o.anchor, o.focus, e), this.afterModelEdit(o, "other", n.focus === !0);
2376
+ }
2377
+ /** Sets the indent level (0 = none) of every paragraph the selection touches. */
2378
+ setIndent(e, n = {}) {
2379
+ const o = this.currentSelection() ?? this.endSelection();
2380
+ this.doc = lo(this.doc, o.anchor, o.focus, e), this.afterModelEdit(o, "other", n.focus === !0);
2381
+ }
2382
+ focus() {
2383
+ this.root.focus({ preventScroll: !0 });
2384
+ const e = this.lastSelection ?? this.endSelection();
2385
+ this.restoreSelection(e);
2386
+ }
2387
+ undo() {
2388
+ this.stepHistory(-1);
2389
+ }
2390
+ redo() {
2391
+ this.stepHistory(1);
2392
+ }
2393
+ /* ── Commands on the model ──────────────────────────────────── */
2394
+ applyPatch(e, n) {
2395
+ const o = this.currentSelection(), i = o ?? this.endSelection();
2396
+ if (i.anchor === i.focus) {
2397
+ this.pending = { ...this.pendingApplies(i) ? this.pending : null, ...e }, this.pendingAt = o ? i.anchor : null, n.focus && this.focusAt(i), this.emitFormat();
2398
+ return;
2399
+ }
2400
+ this.doc = fe(this.doc, i.anchor, i.focus, (r) => dt(r, e)), this.afterModelEdit(i, "other", n.focus === !0);
2401
+ }
2402
+ replace(e, n, o, i = "other") {
2403
+ const { doc: r, caret: s } = ue(this.doc, e, n, o);
2404
+ this.doc = r, this.pending = null, this.afterModelEdit({ anchor: s, focus: s }, i, !1);
2405
+ }
2406
+ insertText(e, n, o) {
2407
+ const i = Math.min(e.anchor, e.focus), r = Math.max(e.anchor, e.focus);
2408
+ let s = Bt(this.doc, i === r ? i : i + 1);
2409
+ i === r && this.pending && this.pendingApplies(e) && (s = dt(s, this.pending)), this.replace(i, r, [{ align: "left", runs: [{ text: n, marks: s }] }], o);
2410
+ }
2411
+ afterModelEdit(e, n, o) {
2412
+ const i = this.isFocused();
2413
+ this.render(i || o ? e : null), o && !i && this.focusAt(e), !i && !o && (this.selectionStale = !0), this.lastSelection = e, this.commit(n, e);
2414
+ }
2415
+ /** Publishes a changed value and records it in the history. */
2416
+ commit(e, n) {
2417
+ var i, r;
2418
+ const o = at(this.doc);
2419
+ o !== this.value && (this.value = o, this.record(e, n ?? this.lastSelection ?? this.endSelection()), (r = (i = this.options).onChange) == null || r.call(i, o, this.getText())), this.emitFormat();
2420
+ }
2421
+ record(e, n) {
2422
+ var s;
2423
+ const o = Date.now(), i = { html: this.value, selection: n }, r = e === "typing" && ((s = this.lastEdit) == null ? void 0 : s.kind) === "typing" && o - this.lastEdit.at < ao;
2424
+ this.history.length = this.historyIndex + 1, r && this.historyIndex > 0 ? this.history[this.historyIndex] = i : (this.history.push(i), this.history.length > co && this.history.shift(), this.historyIndex = this.history.length - 1), this.lastEdit = { kind: e, at: o };
2425
+ }
2426
+ stepHistory(e) {
2427
+ var r, s;
2428
+ const n = this.historyIndex + e, o = this.history[n];
2429
+ if (!o) return;
2430
+ this.historyIndex = n, this.lastEdit = null, this.doc = J(o.html), this.value = at(this.doc), this.pending = null;
2431
+ const i = this.isFocused();
2432
+ this.render(i ? o.selection : null), i || (this.selectionStale = !0), this.lastSelection = o.selection, (s = (r = this.options).onChange) == null || s.call(r, this.value, this.getText()), this.emitFormat();
2433
+ }
2434
+ emitFormat() {
2435
+ var o, i;
2436
+ const e = this.getFormat(), n = JSON.stringify(e);
2437
+ n !== this.formatKey && (this.formatKey = n, (i = (o = this.options).onFormatChange) == null || i.call(o, e));
2438
+ }
2439
+ /* ── DOM ↔ model ────────────────────────────────────────────── */
2440
+ render(e = null) {
2441
+ this.root.innerHTML = ct(this.doc), this.items = $t(this.root).items, e && this.restoreSelection(e);
2442
+ }
2443
+ /** Re-reads the DOM after native editing; rewrites it if the browser left non-canonical markup. */
2444
+ syncFromDom(e) {
2445
+ const n = $t(this.root);
2446
+ this.doc = n.doc, this.items = n.items;
2447
+ const o = this.domSelection();
2448
+ this.root.innerHTML !== ct(this.doc) && this.render(o), o && (this.lastSelection = o), this.commit(e, o);
2449
+ }
2450
+ isFocused() {
2451
+ const e = this.root.ownerDocument.activeElement;
2452
+ return !!e && (e === this.root || this.root.contains(e));
2453
+ }
2454
+ endSelection() {
2455
+ const e = Q(this.doc);
2456
+ return { anchor: e, focus: e };
2457
+ }
2458
+ /**
2459
+ * The live selection while the editor has focus, else the last one it had
2460
+ * (focus on a toolbar button leaves the document selection behind).
2461
+ */
2462
+ currentSelection() {
2463
+ return (this.isFocused() ? this.domSelection() : null) ?? this.lastSelection;
2464
+ }
2465
+ domSelection() {
2466
+ const e = this.root.ownerDocument.getSelection();
2467
+ return !e || e.rangeCount === 0 || !e.anchorNode || !e.focusNode || !this.root.contains(e.anchorNode) || !this.root.contains(e.focusNode) ? null : {
2468
+ anchor: this.globalAt(e.anchorNode, e.anchorOffset),
2469
+ focus: this.globalAt(e.focusNode, e.focusOffset)
2470
+ };
2471
+ }
2472
+ globalAt(e, n) {
2473
+ const o = this.posAt(e, n);
2474
+ return Ce(this.doc, o);
2475
+ }
2476
+ posAt(e, n) {
2477
+ if (e.nodeType === 3) {
2478
+ const i = this.items.find((s) => s.node === e);
2479
+ if (i) return { block: i.block, offset: i.start + Math.min(n, i.length) };
2480
+ const r = e.parentNode;
2481
+ return r ? this.posAt(r, Array.prototype.indexOf.call(r.childNodes, e) + (n > 0 ? 1 : 0)) : { block: 0, offset: 0 };
2482
+ }
2483
+ const o = e.childNodes[n];
2484
+ if (o) {
2485
+ for (const i of this.items)
2486
+ if (i.node === o || o.contains(i.node) || o.compareDocumentPosition(i.node) & Node.DOCUMENT_POSITION_FOLLOWING)
2487
+ return { block: i.block, offset: i.start };
2488
+ return z(this.doc, Q(this.doc));
2489
+ }
2490
+ for (let i = this.items.length - 1; i >= 0; i--) {
2491
+ const r = this.items[i];
2492
+ if (r.node === e || e.contains(r.node) || r.node.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING)
2493
+ return { block: r.block, offset: r.start + r.length };
2494
+ }
2495
+ return { block: 0, offset: 0 };
2496
+ }
2497
+ /** A DOM point for a model position; at a format boundary it stays with the text before it. */
2498
+ domPoint(e) {
2499
+ const n = z(this.doc, e), o = this.items.filter((c) => c.block === n.block), i = o.filter((c) => c.kind === "text"), r = i.find((c) => c.start < n.offset && n.offset <= c.start + c.length);
2500
+ if (r) return [r.node, n.offset - r.start];
2501
+ const s = i.find((c) => c.start === n.offset);
2502
+ if (s) return [s.node, 0];
2503
+ const l = o.find((c) => (c.kind === "br" || c.kind === "placeholder") && c.start === n.offset), a = o.find((c) => c.kind === "br" && c.start + 1 === n.offset), f = l ?? a;
2504
+ if (f != null && f.node.parentNode) {
2505
+ const c = f.node.parentNode, d = Array.prototype.indexOf.call(c.childNodes, f.node);
2506
+ return [c, l ? d : d + 1];
2507
+ }
2508
+ const u = o.find((c) => c.kind === "block");
2509
+ return u ? [u.node, 0] : [this.root, 0];
2510
+ }
2511
+ restoreSelection(e) {
2512
+ const n = this.root.ownerDocument.getSelection();
2513
+ if (!n) return;
2514
+ const [o, i] = this.domPoint(e.anchor), [r, s] = this.domPoint(e.focus);
2515
+ n.setBaseAndExtent(o, i, r, s);
2516
+ }
2517
+ focusAt(e) {
2518
+ this.root.focus({ preventScroll: !0 }), this.restoreSelection(e);
2519
+ }
2520
+ pendingApplies(e) {
2521
+ return !!this.pending && e.anchor === e.focus && (this.pendingAt === null || this.pendingAt === e.anchor);
2522
+ }
2523
+ /* ── Events ─────────────────────────────────────────────────── */
2524
+ listen(e, n, o) {
2525
+ e.addEventListener(n, o), this.cleanup.push(() => e.removeEventListener(n, o));
2526
+ }
2527
+ onFocus() {
2528
+ this.selectionStale && this.lastSelection && this.restoreSelection(this.lastSelection), this.selectionStale = !1, this.onSelectionChange();
2529
+ }
2530
+ onSelectionChange() {
2531
+ if (!this.isFocused()) return;
2532
+ const e = this.domSelection();
2533
+ e && (this.lastSelection = e, this.pending && (e.anchor !== e.focus ? this.pending = null : this.pendingAt === null ? this.pendingAt = e.anchor : this.pendingAt !== e.anchor && (this.pending = null)), this.emitFormat());
2534
+ }
2535
+ onKeyDown(e) {
2536
+ var i, r;
2537
+ if (!(e.ctrlKey || e.metaKey) || e.altKey || e.isComposing) return;
2538
+ const n = e.key.toLowerCase(), o = { b: "bold", i: "italic", u: "underline" }[n];
2539
+ o && !e.shiftKey ? (e.preventDefault(), this.toggleMark(o)) : n === "z" ? (e.preventDefault(), e.shiftKey ? this.redo() : this.undo()) : n === "y" && e.ctrlKey && !e.metaKey ? (e.preventDefault(), this.redo()) : (r = (i = this.options).blockShortcuts) != null && r.call(i) && (!e.shiftKey && (n === "]" || e.code === "BracketRight") ? (e.preventDefault(), this.setIndent((s) => s + 1)) : !e.shiftKey && (n === "[" || e.code === "BracketLeft") ? (e.preventDefault(), this.setIndent((s) => s - 1)) : e.shiftKey && (n === "9" || n === "(" || e.code === "Digit9") && (e.preventDefault(), this.setQuote(!this.getFormat().quote)));
2540
+ }
2541
+ onBeforeInput(e) {
2542
+ var f, u;
2543
+ const n = e.inputType;
2544
+ if (n === "historyUndo" || n === "historyRedo") {
2545
+ e.preventDefault(), n === "historyUndo" ? this.undo() : this.redo();
2546
+ return;
2547
+ }
2548
+ if (n.startsWith("format")) {
2549
+ e.preventDefault();
2550
+ const c = (f = Ct[n]) == null ? void 0 : f.call(Ct);
2551
+ (c == null ? void 0 : c[0]) === "align" ? this.setAlign(c[1]) : c && this.toggleMark(c[0]);
2552
+ return;
2553
+ }
2554
+ if (uo.has(n)) {
2555
+ e.preventDefault();
2556
+ return;
2557
+ }
2558
+ if (this.composing || n === "insertCompositionText") return;
2559
+ const o = this.domSelection();
2560
+ if (!o) return;
2561
+ const i = Math.min(o.anchor, o.focus), r = Math.max(o.anchor, o.focus), s = z(this.doc, i), l = z(this.doc, r), a = s.block !== l.block;
2562
+ if (n === "insertParagraph")
2563
+ e.preventDefault(), this.replace(i, r, [{ align: "left", runs: [] }, { align: "left", runs: [] }]);
2564
+ else if (n === "insertLineBreak")
2565
+ e.preventDefault(), this.insertText(o, `
2566
+ `, "other");
2567
+ else if (n === "insertText" || n === "insertReplacementText") {
2568
+ const c = e.data ?? ((u = e.dataTransfer) == null ? void 0 : u.getData("text/plain")) ?? "";
2569
+ (a || i === r && this.pendingApplies(o)) && (e.preventDefault(), c && this.insertText(o, c, "typing"));
2570
+ } else if (he.has(n) || me.has(n) || n.startsWith("delete")) {
2571
+ if (i !== r) {
2572
+ a && (e.preventDefault(), this.replace(i, r, []));
2573
+ return;
2574
+ }
2575
+ const c = this.doc[s.block] ? this.doc[s.block].runs.reduce((d, m) => d + m.text.length, 0) : 0;
2576
+ if (he.has(n) && s.offset === 0) {
2577
+ e.preventDefault();
2578
+ const d = this.doc[s.block];
2579
+ d != null && d.indent ? this.setIndent((m) => m - 1) : d != null && d.quote ? this.setQuote(!1) : s.block > 0 && this.replace(i - 1, i, []);
2580
+ } else me.has(n) && s.offset === c && (e.preventDefault(), s.block < this.doc.length - 1 && this.replace(i, i + 1, []));
2581
+ }
2582
+ }
2583
+ onInput(e) {
2584
+ var n, o;
2585
+ this.composing || e.isComposing || this.syncFromDom((n = e.inputType) != null && n.startsWith("insert") || (o = e.inputType) != null && o.startsWith("delete") ? "typing" : "other");
2586
+ }
2587
+ onCompositionStart() {
2588
+ this.composing = !0;
2589
+ const e = this.domSelection();
2590
+ this.compositionStart = e ? Math.min(e.anchor, e.focus) : null;
2591
+ }
2592
+ onCompositionEnd() {
2593
+ this.composing = !1;
2594
+ const e = this.pending, n = this.compositionStart;
2595
+ this.compositionStart = null, this.syncFromDom("typing");
2596
+ const o = this.domSelection();
2597
+ e && n !== null && o && o.focus > n && (this.pendingAt === null || this.pendingAt === n) && (this.doc = fe(this.doc, n, o.focus, (i) => dt(i, e)), this.pending = null, this.afterModelEdit(o, "typing", !1));
2598
+ }
2599
+ fragmentFrom(e, n) {
2600
+ if (!e) return null;
2601
+ const o = e.getData("text/html");
2602
+ if (o) return J(o, { foreign: !o.includes(de) });
2603
+ const i = e.getData("text/plain");
2604
+ return i ? [{ align: "left", runs: [{ text: i.replace(/\r\n?/g, `
2605
+ `), marks: Bt(this.doc, n) }] }] : null;
2606
+ }
2607
+ onPaste(e) {
2608
+ e.preventDefault();
2609
+ const n = this.domSelection() ?? this.lastSelection ?? this.endSelection(), o = Math.min(n.anchor, n.focus), i = this.fragmentFrom(e.clipboardData, o);
2610
+ i && this.replace(o, Math.max(n.anchor, n.focus), i);
2611
+ }
2612
+ writeClipboard(e, n) {
2613
+ const o = Ie(this.doc, n.anchor, n.focus);
2614
+ e.setData("text/plain", _t(o)), e.setData("text/html", `<div ${de}="">${ct(o)}</div>`);
2615
+ }
2616
+ onCopy(e, n) {
2617
+ const o = this.domSelection();
2618
+ !o || o.anchor === o.focus || !e.clipboardData || (e.preventDefault(), this.writeClipboard(e.clipboardData, o), n && this.replace(Math.min(o.anchor, o.focus), Math.max(o.anchor, o.focus), []));
2619
+ }
2620
+ onDragStart(e) {
2621
+ const n = this.domSelection();
2622
+ !n || n.anchor === n.focus || !e.dataTransfer || (this.dragRange = { anchor: Math.min(n.anchor, n.focus), focus: Math.max(n.anchor, n.focus) }, this.writeClipboard(e.dataTransfer, n));
2623
+ }
2624
+ onDrop(e) {
2625
+ var f, u, c;
2626
+ e.preventDefault();
2627
+ const n = this.root.ownerDocument;
2628
+ let o = null;
2629
+ const i = (f = n.caretPositionFromPoint) == null ? void 0 : f.call(n, e.clientX, e.clientY), r = i ? null : (u = n.caretRangeFromPoint) == null ? void 0 : u.call(n, e.clientX, e.clientY), s = (i == null ? void 0 : i.offsetNode) ?? (r == null ? void 0 : r.startContainer);
2630
+ s && this.root.contains(s) && (o = this.globalAt(s, (i == null ? void 0 : i.offset) ?? (r == null ? void 0 : r.startOffset) ?? 0)), o ?? (o = ((c = this.currentSelection()) == null ? void 0 : c.focus) ?? Q(this.doc));
2631
+ const l = this.fragmentFrom(e.dataTransfer, o), a = this.dragRange;
2632
+ if (this.dragRange = null, !!l) {
2633
+ if (a) {
2634
+ if (o >= a.anchor && o <= a.focus) return;
2635
+ this.doc = ue(this.doc, a.anchor, a.focus, []).doc, o > a.focus && (o -= a.focus - a.anchor);
2636
+ }
2637
+ this.root.focus({ preventScroll: !0 }), this.replace(o, o, l);
2638
+ }
2639
+ }
2640
+ }
2641
+ function It(t) {
2642
+ const e = t.ownerDocument.getSelection();
2643
+ let n = e && e.rangeCount > 0 ? e.anchorNode : null;
2644
+ if (!n || !t.contains(n)) return null;
2645
+ for (; n && n !== t; n = n.parentNode)
2646
+ if (n.nodeType === 1 && n.localName === "blockquote") return n;
2647
+ return null;
2648
+ }
2649
+ function zi(t) {
2650
+ const e = t.ownerDocument;
2651
+ if (!It(t))
2652
+ return e.execCommand("formatBlock", !1, "blockquote"), !!It(t);
2653
+ e.execCommand("formatBlock", !1, "p");
2654
+ const n = It(t);
2655
+ if (n) {
2656
+ const o = e.getSelection(), i = o != null && o.anchorNode && o.focusNode ? [o.anchorNode, o.anchorOffset, o.focusNode, o.focusOffset] : null;
2657
+ n.replaceWith(...Array.from(n.childNodes)), o && i && o.setBaseAndExtent(...i);
2658
+ }
2659
+ return !1;
2660
+ }
2661
+ function Ui(t, e) {
2662
+ return t[e];
2663
+ }
2664
+ export {
2665
+ W as BREAKPOINTS,
2666
+ Qe as CHART_COLORS,
2667
+ Do as CHART_SHADES,
2668
+ Ei as MEDIA,
2669
+ _e as MENU_ITEM_SELECTOR,
2670
+ ve as RICH_TEXT_INDENT_STEP,
2671
+ En as RICH_TEXT_MAX_INDENT,
2672
+ Ki as RichTextEditor,
2673
+ kn as TYPEAHEAD_TIMEOUT_MS,
2674
+ X as addDays,
2675
+ Li as addDismissLayer,
2676
+ on as addMonthsClamped,
2677
+ ro as alignRange,
2678
+ po as announce,
2679
+ Vo as annularSectorPath,
2680
+ dt as applyMarkPatch,
2681
+ Bo as arcPath,
2682
+ Yo as areaPath,
2683
+ vi as autoUpdate,
2684
+ bo as bindHorizontalStrip,
2685
+ xo as bindScrollEdges,
2686
+ pt as blockLength,
2687
+ $e as blockText,
2688
+ It as blockquoteAtSelection,
2689
+ Mi as breakpointFor,
2690
+ sn as buildMonthGrid,
2691
+ To as chartCaptionColorVar,
2692
+ kt as chartColorVar,
2693
+ Co as chartFillVars,
2694
+ zo as chartRatio,
2695
+ $o as chartSeriesColor,
2696
+ Uo as chartStack,
2697
+ Je as chartSum,
2698
+ Lo as chartThemeOpacity,
2699
+ Ao as clamp,
2700
+ ge as clampChartValue,
2701
+ Jo as clampDay,
2702
+ In as cleanRichTextColor,
2703
+ Fn as cleanRichTextFontFamily,
2704
+ On as cleanRichTextFontSize,
2705
+ mi as collectTreeIds,
2706
+ hn as computeFloatingLayout,
2707
+ Fi as createFocusOut,
2708
+ xi as createKanbanDnd,
2709
+ yo as createSubmenuHoverIntent,
2710
+ gi as createTreeTypeahead,
2711
+ Ii as createTypeahead,
2712
+ ko as cx,
2713
+ ti as dayKey,
2714
+ ut as dayStamp,
2715
+ nn as daysInMonth,
2716
+ cn as defaultKanbanAnnouncements,
2717
+ bi as defaultKanbanInstructions,
2718
+ jo as describeData,
2719
+ Q as docLength,
2720
+ Xo as donutArcs,
2721
+ Y as emptyBlock,
2722
+ ai as eventsOnDay,
2723
+ xt as findEnabledIndex,
2724
+ hi as flattenVisibleTree,
2725
+ ho as focusDialogInitial,
2726
+ vn as focusLeftWidget,
2727
+ je as focusMenuItem,
2728
+ An as formEntries,
2729
+ Ri as formValueFilled,
2730
+ si as formatCalendarTitle,
2731
+ ri as formatDateRange,
2732
+ ci as formatEventTimeRange,
2733
+ li as formatHourLabel,
2734
+ ii as formatMonthLabel,
2735
+ jt as formatOf,
2736
+ fe as formatRange,
2737
+ Mt as formatShortDate,
2738
+ oe as formatTimeLabel,
2739
+ z as fromGlobal,
2740
+ fo as generateId,
2741
+ mn as getClippingAncestors,
2742
+ qt as getFocusableElements,
2743
+ Kt as getMenuItems,
2744
+ fi as groupEventRows,
2745
+ wo as handleColumnArrowKeys,
2746
+ go as handleMenuKeydown,
2747
+ Ai as hideFromTopLayer,
2748
+ lo as indentRange,
2749
+ Eo as inferCodeLanguage,
2750
+ ne as isBeforeDay,
2751
+ di as isCurrentPeriod,
2752
+ Qo as isDayOutOfRange,
2753
+ ye as isInTopLayer,
2754
+ io as isRichTextEmpty,
2755
+ Pt as isSameDay,
2756
+ rn as isSameMonth,
2757
+ yi as isTypeaheadKey,
2758
+ Ci as keyToMove,
2759
+ ui as layoutTimedEvents,
2760
+ tn as linearLinePath,
2761
+ No as linearScale,
2762
+ Bt as marksAt,
2763
+ Fo as maxValue,
2764
+ Ui as moduleClass,
2765
+ ln as monthGridCells,
2766
+ $i as moveIndex,
2767
+ qo as nextChartIndex,
2768
+ Ko as nextGridCell,
2769
+ Ro as niceMax,
2770
+ Ut as normalizeDoc,
2771
+ So as omit,
2772
+ Oi as onFormReset,
2773
+ Sn as ownerForm,
2774
+ J as parseRichText,
2775
+ wi as placeFloating,
2776
+ Wo as plateauLinePath,
2777
+ Ot as polarPoint,
2778
+ yt as polarToCartesian,
2779
+ so as quoteRange,
2780
+ $t as readRichTextDom,
2781
+ no as renderRichText,
2782
+ ue as replaceRange,
2783
+ ki as requestFloatingUpdate,
2784
+ _t as richTextDocText,
2785
+ qi as richTextFormat,
2786
+ ji as richTextToPlainText,
2787
+ at as richTextValue,
2788
+ _i as sameList,
2789
+ Bi as sanitizeRichText,
2790
+ ct as serializeRichText,
2791
+ Be as setMenuRovingItem,
2792
+ ni as shiftCalendarDate,
2793
+ Zo as shiftMonth,
2794
+ Si as showInTopLayer,
2795
+ Ie as sliceDoc,
2796
+ Ti as sliderValueFromKey,
2797
+ Di as sliderValueFromPointer,
2798
+ Ho as smoothLinePath,
2799
+ lt as snapSliderValue,
2800
+ Ze as splitCodeTokensIntoLines,
2801
+ _o as stackValues,
2802
+ U as startOfDay,
2803
+ en as startOfMonth,
2804
+ vt as startOfWeek,
2805
+ Go as strokeArcPath,
2806
+ Io as sumValues,
2807
+ Po as ticks,
2808
+ Ce as toGlobal,
2809
+ Pi as toISODate,
2810
+ Ni as toISOTime,
2811
+ Oo as toPercent,
2812
+ zi as toggleBlockquote,
2813
+ Mo as tokenizeCode,
2814
+ mo as trapFocus,
2815
+ pi as treeKeyAction,
2816
+ vo as typedEntries,
2817
+ ei as visibleDays,
2818
+ oi as weekdayLabels
2819
+ };