@vscode/markdown-editor 0.0.2-19 → 0.0.2-20

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
@@ -2,8 +2,8 @@ import { parse as Gn, preprocess as jn, postprocess as Un } from "micromark";
2
2
  import { math as Xn } from "micromark-extension-math";
3
3
  import { gfmTable as Qn } from "micromark-extension-gfm-table";
4
4
  import { gfmTaskListItem as Yn } from "micromark-extension-gfm-task-list-item";
5
- import { gfmStrikethrough as Jn } from "micromark-extension-gfm-strikethrough";
6
- import { o as N, d as $, D as W, t as Zn, r as es, a as P, c as ts } from "./runOnChange-CkxK2gSn.js";
5
+ import { gfmStrikethrough as Zn } from "micromark-extension-gfm-strikethrough";
6
+ import { o as N, d as $, D as W, t as Jn, r as es, a as P, c as ts } from "./runOnChange-CkxK2gSn.js";
7
7
  import { createDiffComputer as ns } from "@vscode/diff";
8
8
  import an from "katex";
9
9
  class _ {
@@ -438,7 +438,7 @@ function Y(s, e) {
438
438
  const t = s.get(e);
439
439
  return t && t !== e ? t : e;
440
440
  }
441
- function ne(s, e) {
441
+ function se(s, e) {
442
442
  return e ? Y(s, e) : void 0;
443
443
  }
444
444
  class Ke extends F {
@@ -485,7 +485,7 @@ class te extends F {
485
485
  return this.leadingTrivia ? [this.leadingTrivia, ...e] : e;
486
486
  }
487
487
  }
488
- class ae extends te {
488
+ class le extends te {
489
489
  constructor(e, t) {
490
490
  super(), this.content = e, this.leadingTrivia = t;
491
491
  }
@@ -497,10 +497,10 @@ class ae extends te {
497
497
  return pe(this.content, "content");
498
498
  }
499
499
  mapChildren(e) {
500
- return new ae(R(e, this.content), ne(e, this.leadingTrivia));
500
+ return new le(R(e, this.content), se(e, this.leadingTrivia));
501
501
  }
502
502
  withLeadingTrivia(e) {
503
- return new ae(this.content, e);
503
+ return new le(this.content, e);
504
504
  }
505
505
  }
506
506
  function pe(s, e) {
@@ -596,7 +596,7 @@ class Te extends F {
596
596
  return this.alt === e.alt && this.url === e.url;
597
597
  }
598
598
  }
599
- class le extends te {
599
+ class de extends te {
600
600
  constructor(e, t, n) {
601
601
  super(), this.tokenType = e, this.content = t, this.leadingTrivia = n;
602
602
  }
@@ -608,16 +608,16 @@ class le extends te {
608
608
  return pe(this.content, "content");
609
609
  }
610
610
  mapChildren(e) {
611
- return new le(this.tokenType, R(e, this.content), ne(e, this.leadingTrivia));
611
+ return new de(this.tokenType, R(e, this.content), se(e, this.leadingTrivia));
612
612
  }
613
613
  withLeadingTrivia(e) {
614
- return new le(this.tokenType, this.content, e);
614
+ return new de(this.tokenType, this.content, e);
615
615
  }
616
616
  _localEquals(e) {
617
617
  return this.tokenType === e.tokenType;
618
618
  }
619
619
  }
620
- class ie extends te {
620
+ class oe extends te {
621
621
  constructor(e, t, n, i) {
622
622
  super(), this.level = e, this.marker = t, this.content = n, this.leadingTrivia = i;
623
623
  }
@@ -626,16 +626,16 @@ class ie extends te {
626
626
  return this._withLeading([this.marker, ...this.content]);
627
627
  }
628
628
  mapChildren(e) {
629
- return new ie(this.level, Y(e, this.marker), R(e, this.content), ne(e, this.leadingTrivia));
629
+ return new oe(this.level, Y(e, this.marker), R(e, this.content), se(e, this.leadingTrivia));
630
630
  }
631
631
  withLeadingTrivia(e) {
632
- return new ie(this.level, this.marker, this.content, e);
632
+ return new oe(this.level, this.marker, this.content, e);
633
633
  }
634
634
  _localEquals(e) {
635
635
  return this.level === e.level;
636
636
  }
637
637
  }
638
- class J extends te {
638
+ class Z extends te {
639
639
  constructor(e, t) {
640
640
  super(), this.content = e, this.leadingTrivia = t;
641
641
  }
@@ -644,10 +644,10 @@ class J extends te {
644
644
  return this._withLeading(this.content);
645
645
  }
646
646
  mapChildren(e) {
647
- return new J(R(e, this.content), ne(e, this.leadingTrivia));
647
+ return new Z(R(e, this.content), se(e, this.leadingTrivia));
648
648
  }
649
649
  withLeadingTrivia(e) {
650
- return new J(this.content, e);
650
+ return new Z(this.content, e);
651
651
  }
652
652
  }
653
653
  class G extends te {
@@ -680,7 +680,7 @@ class G extends te {
680
680
  return e;
681
681
  }
682
682
  mapChildren(e) {
683
- return new G(this.language, R(e, this.content), ne(e, this.leadingTrivia));
683
+ return new G(this.language, R(e, this.content), se(e, this.leadingTrivia));
684
684
  }
685
685
  withLeadingTrivia(e) {
686
686
  return new G(this.language, this.content, e);
@@ -708,7 +708,7 @@ class G extends te {
708
708
  return { stringEdit: this._contentEdit };
709
709
  }
710
710
  }
711
- class de extends te {
711
+ class he extends te {
712
712
  constructor(e, t) {
713
713
  super(), this.content = e, this.leadingTrivia = t;
714
714
  }
@@ -720,10 +720,10 @@ class de extends te {
720
720
  return pe(this.content, "content");
721
721
  }
722
722
  mapChildren(e) {
723
- return new de(R(e, this.content), ne(e, this.leadingTrivia));
723
+ return new he(R(e, this.content), se(e, this.leadingTrivia));
724
724
  }
725
725
  withLeadingTrivia(e) {
726
- return new de(this.content, e);
726
+ return new he(this.content, e);
727
727
  }
728
728
  }
729
729
  class we extends te {
@@ -738,13 +738,13 @@ class we extends te {
738
738
  return this.content.filter(ut);
739
739
  }
740
740
  mapChildren(e) {
741
- return new we(R(e, this.content), ne(e, this.leadingTrivia));
741
+ return new we(R(e, this.content), se(e, this.leadingTrivia));
742
742
  }
743
743
  withLeadingTrivia(e) {
744
744
  return new we(this.content, e);
745
745
  }
746
746
  }
747
- class Z extends te {
747
+ class J extends te {
748
748
  constructor(e, t, n) {
749
749
  super(), this.ordered = e, this.content = t, this.leadingTrivia = n;
750
750
  }
@@ -756,10 +756,10 @@ class Z extends te {
756
756
  return this.content.filter((e) => e instanceof ee);
757
757
  }
758
758
  mapChildren(e) {
759
- return new Z(this.ordered, R(e, this.content), ne(e, this.leadingTrivia));
759
+ return new J(this.ordered, R(e, this.content), se(e, this.leadingTrivia));
760
760
  }
761
761
  withLeadingTrivia(e) {
762
- return new Z(this.ordered, this.content, e);
762
+ return new J(this.ordered, this.content, e);
763
763
  }
764
764
  _localEquals(e) {
765
765
  return this.ordered === e.ordered;
@@ -812,7 +812,7 @@ class ke extends te {
812
812
  return this._rows.slice(2);
813
813
  }
814
814
  mapChildren(e) {
815
- return new ke(R(e, this.content), ne(e, this.leadingTrivia));
815
+ return new ke(R(e, this.content), se(e, this.leadingTrivia));
816
816
  }
817
817
  withLeadingTrivia(e) {
818
818
  return new ke(this.content, e);
@@ -861,7 +861,7 @@ class ht extends F {
861
861
  }
862
862
  }
863
863
  function ut(s) {
864
- return s instanceof ie || s instanceof J || s instanceof G || s instanceof de || s instanceof ae || s instanceof we || s instanceof Z || s instanceof ke || s instanceof le;
864
+ return s instanceof oe || s instanceof Z || s instanceof G || s instanceof he || s instanceof le || s instanceof we || s instanceof J || s instanceof ke || s instanceof de;
865
865
  }
866
866
  function hn(s, e) {
867
867
  if (s.id === e.id)
@@ -891,7 +891,7 @@ function un(s) {
891
891
  return e;
892
892
  }
893
893
  function cs(s) {
894
- const e = Gn({ extensions: [Xn(), Qn(), Yn(), Jn()] }), t = jn()(s, void 0, !0);
894
+ const e = Gn({ extensions: [Xn(), Qn(), Yn(), Zn()] }), t = jn()(s, void 0, !0);
895
895
  return Un(e.document().write(t)).map(([i, o]) => ({
896
896
  type: i,
897
897
  tokenType: o.type,
@@ -930,12 +930,12 @@ function Ne(s) {
930
930
  return e;
931
931
  }
932
932
  function ds(s, e) {
933
- if (s instanceof Z) {
933
+ if (s instanceof J) {
934
934
  const t = s.content.findIndex((i) => i instanceof ee);
935
935
  if (t < 0)
936
936
  return;
937
937
  const n = s.content.map((i, o) => o === t ? i.withLeadingTrivia(e) : i);
938
- return new Z(s.ordered, n, s.leadingTrivia);
938
+ return new J(s.ordered, n, s.leadingTrivia);
939
939
  }
940
940
  if (s instanceof ee || s instanceof te)
941
941
  return s.withLeadingTrivia(e);
@@ -945,7 +945,7 @@ function Re(s) {
945
945
  for (let t = 0; t < s.length; t++) {
946
946
  const n = s[t];
947
947
  if (n instanceof H && n.glueKind === void 0) {
948
- const i = e[e.length - 1], o = s[t + 1], r = i instanceof J && o instanceof J, c = new H(n.content, r ? "blockBreak" : "blockGap"), a = i !== void 0 ? fn(i, c) : void 0;
948
+ const i = e[e.length - 1], o = s[t + 1], r = i instanceof Z && o instanceof Z, c = new H(n.content, r ? "blockBreak" : "blockGap"), a = i !== void 0 ? fn(i, c) : void 0;
949
949
  a ? e[e.length - 1] = a : e.push(c);
950
950
  continue;
951
951
  }
@@ -957,11 +957,11 @@ function fn(s, e) {
957
957
  switch (s.kind) {
958
958
  case "paragraph": {
959
959
  const t = s;
960
- return new J([...t.content, e], t.leadingTrivia);
960
+ return new Z([...t.content, e], t.leadingTrivia);
961
961
  }
962
962
  case "heading": {
963
963
  const t = s;
964
- return new ie(t.level, t.marker, [...t.content, e], t.leadingTrivia);
964
+ return new oe(t.level, t.marker, [...t.content, e], t.leadingTrivia);
965
965
  }
966
966
  case "codeBlock": {
967
967
  const t = s;
@@ -969,15 +969,15 @@ function fn(s, e) {
969
969
  }
970
970
  case "mathBlock": {
971
971
  const t = s;
972
- return new de([...t.content, e], t.leadingTrivia);
972
+ return new he([...t.content, e], t.leadingTrivia);
973
973
  }
974
974
  case "thematicBreak": {
975
975
  const t = s;
976
- return new ae([...t.content, e], t.leadingTrivia);
976
+ return new le([...t.content, e], t.leadingTrivia);
977
977
  }
978
978
  case "unhandledBlock": {
979
979
  const t = s;
980
- return new le(t.tokenType, [...t.content, e], t.leadingTrivia);
980
+ return new de(t.tokenType, [...t.content, e], t.leadingTrivia);
981
981
  }
982
982
  case "table": {
983
983
  const t = s;
@@ -989,7 +989,7 @@ function fn(s, e) {
989
989
  }
990
990
  case "list": {
991
991
  const t = s;
992
- return new Z(t.ordered, qe(t.content, e), t.leadingTrivia);
992
+ return new J(t.ordered, qe(t.content, e), t.leadingTrivia);
993
993
  }
994
994
  case "listItem": {
995
995
  const t = s;
@@ -1008,7 +1008,7 @@ function qe(s, e) {
1008
1008
  return [...s, e];
1009
1009
  }
1010
1010
  function hs(s) {
1011
- return s.some((e) => !(e instanceof H)) ? s : [new J(s)];
1011
+ return s.some((e) => !(e instanceof H)) ? s : [new Z(s)];
1012
1012
  }
1013
1013
  class M {
1014
1014
  constructor(e, t) {
@@ -1102,7 +1102,7 @@ class us {
1102
1102
  r.tokenType === t && (n += r.type === "enter" ? 1 : -1), n === 0 && (i = r), this._idx++;
1103
1103
  }
1104
1104
  const o = this._source.substring(e.startOffset, i.endOffset);
1105
- return new le(t, [new b("content", o)]);
1105
+ return new de(t, [new b("content", o)]);
1106
1106
  }
1107
1107
  /**
1108
1108
  * Decides what to do with an unrecognized `enter` token at the top of a
@@ -1139,7 +1139,7 @@ class us {
1139
1139
  for (const d of o)
1140
1140
  a.add(d.node, d.start);
1141
1141
  const l = a.build(r.endOffset - i);
1142
- return new ie(t, c, l);
1142
+ return new oe(t, c, l);
1143
1143
  }
1144
1144
  _parseParagraph() {
1145
1145
  const e = this._consume("enter", "paragraph"), t = [];
@@ -1148,7 +1148,7 @@ class us {
1148
1148
  const n = this._consume("exit", "paragraph"), i = new M(e.startOffset, this._source);
1149
1149
  for (const o of t)
1150
1150
  i.add(o.node, o.start);
1151
- return new J(i.build(n.endOffset - e.startOffset));
1151
+ return new Z(i.build(n.endOffset - e.startOffset));
1152
1152
  }
1153
1153
  _parseCodeFenced() {
1154
1154
  const e = this._consume("enter", "codeFenced");
@@ -1223,14 +1223,14 @@ class us {
1223
1223
  } else c.tokenType === "mathFlowValue" || c.tokenType === "lineEnding" ? (i === void 0 && (i = c.startOffset), o = c.endOffset, this._idx++) : this._idx++;
1224
1224
  }
1225
1225
  const r = this._consume("exit", "mathFlow");
1226
- return i !== void 0 && t.add(new b("content", this._source.substring(i, o)), i), new de(t.build(r.endOffset - e.startOffset));
1226
+ return i !== void 0 && t.add(new b("content", this._source.substring(i, o)), i), new he(t.build(r.endOffset - e.startOffset));
1227
1227
  }
1228
1228
  _parseThematicBreak() {
1229
1229
  const e = this._consume("enter", "thematicBreak");
1230
1230
  for (; this._notExit("thematicBreak"); )
1231
1231
  this._idx++;
1232
1232
  const t = this._consume("exit", "thematicBreak"), n = new b("content", this._source.substring(e.startOffset, t.endOffset));
1233
- return new ae([n]);
1233
+ return new le([n]);
1234
1234
  }
1235
1235
  _parseBlockQuote() {
1236
1236
  const e = this._consume("enter", "blockQuote"), t = new M(e.startOffset, this._source);
@@ -1285,7 +1285,7 @@ class us {
1285
1285
  }
1286
1286
  u();
1287
1287
  const f = this._consume("exit", e);
1288
- return new Z(t, Re(Ne(i.build(f.endOffset - n.startOffset))));
1288
+ return new J(t, Re(Ne(i.build(f.endOffset - n.startOffset))));
1289
1289
  }
1290
1290
  _parseTable() {
1291
1291
  const e = this._consume("enter", "table"), t = new M(e.startOffset, this._source);
@@ -1670,13 +1670,13 @@ function ks(s, e, t = 0) {
1670
1670
  }
1671
1671
  function xt(s) {
1672
1672
  const e = {};
1673
- return s instanceof ie ? e.level = String(s.level) : s instanceof Z ? e.ordered = String(s.ordered) : s instanceof G ? s.language && (e.language = s.language) : s instanceof Le ? e.url = s.url : s instanceof Te ? (e.alt = s.alt, e.url = s.url) : s instanceof ee ? s.checked !== void 0 && (e.checked = String(s.checked)) : s instanceof le ? e.token = s.tokenType : s instanceof H && s.glueKind && (e.kind = s.glueKind), Object.entries(e).map(([t, n]) => ` ${t}="${pn(n)}"`).join("");
1673
+ return s instanceof oe ? e.level = String(s.level) : s instanceof J ? e.ordered = String(s.ordered) : s instanceof G ? s.language && (e.language = s.language) : s instanceof Le ? e.url = s.url : s instanceof Te ? (e.alt = s.alt, e.url = s.url) : s instanceof ee ? s.checked !== void 0 && (e.checked = String(s.checked)) : s instanceof de ? e.token = s.tokenType : s instanceof H && s.glueKind && (e.kind = s.glueKind), Object.entries(e).map(([t, n]) => ` ${t}="${pn(n)}"`).join("");
1674
1674
  }
1675
1675
  function pn(s) {
1676
1676
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1677
1677
  }
1678
1678
  function xs(s) {
1679
- return s instanceof be ? `text ${JSON.stringify(s.content)}` : s instanceof H ? `glue${s.glueKind ? `(${s.glueKind})` : ""} ${JSON.stringify(s.content)}` : s instanceof b ? `marker(${s.markerKind}) ${JSON.stringify(s.content)}` : s instanceof ae ? `thematicBreak ${JSON.stringify(s.content)}` : s instanceof ie ? `heading(level=${s.level})` : s instanceof Z ? `list(ordered=${s.ordered})` : s instanceof ee ? s.checked === void 0 ? "listItem" : `listItem(checked=${s.checked})` : s instanceof G ? `codeBlock(language=${JSON.stringify(s.language)})` : s instanceof de ? "mathBlock" : s instanceof Le ? `link(url=${JSON.stringify(s.url)})` : s instanceof Te ? `image(alt=${JSON.stringify(s.alt)}, url=${JSON.stringify(s.url)})` : s.kind;
1679
+ return s instanceof be ? `text ${JSON.stringify(s.content)}` : s instanceof H ? `glue${s.glueKind ? `(${s.glueKind})` : ""} ${JSON.stringify(s.content)}` : s instanceof b ? `marker(${s.markerKind}) ${JSON.stringify(s.content)}` : s instanceof le ? `thematicBreak ${JSON.stringify(s.content)}` : s instanceof oe ? `heading(level=${s.level})` : s instanceof J ? `list(ordered=${s.ordered})` : s instanceof ee ? s.checked === void 0 ? "listItem" : `listItem(checked=${s.checked})` : s instanceof G ? `codeBlock(language=${JSON.stringify(s.language)})` : s instanceof he ? "mathBlock" : s instanceof Le ? `link(url=${JSON.stringify(s.url)})` : s instanceof Te ? `image(alt=${JSON.stringify(s.alt)}, url=${JSON.stringify(s.url)})` : s.kind;
1680
1680
  }
1681
1681
  const bt = /* @__PURE__ */ new WeakMap();
1682
1682
  let bs = 0;
@@ -1706,21 +1706,21 @@ function Es(s) {
1706
1706
  return t;
1707
1707
  }
1708
1708
  const Cs = {}, _n = N(Cs, !1), Ls = _n;
1709
- let Ze, Ge;
1709
+ let Je, Ge;
1710
1710
  function Ts() {
1711
1711
  return Ge || (Ge = ns({ useWasm: !1 }).then((s) => {
1712
- Ze = s, _n.set(!0, void 0);
1712
+ Je = s, _n.set(!0, void 0);
1713
1713
  }).catch(() => {
1714
1714
  })), Ge;
1715
1715
  }
1716
1716
  Ts();
1717
- function Os(s, e) {
1718
- if (!Ze)
1717
+ function Ss(s, e) {
1718
+ if (!Je)
1719
1719
  throw new Error("Diff computer not loaded yet — await ensureDiffComputer() / observe diffComputerReady first.");
1720
- const t = Ze.computeDiff(s, e, { extendToSubwords: !0 });
1721
- return Ss(t.edits.stripData());
1720
+ const t = Je.computeDiff(s, e, { extendToSubwords: !0 });
1721
+ return Os(t.edits.stripData());
1722
1722
  }
1723
- function Ss(s) {
1723
+ function Os(s) {
1724
1724
  return new T(s.replacements.map((e) => z.replace(new _(e.range.start, e.range.endExclusive), e.newText)));
1725
1725
  }
1726
1726
  const Ms = /* @__PURE__ */ new Set([
@@ -1920,7 +1920,7 @@ class Ir {
1920
1920
  const t = e.readObservable(this._baselineDocument), n = e.readObservable(this.baseline);
1921
1921
  if (!t || !n || !e.readObservable(Ls))
1922
1922
  return;
1923
- const i = e.readObservable(this.document), o = e.readObservable(this.sourceText), r = Os(n.value, o.value), c = Rs(t, i, r), a = [], l = (u, f) => {
1923
+ const i = e.readObservable(this.document), o = e.readObservable(this.sourceText), r = Ss(n.value, o.value), c = Rs(t, i, r), a = [], l = (u, f) => {
1924
1924
  for (const h of u)
1925
1925
  if (h.kind === "replaced")
1926
1926
  for (const g of h.insertedLocal)
@@ -1942,7 +1942,7 @@ class Ir {
1942
1942
  * applied — the blank line exists only in the view until it is materialized.
1943
1943
  */
1944
1944
  armPendingParagraph(e) {
1945
- this.pendingParagraph.set({ ...e, syntheticAst: new J([]) }, void 0), this.selection.set(x.collapsed(e.replaceRange.start), void 0);
1945
+ this.pendingParagraph.set({ ...e, syntheticAst: new Z([]) }, void 0), this.selection.set(x.collapsed(e.replaceRange.start), void 0);
1946
1946
  }
1947
1947
  /** Discard the pending paragraph (if any) without touching the source. */
1948
1948
  cancelPendingParagraph() {
@@ -2008,11 +2008,11 @@ function Ds(s, e, t) {
2008
2008
  }
2009
2009
  return n;
2010
2010
  }
2011
- class Oe {
2011
+ class Se {
2012
2012
  constructor(e) {
2013
2013
  this.lines = e;
2014
2014
  }
2015
- static EMPTY = new Oe([]);
2015
+ static EMPTY = new Se([]);
2016
2016
  static measure(e) {
2017
2017
  return Vs(e);
2018
2018
  }
@@ -2277,7 +2277,7 @@ function Vs(s) {
2277
2277
  const d = l.rect, u = Math.min(i + o, d.y + d.height) - Math.max(i, d.y);
2278
2278
  n.length > 0 && u > Math.min(o, d.height) / 2 ? (n.push(l), o = Math.max(o, d.y + d.height - i), r = Math.min(r, d.left), c = Math.max(c, d.right)) : (a(), n = [l], i = d.y, o = d.height, r = d.left, c = d.right);
2279
2279
  }
2280
- return a(), new Oe(t);
2280
+ return a(), new Se(t);
2281
2281
  }
2282
2282
  function Hs(s, e) {
2283
2283
  const t = [], n = document.createRange();
@@ -2326,7 +2326,7 @@ class Ws {
2326
2326
  */
2327
2327
  visualLineMap = $(this, (e) => {
2328
2328
  const n = e.readObservable(this.measurements).flatMap((i) => i.visualLineMap?.lines ?? []);
2329
- return new Oe(n);
2329
+ return new Se(n);
2330
2330
  });
2331
2331
  }
2332
2332
  function kn(s, e, t, n) {
@@ -2425,7 +2425,7 @@ function gt(s, e, t) {
2425
2425
  for (const i of s.children)
2426
2426
  gt(i, n, t), n += i.length;
2427
2427
  }
2428
- const Us = (s) => s.selection.isCollapsed ? Math.min(s.selection.active + 1, s.text.length) : s.selection.range.endExclusive, Xs = (s) => s.selection.isCollapsed ? Math.max(s.selection.active - 1, 0) : s.selection.range.start, Qs = (s) => Math.min(s.selection.active + 1, s.text.length), Ys = (s) => Math.max(s.selection.active - 1, 0), Js = (s) => dn(s.text, s.selection.active), Lt = (s) => ln(s.text, s.selection.active), Zs = (s) => s.text.lastIndexOf(`
2428
+ const Us = (s) => s.selection.isCollapsed ? Math.min(s.selection.active + 1, s.text.length) : s.selection.range.endExclusive, Xs = (s) => s.selection.isCollapsed ? Math.max(s.selection.active - 1, 0) : s.selection.range.start, Qs = (s) => Math.min(s.selection.active + 1, s.text.length), Ys = (s) => Math.max(s.selection.active - 1, 0), Zs = (s) => dn(s.text, s.selection.active), Lt = (s) => ln(s.text, s.selection.active), Js = (s) => s.text.lastIndexOf(`
2429
2429
  `, s.selection.active - 1) + 1, ei = (s) => {
2430
2430
  const e = s.text.indexOf(`
2431
2431
  `, s.selection.active);
@@ -2433,10 +2433,10 @@ const Us = (s) => s.selection.isCollapsed ? Math.min(s.selection.active + 1, s.t
2433
2433
  }, ti = () => 0, ni = (s) => s.text.length, Tt = (s) => {
2434
2434
  const e = s.lineMap.lineIndexOfOffset(s.selection.active), t = s.desiredColumn ?? s.lineMap.xAtOffset(s.selection.active);
2435
2435
  return e >= s.lineMap.lineCount - 1 ? { offset: s.selection.active, desiredColumn: t } : { offset: s.lineMap.offsetInLineAtX(e + 1, t), desiredColumn: t };
2436
- }, Ot = (s) => {
2436
+ }, St = (s) => {
2437
2437
  const e = s.lineMap.lineIndexOfOffset(s.selection.active), t = s.desiredColumn ?? s.lineMap.xAtOffset(s.selection.active);
2438
2438
  return e <= 0 ? { offset: s.selection.active, desiredColumn: t } : { offset: s.lineMap.offsetInLineAtX(e - 1, t), desiredColumn: t };
2439
- }, St = (s) => {
2439
+ }, Ot = (s) => {
2440
2440
  const e = s.selection;
2441
2441
  if (!e.isCollapsed)
2442
2442
  return {
@@ -2671,7 +2671,7 @@ function ki(s, e) {
2671
2671
  return new x(e.start, e.endExclusive);
2672
2672
  }
2673
2673
  const Mt = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap();
2674
- class he extends W {
2674
+ class ne extends W {
2675
2675
  constructor(e, t, n = xi) {
2676
2676
  super(), this.ast = e, this.dom = t, this._children = n, Mt.set(t, this);
2677
2677
  for (const i of n)
@@ -2780,7 +2780,7 @@ class he extends W {
2780
2780
  * until it reaches this node.
2781
2781
  */
2782
2782
  resolveSource(e) {
2783
- let t = he.forDom(e.node);
2783
+ let t = ne.forDom(e.node);
2784
2784
  if (!t)
2785
2785
  return;
2786
2786
  let n = t.getLocalSourceRange(e);
@@ -2825,7 +2825,7 @@ class he extends W {
2825
2825
  }
2826
2826
  }
2827
2827
  const xi = [];
2828
- class S extends he {
2828
+ class O extends ne {
2829
2829
  constructor(e, t, n) {
2830
2830
  super(e.ast, t, n), this.data = e;
2831
2831
  }
@@ -2835,6 +2835,19 @@ class S extends he {
2835
2835
  get element() {
2836
2836
  return this.dom;
2837
2837
  }
2838
+ /**
2839
+ * The horizontal scroll viewport for selection/caret clipping
2840
+ * ({@link blockViewportClip}). For most blocks the scroller *is*
2841
+ * {@link element} — a code / math / unhandled block's `element` is the very
2842
+ * `overflow-x: auto` box that scrolls. A table is the exception: its
2843
+ * `element` stays the inner `<table>` (so the active/markers classes and
2844
+ * `.md-table` theme styling are unaffected), but the box that actually
2845
+ * scrolls is the wrapping `.md-table-wrapper`, so {@link TableViewNode}
2846
+ * overrides this to return that wrapper.
2847
+ */
2848
+ get scrollElement() {
2849
+ return this.element;
2850
+ }
2838
2851
  /**
2839
2852
  * Whether this already-built node can stand in for `data` unchanged. The
2840
2853
  * builder preserves view-data identity for any subtree whose ast and
@@ -2855,7 +2868,7 @@ class S extends he {
2855
2868
  }
2856
2869
  }
2857
2870
  function q(s, e, t) {
2858
- if (t instanceof S) {
2871
+ if (t instanceof O) {
2859
2872
  if (t.canReuse(s))
2860
2873
  return t;
2861
2874
  } else if (t?.ast === s.ast)
@@ -2870,7 +2883,7 @@ function q(s, e, t) {
2870
2883
  case "heading":
2871
2884
  return new Dt(s, e, I(t, Dt));
2872
2885
  case "paragraph":
2873
- return new se(s, "p", "md-block md-paragraph", e, re(t));
2886
+ return new ie(s, "p", "md-block md-paragraph", e, ce(t));
2874
2887
  case "codeBlock":
2875
2888
  return new _t(s, e, t);
2876
2889
  case "mathBlock":
@@ -2880,7 +2893,7 @@ function q(s, e, t) {
2880
2893
  case "unhandledBlock":
2881
2894
  return new $t(s, e, I(t, $t));
2882
2895
  case "blockQuote":
2883
- return new se(s, "blockquote", "md-block md-blockquote", e, re(t));
2896
+ return new ie(s, "blockquote", "md-block md-blockquote", e, ce(t));
2884
2897
  case "list":
2885
2898
  return new Ht(s, e, I(t, Ht));
2886
2899
  case "listItem":
@@ -2890,13 +2903,13 @@ function q(s, e, t) {
2890
2903
  case "tableRow":
2891
2904
  return new Wt(s, e, I(t, Wt));
2892
2905
  case "tableCell":
2893
- return new se(s, "td", "", e, re(t));
2906
+ return new ie(s, "td", "", e, ce(t));
2894
2907
  case "strong":
2895
- return new se(s, "strong", "", e, re(t));
2908
+ return new ie(s, "strong", "", e, ce(t));
2896
2909
  case "emphasis":
2897
- return new se(s, "em", "", e, re(t));
2910
+ return new ie(s, "em", "", e, ce(t));
2898
2911
  case "strikethrough":
2899
- return new se(s, "del", "", e, re(t));
2912
+ return new ie(s, "del", "", e, ce(t));
2900
2913
  case "inlineCode":
2901
2914
  return new zt(s, e, I(t, zt));
2902
2915
  case "inlineMath":
@@ -2906,7 +2919,7 @@ function q(s, e, t) {
2906
2919
  case "image":
2907
2920
  return new jt(s, e, I(t, jt));
2908
2921
  case "document":
2909
- return new se(s, "div", "", e, re(t));
2922
+ return new ie(s, "div", "", e, ce(t));
2910
2923
  case "diffHunk":
2911
2924
  return new tt(s, e, I(t, tt));
2912
2925
  case "diffDecoration":
@@ -2916,8 +2929,8 @@ function q(s, e, t) {
2916
2929
  function I(s, e) {
2917
2930
  return s instanceof e ? s : void 0;
2918
2931
  }
2919
- function re(s) {
2920
- return s instanceof se ? s : void 0;
2932
+ function ce(s) {
2933
+ return s instanceof ie ? s : void 0;
2921
2934
  }
2922
2935
  function U(s, e, t, n) {
2923
2936
  const { paired: i, unused: o } = vt(e, t ?? D), r = e.map((c) => n(c, i.get(c)));
@@ -2926,9 +2939,9 @@ function U(s, e, t, n) {
2926
2939
  return bi(s, r), r;
2927
2940
  }
2928
2941
  function bi(s, e) {
2929
- ce(s, e.map((t) => t.mountNode));
2942
+ ae(s, e.map((t) => t.mountNode));
2930
2943
  }
2931
- function ce(s, e) {
2944
+ function ae(s, e) {
2932
2945
  let t = s.firstChild, n = 0;
2933
2946
  for (; n < e.length && t === e[n]; n++)
2934
2947
  t = t.nextSibling;
@@ -2943,21 +2956,21 @@ function ce(s, e) {
2943
2956
  }
2944
2957
  }
2945
2958
  }
2946
- function oe(s) {
2959
+ function re(s) {
2947
2960
  return (e, t) => q(e, s, t);
2948
2961
  }
2949
2962
  function En(s) {
2950
2963
  return (e, t) => e.kind === "marker" && e.ast.markerKind === "content" ? new pt(e, document.createTextNode(e.ast.content)) : q(e, s, t);
2951
2964
  }
2952
2965
  const D = [];
2953
- class tt extends S {
2966
+ class tt extends O {
2954
2967
  _originalNode;
2955
2968
  _modifiedNode;
2956
2969
  constructor(e, t, n) {
2957
2970
  const i = n?.dom ?? document.createElement("div");
2958
2971
  i.className = "md-block md-diff-hunk";
2959
2972
  const o = [], r = [], c = e.original ? Nt(e.original, "md-diff-original", t, n?._originalNode) : void 0, a = e.modified ? Nt(e.modified, "md-diff-modified", t, n?._modifiedNode) : void 0;
2960
- c && (o.push(c), r.push(c.mountNode)), a && (o.push(a), r.push(a.mountNode)), ce(i, r), super(e, i, o), this._originalNode = c, this._modifiedNode = a;
2973
+ c && (o.push(c), r.push(c.mountNode)), a && (o.push(a), r.push(a.mountNode)), ae(i, r), super(e, i, o), this._originalNode = c, this._modifiedNode = a;
2961
2974
  }
2962
2975
  /** The mounted sides with their highlight ranges, for the diff highlighter. */
2963
2976
  get sides() {
@@ -2969,13 +2982,13 @@ function Nt(s, e, t, n) {
2969
2982
  const i = q(s.view, t, n), o = i.element;
2970
2983
  return o.classList.add(e), o.classList.toggle("md-block-active", s.active), o.classList.toggle("md-markers-hidden", !s.active), i;
2971
2984
  }
2972
- class nt extends S {
2985
+ class nt extends O {
2973
2986
  sideNode;
2974
2987
  constructor(e, t, n) {
2975
2988
  const i = n?.dom ?? document.createElement("div");
2976
2989
  i.className = "md-block md-diff-decoration", i.style.pointerEvents = "none";
2977
2990
  const o = q(e.side, t, n?.sideNode), r = o.element, c = !e.whole;
2978
- r.classList.add(e.whole ? "md-diff-removed" : "md-diff-original"), r.classList.toggle("md-block-active", c), r.classList.toggle("md-markers-hidden", !c), ce(i, [o.mountNode]), super(e, i, [o]), this.sideNode = o;
2991
+ r.classList.add(e.whole ? "md-diff-removed" : "md-diff-original"), r.classList.toggle("md-block-active", c), r.classList.toggle("md-markers-hidden", !c), ae(i, [o.mountNode]), super(e, i, [o]), this.sideNode = o;
2979
2992
  }
2980
2993
  /** A decoration has no presence in the modified document's source space. */
2981
2994
  get sourceLength() {
@@ -3007,7 +3020,7 @@ function Ei(s, e) {
3007
3020
  const r = document.createElement("span");
3008
3021
  r.className = "md-text";
3009
3022
  const c = We(r, t, n, s.ast);
3010
- return new S(s, r, c);
3023
+ return new O(s, r, c);
3011
3024
  }
3012
3025
  const i = e?.dom, o = i instanceof globalThis.Text && i.data === t ? i : document.createTextNode(t);
3013
3026
  return new pt(s, o);
@@ -3040,7 +3053,7 @@ function Tn(s, e) {
3040
3053
  }
3041
3054
  return !1;
3042
3055
  }
3043
- function Oi(s, e) {
3056
+ function Si(s, e) {
3044
3057
  const t = [];
3045
3058
  let n = -1;
3046
3059
  const i = (c) => {
@@ -3070,7 +3083,7 @@ function Oi(s, e) {
3070
3083
  }
3071
3084
  function We(s, e, t, n) {
3072
3085
  const i = [];
3073
- for (const o of Oi(e, t)) {
3086
+ for (const o of Si(e, t)) {
3074
3087
  const r = document.createTextNode(o.display ?? o.text);
3075
3088
  if (o.cls) {
3076
3089
  const c = document.createElement("span");
@@ -3081,12 +3094,12 @@ function We(s, e, t, n) {
3081
3094
  }
3082
3095
  return i;
3083
3096
  }
3084
- class pt extends S {
3097
+ class pt extends O {
3085
3098
  constructor(e, t) {
3086
3099
  super(e, t, D);
3087
3100
  }
3088
3101
  }
3089
- class j extends he {
3102
+ class j extends ne {
3090
3103
  _sourceLength;
3091
3104
  constructor(e, t, n = D, i = e.length) {
3092
3105
  super(e, t, n), this._sourceLength = i;
@@ -3095,7 +3108,7 @@ class j extends he {
3095
3108
  return this._sourceLength;
3096
3109
  }
3097
3110
  }
3098
- class It extends S {
3111
+ class It extends O {
3099
3112
  _span;
3100
3113
  constructor(e, t) {
3101
3114
  const n = e.ast, i = `md-marker md-marker-${n.markerKind}`, o = t && t.dom instanceof globalThis.Text && t.dom.data === n.content, r = o ? t._span : document.createElement("span");
@@ -3107,7 +3120,7 @@ class It extends S {
3107
3120
  return this._span;
3108
3121
  }
3109
3122
  }
3110
- class Ve extends S {
3123
+ class Ve extends O {
3111
3124
  _span;
3112
3125
  constructor(e, t) {
3113
3126
  const n = Ve._build(e, t);
@@ -3136,47 +3149,47 @@ class Ve extends S {
3136
3149
  return a || l.appendChild(d), { span: l, dom: d, children: D };
3137
3150
  }
3138
3151
  }
3139
- class Bt extends S {
3152
+ class Bt extends O {
3140
3153
  _span;
3141
3154
  constructor(e, t) {
3142
3155
  const n = e.ast.content, i = document.createElement("span");
3143
3156
  i.className = "md-hardbreak";
3144
3157
  const o = document.createElement("span");
3145
3158
  o.className = e.visible ? "md-hardbreak-src" : "md-hardbreak-src md-hardbreak-src-hidden";
3146
- const r = e.visible ? We(o, n, Ci, e.ast) : Si(o, n, e.ast);
3159
+ const r = e.visible ? We(o, n, Ci, e.ast) : Oi(o, n, e.ast);
3147
3160
  i.appendChild(o), i.appendChild(document.createElement("br")), super(e, i, r), this._span = i;
3148
3161
  }
3149
3162
  get mountNode() {
3150
3163
  return this._span;
3151
3164
  }
3152
3165
  }
3153
- function Si(s, e, t) {
3166
+ function Oi(s, e, t) {
3154
3167
  const n = document.createTextNode(e);
3155
3168
  return s.appendChild(n), [new j(t, n)];
3156
3169
  }
3157
- class se extends S {
3170
+ class ie extends O {
3158
3171
  constructor(e, t, n, i, o) {
3159
3172
  const r = o?.element ?? document.createElement(t);
3160
3173
  !o && n && (r.className = n);
3161
- const c = U(r, Cn(e), o?.children, oe(i));
3174
+ const c = U(r, Cn(e), o?.children, re(i));
3162
3175
  super(e, r, c);
3163
3176
  }
3164
3177
  }
3165
- class Dt extends S {
3178
+ class Dt extends O {
3166
3179
  constructor(e, t, n) {
3167
3180
  const i = n && n.element.tagName === `H${e.ast.level}`, o = i ? n.element : document.createElement(`h${e.ast.level}`);
3168
3181
  i || (o.className = "md-block md-heading");
3169
- const r = U(o, e.content, n?.children, oe(t));
3182
+ const r = U(o, e.content, n?.children, re(t));
3170
3183
  super(e, o, r);
3171
3184
  }
3172
3185
  }
3173
- class At extends S {
3186
+ class At extends O {
3174
3187
  _contentEl;
3175
3188
  constructor(e, t, n) {
3176
3189
  if (e.showMarkup) {
3177
3190
  const r = n?.data.showMarkup ? n : void 0, c = r?.dom ?? document.createElement("div");
3178
3191
  r || (c.className = "md-block md-thematic-break-source");
3179
- const a = U(c, e.content, r?.children, oe(t));
3192
+ const a = U(c, e.content, r?.children, re(t));
3180
3193
  super(e, c, a), this._contentEl = c;
3181
3194
  return;
3182
3195
  }
@@ -3189,7 +3202,7 @@ class At extends S {
3189
3202
  return this._contentEl;
3190
3203
  }
3191
3204
  }
3192
- class $t extends S {
3205
+ class $t extends O {
3193
3206
  _scroller;
3194
3207
  constructor(e, t, n) {
3195
3208
  const i = n && n.dom instanceof HTMLDivElement ? n : void 0, o = i?.dom ?? document.createElement("div");
@@ -3212,7 +3225,7 @@ class $t extends S {
3212
3225
  return this._scroller;
3213
3226
  }
3214
3227
  }
3215
- class _t extends S {
3228
+ class _t extends O {
3216
3229
  _session;
3217
3230
  /**
3218
3231
  * Subscription that re-tokenises the rendered `<code>` in place whenever the
@@ -3244,7 +3257,7 @@ class _t extends S {
3244
3257
  h = r._session, r._session = void 0;
3245
3258
  else if (r?._session) {
3246
3259
  const w = i.getDiff(r.ast);
3247
- w && (h = r._session, r._session = void 0, Zn((y) => h.update(w.stringEdit, y)));
3260
+ w && (h = r._session, r._session = void 0, Jn((y) => h.update(w.stringEdit, y)));
3248
3261
  }
3249
3262
  h || (h = f.create(i.language, o));
3250
3263
  }
@@ -3271,7 +3284,7 @@ class _t extends S {
3271
3284
  const v = document.createElement("code");
3272
3285
  i.language && (v.className = `language-${CSS.escape(i.language)}`);
3273
3286
  const C = Mi(i.code, o, v, g);
3274
- C instanceof On && (k = C), y.push(C), w.appendChild(v);
3287
+ C instanceof Sn && (k = C), y.push(C), w.appendChild(v);
3275
3288
  } else {
3276
3289
  const v = q(E, t, void 0);
3277
3290
  w.appendChild(v.mountNode), y.push(v);
@@ -3320,9 +3333,9 @@ function Mi(s, e, t, n) {
3320
3333
  const i = document.createTextNode(e);
3321
3334
  return t.appendChild(i), new j(s, i);
3322
3335
  }
3323
- return new On(s, t, e, n);
3336
+ return new Sn(s, t, e, n);
3324
3337
  }
3325
- class On extends he {
3338
+ class Sn extends ne {
3326
3339
  constructor(e, t, n, i) {
3327
3340
  super(e, t, Pt(e, t, n, i));
3328
3341
  }
@@ -3350,7 +3363,7 @@ function Pt(s, e, t, n) {
3350
3363
  }
3351
3364
  return i;
3352
3365
  }
3353
- function Sn(s) {
3366
+ function On(s) {
3354
3367
  let e = 0;
3355
3368
  for (const t of s) {
3356
3369
  if (t.kind === "marker" && t.markerKind === "content")
@@ -3369,7 +3382,7 @@ function Mn(s, e, t) {
3369
3382
  c.start < o || (r(c.start - o), i.push(new j(s, c.dom, D, c.length)), o = c.start + c.length);
3370
3383
  return r(t - o), i;
3371
3384
  }
3372
- class Vt extends S {
3385
+ class Vt extends O {
3373
3386
  /**
3374
3387
  * The rendered (inactive, KaTeX) height in px, measured after mount and
3375
3388
  * carried forward across rebuilds via `previous`. When the block becomes
@@ -3400,7 +3413,7 @@ class Vt extends S {
3400
3413
  displayMode: !0,
3401
3414
  className: "md-block md-math-block",
3402
3415
  nodeLength: i.length,
3403
- contentStart: Sn(i.content)
3416
+ contentStart: On(i.content)
3404
3417
  });
3405
3418
  if (c) {
3406
3419
  super(e, c.dom, Mn(i, c.segments, i.length)), this._renderedHeight = o;
@@ -3419,15 +3432,15 @@ class Vt extends S {
3419
3432
  this.data.showMarkup || (this._renderedHeight = e);
3420
3433
  }
3421
3434
  }
3422
- class Ht extends S {
3435
+ class Ht extends O {
3423
3436
  constructor(e, t, n) {
3424
3437
  const i = e.ast.ordered ? "ol" : "ul", o = n && n.element.tagName === i.toUpperCase(), r = o ? n.element : document.createElement(i);
3425
3438
  o || (r.className = "md-block md-list");
3426
- const c = U(r, e.content, n?.children, oe(t));
3439
+ const c = U(r, e.content, n?.children, re(t));
3427
3440
  super(e, r, c);
3428
3441
  }
3429
3442
  }
3430
- class Ft extends S {
3443
+ class Ft extends O {
3431
3444
  constructor(e, t, n) {
3432
3445
  const i = e.ast, o = document.createElement("li");
3433
3446
  e.isActive && o.classList.add("md-list-item-active"), i.checked !== void 0 && o.classList.add("md-task-list-item"), e.isActive || o.classList.add("md-markers-hidden"), o.style.setProperty("--md-list-level", String(e.level));
@@ -3453,39 +3466,42 @@ function Ni(s, e, t, n) {
3453
3466
  for (const d of o)
3454
3467
  d.dispose();
3455
3468
  if (!(e.length >= 2 && e[0].kind === "glue" && e[0].ast.glueKind === "indent" && e[1].kind === "marker" && e[1].ast.markerKind === "listItemMarker"))
3456
- return ce(s, r.map((d) => d.mountNode)), r;
3469
+ return ae(s, r.map((d) => d.mountNode)), r;
3457
3470
  const a = s.firstElementChild, l = a && a.classList.contains("md-list-gutter") ? a : document.createElement("span");
3458
- return l.className = "md-list-gutter", ce(l, [r[0].mountNode, r[1].mountNode]), ce(s, [l, ...r.slice(2).map((d) => d.mountNode)]), r;
3471
+ return l.className = "md-list-gutter", ae(l, [r[0].mountNode, r[1].mountNode]), ae(s, [l, ...r.slice(2).map((d) => d.mountNode)]), r;
3459
3472
  }
3460
- class Kt extends S {
3473
+ class Kt extends O {
3461
3474
  _table;
3462
3475
  constructor(e, t, n) {
3463
3476
  const i = n?.dom ?? document.createElement("div"), o = n?._table ?? document.createElement("table");
3464
3477
  n || (i.className = "md-block md-table-wrapper", o.className = "md-block md-table", i.appendChild(o));
3465
- const r = U(o, Cn(e), n?.children, oe(t));
3478
+ const r = U(o, Cn(e), n?.children, re(t));
3466
3479
  super(e, i, r), this._table = o;
3467
3480
  }
3468
3481
  get element() {
3469
3482
  return this._table;
3470
3483
  }
3484
+ get scrollElement() {
3485
+ return this.dom;
3486
+ }
3471
3487
  }
3472
- class Wt extends S {
3488
+ class Wt extends O {
3473
3489
  constructor(e, t, n) {
3474
3490
  const i = n?.element ?? document.createElement("tr");
3475
3491
  e.isDelimiter && i.classList.add("md-table-delimiter-row");
3476
- const o = U(i, e.content, n?.children, oe(t));
3492
+ const o = U(i, e.content, n?.children, re(t));
3477
3493
  e.isDelimiter || e.content.forEach((r, c) => {
3478
- r.kind === "tableCell" && r.isActive && o[c].element.classList.add("md-table-cell-active");
3494
+ r.kind === "tableCell" && o[c].element.classList.toggle("md-table-cell-active", r.isActive);
3479
3495
  }), super(e, i, o);
3480
3496
  }
3481
3497
  }
3482
- class zt extends S {
3498
+ class zt extends O {
3483
3499
  constructor(e, t, n) {
3484
3500
  const i = n?.element ?? document.createElement("code"), o = U(i, e.content, n?.children, En(t));
3485
3501
  super(e, i, o);
3486
3502
  }
3487
3503
  }
3488
- class qt extends S {
3504
+ class qt extends O {
3489
3505
  constructor(e, t, n) {
3490
3506
  if (e.showMarkup) {
3491
3507
  const a = document.createElement("span");
@@ -3501,7 +3517,7 @@ class qt extends S {
3501
3517
  displayMode: !1,
3502
3518
  className: "md-inline-math",
3503
3519
  nodeLength: e.ast.length,
3504
- contentStart: Sn(e.ast.content)
3520
+ contentStart: On(e.ast.content)
3505
3521
  });
3506
3522
  if (r) {
3507
3523
  super(e, r.dom, Mn(e.ast, r.segments, e.ast.length));
@@ -3517,7 +3533,7 @@ class qt extends S {
3517
3533
  super(e, c, D);
3518
3534
  }
3519
3535
  }
3520
- class Gt extends S {
3536
+ class Gt extends O {
3521
3537
  constructor(e, t, n) {
3522
3538
  const i = n?.element ?? document.createElement("a");
3523
3539
  if (Nn(e.ast.url) ? (i.href = e.ast.url, i.dataset.mdUrl = e.ast.url) : (i.removeAttribute("href"), delete i.dataset.mdUrl), !n) {
@@ -3544,17 +3560,17 @@ class Gt extends S {
3544
3560
  };
3545
3561
  i.addEventListener("click", l), i.addEventListener("auxclick", l);
3546
3562
  }
3547
- const o = U(i, e.content, n?.children, oe(t));
3563
+ const o = U(i, e.content, n?.children, re(t));
3548
3564
  super(e, i, o);
3549
3565
  }
3550
3566
  }
3551
- class jt extends S {
3567
+ class jt extends O {
3552
3568
  constructor(e, t, n) {
3553
3569
  const i = e.ast;
3554
3570
  if (e.showMarkup) {
3555
3571
  const r = document.createElement("span");
3556
3572
  r.className = "md-image-source";
3557
- const c = U(r, e.content, n?.children, oe(t));
3573
+ const c = U(r, e.content, n?.children, re(t));
3558
3574
  super(e, r, c);
3559
3575
  return;
3560
3576
  }
@@ -3576,7 +3592,7 @@ function vt(s, e) {
3576
3592
  function Nn(s) {
3577
3593
  return !s.trim().toLowerCase().startsWith("javascript:");
3578
3594
  }
3579
- class wt extends he {
3595
+ class wt extends ne {
3580
3596
  constructor(e, t, n, i, o) {
3581
3597
  super(e, t, i), this.blocks = n, this.pendingElement = o;
3582
3598
  }
@@ -3602,7 +3618,7 @@ class wt extends he {
3602
3618
  });
3603
3619
  for (const h of l)
3604
3620
  h.dispose();
3605
- ce(i, u.map((h) => h.mountNode));
3621
+ ae(i, u.map((h) => h.mountNode));
3606
3622
  const f = [];
3607
3623
  return e.children.forEach((h, g) => {
3608
3624
  h.kind === "block" && f.push({ node: u[g], absoluteStart: h.absoluteStart });
@@ -3613,7 +3629,7 @@ class wt extends he {
3613
3629
  return this.dom;
3614
3630
  }
3615
3631
  }
3616
- class Ut extends he {
3632
+ class Ut extends ne {
3617
3633
  element;
3618
3634
  constructor(e) {
3619
3635
  const t = document.createElement("p");
@@ -3745,7 +3761,7 @@ class Yi {
3745
3761
  }
3746
3762
  kind = "tableCell";
3747
3763
  }
3748
- class Ji {
3764
+ class Zi {
3749
3765
  /**
3750
3766
  * Whether non-obvious whitespace in this text is revealed (block is active).
3751
3767
  * `leftWordBoundary`/`rightWordBoundary` say whether the inline sibling on
@@ -3758,7 +3774,7 @@ class Ji {
3758
3774
  }
3759
3775
  kind = "text";
3760
3776
  }
3761
- class Zi {
3777
+ class Ji {
3762
3778
  constructor(e, t, n) {
3763
3779
  this.ast = e, this.showMarkup = t, this.content = n;
3764
3780
  }
@@ -3820,7 +3836,7 @@ function Dn(s, e, t, n, i) {
3820
3836
  kind: "pendingParagraph"
3821
3837
  });
3822
3838
  } else if (f instanceof H) {
3823
- const h = o.get(f), g = O(h?.view, new In(f, !1, !1));
3839
+ const h = o.get(f), g = S(h?.view, new In(f, !1, !1));
3824
3840
  l.push({ absoluteStart: d, isActive: !1, view: g, kind: "glue" });
3825
3841
  }
3826
3842
  d += f.length;
@@ -3916,51 +3932,51 @@ function xe(s, e, t, n) {
3916
3932
  const i = s;
3917
3933
  switch (i.kind) {
3918
3934
  case "text":
3919
- return O(t, new Ji(i, e.showMarkup, n?.left ?? !1, n?.right ?? !1));
3935
+ return S(t, new Zi(i, e.showMarkup, n?.left ?? !1, n?.right ?? !1));
3920
3936
  // The trailing gap is revealed as `↵` glyphs by virtue of its `blockGap`
3921
3937
  // kind (see `GlueViewNode`), so the break needs no inline-flow opt-in.
3922
3938
  case "thematicBreak":
3923
- return O(t, new Zi(i, e.showMarkup, A(i.children, e, t)));
3939
+ return S(t, new Ji(i, e.showMarkup, A(i.children, e, t)));
3924
3940
  case "unhandledBlock":
3925
- return O(t, new eo(i, A(i.children, e, t)));
3941
+ return S(t, new eo(i, A(i.children, e, t)));
3926
3942
  case "marker":
3927
- return O(t, new to(i, ao(i.markerKind, e)));
3943
+ return S(t, new to(i, ao(i.markerKind, e)));
3928
3944
  case "glue":
3929
- return O(t, new In(i, lo(i.glueKind, e), e.inlineFlow ?? !1));
3945
+ return S(t, new In(i, lo(i.glueKind, e), e.inlineFlow ?? !1));
3930
3946
  case "heading":
3931
- return O(t, new Bi(i, A(i.children, Q(e), t)));
3947
+ return S(t, new Bi(i, A(i.children, Q(e), t)));
3932
3948
  case "paragraph":
3933
- return O(t, new Di(i, A(i.children, Q(e), t)));
3949
+ return S(t, new Di(i, A(i.children, Q(e), t)));
3934
3950
  case "codeBlock":
3935
- return O(t, new $i(i, e.showMarkup, A(i.children, e, t)));
3951
+ return S(t, new $i(i, e.showMarkup, A(i.children, e, t)));
3936
3952
  case "mathBlock":
3937
- return O(t, new Pi(i, e.showMarkup, A(i.children, e, t)));
3953
+ return S(t, new Pi(i, e.showMarkup, A(i.children, e, t)));
3938
3954
  case "blockQuote":
3939
- return O(t, new Vi(i, A(i.children, e, t)));
3955
+ return S(t, new Vi(i, A(i.children, e, t)));
3940
3956
  case "list":
3941
- return O(t, ho(i, e, t));
3957
+ return S(t, ho(i, e, t));
3942
3958
  case "listItem":
3943
- return O(t, Pn(i, e, t));
3959
+ return S(t, Pn(i, e, t));
3944
3960
  case "table":
3945
- return O(t, uo(i, e, t));
3961
+ return S(t, uo(i, e, t));
3946
3962
  case "tableRow":
3947
- return O(t, Vn(i, e, !1, t));
3963
+ return S(t, Vn(i, e, !1, t));
3948
3964
  case "tableCell":
3949
- return O(t, Hn(i, e.showMarkup, e.showTableGlue, e.selectionInNode, t));
3965
+ return S(t, Hn(i, e.showMarkup, e.showTableGlue, e.selectionInNode, t));
3950
3966
  case "strong":
3951
- return O(t, new Ki(i, A(i.children, Q(e), t)));
3967
+ return S(t, new Ki(i, A(i.children, Q(e), t)));
3952
3968
  case "emphasis":
3953
- return O(t, new Wi(i, A(i.children, Q(e), t)));
3969
+ return S(t, new Wi(i, A(i.children, Q(e), t)));
3954
3970
  case "strikethrough":
3955
- return O(t, new zi(i, A(i.children, Q(e), t)));
3971
+ return S(t, new zi(i, A(i.children, Q(e), t)));
3956
3972
  case "inlineCode":
3957
- return O(t, new qi(i, A(i.children, Q(e), t)));
3973
+ return S(t, new qi(i, A(i.children, Q(e), t)));
3958
3974
  case "inlineMath":
3959
- return O(t, new Gi(i, e.showMarkup, A(i.children, Q(e), t)));
3975
+ return S(t, new Gi(i, e.showMarkup, A(i.children, Q(e), t)));
3960
3976
  case "link":
3961
- return O(t, new ji(i, A(i.children, Q(e), t)));
3977
+ return S(t, new ji(i, A(i.children, Q(e), t)));
3962
3978
  case "image":
3963
- return O(t, new Ui(i, e.showMarkup, A(i.children, Q(e), t)));
3979
+ return S(t, new Ui(i, e.showMarkup, A(i.children, Q(e), t)));
3964
3980
  case "document":
3965
3981
  return Dn(i, /* @__PURE__ */ new Set(), _.ofLength(0), void 0);
3966
3982
  }
@@ -3969,7 +3985,7 @@ function it(s) {
3969
3985
  return s.kind === "document" ? s.blocks.map((e) => e.view) : "content" in s ? s.content : ro;
3970
3986
  }
3971
3987
  const ro = [];
3972
- function Se(s) {
3988
+ function Oe(s) {
3973
3989
  if (!s)
3974
3990
  return;
3975
3991
  const e = /* @__PURE__ */ new Map();
@@ -3977,7 +3993,7 @@ function Se(s) {
3977
3993
  e.set(t.ast, t);
3978
3994
  return e;
3979
3995
  }
3980
- function O(s, e) {
3996
+ function S(s, e) {
3981
3997
  if (s && s.kind === e.kind && s.ast === e.ast && co(s, e)) {
3982
3998
  const t = it(s), n = it(e);
3983
3999
  if (t.length === n.length && t.every((i, o) => i === n[o]))
@@ -4016,7 +4032,7 @@ function co(s, e) {
4016
4032
  }
4017
4033
  }
4018
4034
  function A(s, e, t) {
4019
- const n = Se(t);
4035
+ const n = Oe(t);
4020
4036
  return s.map((i, o) => {
4021
4037
  const r = i.kind === "text" ? {
4022
4038
  left: o > 0 && Xt(s[o - 1], "end"),
@@ -4051,7 +4067,7 @@ function lo(s, e) {
4051
4067
  return e.showMarkup || s === "tableCellGlue" && e.showTableGlue;
4052
4068
  }
4053
4069
  function ho(s, e, t) {
4054
- const n = Se(t), i = fo(s, e), o = new Set(s.items), r = (e.listLevel ?? 0) + 1, c = [];
4070
+ const n = Oe(t), i = fo(s, e), o = new Set(s.items), r = (e.listLevel ?? 0) + 1, c = [];
4055
4071
  let a = 0;
4056
4072
  for (const l of s.children) {
4057
4073
  if (o.has(l)) {
@@ -4061,7 +4077,7 @@ function ho(s, e, t) {
4061
4077
  selectionInNode: u && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0,
4062
4078
  listLevel: r
4063
4079
  };
4064
- c.push(O(n?.get(d), Pn(d, f, n?.get(d))));
4080
+ c.push(S(n?.get(d), Pn(d, f, n?.get(d))));
4065
4081
  } else
4066
4082
  c.push(xe(l, e, n?.get(l)));
4067
4083
  a += l.length;
@@ -4069,7 +4085,7 @@ function ho(s, e, t) {
4069
4085
  return new Hi(s, c);
4070
4086
  }
4071
4087
  function Pn(s, e, t) {
4072
- const n = Se(t), i = [];
4088
+ const n = Oe(t), i = [];
4073
4089
  let o = 0;
4074
4090
  for (const r of s.children) {
4075
4091
  const c = e.selectionInNode ? { ...e, selectionInNode: e.selectionInNode.delta(-o) } : e;
@@ -4078,7 +4094,7 @@ function Pn(s, e, t) {
4078
4094
  return new Xi(s, e.showMarkup, i, e.listLevel ?? 1);
4079
4095
  }
4080
4096
  function uo(s, e, t) {
4081
- const n = Se(t), i = e.showMarkup, o = s.delimiterRow, r = new Set(
4097
+ const n = Oe(t), i = e.showMarkup, o = s.delimiterRow, r = new Set(
4082
4098
  [s.headerRow, s.delimiterRow, ...s.bodyRows].filter((l) => l !== void 0)
4083
4099
  ), c = [];
4084
4100
  let a = 0;
@@ -4089,7 +4105,7 @@ function uo(s, e, t) {
4089
4105
  showTableGlue: i,
4090
4106
  selectionInNode: !u && i && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0
4091
4107
  };
4092
- c.push(O(n?.get(d), Vn(d, f, u, n?.get(d))));
4108
+ c.push(S(n?.get(d), Vn(d, f, u, n?.get(d))));
4093
4109
  } else
4094
4110
  c.push(xe(l, e, n?.get(l)));
4095
4111
  a += l.length;
@@ -4097,7 +4113,7 @@ function uo(s, e, t) {
4097
4113
  return new Fi(s, c);
4098
4114
  }
4099
4115
  function Vn(s, e, t, n) {
4100
- const i = Se(n), o = e.showMarkup, r = t ? void 0 : go(s, e), c = new Set(s.cells), a = [];
4116
+ const i = Oe(n), o = e.showMarkup, r = t ? void 0 : go(s, e), c = new Set(s.cells), a = [];
4101
4117
  let l = 0;
4102
4118
  for (const d of s.children) {
4103
4119
  if (c.has(d)) {
@@ -4372,7 +4388,7 @@ function Qe(s, e) {
4372
4388
  function Kn(s) {
4373
4389
  if (!s)
4374
4390
  return;
4375
- const e = s.element;
4391
+ const e = s.scrollElement;
4376
4392
  if (e.scrollWidth <= e.clientWidth + 1)
4377
4393
  return;
4378
4394
  const n = e.getBoundingClientRect().left + e.clientLeft;
@@ -4499,7 +4515,7 @@ class To extends W {
4499
4515
  return new Yt([]);
4500
4516
  const n = this._parent.getBoundingClientRect(), i = [];
4501
4517
  for (const o of e) {
4502
- const r = o.type === "deleted" || o.range.isEmpty ? So(o, t, n.top) : Oo(o, t, n.top);
4518
+ const r = o.type === "deleted" || o.range.isEmpty ? Oo(o, t, n.top) : So(o, t, n.top);
4503
4519
  if (!r)
4504
4520
  continue;
4505
4521
  const c = document.createElement("div");
@@ -4513,7 +4529,7 @@ class Yt {
4513
4529
  this.rects = e;
4514
4530
  }
4515
4531
  }
4516
- function Oo(s, e, t) {
4532
+ function So(s, e, t) {
4517
4533
  let n = 1 / 0, i = -1 / 0;
4518
4534
  for (const o of e.lines) {
4519
4535
  const r = Mo(o);
@@ -4522,7 +4538,7 @@ function Oo(s, e, t) {
4522
4538
  if (!(i <= n))
4523
4539
  return { type: s.type, y: n - t, height: i - n };
4524
4540
  }
4525
- function So(s, e, t) {
4541
+ function Oo(s, e, t) {
4526
4542
  const n = e.lineIndexOfOffset(s.range.start);
4527
4543
  return { type: "deleted", y: e.lineRect(n).top - t, height: 0 };
4528
4544
  }
@@ -4642,7 +4658,8 @@ class Br extends W {
4642
4658
  block: n.node.block,
4643
4659
  absoluteStart: n.absoluteStart,
4644
4660
  viewNode: n.node,
4645
- element: n.node.element
4661
+ element: n.node.element,
4662
+ scrollElement: n.node.scrollElement
4646
4663
  })) : [];
4647
4664
  });
4648
4665
  /**
@@ -4692,7 +4709,7 @@ class Br extends W {
4692
4709
  }));
4693
4710
  }
4694
4711
  /**
4695
- * Renders the edit/read-only lock toggle. It flips the model's
4712
+ * Renders the edit/read-only mode toggle. It flips the model's
4696
4713
  * {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
4697
4714
  * in its clean rendered form (no markdown markers revealed) and edits are
4698
4715
  * ignored, while text selection still works. The control lives in a
@@ -4706,29 +4723,35 @@ class Br extends W {
4706
4723
  const t = document.createElement("button");
4707
4724
  t.type = "button", t.className = "md-readonly-toggle";
4708
4725
  const n = document.createElement("span");
4709
- n.className = "codicon codicon-lock md-readonly-toggle-icon md-readonly-toggle-icon-locked", n.setAttribute("aria-hidden", "true");
4710
- const i = document.createElement("span");
4711
- i.className = "codicon codicon-unlock md-readonly-toggle-icon md-readonly-toggle-icon-unlocked", i.setAttribute("aria-hidden", "true");
4712
- const o = document.createElement("span");
4713
- o.className = "md-readonly-toggle-label", t.append(n, i, o), e.appendChild(t), this.element.style.position || (this.element.style.position = "relative");
4714
- const r = () => {
4726
+ n.className = "md-readonly-toggle-indicator", n.setAttribute("aria-hidden", "true");
4727
+ const i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4728
+ i.classList.add("md-readonly-toggle-icon", "md-readonly-toggle-icon-locked"), i.setAttribute("viewBox", "0 0 16 16"), i.setAttribute("fill", "currentColor"), i.setAttribute("aria-hidden", "true");
4729
+ const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
4730
+ o.setAttribute("d", "M8 9C8.55228 9 9 9.44771 9 10C9 10.5523 8.55228 11 8 11C7.44772 11 7 10.5523 7 10C7 9.44771 7.44772 9 8 9Z");
4731
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
4732
+ r.setAttribute("fill-rule", "evenodd"), r.setAttribute("clip-rule", "evenodd"), r.setAttribute("d", "M8 1C9.654 1 11 2.346 11 4V6H12C13.103 6 14 6.897 14 8V13C14 14.103 13.103 15 12 15H4C2.897 15 2 14.103 2 13V8C2 6.897 2.897 6 4 6H5V4C5 2.346 6.346 1 8 1ZM4 7C3.449 7 3 7.449 3 8V13C3 13.551 3.449 14 4 14H12C12.551 14 13 13.551 13 13V8C13 7.449 12.551 7 12 7H4ZM8 2C6.897 2 6 2.897 6 4V6H10V4C10 2.897 9.103 2 8 2Z"), i.append(o, r);
4733
+ const c = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4734
+ c.classList.add("md-readonly-toggle-icon", "md-readonly-toggle-icon-editing"), c.setAttribute("viewBox", "0 0 16 16"), c.setAttribute("fill", "currentColor"), c.setAttribute("aria-hidden", "true");
4735
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
4736
+ a.setAttribute("d", "M14.236 1.76386C13.2123 0.740172 11.5525 0.740171 10.5289 1.76386L2.65722 9.63549C2.28304 10.0097 2.01623 10.4775 1.88467 10.99L1.01571 14.3755C0.971767 14.5467 1.02148 14.7284 1.14646 14.8534C1.27144 14.9783 1.45312 15.028 1.62432 14.9841L5.00978 14.1151C5.52234 13.9836 5.99015 13.7168 6.36433 13.3426L14.236 5.47097C15.2596 4.44728 15.2596 2.78755 14.236 1.76386ZM11.236 2.47097C11.8691 1.8378 12.8957 1.8378 13.5288 2.47097C14.162 3.10413 14.162 4.1307 13.5288 4.76386L12.75 5.54269L10.4571 3.24979L11.236 2.47097ZM9.75002 3.9569L12.0429 6.24979L5.65722 12.6355C5.40969 12.883 5.10023 13.0595 4.76117 13.1465L2.19447 13.8053L2.85327 11.2386C2.9403 10.8996 3.1168 10.5901 3.36433 10.3426L9.75002 3.9569Z"), c.appendChild(a), t.append(n, i, c), e.appendChild(t), this.element.style.position || (this.element.style.position = "relative");
4737
+ const l = () => {
4715
4738
  this._model.readonlyMode.set(!this._model.readonlyMode.get(), void 0);
4716
- }, c = (u) => {
4717
- u.button === 0 && (u.preventDefault(), u.stopPropagation(), this.focus());
4718
- }, a = (u) => {
4719
- u.stopPropagation();
4720
- }, l = () => {
4739
+ }, d = (g) => {
4740
+ g.button === 0 && (g.preventDefault(), g.stopPropagation(), this.focus());
4741
+ }, u = (g) => {
4742
+ g.stopPropagation();
4743
+ }, f = () => {
4721
4744
  this.element.editContext = null;
4722
- }, d = () => {
4745
+ }, h = () => {
4723
4746
  this.element.editContext = this.editContext;
4724
4747
  };
4725
- t.addEventListener("pointerdown", c), t.addEventListener("keydown", a), t.addEventListener("focus", l), t.addEventListener("blur", d), t.addEventListener("click", r), this._register({
4748
+ t.addEventListener("pointerdown", d), t.addEventListener("keydown", u), t.addEventListener("focus", f), t.addEventListener("blur", h), t.addEventListener("click", l), this._register({
4726
4749
  dispose: () => {
4727
- t.removeEventListener("pointerdown", c), t.removeEventListener("keydown", a), t.removeEventListener("focus", l), t.removeEventListener("blur", d), t.removeEventListener("click", r), this.element.editContext === null && (this.element.editContext = this.editContext);
4750
+ t.removeEventListener("pointerdown", d), t.removeEventListener("keydown", u), t.removeEventListener("focus", f), t.removeEventListener("blur", h), t.removeEventListener("click", l), this.element.editContext === null && (this.element.editContext = this.editContext);
4728
4751
  }
4729
- }), this._register(P((u) => {
4730
- const f = this._model.readonlyMode.read(u);
4731
- o.textContent = f ? "Locked" : "Editing", t.classList.toggle("md-readonly-toggle-locked", f), t.setAttribute("aria-pressed", String(f)), t.title = f ? "Read-only: markers hidden, editing disabled. Click to edit." : "Editing: click to lock (hide markers, disable editing).", this.element.classList.toggle("md-readonly", f);
4752
+ }), this._register(P((g) => {
4753
+ const m = this._model.readonlyMode.read(g);
4754
+ t.classList.toggle("md-readonly-toggle-locked", m), t.setAttribute("aria-pressed", String(m)), t.setAttribute("aria-label", m ? "Locked; switch to editing" : "Editing; switch to locked mode"), t.title = m ? "Read-only: markers hidden, editing disabled. Click to edit." : "Editing: click to lock (hide markers, disable editing).", this.element.classList.toggle("md-readonly", m);
4732
4755
  })), this.element.insertBefore(e, this.element.firstChild);
4733
4756
  }
4734
4757
  focus() {
@@ -4753,13 +4776,51 @@ class Br extends W {
4753
4776
  * original block. Honours {@link geometricHitTest}.
4754
4777
  */
4755
4778
  resolveOffsetFromPoint(e) {
4779
+ const t = this._resolveTableCellOffset(e);
4780
+ if (t !== void 0)
4781
+ return t;
4756
4782
  if (this.geometricHitTest.get()) {
4757
- const n = this.measuredLayout.visualLineMap.get();
4758
- return n.isEmpty ? void 0 : n.offsetAtPoint(e);
4783
+ const i = this.measuredLayout.visualLineMap.get();
4784
+ return i.isEmpty ? void 0 : i.offsetAtPoint(e);
4785
+ }
4786
+ const n = Ii(e);
4787
+ if (n)
4788
+ return this._document.get()?.resolveSource(n);
4789
+ }
4790
+ /**
4791
+ * Resolve table-cell hits that have no measurable text run. Empty cells map
4792
+ * from their own box instead of snapping to a neighboring cell; element-only
4793
+ * content (for example an inactive image) maps through the hit element's view
4794
+ * node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
4795
+ */
4796
+ _resolveTableCellOffset(e) {
4797
+ const t = document.elementFromPoint(e.x, e.y), n = t?.closest("td");
4798
+ if (!(n instanceof HTMLTableCellElement) || !this._contentContainer.contains(n))
4799
+ return;
4800
+ const i = this._document.get();
4801
+ if (!i)
4802
+ return;
4803
+ const o = ne.forDom(n);
4804
+ if (o?.ast.kind !== "tableCell" || o.dom !== n)
4805
+ return;
4806
+ const r = i.resolveSource({ node: n, offset: 0 }), c = i.resolveSource({ node: n, offset: 1 });
4807
+ if (r === void 0 || c === void 0)
4808
+ return;
4809
+ const a = (u) => {
4810
+ const f = u.getBoundingClientRect();
4811
+ return (getComputedStyle(u).direction === "rtl" ? e.x >= f.left + f.width / 2 : e.x < f.left + f.width / 2) ? 0 : 1;
4812
+ }, l = (u, f) => this.measuredLayout.visualLineMap.get().lines.some(
4813
+ (h) => h.runs.some(
4814
+ (g) => g.source !== void 0 && g.sourceStart < f && g.sourceEndExclusive > u
4815
+ )
4816
+ ), d = t ? ne.forDom(t) : void 0;
4817
+ if (d && d !== o && d.dom instanceof Element) {
4818
+ const u = i.resolveSource({ node: d.dom, offset: 0 }), f = i.resolveSource({ node: d.dom, offset: 1 });
4819
+ if (u !== void 0 && f !== void 0 && !l(u, f))
4820
+ return f - u <= 1 ? f : a(d.dom) === 0 ? u + 1 : f - 1;
4759
4821
  }
4760
- const t = Ii(e);
4761
- if (t)
4762
- return this._document.get()?.resolveSource(t);
4822
+ if (!l(r, c))
4823
+ return c - r <= 1 ? c : a(n) === 0 ? r + 1 : c - 1;
4763
4824
  }
4764
4825
  /**
4765
4826
  * Whether a client point falls on the rendered document content, as
@@ -4819,7 +4880,7 @@ class Br extends W {
4819
4880
  for (const n of e.blocks) {
4820
4881
  const i = n.node.element.getBoundingClientRect();
4821
4882
  n.node.recordMeasuredHeight(i.height);
4822
- const o = Oe.measure([{
4883
+ const o = Se.measure([{
4823
4884
  absoluteStart: n.absoluteStart,
4824
4885
  viewNode: n.node
4825
4886
  }]);
@@ -4901,7 +4962,7 @@ class Dr {
4901
4962
  return n.addEventListener("keydown", t), { dispose: () => n.removeEventListener("keydown", t) };
4902
4963
  }
4903
4964
  }
4904
- const Io = 500, Jt = 5;
4965
+ const Io = 500, Zt = 5;
4905
4966
  class Ar extends W {
4906
4967
  constructor(e, t, n) {
4907
4968
  super(), this._model = e, this._view = t;
@@ -4921,7 +4982,7 @@ class Ar extends W {
4921
4982
  this._register(r.connect({
4922
4983
  element: i,
4923
4984
  getSelectedText: () => this._selectedText(),
4924
- deleteSelection: () => this._executeEditCommand(St),
4985
+ deleteSelection: () => this._executeEditCommand(Ot),
4925
4986
  insertText: (a) => {
4926
4987
  this._model.pendingParagraph.get() !== void 0 ? this._model.materializePendingParagraph(a) : this._executeEditCommand(ri(a));
4927
4988
  }
@@ -4951,7 +5012,7 @@ class Ar extends W {
4951
5012
  if (e.button !== 0)
4952
5013
  return;
4953
5014
  e.preventDefault(), this._model.cancelPendingParagraph(), this._view.focus(), this._desiredColumn = void 0;
4954
- const t = new ve(e.clientX, e.clientY), n = this._lastPointerDown, i = n !== void 0 && e.timeStamp - n.time < Io && Math.abs(t.x - n.point.x) < Jt && Math.abs(t.y - n.point.y) < Jt;
5015
+ const t = new ve(e.clientX, e.clientY), n = this._lastPointerDown, i = n !== void 0 && e.timeStamp - n.time < Io && Math.abs(t.x - n.point.x) < Zt && Math.abs(t.y - n.point.y) < Zt;
4955
5016
  if (this._clickCount = i ? this._clickCount + 1 : 1, this._lastPointerDown = { time: e.timeStamp, point: t }, !this._view.isPointInContent(t)) {
4956
5017
  this._model.selection.set(void 0, void 0);
4957
5018
  return;
@@ -5021,7 +5082,7 @@ class Ar extends W {
5021
5082
  }
5022
5083
  /** Move the cursor up one visual line (Arrow Up). */
5023
5084
  cursorUp(e = !1) {
5024
- this._executeVisualCursorCommand(Ot, e);
5085
+ this._executeVisualCursorCommand(St, e);
5025
5086
  }
5026
5087
  _selectedText() {
5027
5088
  const e = this._model.selection.get();
@@ -5046,20 +5107,20 @@ class Ar extends W {
5046
5107
  if (e.key === "ArrowLeft")
5047
5108
  e.preventDefault(), t ? this._executeCursorCommand((e.shiftKey, Lt), e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Ys, !0) : this._executeCursorCommand(Xs, !1);
5048
5109
  else if (e.key === "ArrowRight")
5049
- e.preventDefault(), t ? this._executeCursorCommand(Js, e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Qs, !0) : this._executeCursorCommand(Us, !1);
5110
+ e.preventDefault(), t ? this._executeCursorCommand(Zs, e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Qs, !0) : this._executeCursorCommand(Us, !1);
5050
5111
  else if (e.key === "ArrowUp")
5051
- e.preventDefault(), this._executeVisualCursorCommand(Ot, e.shiftKey);
5112
+ e.preventDefault(), this._executeVisualCursorCommand(St, e.shiftKey);
5052
5113
  else if (e.key === "ArrowDown")
5053
5114
  e.preventDefault(), this._executeVisualCursorCommand(Tt, e.shiftKey);
5054
5115
  else if (e.key === "Home")
5055
- e.preventDefault(), t ? this._executeCursorCommand(ti, e.shiftKey) : this._executeCursorCommand(Zs, e.shiftKey);
5116
+ e.preventDefault(), t ? this._executeCursorCommand(ti, e.shiftKey) : this._executeCursorCommand(Js, e.shiftKey);
5056
5117
  else if (e.key === "End")
5057
5118
  e.preventDefault(), t ? this._executeCursorCommand(ni, e.shiftKey) : this._executeCursorCommand(ei, e.shiftKey);
5058
5119
  else if (e.key === "a" && t) {
5059
5120
  e.preventDefault();
5060
5121
  const n = this._makeCursorContext();
5061
5122
  this._model.selection.set(vi(n), void 0);
5062
- } else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ? ii : St)) : e.key === "Delete" ? (e.preventDefault(), this._executeEditCommand(t ? oi : si)) : e.key === "Enter" && (e.preventDefault(), t ? this._executeEditCommand(ci) : e.shiftKey ? this._executeEditCommand(li) : this._smartEnter());
5123
+ } else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ? ii : Ot)) : e.key === "Delete" ? (e.preventDefault(), this._executeEditCommand(t ? oi : si)) : e.key === "Enter" && (e.preventDefault(), t ? this._executeEditCommand(ci) : e.shiftKey ? this._executeEditCommand(li) : this._smartEnter());
5063
5124
  };
5064
5125
  /**
5065
5126
  * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
@@ -5085,7 +5146,7 @@ function Bo(s, e) {
5085
5146
  t += n.length;
5086
5147
  }
5087
5148
  }
5088
- const Zt = "md-debug-show-line-rects";
5149
+ const Jt = "md-debug-show-line-rects";
5089
5150
  function Do(s, e) {
5090
5151
  try {
5091
5152
  const t = localStorage.getItem(s);
@@ -5129,7 +5190,7 @@ class $r extends W {
5129
5190
  });
5130
5191
  const i = document.createElement("input");
5131
5192
  i.type = "checkbox", i.checked = this._showLineRects.get(), i.addEventListener("change", () => {
5132
- this._showLineRects.set(i.checked, void 0), Ao(Zt, i.checked);
5193
+ this._showLineRects.set(i.checked, void 0), Ao(Jt, i.checked);
5133
5194
  }), n.appendChild(i), n.appendChild(document.createTextNode("show line rects")), this.infoElement.appendChild(n);
5134
5195
  const o = document.createElement("pre");
5135
5196
  o.style.margin = "0", o.style.whiteSpace = "pre", this.infoElement.appendChild(o), this.rendering = $(this, (r) => {
@@ -5147,7 +5208,7 @@ class $r extends W {
5147
5208
  /** Absolute source offsets that map to a rendered DOM character. */
5148
5209
  mappedOffsets;
5149
5210
  /** Whether the dashed line-bands and run boxes are drawn (persisted). */
5150
- _showLineRects = N(this, Do(Zt, !0));
5211
+ _showLineRects = N(this, Do(Jt, !0));
5151
5212
  }
5152
5213
  class $o {
5153
5214
  constructor(e, t, n, i) {
@@ -5661,7 +5722,7 @@ class Hr {
5661
5722
  this._comments.set(this._comments.get().filter((t) => t.id !== e), void 0);
5662
5723
  }
5663
5724
  }
5664
- const De = "http://www.w3.org/2000/svg", Yo = 260, Jo = 320, Zo = 0.32, er = 28, rn = 16, tr = 12, nr = 18, sr = 4, ir = 2, or = 10;
5725
+ const De = "http://www.w3.org/2000/svg", Yo = 260, Zo = 320, Jo = 0.32, er = 28, rn = 16, tr = 12, nr = 18, sr = 4, ir = 2, or = 10;
5665
5726
  class rr extends W {
5666
5727
  constructor(e, t) {
5667
5728
  super(), this._model = e, this._view = t, this._layer = this._createLayer("md-comment-shapes"), this._view.overlayContainer.appendChild(this._layer), this._register({
@@ -5762,7 +5823,7 @@ class rr extends W {
5762
5823
  return;
5763
5824
  }
5764
5825
  this._layer.style.display = "";
5765
- const i = t.getBoundingClientRect(), o = i.width, r = getComputedStyle(n), c = parseFloat(r.maxWidth), a = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), l = (parseFloat(r.borderLeftWidth) || 0) + (parseFloat(r.borderRightWidth) || 0), d = Number.isNaN(c) ? o : r.boxSizing === "border-box" ? c : c + a + l, u = Math.max(0, (o - Math.min(d, o)) / 2), f = Math.round(Math.max(Yo, Math.min(Jo, o * Zo))), h = f + er + rn, g = u >= h ? 0 : Math.min(2 * (h - u), h), m = g > 0 ? `${Math.ceil(g)}px` : "";
5826
+ const i = t.getBoundingClientRect(), o = i.width, r = getComputedStyle(n), c = parseFloat(r.maxWidth), a = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), l = (parseFloat(r.borderLeftWidth) || 0) + (parseFloat(r.borderRightWidth) || 0), d = Number.isNaN(c) ? o : r.boxSizing === "border-box" ? c : c + a + l, u = Math.max(0, (o - Math.min(d, o)) / 2), f = Math.round(Math.max(Yo, Math.min(Zo, o * Jo))), h = f + er + rn, g = u >= h ? 0 : Math.min(2 * (h - u), h), m = g > 0 ? `${Math.ceil(g)}px` : "";
5766
5827
  t.style.paddingRight !== m && (t.style.paddingRight = m);
5767
5828
  const p = n.getBoundingClientRect(), k = i.right - rn - f - p.left, w = n.clientWidth, y = e.map(({ entry: v, rects: C }) => {
5768
5829
  v.card.style.left = `${k}px`, v.card.style.width = `${f}px`;
@@ -5888,7 +5949,7 @@ const qn = {
5888
5949
  edit: fe('<path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>'),
5889
5950
  close: fe('<line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>')
5890
5951
  };
5891
- function Je(s) {
5952
+ function Ze(s) {
5892
5953
  const e = L(`span.codicon.codicon-${s}`);
5893
5954
  return e.setAttribute("aria-hidden", "true"), e.innerHTML = qn[s] ?? "", e;
5894
5955
  }
@@ -5903,7 +5964,7 @@ function Ae(s) {
5903
5964
  }
5904
5965
  class mr {
5905
5966
  constructor(e, t) {
5906
- this._comments = e, this._domNode = L("div.agent-feedback-widget"), this._domNode.classList.add("collapsed"), this._domNode.tabIndex = -1, this._domNode.setAttribute("widgetid", "agent-feedback-widget-0"), this._headerNode = L("div.agent-feedback-widget-header"), this._headerNode.appendChild(Je("comment")), this._titleNode = L("span.agent-feedback-widget-title"), this._updateTitle(), this._headerNode.appendChild(this._titleNode), this._headerNode.appendChild(L("span.agent-feedback-widget-spacer")), this._toggleButton = L("div.agent-feedback-widget-toggle"), this._updateToggleButton(), this._headerNode.appendChild(this._toggleButton), this._domNode.appendChild(this._headerNode), this._bodyNode = L("div.agent-feedback-widget-body"), this._bodyNode.classList.add("collapsed"), this._buildFeedbackItems(), this._domNode.appendChild(this._bodyNode), this._domNode.appendChild(L("div.agent-feedback-widget-arrow")), this._setupEventHandlers(), this._domNode.classList.add("visible"), t?.expanded && this.expand(), t?.focusedCommentId && this.focusFeedback(t.focusedCommentId);
5967
+ this._comments = e, this._domNode = L("div.agent-feedback-widget"), this._domNode.classList.add("collapsed"), this._domNode.tabIndex = -1, this._domNode.setAttribute("widgetid", "agent-feedback-widget-0"), this._headerNode = L("div.agent-feedback-widget-header"), this._headerNode.appendChild(Ze("comment")), this._titleNode = L("span.agent-feedback-widget-title"), this._updateTitle(), this._headerNode.appendChild(this._titleNode), this._headerNode.appendChild(L("span.agent-feedback-widget-spacer")), this._toggleButton = L("div.agent-feedback-widget-toggle"), this._updateToggleButton(), this._headerNode.appendChild(this._toggleButton), this._domNode.appendChild(this._headerNode), this._bodyNode = L("div.agent-feedback-widget-body"), this._bodyNode.classList.add("collapsed"), this._buildFeedbackItems(), this._domNode.appendChild(this._bodyNode), this._domNode.appendChild(L("div.agent-feedback-widget-arrow")), this._setupEventHandlers(), this._domNode.classList.add("visible"), t?.expanded && this.expand(), t?.focusedCommentId && this.focusFeedback(t.focusedCommentId);
5907
5968
  }
5908
5969
  _domNode;
5909
5970
  _headerNode;
@@ -5923,7 +5984,7 @@ class mr {
5923
5984
  this._titleNode.textContent = e === 1 ? this._comments[0].text : `${e} comments`;
5924
5985
  }
5925
5986
  _updateToggleButton() {
5926
- this._toggleButton.textContent = "", this._isExpanded ? (this._toggleButton.appendChild(Je("chevron-up")), this._toggleButton.title = "Collapse") : (this._toggleButton.appendChild(Je("chevron-down")), this._toggleButton.title = "Expand");
5987
+ this._toggleButton.textContent = "", this._isExpanded ? (this._toggleButton.appendChild(Ze("chevron-up")), this._toggleButton.title = "Collapse") : (this._toggleButton.appendChild(Ze("chevron-down")), this._toggleButton.title = "Expand");
5927
5988
  }
5928
5989
  _setupEventHandlers() {
5929
5990
  this._listen(this._toggleButton, "click", (e) => {
@@ -6205,7 +6266,7 @@ export {
6205
6266
  F as AstNode,
6206
6267
  Dr as AsyncClipboardStrategy,
6207
6268
  we as BlockQuoteAstNode,
6208
- S as BlockViewNode,
6269
+ O as BlockViewNode,
6209
6270
  Kr as COMMENTS_DESIGNS,
6210
6271
  Fr as COMMENTS_DESIGN_LABELS,
6211
6272
  G as CodeBlockAstNode,
@@ -6223,25 +6284,25 @@ export {
6223
6284
  Br as EditorView,
6224
6285
  ct as EmphasisAstNode,
6225
6286
  H as GlueAstNode,
6226
- ie as HeadingAstNode,
6287
+ oe as HeadingAstNode,
6227
6288
  Te as ImageAstNode,
6228
6289
  lt as InlineCodeAstNode,
6229
6290
  dt as InlineMathAstNode,
6230
6291
  me as LengthEdit,
6231
6292
  ot as LengthReplacement,
6232
6293
  Le as LinkAstNode,
6233
- Z as ListAstNode,
6294
+ J as ListAstNode,
6234
6295
  ee as ListItemAstNode,
6235
6296
  ws as MarkdownParser,
6236
6297
  b as MarkerAstNode,
6237
- de as MathBlockAstNode,
6298
+ he as MathBlockAstNode,
6238
6299
  $o as MeasuredLayoutDebugRendering,
6239
6300
  $r as MeasuredLayoutDebugView,
6240
6301
  Ws as MeasuredLayoutModel,
6241
6302
  Fo as MonacoSyntaxHighlighter,
6242
6303
  Ro as NativeClipboardStrategy,
6243
6304
  _ as OffsetRange,
6244
- J as ParagraphAstNode,
6305
+ Z as ParagraphAstNode,
6245
6306
  ve as Point2D,
6246
6307
  V as Rect2D,
6247
6308
  x as Selection,
@@ -6257,11 +6318,11 @@ export {
6257
6318
  Ee as TableCellAstNode,
6258
6319
  ye as TableRowAstNode,
6259
6320
  be as TextAstNode,
6260
- ae as ThematicBreakAstNode,
6321
+ le as ThematicBreakAstNode,
6261
6322
  Ce as Token,
6262
- he as ViewNode,
6323
+ ne as ViewNode,
6263
6324
  As as VisualLine,
6264
- Oe as VisualLineMap,
6325
+ Se as VisualLineMap,
6265
6326
  et as VisualRun,
6266
6327
  br as VsCodeV2CommentsView,
6267
6328
  pr as VscodeStackedCommentsView,
@@ -6271,14 +6332,14 @@ export {
6271
6332
  Tt as cursorDown,
6272
6333
  Xs as cursorLeft,
6273
6334
  ei as cursorLineEnd,
6274
- Zs as cursorLineStart,
6335
+ Js as cursorLineStart,
6275
6336
  Ys as cursorMoveLeft,
6276
6337
  Qs as cursorMoveRight,
6277
6338
  Us as cursorRight,
6278
- Ot as cursorUp,
6339
+ St as cursorUp,
6279
6340
  Lt as cursorWordLeft,
6280
- Js as cursorWordRight,
6281
- St as deleteLeft,
6341
+ Zs as cursorWordRight,
6342
+ Ot as deleteLeft,
6282
6343
  si as deleteRight,
6283
6344
  ii as deleteWordLeft,
6284
6345
  oi as deleteWordRight,