@aiquants/markdown-explorer 0.22.0 → 0.24.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 (58) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/README.md +63 -17
  3. package/dist/{EditSurface-BesNcSQj.cjs → EditSurface-CRc4g0Qa.cjs} +5 -5
  4. package/dist/{EditSurface-DNjI8pV3.js → EditSurface-CcWEczj3.js} +333 -336
  5. package/dist/{ExplorerSplit-GUdzpDPg.js → ExplorerSplit-97SeIAOS.js} +81 -81
  6. package/dist/{ExplorerSplit-B4oNvydP.cjs → ExplorerSplit-ByxxXlgs.cjs} +1 -1
  7. package/dist/{MultiLayout-DtKChQ_s.cjs → MultiLayout-B_yMVDt_.cjs} +1 -1
  8. package/dist/{MultiLayout-BJ-s6AaD.js → MultiLayout-CnbuAlxd.js} +4 -4
  9. package/dist/{NativeScrollBar-D10fsk-7.js → NativeScrollBar-BXdaM3EA.js} +1 -1
  10. package/dist/{NativeScrollBar-DJKlPWvD.cjs → NativeScrollBar-D4a7fBOS.cjs} +1 -1
  11. package/dist/{TreeLayout-DQT5p2vI.js → TreeLayout-BIQBKAkV.js} +3 -3
  12. package/dist/{TreeLayout-C1mTmoPp.cjs → TreeLayout-C6QDpEBS.cjs} +1 -1
  13. package/dist/core/config.d.cts +13 -0
  14. package/dist/core/config.d.ts +13 -0
  15. package/dist/core/contracts.d.cts +29 -4
  16. package/dist/core/contracts.d.ts +29 -4
  17. package/dist/core/labels.d.cts +21 -0
  18. package/dist/core/labels.d.ts +21 -0
  19. package/dist/core/textEncoding.d.cts +4 -0
  20. package/dist/core/textEncoding.d.ts +4 -0
  21. package/dist/{dataRoute-CObbjNxG.js → dataRoute-BEvesOvN.js} +108 -99
  22. package/dist/dataRoute-Cv7fgCW7.cjs +1 -0
  23. package/dist/index-BwTVYkTR.cjs +13 -0
  24. package/dist/index-CeZDCyEl.js +4088 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +24 -23
  29. package/dist/location-CasigkBk.cjs +1 -0
  30. package/dist/location-gXXmC7CQ.js +643 -0
  31. package/dist/{merge-DauzoA2W.js → merge-DqjUgcV_.js} +1 -1
  32. package/dist/{merge-CTkzzHtn.cjs → merge-QLktbpZY.cjs} +1 -1
  33. package/dist/{sanitizePolicy-gEXeavb-.cjs → sanitizePolicy-CZwOaJ92.cjs} +1 -1
  34. package/dist/{sanitizePolicy-BWQtWhsL.js → sanitizePolicy-gVKBhabq.js} +1 -1
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +1 -1
  37. package/dist/server/fileSystemSource.d.cts +1 -0
  38. package/dist/server/fileSystemSource.d.ts +1 -0
  39. package/dist/server/ports.d.cts +9 -1
  40. package/dist/server/ports.d.ts +9 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -0
  43. package/dist/server.d.ts +1 -0
  44. package/dist/server.js +852 -834
  45. package/dist/styles/markdown-explorer.css +1 -1
  46. package/dist/{useSplitPersistence-Cc4tDxB4.js → useSplitPersistence-BPNjvuJi.js} +1 -1
  47. package/dist/{useSplitPersistence-Ba-v64n-.cjs → useSplitPersistence-Bmpb2prR.cjs} +1 -1
  48. package/docs/behavior/dom-hooks.md +13 -6
  49. package/docs/behavior/layout.md +22 -8
  50. package/docs/behavior/localization.md +9 -5
  51. package/docs/behavior/security.md +6 -4
  52. package/docs/behavior/url-contract.md +2 -2
  53. package/package.json +5 -5
  54. package/dist/dataRoute-BONacTPi.cjs +0 -1
  55. package/dist/index-0pnuyLUO.js +0 -3662
  56. package/dist/index-T98wklgM.cjs +0 -13
  57. package/dist/location-B-m9scLf.js +0 -499
  58. package/dist/location-BVEN_Ihk.cjs +0 -1
