monowind 0.1.3 → 0.1.5

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,14 +1,269 @@
1
+ //#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)
17
+ };
18
+ s.width <= 0 || s.height <= 0 || t(r, e.borderStyle, e.borderColor, s, a);
19
+ }
20
+ }
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({
24
+ glyph: a.h,
25
+ x: g,
26
+ y: f,
27
+ length: _ - g,
28
+ color: n.top
29
+ }), i.bottom && m > +!!i.top && _ > g && e.push({
30
+ glyph: s.h,
31
+ x: g,
32
+ y: f + m - 1,
33
+ length: _ - g,
34
+ color: n.bottom
35
+ }), i.left) for (let t = v; t < y; t++) e.push({
36
+ glyph: l.v,
37
+ x: d,
38
+ y: t,
39
+ length: 1,
40
+ color: n.left
41
+ });
42
+ if (i.right && p > +!!i.left) for (let t = v; t < y; t++) e.push({
43
+ glyph: o.v,
44
+ x: d + p - 1,
45
+ y: t,
46
+ length: 1,
47
+ color: n.right
48
+ });
49
+ h && (i.top && i.left && e.push({
50
+ glyph: u(t.top, t.left, (e) => e.tl),
51
+ x: d,
52
+ y: f,
53
+ length: 1,
54
+ color: n.top
55
+ }), i.top && i.right && e.push({
56
+ glyph: u(t.top, t.right, (e) => e.tr),
57
+ x: d + p - 1,
58
+ y: f,
59
+ length: 1,
60
+ color: n.top
61
+ }), i.bottom && i.left && e.push({
62
+ glyph: u(t.bottom, t.left, (e) => e.bl),
63
+ x: d,
64
+ y: f + m - 1,
65
+ length: 1,
66
+ color: n.bottom
67
+ }), 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,
71
+ length: 1,
72
+ color: n.bottom
73
+ }));
74
+ }
75
+ function n(e, t) {
76
+ return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
77
+ }
78
+ function r(e) {
79
+ 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 : [
83
+ ...t ?? [],
84
+ ...r ?? [],
85
+ ...i ?? []
86
+ ];
87
+ }
88
+ function i(e, t) {
89
+ let n = c(e);
90
+ return t === "h" ? n.h : n.v;
91
+ }
92
+ function a(e, t, n, r, i) {
93
+ return (e === "double" ? s : o)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
94
+ }
95
+ var o = [
96
+ " ",
97
+ "─",
98
+ "─",
99
+ "─",
100
+ "│",
101
+ "┌",
102
+ "┐",
103
+ "┬",
104
+ "│",
105
+ "└",
106
+ "┘",
107
+ "┴",
108
+ "│",
109
+ "├",
110
+ "┤",
111
+ "┼"
112
+ ], s = [
113
+ " ",
114
+ "═",
115
+ "═",
116
+ "═",
117
+ "║",
118
+ "╔",
119
+ "╗",
120
+ "╦",
121
+ "║",
122
+ "╚",
123
+ "╝",
124
+ "╩",
125
+ "║",
126
+ "╠",
127
+ "╣",
128
+ "╬"
129
+ ];
130
+ function c(e) {
131
+ let t = (t, n, r, i) => a(e, t, n, r, i), n = {
132
+ h: t(!1, !1, !0, !0),
133
+ v: t(!0, !0, !1, !1),
134
+ tl: t(!1, !0, !1, !0),
135
+ tr: t(!1, !0, !0, !1),
136
+ bl: t(!0, !1, !1, !0),
137
+ br: t(!0, !1, !0, !1)
138
+ };
139
+ return e === "dashed" ? {
140
+ ...n,
141
+ h: "╌",
142
+ v: "╎"
143
+ } : e === "dotted" ? {
144
+ ...n,
145
+ h: "┄",
146
+ v: "┊"
147
+ } : n;
148
+ }
149
+ function l(e, t, n, r) {
150
+ let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
151
+ for (let n = 0; n < e.length; n++) if (a.push({
152
+ start: e[n].start,
153
+ end: e[n].end,
154
+ covered: i[n]
155
+ }), n + 1 < e.length) {
156
+ let r = t === "intersection" ? !1 : t === "none" ? i[n] || i[n + 1] : i[n] && i[n + 1];
157
+ a.push({
158
+ start: e[n].end,
159
+ end: e[n + 1].start,
160
+ covered: r
161
+ });
162
+ }
163
+ let o = [];
164
+ for (let e of a) {
165
+ if (!e.covered) continue;
166
+ let t = o[o.length - 1];
167
+ t && t.end === e.start ? t.end = e.end : o.push({
168
+ start: e.start,
169
+ end: e.end
170
+ });
171
+ }
172
+ if (r === "overlap-join") {
173
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
174
+ for (let r = 0; r + 1 < e.length; r++) {
175
+ let i = e[r].end, a = e[r + 1].start - i;
176
+ a <= 0 || (n.set(i, i + Math.ceil(a / 2)), t.set(e[r + 1].start, i + Math.floor(a / 2)));
177
+ }
178
+ return o.map((e) => {
179
+ let r = t.get(e.start), i = n.get(e.end);
180
+ return {
181
+ start: r ?? e.start,
182
+ end: i ?? e.end,
183
+ startHalf: r !== void 0,
184
+ endHalf: i !== void 0
185
+ };
186
+ });
187
+ }
188
+ return o.map((e) => ({
189
+ start: e.start + r,
190
+ end: e.end - r
191
+ })).filter((e) => e.end > e.start);
192
+ }
193
+ function u(e) {
194
+ let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, o = (e, t) => ({
195
+ line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
196
+ start: t.start,
197
+ end: t.end,
198
+ startHalf: t.startHalf === !0,
199
+ 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);
201
+ 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,
207
+ y: r + s,
208
+ length: 1,
209
+ color: e.ruleX.color
210
+ });
211
+ d(e, t, "x", i.line, i.start, i.end);
212
+ }
213
+ }
214
+ 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);
221
+ 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"),
223
+ x: n + d,
224
+ y: r + m,
225
+ length: 1,
226
+ color: e.ruleY.color
227
+ });
228
+ }
229
+ }
230
+ d(e, t, "y", p.line, p.start, p.end);
231
+ }
232
+ }
233
+ return t;
234
+ }
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";
238
+ t.push({
239
+ glyph: a(d, o, c, l, u),
240
+ x: e,
241
+ y: n,
242
+ length: 1,
243
+ color: i
244
+ });
245
+ };
246
+ if (n === "x") for (let t = 0; t < s.width; t++) {
247
+ 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);
249
+ }
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);
253
+ }
254
+ }
255
+ //#endregion
1
256
  //#region src/metrics.ts
