@aiquants/markdown-explorer 0.37.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +2 -1
  3. package/dist/{EditSurface-BvwgM4lC.js → EditSurface-BTrQ1viw.js} +3 -3
  4. package/dist/{EditSurface-Ce4bpuvh.cjs → EditSurface-Dis52Iwq.cjs} +1 -1
  5. package/dist/{ExplorerSplit-DBUFhlo_.cjs → ExplorerSplit-13nPIuf0.cjs} +1 -1
  6. package/dist/{ExplorerSplit-DKpqQBsQ.js → ExplorerSplit-Dq7HfNre.js} +4 -4
  7. package/dist/{MultiLayout-CVj5iam0.js → MultiLayout-1rKm2Hzt.js} +3 -3
  8. package/dist/{MultiLayout-BfGxy2pf.cjs → MultiLayout-B7RvBpCj.cjs} +1 -1
  9. package/dist/{NativeScrollBar-BkZPkphH.js → NativeScrollBar-Bg05yuzM.js} +2 -2
  10. package/dist/{NativeScrollBar-BQpaWt45.cjs → NativeScrollBar-D63-6AL1.cjs} +1 -1
  11. package/dist/{TreeLayout-B83wJ2CL.js → TreeLayout-9eEP62LF.js} +3 -3
  12. package/dist/{TreeLayout-Df4HLMP-.cjs → TreeLayout-CNE0XkWz.cjs} +1 -1
  13. package/dist/core/config.d.cts +3 -0
  14. package/dist/core/config.d.ts +3 -0
  15. package/dist/{explorerCore-DivWkFQF.cjs → explorerCore-5qeC3-gt.cjs} +1 -1
  16. package/dist/{explorerCore-EkU0mwdW.js → explorerCore-GCqatHTO.js} +1 -1
  17. package/dist/{index-CVnGqEmh.js → index-C52Nj37x.js} +13 -12
  18. package/dist/{index-Bz-n0dl1.cjs → index-_XNluAcx.cjs} +6 -6
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/{location-Dh6K-y7w.js → location-CJvL6JNs.js} +248 -243
  22. package/dist/location-DOIG84V9.cjs +1 -0
  23. package/dist/{merge-hFiGx_ND.cjs → merge-CKpFyeqR.cjs} +1 -1
  24. package/dist/{merge-BGr72noP.js → merge-CnrrjXmc.js} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +3 -3
  27. package/dist/serverCore.cjs +1 -1
  28. package/dist/serverCore.js +3 -3
  29. package/dist/{tapScrollCircle-DDwYa54Q.cjs → tapScrollCircle-6etmzCb7.cjs} +1 -1
  30. package/dist/{tapScrollCircle-BTCGTQ8T.js → tapScrollCircle-D-Lgzdxx.js} +1 -1
  31. package/dist/{useSplitPersistence-BUa_KMsV.cjs → useSplitPersistence-CD_n1ivo.cjs} +1 -1
  32. package/dist/{useSplitPersistence-pnb21dsr.js → useSplitPersistence-tbTu3P5m.js} +1 -1
  33. package/package.json +5 -5
  34. package/dist/location-DrOP6t1F.cjs +0 -1
