@aiquants/markdown-explorer 0.38.0 → 0.39.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 (35) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +2 -2
  3. package/dist/{EditSurface-BTrQ1viw.js → EditSurface-CUPN9dUY.js} +211 -211
  4. package/dist/{EditSurface-Dis52Iwq.cjs → EditSurface-CZnjX0sv.cjs} +2 -2
  5. package/dist/{ExplorerSplit-Dq7HfNre.js → ExplorerSplit-DHpgdXhb.js} +407 -407
  6. package/dist/{ExplorerSplit-13nPIuf0.cjs → ExplorerSplit-DWBhCe7m.cjs} +1 -1
  7. package/dist/{MultiLayout-B7RvBpCj.cjs → MultiLayout-BkHbfUuh.cjs} +1 -1
  8. package/dist/{MultiLayout-1rKm2Hzt.js → MultiLayout-HmvjE8ht.js} +3 -3
  9. package/dist/{NativeScrollBar-D63-6AL1.cjs → NativeScrollBar-CzGhZ-w3.cjs} +1 -1
  10. package/dist/{NativeScrollBar-Bg05yuzM.js → NativeScrollBar-DAukiH01.js} +2 -2
  11. package/dist/{TreeLayout-CNE0XkWz.cjs → TreeLayout-BEvPaxLb.cjs} +1 -1
  12. package/dist/{TreeLayout-9eEP62LF.js → TreeLayout-dtnugwQ7.js} +3 -3
  13. package/dist/core/geometry.d.cts +0 -1
  14. package/dist/core/geometry.d.ts +0 -1
  15. package/dist/{explorerCore-GCqatHTO.js → explorerCore-CUtc1Vmx.js} +1 -1
  16. package/dist/{explorerCore-5qeC3-gt.cjs → explorerCore-Dj7RxZRd.cjs} +1 -1
  17. package/dist/{index-C52Nj37x.js → index-BBJoJu-b.js} +7 -7
  18. package/dist/{index-_XNluAcx.cjs → index-D6at9qMs.cjs} +5 -5
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +15 -15
  21. package/dist/location-DFXJSMit.cjs +1 -0
  22. package/dist/{location-CJvL6JNs.js → location-T9o5XYpX.js} +74 -75
  23. package/dist/{merge-CnrrjXmc.js → merge-CkMe5hqA.js} +1 -1
  24. package/dist/{merge-CKpFyeqR.cjs → merge-XyuOlVWP.cjs} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +3 -3
  27. package/dist/serverCore.cjs +1 -1
  28. package/dist/serverCore.js +3 -3
  29. package/dist/styles/markdown-explorer.css +1 -1
  30. package/dist/{tapScrollCircle-D-Lgzdxx.js → tapScrollCircle-CvWJKtbF.js} +1 -1
  31. package/dist/{tapScrollCircle-6etmzCb7.cjs → tapScrollCircle-ExxyHVWY.cjs} +1 -1
  32. package/dist/{useSplitPersistence-CD_n1ivo.cjs → useSplitPersistence-BCitqdAe.cjs} +1 -1
  33. package/dist/{useSplitPersistence-tbTu3P5m.js → useSplitPersistence-C86jW1yY.js} +1 -1
  34. package/package.json +3 -3
  35. package/dist/location-DOIG84V9.cjs +0 -1
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-_XNluAcx.cjs"),e=require("./storage-BpYsprog.cjs"),E=require("./location-DOIG84V9.cjs"),_=require("./ownUrls-BTPGNhBt.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_HOST_CHANGE_POLICIES=L.EXPLORER_HOST_CHANGE_POLICIES;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.draftAnswerOf=L.draftAnswerOf;exports.draftConversionOf=L.draftConversionOf;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.SPREADSHEET_BYTE_LIMITS=E.SPREADSHEET_BYTE_LIMITS;exports.WORKBOOK_BYTE_LIMITS=E.WORKBOOK_BYTE_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.DOCUMENT_ID_ALPHABET=_.DOCUMENT_ID_ALPHABET;exports.DOCUMENT_ID_LENGTH=_.DOCUMENT_ID_LENGTH;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.groupDocumentId=_.groupDocumentId;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isCanonicalDocumentId=_.isCanonicalDocumentId;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerDocumentLang=_.isExplorerDocumentLang;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;exports.parseDocumentId=_.parseDocumentId;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-D6at9qMs.cjs"),e=require("./storage-BpYsprog.cjs"),E=require("./location-DFXJSMit.cjs"),_=require("./ownUrls-BTPGNhBt.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_HOST_CHANGE_POLICIES=L.EXPLORER_HOST_CHANGE_POLICIES;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.draftAnswerOf=L.draftAnswerOf;exports.draftConversionOf=L.draftConversionOf;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.SPREADSHEET_BYTE_LIMITS=E.SPREADSHEET_BYTE_LIMITS;exports.WORKBOOK_BYTE_LIMITS=E.WORKBOOK_BYTE_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.DOCUMENT_ID_ALPHABET=_.DOCUMENT_ID_ALPHABET;exports.DOCUMENT_ID_LENGTH=_.DOCUMENT_ID_LENGTH;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.groupDocumentId=_.groupDocumentId;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isCanonicalDocumentId=_.isCanonicalDocumentId;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerDocumentLang=_.isExplorerDocumentLang;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;exports.parseDocumentId=_.parseDocumentId;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { ak as _, al as s, am as L, an as e, ao as r, ap as R, aq as T, ar as o, as as A, at as O, au as I, av as D } from "./index-C52Nj37x.js";
1
+ import { ak as _, al as s, am as L, an as e, ao as r, ap as R, aq as T, ar as o, as as A, at as O, au as I, av as D } from "./index-BBJoJu-b.js";
2
2
  import { c as N } from "./storage-D1uSw-xj.js";
