@aiquants/markdown-explorer 0.1.0 → 0.2.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 +30 -1
  2. package/README.md +31 -13
  3. package/dist/{ExplorerSplit-BESGFcu6.cjs → ExplorerSplit-D2plJRRe.cjs} +1 -1
  4. package/dist/{ExplorerSplit-DwEFmvQM.js → ExplorerSplit-DB37U7Kh.js} +3 -3
  5. package/dist/MultiLayout-DCPDu1-l.js +909 -0
  6. package/dist/MultiLayout-UyWxs6Xy.cjs +1 -0
  7. package/dist/TreeLayout-BoyFelK2.js +22 -0
  8. package/dist/TreeLayout-CLWbWjOc.cjs +1 -0
  9. package/dist/core/config.d.cts +6 -0
  10. package/dist/core/config.d.ts +6 -0
  11. package/dist/core/labels.d.cts +6 -1
  12. package/dist/core/labels.d.ts +6 -1
  13. package/dist/{index-BgkZ9ATV.js → index-BfuAu2GV.js} +947 -901
  14. package/dist/index-Cx3-jSna.cjs +3 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/location-Oo21lTyV.cjs +1 -0
  18. package/dist/{location-Cb2Ak55B.js → location-fVl2R1ee.js} +154 -141
  19. package/dist/sanitizeWorker.cjs +1 -1
  20. package/dist/sanitizeWorker.js +196 -206
  21. package/dist/server.cjs +1 -1
  22. package/dist/server.js +1 -1
  23. package/dist/styles/markdown-explorer.css +1 -1
  24. package/docs/behavior/dom-hooks.md +4 -4
  25. package/docs/behavior/layout.md +21 -9
  26. package/docs/behavior/localization.md +4 -3
  27. package/docs/behavior/security.md +7 -3
  28. package/docs/behavior/url-contract.md +8 -2
  29. package/package.json +5 -5
  30. package/dist/MultiLayout-DxPiARsv.js +0 -896
  31. package/dist/MultiLayout-r_qx1Mfz.cjs +0 -1
  32. package/dist/TreeLayout-9-20bbSM.cjs +0 -1
  33. package/dist/TreeLayout-CW7lgV_e.js +0 -19
  34. package/dist/index-y9tVvDW7.cjs +0 -3
  35. package/dist/location-DWHQYntR.cjs +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,35 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 (unreleased)
3
+ ## 0.2.0 (2026-10-07)
4
+
5
+ ### Changed
6
+
7
+ - **Refresh tree**: the explorer's tree refresh button reads **Refresh tree** (`refreshTreeLabel`, a visible label that is also its accessible name; tooltip `refreshTree` unchanged) instead of **Refresh**, so it is told apart from the new **Refresh document**. It still reloads the tree and then reads the documents again with the refresh header. The shared visible label `refresh` is removed: a host that overrode it sets `refreshTreeLabel` and `refreshDocumentLabel` instead.
8
+ Where the explorer pane is too narrow for the whole label, the button shrinks and ends its label with an ellipsis rather than pushing the pane sideways, as Refresh document does in its bar; the accessible name stays the whole label.
9
+ - **Single view refresh**: the single view's toolbar is the shared document refresh bar. Its DOM hooks `markdown-explorer-single-toolbar`, `markdown-explorer-single-refresh` and `markdown-explorer-single-refresh-failure` are replaced by `markdown-explorer-document-refresh-bar`, `markdown-explorer-document-refresh` and `markdown-explorer-document-refresh-failure`, and a failed reload is a notice inside the bar that is no live region and that the announcer speaks, instead of an alert.
10
+ - **Table of contents entries of headings without an id** are text, as `@aiquants/markdown` 6 draws them, instead of links to the document itself; `onHeadingSelect` and `headingHref` are only asked about entries that name a heading.
11
+ - **`@aiquants/markdown` 6**: the peer range is `^6.0.0`. The viewer's labels gain `viewerEmbeddedVideo`, `viewerEmbeddedPost` and `viewerEmbeddedFrame` (en "embedded video", "embedded post", "Embedded content"; ja 「埋め込みの動画」「埋め込みの投稿」「埋め込みのコンテンツ」), which name embedded frames in the UI language.
12
+ - **`@aiquants/virtualscroll` 3.14**: the peer range is `^3.14.0` (was `^3.13.0`), the version the explorer is tested with; its scroll bar arrows are drawn as SVG triangles, and the explorer styles no arrow of its own.
13
+ - **Iframes written in documents** pass the sanitizer through the frame policy of `@aiquants/markdown/embeds` (`allowedFrameUrlOf`, `reduceFrameFeatures`, `EMBED_FRAME_REFERRER_POLICIES`), the one the viewer applies too, instead of the sanitizer's own copies: the rules are unchanged (`https:` only, no user name, password or explicit port, the host listed exactly in `iframeHosts`, six `allow` features, safe referrer policies). The viewer never renders an iframe of the page's own origin, whatever `iframeHosts` lists, so the README no longer warns about listing your own origin.
14
+
15
+ ### Added
16
+
17
+ - **Refresh document** in every view: it reads the shown document alone again with the refresh header, without reloading the tree — a labelled button in a bar above the document in the tree and single views, and an icon-only one named after the document in a bar pinned to the top of each multi-view panel's scroll area, whose state belongs to that panel.
18
+ It keeps the document and its scroll position while it reloads, announces a reloaded document, and shows a failed reload in a notice inside the bar that a newer copy of the document, a move to another document or the next refresh takes down (`refreshDocumentLabel`, `refreshDocument`, `refreshDocumentNamed`, `documentRefreshed`, `documentRefreshFailed`).
19
+ - **Embeds and link cards**: `defineExplorerConfig({ embeds: { providers, linkCardEndpoint } })` hands `@aiquants/markdown`'s embeds to the viewer. `providers` lists the ids of `EMBED_PROVIDER_IDS` (`youtube`, `x`, `instagram`, `threads`, `tiktok`, `bluesky`, `linkedin`, `reddit`, `note`, `niconico`) whose posts and videos a link alone in a paragraph embeds as a cross-origin frame (no provider script runs in the page), and `linkCardEndpoint` is the same-origin path of the host's link-card endpoint, which turns a link written as its own URL into a card.
20
+ Each field defaults to none (`null` is also none for the endpoint), so without the option such a link stays its paragraph; repeated ids are removed, and an unknown id, a malformed endpoint or an unknown key throws a `RangeError` (`[markdown-explorer] embeds…`).
21
+ The endpoint answers `GET <path>?url=<href>` with JSON `{ title?, description?, site_name?, image?, icon? }`; it must not set cookies or refresh credentials, because the request runs in the background and can be in flight during a sign-out, and a redirect, a 401, any other non-OK status or a non-JSON answer means no card.
22
+ Content security policy: `frame-src` adds `embedFrameHostsOf(config.embeds.providers)` to `'self'` and the `iframeHosts`, a policy with `connect-src` adds `embedConnectOriginsOf(config.embeds.providers)` (the Bluesky handle lookup), one with `img-src` allows `https:` for card images and icons, and a host that enables providers should send `Cross-Origin-Opener-Policy: same-origin`, which severs the opener of a popup that escapes a provider frame's sandbox.
23
+
24
+ ### Fixed
25
+
26
+ - **Fragments resolve as HTML resolves them**: within the pane, the fragment as the URL carries it and then the fragment percent-decoded once (as the URL standard decodes it), each looked up first as an element's id and then as the first `<a name>` with that value (before, only the decoded fragment was looked up, and only as an id). A fragment with a malformed escape (`#%zz`, `#%E6%A6`) no longer abandons the jump: the escape stays as written and a malformed UTF-8 sequence reads as U+FFFD.
27
+ So the explorer's own jumps now reach an `<a name>` anchor: a followed document link (which gives it the focus, as it does a heading), a multi-view panel's fragment-only link and a page view's alignment of the URL's fragment.
28
+ - **A client-side canonical redirect keeps the fragment**: reaching a non-canonical URL without the loader (`/docs#概要`, for example) replaces it by the canonical URL with the same fragment, as the browser does across the loader's HTTP redirect. A client-side navigation from another route still loses the fragment when the loader redirects it (React Router builds the new location from the redirect's `Location` alone), so link to canonical URLs.
29
+ - **A link alone in a paragraph is no longer lost**: the converter of `@aiquants/markdown` 5 replaced such a paragraph with a `<div data-plugin-type>` placeholder without the link, and the sanitizer removed the placeholder's attributes, so a YouTube or X URL or any bare URL vanished from the page.
30
+ The 6.0.0 converter keeps the paragraph and its link and marks it with `data-embed-url`, and the sanitizer keeps that mark, provider-agnostically, only where `placeholderLinkOf` of `@aiquants/markdown/embeds` accepts it against the paragraph's children with the link's sanitized `href`; a forged or altered mark leaves the plain paragraph, and the link stays in every case.
31
+
32
+ ## 0.1.0 (2026-10-07)
4
33
 
5
34
  The first release: a Markdown document explorer for React Router 8 framework mode, with a source tree beside the document, a multi-panel reading view and a full-page single view, behind server ports for authentication, storage and Markdown parsing.
6
35
 
package/README.md CHANGED
@@ -5,15 +5,21 @@ A Markdown document explorer for React Router 8 (framework mode): a source tree
5
5
  - **Three views, one URL contract** — the tree view, the multi-panel view and the single view are addressed by plain URLs (`/docs/tree/<document>`, `/docs/multi?doc=a&doc=b`, `/docs/single/<document>`). `explorerHref` writes only canonical URLs (it refuses a target that would be redirected or partly ignored), and a non-canonical URL is redirected to its canonical form on the server and in the browser alike.
