monowind 0.2.0 → 0.2.2

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
@@ -289,7 +289,7 @@ function D(e) {
289
289
  }
290
290
  return t;
291
291
  }
292
- var O = (e) => D(Array(16).fill(e));
292
+ var O = (e) => D(Array.from({ length: 16 }, () => e));
293
293
  x("default", {}), x("rounded", { solid: {
294
294
  tl: "╭",
295
295
  tr: "╮",
@@ -302,7 +302,11 @@ var k = {
302
302
  v: "|"
303
303
  };
304
304
  x("ascii", {
305
- solid: k,
305
+ solid: {
306
+ ...k,
307
+ scrollTrack: "|",
308
+ scrollThumb: "#"
309
+ },
306
310
  double: {
307
311
  ...k,
308
312
  h: "="
@@ -322,7 +326,14 @@ x("single", {
322
326
  }), x("cp437", {
323
327
  dashed: A,
324
328
  dotted: A
325
- }), x("blocks", {
329
+ });
330
+ function j(e) {
331
+ return {
332
+ track: e?.solid?.scrollTrack ?? "░",
333
+ thumb: e?.solid?.scrollThumb ?? "█"
334
+ };
335
+ }
336
+ x("blocks", {
326
337
  solid: O("█"),
327
338
  double: O("█"),
328
339
  dashed: O("▒"),
@@ -330,52 +341,52 @@ x("single", {
330
341
  });
331
342
  //#endregion
332
343
  //#region src/warn.ts
333
- var j = /* @__PURE__ */ new WeakMap();
334
- function M(e, t) {
335
- let n = j.get(e);
336
- n || j.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
344
+ var M = /* @__PURE__ */ new WeakMap();
345
+ function N(e, t) {
346
+ let n = M.get(e);
347
+ n || M.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
337
348
  }
338
349
  //#endregion
339
350
  //#region src/leaf.ts
340
- var N = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set();
341
- function te(e) {
351
+ var ee = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set();
352
+ function ne(e) {
342
353
  let t = e.tag.toLowerCase();
343
354
  if (!t.includes("-")) {
344
355
  console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
345
356
  return;
346
357
  }
347
- N.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), N.set(t, {
358
+ ee.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), ee.set(t, {
348
359
  ...e,
349
360
  tag: t
350
- }), se();
361
+ }), ce();
351
362
  }
352
- function ne() {
353
- se();
363
+ function re() {
364
+ ce();
354
365
  }
355
- function re(e) {
356
- return N.get(e.toLowerCase());
366
+ function ie(e) {
367
+ return ee.get(e.toLowerCase());
357
368
  }
358
- function ie() {
369
+ function ae() {
359
370
  let e = /* @__PURE__ */ new Set();
360
- for (let t of N.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
371
+ for (let t of ee.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
361
372
  return [...e];
362
373
  }
363
- function ae(e) {
364
- return ee.add(e), () => ee.delete(e);
374
+ function oe(e) {
375
+ return te.add(e), () => te.delete(e);
365
376
  }
366
- function oe(e, t) {
377
+ function se(e, t) {
367
378
  try {
368
379
  return e.render(t);
369
380
  } catch (n) {
370
- return M(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
381
+ return N(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
371
382
  }
372
383
  }
373
- function se() {
374
- for (let e of ee) e();
384
+ function ce() {
385
+ for (let e of te) e();
375
386
  }
376
387
  //#endregion
377
388
  //#region src/borders.ts
378
- function ce(e, t, n) {
389
+ function le(e, t, n) {
379
390
  let r = e.border;
380
391
  if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
381
392
  let i = Math.max(r.top, r.right, r.bottom, r.left);
@@ -391,11 +402,11 @@ function ce(e, t, n) {
391
402
  width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
392
403
  height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
393
404
  };
394
- o.width <= 0 || o.height <= 0 || le(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
405
+ o.width <= 0 || o.height <= 0 || ue(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
395
406
  }
396
407
  }
397
- function le(e, t, n, r, i, a) {
398
- let o = me(t.top, a), s = me(t.right, a), c = me(t.bottom, a), l = me(t.left, a), u = (e, t, n) => n(me(e === t ? e : "solid", a)), { 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;
408
+ function ue(e, t, n, r, i, a) {
409
+ let o = he(t.top, a), s = he(t.right, a), c = he(t.bottom, a), l = he(t.left, a), u = (e, t, n) => n(he(e === t ? e : "solid", a)), { 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;
399
410
  if (i.top && _ > g && e.push({
400
411
  glyph: o.h,
401
412
  x: g,
@@ -448,24 +459,25 @@ function le(e, t, n, r, i, a) {
448
459
  color: n.bottom
449
460
  }));
450
461
  }
451
- function ue(e, t) {
452
- return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
462
+ function de(e, t) {
463
+ return e.style.position !== "static" || (t.style.display === "flex" || t.style.display === "grid") && e.style.zIndex !== null;
453
464
  }
454
- function de(e) {
465
+ function fe(e) {
455
466
  if (e.children.length <= 1) return e.children;
456
- let t = null, n = null, r = null;
457
- for (let i of e.children) ue(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
458
- return r && r.length > 1 && r.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), t && !n && !r ? t : !t && n && !r ? n : !t && !n && r ? r : [
467
+ let t = null, n = null, r = null, i = null;
468
+ for (let a of e.children) de(a, e) ? (a.style.zIndex ?? 0) < 0 ? (t ??= []).push(a) : (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (n ??= []).push(a);
469
+ return t && t.length > 1 && t.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), i && i.length > 1 && i.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), !t && n && !r && !i ? n : !t && !n && r && !i ? r : !t && !n && !r && i ? i : [
459
470
  ...t ?? [],
460
471
  ...n ?? [],
461
- ...r ?? []
472
+ ...r ?? [],
473
+ ...i ?? []
462
474
  ];
463
475
  }
464
- function fe(e, t, n) {
465
- let r = me(e, n);
476
+ function pe(e, t, n) {
477
+ let r = he(e, n);
466
478
  return t === "h" ? r.h : r.v;
467
479
  }
468
- function pe(e, t, n, r, i, a) {
480
+ function me(e, t, n, r, i, a) {
469
481
  let o = (t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i;
470
482
  if (a) {
471
483
  let t = w(o), n = t && a[e]?.[t];
@@ -473,8 +485,8 @@ function pe(e, t, n, r, i, a) {
473
485
  }
474
486
  return (e === "double" ? E : T)[o];
475
487
  }
476
- function me(e, t) {
477
- let n = (n, r, i, a) => pe(e, n, r, i, a, t), r = {
488
+ function he(e, t) {
489
+ let n = (n, r, i, a) => me(e, n, r, i, a, t), r = {
478
490
  h: n(!1, !1, !0, !0),
479
491
  v: n(!0, !0, !1, !1),
480
492
  tl: n(!1, !0, !1, !0),
@@ -485,24 +497,24 @@ function me(e, t) {
485
497
  return e === "dashed" ? {
486
498
  h: "╌",
487
499
  v: "╎",
488
- ...he(r),
489
- ...ge(t, e)
500
+ ...ge(r),
501
+ ..._e(t, e)
490
502
  } : e === "dotted" ? {
491
503
  h: "┄",
492
504
  v: "┊",
493
- ...he(r),
494
- ...ge(t, e)
505
+ ...ge(r),
506
+ ..._e(t, e)
495
507
  } : r;
496
508
  }
497
- function he(e) {
509
+ function ge(e) {
498
510
  let { h: t, v: n, ...r } = e;
499
511
  return r;
500
512
  }
501
- function ge(e, t) {
513
+ function _e(e, t) {
502
514
  let n = e?.[t], r = {};
503
515
  return n?.h && (r.h = n.h), n?.v && (r.v = n.v), r;
504
516
  }
505
- function _e(e, t, n, r) {
517
+ function ve(e, t, n, r) {
506
518
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
507
519
  for (let n = 0; n < e.length; n++) if (a.push({
508
520
  start: e[n].start,
@@ -546,7 +558,7 @@ function _e(e, t, n, r) {
546
558
  end: e.end - r
547
559
  })).filter((e) => e.end > e.start);
548
560
  }
549
- function ve(e) {
561
+ function ye(e) {
550
562
  let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
551
563
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
552
564
  start: t.start,
@@ -555,7 +567,7 @@ function ve(e) {
555
567
  endHalf: t.endHalf === !0
556
568
  }), a = e.ruleX ? e.vertical.map((t) => i(e.ruleX, t)) : [], o = e.ruleY ? e.horizontal.map((t) => i(e.ruleY, t)) : [], s = e.ruleX?.width ?? 0, c = e.ruleY?.width ?? 0, l = (e, t, n, r) => e.some((e) => n >= e.line && n < e.line + t && (e.start < r && e.end > r || e.end === r && !e.endHalf || e.start === r && !e.startHalf)), u = (e, t) => o.some((n) => t >= n.line && t < n.line + c && e >= n.start && e < n.end);
557
569
  if (e.ruleX) {
558
- let i = fe(e.ruleX.style, "v", e.glyphs);
570
+ let i = pe(e.ruleX.style, "v", e.glyphs);
559
571
  for (let o of a) {
560
572
  for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
561
573
  glyph: i,
@@ -564,7 +576,7 @@ function ve(e) {
564
576
  length: 1,
565
577
  color: e.ruleX.color
566
578
  });
567
- ye(e, t, "x", o.line, o.start, o.end);
579
+ be(e, t, "x", o.line, o.start, o.end);
568
580
  }
569
581
  }
570
582
  if (e.ruleY) {
@@ -575,7 +587,7 @@ function ve(e) {
575
587
  for (let d = u.start; d < u.end; d++) {
576
588
  let u = l(a, s, d, f), p = l(a, s, d, f + 1);
577
589
  t.push({
578
- glyph: u || p ? pe(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : fe(e.ruleY.style, "h", e.glyphs),
590
+ glyph: u || p ? me(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : pe(e.ruleY.style, "h", e.glyphs),
579
591
  x: n + d,
580
592
  y: r + f,
581
593
  length: 1,
@@ -583,16 +595,16 @@ function ve(e) {
583
595
  });
584
596
  }
585
597
  }
586
- ye(e, t, "y", u.line, u.start, u.end);
598
+ be(e, t, "y", u.line, u.start, u.end);
587
599
  }
588
600
  }
589
601
  return t;
590
602
  }
591
- function ye(e, t, n, r, i, a) {
603
+ function be(e, t, n, r, i, a) {
592
604
  let o = n === "x" ? e.ruleX : e.ruleY, s = e.border.left + e.padding.left, c = e.border.top + e.padding.top, l = s + e.contentWidth + e.padding.right + e.border.right, u = c + e.contentHeight + e.padding.bottom + e.border.bottom, d = (n, r, i, a, s, c, l, u) => {
593
605
  let d = o.style === "double" && i === "double" ? "double" : "solid";
594
606
  t.push({
595
- glyph: pe(d, s, c, l, u, e.glyphs),
607
+ glyph: me(d, s, c, l, u, e.glyphs),
596
608
  x: n,
597
609
  y: r,
598
610
  length: 1,
@@ -610,19 +622,26 @@ function ye(e, t, n, r, i, a) {
610
622
  }
611
623
  //#endregion
612
624
  //#region src/pointer.ts
613
- function be(e, t, n) {
625
+ function xe(e, t, n) {
614
626
  let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
615
627
  for (;;) {
616
628
  let e = null;
617
- for (let r of de(i)) {
629
+ for (let r of fe(i)) {
618
630
  if (r.tableHidden) continue;
619
631
  let i = a + r.localRect.x, s = o + r.localRect.y;
620
632
  t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
621
633
  }
622
634
  if (!e) return r;
623
- r.push(e.source), a += e.localRect.x, o += e.localRect.y, i = e;
635
+ r.push({
636
+ node: e,
637
+ x: a + e.localRect.x,
638
+ y: o + e.localRect.y
639
+ }), a += e.localRect.x - (e.scroll?.x ?? 0), o += e.localRect.y - (e.scroll?.y ?? 0), i = e;
624
640
  }
625
641
  }
642
+ function Se(e, t, n) {
643
+ return xe(e, t, n).map((e) => e.node.source);
644
+ }
626
645
  //#endregion
627
646
  //#region src/metrics.ts
628
647
  function P(e) {
@@ -631,10 +650,10 @@ function P(e) {
631
650
  function F(e, t) {
632
651
  return t <= 0 ? 0 : P(e / (.25 * t));
633
652
  }
634
- function xe(e, t) {
653
+ function Ce(e, t) {
635
654
  return P(t * e / 100);
636
655
  }
637
- function Se(e, t) {
656
+ function we(e, t) {
638
657
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
639
658
  i.selectNodeContents(t);
640
659
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -645,56 +664,56 @@ function Se(e, t) {
645
664
  inkOverhang: a
646
665
  };
647
666
  }
648
- function Ce() {
667
+ function Te() {
649
668
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
650
669
  }
651
670
  //#endregion
652
671
  //#region src/wrap.ts
653
- function we(e, t, n = {}) {
654
- return Oe(e, t, n).map((t) => e.slice(t.start, t.end));
672
+ function Ee(e, t, n = {}) {
673
+ return Ae(e, t, n).map((t) => e.slice(t.start, t.end));
655
674
  }
656
- function Te(e, t, n = {}) {
657
- return Oe(e, t, n).length;
675
+ function De(e, t, n = {}) {
676
+ return Ae(e, t, n).length;
658
677
  }
659
- function Ee(e, t) {
678
+ function Oe(e, t) {
660
679
  return t.endsWith("\n") && e.pop(), e;
661
680
  }
662
- function De(e) {
681
+ function ke(e) {
663
682
  let t = [], n = 0;
664
683
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
665
684
  start: n,
666
685
  end: r
667
686
  }), n = r + 1);
668
- return Ee(t, e);
687
+ return Oe(t, e);
669
688
  }
670
- function Oe(e, t, n = {}) {
689
+ function Ae(e, t, n = {}) {
671
690
  if (!/[^ \t\r\f]/.test(e)) return [];
672
691
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
673
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Ie(e, i, o, t, n, a)), a = 0, i = o + 1);
674
- return Ee(r, e);
692
+ for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Re(e, i, o, t, n, a)), a = 0, i = o + 1);
693
+ return Oe(r, e);
675
694
  }
676
- function ke(e, t, n) {
695
+ function je(e, t, n) {
677
696
  if (!n) return t - e;
678
697
  let r = 0;
679
698
  for (let i = e; i < t; i++) r += n[i] ?? 1;
680
699
  return r;
681
700
  }
682
701
  function I(e, t, n, r = 0) {
683
- return t <= e ? 0 : ke(e, t, n) - Math.min(r, Ae(t - 1, n));
702
+ return t <= e ? 0 : je(e, t, n) - Math.min(r, Me(t - 1, n));
684
703
  }
685
- function Ae(e, t) {
704
+ function Me(e, t) {
686
705
  return t ? (t[e] ?? 1) - 1 : 0;
687
706
  }
688
- function je(e, t = {}) {
707
+ function Ne(e, t = {}) {
689
708
  let { advances: n, tracking: r = 0 } = t, i = 0;
690
- for (let t of Fe(e, 0, e.length)) for (let a of Ne(e, t.start, t.end)) i = Math.max(i, I(a.start, a.end, n, r));
709
+ for (let t of Le(e, 0, e.length)) for (let a of Fe(e, t.start, t.end)) i = Math.max(i, I(a.start, a.end, n, r));
691
710
  return i;
692
711
  }
693
- function Me(e, t) {
712
+ function Pe(e, t) {
694
713
  let n = 0;
695
714
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
696
715
  }
697
- function Ne(e, t, n) {
716
+ function Fe(e, t, n) {
698
717
  let r = [], i = t;
699
718
  for (let a = t; a < n; a++) {
700
719
  if (e[a] === "") {
@@ -721,14 +740,14 @@ function Ne(e, t, n) {
721
740
  end: n
722
741
  }), r;
723
742
  }
724
- var Pe = /[ \t\r\n\f]/;
725
- function Fe(e, t, n) {
743
+ var Ie = /[ \t\r\n\f]/;
744
+ function Le(e, t, n) {
726
745
  let r = [], i = t;
727
746
  for (; i < n;) {
728
- for (; i < n && Pe.test(e[i]);) i++;
747
+ for (; i < n && Ie.test(e[i]);) i++;
729
748
  if (i >= n) break;
730
749
  let t = i;
731
- for (; i < n && !Pe.test(e[i]);) i++;
750
+ for (; i < n && !Ie.test(e[i]);) i++;
732
751
  r.push({
733
752
  start: t,
734
753
  end: i
@@ -736,8 +755,8 @@ function Fe(e, t, n) {
736
755
  }
737
756
  return r;
738
757
  }
739
- function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
740
- let s = Fe(e, t, n);
758
+ function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
759
+ let s = Le(e, t, n);
741
760
  if (s.length === 0) return [{
742
761
  start: t,
743
762
  end: t
@@ -749,8 +768,8 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
749
768
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
750
769
  for (let t of s) {
751
770
  let n = !1;
752
- for (let r of Ne(e, t.start, t.end)) {
753
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + ke(o, t, i), p = Math.min(a, Ae(t - 1, i));
771
+ for (let r of Fe(e, t.start, t.end)) {
772
+ let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + je(o, t, i), p = Math.min(a, Me(t - 1, i));
754
773
  if (l !== null && s - p <= f()) l.end = t, u = s;
755
774
  else {
756
775
  for (l !== null && (c.push(l), d = 0);;) {
@@ -765,7 +784,7 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
765
784
  l = {
766
785
  start: e,
767
786
  end: t
768
- }, u = ke(e, t, i);
787
+ }, u = je(e, t, i);
769
788
  }
770
789
  n = !0;
771
790
  }
@@ -774,7 +793,7 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
774
793
  }
775
794
  //#endregion
776
795
  //#region src/flex.ts
777
- function Le(e, t) {
796
+ function ze(e, t) {
778
797
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
779
798
  for (let e = 1; e < n.length; e++) {
780
799
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -785,12 +804,12 @@ function Le(e, t) {
785
804
  }
786
805
  return r;
787
806
  }
788
- function Re(e, t, n, r, i) {
807
+ function Be(e, t, n, r, i) {
789
808
  if (e.style.ruleBreak !== "intersection") return [{
790
809
  start: 0,
791
810
  end: i
792
811
  }];
793
- let a = [t[n - 1], t[n]].flatMap((e) => Le(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
812
+ let a = [t[n - 1], t[n]].flatMap((e) => ze(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
794
813
  start: e,
795
814
  end: t,
796
815
  spanned: !1,
@@ -798,24 +817,24 @@ function Re(e, t, n, r, i) {
798
817
  afterOccupied: !0
799
818
  }), s = [], c = 0;
800
819
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
801
- return c < i && s.push(o(c, i)), _e(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
820
+ return c < i && s.push(o(c, i)), ve(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
802
821
  }
803
- function ze(e, t) {
822
+ function Ve(e, t) {
804
823
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
805
824
  ...e,
806
825
  start: e.start + t,
807
826
  end: e.end - t
808
827
  })).filter((e) => e.end > e.start);
809
828
  }
810
- function Be(e, t, n, r, i, a, o) {
811
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Ye(e).map((e) => {
829
+ function He(e, t, n, r, i, a, o) {
830
+ let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Xe(e).map((e) => {
812
831
  let n = G(e.style.margin, t);
813
832
  return {
814
833
  node: e,
815
- base: Je(e, t, o),
834
+ base: Ye(e, t, o),
816
835
  grow: e.style.flexGrow,
817
836
  shrink: e.style.flexShrink,
818
- min: Qe(e, t, o),
837
+ min: $e(e, t, o),
819
838
  max: K(e.style.maxWidth, t),
820
839
  margin: n
821
840
  };
@@ -829,7 +848,7 @@ function Be(e, t, n, r, i, a, o) {
829
848
  n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
830
849
  } else u.push(l);
831
850
  let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
832
- let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, H(e.base, e.min, e.max))) : Ge(e, a);
851
+ let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, H(e.base, e.min, e.max))) : qe(e, a);
833
852
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
834
853
  return {
835
854
  row: e,
@@ -838,9 +857,9 @@ function Be(e, t, n, r, i, a, o) {
838
857
  height: e.reduce((e, t) => Math.max(e, t.node.localRect.height), 0)
839
858
  };
840
859
  }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
841
- if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
860
+ if (e.style.flexWrap === "nowrap") r === void 0 ? Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)) : m[0] = r, g = [0];
842
861
  else {
843
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Xe(e.style);
862
+ let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Ze(e.style);
844
863
  if (i === "stretch" && r > 0) {
845
864
  let e = R(Array.from({ length: p.length }, () => 1), r);
846
865
  for (let t = 0; t < m.length; t++) m[t] += e[t];
@@ -850,8 +869,8 @@ function Be(e, t, n, r, i, a, o) {
850
869
  for (let i = 0; i < p.length; i++) {
851
870
  let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
852
871
  for (let i = 0; i < a.length; i++) {
853
- let s = a[i].node, c = Ke(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
854
- if (c === "stretch" && !d && !f && h > s.localRect.height) {
872
+ let s = a[i].node, c = Je(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
873
+ if (c === "stretch" && !d && !f && h !== s.localRect.height) {
855
874
  let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = H(Math.max(0, h - e - a), K(s.style.minHeight, c) ?? 0, K(s.style.maxHeight, c));
856
875
  if (d === s.localRect.height) continue;
857
876
  V(s, t, r, 0, 0, "fill", o, {
@@ -865,14 +884,14 @@ function Be(e, t, n, r, i, a, o) {
865
884
  let e = R(Array.from({ length: b }, () => 1), y), t = 0;
866
885
  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++]);
867
886
  C = L("start", l, 0);
868
- } else C = L(Ze(e.style), l, y);
887
+ } else C = L(Qe(e.style), l, y);
869
888
  let w = 0;
870
889
  for (let t = 0; t < a.length; t++) {
871
890
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
872
891
  w += x[t] + i, r.localRect = {
873
892
  ...r.localRect,
874
893
  x: d + C[t] + t * s + w,
875
- y: f + _ + Ue(r, e.style.alignItems, h, n.margin)
894
+ y: f + _ + Ge(r, e.style.alignItems, h, n.margin)
876
895
  }, w += S[t] + o;
877
896
  }
878
897
  }
@@ -881,7 +900,7 @@ function Be(e, t, n, r, i, a, o) {
881
900
  let n = [], r = [];
882
901
  for (let i = 0; i < p.length; i++) {
883
902
  let a = g[i] + i * c;
884
- for (let e of Le(p[i], d)) n.push({
903
+ for (let e of ze(p[i], d)) n.push({
885
904
  bandStart: e.start,
886
905
  bandSize: e.end - e.start,
887
906
  start: a,
@@ -889,19 +908,19 @@ function Be(e, t, n, r, i, a, o) {
889
908
  });
890
909
  if (i > 0) {
891
910
  let n = g[i - 1] + (i - 1) * c + m[i - 1];
892
- if (a > n) for (let o of Re(e, p, i, d, t)) r.push({
911
+ if (a > n) for (let o of Be(e, p, i, d, t)) r.push({
893
912
  bandStart: n,
894
913
  bandSize: a - n,
895
914
  ...o
896
915
  });
897
916
  }
898
917
  }
899
- e.decorationRuns = ve({
918
+ e.decorationRuns = ye({
900
919
  glyphs: S(e.style.glyphSet),
901
920
  ruleX: e.style.ruleX,
902
921
  ruleY: e.style.ruleY,
903
- vertical: ze(n, e.style.ruleInset),
904
- horizontal: ze(r, e.style.ruleInset),
922
+ vertical: Ve(n, e.style.ruleInset),
923
+ horizontal: Ve(r, e.style.ruleInset),
905
924
  contentWidth: t,
906
925
  contentHeight: v,
907
926
  border: i,
@@ -910,9 +929,9 @@ function Be(e, t, n, r, i, a, o) {
910
929
  padding: a
911
930
  });
912
931
  }
913
- return Ve(e, i, a, t, v), v;
932
+ return Ue(e, i, a, t, v), v;
914
933
  }
915
- function Ve(e, t, n, r, i) {
934
+ function Ue(e, t, n, r, i) {
916
935
  for (let a of e.children) B(a.style) && (a.staticSlot = {
917
936
  kind: "flex",
918
937
  direction: e.style.flexDirection,
@@ -922,11 +941,11 @@ function Ve(e, t, n, r, i) {
922
941
  innerHeight: i
923
942
  });
924
943
  }
925
- function He(e, t, n, r, i, a, o) {
926
- let s = U(e.style, "y", n), c = Ye(e).map((i) => {
927
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ke(i, e) === "stretch";
944
+ function We(e, t, n, r, i, a, o) {
945
+ let s = U(e.style, "y", n), c = Xe(e).map((i) => {
946
+ let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Je(i, e) === "stretch";
928
947
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
929
- 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 ? xe(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
948
+ 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 ? Ce(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow.y === "visible" ? i.localRect.height : 0 : void 0;
930
949
  return {
931
950
  node: i,
932
951
  base: d,
@@ -936,9 +955,9 @@ function He(e, t, n, r, i, a, o) {
936
955
  max: K(i.style.maxHeight, l),
937
956
  margin: a
938
957
  };
939
- }), l = s * Math.max(0, c.length - 1), u = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), d = Number.isFinite(n), f = c.reduce((e, t) => e + t.base, 0), p = d ? Math.max(0, n - l - u) : f, m = r ? p : Math.max(p, f), h = c.some((e) => e.margin.top === null || e.margin.bottom === null), g = d && !(d && h && f <= m) ? Ge(c, m) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
958
+ }), l = s * Math.max(0, c.length - 1), u = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), d = Number.isFinite(n), f = c.reduce((e, t) => e + t.base, 0), p = d ? Math.max(0, n - l - u) : f, m = r ? p : Math.max(p, f), h = c.some((e) => e.margin.top === null || e.margin.bottom === null), g = d && !(d && h && f <= m) ? qe(c, m) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
940
959
  for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
941
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ke(r.node, e) === "stretch";
960
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Je(r.node, e) === "stretch";
942
961
  V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
943
962
  }
944
963
  let _ = g.reduce((e, t) => e + t, 0), v = Math.max(0, m - _), y = c.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), b = Array.from({ length: c.length }, () => 0), x = Array.from({ length: c.length }, () => 0), C;
@@ -946,13 +965,13 @@ function He(e, t, n, r, i, a, o) {
946
965
  let e = R(Array.from({ length: y }, () => 1), v), t = 0;
947
966
  for (let n = 0; n < c.length; n++) c[n].margin.top === null && (b[n] = e[t++]), c[n].margin.bottom === null && (x[n] = e[t++]);
948
967
  C = L("start", g, 0);
949
- } else C = L(Ze(e.style), g, v);
968
+ } else C = L(Qe(e.style), g, v);
950
969
  let w = i.left + a.left, T = i.top + a.top, E = 0;
951
970
  for (let n = 0; n < c.length; n++) {
952
971
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
953
972
  E += b[n] + a, i.localRect = {
954
973
  ...i.localRect,
955
- x: w + We(i, e.style.alignItems, t, r.margin),
974
+ x: w + Ke(i, e.style.alignItems, t, r.margin),
956
975
  y: T + C[n] + n * s + E
957
976
  }, E += x[n] + o;
958
977
  }
@@ -968,12 +987,12 @@ function He(e, t, n, r, i, a, o) {
968
987
  end: t
969
988
  });
970
989
  }
971
- e.decorationRuns = ve({
990
+ e.decorationRuns = ye({
972
991
  glyphs: S(e.style.glyphSet),
973
992
  ruleX: null,
974
993
  ruleY: e.style.ruleY,
975
994
  vertical: [],
976
- horizontal: ze(n, e.style.ruleInset),
995
+ horizontal: Ve(n, e.style.ruleInset),
977
996
  contentWidth: t,
978
997
  contentHeight: O,
979
998
  border: i,
@@ -982,15 +1001,15 @@ function He(e, t, n, r, i, a, o) {
982
1001
  padding: a
983
1002
  });
984
1003
  }
985
- return Ve(e, i, a, t, O), O;
1004
+ return Ue(e, i, a, t, O), O;
986
1005
  }
987
- function Ue(e, t, n, r) {
1006
+ function Ge(e, t, n, r) {
988
1007
  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;
989
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.height);
1008
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.height);
990
1009
  }
991
- function We(e, t, n, r) {
1010
+ function Ke(e, t, n, r) {
992
1011
  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;
993
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.width);
1012
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.width);
994
1013
  }
995
1014
  function L(e, t, n) {
996
1015
  let r = t.length;
@@ -1010,7 +1029,7 @@ function L(e, t, n) {
1010
1029
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
1011
1030
  return i;
1012
1031
  }
1013
- function Ge(e, t) {
1032
+ function qe(e, t) {
1014
1033
  let n = e.length, r = (t, n) => Math.max(0, H(t, e[n].min ?? 0, e[n].max)), i = e.map((e) => e.base), a = t >= i.reduce((e, t, n) => e + r(t, n), 0), o = Array.from({ length: n }, () => 0), s = Array.from({ length: n }, () => !1);
1015
1034
  for (let t = 0; t < n; t++) {
1016
1035
  let n = r(i[t], t);
@@ -1045,33 +1064,45 @@ function R(e, t) {
1045
1064
  }
1046
1065
  return i;
1047
1066
  }
1048
- function Ke(e, t) {
1067
+ function Je(e, t) {
1049
1068
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
1050
1069
  }
1051
- function qe(e, t, n) {
1070
+ function z(e, t, n) {
1052
1071
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
1053
1072
  }
1054
- function Je(e, t, n) {
1073
+ function Ye(e, t, n) {
1055
1074
  let r = e.style.flexBasis, i = e.style.width;
1056
1075
  return r !== void 0 && r.kind !== "auto" ? q(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? q(i, t, e, n) : J(e, n);
1057
1076
  }
1058
- function Ye(e) {
1077
+ function Xe(e) {
1059
1078
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
1060
1079
  return e.style.flexReverse && t.reverse(), t;
1061
1080
  }
1062
- function Xe(e) {
1081
+ function Ze(e) {
1063
1082
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
1064
1083
  }
1065
- function Ze(e) {
1084
+ function Qe(e) {
1066
1085
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
1067
1086
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
1068
1087
  }
1069
- function Qe(e, t, n) {
1070
- return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
1088
+ function $e(e, t, n) {
1089
+ return e.style.minWidth === "auto" ? e.style.overflow.x === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
1071
1090
  }
1072
1091
  //#endregion
1073
1092
  //#region src/types.ts
1074
- function $e() {
1093
+ function et(e) {
1094
+ return e === "auto" || e === "scroll";
1095
+ }
1096
+ function tt(e) {
1097
+ return e.scrollbarWidth === "none" ? {
1098
+ right: 0,
1099
+ bottom: 0
1100
+ } : {
1101
+ right: e.overflow.y === "scroll" ? e.scrollbarSize.y : 0,
1102
+ bottom: e.overflow.x === "scroll" ? e.scrollbarSize.x : 0
1103
+ };
1104
+ }
1105
+ function nt() {
1075
1106
  return {
1076
1107
  display: "block",
1077
1108
  flexDirection: "row",
@@ -1090,8 +1121,8 @@ function $e() {
1090
1121
  justifySelf: "auto",
1091
1122
  gridTemplateColumns: { kind: "none" },
1092
1123
  gridTemplateRows: { kind: "none" },
1093
- gridAutoColumns: [et()],
1094
- gridAutoRows: [et()],
1124
+ gridAutoColumns: [it()],
1125
+ gridAutoRows: [it()],
1095
1126
  gridAutoFlow: {
1096
1127
  direction: "row",
1097
1128
  dense: !1
@@ -1107,7 +1138,7 @@ function $e() {
1107
1138
  minHeight: "auto",
1108
1139
  maxWidth: void 0,
1109
1140
  maxHeight: void 0,
1110
- padding: z(),
1141
+ padding: rt(),
1111
1142
  margin: {
1112
1143
  top: 0,
1113
1144
  right: 0,
@@ -1123,14 +1154,27 @@ function $e() {
1123
1154
  },
1124
1155
  gapX: 0,
1125
1156
  gapY: 0,
1126
- border: z(),
1157
+ border: rt(),
1127
1158
  borderStyle: {
1128
1159
  top: "solid",
1129
1160
  right: "solid",
1130
1161
  bottom: "solid",
1131
1162
  left: "solid"
1132
1163
  },
1133
- overflow: "visible",
1164
+ overflow: {
1165
+ x: "visible",
1166
+ y: "visible"
1167
+ },
1168
+ scrollbarWidth: "auto",
1169
+ scrollbarSize: {
1170
+ x: 1,
1171
+ y: 1
1172
+ },
1173
+ overscroll: {
1174
+ x: !0,
1175
+ y: !0
1176
+ },
1177
+ scrollbarColor: null,
1134
1178
  whiteSpace: "normal",
1135
1179
  tabSize: 8,
1136
1180
  lineGap: 0,
@@ -1176,7 +1220,7 @@ function $e() {
1176
1220
  breakInsideAvoid: !1
1177
1221
  };
1178
1222
  }
1179
- function z() {
1223
+ function rt() {
1180
1224
  return {
1181
1225
  top: 0,
1182
1226
  right: 0,
@@ -1184,7 +1228,7 @@ function z() {
1184
1228
  left: 0
1185
1229
  };
1186
1230
  }
1187
- function et() {
1231
+ function it() {
1188
1232
  return {
1189
1233
  min: { kind: "auto" },
1190
1234
  max: { kind: "auto" }
@@ -1192,15 +1236,15 @@ function et() {
1192
1236
  }
1193
1237
  //#endregion
1194
1238
  //#region src/grid.ts
1195
- function tt(e, t, n, r, i, a) {
1196
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : U(o, "x", t), d = l ? l.gap : U(o, "y", s), f = dt(e, t, s, u, d, e.subgrid ? {
1239
+ function at(e, t, n, r, i, a) {
1240
+ let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : U(o, "x", t), d = l ? l.gap : U(o, "y", s), f = ht(e, t, s, u, d, e.subgrid ? {
1197
1241
  col: e.subgrid.colSpan,
1198
1242
  row: e.subgrid.rowSpan
1199
- } : 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)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(nt), T = c ? it(c) : Dt(_, y, at(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Ot(T, t, o.justifyContent), D = [];
1243
+ } : 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)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(ot), T = c ? ct(c) : jt(_, y, lt(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Mt(T, t, o.justifyContent), D = [];
1200
1244
  for (let e = 0; e < p.length; e++) {
1201
- let t = p[e], n = m.items[e], r = At(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - ht(i)), s = w[e];
1245
+ let t = p[e], n = m.items[e], r = Pt(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - yt(i)), s = w[e];
1202
1246
  if (s.cols || s.rows) {
1203
- let e = s.cols ? rt(E, T, u, n.col.start, n.col.span, st(t, "cols", i, r)) : void 0;
1247
+ let e = s.cols ? st(E, T, u, n.col.start, n.col.span, dt(t, "cols", i, r)) : void 0;
1204
1248
  t.subgrid = {
1205
1249
  colSpan: n.col.span,
1206
1250
  rowSpan: n.row.span,
@@ -1209,17 +1253,17 @@ function tt(e, t, n, r, i, a) {
1209
1253
  };
1210
1254
  } else t.subgrid = void 0;
1211
1255
  let c = C[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1212
- s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Bn(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1256
+ s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow.x === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Wn(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1213
1257
  }
1214
- let O = l ? it(l) : Dt(v, b, ot(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = kt(O), A = l ? l.positions : Ot(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1258
+ let O = l ? ct(l) : jt(v, b, ut(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = Nt(O), A = l ? l.positions : Mt(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1215
1259
  for (let t = 0; t < p.length; t++) {
1216
- let n = p[t], r = m.items[t], i = x[t], o = At(E, T.sizes, r.col.start, r.col.span), s = At(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - gt(i)), l = Ke(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1217
- if (w[t].rows) n.subgrid.rows = rt(A, O, d, r.row.start, r.row.span, st(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1260
+ let n = p[t], r = m.items[t], i = x[t], o = Pt(E, T.sizes, r.col.start, r.col.span), s = Pt(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - bt(i)), l = Je(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1261
+ if (w[t].rows) n.subgrid.rows = st(A, O, d, r.row.start, r.row.span, dt(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1218
1262
  width: D[t],
1219
1263
  height: c
1220
1264
  });
1221
1265
  else if (l === "stretch" && !u && !f) {
1222
- let e = H(c, n.style.minHeight === "auto" ? n.style.overflow === "visible" ? n.localRect.height : 0 : K(n.style.minHeight, s) ?? 0, K(n.style.maxHeight, s));
1266
+ let e = H(c, n.style.minHeight === "auto" ? n.style.overflow.y === "visible" ? n.localRect.height : 0 : K(n.style.minHeight, s) ?? 0, K(n.style.maxHeight, s));
1223
1267
  e !== n.localRect.height && V(n, o, s, 0, 0, "fill", a, {
1224
1268
  width: D[t],
1225
1269
  height: e
@@ -1227,8 +1271,8 @@ function tt(e, t, n, r, i, a) {
1227
1271
  } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: D[t] });
1228
1272
  n.localRect = {
1229
1273
  ...n.localRect,
1230
- x: j + E[r.col.start] + jt(C[t], i.left, i.right, o, n.localRect.width),
1231
- y: M + A[r.row.start] + jt(l, i.top, i.bottom, s, n.localRect.height)
1274
+ x: j + E[r.col.start] + Ft(C[t], i.left, i.right, o, n.localRect.width),
1275
+ y: M + A[r.row.start] + Ft(l, i.top, i.bottom, s, n.localRect.height)
1232
1276
  };
1233
1277
  }
1234
1278
  let N = Number.isFinite(n) ? Math.max(n, k) : k;
@@ -1245,7 +1289,7 @@ function tt(e, t, n, r, i, a) {
1245
1289
  let r = [];
1246
1290
  for (let i = 1; i < e.length; i++) {
1247
1291
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
1248
- if (!(s <= 0)) for (let e of _e(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1292
+ if (!(s <= 0)) for (let e of ve(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1249
1293
  bandStart: a,
1250
1294
  bandSize: s,
1251
1295
  ...e
@@ -1253,7 +1297,7 @@ function tt(e, t, n, r, i, a) {
1253
1297
  }
1254
1298
  return r;
1255
1299
  }, f = d(E, T.sizes, (e) => u(e, A, O.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), p = d(A, O.sizes, (e) => u(e, E, T.sizes, l, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
1256
- e.decorationRuns = ve({
1300
+ e.decorationRuns = ye({
1257
1301
  glyphs: S(o.glyphSet),
1258
1302
  ruleX: o.ruleX,
1259
1303
  ruleY: o.ruleY,
@@ -1281,7 +1325,7 @@ function tt(e, t, n, r, i, a) {
1281
1325
  height: N
1282
1326
  };
1283
1327
  for (let n of ee) {
1284
- let r = lt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = lt(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
1328
+ let r = pt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = pt(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
1285
1329
  n.staticSlot = {
1286
1330
  kind: "grid",
1287
1331
  area: {
@@ -1296,14 +1340,14 @@ function tt(e, t, n, r, i, a) {
1296
1340
  }
1297
1341
  return N;
1298
1342
  }
1299
- function nt(e) {
1343
+ function ot(e) {
1300
1344
  let t = e.style.display === "grid";
1301
1345
  return {
1302
1346
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
1303
1347
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
1304
1348
  };
1305
1349
  }
1306
- function rt(e, t, n, r, i, a) {
1350
+ function st(e, t, n, r, i, a) {
1307
1351
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
1308
1352
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
1309
1353
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -1312,20 +1356,20 @@ function rt(e, t, n, r, i, a) {
1312
1356
  gap: n
1313
1357
  };
1314
1358
  }
1315
- function it(e) {
1359
+ function ct(e) {
1316
1360
  return {
1317
1361
  sizes: e.sizes,
1318
1362
  gapBefore: e.gapBefore,
1319
1363
  limits: e.sizes
1320
1364
  };
1321
1365
  }
1322
- function at(e, t, n, r) {
1366
+ function lt(e, t, n, r) {
1323
1367
  let i = [];
1324
1368
  return e.children.forEach((a, o) => {
1325
1369
  let s = e.placed.items[o], c = n[o];
1326
1370
  if (t[o].cols) {
1327
- let e = st(a, "cols", c, 0);
1328
- for (let t of ct(a, "cols", s, e, r)) i.push({
1371
+ let e = dt(a, "cols", c, 0);
1372
+ for (let t of ft(a, "cols", s, e, r)) i.push({
1329
1373
  ...t,
1330
1374
  start: t.start + s.col.start
1331
1375
  });
@@ -1334,33 +1378,33 @@ function at(e, t, n, r) {
1334
1378
  i.push({
1335
1379
  start: s.col.start,
1336
1380
  span: s.col.span,
1337
- min: _t(a, "min", r) + ht(c),
1338
- max: _t(a, "max", r) + ht(c)
1381
+ min: xt(a, "min", r) + yt(c),
1382
+ max: xt(a, "max", r) + yt(c)
1339
1383
  });
1340
1384
  }), i;
1341
1385
  }
1342
- function ot(e, t, n) {
1386
+ function ut(e, t, n) {
1343
1387
  let r = [];
1344
1388
  return e.children.forEach((i, a) => {
1345
1389
  let o = e.placed.items[a], s = n[a];
1346
1390
  if (t[a].rows) {
1347
- let e = st(i, "rows", s, 0);
1348
- for (let t of ct(i, "rows", o, e)) r.push({
1391
+ let e = dt(i, "rows", s, 0);
1392
+ for (let t of ft(i, "rows", o, e)) r.push({
1349
1393
  ...t,
1350
1394
  start: t.start + o.row.start
1351
1395
  });
1352
1396
  return;
1353
1397
  }
1354
- let c = i.localRect.height + gt(s);
1398
+ let c = i.localRect.height + bt(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? bt(s) : c;
1355
1399
  r.push({
1356
1400
  start: o.row.start,
1357
1401
  span: o.row.span,
1358
- min: c,
1402
+ min: l,
1359
1403
  max: c
1360
1404
  });
1361
1405
  }), r;
1362
1406
  }
1363
- function st(e, t, n, r) {
1407
+ function dt(e, t, n, r) {
1364
1408
  let { border: i, padding: a } = e.style;
1365
1409
  return t === "cols" ? {
1366
1410
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -1370,15 +1414,15 @@ function st(e, t, n, r) {
1370
1414
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
1371
1415
  };
1372
1416
  }
1373
- function ct(e, t, n, r, i) {
1374
- let a = t === "cols" ? n.col.span : n.row.span, o = dt(e, void 0, void 0, 0, 0, {
1417
+ function ft(e, t, n, r, i) {
1418
+ let a = t === "cols" ? n.col.span : n.row.span, o = ht(e, void 0, void 0, 0, 0, {
1375
1419
  col: n.col.span,
1376
1420
  row: n.row.span
1377
1421
  }), s = [];
1378
1422
  if (o.children.forEach((e, n) => {
1379
1423
  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);
1380
- if (nt(e)[t]) {
1381
- let n = st(e, t, p, 0), a = ct(e, t, c, {
1424
+ if (ot(e)[t]) {
1425
+ let n = dt(e, t, p, 0), a = ft(e, t, c, {
1382
1426
  start: n.start + (u ? r.start : 0),
1383
1427
  end: n.end + (d ? r.end : 0)
1384
1428
  }, i);
@@ -1391,11 +1435,11 @@ function ct(e, t, n, r, i) {
1391
1435
  if (t === "cols") s.push({
1392
1436
  start: l.start,
1393
1437
  span: l.span,
1394
- min: _t(e, "min", i) + ht(p) + f,
1395
- max: _t(e, "max", i) + ht(p) + f
1438
+ min: xt(e, "min", i) + yt(p) + f,
1439
+ max: xt(e, "max", i) + yt(p) + f
1396
1440
  });
1397
1441
  else {
1398
- let t = e.localRect.height + gt(p) + f;
1442
+ let t = e.localRect.height + bt(p) + f;
1399
1443
  s.push({
1400
1444
  start: l.start,
1401
1445
  span: l.span,
@@ -1414,9 +1458,9 @@ function ct(e, t, n, r, i) {
1414
1458
  }
1415
1459
  return s;
1416
1460
  }
1417
- function lt(e, t, n, r, i, a, o, s) {
1418
- let c = Ct(e, "start", n), l = Ct(t, "end", n);
1419
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = wt(c, t, 1, n) : l !== null && e.kind === "span" && (c = wt(l, e, -1, n));
1461
+ function pt(e, t, n, r, i, a, o, s) {
1462
+ let c = Dt(e, "start", n), l = Dt(t, "end", n);
1463
+ c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = Ot(c, t, 1, n) : l !== null && e.kind === "span" && (c = Ot(l, e, -1, n));
1420
1464
  let u = i.length, d = (e) => {
1421
1465
  if (e === null) return;
1422
1466
  let t = e - r;
@@ -1427,22 +1471,22 @@ function lt(e, t, n, r, i, a, o, s) {
1427
1471
  end: h === void 0 ? s : p(h)
1428
1472
  };
1429
1473
  }
1430
- function ut(e, t) {
1474
+ function mt(e, t) {
1431
1475
  let n = t.gridIntrinsic.get(e);
1432
1476
  if (n !== void 0) return n;
1433
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = dt(e, void 0, void 0, i, 0, e.subgrid ? {
1477
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = ht(e, void 0, void 0, i, 0, e.subgrid ? {
1434
1478
  col: e.subgrid.colSpan,
1435
1479
  row: e.subgrid.rowSpan
1436
- } : void 0), o = a.children.map(nt), s = a.children.map((e) => G(e.style.margin, 0)), c = Dt(a.colTracks, a.colCollapsed, at(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1480
+ } : void 0), o = a.children.map(ot), s = a.children.map((e) => G(e.style.margin, 0)), c = jt(a.colTracks, a.colCollapsed, lt(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1437
1481
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1438
1482
  max: c.limits.reduce((e, t) => e + t, 0) + l
1439
1483
  };
1440
1484
  return t.gridIntrinsic.set(e, u), u;
1441
1485
  }
1442
- function dt(e, t, n, r, i, a) {
1443
- let o = e.style, s = mt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? ft(a.col) : vt(o.gridTemplateColumns, t, r), d = l ? ft(a.row) : vt(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1486
+ function ht(e, t, n, r, i, a) {
1487
+ let o = e.style, s = vt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? gt(a.col) : St(o.gridTemplateColumns, t, r), d = l ? gt(a.row) : St(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1444
1488
  if (f) {
1445
- c || bt(p, u.lineNames, f.columns, o.gridAutoColumns), l || bt(m, d.lineNames, f.rows, o.gridAutoRows);
1489
+ c || wt(p, u.lineNames, f.columns, o.gridAutoColumns), l || wt(m, d.lineNames, f.rows, o.gridAutoRows);
1446
1490
  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`);
1447
1491
  }
1448
1492
  let h = {
@@ -1451,28 +1495,28 @@ function dt(e, t, n, r, i, a) {
1451
1495
  }, g = {
1452
1496
  explicitCount: m.length,
1453
1497
  names: d.lineNames
1454
- }, _ = Et(s.map((e) => ({
1455
- col: Tt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1456
- row: Tt(e.style.gridRowStart, e.style.gridRowEnd, g)
1498
+ }, _ = At(s.map((e) => ({
1499
+ col: kt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1500
+ row: kt(e.style.gridRowStart, e.style.gridRowEnd, g)
1457
1501
  })), p.length, m.length, o.gridAutoFlow);
1458
- return c && pt(_, "col", p.length), l && pt(_, "row", m.length), {
1502
+ return c && _t(_, "col", p.length), l && _t(_, "row", m.length), {
1459
1503
  children: s,
1460
1504
  placed: _,
1461
1505
  colLines: h,
1462
1506
  rowLines: g,
1463
- colTracks: xt(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1464
- rowTracks: xt(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1465
- colCollapsed: St(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1466
- rowCollapsed: St(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1507
+ colTracks: Tt(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1508
+ rowTracks: Tt(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1509
+ colCollapsed: Et(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1510
+ rowCollapsed: Et(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1467
1511
  };
1468
1512
  }
1469
- function ft(e) {
1513
+ function gt(e) {
1470
1514
  return {
1471
- tracks: Array.from({ length: e }, () => et()),
1515
+ tracks: Array.from({ length: e }, () => it()),
1472
1516
  lineNames: Array.from({ length: e + 1 }, () => [])
1473
1517
  };
1474
1518
  }
1475
- function pt(e, t, n) {
1519
+ function _t(e, t, n) {
1476
1520
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1477
1521
  for (let i of e.items) {
1478
1522
  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);
@@ -1480,22 +1524,22 @@ function pt(e, t, n) {
1480
1524
  }
1481
1525
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1482
1526
  }
1483
- function mt(e) {
1527
+ function vt(e) {
1484
1528
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1485
1529
  }
1486
- function ht(e) {
1530
+ function yt(e) {
1487
1531
  return (e.left ?? 0) + (e.right ?? 0);
1488
1532
  }
1489
- function gt(e) {
1533
+ function bt(e) {
1490
1534
  return (e.top ?? 0) + (e.bottom ?? 0);
1491
1535
  }
1492
- function _t(e, t, n) {
1536
+ function xt(e, t, n) {
1493
1537
  let r = e.style, i;
1494
1538
  r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = q(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? Y(e, n) : J(e, n));
1495
1539
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1496
1540
  return Math.max(0, H(i, a, o));
1497
1541
  }
1498
- function vt(e, t, n) {
1542
+ function St(e, t, n) {
1499
1543
  if (e.kind !== "tracks") return {
1500
1544
  tracks: [],
1501
1545
  lineNames: [[]]
@@ -1508,7 +1552,7 @@ function vt(e, t, n) {
1508
1552
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1509
1553
  if (t !== void 0) {
1510
1554
  let e = a.reduce((e, n) => {
1511
- let r = yt(n.min, t) ?? yt(n.max, t) ?? 1;
1555
+ let r = Ct(n.min, t) ?? Ct(n.max, t) ?? 1;
1512
1556
  return e + Math.max(1, r);
1513
1557
  }, 0);
1514
1558
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1536,23 +1580,23 @@ function vt(e, t, n) {
1536
1580
  lineNames: d
1537
1581
  };
1538
1582
  }
1539
- function yt(e, t) {
1583
+ function Ct(e, t) {
1540
1584
  if (e.kind === "cells") return e.value;
1541
- if (e.kind === "percent" && t !== void 0) return xe(e.value, t);
1585
+ if (e.kind === "percent" && t !== void 0) return Ce(e.value, t);
1542
1586
  if (e.kind === "math") {
1543
1587
  let n = [];
1544
1588
  for (let r of e.args) {
1545
- let e = yt(r, t);
1589
+ let e = Ct(r, t);
1546
1590
  if (e === void 0) return;
1547
1591
  n.push(e);
1548
1592
  }
1549
1593
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1550
1594
  }
1551
1595
  }
1552
- function bt(e, t, n, r) {
1596
+ function wt(e, t, n, r) {
1553
1597
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1554
1598
  }
1555
- function xt(e, t, n, r) {
1599
+ function Tt(e, t, n, r) {
1556
1600
  let i = [];
1557
1601
  for (let a = 0; a < n; a++) {
1558
1602
  let n = a + t;
@@ -1564,7 +1608,7 @@ function xt(e, t, n, r) {
1564
1608
  }
1565
1609
  return i;
1566
1610
  }
1567
- function St(e, t, n, r) {
1611
+ function Et(e, t, n, r) {
1568
1612
  let i = Array.from({ length: n }, () => !1);
1569
1613
  if (!e.autoFit) return i;
1570
1614
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1573,7 +1617,7 @@ function St(e, t, n, r) {
1573
1617
  }
1574
1618
  return i;
1575
1619
  }
1576
- function Ct(e, t, n) {
1620
+ function Dt(e, t, n) {
1577
1621
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1578
1622
  if (e.kind !== "name") return null;
1579
1623
  if (e.nth === void 0) {
@@ -1588,14 +1632,14 @@ function Ct(e, t, n) {
1588
1632
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1589
1633
  return -(-r - a);
1590
1634
  }
1591
- function wt(e, t, n, r) {
1635
+ function Ot(e, t, n, r) {
1592
1636
  if (t.name === void 0) return e + n * t.value;
1593
1637
  let i = t.value, a = e;
1594
1638
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1595
1639
  return a;
1596
1640
  }
1597
- function Tt(e, t, n) {
1598
- let r = Ct(e, "start", n), i = Ct(t, "end", n);
1641
+ function kt(e, t, n) {
1642
+ let r = Dt(e, "start", n), i = Dt(t, "end", n);
1599
1643
  if (r !== null && i !== null) return r === i ? {
1600
1644
  start: r,
1601
1645
  span: 1
@@ -1605,10 +1649,10 @@ function Tt(e, t, n) {
1605
1649
  };
1606
1650
  if (r !== null) return {
1607
1651
  start: r,
1608
- span: (t.kind === "span" ? wt(r, t, 1, n) : r + 1) - r
1652
+ span: (t.kind === "span" ? Ot(r, t, 1, n) : r + 1) - r
1609
1653
  };
1610
1654
  if (i !== null) {
1611
- let t = e.kind === "span" ? wt(i, e, -1, n) : i - 1;
1655
+ let t = e.kind === "span" ? Ot(i, e, -1, n) : i - 1;
1612
1656
  return {
1613
1657
  start: t,
1614
1658
  span: i - t
@@ -1619,7 +1663,7 @@ function Tt(e, t, n) {
1619
1663
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1620
1664
  };
1621
1665
  }
1622
- function Et(e, t, n, r) {
1666
+ function At(e, t, n, r) {
1623
1667
  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);
1624
1668
  for (let t = 0; t < e.length; t++) {
1625
1669
  let e = o[t];
@@ -1716,7 +1760,7 @@ function Et(e, t, n, r) {
1716
1760
  rowCount: S
1717
1761
  };
1718
1762
  }
1719
- function Dt(e, t, n, r, i, a) {
1763
+ function jt(e, t, n, r, i, a) {
1720
1764
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1721
1765
  if (t[n]) return {
1722
1766
  base: 0,
@@ -1726,7 +1770,7 @@ function Dt(e, t, n, r, i, a) {
1726
1770
  frFactor: 0,
1727
1771
  collapsed: !0
1728
1772
  };
1729
- let r = yt(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1773
+ let r = Ct(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1730
1774
  if (s.kind === "fr") return {
1731
1775
  base: i,
1732
1776
  limit: null,
@@ -1735,7 +1779,7 @@ function Dt(e, t, n, r, i, a) {
1735
1779
  frFactor: s.value,
1736
1780
  collapsed: !1
1737
1781
  };
1738
- let c = yt(s, o);
1782
+ let c = Ct(s, o);
1739
1783
  return c === void 0 ? {
1740
1784
  base: i,
1741
1785
  limit: null,
@@ -1860,65 +1904,65 @@ function Dt(e, t, n, r, i, a) {
1860
1904
  limits: s.map((e) => u(e))
1861
1905
  };
1862
1906
  }
1863
- function Ot(e, t, n) {
1864
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - kt(e)), o = L(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1907
+ function Mt(e, t, n) {
1908
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Nt(e)), o = L(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1865
1909
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1866
1910
  return s;
1867
1911
  }
1868
- function kt(e) {
1912
+ function Nt(e) {
1869
1913
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1870
1914
  }
1871
- function At(e, t, n, r) {
1915
+ function Pt(e, t, n, r) {
1872
1916
  let i = n + r - 1;
1873
1917
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1874
1918
  }
1875
- function jt(e, t, n, r, i) {
1919
+ function Ft(e, t, n, r, i) {
1876
1920
  let a = t ?? 0, o = n ?? 0, s = r - i;
1877
- return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + qe(e, r, i + a + o);
1921
+ return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + z(e, r, i + a + o);
1878
1922
  }
1879
1923
  //#endregion
1880
1924
  //#region src/multicol.ts
1881
- function Mt(e, t, n) {
1925
+ function It(e, t, n) {
1882
1926
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1883
1927
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1884
1928
  }
1885
- function Nt(e, t, n) {
1886
- let r = Mt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1929
+ function Lt(e, t, n) {
1930
+ let r = It(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1887
1931
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1888
1932
  }
1889
- function Pt(e, t) {
1933
+ function Rt(e, t) {
1890
1934
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1891
1935
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1892
1936
  }
1893
- function Ft(e, t) {
1937
+ function zt(e, t) {
1894
1938
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1895
1939
  }
1896
- function It(e, t, n) {
1940
+ function Bt(e, t, n) {
1897
1941
  for (; e < t;) {
1898
1942
  let r = e + t >> 1;
1899
1943
  n(r) ? t = r : e = r + 1;
1900
1944
  }
1901
1945
  return e;
1902
1946
  }
1903
- function Lt(e, t, n) {
1904
- let r = Mt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1947
+ function Vt(e, t, n) {
1948
+ let r = It(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1905
1949
  return {
1906
1950
  count: r,
1907
1951
  width: i,
1908
1952
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1909
1953
  };
1910
1954
  }
1911
- function Rt(e, t, n) {
1955
+ function Ht(e, t, n) {
1912
1956
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1913
1957
  }
1914
- function zt(e, t, n, r) {
1915
- let i = Ln(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Rn(e, i), s = e.style.lineGap, c = Vt(a.map((e) => e + s)), l;
1958
+ function Ut(e, t, n, r) {
1959
+ let i = Vn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Hn(e, i), s = e.style.lineGap, c = Gt(a.map((e) => e + s)), l;
1916
1960
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1917
1961
  else {
1918
- let e = It(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Bt(c, s, e).columns <= t.count);
1962
+ let e = Bt(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Wt(c, s, e).columns <= t.count);
1919
1963
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1920
1964
  }
1921
- let u = Bt(c, s, l);
1965
+ let u = Wt(c, s, l);
1922
1966
  return {
1923
1967
  spans: i,
1924
1968
  lineY: u.top,
@@ -1931,7 +1975,7 @@ function zt(e, t, n, r) {
1931
1975
  columnsUsed: i.length > 0 ? u.columns : 0
1932
1976
  };
1933
1977
  }
1934
- function Bt(e, t, n, r = "truncate") {
1978
+ function Wt(e, t, n, r = "truncate") {
1935
1979
  let i = 0, a = 0, o = 0, s = [], c = [];
1936
1980
  for (let l = 0; l < e.length; l++) {
1937
1981
  let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
@@ -1952,7 +1996,7 @@ function Bt(e, t, n, r = "truncate") {
1952
1996
  top: c
1953
1997
  };
1954
1998
  }
1955
- function Vt(e) {
1999
+ function Gt(e) {
1956
2000
  return e.map((e) => ({
1957
2001
  rows: e,
1958
2002
  pre: 0,
@@ -1961,27 +2005,27 @@ function Vt(e) {
1961
2005
  lines: 1
1962
2006
  }));
1963
2007
  }
1964
- var Ht = null;
1965
- function Ut() {
1966
- if (Ht !== null) return Ht;
2008
+ var Kt = null;
2009
+ function qt() {
2010
+ if (Kt !== null) return Kt;
1967
2011
  let e = document.createElement("div");
1968
2012
  e.style.cssText = "position:absolute;left:-9999px;visibility:hidden;columns:2;column-gap:0;column-fill:balance;width:200px;font:10px/20px monospace;orphans:1;widows:1", e.innerHTML = "<div style=\"margin:0;padding:0 0 20px 0\">aaaaaa aaaaaa aaaaaa</div><div style=\"margin:0\"><span>bbbbbb</span> bbbbbb</div>", document.body.appendChild(e);
1969
2013
  let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
1970
- return e.remove(), Ht = !(n.width > 0 && n.top - t >= 10), Ht;
2014
+ return e.remove(), Kt = !(n.width > 0 && n.top - t >= 10), Kt;
1971
2015
  }
1972
- function Wt(e, t) {
1973
- let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = Oe(e, Math.max(1, n - i), {
2016
+ function Jt(e, t) {
2017
+ let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = Ae(e, Math.max(1, n - i), {
1974
2018
  advances: s,
1975
2019
  tracking: i,
1976
2020
  firstLineIndent: t.firstLineIndent
1977
- }), l = Vt(c.map(() => 1 + a)), u = Bt(l, a, o ?? It(1, Math.max(1, c.length * (1 + a) - a), (e) => Bt(l, a, e).columns <= r));
2021
+ }), l = Gt(c.map(() => 1 + a)), u = Wt(l, a, o ?? Bt(1, Math.max(1, c.length * (1 + a) - a), (e) => Wt(l, a, e).columns <= r));
1978
2022
  return c.map((t, n) => ({
1979
2023
  text: e.slice(t.start, t.end),
1980
2024
  column: u.column[n],
1981
2025
  top: u.top[n]
1982
2026
  }));
1983
2027
  }
1984
- function Gt(e, t, n, r) {
2028
+ function Yt(e, t, n, r) {
1985
2029
  let i = e.style;
1986
2030
  if (!i.ruleX) return;
1987
2031
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -1991,18 +2035,18 @@ function Gt(e, t, n, r) {
1991
2035
  }], s = [];
1992
2036
  for (let e of o) {
1993
2037
  let n = Math.min(e.columns, t.columnCount);
1994
- for (let r = 0; r < t.columnCount - 1; r++) Rt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
2038
+ for (let r = 0; r < t.columnCount - 1; r++) Ht(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1995
2039
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
1996
2040
  bandSize: t.gap,
1997
2041
  start: e.start,
1998
2042
  end: e.end
1999
2043
  });
2000
2044
  }
2001
- e.decorationRuns = ve({
2045
+ e.decorationRuns = ye({
2002
2046
  glyphs: S(i.glyphSet),
2003
2047
  ruleX: i.ruleX,
2004
2048
  ruleY: null,
2005
- vertical: ze(s, i.ruleInset),
2049
+ vertical: Ve(s, i.ruleInset),
2006
2050
  horizontal: [],
2007
2051
  contentWidth: a,
2008
2052
  contentHeight: t.totalRows,
@@ -2012,12 +2056,12 @@ function Gt(e, t, n, r) {
2012
2056
  padding: r
2013
2057
  });
2014
2058
  }
2015
- function Kt(e, t) {
2059
+ function Xt(e, t) {
2016
2060
  let n = e.style, r = n.padding;
2017
- return e.text !== "" && e.children.length === 0 && n.display === "block" && n.position === "static" && !n.columnSpan && n.whiteSpace === "normal" && n.lineGap === t.lineGap && n.border.top === 0 && n.border.right === 0 && n.border.bottom === 0 && n.border.left === 0 && r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0 && n.backgroundColor === void 0 && !n.backgroundClear && (n.width === void 0 || n.width.kind === "auto") && (n.height === void 0 || n.height.kind === "auto") && (n.minWidth === "auto" || n.minWidth === 0 || n.minWidth === void 0) && (n.minHeight === "auto" || n.minHeight === 0 || n.minHeight === void 0) && n.maxWidth === void 0 && n.maxHeight === void 0;
2061
+ return e.text !== "" && e.children.length === 0 && n.display === "block" && n.position === "static" && !n.columnSpan && n.whiteSpace === "normal" && n.lineGap === t.lineGap && n.border.top === 0 && n.border.right === 0 && n.border.bottom === 0 && n.border.left === 0 && r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0 && n.backgroundColor === void 0 && !n.backgroundClear && n.overflow.x === "visible" && n.overflow.y === "visible" && (n.width === void 0 || n.width.kind === "auto") && (n.height === void 0 || n.height.kind === "auto") && (n.minWidth === "auto" || n.minWidth === 0 || n.minWidth === void 0) && (n.minHeight === "auto" || n.minHeight === 0 || n.minHeight === void 0) && n.maxWidth === void 0 && n.maxHeight === void 0;
2018
2062
  }
2019
- function qt(e, t, n, r, i, a, o) {
2020
- let s = e.style, c = U(s, "x", n), l = Lt(s, n, c);
2063
+ function Zt(e, t, n, r, i, a, o) {
2064
+ let s = e.style, c = U(s, "x", n), l = Vt(s, n, c);
2021
2065
  a.right += l.leftover;
2022
2066
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
2023
2067
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
@@ -2027,13 +2071,13 @@ function qt(e, t, n, r, i, a, o) {
2027
2071
  if (t.length > 0) {
2028
2072
  let i = t.map((e) => ({
2029
2073
  node: e,
2030
- spans: Ln(e, Math.max(1, l.width - e.style.tracking)),
2074
+ spans: Vn(e, Math.max(1, l.width - e.style.tracking)),
2031
2075
  margin: G(e.style.margin, l.width),
2032
2076
  pre: 0,
2033
2077
  post: 0
2034
2078
  })), a = [], o = null, h = null, x = !1;
2035
2079
  for (let e of i) {
2036
- let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : Un(o, r.top ?? 0), s = i;
2080
+ let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : qn(o, r.top ?? 0), s = i;
2037
2081
  _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
2038
2082
  let c = x || t.style.breakBeforeColumn;
2039
2083
  if (t.style.breakInsideAvoid && n.length > 0) a.push({
@@ -2056,10 +2100,10 @@ function qt(e, t, n, r, i, a, o) {
2056
2100
  let S;
2057
2101
  if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
2058
2102
  else {
2059
- let e = It(1, Math.max(1, Bt(a, u, Infinity, _).maxUsed), (e) => Bt(a, u, e, _).columns <= l.count);
2103
+ let e = Bt(1, Math.max(1, Wt(a, u, Infinity, _).maxUsed), (e) => Wt(a, u, e, _).columns <= l.count);
2060
2104
  S = r === void 0 ? e : Math.max(1, Math.min(e, r));
2061
2105
  }
2062
- let C = Bt(a, u, S, _);
2106
+ let C = Wt(a, u, S, _);
2063
2107
  for (let e = 0, t = 0; e < i.length; e++) {
2064
2108
  let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
2065
2109
  for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
@@ -2100,7 +2144,7 @@ function qt(e, t, n, r, i, a, o) {
2100
2144
  if (i) {
2101
2145
  let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2102
2146
  V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2103
- let r = Hn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2147
+ let r = Kn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2104
2148
  y += a, i.localRect = {
2105
2149
  ...i.localRect,
2106
2150
  x: d + r,
@@ -2139,10 +2183,10 @@ function qt(e, t, n, r, i, a, o) {
2139
2183
  } : {}
2140
2184
  }, x;
2141
2185
  }
2142
- function Jt(e, t, n, r, i, a, o) {
2143
- let s = e.style, c = Ft(n, r), l = e.children.filter((e) => !B(e.style)), u = l.filter((e) => !e.style.columnSpan), d = l.reduce((e, t, n) => !t.style.columnSpan && (n === 0 || l[n - 1].style.columnSpan) ? e + 1 : e, 0);
2144
- if (u.length > 0 && u.every((e) => Kt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (Ut() || d <= 1 && u.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null))))) return qt(e, l, t, c, i, a, o);
2145
- let f = U(s, "x", t), p = Nt(s, t, f), m = p.length, h = [];
2186
+ function Qt(e, t, n, r, i, a, o) {
2187
+ let s = e.style, c = zt(n, r), l = e.children.filter((e) => !B(e.style)), u = l.filter((e) => !e.style.columnSpan), d = l.reduce((e, t, n) => !t.style.columnSpan && (n === 0 || l[n - 1].style.columnSpan) ? e + 1 : e, 0);
2188
+ if (u.length > 0 && u.every((e) => Xt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (qt() || d <= 1 && u.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null))))) return Zt(e, l, t, c, i, a, o);
2189
+ let f = U(s, "x", t), p = Lt(s, t, f), m = p.length, h = [];
2146
2190
  {
2147
2191
  let e = 0;
2148
2192
  for (let t of p) h.push(e), e += t + f;
@@ -2151,7 +2195,7 @@ function Jt(e, t, n, r, i, a, o) {
2151
2195
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
2152
2196
  if (t) for (let t of T) {
2153
2197
  if (t.index !== e) continue;
2154
- let n = a === null ? t.margin.top ?? 0 : Un(a, t.margin.top ?? 0);
2198
+ let n = a === null ? t.margin.top ?? 0 : qn(a, t.margin.top ?? 0);
2155
2199
  t.child.staticSlot = {
2156
2200
  kind: "block",
2157
2201
  x: y + g(r) + (t.margin.left ?? 0),
@@ -2162,7 +2206,7 @@ function Jt(e, t, n, r, i, a, o) {
2162
2206
  for (let l = 0; l < w.length; l++) {
2163
2207
  let u = w[l];
2164
2208
  c(l);
2165
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : Un(a, u.margin.top ?? 0), f = u.node.localRect.height;
2209
+ let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : qn(a, u.margin.top ?? 0), f = u.node.localRect.height;
2166
2210
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
2167
2211
  let e = u.node, t = _(r);
2168
2212
  if (t !== v) {
@@ -2171,7 +2215,7 @@ function Jt(e, t, n, r, i, a, o) {
2171
2215
  }
2172
2216
  e.localRect = {
2173
2217
  ...e.localRect,
2174
- x: y + g(r) + Hn(u.margin, t, e.localRect.width),
2218
+ x: y + g(r) + Kn(u.margin, t, e.localRect.width),
2175
2219
  y: b + C + i + d
2176
2220
  };
2177
2221
  }
@@ -2194,13 +2238,13 @@ function Jt(e, t, n, r, i, a, o) {
2194
2238
  let e = c === void 0 ? void 0 : Math.max(1, c - C), t = s.columnFill === "auto" && e !== void 0, r;
2195
2239
  if (t) r = e;
2196
2240
  else {
2197
- let t = It(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2241
+ let t = Bt(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2198
2242
  r = e === void 0 ? t : Math.min(t, e);
2199
2243
  }
2200
2244
  let i = D(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2201
2245
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
2202
2246
  let t = Math.min(i.columns, m);
2203
- Rt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2247
+ Ht(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2204
2248
  bandStart: h[e] + p[e],
2205
2249
  bandSize: f,
2206
2250
  start: C,
@@ -2223,7 +2267,7 @@ function Jt(e, t, n, r, i, a, o) {
2223
2267
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2224
2268
  V(r, Math.max(0, t - i), n, 0, 0, "fill", o), C += e.top ?? 0, r.localRect = {
2225
2269
  ...r.localRect,
2226
- x: y + Hn(e, t, r.localRect.width),
2270
+ x: y + Kn(e, t, r.localRect.width),
2227
2271
  y: b + C
2228
2272
  }, C += r.localRect.height + (e.bottom ?? 0);
2229
2273
  continue;
@@ -2235,11 +2279,11 @@ function Jt(e, t, n, r, i, a, o) {
2235
2279
  breakBefore: E || r.style.breakBeforeColumn
2236
2280
  }), E = r.style.breakAfterColumn;
2237
2281
  }
2238
- return O(), s.ruleX && x.length > 0 && (e.decorationRuns = ve({
2282
+ return O(), s.ruleX && x.length > 0 && (e.decorationRuns = ye({
2239
2283
  glyphs: S(s.glyphSet),
2240
2284
  ruleX: s.ruleX,
2241
2285
  ruleY: null,
2242
- vertical: ze(x, s.ruleInset),
2286
+ vertical: Ve(x, s.ruleInset),
2243
2287
  horizontal: [],
2244
2288
  contentWidth: t,
2245
2289
  contentHeight: C,
@@ -2251,32 +2295,32 @@ function Jt(e, t, n, r, i, a, o) {
2251
2295
  }
2252
2296
  //#endregion
2253
2297
  //#region src/table.ts
2254
- function Yt(e, t) {
2255
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && M(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).");
2298
+ function $t(e, t) {
2299
+ e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && N(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).");
2256
2300
  }
2257
- function Xt(e, t) {
2301
+ function en(e, t) {
2258
2302
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
2259
2303
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
2260
2304
  }
2261
- function Zt(e, t, n) {
2305
+ function tn(e, t, n) {
2262
2306
  let r = (t, r) => {
2263
2307
  let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? q(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
2264
2308
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
2265
2309
  };
2266
2310
  if (t.style.tableRole === "column") {
2267
- r(t, Qt(t.source));
2311
+ r(t, nn(t.source));
2268
2312
  return;
2269
2313
  }
2270
2314
  let i = t.children.filter((e) => e.style.tableRole === "column");
2271
- if (i.length === 0) r(t, Qt(t.source));
2272
- else for (let e of i) r(e, Qt(e.source));
2273
- for (let n of t.children) n.style.tableRole !== "column" && Yt(e, n);
2315
+ if (i.length === 0) r(t, nn(t.source));
2316
+ else for (let e of i) r(e, nn(e.source));
2317
+ for (let n of t.children) n.style.tableRole !== "column" && $t(e, n);
2274
2318
  }
2275
- function Qt(e) {
2319
+ function nn(e) {
2276
2320
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
2277
2321
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
2278
2322
  }
2279
- function $t(e, t) {
2323
+ function rn(e, t) {
2280
2324
  let n = {
2281
2325
  caption: null,
2282
2326
  rows: [],
@@ -2300,8 +2344,8 @@ function $t(e, t) {
2300
2344
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
2301
2345
  row: e,
2302
2346
  group: o
2303
- }) : Yt(n, e));
2304
- } else e === "caption" ? n.caption === null ? n.caption = o : Yt(n, o) : e === "column" || e === "column-group" ? (Zt(n, o, t), n.hidden.push(o)) : Yt(n, o);
2347
+ }) : $t(n, e));
2348
+ } else e === "caption" ? n.caption === null ? n.caption = o : $t(n, o) : e === "column" || e === "column-group" ? (tn(n, o, t), n.hidden.push(o)) : $t(n, o);
2305
2349
  }
2306
2350
  let o = [
2307
2351
  ...r,
@@ -2316,20 +2360,20 @@ function $t(e, t) {
2316
2360
  s = e + 1;
2317
2361
  }
2318
2362
  }
2319
- return en(n), n;
2363
+ return an(n), n;
2320
2364
  }
2321
- function en(e) {
2365
+ function an(e) {
2322
2366
  let t = [];
2323
2367
  for (let n = 0; n < e.rows.length; n++) {
2324
2368
  let r = e.rows[n], i = 0;
2325
2369
  for (let a of r.children) {
2326
2370
  if (B(a.style)) continue;
2327
2371
  if (a.style.tableRole !== "cell") {
2328
- Yt(e, a);
2372
+ $t(e, a);
2329
2373
  continue;
2330
2374
  }
2331
2375
  for (; (t[i] ?? 0) > n;) i++;
2332
- let o = Xt(a.source, "colspan"), s = Xt(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2376
+ let o = en(a.source, "colspan"), s = en(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2333
2377
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
2334
2378
  e.cells.push({
2335
2379
  node: a,
@@ -2343,7 +2387,7 @@ function en(e) {
2343
2387
  }
2344
2388
  e.columnCount = Math.max(t.length, e.colFixed.length);
2345
2389
  }
2346
- function tn(e, t, n) {
2390
+ function on(e, t, n) {
2347
2391
  let r = e.style, i = Y(e, n), a;
2348
2392
  if (t === "min") a = i;
2349
2393
  else {
@@ -2353,11 +2397,11 @@ function tn(e, t, n) {
2353
2397
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
2354
2398
  return Math.max(0, H(a, o, s));
2355
2399
  }
2356
- function nn(e) {
2400
+ function sn(e) {
2357
2401
  let t = e.style.width;
2358
2402
  return t && t.kind === "percent" ? t.value : void 0;
2359
2403
  }
2360
- function rn(e, t, n) {
2404
+ function cn(e, t, n) {
2361
2405
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
2362
2406
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
2363
2407
  let s = [];
@@ -2366,15 +2410,15 @@ function rn(e, t, n) {
2366
2410
  s.push(t);
2367
2411
  continue;
2368
2412
  }
2369
- i[t.col] = Math.max(i[t.col], tn(t.node, "min", n)), a[t.col] = Math.max(a[t.col], tn(t.node, "max", n));
2370
- let e = nn(t.node);
2413
+ i[t.col] = Math.max(i[t.col], on(t.node, "min", n)), a[t.col] = Math.max(a[t.col], on(t.node, "max", n));
2414
+ let e = sn(t.node);
2371
2415
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
2372
2416
  }
2373
2417
  s.sort((e, t) => e.colSpan - t.colSpan);
2374
2418
  for (let e of s) {
2375
- let r = e.col, o = e.col + e.colSpan, s = dn(t, r, o), c = a.slice(r, o);
2419
+ let r = e.col, o = e.col + e.colSpan, s = hn(t, r, o), c = a.slice(r, o);
2376
2420
  for (let t of ["min", "max"]) {
2377
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = tn(e.node, t, n) - u;
2421
+ let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = on(e.node, t, n) - u;
2378
2422
  if (d <= 0) continue;
2379
2423
  let f = R(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2380
2424
  for (let e = r; e < o; e++) l[e] += f[e - r];
@@ -2387,7 +2431,7 @@ function rn(e, t, n) {
2387
2431
  percent: o
2388
2432
  };
2389
2433
  }
2390
- function an(e, t) {
2434
+ function ln(e, t) {
2391
2435
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
2392
2436
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2393
2437
  if (i.length > 0) {
@@ -2416,7 +2460,7 @@ function an(e, t) {
2416
2460
  }
2417
2461
  return r;
2418
2462
  }
2419
- function on(e, t, n) {
2463
+ function un(e, t, n) {
2420
2464
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2421
2465
  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];
2422
2466
  for (let r of e.cells) {
@@ -2436,13 +2480,13 @@ function on(e, t, n) {
2436
2480
  }
2437
2481
  return i.map((e) => e ?? 0);
2438
2482
  }
2439
- var sn = {
2483
+ var dn = {
2440
2484
  double: 3,
2441
2485
  solid: 2,
2442
2486
  dashed: 1,
2443
2487
  dotted: 0
2444
2488
  };
2445
- function cn(e) {
2489
+ function fn(e) {
2446
2490
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2447
2491
  let t = null;
2448
2492
  for (let { border: n, side: r } of e) {
@@ -2450,7 +2494,7 @@ function cn(e) {
2450
2494
  let e = n.width[r];
2451
2495
  if (e <= 0) continue;
2452
2496
  let i = n.style[r];
2453
- (t === null || e > t.width || e === t.width && sn[i] > sn[t.style]) && (t = {
2497
+ (t === null || e > t.width || e === t.width && dn[i] > dn[t.style]) && (t = {
2454
2498
  width: e,
2455
2499
  style: i,
2456
2500
  color: n.color[r]
@@ -2458,7 +2502,7 @@ function cn(e) {
2458
2502
  }
2459
2503
  return t;
2460
2504
  }
2461
- function ln(e, t) {
2505
+ function pn(e, t) {
2462
2506
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2463
2507
  collapsed: i,
2464
2508
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2503,7 +2547,7 @@ function ln(e, t) {
2503
2547
  side: u
2504
2548
  });
2505
2549
  }
2506
- i.push(cn(l));
2550
+ i.push(fn(l));
2507
2551
  }
2508
2552
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2509
2553
  }
@@ -2542,47 +2586,47 @@ function ln(e, t) {
2542
2586
  }), e === r && l.push({
2543
2587
  border: s,
2544
2588
  side: "bottom"
2545
- }), i.push(cn(l));
2589
+ }), i.push(fn(l));
2546
2590
  }
2547
2591
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2548
2592
  }
2549
2593
  return a;
2550
2594
  }
2551
- function un(e, t) {
2595
+ function mn(e, t) {
2552
2596
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2553
2597
  }
2554
- function dn(e, t, n) {
2598
+ function hn(e, t, n) {
2555
2599
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2556
2600
  let r = 0;
2557
2601
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2558
2602
  return r;
2559
2603
  }
2560
- function fn(e, t, n) {
2604
+ function gn(e, t, n) {
2561
2605
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2562
2606
  let r = 0;
2563
2607
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2564
2608
  return r;
2565
2609
  }
2566
- function pn(e, t) {
2610
+ function _n(e, t) {
2567
2611
  let n = t.tableData.get(e);
2568
2612
  if (n) return n;
2569
- let r = $t(e, t), i = ln(e, r), a = {
2613
+ let r = rn(e, t), i = pn(e, r), a = {
2570
2614
  structure: r,
2571
2615
  chrome: i,
2572
- bounds: rn(r, i, t),
2573
- chromeX: un(i, r.columnCount)
2616
+ bounds: cn(r, i, t),
2617
+ chromeX: mn(i, r.columnCount)
2574
2618
  };
2575
2619
  return t.tableData.set(e, a), a;
2576
2620
  }
2577
- function mn(e, t) {
2578
- let { structure: n, bounds: r, chromeX: i } = pn(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2621
+ function vn(e, t) {
2622
+ let { structure: n, bounds: r, chromeX: i } = _n(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2579
2623
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2580
2624
  min: a,
2581
2625
  max: o
2582
2626
  };
2583
2627
  }
2584
- function hn(e, t, n) {
2585
- let r = e.style, { bounds: i, chromeX: a } = pn(e, n), { min: o, max: s } = mn(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;
2628
+ function yn(e, t, n) {
2629
+ let r = e.style, { bounds: i, chromeX: a } = _n(e, n), { min: o, max: s } = vn(e, n), c = r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t) + tt(r).right, l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2586
2630
  for (let e = 0; e < i.max.length; e++) {
2587
2631
  let t = i.percent[e];
2588
2632
  t === void 0 ? d += i.max[e] : u += t;
@@ -2598,8 +2642,8 @@ function hn(e, t, n) {
2598
2642
  let f = Math.max(l + a, s) + c;
2599
2643
  return Math.max(o + c, Math.min(f, t));
2600
2644
  }
2601
- function gn(e, t, n, r, i, a) {
2602
- let { structure: o, chrome: s, bounds: c } = pn(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2645
+ function bn(e, t, n, r, i, a) {
2646
+ let { structure: o, chrome: s, bounds: c } = _n(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2603
2647
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2604
2648
  x: 0,
2605
2649
  y: 0,
@@ -2611,16 +2655,16 @@ function gn(e, t, n, r, i, a) {
2611
2655
  bottom: 0,
2612
2656
  left: 0
2613
2657
  }, e.unclampedHeight = 0;
2614
- let p = Math.max(0, t - un(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? on(o, p, a) : an(c, p), g = [], _ = 0;
2658
+ let p = Math.max(0, t - mn(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? un(o, p, a) : ln(c, p), g = [], _ = 0;
2615
2659
  for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2616
2660
  let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2617
2661
  o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2618
2662
  let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2619
2663
  for (let e of o.cells) {
2620
- let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + dn(s, e.col, t);
2664
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + hn(s, e.col, t);
2621
2665
  x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2622
2666
  }
2623
- 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 - y - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? xe(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2667
+ 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 - y - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? Ce(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2624
2668
  for (let e = 0; e < u; e++) {
2625
2669
  let t = o.rows[e].style.height;
2626
2670
  t !== void 0 && t.kind === "cells" && (E[e] = t.value);
@@ -2633,7 +2677,7 @@ function gn(e, t, n, r, i, a) {
2633
2677
  }
2634
2678
  let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2635
2679
  for (let e of O) {
2636
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + fn(s, e.row, t), r = b.get(e) - n;
2680
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + gn(s, e.row, t), r = b.get(e) - n;
2637
2681
  if (r <= 0) continue;
2638
2682
  let i = R(Array.from({ length: e.rowSpan }, () => 1), r);
2639
2683
  for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
@@ -2684,11 +2728,11 @@ function gn(e, t, n, r, i, a) {
2684
2728
  }, t.unclampedHeight = E[e];
2685
2729
  }
2686
2730
  for (let e of o.cells) {
2687
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + fn(s, e.row, t);
2731
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + gn(s, e.row, t);
2688
2732
  e.node.children.some((e) => !B(e.style) && e.style.height?.kind === "percent") && n !== b.get(e) && V(e.node, x.get(e), n, 0, 0, "fill", a, {
2689
2733
  width: x.get(e),
2690
2734
  height: n
2691
- }), _n(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2735
+ }), xn(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2692
2736
  x: g[e.col],
2693
2737
  y: 0,
2694
2738
  width: e.node.localRect.width,
@@ -2700,9 +2744,9 @@ function gn(e, t, n, r, i, a) {
2700
2744
  x: d,
2701
2745
  y: f
2702
2746
  });
2703
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = vn(s, o, h, E, g, A, d, f, S(e.style.glyphSet))), e.style.captionSide === "bottom" ? M + y : M;
2747
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Sn(s, o, h, E, g, A, d, f, S(e.style.glyphSet))), e.style.captionSide === "bottom" ? M + y : M;
2704
2748
  }
2705
- function _n(e, t) {
2749
+ function xn(e, t) {
2706
2750
  if (t <= 0) return;
2707
2751
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2708
2752
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2711,14 +2755,14 @@ function _n(e, t) {
2711
2755
  }
2712
2756
  if (!(r <= 0)) for (let t of e.children) t.inlineBox || (B(t.style) ? t.staticSlot?.kind === "block" && (t.staticSlot.y += r) : t.localRect.y += r);
2713
2757
  }
2714
- function vn(e, t, n, r, i, a, o, s, c) {
2758
+ function Sn(e, t, n, r, i, a, o, s, c) {
2715
2759
  let l = t.columnCount, u = t.rows.length, d = [], f = (t) => t < l ? i[t] - e.vLines[t] : i[l - 1] + n[l - 1], p = (t) => t < u ? a[t] - e.hLines[t] : a[u - 1] + r[u - 1];
2716
2760
  for (let t = 0; t <= l; t++) {
2717
2761
  let n = e.vSegments[t];
2718
2762
  for (let e = 0; e < u; e++) {
2719
2763
  let i = n[e];
2720
2764
  if (!i) continue;
2721
- let l = fe(i.style, "v", c);
2765
+ let l = pe(i.style, "v", c);
2722
2766
  for (let n = 0; n < i.width; n++) for (let c = a[e]; c < a[e] + r[e]; c++) d.push({
2723
2767
  glyph: l,
2724
2768
  x: o + f(t) + n,
@@ -2733,7 +2777,7 @@ function vn(e, t, n, r, i, a, o, s, c) {
2733
2777
  for (let e = 0; e < l; e++) {
2734
2778
  let a = r[e];
2735
2779
  if (!a) continue;
2736
- let l = fe(a.style, "h", c);
2780
+ let l = pe(a.style, "h", c);
2737
2781
  for (let r = 0; r < a.width; r++) d.push({
2738
2782
  glyph: l,
2739
2783
  x: o + i[e],
@@ -2752,7 +2796,7 @@ function vn(e, t, n, r, i, a, o, s, c) {
2752
2796
  m
2753
2797
  ].filter((e) => e !== null);
2754
2798
  if (h.length === 0) continue;
2755
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && sn[t.style] > sn[e.style] ? t : e), v = pe(g, r !== null, i !== null, a !== null, m !== null, c);
2799
+ let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && dn[t.style] > dn[e.style] ? t : e), v = me(g, r !== null, i !== null, a !== null, m !== null, c);
2756
2800
  for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) d.push({
2757
2801
  glyph: v,
2758
2802
  x: o + f(t) + r,
@@ -2765,30 +2809,30 @@ function vn(e, t, n, r, i, a, o, s, c) {
2765
2809
  }
2766
2810
  //#endregion
2767
2811
  //#region src/positioning.ts
2768
- function yn(e) {
2812
+ function Cn(e) {
2769
2813
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2770
2814
  }
2771
- function bn(e, t, n, r, i) {
2815
+ function wn(e, t, n, r, i) {
2772
2816
  for (let a of e.children) {
2773
- let o = yn(a.style);
2817
+ let o = Cn(a.style);
2774
2818
  if (o === "relative") {
2775
2819
  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;
2776
- a.localRect.x += xn(a.style.insets.left, a.style.insets.right, t), a.localRect.y += xn(a.style.insets.top, a.style.insets.bottom, n);
2777
- } else o === "absolute" && Cn(a, e, t, n, r, i);
2778
- bn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2820
+ a.localRect.x += Tn(a.style.insets.left, a.style.insets.right, t), a.localRect.y += Tn(a.style.insets.top, a.style.insets.bottom, n);
2821
+ } else o === "absolute" && Dn(a, e, t, n, r, i);
2822
+ wn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2779
2823
  node: a,
2780
2824
  absX: t + a.localRect.x,
2781
2825
  absY: n + a.localRect.y
2782
2826
  }], i);
2783
2827
  }
2784
2828
  }
2785
- function xn(e, t, n) {
2829
+ function Tn(e, t, n) {
2786
2830
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2787
2831
  }
2788
- function Sn(e, t) {
2832
+ function En(e, t) {
2789
2833
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2790
2834
  let n = e[t];
2791
- if (!jn(n.node.style)) continue;
2835
+ if (!Fn(n.node.style)) continue;
2792
2836
  let r = n.node.style.border;
2793
2837
  return {
2794
2838
  x: n.absX + r.left,
@@ -2805,13 +2849,13 @@ function Sn(e, t) {
2805
2849
  height: n.node.localRect.height
2806
2850
  };
2807
2851
  }
2808
- function Cn(e, t, n, r, i, a) {
2809
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && jn(t.style) ? {
2852
+ function Dn(e, t, n, r, i, a) {
2853
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Fn(t.style) ? {
2810
2854
  x: n + c.area.x,
2811
2855
  y: r + c.area.y,
2812
2856
  width: c.area.width,
2813
2857
  height: c.area.height
2814
- } : Sn(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 = Bn(o.minWidth, l.width, e, a) ?? 0, S = Bn(o.maxWidth, l.width, e, a), C = {};
2858
+ } : En(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 = Wn(o.minWidth, l.width, e, a) ?? 0, S = Wn(o.maxWidth, l.width, e, a), C = {};
2815
2859
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2816
2860
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2817
2861
  else {
@@ -2823,25 +2867,25 @@ function Cn(e, t, n, r, i, a) {
2823
2867
  if (u !== null && d !== null) {
2824
2868
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2825
2869
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2826
- } else E = u === null ? d === null ? On(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2870
+ } else E = u === null ? d === null ? Mn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2827
2871
  let D;
2828
2872
  if (f !== null && p !== null) {
2829
2873
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2830
2874
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2831
- } else D = f === null ? p === null ? kn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2875
+ } else D = f === null ? p === null ? Nn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2832
2876
  e.localRect = {
2833
2877
  ...e.localRect,
2834
2878
  x: E - n,
2835
2879
  y: D - r
2836
2880
  };
2837
2881
  }
2838
- function wn(e, t, n) {
2882
+ function On(e, t, n) {
2839
2883
  return L(e, [n], Math.max(0, t - n))[0];
2840
2884
  }
2841
- function Tn(e, t, n, r) {
2842
- return qe(Ke(e, t), n, r);
2885
+ function kn(e, t, n, r) {
2886
+ return z(Je(e, t), n, r);
2843
2887
  }
2844
- function En(e, t, n, r, i) {
2888
+ function An(e, t, n, r, i) {
2845
2889
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2846
2890
  a.left ?? 0,
2847
2891
  a.right ?? 0,
@@ -2853,9 +2897,9 @@ function En(e, t, n, r, i) {
2853
2897
  n.innerHeight,
2854
2898
  n.direction === "column"
2855
2899
  ], u = i + o + s;
2856
- return (l ? wn(Ze(t.style), c, u) : Tn(e, t, c, u)) + o;
2900
+ return (l ? On(Qe(t.style), c, u) : kn(e, t, c, u)) + o;
2857
2901
  }
2858
- function Dn(e, t, n, r, i) {
2902
+ function jn(e, t, n, r, i) {
2859
2903
  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" ? [
2860
2904
  a.left ?? 0,
2861
2905
  a.right ?? 0,
@@ -2865,35 +2909,37 @@ function Dn(e, t, n, r, i) {
2865
2909
  a.top ?? 0,
2866
2910
  a.bottom ?? 0,
2867
2911
  n.height,
2868
- Ke(e, t)
2912
+ Je(e, t)
2869
2913
  ];
2870
- return qe(u, l, i + s + c) + s;
2914
+ return z(u, l, i + s + c) + s;
2871
2915
  }
2872
- function On(e, t, n, r) {
2916
+ function Mn(e, t, n, r) {
2873
2917
  let i = e.staticSlot;
2874
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Dn(e, t, i.staticArea, "x", r) : n + i.originX + En(e, t, i, "x", r);
2918
+ return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + jn(e, t, i.staticArea, "x", r) : n + i.originX + An(e, t, i, "x", r);
2875
2919
  }
2876
- function kn(e, t, n, r) {
2920
+ function Nn(e, t, n, r) {
2877
2921
  let i = e.staticSlot;
2878
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Dn(e, t, i.staticArea, "y", r) : n + i.originY + En(e, t, i, "y", r);
2922
+ return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + jn(e, t, i.staticArea, "y", r) : n + i.originY + An(e, t, i, "y", r);
2879
2923
  }
2880
2924
  //#endregion
2881
2925
  //#region src/layout.ts
2882
- function An(e, t) {
2883
- let n = Mn();
2884
- return V(e, t, void 0, 0, 0, "fill", n), bn(e, 0, 0, [{
2926
+ function Pn(e, t) {
2927
+ let n = In();
2928
+ V(e, t, void 0, 0, 0, "fill", n), wn(e, 0, 0, [{
2885
2929
  node: e,
2886
2930
  absX: 0,
2887
2931
  absY: 0
2888
- }], n), { height: e.localRect.height };
2932
+ }], n);
2933
+ let r = e.localRect.height, i = Yn(e);
2934
+ return e.localRect.width = Math.max(e.localRect.width, i.x), e.localRect.height = Math.max(r, i.y), { height: r };
2889
2935
  }
2890
2936
  function B(e) {
2891
2937
  return e.position === "absolute" || e.position === "fixed";
2892
2938
  }
2893
- function jn(e) {
2939
+ function Fn(e) {
2894
2940
  return e.position !== "static";
2895
2941
  }
2896
- function Mn() {
2942
+ function In() {
2897
2943
  return {
2898
2944
  maxContent: /* @__PURE__ */ new WeakMap(),
2899
2945
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2903,54 +2949,86 @@ function Mn() {
2903
2949
  }
2904
2950
  function V(e, t, n, r, i, a, o, s) {
2905
2951
  let c = e.style, l = s?.height;
2906
- delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan;
2907
- let u = Bn(c.minWidth, t, e, o) ?? 0, d = Bn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2952
+ delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan, delete e.textExtent;
2953
+ let u = Wn(c.minWidth, t, e, o) ?? 0, d = Wn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = tt(c);
2954
+ s?.gutter?.right && (m.right = c.scrollbarSize.y), s?.gutter?.bottom && (m.bottom = c.scrollbarSize.x);
2955
+ let h = {
2908
2956
  top: W(c.padding.top, t),
2909
- right: W(c.padding.right, t),
2910
- bottom: W(c.padding.bottom, t),
2957
+ right: W(c.padding.right, t) + m.right,
2958
+ bottom: W(c.padding.bottom, t) + m.bottom,
2911
2959
  left: W(c.padding.left, t)
2912
2960
  };
2913
- e.resolvedPadding = m;
2914
- let h = s?.width ?? H(Wn(c, t, a, e, o), u, d), g = Kn(c, n), _ = Yn(h, l ?? g ?? (f > 0 ? f : void 0) ?? Infinity, c.border, m), v = l !== void 0 || g !== void 0, y = v && Number.isFinite(_.height) ? _.height : void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - m.top - m.bottom), x;
2915
- x = Pn(e) ? Nn(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? Be(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? He(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? tt(e, _.width, _.height, c.border, m, o) : c.display === "table" ? gn(e, _.width, y, c.border, m, o) : c.display === "multicol" ? Jt(e, _.width, y, b, c.border, m, o) : Vn(e, _.width, y, c.border, m, o);
2916
- let S = x + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? S;
2917
- e.unclampedHeight = C, e.naturalContentHeight = S;
2918
- let w = H(C, f, p), T = e.multicolGeometry;
2919
- if (T) {
2920
- let t = w - c.border.top - c.border.bottom - m.top - m.bottom;
2921
- t > T.totalRows && (m.bottom += t - T.totalRows), Gt(e, T, c.border, m);
2922
- }
2923
- e.localRect = {
2961
+ e.resolvedPadding = h;
2962
+ let g = s?.width ?? H(Jn(c, t, a, e, o), u, d), _ = Qn(c, n), v = tr(g, l ?? _ ?? (f > 0 ? f : void 0) ?? Infinity, c.border, h), y = l !== void 0 || _ !== void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - h.top - h.bottom), x = Rn(e), S = (t, n) => {
2963
+ let r = n && Number.isFinite(t) ? t : void 0;
2964
+ return x ? Ln(e, v.width, t, r, b, h, o) : c.display === "flex" && c.flexDirection === "row" ? He(e, v.width, t, r, c.border, h, o) : c.display === "flex" ? We(e, v.width, t, n, c.border, h, o) : c.display === "grid" ? at(e, v.width, t, c.border, h, o) : c.display === "table" ? bn(e, v.width, r, c.border, h, o) : c.display === "multicol" ? Qt(e, v.width, r, b, c.border, h, o) : Gn(e, v.width, r, c.border, h, o);
2965
+ }, C = S(v.height, y);
2966
+ !x && (c.display === "flex" || c.display === "grid") && !y && b !== void 0 && C > b && (C = S(b, !0));
2967
+ let w = C + c.border.top + c.border.bottom + h.top + h.bottom, T = l ?? _ ?? w;
2968
+ e.unclampedHeight = T, e.naturalContentHeight = w;
2969
+ let E = H(T, f, p), D = e.multicolGeometry;
2970
+ if (D) {
2971
+ let t = E - c.border.top - c.border.bottom - h.top - h.bottom;
2972
+ t > D.totalRows && (h.bottom += t - D.totalRows), Yt(e, D, c.border, h);
2973
+ }
2974
+ if (e.localRect = {
2924
2975
  x: r,
2925
2976
  y: i,
2926
- width: h,
2927
- height: w
2928
- };
2977
+ width: g,
2978
+ height: E
2979
+ }, et(c.overflow.x) || et(c.overflow.y)) {
2980
+ let l = Yn(e), u = Math.max(0, l.x - c.border.left - h.left), d = Math.max(0, l.y - c.border.top - h.top), f = Math.max(0, g - c.border.left - c.border.right - h.left - h.right), p = Math.max(0, E - c.border.top - c.border.bottom - h.top - h.bottom);
2981
+ if (e.scrollRange = {
2982
+ sizeX: u,
2983
+ sizeY: d,
2984
+ maxX: et(c.overflow.x) ? Math.max(0, u - f) : 0,
2985
+ maxY: et(c.overflow.y) ? Math.max(0, d - p) : 0
2986
+ }, !s?.gutter && c.scrollbarWidth !== "none") {
2987
+ let l = c.overflow.y === "auto" && e.scrollRange.maxY > 0, u = c.overflow.x === "auto" && e.scrollRange.maxX > 0;
2988
+ if (l || u) {
2989
+ V(e, t, n, r, i, a, o, {
2990
+ ...s,
2991
+ gutter: {
2992
+ right: l,
2993
+ bottom: u
2994
+ }
2995
+ });
2996
+ return;
2997
+ }
2998
+ }
2999
+ e.scrollGutterCells = {
3000
+ right: m.right,
3001
+ bottom: m.bottom
3002
+ };
3003
+ } else delete e.scrollRange, delete e.scrollGutterCells;
2929
3004
  }
2930
- function Nn(e, t, n, r, i, a, o) {
3005
+ function Ln(e, t, n, r, i, a, o) {
2931
3006
  let s = e.style, c;
2932
3007
  if (e.text) {
2933
3008
  let l = e.children.filter((e) => e.inlineBox);
2934
- Me(e.text, (n, r) => {
3009
+ Pe(e.text, (n, r) => {
2935
3010
  let i = l[r];
2936
3011
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2937
3012
  });
2938
3013
  let u, d;
2939
3014
  if (s.display === "multicol") {
2940
- let n = U(s, "x", t), o = Lt(s, t, n);
3015
+ let n = U(s, "x", t), o = Vt(s, t, n);
2941
3016
  a.right += o.leftover;
2942
- let c = zt(e, o, n, Ft(r, i));
3017
+ let c = Ut(e, o, n, zt(r, i));
2943
3018
  e.multicolGeometry = c, u = c, d = c.lineX;
2944
- } else u = In(e, t);
2945
- if (c = u.totalRows, Fn(e, u, t, n, a), l.length > 0) {
3019
+ } else u = Bn(e, t);
3020
+ if (c = u.totalRows, e.textExtent = {
3021
+ width: u.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, s.tracking)), 0),
3022
+ rows: u.totalRows
3023
+ }, zn(e, u, t, n, a), l.length > 0) {
2946
3024
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
2947
- Me(e.text, (n, r) => {
3025
+ Pe(e.text, (n, r) => {
2948
3026
  let i = t(n);
2949
3027
  if (i === -1) return;
2950
3028
  let o = u.spans[i];
2951
3029
  l[r].localRect = {
2952
3030
  ...l[r].localRect,
2953
- x: s.border.left + a.left + (d?.[i] ?? 0) + ke(o.start, n, e.advances),
3031
+ x: s.border.left + a.left + (d?.[i] ?? 0) + je(o.start, n, e.advances),
2954
3032
  y: s.border.top + a.top + u.lineY[i]
2955
3033
  };
2956
3034
  });
@@ -2967,30 +3045,30 @@ function Nn(e, t, n, r, i, a, o) {
2967
3045
  }
2968
3046
  return c;
2969
3047
  }
2970
- function Pn(e) {
3048
+ function Rn(e) {
2971
3049
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
2972
3050
  }
2973
3051
  function H(e, t, n) {
2974
3052
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
2975
3053
  }
2976
- function Fn(e, t, n, r, i) {
3054
+ function zn(e, t, n, r, i) {
2977
3055
  let a = e.style;
2978
3056
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
2979
3057
  let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
2980
3058
  if (c > 0) {
2981
- let e = a.display === "grid" ? qe(a.justifyItems, n, s) : o ? qe(a.alignItems, n, s) : L(Ze(a), [s], c)[0];
3059
+ let e = a.display === "grid" ? z(a.justifyItems, n, s) : o ? z(a.alignItems, n, s) : L(Qe(a), [s], c)[0];
2982
3060
  e > 0 && (i.left += e, i.right += c - e);
2983
3061
  }
2984
3062
  if (Number.isFinite(r)) {
2985
3063
  let e = Math.max(0, r - t.totalRows);
2986
3064
  if (e > 0) {
2987
- let n = a.display === "grid" || !o ? qe(a.alignItems, r, t.totalRows) : L(Ze(a), [t.totalRows], e)[0];
3065
+ let n = a.display === "grid" || !o ? z(a.alignItems, r, t.totalRows) : L(Qe(a), [t.totalRows], e)[0];
2988
3066
  n > 0 && (i.top += n, i.bottom += e - n);
2989
3067
  }
2990
3068
  }
2991
3069
  }
2992
- function In(e, t) {
2993
- let n = Ln(e, t), { heights: r, textOffsets: i } = Rn(e, n), a = [], o = [], s = 0;
3070
+ function Bn(e, t) {
3071
+ let n = Vn(e, t), { heights: r, textOffsets: i } = Hn(e, n), a = [], o = [], s = 0;
2994
3072
  for (let t = 0; t < n.length; t++) a.push(s), o.push(s + i[t]), s += r[t] + (t < n.length - 1 ? e.style.lineGap : 0);
2995
3073
  return {
2996
3074
  spans: n,
@@ -2999,21 +3077,21 @@ function In(e, t) {
2999
3077
  totalRows: s
3000
3078
  };
3001
3079
  }
3002
- function Ln(e, t) {
3003
- return e.style.whiteSpace === "normal" ? Oe(e.text, t, {
3080
+ function Vn(e, t) {
3081
+ return e.style.whiteSpace === "normal" ? Ae(e.text, t, {
3004
3082
  advances: e.advances,
3005
3083
  tracking: e.style.tracking,
3006
3084
  firstLineIndent: e.style.textIndent
3007
- }) : De(e.text);
3085
+ }) : ke(e.text);
3008
3086
  }
3009
- function Rn(e, t) {
3087
+ function Hn(e, t) {
3010
3088
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
3011
3089
  for (let o of t) {
3012
3090
  let t = 1, s = 0;
3013
3091
  for (let r = o.start; r < o.end; r++) {
3014
3092
  if (e.text[r] !== "") continue;
3015
3093
  let i = n[a];
3016
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && M(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3094
+ t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && N(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3017
3095
  }
3018
3096
  r.push(t), i.push(Math.min(s, t - 1));
3019
3097
  }
@@ -3027,7 +3105,7 @@ function U(e, t, n) {
3027
3105
  return Math.max(r, i?.width ?? 0);
3028
3106
  }
3029
3107
  function W(e, t) {
3030
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : xe(e.percent, t);
3108
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : Ce(e.percent, t);
3031
3109
  }
3032
3110
  function G(e, t) {
3033
3111
  let n = (e) => e === null ? null : W(e, t);
@@ -3038,16 +3116,16 @@ function G(e, t) {
3038
3116
  left: n(e.left)
3039
3117
  };
3040
3118
  }
3041
- function zn(e) {
3119
+ function Un(e) {
3042
3120
  return typeof e == "number" ? e : 0;
3043
3121
  }
3044
3122
  function K(e, t) {
3045
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : xe(e.percent, t);
3123
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : Ce(e.percent, t);
3046
3124
  }
3047
- function Bn(e, t, n, r) {
3125
+ function Wn(e, t, n, r) {
3048
3126
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
3049
3127
  }
3050
- function Vn(e, t, n, r, i, a) {
3128
+ function Gn(e, t, n, r, i, a) {
3051
3129
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
3052
3130
  for (let r of e.children) {
3053
3131
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -3055,13 +3133,13 @@ function Vn(e, t, n, r, i, a) {
3055
3133
  r.staticSlot = {
3056
3134
  kind: "block",
3057
3135
  x: o + u,
3058
- y: c + (l === null ? i : Un(l, i))
3136
+ y: c + (l === null ? i : qn(l, i))
3059
3137
  };
3060
3138
  continue;
3061
3139
  }
3062
3140
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
3063
- let f = Hn(e, t, r.localRect.width);
3064
- c += l === null ? i : Un(l, i), r.localRect = {
3141
+ let f = Kn(e, t, r.localRect.width);
3142
+ c += l === null ? i : qn(l, i), r.localRect = {
3065
3143
  ...r.localRect,
3066
3144
  x: o + f,
3067
3145
  y: c
@@ -3069,37 +3147,65 @@ function Vn(e, t, n, r, i, a) {
3069
3147
  }
3070
3148
  return l !== null && (c += l), c - s;
3071
3149
  }
3072
- function Hn(e, t, n) {
3150
+ function Kn(e, t, n) {
3073
3151
  let r = t - n;
3074
3152
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
3075
3153
  }
3076
- function Un(e, t) {
3154
+ function qn(e, t) {
3077
3155
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
3078
3156
  }
3079
- function Wn(e, t, n, r, i) {
3157
+ function Jn(e, t, n, r, i) {
3080
3158
  let a = e.width;
3081
3159
  if (e.display === "table") {
3082
3160
  if (!r.children.some((e) => !B(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : Math.min(t, J(r, i));
3083
3161
  if (a !== void 0 && a.kind !== "auto") {
3084
3162
  let e = q(a, t, r, i);
3085
- return Math.max(e, Gn(r, t, i));
3163
+ return Math.max(e, Zn(r, t, i));
3086
3164
  }
3087
- return hn(r, t, i);
3165
+ return yn(r, t, i);
3088
3166
  }
3089
3167
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
3090
3168
  }
3091
- function Gn(e, t, n) {
3169
+ function Yn(e) {
3170
+ let t = 0, n = 0;
3171
+ for (let r of e.children) {
3172
+ if (r.style.position === "fixed") continue;
3173
+ let e = Xn(r);
3174
+ t = Math.max(t, r.localRect.x + e.x), n = Math.max(n, r.localRect.y + e.y);
3175
+ }
3176
+ if (e.textExtent) {
3177
+ let { border: r } = e.style, i = e.resolvedPadding;
3178
+ t = Math.max(t, r.left + i.left + e.textExtent.width), n = Math.max(n, r.top + i.top + e.textExtent.rows);
3179
+ }
3180
+ return {
3181
+ x: t,
3182
+ y: n
3183
+ };
3184
+ }
3185
+ function Xn(e) {
3186
+ let { width: t, height: n } = e.localRect, r = e.style.overflow.x !== "visible", i = e.style.overflow.y !== "visible";
3187
+ if (r && i) return {
3188
+ x: t,
3189
+ y: n
3190
+ };
3191
+ let a = Yn(e);
3192
+ return {
3193
+ x: r ? t : Math.max(t, a.x),
3194
+ y: i ? n : Math.max(n, a.y)
3195
+ };
3196
+ }
3197
+ function Zn(e, t, n) {
3092
3198
  let r = e.style;
3093
- return mn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
3199
+ return vn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t) + tt(r).right;
3094
3200
  }
3095
- function Kn(e, t) {
3201
+ function Qn(e, t) {
3096
3202
  if (e.height?.kind === "cells") return e.height.value;
3097
- if (e.height?.kind === "percent" && t != null) return xe(e.height.value, t);
3203
+ if (e.height?.kind === "percent" && t != null) return Ce(e.height.value, t);
3098
3204
  }
3099
3205
  function q(e, t, n, r) {
3100
3206
  switch (e.kind) {
3101
3207
  case "cells": return e.value;
3102
- case "percent": return xe(e.value, t);
3208
+ case "percent": return Ce(e.value, t);
3103
3209
  case "min-content": return Y(n, r);
3104
3210
  case "max-content": return J(n, r);
3105
3211
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -3109,42 +3215,42 @@ function q(e, t, n, r) {
3109
3215
  function J(e, t) {
3110
3216
  let n = t.maxContent.get(e);
3111
3217
  if (n !== void 0) return n;
3112
- let r = e.style, i = qn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.right);
3218
+ let r = e.style, i = $n(e, t) + r.border.left + r.border.right + Un(r.padding.left) + Un(r.padding.right) + tt(r).right;
3113
3219
  return t.maxContent.set(e, i), i;
3114
3220
  }
3115
- function qn(e, t) {
3221
+ function $n(e, t) {
3116
3222
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3117
- if (n.length === 0) return e.style.display === "multicol" ? Pt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3118
- if (e.style.display === "grid") return ut(e, t).max;
3119
- if (e.style.display === "table") return mn(e, t).max;
3223
+ if (n.length === 0) return e.style.display === "multicol" ? Rt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3224
+ if (e.style.display === "grid") return mt(e, t).max;
3225
+ if (e.style.display === "table") return vn(e, t).max;
3120
3226
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
3121
- let r = Math.max(zn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3227
+ let r = Math.max(Un(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3122
3228
  return n.reduce((e, n) => e + J(n, t), 0) + r;
3123
3229
  }
3124
3230
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
3125
- return e.style.display === "multicol" ? Pt(e.style, r) : r;
3231
+ return e.style.display === "multicol" ? Rt(e.style, r) : r;
3126
3232
  }
3127
3233
  function Y(e, t) {
3128
3234
  let n = t.minContent.get(e);
3129
3235
  if (n !== void 0) return n;
3130
- let r = e.style, i = Jn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.right);
3236
+ let r = e.style, i = er(e, t) + r.border.left + r.border.right + Un(r.padding.left) + Un(r.padding.right) + tt(r).right;
3131
3237
  return t.minContent.set(e, i), i;
3132
3238
  }
3133
- function Jn(e, t) {
3239
+ function er(e, t) {
3134
3240
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3135
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : je(e.text, {
3241
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Ne(e.text, {
3136
3242
  advances: e.advances,
3137
3243
  tracking: e.style.tracking
3138
3244
  });
3139
- if (e.style.display === "grid") return ut(e, t).min;
3140
- if (e.style.display === "table") return mn(e, t).min;
3245
+ if (e.style.display === "grid") return mt(e, t).min;
3246
+ if (e.style.display === "table") return vn(e, t).min;
3141
3247
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
3142
- let r = Math.max(zn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3248
+ let r = Math.max(Un(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3143
3249
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
3144
3250
  }
3145
3251
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
3146
3252
  }
3147
- function Yn(e, t, n, r) {
3253
+ function tr(e, t, n, r) {
3148
3254
  return {
3149
3255
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
3150
3256
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -3152,38 +3258,38 @@ function Yn(e, t, n, r) {
3152
3258
  }
3153
3259
  //#endregion
3154
3260
  //#region src/plain-text.ts
3155
- function Xn(e) {
3156
- return nr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3261
+ function nr(e) {
3262
+ return cr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3157
3263
  }
3158
- function Zn(e) {
3159
- let { grid: t, paints: n } = nr(e);
3160
- return t.map((e, t) => Qn(e, n[t]));
3264
+ function rr(e) {
3265
+ let { grid: t, paints: n } = cr(e);
3266
+ return t.map((e, t) => ir(e, n[t]));
3161
3267
  }
3162
- function Qn(e, t) {
3268
+ function ir(e, t) {
3163
3269
  let n = e.length;
3164
3270
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
3165
3271
  let r = [];
3166
3272
  for (let i = 0; i < n; i++) {
3167
3273
  let n = t[i], a = r[r.length - 1];
3168
- a && $n(a, n) ? a.text += e[i] : r.push({
3274
+ a && ar(a, n) ? a.text += e[i] : r.push({
3169
3275
  text: e[i],
3170
3276
  ...n
3171
3277
  });
3172
3278
  }
3173
3279
  return r;
3174
3280
  }
3175
- function $n(e, t) {
3281
+ function ar(e, t) {
3176
3282
  return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine && e.opacity === t?.opacity;
3177
3283
  }
3178
- function er(e, t) {
3284
+ function or(e, t) {
3179
3285
  e.color !== void 0 && (t.color = e.color), e.backgroundColor !== void 0 && (t.backgroundColor = e.backgroundColor), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.textDecorationLine !== void 0 && (t.textDecoration = e.textDecorationLine), e.opacity !== void 0 && (t.opacity = e.opacity);
3180
3286
  }
3181
- function tr(e) {
3287
+ function sr(e) {
3182
3288
  return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0 && e.opacity === void 0;
3183
3289
  }
3184
- function nr(e) {
3290
+ function cr(e) {
3185
3291
  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));
3186
- return ir(e, 0, 0, (e, a, o, s) => {
3292
+ return ur(e, 0, 0, (e, a, o, s) => {
3187
3293
  if (e >= 0 && e < t && a >= 0 && a < n) {
3188
3294
  r[a][e] = o;
3189
3295
  let t = i[a][e];
@@ -3197,22 +3303,22 @@ function nr(e) {
3197
3303
  paints: i
3198
3304
  };
3199
3305
  }
3200
- function rr(e) {
3306
+ function lr(e) {
3201
3307
  let t = {};
3202
3308
  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;
3203
3309
  }
3204
- function ir(e, t, n, r, i = 1) {
3310
+ function ur(e, t, n, r, i = 1) {
3205
3311
  if (e.tableHidden) return;
3206
3312
  let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3207
3313
  ...e,
3208
3314
  opacity: String(Math.round(i * 1e3) / 1e3)
3209
3315
  };
3210
3316
  if (s.backgroundColor !== void 0 || s.backgroundClear) {
3211
- let t = s.backgroundColor === void 0 ? void 0 : c({ backgroundColor: s.backgroundColor });
3317
+ let t = s.backgroundColor === void 0 ? { backgroundColor: void 0 } : c({ backgroundColor: s.backgroundColor });
3212
3318
  for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
3213
3319
  }
3214
3320
  let l = [];
3215
- ce(s, {
3321
+ le(s, {
3216
3322
  x: a,
3217
3323
  y: o,
3218
3324
  width: e.localRect.width,
@@ -3226,26 +3332,64 @@ function ir(e, t, n, r, i = 1) {
3226
3332
  let e = c(t.color === void 0 ? void 0 : { color: t.color });
3227
3333
  for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3228
3334
  }
3335
+ let u = e.resolvedPadding, d = e.scrollGutterCells, f = s.overflow.x !== "visible", p = s.overflow.y !== "visible", m = a - (e.scroll?.x ?? 0), h = o - (e.scroll?.y ?? 0), g = r;
3336
+ if (f || p) {
3337
+ let t = a + s.border.left, n = o + s.border.top, i = a + e.localRect.width - s.border.right - (d?.right ?? 0), c = o + e.localRect.height - s.border.bottom - (d?.bottom ?? 0);
3338
+ g = (e, a, o, s) => {
3339
+ f && (e < t || e >= i) || p && (a < n || a >= c) || r(e, a, o, s);
3340
+ };
3341
+ }
3229
3342
  if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3230
- let t = e.resolvedPadding, n = a + s.border.left + t.left, i = o + s.border.top + t.top, l = e.localRect.width - s.border.left - s.border.right - t.left - t.right, u = e.multicolGeometry, { spans: d, textY: f } = u ?? In(e, l), p = u ? Math.max(1, u.columnWidth - s.tracking) : l, m = c(rr(s)), h = e.inlineElements?.map((e) => c(rr(e)));
3231
- for (let t = 0; t < d.length; t++) {
3232
- let a = d[t], o = i + f[t], l = t === 0 ? s.textIndent : 0, g = s.whiteSpace !== "normal" && s.overflow === "clip" ? ar(e.text, a, p - l, e.advances, s) : {
3233
- end: a.end,
3343
+ let t = m + s.border.left + u.left, n = h + s.border.top + u.top, r = e.localRect.width - s.border.left - s.border.right - u.left - u.right, i = e.multicolGeometry, { spans: a, textY: o } = i ?? Bn(e, r), l = i ? Math.max(1, i.columnWidth - s.tracking) : r, d = c(lr(s)), f = e.inlineElements?.map((e) => c(lr(e)));
3344
+ for (let r = 0; r < a.length; r++) {
3345
+ let u = a[r], p = n + o[r], m = r === 0 ? s.textIndent : 0, h = s.whiteSpace !== "normal" && s.overflow.x === "clip" ? fr(e.text, u, l - m, e.advances, s) : {
3346
+ end: u.end,
3234
3347
  ellipsis: !1
3235
- }, _ = I(a.start, a.end, e.advances, s.tracking), v = Math.max(0, p - l - _), y = s.textAlign === "end" ? v : s.textAlign === "center" ? Math.floor(v / 2) : 0, b = n + (u?.lineX[t] ?? 0) + y + l;
3236
- for (let t = a.start; t < g.end; t++) {
3348
+ }, _ = I(u.start, u.end, e.advances, s.tracking), v = Math.max(0, l - m - _), y = s.textAlign === "end" ? v : s.textAlign === "center" ? Math.floor(v / 2) : 0, b = t + (i?.lineX[r] ?? 0) + y + m;
3349
+ for (let t = u.start; t < h.end; t++) {
3237
3350
  if (e.text[t] !== "") {
3238
- let n = e.charInline?.[t] ?? -1, i = n >= 0 ? e.inlineElements[n] : void 0, a = i?.insets, s = a ? a.left ?? (a.right === null ? 0 : -a.right) : 0, l = a ? a.top ?? (a.bottom === null ? 0 : -a.bottom) : 0;
3239
- e.text[t] === "⁠" ? i?.backgroundColor && r(b + s, o + l, " ", c({ backgroundColor: i.backgroundColor })) : r(b + s, o + l, e.text[t], i ? h[n] : m);
3351
+ let n = e.charInline?.[t] ?? -1, r = n >= 0 ? e.inlineElements[n] : void 0, i = r?.insets, a = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, o = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
3352
+ e.text[t] === "⁠" ? r?.backgroundColor && g(b + a, p + o, " ", c({ backgroundColor: r.backgroundColor })) : g(b + a, p + o, e.text[t], r ? f[n] : d);
3353
+ }
3354
+ b += je(t, t + 1, e.advances);
3355
+ }
3356
+ h.ellipsis && g(b, p, "…", d);
3357
+ }
3358
+ }
3359
+ for (let t of fe(e)) ur(t, m, h, g, i * t.style.opacity);
3360
+ let _ = e.scrollRange;
3361
+ if (_ && d && (d.right > 0 || d.bottom > 0)) {
3362
+ let { track: t, thumb: n } = j(S(s.glyphSet)), i = o + s.border.top, l = a + s.border.left, u = o + e.localRect.height - s.border.bottom, f = a + e.localRect.width - s.border.right, p = (e) => c(e ? { color: e } : void 0), m = p(s.scrollbarColor?.track ?? s.color), h = p(s.scrollbarColor?.thumb ?? s.color);
3363
+ if (d.right > 0) {
3364
+ let a = u - i - d.bottom, { at: o, len: s } = dr(a, _.sizeY, _.maxY, e.scroll?.y ?? 0);
3365
+ for (let e = 0; e < d.right; e++) {
3366
+ let c = f - d.right + e;
3367
+ for (let e = 0; e < a; e++) {
3368
+ let a = e >= o && e < o + s;
3369
+ r(c, i + e, a ? n : t, a ? h : m);
3370
+ }
3371
+ }
3372
+ }
3373
+ if (d.bottom > 0) {
3374
+ let i = f - l - d.right, { at: a, len: o } = dr(i, _.sizeX, _.maxX, e.scroll?.x ?? 0);
3375
+ for (let e = 0; e < d.bottom; e++) {
3376
+ let s = u - d.bottom + e;
3377
+ for (let e = 0; e < i; e++) {
3378
+ let i = e >= a && e < a + o;
3379
+ r(l + e, s, i ? n : t, i ? h : m);
3240
3380
  }
3241
- b += ke(t, t + 1, e.advances);
3242
3381
  }
3243
- g.ellipsis && r(b, o, "…", m);
3244
3382
  }
3245
3383
  }
3246
- for (let t of de(e)) ir(t, a, o, r, i * t.style.opacity);
3247
3384
  }
3248
- function ar(e, t, n, r, i) {
3385
+ function dr(e, t, n, r) {
3386
+ let i = t > 0 ? Math.min(1, e / t) : 1, a = Math.max(1, Math.round(i * e));
3387
+ return n > 0 && (a = Math.max(1, Math.min(a, e - n))), {
3388
+ at: n > 0 ? Math.round(Math.min(r, n) / n * (e - a)) : 0,
3389
+ len: a
3390
+ };
3391
+ }
3392
+ function fr(e, t, n, r, i) {
3249
3393
  let { textOverflow: a, tracking: o } = i;
3250
3394
  if (I(t.start, t.end, r, o) <= n) return {
3251
3395
  end: t.end,
@@ -3260,61 +3404,61 @@ function ar(e, t, n, r, i) {
3260
3404
  }
3261
3405
  //#endregion
3262
3406
  //#region src/paint.ts
3263
- var or = /* @__PURE__ */ new WeakMap(), sr = /* @__PURE__ */ new WeakMap();
3264
- function cr(e) {
3265
- return dr(e, !0) !== null;
3266
- }
3267
- function lr(e, t, n = !1) {
3268
- let r = Zn(e), i = gr(r);
3269
- if (or.get(t) === i) return !0;
3270
- let a = sr.get(t);
3271
- if (a && ur(t, a.nodes, r)) {
3272
- or.set(t, i);
3407
+ var pr = /* @__PURE__ */ new WeakMap(), mr = /* @__PURE__ */ new WeakMap();
3408
+ function hr(e) {
3409
+ return vr(e, !0) !== null;
3410
+ }
3411
+ function gr(e, t, n = !1) {
3412
+ let r = rr(e), i = Cr(r);
3413
+ if (pr.get(t) === i) return !0;
3414
+ let a = mr.get(t);
3415
+ if (a && _r(t, a.nodes, r)) {
3416
+ pr.set(t, i);
3273
3417
  for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3274
3418
  let n = r[e][t];
3275
- if (tr(n) || $n(n, a.segments[e][t])) continue;
3419
+ if (sr(n) || ar(n, a.segments[e][t])) continue;
3276
3420
  let i = a.nodes[e][t];
3277
- i.style.cssText = "", er(n, i.style);
3421
+ i.style.cssText = "", or(n, i.style);
3278
3422
  }
3279
3423
  return a.segments = r, !0;
3280
3424
  }
3281
- if (n && cr(t)) return !1;
3282
- or.set(t, i);
3425
+ if (n && hr(t)) return !1;
3426
+ pr.set(t, i);
3283
3427
  let o = document.createDocumentFragment(), s = [];
3284
3428
  for (let e = 0; e < r.length; e++) {
3285
3429
  e > 0 && o.appendChild(document.createTextNode("\n"));
3286
3430
  let t = [];
3287
3431
  for (let n of r[e]) {
3288
- if (tr(n)) {
3432
+ if (sr(n)) {
3289
3433
  let e = document.createTextNode(n.text);
3290
3434
  t.push(e), o.appendChild(e);
3291
3435
  continue;
3292
3436
  }
3293
3437
  let e = document.createElement("span");
3294
- er(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3438
+ or(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3295
3439
  }
3296
3440
  s.push(t);
3297
3441
  }
3298
- sr.set(t, {
3442
+ mr.set(t, {
3299
3443
  nodes: s,
3300
3444
  segments: r
3301
3445
  });
3302
- let c = dr(t, !1);
3303
- return t.replaceChildren(o), c && fr(t, c), !0;
3446
+ let c = vr(t, !1);
3447
+ return t.replaceChildren(o), c && yr(t, c), !0;
3304
3448
  }
3305
- function ur(e, t, n) {
3449
+ function _r(e, t, n) {
3306
3450
  if (t.length !== n.length) return !1;
3307
3451
  for (let r = 0; r < n.length; r++) {
3308
3452
  let i = t[r], a = n[r];
3309
3453
  if (i.length !== a.length) return !1;
3310
3454
  for (let t = 0; t < a.length; t++) {
3311
3455
  let n = i[t];
3312
- if (tr(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3456
+ if (sr(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3313
3457
  }
3314
3458
  }
3315
3459
  return !0;
3316
3460
  }
3317
- function dr(e, t) {
3461
+ function vr(e, t) {
3318
3462
  try {
3319
3463
  let n = e.ownerDocument.getSelection();
3320
3464
  if (!n) return null;
@@ -3330,7 +3474,7 @@ function dr(e, t) {
3330
3474
  if (!e || e.rangeCount === 0) return null;
3331
3475
  i = e.getRangeAt(0);
3332
3476
  }
3333
- let a = pr(e, i.startContainer, i.startOffset), o = pr(e, i.endContainer, i.endOffset);
3477
+ let a = br(e, i.startContainer, i.startOffset), o = br(e, i.endContainer, i.endOffset);
3334
3478
  return a === null || o === null || a === o && !t ? null : {
3335
3479
  start: a,
3336
3480
  end: o,
@@ -3340,32 +3484,32 @@ function dr(e, t) {
3340
3484
  return null;
3341
3485
  }
3342
3486
  }
3343
- function fr(e, t) {
3487
+ function yr(e, t) {
3344
3488
  try {
3345
- let n = mr(e, t.start), r = mr(e, t.end);
3489
+ let n = xr(e, t.start), r = xr(e, t.end);
3346
3490
  if (!n || !r) return;
3347
3491
  let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3348
3492
  t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3349
3493
  } catch {}
3350
3494
  }
3351
- function pr(e, t, n) {
3495
+ function br(e, t, n) {
3352
3496
  if (!e.contains(t)) return null;
3353
3497
  let r = e.ownerDocument.createRange();
3354
3498
  return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3355
3499
  }
3356
- function mr(e, t) {
3500
+ function xr(e, t) {
3357
3501
  let n = t, r = null;
3358
- for (let t of hr(e)) {
3502
+ for (let t of Sr(e)) {
3359
3503
  if (n <= t.data.length) return [t, n];
3360
3504
  n -= t.data.length, r = [t, t.data.length];
3361
3505
  }
3362
3506
  return r;
3363
3507
  }
3364
- function* hr(e) {
3508
+ function* Sr(e) {
3365
3509
  let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3366
3510
  for (; n;) yield n, n = t.nextNode();
3367
3511
  }
3368
- function gr(e) {
3512
+ function Cr(e) {
3369
3513
  let t = [];
3370
3514
  for (let n of e) {
3371
3515
  for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
@@ -3375,9 +3519,9 @@ function gr(e) {
3375
3519
  }
3376
3520
  //#endregion
3377
3521
  //#region src/render.ts
3378
- function _r(e) {
3522
+ function wr(e) {
3379
3523
  let t = /* @__PURE__ */ new Set();
3380
- vr(e, !0, t);
3524
+ Tr(e, !0, t);
3381
3525
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
3382
3526
  n.removeAttribute("data-mw-inline-inset");
3383
3527
  let e = n.style;
@@ -3398,60 +3542,64 @@ function Z(e, t) {
3398
3542
  function Q(e, t, n) {
3399
3543
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
3400
3544
  }
3401
- function vr(e, t, n) {
3545
+ function Tr(e, t, n) {
3402
3546
  if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
3403
3547
  let e = t;
3404
- X(e, "--mw-ls", String(r)), i > 0 ? X(e, "--mw-ipl", String(i)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (n.add(t), yr(e, o));
3548
+ X(e, "--mw-ls", String(r)), i > 0 ? X(e, "--mw-ipl", String(i)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (n.add(t), Er(e, o));
3405
3549
  }
3406
- if (t || xr(e), !e.tableHidden) for (let t of de(e)) {
3550
+ if (t || Or(e), !e.tableHidden) for (let t of fe(e)) {
3407
3551
  let r = t.source;
3408
- t.style.zIndex !== null && ue(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), vr(t, !1, n);
3552
+ t.style.zIndex !== null && de(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), Tr(t, !1, n);
3409
3553
  }
3410
3554
  }
3411
- function yr(e, t) {
3555
+ function Er(e, t) {
3412
3556
  Q(e, "data-mw-inline-inset", !0);
3413
3557
  let n = (t, n) => {
3414
3558
  n === null ? Z(e, t) : X(e, t, String(n));
3415
3559
  };
3416
3560
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
3417
3561
  }
3418
- function br(e) {
3562
+ function Dr(e) {
3419
3563
  let t = e.style;
3420
3564
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
3421
- let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? Ln(e, i);
3565
+ let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? Vn(e, i);
3422
3566
  return o.length !== 0 && o.every((n, r) => {
3423
3567
  let i = r === 0 ? t.textIndent : 0, o = a - i - I(n.start, n.end, e.advances, t.tracking);
3424
3568
  return o > 0 && o % 2 == 1;
3425
3569
  });
3426
3570
  }
3427
- function xr(e) {
3571
+ function Or(e) {
3428
3572
  let t = e.source, n = e.localRect, r = e.resolvedPadding, { border: i, textAlignBlocked: a, overflow: o, whiteSpace: s, tracking: c, lineGap: l } = e.style, u = e.multicolFlow, d = e.multicolFlowSpan;
3429
3573
  Q(t, "data-mw-laid-out", !e.inlineBox && !u && !d), Q(t, "data-mw-inline-box", !!e.inlineBox), Q(t, "data-mw-multicol-flow", !!u), Q(t, "data-mw-multicol-flow-span", !!d);
3430
3574
  let f = u ?? d;
3431
3575
  f ? (X(t, "--mw-mt", String(f.top ?? 0)), X(t, "--mw-mr", String(f.right ?? 0)), X(t, "--mw-mb", String(f.bottom ?? 0)), X(t, "--mw-ml", String(f.left ?? 0))) : (Z(t, "--mw-mt"), Z(t, "--mw-mr"), Z(t, "--mw-mb"), Z(t, "--mw-ml")), Q(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), X(t, "--mw-ls", String(c)), X(t, "--mw-lh", String(l + 1)), X(t, "--mw-lhs", String(-l / 2)), Q(t, "data-mw-nowrap", s !== "normal");
3432
3576
  let p = u || d ? void 0 : e.multicolGeometry;
3433
- Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o === "clip"), X(t, "--mw-pt", String(r.top)), X(t, "--mw-pr", String(r.right)), X(t, "--mw-pb", String(r.bottom)), X(t, "--mw-pl", String(r.left)), X(t, "--mw-bt", String(i.top)), X(t, "--mw-br", String(i.right)), X(t, "--mw-bb", String(i.bottom)), X(t, "--mw-bl", String(i.left)), X(t, "--mw-ti", String(e.style.textIndent)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-center-nudge", br(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3577
+ if (Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o.x === "clip" || o.y === "clip"), Q(t, "data-mw-scroll", e.scrollRange !== void 0), e.scrollRange) {
3578
+ let { maxX: n, maxY: r } = e.scrollRange;
3579
+ X(t, "--mw-se-x", String(n > 0 ? n + e.localRect.width : 1)), X(t, "--mw-se-y", String(r > 0 ? r + e.localRect.height : 1));
3580
+ } else Z(t, "--mw-se-x"), Z(t, "--mw-se-y");
3581
+ X(t, "--mw-pt", String(r.top)), X(t, "--mw-pr", String(r.right)), X(t, "--mw-pb", String(r.bottom)), X(t, "--mw-pl", String(r.left)), X(t, "--mw-bt", String(i.top)), X(t, "--mw-br", String(i.right)), X(t, "--mw-bb", String(i.bottom)), X(t, "--mw-bl", String(i.left)), X(t, "--mw-ti", String(e.style.textIndent)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-center-nudge", Dr(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3434
3582
  }
3435
3583
  //#endregion
3436
3584
  //#region src/style.ts
3437
- function Sr(e, t, n) {
3438
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Ir(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3439
- jr(e, o, s);
3440
- let c = r.display || Or[e.tagName] || "", l = kr[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, f = Number.isFinite(d) ? Math.max(1, F(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || Dr(r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [et()], _ = [et()], v = {
3585
+ function kr(e, t, n) {
3586
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Zr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3587
+ Kr(e, o, s);
3588
+ let c = r.display || Ur[e.tagName] || "", l = Wr[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, f = Number.isFinite(d) ? Math.max(1, F(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || Hr(e, r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [it()], _ = [it()], v = {
3441
3589
  direction: "row",
3442
3590
  dense: !1
3443
3591
  }, y = null;
3444
3592
  if (p === "grid") {
3445
- if (a) m = ni(a.get("grid-template-columns")?.toString() ?? "", t), h = ni(a.get("grid-template-rows")?.toString() ?? "", t);
3593
+ if (a) m = _i(a.get("grid-template-columns")?.toString() ?? "", t), h = _i(a.get("grid-template-rows")?.toString() ?? "", t);
3446
3594
  else {
3447
3595
  e.setAttribute("data-mw-degrid", "");
3448
3596
  try {
3449
- m = ni(r.getPropertyValue("grid-template-columns"), t), h = ni(r.getPropertyValue("grid-template-rows"), t);
3597
+ m = _i(r.getPropertyValue("grid-template-columns"), t), h = _i(r.getPropertyValue("grid-template-rows"), t);
3450
3598
  } finally {
3451
3599
  e.removeAttribute("data-mw-degrid");
3452
3600
  }
3453
3601
  }
3454
- g = oi(r.getPropertyValue("grid-auto-columns"), t), _ = oi(r.getPropertyValue("grid-auto-rows"), t), v = fi(r.getPropertyValue("grid-auto-flow")), y = ai(r.getPropertyValue("grid-template-areas"));
3602
+ g = xi(r.getPropertyValue("grid-auto-columns"), t), _ = xi(r.getPropertyValue("grid-auto-rows"), t), v = Di(r.getPropertyValue("grid-auto-flow")), y = bi(r.getPropertyValue("grid-template-areas"));
3455
3603
  }
3456
3604
  let b = "auto", x = !1, S = 0, C = 0;
3457
3605
  if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
@@ -3466,61 +3614,71 @@ function Sr(e, t, n) {
3466
3614
  borderSpacingX: S,
3467
3615
  borderSpacingY: C,
3468
3616
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
3469
- verticalAlign: l === "cell" || c.startsWith("inline-") ? Ar(e, r) : "start",
3617
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? Gr(e, r) : "start",
3470
3618
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
3471
3619
  flexReverse: r.flexDirection.endsWith("-reverse"),
3472
3620
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
3473
3621
  wrapReverse: r.flexWrap === "wrap-reverse",
3474
3622
  flexGrow: Number(r.flexGrow) || 0,
3475
3623
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
3476
- flexBasis: ei(r.flexBasis, t),
3624
+ flexBasis: hi(r.flexBasis, t),
3477
3625
  order: Number(r.order) || 0,
3478
- justifyContent: Lr(r.justifyContent),
3479
- alignContent: Lr(r.alignContent),
3480
- alignItems: Rr(r.alignItems),
3481
- alignSelf: zr(r.alignSelf),
3482
- justifyItems: Rr(r.justifyItems),
3483
- justifySelf: zr(r.justifySelf),
3626
+ justifyContent: Qr(r.justifyContent),
3627
+ alignContent: Qr(r.alignContent),
3628
+ alignItems: $r(r.alignItems),
3629
+ alignSelf: ei(r.alignSelf),
3630
+ justifyItems: $r(r.justifyItems),
3631
+ justifySelf: ei(r.justifySelf),
3484
3632
  gridTemplateColumns: m,
3485
3633
  gridTemplateRows: h,
3486
3634
  gridAutoColumns: g,
3487
3635
  gridAutoRows: _,
3488
3636
  gridAutoFlow: v,
3489
3637
  gridTemplateAreas: y,
3490
- gridColumnStart: di(r.getPropertyValue("grid-column-start")),
3491
- gridColumnEnd: di(r.getPropertyValue("grid-column-end")),
3492
- gridRowStart: di(r.getPropertyValue("grid-row-start")),
3493
- gridRowEnd: di(r.getPropertyValue("grid-row-end")),
3494
- width: Yr(a, r.width, "width", t, o, s, n),
3495
- height: Yr(a, r.height, "height", t, o, s, n),
3496
- minWidth: $r(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Kr(r.minWidth, t) ?? "auto",
3497
- minHeight: $r(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Kr(r.minHeight, t) ?? "auto",
3498
- maxWidth: $r(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Kr(r.maxWidth, t),
3499
- maxHeight: $r(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Kr(r.maxHeight, t),
3500
- padding: mi(r, t),
3501
- margin: Br(r, a, o, s, t),
3502
- position: Ur(r.position),
3503
- insets: Wr(r, a, o, s, t),
3638
+ gridColumnStart: Ei(r.getPropertyValue("grid-column-start")),
3639
+ gridColumnEnd: Ei(r.getPropertyValue("grid-column-end")),
3640
+ gridRowStart: Ei(r.getPropertyValue("grid-row-start")),
3641
+ gridRowEnd: Ei(r.getPropertyValue("grid-row-end")),
3642
+ width: ui(a, r.width, "width", t, o, s, n),
3643
+ height: ui(a, r.height, "height", t, o, s, n),
3644
+ minWidth: mi(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? si(r.minWidth, t) ?? "auto",
3645
+ minHeight: mi(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? si(r.minHeight, t) ?? "auto",
3646
+ maxWidth: mi(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? si(r.maxWidth, t),
3647
+ maxHeight: mi(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? si(r.maxHeight, t),
3648
+ padding: ki(r, t),
3649
+ margin: ti(r, a, o, s, t),
3650
+ position: ii(r.position),
3651
+ insets: ai(r, a, o, s, t),
3504
3652
  gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3505
3653
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3506
- border: hi(r),
3654
+ border: Ai(r),
3507
3655
  borderStyle: {
3508
- top: Gr(r.borderTopStyle),
3509
- right: Gr(r.borderRightStyle),
3510
- bottom: Gr(r.borderBottomStyle),
3511
- left: Gr(r.borderLeftStyle)
3656
+ top: oi(r.borderTopStyle),
3657
+ right: oi(r.borderRightStyle),
3658
+ bottom: oi(r.borderBottomStyle),
3659
+ left: oi(r.borderLeftStyle)
3660
+ },
3661
+ overflow: Vr(r),
3662
+ scrollbarWidth: Lr(e, r),
3663
+ scrollbarColor: Rr(r.scrollbarColor),
3664
+ overscroll: {
3665
+ x: (r.overscrollBehaviorX || "auto") === "auto",
3666
+ y: (r.overscrollBehaviorY || "auto") === "auto"
3667
+ },
3668
+ scrollbarSize: {
3669
+ x: zr(r.getPropertyValue("--mw-scrollbar-x-size")),
3670
+ y: zr(r.getPropertyValue("--mw-scrollbar-y-size"))
3512
3671
  },
3513
- overflow: Er(r.overflow) || Er(r.overflowX) || Er(r.overflowY) ? "clip" : "visible",
3514
3672
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3515
3673
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3516
- lineGap: Hr(r.lineHeight, i),
3517
- tracking: Vr(r.letterSpacing, i, n?.letterSpacing ?? 0),
3674
+ lineGap: ri(r.lineHeight, i),
3675
+ tracking: ni(r.letterSpacing, i, n?.letterSpacing ?? 0),
3518
3676
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3519
3677
  color: r.color,
3520
3678
  fontWeight: r.fontWeight,
3521
3679
  fontStyle: r.fontStyle,
3522
3680
  textDecorationLine: r.textDecorationLine,
3523
- backgroundColor: Tr(e, r.backgroundColor, r),
3681
+ backgroundColor: Mr(e, r.backgroundColor, r),
3524
3682
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3525
3683
  borderColor: {
3526
3684
  top: r.borderTopColor,
@@ -3528,18 +3686,18 @@ function Sr(e, t, n) {
3528
3686
  bottom: r.borderBottomColor,
3529
3687
  left: r.borderLeftColor
3530
3688
  },
3531
- textAlignBlocked: Pr(e, r),
3532
- textAlign: Fr(e, r),
3533
- textIndent: Jr(r, t),
3534
- opacity: qr(r.opacity),
3689
+ textAlignBlocked: Yr(e, r),
3690
+ textAlign: Xr(e, r),
3691
+ textIndent: li(r, t),
3692
+ opacity: ci(r.opacity),
3535
3693
  glyphSet: r.getPropertyValue("--mw-border-glyphs").trim() || null,
3536
3694
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3537
3695
  latticeBorder: null,
3538
- ruleX: p === "flex" || p === "grid" || p === "multicol" ? Nr(r, "x") : null,
3539
- ruleY: p === "flex" || p === "grid" ? Nr(r, "y") : null,
3540
- ruleBreak: Mr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3696
+ ruleX: p === "flex" || p === "grid" || p === "multicol" ? Jr(r, "x") : null,
3697
+ ruleY: p === "flex" || p === "grid" ? Jr(r, "y") : null,
3698
+ ruleBreak: qr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3541
3699
  ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, P(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3542
- ruleVisibilityItems: Mr(r, "--mw-rule-visibility-items", [
3700
+ ruleVisibilityItems: qr(r, "--mw-rule-visibility-items", [
3543
3701
  "all",
3544
3702
  "around",
3545
3703
  "between"
@@ -3552,9 +3710,9 @@ function Sr(e, t, n) {
3552
3710
  breakAfterColumn: r.breakAfter === "column",
3553
3711
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3554
3712
  };
3555
- return Cr(w, r), w;
3713
+ return Ar(w, r), w;
3556
3714
  }
3557
- function Cr(e, t) {
3715
+ function Ar(e, t) {
3558
3716
  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 = {
3559
3717
  width: e.border,
3560
3718
  style: e.borderStyle,
@@ -3565,26 +3723,70 @@ function Cr(e, t) {
3565
3723
  bottom: t.borderBottomStyle === "hidden",
3566
3724
  left: t.borderLeftStyle === "hidden"
3567
3725
  }
3568
- }, e.border = z(), e.display === "table" && (e.padding = z()));
3726
+ }, e.border = rt(), e.display === "table" && (e.padding = rt()));
3569
3727
  }
3570
- function wr(e) {
3728
+ function jr(e) {
3571
3729
  if (!e) return !0;
3572
3730
  let t = e.trim().toLowerCase();
3573
3731
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3574
3732
  }
3575
- function Tr(e, t, n) {
3576
- let i = r(e, wr(t) ? "" : t, n);
3733
+ function Mr(e, t, n) {
3734
+ let i = r(e, jr(t) ? "" : t, n);
3577
3735
  return i === "" ? void 0 : i;
3578
3736
  }
3579
- function Er(e) {
3737
+ function Nr(e) {
3580
3738
  return e === "hidden" || e === "clip";
3581
3739
  }
3582
- function Dr(e) {
3583
- if (e.position !== "absolute" && e.position !== "fixed") return !1;
3584
- let t = e.clip.replace(/\s/g, "");
3585
- return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (Er(e.overflow) || Er(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3740
+ var Pr = /* @__PURE__ */ new WeakMap(), Fr = null;
3741
+ function Ir(e) {
3742
+ if (Fr !== null) return Fr;
3743
+ if (!e.body) return !0;
3744
+ let t = e.createElement("div");
3745
+ return t.style.cssText = "position: absolute; width: 0; height: 0; overflow: auto", e.body.appendChild(t), Fr = getComputedStyle(t).scrollbarWidth !== "none", t.remove(), Fr;
3586
3746
  }
3587
- var Or = {
3747
+ function Lr(e, t) {
3748
+ if (!Ir(e.ownerDocument)) return "auto";
3749
+ if (e.hasAttribute("data-mw-scroll")) {
3750
+ let t = Pr.get(e);
3751
+ if (t !== void 0) return t;
3752
+ }
3753
+ let n = t.scrollbarWidth === "none" ? "none" : "auto";
3754
+ return Pr.set(e, n), n;
3755
+ }
3756
+ function Rr(e) {
3757
+ let t = (e ?? "").trim();
3758
+ if (!t || t === "auto") return null;
3759
+ let n = 0;
3760
+ for (let e = 0; e < t.length; e++) {
3761
+ let r = t[e];
3762
+ if (r === "(") n++;
3763
+ else if (r === ")") n--;
3764
+ else if (r === " " && n === 0) return {
3765
+ thumb: t.slice(0, e),
3766
+ track: t.slice(e + 1).trim()
3767
+ };
3768
+ }
3769
+ return null;
3770
+ }
3771
+ function zr(e) {
3772
+ return Math.max(1, Math.floor(Number(e) || 1));
3773
+ }
3774
+ function Br(e) {
3775
+ return Nr(e) ? "clip" : e === "auto" || e === "scroll" ? e : "visible";
3776
+ }
3777
+ function Vr(e) {
3778
+ let t = Br(e.overflowX || e.overflow), n = Br(e.overflowY || e.overflow);
3779
+ return t !== "visible" && n === "visible" && (n = "auto"), n !== "visible" && t === "visible" && (t = "auto"), {
3780
+ x: t,
3781
+ y: n
3782
+ };
3783
+ }
3784
+ function Hr(e, t) {
3785
+ if (t.position !== "absolute" && t.position !== "fixed") return !1;
3786
+ let n = t.clip.replace(/\s/g, "");
3787
+ return n === "rect(0px,0px,0px,0px)" || n === "rect(0,0,0,0)" || !ie(e.tagName) && (Nr(t.overflow) || Nr(t.overflowX)) && parseFloat(t.width) <= 1 && parseFloat(t.height) <= 1;
3788
+ }
3789
+ var Ur = {
3588
3790
  TABLE: "table",
3589
3791
  THEAD: "table-header-group",
3590
3792
  TBODY: "table-row-group",
@@ -3595,7 +3797,7 @@ var Or = {
3595
3797
  CAPTION: "table-caption",
3596
3798
  COL: "table-column",
3597
3799
  COLGROUP: "table-column-group"
3598
- }, kr = {
3800
+ }, Wr = {
3599
3801
  "table-header-group": "header-group",
3600
3802
  "table-row-group": "row-group",
3601
3803
  "table-footer-group": "footer-group",
@@ -3605,38 +3807,38 @@ var Or = {
3605
3807
  "table-column": "column",
3606
3808
  "table-column-group": "column-group"
3607
3809
  };
3608
- function Ar(e, t) {
3810
+ function Gr(e, t) {
3609
3811
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3610
3812
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3611
3813
  }
3612
- function jr(e, t, n) {
3613
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && M(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3814
+ function Kr(e, t, n) {
3815
+ (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && N(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3614
3816
  }
3615
- function Mr(e, t, n, r) {
3817
+ function qr(e, t, n, r) {
3616
3818
  let i = e.getPropertyValue(t).trim();
3617
3819
  return n.includes(i) ? i : r;
3618
3820
  }
3619
- function Nr(e, t) {
3821
+ function Jr(e, t) {
3620
3822
  let n = P(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3621
3823
  if (n <= 0) return null;
3622
3824
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3623
3825
  return {
3624
3826
  width: n,
3625
- style: Gr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3827
+ style: oi(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3626
3828
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3627
3829
  };
3628
3830
  }
3629
- function Pr(e, t) {
3831
+ function Yr(e, t) {
3630
3832
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3631
3833
  }
3632
- function Fr(e, t) {
3834
+ function Xr(e, t) {
3633
3835
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3634
3836
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3635
3837
  }
3636
- function Ir(e) {
3838
+ function Zr(e) {
3637
3839
  return typeof e.computedStyleMap == "function";
3638
3840
  }
3639
- function Lr(e) {
3841
+ function Qr(e) {
3640
3842
  switch (e) {
3641
3843
  case "center": return "center";
3642
3844
  case "flex-end":
@@ -3651,7 +3853,7 @@ function Lr(e) {
3651
3853
  default: return "start";
3652
3854
  }
3653
3855
  }
3654
- function Rr(e) {
3856
+ function $r(e) {
3655
3857
  switch (e) {
3656
3858
  case "center": return "center";
3657
3859
  case "flex-end":
@@ -3662,10 +3864,10 @@ function Rr(e) {
3662
3864
  default: return "start";
3663
3865
  }
3664
3866
  }
3665
- function zr(e) {
3666
- return e === "auto" || e === "" || e === "normal" ? "auto" : Rr(e);
3867
+ function ei(e) {
3868
+ return e === "auto" || e === "" || e === "normal" ? "auto" : $r(e);
3667
3869
  }
3668
- function Br(e, t, n, r, i) {
3870
+ function ti(e, t, n, r, i) {
3669
3871
  let a = (a, o, s) => {
3670
3872
  if (t) {
3671
3873
  let e = t.get(a)?.toString().trim();
@@ -3689,16 +3891,16 @@ function Br(e, t, n, r, i) {
3689
3891
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3690
3892
  };
3691
3893
  }
3692
- function Vr(e, t, n) {
3894
+ function ni(e, t, n) {
3693
3895
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3694
3896
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3695
3897
  }
3696
- function Hr(e, t) {
3898
+ function ri(e, t) {
3697
3899
  if (!e || e === "normal" || t <= 0) return 0;
3698
3900
  let n = parseFloat(e);
3699
3901
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3700
3902
  }
3701
- function Ur(e) {
3903
+ function ii(e) {
3702
3904
  switch (e) {
3703
3905
  case "relative":
3704
3906
  case "absolute":
@@ -3707,7 +3909,7 @@ function Ur(e) {
3707
3909
  default: return "static";
3708
3910
  }
3709
3911
  }
3710
- function Wr(e, t, n, r, i) {
3912
+ function ai(e, t, n, r, i) {
3711
3913
  let a = (a, o) => {
3712
3914
  if (t) {
3713
3915
  let e = t.get(a)?.toString().trim();
@@ -3726,7 +3928,7 @@ function Wr(e, t, n, r, i) {
3726
3928
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3727
3929
  };
3728
3930
  }
3729
- function Gr(e) {
3931
+ function oi(e) {
3730
3932
  switch (e) {
3731
3933
  case "double": return "double";
3732
3934
  case "dashed": return "dashed";
@@ -3734,7 +3936,7 @@ function Gr(e) {
3734
3936
  default: return "solid";
3735
3937
  }
3736
3938
  }
3737
- function Kr(e, t) {
3939
+ function si(e, t) {
3738
3940
  if (!e || e === "none" || e === "auto") return;
3739
3941
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3740
3942
  if (e.endsWith("%")) {
@@ -3753,28 +3955,28 @@ function $(e, t) {
3753
3955
  let n = parseFloat(e);
3754
3956
  return Number.isFinite(n) ? F(n, t) : 0;
3755
3957
  }
3756
- function qr(e) {
3958
+ function ci(e) {
3757
3959
  let t = parseFloat(e);
3758
3960
  return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3759
3961
  }
3760
- function Jr(e, t) {
3962
+ function li(e, t) {
3761
3963
  let n = e.textIndent;
3762
3964
  if (!n || n.endsWith("%")) return 0;
3763
3965
  let r = parseFloat(n);
3764
3966
  return Number.isFinite(r) ? Math.max(0, F(r, t)) : 0;
3765
3967
  }
3766
- function Yr(e, t, n, r, i, a, o) {
3767
- let s = Xr(n === "width" ? a.width : a.height);
3968
+ function ui(e, t, n, r, i, a, o) {
3969
+ let s = di(n === "width" ? a.width : a.height);
3768
3970
  if (s !== null) return {
3769
3971
  kind: "cells",
3770
- value: Qr(s, n, o, r)
3972
+ value: pi(s, n, o, r)
3771
3973
  };
3772
- let c = Zr(i, n === "width" ? "w" : "h");
3974
+ let c = fi(i, n === "width" ? "w" : "h");
3773
3975
  if (c !== null) {
3774
3976
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3775
3977
  if (a || !Number.isFinite(i)) return {
3776
3978
  kind: "cells",
3777
- value: Qr(a ? i : c, n, o, r)
3979
+ value: pi(a ? i : c, n, o, r)
3778
3980
  };
3779
3981
  }
3780
3982
  if (e) {
@@ -3782,7 +3984,7 @@ function Yr(e, t, n, r, i, a, o) {
3782
3984
  if (t == null) return;
3783
3985
  let i = t.toString().trim();
3784
3986
  if (i === "auto") return { kind: "auto" };
3785
- let a = ti(i);
3987
+ let a = gi(i);
3786
3988
  if (a) return a;
3787
3989
  if (i.endsWith("%")) return {
3788
3990
  kind: "percent",
@@ -3796,16 +3998,16 @@ function Yr(e, t, n, r, i, a, o) {
3796
3998
  kind: "cells",
3797
3999
  value: P(parseFloat(i) / .25)
3798
4000
  };
3799
- let s = Xr(i);
4001
+ let s = di(i);
3800
4002
  if (s !== null) return {
3801
4003
  kind: "cells",
3802
- value: Qr(s, n, o, r)
4004
+ value: pi(s, n, o, r)
3803
4005
  };
3804
4006
  }
3805
4007
  let l = n === "width" ? a.width : a.height;
3806
4008
  if (l) {
3807
4009
  if (l === "auto") return { kind: "auto" };
3808
- let e = ti(l);
4010
+ let e = gi(l);
3809
4011
  if (e) return e;
3810
4012
  if (l.endsWith("%")) return {
3811
4013
  kind: "percent",
@@ -3840,7 +4042,7 @@ function Yr(e, t, n, r, i, a, o) {
3840
4042
  kind: "cells",
3841
4043
  value: P(Number(p[1]))
3842
4044
  };
3843
- if (!pi(i, u) || t === "auto") return { kind: "auto" };
4045
+ if (!Oi(i, u) || t === "auto") return { kind: "auto" };
3844
4046
  if (t.endsWith("%")) return {
3845
4047
  kind: "percent",
3846
4048
  value: parseFloat(t)
@@ -3851,7 +4053,7 @@ function Yr(e, t, n, r, i, a, o) {
3851
4053
  value: F(m, r)
3852
4054
  };
3853
4055
  }
3854
- function Xr(e) {
4056
+ function di(e) {
3855
4057
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
3856
4058
  if (!t || typeof window > "u") return null;
3857
4059
  let n = parseFloat(t[1]);
@@ -3859,7 +4061,7 @@ function Xr(e) {
3859
4061
  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;
3860
4062
  return n / 100 * o;
3861
4063
  }
3862
- function Zr(e, t) {
4064
+ function fi(e, t) {
3863
4065
  if (typeof window > "u") return null;
3864
4066
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
3865
4067
  if (n) {
@@ -3867,23 +4069,23 @@ function Zr(e, t) {
3867
4069
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
3868
4070
  }
3869
4071
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
3870
- return r ? Xr(r[1]) : null;
4072
+ return r ? di(r[1]) : null;
3871
4073
  }
3872
- function Qr(e, t, n, r) {
4074
+ function pi(e, t, n, r) {
3873
4075
  let i = t === "width" ? n?.width : n?.height;
3874
4076
  return i && i > 0 ? Math.max(0, Math.floor(e / i)) : F(e, r);
3875
4077
  }
3876
- function $r(e, t, n, r, i, a, o, s) {
3877
- let c = t.endsWith("width") ? "width" : "height", l = Xr(a.getPropertyValue(t)) ?? Xr(e?.get(t)?.toString().trim() ?? "");
3878
- if (l !== null) return Qr(l, c, o, s);
3879
- let u = Zr(r, i);
4078
+ function mi(e, t, n, r, i, a, o, s) {
4079
+ let c = t.endsWith("width") ? "width" : "height", l = di(a.getPropertyValue(t)) ?? di(e?.get(t)?.toString().trim() ?? "");
4080
+ if (l !== null) return pi(l, c, o, s);
4081
+ let u = fi(r, i);
3880
4082
  if (u === null) return;
3881
4083
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
3882
- if (!(!f && Number.isFinite(d))) return Qr(f ? d : u, c, o, s);
4084
+ if (!(!f && Number.isFinite(d))) return pi(f ? d : u, c, o, s);
3883
4085
  }
3884
- function ei(e, t) {
4086
+ function hi(e, t) {
3885
4087
  if (!e || e === "auto" || e === "content") return;
3886
- let n = ti(e);
4088
+ let n = gi(e);
3887
4089
  if (n) return n;
3888
4090
  if (e.endsWith("%")) {
3889
4091
  let t = parseFloat(e);
@@ -3898,27 +4100,27 @@ function ei(e, t) {
3898
4100
  value: F(r, t)
3899
4101
  } : void 0;
3900
4102
  }
3901
- function ti(e) {
4103
+ function gi(e) {
3902
4104
  if (e === "min-content") return { kind: "min-content" };
3903
4105
  if (e === "max-content") return { kind: "max-content" };
3904
4106
  if (e === "fit-content") return { kind: "fit-content" };
3905
4107
  }
3906
- function ni(e, t) {
4108
+ function _i(e, t) {
3907
4109
  let n = e.trim();
3908
4110
  if (!n || n === "none") return { kind: "none" };
3909
4111
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
3910
4112
  let r = [], i = [], a = [], o = (e) => {
3911
4113
  i.push(a), a = [], r.push(e);
3912
4114
  }, s;
3913
- for (let e of ui(n)) {
3914
- let n = ii(e);
4115
+ for (let e of Ti(n)) {
4116
+ let n = yi(e);
3915
4117
  if (n) {
3916
4118
  a.push(...n);
3917
4119
  continue;
3918
4120
  }
3919
4121
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
3920
4122
  if (i) {
3921
- let e = ri(i[2].trim(), t);
4123
+ let e = vi(i[2].trim(), t);
3922
4124
  if (e.tracks.length === 0) continue;
3923
4125
  let n = i[1];
3924
4126
  if (n === "auto-fill" || n === "auto-fit") {
@@ -3936,7 +4138,7 @@ function ni(e, t) {
3936
4138
  }
3937
4139
  continue;
3938
4140
  }
3939
- o(si(e, t));
4141
+ o(Si(e, t));
3940
4142
  }
3941
4143
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
3942
4144
  let c = {
@@ -3945,26 +4147,26 @@ function ni(e, t) {
3945
4147
  };
3946
4148
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
3947
4149
  }
3948
- function ri(e, t) {
4150
+ function vi(e, t) {
3949
4151
  let n = [], r = [], i = [];
3950
- for (let a of ui(e)) {
3951
- let e = ii(a);
4152
+ for (let a of Ti(e)) {
4153
+ let e = yi(a);
3952
4154
  if (e) {
3953
4155
  i.push(...e);
3954
4156
  continue;
3955
4157
  }
3956
- r.push(i), i = [], n.push(si(a, t));
4158
+ r.push(i), i = [], n.push(Si(a, t));
3957
4159
  }
3958
4160
  return r.push(i), {
3959
4161
  tracks: n,
3960
4162
  lineNames: r
3961
4163
  };
3962
4164
  }
3963
- function ii(e) {
4165
+ function yi(e) {
3964
4166
  let t = e.match(/^\[(.*)\]$/s);
3965
4167
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
3966
4168
  }
3967
- function ai(e) {
4169
+ function bi(e) {
3968
4170
  let t = [];
3969
4171
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
3970
4172
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -3994,23 +4196,23 @@ function ai(e) {
3994
4196
  areas: r
3995
4197
  };
3996
4198
  }
3997
- function oi(e, t) {
3998
- let n = ui(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => si(e, t));
3999
- return n.length > 0 ? n : [et()];
4199
+ function xi(e, t) {
4200
+ let n = Ti(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Si(e, t));
4201
+ return n.length > 0 ? n : [it()];
4000
4202
  }
4001
- function si(e, t) {
4203
+ function Si(e, t) {
4002
4204
  let n = e.match(/^minmax\((.*)\)$/s);
4003
4205
  if (n) {
4004
- let e = li(n[1]).map((e) => e.trim());
4206
+ let e = wi(n[1]).map((e) => e.trim());
4005
4207
  return e.length === 2 ? {
4006
- min: ci(e[0], t),
4007
- max: ci(e[1], t)
4208
+ min: Ci(e[0], t),
4209
+ max: Ci(e[1], t)
4008
4210
  } : {
4009
4211
  min: { kind: "auto" },
4010
4212
  max: { kind: "auto" }
4011
4213
  };
4012
4214
  }
4013
- let r = ci(e, t);
4215
+ let r = Ci(e, t);
4014
4216
  return r.kind === "fr" ? {
4015
4217
  min: { kind: "auto" },
4016
4218
  max: r
@@ -4019,13 +4221,13 @@ function si(e, t) {
4019
4221
  max: r
4020
4222
  };
4021
4223
  }
4022
- function ci(e, t) {
4224
+ function Ci(e, t) {
4023
4225
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
4024
4226
  if (e === "min-content") return { kind: "min-content" };
4025
4227
  if (e === "max-content") return { kind: "max-content" };
4026
4228
  let n = e.match(/^(min|max)\((.*)\)$/s);
4027
4229
  if (n) {
4028
- let e = li(n[2]).map((e) => ci(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4230
+ let e = wi(n[2]).map((e) => Ci(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4029
4231
  return e.length > 0 && r ? {
4030
4232
  kind: "math",
4031
4233
  fn: n[1],
@@ -4052,7 +4254,7 @@ function ci(e, t) {
4052
4254
  value: e.endsWith("rem") ? P(r / .25) : F(r, t)
4053
4255
  } : { kind: "auto" };
4054
4256
  }
4055
- function li(e) {
4257
+ function wi(e) {
4056
4258
  let t = [], n = 0, r = 0;
4057
4259
  for (let i = 0; i < e.length; i++) {
4058
4260
  let a = e[i];
@@ -4060,7 +4262,7 @@ function li(e) {
4060
4262
  }
4061
4263
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
4062
4264
  }
4063
- function ui(e) {
4265
+ function Ti(e) {
4064
4266
  let t = [], n = 0, r = -1;
4065
4267
  for (let i = 0; i < e.length; i++) {
4066
4268
  let a = e[i];
@@ -4068,7 +4270,7 @@ function ui(e) {
4068
4270
  }
4069
4271
  return r !== -1 && t.push(e.slice(r)), t;
4070
4272
  }
4071
- function di(e) {
4273
+ function Ei(e) {
4072
4274
  let t = e.trim();
4073
4275
  if (!t || t === "auto") return { kind: "auto" };
4074
4276
  let n = !1, r, i;
@@ -4096,16 +4298,16 @@ function di(e) {
4096
4298
  nth: r
4097
4299
  };
4098
4300
  }
4099
- function fi(e) {
4301
+ function Di(e) {
4100
4302
  return {
4101
4303
  direction: e.includes("column") ? "column" : "row",
4102
4304
  dense: e.includes("dense")
4103
4305
  };
4104
4306
  }
4105
- function pi(e, t) {
4307
+ function Oi(e, t) {
4106
4308
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
4107
4309
  }
4108
- function mi(e, t) {
4310
+ function ki(e, t) {
4109
4311
  return {
4110
4312
  top: $(e.getPropertyValue("padding-top"), t),
4111
4313
  right: $(e.getPropertyValue("padding-right"), t),
@@ -4113,7 +4315,7 @@ function mi(e, t) {
4113
4315
  left: $(e.getPropertyValue("padding-left"), t)
4114
4316
  };
4115
4317
  }
4116
- function hi(e) {
4318
+ function Ai(e) {
4117
4319
  let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : P(parseFloat(e.getPropertyValue(t)) || 0);
4118
4320
  return {
4119
4321
  top: t("border-top-width", "border-top-style"),
@@ -4124,14 +4326,14 @@ function hi(e) {
4124
4326
  }
4125
4327
  //#endregion
4126
4328
  //#region src/tree.ts
4127
- function gi(e, t, n, r) {
4128
- let i = Sr(e, t, n);
4329
+ function ji(e, t, n, r) {
4330
+ let i = kr(e, t, n);
4129
4331
  if (i.display === "none") return null;
4130
- let a = re(e.tagName);
4131
- if (a) return _i(e, i, a);
4132
- let o = Array.from(e.children), s = o.map(Si), c = e.tagName, l = Ni(c);
4332
+ let a = ie(e.tagName);
4333
+ if (a) return Mi(e, i, a);
4334
+ let o = Array.from(e.children), s = o.map(Li), c = e.tagName, l = Ji(c);
4133
4335
  if (!s.includes("block") || l) {
4134
- let a = Ci(e, i.tracking, {
4336
+ let a = Ri(e, i.tracking, {
4135
4337
  rootFontSizePx: t,
4136
4338
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
4137
4339
  cellMetrics: n,
@@ -4140,12 +4342,12 @@ function gi(e, t, n, r) {
4140
4342
  tabSize: i.tabSize
4141
4343
  }), u = a.chars.join("");
4142
4344
  if (a.boxes.length > 0) {
4143
- let e = Mn();
4144
- Me(a.chars, (t, n) => {
4345
+ let e = In();
4346
+ Pe(a.chars, (t, n) => {
4145
4347
  a.advances[t] = Math.max(1, J(a.boxes[n], e));
4146
4348
  });
4147
4349
  }
4148
- let d = Oi(u, a.advances, i.tracking);
4350
+ let d = Ui(u, a.advances, i.tracking);
4149
4351
  if (l && d === 0) {
4150
4352
  if (c === "INPUT") d = Number(e.size) || 20;
4151
4353
  else if (c === "TEXTAREA") d = Number(e.cols) || 20;
@@ -4154,9 +4356,9 @@ function gi(e, t, n, r) {
4154
4356
  d = Math.max(1, ...r.map((e) => e.trim().length));
4155
4357
  }
4156
4358
  }
4157
- let f = u.length > 0 ? ki(u) : 0, p;
4359
+ let f = u.length > 0 ? Wi(u) : 0, p;
4158
4360
  if (c === "TEXTAREA") {
4159
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? Te(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);
4361
+ let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? De(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);
4160
4362
  p = l + Math.max(0, l - 1) * i.lineGap;
4161
4363
  } else p = l ? Math.max(1, f) : f;
4162
4364
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -4166,7 +4368,7 @@ function gi(e, t, n, r) {
4166
4368
  let i = o[e], a = m.get(i);
4167
4369
  if (a) g.push(a);
4168
4370
  else if (s[e] === "out-of-flow") {
4169
- let e = gi(i, t, n, r);
4371
+ let e = ji(i, t, n, r);
4170
4372
  e && g.push(e);
4171
4373
  }
4172
4374
  }
@@ -4185,14 +4387,14 @@ function gi(e, t, n, r) {
4185
4387
  height: p
4186
4388
  },
4187
4389
  unclampedHeight: 0,
4188
- resolvedPadding: z()
4390
+ resolvedPadding: rt()
4189
4391
  };
4190
4392
  return (a.advances.some((e) => e !== 1) || a.boxes.length > 0) && (_.advances = a.advances), a.inlineElements.length > 0 && (_.inlineElements = a.inlineElements, _.charInline = a.chars.map((e, t) => a.inlineIndex[t] ?? -1)), _;
4191
4393
  }
4192
4394
  let u = [];
4193
4395
  for (let e = 0; e < o.length; e++) {
4194
4396
  if (s[e] === "none") continue;
4195
- let i = gi(o[e], t, n, r);
4397
+ let i = ji(o[e], t, n, r);
4196
4398
  i && u.push(i);
4197
4399
  }
4198
4400
  let d = {
@@ -4209,34 +4411,36 @@ function gi(e, t, n, r) {
4209
4411
  height: 0
4210
4412
  },
4211
4413
  unclampedHeight: 0,
4212
- resolvedPadding: z()
4414
+ resolvedPadding: rt()
4213
4415
  };
4214
- return Pi(e, d), d;
4416
+ return Yi(e, d), d;
4215
4417
  }
4216
- function _i(e, t, n) {
4217
- let r = oe(n, e), i = r?.lines ?? [], a = i.join("\n");
4418
+ function Mi(e, t, n) {
4419
+ let r = se(n, e), i = r?.lines ?? [], a = i.join("\n");
4218
4420
  t.whiteSpace = "pre", (t.width === void 0 || t.width.kind === "auto") && (t.width = { kind: "max-content" });
4219
- let o = Oi(a, Array.from({ length: a.length }, () => 1), t.tracking), s = i.length, c = {
4421
+ let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Ui(a, o, t.tracking), c = i.length, l = {
4220
4422
  source: e,
4221
4423
  style: t,
4222
4424
  children: [],
4223
4425
  text: a,
4224
- intrinsicWidth: o,
4225
- intrinsicHeight: s,
4426
+ intrinsicWidth: s,
4427
+ intrinsicHeight: c,
4226
4428
  localRect: {
4227
4429
  x: 0,
4228
4430
  y: 0,
4229
- width: o,
4230
- height: s
4431
+ width: s,
4432
+ height: c
4231
4433
  },
4232
4434
  unclampedHeight: 0,
4233
- resolvedPadding: z()
4234
- }, l = r?.runs ?? [];
4235
- if (l.length > 0 && a.length > 0) {
4435
+ resolvedPadding: rt()
4436
+ };
4437
+ t.tracking > 0 && (l.advances = o);
4438
+ let u = r?.runs ?? [];
4439
+ if (u.length > 0 && a.length > 0) {
4236
4440
  let t = [0];
4237
4441
  for (let e of i) t.push(t[t.length - 1] + e.length + 1);
4238
4442
  let n = Array.from({ length: a.length }, () => -1);
4239
- c.inlineElements = l.map((t) => ({
4443
+ l.inlineElements = u.map((t) => ({
4240
4444
  element: e,
4241
4445
  tracking: 0,
4242
4446
  padLeft: 0,
@@ -4247,32 +4451,32 @@ function _i(e, t, n) {
4247
4451
  fontWeight: t.paint.fontWeight ?? "",
4248
4452
  fontStyle: t.paint.fontStyle ?? "",
4249
4453
  textDecorationLine: t.paint.textDecorationLine ?? ""
4250
- })), l.forEach((e, r) => {
4454
+ })), u.forEach((e, r) => {
4251
4455
  let a = i[e.line];
4252
4456
  if (a === void 0) return;
4253
4457
  let o = Math.max(0, e.start), s = Math.min(a.length, e.end);
4254
4458
  for (let i = o; i < s; i++) n[t[e.line] + i] = r;
4255
- }), c.charInline = n;
4459
+ }), l.charInline = n;
4256
4460
  }
4257
- return c;
4461
+ return l;
4258
4462
  }
4259
- var vi = /* @__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("."));
4260
- function yi(e, t) {
4261
- return t || (vi.has(e.tagName) ? "inline" : "block");
4463
+ var Ni = /* @__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("."));
4464
+ function Pi(e, t) {
4465
+ return t || (Ni.has(e.tagName) ? "inline" : "block");
4262
4466
  }
4263
- function bi(e, t) {
4264
- let n = yi(e, t);
4467
+ function Fi(e, t) {
4468
+ let n = Pi(e, t);
4265
4469
  return n === "inline" || n === "contents";
4266
4470
  }
4267
- function xi(e, t) {
4268
- let n = yi(e, t);
4471
+ function Ii(e, t) {
4472
+ let n = Pi(e, t);
4269
4473
  return n.startsWith("inline") && n !== "inline";
4270
4474
  }
4271
- function Si(e) {
4475
+ function Li(e) {
4272
4476
  let t = getComputedStyle(e);
4273
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : re(e.tagName) ? "block" : bi(e, t.display) || xi(e, t.display) ? "inline" : "block";
4477
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : ie(e.tagName) ? "block" : Fi(e, t.display) || Ii(e, t.display) ? "inline" : "block";
4274
4478
  }
4275
- function Ci(e, t, n) {
4479
+ function Ri(e, t, n) {
4276
4480
  let r = {
4277
4481
  chars: [],
4278
4482
  advances: [],
@@ -4280,15 +4484,15 @@ function Ci(e, t, n) {
4280
4484
  inlineElements: [],
4281
4485
  boxes: []
4282
4486
  };
4283
- return wi(e, t, n, r), n.preserve ? r : Di(r);
4487
+ return zi(e, t, n, r), n.preserve ? r : Hi(r);
4284
4488
  }
4285
- function wi(e, t, n, r) {
4489
+ function zi(e, t, n, r) {
4286
4490
  let i = () => {
4287
4491
  let e = 0;
4288
4492
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
4289
4493
  return e;
4290
4494
  };
4291
- if (!Ni(e.tagName)) {
4495
+ if (!Ji(e.tagName)) {
4292
4496
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
4293
4497
  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);
4294
4498
  else if (e === " ") {
@@ -4304,24 +4508,24 @@ function wi(e, t, n, r) {
4304
4508
  }
4305
4509
  let t = getComputedStyle(e);
4306
4510
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
4307
- if (xi(e, t.display)) {
4308
- let t = gi(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4511
+ if (Ii(e, t.display)) {
4512
+ let t = ji(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4309
4513
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
4310
4514
  continue;
4311
4515
  }
4312
- if (!bi(e, t.display)) {
4313
- Ai(e);
4516
+ if (!Fi(e, t.display)) {
4517
+ Gi(e);
4314
4518
  continue;
4315
4519
  }
4316
- let i = Vr(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Ti(t.paddingLeft, n.rootFontSizePx), s = Ti(t.paddingRight, n.rootFontSizePx);
4520
+ let i = ni(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Bi(t.paddingLeft, n.rootFontSizePx), s = Bi(t.paddingRight, n.rootFontSizePx);
4317
4521
  r.inlineElements.push({
4318
4522
  element: e,
4319
4523
  tracking: i,
4320
4524
  padLeft: o,
4321
4525
  padRight: s,
4322
- insets: t.position === "static" ? null : Ei(t, n.rootFontSizePx),
4526
+ insets: t.position === "static" ? null : Vi(t, n.rootFontSizePx),
4323
4527
  color: t.color,
4324
- backgroundColor: wr(t.backgroundColor) ? void 0 : t.backgroundColor,
4528
+ backgroundColor: jr(t.backgroundColor) ? void 0 : t.backgroundColor,
4325
4529
  fontWeight: t.fontWeight,
4326
4530
  fontStyle: t.fontStyle,
4327
4531
  textDecorationLine: t.textDecorationLine
@@ -4329,18 +4533,18 @@ function wi(e, t, n, r) {
4329
4533
  let c = r.inlineElements.length - 1;
4330
4534
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4331
4535
  let l = r.chars.length;
4332
- wi(e, i, n, r);
4536
+ zi(e, i, n, r);
4333
4537
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
4334
4538
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4335
4539
  }
4336
4540
  }
4337
4541
  }
4338
- function Ti(e, t) {
4542
+ function Bi(e, t) {
4339
4543
  if (!e || e.endsWith("%")) return 0;
4340
4544
  let n = parseFloat(e);
4341
4545
  return Number.isFinite(n) ? Math.max(0, F(n, t)) : 0;
4342
4546
  }
4343
- function Ei(e, t) {
4547
+ function Vi(e, t) {
4344
4548
  let n = (e) => {
4345
4549
  if (!e || e === "auto" || e.endsWith("%")) return null;
4346
4550
  let n = parseFloat(e);
@@ -4353,7 +4557,7 @@ function Ei(e, t) {
4353
4557
  left: n(e.left)
4354
4558
  };
4355
4559
  }
4356
- function Di(e) {
4560
+ function Hi(e) {
4357
4561
  let t = [], n = [], r = [], i = () => {
4358
4562
  let e = t.length;
4359
4563
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -4378,30 +4582,30 @@ function Di(e) {
4378
4582
  boxes: e.boxes
4379
4583
  };
4380
4584
  }
4381
- function Oi(e, t, n) {
4585
+ function Ui(e, t, n) {
4382
4586
  let r = 0, i = 0;
4383
4587
  for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, I(i, a, t, n)), i = a + 1);
4384
4588
  return r;
4385
4589
  }
4386
- function ki(e) {
4387
- return De(e).length;
4590
+ function Wi(e) {
4591
+ return ke(e).length;
4388
4592
  }
4389
- function Ai(e) {
4390
- M(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.");
4593
+ function Gi(e) {
4594
+ N(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.");
4391
4595
  }
4392
- function ji(e) {
4596
+ function Ki(e) {
4393
4597
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
4394
4598
  }
4395
- var Mi = "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>).";
4396
- function Ni(e) {
4599
+ var qi = "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>).";
4600
+ function Ji(e) {
4397
4601
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
4398
4602
  }
4399
- function Pi(e, t) {
4400
- ji(e) && (t.droppedText = !0, M(e, Mi));
4603
+ function Yi(e, t) {
4604
+ Ki(e) && (t.droppedText = !0, N(e, qi));
4401
4605
  }
4402
4606
  //#endregion
4403
4607
  //#region src/element.ts
4404
- var Fi = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n #grid { position: absolute; inset: 0; margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; pointer-events: none; user-select: none; -webkit-user-select: none; }\n :host([select=\"grid\"]) #grid { pointer-events: auto; user-select: text; -webkit-user-select: text; }\n :host([select=\"grid\"]) slot { pointer-events: none; user-select: none; -webkit-user-select: none; }\n /* Full invert on selection (TUI-native, matches focus-visible).\n * Both fields spelled out — setting only color makes some engines\n * drop the OS default background. */\n ::selection { color: var(--mw-bg, canvas); background: var(--mw-fg, canvastext); }\n</style>\n<div id=\"viewport\">\n <pre id=\"grid\" aria-hidden=\"true\"></pre>\n <slot></slot>\n</div>\n", Ii = "grid", Li = [
4608
+ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; background: inherit; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n /* Sized by the engine's ink extent (element.ts), not the host box:\n * visible overflow paints past the host (specs/cell-model.md\n * \"Overflow\"), and the host's background follows it there — the\n * host is the canvas, as the root element's background covers a\n * document's overflow — inherited through #viewport, the shadow\n * parent. (A translucent host background paints repeatedly inside\n * the box.) */\n #grid { position: absolute; top: 0; left: 0; margin: 0; background: inherit; 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 /* Selection invert mirror of the canonical rule in styles.css\n * (which explains the field choices); update together. */\n ::selection { color: var(--mw-bg, canvas); text-shadow: 0 0 0 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", Zi = "grid", Qi = [
4405
4609
  "pointerover",
4406
4610
  "pointerleave",
4407
4611
  "pointerdown",
@@ -4413,12 +4617,12 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4413
4617
  "focusout",
4414
4618
  "input",
4415
4619
  "change"
4416
- ], Ri = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, zi = 3e4, Bi = typeof HTMLElement > "u" ? class {} : HTMLElement, Vi = class e extends Bi {
4620
+ ], $i = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, ea = 3e4, ta = 200, na = 3, ra = 4, ia = 8, aa = 160, oa = typeof HTMLElement > "u" ? class {} : HTMLElement, sa = class e extends oa {
4417
4621
  static observedAttributes = ["select"];
4418
4622
  static #e = /* @__PURE__ */ new Set();
4419
4623
  static #t = null;
4420
4624
  static #n = () => {
4421
- for (let t of e.#e) t.#G();
4625
+ for (let t of e.#e) t.#se();
4422
4626
  };
4423
4627
  static #r(t) {
4424
4628
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -4449,7 +4653,13 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4449
4653
  #p = null;
4450
4654
  #m = null;
4451
4655
  #h = null;
4452
- #g() {
4656
+ #g = !1;
4657
+ #_ = [];
4658
+ #v = /* @__PURE__ */ new Map();
4659
+ #y = /* @__PURE__ */ new WeakMap();
4660
+ #b = null;
4661
+ #x = null;
4662
+ #S() {
4453
4663
  this.#u?.observe(this, {
4454
4664
  childList: !0,
4455
4665
  subtree: !0,
@@ -4461,89 +4671,273 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4461
4671
  "colspan",
4462
4672
  "rowspan",
4463
4673
  "span",
4464
- ...ie()
4674
+ ...ae()
4465
4675
  ]
4466
4676
  });
4467
4677
  }
4468
4678
  constructor() {
4469
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Fi, 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);
4679
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Xi, 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);
4470
4680
  }
4471
4681
  connectedCallback() {
4472
- this.hasAttribute("select") || this.setAttribute("select", Ii), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#G()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#V), this.#u = new MutationObserver(() => this.#G()), this.#g(), this.#m = ae(() => {
4473
- this.#g(), this.#G();
4474
- }), this.#h = C(() => this.#G()), document.fonts?.ready.then(this.#H).catch((e) => {
4682
+ this.hasAttribute("select") || this.setAttribute("select", Zi), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#se()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#re), this.#u = new MutationObserver(() => this.#se()), this.#S(), this.#m = oe(() => {
4683
+ this.#S(), this.#se();
4684
+ }), this.#h = C(() => this.#se()), document.fonts?.ready.then(this.#ie).catch((e) => {
4475
4685
  console.warn("[monowind] document.fonts.ready failed:", e);
4476
- }), document.fonts?.addEventListener("loadingdone", this.#H);
4477
- for (let e of Li) this.addEventListener(e, this.#B);
4478
- this.addEventListener("transitionrun", this.#L), this.addEventListener("transitionend", this.#R), this.addEventListener("transitioncancel", this.#R), this.addEventListener("pointermove", this.#D), this.addEventListener("pointerleave", this.#O), this.addEventListener("pointerdown", this.#k), window.addEventListener("pointerup", this.#A), window.addEventListener("pointercancel", this.#A), document.addEventListener("scroll", this.#j, {
4686
+ }), document.fonts?.addEventListener("loadingdone", this.#ie);
4687
+ for (let e of Qi) this.addEventListener(e, this.#ne);
4688
+ this.addEventListener("transitionrun", this.#$), this.addEventListener("transitionend", this.#ee), this.addEventListener("transitioncancel", this.#ee), this.addEventListener("pointermove", this.#U), this.addEventListener("pointerleave", this.#W), this.addEventListener("pointerdown", this.#G), this.addEventListener("scroll", this.#L, {
4689
+ capture: !0,
4690
+ passive: !0
4691
+ }), this.addEventListener("scrollend", this.#R, { capture: !0 }), this.addEventListener("wheel", this.#B, { passive: !1 }), window.addEventListener("pointerup", this.#K), window.addEventListener("pointercancel", this.#K), document.addEventListener("scroll", this.#q, {
4479
4692
  capture: !0,
4480
4693
  passive: !0
4481
- }), e.#i(this), this.#G();
4694
+ }), e.#i(this), this.#se();
4482
4695
  }
4483
4696
  disconnectedCallback() {
4484
- window.removeEventListener("resize", this.#V), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, this.#h?.(), this.#h = null, document.fonts?.removeEventListener("loadingdone", this.#H);
4485
- for (let e of Li) this.removeEventListener(e, this.#B);
4486
- this.removeEventListener("transitionrun", this.#L), this.removeEventListener("transitionend", this.#R), this.removeEventListener("transitioncancel", this.#R), this.#P = 0, this.removeEventListener("pointermove", this.#D), this.removeEventListener("pointerleave", this.#O), this.removeEventListener("pointerdown", this.#k), window.removeEventListener("pointerup", this.#A), window.removeEventListener("pointercancel", this.#A), document.removeEventListener("scroll", this.#j, { capture: !0 }), this.#S = null, this.#y = null, this.#b = !1, this.#x = !1, this.#M(), e.#a(this);
4487
- }
4488
- #_ = /* @__PURE__ */ new Set();
4489
- #v = /* @__PURE__ */ new Set();
4490
- #y = null;
4491
- #b = !1;
4492
- #x = !1;
4493
- #S = null;
4494
- #C = NaN;
4495
- #w = NaN;
4697
+ window.removeEventListener("resize", this.#re), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, this.#h?.(), this.#h = null, document.fonts?.removeEventListener("loadingdone", this.#ie);
4698
+ for (let e of Qi) this.removeEventListener(e, this.#ne);
4699
+ this.removeEventListener("transitionrun", this.#$), this.removeEventListener("transitionend", this.#ee), this.removeEventListener("transitioncancel", this.#ee), this.#X = 0, this.removeEventListener("pointermove", this.#U), this.removeEventListener("pointerleave", this.#W), this.removeEventListener("pointerdown", this.#G), this.removeEventListener("scroll", this.#L, { capture: !0 }), this.removeEventListener("scrollend", this.#R, { capture: !0 }), this.removeEventListener("wheel", this.#B);
4700
+ for (let e of this.#v.values()) clearTimeout(e);
4701
+ this.#v.clear(), this.#x = null, this.#b = null, window.removeEventListener("pointerup", this.#K), window.removeEventListener("pointercancel", this.#K), document.removeEventListener("scroll", this.#q, { capture: !0 }), this.#O = null, this.#T = null, this.#E = !1, this.#D = !1, this.#J(), e.#a(this);
4702
+ }
4703
+ #C = /* @__PURE__ */ new Set();
4704
+ #w = /* @__PURE__ */ new Set();
4496
4705
  #T = null;
4497
- static #E = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4498
- #D = (e) => {
4499
- let { clientX: t, clientY: n } = e;
4500
- this.#S = {
4706
+ #E = !1;
4707
+ #D = !1;
4708
+ #O = null;
4709
+ #k = NaN;
4710
+ #A = NaN;
4711
+ #j = null;
4712
+ static #M = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4713
+ #N() {
4714
+ if (this.#g || this.#d) return;
4715
+ this.#g = !0;
4716
+ let e = !1, t = () => {
4717
+ if (e) return;
4718
+ e = !0, this.#g = !1;
4719
+ let t = this.#f;
4720
+ !this.isConnected || !this.#p || !t || (this.#P(t), this.#D = !gr(this.#p, this.#s, this.#E), this.#J());
4721
+ };
4722
+ requestAnimationFrame(t), setTimeout(t, 50);
4723
+ }
4724
+ #P(e, t) {
4725
+ for (let n of this.#_) {
4726
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = t?.get(r);
4727
+ n.scroll = o ? {
4728
+ x: o.pinX ? i : Math.min(o.x, i),
4729
+ y: o.pinY ? a : Math.min(o.y, a)
4730
+ } : {
4731
+ x: la(r, "x", e.width, i),
4732
+ y: la(r, "y", e.height, a)
4733
+ };
4734
+ }
4735
+ }
4736
+ #F() {
4737
+ let e = /* @__PURE__ */ new Map(), t = this.#f;
4738
+ if (!t) return e;
4739
+ for (let n of this.#_) {
4740
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = la(r, "x", t.width, i), s = la(r, "y", t.height, a);
4741
+ e.set(r, {
4742
+ top: r.scrollTop,
4743
+ left: r.scrollLeft,
4744
+ x: o,
4745
+ y: s,
4746
+ pinX: i > 0 && o >= i,
4747
+ pinY: a > 0 && s >= a
4748
+ });
4749
+ }
4750
+ return e;
4751
+ }
4752
+ #I(e) {
4753
+ for (let t of this.#_) {
4754
+ let n = t.source, r = e.get(n);
4755
+ r && (n.scrollTop = r.pinY ? n.scrollHeight : r.top, n.scrollLeft = r.pinX ? n.scrollWidth : r.left, n.scrollTop, n.scrollLeft);
4756
+ }
4757
+ }
4758
+ #L = (e) => {
4759
+ let t = e.target;
4760
+ !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (this.#N(), "onscrollend" in window || (clearTimeout(this.#v.get(t)), this.#v.set(t, setTimeout(() => this.#z(t), aa))));
4761
+ };
4762
+ #R = (e) => {
4763
+ let t = e.target;
4764
+ !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < ta || this.#z(t));
4765
+ };
4766
+ #z(e) {
4767
+ if (this.#x?.el === e) return;
4768
+ this.#N();
4769
+ let t = this.#f, n = this.#_.find((t) => t.source === e);
4770
+ if (!t || !n) return;
4771
+ let r = n.scrollRange, i = (e, t, n, r) => {
4772
+ let i = Math.min(Math.max(0, Math.round(e / t)), n);
4773
+ return i === n ? r : i * t;
4774
+ }, a = i(e.scrollTop, t.height, r.maxY, e.scrollHeight - e.clientHeight), o = i(e.scrollLeft, t.width, r.maxX, e.scrollWidth - e.clientWidth);
4775
+ (Math.abs(e.scrollTop - a) > .5 || Math.abs(e.scrollLeft - o) > .5) && e.scrollTo({
4776
+ top: a,
4777
+ left: o,
4778
+ behavior: "instant"
4779
+ });
4780
+ }
4781
+ #B = (e) => {
4782
+ if (this.getAttribute("select") !== "grid") return;
4783
+ let t = this.#p, n = this.#f;
4784
+ if (!t || !n || this.#_.length === 0) return;
4785
+ let r = e;
4786
+ if (!r.cancelable) return;
4787
+ let { col: i, row: a } = this.#V(r.clientX, r.clientY, n), o = r.deltaMode === 1 ? n.height : r.deltaMode === 2 ? this.clientHeight : 1, s = r.deltaX * o, c = r.deltaY * o, l = Date.now(), u = Math.abs(s) + Math.abs(c);
4788
+ if (u === 0) {
4789
+ this.#b = null;
4790
+ return;
4791
+ }
4792
+ let d = (e) => {
4793
+ let t = e.scrollRange, n = e.source;
4794
+ return c !== 0 && t.maxY > 0 && (c > 0 && n.scrollTop < n.scrollHeight - n.clientHeight - .5 || c < 0 && n.scrollTop > .5) || s !== 0 && t.maxX > 0 && (s > 0 && n.scrollLeft < n.scrollWidth - n.clientWidth - .5 || s < 0 && n.scrollLeft > .5);
4795
+ }, f = this.#b, p = Math.abs(s) >= Math.abs(c) ? "x" : "y", m = f !== null && u > f.mag * 1.25 + 1, h = f !== null && (Math.abs(r.clientX - f.x) > na || Math.abs(r.clientY - f.y) > na), g = f !== null && f.decayed >= ia, _ = f !== null && l - f.at < ta && p === f.axis && (h ? u <= f.mag : !(g && m)), v = null;
4796
+ if (_) {
4797
+ if (f.decayed = u <= f.mag && u >= f.mag * .5 ? f.decayed + 1 : g ? f.decayed : 0, f.mag = u, f.at = l, !f.el) return;
4798
+ v = this.#_.find((e) => e.source === f.el) ?? null;
4799
+ }
4800
+ if (!v) {
4801
+ let e = xe(t, i, a);
4802
+ for (let t = e.length - 1; t >= 0; t--) {
4803
+ let n = e[t].node;
4804
+ if (!n.scrollRange) continue;
4805
+ if (d(n)) {
4806
+ v = n;
4807
+ break;
4808
+ }
4809
+ let r = n.style.overscroll;
4810
+ if (c !== 0 && !r.y || s !== 0 && !r.x) {
4811
+ v = n;
4812
+ break;
4813
+ }
4814
+ }
4815
+ if (!v && u < ra) {
4816
+ r.preventDefault();
4817
+ return;
4818
+ }
4819
+ this.#b = {
4820
+ el: v ? v.source : null,
4821
+ x: r.clientX,
4822
+ y: r.clientY,
4823
+ axis: p,
4824
+ at: l,
4825
+ mag: u,
4826
+ decayed: 0
4827
+ };
4828
+ }
4829
+ if (!v || (r.preventDefault(), !d(v))) return;
4830
+ let y = v.source, b = v.scrollRange, x = { behavior: "instant" };
4831
+ c !== 0 && b.maxY > 0 && (x.top = c), s !== 0 && b.maxX > 0 && (x.left = s), y.scrollBy(x), this.#y.set(y, l), clearTimeout(this.#v.get(y)), this.#v.set(y, setTimeout(() => this.#z(y), ta));
4832
+ };
4833
+ #V(e, t, n) {
4834
+ if (!this.#j) {
4835
+ let e = this.#s.getBoundingClientRect();
4836
+ this.#j = {
4837
+ left: e.left,
4838
+ top: e.top
4839
+ };
4840
+ }
4841
+ return {
4842
+ col: Math.floor((e - this.#j.left) / n.width),
4843
+ row: Math.floor((t - this.#j.top) / n.height)
4844
+ };
4845
+ }
4846
+ #H(e, t) {
4847
+ let n = this.#p, r = this.#f;
4848
+ if (!n || !r || this.#_.length === 0) return null;
4849
+ let { col: i, row: a } = this.#V(e, t, r), o = xe(n, i, a);
4850
+ for (let n = o.length - 1; n >= 0; n--) {
4851
+ let { node: s, x: c, y: l } = o[n], u = s.scrollRange;
4852
+ if (!u) continue;
4853
+ let d = s.style, f = s.scrollGutterCells;
4854
+ if (!f || f.right === 0 && f.bottom === 0) continue;
4855
+ let p = s.source, m = l + d.border.top, h = c + d.border.left, g = l + s.localRect.height - d.border.bottom, _ = c + s.localRect.width - d.border.right;
4856
+ if (f.right > 0 && u.maxY > 0 && i >= _ - f.right && i < _ && a >= m && a < g) {
4857
+ let e = g - m - f.bottom, n = dr(e, u.sizeY, u.maxY, 0).len, i = Math.max(1, (e - n) * r.height);
4858
+ return {
4859
+ el: p,
4860
+ axis: "y",
4861
+ startClient: t,
4862
+ startPx: p.scrollTop,
4863
+ factor: u.maxY * r.height / i
4864
+ };
4865
+ }
4866
+ if (f.bottom > 0 && u.maxX > 0 && a >= g - f.bottom && a < g && i >= h && i < _) {
4867
+ let t = _ - h - f.right, n = dr(t, u.sizeX, u.maxX, 0).len, i = Math.max(1, (t - n) * r.width);
4868
+ return {
4869
+ el: p,
4870
+ axis: "x",
4871
+ startClient: e,
4872
+ startPx: p.scrollLeft,
4873
+ factor: u.maxX * r.width / i
4874
+ };
4875
+ }
4876
+ }
4877
+ return null;
4878
+ }
4879
+ #U = (e) => {
4880
+ let { clientX: t, clientY: n } = e, r = this.#x;
4881
+ if (r) {
4882
+ let e = (r.axis === "y" ? n : t) - r.startClient, i = r.startPx + e * r.factor;
4883
+ r.axis === "y" ? r.el.scrollTop = i : r.el.scrollLeft = i;
4884
+ return;
4885
+ }
4886
+ this.#O = {
4501
4887
  x: t,
4502
4888
  y: n
4503
4889
  };
4504
- let r = this.#T, i = this.#f;
4505
- if (r && i) {
4506
- let e = Math.floor((t - r.left) / i.width), a = Math.floor((n - r.top) / i.height);
4507
- if (e === this.#C && a === this.#w) return;
4890
+ let i = this.#f;
4891
+ if (i) {
4892
+ let { col: e, row: r } = this.#V(t, n, i);
4893
+ if (e === this.#k && r === this.#A) return;
4508
4894
  }
4509
- this.#M();
4895
+ this.#J();
4510
4896
  };
4511
- #O = () => {
4512
- this.#S = null, this.#M();
4897
+ #W = () => {
4898
+ this.#O = null, this.#J();
4513
4899
  };
4514
- #k = (e) => {
4900
+ #G = (e) => {
4515
4901
  let t = e;
4516
- !t.isPrimary || t.button !== 0 || (this.#S = {
4902
+ if (!t.isPrimary || t.button !== 0) return;
4903
+ let n = t.pointerType === "touch" ? null : this.#H(t.clientX, t.clientY);
4904
+ if (n) {
4905
+ this.#x = n, t.preventDefault(), t.isTrusted && this.setPointerCapture(t.pointerId);
4906
+ return;
4907
+ }
4908
+ this.#O = {
4517
4909
  x: t.clientX,
4518
4910
  y: t.clientY
4519
- }, this.#b = !0, this.#M(!0));
4911
+ }, this.#E = !0, this.#J(!0);
4520
4912
  };
4521
- #A = (e) => {
4522
- e.isPrimary && (!this.#b && !this.#y || (this.#b = !1, this.#y = null, this.#M(), this.#x && this.#G()));
4913
+ #K = (e) => {
4914
+ if (e.isPrimary) {
4915
+ if (this.#x) {
4916
+ this.#z(this.#x.el), this.#x = null;
4917
+ return;
4918
+ }
4919
+ !this.#E && !this.#T || (this.#E = !1, this.#T = null, this.#J(), this.#D && this.#se());
4920
+ }
4523
4921
  };
4524
- #j = () => {
4525
- this.#S && (this.#T = null, this.#M());
4922
+ #q = (e) => {
4923
+ if (!this.#O) return;
4924
+ let t = e.target;
4925
+ t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#j = null, this.#J());
4526
4926
  };
4527
- #M(t = !1) {
4927
+ #J(t = !1) {
4528
4928
  let n = this.#p, r = this.#f, i = [];
4529
- if (this.#S && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#b || e.#E?.matches)) {
4530
- if (!this.#T) {
4531
- let e = this.#s.getBoundingClientRect();
4532
- this.#T = {
4533
- left: e.left,
4534
- top: e.top
4535
- };
4536
- }
4537
- this.#C = Math.floor((this.#S.x - this.#T.left) / r.width), this.#w = Math.floor((this.#S.y - this.#T.top) / r.height), i = be(n, this.#C, this.#w);
4538
- } else this.#C = NaN, this.#w = NaN;
4929
+ if (this.#O && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#E || e.#M?.matches)) {
4930
+ let { col: e, row: t } = this.#V(this.#O.x, this.#O.y, r);
4931
+ this.#k = e, this.#A = t, i = Se(n, e, t);
4932
+ } else this.#k = NaN, this.#A = NaN;
4539
4933
  let a = i.at(-1) ?? null;
4540
- t && (this.#y = a);
4541
- let o = e.#E?.matches ? i : [], s = this.#y ? i.indexOf(this.#y) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#N("data-mw-hover", this.#_, o);
4542
- l = this.#N("data-mw-active", this.#v, c) || l;
4934
+ t && (this.#T = a);
4935
+ let o = e.#M?.matches ? i : [], s = this.#T ? i.indexOf(this.#T) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#Y("data-mw-hover", this.#C, o);
4936
+ l = this.#Y("data-mw-active", this.#w, c) || l;
4543
4937
  let u = a ? getComputedStyle(a).cursor : "";
4544
- this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#G();
4938
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#se();
4545
4939
  }
4546
- #N(e, t, n) {
4940
+ #Y(e, t, n) {
4547
4941
  let r = !1, i = new Set(n);
4548
4942
  for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4549
4943
  for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
@@ -4551,51 +4945,51 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4551
4945
  for (let e of i) t.add(e);
4552
4946
  return r;
4553
4947
  }
4554
- #P = 0;
4555
- #F = !1;
4556
- #I = 0;
4557
- #L = (e) => {
4558
- Ri.test(e.propertyName) && (this.#P++, this.#I = performance.now(), this.#z());
4948
+ #X = 0;
4949
+ #Z = !1;
4950
+ #Q = 0;
4951
+ #$ = (e) => {
4952
+ $i.test(e.propertyName) && (this.#X++, this.#Q = performance.now(), this.#te());
4559
4953
  };
4560
- #R = (e) => {
4561
- Ri.test(e.propertyName) && (this.#P = Math.max(0, this.#P - 1));
4954
+ #ee = (e) => {
4955
+ $i.test(e.propertyName) && (this.#X = Math.max(0, this.#X - 1));
4562
4956
  };
4563
- #z() {
4564
- if (this.#F) return;
4565
- this.#F = !0;
4957
+ #te() {
4958
+ if (this.#Z) return;
4959
+ this.#Z = !0;
4566
4960
  let e = () => {
4567
- if (!this.isConnected || this.#P === 0 && !a() || performance.now() - this.#I > zi) {
4568
- this.#F = !1, this.#P = 0, this.#G();
4961
+ if (!this.isConnected || this.#X === 0 && !a() || performance.now() - this.#Q > ea) {
4962
+ this.#Z = !1, this.#X = 0, this.#se();
4569
4963
  return;
4570
4964
  }
4571
- this.#W(), requestAnimationFrame(e);
4965
+ this.#oe(), requestAnimationFrame(e);
4572
4966
  };
4573
4967
  requestAnimationFrame(e);
4574
4968
  }
4575
- #B = (e) => {
4969
+ #ne = (e) => {
4576
4970
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
4577
- this.#W();
4971
+ this.#oe();
4578
4972
  return;
4579
4973
  }
4580
- this.#G();
4974
+ this.#se();
4581
4975
  };
4582
4976
  attributeChangedCallback(e, t, n) {
4583
4977
  if (e === "select" && n !== "text" && n !== "grid") {
4584
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Ii);
4978
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Zi);
4585
4979
  return;
4586
4980
  }
4587
- e === "select" && this.#M(), this.#G();
4981
+ e === "select" && this.#J(), this.#se();
4588
4982
  }
4589
4983
  toPlainText() {
4590
- return this.#d && this.#K(), this.#p ? Xn(this.#p) : "";
4984
+ return this.#d && this.#ce(), this.#p ? nr(this.#p) : "";
4591
4985
  }
4592
- #V = () => {
4593
- this.#G();
4986
+ #re = () => {
4987
+ this.#se();
4594
4988
  };
4595
- #H = () => {
4596
- requestAnimationFrame(() => this.#G());
4989
+ #ie = () => {
4990
+ requestAnimationFrame(() => this.#se());
4597
4991
  };
4598
- #U() {
4992
+ #ae() {
4599
4993
  let e = document.activeElement;
4600
4994
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
4601
4995
  try {
@@ -4604,50 +4998,50 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4604
4998
  return !1;
4605
4999
  }
4606
5000
  }
4607
- #W() {
5001
+ #oe() {
4608
5002
  try {
4609
- this.#K();
5003
+ this.#ce();
4610
5004
  } catch (e) {
4611
5005
  console.error("[monowind] layout failed:", e);
4612
5006
  }
4613
5007
  }
4614
- #G() {
5008
+ #se() {
4615
5009
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
4616
- if (this.#d = !1, this.#U()) {
4617
- this.#G();
5010
+ if (this.#d = !1, this.#ae()) {
5011
+ this.#se();
4618
5012
  return;
4619
5013
  }
4620
- this.#W();
5014
+ this.#oe();
4621
5015
  }));
4622
5016
  }
4623
- #K() {
5017
+ #ce() {
4624
5018
  if (!this.isConnected) return;
4625
- let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
4626
- if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
4627
- let r = getComputedStyle(t), i = t.clientWidth - (parseFloat(r.paddingLeft) || 0) - (parseFloat(r.paddingRight) || 0);
4628
- e.set(t, Math.max(0, Math.round(i / n)));
5019
+ let e = this.#F(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5020
+ if (Number.isFinite(r) && r > 0) for (let e of this.querySelectorAll("textarea")) {
5021
+ let n = getComputedStyle(e), i = e.clientWidth - (parseFloat(n.paddingLeft) || 0) - (parseFloat(n.paddingRight) || 0);
5022
+ t.set(e, Math.max(0, Math.round(i / r)));
4629
5023
  }
4630
5024
  this.setAttribute("measuring", "");
4631
5025
  try {
4632
5026
  this.#c.parentNode !== this && this.appendChild(this.#c);
4633
- let t = Se(this, this.#c), n = this.#f;
4634
- (n === null || n.width !== t.width || n.height !== t.height || n.letterSpacing !== t.letterSpacing || n.inkOverhang !== t.inkOverhang) && (this.style.setProperty("--mw-cw", `${t.width}px`), this.style.setProperty("--mw-ch", `${t.height}px`), this.style.setProperty("--mw-rls", `${t.letterSpacing}px`), this.style.setProperty("--mw-ink", `${t.inkOverhang ?? 0}px`)), this.#f = t;
4635
- let r = getComputedStyle(this), i = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), a = Math.max(0, Math.floor((this.clientWidth - i) / t.width));
4636
- if (a === 0) return;
4637
- let o = Ce(), s = [];
4638
- for (let n of Array.from(this.children)) {
4639
- if (n === this.#c) continue;
4640
- let r = gi(n, o, t, e);
4641
- r && s.push(r);
5027
+ let n = we(this, this.#c), r = this.#f;
5028
+ (r === null || r.width !== n.width || r.height !== n.height || r.letterSpacing !== n.letterSpacing || r.inkOverhang !== n.inkOverhang) && (this.style.setProperty("--mw-cw", `${n.width}px`), this.style.setProperty("--mw-ch", `${n.height}px`), this.style.setProperty("--mw-rls", `${n.letterSpacing}px`), this.style.setProperty("--mw-ink", `${n.inkOverhang ?? 0}px`)), this.#f = n;
5029
+ let i = getComputedStyle(this), a = (parseFloat(i.paddingLeft) || 0) + (parseFloat(i.paddingRight) || 0), o = Math.max(0, Math.floor((this.clientWidth - a) / n.width));
5030
+ if (o === 0) return;
5031
+ let s = Te(), c = [];
5032
+ for (let e of Array.from(this.children)) {
5033
+ if (e === this.#c) continue;
5034
+ let r = ji(e, s, n, t);
5035
+ r && c.push(r);
4642
5036
  }
4643
- if (ji(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Mi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
5037
+ if (Ki(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${qi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
4644
5038
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
4645
5039
  return;
4646
5040
  }
4647
- let c = {
5041
+ let l = {
4648
5042
  source: this,
4649
- style: $e(),
4650
- children: s,
5043
+ style: nt(),
5044
+ children: c,
4651
5045
  text: "",
4652
5046
  intrinsicWidth: 0,
4653
5047
  intrinsicHeight: 0,
@@ -4658,20 +5052,33 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4658
5052
  height: 0
4659
5053
  },
4660
5054
  unclampedHeight: 0,
4661
- resolvedPadding: z()
4662
- }, { height: l } = An(c, a);
4663
- _r(c), this.#x = !lr(c, this.#s, this.#b), this.#p = c;
4664
- 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`;
4665
- this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
5055
+ resolvedPadding: rt()
5056
+ }, { height: u } = Pn(l, o);
5057
+ wr(l), this.#_ = ua(l), this.#P(n, e), this.#D = !gr(l, this.#s, this.#E), this.#p = l;
5058
+ let d = `${l.localRect.width * n.width}px`, f = `${l.localRect.height * n.height}px`;
5059
+ this.#s.style.width !== d && (this.#s.style.width = d), this.#s.style.height !== f && (this.#s.style.height = f);
5060
+ let p = i.boxSizing === "border-box" ? (parseFloat(i.paddingTop) || 0) + (parseFloat(i.paddingBottom) || 0) + (parseFloat(i.borderTopWidth) || 0) + (parseFloat(i.borderBottomWidth) || 0) : 0, m = `${u * n.height + p}px`;
5061
+ this.style.height !== m && (this.style.height = m), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
4666
5062
  } finally {
4667
- this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#u?.takeRecords(), i(this) && (a() ? (this.#I = performance.now(), this.#z()) : this.#G()), this.#T = null, this.#S && this.#M();
5063
+ this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#I(e), this.#u?.takeRecords(), i(this) && (a() ? (this.#Q = performance.now(), this.#te()) : this.#se()), this.#j = null, this.#O && this.#J();
4668
5064
  }
4669
5065
  }
4670
5066
  };
4671
- function Hi() {
4672
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", Vi);
5067
+ function ca() {
5068
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", sa);
5069
+ }
5070
+ function la(e, t, n, r) {
5071
+ let i = t === "y" ? e.scrollTop : e.scrollLeft, a = t === "y" ? e.scrollHeight - e.clientHeight : e.scrollWidth - e.clientWidth;
5072
+ return r > 0 && i > 0 && i >= a - 1 ? r : Math.min(Math.max(0, Math.floor((i + 1) / n)), r);
5073
+ }
5074
+ function ua(e) {
5075
+ let t = [], n = (e) => {
5076
+ e.scrollRange && t.push(e);
5077
+ for (let t of e.children) n(t);
5078
+ };
5079
+ return n(e), t;
4673
5080
  }
4674
5081
  //#endregion
4675
- export { Vi as MonoWindElement, Hi as defineMonoWind, ne as invalidateLeaves, Wt as multicolLines, x as registerBorderGlyphs, te as registerLeafRenderer, Xn as renderPlainText, we as wrapLines };
5082
+ export { sa as MonoWindElement, ca as defineMonoWind, re as invalidateLeaves, Jt as multicolLines, x as registerBorderGlyphs, ne as registerLeafRenderer, nr as renderPlainText, Ee as wrapLines };
4676
5083
 
4677
5084
  //# sourceMappingURL=index.js.map