@aiquants/markdown-explorer 0.21.0 → 0.23.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 (48) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +27 -16
  3. package/dist/EditSurface-Bk4tdJ99.cjs +6 -0
  4. package/dist/EditSurface-Dhvw9IDD.js +975 -0
  5. package/dist/{ExplorerSplit-CdqEKz-I.cjs → ExplorerSplit-BAFiXU-V.cjs} +1 -1
  6. package/dist/{ExplorerSplit-3WMRDA7G.js → ExplorerSplit-Q5VqUBDE.js} +3 -3
  7. package/dist/{MultiLayout-BEg1X8Jx.cjs → MultiLayout-Bq_TS3ez.cjs} +1 -1
  8. package/dist/{MultiLayout-Gf1xT-Le.js → MultiLayout-DlATT7km.js} +22 -22
  9. package/dist/{NativeScrollBar-idIQsvCv.cjs → NativeScrollBar-A6-qEpz7.cjs} +1 -1
  10. package/dist/{NativeScrollBar-0cpp2OIu.js → NativeScrollBar-TsIcS3JZ.js} +1 -1
  11. package/dist/{TreeLayout-DJY_WqzP.cjs → TreeLayout-l-r2pPao.cjs} +1 -1
  12. package/dist/{TreeLayout-DzZCgMTt.js → TreeLayout-zrSo4MNZ.js} +3 -3
  13. package/dist/core/contracts.d.cts +7 -0
  14. package/dist/core/contracts.d.ts +7 -0
  15. package/dist/core/labels.d.cts +21 -27
  16. package/dist/core/labels.d.ts +21 -27
  17. package/dist/{dataRoute-CObbjNxG.js → dataRoute-Diu_7gle.js} +84 -83
  18. package/dist/dataRoute-vXGZMVB-.cjs +1 -0
  19. package/dist/index-BNFl3BsO.cjs +13 -0
  20. package/dist/{index-CJgHGeZs.js → index-Jz6zeO4O.js} +1500 -1529
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +9 -9
  25. package/dist/{location-B-m9scLf.js → location-8Ho8ZNv_.js} +1 -1
  26. package/dist/{location-BVEN_Ihk.cjs → location-DN0AI4ir.cjs} +1 -1
  27. package/dist/{merge-BOcofJN5.js → merge-BzMpSaxx.js} +1 -1
  28. package/dist/{merge-BVk6pvO_.cjs → merge-DlPkU2Jc.cjs} +1 -1
  29. package/dist/{sanitizePolicy-BWQtWhsL.js → sanitizePolicy-BvhYIqVO.js} +1 -1
  30. package/dist/{sanitizePolicy-gEXeavb-.cjs → sanitizePolicy-Du3lFZd-.cjs} +1 -1
  31. package/dist/sanitizeWorker.cjs +1 -1
  32. package/dist/sanitizeWorker.js +1 -1
  33. package/dist/server/ports.d.cts +2 -1
  34. package/dist/server/ports.d.ts +2 -1
  35. package/dist/server.cjs +1 -1
  36. package/dist/server.js +524 -521
  37. package/dist/{useSplitPersistence-Ba-v64n-.cjs → useSplitPersistence-CR4Oxtaa.cjs} +1 -1
  38. package/dist/{useSplitPersistence-Cc4tDxB4.js → useSplitPersistence-HfAb8Kzh.js} +1 -1
  39. package/docs/behavior/dom-hooks.md +3 -3
  40. package/docs/behavior/layout.md +11 -5
  41. package/docs/behavior/localization.md +9 -7
  42. package/docs/behavior/security.md +1 -1
  43. package/docs/behavior/url-contract.md +2 -2
  44. package/package.json +5 -5
  45. package/dist/EditSurface-Bwl4S1vQ.cjs +0 -7
  46. package/dist/EditSurface-rKoy_ndP.js +0 -880
  47. package/dist/dataRoute-BONacTPi.cjs +0 -1
  48. package/dist/index-bMaSoQTe.cjs +0 -13
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-bMaSoQTe.cjs"),e=require("./storage-DM0EvkVf.cjs"),E=require("./location-BVEN_Ihk.cjs"),_=require("./dataRoute-BONacTPi.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=E.REVEAL_DOCUMENT_DEPTH_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_.EXPLORER_EDIT_TOKEN_MAX_LENGTH;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-BNFl3BsO.cjs"),e=require("./storage-DM0EvkVf.cjs"),E=require("./location-DN0AI4ir.cjs"),_=require("./dataRoute-vXGZMVB-.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=E.REVEAL_DOCUMENT_DEPTH_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_.EXPLORER_EDIT_TOKEN_MAX_LENGTH;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { type ExplorerFrameRenderer, MarkdownExplorer, type MarkdownExplorerProps } from "./client/MarkdownExplorer.cjs";
2
2
  export { clearExplorerStorage } from "./client/storage.cjs";
3
3
  export { DEFAULT_VIEW_SLUGS, defineExplorerConfig, EXPAND_ALL_DEPTH_LIMITS, EXPAND_ALL_FOLDER_LIMITS, type ExplorerConfig, type ExplorerConfigInput, type ExplorerDocumentStyle, type ExplorerLocationConfig, type ExplorerView, type ExplorerViewSlugs, isExplorerSourceId, MULTI_VIEW_COLUMN_LIMITS, MULTI_VIEW_PANEL_LIMITS, REVEAL_DOCUMENT_DEPTH_LIMITS, withExplorerSources, } from "./core/config.cjs";