3
- import { a0 as S, a1 as l, a2 as i, a3 as n, a4 as p, I as t, H as X, a5 as C, J as U, R as x, a6 as u, a7 as c, a8 as d, a9 as f, aa as H, ab as m, e as F, i as G, h as K, w as W } from "./location-CJvL6JNs.js";
4
- import { D as B, ac as g, ad as v, ae as w, af as b, E as k, M as V, g as Y, k as j, Y as q, i as J, K as y, a as z, a2 as Q, b as Z, j as $, h as EE, T as aE } from "./ownUrls-DD0cSCsF.js";
3
+ import { $ as S, a0 as l, a1 as i, a2 as n, a3 as p, H as t, G as X, a4 as C, I as U, Q as x, a5 as u, a6 as c, a7 as d, a8 as f, a9 as H, aa as m, e as G, i as F, h as K, w as W } from "./location-T9o5XYpX.js";
4
+ import { D as B, ac as g, ad as v, ae as w, af as k, E as V, M as Y, g as b, k as j, Y as q, i as Q, K as $, a as y, a2 as z, b as J, j as Z, h as EE, T as aE } from "./ownUrls-DD0cSCsF.js";
5
5
  export {
6
6
  S as COLUMN_MIN_MEASURE,
7
7
  B as DEFAULT_DENIED_PATH_SEGMENTS,
@@ -14,9 +14,9 @@ export {
14
14
  p as EXPAND_ALL_FOLDER_LIMITS,
15
15
  t as EXPLORER_DEFAULT_PERCENT,
16
16
  w as EXPLORER_EDIT_TOKEN_MAX_LENGTH,
17
- b as EXPLORER_FAILURE_REASONS,
17
+ k as EXPLORER_FAILURE_REASONS,
18
18
  s as EXPLORER_HOST_CHANGE_POLICIES,
19
- k as EXPLORER_MAX_HEADINGS,
19
+ V as EXPLORER_MAX_HEADINGS,
20
20
  X as EXPLORER_MAX_PERCENT,
21
21
  C as EXPLORER_MIN_REM,
22
22
  U as EXPLORER_MULTI_DEFAULT_PERCENT,
@@ -26,7 +26,7 @@ export {
26
26
  r as MARKDOWN_EXPLORER_LABEL_KEYS,
27
27
  R as MARKDOWN_EXPLORER_LABEL_TEMPLATES,
28
28
  T as MARKDOWN_EXPLORER_LOCALES,
29
- V as MAX_DOCUMENT_PATH_LENGTH,
29
+ Y as MAX_DOCUMENT_PATH_LENGTH,
30
30
  u as MULTI_VIEW_COLUMN_LIMITS,
31
31
  c as MULTI_VIEW_PANEL_LIMITS,
32
32
  o as MarkdownExplorer,
@@ -37,18 +37,18 @@ export {
37
37
  m as defineExplorerConfig,
38
38
  A as draftAnswerOf,
39
39
  O as draftConversionOf,
40
- F as explorerHref,
41
- Y as failureDocument,
40
+ G as explorerHref,
41
+ b as failureDocument,
42
42
  j as failureOf,
43
43
  q as groupDocumentId,
44
- J as isAcceptableDocumentPath,
45
- y as isCanonicalDocumentId,
46
- z as isDeniedPath,
47
- Q as isExplorerChildrenResult,
48
- Z as isExplorerDocumentLang,
49
- $ as isExplorerFailureCode,
44
+ Q as isAcceptableDocumentPath,
45
+ $ as isCanonicalDocumentId,
46
+ y as isDeniedPath,
47
+ z as isExplorerChildrenResult,
48
+ J as isExplorerDocumentLang,
49
+ Z as isExplorerFailureCode,
50
50
  EE as isExplorerFailureReason,
51
- G as isExplorerSourceId,
51
+ F as isExplorerSourceId,
52
52
  aE as parseDocumentId,
53
53
  K as resolveExplorerLocation,
54
54
  I as resolveMarkdownExplorerLabels,
@@ -0,0 +1 @@
1
+ "use strict";const L=require("@aiquants/markdown/embeds"),T=require("@aiquants/markdown/viewer-settings"),g=require("./ownUrls-BTPGNhBt.cjs"),i=require("./describeValue-Ccvhbt36.cjs"),Je=Object.freeze(["UTF-8","IBM866","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-8-I","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic","GBK","gb18030","Big5","EUC-JP","ISO-2022-JP","Shift_JIS","EUC-KR","replacement","UTF-16BE","UTF-16LE","x-user-defined"]),Ze=new Map(Je.map(e=>[e.toLowerCase(),e])),$="UTF-8",ae=Object.freeze([Object.freeze({bytes:Object.freeze([239,187,191]),encoding:$}),Object.freeze({bytes:Object.freeze([255,254]),encoding:"UTF-16LE"}),Object.freeze({bytes:Object.freeze([254,255]),encoding:"UTF-16BE"})]),Qe=new Map([[$,"is read before any legacy encoding"],["UTF-16LE","is read only by its byte order mark"],["UTF-16BE","is read only by its byte order mark"],["ISO-2022-JP","writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],["x-user-defined","is no text encoding (it maps bytes to private-use characters)"]]),Q=e=>{let r;try{r=new TextDecoder(e).encoding}catch(o){throw o instanceof RangeError?new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`):o}const t=er(r),n=Qe.get(t);if(n!==void 0)throw new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} names ${t}, which cannot be the legacy encoding: it ${n}`);return t},er=e=>{const r=Ze.get(e);if(r===void 0)throw new RangeError(`[markdown-explorer] TextDecoder answered ${i.describeValue(e)}, which is no encoding of the WHATWG Encoding Standard`);return r},V=(e,r,t)=>{const n=t===null?null:Q(t),o=ae.find(({bytes:a})=>a.every((d,l)=>e[l]===d));if(o!==void 0)return{body:e.subarray(o.bytes.length),encodings:[o.encoding]};const s=r||e.length===0?void 0:ae.find(({bytes:a})=>e.length<a.length&&e.every((d,l)=>a[l]===d));return s!==void 0?{body:e.subarray(e.length),encodings:[s.encoding]}:{body:e,encodings:n===null?[$]:[$,n]}},rr=(e,r,t)=>V(e,r,t).encodings,tr=(e,r,t)=>{try{return new TextDecoder(e,{fatal:!0,ignoreBOM:!0}).decode(r,{stream:!t})}catch(n){if(n instanceof TypeError)return null;throw n}},nr=(e,r,t)=>{const n=ee(V(e,r,t),r);return n===null?null:n.text},ee=({body:e,encodings:r},t)=>{for(const n of r){const o=tr(n,e,t);if(o!==null)return{encoding:n,text:o}}return null},or=(e,r,t)=>{const n=V(e,r,t),o=ee(n,r);return o===null?n.encodings[0]:o.encoding},ir=(e,r,t)=>{const n=V(e,r,t),o=ee(n,r);return o!==null?o.text:new TextDecoder(n.encodings[0],{ignoreBOM:!0}).decode(n.body,{stream:!r})},N=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),sr=/^readme(?:\.|$)/iu,de=/^readme(?:\.[^.]*)?$/iu,le=Object.freeze(["md","markdown","mdx","txt",""]),ar=e=>sr.test(e),X=e=>e.type==="file"&&ar(e.name),ce=e=>{const r=e.lastIndexOf("."),t=le.indexOf(r<0?"":e.slice(r+1).toLowerCase());return t<0?le.length:t},dr=(e,r)=>{const t=+!de.test(e.name)-+!de.test(r.name);if(t!==0)return t;const n=ce(e.name)-ce(r.name);if(n!==0)return n;const o=N.compare(e.name,r.name);return o!==0?o:N.compare(e.path,r.path)},lr=e=>{let r=null;for(const t of e)X(t)&&(r===null||dr(t,r)<0)&&(r=t);return r===null?null:r.path},W=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,showFolderReadme:!0,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),he=[!0,!1],pe=(e,r)=>r?e.settingOn:e.settingOff,y=(e,r)=>({key:e,labelKey:r,values:he,formatValue:pe,requiresTreeView:!1}),cr=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),R=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,r)=>cr[r](e),requiresTreeView:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.folderPlacementMixed:r==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresTreeView:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.readmePlacementMixed:r==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresTreeView:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,r)=>r==="single"?e.selectionSingle:r==="multiple"?e.selectionMultiple:e.selectionNone,requiresTreeView:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,r)=>r==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresTreeView:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,r)=>e.expandIconSizeValue(r),requiresTreeView:!1},y("alwaysExpanded","settingAlwaysExpanded"),y("revealDocument","settingRevealDocument"),{key:"showFolderReadme",labelKey:"settingShowFolderReadme",values:he,formatValue:pe,requiresTreeView:!0},y("removeRootIndent","settingRemoveRootIndent"),y("lines","settingTreeLines"),y("expandIcons","settingExpandIcons"),y("directoryIcons","settingDirectoryIcons"),y("fileIcons","settingFileIcons")]),ur=e=>e==="tree"?R:R.filter(r=>!r.requiresTreeView),be=e=>{const r=R.find(t=>t.key===e);if(r===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return r},mr=(e,r)=>{const t=be(r).values,n=t[(t.indexOf(e[r])+1)%t.length];return{...e,[r]:n}},fr=(e,r,t)=>be(t).formatValue(e,r[t]),xe=2,H=Object.freeze({}),re=(e,r)=>Object.freeze(Object.fromEntries(R.filter(t=>r(t,e[t.key])).map(t=>[t.key,e[t.key]]))),ue="directoriesFirst",wr=e=>{if(!Object.hasOwn(e,ue))return e;const{[ue]:r,...t}=e;return Object.hasOwn(t,"folderPlacement")||typeof r!="boolean"?t:{...t,folderPlacement:r?"first":"mixed"}},gr=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return H;const r=e;return r.version!==xe||r.settings===null||typeof r.settings!="object"||Array.isArray(r.settings)?H:re(wr(r.settings),(t,n)=>t.values.includes(n))},Er=(e,r)=>{const t=re(r,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(t).length===0?e:Object.freeze({...e,...t})},hr=(e,r,t,n)=>re({...e,[r]:t},(o,s)=>s!==void 0&&!(o.key===r&&s===n[r])),pr=e=>JSON.stringify({version:xe,settings:e}),br=(e,r,t)=>e===void 0||r===void 0?e===r?0:e===void 0?1:-1:t*(e-r),xr=e=>{const{sortMode:r,folderPlacement:t,readmePlacement:n}=e;if(r==="native"&&t==="mixed"&&n==="mixed")return;const o=(s,a)=>{const d=N.compare(s.name,a.name);return d!==0?d:N.compare(s.path,a.path)};return(s,a)=>{if(t!=="mixed"&&s.type!==a.type)return s.type==="directory"==(t==="first")?-1:1;if(n!=="mixed"){const l=X(s);if(l!==X(a))return l===(n==="first")?-1:1}if(r==="native")return 0;if(r==="asc")return o(s,a);if(r==="desc")return-o(s,a);const d=br(s.modifiedAt,a.modifiedAt,r==="oldest"?1:-1);return d!==0?d:o(s,a)}},b=(1+Math.sqrt(5))/2,Sr=100/b**3,Or=100/b**4,te=100/b**2,Se=13,Tr=16,yr=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),K=Object.freeze([1,2,3,5,8,13,21,34,55]),_r=Object.freeze([89,144,233,377]),ne=44,Ir=ne;2*K[3]+ne+K[0];const Rr=1/b,kr=1/b**3,Pr="40ch",Ar=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${i.describeValue(e)}`)},Oe=e=>(Ar(e),Se*e),Lr=e=>Oe(e)*b**2,Nr=233,Dr=50,Te=100/b**3,vr=100-Te,$r=_r[0],S=(e,r)=>{if(!Number.isFinite(r)||r<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${i.describeValue(r)}`)},Cr=({trackInlineSize:e,gap:r,minColumnInlineSize:t,logicalColumns:n})=>{if(S("trackInlineSize",e),S("gap",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${i.describeValue(t)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${i.describeValue(n)}`);const o=Math.floor((e+r)/(t+r));return Math.min(n,Math.max(1,o))},Mr=(e,r)=>{const{trackInlineSize:t,gap:n,minColumnInlineSize:o,logicalColumns:s}=r;if(!([t,n,o].every(Number.isFinite)&&t>0&&n>=0&&o>0))return e;const d=Cr(r);if(e===null||d===e)return d;const l=Math.min(s,Math.max(1,e));if(d>l){const w=(l+1)*o+l*n+n/b;return t>=w?d:l}return t>=l*o+(l-1)*n?l:d},Vr=(e,r)=>{if(!(Number.isInteger(e)&&Number.isInteger(r))||r<1||r>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${i.describeValue(r)}`);return Array.from({length:r},(t,n)=>[Math.floor(n*e/r),Math.floor((n+1)*e/r)])},zr=(e,r,t)=>{if(S("surfaceInlineSize",e),S("handlePixels",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${i.describeValue(r)}`);return e>=2*r+t?"beside":"stacked"},G=(e,r,t)=>Math.max(r,Math.min(e,t)),me=(e,r,t,n)=>{const o=(G(e,0,t)+G(r,0,t))/2;return G(o-n/2,0,t-n)},jr=(e,r,t)=>{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 ${i.describeValue(o)}`);return S("marginBox.width",r.width),S("marginBox.height",r.height),S("viewport.width",t.width),S("viewport.height",t.height),{left:me(e.left,e.right,t.width,r.width),top:me(e.top,e.bottom,t.height,r.height)}},Ur=31536e3,Fr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Br=e=>{if(typeof e!="string"||!Fr.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${i.describeValue(e)}`)},fe=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=te,v=(e,r)=>typeof r=="string"&&e.includes(r),Gr=(e,r)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const t=e,{treeExplorer:n,treeExplorerHidden:o,multiExplorer:s,multiExplorerHidden:a,style:d,align:l,measure:m,documentColors:w}=t;return{...fe(n)?{treeExplorer:n}:{},...o===!0?{treeExplorerHidden:o}:{},...fe(s)?{multiExplorer:s}:{},...a===!0?{multiExplorerHidden:a}:{},...v(r,d)?{style:d}:{},...v(T.CONTENT_ALIGNS,l)?{align:l}:{},...v(T.CONTENT_MEASURES,m)?{measure:m}:{},...v(T.CONTENT_COLORS,w)?{documentColors:w}:{}}},Xr=(e,r)=>{if(e!==null)for(const t of e.split(";")){const n=t.indexOf("=");if(!(n<0)&&t.slice(0,n).trim()===r)return t.slice(n+1).trim()}},Wr=(e,r)=>{if(e===void 0||e==="")return{};try{return Gr(JSON.parse(decodeURIComponent(e)),r)}catch{return{}}},C=100,Hr=Math.floor(te*C)/C,ye=e=>{const r=t=>Math.min(Hr,Math.max(1,Math.round(t*C))/C);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:r(e.treeExplorer)},...e.treeExplorerHidden===!0?{treeExplorerHidden:!0}:{},...e.multiExplorer===void 0?{}:{multiExplorer:r(e.multiExplorer)},...e.multiExplorerHidden===!0?{multiExplorerHidden:!0}:{},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align},...e.measure===void 0?{}:{measure:e.measure},...e.documentColors===void 0?{}:{documentColors:e.documentColors}}))},Kr=(e,r,t)=>`${e}=${ye(r)}; Path=/; Max-Age=${String(Ur)}; SameSite=Lax${t?"; Secure":""}`,_e=["ctrl","shift"],qr=e=>typeof e=="string"&&_e.includes(e),q=Object.freeze({tree:"tree",multi:"multi",single:"single"}),Ie=Object.freeze({default:12,min:1,max:64}),Re=Object.freeze({default:4,min:1,max:6}),ke=Object.freeze({default:500,min:1,max:1e4}),Pe=Object.freeze({default:16,min:1,max:64}),Ae=Object.freeze({default:16,min:1,max:64}),Le=Object.freeze({default:2*1024*1024,min:1,max:256*1024*1024}),Ne=Object.freeze({default:8*1024*1024,min:1,max:256*1024*1024}),De=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,Yr=/^[a-z0-9][a-z0-9-]*$/u,Jr=/^(?=.{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,Y=(e,r)=>{if(typeof r!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${i.describeValue(r)}`);if(!g.isMountPath(r))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${i.describeValue(r)}`)},we=Object.freeze(Object.keys({basePath:!0,dataPath:!0,settingsCookie:!0,views:!0,documentIds:!0,multiView:!0,expandAll:!0,revealDocument:!0,documentStyles:!0,defaultDocumentStyle:!0,mermaidModifier:!0,iframeHosts:!0,appOrigins:!0,mediaDataPath:!0,embeds:!0,defaultTreeSettings:!0,legacyTextEncoding:!0,spreadsheets:!0})),O=(e,r,t)=>{if(r===void 0)return[];if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${i.describeValue(r)}`);const n=Object.entries(r);for(const[o]of n)if(!t.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${t.join(", ")}`);return n.filter(([,o])=>o!==void 0)},Zr=e=>{const r={...q};for(const[t,n]of O("views",e,Object.keys(q)))r[t]=n;for(const[t,n]of Object.entries(r))if(typeof n!="string"||!De.test(n))throw new RangeError(`[markdown-explorer] views.${t} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(n)}`);return Object.freeze(r)},Qr=e=>{if(e===void 0)return null;const r=O("documentIds",e,["slug"]).find(([t])=>t==="slug")?.[1];if(typeof r!="string"||!De.test(r))throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(r)}`);return Object.freeze({slug:r})},_=(e,r,t)=>{if(r===void 0)return t.default;if(typeof r!="number"||!Number.isInteger(r)||r<t.min||r>t.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(t.min)}..${String(t.max)}; got ${i.describeValue(r)}`);return r},et=(e,r)=>{const t=new Map(O("embeds",e,["providers","linkCards","linkCardSize"]));if(t.size===0)return L.NO_EMBEDS;const n=t.has("providers")?t.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${i.describeValue(n)}`);for(const d of n)if(!L.isEmbedProviderId(d))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${L.EMBED_PROVIDER_IDS.join(", ")}; got ${i.describeValue(d)}`);const o=t.has("linkCards")?t.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${i.describeValue(o)}`);const s={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?g.explorerLinkCardEndpoint(r):null};if(!t.has("linkCardSize"))return Object.freeze(s);const a=t.get("linkCardSize");if(!L.isLinkCardSize(a))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${L.LINK_CARD_SIZES.join(", ")}; got ${i.describeValue(a)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${i.describeValue(a)} with linkCards ${i.describeValue(o)}`);return Object.freeze({...s,linkCardSize:a})},rt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${i.describeValue(e)}`);return Q(e)},tt=e=>{if(e===void 0)return Object.freeze([]);if(!Array.isArray(e))throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${i.describeValue(e)}`);for(const[r,t]of e.entries()){if(typeof t!="string")throw new TypeError(`[markdown-explorer] appOrigins[${String(r)}] must be a string; got ${i.describeValue(t)}`);if(!g.isBrowserOrigin(t))throw new RangeError(`[markdown-explorer] appOrigins[${String(r)}] must be an origin as the browser writes it (scheme://host[:port], without a default port, path, query, fragment or user info); got ${i.describeValue(t)}`)}return Object.freeze([...new Set(e)])},nt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${i.describeValue(e)}`);if(!g.isMediaDataUrl(e))throw new RangeError(`[markdown-explorer] mediaDataPath must be an absolute http: or https: URL as the browser writes it, of an origin and a path that starts with "/", has no trailing "/", uses only letters, digits and "._~-" in each segment and has no "." or ".." segment, without a query, fragment or user info; got ${i.describeValue(e)}`);return e},ot=e=>{const r=new Map(O("defaultTreeSettings",e,R.map(n=>n.key)));if(r.size===0)return W;const t={...W};for(const n of R){if(!r.has(n.key))continue;const o=r.get(n.key),s=n.values;if(!s.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(i.describeValue).join(", ")}; got ${i.describeValue(o)}`);t[n.key]=o}return Object.freeze(t)},ve=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");for(const c of Object.keys(e))if(!we.includes(c))throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${we.join(", ")}`);Y("basePath",e.basePath),Y("dataPath",e.dataPath);const r=Zr(e.views);if(new Set([r.tree,r.multi,r.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got tree ${i.describeValue(r.tree)}, multi ${i.describeValue(r.multi)} and single ${i.describeValue(r.single)}`);const t=Qr(e.documentIds);if(t!==null&&[r.tree,r.multi,r.single].includes(t.slug))throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${i.describeValue(t.slug)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const c=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(c===r.tree||c===r.multi||c===r.single||c===t?.slug)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${i.describeValue(e.dataPath)}`)}Br(e.settingsCookie);const n=e.iframeHosts??[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${i.describeValue(n)}`);for(const[c,x]of n.entries())if(typeof x!="string"||!Jr.test(x))throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${i.describeValue(x)}`);const o=Object.fromEntries(O("multiView",e.multiView,["maxPanels","columns"])),s=Object.fromEntries(O("expandAll",e.expandAll,["maxFolders","maxDepth"])),a=Object.fromEntries(O("revealDocument",e.revealDocument,["maxDepth"])),d=Object.fromEntries(O("spreadsheets",e.spreadsheets,["maxBytes","maxWorkbookBytes"])),l=e.documentStyles??T.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(l)||l.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const m=new Set;for(const c of l){if(c===null||typeof c!="object"||typeof c.name!="string"||c.name.trim()===""||typeof c.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(m.has(c.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${i.describeValue(c.name)} repeats`);m.add(c.name)}const w=e.defaultDocumentStyle===void 0?T.DEFAULT_MARKDOWN_STYLE:e.defaultDocumentStyle;if(typeof w!="string")throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${i.describeValue(w)}`);if(!m.has(w)){const c=e.defaultDocumentStyle===void 0?" (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)":"";throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...m].map(i.describeValue).join(", ")}); got ${i.describeValue(w)}${c}`)}const f=e.mermaidModifier;if(f!==void 0&&!qr(f))throw new RangeError(`[markdown-explorer] mermaidModifier must be one of ${_e.map(i.describeValue).join(", ")}; got ${i.describeValue(f)}`);return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:r,documentIds:t,multiView:Object.freeze({maxPanels:_("multiView.maxPanels",o.maxPanels,Ie),columns:_("multiView.columns",o.columns,Re)}),expandAll:Object.freeze({maxFolders:_("expandAll.maxFolders",s.maxFolders,ke),maxDepth:_("expandAll.maxDepth",s.maxDepth,Pe)}),revealDocument:Object.freeze({maxDepth:_("revealDocument.maxDepth",a.maxDepth,Ae)}),documentStyles:Object.freeze(l.map(c=>Object.freeze({name:c.name,className:c.className}))),defaultDocumentStyle:w,mermaidModifier:f,iframeHosts:Object.freeze([...new Set(n)]),appOrigins:tt(e.appOrigins),mediaDataPath:nt(e.mediaDataPath),embeds:et(e.embeds,e.dataPath),defaultTreeSettings:ot(e.defaultTreeSettings),legacyTextEncoding:rt(e.legacyTextEncoding),spreadsheets:Object.freeze({maxBytes:_("spreadsheets.maxBytes",d.maxBytes,Le),maxWorkbookBytes:_("spreadsheets.maxWorkbookBytes",d.maxWorkbookBytes,Ne)})})},it=e=>{const r=e.embeds;if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${i.describeValue(r)}`);if(Object.hasOwn(r,"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 ${i.describeValue(r.linkCards)})`);const t=e.legacyTextEncoding;if(t!==null&&typeof t!="string")throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${i.describeValue(t)}`);const n=e.mediaDataPath;if(n!==null&&typeof n!="string")throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${i.describeValue(n)}`);const o=e.documentIds;if(o!==null&&!i.isPlainObject(o))throw new TypeError(`[markdown-explorer] config.documentIds must be the segment defineExplorerConfig resolved, or null; got ${i.describeValue(o)}`);const{linkCardEndpoint:s,...a}=r,d=ve({...e,embeds:{...a,linkCards:s!==null},legacyTextEncoding:t===null?void 0:t,mediaDataPath:n===null?void 0:n,documentIds:o===null?void 0:o});if(d.embeds.linkCardEndpoint!==s)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${i.describeValue(d.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${i.describeValue(s)}`);if(d.legacyTextEncoding!==t)throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${i.describeValue(d.legacyTextEncoding)} (the written name of the encoding it names); got ${i.describeValue(t)}`);const l=e;for(const[m,w]of Object.entries(d)){const f=J(l[m],w,m);if(f!==null)throw f.kind==="extra"?new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${i.describeValue(f.given)} there`):new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${i.describeValue(f.given)} where it resolves ${i.describeValue(f.resolved)}`)}return d},J=(e,r,t)=>{if(Object.is(e,r))return null;if(Array.isArray(r)){if(!Array.isArray(e))return{kind:"value",path:t,given:e,resolved:r};if(e.length!==r.length)return{kind:"value",path:`${t}.length`,given:e.length,resolved:r.length};for(const[o,s]of r.entries()){const a=J(e[o],s,`${t}[${String(o)}]`);if(a!==null)return a}return null}if(!(i.isPlainObject(r)&&i.isPlainObject(e)))return{kind:"value",path:t,given:e,resolved:r};for(const o of Object.keys(r)){const s=J(Object.hasOwn(e,o)?e[o]:void 0,r[o],`${t}.${o}`);if(s!==null)return s}const n=Object.keys(e).find(o=>!Object.hasOwn(r,o));return n===void 0?null:{kind:"extra",path:`${t}.${n}`,given:e[n]}},$e=e=>typeof e=="string"&&Yr.test(e),st=(e,r)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${i.describeValue(e)}`);if(!Array.isArray(r)||r.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${i.describeValue(r)}`);const t=new Set;for(const[n,o]of r.entries()){if(!$e(o))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${i.describeValue(o)}`);if(t.has(o))throw new RangeError(`[markdown-explorer] source ids must be unique; ${i.describeValue(o)} repeats at sourceIds[${String(n)}]`);t.add(o)}return Object.freeze({...e,sourceIds:Object.freeze([...r])})},at=e=>e.documentStyles.map(r=>r.name),dt=e=>Object.freeze({origins:e.appOrigins,resources:Object.freeze([e.dataPath]),links:Object.freeze([e.basePath,e.dataPath]),media:Object.freeze(e.mediaDataPath===null?[]:[e.mediaDataPath])}),u=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"}),Ce="true",Me="true",M="/",ge=".data",Ve=256,ze=/^\d+(?:\.\d+)?$/u,Z=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,je=Object.freeze(["showToc","showStyle","showAlign"]),Ee=e=>{const r=encodeURIComponent(e.replaceAll("%","%25"));return r.endsWith(ge)?`${r.slice(0,-ge.length)}%2Edata`:r},lt=e=>e.replaceAll("%25","%"),Ue=e=>{const{sourceIds:r}=e;if(r===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return r},ct=(e,r,t)=>{const n=t.getAll(u.source);if(n.length===0)return r;const[o]=n;return n.length>1||o===void 0||o===r||!e.includes(o)?null:o},Fe=(e,r)=>{const t=r.get(u.style),n=r.get(u.align);return{...t!==null&&e.documentStyles.some(o=>o.name===t)?{style:t}:{},...n!==null&&T.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},Be=e=>Number.isFinite(e)&&e>=0&&e<=Ve&&ze.test(String(e)),Ge=e=>{const r=e.get(u.padding),t=r!==null&&ze.test(r)?Number(r):Number.NaN,n=e.get(u.width),o=e.get(u.maxWidth);return{...e.get(u.showToc)==="false"?{showToc:!1}:{},...e.get(u.showStyle)==="false"?{showStyle:!1}:{},...e.get(u.showAlign)==="false"?{showAlign:!1}:{},...Be(t)?{padding:t}:{},...n!==null&&Z.test(n)?{width:n}:{},...o!==null&&Z.test(o)?{maxWidth:o}:{}}},Xe=(e,r)=>[...new Set(r.filter(g.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),ut=(e,r,t,n)=>{for(const s of r)oe(s);if(new Set(r).size!==r.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(r.length)} with repeats`);if(r.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(r.length)}`);if(t!==null&&!r.includes(t))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${i.describeValue(t)}`);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(s=>!r.includes(s));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${i.describeValue(o)}`)},oe=e=>{if(!g.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${i.describeValue(e)}`);return e},mt=e=>{if(!We(oe(e)))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${i.describeValue(e)}`);return e},We=e=>g.isAcceptableDocumentPath(e)&&!e.endsWith(M),ft=(e,r)=>{if(r.style!==void 0&&!e.documentStyles.some(t=>t.name===r.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(t=>i.describeValue(t.name)).join(", ")}); got ${i.describeValue(r.style)}`);if(r.align!==void 0&&!T.CONTENT_ALIGNS.includes(r.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${T.CONTENT_ALIGNS.join(", ")}; got ${i.describeValue(r.align)}`)},wt=e=>{for(const r of je)if(e[r]!==void 0&&typeof e[r]!="boolean")throw new RangeError(`[markdown-explorer] embed.${r} must be a boolean; got ${i.describeValue(e[r])}`);if(e.padding!==void 0&&!Be(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(Ve)} px in plain decimal digits; got ${i.describeValue(e.padding)}`);for(const r of["width","maxWidth"]){const t=e[r];if(t!==void 0&&!Z.test(t))throw new RangeError(`[markdown-explorer] embed.${r} must be a CSS length in px, rem, em, ch, vw or %; got ${i.describeValue(t)}`)}},ie=(e,r)=>{if(r.view==="document-id")return gt(e,r);const t=new URLSearchParams;let n=`${e.basePath}/${e.views[r.view]}`;if(r.view==="multi"){const s=r.docs??[],a=r.maximized??null,d=r.markup??[];ut(e,s,a,d);for(const l of s)t.append(u.doc,l);a!==null&&t.set(u.maximized,a);for(const l of s)d.includes(l)&&t.append(u.markup,l)}else{const s=r.doc??null,a=r.view==="tree"?r.folder??null:null;if(s!==null&&a!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");s!==null&&(n+=`/${Ee(mt(s))}`),a!==null&&(n+=`/${Ee(`${oe(a)}${M}`)}`)}if(r.source!==void 0){const s=Ue(e);if(!s.includes(r.source))throw new RangeError(`[markdown-explorer] unknown source ${i.describeValue(r.source)}; expected one of ${s.join(", ")}`);r.source!==s[0]&&t.set(u.source,r.source)}r.view!=="multi"&&r.overrides!==void 0&&He(e,t,r.overrides);const o=r.view!=="multi"&&(r.doc!==void 0&&r.doc!==null||r.view==="tree"&&r.folder!==void 0&&r.folder!==null);if(r.view==="tree"&&r.maximized===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");t.set(u.maximized,Me)}if(r.view!=="multi"&&r.markup===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");t.set(u.markup,Ce)}return r.view==="single"&&r.embed!==void 0&&Ke(t,r.embed),qe(n,t)},gt=(e,r)=>{if(e.documentIds===null)throw new TypeError("[markdown-explorer] an ID link needs documentIds in defineExplorerConfig");if(!g.isCanonicalDocumentId(r.id))throw new RangeError(`[markdown-explorer] not a canonical document ID: ${i.describeValue(r.id)}`);if(r.opens!==void 0&&r.opens!=="single")throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${i.describeValue(r.opens)}`);if(r.embed!==void 0&&r.opens!=="single")throw new RangeError('[markdown-explorer] embed needs opens: "single" (only the single view takes embedding options)');const t=new URLSearchParams;r.overrides!==void 0&&He(e,t,r.overrides),r.embed!==void 0&&Ke(t,r.embed);const n=r.opens==="single"?`/${e.views.single}`:"";return qe(`${e.basePath}/${e.documentIds.slug}/${r.id}${n}`,t)},He=(e,r,t)=>{ft(e,t),t.style!==void 0&&r.set(u.style,t.style),t.align!==void 0&&r.set(u.align,t.align)},Ke=(e,r)=>{wt(r);for(const t of je)r[t]===!1&&e.set(u[t],"false");r.padding!==void 0&&e.set(u.padding,String(r.padding)),r.width!==void 0&&e.set(u.width,r.width),r.maxWidth!==void 0&&e.set(u.maxWidth,r.maxWidth)},qe=(e,r)=>{const t=r.toString();return t===""?e:`${e}?${t}`},Et=(e,r)=>Object.keys(e.views).find(t=>e.views[t]===r),ht=(e,r,t)=>{const n=Ue(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const s=ct(n,o,t),a=s===null?o:s,d=p=>({kind:"redirect",href:ie(e,p),location:p}),l=()=>d({view:"tree",source:a,doc:null,folder:null,overrides:{},markup:!1,maximized:!1});if(r===void 0||r==="")return l();const m=r.indexOf("/"),w=m<0?r:r.slice(0,m),f=m<0?null:r.slice(m+1);if(e.documentIds!==null&&w===e.documentIds.slug)return pt(e,f,t,o,l);const c=Et(e,w);if(c===void 0)return l();if(c==="multi"){const p=t.getAll(u.doc),I=Xe(e,p),z=t.getAll(u.maximized),[j]=z,U=z.length===1&&j!==void 0&&I.includes(j)?j:null,F=t.getAll(u.markup),D=I.filter(A=>F.includes(A)),Ye=D.length===F.length&&D.every((A,B)=>A===F[B]);return f===null&&s!==null&&I.length===p.length&&I.every((A,B)=>A===p[B])&&(z.length===0||U!==null)&&Ye?{kind:"location",location:{view:"multi",source:a,docs:I,maximized:U,markup:D}}:d({view:"multi",source:a,docs:I,maximized:U,markup:D})}const x=f===null?null:lt(f),E=x?.endsWith(M)===!0?x.slice(0,-M.length):null,h=x!==null&&E===null?x:null;if(h!==null&&!g.isAcceptableDocumentPath(h)||E!==null&&!g.isAcceptableDocumentPath(E))return l();const k=Fe(e,t),P=(h!==null||E!==null)&&t.get(u.markup)===Ce;if(c==="single"){if(E!==null)return d({view:"tree",source:a,doc:null,folder:E,overrides:k,markup:P,maximized:!1});if(h===null)return l();const p=Ge(t);return s===null?d({view:c,source:a,doc:h,overrides:k,embed:p,markup:P}):{kind:"location",location:{view:c,source:a,doc:h,overrides:k,embed:p,markup:P}}}const se=(h!==null||E!==null)&&t.get(u.maximized)===Me;return s===null?d({view:c,source:a,doc:h,folder:E,overrides:k,markup:P,maximized:se}):{kind:"location",location:{view:c,source:a,doc:h,folder:E,overrides:k,markup:P,maximized:se}}},pt=(e,r,t,n,o)=>{if(r===null||r==="")return o();const s=r.indexOf("/"),a=g.parseDocumentId(s<0?r:r.slice(0,s)),d=s<0?null:r.slice(s+1),l=Fe(e,t),m={view:"tree",source:n,doc:null,folder:null,overrides:{},markup:!1,maximized:!1};return d===e.views.single?{kind:"document-id",id:a,opens:{view:"single",overrides:l,embed:Ge(t)},location:m}:d!==null&&a!==null?{kind:"redirect",href:ie(e,{view:"document-id",id:a,overrides:l}),location:m}:{kind:"document-id",id:a,opens:{view:"tree",overrides:l},location:m}},bt=(e,r,t)=>e.view==="single"?{view:"single",source:t,doc:r,overrides:e.overrides,embed:e.embed}:{view:"tree",source:t,doc:r,overrides:e.overrides};exports.ASSUMED_ROOT_FONT_PIXELS=Tr;exports.COARSE_TARGET_PIXELS=Ir;exports.COLUMN_MIN_MEASURE=Pr;exports.CONTROL_BLOCK_PIXELS=ne;exports.DEFAULT_TREE_SETTINGS=W;exports.DEFAULT_VIEW_SLUGS=q;exports.EDIT_SPLIT_DEFAULT_PERCENT=Dr;exports.EDIT_SPLIT_MAX_PERCENT=vr;exports.EDIT_SPLIT_MIN_PERCENT=Te;exports.EXPAND_ALL_DEPTH_LIMITS=Pe;exports.EXPAND_ALL_FOLDER_LIMITS=ke;exports.EXPLORER_DEFAULT_PERCENT=Sr;exports.EXPLORER_MAX_PERCENT=te;exports.EXPLORER_MIN_REM=Se;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Or;exports.FIBONACCI_SPACING_PIXELS=K;exports.GOLDEN_RATIO=b;exports.MULTI_VIEW_COLUMN_LIMITS=Re;exports.MULTI_VIEW_PANEL_LIMITS=Ie;exports.NAME_COLLATOR=N;exports.NO_TREE_SETTING_CHANGES=H;exports.PANEL_MAX_BLOCK_RATIO=Rr;exports.PANEL_MIN_BLOCK_RATIO=kr;exports.PREFETCH_DWELL_MS=$r;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=Ae;exports.SPLIT_HANDLE_PIXELS=yr;exports.SPLIT_PERSIST_DELAY_MS=Nr;exports.SPREADSHEET_BYTE_LIMITS=Le;exports.WORKBOOK_BYTE_LIMITS=Ne;exports.advanceTreeSetting=mr;exports.applyTreeSettingChanges=Er;exports.assertMountPath=Y;exports.canonicalMultiDocuments=Xe;exports.centeredDialogPosition=jr;exports.columnGroups=Vr;exports.createEntryComparator=xr;exports.decodeText=nr;exports.decodeTextLeniently=ir;exports.defineExplorerConfig=ve;exports.documentIdOpeningTarget=bt;exports.documentStyleNames=at;exports.editSplitOrientation=zr;exports.explorerHref=ie;exports.explorerMinPixels=Oe;exports.explorerSheetBelowPixels=Lr;exports.folderReadmeOf=lr;exports.formatTreeSettingValue=fr;exports.hasDocumentUrl=We;exports.isExplorerSourceId=$e;exports.legacyTextEncodingOf=Q;exports.ownUrlsOf=dt;exports.parseViewSettings=Wr;exports.readCookieValue=Xr;exports.readTreeSettingChanges=gr;exports.recordTreeSettingChange=hr;exports.replanVisibleColumns=Mr;exports.resolveExplorerLocation=ht;exports.revalidateExplorerConfig=it;exports.serializeTreeSettingChanges=pr;exports.serializeViewSettings=ye;exports.textEncodingOf=or;exports.textEncodingsOf=rr;exports.viewSettingsCookieString=Kr;exports.visibleTreeSettingDescriptors=ur;exports.withExplorerSources=st;
@@ -1,6 +1,6 @@
1
1
  import { NO_EMBEDS as Me, isEmbedProviderId as ze, EMBED_PROVIDER_IDS as Le, isLinkCardSize as je, LINK_CARD_SIZES as Fe } from "@aiquants/markdown/embeds";
2
2
  import { CONTENT_COLORS as Ue, CONTENT_MEASURES as Ve, CONTENT_ALIGNS as D, DEFAULT_MARKDOWN_STYLES as Be, DEFAULT_MARKDOWN_STYLE as We } from "@aiquants/markdown/viewer-settings";
3
- import { P as Ge, Q as He, R as Ke, S as Xe, i as $, K as qe, T as Ye } from "./ownUrls-DD0cSCsF.js";
3
+ import { P as Ge, Q as He, R as Ke, S as Xe, i as _, K as qe, T as Ye } from "./ownUrls-DD0cSCsF.js";
4
4
  import { d as s, i as v } from "./describeValue-CLlVRO8d.js";
5
5
  const Je = Object.freeze([
6
6
  "UTF-8",
@@ -224,12 +224,12 @@ const Je = Object.freeze([
224
224
  const d = at(i.modifiedAt, a.modifiedAt, t === "oldest" ? 1 : -1);
225
225
  return d !== 0 ? d : o(i, a);
226
226
  };
227
- }, y = (1 + Math.sqrt(5)) / 2, wr = 100 / y ** 3, gr = 100 / y ** 4, Ee = 100 / y ** 2, dt = 13, hr = 16, pr = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), se = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), lt = Object.freeze([89, 144, 233, 377]), xe = 44, Er = xe, xr = 24;
227
+ }, y = (1 + Math.sqrt(5)) / 2, wr = 100 / y ** 3, gr = 100 / y ** 4, Ee = 100 / y ** 2, dt = 13, hr = 16, pr = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), se = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), lt = Object.freeze([89, 144, 233, 377]), xe = 44, Er = xe;
228
228
  2 * se[3] + xe + se[0];
