monowind 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,98 +1,358 @@
1
+ //#region src/animate.ts
2
+ var e = /* @__PURE__ */ new WeakMap(), t = [], n = /* @__PURE__ */ new Map();
3
+ function r(r, i, a) {
4
+ let s = e.get(r);
5
+ e.set(r, i);
6
+ let c = n.get(r);
7
+ if (c) {
8
+ if (i !== c.toValue) {
9
+ let e = o(c);
10
+ return n.delete(r), t.push({
11
+ el: r,
12
+ from: e,
13
+ to: i
14
+ }), e;
15
+ }
16
+ let e = o(c);
17
+ return e === c.toValue && n.delete(r), e;
18
+ }
19
+ return s !== void 0 && s !== i && a.transitionDuration.split(",").some((e) => parseFloat(e) > 0) ? (t.push({
20
+ el: r,
21
+ from: s,
22
+ to: i
23
+ }), s) : i;
24
+ }
25
+ function i(e) {
26
+ let r = !1;
27
+ for (let i = t.length - 1; i >= 0; i--) {
28
+ let { el: a, from: o, to: s } = t[i];
29
+ if (!a.isConnected) {
30
+ t.splice(i, 1);
31
+ continue;
32
+ }
33
+ if (!e.contains(a)) continue;
34
+ t.splice(i, 1), r = !0;
35
+ let l = c(getComputedStyle(a), "background-color"), u = f(o), d = f(s);
36
+ !l || !u || !d || n.set(a, {
37
+ from: u,
38
+ to: d,
39
+ toValue: s,
40
+ start: performance.now() + l.delay,
41
+ duration: l.duration,
42
+ easing: l.easing
43
+ });
44
+ }
45
+ return r;
46
+ }
47
+ function a() {
48
+ let e = performance.now();
49
+ for (let [t, r] of n) (!t.isConnected || e >= r.start + r.duration) && n.delete(t);
50
+ return n.size > 0;
51
+ }
52
+ function o(e) {
53
+ let t = (performance.now() - e.start) / e.duration;
54
+ if (t >= 1) return e.toValue;
55
+ let n = t <= 0 ? 0 : e.easing(t);
56
+ return m(p(e.from, e.to, n));
57
+ }
58
+ var s = {
59
+ ease: [
60
+ .25,
61
+ .1,
62
+ .25,
63
+ 1
64
+ ],
65
+ "ease-in": [
66
+ .42,
67
+ 0,
68
+ 1,
69
+ 1
70
+ ],
71
+ "ease-out": [
72
+ 0,
73
+ 0,
74
+ .58,
75
+ 1
76
+ ],
77
+ "ease-in-out": [
78
+ .42,
79
+ 0,
80
+ .58,
81
+ 1
82
+ ]
83
+ };
84
+ function c(e, t) {
85
+ let n = e.transitionProperty.split(",").map((e) => e.trim()), r = -1;
86
+ for (let e = 0; e < n.length; e++) (n[e] === t || n[e] === "all") && (r = e);
87
+ if (r < 0) return null;
88
+ let i = (e) => {
89
+ let t = e.split(",").map((e) => e.trim());
90
+ return t[r % t.length] ?? "";
91
+ }, a = l(i(e.transitionDuration));
92
+ return a <= 0 ? null : {
93
+ duration: a * 1e3,
94
+ delay: l(i(e.transitionDelay)) * 1e3,
95
+ easing: u(i(e.transitionTimingFunction))
96
+ };
97
+ }
98
+ function l(e) {
99
+ let t = parseFloat(e);
100
+ return Number.isFinite(t) ? e.endsWith("ms") ? t / 1e3 : t : 0;
101
+ }
102
+ function u(e) {
103
+ if (e === "linear") return (e) => e;
104
+ let t = s[e];
105
+ if (t) return d(...t);
106
+ let n = e.match(/^cubic-bezier\(([^)]+)\)$/);
107
+ if (n) {
108
+ let [e, t, r, i] = n[1].split(",").map((e) => parseFloat(e));
109
+ if ([
110
+ e,
111
+ t,
112
+ r,
113
+ i
114
+ ].every((e) => Number.isFinite(e))) return d(e, t, r, i);
115
+ }
116
+ return (e) => e;
117
+ }
118
+ function d(e, t, n, r) {
119
+ let i = (e, t, n) => 3 * e * n * (1 - n) * (1 - n) + 3 * t * n * n * (1 - n) + n * n * n;
120
+ return (a) => {
121
+ let o = 0, s = 1;
122
+ for (let t = 0; t < 24; t++) {
123
+ let t = (o + s) / 2;
124
+ i(e, n, t) < a ? o = t : s = t;
125
+ }
126
+ return i(t, r, (o + s) / 2);
127
+ };
128
+ }
129
+ function f(e) {
130
+ if (e === "" || e === "transparent") return {
131
+ r: 0,
132
+ g: 0,
133
+ b: 0,
134
+ a: 0,
135
+ legacy: !0
136
+ };
137
+ let t = e.match(/^rgba?\(([^)]+)\)$/);
138
+ if (t) {
139
+ let e = t[1].split(/[\s,/]+/).map((e) => parseFloat(e));
140
+ return e.length < 3 || e.some((e) => !Number.isFinite(e)) ? null : {
141
+ r: e[0] / 255,
142
+ g: e[1] / 255,
143
+ b: e[2] / 255,
144
+ a: e[3] ?? 1,
145
+ legacy: !0
146
+ };
147
+ }
148
+ if (t = e.match(/^color\(srgb ([^)]+)\)$/), t) {
149
+ let e = t[1].split(/[\s/]+/).map((e) => parseFloat(e));
150
+ return e.length < 3 || e.slice(0, 3).some((e) => !Number.isFinite(e)) ? null : {
151
+ r: e[0],
152
+ g: e[1],
153
+ b: e[2],
154
+ a: e[3] ?? 1,
155
+ legacy: !1
156
+ };
157
+ }
158
+ if (t = e.match(/^okl(ch|ab)\(([^)]+)\)$/), t) {
159
+ let e = t[1] === "ch", n = t[2].replaceAll("none", "0").split(/[\s/]+/).map((e) => parseFloat(e));
160
+ if (n.length < 3 || n.some((e) => !Number.isFinite(e))) return null;
161
+ let [r, i, a] = n;
162
+ return {
163
+ ...v(r, e ? i * Math.cos(a * Math.PI / 180) : i, e ? i * Math.sin(a * Math.PI / 180) : a),
164
+ a: n[3] ?? 1,
165
+ legacy: !1
166
+ };
167
+ }
168
+ return null;
169
+ }
170
+ function p(e, t, n) {
171
+ let r = e.a + (t.a - e.a) * n, i = (i, a) => {
172
+ let o = i * e.a + (a * t.a - i * e.a) * n;
173
+ return r === 0 ? 0 : o / r;
174
+ };
175
+ if (e.legacy && t.legacy) return {
176
+ r: i(e.r, t.r),
177
+ g: i(e.g, t.g),
178
+ b: i(e.b, t.b),
179
+ a: r,
180
+ legacy: !0
181
+ };
182
+ let a = _(e.r, e.g, e.b), o = _(t.r, t.g, t.b);
183
+ return {
184
+ ...v(i(a.l, o.l), i(a.a, o.a), i(a.b, o.b)),
185
+ a: r,
186
+ legacy: !1
187
+ };
188
+ }
189
+ function m(e) {
190
+ let t = (e) => Math.round(Math.min(1, Math.max(0, e)) * 255), n = Math.round(Math.min(1, Math.max(0, e.a)) * 1e3) / 1e3;
191
+ return `rgba(${t(e.r)}, ${t(e.g)}, ${t(e.b)}, ${n})`;
192
+ }
193
+ function h(e) {
194
+ return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
195
+ }
196
+ function g(e) {
197
+ return e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
198
+ }
199
+ function _(e, t, n) {
200
+ let r = h(e), i = h(t), a = h(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
201
+ return {
202
+ l: .2104542553 * o + .793617785 * s - .0040720468 * c,
203
+ a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
204
+ b: .0259040371 * o + .7827717662 * s - .808675766 * c
205
+ };
206
+ }
207
+ function v(e, t, n) {
208
+ let r = (e + .3963377774 * t + .2158037573 * n) ** 3, i = (e - .1055613458 * t - .0638541728 * n) ** 3, a = (e - .0894841775 * t - 1.291485548 * n) ** 3;
209
+ return {
210
+ r: g(4.0767416621 * r - 3.3077115913 * i + .2309699292 * a),
211
+ g: g(-1.2684380046 * r + 2.6097574011 * i - .3413193965 * a),
212
+ b: g(-.0041960863 * r - .7034186147 * i + 1.707614701 * a)
213
+ };
214
+ }
215
+ //#endregion
216
+ //#region src/warn.ts
217
+ var y = /* @__PURE__ */ new WeakMap();
218
+ function b(e, t) {
219
+ let n = y.get(e);
220
+ n || y.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
221
+ }
222
+ //#endregion
223
+ //#region src/leaf.ts
224
+ var x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
225
+ function C(e) {
226
+ let t = e.tag.toLowerCase();
227
+ if (!t.includes("-")) {
228
+ console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
229
+ return;
230
+ }
231
+ x.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), x.set(t, {
232
+ ...e,
233
+ tag: t
234
+ }), O();
235
+ }
236
+ function w() {
237
+ O();
238
+ }
239
+ function T(e) {
240
+ return x.get(e.toLowerCase());
241
+ }
242
+ function E() {
243
+ let e = /* @__PURE__ */ new Set();
244
+ for (let t of x.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
245
+ return [...e];
246
+ }
247
+ function D(e) {
248
+ return S.add(e), () => S.delete(e);
249
+ }
250
+ function ee(e, t) {
251
+ try {
252
+ return e.render(t);
253
+ } catch (n) {
254
+ return b(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
255
+ }
256
+ }
257
+ function O() {
258
+ for (let e of S) e();
259
+ }
260
+ //#endregion
1
261
  //#region src/borders.ts
2
- function e(e, n, r) {
3
- let i = e.border;
4
- if (i.top === 0 && i.right === 0 && i.bottom === 0 && i.left === 0) return;
5
- let a = Math.max(i.top, i.right, i.bottom, i.left);
6
- for (let o = 0; o < a; o++) {
7
- let a = {
8
- top: o < i.top,
9
- right: o < i.right,
10
- bottom: o < i.bottom,
11
- left: o < i.left
12
- }, s = {
13
- x: n.x + (a.left ? o : 0),
14
- y: n.y + (a.top ? o : 0),
15
- width: n.width - (a.left ? o : 0) - (a.right ? o : 0),
16
- height: n.height - (a.top ? o : 0) - (a.bottom ? o : 0)
262
+ function k(e, t, n) {
263
+ let r = e.border;
264
+ if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
265
+ let i = Math.max(r.top, r.right, r.bottom, r.left);
266
+ for (let a = 0; a < i; a++) {
267
+ let i = {
268
+ top: a < r.top,
269
+ right: a < r.right,
270
+ bottom: a < r.bottom,
271
+ left: a < r.left
272
+ }, o = {
273
+ x: t.x + (i.left ? a : 0),
274
+ y: t.y + (i.top ? a : 0),
275
+ width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
276
+ height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
17
277
  };
18
- s.width <= 0 || s.height <= 0 || t(r, e.borderStyle, e.borderColor, s, a);
278
+ o.width <= 0 || o.height <= 0 || A(n, e.borderStyle, e.borderColor, o, i);
19
279
  }
20
280
  }
21
- function t(e, t, n, r, i) {
22
- let a = c(t.top), o = c(t.right), s = c(t.bottom), l = c(t.left), u = (e, t, n) => n(c(e === t ? e : "solid")), { x: d, y: f, width: p, height: m } = r, h = p >= 2 && m >= 2, g = d + +!!i.left, _ = d + p - +!!i.right, v = f + +!!i.top, y = f + m - +!!i.bottom;
23
- if (i.top && _ > g && e.push({
281
+ function A(e, t, n, r, i) {
282
+ let a = oe(t.top), o = oe(t.right), s = oe(t.bottom), c = oe(t.left), l = (e, t, n) => n(oe(e === t ? e : "solid")), { x: u, y: d, width: f, height: p } = r, m = f >= 2 && p >= 2, h = u + +!!i.left, g = u + f - +!!i.right, _ = d + +!!i.top, v = d + p - +!!i.bottom;
283
+ if (i.top && g > h && e.push({
24
284
  glyph: a.h,
25
- x: g,
26
- y: f,
27
- length: _ - g,
285
+ x: h,
286
+ y: d,
287
+ length: g - h,
28
288
  color: n.top
29
- }), i.bottom && m > +!!i.top && _ > g && e.push({
289
+ }), i.bottom && p > +!!i.top && g > h && e.push({
30
290
  glyph: s.h,
31
- x: g,
32
- y: f + m - 1,
33
- length: _ - g,
291
+ x: h,
292
+ y: d + p - 1,
293
+ length: g - h,
34
294
  color: n.bottom
35
- }), i.left) for (let t = v; t < y; t++) e.push({
36
- glyph: l.v,
37
- x: d,
295
+ }), i.left) for (let t = _; t < v; t++) e.push({
296
+ glyph: c.v,
297
+ x: u,
38
298
  y: t,
39
299
  length: 1,
40
300
  color: n.left
41
301
  });
42
- if (i.right && p > +!!i.left) for (let t = v; t < y; t++) e.push({
302
+ if (i.right && f > +!!i.left) for (let t = _; t < v; t++) e.push({
43
303
  glyph: o.v,
44
- x: d + p - 1,
304
+ x: u + f - 1,
45
305
  y: t,
46
306
  length: 1,
47
307
  color: n.right
48
308
  });
49
- h && (i.top && i.left && e.push({
50
- glyph: u(t.top, t.left, (e) => e.tl),
51
- x: d,
52
- y: f,
309
+ m && (i.top && i.left && e.push({
310
+ glyph: l(t.top, t.left, (e) => e.tl),
311
+ x: u,
312
+ y: d,
53
313
  length: 1,
54
314
  color: n.top
55
315
  }), i.top && i.right && e.push({
56
- glyph: u(t.top, t.right, (e) => e.tr),
57
- x: d + p - 1,
58
- y: f,
316
+ glyph: l(t.top, t.right, (e) => e.tr),
317
+ x: u + f - 1,
318
+ y: d,
59
319
  length: 1,
60
320
  color: n.top
61
321
  }), i.bottom && i.left && e.push({
62
- glyph: u(t.bottom, t.left, (e) => e.bl),
63
- x: d,
64
- y: f + m - 1,
322
+ glyph: l(t.bottom, t.left, (e) => e.bl),
323
+ x: u,
324
+ y: d + p - 1,
65
325
  length: 1,
66
326
  color: n.bottom
67
327
  }), i.bottom && i.right && e.push({
68
- glyph: u(t.bottom, t.right, (e) => e.br),
69
- x: d + p - 1,
70
- y: f + m - 1,
328
+ glyph: l(t.bottom, t.right, (e) => e.br),
329
+ x: u + f - 1,
330
+ y: d + p - 1,
71
331
  length: 1,
72
332
  color: n.bottom
73
333
  }));
74
334
  }
75
- function n(e, t) {
335
+ function j(e, t) {
76
336
  return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
77
337
  }
78
- function r(e) {
338
+ function te(e) {
79
339
  if (e.children.length <= 1) return e.children;
80
- let t = null, r = null, i = null;
81
- for (let a of e.children) n(a, e) ? (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (t ??= []).push(a);
82
- return i && i.length > 1 && i.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), t && !r && !i ? t : !t && r && !i ? r : !t && !r && i ? i : [
340
+ let t = null, n = null, r = null;
341
+ for (let i of e.children) j(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
342
+ return r && r.length > 1 && r.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), t && !n && !r ? t : !t && n && !r ? n : !t && !n && r ? r : [
83
343
  ...t ?? [],
84
- ...r ?? [],
85
- ...i ?? []
344
+ ...n ?? [],
345
+ ...r ?? []
86
346
  ];
87
347
  }
88
- function i(e, t) {
89
- let n = c(e);
348
+ function ne(e, t) {
349
+ let n = oe(e);
90
350
  return t === "h" ? n.h : n.v;
91
351
  }
92
- function a(e, t, n, r, i) {
93
- return (e === "double" ? s : o)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
352
+ function re(e, t, n, r, i) {
353
+ return (e === "double" ? ae : ie)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
94
354
  }
95
- var o = [
355
+ var ie = [
96
356
  " ",
97
357
  "─",
98
358
  "─",
@@ -109,7 +369,7 @@ var o = [
109
369
  "├",
110
370
  "┤",
111
371
  "┼"
112
- ], s = [
372
+ ], ae = [
113
373
  " ",
114
374
  "═",
115
375
  "═",
@@ -127,8 +387,8 @@ var o = [
127
387
  "╣",
128
388
  "╬"
129
389
  ];
130
- function c(e) {
131
- let t = (t, n, r, i) => a(e, t, n, r, i), n = {
390
+ function oe(e) {
391
+ let t = (t, n, r, i) => re(e, t, n, r, i), n = {
132
392
  h: t(!1, !1, !0, !0),
133
393
  v: t(!0, !0, !1, !1),
134
394
  tl: t(!1, !0, !1, !0),
@@ -146,7 +406,7 @@ function c(e) {
146
406
  v: "┊"
147
407
  } : n;
148
408
  }
149
- function l(e, t, n, r) {
409
+ function se(e, t, n, r) {
150
410
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
151
411
  for (let n = 0; n < e.length; n++) if (a.push({
152
412
  start: e[n].start,
@@ -190,80 +450,95 @@ function l(e, t, n, r) {
190
450
  end: e.end - r
191
451
  })).filter((e) => e.end > e.start);
192
452
  }
193
- function u(e) {
194
- let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, o = (e, t) => ({
453
+ function ce(e) {
454
+ let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
195
455
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
196
456
  start: t.start,
197
457
  end: t.end,
198
458
  startHalf: t.startHalf === !0,
199
459
  endHalf: t.endHalf === !0
200
- }), s = e.ruleX ? e.vertical.map((t) => o(e.ruleX, t)) : [], c = e.ruleY ? e.horizontal.map((t) => o(e.ruleY, t)) : [], l = e.ruleX?.width ?? 0, u = e.ruleY?.width ?? 0, f = (e, t, n, r) => e.some((e) => n >= e.line && n < e.line + t && (e.start < r && e.end > r || e.end === r && !e.endHalf || e.start === r && !e.startHalf)), p = (e, t) => c.some((n) => t >= n.line && t < n.line + u && e >= n.start && e < n.end);
460
+ }), a = e.ruleX ? e.vertical.map((t) => i(e.ruleX, t)) : [], o = e.ruleY ? e.horizontal.map((t) => i(e.ruleY, t)) : [], s = e.ruleX?.width ?? 0, c = e.ruleY?.width ?? 0, l = (e, t, n, r) => e.some((e) => n >= e.line && n < e.line + t && (e.start < r && e.end > r || e.end === r && !e.endHalf || e.start === r && !e.startHalf)), u = (e, t) => o.some((n) => t >= n.line && t < n.line + c && e >= n.start && e < n.end);
201
461
  if (e.ruleX) {
202
- let a = i(e.ruleX.style, "v");
203
- for (let i of s) {
204
- for (let o = 0; o < l; o++) for (let s = i.start; s < i.end; s++) p(i.line + o, s) || t.push({
205
- glyph: a,
206
- x: n + i.line + o,
462
+ let i = ne(e.ruleX.style, "v");
463
+ for (let o of a) {
464
+ for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
465
+ glyph: i,
466
+ x: n + o.line + a,
207
467
  y: r + s,
208
468
  length: 1,
209
469
  color: e.ruleX.color
210
470
  });
211
- d(e, t, "x", i.line, i.start, i.end);
471
+ le(e, t, "x", o.line, o.start, o.end);
212
472
  }
213
473
  }
214
474
  if (e.ruleY) {
215
- let o = e.ruleY.style === "double" && e.ruleX?.style === "double";
216
- for (let p of c) {
217
- for (let d = 0; d < u; d++) {
218
- let m = p.line + d;
219
- for (let d = p.start; d < p.end; d++) {
220
- let p = f(s, l, d, m), h = f(s, l, d, m + 1);
475
+ let i = e.ruleY.style === "double" && e.ruleX?.style === "double";
476
+ for (let u of o) {
477
+ for (let d = 0; d < c; d++) {
478
+ let f = u.line + d;
479
+ for (let d = u.start; d < u.end; d++) {
480
+ let u = l(a, s, d, f), p = l(a, s, d, f + 1);
221
481
  t.push({
222
- glyph: p || h ? a(o ? "double" : "solid", p, h, f(c, u, m, d), f(c, u, m, d + 1)) : i(e.ruleY.style, "h"),
482
+ glyph: u || p ? re(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1)) : ne(e.ruleY.style, "h"),
223
483
  x: n + d,
224
- y: r + m,
484
+ y: r + f,
225
485
  length: 1,
226
486
  color: e.ruleY.color
227
487
  });
228
488
  }
229
489
  }
230
- d(e, t, "y", p.line, p.start, p.end);
490
+ le(e, t, "y", u.line, u.start, u.end);
231
491
  }
232
492
  }
233
493
  return t;
234
494
  }
235
- function d(e, t, n, r, i, o) {
236
- let s = n === "x" ? e.ruleX : e.ruleY, c = e.border.left + e.padding.left, l = e.border.top + e.padding.top, u = c + e.contentWidth + e.padding.right + e.border.right, d = l + e.contentHeight + e.padding.bottom + e.border.bottom, f = (e, n, r, i, o, c, l, u) => {
237
- let d = s.style === "double" && r === "double" ? "double" : "solid";
495
+ function le(e, t, n, r, i, a) {
496
+ let o = n === "x" ? e.ruleX : e.ruleY, s = e.border.left + e.padding.left, c = e.border.top + e.padding.top, l = s + e.contentWidth + e.padding.right + e.border.right, u = c + e.contentHeight + e.padding.bottom + e.border.bottom, d = (e, n, r, i, a, s, c, l) => {
497
+ let u = o.style === "double" && r === "double" ? "double" : "solid";
238
498
  t.push({
239
- glyph: a(d, o, c, l, u),
499
+ glyph: re(u, a, s, c, l),
240
500
  x: e,
241
501
  y: n,
242
502
  length: 1,
243
503
  color: i
244
504
  });
245
505
  };
246
- if (n === "x") for (let t = 0; t < s.width; t++) {
506
+ if (n === "x") for (let t = 0; t < o.width; t++) {
507
+ let n = s + r + t;
508
+ i <= 0 && e.padding.top === 0 && e.border.top > 0 && d(n, e.border.top - 1, e.borderStyle.top, e.borderColor.top, !1, !0, !0, !0), a >= e.contentHeight && e.padding.bottom === 0 && e.border.bottom > 0 && d(n, u - e.border.bottom, e.borderStyle.bottom, e.borderColor.bottom, !0, !1, !0, !0);
509
+ }
510
+ else for (let t = 0; t < o.width; t++) {
247
511
  let n = c + r + t;
248
- i <= 0 && e.padding.top === 0 && e.border.top > 0 && f(n, e.border.top - 1, e.borderStyle.top, e.borderColor.top, !1, !0, !0, !0), o >= e.contentHeight && e.padding.bottom === 0 && e.border.bottom > 0 && f(n, d - e.border.bottom, e.borderStyle.bottom, e.borderColor.bottom, !0, !1, !0, !0);
512
+ i <= 0 && e.padding.left === 0 && e.border.left > 0 && d(e.border.left - 1, n, e.borderStyle.left, e.borderColor.left, !0, !0, !1, !0), a >= e.contentWidth && e.padding.right === 0 && e.border.right > 0 && d(l - e.border.right, n, e.borderStyle.right, e.borderColor.right, !0, !0, !0, !1);
249
513
  }
250
- else for (let t = 0; t < s.width; t++) {
251
- let n = l + r + t;
252
- i <= 0 && e.padding.left === 0 && e.border.left > 0 && f(e.border.left - 1, n, e.borderStyle.left, e.borderColor.left, !0, !0, !1, !0), o >= e.contentWidth && e.padding.right === 0 && e.border.right > 0 && f(u - e.border.right, n, e.borderStyle.right, e.borderColor.right, !0, !0, !0, !1);
514
+ }
515
+ //#endregion
516
+ //#region src/pointer.ts
517
+ function ue(e, t, n) {
518
+ let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
519
+ for (;;) {
520
+ let e = null;
521
+ for (let r of te(i)) {
522
+ if (r.tableHidden) continue;
523
+ let i = a + r.localRect.x, s = o + r.localRect.y;
524
+ t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
525
+ }
526
+ if (!e) return r;
527
+ r.push(e.source), a += e.localRect.x, o += e.localRect.y, i = e;
253
528
  }
254
529
  }
255
530
  //#endregion
256
531
  //#region src/metrics.ts
257
- function f(e) {
532
+ function M(e) {
258
533
  return (e >= 0 ? Math.floor(e + .5) : -Math.floor(-e + .5)) || 0;
259
534
  }
260
- function p(e, t) {
261
- return t <= 0 ? 0 : f(e / (.25 * t));
535
+ function N(e, t) {
536
+ return t <= 0 ? 0 : M(e / (.25 * t));
262
537
  }
263
- function m(e, t) {
264
- return f(t * e / 100);
538
+ function de(e, t) {
539
+ return M(t * e / 100);
265
540
  }
266
- function h(e, t) {
541
+ function fe(e, t) {
267
542
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
268
543
  i.selectNodeContents(t);
269
544
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -274,56 +549,56 @@ function h(e, t) {
274
549
  inkOverhang: a
275
550
  };
276
551
  }
277
- function g() {
552
+ function pe() {
278
553
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
279
554
  }
280
555
  //#endregion
281
556
  //#region src/wrap.ts
282
- function _(e, t, n = {}) {
283
- return x(e, t, n).map((t) => e.slice(t.start, t.end));
557
+ function me(e, t, n = {}) {
558
+ return ve(e, t, n).map((t) => e.slice(t.start, t.end));
284
559
  }
285
- function v(e, t, n = {}) {
286
- return x(e, t, n).length;
560
+ function he(e, t, n = {}) {
561
+ return ve(e, t, n).length;
287
562
  }
288
- function y(e, t) {
563
+ function ge(e, t) {
289
564
  return t.endsWith("\n") && e.pop(), e;
290
565
  }
291
- function b(e) {
566
+ function _e(e) {
292
567
  let t = [], n = 0;
293
568
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
294
569
  start: n,
295
570
  end: r
296
571
  }), n = r + 1);
297
- return y(t, e);
572
+ return ge(t, e);
298
573
  }
299
- function x(e, t, n = {}) {
574
+ function ve(e, t, n = {}) {
300
575
  if (!/[^ \t\r\f]/.test(e)) return [];
301
576
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
302
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...A(e, i, o, t, n, a)), a = 0, i = o + 1);
303
- return y(r, e);
577
+ for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Ee(e, i, o, t, n, a)), a = 0, i = o + 1);
578
+ return ge(r, e);
304
579
  }
305
- function S(e, t, n) {
580
+ function ye(e, t, n) {
306
581
  if (!n) return t - e;
307
582
  let r = 0;
308
583
  for (let i = e; i < t; i++) r += n[i] ?? 1;
309
584
  return r;
310
585
  }
311
- function C(e, t, n, r = 0) {
312
- return t <= e ? 0 : S(e, t, n) - Math.min(r, w(t - 1, n));
586
+ function P(e, t, n, r = 0) {
587
+ return t <= e ? 0 : ye(e, t, n) - Math.min(r, be(t - 1, n));
313
588
  }
314
- function w(e, t) {
589
+ function be(e, t) {
315
590
  return t ? (t[e] ?? 1) - 1 : 0;
316
591
  }
317
- function T(e, t = {}) {
592
+ function xe(e, t = {}) {
318
593
  let { advances: n, tracking: r = 0 } = t, i = 0;
319
- for (let t of k(e, 0, e.length)) for (let a of D(e, t.start, t.end)) i = Math.max(i, C(a.start, a.end, n, r));
594
+ for (let t of Te(e, 0, e.length)) for (let a of Ce(e, t.start, t.end)) i = Math.max(i, P(a.start, a.end, n, r));
320
595
  return i;
321
596
  }
322
- function E(e, t) {
597
+ function Se(e, t) {
323
598
  let n = 0;
324
599
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
325
600
  }
326
- function D(e, t, n) {
601
+ function Ce(e, t, n) {
327
602
  let r = [], i = t;
328
603
  for (let a = t; a < n; a++) {
329
604
  if (e[a] === "") {
@@ -350,14 +625,14 @@ function D(e, t, n) {
350
625
  end: n
351
626
  }), r;
352
627
  }
353
- var O = /[ \t\r\n\f]/;
354
- function k(e, t, n) {
628
+ var we = /[ \t\r\n\f]/;
629
+ function Te(e, t, n) {
355
630
  let r = [], i = t;
356
631
  for (; i < n;) {
357
- for (; i < n && O.test(e[i]);) i++;
632
+ for (; i < n && we.test(e[i]);) i++;
358
633
  if (i >= n) break;
359
634
  let t = i;
360
- for (; i < n && !O.test(e[i]);) i++;
635
+ for (; i < n && !we.test(e[i]);) i++;
361
636
  r.push({
362
637
  start: t,
363
638
  end: i
@@ -365,8 +640,8 @@ function k(e, t, n) {
365
640
  }
366
641
  return r;
367
642
  }
368
- function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
369
- let s = k(e, t, n);
643
+ function Ee(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
644
+ let s = Te(e, t, n);
370
645
  if (s.length === 0) return [{
371
646
  start: t,
372
647
  end: t
@@ -378,13 +653,13 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
378
653
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
379
654
  for (let t of s) {
380
655
  let n = !1;
381
- for (let r of D(e, t.start, t.end)) {
382
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + S(o, t, i), p = Math.min(a, w(t - 1, i));
656
+ for (let r of Ce(e, t.start, t.end)) {
657
+ let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + ye(o, t, i), p = Math.min(a, be(t - 1, i));
383
658
  if (l !== null && s - p <= f()) l.end = t, u = s;
384
659
  else {
385
660
  for (l !== null && (c.push(l), d = 0);;) {
386
661
  let n = e;
387
- for (; n < t && C(e, n + 1, i, a) <= f();) n++;
662
+ for (; n < t && P(e, n + 1, i, a) <= f();) n++;
388
663
  if (n === t || n === e) break;
389
664
  c.push({
390
665
  start: e,
@@ -394,7 +669,7 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
394
669
  l = {
395
670
  start: e,
396
671
  end: t
397
- }, u = S(e, t, i);
672
+ }, u = ye(e, t, i);
398
673
  }
399
674
  n = !0;
400
675
  }
@@ -403,7 +678,7 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
403
678
  }
404
679
  //#endregion
405
680
  //#region src/flex.ts
406
- function j(e, t) {
681
+ function De(e, t) {
407
682
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
408
683
  for (let e = 1; e < n.length; e++) {
409
684
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -414,12 +689,12 @@ function j(e, t) {
414
689
  }
415
690
  return r;
416
691
  }
417
- function M(e, t, n, r, i) {
692
+ function Oe(e, t, n, r, i) {
418
693
  if (e.style.ruleBreak !== "intersection") return [{
419
694
  start: 0,
420
695
  end: i
421
696
  }];
422
- let a = [t[n - 1], t[n]].flatMap((e) => j(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
697
+ let a = [t[n - 1], t[n]].flatMap((e) => De(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
423
698
  start: e,
424
699
  end: t,
425
700
  spanned: !1,
@@ -427,38 +702,38 @@ function M(e, t, n, r, i) {
427
702
  afterOccupied: !0
428
703
  }), s = [], c = 0;
429
704
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
430
- return c < i && s.push(o(c, i)), l(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
705
+ return c < i && s.push(o(c, i)), se(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
431
706
  }
432
- function N(e, t) {
707
+ function ke(e, t) {
433
708
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
434
709
  ...e,
435
710
  start: e.start + t,
436
711
  end: e.end - t
437
712
  })).filter((e) => e.end > e.start);
438
713
  }
439
- function P(e, t, n, r, i, a, o) {
440
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = se(e).map((e) => {
714
+ function Ae(e, t, n, r, i, a, o) {
715
+ let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Re(e).map((e) => {
441
716
  let n = G(e.style.margin, t);
442
717
  return {
443
718
  node: e,
444
- base: oe(e, t, o),
719
+ base: Le(e, t, o),
445
720
  grow: e.style.flexGrow,
446
721
  shrink: e.style.flexShrink,
447
- min: ue(e, t, o),
722
+ min: Ve(e, t, o),
448
723
  max: K(e.style.maxWidth, t),
449
724
  margin: n
450
725
  };
451
- }), d = [];
726
+ }), u = [];
452
727
  if (e.style.flexWrap === "wrap") {
453
728
  let n = [], r = 0;
454
729
  for (let e of l) {
455
730
  let i = Math.max(0, H(e.base, e.min, e.max)) + (e.margin.left ?? 0) + (e.margin.right ?? 0), a = n.length === 0 ? i : r + s + i;
456
- n.length > 0 && a > t && (d.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
731
+ n.length > 0 && a > t && (u.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
457
732
  }
458
- n.length > 0 && d.push(n), e.style.wrapReverse && d.reverse();
459
- } else d.push(l);
460
- let f = i.left + a.left, p = i.top + a.top, m = d.map((e) => {
461
- let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, H(e.base, e.min, e.max))) : ie(e, a);
733
+ n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
734
+ } else u.push(l);
735
+ let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
736
+ let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, H(e.base, e.min, e.max))) : Fe(e, a);
462
737
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
463
738
  return {
464
739
  row: e,
@@ -466,26 +741,26 @@ function P(e, t, n, r, i, a, o) {
466
741
  availableForItems: a,
467
742
  height: e.reduce((e, t) => Math.max(e, t.node.localRect.height), 0)
468
743
  };
469
- }), h = m.map((e) => e.height), g = c * Math.max(0, m.length - 1), _;
470
- if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (h[0] = Math.max(n, h[0] ?? 0)), _ = [0];
744
+ }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
745
+ if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
471
746
  else {
472
- let t = h.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - g) : 0, i = ce(e.style);
747
+ let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = ze(e.style);
473
748
  if (i === "stretch" && r > 0) {
474
- let e = I(Array.from({ length: m.length }, () => 1), r);
475
- for (let t = 0; t < h.length; t++) h[t] += e[t];
476
- _ = F("start", h, 0);
477
- } else _ = F(i === "stretch" ? "start" : i, h, r);
749
+ let e = I(Array.from({ length: p.length }, () => 1), r);
750
+ for (let t = 0; t < m.length; t++) m[t] += e[t];
751
+ g = F("start", m, 0);
752
+ } else g = F(i === "stretch" ? "start" : i, m, r);
478
753
  }
479
- for (let i = 0; i < m.length; i++) {
480
- let { row: a, widths: l, availableForItems: u } = m[i], d = h[i], g = _[i] + i * c;
754
+ for (let i = 0; i < p.length; i++) {
755
+ let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
481
756
  for (let i = 0; i < a.length; i++) {
482
- let s = a[i].node, c = ae(s, e), u = a[i].margin, f = u.top === null || u.bottom === null, p = s.style.height !== void 0 && s.style.height.kind !== "auto";
483
- if (c === "stretch" && !f && !p && d > s.localRect.height) {
484
- let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, f = H(Math.max(0, d - e - a), K(s.style.minHeight, c) ?? 0, K(s.style.maxHeight, c));
485
- if (f === s.localRect.height) continue;
757
+ let s = a[i].node, c = Ie(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
758
+ if (c === "stretch" && !d && !f && h > s.localRect.height) {
759
+ let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = H(Math.max(0, h - e - a), K(s.style.minHeight, c) ?? 0, K(s.style.maxHeight, c));
760
+ if (d === s.localRect.height) continue;
486
761
  V(s, t, r, 0, 0, "fill", o, {
487
762
  width: l[i],
488
- height: f
763
+ height: d
489
764
  });
490
765
  }
491
766
  }
@@ -494,53 +769,53 @@ function P(e, t, n, r, i, a, o) {
494
769
  let e = I(Array.from({ length: b }, () => 1), y), t = 0;
495
770
  for (let n = 0; n < a.length; n++) a[n].margin.left === null && (x[n] = e[t++]), a[n].margin.right === null && (S[n] = e[t++]);
496
771
  C = F("start", l, 0);
497
- } else C = F(le(e.style), l, y);
772
+ } else C = F(Be(e.style), l, y);
498
773
  let w = 0;
499
774
  for (let t = 0; t < a.length; t++) {
500
775
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
501
776
  w += x[t] + i, r.localRect = {
502
777
  ...r.localRect,
503
- x: f + C[t] + t * s + w,
504
- y: p + g + ne(r, e.style.alignItems, d, n.margin)
778
+ x: d + C[t] + t * s + w,
779
+ y: f + _ + Ne(r, e.style.alignItems, h, n.margin)
505
780
  }, w += S[t] + o;
506
781
  }
507
782
  }
508
- let v = h.reduce((e, t) => e + t, 0) + g, y = Number.isFinite(n) ? Math.max(n, v) : v;
783
+ let _ = m.reduce((e, t) => e + t, 0) + h, v = Number.isFinite(n) ? Math.max(n, _) : _;
509
784
  if (e.style.ruleX || e.style.ruleY) {
510
785
  let n = [], r = [];
511
- for (let i = 0; i < m.length; i++) {
512
- let a = _[i] + i * c;
513
- for (let e of j(m[i], f)) n.push({
786
+ for (let i = 0; i < p.length; i++) {
787
+ let a = g[i] + i * c;
788
+ for (let e of De(p[i], d)) n.push({
514
789
  bandStart: e.start,
515
790
  bandSize: e.end - e.start,
516
791
  start: a,
517
- end: a + h[i]
792
+ end: a + m[i]
518
793
  });
519
794
  if (i > 0) {
520
- let n = _[i - 1] + (i - 1) * c + h[i - 1];
521
- if (a > n) for (let o of M(e, m, i, f, t)) r.push({
795
+ let n = g[i - 1] + (i - 1) * c + m[i - 1];
796
+ if (a > n) for (let o of Oe(e, p, i, d, t)) r.push({
522
797
  bandStart: n,
523
798
  bandSize: a - n,
524
799
  ...o
525
800
  });
526
801
  }
527
802
  }
528
- e.decorationRuns = u({
803
+ e.decorationRuns = ce({
529
804
  ruleX: e.style.ruleX,
530
805
  ruleY: e.style.ruleY,
531
- vertical: N(n, e.style.ruleInset),
532
- horizontal: N(r, e.style.ruleInset),
806
+ vertical: ke(n, e.style.ruleInset),
807
+ horizontal: ke(r, e.style.ruleInset),
533
808
  contentWidth: t,
534
- contentHeight: y,
809
+ contentHeight: v,
535
810
  border: i,
536
811
  borderStyle: e.style.borderStyle,
537
812
  borderColor: e.style.borderColor,
538
813
  padding: a
539
814
  });
540
815
  }
541
- return ee(e, i, a, t, y), y;
816
+ return je(e, i, a, t, v), v;
542
817
  }
543
- function ee(e, t, n, r, i) {
818
+ function je(e, t, n, r, i) {
544
819
  for (let a of e.children) B(a.style) && (a.staticSlot = {
545
820
  kind: "flex",
546
821
  direction: e.style.flexDirection,
@@ -550,11 +825,11 @@ function ee(e, t, n, r, i) {
550
825
  innerHeight: i
551
826
  });
552
827
  }
553
- function te(e, t, n, r, i, a, o) {
554
- let s = U(e.style, "y", n), c = se(e).map((i) => {
555
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = ae(i, e) === "stretch";
828
+ function Me(e, t, n, r, i, a, o) {
829
+ let s = U(e.style, "y", n), c = Re(e).map((i) => {
830
+ let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ie(i, e) === "stretch";
556
831
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
557
- let l = Number.isFinite(n) ? n : void 0, u = i.style.flexBasis, d = u === void 0 || u.kind === "auto" ? i.unclampedHeight : u.kind === "cells" ? u.value : u.kind === "percent" && l !== void 0 ? m(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
832
+ let l = Number.isFinite(n) ? n : void 0, u = i.style.flexBasis, d = u === void 0 || u.kind === "auto" ? i.unclampedHeight : u.kind === "cells" ? u.value : u.kind === "percent" && l !== void 0 ? de(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
558
833
  return {
559
834
  node: i,
560
835
  base: d,
@@ -564,31 +839,31 @@ function te(e, t, n, r, i, a, o) {
564
839
  max: K(i.style.maxHeight, l),
565
840
  margin: a
566
841
  };
567
- }), l = s * Math.max(0, c.length - 1), d = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), f = Number.isFinite(n), p = c.reduce((e, t) => e + t.base, 0), h = f ? Math.max(0, n - l - d) : p, g = r ? h : Math.max(h, p), _ = c.some((e) => e.margin.top === null || e.margin.bottom === null), v = f && !(f && _ && p <= g) ? ie(c, g) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
568
- for (let n = 0; n < c.length; n++) if (v[n] !== c[n].node.localRect.height) {
569
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = ae(r.node, e) === "stretch";
570
- V(r.node, i, v[n], 0, 0, a ? "fill" : "shrink", o, { height: v[n] });
571
- }
572
- let y = v.reduce((e, t) => e + t, 0), b = Math.max(0, g - y), x = c.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), S = Array.from({ length: c.length }, () => 0), C = Array.from({ length: c.length }, () => 0), w;
573
- if (x > 0 && b > 0) {
574
- let e = I(Array.from({ length: x }, () => 1), b), t = 0;
575
- for (let n = 0; n < c.length; n++) c[n].margin.top === null && (S[n] = e[t++]), c[n].margin.bottom === null && (C[n] = e[t++]);
576
- w = F("start", v, 0);
577
- } else w = F(le(e.style), v, b);
578
- let T = i.left + a.left, E = i.top + a.top, D = 0;
842
+ }), l = s * Math.max(0, c.length - 1), u = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), d = Number.isFinite(n), f = c.reduce((e, t) => e + t.base, 0), p = d ? Math.max(0, n - l - u) : f, m = r ? p : Math.max(p, f), h = c.some((e) => e.margin.top === null || e.margin.bottom === null), g = d && !(d && h && f <= m) ? Fe(c, m) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
843
+ for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
844
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ie(r.node, e) === "stretch";
845
+ V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
846
+ }
847
+ let _ = g.reduce((e, t) => e + t, 0), v = Math.max(0, m - _), y = c.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), b = Array.from({ length: c.length }, () => 0), x = Array.from({ length: c.length }, () => 0), S;
848
+ if (y > 0 && v > 0) {
849
+ let e = I(Array.from({ length: y }, () => 1), v), t = 0;
850
+ for (let n = 0; n < c.length; n++) c[n].margin.top === null && (b[n] = e[t++]), c[n].margin.bottom === null && (x[n] = e[t++]);
851
+ S = F("start", g, 0);
852
+ } else S = F(Be(e.style), g, v);
853
+ let C = i.left + a.left, w = i.top + a.top, T = 0;
579
854
  for (let n = 0; n < c.length; n++) {
580
855
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
581
- D += S[n] + a, i.localRect = {
856
+ T += b[n] + a, i.localRect = {
582
857
  ...i.localRect,
583
- x: T + re(i, e.style.alignItems, t, r.margin),
584
- y: E + w[n] + n * s + D
585
- }, D += C[n] + o;
858
+ x: C + Pe(i, e.style.alignItems, t, r.margin),
859
+ y: w + S[n] + n * s + T
860
+ }, T += x[n] + o;
586
861
  }
587
- let O = y + l + d, k = f ? Math.max(n, O) : O;
862
+ let E = _ + l + u, D = d ? Math.max(n, E) : E;
588
863
  if (e.style.ruleY && c.length > 1) {
589
864
  let n = [], r = c.map((e) => e.node.localRect).slice().sort((e, t) => e.y - t.y);
590
865
  for (let e = 1; e < r.length; e++) {
591
- let i = r[e - 1].y + r[e - 1].height - E, a = r[e].y - E - i;
866
+ let i = r[e - 1].y + r[e - 1].height - w, a = r[e].y - w - i;
592
867
  a > 0 && n.push({
593
868
  bandStart: i,
594
869
  bandSize: a,
@@ -596,26 +871,26 @@ function te(e, t, n, r, i, a, o) {
596
871
  end: t
597
872
  });
598
873
  }
599
- e.decorationRuns = u({
874
+ e.decorationRuns = ce({
600
875
  ruleX: null,
601
876
  ruleY: e.style.ruleY,
602
877
  vertical: [],
603
- horizontal: N(n, e.style.ruleInset),
878
+ horizontal: ke(n, e.style.ruleInset),
604
879
  contentWidth: t,
605
- contentHeight: k,
880
+ contentHeight: D,
606
881
  border: i,
607
882
  borderStyle: e.style.borderStyle,
608
883
  borderColor: e.style.borderColor,
609
884
  padding: a
610
885
  });
611
886
  }
612
- return ee(e, i, a, t, k), k;
887
+ return je(e, i, a, t, D), D;
613
888
  }
614
- function ne(e, t, n, r) {
889
+ function Ne(e, t, n, r) {
615
890
  let i = e.style.alignSelf === "auto" ? t : e.style.alignSelf, a = r.top ?? 0, o = r.bottom ?? 0, s = n - e.localRect.height, c = r.top === null && r.bottom === null, l = r.top === null && r.bottom !== null, u = r.bottom === null && r.top !== null;
616
891
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.height);
617
892
  }
618
- function re(e, t, n, r) {
893
+ function Pe(e, t, n, r) {
619
894
  let i = e.style.alignSelf === "auto" ? t : e.style.alignSelf, a = r.left ?? 0, o = r.right ?? 0, s = n - e.localRect.width, c = r.left === null && r.right === null, l = r.left === null && r.right !== null, u = r.right === null && r.left !== null;
620
895
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.width);
621
896
  }
@@ -637,7 +912,7 @@ function F(e, t, n) {
637
912
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
638
913
  return i;
639
914
  }
640
- function ie(e, t) {
915
+ function Fe(e, t) {
641
916
  let n = e.length, r = (t, n) => Math.max(0, H(t, e[n].min ?? 0, e[n].max)), i = e.map((e) => e.base), a = t >= i.reduce((e, t, n) => e + r(t, n), 0), o = Array.from({ length: n }, () => 0), s = Array.from({ length: n }, () => !1);
642
917
  for (let t = 0; t < n; t++) {
643
918
  let n = r(i[t], t);
@@ -672,33 +947,33 @@ function I(e, t) {
672
947
  }
673
948
  return i;
674
949
  }
675
- function ae(e, t) {
950
+ function Ie(e, t) {
676
951
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
677
952
  }
678
953
  function L(e, t, n) {
679
954
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
680
955
  }
681
- function oe(e, t, n) {
956
+ function Le(e, t, n) {
682
957
  let r = e.style.flexBasis, i = e.style.width;
683
958
  return r !== void 0 && r.kind !== "auto" ? q(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? q(i, t, e, n) : J(e, n);
684
959
  }
685
- function se(e) {
960
+ function Re(e) {
686
961
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
687
962
  return e.style.flexReverse && t.reverse(), t;
688
963
  }
689
- function ce(e) {
964
+ function ze(e) {
690
965
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
691
966
  }
692
- function le(e) {
967
+ function Be(e) {
693
968
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
694
969
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
695
970
  }
696
- function ue(e, t, n) {
971
+ function Ve(e, t, n) {
697
972
  return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
698
973
  }
699
974
  //#endregion
700
975
  //#region src/types.ts
701
- function de() {
976
+ function He() {
702
977
  return {
703
978
  display: "block",
704
979
  flexDirection: "row",
@@ -717,8 +992,8 @@ function de() {
717
992
  justifySelf: "auto",
718
993
  gridTemplateColumns: { kind: "none" },
719
994
  gridTemplateRows: { kind: "none" },
720
- gridAutoColumns: [fe()],
721
- gridAutoRows: [fe()],
995
+ gridAutoColumns: [Ue()],
996
+ gridAutoRows: [Ue()],
722
997
  gridAutoFlow: {
723
998
  direction: "row",
724
999
  dense: !1
@@ -785,6 +1060,7 @@ function de() {
785
1060
  borderSpacingY: 0,
786
1061
  captionSide: "top",
787
1062
  verticalAlign: "start",
1063
+ opacity: 1,
788
1064
  zIndex: null,
789
1065
  latticeBorder: null,
790
1066
  ruleX: null,
@@ -809,7 +1085,7 @@ function R() {
809
1085
  left: 0
810
1086
  };
811
1087
  }
812
- function fe() {
1088
+ function Ue() {
813
1089
  return {
814
1090
  min: { kind: "auto" },
815
1091
  max: { kind: "auto" }
@@ -817,15 +1093,15 @@ function fe() {
817
1093
  }
818
1094
  //#endregion
819
1095
  //#region src/grid.ts
820
- function pe(e, t, n, r, i, a) {
821
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, d = e.subgrid?.rows, f = c ? c.gap : U(o, "x", t), p = d ? d.gap : U(o, "y", s), m = Ce(e, t, s, f, p, e.subgrid ? {
1096
+ function We(e, t, n, r, i, a) {
1097
+ let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : U(o, "x", t), d = l ? l.gap : U(o, "y", s), f = et(e, t, s, u, d, e.subgrid ? {
822
1098
  col: e.subgrid.colSpan,
823
1099
  row: e.subgrid.rowSpan
824
- } : void 0), { children: h, placed: g, colLines: _, rowLines: v, colTracks: y, rowTracks: b, colCollapsed: x, rowCollapsed: S } = m, C = h.map((e) => G(e.style.margin, t)), w = h.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), T = h.map(me), E = c ? ge(c) : ze(y, x, _e(m, T, C, a), t, f, o.justifyContent === "stretch"), D = c ? c.positions : Be(E, t, o.justifyContent), O = [];
825
- for (let e = 0; e < h.length; e++) {
826
- let t = h[e], n = g.items[e], r = He(D, E.sizes, n.col.start, n.col.span), i = C[e], o = Math.max(0, r - De(i)), s = T[e];
1100
+ } : void 0), { children: p, placed: m, colLines: h, rowLines: g, colTracks: _, rowTracks: v, colCollapsed: y, rowCollapsed: b } = f, x = p.map((e) => G(e.style.margin, t)), S = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), C = p.map(Ge), w = c ? qe(c) : gt(_, y, Je(f, C, x, a), t, u, o.justifyContent === "stretch"), T = c ? c.positions : _t(w, t, o.justifyContent), E = [];
1101
+ for (let e = 0; e < p.length; e++) {
1102
+ let t = p[e], n = m.items[e], r = yt(T, w.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - it(i)), s = C[e];
827
1103
  if (s.cols || s.rows) {
828
- let e = s.cols ? he(D, E, f, n.col.start, n.col.span, ye(t, "cols", i, r)) : void 0;
1104
+ let e = s.cols ? Ke(T, w, u, n.col.start, n.col.span, Xe(t, "cols", i, r)) : void 0;
829
1105
  t.subgrid = {
830
1106
  colSpan: n.col.span,
831
1107
  rowSpan: n.row.span,
@@ -833,84 +1109,84 @@ function pe(e, t, n, r, i, a) {
833
1109
  rows: void 0
834
1110
  };
835
1111
  } else t.subgrid = void 0;
836
- let c = w[e], l = i.left === null || i.right === null, u = t.style.width !== void 0 && t.style.width.kind !== "auto";
837
- s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !u ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Xt(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), O.push(t.localRect.width);
838
- }
839
- let k = d ? ge(d) : ze(b, S, ve(m, T, C), s ?? "max-content", p, o.alignContent === "stretch"), A = Ve(k), j = d ? d.positions : Be(k, s ?? A, o.alignContent), M = r.left + i.left, N = r.top + i.top;
840
- for (let t = 0; t < h.length; t++) {
841
- let n = h[t], r = g.items[t], i = C[t], o = He(D, E.sizes, r.col.start, r.col.span), s = He(j, k.sizes, r.row.start, r.row.span), c = Math.max(0, s - Oe(i)), l = ae(n, e), u = i.top === null || i.bottom === null, d = n.style.height !== void 0 && n.style.height.kind !== "auto";
842
- if (T[t].rows) n.subgrid.rows = he(j, k, p, r.row.start, r.row.span, ye(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
843
- width: O[t],
1112
+ let c = S[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1113
+ s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, On(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), E.push(t.localRect.width);
1114
+ }
1115
+ let D = l ? qe(l) : gt(v, b, Ye(f, C, x), s ?? "max-content", d, o.alignContent === "stretch"), ee = vt(D), O = l ? l.positions : _t(D, s ?? ee, o.alignContent), k = r.left + i.left, A = r.top + i.top;
1116
+ for (let t = 0; t < p.length; t++) {
1117
+ let n = p[t], r = m.items[t], i = x[t], o = yt(T, w.sizes, r.col.start, r.col.span), s = yt(O, D.sizes, r.row.start, r.row.span), c = Math.max(0, s - at(i)), l = Ie(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1118
+ if (C[t].rows) n.subgrid.rows = Ke(O, D, d, r.row.start, r.row.span, Xe(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1119
+ width: E[t],
844
1120
  height: c
845
1121
  });
846
- else if (l === "stretch" && !u && !d) {
1122
+ else if (l === "stretch" && !u && !f) {
847
1123
  let e = H(c, n.style.minHeight === "auto" ? n.style.overflow === "visible" ? n.localRect.height : 0 : K(n.style.minHeight, s) ?? 0, K(n.style.maxHeight, s));
848
1124
  e !== n.localRect.height && V(n, o, s, 0, 0, "fill", a, {
849
- width: O[t],
1125
+ width: E[t],
850
1126
  height: e
851
1127
  });
852
- } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: O[t] });
1128
+ } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: E[t] });
853
1129
  n.localRect = {
854
1130
  ...n.localRect,
855
- x: M + D[r.col.start] + Ue(w[t], i.left, i.right, o, n.localRect.width),
856
- y: N + j[r.row.start] + Ue(l, i.top, i.bottom, s, n.localRect.height)
1131
+ x: k + T[r.col.start] + bt(S[t], i.left, i.right, o, n.localRect.width),
1132
+ y: A + O[r.row.start] + bt(l, i.top, i.bottom, s, n.localRect.height)
857
1133
  };
858
1134
  }
859
- let P = Number.isFinite(n) ? Math.max(n, A) : A;
1135
+ let j = Number.isFinite(n) ? Math.max(n, ee) : ee;
860
1136
  if (o.ruleX || o.ruleY) {
861
- let n = E.sizes.length, a = k.sizes.length, s = Array.from({ length: n }, () => Array.from({ length: a }, () => !1)), c = Array.from({ length: Math.max(0, n - 1) }, () => Array.from({ length: a }, () => !1)), d = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
862
- for (let e of g.items) for (let t = e.col.start; t < e.col.start + e.col.span && t < n; t++) for (let r = e.row.start; r < e.row.start + e.row.span && r < a; r++) s[t][r] = !0, t + 1 < e.col.start + e.col.span && t < n - 1 && (c[t][r] = !0), r + 1 < e.row.start + e.row.span && r < a - 1 && (d[r][t] = !0);
863
- let f = (e, t, n, r, i, a) => t.map((t, o) => ({
1137
+ let n = w.sizes.length, a = D.sizes.length, s = Array.from({ length: n }, () => Array.from({ length: a }, () => !1)), c = Array.from({ length: Math.max(0, n - 1) }, () => Array.from({ length: a }, () => !1)), l = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
1138
+ for (let e of m.items) for (let t = e.col.start; t < e.col.start + e.col.span && t < n; t++) for (let r = e.row.start; r < e.row.start + e.row.span && r < a; r++) s[t][r] = !0, t + 1 < e.col.start + e.col.span && t < n - 1 && (c[t][r] = !0), r + 1 < e.row.start + e.row.span && r < a - 1 && (l[r][t] = !0);
1139
+ let u = (e, t, n, r, i, a) => t.map((t, o) => ({
864
1140
  start: t,
865
1141
  end: t + n[o],
866
1142
  spanned: r[e]?.[o] ?? !1,
867
1143
  beforeOccupied: i(o),
868
1144
  afterOccupied: a(o)
869
- })), p = (e, t, n) => {
1145
+ })), d = (e, t, n) => {
870
1146
  let r = [];
871
1147
  for (let i = 1; i < e.length; i++) {
872
1148
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
873
- if (!(s <= 0)) for (let e of l(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1149
+ if (!(s <= 0)) for (let e of se(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
874
1150
  bandStart: a,
875
1151
  bandSize: s,
876
1152
  ...e
877
1153
  });
878
1154
  }
879
1155
  return r;
880
- }, m = p(D, E.sizes, (e) => f(e, j, k.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), h = p(j, k.sizes, (e) => f(e, D, E.sizes, d, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
881
- e.decorationRuns = u({
1156
+ }, f = d(T, w.sizes, (e) => u(e, O, D.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), p = d(O, D.sizes, (e) => u(e, T, w.sizes, l, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
1157
+ e.decorationRuns = ce({
882
1158
  ruleX: o.ruleX,
883
1159
  ruleY: o.ruleY,
884
- vertical: m,
885
- horizontal: h,
1160
+ vertical: f,
1161
+ horizontal: p,
886
1162
  contentWidth: t,
887
- contentHeight: P,
1163
+ contentHeight: j,
888
1164
  border: r,
889
1165
  borderStyle: o.borderStyle,
890
1166
  borderColor: o.borderColor,
891
1167
  padding: i
892
1168
  });
893
1169
  }
894
- let ee = e.children.filter((e) => B(e.style));
895
- if (ee.length > 0) {
1170
+ let te = e.children.filter((e) => B(e.style));
1171
+ if (te.length > 0) {
896
1172
  let e = B(o) ? {
897
1173
  x: r.left,
898
1174
  y: r.top,
899
1175
  width: i.left + t + i.right,
900
- height: i.top + P + i.bottom
1176
+ height: i.top + j + i.bottom
901
1177
  } : {
902
- x: M,
903
- y: N,
1178
+ x: k,
1179
+ y: A,
904
1180
  width: t,
905
- height: P
1181
+ height: j
906
1182
  };
907
- for (let n of ee) {
908
- let r = xe(n.style.gridColumnStart, n.style.gridColumnEnd, _, g.colOrigin, D, E.sizes, -i.left, t + i.right), a = xe(n.style.gridRowStart, n.style.gridRowEnd, v, g.rowOrigin, j, k.sizes, -i.top, P + i.bottom);
1183
+ for (let n of te) {
1184
+ let r = Qe(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, T, w.sizes, -i.left, t + i.right), a = Qe(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, O, D.sizes, -i.top, j + i.bottom);
909
1185
  n.staticSlot = {
910
1186
  kind: "grid",
911
1187
  area: {
912
- x: M + r.start,
913
- y: N + a.start,
1188
+ x: k + r.start,
1189
+ y: A + a.start,
914
1190
  width: Math.max(0, r.end - r.start),
915
1191
  height: Math.max(0, a.end - a.start)
916
1192
  },
@@ -918,16 +1194,16 @@ function pe(e, t, n, r, i, a) {
918
1194
  };
919
1195
  }
920
1196
  }
921
- return P;
1197
+ return j;
922
1198
  }
923
- function me(e) {
1199
+ function Ge(e) {
924
1200
  let t = e.style.display === "grid";
925
1201
  return {
926
1202
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
927
1203
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
928
1204
  };
929
1205
  }
930
- function he(e, t, n, r, i, a) {
1206
+ function Ke(e, t, n, r, i, a) {
931
1207
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
932
1208
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
933
1209
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -936,20 +1212,20 @@ function he(e, t, n, r, i, a) {
936
1212
  gap: n
937
1213
  };
938
1214
  }
939
- function ge(e) {
1215
+ function qe(e) {
940
1216
  return {
941
1217
  sizes: e.sizes,
942
1218
  gapBefore: e.gapBefore,
943
1219
  limits: e.sizes
944
1220
  };
945
1221
  }
946
- function _e(e, t, n, r) {
1222
+ function Je(e, t, n, r) {
947
1223
  let i = [];
948
1224
  return e.children.forEach((a, o) => {
949
1225
  let s = e.placed.items[o], c = n[o];
950
1226
  if (t[o].cols) {
951
- let e = ye(a, "cols", c, 0);
952
- for (let t of be(a, "cols", s, e, r)) i.push({
1227
+ let e = Xe(a, "cols", c, 0);
1228
+ for (let t of Ze(a, "cols", s, e, r)) i.push({
953
1229
  ...t,
954
1230
  start: t.start + s.col.start
955
1231
  });
@@ -958,24 +1234,24 @@ function _e(e, t, n, r) {
958
1234
  i.push({
959
1235
  start: s.col.start,
960
1236
  span: s.col.span,
961
- min: ke(a, "min", r) + De(c),
962
- max: ke(a, "max", r) + De(c)
1237
+ min: ot(a, "min", r) + it(c),
1238
+ max: ot(a, "max", r) + it(c)
963
1239
  });
964
1240
  }), i;
965
1241
  }
966
- function ve(e, t, n) {
1242
+ function Ye(e, t, n) {
967
1243
  let r = [];
968
1244
  return e.children.forEach((i, a) => {
969
1245
  let o = e.placed.items[a], s = n[a];
970
1246
  if (t[a].rows) {
971
- let e = ye(i, "rows", s, 0);
972
- for (let t of be(i, "rows", o, e)) r.push({
1247
+ let e = Xe(i, "rows", s, 0);
1248
+ for (let t of Ze(i, "rows", o, e)) r.push({
973
1249
  ...t,
974
1250
  start: t.start + o.row.start
975
1251
  });
976
1252
  return;
977
1253
  }
978
- let c = i.localRect.height + Oe(s);
1254
+ let c = i.localRect.height + at(s);
979
1255
  r.push({
980
1256
  start: o.row.start,
981
1257
  span: o.row.span,
@@ -984,7 +1260,7 @@ function ve(e, t, n) {
984
1260
  });
985
1261
  }), r;
986
1262
  }
987
- function ye(e, t, n, r) {
1263
+ function Xe(e, t, n, r) {
988
1264
  let { border: i, padding: a } = e.style;
989
1265
  return t === "cols" ? {
990
1266
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -994,15 +1270,15 @@ function ye(e, t, n, r) {
994
1270
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
995
1271
  };
996
1272
  }
997
- function be(e, t, n, r, i) {
998
- let a = t === "cols" ? n.col.span : n.row.span, o = Ce(e, void 0, void 0, 0, 0, {
1273
+ function Ze(e, t, n, r, i) {
1274
+ let a = t === "cols" ? n.col.span : n.row.span, o = et(e, void 0, void 0, 0, 0, {
999
1275
  col: n.col.span,
1000
1276
  row: n.row.span
1001
1277
  }), s = [];
1002
1278
  if (o.children.forEach((e, n) => {
1003
1279
  let c = o.placed.items[n], l = t === "cols" ? c.col : c.row, u = l.start === 0, d = l.start + l.span === a, f = (u ? r.start : 0) + (d ? r.end : 0), p = G(e.style.margin, 0);
1004
- if (me(e)[t]) {
1005
- let n = ye(e, t, p, 0), a = be(e, t, c, {
1280
+ if (Ge(e)[t]) {
1281
+ let n = Xe(e, t, p, 0), a = Ze(e, t, c, {
1006
1282
  start: n.start + (u ? r.start : 0),
1007
1283
  end: n.end + (d ? r.end : 0)
1008
1284
  }, i);
@@ -1015,11 +1291,11 @@ function be(e, t, n, r, i) {
1015
1291
  if (t === "cols") s.push({
1016
1292
  start: l.start,
1017
1293
  span: l.span,
1018
- min: ke(e, "min", i) + De(p) + f,
1019
- max: ke(e, "max", i) + De(p) + f
1294
+ min: ot(e, "min", i) + it(p) + f,
1295
+ max: ot(e, "max", i) + it(p) + f
1020
1296
  });
1021
1297
  else {
1022
- let t = e.localRect.height + Oe(p) + f;
1298
+ let t = e.localRect.height + at(p) + f;
1023
1299
  s.push({
1024
1300
  start: l.start,
1025
1301
  span: l.span,
@@ -1038,9 +1314,9 @@ function be(e, t, n, r, i) {
1038
1314
  }
1039
1315
  return s;
1040
1316
  }
1041
- function xe(e, t, n, r, i, a, o, s) {
1042
- let c = Fe(e, "start", n), l = Fe(t, "end", n);
1043
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = Ie(c, t, 1, n) : l !== null && e.kind === "span" && (c = Ie(l, e, -1, n));
1317
+ function Qe(e, t, n, r, i, a, o, s) {
1318
+ let c = ft(e, "start", n), l = ft(t, "end", n);
1319
+ c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = pt(c, t, 1, n) : l !== null && e.kind === "span" && (c = pt(l, e, -1, n));
1044
1320
  let u = i.length, d = (e) => {
1045
1321
  if (e === null) return;
1046
1322
  let t = e - r;
@@ -1051,22 +1327,22 @@ function xe(e, t, n, r, i, a, o, s) {
1051
1327
  end: h === void 0 ? s : p(h)
1052
1328
  };
1053
1329
  }
1054
- function Se(e, t) {
1330
+ function $e(e, t) {
1055
1331
  let n = t.gridIntrinsic.get(e);
1056
1332
  if (n !== void 0) return n;
1057
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = Ce(e, void 0, void 0, i, 0, e.subgrid ? {
1333
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = et(e, void 0, void 0, i, 0, e.subgrid ? {
1058
1334
  col: e.subgrid.colSpan,
1059
1335
  row: e.subgrid.rowSpan
1060
- } : void 0), o = a.children.map(me), s = a.children.map((e) => G(e.style.margin, 0)), c = ze(a.colTracks, a.colCollapsed, _e(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1336
+ } : void 0), o = a.children.map(Ge), s = a.children.map((e) => G(e.style.margin, 0)), c = gt(a.colTracks, a.colCollapsed, Je(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1061
1337
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1062
1338
  max: c.limits.reduce((e, t) => e + t, 0) + l
1063
1339
  };
1064
1340
  return t.gridIntrinsic.set(e, u), u;
1065
1341
  }
1066
- function Ce(e, t, n, r, i, a) {
1067
- let o = e.style, s = Ee(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? we(a.col) : Ae(o.gridTemplateColumns, t, r), d = l ? we(a.row) : Ae(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1342
+ function et(e, t, n, r, i, a) {
1343
+ let o = e.style, s = rt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? tt(a.col) : st(o.gridTemplateColumns, t, r), d = l ? tt(a.row) : st(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1068
1344
  if (f) {
1069
- c || Me(p, u.lineNames, f.columns, o.gridAutoColumns), l || Me(m, d.lineNames, f.rows, o.gridAutoRows);
1345
+ c || lt(p, u.lineNames, f.columns, o.gridAutoColumns), l || lt(m, d.lineNames, f.rows, o.gridAutoRows);
1070
1346
  for (let [e, t] of f.areas) u.lineNames[Math.min(t.colStart, p.length)].push(`${e}-start`), u.lineNames[Math.min(t.colEnd, p.length)].push(`${e}-end`), d.lineNames[Math.min(t.rowStart, m.length)].push(`${e}-start`), d.lineNames[Math.min(t.rowEnd, m.length)].push(`${e}-end`);
1071
1347
  }
1072
1348
  let h = {
@@ -1075,28 +1351,28 @@ function Ce(e, t, n, r, i, a) {
1075
1351
  }, g = {
1076
1352
  explicitCount: m.length,
1077
1353
  names: d.lineNames
1078
- }, _ = Re(s.map((e) => ({
1079
- col: Le(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1080
- row: Le(e.style.gridRowStart, e.style.gridRowEnd, g)
1354
+ }, _ = ht(s.map((e) => ({
1355
+ col: mt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1356
+ row: mt(e.style.gridRowStart, e.style.gridRowEnd, g)
1081
1357
  })), p.length, m.length, o.gridAutoFlow);
1082
- return c && Te(_, "col", p.length), l && Te(_, "row", m.length), {
1358
+ return c && nt(_, "col", p.length), l && nt(_, "row", m.length), {
1083
1359
  children: s,
1084
1360
  placed: _,
1085
1361
  colLines: h,
1086
1362
  rowLines: g,
1087
- colTracks: Ne(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1088
- rowTracks: Ne(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1089
- colCollapsed: Pe(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1090
- rowCollapsed: Pe(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1363
+ colTracks: ut(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1364
+ rowTracks: ut(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1365
+ colCollapsed: dt(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1366
+ rowCollapsed: dt(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1091
1367
  };
1092
1368
  }
1093
- function we(e) {
1369
+ function tt(e) {
1094
1370
  return {
1095
- tracks: Array.from({ length: e }, () => fe()),
1371
+ tracks: Array.from({ length: e }, () => Ue()),
1096
1372
  lineNames: Array.from({ length: e + 1 }, () => [])
1097
1373
  };
1098
1374
  }
1099
- function Te(e, t, n) {
1375
+ function nt(e, t, n) {
1100
1376
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1101
1377
  for (let i of e.items) {
1102
1378
  let e = i[t], a = Math.min(Math.max(e.start + r, 0), n - 1), o = Math.min(Math.max(e.start + r + e.span, a + 1), n);
@@ -1104,22 +1380,22 @@ function Te(e, t, n) {
1104
1380
  }
1105
1381
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1106
1382
  }
1107
- function Ee(e) {
1383
+ function rt(e) {
1108
1384
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1109
1385
  }
1110
- function De(e) {
1386
+ function it(e) {
1111
1387
  return (e.left ?? 0) + (e.right ?? 0);
1112
1388
  }
1113
- function Oe(e) {
1389
+ function at(e) {
1114
1390
  return (e.top ?? 0) + (e.bottom ?? 0);
1115
1391
  }
1116
- function ke(e, t, n) {
1392
+ function ot(e, t, n) {
1117
1393
  let r = e.style, i;
1118
1394
  r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = q(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? Y(e, n) : J(e, n));
1119
1395
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1120
1396
  return Math.max(0, H(i, a, o));
1121
1397
  }
1122
- function Ae(e, t, n) {
1398
+ function st(e, t, n) {
1123
1399
  if (e.kind !== "tracks") return {
1124
1400
  tracks: [],
1125
1401
  lineNames: [[]]
@@ -1132,7 +1408,7 @@ function Ae(e, t, n) {
1132
1408
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1133
1409
  if (t !== void 0) {
1134
1410
  let e = a.reduce((e, n) => {
1135
- let r = je(n.min, t) ?? je(n.max, t) ?? 1;
1411
+ let r = ct(n.min, t) ?? ct(n.max, t) ?? 1;
1136
1412
  return e + Math.max(1, r);
1137
1413
  }, 0);
1138
1414
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1160,23 +1436,23 @@ function Ae(e, t, n) {
1160
1436
  lineNames: d
1161
1437
  };
1162
1438
  }
1163
- function je(e, t) {
1439
+ function ct(e, t) {
1164
1440
  if (e.kind === "cells") return e.value;
1165
- if (e.kind === "percent" && t !== void 0) return m(e.value, t);
1441
+ if (e.kind === "percent" && t !== void 0) return de(e.value, t);
1166
1442
  if (e.kind === "math") {
1167
1443
  let n = [];
1168
1444
  for (let r of e.args) {
1169
- let e = je(r, t);
1445
+ let e = ct(r, t);
1170
1446
  if (e === void 0) return;
1171
1447
  n.push(e);
1172
1448
  }
1173
1449
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1174
1450
  }
1175
1451
  }
1176
- function Me(e, t, n, r) {
1452
+ function lt(e, t, n, r) {
1177
1453
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1178
1454
  }
1179
- function Ne(e, t, n, r) {
1455
+ function ut(e, t, n, r) {
1180
1456
  let i = [];
1181
1457
  for (let a = 0; a < n; a++) {
1182
1458
  let n = a + t;
@@ -1188,7 +1464,7 @@ function Ne(e, t, n, r) {
1188
1464
  }
1189
1465
  return i;
1190
1466
  }
1191
- function Pe(e, t, n, r) {
1467
+ function dt(e, t, n, r) {
1192
1468
  let i = Array.from({ length: n }, () => !1);
1193
1469
  if (!e.autoFit) return i;
1194
1470
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1197,7 +1473,7 @@ function Pe(e, t, n, r) {
1197
1473
  }
1198
1474
  return i;
1199
1475
  }
1200
- function Fe(e, t, n) {
1476
+ function ft(e, t, n) {
1201
1477
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1202
1478
  if (e.kind !== "name") return null;
1203
1479
  if (e.nth === void 0) {
@@ -1212,14 +1488,14 @@ function Fe(e, t, n) {
1212
1488
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1213
1489
  return -(-r - a);
1214
1490
  }
1215
- function Ie(e, t, n, r) {
1491
+ function pt(e, t, n, r) {
1216
1492
  if (t.name === void 0) return e + n * t.value;
1217
1493
  let i = t.value, a = e;
1218
1494
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1219
1495
  return a;
1220
1496
  }
1221
- function Le(e, t, n) {
1222
- let r = Fe(e, "start", n), i = Fe(t, "end", n);
1497
+ function mt(e, t, n) {
1498
+ let r = ft(e, "start", n), i = ft(t, "end", n);
1223
1499
  if (r !== null && i !== null) return r === i ? {
1224
1500
  start: r,
1225
1501
  span: 1
@@ -1229,10 +1505,10 @@ function Le(e, t, n) {
1229
1505
  };
1230
1506
  if (r !== null) return {
1231
1507
  start: r,
1232
- span: (t.kind === "span" ? Ie(r, t, 1, n) : r + 1) - r
1508
+ span: (t.kind === "span" ? pt(r, t, 1, n) : r + 1) - r
1233
1509
  };
1234
1510
  if (i !== null) {
1235
- let t = e.kind === "span" ? Ie(i, e, -1, n) : i - 1;
1511
+ let t = e.kind === "span" ? pt(i, e, -1, n) : i - 1;
1236
1512
  return {
1237
1513
  start: t,
1238
1514
  span: i - t
@@ -1243,7 +1519,7 @@ function Le(e, t, n) {
1243
1519
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1244
1520
  };
1245
1521
  }
1246
- function Re(e, t, n, r) {
1522
+ function ht(e, t, n, r) {
1247
1523
  let i = r.direction === "row", a = e.map((e) => i ? e.row : e.col), o = e.map((e) => i ? e.col : e.row), s = i ? t : n, c = i ? n : t, l = 0, u = Math.max(s, 1);
1248
1524
  for (let t = 0; t < e.length; t++) {
1249
1525
  let e = o[t];
@@ -1340,7 +1616,7 @@ function Re(e, t, n, r) {
1340
1616
  rowCount: S
1341
1617
  };
1342
1618
  }
1343
- function ze(e, t, n, r, i, a) {
1619
+ function gt(e, t, n, r, i, a) {
1344
1620
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1345
1621
  if (t[n]) return {
1346
1622
  base: 0,
@@ -1350,7 +1626,7 @@ function ze(e, t, n, r, i, a) {
1350
1626
  frFactor: 0,
1351
1627
  collapsed: !0
1352
1628
  };
1353
- let r = je(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1629
+ let r = ct(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1354
1630
  if (s.kind === "fr") return {
1355
1631
  base: i,
1356
1632
  limit: null,
@@ -1359,7 +1635,7 @@ function ze(e, t, n, r, i, a) {
1359
1635
  frFactor: s.value,
1360
1636
  collapsed: !1
1361
1637
  };
1362
- let c = je(s, o);
1638
+ let c = ct(s, o);
1363
1639
  return c === void 0 ? {
1364
1640
  base: i,
1365
1641
  limit: null,
@@ -1437,7 +1713,7 @@ function ze(e, t, n, r, i, a) {
1437
1713
  n <= 0 || (t = Math.max(t, (e.max - r) / Math.max(n, 1)));
1438
1714
  }
1439
1715
  for (let n of e) {
1440
- let e = Math.max(n.base, f(n.frFactor * t));
1716
+ let e = Math.max(n.base, M(n.frFactor * t));
1441
1717
  n.limit = e, r === "max-content" && (n.base = e);
1442
1718
  }
1443
1719
  }
@@ -1484,62 +1760,62 @@ function ze(e, t, n, r, i, a) {
1484
1760
  limits: s.map((e) => u(e))
1485
1761
  };
1486
1762
  }
1487
- function Be(e, t, n) {
1488
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Ve(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1763
+ function _t(e, t, n) {
1764
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - vt(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1489
1765
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1490
1766
  return s;
1491
1767
  }
1492
- function Ve(e) {
1768
+ function vt(e) {
1493
1769
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1494
1770
  }
1495
- function He(e, t, n, r) {
1771
+ function yt(e, t, n, r) {
1496
1772
  let i = n + r - 1;
1497
1773
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1498
1774
  }
1499
- function Ue(e, t, n, r, i) {
1775
+ function bt(e, t, n, r, i) {
1500
1776
  let a = t ?? 0, o = n ?? 0, s = r - i;
1501
1777
  return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + L(e, r, i + a + o);
1502
1778
  }
1503
1779
  //#endregion
1504
1780
  //#region src/multicol.ts
1505
- function We(e, t, n) {
1781
+ function xt(e, t, n) {
1506
1782
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1507
1783
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1508
1784
  }
1509
- function Ge(e, t, n) {
1510
- let r = We(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1785
+ function St(e, t, n) {
1786
+ let r = xt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1511
1787
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1512
1788
  }
1513
- function Ke(e, t) {
1789
+ function Ct(e, t) {
1514
1790
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1515
1791
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1516
1792
  }
1517
- function qe(e, t) {
1793
+ function wt(e, t) {
1518
1794
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1519
1795
  }
1520
- function Je(e, t, n) {
1796
+ function Tt(e, t, n) {
1521
1797
  for (; e < t;) {
1522
1798
  let r = e + t >> 1;
1523
1799
  n(r) ? t = r : e = r + 1;
1524
1800
  }
1525
1801
  return e;
1526
1802
  }
1527
- function Ye(e, t, n) {
1528
- let r = We(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1803
+ function Et(e, t, n) {
1804
+ let r = xt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1529
1805
  return {
1530
1806
  count: r,
1531
1807
  width: i,
1532
1808
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1533
1809
  };
1534
1810
  }
1535
- function Xe(e, t, n) {
1811
+ function Dt(e, t, n) {
1536
1812
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1537
1813
  }
1538
- function Ze(e, t, n, r) {
1539
- let i = qt(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Jt(e, i), s = e.style.lineGap, c = Qe(a.map((e) => e + s)), l;
1814
+ function Ot(e, t, n, r) {
1815
+ let i = Tn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = En(e, i), s = e.style.lineGap, c = kt(a.map((e) => e + s)), l;
1540
1816
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1541
1817
  else {
1542
- let e = Je(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => z(c, s, e).columns <= t.count);
1818
+ let e = Tt(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => z(c, s, e).columns <= t.count);
1543
1819
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1544
1820
  }
1545
1821
  let u = z(c, s, l);
@@ -1555,47 +1831,57 @@ function Ze(e, t, n, r) {
1555
1831
  columnsUsed: i.length > 0 ? u.columns : 0
1556
1832
  };
1557
1833
  }
1558
- function z(e, t, n) {
1559
- let r = 0, i = 0, a = 0, o = [], s = [];
1560
- for (let c = 0; c < e.length; c++) {
1561
- let l = e[c], u = c === 0 || i > 0 ? l.pre : 0;
1562
- i > 0 && (l.forced || i + u + l.rows - t > n) && (r += 1, i = 0, u = 0);
1563
- let d = l.rows / l.lines;
1564
- if (l.lines > 1 && l.rows - t > n) {
1565
- for (let e = 0; e < l.lines; e++) i > 0 && i + u + d - t > n && (r += 1, i = 0, u = 0), o.push(r), s.push(i + u), i += u + d, u = 0, a = Math.max(a, i - t);
1834
+ function z(e, t, n, r = "truncate") {
1835
+ let i = 0, a = 0, o = 0, s = [], c = [];
1836
+ for (let l = 0; l < e.length; l++) {
1837
+ let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
1838
+ a > 0 && (u.forced || a + d + u.rows + u.post - t > n) && (r === "truncate" && (d = 0), i += 1, a = 0);
1839
+ let f = u.rows / u.lines;
1840
+ if (u.lines > 1 && u.rows - t > n) {
1841
+ for (let e = 0; e < u.lines; e++) a > 0 && a + d + f - t > n && (r === "truncate" && (d = 0), i += 1, a = 0), s.push(i), c.push(a + d), a += d + f, d = 0, o = Math.max(o, a - t);
1842
+ a += u.post, u.post > 0 && (o = Math.max(o, a));
1566
1843
  continue;
1567
1844
  }
1568
- for (let e = 0; e < l.lines; e++) o.push(r), s.push(i + u + e * d);
1569
- i += u + l.rows, a = Math.max(a, i - t);
1845
+ for (let e = 0; e < u.lines; e++) s.push(i), c.push(a + d + e * f);
1846
+ a += d + u.rows + u.post, o = Math.max(o, a - (u.post > 0 ? 0 : t));
1570
1847
  }
1571
1848
  return {
1572
- columns: r + 1,
1573
- maxUsed: a,
1574
- column: o,
1575
- top: s
1849
+ columns: i + 1,
1850
+ maxUsed: o,
1851
+ column: s,
1852
+ top: c
1576
1853
  };
1577
1854
  }
1578
- function Qe(e) {
1855
+ function kt(e) {
1579
1856
  return e.map((e) => ({
1580
1857
  rows: e,
1581
1858
  pre: 0,
1859
+ post: 0,
1582
1860
  forced: !1,
1583
1861
  lines: 1
1584
1862
  }));
1585
1863
  }
1586
- function $e(e, t) {
1587
- let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = x(e, Math.max(1, n - i), {
1864
+ var At = null;
1865
+ function jt() {
1866
+ if (At !== null) return At;
1867
+ let e = document.createElement("div");
1868
+ e.style.cssText = "position:absolute;left:-9999px;visibility:hidden;columns:2;column-gap:0;column-fill:balance;width:200px;font:10px/20px monospace;orphans:1;widows:1", e.innerHTML = "<div style=\"margin:0;padding:0 0 20px 0\">aaaaaa aaaaaa aaaaaa</div><div style=\"margin:0\"><span>bbbbbb</span> bbbbbb</div>", document.body.appendChild(e);
1869
+ let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
1870
+ return e.remove(), At = !(n.width > 0 && n.top - t >= 10), At;
1871
+ }
1872
+ function Mt(e, t) {
1873
+ let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = ve(e, Math.max(1, n - i), {
1588
1874
  advances: s,
1589
1875
  tracking: i,
1590
1876
  firstLineIndent: t.firstLineIndent
1591
- }), l = Qe(c.map(() => 1 + a)), u = z(l, a, o ?? Je(1, Math.max(1, c.length * (1 + a) - a), (e) => z(l, a, e).columns <= r));
1877
+ }), l = kt(c.map(() => 1 + a)), u = z(l, a, o ?? Tt(1, Math.max(1, c.length * (1 + a) - a), (e) => z(l, a, e).columns <= r));
1592
1878
  return c.map((t, n) => ({
1593
1879
  text: e.slice(t.start, t.end),
1594
1880
  column: u.column[n],
1595
1881
  top: u.top[n]
1596
1882
  }));
1597
1883
  }
1598
- function et(e, t, n, r) {
1884
+ function Nt(e, t, n, r) {
1599
1885
  let i = e.style;
1600
1886
  if (!i.ruleX) return;
1601
1887
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -1605,17 +1891,17 @@ function et(e, t, n, r) {
1605
1891
  }], s = [];
1606
1892
  for (let e of o) {
1607
1893
  let n = Math.min(e.columns, t.columnCount);
1608
- for (let r = 0; r < t.columnCount - 1; r++) Xe(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1894
+ for (let r = 0; r < t.columnCount - 1; r++) Dt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1609
1895
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
1610
1896
  bandSize: t.gap,
1611
1897
  start: e.start,
1612
1898
  end: e.end
1613
1899
  });
1614
1900
  }
1615
- e.decorationRuns = u({
1901
+ e.decorationRuns = ce({
1616
1902
  ruleX: i.ruleX,
1617
1903
  ruleY: null,
1618
- vertical: N(s, i.ruleInset),
1904
+ vertical: ke(s, i.ruleInset),
1619
1905
  horizontal: [],
1620
1906
  contentWidth: a,
1621
1907
  contentHeight: t.totalRows,
@@ -1625,96 +1911,108 @@ function et(e, t, n, r) {
1625
1911
  padding: r
1626
1912
  });
1627
1913
  }
1628
- function tt(e, t) {
1914
+ function Pt(e, t) {
1629
1915
  let n = e.style, r = n.padding;
1630
1916
  return e.text !== "" && e.children.length === 0 && n.display === "block" && n.position === "static" && !n.columnSpan && n.whiteSpace === "normal" && n.lineGap === t.lineGap && n.border.top === 0 && n.border.right === 0 && n.border.bottom === 0 && n.border.left === 0 && r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0 && n.backgroundColor === void 0 && !n.backgroundClear && (n.width === void 0 || n.width.kind === "auto") && (n.height === void 0 || n.height.kind === "auto") && (n.minWidth === "auto" || n.minWidth === 0 || n.minWidth === void 0) && (n.minHeight === "auto" || n.minHeight === 0 || n.minHeight === void 0) && n.maxWidth === void 0 && n.maxHeight === void 0;
1631
1917
  }
1632
- function nt(e, t, n, r, i, a, o) {
1633
- let s = e.style, c = U(s, "x", n), l = Ye(s, n, c);
1918
+ function Ft(e, t, n, r, i, a, o) {
1919
+ let s = e.style, c = U(s, "x", n), l = Et(s, n, c);
1634
1920
  a.right += l.leftover;
1635
1921
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
1636
1922
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
1637
- let g = m.length > 1, _ = [], v = 0, y = 0;
1923
+ let g = m.length > 1, _ = g ? "glue" : "truncate", v = [], y = 0, b = 0;
1638
1924
  for (let e = 0; e < m.length; e++) {
1639
- let t = m[e];
1925
+ let t = m[e], n = 0;
1640
1926
  if (t.length > 0) {
1641
- let n = t.map((e) => ({
1927
+ let i = t.map((e) => ({
1642
1928
  node: e,
1643
- spans: qt(e, Math.max(1, l.width - e.style.tracking)),
1644
- margin: G(e.style.margin, l.width)
1645
- })), i = [], a = null, o = !1;
1646
- for (let { node: e, spans: t, margin: r } of n) {
1647
- let n = a === null ? r.top ?? 0 : $t(a, r.top ?? 0), s = o || e.style.breakBeforeColumn;
1648
- if (e.style.breakInsideAvoid && t.length > 0) i.push({
1649
- rows: t.length * (1 + u),
1650
- pre: n,
1651
- forced: s,
1652
- lines: t.length
1929
+ spans: Tn(e, Math.max(1, l.width - e.style.tracking)),
1930
+ margin: G(e.style.margin, l.width),
1931
+ pre: 0,
1932
+ post: 0
1933
+ })), a = [], o = null, h = null, x = !1;
1934
+ for (let e of i) {
1935
+ let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : jn(o, r.top ?? 0), s = i;
1936
+ _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
1937
+ let c = x || t.style.breakBeforeColumn;
1938
+ if (t.style.breakInsideAvoid && n.length > 0) a.push({
1939
+ rows: n.length * (1 + u),
1940
+ pre: s,
1941
+ post: 0,
1942
+ forced: c,
1943
+ lines: n.length
1653
1944
  });
1654
- else for (let e = 0; e < t.length; e++) i.push({
1945
+ else for (let e = 0; e < n.length; e++) a.push({
1655
1946
  rows: 1 + u,
1656
- pre: e > 0 ? 0 : n,
1657
- forced: e === 0 && s,
1947
+ pre: e > 0 ? 0 : s,
1948
+ post: 0,
1949
+ forced: e === 0 && c,
1658
1950
  lines: 1
1659
1951
  });
1660
- t.length > 0 && (a = r.bottom ?? 0), o = e.style.breakAfterColumn;
1952
+ n.length > 0 && (o = r.bottom ?? 0, h = e), x = t.style.breakAfterColumn;
1661
1953
  }
1662
- let h;
1663
- if (s.columnFill === "auto" && r !== void 0) h = Math.max(1, r);
1954
+ n = o ?? 0;
1955
+ let S;
1956
+ if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
1664
1957
  else {
1665
- let e = Je(1, Math.max(1, z(i, u, Infinity).maxUsed), (e) => z(i, u, e).columns <= l.count);
1666
- h = r === void 0 ? e : Math.max(1, Math.min(e, r));
1958
+ let e = Tt(1, Math.max(1, z(a, u, Infinity, _).maxUsed), (e) => z(a, u, e, _).columns <= l.count);
1959
+ S = r === void 0 ? e : Math.max(1, Math.min(e, r));
1667
1960
  }
1668
- let g = z(i, u, h);
1669
- for (let e = 0, t = 0; e < n.length; e++) {
1670
- let { node: r, spans: i, margin: a } = n[e], o = [], s = [];
1671
- for (let e = 0; e < i.length; e++, t++) o.push(v + g.top[t]), s.push(g.column[t] * (l.width + c));
1672
- delete r.decorationRuns, r.multicolGeometry = {
1673
- spans: i,
1674
- lineY: o,
1675
- textY: o,
1676
- lineX: s,
1677
- totalRows: v + g.maxUsed,
1961
+ let C = z(a, u, S, _);
1962
+ for (let e = 0, t = 0; e < i.length; e++) {
1963
+ let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
1964
+ for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
1965
+ delete n.decorationRuns, n.multicolGeometry = {
1966
+ spans: r,
1967
+ lineY: u,
1968
+ textY: u,
1969
+ lineX: m,
1970
+ totalRows: y + C.maxUsed,
1678
1971
  columnCount: l.count,
1679
1972
  columnWidth: l.width,
1680
1973
  gap: c,
1681
- columnsUsed: g.columns
1682
- }, r.multicolFlow = a, r.localRect = {
1974
+ columnsUsed: C.columns
1975
+ }, n.multicolFlow = g ? {
1976
+ top: o,
1977
+ right: a.right,
1978
+ bottom: s,
1979
+ left: a.left
1980
+ } : a, n.localRect = {
1683
1981
  x: d,
1684
1982
  y: f,
1685
1983
  width: p,
1686
- height: g.maxUsed
1687
- }, r.resolvedPadding = {
1984
+ height: C.maxUsed
1985
+ }, n.resolvedPadding = {
1688
1986
  top: 0,
1689
1987
  right: 0,
1690
1988
  bottom: 0,
1691
1989
  left: 0
1692
1990
  };
1693
1991
  }
1694
- i.length > 0 && (_.push({
1695
- start: v,
1696
- end: v + g.maxUsed,
1697
- columns: g.columns
1698
- }), y = Math.max(y, g.columns), v += g.maxUsed + (e < m.length - 1 ? u : 0));
1992
+ a.length > 0 && (v.push({
1993
+ start: y,
1994
+ end: y + C.maxUsed,
1995
+ columns: C.columns
1996
+ }), b = Math.max(b, C.columns), y += C.maxUsed + (e < m.length - 1 ? u : 0));
1699
1997
  }
1700
- let n = h[e];
1701
- if (n) {
1702
- let e = G(n.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
1703
- V(n, Math.max(0, p - t), void 0, 0, 0, "fill", o);
1704
- let r = Qt(e, p, n.localRect.width);
1705
- v += e.top ?? 0, n.localRect = {
1706
- ...n.localRect,
1998
+ let i = h[e];
1999
+ if (i) {
2000
+ let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2001
+ V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2002
+ let r = An(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2003
+ y += a, i.localRect = {
2004
+ ...i.localRect,
1707
2005
  x: d + r,
1708
- y: f + v
1709
- }, n.multicolFlowSpan = {
1710
- top: e.top ?? 0,
2006
+ y: f + y
2007
+ }, i.multicolFlowSpan = {
2008
+ top: a,
1711
2009
  right: 0,
1712
2010
  bottom: e.bottom ?? 0,
1713
2011
  left: r
1714
- }, v += n.localRect.height + (e.bottom ?? 0);
2012
+ }, y += i.localRect.height + (e.bottom ?? 0);
1715
2013
  }
1716
2014
  }
1717
- let b = v;
2015
+ let x = y;
1718
2016
  for (let t of e.children) {
1719
2017
  if (!B(t.style)) continue;
1720
2018
  let e = G(t.style.margin, n);
@@ -1729,21 +2027,21 @@ function nt(e, t, n, r, i, a, o) {
1729
2027
  lineY: [],
1730
2028
  textY: [],
1731
2029
  lineX: [],
1732
- totalRows: b,
2030
+ totalRows: x,
1733
2031
  columnCount: l.count,
1734
2032
  columnWidth: l.width,
1735
2033
  gap: c,
1736
- columnsUsed: y,
2034
+ columnsUsed: b,
1737
2035
  ...g ? {
1738
- ruleSegments: _,
2036
+ ruleSegments: v,
1739
2037
  nativeBalance: !0
1740
2038
  } : {}
1741
- }, b;
2039
+ }, x;
1742
2040
  }
1743
- function rt(e, t, n, r, i, a, o) {
1744
- let s = e.style, c = qe(n, r), l = e.children.filter((e) => !B(e.style)), d = l.filter((e) => !e.style.columnSpan);
1745
- if (d.length > 0 && d.every((e) => tt(e, s)) && (d.length === l.length || s.columnFill === "balance" && c === void 0 && d.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null)))) return nt(e, l, t, c, i, a, o);
1746
- let f = U(s, "x", t), p = Ge(s, t, f), m = p.length, h = [];
2041
+ function It(e, t, n, r, i, a, o) {
2042
+ let s = e.style, c = wt(n, r), l = e.children.filter((e) => !B(e.style)), u = l.filter((e) => !e.style.columnSpan), d = l.reduce((e, t, n) => !t.style.columnSpan && (n === 0 || l[n - 1].style.columnSpan) ? e + 1 : e, 0);
2043
+ if (u.length > 0 && u.every((e) => Pt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (jt() || d <= 1 && u.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null))))) return Ft(e, l, t, c, i, a, o);
2044
+ let f = U(s, "x", t), p = St(s, t, f), m = p.length, h = [];
1747
2045
  {
1748
2046
  let e = 0;
1749
2047
  for (let t of p) h.push(e), e += t + f;
@@ -1752,7 +2050,7 @@ function rt(e, t, n, r, i, a, o) {
1752
2050
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
1753
2051
  if (t) for (let t of w) {
1754
2052
  if (t.index !== e) continue;
1755
- let n = a === null ? t.margin.top ?? 0 : $t(a, t.margin.top ?? 0);
2053
+ let n = a === null ? t.margin.top ?? 0 : jn(a, t.margin.top ?? 0);
1756
2054
  t.child.staticSlot = {
1757
2055
  kind: "block",
1758
2056
  x: y + g(r) + (t.margin.left ?? 0),
@@ -1763,7 +2061,7 @@ function rt(e, t, n, r, i, a, o) {
1763
2061
  for (let l = 0; l < C.length; l++) {
1764
2062
  let u = C[l];
1765
2063
  c(l);
1766
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : $t(a, u.margin.top ?? 0), f = u.node.localRect.height;
2064
+ let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : jn(a, u.margin.top ?? 0), f = u.node.localRect.height;
1767
2065
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
1768
2066
  let e = u.node, t = _(r);
1769
2067
  if (t !== v) {
@@ -1772,7 +2070,7 @@ function rt(e, t, n, r, i, a, o) {
1772
2070
  }
1773
2071
  e.localRect = {
1774
2072
  ...e.localRect,
1775
- x: y + g(r) + Qt(u.margin, t, e.localRect.width),
2073
+ x: y + g(r) + An(u.margin, t, e.localRect.width),
1776
2074
  y: b + S + i + d
1777
2075
  };
1778
2076
  }
@@ -1795,13 +2093,13 @@ function rt(e, t, n, r, i, a, o) {
1795
2093
  let e = c === void 0 ? void 0 : Math.max(1, c - S), t = s.columnFill === "auto" && e !== void 0, r;
1796
2094
  if (t) r = e;
1797
2095
  else {
1798
- let t = Je(1, E(Infinity, !1).maxUsed, (e) => E(e, !1).columns <= m);
2096
+ let t = Tt(1, E(Infinity, !1).maxUsed, (e) => E(e, !1).columns <= m);
1799
2097
  r = e === void 0 ? t : Math.min(t, e);
1800
2098
  }
1801
2099
  let i = E(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
1802
2100
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
1803
2101
  let t = Math.min(i.columns, m);
1804
- Xe(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2102
+ Dt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
1805
2103
  bandStart: h[e] + p[e],
1806
2104
  bandSize: f,
1807
2105
  start: S,
@@ -1824,7 +2122,7 @@ function rt(e, t, n, r, i, a, o) {
1824
2122
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
1825
2123
  V(r, Math.max(0, t - i), n, 0, 0, "fill", o), S += e.top ?? 0, r.localRect = {
1826
2124
  ...r.localRect,
1827
- x: y + Qt(e, t, r.localRect.width),
2125
+ x: y + An(e, t, r.localRect.width),
1828
2126
  y: b + S
1829
2127
  }, S += r.localRect.height + (e.bottom ?? 0);
1830
2128
  continue;
@@ -1836,10 +2134,10 @@ function rt(e, t, n, r, i, a, o) {
1836
2134
  breakBefore: T || r.style.breakBeforeColumn
1837
2135
  }), T = r.style.breakAfterColumn;
1838
2136
  }
1839
- return D(), s.ruleX && x.length > 0 && (e.decorationRuns = u({
2137
+ return D(), s.ruleX && x.length > 0 && (e.decorationRuns = ce({
1840
2138
  ruleX: s.ruleX,
1841
2139
  ruleY: null,
1842
- vertical: N(x, s.ruleInset),
2140
+ vertical: ke(x, s.ruleInset),
1843
2141
  horizontal: [],
1844
2142
  contentWidth: t,
1845
2143
  contentHeight: S,
@@ -1850,40 +2148,33 @@ function rt(e, t, n, r, i, a, o) {
1850
2148
  })), S;
1851
2149
  }
1852
2150
  //#endregion
1853
- //#region src/warn.ts
1854
- var it = /* @__PURE__ */ new WeakMap();
1855
- function at(e, t) {
1856
- let n = it.get(e);
1857
- n || it.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
1858
- }
1859
- //#endregion
1860
2151
  //#region src/table.ts
1861
- function ot(e, t) {
1862
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && at(t.source, "Table content outside the expected structure (rows in tables, cells in rows) can't be laid out and was hidden — no anonymous table boxes (specs/table.md).");
2152
+ function Lt(e, t) {
2153
+ e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && b(t.source, "Table content outside the expected structure (rows in tables, cells in rows) can't be laid out and was hidden — no anonymous table boxes (specs/table.md).");
1863
2154
  }
1864
- function st(e, t) {
2155
+ function Rt(e, t) {
1865
2156
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
1866
2157
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
1867
2158
  }
1868
- function ct(e, t, n) {
2159
+ function zt(e, t, n) {
1869
2160
  let r = (t, r) => {
1870
2161
  let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? q(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
1871
2162
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
1872
2163
  };
1873
2164
  if (t.style.tableRole === "column") {
1874
- r(t, lt(t.source));
2165
+ r(t, Bt(t.source));
1875
2166
  return;
1876
2167
  }
1877
2168
  let i = t.children.filter((e) => e.style.tableRole === "column");
1878
- if (i.length === 0) r(t, lt(t.source));
1879
- else for (let e of i) r(e, lt(e.source));
1880
- for (let n of t.children) n.style.tableRole !== "column" && ot(e, n);
2169
+ if (i.length === 0) r(t, Bt(t.source));
2170
+ else for (let e of i) r(e, Bt(e.source));
2171
+ for (let n of t.children) n.style.tableRole !== "column" && Lt(e, n);
1881
2172
  }
1882
- function lt(e) {
2173
+ function Bt(e) {
1883
2174
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
1884
2175
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
1885
2176
  }
1886
- function ut(e, t) {
2177
+ function Vt(e, t) {
1887
2178
  let n = {
1888
2179
  caption: null,
1889
2180
  rows: [],
@@ -1907,8 +2198,8 @@ function ut(e, t) {
1907
2198
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
1908
2199
  row: e,
1909
2200
  group: o
1910
- }) : ot(n, e));
1911
- } else e === "caption" ? n.caption === null ? n.caption = o : ot(n, o) : e === "column" || e === "column-group" ? (ct(n, o, t), n.hidden.push(o)) : ot(n, o);
2201
+ }) : Lt(n, e));
2202
+ } else e === "caption" ? n.caption === null ? n.caption = o : Lt(n, o) : e === "column" || e === "column-group" ? (zt(n, o, t), n.hidden.push(o)) : Lt(n, o);
1912
2203
  }
1913
2204
  let o = [
1914
2205
  ...r,
@@ -1923,20 +2214,20 @@ function ut(e, t) {
1923
2214
  s = e + 1;
1924
2215
  }
1925
2216
  }
1926
- return dt(n), n;
2217
+ return Ht(n), n;
1927
2218
  }
1928
- function dt(e) {
2219
+ function Ht(e) {
1929
2220
  let t = [];
1930
2221
  for (let n = 0; n < e.rows.length; n++) {
1931
2222
  let r = e.rows[n], i = 0;
1932
2223
  for (let a of r.children) {
1933
2224
  if (B(a.style)) continue;
1934
2225
  if (a.style.tableRole !== "cell") {
1935
- ot(e, a);
2226
+ Lt(e, a);
1936
2227
  continue;
1937
2228
  }
1938
2229
  for (; (t[i] ?? 0) > n;) i++;
1939
- let o = st(a.source, "colspan"), s = st(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2230
+ let o = Rt(a.source, "colspan"), s = Rt(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
1940
2231
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
1941
2232
  e.cells.push({
1942
2233
  node: a,
@@ -1950,7 +2241,7 @@ function dt(e) {
1950
2241
  }
1951
2242
  e.columnCount = Math.max(t.length, e.colFixed.length);
1952
2243
  }
1953
- function ft(e, t, n) {
2244
+ function Ut(e, t, n) {
1954
2245
  let r = e.style, i = Y(e, n), a;
1955
2246
  if (t === "min") a = i;
1956
2247
  else {
@@ -1960,11 +2251,11 @@ function ft(e, t, n) {
1960
2251
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1961
2252
  return Math.max(0, H(a, o, s));
1962
2253
  }
1963
- function pt(e) {
2254
+ function Wt(e) {
1964
2255
  let t = e.style.width;
1965
2256
  return t && t.kind === "percent" ? t.value : void 0;
1966
2257
  }
1967
- function mt(e, t, n) {
2258
+ function Gt(e, t, n) {
1968
2259
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
1969
2260
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
1970
2261
  let s = [];
@@ -1973,15 +2264,15 @@ function mt(e, t, n) {
1973
2264
  s.push(t);
1974
2265
  continue;
1975
2266
  }
1976
- i[t.col] = Math.max(i[t.col], ft(t.node, "min", n)), a[t.col] = Math.max(a[t.col], ft(t.node, "max", n));
1977
- let e = pt(t.node);
2267
+ i[t.col] = Math.max(i[t.col], Ut(t.node, "min", n)), a[t.col] = Math.max(a[t.col], Ut(t.node, "max", n));
2268
+ let e = Wt(t.node);
1978
2269
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
1979
2270
  }
1980
2271
  s.sort((e, t) => e.colSpan - t.colSpan);
1981
2272
  for (let e of s) {
1982
- let r = e.col, o = e.col + e.colSpan, s = xt(t, r, o), c = a.slice(r, o);
2273
+ let r = e.col, o = e.col + e.colSpan, s = Qt(t, r, o), c = a.slice(r, o);
1983
2274
  for (let t of ["min", "max"]) {
1984
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = ft(e.node, t, n) - u;
2275
+ let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = Ut(e.node, t, n) - u;
1985
2276
  if (d <= 0) continue;
1986
2277
  let f = I(c.some((e) => e > 0) ? c : c.map(() => 1), d);
1987
2278
  for (let e = r; e < o; e++) l[e] += f[e - r];
@@ -1994,7 +2285,7 @@ function mt(e, t, n) {
1994
2285
  percent: o
1995
2286
  };
1996
2287
  }
1997
- function ht(e, t) {
2288
+ function Kt(e, t) {
1998
2289
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
1999
2290
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2000
2291
  if (i.length > 0) {
@@ -2023,7 +2314,7 @@ function ht(e, t) {
2023
2314
  }
2024
2315
  return r;
2025
2316
  }
2026
- function gt(e, t, n) {
2317
+ function qt(e, t, n) {
2027
2318
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2028
2319
  for (let n = 0; n < r; n++) e.colFixed[n] === void 0 ? e.colPercent[n] !== void 0 && (i[n] = Math.max(0, Math.round(t * e.colPercent[n] / 100))) : i[n] = e.colFixed[n];
2029
2320
  for (let r of e.cells) {
@@ -2043,13 +2334,13 @@ function gt(e, t, n) {
2043
2334
  }
2044
2335
  return i.map((e) => e ?? 0);
2045
2336
  }
2046
- var _t = {
2337
+ var Jt = {
2047
2338
  double: 3,
2048
2339
  solid: 2,
2049
2340
  dashed: 1,
2050
2341
  dotted: 0
2051
2342
  };
2052
- function vt(e) {
2343
+ function Yt(e) {
2053
2344
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2054
2345
  let t = null;
2055
2346
  for (let { border: n, side: r } of e) {
@@ -2057,7 +2348,7 @@ function vt(e) {
2057
2348
  let e = n.width[r];
2058
2349
  if (e <= 0) continue;
2059
2350
  let i = n.style[r];
2060
- (t === null || e > t.width || e === t.width && _t[i] > _t[t.style]) && (t = {
2351
+ (t === null || e > t.width || e === t.width && Jt[i] > Jt[t.style]) && (t = {
2061
2352
  width: e,
2062
2353
  style: i,
2063
2354
  color: n.color[r]
@@ -2065,7 +2356,7 @@ function vt(e) {
2065
2356
  }
2066
2357
  return t;
2067
2358
  }
2068
- function yt(e, t) {
2359
+ function Xt(e, t) {
2069
2360
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2070
2361
  collapsed: i,
2071
2362
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2110,7 +2401,7 @@ function yt(e, t) {
2110
2401
  side: u
2111
2402
  });
2112
2403
  }
2113
- i.push(vt(l));
2404
+ i.push(Yt(l));
2114
2405
  }
2115
2406
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2116
2407
  }
@@ -2149,47 +2440,47 @@ function yt(e, t) {
2149
2440
  }), e === r && l.push({
2150
2441
  border: s,
2151
2442
  side: "bottom"
2152
- }), i.push(vt(l));
2443
+ }), i.push(Yt(l));
2153
2444
  }
2154
2445
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2155
2446
  }
2156
2447
  return a;
2157
2448
  }
2158
- function bt(e, t) {
2449
+ function Zt(e, t) {
2159
2450
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2160
2451
  }
2161
- function xt(e, t, n) {
2452
+ function Qt(e, t, n) {
2162
2453
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2163
2454
  let r = 0;
2164
2455
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2165
2456
  return r;
2166
2457
  }
2167
- function St(e, t, n) {
2458
+ function $t(e, t, n) {
2168
2459
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2169
2460
  let r = 0;
2170
2461
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2171
2462
  return r;
2172
2463
  }
2173
- function Ct(e, t) {
2464
+ function en(e, t) {
2174
2465
  let n = t.tableData.get(e);
2175
2466
  if (n) return n;
2176
- let r = ut(e, t), i = yt(e, r), a = {
2467
+ let r = Vt(e, t), i = Xt(e, r), a = {
2177
2468
  structure: r,
2178
2469
  chrome: i,
2179
- bounds: mt(r, i, t),
2180
- chromeX: bt(i, r.columnCount)
2470
+ bounds: Gt(r, i, t),
2471
+ chromeX: Zt(i, r.columnCount)
2181
2472
  };
2182
2473
  return t.tableData.set(e, a), a;
2183
2474
  }
2184
- function wt(e, t) {
2185
- let { structure: n, bounds: r, chromeX: i } = Ct(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2475
+ function tn(e, t) {
2476
+ let { structure: n, bounds: r, chromeX: i } = en(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2186
2477
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2187
2478
  min: a,
2188
2479
  max: o
2189
2480
  };
2190
2481
  }
2191
- function Tt(e, t, n) {
2192
- let r = e.style, { bounds: i, chromeX: a } = Ct(e, n), { min: o, max: s } = wt(e, n), c = r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t), l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2482
+ function nn(e, t, n) {
2483
+ let r = e.style, { bounds: i, chromeX: a } = en(e, n), { min: o, max: s } = tn(e, n), c = r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t), l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2193
2484
  for (let e = 0; e < i.max.length; e++) {
2194
2485
  let t = i.percent[e];
2195
2486
  t === void 0 ? d += i.max[e] : u += t;
@@ -2205,8 +2496,8 @@ function Tt(e, t, n) {
2205
2496
  let f = Math.max(l + a, s) + c;
2206
2497
  return Math.max(o + c, Math.min(f, t));
2207
2498
  }
2208
- function Et(e, t, n, r, i, a) {
2209
- let { structure: o, chrome: s, bounds: c } = Ct(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2499
+ function rn(e, t, n, r, i, a) {
2500
+ let { structure: o, chrome: s, bounds: c } = en(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2210
2501
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2211
2502
  x: 0,
2212
2503
  y: 0,
@@ -2218,56 +2509,56 @@ function Et(e, t, n, r, i, a) {
2218
2509
  bottom: 0,
2219
2510
  left: 0
2220
2511
  }, e.unclampedHeight = 0;
2221
- let p = Math.max(0, t - bt(s, l)), h = e.style, g = h.tableLayout === "fixed" && h.width !== void 0 && h.width.kind !== "auto" ? gt(o, p, a) : ht(c, p), _ = [], v = 0;
2222
- for (let e = 0; e < l; e++) v += s.collapsed ? s.vLines[e] : s.spacingX, _.push(v), v += g[e];
2223
- let y = v + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), b = 0;
2224
- o.caption && (V(o.caption, t, void 0, d, f, "fill", a), b = o.caption.localRect.height);
2225
- let x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
2512
+ let p = Math.max(0, t - Zt(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? qt(o, p, a) : Kt(c, p), g = [], _ = 0;
2513
+ for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2514
+ let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2515
+ o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2516
+ let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2226
2517
  for (let e of o.cells) {
2227
- let t = e.col + e.colSpan, n = g.slice(e.col, t).reduce((e, t) => e + t, 0) + xt(s, e.col, t);
2228
- S.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), x.set(e, e.node.localRect.height);
2518
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + Qt(s, e.col, t);
2519
+ x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2229
2520
  }
2230
- let C = s.collapsed ? s.hLines.reduce((e, t) => e + t, 0) : (u + 1) * s.spacingY, w = n === void 0 ? void 0 : Math.max(0, n - b - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? m(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2521
+ let S = s.collapsed ? s.hLines.reduce((e, t) => e + t, 0) : (u + 1) * s.spacingY, C = n === void 0 ? void 0 : Math.max(0, n - y - S), w = (e) => e !== void 0 && e.kind === "percent" && C !== void 0 ? de(e.value, C) : 0, T = Array.from({ length: u }, () => 0), E = Array.from({ length: u }, () => !1);
2231
2522
  for (let e = 0; e < u; e++) {
2232
2523
  let t = o.rows[e].style.height;
2233
- t !== void 0 && t.kind === "cells" && (E[e] = t.value);
2234
- let n = T(t);
2235
- n > 0 && (E[e] = Math.max(E[e], n), D[e] = !0);
2524
+ t !== void 0 && t.kind === "cells" && (T[e] = t.value);
2525
+ let n = w(t);
2526
+ n > 0 && (T[e] = Math.max(T[e], n), E[e] = !0);
2236
2527
  }
2237
2528
  for (let e of o.cells) if (e.rowSpan === 1) {
2238
- let t = T(e.node.style.height);
2239
- t > 0 && (D[e.row] = !0), E[e.row] = Math.max(E[e.row], x.get(e), t);
2529
+ let t = w(e.node.style.height);
2530
+ t > 0 && (E[e.row] = !0), T[e.row] = Math.max(T[e.row], b.get(e), t);
2240
2531
  }
2241
- let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2242
- for (let e of O) {
2243
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + St(s, e.row, t), r = x.get(e) - n;
2532
+ let D = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2533
+ for (let e of D) {
2534
+ let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + $t(s, e.row, t), r = b.get(e) - n;
2244
2535
  if (r <= 0) continue;
2245
2536
  let i = I(Array.from({ length: e.rowSpan }, () => 1), r);
2246
- for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
2537
+ for (let n = e.row; n < t; n++) T[n] += i[n - e.row];
2247
2538
  }
2248
2539
  if (n !== void 0 && u > 0) {
2249
- let e = n - b - C - E.reduce((e, t) => e + t, 0);
2540
+ let e = n - y - S - T.reduce((e, t) => e + t, 0);
2250
2541
  if (e > 0) {
2251
2542
  let t = [];
2252
- for (let e = 0; e < u; e++) D[e] || t.push(e);
2543
+ for (let e = 0; e < u; e++) E[e] || t.push(e);
2253
2544
  let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = I(n.map(() => 1), e);
2254
- n.forEach((e, t) => E[e] += r[t]);
2545
+ n.forEach((e, t) => T[e] += r[t]);
2255
2546
  }
2256
2547
  }
2257
- let k = o.caption && e.style.captionSide === "top" ? b : 0, A = [], j = k;
2258
- for (let e = 0; e < u; e++) j += s.collapsed ? s.hLines[e] : s.spacingY, A.push(j), j += E[e];
2259
- let M = u > 0 ? j + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, N = /* @__PURE__ */ new Map();
2548
+ let ee = o.caption && e.style.captionSide === "top" ? y : 0, O = [], k = ee;
2549
+ for (let e = 0; e < u; e++) k += s.collapsed ? s.hLines[e] : s.spacingY, O.push(k), k += T[e];
2550
+ let A = u > 0 ? k + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : ee, j = /* @__PURE__ */ new Map();
2260
2551
  for (let e = 0; e < u; e++) {
2261
2552
  let t = o.rowGroups[e];
2262
- t && !N.has(t) && N.set(t, A[e]);
2553
+ t && !j.has(t) && j.set(t, O[e]);
2263
2554
  }
2264
- for (let [e, t] of N) {
2555
+ for (let [e, t] of j) {
2265
2556
  let n = t;
2266
- for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = A[t] + E[t]);
2557
+ for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = O[t] + T[t]);
2267
2558
  e.localRect = {
2268
2559
  x: d,
2269
2560
  y: f + t,
2270
- width: y,
2561
+ width: v,
2271
2562
  height: n - t
2272
2563
  }, e.resolvedPadding = {
2273
2564
  top: 0,
@@ -2277,26 +2568,26 @@ function Et(e, t, n, r, i, a) {
2277
2568
  }, e.unclampedHeight = n - t;
2278
2569
  }
2279
2570
  for (let e = 0; e < u; e++) {
2280
- let t = o.rows[e], n = o.rowGroups[e], r = n ? N.get(n) : void 0;
2571
+ let t = o.rows[e], n = o.rowGroups[e], r = n ? j.get(n) : void 0;
2281
2572
  t.localRect = {
2282
2573
  x: r === void 0 ? d : 0,
2283
- y: r === void 0 ? f + A[e] : A[e] - r,
2284
- width: y,
2285
- height: E[e]
2574
+ y: r === void 0 ? f + O[e] : O[e] - r,
2575
+ width: v,
2576
+ height: T[e]
2286
2577
  }, t.resolvedPadding = {
2287
2578
  top: 0,
2288
2579
  right: 0,
2289
2580
  bottom: 0,
2290
2581
  left: 0
2291
- }, t.unclampedHeight = E[e];
2582
+ }, t.unclampedHeight = T[e];
2292
2583
  }
2293
2584
  for (let e of o.cells) {
2294
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + St(s, e.row, t);
2295
- e.node.children.some((e) => !B(e.style) && e.style.height?.kind === "percent") && n !== x.get(e) && V(e.node, S.get(e), n, 0, 0, "fill", a, {
2296
- width: S.get(e),
2585
+ let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + $t(s, e.row, t);
2586
+ e.node.children.some((e) => !B(e.style) && e.style.height?.kind === "percent") && n !== b.get(e) && V(e.node, x.get(e), n, 0, 0, "fill", a, {
2587
+ width: x.get(e),
2297
2588
  height: n
2298
- }), Dt(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2299
- x: _[e.col],
2589
+ }), an(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2590
+ x: g[e.col],
2300
2591
  y: 0,
2301
2592
  width: e.node.localRect.width,
2302
2593
  height: n
@@ -2307,9 +2598,9 @@ function Et(e, t, n, r, i, a) {
2307
2598
  x: d,
2308
2599
  y: f
2309
2600
  });
2310
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Ot(s, o, g, E, _, A, d, f)), e.style.captionSide === "bottom" ? M + b : M;
2601
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + A), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = on(s, o, h, T, g, O, d, f)), e.style.captionSide === "bottom" ? A + y : A;
2311
2602
  }
2312
- function Dt(e, t) {
2603
+ function an(e, t) {
2313
2604
  if (t <= 0) return;
2314
2605
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2315
2606
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2318,84 +2609,84 @@ function Dt(e, t) {
2318
2609
  }
2319
2610
  if (!(r <= 0)) for (let t of e.children) t.inlineBox || (B(t.style) ? t.staticSlot?.kind === "block" && (t.staticSlot.y += r) : t.localRect.y += r);
2320
2611
  }
2321
- function Ot(e, t, n, r, o, s, c, l) {
2322
- let u = t.columnCount, d = t.rows.length, f = [], p = (t) => t < u ? o[t] - e.vLines[t] : o[u - 1] + n[u - 1], m = (t) => t < d ? s[t] - e.hLines[t] : s[d - 1] + r[d - 1];
2323
- for (let t = 0; t <= u; t++) {
2612
+ function on(e, t, n, r, i, a, o, s) {
2613
+ let c = t.columnCount, l = t.rows.length, u = [], d = (t) => t < c ? i[t] - e.vLines[t] : i[c - 1] + n[c - 1], f = (t) => t < l ? a[t] - e.hLines[t] : a[l - 1] + r[l - 1];
2614
+ for (let t = 0; t <= c; t++) {
2324
2615
  let n = e.vSegments[t];
2325
- for (let e = 0; e < d; e++) {
2326
- let a = n[e];
2327
- if (!a) continue;
2328
- let o = i(a.style, "v");
2329
- for (let n = 0; n < a.width; n++) for (let i = s[e]; i < s[e] + r[e]; i++) f.push({
2330
- glyph: o,
2331
- x: c + p(t) + n,
2332
- y: l + i,
2616
+ for (let e = 0; e < l; e++) {
2617
+ let i = n[e];
2618
+ if (!i) continue;
2619
+ let c = ne(i.style, "v");
2620
+ for (let n = 0; n < i.width; n++) for (let l = a[e]; l < a[e] + r[e]; l++) u.push({
2621
+ glyph: c,
2622
+ x: o + d(t) + n,
2623
+ y: s + l,
2333
2624
  length: 1,
2334
- color: a.color
2625
+ color: i.color
2335
2626
  });
2336
2627
  }
2337
2628
  }
2338
- for (let t = 0; t <= d; t++) {
2629
+ for (let t = 0; t <= l; t++) {
2339
2630
  let r = e.hSegments[t];
2340
- for (let e = 0; e < u; e++) {
2631
+ for (let e = 0; e < c; e++) {
2341
2632
  let a = r[e];
2342
2633
  if (!a) continue;
2343
- let s = i(a.style, "h");
2344
- for (let r = 0; r < a.width; r++) f.push({
2345
- glyph: s,
2346
- x: c + o[e],
2347
- y: l + m(t) + r,
2634
+ let c = ne(a.style, "h");
2635
+ for (let r = 0; r < a.width; r++) u.push({
2636
+ glyph: c,
2637
+ x: o + i[e],
2638
+ y: s + f(t) + r,
2348
2639
  length: n[e],
2349
2640
  color: a.color
2350
2641
  });
2351
2642
  }
2352
2643
  }
2353
- for (let t = 0; t <= u; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= d; n++) {
2644
+ for (let t = 0; t <= c; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= l; n++) {
2354
2645
  if (e.hLines[n] <= 0) continue;
2355
- let r = n > 0 ? e.vSegments[t][n - 1] : null, i = n < d ? e.vSegments[t][n] : null, o = t > 0 ? e.hSegments[n][t - 1] : null, s = t < u ? e.hSegments[n][t] : null, h = [
2646
+ let r = n > 0 ? e.vSegments[t][n - 1] : null, i = n < l ? e.vSegments[t][n] : null, a = t > 0 ? e.hSegments[n][t - 1] : null, p = t < c ? e.hSegments[n][t] : null, m = [
2356
2647
  r,
2357
2648
  i,
2358
- o,
2359
- s
2649
+ a,
2650
+ p
2360
2651
  ].filter((e) => e !== null);
2361
- if (h.length === 0) continue;
2362
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && _t[t.style] > _t[e.style] ? t : e), v = a(g, r !== null, i !== null, o !== null, s !== null);
2363
- for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) f.push({
2364
- glyph: v,
2365
- x: c + p(t) + r,
2366
- y: l + m(n) + i,
2652
+ if (m.length === 0) continue;
2653
+ let h = m.every((e) => e.style === "double") ? "double" : "solid", g = m.reduce((e, t) => t.width > e.width || t.width === e.width && Jt[t.style] > Jt[e.style] ? t : e), _ = re(h, r !== null, i !== null, a !== null, p !== null);
2654
+ for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) u.push({
2655
+ glyph: _,
2656
+ x: o + d(t) + r,
2657
+ y: s + f(n) + i,
2367
2658
  length: 1,
2368
- color: _.color
2659
+ color: g.color
2369
2660
  });
2370
2661
  }
2371
- return f;
2662
+ return u;
2372
2663
  }
2373
2664
  //#endregion
2374
2665
  //#region src/positioning.ts
2375
- function kt(e) {
2666
+ function sn(e) {
2376
2667
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2377
2668
  }
2378
- function At(e, t, n, r, i) {
2669
+ function cn(e, t, n, r, i) {
2379
2670
  for (let a of e.children) {
2380
- let o = kt(a.style);
2671
+ let o = sn(a.style);
2381
2672
  if (o === "relative") {
2382
2673
  let t = e.localRect.width - e.style.border.left - e.style.border.right - e.resolvedPadding.left - e.resolvedPadding.right, n = e.localRect.height - e.style.border.top - e.style.border.bottom - e.resolvedPadding.top - e.resolvedPadding.bottom;
2383
- a.localRect.x += jt(a.style.insets.left, a.style.insets.right, t), a.localRect.y += jt(a.style.insets.top, a.style.insets.bottom, n);
2384
- } else o === "absolute" && Nt(a, e, t, n, r, i);
2385
- At(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2674
+ a.localRect.x += ln(a.style.insets.left, a.style.insets.right, t), a.localRect.y += ln(a.style.insets.top, a.style.insets.bottom, n);
2675
+ } else o === "absolute" && dn(a, e, t, n, r, i);
2676
+ cn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2386
2677
  node: a,
2387
2678
  absX: t + a.localRect.x,
2388
2679
  absY: n + a.localRect.y
2389
2680
  }], i);
2390
2681
  }
2391
2682
  }
2392
- function jt(e, t, n) {
2683
+ function ln(e, t, n) {
2393
2684
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2394
2685
  }
2395
- function Mt(e, t) {
2686
+ function un(e, t) {
2396
2687
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2397
2688
  let n = e[t];
2398
- if (!Vt(n.node.style)) continue;
2689
+ if (!yn(n.node.style)) continue;
2399
2690
  let r = n.node.style.border;
2400
2691
  return {
2401
2692
  x: n.absX + r.left,
@@ -2412,13 +2703,13 @@ function Mt(e, t) {
2412
2703
  height: n.node.localRect.height
2413
2704
  };
2414
2705
  }
2415
- function Nt(e, t, n, r, i, a) {
2416
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Vt(t.style) ? {
2706
+ function dn(e, t, n, r, i, a) {
2707
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && yn(t.style) ? {
2417
2708
  x: n + c.area.x,
2418
2709
  y: r + c.area.y,
2419
2710
  width: c.area.width,
2420
2711
  height: c.area.height
2421
- } : Mt(i, s), u = o.insets.left === null ? null : W(o.insets.left, l.width), d = o.insets.right === null ? null : W(o.insets.right, l.width), f = o.insets.top === null ? null : W(o.insets.top, l.height), p = o.insets.bottom === null ? null : W(o.insets.bottom, l.height), m = G(o.margin, l.width), h = m.left ?? 0, g = m.right ?? 0, _ = m.top ?? 0, v = m.bottom ?? 0, y = o.width === void 0 || o.width.kind === "auto", b = o.height === void 0 || o.height.kind === "auto", x = Xt(o.minWidth, l.width, e, a) ?? 0, S = Xt(o.maxWidth, l.width, e, a), C = {};
2712
+ } : un(i, s), u = o.insets.left === null ? null : W(o.insets.left, l.width), d = o.insets.right === null ? null : W(o.insets.right, l.width), f = o.insets.top === null ? null : W(o.insets.top, l.height), p = o.insets.bottom === null ? null : W(o.insets.bottom, l.height), m = G(o.margin, l.width), h = m.left ?? 0, g = m.right ?? 0, _ = m.top ?? 0, v = m.bottom ?? 0, y = o.width === void 0 || o.width.kind === "auto", b = o.height === void 0 || o.height.kind === "auto", x = On(o.minWidth, l.width, e, a) ?? 0, S = On(o.maxWidth, l.width, e, a), C = {};
2422
2713
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2423
2714
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2424
2715
  else {
@@ -2430,25 +2721,25 @@ function Nt(e, t, n, r, i, a) {
2430
2721
  if (u !== null && d !== null) {
2431
2722
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2432
2723
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2433
- } else E = u === null ? d === null ? Rt(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2724
+ } else E = u === null ? d === null ? gn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2434
2725
  let D;
2435
2726
  if (f !== null && p !== null) {
2436
2727
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2437
2728
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2438
- } else D = f === null ? p === null ? zt(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2729
+ } else D = f === null ? p === null ? _n(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2439
2730
  e.localRect = {
2440
2731
  ...e.localRect,
2441
2732
  x: E - n,
2442
2733
  y: D - r
2443
2734
  };
2444
2735
  }
2445
- function Pt(e, t, n) {
2736
+ function fn(e, t, n) {
2446
2737
  return F(e, [n], Math.max(0, t - n))[0];
2447
2738
  }
2448
- function Ft(e, t, n, r) {
2449
- return L(ae(e, t), n, r);
2739
+ function pn(e, t, n, r) {
2740
+ return L(Ie(e, t), n, r);
2450
2741
  }
2451
- function It(e, t, n, r, i) {
2742
+ function mn(e, t, n, r, i) {
2452
2743
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2453
2744
  a.left ?? 0,
2454
2745
  a.right ?? 0,
@@ -2460,9 +2751,9 @@ function It(e, t, n, r, i) {
2460
2751
  n.innerHeight,
2461
2752
  n.direction === "column"
2462
2753
  ], u = i + o + s;
2463
- return (l ? Pt(le(t.style), c, u) : Ft(e, t, c, u)) + o;
2754
+ return (l ? fn(Be(t.style), c, u) : pn(e, t, c, u)) + o;
2464
2755
  }
2465
- function Lt(e, t, n, r, i) {
2756
+ function hn(e, t, n, r, i) {
2466
2757
  let a = G(e.style.margin, n.width), o = e.style.justifySelf === "auto" ? t.style.justifyItems : e.style.justifySelf, [s, c, l, u] = r === "x" ? [
2467
2758
  a.left ?? 0,
2468
2759
  a.right ?? 0,
@@ -2472,23 +2763,23 @@ function Lt(e, t, n, r, i) {
2472
2763
  a.top ?? 0,
2473
2764
  a.bottom ?? 0,
2474
2765
  n.height,
2475
- ae(e, t)
2766
+ Ie(e, t)
2476
2767
  ];
2477
2768
  return L(u, l, i + s + c) + s;
2478
2769
  }
2479
- function Rt(e, t, n, r) {
2770
+ function gn(e, t, n, r) {
2480
2771
  let i = e.staticSlot;
2481
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Lt(e, t, i.staticArea, "x", r) : n + i.originX + It(e, t, i, "x", r);
2772
+ return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + hn(e, t, i.staticArea, "x", r) : n + i.originX + mn(e, t, i, "x", r);
2482
2773
  }
2483
- function zt(e, t, n, r) {
2774
+ function _n(e, t, n, r) {
2484
2775
  let i = e.staticSlot;
2485
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Lt(e, t, i.staticArea, "y", r) : n + i.originY + It(e, t, i, "y", r);
2776
+ return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + hn(e, t, i.staticArea, "y", r) : n + i.originY + mn(e, t, i, "y", r);
2486
2777
  }
2487
2778
  //#endregion
2488
2779
  //#region src/layout.ts
2489
- function Bt(e, t) {
2490
- let n = Ht();
2491
- return V(e, t, void 0, 0, 0, "fill", n), At(e, 0, 0, [{
2780
+ function vn(e, t) {
2781
+ let n = bn();
2782
+ return V(e, t, void 0, 0, 0, "fill", n), cn(e, 0, 0, [{
2492
2783
  node: e,
2493
2784
  absX: 0,
2494
2785
  absY: 0
@@ -2497,10 +2788,10 @@ function Bt(e, t) {
2497
2788
  function B(e) {
2498
2789
  return e.position === "absolute" || e.position === "fixed";
2499
2790
  }
2500
- function Vt(e) {
2791
+ function yn(e) {
2501
2792
  return e.position !== "static";
2502
2793
  }
2503
- function Ht() {
2794
+ function bn() {
2504
2795
  return {
2505
2796
  maxContent: /* @__PURE__ */ new WeakMap(),
2506
2797
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2511,21 +2802,21 @@ function Ht() {
2511
2802
  function V(e, t, n, r, i, a, o, s) {
2512
2803
  let c = e.style, l = s?.height;
2513
2804
  delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan;
2514
- let u = Xt(c.minWidth, t, e, o) ?? 0, d = Xt(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2805
+ let u = On(c.minWidth, t, e, o) ?? 0, d = On(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2515
2806
  top: W(c.padding.top, t),
2516
2807
  right: W(c.padding.right, t),
2517
2808
  bottom: W(c.padding.bottom, t),
2518
2809
  left: W(c.padding.left, t)
2519
2810
  };
2520
2811
  e.resolvedPadding = m;
2521
- let h = s?.width ?? H(en(c, t, a, e, o), u, d), g = nn(c, n), _ = on(h, l ?? g ?? (f > 0 ? f : void 0) ?? Infinity, c.border, m), v = l !== void 0 || g !== void 0, y = v && Number.isFinite(_.height) ? _.height : void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - m.top - m.bottom), x;
2522
- x = Wt(e) ? Ut(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? P(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? te(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? pe(e, _.width, _.height, c.border, m, o) : c.display === "table" ? Et(e, _.width, y, c.border, m, o) : c.display === "multicol" ? rt(e, _.width, y, b, c.border, m, o) : Zt(e, _.width, y, c.border, m, o);
2812
+ let h = s?.width ?? H(Mn(c, t, a, e, o), u, d), g = Pn(c, n), _ = Ln(h, l ?? g ?? (f > 0 ? f : void 0) ?? Infinity, c.border, m), v = l !== void 0 || g !== void 0, y = v && Number.isFinite(_.height) ? _.height : void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - m.top - m.bottom), x;
2813
+ x = Sn(e) ? xn(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? Ae(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? Me(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? We(e, _.width, _.height, c.border, m, o) : c.display === "table" ? rn(e, _.width, y, c.border, m, o) : c.display === "multicol" ? It(e, _.width, y, b, c.border, m, o) : kn(e, _.width, y, c.border, m, o);
2523
2814
  let S = x + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? S;
2524
2815
  e.unclampedHeight = C, e.naturalContentHeight = S;
2525
2816
  let w = H(C, f, p), T = e.multicolGeometry;
2526
2817
  if (T) {
2527
2818
  let t = w - c.border.top - c.border.bottom - m.top - m.bottom;
2528
- t > T.totalRows && (m.bottom += t - T.totalRows), et(e, T, c.border, m);
2819
+ t > T.totalRows && (m.bottom += t - T.totalRows), Nt(e, T, c.border, m);
2529
2820
  }
2530
2821
  e.localRect = {
2531
2822
  x: r,
@@ -2534,30 +2825,30 @@ function V(e, t, n, r, i, a, o, s) {
2534
2825
  height: w
2535
2826
  };
2536
2827
  }
2537
- function Ut(e, t, n, r, i, a, o) {
2828
+ function xn(e, t, n, r, i, a, o) {
2538
2829
  let s = e.style, c;
2539
2830
  if (e.text) {
2540
2831
  let l = e.children.filter((e) => e.inlineBox);
2541
- E(e.text, (n, r) => {
2832
+ Se(e.text, (n, r) => {
2542
2833
  let i = l[r];
2543
2834
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2544
2835
  });
2545
2836
  let u, d;
2546
2837
  if (s.display === "multicol") {
2547
- let n = U(s, "x", t), o = Ye(s, t, n);
2838
+ let n = U(s, "x", t), o = Et(s, t, n);
2548
2839
  a.right += o.leftover;
2549
- let c = Ze(e, o, n, qe(r, i));
2840
+ let c = Ot(e, o, n, wt(r, i));
2550
2841
  e.multicolGeometry = c, u = c, d = c.lineX;
2551
- } else u = Kt(e, t);
2552
- if (c = u.totalRows, Gt(e, u, t, n, a), l.length > 0) {
2842
+ } else u = wn(e, t);
2843
+ if (c = u.totalRows, Cn(e, u, t, n, a), l.length > 0) {
2553
2844
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
2554
- E(e.text, (n, r) => {
2845
+ Se(e.text, (n, r) => {
2555
2846
  let i = t(n);
2556
2847
  if (i === -1) return;
2557
2848
  let o = u.spans[i];
2558
2849
  l[r].localRect = {
2559
2850
  ...l[r].localRect,
2560
- x: s.border.left + a.left + (d?.[i] ?? 0) + S(o.start, n, e.advances),
2851
+ x: s.border.left + a.left + (d?.[i] ?? 0) + ye(o.start, n, e.advances),
2561
2852
  y: s.border.top + a.top + u.lineY[i]
2562
2853
  };
2563
2854
  });
@@ -2574,30 +2865,30 @@ function Ut(e, t, n, r, i, a, o) {
2574
2865
  }
2575
2866
  return c;
2576
2867
  }
2577
- function Wt(e) {
2868
+ function Sn(e) {
2578
2869
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
2579
2870
  }
2580
2871
  function H(e, t, n) {
2581
2872
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
2582
2873
  }
2583
- function Gt(e, t, n, r, i) {
2874
+ function Cn(e, t, n, r, i) {
2584
2875
  let a = e.style;
2585
2876
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
2586
- let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, C(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
2877
+ let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, P(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
2587
2878
  if (c > 0) {
2588
- let e = a.display === "grid" ? L(a.justifyItems, n, s) : o ? L(a.alignItems, n, s) : F(le(a), [s], c)[0];
2879
+ let e = a.display === "grid" ? L(a.justifyItems, n, s) : o ? L(a.alignItems, n, s) : F(Be(a), [s], c)[0];
2589
2880
  e > 0 && (i.left += e, i.right += c - e);
2590
2881
  }
2591
2882
  if (Number.isFinite(r)) {
2592
2883
  let e = Math.max(0, r - t.totalRows);
2593
2884
  if (e > 0) {
2594
- let n = a.display === "grid" || !o ? L(a.alignItems, r, t.totalRows) : F(le(a), [t.totalRows], e)[0];
2885
+ let n = a.display === "grid" || !o ? L(a.alignItems, r, t.totalRows) : F(Be(a), [t.totalRows], e)[0];
2595
2886
  n > 0 && (i.top += n, i.bottom += e - n);
2596
2887
  }
2597
2888
  }
2598
2889
  }
2599
- function Kt(e, t) {
2600
- let n = qt(e, t), { heights: r, textOffsets: i } = Jt(e, n), a = [], o = [], s = 0;
2890
+ function wn(e, t) {
2891
+ let n = Tn(e, t), { heights: r, textOffsets: i } = En(e, n), a = [], o = [], s = 0;
2601
2892
  for (let t = 0; t < n.length; t++) a.push(s), o.push(s + i[t]), s += r[t] + (t < n.length - 1 ? e.style.lineGap : 0);
2602
2893
  return {
2603
2894
  spans: n,
@@ -2606,21 +2897,21 @@ function Kt(e, t) {
2606
2897
  totalRows: s
2607
2898
  };
2608
2899
  }
2609
- function qt(e, t) {
2610
- return e.style.whiteSpace === "normal" ? x(e.text, t, {
2900
+ function Tn(e, t) {
2901
+ return e.style.whiteSpace === "normal" ? ve(e.text, t, {
2611
2902
  advances: e.advances,
2612
2903
  tracking: e.style.tracking,
2613
2904
  firstLineIndent: e.style.textIndent
2614
- }) : b(e.text);
2905
+ }) : _e(e.text);
2615
2906
  }
2616
- function Jt(e, t) {
2907
+ function En(e, t) {
2617
2908
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
2618
2909
  for (let o of t) {
2619
2910
  let t = 1, s = 0;
2620
2911
  for (let r = o.start; r < o.end; r++) {
2621
2912
  if (e.text[r] !== "") continue;
2622
2913
  let i = n[a];
2623
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && at(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
2914
+ t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && b(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
2624
2915
  }
2625
2916
  r.push(t), i.push(Math.min(s, t - 1));
2626
2917
  }
@@ -2634,7 +2925,7 @@ function U(e, t, n) {
2634
2925
  return Math.max(r, i?.width ?? 0);
2635
2926
  }
2636
2927
  function W(e, t) {
2637
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : m(e.percent, t);
2928
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : de(e.percent, t);
2638
2929
  }
2639
2930
  function G(e, t) {
2640
2931
  let n = (e) => e === null ? null : W(e, t);
@@ -2645,16 +2936,16 @@ function G(e, t) {
2645
2936
  left: n(e.left)
2646
2937
  };
2647
2938
  }
2648
- function Yt(e) {
2939
+ function Dn(e) {
2649
2940
  return typeof e == "number" ? e : 0;
2650
2941
  }
2651
2942
  function K(e, t) {
2652
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : m(e.percent, t);
2943
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : de(e.percent, t);
2653
2944
  }
2654
- function Xt(e, t, n, r) {
2945
+ function On(e, t, n, r) {
2655
2946
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
2656
2947
  }
2657
- function Zt(e, t, n, r, i, a) {
2948
+ function kn(e, t, n, r, i, a) {
2658
2949
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
2659
2950
  for (let r of e.children) {
2660
2951
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -2662,13 +2953,13 @@ function Zt(e, t, n, r, i, a) {
2662
2953
  r.staticSlot = {
2663
2954
  kind: "block",
2664
2955
  x: o + u,
2665
- y: c + (l === null ? i : $t(l, i))
2956
+ y: c + (l === null ? i : jn(l, i))
2666
2957
  };
2667
2958
  continue;
2668
2959
  }
2669
2960
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
2670
- let f = Qt(e, t, r.localRect.width);
2671
- c += l === null ? i : $t(l, i), r.localRect = {
2961
+ let f = An(e, t, r.localRect.width);
2962
+ c += l === null ? i : jn(l, i), r.localRect = {
2672
2963
  ...r.localRect,
2673
2964
  x: o + f,
2674
2965
  y: c
@@ -2676,37 +2967,37 @@ function Zt(e, t, n, r, i, a) {
2676
2967
  }
2677
2968
  return l !== null && (c += l), c - s;
2678
2969
  }
2679
- function Qt(e, t, n) {
2970
+ function An(e, t, n) {
2680
2971
  let r = t - n;
2681
2972
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
2682
2973
  }
2683
- function $t(e, t) {
2974
+ function jn(e, t) {
2684
2975
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
2685
2976
  }
2686
- function en(e, t, n, r, i) {
2977
+ function Mn(e, t, n, r, i) {
2687
2978
  let a = e.width;
2688
2979
  if (e.display === "table") {
2689
2980
  if (!r.children.some((e) => !B(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : Math.min(t, J(r, i));
2690
2981
  if (a !== void 0 && a.kind !== "auto") {
2691
2982
  let e = q(a, t, r, i);
2692
- return Math.max(e, tn(r, t, i));
2983
+ return Math.max(e, Nn(r, t, i));
2693
2984
  }
2694
- return Tt(r, t, i);
2985
+ return nn(r, t, i);
2695
2986
  }
2696
2987
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
2697
2988
  }
2698
- function tn(e, t, n) {
2989
+ function Nn(e, t, n) {
2699
2990
  let r = e.style;
2700
- return wt(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2991
+ return tn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2701
2992
  }
2702
- function nn(e, t) {
2993
+ function Pn(e, t) {
2703
2994
  if (e.height?.kind === "cells") return e.height.value;
2704
- if (e.height?.kind === "percent" && t != null) return m(e.height.value, t);
2995
+ if (e.height?.kind === "percent" && t != null) return de(e.height.value, t);
2705
2996
  }
2706
2997
  function q(e, t, n, r) {
2707
2998
  switch (e.kind) {
2708
2999
  case "cells": return e.value;
2709
- case "percent": return m(e.value, t);
3000
+ case "percent": return de(e.value, t);
2710
3001
  case "min-content": return Y(n, r);
2711
3002
  case "max-content": return J(n, r);
2712
3003
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -2716,42 +3007,42 @@ function q(e, t, n, r) {
2716
3007
  function J(e, t) {
2717
3008
  let n = t.maxContent.get(e);
2718
3009
  if (n !== void 0) return n;
2719
- let r = e.style, i = rn(e, t) + r.border.left + r.border.right + Yt(r.padding.left) + Yt(r.padding.right);
3010
+ let r = e.style, i = Fn(e, t) + r.border.left + r.border.right + Dn(r.padding.left) + Dn(r.padding.right);
2720
3011
  return t.maxContent.set(e, i), i;
2721
3012
  }
2722
- function rn(e, t) {
3013
+ function Fn(e, t) {
2723
3014
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
2724
- if (n.length === 0) return e.style.display === "multicol" ? Ke(e.style, e.intrinsicWidth) : e.intrinsicWidth;
2725
- if (e.style.display === "grid") return Se(e, t).max;
2726
- if (e.style.display === "table") return wt(e, t).max;
3015
+ if (n.length === 0) return e.style.display === "multicol" ? Ct(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3016
+ if (e.style.display === "grid") return $e(e, t).max;
3017
+ if (e.style.display === "table") return tn(e, t).max;
2727
3018
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
2728
- let r = Math.max(Yt(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3019
+ let r = Math.max(Dn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2729
3020
  return n.reduce((e, n) => e + J(n, t), 0) + r;
2730
3021
  }
2731
3022
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
2732
- return e.style.display === "multicol" ? Ke(e.style, r) : r;
3023
+ return e.style.display === "multicol" ? Ct(e.style, r) : r;
2733
3024
  }
2734
3025
  function Y(e, t) {
2735
3026
  let n = t.minContent.get(e);
2736
3027
  if (n !== void 0) return n;
2737
- let r = e.style, i = an(e, t) + r.border.left + r.border.right + Yt(r.padding.left) + Yt(r.padding.right);
3028
+ let r = e.style, i = In(e, t) + r.border.left + r.border.right + Dn(r.padding.left) + Dn(r.padding.right);
2738
3029
  return t.minContent.set(e, i), i;
2739
3030
  }
2740
- function an(e, t) {
3031
+ function In(e, t) {
2741
3032
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
2742
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : T(e.text, {
3033
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : xe(e.text, {
2743
3034
  advances: e.advances,
2744
3035
  tracking: e.style.tracking
2745
3036
  });
2746
- if (e.style.display === "grid") return Se(e, t).min;
2747
- if (e.style.display === "table") return wt(e, t).min;
3037
+ if (e.style.display === "grid") return $e(e, t).min;
3038
+ if (e.style.display === "table") return tn(e, t).min;
2748
3039
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
2749
- let r = Math.max(Yt(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3040
+ let r = Math.max(Dn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2750
3041
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
2751
3042
  }
2752
3043
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
2753
3044
  }
2754
- function on(e, t, n, r) {
3045
+ function Ln(e, t, n, r) {
2755
3046
  return {
2756
3047
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
2757
3048
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -2759,38 +3050,38 @@ function on(e, t, n, r) {
2759
3050
  }
2760
3051
  //#endregion
2761
3052
  //#region src/plain-text.ts
2762
- function sn(e) {
2763
- return pn(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3053
+ function Rn(e) {
3054
+ return Wn(e).grid.map((e) => e.join("").trimEnd()).join("\n");
2764
3055
  }
2765
- function cn(e) {
2766
- let { grid: t, paints: n } = pn(e);
2767
- return t.map((e, t) => ln(e, n[t]));
3056
+ function zn(e) {
3057
+ let { grid: t, paints: n } = Wn(e);
3058
+ return t.map((e, t) => Bn(e, n[t]));
2768
3059
  }
2769
- function ln(e, t) {
3060
+ function Bn(e, t) {
2770
3061
  let n = e.length;
2771
3062
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
2772
3063
  let r = [];
2773
3064
  for (let i = 0; i < n; i++) {
2774
3065
  let n = t[i], a = r[r.length - 1];
2775
- a && un(a, n) ? a.text += e[i] : r.push({
3066
+ a && Vn(a, n) ? a.text += e[i] : r.push({
2776
3067
  text: e[i],
2777
3068
  ...n
2778
3069
  });
2779
3070
  }
2780
3071
  return r;
2781
3072
  }
2782
- function un(e, t) {
2783
- return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine;
3073
+ function Vn(e, t) {
3074
+ return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine && e.opacity === t?.opacity;
2784
3075
  }
2785
- function dn(e, t) {
2786
- e.color !== void 0 && (t.color = e.color), e.backgroundColor !== void 0 && (t.backgroundColor = e.backgroundColor), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.textDecorationLine !== void 0 && (t.textDecoration = e.textDecorationLine);
3076
+ function Hn(e, t) {
3077
+ e.color !== void 0 && (t.color = e.color), e.backgroundColor !== void 0 && (t.backgroundColor = e.backgroundColor), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.textDecorationLine !== void 0 && (t.textDecoration = e.textDecorationLine), e.opacity !== void 0 && (t.opacity = e.opacity);
2787
3078
  }
2788
- function fn(e) {
2789
- return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0;
3079
+ function Un(e) {
3080
+ return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0 && e.opacity === void 0;
2790
3081
  }
2791
- function pn(e) {
3082
+ function Wn(e) {
2792
3083
  let t = Math.max(0, e.localRect.width), n = Math.max(0, e.localRect.height), r = Array.from({ length: n }, () => Array.from({ length: t }, () => " ")), i = Array.from({ length: n }, () => Array.from({ length: t }, () => void 0));
2793
- return hn(e, 0, 0, (e, a, o, s) => {
3084
+ return Kn(e, 0, 0, (e, a, o, s) => {
2794
3085
  if (e >= 0 && e < t && a >= 0 && a < n) {
2795
3086
  r[a][e] = o;
2796
3087
  let t = i[a][e];
@@ -2804,59 +3095,62 @@ function pn(e) {
2804
3095
  paints: i
2805
3096
  };
2806
3097
  }
2807
- function mn(e) {
3098
+ function Gn(e) {
2808
3099
  let t = {};
2809
3100
  return e.color && (t.color = e.color), e.backgroundColor && (t.backgroundColor = e.backgroundColor), e.fontWeight !== "400" && e.fontWeight !== "normal" && e.fontWeight !== "" && (t.fontWeight = e.fontWeight), e.fontStyle !== "normal" && e.fontStyle !== "" && (t.fontStyle = e.fontStyle), e.textDecorationLine !== "none" && e.textDecorationLine !== "" && (t.textDecorationLine = e.textDecorationLine), t;
2810
3101
  }
2811
- function hn(t, n, i, a) {
2812
- if (t.tableHidden) return;
2813
- let o = n + t.localRect.x, s = i + t.localRect.y, c = t.style;
2814
- if (c.backgroundColor !== void 0 || c.backgroundClear) {
2815
- let e = c.backgroundColor === void 0 ? void 0 : { backgroundColor: c.backgroundColor };
2816
- for (let n = 0; n < t.localRect.height; n++) for (let r = 0; r < t.localRect.width; r++) a(o + r, s + n, " ", e);
3102
+ function Kn(e, t, n, r, i = 1) {
3103
+ if (e.tableHidden) return;
3104
+ let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3105
+ ...e,
3106
+ opacity: String(Math.round(i * 1e3) / 1e3)
3107
+ };
3108
+ if (s.backgroundColor !== void 0 || s.backgroundClear) {
3109
+ let t = s.backgroundColor === void 0 ? void 0 : c({ backgroundColor: s.backgroundColor });
3110
+ for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
2817
3111
  }
2818
3112
  let l = [];
2819
- e(c, {
2820
- x: o,
2821
- y: s,
2822
- width: t.localRect.width,
2823
- height: t.localRect.height
3113
+ k(s, {
3114
+ x: a,
3115
+ y: o,
3116
+ width: e.localRect.width,
3117
+ height: e.localRect.height
2824
3118
  }, l);
2825
3119
  for (let e of l) {
2826
- let t = e.color === void 0 ? void 0 : { color: e.color };
2827
- for (let n = 0; n < e.length; n++) a(e.x + n, e.y, e.glyph, t);
2828
- }
2829
- if (t.decorationRuns) for (let e of t.decorationRuns) {
2830
- let t = e.color === void 0 ? void 0 : { color: e.color };
2831
- for (let n = 0; n < e.length; n++) a(o + e.x + n, s + e.y, e.glyph, t);
2832
- }
2833
- if (!t.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && t.text) {
2834
- let e = t.resolvedPadding, n = o + c.border.left + e.left, r = s + c.border.top + e.top, i = t.localRect.width - c.border.left - c.border.right - e.left - e.right, l = t.multicolGeometry, { spans: u, textY: d } = l ?? Kt(t, i), f = l ? Math.max(1, l.columnWidth - c.tracking) : i, p = mn(c), m = t.inlineElements?.map((e) => mn(e));
2835
- for (let e = 0; e < u.length; e++) {
2836
- let i = u[e], o = r + d[e], s = e === 0 ? c.textIndent : 0, h = c.whiteSpace !== "normal" && c.overflow === "clip" ? gn(t.text, i, f - s, t.advances, c) : {
2837
- end: i.end,
3120
+ let t = c(e.color === void 0 ? void 0 : { color: e.color });
3121
+ for (let n = 0; n < e.length; n++) r(e.x + n, e.y, e.glyph, t);
3122
+ }
3123
+ if (e.decorationRuns) for (let t of e.decorationRuns) {
3124
+ let e = c(t.color === void 0 ? void 0 : { color: t.color });
3125
+ for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3126
+ }
3127
+ if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3128
+ let t = e.resolvedPadding, n = a + s.border.left + t.left, i = o + s.border.top + t.top, l = e.localRect.width - s.border.left - s.border.right - t.left - t.right, u = e.multicolGeometry, { spans: d, textY: f } = u ?? wn(e, l), p = u ? Math.max(1, u.columnWidth - s.tracking) : l, m = c(Gn(s)), h = e.inlineElements?.map((e) => c(Gn(e)));
3129
+ for (let t = 0; t < d.length; t++) {
3130
+ let a = d[t], o = i + f[t], l = t === 0 ? s.textIndent : 0, g = s.whiteSpace !== "normal" && s.overflow === "clip" ? qn(e.text, a, p - l, e.advances, s) : {
3131
+ end: a.end,
2838
3132
  ellipsis: !1
2839
- }, g = C(i.start, i.end, t.advances, c.tracking), _ = Math.max(0, f - s - g), v = c.textAlign === "end" ? _ : c.textAlign === "center" ? Math.floor(_ / 2) : 0, y = n + (l?.lineX[e] ?? 0) + v + s;
2840
- for (let e = i.start; e < h.end; e++) {
2841
- if (t.text[e] !== "") {
2842
- let n = t.charInline?.[e] ?? -1, r = n >= 0 ? t.inlineElements[n] : void 0, i = r?.insets, s = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, c = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
2843
- t.text[e] === "⁠" ? r?.backgroundColor && a(y + s, o + c, " ", { backgroundColor: r.backgroundColor }) : a(y + s, o + c, t.text[e], r ? m[n] : p);
3133
+ }, _ = P(a.start, a.end, e.advances, s.tracking), v = Math.max(0, p - l - _), y = s.textAlign === "end" ? v : s.textAlign === "center" ? Math.floor(v / 2) : 0, b = n + (u?.lineX[t] ?? 0) + y + l;
3134
+ for (let t = a.start; t < g.end; t++) {
3135
+ if (e.text[t] !== "") {
3136
+ let n = e.charInline?.[t] ?? -1, i = n >= 0 ? e.inlineElements[n] : void 0, a = i?.insets, s = a ? a.left ?? (a.right === null ? 0 : -a.right) : 0, l = a ? a.top ?? (a.bottom === null ? 0 : -a.bottom) : 0;
3137
+ e.text[t] === "⁠" ? i?.backgroundColor && r(b + s, o + l, " ", c({ backgroundColor: i.backgroundColor })) : r(b + s, o + l, e.text[t], i ? h[n] : m);
2844
3138
  }
2845
- y += S(e, e + 1, t.advances);
3139
+ b += ye(t, t + 1, e.advances);
2846
3140
  }
2847
- h.ellipsis && a(y, o, "…", p);
3141
+ g.ellipsis && r(b, o, "…", m);
2848
3142
  }
2849
3143
  }
2850
- for (let e of r(t)) hn(e, o, s, a);
3144
+ for (let t of te(e)) Kn(t, a, o, r, i * t.style.opacity);
2851
3145
  }
2852
- function gn(e, t, n, r, i) {
3146
+ function qn(e, t, n, r, i) {
2853
3147
  let { textOverflow: a, tracking: o } = i;
2854
- if (C(t.start, t.end, r, o) <= n) return {
3148
+ if (P(t.start, t.end, r, o) <= n) return {
2855
3149
  end: t.end,
2856
3150
  ellipsis: !1
2857
3151
  };
2858
3152
  let s = a === "ellipsis" ? n - 1 : n, c = t.start;
2859
- for (; c < t.end && C(t.start, c + 1, r, o) <= s;) c++;
3153
+ for (; c < t.end && P(t.start, c + 1, r, o) <= s;) c++;
2860
3154
  return {
2861
3155
  end: c,
2862
3156
  ellipsis: a === "ellipsis" && n > 0
@@ -2864,38 +3158,124 @@ function gn(e, t, n, r, i) {
2864
3158
  }
2865
3159
  //#endregion
2866
3160
  //#region src/paint.ts
2867
- var _n = /* @__PURE__ */ new WeakMap();
2868
- function vn(e, t) {
2869
- let n = cn(e), r = yn(n);
2870
- if (_n.get(t) === r) return;
2871
- _n.set(t, r);
2872
- let i = document.createDocumentFragment();
2873
- for (let e = 0; e < n.length; e++) {
2874
- e > 0 && i.appendChild(document.createTextNode("\n"));
2875
- for (let t of n[e]) {
2876
- if (fn(t)) {
2877
- i.appendChild(document.createTextNode(t.text));
3161
+ var Jn = /* @__PURE__ */ new WeakMap(), Yn = /* @__PURE__ */ new WeakMap();
3162
+ function Xn(e) {
3163
+ return $n(e, !0) !== null;
3164
+ }
3165
+ function Zn(e, t, n = !1) {
3166
+ let r = zn(e), i = ir(r);
3167
+ if (Jn.get(t) === i) return !0;
3168
+ let a = Yn.get(t);
3169
+ if (a && Qn(t, a.nodes, r)) {
3170
+ Jn.set(t, i);
3171
+ for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3172
+ let n = r[e][t];
3173
+ if (Un(n) || Vn(n, a.segments[e][t])) continue;
3174
+ let i = a.nodes[e][t];
3175
+ i.style.cssText = "", Hn(n, i.style);
3176
+ }
3177
+ return a.segments = r, !0;
3178
+ }
3179
+ if (n && Xn(t)) return !1;
3180
+ Jn.set(t, i);
3181
+ let o = document.createDocumentFragment(), s = [];
3182
+ for (let e = 0; e < r.length; e++) {
3183
+ e > 0 && o.appendChild(document.createTextNode("\n"));
3184
+ let t = [];
3185
+ for (let n of r[e]) {
3186
+ if (Un(n)) {
3187
+ let e = document.createTextNode(n.text);
3188
+ t.push(e), o.appendChild(e);
2878
3189
  continue;
2879
3190
  }
2880
3191
  let e = document.createElement("span");
2881
- dn(t, e.style), e.textContent = t.text, i.appendChild(e);
3192
+ Hn(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3193
+ }
3194
+ s.push(t);
3195
+ }
3196
+ Yn.set(t, {
3197
+ nodes: s,
3198
+ segments: r
3199
+ });
3200
+ let c = $n(t, !1);
3201
+ return t.replaceChildren(o), c && er(t, c), !0;
3202
+ }
3203
+ function Qn(e, t, n) {
3204
+ if (t.length !== n.length) return !1;
3205
+ for (let r = 0; r < n.length; r++) {
3206
+ let i = t[r], a = n[r];
3207
+ if (i.length !== a.length) return !1;
3208
+ for (let t = 0; t < a.length; t++) {
3209
+ let n = i[t];
3210
+ if (Un(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3211
+ }
3212
+ }
3213
+ return !0;
3214
+ }
3215
+ function $n(e, t) {
3216
+ try {
3217
+ let n = e.ownerDocument.getSelection();
3218
+ if (!n) return null;
3219
+ let r = e.getRootNode();
3220
+ if (!(r instanceof ShadowRoot)) return null;
3221
+ let i;
3222
+ if (n.getComposedRanges) {
3223
+ let e = n.getComposedRanges({ shadowRoots: [r] });
3224
+ if (e.length === 0) return null;
3225
+ i = e[0];
3226
+ } else {
3227
+ let e = r.getSelection?.();
3228
+ if (!e || e.rangeCount === 0) return null;
3229
+ i = e.getRangeAt(0);
2882
3230
  }
3231
+ let a = tr(e, i.startContainer, i.startOffset), o = tr(e, i.endContainer, i.endOffset);
3232
+ return a === null || o === null || a === o && !t ? null : {
3233
+ start: a,
3234
+ end: o,
3235
+ backward: n.direction === "backward"
3236
+ };
3237
+ } catch {
3238
+ return null;
2883
3239
  }
2884
- t.replaceChildren(i);
2885
3240
  }
2886
- function yn(e) {
3241
+ function er(e, t) {
3242
+ try {
3243
+ let n = nr(e, t.start), r = nr(e, t.end);
3244
+ if (!n || !r) return;
3245
+ let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3246
+ t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3247
+ } catch {}
3248
+ }
3249
+ function tr(e, t, n) {
3250
+ if (!e.contains(t)) return null;
3251
+ let r = e.ownerDocument.createRange();
3252
+ return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3253
+ }
3254
+ function nr(e, t) {
3255
+ let n = t, r = null;
3256
+ for (let t of rr(e)) {
3257
+ if (n <= t.data.length) return [t, n];
3258
+ n -= t.data.length, r = [t, t.data.length];
3259
+ }
3260
+ return r;
3261
+ }
3262
+ function* rr(e) {
3263
+ let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3264
+ for (; n;) yield n, n = t.nextNode();
3265
+ }
3266
+ function ir(e) {
2887
3267
  let t = [];
2888
3268
  for (let n of e) {
2889
- for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "");
3269
+ for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
2890
3270
  t.push("\n");
2891
3271
  }
2892
3272
  return t.join("");
2893
3273
  }
2894
3274
  //#endregion
2895
3275
  //#region src/render.ts
2896
- function bn(e) {
3276
+ function ar(e) {
2897
3277
  let t = /* @__PURE__ */ new Set();
2898
- xn(e, !0, t);
3278
+ or(e, !0, t);
2899
3279
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
2900
3280
  n.removeAttribute("data-mw-inline-inset");
2901
3281
  let e = n.style;
@@ -2916,129 +3296,129 @@ function Z(e, t) {
2916
3296
  function Q(e, t, n) {
2917
3297
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
2918
3298
  }
2919
- function xn(e, t, i) {
2920
- if (e.inlineElements) for (let { element: t, tracking: n, padLeft: r, padRight: a, insets: o } of e.inlineElements) {
3299
+ function or(e, t, n) {
3300
+ if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
2921
3301
  let e = t;
2922
- X(e, "--mw-ls", String(n)), r > 0 ? X(e, "--mw-ipl", String(r)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (i.add(t), Sn(e, o));
3302
+ X(e, "--mw-ls", String(r)), i > 0 ? X(e, "--mw-ipl", String(i)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (n.add(t), sr(e, o));
2923
3303
  }
2924
- if (t || wn(e), !e.tableHidden) for (let t of r(e)) {
3304
+ if (t || lr(e), !e.tableHidden) for (let t of te(e)) {
2925
3305
  let r = t.source;
2926
- t.style.zIndex !== null && n(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), xn(t, !1, i);
3306
+ t.style.zIndex !== null && j(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), or(t, !1, n);
2927
3307
  }
2928
3308
  }
2929
- function Sn(e, t) {
3309
+ function sr(e, t) {
2930
3310
  Q(e, "data-mw-inline-inset", !0);
2931
3311
  let n = (t, n) => {
2932
3312
  n === null ? Z(e, t) : X(e, t, String(n));
2933
3313
  };
2934
3314
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
2935
3315
  }
2936
- function Cn(e) {
3316
+ function cr(e) {
2937
3317
  let t = e.style;
2938
3318
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
2939
- let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? qt(e, i);
3319
+ let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? Tn(e, i);
2940
3320
  return o.length !== 0 && o.every((n, r) => {
2941
- let i = r === 0 ? t.textIndent : 0, o = a - i - C(n.start, n.end, e.advances, t.tracking);
3321
+ let i = r === 0 ? t.textIndent : 0, o = a - i - P(n.start, n.end, e.advances, t.tracking);
2942
3322
  return o > 0 && o % 2 == 1;
2943
3323
  });
2944
3324
  }
2945
- function wn(e) {
3325
+ function lr(e) {
2946
3326
  let t = e.source, n = e.localRect, r = e.resolvedPadding, { border: i, textAlignBlocked: a, overflow: o, whiteSpace: s, tracking: c, lineGap: l } = e.style, u = e.multicolFlow, d = e.multicolFlowSpan;
2947
3327
  Q(t, "data-mw-laid-out", !e.inlineBox && !u && !d), Q(t, "data-mw-inline-box", !!e.inlineBox), Q(t, "data-mw-multicol-flow", !!u), Q(t, "data-mw-multicol-flow-span", !!d);
2948
3328
  let f = u ?? d;
2949
3329
  f ? (X(t, "--mw-mt", String(f.top ?? 0)), X(t, "--mw-mr", String(f.right ?? 0)), X(t, "--mw-mb", String(f.bottom ?? 0)), X(t, "--mw-ml", String(f.left ?? 0))) : (Z(t, "--mw-mt"), Z(t, "--mw-mr"), Z(t, "--mw-mb"), Z(t, "--mw-ml")), Q(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), X(t, "--mw-ls", String(c)), X(t, "--mw-lh", String(l + 1)), X(t, "--mw-lhs", String(-l / 2)), Q(t, "data-mw-nowrap", s !== "normal");
2950
3330
  let p = u || d ? void 0 : e.multicolGeometry;
2951
- Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o === "clip"), X(t, "--mw-pt", String(r.top)), X(t, "--mw-pr", String(r.right)), X(t, "--mw-pb", String(r.bottom)), X(t, "--mw-pl", String(r.left)), X(t, "--mw-bt", String(i.top)), X(t, "--mw-br", String(i.right)), X(t, "--mw-bb", String(i.bottom)), X(t, "--mw-bl", String(i.left)), X(t, "--mw-ti", String(e.style.textIndent)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-center-nudge", Cn(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3331
+ Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o === "clip"), X(t, "--mw-pt", String(r.top)), X(t, "--mw-pr", String(r.right)), X(t, "--mw-pb", String(r.bottom)), X(t, "--mw-pl", String(r.left)), X(t, "--mw-bt", String(i.top)), X(t, "--mw-br", String(i.right)), X(t, "--mw-bb", String(i.bottom)), X(t, "--mw-bl", String(i.left)), X(t, "--mw-ti", String(e.style.textIndent)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-center-nudge", cr(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
2952
3332
  }
2953
3333
  //#endregion
2954
3334
  //#region src/style.ts
2955
- function Tn(e, t, n) {
2956
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Rn(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
2957
- Nn(e, o, s);
2958
- let c = r.display || An[e.tagName] || "", l = jn[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, m = Number.isFinite(d) ? Math.max(1, p(d, t)) : null, h = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || kn(r) ? "none" : u !== null || m !== null ? "multicol" : "block", g = { kind: "none" }, _ = { kind: "none" }, v = [fe()], y = [fe()], b = {
3335
+ function ur(e, t, n) {
3336
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = wr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3337
+ yr(e, o, s);
3338
+ let c = r.display || gr[e.tagName] || "", l = _r[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, f = Number.isFinite(d) ? Math.max(1, N(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || hr(r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [Ue()], _ = [Ue()], v = {
2959
3339
  direction: "row",
2960
3340
  dense: !1
2961
- }, x = null;
2962
- if (h === "grid") {
2963
- if (a) g = rr(a.get("grid-template-columns")?.toString() ?? "", t), _ = rr(a.get("grid-template-rows")?.toString() ?? "", t);
3341
+ }, y = null;
3342
+ if (p === "grid") {
3343
+ if (a) m = Wr(a.get("grid-template-columns")?.toString() ?? "", t), h = Wr(a.get("grid-template-rows")?.toString() ?? "", t);
2964
3344
  else {
2965
3345
  e.setAttribute("data-mw-degrid", "");
2966
3346
  try {
2967
- g = rr(r.getPropertyValue("grid-template-columns"), t), _ = rr(r.getPropertyValue("grid-template-rows"), t);
3347
+ m = Wr(r.getPropertyValue("grid-template-columns"), t), h = Wr(r.getPropertyValue("grid-template-rows"), t);
2968
3348
  } finally {
2969
3349
  e.removeAttribute("data-mw-degrid");
2970
3350
  }
2971
3351
  }
2972
- v = sr(r.getPropertyValue("grid-auto-columns"), t), y = sr(r.getPropertyValue("grid-auto-rows"), t), b = pr(r.getPropertyValue("grid-auto-flow")), x = or(r.getPropertyValue("grid-template-areas"));
3352
+ g = Jr(r.getPropertyValue("grid-auto-columns"), t), _ = Jr(r.getPropertyValue("grid-auto-rows"), t), v = ei(r.getPropertyValue("grid-auto-flow")), y = qr(r.getPropertyValue("grid-template-areas"));
2973
3353
  }
2974
- let S = "auto", C = !1, w = 0, T = 0;
2975
- if (h === "table" && (S = r.tableLayout === "fixed" ? "fixed" : "auto", C = r.borderCollapse === "collapse", !C)) {
3354
+ let b = "auto", x = !1, S = 0, C = 0;
3355
+ if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
2976
3356
  let e = r.borderSpacing.split(" ");
2977
- w = p(parseFloat(e[0] ?? "") || 0, t), T = p(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3357
+ S = N(parseFloat(e[0] ?? "") || 0, t), C = N(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
2978
3358
  }
2979
- let E = {
2980
- display: h,
3359
+ let w = {
3360
+ display: p,
2981
3361
  tableRole: l,
2982
- tableLayout: S,
2983
- borderCollapse: C,
2984
- borderSpacingX: w,
2985
- borderSpacingY: T,
3362
+ tableLayout: b,
3363
+ borderCollapse: x,
3364
+ borderSpacingX: S,
3365
+ borderSpacingY: C,
2986
3366
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
2987
- verticalAlign: l === "cell" || c.startsWith("inline-") ? Mn(e, r) : "start",
3367
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? vr(e, r) : "start",
2988
3368
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
2989
3369
  flexReverse: r.flexDirection.endsWith("-reverse"),
2990
3370
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
2991
3371
  wrapReverse: r.flexWrap === "wrap-reverse",
2992
3372
  flexGrow: Number(r.flexGrow) || 0,
2993
3373
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
2994
- flexBasis: tr(r.flexBasis, t),
3374
+ flexBasis: Hr(r.flexBasis, t),
2995
3375
  order: Number(r.order) || 0,
2996
- justifyContent: zn(r.justifyContent),
2997
- alignContent: zn(r.alignContent),
2998
- alignItems: Bn(r.alignItems),
2999
- alignSelf: Vn(r.alignSelf),
3000
- justifyItems: Bn(r.justifyItems),
3001
- justifySelf: Vn(r.justifySelf),
3002
- gridTemplateColumns: g,
3003
- gridTemplateRows: _,
3004
- gridAutoColumns: v,
3005
- gridAutoRows: y,
3006
- gridAutoFlow: b,
3007
- gridTemplateAreas: x,
3008
- gridColumnStart: fr(r.getPropertyValue("grid-column-start")),
3009
- gridColumnEnd: fr(r.getPropertyValue("grid-column-end")),
3010
- gridRowStart: fr(r.getPropertyValue("grid-row-start")),
3011
- gridRowEnd: fr(r.getPropertyValue("grid-row-end")),
3012
- width: Xn(a, r.width, "width", t, o, s, n),
3013
- height: Xn(a, r.height, "height", t, o, s, n),
3014
- minWidth: er(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Jn(r.minWidth, t) ?? "auto",
3015
- minHeight: er(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Jn(r.minHeight, t) ?? "auto",
3016
- maxWidth: er(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Jn(r.maxWidth, t),
3017
- maxHeight: er(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Jn(r.maxHeight, t),
3018
- padding: hr(r, t),
3019
- margin: Hn(r, a, o, s, t),
3020
- position: Gn(r.position),
3021
- insets: Kn(r, a, o, s, t),
3022
- gapX: $(r.columnGap === "normal" || r.columnGap === "" ? h === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3376
+ justifyContent: Tr(r.justifyContent),
3377
+ alignContent: Tr(r.alignContent),
3378
+ alignItems: Er(r.alignItems),
3379
+ alignSelf: Dr(r.alignSelf),
3380
+ justifyItems: Er(r.justifyItems),
3381
+ justifySelf: Dr(r.justifySelf),
3382
+ gridTemplateColumns: m,
3383
+ gridTemplateRows: h,
3384
+ gridAutoColumns: g,
3385
+ gridAutoRows: _,
3386
+ gridAutoFlow: v,
3387
+ gridTemplateAreas: y,
3388
+ gridColumnStart: $r(r.getPropertyValue("grid-column-start")),
3389
+ gridColumnEnd: $r(r.getPropertyValue("grid-column-end")),
3390
+ gridRowStart: $r(r.getPropertyValue("grid-row-start")),
3391
+ gridRowEnd: $r(r.getPropertyValue("grid-row-end")),
3392
+ width: Lr(a, r.width, "width", t, o, s, n),
3393
+ height: Lr(a, r.height, "height", t, o, s, n),
3394
+ minWidth: Vr(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Pr(r.minWidth, t) ?? "auto",
3395
+ minHeight: Vr(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Pr(r.minHeight, t) ?? "auto",
3396
+ maxWidth: Vr(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Pr(r.maxWidth, t),
3397
+ maxHeight: Vr(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Pr(r.maxHeight, t),
3398
+ padding: ni(r, t),
3399
+ margin: Or(r, a, o, s, t),
3400
+ position: jr(r.position),
3401
+ insets: Mr(r, a, o, s, t),
3402
+ gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3023
3403
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3024
- border: gr(r),
3404
+ border: ri(r),
3025
3405
  borderStyle: {
3026
- top: qn(r.borderTopStyle),
3027
- right: qn(r.borderRightStyle),
3028
- bottom: qn(r.borderBottomStyle),
3029
- left: qn(r.borderLeftStyle)
3406
+ top: Nr(r.borderTopStyle),
3407
+ right: Nr(r.borderRightStyle),
3408
+ bottom: Nr(r.borderBottomStyle),
3409
+ left: Nr(r.borderLeftStyle)
3030
3410
  },
3031
- overflow: On(r.overflow) || On(r.overflowX) || On(r.overflowY) ? "clip" : "visible",
3411
+ overflow: mr(r.overflow) || mr(r.overflowX) || mr(r.overflowY) ? "clip" : "visible",
3032
3412
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3033
3413
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3034
- lineGap: Wn(r.lineHeight, i),
3035
- tracking: Un(r.letterSpacing, i, n?.letterSpacing ?? 0),
3414
+ lineGap: Ar(r.lineHeight, i),
3415
+ tracking: kr(r.letterSpacing, i, n?.letterSpacing ?? 0),
3036
3416
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3037
3417
  color: r.color,
3038
3418
  fontWeight: r.fontWeight,
3039
3419
  fontStyle: r.fontStyle,
3040
3420
  textDecorationLine: r.textDecorationLine,
3041
- backgroundColor: Dn(r.backgroundColor) ? void 0 : r.backgroundColor,
3421
+ backgroundColor: pr(e, r.backgroundColor, r),
3042
3422
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3043
3423
  borderColor: {
3044
3424
  top: r.borderTopColor,
@@ -3046,31 +3426,32 @@ function Tn(e, t, n) {
3046
3426
  bottom: r.borderBottomColor,
3047
3427
  left: r.borderLeftColor
3048
3428
  },
3049
- textAlignBlocked: In(e, r),
3050
- textAlign: Ln(e, r),
3051
- textIndent: Yn(r, t),
3429
+ textAlignBlocked: Sr(e, r),
3430
+ textAlign: Cr(e, r),
3431
+ textIndent: Ir(r, t),
3432
+ opacity: Fr(r.opacity),
3052
3433
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3053
3434
  latticeBorder: null,
3054
- ruleX: h === "flex" || h === "grid" || h === "multicol" ? Fn(r, "x") : null,
3055
- ruleY: h === "flex" || h === "grid" ? Fn(r, "y") : null,
3056
- ruleBreak: Pn(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3057
- ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, f(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3058
- ruleVisibilityItems: Pn(r, "--mw-rule-visibility-items", [
3435
+ ruleX: p === "flex" || p === "grid" || p === "multicol" ? xr(r, "x") : null,
3436
+ ruleY: p === "flex" || p === "grid" ? xr(r, "y") : null,
3437
+ ruleBreak: br(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3438
+ ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, M(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3439
+ ruleVisibilityItems: br(r, "--mw-rule-visibility-items", [
3059
3440
  "all",
3060
3441
  "around",
3061
3442
  "between"
3062
3443
  ], "normal"),
3063
3444
  columnCount: u,
3064
- columnWidth: m,
3445
+ columnWidth: f,
3065
3446
  columnFill: r.columnFill === "auto" ? "auto" : "balance",
3066
3447
  columnSpan: r.columnSpan === "all",
3067
3448
  breakBeforeColumn: r.breakBefore === "column",
3068
3449
  breakAfterColumn: r.breakAfter === "column",
3069
3450
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3070
3451
  };
3071
- return En(E, r), E;
3452
+ return dr(w, r), w;
3072
3453
  }
3073
- function En(e, t) {
3454
+ function dr(e, t) {
3074
3455
  t.borderCollapse === "collapse" && (e.display === "table" || e.tableRole === "cell" || e.tableRole === "row" || e.tableRole === "row-group" || e.tableRole === "header-group" || e.tableRole === "footer-group") && (e.latticeBorder = {
3075
3456
  width: e.border,
3076
3457
  style: e.borderStyle,
@@ -3083,20 +3464,24 @@ function En(e, t) {
3083
3464
  }
3084
3465
  }, e.border = R(), e.display === "table" && (e.padding = R()));
3085
3466
  }
3086
- function Dn(e) {
3467
+ function fr(e) {
3087
3468
  if (!e) return !0;
3088
3469
  let t = e.trim().toLowerCase();
3089
3470
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3090
3471
  }
3091
- function On(e) {
3472
+ function pr(e, t, n) {
3473
+ let i = r(e, fr(t) ? "" : t, n);
3474
+ return i === "" ? void 0 : i;
3475
+ }
3476
+ function mr(e) {
3092
3477
  return e === "hidden" || e === "clip";
3093
3478
  }
3094
- function kn(e) {
3479
+ function hr(e) {
3095
3480
  if (e.position !== "absolute" && e.position !== "fixed") return !1;
3096
3481
  let t = e.clip.replace(/\s/g, "");
3097
- return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (On(e.overflow) || On(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3482
+ return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (mr(e.overflow) || mr(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3098
3483
  }
3099
- var An = {
3484
+ var gr = {
3100
3485
  TABLE: "table",
3101
3486
  THEAD: "table-header-group",
3102
3487
  TBODY: "table-row-group",
@@ -3107,7 +3492,7 @@ var An = {
3107
3492
  CAPTION: "table-caption",
3108
3493
  COL: "table-column",
3109
3494
  COLGROUP: "table-column-group"
3110
- }, jn = {
3495
+ }, _r = {
3111
3496
  "table-header-group": "header-group",
3112
3497
  "table-row-group": "row-group",
3113
3498
  "table-footer-group": "footer-group",
@@ -3117,38 +3502,38 @@ var An = {
3117
3502
  "table-column": "column",
3118
3503
  "table-column-group": "column-group"
3119
3504
  };
3120
- function Mn(e, t) {
3505
+ function vr(e, t) {
3121
3506
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3122
3507
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3123
3508
  }
3124
- function Nn(e, t, n) {
3125
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && at(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3509
+ function yr(e, t, n) {
3510
+ (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && b(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3126
3511
  }
3127
- function Pn(e, t, n, r) {
3512
+ function br(e, t, n, r) {
3128
3513
  let i = e.getPropertyValue(t).trim();
3129
3514
  return n.includes(i) ? i : r;
3130
3515
  }
3131
- function Fn(e, t) {
3132
- let n = f(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3516
+ function xr(e, t) {
3517
+ let n = M(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3133
3518
  if (n <= 0) return null;
3134
3519
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3135
3520
  return {
3136
3521
  width: n,
3137
- style: qn(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3522
+ style: Nr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3138
3523
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3139
3524
  };
3140
3525
  }
3141
- function In(e, t) {
3526
+ function Sr(e, t) {
3142
3527
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3143
3528
  }
3144
- function Ln(e, t) {
3529
+ function Cr(e, t) {
3145
3530
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3146
3531
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3147
3532
  }
3148
- function Rn(e) {
3533
+ function wr(e) {
3149
3534
  return typeof e.computedStyleMap == "function";
3150
3535
  }
3151
- function zn(e) {
3536
+ function Tr(e) {
3152
3537
  switch (e) {
3153
3538
  case "center": return "center";
3154
3539
  case "flex-end":
@@ -3163,7 +3548,7 @@ function zn(e) {
3163
3548
  default: return "start";
3164
3549
  }
3165
3550
  }
3166
- function Bn(e) {
3551
+ function Er(e) {
3167
3552
  switch (e) {
3168
3553
  case "center": return "center";
3169
3554
  case "flex-end":
@@ -3174,10 +3559,10 @@ function Bn(e) {
3174
3559
  default: return "start";
3175
3560
  }
3176
3561
  }
3177
- function Vn(e) {
3178
- return e === "auto" || e === "" || e === "normal" ? "auto" : Bn(e);
3562
+ function Dr(e) {
3563
+ return e === "auto" || e === "" || e === "normal" ? "auto" : Er(e);
3179
3564
  }
3180
- function Hn(e, t, n, r, i) {
3565
+ function Or(e, t, n, r, i) {
3181
3566
  let a = (a, o, s) => {
3182
3567
  if (t) {
3183
3568
  let e = t.get(a)?.toString().trim();
@@ -3201,16 +3586,16 @@ function Hn(e, t, n, r, i) {
3201
3586
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3202
3587
  };
3203
3588
  }
3204
- function Un(e, t, n) {
3589
+ function kr(e, t, n) {
3205
3590
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3206
3591
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3207
3592
  }
3208
- function Wn(e, t) {
3593
+ function Ar(e, t) {
3209
3594
  if (!e || e === "normal" || t <= 0) return 0;
3210
3595
  let n = parseFloat(e);
3211
3596
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3212
3597
  }
3213
- function Gn(e) {
3598
+ function jr(e) {
3214
3599
  switch (e) {
3215
3600
  case "relative":
3216
3601
  case "absolute":
@@ -3219,7 +3604,7 @@ function Gn(e) {
3219
3604
  default: return "static";
3220
3605
  }
3221
3606
  }
3222
- function Kn(e, t, n, r, i) {
3607
+ function Mr(e, t, n, r, i) {
3223
3608
  let a = (a, o) => {
3224
3609
  if (t) {
3225
3610
  let e = t.get(a)?.toString().trim();
@@ -3238,7 +3623,7 @@ function Kn(e, t, n, r, i) {
3238
3623
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3239
3624
  };
3240
3625
  }
3241
- function qn(e) {
3626
+ function Nr(e) {
3242
3627
  switch (e) {
3243
3628
  case "double": return "double";
3244
3629
  case "dashed": return "dashed";
@@ -3246,7 +3631,7 @@ function qn(e) {
3246
3631
  default: return "solid";
3247
3632
  }
3248
3633
  }
3249
- function Jn(e, t) {
3634
+ function Pr(e, t) {
3250
3635
  if (!e || e === "none" || e === "auto") return;
3251
3636
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3252
3637
  if (e.endsWith("%")) {
@@ -3254,7 +3639,7 @@ function Jn(e, t) {
3254
3639
  return Number.isFinite(t) ? { percent: t } : void 0;
3255
3640
  }
3256
3641
  let n = parseFloat(e);
3257
- return Number.isFinite(n) ? p(n, t) : void 0;
3642
+ return Number.isFinite(n) ? N(n, t) : void 0;
3258
3643
  }
3259
3644
  function $(e, t) {
3260
3645
  if (!e || e === "auto" || e === "none") return 0;
@@ -3263,26 +3648,30 @@ function $(e, t) {
3263
3648
  return Number.isFinite(t) && t !== 0 ? { percent: t } : 0;
3264
3649
  }
3265
3650
  let n = parseFloat(e);
3266
- return Number.isFinite(n) ? p(n, t) : 0;
3651
+ return Number.isFinite(n) ? N(n, t) : 0;
3652
+ }
3653
+ function Fr(e) {
3654
+ let t = parseFloat(e);
3655
+ return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3267
3656
  }
3268
- function Yn(e, t) {
3657
+ function Ir(e, t) {
3269
3658
  let n = e.textIndent;
3270
3659
  if (!n || n.endsWith("%")) return 0;
3271
3660
  let r = parseFloat(n);
3272
- return Number.isFinite(r) ? Math.max(0, p(r, t)) : 0;
3661
+ return Number.isFinite(r) ? Math.max(0, N(r, t)) : 0;
3273
3662
  }
3274
- function Xn(e, t, n, r, i, a, o) {
3275
- let s = Zn(n === "width" ? a.width : a.height);
3663
+ function Lr(e, t, n, r, i, a, o) {
3664
+ let s = Rr(n === "width" ? a.width : a.height);
3276
3665
  if (s !== null) return {
3277
3666
  kind: "cells",
3278
- value: $n(s, n, o, r)
3667
+ value: Br(s, n, o, r)
3279
3668
  };
3280
- let c = Qn(i, n === "width" ? "w" : "h");
3669
+ let c = zr(i, n === "width" ? "w" : "h");
3281
3670
  if (c !== null) {
3282
3671
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3283
3672
  if (a || !Number.isFinite(i)) return {
3284
3673
  kind: "cells",
3285
- value: $n(a ? i : c, n, o, r)
3674
+ value: Br(a ? i : c, n, o, r)
3286
3675
  };
3287
3676
  }
3288
3677
  if (e) {
@@ -3290,7 +3679,7 @@ function Xn(e, t, n, r, i, a, o) {
3290
3679
  if (t == null) return;
3291
3680
  let i = t.toString().trim();
3292
3681
  if (i === "auto") return { kind: "auto" };
3293
- let a = nr(i);
3682
+ let a = Ur(i);
3294
3683
  if (a) return a;
3295
3684
  if (i.endsWith("%")) return {
3296
3685
  kind: "percent",
@@ -3298,22 +3687,22 @@ function Xn(e, t, n, r, i, a, o) {
3298
3687
  };
3299
3688
  if (i.endsWith("px")) return {
3300
3689
  kind: "cells",
3301
- value: p(parseFloat(i), r)
3690
+ value: N(parseFloat(i), r)
3302
3691
  };
3303
3692
  if (i.endsWith("rem")) return {
3304
3693
  kind: "cells",
3305
- value: f(parseFloat(i) / .25)
3694
+ value: M(parseFloat(i) / .25)
3306
3695
  };
3307
- let s = Zn(i);
3696
+ let s = Rr(i);
3308
3697
  if (s !== null) return {
3309
3698
  kind: "cells",
3310
- value: $n(s, n, o, r)
3699
+ value: Br(s, n, o, r)
3311
3700
  };
3312
3701
  }
3313
3702
  let l = n === "width" ? a.width : a.height;
3314
3703
  if (l) {
3315
3704
  if (l === "auto") return { kind: "auto" };
3316
- let e = nr(l);
3705
+ let e = Ur(l);
3317
3706
  if (e) return e;
3318
3707
  if (l.endsWith("%")) return {
3319
3708
  kind: "percent",
@@ -3322,7 +3711,7 @@ function Xn(e, t, n, r, i, a, o) {
3322
3711
  let t = parseFloat(l);
3323
3712
  if (Number.isFinite(t)) return {
3324
3713
  kind: "cells",
3325
- value: p(t, r)
3714
+ value: N(t, r)
3326
3715
  };
3327
3716
  }
3328
3717
  let u = n === "width" ? "w" : "h";
@@ -3338,28 +3727,28 @@ function Xn(e, t, n, r, i, a, o) {
3338
3727
  kind: "percent",
3339
3728
  value: 100
3340
3729
  };
3341
- let m = RegExp(`(?:^|[\\s:.[!])${u}-\\[(\\d+(?:\\.\\d+)?)%\\]`).exec(i);
3342
- if (m) return {
3730
+ let f = RegExp(`(?:^|[\\s:.[!])${u}-\\[(\\d+(?:\\.\\d+)?)%\\]`).exec(i);
3731
+ if (f) return {
3343
3732
  kind: "percent",
3344
- value: Number(m[1])
3733
+ value: Number(f[1])
3345
3734
  };
3346
- let h = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
3347
- if (h) return {
3735
+ let p = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
3736
+ if (p) return {
3348
3737
  kind: "cells",
3349
- value: f(Number(h[1]))
3738
+ value: M(Number(p[1]))
3350
3739
  };
3351
- if (!mr(i, u) || t === "auto") return { kind: "auto" };
3740
+ if (!ti(i, u) || t === "auto") return { kind: "auto" };
3352
3741
  if (t.endsWith("%")) return {
3353
3742
  kind: "percent",
3354
3743
  value: parseFloat(t)
3355
3744
  };
3356
- let g = parseFloat(t);
3357
- if (Number.isFinite(g)) return {
3745
+ let m = parseFloat(t);
3746
+ if (Number.isFinite(m)) return {
3358
3747
  kind: "cells",
3359
- value: p(g, r)
3748
+ value: N(m, r)
3360
3749
  };
3361
3750
  }
3362
- function Zn(e) {
3751
+ function Rr(e) {
3363
3752
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
3364
3753
  if (!t || typeof window > "u") return null;
3365
3754
  let n = parseFloat(t[1]);
@@ -3367,7 +3756,7 @@ function Zn(e) {
3367
3756
  let r = t[2], i = window.innerHeight, a = window.innerWidth, o = r.endsWith("h") ? i : r.endsWith("min") ? Math.min(a, i) : r.endsWith("max") ? Math.max(a, i) : r === "vb" ? i : a;
3368
3757
  return n / 100 * o;
3369
3758
  }
3370
- function Qn(e, t) {
3759
+ function zr(e, t) {
3371
3760
  if (typeof window > "u") return null;
3372
3761
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
3373
3762
  if (n) {
@@ -3375,23 +3764,23 @@ function Qn(e, t) {
3375
3764
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
3376
3765
  }
3377
3766
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
3378
- return r ? Zn(r[1]) : null;
3767
+ return r ? Rr(r[1]) : null;
3379
3768
  }
3380
- function $n(e, t, n, r) {
3769
+ function Br(e, t, n, r) {
3381
3770
  let i = t === "width" ? n?.width : n?.height;
3382
- return i && i > 0 ? Math.max(0, Math.floor(e / i)) : p(e, r);
3771
+ return i && i > 0 ? Math.max(0, Math.floor(e / i)) : N(e, r);
3383
3772
  }
3384
- function er(e, t, n, r, i, a, o, s) {
3385
- let c = t.endsWith("width") ? "width" : "height", l = Zn(a.getPropertyValue(t)) ?? Zn(e?.get(t)?.toString().trim() ?? "");
3386
- if (l !== null) return $n(l, c, o, s);
3387
- let u = Qn(r, i);
3773
+ function Vr(e, t, n, r, i, a, o, s) {
3774
+ let c = t.endsWith("width") ? "width" : "height", l = Rr(a.getPropertyValue(t)) ?? Rr(e?.get(t)?.toString().trim() ?? "");
3775
+ if (l !== null) return Br(l, c, o, s);
3776
+ let u = zr(r, i);
3388
3777
  if (u === null) return;
3389
3778
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
3390
- if (!(!f && Number.isFinite(d))) return $n(f ? d : u, c, o, s);
3779
+ if (!(!f && Number.isFinite(d))) return Br(f ? d : u, c, o, s);
3391
3780
  }
3392
- function tr(e, t) {
3781
+ function Hr(e, t) {
3393
3782
  if (!e || e === "auto" || e === "content") return;
3394
- let n = nr(e);
3783
+ let n = Ur(e);
3395
3784
  if (n) return n;
3396
3785
  if (e.endsWith("%")) {
3397
3786
  let t = parseFloat(e);
@@ -3403,30 +3792,30 @@ function tr(e, t) {
3403
3792
  let r = parseFloat(e);
3404
3793
  return Number.isFinite(r) ? {
3405
3794
  kind: "cells",
3406
- value: p(r, t)
3795
+ value: N(r, t)
3407
3796
  } : void 0;
3408
3797
  }
3409
- function nr(e) {
3798
+ function Ur(e) {
3410
3799
  if (e === "min-content") return { kind: "min-content" };
3411
3800
  if (e === "max-content") return { kind: "max-content" };
3412
3801
  if (e === "fit-content") return { kind: "fit-content" };
3413
3802
  }
3414
- function rr(e, t) {
3803
+ function Wr(e, t) {
3415
3804
  let n = e.trim();
3416
3805
  if (!n || n === "none") return { kind: "none" };
3417
3806
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
3418
3807
  let r = [], i = [], a = [], o = (e) => {
3419
3808
  i.push(a), a = [], r.push(e);
3420
3809
  }, s;
3421
- for (let e of dr(n)) {
3422
- let n = ar(e);
3810
+ for (let e of Qr(n)) {
3811
+ let n = Kr(e);
3423
3812
  if (n) {
3424
3813
  a.push(...n);
3425
3814
  continue;
3426
3815
  }
3427
3816
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
3428
3817
  if (i) {
3429
- let e = ir(i[2].trim(), t);
3818
+ let e = Gr(i[2].trim(), t);
3430
3819
  if (e.tracks.length === 0) continue;
3431
3820
  let n = i[1];
3432
3821
  if (n === "auto-fill" || n === "auto-fit") {
@@ -3444,7 +3833,7 @@ function rr(e, t) {
3444
3833
  }
3445
3834
  continue;
3446
3835
  }
3447
- o(cr(e, t));
3836
+ o(Yr(e, t));
3448
3837
  }
3449
3838
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
3450
3839
  let c = {
@@ -3453,26 +3842,26 @@ function rr(e, t) {
3453
3842
  };
3454
3843
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
3455
3844
  }
3456
- function ir(e, t) {
3845
+ function Gr(e, t) {
3457
3846
  let n = [], r = [], i = [];
3458
- for (let a of dr(e)) {
3459
- let e = ar(a);
3847
+ for (let a of Qr(e)) {
3848
+ let e = Kr(a);
3460
3849
  if (e) {
3461
3850
  i.push(...e);
3462
3851
  continue;
3463
3852
  }
3464
- r.push(i), i = [], n.push(cr(a, t));
3853
+ r.push(i), i = [], n.push(Yr(a, t));
3465
3854
  }
3466
3855
  return r.push(i), {
3467
3856
  tracks: n,
3468
3857
  lineNames: r
3469
3858
  };
3470
3859
  }
3471
- function ar(e) {
3860
+ function Kr(e) {
3472
3861
  let t = e.match(/^\[(.*)\]$/s);
3473
3862
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
3474
3863
  }
3475
- function or(e) {
3864
+ function qr(e) {
3476
3865
  let t = [];
3477
3866
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
3478
3867
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -3502,23 +3891,23 @@ function or(e) {
3502
3891
  areas: r
3503
3892
  };
3504
3893
  }
3505
- function sr(e, t) {
3506
- let n = dr(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => cr(e, t));
3507
- return n.length > 0 ? n : [fe()];
3894
+ function Jr(e, t) {
3895
+ let n = Qr(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Yr(e, t));
3896
+ return n.length > 0 ? n : [Ue()];
3508
3897
  }
3509
- function cr(e, t) {
3898
+ function Yr(e, t) {
3510
3899
  let n = e.match(/^minmax\((.*)\)$/s);
3511
3900
  if (n) {
3512
- let e = ur(n[1]).map((e) => e.trim());
3901
+ let e = Zr(n[1]).map((e) => e.trim());
3513
3902
  return e.length === 2 ? {
3514
- min: lr(e[0], t),
3515
- max: lr(e[1], t)
3903
+ min: Xr(e[0], t),
3904
+ max: Xr(e[1], t)
3516
3905
  } : {
3517
3906
  min: { kind: "auto" },
3518
3907
  max: { kind: "auto" }
3519
3908
  };
3520
3909
  }
3521
- let r = lr(e, t);
3910
+ let r = Xr(e, t);
3522
3911
  return r.kind === "fr" ? {
3523
3912
  min: { kind: "auto" },
3524
3913
  max: r
@@ -3527,13 +3916,13 @@ function cr(e, t) {
3527
3916
  max: r
3528
3917
  };
3529
3918
  }
3530
- function lr(e, t) {
3919
+ function Xr(e, t) {
3531
3920
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
3532
3921
  if (e === "min-content") return { kind: "min-content" };
3533
3922
  if (e === "max-content") return { kind: "max-content" };
3534
3923
  let n = e.match(/^(min|max)\((.*)\)$/s);
3535
3924
  if (n) {
3536
- let e = ur(n[2]).map((e) => lr(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
3925
+ let e = Zr(n[2]).map((e) => Xr(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
3537
3926
  return e.length > 0 && r ? {
3538
3927
  kind: "math",
3539
3928
  fn: n[1],
@@ -3557,10 +3946,10 @@ function lr(e, t) {
3557
3946
  let r = parseFloat(e);
3558
3947
  return Number.isFinite(r) ? {
3559
3948
  kind: "cells",
3560
- value: e.endsWith("rem") ? f(r / .25) : p(r, t)
3949
+ value: e.endsWith("rem") ? M(r / .25) : N(r, t)
3561
3950
  } : { kind: "auto" };
3562
3951
  }
3563
- function ur(e) {
3952
+ function Zr(e) {
3564
3953
  let t = [], n = 0, r = 0;
3565
3954
  for (let i = 0; i < e.length; i++) {
3566
3955
  let a = e[i];
@@ -3568,7 +3957,7 @@ function ur(e) {
3568
3957
  }
3569
3958
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
3570
3959
  }
3571
- function dr(e) {
3960
+ function Qr(e) {
3572
3961
  let t = [], n = 0, r = -1;
3573
3962
  for (let i = 0; i < e.length; i++) {
3574
3963
  let a = e[i];
@@ -3576,7 +3965,7 @@ function dr(e) {
3576
3965
  }
3577
3966
  return r !== -1 && t.push(e.slice(r)), t;
3578
3967
  }
3579
- function fr(e) {
3968
+ function $r(e) {
3580
3969
  let t = e.trim();
3581
3970
  if (!t || t === "auto") return { kind: "auto" };
3582
3971
  let n = !1, r, i;
@@ -3604,16 +3993,16 @@ function fr(e) {
3604
3993
  nth: r
3605
3994
  };
3606
3995
  }
3607
- function pr(e) {
3996
+ function ei(e) {
3608
3997
  return {
3609
3998
  direction: e.includes("column") ? "column" : "row",
3610
3999
  dense: e.includes("dense")
3611
4000
  };
3612
4001
  }
3613
- function mr(e, t) {
4002
+ function ti(e, t) {
3614
4003
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
3615
4004
  }
3616
- function hr(e, t) {
4005
+ function ni(e, t) {
3617
4006
  return {
3618
4007
  top: $(e.getPropertyValue("padding-top"), t),
3619
4008
  right: $(e.getPropertyValue("padding-right"), t),
@@ -3621,8 +4010,8 @@ function hr(e, t) {
3621
4010
  left: $(e.getPropertyValue("padding-left"), t)
3622
4011
  };
3623
4012
  }
3624
- function gr(e) {
3625
- let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : f(parseFloat(e.getPropertyValue(t)) || 0);
4013
+ function ri(e) {
4014
+ let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : M(parseFloat(e.getPropertyValue(t)) || 0);
3626
4015
  return {
3627
4016
  top: t("border-top-width", "border-top-style"),
3628
4017
  right: t("border-right-width", "border-right-style"),
@@ -3632,47 +4021,49 @@ function gr(e) {
3632
4021
  }
3633
4022
  //#endregion
3634
4023
  //#region src/tree.ts
3635
- function _r(e, t, n, r) {
3636
- let i = Tn(e, t, n);
4024
+ function ii(e, t, n, r) {
4025
+ let i = ur(e, t, n);
3637
4026
  if (i.display === "none") return null;
3638
- let a = Array.from(e.children), o = a.map(Sr), s = e.tagName, c = Nr(s);
3639
- if (!o.includes("block") || c) {
3640
- let l = Cr(e, i.tracking, {
4027
+ let a = T(e.tagName);
4028
+ if (a) return ai(e, i, a);
4029
+ let o = Array.from(e.children), s = o.map(ui), c = e.tagName, l = xi(c);
4030
+ if (!s.includes("block") || l) {
4031
+ let a = di(e, i.tracking, {
3641
4032
  rootFontSizePx: t,
3642
4033
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
3643
4034
  cellMetrics: n,
3644
4035
  textareaWidths: r,
3645
4036
  preserve: i.whiteSpace === "pre",
3646
4037
  tabSize: i.tabSize
3647
- }), u = l.chars.join("");
3648
- if (l.boxes.length > 0) {
3649
- let e = Ht();
3650
- E(l.chars, (t, n) => {
3651
- l.advances[t] = Math.max(1, J(l.boxes[n], e));
4038
+ }), u = a.chars.join("");
4039
+ if (a.boxes.length > 0) {
4040
+ let e = bn();
4041
+ Se(a.chars, (t, n) => {
4042
+ a.advances[t] = Math.max(1, J(a.boxes[n], e));
3652
4043
  });
3653
4044
  }
3654
- let d = Or(u, l.advances, i.tracking);
3655
- if (c && d === 0) {
3656
- if (s === "INPUT") d = Number(e.size) || 20;
3657
- else if (s === "TEXTAREA") d = Number(e.cols) || 20;
4045
+ let d = gi(u, a.advances, i.tracking);
4046
+ if (l && d === 0) {
4047
+ if (c === "INPUT") d = Number(e.size) || 20;
4048
+ else if (c === "TEXTAREA") d = Number(e.cols) || 20;
3658
4049
  else {
3659
4050
  let t = e, n = (e) => e?.label || e?.textContent || "", r = getComputedStyle(e).getPropertyValue("field-sizing") === "content" ? [n(t.selectedOptions[0])] : Array.from(t.options, n);
3660
4051
  d = Math.max(1, ...r.map((e) => e.trim().length));
3661
4052
  }
3662
4053
  }
3663
- let f = u.length > 0 ? kr(u) : 0, p;
3664
- if (s === "TEXTAREA") {
3665
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? v(n, a) + o : n === "" ? 0 : n.split(/\r\n?|\n/).length, c = getComputedStyle(e).getPropertyValue("field-sizing") === "content" ? 1 : Number(t.rows) || 2, l = Math.max(c, s);
4054
+ let f = u.length > 0 ? _i(u) : 0, p;
4055
+ if (c === "TEXTAREA") {
4056
+ let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? he(n, a) + o : n === "" ? 0 : n.split(/\r\n?|\n/).length, c = getComputedStyle(e).getPropertyValue("field-sizing") === "content" ? 1 : Number(t.rows) || 2, l = Math.max(c, s);
3666
4057
  p = l + Math.max(0, l - 1) * i.lineGap;
3667
- } else p = c ? Math.max(1, f) : f;
4058
+ } else p = l ? Math.max(1, f) : f;
3668
4059
  let m = /* @__PURE__ */ new Map(), h = [];
3669
- for (let t of l.boxes) t.source.parentElement === e ? m.set(t.source, t) : h.push(t);
4060
+ for (let t of a.boxes) t.source.parentElement === e ? m.set(t.source, t) : h.push(t);
3670
4061
  let g = [];
3671
- for (let e = 0; e < a.length; e++) {
3672
- let i = a[e], s = m.get(i);
3673
- if (s) g.push(s);
3674
- else if (o[e] === "out-of-flow") {
3675
- let e = _r(i, t, n, r);
4062
+ for (let e = 0; e < o.length; e++) {
4063
+ let i = o[e], a = m.get(i);
4064
+ if (a) g.push(a);
4065
+ else if (s[e] === "out-of-flow") {
4066
+ let e = ii(i, t, n, r);
3676
4067
  e && g.push(e);
3677
4068
  }
3678
4069
  }
@@ -3693,18 +4084,18 @@ function _r(e, t, n, r) {
3693
4084
  unclampedHeight: 0,
3694
4085
  resolvedPadding: R()
3695
4086
  };
3696
- return (l.advances.some((e) => e !== 1) || l.boxes.length > 0) && (_.advances = l.advances), l.inlineElements.length > 0 && (_.inlineElements = l.inlineElements, _.charInline = l.chars.map((e, t) => l.inlineIndex[t] ?? -1)), _;
4087
+ return (a.advances.some((e) => e !== 1) || a.boxes.length > 0) && (_.advances = a.advances), a.inlineElements.length > 0 && (_.inlineElements = a.inlineElements, _.charInline = a.chars.map((e, t) => a.inlineIndex[t] ?? -1)), _;
3697
4088
  }
3698
- let l = [];
3699
- for (let e = 0; e < a.length; e++) {
3700
- if (o[e] === "none") continue;
3701
- let i = _r(a[e], t, n, r);
3702
- i && l.push(i);
4089
+ let u = [];
4090
+ for (let e = 0; e < o.length; e++) {
4091
+ if (s[e] === "none") continue;
4092
+ let i = ii(o[e], t, n, r);
4093
+ i && u.push(i);
3703
4094
  }
3704
- let u = {
4095
+ let d = {
3705
4096
  source: e,
3706
4097
  style: i,
3707
- children: l,
4098
+ children: u,
3708
4099
  text: "",
3709
4100
  intrinsicWidth: 0,
3710
4101
  intrinsicHeight: 0,
@@ -3717,25 +4108,68 @@ function _r(e, t, n, r) {
3717
4108
  unclampedHeight: 0,
3718
4109
  resolvedPadding: R()
3719
4110
  };
3720
- return Pr(e, u), u;
4111
+ return Si(e, d), d;
4112
+ }
4113
+ function ai(e, t, n) {
4114
+ let r = ee(n, e), i = r?.lines ?? [], a = i.join("\n");
4115
+ t.whiteSpace = "pre";
4116
+ let o = gi(a, Array.from({ length: a.length }, () => 1), t.tracking), s = i.length, c = {
4117
+ source: e,
4118
+ style: t,
4119
+ children: [],
4120
+ text: a,
4121
+ intrinsicWidth: o,
4122
+ intrinsicHeight: s,
4123
+ localRect: {
4124
+ x: 0,
4125
+ y: 0,
4126
+ width: o,
4127
+ height: s
4128
+ },
4129
+ unclampedHeight: 0,
4130
+ resolvedPadding: R()
4131
+ }, l = r?.runs ?? [];
4132
+ if (l.length > 0 && a.length > 0) {
4133
+ let t = [0];
4134
+ for (let e of i) t.push(t[t.length - 1] + e.length + 1);
4135
+ let n = Array.from({ length: a.length }, () => -1);
4136
+ c.inlineElements = l.map((t) => ({
4137
+ element: e,
4138
+ tracking: 0,
4139
+ padLeft: 0,
4140
+ padRight: 0,
4141
+ insets: null,
4142
+ color: t.paint.color,
4143
+ backgroundColor: t.paint.backgroundColor,
4144
+ fontWeight: t.paint.fontWeight ?? "",
4145
+ fontStyle: t.paint.fontStyle ?? "",
4146
+ textDecorationLine: t.paint.textDecorationLine ?? ""
4147
+ })), l.forEach((e, r) => {
4148
+ let a = i[e.line];
4149
+ if (a === void 0) return;
4150
+ let o = Math.max(0, e.start), s = Math.min(a.length, e.end);
4151
+ for (let i = o; i < s; i++) n[t[e.line] + i] = r;
4152
+ }), c.charInline = n;
4153
+ }
4154
+ return c;
3721
4155
  }
3722
- var vr = /* @__PURE__ */ new Set(/* @__PURE__ */ "A.ABBR.B.BDI.BDO.BR.CITE.CODE.DATA.DFN.EM.I.KBD.MARK.Q.S.SAMP.SMALL.SPAN.STRONG.SUB.SUP.TIME.U.VAR.WBR".split("."));
3723
- function yr(e, t) {
3724
- return t || (vr.has(e.tagName) ? "inline" : "block");
4156
+ var oi = /* @__PURE__ */ new Set(/* @__PURE__ */ "A.ABBR.B.BDI.BDO.BR.CITE.CODE.DATA.DFN.EM.I.KBD.MARK.Q.S.SAMP.SMALL.SPAN.STRONG.SUB.SUP.TIME.U.VAR.WBR".split("."));
4157
+ function si(e, t) {
4158
+ return t || (oi.has(e.tagName) ? "inline" : "block");
3725
4159
  }
3726
- function br(e, t) {
3727
- let n = yr(e, t);
4160
+ function ci(e, t) {
4161
+ let n = si(e, t);
3728
4162
  return n === "inline" || n === "contents";
3729
4163
  }
3730
- function xr(e, t) {
3731
- let n = yr(e, t);
4164
+ function li(e, t) {
4165
+ let n = si(e, t);
3732
4166
  return n.startsWith("inline") && n !== "inline";
3733
4167
  }
3734
- function Sr(e) {
4168
+ function ui(e) {
3735
4169
  let t = getComputedStyle(e);
3736
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : br(e, t.display) || xr(e, t.display) ? "inline" : "block";
4170
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : T(e.tagName) ? "block" : ci(e, t.display) || li(e, t.display) ? "inline" : "block";
3737
4171
  }
3738
- function Cr(e, t, n) {
4172
+ function di(e, t, n) {
3739
4173
  let r = {
3740
4174
  chars: [],
3741
4175
  advances: [],
@@ -3743,15 +4177,15 @@ function Cr(e, t, n) {
3743
4177
  inlineElements: [],
3744
4178
  boxes: []
3745
4179
  };
3746
- return wr(e, t, n, r), n.preserve ? r : Dr(r);
4180
+ return fi(e, t, n, r), n.preserve ? r : hi(r);
3747
4181
  }
3748
- function wr(e, t, n, r) {
4182
+ function fi(e, t, n, r) {
3749
4183
  let i = () => {
3750
4184
  let e = 0;
3751
4185
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
3752
4186
  return e;
3753
4187
  };
3754
- if (!Nr(e.tagName)) {
4188
+ if (!xi(e.tagName)) {
3755
4189
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
3756
4190
  if (n.preserve) for (let e of (a.textContent ?? "").replace(/\r\n?/g, "\n")) if (e === "\n") r.chars.push("\n"), r.advances.push(0);
3757
4191
  else if (e === " ") {
@@ -3767,24 +4201,24 @@ function wr(e, t, n, r) {
3767
4201
  }
3768
4202
  let t = getComputedStyle(e);
3769
4203
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
3770
- if (xr(e, t.display)) {
3771
- let t = _r(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4204
+ if (li(e, t.display)) {
4205
+ let t = ii(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
3772
4206
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
3773
4207
  continue;
3774
4208
  }
3775
- if (!br(e, t.display)) {
3776
- Ar(e);
4209
+ if (!ci(e, t.display)) {
4210
+ vi(e);
3777
4211
  continue;
3778
4212
  }
3779
- let i = Un(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Tr(t.paddingLeft, n.rootFontSizePx), s = Tr(t.paddingRight, n.rootFontSizePx);
4213
+ let i = kr(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = pi(t.paddingLeft, n.rootFontSizePx), s = pi(t.paddingRight, n.rootFontSizePx);
3780
4214
  r.inlineElements.push({
3781
4215
  element: e,
3782
4216
  tracking: i,
3783
4217
  padLeft: o,
3784
4218
  padRight: s,
3785
- insets: t.position === "static" ? null : Er(t, n.rootFontSizePx),
4219
+ insets: t.position === "static" ? null : mi(t, n.rootFontSizePx),
3786
4220
  color: t.color,
3787
- backgroundColor: Dn(t.backgroundColor) ? void 0 : t.backgroundColor,
4221
+ backgroundColor: fr(t.backgroundColor) ? void 0 : t.backgroundColor,
3788
4222
  fontWeight: t.fontWeight,
3789
4223
  fontStyle: t.fontStyle,
3790
4224
  textDecorationLine: t.textDecorationLine
@@ -3792,22 +4226,22 @@ function wr(e, t, n, r) {
3792
4226
  let c = r.inlineElements.length - 1;
3793
4227
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
3794
4228
  let l = r.chars.length;
3795
- wr(e, i, n, r);
4229
+ fi(e, i, n, r);
3796
4230
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
3797
4231
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
3798
4232
  }
3799
4233
  }
3800
4234
  }
3801
- function Tr(e, t) {
4235
+ function pi(e, t) {
3802
4236
  if (!e || e.endsWith("%")) return 0;
3803
4237
  let n = parseFloat(e);
3804
- return Number.isFinite(n) ? Math.max(0, p(n, t)) : 0;
4238
+ return Number.isFinite(n) ? Math.max(0, N(n, t)) : 0;
3805
4239
  }
3806
- function Er(e, t) {
4240
+ function mi(e, t) {
3807
4241
  let n = (e) => {
3808
4242
  if (!e || e === "auto" || e.endsWith("%")) return null;
3809
4243
  let n = parseFloat(e);
3810
- return Number.isFinite(n) ? p(n, t) : null;
4244
+ return Number.isFinite(n) ? N(n, t) : null;
3811
4245
  };
3812
4246
  return {
3813
4247
  top: n(e.top),
@@ -3816,7 +4250,7 @@ function Er(e, t) {
3816
4250
  left: n(e.left)
3817
4251
  };
3818
4252
  }
3819
- function Dr(e) {
4253
+ function hi(e) {
3820
4254
  let t = [], n = [], r = [], i = () => {
3821
4255
  let e = t.length;
3822
4256
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -3841,42 +4275,47 @@ function Dr(e) {
3841
4275
  boxes: e.boxes
3842
4276
  };
3843
4277
  }
3844
- function Or(e, t, n) {
4278
+ function gi(e, t, n) {
3845
4279
  let r = 0, i = 0;
3846
- for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, C(i, a, t, n)), i = a + 1);
4280
+ for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, P(i, a, t, n)), i = a + 1);
3847
4281
  return r;
3848
4282
  }
3849
- function kr(e) {
3850
- return b(e).length;
4283
+ function _i(e) {
4284
+ return _e(e).length;
3851
4285
  }
3852
- function Ar(e) {
3853
- at(e, "A block-level element nested inside a text run can't be laid out and was skipped. Give it its own place in the layout instead.");
4286
+ function vi(e) {
4287
+ b(e, "A block-level element nested inside a text run can't be laid out and was skipped. Give it its own place in the layout instead.");
3854
4288
  }
3855
- function jr(e) {
4289
+ function yi(e) {
3856
4290
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
3857
4291
  }
3858
- var Mr = "Direct text next to block-level children can't be laid out and was hidden. Wrap each text segment in its own element (e.g. a <div>).";
3859
- function Nr(e) {
4292
+ var bi = "Direct text next to block-level children can't be laid out and was hidden. Wrap each text segment in its own element (e.g. a <div>).";
4293
+ function xi(e) {
3860
4294
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
3861
4295
  }
3862
- function Pr(e, t) {
3863
- jr(e) && (t.droppedText = !0, at(e, Mr));
4296
+ function Si(e, t) {
4297
+ yi(e) && (t.droppedText = !0, b(e, bi));
3864
4298
  }
3865
4299
  //#endregion
3866
4300
  //#region src/element.ts
3867
- var Fr = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n #grid { position: absolute; inset: 0; margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; pointer-events: none; user-select: none; -webkit-user-select: none; }\n :host([select=\"grid\"]) #grid { pointer-events: auto; user-select: text; -webkit-user-select: text; }\n :host([select=\"grid\"]) slot { pointer-events: none; user-select: none; -webkit-user-select: none; }\n /* Full invert on selection (TUI-native, matches focus-visible).\n * Both fields spelled out — setting only color makes some engines\n * drop the OS default background. */\n ::selection { color: var(--mw-bg, canvas); background: var(--mw-fg, canvastext); }\n</style>\n<div id=\"viewport\">\n <pre id=\"grid\" aria-hidden=\"true\"></pre>\n <slot></slot>\n</div>\n", Ir = "grid", Lr = [
4301
+ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n #grid { position: absolute; inset: 0; margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; pointer-events: none; user-select: none; -webkit-user-select: none; }\n :host([select=\"grid\"]) #grid { pointer-events: auto; user-select: text; -webkit-user-select: text; }\n :host([select=\"grid\"]) slot { pointer-events: none; user-select: none; -webkit-user-select: none; }\n /* Full invert on selection (TUI-native, matches focus-visible).\n * Both fields spelled out — setting only color makes some engines\n * drop the OS default background. */\n ::selection { color: var(--mw-bg, canvas); background: var(--mw-fg, canvastext); }\n</style>\n<div id=\"viewport\">\n <pre id=\"grid\" aria-hidden=\"true\"></pre>\n <slot></slot>\n</div>\n", wi = "grid", Ti = [
3868
4302
  "pointerover",
3869
4303
  "pointerleave",
4304
+ "pointerdown",
4305
+ "pointerup",
4306
+ "pointercancel",
4307
+ "keydown",
4308
+ "keyup",
3870
4309
  "focusin",
3871
4310
  "focusout",
3872
4311
  "input",
3873
4312
  "change"
3874
- ], Rr = typeof HTMLElement > "u" ? class {} : HTMLElement, zr = class e extends Rr {
4313
+ ], Ei = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, Di = 3e4, Oi = typeof HTMLElement > "u" ? class {} : HTMLElement, ki = class e extends Oi {
3875
4314
  static observedAttributes = ["select"];
3876
4315
  static #e = /* @__PURE__ */ new Set();
3877
4316
  static #t = null;
3878
4317
  static #n = () => {
3879
- for (let t of e.#e) t.#y();
4318
+ for (let t of e.#e) t.#W();
3880
4319
  };
3881
4320
  static #r(t) {
3882
4321
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -3905,11 +4344,9 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3905
4344
  #d = !1;
3906
4345
  #f = null;
3907
4346
  #p = null;
3908
- constructor() {
3909
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Fr, this.#s = this.#o.getElementById("grid"), this.#c = document.createElement("span"), this.#c.setAttribute("aria-hidden", "true"), this.#c.setAttribute("data-mw-probe", ""), this.#c.style.cssText = "position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;", this.#c.textContent = "M".repeat(100);
3910
- }
3911
- connectedCallback() {
3912
- this.hasAttribute("select") || this.setAttribute("select", Ir), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#y()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#h), this.#u = new MutationObserver(() => this.#y()), this.#u.observe(this, {
4347
+ #m = null;
4348
+ #h() {
4349
+ this.#u?.observe(this, {
3913
4350
  childList: !0,
3914
4351
  subtree: !0,
3915
4352
  characterData: !0,
@@ -3919,43 +4356,142 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3919
4356
  "style",
3920
4357
  "colspan",
3921
4358
  "rowspan",
3922
- "span"
4359
+ "span",
4360
+ ...E()
3923
4361
  ]
3924
- }), document.fonts?.ready.then(this.#g).catch((e) => {
4362
+ });
4363
+ }
4364
+ constructor() {
4365
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Ci, this.#s = this.#o.getElementById("grid"), this.#c = document.createElement("span"), this.#c.setAttribute("aria-hidden", "true"), this.#c.setAttribute("data-mw-probe", ""), this.#c.style.cssText = "position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;", this.#c.textContent = "M".repeat(100);
4366
+ }
4367
+ connectedCallback() {
4368
+ this.hasAttribute("select") || this.setAttribute("select", wi), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#W()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#B), this.#u = new MutationObserver(() => this.#W()), this.#h(), this.#m = D(() => {
4369
+ this.#h(), this.#W();
4370
+ }), document.fonts?.ready.then(this.#V).catch((e) => {
3925
4371
  console.warn("[monowind] document.fonts.ready failed:", e);
3926
- }), document.fonts?.addEventListener("loadingdone", this.#g);
3927
- for (let e of Lr) this.addEventListener(e, this.#m);
3928
- e.#i(this), this.#y();
4372
+ }), document.fonts?.addEventListener("loadingdone", this.#V);
4373
+ for (let e of Ti) this.addEventListener(e, this.#z);
4374
+ this.addEventListener("transitionrun", this.#I), this.addEventListener("transitionend", this.#L), this.addEventListener("transitioncancel", this.#L), this.addEventListener("pointermove", this.#E), this.addEventListener("pointerleave", this.#D), this.addEventListener("pointerdown", this.#O), window.addEventListener("pointerup", this.#k), window.addEventListener("pointercancel", this.#k), document.addEventListener("scroll", this.#A, {
4375
+ capture: !0,
4376
+ passive: !0
4377
+ }), e.#i(this), this.#W();
3929
4378
  }
3930
4379
  disconnectedCallback() {
3931
- window.removeEventListener("resize", this.#h), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, document.fonts?.removeEventListener("loadingdone", this.#g);
3932
- for (let e of Lr) this.removeEventListener(e, this.#m);
3933
- e.#a(this);
4380
+ window.removeEventListener("resize", this.#B), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, document.fonts?.removeEventListener("loadingdone", this.#V);
4381
+ for (let e of Ti) this.removeEventListener(e, this.#z);
4382
+ this.removeEventListener("transitionrun", this.#I), this.removeEventListener("transitionend", this.#L), this.removeEventListener("transitioncancel", this.#L), this.#N = 0, this.removeEventListener("pointermove", this.#E), this.removeEventListener("pointerleave", this.#D), this.removeEventListener("pointerdown", this.#O), window.removeEventListener("pointerup", this.#k), window.removeEventListener("pointercancel", this.#k), document.removeEventListener("scroll", this.#A, { capture: !0 }), this.#x = null, this.#v = null, this.#y = !1, this.#b = !1, this.#j(), e.#a(this);
4383
+ }
4384
+ #g = /* @__PURE__ */ new Set();
4385
+ #_ = /* @__PURE__ */ new Set();
4386
+ #v = null;
4387
+ #y = !1;
4388
+ #b = !1;
4389
+ #x = null;
4390
+ #S = NaN;
4391
+ #C = NaN;
4392
+ #w = null;
4393
+ static #T = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4394
+ #E = (e) => {
4395
+ let { clientX: t, clientY: n } = e;
4396
+ this.#x = {
4397
+ x: t,
4398
+ y: n
4399
+ };
4400
+ let r = this.#w, i = this.#f;
4401
+ if (r && i) {
4402
+ let e = Math.floor((t - r.left) / i.width), a = Math.floor((n - r.top) / i.height);
4403
+ if (e === this.#S && a === this.#C) return;
4404
+ }
4405
+ this.#j();
4406
+ };
4407
+ #D = () => {
4408
+ this.#x = null, this.#j();
4409
+ };
4410
+ #O = (e) => {
4411
+ let t = e;
4412
+ !t.isPrimary || t.button !== 0 || (this.#x = {
4413
+ x: t.clientX,
4414
+ y: t.clientY
4415
+ }, this.#y = !0, this.#j(!0));
4416
+ };
4417
+ #k = (e) => {
4418
+ e.isPrimary && (!this.#y && !this.#v || (this.#y = !1, this.#v = null, this.#j(), this.#b && this.#W()));
4419
+ };
4420
+ #A = () => {
4421
+ this.#x && (this.#w = null, this.#j());
4422
+ };
4423
+ #j(t = !1) {
4424
+ let n = this.#p, r = this.#f, i = [];
4425
+ if (this.#x && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#y || e.#T?.matches)) {
4426
+ if (!this.#w) {
4427
+ let e = this.#s.getBoundingClientRect();
4428
+ this.#w = {
4429
+ left: e.left,
4430
+ top: e.top
4431
+ };
4432
+ }
4433
+ this.#S = Math.floor((this.#x.x - this.#w.left) / r.width), this.#C = Math.floor((this.#x.y - this.#w.top) / r.height), i = ue(n, this.#S, this.#C);
4434
+ } else this.#S = NaN, this.#C = NaN;
4435
+ let a = i.at(-1) ?? null;
4436
+ t && (this.#v = a);
4437
+ let o = e.#T?.matches ? i : [], s = this.#v ? i.indexOf(this.#v) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#M("data-mw-hover", this.#g, o);
4438
+ l = this.#M("data-mw-active", this.#_, c) || l;
4439
+ let u = a ? getComputedStyle(a).cursor : "";
4440
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#W();
4441
+ }
4442
+ #M(e, t, n) {
4443
+ let r = !1, i = new Set(n);
4444
+ for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4445
+ for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
4446
+ t.clear();
4447
+ for (let e of i) t.add(e);
4448
+ return r;
4449
+ }
4450
+ #N = 0;
4451
+ #P = !1;
4452
+ #F = 0;
4453
+ #I = (e) => {
4454
+ Ei.test(e.propertyName) && (this.#N++, this.#F = performance.now(), this.#R());
4455
+ };
4456
+ #L = (e) => {
4457
+ Ei.test(e.propertyName) && (this.#N = Math.max(0, this.#N - 1));
4458
+ };
4459
+ #R() {
4460
+ if (this.#P) return;
4461
+ this.#P = !0;
4462
+ let e = () => {
4463
+ if (!this.isConnected || this.#N === 0 && !a() || performance.now() - this.#F > Di) {
4464
+ this.#P = !1, this.#N = 0, this.#W();
4465
+ return;
4466
+ }
4467
+ this.#U(), requestAnimationFrame(e);
4468
+ };
4469
+ requestAnimationFrame(e);
3934
4470
  }
3935
- #m = (e) => {
4471
+ #z = (e) => {
3936
4472
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
3937
- this.#v();
4473
+ this.#U();
3938
4474
  return;
3939
4475
  }
3940
- this.#y();
4476
+ this.#W();
3941
4477
  };
3942
4478
  attributeChangedCallback(e, t, n) {
3943
4479
  if (e === "select" && n !== "text" && n !== "grid") {
3944
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Ir);
4480
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", wi);
3945
4481
  return;
3946
4482
  }
3947
- this.#y();
4483
+ e === "select" && this.#j(), this.#W();
3948
4484
  }
3949
4485
  toPlainText() {
3950
- return this.#d && this.#b(), this.#p ? sn(this.#p) : "";
4486
+ return this.#d && this.#G(), this.#p ? Rn(this.#p) : "";
3951
4487
  }
3952
- #h = () => {
3953
- this.#y();
4488
+ #B = () => {
4489
+ this.#W();
3954
4490
  };
3955
- #g = () => {
3956
- requestAnimationFrame(() => this.#y());
4491
+ #V = () => {
4492
+ requestAnimationFrame(() => this.#W());
3957
4493
  };
3958
- #_() {
4494
+ #H() {
3959
4495
  let e = document.activeElement;
3960
4496
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
3961
4497
  try {
@@ -3964,23 +4500,23 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3964
4500
  return !1;
3965
4501
  }
3966
4502
  }
3967
- #v() {
4503
+ #U() {
3968
4504
  try {
3969
- this.#b();
4505
+ this.#G();
3970
4506
  } catch (e) {
3971
4507
  console.error("[monowind] layout failed:", e);
3972
4508
  }
3973
4509
  }
3974
- #y() {
4510
+ #W() {
3975
4511
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
3976
- if (this.#d = !1, this.#_()) {
3977
- this.#y();
4512
+ if (this.#d = !1, this.#H()) {
4513
+ this.#W();
3978
4514
  return;
3979
4515
  }
3980
- this.#v();
4516
+ this.#U();
3981
4517
  }));
3982
4518
  }
3983
- #b() {
4519
+ #G() {
3984
4520
  if (!this.isConnected) return;
3985
4521
  let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
3986
4522
  if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
@@ -3990,23 +4526,23 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3990
4526
  this.setAttribute("measuring", "");
3991
4527
  try {
3992
4528
  this.#c.parentNode !== this && this.appendChild(this.#c);
3993
- let t = h(this, this.#c), n = this.#f;
4529
+ let t = fe(this, this.#c), n = this.#f;
3994
4530
  (n === null || n.width !== t.width || n.height !== t.height || n.letterSpacing !== t.letterSpacing || n.inkOverhang !== t.inkOverhang) && (this.style.setProperty("--mw-cw", `${t.width}px`), this.style.setProperty("--mw-ch", `${t.height}px`), this.style.setProperty("--mw-rls", `${t.letterSpacing}px`), this.style.setProperty("--mw-ink", `${t.inkOverhang ?? 0}px`)), this.#f = t;
3995
4531
  let r = getComputedStyle(this), i = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), a = Math.max(0, Math.floor((this.clientWidth - i) / t.width));
3996
4532
  if (a === 0) return;
3997
- let o = g(), s = [];
4533
+ let o = pe(), s = [];
3998
4534
  for (let n of Array.from(this.children)) {
3999
4535
  if (n === this.#c) continue;
4000
- let r = _r(n, o, t, e);
4536
+ let r = ii(n, o, t, e);
4001
4537
  r && s.push(r);
4002
4538
  }
4003
- if (jr(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Mr}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
4539
+ if (yi(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${bi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
4004
4540
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
4005
4541
  return;
4006
4542
  }
4007
4543
  let c = {
4008
4544
  source: this,
4009
- style: de(),
4545
+ style: He(),
4010
4546
  children: s,
4011
4547
  text: "",
4012
4548
  intrinsicWidth: 0,
@@ -4019,19 +4555,19 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
4019
4555
  },
4020
4556
  unclampedHeight: 0,
4021
4557
  resolvedPadding: R()
4022
- }, { height: l } = Bt(c, a);
4023
- bn(c), vn(c, this.#s), this.#p = c;
4558
+ }, { height: l } = vn(c, a);
4559
+ ar(c), this.#b = !Zn(c, this.#s, this.#y), this.#p = c;
4024
4560
  let u = r.boxSizing === "border-box" ? (parseFloat(r.paddingTop) || 0) + (parseFloat(r.paddingBottom) || 0) + (parseFloat(r.borderTopWidth) || 0) + (parseFloat(r.borderBottomWidth) || 0) : 0, d = `${l * t.height + u}px`;
4025
4561
  this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
4026
4562
  } finally {
4027
- this.removeAttribute("measuring"), this.#u?.takeRecords();
4563
+ this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#u?.takeRecords(), i(this) && (a() ? (this.#F = performance.now(), this.#R()) : this.#W()), this.#w = null, this.#x && this.#j();
4028
4564
  }
4029
4565
  }
4030
4566
  };
4031
- function Br() {
4032
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", zr);
4567
+ function Ai() {
4568
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", ki);
4033
4569
  }
4034
4570
  //#endregion
4035
- export { zr as MonoWindElement, Br as defineMonoWind, $e as multicolLines, sn as renderPlainText, _ as wrapLines };
4571
+ export { ki as MonoWindElement, Ai as defineMonoWind, w as invalidateLeaves, Mt as multicolLines, C as registerLeafRenderer, Rn as renderPlainText, me as wrapLines };
4036
4572
 
4037
4573
  //# sourceMappingURL=index.js.map