@aiquants/markdown-explorer 0.24.1 → 0.25.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 (30) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +14 -5
  3. package/dist/{EditSurface-CFXG8Qok.js → EditSurface-Blymamic.js} +3 -3
  4. package/dist/{EditSurface-CiKQiYSD.cjs → EditSurface-Co4Rvfa1.cjs} +1 -1
  5. package/dist/{ExplorerSplit-DIkC3R7O.js → ExplorerSplit-BZ0PA3z3.js} +47 -47
  6. package/dist/{ExplorerSplit-BWMVatnB.cjs → ExplorerSplit-WApgYMPb.cjs} +1 -1
  7. package/dist/{MultiLayout-DXnuRzb4.js → MultiLayout-B5-1N3JD.js} +3 -3
  8. package/dist/{MultiLayout-q_Pvwykp.cjs → MultiLayout-dAW_JCzg.cjs} +1 -1
  9. package/dist/{NativeScrollBar-s_uSPPEd.js → NativeScrollBar-BraWuZvN.js} +1 -1
  10. package/dist/{NativeScrollBar-UYBG64v1.cjs → NativeScrollBar-ThVMbI0Y.cjs} +1 -1
  11. package/dist/{TreeLayout-Di0yv1E-.cjs → TreeLayout-C60lb9hP.cjs} +1 -1
  12. package/dist/{TreeLayout-BQ1lWVf3.js → TreeLayout-CChoxh9W.js} +3 -3
  13. package/dist/core/textEncoding.d.cts +1 -0
  14. package/dist/core/textEncoding.d.ts +1 -0
  15. package/dist/{index-ZdsIXJap.cjs → index-B6FkGD-p.cjs} +4 -4
  16. package/dist/{index-BhxsL0Sm.js → index-Bd6hgisa.js} +5 -5
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +3 -3
  19. package/dist/location-D3DgoELB.cjs +1 -0
  20. package/dist/{location-gXXmC7CQ.js → location-DIxIjqs7.js} +147 -140
  21. package/dist/{merge-CQAXBfvi.js → merge-CgSp-0Dd.js} +1 -1
  22. package/dist/{merge-DkmrVEIc.cjs → merge-DRWmjC24.cjs} +1 -1
  23. package/dist/server.cjs +1 -1
  24. package/dist/server.js +785 -725
  25. package/dist/{useSplitPersistence-Bmpb2prR.cjs → useSplitPersistence-D-T75Hlh.cjs} +1 -1
  26. package/dist/{useSplitPersistence-BPNjvuJi.js → useSplitPersistence-Df63lnQZ.js} +1 -1
  27. package/docs/behavior/security.md +5 -2
  28. package/docs/behavior/url-contract.md +3 -3
  29. package/package.json +1 -1
  30. package/dist/location-CasigkBk.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";const e=require("react"),d=require("./location-CasigkBk.cjs"),f="(pointer: coarse)",E=r=>{const n=window.matchMedia(f);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},S=()=>window.matchMedia(f).matches,m=()=>!1,C=()=>e.useSyncExternalStore(E,S,m),R=r=>{const n=e.useRef(r);e.useLayoutEffect(()=>{n.current=r},[r]);const c=e.useRef(null),t=e.useRef(null),s=e.useRef(!1),u=e.useCallback(()=>{t.current!==null&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,c.current!==null&&n.current(c.current)},d.SPLIT_PERSIST_DELAY_MS)},[]);e.useEffect(()=>()=>{t.current!==null&&clearTimeout(t.current)},[]);const a=e.useCallback((o,l)=>{c.current=o,l.source==="keyboard"?u():l.source==="pointer"&&(s.current=!0)},[u]),i=e.useCallback(o=>{if(o){s.current=!1;return}s.current&&(s.current=!1,u())},[u]);return e.useMemo(()=>({layoutChanged:a,draggingChanged:i}),[a,i])};exports.useCoarsePointer=C;exports.useSplitPersistence=R;
1
+ "use strict";const e=require("react"),d=require("./location-D3DgoELB.cjs"),f="(pointer: coarse)",E=r=>{const n=window.matchMedia(f);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},S=()=>window.matchMedia(f).matches,m=()=>!1,C=()=>e.useSyncExternalStore(E,S,m),R=r=>{const n=e.useRef(r);e.useLayoutEffect(()=>{n.current=r},[r]);const c=e.useRef(null),t=e.useRef(null),s=e.useRef(!1),u=e.useCallback(()=>{t.current!==null&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,c.current!==null&&n.current(c.current)},d.SPLIT_PERSIST_DELAY_MS)},[]);e.useEffect(()=>()=>{t.current!==null&&clearTimeout(t.current)},[]);const a=e.useCallback((o,l)=>{c.current=o,l.source==="keyboard"?u():l.source==="pointer"&&(s.current=!0)},[u]),i=e.useCallback(o=>{if(o){s.current=!1;return}s.current&&(s.current=!1,u())},[u]);return e.useMemo(()=>({layoutChanged:a,draggingChanged:i}),[a,i])};exports.useCoarsePointer=C;exports.useSplitPersistence=R;
@@ -1,5 +1,5 @@
1
1
  import { useSyncExternalStore as d, useRef as c, useLayoutEffect as E, useCallback as a, useEffect as S, useMemo as h } from "react";