2
- function e(e) {
257
+ function f(e) {
3
258
  return (e >= 0 ? Math.floor(e + .5) : -Math.floor(-e + .5)) || 0;
4
259
  }
5
- function t(t, n) {
6
- return n <= 0 ? 0 : e(t / (.25 * n));
260
+ function p(e, t) {
261
+ return t <= 0 ? 0 : f(e / (.25 * t));
7
262
  }
8
- function n(t, n) {
9
- return e(n * t / 100);
263
+ function m(e, t) {
264
+ return f(t * e / 100);
10
265
  }
11
- function r(e, t) {
266
+ function h(e, t) {
12
267
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0;
13
268
  return {
14
269
  width: n.width / 100,
@@ -16,47 +271,56 @@ function r(e, t) {
16
271
  letterSpacing: r
17
272
  };
18
273
  }
19
- function i() {
274
+ function g() {
20
275
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
21
276
  }
22
277
  //#endregion
23
278
  //#region src/wrap.ts
24
- function a(e) {
279
+ function _(e, t, n = {}) {
280
+ return x(e, t, n).map((t) => e.slice(t.start, t.end));
281
+ }
282
+ function v(e, t, n = {}) {
283
+ return x(e, t, n).length;
284
+ }
285
+ function y(e, t) {
286
+ return t.endsWith("\n") && e.pop(), e;
287
+ }
288
+ function b(e) {
25
289
  let t = [], n = 0;
26
290
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
27
291
  start: n,
28
292
  end: r
29
293
  }), n = r + 1);
30
- return t;
294
+ return y(t, e);
31
295
  }
32
- function o(e, t, n = {}) {
33
- if (!/[^ \t\r\n\f]/.test(e)) return [];
296
+ function x(e, t, n = {}) {
297
+ if (!/[^ \t\r\f]/.test(e)) return [];
34
298
  let r = [], i = 0;
35
- for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r.push(...h(e, i, a, t, n)), i = a + 1);
36
- return r;
299
+ for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r.push(...A(e, i, a, t, n)), i = a + 1);
300
+ return y(r, e);
37
301
  }
38
- function s(e, t, n) {
302
+ function S(e, t, n) {
39
303
  if (!n) return t - e;
40
304
  let r = 0;
41
305
  for (let i = e; i < t; i++) r += n[i] ?? 1;
42
306
  return r;
43
307
  }
44
- function c(e, t, n, r = 0) {
45
- return t <= e ? 0 : s(e, t, n) - Math.min(r, l(t - 1, n));
308
+ function C(e, t, n, r = 0) {
309
+ return t <= e ? 0 : S(e, t, n) - Math.min(r, w(t - 1, n));
46
310
  }
47
- function l(e, t) {
311
+ function w(e, t) {
48
312
  return t ? (t[e] ?? 1) - 1 : 0;
49
313
  }
50
- function u(e, t = {}) {
314
+ function T(e, t = {}) {
51
315
  let { advances: n, tracking: r = 0 } = t, i = 0;
52
- for (let t of m(e, 0, e.length)) for (let a of f(e, t.start, t.end)) i = Math.max(i, c(a.start, a.end, n, r));
316
+ 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));
53
317
  return i;
54
318
  }
55
- function d(e, t) {
319
+ function E(e, t) {
56
320
  let n = 0;
57
321
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
58
322
  }
59
- function f(e, t, n) {
323
+ function D(e, t, n) {
60
324
  let r = [], i = t;
61
325
  for (let a = t; a < n; a++) {
62
326
  if (e[a] === "") {
@@ -70,26 +334,27 @@ function f(e, t, n) {
70
334
  continue;
71
335
  }
72
336
  if (e[a] !== "-") continue;
337
+ let o = a === t;
73
338
  for (; a + 1 < n && e[a + 1] === "-";) a++;
74
- let t = a + 1;
75
- t < n && !/[0-9]/.test(e[t]) && (r.push({
339
+ let s = a + 1;
340
+ !o && s < n && (r.push({
76
341
  start: i,
77
- end: t
78
- }), i = t);
342
+ end: s
343
+ }), i = s);
79
344
  }
80
345
  return r.push({
81
346
  start: i,
82
347
  end: n
83
348
  }), r;
84
349
  }
85
- var p = /[ \t\r\n\f]/;
86
- function m(e, t, n) {
350
+ var O = /[ \t\r\n\f]/;
351
+ function k(e, t, n) {
87
352
  let r = [], i = t;
88
353
  for (; i < n;) {
89
- for (; i < n && p.test(e[i]);) i++;
354
+ for (; i < n && O.test(e[i]);) i++;
90
355
  if (i >= n) break;
91
356
  let t = i;
92
- for (; i < n && !p.test(e[i]);) i++;
357
+ for (; i < n && !O.test(e[i]);) i++;
93
358
  r.push({
94
359
  start: t,
95
360
  end: i
@@ -97,8 +362,8 @@ function m(e, t, n) {
97
362
  }
98
363
  return r;
99
364
  }
100
- function h(e, t, n, r, { advances: i, tracking: a = 0 }) {
101
- let o = m(e, t, n);
365
+ function A(e, t, n, r, { advances: i, tracking: a = 0 }) {
366
+ let o = k(e, t, n);
102
367
  if (o.length === 0) return [{
103
368
  start: t,
104
369
  end: t
@@ -107,57 +372,90 @@ function h(e, t, n, r, { advances: i, tracking: a = 0 }) {
107
372
  start: o[0].start,
108
373
  end: o[o.length - 1].end
109
374
  }];
110
- let u = [], d = null, p = 0;
375
+ let s = [], c = null, l = 0;
111
376
  for (let t of o) {
112
377
  let n = !1;
113
- for (let o of f(e, t.start, t.end)) {
114
- let e = o.start, t = o.end, f = d !== null && !n ? e - 1 : e, m = p + s(f, t, i), h = Math.min(a, l(t - 1, i));
115
- if (d !== null && m - h <= r) d.end = t, p = m;
378
+ for (let o of D(e, t.start, t.end)) {
379
+ let e = o.start, t = o.end, u = c !== null && !n ? e - 1 : e, d = l + S(u, t, i), f = Math.min(a, w(t - 1, i));
380
+ if (c !== null && d - f <= r) c.end = t, l = d;
116
381
  else {
117
- for (d !== null && u.push(d);;) {
382
+ for (c !== null && s.push(c);;) {
118
383
  let n = e;
119
- for (; n < t && c(e, n + 1, i, a) <= r;) n++;
384
+ for (; n < t && C(e, n + 1, i, a) <= r;) n++;
120
385
  if (n === t || n === e) break;
121
- u.push({
386
+ s.push({
122
387
  start: e,
123
388
  end: n
124
389
  }), e = n;
125
390
  }
126
- d = {
391
+ c = {
127
392
  start: e,
128
393
  end: t
129
- }, p = s(e, t, i);
394
+ }, l = S(e, t, i);
130
395
  }
131
396
  n = !0;
132
397
  }
133
398
  }
134
- return d !== null && u.push(d), u;
399
+ return c !== null && s.push(c), s;
135
400
  }
136
401
  //#endregion
137
402
  //#region src/flex.ts
138
- function g(e, t, n, r, i, a, o) {
139
- let s = W(e.style.gapX, t), c = W(e.style.gapY, n), l = D(e).map((e) => {
403
+ function j(e, t) {
404
+ let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
405
+ for (let e = 1; e < n.length; e++) {
406
+ let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
407
+ a > i && r.push({
408
+ start: i,
409
+ end: a
410
+ });
411
+ }
412
+ return r;
413
+ }
414
+ function M(e, t, n, r, i) {
415
+ if (e.style.ruleBreak !== "intersection") return [{
416
+ start: 0,
417
+ end: i
418
+ }];
419
+ let a = [t[n - 1], t[n]].flatMap((e) => j(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
420
+ start: e,
421
+ end: t,
422
+ spanned: !1,
423
+ beforeOccupied: !0,
424
+ afterOccupied: !0
425
+ }), s = [], c = 0;
426
+ for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
427
+ return c < i && s.push(o(c, i)), l(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
428
+ }
429
+ function N(e, t) {
430
+ return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
431
+ ...e,
432
+ start: e.start + t,
433
+ end: e.end - t
434
+ })).filter((e) => e.end > e.start);
435
+ }
436
+ function P(e, t, n, r, i, a, o) {
437
+ let s = At(e.style, "x", t), c = At(e.style, "y", n), l = oe(e).map((e) => {
140
438
  let n = G(e.style.margin, t);
141
439
  return {
142
440
  node: e,
143
- base: E(e, t, o),
441
+ base: ae(e, t, o),
144
442
  grow: e.style.flexGrow,
145
443
  shrink: e.style.flexShrink,
146
- min: A(e, t, o),
444
+ min: le(e, t, o),
147
445
  max: q(e.style.maxWidth, t),
148
446
  margin: n
149
447
  };
150
- }), u = [];
448
+ }), d = [];
151
449
  if (e.style.flexWrap === "wrap") {
152
450
  let n = [], r = 0;
153
451
  for (let e of l) {
154
452
  let i = Math.max(0, U(e.base, e.min, e.max)) + (e.margin.left ?? 0) + (e.margin.right ?? 0), a = n.length === 0 ? i : r + s + i;
155
- n.length > 0 && a > t && (u.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
453
+ n.length > 0 && a > t && (d.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
156
454
  }
157
- n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
158
- } else u.push(l);
159
- let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
160
- 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, U(e.base, e.min, e.max))) : S(e, a);
455
+ n.length > 0 && d.push(n), e.style.wrapReverse && d.reverse();
456
+ } else d.push(l);
457
+ let f = i.left + a.left, p = i.top + a.top, m = d.map((e) => {
458
+ 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, U(e.base, e.min, e.max))) : ie(e, a);
161
459
  for (let n = 0; n < e.length; n++) H(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
162
460
  return {
163
461
  row: e,
@@ -165,49 +463,81 @@ function g(e, t, n, r, i, a, o) {
165
463
  availableForItems: a,
166
464
  height: e.reduce((e, t) => Math.max(e, t.node.localRect.height), 0)
167
465
  };
168
- }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
169
- if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
466
+ }), h = m.map((e) => e.height), g = c * Math.max(0, m.length - 1), _;
467
+ if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (h[0] = Math.max(n, h[0] ?? 0)), _ = [0];
170
468
  else {
171
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = O(e.style);
469
+ let t = h.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - g) : 0, i = se(e.style);
172
470
  if (i === "stretch" && r > 0) {
173
- let e = C(Array.from({ length: p.length }, () => 1), r);
174
- for (let t = 0; t < m.length; t++) m[t] += e[t];
175
- g = x("start", m, 0);
176
- } else g = x(i === "stretch" ? "start" : i, m, r);
471
+ let e = I(Array.from({ length: m.length }, () => 1), r);
472
+ for (let t = 0; t < h.length; t++) h[t] += e[t];
473
+ _ = F("start", h, 0);
474
+ } else _ = F(i === "stretch" ? "start" : i, h, r);
177
475
  }
178
- for (let i = 0; i < p.length; i++) {
179
- let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
476
+ for (let i = 0; i < m.length; i++) {
477
+ let { row: a, widths: l, availableForItems: u } = m[i], d = h[i], g = _[i] + i * c;
180
478
  for (let i = 0; i < a.length; i++) {
181
- let s = a[i].node, c = w(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
182
- if (c === "stretch" && !d && !f && h > s.localRect.height) {
183
- let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = U(Math.max(0, h - e - a), q(s.style.minHeight, c) ?? 0, q(s.style.maxHeight, c));
184
- if (d === s.localRect.height) continue;
479
+ let s = a[i].node, c = L(s, e), u = a[i].margin, f = u.top === null || u.bottom === null, p = s.style.height !== void 0 && s.style.height.kind !== "auto";
480
+ if (c === "stretch" && !f && !p && d > s.localRect.height) {
481
+ let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, f = U(Math.max(0, d - e - a), q(s.style.minHeight, c) ?? 0, q(s.style.maxHeight, c));
482
+ if (f === s.localRect.height) continue;
185
483
  H(s, t, r, 0, 0, "fill", o, {
186
484
  width: l[i],
187
- height: d
485
+ height: f
188
486
  });
189
487
  }
190
488
  }
191
- let v = l.reduce((e, t) => e + t, 0), b = Math.max(0, u - v), S = a.reduce((e, t) => e + +(t.margin.left === null) + +(t.margin.right === null), 0), T = Array.from({ length: a.length }, () => 0), E = Array.from({ length: a.length }, () => 0), D;
192
- if (S > 0 && b > 0) {
193
- let e = C(Array.from({ length: S }, () => 1), b), t = 0;
194
- for (let n = 0; n < a.length; n++) a[n].margin.left === null && (T[n] = e[t++]), a[n].margin.right === null && (E[n] = e[t++]);
195
- D = x("start", l, 0);
196
- } else D = x(k(e.style), l, b);
197
- let O = 0;
489
+ let v = l.reduce((e, t) => e + t, 0), y = Math.max(0, u - v), b = a.reduce((e, t) => e + +(t.margin.left === null) + +(t.margin.right === null), 0), x = Array.from({ length: a.length }, () => 0), S = Array.from({ length: a.length }, () => 0), C;
490
+ if (b > 0 && y > 0) {
491
+ let e = I(Array.from({ length: b }, () => 1), y), t = 0;
492
+ 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++]);
493
+ C = F("start", l, 0);
494
+ } else C = F(ce(e.style), l, y);
495
+ let w = 0;
198
496
  for (let t = 0; t < a.length; t++) {
199
497
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
200
- O += T[t] + i, r.localRect = {
498
+ w += x[t] + i, r.localRect = {
201
499
  ...r.localRect,
202
- x: d + D[t] + t * s + O,
203
- y: f + _ + y(r, e.style.alignItems, h, n.margin)
204
- }, O += E[t] + o;
500
+ x: f + C[t] + t * s + w,
501
+ y: p + g + ne(r, e.style.alignItems, d, n.margin)
502
+ }, w += S[t] + o;
205
503
  }
206
504
  }
207
- let v = m.reduce((e, t) => e + t, 0) + h, b = Number.isFinite(n) ? Math.max(n, v) : v;
208
- return _(e, i, a, t, b), b;
505
+ let v = h.reduce((e, t) => e + t, 0) + g, y = Number.isFinite(n) ? Math.max(n, v) : v;
506
+ if (e.style.ruleX || e.style.ruleY) {
507
+ let n = [], r = [];
508
+ for (let i = 0; i < m.length; i++) {
509
+ let a = _[i] + i * c;
510
+ for (let e of j(m[i], f)) n.push({
511
+ bandStart: e.start,
512
+ bandSize: e.end - e.start,
513
+ start: a,
514
+ end: a + h[i]
515
+ });
516
+ if (i > 0) {
517
+ let n = _[i - 1] + (i - 1) * c + h[i - 1];
518
+ if (a > n) for (let o of M(e, m, i, f, t)) r.push({
519
+ bandStart: n,
520
+ bandSize: a - n,
521
+ ...o
522
+ });
523
+ }
524
+ }
525
+ e.decorationRuns = u({
526
+ ruleX: e.style.ruleX,
527
+ ruleY: e.style.ruleY,
528
+ vertical: N(n, e.style.ruleInset),
529
+ horizontal: N(r, e.style.ruleInset),
530
+ contentWidth: t,
531
+ contentHeight: y,
532
+ border: i,
533
+ borderStyle: e.style.borderStyle,
534
+ borderColor: e.style.borderColor,
535
+ padding: a
536
+ });
537
+ }
538
+ return ee(e, i, a, t, y), y;
209
539
  }
210
- function _(e, t, n, r, i) {
540
+ function ee(e, t, n, r, i) {
211
541
  for (let a of e.children) V(a.style) && (a.staticSlot = {
212
542
  kind: "flex",
213
543
  direction: e.style.flexDirection,
@@ -217,52 +547,76 @@ function _(e, t, n, r, i) {
217
547
  innerHeight: i
218
548
  });
219
549
  }
220
- function v(e, t, r, i, a, o, s) {
221
- let c = W(e.style.gapY, r), l = D(e).map((a) => {
222
- let o = G(a.style.margin, t), c = Math.max(0, t - (o.left ?? 0) - (o.right ?? 0)), l = w(a, e) === "stretch";
223
- H(a, c, i && Number.isFinite(r) ? r : void 0, 0, 0, l ? "fill" : "shrink", s);
224
- let u = Number.isFinite(r) ? r : void 0, d = a.style.flexBasis, f = d === void 0 || d.kind === "auto" ? a.unclampedHeight : d.kind === "cells" ? d.value : d.kind === "percent" && u !== void 0 ? n(d.value, u) : a.unclampedHeight, p = a.style.minHeight === "auto" ? a.style.overflow === "visible" ? a.localRect.height : 0 : void 0;
550
+ function te(e, t, n, r, i, a, o) {
551
+ let s = At(e.style, "y", n), c = oe(e).map((i) => {
552
+ let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = L(i, e) === "stretch";
553
+ H(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
554
+ 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;
225
555
  return {
226
- node: a,
227
- base: f,
228
- grow: a.style.flexGrow,
229
- shrink: a.style.flexShrink,
230
- min: p ?? q(a.style.minHeight, u) ?? 0,
231
- max: q(a.style.maxHeight, u),
232
- margin: o
556
+ node: i,
557
+ base: d,
558
+ grow: i.style.flexGrow,
559
+ shrink: i.style.flexShrink,
560
+ min: f ?? q(i.style.minHeight, l) ?? 0,
561
+ max: q(i.style.maxHeight, l),
562
+ margin: a
233
563
  };
234
- }), u = c * Math.max(0, l.length - 1), d = l.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), f = Number.isFinite(r), p = l.reduce((e, t) => e + t.base, 0), m = f ? Math.max(0, r - u - d) : p, h = i ? m : Math.max(m, p), g = l.some((e) => e.margin.top === null || e.margin.bottom === null), v = f && !(f && g && p <= h) ? S(l, h) : l.map((e) => Math.max(0, U(e.base, e.min, e.max)));
235
- for (let n = 0; n < l.length; n++) if (v[n] !== l[n].node.localRect.height) {
236
- let r = l[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = w(r.node, e) === "stretch";
237
- H(r.node, i, v[n], 0, 0, a ? "fill" : "shrink", s, { height: v[n] });
238
- }
239
- let y = v.reduce((e, t) => e + t, 0), T = Math.max(0, h - y), E = l.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), O = Array.from({ length: l.length }, () => 0), A = Array.from({ length: l.length }, () => 0), j;
240
- if (E > 0 && T > 0) {
241
- let e = C(Array.from({ length: E }, () => 1), T), t = 0;
242
- for (let n = 0; n < l.length; n++) l[n].margin.top === null && (O[n] = e[t++]), l[n].margin.bottom === null && (A[n] = e[t++]);
243
- j = x("start", v, 0);
244
- } else j = x(k(e.style), v, T);
245
- let M = a.left + o.left, N = a.top + o.top, P = 0;
246
- for (let n = 0; n < l.length; n++) {
247
- let r = l[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
248
- P += O[n] + a, i.localRect = {
564
+ }), 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, U(e.base, e.min, e.max)));
565
+ for (let n = 0; n < c.length; n++) if (v[n] !== c[n].node.localRect.height) {
566
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = L(r.node, e) === "stretch";
567
+ H(r.node, i, v[n], 0, 0, a ? "fill" : "shrink", o, { height: v[n] });
568
+ }
569
+ 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;
570
+ if (x > 0 && b > 0) {
571
+ let e = I(Array.from({ length: x }, () => 1), b), t = 0;
572
+ 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++]);
573
+ w = F("start", v, 0);
574
+ } else w = F(ce(e.style), v, b);
575
+ let T = i.left + a.left, E = i.top + a.top, D = 0;
576
+ for (let n = 0; n < c.length; n++) {
577
+ let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
578
+ D += S[n] + a, i.localRect = {
249
579
  ...i.localRect,
250
- x: M + b(i, e.style.alignItems, t, r.margin),
251
- y: N + j[n] + n * c + P
252
- }, P += A[n] + o;
580
+ x: T + re(i, e.style.alignItems, t, r.margin),
581
+ y: E + w[n] + n * s + D
582
+ }, D += C[n] + o;
583
+ }
584
+ let O = y + l + d, k = f ? Math.max(n, O) : O;
585
+ if (e.style.ruleY && c.length > 1) {
586
+ let n = [], r = c.map((e) => e.node.localRect).slice().sort((e, t) => e.y - t.y);
587
+ for (let e = 1; e < r.length; e++) {
588
+ let i = r[e - 1].y + r[e - 1].height - E, a = r[e].y - E - i;
589
+ a > 0 && n.push({
590
+ bandStart: i,
591
+ bandSize: a,
592
+ start: 0,
593
+ end: t
594
+ });
595
+ }
596
+ e.decorationRuns = u({
597
+ ruleX: null,
598
+ ruleY: e.style.ruleY,
599
+ vertical: [],
600
+ horizontal: N(n, e.style.ruleInset),
601
+ contentWidth: t,
602
+ contentHeight: k,
603
+ border: i,
604
+ borderStyle: e.style.borderStyle,
605
+ borderColor: e.style.borderColor,
606
+ padding: a
607
+ });
253
608
  }
254
- let F = y + u + d, I = f ? Math.max(r, F) : F;
255
- return _(e, a, o, t, I), I;
609
+ return ee(e, i, a, t, k), k;
256
610
  }
257
- function y(e, t, n, r) {
611
+ function ne(e, t, n, r) {
258
612
  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;
259
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + T(i, n, e.localRect.height);
613
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + R(i, n, e.localRect.height);
260
614
  }
261
- function b(e, t, n, r) {
615
+ function re(e, t, n, r) {
262
616
  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;
263
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + T(i, n, e.localRect.width);
617
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + R(i, n, e.localRect.width);
264
618
  }
265
- function x(e, t, n) {
619
+ function F(e, t, n) {
266
620
  let r = t.length;
267
621
  if (r === 0) return [];
268
622
  let i = [], a = 0;
@@ -272,7 +626,7 @@ function x(e, t, n) {
272
626
  return i;
273
627
  }
274
628
  if ((e === "space-around" || e === "space-evenly") && n > 0) {
275
- let o = C(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
629
+ let o = I(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
276
630
  for (let e = 0; e < r; e++) a += o[e], i.push(a), a += t[e];
277
631
  return i;
278
632
  }
@@ -280,7 +634,7 @@ function x(e, t, n) {
280
634
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
281
635
  return i;
282
636
  }
283
- function S(e, t) {
637
+ function ie(e, t) {
284
638
  let n = e.length, r = (t, n) => Math.max(0, U(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);
285
639
  for (let t = 0; t < n; t++) {
286
640
  let n = r(i[t], t);
@@ -290,7 +644,7 @@ function S(e, t) {
290
644
  let c = [];
291
645
  for (let e = 0; e < n; e++) s[e] || c.push(e);
292
646
  if (c.length === 0) break;
293
- let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = C(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
647
+ let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = I(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
294
648
  if (g === 0) {
295
649
  for (let e = 0; e < c.length; e++) o[c[e]] = h[e];
296
650
  break;
@@ -302,7 +656,7 @@ function S(e, t) {
302
656
  }
303
657
  return o;
304
658
  }
305
- function C(e, t) {
659
+ function I(e, t) {
306
660
  let n = e.reduce((e, t) => e + t, 0);
307
661
  if (n === 0 || t <= 0) return e.map(() => 0);
308
662
  let r = e.map((e) => e / n * t), i = r.map(Math.floor), a = t - i.reduce((e, t) => e + t, 0);
@@ -315,33 +669,33 @@ function C(e, t) {
315
669
  }
316
670
  return i;
317
671
  }
318
- function w(e, t) {
672
+ function L(e, t) {
319
673
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
320
674
  }
321
- function T(e, t, n) {
675
+ function R(e, t, n) {
322
676
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
323
677
  }
324
- function E(e, t, n) {
678
+ function ae(e, t, n) {
325
679
  let r = e.style.flexBasis, i = e.style.width;
326
- return r !== void 0 && r.kind !== "auto" ? Y(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? Y(i, t, e, n) : X(e, n);
680
+ return r !== void 0 && r.kind !== "auto" ? J(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? J(i, t, e, n) : Y(e, n);
327
681
  }
328
- function D(e) {
682
+ function oe(e) {
329
683
  let t = e.children.filter((e) => !V(e.style)).sort((e, t) => e.style.order - t.style.order);
330
684
  return e.style.flexReverse && t.reverse(), t;
331
685
  }
332
- function O(e) {
686
+ function se(e) {
333
687
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
334
688
  }
335
- function k(e) {
689
+ function ce(e) {
336
690
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
337
691
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
338
692
  }
339
- function A(e, t, n) {
340
- return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Z(e, n) : 0 : q(e.style.minWidth, t) ?? 0;
693
+ function le(e, t, n) {
694
+ return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? X(e, n) : 0 : q(e.style.minWidth, t) ?? 0;
341
695
  }
342
696
  //#endregion
343
697
  //#region src/types.ts
344
- function j() {
698
+ function ue() {
345
699
  return {
346
700
  display: "block",
347
701
  flexDirection: "row",
@@ -360,8 +714,8 @@ function j() {
360
714
  justifySelf: "auto",
361
715
  gridTemplateColumns: { kind: "none" },
362
716
  gridTemplateRows: { kind: "none" },
363
- gridAutoColumns: [N()],
364
- gridAutoRows: [N()],
717
+ gridAutoColumns: [B()],
718
+ gridAutoRows: [B()],
365
719
  gridAutoFlow: {
366
720
  direction: "row",
367
721
  dense: !1
@@ -377,7 +731,7 @@ function j() {
377
731
  minHeight: "auto",
378
732
  maxWidth: void 0,
379
733
  maxHeight: void 0,
380
- padding: M(),
734
+ padding: z(),
381
735
  margin: {
382
736
  top: 0,
383
737
  right: 0,
@@ -393,7 +747,7 @@ function j() {
393
747
  },
394
748
  gapX: 0,
395
749
  gapY: 0,
396
- border: M(),
750
+ border: z(),
397
751
  borderStyle: {
398
752
  top: "solid",
399
753
  right: "solid",
@@ -408,16 +762,35 @@ function j() {
408
762
  textOverflow: "clip",
409
763
  color: void 0,
410
764
  backgroundColor: void 0,
765
+ backgroundClear: !1,
766
+ fontWeight: "400",
767
+ fontStyle: "normal",
768
+ textDecorationLine: "none",
411
769
  borderColor: {
412
770
  top: void 0,
413
771
  right: void 0,
414
772
  bottom: void 0,
415
773
  left: void 0
416
774
  },
417
- textAlignBlocked: !1
775
+ textAlignBlocked: !1,
776
+ textAlign: "start",
777
+ tableRole: "none",
778
+ tableLayout: "auto",
779
+ borderCollapse: !1,
780
+ borderSpacingX: 0,
781
+ borderSpacingY: 0,
782
+ captionSide: "top",
783
+ verticalAlign: "start",
784
+ zIndex: null,
785
+ latticeBorder: null,
786
+ ruleX: null,
787
+ ruleY: null,
788
+ ruleBreak: "normal",
789
+ ruleInset: 0,
790
+ ruleVisibilityItems: "normal"
418
791
  };
419
792
  }
420
- function M() {
793
+ function z() {
421
794
  return {
422
795
  top: 0,
423
796
  right: 0,
@@ -425,7 +798,7 @@ function M() {
425
798
  left: 0
426
799
  };
427
800
  }
428
- function N() {
801
+ function B() {
429
802
  return {
430
803
  min: { kind: "auto" },
431
804
  max: { kind: "auto" }
@@ -433,15 +806,15 @@ function N() {
433
806
  }
434
807
  //#endregion
435
808
  //#region src/grid.ts
436
- function P(e, t, n, r, i, a) {
437
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : W(o.gapX, t), d = l ? l.gap : W(o.gapY, s), f = oe(e, t, s, u, d, e.subgrid ? {
809
+ function de(e, t, n, r, i, a) {
810
+ let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, d = e.subgrid?.rows, f = c ? c.gap : At(o, "x", t), p = d ? d.gap : At(o, "y", s), m = xe(e, t, s, f, p, e.subgrid ? {
438
811
  col: e.subgrid.colSpan,
439
812
  row: e.subgrid.rowSpan
440
- } : 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(F), T = c ? ee(c) : ye(_, y, te(f, C, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : be(T, t, o.justifyContent), D = [];
441
- for (let e = 0; e < p.length; e++) {
442
- let t = p[e], n = m.items[e], r = Se(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - R(i)), s = C[e];
813
+ } : 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(fe), E = c ? me(c) : Le(y, x, he(m, T, C, a), t, f, o.justifyContent === "stretch"), D = c ? c.positions : Re(E, t, o.justifyContent), O = [];
814
+ for (let e = 0; e < h.length; e++) {
815
+ let t = h[e], n = g.items[e], r = Be(D, E.sizes, n.col.start, n.col.span), i = C[e], o = Math.max(0, r - Te(i)), s = T[e];
443
816
  if (s.cols || s.rows) {
444
- let e = s.cols ? I(E, T, u, n.col.start, n.col.span, L(t, "cols", i, r)) : void 0;
817
+ let e = s.cols ? pe(D, E, f, n.col.start, n.col.span, _e(t, "cols", i, r)) : void 0;
445
818
  t.subgrid = {
446
819
  colSpan: n.col.span,
447
820
  rowSpan: n.row.span,
@@ -449,49 +822,84 @@ function P(e, t, n, r, i, a) {
449
822
  rows: void 0
450
823
  };
451
824
  } else t.subgrid = void 0;
452
- let c = S[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
453
- s.cols ? H(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? H(t, r, void 0, 0, 0, "fill", a, { width: U(o, t.style.minWidth === "auto" ? t.style.overflow === "visible" ? Z(t, a) : 0 : q(t.style.minWidth, r) ?? 0, J(t.style.maxWidth, r, t, a)) }) : H(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
454
- }
455
- let O = l ? ee(l) : ye(v, b, ne(f, C, x), s ?? "max-content", d, o.alignContent === "stretch"), k = xe(O), A = l ? l.positions : be(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
456
- for (let t = 0; t < p.length; t++) {
457
- let n = p[t], r = m.items[t], i = x[t], o = Se(E, T.sizes, r.col.start, r.col.span), s = Se(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - ue(i)), l = w(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
458
- if (C[t].rows) n.subgrid.rows = I(A, O, d, r.row.start, r.row.span, L(n, "rows", i, o)), H(n, o, s, 0, 0, "fill", a, {
459
- width: D[t],
825
+ let c = w[e], l = i.left === null || i.right === null, u = t.style.width !== void 0 && t.style.width.kind !== "auto";
826
+ s.cols ? H(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !u ? H(t, r, void 0, 0, 0, "fill", a, { width: U(o, t.style.minWidth === "auto" ? t.style.overflow === "visible" ? X(t, a) : 0 : q(t.style.minWidth, r) ?? 0, jt(t.style.maxWidth, r, t, a)) }) : H(t, o, void 0, 0, 0, "shrink", a), O.push(t.localRect.width);
827
+ }
828
+ let k = d ? me(d) : Le(b, S, ge(m, T, C), s ?? "max-content", p, o.alignContent === "stretch"), A = ze(k), j = d ? d.positions : Re(k, s ?? A, o.alignContent), M = r.left + i.left, N = r.top + i.top;
829
+ for (let t = 0; t < h.length; t++) {
830
+ let n = h[t], r = g.items[t], i = C[t], o = Be(D, E.sizes, r.col.start, r.col.span), s = Be(j, k.sizes, r.row.start, r.row.span), c = Math.max(0, s - Ee(i)), l = L(n, e), u = i.top === null || i.bottom === null, d = n.style.height !== void 0 && n.style.height.kind !== "auto";
831
+ if (T[t].rows) n.subgrid.rows = pe(j, k, p, r.row.start, r.row.span, _e(n, "rows", i, o)), H(n, o, s, 0, 0, "fill", a, {
832
+ width: O[t],
460
833
  height: c
461
834
  });
462
- else if (l === "stretch" && !u && !f) {
835
+ else if (l === "stretch" && !u && !d) {
463
836
  let e = U(c, n.style.minHeight === "auto" ? n.style.overflow === "visible" ? n.localRect.height : 0 : q(n.style.minHeight, s) ?? 0, q(n.style.maxHeight, s));
464
837
  e !== n.localRect.height && H(n, o, s, 0, 0, "fill", a, {
465
- width: D[t],
838
+ width: O[t],
466
839
  height: e
467
840
  });
468
- } else n.style.height?.kind === "percent" && H(n, o, s, 0, 0, "fill", a, { width: D[t] });
841
+ } else n.style.height?.kind === "percent" && H(n, o, s, 0, 0, "fill", a, { width: O[t] });
469
842
  n.localRect = {
470
843
  ...n.localRect,
471
- x: j + E[r.col.start] + Ce(S[t], i.left, i.right, o, n.localRect.width),
472
- y: M + A[r.row.start] + Ce(l, i.top, i.bottom, s, n.localRect.height)
844
+ x: M + D[r.col.start] + Ve(w[t], i.left, i.right, o, n.localRect.width),
845
+ y: N + j[r.row.start] + Ve(l, i.top, i.bottom, s, n.localRect.height)
473
846
  };
474
847
  }
475
- let N = Number.isFinite(n) ? Math.max(n, k) : k, P = e.children.filter((e) => V(e.style));
476
- if (P.length > 0) {
848
+ let P = Number.isFinite(n) ? Math.max(n, A) : A;
849
+ if (o.ruleX || o.ruleY) {
850
+ 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));
851
+ 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);
852
+ let f = (e, t, n, r, i, a) => t.map((t, o) => ({
853
+ start: t,
854
+ end: t + n[o],
855
+ spanned: r[e]?.[o] ?? !1,
856
+ beforeOccupied: i(o),
857
+ afterOccupied: a(o)
858
+ })), p = (e, t, n) => {
859
+ let r = [];
860
+ for (let i = 1; i < e.length; i++) {
861
+ let a = e[i - 1] + t[i - 1], s = e[i] - a;
862
+ if (!(s <= 0)) for (let e of l(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
863
+ bandStart: a,
864
+ bandSize: s,
865
+ ...e
866
+ });
867
+ }
868
+ return r;
869
+ }, 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));
870
+ e.decorationRuns = u({
871
+ ruleX: o.ruleX,
872
+ ruleY: o.ruleY,
873
+ vertical: m,
874
+ horizontal: h,
875
+ contentWidth: t,
876
+ contentHeight: P,
877
+ border: r,
878
+ borderStyle: o.borderStyle,
879
+ borderColor: o.borderColor,
880
+ padding: i
881
+ });
882
+ }
883
+ let ee = e.children.filter((e) => V(e.style));
884
+ if (ee.length > 0) {
477
885
  let e = V(o) ? {
478
886
  x: r.left,
479
887
  y: r.top,
480
888
  width: i.left + t + i.right,
481
- height: i.top + N + i.bottom
889
+ height: i.top + P + i.bottom
482
890
  } : {
483
- x: j,
484
- y: M,
891
+ x: M,
892
+ y: N,
485
893
  width: t,
486
- height: N
894
+ height: P
487
895
  };
488
- for (let n of P) {
489
- let r = ie(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = ie(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
896
+ for (let n of ee) {
897
+ let r = ye(n.style.gridColumnStart, n.style.gridColumnEnd, _, g.colOrigin, D, E.sizes, -i.left, t + i.right), a = ye(n.style.gridRowStart, n.style.gridRowEnd, v, g.rowOrigin, j, k.sizes, -i.top, P + i.bottom);
490
898
  n.staticSlot = {
491
899
  kind: "grid",
492
900
  area: {
493
- x: j + r.start,
494
- y: M + a.start,
901
+ x: M + r.start,
902
+ y: N + a.start,
495
903
  width: Math.max(0, r.end - r.start),
496
904
  height: Math.max(0, a.end - a.start)
497
905
  },
@@ -499,16 +907,16 @@ function P(e, t, n, r, i, a) {
499
907
  };
500
908
  }
501
909
  }
502
- return N;
910
+ return P;
503
911
  }
504
- function F(e) {
912
+ function fe(e) {
505
913
  let t = e.style.display === "grid";
506
914
  return {
507
915
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
508
916
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
509
917
  };
510
918
  }
511
- function I(e, t, n, r, i, a) {
919
+ function pe(e, t, n, r, i, a) {
512
920
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
513
921
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
514
922
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -517,20 +925,20 @@ function I(e, t, n, r, i, a) {
517
925
  gap: n
518
926
  };
519
927
  }
520
- function ee(e) {
928
+ function me(e) {
521
929
  return {
522
930
  sizes: e.sizes,
523
931
  gapBefore: e.gapBefore,
524
932
  limits: e.sizes
525
933
  };
526
934
  }
527
- function te(e, t, n, r) {
935
+ function he(e, t, n, r) {
528
936
  let i = [];
529
937
  return e.children.forEach((a, o) => {
530
938
  let s = e.placed.items[o], c = n[o];
531
939
  if (t[o].cols) {
532
- let e = L(a, "cols", c, 0);
533
- for (let t of re(a, "cols", s, e, r)) i.push({
940
+ let e = _e(a, "cols", c, 0);
941
+ for (let t of ve(a, "cols", s, e, r)) i.push({
534
942
  ...t,
535
943
  start: t.start + s.col.start
536
944
  });
@@ -539,24 +947,24 @@ function te(e, t, n, r) {
539
947
  i.push({
540
948
  start: s.col.start,
541
949
  span: s.col.span,
542
- min: z(a, "min", r) + R(c),
543
- max: z(a, "max", r) + R(c)
950
+ min: De(a, "min", r) + Te(c),
951
+ max: De(a, "max", r) + Te(c)
544
952
  });
545
953
  }), i;
546
954
  }
547
- function ne(e, t, n) {
955
+ function ge(e, t, n) {
548
956
  let r = [];
549
957
  return e.children.forEach((i, a) => {
550
958
  let o = e.placed.items[a], s = n[a];
551
959
  if (t[a].rows) {
552
- let e = L(i, "rows", s, 0);
553
- for (let t of re(i, "rows", o, e)) r.push({
960
+ let e = _e(i, "rows", s, 0);
961
+ for (let t of ve(i, "rows", o, e)) r.push({
554
962
  ...t,
555
963
  start: t.start + o.row.start
556
964
  });
557
965
  return;
558
966
  }
559
- let c = i.localRect.height + ue(s);
967
+ let c = i.localRect.height + Ee(s);
560
968
  r.push({
561
969
  start: o.row.start,
562
970
  span: o.row.span,
@@ -565,7 +973,7 @@ function ne(e, t, n) {
565
973
  });
566
974
  }), r;
567
975
  }
568
- function L(e, t, n, r) {
976
+ function _e(e, t, n, r) {
569
977
  let { border: i, padding: a } = e.style;
570
978
  return t === "cols" ? {
571
979
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -575,15 +983,15 @@ function L(e, t, n, r) {
575
983
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
576
984
  };
577
985
  }
578
- function re(e, t, n, r, i) {
579
- let a = t === "cols" ? n.col.span : n.row.span, o = oe(e, void 0, void 0, 0, 0, {
986
+ function ve(e, t, n, r, i) {
987
+ let a = t === "cols" ? n.col.span : n.row.span, o = xe(e, void 0, void 0, 0, 0, {
580
988
  col: n.col.span,
581
989
  row: n.row.span
582
990
  }), s = [];
583
991
  if (o.children.forEach((e, n) => {
584
992
  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);
585
- if (F(e)[t]) {
586
- let n = L(e, t, p, 0), a = re(e, t, c, {
993
+ if (fe(e)[t]) {
994
+ let n = _e(e, t, p, 0), a = ve(e, t, c, {
587
995
  start: n.start + (u ? r.start : 0),
588
996
  end: n.end + (d ? r.end : 0)
589
997
  }, i);
@@ -596,11 +1004,11 @@ function re(e, t, n, r, i) {
596
1004
  if (t === "cols") s.push({
597
1005
  start: l.start,
598
1006
  span: l.span,
599
- min: z(e, "min", i) + R(p) + f,
600
- max: z(e, "max", i) + R(p) + f
1007
+ min: De(e, "min", i) + Te(p) + f,
1008
+ max: De(e, "max", i) + Te(p) + f
601
1009
  });
602
1010
  else {
603
- let t = e.localRect.height + ue(p) + f;
1011
+ let t = e.localRect.height + Ee(p) + f;
604
1012
  s.push({
605
1013
  start: l.start,
606
1014
  span: l.span,
@@ -619,9 +1027,9 @@ function re(e, t, n, r, i) {
619
1027
  }
620
1028
  return s;
621
1029
  }
622
- function ie(e, t, n, r, i, a, o, s) {
623
- let c = he(e, "start", n), l = he(t, "end", n);
624
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = ge(c, t, 1, n) : l !== null && e.kind === "span" && (c = ge(l, e, -1, n));
1030
+ function ye(e, t, n, r, i, a, o, s) {
1031
+ let c = Ne(e, "start", n), l = Ne(t, "end", n);
1032
+ c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = Pe(c, t, 1, n) : l !== null && e.kind === "span" && (c = Pe(l, e, -1, n));
625
1033
  let u = i.length, d = (e) => {
626
1034
  if (e === null) return;
627
1035
  let t = e - r;
@@ -632,22 +1040,22 @@ function ie(e, t, n, r, i, a, o, s) {
632
1040
  end: h === void 0 ? s : p(h)
633
1041
  };
634
1042
  }
635
- function ae(e, t) {
1043
+ function be(e, t) {
636
1044
  let n = t.gridIntrinsic.get(e);
637
1045
  if (n !== void 0) return n;
638
- let r = e.style, i = typeof r.gapX == "number" ? r.gapX : 0, a = oe(e, void 0, void 0, i, 0, e.subgrid ? {
1046
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = xe(e, void 0, void 0, i, 0, e.subgrid ? {
639
1047
  col: e.subgrid.colSpan,
640
1048
  row: e.subgrid.rowSpan
641
- } : void 0), o = a.children.map(F), s = a.children.map((e) => G(e.style.margin, 0)), c = ye(a.colTracks, a.colCollapsed, te(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1049
+ } : void 0), o = a.children.map(fe), s = a.children.map((e) => G(e.style.margin, 0)), c = Le(a.colTracks, a.colCollapsed, he(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
642
1050
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
643
1051
  max: c.limits.reduce((e, t) => e + t, 0) + l
644
1052
  };
645
1053
  return t.gridIntrinsic.set(e, u), u;
646
1054
  }
647
- function oe(e, t, n, r, i, a) {
648
- let o = e.style, s = le(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? se(a.col) : de(o.gridTemplateColumns, t, r), d = l ? se(a.row) : de(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1055
+ function xe(e, t, n, r, i, a) {
1056
+ let o = e.style, s = we(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? Se(a.col) : Oe(o.gridTemplateColumns, t, r), d = l ? Se(a.row) : Oe(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
649
1057
  if (f) {
650
- c || fe(p, u.lineNames, f.columns, o.gridAutoColumns), l || fe(m, d.lineNames, f.rows, o.gridAutoRows);
1058
+ c || Ae(p, u.lineNames, f.columns, o.gridAutoColumns), l || Ae(m, d.lineNames, f.rows, o.gridAutoRows);
651
1059
  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`);
652
1060
  }
653
1061
  let h = {
@@ -656,28 +1064,28 @@ function oe(e, t, n, r, i, a) {
656
1064
  }, g = {
657
1065
  explicitCount: m.length,
658
1066
  names: d.lineNames
659
- }, _ = ve(s.map((e) => ({
660
- col: _e(e.style.gridColumnStart, e.style.gridColumnEnd, h),
661
- row: _e(e.style.gridRowStart, e.style.gridRowEnd, g)
1067
+ }, _ = Ie(s.map((e) => ({
1068
+ col: Fe(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1069
+ row: Fe(e.style.gridRowStart, e.style.gridRowEnd, g)
662
1070
  })), p.length, m.length, o.gridAutoFlow);
663
- return c && ce(_, "col", p.length), l && ce(_, "row", m.length), {
1071
+ return c && Ce(_, "col", p.length), l && Ce(_, "row", m.length), {
664
1072
  children: s,
665
1073
  placed: _,
666
1074
  colLines: h,
667
1075
  rowLines: g,
668
- colTracks: pe(p, _.colOrigin, _.colCount, o.gridAutoColumns),
669
- rowTracks: pe(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
670
- colCollapsed: me(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
671
- rowCollapsed: me(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1076
+ colTracks: je(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1077
+ rowTracks: je(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1078
+ colCollapsed: Me(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1079
+ rowCollapsed: Me(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
672
1080
  };
673
1081
  }
674
- function se(e) {
1082
+ function Se(e) {
675
1083
  return {
676
- tracks: Array.from({ length: e }, () => N()),
1084
+ tracks: Array.from({ length: e }, () => B()),
677
1085
  lineNames: Array.from({ length: e + 1 }, () => [])
678
1086
  };
679
1087
  }
680
- function ce(e, t, n) {
1088
+ function Ce(e, t, n) {
681
1089
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
682
1090
  for (let i of e.items) {
683
1091
  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);
@@ -685,22 +1093,22 @@ function ce(e, t, n) {
685
1093
  }
686
1094
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
687
1095
  }
688
- function le(e) {
1096
+ function we(e) {
689
1097
  return e.children.filter((e) => !V(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
690
1098
  }
691
- function R(e) {
1099
+ function Te(e) {
692
1100
  return (e.left ?? 0) + (e.right ?? 0);
693
1101
  }
694
- function ue(e) {
1102
+ function Ee(e) {
695
1103
  return (e.top ?? 0) + (e.bottom ?? 0);
696
1104
  }
697
- function z(e, t, n) {
1105
+ function De(e, t, n) {
698
1106
  let r = e.style, i;
699
- r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = Y(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? Z(e, n) : X(e, n));
1107
+ r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = J(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? X(e, n) : Y(e, n));
700
1108
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
701
1109
  return Math.max(0, U(i, a, o));
702
1110
  }
703
- function de(e, t, n) {
1111
+ function Oe(e, t, n) {
704
1112
  if (e.kind !== "tracks") return {
705
1113
  tracks: [],
706
1114
  lineNames: [[]]
@@ -713,7 +1121,7 @@ function de(e, t, n) {
713
1121
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
714
1122
  if (t !== void 0) {
715
1123
  let e = a.reduce((e, n) => {
716
- let r = B(n.min, t) ?? B(n.max, t) ?? 1;
1124
+ let r = ke(n.min, t) ?? ke(n.max, t) ?? 1;
717
1125
  return e + Math.max(1, r);
718
1126
  }, 0);
719
1127
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -741,23 +1149,23 @@ function de(e, t, n) {
741
1149
  lineNames: d
742
1150
  };
743
1151
  }
744
- function B(e, t) {
1152
+ function ke(e, t) {
745
1153
  if (e.kind === "cells") return e.value;
746
- if (e.kind === "percent" && t !== void 0) return n(e.value, t);
1154
+ if (e.kind === "percent" && t !== void 0) return m(e.value, t);
747
1155
  if (e.kind === "math") {
748
1156
  let n = [];
749
1157
  for (let r of e.args) {
750
- let e = B(r, t);
1158
+ let e = ke(r, t);
751
1159
  if (e === void 0) return;
752
1160
  n.push(e);
753
1161
  }
754
1162
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
755
1163
  }
756
1164
  }
757
- function fe(e, t, n, r) {
1165
+ function Ae(e, t, n, r) {
758
1166
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
759
1167
  }
760
- function pe(e, t, n, r) {
1168
+ function je(e, t, n, r) {
761
1169
  let i = [];
762
1170
  for (let a = 0; a < n; a++) {
763
1171
  let n = a + t;
@@ -769,7 +1177,7 @@ function pe(e, t, n, r) {
769
1177
  }
770
1178
  return i;
771
1179
  }
772
- function me(e, t, n, r) {
1180
+ function Me(e, t, n, r) {
773
1181
  let i = Array.from({ length: n }, () => !1);
774
1182
  if (!e.autoFit) return i;
775
1183
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -778,7 +1186,7 @@ function me(e, t, n, r) {
778
1186
  }
779
1187
  return i;
780
1188
  }
781
- function he(e, t, n) {
1189
+ function Ne(e, t, n) {
782
1190
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
783
1191
  if (e.kind !== "name") return null;
784
1192
  if (e.nth === void 0) {
@@ -793,14 +1201,14 @@ function he(e, t, n) {
793
1201
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
794
1202
  return -(-r - a);
795
1203
  }
796
- function ge(e, t, n, r) {
1204
+ function Pe(e, t, n, r) {
797
1205
  if (t.name === void 0) return e + n * t.value;
798
1206
  let i = t.value, a = e;
799
1207
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
800
1208
  return a;
801
1209
  }
802
- function _e(e, t, n) {
803
- let r = he(e, "start", n), i = he(t, "end", n);
1210
+ function Fe(e, t, n) {
1211
+ let r = Ne(e, "start", n), i = Ne(t, "end", n);
804
1212
  if (r !== null && i !== null) return r === i ? {
805
1213
  start: r,
806
1214
  span: 1
@@ -810,10 +1218,10 @@ function _e(e, t, n) {
810
1218
  };
811
1219
  if (r !== null) return {
812
1220
  start: r,
813
- span: (t.kind === "span" ? ge(r, t, 1, n) : r + 1) - r
1221
+ span: (t.kind === "span" ? Pe(r, t, 1, n) : r + 1) - r
814
1222
  };
815
1223
  if (i !== null) {
816
- let t = e.kind === "span" ? ge(i, e, -1, n) : i - 1;
1224
+ let t = e.kind === "span" ? Pe(i, e, -1, n) : i - 1;
817
1225
  return {
818
1226
  start: t,
819
1227
  span: i - t
@@ -824,7 +1232,7 @@ function _e(e, t, n) {
824
1232
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
825
1233
  };
826
1234
  }
827
- function ve(e, t, n, r) {
1235
+ function Ie(e, t, n, r) {
828
1236
  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);
829
1237
  for (let t = 0; t < e.length; t++) {
830
1238
  let e = o[t];
@@ -921,9 +1329,9 @@ function ve(e, t, n, r) {
921
1329
  rowCount: S
922
1330
  };
923
1331
  }
924
- function ye(t, n, r, i, a, o) {
925
- let s = typeof i == "number" ? i : void 0, c = t.map((e, t) => {
926
- if (n[t]) return {
1332
+ function Le(e, t, n, r, i, a) {
1333
+ let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1334
+ if (t[n]) return {
927
1335
  base: 0,
928
1336
  limit: 0,
929
1337
  baseIntrinsic: !1,
@@ -931,21 +1339,21 @@ function ye(t, n, r, i, a, o) {
931
1339
  frFactor: 0,
932
1340
  collapsed: !0
933
1341
  };
934
- let r = B(e.min, s), i = r ?? 0, a = r === void 0, o = e.max;
935
- if (o.kind === "fr") return {
1342
+ let r = ke(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1343
+ if (s.kind === "fr") return {
936
1344
  base: i,
937
1345
  limit: null,
938
1346
  baseIntrinsic: a,
939
1347
  limitKind: "fr",
940
- frFactor: o.value,
1348
+ frFactor: s.value,
941
1349
  collapsed: !1
942
1350
  };
943
- let c = B(o, s);
1351
+ let c = ke(s, o);
944
1352
  return c === void 0 ? {
945
1353
  base: i,
946
1354
  limit: null,
947
1355
  baseIntrinsic: a,
948
- limitKind: o.kind === "min-content" ? "intrinsic-min" : "intrinsic-max",
1356
+ limitKind: s.kind === "min-content" ? "intrinsic-min" : "intrinsic-max",
949
1357
  frFactor: 0,
950
1358
  collapsed: !1
951
1359
  } : {
@@ -956,25 +1364,25 @@ function ye(t, n, r, i, a, o) {
956
1364
  frFactor: 0,
957
1365
  collapsed: !1
958
1366
  };
959
- }), l = c.map((e, t) => t === 0 || e.collapsed ? 0 : c.slice(0, t).some((e) => !e.collapsed) ? a : 0), u = (e, t) => {
1367
+ }), c = s.map((e, t) => t === 0 || e.collapsed ? 0 : s.slice(0, t).some((e) => !e.collapsed) ? i : 0), l = (e, t) => {
960
1368
  let n = 0;
961
- for (let r = e + 1; r < e + t; r++) n += l[r];
1369
+ for (let r = e + 1; r < e + t; r++) n += c[r];
962
1370
  return n;
963
- }, d = (e) => e.collapsed ? 0 : e.limitKind === "fixed" ? e.limit : Math.max(e.base, e.limit ?? e.base), f = [...r].sort((e, t) => e.span - t.span);
964
- for (let e of f) {
1371
+ }, u = (e) => e.collapsed ? 0 : e.limitKind === "fixed" ? e.limit : Math.max(e.base, e.limit ?? e.base), d = [...n].sort((e, t) => e.span - t.span);
1372
+ for (let e of d) {
965
1373
  let t = [], n = !1;
966
1374
  for (let r = e.start; r < e.start + e.span; r++) {
967
- let e = c[r];
1375
+ let e = s[r];
968
1376
  e !== void 0 && (e.limitKind === "fr" && (n = !0), t.push(e));
969
1377
  }
970
1378
  if (t.length === 0) continue;
971
- let r = u(e.start, e.span);
1379
+ let r = l(e.start, e.span);
972
1380
  if (n) {
973
1381
  let n = t.filter((e) => e.limitKind === "fr" && e.baseIntrinsic && !e.collapsed);
974
1382
  if (n.length === 0) continue;
975
1383
  let i = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - i;
976
1384
  if (a > 0) {
977
- let e = n.reduce((e, t) => e + t.frFactor, 0), t = C(n.map((t) => e > 0 ? t.frFactor : 1), a);
1385
+ let e = n.reduce((e, t) => e + t.frFactor, 0), t = I(n.map((t) => e > 0 ? t.frFactor : 1), a);
978
1386
  n.forEach((e, n) => {
979
1387
  e.base += t[n];
980
1388
  });
@@ -985,7 +1393,7 @@ function ye(t, n, r, i, a, o) {
985
1393
  if (i.length > 0) {
986
1394
  let n = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - n;
987
1395
  if (a > 0) {
988
- let e = C(i.map(() => 1), a);
1396
+ let e = I(i.map(() => 1), a);
989
1397
  i.forEach((t, n) => {
990
1398
  t.base += e[n];
991
1399
  });
@@ -994,51 +1402,51 @@ function ye(t, n, r, i, a, o) {
994
1402
  for (let [n, i] of [["intrinsic-min", e.min], ["intrinsic-max", e.max]]) {
995
1403
  let e = t.filter((e) => e.limitKind === n && !e.collapsed);
996
1404
  if (e.length === 0) continue;
997
- let a = i - (t.reduce((e, t) => e + d(t), 0) + r);
1405
+ let a = i - (t.reduce((e, t) => e + u(t), 0) + r);
998
1406
  if (a > 0) {
999
- let t = C(e.map(() => 1), a);
1407
+ let t = I(e.map(() => 1), a);
1000
1408
  e.forEach((e, n) => {
1001
- e.limit = d(e) + t[n];
1409
+ e.limit = u(e) + t[n];
1002
1410
  });
1003
1411
  }
1004
1412
  }
1005
1413
  }
1006
- for (let e of c) e.collapsed || (e.limitKind === "fixed" ? e.base = Math.min(e.base, e.limit) : e.limitKind !== "fr" && (e.limit = Math.max(e.base, e.limit ?? e.base)));
1007
- if (s === void 0) {
1008
- let t = c.filter((e) => e.limitKind === "fr" && !e.collapsed);
1009
- if (t.length > 0) {
1010
- let n = 0;
1011
- for (let e of t) e.frFactor > 0 && (n = Math.max(n, e.base / e.frFactor));
1012
- for (let e of r) {
1013
- let t = 0, r = u(e.start, e.span);
1014
- for (let n = e.start; n < e.start + e.span; n++) {
1015
- let e = c[n];
1016
- e === void 0 || e.collapsed || (e.limitKind === "fr" ? t += e.frFactor : r += d(e));
1414
+ for (let e of s) e.collapsed || (e.limitKind === "fixed" ? e.base = Math.min(e.base, e.limit) : e.limitKind !== "fr" && (e.limit = Math.max(e.base, e.limit ?? e.base)));
1415
+ if (o === void 0) {
1416
+ let e = s.filter((e) => e.limitKind === "fr" && !e.collapsed);
1417
+ if (e.length > 0) {
1418
+ let t = 0;
1419
+ for (let n of e) n.frFactor > 0 && (t = Math.max(t, n.base / n.frFactor));
1420
+ for (let e of n) {
1421
+ let n = 0, r = l(e.start, e.span);
1422
+ for (let t = e.start; t < e.start + e.span; t++) {
1423
+ let e = s[t];
1424
+ e === void 0 || e.collapsed || (e.limitKind === "fr" ? n += e.frFactor : r += u(e));
1017
1425
  }
1018
- t <= 0 || (n = Math.max(n, (e.max - r) / Math.max(t, 1)));
1426
+ n <= 0 || (t = Math.max(t, (e.max - r) / Math.max(n, 1)));
1019
1427
  }
1020
- for (let r of t) {
1021
- let t = Math.max(r.base, e(r.frFactor * n));
1022
- r.limit = t, i === "max-content" && (r.base = t);
1428
+ for (let n of e) {
1429
+ let e = Math.max(n.base, f(n.frFactor * t));
1430
+ n.limit = e, r === "max-content" && (n.base = e);
1023
1431
  }
1024
1432
  }
1025
- if (i === "max-content") for (let e of c) !e.collapsed && e.limitKind !== "fr" && (e.base = d(e));
1433
+ if (r === "max-content") for (let e of s) !e.collapsed && e.limitKind !== "fr" && (e.base = u(e));
1026
1434
  } else {
1027
- let e = l.reduce((e, t) => e + t, 0), t = s - e - c.reduce((e, t) => e + t.base, 0);
1435
+ let e = c.reduce((e, t) => e + t, 0), t = o - e - s.reduce((e, t) => e + t.base, 0);
1028
1436
  for (; !(t <= 0);) {
1029
- let e = c.filter((e) => !e.collapsed && e.limitKind !== "fr" && e.base < d(e));
1437
+ let e = s.filter((e) => !e.collapsed && e.limitKind !== "fr" && e.base < u(e));
1030
1438
  if (e.length === 0) break;
1031
- let n = C(e.map(() => 1), t), r = 0;
1439
+ let n = I(e.map(() => 1), t), r = 0;
1032
1440
  if (e.forEach((e, t) => {
1033
- let i = Math.min(n[t], d(e) - e.base);
1441
+ let i = Math.min(n[t], u(e) - e.base);
1034
1442
  e.base += i, r += i;
1035
1443
  }), t -= r, r === 0) break;
1036
1444
  }
1037
- let n = c.filter((e) => e.limitKind === "fr");
1445
+ let n = s.filter((e) => e.limitKind === "fr");
1038
1446
  if (n.length > 0) {
1039
- let t = Math.max(0, s - e - c.reduce((e, t) => e + (t.limitKind === "fr" ? 0 : t.base), 0)), r = n, i = t, a = n.reduce((e, t) => e + t.frFactor, 0);
1447
+ let t = Math.max(0, o - e - s.reduce((e, t) => e + (t.limitKind === "fr" ? 0 : t.base), 0)), r = n, i = t, a = n.reduce((e, t) => e + t.frFactor, 0);
1040
1448
  for (a < 1 && (i = Math.floor(i * a));;) {
1041
- let e = C(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1449
+ let e = I(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1042
1450
  if (t.length === 0) {
1043
1451
  r.forEach((t, n) => {
1044
1452
  t.base = Math.max(t.base, e[n]);
@@ -1049,10 +1457,10 @@ function ye(t, n, r, i, a, o) {
1049
1457
  if (i = Math.max(0, i), r = r.filter((e) => !t.includes(e)), r.length === 0) break;
1050
1458
  }
1051
1459
  }
1052
- if (o) {
1053
- let t = s - e - c.reduce((e, t) => e + t.base, 0), n = c.filter((e) => !e.collapsed && e.limitKind === "intrinsic-max");
1460
+ if (a) {
1461
+ let t = o - e - s.reduce((e, t) => e + t.base, 0), n = s.filter((e) => !e.collapsed && e.limitKind === "intrinsic-max");
1054
1462
  if (t > 0 && n.length > 0) {
1055
- let e = C(n.map(() => 1), t);
1463
+ let e = I(n.map(() => 1), t);
1056
1464
  n.forEach((t, n) => {
1057
1465
  t.base += e[n];
1058
1466
  });
@@ -1060,53 +1468,574 @@ function ye(t, n, r, i, a, o) {
1060
1468
  }
1061
1469
  }
1062
1470
  return {
1063
- sizes: c.map((e) => e.base),
1064
- gapBefore: l,
1065
- limits: c.map((e) => d(e))
1471
+ sizes: s.map((e) => e.base),
1472
+ gapBefore: c,
1473
+ limits: s.map((e) => u(e))
1066
1474
  };
1067
1475
  }
1068
- function be(e, t, n) {
1069
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - xe(e)), o = x(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1476
+ function Re(e, t, n) {
1477
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - ze(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1070
1478
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1071
1479
  return s;
1072
1480
  }
1073
- function xe(e) {
1481
+ function ze(e) {
1074
1482
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1075
1483
  }
1076
- function Se(e, t, n, r) {
1484
+ function Be(e, t, n, r) {
1077
1485
  let i = n + r - 1;
1078
1486
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1079
1487
  }
1080
- function Ce(e, t, n, r, i) {
1488
+ function Ve(e, t, n, r, i) {
1081
1489
  let a = t ?? 0, o = n ?? 0, s = r - i;
1082
- return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + T(e, r, i + a + o);
1490
+ return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + R(e, r, i + a + o);
1491
+ }
1492
+ //#endregion
1493
+ //#region src/warn.ts
1494
+ var He = /* @__PURE__ */ new WeakMap();
1495
+ function Ue(e, t) {
1496
+ let n = He.get(e);
1497
+ n || He.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
1498
+ }
1499
+ //#endregion
1500
+ //#region src/table.ts
1501
+ function We(e, t) {
1502
+ e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && Ue(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).");
1503
+ }
1504
+ function Ge(e, t) {
1505
+ let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
1506
+ return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
1507
+ }
1508
+ function Ke(e, t, n) {
1509
+ let r = (t, r) => {
1510
+ let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? J(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
1511
+ for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
1512
+ };
1513
+ if (t.style.tableRole === "column") {
1514
+ r(t, qe(t.source));
1515
+ return;
1516
+ }
1517
+ let i = t.children.filter((e) => e.style.tableRole === "column");
1518
+ if (i.length === 0) r(t, qe(t.source));
1519
+ else for (let e of i) r(e, qe(e.source));
1520
+ for (let n of t.children) n.style.tableRole !== "column" && We(e, n);
1521
+ }
1522
+ function qe(e) {
1523
+ let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
1524
+ return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
1525
+ }
1526
+ function Je(e, t) {
1527
+ let n = {
1528
+ caption: null,
1529
+ rows: [],
1530
+ rowGroups: [],
1531
+ groupEnds: [],
1532
+ cells: [],
1533
+ columnCount: 0,
1534
+ colFixed: [],
1535
+ colPercent: [],
1536
+ hidden: []
1537
+ }, r = [], i = [], a = [];
1538
+ for (let o of e.children) {
1539
+ if (V(o.style)) continue;
1540
+ let e = o.style.tableRole;
1541
+ if (e === "row") i.push({
1542
+ row: o,
1543
+ group: null
1544
+ });
1545
+ else if (e === "header-group" || e === "row-group" || e === "footer-group") {
1546
+ let t = e === "header-group" ? r : e === "footer-group" ? a : i;
1547
+ for (let e of o.children) V(e.style) || (e.style.tableRole === "row" ? t.push({
1548
+ row: e,
1549
+ group: o
1550
+ }) : We(n, e));
1551
+ } else e === "caption" ? n.caption === null ? n.caption = o : We(n, o) : e === "column" || e === "column-group" ? (Ke(n, o, t), n.hidden.push(o)) : We(n, o);
1552
+ }
1553
+ let o = [
1554
+ ...r,
1555
+ ...i,
1556
+ ...a
1557
+ ], s = 0;
1558
+ for (let e = 0; e < o.length; e++) {
1559
+ n.rows.push(o[e].row), n.rowGroups.push(o[e].group);
1560
+ let t = o[e + 1]?.group;
1561
+ if (!(e + 1 < o.length && (o[e].group === t || o[e].group === null && t === null))) {
1562
+ for (let t = s; t <= e; t++) n.groupEnds.push(e + 1);
1563
+ s = e + 1;
1564
+ }
1565
+ }
1566
+ return Ye(n), n;
1567
+ }
1568
+ function Ye(e) {
1569
+ let t = [];
1570
+ for (let n = 0; n < e.rows.length; n++) {
1571
+ let r = e.rows[n], i = 0;
1572
+ for (let a of r.children) {
1573
+ if (V(a.style)) continue;
1574
+ if (a.style.tableRole !== "cell") {
1575
+ We(e, a);
1576
+ continue;
1577
+ }
1578
+ for (; (t[i] ?? 0) > n;) i++;
1579
+ let o = Ge(a.source, "colspan"), s = Ge(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
1580
+ for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
1581
+ e.cells.push({
1582
+ node: a,
1583
+ rowNode: r,
1584
+ row: n,
1585
+ col: i,
1586
+ rowSpan: l,
1587
+ colSpan: o
1588
+ }), i += o;
1589
+ }
1590
+ }
1591
+ e.columnCount = Math.max(t.length, e.colFixed.length);
1592
+ }
1593
+ function Xe(e, t, n) {
1594
+ let r = e.style, i = X(e, n), a;
1595
+ if (t === "min") a = i;
1596
+ else {
1597
+ let t = r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" ? J(r.width, 0, e, n) : void 0;
1598
+ a = t === void 0 ? Y(e, n) : Math.max(i, t);
1599
+ }
1600
+ let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1601
+ return Math.max(0, U(a, o, s));
1602
+ }
1603
+ function Ze(e) {
1604
+ let t = e.style.width;
1605
+ return t && t.kind === "percent" ? t.value : void 0;
1606
+ }
1607
+ function Qe(e, t, n) {
1608
+ let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
1609
+ for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
1610
+ let s = [];
1611
+ for (let t of e.cells) {
1612
+ if (t.colSpan > 1) {
1613
+ s.push(t);
1614
+ continue;
1615
+ }
1616
+ i[t.col] = Math.max(i[t.col], Xe(t.node, "min", n)), a[t.col] = Math.max(a[t.col], Xe(t.node, "max", n));
1617
+ let e = Ze(t.node);
1618
+ e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
1619
+ }
1620
+ s.sort((e, t) => e.colSpan - t.colSpan);
1621
+ for (let e of s) {
1622
+ let r = e.col, o = e.col + e.colSpan, s = at(t, r, o), c = a.slice(r, o);
1623
+ for (let t of ["min", "max"]) {
1624
+ let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = Xe(e.node, t, n) - u;
1625
+ if (d <= 0) continue;
1626
+ let f = I(c.some((e) => e > 0) ? c : c.map(() => 1), d);
1627
+ for (let e = r; e < o; e++) l[e] += f[e - r];
1628
+ }
1629
+ }
1630
+ for (let e = 0; e < r; e++) a[e] = Math.max(a[e], i[e]);
1631
+ return {
1632
+ min: i,
1633
+ max: a,
1634
+ percent: o
1635
+ };
1636
+ }
1637
+ function $e(e, t) {
1638
+ let n = e.min.length, r = e.min.slice(), i = [], a = [];
1639
+ for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
1640
+ if (i.length > 0) {
1641
+ let n = i.reduce((t, n) => t + e.percent[n], 0), o = Math.max(100, n);
1642
+ for (let n of i) {
1643
+ let i = Math.round(t * e.percent[n] / o);
1644
+ r[n] = Math.max(e.min[n], i);
1645
+ }
1646
+ let s = a.reduce((t, n) => t + e.min[n], 0), c = i.reduce((e, t) => e + r[t], 0) - (t - s);
1647
+ if (c > 0) {
1648
+ let t = i.map((t) => r[t] - e.min[t]), n = I(t, Math.min(c, t.reduce((e, t) => e + t, 0)));
1649
+ i.forEach((e, t) => r[e] -= n[t]);
1650
+ }
1651
+ }
1652
+ let o = t - r.reduce((e, t) => e + t, 0);
1653
+ if (o > 0 && a.length > 0) {
1654
+ let t = a.map((t) => e.max[t] - e.min[t]), n = t.reduce((e, t) => e + t, 0), i = I(t, Math.min(o, n));
1655
+ a.forEach((e, t) => r[e] += i[t]), o -= Math.min(o, n);
1656
+ }
1657
+ if (o > 0) {
1658
+ let t = a.length > 0 ? a : i;
1659
+ if (t.length > 0) {
1660
+ let n = t.map((t) => e.max[t]), i = I(n.some((e) => e > 0) ? n : n.map(() => 1), o);
1661
+ t.forEach((e, t) => r[e] += i[t]);
1662
+ }
1663
+ }
1664
+ return r;
1665
+ }
1666
+ function et(e, t, n) {
1667
+ let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
1668
+ 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];
1669
+ for (let r of e.cells) {
1670
+ if (r.row !== 0) continue;
1671
+ let e = r.node.style, a;
1672
+ if (e.width && e.width.kind === "percent" ? a = Math.max(0, Math.round(t * e.width.value / 100)) : e.width && e.width.kind !== "auto" && (a = J(e.width, 0, r.node, n)), a === void 0) continue;
1673
+ let o = I(Array.from({ length: r.colSpan }, () => 1), a);
1674
+ for (let e = 0; e < r.colSpan; e++) {
1675
+ let t = r.col + e;
1676
+ i[t] === void 0 && (i[t] = o[e]);
1677
+ }
1678
+ }
1679
+ let a = i.reduce((e, t) => e + (t ?? 0), 0), o = i.filter((e) => e === void 0).length;
1680
+ if (o > 0) {
1681
+ let e = I(Array.from({ length: o }, () => 1), Math.max(0, t - a)), n = 0;
1682
+ for (let t = 0; t < r; t++) i[t] === void 0 && (i[t] = e[n++]);
1683
+ }
1684
+ return i.map((e) => e ?? 0);
1685
+ }
1686
+ var tt = {
1687
+ double: 3,
1688
+ solid: 2,
1689
+ dashed: 1,
1690
+ dotted: 0
1691
+ };
1692
+ function nt(e) {
1693
+ for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
1694
+ let t = null;
1695
+ for (let { border: n, side: r } of e) {
1696
+ if (!n) continue;
1697
+ let e = n.width[r];
1698
+ if (e <= 0) continue;
1699
+ let i = n.style[r];
1700
+ (t === null || e > t.width || e === t.width && tt[i] > tt[t.style]) && (t = {
1701
+ width: e,
1702
+ style: i,
1703
+ color: n.color[r]
1704
+ });
1705
+ }
1706
+ return t;
1707
+ }
1708
+ function rt(e, t) {
1709
+ let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
1710
+ collapsed: i,
1711
+ vLines: Array.from({ length: n + 1 }, () => 0),
1712
+ hLines: Array.from({ length: r + 1 }, () => 0),
1713
+ spacingX: i ? 0 : e.style.borderSpacingX,
1714
+ spacingY: i ? 0 : e.style.borderSpacingY,
1715
+ vSegments: [],
1716
+ hSegments: []
1717
+ };
1718
+ if (!i || n === 0 || r === 0) return a;
1719
+ let o = Array.from({ length: r }, () => Array.from({ length: n }, () => void 0));
1720
+ for (let e of t.cells) for (let t = e.row; t < e.row + e.rowSpan; t++) for (let n = e.col; n < e.col + e.colSpan; n++) o[t][n] = e;
1721
+ let s = e.style.latticeBorder;
1722
+ for (let e = 0; e <= n; e++) {
1723
+ let i = [];
1724
+ for (let a = 0; a < r; a++) {
1725
+ let r = e > 0 ? o[a][e - 1] : void 0, c = e < n ? o[a][e] : void 0;
1726
+ if (r !== void 0 && r === c) {
1727
+ i.push(null);
1728
+ continue;
1729
+ }
1730
+ let l = [];
1731
+ r && r.col + r.colSpan === e && l.push({
1732
+ border: r.node.style.latticeBorder,
1733
+ side: "right"
1734
+ }), c && c.col === e && l.push({
1735
+ border: c.node.style.latticeBorder,
1736
+ side: "left"
1737
+ });
1738
+ let u = e === 0 ? "left" : e === n ? "right" : null;
1739
+ if (u) {
1740
+ l.push({
1741
+ border: t.rows[a].style.latticeBorder,
1742
+ side: u
1743
+ });
1744
+ let e = t.rowGroups[a];
1745
+ e && l.push({
1746
+ border: e.style.latticeBorder,
1747
+ side: u
1748
+ }), l.push({
1749
+ border: s,
1750
+ side: u
1751
+ });
1752
+ }
1753
+ i.push(nt(l));
1754
+ }
1755
+ a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
1756
+ }
1757
+ for (let e = 0; e <= r; e++) {
1758
+ let i = [];
1759
+ for (let a = 0; a < n; a++) {
1760
+ let n = e > 0 ? o[e - 1][a] : void 0, c = e < r ? o[e][a] : void 0;
1761
+ if (n !== void 0 && n === c) {
1762
+ i.push(null);
1763
+ continue;
1764
+ }
1765
+ let l = [];
1766
+ n && n.row + n.rowSpan === e && l.push({
1767
+ border: n.node.style.latticeBorder,
1768
+ side: "bottom"
1769
+ }), c && c.row === e && l.push({
1770
+ border: c.node.style.latticeBorder,
1771
+ side: "top"
1772
+ }), e > 0 && l.push({
1773
+ border: t.rows[e - 1].style.latticeBorder,
1774
+ side: "bottom"
1775
+ }), e < r && l.push({
1776
+ border: t.rows[e].style.latticeBorder,
1777
+ side: "top"
1778
+ });
1779
+ let u = e > 0 ? t.rowGroups[e - 1] : null, d = e < r ? t.rowGroups[e] : null;
1780
+ u && u !== d && l.push({
1781
+ border: u.style.latticeBorder,
1782
+ side: "bottom"
1783
+ }), d && d !== u && l.push({
1784
+ border: d.style.latticeBorder,
1785
+ side: "top"
1786
+ }), e === 0 && l.push({
1787
+ border: s,
1788
+ side: "top"
1789
+ }), e === r && l.push({
1790
+ border: s,
1791
+ side: "bottom"
1792
+ }), i.push(nt(l));
1793
+ }
1794
+ a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
1795
+ }
1796
+ return a;
1797
+ }
1798
+ function it(e, t) {
1799
+ return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
1800
+ }
1801
+ function at(e, t, n) {
1802
+ if (!e.collapsed) return e.spacingX * (n - t - 1);
1803
+ let r = 0;
1804
+ for (let i = t + 1; i < n; i++) r += e.vLines[i];
1805
+ return r;
1806
+ }
1807
+ function ot(e, t, n) {
1808
+ if (!e.collapsed) return e.spacingY * (n - t - 1);
1809
+ let r = 0;
1810
+ for (let i = t + 1; i < n; i++) r += e.hLines[i];
1811
+ return r;
1812
+ }
1813
+ function st(e, t) {
1814
+ let n = t.tableData.get(e);
1815
+ if (n) return n;
1816
+ let r = Je(e, t), i = rt(e, r), a = {
1817
+ structure: r,
1818
+ chrome: i,
1819
+ bounds: Qe(r, i, t),
1820
+ chromeX: it(i, r.columnCount)
1821
+ };
1822
+ return t.tableData.set(e, a), a;
1823
+ }
1824
+ function ct(e, t) {
1825
+ let { structure: n, bounds: r, chromeX: i } = st(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
1826
+ return n.caption && (a = Math.max(a, X(n.caption, t)), o = Math.max(o, Y(n.caption, t))), {
1827
+ min: a,
1828
+ max: o
1829
+ };
1830
+ }
1831
+ function lt(e, t, n) {
1832
+ let r = e.style, { bounds: i, chromeX: a } = st(e, n), { min: o, max: s } = ct(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;
1833
+ for (let e = 0; e < i.max.length; e++) {
1834
+ let t = i.percent[e];
1835
+ t === void 0 ? d += i.max[e] : u += t;
1836
+ }
1837
+ if (u >= 100) l = Infinity;
1838
+ else if (u > 0) {
1839
+ for (let e = 0; e < i.max.length; e++) {
1840
+ let t = i.percent[e];
1841
+ t !== void 0 && t > 0 && (l = Math.max(l, Math.ceil(i.max[e] * 100 / t)));
1842
+ }
1843
+ l = Math.max(l, Math.ceil(d * 100 / (100 - u)));
1844
+ }
1845
+ let f = Math.max(l + a, s) + c;
1846
+ return Math.max(o + c, Math.min(f, t));
1847
+ }
1848
+ function ut(e, t, n, r, i, a) {
1849
+ let { structure: o, chrome: s, bounds: c } = st(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
1850
+ for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
1851
+ x: 0,
1852
+ y: 0,
1853
+ width: 0,
1854
+ height: 0
1855
+ }, e.resolvedPadding = {
1856
+ top: 0,
1857
+ right: 0,
1858
+ bottom: 0,
1859
+ left: 0
1860
+ }, e.unclampedHeight = 0;
1861
+ let p = Math.max(0, t - it(s, l)), h = e.style, g = h.tableLayout === "fixed" && h.width !== void 0 && h.width.kind !== "auto" ? et(o, p, a) : $e(c, p), _ = [], v = 0;
1862
+ for (let e = 0; e < l; e++) v += s.collapsed ? s.vLines[e] : s.spacingX, _.push(v), v += g[e];
1863
+ let y = v + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), b = 0;
1864
+ o.caption && (H(o.caption, t, void 0, d, f, "fill", a), b = o.caption.localRect.height);
1865
+ let x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
1866
+ for (let e of o.cells) {
1867
+ let t = e.col + e.colSpan, n = g.slice(e.col, t).reduce((e, t) => e + t, 0) + at(s, e.col, t);
1868
+ S.set(e, n), H(e.node, n, void 0, 0, 0, "fill", a, { width: n }), x.set(e, e.node.localRect.height);
1869
+ }
1870
+ 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);
1871
+ for (let e = 0; e < u; e++) {
1872
+ let t = o.rows[e].style.height;
1873
+ t !== void 0 && t.kind === "cells" && (E[e] = t.value);
1874
+ let n = T(t);
1875
+ n > 0 && (E[e] = Math.max(E[e], n), D[e] = !0);
1876
+ }
1877
+ for (let e of o.cells) if (e.rowSpan === 1) {
1878
+ let t = T(e.node.style.height);
1879
+ t > 0 && (D[e.row] = !0), E[e.row] = Math.max(E[e.row], x.get(e), t);
1880
+ }
1881
+ let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
1882
+ for (let e of O) {
1883
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + ot(s, e.row, t), r = x.get(e) - n;
1884
+ if (r <= 0) continue;
1885
+ let i = I(Array.from({ length: e.rowSpan }, () => 1), r);
1886
+ for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
1887
+ }
1888
+ if (n !== void 0 && u > 0) {
1889
+ let e = n - b - C - E.reduce((e, t) => e + t, 0);
1890
+ if (e > 0) {
1891
+ let t = [];
1892
+ for (let e = 0; e < u; e++) D[e] || t.push(e);
1893
+ let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = I(n.map(() => 1), e);
1894
+ n.forEach((e, t) => E[e] += r[t]);
1895
+ }
1896
+ }
1897
+ let k = o.caption && e.style.captionSide === "top" ? b : 0, A = [], j = k;
1898
+ for (let e = 0; e < u; e++) j += s.collapsed ? s.hLines[e] : s.spacingY, A.push(j), j += E[e];
1899
+ let M = u > 0 ? j + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, N = /* @__PURE__ */ new Map();
1900
+ for (let e = 0; e < u; e++) {
1901
+ let t = o.rowGroups[e];
1902
+ t && !N.has(t) && N.set(t, A[e]);
1903
+ }
1904
+ for (let [e, t] of N) {
1905
+ let n = t;
1906
+ for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = A[t] + E[t]);
1907
+ e.localRect = {
1908
+ x: d,
1909
+ y: f + t,
1910
+ width: y,
1911
+ height: n - t
1912
+ }, e.resolvedPadding = {
1913
+ top: 0,
1914
+ right: 0,
1915
+ bottom: 0,
1916
+ left: 0
1917
+ }, e.unclampedHeight = n - t;
1918
+ }
1919
+ for (let e = 0; e < u; e++) {
1920
+ let t = o.rows[e], n = o.rowGroups[e], r = n ? N.get(n) : void 0;
1921
+ t.localRect = {
1922
+ x: r === void 0 ? d : 0,
1923
+ y: r === void 0 ? f + A[e] : A[e] - r,
1924
+ width: y,
1925
+ height: E[e]
1926
+ }, t.resolvedPadding = {
1927
+ top: 0,
1928
+ right: 0,
1929
+ bottom: 0,
1930
+ left: 0
1931
+ }, t.unclampedHeight = E[e];
1932
+ }
1933
+ for (let e of o.cells) {
1934
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + ot(s, e.row, t);
1935
+ e.node.children.some((e) => !V(e.style) && e.style.height?.kind === "percent") && n !== x.get(e) && H(e.node, S.get(e), n, 0, 0, "fill", a, {
1936
+ width: S.get(e),
1937
+ height: n
1938
+ }), dt(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
1939
+ x: _[e.col],
1940
+ y: 0,
1941
+ width: e.node.localRect.width,
1942
+ height: n
1943
+ };
1944
+ }
1945
+ for (let t of e.children) V(t.style) && (t.staticSlot = {
1946
+ kind: "block",
1947
+ x: d,
1948
+ y: f
1949
+ });
1950
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = ft(s, o, g, E, _, A, d, f)), e.style.captionSide === "bottom" ? M + b : M;
1951
+ }
1952
+ function dt(e, t) {
1953
+ if (t <= 0) return;
1954
+ let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
1955
+ if (!e.children.some((e) => !V(e.style) && !e.inlineBox)) {
1956
+ e.resolvedPadding.top += r, e.resolvedPadding.bottom += t - r;
1957
+ return;
1958
+ }
1959
+ if (!(r <= 0)) for (let t of e.children) t.inlineBox || (V(t.style) ? t.staticSlot?.kind === "block" && (t.staticSlot.y += r) : t.localRect.y += r);
1960
+ }
1961
+ function ft(e, t, n, r, o, s, c, l) {
1962
+ 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];
1963
+ for (let t = 0; t <= u; t++) {
1964
+ let n = e.vSegments[t];
1965
+ for (let e = 0; e < d; e++) {
1966
+ let a = n[e];
1967
+ if (!a) continue;
1968
+ let o = i(a.style, "v");
1969
+ for (let n = 0; n < a.width; n++) for (let i = s[e]; i < s[e] + r[e]; i++) f.push({
1970
+ glyph: o,
1971
+ x: c + p(t) + n,
1972
+ y: l + i,
1973
+ length: 1,
1974
+ color: a.color
1975
+ });
1976
+ }
1977
+ }
1978
+ for (let t = 0; t <= d; t++) {
1979
+ let r = e.hSegments[t];
1980
+ for (let e = 0; e < u; e++) {
1981
+ let a = r[e];
1982
+ if (!a) continue;
1983
+ let s = i(a.style, "h");
1984
+ for (let r = 0; r < a.width; r++) f.push({
1985
+ glyph: s,
1986
+ x: c + o[e],
1987
+ y: l + m(t) + r,
1988
+ length: n[e],
1989
+ color: a.color
1990
+ });
1991
+ }
1992
+ }
1993
+ for (let t = 0; t <= u; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= d; n++) {
1994
+ if (e.hLines[n] <= 0) continue;
1995
+ 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 = [
1996
+ r,
1997
+ i,
1998
+ o,
1999
+ s
2000
+ ].filter((e) => e !== null);
2001
+ if (h.length === 0) continue;
2002
+ let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && tt[t.style] > tt[e.style] ? t : e), v = a(g, r !== null, i !== null, o !== null, s !== null);
2003
+ for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) f.push({
2004
+ glyph: v,
2005
+ x: c + p(t) + r,
2006
+ y: l + m(n) + i,
2007
+ length: 1,
2008
+ color: _.color
2009
+ });
2010
+ }
2011
+ return f;
1083
2012
  }
1084
2013
  //#endregion
1085
2014
  //#region src/positioning.ts
1086
- function we(e) {
2015
+ function pt(e) {
1087
2016
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
1088
2017
  }
1089
- function Te(e, t, n, r, i) {
2018
+ function mt(e, t, n, r, i) {
1090
2019
  for (let a of e.children) {
1091
- let o = we(a.style);
2020
+ let o = pt(a.style);
1092
2021
  if (o === "relative") {
1093
2022
  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;
1094
- a.localRect.x += Ee(a.style.insets.left, a.style.insets.right, t), a.localRect.y += Ee(a.style.insets.top, a.style.insets.bottom, n);
1095
- } else o === "absolute" && Oe(a, e, t, n, r, i);
1096
- Te(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2023
+ a.localRect.x += ht(a.style.insets.left, a.style.insets.right, t), a.localRect.y += ht(a.style.insets.top, a.style.insets.bottom, n);
2024
+ } else o === "absolute" && _t(a, e, t, n, r, i);
2025
+ mt(a, t + a.localRect.x, n + a.localRect.y, [...r, {
1097
2026
  node: a,
1098
2027
  absX: t + a.localRect.x,
1099
2028
  absY: n + a.localRect.y
1100
2029
  }], i);
1101
2030
  }
1102
2031
  }
1103
- function Ee(e, t, n) {
2032
+ function ht(e, t, n) {
1104
2033
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
1105
2034
  }
1106
- function De(e, t) {
2035
+ function gt(e, t) {
1107
2036
  if (!t) for (let t = e.length - 1; t > 0; t--) {
1108
2037
  let n = e[t];
1109
- if (!Ie(n.node.style)) continue;
2038
+ if (!Tt(n.node.style)) continue;
1110
2039
  let r = n.node.style.border;
1111
2040
  return {
1112
2041
  x: n.absX + r.left,
@@ -1123,43 +2052,43 @@ function De(e, t) {
1123
2052
  height: n.node.localRect.height
1124
2053
  };
1125
2054
  }
1126
- function Oe(e, t, n, r, i, a) {
1127
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Ie(t.style) ? {
2055
+ function _t(e, t, n, r, i, a) {
2056
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Tt(t.style) ? {
1128
2057
  x: n + c.area.x,
1129
2058
  y: r + c.area.y,
1130
2059
  width: c.area.width,
1131
2060
  height: c.area.height
1132
- } : De(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 = J(o.minWidth, l.width, e, a) ?? 0, S = J(o.maxWidth, l.width, e, a), C = {};
1133
- if (!y) C.width = U(Y(o.width, l.width, e, a), x, S);
2061
+ } : gt(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 = jt(o.minWidth, l.width, e, a) ?? 0, S = jt(o.maxWidth, l.width, e, a), C = {};
2062
+ if (!y) C.width = U(J(o.width, l.width, e, a), x, S);
1134
2063
  else if (u !== null && d !== null) C.width = U(Math.max(0, l.width - u - d - h - g), x, S);
1135
2064
  else {
1136
2065
  let t = Math.max(0, l.width - (u ?? 0) - (d ?? 0) - h - g);
1137
- C.width = U(Math.min(X(e, a), Math.max(Z(e, a), t)), x, S);
2066
+ C.width = U(Math.min(Y(e, a), Math.max(X(e, a), t)), x, S);
1138
2067
  }
1139
2068
  f !== null && p !== null && b && (C.height = U(Math.max(0, l.height - f - p - _ - v), q(o.minHeight, l.height) ?? 0, q(o.maxHeight, l.height))), H(e, l.width, l.height, 0, 0, "shrink", a, C);
1140
2069
  let w = e.localRect.width, T = e.localRect.height, E;
1141
2070
  if (u !== null && d !== null) {
1142
2071
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
1143
2072
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
1144
- } else E = u === null ? d === null ? Ne(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2073
+ } else E = u === null ? d === null ? St(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
1145
2074
  let D;
1146
2075
  if (f !== null && p !== null) {
1147
2076
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
1148
2077
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
1149
- } else D = f === null ? p === null ? Pe(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2078
+ } else D = f === null ? p === null ? Ct(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
1150
2079
  e.localRect = {
1151
2080
  ...e.localRect,
1152
2081
  x: E - n,
1153
2082
  y: D - r
1154
2083
  };
1155
2084
  }
1156
- function ke(e, t, n) {
1157
- return x(e, [n], Math.max(0, t - n))[0];
2085
+ function vt(e, t, n) {
2086
+ return F(e, [n], Math.max(0, t - n))[0];
1158
2087
  }
1159
- function Ae(e, t, n, r) {
1160
- return T(w(e, t), n, r);
2088
+ function yt(e, t, n, r) {
2089
+ return R(L(e, t), n, r);
1161
2090
  }
1162
- function je(e, t, n, r, i) {
2091
+ function bt(e, t, n, r, i) {
1163
2092
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
1164
2093
  a.left ?? 0,
1165
2094
  a.right ?? 0,
@@ -1171,9 +2100,9 @@ function je(e, t, n, r, i) {
1171
2100
  n.innerHeight,
1172
2101
  n.direction === "column"
1173
2102
  ], u = i + o + s;
1174
- return (l ? ke(k(t.style), c, u) : Ae(e, t, c, u)) + o;
2103
+ return (l ? vt(ce(t.style), c, u) : yt(e, t, c, u)) + o;
1175
2104
  }
1176
- function Me(e, t, n, r, i) {
2105
+ function xt(e, t, n, r, i) {
1177
2106
  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" ? [
1178
2107
  a.left ?? 0,
1179
2108
  a.right ?? 0,
@@ -1183,23 +2112,23 @@ function Me(e, t, n, r, i) {
1183
2112
  a.top ?? 0,
1184
2113
  a.bottom ?? 0,
1185
2114
  n.height,
1186
- w(e, t)
2115
+ L(e, t)
1187
2116
  ];
1188
- return T(u, l, i + s + c) + s;
2117
+ return R(u, l, i + s + c) + s;
1189
2118
  }
1190
- function Ne(e, t, n, r) {
2119
+ function St(e, t, n, r) {
1191
2120
  let i = e.staticSlot;
1192
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Me(e, t, i.staticArea, "x", r) : n + i.originX + je(e, t, i, "x", r);
2121
+ return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + xt(e, t, i.staticArea, "x", r) : n + i.originX + bt(e, t, i, "x", r);
1193
2122
  }
1194
- function Pe(e, t, n, r) {
2123
+ function Ct(e, t, n, r) {
1195
2124
  let i = e.staticSlot;
1196
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Me(e, t, i.staticArea, "y", r) : n + i.originY + je(e, t, i, "y", r);
2125
+ return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + xt(e, t, i.staticArea, "y", r) : n + i.originY + bt(e, t, i, "y", r);
1197
2126
  }
1198
2127
  //#endregion
1199
2128
  //#region src/layout.ts
1200
- function Fe(e, t) {
1201
- let n = Le();
1202
- return H(e, t, void 0, 0, 0, "fill", n), Te(e, 0, 0, [{
2129
+ function wt(e, t) {
2130
+ let n = Et();
2131
+ return H(e, t, void 0, 0, 0, "fill", n), mt(e, 0, 0, [{
1203
2132
  node: e,
1204
2133
  absX: 0,
1205
2134
  absY: 0
@@ -1208,106 +2137,118 @@ function Fe(e, t) {
1208
2137
  function V(e) {
1209
2138
  return e.position === "absolute" || e.position === "fixed";
1210
2139
  }
1211
- function Ie(e) {
2140
+ function Tt(e) {
1212
2141
  return e.position !== "static";
1213
2142
  }
1214
- function Le() {
2143
+ function Et() {
1215
2144
  return {
1216
2145
  maxContent: /* @__PURE__ */ new WeakMap(),
1217
2146
  minContent: /* @__PURE__ */ new WeakMap(),
1218
- gridIntrinsic: /* @__PURE__ */ new WeakMap()
2147
+ gridIntrinsic: /* @__PURE__ */ new WeakMap(),
2148
+ tableData: /* @__PURE__ */ new WeakMap()
1219
2149
  };
1220
2150
  }
1221
- function H(e, t, n, r, i, a, o, c) {
1222
- let l = e.style, u = c?.height, f = J(l.minWidth, t, e, o) ?? 0, p = J(l.maxWidth, t, e, o), m = q(l.minHeight, n) ?? 0, h = q(l.maxHeight, n), _ = {
1223
- top: W(l.padding.top, t),
1224
- right: W(l.padding.right, t),
1225
- bottom: W(l.padding.bottom, t),
1226
- left: W(l.padding.left, t)
2151
+ function H(e, t, n, r, i, a, o, s) {
2152
+ let c = e.style, l = s?.height;
2153
+ delete e.decorationRuns;
2154
+ let u = jt(c.minWidth, t, e, o) ?? 0, d = jt(c.maxWidth, t, e, o), f = q(c.minHeight, n) ?? 0, p = q(c.maxHeight, n), m = {
2155
+ top: W(c.padding.top, t),
2156
+ right: W(c.padding.right, t),
2157
+ bottom: W(c.padding.bottom, t),
2158
+ left: W(c.padding.left, t)
1227
2159
  };
1228
- e.resolvedPadding = _;
1229
- let y = c?.width ?? U(Ue(l, t, a, e, o), f, p), b = We(l, n), x = qe(y, u ?? b ?? (m > 0 ? m : void 0) ?? Infinity, l.border, _), S = u !== void 0 || b !== void 0, C = S && Number.isFinite(x.height) ? x.height : void 0, w;
1230
- if (Re(e)) {
2160
+ e.resolvedPadding = m;
2161
+ let h = s?.width ?? U(Pt(c, t, a, e, o), u, d), g = It(c, n), _ = zt(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;
2162
+ if (Dt(e)) {
1231
2163
  if (e.text) {
1232
2164
  let t = e.children.filter((e) => e.inlineBox);
1233
- d(e.text, (n, r) => {
2165
+ E(e.text, (n, r) => {
1234
2166
  let i = t[r];
1235
- H(i, x.width, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2167
+ H(i, _.width, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
1236
2168
  });
1237
- let n = Be(e, x.width);
1238
- if (w = n.totalRows, ze(e, n, x.width, x.height, _), t.length > 0) {
2169
+ let n = kt(e, _.width);
2170
+ if (b = n.totalRows, Ot(e, n, _.width, _.height, m), t.length > 0) {
1239
2171
  let r = (e) => n.spans.findIndex((t) => e >= t.start && e < t.end);
1240
- d(e.text, (i, a) => {
2172
+ E(e.text, (i, a) => {
1241
2173
  let o = r(i);
1242
2174
  if (o === -1) return;
1243
- let c = n.spans[o];
2175
+ let s = n.spans[o];
1244
2176
  t[a].localRect = {
1245
2177
  ...t[a].localRect,
1246
- x: l.border.left + _.left + s(c.start, i, e.advances),
1247
- y: l.border.top + _.top + n.lineY[o]
2178
+ x: c.border.left + m.left + S(s.start, i, e.advances),
2179
+ y: c.border.top + m.top + n.lineY[o]
1248
2180
  };
1249
2181
  });
1250
2182
  }
1251
- } else w = e.intrinsicHeight;
2183
+ } else b = e.intrinsicHeight;
1252
2184
  for (let t of e.children) {
1253
2185
  if (t.inlineBox) continue;
1254
- let e = G(t.style.margin, x.width);
2186
+ let e = G(t.style.margin, _.width);
1255
2187
  t.staticSlot = {
1256
2188
  kind: "block",
1257
- x: l.border.left + _.left + (e.left ?? 0),
1258
- y: l.border.top + _.top + (e.top ?? 0)
2189
+ x: c.border.left + m.left + (e.left ?? 0),
2190
+ y: c.border.top + m.top + (e.top ?? 0)
1259
2191
  };
1260
2192
  }
1261
- } else w = l.display === "flex" && l.flexDirection === "row" ? g(e, x.width, x.height, C, l.border, _, o) : l.display === "flex" && l.flexDirection === "column" ? v(e, x.width, x.height, S, l.border, _, o) : l.display === "grid" ? P(e, x.width, x.height, l.border, _, o) : Ve(e, x.width, C, l.border, _, o);
1262
- let T = w + l.border.top + l.border.bottom + _.top + _.bottom, E = u ?? b ?? T;
1263
- e.unclampedHeight = E, e.localRect = {
2193
+ } else b = 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" ? de(e, _.width, _.height, c.border, m, o) : c.display === "table" ? ut(e, _.width, y, c.border, m, o) : Mt(e, _.width, y, c.border, m, o);
2194
+ let x = b + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? x;
2195
+ e.unclampedHeight = C, e.naturalContentHeight = x, e.localRect = {
1264
2196
  x: r,
1265
2197
  y: i,
1266
- width: y,
1267
- height: U(E, m, h)
2198
+ width: h,
2199
+ height: U(C, f, p)
1268
2200
  };
1269
2201
  }
1270
- function Re(e) {
2202
+ function Dt(e) {
1271
2203
  return e.children.some((e) => !V(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
1272
2204
  }
1273
2205
  function U(e, t, n) {
1274
2206
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
1275
2207
  }
1276
- function ze(e, t, n, r, i) {
2208
+ function Ot(e, t, n, r, i) {
1277
2209
  let a = e.style;
1278
2210
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
1279
- 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), l = Math.max(0, n - s);
1280
- if (l > 0) {
1281
- let e = a.display === "grid" ? T(a.justifyItems, n, s) : o ? T(a.alignItems, n, s) : x(k(a), [s], l)[0];
1282
- e > 0 && (i.left += e, i.right += l - e);
2211
+ 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);
2212
+ if (c > 0) {
2213
+ let e = a.display === "grid" ? R(a.justifyItems, n, s) : o ? R(a.alignItems, n, s) : F(ce(a), [s], c)[0];
2214
+ e > 0 && (i.left += e, i.right += c - e);
1283
2215
  }
1284
2216
  if (Number.isFinite(r)) {
1285
2217
  let e = Math.max(0, r - t.totalRows);
1286
2218
  if (e > 0) {
1287
- let n = a.display === "grid" || !o ? T(a.alignItems, r, t.totalRows) : x(k(a), [t.totalRows], e)[0];
2219
+ let n = a.display === "grid" || !o ? R(a.alignItems, r, t.totalRows) : F(ce(a), [t.totalRows], e)[0];
1288
2220
  n > 0 && (i.top += n, i.bottom += e - n);
1289
2221
  }
1290
2222
  }
1291
2223
  }
1292
- function Be(e, t) {
1293
- let n = e.style.whiteSpace === "normal" ? o(e.text, t, {
2224
+ function kt(e, t) {
2225
+ let n = e.style.whiteSpace === "normal" ? x(e.text, t, {
1294
2226
  advances: e.advances,
1295
2227
  tracking: e.style.tracking
1296
- }) : a(e.text), r = e.children.filter((e) => e.inlineBox), i = [], s = 0, c = 0;
2228
+ }) : b(e.text), r = e.children.filter((e) => e.inlineBox), i = [], a = [], o = 0, s = 0;
1297
2229
  for (let t = 0; t < n.length; t++) {
1298
- i.push(s);
1299
- let a = n[t], o = 1;
1300
- for (let t = a.start; t < a.end; t++) e.text[t] === "" && (o = Math.max(o, r[c].localRect.height), c++);
1301
- s += o + (t < n.length - 1 ? e.style.lineGap : 0);
2230
+ i.push(o);
2231
+ let c = n[t], l = 1, u = 0;
2232
+ for (let t = c.start; t < c.end; t++) {
2233
+ if (e.text[t] !== "") continue;
2234
+ let n = r[s];
2235
+ l = Math.max(l, n.localRect.height), n.style.verticalAlign === "end" ? u = Math.max(u, n.localRect.height - 1) : n.style.verticalAlign === "center" && Ue(n.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), s++;
2236
+ }
2237
+ a.push(o + Math.min(u, l - 1)), o += l + (t < n.length - 1 ? e.style.lineGap : 0);
1302
2238
  }
1303
2239
  return {
1304
2240
  spans: n,
1305
2241
  lineY: i,
1306
- totalRows: s
2242
+ textY: a,
2243
+ totalRows: o
1307
2244
  };
1308
2245
  }
2246
+ function At(e, t, n) {
2247
+ let r = W(t === "x" ? e.gapX : e.gapY, n), i = t === "x" ? e.ruleX : e.ruleY;
2248
+ return Math.max(r, i?.width ?? 0);
2249
+ }
1309
2250
  function W(e, t) {
1310
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : n(e.percent, t);
2251
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : m(e.percent, t);
1311
2252
  }
1312
2253
  function G(e, t) {
1313
2254
  let n = (e) => e === null ? null : W(e, t);
@@ -1322,12 +2263,12 @@ function K(e) {
1322
2263
  return typeof e == "number" ? e : 0;
1323
2264
  }
1324
2265
  function q(e, t) {
1325
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : n(e.percent, t);
2266
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : m(e.percent, t);
1326
2267
  }
1327
- function J(e, t, n, r) {
1328
- return e === "min-content" || e === "max-content" || e === "fit-content" ? Y({ kind: e }, t, n, r) : q(e, t);
2268
+ function jt(e, t, n, r) {
2269
+ return e === "min-content" || e === "max-content" || e === "fit-content" ? J({ kind: e }, t, n, r) : q(e, t);
1329
2270
  }
1330
- function Ve(e, t, n, r, i, a) {
2271
+ function Mt(e, t, n, r, i, a) {
1331
2272
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
1332
2273
  for (let r of e.children) {
1333
2274
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -1335,7 +2276,7 @@ function Ve(e, t, n, r, i, a) {
1335
2276
  r.staticSlot = {
1336
2277
  kind: "block",
1337
2278
  x: o + u,
1338
- y: c + (l === null ? i : He(l, i))
2279
+ y: c + (l === null ? i : Nt(l, i))
1339
2280
  };
1340
2281
  continue;
1341
2282
  }
@@ -1343,7 +2284,7 @@ function Ve(e, t, n, r, i, a) {
1343
2284
  let f = t - r.localRect.width, p = e.left === null && e.right === null, m = e.left === null && e.right !== null;
1344
2285
  e.right === null && e.left;
1345
2286
  let h;
1346
- h = p ? Math.floor(f / 2) : m ? f - d : u, c += l === null ? i : He(l, i), r.localRect = {
2287
+ h = p ? Math.floor(f / 2) : m ? f - d : u, c += l === null ? i : Nt(l, i), r.localRect = {
1347
2288
  ...r.localRect,
1348
2289
  x: o + h,
1349
2290
  y: c
@@ -1351,187 +2292,224 @@ function Ve(e, t, n, r, i, a) {
1351
2292
  }
1352
2293
  return l !== null && (c += l), c - s;
1353
2294
  }
1354
- function He(e, t) {
2295
+ function Nt(e, t) {
1355
2296
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
1356
2297
  }
1357
- function Ue(e, t, n, r, i) {
2298
+ function Pt(e, t, n, r, i) {
1358
2299
  let a = e.width;
1359
- return a !== void 0 && a.kind !== "auto" ? Y(a, t, r, i) : n === "shrink" ? Math.min(t, X(r, i)) : t;
2300
+ if (e.display === "table") {
2301
+ if (!r.children.some((e) => !V(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? J(a, t, r, i) : Math.min(t, Y(r, i));
2302
+ if (a !== void 0 && a.kind !== "auto") {
2303
+ let e = J(a, t, r, i);
2304
+ return Math.max(e, Ft(r, t, i));
2305
+ }
2306
+ return lt(r, t, i);
2307
+ }
2308
+ return a !== void 0 && a.kind !== "auto" ? J(a, t, r, i) : n === "shrink" ? Math.min(t, Y(r, i)) : t;
1360
2309
  }
1361
- function We(e, t) {
2310
+ function Ft(e, t, n) {
2311
+ let r = e.style;
2312
+ return ct(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2313
+ }
2314
+ function It(e, t) {
1362
2315
  if (e.height?.kind === "cells") return e.height.value;
1363
- if (e.height?.kind === "percent" && t != null) return n(e.height.value, t);
2316
+ if (e.height?.kind === "percent" && t != null) return m(e.height.value, t);
1364
2317
  }
1365
- function Y(e, t, r, i) {
2318
+ function J(e, t, n, r) {
1366
2319
  switch (e.kind) {
1367
2320
  case "cells": return e.value;
1368
- case "percent": return n(e.value, t);
1369
- case "min-content": return Z(r, i);
1370
- case "max-content": return X(r, i);
1371
- case "fit-content": return Math.min(X(r, i), Math.max(Z(r, i), t));
1372
- case "auto": return X(r, i);
2321
+ case "percent": return m(e.value, t);
2322
+ case "min-content": return X(n, r);
2323
+ case "max-content": return Y(n, r);
2324
+ case "fit-content": return Math.min(Y(n, r), Math.max(X(n, r), t));
2325
+ case "auto": return Y(n, r);
1373
2326
  }
1374
2327
  }
1375
- function X(e, t) {
2328
+ function Y(e, t) {
1376
2329
  let n = t.maxContent.get(e);
1377
2330
  if (n !== void 0) return n;
1378
- let r = e.style, i = Ge(e, t) + r.border.left + r.border.right + K(r.padding.left) + K(r.padding.right);
2331
+ let r = e.style, i = Lt(e, t) + r.border.left + r.border.right + K(r.padding.left) + K(r.padding.right);
1379
2332
  return t.maxContent.set(e, i), i;
1380
2333
  }
1381
- function Ge(e, t) {
2334
+ function Lt(e, t) {
1382
2335
  let n = e.children.filter((e) => !V(e.style) && !e.inlineBox);
1383
2336
  if (n.length === 0) return e.intrinsicWidth;
1384
- if (e.style.display === "grid") return ae(e, t).max;
2337
+ if (e.style.display === "grid") return be(e, t).max;
2338
+ if (e.style.display === "table") return ct(e, t).max;
1385
2339
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
1386
- let r = K(e.style.gapX) * Math.max(0, n.length - 1);
1387
- return n.reduce((e, n) => e + X(n, t), 0) + r;
2340
+ let r = Math.max(K(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2341
+ return n.reduce((e, n) => e + Y(n, t), 0) + r;
1388
2342
  }
1389
- return n.reduce((e, n) => Math.max(e, X(n, t)), 0);
2343
+ return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
1390
2344
  }
1391
- function Z(e, t) {
2345
+ function X(e, t) {
1392
2346
  let n = t.minContent.get(e);
1393
2347
  if (n !== void 0) return n;
1394
- let r = e.style, i = Ke(e, t) + r.border.left + r.border.right + K(r.padding.left) + K(r.padding.right);
2348
+ let r = e.style, i = Rt(e, t) + r.border.left + r.border.right + K(r.padding.left) + K(r.padding.right);
1395
2349
  return t.minContent.set(e, i), i;
1396
2350
  }
1397
- function Ke(e, t) {
2351
+ function Rt(e, t) {
1398
2352
  let n = e.children.filter((e) => !V(e.style) && !e.inlineBox);
1399
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : u(e.text, {
2353
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : T(e.text, {
1400
2354
  advances: e.advances,
1401
2355
  tracking: e.style.tracking
1402
2356
  });
1403
- if (e.style.display === "grid") return ae(e, t).min;
2357
+ if (e.style.display === "grid") return be(e, t).min;
2358
+ if (e.style.display === "table") return ct(e, t).min;
1404
2359
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
1405
- let r = K(e.style.gapX) * Math.max(0, n.length - 1);
1406
- return n.reduce((e, n) => e + Z(n, t), 0) + r;
2360
+ let r = Math.max(K(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2361
+ return n.reduce((e, n) => e + X(n, t), 0) + r;
1407
2362
  }
1408
- return n.reduce((e, n) => Math.max(e, Z(n, t)), 0);
2363
+ return n.reduce((e, n) => Math.max(e, X(n, t)), 0);
1409
2364
  }
1410
- function qe(e, t, n, r) {
2365
+ function zt(e, t, n, r) {
1411
2366
  return {
1412
2367
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
1413
2368
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
1414
2369
  };
1415
2370
  }
1416
2371
  //#endregion
1417
- //#region src/borders.ts
1418
- function Je(e, t, n) {
1419
- let r = e.border;
1420
- if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
1421
- let i = Math.max(r.top, r.right, r.bottom, r.left);
1422
- for (let a = 0; a < i; a++) {
1423
- let i = {
1424
- top: a < r.top,
1425
- right: a < r.right,
1426
- bottom: a < r.bottom,
1427
- left: a < r.left
1428
- }, o = {
1429
- x: t.x + (i.left ? a : 0),
1430
- y: t.y + (i.top ? a : 0),
1431
- width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
1432
- height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
1433
- };
1434
- o.width <= 0 || o.height <= 0 || Ye(n, e.borderStyle, e.borderColor, o, i);
2372
+ //#region src/plain-text.ts
2373
+ function Bt(e) {
2374
+ return Kt(e).grid.map((e) => e.join("").trimEnd()).join("\n");
2375
+ }
2376
+ function Vt(e) {
2377
+ let { grid: t, paints: n } = Kt(e);
2378
+ return t.map((e, t) => Ht(e, n[t]));
2379
+ }
2380
+ function Ht(e, t) {
2381
+ let n = e.length;
2382
+ for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
2383
+ let r = [];
2384
+ for (let i = 0; i < n; i++) {
2385
+ let n = t[i], a = r[r.length - 1];
2386
+ a && Ut(a, n) ? a.text += e[i] : r.push({
2387
+ text: e[i],
2388
+ ...n
2389
+ });
1435
2390
  }
2391
+ return r;
1436
2392
  }
1437
- function Ye(e, t, n, r, i) {
1438
- let a = Q(t.top), o = Q(t.right), s = Q(t.bottom), c = Q(t.left), l = (e, t, n) => n(Q(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;
1439
- if (i.top && g > h && e.push({
1440
- glyph: a.h,
1441
- x: h,
1442
- y: d,
1443
- length: g - h,
1444
- color: n.top
1445
- }), i.bottom && p > +!!i.top && g > h && e.push({
1446
- glyph: s.h,
1447
- x: h,
1448
- y: d + p - 1,
1449
- length: g - h,
1450
- color: n.bottom
1451
- }), i.left) for (let t = _; t < v; t++) e.push({
1452
- glyph: c.v,
1453
- x: u,
1454
- y: t,
1455
- length: 1,
1456
- color: n.left
1457
- });
1458
- if (i.right && f > +!!i.left) for (let t = _; t < v; t++) e.push({
1459
- glyph: o.v,
1460
- x: u + f - 1,
1461
- y: t,
1462
- length: 1,
1463
- color: n.right
1464
- });
1465
- m && (i.top && i.left && e.push({
1466
- glyph: l(t.top, t.left, (e) => e.tl),
1467
- x: u,
1468
- y: d,
1469
- length: 1,
1470
- color: n.top
1471
- }), i.top && i.right && e.push({
1472
- glyph: l(t.top, t.right, (e) => e.tr),
1473
- x: u + f - 1,
1474
- y: d,
1475
- length: 1,
1476
- color: n.top
1477
- }), i.bottom && i.left && e.push({
1478
- glyph: l(t.bottom, t.left, (e) => e.bl),
1479
- x: u,
1480
- y: d + p - 1,
1481
- length: 1,
1482
- color: n.bottom
1483
- }), i.bottom && i.right && e.push({
1484
- glyph: l(t.bottom, t.right, (e) => e.br),
1485
- x: u + f - 1,
1486
- y: d + p - 1,
1487
- length: 1,
1488
- color: n.bottom
1489
- }));
2393
+ function Ut(e, t) {
2394
+ return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine;
1490
2395
  }
1491
- function Q(e) {
1492
- switch (e) {
1493
- case "double": return {
1494
- h: "═",
1495
- v: "║",
1496
- tl: "╔",
1497
- tr: "╗",
1498
- bl: "╚",
1499
- br: "╝"
1500
- };
1501
- case "dashed": return {
1502
- h: "╌",
1503
- v: "╎",
1504
- tl: "┌",
1505
- tr: "┐",
1506
- bl: "└",
1507
- br: "┘"
1508
- };
1509
- case "dotted": return {
1510
- h: "┄",
1511
- v: "┊",
1512
- tl: "┌",
1513
- tr: "┐",
1514
- bl: "└",
1515
- br: "┘"
1516
- };
1517
- default: return {
1518
- h: "─",
1519
- v: "│",
1520
- tl: "┌",
1521
- tr: "┐",
1522
- bl: "└",
1523
- br: "┘"
1524
- };
2396
+ function Wt(e, t) {
2397
+ 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);
2398
+ }
2399
+ function Gt(e) {
2400
+ return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0;
2401
+ }
2402
+ function Kt(e) {
2403
+ 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));
2404
+ return Jt(e, 0, 0, (e, a, o, s) => {
2405
+ if (e >= 0 && e < t && a >= 0 && a < n) {
2406
+ r[a][e] = o;
2407
+ let t = i[a][e];
2408
+ i[a][e] = t ? {
2409
+ ...t,
2410
+ ...s
2411
+ } : s;
2412
+ }
2413
+ }), {
2414
+ grid: r,
2415
+ paints: i
2416
+ };
2417
+ }
2418
+ function qt(e) {
2419
+ let t = {};
2420
+ 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;
2421
+ }
2422
+ function Jt(t, n, i, a) {
2423
+ if (t.tableHidden) return;
2424
+ let o = n + t.localRect.x, s = i + t.localRect.y, c = t.style;
2425
+ if (c.backgroundColor !== void 0 || c.backgroundClear) {
2426
+ let e = c.backgroundColor === void 0 ? void 0 : { backgroundColor: c.backgroundColor };
2427
+ for (let n = 0; n < t.localRect.height; n++) for (let r = 0; r < t.localRect.width; r++) a(o + r, s + n, " ", e);
2428
+ }
2429
+ let l = [];
2430
+ e(c, {
2431
+ x: o,
2432
+ y: s,
2433
+ width: t.localRect.width,
2434
+ height: t.localRect.height
2435
+ }, l);
2436
+ for (let e of l) {
2437
+ let t = e.color === void 0 ? void 0 : { color: e.color };
2438
+ for (let n = 0; n < e.length; n++) a(e.x + n, e.y, e.glyph, t);
2439
+ }
2440
+ if (t.decorationRuns) for (let e of t.decorationRuns) {
2441
+ let t = e.color === void 0 ? void 0 : { color: e.color };
2442
+ for (let n = 0; n < e.length; n++) a(o + e.x + n, s + e.y, e.glyph, t);
2443
+ }
2444
+ if (!t.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && t.text) {
2445
+ 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, { spans: l, textY: u } = kt(t, i), d = qt(c), f = t.inlineElements?.map((e) => qt(e));
2446
+ for (let e = 0; e < l.length; e++) {
2447
+ let o = l[e], s = r + u[e], p = c.whiteSpace !== "normal" && c.overflow === "clip" ? Yt(t.text, o, i, t.advances, c) : {
2448
+ end: o.end,
2449
+ ellipsis: !1
2450
+ }, m = C(o.start, o.end, t.advances, c.tracking), h = Math.max(0, i - m), g = n + (c.textAlign === "end" ? h : c.textAlign === "center" ? Math.floor(h / 2) : 0);
2451
+ for (let e = o.start; e < p.end; e++) {
2452
+ if (t.text[e] !== "") {
2453
+ let n = t.charInline?.[e] ?? -1, r = n >= 0 ? t.inlineElements[n] : void 0, i = r?.insets, o = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, c = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
2454
+ t.text[e] === "⁠" ? r?.backgroundColor && a(g + o, s + c, " ", { backgroundColor: r.backgroundColor }) : a(g + o, s + c, t.text[e], r ? f[n] : d);
2455
+ }
2456
+ g += S(e, e + 1, t.advances);
2457
+ }
2458
+ p.ellipsis && a(g, s, "…", d);
2459
+ }
2460
+ }
2461
+ for (let e of r(t)) Jt(e, o, s, a);
2462
+ }
2463
+ function Yt(e, t, n, r, i) {
2464
+ let { textOverflow: a, tracking: o } = i;
2465
+ if (C(t.start, t.end, r, o) <= n) return {
2466
+ end: t.end,
2467
+ ellipsis: !1
2468
+ };
2469
+ let s = a === "ellipsis" ? n - 1 : n, c = t.start;
2470
+ for (; c < t.end && C(t.start, c + 1, r, o) <= s;) c++;
2471
+ return {
2472
+ end: c,
2473
+ ellipsis: a === "ellipsis" && n > 0
2474
+ };
2475
+ }
2476
+ //#endregion
2477
+ //#region src/paint.ts
2478
+ var Xt = /* @__PURE__ */ new WeakMap();
2479
+ function Zt(e, t) {
2480
+ let n = Vt(e), r = Qt(n);
2481
+ if (Xt.get(t) === r) return;
2482
+ Xt.set(t, r);
2483
+ let i = document.createDocumentFragment();
2484
+ for (let e = 0; e < n.length; e++) {
2485
+ e > 0 && i.appendChild(document.createTextNode("\n"));
2486
+ for (let t of n[e]) {
2487
+ if (Gt(t)) {
2488
+ i.appendChild(document.createTextNode(t.text));
2489
+ continue;
2490
+ }
2491
+ let e = document.createElement("span");
2492
+ Wt(t, e.style), e.textContent = t.text, i.appendChild(e);
2493
+ }
2494
+ }
2495
+ t.replaceChildren(i);
2496
+ }
2497
+ function Qt(e) {
2498
+ let t = [];
2499
+ for (let n of e) {
2500
+ for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "");
2501
+ t.push("\n");
1525
2502
  }
2503
+ return t.join("");
1526
2504
  }
1527
2505
  //#endregion
1528
2506
  //#region src/render.ts
1529
- function Xe(e, t) {
1530
- let n = [], r = /* @__PURE__ */ new Set();
1531
- Ze(e, 0, 0, n, !0, r), et(t, n);
1532
- for (let t of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!r.has(t)) {
1533
- t.removeAttribute("data-mw-inline-inset");
1534
- let e = t.style;
2507
+ function $t(e) {
2508
+ let t = /* @__PURE__ */ new Set();
2509
+ tn(e, !0, t);
2510
+ for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
2511
+ n.removeAttribute("data-mw-inline-inset");
2512
+ let e = n.style;
1535
2513
  for (let t of [
1536
2514
  "--mw-it",
1537
2515
  "--mw-ir",
@@ -1540,131 +2518,227 @@ function Xe(e, t) {
1540
2518
  ]) e.removeProperty(t);
1541
2519
  }
1542
2520
  }
1543
- function Ze(e, t, n, r, i, a) {
1544
- let o = t + e.localRect.x, s = n + e.localRect.y;
1545
- if (e.inlineElements) for (let { element: t, tracking: n, padLeft: r, padRight: i, insets: o } of e.inlineElements) {
2521
+ function Z(e, t, n) {
2522
+ e.style.getPropertyValue(t) !== n && e.style.setProperty(t, n);
2523
+ }
2524
+ function en(e, t) {
2525
+ e.style.getPropertyValue(t) !== "" && e.style.removeProperty(t);
2526
+ }
2527
+ function Q(e, t, n) {
2528
+ e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
2529
+ }
2530
+ function tn(e, t, i) {
2531
+ if (e.inlineElements) for (let { element: t, tracking: n, padLeft: r, padRight: a, insets: o } of e.inlineElements) {
1546
2532
  let e = t;
1547
- e.style.setProperty("--mw-ls", String(n)), r > 0 ? e.style.setProperty("--mw-ipl", String(r)) : e.style.removeProperty("--mw-ipl"), i > 0 ? e.style.setProperty("--mw-ipr", String(i)) : e.style.removeProperty("--mw-ipr"), o && (a.add(t), Qe(e, o));
2533
+ Z(e, "--mw-ls", String(n)), r > 0 ? Z(e, "--mw-ipl", String(r)) : en(e, "--mw-ipl"), a > 0 ? Z(e, "--mw-ipr", String(a)) : en(e, "--mw-ipr"), o && (i.add(t), nn(e, o));
2534
+ }
2535
+ if (t || rn(e), !e.tableHidden) for (let t of r(e)) {
2536
+ let r = t.source;
2537
+ t.style.zIndex !== null && n(t, e) && !t.inlineBox ? Z(r, "--mw-z", String(t.style.zIndex)) : en(r, "--mw-z"), tn(t, !1, i);
1548
2538
  }
1549
- i || $e(e), Je(e.style, {
1550
- x: o,
1551
- y: s,
1552
- width: e.localRect.width,
1553
- height: e.localRect.height
1554
- }, r);
1555
- for (let t of e.children) Ze(t, o, s, r, !1, a);
1556
2539
  }
1557
- function Qe(e, t) {
1558
- e.setAttribute("data-mw-inline-inset", "");
2540
+ function nn(e, t) {
2541
+ Q(e, "data-mw-inline-inset", !0);
1559
2542
  let n = (t, n) => {
1560
- n === null ? e.style.removeProperty(t) : e.style.setProperty(t, String(n));
2543
+ n === null ? en(e, t) : Z(e, t, String(n));
1561
2544
  };
1562
2545
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
1563
2546
  }
1564
- function $e(e) {
2547
+ function rn(e) {
1565
2548
  let t = e.source, n = e.localRect, r = e.resolvedPadding, { border: i, textAlignBlocked: a, overflow: o, whiteSpace: s, tracking: c, lineGap: l } = e.style;
1566
- t.setAttribute(e.inlineBox ? "data-mw-inline-box" : "data-mw-laid-out", ""), t.removeAttribute(e.inlineBox ? "data-mw-laid-out" : "data-mw-inline-box"), t.style.setProperty("--mw-ls", String(c)), t.style.setProperty("--mw-lh", String(l + 1)), t.style.setProperty("--mw-lhs", String(-l / 2)), s === "normal" ? t.removeAttribute("data-mw-nowrap") : t.setAttribute("data-mw-nowrap", ""), s === "pre" ? t.setAttribute("data-mw-pre", "") : t.removeAttribute("data-mw-pre"), t.style.setProperty("--mw-x", String(n.x)), t.style.setProperty("--mw-y", String(n.y)), t.style.setProperty("--mw-w", String(n.width)), t.style.setProperty("--mw-h", String(n.height)), o === "clip" ? t.setAttribute("data-mw-clip", "") : t.removeAttribute("data-mw-clip"), t.style.setProperty("--mw-pt", String(r.top)), t.style.setProperty("--mw-pr", String(r.right)), t.style.setProperty("--mw-pb", String(r.bottom)), t.style.setProperty("--mw-pl", String(r.left)), t.style.setProperty("--mw-bt", String(i.top)), t.style.setProperty("--mw-br", String(i.right)), t.style.setProperty("--mw-bb", String(i.bottom)), t.style.setProperty("--mw-bl", String(i.left)), a ? t.setAttribute("data-mw-text-align-blocked", "") : t.removeAttribute("data-mw-text-align-blocked"), e.droppedText ? t.setAttribute("data-mw-dropped-text", "") : t.removeAttribute("data-mw-dropped-text");
1567
- }
1568
- function et(e, t) {
1569
- e.replaceChildren();
1570
- for (let n of t) for (let t = 0; t < n.length; t++) {
1571
- let r = document.createElement("span");
1572
- r.setAttribute("aria-hidden", "true"), r.style.position = "absolute", r.style.left = `calc(${n.x + t} * var(--mw-cw))`, r.style.top = `calc(${n.y} * var(--mw-ch))`, r.style.font = "inherit", r.style.lineHeight = "inherit", r.style.whiteSpace = "pre", r.style.pointerEvents = "none", r.style.userSelect = "none", n.color && (r.style.color = n.color), r.textContent = n.glyph, e.appendChild(r);
1573
- }
2549
+ Q(t, e.inlineBox ? "data-mw-inline-box" : "data-mw-laid-out", !0), Q(t, e.inlineBox ? "data-mw-laid-out" : "data-mw-inline-box", !1), Q(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), Z(t, "--mw-ls", String(c)), Z(t, "--mw-lh", String(l + 1)), Z(t, "--mw-lhs", String(-l / 2)), Q(t, "data-mw-nowrap", s !== "normal"), Q(t, "data-mw-pre", s === "pre"), Z(t, "--mw-x", String(n.x)), Z(t, "--mw-y", String(n.y)), Z(t, "--mw-w", String(n.width)), Z(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o === "clip"), Z(t, "--mw-pt", String(r.top)), Z(t, "--mw-pr", String(r.right)), Z(t, "--mw-pb", String(r.bottom)), Z(t, "--mw-pl", String(r.left)), Z(t, "--mw-bt", String(i.top)), Z(t, "--mw-br", String(i.right)), Z(t, "--mw-bb", String(i.bottom)), Z(t, "--mw-bl", String(i.left)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
1574
2550
  }
1575
2551
  //#endregion
1576
2552
  //#region src/style.ts
1577
- function tt(e, t, n) {
1578
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = it(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style, c = r.display, l = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "none" ? "none" : "block", u = { kind: "none" }, d = { kind: "none" }, f = [N()], p = [N()], m = {
2553
+ function an(e, t, n) {
2554
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = vn(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
2555
+ pn(e, o, s);
2556
+ let c = r.display || un[e.tagName] || "", l = dn[c] ?? "none", u = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || ln(r) ? "none" : "block", d = { kind: "none" }, m = { kind: "none" }, h = [B()], g = [B()], _ = {
1579
2557
  direction: "row",
1580
2558
  dense: !1
1581
- }, h = null;
1582
- if (l === "grid") {
1583
- if (a) u = vt(a.get("grid-template-columns")?.toString() ?? "", t), d = vt(a.get("grid-template-rows")?.toString() ?? "", t);
2559
+ }, v = null;
2560
+ if (u === "grid") {
2561
+ if (a) d = In(a.get("grid-template-columns")?.toString() ?? "", t), m = In(a.get("grid-template-rows")?.toString() ?? "", t);
1584
2562
  else {
1585
2563
  e.setAttribute("data-mw-degrid", "");
1586
2564
  try {
1587
- u = vt(r.getPropertyValue("grid-template-columns"), t), d = vt(r.getPropertyValue("grid-template-rows"), t);
2565
+ d = In(r.getPropertyValue("grid-template-columns"), t), m = In(r.getPropertyValue("grid-template-rows"), t);
1588
2566
  } finally {
1589
2567
  e.removeAttribute("data-mw-degrid");
1590
2568
  }
1591
2569
  }
1592
- f = St(r.getPropertyValue("grid-auto-columns"), t), p = St(r.getPropertyValue("grid-auto-rows"), t), m = Ot(r.getPropertyValue("grid-auto-flow")), h = xt(r.getPropertyValue("grid-template-areas"));
1593
- }
1594
- return {
1595
- display: l,
2570
+ h = Bn(r.getPropertyValue("grid-auto-columns"), t), g = Bn(r.getPropertyValue("grid-auto-rows"), t), _ = Kn(r.getPropertyValue("grid-auto-flow")), v = zn(r.getPropertyValue("grid-template-areas"));
2571
+ }
2572
+ let y = "auto", b = !1, x = 0, S = 0;
2573
+ if (u === "table" && (y = r.tableLayout === "fixed" ? "fixed" : "auto", b = r.borderCollapse === "collapse", !b)) {
2574
+ let e = r.borderSpacing.split(" ");
2575
+ x = p(parseFloat(e[0] ?? "") || 0, t), S = p(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
2576
+ }
2577
+ let C = {
2578
+ display: u,
2579
+ tableRole: l,
2580
+ tableLayout: y,
2581
+ borderCollapse: b,
2582
+ borderSpacingX: x,
2583
+ borderSpacingY: S,
2584
+ captionSide: r.captionSide === "bottom" ? "bottom" : "top",
2585
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? fn(e, r) : "start",
1596
2586
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
1597
2587
  flexReverse: r.flexDirection.endsWith("-reverse"),
1598
2588
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
1599
2589
  wrapReverse: r.flexWrap === "wrap-reverse",
1600
2590
  flexGrow: Number(r.flexGrow) || 0,
1601
2591
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
1602
- flexBasis: gt(r.flexBasis, t),
2592
+ flexBasis: Pn(r.flexBasis, t),
1603
2593
  order: Number(r.order) || 0,
1604
- justifyContent: at(r.justifyContent),
1605
- alignContent: at(r.alignContent),
1606
- alignItems: ot(r.alignItems),
1607
- alignSelf: st(r.alignSelf),
1608
- justifyItems: ot(r.justifyItems),
1609
- justifySelf: st(r.justifySelf),
1610
- gridTemplateColumns: u,
1611
- gridTemplateRows: d,
1612
- gridAutoColumns: f,
1613
- gridAutoRows: p,
1614
- gridAutoFlow: m,
1615
- gridTemplateAreas: h,
1616
- gridColumnStart: Dt(r.getPropertyValue("grid-column-start")),
1617
- gridColumnEnd: Dt(r.getPropertyValue("grid-column-end")),
1618
- gridRowStart: Dt(r.getPropertyValue("grid-row-start")),
1619
- gridRowEnd: Dt(r.getPropertyValue("grid-row-end")),
1620
- width: ht(a, r.width, "width", t, o, s),
1621
- height: ht(a, r.height, "height", t, o, s),
1622
- minWidth: mt(r.minWidth, t) ?? "auto",
1623
- minHeight: mt(r.minHeight, t) ?? "auto",
1624
- maxWidth: mt(r.maxWidth, t),
1625
- maxHeight: mt(r.maxHeight, t),
1626
- padding: At(r, t),
1627
- margin: ct(r, a, o, t),
1628
- position: dt(r.position),
1629
- insets: ft(r, a, o, s, t),
2594
+ justifyContent: yn(r.justifyContent),
2595
+ alignContent: yn(r.alignContent),
2596
+ alignItems: bn(r.alignItems),
2597
+ alignSelf: xn(r.alignSelf),
2598
+ justifyItems: bn(r.justifyItems),
2599
+ justifySelf: xn(r.justifySelf),
2600
+ gridTemplateColumns: d,
2601
+ gridTemplateRows: m,
2602
+ gridAutoColumns: h,
2603
+ gridAutoRows: g,
2604
+ gridAutoFlow: _,
2605
+ gridTemplateAreas: v,
2606
+ gridColumnStart: Gn(r.getPropertyValue("grid-column-start")),
2607
+ gridColumnEnd: Gn(r.getPropertyValue("grid-column-end")),
2608
+ gridRowStart: Gn(r.getPropertyValue("grid-row-start")),
2609
+ gridRowEnd: Gn(r.getPropertyValue("grid-row-end")),
2610
+ width: kn(a, r.width, "width", t, o, s, n),
2611
+ height: kn(a, r.height, "height", t, o, s, n),
2612
+ minWidth: Nn(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? On(r.minWidth, t) ?? "auto",
2613
+ minHeight: Nn(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? On(r.minHeight, t) ?? "auto",
2614
+ maxWidth: Nn(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? On(r.maxWidth, t),
2615
+ maxHeight: Nn(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? On(r.maxHeight, t),
2616
+ padding: Jn(r, t),
2617
+ margin: Sn(r, a, o, s, t),
2618
+ position: Tn(r.position),
2619
+ insets: En(r, a, o, s, t),
1630
2620
  gapX: $(r.columnGap === "normal" ? "0px" : r.columnGap, t),
1631
2621
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
1632
- border: jt(r),
2622
+ border: Yn(r),
1633
2623
  borderStyle: {
1634
- top: pt(r.borderTopStyle),
1635
- right: pt(r.borderRightStyle),
1636
- bottom: pt(r.borderBottomStyle),
1637
- left: pt(r.borderLeftStyle)
2624
+ top: Dn(r.borderTopStyle),
2625
+ right: Dn(r.borderRightStyle),
2626
+ bottom: Dn(r.borderBottomStyle),
2627
+ left: Dn(r.borderLeftStyle)
1638
2628
  },
1639
- overflow: nt(r.overflow) || nt(r.overflowX) || nt(r.overflowY) ? "clip" : "visible",
2629
+ overflow: cn(r.overflow) || cn(r.overflowX) || cn(r.overflowY) ? "clip" : "visible",
1640
2630
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
1641
2631
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
1642
- lineGap: ut(r.lineHeight, n?.height ?? i),
1643
- tracking: lt(r.letterSpacing, i, n?.letterSpacing ?? 0),
2632
+ lineGap: wn(r.lineHeight, i),
2633
+ tracking: Cn(r.letterSpacing, i, n?.letterSpacing ?? 0),
1644
2634
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
1645
2635
  color: r.color,
1646
- backgroundColor: r.backgroundColor === "rgba(0, 0, 0, 0)" ? void 0 : r.backgroundColor,
2636
+ fontWeight: r.fontWeight,
2637
+ fontStyle: r.fontStyle,
2638
+ textDecorationLine: r.textDecorationLine,
2639
+ backgroundColor: sn(r.backgroundColor) ? void 0 : r.backgroundColor,
2640
+ backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
1647
2641
  borderColor: {
1648
2642
  top: r.borderTopColor,
1649
2643
  right: r.borderRightColor,
1650
2644
  bottom: r.borderBottomColor,
1651
2645
  left: r.borderLeftColor
1652
2646
  },
1653
- textAlignBlocked: rt(o, s)
2647
+ textAlignBlocked: gn(e, r),
2648
+ textAlign: _n(e, r),
2649
+ zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
2650
+ latticeBorder: null,
2651
+ ruleX: u === "flex" || u === "grid" ? hn(r, "x") : null,
2652
+ ruleY: u === "flex" || u === "grid" ? hn(r, "y") : null,
2653
+ ruleBreak: mn(r, "--mw-rule-break", ["none", "intersection"], "normal"),
2654
+ ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, f(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
2655
+ ruleVisibilityItems: mn(r, "--mw-rule-visibility-items", [
2656
+ "all",
2657
+ "around",
2658
+ "between"
2659
+ ], "normal")
1654
2660
  };
2661
+ return on(C, r), C;
2662
+ }
2663
+ function on(e, t) {
2664
+ 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 = {
2665
+ width: e.border,
2666
+ style: e.borderStyle,
2667
+ color: e.borderColor,
2668
+ hidden: {
2669
+ top: t.borderTopStyle === "hidden",
2670
+ right: t.borderRightStyle === "hidden",
2671
+ bottom: t.borderBottomStyle === "hidden",
2672
+ left: t.borderLeftStyle === "hidden"
2673
+ }
2674
+ }, e.border = z(), e.display === "table" && (e.padding = z()));
1655
2675
  }
1656
- function nt(e) {
2676
+ function sn(e) {
2677
+ if (!e) return !0;
2678
+ let t = e.trim().toLowerCase();
2679
+ return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
2680
+ }
2681
+ function cn(e) {
1657
2682
  return e === "hidden" || e === "clip";
1658
2683
  }
1659
- function rt(e, t) {
1660
- if (/(?:^|[\s:.[!])text-(?:center|justify)/.test(e)) return !0;
1661
- let n = t.textAlign;
1662
- return n === "center" || n === "justify";
2684
+ function ln(e) {
2685
+ if (e.position !== "absolute" && e.position !== "fixed") return !1;
2686
+ let t = e.clip.replace(/\s/g, "");
2687
+ return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (cn(e.overflow) || cn(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
2688
+ }
2689
+ var un = {
2690
+ TABLE: "table",
2691
+ THEAD: "table-header-group",
2692
+ TBODY: "table-row-group",
2693
+ TFOOT: "table-footer-group",
2694
+ TR: "table-row",
2695
+ TD: "table-cell",
2696
+ TH: "table-cell",
2697
+ CAPTION: "table-caption",
2698
+ COL: "table-column",
2699
+ COLGROUP: "table-column-group"
2700
+ }, dn = {
2701
+ "table-header-group": "header-group",
2702
+ "table-row-group": "row-group",
2703
+ "table-footer-group": "footer-group",
2704
+ "table-row": "row",
2705
+ "table-cell": "cell",
2706
+ "table-caption": "caption",
2707
+ "table-column": "column",
2708
+ "table-column-group": "column-group"
2709
+ };
2710
+ function fn(e, t) {
2711
+ let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
2712
+ return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
2713
+ }
2714
+ function pn(e, t, n) {
2715
+ (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && Ue(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
2716
+ }
2717
+ function mn(e, t, n, r) {
2718
+ let i = e.getPropertyValue(t).trim();
2719
+ return n.includes(i) ? i : r;
2720
+ }
2721
+ function hn(e, t) {
2722
+ let n = f(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
2723
+ if (n <= 0) return null;
2724
+ let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
2725
+ return {
2726
+ width: n,
2727
+ style: Dn(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
2728
+ color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
2729
+ };
1663
2730
  }
1664
- function it(e) {
2731
+ function gn(e, t) {
2732
+ return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
2733
+ }
2734
+ function _n(e, t) {
2735
+ let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
2736
+ return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
2737
+ }
2738
+ function vn(e) {
1665
2739
  return typeof e.computedStyleMap == "function";
1666
2740
  }
1667
- function at(e) {
2741
+ function yn(e) {
1668
2742
  switch (e) {
1669
2743
  case "center": return "center";
1670
2744
  case "flex-end":
@@ -1679,7 +2753,7 @@ function at(e) {
1679
2753
  default: return "start";
1680
2754
  }
1681
2755
  }
1682
- function ot(e) {
2756
+ function bn(e) {
1683
2757
  switch (e) {
1684
2758
  case "center": return "center";
1685
2759
  case "flex-end":
@@ -1690,43 +2764,43 @@ function ot(e) {
1690
2764
  default: return "start";
1691
2765
  }
1692
2766
  }
1693
- function st(e) {
1694
- return e === "auto" || e === "" || e === "normal" ? "auto" : ot(e);
2767
+ function xn(e) {
2768
+ return e === "auto" || e === "" || e === "normal" ? "auto" : bn(e);
1695
2769
  }
1696
- function ct(e, t, n, r) {
1697
- let i = (i, a, o) => {
2770
+ function Sn(e, t, n, r, i) {
2771
+ let a = (a, o, s) => {
1698
2772
  if (t) {
1699
- let e = t.get(i)?.toString().trim();
1700
- if (e === "auto" || t.get(a)?.toString().trim() === "auto") return null;
2773
+ let e = t.get(a)?.toString().trim();
2774
+ if (e === "auto" || t.get(o)?.toString().trim() === "auto") return null;
1701
2775
  if (e?.endsWith("%")) {
1702
2776
  let t = parseFloat(e);
1703
2777
  if (Number.isFinite(t) && t !== 0) return { percent: t };
1704
2778
  }
1705
- } else if (o.test(n)) return null;
1706
- let s = e.getPropertyValue(i);
1707
- if (s === "auto") return null;
1708
- let c = $(s, r);
1709
- if (c !== 0) return c;
1710
- let l = e.getPropertyValue(a);
1711
- return l === "auto" ? null : $(l, r);
2779
+ } else if (s.test(n) || r.getPropertyValue(a) === "auto") return null;
2780
+ let c = e.getPropertyValue(a);
2781
+ if (c === "auto") return null;
2782
+ let l = $(c, i);
2783
+ if (l !== 0) return l;
2784
+ let u = e.getPropertyValue(o);
2785
+ return u === "auto" ? null : $(u, i);
1712
2786
  };
1713
2787
  return {
1714
- top: i("margin-top", "margin-block-start", /(?:^|[\s:.[!])(?:m|my|mt)-auto\b/),
1715
- right: i("margin-right", "margin-inline-end", /(?:^|[\s:.[!])(?:m|mx|mr|me)-auto\b/),
1716
- bottom: i("margin-bottom", "margin-block-end", /(?:^|[\s:.[!])(?:m|my|mb)-auto\b/),
1717
- left: i("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
2788
+ top: a("margin-top", "margin-block-start", /(?:^|[\s:.[!])(?:m|my|mt)-auto\b/),
2789
+ right: a("margin-right", "margin-inline-end", /(?:^|[\s:.[!])(?:m|mx|mr|me)-auto\b/),
2790
+ bottom: a("margin-bottom", "margin-block-end", /(?:^|[\s:.[!])(?:m|my|mb)-auto\b/),
2791
+ left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
1718
2792
  };
1719
2793
  }
1720
- function lt(e, t, n) {
2794
+ function Cn(e, t, n) {
1721
2795
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
1722
2796
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
1723
2797
  }
1724
- function ut(e, t) {
2798
+ function wn(e, t) {
1725
2799
  if (!e || e === "normal" || t <= 0) return 0;
1726
2800
  let n = parseFloat(e);
1727
2801
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
1728
2802
  }
1729
- function dt(e) {
2803
+ function Tn(e) {
1730
2804
  switch (e) {
1731
2805
  case "relative":
1732
2806
  case "absolute":
@@ -1735,7 +2809,7 @@ function dt(e) {
1735
2809
  default: return "static";
1736
2810
  }
1737
2811
  }
1738
- function ft(e, t, n, r, i) {
2812
+ function En(e, t, n, r, i) {
1739
2813
  let a = (a, o) => {
1740
2814
  if (t) {
1741
2815
  let e = t.get(a)?.toString().trim();
@@ -1754,7 +2828,7 @@ function ft(e, t, n, r, i) {
1754
2828
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
1755
2829
  };
1756
2830
  }
1757
- function pt(e) {
2831
+ function Dn(e) {
1758
2832
  switch (e) {
1759
2833
  case "double": return "double";
1760
2834
  case "dashed": return "dashed";
@@ -1762,80 +2836,147 @@ function pt(e) {
1762
2836
  default: return "solid";
1763
2837
  }
1764
2838
  }
1765
- function mt(e, n) {
2839
+ function On(e, t) {
1766
2840
  if (!e || e === "none" || e === "auto") return;
1767
2841
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
1768
2842
  if (e.endsWith("%")) {
1769
2843
  let t = parseFloat(e);
1770
2844
  return Number.isFinite(t) ? { percent: t } : void 0;
1771
2845
  }
1772
- let r = parseFloat(e);
1773
- return Number.isFinite(r) ? t(r, n) : void 0;
2846
+ let n = parseFloat(e);
2847
+ return Number.isFinite(n) ? p(n, t) : void 0;
1774
2848
  }
1775
- function $(e, n) {
2849
+ function $(e, t) {
1776
2850
  if (!e || e === "auto" || e === "none") return 0;
1777
2851
  if (e.endsWith("%")) {
1778
2852
  let t = parseFloat(e);
1779
2853
  return Number.isFinite(t) && t !== 0 ? { percent: t } : 0;
1780
2854
  }
1781
- let r = parseFloat(e);
1782
- return Number.isFinite(r) ? t(r, n) : 0;
2855
+ let n = parseFloat(e);
2856
+ return Number.isFinite(n) ? p(n, t) : 0;
1783
2857
  }
1784
- function ht(n, r, i, a, o, s) {
1785
- if (n) {
1786
- let r = n.get(i);
1787
- if (r == null) return;
1788
- let o = r.toString().trim();
1789
- if (o === "auto") return { kind: "auto" };
1790
- let s = _t(o);
1791
- if (s) return s;
1792
- if (o.endsWith("%")) return {
2858
+ function kn(e, t, n, r, i, a, o) {
2859
+ let s = An(n === "width" ? a.width : a.height);
2860
+ if (s !== null) return {
2861
+ kind: "cells",
2862
+ value: Mn(s, n, o, r)
2863
+ };
2864
+ let c = jn(i, n === "width" ? "w" : "h");
2865
+ if (c !== null) {
2866
+ let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
2867
+ if (a || !Number.isFinite(i)) return {
2868
+ kind: "cells",
2869
+ value: Mn(a ? i : c, n, o, r)
2870
+ };
2871
+ }
2872
+ if (e) {
2873
+ let t = e.get(n);
2874
+ if (t == null) return;
2875
+ let i = t.toString().trim();
2876
+ if (i === "auto") return { kind: "auto" };
2877
+ let a = Fn(i);
2878
+ if (a) return a;
2879
+ if (i.endsWith("%")) return {
1793
2880
  kind: "percent",
1794
- value: parseFloat(o)
2881
+ value: parseFloat(i)
1795
2882
  };
1796
- if (o.endsWith("px")) return {
2883
+ if (i.endsWith("px")) return {
1797
2884
  kind: "cells",
1798
- value: t(parseFloat(o), a)
2885
+ value: p(parseFloat(i), r)
1799
2886
  };
1800
- if (o.endsWith("rem")) return {
2887
+ if (i.endsWith("rem")) return {
1801
2888
  kind: "cells",
1802
- value: e(parseFloat(o) / .25)
2889
+ value: f(parseFloat(i) / .25)
2890
+ };
2891
+ let s = An(i);
2892
+ if (s !== null) return {
2893
+ kind: "cells",
2894
+ value: Mn(s, n, o, r)
1803
2895
  };
1804
2896
  }
1805
- let c = i === "width" ? s.width : s.height;
1806
- if (c) {
1807
- if (c === "auto") return { kind: "auto" };
1808
- let e = _t(c);
2897
+ let l = n === "width" ? a.width : a.height;
2898
+ if (l) {
2899
+ if (l === "auto") return { kind: "auto" };
2900
+ let e = Fn(l);
1809
2901
  if (e) return e;
1810
- if (c.endsWith("%")) return {
2902
+ if (l.endsWith("%")) return {
1811
2903
  kind: "percent",
1812
- value: parseFloat(c)
2904
+ value: parseFloat(l)
1813
2905
  };
1814
- let n = parseFloat(c);
1815
- if (Number.isFinite(n)) return {
2906
+ let t = parseFloat(l);
2907
+ if (Number.isFinite(t)) return {
1816
2908
  kind: "cells",
1817
- value: t(n, a)
2909
+ value: p(t, r)
1818
2910
  };
1819
2911
  }
1820
- let l = i === "width" ? "w" : "h";
1821
- if (RegExp(`(?:^|[\\s:.[!])${l}-min\\b`).test(o)) return { kind: "min-content" };
1822
- if (RegExp(`(?:^|[\\s:.[!])${l}-max\\b`).test(o)) return { kind: "max-content" };
1823
- if (RegExp(`(?:^|[\\s:.[!])${l}-fit\\b`).test(o)) return { kind: "fit-content" };
1824
- if (!kt(o, l) || r === "auto") return { kind: "auto" };
1825
- if (r.endsWith("%")) return {
2912
+ let u = n === "width" ? "w" : "h";
2913
+ if (RegExp(`(?:^|[\\s:.[!])${u}-min\\b`).test(i)) return { kind: "min-content" };
2914
+ if (RegExp(`(?:^|[\\s:.[!])${u}-max\\b`).test(i)) return { kind: "max-content" };
2915
+ if (RegExp(`(?:^|[\\s:.[!])${u}-fit\\b`).test(i)) return { kind: "fit-content" };
2916
+ let d = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+)/(\\d+)(?![\\w./])`).exec(i);
2917
+ if (d) return {
2918
+ kind: "percent",
2919
+ value: 100 * Number(d[1]) / Number(d[2])
2920
+ };
2921
+ if (RegExp(`(?:^|[\\s:.[!])${u}-full(?![\\w-])`).test(i)) return {
2922
+ kind: "percent",
2923
+ value: 100
2924
+ };
2925
+ let m = RegExp(`(?:^|[\\s:.[!])${u}-\\[(\\d+(?:\\.\\d+)?)%\\]`).exec(i);
2926
+ if (m) return {
2927
+ kind: "percent",
2928
+ value: Number(m[1])
2929
+ };
2930
+ let h = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
2931
+ if (h) return {
2932
+ kind: "cells",
2933
+ value: f(Number(h[1]))
2934
+ };
2935
+ if (!qn(i, u) || t === "auto") return { kind: "auto" };
2936
+ if (t.endsWith("%")) return {
1826
2937
  kind: "percent",
1827
- value: parseFloat(r)
2938
+ value: parseFloat(t)
1828
2939
  };
1829
- let u = parseFloat(r);
1830
- if (Number.isFinite(u)) return {
2940
+ let g = parseFloat(t);
2941
+ if (Number.isFinite(g)) return {
1831
2942
  kind: "cells",
1832
- value: t(u, a)
2943
+ value: p(g, r)
1833
2944
  };
1834
2945
  }
1835
- function gt(e, n) {
2946
+ function An(e) {
2947
+ let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
2948
+ if (!t || typeof window > "u") return null;
2949
+ let n = parseFloat(t[1]);
2950
+ if (!Number.isFinite(n)) return null;
2951
+ 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;
2952
+ return n / 100 * o;
2953
+ }
2954
+ function jn(e, t) {
2955
+ if (typeof window > "u") return null;
2956
+ let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
2957
+ if (n) {
2958
+ let e = n[1];
2959
+ return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
2960
+ }
2961
+ let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
2962
+ return r ? An(r[1]) : null;
2963
+ }
2964
+ function Mn(e, t, n, r) {
2965
+ let i = t === "width" ? n?.width : n?.height;
2966
+ return i && i > 0 ? Math.max(0, Math.floor(e / i)) : p(e, r);
2967
+ }
2968
+ function Nn(e, t, n, r, i, a, o, s) {
2969
+ let c = t.endsWith("width") ? "width" : "height", l = An(a.getPropertyValue(t)) ?? An(e?.get(t)?.toString().trim() ?? "");
2970
+ if (l !== null) return Mn(l, c, o, s);
2971
+ let u = jn(r, i);
2972
+ if (u === null) return;
2973
+ let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
2974
+ if (!(!f && Number.isFinite(d))) return Mn(f ? d : u, c, o, s);
2975
+ }
2976
+ function Pn(e, t) {
1836
2977
  if (!e || e === "auto" || e === "content") return;
1837
- let r = _t(e);
1838
- if (r) return r;
2978
+ let n = Fn(e);
2979
+ if (n) return n;
1839
2980
  if (e.endsWith("%")) {
1840
2981
  let t = parseFloat(e);
1841
2982
  return Number.isFinite(t) ? {
@@ -1843,33 +2984,33 @@ function gt(e, n) {
1843
2984
  value: t
1844
2985
  } : void 0;
1845
2986
  }
1846
- let i = parseFloat(e);
1847
- return Number.isFinite(i) ? {
2987
+ let r = parseFloat(e);
2988
+ return Number.isFinite(r) ? {
1848
2989
  kind: "cells",
1849
- value: t(i, n)
2990
+ value: p(r, t)
1850
2991
  } : void 0;
1851
2992
  }
1852
- function _t(e) {
2993
+ function Fn(e) {
1853
2994
  if (e === "min-content") return { kind: "min-content" };
1854
2995
  if (e === "max-content") return { kind: "max-content" };
1855
2996
  if (e === "fit-content") return { kind: "fit-content" };
1856
2997
  }
1857
- function vt(e, t) {
2998
+ function In(e, t) {
1858
2999
  let n = e.trim();
1859
3000
  if (!n || n === "none") return { kind: "none" };
1860
3001
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
1861
3002
  let r = [], i = [], a = [], o = (e) => {
1862
3003
  i.push(a), a = [], r.push(e);
1863
3004
  }, s;
1864
- for (let e of Et(n)) {
1865
- let n = bt(e);
3005
+ for (let e of Wn(n)) {
3006
+ let n = Rn(e);
1866
3007
  if (n) {
1867
3008
  a.push(...n);
1868
3009
  continue;
1869
3010
  }
1870
3011
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
1871
3012
  if (i) {
1872
- let e = yt(i[2].trim(), t);
3013
+ let e = Ln(i[2].trim(), t);
1873
3014
  if (e.tracks.length === 0) continue;
1874
3015
  let n = i[1];
1875
3016
  if (n === "auto-fill" || n === "auto-fit") {
@@ -1887,7 +3028,7 @@ function vt(e, t) {
1887
3028
  }
1888
3029
  continue;
1889
3030
  }
1890
- o(Ct(e, t));
3031
+ o(Vn(e, t));
1891
3032
  }
1892
3033
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
1893
3034
  let c = {
@@ -1896,26 +3037,26 @@ function vt(e, t) {
1896
3037
  };
1897
3038
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
1898
3039
  }
1899
- function yt(e, t) {
3040
+ function Ln(e, t) {
1900
3041
  let n = [], r = [], i = [];
1901
- for (let a of Et(e)) {
1902
- let e = bt(a);
3042
+ for (let a of Wn(e)) {
3043
+ let e = Rn(a);
1903
3044
  if (e) {
1904
3045
  i.push(...e);
1905
3046
  continue;
1906
3047
  }
1907
- r.push(i), i = [], n.push(Ct(a, t));
3048
+ r.push(i), i = [], n.push(Vn(a, t));
1908
3049
  }
1909
3050
  return r.push(i), {
1910
3051
  tracks: n,
1911
3052
  lineNames: r
1912
3053
  };
1913
3054
  }
1914
- function bt(e) {
3055
+ function Rn(e) {
1915
3056
  let t = e.match(/^\[(.*)\]$/s);
1916
3057
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
1917
3058
  }
1918
- function xt(e) {
3059
+ function zn(e) {
1919
3060
  let t = [];
1920
3061
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
1921
3062
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -1945,23 +3086,23 @@ function xt(e) {
1945
3086
  areas: r
1946
3087
  };
1947
3088
  }
1948
- function St(e, t) {
1949
- let n = Et(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Ct(e, t));
1950
- return n.length > 0 ? n : [N()];
3089
+ function Bn(e, t) {
3090
+ let n = Wn(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Vn(e, t));
3091
+ return n.length > 0 ? n : [B()];
1951
3092
  }
1952
- function Ct(e, t) {
3093
+ function Vn(e, t) {
1953
3094
  let n = e.match(/^minmax\((.*)\)$/s);
1954
3095
  if (n) {
1955
- let e = Tt(n[1]).map((e) => e.trim());
3096
+ let e = Un(n[1]).map((e) => e.trim());
1956
3097
  return e.length === 2 ? {
1957
- min: wt(e[0], t),
1958
- max: wt(e[1], t)
3098
+ min: Hn(e[0], t),
3099
+ max: Hn(e[1], t)
1959
3100
  } : {
1960
3101
  min: { kind: "auto" },
1961
3102
  max: { kind: "auto" }
1962
3103
  };
1963
3104
  }
1964
- let r = wt(e, t);
3105
+ let r = Hn(e, t);
1965
3106
  return r.kind === "fr" ? {
1966
3107
  min: { kind: "auto" },
1967
3108
  max: r
@@ -1970,40 +3111,40 @@ function Ct(e, t) {
1970
3111
  max: r
1971
3112
  };
1972
3113
  }
1973
- function wt(n, r) {
1974
- if (n === "auto" || n.startsWith("fit-content")) return { kind: "auto" };
1975
- if (n === "min-content") return { kind: "min-content" };
1976
- if (n === "max-content") return { kind: "max-content" };
1977
- let i = n.match(/^(min|max)\((.*)\)$/s);
1978
- if (i) {
1979
- let e = Tt(i[2]).map((e) => wt(e.trim(), r)), t = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
1980
- return e.length > 0 && t ? {
3114
+ function Hn(e, t) {
3115
+ if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
3116
+ if (e === "min-content") return { kind: "min-content" };
3117
+ if (e === "max-content") return { kind: "max-content" };
3118
+ let n = e.match(/^(min|max)\((.*)\)$/s);
3119
+ if (n) {
3120
+ let e = Un(n[2]).map((e) => Hn(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
3121
+ return e.length > 0 && r ? {
1981
3122
  kind: "math",
1982
- fn: i[1],
3123
+ fn: n[1],
1983
3124
  args: e
1984
3125
  } : { kind: "auto" };
1985
3126
  }
1986
- if (n.endsWith("fr")) {
1987
- let e = parseFloat(n);
1988
- return Number.isFinite(e) && e >= 0 ? {
3127
+ if (e.endsWith("fr")) {
3128
+ let t = parseFloat(e);
3129
+ return Number.isFinite(t) && t >= 0 ? {
1989
3130
  kind: "fr",
1990
- value: e
3131
+ value: t
1991
3132
  } : { kind: "auto" };
1992
3133
  }
1993
- if (n.endsWith("%")) {
1994
- let e = parseFloat(n);
1995
- return Number.isFinite(e) ? {
3134
+ if (e.endsWith("%")) {
3135
+ let t = parseFloat(e);
3136
+ return Number.isFinite(t) ? {
1996
3137
  kind: "percent",
1997
- value: e
3138
+ value: t
1998
3139
  } : { kind: "auto" };
1999
3140
  }
2000
- let a = parseFloat(n);
2001
- return Number.isFinite(a) ? {
3141
+ let r = parseFloat(e);
3142
+ return Number.isFinite(r) ? {
2002
3143
  kind: "cells",
2003
- value: n.endsWith("rem") ? e(a / .25) : t(a, r)
3144
+ value: e.endsWith("rem") ? f(r / .25) : p(r, t)
2004
3145
  } : { kind: "auto" };
2005
3146
  }
2006
- function Tt(e) {
3147
+ function Un(e) {
2007
3148
  let t = [], n = 0, r = 0;
2008
3149
  for (let i = 0; i < e.length; i++) {
2009
3150
  let a = e[i];
@@ -2011,7 +3152,7 @@ function Tt(e) {
2011
3152
  }
2012
3153
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
2013
3154
  }
2014
- function Et(e) {
3155
+ function Wn(e) {
2015
3156
  let t = [], n = 0, r = -1;
2016
3157
  for (let i = 0; i < e.length; i++) {
2017
3158
  let a = e[i];
@@ -2019,7 +3160,7 @@ function Et(e) {
2019
3160
  }
2020
3161
  return r !== -1 && t.push(e.slice(r)), t;
2021
3162
  }
2022
- function Dt(e) {
3163
+ function Gn(e) {
2023
3164
  let t = e.trim();
2024
3165
  if (!t || t === "auto") return { kind: "auto" };
2025
3166
  let n = !1, r, i;
@@ -2047,16 +3188,16 @@ function Dt(e) {
2047
3188
  nth: r
2048
3189
  };
2049
3190
  }
2050
- function Ot(e) {
3191
+ function Kn(e) {
2051
3192
  return {
2052
3193
  direction: e.includes("column") ? "column" : "row",
2053
3194
  dense: e.includes("dense")
2054
3195
  };
2055
3196
  }
2056
- function kt(e, t) {
3197
+ function qn(e, t) {
2057
3198
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
2058
3199
  }
2059
- function At(e, t) {
3200
+ function Jn(e, t) {
2060
3201
  return {
2061
3202
  top: $(e.getPropertyValue("padding-top"), t),
2062
3203
  right: $(e.getPropertyValue("padding-right"), t),
@@ -2064,69 +3205,90 @@ function At(e, t) {
2064
3205
  left: $(e.getPropertyValue("padding-left"), t)
2065
3206
  };
2066
3207
  }
2067
- function jt(t) {
2068
- let n = (n, r) => t.getPropertyValue(r) === "none" ? 0 : e(parseFloat(t.getPropertyValue(n)) || 0);
3208
+ function Yn(e) {
3209
+ let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : f(parseFloat(e.getPropertyValue(t)) || 0);
2069
3210
  return {
2070
- top: n("border-top-width", "border-top-style"),
2071
- right: n("border-right-width", "border-right-style"),
2072
- bottom: n("border-bottom-width", "border-bottom-style"),
2073
- left: n("border-left-width", "border-left-style")
3211
+ top: t("border-top-width", "border-top-style"),
3212
+ right: t("border-right-width", "border-right-style"),
3213
+ bottom: t("border-bottom-width", "border-bottom-style"),
3214
+ left: t("border-left-width", "border-left-style")
2074
3215
  };
2075
3216
  }
2076
3217
  //#endregion
2077
3218
  //#region src/tree.ts
2078
- function Mt(e, t, n) {
2079
- let r = tt(e, t, n);
2080
- if (r.display === "none") return null;
2081
- let i = Array.from(e.children), a = i.map(Lt);
2082
- if (!a.includes("block")) {
2083
- let o = Rt(e, r.tracking, {
3219
+ function Xn(e, t, n, r) {
3220
+ let i = an(e, t, n);
3221
+ if (i.display === "none") return null;
3222
+ let a = Array.from(e.children), o = a.map(tr), s = e.tagName, c = fr(s);
3223
+ if (!o.includes("block") || c) {
3224
+ let l = nr(e, i.tracking, {
2084
3225
  rootFontSizePx: t,
2085
3226
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
2086
3227
  cellMetrics: n,
2087
- preserve: r.whiteSpace === "pre",
2088
- tabSize: r.tabSize
2089
- }), s = o.chars.join("");
2090
- if (o.boxes.length > 0) {
2091
- let e = Le();
2092
- d(o.chars, (t, n) => {
2093
- o.advances[t] = Math.max(1, X(o.boxes[n], e));
3228
+ textareaWidths: r,
3229
+ preserve: i.whiteSpace === "pre",
3230
+ tabSize: i.tabSize
3231
+ }), u = l.chars.join("");
3232
+ if (l.boxes.length > 0) {
3233
+ let e = Et();
3234
+ E(l.chars, (t, n) => {
3235
+ l.advances[t] = Math.max(1, Y(l.boxes[n], e));
2094
3236
  });
2095
3237
  }
2096
- let c = Ut(s, o.advances, r.tracking), l = s.length > 0 ? Wt(s) : 0, u = [...o.boxes];
2097
- for (let e = 0; e < i.length; e++) {
2098
- if (a[e] !== "out-of-flow") continue;
2099
- let r = Mt(i[e], t, n);
2100
- r && u.push(r);
3238
+ let d = sr(u, l.advances, i.tracking);
3239
+ if (c && d === 0) {
3240
+ if (s === "INPUT") d = Number(e.size) || 20;
3241
+ else if (s === "TEXTAREA") d = Number(e.cols) || 20;
3242
+ else {
3243
+ 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);
3244
+ d = Math.max(1, ...r.map((e) => e.trim().length));
3245
+ }
2101
3246
  }
2102
- let f = {
3247
+ let f = u.length > 0 ? cr(u) : 0, p;
3248
+ if (s === "TEXTAREA") {
3249
+ 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);
3250
+ p = l + Math.max(0, l - 1) * i.lineGap;
3251
+ } else p = c ? Math.max(1, f) : f;
3252
+ let m = /* @__PURE__ */ new Map(), h = [];
3253
+ for (let t of l.boxes) t.source.parentElement === e ? m.set(t.source, t) : h.push(t);
3254
+ let g = [];
3255
+ for (let e = 0; e < a.length; e++) {
3256
+ let i = a[e], s = m.get(i);
3257
+ if (s) g.push(s);
3258
+ else if (o[e] === "out-of-flow") {
3259
+ let e = Xn(i, t, n, r);
3260
+ e && g.push(e);
3261
+ }
3262
+ }
3263
+ g.push(...h);
3264
+ let _ = {
2103
3265
  source: e,
2104
- style: r,
2105
- children: u,
2106
- text: s,
2107
- intrinsicWidth: c,
2108
- intrinsicHeight: l,
3266
+ style: i,
3267
+ children: g,
3268
+ text: u,
3269
+ intrinsicWidth: d,
3270
+ intrinsicHeight: p,
2109
3271
  localRect: {
2110
3272
  x: 0,
2111
3273
  y: 0,
2112
- width: c,
2113
- height: l
3274
+ width: d,
3275
+ height: p
2114
3276
  },
2115
3277
  unclampedHeight: 0,
2116
- resolvedPadding: M()
3278
+ resolvedPadding: z()
2117
3279
  };
2118
- return (o.advances.some((e) => e !== 1) || o.boxes.length > 0) && (f.advances = o.advances), o.inlineElements.length > 0 && (f.inlineElements = o.inlineElements), f;
3280
+ 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)), _;
2119
3281
  }
2120
- let o = [];
2121
- for (let e = 0; e < i.length; e++) {
2122
- if (a[e] === "none") continue;
2123
- let r = Mt(i[e], t, n);
2124
- r && o.push(r);
3282
+ let l = [];
3283
+ for (let e = 0; e < a.length; e++) {
3284
+ if (o[e] === "none") continue;
3285
+ let i = Xn(a[e], t, n, r);
3286
+ i && l.push(i);
2125
3287
  }
2126
- let s = {
3288
+ let u = {
2127
3289
  source: e,
2128
- style: r,
2129
- children: o,
3290
+ style: i,
3291
+ children: l,
2130
3292
  text: "",
2131
3293
  intrinsicWidth: 0,
2132
3294
  intrinsicHeight: 0,
@@ -2137,198 +3299,294 @@ function Mt(e, t, n) {
2137
3299
  height: 0
2138
3300
  },
2139
3301
  unclampedHeight: 0,
2140
- resolvedPadding: M()
3302
+ resolvedPadding: z()
2141
3303
  };
2142
- return Jt(e, s), s;
3304
+ return pr(e, u), u;
2143
3305
  }
2144
- var Nt = /* @__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("."));
2145
- function Pt(e, t) {
2146
- return t || (Nt.has(e.tagName) ? "inline" : "block");
3306
+ var Zn = /* @__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("."));
3307
+ function Qn(e, t) {
3308
+ return t || (Zn.has(e.tagName) ? "inline" : "block");
2147
3309
  }
2148
- function Ft(e, t) {
2149
- let n = Pt(e, t);
3310
+ function $n(e, t) {
3311
+ let n = Qn(e, t);
2150
3312
  return n === "inline" || n === "contents";
2151
3313
  }
2152
- function It(e, t) {
2153
- let n = Pt(e, t);
3314
+ function er(e, t) {
3315
+ let n = Qn(e, t);
2154
3316
  return n.startsWith("inline") && n !== "inline";
2155
3317
  }
2156
- function Lt(e) {
3318
+ function tr(e) {
2157
3319
  let t = getComputedStyle(e);
2158
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : Ft(e, t.display) || It(e, t.display) ? "inline" : "block";
3320
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : $n(e, t.display) || er(e, t.display) ? "inline" : "block";
2159
3321
  }
2160
- function Rt(e, t, n) {
3322
+ function nr(e, t, n) {
2161
3323
  let r = {
2162
3324
  chars: [],
2163
3325
  advances: [],
3326
+ inlineIndex: [],
2164
3327
  inlineElements: [],
2165
3328
  boxes: []
2166
3329
  };
2167
- return zt(e, t, n, r), n.preserve ? (r.chars[r.chars.length - 1] === "\n" && (r.chars.pop(), r.advances.pop()), r) : Ht(r);
3330
+ return rr(e, t, n, r), n.preserve ? r : or(r);
2168
3331
  }
2169
- function zt(e, t, n, r) {
3332
+ function rr(e, t, n, r) {
2170
3333
  let i = () => {
2171
3334
  let e = 0;
2172
3335
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
2173
3336
  return e;
2174
3337
  };
2175
- for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
2176
- 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);
2177
- else if (e === " ") {
2178
- let e = (Math.floor(i() / n.tabSize) + 1) * n.tabSize;
2179
- for (let t = i(); t < e; t++) r.chars.push(" "), r.advances.push(1);
2180
- } else r.chars.push(e), r.advances.push(1 + t);
2181
- else for (let e of (a.textContent ?? "").replace(/[ \t\r\n\f]+/g, " ")) r.chars.push(e), r.advances.push(1 + t);
2182
- } else if (a.nodeType === Node.ELEMENT_NODE) {
2183
- let e = a;
2184
- if (e.tagName === "BR") {
2185
- r.chars.push("\n"), r.advances.push(0);
2186
- continue;
2187
- }
2188
- let t = getComputedStyle(e);
2189
- if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
2190
- if (It(e, t.display)) {
2191
- let t = Mt(e, n.rootFontSizePx, n.cellMetrics);
2192
- t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
2193
- continue;
2194
- }
2195
- if (!Ft(e, t.display)) {
2196
- qt(e);
2197
- continue;
3338
+ if (!fr(e.tagName)) {
3339
+ for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
3340
+ 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);
3341
+ else if (e === " ") {
3342
+ let e = (Math.floor(i() / n.tabSize) + 1) * n.tabSize;
3343
+ for (let t = i(); t < e; t++) r.chars.push(" "), r.advances.push(1);
3344
+ } else r.chars.push(e), r.advances.push(1 + t);
3345
+ else for (let e of (a.textContent ?? "").replace(/[ \t\r\n\f]+/g, " ")) r.chars.push(e), r.advances.push(1 + t);
3346
+ } else if (a.nodeType === Node.ELEMENT_NODE) {
3347
+ let e = a;
3348
+ if (e.tagName === "BR") {
3349
+ r.chars.push("\n"), r.advances.push(0);
3350
+ continue;
3351
+ }
3352
+ let t = getComputedStyle(e);
3353
+ if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
3354
+ if (er(e, t.display)) {
3355
+ let t = Xn(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
3356
+ t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
3357
+ continue;
3358
+ }
3359
+ if (!$n(e, t.display)) {
3360
+ lr(e);
3361
+ continue;
3362
+ }
3363
+ let i = Cn(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = ir(t.paddingLeft, n.rootFontSizePx), s = ir(t.paddingRight, n.rootFontSizePx);
3364
+ r.inlineElements.push({
3365
+ element: e,
3366
+ tracking: i,
3367
+ padLeft: o,
3368
+ padRight: s,
3369
+ insets: t.position === "static" ? null : ar(t, n.rootFontSizePx),
3370
+ color: t.color,
3371
+ backgroundColor: sn(t.backgroundColor) ? void 0 : t.backgroundColor,
3372
+ fontWeight: t.fontWeight,
3373
+ fontStyle: t.fontStyle,
3374
+ textDecorationLine: t.textDecorationLine
3375
+ });
3376
+ let c = r.inlineElements.length - 1;
3377
+ for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
3378
+ let l = r.chars.length;
3379
+ rr(e, i, n, r);
3380
+ for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
3381
+ for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
2198
3382
  }
2199
- let i = lt(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Bt(t.paddingLeft, n.rootFontSizePx), s = Bt(t.paddingRight, n.rootFontSizePx);
2200
- r.inlineElements.push({
2201
- element: e,
2202
- tracking: i,
2203
- padLeft: o,
2204
- padRight: s,
2205
- insets: t.position === "static" ? null : Vt(t, n.rootFontSizePx)
2206
- });
2207
- for (let e = 0; e < o; e++) r.chars.push("⁠"), r.advances.push(1);
2208
- zt(e, i, n, r);
2209
- for (let e = 0; e < s; e++) r.chars.push("⁠"), r.advances.push(1);
2210
3383
  }
2211
3384
  }
2212
- function Bt(e, n) {
3385
+ function ir(e, t) {
2213
3386
  if (!e || e.endsWith("%")) return 0;
2214
- let r = parseFloat(e);
2215
- return Number.isFinite(r) ? Math.max(0, t(r, n)) : 0;
3387
+ let n = parseFloat(e);
3388
+ return Number.isFinite(n) ? Math.max(0, p(n, t)) : 0;
2216
3389
  }
2217
- function Vt(e, n) {
2218
- let r = (e) => {
3390
+ function ar(e, t) {
3391
+ let n = (e) => {
2219
3392
  if (!e || e === "auto" || e.endsWith("%")) return null;
2220
- let r = parseFloat(e);
2221
- return Number.isFinite(r) ? t(r, n) : null;
3393
+ let n = parseFloat(e);
3394
+ return Number.isFinite(n) ? p(n, t) : null;
2222
3395
  };
2223
3396
  return {
2224
- top: r(e.top),
2225
- right: r(e.right),
2226
- bottom: r(e.bottom),
2227
- left: r(e.left)
3397
+ top: n(e.top),
3398
+ right: n(e.right),
3399
+ bottom: n(e.bottom),
3400
+ left: n(e.left)
2228
3401
  };
2229
3402
  }
2230
- function Ht(e) {
2231
- let t = [], n = [], r = () => {
3403
+ function or(e) {
3404
+ let t = [], n = [], r = [], i = () => {
2232
3405
  let e = t.length;
2233
3406
  for (; e > 0 && t[e - 1] !== "\n";) e--;
2234
3407
  return e;
2235
- }, i = () => {
2236
- for (; t.length > r() && t[t.length - 1] === " ";) t.pop(), n.pop();
3408
+ }, a = () => {
3409
+ for (; t.length > i() && t[t.length - 1] === " ";) t.pop(), n.pop(), r.pop();
2237
3410
  };
2238
- for (let r = 0; r < e.chars.length; r++) {
2239
- let a = e.chars[r];
2240
- if (a === " ") {
3411
+ for (let i = 0; i < e.chars.length; i++) {
3412
+ let o = e.chars[i];
3413
+ if (o === " ") {
2241
3414
  let e = t.length - 1;
2242
3415
  for (; e >= 0 && t[e] === "⁠";) e--;
2243
3416
  if (e < 0 || t[e] === "\n" || t[e] === " ") continue;
2244
- } else a === "\n" && i();
2245
- t.push(a), n.push(e.advances[r]);
3417
+ } else o === "\n" && a();
3418
+ t.push(o), n.push(e.advances[i]), r.push(e.inlineIndex[i] ?? -1);
2246
3419
  }
2247
- for (i(); t[0] === "\n";) t.shift(), n.shift();
2248
- for (; t[t.length - 1] === "\n";) t.pop(), n.pop();
2249
- return {
3420
+ return a(), {
2250
3421
  chars: t,
2251
3422
  advances: n,
3423
+ inlineIndex: r,
2252
3424
  inlineElements: e.inlineElements,
2253
3425
  boxes: e.boxes
2254
3426
  };
2255
3427
  }
2256
- function Ut(e, t, n) {
3428
+ function sr(e, t, n) {
2257
3429
  let r = 0, i = 0;
2258
- 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);
3430
+ 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);
2259
3431
  return r;
2260
3432
  }
2261
- function Wt(e) {
2262
- return e.split("\n").length;
3433
+ function cr(e) {
3434
+ return b(e).length;
2263
3435
  }
2264
- var Gt = /* @__PURE__ */ new WeakSet(), Kt = /* @__PURE__ */ new WeakSet();
2265
- function qt(e) {
2266
- Kt.has(e) || (Kt.add(e), console.warn("[monowind] 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.", e));
3436
+ function lr(e) {
3437
+ Ue(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.");
2267
3438
  }
2268
- function Jt(e, t) {
2269
- Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? "")) && (t.droppedText = !0, !Gt.has(e) && (Gt.add(e), console.warn("[monowind] 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>).", e)));
3439
+ function ur(e) {
3440
+ return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
3441
+ }
3442
+ var dr = "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>).";
3443
+ function fr(e) {
3444
+ return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
3445
+ }
3446
+ function pr(e, t) {
3447
+ ur(e) && (t.droppedText = !0, Ue(e, dr));
2270
3448
  }
2271
3449
  //#endregion
2272
3450
  //#region src/element.ts
2273
- var Yt = "\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 decoration layer must not sink with it. Scoped to\n * that state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n #decorations { position: absolute; inset: 0; pointer-events: none; user-select: none; white-space: pre; }\n</style>\n<div id=\"viewport\">\n <div id=\"decorations\" aria-hidden=\"true\"></div>\n <slot></slot>\n</div>\n", Xt = typeof HTMLElement > "u" ? class {} : HTMLElement, Zt = class extends Xt {
2274
- #e;
2275
- #t;
2276
- #n;
2277
- #r = null;
2278
- #i = null;
2279
- #a = !1;
2280
- #o = null;
3451
+ var mr = "\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 grid\n * 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 default select=\"text\" the grid is inert to events\n * and drag 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", hr = [
3452
+ "pointerover",
3453
+ "pointerleave",
3454
+ "focusin",
3455
+ "focusout",
3456
+ "input",
3457
+ "change"
3458
+ ], gr = typeof HTMLElement > "u" ? class {} : HTMLElement, _r = class e extends gr {
3459
+ static observedAttributes = ["select"];
3460
+ static #e = /* @__PURE__ */ new Set();
3461
+ static #t = null;
3462
+ static #n = () => {
3463
+ for (let t of e.#e) t.#y();
3464
+ };
3465
+ static #r(t) {
3466
+ t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
3467
+ }
3468
+ static #i(t) {
3469
+ if (e.#e.add(t), e.#t) return;
3470
+ for (let t of document.querySelectorAll("link[rel=stylesheet]")) e.#r(t);
3471
+ let n = new MutationObserver((t) => {
3472
+ for (let n of t) for (let t of n.addedNodes) e.#r(t);
3473
+ e.#n();
3474
+ });
3475
+ n.observe(document.head, {
3476
+ childList: !0,
3477
+ subtree: !0,
3478
+ characterData: !0
3479
+ }), e.#t = n;
3480
+ }
3481
+ static #a(t) {
3482
+ e.#e.delete(t), e.#e.size === 0 && (e.#t?.disconnect(), e.#t = null);
3483
+ }
3484
+ #o;
3485
+ #s;
3486
+ #c;
3487
+ #l = null;
3488
+ #u = null;
3489
+ #d = !1;
3490
+ #f = null;
3491
+ #p = null;
2281
3492
  constructor() {
2282
- super(), this.#e = this.attachShadow({ mode: "open" }), this.#e.innerHTML = Yt, this.#t = this.#e.getElementById("decorations"), this.#n = document.createElement("span"), this.#n.setAttribute("aria-hidden", "true"), this.#n.setAttribute("data-mw-probe", ""), this.#n.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.#n.textContent = "M".repeat(100);
3493
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = mr, 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);
2283
3494
  }
2284
3495
  connectedCallback() {
2285
- this.#n.parentNode !== this && this.appendChild(this.#n), this.#r = new ResizeObserver(() => this.#c()), this.#r.observe(this), this.#i = new MutationObserver(() => this.#c()), this.#i.observe(this, {
3496
+ this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#y()), this.#l.observe(this), window.addEventListener("resize", this.#h), this.#u = new MutationObserver(() => this.#y()), this.#u.observe(this, {
2286
3497
  childList: !0,
2287
3498
  subtree: !0,
2288
3499
  characterData: !0,
2289
3500
  attributes: !0,
2290
- attributeFilter: ["class", "style"]
2291
- }), document.fonts?.ready.then(this.#s).catch((e) => {
3501
+ attributeFilter: [
3502
+ "class",
3503
+ "style",
3504
+ "colspan",
3505
+ "rowspan",
3506
+ "span"
3507
+ ]
3508
+ }), document.fonts?.ready.then(this.#g).catch((e) => {
2292
3509
  console.warn("[monowind] document.fonts.ready failed:", e);
2293
- }), document.fonts?.addEventListener("loadingdone", this.#s), this.#c();
3510
+ }), document.fonts?.addEventListener("loadingdone", this.#g);
3511
+ for (let e of hr) this.addEventListener(e, this.#m);
3512
+ e.#i(this), this.#y();
2294
3513
  }
2295
3514
  disconnectedCallback() {
2296
- this.#r?.disconnect(), this.#i?.disconnect(), this.#r = null, this.#i = null, document.fonts?.removeEventListener("loadingdone", this.#s);
3515
+ window.removeEventListener("resize", this.#h), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, document.fonts?.removeEventListener("loadingdone", this.#g);
3516
+ for (let e of hr) this.removeEventListener(e, this.#m);
3517
+ e.#a(this);
2297
3518
  }
2298
- #s = () => {
2299
- requestAnimationFrame(() => this.#c());
3519
+ #m = (e) => {
3520
+ if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
3521
+ this.#v();
3522
+ return;
3523
+ }
3524
+ this.#y();
2300
3525
  };
2301
- #c() {
2302
- this.#a || (this.#a = !0, requestAnimationFrame(() => {
2303
- this.#a = !1;
2304
- try {
2305
- this.#l();
2306
- } catch (e) {
2307
- console.error("[monowind] layout failed:", e);
3526
+ attributeChangedCallback(e, t, n) {
3527
+ e === "select" && n !== null && n !== "text" && n !== "grid" && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "text" (default) or "grid".`, this), this.#y();
3528
+ }
3529
+ toPlainText() {
3530
+ return this.#d && this.#b(), this.#p ? Bt(this.#p) : "";
3531
+ }
3532
+ #h = () => {
3533
+ this.#y();
3534
+ };
3535
+ #g = () => {
3536
+ requestAnimationFrame(() => this.#y());
3537
+ };
3538
+ #_() {
3539
+ let e = document.activeElement;
3540
+ if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
3541
+ try {
3542
+ return e.matches(":open");
3543
+ } catch {
3544
+ return !1;
3545
+ }
3546
+ }
3547
+ #v() {
3548
+ try {
3549
+ this.#b();
3550
+ } catch (e) {
3551
+ console.error("[monowind] layout failed:", e);
3552
+ }
3553
+ }
3554
+ #y() {
3555
+ this.#d || (this.#d = !0, requestAnimationFrame(() => {
3556
+ if (this.#d = !1, this.#_()) {
3557
+ this.#y();
3558
+ return;
2308
3559
  }
3560
+ this.#v();
2309
3561
  }));
2310
3562
  }
2311
- #l() {
3563
+ #b() {
3564
+ if (!this.isConnected) return;
3565
+ let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
3566
+ if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
3567
+ let r = getComputedStyle(t), i = t.clientWidth - (parseFloat(r.paddingLeft) || 0) - (parseFloat(r.paddingRight) || 0);
3568
+ e.set(t, Math.max(0, Math.round(i / n)));
3569
+ }
2312
3570
  this.setAttribute("measuring", "");
2313
3571
  try {
2314
- let e = r(this, this.#n), t = this.#o;
2315
- (t === null || t.width !== e.width || t.height !== e.height || t.letterSpacing !== e.letterSpacing) && (this.style.setProperty("--mw-cw", `${e.width}px`), this.style.setProperty("--mw-ch", `${e.height}px`), this.style.setProperty("--mw-rls", `${e.letterSpacing}px`)), this.#o = e;
2316
- let n = getComputedStyle(this), a = (parseFloat(n.paddingLeft) || 0) + (parseFloat(n.paddingRight) || 0), o = Math.max(0, Math.floor((this.clientWidth - a) / e.width));
2317
- if (o === 0) return;
2318
- let s = i(), c = [];
2319
- for (let t of Array.from(this.children)) {
2320
- if (t === this.#n) continue;
2321
- let n = Mt(t, s, e);
2322
- n && c.push(n);
3572
+ let t = h(this, this.#c), n = this.#f;
3573
+ (n === null || n.width !== t.width || n.height !== t.height || n.letterSpacing !== t.letterSpacing) && (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.#f = t;
3574
+ let r = getComputedStyle(this), i = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), a = Math.max(0, Math.floor((this.clientWidth - i) / t.width));
3575
+ if (a === 0) return;
3576
+ let o = g(), s = [];
3577
+ for (let n of Array.from(this.children)) {
3578
+ if (n === this.#c) continue;
3579
+ let r = Xn(n, o, t, e);
3580
+ r && s.push(r);
2323
3581
  }
2324
- if (Array.from(this.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? "")) ? (this.hasAttribute("data-mw-dropped-text") || console.warn("[monowind] Direct text inside <mono-wind> can't be laid out and was hidden. Wrap each text segment in its own element (e.g. a <div>).", this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
2325
- this.#t.replaceChildren(), this.setAttribute("data-mw-ready", "");
3582
+ if (ur(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${dr}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
3583
+ this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
2326
3584
  return;
2327
3585
  }
2328
- let l = {
3586
+ let c = {
2329
3587
  source: this,
2330
- style: j(),
2331
- children: c,
3588
+ style: ue(),
3589
+ children: s,
2332
3590
  text: "",
2333
3591
  intrinsicWidth: 0,
2334
3592
  intrinsicHeight: 0,
@@ -2339,65 +3597,20 @@ var Yt = "\n<style>\n :host { display: block; position: relative; contain: layo
2339
3597
  height: 0
2340
3598
  },
2341
3599
  unclampedHeight: 0,
2342
- resolvedPadding: M()
2343
- }, { height: u } = Fe(l, o);
2344
- Xe(l, this.#t);
2345
- let d = n.boxSizing === "border-box" ? (parseFloat(n.paddingTop) || 0) + (parseFloat(n.paddingBottom) || 0) + (parseFloat(n.borderTopWidth) || 0) + (parseFloat(n.borderBottomWidth) || 0) : 0;
2346
- this.style.height = `${u * e.height + d}px`, this.setAttribute("data-mw-ready", "");
3600
+ resolvedPadding: z()
3601
+ }, { height: l } = wt(c, a);
3602
+ $t(c), Zt(c, this.#s), this.#p = c;
3603
+ 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`;
3604
+ this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
2347
3605
  } finally {
2348
- this.removeAttribute("measuring"), this.#i?.takeRecords();
3606
+ this.removeAttribute("measuring"), this.#u?.takeRecords();
2349
3607
  }
2350
3608
  }
2351
3609
  };
2352
- function Qt() {
2353
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", Zt);
2354
- }
2355
- //#endregion
2356
- //#region src/ascii.ts
2357
- function $t(e) {
2358
- let t = e.localRect.width, n = e.localRect.height;
2359
- if (t <= 0 || n <= 0) return "";
2360
- let r = Array.from({ length: n }, () => Array.from({ length: t }, () => " "));
2361
- return en(e, 0, 0, (e, i, a) => {
2362
- e >= 0 && e < t && i >= 0 && i < n && (r[i][e] = a);
2363
- }), r.map((e) => e.join("").trimEnd()).join("\n");
2364
- }
2365
- function en(e, t, n, r) {
2366
- let i = t + e.localRect.x, a = n + e.localRect.y, o = e.style, c = [];
2367
- Je(o, {
2368
- x: i,
2369
- y: a,
2370
- width: e.localRect.width,
2371
- height: e.localRect.height
2372
- }, c);
2373
- for (let e of c) for (let t = 0; t < e.length; t++) r(e.x + t, e.y, e.glyph);
2374
- if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
2375
- let t = e.resolvedPadding, n = i + o.border.left + t.left, c = a + o.border.top + t.top, l = e.localRect.width - o.border.left - o.border.right - t.left - t.right, { spans: u, lineY: d } = Be(e, l);
2376
- for (let t = 0; t < u.length; t++) {
2377
- let i = u[t], a = c + d[t], f = o.whiteSpace !== "normal" && o.overflow === "clip" ? tn(e.text, i, l, e.advances, o) : {
2378
- end: i.end,
2379
- ellipsis: !1
2380
- }, p = n;
2381
- for (let t = i.start; t < f.end; t++) e.text[t] !== "" && e.text[t] !== "⁠" && r(p, a, e.text[t]), p += s(t, t + 1, e.advances);
2382
- f.ellipsis && r(p, a, "…");
2383
- }
2384
- }
2385
- for (let t of e.children) en(t, i, a, r);
2386
- }
2387
- function tn(e, t, n, r, i) {
2388
- let { textOverflow: a, tracking: o } = i;
2389
- if (c(t.start, t.end, r, o) <= n) return {
2390
- end: t.end,
2391
- ellipsis: !1
2392
- };
2393
- let s = a === "ellipsis" ? n - 1 : n, l = t.start;
2394
- for (; l < t.end && c(t.start, l + 1, r, o) <= s;) l++;
2395
- return {
2396
- end: l,
2397
- ellipsis: a === "ellipsis" && n > 0
2398
- };
3610
+ function vr() {
3611
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", _r);
2399
3612
  }
2400
3613
  //#endregion
2401
- export { Zt as MonoWindElement, Qt as defineMonoWind, $t as renderAscii };
3614
+ export { _r as MonoWindElement, vr as defineMonoWind, Bt as renderPlainText, _ as wrapLines };
2402
3615
 
2403
3616
  //# sourceMappingURL=index.js.map