@@ -1,8 +1,8 @@
1
- import { NO_EMBEDS as Ce, isEmbedProviderId as ze, EMBED_PROVIDER_IDS as Le, isLinkCardSize as Me, LINK_CARD_SIZES as je } from "@aiquants/markdown/embeds";
2
- import { CONTENT_COLORS as Fe, CONTENT_MEASURES as Ue, CONTENT_ALIGNS as D, DEFAULT_MARKDOWN_STYLES as Ve, DEFAULT_MARKDOWN_STYLE as Be } from "@aiquants/markdown/viewer-settings";
3
- import { P as We, Q as Ge, R as He, S as Ke, i as _, K as Xe, T as qe } from "./ownUrls-DD0cSCsF.js";
4
- import { d as s, i as $ } from "./describeValue-CLlVRO8d.js";
5
- const Ye = Object.freeze([
1
+ import { NO_EMBEDS as Me, isEmbedProviderId as ze, EMBED_PROVIDER_IDS as Le, isLinkCardSize as je, LINK_CARD_SIZES as Fe } from "@aiquants/markdown/embeds";
2
+ import { CONTENT_COLORS as Ue, CONTENT_MEASURES as Ve, CONTENT_ALIGNS as D, DEFAULT_MARKDOWN_STYLES as Be, DEFAULT_MARKDOWN_STYLE as We } from "@aiquants/markdown/viewer-settings";
3
+ import { P as Ge, Q as He, R as Ke, S as Xe, i as $, K as qe, T as Ye } from "./ownUrls-DD0cSCsF.js";
4
+ import { d as s, i as v } from "./describeValue-CLlVRO8d.js";
5
+ const Je = Object.freeze([
6
6
  "UTF-8",
7
7
  "IBM866",
8
8
  "ISO-8859-2",
@@ -43,11 +43,11 @@ const Ye = Object.freeze([
43
43
  "UTF-16BE",
44
44
  "UTF-16LE",
45
45
  "x-user-defined"
46
- ]), Je = new Map(Ye.map((e) => [e.toLowerCase(), e])), N = "UTF-8", Z = Object.freeze([
46
+ ]), Ze = new Map(Je.map((e) => [e.toLowerCase(), e])), N = "UTF-8", Z = Object.freeze([
47
47
  Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: N }),
48
48
  Object.freeze({ bytes: Object.freeze([255, 254]), encoding: "UTF-16LE" }),
49
49
  Object.freeze({ bytes: Object.freeze([254, 255]), encoding: "UTF-16BE" })
50
- ]), Ze = /* @__PURE__ */ new Map([
50
+ ]), Qe = /* @__PURE__ */ new Map([
51
51
  [N, "is read before any legacy encoding"],
52
52
  ["UTF-16LE", "is read only by its byte order mark"],
53
53
  ["UTF-16BE", "is read only by its byte order mark"],
@@ -60,54 +60,54 @@ const Ye = Object.freeze([
60
60
  } catch (o) {
61
61
  throw o instanceof RangeError ? new RangeError(`[markdown-explorer] legacyTextEncoding ${s(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`) : o;
62
62
  }
63
- const r = Qe(t), n = Ze.get(r);
63
+ const r = et(t), n = Qe.get(r);
64
64
  if (n !== void 0) throw new RangeError(`[markdown-explorer] legacyTextEncoding ${s(e)} names ${r}, which cannot be the legacy encoding: it ${n}`);
65
65
  return r;
66
- }, Qe = (e) => {
67
- const t = Je.get(e);
66
+ }, et = (e) => {
67
+ const t = Ze.get(e);
68
68
  if (t === void 0) throw new RangeError(`[markdown-explorer] TextDecoder answered ${s(e)}, which is no encoding of the WHATWG Encoding Standard`);
69
69
  return t;
70
- }, M = (e, t, r) => {
70
+ }, L = (e, t, r) => {
71
71
  const n = r === null ? null : fe(r), o = Z.find(({ bytes: a }) => a.every((d, l) => e[l] === d));
72
72
  if (o !== void 0) return { body: e.subarray(o.bytes.length), encodings: [o.encoding] };
73
73
  const i = t || e.length === 0 ? void 0 : Z.find(({ bytes: a }) => e.length < a.length && e.every((d, l) => a[l] === d));
74
74
  return i !== void 0 ? { body: e.subarray(e.length), encodings: [i.encoding] } : { body: e, encodings: n === null ? [N] : [N, n] };
75
- }, Qt = (e, t, r) => M(e, t, r).encodings, et = (e, t, r) => {
75
+ }, tr = (e, t, r) => L(e, t, r).encodings, tt = (e, t, r) => {
76
76
  try {
77
77
  return new TextDecoder(e, { fatal: !0, ignoreBOM: !0 }).decode(t, { stream: !r });
78
78
  } catch (n) {
79
79
  if (n instanceof TypeError) return null;
80
80
  throw n;
81
81
  }
82
- }, er = (e, t, r) => {
83
- const n = X(M(e, t, r), t);
82
+ }, rr = (e, t, r) => {
83
+ const n = X(L(e, t, r), t);
84
84
  return n === null ? null : n.text;
85
85
  }, X = ({ body: e, encodings: t }, r) => {
86
86
  for (const n of t) {
87
- const o = et(n, e, r);
87
+ const o = tt(n, e, r);
88
88
  if (o !== null) return { encoding: n, text: o };
89
89
  }
90
90
  return null;
91
- }, tr = (e, t, r) => {
92
- const n = M(e, t, r), o = X(n, t);
91
+ }, nr = (e, t, r) => {
92
+ const n = L(e, t, r), o = X(n, t);
93
93
  return o === null ? n.encodings[0] : o.encoding;
94
- }, rr = (e, t, r) => {
95
- const n = M(e, t, r), o = X(n, t);
94
+ }, or = (e, t, r) => {
95
+ const n = L(e, t, r), o = X(n, t);
96
96
  return o !== null ? o.text : new TextDecoder(n.encodings[0], { ignoreBOM: !0 }).decode(n.body, { stream: !t });
97
- }, C = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), tt = /^readme(?:\.|$)/iu, Q = /^readme(?:\.[^.]*)?$/iu, ee = Object.freeze(["md", "markdown", "mdx", "txt", ""]), rt = (e) => tt.test(e), G = (e) => e.type === "file" && rt(e.name), te = (e) => {
97
+ }, C = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), rt = /^readme(?:\.|$)/iu, Q = /^readme(?:\.[^.]*)?$/iu, ee = Object.freeze(["md", "markdown", "mdx", "txt", ""]), nt = (e) => rt.test(e), G = (e) => e.type === "file" && nt(e.name), te = (e) => {
98
98
  const t = e.lastIndexOf("."), r = ee.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
99
99
  return r < 0 ? ee.length : r;
100
- }, nt = (e, t) => {
100
+ }, ot = (e, t) => {
101
101
  const r = +!Q.test(e.name) - +!Q.test(t.name);
102
102
  if (r !== 0) return r;
103
103
  const n = te(e.name) - te(t.name);
104
104
  if (n !== 0) return n;
105
105
  const o = C.compare(e.name, t.name);
106
106
  return o !== 0 ? o : C.compare(e.path, t.path);
107
- }, nr = (e) => {
107
+ }, sr = (e) => {
108
108
  let t = null;
109
109
  for (const r of e)
110
- G(r) && (t === null || nt(r, t) < 0) && (t = r);
110
+ G(r) && (t === null || ot(r, t) < 0) && (t = r);
111
111
  return t === null ? null : t.path;
112
112
  }, re = Object.freeze({
113
113
  sortMode: "native",
@@ -124,18 +124,18 @@ const Ye = Object.freeze([
124
124
  expandIcons: !0,
125
125
  directoryIcons: !0,
126
126
  fileIcons: !0
127
- }), we = [!0, !1], ge = (e, t) => t ? e.settingOn : e.settingOff, y = (e, t) => ({ key: e, labelKey: t, values: we, formatValue: ge, requiresTreeView: !1 }), ot = Object.freeze({
127
+ }), we = [!0, !1], ge = (e, t) => t ? e.settingOn : e.settingOff, S = (e, t) => ({ key: e, labelKey: t, values: we, formatValue: ge, requiresTreeView: !1 }), st = Object.freeze({
128
128
  native: (e) => e.sortNative,
129
129
  asc: (e) => e.sortAscending,
130
130
  desc: (e) => e.sortDescending,
131
131
  oldest: (e) => e.sortOldest,
132
132
  newest: (e) => e.sortNewest
133
- }), k = Object.freeze([
133
+ }), T = Object.freeze([
134
134
  {
135
135
  key: "sortMode",
136
136
  labelKey: "settingSortMode",
137
137
  values: ["native", "asc", "desc", "oldest", "newest"],
138
- formatValue: (e, t) => ot[t](e),
138
+ formatValue: (e, t) => st[t](e),
139
139
  requiresTreeView: !1
140
140
  },
141
141
  {
@@ -173,8 +173,8 @@ const Ye = Object.freeze([
173
173
  formatValue: (e, t) => e.expandIconSizeValue(t),
174
174
  requiresTreeView: !1
175
175
  },
176
- y("alwaysExpanded", "settingAlwaysExpanded"),
177
- y("revealDocument", "settingRevealDocument"),
176
+ S("alwaysExpanded", "settingAlwaysExpanded"),
177
+ S("revealDocument", "settingRevealDocument"),
178
178
  {
179
179
  key: "showFolderReadme",
180
180
  labelKey: "settingShowFolderReadme",
@@ -182,30 +182,30 @@ const Ye = Object.freeze([
182
182
  formatValue: ge,
183
183
  requiresTreeView: !0
184
184
  },
185
- y("removeRootIndent", "settingRemoveRootIndent"),
186
- y("lines", "settingTreeLines"),
187
- y("expandIcons", "settingExpandIcons"),
188
- y("directoryIcons", "settingDirectoryIcons"),
189
- y("fileIcons", "settingFileIcons")
190
- ]), or = (e) => e === "tree" ? k : k.filter((t) => !t.requiresTreeView), he = (e) => {
191
- const t = k.find((r) => r.key === e);
185
+ S("removeRootIndent", "settingRemoveRootIndent"),
186
+ S("lines", "settingTreeLines"),
187
+ S("expandIcons", "settingExpandIcons"),
188
+ S("directoryIcons", "settingDirectoryIcons"),
189
+ S("fileIcons", "settingFileIcons")
190
+ ]), ir = (e) => e === "tree" ? T : T.filter((t) => !t.requiresTreeView), he = (e) => {
191
+ const t = T.find((r) => r.key === e);
192
192
  if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
193
193
  return t;
194
- }, sr = (e, t) => {
194
+ }, ar = (e, t) => {
195
195
  const r = he(t).values, n = r[(r.indexOf(e[t]) + 1) % r.length];
196
196
  return { ...e, [t]: n };
197
- }, ir = (e, t, r) => he(r).formatValue(e, t[r]), pe = 2, ne = Object.freeze({}), q = (e, t) => Object.freeze(Object.fromEntries(k.filter((r) => t(r, e[r.key])).map((r) => [r.key, e[r.key]]))), oe = "directoriesFirst", st = (e) => {
197
+ }, dr = (e, t, r) => he(r).formatValue(e, t[r]), pe = 2, ne = Object.freeze({}), q = (e, t) => Object.freeze(Object.fromEntries(T.filter((r) => t(r, e[r.key])).map((r) => [r.key, e[r.key]]))), oe = "directoriesFirst", it = (e) => {
198
198
  if (!Object.hasOwn(e, oe)) return e;
199
199
  const { [oe]: t, ...r } = e;
200
200
  return Object.hasOwn(r, "folderPlacement") || typeof t != "boolean" ? r : { ...r, folderPlacement: t ? "first" : "mixed" };
201
- }, ar = (e) => {
201
+ }, lr = (e) => {
202
202
  if (e === null || typeof e != "object" || Array.isArray(e)) return ne;
203
203
  const t = e;
204
- return t.version !== pe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? ne : q(st(t.settings), (r, n) => r.values.includes(n));
205
- }, dr = (e, t) => {
204
+ return t.version !== pe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? ne : q(it(t.settings), (r, n) => r.values.includes(n));
205
+ }, cr = (e, t) => {
206
206
  const r = q(t, (n, o) => o !== void 0 && o !== e[n.key]);
207
207
  return Object.keys(r).length === 0 ? e : Object.freeze({ ...e, ...r });
208
- }, lr = (e, t, r, n) => q({ ...e, [t]: r }, (o, i) => i !== void 0 && !(o.key === t && i === n[t])), cr = (e) => JSON.stringify({ version: pe, settings: e }), it = (e, t, r) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : r * (e - t), mr = (e) => {
208
+ }, mr = (e, t, r, n) => q({ ...e, [t]: r }, (o, i) => i !== void 0 && !(o.key === t && i === n[t])), ur = (e) => JSON.stringify({ version: pe, settings: e }), at = (e, t, r) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : r * (e - t), fr = (e) => {
209
209
  const { sortMode: t, folderPlacement: r, readmePlacement: n } = e;
210
210
  if (t === "native" && r === "mixed" && n === "mixed") return;
211
211
  const o = (i, a) => {
@@ -221,59 +221,59 @@ const Ye = Object.freeze([
221
221
  if (t === "native") return 0;
222
222
  if (t === "asc") return o(i, a);
223
223
  if (t === "desc") return -o(i, a);
224
- const d = it(i.modifiedAt, a.modifiedAt, t === "oldest" ? 1 : -1);
224
+ const d = at(i.modifiedAt, a.modifiedAt, t === "oldest" ? 1 : -1);
225
225
  return d !== 0 ? d : o(i, a);
226
226
  };
227
- }, b = (1 + Math.sqrt(5)) / 2, ur = 100 / b ** 3, fr = 100 / b ** 4, Ee = 100 / b ** 2, at = 13, wr = 16, gr = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), se = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), dt = Object.freeze([89, 144, 233, 377]), xe = 44, hr = xe, pr = 24;
227
+ }, y = (1 + Math.sqrt(5)) / 2, wr = 100 / y ** 3, gr = 100 / y ** 4, Ee = 100 / y ** 2, dt = 13, hr = 16, pr = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), se = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), lt = Object.freeze([89, 144, 233, 377]), xe = 44, Er = xe, xr = 24;
228
228
  2 * se[3] + xe + se[0];
229
- const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
229
+ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
230
230
  if (!Number.isFinite(e) || e <= 0)
231
231
  throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${s(e)}`);
232
- }, ct = (e) => (lt(e), at * e), yr = (e) => ct(e) * b ** 2, Sr = 233, Or = 50, mt = 100 / b ** 3, kr = 100 - mt, Tr = dt[0], E = (e, t) => {
232
+ }, mt = (e) => (ct(e), dt * e), Or = (e) => mt(e) * y ** 2, kr = 233, Tr = 50, ut = 100 / y ** 3, Rr = 100 - ut, Ir = lt[0], x = (e, t) => {
233
233
  if (!Number.isFinite(t) || t < 0)
234
234
  throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${s(t)}`);
235
- }, ut = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
236
- if (E("trackInlineSize", e), E("gap", t), !Number.isFinite(r) || r <= 0)
235
+ }, ft = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
236
+ if (x("trackInlineSize", e), x("gap", t), !Number.isFinite(r) || r <= 0)
237
237
  throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${s(r)}`);
238
238
  if (!Number.isInteger(n) || n < 1)
239
239
  throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${s(n)}`);