2
- import { S as y } from "./location-gXXmC7CQ.js";
2
+ import { S as y } from "./location-DIxIjqs7.js";
3
3
  const m = "(pointer: coarse)", C = (e) => {
4
4
  const t = window.matchMedia(m);
5
5
  return t.addEventListener("change", e), () => t.removeEventListener("change", e);
@@ -112,12 +112,15 @@ In a tree or children listing, an entry with an empty name, or with a path the b
112
112
  It carries no refresh mark: the host's `asset` port receives `refresh: false`. The file is opened as the asset operation opens it — the first `textMaxBytes` bytes as a range when the port reports a longer size, the whole file otherwise, an empty file never — and the stream is cancelled once enough was read.
113
113
  - The `asset` operation answers bytes instead of JSON (its failures stay JSON failures with the statuses above). GET and HEAD only; a request whose own URL path ends in `.data` is 404 before authentication; signed out 401 and forbidden 403 with no redirect; a missing, repeated or unacceptable `path` 400; a denied or unadmitted path 403.
114
114
  After admission it answers 304 for a matching `If-None-Match`, 200 for the whole file (without `Accept-Ranges` and `Content-Length` when the host reports no size; empty with `Content-Length: 0` for an empty file), 206 for one satisfiable byte range, and 416 (`Content-Range: bytes */<size>`, `Cache-Control: private, no-store`) for a range starting at or after the end; HEAD carries the GET's status and headers without a body.
115
- `If-None-Match` matches the ETag (`"<version>"`) as RFC 9110 evaluates it: `*`, or a comma-separated list holding the ETag by the weak comparison, so `W/"<version>"` matches too, while a malformed element matches nothing; an `If-Range` counts only when it is the ETag itself (the strong comparison).
115
+ `If-None-Match` matches the ETag (`"<version>"`; `"<legacy encoding>;<version>"` for the plain-text display, below) as RFC 9110 evaluates it: `*`, or a comma-separated list holding the ETag by the weak comparison, so `W/"<version>"` matches too, while a malformed element matches nothing; an `If-Range` counts only when it is the ETag itself (the strong comparison).
116
116
  `If-None-Match` and `Range` are read only after admission, so a path outside every boundary is 403 even with a matching validator.
117
117
  Every 200, 206 and 304 carries the declared type as a browser parses it (else `application/octet-stream`), `X-Content-Type-Options: nosniff`, `Content-Disposition` (`inline` or `attachment`, see [What the explorer serves](#what-the-explorer-serves)), `Content-Security-Policy: default-src 'none'; media-src 'self'; style-src 'unsafe-inline'; sandbox` except for PDF, `Cross-Origin-Resource-Policy: same-origin`, `Cache-Control: private, max-age=60, stale-while-revalidate=600, no-transform` and `Vary: Cookie`.
118
118
  Inline audio and video get `sandbox allow-same-origin` instead of `sandbox`: the browser's media document of a file opened on its own fetches the file again, and under a plain `sandbox` its opaque origin would send that request cross-site, without the reader's `SameSite` cookie, to be answered 401; without `allow-scripts` no script runs.
119
119
  The authentication's headers (a refreshed session cookie) go onto every asset response; the reader's scope header never does.
120
120
  A body with a `Content-Length` carries exactly that many bytes: the bytes past it are dropped and the host's stream is cancelled, and a stream that ends short fails the response, so a file that changes while it is served never gets a body that disagrees with its length and ETag.
121
+ The plain-text display (`as=text`) names its `charset` from the file's first 64 KiB by the explorer's one text rule before it answers, holding the host's chunks that carry those bytes until they are sent:
122
+ a whole GET opens the file once and sends them first, and a HEAD or a range reads them on their own (as a range, or the whole file cancelled after them when the host reports no size; a range then opens its own bytes).
123
+ A beginning that ends before the reported size is answered `failed` (logged) before any header is sent. Its ETag is `"<legacy encoding>;<version>"` (the legacy encoding's written name, nothing when none is configured), so a cached copy revalidates into a new `charset` when the configuration changes. The bytes are sent as stored, never converted.
121
124
  - Responses never contain tokens, principals, server paths or raw error messages. A failure carries only its reason and an optional host-defined code (`[a-z0-9-]{1,64}`); everything else goes to the server's `logger`. `new ExplorerError` throws a `RangeError` for a malformed code, and a failure document returned with one is logged and sent as `failed`.
122
125
 
123
126
  - The `link-card` operation passes the answers of `@aiquants/markdown`'s link-card handler through unchanged (see [Link cards](#link-cards)): a card is `200` JSON with `Cache-Control: private, max-age=1800`, a link without a card `204 No Content` with `X-Link-Card-Skip`, and the handler's own errors JSON with `no-store`; each carries `nosniff` and never `Set-Cookie`. Only the explorer's own refusals in front of it (`not-found`, 405, a refused authentication) are the explorer's failure JSON above.
@@ -179,7 +182,7 @@ In a tree or children listing, an entry with an empty name, or with a path the b
179
182
  ## What the explorer serves
180
183
 
181
184
  - Any regular file the document admission admits, whatever its kind: the bytes of image and media documents, the whole file behind a text preview, every `file` document (a file the explorer cannot show) and every image embedded in Markdown.
182
- - Inline only for raster images, audio, video and PDF; everything else, SVG and an empty or unknown type included, as an attachment — unless the request asks for the plain-text display (`as=text`, the text viewers' Open in a new tab and a table file's preview), which shows any admitted file in place as `text/plain; charset=utf-8` whatever its declared type,
185
+ - Inline only for raster images, audio, video and PDF; everything else, SVG and an empty or unknown type included, as an attachment — unless the request asks for the plain-text display (`as=text`, the text viewers' Open in a new tab and a table file's preview), which shows any admitted file in place as `text/plain; charset=<encoding>` (the encoding the explorer's one text rule reads the file's first 64 KiB in) whatever its declared type,
183
186
  under the same `nosniff` and sandboxing policy, so an HTML or SVG file opened that way shows its source and runs nothing. Both dispositions name the file (`filename*=UTF-8''<name>`, the RFC 8187 encoding of the name with `'`, `(`, `)` and `*` percent-encoded too), so a saved file keeps its name although every asset URL's path ends in `asset`.
184
187
  - The type is the one the host declares, parsed as a browser parses it, never guessed from the name; `nosniff` stops the browser from guessing either, and the sandboxing policy keeps an SVG or HTML file opened on its own from running script.
185
188
  - For `createFileSystemSource`, files of unknown extensions are downloadable, and so are the whole bytes of every Markdown and text file the source admits: raw Markdown keeps what the rendered view drops (front matter, HTML comments), and a text file is served beyond its preview. Its deny rules — `DEFAULT_DENIED_PATH_SEGMENTS` (environment files, keys and certificates, credential files, Terraform state, shell histories) plus the host's `deny` patterns — are the only filter, so add a pattern for anything else the folder must withhold.
@@ -103,11 +103,11 @@ The explorer serves every file it shows or offers for download through the `asse
103
103
  | --- | --- |
104
104
  | Path | `<dataPath>/asset`. GET and HEAD only; any other method answers 405 with `Allow: GET, HEAD`. |
105
105
  | `path` | Required exactly once: the document path exactly as the explorer shows it (workspace-relative, `gcs://bucket/object`, `gdrive://…`), an acceptable document path; otherwise 400. `filePath` is not a parameter (`?filePath=` alone answers 400). |
106
- | `v` | Written only on the URL a document carries (image, media, text and file documents), from the version the host reported: a cache-buster the server never reads. The response's ETag is always the file's current version. |
107
- | `as` | Optional: `text` (exactly once) asks for the file as UTF-8 plain text shown in place (`text/plain; charset=utf-8`, `inline`), whatever type the host declares; any other value, an empty one or the parameter repeated answers 400 before the port is called. `explorerPlainTextHref(assetHref)` adds it to a text document's `url` for the text viewers' Open in a new tab. |
106
+ | `v` | Written only on the URL a document carries (image, media, text, spreadsheet and file documents), from the version the host reported: a cache-buster the server never reads. The response's ETag always names the file's current version (`"<version>"`, or `"<legacy encoding>;<version>"` with `as=text`). |
107
+ | `as` | Optional: `text` (exactly once) asks for the file as plain text shown in place (`text/plain; charset=<encoding>`, the encoding the explorer's one text rule reads the file's first 64 KiB in, `inline`), whatever type the host declares; any other value, an empty one or the parameter repeated answers 400 before the port is called. `explorerPlainTextHref(assetHref)` adds it to a text or spreadsheet document's `url` for the viewers' Open in a new tab. |
108
108
  | Encoding | `encodeURIComponent` once, decoded once by `URLSearchParams`: exact for `%`, `#`, `?`, `+`, spaces, NFC and NFD names and a trailing `.data`. The request's own path always ends in `asset`, never in `.data`, so no name needs another escape. |
109
109
 
110
- Two writers call it: the copy of the host's `document` answer, for the `url` of image, media, text and file documents (with `v`), and the sanitizer, for images marked with `data-asset-src` (without `v`). With `dataPath` `/docs/_data`:
110
+ Two writers call it: the copy of the host's `document` answer, for the `url` of image, media, text, spreadsheet and file documents (with `v`), and the sanitizer, for images marked with `data-asset-src` (without `v`). With `dataPath` `/docs/_data`:
111
111
 
112
112
  - `![](./images/diagram.png)` in `guide/README.md` → `<img data-asset-src="guide/images/diagram.png" data-asset-exists="true">` from the parser → `src="/docs/_data/asset?path=guide%2Fimages%2Fdiagram.png"` after the sanitizer.
113
113
  - An image document opened in the tree view: `url: "/docs/_data/asset?path=guide%2Fimages%2Fdiagram.png&v=<version>"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/markdown-explorer",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Markdown document explorer for React Router 8 (framework mode): a source tree with a single-document view and a multi-panel reading view, storage-agnostic server ports, golden-ratio layout and an en / ja UI.",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -1 +0,0 @@
1
- "use strict";const I=require("@aiquants/markdown/embeds"),k=require("@aiquants/markdown/viewer-settings"),N=require("./dataRoute-Cv7fgCW7.cjs"),y=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},De=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"]),ve=new Map(De.map(e=>[e.toLowerCase(),e])),$="UTF-8",te=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"})]),je=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 t;try{t=new TextDecoder(e).encoding}catch(o){throw o instanceof RangeError?new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`):o}const n=ze(t),r=je.get(n);if(r!==void 0)throw new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} names ${n}, which cannot be the legacy encoding: it ${r}`);return n},ze=e=>{const t=ve.get(e);if(t===void 0)throw new RangeError(`[markdown-explorer] TextDecoder answered ${JSON.stringify(e)}, which is no encoding of the WHATWG Encoding Standard`);return t},Y=(e,t,n)=>{const r=n===null?null:q(n),o=te.find(({bytes:s})=>s.every((a,l)=>e[l]===a));if(o!==void 0)return{body:e.subarray(o.bytes.length),encodings:[o.encoding]};const i=t||e.length===0?void 0:te.find(({bytes:s})=>e.length<s.length&&e.every((a,l)=>s[l]===a));return i!==void 0?{body:e.subarray(e.length),encodings:[i.encoding]}:{body:e,encodings:r===null?[$]:[$,r]}},Fe=(e,t,n)=>Y(e,t,n).encodings,Ue=(e,t,n)=>{try{return new TextDecoder(e,{fatal:!0,ignoreBOM:!0}).decode(t,{stream:!n})}catch(r){if(r instanceof TypeError)return null;throw r}},Ve=(e,t,n)=>fe(Y(e,t,n),t),fe=({body:e,encodings:t},n)=>{for(const r of t){const o=Ue(r,e,n);if(o!==null)return o}return null},Ge=(e,t,n)=>{const r=Y(e,t,n),o=fe(r,t);return o!==null?o:new TextDecoder(r.encodings[0],{ignoreBOM:!0}).decode(r.body,{stream:!t})},A=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),Xe=/^readme(?:\.|$)/iu,ne=/^readme(?:\.[^.]*)?$/iu,re=Object.freeze(["md","markdown","mdx","txt",""]),Je=e=>Xe.test(e),X=e=>e.type==="file"&&Je(e.name),oe=e=>{const t=e.lastIndexOf("."),n=re.indexOf(t<0?"":e.slice(t+1).toLowerCase());return n<0?re.length:n},Be=(e,t)=>{const n=+!ne.test(e.name)-+!ne.test(t.name);if(n!==0)return n;const r=oe(e.name)-oe(t.name);if(r!==0)return r;const o=A.compare(e.name,t.name);return o!==0?o:A.compare(e.path,t.path)},We=e=>{let t=null;for(const n of e)X(n)&&(t===null||Be(n,t)<0)&&(t=n);return t===null?null:t.path},J=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),He=[!0,!1],Ke=(e,t)=>t?e.settingOn:e.settingOff,p=(e,t)=>({key:e,labelKey:t,values:He,formatValue:Ke,requiresItemSelection:!1}),qe=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),T=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,t)=>qe[t](e),requiresItemSelection:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.folderPlacementMixed:t==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresItemSelection:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.readmePlacementMixed:t==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresItemSelection:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},p("alwaysExpanded","settingAlwaysExpanded"),p("revealDocument","settingRevealDocument"),p("removeRootIndent","settingRemoveRootIndent"),p("lines","settingTreeLines"),p("expandIcons","settingExpandIcons"),p("directoryIcons","settingDirectoryIcons"),p("fileIcons","settingFileIcons")]),Ye=e=>e?T:T.filter(t=>!t.requiresItemSelection),ue=e=>{const t=T.find(n=>n.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},Ze=(e,t)=>{const n=ue(t).values,r=n[(n.indexOf(e[t])+1)%n.length];return{...e,[t]:r}},Qe=(e,t,n)=>ue(n).formatValue(e,t[n]),ge=2,B=Object.freeze({}),Z=(e,t)=>Object.freeze(Object.fromEntries(T.filter(n=>t(n,e[n.key])).map(n=>[n.key,e[n.key]]))),ie="directoriesFirst",et=e=>{if(!Object.hasOwn(e,ie))return e;const{[ie]:t,...n}=e;return Object.hasOwn(n,"folderPlacement")||typeof t!="boolean"?n:{...n,folderPlacement:t?"first":"mixed"}},tt=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return B;const t=e;return t.version!==ge||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?B:Z(et(t.settings),(n,r)=>n.values.includes(r))},nt=(e,t)=>{const n=Z(t,(r,o)=>o!==void 0&&o!==e[r.key]);return Object.keys(n).length===0?e:Object.freeze({...e,...n})},rt=(e,t,n,r)=>Z({...e,[t]:n},(o,i)=>i!==void 0&&!(o.key===t&&i===r[t])),ot=e=>JSON.stringify({version:ge,settings:e}),it=(e,t,n)=>e===void 0||t===void 0?e===t?0:e===void 0?1:-1:n*(e-t),st=e=>{const{sortMode:t,folderPlacement:n,readmePlacement:r}=e;if(t==="native"&&n==="mixed"&&r==="mixed")return;const o=(i,s)=>{const a=A.compare(i.name,s.name);return a!==0?a:A.compare(i.path,s.path)};return(i,s)=>{if(n!=="mixed"&&i.type!==s.type)return i.type==="directory"==(n==="first")?-1:1;if(r!=="mixed"){const l=X(i);if(l!==X(s))return l===(r==="first")?-1:1}if(t==="native")return 0;if(t==="asc")return o(i,s);if(t==="desc")return-o(i,s);const a=it(i.modifiedAt,s.modifiedAt,t==="oldest"?1:-1);return a!==0?a:o(i,s)}},u=(1+Math.sqrt(5))/2,at=100/u**3,ct=100/u**4,Q=100/u**2,Ee=13,lt=16,dt=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),mt=Object.freeze([89,144,233,377]),we=44,ft=we,ut=24,gt=1/u,Et=1/u**3,wt="40ch",ht=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},he=e=>(ht(e),Ee*e),pt=e=>he(e)*u**2,St=233,xt=50,pe=100/u**3,Ot=100-pe,yt=mt[0],w=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},Tt=({trackInlineSize:e,gap:t,minColumnInlineSize:n,logicalColumns:r})=>{if(w("trackInlineSize",e),w("gap",t),!Number.isFinite(n)||n<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(n)}`);if(!Number.isInteger(r)||r<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(r)}`);const o=Math.floor((e+t)/(n+t));return Math.min(r,Math.max(1,o))},bt=(e,t)=>{const{trackInlineSize:n,gap:r,minColumnInlineSize:o,logicalColumns:i}=t;if(!([n,r,o].every(Number.isFinite)&&n>0&&r>=0&&o>0))return e;const a=Tt(t);if(e===null||a===e)return a;const l=Math.min(i,Math.max(1,e));if(a>l){const D=(l+1)*o+l*r+r/u;return n>=D?a:l}return n>=l*o+(l-1)*r?l:a},_t=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(n,r)=>[Math.floor(r*e/t),Math.floor((r+1)*e/t)])},Rt=(e,t,n)=>{if(w("surfaceInlineSize",e),w("handlePixels",n),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);return e>=2*t+n?"beside":"stacked"},G=(e,t,n)=>Math.max(t,Math.min(e,n)),se=(e,t,n,r)=>{const o=(G(e,0,n)+G(t,0,n))/2;return G(o-r/2,0,n-r)},It=(e,t,n)=>{for(const[r,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${r} must be a finite number; got ${String(o)}`);return w("marginBox.width",t.width),w("marginBox.height",t.height),w("viewport.width",n.width),w("viewport.height",n.height),{left:se(e.left,e.right,n.width,t.width),top:se(e.top,e.bottom,n.height,t.height)}},kt=31536e3,Nt=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,At=e=>{if(typeof e!="string"||!Nt.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},ae=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=Q,Pt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const n=e,{treeExplorer:r,multiExplorer:o,style:i,align:s}=n;return{...ae(r)?{treeExplorer:r}:{},...ae(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof s=="string"&&k.CONTENT_ALIGNS.includes(s)?{align:s}:{}}},Lt=(e,t)=>{if(e!==null)for(const n of e.split(";")){const r=n.indexOf("=");if(!(r<0)&&n.slice(0,r).trim()===t)return n.slice(r+1).trim()}},$t=(e,t)=>{if(e===void 0||e==="")return{};try{return Pt(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},C=100,Ct=Math.floor(Q*C)/C,Mt=e=>{const t=n=>Math.min(Ct,Math.max(1,Math.round(n*C))/C);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},Dt=(e,t,n)=>`${e}=${Mt(t)}; Path=/; Max-Age=${String(kt)}; SameSite=Lax${n?"; Secure":""}`,W=Object.freeze({tree:"tree",multi:"multi",single:"single"}),Se=Object.freeze({default:12,min:1,max:64}),xe=Object.freeze({default:4,min:1,max:6}),Oe=Object.freeze({default:500,min:1,max:1e4}),ye=Object.freeze({default:16,min:1,max:64}),Te=Object.freeze({default:16,min:1,max:64}),be=Object.freeze({default:2*1024*1024,min:1,max:256*1024*1024}),vt=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,jt=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,zt=/^[a-z0-9][a-z0-9-]*$/u,Ft=/^(?=.{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,ce=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!vt.test(t)||t.split("/").some(n=>n==="."||n===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},m=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?y(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),le=Object.freeze(Object.keys({basePath:!0,dataPath:!0,settingsCookie:!0,views:!0,multiView:!0,expandAll:!0,revealDocument:!0,documentStyles:!0,iframeHosts:!0,embeds:!0,defaultTreeSettings:!0,legacyTextEncoding:!0,spreadsheets:!0})),S=(e,t,n)=>{if(t===void 0)return[];if(!y(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${m(t)}`);const r=Object.entries(t);for(const[o]of r)if(!n.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${n.join(", ")}`);return r.filter(([,o])=>o!==void 0)},Ut=e=>{const t={...W};for(const[n,r]of S("views",e,Object.keys(W)))t[n]=r;for(const[n,r]of Object.entries(t))if(typeof r!="string"||!jt.test(r))throw new RangeError(`[markdown-explorer] views.${n} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(r)}`);return Object.freeze(t)},O=(e,t,n)=>{if(t===void 0)return n.default;if(typeof t!="number"||!Number.isInteger(t)||t<n.min||t>n.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${m(t)}`);return t},Vt=(e,t)=>{const n=new Map(S("embeds",e,["providers","linkCards","linkCardSize"]));if(n.size===0)return I.NO_EMBEDS;const r=n.has("providers")?n.get("providers"):[];if(!Array.isArray(r))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${m(r)}`);for(const a of r)if(!I.isEmbedProviderId(a))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${I.EMBED_PROVIDER_IDS.join(", ")}; got ${m(a)}`);const o=n.has("linkCards")?n.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${m(o)}`);const i={providers:Object.freeze([...new Set(r)]),linkCardEndpoint:o?N.explorerLinkCardEndpoint(t):null};if(!n.has("linkCardSize"))return Object.freeze(i);const s=n.get("linkCardSize");if(!I.isLinkCardSize(s))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${I.LINK_CARD_SIZES.join(", ")}; got ${m(s)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${m(s)} with linkCards ${m(o)}`);return Object.freeze({...i,linkCardSize:s})},Gt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${m(e)}`);return q(e)},Xt=e=>{const t=new Map(S("defaultTreeSettings",e,T.map(r=>r.key)));if(t.size===0)return J;const n={...J};for(const r of T){if(!t.has(r.key))continue;const o=t.get(r.key),i=r.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${i.map(m).join(", ")}; got ${m(o)}`);n[r.key]=o}return Object.freeze(n)},_e=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(!le.includes(c))throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${le.join(", ")}`);ce("basePath",e.basePath),ce("dataPath",e.dataPath);const t=Ut(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const c=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(c===t.tree||c===t.multi||c===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}At(e.settingsCookie);const n=e.iframeHosts??[];if(!Array.isArray(n)||n.some(c=>typeof c!="string"||!Ft.test(c)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(n)}`);const r=Object.fromEntries(S("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(S("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=Object.fromEntries(S("revealDocument",e.revealDocument,["maxDepth"])),s=Object.fromEntries(S("spreadsheets",e.spreadsheets,["maxBytes"])),a=e.documentStyles??k.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(a)||a.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const l=new Set;for(const c of a){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(l.has(c.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(c.name)} repeats`);l.add(c.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:O("multiView.maxPanels",r.maxPanels,Se),columns:O("multiView.columns",r.columns,xe)}),expandAll:Object.freeze({maxFolders:O("expandAll.maxFolders",o.maxFolders,Oe),maxDepth:O("expandAll.maxDepth",o.maxDepth,ye)}),revealDocument:Object.freeze({maxDepth:O("revealDocument.maxDepth",i.maxDepth,Te)}),documentStyles:Object.freeze(a.map(c=>Object.freeze({name:c.name,className:c.className}))),iframeHosts:Object.freeze([...new Set(n)]),embeds:Vt(e.embeds,e.dataPath),defaultTreeSettings:Xt(e.defaultTreeSettings),legacyTextEncoding:Gt(e.legacyTextEncoding),spreadsheets:Object.freeze({maxBytes:O("spreadsheets.maxBytes",s.maxBytes,be)})})},Jt=e=>{const t=e.embeds;if(!y(t))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${m(t)}`);if(Object.hasOwn(t,"linkCards"))throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${m(t.linkCards)})`);const n=e.legacyTextEncoding;if(n!==null&&typeof n!="string")throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${m(n)}`);const{linkCardEndpoint:r,...o}=t,i=_e({...e,embeds:{...o,linkCards:r!==null},legacyTextEncoding:n===null?void 0:n});if(i.embeds.linkCardEndpoint!==r)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${m(i.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${m(r)}`);if(i.legacyTextEncoding!==n)throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${m(i.legacyTextEncoding)} (the written name of the encoding it names); got ${m(n)}`);const s=e;for(const[a,l]of Object.entries(i)){const c=H(s[a],l,a);if(c!==null)throw c.kind==="extra"?new RangeError(`[markdown-explorer] config.${c.path} is not a key of what defineExplorerConfig resolves; got ${m(c.given)} there`):new RangeError(`[markdown-explorer] config.${c.path} must be what defineExplorerConfig resolves; got ${m(c.given)} where it resolves ${m(c.resolved)}`)}return i},H=(e,t,n)=>{if(Object.is(e,t))return null;if(Array.isArray(t)){if(!Array.isArray(e))return{kind:"value",path:n,given:e,resolved:t};if(e.length!==t.length)return{kind:"value",path:`${n}.length`,given:e.length,resolved:t.length};for(const[o,i]of t.entries()){const s=H(e[o],i,`${n}[${String(o)}]`);if(s!==null)return s}return null}if(!(y(t)&&y(e)))return{kind:"value",path:n,given:e,resolved:t};for(const o of Object.keys(t)){const i=H(Object.hasOwn(e,o)?e[o]:void 0,t[o],`${n}.${o}`);if(i!==null)return i}const r=Object.keys(e).find(o=>!Object.hasOwn(t,o));return r===void 0?null:{kind:"extra",path:`${n}.${r}`,given:e[r]}},Re=e=>typeof e=="string"&&zt.test(e),Bt=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${m(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${m(t)}`);for(const n of t)if(!Re(n))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${m(n)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},Wt=e=>e.documentStyles.map(t=>t.name),d=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"}),Ie="true",M="/",de=".data",ke=256,Ne=/^\d+(?:\.\d+)?$/u,K=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,Ae=Object.freeze(["showToc","showStyle","showAlign"]),me=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(de)?`${t.slice(0,-de.length)}%2Edata`:t},Ht=e=>e.replaceAll("%25","%"),Pe=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},Kt=(e,t,n)=>{const r=n.getAll(d.source);if(r.length===0)return t;const[o]=r;return r.length>1||o===void 0||o===t||!e.includes(o)?null:o},qt=(e,t)=>{const n=t.get(d.style),r=t.get(d.align);return{...n!==null&&e.documentStyles.some(o=>o.name===n)?{style:n}:{},...r!==null&&k.CONTENT_ALIGNS.includes(r)?{align:r}:{}}},Le=e=>Number.isFinite(e)&&e>=0&&e<=ke&&Ne.test(String(e)),Yt=e=>{const t=e.get(d.padding),n=t!==null&&Ne.test(t)?Number(t):Number.NaN,r=e.get(d.width),o=e.get(d.maxWidth);return{...e.get(d.showToc)==="false"?{showToc:!1}:{},...e.get(d.showStyle)==="false"?{showStyle:!1}:{},...e.get(d.showAlign)==="false"?{showAlign:!1}:{},...Le(n)?{padding:n}:{},...r!==null&&K.test(r)?{width:r}:{},...o!==null&&K.test(o)?{maxWidth:o}:{}}},$e=(e,t)=>[...new Set(t.filter(N.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),Zt=(e,t,n,r)=>{for(const i of t)ee(i);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);if(t.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);if(n!==null&&!t.includes(n))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(n.slice(0,80))}`);if(new Set(r).size!==r.length)throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(r.length)} with repeats`);const o=r.find(i=>!t.includes(i));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0,80))}`)},ee=e=>{if(!N.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},Qt=e=>{if(ee(e).endsWith(M))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0,80))}`);return e},en=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(n=>n.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(n=>JSON.stringify(n.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!k.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${k.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},tn=e=>{for(const t of Ae)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!Le(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const n=e[t];if(n!==void 0&&!K.test(n))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(n)}`)}},Ce=(e,t)=>{const n=new URLSearchParams;let r=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],s=t.maximized??null,a=t.markup??[];Zt(e,i,s,a);for(const l of i)n.append(d.doc,l);s!==null&&n.set(d.maximized,s);for(const l of i)a.includes(l)&&n.append(d.markup,l)}else{const i=t.doc??null,s=t.view==="tree"?t.folder??null:null;if(i!==null&&s!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");i!==null&&(r+=`/${me(Qt(i))}`),s!==null&&(r+=`/${me(`${ee(s)}${M}`)}`)}if(t.source!==void 0){const i=Pe(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&n.set(d.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&(en(e,t.overrides),t.overrides.style!==void 0&&n.set(d.style,t.overrides.style),t.overrides.align!==void 0&&n.set(d.align,t.overrides.align)),t.view!=="multi"&&t.markup===!0){if(!(t.doc!==void 0&&t.doc!==null||t.view==="tree"&&t.folder!==void 0&&t.folder!==null))throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");n.set(d.markup,Ie)}if(t.view==="single"&&t.embed!==void 0){const{embed:i}=t;tn(i);for(const s of Ae)i[s]===!1&&n.set(d[s],"false");i.padding!==void 0&&n.set(d.padding,String(i.padding)),i.width!==void 0&&n.set(d.width,i.width),i.maxWidth!==void 0&&n.set(d.maxWidth,i.maxWidth)}const o=n.toString();return o===""?r:`${r}?${o}`},nn=(e,t)=>Object.keys(e.views).find(n=>e.views[n]===t),rn=(e,t,n)=>{const r=Pe(e),[o]=r;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=Kt(r,o,n),s=i===null?o:i,a=f=>({kind:"redirect",href:Ce(e,f),location:f}),l=()=>a({view:"tree",source:s,doc:null,folder:null,overrides:{},markup:!1});if(t===void 0||t==="")return l();const c=t.indexOf("/"),D=c<0?t:t.slice(0,c),v=c<0?null:t.slice(c+1),h=nn(e,D);if(h===void 0)return l();if(h==="multi"){const f=n.getAll(d.doc),x=$e(e,f),j=n.getAll(d.maximized),[z]=j,F=j.length===1&&z!==void 0&&x.includes(z)?z:null,U=n.getAll(d.markup),L=x.filter(R=>U.includes(R)),Me=L.length===U.length&&L.every((R,V)=>R===U[V]);return v===null&&i!==null&&x.length===f.length&&x.every((R,V)=>R===f[V])&&(j.length===0||F!==null)&&Me?{kind:"location",location:{view:"multi",source:s,docs:x,maximized:F,markup:L}}:a({view:"multi",source:s,docs:x,maximized:F,markup:L})}const P=v===null?null:Ht(v),g=P?.endsWith(M)===!0?P.slice(0,-M.length):null,E=P!==null&&g===null?P:null;if(E!==null&&!N.isAcceptableDocumentPath(E)||g!==null&&!N.isAcceptableDocumentPath(g))return l();const b=qt(e,n),_=(E!==null||g!==null)&&n.get(d.markup)===Ie;if(h==="single"){if(g!==null)return a({view:"tree",source:s,doc:null,folder:g,overrides:b,markup:_});if(E===null)return l();const f=Yt(n);return i===null?a({view:h,source:s,doc:E,overrides:b,embed:f,markup:_}):{kind:"location",location:{view:h,source:s,doc:E,overrides:b,embed:f,markup:_}}}return i===null?a({view:h,source:s,doc:E,folder:g,overrides:b,markup:_}):{kind:"location",location:{view:h,source:s,doc:E,folder:g,overrides:b,markup:_}}};exports.ASSUMED_ROOT_FONT_PIXELS=lt;exports.COARSE_TARGET_PIXELS=ft;exports.COLUMN_MIN_MEASURE=wt;exports.CONTROL_BLOCK_PIXELS=we;exports.DEFAULT_TREE_SETTINGS=J;exports.DEFAULT_VIEW_SLUGS=W;exports.EDIT_SPLIT_DEFAULT_PERCENT=xt;exports.EDIT_SPLIT_MAX_PERCENT=Ot;exports.EDIT_SPLIT_MIN_PERCENT=pe;exports.EXPAND_ALL_DEPTH_LIMITS=ye;exports.EXPAND_ALL_FOLDER_LIMITS=Oe;exports.EXPLORER_DEFAULT_PERCENT=at;exports.EXPLORER_MAX_PERCENT=Q;exports.EXPLORER_MIN_REM=Ee;exports.EXPLORER_MULTI_DEFAULT_PERCENT=ct;exports.FINE_TARGET_PIXELS=ut;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=xe;exports.MULTI_VIEW_PANEL_LIMITS=Se;exports.NAME_COLLATOR=A;exports.NO_TREE_SETTING_CHANGES=B;exports.PANEL_MAX_BLOCK_RATIO=gt;exports.PANEL_MIN_BLOCK_RATIO=Et;exports.PREFETCH_DWELL_MS=yt;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=Te;exports.SPLIT_HANDLE_PIXELS=dt;exports.SPLIT_PERSIST_DELAY_MS=St;exports.SPREADSHEET_BYTE_LIMITS=be;exports.advanceTreeSetting=Ze;exports.applyTreeSettingChanges=nt;exports.canonicalMultiDocuments=$e;exports.centeredDialogPosition=It;exports.columnGroups=_t;exports.createEntryComparator=st;exports.decodeText=Ve;exports.decodeTextLeniently=Ge;exports.defineExplorerConfig=_e;exports.documentStyleNames=Wt;exports.editSplitOrientation=Rt;exports.explorerHref=Ce;exports.explorerMinPixels=he;exports.explorerSheetBelowPixels=pt;exports.folderReadmeOf=We;exports.formatTreeSettingValue=Qe;exports.isExplorerSourceId=Re;exports.isPlainObject=y;exports.legacyTextEncodingOf=q;exports.parseViewSettings=$t;exports.readCookieValue=Lt;exports.readTreeSettingChanges=tt;exports.recordTreeSettingChange=rt;exports.replanVisibleColumns=bt;exports.resolveExplorerLocation=rn;exports.revalidateExplorerConfig=Jt;exports.serializeTreeSettingChanges=ot;exports.textEncodingsOf=Fe;exports.viewSettingsCookieString=Dt;exports.visibleTreeSettingDescriptors=Ye;exports.withExplorerSources=Bt;