229
- const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
229
+ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
230
230
  if (!Number.isFinite(e) || e <= 0)
231
231
  throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${s(e)}`);
232
- }, mt = (e) => (ct(e), dt * e), Or = (e) => mt(e) * y ** 2, kr = 233, Tr = 50, ut = 100 / y ** 3, Rr = 100 - ut, Ir = lt[0], x = (e, t) => {
232
+ }, mt = (e) => (ct(e), dt * e), Sr = (e) => mt(e) * y ** 2, Or = 233, kr = 50, ut = 100 / y ** 3, Tr = 100 - ut, Rr = lt[0], x = (e, t) => {
233
233
  if (!Number.isFinite(t) || t < 0)
234
234
  throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${s(t)}`);
235
235
  }, ft = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
@@ -239,7 +239,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
239
239
  throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${s(n)}`);
240
240
  const o = Math.floor((e + t) / (r + t));
241
241
  return Math.min(n, Math.max(1, o));
242
- }, _r = (e, t) => {
242
+ }, Ir = (e, t) => {
243
243
  const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: i } = t;
244
244
  if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
245
245
  const d = ft(t);
@@ -254,14 +254,14 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
254
254
  if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
255
255
  throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${s(t)}`);
256
256
  return Array.from({ length: t }, (r, n) => [Math.floor(n * e / t), Math.floor((n + 1) * e / t)]);