@@ -1,5 +1,5 @@
1
- const de = 4096;
2
- const v = Object.freeze([
1
+ const he = 4096;
2
+ const P = Object.freeze([
3
3
  ".env*",
4
4
  "*.env",
5
5
  "*.env.*",
@@ -57,80 +57,80 @@ const v = Object.freeze([
57
57
  "*.tfvars.json",
58
58
  ".*_history",
59
59
  "fish_history"
60
- ]), w = /[\u0000-\u001f\u007f]/u, P = /\p{Cs}/u, pe = (e) => {
60
+ ]), w = /[\u0000-\u001f\u007f]/u, L = /\p{Cs}/u, be = (e) => {
61
61
  const t = e.split("/").filter((n) => n !== "").at(-1);
62
62
  return t === void 0 ? e : t;
63
- }, R = (e) => e.length > 0 && e.length <= 4096 && !P.test(e) && !w.test(e) && !e.includes("\\"), A = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), L = /(?:%[0-9A-Fa-f]{2})+/gu, D = new TextDecoder("utf-8"), k = /[/\\]/u, j = (e) => e.replace(
64
- L,
63
+ }, R = (e) => e.length > 0 && e.length <= 4096 && !L.test(e) && !w.test(e) && !e.includes("\\"), h = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), k = /(?:%[0-9A-Fa-f]{2})+/gu, D = new TextDecoder("utf-8"), j = /[/\\]/u, $ = (e) => e.replace(
64
+ k,
65
65
  (t) => D.decode(
66
66
  Uint8Array.from(
67
67
  t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
68
  )
69
69
  )
70
- ), $ = (e) => {
70
+ ), I = (e) => {
71
71
  const t = [e];
72
72
  let n = e;
73
73
  for (let r = 0; r < 3 && n.includes("%"); r += 1) {
74
- const s = j(n);
74
+ const s = $(n);
75
75
  if (s === n) break;
76
76
  t.push(s), n = s;
77
77
  }
78
- return t.map(A);
79
- }, I = (e) => {
78
+ return t.map(h);
79
+ }, C = (e) => {
80
80
  if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
81
  throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
- const t = A(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
82
+ const t = h(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
83
  return new RegExp(`^${t}$`, "su");
84
84
  }, y = (e) => {
85
85
  if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
86
- const t = e.map(I), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => s !== "" && $(s).some((i) => n(i) || i.split(k).some(n));
86
+ const t = e.map(C), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => s !== "" && I(s).some((i) => n(i) || i.split(j).some(n));
87
87
  return {
88
88
  deniesPath: (s) => s.split("/").some(r),
89
89
  deniesName: r
90
90
  };
91
- }, C = y(v), z = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ee = (e) => e === void 0 ? C : e === !1 ? z : y(e), ye = (e, t) => y(e).deniesPath(t), h = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), X = Object.freeze(["video", "audio", "pdf"]), H = Object.freeze(["info", "warning", "danger"]), V = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), me = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ge = Object.freeze(["http:", "https:", "mailto:"]), b = 1024, F = /^[a-z0-9-]{1,64}$/u, M = "https://relative.invalid/", g = 64, d = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, K = (e) => d(h, e), G = (e) => d(U, e), W = (e) => d(X, e), Re = (e) => d(H, e), Y = (e) => d(V, e), _ = (e) => typeof e == "string" && F.test(e), Ae = (e, t) => {
91
+ }, z = y(P), X = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ae = (e) => e === void 0 ? z : e === !1 ? X : y(e), _e = (e, t) => y(e).deniesPath(t), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), H = Object.freeze(["video", "audio", "pdf"]), V = Object.freeze(["raster", "svg"]), F = Object.freeze(["csv", "tsv"]), M = Object.freeze(["info", "warning", "danger"]), K = Object.freeze(["markdown", "text", "image", "media", "spreadsheet", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), Oe = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), xe = Object.freeze(["http:", "https:", "mailto:"]), A = 1024, G = /^[a-z0-9-]{1,64}$/u, Y = "https://relative.invalid/", g = 64, c = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, W = (e) => c(b, e), J = (e) => c(U, e), q = (e) => c(H, e), B = (e) => c(V, e), Q = (e) => c(F, e), Se = (e) => c(M, e), Z = (e) => c(K, e), _ = (e) => typeof e == "string" && G.test(e), Te = (e, t) => {
92
92
  if (typeof e != "string") return !1;
93
93
  try {
94
- return t.includes(new URL(e, M).protocol);
94
+ return t.includes(new URL(e, Y).protocol);
95
95
  } catch {
96
96
  return !1;
97
97
  }
98
98
  }, p = (e) => {
99
99
  if (e === null || typeof e != "object") return "a failure must be an object";
100
100
  const { reason: t, code: n } = e;
101
- return K(t) ? n !== void 0 && !_(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
102
- }, J = (e) => {
101
+ return W(t) ? n !== void 0 && !_(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
102
+ }, ee = (e) => {
103
103
  if (e === null || typeof e != "object") return "an entry must be an object";
104
- const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy: c } = e;
105
- return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" : G(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : c !== void 0 && typeof c != "boolean" ? "an entry lazy flag must be a boolean" : a !== void 0 && !Array.isArray(a) ? "entry children must be an array" : r === "file" && (a !== void 0 || c === !0) ? "a file entry cannot have children or be lazy" : c === !0 && Array.isArray(a) && a.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
104
+ const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy: l } = e;
105
+ return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" : J(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : l !== void 0 && typeof l != "boolean" ? "an entry lazy flag must be a boolean" : a !== void 0 && !Array.isArray(a) ? "entry children must be an array" : r === "file" && (a !== void 0 || l === !0) ? "a file entry cannot have children or be lazy" : l === !0 && Array.isArray(a) && a.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
106
106
  }, O = (e) => {
107
- if (J(e) !== null) return !1;
107
+ if (ee(e) !== null) return !1;
108
108
  const { children: t } = e;
109
109
  return t === void 0 || t.every(O);
110
- }, q = (e) => {
110
+ }, te = (e) => {
111
111
  if (e === null || typeof e != "object") return !1;
112
112
  const { status: t, entries: n, failure: r } = e;
113
113
  return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && p(r) === null;
114
- }, he = (e) => {
114
+ }, Ne = (e) => {
115
115
  if (e === null || typeof e != "object") return !1;
116
116
  const { status: t, ancestors: n, failure: r } = e;
117
117
  return t === "ok" ? n === null || x(n) : t === "error" && p(r) === null;
118
- }, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, be = (e) => {
118
+ }, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, ve = (e) => {
119
119
  if (e === null || typeof e != "object") return !1;
120
120
  const { status: t, source: n, ancestors: r, failure: s } = e;
121
121
  return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && p(s) === null;
122
- }, _e = (e) => {
122
+ }, Pe = (e) => {
123
123
  if (e === null || typeof e != "object") return !1;
124
124
  const { status: t, loadedAt: n } = e;
125
- return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : q(e);
126
- }, T = (e) => {
125
+ return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : te(e);
126
+ }, S = (e) => {
127
127
  if (e === null || typeof e != "object") return "a heading must be an object";
128
128
  const { text: t, depth: n, id: r } = e;
129
129
  return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < m.min || n > m.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
130
- }, B = (e) => {
130
+ }, ne = (e) => {
131
131
  if (e === null || typeof e != "object") return "a document must be an object";
132
132
  const t = e, { kind: n } = t;
133
- if (!Y(n)) return `unknown document kind ${o(n)}`;
133
+ if (!Z(n)) return `unknown document kind ${o(n)}`;
134
134
  if (n === "failure") return p(t.failure);
135
135
  if (typeof t.name != "string") return "a document needs a name string";
136
136
  switch (n) {
@@ -138,84 +138,91 @@ const v = Object.freeze([
138
138
  const { htmlContent: r, headings: s } = t;
139
139
  if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
140
140
  for (const i of s) {
141
- const a = T(i);
141
+ const a = S(i);
142
142
  if (a !== null) return a;
143
143
  }
144
- return Z(t.edit);
144
+ return se(t.edit);
145
145
  }
146
146
  case "text":
147
147
  return typeof t.text != "string" || typeof t.truncated != "boolean" ? "a text document needs text and truncated" : u(t.url) ? null : "a text document needs a root-relative url";
148
148
  case "image":
149
- return u(t.url) ? null : "an image document needs a root-relative url";
149
+ return u(t.url) ? B(t.imageType) ? null : `unknown image type ${o(t.imageType)}` : "an image document needs a root-relative url";
150
150
  case "media":
151
- return u(t.url) ? W(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
151
+ return u(t.url) ? q(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
152
+ case "spreadsheet":
153
+ return u(t.url) ? ie(t) : "a spreadsheet document needs a root-relative url";
152
154
  case "file":
153
155
  return u(t.url) ? null : "a file document needs a root-relative url";
154
156
  }
155
- }, Q = (e) => B(e) === null, Oe = (e) => Q(e) && (e.kind === "text" || e.kind === "failure"), Z = (e) => {
157
+ }, re = (e) => ne(e) === null, we = (e) => re(e) && (e.kind === "text" || e.kind === "failure"), se = (e) => {
156
158
  if (e === null) return null;
157
159
  if (typeof e != "object") return "a markdown document's edit must be null or an object";
158
160
  const { kind: t, href: n } = e;
159
- return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : ee(n) ? null : `an external edit needs an absolute https: href; got ${o(n)}`;
160
- }, ee = (e) => {
161
+ return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : T(n);
162
+ }, oe = (e) => {
163
+ if (e === null) return null;
164
+ if (typeof e != "object") return "a spreadsheet document's edit must be null or an object";
165
+ const { kind: t, href: n } = e;
166
+ return t !== "external" ? `a spreadsheet document's edit must be external; got ${o(t)}` : T(n);
167
+ }, ie = (e) => Q(e.format) ? typeof e.firstSheetOnly != "boolean" ? "a spreadsheet document needs a boolean firstSheetOnly" : oe(e.edit) : `unknown spreadsheet format ${o(e.format)}`, T = (e) => ae(e) ? null : `an external edit needs an absolute https: href; got ${o(e)}`, ae = (e) => {
161
168
  if (typeof e != "string") return !1;
162
169
  try {
163
170
  return new URL(e).protocol === "https:";
164
171
  } catch {
165
172
  return !1;
166
173
  }
167
- }, f = (e) => typeof e == "string" && e.length > 0 && e.length <= b, te = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ne = (e) => {
174
+ }, d = (e) => typeof e == "string" && e.length > 0 && e.length <= A, le = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ce = (e) => {
168
175
  if (e === null || typeof e != "object") return "a revision must be an object";
169
176
  const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: a } = e;
170
- return f(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${b} characters; got ${o(t)}`;
171
- }, l = (e, t) => {
177
+ return d(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${A} characters; got ${o(t)}`;
178
+ }, f = (e, t) => {
172
179
  if (e === null || typeof e != "object") return "an answer must be an object";
173
180
  const n = e, { kind: r } = n;
174
181
  if (r === "failure") return p(n.failure);
175
182
  if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${o(r)}`;
176
183
  switch (r) {
177
184
  case "grant":
178
- return te(n);
185
+ return le(n);
179
186
  case "edit":
180
- return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : f(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
187
+ return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : d(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
181
188
  case "draft":
182
189
  return typeof n.text == "string" ? null : "a draft source needs text";
183
190
  case "saved":
184
- return f(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
191
+ return d(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
185
192
  case "conflict":
186
- return typeof n.text != "string" ? "a conflict needs the current text" : f(n.version) ? null : `a conflict needs the current version; got ${o(n.version)}`;
193
+ return typeof n.text != "string" ? "a conflict needs the current text" : d(n.version) ? null : `a conflict needs the current version; got ${o(n.version)}`;
187
194
  case "preview": {
188
195
  const { htmlContent: s, headings: i } = n;
189
196
  if (typeof s != "string" || !Array.isArray(i)) return "a preview needs htmlContent and headings";
190
197
  for (const a of i) {
191
- const c = T(a);
192
- if (c !== null) return c;
198
+ const l = S(a);
199
+ if (l !== null) return l;
193
200
  }
194
201
  return null;
195
202
  }
196
203
  case "revisions": {
197
204
  if (!Array.isArray(n.revisions)) return "revisions need an array";
198
205
  for (const s of n.revisions) {
199
- const i = ne(s);
206
+ const i = ce(s);
200
207
  if (i !== null) return i;
201
208
  }
202
209
  return null;
203
210
  }
204
211
  case "revision":
205
- return typeof n.text != "string" ? "a revision answer needs text" : f(n.id) ? null : `a revision answer needs an id; got ${o(n.id)}`;
212
+ return typeof n.text != "string" ? "a revision answer needs text" : d(n.id) ? null : `a revision answer needs an id; got ${o(n.id)}`;
206
213
  default:
207
214
  return `unexpected answer kind ${o(r)}`;
208
215
  }
209
- }, re = Object.freeze(["edit", "draft", "grant"]), se = Object.freeze(["saved", "conflict", "grant"]), S = Object.freeze(["preview"]), oe = Object.freeze(["revisions"]), ie = Object.freeze(["revision"]), xe = (e) => l(e, re) === null, Te = (e) => l(e, se) === null, Se = (e) => l(e, S) === null, Ne = (e) => l(e, oe) === null, ve = (e) => l(e, ie) === null, we = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : l(e, S), Pe = (e, t) => ({ kind: "failure", failure: ae(e, t) }), ae = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ce = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), le = "asset", ue = "link-card", Le = (e, t, n) => {
210
- const r = `${e}/${le}?${E.path}=${encodeURIComponent(t)}`;
216
+ }, ue = Object.freeze(["edit", "draft", "grant"]), fe = Object.freeze(["saved", "conflict", "grant"]), N = Object.freeze(["preview"]), de = Object.freeze(["revisions"]), pe = Object.freeze(["revision"]), Le = (e) => f(e, ue) === null, ke = (e) => f(e, fe) === null, De = (e) => f(e, N) === null, je = (e) => f(e, de) === null, $e = (e) => f(e, pe) === null, Ie = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : f(e, N), Ce = (e, t) => ({ kind: "failure", failure: Ee(e, t) }), Ee = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ye = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), me = "asset", ge = "link-card", ze = (e, t, n) => {
217
+ const r = `${e}/${me}?${E.path}=${encodeURIComponent(t)}`;
211
218
  return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
212
- }, N = "text", De = (e) => {
219
+ }, v = "text", Xe = (e) => {
213
220
  if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
214
- return `${e}&${E.display}=${N}`;
215
- }, ke = (e) => {
221
+ return `${e}&${E.display}=${v}`;
222
+ }, Ue = (e) => {
216
223
  const t = e.getAll(E.display);
217
- return t.length === 0 ? "file" : t.length === 1 && t[0] === N ? "text" : null;
218
- }, je = (e) => `${e}/${ue}`, $e = "X-Markdown-Explorer-Scope", Ie = "X-Markdown-Explorer", Ce = "refresh", ze = "edit", Ue = "text/markdown", Xe = (e) => ce.includes(e), fe = Object.freeze({
224
+ return t.length === 0 ? "file" : t.length === 1 && t[0] === v ? "text" : null;
225
+ }, He = (e) => `${e}/${ge}`, Ve = "X-Markdown-Explorer-Scope", Fe = "X-Markdown-Explorer", Me = "refresh", Ke = "edit", Ge = "text/markdown", Ye = (e) => ye.includes(e), Re = Object.freeze({
219
226
  invalid: 400,
220
227
  unauthorized: 401,
221
228
  forbidden: 403,
@@ -224,58 +231,60 @@ const v = Object.freeze([
224
231
  "not-configured": 500,
225
232
  unsupported: 500,
226
233
  failed: 500
227
- }), He = (e) => {
228
- const [t, ...n] = h.filter((r) => fe[r] === e);
234
+ }), We = (e) => {
235
+ const [t, ...n] = b.filter((r) => Re[r] === e);
229
236
  return t !== void 0 && n.length === 0 ? t : "failed";
230
237
  };
231
238
  export {
232
- ke as A,
233
- Ue as B,
234
- ye as C,
235
- v as D,
236
- me as E,
237
- pe as F,
238
- De as G,
239
- He as H,
240
- Oe as I,
241
- be as J,
242
- he as K,
243
- q as L,
244
- de as M,
245
- p as N,
246
- _e as O,
247
- ve as P,
248
- Ne as Q,
249
- Se as R,
250
- Te as S,
251
- xe as T,
252
- Q as U,
253
- b as V,
254
- h as W,
255
- je as a,
256
- K as b,
239
+ E as A,
240
+ Ce as B,
241
+ Ue as C,
242
+ Ge as D,
243
+ Oe as E,
244
+ P as F,
245
+ _e as G,
246
+ be as H,
247
+ Xe as I,
248
+ We as J,
249
+ p as K,
250
+ we as L,
251
+ he as M,
252
+ ve as N,
253
+ Ne as O,
254
+ te as P,
255
+ Pe as Q,
256
+ $e as R,
257
+ je as S,
258
+ De as T,
259
+ ke as U,
260
+ Le as V,
261
+ re as W,
262
+ A as X,
263
+ b as Y,
264
+ He as a,
265
+ W as b,
257
266
  _ as c,
258
- we as d,
259
- Le as e,
260
- ae as f,
261
- Re as g,
262
- Ae as h,
267
+ Ie as d,
268
+ ze as e,
269
+ Ee as f,
270
+ Se as g,
271
+ Te as h,
263
272
  R as i,
264
- W as j,
273
+ q as j,
265
274
  B as k,
266
- f as l,
267
- T as m,
268
- u as n,
269
- J as o,
270
- ge as p,
271
- Ee as q,
272
- ne as r,
273
- Xe as s,
274
- fe as t,
275
- Ie as u,
276
- Ce as v,
277
- ze as w,
278
- $e as x,
279
- E as y,
280
- Pe as z
275
+ ne as l,
276
+ d as m,
277
+ S as n,
278
+ u as o,
279
+ ee as p,
280
+ xe as q,
281
+ ce as r,
282
+ ie as s,
283
+ Ae as t,
284
+ Ye as u,
285
+ Re as v,
286
+ Fe as w,
287
+ Me as x,
288
+ Ke as y,
289
+ Ve as z
281
290
  };
@@ -0,0 +1 @@
1
+ "use strict";const b=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),z=/[\u0000-\u001f\u007f]/u,F=/\p{Cs}/u,V=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},R=e=>e.length>0&&e.length<=4096&&!F.test(e)&&!z.test(e)&&!e.includes("\\"),x=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),M=/(?:%[0-9A-Fa-f]{2})+/gu,G=new TextDecoder("utf-8"),K=/[/\\]/u,Y=e=>e.replace(M,t=>G.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),W=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=Y(n);if(o===n)break;t.push(o),n=o}return t.map(x)},J=e=>{if(typeof e!="string"||e.trim()===""||e.includes("/")||e.includes("\\"))throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);const t=x(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},m=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(J),n=o=>o!==""&&t.some(i=>i.test(o)),r=o=>o!==""&&W(o).some(i=>n(i)||i.split(K).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},Q=m(b),q=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),B=e=>e===void 0?Q:e===!1?q:m(e),Z=(e,t)=>m(e).deniesPath(t),y=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),ee=Object.freeze(["file","directory"]),te=Object.freeze(["video","audio","pdf"]),ne=Object.freeze(["raster","svg"]),re=Object.freeze(["csv","tsv"]),oe=Object.freeze(["info","warning","danger"]),se=Object.freeze(["markdown","text","image","media","spreadsheet","file","failure"]),O=Object.freeze({min:1,max:6}),ie=1e4,c=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ae=Object.freeze(["http:","https:","mailto:"]),_=1024,le=/^[a-z0-9-]{1,64}$/u,ce="https://relative.invalid/",h=64,u=(e,t)=>typeof t=="string"&&e.includes(t),s=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,T=e=>u(y,e),ue=e=>u(ee,e),P=e=>u(te,e),S=e=>u(ne,e),fe=e=>u(re,e),de=e=>u(oe,e),Ee=e=>u(se,e),g=e=>typeof e=="string"&&le.test(e),pe=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,ce).protocol)}catch{return!1}},d=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return T(t)?n!==void 0&&!g(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${s(n)}`:null:`unknown failure reason ${s(t)}`},L=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,modifiedAt:i,children:a,lazy:l}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!R(n)?"an entry needs an acceptable path":ue(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&!Number.isSafeInteger(i)?`an entry modifiedAt must be a safe integer of epoch milliseconds; got ${s(i)}`:l!==void 0&&typeof l!="boolean"?"an entry lazy flag must be a boolean":a!==void 0&&!Array.isArray(a)?"entry children must be an array":r==="file"&&(a!==void 0||l===!0)?"a file entry cannot have children or be lazy":l===!0&&Array.isArray(a)&&a.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${s(r)}`},N=e=>{if(L(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(N)},D=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:n,failure:r}=e;return t==="ok"?Array.isArray(n)&&n.every(N):t==="error"&&d(r)===null},Re=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||v(n):t==="error"&&d(r)===null},v=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&R(t))&&new Set(e).size===e.length,me=e=>{if(e===null||typeof e!="object")return!1;const{status:t,source:n,ancestors:r,failure:o}=e;return t==="ok"?n===null&&r===null||typeof n=="string"&&n!==""&&v(r):t==="error"&&d(o)===null},ye=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:D(e)},A=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:n,id:r}=e;return typeof t!="string"||typeof r!="string"?"a heading needs text and id strings":typeof n!="number"||!Number.isInteger(n)||n<O.min||n>O.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},w=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!Ee(n))return`unknown document kind ${s(n)}`;if(n==="failure")return d(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const i of o){const a=A(i);if(a!==null)return a}return ge(t.edit)}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":c(t.url)?null:"a text document needs a root-relative url";case"image":return c(t.url)?S(t.imageType)?null:`unknown image type ${s(t.imageType)}`:"an image document needs a root-relative url";case"media":return c(t.url)?P(t.mediaType)?null:`unknown media type ${s(t.mediaType)}`:"a media document needs a root-relative url";case"spreadsheet":return c(t.url)?I(t):"a spreadsheet document needs a root-relative url";case"file":return c(t.url)?null:"a file document needs a root-relative url"}},k=e=>w(e)===null,_e=e=>k(e)&&(e.kind==="text"||e.kind==="failure"),ge=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:t,href:n}=e;return t==="inline"?n===void 0?null:"an inline edit carries no href":t==="draft"?n===void 0?null:"a draft edit carries no href":t!=="external"?`unknown edit kind ${s(t)}`:j(n)},Ae=e=>{if(e===null)return null;if(typeof e!="object")return"a spreadsheet document's edit must be null or an object";const{kind:t,href:n}=e;return t!=="external"?`a spreadsheet document's edit must be external; got ${s(t)}`:j(n)},I=e=>fe(e.format)?typeof e.firstSheetOnly!="boolean"?"a spreadsheet document needs a boolean firstSheetOnly":Ae(e.edit):`unknown spreadsheet format ${s(e.format)}`,j=e=>Oe(e)?null:`an external edit needs an absolute https: href; got ${s(e)}`,Oe=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},f=e=>typeof e=="string"&&e.length>0&&e.length<=_,he=e=>c(e.href)?null:`a grant needs a root-relative href; got ${s(e.href)}`,$=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:n,size:r,author:o,kept:i,current:a}=e;return f(t)?n!==null&&(typeof n!="string"||Number.isNaN(Date.parse(n)))?`a revision's modifiedAt must be a date-time string or null; got ${s(n)}`:typeof r!="number"||!Number.isSafeInteger(r)||r<0?`a revision's size must be a non-negative integer; got ${s(r)}`:o!==null&&typeof o!="string"?`a revision's author must be a string or null; got ${s(o)}`:typeof i!="boolean"||typeof a!="boolean"?"a revision needs kept and current booleans":null:`a revision id must be a non-empty string of at most ${_} characters; got ${s(t)}`},E=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const n=e,{kind:r}=n;if(r==="failure")return d(n.failure);if(typeof r!="string"||!t.includes(r))return`unexpected answer kind ${s(r)}`;switch(r){case"grant":return he(n);case"edit":return typeof n.text!="string"||typeof n.history!="boolean"?"an edit source needs text and history":f(n.version)?null:`an edit source needs a version; got ${s(n.version)}`;case"draft":return typeof n.text=="string"?null:"a draft source needs text";case"saved":return f(n.version)?null:`a saved answer needs a version; got ${s(n.version)}`;case"conflict":return typeof n.text!="string"?"a conflict needs the current text":f(n.version)?null:`a conflict needs the current version; got ${s(n.version)}`;case"preview":{const{htmlContent:o,headings:i}=n;if(typeof o!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const a of i){const l=A(a);if(l!==null)return l}return null}case"revisions":{if(!Array.isArray(n.revisions))return"revisions need an array";for(const o of n.revisions){const i=$(o);if(i!==null)return i}return null}case"revision":return typeof n.text!="string"?"a revision answer needs text":f(n.id)?null:`a revision answer needs an id; got ${s(n.id)}`;default:return`unexpected answer kind ${s(r)}`}},be=Object.freeze(["edit","draft","grant"]),xe=Object.freeze(["saved","conflict","grant"]),X=Object.freeze(["preview"]),Te=Object.freeze(["revisions"]),Pe=Object.freeze(["revision"]),Se=e=>E(e,be)===null,Le=e=>E(e,xe)===null,Ne=e=>E(e,X)===null,De=e=>E(e,Te)===null,ve=e=>E(e,Pe)===null,we=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:E(e,X),ke=(e,t)=>({kind:"failure",failure:C(e,t)}),C=(e,t)=>g(t)?{reason:e,code:t}:{reason:e},Ie=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),p=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),je="asset",$e="link-card",Xe=(e,t,n)=>{const r=`${e}/${je}?${p.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${p.version}=${encodeURIComponent(n)}`},U="text",Ce=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${p.display}=${U}`},Ue=e=>{const t=e.getAll(p.display);return t.length===0?"file":t.length===1&&t[0]===U?"text":null},He=e=>`${e}/${$e}`,ze="X-Markdown-Explorer-Scope",Fe="X-Markdown-Explorer",Ve="refresh",Me="edit",Ge="text/markdown",Ke=e=>Ie.includes(e),H=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Ye=e=>{const[t,...n]=y.filter(r=>H[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=p;exports.EXPLORER_DRAFT_MEDIA_TYPE=Ge;exports.EXPLORER_EDIT_PROOF=Me;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=y;exports.EXPLORER_FAILURE_STATUS=H;exports.EXPLORER_LINK_PROTOCOLS=ae;exports.EXPLORER_MAX_HEADINGS=ie;exports.EXPLORER_PROOF_HEADER=Fe;exports.EXPLORER_REFRESH_PROOF=Ve;exports.EXPLORER_SCOPE_HEADER=ze;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=w;exports.draftAnswerViolation=we;exports.entryViolation=L;exports.explorerAssetHref=Xe;exports.explorerLinkCardEndpoint=He;exports.explorerPlainTextHref=Ce;exports.failureDocument=ke;exports.failureOf=C;exports.failureReasonOfStatus=Ye;exports.failureViolation=d;exports.headingViolation=A;exports.isAcceptableDocumentPath=R;exports.isAcceptableUrl=pe;exports.isDeniedPath=Z;exports.isExplorerAncestorsResult=Re;exports.isExplorerChildrenResult=D;exports.isExplorerDataOperation=Ke;exports.isExplorerDocument=k;exports.isExplorerEditAnswer=Se;exports.isExplorerEditToken=f;exports.isExplorerFailureCode=g;exports.isExplorerFailureReason=T;exports.isExplorerImageType=S;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=de;exports.isExplorerPreviewAnswer=Ne;exports.isExplorerRevealResult=me;exports.isExplorerRevisionAnswer=ve;exports.isExplorerRevisionsAnswer=De;exports.isExplorerSaveAnswer=Le;exports.isExplorerTextAnswer=_e;exports.isExplorerTreeResult=ye;exports.isRootRelativeUrl=c;exports.lastPathSegment=V;exports.readExplorerAssetDisplay=Ue;exports.resolvePathRules=B;exports.revisionViolation=$;exports.spreadsheetFieldsViolation=I;