240
240
  const o = Math.floor((e + t) / (r + t));
241
241
  return Math.min(n, Math.max(1, o));
242
- }, Rr = (e, t) => {
242
+ }, _r = (e, t) => {
243
243
  const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: i } = t;
244
244
  if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
245
- const d = ut(t);
245
+ const d = ft(t);
246
246
  if (e === null || d === e) return d;
247
247
  const l = Math.min(i, Math.max(1, e));
248
248
  if (d > l) {
249
- const f = (l + 1) * o + l * n + n / b;
250
- return r >= f ? d : l;
249
+ const w = (l + 1) * o + l * n + n / y;
250
+ return r >= w ? d : l;
251
251
  }
252
252
  return r >= l * o + (l - 1) * n ? l : d;
253
- }, Ir = (e, t) => {
253
+ }, $r = (e, t) => {
254
254
  if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
255
255
  throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${s(t)}`);
256
256
  return Array.from({ length: t }, (r, n) => [Math.floor(n * e / t), Math.floor((n + 1) * e / t)]);
257
- }, _r = (e, t, r) => {
258
- if (E("surfaceInlineSize", e), E("handlePixels", r), !Number.isFinite(t) || t <= 0)
257
+ }, vr = (e, t, r) => {
258
+ if (x("surfaceInlineSize", e), x("handlePixels", r), !Number.isFinite(t) || t <= 0)
259
259
  throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${s(t)}`);
260
260
  return e >= 2 * t + r ? "beside" : "stacked";
261
261
  }, W = (e, t, r) => Math.max(t, Math.min(e, r)), ie = (e, t, r, n) => {
262
262
  const o = (W(e, 0, r) + W(t, 0, r)) / 2;
263
263
  return W(o - n / 2, 0, r - n);
264
- }, $r = (e, t, r) => {
264
+ }, Pr = (e, t, r) => {
265
265
  for (const [n, o] of Object.entries(e))
266
266
  if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${s(o)}`);
267
- return E("marginBox.width", t.width), E("marginBox.height", t.height), E("viewport.width", r.width), E("viewport.height", r.height), {
267
+ return x("marginBox.width", t.width), x("marginBox.height", t.height), x("viewport.width", r.width), x("viewport.height", r.height), {
268
268
  left: ie(e.left, e.right, r.width, t.width),
269
269
  top: ie(e.top, e.bottom, r.height, t.height)
270
270
  };
271
- }, ft = 31536e3, wt = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, gt = (e) => {
272
- if (typeof e != "string" || !wt.test(e))
271
+ }, wt = 31536e3, gt = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, ht = (e) => {
272
+ if (typeof e != "string" || !gt.test(e))
273
273
  throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${s(e)}`);