257
- }, vr = (e, t, r) => {
257
+ }, _r = (e, t, r) => {
258
258
  if (x("surfaceInlineSize", e), x("handlePixels", r), !Number.isFinite(t) || t <= 0)
259
259
  throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${s(t)}`);
260
260
  return e >= 2 * t + r ? "beside" : "stacked";
261
261
  }, W = (e, t, r) => Math.max(t, Math.min(e, r)), ie = (e, t, r, n) => {
262
262
  const o = (W(e, 0, r) + W(t, 0, r)) / 2;
263
263
  return W(o - n / 2, 0, r - n);
264
- }, Pr = (e, t, r) => {
264
+ }, vr = (e, t, r) => {
265
265
  for (const [n, o] of Object.entries(e))
266
266
  if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${s(o)}`);
267
267
  return x("marginBox.width", t.width), x("marginBox.height", t.height), x("viewport.width", r.width), x("viewport.height", r.height), {
@@ -284,14 +284,14 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
284
284
  ...A(Ve, u) ? { measure: u } : {},
285
285
  ...A(Ue, w) ? { documentColors: w } : {}
286
286
  };
287
- }, Ar = (e, t) => {
287
+ }, Pr = (e, t) => {
288
288
  if (e !== null)
289
289
  for (const r of e.split(";")) {
290
290
  const n = r.indexOf("=");
291
291
  if (!(n < 0) && r.slice(0, n).trim() === t)
292
292
  return r.slice(n + 1).trim();
293
293
  }
294
- }, Dr = (e, t) => {
294
+ }, Ar = (e, t) => {
295
295
  if (e === void 0 || e === "") return {};
296
296
  try {
297
297
  return pt(JSON.parse(decodeURIComponent(e)), t);
@@ -312,7 +312,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
312
312
  ...e.documentColors === void 0 ? {} : { documentColors: e.documentColors }
313
313
  })