6
6
  - **Golden-ratio layout** — the explorer takes 1/φ³ of the width in the tree view (the document gets 2φ times the explorer) and 1/φ⁴ in the multi-panel view, may grow to the golden section 1/φ² and never below 13rem (it follows the reader's root font size); on a frame too narrow for that, such as a phone, the explorer opens as a sheet over the content from a labelled toggle; spacing and durations are Fibonacci numbers; multi-view columns never get narrower than the 40-character multi-column reading measure, so text is never scaled down.
7
7
  - **Streaming first paint** — the page loader streams the tree, the open documents and the notices; after that the browser reads through a JSON data route with a stale-while-revalidate cache (a document opened again within 55 s is used as it is; an older one is shown at once and revalidated in the background), so switching documents never reloads the tree. A tree row or document link that the pointer or the keyboard focus rests on for 89 ms is prefetched, one request at a time (a target the reader has left by then is skipped).
8
- The tree's **Refresh** button (a visible label, also its accessible name) has the server reload the tree
8
+ The explorer's **Refresh tree** button (a visible label, also its accessible name) has the server reload the tree
9
9
  and answers it, then reads the documents again past the host's caches: shown ones in the background
10
10
  (replaced only when they changed), shown failures at once, a shown one still loading as soon as its
11
11
  request settles, the others when they are next opened. A tree that loads meanwhile never discards the
12
12
  reader's refresh; the newer of the two stays. A reloaded tree is announced; a failed reload keeps the
13
13
  tree under an alert naming the failure.
14
- The single view has its own **Refresh** in a toolbar row above the document, which reads the shown
15
- document again the same way (the document stays on screen, and a failed reload shows an alert).
14
+ Every view also reads one shown document alone again with **Refresh document**, without listing the tree again: a
15
+ labelled button in a thin bar above the document in the tree and single views, and an icon-only button named after
16
+ the document in a bar pinned to the top of each multi-view panel's scroll area, reachable from anywhere in the
17
+ document. The document stays on screen while it reloads and is replaced in place, keeping its scroll position; a
18
+ reloaded document is announced, and a failed reload keeps the document under a notice naming the failure, which is
19
+ announced too and stays until a newer copy of the document replaces or confirms it, the reader moves to another
20
+ document, or the next refresh starts.
16
21
  A single-view (embedding) page never downloads the tree and multi-panel views, which load on demand.
22
+ - **Embeds and link cards** — with `embeds` in the configuration, a link alone in a paragraph shows its post or video from up to ten providers (YouTube, X, Instagram, Threads, TikTok, Bluesky, LinkedIn, Reddit, note and niconico) in a cross-origin frame, with no provider script in the page, or a card from your own link-card endpoint; the link itself always stays, under the frame, as the card or as the paragraph.
17
23
  - **Secure by default** — Markdown HTML is sanitized on the server with an allow-list (scripts, event handlers, `srcdoc` and foreign iframes never reach the browser), and the document viewer applies its own on every render (a document keeps only the converter's class tokens, and ids only on headings, footnotes and `user-content-…` targets); document paths are validated, and deny rules hide environment files, keys and version-control metadata through up to three percent-decoding levels; tokens, principals, server paths and raw error messages never leave the server.
18
24
  - **Multi-panel reading** — open documents as panels, rearrange them by dragging (on a touch screen or with a pen, after a long-press on a panel's header), with the move buttons in each panel's header, or with Alt + Shift + arrow keys, hide, maximize (Escape restores), and navigate inside a panel; the arrangement survives reloads, and a document reopened later returns to its column.
19
25
  - **Accessible and localized** — named landmarks and controls, a keyboard-operable tree with one Tab stop on the shown document, keyboard-operable menus, panel headers and resize handle, polite announcements (spoken from the sheet while it is open), WCAG 2.2 contrast in light and dark; English (default) and Japanese built in — the tree's and the panel headers' strings included —, every string overridable.
@@ -22,7 +28,7 @@ A single-view (embedding) page never downloads the tree and multi-panel views, w
22
28
 
23
29
  - React 19.2.7 or later and React Router 8 in framework mode (route modules with `loader` / `headers`).
24
30
  - Node.js 22.22 or later (the floor React Router 8 declares). The package ships ES modules and CommonJS; the CommonJS entries load the ESM-only `react-router` through `require(esm)`.
25
- - The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^4.0.0 (document rendering; its math diagnostics and gantt sizing), `@aiquants/directory-tree` ^4.1.0 (reveals of rows under the scroll bar's buttons), `@aiquants/drag-drop-panels` ^0.9.1, `@aiquants/resize-panels` ^2.1.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.11.4.
31
+ - The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^6.0.0 (document rendering; its math diagnostics, gantt sizing, embeds and link cards, and the React-free `@aiquants/markdown/embeds` the sanitizer worker loads), `@aiquants/directory-tree` ^4.1.0 (reveals of rows under the scroll bar's buttons), `@aiquants/drag-drop-panels` ^0.9.1, `@aiquants/resize-panels` ^2.1.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.11.4.
26
32
  The client depends on these floors, while a package manager may only warn about an older peer.
27
33
  - A Markdown parser of your choice on the server that produces HTML and its headings (the explorer sanitizes the HTML before it is sent).
28
34
  - Browsers: the multi view's panel-limit notice uses the Popover API (Chrome and Edge 114, Firefox 125, Safari 17 and later). In browsers without it (for example iOS 16), the notice is drawn in place at the stage's corner instead of in the top layer (while the sheet is open it spans the sheet's header, as in every browser).
@@ -53,7 +59,7 @@ export const explorerConfig = defineExplorerConfig({
53
59
  })
54
60
  ```
55
61
 
56
- `defineExplorerConfig` validates everything once and returns a frozen value: mount paths, view slugs (`tree`, `multi`, `single` by default), the multi-view limits (`maxPanels` 12, `columns` 4), Expand all's budget per press (`maxFolders` 500, `maxDepth` 16), the document styles, the iframe host allow-list and the reader's default tree settings. A mistake throws at startup instead of producing links that point nowhere.
62
+ `defineExplorerConfig` validates everything once and returns a frozen value: mount paths, view slugs (`tree`, `multi`, `single` by default), the multi-view limits (`maxPanels` 12, `columns` 4), Expand all's budget per press (`maxFolders` 500, `maxDepth` 16), the document styles, the iframe host allow-list, the embeds and link cards and the reader's default tree settings. A mistake throws at startup instead of producing links that point nowhere.
57
63
  The source ids are not part of it: they are the ids of the server's `sources` (a runtime setting of the server), and the browser learns them from the page data. `withExplorerSources(config, sourceIds)` joins them to the configuration where the URL codec needs them (see [Views and URLs](#views-and-urls)).
58
64
 
59
65
  | Option | Type | Purpose |
@@ -65,7 +71,8 @@ The source ids are not part of it: they are the ids of the server's `sources` (a
65
71
  | `multiView?` | `{ maxPanels?, columns? }` | The panel limit (1–64, default 12) and the logical column count (1–6, default 4). |
66
72
  | `expandAll?` | `{ maxFolders?, maxDepth? }` | Expand all's budget per press (see [Expand all and Collapse all](#expand-all-and-collapse-all)): the folder listings a press may start (1–10,000, default 500, `EXPAND_ALL_FOLDER_LIMITS`) and the deepest level (the top being 1) at which it opens a folder of unknown contents (1–64, default 16, `EXPAND_ALL_DEPTH_LIMITS`). Each field defaults on its own, also when given as `undefined`; a value that is not an integer within its bounds or an unknown key throws a `RangeError` naming the field, and anything but a plain object a `TypeError`. |
67
73
  | `documentStyles?` | `readonly { name, className }[]` | Document styles, the first being the default; `@aiquants/markdown`'s `DEFAULT_MARKDOWN_STYLES` (None, GitHub, Zenn; also exported without React from `@aiquants/markdown/viewer-settings`) when omitted. |
68
- | `iframeHosts?` | `readonly string[]` | Host names whose `https:` iframes documents may embed (exact match); none when omitted. |
74
+ | `iframeHosts?` | `readonly string[]` | Host names whose `https:` iframes written in documents may load (exact match); none when omitted. They gate only iframes written in documents; provider frames come from `embeds`, and no iframe of the page's own origin ever renders, whatever is listed. |
75
+ | `embeds?` | `{ providers?, linkCardEndpoint? }` | What `@aiquants/markdown` makes of a link alone in a paragraph. `providers` lists the ids (`EMBED_PROVIDER_IDS` of `@aiquants/markdown/embeds`: `youtube`, `x`, `instagram`, `threads`, `tiktok`, `bluesky`, `linkedin`, `reddit`, `note`, `niconico`) whose posts and videos documents embed as cross-origin frames, whatever the link's text; `linkCardEndpoint` is the same-origin path of your link-card endpoint (the mount-path grammar), which turns a link written as its own URL into a card. Each field defaults to none, also when given as `undefined` (`null` is also none for the endpoint, as in `MarkdownEmbeds`), so without the option such a link stays its paragraph. Repeated ids are removed. An unknown id, a malformed endpoint or an unknown key throws a `RangeError` (`[markdown-explorer] embeds…`), and anything but a plain object a `TypeError`. The endpoint answers `GET <path>?url=<href>` with JSON `{ title?, description?, site_name?, image?, icon? }`, sets no cookie and refreshes no credential (the request runs in the background and can be in flight during a sign-out); a redirect, a 401, any other non-OK status or a non-JSON answer means no card. See `@aiquants/markdown`'s README (Embeds) for the URLs each provider recognizes and the frames' sizes. |
69
76
  | `defaultTreeSettings?` | `Partial<TreeSettings>` | The reader's tree settings before they change any, merged over the package's `DEFAULT_TREE_SETTINGS` (the source's own order, folders not first, Single selection, a recursive double click, 8 px expand icons, nothing kept expanded, the root indent kept, lines, expand icons and folder and file icons on). Each value is one the settings menu offers: `sortMode` `"native"`, `"asc"` or `"desc"`; `selectionMode` `"single"`, `"multiple"` or `"none"`; `doubleClickAction` `"recursive"` or `"toggle"`; `expandIconSize` `8`, `13` or `5`; the other settings (`directoriesFirst`, `alwaysExpanded`, `removeRootIndent`, `lines`, `expandIcons`, `directoryIcons`, `fileIcons`) `true` or `false`. An unknown key or any other value throws a `RangeError`, and anything but a plain object (a `Map`, a class instance, an object inheriting its settings) throws a `TypeError`; a setting given as `undefined` keeps the package default. The server render and the hydration draw these defaults (see [Tree settings](#tree-settings)). |
70
77
 
71
78
  For example, `defaultTreeSettings: { sortMode: "desc" }` lists every folder's entries by name, Z to A, until the reader picks another order.
@@ -299,7 +306,7 @@ The published type declarations carry no doc comments, so the shapes a source re
299
306
  | `principal` | `P` | The reader, as `authenticate` returned it. |
300
307
  | `request` | `Request` | The request that asked for the call. |
301
308
  | `signal` | `AbortSignal` | Aborts when nobody waits for the result any longer: every request that waited on the call has left (a walk a refresh or `forgetTree` superseded keeps running for the requests already waiting on it), or the page loader gave up streaming the value — at once for notices, and `deferredTimeoutMs` later for a tree or document, whose late value the browser fetches through the data route (that request has the time to join the work; the page request's own signal never aborts once its response has finished). Pass it to your I/O, so an abandoned call stops at once; a source that ignores it keeps running, and a tree walk that ignores it holds its cache key until it ends. |
302
- | `refresh` | `boolean` | Whether the reader asked to reload from the source: the tree refresh, and every document request it triggered (`X-Markdown-Explorer: refresh`). A cache of your own in front of the source should be skipped and refilled when it is `true`. |
309
+ | `refresh` | `boolean` | Whether the reader asked to reload from the source: the tree refresh, every document request it triggered, and a document's own Refresh document (`X-Markdown-Explorer: refresh`). A cache of your own in front of the source should be skipped and refilled when it is `true`. |
303
310
 
304
311
  `tree(context)` returns the source's entries (its roots), and `children(context, path, readPath)` those of one lazy folder (`readPath` as for `document`):
305
312
 
@@ -346,7 +353,9 @@ A `text` document shows the beginning of a file under the file header (its name,
346
353
  A markdown document lists at most `EXPLORER_MAX_HEADINGS` (10,000) headings; one that lists more is answered `too-large`, because every listed heading travels with the document (in the data response, the browser's document cache and the viewer's table of contents, one entry each) and a parser can list headings its HTML never renders (`#` lines inside a math block), so none of the HTML's limits bounds the list. A cache of your parser's results can rely on the same bound.
347
354
 
348
355
  Markdown links the viewer should follow inside the explorer carry `data-link-kind="doc"` and `data-doc-path="<document path>"` (plus `data-doc-exists="false"` for a missing target); a `doc` link without a path, or with one that is not an acceptable document path (`isAcceptableDocumentPath`: non-empty, at most `MAX_DOCUMENT_PATH_LENGTH` characters, no lone surrogates, control characters or backslashes), renders as an inert link.
349
- The sanitizer keeps only the `data-*` attributes of this contract: `data-link-kind`, `data-doc-path`, `data-doc-exists`, `data-footnote-ref` and `data-footnote-backref` on links, `data-asset-src` and `data-asset-exists` on images, and `data-footnotes` on sections; every other one, including the `data-plugin-type` embeds of `@aiquants/markdown`, is removed.
356
+ The sanitizer keeps only the `data-*` attributes of this contract: `data-link-kind`, `data-doc-path`, `data-doc-exists`, `data-footnote-ref` and `data-footnote-backref` on links, `data-asset-src` and `data-asset-exists` on images, and `data-footnotes` on sections; every other one is removed, including the `data-plugin-type` iframe trigger of `@aiquants/markdown` and the `<div data-plugin-type>` placeholders its 5.x converter wrote.
357
+ The one exception is the converter's embed placeholder: a paragraph whose only content is one absolute `http(s)` link without a user name or password (besides white space, U+00A0 and U+3000) carries the link's `href`, byte for byte, in `data-embed-url` on the `<p>`, and the paragraph and its link stay as written.
358
+ The sanitizer keeps that attribute only where `placeholderLinkOf` of `@aiquants/markdown/embeds` accepts it against the paragraph's children with the link's sanitized `href`; a forged or altered placeholder leaves the plain paragraph (see [Security](docs/behavior/security.md#html)). Mark such paragraphs in your parser as the Go converter does to get embeds and cards (the demo's parser shows how); without the mark the link stays its paragraph.
350
359
  The viewer (`@aiquants/markdown`) renders an external link itself, in a new tab with `rel="noreferrer"`: one marked `data-link-kind="external"`, or, without `data-link-kind`, one whose `href` names a scheme in any case (`https:`, `HTTPS:`, `mailto:`) or another host (`//host/…`), so links to other sites need no mark.
351
360
  Every other link with an `href` reaches the explorer's link component with its `data-link-kind`, `data-doc-path` and `data-doc-exists`, its class, its content and the attributes your parser gives it for assistive technology and footnotes — `title`, `lang`, `dir`, `role`, `aria-*`, `data-footnote-*` and an `id` in the `user-content-` namespace — which the explorer puts on the anchor it renders (an inert link's `title` is the explorer's reason instead). Anchors without an `href` keep their attributes.
352
361
  The viewer keeps only its own class tokens and fragment targets of your HTML, whatever the sanitizer kept (see [Security](docs/behavior/security.md#the-viewers-allow-list)): a class token survives when it belongs to the markup below, to footnotes (`footnotes`, `footnote-ref`, `footnote-backref`), to formulas (`math`, `inline`, `display`) or to a code block's language (`language-*`),
@@ -453,10 +462,11 @@ Spread it into the configuration when your application has no sign-in: it provid
453
462
 
454
463
  - The HTML sanitizer runs in worker threads started from `sanitizeWorker.js` (`sanitizeWorker.cjs` for the CommonJS entry) next to the server entry, and creating the explorer fails when that file is missing: keep the package external in your server bundle instead of bundling it into your own file. Each worker has its own DOMPurify, so nothing else in your server shares its configuration. Running the package from its TypeScript sources (tests, a dev server aliased to `src/`) needs Node's type stripping (22.18+, 23.6+ or 24).
455
464
  - Serve a content security policy of your own; the explorer's sanitizer is the first line of defence, not the only one. In a single-page app a policy binds to the document, which client-side navigations keep, so set one policy for every page (at the root route or the document handler, or at the edge), never on the explorer's route responses alone: a policy sent only there is missing when the reader arrives by a client-side navigation, and stays on every page the reader visits next.
456
- The explorer needs `frame-src`, `img-src` and `media-src` to allow `'self'`, the origin of its own asset URLs (PDF documents open in a frame from that URL), plus `frame-src https://<host>` for each `iframeHosts` entry; it renders no `<object>` or `<embed>`, so `object-src 'none'` and `base-uri 'none'` hold for it; prefer a nonce-based `script-src` if your framework's inline hydration scripts allow it.
465
+ The explorer needs `frame-src`, `img-src` and `media-src` to allow `'self'`, the origin of its own asset URLs (PDF documents open in a frame from that URL), plus `frame-src https://<host>` for each `iframeHosts` entry and each host of `embedFrameHostsOf(config.embeds.providers)` (from `@aiquants/markdown/embeds`); a policy with `connect-src` also needs `embedConnectOriginsOf(config.embeds.providers)` (the Bluesky handle lookup), and one with `img-src` needs `https:` for card images and icons.
466
+ It renders no `<object>` or `<embed>`, so `object-src 'none'` and `base-uri 'none'` hold for it; prefer a nonce-based `script-src` if your framework's inline hydration scripts allow it.
467
+ A host that enables providers should also send `Cross-Origin-Opener-Policy: same-origin`: provider frames may open popups that escape their sandbox (`allow-popups-to-escape-sandbox`), and the policy severs such a popup's opener.
457
468
  - Every GET route on the explorer's origin is reachable from a document: a rendered document makes the reader's browser send credentialed same-origin GET requests through its images (`![](/path)`, `<img src>`), media (`<video poster>`, `<audio src>`) and frames without the reader's interaction, and through its links once the reader follows one; the sanitizer keeps relative and root-relative URLs because a document's own images are legitimate.
458
469
  Make every endpoint that changes state (signing out, deleting, starting a download of the reader's files) non-GET, or have it refuse, before it changes anything, a request that carries `Sec-Purpose` (a prefetch or prerender: speculation rules can request a document's same-origin links, with `Sec-Fetch-Dest: document`, before or without a click) or whose `Sec-Fetch-Dest` is present and is neither `document` (a typed address or a followed link) nor `empty` with `Sec-Fetch-Site: same-origin` (a script of your own origin: `fetch`, React Router's single-fetch data).
459
- Listing your own origin in `iframeHosts` lets a document frame any of your pages, with the reader's cookies; list it only when documents must frame it.
460
470
  - Set your server entry's `streamTimeout` above `deferredTimeoutMs`, so a slow source is fetched by the browser instead of failing the stream.
461
471
  - Each process keeps its own tree cache. A host running several processes (a Node cluster, for example) relays the keys `onTreeRefreshed` receives to its other processes, which call `forgetTree`, so a refresh in one process is not answered by an older tree in another; without the relay each process still answers no tree older than `treeCache.ttlMs`. With `node:cluster`, a worker sends the key to the primary, the primary forwards it to every other worker, and each worker forgets it:
462
472
 
@@ -478,6 +488,11 @@ Spread it into the configuration when your application has no sign-in: it provid
478
488
  })
479
489
  ```
480
490
 
491
+ - **Fragments.** A fragment — a page's URL hash, a link's `#section`, a table-of-contents entry — indicates an element as HTML's "select the indicated part" finds it, but only inside the pane that shows the document (two multi-view panels may show the same ids): first the fragment as the URL carries it, then the fragment percent-decoded once as the URL standard decodes it (a malformed escape stays as written and a malformed UTF-8 sequence reads as U+FFFD, so a hand-typed fragment never stops the jump),
492
+ each looked up first as an element's `id` and then as the `name` of an `a` element, the first match in tree order winning. A fragment that indicates no element but is `#` or decodes to `top` in any ASCII case takes the pane to its start.
493
+ Link to what survives sanitizing: a heading's id — with `@aiquants/markdown` 6 or later as your converter, GitHub's automatic ids (`#概要`, `#api-の使い方`, `#snake_case-名`, `#重複-1` for a second `重複`) and ids written as `{#id}` —, an `<a name="…">` anchor in raw HTML, or an id in the `user-content-` namespace (see [The viewer's allow list](docs/behavior/security.md#the-viewers-allow-list)). DOMPurify drops an `id` or `name` equal to a property of the document or of a form (`title`, `images`, …), except a heading's id.
494
+ A canonical redirect keeps the fragment on a page load (the browser carries it across the loader's HTTP redirect) and on the explorer's own client-side replace (it appends the fragment), so loading `/docs#%E6%A6%82%E8%A6%81` ends on the tree view's URL with the same fragment.
495
+ A client-side navigation from another of your routes to a non-canonical URL loses its fragment, because React Router builds the redirected location from the loader's `Location` alone: link to the canonical URL that `explorerHref` writes, with the fragment appended. A multi-view URL ignores the hash: a panel's fragment-only link scrolls the panel instead.
481
496
  - In a page view the explorer brings a fragment's element to the start of the pane's own scroller and moves every scroller around it only as far as needed (see [The document region](docs/behavior/layout.md#the-document-region)). Two scrolls it does not own can do more:
482
497
  React Router's `<ScrollRestoration>` scrolls the element whose id is the URL's hash into view itself — page-wide, aligned to the start of every scroller, the page and your own scroll containers included — on a router navigation that carries a hash to a location it has saved no window offset for (a new history entry: it keys the offsets it saves by the location's key, or by your `getKey`), whenever that element is already in the page (a link to a section of the shown document, or an entry of the document viewer's table of contents, which the explorer follows as such a link). On Back or Forward to an entry it saved an offset for, it restores the window's offset instead, as it does for every entry the browser made itself (a fragment-only link) once it has left one, since React Router gives all of those the key `default`. The browser scrolls to the element itself for a fragment-only link and for the hash of a page it loads, and for a link to `#top` or `#` that names no element it scrolls the page itself to its top (HTML's top of the document is the viewport's).
483
498
  They move nothing while the explorer fills a container that does not scroll (with `lockDocumentScroll`, for example); in a page that scrolls around a page view, leave `<ScrollRestoration>` off the explorer's routes if your scrollers must not move.
@@ -530,7 +545,9 @@ A folder met again among its own ancestors (a shortcut inside its own target, or
530
545
 
531
546
  ### Localization
532
547
 
533
- `locale` selects a built-in catalog (`MARKDOWN_EXPLORER_LABEL_CATALOGS.en` / `.ja`); `labels` overrides single keys. The catalogs also name every control of the document viewer (the `viewer…` keys: its toolbar, the table of contents, the style and alignment menus and each Mermaid diagram's controls) and everything the multi view's drag-and-drop layout shows (the panel headers' buttons and the custom drag mode's badge, the move announcements and a touch or pen drag's lift and cancel announcements, the bar of hidden panels, the columns' names and the drop placeholders), which therefore follow `locale` too. The labels the layout fills with a value are templates with `{name}` placeholders (`MARKDOWN_EXPLORER_LABEL_TEMPLATES`). An unknown key, a blank string, a value of the wrong type, a template placeholder its key does not offer or a regional tag such as `"ja-JP"` throws — see [Localization](docs/behavior/localization.md).
548
+ `locale` selects a built-in catalog (`MARKDOWN_EXPLORER_LABEL_CATALOGS.en` / `.ja`); `labels` overrides single keys.
549
+ The catalogs also name every control of the document viewer (the `viewer…` keys: its toolbar, the table of contents, the style and alignment menus, each Mermaid diagram's controls and the titles of embedded frames) and everything the multi view's drag-and-drop layout shows (the panel headers' buttons and the custom drag mode's badge, the move announcements and a touch or pen drag's lift and cancel announcements, the bar of hidden panels, the columns' names and the drop placeholders), which therefore follow `locale` too.
550
+ The labels the layout fills with a value are templates with `{name}` placeholders (`MARKDOWN_EXPLORER_LABEL_TEMPLATES`). An unknown key, a blank string, a value of the wrong type, a template placeholder its key does not offer or a regional tag such as `"ja-JP"` throws — see [Localization](docs/behavior/localization.md).
534
551
 
535
552
  ## Layout
536
553
 
@@ -551,7 +568,7 @@ The reader's own explorer width is remembered per view as a percentage, and only
551
568
  ## Security model
552
569
 
553
570
  - Markdown HTML is sanitized on the server with DOMPurify and an allow-list, in worker threads with limits on size (4 MiB), nesting (512 levels, as the sanitizer's parser builds the tree), parsed nodes (81,920 elements, attributes and comments, at most 4,096 of them comments), attributes (at most 1,024 per element, and no more attribute characters than `maxHtmlBytes`, counting the copies the parser makes of reopened formatting elements), output (at most four characters per byte of `maxHtmlBytes`), heap (512 MiB per worker) and time (30 s) and a fair share of the workers for each reader:
554
- no `script`, `style`, `form` or embedding elements, no event-handler attributes or `srcdoc`, only `text-align` in `style`, iframes only over HTTPS from hosts listed exactly in `config.iframeHosts` (with `allow` and `referrerpolicy` reduced to safe values), `data-*` only for the link, image and footnote contract, and only `http:`, `https:`, `mailto:`, `tel:` and relative URLs (no `data:` URL in any element).
571
+ no `script`, `style`, `form` or embedding elements, no event-handler attributes or `srcdoc`, only `text-align` in `style`, iframes only over HTTPS from hosts listed exactly in `config.iframeHosts` (with `allow` and `referrerpolicy` reduced to safe values, by the frame policy `@aiquants/markdown/embeds` shares with the viewer), `data-*` only for the link, image and footnote contract and the embed placeholder its shared contract accepts, and only `http:`, `https:`, `mailto:`, `tel:` and relative URLs (no `data:` URL in any element).
555
572
  - The document viewer (`@aiquants/markdown`) applies its own allow list on every render, so the page holds the intersection: `class` reduced to the converter's tokens (alerts, Zenn containers, footnotes, formulas, `language-*`), `id` only on headings, footnotes and in the `user-content-` namespace, and no author `target`, `rel` or `srcset`. The sanitizer leaves classes and ids to that single definition; render `htmlContent` only through the explorer or `@aiquants/markdown`'s renderers.
556
573
  - Document paths from URLs are limited to 4096 characters without lone surrogates, control characters or backslashes; deny rules are matched through up to three lenient percent-decoding levels, against each level whole and split on `/` or `\` (a storage may read either as part of a name or as a separator), and after full Unicode case folding.
557
574
  - Every source is confined to its boundary: its tree and children list only paths inside it, a children request reaches the host only for a path the named source's boundary admits, and a document or a file's bytes reach the host only when the boundary of at least one source admits its path (see [Source boundaries](#source-boundaries)). A source whose boundary admits everything a reader can read in a store confines nothing in that store.
@@ -582,7 +599,8 @@ Tests and host styling may rely on the `data-testid` and `data-aqmx-*` attribute
582
599
  ## Demo
583
600
 
584
601
  The source repository holds a runnable demo next to the package (`packages/markdown-explorer/demo`): three file-system sources with anonymous access (`guide` and `notes`, kept apart by their path prefix, with one folder of the guide, `guide/a`, served lazily through `children`; and `reference`, rooted at the folder `guide/reference` inside `guide`, so a document under it appears in two trees under the same path),
585
- the page and data routes, the error boundary, document and asset ports that route each path to the first source whose boundary contains it (no asset route of its own), a Markdown parser that produces document links and image targets, GitHub alerts, Zenn's message and details containers, and footnotes, task lists and formulas in the Go converter's markup, and the end-to-end tests' fixtures. Run it with `pnpm run demo:dev` from the package folder.
602
+ the page and data routes, the error boundary, document and asset ports that route each path to the first source whose boundary contains it (no asset route of its own), a Markdown parser that produces document links and image targets, GitHub alerts, Zenn's message and details containers, embed placeholders, and footnotes, task lists and formulas in the Go converter's markup, every embed provider with an offline link-card endpoint (`/api/link-card`, answering from fixtures; `guide/reference/embeds.md` and `guide/reference/link-cards.md` show them), and the end-to-end tests' fixtures.
603
+ Run it with `pnpm run demo:dev` from the package folder.
586
604
 
587
605
  ## License
588
606
 
@@ -1 +1 @@
1
- "use strict";const i=require("react/jsx-runtime"),R=require("./index-y9tVvDW7.cjs"),r=require("react"),T=require("./location-DWHQYntR.cjs"),ye=require("@aiquants/directory-tree"),Ue=require("@aiquants/virtualscroll"),We=require("./storage-Bkb2Axdi.cjs"),re=require("@aiquants/resize-panels"),Ge=require("react-router");function Ye(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Ye(r);function Qe({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const Je=p.forwardRef(Qe);function et({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const tt=p.forwardRef(et);function nt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),p.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const rt=p.forwardRef(nt);function at({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const lt=p.forwardRef(at),ot=()=>{const{notices:e}=R.useExplorer(),t=r.use(e);return t.length===0?null:i.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>i.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[i.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:i.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:i.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function st({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const ct=p.forwardRef(st),ue=r.createContext(!0),ke="\0loop\0",Te="\0",it=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=l=>{const o=e.get(l);if(o!==void 0)return o;const c=Object.freeze({type:"loop",name:l.name,path:l.path});return e.set(l,c),c},s=(l,o,c)=>{let m=!1;const f=l.map(h=>{const x=u(h,o,c);return x!==h&&(m=!0),x});if(!m)return l;const d=n.get(l);return d!==void 0&&d.length===f.length&&d.every((h,x)=>h===f[x])?d:(n.set(l,f),f)},u=(l,o,c)=>{if(l.type!=="directory")return l;if(c.has(l.path))return a(l);const m=l.lazy===!0?o(l.path):void 0,f=m?.status==="loaded",d=f?m.entries:l.children;if(d===void 0)return l;c.add(l.path);const h=s(d,o,c);if(c.delete(l.path),!f&&h===l.children)return l;const x=t.get(l);if(x!==void 0&&x.state===m&&x.children===h)return x.grafted;const w={...l,children:h,lazy:f?!1:l.lazy};return t.set(l,{state:m,children:h,grafted:w}),w};return(l,o)=>s(l,o,new Set)},ut=(e,t)=>`${ke}${e}${Te}${t}`,J=e=>e.startsWith(ke),dt=e=>e.slice(e.lastIndexOf(Te)+1),G="data-aqmx-path",ft=(e,t,n,a,s)=>{const u={aqmxPath:e.path};return n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:u}},mt=(e,t,n,a)=>{const s=ut(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},pt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(o,c,m)=>{const f=o.map(h=>h.type==="loop"?u(h,c,m):l(h,c)),d=n.get(o);return d!==void 0&&d.length===f.length&&d.every((h,x)=>h===f[x])?d:(n.set(o,f),f)},u=(o,c,m)=>{const f=t.get(o);if(f!==void 0&&f.parentKey===m&&f.loopFolderName===c.loopFolderName)return f.row;const d=mt(o,m,c.loopFolderName(o.name),a);return t.set(o,{row:d,parentKey:m,loopFolderName:c.loopFolderName}),d},l=(o,c)=>{const m=o.type==="directory"?o.children===void 0?a:s(o.children,c,o.path):void 0,f=c.openPaths.has(o.path),d=o.type==="directory"&&o.lazy===!0?c.childrenOf(o.path)?.status:void 0,h=d==="failed"?c.renderFailedFolder:void 0,x=e.get(o);if(x!==void 0&&x.open===f&&x.childrenStatus===d&&x.children===m&&x.renderFailedFolder===h)return x.row;const w=ft(o,m,f,d,h===void 0?void 0:h(o));return e.set(o,{row:w,open:f,childrenStatus:d,children:m,renderFailedFolder:h}),w};return(o,c)=>s(o,c,"")},ht=e=>{if(e===void 0)return;const t=n=>({name:n.name,path:n.absolutePath,type:n.type});return(n,a)=>e(t(n),t(a))},ie=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},xt=(e,t)=>{const n=new Map;let a=0;const s=u=>{for(const l of ie(u,t.compare))if(t.isShownExpanded(l.path)){if(l.lazy!==!0){l.children!==void 0&&s(l.children);continue}n.has(l.path)||(n.set(l.path,t.isDirect(l.path)?"direct":"bulk"),t.childrenOf(l.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},wt=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},Ce=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Ce(n.children,t);if(a!==null)return a}return null},Ee=new Set,gt=(e,t)=>e.has(t)?e:new Set(e).add(t),Et=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},bt=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),vt=()=>{const[e,t]=r.useState(Ee),n=r.useCallback(l=>t(o=>gt(o,l)),[]),a=r.useCallback(l=>t(o=>Et(o,l)),[]),s=r.useCallback(l=>t(o=>bt(o,l)),[]),u=r.useCallback(()=>t(Ee),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:u}),[e,n,a,s,u])},Rt=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),St=(e,t)=>{const n=[];let a=ie(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const u=[];for(const l of a){const{path:o}=l;if(t.isShownExpanded(o))e.handled.add(o);else{if(e.handled.has(o))continue;if(e.handled.add(o),l.lazy===!0&&t.childrenOf(o)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(o)}n.push(o),e.opened+=1}l.lazy!==!0&&l.children!==void 0&&u.push(...ie(l.children,t.compare))}a=u}return n},Le=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||Le(n.children,t))),yt=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:Le(t.entries,t.isShownExpanded)}},ce=Object.freeze({state:"idle"}),kt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(ce);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=Rt(n.current.budget),s({state:"running",opened:0}))},[]),l=r.useCallback(()=>{t.current=null,s(ce)},[]),o=r.useCallback(c=>{const m=t.current;if(m===null)return;const f=St(m,c);if(f.length>0&&(m.issuedAgainst=c.expanded,n.current.expandMultiple([...f])),!m.announcedStart&&(m.loads.size>0||c.waiting>0)&&(m.announcedStart=!0,n.current.onStart()),f.length===0&&!c.expansionPending&&c.expanded!==m.issuedAgainst&&c.waiting===0){t.current=null;const h=yt(m,c);s(h.kind==="done"?ce:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=m;s(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:l,advance:o}),[a,u,l,o])},Tt="--aqmx-tree-line",Ct=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Lt="data-aqmx-tree-probe",jt=Object.freeze({rowHeight:T.CONTROL_BLOCK_PIXELS,lineColor:null}),Nt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,qt=e=>{const t=Nt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Pt=(e,t)=>{const[n,a]=r.useState(jt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const u=()=>{const c=Math.round(s.getBoundingClientRect().height),m=getComputedStyle(s),f=m.getPropertyValue(Tt).trim()===""?null:qt(m.color);a(d=>{const h=Number.isFinite(c)&&c>0?c:d.rowHeight;return d.rowHeight===h&&d.lineColor===f?d:{rowHeight:h,lineColor:f}})};u();const l=Ct.map(c=>window.matchMedia(c));for(const c of l)c.addEventListener("change",u);const o=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return o?.observe(s),()=>{for(const c of l)c.removeEventListener("change",u);o?.disconnect()}},[e,t]),n},Ot={renderVisual:Ue.tapScrollCircleSampleVisual,minSpeedMultiplier:.25,maxSpeedMultiplier:18},At="markdown-explorer-tree-scroll",Mt={testId:At,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:Ot},behaviorOptions:{enablePointerDrag:!0}},Ft={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},_t={color:"inherit"},It={paddingBlock:0},Dt=new Set,Ht=new Map,Zt={color:"var(--aqmx-tree-line)"},be=["pointerdown","wheel","touchstart","keydown","focusin"],$t=(e,t,n)=>{const a=r.useRef(null),s=r.useRef(null),u=r.useCallback(()=>{const l=t.current;a.current===null||s.current!==null||l===null||l.getClientRects().length===0||(s.current=requestAnimationFrame(()=>{s.current=null;const o=a.current;o!==null&&e.current?.scrollToPath(o,{align:"nearest"})===!1&&(a.current=null)}))},[e,t]);r.useEffect(()=>{const l=t.current;if(l===null)return;const o=()=>{a.current=null},c=typeof ResizeObserver>"u"?null:new ResizeObserver(u);c?.observe(l);for(const m of be)l.addEventListener(m,o,{passive:!0});return()=>{c?.disconnect();for(const m of be)l.removeEventListener(m,o);s.current!==null&&cancelAnimationFrame(s.current),s.current=null}},[t,u]),r.useEffect(()=>{const l=t.current;a.current=n===null||l===null||l.contains(l.ownerDocument.activeElement)?null:n,u()},[n,t,u])},Bt=e=>{const t=e instanceof Element?e.closest(`[${G}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(G)},je=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),zt=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):je(e,t,n.kind,n.opened),Ne=()=>{const{labels:e}=R.useExplorer();return i.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[i.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),i.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})]})},Vt=()=>{const{labels:e}=R.useExplorer();return i.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[i.jsx(ct,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),i.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),i.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},Kt=({name:e,onRetry:t})=>{const{labels:n}=R.useExplorer(),a=r.useId();return i.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[i.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),i.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),i.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const u=s.currentTarget,l=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;l instanceof HTMLElement&&R.focusWithoutScroll(l),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[i.jsx(R.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},Xt=({entries:e,version:t,mode:n,sourceId:a,settings:s,openPaths:u,selection:l,onOpenDocument:o,expansion:c,onShown:m,marks:f,claimsHeld:d,expandAll:h})=>{const{trees:x,documents:w,labels:v,locale:C,theme:y}=R.useExplorer(),M=r.use(ue),[k]=r.useState(pt),_=r.useRef(null),{rowHeight:D,lineColor:I}=Pt(_,y),{isExpanded:b,toggle:L,expandMultiple:E,collapseMultiple:N,expanded:P,isPending:z}=c,{alwaysExpanded:V,sortMode:O,directoriesFirst:Y}=s,{direct:K,markDirect:H,unmarkDirect:F,pruneDirect:A}=f,{running:Z,advance:ee}=h,Q=r.useRef(null),W=r.useRef(null);$t(Q,W,l.shownPath);const X=r.useMemo(()=>T.createEntryComparator({sortMode:O,directoriesFirst:Y}),[O,Y]),le=r.useMemo(()=>ht(X),[X]),$=r.useCallback(g=>x.children(a,g),[x,a]),S=r.useMemo(()=>wt(e),[e]),j=r.useCallback(g=>!J(g)&&(b(g)||V&&!S.has(g)),[b,V,S]),B=r.useRef({shownExpanded:j,isExpanded:b,unloadedFolders:S});r.useLayoutEffect(()=>{B.current={shownExpanded:j,isExpanded:b,unloadedFolders:S}},[j,b,S]);const pe=r.useCallback(g=>{Q.current?.scrollToPath(g,{align:"nearest"}),requestAnimationFrame(()=>{const q=W.current;if(q===null)return;const U=[...q.querySelectorAll(`[role="treeitem"][${G}]`)].find(Xe=>Xe.getAttribute(G)===g);U!==void 0&&R.focusWithoutScroll(U)})},[]),Ie=r.useCallback(g=>{if(J(g)){pe(dt(g));return}B.current.isExpanded(g)?F([g]):B.current.unloadedFolders.has(g)&&H(g),L(g)},[pe,H,F,L]),oe=r.useCallback(g=>{const q=g.filter(U=>!J(U));q.length!==0&&(F(q),N(q))},[F,N]),De=r.useCallback(g=>{const q=g.filter(U=>!J(U));q.length!==0&&(q.length<g.length&&q.every(U=>B.current.shownExpanded(U))?oe(q):E(q))},[E,oe]),he=r.useCallback(g=>i.jsx(Kt,{name:g.name,onRetry:()=>{H(g.path),x.retryChildren(a,g.path),B.current.shownExpanded(g.path)||E([g.path])}}),[x,a,H,E]),xe=n==="multi"?u:Dt,{loopFolderName:we}=v,He=r.useMemo(()=>k(e,{openPaths:xe,childrenOf:$,renderFailedFolder:he,loopFolderName:we}),[k,e,xe,$,he,we,t]),Ze=R.useIntentPrefetch(w,Bt),ge=r.useCallback(g=>K.has(g),[K]),te=r.useMemo(()=>xt(e,{isShownExpanded:j,childrenOf:$,compare:X,isDirect:ge}),[e,j,$,X,ge,t]),ne=M&&d;r.useLayoutEffect(()=>{m(e)},[e,m]),r.useLayoutEffect(()=>()=>m(null),[m]),r.useEffect(()=>x.claimChildren(a,ne?te.folders:Ht),[x,a,ne,te]),r.useEffect(()=>A(S),[A,S]),r.useEffect(()=>{ne&&Z&&ee({entries:e,isShownExpanded:j,childrenOf:$,compare:X,expanded:P,waiting:te.waiting,expansionPending:z})},[ne,Z,ee,e,j,$,X,P,te,z]);const $e=r.useCallback(g=>{g.isDirectory||o(g.entry.absolutePath)},[o]),{onChange:se}=l,Be=r.useMemo(()=>se===null?void 0:(g,q)=>{J(g.absolutePath)||se({path:g.absolutePath,name:g.name,selected:q})},[se]),ze=r.useMemo(()=>new Set(l.items),[l.items]),Ve=r.useMemo(()=>({entryKindDirectory:v.treeEntryKindDirectory,entryKindFile:v.treeEntryKindFile,scrollUp:v.treeScrollUp,scrollDown:v.treeScrollDown,scrollToTop:v.treeScrollToTop,scrollToBottom:v.treeScrollToBottom}),[v]),Ke=I===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:I};return i.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...Ze,children:[i.jsx("span",{ref:_,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Lt]:""}),i.jsx(ye.DirectoryTree,{ref:Q,entries:He,expansion:{toggle:Ie,isExpanded:j,expandMultiple:De,collapseMultiple:oe,isPending:z&&!Z,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ze,onEntryClick:$e,onSelectionChange:Be},visual:{className:"aqmx-explorer-tree-view",ariaLabel:v.treeRegion,...Ke,showExpandIcons:s.expandIcons,expandIconStyle:Zt,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:D,removeRootIndent:s.removeRootIndent,highlightStyles:Ft,entryStyle:It,nameStyle:_t},virtualScroll:Mt,sort:le,locale:C,labels:Ve})]})},Ut=({pending:e,status:t})=>{const{labels:n}=R.useExplorer(),a=t.state!=="running",[s,u]=r.useState(0),l=r.useRef(!0);r.useLayoutEffect(()=>{const c=l.current;if(l.current=a,!a||e>0&&!c){u(0);return}if(e>0){u(e);return}if(s===0)return;const m=setTimeout(()=>u(0),0);return()=>clearTimeout(m)},[a,e,s]);const o=a&&e===0?s:e;return o===0&&a?null:i.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(o),"data-aqmx-expand-all":t.state,children:[o>0?i.jsx(R.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,i.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,o):n.foldersLoading(o)})]})},Wt=({stop:e,opened:t,budget:n})=>{const{labels:a}=R.useExplorer();return i.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:je(a,n,e,t)})},Gt=({entries:e,...t})=>{const{trees:n}=R.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[u]=r.useState(it),l=r.useMemo(()=>u(e,o=>n.children(s,o)),[u,e,n,s,a]);return l.length===0?i.jsx(Vt,{}):i.jsx(Xt,{entries:l,version:a,...t})},Yt=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=R.useExplorer(),s=r.use(e);if(s.status==="deferred")return i.jsx(Ne,{});if(s.status==="ok")return i.jsx(Gt,{entries:s.entries,...n});const u=a?.(s.failure);return i.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:u!==void 0?u:i.jsx(R.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},Qt=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:u,config:l}=R.useExplorer(),{sourceId:o}=t,c=ye.useDirectoryTreeState({storageKey:We.storageKeys(a).treeExpansion(o)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const m=n.read(o),f=r.useCallback(()=>n.retry(o),[n,o]);r.useLayoutEffect(()=>n.open(o),[n,o]);const d=vt(),{expanded:h,expandMultiple:x,collapseAll:w}=c,[v,C]=r.useState(null),y=v!==h,M=r.useRef(h);r.useLayoutEffect(()=>{M.current=h},[h]);const k=l.expandAll,_=r.useCallback(()=>u.announce(s.expandAllStarted),[u,s]),D=r.useCallback(A=>u.announce(zt(s,k,A)),[u,s,k]),I=kt({budget:k,expandMultiple:x,onStart:_,onFinish:D}),{status:b,start:L,end:E,advance:N}=I,P=b.state==="running",z=r.useMemo(()=>({running:P,advance:N}),[P,N]),V=r.useRef(null),[O,Y]=r.useState(!1),K=r.useCallback(A=>{V.current=A,Y(A!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(A=>{const Z=A.sourceId===o&&V.current!==null?Ce(V.current,A.path):null;Z!==null&&u.announce({list:s.foldersLoadFailedNamed,item:Z.name})}),[n,o,u,s]);const{clearDirect:H}=d,F=r.useCallback(()=>{E(),H(),C(M.current),w()},[E,H,w]);return r.useEffect(()=>{e({collapseAll:F,expandAll:O?L:null,expanding:P})},[e,F,L,O,P]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{O||E()},[O,E]),i.jsxs(i.Fragment,{children:[b.state==="stopped"?i.jsx(Wt,{stop:b.stop,opened:b.opened,budget:k}):null,i.jsxs("div",{className:"aqmx-explorer-tree-area",children:[i.jsx(r.Suspense,{fallback:i.jsx(Ne,{}),children:i.jsx(Yt,{result:m,onRetry:f,expansion:c,onShown:K,marks:d,claimsHeld:y,expandAll:z,...t})}),i.jsx(Ut,{pending:n.pendingChildren(o),status:b})]})]})};function Jt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const qe=p.forwardRef(Jt),ve="markdown-explorer-selection-remove",en=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:u}=R.useExplorer(),l=r.useId(),o=r.useRef(null),c=[...e],m=(d,h)=>{if(h.ownerDocument.activeElement===h){const x=o.current===null?[]:[...o.current.querySelectorAll(`[data-testid="${ve}"]`)],w=x.indexOf(h),v=[x[w+1],x[w-1]].find(C=>C!==void 0);v===void 0?s():v.focus()}t(d)},f=()=>{const d=o.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&s(),n()};return i.jsxs("section",{ref:o,className:"aqmx-explorer-tray","aria-labelledby":l,"data-testid":"markdown-explorer-selection-tray",children:[i.jsxs("div",{className:"aqmx-explorer-tray-header",children:[i.jsx("p",{id:l,className:"aqmx-explorer-tray-title",children:u.selectionTitle(c.length)}),i.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:f,children:u.clearSelection})]}),i.jsx("ul",{className:"aqmx-explorer-tray-list",children:c.map(([d,h])=>i.jsxs("li",{className:"aqmx-explorer-tray-item",children:[i.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),i.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(h),title:u.removeFromSelection(h),"data-testid":ve,"data-aqmx-path":d,onClick:x=>m(d,x.currentTarget),children:i.jsx(qe,{"aria-hidden":"true"})})]},d))}),a===void 0?null:i.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(c.map(([d])=>d)),children:u.openSelectionInMulti(c.length)})]})},ae=new Map,tn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},nn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Pe=r.createContext(null),rn=e=>{const t=r.use(Pe);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function an({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const ln=p.forwardRef(an);function on({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const sn=p.forwardRef(on);function cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const un=p.forwardRef(cn);function dn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const fn=p.forwardRef(dn);function mn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const pn=p.forwardRef(mn);function hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const xn=p.forwardRef(hn);function wn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const gn=p.forwardRef(wn);function En({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),p.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const bn=p.forwardRef(En);function vn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const Rn=p.forwardRef(vn);function Sn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const yn=p.forwardRef(Sn);function kn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Tn=p.forwardRef(kn);function Cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Ln=p.forwardRef(Cn),de=e=>{e.preventDefault(),e.stopPropagation()},jn=Object.freeze({sortMode:sn,directoriesFirst:Rn,selectionMode:un,doubleClickAction:gn,expandIconSize:Tn,alwaysExpanded:ln,removeRootIndent:fn,lines:Ln,expandIcons:pn,directoryIcons:yn,fileIcons:bn}),Oe=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Nn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:u})=>{const{labels:l}=R.useExplorer(),o=r.useRef([]);r.useEffect(()=>{o.current[0]?.focus()},[]);const c=r.useCallback(f=>{const d=n.length;o.current[(f%d+d)%d]?.focus()},[n.length]),m=r.useCallback((f,d)=>{switch(f.key){case"ArrowDown":f.preventDefault(),c(d+1);break;case"ArrowUp":f.preventDefault(),c(d-1);break;case"Home":f.preventDefault(),c(0);break;case"End":f.preventDefault(),c(n.length-1);break;case"Escape":de(f),s();break;case"Tab":s();break}},[n.length,c,s]);return i.jsx("div",{ref:u,id:e,role:"menu","aria-label":l.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((f,d)=>{const h=jn[f.key],x=Oe(l,f),w=T.formatTreeSettingValue(l,t,f.key),v=t[f.key],C=typeof v=="boolean"?{role:"menuitemcheckbox","aria-checked":v,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${w}`};return i.jsxs("button",{ref:y=>{o.current[d]=y},type:"button",tabIndex:-1,...C,title:`${x}: ${w}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":f.key,onClick:()=>a(f),onKeyDown:y=>m(y,d),children:[i.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),i.jsx("span",{className:"aqmx-explorer-menu-value",children:w})]},f.key)})})},qn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=R.useExplorer(),[u,l]=r.useState(!1),o=r.useRef(null),c=r.useRef(null),m=r.useRef(null),f=r.useId(),d=r.useCallback(()=>{o.current?.focus(),l(!1)},[]);r.useEffect(()=>{if(!u)return;const w=v=>{v.target instanceof Node&&(o.current?.contains(v.target)===!0||c.current?.contains(v.target)===!0)||(l(!1),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{m.current=null,(document.activeElement===null||document.activeElement===document.body)&&o.current?.focus()},0))};return document.addEventListener("pointerdown",w),()=>document.removeEventListener("pointerdown",w)},[u]),r.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const h=r.useCallback(w=>{w.key!=="Escape"||!u||(de(w),d())},[u,d]),x=r.useCallback(w=>{const v=n(w.key);s.announce(a.settingAnnouncement(Oe(a,w),T.formatTreeSettingValue(a,v,w.key)))},[s,a,n]);return{trigger:i.jsx("button",{ref:o,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?f:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>l(w=>!w),onKeyDown:h,children:i.jsx(xn,{"aria-hidden":"true"})}),menu:u?i.jsx(Nn,{ref:c,id:f,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},Pn=()=>{const{treeSettings:e}=R.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Re=new Set,On='[role="tree"] [role="treeitem"][tabindex="0"]',An="[data-directory-tree-tab-stop]",Mn=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:u,onSourceChange:l,viewSwitch:o}=e,{labels:c,sources:m,trees:f,documents:d,announcer:h}=R.useExplorer(),{settings:x,advance:w}=Pn(),v=r.useMemo(()=>T.visibleTreeSettingDescriptors(t==="tree"),[t]),C=t==="tree"&&x.selectionMode==="multiple";rn(C);const y=e.mode==="tree"?e.tray.onGatheredChange:null,M=e.mode==="tree"?e.onOpenSelection:void 0,k=e.mode==="tree"&&C?e.tray.gathered:ae,_=r.useCallback(S=>{const j=w(S);return j.selectionMode!=="multiple"&&y?.(ae),j},[w,y]),D=qn({settings:x,descriptors:v,onAdvance:_}),I=r.useCallback(S=>y?.(j=>tn(j,S)),[y]),b=r.useCallback(S=>y?.(j=>nn(j,S)),[y]),L=r.useCallback(()=>y?.(ae),[y]),E=r.useRef(null),N=r.useCallback(()=>{const S=E.current;if(S===null)return;[On,An,'[data-testid="markdown-explorer-tree-settings"]'].map(B=>S.querySelector(B)).find(B=>B!==null)?.focus()},[]),P=r.useMemo(()=>new Set(k.keys()),[k]),z=r.useMemo(()=>a===null?Re:new Set([a]),[a]),V=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(x.selectionMode){case"single":return{mode:"single",items:z,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:P,shownPath:a,onChange:I};case"none":return{mode:"none",items:Re,shownPath:null,onChange:null}}},[t,s,x.selectionMode,z,a,P,I]),[O,Y]=r.useState(null),[K,H]=r.useState(!1),[F,A]=r.useState(null),Z=r.useRef(!1),ee=r.useCallback(async()=>{if(!Z.current){Z.current=!0,H(!0),A(null);try{const S=await f.refresh(n);if(S.status==="superseded")return;d.invalidate(),S.status==="failed"?A({sourceId:n,failure:S.failure}):h.announce(c.treeRefreshed)}finally{Z.current=!1,H(!1)}}},[f,d,n,h,c]),Q=O===null?null:O.expandAll,W=O?.expanding===!0,X=m.find(S=>S.id===n),le=o.target==="multi"?lt:rt,$=o.target==="multi"?c.switchToMulti:c.switchToTree;return i.jsxs("nav",{ref:E,"aria-label":c.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[i.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?i.jsx("select",{className:"aqmx-explorer-source","aria-label":c.sourceLabel,title:X?.label,value:n,onChange:S=>l(S.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(S=>i.jsx("option",{value:S.id,children:S.label},S.id))}):null,i.jsxs("div",{className:"aqmx-explorer-actions",children:[i.jsx(R.ExplorerLink,{to:o.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":$,title:$,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":o.target,children:i.jsx(le,{"aria-hidden":"true"})}),i.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:c.refreshTree,"aria-disabled":K,"aria-busy":K,"data-aqmx-busy":K?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{ee()},children:[i.jsx(R.ForwardRef,{"aria-hidden":"true"}),i.jsx("span",{children:c.refresh})]}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":c.expandAll,title:c.expandAll,"aria-disabled":Q===null||W,"aria-busy":W,"data-aqmx-busy":W?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>Q?.(),children:i.jsx(tt,{"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":c.collapseAll,title:c.collapseAll,"aria-disabled":O===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>O?.collapseAll(),children:i.jsx(Je,{"aria-hidden":"true"})}),D.trigger]})]}),i.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[F!==null&&F.sourceId===n?i.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":F.failure.reason,children:c.treeRefreshFailed(R.failureTitleOf(c,F.failure.reason))}):null,i.jsx(r.Suspense,{fallback:null,children:i.jsx(ot,{})}),i.jsx(Qt,{mode:t,sourceId:n,settings:x,openPaths:s,selection:V,onOpenDocument:u,onControls:Y},n),C&&k.size>0?i.jsx(en,{selection:k,onRemove:b,onClear:L,onOpenSelection:M,onLeave:N}):null,D.menu]})]})},Ae="(pointer: coarse)",Fn=e=>{const t=window.matchMedia(Ae);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},_n=()=>window.matchMedia(Ae).matches,In=()=>!1,Dn=()=>r.useSyncExternalStore(Fn,_n,In);function Hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const Zn=p.forwardRef(Hn),$n=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:u}=R.useExplorer(),l=Ge.useLocation(),{location:o}=R.useExplorerLocation(),[c,m]=r.useState(!1),[f,d]=r.useState({navigated:l,source:o.source}),[h,x]=r.useState(!1);f.navigated!==l&&(d({navigated:l,source:o.source}),f.source===o.source&&!h&&m(!1));const[w,v]=r.useState(s);w!==s&&(v(s),m(!1));const C=r.useRef(null),y=r.useRef(null),M=r.useRef(null),k=r.useRef(!1),_=r.useId();r.useLayoutEffect(()=>{const E=C.current;E!==null&&(c&&!E.open?(E.showModal(),y.current?.focus()):!c&&E.open&&(E.close(),t.current?.focus()),a(c?M.current:null))},[c,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const D=r.useCallback(E=>{E.key!=="Escape"||E.defaultPrevented||(de(E),m(!1))},[]),I=r.useCallback(E=>{k.current=E.target===E.currentTarget},[]),b=r.useCallback(E=>{const N=k.current;k.current=!1,N&&E.target===E.currentTarget&&m(!1)},[]),L=r.useCallback(()=>{m(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:i.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":c,"aria-controls":_,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>m(!0),children:[i.jsx(Zn,{"aria-hidden":"true"}),i.jsx("span",{children:u.showExplorer})]})}),i.jsx("dialog",{ref:C,id:_,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:D,onPointerDown:I,onClick:b,onClose:L,children:i.jsxs("div",{className:"aqmx-sheet-panel",children:[i.jsxs("div",{className:"aqmx-sheet-header",children:[i.jsx("div",{ref:M,className:"aqmx-sheet-notice-slot"}),i.jsx("button",{ref:y,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>m(!1),children:i.jsx(qe,{"aria-hidden":"true"})})]}),i.jsx("div",{className:"aqmx-sheet-body",children:i.jsx(ue,{value:c,children:i.jsx(Pe,{value:x,children:e})})}),i.jsx(R.LiveRegion,{holds:c,testId:"markdown-explorer-sheet-announcer"})]})})]})},Me=r.createContext(null),fe="aqmx-explorer",Fe="aqmx-content",me='[role="tree"] [role="treeitem"]',Bn=`${me}[tabindex="0"]`,zn="[data-directory-tree-tab-stop]",Vn=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${fe}"] ${me}`))if(n.getAttribute(G)===t)return n;return null},Se=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:T.ASSUMED_ROOT_FONT_PIXELS}),Kn=(e,t)=>{const[n,a]=r.useState(()=>Se(0,0));return r.useLayoutEffect(()=>{const s=e.current,u=t.current;if(s===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const l={frame:s.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},o=()=>{const m=Se(l.frame,l.rem);a(f=>f.inlineSize===m.inlineSize&&f.rootFontPixels===m.rootFontPixels?f:m)};o();const c=new ResizeObserver(m=>{for(const f of m){const[d]=f.borderBoxSize;d!==void 0&&(f.target===s&&(l.frame=d.inlineSize),f.target===u&&(l.rem=d.inlineSize))}o()});return c.observe(s),c.observe(u),()=>c.disconnect()},[e,t]),n},_e=e=>`aqmx-split-handle-${e}`,Xn=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),u=r.useRef(null),l=r.useRef(!1);r.useLayoutEffect(()=>{const c=t.current;if(c===null)throw new Error("[markdown-explorer] the split frame is not mounted");const m=d=>{const h=d.target instanceof Element?d.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Fe}"]`)===null,!l.current&&(u.current=h?.closest(`${me}[${G}]`)?.getAttribute(G)??null)},f=d=>{d.relatedTarget instanceof Node&&!c.contains(d.relatedTarget)&&(s.current=!1)};return c.addEventListener("focusin",m),c.addEventListener("focusout",f),()=>{c.removeEventListener("focusin",m),c.removeEventListener("focusout",f)}},[t]);const o=r.useRef(e);r.useLayoutEffect(()=>{if(o.current===e)return;o.current=e;const c=t.current;if(c===null||!s.current)return;const m=f=>{const{activeElement:d,body:h}=c.ownerDocument;if(d!==null&&d!==h)return;const x=f.find(w=>w!==null);if(x!=null){l.current=!0;try{x.focus()}finally{l.current=!1}}};if(e){m([n.current]);return}queueMicrotask(()=>{if(o.current!==e||!s.current)return;const f=u.current,d=`[data-panel-id="${fe}"]`;m([f===null?null:Vn(c,f),c.querySelector(`${d} ${Bn}`),c.querySelector(`${d} ${zn}`),c.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},Un=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:u})=>{const l=r.useRef(null),[o,c]=r.useState(null),m=r.useRef(null),f=r.useRef(null),{inlineSize:d,rootFontPixels:h}=Kn(l,m),x=d!==null&&d<T.explorerSheetBelowPixels(h);return Xn(x,{frameRef:l,sheetToggleRef:f,handleId:_e(e)}),i.jsxs("div",{ref:l,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[i.jsx("span",{ref:m,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?i.jsx($n,{explorer:t,toggleRef:f,covered:a,onNoticeSlotChange:c,dismissals:s}):null,i.jsx(Me,{value:x?o:null,children:i.jsx(Wn,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:T.explorerMinPixels(h)})})]})},Wn=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:u,explorerMinPixels:l})=>{const{viewSettings:o,labels:c}=R.useExplorer(),f=R.useViewSetting(b=>e==="tree"?b.treeExplorer:b.multiExplorer)??(e==="tree"?T.EXPLORER_DEFAULT_PERCENT:T.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(null),h=r.useRef(null),x=r.useRef(!1),w=r.useRef(!1),[v,C]=r.useState(!1),y=r.useRef(u);r.useLayoutEffect(()=>{y.current=u},[u]);const M=r.useCallback(()=>{const b=d.current;if(b===null||b.length!==2)return;const[L=0,E=0]=b,N=L+E;if(N<=0||L<=0)return;const P=Math.min(T.EXPLORER_MAX_PERCENT,L/N*100);o.update(e==="tree"?{treeExplorer:P}:{multiExplorer:P})},[o,e]),k=r.useCallback(()=>{h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,M()},T.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[M]);r.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current),w.current&&y.current?.(!1)},[]);const _=Dn(),D=r.useCallback((b,L)=>{d.current=b;const[E=0,N=0]=b;b.length===2&&N>0&&C(E<=0),L.source==="keyboard"?k():L.source==="pointer"&&(x.current=!0)},[k]),I=r.useCallback(b=>{if(w.current=b,u?.(b),b){x.current=!1;return}x.current&&(x.current=!1,k())},[u,k]);return i.jsxs(re.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:D,className:"aqmx-split","data-aqmx-split":e,children:[t?null:i.jsx(re.Panel,{id:fe,defaultSize:{value:f,unit:"percentage"},minSize:{value:l,unit:"pixels"},maxSize:{value:T.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:i.jsx(ue,{value:!v,children:n})}),t?null:i.jsx(re.PanelResizeHandle,{id:_e(e),thickness:_?T.COARSE_TARGET_PIXELS:T.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:T.SPLIT_HANDLE_PIXELS.gripThickness,length:T.SPLIT_HANDLE_PIXELS.gripLength,barThickness:T.SPLIT_HANDLE_PIXELS.barThickness,barLength:T.SPLIT_HANDLE_PIXELS.barLength},title:c.resizeExplorer,"aria-label":c.resizeExplorer,onDragging:I,inert:s,className:"aqmx-split-handle"}),i.jsx(re.Panel,{id:Fe,defaultSize:{value:100-f,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=ae;exports.ExplorerPane=Mn;exports.ExplorerSplit=Un;exports.SheetNoticeSlotContext=Me;
1
+ "use strict";const i=require("react/jsx-runtime"),R=require("./index-Cx3-jSna.cjs"),r=require("react"),T=require("./location-Oo21lTyV.cjs"),ye=require("@aiquants/directory-tree"),Ue=require("@aiquants/virtualscroll"),We=require("./storage-Bkb2Axdi.cjs"),re=require("@aiquants/resize-panels"),Ge=require("react-router");function Ye(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Ye(r);function Qe({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const Je=p.forwardRef(Qe);function et({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const tt=p.forwardRef(et);function nt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),p.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const rt=p.forwardRef(nt);function at({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const lt=p.forwardRef(at),ot=()=>{const{notices:e}=R.useExplorer(),t=r.use(e);return t.length===0?null:i.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>i.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[i.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:i.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:i.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function st({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const ct=p.forwardRef(st),ue=r.createContext(!0),ke="\0loop\0",Te="\0",it=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=l=>{const o=e.get(l);if(o!==void 0)return o;const c=Object.freeze({type:"loop",name:l.name,path:l.path});return e.set(l,c),c},s=(l,o,c)=>{let m=!1;const f=l.map(h=>{const x=u(h,o,c);return x!==h&&(m=!0),x});if(!m)return l;const d=n.get(l);return d!==void 0&&d.length===f.length&&d.every((h,x)=>h===f[x])?d:(n.set(l,f),f)},u=(l,o,c)=>{if(l.type!=="directory")return l;if(c.has(l.path))return a(l);const m=l.lazy===!0?o(l.path):void 0,f=m?.status==="loaded",d=f?m.entries:l.children;if(d===void 0)return l;c.add(l.path);const h=s(d,o,c);if(c.delete(l.path),!f&&h===l.children)return l;const x=t.get(l);if(x!==void 0&&x.state===m&&x.children===h)return x.grafted;const w={...l,children:h,lazy:f?!1:l.lazy};return t.set(l,{state:m,children:h,grafted:w}),w};return(l,o)=>s(l,o,new Set)},ut=(e,t)=>`${ke}${e}${Te}${t}`,J=e=>e.startsWith(ke),dt=e=>e.slice(e.lastIndexOf(Te)+1),G="data-aqmx-path",ft=(e,t,n,a,s)=>{const u={aqmxPath:e.path};return n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:u}},mt=(e,t,n,a)=>{const s=ut(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},pt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(o,c,m)=>{const f=o.map(h=>h.type==="loop"?u(h,c,m):l(h,c)),d=n.get(o);return d!==void 0&&d.length===f.length&&d.every((h,x)=>h===f[x])?d:(n.set(o,f),f)},u=(o,c,m)=>{const f=t.get(o);if(f!==void 0&&f.parentKey===m&&f.loopFolderName===c.loopFolderName)return f.row;const d=mt(o,m,c.loopFolderName(o.name),a);return t.set(o,{row:d,parentKey:m,loopFolderName:c.loopFolderName}),d},l=(o,c)=>{const m=o.type==="directory"?o.children===void 0?a:s(o.children,c,o.path):void 0,f=c.openPaths.has(o.path),d=o.type==="directory"&&o.lazy===!0?c.childrenOf(o.path)?.status:void 0,h=d==="failed"?c.renderFailedFolder:void 0,x=e.get(o);if(x!==void 0&&x.open===f&&x.childrenStatus===d&&x.children===m&&x.renderFailedFolder===h)return x.row;const w=ft(o,m,f,d,h===void 0?void 0:h(o));return e.set(o,{row:w,open:f,childrenStatus:d,children:m,renderFailedFolder:h}),w};return(o,c)=>s(o,c,"")},ht=e=>{if(e===void 0)return;const t=n=>({name:n.name,path:n.absolutePath,type:n.type});return(n,a)=>e(t(n),t(a))},ie=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},xt=(e,t)=>{const n=new Map;let a=0;const s=u=>{for(const l of ie(u,t.compare))if(t.isShownExpanded(l.path)){if(l.lazy!==!0){l.children!==void 0&&s(l.children);continue}n.has(l.path)||(n.set(l.path,t.isDirect(l.path)?"direct":"bulk"),t.childrenOf(l.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},wt=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},Ce=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Ce(n.children,t);if(a!==null)return a}return null},Ee=new Set,gt=(e,t)=>e.has(t)?e:new Set(e).add(t),Et=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},bt=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),vt=()=>{const[e,t]=r.useState(Ee),n=r.useCallback(l=>t(o=>gt(o,l)),[]),a=r.useCallback(l=>t(o=>Et(o,l)),[]),s=r.useCallback(l=>t(o=>bt(o,l)),[]),u=r.useCallback(()=>t(Ee),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:u}),[e,n,a,s,u])},Rt=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),St=(e,t)=>{const n=[];let a=ie(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const u=[];for(const l of a){const{path:o}=l;if(t.isShownExpanded(o))e.handled.add(o);else{if(e.handled.has(o))continue;if(e.handled.add(o),l.lazy===!0&&t.childrenOf(o)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(o)}n.push(o),e.opened+=1}l.lazy!==!0&&l.children!==void 0&&u.push(...ie(l.children,t.compare))}a=u}return n},Le=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||Le(n.children,t))),yt=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:Le(t.entries,t.isShownExpanded)}},ce=Object.freeze({state:"idle"}),kt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(ce);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=Rt(n.current.budget),s({state:"running",opened:0}))},[]),l=r.useCallback(()=>{t.current=null,s(ce)},[]),o=r.useCallback(c=>{const m=t.current;if(m===null)return;const f=St(m,c);if(f.length>0&&(m.issuedAgainst=c.expanded,n.current.expandMultiple([...f])),!m.announcedStart&&(m.loads.size>0||c.waiting>0)&&(m.announcedStart=!0,n.current.onStart()),f.length===0&&!c.expansionPending&&c.expanded!==m.issuedAgainst&&c.waiting===0){t.current=null;const h=yt(m,c);s(h.kind==="done"?ce:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=m;s(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:l,advance:o}),[a,u,l,o])},Tt="--aqmx-tree-line",Ct=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Lt="data-aqmx-tree-probe",jt=Object.freeze({rowHeight:T.CONTROL_BLOCK_PIXELS,lineColor:null}),Nt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,qt=e=>{const t=Nt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Pt=(e,t)=>{const[n,a]=r.useState(jt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const u=()=>{const c=Math.round(s.getBoundingClientRect().height),m=getComputedStyle(s),f=m.getPropertyValue(Tt).trim()===""?null:qt(m.color);a(d=>{const h=Number.isFinite(c)&&c>0?c:d.rowHeight;return d.rowHeight===h&&d.lineColor===f?d:{rowHeight:h,lineColor:f}})};u();const l=Ct.map(c=>window.matchMedia(c));for(const c of l)c.addEventListener("change",u);const o=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return o?.observe(s),()=>{for(const c of l)c.removeEventListener("change",u);o?.disconnect()}},[e,t]),n},Ot={renderVisual:Ue.tapScrollCircleSampleVisual,minSpeedMultiplier:.25,maxSpeedMultiplier:18},At="markdown-explorer-tree-scroll",Mt={testId:At,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:Ot},behaviorOptions:{enablePointerDrag:!0}},Ft={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},_t={color:"inherit"},It={paddingBlock:0},Dt=new Set,Ht=new Map,Zt={color:"var(--aqmx-tree-line)"},be=["pointerdown","wheel","touchstart","keydown","focusin"],$t=(e,t,n)=>{const a=r.useRef(null),s=r.useRef(null),u=r.useCallback(()=>{const l=t.current;a.current===null||s.current!==null||l===null||l.getClientRects().length===0||(s.current=requestAnimationFrame(()=>{s.current=null;const o=a.current;o!==null&&e.current?.scrollToPath(o,{align:"nearest"})===!1&&(a.current=null)}))},[e,t]);r.useEffect(()=>{const l=t.current;if(l===null)return;const o=()=>{a.current=null},c=typeof ResizeObserver>"u"?null:new ResizeObserver(u);c?.observe(l);for(const m of be)l.addEventListener(m,o,{passive:!0});return()=>{c?.disconnect();for(const m of be)l.removeEventListener(m,o);s.current!==null&&cancelAnimationFrame(s.current),s.current=null}},[t,u]),r.useEffect(()=>{const l=t.current;a.current=n===null||l===null||l.contains(l.ownerDocument.activeElement)?null:n,u()},[n,t,u])},Bt=e=>{const t=e instanceof Element?e.closest(`[${G}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(G)},je=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),zt=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):je(e,t,n.kind,n.opened),Ne=()=>{const{labels:e}=R.useExplorer();return i.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[i.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),i.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})]})},Vt=()=>{const{labels:e}=R.useExplorer();return i.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[i.jsx(ct,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),i.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),i.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},Kt=({name:e,onRetry:t})=>{const{labels:n}=R.useExplorer(),a=r.useId();return i.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[i.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),i.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),i.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const u=s.currentTarget,l=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;l instanceof HTMLElement&&R.focusWithoutScroll(l),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[i.jsx(R.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},Xt=({entries:e,version:t,mode:n,sourceId:a,settings:s,openPaths:u,selection:l,onOpenDocument:o,expansion:c,onShown:m,marks:f,claimsHeld:d,expandAll:h})=>{const{trees:x,documents:w,labels:v,locale:C,theme:y}=R.useExplorer(),M=r.use(ue),[k]=r.useState(pt),_=r.useRef(null),{rowHeight:D,lineColor:I}=Pt(_,y),{isExpanded:b,toggle:L,expandMultiple:E,collapseMultiple:N,expanded:P,isPending:z}=c,{alwaysExpanded:V,sortMode:O,directoriesFirst:Y}=s,{direct:K,markDirect:H,unmarkDirect:F,pruneDirect:A}=f,{running:Z,advance:ee}=h,Q=r.useRef(null),W=r.useRef(null);$t(Q,W,l.shownPath);const X=r.useMemo(()=>T.createEntryComparator({sortMode:O,directoriesFirst:Y}),[O,Y]),le=r.useMemo(()=>ht(X),[X]),$=r.useCallback(g=>x.children(a,g),[x,a]),S=r.useMemo(()=>wt(e),[e]),j=r.useCallback(g=>!J(g)&&(b(g)||V&&!S.has(g)),[b,V,S]),B=r.useRef({shownExpanded:j,isExpanded:b,unloadedFolders:S});r.useLayoutEffect(()=>{B.current={shownExpanded:j,isExpanded:b,unloadedFolders:S}},[j,b,S]);const pe=r.useCallback(g=>{Q.current?.scrollToPath(g,{align:"nearest"}),requestAnimationFrame(()=>{const q=W.current;if(q===null)return;const U=[...q.querySelectorAll(`[role="treeitem"][${G}]`)].find(Xe=>Xe.getAttribute(G)===g);U!==void 0&&R.focusWithoutScroll(U)})},[]),Ie=r.useCallback(g=>{if(J(g)){pe(dt(g));return}B.current.isExpanded(g)?F([g]):B.current.unloadedFolders.has(g)&&H(g),L(g)},[pe,H,F,L]),oe=r.useCallback(g=>{const q=g.filter(U=>!J(U));q.length!==0&&(F(q),N(q))},[F,N]),De=r.useCallback(g=>{const q=g.filter(U=>!J(U));q.length!==0&&(q.length<g.length&&q.every(U=>B.current.shownExpanded(U))?oe(q):E(q))},[E,oe]),he=r.useCallback(g=>i.jsx(Kt,{name:g.name,onRetry:()=>{H(g.path),x.retryChildren(a,g.path),B.current.shownExpanded(g.path)||E([g.path])}}),[x,a,H,E]),xe=n==="multi"?u:Dt,{loopFolderName:we}=v,He=r.useMemo(()=>k(e,{openPaths:xe,childrenOf:$,renderFailedFolder:he,loopFolderName:we}),[k,e,xe,$,he,we,t]),Ze=R.useIntentPrefetch(w,Bt),ge=r.useCallback(g=>K.has(g),[K]),te=r.useMemo(()=>xt(e,{isShownExpanded:j,childrenOf:$,compare:X,isDirect:ge}),[e,j,$,X,ge,t]),ne=M&&d;r.useLayoutEffect(()=>{m(e)},[e,m]),r.useLayoutEffect(()=>()=>m(null),[m]),r.useEffect(()=>x.claimChildren(a,ne?te.folders:Ht),[x,a,ne,te]),r.useEffect(()=>A(S),[A,S]),r.useEffect(()=>{ne&&Z&&ee({entries:e,isShownExpanded:j,childrenOf:$,compare:X,expanded:P,waiting:te.waiting,expansionPending:z})},[ne,Z,ee,e,j,$,X,P,te,z]);const $e=r.useCallback(g=>{g.isDirectory||o(g.entry.absolutePath)},[o]),{onChange:se}=l,Be=r.useMemo(()=>se===null?void 0:(g,q)=>{J(g.absolutePath)||se({path:g.absolutePath,name:g.name,selected:q})},[se]),ze=r.useMemo(()=>new Set(l.items),[l.items]),Ve=r.useMemo(()=>({entryKindDirectory:v.treeEntryKindDirectory,entryKindFile:v.treeEntryKindFile,scrollUp:v.treeScrollUp,scrollDown:v.treeScrollDown,scrollToTop:v.treeScrollToTop,scrollToBottom:v.treeScrollToBottom}),[v]),Ke=I===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:I};return i.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...Ze,children:[i.jsx("span",{ref:_,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Lt]:""}),i.jsx(ye.DirectoryTree,{ref:Q,entries:He,expansion:{toggle:Ie,isExpanded:j,expandMultiple:De,collapseMultiple:oe,isPending:z&&!Z,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ze,onEntryClick:$e,onSelectionChange:Be},visual:{className:"aqmx-explorer-tree-view",ariaLabel:v.treeRegion,...Ke,showExpandIcons:s.expandIcons,expandIconStyle:Zt,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:D,removeRootIndent:s.removeRootIndent,highlightStyles:Ft,entryStyle:It,nameStyle:_t},virtualScroll:Mt,sort:le,locale:C,labels:Ve})]})},Ut=({pending:e,status:t})=>{const{labels:n}=R.useExplorer(),a=t.state!=="running",[s,u]=r.useState(0),l=r.useRef(!0);r.useLayoutEffect(()=>{const c=l.current;if(l.current=a,!a||e>0&&!c){u(0);return}if(e>0){u(e);return}if(s===0)return;const m=setTimeout(()=>u(0),0);return()=>clearTimeout(m)},[a,e,s]);const o=a&&e===0?s:e;return o===0&&a?null:i.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(o),"data-aqmx-expand-all":t.state,children:[o>0?i.jsx(R.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,i.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,o):n.foldersLoading(o)})]})},Wt=({stop:e,opened:t,budget:n})=>{const{labels:a}=R.useExplorer();return i.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:je(a,n,e,t)})},Gt=({entries:e,...t})=>{const{trees:n}=R.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[u]=r.useState(it),l=r.useMemo(()=>u(e,o=>n.children(s,o)),[u,e,n,s,a]);return l.length===0?i.jsx(Vt,{}):i.jsx(Xt,{entries:l,version:a,...t})},Yt=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=R.useExplorer(),s=r.use(e);if(s.status==="deferred")return i.jsx(Ne,{});if(s.status==="ok")return i.jsx(Gt,{entries:s.entries,...n});const u=a?.(s.failure);return i.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:u!==void 0?u:i.jsx(R.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},Qt=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:u,config:l}=R.useExplorer(),{sourceId:o}=t,c=ye.useDirectoryTreeState({storageKey:We.storageKeys(a).treeExpansion(o)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const m=n.read(o),f=r.useCallback(()=>n.retry(o),[n,o]);r.useLayoutEffect(()=>n.open(o),[n,o]);const d=vt(),{expanded:h,expandMultiple:x,collapseAll:w}=c,[v,C]=r.useState(null),y=v!==h,M=r.useRef(h);r.useLayoutEffect(()=>{M.current=h},[h]);const k=l.expandAll,_=r.useCallback(()=>u.announce(s.expandAllStarted),[u,s]),D=r.useCallback(A=>u.announce(zt(s,k,A)),[u,s,k]),I=kt({budget:k,expandMultiple:x,onStart:_,onFinish:D}),{status:b,start:L,end:E,advance:N}=I,P=b.state==="running",z=r.useMemo(()=>({running:P,advance:N}),[P,N]),V=r.useRef(null),[O,Y]=r.useState(!1),K=r.useCallback(A=>{V.current=A,Y(A!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(A=>{const Z=A.sourceId===o&&V.current!==null?Ce(V.current,A.path):null;Z!==null&&u.announce({list:s.foldersLoadFailedNamed,item:Z.name})}),[n,o,u,s]);const{clearDirect:H}=d,F=r.useCallback(()=>{E(),H(),C(M.current),w()},[E,H,w]);return r.useEffect(()=>{e({collapseAll:F,expandAll:O?L:null,expanding:P})},[e,F,L,O,P]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{O||E()},[O,E]),i.jsxs(i.Fragment,{children:[b.state==="stopped"?i.jsx(Wt,{stop:b.stop,opened:b.opened,budget:k}):null,i.jsxs("div",{className:"aqmx-explorer-tree-area",children:[i.jsx(r.Suspense,{fallback:i.jsx(Ne,{}),children:i.jsx(Yt,{result:m,onRetry:f,expansion:c,onShown:K,marks:d,claimsHeld:y,expandAll:z,...t})}),i.jsx(Ut,{pending:n.pendingChildren(o),status:b})]})]})};function Jt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const qe=p.forwardRef(Jt),ve="markdown-explorer-selection-remove",en=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:u}=R.useExplorer(),l=r.useId(),o=r.useRef(null),c=[...e],m=(d,h)=>{if(h.ownerDocument.activeElement===h){const x=o.current===null?[]:[...o.current.querySelectorAll(`[data-testid="${ve}"]`)],w=x.indexOf(h),v=[x[w+1],x[w-1]].find(C=>C!==void 0);v===void 0?s():v.focus()}t(d)},f=()=>{const d=o.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&s(),n()};return i.jsxs("section",{ref:o,className:"aqmx-explorer-tray","aria-labelledby":l,"data-testid":"markdown-explorer-selection-tray",children:[i.jsxs("div",{className:"aqmx-explorer-tray-header",children:[i.jsx("p",{id:l,className:"aqmx-explorer-tray-title",children:u.selectionTitle(c.length)}),i.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:f,children:u.clearSelection})]}),i.jsx("ul",{className:"aqmx-explorer-tray-list",children:c.map(([d,h])=>i.jsxs("li",{className:"aqmx-explorer-tray-item",children:[i.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),i.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(h),title:u.removeFromSelection(h),"data-testid":ve,"data-aqmx-path":d,onClick:x=>m(d,x.currentTarget),children:i.jsx(qe,{"aria-hidden":"true"})})]},d))}),a===void 0?null:i.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(c.map(([d])=>d)),children:u.openSelectionInMulti(c.length)})]})},ae=new Map,tn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},nn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Pe=r.createContext(null),rn=e=>{const t=r.use(Pe);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function an({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const ln=p.forwardRef(an);function on({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const sn=p.forwardRef(on);function cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const un=p.forwardRef(cn);function dn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const fn=p.forwardRef(dn);function mn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const pn=p.forwardRef(mn);function hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const xn=p.forwardRef(hn);function wn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const gn=p.forwardRef(wn);function En({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),p.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const bn=p.forwardRef(En);function vn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const Rn=p.forwardRef(vn);function Sn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const yn=p.forwardRef(Sn);function kn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Tn=p.forwardRef(kn);function Cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Ln=p.forwardRef(Cn),de=e=>{e.preventDefault(),e.stopPropagation()},jn=Object.freeze({sortMode:sn,directoriesFirst:Rn,selectionMode:un,doubleClickAction:gn,expandIconSize:Tn,alwaysExpanded:ln,removeRootIndent:fn,lines:Ln,expandIcons:pn,directoryIcons:yn,fileIcons:bn}),Oe=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Nn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:u})=>{const{labels:l}=R.useExplorer(),o=r.useRef([]);r.useEffect(()=>{o.current[0]?.focus()},[]);const c=r.useCallback(f=>{const d=n.length;o.current[(f%d+d)%d]?.focus()},[n.length]),m=r.useCallback((f,d)=>{switch(f.key){case"ArrowDown":f.preventDefault(),c(d+1);break;case"ArrowUp":f.preventDefault(),c(d-1);break;case"Home":f.preventDefault(),c(0);break;case"End":f.preventDefault(),c(n.length-1);break;case"Escape":de(f),s();break;case"Tab":s();break}},[n.length,c,s]);return i.jsx("div",{ref:u,id:e,role:"menu","aria-label":l.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((f,d)=>{const h=jn[f.key],x=Oe(l,f),w=T.formatTreeSettingValue(l,t,f.key),v=t[f.key],C=typeof v=="boolean"?{role:"menuitemcheckbox","aria-checked":v,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${w}`};return i.jsxs("button",{ref:y=>{o.current[d]=y},type:"button",tabIndex:-1,...C,title:`${x}: ${w}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":f.key,onClick:()=>a(f),onKeyDown:y=>m(y,d),children:[i.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),i.jsx("span",{className:"aqmx-explorer-menu-value",children:w})]},f.key)})})},qn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=R.useExplorer(),[u,l]=r.useState(!1),o=r.useRef(null),c=r.useRef(null),m=r.useRef(null),f=r.useId(),d=r.useCallback(()=>{o.current?.focus(),l(!1)},[]);r.useEffect(()=>{if(!u)return;const w=v=>{v.target instanceof Node&&(o.current?.contains(v.target)===!0||c.current?.contains(v.target)===!0)||(l(!1),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{m.current=null,(document.activeElement===null||document.activeElement===document.body)&&o.current?.focus()},0))};return document.addEventListener("pointerdown",w),()=>document.removeEventListener("pointerdown",w)},[u]),r.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const h=r.useCallback(w=>{w.key!=="Escape"||!u||(de(w),d())},[u,d]),x=r.useCallback(w=>{const v=n(w.key);s.announce(a.settingAnnouncement(Oe(a,w),T.formatTreeSettingValue(a,v,w.key)))},[s,a,n]);return{trigger:i.jsx("button",{ref:o,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?f:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>l(w=>!w),onKeyDown:h,children:i.jsx(xn,{"aria-hidden":"true"})}),menu:u?i.jsx(Nn,{ref:c,id:f,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},Pn=()=>{const{treeSettings:e}=R.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Re=new Set,On='[role="tree"] [role="treeitem"][tabindex="0"]',An="[data-directory-tree-tab-stop]",Mn=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:u,onSourceChange:l,viewSwitch:o}=e,{labels:c,sources:m,trees:f,documents:d,announcer:h}=R.useExplorer(),{settings:x,advance:w}=Pn(),v=r.useMemo(()=>T.visibleTreeSettingDescriptors(t==="tree"),[t]),C=t==="tree"&&x.selectionMode==="multiple";rn(C);const y=e.mode==="tree"?e.tray.onGatheredChange:null,M=e.mode==="tree"?e.onOpenSelection:void 0,k=e.mode==="tree"&&C?e.tray.gathered:ae,_=r.useCallback(S=>{const j=w(S);return j.selectionMode!=="multiple"&&y?.(ae),j},[w,y]),D=qn({settings:x,descriptors:v,onAdvance:_}),I=r.useCallback(S=>y?.(j=>tn(j,S)),[y]),b=r.useCallback(S=>y?.(j=>nn(j,S)),[y]),L=r.useCallback(()=>y?.(ae),[y]),E=r.useRef(null),N=r.useCallback(()=>{const S=E.current;if(S===null)return;[On,An,'[data-testid="markdown-explorer-tree-settings"]'].map(B=>S.querySelector(B)).find(B=>B!==null)?.focus()},[]),P=r.useMemo(()=>new Set(k.keys()),[k]),z=r.useMemo(()=>a===null?Re:new Set([a]),[a]),V=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(x.selectionMode){case"single":return{mode:"single",items:z,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:P,shownPath:a,onChange:I};case"none":return{mode:"none",items:Re,shownPath:null,onChange:null}}},[t,s,x.selectionMode,z,a,P,I]),[O,Y]=r.useState(null),[K,H]=r.useState(!1),[F,A]=r.useState(null),Z=r.useRef(!1),ee=r.useCallback(async()=>{if(!Z.current){Z.current=!0,H(!0),A(null);try{const S=await f.refresh(n);if(S.status==="superseded")return;d.invalidate(),S.status==="failed"?A({sourceId:n,failure:S.failure}):h.announce(c.treeRefreshed)}finally{Z.current=!1,H(!1)}}},[f,d,n,h,c]),Q=O===null?null:O.expandAll,W=O?.expanding===!0,X=m.find(S=>S.id===n),le=o.target==="multi"?lt:rt,$=o.target==="multi"?c.switchToMulti:c.switchToTree;return i.jsxs("nav",{ref:E,"aria-label":c.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[i.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?i.jsx("select",{className:"aqmx-explorer-source","aria-label":c.sourceLabel,title:X?.label,value:n,onChange:S=>l(S.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(S=>i.jsx("option",{value:S.id,children:S.label},S.id))}):null,i.jsxs("div",{className:"aqmx-explorer-actions",children:[i.jsx(R.ExplorerLink,{to:o.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":$,title:$,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":o.target,children:i.jsx(le,{"aria-hidden":"true"})}),i.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:c.refreshTree,"aria-disabled":K,"aria-busy":K,"data-aqmx-busy":K?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{ee()},children:[i.jsx(R.ForwardRef,{"aria-hidden":"true"}),i.jsx("span",{children:c.refreshTreeLabel})]}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":c.expandAll,title:c.expandAll,"aria-disabled":Q===null||W,"aria-busy":W,"data-aqmx-busy":W?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>Q?.(),children:i.jsx(tt,{"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":c.collapseAll,title:c.collapseAll,"aria-disabled":O===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>O?.collapseAll(),children:i.jsx(Je,{"aria-hidden":"true"})}),D.trigger]})]}),i.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[F!==null&&F.sourceId===n?i.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":F.failure.reason,children:c.treeRefreshFailed(R.failureTitleOf(c,F.failure.reason))}):null,i.jsx(r.Suspense,{fallback:null,children:i.jsx(ot,{})}),i.jsx(Qt,{mode:t,sourceId:n,settings:x,openPaths:s,selection:V,onOpenDocument:u,onControls:Y},n),C&&k.size>0?i.jsx(en,{selection:k,onRemove:b,onClear:L,onOpenSelection:M,onLeave:N}):null,D.menu]})]})},Ae="(pointer: coarse)",Fn=e=>{const t=window.matchMedia(Ae);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},_n=()=>window.matchMedia(Ae).matches,In=()=>!1,Dn=()=>r.useSyncExternalStore(Fn,_n,In);function Hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const Zn=p.forwardRef(Hn),$n=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:u}=R.useExplorer(),l=Ge.useLocation(),{location:o}=R.useExplorerLocation(),[c,m]=r.useState(!1),[f,d]=r.useState({navigated:l,source:o.source}),[h,x]=r.useState(!1);f.navigated!==l&&(d({navigated:l,source:o.source}),f.source===o.source&&!h&&m(!1));const[w,v]=r.useState(s);w!==s&&(v(s),m(!1));const C=r.useRef(null),y=r.useRef(null),M=r.useRef(null),k=r.useRef(!1),_=r.useId();r.useLayoutEffect(()=>{const E=C.current;E!==null&&(c&&!E.open?(E.showModal(),y.current?.focus()):!c&&E.open&&(E.close(),t.current?.focus()),a(c?M.current:null))},[c,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const D=r.useCallback(E=>{E.key!=="Escape"||E.defaultPrevented||(de(E),m(!1))},[]),I=r.useCallback(E=>{k.current=E.target===E.currentTarget},[]),b=r.useCallback(E=>{const N=k.current;k.current=!1,N&&E.target===E.currentTarget&&m(!1)},[]),L=r.useCallback(()=>{m(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:i.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":c,"aria-controls":_,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>m(!0),children:[i.jsx(Zn,{"aria-hidden":"true"}),i.jsx("span",{children:u.showExplorer})]})}),i.jsx("dialog",{ref:C,id:_,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:D,onPointerDown:I,onClick:b,onClose:L,children:i.jsxs("div",{className:"aqmx-sheet-panel",children:[i.jsxs("div",{className:"aqmx-sheet-header",children:[i.jsx("div",{ref:M,className:"aqmx-sheet-notice-slot"}),i.jsx("button",{ref:y,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>m(!1),children:i.jsx(qe,{"aria-hidden":"true"})})]}),i.jsx("div",{className:"aqmx-sheet-body",children:i.jsx(ue,{value:c,children:i.jsx(Pe,{value:x,children:e})})}),i.jsx(R.LiveRegion,{holds:c,testId:"markdown-explorer-sheet-announcer"})]})})]})},Me=r.createContext(null),fe="aqmx-explorer",Fe="aqmx-content",me='[role="tree"] [role="treeitem"]',Bn=`${me}[tabindex="0"]`,zn="[data-directory-tree-tab-stop]",Vn=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${fe}"] ${me}`))if(n.getAttribute(G)===t)return n;return null},Se=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:T.ASSUMED_ROOT_FONT_PIXELS}),Kn=(e,t)=>{const[n,a]=r.useState(()=>Se(0,0));return r.useLayoutEffect(()=>{const s=e.current,u=t.current;if(s===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const l={frame:s.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},o=()=>{const m=Se(l.frame,l.rem);a(f=>f.inlineSize===m.inlineSize&&f.rootFontPixels===m.rootFontPixels?f:m)};o();const c=new ResizeObserver(m=>{for(const f of m){const[d]=f.borderBoxSize;d!==void 0&&(f.target===s&&(l.frame=d.inlineSize),f.target===u&&(l.rem=d.inlineSize))}o()});return c.observe(s),c.observe(u),()=>c.disconnect()},[e,t]),n},_e=e=>`aqmx-split-handle-${e}`,Xn=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),u=r.useRef(null),l=r.useRef(!1);r.useLayoutEffect(()=>{const c=t.current;if(c===null)throw new Error("[markdown-explorer] the split frame is not mounted");const m=d=>{const h=d.target instanceof Element?d.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Fe}"]`)===null,!l.current&&(u.current=h?.closest(`${me}[${G}]`)?.getAttribute(G)??null)},f=d=>{d.relatedTarget instanceof Node&&!c.contains(d.relatedTarget)&&(s.current=!1)};return c.addEventListener("focusin",m),c.addEventListener("focusout",f),()=>{c.removeEventListener("focusin",m),c.removeEventListener("focusout",f)}},[t]);const o=r.useRef(e);r.useLayoutEffect(()=>{if(o.current===e)return;o.current=e;const c=t.current;if(c===null||!s.current)return;const m=f=>{const{activeElement:d,body:h}=c.ownerDocument;if(d!==null&&d!==h)return;const x=f.find(w=>w!==null);if(x!=null){l.current=!0;try{x.focus()}finally{l.current=!1}}};if(e){m([n.current]);return}queueMicrotask(()=>{if(o.current!==e||!s.current)return;const f=u.current,d=`[data-panel-id="${fe}"]`;m([f===null?null:Vn(c,f),c.querySelector(`${d} ${Bn}`),c.querySelector(`${d} ${zn}`),c.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},Un=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:u})=>{const l=r.useRef(null),[o,c]=r.useState(null),m=r.useRef(null),f=r.useRef(null),{inlineSize:d,rootFontPixels:h}=Kn(l,m),x=d!==null&&d<T.explorerSheetBelowPixels(h);return Xn(x,{frameRef:l,sheetToggleRef:f,handleId:_e(e)}),i.jsxs("div",{ref:l,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[i.jsx("span",{ref:m,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?i.jsx($n,{explorer:t,toggleRef:f,covered:a,onNoticeSlotChange:c,dismissals:s}):null,i.jsx(Me,{value:x?o:null,children:i.jsx(Wn,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:T.explorerMinPixels(h)})})]})},Wn=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:u,explorerMinPixels:l})=>{const{viewSettings:o,labels:c}=R.useExplorer(),f=R.useViewSetting(b=>e==="tree"?b.treeExplorer:b.multiExplorer)??(e==="tree"?T.EXPLORER_DEFAULT_PERCENT:T.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(null),h=r.useRef(null),x=r.useRef(!1),w=r.useRef(!1),[v,C]=r.useState(!1),y=r.useRef(u);r.useLayoutEffect(()=>{y.current=u},[u]);const M=r.useCallback(()=>{const b=d.current;if(b===null||b.length!==2)return;const[L=0,E=0]=b,N=L+E;if(N<=0||L<=0)return;const P=Math.min(T.EXPLORER_MAX_PERCENT,L/N*100);o.update(e==="tree"?{treeExplorer:P}:{multiExplorer:P})},[o,e]),k=r.useCallback(()=>{h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,M()},T.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[M]);r.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current),w.current&&y.current?.(!1)},[]);const _=Dn(),D=r.useCallback((b,L)=>{d.current=b;const[E=0,N=0]=b;b.length===2&&N>0&&C(E<=0),L.source==="keyboard"?k():L.source==="pointer"&&(x.current=!0)},[k]),I=r.useCallback(b=>{if(w.current=b,u?.(b),b){x.current=!1;return}x.current&&(x.current=!1,k())},[u,k]);return i.jsxs(re.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:D,className:"aqmx-split","data-aqmx-split":e,children:[t?null:i.jsx(re.Panel,{id:fe,defaultSize:{value:f,unit:"percentage"},minSize:{value:l,unit:"pixels"},maxSize:{value:T.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:i.jsx(ue,{value:!v,children:n})}),t?null:i.jsx(re.PanelResizeHandle,{id:_e(e),thickness:_?T.COARSE_TARGET_PIXELS:T.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:T.SPLIT_HANDLE_PIXELS.gripThickness,length:T.SPLIT_HANDLE_PIXELS.gripLength,barThickness:T.SPLIT_HANDLE_PIXELS.barThickness,barLength:T.SPLIT_HANDLE_PIXELS.barLength},title:c.resizeExplorer,"aria-label":c.resizeExplorer,onDragging:I,inert:s,className:"aqmx-split-handle"}),i.jsx(re.Panel,{id:Fe,defaultSize:{value:100-f,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=ae;exports.ExplorerPane=Mn;exports.ExplorerSplit=Un;exports.SheetNoticeSlotContext=Me;
@@ -1,8 +1,8 @@
1
1
  import { jsx as m, jsxs as S, Fragment as _e } from "react/jsx-runtime";
2
- import { u as k, F as ct, b as ge, f as Ie, d as it, E as dt, g as ut, h as mt, L as pt, i as ft } from "./index-BgkZ9ATV.js";
2
+ import { u as k, F as ct, d as ge, f as Ie, g as it, E as dt, h as ut, i as mt, L as pt, j as ft } from "./index-BfuAu2GV.js";
3
3
  import * as p from "react";
4
4
  import { use as ie, createContext as ve, useState as N, useCallback as x, useMemo as C, useRef as v, useLayoutEffect as P, useSyncExternalStore as de, useEffect as H, Suspense as De, useId as ue } from "react";
5
- import { C as ht, k as xt, l as He, v as wt, m as gt, n as vt, E as bt, o as qe, q as Et, s as yt, S as ce, t as Rt, F as St, A as Tt } from "./location-Cb2Ak55B.js";
5
+ import { C as ht, k as xt, l as He, v as wt, m as gt, n as vt, E as bt, o as qe, q as Et, s as yt, S as ce, t as Rt, F as St, A as Tt } from "./location-fVl2R1ee.js";
6
6
  import { useDirectoryTreeState as Lt, DirectoryTree as Nt } from "@aiquants/directory-tree";
7
7
  import { tapScrollCircleSampleVisual as kt } from "@aiquants/virtualscroll";
8
8
  import { s as qt } from "./storage-DA4ItHzl.js";
@@ -1104,7 +1104,7 @@ const ir = /* @__PURE__ */ p.forwardRef(cr), Ee = (e) => {
1104
1104
  },
1105
1105
  children: [
1106
1106
  /* @__PURE__ */ m(ge, { "aria-hidden": "true" }),
1107
- /* @__PURE__ */ m("span", { children: s.refresh })
1107
+ /* @__PURE__ */ m("span", { children: s.refreshTreeLabel })
1108
1108
  ]
1109
1109
  }
1110
1110
  ),