274
- }, ae = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= Ee, A = (e, t) => typeof t == "string" && e.includes(t), ht = (e, t) => {
274
+ }, ae = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= Ee, A = (e, t) => typeof t == "string" && e.includes(t), pt = (e, t) => {
275
275
  if (e === null || typeof e != "object" || Array.isArray(e)) return {};
276
- const r = e, { treeExplorer: n, treeExplorerHidden: o, multiExplorer: i, multiExplorerHidden: a, style: d, align: l, measure: u, documentColors: f } = r;
276
+ const r = e, { treeExplorer: n, treeExplorerHidden: o, multiExplorer: i, multiExplorerHidden: a, style: d, align: l, measure: u, documentColors: w } = r;
277
277
  return {
278
278
  ...ae(n) ? { treeExplorer: n } : {},
279
279
  ...o === !0 ? { treeExplorerHidden: o } : {},
@@ -281,25 +281,25 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
281
281
  ...a === !0 ? { multiExplorerHidden: a } : {},
282
282
  ...A(t, d) ? { style: d } : {},
283
283
  ...A(D, l) ? { align: l } : {},
284
- ...A(Ue, u) ? { measure: u } : {},
285
- ...A(Fe, f) ? { documentColors: f } : {}
284
+ ...A(Ve, u) ? { measure: u } : {},
285
+ ...A(Ue, w) ? { documentColors: w } : {}
286
286
  };
287
- }, vr = (e, t) => {
287
+ }, Ar = (e, t) => {
288
288
  if (e !== null)
289
289
  for (const r of e.split(";")) {
290
290
  const n = r.indexOf("=");
291
291
  if (!(n < 0) && r.slice(0, n).trim() === t)
292
292
  return r.slice(n + 1).trim();
293
293
  }
294
- }, Pr = (e, t) => {
294
+ }, Dr = (e, t) => {
295
295
  if (e === void 0 || e === "") return {};
296
296
  try {
297
- return ht(JSON.parse(decodeURIComponent(e)), t);
297
+ return pt(JSON.parse(decodeURIComponent(e)), t);
298
298
  } catch {
299
299
  return {};
300
300
  }
301
- }, z = 100, pt = Math.floor(Ee * z) / z, Et = (e) => {
302
- const t = (r) => Math.min(pt, Math.max(1, Math.round(r * z)) / z);
301
+ }, M = 100, Et = Math.floor(Ee * M) / M, xt = (e) => {
302
+ const t = (r) => Math.min(Et, Math.max(1, Math.round(r * M)) / M);
303
303
  return encodeURIComponent(
304
304
  JSON.stringify({
305
305
  ...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
@@ -312,9 +312,9 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
312
312
  ...e.documentColors === void 0 ? {} : { documentColors: e.documentColors }
313
313
  })
314
314
  );
315
- }, Ar = (e, t, r) => `${e}=${Et(t)}; Path=/; Max-Age=${String(ft)}; SameSite=Lax${r ? "; Secure" : ""}`, de = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), xt = Object.freeze({ default: 12, min: 1, max: 64 }), bt = Object.freeze({ default: 4, min: 1, max: 6 }), yt = Object.freeze({ default: 500, min: 1, max: 1e4 }), St = Object.freeze({ default: 16, min: 1, max: 64 }), Ot = Object.freeze({ default: 16, min: 1, max: 64 }), kt = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), Tt = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), be = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, Rt = /^[a-z0-9][a-z0-9-]*$/u, It = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, le = (e, t) => {
315
+ }, Nr = (e, t, r) => `${e}=${xt(t)}; Path=/; Max-Age=${String(wt)}; SameSite=Lax${r ? "; Secure" : ""}`, be = ["ctrl", "shift"], bt = (e) => typeof e == "string" && be.includes(e), de = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), yt = Object.freeze({ default: 12, min: 1, max: 64 }), St = Object.freeze({ default: 4, min: 1, max: 6 }), Ot = Object.freeze({ default: 500, min: 1, max: 1e4 }), kt = Object.freeze({ default: 16, min: 1, max: 64 }), Tt = Object.freeze({ default: 16, min: 1, max: 64 }), Rt = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), It = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ye = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, _t = /^[a-z0-9][a-z0-9-]*$/u, $t = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, le = (e, t) => {
316
316
  if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${s(t)}`);
317
- if (!We(t))
317
+ if (!Ge(t))
318
318
  throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${s(t)}`);
319
319
  }, ce = Object.freeze(
320
320
  Object.keys({
@@ -328,6 +328,7 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
328
328
  revealDocument: !0,
329
329
  documentStyles: !0,
330
330
  defaultDocumentStyle: !0,
331
+ mermaidModifier: !0,
331
332
  iframeHosts: !0,
332
333
  appOrigins: !0,
333
334
  mediaDataPath: !0,
@@ -336,93 +337,93 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
336
337
  legacyTextEncoding: !0,
337
338
  spreadsheets: !0
338
339
  })
339
- ), x = (e, t, r) => {
340
+ ), b = (e, t, r) => {
340
341
  if (t === void 0) return [];
341
- if (!$(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${s(t)}`);
342
+ if (!v(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${s(t)}`);
342
343
  const n = Object.entries(t);
343
344
  for (const [o] of n)
344
345
  if (!r.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);
345
346
  return n.filter(([, o]) => o !== void 0);
346
- }, _t = (e) => {
347
+ }, vt = (e) => {
347
348
  const t = { ...de };
348
- for (const [r, n] of x("views", e, Object.keys(de))) t[r] = n;
349
+ for (const [r, n] of b("views", e, Object.keys(de))) t[r] = n;
349
350
  for (const [r, n] of Object.entries(t))
350
- if (typeof n != "string" || !be.test(n))
351
+ if (typeof n != "string" || !ye.test(n))
351
352
  throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(n)}`);
352
353
  return Object.freeze(t);
353
- }, $t = (e) => {
354
+ }, Pt = (e) => {
354
355
  if (e === void 0) return null;
355
- const t = x("documentIds", e, ["slug"]).find(([r]) => r === "slug")?.[1];
356
- if (typeof t != "string" || !be.test(t))
356
+ const t = b("documentIds", e, ["slug"]).find(([r]) => r === "slug")?.[1];
357
+ if (typeof t != "string" || !ye.test(t))
357
358
  throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(t)}`);
358
359
  return Object.freeze({ slug: t });
359
- }, S = (e, t, r) => {
360
+ }, O = (e, t, r) => {
360
361
  if (t === void 0) return r.default;
361
362
  if (typeof t != "number" || !Number.isInteger(t) || t < r.min || t > r.max)
362
363
  throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${s(t)}`);
363
364
  return t;
364
- }, vt = (e, t) => {
365
- const r = new Map(x("embeds", e, ["providers", "linkCards", "linkCardSize"]));
366
- if (r.size === 0) return Ce;
365
+ }, At = (e, t) => {
366
+ const r = new Map(b("embeds", e, ["providers", "linkCards", "linkCardSize"]));
367
+ if (r.size === 0) return Me;
367
368
  const n = r.has("providers") ? r.get("providers") : [];
368
369
  if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${s(n)}`);
369
370
  for (const d of n)
370
371
  if (!ze(d)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Le.join(", ")}; got ${s(d)}`);
371
372
  const o = r.has("linkCards") ? r.get("linkCards") : !1;
372
373
  if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${s(o)}`);
373
- const i = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ? Ke(t) : null };
374
+ const i = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ? Xe(t) : null };
374
375
  if (!r.has("linkCardSize")) return Object.freeze(i);
375
376
  const a = r.get("linkCardSize");
376
- if (!Me(a)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${je.join(", ")}; got ${s(a)}`);
377
+ if (!je(a)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Fe.join(", ")}; got ${s(a)}`);
377
378
  if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${s(a)} with linkCards ${s(o)}`);
378
379
  return Object.freeze({ ...i, linkCardSize: a });
379
- }, Pt = (e) => {
380
+ }, Dt = (e) => {
380
381
  if (e === void 0) return null;
381
382
  if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${s(e)}`);
382
383
  return fe(e);