314
314
  );
315
- }, Nr = (e, t, r) => `${e}=${xt(t)}; Path=/; Max-Age=${String(wt)}; SameSite=Lax${r ? "; Secure" : ""}`, be = ["ctrl", "shift"], bt = (e) => typeof e == "string" && be.includes(e), de = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), yt = Object.freeze({ default: 12, min: 1, max: 64 }), St = Object.freeze({ default: 4, min: 1, max: 6 }), Ot = Object.freeze({ default: 500, min: 1, max: 1e4 }), kt = Object.freeze({ default: 16, min: 1, max: 64 }), Tt = Object.freeze({ default: 16, min: 1, max: 64 }), Rt = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), It = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ye = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, _t = /^[a-z0-9][a-z0-9-]*$/u, $t = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, le = (e, t) => {
315
+ }, Dr = (e, t, r) => `${e}=${xt(t)}; Path=/; Max-Age=${String(wt)}; SameSite=Lax${r ? "; Secure" : ""}`, be = ["ctrl", "shift"], bt = (e) => typeof e == "string" && be.includes(e), de = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), yt = Object.freeze({ default: 12, min: 1, max: 64 }), St = Object.freeze({ default: 4, min: 1, max: 6 }), Ot = Object.freeze({ default: 500, min: 1, max: 1e4 }), kt = Object.freeze({ default: 16, min: 1, max: 64 }), Tt = Object.freeze({ default: 16, min: 1, max: 64 }), Rt = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), It = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ye = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, $t = /^[a-z0-9][a-z0-9-]*$/u, _t = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, le = (e, t) => {
316
316
  if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${s(t)}`);
317
317
  if (!Ge(t))
318
318
  throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${s(t)}`);