4
- export { EXPLORER_EDIT_TOKEN_MAX_LENGTH, EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerDocumentEdit, type ExplorerDraft, type ExplorerDraftAnswer, type ExplorerDraftConverter, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerGrantRequired, type ExplorerHeading, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerRevision, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.cjs";
4
+ export { EXPLORER_EDIT_TOKEN_MAX_LENGTH, EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerDocumentEdit, type ExplorerDraft, type ExplorerDraftAnswer, type ExplorerDraftConverter, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerGrantRequired, type ExplorerHeading, type ExplorerImageType, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerRevision, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.cjs";
5
5
  export { COLUMN_MIN_MEASURE, EXPLORER_DEFAULT_PERCENT, EXPLORER_MAX_PERCENT, EXPLORER_MIN_REM, EXPLORER_MULTI_DEFAULT_PERCENT, GOLDEN_RATIO } from "./core/geometry.cjs";
6
6
  export { DEFAULT_MARKDOWN_EXPLORER_LOCALE, MARKDOWN_EXPLORER_LABEL_CATALOGS, MARKDOWN_EXPLORER_LABEL_KEYS, MARKDOWN_EXPLORER_LABEL_TEMPLATES, MARKDOWN_EXPLORER_LOCALES, type MarkdownExplorerLabelKey, type MarkdownExplorerLabelOverrides, type MarkdownExplorerLabels, type MarkdownExplorerLocale, resolveMarkdownExplorerLabels, } from "./core/labels.cjs";
7
7
  export { type ExplorerEmbedOptions, type ExplorerHrefTarget, type ExplorerLocation, type ExplorerLocationResult, type ExplorerOverrides, type ExplorerSourcelessHrefTarget, explorerHref, resolveExplorerLocation, } from "./core/location.cjs";
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { type ExplorerFrameRenderer, MarkdownExplorer, type MarkdownExplorerProps } from "./client/MarkdownExplorer.js";
2
2
  export { clearExplorerStorage } from "./client/storage.js";
3
3
  export { DEFAULT_VIEW_SLUGS, defineExplorerConfig, EXPAND_ALL_DEPTH_LIMITS, EXPAND_ALL_FOLDER_LIMITS, type ExplorerConfig, type ExplorerConfigInput, type ExplorerDocumentStyle, type ExplorerLocationConfig, type ExplorerView, type ExplorerViewSlugs, isExplorerSourceId, MULTI_VIEW_COLUMN_LIMITS, MULTI_VIEW_PANEL_LIMITS, REVEAL_DOCUMENT_DEPTH_LIMITS, withExplorerSources, } from "./core/config.js";
4
- export { EXPLORER_EDIT_TOKEN_MAX_LENGTH, EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerDocumentEdit, type ExplorerDraft, type ExplorerDraftAnswer, type ExplorerDraftConverter, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerGrantRequired, type ExplorerHeading, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerRevision, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.js";
4
+ export { EXPLORER_EDIT_TOKEN_MAX_LENGTH, EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerDocumentEdit, type ExplorerDraft, type ExplorerDraftAnswer, type ExplorerDraftConverter, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerGrantRequired, type ExplorerHeading, type ExplorerImageType, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerRevision, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.js";
5
5
  export { COLUMN_MIN_MEASURE, EXPLORER_DEFAULT_PERCENT, EXPLORER_MAX_PERCENT, EXPLORER_MIN_REM, EXPLORER_MULTI_DEFAULT_PERCENT, GOLDEN_RATIO } from "./core/geometry.js";
6
6
  export { DEFAULT_MARKDOWN_EXPLORER_LOCALE, MARKDOWN_EXPLORER_LABEL_CATALOGS, MARKDOWN_EXPLORER_LABEL_KEYS, MARKDOWN_EXPLORER_LABEL_TEMPLATES, MARKDOWN_EXPLORER_LOCALES, type MarkdownExplorerLabelKey, type MarkdownExplorerLabelOverrides, type MarkdownExplorerLabels, type MarkdownExplorerLocale, resolveMarkdownExplorerLabels, } from "./core/labels.js";
7
7
  export { type ExplorerEmbedOptions, type ExplorerHrefTarget, type ExplorerLocation, type ExplorerLocationResult, type ExplorerOverrides, type ExplorerSourcelessHrefTarget, explorerHref, resolveExplorerLocation, } from "./core/location.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { W as a, X as L, Y as s, Z as e, _ as r, $ as R, a0 as A, a1 as T, a2 as o } from "./index-CJgHGeZs.js";
1
+ import { W as a, X as L, Y as s, Z as e, _ as r, $ as R, a0 as A, a1 as T, a2 as o } from "./index-Jz6zeO4O.js";
2
2
  import { c as O } from "./storage-CmGHg7OA.js";
3
- import { R as N, T as P, U as l, V as I, W as S, x as X, u as i, X as p, y as x, H as U, Y as t, Z as C, _ as f, $ as u, e as W, i as c, g as n, w as F } from "./location-B-m9scLf.js";
4
- import { D as d, V as G, W as K, E as m, M as V, z as h, f as w, i as b, C as g, L as v, c as B, b as Y } from "./dataRoute-CObbjNxG.js";
3
+ import { R as N, T as P, U as l, V as I, W as S, x as X, u as i, X as p, y as x, H as U, Y as t, Z as C, _ as f, $ as u, e as F, i as W, g as c, w as n } from "./location-8Ho8ZNv_.js";
4
+ import { D as d, W as G, X as K, E as m, M as h, A as V, f as w, i as b, F as g, N as v, c as B, b as Y } from "./dataRoute-Diu_7gle.js";
5
5
  export {
6
6
  N as COLUMN_MIN_MEASURE,
7
7
  d as DEFAULT_DENIED_PATH_SEGMENTS,
@@ -23,24 +23,24 @@ export {
23
23
  e as MARKDOWN_EXPLORER_LABEL_KEYS,
24
24
  r as MARKDOWN_EXPLORER_LABEL_TEMPLATES,
25
25
  R as MARKDOWN_EXPLORER_LOCALES,
26
- V as MAX_DOCUMENT_PATH_LENGTH,
26
+ h as MAX_DOCUMENT_PATH_LENGTH,
27
27
  t as MULTI_VIEW_COLUMN_LIMITS,
28
28
  C as MULTI_VIEW_PANEL_LIMITS,
29
29
  A as MarkdownExplorer,
30
30
  f as REVEAL_DOCUMENT_DEPTH_LIMITS,
31
31
  O as clearExplorerStorage,
32
32
  u as defineExplorerConfig,
33
- W as explorerHref,
34
- h as failureDocument,
33
+ F as explorerHref,
34
+ V as failureDocument,
35
35
  w as failureOf,
36
36
  b as isAcceptableDocumentPath,
37
37
  g as isDeniedPath,
38
38
  v as isExplorerChildrenResult,
39
39
  B as isExplorerFailureCode,
40
40
  Y as isExplorerFailureReason,
41
- c as isExplorerSourceId,
42
- n as resolveExplorerLocation,
41
+ W as isExplorerSourceId,
42
+ c as resolveExplorerLocation,
43
43
  T as resolveMarkdownExplorerLabels,
44
44
  o as shouldRevalidateExplorer,
45
- F as withExplorerSources
45
+ n as withExplorerSources
46
46
  };
@@ -1,6 +1,6 @@
1
1
  import { NO_EMBEDS as we, isEmbedProviderId as ge, EMBED_PROVIDER_IDS as pe, isLinkCardSize as he, LINK_CARD_SIZES as Ee } from "@aiquants/markdown/embeds";
2
2
  import { CONTENT_ALIGNS as N, DEFAULT_MARKDOWN_STYLES as Se } from "@aiquants/markdown/viewer-settings";
3
- import { a as xe, i as A } from "./dataRoute-CObbjNxG.js";
3
+ import { a as xe, i as A } from "./dataRoute-Diu_7gle.js";
4
4
  const J = (e) => {
5
5
  if (e === null || typeof e != "object") return !1;
6
6
  const t = Object.getPrototypeOf(e);
@@ -1 +1 @@
1
- "use strict";const y=require("@aiquants/markdown/embeds"),N=require("@aiquants/markdown/viewer-settings"),I=require("./dataRoute-BONacTPi.cjs"),M=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},A=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),Ie=/^readme(?:\.|$)/iu,Z=/^readme(?:\.[^.]*)?$/iu,Y=Object.freeze(["md","markdown","mdx","txt",""]),Ae=e=>Ie.test(e),X=e=>e.type==="file"&&Ae(e.name),Q=e=>{const t=e.lastIndexOf("."),r=Y.indexOf(t<0?"":e.slice(t+1).toLowerCase());return r<0?Y.length:r},ke=(e,t)=>{const r=+!Z.test(e.name)-+!Z.test(t.name);if(r!==0)return r;const n=Q(e.name)-Q(t.name);if(n!==0)return n;const o=A.compare(e.name,t.name);return o!==0?o:A.compare(e.path,t.path)},Pe=e=>{let t=null;for(const r of e)X(r)&&(t===null||ke(r,t)<0)&&(t=r);return t===null?null:t.path},G=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),Le=[!0,!1],Ce=(e,t)=>t?e.settingOn:e.settingOff,p=(e,t)=>({key:e,labelKey:t,values:Le,formatValue:Ce,requiresItemSelection:!1}),Me=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),_=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,t)=>Me[t](e),requiresItemSelection:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.folderPlacementMixed:t==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresItemSelection:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.readmePlacementMixed:t==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresItemSelection:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},p("alwaysExpanded","settingAlwaysExpanded"),p("revealDocument","settingRevealDocument"),p("removeRootIndent","settingRemoveRootIndent"),p("lines","settingTreeLines"),p("expandIcons","settingExpandIcons"),p("directoryIcons","settingDirectoryIcons"),p("fileIcons","settingFileIcons")]),ve=e=>e?_:_.filter(t=>!t.requiresItemSelection),se=e=>{const t=_.find(r=>r.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},De=(e,t)=>{const r=se(t).values,n=r[(r.indexOf(e[t])+1)%r.length];return{...e,[t]:n}},$e=(e,t,r)=>se(r).formatValue(e,t[r]),ae=2,W=Object.freeze({}),K=(e,t)=>Object.freeze(Object.fromEntries(_.filter(r=>t(r,e[r.key])).map(r=>[r.key,e[r.key]]))),ee="directoriesFirst",ze=e=>{if(!Object.hasOwn(e,ee))return e;const{[ee]:t,...r}=e;return Object.hasOwn(r,"folderPlacement")||typeof t!="boolean"?r:{...r,folderPlacement:t?"first":"mixed"}},je=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return W;const t=e;return t.version!==ae||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?W:K(ze(t.settings),(r,n)=>r.values.includes(n))},Fe=(e,t)=>{const r=K(t,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(r).length===0?e:Object.freeze({...e,...r})},Ve=(e,t,r,n)=>K({...e,[t]:r},(o,i)=>i!==void 0&&!(o.key===t&&i===n[t])),Ue=e=>JSON.stringify({version:ae,settings:e}),Xe=(e,t,r)=>e===void 0||t===void 0?e===t?0:e===void 0?1:-1:r*(e-t),Ge=e=>{const{sortMode:t,folderPlacement:r,readmePlacement:n}=e;if(t==="native"&&r==="mixed"&&n==="mixed")return;const o=(i,s)=>{const l=A.compare(i.name,s.name);return l!==0?l:A.compare(i.path,s.path)};return(i,s)=>{if(r!=="mixed"&&i.type!==s.type)return i.type==="directory"==(r==="first")?-1:1;if(n!=="mixed"){const a=X(i);if(a!==X(s))return a===(n==="first")?-1:1}if(t==="native")return 0;if(t==="asc")return o(i,s);if(t==="desc")return-o(i,s);const l=Xe(i.modifiedAt,s.modifiedAt,t==="oldest"?1:-1);return l!==0?l:o(i,s)}},u=(1+Math.sqrt(5))/2,We=100/u**3,Je=100/u**4,q=100/u**2,le=13,He=16,Ke=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),qe=Object.freeze([89,144,233,377]),ce=44,Be=ce,Ze=24,Ye=1/u,Qe=1/u**3,et="40ch",tt=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},de=e=>(tt(e),le*e),rt=e=>de(e)*u**2,nt=233,ot=50,me=100/u**3,it=100-me,st=qe[0],g=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},at=({trackInlineSize:e,gap:t,minColumnInlineSize:r,logicalColumns:n})=>{if(g("trackInlineSize",e),g("gap",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);const o=Math.floor((e+t)/(r+t));return Math.min(n,Math.max(1,o))},lt=(e,t)=>{const{trackInlineSize:r,gap:n,minColumnInlineSize:o,logicalColumns:i}=t;if(!([r,n,o].every(Number.isFinite)&&r>0&&n>=0&&o>0))return e;const l=at(t);if(e===null||l===e)return l;const a=Math.min(i,Math.max(1,e));if(l>a){const v=(a+1)*o+a*n+n/u;return r>=v?l:a}return r>=a*o+(a-1)*n?a:l},ct=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(r,n)=>[Math.floor(n*e/t),Math.floor((n+1)*e/t)])},dt=(e,t,r)=>{if(g("surfaceInlineSize",e),g("handlePixels",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);return e>=2*t+r?"beside":"stacked"},U=(e,t,r)=>Math.max(t,Math.min(e,r)),te=(e,t,r,n)=>{const o=(U(e,0,r)+U(t,0,r))/2;return U(o-n/2,0,r-n)},mt=(e,t,r)=>{for(const[n,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${String(o)}`);return g("marginBox.width",t.width),g("marginBox.height",t.height),g("viewport.width",r.width),g("viewport.height",r.height),{left:te(e.left,e.right,r.width,t.width),top:te(e.top,e.bottom,r.height,t.height)}},ut=31536e3,ft=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Et=e=>{if(typeof e!="string"||!ft.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},re=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=q,gt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const r=e,{treeExplorer:n,multiExplorer:o,style:i,align:s}=r;return{...re(n)?{treeExplorer:n}:{},...re(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof s=="string"&&N.CONTENT_ALIGNS.includes(s)?{align:s}:{}}},wt=(e,t)=>{if(e!==null)for(const r of e.split(";")){const n=r.indexOf("=");if(!(n<0)&&r.slice(0,n).trim()===t)return r.slice(n+1).trim()}},pt=(e,t)=>{if(e===void 0||e==="")return{};try{return gt(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},L=100,St=Math.floor(q*L)/L,ht=e=>{const t=r=>Math.min(St,Math.max(1,Math.round(r*L))/L);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},_t=(e,t,r)=>`${e}=${ht(t)}; Path=/; Max-Age=${String(ut)}; SameSite=Lax${r?"; Secure":""}`,J=Object.freeze({tree:"tree",multi:"multi",single:"single"}),ue=Object.freeze({default:12,min:1,max:64}),fe=Object.freeze({default:4,min:1,max:6}),Ee=Object.freeze({default:500,min:1,max:1e4}),ge=Object.freeze({default:16,min:1,max:64}),we=Object.freeze({default:16,min:1,max:64}),xt=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,Ot=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,Tt=/^[a-z0-9][a-z0-9-]*$/u,bt=/^(?=.{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,ne=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!xt.test(t)||t.split("/").some(r=>r==="."||r===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},d=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?M(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),h=(e,t,r)=>{if(t===void 0)return[];if(!M(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);const n=Object.entries(t);for(const[o]of n)if(!r.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);return n.filter(([,o])=>o!==void 0)},yt=e=>{const t={...J};for(const[r,n]of h("views",e,Object.keys(J)))t[r]=n;for(const[r,n]of Object.entries(t))if(typeof n!="string"||!Ot.test(n))throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);return Object.freeze(t)},R=(e,t,r)=>{if(t===void 0)return r.default;if(typeof t!="number"||!Number.isInteger(t)||t<r.min||t>r.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);return t},Rt=(e,t)=>{const r=new Map(h("embeds",e,["providers","linkCards","linkCardSize"]));if(r.size===0)return y.NO_EMBEDS;const n=r.has("providers")?r.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(n)}`);for(const l of n)if(!y.isEmbedProviderId(l))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${y.EMBED_PROVIDER_IDS.join(", ")}; got ${d(l)}`);const o=r.has("linkCards")?r.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);const i={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?I.explorerLinkCardEndpoint(t):null};if(!r.has("linkCardSize"))return Object.freeze(i);const s=r.get("linkCardSize");if(!y.isLinkCardSize(s))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${y.LINK_CARD_SIZES.join(", ")}; got ${d(s)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(s)} with linkCards ${d(o)}`);return Object.freeze({...i,linkCardSize:s})},Nt=e=>{const t=new Map(h("defaultTreeSettings",e,_.map(n=>n.key)));if(t.size===0)return G;const r={...G};for(const n of _){if(!t.has(n.key))continue;const o=t.get(n.key),i=n.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(d).join(", ")}; got ${d(o)}`);r[n.key]=o}return Object.freeze(r)},pe=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");ne("basePath",e.basePath),ne("dataPath",e.dataPath);const t=yt(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const a=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(a===t.tree||a===t.multi||a===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}Et(e.settingsCookie);const r=e.iframeHosts??[];if(!Array.isArray(r)||r.some(a=>typeof a!="string"||!bt.test(a)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);const n=Object.fromEntries(h("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(h("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=Object.fromEntries(h("revealDocument",e.revealDocument,["maxDepth"])),s=e.documentStyles??N.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(s)||s.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const l=new Set;for(const a of s){if(a===null||typeof a!="object"||typeof a.name!="string"||a.name.trim()===""||typeof a.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(l.has(a.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(a.name)} repeats`);l.add(a.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:R("multiView.maxPanels",n.maxPanels,ue),columns:R("multiView.columns",n.columns,fe)}),expandAll:Object.freeze({maxFolders:R("expandAll.maxFolders",o.maxFolders,Ee),maxDepth:R("expandAll.maxDepth",o.maxDepth,ge)}),revealDocument:Object.freeze({maxDepth:R("revealDocument.maxDepth",i.maxDepth,we)}),documentStyles:Object.freeze(s.map(a=>Object.freeze({name:a.name,className:a.className}))),iframeHosts:Object.freeze([...new Set(r)]),embeds:Rt(e.embeds,e.dataPath),defaultTreeSettings:Nt(e.defaultTreeSettings)})},It=e=>{const t=e.embeds;if(!M(t))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);if(Object.hasOwn(t,"linkCards"))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 ${d(t.linkCards)})`);const{linkCardEndpoint:r,...n}=t,o=pe({...e,embeds:{...n,linkCards:r!==null}});if(o.embeds.linkCardEndpoint!==r)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(o.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);return o},Se=e=>typeof e=="string"&&Tt.test(e),At=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);for(const r of t)if(!Se(r))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},kt=e=>e.documentStyles.map(t=>t.name),c=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),he="true",C="/",oe=".data",_e=256,xe=/^\d+(?:\.\d+)?$/u,H=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,Oe=Object.freeze(["showToc","showStyle","showAlign"]),ie=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(oe)?`${t.slice(0,-oe.length)}%2Edata`:t},Pt=e=>e.replaceAll("%25","%"),Te=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},Lt=(e,t,r)=>{const n=r.getAll(c.source);if(n.length===0)return t;const[o]=n;return n.length>1||o===void 0||o===t||!e.includes(o)?null:o},Ct=(e,t)=>{const r=t.get(c.style),n=t.get(c.align);return{...r!==null&&e.documentStyles.some(o=>o.name===r)?{style:r}:{},...n!==null&&N.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},be=e=>Number.isFinite(e)&&e>=0&&e<=_e&&xe.test(String(e)),Mt=e=>{const t=e.get(c.padding),r=t!==null&&xe.test(t)?Number(t):Number.NaN,n=e.get(c.width),o=e.get(c.maxWidth);return{...e.get(c.showToc)==="false"?{showToc:!1}:{},...e.get(c.showStyle)==="false"?{showStyle:!1}:{},...e.get(c.showAlign)==="false"?{showAlign:!1}:{},...be(r)?{padding:r}:{},...n!==null&&H.test(n)?{width:n}:{},...o!==null&&H.test(o)?{maxWidth:o}:{}}},ye=(e,t)=>[...new Set(t.filter(I.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),vt=(e,t,r,n)=>{for(const i of t)B(i);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`);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)}`);if(r!==null&&!t.includes(r))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0,80))}`);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`);const o=n.find(i=>!t.includes(i));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0,80))}`)},B=e=>{if(!I.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},Dt=e=>{if(B(e).endsWith(C))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0,80))}`);return e},$t=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(r=>r.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(r=>JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!N.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${N.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},zt=e=>{for(const t of Oe)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!be(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(_e)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const r=e[t];if(r!==void 0&&!H.test(r))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`)}},Re=(e,t)=>{const r=new URLSearchParams;let n=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],s=t.maximized??null,l=t.markup??[];vt(e,i,s,l);for(const a of i)r.append(c.doc,a);s!==null&&r.set(c.maximized,s);for(const a of i)l.includes(a)&&r.append(c.markup,a)}else{const i=t.doc??null,s=t.view==="tree"?t.folder??null:null;if(i!==null&&s!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");i!==null&&(n+=`/${ie(Dt(i))}`),s!==null&&(n+=`/${ie(`${B(s)}${C}`)}`)}if(t.source!==void 0){const i=Te(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&r.set(c.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&($t(e,t.overrides),t.overrides.style!==void 0&&r.set(c.style,t.overrides.style),t.overrides.align!==void 0&&r.set(c.align,t.overrides.align)),t.view!=="multi"&&t.markup===!0){if(!(t.doc!==void 0&&t.doc!==null||t.view==="tree"&&t.folder!==void 0&&t.folder!==null))throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");r.set(c.markup,he)}if(t.view==="single"&&t.embed!==void 0){const{embed:i}=t;zt(i);for(const s of Oe)i[s]===!1&&r.set(c[s],"false");i.padding!==void 0&&r.set(c.padding,String(i.padding)),i.width!==void 0&&r.set(c.width,i.width),i.maxWidth!==void 0&&r.set(c.maxWidth,i.maxWidth)}const o=r.toString();return o===""?n:`${n}?${o}`},jt=(e,t)=>Object.keys(e.views).find(r=>e.views[r]===t),Ft=(e,t,r)=>{const n=Te(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=Lt(n,o,r),s=i===null?o:i,l=m=>({kind:"redirect",href:Re(e,m),location:m}),a=()=>l({view:"tree",source:s,doc:null,folder:null,overrides:{},markup:!1});if(t===void 0||t==="")return a();const x=t.indexOf("/"),v=x<0?t:t.slice(0,x),D=x<0?null:t.slice(x+1),w=jt(e,v);if(w===void 0)return a();if(w==="multi"){const m=r.getAll(c.doc),S=ye(e,m),$=r.getAll(c.maximized),[z]=$,j=$.length===1&&z!==void 0&&S.includes(z)?z:null,F=r.getAll(c.markup),P=S.filter(b=>F.includes(b)),Ne=P.length===F.length&&P.every((b,V)=>b===F[V]);return D===null&&i!==null&&S.length===m.length&&S.every((b,V)=>b===m[V])&&($.length===0||j!==null)&&Ne?{kind:"location",location:{view:"multi",source:s,docs:S,maximized:j,markup:P}}:l({view:"multi",source:s,docs:S,maximized:j,markup:P})}const k=D===null?null:Pt(D),f=k?.endsWith(C)===!0?k.slice(0,-C.length):null,E=k!==null&&f===null?k:null;if(E!==null&&!I.isAcceptableDocumentPath(E)||f!==null&&!I.isAcceptableDocumentPath(f))return a();const O=Ct(e,r),T=(E!==null||f!==null)&&r.get(c.markup)===he;if(w==="single"){if(f!==null)return l({view:"tree",source:s,doc:null,folder:f,overrides:O,markup:T});if(E===null)return a();const m=Mt(r);return i===null?l({view:w,source:s,doc:E,overrides:O,embed:m,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,overrides:O,embed:m,markup:T}}}return i===null?l({view:w,source:s,doc:E,folder:f,overrides:O,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,folder:f,overrides:O,markup:T}}};exports.ASSUMED_ROOT_FONT_PIXELS=He;exports.COARSE_TARGET_PIXELS=Be;exports.COLUMN_MIN_MEASURE=et;exports.CONTROL_BLOCK_PIXELS=ce;exports.DEFAULT_TREE_SETTINGS=G;exports.DEFAULT_VIEW_SLUGS=J;exports.EDIT_SPLIT_DEFAULT_PERCENT=ot;exports.EDIT_SPLIT_MAX_PERCENT=it;exports.EDIT_SPLIT_MIN_PERCENT=me;exports.EXPAND_ALL_DEPTH_LIMITS=ge;exports.EXPAND_ALL_FOLDER_LIMITS=Ee;exports.EXPLORER_DEFAULT_PERCENT=We;exports.EXPLORER_MAX_PERCENT=q;exports.EXPLORER_MIN_REM=le;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Je;exports.FINE_TARGET_PIXELS=Ze;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=fe;exports.MULTI_VIEW_PANEL_LIMITS=ue;exports.NAME_COLLATOR=A;exports.NO_TREE_SETTING_CHANGES=W;exports.PANEL_MAX_BLOCK_RATIO=Ye;exports.PANEL_MIN_BLOCK_RATIO=Qe;exports.PREFETCH_DWELL_MS=st;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=we;exports.SPLIT_HANDLE_PIXELS=Ke;exports.SPLIT_PERSIST_DELAY_MS=nt;exports.advanceTreeSetting=De;exports.applyTreeSettingChanges=Fe;exports.canonicalMultiDocuments=ye;exports.centeredDialogPosition=mt;exports.columnGroups=ct;exports.createEntryComparator=Ge;exports.defineExplorerConfig=pe;exports.documentStyleNames=kt;exports.editSplitOrientation=dt;exports.explorerHref=Re;exports.explorerMinPixels=de;exports.explorerSheetBelowPixels=rt;exports.folderReadmeOf=Pe;exports.formatTreeSettingValue=$e;exports.isExplorerSourceId=Se;exports.isPlainObject=M;exports.parseViewSettings=pt;exports.readCookieValue=wt;exports.readTreeSettingChanges=je;exports.recordTreeSettingChange=Ve;exports.replanVisibleColumns=lt;exports.resolveExplorerLocation=Ft;exports.revalidateExplorerConfig=It;exports.serializeTreeSettingChanges=Ue;exports.viewSettingsCookieString=_t;exports.visibleTreeSettingDescriptors=ve;exports.withExplorerSources=At;
1
+ "use strict";const y=require("@aiquants/markdown/embeds"),N=require("@aiquants/markdown/viewer-settings"),I=require("./dataRoute-vXGZMVB-.cjs"),M=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},A=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),Ie=/^readme(?:\.|$)/iu,Z=/^readme(?:\.[^.]*)?$/iu,Y=Object.freeze(["md","markdown","mdx","txt",""]),Ae=e=>Ie.test(e),X=e=>e.type==="file"&&Ae(e.name),Q=e=>{const t=e.lastIndexOf("."),r=Y.indexOf(t<0?"":e.slice(t+1).toLowerCase());return r<0?Y.length:r},ke=(e,t)=>{const r=+!Z.test(e.name)-+!Z.test(t.name);if(r!==0)return r;const n=Q(e.name)-Q(t.name);if(n!==0)return n;const o=A.compare(e.name,t.name);return o!==0?o:A.compare(e.path,t.path)},Pe=e=>{let t=null;for(const r of e)X(r)&&(t===null||ke(r,t)<0)&&(t=r);return t===null?null:t.path},G=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),Le=[!0,!1],Ce=(e,t)=>t?e.settingOn:e.settingOff,p=(e,t)=>({key:e,labelKey:t,values:Le,formatValue:Ce,requiresItemSelection:!1}),Me=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),_=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,t)=>Me[t](e),requiresItemSelection:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.folderPlacementMixed:t==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresItemSelection:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.readmePlacementMixed:t==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresItemSelection:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},p("alwaysExpanded","settingAlwaysExpanded"),p("revealDocument","settingRevealDocument"),p("removeRootIndent","settingRemoveRootIndent"),p("lines","settingTreeLines"),p("expandIcons","settingExpandIcons"),p("directoryIcons","settingDirectoryIcons"),p("fileIcons","settingFileIcons")]),ve=e=>e?_:_.filter(t=>!t.requiresItemSelection),se=e=>{const t=_.find(r=>r.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},De=(e,t)=>{const r=se(t).values,n=r[(r.indexOf(e[t])+1)%r.length];return{...e,[t]:n}},$e=(e,t,r)=>se(r).formatValue(e,t[r]),ae=2,W=Object.freeze({}),K=(e,t)=>Object.freeze(Object.fromEntries(_.filter(r=>t(r,e[r.key])).map(r=>[r.key,e[r.key]]))),ee="directoriesFirst",ze=e=>{if(!Object.hasOwn(e,ee))return e;const{[ee]:t,...r}=e;return Object.hasOwn(r,"folderPlacement")||typeof t!="boolean"?r:{...r,folderPlacement:t?"first":"mixed"}},je=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return W;const t=e;return t.version!==ae||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?W:K(ze(t.settings),(r,n)=>r.values.includes(n))},Fe=(e,t)=>{const r=K(t,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(r).length===0?e:Object.freeze({...e,...r})},Ve=(e,t,r,n)=>K({...e,[t]:r},(o,i)=>i!==void 0&&!(o.key===t&&i===n[t])),Ue=e=>JSON.stringify({version:ae,settings:e}),Xe=(e,t,r)=>e===void 0||t===void 0?e===t?0:e===void 0?1:-1:r*(e-t),Ge=e=>{const{sortMode:t,folderPlacement:r,readmePlacement:n}=e;if(t==="native"&&r==="mixed"&&n==="mixed")return;const o=(i,s)=>{const l=A.compare(i.name,s.name);return l!==0?l:A.compare(i.path,s.path)};return(i,s)=>{if(r!=="mixed"&&i.type!==s.type)return i.type==="directory"==(r==="first")?-1:1;if(n!=="mixed"){const a=X(i);if(a!==X(s))return a===(n==="first")?-1:1}if(t==="native")return 0;if(t==="asc")return o(i,s);if(t==="desc")return-o(i,s);const l=Xe(i.modifiedAt,s.modifiedAt,t==="oldest"?1:-1);return l!==0?l:o(i,s)}},u=(1+Math.sqrt(5))/2,We=100/u**3,Je=100/u**4,q=100/u**2,le=13,He=16,Ke=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),qe=Object.freeze([89,144,233,377]),ce=44,Be=ce,Ze=24,Ye=1/u,Qe=1/u**3,et="40ch",tt=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},de=e=>(tt(e),le*e),rt=e=>de(e)*u**2,nt=233,ot=50,me=100/u**3,it=100-me,st=qe[0],g=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},at=({trackInlineSize:e,gap:t,minColumnInlineSize:r,logicalColumns:n})=>{if(g("trackInlineSize",e),g("gap",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);const o=Math.floor((e+t)/(r+t));return Math.min(n,Math.max(1,o))},lt=(e,t)=>{const{trackInlineSize:r,gap:n,minColumnInlineSize:o,logicalColumns:i}=t;if(!([r,n,o].every(Number.isFinite)&&r>0&&n>=0&&o>0))return e;const l=at(t);if(e===null||l===e)return l;const a=Math.min(i,Math.max(1,e));if(l>a){const v=(a+1)*o+a*n+n/u;return r>=v?l:a}return r>=a*o+(a-1)*n?a:l},ct=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(r,n)=>[Math.floor(n*e/t),Math.floor((n+1)*e/t)])},dt=(e,t,r)=>{if(g("surfaceInlineSize",e),g("handlePixels",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);return e>=2*t+r?"beside":"stacked"},U=(e,t,r)=>Math.max(t,Math.min(e,r)),te=(e,t,r,n)=>{const o=(U(e,0,r)+U(t,0,r))/2;return U(o-n/2,0,r-n)},mt=(e,t,r)=>{for(const[n,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${String(o)}`);return g("marginBox.width",t.width),g("marginBox.height",t.height),g("viewport.width",r.width),g("viewport.height",r.height),{left:te(e.left,e.right,r.width,t.width),top:te(e.top,e.bottom,r.height,t.height)}},ut=31536e3,ft=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Et=e=>{if(typeof e!="string"||!ft.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},re=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=q,gt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const r=e,{treeExplorer:n,multiExplorer:o,style:i,align:s}=r;return{...re(n)?{treeExplorer:n}:{},...re(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof s=="string"&&N.CONTENT_ALIGNS.includes(s)?{align:s}:{}}},wt=(e,t)=>{if(e!==null)for(const r of e.split(";")){const n=r.indexOf("=");if(!(n<0)&&r.slice(0,n).trim()===t)return r.slice(n+1).trim()}},pt=(e,t)=>{if(e===void 0||e==="")return{};try{return gt(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},L=100,St=Math.floor(q*L)/L,ht=e=>{const t=r=>Math.min(St,Math.max(1,Math.round(r*L))/L);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},_t=(e,t,r)=>`${e}=${ht(t)}; Path=/; Max-Age=${String(ut)}; SameSite=Lax${r?"; Secure":""}`,J=Object.freeze({tree:"tree",multi:"multi",single:"single"}),ue=Object.freeze({default:12,min:1,max:64}),fe=Object.freeze({default:4,min:1,max:6}),Ee=Object.freeze({default:500,min:1,max:1e4}),ge=Object.freeze({default:16,min:1,max:64}),we=Object.freeze({default:16,min:1,max:64}),xt=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,Ot=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,Tt=/^[a-z0-9][a-z0-9-]*$/u,bt=/^(?=.{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,ne=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!xt.test(t)||t.split("/").some(r=>r==="."||r===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},d=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?M(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),h=(e,t,r)=>{if(t===void 0)return[];if(!M(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);const n=Object.entries(t);for(const[o]of n)if(!r.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);return n.filter(([,o])=>o!==void 0)},yt=e=>{const t={...J};for(const[r,n]of h("views",e,Object.keys(J)))t[r]=n;for(const[r,n]of Object.entries(t))if(typeof n!="string"||!Ot.test(n))throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);return Object.freeze(t)},R=(e,t,r)=>{if(t===void 0)return r.default;if(typeof t!="number"||!Number.isInteger(t)||t<r.min||t>r.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);return t},Rt=(e,t)=>{const r=new Map(h("embeds",e,["providers","linkCards","linkCardSize"]));if(r.size===0)return y.NO_EMBEDS;const n=r.has("providers")?r.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(n)}`);for(const l of n)if(!y.isEmbedProviderId(l))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${y.EMBED_PROVIDER_IDS.join(", ")}; got ${d(l)}`);const o=r.has("linkCards")?r.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);const i={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?I.explorerLinkCardEndpoint(t):null};if(!r.has("linkCardSize"))return Object.freeze(i);const s=r.get("linkCardSize");if(!y.isLinkCardSize(s))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${y.LINK_CARD_SIZES.join(", ")}; got ${d(s)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(s)} with linkCards ${d(o)}`);return Object.freeze({...i,linkCardSize:s})},Nt=e=>{const t=new Map(h("defaultTreeSettings",e,_.map(n=>n.key)));if(t.size===0)return G;const r={...G};for(const n of _){if(!t.has(n.key))continue;const o=t.get(n.key),i=n.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(d).join(", ")}; got ${d(o)}`);r[n.key]=o}return Object.freeze(r)},pe=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");ne("basePath",e.basePath),ne("dataPath",e.dataPath);const t=yt(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const a=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(a===t.tree||a===t.multi||a===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}Et(e.settingsCookie);const r=e.iframeHosts??[];if(!Array.isArray(r)||r.some(a=>typeof a!="string"||!bt.test(a)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);const n=Object.fromEntries(h("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(h("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=Object.fromEntries(h("revealDocument",e.revealDocument,["maxDepth"])),s=e.documentStyles??N.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(s)||s.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const l=new Set;for(const a of s){if(a===null||typeof a!="object"||typeof a.name!="string"||a.name.trim()===""||typeof a.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(l.has(a.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(a.name)} repeats`);l.add(a.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:R("multiView.maxPanels",n.maxPanels,ue),columns:R("multiView.columns",n.columns,fe)}),expandAll:Object.freeze({maxFolders:R("expandAll.maxFolders",o.maxFolders,Ee),maxDepth:R("expandAll.maxDepth",o.maxDepth,ge)}),revealDocument:Object.freeze({maxDepth:R("revealDocument.maxDepth",i.maxDepth,we)}),documentStyles:Object.freeze(s.map(a=>Object.freeze({name:a.name,className:a.className}))),iframeHosts:Object.freeze([...new Set(r)]),embeds:Rt(e.embeds,e.dataPath),defaultTreeSettings:Nt(e.defaultTreeSettings)})},It=e=>{const t=e.embeds;if(!M(t))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);if(Object.hasOwn(t,"linkCards"))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 ${d(t.linkCards)})`);const{linkCardEndpoint:r,...n}=t,o=pe({...e,embeds:{...n,linkCards:r!==null}});if(o.embeds.linkCardEndpoint!==r)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(o.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);return o},Se=e=>typeof e=="string"&&Tt.test(e),At=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);for(const r of t)if(!Se(r))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},kt=e=>e.documentStyles.map(t=>t.name),c=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),he="true",C="/",oe=".data",_e=256,xe=/^\d+(?:\.\d+)?$/u,H=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,Oe=Object.freeze(["showToc","showStyle","showAlign"]),ie=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(oe)?`${t.slice(0,-oe.length)}%2Edata`:t},Pt=e=>e.replaceAll("%25","%"),Te=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},Lt=(e,t,r)=>{const n=r.getAll(c.source);if(n.length===0)return t;const[o]=n;return n.length>1||o===void 0||o===t||!e.includes(o)?null:o},Ct=(e,t)=>{const r=t.get(c.style),n=t.get(c.align);return{...r!==null&&e.documentStyles.some(o=>o.name===r)?{style:r}:{},...n!==null&&N.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},be=e=>Number.isFinite(e)&&e>=0&&e<=_e&&xe.test(String(e)),Mt=e=>{const t=e.get(c.padding),r=t!==null&&xe.test(t)?Number(t):Number.NaN,n=e.get(c.width),o=e.get(c.maxWidth);return{...e.get(c.showToc)==="false"?{showToc:!1}:{},...e.get(c.showStyle)==="false"?{showStyle:!1}:{},...e.get(c.showAlign)==="false"?{showAlign:!1}:{},...be(r)?{padding:r}:{},...n!==null&&H.test(n)?{width:n}:{},...o!==null&&H.test(o)?{maxWidth:o}:{}}},ye=(e,t)=>[...new Set(t.filter(I.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),vt=(e,t,r,n)=>{for(const i of t)B(i);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`);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)}`);if(r!==null&&!t.includes(r))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0,80))}`);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`);const o=n.find(i=>!t.includes(i));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0,80))}`)},B=e=>{if(!I.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},Dt=e=>{if(B(e).endsWith(C))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0,80))}`);return e},$t=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(r=>r.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(r=>JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!N.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${N.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},zt=e=>{for(const t of Oe)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!be(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(_e)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const r=e[t];if(r!==void 0&&!H.test(r))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`)}},Re=(e,t)=>{const r=new URLSearchParams;let n=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],s=t.maximized??null,l=t.markup??[];vt(e,i,s,l);for(const a of i)r.append(c.doc,a);s!==null&&r.set(c.maximized,s);for(const a of i)l.includes(a)&&r.append(c.markup,a)}else{const i=t.doc??null,s=t.view==="tree"?t.folder??null:null;if(i!==null&&s!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");i!==null&&(n+=`/${ie(Dt(i))}`),s!==null&&(n+=`/${ie(`${B(s)}${C}`)}`)}if(t.source!==void 0){const i=Te(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&r.set(c.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&($t(e,t.overrides),t.overrides.style!==void 0&&r.set(c.style,t.overrides.style),t.overrides.align!==void 0&&r.set(c.align,t.overrides.align)),t.view!=="multi"&&t.markup===!0){if(!(t.doc!==void 0&&t.doc!==null||t.view==="tree"&&t.folder!==void 0&&t.folder!==null))throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");r.set(c.markup,he)}if(t.view==="single"&&t.embed!==void 0){const{embed:i}=t;zt(i);for(const s of Oe)i[s]===!1&&r.set(c[s],"false");i.padding!==void 0&&r.set(c.padding,String(i.padding)),i.width!==void 0&&r.set(c.width,i.width),i.maxWidth!==void 0&&r.set(c.maxWidth,i.maxWidth)}const o=r.toString();return o===""?n:`${n}?${o}`},jt=(e,t)=>Object.keys(e.views).find(r=>e.views[r]===t),Ft=(e,t,r)=>{const n=Te(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=Lt(n,o,r),s=i===null?o:i,l=m=>({kind:"redirect",href:Re(e,m),location:m}),a=()=>l({view:"tree",source:s,doc:null,folder:null,overrides:{},markup:!1});if(t===void 0||t==="")return a();const x=t.indexOf("/"),v=x<0?t:t.slice(0,x),D=x<0?null:t.slice(x+1),w=jt(e,v);if(w===void 0)return a();if(w==="multi"){const m=r.getAll(c.doc),S=ye(e,m),$=r.getAll(c.maximized),[z]=$,j=$.length===1&&z!==void 0&&S.includes(z)?z:null,F=r.getAll(c.markup),P=S.filter(b=>F.includes(b)),Ne=P.length===F.length&&P.every((b,V)=>b===F[V]);return D===null&&i!==null&&S.length===m.length&&S.every((b,V)=>b===m[V])&&($.length===0||j!==null)&&Ne?{kind:"location",location:{view:"multi",source:s,docs:S,maximized:j,markup:P}}:l({view:"multi",source:s,docs:S,maximized:j,markup:P})}const k=D===null?null:Pt(D),f=k?.endsWith(C)===!0?k.slice(0,-C.length):null,E=k!==null&&f===null?k:null;if(E!==null&&!I.isAcceptableDocumentPath(E)||f!==null&&!I.isAcceptableDocumentPath(f))return a();const O=Ct(e,r),T=(E!==null||f!==null)&&r.get(c.markup)===he;if(w==="single"){if(f!==null)return l({view:"tree",source:s,doc:null,folder:f,overrides:O,markup:T});if(E===null)return a();const m=Mt(r);return i===null?l({view:w,source:s,doc:E,overrides:O,embed:m,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,overrides:O,embed:m,markup:T}}}return i===null?l({view:w,source:s,doc:E,folder:f,overrides:O,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,folder:f,overrides:O,markup:T}}};exports.ASSUMED_ROOT_FONT_PIXELS=He;exports.COARSE_TARGET_PIXELS=Be;exports.COLUMN_MIN_MEASURE=et;exports.CONTROL_BLOCK_PIXELS=ce;exports.DEFAULT_TREE_SETTINGS=G;exports.DEFAULT_VIEW_SLUGS=J;exports.EDIT_SPLIT_DEFAULT_PERCENT=ot;exports.EDIT_SPLIT_MAX_PERCENT=it;exports.EDIT_SPLIT_MIN_PERCENT=me;exports.EXPAND_ALL_DEPTH_LIMITS=ge;exports.EXPAND_ALL_FOLDER_LIMITS=Ee;exports.EXPLORER_DEFAULT_PERCENT=We;exports.EXPLORER_MAX_PERCENT=q;exports.EXPLORER_MIN_REM=le;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Je;exports.FINE_TARGET_PIXELS=Ze;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=fe;exports.MULTI_VIEW_PANEL_LIMITS=ue;exports.NAME_COLLATOR=A;exports.NO_TREE_SETTING_CHANGES=W;exports.PANEL_MAX_BLOCK_RATIO=Ye;exports.PANEL_MIN_BLOCK_RATIO=Qe;exports.PREFETCH_DWELL_MS=st;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=we;exports.SPLIT_HANDLE_PIXELS=Ke;exports.SPLIT_PERSIST_DELAY_MS=nt;exports.advanceTreeSetting=De;exports.applyTreeSettingChanges=Fe;exports.canonicalMultiDocuments=ye;exports.centeredDialogPosition=mt;exports.columnGroups=ct;exports.createEntryComparator=Ge;exports.defineExplorerConfig=pe;exports.documentStyleNames=kt;exports.editSplitOrientation=dt;exports.explorerHref=Re;exports.explorerMinPixels=de;exports.explorerSheetBelowPixels=rt;exports.folderReadmeOf=Pe;exports.formatTreeSettingValue=$e;exports.isExplorerSourceId=Se;exports.isPlainObject=M;exports.parseViewSettings=pt;exports.readCookieValue=wt;exports.readTreeSettingChanges=je;exports.recordTreeSettingChange=Ve;exports.replanVisibleColumns=lt;exports.resolveExplorerLocation=Ft;exports.revalidateExplorerConfig=It;exports.serializeTreeSettingChanges=Ue;exports.viewSettingsCookieString=_t;exports.visibleTreeSettingDescriptors=ve;exports.withExplorerSources=At;
@@ -1,5 +1,5 @@
1
1
  import { diff3Merge as d } from "node-diff3";
2
- import { C, a as R, b as u } from "./index-CJgHGeZs.js";
2
+ import { C, a as R, b as u } from "./index-Jz6zeO4O.js";
3
3
  const g = (n, o, e, l) => {
4
4
  if (o === n || o === e) return { kind: "clean", text: e };
5
5
  if (e === n) return { kind: "clean", text: o };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-bMaSoQTe.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-BNFl3BsO.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
2
2
  `),n.split(`
3
3
  `),i.split(`
4
4
  `),{excludeFalseConflicts:!0}),o=[];let c=0;const u=s(l.ours),a=s(l.theirs);for(const e of d)e.ok!==void 0?o.push(...e.ok):e.conflict!==void 0&&(c+=1,o.push(`${r.CONFLICT_OURS_MARKER} ${u}`,...e.conflict.a,r.CONFLICT_SEPARATOR,...e.conflict.b,`${r.CONFLICT_THEIRS_MARKER} ${a}`));const f=o.join(`
@@ -1,7 +1,7 @@
1
1
  import { CODE_META_ATTRIBUTE as w } from "@aiquants/markdown/code-blocks";
2
2
  import { allowedFrameUrlOf as O, reduceFrameFeatures as L, EMBED_FRAME_REFERRER_POLICIES as D, EMBED_LINK_ATTRIBUTE as T, placeholderLinkOf as I } from "@aiquants/markdown/embeds";
3
3
  import { SOURCE_LINES_ATTRIBUTE as E, parseSourceLines as z } from "@aiquants/markdown/source-lines";
4
- import { i as M, e as x } from "./dataRoute-CObbjNxG.js";
4
+ import { i as M, e as x } from "./dataRoute-Diu_7gle.js";
5
5
  const ee = 512;
6
6
  class H extends RangeError {
7
7
  constructor(o) {
@@ -1 +1 @@
1
- "use strict";const O=require("@aiquants/markdown/code-blocks"),i=require("@aiquants/markdown/embeds"),E=require("@aiquants/markdown/source-lines"),R=require("./dataRoute-BONacTPi.cjs"),w=512;class h extends RangeError{constructor(s){super(`[markdown-explorer] the HTML nests deeper than ${String(s)} levels`),this.name="HtmlNestingLimitError"}}const D=["script","style","noscript","template","form","button","textarea","select","option","object","embed","base","meta","link","frame","frameset"],z=["srcdoc","formaction"],M=/^(?:(?:https?|mailto|tel):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/iu,B=new Set(["left","right","center","justify","start","end"]),H=new Set(["h1","h2","h3","h4","h5","h6"]),T=1,U=3,C=7,x=8,k=Object.freeze({a:Object.freeze(["target","data-link-kind","data-doc-path","data-doc-exists","data-footnote-ref","data-footnote-backref"]),area:Object.freeze(["target"]),img:Object.freeze(["data-asset-src","data-asset-exists"]),section:Object.freeze(["data-footnotes"]),code:Object.freeze([O.CODE_META_ATTRIBUTE]),iframe:Object.freeze(["allow","allowfullscreen","frameborder","referrerpolicy"])}),j=[...new Set([...Object.values(k).flatMap(t=>t.filter(s=>s.startsWith("data-"))),E.SOURCE_LINES_ATTRIBUTE])],F=new Set(["src","href","xlink:href"]),G=/^data:/iu,y=Object.freeze({FORBID_TAGS:D,FORBID_ATTR:z,ADD_TAGS:["iframe"],ADD_ATTR:(t,s)=>t===E.SOURCE_LINES_ATTRIBUTE||k[s]?.includes(t)===!0,ADD_URI_SAFE_ATTR:j,ALLOWED_URI_REGEXP:M,ALLOW_DATA_ATTR:!1}),V=t=>{let s=null;for(const c of t.split(";")){const n=c.indexOf(":");if(n<0||c.slice(0,n).trim().toLowerCase()!=="text-align")continue;const d=c.slice(n+1).trim().toLowerCase();B.has(d)&&(s=d)}return s===null?null:`text-align: ${s}`},P=t=>t.nodeType===U?{kind:"text",text:t.nodeValue??""}:t.nodeType===x||t.nodeType===C?{kind:"ignored"}:t.nodeType===T&&t.nodeName.toLowerCase()==="a"?{kind:"link",href:t.getAttribute("href")}:{kind:"element"},W=t=>{const s=t.getAttribute("type");return s!==null&&s.trim().toLowerCase()==="checkbox"&&t.hasAttribute("disabled")},X=(t,s,c,n)=>{if(t.isSupported!==!0)throw new Error("[markdown-explorer] the HTML sanitizer cannot run in this environment");if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`[markdown-explorer] the HTML sanitizer's depth limit must be a positive integer; got ${String(n)}`);const d=Object.freeze([...s]);let A=new WeakMap,m=new WeakMap,f;const _=r=>{const e=r.parentNode===null?void 0:A.get(r.parentNode),a=e===void 0?0:e+1;if(A.set(r,a),r.nodeType===T&&a>n)throw new h(n)},p=(r,e)=>{if(r.nodeType!==T)return;const a=r;(e.tagName==="input"&&!W(a)||e.tagName==="iframe"&&i.allowedFrameUrlOf(a.getAttribute("src")?.trim(),d)===null)&&a.parentNode?.removeChild(a)},N=(r,e)=>{const a=r.nodeName.toLowerCase();if(e.attrName==="style"){const o=V(e.attrValue);o===null?e.keepAttr=!1:e.attrValue=o}else if(e.attrName==="allow"&&a==="iframe"){const o=i.reduceFrameFeatures(e.attrValue);o===null?e.keepAttr=!1:e.attrValue=o}else if(e.attrName==="referrerpolicy"&&a==="iframe"){const o=e.attrValue.trim().toLowerCase();i.EMBED_FRAME_REFERRER_POLICIES.has(o)?e.attrValue=o:e.keepAttr=!1}else e.attrName===i.EMBED_LINK_ATTRIBUTE&&a==="p"?m.set(r,r.getAttribute(i.EMBED_LINK_ATTRIBUTE)):F.has(e.attrName)&&G.test(e.attrValue)||e.attrName===E.SOURCE_LINES_ATTRIBUTE&&E.parseSourceLines(e.attrValue)===null?e.keepAttr=!1:e.attrName==="id"&&H.has(a)&&(e.forceKeepAttr=!0)},g=r=>{const e=r.getAttribute("data-asset-src");e!==null&&(r.getAttribute("data-asset-exists")!=="false"&&R.isAcceptableDocumentPath(e)?r.setAttribute("src",R.explorerAssetHref(c,e,null)):r.removeAttribute("src"))},S=(r,e,a,o)=>{if(f===void 0)return;const u=r.getAttribute(a);if(u===null)return;const l=f({kind:e,path:u});l!==void 0&&r.setAttribute(o,String(l))},I=r=>{const e=r.parentNode;if(e===null)return;const a=m.get(e);a!=null&&i.placeholderLinkOf(a,[...e.childNodes].map(P))!==null&&e.setAttribute(i.EMBED_LINK_ATTRIBUTE,a)},b=r=>{if(r.nodeType!==T)return;const e=r,a=e.nodeName.toLowerCase();a==="img"?(S(e,"asset","data-asset-src","data-asset-exists"),g(e)):a==="a"&&(S(e,"doc","data-doc-path","data-doc-exists"),I(e));const o=e.getAttribute("target");if(o===null||o.trim().toLowerCase()==="_self")return;const u=e.getAttribute("rel"),l=new Set(u===null?[]:u.split(/\s+/u).filter(L=>L!==""));l.add("noopener"),l.add("noreferrer"),e.setAttribute("rel",[...l].join(" "))};return(r,e)=>{A=new WeakMap,m=new WeakMap,f=e,t.addHook("beforeSanitizeElements",_),t.addHook("uponSanitizeElement",p),t.addHook("uponSanitizeAttribute",N),t.addHook("afterSanitizeAttributes",b);try{return t.sanitize(r,y)}finally{t.removeHook("beforeSanitizeElements",_),t.removeHook("uponSanitizeElement",p),t.removeHook("uponSanitizeAttribute",N),t.removeHook("afterSanitizeAttributes",b),f=void 0}}};exports.HtmlNestingLimitError=h;exports.MAX_HTML_NESTING_DEPTH=w;exports.createHtmlSanitizer=X;
1
+ "use strict";const O=require("@aiquants/markdown/code-blocks"),i=require("@aiquants/markdown/embeds"),E=require("@aiquants/markdown/source-lines"),R=require("./dataRoute-vXGZMVB-.cjs"),w=512;class h extends RangeError{constructor(s){super(`[markdown-explorer] the HTML nests deeper than ${String(s)} levels`),this.name="HtmlNestingLimitError"}}const D=["script","style","noscript","template","form","button","textarea","select","option","object","embed","base","meta","link","frame","frameset"],z=["srcdoc","formaction"],M=/^(?:(?:https?|mailto|tel):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/iu,B=new Set(["left","right","center","justify","start","end"]),H=new Set(["h1","h2","h3","h4","h5","h6"]),T=1,U=3,C=7,x=8,k=Object.freeze({a:Object.freeze(["target","data-link-kind","data-doc-path","data-doc-exists","data-footnote-ref","data-footnote-backref"]),area:Object.freeze(["target"]),img:Object.freeze(["data-asset-src","data-asset-exists"]),section:Object.freeze(["data-footnotes"]),code:Object.freeze([O.CODE_META_ATTRIBUTE]),iframe:Object.freeze(["allow","allowfullscreen","frameborder","referrerpolicy"])}),j=[...new Set([...Object.values(k).flatMap(t=>t.filter(s=>s.startsWith("data-"))),E.SOURCE_LINES_ATTRIBUTE])],F=new Set(["src","href","xlink:href"]),G=/^data:/iu,y=Object.freeze({FORBID_TAGS:D,FORBID_ATTR:z,ADD_TAGS:["iframe"],ADD_ATTR:(t,s)=>t===E.SOURCE_LINES_ATTRIBUTE||k[s]?.includes(t)===!0,ADD_URI_SAFE_ATTR:j,ALLOWED_URI_REGEXP:M,ALLOW_DATA_ATTR:!1}),V=t=>{let s=null;for(const c of t.split(";")){const n=c.indexOf(":");if(n<0||c.slice(0,n).trim().toLowerCase()!=="text-align")continue;const d=c.slice(n+1).trim().toLowerCase();B.has(d)&&(s=d)}return s===null?null:`text-align: ${s}`},P=t=>t.nodeType===U?{kind:"text",text:t.nodeValue??""}:t.nodeType===x||t.nodeType===C?{kind:"ignored"}:t.nodeType===T&&t.nodeName.toLowerCase()==="a"?{kind:"link",href:t.getAttribute("href")}:{kind:"element"},W=t=>{const s=t.getAttribute("type");return s!==null&&s.trim().toLowerCase()==="checkbox"&&t.hasAttribute("disabled")},X=(t,s,c,n)=>{if(t.isSupported!==!0)throw new Error("[markdown-explorer] the HTML sanitizer cannot run in this environment");if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`[markdown-explorer] the HTML sanitizer's depth limit must be a positive integer; got ${String(n)}`);const d=Object.freeze([...s]);let A=new WeakMap,m=new WeakMap,f;const _=r=>{const e=r.parentNode===null?void 0:A.get(r.parentNode),a=e===void 0?0:e+1;if(A.set(r,a),r.nodeType===T&&a>n)throw new h(n)},p=(r,e)=>{if(r.nodeType!==T)return;const a=r;(e.tagName==="input"&&!W(a)||e.tagName==="iframe"&&i.allowedFrameUrlOf(a.getAttribute("src")?.trim(),d)===null)&&a.parentNode?.removeChild(a)},N=(r,e)=>{const a=r.nodeName.toLowerCase();if(e.attrName==="style"){const o=V(e.attrValue);o===null?e.keepAttr=!1:e.attrValue=o}else if(e.attrName==="allow"&&a==="iframe"){const o=i.reduceFrameFeatures(e.attrValue);o===null?e.keepAttr=!1:e.attrValue=o}else if(e.attrName==="referrerpolicy"&&a==="iframe"){const o=e.attrValue.trim().toLowerCase();i.EMBED_FRAME_REFERRER_POLICIES.has(o)?e.attrValue=o:e.keepAttr=!1}else e.attrName===i.EMBED_LINK_ATTRIBUTE&&a==="p"?m.set(r,r.getAttribute(i.EMBED_LINK_ATTRIBUTE)):F.has(e.attrName)&&G.test(e.attrValue)||e.attrName===E.SOURCE_LINES_ATTRIBUTE&&E.parseSourceLines(e.attrValue)===null?e.keepAttr=!1:e.attrName==="id"&&H.has(a)&&(e.forceKeepAttr=!0)},g=r=>{const e=r.getAttribute("data-asset-src");e!==null&&(r.getAttribute("data-asset-exists")!=="false"&&R.isAcceptableDocumentPath(e)?r.setAttribute("src",R.explorerAssetHref(c,e,null)):r.removeAttribute("src"))},S=(r,e,a,o)=>{if(f===void 0)return;const u=r.getAttribute(a);if(u===null)return;const l=f({kind:e,path:u});l!==void 0&&r.setAttribute(o,String(l))},I=r=>{const e=r.parentNode;if(e===null)return;const a=m.get(e);a!=null&&i.placeholderLinkOf(a,[...e.childNodes].map(P))!==null&&e.setAttribute(i.EMBED_LINK_ATTRIBUTE,a)},b=r=>{if(r.nodeType!==T)return;const e=r,a=e.nodeName.toLowerCase();a==="img"?(S(e,"asset","data-asset-src","data-asset-exists"),g(e)):a==="a"&&(S(e,"doc","data-doc-path","data-doc-exists"),I(e));const o=e.getAttribute("target");if(o===null||o.trim().toLowerCase()==="_self")return;const u=e.getAttribute("rel"),l=new Set(u===null?[]:u.split(/\s+/u).filter(L=>L!==""));l.add("noopener"),l.add("noreferrer"),e.setAttribute("rel",[...l].join(" "))};return(r,e)=>{A=new WeakMap,m=new WeakMap,f=e,t.addHook("beforeSanitizeElements",_),t.addHook("uponSanitizeElement",p),t.addHook("uponSanitizeAttribute",N),t.addHook("afterSanitizeAttributes",b);try{return t.sanitize(r,y)}finally{t.removeHook("beforeSanitizeElements",_),t.removeHook("uponSanitizeElement",p),t.removeHook("uponSanitizeAttribute",N),t.removeHook("afterSanitizeAttributes",b),f=void 0}}};exports.HtmlNestingLimitError=h;exports.MAX_HTML_NESTING_DEPTH=w;exports.createHtmlSanitizer=X;
@@ -1 +1 @@
1
- "use strict";const J=require("node:worker_threads"),W=require("isomorphic-dompurify"),M=require("./sanitizePolicy-gEXeavb-.cjs"),A=require("parse5"),K=4096,P=1024,B=Symbol("placement"),G=2,Y=3,Z=new Set(["html","head","body"]),S=0,v=1,I=2,z=3,U=4,C=5,N=6,w=7,F=8,b=9,Q=10,m=-1,ee=0,te=1,re=2,ne=3,se=4,oe=5,q=6,ae=7,ie=t=>{switch(t){case 9:case 10:case 12:case 13:case 32:return ee;case 47:return te;case 62:return re;case 61:return ne;case 34:return se;case 39:return oe;default:return q}},ce=Uint8Array.from({length:128},(t,i)=>ie(i)),x=60,V=47,le=/[\t\n\f\r />="'<]/g,ue=/["<]/g,fe=/['<]/g,f=-1-I,de=Int8Array.from([[v,b,m,S,S,S,S],[v,b,m,f,f,f,f],[z,b,m,U,I,I,I],[z,b,m,U,f,f,f],[U,w,m,w,C,N,w],[C,C,C,C,F,C,C],[N,N,N,N,N,F,N],[v,w,m,w,w,w,w],[v,b,m,f,f,f,f],[v,b,m,f,f,f,f]].flat()),$=t=>t>=65&&t<=90||t>=97&&t<=122,Ee=(t,i)=>{let c=new Int32Array(Q),l=new Int32Array(Q),o=0,p=0,n=0;for(;n<t.length;){if(o===0){const u=t.indexOf("<",n);if(u<0)return!1;n=u+1,t.charCodeAt(n)===V&&(n+=1),$(t.charCodeAt(n))&&(c[S]=0,o=1<<S,n+=1);continue}if((o&-230)===0&&n>=p){const u=o===1<<C?ue:o===1<<N?fe:le;u.lastIndex=n;const _=u.exec(t);if(_===null)return!1;n=_.index,t.charCodeAt(n)===x&&(p=n+3)}const d=t.charCodeAt(n),g=d<128?ce[d]:q;let h=0;for(let u=o;u!==0;u&=u-1){const _=31-Math.clz32(u&-u);let T=de[_*ae+g],E=c[_];if(T<m&&(T=-1-T,E+=1,E>i))return!0;if(T===m)continue;const L=1<<T;((h&L)===0||E>l[T])&&(l[T]=E),h|=L}$(d)&&(t.charCodeAt(n-1)===x||t.charCodeAt(n-1)===V&&t.charCodeAt(n-2)===x)&&(h&1<<S)===0&&(l[S]=0,h|=1<<S);const y=c;c=l,l=y,o=h,n+=1}return!1};class O extends Error{status;constructor(i){super(`[markdown-explorer] the nesting guard stopped the parse: ${i}`),this.name="ParseStop",this.status=i}}const he=(t,i,c,l)=>{if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`[markdown-explorer] the nesting guard's depth limit must be a positive safe integer; got ${String(i)}`);if(!Number.isSafeInteger(c)||c<=0)throw new RangeError(`[markdown-explorer] the nesting guard's node budget must be a positive safe integer; got ${String(c)}`);if(!Number.isSafeInteger(l)||l<=0)throw new RangeError(`[markdown-explorer] the nesting guard's attribute character budget must be a positive safe integer; got ${String(l)}`);if(Ee(t,P))return{status:"too-many-attributes"};const o=i+G,p=t.length+Y;let n=null,d=0,g=0,h=0,y=0;const u=e=>{if(g+=e,g>c)throw new O("too-many-nodes")},_=e=>{for(const r of e)y+=r.name.length+r.value.length;if(y>l)throw new O("too-many-attribute-characters")},T=(e,r,s,a)=>{const D={node:e,above:null,levels:r,height:0,keepsChildren:s,attributes:a,first:null,next:null,previous:null},j=e;return j[B]=D,D},E=e=>{const s=e[B];if(s===void 0)throw new Error("[markdown-explorer] the nesting guard was handed a node it did not create");return s},L=(e,r)=>{let s=r;for(let a=e;a!==null&&s>a.height;a=a.above)a.height=s,s+=a.levels;if(n!==null&&n.height>o)throw new O("too-deep")},k=e=>{const r=e.above;r?.keepsChildren&&(e.previous===null?r.first=e.next:e.previous.next=e.next,e.next!==null&&(e.next.previous=e.previous)),e.above=null,e.next=null,e.previous=null},R=(e,r)=>{if(!A.defaultTreeAdapter.isElementNode(r))return;const s=E(r),a=E(e);k(s),s.above=a,a.keepsChildren&&(s.next=a.first,a.first!==null&&(a.first.previous=s),a.first=s),r.parentNode=e,L(a,s.height+s.levels)},X={...A.defaultTreeAdapter,createDocument:()=>{const e=A.defaultTreeAdapter.createDocument();return n=T(e,0,!1,0),e},createDocumentFragment:()=>{const e=A.defaultTreeAdapter.createDocumentFragment();return T(e,0,!1,0),e},createElement:(e,r,s)=>{if(d+=1,d>p)throw new O("too-many-elements");u(1+s.length),_(s);const a=A.defaultTreeAdapter.createElement(e,r,s);return T(a,1,!(r===A.html.NS.HTML&&Z.has(e)),s.length),a},createCommentNode:e=>{if(h+=1,h>K)throw new O("too-many-comments");return u(1),A.defaultTreeAdapter.createCommentNode(e)},setTemplateContent:(e,r)=>{A.defaultTreeAdapter.setTemplateContent(e,r);const s=E(r);s.above=E(e),L(s.above,s.height)},appendChild:R,insertBefore:(e,r)=>R(e,r),detachNode:e=>{A.defaultTreeAdapter.isElementNode(e)&&(k(E(e)),e.parentNode=null)},getFirstChild:e=>{const r=E(e);if(!r.keepsChildren)throw new Error("[markdown-explorer] the nesting guard was asked for the children of a node whose children it does not keep");return r.first===null?null:r.first.node},getChildNodes:()=>{throw new Error("[markdown-explorer] the nesting guard keeps no child lists for source locations")},onItemPop:e=>{const r=E(e);r.keepsChildren=!1,r.first=null},insertText:()=>{},insertTextBefore:()=>{},adoptAttributes:(e,r)=>{u(r.length),_(r);const s=E(e);if(s.attributes+=r.length,s.attributes>P)throw new O("too-many-attributes")}};let H;try{H=A.parse(t,{scriptingEnabled:!1,treeAdapter:X})}catch(e){if(e instanceof O)return{status:e.status};throw e}return{status:"within",depth:E(H).height-G,elements:d,nodes:g}},pe=t=>{if(t===null||typeof t!="object")return!1;const{id:i,input:c}=t;if(typeof i!="number"||c===null||typeof c!="object")return!1;const{html:l,iframeHosts:o,dataPath:p,maxNodes:n,maxAttributeChars:d,maxSanitizedChars:g}=c;return typeof l=="string"&&Array.isArray(o)&&o.every(h=>typeof h=="string")&&typeof p=="string"&&p!==""&&[n,d,g].every(h=>Number.isSafeInteger(h)&&h>0)},Te=()=>{const t=J.parentPort;if(t===null)throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");const i=new Map;t.on("message",c=>{if(!pe(c))throw new TypeError("[markdown-explorer] the sanitizer worker received a message that is not a job");const{id:l,input:o}=c;let p;try{if(he(o.html,M.MAX_HTML_NESTING_DEPTH,o.maxNodes,o.maxAttributeChars).status!=="within"){t.postMessage({id:l,output:{status:"too-large"}});return}const n=JSON.stringify([o.iframeHosts,o.dataPath]);let d=i.get(n);d===void 0&&(d=M.createHtmlSanitizer(W,o.iframeHosts,o.dataPath,M.MAX_HTML_NESTING_DEPTH),i.set(n,d));const g=d(o.html);p=g.length>o.maxSanitizedChars?{status:"too-large"}:{status:"sanitized",html:g}}catch(n){p=n instanceof M.HtmlNestingLimitError?{status:"too-large"}:{status:"error",message:n instanceof Error?`${n.name}: ${n.message}`:String(n)}}t.postMessage({id:l,output:p})}),t.postMessage({ready:!0})};Te();
1
+ "use strict";const J=require("node:worker_threads"),W=require("isomorphic-dompurify"),M=require("./sanitizePolicy-Du3lFZd-.cjs"),A=require("parse5"),K=4096,P=1024,B=Symbol("placement"),G=2,Y=3,Z=new Set(["html","head","body"]),S=0,v=1,I=2,z=3,U=4,C=5,N=6,w=7,F=8,b=9,Q=10,m=-1,ee=0,te=1,re=2,ne=3,se=4,oe=5,q=6,ae=7,ie=t=>{switch(t){case 9:case 10:case 12:case 13:case 32:return ee;case 47:return te;case 62:return re;case 61:return ne;case 34:return se;case 39:return oe;default:return q}},ce=Uint8Array.from({length:128},(t,i)=>ie(i)),x=60,V=47,le=/[\t\n\f\r />="'<]/g,ue=/["<]/g,fe=/['<]/g,f=-1-I,de=Int8Array.from([[v,b,m,S,S,S,S],[v,b,m,f,f,f,f],[z,b,m,U,I,I,I],[z,b,m,U,f,f,f],[U,w,m,w,C,N,w],[C,C,C,C,F,C,C],[N,N,N,N,N,F,N],[v,w,m,w,w,w,w],[v,b,m,f,f,f,f],[v,b,m,f,f,f,f]].flat()),$=t=>t>=65&&t<=90||t>=97&&t<=122,Ee=(t,i)=>{let c=new Int32Array(Q),l=new Int32Array(Q),o=0,p=0,n=0;for(;n<t.length;){if(o===0){const u=t.indexOf("<",n);if(u<0)return!1;n=u+1,t.charCodeAt(n)===V&&(n+=1),$(t.charCodeAt(n))&&(c[S]=0,o=1<<S,n+=1);continue}if((o&-230)===0&&n>=p){const u=o===1<<C?ue:o===1<<N?fe:le;u.lastIndex=n;const _=u.exec(t);if(_===null)return!1;n=_.index,t.charCodeAt(n)===x&&(p=n+3)}const d=t.charCodeAt(n),g=d<128?ce[d]:q;let h=0;for(let u=o;u!==0;u&=u-1){const _=31-Math.clz32(u&-u);let T=de[_*ae+g],E=c[_];if(T<m&&(T=-1-T,E+=1,E>i))return!0;if(T===m)continue;const L=1<<T;((h&L)===0||E>l[T])&&(l[T]=E),h|=L}$(d)&&(t.charCodeAt(n-1)===x||t.charCodeAt(n-1)===V&&t.charCodeAt(n-2)===x)&&(h&1<<S)===0&&(l[S]=0,h|=1<<S);const y=c;c=l,l=y,o=h,n+=1}return!1};class O extends Error{status;constructor(i){super(`[markdown-explorer] the nesting guard stopped the parse: ${i}`),this.name="ParseStop",this.status=i}}const he=(t,i,c,l)=>{if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`[markdown-explorer] the nesting guard's depth limit must be a positive safe integer; got ${String(i)}`);if(!Number.isSafeInteger(c)||c<=0)throw new RangeError(`[markdown-explorer] the nesting guard's node budget must be a positive safe integer; got ${String(c)}`);if(!Number.isSafeInteger(l)||l<=0)throw new RangeError(`[markdown-explorer] the nesting guard's attribute character budget must be a positive safe integer; got ${String(l)}`);if(Ee(t,P))return{status:"too-many-attributes"};const o=i+G,p=t.length+Y;let n=null,d=0,g=0,h=0,y=0;const u=e=>{if(g+=e,g>c)throw new O("too-many-nodes")},_=e=>{for(const r of e)y+=r.name.length+r.value.length;if(y>l)throw new O("too-many-attribute-characters")},T=(e,r,s,a)=>{const D={node:e,above:null,levels:r,height:0,keepsChildren:s,attributes:a,first:null,next:null,previous:null},j=e;return j[B]=D,D},E=e=>{const s=e[B];if(s===void 0)throw new Error("[markdown-explorer] the nesting guard was handed a node it did not create");return s},L=(e,r)=>{let s=r;for(let a=e;a!==null&&s>a.height;a=a.above)a.height=s,s+=a.levels;if(n!==null&&n.height>o)throw new O("too-deep")},k=e=>{const r=e.above;r?.keepsChildren&&(e.previous===null?r.first=e.next:e.previous.next=e.next,e.next!==null&&(e.next.previous=e.previous)),e.above=null,e.next=null,e.previous=null},R=(e,r)=>{if(!A.defaultTreeAdapter.isElementNode(r))return;const s=E(r),a=E(e);k(s),s.above=a,a.keepsChildren&&(s.next=a.first,a.first!==null&&(a.first.previous=s),a.first=s),r.parentNode=e,L(a,s.height+s.levels)},X={...A.defaultTreeAdapter,createDocument:()=>{const e=A.defaultTreeAdapter.createDocument();return n=T(e,0,!1,0),e},createDocumentFragment:()=>{const e=A.defaultTreeAdapter.createDocumentFragment();return T(e,0,!1,0),e},createElement:(e,r,s)=>{if(d+=1,d>p)throw new O("too-many-elements");u(1+s.length),_(s);const a=A.defaultTreeAdapter.createElement(e,r,s);return T(a,1,!(r===A.html.NS.HTML&&Z.has(e)),s.length),a},createCommentNode:e=>{if(h+=1,h>K)throw new O("too-many-comments");return u(1),A.defaultTreeAdapter.createCommentNode(e)},setTemplateContent:(e,r)=>{A.defaultTreeAdapter.setTemplateContent(e,r);const s=E(r);s.above=E(e),L(s.above,s.height)},appendChild:R,insertBefore:(e,r)=>R(e,r),detachNode:e=>{A.defaultTreeAdapter.isElementNode(e)&&(k(E(e)),e.parentNode=null)},getFirstChild:e=>{const r=E(e);if(!r.keepsChildren)throw new Error("[markdown-explorer] the nesting guard was asked for the children of a node whose children it does not keep");return r.first===null?null:r.first.node},getChildNodes:()=>{throw new Error("[markdown-explorer] the nesting guard keeps no child lists for source locations")},onItemPop:e=>{const r=E(e);r.keepsChildren=!1,r.first=null},insertText:()=>{},insertTextBefore:()=>{},adoptAttributes:(e,r)=>{u(r.length),_(r);const s=E(e);if(s.attributes+=r.length,s.attributes>P)throw new O("too-many-attributes")}};let H;try{H=A.parse(t,{scriptingEnabled:!1,treeAdapter:X})}catch(e){if(e instanceof O)return{status:e.status};throw e}return{status:"within",depth:E(H).height-G,elements:d,nodes:g}},pe=t=>{if(t===null||typeof t!="object")return!1;const{id:i,input:c}=t;if(typeof i!="number"||c===null||typeof c!="object")return!1;const{html:l,iframeHosts:o,dataPath:p,maxNodes:n,maxAttributeChars:d,maxSanitizedChars:g}=c;return typeof l=="string"&&Array.isArray(o)&&o.every(h=>typeof h=="string")&&typeof p=="string"&&p!==""&&[n,d,g].every(h=>Number.isSafeInteger(h)&&h>0)},Te=()=>{const t=J.parentPort;if(t===null)throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");const i=new Map;t.on("message",c=>{if(!pe(c))throw new TypeError("[markdown-explorer] the sanitizer worker received a message that is not a job");const{id:l,input:o}=c;let p;try{if(he(o.html,M.MAX_HTML_NESTING_DEPTH,o.maxNodes,o.maxAttributeChars).status!=="within"){t.postMessage({id:l,output:{status:"too-large"}});return}const n=JSON.stringify([o.iframeHosts,o.dataPath]);let d=i.get(n);d===void 0&&(d=M.createHtmlSanitizer(W,o.iframeHosts,o.dataPath,M.MAX_HTML_NESTING_DEPTH),i.set(n,d));const g=d(o.html);p=g.length>o.maxSanitizedChars?{status:"too-large"}:{status:"sanitized",html:g}}catch(n){p=n instanceof M.HtmlNestingLimitError?{status:"too-large"}:{status:"error",message:n instanceof Error?`${n.name}: ${n.message}`:String(n)}}t.postMessage({id:l,output:p})}),t.postMessage({ready:!0})};Te();
@@ -1,6 +1,6 @@
1
1
  import { parentPort as W } from "node:worker_threads";
2
2
  import q from "isomorphic-dompurify";
3
- import { M as D, c as K, H as Y } from "./sanitizePolicy-BWQtWhsL.js";
3
+ import { M as D, c as K, H as Y } from "./sanitizePolicy-BvhYIqVO.js";
4
4
  import { defaultTreeAdapter as w, parse as Z, html as ee } from "parse5";
5
5
  const te = 4096, P = 1024, B = /* @__PURE__ */ Symbol("placement"), G = 2, re = 3, ne = /* @__PURE__ */ new Set(["html", "head", "body"]), A = 0, L = 1, M = 2, z = 3, U = 4, C = 5, N = 6, _ = 7, F = 8, b = 9, Q = 10, T = -1, oe = 0, se = 1, ae = 2, ie = 3, ce = 4, le = 5, j = 6, ue = 7, fe = (t) => {
6
6
  switch (t) {
@@ -1,6 +1,6 @@
1
1
  import { ActionFunctionArgs, data, HeadersFunction, LoaderFunctionArgs } from "react-router";
2
2
  import { ExplorerConfig } from "../core/config.cjs";
3
- import { ExplorerDocumentEdit, ExplorerEntry, ExplorerFailureDocument, ExplorerGrantRequired, ExplorerHeading, ExplorerMediaType, ExplorerNotice, ExplorerPageData, ExplorerRevision } from "../core/contracts.cjs";
3
+ import { ExplorerDocumentEdit, ExplorerEntry, ExplorerFailureDocument, ExplorerGrantRequired, ExplorerHeading, ExplorerImageType, ExplorerMediaType, ExplorerNotice, ExplorerPageData, ExplorerRevision } from "../core/contracts.cjs";
4
4
  import { ExplorerPathRules } from "../core/paths.cjs";
5
5
  import { ExplorerLogger } from "./errors.cjs";
6
6
  import { HtmlSanitizerOptions } from "./sanitizer.cjs";
@@ -79,6 +79,7 @@ export type ExplorerHostDocument = {
79
79
  } | {
80
80
  readonly kind: "image";
81
81
  readonly name: string;
82
+ readonly imageType: ExplorerImageType;
82
83
  readonly version: string;
83
84
  } | {
84
85
  readonly kind: "media";
@@ -1,6 +1,6 @@
1
1
  import { ActionFunctionArgs, data, HeadersFunction, LoaderFunctionArgs } from "react-router";
2
2
  import { ExplorerConfig } from "../core/config.js";
3
- import { ExplorerDocumentEdit, ExplorerEntry, ExplorerFailureDocument, ExplorerGrantRequired, ExplorerHeading, ExplorerMediaType, ExplorerNotice, ExplorerPageData, ExplorerRevision } from "../core/contracts.js";
3
+ import { ExplorerDocumentEdit, ExplorerEntry, ExplorerFailureDocument, ExplorerGrantRequired, ExplorerHeading, ExplorerImageType, ExplorerMediaType, ExplorerNotice, ExplorerPageData, ExplorerRevision } from "../core/contracts.js";
4
4
  import { ExplorerPathRules } from "../core/paths.js";
5
5
  import { ExplorerLogger } from "./errors.js";
6
6
  import { HtmlSanitizerOptions } from "./sanitizer.js";
@@ -79,6 +79,7 @@ export type ExplorerHostDocument = {
79
79
  } | {
80
80
  readonly kind: "image";
81
81
  readonly name: string;
82
+ readonly imageType: ExplorerImageType;
82
83
  readonly version: string;
83
84
  } | {
84
85
  readonly kind: "media";