383
- }, At = (e) => {
384
+ }, Nt = (e) => {
384
385
  if (e === void 0) return Object.freeze([]);
385
386
  if (!Array.isArray(e)) throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${s(e)}`);
386
387
  for (const [t, r] of e.entries()) {
387
388
  if (typeof r != "string") throw new TypeError(`[markdown-explorer] appOrigins[${String(t)}] must be a string; got ${s(r)}`);
388
- if (!He(r))
389
+ if (!Ke(r))
389
390
  throw new RangeError(`[markdown-explorer] appOrigins[${String(t)}] must be an origin as the browser writes it (scheme://host[:port], without a default port, path, query, fragment or user info); got ${s(r)}`);
390
391
  }
391
392
  return Object.freeze([...new Set(e)]);
392
- }, Dt = (e) => {
393
+ }, Ct = (e) => {
393
394
  if (e === void 0) return null;
394
395
  if (typeof e != "string") throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${s(e)}`);
395
- if (!Ge(e))
396
+ if (!He(e))
396
397
  throw new RangeError(
397
398
  `[markdown-explorer] mediaDataPath must be an absolute http: or https: URL as the browser writes it, of an origin and a path that starts with "/", has no trailing "/", uses only letters, digits and "._~-" in each segment and has no "." or ".." segment, without a query, fragment or user info; got ${s(e)}`
398
399
  );
399
400
  return e;
400
- }, Nt = (e) => {
401
+ }, Mt = (e) => {
401
402
  const t = new Map(
402
- x(
403
+ b(
403
404
  "defaultTreeSettings",
404
405
  e,
405
- k.map((n) => n.key)
406
+ T.map((n) => n.key)
406
407
  )
407
408
  );
408
409
  if (t.size === 0) return re;
409
410
  const r = { ...re };
410
- for (const n of k) {
411
+ for (const n of T) {
411
412
  if (!t.has(n.key)) continue;
412
413
  const o = t.get(n.key), i = n.values;
413
414
  if (!i.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(s).join(", ")}; got ${s(o)}`);
414
415
  r[n.key] = o;
415
416
  }
416
417
  return Object.freeze(r);
417
- }, Ct = (e) => {
418
+ }, zt = (e) => {
418
419
  if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
419
420
  for (const c of Object.keys(e))
420
421
  if (!ce.includes(c)) throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${ce.join(", ")}`);
421
422
  le("basePath", e.basePath), le("dataPath", e.dataPath);
422
- const t = _t(e.views);
423
+ const t = vt(e.views);
423
424
  if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
424
425
  throw new RangeError(`[markdown-explorer] the view slugs must differ; got tree ${s(t.tree)}, multi ${s(t.multi)} and single ${s(t.single)}`);
425
- const r = $t(e.documentIds);
426
+ const r = Pt(e.documentIds);
426
427
  if (r !== null && [t.tree, t.multi, t.single].includes(r.slug))
427
428
  throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${s(r.slug)}`);
428
429
  if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
@@ -431,13 +432,13 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
431
432
  if (c === t.tree || c === t.multi || c === t.single || c === r?.slug)
432
433
  throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${s(e.dataPath)}`);
433
434
  }
434
- gt(e.settingsCookie);
435
+ ht(e.settingsCookie);
435
436
  const n = e.iframeHosts ?? [];
436
437
  if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${s(n)}`);
437
- for (const [c, w] of n.entries())
438
- if (typeof w != "string" || !It.test(w))
439
- throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(w)}`);
440
- const o = Object.fromEntries(x("multiView", e.multiView, ["maxPanels", "columns"])), i = Object.fromEntries(x("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), a = Object.fromEntries(x("revealDocument", e.revealDocument, ["maxDepth"])), d = Object.fromEntries(x("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), l = e.documentStyles ?? Ve;
438
+ for (const [c, E] of n.entries())
439
+ if (typeof E != "string" || !$t.test(E))
440
+ throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(E)}`);
441
+ const o = Object.fromEntries(b("multiView", e.multiView, ["maxPanels", "columns"])), i = Object.fromEntries(b("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), a = Object.fromEntries(b("revealDocument", e.revealDocument, ["maxDepth"])), d = Object.fromEntries(b("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), l = e.documentStyles ?? Be;
441
442
  if (!Array.isArray(l) || l.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
442
443
  const u = /* @__PURE__ */ new Set();
443
444
  for (const c of l) {
@@ -446,12 +447,15 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
446
447
  if (u.has(c.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${s(c.name)} repeats`);
447
448
  u.add(c.name);
448
449
  }
449
- const f = e.defaultDocumentStyle === void 0 ? Be : e.defaultDocumentStyle;
450
- if (typeof f != "string") throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${s(f)}`);
451
- if (!u.has(f)) {
450
+ const w = e.defaultDocumentStyle === void 0 ? We : e.defaultDocumentStyle;
451
+ if (typeof w != "string") throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${s(w)}`);
452
+ if (!u.has(w)) {
452
453
  const c = e.defaultDocumentStyle === void 0 ? " (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)" : "";
453
- throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...u].map(s).join(", ")}); got ${s(f)}${c}`);
454
+ throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...u].map(s).join(", ")}); got ${s(w)}${c}`);
454
455
  }
456
+ const f = e.mermaidModifier;
457
+ if (f !== void 0 && !bt(f))
458
+ throw new RangeError(`[markdown-explorer] mermaidModifier must be one of ${be.map(s).join(", ")}; got ${s(f)}`);
455
459
  return Object.freeze({
456
460
  basePath: e.basePath,
457
461
  dataPath: e.dataPath,
@@ -459,30 +463,31 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
459
463
  views: t,
460
464
  documentIds: r,
461
465
  multiView: Object.freeze({
462
- maxPanels: S("multiView.maxPanels", o.maxPanels, xt),
463
- columns: S("multiView.columns", o.columns, bt)
466
+ maxPanels: O("multiView.maxPanels", o.maxPanels, yt),
467
+ columns: O("multiView.columns", o.columns, St)
464
468
  }),
465
469
  expandAll: Object.freeze({
466
- maxFolders: S("expandAll.maxFolders", i.maxFolders, yt),
467
- maxDepth: S("expandAll.maxDepth", i.maxDepth, St)
470
+ maxFolders: O("expandAll.maxFolders", i.maxFolders, Ot),
471
+ maxDepth: O("expandAll.maxDepth", i.maxDepth, kt)
468
472
  }),
469
- revealDocument: Object.freeze({ maxDepth: S("revealDocument.maxDepth", a.maxDepth, Ot) }),
473
+ revealDocument: Object.freeze({ maxDepth: O("revealDocument.maxDepth", a.maxDepth, Tt) }),
470
474
  documentStyles: Object.freeze(l.map((c) => Object.freeze({ name: c.name, className: c.className }))),
471
- defaultDocumentStyle: f,
475
+ defaultDocumentStyle: w,
476
+ mermaidModifier: f,
472
477
  iframeHosts: Object.freeze([...new Set(n)]),
473
- appOrigins: At(e.appOrigins),
474
- mediaDataPath: Dt(e.mediaDataPath),
475
- embeds: vt(e.embeds, e.dataPath),
476
- defaultTreeSettings: Nt(e.defaultTreeSettings),
477
- legacyTextEncoding: Pt(e.legacyTextEncoding),
478
+ appOrigins: Nt(e.appOrigins),
479
+ mediaDataPath: Ct(e.mediaDataPath),
480
+ embeds: At(e.embeds, e.dataPath),
481
+ defaultTreeSettings: Mt(e.defaultTreeSettings),
482
+ legacyTextEncoding: Dt(e.legacyTextEncoding),
478
483
  spreadsheets: Object.freeze({
479
- maxBytes: S("spreadsheets.maxBytes", d.maxBytes, kt),
480
- maxWorkbookBytes: S("spreadsheets.maxWorkbookBytes", d.maxWorkbookBytes, Tt)
484
+ maxBytes: O("spreadsheets.maxBytes", d.maxBytes, Rt),
485
+ maxWorkbookBytes: O("spreadsheets.maxWorkbookBytes", d.maxWorkbookBytes, It)
481
486
  })
482
487
  });
483
- }, Dr = (e) => {
488
+ }, Cr = (e) => {
484
489
  const t = e.embeds;
485
- if (!$(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${s(t)}`);
490
+ if (!v(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${s(t)}`);
486
491
  if (Object.hasOwn(t, "linkCards"))
487
492
  throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${s(t.linkCards)})`);
488
493
  const r = e.legacyTextEncoding;
@@ -492,9 +497,9 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
492
497
  if (n !== null && typeof n != "string")
493
498
  throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${s(n)}`);
494
499
  const o = e.documentIds;
495
- if (o !== null && !$(o))
500
+ if (o !== null && !v(o))
496
501
  throw new TypeError(`[markdown-explorer] config.documentIds must be the segment defineExplorerConfig resolved, or null; got ${s(o)}`);
497
- const { linkCardEndpoint: i, ...a } = t, d = Ct({
502
+ const { linkCardEndpoint: i, ...a } = t, d = zt({
498
503
  ...e,
499
504
  embeds: { ...a, linkCards: i !== null },
500
505
  legacyTextEncoding: r === null ? void 0 : r,
@@ -506,10 +511,10 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
506
511
  if (d.legacyTextEncoding !== r)
507
512
  throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${s(d.legacyTextEncoding)} (the written name of the encoding it names); got ${s(r)}`);