@@ -436,7 +436,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
436
436
  const n = e.iframeHosts ?? [];
437
437
  if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${s(n)}`);
438
438
  for (const [c, E] of n.entries())
439
- if (typeof E != "string" || !$t.test(E))
439
+ if (typeof E != "string" || !_t.test(E))
440
440
  throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(E)}`);
441
441
  const o = Object.fromEntries(b("multiView", e.multiView, ["maxPanels", "columns"])), i = Object.fromEntries(b("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), a = Object.fromEntries(b("revealDocument", e.revealDocument, ["maxDepth"])), d = Object.fromEntries(b("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), l = e.documentStyles ?? Be;
442
442
  if (!Array.isArray(l) || l.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
@@ -485,7 +485,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
485
485
  maxWorkbookBytes: O("spreadsheets.maxWorkbookBytes", d.maxWorkbookBytes, It)
486
486
  })
487
487
  });
488
- }, Cr = (e) => {
488
+ }, Nr = (e) => {
489
489
  const t = e.embeds;
490
490
  if (!v(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${s(t)}`);
491
491
  if (Object.hasOwn(t, "linkCards"))
@@ -535,7 +535,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
535
535
  }
536
536
  const n = Object.keys(e).find((o) => !Object.hasOwn(t, o));
537
537
  return n === void 0 ? null : { kind: "extra", path: `${r}.${n}`, given: e[n] };
538
- }, Lt = (e) => typeof e == "string" && _t.test(e), Mr = (e, t) => {
538
+ }, Lt = (e) => typeof e == "string" && $t.test(e), Cr = (e, t) => {
539
539
  if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${s(e)}`);
540
540
  if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${s(t)}`);
541
541
  const r = /* @__PURE__ */ new Set();
@@ -545,7 +545,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
545
545
  r.add(o);
546
546
  }
547
547
  return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
548
- }, zr = (e) => e.documentStyles.map((t) => t.name), Lr = (e) => Object.freeze({
548
+ }, Mr = (e) => e.documentStyles.map((t) => t.name), zr = (e) => Object.freeze({
549
549
  origins: e.appOrigins,
550
550
  resources: Object.freeze([e.dataPath]),
551
551
  links: Object.freeze([e.basePath, e.dataPath]),
@@ -575,23 +575,23 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
575
575
  if (n.length === 0) return t;
576
576
  const [o] = n;
577
577
  return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
578
- }, _e = (e, t) => {
578
+ }, $e = (e, t) => {
579
579
  const r = t.get(m.style), n = t.get(m.align);
580
580
  return {
581
581
  ...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
582
582
  ...n !== null && D.includes(n) ? { align: n } : {}
583
583
  };
584
- }, $e = (e) => Number.isFinite(e) && e >= 0 && e <= ke && Te.test(String(e)), ve = (e) => {
584
+ }, _e = (e) => Number.isFinite(e) && e >= 0 && e <= ke && Te.test(String(e)), ve = (e) => {
585
585
  const t = e.get(m.padding), r = t !== null && Te.test(t) ? Number(t) : Number.NaN, n = e.get(m.width), o = e.get(m.maxWidth);
586
586
  return {
587
587
  ...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
588
588
  ...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
589
589
  ...e.get(m.showAlign) === "false" ? { showAlign: !1 } : {},
590
- ...$e(r) ? { padding: r } : {},
590
+ ..._e(r) ? { padding: r } : {},
591
591
  ...n !== null && K.test(n) ? { width: n } : {},
592
592
  ...o !== null && K.test(o) ? { maxWidth: o } : {}
593
593
  };
594
- }, Ut = (e, t) => [...new Set(t.filter($))].slice(0, e.multiView.maxPanels), Vt = (e, t, r, n) => {
594
+ }, Ut = (e, t) => [...new Set(t.filter(_))].slice(0, e.multiView.maxPanels), Vt = (e, t, r, n) => {
595
595
  for (const i of t) Y(i);
596
596
  if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);
597
597
  if (t.length > e.multiView.maxPanels) throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);
@@ -600,12 +600,12 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
600
600
  const o = n.find((i) => !t.includes(i));
601
601
  if (o !== void 0) throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${s(o)}`);
602
602
  }, Y = (e) => {
603
- if (!$(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
603
+ if (!_(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
604
604
  return e;
605
605
  }, Bt = (e) => {
606
606
  if (!Wt(Y(e))) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${s(e)}`);
607
607
  return e;
608
- }, Wt = (e) => $(e) && !e.endsWith(z), Gt = (e, t) => {
608
+ }, Wt = (e) => _(e) && !e.endsWith(z), Gt = (e, t) => {
609
609
  if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
610
610
  throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((r) => s(r.name)).join(", ")}); got ${s(t.style)}`);
611
611
  if (t.align !== void 0 && !D.includes(t.align))
@@ -613,7 +613,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
613
613
  }, Ht = (e) => {
614
614
  for (const t of Re)
615
615
  if (e[t] !== void 0 && typeof e[t] != "boolean") throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${s(e[t])}`);
616
- if (e.padding !== void 0 && !$e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${s(e.padding)}`);
616
+ if (e.padding !== void 0 && !_e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${s(e.padding)}`);
617
617
  for (const t of ["width", "maxWidth"]) {
618
618
  const r = e[t];
619
619
  if (r !== void 0 && !K.test(r)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${s(r)}`);
@@ -667,7 +667,7 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
667
667
  }, Ne = (e, t) => {
668
668
  const r = t.toString();
669
669
  return r === "" ? e : `${e}?${r}`;
670
- }, Xt = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), jr = (e, t, r) => {
670
+ }, Xt = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), Lr = (e, t, r) => {
671
671
  const n = Ie(e), [o] = n;
672
672
  if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
673
673
  const i = Ft(n, o, r), a = i === null ? o : i, d = (p) => ({ kind: "redirect", href: Pe(e, p), location: p }), l = () => d({ view: "tree", source: a, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 });
@@ -677,12 +677,12 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
677
677
  const c = Xt(e, w);
678
678
  if (c === void 0) return l();
679
679
  if (c === "multi") {
680
- const p = r.getAll(m.doc), k = Ut(e, p), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && k.includes(F) ? F : null, V = r.getAll(m.markup), P = k.filter((_) => V.includes(_)), Ce = P.length === V.length && P.every((_, B) => _ === V[B]);
681
- return f === null && i !== null && k.length === p.length && k.every((_, B) => _ === p[B]) && (j.length === 0 || U !== null) && Ce ? { kind: "location", location: { view: "multi", source: a, docs: k, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: k, maximized: U, markup: P });
680
+ const p = r.getAll(m.doc), k = Ut(e, p), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && k.includes(F) ? F : null, V = r.getAll(m.markup), P = k.filter(($) => V.includes($)), Ce = P.length === V.length && P.every(($, B) => $ === V[B]);
681
+ return f === null && i !== null && k.length === p.length && k.every(($, B) => $ === p[B]) && (j.length === 0 || U !== null) && Ce ? { kind: "location", location: { view: "multi", source: a, docs: k, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: k, maximized: U, markup: P });
682
682
  }
683
683
  const E = f === null ? null : jt(f), g = E?.endsWith(z) === !0 ? E.slice(0, -z.length) : null, h = E !== null && g === null ? E : null;
684
- if (h !== null && !$(h) || g !== null && !$(g)) return l();
685
- const R = _e(e, r), I = (h !== null || g !== null) && r.get(m.markup) === Se;
684
+ if (h !== null && !_(h) || g !== null && !_(g)) return l();
685
+ const R = $e(e, r), I = (h !== null || g !== null) && r.get(m.markup) === Se;
686
686
  if (c === "single") {
687
687
  if (g !== null) return d({ view: "tree", source: a, doc: null, folder: g, overrides: R, markup: I, maximized: !1 });
688
688
  if (h === null) return l();
@@ -693,73 +693,72 @@ const br = 1 / y, yr = 1 / y ** 3, Sr = "40ch", ct = (e) => {
693
693
  return i === null ? d({ view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J }) : { kind: "location", location: { view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J } };
694
694
  }, qt = (e, t, r, n, o) => {
695
695
  if (t === null || t === "") return o();
696
- const i = t.indexOf("/"), a = Ye(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = _e(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
696
+ const i = t.indexOf("/"), a = Ye(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = $e(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
697
697
  return d === e.views.single ? { kind: "document-id", id: a, opens: { view: "single", overrides: l, embed: ve(r) }, location: u } : d !== null && a !== null ? { kind: "redirect", href: Pe(e, { view: "document-id", id: a, overrides: l }), location: u } : { kind: "document-id", id: a, opens: { view: "tree", overrides: l }, location: u };
698
- }, Fr = (e, t, r) => e.view === "single" ? { view: "single", source: r, doc: t, overrides: e.overrides, embed: e.embed } : { view: "tree", source: r, doc: t, overrides: e.overrides };
698
+ }, jr = (e, t, r) => e.view === "single" ? { view: "single", source: r, doc: t, overrides: e.overrides, embed: e.embed } : { view: "tree", source: r, doc: t, overrides: e.overrides };
699
699
  export {
700
- Nr as $,
700
+ yr as $,
701
701
  dr as A,
702
702
  ir as B,
703
703
  Er as C,
704
- Or as D,
705
- Rr as E,
706
- xr as F,
707
- mt as G,
708
- Ee as H,
709
- wr as I,
710
- gr as J,
711
- hr as K,
712
- Tr as L,
713
- Pr as M,
704
+ Sr as D,
705
+ Tr as E,
706
+ mt as F,
707
+ Ee as G,
708
+ wr as H,
709
+ gr as I,
710
+ hr as J,
711
+ kr as K,
712
+ vr as L,
713
+ Rr as M,
714
714
  C as N,
715
- Ir as O,
716
- br as P,
717
- se as Q,
718
- y as R,
719
- kr as S,
720
- tr as T,
721
- mr as U,
722
- ar as V,
723
- cr as W,
724
- ur as X,
725
- ne as Y,
726
- lr as Z,
727
- xt as _,
715
+ se as O,
716
+ xr as P,
717
+ y as Q,
718
+ tr as R,
719
+ Or as S,
720
+ mr as T,
721
+ ar as U,
722
+ cr as V,
723
+ ur as W,
724
+ ne as X,
725
+ lr as Y,
726
+ xt as Z,
727
+ Dr as _,
728
728
  le as a,
729
- Sr as a0,
730
- re as a1,
731
- de as a2,
732
- kt as a3,
733
- Ot as a4,
734
- dt as a5,
735
- St as a6,
736
- yt as a7,
737
- Tt as a8,
738
- Rt as a9,
739
- It as aa,
740
- zt as ab,
729
+ re as a0,
730
+ de as a1,
731
+ kt as a2,
732
+ Ot as a3,
733
+ dt as a4,
734
+ St as a5,
735
+ yt as a6,
736
+ Tt as a7,
737
+ Rt as a8,
738
+ It as a9,
739
+ zt as aa,
741
740
  or as b,
742
741
  Ut as c,
743
742
  rr as d,
744
743
  Pe as e,
745
- zr as f,
746
- Cr as g,
747
- jr as h,
744
+ Mr as f,
745
+ Nr as g,
746
+ Lr as h,
748
747
  Lt as i,
749
- Fr as j,
748
+ jr as j,
750
749
  Wt as k,
751
750
  fe as l,
752
751
  ut as m,
753
752
  pr as n,
754
- Lr as o,
755
- Dr as p,
756
- vr as q,
757
- Ar as r,
753
+ zr as o,
754
+ Ar as p,
755
+ _r as q,
756
+ Pr as r,
758
757
  $r as s,
759
758
  nr as t,
760
- _r as u,
761
- yr as v,
762
- Mr as w,
759
+ Ir as u,
760
+ br as v,
761
+ Cr as w,
763
762
  sr as x,
764
763
  xe as y,
765
764
  fr as z
@@ -1,5 +1,5 @@
1
1
  import { diff3Merge as d } from "node-diff3";
2
- import { C, a as R, b as u } from "./index-C52Nj37x.js";
2
+ import { C, a as R, b as u } from "./index-BBJoJu-b.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-_XNluAcx.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-D6at9qMs.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(`
package/dist/server.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-BTPGNhBt.cjs"),v=require("./location-DOIG84V9.cjs"),P=require("./explorerCore-5qeC3-gt.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-DomN7lwC.cjs"),X=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,X.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,X.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,X.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Xe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},qe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),q=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>qe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,q),T=A.size>BigInt(q),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>Xe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-BTPGNhBt.cjs"),v=require("./location-DFXJSMit.cjs"),P=require("./explorerCore-Dj7RxZRd.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-DomN7lwC.cjs"),X=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,X.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,X.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,X.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Xe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},qe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),q=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>qe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,q),T=A.size>BigInt(q),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>Xe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;