@aiquants/markdown-explorer 0.35.0 → 0.36.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.
- package/CHANGELOG.md +93 -0
- package/README.md +31 -2
- package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
- package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
- package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
- package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
- package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
- package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
- package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
- package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
- package/dist/TreeLayout-DsSKW_Qj.js +103 -0
- package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
- package/dist/core/config.d.cts +6 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/contracts.d.cts +21 -0
- package/dist/core/contracts.d.ts +21 -0
- package/dist/core/dataRoute.d.cts +5 -1
- package/dist/core/dataRoute.d.ts +5 -1
- package/dist/core/documentId.d.cts +6 -0
- package/dist/core/documentId.d.ts +6 -0
- package/dist/core/labels.d.cts +10 -0
- package/dist/core/labels.d.ts +10 -0
- package/dist/core/location.d.cts +21 -0
- package/dist/core/location.d.ts +21 -0
- package/dist/explorerCore-B3RGmMG6.js +1083 -0
- package/dist/explorerCore-CUkyKtm8.cjs +1 -0
- package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
- package/dist/index-lpL7GltU.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +38 -33
- package/dist/location-Dh6K-y7w.js +761 -0
- package/dist/location-DrOP6t1F.cjs +1 -0
- package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
- package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
- package/dist/ownUrls-BTPGNhBt.cjs +1 -0
- package/dist/ownUrls-DD0cSCsF.js +409 -0
- package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
- package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
- package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
- package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +3 -3
- package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
- package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +19 -0
- package/dist/server/ports.d.ts +19 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +6 -6
- package/dist/serverBrowser.cjs +1 -1
- package/dist/serverBrowser.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +4 -4
- package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
- package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +80 -2
- package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
- package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/security.md +23 -2
- package/docs/behavior/url-contract.md +26 -0
- package/package.json +2 -2
- package/dist/TreeLayout-AxLw-36S.js +0 -103
- package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
- package/dist/explorerCore-DLpDuSev.js +0 -998
- package/dist/explorerCore-DYrxS9ez.cjs +0 -1
- package/dist/index-LQWQfpAf.cjs +0 -18
- package/dist/location--KvTA0Ri.js +0 -726
- package/dist/location-D8DyDkuA.cjs +0 -1
- package/dist/ownUrls-B259RGgd.cjs +0 -1
- package/dist/ownUrls-Dh5g6ZJi.js +0 -370
|
@@ -0,0 +1,761 @@
|
|
|
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([
|
|
6
|
+
"UTF-8",
|
|
7
|
+
"IBM866",
|
|
8
|
+
"ISO-8859-2",
|
|
9
|
+
"ISO-8859-3",
|
|
10
|
+
"ISO-8859-4",
|
|
11
|
+
"ISO-8859-5",
|
|
12
|
+
"ISO-8859-6",
|
|
13
|
+
"ISO-8859-7",
|
|
14
|
+
"ISO-8859-8",
|
|
15
|
+
"ISO-8859-8-I",
|
|
16
|
+
"ISO-8859-10",
|
|
17
|
+
"ISO-8859-13",
|
|
18
|
+
"ISO-8859-14",
|
|
19
|
+
"ISO-8859-15",
|
|
20
|
+
"ISO-8859-16",
|
|
21
|
+
"KOI8-R",
|
|
22
|
+
"KOI8-U",
|
|
23
|
+
"macintosh",
|
|
24
|
+
"windows-874",
|
|
25
|
+
"windows-1250",
|
|
26
|
+
"windows-1251",
|
|
27
|
+
"windows-1252",
|
|
28
|
+
"windows-1253",
|
|
29
|
+
"windows-1254",
|
|
30
|
+
"windows-1255",
|
|
31
|
+
"windows-1256",
|
|
32
|
+
"windows-1257",
|
|
33
|
+
"windows-1258",
|
|
34
|
+
"x-mac-cyrillic",
|
|
35
|
+
"GBK",
|
|
36
|
+
"gb18030",
|
|
37
|
+
"Big5",
|
|
38
|
+
"EUC-JP",
|
|
39
|
+
"ISO-2022-JP",
|
|
40
|
+
"Shift_JIS",
|
|
41
|
+
"EUC-KR",
|
|
42
|
+
"replacement",
|
|
43
|
+
"UTF-16BE",
|
|
44
|
+
"UTF-16LE",
|
|
45
|
+
"x-user-defined"
|
|
46
|
+
]), Je = new Map(Ye.map((e) => [e.toLowerCase(), e])), N = "UTF-8", Z = Object.freeze([
|
|
47
|
+
Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: N }),
|
|
48
|
+
Object.freeze({ bytes: Object.freeze([255, 254]), encoding: "UTF-16LE" }),
|
|
49
|
+
Object.freeze({ bytes: Object.freeze([254, 255]), encoding: "UTF-16BE" })
|
|
50
|
+
]), Ze = /* @__PURE__ */ new Map([
|
|
51
|
+
[N, "is read before any legacy encoding"],
|
|
52
|
+
["UTF-16LE", "is read only by its byte order mark"],
|
|
53
|
+
["UTF-16BE", "is read only by its byte order mark"],
|
|
54
|
+
["ISO-2022-JP", "writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],
|
|
55
|
+
["x-user-defined", "is no text encoding (it maps bytes to private-use characters)"]
|
|
56
|
+
]), fe = (e) => {
|
|
57
|
+
let t;
|
|
58
|
+
try {
|
|
59
|
+
t = new TextDecoder(e).encoding;
|
|
60
|
+
} catch (o) {
|
|
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
|
+
}
|
|
63
|
+
const r = Qe(t), n = Ze.get(r);
|
|
64
|
+
if (n !== void 0) throw new RangeError(`[markdown-explorer] legacyTextEncoding ${s(e)} names ${r}, which cannot be the legacy encoding: it ${n}`);
|
|
65
|
+
return r;
|
|
66
|
+
}, Qe = (e) => {
|
|
67
|
+
const t = Je.get(e);
|
|
68
|
+
if (t === void 0) throw new RangeError(`[markdown-explorer] TextDecoder answered ${s(e)}, which is no encoding of the WHATWG Encoding Standard`);
|
|
69
|
+
return t;
|
|
70
|
+
}, M = (e, t, r) => {
|
|
71
|
+
const n = r === null ? null : fe(r), o = Z.find(({ bytes: a }) => a.every((d, l) => e[l] === d));
|
|
72
|
+
if (o !== void 0) return { body: e.subarray(o.bytes.length), encodings: [o.encoding] };
|
|
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
|
+
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) => {
|
|
76
|
+
try {
|
|
77
|
+
return new TextDecoder(e, { fatal: !0, ignoreBOM: !0 }).decode(t, { stream: !r });
|
|
78
|
+
} catch (n) {
|
|
79
|
+
if (n instanceof TypeError) return null;
|
|
80
|
+
throw n;
|
|
81
|
+
}
|
|
82
|
+
}, er = (e, t, r) => {
|
|
83
|
+
const n = X(M(e, t, r), t);
|
|
84
|
+
return n === null ? null : n.text;
|
|
85
|
+
}, X = ({ body: e, encodings: t }, r) => {
|
|
86
|
+
for (const n of t) {
|
|
87
|
+
const o = et(n, e, r);
|
|
88
|
+
if (o !== null) return { encoding: n, text: o };
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}, tr = (e, t, r) => {
|
|
92
|
+
const n = M(e, t, r), o = X(n, t);
|
|
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);
|
|
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) => {
|
|
98
|
+
const t = e.lastIndexOf("."), r = ee.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
|
|
99
|
+
return r < 0 ? ee.length : r;
|
|
100
|
+
}, nt = (e, t) => {
|
|
101
|
+
const r = +!Q.test(e.name) - +!Q.test(t.name);
|
|
102
|
+
if (r !== 0) return r;
|
|
103
|
+
const n = te(e.name) - te(t.name);
|
|
104
|
+
if (n !== 0) return n;
|
|
105
|
+
const o = C.compare(e.name, t.name);
|
|
106
|
+
return o !== 0 ? o : C.compare(e.path, t.path);
|
|
107
|
+
}, nr = (e) => {
|
|
108
|
+
let t = null;
|
|
109
|
+
for (const r of e)
|
|
110
|
+
G(r) && (t === null || nt(r, t) < 0) && (t = r);
|
|
111
|
+
return t === null ? null : t.path;
|
|
112
|
+
}, re = Object.freeze({
|
|
113
|
+
sortMode: "native",
|
|
114
|
+
folderPlacement: "mixed",
|
|
115
|
+
readmePlacement: "mixed",
|
|
116
|
+
selectionMode: "single",
|
|
117
|
+
doubleClickAction: "recursive",
|
|
118
|
+
expandIconSize: 8,
|
|
119
|
+
alwaysExpanded: !1,
|
|
120
|
+
revealDocument: !1,
|
|
121
|
+
showFolderReadme: !0,
|
|
122
|
+
removeRootIndent: !1,
|
|
123
|
+
lines: !0,
|
|
124
|
+
expandIcons: !0,
|
|
125
|
+
directoryIcons: !0,
|
|
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({
|
|
128
|
+
native: (e) => e.sortNative,
|
|
129
|
+
asc: (e) => e.sortAscending,
|
|
130
|
+
desc: (e) => e.sortDescending,
|
|
131
|
+
oldest: (e) => e.sortOldest,
|
|
132
|
+
newest: (e) => e.sortNewest
|
|
133
|
+
}), k = Object.freeze([
|
|
134
|
+
{
|
|
135
|
+
key: "sortMode",
|
|
136
|
+
labelKey: "settingSortMode",
|
|
137
|
+
values: ["native", "asc", "desc", "oldest", "newest"],
|
|
138
|
+
formatValue: (e, t) => ot[t](e),
|
|
139
|
+
requiresTreeView: !1
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "folderPlacement",
|
|
143
|
+
labelKey: "settingFolderPlacement",
|
|
144
|
+
values: ["mixed", "first", "last"],
|
|
145
|
+
formatValue: (e, t) => t === "mixed" ? e.folderPlacementMixed : t === "first" ? e.folderPlacementFirst : e.folderPlacementLast,
|
|
146
|
+
requiresTreeView: !1
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: "readmePlacement",
|
|
150
|
+
labelKey: "settingReadmePlacement",
|
|
151
|
+
values: ["mixed", "first", "last"],
|
|
152
|
+
formatValue: (e, t) => t === "mixed" ? e.readmePlacementMixed : t === "first" ? e.readmePlacementFirst : e.readmePlacementLast,
|
|
153
|
+
requiresTreeView: !1
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: "selectionMode",
|
|
157
|
+
labelKey: "settingSelectionMode",
|
|
158
|
+
values: ["single", "multiple", "none"],
|
|
159
|
+
formatValue: (e, t) => t === "single" ? e.selectionSingle : t === "multiple" ? e.selectionMultiple : e.selectionNone,
|
|
160
|
+
requiresTreeView: !0
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: "doubleClickAction",
|
|
164
|
+
labelKey: "settingDoubleClick",
|
|
165
|
+
values: ["recursive", "toggle"],
|
|
166
|
+
formatValue: (e, t) => t === "recursive" ? e.doubleClickRecursive : e.doubleClickToggle,
|
|
167
|
+
requiresTreeView: !1
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "expandIconSize",
|
|
171
|
+
labelKey: "settingExpandIconSize",
|
|
172
|
+
values: [8, 13, 5],
|
|
173
|
+
formatValue: (e, t) => e.expandIconSizeValue(t),
|
|
174
|
+
requiresTreeView: !1
|
|
175
|
+
},
|
|
176
|
+
y("alwaysExpanded", "settingAlwaysExpanded"),
|
|
177
|
+
y("revealDocument", "settingRevealDocument"),
|
|
178
|
+
{
|
|
179
|
+
key: "showFolderReadme",
|
|
180
|
+
labelKey: "settingShowFolderReadme",
|
|
181
|
+
values: we,
|
|
182
|
+
formatValue: ge,
|
|
183
|
+
requiresTreeView: !0
|
|
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);
|
|
192
|
+
if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
|
|
193
|
+
return t;
|
|
194
|
+
}, sr = (e, t) => {
|
|
195
|
+
const r = he(t).values, n = r[(r.indexOf(e[t]) + 1) % r.length];
|
|
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) => {
|
|
198
|
+
if (!Object.hasOwn(e, oe)) return e;
|
|
199
|
+
const { [oe]: t, ...r } = e;
|
|
200
|
+
return Object.hasOwn(r, "folderPlacement") || typeof t != "boolean" ? r : { ...r, folderPlacement: t ? "first" : "mixed" };
|
|
201
|
+
}, ar = (e) => {
|
|
202
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return ne;
|
|
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) => {
|
|
206
|
+
const r = q(t, (n, o) => o !== void 0 && o !== e[n.key]);
|
|
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) => {
|
|
209
|
+
const { sortMode: t, folderPlacement: r, readmePlacement: n } = e;
|
|
210
|
+
if (t === "native" && r === "mixed" && n === "mixed") return;
|
|
211
|
+
const o = (i, a) => {
|
|
212
|
+
const d = C.compare(i.name, a.name);
|
|
213
|
+
return d !== 0 ? d : C.compare(i.path, a.path);
|
|
214
|
+
};
|
|
215
|
+
return (i, a) => {
|
|
216
|
+
if (r !== "mixed" && i.type !== a.type) return i.type === "directory" == (r === "first") ? -1 : 1;
|
|
217
|
+
if (n !== "mixed") {
|
|
218
|
+
const l = G(i);
|
|
219
|
+
if (l !== G(a)) return l === (n === "first") ? -1 : 1;
|
|
220
|
+
}
|
|
221
|
+
if (t === "native") return 0;
|
|
222
|
+
if (t === "asc") return o(i, a);
|
|
223
|
+
if (t === "desc") return -o(i, a);
|
|
224
|
+
const d = it(i.modifiedAt, a.modifiedAt, t === "oldest" ? 1 : -1);
|
|
225
|
+
return d !== 0 ? d : o(i, a);
|
|
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;
|
|
228
|
+
2 * se[3] + xe + se[0];
|
|
229
|
+
const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
230
|
+
if (!Number.isFinite(e) || e <= 0)
|
|
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) => {
|
|
233
|
+
if (!Number.isFinite(t) || t < 0)
|
|
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)
|
|
237
|
+
throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${s(r)}`);
|
|
238
|
+
if (!Number.isInteger(n) || n < 1)
|
|
239
|
+
throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${s(n)}`);
|
|
240
|
+
const o = Math.floor((e + t) / (r + t));
|
|
241
|
+
return Math.min(n, Math.max(1, o));
|
|
242
|
+
}, Rr = (e, t) => {
|
|
243
|
+
const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: i } = t;
|
|
244
|
+
if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
|
|
245
|
+
const d = ut(t);
|
|
246
|
+
if (e === null || d === e) return d;
|
|
247
|
+
const l = Math.min(i, Math.max(1, e));
|
|
248
|
+
if (d > l) {
|
|
249
|
+
const f = (l + 1) * o + l * n + n / b;
|
|
250
|
+
return r >= f ? d : l;
|
|
251
|
+
}
|
|
252
|
+
return r >= l * o + (l - 1) * n ? l : d;
|
|
253
|
+
}, Ir = (e, t) => {
|
|
254
|
+
if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
|
|
255
|
+
throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${s(t)}`);
|
|
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)
|
|
259
|
+
throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${s(t)}`);
|
|
260
|
+
return e >= 2 * t + r ? "beside" : "stacked";
|
|
261
|
+
}, W = (e, t, r) => Math.max(t, Math.min(e, r)), ie = (e, t, r, n) => {
|
|
262
|
+
const o = (W(e, 0, r) + W(t, 0, r)) / 2;
|
|
263
|
+
return W(o - n / 2, 0, r - n);
|
|
264
|
+
}, $r = (e, t, r) => {
|
|
265
|
+
for (const [n, o] of Object.entries(e))
|
|
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), {
|
|
268
|
+
left: ie(e.left, e.right, r.width, t.width),
|
|
269
|
+
top: ie(e.top, e.bottom, r.height, t.height)
|
|
270
|
+
};
|
|
271
|
+
}, ft = 31536e3, wt = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, gt = (e) => {
|
|
272
|
+
if (typeof e != "string" || !wt.test(e))
|
|
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) => {
|
|
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;
|
|
277
|
+
return {
|
|
278
|
+
...ae(n) ? { treeExplorer: n } : {},
|
|
279
|
+
...o === !0 ? { treeExplorerHidden: o } : {},
|
|
280
|
+
...ae(i) ? { multiExplorer: i } : {},
|
|
281
|
+
...a === !0 ? { multiExplorerHidden: a } : {},
|
|
282
|
+
...A(t, d) ? { style: d } : {},
|
|
283
|
+
...A(D, l) ? { align: l } : {},
|
|
284
|
+
...A(Ue, u) ? { measure: u } : {},
|
|
285
|
+
...A(Fe, f) ? { documentColors: f } : {}
|
|
286
|
+
};
|
|
287
|
+
}, vr = (e, t) => {
|
|
288
|
+
if (e !== null)
|
|
289
|
+
for (const r of e.split(";")) {
|
|
290
|
+
const n = r.indexOf("=");
|
|
291
|
+
if (!(n < 0) && r.slice(0, n).trim() === t)
|
|
292
|
+
return r.slice(n + 1).trim();
|
|
293
|
+
}
|
|
294
|
+
}, Pr = (e, t) => {
|
|
295
|
+
if (e === void 0 || e === "") return {};
|
|
296
|
+
try {
|
|
297
|
+
return ht(JSON.parse(decodeURIComponent(e)), t);
|
|
298
|
+
} catch {
|
|
299
|
+
return {};
|
|
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);
|
|
303
|
+
return encodeURIComponent(
|
|
304
|
+
JSON.stringify({
|
|
305
|
+
...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
|
|
306
|
+
...e.treeExplorerHidden === !0 ? { treeExplorerHidden: !0 } : {},
|
|
307
|
+
...e.multiExplorer === void 0 ? {} : { multiExplorer: t(e.multiExplorer) },
|
|
308
|
+
...e.multiExplorerHidden === !0 ? { multiExplorerHidden: !0 } : {},
|
|
309
|
+
...e.style === void 0 ? {} : { style: e.style },
|
|
310
|
+
...e.align === void 0 ? {} : { align: e.align },
|
|
311
|
+
...e.measure === void 0 ? {} : { measure: e.measure },
|
|
312
|
+
...e.documentColors === void 0 ? {} : { documentColors: e.documentColors }
|
|
313
|
+
})
|
|
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) => {
|
|
316
|
+
if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${s(t)}`);
|
|
317
|
+
if (!We(t))
|
|
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
|
+
}, ce = Object.freeze(
|
|
320
|
+
Object.keys({
|
|
321
|
+
basePath: !0,
|
|
322
|
+
dataPath: !0,
|
|
323
|
+
settingsCookie: !0,
|
|
324
|
+
views: !0,
|
|
325
|
+
documentIds: !0,
|
|
326
|
+
multiView: !0,
|
|
327
|
+
expandAll: !0,
|
|
328
|
+
revealDocument: !0,
|
|
329
|
+
documentStyles: !0,
|
|
330
|
+
defaultDocumentStyle: !0,
|
|
331
|
+
iframeHosts: !0,
|
|
332
|
+
appOrigins: !0,
|
|
333
|
+
mediaDataPath: !0,
|
|
334
|
+
embeds: !0,
|
|
335
|
+
defaultTreeSettings: !0,
|
|
336
|
+
legacyTextEncoding: !0,
|
|
337
|
+
spreadsheets: !0
|
|
338
|
+
})
|
|
339
|
+
), x = (e, t, r) => {
|
|
340
|
+
if (t === void 0) return [];
|
|
341
|
+
if (!$(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${s(t)}`);
|
|
342
|
+
const n = Object.entries(t);
|
|
343
|
+
for (const [o] of n)
|
|
344
|
+
if (!r.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);
|
|
345
|
+
return n.filter(([, o]) => o !== void 0);
|
|
346
|
+
}, _t = (e) => {
|
|
347
|
+
const t = { ...de };
|
|
348
|
+
for (const [r, n] of x("views", e, Object.keys(de))) t[r] = n;
|
|
349
|
+
for (const [r, n] of Object.entries(t))
|
|
350
|
+
if (typeof n != "string" || !be.test(n))
|
|
351
|
+
throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(n)}`);
|
|
352
|
+
return Object.freeze(t);
|
|
353
|
+
}, $t = (e) => {
|
|
354
|
+
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))
|
|
357
|
+
throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(t)}`);
|
|
358
|
+
return Object.freeze({ slug: t });
|
|
359
|
+
}, S = (e, t, r) => {
|
|
360
|
+
if (t === void 0) return r.default;
|
|
361
|
+
if (typeof t != "number" || !Number.isInteger(t) || t < r.min || t > r.max)
|
|
362
|
+
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${s(t)}`);
|
|
363
|
+
return t;
|
|
364
|
+
}, vt = (e, t) => {
|
|
365
|
+
const r = new Map(x("embeds", e, ["providers", "linkCards", "linkCardSize"]));
|
|
366
|
+
if (r.size === 0) return Ce;
|
|
367
|
+
const n = r.has("providers") ? r.get("providers") : [];
|
|
368
|
+
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${s(n)}`);
|
|
369
|
+
for (const d of n)
|
|
370
|
+
if (!ze(d)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Le.join(", ")}; got ${s(d)}`);
|
|
371
|
+
const o = r.has("linkCards") ? r.get("linkCards") : !1;
|
|
372
|
+
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
|
+
if (!r.has("linkCardSize")) return Object.freeze(i);
|
|
375
|
+
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 (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${s(a)} with linkCards ${s(o)}`);
|
|
378
|
+
return Object.freeze({ ...i, linkCardSize: a });
|
|
379
|
+
}, Pt = (e) => {
|
|
380
|
+
if (e === void 0) return null;
|
|
381
|
+
if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${s(e)}`);
|
|
382
|
+
return fe(e);
|
|
383
|
+
}, At = (e) => {
|
|
384
|
+
if (e === void 0) return Object.freeze([]);
|
|
385
|
+
if (!Array.isArray(e)) throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${s(e)}`);
|
|
386
|
+
for (const [t, r] of e.entries()) {
|
|
387
|
+
if (typeof r != "string") throw new TypeError(`[markdown-explorer] appOrigins[${String(t)}] must be a string; got ${s(r)}`);
|
|
388
|
+
if (!He(r))
|
|
389
|
+
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
|
+
return Object.freeze([...new Set(e)]);
|
|
392
|
+
}, Dt = (e) => {
|
|
393
|
+
if (e === void 0) return null;
|
|
394
|
+
if (typeof e != "string") throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${s(e)}`);
|
|
395
|
+
if (!Ge(e))
|
|
396
|
+
throw new RangeError(
|
|
397
|
+
`[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
|
+
return e;
|
|
400
|
+
}, Nt = (e) => {
|
|
401
|
+
const t = new Map(
|
|
402
|
+
x(
|
|
403
|
+
"defaultTreeSettings",
|
|
404
|
+
e,
|
|
405
|
+
k.map((n) => n.key)
|
|
406
|
+
)
|
|
407
|
+
);
|
|
408
|
+
if (t.size === 0) return re;
|
|
409
|
+
const r = { ...re };
|
|
410
|
+
for (const n of k) {
|
|
411
|
+
if (!t.has(n.key)) continue;
|
|
412
|
+
const o = t.get(n.key), i = n.values;
|
|
413
|
+
if (!i.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(s).join(", ")}; got ${s(o)}`);
|
|
414
|
+
r[n.key] = o;
|
|
415
|
+
}
|
|
416
|
+
return Object.freeze(r);
|
|
417
|
+
}, Ct = (e) => {
|
|
418
|
+
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
|
|
419
|
+
for (const c of Object.keys(e))
|
|
420
|
+
if (!ce.includes(c)) throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${ce.join(", ")}`);
|
|
421
|
+
le("basePath", e.basePath), le("dataPath", e.dataPath);
|
|
422
|
+
const t = _t(e.views);
|
|
423
|
+
if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
|
|
424
|
+
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
|
+
if (r !== null && [t.tree, t.multi, t.single].includes(r.slug))
|
|
427
|
+
throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${s(r.slug)}`);
|
|
428
|
+
if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
|
|
429
|
+
if (e.dataPath.startsWith(`${e.basePath}/`)) {
|
|
430
|
+
const c = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
|
|
431
|
+
if (c === t.tree || c === t.multi || c === t.single || c === r?.slug)
|
|
432
|
+
throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${s(e.dataPath)}`);
|
|
433
|
+
}
|
|
434
|
+
gt(e.settingsCookie);
|
|
435
|
+
const n = e.iframeHosts ?? [];
|
|
436
|
+
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;
|
|
441
|
+
if (!Array.isArray(l) || l.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
442
|
+
const u = /* @__PURE__ */ new Set();
|
|
443
|
+
for (const c of l) {
|
|
444
|
+
if (c === null || typeof c != "object" || typeof c.name != "string" || c.name.trim() === "" || typeof c.className != "string")
|
|
445
|
+
throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");
|
|
446
|
+
if (u.has(c.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${s(c.name)} repeats`);
|
|
447
|
+
u.add(c.name);
|
|
448
|
+
}
|
|
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)) {
|
|
452
|
+
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
|
+
}
|
|
455
|
+
return Object.freeze({
|
|
456
|
+
basePath: e.basePath,
|
|
457
|
+
dataPath: e.dataPath,
|
|
458
|
+
settingsCookie: e.settingsCookie,
|
|
459
|
+
views: t,
|
|
460
|
+
documentIds: r,
|
|
461
|
+
multiView: Object.freeze({
|
|
462
|
+
maxPanels: S("multiView.maxPanels", o.maxPanels, xt),
|
|
463
|
+
columns: S("multiView.columns", o.columns, bt)
|
|
464
|
+
}),
|
|
465
|
+
expandAll: Object.freeze({
|
|
466
|
+
maxFolders: S("expandAll.maxFolders", i.maxFolders, yt),
|
|
467
|
+
maxDepth: S("expandAll.maxDepth", i.maxDepth, St)
|
|
468
|
+
}),
|
|
469
|
+
revealDocument: Object.freeze({ maxDepth: S("revealDocument.maxDepth", a.maxDepth, Ot) }),
|
|
470
|
+
documentStyles: Object.freeze(l.map((c) => Object.freeze({ name: c.name, className: c.className }))),
|
|
471
|
+
defaultDocumentStyle: f,
|
|
472
|
+
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
|
+
spreadsheets: Object.freeze({
|
|
479
|
+
maxBytes: S("spreadsheets.maxBytes", d.maxBytes, kt),
|
|
480
|
+
maxWorkbookBytes: S("spreadsheets.maxWorkbookBytes", d.maxWorkbookBytes, Tt)
|
|
481
|
+
})
|
|
482
|
+
});
|
|
483
|
+
}, Dr = (e) => {
|
|
484
|
+
const t = e.embeds;
|
|
485
|
+
if (!$(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${s(t)}`);
|
|
486
|
+
if (Object.hasOwn(t, "linkCards"))
|
|
487
|
+
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
|
+
const r = e.legacyTextEncoding;
|
|
489
|
+
if (r !== null && typeof r != "string")
|
|
490
|
+
throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${s(r)}`);
|
|
491
|
+
const n = e.mediaDataPath;
|
|
492
|
+
if (n !== null && typeof n != "string")
|
|
493
|
+
throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${s(n)}`);
|
|
494
|
+
const o = e.documentIds;
|
|
495
|
+
if (o !== null && !$(o))
|
|
496
|
+
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({
|
|
498
|
+
...e,
|
|
499
|
+
embeds: { ...a, linkCards: i !== null },
|
|
500
|
+
legacyTextEncoding: r === null ? void 0 : r,
|
|
501
|
+
mediaDataPath: n === null ? void 0 : n,
|
|
502
|
+
documentIds: o === null ? void 0 : o
|
|
503
|
+
});
|
|
504
|
+
if (d.embeds.linkCardEndpoint !== i)
|
|
505
|
+
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${s(d.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${s(i)}`);
|
|
506
|
+
if (d.legacyTextEncoding !== r)
|
|
507
|
+
throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${s(d.legacyTextEncoding)} (the written name of the encoding it names); got ${s(r)}`);
|
|
508
|
+
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)}`);
|
|
513
|
+
}
|
|
514
|
+
return d;
|
|
515
|
+
}, H = (e, t, r) => {
|
|
516
|
+
if (Object.is(e, t)) return null;
|
|
517
|
+
if (Array.isArray(t)) {
|
|
518
|
+
if (!Array.isArray(e)) return { kind: "value", path: r, given: e, resolved: t };
|
|
519
|
+
if (e.length !== t.length) return { kind: "value", path: `${r}.length`, given: e.length, resolved: t.length };
|
|
520
|
+
for (const [o, i] of t.entries()) {
|
|
521
|
+
const a = H(e[o], i, `${r}[${String(o)}]`);
|
|
522
|
+
if (a !== null) return a;
|
|
523
|
+
}
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
if (!($(t) && $(e))) return { kind: "value", path: r, given: e, resolved: t };
|
|
527
|
+
for (const o of Object.keys(t)) {
|
|
528
|
+
const i = H(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${r}.${o}`);
|
|
529
|
+
if (i !== null) return i;
|
|
530
|
+
}
|
|
531
|
+
const n = Object.keys(e).find((o) => !Object.hasOwn(t, o));
|
|
532
|
+
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) => {
|
|
534
|
+
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${s(e)}`);
|
|
535
|
+
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${s(t)}`);
|
|
536
|
+
const r = /* @__PURE__ */ new Set();
|
|
537
|
+
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)}`);
|
|
539
|
+
if (r.has(o)) throw new RangeError(`[markdown-explorer] source ids must be unique; ${s(o)} repeats at sourceIds[${String(n)}]`);
|
|
540
|
+
r.add(o);
|
|
541
|
+
}
|
|
542
|
+
return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
|
|
543
|
+
}, Cr = (e) => e.documentStyles.map((t) => t.name), zr = (e) => Object.freeze({
|
|
544
|
+
origins: e.appOrigins,
|
|
545
|
+
resources: Object.freeze([e.dataPath]),
|
|
546
|
+
links: Object.freeze([e.basePath, e.dataPath]),
|
|
547
|
+
media: Object.freeze(e.mediaDataPath === null ? [] : [e.mediaDataPath])
|
|
548
|
+
}), m = Object.freeze({
|
|
549
|
+
source: "source",
|
|
550
|
+
doc: "doc",
|
|
551
|
+
maximized: "maximized",
|
|
552
|
+
style: "style",
|
|
553
|
+
align: "align",
|
|
554
|
+
showToc: "showToc",
|
|
555
|
+
showStyle: "showStyle",
|
|
556
|
+
showAlign: "showAlign",
|
|
557
|
+
padding: "padding",
|
|
558
|
+
width: "width",
|
|
559
|
+
maxWidth: "maxWidth",
|
|
560
|
+
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) => {
|
|
562
|
+
const t = encodeURIComponent(e.replaceAll("%", "%25"));
|
|
563
|
+
return t.endsWith(me) ? `${t.slice(0, -me.length)}%2Edata` : t;
|
|
564
|
+
}, Lt = (e) => e.replaceAll("%25", "%"), Re = (e) => {
|
|
565
|
+
const { sourceIds: t } = e;
|
|
566
|
+
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
|
+
return t;
|
|
568
|
+
}, Mt = (e, t, r) => {
|
|
569
|
+
const n = r.getAll(m.source);
|
|
570
|
+
if (n.length === 0) return t;
|
|
571
|
+
const [o] = n;
|
|
572
|
+
return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
|
|
573
|
+
}, Ie = (e, t) => {
|
|
574
|
+
const r = t.get(m.style), n = t.get(m.align);
|
|
575
|
+
return {
|
|
576
|
+
...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
|
|
577
|
+
...n !== null && D.includes(n) ? { align: n } : {}
|
|
578
|
+
};
|
|
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);
|
|
581
|
+
return {
|
|
582
|
+
...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
|
|
583
|
+
...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
|
|
584
|
+
...e.get(m.showAlign) === "false" ? { showAlign: !1 } : {},
|
|
585
|
+
..._e(r) ? { padding: r } : {},
|
|
586
|
+
...n !== null && K.test(n) ? { width: n } : {},
|
|
587
|
+
...o !== null && K.test(o) ? { maxWidth: o } : {}
|
|
588
|
+
};
|
|
589
|
+
}, jt = (e, t) => [...new Set(t.filter(_))].slice(0, e.multiView.maxPanels), Ft = (e, t, r, n) => {
|
|
590
|
+
for (const i of t) Y(i);
|
|
591
|
+
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
|
+
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)}`);
|
|
593
|
+
if (r !== null && !t.includes(r)) throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${s(r)}`);
|
|
594
|
+
if (new Set(n).size !== n.length) throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(n.length)} with repeats`);
|
|
595
|
+
const o = n.find((i) => !t.includes(i));
|
|
596
|
+
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
|
+
}, Y = (e) => {
|
|
598
|
+
if (!_(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
|
|
599
|
+
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)}`);
|
|
602
|
+
return e;
|
|
603
|
+
}, Vt = (e) => _(e) && !e.endsWith(L), Bt = (e, t) => {
|
|
604
|
+
if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
|
|
605
|
+
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
|
+
if (t.align !== void 0 && !D.includes(t.align))
|
|
607
|
+
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)
|
|
610
|
+
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)}`);
|
|
612
|
+
for (const t of ["width", "maxWidth"]) {
|
|
613
|
+
const r = e[t];
|
|
614
|
+
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
|
+
}
|
|
616
|
+
}, ve = (e, t) => {
|
|
617
|
+
if (t.view === "document-id") return Gt(e, t);
|
|
618
|
+
const r = new URLSearchParams();
|
|
619
|
+
let n = `${e.basePath}/${e.views[t.view]}`;
|
|
620
|
+
if (t.view === "multi") {
|
|
621
|
+
const i = t.docs ?? [], a = t.maximized ?? null, d = t.markup ?? [];
|
|
622
|
+
Ft(e, i, a, d);
|
|
623
|
+
for (const l of i) r.append(m.doc, l);
|
|
624
|
+
a !== null && r.set(m.maximized, a);
|
|
625
|
+
for (const l of i) d.includes(l) && r.append(m.markup, l);
|
|
626
|
+
} else {
|
|
627
|
+
const i = t.doc ?? null, a = t.view === "tree" ? t.folder ?? null : null;
|
|
628
|
+
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}`)}`);
|
|
630
|
+
}
|
|
631
|
+
if (t.source !== void 0) {
|
|
632
|
+
const i = Re(e);
|
|
633
|
+
if (!i.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${s(t.source)}; expected one of ${i.join(", ")}`);
|
|
634
|
+
t.source !== i[0] && r.set(m.source, t.source);
|
|
635
|
+
}
|
|
636
|
+
t.view !== "multi" && t.overrides !== void 0 && Pe(e, r, t.overrides);
|
|
637
|
+
const o = t.view !== "multi" && (t.doc !== void 0 && t.doc !== null || t.view === "tree" && t.folder !== void 0 && t.folder !== null);
|
|
638
|
+
if (t.view === "tree" && t.maximized === !0) {
|
|
639
|
+
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);
|
|
641
|
+
}
|
|
642
|
+
if (t.view !== "multi" && t.markup === !0) {
|
|
643
|
+
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);
|
|
645
|
+
}
|
|
646
|
+
return t.view === "single" && t.embed !== void 0 && Ae(r, t.embed), De(n, r);
|
|
647
|
+
}, Gt = (e, t) => {
|
|
648
|
+
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)}`);
|
|
650
|
+
if (t.opens !== void 0 && t.opens !== "single") throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${s(t.opens)}`);
|
|
651
|
+
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
|
+
const r = new URLSearchParams();
|
|
653
|
+
t.overrides !== void 0 && Pe(e, r, t.overrides), t.embed !== void 0 && Ae(r, t.embed);
|
|
654
|
+
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);
|
|
662
|
+
}, De = (e, t) => {
|
|
663
|
+
const r = t.toString();
|
|
664
|
+
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;
|
|
667
|
+
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 });
|
|
669
|
+
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 });
|
|
677
|
+
}
|
|
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
|
+
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 } };
|
|
686
|
+
}
|
|
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) => {
|
|
690
|
+
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 };
|
|
694
|
+
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,
|
|
703
|
+
Ee as H,
|
|
704
|
+
ur as I,
|
|
705
|
+
fr as J,
|
|
706
|
+
wr as K,
|
|
707
|
+
Or as L,
|
|
708
|
+
$r as M,
|
|
709
|
+
C as N,
|
|
710
|
+
Tr as O,
|
|
711
|
+
Er as P,
|
|
712
|
+
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,
|
|
720
|
+
ne as Y,
|
|
721
|
+
ar as Z,
|
|
722
|
+
Et as _,
|
|
723
|
+
le as a,
|
|
724
|
+
br as a0,
|
|
725
|
+
re as a1,
|
|
726
|
+
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,
|
|
746
|
+
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,
|
|
759
|
+
xe as y,
|
|
760
|
+
mr as z
|
|
761
|
+
};
|