508
513
  const l = e;
509
- for (const [u, f] of Object.entries(d)) {
510
- const c = H(l[u], f, u);
511
- if (c !== null)
512
- throw c.kind === "extra" ? new RangeError(`[markdown-explorer] config.${c.path} is not a key of what defineExplorerConfig resolves; got ${s(c.given)} there`) : new RangeError(`[markdown-explorer] config.${c.path} must be what defineExplorerConfig resolves; got ${s(c.given)} where it resolves ${s(c.resolved)}`);
514
+ for (const [u, w] of Object.entries(d)) {
515
+ const f = H(l[u], w, u);
516
+ if (f !== null)
517
+ throw f.kind === "extra" ? new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${s(f.given)} there`) : new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${s(f.given)} where it resolves ${s(f.resolved)}`);
513
518
  }
514
519
  return d;
515
520
  }, H = (e, t, r) => {
@@ -523,24 +528,24 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
523
528
  }
524
529
  return null;
525
530
  }
526
- if (!($(t) && $(e))) return { kind: "value", path: r, given: e, resolved: t };
531
+ if (!(v(t) && v(e))) return { kind: "value", path: r, given: e, resolved: t };
527
532
  for (const o of Object.keys(t)) {
528
533
  const i = H(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${r}.${o}`);
529
534
  if (i !== null) return i;
530
535
  }
531
536
  const n = Object.keys(e).find((o) => !Object.hasOwn(t, o));
532
537
  return n === void 0 ? null : { kind: "extra", path: `${r}.${n}`, given: e[n] };
533
- }, zt = (e) => typeof e == "string" && Rt.test(e), Nr = (e, t) => {
538
+ }, Lt = (e) => typeof e == "string" && _t.test(e), Mr = (e, t) => {
534
539
  if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${s(e)}`);
535
540
  if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${s(t)}`);
536
541
  const r = /* @__PURE__ */ new Set();
537
542
  for (const [n, o] of t.entries()) {
538
- if (!zt(o)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${s(o)}`);
543
+ if (!Lt(o)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${s(o)}`);
539
544
  if (r.has(o)) throw new RangeError(`[markdown-explorer] source ids must be unique; ${s(o)} repeats at sourceIds[${String(n)}]`);
540
545
  r.add(o);
541
546
  }
542
547
  return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
543
- }, Cr = (e) => e.documentStyles.map((t) => t.name), zr = (e) => Object.freeze({
548
+ }, zr = (e) => e.documentStyles.map((t) => t.name), Lr = (e) => Object.freeze({
544
549
  origins: e.appOrigins,
545
550
  resources: Object.freeze([e.dataPath]),
546
551
  links: Object.freeze([e.basePath, e.dataPath]),
@@ -558,35 +563,35 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
558
563
  width: "width",
559
564
  maxWidth: "maxWidth",
560
565
  markup: "markup"
561
- }), ye = "true", Se = "true", L = "/", me = ".data", Oe = 256, ke = /^\d+(?:\.\d+)?$/u, K = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Te = Object.freeze(["showToc", "showStyle", "showAlign"]), ue = (e) => {
566
+ }), Se = "true", Oe = "true", z = "/", me = ".data", ke = 256, Te = /^\d+(?:\.\d+)?$/u, K = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Re = Object.freeze(["showToc", "showStyle", "showAlign"]), ue = (e) => {
562
567
  const t = encodeURIComponent(e.replaceAll("%", "%25"));
563
568
  return t.endsWith(me) ? `${t.slice(0, -me.length)}%2Edata` : t;
564
- }, Lt = (e) => e.replaceAll("%25", "%"), Re = (e) => {
569
+ }, jt = (e) => e.replaceAll("%25", "%"), Ie = (e) => {
565
570
  const { sourceIds: t } = e;
566
571
  if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
567
572
  return t;
568
- }, Mt = (e, t, r) => {
573
+ }, Ft = (e, t, r) => {
569
574
  const n = r.getAll(m.source);
570
575
  if (n.length === 0) return t;
571
576
  const [o] = n;
572
577
  return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
573
- }, Ie = (e, t) => {
578
+ }, _e = (e, t) => {
574
579
  const r = t.get(m.style), n = t.get(m.align);
575
580
  return {
576
581
  ...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
577
582
  ...n !== null && D.includes(n) ? { align: n } : {}
578
583
  };
579
- }, _e = (e) => Number.isFinite(e) && e >= 0 && e <= Oe && ke.test(String(e)), $e = (e) => {
580
- const t = e.get(m.padding), r = t !== null && ke.test(t) ? Number(t) : Number.NaN, n = e.get(m.width), o = e.get(m.maxWidth);
584
+ }, $e = (e) => Number.isFinite(e) && e >= 0 && e <= ke && Te.test(String(e)), ve = (e) => {
585
+ const t = e.get(m.padding), r = t !== null && Te.test(t) ? Number(t) : Number.NaN, n = e.get(m.width), o = e.get(m.maxWidth);
581
586
  return {
582
587
  ...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
583
588
  ...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
584
589
  ...e.get(m.showAlign) === "false" ? { showAlign: !1 } : {},
585
- ..._e(r) ? { padding: r } : {},
590
+ ...$e(r) ? { padding: r } : {},
586
591
  ...n !== null && K.test(n) ? { width: n } : {},
587
592
  ...o !== null && K.test(o) ? { maxWidth: o } : {}
588
593
  };
589
- }, jt = (e, t) => [...new Set(t.filter(_))].slice(0, e.multiView.maxPanels), Ft = (e, t, r, n) => {
594
+ }, Ut = (e, t) => [...new Set(t.filter($))].slice(0, e.multiView.maxPanels), Vt = (e, t, r, n) => {
590
595
  for (const i of t) Y(i);
591
596
  if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);
592
597
  if (t.length > e.multiView.maxPanels) throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);
@@ -595,167 +600,167 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
595
600
  const o = n.find((i) => !t.includes(i));
596
601
  if (o !== void 0) throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${s(o)}`);
