@aiquants/markdown-explorer 0.5.0 → 0.6.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.
- package/CHANGELOG.md +19 -0
- package/README.md +10 -2
- package/dist/{ExplorerSplit-CWcK1E4I.js → ExplorerSplit-CN5TvRj6.js} +2 -2
- package/dist/{ExplorerSplit-ajN3GSdA.cjs → ExplorerSplit-CUIbSLQm.cjs} +1 -1
- package/dist/{MultiLayout-DvkcdO9c.cjs → MultiLayout-BDcQSpa6.cjs} +1 -1
- package/dist/{MultiLayout-BtWtCzJV.js → MultiLayout-hPmV-bae.js} +4 -4
- package/dist/{NativeScrollBar-DbzyQ85y.cjs → NativeScrollBar-CHEQgaVx.cjs} +1 -1
- package/dist/{NativeScrollBar-apXjIKRW.js → NativeScrollBar-DYEv2GLV.js} +1 -1
- package/dist/{TreeLayout-rwhJfLmU.cjs → TreeLayout-BDaIyoGT.cjs} +1 -1
- package/dist/{TreeLayout-BcHsv9G8.js → TreeLayout-CqzxLpoM.js} +3 -3
- package/dist/core/contracts.d.cts +10 -7
- package/dist/core/contracts.d.ts +10 -7
- package/dist/core/labels.d.cts +4 -0
- package/dist/core/labels.d.ts +4 -0
- package/dist/dataRoute-CUXlMhUJ.cjs +1 -0
- package/dist/{dataRoute-Btg4w3vO.js → dataRoute-Ce6EIuu4.js} +41 -40
- package/dist/index-B3nShkkt.cjs +3 -0
- package/dist/{index-CIZw73j9.js → index-gJp1iXTc.js} +987 -903
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/{location-c1zdeySY.js → location-CtM94G0O.js} +1 -1
- package/dist/{location-CSIhx-L4.cjs → location-FavgY_gB.cjs} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +1 -0
- package/dist/server/ports.d.ts +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.js +670 -641
- package/dist/styles/markdown-explorer.css +1 -1
- package/docs/behavior/dom-hooks.md +6 -3
- package/docs/behavior/layout.md +6 -0
- package/docs/behavior/localization.md +4 -1
- package/docs/behavior/security.md +11 -4
- package/package.json +4 -3
- package/dist/dataRoute-DHpu0fg2.cjs +0 -1
- package/dist/index-Cie6WPiM.cjs +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Source of a Markdown document** (minor): the document bar offers a **Source** toggle before Refresh document while its document is a loaded Markdown document — labelled beside a page view's pane (`showMarkupLabel` «Source» / 「ソース」, tooltip `showMarkup`), icon-only and named after the document in a multi-view panel (`showMarkupNamed`) — a toggle button (`aria-pressed`) that shows the document as written instead of rendered, in place, keeping the focus on the toggle.
|
|
8
|
+
- The pane reads the document's file through the data route's new `text` operation and shows it like a text file (the file header with Open and Download, `textTruncated` when the file was cut, the text never interpreted): the skeleton until the first answer (`markupLoading` for screen readers), a failure announced once (`documentFailed`) with Try again for a `failed` read, and the text read again on every new answer for the document (Refresh document, Refresh tree, a revalidation) while the previous text stays.
|
|
9
|
+
- The choice belongs to the reader and the document (one choice per reader): every view showing the document follows it, a document the reader comes back to keeps it, and nothing is saved. The document region carries `data-aqmx-document-view` (`rendered` / `markup`) for a Markdown document; new DOM hooks `markdown-explorer-document-markup`, `markdown-explorer-markup-skeleton` and `markdown-explorer-markup-failure`.
|
|
10
|
+
- The data route's `text` operation (`GET <dataPath>/text?path=<document>`, GET and HEAD) answers a text document (`name`, `text`, `truncated`, the asset `url`) or a failure document, behind the same authentication, deny rules (a refusal logged with the operation `text`) and admission as `asset`,
|
|
11
|
+
reading the file through the host's `asset` port: at most `textMaxBytes` bytes (a range when the reported size is larger, one byte past the limit when the size is unknown), decoded as UTF-8 (a leading byte order mark dropped, a multi-byte character the limit cuts left out), `unsupported` for bytes holding NUL, `failed` (logged) for a stream short of its reported size.
|
|
12
|
+
No host change is needed.
|
|
13
|
+
- The server option `textMaxBytes` (a positive integer up to 256 MiB; default 2 MiB) bounds it; `ExplorerOperation` gains `"text"`.
|
|
14
|
+
- New labels `showMarkupLabel`, `showMarkup`, `showMarkupNamed` and `markupLoading` (English and Japanese).
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **The refresh's proof of origin is the shared cross-origin check of server routes** (`crossOriginRefusal` of `@aiquants/request-isolation`, a new dependency, serving no navigation from another origin): the tree refresh and a document request marked as a refresh still need the custom header `X-Markdown-Explorer: refresh`, and now pass that one check instead of the explorer's own reading of `Sec-Fetch-Site`.
|
|
19
|
+
- A refresh `POST` without Fetch Metadata is now refused (403) when its `Origin` names another host or port, is `null` or is not a URL; before, any request without `Sec-Fetch-Site` passed. A request without `Origin` still passes, and so does a marked document `GET` without Fetch Metadata, whatever its `Origin`.
|
|
20
|
+
- `Sec-Fetch-Site: none` (a load the user started, which a fetch never sends) now passes, as `same-origin` does. `same-site` and `cross-site` are refused as before.
|
|
21
|
+
|
|
3
22
|
## 0.5.0 (2026-10-09)
|
|
4
23
|
|
|
5
24
|
### Added
|
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@ document. The document stays on screen while it reloads and is replaced in place
|
|
|
18
18
|
reloaded document is announced, and a failed reload keeps the document under a notice naming the failure, which is
|
|
19
19
|
announced too and stays until a newer copy of the document replaces or confirms it, the reader moves to another
|
|
20
20
|
document, or the next refresh starts.
|
|
21
|
+
Beside it, a Markdown document offers **Source**: a toggle that shows the document as written instead of rendered
|
|
22
|
+
(its file read through the data route's `text` operation, shown like a text file), for every view the document
|
|
23
|
+
appears in, until the reader toggles it back; the choice is never saved.
|
|
21
24
|
A single-view (embedding) page never downloads the tree and multi-panel views, which load on demand.
|
|
22
25
|
- **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 link card the explorer's own data route reads (`{dataPath}/link-card`, through `@aiquants/markdown`'s link-card handler: internal addresses never become cards); the link itself always stays, under the frame, as the card or as the paragraph.
|
|
23
26
|
- **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.
|
|
@@ -268,7 +271,7 @@ The full contract, including canonicalization, is in [URL contract](docs/behavio
|
|
|
268
271
|
| `scopeSecret` | `string` | The deployment's secret for the readers' scopes: at least 32 characters (a shorter one throws a `RangeError`) and the same on every server instance. |
|
|
269
272
|
| `sources` | `ExplorerSource<P>[]` | The sources in switcher order (at least one; the first is the default): `id` (lowercase letters, digits and `-`, starting with a letter or digit, unique; the URL's `source` value), `label` (a string, or a function of the principal), `boundary` (where the source's documents may lie, see [Source boundaries](#source-boundaries)), `tree(context)` (lists the source's roots), `children?(context, path, readPath)` for lazy folders (asked only while the tree shows the folder open — the reader opened it, Expand all opened it (a press keeps opening folders as their listings land, within `expandAll`), or a remembered expansion opened it — and only for a path inside the source's boundary; a listing no tree wants any more is aborted through `context.signal`, which the source should honour), `ancestors?(context, path, readPath, options)` (the folders down to a document, for the reader's reveal; see [Revealing the open document](#revealing-the-open-document)), `cacheScope?` (`"principal"`, the default, or `"shared"`). The `context` is described under [Entries and notices](#entries-and-notices). |
|
|
270
273
|
| `document` | `(context, path, readPath) => Promise<ExplorerHostDocument>` | Resolves a document path. Called only for a path inside at least one source's boundary; `readPath` is what the admitting source's `confirm` answered (`path` when that source has no `confirm`), so read `readPath` and show the document as `path`. An image, media, text or file document reports its file's `version`; the explorer writes its URL (see [Documents](#documents)). |
|
|
271
|
-
| `asset` | `(context, path, readPath) => Promise<ExplorerAssetFile>` | Finds the file behind the data route's `asset` operation: any regular file the document admission admits, whatever its kind. Called only after the path passed the deny rules and the same union admission as a document, with the same `readPath`; see [Serving files](#serving-files). |
|
|
274
|
+
| `asset` | `(context, path, readPath) => Promise<ExplorerAssetFile>` | Finds the file behind the data route's `asset` operation (and its `text` operation, which reads a Markdown document's source through it): any regular file the document admission admits, whatever its kind. Called only after the path passed the deny rules and the same union admission as a document, with the same `readPath`; see [Serving files](#serving-files). |
|
|
272
275
|
| `signedOutPage` | `(request, headers) => Response` | The page response for a signed-out reader, usually a redirect to sign-in. Data requests answer 401 instead. |
|
|
273
276
|
| `forbiddenPage?` | `(request, headers) => Response` | The page response for a reader without access (default: a 403 for the route's error boundary). |
|
|
274
277
|
| `notices?` | `(context) => Promise<ExplorerNotice[]>` | Callouts above the tree (a missing permission with a link that grants it, for example). |
|
|
@@ -276,6 +279,7 @@ The full contract, including canonicalization, is in [URL contract](docs/behavio
|
|
|
276
279
|
| `treeCache?` | `{ ttlMs?, maxEntries?, maxBytes? } \| false` | The server's tree cache, each limit defaulting on its own (5 minutes, 64 entries, 64 MiB of the trees' JSON, counted at two bytes per character). The time to live counts from the moment the tree's walk began, and an expired tree is never answered: a page load or tree request after it waits for one new walk, which every concurrent request shares. Each cached tree is also kept parsed beside its JSON, which `maxBytes` does not count; its share falls as names get longer and is higher for non-ASCII names (measured on trees of 20,000 entries: about 1.0 to 1.9 times the counted bytes for ASCII names of 40 down to 4 characters, 1.4 to 2.2 times for non-ASCII names), and a tree with any non-ASCII name keeps a two-byte JSON as large as its count, so plan for up to about 2.4 times `maxBytes` of memory per process with ASCII names and up to about 3.2 times with short non-ASCII names. `false` turns the cache off. |
|
|
277
280
|
| `sanitizer?` | `{ workers?, deadlineMs?, maxHtmlBytes?, cacheBytes?, workerHeapMb?, jobsPerScope?, maxQueuedJobs? }` | The HTML sanitizer, each field defaulting on its own: 2 worker threads, a 30 s deadline per document, HTML up to 4 MiB, a 64 MiB cache of outcomes, 512 MiB of heap per worker (`workerHeapMb`), at most `multiView.maxPanels` + max(1, `workers` − 1) + 3 documents per reader running or waiting (`maxPanels` + 4 with the default two workers, 16 with the default 12 panels) and four times `jobsPerScope` waiting in all, also when `jobsPerScope` is set. Neither `jobsPerScope` nor `maxQueuedJobs` may be set below `multiView.maxPanels`, because a page sends the document of every panel at once and a reader who finds every worker busy waits with all of them; a smaller value throws a `RangeError` naming both options at startup, as does a `workerHeapMb` that leaves room for fewer than 4,096 parsed nodes beside HTML of `maxHtmlBytes`. A document over the size, nesting, node, comment or attribute limits, whose sanitized HTML is longer than four characters per byte of `maxHtmlBytes` (16,777,216 by default), past the deadline, or one that runs a worker out of heap is `too-large`; one beyond either admission limit, or one whose worker could not start, is `failed` (logged without the principal) and a later request tries again. A reader runs at most `workers` − 1 documents at once (one when there is a single worker): with the default two workers, one reader — or all anonymous readers, who share one scope and so one admission budget — uses one. |
|
|
278
281
|
| `deferredTimeoutMs?` | `number` | How long the page loader waits for a streamed value (default 4000 ms; keep it below your server entry's `streamTimeout`). A late value renders the loading state on the server (never a failure) and is fetched by the browser once a pane shows it. The work behind a late tree or document keeps running for another `deferredTimeoutMs`, so the browser's data request for it can join that work instead of starting over (a host that joins requests for the same work keeps it for that request), and its `signal` aborts then; the work behind late notices, which the browser never fetches again, is aborted as soon as they are given up. |
|
|
282
|
+
| `textMaxBytes?` | `number` | The most bytes of a file the data route's `text` operation reads and answers (a positive integer up to 256 MiB; default 2 MiB): a longer file answers its beginning, marked truncated. The explorer shows a Markdown document's source with it, so a host that renders larger Markdown sets it to its own source limit. |
|
|
279
283
|
| `logger?` | `{ error(message, detail) }` | Where adapter failures and malformed source output are reported (default `console.error`). A tree or children entry with an empty name, or with a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash — for example macOS's `Icon\r`), or outside its source's boundary, is left out together with its subtree and reported with the message `[markdown-explorer] <operation> left out an entry` and the detail `{ operation, sourceId, path, error }`, whose `error` names the reason; any other malformed listing becomes `failed`. A boundary that throws or answers malformed values is reported with the operation `boundary`, and so is the rejection of a promise a `contains` answers (it is not awaited and counts as outside). A failed authentication of a data request is reported with the operation `authenticate` and never quotes a header: `headers` that `Headers` cannot read are reported by a fixed message, and a `Response` that `authenticate` throws (React Router's `throw redirect(...)`) by its status alone; any other exception of your adapters is logged as thrown, so keep secrets out of it. |
|
|
280
284
|
| `onTreeRefreshed?` | `(key: string) => void` | Called once per tree refresh, after its reload settled (whatever its result) unless the request went away, with the refreshed tree's cache key (opaque). A multi-process host relays the key to its other processes, which call `forgetTree(key)` (see [Hosting notes](#hosting-notes)). Its return value is ignored, but a promise it returns (an asynchronous relay) is observed, never awaited: a throw, or the rejection of that promise, is logged with the operation `refresh` and does not change the response. |
|
|
281
285
|
|
|
@@ -491,6 +495,9 @@ and `Cache-Control: private, max-age=60, stale-while-revalidate=600, no-transfor
|
|
|
491
495
|
The body of a 200 or 206 with a `Content-Length` carries exactly that many bytes: the explorer drops the bytes past it and cancels the stream `open` returned, and fails the response when that stream ends short, so a file that changes while it is served never gets a body that disagrees with its length and ETag.
|
|
492
496
|
The URL carries the path in its query, so no name needs an extra escape and the request's own path never ends in `.data`; a document's URL carries `v=<version>` as a cache-buster, which the server never reads (the ETag is always the current version).
|
|
493
497
|
|
|
498
|
+
The data route's `text` operation reads a file through the same port for the Source toggle: `<dataPath>/text?path=<document path>` (GET and HEAD) takes the same authentication, deny rules (a refusal logged once with the operation `text`) and admission as `asset`, then answers JSON like a document request — status 200 with a text document (`name`, `text`, `truncated`, and the file's asset `url` with its version) or a failure document, and the reader's scope header.
|
|
499
|
+
It reads at most `textMaxBytes` bytes (the first ones as a range when `size` is larger, the whole file otherwise, an empty file never, a file of unknown `size` one byte past the limit to learn whether more follows), cancels the stream once enough was read, decodes them as UTF-8 (a leading byte order mark dropped, a multi-byte character the limit cuts left out), and answers `unsupported` for bytes holding NUL and `failed` (logged) for a stream that ends before the `size` the port reported. It sends no refresh mark: the port receives `refresh: false`.
|
|
500
|
+
|
|
494
501
|
### Link cards
|
|
495
502
|
|
|
496
503
|
With `embeds: { linkCards: true }`, the data route has a `link-card` operation: `GET` or `HEAD` `<dataPath>/link-card?url=<href>`, which `@aiquants/markdown`'s link card asks (same-origin, in the background, once the card nears the viewport). It is the only route of the cards: the explorer creates `@aiquants/markdown`'s `createLinkCardHandler` once, in `createMarkdownExplorer`, behind the read-only authentication, and passes every answer of it through unchanged — status, headers and cache headers. In order:
|
|
@@ -647,7 +654,8 @@ Every scroller of the explorer that the reader browses gets one pointer scroll b
|
|
|
647
654
|
- 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.
|
|
648
655
|
- 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.
|
|
649
656
|
- File bytes are served only by the explorer's `asset` operation, after the deny rules and the document admission, inline only for raster images, audio, video and PDF, always with `nosniff` and a `same-origin` resource policy, and with a sandboxing policy except for PDF, under which inline audio and video keep the URL's origin (`allow-same-origin`, no `allow-scripts`) (see [Serving files](#serving-files)).
|
|
650
|
-
-
|
|
657
|
+
- A Markdown document's source (the Source toggle) is read only by the explorer's `text` operation, through the same `asset` port after the same deny rules and admission, so it serves nothing the reader could not already download: at most `textMaxBytes` of the file's beginning, decoded as UTF-8 into JSON, which the browser shows as text and never interprets.
|
|
658
|
+
- Data responses are `private, no-store` JSON with `nosniff`, a sandboxing content security policy and `same-origin` resource policy, and the data route refuses React Router's single-fetch requests (`.data`), whose answers would carry none of those headers; the tree refresh, and a document request marked as triggered by a refresh (`X-Markdown-Explorer: refresh`, which makes the host skip its caches), require the custom request header and pass the shared cross-origin check of server routes (`@aiquants/request-isolation`).
|
|
651
659
|
- Link cards are read by `@aiquants/markdown`'s handler behind a read-only authentication (no token refresh, no `Set-Cookie`; an authentication that carries headers is refused and logged), and its guards keep every internal address from becoming a card; see [Link cards](#link-cards).
|
|
652
660
|
- Each data response carries an opaque, pseudonymous scope (an HMAC of the principal key under `scopeSecret`); when it changes, the browser drops every cache and remembered path. Browser storage is also checked against the page's scope on every page load, before anything reads it.
|
|
653
661
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as f, jsxs as O, Fragment as Ge } from "react/jsx-runtime";
|
|
2
|
-
import { u as D, F as Nt, d as Oe, f as Ye, g as kt, E as Lt, h as Ot, i as Pt, j as At, k as qt } from "./index-
|
|
2
|
+
import { u as D, F as Nt, d as Oe, f as Ye, g as kt, E as Lt, h as Ot, i as Pt, j as At, k as qt } from "./index-gJp1iXTc.js";
|
|
3
3
|
import * as m from "react";
|
|
4
4
|
import { use as Ee, createContext as Pe, useState as q, useCallback as w, useMemo as F, useRef as g, useLayoutEffect as I, useEffect as _, useSyncExternalStore as be, Suspense as Qe, useId as ye } from "react";
|
|
5
|
-
import { C as Ct, k as Ft, l as Je, v as Mt, m as _t, n as It, E as Dt, o as Be, q as Ht, s as Zt, S as ve, t as $t, F as Bt, A as zt } from "./location-
|
|
5
|
+
import { C as Ct, k as Ft, l as Je, v as Mt, m as _t, n as It, E as Dt, o as Be, q as Ht, s as Zt, S as ve, t as $t, F as Bt, A as zt } from "./location-CtM94G0O.js";
|
|
6
6
|
import { useDirectoryTreeState as Vt, DirectoryTree as jt } from "@aiquants/directory-tree";
|
|
7
7
|
import { T as Kt } from "./tapScrollCircle-u4EXeLhx.js";
|
|
8
8
|
import { s as Ut } from "./storage-DA4ItHzl.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const c=require("react/jsx-runtime"),C=require("./index-Cie6WPiM.cjs"),r=require("react"),O=require("./location-CSIhx-L4.cjs"),Ie=require("@aiquants/directory-tree"),ft=require("./tapScrollCircle-C5DGI-0H.cjs"),mt=require("./storage-Bkb2Axdi.cjs"),pe=require("@aiquants/resize-panels"),pt=require("react-router");function ht(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=ht(r);function xt({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 wt=p.forwardRef(xt);function gt({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 Et=p.forwardRef(gt);function bt({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 vt=p.forwardRef(bt);function Rt({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 yt=p.forwardRef(Rt),St=()=>{const{notices:e}=C.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function kt({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(kt),ve=r.createContext(!0),De="\0loop\0",He="\0",Tt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(h=>{const x=d(h,l,i);return x!==h&&(f=!0),x});if(!f)return o;const u=n.get(o);return u!==void 0&&u.length===m.length&&u.every((h,x)=>h===m[x])?u:(n.set(o,m),m)},d=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",u=m?f.entries:o.children;if(u===void 0)return o;i.add(o.path);const h=s(u,l,i);if(i.delete(o.path),!m&&h===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===h)return x.grafted;const g={...o,children:h,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:h,grafted:g}),g};return(o,l)=>s(o,l,new Set)},Lt=(e,t)=>`${De}${e}${He}${t}`,ie=e=>e.startsWith(De),jt=e=>e.slice(e.lastIndexOf(He)+1),ne="data-aqmx-path",Nt=(e,t,n,a,s)=>{const d={aqmxPath:e.path};return n&&(d.aqmxOpen=!0),(a==="loading"||a==="failed")&&(d.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:d}},Pt=(e,t,n,a)=>{const s=Lt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},Ot=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(h=>h.type==="loop"?d(h,i,f):o(h,i)),u=n.get(l);return u!==void 0&&u.length===m.length&&u.every((h,x)=>h===m[x])?u:(n.set(l,m),m)},d=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const u=Pt(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:u,parentKey:f,loopFolderName:i.loopFolderName}),u},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),u=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,h=u==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===u&&x.children===f&&x.renderFailedFolder===h)return x.row;const g=Nt(l,f,m,u,h===void 0?void 0:h(l));return e.set(l,{row:g,open:m,childrenStatus:u,children:f,renderFailedFolder:h}),g};return(l,i)=>s(l,i,"")},Mt=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))},be=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},qt=(e,t)=>{const n=new Map;let a=0;const s=d=>{for(const o of be(d,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},At=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},Ze=(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:Ze(n.children,t);if(a!==null)return a}return null},Ft=(e,t,n,a)=>{let s=e;for(const d of t){const o=s.find(l=>l.type==="directory"&&l.path===d);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(d=>d.type==="file"&&d.path===n)?"ready":"missing"},Oe=new Set,_t=(e,t)=>e.has(t)?e:new Set(e).add(t),It=(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)))},Dt=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Ht=()=>{const[e,t]=r.useState(Oe),n=r.useCallback(o=>t(l=>_t(l,o)),[]),a=r.useCallback(o=>t(l=>It(l,o)),[]),s=r.useCallback(o=>t(l=>Dt(l,o)),[]),d=r.useCallback(()=>t(Oe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:d}),[e,n,a,s,d])},Zt=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),$t=(e,t)=>{const n=[];let a=be(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const d=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===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(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&d.push(...be(o.children,t.compare))}a=d}return n},$e=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||$e(n.children,t))),Bt=(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:$e(t.entries,t.isShownExpanded)}},Ee=Object.freeze({state:"idle"}),zt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(Ee);r.useLayoutEffect(()=>{n.current=e});const d=r.useCallback(()=>{t.current===null&&(t.current=Zt(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(Ee)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=$t(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const h=Bt(f,i);s(h.kind==="done"?Ee:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:u}=f;s(h=>h.state==="running"&&h.opened===u?h:{state:"running",opened:u})},[]);return r.useMemo(()=>({status:a,start:d,end:o,advance:l}),[a,d,o,l])},Me=["pointerdown","wheel","touchstart","keydown","focusin"],Vt=8,qe={least:Number.POSITIVE_INFINITY,stalled:0},Kt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:d,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(qe),u=r.useRef(null),h=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const b=r.useCallback(()=>{const L=u.current;L!==null&&(u.current=null,L.phase==="asking"?L.controller.abort():x.current?.open(null))},[]),y=r.useCallback(()=>{i.current=null,b()},[b]),P=r.useCallback(()=>{const L=t.current;i.current===null||h.current!==null||L===null||L.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const E=i.current;if(E===null)return;const R=g.current(E);if(R===0){f.current=!0,u.current?.phase==="opening"&&b();return}if(e.current?.scrollToPath(E,{align:"nearest"})===!0){u.current?.phase==="opening"&&b();const{least:j,stalled:q}=m.current;m.current=R<j?{least:R,stalled:0}:{least:j,stalled:q+1},m.current.stalled<Vt&&P();return}const v=u.current;if(v===null){i.current=null;return}v.phase==="opening"&&x.current?.progress(v.folders,E)!=="loading"&&y()}))},[e,t,b,y]),S=r.useCallback(()=>{f.current=!1,m.current=qe,P()},[P]);r.useEffect(()=>{const L=t.current;if(L===null)return;const E=typeof ResizeObserver>"u"?null:new ResizeObserver(S);E?.observe(L);for(const R of Me)L.addEventListener(R,y,{passive:!0});return()=>{E?.disconnect();for(const R of Me)L.removeEventListener(R,y);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,b()}},[t,S,y,b]);const T=a!==null;r.useEffect(()=>{const L=t.current;if(y(),n===null||L===null||L.contains(L.ownerDocument.activeElement))return;i.current=n;const E=x.current;if(T&&E!==null){const R=new AbortController,v={phase:"asking",controller:R};u.current=v,E.ancestors(n,R.signal).then(j=>{u.current===v&&(j===null?u.current=null:(u.current={phase:"opening",folders:j},x.current?.open(j)),S())})}S()},[n,T,t,y,S]),r.useEffect(()=>{(u.current?.phase==="opening"||i.current!==null&&!f.current)&&S()},[s,S]);const F=r.useRef(d);r.useEffect(()=>{F.current!==d&&(F.current=d,y())},[d,y]);const M=r.useRef(o);r.useEffect(()=>{M.current&&!o&&b(),M.current=o},[o,b])},Xt="--aqmx-tree-line",Wt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Ut="data-aqmx-tree-probe",Gt=Object.freeze({rowHeight:O.CONTROL_BLOCK_PIXELS,lineColor:null}),Yt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Qt=e=>{const t=Yt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Jt=(e,t)=>{const[n,a]=r.useState(Gt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const d=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Xt).trim()===""?null:Qt(f.color);a(u=>{const h=Number.isFinite(i)&&i>0?i:u.rowHeight;return u.rowHeight===h&&u.lineColor===m?u:{rowHeight:h,lineColor:m}})};d();const o=Wt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",d);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",d);l?.disconnect()}},[e,t]),n},Be="markdown-explorer-tree-scroll",en=.5,ze=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),tn=(e,t)=>{const n=ze(e,t),a=n?.closest(`[data-testid="${Be}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),d=n.getBoundingClientRect(),o=s.top-d.top,l=d.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,d.bottom-s.bottom);return l<=en?0:l},nn={testId:Be,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:ft.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},rn={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},an={color:"inherit"},ln={paddingBlock:0},on=new Set,sn=new Map,cn={color:"var(--aqmx-tree-line)"},un=e=>{const t=e instanceof Element?e.closest(`[${ne}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},Ve=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),dn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):Ve(e,t,n.kind,n.opened),Ke=()=>{const{labels:e}=C.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},fn=()=>{const{labels:e}=C.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Ct,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},mn=({name:e,onRetry:t})=>{const{labels:n}=C.useExplorer(),a=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const d=s.currentTarget,o=d.ownerDocument.activeElement===d?d.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&C.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(C.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},pn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:d,openPaths:o,selection:l,onOpenDocument:i,onRevealSource:f,expansion:m,onShown:u,marks:h,claimsHeld:x,expandAll:g,revealCancel:b})=>{const{trees:y,documents:P,labels:S,locale:T,theme:F,data:M,config:L,sources:E,reveals:R}=C.useExplorer(),v=r.use(ve),[j]=r.useState(Ot),q=r.useRef(null),{rowHeight:le,lineColor:z}=Jt(q,F),{isExpanded:_,toggle:U,expandMultiple:Z,collapseMultiple:J,expanded:D,isPending:ee}=m,{alwaysExpanded:V,sortMode:A,folderPlacement:$}=s,{direct:oe,markDirect:B,unmarkDirect:re,pruneDirect:se}=h,{running:te,advance:ue}=g,ce=r.useRef(null),G=r.useRef(null),k=r.useMemo(()=>O.createEntryComparator({sortMode:A,folderPlacement:$}),[A,$]),K=r.useMemo(()=>Mt(k),[k]),I=r.useCallback(w=>y.children(a,w),[y,a]),Y=r.useMemo(()=>At(e),[e]),Q=r.useCallback(w=>!ie(w)&&(_(w)||V&&!Y.has(w)),[_,V,Y]),X=r.useRef({shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I});r.useLayoutEffect(()=>{X.current={shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I}},[Q,_,Y,e,I]);const ke=r.useCallback(w=>{ce.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const N=G.current,H=N===null?void 0:ze(N,w);H!==void 0&&C.focusWithoutScroll(H)})},[]),et=r.useCallback(w=>{if(ie(w)){ke(jt(w));return}X.current.isExpanded(w)?re([w]):X.current.unloadedFolders.has(w)&&B(w),U(w)},[ke,B,re,U]),xe=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(re(N),J(N))},[re,J]),tt=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(N.length<w.length&&N.every(H=>X.current.shownExpanded(H))?xe(N):Z(N))},[Z,xe]),Ce=r.useCallback(w=>c.jsx(mn,{name:w.name,onRetry:()=>{B(w.path),y.retryChildren(a,w.path),X.current.shownExpanded(w.path)||Z([w.path])}}),[y,a,B,Z]),Te=n==="multi"?o:on,{loopFolderName:Le}=S,nt=r.useMemo(()=>j(e,{openPaths:Te,childrenOf:I,renderFailedFolder:Ce,loopFolderName:Le}),[j,e,Te,I,Ce,Le,t]),rt=C.useIntentPrefetch(P,un),je=r.useRef([]),de=r.useCallback(()=>{for(const w of je.current)X.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:we}=L.revealDocument,Ne=r.useRef(f);r.useLayoutEffect(()=>{Ne.current=f},[f]);const at=r.useMemo(()=>({ancestors:async(w,N)=>{const H=R.take(a,w);if(H!==null)return H;if(!R.mayMove(w)){const ae=await M.ancestors(a,w,N);return ae.status!=="ok"||ae.ancestors===null||ae.ancestors.length>we?null:ae.ancestors}const W=await M.reveal(a,w,N);return W.status!=="ok"||W.source===null||W.ancestors.length>we?null:W.source===a?W.ancestors:(N.aborted||!E.some(ae=>ae.id===W.source)||(R.move(W.source,w,W.ancestors),Ne.current(W.source)),null)},open:w=>{je.current=w??[],w!==null&&(de(),Z([...w]))},progress:(w,N)=>Ft(X.current.entries,w,N,{isShownExpanded:X.current.shownExpanded,childrenOf:X.current.childrenOf})}),[M,a,E,R,we,de,Z]);r.useEffect(()=>de(),[de,Y]);const lt=r.useMemo(()=>[e,t,D],[e,t,D]),ot=r.useCallback(w=>G.current===null?Number.POSITIVE_INFINITY:tn(G.current,w),[]);Kt({tree:ce,container:G,path:d.path,chain:d.openFolders?at:null,rows:lt,cancel:b,displayed:v,placement:ot});const Pe=r.useCallback(w=>oe.has(w),[oe]),fe=r.useMemo(()=>qt(e,{isShownExpanded:Q,childrenOf:I,compare:k,isDirect:Pe}),[e,Q,I,k,Pe,t]),me=v&&x;r.useLayoutEffect(()=>{u(e)},[e,u]),r.useLayoutEffect(()=>()=>u(null),[u]),r.useEffect(()=>y.claimChildren(a,me?fe.folders:sn),[y,a,me,fe]),r.useEffect(()=>se(Y),[se,Y]),r.useEffect(()=>{me&&te&&ue({entries:e,isShownExpanded:Q,childrenOf:I,compare:k,expanded:D,waiting:fe.waiting,expansionPending:ee})},[me,te,ue,e,Q,I,k,D,fe,ee]);const st=r.useCallback(w=>{w.isDirectory||(R.settle(w.entry.absolutePath),i(w.entry.absolutePath))},[R,i]),{onChange:ge}=l,ct=r.useMemo(()=>ge===null?void 0:(w,N)=>{ie(w.absolutePath)||ge({path:w.absolutePath,name:w.name,selected:N})},[ge]),it=r.useMemo(()=>new Set(l.items),[l.items]),ut=r.useMemo(()=>({entryKindDirectory:S.treeEntryKindDirectory,entryKindFile:S.treeEntryKindFile,scrollUp:S.treeScrollUp,scrollDown:S.treeScrollDown,scrollToTop:S.treeScrollToTop,scrollToBottom:S.treeScrollToBottom}),[S]),dt=z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:z};return c.jsxs("div",{ref:G,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...rt,children:[c.jsx("span",{ref:q,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Ut]:""}),c.jsx(Ie.DirectoryTree,{ref:ce,entries:nt,expansion:{toggle:et,isExpanded:Q,expandMultiple:tt,collapseMultiple:xe,isPending:ee&&!te,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:it,onEntryClick:st,onSelectionChange:ct},visual:{className:"aqmx-explorer-tree-view",ariaLabel:S.treeRegion,...dt,showExpandIcons:s.expandIcons,expandIconStyle:cn,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:le,removeRootIndent:s.removeRootIndent,highlightStyles:rn,entryStyle:ln,nameStyle:an},virtualScroll:nn,sort:K,locale:T,labels:ut})]})},hn=({pending:e,status:t})=>{const{labels:n}=C.useExplorer(),a=t.state!=="running",[s,d]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){d(0);return}if(e>0){d(e);return}if(s===0)return;const f=setTimeout(()=>d(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(C.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},xn=({stop:e,opened:t,budget:n})=>{const{labels:a}=C.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:Ve(a,n,e,t)})},wn=({entries:e,...t})=>{const{trees:n}=C.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[d]=r.useState(Tt),o=r.useMemo(()=>d(e,l=>n.children(s,l)),[d,e,n,s,a]);return o.length===0?c.jsx(fn,{}):c.jsx(pn,{entries:o,version:a,...t})},gn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=C.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(Ke,{});if(s.status==="ok")return c.jsx(wn,{entries:s.entries,...n});const d=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:d!==void 0?d:c.jsx(C.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},En=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:d,config:o}=C.useExplorer(),{sourceId:l}=t,i=Ie.useDirectoryTreeState({storageKey:mt.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const u=Ht(),{expanded:h,expandMultiple:x,collapseAll:g}=i,[b,y]=r.useState(null),P=b!==h,S=r.useRef(h);r.useLayoutEffect(()=>{S.current=h},[h]);const T=o.expandAll,F=r.useCallback(()=>d.announce(s.expandAllStarted),[d,s]),M=r.useCallback(A=>d.announce(dn(s,T,A)),[d,s,T]),L=zt({budget:T,expandMultiple:x,onStart:F,onFinish:M}),{status:E,start:R,end:v,advance:j}=L,q=E.state==="running",le=r.useMemo(()=>({running:q,advance:j}),[q,j]),z=r.useRef(null),[_,U]=r.useState(!1),Z=r.useCallback(A=>{z.current=A,U(A!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(A=>{const $=A.sourceId===l&&z.current!==null?Ze(z.current,A.path):null;$!==null&&d.announce({list:s.foldersLoadFailedNamed,item:$.name})}),[n,l,d,s]);const{clearDirect:J}=u,[D,ee]=r.useState(0),V=r.useCallback(()=>{ee(A=>A+1),v(),J(),y(S.current),g()},[v,J,g]);return r.useEffect(()=>{e({collapseAll:V,expandAll:_?R:null,expanding:q})},[e,V,R,_,q]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{_||v()},[_,v]),c.jsxs(c.Fragment,{children:[E.state==="stopped"?c.jsx(xn,{stop:E.stop,opened:E.opened,budget:T}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(Ke,{}),children:c.jsx(gn,{result:f,onRetry:m,expansion:i,onShown:Z,marks:u,claimsHeld:P,expandAll:le,revealCancel:D,...t})}),c.jsx(hn,{pending:n.pendingChildren(l),status:E})]})]})};function bn({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 Xe=p.forwardRef(bn),Ae="markdown-explorer-selection-remove",vn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:d}=C.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(u,h)=>{if(h.ownerDocument.activeElement===h){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${Ae}"]`)],g=x.indexOf(h),b=[x[g+1],x[g-1]].find(y=>y!==void 0);b===void 0?s():b.focus()}t(u)},m=()=>{const u=l.current;u!==null&&u.contains(u.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:d.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:d.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([u,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:u,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":d.removeFromSelection(h),title:d.removeFromSelection(h),"data-testid":Ae,"data-aqmx-path":u,onClick:x=>f(u,x.currentTarget),children:c.jsx(Xe,{"aria-hidden":"true"})})]},u))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([u])=>u)),children:d.openSelectionInMulti(i.length)})]})},he=new Map,Rn=(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},yn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},We=r.createContext(null),Sn=e=>{const t=r.use(We);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};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:"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 Cn=p.forwardRef(kn);function Tn({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 Ln=p.forwardRef(Tn);function jn({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 Nn=p.forwardRef(jn);function Pn({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 On=p.forwardRef(Pn);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 qn=p.forwardRef(Mn);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:"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 Fn=p.forwardRef(An);function _n({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 In=p.forwardRef(_n);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:"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 Hn=p.forwardRef(Dn);function Zn({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:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),p.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const $n=p.forwardRef(Zn);function Bn({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 zn=p.forwardRef(Bn);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.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 Kn=p.forwardRef(Vn);function Xn({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 Wn=p.forwardRef(Xn);function Un({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 Gn=p.forwardRef(Un),Re=e=>{e.preventDefault(),e.stopPropagation()},Yn=Object.freeze({sortMode:Ln,folderPlacement:zn,selectionMode:Nn,doubleClickAction:In,expandIconSize:Wn,alwaysExpanded:Cn,revealDocument:$n,removeRootIndent:On,lines:Gn,expandIcons:qn,directoryIcons:Kn,fileIcons:Hn}),Ue=(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},Qn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:d})=>{const{labels:o}=C.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const u=n.length;l.current[(m%u+u)%u]?.focus()},[n.length]),f=r.useCallback((m,u)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(u+1);break;case"ArrowUp":m.preventDefault(),i(u-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":Re(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:d,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,u)=>{const h=Yn[m.key],x=Ue(o,m),g=O.formatTreeSettingValue(o,t,m.key),b=t[m.key],y=typeof b=="boolean"?{role:"menuitemcheckbox","aria-checked":b,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:P=>{l.current[u]=P},type:"button",tabIndex:-1,...y,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:P=>f(P,u),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},Jn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=C.useExplorer(),[d,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),u=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!d)return;const g=b=>{b.target instanceof Node&&(l.current?.contains(b.target)===!0||i.current?.contains(b.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[d]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!d||(Re(g),u())},[d,u]),x=r.useCallback(g=>{const b=n(g.key);s.announce(a.settingAnnouncement(Ue(a,g),O.formatTreeSettingValue(a,b,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:h,children:c.jsx(Fn,{"aria-hidden":"true"})}),menu:d?c.jsx(Qn,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:u}):null}},er=()=>{const{treeSettings:e}=C.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Fe=new Set,tr='[role="tree"] [role="treeitem"][tabindex="0"]',nr="[data-directory-tree-tab-stop]",rr=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:d,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:u,documents:h,announcer:x,reveals:g}=C.useExplorer(),{settings:b,advance:y}=er(),P=r.useMemo(()=>O.visibleTreeSettingDescriptors(t==="tree"),[t]),S=t==="tree"&&b.selectionMode==="multiple";Sn(S);const T=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,M=e.mode==="tree"&&S?e.tray.gathered:he,L=r.useCallback(k=>{const K=y(k);return K.selectionMode!=="multiple"&&T?.(he),K},[y,T]),E=Jn({settings:b,descriptors:P,onAdvance:L}),R=r.useCallback(k=>T?.(K=>Rn(K,k)),[T]),v=r.useCallback(k=>T?.(K=>yn(K,k)),[T]),j=r.useCallback(()=>T?.(he),[T]),q=r.useRef(null),le=r.useCallback(()=>{const k=q.current;if(k===null)return;[tr,nr,'[data-testid="markdown-explorer-tree-settings"]'].map(I=>k.querySelector(I)).find(I=>I!==null)?.focus()},[]),z=r.useMemo(()=>new Set(M.keys()),[M]),_=r.useMemo(()=>a===null?Fe:new Set([a]),[a]),U=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(b.selectionMode){case"single":return{mode:"single",items:_,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:z,shownPath:a,onChange:R};case"none":return{mode:"none",items:Fe,shownPath:null,onChange:null}}},[t,s,b.selectionMode,_,a,z,R]),Z=r.useMemo(()=>b.revealDocument?{path:a,openFolders:!0}:{path:U.shownPath,openFolders:!1},[b.revealDocument,a,U.shownPath]),J=r.useCallback(k=>{a!==null&&g.settle(a),o(k)},[a,g,o]),[D,ee]=r.useState(null),[V,A]=r.useState(!1),[$,oe]=r.useState(null),B=r.useRef(!1),re=r.useCallback(async()=>{if(!B.current){B.current=!0,A(!0),oe(null);try{const k=await u.refresh(n);if(k.status==="superseded")return;h.invalidate(),k.status==="failed"?oe({sourceId:n,failure:k.failure}):x.announce(f.treeRefreshed)}finally{B.current=!1,A(!1)}}},[u,h,n,x,f]),se=D===null?null:D.expandAll,te=D?.expanding===!0,ue=m.find(k=>k.id===n),ce=i.target==="multi"?yt:vt,G=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:q,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ue?.label,value:n,onChange:k=>J(k.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(k=>c.jsx("option",{value:k.id,children:k.label},k.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(C.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":G,title:G,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ce,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":V,"aria-busy":V,"data-aqmx-busy":V?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{re()},children:[c.jsx(C.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":se===null||te,"aria-busy":te,"data-aqmx-busy":te?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>se?.(),children:c.jsx(Et,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":D===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>D?.collapseAll(),children:c.jsx(wt,{"aria-hidden":"true"})}),E.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[$!==null&&$.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":$.failure.reason,children:f.treeRefreshFailed(C.failureTitleOf(f,$.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(St,{})}),c.jsx(En,{mode:t,sourceId:n,settings:b,reveal:Z,openPaths:s,selection:U,onOpenDocument:d,onRevealSource:l,onControls:ee},n),S&&M.size>0?c.jsx(vn,{selection:M,onRemove:v,onClear:j,onOpenSelection:F,onLeave:le}):null,E.menu]})]})},Ge="(pointer: coarse)",ar=e=>{const t=window.matchMedia(Ge);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},lr=()=>window.matchMedia(Ge).matches,or=()=>!1,sr=()=>r.useSyncExternalStore(ar,lr,or);function cr({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 ir=p.forwardRef(cr),ur=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:d}=C.useExplorer(),o=pt.useLocation(),{location:l}=C.useExplorerLocation(),[i,f]=r.useState(!1),[m,u]=r.useState({navigated:o,source:l.source}),[h,x]=r.useState(!1);m.navigated!==o&&(u({navigated:o,source:l.source}),m.source===l.source&&!h&&f(!1));const[g,b]=r.useState(s);g!==s&&(b(s),f(!1));const y=r.useRef(null),P=r.useRef(null),S=r.useRef(null),T=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const v=y.current;v!==null&&(i&&!v.open?(v.showModal(),P.current?.focus()):!i&&v.open&&(v.close(),t.current?.focus()),a(i?S.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const M=r.useCallback(v=>{v.key!=="Escape"||v.defaultPrevented||(Re(v),f(!1))},[]),L=r.useCallback(v=>{T.current=v.target===v.currentTarget},[]),E=r.useCallback(v=>{const j=T.current;T.current=!1,j&&v.target===v.currentTarget&&f(!1)},[]),R=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(ir,{"aria-hidden":"true"}),c.jsx("span",{children:d.showExplorer})]})}),c.jsx("dialog",{ref:y,id:F,className:"aqmx-sheet","aria-label":d.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:M,onPointerDown:L,onClick:E,onClose:R,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:S,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:P,type:"button",className:"aqmx-sheet-close","aria-label":d.hideExplorer,title:d.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Xe,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ve,{value:i,children:c.jsx(We,{value:x,children:e})})}),c.jsx(C.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Ye=r.createContext(null),ye="aqmx-explorer",Qe="aqmx-content",Se='[role="tree"] [role="treeitem"]',dr=`${Se}[tabindex="0"]`,fr="[data-directory-tree-tab-stop]",mr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${ye}"] ${Se}`))if(n.getAttribute(ne)===t)return n;return null},_e=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:O.ASSUMED_ROOT_FONT_PIXELS}),pr=(e,t)=>{const[n,a]=r.useState(()=>_e(0,0));return r.useLayoutEffect(()=>{const s=e.current,d=t.current;if(s===null||d===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:d.getBoundingClientRect().width},l=()=>{const f=_e(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[u]=m.borderBoxSize;u!==void 0&&(m.target===s&&(o.frame=u.inlineSize),m.target===d&&(o.rem=u.inlineSize))}l()});return i.observe(s),i.observe(d),()=>i.disconnect()},[e,t]),n},Je=e=>`aqmx-split-handle-${e}`,hr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),d=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=u=>{const h=u.target instanceof Element?u.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Qe}"]`)===null,!o.current&&(d.current=h?.closest(`${Se}[${ne}]`)?.getAttribute(ne)??null)},m=u=>{u.relatedTarget instanceof Node&&!i.contains(u.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:u,body:h}=i.ownerDocument;if(u!==null&&u!==h)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=d.current,u=`[data-panel-id="${ye}"]`;f([m===null?null:mr(i,m),i.querySelector(`${u} ${dr}`),i.querySelector(`${u} ${fr}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},xr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:d})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:u,rootFontPixels:h}=pr(o,f),x=u!==null&&u<O.explorerSheetBelowPixels(h);return hr(x,{frameRef:o,sheetToggleRef:m,handleId:Je(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(ur,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Ye,{value:x?l:null,children:c.jsx(wr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:d,explorerMinPixels:O.explorerMinPixels(h)})})]})},wr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:d,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=C.useExplorer(),m=C.useViewSetting(E=>e==="tree"?E.treeExplorer:E.multiExplorer)??(e==="tree"?O.EXPLORER_DEFAULT_PERCENT:O.EXPLORER_MULTI_DEFAULT_PERCENT),u=r.useRef(null),h=r.useRef(null),x=r.useRef(!1),g=r.useRef(!1),[b,y]=r.useState(!1),P=r.useRef(d);r.useLayoutEffect(()=>{P.current=d},[d]);const S=r.useCallback(()=>{const E=u.current;if(E===null||E.length!==2)return;const[R=0,v=0]=E,j=R+v;if(j<=0||R<=0)return;const q=Math.min(O.EXPLORER_MAX_PERCENT,R/j*100);l.update(e==="tree"?{treeExplorer:q}:{multiExplorer:q})},[l,e]),T=r.useCallback(()=>{h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,S()},O.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[S]);r.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current),g.current&&P.current?.(!1)},[]);const F=sr(),M=r.useCallback((E,R)=>{u.current=E;const[v=0,j=0]=E;E.length===2&&j>0&&y(v<=0),R.source==="keyboard"?T():R.source==="pointer"&&(x.current=!0)},[T]),L=r.useCallback(E=>{if(g.current=E,d?.(E),E){x.current=!1;return}x.current&&(x.current=!1,T())},[d,T]);return c.jsxs(pe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:M,className:"aqmx-split","data-aqmx-split":e,children:[t?null:c.jsx(pe.Panel,{id:ye,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:O.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ve,{value:!b,children:n})}),t?null:c.jsx(pe.PanelResizeHandle,{id:Je(e),thickness:F?O.COARSE_TARGET_PIXELS:O.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:O.SPLIT_HANDLE_PIXELS.gripThickness,length:O.SPLIT_HANDLE_PIXELS.gripLength,barThickness:O.SPLIT_HANDLE_PIXELS.barThickness,barLength:O.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:L,inert:s,className:"aqmx-split-handle"}),c.jsx(pe.Panel,{id:Qe,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=he;exports.ExplorerPane=rr;exports.ExplorerSplit=xr;exports.SheetNoticeSlotContext=Ye;
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),C=require("./index-B3nShkkt.cjs"),r=require("react"),O=require("./location-FavgY_gB.cjs"),Ie=require("@aiquants/directory-tree"),ft=require("./tapScrollCircle-C5DGI-0H.cjs"),mt=require("./storage-Bkb2Axdi.cjs"),pe=require("@aiquants/resize-panels"),pt=require("react-router");function ht(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=ht(r);function xt({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 wt=p.forwardRef(xt);function gt({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 Et=p.forwardRef(gt);function bt({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 vt=p.forwardRef(bt);function Rt({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 yt=p.forwardRef(Rt),St=()=>{const{notices:e}=C.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function kt({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(kt),ve=r.createContext(!0),De="\0loop\0",He="\0",Tt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(h=>{const x=d(h,l,i);return x!==h&&(f=!0),x});if(!f)return o;const u=n.get(o);return u!==void 0&&u.length===m.length&&u.every((h,x)=>h===m[x])?u:(n.set(o,m),m)},d=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",u=m?f.entries:o.children;if(u===void 0)return o;i.add(o.path);const h=s(u,l,i);if(i.delete(o.path),!m&&h===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===h)return x.grafted;const g={...o,children:h,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:h,grafted:g}),g};return(o,l)=>s(o,l,new Set)},Lt=(e,t)=>`${De}${e}${He}${t}`,ie=e=>e.startsWith(De),jt=e=>e.slice(e.lastIndexOf(He)+1),ne="data-aqmx-path",Nt=(e,t,n,a,s)=>{const d={aqmxPath:e.path};return n&&(d.aqmxOpen=!0),(a==="loading"||a==="failed")&&(d.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:d}},Pt=(e,t,n,a)=>{const s=Lt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},Ot=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(h=>h.type==="loop"?d(h,i,f):o(h,i)),u=n.get(l);return u!==void 0&&u.length===m.length&&u.every((h,x)=>h===m[x])?u:(n.set(l,m),m)},d=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const u=Pt(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:u,parentKey:f,loopFolderName:i.loopFolderName}),u},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),u=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,h=u==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===u&&x.children===f&&x.renderFailedFolder===h)return x.row;const g=Nt(l,f,m,u,h===void 0?void 0:h(l));return e.set(l,{row:g,open:m,childrenStatus:u,children:f,renderFailedFolder:h}),g};return(l,i)=>s(l,i,"")},Mt=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))},be=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},qt=(e,t)=>{const n=new Map;let a=0;const s=d=>{for(const o of be(d,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},At=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},Ze=(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:Ze(n.children,t);if(a!==null)return a}return null},Ft=(e,t,n,a)=>{let s=e;for(const d of t){const o=s.find(l=>l.type==="directory"&&l.path===d);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(d=>d.type==="file"&&d.path===n)?"ready":"missing"},Oe=new Set,_t=(e,t)=>e.has(t)?e:new Set(e).add(t),It=(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)))},Dt=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Ht=()=>{const[e,t]=r.useState(Oe),n=r.useCallback(o=>t(l=>_t(l,o)),[]),a=r.useCallback(o=>t(l=>It(l,o)),[]),s=r.useCallback(o=>t(l=>Dt(l,o)),[]),d=r.useCallback(()=>t(Oe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:d}),[e,n,a,s,d])},Zt=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),$t=(e,t)=>{const n=[];let a=be(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const d=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===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(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&d.push(...be(o.children,t.compare))}a=d}return n},$e=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||$e(n.children,t))),Bt=(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:$e(t.entries,t.isShownExpanded)}},Ee=Object.freeze({state:"idle"}),zt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(Ee);r.useLayoutEffect(()=>{n.current=e});const d=r.useCallback(()=>{t.current===null&&(t.current=Zt(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(Ee)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=$t(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const h=Bt(f,i);s(h.kind==="done"?Ee:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:u}=f;s(h=>h.state==="running"&&h.opened===u?h:{state:"running",opened:u})},[]);return r.useMemo(()=>({status:a,start:d,end:o,advance:l}),[a,d,o,l])},Me=["pointerdown","wheel","touchstart","keydown","focusin"],Vt=8,qe={least:Number.POSITIVE_INFINITY,stalled:0},Kt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:d,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(qe),u=r.useRef(null),h=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const b=r.useCallback(()=>{const L=u.current;L!==null&&(u.current=null,L.phase==="asking"?L.controller.abort():x.current?.open(null))},[]),y=r.useCallback(()=>{i.current=null,b()},[b]),P=r.useCallback(()=>{const L=t.current;i.current===null||h.current!==null||L===null||L.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const E=i.current;if(E===null)return;const R=g.current(E);if(R===0){f.current=!0,u.current?.phase==="opening"&&b();return}if(e.current?.scrollToPath(E,{align:"nearest"})===!0){u.current?.phase==="opening"&&b();const{least:j,stalled:q}=m.current;m.current=R<j?{least:R,stalled:0}:{least:j,stalled:q+1},m.current.stalled<Vt&&P();return}const v=u.current;if(v===null){i.current=null;return}v.phase==="opening"&&x.current?.progress(v.folders,E)!=="loading"&&y()}))},[e,t,b,y]),S=r.useCallback(()=>{f.current=!1,m.current=qe,P()},[P]);r.useEffect(()=>{const L=t.current;if(L===null)return;const E=typeof ResizeObserver>"u"?null:new ResizeObserver(S);E?.observe(L);for(const R of Me)L.addEventListener(R,y,{passive:!0});return()=>{E?.disconnect();for(const R of Me)L.removeEventListener(R,y);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,b()}},[t,S,y,b]);const T=a!==null;r.useEffect(()=>{const L=t.current;if(y(),n===null||L===null||L.contains(L.ownerDocument.activeElement))return;i.current=n;const E=x.current;if(T&&E!==null){const R=new AbortController,v={phase:"asking",controller:R};u.current=v,E.ancestors(n,R.signal).then(j=>{u.current===v&&(j===null?u.current=null:(u.current={phase:"opening",folders:j},x.current?.open(j)),S())})}S()},[n,T,t,y,S]),r.useEffect(()=>{(u.current?.phase==="opening"||i.current!==null&&!f.current)&&S()},[s,S]);const F=r.useRef(d);r.useEffect(()=>{F.current!==d&&(F.current=d,y())},[d,y]);const M=r.useRef(o);r.useEffect(()=>{M.current&&!o&&b(),M.current=o},[o,b])},Xt="--aqmx-tree-line",Wt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Ut="data-aqmx-tree-probe",Gt=Object.freeze({rowHeight:O.CONTROL_BLOCK_PIXELS,lineColor:null}),Yt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Qt=e=>{const t=Yt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Jt=(e,t)=>{const[n,a]=r.useState(Gt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const d=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Xt).trim()===""?null:Qt(f.color);a(u=>{const h=Number.isFinite(i)&&i>0?i:u.rowHeight;return u.rowHeight===h&&u.lineColor===m?u:{rowHeight:h,lineColor:m}})};d();const o=Wt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",d);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",d);l?.disconnect()}},[e,t]),n},Be="markdown-explorer-tree-scroll",en=.5,ze=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),tn=(e,t)=>{const n=ze(e,t),a=n?.closest(`[data-testid="${Be}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),d=n.getBoundingClientRect(),o=s.top-d.top,l=d.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,d.bottom-s.bottom);return l<=en?0:l},nn={testId:Be,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:ft.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},rn={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},an={color:"inherit"},ln={paddingBlock:0},on=new Set,sn=new Map,cn={color:"var(--aqmx-tree-line)"},un=e=>{const t=e instanceof Element?e.closest(`[${ne}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},Ve=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),dn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):Ve(e,t,n.kind,n.opened),Ke=()=>{const{labels:e}=C.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},fn=()=>{const{labels:e}=C.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Ct,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},mn=({name:e,onRetry:t})=>{const{labels:n}=C.useExplorer(),a=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const d=s.currentTarget,o=d.ownerDocument.activeElement===d?d.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&C.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(C.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},pn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:d,openPaths:o,selection:l,onOpenDocument:i,onRevealSource:f,expansion:m,onShown:u,marks:h,claimsHeld:x,expandAll:g,revealCancel:b})=>{const{trees:y,documents:P,labels:S,locale:T,theme:F,data:M,config:L,sources:E,reveals:R}=C.useExplorer(),v=r.use(ve),[j]=r.useState(Ot),q=r.useRef(null),{rowHeight:le,lineColor:z}=Jt(q,F),{isExpanded:_,toggle:U,expandMultiple:Z,collapseMultiple:J,expanded:D,isPending:ee}=m,{alwaysExpanded:V,sortMode:A,folderPlacement:$}=s,{direct:oe,markDirect:B,unmarkDirect:re,pruneDirect:se}=h,{running:te,advance:ue}=g,ce=r.useRef(null),G=r.useRef(null),k=r.useMemo(()=>O.createEntryComparator({sortMode:A,folderPlacement:$}),[A,$]),K=r.useMemo(()=>Mt(k),[k]),I=r.useCallback(w=>y.children(a,w),[y,a]),Y=r.useMemo(()=>At(e),[e]),Q=r.useCallback(w=>!ie(w)&&(_(w)||V&&!Y.has(w)),[_,V,Y]),X=r.useRef({shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I});r.useLayoutEffect(()=>{X.current={shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I}},[Q,_,Y,e,I]);const ke=r.useCallback(w=>{ce.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const N=G.current,H=N===null?void 0:ze(N,w);H!==void 0&&C.focusWithoutScroll(H)})},[]),et=r.useCallback(w=>{if(ie(w)){ke(jt(w));return}X.current.isExpanded(w)?re([w]):X.current.unloadedFolders.has(w)&&B(w),U(w)},[ke,B,re,U]),xe=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(re(N),J(N))},[re,J]),tt=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(N.length<w.length&&N.every(H=>X.current.shownExpanded(H))?xe(N):Z(N))},[Z,xe]),Ce=r.useCallback(w=>c.jsx(mn,{name:w.name,onRetry:()=>{B(w.path),y.retryChildren(a,w.path),X.current.shownExpanded(w.path)||Z([w.path])}}),[y,a,B,Z]),Te=n==="multi"?o:on,{loopFolderName:Le}=S,nt=r.useMemo(()=>j(e,{openPaths:Te,childrenOf:I,renderFailedFolder:Ce,loopFolderName:Le}),[j,e,Te,I,Ce,Le,t]),rt=C.useIntentPrefetch(P,un),je=r.useRef([]),de=r.useCallback(()=>{for(const w of je.current)X.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:we}=L.revealDocument,Ne=r.useRef(f);r.useLayoutEffect(()=>{Ne.current=f},[f]);const at=r.useMemo(()=>({ancestors:async(w,N)=>{const H=R.take(a,w);if(H!==null)return H;if(!R.mayMove(w)){const ae=await M.ancestors(a,w,N);return ae.status!=="ok"||ae.ancestors===null||ae.ancestors.length>we?null:ae.ancestors}const W=await M.reveal(a,w,N);return W.status!=="ok"||W.source===null||W.ancestors.length>we?null:W.source===a?W.ancestors:(N.aborted||!E.some(ae=>ae.id===W.source)||(R.move(W.source,w,W.ancestors),Ne.current(W.source)),null)},open:w=>{je.current=w??[],w!==null&&(de(),Z([...w]))},progress:(w,N)=>Ft(X.current.entries,w,N,{isShownExpanded:X.current.shownExpanded,childrenOf:X.current.childrenOf})}),[M,a,E,R,we,de,Z]);r.useEffect(()=>de(),[de,Y]);const lt=r.useMemo(()=>[e,t,D],[e,t,D]),ot=r.useCallback(w=>G.current===null?Number.POSITIVE_INFINITY:tn(G.current,w),[]);Kt({tree:ce,container:G,path:d.path,chain:d.openFolders?at:null,rows:lt,cancel:b,displayed:v,placement:ot});const Pe=r.useCallback(w=>oe.has(w),[oe]),fe=r.useMemo(()=>qt(e,{isShownExpanded:Q,childrenOf:I,compare:k,isDirect:Pe}),[e,Q,I,k,Pe,t]),me=v&&x;r.useLayoutEffect(()=>{u(e)},[e,u]),r.useLayoutEffect(()=>()=>u(null),[u]),r.useEffect(()=>y.claimChildren(a,me?fe.folders:sn),[y,a,me,fe]),r.useEffect(()=>se(Y),[se,Y]),r.useEffect(()=>{me&&te&&ue({entries:e,isShownExpanded:Q,childrenOf:I,compare:k,expanded:D,waiting:fe.waiting,expansionPending:ee})},[me,te,ue,e,Q,I,k,D,fe,ee]);const st=r.useCallback(w=>{w.isDirectory||(R.settle(w.entry.absolutePath),i(w.entry.absolutePath))},[R,i]),{onChange:ge}=l,ct=r.useMemo(()=>ge===null?void 0:(w,N)=>{ie(w.absolutePath)||ge({path:w.absolutePath,name:w.name,selected:N})},[ge]),it=r.useMemo(()=>new Set(l.items),[l.items]),ut=r.useMemo(()=>({entryKindDirectory:S.treeEntryKindDirectory,entryKindFile:S.treeEntryKindFile,scrollUp:S.treeScrollUp,scrollDown:S.treeScrollDown,scrollToTop:S.treeScrollToTop,scrollToBottom:S.treeScrollToBottom}),[S]),dt=z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:z};return c.jsxs("div",{ref:G,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...rt,children:[c.jsx("span",{ref:q,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Ut]:""}),c.jsx(Ie.DirectoryTree,{ref:ce,entries:nt,expansion:{toggle:et,isExpanded:Q,expandMultiple:tt,collapseMultiple:xe,isPending:ee&&!te,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:it,onEntryClick:st,onSelectionChange:ct},visual:{className:"aqmx-explorer-tree-view",ariaLabel:S.treeRegion,...dt,showExpandIcons:s.expandIcons,expandIconStyle:cn,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:le,removeRootIndent:s.removeRootIndent,highlightStyles:rn,entryStyle:ln,nameStyle:an},virtualScroll:nn,sort:K,locale:T,labels:ut})]})},hn=({pending:e,status:t})=>{const{labels:n}=C.useExplorer(),a=t.state!=="running",[s,d]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){d(0);return}if(e>0){d(e);return}if(s===0)return;const f=setTimeout(()=>d(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(C.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},xn=({stop:e,opened:t,budget:n})=>{const{labels:a}=C.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:Ve(a,n,e,t)})},wn=({entries:e,...t})=>{const{trees:n}=C.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[d]=r.useState(Tt),o=r.useMemo(()=>d(e,l=>n.children(s,l)),[d,e,n,s,a]);return o.length===0?c.jsx(fn,{}):c.jsx(pn,{entries:o,version:a,...t})},gn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=C.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(Ke,{});if(s.status==="ok")return c.jsx(wn,{entries:s.entries,...n});const d=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:d!==void 0?d:c.jsx(C.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},En=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:d,config:o}=C.useExplorer(),{sourceId:l}=t,i=Ie.useDirectoryTreeState({storageKey:mt.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const u=Ht(),{expanded:h,expandMultiple:x,collapseAll:g}=i,[b,y]=r.useState(null),P=b!==h,S=r.useRef(h);r.useLayoutEffect(()=>{S.current=h},[h]);const T=o.expandAll,F=r.useCallback(()=>d.announce(s.expandAllStarted),[d,s]),M=r.useCallback(A=>d.announce(dn(s,T,A)),[d,s,T]),L=zt({budget:T,expandMultiple:x,onStart:F,onFinish:M}),{status:E,start:R,end:v,advance:j}=L,q=E.state==="running",le=r.useMemo(()=>({running:q,advance:j}),[q,j]),z=r.useRef(null),[_,U]=r.useState(!1),Z=r.useCallback(A=>{z.current=A,U(A!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(A=>{const $=A.sourceId===l&&z.current!==null?Ze(z.current,A.path):null;$!==null&&d.announce({list:s.foldersLoadFailedNamed,item:$.name})}),[n,l,d,s]);const{clearDirect:J}=u,[D,ee]=r.useState(0),V=r.useCallback(()=>{ee(A=>A+1),v(),J(),y(S.current),g()},[v,J,g]);return r.useEffect(()=>{e({collapseAll:V,expandAll:_?R:null,expanding:q})},[e,V,R,_,q]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{_||v()},[_,v]),c.jsxs(c.Fragment,{children:[E.state==="stopped"?c.jsx(xn,{stop:E.stop,opened:E.opened,budget:T}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(Ke,{}),children:c.jsx(gn,{result:f,onRetry:m,expansion:i,onShown:Z,marks:u,claimsHeld:P,expandAll:le,revealCancel:D,...t})}),c.jsx(hn,{pending:n.pendingChildren(l),status:E})]})]})};function bn({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 Xe=p.forwardRef(bn),Ae="markdown-explorer-selection-remove",vn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:d}=C.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(u,h)=>{if(h.ownerDocument.activeElement===h){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${Ae}"]`)],g=x.indexOf(h),b=[x[g+1],x[g-1]].find(y=>y!==void 0);b===void 0?s():b.focus()}t(u)},m=()=>{const u=l.current;u!==null&&u.contains(u.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:d.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:d.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([u,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:u,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":d.removeFromSelection(h),title:d.removeFromSelection(h),"data-testid":Ae,"data-aqmx-path":u,onClick:x=>f(u,x.currentTarget),children:c.jsx(Xe,{"aria-hidden":"true"})})]},u))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([u])=>u)),children:d.openSelectionInMulti(i.length)})]})},he=new Map,Rn=(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},yn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},We=r.createContext(null),Sn=e=>{const t=r.use(We);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};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:"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 Cn=p.forwardRef(kn);function Tn({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 Ln=p.forwardRef(Tn);function jn({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 Nn=p.forwardRef(jn);function Pn({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 On=p.forwardRef(Pn);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 qn=p.forwardRef(Mn);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:"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 Fn=p.forwardRef(An);function _n({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 In=p.forwardRef(_n);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:"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 Hn=p.forwardRef(Dn);function Zn({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:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),p.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const $n=p.forwardRef(Zn);function Bn({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 zn=p.forwardRef(Bn);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.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 Kn=p.forwardRef(Vn);function Xn({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 Wn=p.forwardRef(Xn);function Un({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 Gn=p.forwardRef(Un),Re=e=>{e.preventDefault(),e.stopPropagation()},Yn=Object.freeze({sortMode:Ln,folderPlacement:zn,selectionMode:Nn,doubleClickAction:In,expandIconSize:Wn,alwaysExpanded:Cn,revealDocument:$n,removeRootIndent:On,lines:Gn,expandIcons:qn,directoryIcons:Kn,fileIcons:Hn}),Ue=(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},Qn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:d})=>{const{labels:o}=C.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const u=n.length;l.current[(m%u+u)%u]?.focus()},[n.length]),f=r.useCallback((m,u)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(u+1);break;case"ArrowUp":m.preventDefault(),i(u-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":Re(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:d,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,u)=>{const h=Yn[m.key],x=Ue(o,m),g=O.formatTreeSettingValue(o,t,m.key),b=t[m.key],y=typeof b=="boolean"?{role:"menuitemcheckbox","aria-checked":b,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:P=>{l.current[u]=P},type:"button",tabIndex:-1,...y,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:P=>f(P,u),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},Jn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=C.useExplorer(),[d,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),u=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!d)return;const g=b=>{b.target instanceof Node&&(l.current?.contains(b.target)===!0||i.current?.contains(b.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[d]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!d||(Re(g),u())},[d,u]),x=r.useCallback(g=>{const b=n(g.key);s.announce(a.settingAnnouncement(Ue(a,g),O.formatTreeSettingValue(a,b,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:h,children:c.jsx(Fn,{"aria-hidden":"true"})}),menu:d?c.jsx(Qn,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:u}):null}},er=()=>{const{treeSettings:e}=C.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Fe=new Set,tr='[role="tree"] [role="treeitem"][tabindex="0"]',nr="[data-directory-tree-tab-stop]",rr=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:d,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:u,documents:h,announcer:x,reveals:g}=C.useExplorer(),{settings:b,advance:y}=er(),P=r.useMemo(()=>O.visibleTreeSettingDescriptors(t==="tree"),[t]),S=t==="tree"&&b.selectionMode==="multiple";Sn(S);const T=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,M=e.mode==="tree"&&S?e.tray.gathered:he,L=r.useCallback(k=>{const K=y(k);return K.selectionMode!=="multiple"&&T?.(he),K},[y,T]),E=Jn({settings:b,descriptors:P,onAdvance:L}),R=r.useCallback(k=>T?.(K=>Rn(K,k)),[T]),v=r.useCallback(k=>T?.(K=>yn(K,k)),[T]),j=r.useCallback(()=>T?.(he),[T]),q=r.useRef(null),le=r.useCallback(()=>{const k=q.current;if(k===null)return;[tr,nr,'[data-testid="markdown-explorer-tree-settings"]'].map(I=>k.querySelector(I)).find(I=>I!==null)?.focus()},[]),z=r.useMemo(()=>new Set(M.keys()),[M]),_=r.useMemo(()=>a===null?Fe:new Set([a]),[a]),U=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(b.selectionMode){case"single":return{mode:"single",items:_,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:z,shownPath:a,onChange:R};case"none":return{mode:"none",items:Fe,shownPath:null,onChange:null}}},[t,s,b.selectionMode,_,a,z,R]),Z=r.useMemo(()=>b.revealDocument?{path:a,openFolders:!0}:{path:U.shownPath,openFolders:!1},[b.revealDocument,a,U.shownPath]),J=r.useCallback(k=>{a!==null&&g.settle(a),o(k)},[a,g,o]),[D,ee]=r.useState(null),[V,A]=r.useState(!1),[$,oe]=r.useState(null),B=r.useRef(!1),re=r.useCallback(async()=>{if(!B.current){B.current=!0,A(!0),oe(null);try{const k=await u.refresh(n);if(k.status==="superseded")return;h.invalidate(),k.status==="failed"?oe({sourceId:n,failure:k.failure}):x.announce(f.treeRefreshed)}finally{B.current=!1,A(!1)}}},[u,h,n,x,f]),se=D===null?null:D.expandAll,te=D?.expanding===!0,ue=m.find(k=>k.id===n),ce=i.target==="multi"?yt:vt,G=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:q,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ue?.label,value:n,onChange:k=>J(k.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(k=>c.jsx("option",{value:k.id,children:k.label},k.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(C.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":G,title:G,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ce,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":V,"aria-busy":V,"data-aqmx-busy":V?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{re()},children:[c.jsx(C.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":se===null||te,"aria-busy":te,"data-aqmx-busy":te?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>se?.(),children:c.jsx(Et,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":D===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>D?.collapseAll(),children:c.jsx(wt,{"aria-hidden":"true"})}),E.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[$!==null&&$.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":$.failure.reason,children:f.treeRefreshFailed(C.failureTitleOf(f,$.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(St,{})}),c.jsx(En,{mode:t,sourceId:n,settings:b,reveal:Z,openPaths:s,selection:U,onOpenDocument:d,onRevealSource:l,onControls:ee},n),S&&M.size>0?c.jsx(vn,{selection:M,onRemove:v,onClear:j,onOpenSelection:F,onLeave:le}):null,E.menu]})]})},Ge="(pointer: coarse)",ar=e=>{const t=window.matchMedia(Ge);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},lr=()=>window.matchMedia(Ge).matches,or=()=>!1,sr=()=>r.useSyncExternalStore(ar,lr,or);function cr({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 ir=p.forwardRef(cr),ur=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:d}=C.useExplorer(),o=pt.useLocation(),{location:l}=C.useExplorerLocation(),[i,f]=r.useState(!1),[m,u]=r.useState({navigated:o,source:l.source}),[h,x]=r.useState(!1);m.navigated!==o&&(u({navigated:o,source:l.source}),m.source===l.source&&!h&&f(!1));const[g,b]=r.useState(s);g!==s&&(b(s),f(!1));const y=r.useRef(null),P=r.useRef(null),S=r.useRef(null),T=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const v=y.current;v!==null&&(i&&!v.open?(v.showModal(),P.current?.focus()):!i&&v.open&&(v.close(),t.current?.focus()),a(i?S.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const M=r.useCallback(v=>{v.key!=="Escape"||v.defaultPrevented||(Re(v),f(!1))},[]),L=r.useCallback(v=>{T.current=v.target===v.currentTarget},[]),E=r.useCallback(v=>{const j=T.current;T.current=!1,j&&v.target===v.currentTarget&&f(!1)},[]),R=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(ir,{"aria-hidden":"true"}),c.jsx("span",{children:d.showExplorer})]})}),c.jsx("dialog",{ref:y,id:F,className:"aqmx-sheet","aria-label":d.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:M,onPointerDown:L,onClick:E,onClose:R,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:S,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:P,type:"button",className:"aqmx-sheet-close","aria-label":d.hideExplorer,title:d.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Xe,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ve,{value:i,children:c.jsx(We,{value:x,children:e})})}),c.jsx(C.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Ye=r.createContext(null),ye="aqmx-explorer",Qe="aqmx-content",Se='[role="tree"] [role="treeitem"]',dr=`${Se}[tabindex="0"]`,fr="[data-directory-tree-tab-stop]",mr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${ye}"] ${Se}`))if(n.getAttribute(ne)===t)return n;return null},_e=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:O.ASSUMED_ROOT_FONT_PIXELS}),pr=(e,t)=>{const[n,a]=r.useState(()=>_e(0,0));return r.useLayoutEffect(()=>{const s=e.current,d=t.current;if(s===null||d===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:d.getBoundingClientRect().width},l=()=>{const f=_e(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[u]=m.borderBoxSize;u!==void 0&&(m.target===s&&(o.frame=u.inlineSize),m.target===d&&(o.rem=u.inlineSize))}l()});return i.observe(s),i.observe(d),()=>i.disconnect()},[e,t]),n},Je=e=>`aqmx-split-handle-${e}`,hr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),d=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=u=>{const h=u.target instanceof Element?u.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Qe}"]`)===null,!o.current&&(d.current=h?.closest(`${Se}[${ne}]`)?.getAttribute(ne)??null)},m=u=>{u.relatedTarget instanceof Node&&!i.contains(u.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:u,body:h}=i.ownerDocument;if(u!==null&&u!==h)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=d.current,u=`[data-panel-id="${ye}"]`;f([m===null?null:mr(i,m),i.querySelector(`${u} ${dr}`),i.querySelector(`${u} ${fr}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},xr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:d})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:u,rootFontPixels:h}=pr(o,f),x=u!==null&&u<O.explorerSheetBelowPixels(h);return hr(x,{frameRef:o,sheetToggleRef:m,handleId:Je(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(ur,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Ye,{value:x?l:null,children:c.jsx(wr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:d,explorerMinPixels:O.explorerMinPixels(h)})})]})},wr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:d,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=C.useExplorer(),m=C.useViewSetting(E=>e==="tree"?E.treeExplorer:E.multiExplorer)??(e==="tree"?O.EXPLORER_DEFAULT_PERCENT:O.EXPLORER_MULTI_DEFAULT_PERCENT),u=r.useRef(null),h=r.useRef(null),x=r.useRef(!1),g=r.useRef(!1),[b,y]=r.useState(!1),P=r.useRef(d);r.useLayoutEffect(()=>{P.current=d},[d]);const S=r.useCallback(()=>{const E=u.current;if(E===null||E.length!==2)return;const[R=0,v=0]=E,j=R+v;if(j<=0||R<=0)return;const q=Math.min(O.EXPLORER_MAX_PERCENT,R/j*100);l.update(e==="tree"?{treeExplorer:q}:{multiExplorer:q})},[l,e]),T=r.useCallback(()=>{h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,S()},O.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[S]);r.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current),g.current&&P.current?.(!1)},[]);const F=sr(),M=r.useCallback((E,R)=>{u.current=E;const[v=0,j=0]=E;E.length===2&&j>0&&y(v<=0),R.source==="keyboard"?T():R.source==="pointer"&&(x.current=!0)},[T]),L=r.useCallback(E=>{if(g.current=E,d?.(E),E){x.current=!1;return}x.current&&(x.current=!1,T())},[d,T]);return c.jsxs(pe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:M,className:"aqmx-split","data-aqmx-split":e,children:[t?null:c.jsx(pe.Panel,{id:ye,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:O.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ve,{value:!b,children:n})}),t?null:c.jsx(pe.PanelResizeHandle,{id:Je(e),thickness:F?O.COARSE_TARGET_PIXELS:O.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:O.SPLIT_HANDLE_PIXELS.gripThickness,length:O.SPLIT_HANDLE_PIXELS.gripLength,barThickness:O.SPLIT_HANDLE_PIXELS.barThickness,barLength:O.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:L,inert:s,className:"aqmx-split-handle"}),c.jsx(pe.Panel,{id:Qe,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=he;exports.ExplorerPane=rr;exports.ExplorerSplit=xr;exports.SheetNoticeSlotContext=Ye;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),u=require("react"),B=require("./location-CSIhx-L4.cjs"),k=require("./index-Cie6WPiM.cjs"),ne=require("./ExplorerSplit-ajN3GSdA.cjs"),D=require("@aiquants/drag-drop-panels"),me=require("react-router"),Z=require("./storage-Bkb2Axdi.cjs"),be=require("./dataRoute-DHpu0fg2.cjs"),Be=require("react-dom"),je=require("@aiquants/markdown"),Fe=require("./scrollBarGeometry-C46jBtmM.cjs"),Ve=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Ce=u.createContext(null),re=()=>{const e=u.use(Ce);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Ue=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},$e=0xcbf29ce484222325n,Ge=0x100000001b3n,Ye=(1n<<64n)-1n,We=(1n<<53n)-1n,Ke=new TextEncoder,Je=e=>{let n=$e;for(const t of Ke.encode(e))n=(n^BigInt(t))*Ge&Ye;return Number(n&We)},J=256,Xe=e=>`aqmx-p-${Je(e).toString(36)}`,Pe=(e,n)=>{const t=Xe(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Ze=new Map,Qe=(e,n=Ze)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Pe(r,t);t.add(s),o.set(r,s)}return o},Le=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Me=(e,n)=>{const[t,...o]=B.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([a,f])=>e.slice(a,f).reduce((c,g)=>c+g.length,0);let s=t;for(const a of o)r(a)<r(s)&&(s=a);let l=s[0];for(let a=s[0];a<s[1];a+=1)(e[a]?.length??0)<(e[l]?.length??0)&&(l=a);return l},X=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Le(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Me(t,n)]?.push(r);return t},en=(e,n)=>B.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),nn=(e,n,t)=>{const[o,r]=n,s=r-o,l=e.length,a=Array.from({length:s},(d,p)=>{const m=[0];for(const O of e)m.push((m.at(-1)??0)+(t(O)===o+p?1:0));return m}),f=(d,p,m)=>(a[d]?.[m]??0)-(a[d]?.[p]??0),c=Array.from({length:s+1},()=>Array.from({length:l+1},()=>Number.NEGATIVE_INFINITY)),g=Array.from({length:s+1},()=>Array.from({length:l+1},()=>0)),S=c[0];S&&(S[0]=0);for(let d=0;d<s;d+=1)for(let p=0;p<=l;p+=1)for(let m=0;m<=p;m+=1){const O=(c[d]?.[m]??Number.NEGATIVE_INFINITY)+f(d,m,p),x=c[d+1],T=g[d+1];x&&T&&O>(x[p]??Number.NEGATIVE_INFINITY)&&(x[p]=O,T[p]=m)}const L=Array.from({length:s},()=>[]);let E=l;for(let d=s;d>0;d-=1){const p=g[d]?.[E]??0;L[d-1]=e.slice(p,E),E=p}return L},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const l of s)o.delete(l),o.set(l,r);for(const r of o.keys()){if(o.size<=J)break;o.delete(r)}return{docs:t,columnOf:o}},tn=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=X(e,t),s=Le(e,n,t.logical)??Me(r,t);r[s]?.push(n);const l=new Map(e.panelIds);return l.set(n,Pe(n,new Set(l.values()))),{state:{...e,...Te(e,r),panelIds:l},outcome:"opened"}},Re=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Map(e.panelIds);return o.delete(n),{...e,docs:e.docs.filter(r=>r!==n),hidden:t,panelIds:o,maximized:e.maximized===n?null:e.maximized}},on=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(e,n),outcome:"closed"};const r=tn(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},rn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const l=new Map(e.panelIds),a=l.get(n);if(a===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return l.delete(n),l.set(t,a),{state:{docs:e.docs.map(f=>f===n?t:f),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,panelIds:l},outcome:"navigated"}},Ne=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},sn=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},ln=(e,n,t)=>{const o=X(e,t),r=new Map;for(const[c,g]of o.entries())for(const S of g)r.set(S,c);const s=new Set(e.docs),l=new Set,a=B.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[c,g]of a.entries()){const S=(n[c]??[]).filter(L=>s.has(L)&&!l.has(L));for(const L of S)l.add(L);for(const[L,E]of nn(S,g,d=>r.get(d)).entries())f[g[0]+L]?.push(...E)}for(const c of e.docs)l.has(c)||f[r.get(c)??0]?.push(c);return f.every((c,g)=>c.length===o[g]?.length&&c.every((S,L)=>o[g]?.[L]===S))?e:{...e,...Te(e,f)}},Q=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),panelIds:Qe(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of X(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=J)break;t.delete(o)}return{...e,columnOf:t}},Ie=1,F=Object.freeze({columnOf:new Map,hidden:new Set}),cn=(e,n)=>{if(e===null||e==="")return F;let t;try{t=JSON.parse(e)}catch{return F}if(t===null||typeof t!="object"||Array.isArray(t))return F;const o=t;if(o.v!==Ie)return F;const r=new Map;if(Array.isArray(o.columnOf))for(const l of o.columnOf.slice(-J))Array.isArray(l)&&l.length===2&&typeof l[0]=="string"&&l[0]!==""&&Number.isInteger(l[1])&&l[1]>=0&&l[1]<n&&(r.delete(l[0]),r.set(l[0],l[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(l=>typeof l=="string"&&l!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Ie,columnOf:[...e.columnOf.entries()].slice(-J),hidden:e.docs.filter(n=>e.hidden.has(n))}),se=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},$=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},un=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,l=k.createEmitter(),a=new Map,f=new Map;let c={layout:Q({docs:n.docs,maximized:n.maximized,stored:F},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},g=!1;const S=i=>g?fe(i,{logical:s,visible:c.visibleColumns}):i,L=(i,v)=>B.explorerHref(e,{view:"multi",source:i,docs:v.docs,maximized:v.maximized});let E=L(n.source,n),d=n.source,p=E;const m=[],O=[];let x=null;const T=()=>{if(!(m.length>0))for(const i of O.splice(0))i()},h=i=>{c={...c,...i},l.emit()},b=()=>{if(!c.ready)return;const i=an(c.layout);i!==x&&(x=i,o(i))},y=(i,v,M)=>{const A=L(i,v);A!==E&&(E=A,d=i,m.push(A),t(A,M))},P=i=>{const v=new Set(i.panelIds.values());for(const C of[...a.keys()])v.has(C)||a.delete(C);for(const C of[...f.keys()])v.has(C)||f.delete(C);const M=new Set(i.docs),A=[...c.titles.keys()].every(C=>M.has(C))?c.titles:new Map([...c.titles].filter(([C])=>M.has(C))),w=[...c.pendingHashes.keys()].every(C=>v.has(C))?c.pendingHashes:new Map([...c.pendingHashes].filter(([C])=>v.has(C)));return{titles:A,pendingHashes:w}},N=i=>i===c.layout?!1:(h({layout:i,...P(i)}),y(d,i,"replace"),b(),!0),I=()=>({logical:s,visible:c.visibleColumns});return{getSnapshot:()=>c,subscribe:l.subscribe,toggle:i=>{pe(i);const{state:v,outcome:M}=on(c.layout,i,I(),r);return N(v),M},close:i=>N(Re(c.layout,i)),navigate:(i,v)=>{pe(v);const{state:M,outcome:A}=rn(c.layout,i,v);if(A!=="navigated")return A;const w=M.panelIds.get(v);return w!==void 0&&(a.delete(w),f.delete(w)),N(M),A},setHidden:(i,v)=>N(Ne(c.layout,i,v)),maximize:i=>N(sn(c.layout,i)),arrange:i=>N(ln(c.layout,i,{logical:s,visible:i.length})),changeSource:i=>{y(i,c.layout,"push")},revealSource:i=>{y(i,c.layout,"replace")},observeLocation:i=>{const v=L(i.source,i);if(v===E)return m.length=0,p=v,i.source!==c.source&&h({source:i.source}),T(),!1;if(v===p)return!1;p=v;const M=m.indexOf(v);if(M>=0)return m.splice(0,M+1),i.source!==c.source&&h({source:i.source}),T(),!1;m.length=0,E=v,d=i.source;const A=S(Q({docs:i.docs,maximized:i.maximized,stored:{columnOf:c.layout.columnOf,hidden:c.layout.hidden},panelIds:c.layout.panelIds},r));return h({layout:A,source:i.source,...P(A)}),b(),T(),!0},whenUrlRendered:i=>{O.push(i),T()},loadStored:i=>{h({layout:S(Q({docs:c.layout.docs,maximized:c.layout.maximized,stored:i,panelIds:c.layout.panelIds},r)),ready:!0}),b()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);g=!0;const v=fe(c.layout,{logical:s,visible:i});i===c.visibleColumns&&v===c.layout||(h({visibleColumns:i,layout:v}),v!==c.layout&&b())},setSplitDragging:i=>{i!==c.splitDragging&&h({splitDragging:i})},setTitle:(i,v)=>{!c.layout.docs.includes(i)||c.titles.get(i)===v||h({titles:new Map(c.titles).set(i,v)})},titleOf:i=>se(c.titles,i),setPendingHash:(i,v)=>{const M=c.pendingHashes.get(i);if(v===null||v===""){if(M===void 0)return;const A=new Map(c.pendingHashes);A.delete(i),h({pendingHashes:A});return}M!==v&&h({pendingHashes:new Map(c.pendingHashes).set(i,v)})},saveReadingPosition:(i,v,M)=>{c.layout.panelIds.get(v)===i&&a.set(i,{doc:v,position:M})},readingPositionOf:(i,v)=>{const M=a.get(i);return M===void 0||M.doc!==v?null:M.position},saveImageView:(i,v,M)=>{f.set(i,{url:v,state:M})},imageViewOf:(i,v)=>{const M=f.get(i);return M===void 0||M.url!==v?null:M.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},dn=e=>{const{config:n,storageNamespace:t}=k.useExplorer(),o=me.useNavigate(),r=u.useRef(o),s=Z.storageKeys(t).multiLayout,[l]=u.useState(()=>un({config:n,location:e,writeUrl:(c,g)=>{r.current(c,k.explorerNavigationOptions(g==="replace"?"browse":"switch-source"))},persist:c=>Z.writeStorage(s,c)}));u.useLayoutEffect(()=>{r.current=o},[o]);const a=me.useLocation(),f=u.useMemo(()=>({location:e,navigated:a}),[e,a]);return u.useLayoutEffect(()=>{l.observeLocation(f.location)},[l,f]),u.useLayoutEffect(()=>{l.loadStored(cn(Z.readStorage(s),n.multiView.columns))},[l,s,n]),l},mn=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},fn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:l,revealInPanel:a}=re(),{announcer:f}=k.useExplorer(),c=z(s,x=>Ue(x,n)),g=u.useCallback((x,T)=>l(n,e,x,T),[l,n,e]),S=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),L=u.useMemo(()=>({read:x=>s.imageViewOf(n,x),save:(x,T)=>s.saveImageView(n,x,T)}),[s,n]),E=u.useCallback((x,T)=>{T.kind!=="failure"&&s.setTitle(x,T.name),r(x)},[s,r]),d=u.useCallback(x=>{s.whenUrlRendered(()=>f.announce(x))},[s,f]),p=u.useMemo(()=>({scrollerOf:mn,reveal:x=>a(n,x)}),[a,n]),m=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:g,pendingHash:c,onHashConsumed:S,announceFailure:d,paneScroll:p}),[t,g,c,S,d,p]),O=u.useMemo(()=>({kind:"panel",documentName:o}),[o]);return R.jsxs(k.ImageViewMemoryContext,{value:L,children:[R.jsx(k.DocumentRefreshBar,{path:e,placement:O}),R.jsx(k.DocumentPane,{path:e,variant:m,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",le="data-aqmx-column-probe",Y="data-panel-id",te="--aqmx-multi-panel-chrome",j=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,pn=e=>e==="normal"?0:j(e),gn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${le}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),l=t.clientWidth-j(s.paddingLeft)-j(s.paddingRight),a=t.clientHeight-j(s.paddingTop)-j(s.paddingBottom);return{plan:{trackInlineSize:l,gap:pn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:a}},hn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+j(t.paddingBottom)+j(t.borderBottomWidth)},W="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",vn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},yn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},Sn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),V=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},De=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ve=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},xn=(e,n)=>{const t=De(e,n),o=[];let r=e;for(let s=ve([...r.children],t);s>=0;s=ve([...r.children],t)){const l=r.children[s];if(l===void 0)break;o.push(s),r=l}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-De(e,n)-t.anchor.offset)},wn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>JSON.stringify([e.tagName,...wn.map(n=>e.getAttribute(n))]),En=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:_e(n)}},On=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&k.focusWithoutScroll(o)||n.focus({preventScroll:!0})},bn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?V(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=Sn(e,r,t);(o||Cn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Cn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Pn=e=>e.scrollHeight>e.clientHeight,Ln=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),l=()=>{const c=hn(e,n);if(!Number.isFinite(c))return;const g=s===null?0:s.getBoundingClientRect().height;g!==r&&(r=g,t.style.setProperty(he,`${String(g)}px`));const S=c+g;S!==o&&(o=S,e.style.setProperty(te,`${String(S)}px`))};l();let a=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,l()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),a!==null&&cancelAnimationFrame(a),e.style.removeProperty(te),t.style.removeProperty(he)}},Mn=e=>{const{docPath:n,panelId:t}=vn(e),{store:o,Body:r,maximize:s,focusCarry:l}=re(),a=z(o,d=>d.layout.maximized===n),f=z(o,d=>se(d.titles,n)),c=u.useRef(null),g=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null||a)return;const m=new Map,O=y=>{const P=m.get(y);if(P!==void 0)return P;const N=yn(y);return m.set(y,N),N},x=y=>bn(y,d,O);let T=!1;const h=()=>{const y=Pn(p);y!==T&&(T=y,y?d.addEventListener("wheel",x,{capture:!0,passive:!1}):d.removeEventListener("wheel",x,{capture:!0}))};h();const b=typeof ResizeObserver>"u"?null:new ResizeObserver(h);return b?.observe(p),b?.observe(d),()=>{b?.disconnect(),d.removeEventListener("wheel",x,{capture:!0})}},[a]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d),m=d===null?null:d.closest(`[${Y}]`);if(!(d===null||p===null||!(m instanceof HTMLElement)))return Ln(m,p,d)},[]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null)return;const m=o.readingPositionOf(t,n);g.current=m===null?null:{doc:n,position:m},m!==null&&ye(d,p,m);let O=null;const x=()=>{O===null&&(O=requestAnimationFrame(()=>{O=null;const T=S.current;T!==null&&o.saveReadingPosition(t,T,xn(d,p))}))};return p.addEventListener("scroll",x,{passive:!0}),()=>{p.removeEventListener("scroll",x),O!==null&&cancelAnimationFrame(O)}},[o,t,n]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:d.closest(`[${Y}]`);if(d===null||p===null)return;const m=l.take(t);return m!==null&&On(p,d,m),()=>{const O=En(p,p.ownerDocument.activeElement);O!==null&&l.hold(t,O)}},[l,t]);const L=u.useCallback(d=>{const p=c.current,m=p===null?null:V(p);if(p===null||m===null)return;const O=S.current;S.current=d;const x=g.current;g.current=null,x!==null&&x.doc===d?ye(p,m,x.position):O!==null&&O!==d&&(m.scrollTop=0)},[]),E=u.useCallback(()=>s(n),[s,n]);return R.jsx("div",{ref:c,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":a?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:a?void 0:E,children:R.jsx(r,{docPath:n,panelId:t,maximized:a,title:f,onContentShown:L})})},Tn=u.memo(Mn),G=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},Se=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=en(X(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>G(e,s))]))},Nn=(e,n)=>{const t=$(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},In=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),An="--aqmx-multi-stage-bar-gutter",Dn=Object.freeze({[An]:`${String(Fe.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%"}),kn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),zn=e=>R.jsx("div",{...kn,children:R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Hn=({props:e,children:n})=>R.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:zn,children:n}),qn=e=>R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ie="--aqmx-stage-block",Bn="--aqmx-multi-panel-body-floor",jn=`calc(var(${ie}) * ${String(B.PANEL_MIN_BLOCK_RATIO)})`,Fn=`max(calc(var(${ie}) * ${String(B.PANEL_MAX_BLOCK_RATIO)}), calc(var(${te}) + var(${Bn})))`,Vn=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((l,a)=>r[a]===l)})},xe=["keydown","pointerdown","wheel","touchstart"],U=new WeakMap,we=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},Un=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},K=(e,n,t)=>{U.get(e)?.();const o=e.querySelector(`[${Y}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const l=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const S=r?.isConnected===!0?r:o;S!==o&&S.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Un(S)};if(l(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(l);we(a,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&we(a,r,o);const{ownerDocument:f}=e,c=S=>{const L=S.target===f?f.scrollingElement:S.target;if(!(L instanceof Element))return;const E=s.get(L);E!==void 0&&(L.scrollTop!==E.top||L.scrollLeft!==E.left)&&g()},g=()=>{a.disconnect();for(const S of xe)f.removeEventListener(S,g,!0);f.removeEventListener("scroll",c,!0),U.get(e)===g&&U.delete(e)};for(const S of xe)f.addEventListener(S,g,{capture:!0,passive:!0});f.addEventListener("scroll",c,{capture:!0,passive:!0}),U.set(e,g)},ke=(e,n)=>{const t=e.querySelector(`[${W}="${n}"]`);return t instanceof HTMLElement?(K(e,n,null),t.focus({preventScroll:!0}),!0):!1},ce=(e,n)=>{const t=e.querySelector(`[${Y}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ce(e,n))return null;const t=[...e.querySelectorAll(`[${W}]`)].map(l=>l.getAttribute(W)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Oe=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&ke(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&ke(t,n)})},$n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(K(o,n,t&&ce(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const l=o.querySelector(`[${W}="${n}"]`);l instanceof HTMLElement&&l.focus({preventScroll:!0})})},Gn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r}=k.useExplorer(),{maximize:s}=re(),l=t.multiView.columns,a=z(e,w=>w.layout),f=z(e,w=>w.visibleColumns),c=z(e,w=>w.titles),g=z(e,w=>w.layout.maximized!==null||w.splitDragging),[S,L]=u.useState(!1),[E]=u.useState(()=>Se(f)),d=u.useMemo(()=>In(o),[o]),p=u.useCallback(w=>{e.arrange(Nn(e.getSnapshot().layout,w))},[e]),m=D.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:p}),{columnPanels:O,setColumnPanels:x}=m,T=u.useRef(g),h=u.useRef(O);u.useLayoutEffect(()=>{T.current=g,h.current=O},[g,O]);const b=u.useCallback(w=>{const C=n.current;if(C===null)return;const{plan:q,stageBlockSize:_}=gn(C,l);if(Number.isFinite(_)&&_>0&&C.style.setProperty(ie,`${String(_)}px`),T.current&&!w)return;const H=B.replanVisibleColumns(e.getSnapshot().visibleColumns,q);H!==null&&e.setVisibleColumns(H)},[e,n,l]);u.useLayoutEffect(()=>{b(!0),L(!0)},[b]),u.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let C=null;const q=new ResizeObserver(()=>{C===null&&(C=requestAnimationFrame(()=>{C=null,b(!1)}))}),_=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,H=w.querySelector(`[${le}]`);return _ instanceof Element&&q.observe(_),H instanceof Element&&q.observe(H),()=>{q.disconnect(),C!==null&&cancelAnimationFrame(C)}},[n,b]),u.useEffect(()=>{g||b(!1)},[g,b]);const y=u.useMemo(()=>S?Rn(a,{logical:l,visible:f}):Se(f),[S,a,l,f]);u.useLayoutEffect(()=>{Vn(h.current,y)||x(y)},[y,x]);const P=u.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),N=u.useMemo(()=>a.docs.map(w=>{const C=G(a,w);return{id:C,component:Tn,title:se(c,w),props:{docPath:w,panelId:C},minHeight:jn,maxHeight:Fn}}),[a,c]),I=u.useMemo(()=>Object.fromEntries(a.docs.map(w=>[G(a,w),!a.hidden.has(w)])),[a]),i=a.maximized===null?null:G(a,a.maximized),v=u.useCallback(w=>{const{layout:C}=e.getSnapshot();for(const[q,_]of $(C)){const H=w[q];if(H===void 0||H!==C.hidden.has(_))continue;const ae=e.titleOf(_);if(H){if(!e.setHidden(_,!1))continue;r.announce(o.panelShown(ae)),ze(n,q);continue}const ue=n.current,de=ue===null?null:Ee(ue,q);e.setHidden(_,!0)&&(r.announce(o.panelHidden(ae)),de!==null&&Oe(n,de))}},[e,n,r,o]),M=u.useCallback(w=>{const C=$(e.getSnapshot().layout).get(w);if(C===void 0)return;const q=e.titleOf(C),_=n.current,H=_===null?null:Ee(_,w);e.close(C)&&(r.announce(o.panelClosed(q)),H!==null&&Oe(n,H))},[e,n,r,o]),A=u.useCallback(w=>{if(w===null){s(null);return}const C=$(e.getSnapshot().layout).get(w);C!==void 0&&s(C)},[e,s]);return R.jsx("div",{className:"aqmx-multi-layout","aria-busy":!S,children:R.jsx(D.DragDropLayout,{columns:P,panels:N,columnPanels:O,onColumnPanelsChange:p,panelVisibility:I,onPanelVisibilityChange:v,dragState:m.dragState,dragOverPosition:m.dragOverPosition,originalPanelPosition:m.originalPanelPosition,dragModes:m.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:m.panelSizes,customDrag:m.customDrag,setPanelRef:m.setPanelRef,onDragStart:m.handleDragStart,onDragEnd:m.handleDragEnd,onPlaceholderDragEnter:m.handlePlaceholderDragEnter,onPlaceholderDragLeave:m.handlePlaceholderDragLeave,onDragOverWithInsert:m.handleDragOverWithInsert,onDropWithInsert:m.handleDropWithInsert,onColumnDragLeave:m.handleColumnDragLeave,onPanelMouseDown:m.handleMouseDown,onPanelSizeInfoClick:m.handlePanelSizeInfoClick,onToggleDragMode:m.toggleDragMode,onPanelClose:M,onPanelMaximizeChange:A,maximizedPanel:i,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Hn,renderStageScrollBar:qn})})},ee={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Yn=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(l=>{const a=n.ownerDocument.elementsFromPoint(s,l),f=a.findIndex(g=>n.contains(g)),c=a.findIndex(g=>e.contains(g));return f!==-1&&c!==-1&&c<f}))},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(ee.blockStart,`${String(t.top)}px`),e.style.setProperty(ee.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(ee.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Kn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:l,announcer:a}=k.useExplorer(),f=u.useRef(null),c=u.useRef(null),g=z(e,h=>h.ready),S=z(e,h=>h.layout.docs.length>0),L=z(e,h=>h.visibleColumns),E=u.use(ne.SheetNoticeSlotContext),d=u.useCallback(h=>{const{layout:b}=e.getSnapshot(),y=b.maximized,P=h===null&&y!==null?b.panelIds.get(y):void 0,N=f.current,I=P!==void 0&&N!==null&&ce(N,P);e.maximize(h)&&(h!==null?a.announce(l.panelMaximized(e.titleOf(h))):y!==null&&a.announce(l.panelRestored(e.titleOf(y))),P!==void 0&&$n(f,P,I))},[e,a,l]),p=u.useCallback((h,b,y,P)=>{if(y===b){e.setPendingHash(h,P);return}const N=e.navigate(b,y);if(N==="navigated"){e.setPendingHash(h,P);return}if(N!=="existing")return;const{layout:I}=e.getSnapshot(),i=I.panelIds.get(y);i!==void 0&&(a.announce(l.panelAlreadyOpen(e.titleOf(y))),I.maximized===null?e.setHidden(y,!1):d(y),e.setPendingHash(i,P),ze(f,i))},[e,a,l,d]);u.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const h=c.current,b=f.current;if(h===null||b===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Wn(h,b)},[t,E]),u.useEffect(()=>{const h=c.current;if(t===null||h===null)return;const{ownerDocument:b}=h;let y=null;const P=N=>{const I=N.target;I instanceof Element&&(y!==null&&cancelAnimationFrame(y),y=requestAnimationFrame(()=>{y=null,b.activeElement===I&&h.isConnected&&Yn(h,I)&&o()}))};return b.addEventListener("focusin",P,!0),()=>{b.removeEventListener("focusin",P,!0),y!==null&&cancelAnimationFrame(y)}},[t,E,o]),u.useImperativeHandle(r,()=>({bringIntoView:h=>{requestAnimationFrame(()=>{const b=f.current,y=e.getSnapshot().layout.panelIds.get(h);b!==null&&y!==void 0&&K(b,y,null)})}}),[e]),u.useEffect(()=>{const h=f.current;return()=>{h!==null&&U.get(h)?.()}},[]);const m=u.useCallback((h,b)=>{const y=f.current;y!==null&&K(y,h,b)},[]),[O]=u.useState(Ve),x=u.useMemo(()=>({store:e,Body:n,followLink:p,maximize:d,revealInPanel:m,focusCarry:O}),[e,n,p,d,m,O]),T=u.useMemo(()=>Array.from({length:s.multiView.columns},(h,b)=>D.generateColumnId(b)),[s]);return R.jsxs("section",{ref:f,className:"aqmx-multi-stage",style:Dn,tabIndex:-1,"aria-label":l.multiRegion,"aria-busy":S&&!g,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":L,children:[R.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[le]:""}),S?g?R.jsx(Ce,{value:x,children:R.jsx(Gn,{store:e,stageRef:f})}):R.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:T.map(h=>R.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]},h))}):R.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:R.jsx("p",{className:"aqmx-empty-title",children:l.multiEmpty})}),t===null?null:E!==null?Be.createPortal(R.jsx("div",{ref:c,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):R.jsx("div",{ref:c,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},oe=(e,n,t)=>{const o=new Set(e),r=n.filter(l=>!o.has(l)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Jn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Xn=({location:e})=>{const{config:n,labels:t,announcer:o}=k.useExplorer(),r=dn(e),s=z(r,P=>P.layout.docs),l=z(r,P=>P.layout.maximized),a=z(r,P=>P.source),[f,c]=u.useState(()=>({docs:s,latest:oe([],s,null)}));f.docs!==s&&c({docs:s,latest:oe(f.docs,s,f.latest)});const g=l!==null?l:f.latest,[S,L]=u.useState(!1),E=u.useRef(null),[d,p]=u.useState(0),m=u.useRef(null),O=u.useRef(null);u.useLayoutEffect(()=>{const P=m.current;m.current=null,P!==null&&(r.whenUrlRendered(()=>o.announce(P.announcement)),O.current?.bringIntoView(P.doc))}),u.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const x=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),L(!0),E.current=setTimeout(()=>{E.current=null,L(!1)},He)},[]),T=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,L(!1)},[]),h=u.useCallback(P=>{const N=r.titleOf(P),I=r.toggle(P);I==="rejected"&&x();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Jn(t,I,N);if(I==="shown"){m.current={doc:P,announcement:i},p(v=>v+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&O.current?.bringIntoView(P)})},[r,x,o,t,n]),b=u.useMemo(()=>new Set(s),[s]),y=u.useMemo(()=>({href:B.explorerHref(n,{view:"tree",source:a,doc:qe(s,l)}),target:"tree"}),[n,a,s,l]);return R.jsx(ne.ExplorerSplit,{view:"multi",explorer:R.jsx(ne.ExplorerPane,{mode:"multi",sourceId:a,currentPath:g,openPaths:b,onOpenDocument:h,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:y}),content:R.jsx(Kn,{ref:O,store:r,body:fn,limitNotice:S?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:T}),contentCoversPage:l!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Xn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=oe;exports.treeSwitchDocument=qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),u=require("react"),B=require("./location-FavgY_gB.cjs"),k=require("./index-B3nShkkt.cjs"),ne=require("./ExplorerSplit-CUIbSLQm.cjs"),D=require("@aiquants/drag-drop-panels"),me=require("react-router"),Z=require("./storage-Bkb2Axdi.cjs"),be=require("./dataRoute-CUXlMhUJ.cjs"),Be=require("react-dom"),je=require("@aiquants/markdown"),Fe=require("./scrollBarGeometry-C46jBtmM.cjs"),Ve=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Ce=u.createContext(null),re=()=>{const e=u.use(Ce);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Ue=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},$e=0xcbf29ce484222325n,Ge=0x100000001b3n,Ye=(1n<<64n)-1n,We=(1n<<53n)-1n,Ke=new TextEncoder,Je=e=>{let n=$e;for(const t of Ke.encode(e))n=(n^BigInt(t))*Ge&Ye;return Number(n&We)},J=256,Xe=e=>`aqmx-p-${Je(e).toString(36)}`,Pe=(e,n)=>{const t=Xe(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Ze=new Map,Qe=(e,n=Ze)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Pe(r,t);t.add(s),o.set(r,s)}return o},Le=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Me=(e,n)=>{const[t,...o]=B.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([a,f])=>e.slice(a,f).reduce((c,g)=>c+g.length,0);let s=t;for(const a of o)r(a)<r(s)&&(s=a);let l=s[0];for(let a=s[0];a<s[1];a+=1)(e[a]?.length??0)<(e[l]?.length??0)&&(l=a);return l},X=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Le(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Me(t,n)]?.push(r);return t},en=(e,n)=>B.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),nn=(e,n,t)=>{const[o,r]=n,s=r-o,l=e.length,a=Array.from({length:s},(d,p)=>{const m=[0];for(const O of e)m.push((m.at(-1)??0)+(t(O)===o+p?1:0));return m}),f=(d,p,m)=>(a[d]?.[m]??0)-(a[d]?.[p]??0),c=Array.from({length:s+1},()=>Array.from({length:l+1},()=>Number.NEGATIVE_INFINITY)),g=Array.from({length:s+1},()=>Array.from({length:l+1},()=>0)),S=c[0];S&&(S[0]=0);for(let d=0;d<s;d+=1)for(let p=0;p<=l;p+=1)for(let m=0;m<=p;m+=1){const O=(c[d]?.[m]??Number.NEGATIVE_INFINITY)+f(d,m,p),x=c[d+1],T=g[d+1];x&&T&&O>(x[p]??Number.NEGATIVE_INFINITY)&&(x[p]=O,T[p]=m)}const L=Array.from({length:s},()=>[]);let E=l;for(let d=s;d>0;d-=1){const p=g[d]?.[E]??0;L[d-1]=e.slice(p,E),E=p}return L},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const l of s)o.delete(l),o.set(l,r);for(const r of o.keys()){if(o.size<=J)break;o.delete(r)}return{docs:t,columnOf:o}},tn=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=X(e,t),s=Le(e,n,t.logical)??Me(r,t);r[s]?.push(n);const l=new Map(e.panelIds);return l.set(n,Pe(n,new Set(l.values()))),{state:{...e,...Te(e,r),panelIds:l},outcome:"opened"}},Re=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Map(e.panelIds);return o.delete(n),{...e,docs:e.docs.filter(r=>r!==n),hidden:t,panelIds:o,maximized:e.maximized===n?null:e.maximized}},on=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(e,n),outcome:"closed"};const r=tn(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},rn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const l=new Map(e.panelIds),a=l.get(n);if(a===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return l.delete(n),l.set(t,a),{state:{docs:e.docs.map(f=>f===n?t:f),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,panelIds:l},outcome:"navigated"}},Ne=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},sn=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},ln=(e,n,t)=>{const o=X(e,t),r=new Map;for(const[c,g]of o.entries())for(const S of g)r.set(S,c);const s=new Set(e.docs),l=new Set,a=B.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[c,g]of a.entries()){const S=(n[c]??[]).filter(L=>s.has(L)&&!l.has(L));for(const L of S)l.add(L);for(const[L,E]of nn(S,g,d=>r.get(d)).entries())f[g[0]+L]?.push(...E)}for(const c of e.docs)l.has(c)||f[r.get(c)??0]?.push(c);return f.every((c,g)=>c.length===o[g]?.length&&c.every((S,L)=>o[g]?.[L]===S))?e:{...e,...Te(e,f)}},Q=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),panelIds:Qe(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of X(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=J)break;t.delete(o)}return{...e,columnOf:t}},Ie=1,F=Object.freeze({columnOf:new Map,hidden:new Set}),cn=(e,n)=>{if(e===null||e==="")return F;let t;try{t=JSON.parse(e)}catch{return F}if(t===null||typeof t!="object"||Array.isArray(t))return F;const o=t;if(o.v!==Ie)return F;const r=new Map;if(Array.isArray(o.columnOf))for(const l of o.columnOf.slice(-J))Array.isArray(l)&&l.length===2&&typeof l[0]=="string"&&l[0]!==""&&Number.isInteger(l[1])&&l[1]>=0&&l[1]<n&&(r.delete(l[0]),r.set(l[0],l[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(l=>typeof l=="string"&&l!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Ie,columnOf:[...e.columnOf.entries()].slice(-J),hidden:e.docs.filter(n=>e.hidden.has(n))}),se=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},$=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},un=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,l=k.createEmitter(),a=new Map,f=new Map;let c={layout:Q({docs:n.docs,maximized:n.maximized,stored:F},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},g=!1;const S=i=>g?fe(i,{logical:s,visible:c.visibleColumns}):i,L=(i,v)=>B.explorerHref(e,{view:"multi",source:i,docs:v.docs,maximized:v.maximized});let E=L(n.source,n),d=n.source,p=E;const m=[],O=[];let x=null;const T=()=>{if(!(m.length>0))for(const i of O.splice(0))i()},h=i=>{c={...c,...i},l.emit()},b=()=>{if(!c.ready)return;const i=an(c.layout);i!==x&&(x=i,o(i))},y=(i,v,M)=>{const A=L(i,v);A!==E&&(E=A,d=i,m.push(A),t(A,M))},P=i=>{const v=new Set(i.panelIds.values());for(const C of[...a.keys()])v.has(C)||a.delete(C);for(const C of[...f.keys()])v.has(C)||f.delete(C);const M=new Set(i.docs),A=[...c.titles.keys()].every(C=>M.has(C))?c.titles:new Map([...c.titles].filter(([C])=>M.has(C))),w=[...c.pendingHashes.keys()].every(C=>v.has(C))?c.pendingHashes:new Map([...c.pendingHashes].filter(([C])=>v.has(C)));return{titles:A,pendingHashes:w}},N=i=>i===c.layout?!1:(h({layout:i,...P(i)}),y(d,i,"replace"),b(),!0),I=()=>({logical:s,visible:c.visibleColumns});return{getSnapshot:()=>c,subscribe:l.subscribe,toggle:i=>{pe(i);const{state:v,outcome:M}=on(c.layout,i,I(),r);return N(v),M},close:i=>N(Re(c.layout,i)),navigate:(i,v)=>{pe(v);const{state:M,outcome:A}=rn(c.layout,i,v);if(A!=="navigated")return A;const w=M.panelIds.get(v);return w!==void 0&&(a.delete(w),f.delete(w)),N(M),A},setHidden:(i,v)=>N(Ne(c.layout,i,v)),maximize:i=>N(sn(c.layout,i)),arrange:i=>N(ln(c.layout,i,{logical:s,visible:i.length})),changeSource:i=>{y(i,c.layout,"push")},revealSource:i=>{y(i,c.layout,"replace")},observeLocation:i=>{const v=L(i.source,i);if(v===E)return m.length=0,p=v,i.source!==c.source&&h({source:i.source}),T(),!1;if(v===p)return!1;p=v;const M=m.indexOf(v);if(M>=0)return m.splice(0,M+1),i.source!==c.source&&h({source:i.source}),T(),!1;m.length=0,E=v,d=i.source;const A=S(Q({docs:i.docs,maximized:i.maximized,stored:{columnOf:c.layout.columnOf,hidden:c.layout.hidden},panelIds:c.layout.panelIds},r));return h({layout:A,source:i.source,...P(A)}),b(),T(),!0},whenUrlRendered:i=>{O.push(i),T()},loadStored:i=>{h({layout:S(Q({docs:c.layout.docs,maximized:c.layout.maximized,stored:i,panelIds:c.layout.panelIds},r)),ready:!0}),b()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);g=!0;const v=fe(c.layout,{logical:s,visible:i});i===c.visibleColumns&&v===c.layout||(h({visibleColumns:i,layout:v}),v!==c.layout&&b())},setSplitDragging:i=>{i!==c.splitDragging&&h({splitDragging:i})},setTitle:(i,v)=>{!c.layout.docs.includes(i)||c.titles.get(i)===v||h({titles:new Map(c.titles).set(i,v)})},titleOf:i=>se(c.titles,i),setPendingHash:(i,v)=>{const M=c.pendingHashes.get(i);if(v===null||v===""){if(M===void 0)return;const A=new Map(c.pendingHashes);A.delete(i),h({pendingHashes:A});return}M!==v&&h({pendingHashes:new Map(c.pendingHashes).set(i,v)})},saveReadingPosition:(i,v,M)=>{c.layout.panelIds.get(v)===i&&a.set(i,{doc:v,position:M})},readingPositionOf:(i,v)=>{const M=a.get(i);return M===void 0||M.doc!==v?null:M.position},saveImageView:(i,v,M)=>{f.set(i,{url:v,state:M})},imageViewOf:(i,v)=>{const M=f.get(i);return M===void 0||M.url!==v?null:M.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},dn=e=>{const{config:n,storageNamespace:t}=k.useExplorer(),o=me.useNavigate(),r=u.useRef(o),s=Z.storageKeys(t).multiLayout,[l]=u.useState(()=>un({config:n,location:e,writeUrl:(c,g)=>{r.current(c,k.explorerNavigationOptions(g==="replace"?"browse":"switch-source"))},persist:c=>Z.writeStorage(s,c)}));u.useLayoutEffect(()=>{r.current=o},[o]);const a=me.useLocation(),f=u.useMemo(()=>({location:e,navigated:a}),[e,a]);return u.useLayoutEffect(()=>{l.observeLocation(f.location)},[l,f]),u.useLayoutEffect(()=>{l.loadStored(cn(Z.readStorage(s),n.multiView.columns))},[l,s,n]),l},mn=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},fn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:l,revealInPanel:a}=re(),{announcer:f}=k.useExplorer(),c=z(s,x=>Ue(x,n)),g=u.useCallback((x,T)=>l(n,e,x,T),[l,n,e]),S=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),L=u.useMemo(()=>({read:x=>s.imageViewOf(n,x),save:(x,T)=>s.saveImageView(n,x,T)}),[s,n]),E=u.useCallback((x,T)=>{T.kind!=="failure"&&s.setTitle(x,T.name),r(x)},[s,r]),d=u.useCallback(x=>{s.whenUrlRendered(()=>f.announce(x))},[s,f]),p=u.useMemo(()=>({scrollerOf:mn,reveal:x=>a(n,x)}),[a,n]),m=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:g,pendingHash:c,onHashConsumed:S,announceFailure:d,paneScroll:p}),[t,g,c,S,d,p]),O=u.useMemo(()=>({kind:"panel",documentName:o}),[o]);return R.jsxs(k.ImageViewMemoryContext,{value:L,children:[R.jsx(k.DocumentRefreshBar,{path:e,placement:O}),R.jsx(k.DocumentPane,{path:e,variant:m,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",le="data-aqmx-column-probe",Y="data-panel-id",te="--aqmx-multi-panel-chrome",j=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,pn=e=>e==="normal"?0:j(e),gn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${le}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),l=t.clientWidth-j(s.paddingLeft)-j(s.paddingRight),a=t.clientHeight-j(s.paddingTop)-j(s.paddingBottom);return{plan:{trackInlineSize:l,gap:pn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:a}},hn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+j(t.paddingBottom)+j(t.borderBottomWidth)},W="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",vn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},yn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},Sn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),V=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},De=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ve=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},xn=(e,n)=>{const t=De(e,n),o=[];let r=e;for(let s=ve([...r.children],t);s>=0;s=ve([...r.children],t)){const l=r.children[s];if(l===void 0)break;o.push(s),r=l}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-De(e,n)-t.anchor.offset)},wn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>JSON.stringify([e.tagName,...wn.map(n=>e.getAttribute(n))]),En=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:_e(n)}},On=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&k.focusWithoutScroll(o)||n.focus({preventScroll:!0})},bn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?V(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=Sn(e,r,t);(o||Cn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Cn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Pn=e=>e.scrollHeight>e.clientHeight,Ln=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),l=()=>{const c=hn(e,n);if(!Number.isFinite(c))return;const g=s===null?0:s.getBoundingClientRect().height;g!==r&&(r=g,t.style.setProperty(he,`${String(g)}px`));const S=c+g;S!==o&&(o=S,e.style.setProperty(te,`${String(S)}px`))};l();let a=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,l()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),a!==null&&cancelAnimationFrame(a),e.style.removeProperty(te),t.style.removeProperty(he)}},Mn=e=>{const{docPath:n,panelId:t}=vn(e),{store:o,Body:r,maximize:s,focusCarry:l}=re(),a=z(o,d=>d.layout.maximized===n),f=z(o,d=>se(d.titles,n)),c=u.useRef(null),g=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null||a)return;const m=new Map,O=y=>{const P=m.get(y);if(P!==void 0)return P;const N=yn(y);return m.set(y,N),N},x=y=>bn(y,d,O);let T=!1;const h=()=>{const y=Pn(p);y!==T&&(T=y,y?d.addEventListener("wheel",x,{capture:!0,passive:!1}):d.removeEventListener("wheel",x,{capture:!0}))};h();const b=typeof ResizeObserver>"u"?null:new ResizeObserver(h);return b?.observe(p),b?.observe(d),()=>{b?.disconnect(),d.removeEventListener("wheel",x,{capture:!0})}},[a]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d),m=d===null?null:d.closest(`[${Y}]`);if(!(d===null||p===null||!(m instanceof HTMLElement)))return Ln(m,p,d)},[]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null)return;const m=o.readingPositionOf(t,n);g.current=m===null?null:{doc:n,position:m},m!==null&&ye(d,p,m);let O=null;const x=()=>{O===null&&(O=requestAnimationFrame(()=>{O=null;const T=S.current;T!==null&&o.saveReadingPosition(t,T,xn(d,p))}))};return p.addEventListener("scroll",x,{passive:!0}),()=>{p.removeEventListener("scroll",x),O!==null&&cancelAnimationFrame(O)}},[o,t,n]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:d.closest(`[${Y}]`);if(d===null||p===null)return;const m=l.take(t);return m!==null&&On(p,d,m),()=>{const O=En(p,p.ownerDocument.activeElement);O!==null&&l.hold(t,O)}},[l,t]);const L=u.useCallback(d=>{const p=c.current,m=p===null?null:V(p);if(p===null||m===null)return;const O=S.current;S.current=d;const x=g.current;g.current=null,x!==null&&x.doc===d?ye(p,m,x.position):O!==null&&O!==d&&(m.scrollTop=0)},[]),E=u.useCallback(()=>s(n),[s,n]);return R.jsx("div",{ref:c,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":a?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:a?void 0:E,children:R.jsx(r,{docPath:n,panelId:t,maximized:a,title:f,onContentShown:L})})},Tn=u.memo(Mn),G=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},Se=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=en(X(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>G(e,s))]))},Nn=(e,n)=>{const t=$(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},In=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),An="--aqmx-multi-stage-bar-gutter",Dn=Object.freeze({[An]:`${String(Fe.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%"}),kn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),zn=e=>R.jsx("div",{...kn,children:R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Hn=({props:e,children:n})=>R.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:zn,children:n}),qn=e=>R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ie="--aqmx-stage-block",Bn="--aqmx-multi-panel-body-floor",jn=`calc(var(${ie}) * ${String(B.PANEL_MIN_BLOCK_RATIO)})`,Fn=`max(calc(var(${ie}) * ${String(B.PANEL_MAX_BLOCK_RATIO)}), calc(var(${te}) + var(${Bn})))`,Vn=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((l,a)=>r[a]===l)})},xe=["keydown","pointerdown","wheel","touchstart"],U=new WeakMap,we=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},Un=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},K=(e,n,t)=>{U.get(e)?.();const o=e.querySelector(`[${Y}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const l=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const S=r?.isConnected===!0?r:o;S!==o&&S.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Un(S)};if(l(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(l);we(a,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&we(a,r,o);const{ownerDocument:f}=e,c=S=>{const L=S.target===f?f.scrollingElement:S.target;if(!(L instanceof Element))return;const E=s.get(L);E!==void 0&&(L.scrollTop!==E.top||L.scrollLeft!==E.left)&&g()},g=()=>{a.disconnect();for(const S of xe)f.removeEventListener(S,g,!0);f.removeEventListener("scroll",c,!0),U.get(e)===g&&U.delete(e)};for(const S of xe)f.addEventListener(S,g,{capture:!0,passive:!0});f.addEventListener("scroll",c,{capture:!0,passive:!0}),U.set(e,g)},ke=(e,n)=>{const t=e.querySelector(`[${W}="${n}"]`);return t instanceof HTMLElement?(K(e,n,null),t.focus({preventScroll:!0}),!0):!1},ce=(e,n)=>{const t=e.querySelector(`[${Y}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ce(e,n))return null;const t=[...e.querySelectorAll(`[${W}]`)].map(l=>l.getAttribute(W)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Oe=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&ke(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&ke(t,n)})},$n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(K(o,n,t&&ce(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const l=o.querySelector(`[${W}="${n}"]`);l instanceof HTMLElement&&l.focus({preventScroll:!0})})},Gn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r}=k.useExplorer(),{maximize:s}=re(),l=t.multiView.columns,a=z(e,w=>w.layout),f=z(e,w=>w.visibleColumns),c=z(e,w=>w.titles),g=z(e,w=>w.layout.maximized!==null||w.splitDragging),[S,L]=u.useState(!1),[E]=u.useState(()=>Se(f)),d=u.useMemo(()=>In(o),[o]),p=u.useCallback(w=>{e.arrange(Nn(e.getSnapshot().layout,w))},[e]),m=D.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:p}),{columnPanels:O,setColumnPanels:x}=m,T=u.useRef(g),h=u.useRef(O);u.useLayoutEffect(()=>{T.current=g,h.current=O},[g,O]);const b=u.useCallback(w=>{const C=n.current;if(C===null)return;const{plan:q,stageBlockSize:_}=gn(C,l);if(Number.isFinite(_)&&_>0&&C.style.setProperty(ie,`${String(_)}px`),T.current&&!w)return;const H=B.replanVisibleColumns(e.getSnapshot().visibleColumns,q);H!==null&&e.setVisibleColumns(H)},[e,n,l]);u.useLayoutEffect(()=>{b(!0),L(!0)},[b]),u.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let C=null;const q=new ResizeObserver(()=>{C===null&&(C=requestAnimationFrame(()=>{C=null,b(!1)}))}),_=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,H=w.querySelector(`[${le}]`);return _ instanceof Element&&q.observe(_),H instanceof Element&&q.observe(H),()=>{q.disconnect(),C!==null&&cancelAnimationFrame(C)}},[n,b]),u.useEffect(()=>{g||b(!1)},[g,b]);const y=u.useMemo(()=>S?Rn(a,{logical:l,visible:f}):Se(f),[S,a,l,f]);u.useLayoutEffect(()=>{Vn(h.current,y)||x(y)},[y,x]);const P=u.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),N=u.useMemo(()=>a.docs.map(w=>{const C=G(a,w);return{id:C,component:Tn,title:se(c,w),props:{docPath:w,panelId:C},minHeight:jn,maxHeight:Fn}}),[a,c]),I=u.useMemo(()=>Object.fromEntries(a.docs.map(w=>[G(a,w),!a.hidden.has(w)])),[a]),i=a.maximized===null?null:G(a,a.maximized),v=u.useCallback(w=>{const{layout:C}=e.getSnapshot();for(const[q,_]of $(C)){const H=w[q];if(H===void 0||H!==C.hidden.has(_))continue;const ae=e.titleOf(_);if(H){if(!e.setHidden(_,!1))continue;r.announce(o.panelShown(ae)),ze(n,q);continue}const ue=n.current,de=ue===null?null:Ee(ue,q);e.setHidden(_,!0)&&(r.announce(o.panelHidden(ae)),de!==null&&Oe(n,de))}},[e,n,r,o]),M=u.useCallback(w=>{const C=$(e.getSnapshot().layout).get(w);if(C===void 0)return;const q=e.titleOf(C),_=n.current,H=_===null?null:Ee(_,w);e.close(C)&&(r.announce(o.panelClosed(q)),H!==null&&Oe(n,H))},[e,n,r,o]),A=u.useCallback(w=>{if(w===null){s(null);return}const C=$(e.getSnapshot().layout).get(w);C!==void 0&&s(C)},[e,s]);return R.jsx("div",{className:"aqmx-multi-layout","aria-busy":!S,children:R.jsx(D.DragDropLayout,{columns:P,panels:N,columnPanels:O,onColumnPanelsChange:p,panelVisibility:I,onPanelVisibilityChange:v,dragState:m.dragState,dragOverPosition:m.dragOverPosition,originalPanelPosition:m.originalPanelPosition,dragModes:m.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:m.panelSizes,customDrag:m.customDrag,setPanelRef:m.setPanelRef,onDragStart:m.handleDragStart,onDragEnd:m.handleDragEnd,onPlaceholderDragEnter:m.handlePlaceholderDragEnter,onPlaceholderDragLeave:m.handlePlaceholderDragLeave,onDragOverWithInsert:m.handleDragOverWithInsert,onDropWithInsert:m.handleDropWithInsert,onColumnDragLeave:m.handleColumnDragLeave,onPanelMouseDown:m.handleMouseDown,onPanelSizeInfoClick:m.handlePanelSizeInfoClick,onToggleDragMode:m.toggleDragMode,onPanelClose:M,onPanelMaximizeChange:A,maximizedPanel:i,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Hn,renderStageScrollBar:qn})})},ee={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Yn=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(l=>{const a=n.ownerDocument.elementsFromPoint(s,l),f=a.findIndex(g=>n.contains(g)),c=a.findIndex(g=>e.contains(g));return f!==-1&&c!==-1&&c<f}))},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(ee.blockStart,`${String(t.top)}px`),e.style.setProperty(ee.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(ee.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Kn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:l,announcer:a}=k.useExplorer(),f=u.useRef(null),c=u.useRef(null),g=z(e,h=>h.ready),S=z(e,h=>h.layout.docs.length>0),L=z(e,h=>h.visibleColumns),E=u.use(ne.SheetNoticeSlotContext),d=u.useCallback(h=>{const{layout:b}=e.getSnapshot(),y=b.maximized,P=h===null&&y!==null?b.panelIds.get(y):void 0,N=f.current,I=P!==void 0&&N!==null&&ce(N,P);e.maximize(h)&&(h!==null?a.announce(l.panelMaximized(e.titleOf(h))):y!==null&&a.announce(l.panelRestored(e.titleOf(y))),P!==void 0&&$n(f,P,I))},[e,a,l]),p=u.useCallback((h,b,y,P)=>{if(y===b){e.setPendingHash(h,P);return}const N=e.navigate(b,y);if(N==="navigated"){e.setPendingHash(h,P);return}if(N!=="existing")return;const{layout:I}=e.getSnapshot(),i=I.panelIds.get(y);i!==void 0&&(a.announce(l.panelAlreadyOpen(e.titleOf(y))),I.maximized===null?e.setHidden(y,!1):d(y),e.setPendingHash(i,P),ze(f,i))},[e,a,l,d]);u.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const h=c.current,b=f.current;if(h===null||b===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Wn(h,b)},[t,E]),u.useEffect(()=>{const h=c.current;if(t===null||h===null)return;const{ownerDocument:b}=h;let y=null;const P=N=>{const I=N.target;I instanceof Element&&(y!==null&&cancelAnimationFrame(y),y=requestAnimationFrame(()=>{y=null,b.activeElement===I&&h.isConnected&&Yn(h,I)&&o()}))};return b.addEventListener("focusin",P,!0),()=>{b.removeEventListener("focusin",P,!0),y!==null&&cancelAnimationFrame(y)}},[t,E,o]),u.useImperativeHandle(r,()=>({bringIntoView:h=>{requestAnimationFrame(()=>{const b=f.current,y=e.getSnapshot().layout.panelIds.get(h);b!==null&&y!==void 0&&K(b,y,null)})}}),[e]),u.useEffect(()=>{const h=f.current;return()=>{h!==null&&U.get(h)?.()}},[]);const m=u.useCallback((h,b)=>{const y=f.current;y!==null&&K(y,h,b)},[]),[O]=u.useState(Ve),x=u.useMemo(()=>({store:e,Body:n,followLink:p,maximize:d,revealInPanel:m,focusCarry:O}),[e,n,p,d,m,O]),T=u.useMemo(()=>Array.from({length:s.multiView.columns},(h,b)=>D.generateColumnId(b)),[s]);return R.jsxs("section",{ref:f,className:"aqmx-multi-stage",style:Dn,tabIndex:-1,"aria-label":l.multiRegion,"aria-busy":S&&!g,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":L,children:[R.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[le]:""}),S?g?R.jsx(Ce,{value:x,children:R.jsx(Gn,{store:e,stageRef:f})}):R.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:T.map(h=>R.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]},h))}):R.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:R.jsx("p",{className:"aqmx-empty-title",children:l.multiEmpty})}),t===null?null:E!==null?Be.createPortal(R.jsx("div",{ref:c,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):R.jsx("div",{ref:c,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},oe=(e,n,t)=>{const o=new Set(e),r=n.filter(l=>!o.has(l)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Jn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Xn=({location:e})=>{const{config:n,labels:t,announcer:o}=k.useExplorer(),r=dn(e),s=z(r,P=>P.layout.docs),l=z(r,P=>P.layout.maximized),a=z(r,P=>P.source),[f,c]=u.useState(()=>({docs:s,latest:oe([],s,null)}));f.docs!==s&&c({docs:s,latest:oe(f.docs,s,f.latest)});const g=l!==null?l:f.latest,[S,L]=u.useState(!1),E=u.useRef(null),[d,p]=u.useState(0),m=u.useRef(null),O=u.useRef(null);u.useLayoutEffect(()=>{const P=m.current;m.current=null,P!==null&&(r.whenUrlRendered(()=>o.announce(P.announcement)),O.current?.bringIntoView(P.doc))}),u.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const x=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),L(!0),E.current=setTimeout(()=>{E.current=null,L(!1)},He)},[]),T=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,L(!1)},[]),h=u.useCallback(P=>{const N=r.titleOf(P),I=r.toggle(P);I==="rejected"&&x();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Jn(t,I,N);if(I==="shown"){m.current={doc:P,announcement:i},p(v=>v+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&O.current?.bringIntoView(P)})},[r,x,o,t,n]),b=u.useMemo(()=>new Set(s),[s]),y=u.useMemo(()=>({href:B.explorerHref(n,{view:"tree",source:a,doc:qe(s,l)}),target:"tree"}),[n,a,s,l]);return R.jsx(ne.ExplorerSplit,{view:"multi",explorer:R.jsx(ne.ExplorerPane,{mode:"multi",sourceId:a,currentPath:g,openPaths:b,onOpenDocument:h,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:y}),content:R.jsx(Kn,{ref:O,store:r,body:fn,limitNotice:S?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:T}),contentCoversPage:l!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Xn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=oe;exports.treeSwitchDocument=qe;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as re, jsx as T } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as Ge, use as Me, useRef as B, useState as V, useLayoutEffect as q, useMemo as _, useSyncExternalStore as We, useCallback as D, memo as Ke, useEffect as $, useImperativeHandle as Je } from "react";
|
|
3
|
-
import { g as se, e as Te, h as Xe, P as Ze, j as Qe } from "./location-
|
|
4
|
-
import { c as en, u as G, e as nn, I as tn, D as on, b as rn, f as ln, L as Le } from "./index-
|
|
5
|
-
import { S as sn, a as an, b as cn } from "./ExplorerSplit-
|
|
3
|
+
import { g as se, e as Te, h as Xe, P as Ze, j as Qe } from "./location-CtM94G0O.js";
|
|
4
|
+
import { c as en, u as G, e as nn, I as tn, D as on, b as rn, f as ln, L as Le } from "./index-gJp1iXTc.js";
|
|
5
|
+
import { S as sn, a as an, b as cn } from "./ExplorerSplit-CN5TvRj6.js";
|
|
6
6
|
import { SCROLL_AREA_SELECTOR as Ie, SCROLL_ROOT_SELECTOR as Q, generateColumnIds as un, sortColumnIds as Ae, generateColumnId as De, NO_PANEL_DRAG_ATTRIBUTE as dn, useDragDropColumns as mn, DEFAULT_DEBUG_CONFIG as ge, DragDropLayout as fn } from "@aiquants/drag-drop-panels";
|
|
7
7
|
import { useNavigate as pn, useLocation as gn } from "react-router";
|
|
8
8
|
import { s as hn, r as vn, w as wn } from "./storage-DA4ItHzl.js";
|
|
9
|
-
import { v as yn, i as Sn } from "./dataRoute-
|
|
9
|
+
import { v as yn, i as Sn } from "./dataRoute-Ce6EIuu4.js";
|
|
10
10
|
import { createPortal as xn } from "react-dom";
|
|
11
11
|
import { HostedScrollArea as En } from "@aiquants/markdown";
|
|
12
12
|
import { N as bn } from "./scrollBarGeometry-DOBdGNV-.js";
|