@aiquants/markdown-explorer 0.35.0 → 0.36.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 +93 -0
- package/README.md +31 -2
- package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
- package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
- package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
- package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
- package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
- package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
- package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
- package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
- package/dist/TreeLayout-DsSKW_Qj.js +103 -0
- package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
- package/dist/core/config.d.cts +6 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/contracts.d.cts +21 -0
- package/dist/core/contracts.d.ts +21 -0
- package/dist/core/dataRoute.d.cts +5 -1
- package/dist/core/dataRoute.d.ts +5 -1
- package/dist/core/documentId.d.cts +6 -0
- package/dist/core/documentId.d.ts +6 -0
- package/dist/core/labels.d.cts +10 -0
- package/dist/core/labels.d.ts +10 -0
- package/dist/core/location.d.cts +21 -0
- package/dist/core/location.d.ts +21 -0
- package/dist/explorerCore-B3RGmMG6.js +1083 -0
- package/dist/explorerCore-CUkyKtm8.cjs +1 -0
- package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
- package/dist/index-lpL7GltU.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +38 -33
- package/dist/location-Dh6K-y7w.js +761 -0
- package/dist/location-DrOP6t1F.cjs +1 -0
- package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
- package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
- package/dist/ownUrls-BTPGNhBt.cjs +1 -0
- package/dist/ownUrls-DD0cSCsF.js +409 -0
- package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
- package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
- package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
- package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +3 -3
- package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
- package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +19 -0
- package/dist/server/ports.d.ts +19 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +6 -6
- package/dist/serverBrowser.cjs +1 -1
- package/dist/serverBrowser.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +4 -4
- package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
- package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +80 -2
- package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
- package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/security.md +23 -2
- package/docs/behavior/url-contract.md +26 -0
- package/package.json +2 -2
- package/dist/TreeLayout-AxLw-36S.js +0 -103
- package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
- package/dist/explorerCore-DLpDuSev.js +0 -998
- package/dist/explorerCore-DYrxS9ez.cjs +0 -1
- package/dist/index-LQWQfpAf.cjs +0 -18
- package/dist/location--KvTA0Ri.js +0 -726
- package/dist/location-D8DyDkuA.cjs +0 -1
- package/dist/ownUrls-B259RGgd.cjs +0 -1
- package/dist/ownUrls-Dh5g6ZJi.js +0 -370
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*! Bundled third-party code: @heroicons/react 2.2.0 (MIT, ./licenses/@heroicons/react/LICENSE) */
|
|
2
|
-
import { jsx as u, jsxs as
|
|
3
|
-
import { u as D, a2 as ht, x as Yt, a3 as Ze, c as xt, W as wt, a4 as Qt, a5 as Jt, a6 as en, K as ze, a7 as tn, a8 as nn, p as rn, a9 as an, aa as ln, ab as on, ac as gt, ad as sn } from "./index-
|
|
2
|
+
import { jsx as u, jsxs as k, Fragment as pt } from "react/jsx-runtime";
|
|
3
|
+
import { u as D, a2 as ht, x as Yt, a3 as Ze, c as xt, W as wt, a4 as Qt, a5 as Jt, a6 as en, K as ze, a7 as tn, a8 as nn, p as rn, a9 as an, aa as ln, ab as on, ac as gt, ad as sn } from "./index-D0l_BJqb.js";
|
|
4
4
|
import * as m from "react";
|
|
5
5
|
import { use as Re, createContext as qe, useState as F, useCallback as g, useMemo as _, useRef as E, useLayoutEffect as I, useEffect as B, useSyncExternalStore as Ve, Suspense as vt, useId as Pe } from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { x as cn, y as dn, z as un, A as bt, B as fn, D as mn, G as pn, H as at, I as hn, J as xn, n as Ce, C as wn, F as gn, K as vn } from "./location-Dh6K-y7w.js";
|
|
7
7
|
import { useHref as lt, useLocation as bn, useNavigationType as En } from "react-router";
|
|
8
|
-
import {
|
|
8
|
+
import { V as ot } from "./ownUrls-DD0cSCsF.js";
|
|
9
9
|
import { useDirectoryTreeState as Rn, DirectoryTree as yn } from "@aiquants/directory-tree";
|
|
10
|
-
import { TOUCH_TAP_SCROLL_CIRCLE as Sn, TAP_SCROLL_CIRCLE as Tn } from "./tapScrollCircle-
|
|
10
|
+
import { TOUCH_TAP_SCROLL_CIRCLE as Sn, TAP_SCROLL_CIRCLE as Tn } from "./tapScrollCircle-smKLgRa2.js";
|
|
11
11
|
import { s as On } from "./storage-D1uSw-xj.js";
|
|
12
12
|
import { d as Et } from "./describeValue-CLlVRO8d.js";
|
|
13
13
|
import { PanelGroup as Nn, Panel as st, PanelResizeHandle as An } from "@aiquants/resize-panels";
|
|
14
|
-
import { t as
|
|
14
|
+
import { t as Ln, u as kn } from "./useSplitPersistence-pnb21dsr.js";
|
|
15
15
|
function Cn({
|
|
16
16
|
title: e,
|
|
17
17
|
titleId: t,
|
|
@@ -108,7 +108,7 @@ const Dn = /* @__PURE__ */ m.forwardRef(In), Hn = "http://path.invalid", Bn = /[
|
|
|
108
108
|
const { notices: e, config: t } = D(), n = Re(e), r = lt(t.basePath), l = lt(t.dataPath);
|
|
109
109
|
return n.length === 0 ? null : /* @__PURE__ */ u("div", { className: "aqmx-explorer-notices", children: n.map((s) => {
|
|
110
110
|
const a = s.action === void 0 ? null : $n(s.action.href, r, l, t.basePath);
|
|
111
|
-
return /* @__PURE__ */
|
|
111
|
+
return /* @__PURE__ */ k("div", { className: "aqmx-callout", "data-aqmx-tone": s.tone, "data-testid": "markdown-explorer-notice", "data-aqmx-notice": s.id, children: [
|
|
112
112
|
/* @__PURE__ */ u("p", { className: "aqmx-callout-title", children: s.title }),
|
|
113
113
|
s.body === void 0 ? null : /* @__PURE__ */ u("p", { className: "aqmx-callout-body", children: s.body }),
|
|
114
114
|
s.action === void 0 ? null : a === null ? (
|
|
@@ -368,13 +368,13 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
368
368
|
}
|
|
369
369
|
C.phase === "opening" && x.current?.progress(C.folders, O) !== "loading" && S();
|
|
370
370
|
}));
|
|
371
|
-
}, [e, t, b, S]),
|
|
371
|
+
}, [e, t, b, S]), L = g(() => {
|
|
372
372
|
d.current = !1, c.current = dt, A();
|
|
373
373
|
}, [A]);
|
|
374
374
|
B(() => {
|
|
375
375
|
const N = t.current;
|
|
376
376
|
if (N === null) return;
|
|
377
|
-
const O = typeof ResizeObserver > "u" ? null : new ResizeObserver(
|
|
377
|
+
const O = typeof ResizeObserver > "u" ? null : new ResizeObserver(L);
|
|
378
378
|
O?.observe(N);
|
|
379
379
|
for (const M of it) N.addEventListener(M, S, { passive: !0 });
|
|
380
380
|
return () => {
|
|
@@ -382,7 +382,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
382
382
|
for (const M of it) N.removeEventListener(M, S);
|
|
383
383
|
p.current !== null && cancelAnimationFrame(p.current), p.current = null, b();
|
|
384
384
|
};
|
|
385
|
-
}, [t,
|
|
385
|
+
}, [t, L, S, b]);
|
|
386
386
|
const y = r !== null;
|
|
387
387
|
B(() => {
|
|
388
388
|
const N = t.current;
|
|
@@ -392,13 +392,13 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
392
392
|
if (y && O !== null) {
|
|
393
393
|
const M = new AbortController(), C = { phase: "asking", controller: M };
|
|
394
394
|
i.current = C, O.ancestors(n, M.signal).then((R) => {
|
|
395
|
-
i.current === C && (R === null ? i.current = null : (i.current = { phase: "opening", folders: R }, x.current?.open(R)),
|
|
395
|
+
i.current === C && (R === null ? i.current = null : (i.current = { phase: "opening", folders: R }, x.current?.open(R)), L());
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
|
-
|
|
399
|
-
}, [n, y, t, S,
|
|
400
|
-
(i.current?.phase === "opening" || f.current !== null && !d.current) &&
|
|
401
|
-
}, [l,
|
|
398
|
+
L();
|
|
399
|
+
}, [n, y, t, S, L]), B(() => {
|
|
400
|
+
(i.current?.phase === "opening" || f.current !== null && !d.current) && L();
|
|
401
|
+
}, [l, L]);
|
|
402
402
|
const z = E(s);
|
|
403
403
|
B(() => {
|
|
404
404
|
z.current !== s && (z.current = s, S());
|
|
@@ -428,8 +428,8 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
428
428
|
f?.disconnect();
|
|
429
429
|
};
|
|
430
430
|
}, [e, t, n]), r;
|
|
431
|
-
}, At = "markdown-explorer-tree-scroll", wr = 0.5,
|
|
432
|
-
const n =
|
|
431
|
+
}, At = "markdown-explorer-tree-scroll", wr = 0.5, Lt = (e, t) => [...e.querySelectorAll(`[role="treeitem"][${se}]`)].find((n) => n.getAttribute(se) === t), gr = (e, t) => {
|
|
432
|
+
const n = Lt(e, t), r = n?.closest(`[data-testid="${At}"]`);
|
|
433
433
|
if (n === void 0 || r === null || r === void 0) return Number.POSITIVE_INFINITY;
|
|
434
434
|
const l = r.getBoundingClientRect(), s = n.getBoundingClientRect(), a = l.top - s.top, o = s.height > l.height ? Math.abs(a) : Math.max(0, a) + Math.max(0, s.bottom - l.bottom);
|
|
435
435
|
return o <= wr ? 0 : o;
|
|
@@ -453,14 +453,14 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
453
453
|
...Jt,
|
|
454
454
|
tapScrollCircleOptions: Sn
|
|
455
455
|
})
|
|
456
|
-
}), br = (e) => e ? vr : $e, Er = { hoverClassName: "", directorySelectedClassName: "", itemSelectedClassName: "" }, Rr = { color: "inherit", fontSize: "inherit" }, yr = { fontSize: "inherit" }, Sr = /* @__PURE__ */ new Set(), Tr = /* @__PURE__ */ new Map(), Or = { color: "var(--aqmx-tree-line)" },
|
|
457
|
-
const t =
|
|
456
|
+
}), br = (e) => e ? vr : $e, Er = { hoverClassName: "", directorySelectedClassName: "", itemSelectedClassName: "" }, Rr = { color: "inherit", fontSize: "inherit" }, yr = { fontSize: "inherit" }, Sr = /* @__PURE__ */ new Set(), Tr = /* @__PURE__ */ new Map(), Or = { color: "var(--aqmx-tree-line)" }, kt = (e) => e instanceof Element ? e.closest(`[${se}]`) : null, Nr = (e) => {
|
|
457
|
+
const t = kt(e);
|
|
458
458
|
return t === null || t.getAttribute("data-entry-type") !== "file" ? null : t.getAttribute(se);
|
|
459
459
|
}, Ct = (e, t, n, r) => n === "folder-limit" ? e.expandAllFolderLimit(r, t.maxFolders, e.expandAll) : e.expandAllDepthLimit(r, t.maxDepth), Ar = (e, t, n) => n.kind === "done" ? e.expandAllDone(n.opened, n.failed, n.complete) : Ct(e, t, n.kind, n.opened), qt = () => {
|
|
460
460
|
const { labels: e } = D();
|
|
461
|
-
return /* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ k("div", { className: "aqmx-explorer-loading", "aria-busy": "true", "data-testid": "markdown-explorer-tree-loading", children: [
|
|
462
462
|
/* @__PURE__ */ u("p", { className: "aqmx-explorer-loading-text", children: e.treeLoading }),
|
|
463
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ k("div", { className: "aqmx-skeleton", "aria-hidden": "true", children: [
|
|
464
464
|
/* @__PURE__ */ u("span", {}),
|
|
465
465
|
/* @__PURE__ */ u("span", {}),
|
|
466
466
|
/* @__PURE__ */ u("span", {}),
|
|
@@ -468,19 +468,19 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
468
468
|
/* @__PURE__ */ u("span", {})
|
|
469
469
|
] })
|
|
470
470
|
] });
|
|
471
|
-
},
|
|
471
|
+
}, Lr = () => {
|
|
472
472
|
const { labels: e } = D();
|
|
473
|
-
return /* @__PURE__ */
|
|
473
|
+
return /* @__PURE__ */ k("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-tree-empty", children: [
|
|
474
474
|
/* @__PURE__ */ u(Vn, { className: "aqmx-explorer-empty-icon", "aria-hidden": "true" }),
|
|
475
475
|
/* @__PURE__ */ u("p", { className: "aqmx-empty-title", children: e.treeEmptyTitle }),
|
|
476
476
|
/* @__PURE__ */ u("p", { className: "aqmx-explorer-empty-body", children: e.treeEmptyBody })
|
|
477
477
|
] });
|
|
478
|
-
},
|
|
478
|
+
}, kr = ({ name: e, onRetry: t }) => {
|
|
479
479
|
const { labels: n } = D(), r = Pe();
|
|
480
|
-
return /* @__PURE__ */
|
|
480
|
+
return /* @__PURE__ */ k("span", { className: "aqmx-explorer-folder-failed", children: [
|
|
481
481
|
/* @__PURE__ */ u("span", { className: "aqmx-explorer-folder-name", children: e }),
|
|
482
482
|
/* @__PURE__ */ u("span", { id: r, className: "aqmx-explorer-folder-error", children: n.folderLoadFailed }),
|
|
483
|
-
/* @__PURE__ */
|
|
483
|
+
/* @__PURE__ */ k(
|
|
484
484
|
"button",
|
|
485
485
|
{
|
|
486
486
|
type: "button",
|
|
@@ -521,7 +521,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
521
521
|
expandAll: b,
|
|
522
522
|
revealCancel: S
|
|
523
523
|
}) => {
|
|
524
|
-
const { trees: A, documents:
|
|
524
|
+
const { trees: A, documents: L, labels: y, locale: z, theme: H, paletteKey: N, data: O, config: M, sources: C, reveals: R } = D(), T = Re(je), $ = Re(Rt), [V] = F(() => $?.get(r)), W = br(xt()), ie = _(() => V === void 0 ? W : { ...W, initialScrollAnchor: V }, [W, V]), [de] = F(Xn), te = E(null), { rowHeight: ue, lineColor: ne } = xr(te, H, N), { isExpanded: Y, toggle: j, expandMultiple: Z, collapseMultiple: ye, expanded: re, isPending: fe } = i, { alwaysExpanded: ce, sortMode: ve, folderPlacement: me, readmePlacement: Se } = l, { direct: be, markDirect: Q, unmarkDirect: pe, pruneDirect: Te } = x, { running: he, advance: q } = b, X = E(null), J = E(null);
|
|
525
525
|
I(() => {
|
|
526
526
|
if ($ === null) return;
|
|
527
527
|
const h = X;
|
|
@@ -557,7 +557,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
557
557
|
[oe, Oe]
|
|
558
558
|
), Ge = g((h) => {
|
|
559
559
|
X.current?.scrollToPath(h, { align: "nearest" }), requestAnimationFrame(() => {
|
|
560
|
-
const v = J.current, P = v === null ? void 0 :
|
|
560
|
+
const v = J.current, P = v === null ? void 0 : Lt(v, h);
|
|
561
561
|
P !== void 0 && wt(P);
|
|
562
562
|
});
|
|
563
563
|
}, []), Ht = g(
|
|
@@ -589,7 +589,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
589
589
|
[we, Z, Me]
|
|
590
590
|
), Xe = g(
|
|
591
591
|
(h) => /* @__PURE__ */ u(
|
|
592
|
-
|
|
592
|
+
kr,
|
|
593
593
|
{
|
|
594
594
|
name: h.name,
|
|
595
595
|
onRetry: () => {
|
|
@@ -602,7 +602,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
602
602
|
I(() => {
|
|
603
603
|
Je.current = Ne;
|
|
604
604
|
}, [Ne]);
|
|
605
|
-
const $t = Qt(
|
|
605
|
+
const $t = Qt(L, Nr), et = E([]), Ae = g(() => {
|
|
606
606
|
for (const h of et.current) K.current.unloadedFolders.has(h) && Q(h);
|
|
607
607
|
}, [Q]), { maxDepth: _e } = M.revealDocument, tt = E(c);
|
|
608
608
|
I(() => {
|
|
@@ -630,12 +630,12 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
630
630
|
B(() => Ae(), [Ae, ae]);
|
|
631
631
|
const zt = _(() => [e, t, re], [e, t, re]), Vt = g((h) => J.current === null ? Number.POSITIVE_INFINITY : gr(J.current, h), []);
|
|
632
632
|
ur({ tree: X, container: J, path: s.path, chain: s.openFolders ? Zt : null, rows: zt, cancel: S, displayed: T, placement: Vt });
|
|
633
|
-
const nt = g((h) => be.has(h), [be]),
|
|
633
|
+
const nt = g((h) => be.has(h), [be]), Le = _(() => Qn(e, { isShownExpanded: le, childrenOf: ee, compare: xe, isDirect: nt }), [e, le, ee, xe, nt, t]), ke = T && w;
|
|
634
634
|
I(() => {
|
|
635
635
|
p(e);
|
|
636
|
-
}, [e, p]), I(() => () => p(null), [p]), B(() => A.claimChildren(r,
|
|
637
|
-
|
|
638
|
-
}, [
|
|
636
|
+
}, [e, p]), I(() => () => p(null), [p]), B(() => A.claimChildren(r, ke ? Le.folders : Tr), [A, r, ke, Le]), B(() => Te(ae), [Te, ae]), B(() => {
|
|
637
|
+
ke && he && q({ entries: e, isShownExpanded: le, childrenOf: ee, compare: xe, expanded: re, waiting: Le.waiting, expansionPending: fe });
|
|
638
|
+
}, [ke, he, q, e, le, ee, xe, re, Le, fe]);
|
|
639
639
|
const jt = g(
|
|
640
640
|
(h) => {
|
|
641
641
|
const v = h.entry.absolutePath, { folderSelection: P, openDocument: U } = K.current;
|
|
@@ -655,7 +655,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
655
655
|
), Kt = g(
|
|
656
656
|
(h) => {
|
|
657
657
|
if (h.key !== "ArrowLeft" && h.key !== "ArrowRight") return;
|
|
658
|
-
const v =
|
|
658
|
+
const v = kt(h.target), P = v === null ? null : v.getAttribute(se);
|
|
659
659
|
P !== null && oe.delete(P);
|
|
660
660
|
},
|
|
661
661
|
[oe]
|
|
@@ -675,7 +675,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
675
675
|
}),
|
|
676
676
|
[y]
|
|
677
677
|
), Xt = ne === null ? { showTreeLines: !1 } : { showTreeLines: l.lines, lineColor: ne };
|
|
678
|
-
return /* @__PURE__ */
|
|
678
|
+
return /* @__PURE__ */ k("div", { ref: J, className: "aqmx-explorer-tree", "data-testid": "markdown-explorer-tree", onKeyDownCapture: Kt, ...$t, children: [
|
|
679
679
|
/* @__PURE__ */ u("span", { ref: te, className: "aqmx-explorer-tree-probe", "aria-hidden": "true", [pr]: "" }),
|
|
680
680
|
/* @__PURE__ */ u(
|
|
681
681
|
yn,
|
|
@@ -730,7 +730,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
730
730
|
return () => clearTimeout(d);
|
|
731
731
|
}, [r, e, l]);
|
|
732
732
|
const o = r && e === 0 ? l : e;
|
|
733
|
-
return o === 0 && r ? null : /* @__PURE__ */
|
|
733
|
+
return o === 0 && r ? null : /* @__PURE__ */ k("p", { className: "aqmx-explorer-tree-progress", "data-testid": "markdown-explorer-tree-progress", "data-aqmx-loading": String(o), "data-aqmx-expand-all": t.state, children: [
|
|
734
734
|
o > 0 ? /* @__PURE__ */ u(Ze, { className: "aqmx-explorer-tree-progress-icon", "aria-hidden": "true" }) : null,
|
|
735
735
|
/* @__PURE__ */ u("span", { children: t.state === "running" ? n.expandAllProgress(t.opened, o) : n.foldersLoading(o) })
|
|
736
736
|
] });
|
|
@@ -739,7 +739,7 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
739
739
|
return /* @__PURE__ */ u("p", { className: "aqmx-explorer-expand-all-stop", "data-testid": "markdown-explorer-expand-all-stop", "data-aqmx-stop": e, children: Ct(r, n, e, t) });
|
|
740
740
|
}, Fr = ({ entries: e, ...t }) => {
|
|
741
741
|
const { trees: n } = D(), r = Ve(n.subscribe, n.version, n.version), { sourceId: l } = t, [s] = F(jn), a = _(() => s(e, (o) => n.children(l, o)), [s, e, n, l, r]);
|
|
742
|
-
return a.length === 0 ? /* @__PURE__ */ u(
|
|
742
|
+
return a.length === 0 ? /* @__PURE__ */ u(Lr, {}) : /* @__PURE__ */ u(Cr, { entries: a, version: r, ...t });
|
|
743
743
|
}, Mr = ({ result: e, onRetry: t, ...n }) => {
|
|
744
744
|
const { renderTreeFailure: r } = D(), l = Re(e);
|
|
745
745
|
if (l.status === "deferred") return /* @__PURE__ */ u(qt, {});
|
|
@@ -751,9 +751,9 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
751
751
|
Ve(n.subscribe, n.version, n.version);
|
|
752
752
|
const d = n.read(o), c = g(() => n.retry(o), [n, o]);
|
|
753
753
|
I(() => n.open(o), [n, o]);
|
|
754
|
-
const i = lr(), { expanded: p, expandMultiple: x, collapseAll: w } = f, [b, S] = F(null), A = b !== p,
|
|
754
|
+
const i = lr(), { expanded: p, expandMultiple: x, collapseAll: w } = f, [b, S] = F(null), A = b !== p, L = E(p);
|
|
755
755
|
I(() => {
|
|
756
|
-
|
|
756
|
+
L.current = p;
|
|
757
757
|
}, [p]);
|
|
758
758
|
const y = a.expandAll, z = g(() => s.announce(l.expandAllStarted), [s, l]), H = g((j) => s.announce(Ar(l, y, j)), [s, l, y]), N = ir({ budget: y, expandMultiple: x, onStart: z, onFinish: H }), { status: O, start: M, end: C, advance: R } = N, T = O.state === "running", $ = _(() => ({ running: T, advance: R }), [T, R]), V = E(null), [W, ie] = F(!1), de = g((j) => {
|
|
759
759
|
V.current = j, ie(j !== null);
|
|
@@ -766,15 +766,15 @@ const Vn = /* @__PURE__ */ m.forwardRef(zn), je = qe(!0), Rt = qe(null), yt = "\
|
|
|
766
766
|
[n, o, s, l]
|
|
767
767
|
);
|
|
768
768
|
const { clearDirect: te } = i, [ue, ne] = F(0), Y = g(() => {
|
|
769
|
-
ne((j) => j + 1), C(), te(), S(
|
|
769
|
+
ne((j) => j + 1), C(), te(), S(L.current), w();
|
|
770
770
|
}, [C, te, w]);
|
|
771
771
|
return B(() => {
|
|
772
772
|
e({ collapseAll: Y, expandAll: W ? M : null, expanding: T });
|
|
773
773
|
}, [e, Y, M, W, T]), B(() => () => e(null), [e]), B(() => {
|
|
774
774
|
W || C();
|
|
775
|
-
}, [W, C]), /* @__PURE__ */
|
|
775
|
+
}, [W, C]), /* @__PURE__ */ k(pt, { children: [
|
|
776
776
|
O.state === "stopped" ? /* @__PURE__ */ u(Pr, { stop: O.stop, opened: O.opened, budget: y }) : null,
|
|
777
|
-
/* @__PURE__ */
|
|
777
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-tree-area", children: [
|
|
778
778
|
/* @__PURE__ */ u(vt, { fallback: /* @__PURE__ */ u(qt, {}), children: /* @__PURE__ */ u(Mr, { result: d, onRetry: c, expansion: f, onShown: de, marks: i, claimsHeld: A, expandAll: $, revealCancel: ue, ...t }) }),
|
|
779
779
|
/* @__PURE__ */ u(qr, { pending: n.pendingChildren(o), status: O })
|
|
780
780
|
] })
|
|
@@ -812,12 +812,12 @@ const Ke = /* @__PURE__ */ m.forwardRef(Ir), ut = "markdown-explorer-selection-r
|
|
|
812
812
|
const i = o.current;
|
|
813
813
|
i !== null && i.contains(i.ownerDocument.activeElement) && l(), n();
|
|
814
814
|
};
|
|
815
|
-
return /* @__PURE__ */
|
|
816
|
-
/* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ k("section", { ref: o, className: "aqmx-explorer-tray", "aria-labelledby": a, "data-testid": "markdown-explorer-selection-tray", children: [
|
|
816
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-tray-header", children: [
|
|
817
817
|
/* @__PURE__ */ u("p", { id: a, className: "aqmx-explorer-tray-title", children: s.selectionTitle(f.length) }),
|
|
818
818
|
/* @__PURE__ */ u("button", { type: "button", className: "aqmx-explorer-tray-button", "data-testid": "markdown-explorer-selection-clear", onClick: c, children: s.clearSelection })
|
|
819
819
|
] }),
|
|
820
|
-
/* @__PURE__ */ u("ul", { className: "aqmx-explorer-tray-list", children: f.map(([i, p]) => /* @__PURE__ */
|
|
820
|
+
/* @__PURE__ */ u("ul", { className: "aqmx-explorer-tray-list", children: f.map(([i, p]) => /* @__PURE__ */ k("li", { className: "aqmx-explorer-tray-item", children: [
|
|
821
821
|
/* @__PURE__ */ u("span", { className: "aqmx-explorer-tray-name", title: i, children: p }),
|
|
822
822
|
/* @__PURE__ */ u(
|
|
823
823
|
"button",
|
|
@@ -1188,7 +1188,7 @@ const ma = /* @__PURE__ */ m.forwardRef(fa), pa = Object.freeze({
|
|
|
1188
1188
|
);
|
|
1189
1189
|
return /* @__PURE__ */ u("div", { ref: s, id: e, role: "menu", "aria-label": a.treeSettings, className: "aqmx-explorer-menu", "data-testid": "markdown-explorer-tree-settings-menu", children: n.map((c, i) => {
|
|
1190
1190
|
const p = pa[c.key], x = Ft(a, c), w = bt(a, t, c.key), b = t[c.key], S = typeof b == "boolean" ? { role: "menuitemcheckbox", "aria-checked": b, "aria-label": x } : { role: "menuitem", "aria-label": `${x}: ${w}` };
|
|
1191
|
-
return /* @__PURE__ */
|
|
1191
|
+
return /* @__PURE__ */ k(
|
|
1192
1192
|
"button",
|
|
1193
1193
|
{
|
|
1194
1194
|
ref: (A) => {
|
|
@@ -1266,9 +1266,9 @@ const ma = /* @__PURE__ */ m.forwardRef(fa), pa = Object.freeze({
|
|
|
1266
1266
|
const { treeSettings: e } = D();
|
|
1267
1267
|
return { settings: Ve(e.subscribe, e.getSnapshot, e.getServerSnapshot), advance: e.advance };
|
|
1268
1268
|
}, ft = /* @__PURE__ */ new Set(), ga = '[role="tree"] [role="treeitem"][tabindex="0"]', va = "[data-directory-tree-tab-stop]", za = (e) => {
|
|
1269
|
-
const { mode: t, sourceId: n, currentPath: r, openPaths: l, onOpenDocument: s, onSourceChange: a, onRevealSource: o, viewSwitch: f } = e, { labels: d, sources: c, trees: i, documents: p, announcer: x, reveals: w } = D(), { settings: b, advance: S } = wa(), A = _(() => fn(t), [t]),
|
|
1270
|
-
$r(
|
|
1271
|
-
const y = e.mode === "tree" ? e.tray.onGatheredChange : null, z = e.mode === "tree" ? e.onOpenSelection : void 0, H = e.mode === "tree" ? e.onOpenFolder : null, N = e.mode === "tree" ? e.onCloseFolder : null, O = e.mode === "tree" && e.currentFolder, M = _(() => H === null || N === null || !b.showFolderReadme ? null : { current: r, open: H, close: N }, [H, N, r, b.showFolderReadme]), C = e.mode === "tree" &&
|
|
1269
|
+
const { mode: t, sourceId: n, currentPath: r, openPaths: l, onOpenDocument: s, onSourceChange: a, onRevealSource: o, viewSwitch: f } = e, { labels: d, sources: c, trees: i, documents: p, announcer: x, reveals: w } = D(), { settings: b, advance: S } = wa(), A = _(() => fn(t), [t]), L = t === "tree" && b.selectionMode === "multiple";
|
|
1270
|
+
$r(L);
|
|
1271
|
+
const y = e.mode === "tree" ? e.tray.onGatheredChange : null, z = e.mode === "tree" ? e.onOpenSelection : void 0, H = e.mode === "tree" ? e.onOpenFolder : null, N = e.mode === "tree" ? e.onCloseFolder : null, O = e.mode === "tree" && e.currentFolder, M = _(() => H === null || N === null || !b.showFolderReadme ? null : { current: r, open: H, close: N }, [H, N, r, b.showFolderReadme]), C = e.mode === "tree" && L ? e.tray.gathered : He, R = g(
|
|
1272
1272
|
(q) => {
|
|
1273
1273
|
const X = S(q);
|
|
1274
1274
|
return X.selectionMode !== "multiple" && y?.(He), X;
|
|
@@ -1305,12 +1305,12 @@ const ma = /* @__PURE__ */ m.forwardRef(fa), pa = Object.freeze({
|
|
|
1305
1305
|
}
|
|
1306
1306
|
}
|
|
1307
1307
|
}, [i, p, n, x, d]), be = Z === null ? null : Z.expandAll, Q = Z?.expanding === !0, pe = c.find((q) => q.id === n), Te = f.target === "multi" ? Dn : _n, he = f.target === "multi" ? d.switchToMulti : d.switchToTree;
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
/* @__PURE__ */
|
|
1308
|
+
return /* @__PURE__ */ k("nav", { ref: ie, "aria-label": d.explorerRegion, className: "aqmx-explorer", "data-testid": "markdown-explorer-explorer", "data-aqmx-mode": t, children: [
|
|
1309
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-header", children: [
|
|
1310
1310
|
c.length > 1 ? /* @__PURE__ */ u("select", { className: "aqmx-explorer-source", "aria-label": d.sourceLabel, title: pe?.label, value: n, onChange: (q) => j(q.currentTarget.value), "data-testid": "markdown-explorer-source-select", children: c.map((q) => /* @__PURE__ */ u("option", { value: q.id, children: q.label }, q.id)) }) : null,
|
|
1311
|
-
/* @__PURE__ */
|
|
1311
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-actions", children: [
|
|
1312
1312
|
/* @__PURE__ */ u(ht, { to: f.href, navigation: "switch-view", className: "aqmx-icon-button", "aria-label": he, title: he, "data-testid": "markdown-explorer-view-switch", "data-aqmx-target": f.target, children: /* @__PURE__ */ u(Te, { "aria-hidden": "true" }) }),
|
|
1313
|
-
/* @__PURE__ */
|
|
1313
|
+
/* @__PURE__ */ k(
|
|
1314
1314
|
"button",
|
|
1315
1315
|
{
|
|
1316
1316
|
type: "button",
|
|
@@ -1348,11 +1348,11 @@ const ma = /* @__PURE__ */ m.forwardRef(fa), pa = Object.freeze({
|
|
|
1348
1348
|
T.trigger
|
|
1349
1349
|
] })
|
|
1350
1350
|
] }),
|
|
1351
|
-
/* @__PURE__ */
|
|
1351
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-body", "data-aqmx-explorer-body": "", children: [
|
|
1352
1352
|
ce !== null && ce.sourceId === n ? /* @__PURE__ */ u("p", { role: "alert", className: "aqmx-explorer-refresh-failure", "data-testid": "markdown-explorer-refresh-failure", "data-aqmx-failure": ce.failure.reason, children: d.treeRefreshFailed(rn(d, ce.failure.reason)) }) : null,
|
|
1353
1353
|
/* @__PURE__ */ u(vt, { fallback: null, children: /* @__PURE__ */ u(Zn, {}) }),
|
|
1354
1354
|
/* @__PURE__ */ u(_r, { mode: t, sourceId: n, settings: b, reveal: Y, openPaths: l, selection: ne, onOpenDocument: s, folders: M, onRevealSource: o, onControls: ye }, n),
|
|
1355
|
-
|
|
1355
|
+
L && C.size > 0 ? /* @__PURE__ */ u(Dr, { selection: C, onRemove: V, onClear: W, onOpenSelection: z, onLeave: de }) : null,
|
|
1356
1356
|
T.menu
|
|
1357
1357
|
] })
|
|
1358
1358
|
] });
|
|
@@ -1383,9 +1383,9 @@ const Mt = /* @__PURE__ */ m.forwardRef(ba), Ea = ({ explorer: e, toggleRef: t,
|
|
|
1383
1383
|
p.navigated !== o && (x({ navigated: o, source: d.source }), p.source === d.source && !w && ln(f, o.state) !== "close-folder" && i(!1));
|
|
1384
1384
|
const [S, A] = F(s);
|
|
1385
1385
|
S !== s && (A(s), i(!1));
|
|
1386
|
-
const
|
|
1386
|
+
const L = E(null), y = E(null), z = E(null), H = E(!1), N = Pe();
|
|
1387
1387
|
I(() => {
|
|
1388
|
-
const T =
|
|
1388
|
+
const T = L.current;
|
|
1389
1389
|
T !== null && (c && !T.open ? (T.showModal(), y.current?.focus()) : !c && T.open && (T.close(), t.current?.focus()), l(c ? z.current : null));
|
|
1390
1390
|
}, [c, t, l]), I(() => () => l(null), [l]);
|
|
1391
1391
|
const O = g((T) => {
|
|
@@ -1398,13 +1398,13 @@ const Mt = /* @__PURE__ */ m.forwardRef(ba), Ea = ({ explorer: e, toggleRef: t,
|
|
|
1398
1398
|
}, []), R = g(() => {
|
|
1399
1399
|
i(!1);
|
|
1400
1400
|
}, []);
|
|
1401
|
-
return /* @__PURE__ */
|
|
1402
|
-
/* @__PURE__ */ u("div", { className: "aqmx-sheet-bar", inert: n, "data-testid": "markdown-explorer-sheet-bar", "data-aqmx-sheet-bar-merged": r ? "true" : "false", children: /* @__PURE__ */
|
|
1401
|
+
return /* @__PURE__ */ k(pt, { children: [
|
|
1402
|
+
/* @__PURE__ */ u("div", { className: "aqmx-sheet-bar", inert: n, "data-testid": "markdown-explorer-sheet-bar", "data-aqmx-sheet-bar-merged": r ? "true" : "false", children: /* @__PURE__ */ k("button", { ref: t, type: "button", className: "aqmx-explorer-toggle", title: r ? a.showExplorer : void 0, "aria-haspopup": "dialog", "aria-expanded": c, "aria-controls": N, "data-testid": "markdown-explorer-sheet-toggle", onClick: () => i(!0), children: [
|
|
1403
1403
|
/* @__PURE__ */ u(Mt, { "aria-hidden": "true" }),
|
|
1404
1404
|
/* @__PURE__ */ u("span", { className: r ? "aqmx-sr-only" : void 0, children: a.showExplorer })
|
|
1405
1405
|
] }) }),
|
|
1406
|
-
/* @__PURE__ */ u("dialog", { ref:
|
|
1407
|
-
/* @__PURE__ */
|
|
1406
|
+
/* @__PURE__ */ u("dialog", { ref: L, id: N, className: "aqmx-sheet", "aria-label": a.explorerRegion, "data-testid": "markdown-explorer-sheet", onKeyDown: O, onPointerDown: M, onClick: C, onClose: R, children: /* @__PURE__ */ k("div", { className: "aqmx-sheet-panel", children: [
|
|
1407
|
+
/* @__PURE__ */ k("div", { className: "aqmx-explorer-chrome", children: [
|
|
1408
1408
|
/* @__PURE__ */ u("div", { ref: z, className: "aqmx-sheet-notice-slot" }),
|
|
1409
1409
|
/* @__PURE__ */ u("button", { ref: y, type: "button", className: "aqmx-explorer-close", "aria-label": a.hideExplorer, title: a.hideExplorer, "data-testid": "markdown-explorer-sheet-close", onClick: () => i(!1), children: /* @__PURE__ */ u(Ke, { "aria-hidden": "true" }) })
|
|
1410
1410
|
] }),
|
|
@@ -1496,26 +1496,26 @@ const Mt = /* @__PURE__ */ m.forwardRef(ba), Ea = ({ explorer: e, toggleRef: t,
|
|
|
1496
1496
|
});
|
|
1497
1497
|
}, [e, t, n, r, l, s]);
|
|
1498
1498
|
}, Aa = (e) => e === "tree" ? "treeExplorerHidden" : "multiExplorerHidden", Va = ({ view: e, explorer: t, content: n, contentCoversPage: r = !1, sheetDismissals: l = 0, onDraggingChange: s }) => {
|
|
1499
|
-
const { viewSettings: a } = D(), o = E(null), [f, d] = F(null), c = E(null), i = E(null), p = E(null), x = E(null), { inlineSize: w, rootFontPixels: b } = Oa(o, c), S = Aa(e), A = gt((R) => R[S] === !0),
|
|
1499
|
+
const { viewSettings: a } = D(), o = E(null), [f, d] = F(null), c = E(null), i = E(null), p = E(null), x = E(null), { inlineSize: w, rootFontPixels: b } = Oa(o, c), S = Aa(e), A = gt((R) => R[S] === !0), L = w !== null && w < mn(b), y = L ? "sheet" : A ? "rail" : "split";
|
|
1500
1500
|
Na(y, { frameRef: o, sheetToggleRef: i, railToggleRef: p, closeButtonRef: x, handleId: It(e) });
|
|
1501
|
-
const z = g(() => a.update({ [S]: !0 }), [a, S]), H = g(() => a.update({ [S]: !1 }), [a, S]), [N, O] = F(!1), M = _(() =>
|
|
1502
|
-
return /* @__PURE__ */ u(Rt, { value: C, children: /* @__PURE__ */
|
|
1501
|
+
const z = g(() => a.update({ [S]: !0 }), [a, S]), H = g(() => a.update({ [S]: !1 }), [a, S]), [N, O] = F(!1), M = _(() => L ? { lane: !r, onBar: O } : null, [L, r]), [C] = F(() => /* @__PURE__ */ new Map());
|
|
1502
|
+
return /* @__PURE__ */ u(Rt, { value: C, children: /* @__PURE__ */ k("div", { ref: o, className: "aqmx-split-frame", "data-aqmx-explorer-mode": y, "data-aqmx-measured": w === null ? "false" : "true", "data-aqmx-content-covers-page": r ? "true" : "false", children: [
|
|
1503
1503
|
/* @__PURE__ */ u("span", { ref: c, className: "aqmx-rem-probe", "aria-hidden": "true", "data-aqmx-rem-probe": "" }),
|
|
1504
|
-
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
y === "rail" ? /* @__PURE__ */ u(
|
|
1507
|
-
/* @__PURE__ */ u(Ra, { value:
|
|
1504
|
+
L ? /* @__PURE__ */ u(Ea, { explorer: t, toggleRef: i, covered: r, merged: N, onNoticeSlotChange: d, dismissals: l }) : null,
|
|
1505
|
+
/* @__PURE__ */ k("div", { className: "aqmx-split-row", children: [
|
|
1506
|
+
y === "rail" ? /* @__PURE__ */ u(La, { toggleRef: p, covered: r, onOpen: H }) : null,
|
|
1507
|
+
/* @__PURE__ */ u(Ra, { value: L ? f : null, children: /* @__PURE__ */ u(sn, { value: M, children: /* @__PURE__ */ u(ka, { view: e, mode: y, explorer: t, content: n, contentCoversPage: r, onDraggingChange: s, explorerMinPixels: pn(b), closeButtonRef: x, onHide: z }) }) })
|
|
1508
1508
|
] })
|
|
1509
1509
|
] }) });
|
|
1510
|
-
},
|
|
1510
|
+
}, La = ({ toggleRef: e, covered: t, onOpen: n }) => {
|
|
1511
1511
|
const { labels: r } = D();
|
|
1512
1512
|
return /* @__PURE__ */ u("div", { className: "aqmx-split-rail", inert: t, "data-testid": "markdown-explorer-rail", children: /* @__PURE__ */ u("button", { ref: e, type: "button", className: "aqmx-explorer-toggle", "aria-expanded": !1, "aria-label": r.showExplorer, title: r.showExplorer, "data-testid": "markdown-explorer-rail-toggle", onClick: n, children: /* @__PURE__ */ u(Mt, { "aria-hidden": "true" }) }) });
|
|
1513
|
-
},
|
|
1514
|
-
const { viewSettings: d, labels: c } = D(), i = _(() =>
|
|
1513
|
+
}, ka = ({ view: e, mode: t, explorer: n, content: r, contentCoversPage: l, onDraggingChange: s, explorerMinPixels: a, closeButtonRef: o, onHide: f }) => {
|
|
1514
|
+
const { viewSettings: d, labels: c } = D(), i = _(() => Ln(c), [c]), x = gt((R) => e === "tree" ? R.treeExplorer : R.multiExplorer) ?? (e === "tree" ? hn : xn), w = E(!1), [b, S] = F(!1), A = E(!1), L = E(s);
|
|
1515
1515
|
I(() => {
|
|
1516
|
-
|
|
1516
|
+
L.current = s;
|
|
1517
1517
|
}, [s]);
|
|
1518
|
-
const y =
|
|
1518
|
+
const y = kn(
|
|
1519
1519
|
g(
|
|
1520
1520
|
(R) => {
|
|
1521
1521
|
if (R.length !== 2) return;
|
|
@@ -1529,7 +1529,7 @@ const Mt = /* @__PURE__ */ m.forwardRef(ba), Ea = ({ explorer: e, toggleRef: t,
|
|
|
1529
1529
|
);
|
|
1530
1530
|
B(
|
|
1531
1531
|
() => () => {
|
|
1532
|
-
w.current &&
|
|
1532
|
+
w.current && L.current?.(!1);
|
|
1533
1533
|
},
|
|
1534
1534
|
[]
|
|
1535
1535
|
);
|
|
@@ -1547,8 +1547,8 @@ const Mt = /* @__PURE__ */ m.forwardRef(ba), Ea = ({ explorer: e, toggleRef: t,
|
|
|
1547
1547
|
},
|
|
1548
1548
|
[s, y, O]
|
|
1549
1549
|
);
|
|
1550
|
-
return /* @__PURE__ */
|
|
1551
|
-
N ? /* @__PURE__ */
|
|
1550
|
+
return /* @__PURE__ */ k(Nn, { id: `aqmx-split-${e}`, direction: "horizontal", onLayout: M, labels: i, className: "aqmx-split", "data-aqmx-split": e, children: [
|
|
1551
|
+
N ? /* @__PURE__ */ k(
|
|
1552
1552
|
st,
|
|
1553
1553
|
{
|
|
1554
1554
|
id: Ue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),Y=require("./describeValue-Ccvhbt36.cjs"),j=require("./location-D8DyDkuA.cjs"),P=require("./index-LQWQfpAf.cjs"),re=require("./ExplorerSplit-D_0VohOv.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-BpYsprog.cjs"),Ce=require("./ownUrls-B259RGgd.cjs"),qe=require("react-dom"),Be=require("@aiquants/markdown"),je=()=>{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}}},Oe=c.createContext(null),ie=()=>{const e=c.use(Oe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Fe=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ve=0xcbf29ce484222325n,Ue=0x100000001b3n,$e=(1n<<64n)-1n,Ge=(1n<<53n)-1n,Ye=new TextEncoder,We=e=>{let n=Ve;for(const t of Ye.encode(e))n=(n^BigInt(t))*Ue&$e;return Number(n&Ge)},Q=256,Ke=e=>`aqmx-p-${We(e).toString(36)}`,be=(e,n)=>{const t=Ke(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Je=new Map,Xe=(e,n=Je)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??be(r,t);t.add(s),o.set(r,s)}return o},Pe=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Te=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([m,g])=>e.slice(m,g).reduce((i,v)=>i+v.length,0);let s=t;for(const m of o)r(m)<r(s)&&(s=m);let a=s[0];for(let m=s[0];m<s[1];m+=1)(e[m]?.length??0)<(e[a]?.length??0)&&(a=m);return a},ee=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Pe(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Te(t,n)]?.push(r);return t},Ze=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Qe=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(y,d)=>{const x=[0];for(const h of e)x.push((x.at(-1)??0)+(t(h)===o+d?1:0));return x}),g=(y,d,x)=>(m[y]?.[x]??0)-(m[y]?.[d]??0),i=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),v=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),C=i[0];C&&(C[0]=0);for(let y=0;y<s;y+=1)for(let d=0;d<=a;d+=1)for(let x=0;x<=d;x+=1){const h=(i[y]?.[x]??Number.NEGATIVE_INFINITY)+g(y,x,d),O=i[y+1],L=v[y+1];O&&L&&h>(O[d]??Number.NEGATIVE_INFINITY)&&(O[d]=h,L[d]=x)}const T=Array.from({length:s},()=>[]);let A=a;for(let y=s;y>0;y-=1){const d=v[y]?.[A]??0;T[y-1]=e.slice(d,A),A=d}return T},Le=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},en=(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=ee(e,t),s=Pe(e,n,t.logical)??Te(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,be(n,new Set(a.values()))),{state:{...e,...Le(e,r),panelIds:a},outcome:"opened"}},Me=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},nn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Me(e,n),outcome:"closed"};const r=en(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},tn=(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 a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);a.delete(n),a.set(t,m);const g=new Set(e.markup);return g.delete(n),{state:{docs:e.docs.map(i=>i===n?t:i),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:g,panelIds:a},outcome:"navigated"}},ke=(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}},on=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},rn=(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}},sn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[i,v]of o.entries())for(const C of v)r.set(C,i);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),g=Array.from({length:t.logical},()=>[]);for(const[i,v]of m.entries()){const C=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of C)a.add(T);for(const[T,A]of Qe(C,v,y=>r.get(y)).entries())g[v[0]+T]?.push(...A)}for(const i of e.docs)a.has(i)||g[r.get(i)??0]?.push(i);return g.every((i,v)=>i.length===o[v]?.length&&i.every((C,T)=>o[v]?.[T]===C))?e:{...e,...Le(e,g)}},te=(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)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Xe(t,e.panelIds)}},pe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of ee(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Q)break;t.delete(o)}return{...e,columnOf:t}},Re=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),ln=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Re)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Q))Array.isArray(a)&&a.length===2&&typeof a[0]=="string"&&a[0]!==""&&Number.isInteger(a[1])&&a[1]>=0&&a[1]<n&&(r.delete(a[0]),r.set(a[0],a[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(a=>typeof a=="string"&&a!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Re,columnOf:[...e.columnOf.entries()].slice(-Q),hidden:e.docs.filter(n=>e.hidden.has(n))}),ae=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},W=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},ge=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${Y.describeValue(e)}`)},cn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=P.createEmitter(),m=new Map,g=new Map;let i={layout:te({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},v=!1;const C=l=>v?pe(l,{logical:s,visible:i.visibleColumns}):l,T=(l,S)=>j.explorerHref(e,{view:"multi",source:l,docs:S.docs,maximized:S.maximized,markup:S.markup}),A=l=>({docs:l.docs,maximized:l.maximized,markup:[...l.markup]});let y=T(n.source,n),d=n.source,x=y;const h=[],O=[];let L=null;const N=()=>{if(!(h.length>0))for(const l of O.splice(0))l()},R=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=an(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==y&&(y=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const E of[...m.keys()])S.has(E)||m.delete(E);for(const E of[...g.keys()])S.has(E)||g.delete(E);const b=new Set(l.docs),I=[...i.titles.keys()].every(E=>b.has(E))?i.titles:new Map([...i.titles].filter(([E])=>b.has(E))),w=[...i.pendingHashes.keys()].every(E=>S.has(E))?i.pendingHashes:new Map([...i.pendingHashes].filter(([E])=>S.has(E)));return{titles:I,pendingHashes:w}},M=l=>l===i.layout?!1:(R({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{ge(l);const{state:S,outcome:b}=nn(i.layout,l,_(),r);return M(S),b},close:l=>M(Me(i.layout,l)),navigate:(l,S)=>{ge(S);const{state:b,outcome:I}=tn(i.layout,l,S);if(I!=="navigated")return I;const w=b.panelIds.get(S);return w!==void 0&&(m.delete(w),g.delete(w)),M(b),I},setHidden:(l,S)=>M(ke(i.layout,l,S)),maximize:l=>M(rn(i.layout,l)),setMarkup:(l,S)=>M(on(i.layout,l,S)),arrange:l=>M(sn(i.layout,l,{logical:s,visible:l.length})),changeSource:l=>{p(l,i.layout,"push")},revealSource:l=>{p(l,i.layout,"replace")},observeLocation:l=>{const S=T(l.source,l);if(S===y)return h.length=0,x=S,l.source!==i.source&&R({source:l.source}),N(),!1;if(S===x)return!1;x=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&R({source:l.source}),N(),!1;h.length=0,y=S,d=l.source;const I=C(te({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return R({layout:I,source:l.source,...f(I)}),u(),N(),!0},whenUrlRendered:l=>{O.push(l),N()},loadStored:l=>{R({layout:C(te({docs:i.layout.docs,maximized:i.layout.maximized,markup:[...i.layout.markup],stored:l,panelIds:i.layout.panelIds},r)),ready:!0}),u()},setVisibleColumns:l=>{if(!Number.isInteger(l)||l<1||l>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${Y.describeValue(l)}`);v=!0;const S=pe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(R({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&R({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||R({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ae(i.titles,l),setPendingHash:(l,S)=>{const b=i.pendingHashes.get(l);if(S===null||S===""){if(b===void 0)return;const I=new Map(i.pendingHashes);I.delete(l),R({pendingHashes:I});return}b!==S&&R({pendingHashes:new Map(i.pendingHashes).set(l,S)})},saveReadingPosition:(l,S,b)=>{i.layout.panelIds.get(S)===l&&m.set(l,{doc:S,position:b})},readingPositionOf:(l,S)=>{const b=m.get(l);return b===void 0||b.doc!==S?null:b.position},saveImageView:(l,S,b)=>{g.set(l,{url:S,state:b})},imageViewOf:(l,S)=>{const b=g.get(l);return b===void 0||b.url!==S?null:b.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return c.useSyncExternalStore(e.subscribe,t,t)},un=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=fe.useNavigate(),r=c.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=c.useState(()=>cn({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ne.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(ln(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},dn=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},mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=ie(),{announcer:i}=P.useExplorer(),v=z(s,u=>Fe(u,n)),C=z(s,u=>u.layout.markup.has(e)),T=c.useCallback((u,p)=>a(n,e,u,p),[a,n,e]),A=c.useCallback(()=>s.setPendingHash(n,null),[s,n]),y=c.useMemo(()=>({read:u=>s.imageViewOf(n,u),save:(u,p)=>s.saveImageView(n,u,p)}),[s,n]),d=c.useCallback((u,p)=>{p.kind!=="failure"&&s.setTitle(u,p.name),r(u)},[s,r]),x=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:dn,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),O=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:x,paneScroll:h}),[t,T,v,A,x,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),N=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),R=c.useMemo(()=>({shown:C,toggle:N}),[C,N]);return k.jsxs(P.ImageViewMemoryContext,{value:y,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:R,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:C,variant:O,onDocumentShown:d})]})},he=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",J="data-panel-id",se="--aqmx-multi-panel-chrome",fn=e=>e==="normal"?0:P.cssPixels(e),pn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),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),a=t.clientWidth-P.cssPixels(s.paddingLeft)-P.cssPixels(s.paddingRight),m=t.clientHeight-P.cssPixels(s.paddingTop)-P.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:a,gap:fn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},gn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+P.cssPixels(t.paddingBottom)+P.cssPixels(t.borderBottomWidth)},X="data-aqmx-panel-frame",Se="--aqmx-multi-panel-pinned-block-size",hn=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}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},xn=(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),$=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ne=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ae=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},xe=(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},yn=(e,n)=>{const t=Ae(e,n),o=[];let r=e;for(let a=xe([...r.children],t);a>=0;a=xe([...r.children],t)){const m=r.children[a];if(m===void 0)break;o.push(a),r=m}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const g of t.anchor.path)o=o?.children[g];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:a}=t.anchor,m=s<0&&a>0?s/a*r.height:s;n.scrollTop+=r.top-Ae(e,n)-m},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ie=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...vn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},wn=(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:Ie(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ie(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=xn(e,r,t);(o||On(r,s))&&(e.preventDefault(),r.scrollTop+=s)},On=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,bn=e=>e.scrollHeight>e.clientHeight,Pn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=gn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(Se,`${String(v)}px`));const C=i+v;C!==o&&(o=C,e.style.setProperty(se,`${String(C)}px`))};a();let m=null;const g=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return g?.observe(e),g?.observe(n),s!==null&&g?.observe(s),()=>{g?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(se),t.style.removeProperty(Se)}},Tn=e=>{const{docPath:n,panelId:t}=hn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ae(d.titles,n)),i=c.useRef(null),v=c.useRef(null),C=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null||m)return;const h=new Map,O=p=>{const f=h.get(p);if(f!==void 0)return f;const M=Sn(p);return h.set(p,M),M},L=p=>Cn(p,d,O);let N=!1;const R=()=>{const p=bn(x);p!==N&&(N=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};R();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return u?.observe(x),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d),h=d===null?null:d.closest(`[${J}]`);if(!(d===null||x===null||!(h instanceof HTMLElement)))return Pn(h,x,d)},[]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null)return;const h=p=>{ye(d,x,p),T.current=x.scrollTop},O=o.readingPositionOf(t,n);v.current=O===null?null:{doc:n,position:O},O!==null&&h(O);let L=null,N=d.getBoundingClientRect().width;const R=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&x.scrollTop===p||d.getBoundingClientRect().width!==N)return;const f=C.current;f!==null&&o.saveReadingPosition(t,f,yn(d,x))}))};x.addEventListener("scroll",R,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===N)return;N=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{x.removeEventListener("scroll",R),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:d.closest(`[${J}]`);if(d===null||x===null)return;const h=a.take(t);return h!==null&&En(x,d,h),()=>{const O=wn(x,x.ownerDocument.activeElement);O!==null&&a.hold(t,O)}},[a,t]);const A=c.useCallback(d=>{const x=i.current,h=x===null?null:$(x);if(x===null||h===null)return;const O=C.current;C.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(x,h,L.position),T.current=h.scrollTop):O!==null&&O!==d&&(h.scrollTop=0)},[]),y=c.useCallback(d=>{P.isInFullscreenBlock(d.target)||s(n)},[s,n]);return k.jsx("div",{ref:i,role:"group","aria-label":g,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",...m?P.CONTENT_PANE:{},onDoubleClick:m?void 0:y,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Ln=c.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);return t},ve=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Mn=(e,n)=>{const t=Ze(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},kn=(e,n)=>{const t=W(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Rn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,morePanelActions:e.panelMoreActions,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}),Nn="--aqmx-multi-stage-bar-gutter",An=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),In=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),_n=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Dn=e=>k.jsx("div",{..._n,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),zn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:In},renderScrollBar:Dn,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),Hn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ue="--aqmx-stage-block",qn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,jn=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${qn})))`,Fn=(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((a,m)=>r[m]===a)})},G=(e,n,t,o)=>{P.stopKeepingInView(e);const r=e.querySelector(`[${J}="${n}"]`);if(!(r instanceof HTMLElement))return;const s=t!==null&&r.contains(t)?t:null,a=[{element:r,boundary:r.closest(D.SCROLL_ROOT_SELECTOR)}];s!==null&&a.push({element:s,boundary:r}),P.keepInView(e,()=>r.isConnected?(r.scrollIntoView(P.NEAREST),s?.isConnected!==!0?r:(o(s),s)):null,a)},Z=e=>{e.scrollIntoView(P.NEAREST)},_e=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,Z),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},we=(e,n)=>{if(!de(e,n))return null;const t=[...e.querySelectorAll(`[${X}]`)].map(a=>a.getAttribute(X)),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"}},Ee=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},De=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Vn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&de(o,n)?r:null,Z),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Un=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,g=z(e,w=>w.layout),i=z(e,w=>w.visibleColumns),v=z(e,w=>w.titles),C=z(e,w=>w.layout.maximized!==null||w.splitDragging),[T,A]=c.useState(!1),[y]=c.useState(()=>ve(i)),d=c.useMemo(()=>Rn(o),[o]),x=c.useCallback(w=>{e.arrange(kn(e.getSnapshot().layout,w))},[e]),h=D.useDragDropColumns({initialColumnPanels:y,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:x}),{columnPanels:O,setColumnPanels:L}=h,N=c.useRef(C),R=c.useRef(O);c.useLayoutEffect(()=>{N.current=C,R.current=O},[C,O]);const u=c.useCallback(w=>{const E=n.current;if(E===null)return;const{plan:B,stageBlockSize:H}=pn(E,m);if(Number.isFinite(H)&&H>0&&E.style.setProperty(ue,`${String(H)}px`),N.current&&!w)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let E=null;const B=new ResizeObserver(()=>{E===null&&(E=requestAnimationFrame(()=>{E=null,u(!1)}))}),H=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=w.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),E!==null&&cancelAnimationFrame(E)}},[n,u]),c.useEffect(()=>{C||u(!1)},[C,u]);const p=c.useMemo(()=>T?Mn(g,{logical:m,visible:i}):ve(i),[T,g,m,i]);c.useLayoutEffect(()=>{Fn(R.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),M=c.useMemo(()=>g.docs.map(w=>{const E=K(g,w);return{id:E,component:Ln,title:ae(v,w),props:{docPath:w,panelId:E},minHeight:Bn,maxHeight:jn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(w=>[K(g,w),!g.hidden.has(w)])),[g]),l=g.maximized===null?null:K(g,g.maximized),S=c.useCallback(w=>{const{layout:E}=e.getSnapshot();for(const[B,H]of W(E)){const q=w[B];if(q===void 0||q!==E.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),De(n,B);continue}const V=n.current,me=V===null?null:we(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),me!==null&&Ee(n,me))}},[e,n,r,o]),b=c.useCallback(w=>{const E=W(e.getSnapshot().layout).get(w);if(E===void 0)return;const B=()=>{const q=e.titleOf(E),F=n.current,V=F===null?null:we(F,w);e.close(E)&&(r.announce(o.panelClosed(q)),V!==null&&Ee(n,V))},H=s.unsavedAmong([E]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),I=c.useCallback(w=>{if(w===null){a(null);return}const E=W(e.getSnapshot().layout).get(w);E!==void 0&&a(E)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:O,onColumnPanelsChange:x,panelVisibility:_,onPanelVisibilityChange:S,dragState:h.dragState,dragOverPosition:h.dragOverPosition,originalPanelPosition:h.originalPanelPosition,dragModes:h.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:h.panelSizes,customDrag:h.customDrag,setPanelRef:h.setPanelRef,onDragStart:h.handleDragStart,onDragEnd:h.handleDragEnd,onPlaceholderDragEnter:h.handlePlaceholderDragEnter,onPlaceholderDragLeave:h.handlePlaceholderDragLeave,onDragOverWithInsert:h.handleDragOverWithInsert,onDropWithInsert:h.handleDropWithInsert,onColumnDragLeave:h.handleColumnDragLeave,onPanelMouseDown:h.handleMouseDown,onPanelSizeInfoClick:h.handlePanelSizeInfoClick,onToggleDragMode:h.toggleDragMode,onPanelClose:b,onPanelMaximizeChange:I,maximizedPanel:l,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:zn,renderStageScrollBar:Hn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},$n=(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(a=>{const m=n.ownerDocument.elementsFromPoint(s,a),g=m.findIndex(v=>n.contains(v)),i=m.findIndex(v=>e.contains(v));return g!==-1&&i!==-1&&i<g}))},Gn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(oe.blockStart,`${String(t.top)}px`),e.style.setProperty(oe.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(oe.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Yn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:g}=P.useExplorer(),i=c.useRef(null),v=c.useRef(null),C=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),y=c.use(re.SheetNoticeSlotContext),d=c.useCallback(u=>{const{layout:p}=e.getSnapshot(),f=p.maximized,M=u===null&&f!==null?p.panelIds.get(f):void 0,_=i.current,l=M!==void 0&&_!==null&&de(_,M);e.maximize(u)&&(u!==null?m.announce(a.panelMaximized(e.titleOf(u))):f!==null&&m.announce(a.panelRestored(e.titleOf(f))),M!==void 0&&Vn(i,M,l))},[e,m,a]),x=c.useCallback((u,p,f,M)=>{if(f===p){e.setPendingHash(u,M);return}const _=g.unsavedAmong([p]);if(_.length>0){g.askToDiscard(_).then(I=>{I&&x(u,p,f,M)});return}const l=e.navigate(p,f);if(l==="navigated"){e.setPendingHash(u,M);return}if(l!=="existing")return;const{layout:S}=e.getSnapshot(),b=S.panelIds.get(f);b!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(f))),S.maximized===null?e.setHidden(f,!1):d(f),e.setPendingHash(b,M),De(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||y!==null||!he())return;const u=v.current,p=i.current;if(u===null||p===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Gn(u,p)},[t,y]),c.useEffect(()=>{const u=v.current;if(t===null||u===null)return;const{ownerDocument:p}=u;let f=null;const M=_=>{const l=_.target;l instanceof Element&&(f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,p.activeElement===l&&u.isConnected&&$n(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,y,o]),c.useImperativeHandle(r,()=>({bringIntoView:u=>{requestAnimationFrame(()=>{const p=i.current,f=e.getSnapshot().layout.panelIds.get(u);p!==null&&f!==void 0&&G(p,f,null,Z)})}}),[e]),c.useEffect(()=>{const u=i.current;return()=>{u!==null&&P.stopKeepingInView(u)}},[]);const h=c.useCallback((u,p)=>{const f=i.current;f!==null&&G(f,u,p,Z)},[]),O=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(je),N=c.useMemo(()=>({store:e,Body:n,followLink:x,maximize:d,revealInPanel:h,keepAtStartInPanel:O,focusCarry:L}),[e,n,x,d,h,O,L]),R=c.useMemo(()=>Array.from({length:s.multiView.columns},(u,p)=>D.generateColumnId(p)),[s]);return k.jsxs("section",{ref:i,className:"aqmx-multi-stage",style:An,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!C,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),T?C?k.jsx(Oe,{value:N,children:k.jsx(Un,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:R.map(u=>k.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]},u))}):k.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:k.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:y!==null?qe.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),y):k.jsx("div",{ref:v,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},ze=3e3,He=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},le=(e,n,t)=>{const o=new Set(e),r=n.filter(a=>!o.has(a)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Wn=(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 ${Y.describeValue(o)}`)}}},Kn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=un(e),s=z(r,f=>f.layout.docs),a=z(r,f=>f.layout.maximized),m=z(r,f=>f.layout.markup),g=z(r,f=>f.source),[i,v]=c.useState(()=>({docs:s,latest:le([],s,null)}));i.docs!==s&&v({docs:s,latest:le(i.docs,s,i.latest)});const C=a!==null?a:i.latest,[T,A]=c.useState(!1),y=c.useRef(null),[d,x]=c.useState(0),h=c.useRef(null),O=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),O.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const L=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),A(!0),y.current=setTimeout(()=>{y.current=null,A(!1)},ze)},[]),N=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),y.current=null,A(!1)},[]),R=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Wn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},x(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&O.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=He(s,a);return{href:j.explorerHref(n,{view:"tree",source:g,doc:f,markup:f!==null&&m.has(f)}),target:"tree"}},[n,g,s,a,m]);return k.jsx(re.ExplorerSplit,{view:"multi",explorer:k.jsx(re.ExplorerPane,{mode:"multi",sourceId:g,currentPath:C,openPaths:u,onOpenDocument:R,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Yn,{ref:O,store:r,body:mn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:N}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Kn;exports.PANEL_LIMIT_NOTICE_MS=ze;exports.latestOpenedDocument=le;exports.treeSwitchDocument=He;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),Y=require("./describeValue-Ccvhbt36.cjs"),j=require("./location-DrOP6t1F.cjs"),P=require("./index-lpL7GltU.cjs"),re=require("./ExplorerSplit-BNrHrIus.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-BpYsprog.cjs"),Ce=require("./ownUrls-BTPGNhBt.cjs"),qe=require("react-dom"),Be=require("@aiquants/markdown"),je=()=>{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}}},Oe=c.createContext(null),ie=()=>{const e=c.use(Oe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Fe=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ve=0xcbf29ce484222325n,Ue=0x100000001b3n,$e=(1n<<64n)-1n,Ge=(1n<<53n)-1n,Ye=new TextEncoder,We=e=>{let n=Ve;for(const t of Ye.encode(e))n=(n^BigInt(t))*Ue&$e;return Number(n&Ge)},Q=256,Ke=e=>`aqmx-p-${We(e).toString(36)}`,be=(e,n)=>{const t=Ke(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Je=new Map,Xe=(e,n=Je)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??be(r,t);t.add(s),o.set(r,s)}return o},Pe=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Te=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([m,g])=>e.slice(m,g).reduce((i,v)=>i+v.length,0);let s=t;for(const m of o)r(m)<r(s)&&(s=m);let a=s[0];for(let m=s[0];m<s[1];m+=1)(e[m]?.length??0)<(e[a]?.length??0)&&(a=m);return a},ee=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Pe(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Te(t,n)]?.push(r);return t},Ze=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Qe=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(y,d)=>{const x=[0];for(const h of e)x.push((x.at(-1)??0)+(t(h)===o+d?1:0));return x}),g=(y,d,x)=>(m[y]?.[x]??0)-(m[y]?.[d]??0),i=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),v=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),C=i[0];C&&(C[0]=0);for(let y=0;y<s;y+=1)for(let d=0;d<=a;d+=1)for(let x=0;x<=d;x+=1){const h=(i[y]?.[x]??Number.NEGATIVE_INFINITY)+g(y,x,d),O=i[y+1],L=v[y+1];O&&L&&h>(O[d]??Number.NEGATIVE_INFINITY)&&(O[d]=h,L[d]=x)}const T=Array.from({length:s},()=>[]);let A=a;for(let y=s;y>0;y-=1){const d=v[y]?.[A]??0;T[y-1]=e.slice(d,A),A=d}return T},Le=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},en=(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=ee(e,t),s=Pe(e,n,t.logical)??Te(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,be(n,new Set(a.values()))),{state:{...e,...Le(e,r),panelIds:a},outcome:"opened"}},Me=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},nn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Me(e,n),outcome:"closed"};const r=en(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},tn=(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 a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);a.delete(n),a.set(t,m);const g=new Set(e.markup);return g.delete(n),{state:{docs:e.docs.map(i=>i===n?t:i),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:g,panelIds:a},outcome:"navigated"}},ke=(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}},on=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},rn=(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}},sn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[i,v]of o.entries())for(const C of v)r.set(C,i);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),g=Array.from({length:t.logical},()=>[]);for(const[i,v]of m.entries()){const C=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of C)a.add(T);for(const[T,A]of Qe(C,v,y=>r.get(y)).entries())g[v[0]+T]?.push(...A)}for(const i of e.docs)a.has(i)||g[r.get(i)??0]?.push(i);return g.every((i,v)=>i.length===o[v]?.length&&i.every((C,T)=>o[v]?.[T]===C))?e:{...e,...Le(e,g)}},te=(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)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Xe(t,e.panelIds)}},pe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of ee(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Q)break;t.delete(o)}return{...e,columnOf:t}},Re=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),ln=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Re)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Q))Array.isArray(a)&&a.length===2&&typeof a[0]=="string"&&a[0]!==""&&Number.isInteger(a[1])&&a[1]>=0&&a[1]<n&&(r.delete(a[0]),r.set(a[0],a[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(a=>typeof a=="string"&&a!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Re,columnOf:[...e.columnOf.entries()].slice(-Q),hidden:e.docs.filter(n=>e.hidden.has(n))}),ae=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},W=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},ge=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${Y.describeValue(e)}`)},cn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=P.createEmitter(),m=new Map,g=new Map;let i={layout:te({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},v=!1;const C=l=>v?pe(l,{logical:s,visible:i.visibleColumns}):l,T=(l,S)=>j.explorerHref(e,{view:"multi",source:l,docs:S.docs,maximized:S.maximized,markup:S.markup}),A=l=>({docs:l.docs,maximized:l.maximized,markup:[...l.markup]});let y=T(n.source,n),d=n.source,x=y;const h=[],O=[];let L=null;const N=()=>{if(!(h.length>0))for(const l of O.splice(0))l()},R=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=an(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==y&&(y=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const E of[...m.keys()])S.has(E)||m.delete(E);for(const E of[...g.keys()])S.has(E)||g.delete(E);const b=new Set(l.docs),I=[...i.titles.keys()].every(E=>b.has(E))?i.titles:new Map([...i.titles].filter(([E])=>b.has(E))),w=[...i.pendingHashes.keys()].every(E=>S.has(E))?i.pendingHashes:new Map([...i.pendingHashes].filter(([E])=>S.has(E)));return{titles:I,pendingHashes:w}},M=l=>l===i.layout?!1:(R({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{ge(l);const{state:S,outcome:b}=nn(i.layout,l,_(),r);return M(S),b},close:l=>M(Me(i.layout,l)),navigate:(l,S)=>{ge(S);const{state:b,outcome:I}=tn(i.layout,l,S);if(I!=="navigated")return I;const w=b.panelIds.get(S);return w!==void 0&&(m.delete(w),g.delete(w)),M(b),I},setHidden:(l,S)=>M(ke(i.layout,l,S)),maximize:l=>M(rn(i.layout,l)),setMarkup:(l,S)=>M(on(i.layout,l,S)),arrange:l=>M(sn(i.layout,l,{logical:s,visible:l.length})),changeSource:l=>{p(l,i.layout,"push")},revealSource:l=>{p(l,i.layout,"replace")},observeLocation:l=>{const S=T(l.source,l);if(S===y)return h.length=0,x=S,l.source!==i.source&&R({source:l.source}),N(),!1;if(S===x)return!1;x=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&R({source:l.source}),N(),!1;h.length=0,y=S,d=l.source;const I=C(te({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return R({layout:I,source:l.source,...f(I)}),u(),N(),!0},whenUrlRendered:l=>{O.push(l),N()},loadStored:l=>{R({layout:C(te({docs:i.layout.docs,maximized:i.layout.maximized,markup:[...i.layout.markup],stored:l,panelIds:i.layout.panelIds},r)),ready:!0}),u()},setVisibleColumns:l=>{if(!Number.isInteger(l)||l<1||l>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${Y.describeValue(l)}`);v=!0;const S=pe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(R({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&R({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||R({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ae(i.titles,l),setPendingHash:(l,S)=>{const b=i.pendingHashes.get(l);if(S===null||S===""){if(b===void 0)return;const I=new Map(i.pendingHashes);I.delete(l),R({pendingHashes:I});return}b!==S&&R({pendingHashes:new Map(i.pendingHashes).set(l,S)})},saveReadingPosition:(l,S,b)=>{i.layout.panelIds.get(S)===l&&m.set(l,{doc:S,position:b})},readingPositionOf:(l,S)=>{const b=m.get(l);return b===void 0||b.doc!==S?null:b.position},saveImageView:(l,S,b)=>{g.set(l,{url:S,state:b})},imageViewOf:(l,S)=>{const b=g.get(l);return b===void 0||b.url!==S?null:b.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return c.useSyncExternalStore(e.subscribe,t,t)},un=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=fe.useNavigate(),r=c.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=c.useState(()=>cn({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ne.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(ln(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},dn=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},mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=ie(),{announcer:i}=P.useExplorer(),v=z(s,u=>Fe(u,n)),C=z(s,u=>u.layout.markup.has(e)),T=c.useCallback((u,p)=>a(n,e,u,p),[a,n,e]),A=c.useCallback(()=>s.setPendingHash(n,null),[s,n]),y=c.useMemo(()=>({read:u=>s.imageViewOf(n,u),save:(u,p)=>s.saveImageView(n,u,p)}),[s,n]),d=c.useCallback((u,p)=>{p.kind!=="failure"&&s.setTitle(u,p.name),r(u)},[s,r]),x=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:dn,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),O=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:x,paneScroll:h}),[t,T,v,A,x,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),N=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),R=c.useMemo(()=>({shown:C,toggle:N}),[C,N]);return k.jsxs(P.ImageViewMemoryContext,{value:y,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:R,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:C,variant:O,onDocumentShown:d})]})},he=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",J="data-panel-id",se="--aqmx-multi-panel-chrome",fn=e=>e==="normal"?0:P.cssPixels(e),pn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),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),a=t.clientWidth-P.cssPixels(s.paddingLeft)-P.cssPixels(s.paddingRight),m=t.clientHeight-P.cssPixels(s.paddingTop)-P.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:a,gap:fn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},gn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+P.cssPixels(t.paddingBottom)+P.cssPixels(t.borderBottomWidth)},X="data-aqmx-panel-frame",Se="--aqmx-multi-panel-pinned-block-size",hn=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}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},xn=(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),$=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ne=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ae=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},xe=(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},yn=(e,n)=>{const t=Ae(e,n),o=[];let r=e;for(let a=xe([...r.children],t);a>=0;a=xe([...r.children],t)){const m=r.children[a];if(m===void 0)break;o.push(a),r=m}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const g of t.anchor.path)o=o?.children[g];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:a}=t.anchor,m=s<0&&a>0?s/a*r.height:s;n.scrollTop+=r.top-Ae(e,n)-m},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ie=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...vn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},wn=(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:Ie(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ie(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=xn(e,r,t);(o||On(r,s))&&(e.preventDefault(),r.scrollTop+=s)},On=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,bn=e=>e.scrollHeight>e.clientHeight,Pn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=gn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(Se,`${String(v)}px`));const C=i+v;C!==o&&(o=C,e.style.setProperty(se,`${String(C)}px`))};a();let m=null;const g=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return g?.observe(e),g?.observe(n),s!==null&&g?.observe(s),()=>{g?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(se),t.style.removeProperty(Se)}},Tn=e=>{const{docPath:n,panelId:t}=hn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ae(d.titles,n)),i=c.useRef(null),v=c.useRef(null),C=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null||m)return;const h=new Map,O=p=>{const f=h.get(p);if(f!==void 0)return f;const M=Sn(p);return h.set(p,M),M},L=p=>Cn(p,d,O);let N=!1;const R=()=>{const p=bn(x);p!==N&&(N=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};R();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return u?.observe(x),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d),h=d===null?null:d.closest(`[${J}]`);if(!(d===null||x===null||!(h instanceof HTMLElement)))return Pn(h,x,d)},[]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null)return;const h=p=>{ye(d,x,p),T.current=x.scrollTop},O=o.readingPositionOf(t,n);v.current=O===null?null:{doc:n,position:O},O!==null&&h(O);let L=null,N=d.getBoundingClientRect().width;const R=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&x.scrollTop===p||d.getBoundingClientRect().width!==N)return;const f=C.current;f!==null&&o.saveReadingPosition(t,f,yn(d,x))}))};x.addEventListener("scroll",R,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===N)return;N=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{x.removeEventListener("scroll",R),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:d.closest(`[${J}]`);if(d===null||x===null)return;const h=a.take(t);return h!==null&&En(x,d,h),()=>{const O=wn(x,x.ownerDocument.activeElement);O!==null&&a.hold(t,O)}},[a,t]);const A=c.useCallback(d=>{const x=i.current,h=x===null?null:$(x);if(x===null||h===null)return;const O=C.current;C.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(x,h,L.position),T.current=h.scrollTop):O!==null&&O!==d&&(h.scrollTop=0)},[]),y=c.useCallback(d=>{P.isInFullscreenBlock(d.target)||s(n)},[s,n]);return k.jsx("div",{ref:i,role:"group","aria-label":g,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",...m?P.CONTENT_PANE:{},onDoubleClick:m?void 0:y,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Ln=c.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);return t},ve=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Mn=(e,n)=>{const t=Ze(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},kn=(e,n)=>{const t=W(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Rn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,morePanelActions:e.panelMoreActions,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}),Nn="--aqmx-multi-stage-bar-gutter",An=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),In=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),_n=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Dn=e=>k.jsx("div",{..._n,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),zn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:In},renderScrollBar:Dn,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),Hn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ue="--aqmx-stage-block",qn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,jn=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${qn})))`,Fn=(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((a,m)=>r[m]===a)})},G=(e,n,t,o)=>{P.stopKeepingInView(e);const r=e.querySelector(`[${J}="${n}"]`);if(!(r instanceof HTMLElement))return;const s=t!==null&&r.contains(t)?t:null,a=[{element:r,boundary:r.closest(D.SCROLL_ROOT_SELECTOR)}];s!==null&&a.push({element:s,boundary:r}),P.keepInView(e,()=>r.isConnected?(r.scrollIntoView(P.NEAREST),s?.isConnected!==!0?r:(o(s),s)):null,a)},Z=e=>{e.scrollIntoView(P.NEAREST)},_e=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,Z),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},we=(e,n)=>{if(!de(e,n))return null;const t=[...e.querySelectorAll(`[${X}]`)].map(a=>a.getAttribute(X)),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"}},Ee=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},De=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Vn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&de(o,n)?r:null,Z),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Un=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,g=z(e,w=>w.layout),i=z(e,w=>w.visibleColumns),v=z(e,w=>w.titles),C=z(e,w=>w.layout.maximized!==null||w.splitDragging),[T,A]=c.useState(!1),[y]=c.useState(()=>ve(i)),d=c.useMemo(()=>Rn(o),[o]),x=c.useCallback(w=>{e.arrange(kn(e.getSnapshot().layout,w))},[e]),h=D.useDragDropColumns({initialColumnPanels:y,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:x}),{columnPanels:O,setColumnPanels:L}=h,N=c.useRef(C),R=c.useRef(O);c.useLayoutEffect(()=>{N.current=C,R.current=O},[C,O]);const u=c.useCallback(w=>{const E=n.current;if(E===null)return;const{plan:B,stageBlockSize:H}=pn(E,m);if(Number.isFinite(H)&&H>0&&E.style.setProperty(ue,`${String(H)}px`),N.current&&!w)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let E=null;const B=new ResizeObserver(()=>{E===null&&(E=requestAnimationFrame(()=>{E=null,u(!1)}))}),H=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=w.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),E!==null&&cancelAnimationFrame(E)}},[n,u]),c.useEffect(()=>{C||u(!1)},[C,u]);const p=c.useMemo(()=>T?Mn(g,{logical:m,visible:i}):ve(i),[T,g,m,i]);c.useLayoutEffect(()=>{Fn(R.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),M=c.useMemo(()=>g.docs.map(w=>{const E=K(g,w);return{id:E,component:Ln,title:ae(v,w),props:{docPath:w,panelId:E},minHeight:Bn,maxHeight:jn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(w=>[K(g,w),!g.hidden.has(w)])),[g]),l=g.maximized===null?null:K(g,g.maximized),S=c.useCallback(w=>{const{layout:E}=e.getSnapshot();for(const[B,H]of W(E)){const q=w[B];if(q===void 0||q!==E.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),De(n,B);continue}const V=n.current,me=V===null?null:we(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),me!==null&&Ee(n,me))}},[e,n,r,o]),b=c.useCallback(w=>{const E=W(e.getSnapshot().layout).get(w);if(E===void 0)return;const B=()=>{const q=e.titleOf(E),F=n.current,V=F===null?null:we(F,w);e.close(E)&&(r.announce(o.panelClosed(q)),V!==null&&Ee(n,V))},H=s.unsavedAmong([E]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),I=c.useCallback(w=>{if(w===null){a(null);return}const E=W(e.getSnapshot().layout).get(w);E!==void 0&&a(E)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:O,onColumnPanelsChange:x,panelVisibility:_,onPanelVisibilityChange:S,dragState:h.dragState,dragOverPosition:h.dragOverPosition,originalPanelPosition:h.originalPanelPosition,dragModes:h.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:h.panelSizes,customDrag:h.customDrag,setPanelRef:h.setPanelRef,onDragStart:h.handleDragStart,onDragEnd:h.handleDragEnd,onPlaceholderDragEnter:h.handlePlaceholderDragEnter,onPlaceholderDragLeave:h.handlePlaceholderDragLeave,onDragOverWithInsert:h.handleDragOverWithInsert,onDropWithInsert:h.handleDropWithInsert,onColumnDragLeave:h.handleColumnDragLeave,onPanelMouseDown:h.handleMouseDown,onPanelSizeInfoClick:h.handlePanelSizeInfoClick,onToggleDragMode:h.toggleDragMode,onPanelClose:b,onPanelMaximizeChange:I,maximizedPanel:l,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:zn,renderStageScrollBar:Hn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},$n=(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(a=>{const m=n.ownerDocument.elementsFromPoint(s,a),g=m.findIndex(v=>n.contains(v)),i=m.findIndex(v=>e.contains(v));return g!==-1&&i!==-1&&i<g}))},Gn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(oe.blockStart,`${String(t.top)}px`),e.style.setProperty(oe.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(oe.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Yn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:g}=P.useExplorer(),i=c.useRef(null),v=c.useRef(null),C=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),y=c.use(re.SheetNoticeSlotContext),d=c.useCallback(u=>{const{layout:p}=e.getSnapshot(),f=p.maximized,M=u===null&&f!==null?p.panelIds.get(f):void 0,_=i.current,l=M!==void 0&&_!==null&&de(_,M);e.maximize(u)&&(u!==null?m.announce(a.panelMaximized(e.titleOf(u))):f!==null&&m.announce(a.panelRestored(e.titleOf(f))),M!==void 0&&Vn(i,M,l))},[e,m,a]),x=c.useCallback((u,p,f,M)=>{if(f===p){e.setPendingHash(u,M);return}const _=g.unsavedAmong([p]);if(_.length>0){g.askToDiscard(_).then(I=>{I&&x(u,p,f,M)});return}const l=e.navigate(p,f);if(l==="navigated"){e.setPendingHash(u,M);return}if(l!=="existing")return;const{layout:S}=e.getSnapshot(),b=S.panelIds.get(f);b!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(f))),S.maximized===null?e.setHidden(f,!1):d(f),e.setPendingHash(b,M),De(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||y!==null||!he())return;const u=v.current,p=i.current;if(u===null||p===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Gn(u,p)},[t,y]),c.useEffect(()=>{const u=v.current;if(t===null||u===null)return;const{ownerDocument:p}=u;let f=null;const M=_=>{const l=_.target;l instanceof Element&&(f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,p.activeElement===l&&u.isConnected&&$n(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,y,o]),c.useImperativeHandle(r,()=>({bringIntoView:u=>{requestAnimationFrame(()=>{const p=i.current,f=e.getSnapshot().layout.panelIds.get(u);p!==null&&f!==void 0&&G(p,f,null,Z)})}}),[e]),c.useEffect(()=>{const u=i.current;return()=>{u!==null&&P.stopKeepingInView(u)}},[]);const h=c.useCallback((u,p)=>{const f=i.current;f!==null&&G(f,u,p,Z)},[]),O=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(je),N=c.useMemo(()=>({store:e,Body:n,followLink:x,maximize:d,revealInPanel:h,keepAtStartInPanel:O,focusCarry:L}),[e,n,x,d,h,O,L]),R=c.useMemo(()=>Array.from({length:s.multiView.columns},(u,p)=>D.generateColumnId(p)),[s]);return k.jsxs("section",{ref:i,className:"aqmx-multi-stage",style:An,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!C,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),T?C?k.jsx(Oe,{value:N,children:k.jsx(Un,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:R.map(u=>k.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]},u))}):k.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:k.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:y!==null?qe.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),y):k.jsx("div",{ref:v,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},ze=3e3,He=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},le=(e,n,t)=>{const o=new Set(e),r=n.filter(a=>!o.has(a)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Wn=(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 ${Y.describeValue(o)}`)}}},Kn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=un(e),s=z(r,f=>f.layout.docs),a=z(r,f=>f.layout.maximized),m=z(r,f=>f.layout.markup),g=z(r,f=>f.source),[i,v]=c.useState(()=>({docs:s,latest:le([],s,null)}));i.docs!==s&&v({docs:s,latest:le(i.docs,s,i.latest)});const C=a!==null?a:i.latest,[T,A]=c.useState(!1),y=c.useRef(null),[d,x]=c.useState(0),h=c.useRef(null),O=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),O.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const L=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),A(!0),y.current=setTimeout(()=>{y.current=null,A(!1)},ze)},[]),N=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),y.current=null,A(!1)},[]),R=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Wn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},x(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&O.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=He(s,a);return{href:j.explorerHref(n,{view:"tree",source:g,doc:f,markup:f!==null&&m.has(f)}),target:"tree"}},[n,g,s,a,m]);return k.jsx(re.ExplorerSplit,{view:"multi",explorer:k.jsx(re.ExplorerPane,{mode:"multi",sourceId:g,currentPath:C,openPaths:u,onOpenDocument:R,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Yn,{ref:O,store:r,body:mn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:N}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Kn;exports.PANEL_LIMIT_NOTICE_MS=ze;exports.latestOpenedDocument=le;exports.treeSwitchDocument=He;
|