597
602
  }, Y = (e) => {
598
- if (!_(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
603
+ if (!$(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
599
604
  return e;
600
- }, Ut = (e) => {
601
- if (!Vt(Y(e))) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${s(e)}`);
605
+ }, Bt = (e) => {
606
+ if (!Wt(Y(e))) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${s(e)}`);
602
607
  return e;
603
- }, Vt = (e) => _(e) && !e.endsWith(L), Bt = (e, t) => {
608
+ }, Wt = (e) => $(e) && !e.endsWith(z), Gt = (e, t) => {
604
609
  if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
605
610
  throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((r) => s(r.name)).join(", ")}); got ${s(t.style)}`);
606
611
  if (t.align !== void 0 && !D.includes(t.align))
607
612
  throw new RangeError(`[markdown-explorer] overrides.align must be one of ${D.join(", ")}; got ${s(t.align)}`);
608
- }, Wt = (e) => {
609
- for (const t of Te)
613
+ }, Ht = (e) => {
614
+ for (const t of Re)
610
615
  if (e[t] !== void 0 && typeof e[t] != "boolean") throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${s(e[t])}`);
611
- if (e.padding !== void 0 && !_e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(Oe)} px in plain decimal digits; got ${s(e.padding)}`);
616
+ if (e.padding !== void 0 && !$e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${s(e.padding)}`);
612
617
  for (const t of ["width", "maxWidth"]) {
613
618
  const r = e[t];
614
619
  if (r !== void 0 && !K.test(r)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${s(r)}`);
615
620
  }
616
- }, ve = (e, t) => {
617
- if (t.view === "document-id") return Gt(e, t);
621
+ }, Pe = (e, t) => {
622
+ if (t.view === "document-id") return Kt(e, t);
618
623
  const r = new URLSearchParams();
619
624
  let n = `${e.basePath}/${e.views[t.view]}`;
620
625
  if (t.view === "multi") {
621
626
  const i = t.docs ?? [], a = t.maximized ?? null, d = t.markup ?? [];
622
- Ft(e, i, a, d);
627
+ Vt(e, i, a, d);
623
628
  for (const l of i) r.append(m.doc, l);
624
629
  a !== null && r.set(m.maximized, a);
625
630
  for (const l of i) d.includes(l) && r.append(m.markup, l);
626
631
  } else {
627
632
  const i = t.doc ?? null, a = t.view === "tree" ? t.folder ?? null : null;
628
633
  if (i !== null && a !== null) throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");
629
- i !== null && (n += `/${ue(Ut(i))}`), a !== null && (n += `/${ue(`${Y(a)}${L}`)}`);
634
+ i !== null && (n += `/${ue(Bt(i))}`), a !== null && (n += `/${ue(`${Y(a)}${z}`)}`);
630
635
  }
631
636
  if (t.source !== void 0) {
632
- const i = Re(e);
637
+ const i = Ie(e);
633
638
  if (!i.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${s(t.source)}; expected one of ${i.join(", ")}`);
634
639
  t.source !== i[0] && r.set(m.source, t.source);
635
640
  }
636
- t.view !== "multi" && t.overrides !== void 0 && Pe(e, r, t.overrides);
641
+ t.view !== "multi" && t.overrides !== void 0 && Ae(e, r, t.overrides);
637
642
  const o = t.view !== "multi" && (t.doc !== void 0 && t.doc !== null || t.view === "tree" && t.folder !== void 0 && t.folder !== null);
638
643
  if (t.view === "tree" && t.maximized === !0) {
639
644
  if (!o) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");
640
- r.set(m.maximized, Se);
645
+ r.set(m.maximized, Oe);
641
646
  }
642
647
  if (t.view !== "multi" && t.markup === !0) {
643
648
  if (!o) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");
644
- r.set(m.markup, ye);
649
+ r.set(m.markup, Se);
645
650
  }
646
- return t.view === "single" && t.embed !== void 0 && Ae(r, t.embed), De(n, r);
647
- }, Gt = (e, t) => {
651
+ return t.view === "single" && t.embed !== void 0 && De(r, t.embed), Ne(n, r);
652
+ }, Kt = (e, t) => {
648
653
  if (e.documentIds === null) throw new TypeError("[markdown-explorer] an ID link needs documentIds in defineExplorerConfig");
649
- if (!Xe(t.id)) throw new RangeError(`[markdown-explorer] not a canonical document ID: ${s(t.id)}`);
654
+ if (!qe(t.id)) throw new RangeError(`[markdown-explorer] not a canonical document ID: ${s(t.id)}`);
650
655
  if (t.opens !== void 0 && t.opens !== "single") throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${s(t.opens)}`);
651
656
  if (t.embed !== void 0 && t.opens !== "single") throw new RangeError('[markdown-explorer] embed needs opens: "single" (only the single view takes embedding options)');
652
657
  const r = new URLSearchParams();
653
- t.overrides !== void 0 && Pe(e, r, t.overrides), t.embed !== void 0 && Ae(r, t.embed);
658
+ t.overrides !== void 0 && Ae(e, r, t.overrides), t.embed !== void 0 && De(r, t.embed);
654
659
  const n = t.opens === "single" ? `/${e.views.single}` : "";
655
- return De(`${e.basePath}/${e.documentIds.slug}/${t.id}${n}`, r);
656
- }, Pe = (e, t, r) => {
657
- Bt(e, r), r.style !== void 0 && t.set(m.style, r.style), r.align !== void 0 && t.set(m.align, r.align);
658
- }, Ae = (e, t) => {
659
- Wt(t);
660
- for (const r of Te) t[r] === !1 && e.set(m[r], "false");
661
- t.padding !== void 0 && e.set(m.padding, String(t.padding)), t.width !== void 0 && e.set(m.width, t.width), t.maxWidth !== void 0 && e.set(m.maxWidth, t.maxWidth);
660
+ return Ne(`${e.basePath}/${e.documentIds.slug}/${t.id}${n}`, r);
661
+ }, Ae = (e, t, r) => {
662
+ Gt(e, r), r.style !== void 0 && t.set(m.style, r.style), r.align !== void 0 && t.set(m.align, r.align);
662
663
  }, De = (e, t) => {
664
+ Ht(t);
665
+ for (const r of Re) t[r] === !1 && e.set(m[r], "false");
666
+ t.padding !== void 0 && e.set(m.padding, String(t.padding)), t.width !== void 0 && e.set(m.width, t.width), t.maxWidth !== void 0 && e.set(m.maxWidth, t.maxWidth);
667
+ }, Ne = (e, t) => {
663
668
  const r = t.toString();
664
669
  return r === "" ? e : `${e}?${r}`;
665
- }, Ht = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), Lr = (e, t, r) => {
666
- const n = Re(e), [o] = n;
670
+ }, Xt = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), jr = (e, t, r) => {
671
+ const n = Ie(e), [o] = n;
667
672
  if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
668
- const i = Mt(n, o, r), a = i === null ? o : i, d = (p) => ({ kind: "redirect", href: ve(e, p), location: p }), l = () => d({ view: "tree", source: a, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 });
673
+ const i = Ft(n, o, r), a = i === null ? o : i, d = (p) => ({ kind: "redirect", href: Pe(e, p), location: p }), l = () => d({ view: "tree", source: a, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 });
669
674
  if (t === void 0 || t === "") return l();
670
- const u = t.indexOf("/"), f = u < 0 ? t : t.slice(0, u), c = u < 0 ? null : t.slice(u + 1);
671
- if (e.documentIds !== null && f === e.documentIds.slug) return Kt(e, c, r, o, l);
672
- const w = Ht(e, f);
673
- if (w === void 0) return l();
674
- if (w === "multi") {
675
- const p = r.getAll(m.doc), O = jt(e, p), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && O.includes(F) ? F : null, V = r.getAll(m.markup), P = O.filter((I) => V.includes(I)), Ne = P.length === V.length && P.every((I, B) => I === V[B]);
676
- return c === null && i !== null && O.length === p.length && O.every((I, B) => I === p[B]) && (j.length === 0 || U !== null) && Ne ? { kind: "location", location: { view: "multi", source: a, docs: O, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: O, maximized: U, markup: P });
675
+ const u = t.indexOf("/"), w = u < 0 ? t : t.slice(0, u), f = u < 0 ? null : t.slice(u + 1);
676
+ if (e.documentIds !== null && w === e.documentIds.slug) return qt(e, f, r, o, l);
677
+ const c = Xt(e, w);
678
+ if (c === void 0) return l();
679
+ if (c === "multi") {
680
+ const p = r.getAll(m.doc), k = Ut(e, p), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && k.includes(F) ? F : null, V = r.getAll(m.markup), P = k.filter((_) => V.includes(_)), Ce = P.length === V.length && P.every((_, B) => _ === V[B]);
681
+ return f === null && i !== null && k.length === p.length && k.every((_, B) => _ === p[B]) && (j.length === 0 || U !== null) && Ce ? { kind: "location", location: { view: "multi", source: a, docs: k, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: k, maximized: U, markup: P });
677
682
  }
678
- const v = c === null ? null : Lt(c), g = v?.endsWith(L) === !0 ? v.slice(0, -L.length) : null, h = v !== null && g === null ? v : null;
679
- if (h !== null && !_(h) || g !== null && !_(g)) return l();
680
- const T = Ie(e, r), R = (h !== null || g !== null) && r.get(m.markup) === ye;
681
- if (w === "single") {
682
- if (g !== null) return d({ view: "tree", source: a, doc: null, folder: g, overrides: T, markup: R, maximized: !1 });
683
+ const E = f === null ? null : jt(f), g = E?.endsWith(z) === !0 ? E.slice(0, -z.length) : null, h = E !== null && g === null ? E : null;
684
+ if (h !== null && !$(h) || g !== null && !$(g)) return l();
685
+ const R = _e(e, r), I = (h !== null || g !== null) && r.get(m.markup) === Se;
686
+ if (c === "single") {
687
+ if (g !== null) return d({ view: "tree", source: a, doc: null, folder: g, overrides: R, markup: I, maximized: !1 });
683
688
  if (h === null) return l();
684
- const p = $e(r);
685
- return i === null ? d({ view: w, source: a, doc: h, overrides: T, embed: p, markup: R }) : { kind: "location", location: { view: w, source: a, doc: h, overrides: T, embed: p, markup: R } };
689
+ const p = ve(r);
690
+ return i === null ? d({ view: c, source: a, doc: h, overrides: R, embed: p, markup: I }) : { kind: "location", location: { view: c, source: a, doc: h, overrides: R, embed: p, markup: I } };
686
691
  }
687
- const J = (h !== null || g !== null) && r.get(m.maximized) === Se;
688
- return i === null ? d({ view: w, source: a, doc: h, folder: g, overrides: T, markup: R, maximized: J }) : { kind: "location", location: { view: w, source: a, doc: h, folder: g, overrides: T, markup: R, maximized: J } };
689
- }, Kt = (e, t, r, n, o) => {
692
+ const J = (h !== null || g !== null) && r.get(m.maximized) === Oe;
693
+ return i === null ? d({ view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J }) : { kind: "location", location: { view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J } };
694
+ }, qt = (e, t, r, n, o) => {
690
695
  if (t === null || t === "") return o();
691
- const i = t.indexOf("/"), a = qe(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = Ie(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
692
- return d === e.views.single ? { kind: "document-id", id: a, opens: { view: "single", overrides: l, embed: $e(r) }, location: u } : d !== null && a !== null ? { kind: "redirect", href: ve(e, { view: "document-id", id: a, overrides: l }), location: u } : { kind: "document-id", id: a, opens: { view: "tree", overrides: l }, location: u };
693
- }, Mr = (e, t, r) => e.view === "single" ? { view: "single", source: r, doc: t, overrides: e.overrides, embed: e.embed } : { view: "tree", source: r, doc: t, overrides: e.overrides };
696
+ const i = t.indexOf("/"), a = Ye(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = _e(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
697
+ return d === e.views.single ? { kind: "document-id", id: a, opens: { view: "single", overrides: l, embed: ve(r) }, location: u } : d !== null && a !== null ? { kind: "redirect", href: Pe(e, { view: "document-id", id: a, overrides: l }), location: u } : { kind: "document-id", id: a, opens: { view: "tree", overrides: l }, location: u };
698
+ }, Fr = (e, t, r) => e.view === "single" ? { view: "single", source: r, doc: t, overrides: e.overrides, embed: e.embed } : { view: "tree", source: r, doc: t, overrides: e.overrides };
694
699
  export {
695
- Ar as $,
696
- ir as A,
697
- or as B,
698
- hr as C,
699
- yr as D,
700
- kr as E,
701
- pr as F,
702
- ct as G,
700
+ Nr as $,
701
+ dr as A,
702
+ ir as B,
703
+ Er as C,
704
+ Or as D,
705
+ Rr as E,
706
+ xr as F,
707
+ mt as G,
703
708
  Ee as H,
704
- ur as I,
705
- fr as J,
706
- wr as K,
707
- Or as L,
708
- $r as M,
709
+ wr as I,
710
+ gr as J,
711
+ hr as K,
712
+ Tr as L,
713
+ Pr as M,
709
714
  C as N,
710
- Tr as O,
711
- Er as P,
715
+ Ir as O,
716
+ br as P,
712
717
  se as Q,
713
- b as R,
714
- Sr as S,
715
- Qt as T,
716
- lr as U,
717
- sr as V,
718
- dr as W,
719
- cr as X,
718
+ y as R,
719
+ kr as S,
720
+ tr as T,
721
+ mr as U,
722
+ ar as V,
723
+ cr as W,
724
+ ur as X,
720
725
  ne as Y,
721
- ar as Z,
722
- Et as _,
726
+ lr as Z,
727
+ xt as _,
723
728
  le as a,
724
- br as a0,
729
+ Sr as a0,
725
730
  re as a1,
726
731
  de as a2,
727
- St as a3,
728
- yt as a4,
729
- at as a5,
730
- bt as a6,
731
- xt as a7,
732
- Ot as a8,
733
- kt as a9,
734
- Tt as aa,
735
- Ct as ab,
736
- rr as b,
737
- jt as c,
738
- er as d,
739
- ve as e,
740
- Cr as f,
741
- Dr as g,
742
- Lr as h,
743
- zt as i,
744
- Mr as j,
745
- Vt as k,
732
+ kt as a3,
733
+ Ot as a4,
734
+ dt as a5,
735
+ St as a6,
736
+ yt as a7,
737
+ Tt as a8,
738
+ Rt as a9,
739
+ It as aa,
740
+ zt as ab,
741
+ or as b,
742
+ Ut as c,
743
+ rr as d,
744
+ Pe as e,
745
+ zr as f,
746
+ Cr as g,
747
+ jr as h,
748
+ Lt as i,
749
+ Fr as j,
750
+ Wt as k,
746
751
  fe as l,
747
- mt as m,
748
- gr as n,
749
- zr as o,
750
- Pr as p,
751
- _r as q,
752
- vr as r,
753
- Ir as s,
754
- tr as t,
755
- Rr as u,
756
- xr as v,
757
- Nr as w,
758
- nr as x,
752
+ ut as m,
753
+ pr as n,
754
+ Lr as o,
755
+ Dr as p,
756
+ vr as q,
757
+ Ar as r,
758
+ $r as s,
759
+ nr as t,
760
+ _r as u,
761
+ yr as v,
762
+ Mr as w,
763
+ sr as x,
759
764
  xe as y,
760
- mr as z
765
+ fr as z
761
766
  };