@aiquants/markdown-explorer 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +20 -12
  3. package/dist/EditSurface-DheIbHJi.js +705 -0
  4. package/dist/EditSurface-omuATGni.cjs +2 -0
  5. package/dist/{ExplorerSplit-DekOjAUZ.cjs → ExplorerSplit-DMizcKaY.cjs} +1 -1
  6. package/dist/{ExplorerSplit-MPHjw3nW.js → ExplorerSplit-DvcNMIjl.js} +109 -109
  7. package/dist/{MultiLayout-DtSW4rEQ.js → MultiLayout-C2R85L4x.js} +25 -25
  8. package/dist/{MultiLayout-HMzVDYWq.cjs → MultiLayout-Cq4y1I1g.cjs} +1 -1
  9. package/dist/{NativeScrollBar-CNQr7JY1.js → NativeScrollBar-CKfD2qpM.js} +1 -1
  10. package/dist/{NativeScrollBar-B0AkVF3E.cjs → NativeScrollBar-qvtXkNTx.cjs} +1 -1
  11. package/dist/{TreeLayout-_XQR-9tV.cjs → TreeLayout-8_V4L9s6.cjs} +1 -1
  12. package/dist/{TreeLayout-CJO9tOPq.js → TreeLayout-FCp9WPFO.js} +3 -3
  13. package/dist/core/contracts.d.cts +7 -1
  14. package/dist/core/contracts.d.ts +7 -1
  15. package/dist/core/labels.d.cts +14 -1
  16. package/dist/core/labels.d.ts +14 -1
  17. package/dist/{dataRoute-CH3yOKR0.cjs → dataRoute-BONacTPi.cjs} +1 -1
  18. package/dist/{dataRoute-Pm_0ue_4.js → dataRoute-CObbjNxG.js} +14 -12
  19. package/dist/index-CdydPdP7.js +3463 -0
  20. package/dist/index-afZWk187.cjs +13 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +21 -21
  23. package/dist/{location-BUNWJ4eB.cjs → location-D6RE3wAN.cjs} +1 -1
  24. package/dist/{location-DWd6SQhN.js → location-IRD9h42r.js} +1 -1
  25. package/dist/{merge-DDJaJmMU.js → merge-Bb7YRgn4.js} +1 -1
  26. package/dist/{merge-Bs7o3GyP.cjs → merge-Dm_uFthw.cjs} +1 -1
  27. package/dist/{sanitizePolicy-djLC3fRN.js → sanitizePolicy-DlrakwA4.js} +1 -1
  28. package/dist/{sanitizePolicy-BfUlXI5E.cjs → sanitizePolicy-DrIMuYCb.cjs} +1 -1
  29. package/dist/sanitizeWorker.cjs +1 -1
  30. package/dist/sanitizeWorker.js +1 -1
  31. package/dist/server/ports.d.cts +3 -0
  32. package/dist/server/ports.d.ts +3 -0
  33. package/dist/server.cjs +1 -1
  34. package/dist/server.js +93 -83
  35. package/dist/styles/markdown-explorer.css +1 -1
  36. package/docs/behavior/dom-hooks.md +6 -5
  37. package/docs/behavior/layout.md +12 -2
  38. package/package.json +1 -1
  39. package/dist/EditSurface-BTAhzvHi.js +0 -509
  40. package/dist/EditSurface-Dfj6Sxxb.cjs +0 -2
  41. package/dist/index-DpIVKG8Y.cjs +0 -13
  42. package/dist/index-o6OpR4ND.js +0 -3358
@@ -0,0 +1,3463 @@
1
+ import { jsxs as F, jsx as c, Fragment as Ne } from "react/jsx-runtime";
2
+ import * as b from "react";
3
+ import { createContext as me, use as ne, useMemo as U, useSyncExternalStore as ee, useRef as q, useId as ve, useLayoutEffect as Z, useCallback as $, useEffect as te, Component as Kt, Suspense as we, lazy as tt, useState as B, useEffectEvent as le } from "react";
4
+ import { useParams as An, useSearchParams as Ln, matchPath as Mn, useBlocker as Nn, useNavigate as Dn, Link as Pn, useHref as De, useLocation as Wt, useRevalidator as $n } from "react-router";
5
+ import { f as Fn, a as Xt, u as qn, G as Se, e as pe, x as _n, y as Bn, z as mt, B as In, D as ht, H as jn, w as Hn, I as Vn } from "./location-IRD9h42r.js";
6
+ import { F as ye, i as zn, G as Un, y as W, x as Zn, H as pt, z as He, I as Gn, J as Kn, K as Wn, L as Xn, N as Yn, f as Jn, O as vt, v as Qn, P as er, Q as tr, R as nr, B as rr, w as or, S as ir, T as lr, U as ar, u as wt } from "./dataRoute-CObbjNxG.js";
7
+ import { HostedScrollArea as gt, useMarkdownToolbarState as sr, MarkdownViewer as Yt } from "@aiquants/markdown";
8
+ import { SOURCE_LINES_ATTRIBUTE as Jt, parseSourceLines as cr } from "@aiquants/markdown/source-lines";
9
+ import { DEFAULT_CONTENT_ALIGN as dr } from "@aiquants/markdown/viewer-settings";
10
+ import { w as Qt, r as en, a as ur, b as bt, s as Ve, c as fr } from "./storage-BSthKLSG.js";
11
+ const Et = Object.freeze(["en", "ja"]), mr = "en", hr = Object.freeze({
12
+ panelMoved: Object.freeze(["title", "column", "position"]),
13
+ panelMoveUnavailable: Object.freeze(["title", "move"]),
14
+ panelDragStarted: Object.freeze(["title"]),
15
+ panelDragCancelled: Object.freeze(["title"]),
16
+ multiColumnRegion: Object.freeze(["column"])
17
+ }), pr = /\{(\w+)\}/gu, tn = {
18
+ explorerRegion: "Explorer",
19
+ sourceLabel: "Source",
20
+ refreshTreeLabel: "Refresh tree",
21
+ refreshTree: "Reload the tree and the open documents from the source",
22
+ treeRefreshed: "Reloaded the tree from the source",
23
+ treeRefreshFailed: (e) => `Could not reload the tree: ${e}`,
24
+ refreshDocumentLabel: "Refresh document",
25
+ refreshDocument: "Reload the document from the source",
26
+ refreshDocumentNamed: (e) => `Refresh ${e}`,
27
+ documentRefreshed: (e) => `Reloaded ${e}`,
28
+ documentRefreshFailed: (e) => `Could not reload the document: ${e}`,
29
+ showMarkupLabel: "Source",
30
+ showMarkup: "Show the document's Markdown as written",
31
+ showMarkupNamed: (e) => `Source of ${e}`,
32
+ editDocumentLabel: "Edit",
33
+ editDocument: "Edit the document's Markdown (or double-click the document)",
34
+ editDocumentNamed: (e) => `Edit ${e}`,
35
+ editDraftDocument: "Edit the document's Markdown without saving, to try it in the preview (or double-click the document)",
36
+ editDraftDocumentNamed: (e) => `Edit ${e} without saving`,
37
+ editExternallyLabel: "Open in its editor",
38
+ editExternally: "Open the document in its own editor, in a new tab",
39
+ editExternallyNamed: (e) => `Open ${e} in its editor`,
40
+ editorRegion: (e) => `Editing ${e}`,
41
+ editorLabel: (e) => `Markdown of ${e}`,
42
+ editLoading: "Loading the source for editing…",
43
+ editToolbar: "Editor",
44
+ saveDraft: "Save",
45
+ saveDraftTooltip: "Save the draft (Ctrl+S, or ⌘S on a Mac)",
46
+ closeEditor: "Close editor",
47
+ editView: "View",
48
+ editViewNamed: (e) => `View of ${e}`,
49
+ editViewEditor: "Editor",
50
+ editViewEditorTooltip: "Show the editor (Ctrl+E, or ⌘E on a Mac, switches with the preview)",
51
+ editViewSplit: "Side by side",
52
+ editViewSplitTooltip: "Show the editor and the preview side by side",
53
+ editViewPreview: "Preview",
54
+ editViewPreviewTooltip: "Show the preview (Ctrl+E, or ⌘E on a Mac, switches with the editor)",
55
+ historyOpen: "History",
56
+ draftUnsaved: "Unsaved changes",
57
+ draftStatus: "Draft, not saved",
58
+ draftNotSaved: "This draft is not saved: the document cannot be saved here.",
59
+ draftSaving: "Saving…",
60
+ draftSaved: "Saved",
61
+ draftSavedMerged: "Saved, merged with changes saved elsewhere",
62
+ draftConflicts: (e) => e === 1 ? "1 conflict with changes saved elsewhere: choose what to keep, then save" : `${e} conflicts with changes saved elsewhere: choose what to keep, then save`,
63
+ draftSaveFailed: (e) => `Could not save: ${e}`,
64
+ documentSaved: (e) => `Saved ${e}`,
65
+ documentSavedMerged: (e) => `Saved ${e}, merged with changes saved elsewhere`,
66
+ conflictOurs: "your draft",
67
+ conflictTheirs: "saved elsewhere",
68
+ conflictUseOurs: "Use my lines",
69
+ conflictUseTheirs: "Use the saved lines",
70
+ conflictKeepBoth: "Keep both",
71
+ conflictNext: "Next conflict",
72
+ editGrantTitle: "Editing needs your permission",
73
+ editGrantBody: "Allow this site to change documents on your behalf. You are asked once; signing out asks again.",
74
+ editGrantAction: "Grant permission",
75
+ editGrantRetry: "Try again",
76
+ unsavedTitle: "Discard unsaved changes?",
77
+ unsavedBody: (e) => `${e} has changes that are not saved.`,
78
+ unsavedDiscard: "Discard changes",
79
+ draftDiscardTitle: "Discard the draft?",
80
+ draftDiscardBody: (e) => `The changes to ${e} are not saved anywhere and will be lost.`,
81
+ unsavedStay: "Keep editing",
82
+ historyTitle: (e) => `Revisions of ${e}`,
83
+ historyLoading: "Loading the revisions…",
84
+ historyEmpty: "No revisions are kept for this document.",
85
+ historyCurrent: "Current",
86
+ historyKept: "Kept",
87
+ historyEntry: (e, t) => t === "" ? e : `${e} by ${t}`,
88
+ historyRestore: "Put into the draft",
89
+ historyClose: "Close",
90
+ historyRestored: (e) => `Put the revision into the draft of ${e}; save to keep it`,
91
+ previewRegion: "Preview",
92
+ previewUpdating: "Updating the preview…",
93
+ previewFailed: (e) => `Could not preview: ${e}`,
94
+ expandAll: "Expand all folders",
95
+ collapseAll: "Collapse all folders",
96
+ treeSettings: "Tree settings",
97
+ switchToMulti: "Open in the multi-panel view",
98
+ switchToTree: "Open in the tree view",
99
+ resizeExplorer: "Resize the explorer",
100
+ showExplorer: "Show the explorer",
101
+ hideExplorer: "Close the explorer",
102
+ treeRegion: "Documents",
103
+ treeLoading: "Loading the tree…",
104
+ treeEmptyTitle: "Nothing to show",
105
+ treeEmptyBody: "This source has no documents you can open.",
106
+ folderLoadFailed: "This folder could not be loaded.",
107
+ loopFolderName: (e) => `${e} (already open above)`,
108
+ foldersLoadFailedNamed: (e) => `${new Intl.ListFormat("en", { type: "conjunction" }).format(e)} could not be loaded`,
109
+ foldersLoading: (e) => e === 1 ? "Loading 1 folder…" : `Loading ${String(e)} folders…`,
110
+ expandAllStarted: "Opening all folders…",
111
+ expandAllProgress: (e, t) => `Opening all folders (${String(e)} opened, ${String(t)} loading)…`,
112
+ expandAllDone: (e, t, n) => {
113
+ const r = `Opened ${String(e)} ${e === 1 ? "folder" : "folders"}`;
114
+ return t > 0 ? `${r}; ${String(t)} could not be loaded` : n ? e === 0 ? "All folders are already open" : `${r}; every folder is open` : r;
115
+ },
116
+ expandAllFolderLimit: (e, t, n) => `Opened ${String(e)} ${e === 1 ? "folder" : "folders"} and stopped at the limit of ${String(t)} ${t === 1 ? "folder" : "folders"} to load. Choose "${n}" again to continue`,
117
+ expandAllDepthLimit: (e, t) => `Opened ${String(e)} ${e === 1 ? "folder" : "folders"}; folders more than ${String(t)} ${t === 1 ? "level" : "levels"} deep stay closed`,
118
+ treeEntryKindDirectory: "directory",
119
+ treeEntryKindFile: "file",
120
+ treeScrollUp: "Scroll up",
121
+ treeScrollDown: "Scroll down",
122
+ treeScrollToTop: "Top",
123
+ treeScrollToBottom: "Bottom",
124
+ selectionTitle: (e) => `Selected (${String(e)})`,
125
+ clearSelection: "Clear the selection",
126
+ openSelectionInMulti: (e) => `Open ${String(e)} in panels`,
127
+ removeFromSelection: (e) => `Remove ${e} from the selection`,
128
+ settingSortMode: "Sort order",
129
+ sortNative: "Source order",
130
+ sortAscending: "Name A→Z",
131
+ sortDescending: "Name Z→A",
132
+ sortOldest: "Modified old→new",
133
+ sortNewest: "Modified new→old",
134
+ settingFolderPlacement: "Folders",
135
+ folderPlacementMixed: "Mixed",
136
+ folderPlacementFirst: "First",
137
+ folderPlacementLast: "Last",
138
+ settingSelectionMode: "Selection",
139
+ selectionSingle: "Single",
140
+ selectionMultiple: "Multiple",
141
+ selectionNone: "Off",
142
+ settingDoubleClick: "Double-click",
143
+ doubleClickRecursive: "Expand all levels",
144
+ doubleClickToggle: "Toggle",
145
+ settingExpandIconSize: "Expander size",
146
+ expandIconSizeValue: (e) => `${String(e)} px`,
147
+ settingAlwaysExpanded: "Always expanded",
148
+ settingRevealDocument: "Reveal the open document",
149
+ settingRemoveRootIndent: "No root indent",
150
+ settingTreeLines: "Tree lines",
151
+ settingExpandIcons: "Expanders",
152
+ settingDirectoryIcons: "Folder icons",
153
+ settingFileIcons: "File icons",
154
+ settingOn: "On",
155
+ settingOff: "Off",
156
+ settingAnnouncement: (e, t) => `${e}: ${t}`,
157
+ documentRegion: "Document",
158
+ documentEmpty: "Select a document in the explorer.",
159
+ documentLoading: "Loading the document…",
160
+ markupLoading: "Loading the source…",
161
+ documentShown: (e) => `Showing ${e}`,
162
+ documentFailed: (e, t) => `${e}: ${t}`,
163
+ announcementSequence: (e) => e.map((t) => /[.!?]$/u.test(t) ? t : `${t}.`).join(" "),
164
+ textTruncated: "Only the beginning of this file is shown.",
165
+ inertLink: "This link points outside the source and cannot be opened.",
166
+ failureUnauthorizedTitle: "Your session has expired",
167
+ failureUnauthorizedBody: "Reload the page to sign in again.",
168
+ failureForbiddenTitle: "Access denied",
169
+ failureForbiddenBody: "You do not have permission to open this.",
170
+ failureNotFoundTitle: "Not found",
171
+ failureNotFoundBody: "It may have been moved or deleted.",
172
+ failureNotConfiguredTitle: "This source is not set up",
173
+ failureNotConfiguredBody: "Ask your administrator to configure it.",
174
+ failureInvalidTitle: "Invalid address",
175
+ failureInvalidBody: "The document path in this address cannot be used.",
176
+ failureTooLargeTitle: "Too large to display",
177
+ failureTooLargeBody: "This file exceeds the size that can be displayed.",
178
+ failureUnsupportedTitle: "Cannot be displayed",
179
+ failureUnsupportedBody: "This type of file cannot be shown here.",
180
+ failureFailedTitle: "Something went wrong",
181
+ failureFailedBody: "Try again in a moment.",
182
+ retry: "Try again",
183
+ reloadPage: "Reload the page",
184
+ imageZoomIn: "Zoom in",
185
+ imageZoomOut: "Zoom out",
186
+ imageFit: "Fit to the view",
187
+ imageFitLevel: "Fit",
188
+ imageZoomLevel: (e) => `${String(e)}%`,
189
+ openInNewTab: "Open in a new tab",
190
+ download: "Download",
191
+ copyText: "Copy the text",
192
+ copiedText: "Copied the text",
193
+ copyTextFailed: "Could not copy the text",
194
+ mediaUnsupported: "Your browser cannot play this file.",
195
+ fileNotShown: "This file cannot be shown here. Download it to open it.",
196
+ viewerLoading: "Loading data...",
197
+ viewerErrorPrefix: "Error: ",
198
+ viewerStyleTitle: "Display Style",
199
+ viewerSelectStyle: "Select display style",
200
+ viewerPinStyle: "Pin style selector",
201
+ viewerUnpinStyle: "Unpin style selector",
202
+ viewerErrorTitle: "An error occurred",
203
+ viewerMissingImage: "Image not found",
204
+ viewerOpenToc: "Open table of contents",
205
+ viewerTocTitle: "Table of contents",
206
+ viewerPinToc: "Pin table of contents",
207
+ viewerUnpinToc: "Unpin table of contents",
208
+ viewerSelectAlign: "Select alignment",
209
+ viewerAlignTitle: "Alignment",
210
+ viewerPinAlign: "Pin alignment selector",
211
+ viewerUnpinAlign: "Unpin alignment selector",
212
+ viewerAlignLeft: "Align left",
213
+ viewerAlignCenter: "Align center",
214
+ viewerAlignRight: "Align right",
215
+ viewerMermaidInteractionMode: "Mouse interaction mode",
216
+ viewerMermaidModeNone: "No interaction",
217
+ viewerMermaidModeZoom: "Zoom only",
218
+ viewerMermaidModePan: "Pan only (drag)",
219
+ viewerMermaidModePanShift: "Pan only (Shift+drag)",
220
+ viewerMermaidModeBoth: "Zoom and pan (drag)",
221
+ viewerMermaidModeBothShift: "Zoom and pan (Shift+drag)",
222
+ viewerMermaidZoomIn: "Zoom In",
223
+ viewerMermaidZoomOut: "Zoom Out",
224
+ viewerMermaidResetView: "Reset View",
225
+ viewerMermaidRetry: "Try again",
226
+ viewerEmbeddedVideo: "embedded video",
227
+ viewerEmbeddedPost: "embedded post",
228
+ viewerEmbeddedFrame: "Embedded content",
229
+ multiRegion: "Panels",
230
+ multiEmpty: "Select documents in the explorer to open them side by side.",
231
+ panelLimit: (e) => `You can open up to ${String(e)} panels at once.`,
232
+ panelOpened: (e) => `Opened ${e}`,
233
+ panelClosed: (e) => `Closed ${e}`,
234
+ panelAlreadyOpen: (e) => `${e} is already open`,
235
+ panelHidden: (e) => `Hid ${e}`,
236
+ panelShown: (e) => `Showed ${e}`,
237
+ panelMaximized: (e) => `Maximized ${e}`,
238
+ panelRestored: (e) => `Restored ${e} to its size`,
239
+ panelHide: "Hide the panel",
240
+ panelMaximize: "Maximize the panel",
241
+ panelRestore: "Restore the panel to its size",
242
+ panelClose: "Close the panel",
243
+ panelSwitchToCustomDrag: "Switch to the custom drag mode",
244
+ panelSwitchToNormalDrag: "Back to the normal drag mode",
245
+ panelCustomDragBadge: "Custom",
246
+ panelMovePreviousColumn: "Move to the previous column",
247
+ panelMoveNextColumn: "Move to the next column",
248
+ panelMoveUp: "Move up",
249
+ panelMoveDown: "Move down",
250
+ panelMoved: "Moved {title} to column {column}, position {position}",
251
+ panelMoveUnavailable: "{move} is not available for {title}",
252
+ panelDragStarted: "Picked up {title}",
253
+ panelDragCancelled: "Kept {title} where it was",
254
+ hiddenPanelsTitle: "Hidden panels:",
255
+ hiddenPanelBadge: "Hidden",
256
+ hiddenPanelNotice: "This panel is hidden",
257
+ multiColumnEmpty: "This column is empty",
258
+ multiColumnRegion: "Column {column}",
259
+ panelDropHere: "Drop the panel here"
260
+ }, vr = {
261
+ explorerRegion: "エクスプローラー",
262
+ sourceLabel: "ソース",
263
+ refreshTreeLabel: "ツリーを更新",
264
+ refreshTree: "ソースからツリーと開いている文書を読み込み直す",
265
+ treeRefreshed: "ツリーをソースから読み込み直しました",
266
+ treeRefreshFailed: (e) => `ツリーを読み込み直せませんでした: ${e}`,
267
+ refreshDocumentLabel: "文書を更新",
268
+ refreshDocument: "ソースから文書を読み込み直す",
269
+ refreshDocumentNamed: (e) => `${e} を更新`,
270
+ documentRefreshed: (e) => `${e} を読み込み直しました`,
271
+ documentRefreshFailed: (e) => `文書を読み込み直せませんでした: ${e}`,
272
+ showMarkupLabel: "ソース",
273
+ showMarkup: "文書の Markdown を書いたまま表示",
274
+ showMarkupNamed: (e) => `${e} のソース`,
275
+ editDocumentLabel: "編集",
276
+ editDocument: "文書の Markdown を編集 (文書のダブルクリックでも)",
277
+ editDocumentNamed: (e) => `${e} を編集`,
278
+ editDraftDocument: "文書の Markdown を保存せずに編集し、プレビューで確かめる (文書のダブルクリックでも)",
279
+ editDraftDocumentNamed: (e) => `${e} を保存せずに編集`,
280
+ editExternallyLabel: "元のエディタで開く",
281
+ editExternally: "文書を元のエディタで、新しいタブに開く",
282
+ editExternallyNamed: (e) => `${e} を元のエディタで開く`,
283
+ editorRegion: (e) => `${e} を編集中`,
284
+ editorLabel: (e) => `${e} の Markdown`,
285
+ editLoading: "編集のためにソースを読み込み中…",
286
+ editToolbar: "エディタ",
287
+ saveDraft: "保存",
288
+ saveDraftTooltip: "下書きを保存 (Ctrl+S、Mac は ⌘S)",
289
+ closeEditor: "編集を閉じる",
290
+ editView: "表示",
291
+ editViewNamed: (e) => `${e} の表示`,
292
+ editViewEditor: "エディタ",
293
+ editViewEditorTooltip: "エディタを表示 (Ctrl+E、Mac は ⌘E でプレビューと切り替え)",
294
+ editViewSplit: "並べて表示",
295
+ editViewSplitTooltip: "エディタとプレビューを並べて表示",
296
+ editViewPreview: "プレビュー",
297
+ editViewPreviewTooltip: "プレビューを表示 (Ctrl+E、Mac は ⌘E でエディタと切り替え)",
298
+ historyOpen: "履歴",
299
+ draftUnsaved: "保存していない変更があります",
300
+ draftStatus: "保存しない下書き",
301
+ draftNotSaved: "この下書きは保存しません。ここでは文書を保存できません。",
302
+ draftSaving: "保存中…",
303
+ draftSaved: "保存しました",
304
+ draftSavedMerged: "ほかで保存された変更と統合して保存しました",
305
+ draftConflicts: (e) => `ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,
306
+ draftSaveFailed: (e) => `保存できませんでした: ${e}`,
307
+ documentSaved: (e) => `${e} を保存しました`,
308
+ documentSavedMerged: (e) => `${e} を、ほかで保存された変更と統合して保存しました`,
309
+ conflictOurs: "あなたの下書き",
310
+ conflictTheirs: "ほかで保存された版",
311
+ conflictUseOurs: "自分の行を使う",
312
+ conflictUseTheirs: "保存された行を使う",
313
+ conflictKeepBoth: "両方を残す",
314
+ conflictNext: "次の衝突へ",
315
+ editGrantTitle: "編集には許可が必要です",
316
+ editGrantBody: "このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",
317
+ editGrantAction: "許可する",
318
+ editGrantRetry: "もう一度試す",
319
+ unsavedTitle: "保存していない変更を破棄しますか?",
320
+ unsavedBody: (e) => `${e} に保存していない変更があります。`,
321
+ unsavedDiscard: "変更を破棄",
322
+ draftDiscardTitle: "下書きを破棄しますか?",
323
+ draftDiscardBody: (e) => `${e} への変更はどこにも保存されず、失われます。`,
324
+ unsavedStay: "編集を続ける",
325
+ historyTitle: (e) => `${e} の版`,
326
+ historyLoading: "版の一覧を読み込み中…",
327
+ historyEmpty: "この文書の版は残っていません。",
328
+ historyCurrent: "現在の版",
329
+ historyKept: "保持",
330
+ historyEntry: (e, t) => t === "" ? e : `${e} (${t})`,
331
+ historyRestore: "下書きに戻す",
332
+ historyClose: "閉じる",
333
+ historyRestored: (e) => `${e} の下書きに版を戻しました。残すには保存してください`,
334
+ previewRegion: "プレビュー",
335
+ previewUpdating: "プレビューを更新中…",
336
+ previewFailed: (e) => `プレビューできませんでした: ${e}`,
337
+ expandAll: "すべてのフォルダーを展開",
338
+ collapseAll: "すべてのフォルダーを折りたたむ",
339
+ treeSettings: "ツリーの設定",
340
+ switchToMulti: "マルチビューで開く",
341
+ switchToTree: "ツリービューで開く",
342
+ resizeExplorer: "エクスプローラーの幅を変更",
343
+ showExplorer: "エクスプローラーを開く",
344
+ hideExplorer: "エクスプローラーを閉じる",
345
+ treeRegion: "文書の一覧",
346
+ treeLoading: "ツリーを読み込み中…",
347
+ treeEmptyTitle: "表示できるファイルがありません",
348
+ treeEmptyBody: "このソースには開ける文書がありません。",
349
+ folderLoadFailed: "このフォルダーを読み込めませんでした。",
350
+ loopFolderName: (e) => `${e} (上の階層で開いています)`,
351
+ foldersLoadFailedNamed: (e) => `${new Intl.ListFormat("ja", { type: "conjunction" }).format(e)} を読み込めませんでした`,
352
+ foldersLoading: (e) => `フォルダーを ${String(e)} 件読み込み中…`,
353
+ expandAllStarted: "すべてのフォルダーを展開しています…",
354
+ expandAllProgress: (e, t) => `すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,
355
+ expandAllDone: (e, t, n) => {
356
+ const r = `${String(e)} 件のフォルダーを展開しました`;
357
+ return t > 0 ? `${r}。うち ${String(t)} 件は読み込めませんでした` : n ? e === 0 ? "すべてのフォルダーが既に開いています" : `${r}。すべてのフォルダーが開いています` : r;
358
+ },
359
+ expandAllFolderLimit: (e, t, n) => `${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,
360
+ expandAllDepthLimit: (e, t) => `${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,
361
+ treeEntryKindDirectory: "ディレクトリ",
362
+ treeEntryKindFile: "ファイル",
363
+ treeScrollUp: "上へスクロール",
364
+ treeScrollDown: "下へスクロール",
365
+ treeScrollToTop: "先頭へ",
366
+ treeScrollToBottom: "末尾へ",
367
+ selectionTitle: (e) => `選択中 (${String(e)})`,
368
+ clearSelection: "選択を解除",
369
+ openSelectionInMulti: (e) => `${String(e)} 件をパネルで開く`,
370
+ removeFromSelection: (e) => `${e} を選択から外す`,
371
+ settingSortMode: "並び順",
372
+ sortNative: "取得順",
373
+ sortAscending: "名前の昇順",
374
+ sortDescending: "名前の降順",
375
+ sortOldest: "更新日時の昇順 (古い順)",
376
+ sortNewest: "更新日時の降順 (新しい順)",
377
+ settingFolderPlacement: "フォルダーの位置",
378
+ folderPlacementMixed: "混ぜる",
379
+ folderPlacementFirst: "先に",
380
+ folderPlacementLast: "後に",
381
+ settingSelectionMode: "選択",
382
+ selectionSingle: "1 件",
383
+ selectionMultiple: "複数",
384
+ selectionNone: "オフ",
385
+ settingDoubleClick: "ダブルクリック",
386
+ doubleClickRecursive: "下の階層まで展開",
387
+ doubleClickToggle: "開閉",
388
+ settingExpandIconSize: "展開アイコンの大きさ",
389
+ expandIconSizeValue: (e) => `${String(e)} px`,
390
+ settingAlwaysExpanded: "常に展開",
391
+ settingRevealDocument: "開いた文書をツリーで表示",
392
+ settingRemoveRootIndent: "最上位の字下げなし",
393
+ settingTreeLines: "ツリーの線",
394
+ settingExpandIcons: "展開アイコン",
395
+ settingDirectoryIcons: "フォルダーのアイコン",
396
+ settingFileIcons: "ファイルのアイコン",
397
+ settingOn: "オン",
398
+ settingOff: "オフ",
399
+ settingAnnouncement: (e, t) => `${e}: ${t}`,
400
+ documentRegion: "文書",
401
+ documentEmpty: "エクスプローラーで文書を選んでください。",
402
+ documentLoading: "文書を読み込み中…",
403
+ markupLoading: "ソースを読み込み中…",
404
+ documentShown: (e) => `${e} を表示しています`,
405
+ documentFailed: (e, t) => `${e}: ${t}`,
406
+ announcementSequence: (e) => e.map((t) => /[。!?]$/u.test(t) ? t : `${t}。`).join(""),
407
+ textTruncated: "このファイルは先頭だけを表示しています。",
408
+ inertLink: "リンク先がソースの外にあるため開けません。",
409
+ failureUnauthorizedTitle: "セッションの有効期限が切れました",
410
+ failureUnauthorizedBody: "ページを再読み込みして、もう一度サインインしてください。",
411
+ failureForbiddenTitle: "アクセスが許可されていません",
412
+ failureForbiddenBody: "これを開く権限がありません。",
413
+ failureNotFoundTitle: "見つかりません",
414
+ failureNotFoundBody: "移動または削除された可能性があります。",
415
+ failureNotConfiguredTitle: "このソースは設定されていません",
416
+ failureNotConfiguredBody: "管理者に設定を依頼してください。",
417
+ failureInvalidTitle: "アドレスが正しくありません",
418
+ failureInvalidBody: "このアドレスに含まれる文書の経路は使えません。",
419
+ failureTooLargeTitle: "大きすぎて表示できません",
420
+ failureTooLargeBody: "このファイルは表示できる大きさを超えています。",
421
+ failureUnsupportedTitle: "表示できない形式です",
422
+ failureUnsupportedBody: "この種類のファイルはここでは表示できません。",
423
+ failureFailedTitle: "読み込みに失敗しました",
424
+ failureFailedBody: "しばらくしてからもう一度お試しください。",
425
+ retry: "再試行",
426
+ reloadPage: "ページを再読み込み",
427
+ imageZoomIn: "拡大",
428
+ imageZoomOut: "縮小",
429
+ imageFit: "画面に合わせる",
430
+ imageFitLevel: "全体",
431
+ imageZoomLevel: (e) => `${String(e)}%`,
432
+ openInNewTab: "新しいタブで開く",
433
+ download: "ダウンロード",
434
+ copyText: "テキストをコピー",
435
+ copiedText: "テキストをコピーしました",
436
+ copyTextFailed: "テキストをコピーできませんでした",
437
+ mediaUnsupported: "このブラウザではこのファイルを再生できません。",
438
+ fileNotShown: "このファイルはここでは表示できません。ダウンロードして開いてください。",
439
+ viewerLoading: "データを読み込み中...",
440
+ viewerErrorPrefix: "エラー: ",
441
+ viewerStyleTitle: "表示スタイル",
442
+ viewerSelectStyle: "表示スタイルを選択",
443
+ viewerPinStyle: "スタイル選択をピン留め",
444
+ viewerUnpinStyle: "スタイル選択のピン留めを解除",
445
+ viewerErrorTitle: "エラーが発生しました",
446
+ viewerMissingImage: "画像が見つかりません",
447
+ viewerOpenToc: "目次を開く",
448
+ viewerTocTitle: "目次",
449
+ viewerPinToc: "目次をピン留め",
450
+ viewerUnpinToc: "目次のピン留めを解除",
451
+ viewerSelectAlign: "揃えを選択",
452
+ viewerAlignTitle: "揃え",
453
+ viewerPinAlign: "揃え選択をピン留め",
454
+ viewerUnpinAlign: "揃え選択のピン留めを解除",
455
+ viewerAlignLeft: "左揃え",
456
+ viewerAlignCenter: "中央揃え",
457
+ viewerAlignRight: "右揃え",
458
+ viewerMermaidInteractionMode: "マウス操作モード",
459
+ viewerMermaidModeNone: "操作なし",
460
+ viewerMermaidModeZoom: "拡大縮小のみ",
461
+ viewerMermaidModePan: "移動のみ (左ドラッグ)",
462
+ viewerMermaidModePanShift: "移動のみ (Shift+ドラッグ)",
463
+ viewerMermaidModeBoth: "拡大縮小+移動 (左ドラッグ)",
464
+ viewerMermaidModeBothShift: "拡大縮小+移動 (Shift+ドラッグ)",
465
+ viewerMermaidZoomIn: "拡大",
466
+ viewerMermaidZoomOut: "縮小",
467
+ viewerMermaidResetView: "表示を元に戻す",
468
+ viewerMermaidRetry: "再試行",
469
+ viewerEmbeddedVideo: "埋め込みの動画",
470
+ viewerEmbeddedPost: "埋め込みの投稿",
471
+ viewerEmbeddedFrame: "埋め込みのコンテンツ",
472
+ multiRegion: "パネル",
473
+ multiEmpty: "エクスプローラーで文書を選ぶと、ここに並べて開きます。",
474
+ panelLimit: (e) => `同時に開けるのは ${String(e)} パネルまでです。`,
475
+ panelOpened: (e) => `${e} を開きました`,
476
+ panelClosed: (e) => `${e} を閉じました`,
477
+ panelAlreadyOpen: (e) => `${e} は既に開いています`,
478
+ panelHidden: (e) => `${e} を隠しました`,
479
+ panelShown: (e) => `${e} を表示しました`,
480
+ panelMaximized: (e) => `${e} を最大化しました`,
481
+ panelRestored: (e) => `${e} を元のサイズに戻しました`,
482
+ panelHide: "パネルを隠す",
483
+ panelMaximize: "パネルを最大化",
484
+ panelRestore: "パネルを元のサイズに戻す",
485
+ panelClose: "パネルを閉じる",
486
+ panelSwitchToCustomDrag: "カスタムのドラッグの方式に切り替え",
487
+ panelSwitchToNormalDrag: "通常のドラッグの方式に戻す",
488
+ panelCustomDragBadge: "カスタム",
489
+ panelMovePreviousColumn: "前の列へ移動",
490
+ panelMoveNextColumn: "次の列へ移動",
491
+ panelMoveUp: "上へ移動",
492
+ panelMoveDown: "下へ移動",
493
+ panelMoved: "{title} を {column} 列目の {position} 番目へ移動しました",
494
+ panelMoveUnavailable: "{title} は「{move}」できません",
495
+ panelDragStarted: "{title} を持ち上げました",
496
+ panelDragCancelled: "{title} の移動を取り消しました",
497
+ hiddenPanelsTitle: "隠したパネル:",
498
+ hiddenPanelBadge: "非表示",
499
+ hiddenPanelNotice: "このパネルは隠しています",
500
+ multiColumnEmpty: "この列は空です",
501
+ multiColumnRegion: "{column} 列目",
502
+ panelDropHere: "ここへパネルをドロップ"
503
+ }, wr = Object.freeze({
504
+ en: Object.freeze(tn),
505
+ ja: Object.freeze(vr)
506
+ }), nn = Object.freeze(Object.keys(tn)), gr = new Set(nn), br = (e) => gr.has(e), Ce = (e) => e === null ? "null" : typeof e == "string" ? JSON.stringify(e.length > 40 ? `${e.slice(0, 40)}…` : e) : typeof e == "function" ? "a function" : Array.isArray(e) ? "an array" : typeof e, rn = (e) => {
507
+ if (e === void 0) return mr;
508
+ if (Et.includes(e)) return e;
509
+ throw new RangeError(`[markdown-explorer] locale is the UI language (${Et.map((t) => JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Ce(e)}`);
510
+ }, yt = (e, t) => {
511
+ const n = wr[rn(e)];
512
+ if (t === void 0) return n;
513
+ if (t === null || typeof t != "object")
514
+ throw new RangeError(`[markdown-explorer] labels must be an object; got ${Ce(t)}`);
515
+ if (!Fn(t))
516
+ throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Ce(t)}`);
517
+ const r = t, o = { ...n };
518
+ for (const i of Object.keys(r)) {
519
+ if (!br(i))
520
+ throw new RangeError(`[markdown-explorer] labels.${i} is not a known label key; expected one of ${nn.join(", ")}`);
521
+ const l = r[i];
522
+ if (l === void 0) continue;
523
+ const d = typeof n[i];
524
+ if (typeof l !== d)
525
+ throw new TypeError(`[markdown-explorer] labels.${i} must be a ${d}; got ${Ce(l)}`);
526
+ if (typeof l == "string" && l.trim() === "")
527
+ throw new RangeError(`[markdown-explorer] labels.${i} must be a non-blank string`);
528
+ const p = hr[i];
529
+ if (typeof l == "string" && p !== void 0) {
530
+ for (const [, f] of l.matchAll(pr))
531
+ if (!p.includes(f ?? ""))
532
+ throw new RangeError(`[markdown-explorer] labels.${i} uses the unknown placeholder {${String(f)}}; it accepts ${p.map((u) => `{${u}}`).join(", ")}`);
533
+ }
534
+ o[i] = l;
535
+ }
536
+ return Object.freeze(o);
537
+ }, Er = (e, t) => {
538
+ if (Object.is(e, t)) return !0;
539
+ if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
540
+ const n = e, r = t, o = Object.keys(n), i = Object.keys(r);
541
+ return o.length === i.length && i.every((l) => Object.hasOwn(n, l) && Object.is(n[l], r[l]));
542
+ }, kt = Object.freeze(["light", "dark"]), yr = (e) => {
543
+ if (e === void 0) return "light";
544
+ if (kt.includes(e)) return e;
545
+ throw new RangeError(`[markdown-explorer] theme must be ${kt.map((t) => JSON.stringify(t)).join(" or ")}; got ${typeof e == "string" ? JSON.stringify(e) : typeof e}`);
546
+ }, on = me(null), D = () => {
547
+ const e = ne(on);
548
+ if (e === null) throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");
549
+ return e;
550
+ }, Ae = (e) => {
551
+ const { viewSettings: t } = D(), n = () => e(t.getSnapshot());
552
+ return ee(t.subscribe, n, n);
553
+ }, nt = () => {
554
+ const { config: e } = D(), t = An()["*"], [n] = Ln(), r = n.toString();
555
+ return U(() => Xt(e, t, new URLSearchParams(r)), [e, t, r]);
556
+ }, ln = {
557
+ unauthorized: ["failureUnauthorizedTitle", "failureUnauthorizedBody"],
558
+ forbidden: ["failureForbiddenTitle", "failureForbiddenBody"],
559
+ "not-found": ["failureNotFoundTitle", "failureNotFoundBody"],
560
+ "not-configured": ["failureNotConfiguredTitle", "failureNotConfiguredBody"],
561
+ invalid: ["failureInvalidTitle", "failureInvalidBody"],
562
+ "too-large": ["failureTooLargeTitle", "failureTooLargeBody"],
563
+ unsupported: ["failureUnsupportedTitle", "failureUnsupportedBody"],
564
+ failed: ["failureFailedTitle", "failureFailedBody"]
565
+ }, se = (e, t) => e[ln[t][0]], ge = ({ failure: e, alert: t, onRetry: n, testId: r }) => {
566
+ const { labels: o } = D(), i = se(o, e.reason), l = o[ln[e.reason][1]], d = e.reason === "unauthorized" || e.reason === "forbidden" || e.reason === "failed" ? "danger" : "warning";
567
+ return /* @__PURE__ */ F("div", { className: "aqmx-callout", role: t ? "alert" : void 0, "data-aqmx-tone": d, "data-testid": r === null ? void 0 : r, "data-aqmx-failure": r === null ? void 0 : e.reason, children: [
568
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-title", children: i }),
569
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: l }),
570
+ e.reason === "unauthorized" ? /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", onClick: () => window.location.reload(), children: o.reloadPage }) : n !== void 0 && e.reason === "failed" ? /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", onClick: n, children: o.retry }) : null
571
+ ] });
572
+ }, kr = (e, t) => {
573
+ const { phase: n, save: r, dirty: o } = t;
574
+ switch (n.kind) {
575
+ case "opening":
576
+ return e.editLoading;
577
+ case "grant":
578
+ return e.editGrantTitle;
579
+ case "failed":
580
+ return se(e, n.failure.reason);
581
+ }
582
+ switch (r.kind) {
583
+ case "draft":
584
+ return e.draftStatus;
585
+ case "saving":
586
+ return e.draftSaving;
587
+ case "conflicts":
588
+ return e.draftConflicts(r.count);
589
+ case "grant":
590
+ return e.editGrantTitle;
591
+ case "failed":
592
+ return e.draftSaveFailed(se(e, r.failure.reason));
593
+ case "saved":
594
+ if (!o) return r.merged ? e.draftSavedMerged : e.draftSaved;
595
+ break;
596
+ }
597
+ return o ? e.draftUnsaved : "";
598
+ }, xr = (e, t, n) => {
599
+ switch (t.kind) {
600
+ case "draft":
601
+ return e.draftNotSaved;
602
+ case "saved":
603
+ return t.merged ? e.documentSavedMerged(n) : e.documentSaved(n);
604
+ case "conflicts":
605
+ return e.draftConflicts(t.count);
606
+ case "grant":
607
+ return e.editGrantTitle;
608
+ case "failed":
609
+ return e.draftSaveFailed(se(e, t.failure.reason));
610
+ case "idle":
611
+ case "saving":
612
+ return null;
613
+ }
614
+ }, ke = () => {
615
+ const e = /* @__PURE__ */ new Set();
616
+ return {
617
+ subscribe: (t) => (e.add(t), () => {
618
+ e.delete(t);
619
+ }),
620
+ emit: () => {
621
+ for (const t of [...e]) t();
622
+ }
623
+ };
624
+ }, Sr = "<<<<<<<", Rr = "=======", Tr = ">>>>>>>", xt = (e, t) => e === t || e.startsWith(`${t} `), St = (e) => Cr(e.split(`
625
+ `)), Cr = (e) => {
626
+ const t = [];
627
+ let n = null, r = null, o = 0;
628
+ for (const i of e) {
629
+ o += 1;
630
+ const l = i.charCodeAt(0);
631
+ l !== 60 && l !== 61 && l !== 62 || (xt(i, Sr) ? (n = o, r = null) : i === Rr ? n !== null && r === null ? r = o : n = null : xt(i, Tr) && (n !== null && r !== null && t.push({ start: n, separator: r, end: o }), n = null, r = null));
632
+ }
633
+ return t;
634
+ }, Rt = (e) => e.includes(`\r
635
+ `) ? `\r
636
+ ` : `
637
+ `, ze = (e) => e.replace(/\r\n?/gu, `
638
+ `), Or = (e, t) => t === `
639
+ ` ? e : e.replaceAll(`
640
+ `, `\r
641
+ `), Ar = 3, Ue = Object.freeze({ kind: "idle" }), Tt = Object.freeze({ kind: "draft" }), Lr = ({ data: e, conflictLabels: t, onSaveSettled: n, sideBySideSetting: r }) => {
642
+ const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), f = ke();
643
+ let u = null, v = null;
644
+ const m = (a, s) => {
645
+ a.value = { ...a.value, ...s }, f.emit();
646
+ }, y = (a, s) => o.get(a) === s, A = async (a, s) => {
647
+ s.controller.abort(), s.controller = new AbortController();
648
+ const { signal: h } = s.controller;
649
+ m(s, { phase: { kind: "opening" } });
650
+ const g = await e.edit(a, h);
651
+ if (!y(a, s) || h.aborted || !("kind" in g)) return;
652
+ if (g.kind === "grant") {
653
+ m(s, { phase: { kind: "grant", href: g.href } });
654
+ return;
655
+ }
656
+ if (g.kind === "failure") {
657
+ m(s, { phase: { kind: "failed", failure: g.failure } });
658
+ return;
659
+ }
660
+ const R = ze(g.text), L = g.kind === "draft";
661
+ s.base = { text: R, version: L ? null : g.version }, s.draft = R, s.ending = Rt(g.text), m(s, { phase: { kind: "editing" }, history: L ? !1 : g.history, dirty: !1, save: L ? Tt : Ue, generation: s.value.generation + 1 });
662
+ }, k = (a) => {
663
+ const s = o.get(a);
664
+ s !== void 0 && (s.controller.abort(), o.delete(a), l.delete(a));
665
+ }, S = (a, s, h) => (a.set(s, h), () => {
666
+ a.get(s) === h && a.delete(s);
667
+ }), M = (a, s, h, g = {}) => {
668
+ m(s, { ...g, save: h }), n(a, h);
669
+ }, T = async (a) => {
670
+ d.get(a)?.flush();
671
+ const s = o.get(a);
672
+ if (s === void 0 || s.value.phase.kind !== "editing" || s.base === null || s.value.save.kind === "saving") return;
673
+ const { version: h } = s.base;
674
+ if (h === null) {
675
+ n(a, Tt);
676
+ return;
677
+ }
678
+ const g = St(s.draft).length;
679
+ if (g > 0) {
680
+ M(a, s, { kind: "conflicts", count: g });
681
+ return;
682
+ }
683
+ s.controller.abort(), s.controller = new AbortController();
684
+ const { signal: R } = s.controller;
685
+ let L = { text: s.base.text, version: h }, O = s.draft, N = !1;
686
+ m(s, { save: { kind: "saving" } });
687
+ for (let j = 0; j < Ar; j += 1) {
688
+ const I = await e.save(a, L.version, Or(O, s.ending), R);
689
+ if (!y(a, s) || R.aborted || !("kind" in I)) return;
690
+ if (I.kind === "saved") {
691
+ d.get(a)?.flush(), s.base = { text: O, version: I.version }, M(a, s, { kind: "saved", merged: N }, { dirty: s.draft !== O });
692
+ return;
693
+ }
694
+ if (I.kind === "grant") {
695
+ M(a, s, { kind: "grant", href: I.href });
696
+ return;
697
+ }
698
+ if (I.kind === "failure") {
699
+ M(a, s, { kind: "failed", failure: I.failure });
700
+ return;
701
+ }
702
+ const { mergeDraft: X } = await import("./merge-Bb7YRgn4.js");
703
+ if (!y(a, s) || R.aborted) return;
704
+ const Q = d.get(a);
705
+ Q?.flush();
706
+ const J = ze(I.text), H = X(L.text, s.draft, J, t());
707
+ if (L = { text: J, version: I.version }, s.base = L, s.ending = Rt(I.text), s.draft = H.text, Q?.adopt(H.text), H.kind === "conflicts") {
708
+ M(a, s, { kind: "conflicts", count: H.conflicts }, { dirty: !0, generation: s.value.generation + 1 });
709
+ return;
710
+ }
711
+ if (N = !0, O = H.text, O === L.text) {
712
+ M(a, s, { kind: "saved", merged: N }, { dirty: !1, generation: s.value.generation + 1 });
713
+ return;
714
+ }
715
+ m(s, { dirty: !0, generation: s.value.generation + 1 });
716
+ }
717
+ M(a, s, { kind: "failed", failure: { reason: "failed" } });
718
+ };
719
+ return {
720
+ session: (a) => o.get(a)?.value,
721
+ subscribe: f.subscribe,
722
+ start: (a, s) => {
723
+ const h = o.get(a);
724
+ if (h !== void 0) {
725
+ m(h, { request: { anchor: s }, view: "editor" }), (h.value.phase.kind === "failed" || h.value.phase.kind === "grant") && A(a, h);
726
+ return;
727
+ }
728
+ i.delete(a);
729
+ const g = {
730
+ value: { path: a, phase: { kind: "opening" }, view: "editor", previewPrepared: !1, history: !1, dirty: !1, save: Ue, generation: 0, request: { anchor: s } },
731
+ base: null,
732
+ draft: "",
733
+ ending: `
734
+ `,
735
+ controller: new AbortController()
736
+ };
737
+ o.set(a, g), A(a, g);
738
+ },
739
+ retry: (a) => {
740
+ const s = o.get(a);
741
+ s === void 0 || s.value.phase.kind === "editing" || A(a, s);
742
+ },
743
+ draft: (a) => {
744
+ const s = o.get(a);
745
+ return s === void 0 || s.base === null ? null : s.draft;
746
+ },
747
+ setDraft: (a, s) => {
748
+ const h = o.get(a);
749
+ if (h === void 0 || h.base === null) return;
750
+ h.draft = s;
751
+ const g = {}, R = s !== h.base.text;
752
+ R !== h.value.dirty && (g.dirty = R);
753
+ const { save: L } = h.value;
754
+ if (L.kind === "conflicts") {
755
+ const O = St(s).length;
756
+ O === 0 ? g.save = Ue : O !== L.count && (g.save = { kind: "conflicts", count: O });
757
+ }
758
+ (g.dirty !== void 0 || g.save !== void 0) && m(h, g);
759
+ },
760
+ consumeRequest: (a) => {
761
+ const s = o.get(a);
762
+ s !== void 0 && s.value.request !== null && m(s, { request: null });
763
+ },
764
+ save: T,
765
+ replaceDraft: (a, s) => {
766
+ const h = d.get(a);
767
+ h?.flush();
768
+ const g = o.get(a);
769
+ if (g === void 0 || g.base === null) return;
770
+ const R = ze(s);
771
+ g.draft = R, h?.adopt(R), m(g, { dirty: R !== g.base.text, generation: g.value.generation + 1 });
772
+ },
773
+ close: (a) => {
774
+ if (!o.has(a)) return;
775
+ const s = d.get(a), h = s === void 0 ? null : s.returnPoint();
776
+ k(a), h === null ? i.delete(a) : i.set(a, h), f.emit();
777
+ },
778
+ takeReturn: (a) => {
779
+ const s = i.get(a) ?? null;
780
+ return i.delete(a), s;
781
+ },
782
+ dirtyPaths: () => [...o.values()].filter((a) => a.value.dirty).map((a) => a.value.path),
783
+ discard: (a) => {
784
+ for (const s of a) k(s);
785
+ a.length > 0 && f.emit();
786
+ },
787
+ editorState: {
788
+ get: (a) => l.get(a),
789
+ set: (a, s) => {
790
+ o.has(a) && l.set(a, s);
791
+ }
792
+ },
793
+ bindEditor: (a, s) => S(d, a, s),
794
+ bindView: (a, s) => S(p, a, s),
795
+ viewAnchor: (a) => {
796
+ const s = p.get(a);
797
+ return s === void 0 ? null : s.anchor();
798
+ },
799
+ flush: (a) => d.get(a)?.flush(),
800
+ flushDrafts: () => {
801
+ for (const a of d.values()) a.flush();
802
+ },
803
+ nextConflict: (a) => d.get(a)?.nextConflict() === !0,
804
+ hasSessions: () => o.size > 0,
805
+ unsavedAmong: (a) => {
806
+ for (const s of d.values()) s.flush();
807
+ return a.filter((s) => o.get(s)?.value.dirty === !0);
808
+ },
809
+ askToDiscard: (a) => new Promise((s) => {
810
+ v?.settle(!1);
811
+ const h = {
812
+ paths: a,
813
+ settle: (g) => {
814
+ if (v === h) {
815
+ if (v = null, g) for (const R of a) k(R);
816
+ f.emit(), s(g);
817
+ }
818
+ }
819
+ };
820
+ v = h, f.emit();
821
+ }),
822
+ discardRequest: () => v,
823
+ sideBySide: () => (u ??= r.read(), u),
824
+ setSideBySide: (a) => {
825
+ u !== a && (u = a, r.write(a), f.emit());
826
+ },
827
+ setView: (a, s) => {
828
+ const h = o.get(a);
829
+ h === void 0 || h.value.view === s || (d.get(a)?.beforeView(s), m(h, { view: s, previewPrepared: h.value.previewPrepared || s === "preview" }));
830
+ },
831
+ preparePreview: (a) => {
832
+ const s = o.get(a);
833
+ s !== void 0 && !s.value.previewPrepared && m(s, { previewPrepared: !0 });
834
+ }
835
+ };
836
+ }, rt = (e) => {
837
+ e.preventDefault(), e.stopPropagation();
838
+ }, an = ({ open: e, title: t, body: n, confirmLabel: r, cancelLabel: o, onConfirm: i, onCancel: l, testId: d }) => {
839
+ const p = q(null), f = q(null), u = q(null), v = ve(), m = ve();
840
+ return Z(() => {
841
+ const k = p.current;
842
+ if (k !== null)
843
+ if (e && !k.open) {
844
+ const S = k.ownerDocument.activeElement;
845
+ u.current = S instanceof HTMLElement ? S : null, k.showModal(), f.current?.focus();
846
+ } else !e && k.open && (k.close(), u.current?.isConnected === !0 && u.current.focus(), u.current = null);
847
+ }, [e]), /* @__PURE__ */ c("dialog", { ref: p, className: "aqmx-confirm", "aria-labelledby": v, "aria-describedby": m, "data-testid": d, onKeyDown: (k) => {
848
+ k.key !== "Escape" || k.defaultPrevented || (rt(k), l());
849
+ }, onClick: (k) => {
850
+ k.target === k.currentTarget && l();
851
+ }, onCancel: (k) => k.preventDefault(), children: /* @__PURE__ */ F("div", { className: "aqmx-confirm-panel", children: [
852
+ /* @__PURE__ */ c("p", { id: v, className: "aqmx-confirm-title", children: t }),
853
+ /* @__PURE__ */ c("p", { id: m, className: "aqmx-confirm-body", children: n }),
854
+ /* @__PURE__ */ F("div", { className: "aqmx-confirm-actions", children: [
855
+ /* @__PURE__ */ c("button", { ref: f, type: "button", className: "aqmx-callout-action", "data-testid": `${d}-cancel`, onClick: l, children: o }),
856
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-aqmx-tone": "danger", "data-testid": `${d}-confirm`, onClick: i, children: r })
857
+ ] })
858
+ ] }) });
859
+ }, Mr = (e, t) => {
860
+ const n = Mn({ path: `${e.basePath}/*`, end: !0 }, t.pathname);
861
+ if (n === null) return /* @__PURE__ */ new Set();
862
+ const { location: r } = Xt(e, n.params["*"], new URLSearchParams(t.search));
863
+ switch (r.view) {
864
+ case "tree":
865
+ return new Set(r.doc === null ? [] : [r.doc]);
866
+ case "single":
867
+ return /* @__PURE__ */ new Set([r.doc]);
868
+ case "multi":
869
+ return new Set(r.docs);
870
+ }
871
+ }, sn = (e) => {
872
+ const { edits: t } = D(), n = $(() => t.session(e), [t, e]);
873
+ return ee(t.subscribe, n, Nr);
874
+ }, cn = () => !1, Nr = () => {
875
+ }, Dr = () => {
876
+ const { edits: e } = D();
877
+ return ee(e.subscribe, e.hasSessions, cn);
878
+ }, Pr = () => {
879
+ const { edits: e } = D();
880
+ return ee(e.subscribe, e.sideBySide, cn);
881
+ }, $r = () => null, Fr = () => {
882
+ const { edits: e, labels: t, config: n } = D(), r = q([]), o = $(
883
+ ({ nextLocation: m }) => {
884
+ const y = Mr(n, m);
885
+ return e.flushDrafts(), r.current = e.dirtyPaths().filter((A) => !y.has(A)), r.current.length > 0;
886
+ },
887
+ [e, n]
888
+ ), i = Nn(o), l = Dr();
889
+ te(() => {
890
+ if (!l) return;
891
+ const m = (y) => {
892
+ e.flushDrafts(), e.dirtyPaths().length !== 0 && (y.preventDefault(), y.returnValue = !0);
893
+ };
894
+ return window.addEventListener("beforeunload", m), () => window.removeEventListener("beforeunload", m);
895
+ }, [l, e]);
896
+ const d = ee(e.subscribe, e.discardRequest, $r), p = i.state === "blocked", f = p ? r.current : d === null ? [] : d.paths, u = f.map((m) => ye(m)).join(", "), v = f.length > 0 && f.every((m) => e.session(m)?.save.kind === "draft");
897
+ return /* @__PURE__ */ c(
898
+ an,
899
+ {
900
+ open: p || d !== null,
901
+ title: v ? t.draftDiscardTitle : t.unsavedTitle,
902
+ body: v ? t.draftDiscardBody(u) : t.unsavedBody(u),
903
+ confirmLabel: t.unsavedDiscard,
904
+ cancelLabel: t.unsavedStay,
905
+ testId: "markdown-explorer-unsaved-guard",
906
+ onConfirm: () => {
907
+ if (i.state === "blocked") {
908
+ e.discard(r.current), i.proceed();
909
+ return;
910
+ }
911
+ d?.settle(!0);
912
+ },
913
+ onCancel: () => {
914
+ if (i.state === "blocked") {
915
+ i.reset();
916
+ return;
917
+ }
918
+ d?.settle(!1);
919
+ }
920
+ }
921
+ );
922
+ };
923
+ function qr({
924
+ title: e,
925
+ titleId: t,
926
+ ...n
927
+ }, r) {
928
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
929
+ xmlns: "http://www.w3.org/2000/svg",
930
+ viewBox: "0 0 20 20",
931
+ fill: "currentColor",
932
+ "aria-hidden": "true",
933
+ "data-slot": "icon",
934
+ ref: r,
935
+ "aria-labelledby": t
936
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
937
+ id: t
938
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
939
+ fillRule: "evenodd",
940
+ d: "M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",
941
+ clipRule: "evenodd"
942
+ }));
943
+ }
944
+ const _r = /* @__PURE__ */ b.forwardRef(qr);
945
+ let Ze = null;
946
+ const dn = () => (Ze ??= import("./EditSurface-DheIbHJi.js").catch((e) => {
947
+ throw Ze = null, e;
948
+ }), Ze), Br = () => {
949
+ dn().catch(() => {
950
+ });
951
+ }, Ir = (e) => {
952
+ const { default: t } = ne(dn());
953
+ return /* @__PURE__ */ c(t, { ...e });
954
+ };
955
+ class jr extends Kt {
956
+ state = { failed: !1 };
957
+ static getDerivedStateFromError() {
958
+ return { failed: !0 };
959
+ }
960
+ retry = () => this.setState({ failed: !1 });
961
+ render() {
962
+ return this.state.failed ? this.props.fallback(this.retry) : this.props.children;
963
+ }
964
+ }
965
+ const ot = `[${Jt}]`, Hr = "[data-aqmd-content]", Vr = 'a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg', zr = 200, be = (e) => cr(e.getAttribute(Jt)), Ur = (e, t) => {
966
+ for (let r = e; r !== null && t.contains(r); r = r.parentElement) {
967
+ const o = be(r);
968
+ if (o !== null) return { block: r, lines: o, own: !0 };
969
+ }
970
+ let n = null;
971
+ for (const r of t.querySelectorAll(ot)) {
972
+ if (!(r.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING)) break;
973
+ const o = be(r);
974
+ o !== null && (n = { block: r, lines: o });
975
+ }
976
+ return n === null ? null : { ...n, own: !1 };
977
+ }, Zr = (e, t) => {
978
+ let n = 0;
979
+ for (let r = e.indexOf(t); r >= 0; r = e.indexOf(t, r + t.length)) n += 1;
980
+ return n;
981
+ }, Gr = (e) => e.closest(Hr) !== null && e.closest(Vr) === null, Kr = (e, t, n) => {
982
+ const r = Ur(e, t);
983
+ if (r === null) return null;
984
+ const { block: o, own: i } = r;
985
+ if (!i) {
986
+ const d = r.lines.last + 1;
987
+ return { lines: { first: d, last: d }, word: null, occurrence: 0, clientTop: Le(e) };
988
+ }
989
+ const l = Jr(o, n);
990
+ return l === null ? { lines: r.lines, word: null, occurrence: 0, clientTop: Le(o) } : { lines: r.lines, word: l.text, occurrence: l.occurrence, clientTop: l.clientTop };
991
+ }, Wr = (e, t) => {
992
+ let n = null, r = null, o = null;
993
+ for (const l of e.querySelectorAll(ot)) {
994
+ const d = be(l);
995
+ if (d === null) continue;
996
+ n ??= Yr(t, l);
997
+ const { top: p, bottom: f } = l.getBoundingClientRect();
998
+ p <= n && n < f ? r = { lines: d, block: l } : o === null && p >= n && (o = { lines: d, block: l });
999
+ }
1000
+ const i = r === null ? o : r;
1001
+ return i === null ? null : { lines: i.lines, word: null, occurrence: 0, clientTop: Le(i.block) };
1002
+ }, Xr = (e) => e === e.ownerDocument.scrollingElement ? 0 : e.getBoundingClientRect().top + e.clientTop, Yr = (e, t) => {
1003
+ const n = Number.parseFloat(getComputedStyle(t).scrollMarginTop);
1004
+ return Xr(e) + (Number.isFinite(n) ? n : 0);
1005
+ }, Jr = (e, t) => {
1006
+ if (t === null || t.rangeCount === 0) return null;
1007
+ const n = t.getRangeAt(0);
1008
+ if (!(e.contains(n.startContainer) && e.contains(n.endContainer))) return null;
1009
+ const r = n.toString().trim();
1010
+ if (r === "" || r.length > zr || /[\r\n]/u.test(r)) return null;
1011
+ const o = e.ownerDocument.createRange();
1012
+ return o.setStart(e, 0), o.setEnd(n.startContainer, n.startOffset), { text: r, occurrence: Zr(o.toString(), r), clientTop: n.getBoundingClientRect().top };
1013
+ }, wa = (e, t) => {
1014
+ const n = e.split(`
1015
+ `), r = Math.min(t.lines.first, n.length), o = Math.min(t.lines.last, n.length), i = { line: r, column: 0 };
1016
+ if (t.word === null) return i;
1017
+ let l = 0;
1018
+ for (let d = r; d <= o; d += 1) {
1019
+ const p = n[d - 1] ?? "";
1020
+ for (let f = p.indexOf(t.word); f >= 0; f = p.indexOf(t.word, f + t.word.length)) {
1021
+ if (l === t.occurrence) return { line: d, column: f };
1022
+ l += 1;
1023
+ }
1024
+ }
1025
+ return l > 0 ? Qr(n, r, o, t.word) ?? i : i;
1026
+ }, Qr = (e, t, n, r) => {
1027
+ for (let o = n; o >= t; o -= 1) {
1028
+ const i = (e[o - 1] ?? "").lastIndexOf(r);
1029
+ if (i >= 0) return { line: o, column: i };
1030
+ }
1031
+ return null;
1032
+ }, eo = (e, t) => {
1033
+ let n = null, r = null;
1034
+ for (const o of e.querySelectorAll(ot)) {
1035
+ const i = be(o);
1036
+ i === null || i.first > t || (i.last >= t ? n = o : (r === null || i.last >= r.last) && (r = { element: o, last: i.last }));
1037
+ }
1038
+ return n !== null ? n : r === null ? null : r.element;
1039
+ }, to = (e, t) => {
1040
+ const { bottom: n } = e.getBoundingClientRect(), r = Le(e), o = be(e);
1041
+ if (o === null) return r;
1042
+ const i = Math.min(Math.max(t - o.first, 0) / (o.last - o.first + 1), 1);
1043
+ return r + (n - r) * i;
1044
+ }, Le = (e) => {
1045
+ const t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT);
1046
+ for (let n = t.nextNode(); n !== null; n = t.nextNode()) {
1047
+ const o = (n.textContent ?? "").search(/\S/u);
1048
+ if (o < 0) continue;
1049
+ const i = e.ownerDocument.createRange();
1050
+ i.setStart(n, o), i.setEnd(n, o + 1);
1051
+ const { top: l, height: d } = i.getBoundingClientRect();
1052
+ if (d > 0) return l;
1053
+ }
1054
+ return e.getBoundingClientRect().top;
1055
+ }, it = Object.freeze({
1056
+ browse: Object.freeze({ replace: !0, preventScrollReset: !0, defaultShouldRevalidate: !1 }),
1057
+ "switch-source": Object.freeze({ replace: !1, preventScrollReset: !0, defaultShouldRevalidate: !1 }),
1058
+ "switch-view": Object.freeze({ replace: !1, preventScrollReset: !1, defaultShouldRevalidate: !1 }),
1059
+ "follow-link": Object.freeze({ replace: !1, preventScrollReset: !1, defaultShouldRevalidate: !1 })
1060
+ }), ga = (e) => it[e], Pe = () => {
1061
+ const e = Dn();
1062
+ return $(
1063
+ (t, n) => {
1064
+ e(t, it[n]);
1065
+ },
1066
+ [e]
1067
+ );
1068
+ }, no = ({ navigation: e, ...t }) => /* @__PURE__ */ c(Pn, { ...t, ...it[e] }), un = (e) => {
1069
+ const t = e.ownerDocument;
1070
+ if (e.focus({ preventScroll: !0 }), t.activeElement === e) return !0;
1071
+ if (e.hasAttribute("tabindex")) return !1;
1072
+ if (e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }), t.activeElement !== e)
1073
+ return e.removeAttribute("tabindex"), !1;
1074
+ const n = () => {
1075
+ t.activeElement !== e && (e.removeAttribute("tabindex"), e.removeEventListener("blur", n));
1076
+ };
1077
+ return e.addEventListener("blur", n), !0;
1078
+ }, ro = (e, t) => {
1079
+ const n = q(null), r = q(null), o = q(null), i = $(() => {
1080
+ n.current !== null && window.clearTimeout(n.current), n.current = null, r.current = null;
1081
+ }, []);
1082
+ te(() => i, [i]);
1083
+ const l = $(
1084
+ (f) => {
1085
+ if (r.current !== f) return;
1086
+ const u = o.current;
1087
+ if (u !== null) {
1088
+ u.then(() => l(f));
1089
+ return;
1090
+ }
1091
+ e.prefetch(f);
1092
+ const v = e.peek(f);
1093
+ if (v?.status !== "pending") return;
1094
+ const m = Promise.allSettled([v.promise]);
1095
+ o.current = m, m.then(() => {
1096
+ o.current === m && (o.current = null);
1097
+ });
1098
+ },
1099
+ [e]
1100
+ ), d = $(
1101
+ (f) => {
1102
+ const u = t(f);
1103
+ u !== r.current && (i(), u !== null && (r.current = u, n.current = window.setTimeout(() => {
1104
+ n.current = null, l(u);
1105
+ }, qn)));
1106
+ },
1107
+ [i, t, l]
1108
+ ), p = $(
1109
+ (f) => {
1110
+ t(f) !== r.current && i();
1111
+ },
1112
+ [i, t]
1113
+ );
1114
+ return U(
1115
+ () => ({
1116
+ onPointerOver: (f) => d(f.target),
1117
+ onPointerOut: (f) => p(f.relatedTarget),
1118
+ onFocus: (f) => d(f.target),
1119
+ onBlur: (f) => p(f.relatedTarget)
1120
+ }),
1121
+ [d, p]
1122
+ );
1123
+ }, oo = tt(() => import("./NativeScrollBar-CKfD2qpM.js").then((e) => ({ default: e.NativeScrollBar })));
1124
+ class io extends Kt {
1125
+ state = { failed: !1 };
1126
+ static getDerivedStateFromError() {
1127
+ return { failed: !0 };
1128
+ }
1129
+ componentDidCatch(t) {
1130
+ console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.", t);
1131
+ }
1132
+ render() {
1133
+ return this.state.failed ? null : this.props.children;
1134
+ }
1135
+ }
1136
+ const lo = ({ scroller: e, withCircle: t }) => /* @__PURE__ */ c(io, { children: /* @__PURE__ */ c(we, { fallback: null, children: /* @__PURE__ */ c(oo, { scroller: e, withCircle: t }) }) }), fn = (e) => /* @__PURE__ */ c(lo, { scroller: e, withCircle: !0 }), mn = () => {
1137
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
1138
+ let n = !1;
1139
+ const r = (o) => {
1140
+ t.add(o), !n && (n = !0, queueMicrotask(() => {
1141
+ n = !1, t.clear();
1142
+ }));
1143
+ };
1144
+ return {
1145
+ hold: (o) => {
1146
+ e.set(o, (e.get(o) ?? 0) + 1);
1147
+ let i = !1;
1148
+ return () => {
1149
+ if (i) return;
1150
+ i = !0;
1151
+ const l = e.get(o);
1152
+ if (l !== void 0 && l > 1) {
1153
+ e.set(o, l - 1);
1154
+ return;
1155
+ }
1156
+ e.delete(o), r(o);
1157
+ };
1158
+ },
1159
+ isHeld: (o) => e.has(o),
1160
+ resumes: (o) => t.delete(o),
1161
+ heldKeys: () => [...e.keys()]
1162
+ };
1163
+ }, Me = (e, t) => {
1164
+ if (Object.is(e, t)) return !0;
1165
+ if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
1166
+ if (Array.isArray(e) || Array.isArray(t))
1167
+ return !(Array.isArray(e) && Array.isArray(t)) || e.length !== t.length ? !1 : e.every((i, l) => Me(i, t[l]));
1168
+ const n = e, r = t, o = Object.keys(n);
1169
+ return o.length !== Object.keys(r).length ? !1 : o.every((i) => Object.hasOwn(r, i) && Me(n[i], r[i]));
1170
+ }, Ee = (e) => {
1171
+ const t = e;
1172
+ return t.status === void 0 && (t.status = "pending", e.then(
1173
+ (n) => {
1174
+ t.status = "fulfilled", t.value = n;
1175
+ },
1176
+ (n) => {
1177
+ t.status = "rejected", t.reason = n;
1178
+ }
1179
+ )), t;
1180
+ }, hn = (e) => Object.assign(Promise.resolve(e), { status: "fulfilled", value: e }), Re = (e) => e.status === "fulfilled" ? e.value : void 0, ao = 55e3, Ct = Object.freeze({ status: "deferred" }), Ot = Object.freeze({ status: "refreshed" }), Ge = Object.freeze({ status: "superseded" }), de = (e) => e === void 0 || e.status === "deferred" ? null : e.status === "loaded" ? e : e.previous, pn = (e) => e !== void 0 && e.status === "loaded" && e.document.kind !== "failure", so = ({ client: e, capacity: t }) => {
1181
+ if (!Number.isInteger(t) || t < 1) throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);
1182
+ const n = /* @__PURE__ */ new Map(), r = mn(), o = ke(), i = /* @__PURE__ */ new WeakSet();
1183
+ let l = 0;
1184
+ const d = o.emit, p = () => (l += 1, l), f = () => {
1185
+ if (!(n.size <= t))
1186
+ for (const a of [...n.keys()]) {
1187
+ if (n.size <= t) return;
1188
+ r.isHeld(a) || n.delete(a);
1189
+ }
1190
+ }, u = (a, s) => {
1191
+ n.delete(a), n.set(a, s);
1192
+ }, v = (a) => performance.now() - a.validatedAt >= ao, m = (a, s, h) => {
1193
+ const g = n.get(a), R = de(g?.snapshot), L = h || g?.refreshPending === !0, O = Ee(e.document(a, { refresh: L }).then((j) => ({ status: "loaded", document: j }))), N = { snapshot: { status: "pending", promise: O, previous: R }, validatedAt: performance.now(), opened: s, background: null, refreshPending: !1, seeded: void 0, stamp: p() };
1194
+ return u(a, N), f(), O.then((j) => {
1195
+ n.get(a) === N && (N.snapshot = j, N.stamp = p(), d());
1196
+ }), N;
1197
+ }, y = (a, s, h, g, R, L) => {
1198
+ s.background === h && (s.background = null, !(n.get(a) !== s || s.snapshot !== g) && (R.kind === "failure" && g.document.kind !== "failure" || (s.validatedAt = L, s.stamp = p(), Me(g.document, R) || (s.snapshot = { status: "loaded", document: R }), d())));
1199
+ }, A = async (a, s) => {
1200
+ const h = s.snapshot;
1201
+ if (h.status !== "loaded") return null;
1202
+ const g = {};
1203
+ s.background = g;
1204
+ const R = performance.now(), L = e.document(a, { refresh: s.refreshPending });
1205
+ s.refreshPending = !1;
1206
+ const O = await L, N = s.background === g && n.get(a) === s && s.snapshot === h;
1207
+ return y(a, s, g, h, O, R), N ? O : null;
1208
+ }, k = (a, s) => {
1209
+ const { snapshot: h } = s;
1210
+ return h.status === "pending" ? !1 : h.status === "loaded" && h.document.kind !== "failure" ? (A(a, s), !1) : (h.status === "loaded" && i.add(h), m(a, !0, !1), !0);
1211
+ }, S = (a) => {
1212
+ const s = r.hold(a);
1213
+ let h = !1;
1214
+ return () => {
1215
+ if (h) return;
1216
+ h = !0, s();
1217
+ const g = n.get(a);
1218
+ g !== void 0 && u(a, g), f();
1219
+ };
1220
+ };
1221
+ return {
1222
+ peek: (a) => n.get(a)?.snapshot,
1223
+ peekSeeded: (a) => n.get(a)?.seeded,
1224
+ answerStampOf: (a) => n.get(a)?.stamp,
1225
+ prefetch: (a) => {
1226
+ const s = n.get(a);
1227
+ s !== void 0 && s.snapshot.status !== "deferred" || (m(a, !1, !1), d());
1228
+ },
1229
+ open: (a) => {
1230
+ const s = r.resumes(a), h = S(a), g = n.get(a);
1231
+ if (g === void 0 || g.snapshot.status === "deferred")
1232
+ return m(a, !0, !1), d(), h;
1233
+ if (u(a, g), s) return h;
1234
+ const { snapshot: R } = g;
1235
+ return R.status === "pending" ? (g.opened = !0, h) : R.document.kind === "failure" ? (g.opened || v(g) ? (i.add(R), m(a, !0, !1), d()) : g.opened = !0, h) : (g.opened = !0, g.background === null && v(g) && A(a, g), h);
1236
+ },
1237
+ retain: S,
1238
+ retry: (a) => {
1239
+ const s = n.get(a);
1240
+ s === void 0 || s.snapshot.status !== "loaded" || s.snapshot.document.kind !== "failure" || (m(a, !0, !1), d());
1241
+ },
1242
+ seed: (a, s) => {
1243
+ const h = performance.now(), g = Ee(
1244
+ s.then(
1245
+ (j) => j === null ? Ct : { status: "loaded", document: j },
1246
+ () => Ct
1247
+ )
1248
+ ), R = n.get(a);
1249
+ if (R !== void 0 && R.snapshot.status === "loaded") {
1250
+ const j = R.snapshot, I = {};
1251
+ R.background = I, g.then((X) => {
1252
+ if (X.status === "loaded") {
1253
+ y(a, R, I, j, X.document, h);
1254
+ return;
1255
+ }
1256
+ R.background === I && (R.background = null);
1257
+ });
1258
+ return;
1259
+ }
1260
+ const L = R !== void 0 && R.snapshot.status === "pending" ? R.snapshot.previous : null, O = { status: "pending", promise: g, previous: L }, N = { snapshot: O, validatedAt: h, opened: R?.opened === !0, background: null, refreshPending: R?.refreshPending === !0, seeded: O, stamp: p() };
1261
+ u(a, N), f(), g.then((j) => {
1262
+ n.get(a) === N && (j.status === "deferred" && r.isHeld(a) ? m(a, N.opened, !1) : (N.snapshot = j, N.stamp = p()), d());
1263
+ });
1264
+ },
1265
+ invalidate: () => {
1266
+ let a = !1;
1267
+ for (const [s, h] of [...n]) {
1268
+ if (h.validatedAt = Number.NEGATIVE_INFINITY, h.opened = !0, h.refreshPending = !0, !r.isHeld(s)) continue;
1269
+ const { snapshot: g } = h;
1270
+ if (g.status !== "pending") {
1271
+ k(s, h) && (a = !0);
1272
+ continue;
1273
+ }
1274
+ g.promise.then(() => {
1275
+ n.get(s) === h && h.refreshPending && r.isHeld(s) && k(s, h) && d();
1276
+ });
1277
+ }
1278
+ a && d();
1279
+ },
1280
+ refresh: async (a) => {
1281
+ const s = n.get(a);
1282
+ if (s !== void 0 && pn(s.snapshot)) {
1283
+ s.refreshPending = !0;
1284
+ const g = await A(a, s);
1285
+ return g === null ? Ge : g.kind === "failure" ? { status: "failed", failure: g.failure } : Ot;
1286
+ }
1287
+ const h = m(a, !0, !0);
1288
+ return d(), h.snapshot.status !== "pending" ? Ge : (await h.snapshot.promise, n.get(a) === h ? Ot : Ge);
1289
+ },
1290
+ clear: () => {
1291
+ n.clear();
1292
+ for (const a of r.heldKeys()) m(a, !0, !1);
1293
+ d();
1294
+ },
1295
+ subscribe: o.subscribe,
1296
+ noteFailureShown: (a) => i.has(a) ? !1 : (i.add(a), !0)
1297
+ };
1298
+ };
1299
+ function co({
1300
+ title: e,
1301
+ titleId: t,
1302
+ ...n
1303
+ }, r) {
1304
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1305
+ xmlns: "http://www.w3.org/2000/svg",
1306
+ viewBox: "0 0 20 20",
1307
+ fill: "currentColor",
1308
+ "aria-hidden": "true",
1309
+ "data-slot": "icon",
1310
+ ref: r,
1311
+ "aria-labelledby": t
1312
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1313
+ id: t
1314
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1315
+ fillRule: "evenodd",
1316
+ d: "M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",
1317
+ clipRule: "evenodd"
1318
+ }), /* @__PURE__ */ b.createElement("path", {
1319
+ fillRule: "evenodd",
1320
+ d: "M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",
1321
+ clipRule: "evenodd"
1322
+ }));
1323
+ }
1324
+ const uo = /* @__PURE__ */ b.forwardRef(co);
1325
+ function fo({
1326
+ title: e,
1327
+ titleId: t,
1328
+ ...n
1329
+ }, r) {
1330
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1331
+ xmlns: "http://www.w3.org/2000/svg",
1332
+ viewBox: "0 0 20 20",
1333
+ fill: "currentColor",
1334
+ "aria-hidden": "true",
1335
+ "data-slot": "icon",
1336
+ ref: r,
1337
+ "aria-labelledby": t
1338
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1339
+ id: t
1340
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1341
+ fillRule: "evenodd",
1342
+ d: "M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",
1343
+ clipRule: "evenodd"
1344
+ }), /* @__PURE__ */ b.createElement("path", {
1345
+ d: "M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"
1346
+ }));
1347
+ }
1348
+ const mo = /* @__PURE__ */ b.forwardRef(fo);
1349
+ function ho({
1350
+ title: e,
1351
+ titleId: t,
1352
+ ...n
1353
+ }, r) {
1354
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1355
+ xmlns: "http://www.w3.org/2000/svg",
1356
+ viewBox: "0 0 20 20",
1357
+ fill: "currentColor",
1358
+ "aria-hidden": "true",
1359
+ "data-slot": "icon",
1360
+ ref: r,
1361
+ "aria-labelledby": t
1362
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1363
+ id: t
1364
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1365
+ fillRule: "evenodd",
1366
+ d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",
1367
+ clipRule: "evenodd"
1368
+ }));
1369
+ }
1370
+ const po = /* @__PURE__ */ b.forwardRef(ho), vo = 2e3, At = Object.freeze({ outcome: "idle" }), wo = (e) => {
1371
+ const t = navigator.clipboard;
1372
+ return t === void 0 ? Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")) : t.writeText(e);
1373
+ }, go = ({ text: e }) => {
1374
+ const { announcer: t, labels: n } = D(), [r, o] = B(At);
1375
+ te(() => {
1376
+ if (r.outcome === "idle") return;
1377
+ const p = setTimeout(() => o(At), vo);
1378
+ return () => clearTimeout(p);
1379
+ }, [r]);
1380
+ const i = (p) => {
1381
+ o({ outcome: p }), t.announce(p === "copied" ? n.copiedText : n.copyTextFailed);
1382
+ }, l = () => {
1383
+ wo(e).then(
1384
+ () => i("copied"),
1385
+ () => i("failed")
1386
+ );
1387
+ }, d = r.outcome === "copied" ? n.copiedText : r.outcome === "failed" ? n.copyTextFailed : n.copyText;
1388
+ return (
1389
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-icon-button", "aria-label": n.copyText, title: d, onClick: l, "data-aqmx-copy-outcome": r.outcome, "data-testid": "markdown-explorer-file-copy", children: r.outcome === "copied" ? /* @__PURE__ */ c(uo, {}) : r.outcome === "failed" ? /* @__PURE__ */ c(po, {}) : /* @__PURE__ */ c(mo, {}) })
1390
+ );
1391
+ }, fe = me("fill"), bo = Object.freeze({ blockSize: "100%" }), xe = ({ scrollerProps: e, children: t }) => ne(fe) === "content" ? /* @__PURE__ */ c(gt, { scrollerProps: e, children: t }) : /* @__PURE__ */ c(gt, { scrollerProps: { ...e, style: bo }, rowClassName: "aqmx-document-scroll-row", renderScrollBar: fn, children: t });
1392
+ function Eo({
1393
+ title: e,
1394
+ titleId: t,
1395
+ ...n
1396
+ }, r) {
1397
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1398
+ xmlns: "http://www.w3.org/2000/svg",
1399
+ viewBox: "0 0 20 20",
1400
+ fill: "currentColor",
1401
+ "aria-hidden": "true",
1402
+ "data-slot": "icon",
1403
+ ref: r,
1404
+ "aria-labelledby": t
1405
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1406
+ id: t
1407
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1408
+ d: "M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"
1409
+ }), /* @__PURE__ */ b.createElement("path", {
1410
+ d: "M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"
1411
+ }));
1412
+ }
1413
+ const yo = /* @__PURE__ */ b.forwardRef(Eo);
1414
+ function ko({
1415
+ title: e,
1416
+ titleId: t,
1417
+ ...n
1418
+ }, r) {
1419
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1420
+ xmlns: "http://www.w3.org/2000/svg",
1421
+ viewBox: "0 0 20 20",
1422
+ fill: "currentColor",
1423
+ "aria-hidden": "true",
1424
+ "data-slot": "icon",
1425
+ ref: r,
1426
+ "aria-labelledby": t
1427
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1428
+ id: t
1429
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1430
+ fillRule: "evenodd",
1431
+ d: "M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",
1432
+ clipRule: "evenodd"
1433
+ }), /* @__PURE__ */ b.createElement("path", {
1434
+ fillRule: "evenodd",
1435
+ d: "M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",
1436
+ clipRule: "evenodd"
1437
+ }));
1438
+ }
1439
+ const xo = /* @__PURE__ */ b.forwardRef(ko), $e = ({ name: e, openUrl: t, downloadUrl: n, icon: r, children: o }) => {
1440
+ const { labels: i } = D();
1441
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-toolbar", children: [
1442
+ /* @__PURE__ */ c("span", { className: "aqmx-document-file-icon", "aria-hidden": "true", children: r }),
1443
+ /* @__PURE__ */ c("span", { className: "aqmx-document-title", title: e, "data-testid": "markdown-explorer-file-name", children: e }),
1444
+ o,
1445
+ /* @__PURE__ */ c("a", { className: "aqmx-icon-button", href: t, target: "_blank", rel: "noopener noreferrer", "aria-label": i.openInNewTab, title: i.openInNewTab, "data-testid": "markdown-explorer-file-open", children: /* @__PURE__ */ c(xo, {}) }),
1446
+ /* @__PURE__ */ c("a", { className: "aqmx-icon-button", href: n, download: e, "aria-label": i.download, title: i.download, "data-testid": "markdown-explorer-file-download", children: /* @__PURE__ */ c(yo, {}) })
1447
+ ] });
1448
+ };
1449
+ function So({
1450
+ title: e,
1451
+ titleId: t,
1452
+ ...n
1453
+ }, r) {
1454
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1455
+ xmlns: "http://www.w3.org/2000/svg",
1456
+ viewBox: "0 0 20 20",
1457
+ fill: "currentColor",
1458
+ "aria-hidden": "true",
1459
+ "data-slot": "icon",
1460
+ ref: r,
1461
+ "aria-labelledby": t
1462
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1463
+ id: t
1464
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1465
+ fillRule: "evenodd",
1466
+ d: "M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",
1467
+ clipRule: "evenodd"
1468
+ }));
1469
+ }
1470
+ const Ro = /* @__PURE__ */ b.forwardRef(So), To = Object.freeze({ className: "aqmx-document-stage" }), Co = ({ document: e }) => {
1471
+ const { labels: t } = D();
1472
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-file-view", children: [
1473
+ /* @__PURE__ */ c($e, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: /* @__PURE__ */ c(Ro, {}) }),
1474
+ /* @__PURE__ */ c(xe, { scrollerProps: To, children: /* @__PURE__ */ F("div", { className: "aqmx-callout", role: "note", "data-testid": "markdown-explorer-file-not-shown", children: [
1475
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: t.fileNotShown }),
1476
+ /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e.url, download: e.name, "data-testid": "markdown-explorer-file-not-shown-download", children: t.download })
1477
+ ] }) })
1478
+ ] });
1479
+ }, Fe = "[data-aqmd-scroll-container], [data-aqmx-document-scroller]", Oo = (e) => {
1480
+ const t = e.indexOf("#");
1481
+ return t === -1 ? "" : e.slice(t);
1482
+ }, Ao = /(%[0-9A-Fa-f]{2})/u, lt = (e) => {
1483
+ if (!e.startsWith("#") || e.length === 1) return null;
1484
+ const t = new TextEncoder(), n = e.slice(1).split(Ao).flatMap((r, o) => o % 2 === 1 ? [Number.parseInt(r.slice(1), 16)] : [...t.encode(r)]);
1485
+ return new TextDecoder("utf-8", { ignoreBOM: !0 }).decode(Uint8Array.from(n));
1486
+ }, vn = (e) => `#${encodeURIComponent(e)}`, Lo = (e) => {
1487
+ if (e === "#") return !0;
1488
+ const t = lt(e);
1489
+ return t !== null && t.replace(/[A-Z]/gu, (n) => n.toLowerCase()) === "top";
1490
+ }, wn = (e, t) => {
1491
+ if (t === "") return null;
1492
+ for (const n of e.querySelectorAll("[id]"))
1493
+ if (n.id === t) return n;
1494
+ return null;
1495
+ }, Mo = "http://www.w3.org/1999/xhtml", Lt = (e, t) => {
1496
+ if (t === "") return null;
1497
+ const n = wn(e, t);
1498
+ if (n !== null) return n;
1499
+ for (const r of e.querySelectorAll("a[name]"))
1500
+ if (r.localName === "a" && r.namespaceURI === Mo && r.getAttribute("name") === t) return r;
1501
+ return null;
1502
+ }, gn = (e, t) => {
1503
+ if (e === null || !t.startsWith("#")) return null;
1504
+ const n = Lt(e, t.slice(1));
1505
+ if (n !== null) return n;
1506
+ const r = lt(t);
1507
+ return r === null ? null : Lt(e, r);
1508
+ }, Mt = (e) => {
1509
+ const { body: t, documentElement: n } = e.ownerDocument;
1510
+ if (e === t) {
1511
+ const o = getComputedStyle(n);
1512
+ if (o.overflowX === "visible" && o.overflowY === "visible") return !1;
1513
+ }
1514
+ const { overflowY: r } = getComputedStyle(e);
1515
+ return r === "auto" || r === "scroll";
1516
+ }, No = (e) => {
1517
+ const { body: t, documentElement: n } = e, r = getComputedStyle(n), o = r.overflowX === "visible" && r.overflowY === "visible" && t !== null ? getComputedStyle(t).overflowY : r.overflowY;
1518
+ return o !== "hidden" && o !== "clip";
1519
+ }, Do = (e, t) => {
1520
+ const n = t.closest(Fe), r = n !== null && e.contains(n) ? n : e;
1521
+ if (r.scrollHeight > r.clientHeight && Mt(r)) return r;
1522
+ const o = e.getBoundingClientRect().height, { documentElement: i, scrollingElement: l } = e.ownerDocument;
1523
+ for (let d = e.parentElement; d !== null && d !== i; d = d.parentElement)
1524
+ if (Mt(d) && d.scrollHeight > d.clientHeight && d.clientHeight < o) return d;
1525
+ return l instanceof Element && No(e.ownerDocument) && l.scrollHeight > l.clientHeight && l.clientHeight < o ? l : r;
1526
+ }, Po = Object.freeze({
1527
+ scrollerOf: Do,
1528
+ reveal: (e) => {
1529
+ e.scrollIntoView(Ye);
1530
+ }
1531
+ }), Ye = Object.freeze({ block: "nearest", inline: "nearest", behavior: "instant" }), $o = (e, t) => {
1532
+ for (let n = t; n !== null && n !== e; n = n.parentElement) {
1533
+ const r = n.parentElement;
1534
+ if (r instanceof HTMLDetailsElement && n !== r.querySelector(":scope > summary") && (r.open = !0), n.getAttribute("hidden")?.toLowerCase() === "until-found") {
1535
+ if (n.dispatchEvent(new Event("beforematch", { bubbles: !0 })), !n.isConnected) return;
1536
+ n.removeAttribute("hidden");
1537
+ }
1538
+ }
1539
+ }, Fo = (e, t) => {
1540
+ if (t.getClientRects().length === 0) return;
1541
+ const n = e === e.ownerDocument.scrollingElement ? 0 : e.getBoundingClientRect().top + e.clientTop, { scrollMarginTop: r, scrollMarginBottom: o } = getComputedStyle(t), i = Number.parseFloat(r), l = t.getBoundingClientRect(), d = l.height + i + Number.parseFloat(o) > e.clientHeight;
1542
+ if (!d && Math.abs(l.top - i - n) < 1) {
1543
+ t.scrollIntoView(Ye);
1544
+ return;
1545
+ }
1546
+ e.scrollBy({ top: d ? l.top - n - e.clientHeight : l.bottom - n + e.clientHeight, behavior: "instant" }), t.scrollIntoView(Ye);
1547
+ }, qo = (e, t) => {
1548
+ const n = t.scrollerOf(e, e.querySelector(Fe) ?? e);
1549
+ n.getClientRects().length !== 0 && (n.scrollTo({ top: 0, left: 0, behavior: "instant" }), t.reveal(n));
1550
+ }, Nt = (e, t, n) => {
1551
+ if (e === null) return null;
1552
+ const r = gn(e, t);
1553
+ return r === null ? (Lo(t) && qo(e, n), null) : ($o(e, r), Fo(n.scrollerOf(e, r), r), n.reveal(r), r);
1554
+ };
1555
+ function _o({
1556
+ title: e,
1557
+ titleId: t,
1558
+ ...n
1559
+ }, r) {
1560
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1561
+ xmlns: "http://www.w3.org/2000/svg",
1562
+ viewBox: "0 0 20 20",
1563
+ fill: "currentColor",
1564
+ "aria-hidden": "true",
1565
+ "data-slot": "icon",
1566
+ ref: r,
1567
+ "aria-labelledby": t
1568
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1569
+ id: t
1570
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1571
+ d: "M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"
1572
+ }));
1573
+ }
1574
+ const Bo = /* @__PURE__ */ b.forwardRef(_o);
1575
+ function Io({
1576
+ title: e,
1577
+ titleId: t,
1578
+ ...n
1579
+ }, r) {
1580
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1581
+ xmlns: "http://www.w3.org/2000/svg",
1582
+ viewBox: "0 0 20 20",
1583
+ fill: "currentColor",
1584
+ "aria-hidden": "true",
1585
+ "data-slot": "icon",
1586
+ ref: r,
1587
+ "aria-labelledby": t
1588
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1589
+ id: t
1590
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1591
+ d: "M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"
1592
+ }), /* @__PURE__ */ b.createElement("path", {
1593
+ fillRule: "evenodd",
1594
+ d: "M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",
1595
+ clipRule: "evenodd"
1596
+ }));
1597
+ }
1598
+ const jo = /* @__PURE__ */ b.forwardRef(Io);
1599
+ function Ho({
1600
+ title: e,
1601
+ titleId: t,
1602
+ ...n
1603
+ }, r) {
1604
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1605
+ xmlns: "http://www.w3.org/2000/svg",
1606
+ viewBox: "0 0 20 20",
1607
+ fill: "currentColor",
1608
+ "aria-hidden": "true",
1609
+ "data-slot": "icon",
1610
+ ref: r,
1611
+ "aria-labelledby": t
1612
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1613
+ id: t
1614
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1615
+ d: "M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"
1616
+ }), /* @__PURE__ */ b.createElement("path", {
1617
+ fillRule: "evenodd",
1618
+ d: "M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",
1619
+ clipRule: "evenodd"
1620
+ }));
1621
+ }
1622
+ const Vo = /* @__PURE__ */ b.forwardRef(Ho);
1623
+ function zo({
1624
+ title: e,
1625
+ titleId: t,
1626
+ ...n
1627
+ }, r) {
1628
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1629
+ xmlns: "http://www.w3.org/2000/svg",
1630
+ viewBox: "0 0 20 20",
1631
+ fill: "currentColor",
1632
+ "aria-hidden": "true",
1633
+ "data-slot": "icon",
1634
+ ref: r,
1635
+ "aria-labelledby": t
1636
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1637
+ id: t
1638
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1639
+ fillRule: "evenodd",
1640
+ d: "M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
1641
+ clipRule: "evenodd"
1642
+ }));
1643
+ }
1644
+ const Uo = /* @__PURE__ */ b.forwardRef(zo), Je = "data-aqmx-key-repeat", Qe = Object.freeze({ [Je]: "allow" }), Zo = `[${Je}="${Qe[Je]}"]`, Go = () => {
1645
+ let e = null;
1646
+ return {
1647
+ onKeyDownCapture: (t) => {
1648
+ if (t.key === "Enter") {
1649
+ if (!t.repeat) {
1650
+ e = t.target instanceof Element ? t.target : null;
1651
+ return;
1652
+ }
1653
+ e !== null && t.target === e && e.closest(Zo) !== null || (t.preventDefault(), t.stopPropagation());
1654
+ }
1655
+ },
1656
+ onKeyUpCapture: (t) => {
1657
+ t.key === "Enter" && (e = null);
1658
+ },
1659
+ onBlurCapture: (t) => {
1660
+ t.target === e && (e = null);
1661
+ }
1662
+ };
1663
+ }, Oe = Object.freeze([1 / Se ** 2, 1 / Se, 1, Se, Se ** 2]), Dt = Object.freeze({ mode: "fit" }), Ko = 1, Wo = Object.freeze({ className: "aqmx-document-canvas", "data-testid": "markdown-explorer-image-canvas" }), Xo = me(null), Yo = (e, t) => e.width > 0 && e.height > 0 && t.width - e.width <= Ko ? { base: e, scale: t.width / e.width } : t.width > 0 && t.height > 0 ? { base: t, scale: 1 } : null, Pt = (e, t, n) => {
1664
+ if (e.mode === "level") {
1665
+ const o = e.index + n;
1666
+ return o >= 0 && o < Oe.length ? o : null;
1667
+ }
1668
+ if (t === null || !Number.isFinite(t) || t <= 0) return null;
1669
+ const r = n === 1 ? Oe.findIndex((o) => o > t) : Oe.findLastIndex((o) => o < t);
1670
+ return r === -1 ? null : r;
1671
+ }, $t = (e, t, n) => {
1672
+ if (e.mode === "level") {
1673
+ const o = Pt(e, null, n);
1674
+ return o === null ? null : { mode: "level", index: o, base: e.base };
1675
+ }
1676
+ if (t === null) return null;
1677
+ const r = Pt(e, t.scale, n);
1678
+ return r === null ? null : { mode: "level", index: r, base: t.base };
1679
+ }, Jo = (e) => {
1680
+ const t = Oe[e];
1681
+ if (t === void 0) throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);
1682
+ return t;
1683
+ }, Ft = (e, t, n) => e !== null && e.width === t && e.height === n ? e : { width: t, height: n }, Qo = ({ document: e }) => {
1684
+ const { labels: t } = D(), n = ne(Xo), [r] = B(() => n === null ? null : n.read(e.url)), [o, i] = B(r === null ? Dt : r.zoom), [l, d] = B(r === null ? null : r.reported), [p, f] = B(null), u = q(null), v = $((T) => {
1685
+ const { naturalWidth: a, naturalHeight: s } = T;
1686
+ d((h) => Ft(h, a, s));
1687
+ }, []), m = $(
1688
+ (T) => {
1689
+ u.current = T, !(T === null || !T.complete) && (T.naturalWidth > 0 || T.naturalHeight > 0 ? v(T) : T.decode().then(
1690
+ () => v(T),
1691
+ () => {
1692
+ }
1693
+ ));
1694
+ },
1695
+ [v]
1696
+ );
1697
+ te(() => {
1698
+ n !== null && l !== null && n.save(e.url, { zoom: o, reported: l });
1699
+ }, [n, e.url, o, l]), Z(() => {
1700
+ const T = u.current;
1701
+ if (T === null || l === null || o.mode !== "fit") return;
1702
+ const a = () => f((h) => Ft(h, T.clientWidth, T.clientHeight));
1703
+ if (a(), typeof ResizeObserver > "u") return;
1704
+ const s = new ResizeObserver(a);
1705
+ return s.observe(T), () => s.disconnect();
1706
+ }, [l, o.mode]);
1707
+ const y = l === null || p === null ? null : Yo(l, p), A = $t(o, y, -1), k = $t(o, y, 1), S = o.mode === "level" ? Jo(o.index) : null, M = o.mode === "level" && S !== null ? { width: `${o.base.width * S}px`, height: `${o.base.height * S}px` } : void 0;
1708
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-image-view", children: [
1709
+ /* @__PURE__ */ F($e, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: /* @__PURE__ */ c(Uo, {}), children: [
1710
+ /* @__PURE__ */ c(
1711
+ "button",
1712
+ {
1713
+ type: "button",
1714
+ className: "aqmx-icon-button",
1715
+ "aria-label": t.imageZoomOut,
1716
+ title: t.imageZoomOut,
1717
+ "aria-disabled": A === null,
1718
+ onClick: () => {
1719
+ A !== null && i(A);
1720
+ },
1721
+ ...Qe,
1722
+ children: /* @__PURE__ */ c(jo, {})
1723
+ }
1724
+ ),
1725
+ /* @__PURE__ */ c("output", { className: "aqmx-document-level", "aria-live": "polite", "data-testid": "markdown-explorer-image-level", children: S === null ? t.imageFitLevel : t.imageZoomLevel(Math.round(S * 100)) }),
1726
+ /* @__PURE__ */ c(
1727
+ "button",
1728
+ {
1729
+ type: "button",
1730
+ className: "aqmx-icon-button",
1731
+ "aria-label": t.imageZoomIn,
1732
+ title: t.imageZoomIn,
1733
+ "aria-disabled": k === null,
1734
+ onClick: () => {
1735
+ k !== null && i(k);
1736
+ },
1737
+ ...Qe,
1738
+ children: /* @__PURE__ */ c(Vo, {})
1739
+ }
1740
+ ),
1741
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-icon-button", "aria-label": t.imageFit, title: t.imageFit, "aria-pressed": o.mode === "fit", onClick: () => i(Dt), children: /* @__PURE__ */ c(Bo, {}) })
1742
+ ] }),
1743
+ /* @__PURE__ */ c(xe, { scrollerProps: Wo, children: /* @__PURE__ */ c("img", { ref: m, className: "aqmx-document-image", src: e.url, alt: e.name, "data-aqmx-image-mode": o.mode, style: M, onLoad: (T) => v(T.currentTarget), "data-testid": "markdown-explorer-image" }) })
1744
+ ] });
1745
+ }, bn = me(null), qe = me(void 0), En = me(null), _e = () => {
1746
+ const e = ne(bn);
1747
+ if (e === null) throw new Error("[markdown-explorer] document links must be rendered inside a document pane");
1748
+ return e;
1749
+ }, ei = () => {
1750
+ const e = ne(En);
1751
+ if (e === null) throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");
1752
+ return e;
1753
+ }, Be = (e, t, n, r) => t.kind === "panel" ? pe(e, { view: "tree", source: n, doc: r }) : t.view === "single" ? pe(e, { view: "single", source: n, doc: r, overrides: t.overrides, embed: t.embed }) : pe(e, { view: "tree", source: n, doc: r, overrides: t.overrides }), ti = ({ children: e }) => {
1754
+ const { config: t } = D(), n = _e(), r = nt(), o = r.kind === "location" ? r.location.source : void 0, i = De(Be(t, n.navigation, o, n.currentPath));
1755
+ return /* @__PURE__ */ c(qe, { value: o, children: /* @__PURE__ */ c(En, { value: i, children: e }) });
1756
+ }, ni = 'a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])', ri = (e) => {
1757
+ const t = e instanceof Element ? e.closest(ni) : null;
1758
+ return t === null ? null : t.getAttribute("data-doc-path");
1759
+ }, Ie = (e) => !e.defaultPrevented && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey, oi = ({ to: e, docPath: t, fragment: n, exists: r, className: o, attributes: i, onDocumentLink: l, scope: d, children: p }) => {
1760
+ const f = De(e);
1761
+ return /* @__PURE__ */ c("a", { ...i, href: f, className: o, "data-link-kind": "doc", "data-doc-path": t, "data-doc-exists": r, onClick: (v) => {
1762
+ if (Ie(v)) {
1763
+ if (v.preventDefault(), t === d.currentPath && n !== "") {
1764
+ d.scrollWithin(n);
1765
+ return;
1766
+ }
1767
+ l(t, n);
1768
+ }
1769
+ }, children: p });
1770
+ }, ii = ({ href: e, docPath: t, docExists: n, className: r, attributes: o, children: i }) => {
1771
+ const { config: l } = D(), d = _e(), p = ne(qe), f = Oo(e), { navigation: u } = d, v = `${Be(l, u, p, t)}${f}`, m = n === !1 ? "false" : void 0;
1772
+ return u.kind === "page" ? /* @__PURE__ */ c(no, { ...o, to: v, navigation: "follow-link", className: r, "data-link-kind": "doc", "data-doc-path": t, "data-doc-exists": m, children: i }) : /* @__PURE__ */ c(oi, { to: v, docPath: t, fragment: f, exists: m, className: r, attributes: o, onDocumentLink: u.onDocumentLink, scope: d, children: i });
1773
+ }, li = ({ className: e, attributes: t, children: n }) => {
1774
+ const { labels: r } = D();
1775
+ return (
1776
+ /* @__PURE__ */ F("a", { ...t, className: e === void 0 ? "aqmx-document-inert-link" : `${e} aqmx-document-inert-link`, title: r.inertLink, "data-link-kind": "doc", "data-doc-exists": "false", children: [
1777
+ n,
1778
+ /* @__PURE__ */ F("span", { className: "aqmx-sr-only", children: [
1779
+ " (",
1780
+ r.inertLink,
1781
+ ")"
1782
+ ] })
1783
+ ] })
1784
+ );
1785
+ }, ai = ({ href: e, className: t, attributes: n, scope: r, children: o }) => {
1786
+ const { config: i } = D(), l = ne(qe), d = De(`${Be(i, r.navigation, l, r.currentPath)}${e}`);
1787
+ return /* @__PURE__ */ c("a", { ...n, href: d, className: t, onClick: (f) => {
1788
+ Ie(f) && (f.preventDefault(), r.scrollWithin(e));
1789
+ }, children: o });
1790
+ }, si = ({ href: e, className: t, attributes: n, children: r }) => {
1791
+ const o = _e();
1792
+ return o.navigation.kind === "page" ? /* @__PURE__ */ c("a", { ...n, href: e, className: t, onClick: (l) => {
1793
+ if (!Ie(l)) return;
1794
+ const d = l.currentTarget;
1795
+ e === "#" ? o.followEmptyFragment(l.nativeEvent) : d.href === d.ownerDocument.URL && o.followSameUrlJump(e, l.nativeEvent);
1796
+ }, children: r }) : /* @__PURE__ */ c(ai, { href: e, className: t, attributes: n, scope: o, children: r });
1797
+ }, ci = ({ href: e, kind: t, docPath: n, docExists: r, className: o, attributes: i, children: l }) => t === "doc" ? n === void 0 || !zn(n) ? /* @__PURE__ */ c(li, { className: o, attributes: i, children: l }) : /* @__PURE__ */ c(ii, { href: e, docPath: n, docExists: r, className: o, attributes: i, children: l }) : e.startsWith("#") ? /* @__PURE__ */ c(si, { href: e, className: o, attributes: i, children: l }) : /* @__PURE__ */ c("a", { ...i, href: e, className: o, children: l }), di = () => {
1798
+ const { config: e } = D(), t = _e(), n = ne(qe), r = Pe();
1799
+ return $(
1800
+ (o, i) => {
1801
+ if (!Ie(i)) return !0;
1802
+ i.preventDefault();
1803
+ const l = vn(o.id), { navigation: d } = t;
1804
+ return d.kind === "panel" || lt(i.currentTarget.ownerDocument.location.hash) === o.id ? (t.scrollWithin(l), !0) : (r(`${Be(e, d, n, t.currentPath)}${l}`, "follow-link"), !0);
1805
+ },
1806
+ [e, t, n, r]
1807
+ );
1808
+ }, ui = () => {
1809
+ const e = ei();
1810
+ return $((t) => `${e}${vn(t.id)}`, [e]);
1811
+ };
1812
+ function fi({
1813
+ title: e,
1814
+ titleId: t,
1815
+ ...n
1816
+ }, r) {
1817
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1818
+ xmlns: "http://www.w3.org/2000/svg",
1819
+ viewBox: "0 0 20 20",
1820
+ fill: "currentColor",
1821
+ "aria-hidden": "true",
1822
+ "data-slot": "icon",
1823
+ ref: r,
1824
+ "aria-labelledby": t
1825
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1826
+ id: t
1827
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1828
+ d: "M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"
1829
+ }));
1830
+ }
1831
+ const mi = /* @__PURE__ */ b.forwardRef(fi);
1832
+ function hi({
1833
+ title: e,
1834
+ titleId: t,
1835
+ ...n
1836
+ }, r) {
1837
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1838
+ xmlns: "http://www.w3.org/2000/svg",
1839
+ viewBox: "0 0 20 20",
1840
+ fill: "currentColor",
1841
+ "aria-hidden": "true",
1842
+ "data-slot": "icon",
1843
+ ref: r,
1844
+ "aria-labelledby": t
1845
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1846
+ id: t
1847
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1848
+ fillRule: "evenodd",
1849
+ d: "M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",
1850
+ clipRule: "evenodd"
1851
+ }));
1852
+ }
1853
+ const pi = /* @__PURE__ */ b.forwardRef(hi);
1854
+ function vi({
1855
+ title: e,
1856
+ titleId: t,
1857
+ ...n
1858
+ }, r) {
1859
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
1860
+ xmlns: "http://www.w3.org/2000/svg",
1861
+ viewBox: "0 0 20 20",
1862
+ fill: "currentColor",
1863
+ "aria-hidden": "true",
1864
+ "data-slot": "icon",
1865
+ ref: r,
1866
+ "aria-labelledby": t
1867
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
1868
+ id: t
1869
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
1870
+ fillRule: "evenodd",
1871
+ d: "M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",
1872
+ clipRule: "evenodd"
1873
+ }));
1874
+ }
1875
+ const wi = /* @__PURE__ */ b.forwardRef(vi), gi = Object.freeze({ className: "aqmx-document-stage" }), bi = (e) => {
1876
+ switch (e) {
1877
+ case "video":
1878
+ return /* @__PURE__ */ c(pi, {});
1879
+ case "audio":
1880
+ return /* @__PURE__ */ c(wi, {});
1881
+ case "pdf":
1882
+ return /* @__PURE__ */ c(mi, {});
1883
+ default: {
1884
+ const t = e;
1885
+ throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`);
1886
+ }
1887
+ }
1888
+ }, Ei = ({ document: e }) => {
1889
+ const { labels: t } = D();
1890
+ switch (e.mediaType) {
1891
+ case "video":
1892
+ return (
1893
+ /* @__PURE__ */ c("video", { className: "aqmx-document-video", src: e.url, controls: !0, preload: "metadata", "aria-label": e.name, "data-testid": "markdown-explorer-media-player", children: t.mediaUnsupported })
1894
+ );
1895
+ case "audio":
1896
+ return (
1897
+ /* @__PURE__ */ c("audio", { className: "aqmx-document-audio", src: e.url, controls: !0, preload: "metadata", "aria-label": e.name, "data-testid": "markdown-explorer-media-player", children: t.mediaUnsupported })
1898
+ );
1899
+ case "pdf":
1900
+ return /* @__PURE__ */ c("iframe", { className: "aqmx-document-frame", src: e.url, title: e.name, "data-testid": "markdown-explorer-media-player" });
1901
+ default: {
1902
+ const n = e.mediaType;
1903
+ throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`);
1904
+ }
1905
+ }
1906
+ }, yi = ({ document: e }) => /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-media-view", "data-aqmx-media-type": e.mediaType, children: [
1907
+ /* @__PURE__ */ c($e, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: bi(e.mediaType) }),
1908
+ /* @__PURE__ */ c(xe, { scrollerProps: gi, children: /* @__PURE__ */ c(Ei, { document: e }) })
1909
+ ] }), ki = (e) => ({
1910
+ loading: e.viewerLoading,
1911
+ errorPrefix: e.viewerErrorPrefix,
1912
+ styleTitle: e.viewerStyleTitle,
1913
+ selectStyleAria: e.viewerSelectStyle,
1914
+ pinStyleAria: e.viewerPinStyle,
1915
+ unpinStyleAria: e.viewerUnpinStyle,
1916
+ defaultErrorTitle: e.viewerErrorTitle,
1917
+ missingImage: e.viewerMissingImage,
1918
+ openTocAria: e.viewerOpenToc,
1919
+ tocTitle: e.viewerTocTitle,
1920
+ pinTocAria: e.viewerPinToc,
1921
+ unpinTocAria: e.viewerUnpinToc,
1922
+ selectAlignAria: e.viewerSelectAlign,
1923
+ alignTitle: e.viewerAlignTitle,
1924
+ pinAlignAria: e.viewerPinAlign,
1925
+ unpinAlignAria: e.viewerUnpinAlign,
1926
+ alignLeft: e.viewerAlignLeft,
1927
+ alignCenter: e.viewerAlignCenter,
1928
+ alignRight: e.viewerAlignRight,
1929
+ mermaidInteractionMode: e.viewerMermaidInteractionMode,
1930
+ mermaidModeNone: e.viewerMermaidModeNone,
1931
+ mermaidModeZoom: e.viewerMermaidModeZoom,
1932
+ mermaidModePan: e.viewerMermaidModePan,
1933
+ mermaidModePanShift: e.viewerMermaidModePanShift,
1934
+ mermaidModeBoth: e.viewerMermaidModeBoth,
1935
+ mermaidModeBothShift: e.viewerMermaidModeBothShift,
1936
+ mermaidZoomIn: e.viewerMermaidZoomIn,
1937
+ mermaidZoomOut: e.viewerMermaidZoomOut,
1938
+ mermaidResetView: e.viewerMermaidResetView,
1939
+ mermaidRetry: e.viewerMermaidRetry,
1940
+ embeddedVideo: e.viewerEmbeddedVideo,
1941
+ embeddedPost: e.viewerEmbeddedPost,
1942
+ embeddedFrame: e.viewerEmbeddedFrame
1943
+ }), yn = (e, t, n) => {
1944
+ if (t !== void 0) return t;
1945
+ if (n !== void 0) return n;
1946
+ const [r] = e.documentStyles;
1947
+ if (r === void 0) throw new Error("[markdown-explorer] the configuration has no document style");
1948
+ return r.name;
1949
+ }, kn = (e, t) => e !== void 0 ? e : t !== void 0 ? t : dr, at = Object.freeze(["l1", "l2", "l3", "l4", "l5", "l6", "l7", "l8"]), xi = (e, t, n) => {
1950
+ if (t.view === "multi" || t.overrides[n] === void 0) return null;
1951
+ const r = n === "style" ? { align: t.overrides.align } : { style: t.overrides.style };
1952
+ return pe(e, { ...t, overrides: r });
1953
+ }, st = ({ kind: e, view: t, label: n, stale: r, busy: o, frameRef: i, intent: l, children: d }) => {
1954
+ const p = ne(fe);
1955
+ return (
1956
+ /* @__PURE__ */ F("section", { ref: i, role: "region", "aria-label": n, "aria-busy": o, "data-testid": "markdown-explorer-document", "data-aqmx-document-kind": e, "data-aqmx-document-view": t, "data-aqmx-document-flow": p, className: "aqmx-document", ...l, children: [
1957
+ r ? /* @__PURE__ */ c("div", { className: "aqmx-progress", "aria-hidden": "true", "data-testid": "markdown-explorer-document-progress" }) : null,
1958
+ d
1959
+ ] })
1960
+ );
1961
+ }, Si = () => {
1962
+ const { labels: e } = D();
1963
+ return /* @__PURE__ */ c(st, { kind: "empty", label: e.documentRegion, stale: !1, busy: !1, children: /* @__PURE__ */ c("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-document-empty", children: /* @__PURE__ */ c("p", { className: "aqmx-empty-title", children: e.documentEmpty }) }) });
1964
+ }, xn = ({ label: e }) => {
1965
+ const { labels: t } = D();
1966
+ return /* @__PURE__ */ F(st, { kind: "loading", label: e, stale: !1, busy: !0, children: [
1967
+ /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-document-skeleton", children: at.map((n) => /* @__PURE__ */ c("span", {}, n)) }),
1968
+ /* @__PURE__ */ c("p", { className: "aqmx-sr-only", children: t.documentLoading })
1969
+ ] });
1970
+ }, qt = Object.freeze(["wheel", "touchstart", "pointerdown", "keydown"]), Ri = ({ path: e, document: t, viewer: n, editing: r }) => {
1971
+ const { reportMathDiagnostics: o, edits: i } = D(), l = U(() => ({ htmlContent: t.htmlContent, headings: [...t.headings] }), [t]), d = di(), p = ui(), f = U(() => o === void 0 ? void 0 : (h) => o(e, h), [o, e]), u = q(null), { editable: v, doubleClick: m, region: y, paneScroll: A, stale: k } = r;
1972
+ Z(() => {
1973
+ if (v)
1974
+ return i.bindView(e, {
1975
+ anchor: () => {
1976
+ const h = u.current, g = y(), R = h === null ? null : h.querySelector(Fe);
1977
+ return h === null || g === null || R === null ? null : Wr(h, A.scrollerOf(g, R));
1978
+ }
1979
+ });
1980
+ }, [i, e, v, y, A]);
1981
+ const S = (h) => {
1982
+ const g = u.current, { target: R } = h;
1983
+ !m || g === null || !(R instanceof Element) || !Gr(R) || (h.stopPropagation(), i.start(e, Kr(R, g, g.ownerDocument.getSelection())));
1984
+ }, M = q(null), T = q(k);
1985
+ Z(() => {
1986
+ T.current = k;
1987
+ });
1988
+ const a = le((h) => {
1989
+ const g = u.current, R = y(), L = g === null ? null : eo(g, h.line);
1990
+ if (R === null || L === null) return !1;
1991
+ const O = A.scrollerOf(R, L);
1992
+ return O.scrollTop += to(L, h.line) - h.clientTop, !0;
1993
+ }), s = le((h) => {
1994
+ const g = y();
1995
+ if (g === null) return;
1996
+ const R = () => {
1997
+ for (const O of qt) g.removeEventListener(O, L, !0);
1998
+ M.current?.release === R && (M.current = null);
1999
+ }, L = () => R();
2000
+ for (const O of qt) g.addEventListener(O, L, { capture: !0, passive: !0 });
2001
+ M.current = { point: h, release: R };
2002
+ });
2003
+ return Z(() => {
2004
+ const h = i.takeReturn(e);
2005
+ if (h !== null)
2006
+ return queueMicrotask(() => {
2007
+ a(h) && T.current && s(h);
2008
+ }), () => M.current?.release();
2009
+ }, [i, e]), Z(() => {
2010
+ const h = M.current;
2011
+ h === null || k || (h.release(), a(h.point));
2012
+ }, [t, k]),
2013
+ /* @__PURE__ */ c("div", { ref: u, className: "aqmx-document-viewer", onDoubleClick: S, children: /* @__PURE__ */ c(Yt, { ...n, onHeadingSelect: d, headingHref: p, onMathDiagnostics: f, parseResult: l, content: null }) });
2014
+ }, Sn = ({ document: e, viewer: t }) => {
2015
+ const { labels: n } = D();
2016
+ return /* @__PURE__ */ F(Ne, { children: [
2017
+ /* @__PURE__ */ c($e, { name: e.name, openUrl: Un(e.url), downloadUrl: e.url, icon: /* @__PURE__ */ c(_r, {}), children: e.truncated ? null : /* @__PURE__ */ c(go, { text: e.text }) }),
2018
+ e.truncated ? /* @__PURE__ */ c("p", { className: "aqmx-callout aqmx-document-notice", role: "note", "data-testid": "markdown-explorer-text-truncated", children: n.textTruncated }) : null,
2019
+ /* @__PURE__ */ c("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ c(Yt, { ...t, parseResult: null, content: e.text }) })
2020
+ ] });
2021
+ }, Ti = ({ path: e, name: t, viewer: n }) => {
2022
+ const { data: r, documents: o, announcer: i, labels: l } = D(), d = $(() => o.answerStampOf(e), [o, e]), p = ee(o.subscribe, d, d), [f, u] = B(0), v = U(() => ({ path: e, stamp: p, attempt: f }), [e, p, f]), [m, y] = B(null), A = le((S) => {
2023
+ y(S), S.kind === "failure" && i.announce(l.documentFailed(t, se(l, S.failure.reason)));
2024
+ });
2025
+ te(() => {
2026
+ const S = new AbortController();
2027
+ return r.text(v.path, S.signal).then((M) => {
2028
+ "kind" in M && A(M);
2029
+ }), () => S.abort();
2030
+ }, [r, v]);
2031
+ const k = $(() => u((S) => S + 1), []);
2032
+ return m === null ? /* @__PURE__ */ F(Ne, { children: [
2033
+ /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-markup-skeleton", children: at.map((S) => /* @__PURE__ */ c("span", {}, S)) }),
2034
+ /* @__PURE__ */ c("p", { className: "aqmx-sr-only", children: l.markupLoading })
2035
+ ] }) : m.kind === "failure" ? /* @__PURE__ */ c(xe, { scrollerProps: Rn, children: /* @__PURE__ */ c(ge, { failure: m.failure, alert: !1, onRetry: k, testId: "markdown-explorer-markup-failure" }) }) : /* @__PURE__ */ c(Sn, { document: m, viewer: n });
2036
+ }, Rn = Object.freeze({ className: "aqmx-document-failure", "data-aqmx-document-scroller": "" }), Ci = Object.freeze({ reason: "failed" }), Oi = (e) => /* @__PURE__ */ c(
2037
+ jr,
2038
+ {
2039
+ fallback: (t) => /* @__PURE__ */ c("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ c(ge, { failure: Ci, alert: !1, onRetry: t, testId: "markdown-explorer-edit-load-failure" }) }),
2040
+ children: /* @__PURE__ */ c(
2041
+ we,
2042
+ {
2043
+ fallback: /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-skeleton", children: at.map((t) => /* @__PURE__ */ c("span", {}, t)) }),
2044
+ children: /* @__PURE__ */ c(Ir, { ...e })
2045
+ }
2046
+ )
2047
+ }
2048
+ ), Ai = ({ path: e, document: t, view: n, viewer: r, onRetry: o, editing: i }) => {
2049
+ switch (t.kind) {
2050
+ case "markdown": {
2051
+ const { session: l, layout: d, region: p, paneScroll: f, stale: u } = i;
2052
+ if (n === "edit" && l !== void 0) return /* @__PURE__ */ c(Oi, { path: e, name: t.name, session: l, layout: d, viewer: r, region: p, paneScroll: f });
2053
+ if (n === "markup") return /* @__PURE__ */ c(Ti, { path: e, name: t.name, viewer: r });
2054
+ const v = t.edit !== null && (t.edit.kind === "inline" || t.edit.kind === "draft");
2055
+ return /* @__PURE__ */ c(Ri, { path: e, document: t, viewer: r, editing: { editable: v, doubleClick: v && d === "fill", region: p, paneScroll: f, stale: u } });
2056
+ }
2057
+ case "text":
2058
+ return /* @__PURE__ */ c(Sn, { document: t, viewer: r });
2059
+ case "image":
2060
+ return /* @__PURE__ */ c(Qo, { document: t });
2061
+ case "media":
2062
+ return /* @__PURE__ */ c(yi, { document: t });
2063
+ case "file":
2064
+ return /* @__PURE__ */ c(Co, { document: t });
2065
+ case "failure":
2066
+ return /* @__PURE__ */ c(xe, { scrollerProps: Rn, children: /* @__PURE__ */ c(ge, { failure: t.failure, alert: !1, onRetry: o, testId: "markdown-explorer-document-failure" }) });
2067
+ default: {
2068
+ const l = t;
2069
+ throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(l)}`);
2070
+ }
2071
+ }
2072
+ }, Li = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])', Mi = (e, t, n) => {
2073
+ const [r] = t.kind === "markdown" ? t.headings : [], o = [n === null ? null : gn(e, n), r === void 0 ? null : wn(e, r.id), e.querySelector(Fe), e.querySelector(Li)];
2074
+ for (const i of o)
2075
+ if (i instanceof HTMLElement && un(i)) return i;
2076
+ return null;
2077
+ }, _t = (e, t, n) => {
2078
+ const { activeElement: r, body: o } = e.ownerDocument, i = r === null || r === o;
2079
+ t instanceof HTMLElement && n && (i || e.contains(r)) && un(t);
2080
+ }, Ni = (e) => {
2081
+ const t = q(!1);
2082
+ return Z(() => {
2083
+ const n = e.current;
2084
+ if (n === null) throw new Error("[markdown-explorer] the document region is not mounted");
2085
+ const r = n.ownerDocument, o = r.defaultView;
2086
+ if (o === null) throw new Error("[markdown-explorer] the document region's document has no window");
2087
+ let i = !1, l;
2088
+ const d = (m) => {
2089
+ i = !(m.target instanceof Node && n.contains(m.target)), i && !n.contains(r.activeElement) && (t.current = !1), clearTimeout(l), l = setTimeout(() => {
2090
+ i = !1;
2091
+ }, 0);
2092
+ }, p = (m) => {
2093
+ t.current = m.target instanceof Node && n.contains(m.target);
2094
+ }, f = (m) => {
2095
+ m.relatedTarget === null && i && (t.current = !1);
2096
+ }, u = () => {
2097
+ const { activeElement: m, body: y } = r;
2098
+ m !== null && m !== y && (t.current = n.contains(m));
2099
+ }, v = () => {
2100
+ i && !n.contains(r.activeElement) && (t.current = !1);
2101
+ };
2102
+ return o.addEventListener("pointerdown", d, !0), o.addEventListener("mousedown", d, !0), o.addEventListener("focusin", p, !0), o.addEventListener("blur", u), o.addEventListener("focus", v), n.addEventListener("focusout", f), () => {
2103
+ clearTimeout(l), o.removeEventListener("pointerdown", d, !0), o.removeEventListener("mousedown", d, !0), o.removeEventListener("focusin", p, !0), o.removeEventListener("blur", u), o.removeEventListener("focus", v), n.removeEventListener("focusout", f);
2104
+ };
2105
+ }, [e]), t;
2106
+ }, Di = ({ path: e, snapshot: t, markup: n, stale: r, viewer: o, editLayout: i, regionLabel: l, navigation: d, fragment: p, paneScroll: f, announces: u, announceFailure: v, onDocumentShown: m }) => {
2107
+ const { labels: y, announcer: A, documents: k } = D(), { document: S } = t, M = q(null), T = q(null), a = q(null), s = q(0), h = Ni(M), g = q({ path: e, document: S }), R = q(null), L = $(
2108
+ (z) => {
2109
+ const K = M.current, Y = Nt(K, z, f);
2110
+ K !== null && Y !== null && _t(K, Y, h.current);
2111
+ },
2112
+ [f, h]
2113
+ ), O = $(
2114
+ (z, K) => {
2115
+ const Y = s.current;
2116
+ setTimeout(() => {
2117
+ !K.defaultPrevented && s.current === Y && L(z);
2118
+ }, 0);
2119
+ },
2120
+ [L]
2121
+ ), N = $(
2122
+ (z) => {
2123
+ setTimeout(() => {
2124
+ z.defaultPrevented || L("#");
2125
+ }, 0);
2126
+ },
2127
+ [L]
2128
+ ), j = U(() => ({ navigation: d, currentPath: e, scrollWithin: L, followSameUrlJump: O, followEmptyFragment: N }), [d, e, L, O, N]), I = $(() => k.retry(e), [k, e]), X = ro(k, ri), Q = sn(e), J = Q !== void 0 ? "edit" : n ? "markup" : "rendered", H = S.kind === "markdown" ? J : void 0, oe = $(() => M.current, []), w = U(() => ({ session: Q, layout: i, region: oe, paneScroll: f, stale: r }), [Q, i, oe, f, r]), E = H === "edit" ? !1 : r, x = ne(fe), C = H === "edit" && i === "fill" ? "fill" : x, P = le((z, K) => {
2129
+ const Y = T.current;
2130
+ if (Y !== null && Y.path === z && Y.snapshot === K) return;
2131
+ T.current = { path: z, snapshot: K };
2132
+ const re = K.document;
2133
+ if (re.kind === "failure") {
2134
+ k.noteFailureShown(K) && v(y.documentFailed(ye(z), se(y, re.failure.reason)));
2135
+ return;
2136
+ }
2137
+ m?.(z, re), u && (Y === null || Y.path !== z || Y.snapshot.document.kind === "failure") && A.announce(y.documentShown(re.name));
2138
+ });
2139
+ te(() => {
2140
+ P(e, t);
2141
+ }, [e, t]);
2142
+ const _ = le(() => {
2143
+ p.kind === "panel" && p.consume();
2144
+ }), G = le((z) => {
2145
+ const K = M.current;
2146
+ if (K === null || !h.current) return null;
2147
+ const { activeElement: Y, body: re } = K.ownerDocument;
2148
+ return Y !== null && Y !== re ? null : Mi(K, S, z);
2149
+ }), V = le((z) => {
2150
+ const K = M.current;
2151
+ K !== null && _t(K, z, h.current);
2152
+ }), ie = le((z) => f.reveal(z)), dt = le((z) => Nt(M.current, z, f));
2153
+ return te(() => {
2154
+ if (r) return;
2155
+ const z = g.current.path !== e, K = z || g.current.document !== S;
2156
+ g.current = { path: e, document: S };
2157
+ const Y = R.current !== e;
2158
+ R.current = e;
2159
+ let re = null;
2160
+ p.kind === "page" ? a.current !== p.navigation && (a.current = p.navigation, s.current += 1, re = p.fragment) : p.fragment !== null && (re = p.fragment, _());
2161
+ const ut = () => {
2162
+ const je = re === null ? null : dt(re);
2163
+ if (!K) {
2164
+ je !== null && V(je);
2165
+ return;
2166
+ }
2167
+ const ft = G(p.fragment);
2168
+ z && je === null && ft !== null && ie(ft);
2169
+ };
2170
+ Y ? queueMicrotask(ut) : ut();
2171
+ }, [p, e, S, r]), /* @__PURE__ */ c(fe, { value: C, children: /* @__PURE__ */ c(st, { kind: S.kind, view: H, label: l(e, S), stale: E, busy: E, frameRef: M, intent: X, children: /* @__PURE__ */ c(bn, { value: j, children: /* @__PURE__ */ c(ti, { children: /* @__PURE__ */ c(Ai, { path: e, document: S, view: J, viewer: o, onRetry: I, editing: w }, e) }) }) }) });
2172
+ }, ct = Object.freeze({ kind: "skeleton" }), Pi = (e, t, n, r, o) => {
2173
+ if (t?.status === "loaded") return { kind: "document", path: e, snapshot: t, stale: !1 };
2174
+ const i = de(t);
2175
+ if (i !== null) return { kind: "document", path: e, snapshot: i, stale: !0 };
2176
+ if (o && t?.status === "pending") return { kind: "streaming", path: e, promise: t.promise };
2177
+ const l = n === null || n === e ? null : de(r);
2178
+ return n === null || l === null ? ct : { kind: "document", path: n, snapshot: l, stale: !0 };
2179
+ }, $i = (e, t) => t.status === "deferred" ? ct : { kind: "document", path: e, snapshot: t, stale: !1 }, Fi = ({ requestedPath: e, content: t, markup: n, ...r }) => {
2180
+ const o = t.kind === "streaming" ? $i(t.path, ne(t.promise)) : t;
2181
+ return o.kind !== "document" ? /* @__PURE__ */ c(xn, { label: r.regionLabel(e, null) }) : /* @__PURE__ */ c(Di, { path: o.path, snapshot: o.snapshot, markup: n, stale: o.stale, ...r });
2182
+ }, Tn = ({ path: e, markup: t, display: n, navigation: r, fragment: o, paneScroll: i, announces: l, announceFailure: d, onDocumentShown: p }) => {
2183
+ const { config: f, labels: u, theme: v, documents: m } = D(), y = sr(), A = q(!1);
2184
+ Z(() => {
2185
+ A.current = !0;
2186
+ }, []);
2187
+ const [k, S] = B(null), [M, T] = B(t), a = $(() => e === null ? void 0 : m.peek(e), [m, e]), s = ee(m.subscribe, a, a), h = $(() => k === null ? void 0 : m.peek(k), [m, k]), g = ee(m.subscribe, h, h);
2188
+ Z(() => e === null ? void 0 : m.open(e), [m, e]), Z(() => k === null ? void 0 : m.retain(k), [m, k]);
2189
+ const R = e === null ? ct : Pi(e, s, k, g, !A.current), L = e === null ? null : R.kind === "document" && !R.stale ? R.path : k;
2190
+ L !== k && S(L);
2191
+ const O = R.kind !== "document" || R.path === e;
2192
+ O && t !== M && T(t);
2193
+ const N = U(() => ki(u), [u]), j = U(() => [...f.iframeHosts], [f]), I = r.kind === "panel", X = U(
2194
+ () => ({
2195
+ labels: N,
2196
+ emptyMessage: u.documentEmpty,
2197
+ theme: v,
2198
+ availableStyles: f.documentStyles,
2199
+ iFrameAllowedDomains: j,
2200
+ embeds: f.embeds,
2201
+ linkComponent: ci,
2202
+ toolbar: y,
2203
+ style: n.style,
2204
+ onStyleChange: n.onStyleChange,
2205
+ align: n.align,
2206
+ onAlignChange: n.onAlignChange,
2207
+ showToc: n.showToc,
2208
+ showStyle: n.showStyle,
2209
+ showAlign: n.showAlign,
2210
+ padding: n.padding,
2211
+ width: n.width === void 0 ? void 0 : `min(${n.width}, 100%)`,
2212
+ maxWidth: n.maxWidth === void 0 ? void 0 : `min(${n.maxWidth}, 100%)`,
2213
+ renderScrollBar: I ? void 0 : fn
2214
+ }),
2215
+ [N, u.documentEmpty, v, f.documentStyles, j, f.embeds, y, n, I]
2216
+ ), Q = $((H, oe) => I ? oe === null || oe.kind === "failure" ? ye(H) : oe.name : u.documentRegion, [I, u.documentRegion]), J = I ? "content" : "fill";
2217
+ return e === null ? /* @__PURE__ */ c(fe, { value: J, children: /* @__PURE__ */ c(Si, {}) }) : /* @__PURE__ */ c(fe, { value: J, children: /* @__PURE__ */ c(we, { fallback: /* @__PURE__ */ c(xn, { label: Q(e, null) }), children: /* @__PURE__ */ c(
2218
+ Fi,
2219
+ {
2220
+ requestedPath: e,
2221
+ content: R,
2222
+ markup: O ? t : M,
2223
+ viewer: X,
2224
+ editLayout: n.editLayout,
2225
+ regionLabel: Q,
2226
+ navigation: r,
2227
+ fragment: o,
2228
+ paneScroll: i,
2229
+ announces: l,
2230
+ announceFailure: d,
2231
+ onDocumentShown: p
2232
+ }
2233
+ ) }) });
2234
+ }, qi = ({ path: e, markup: t, variant: n, onDocumentShown: r }) => {
2235
+ const { config: o, viewSettings: i, announcer: l } = D(), d = Ae((L) => L.style), p = Ae((L) => L.align), f = Pe(), u = Wt(), v = nt(), { view: m, overrides: y, embed: A } = n, k = $(
2236
+ (L) => {
2237
+ if (v.kind !== "location") return;
2238
+ const O = xi(o, v.location, L);
2239
+ O !== null && f(O, "browse");
2240
+ },
2241
+ [o, f, v]
2242
+ ), S = $(
2243
+ (L) => {
2244
+ i.update({ style: L }), k("style");
2245
+ },
2246
+ [i, k]
2247
+ ), M = $(
2248
+ (L) => {
2249
+ i.update({ align: L }), k("align");
2250
+ },
2251
+ [i, k]
2252
+ ), T = yn(o, y.style, d), a = kn(y.align, p), s = U(
2253
+ () => ({
2254
+ style: T,
2255
+ onStyleChange: S,
2256
+ align: a,
2257
+ onAlignChange: M,
2258
+ showToc: A.showToc !== !1,
2259
+ showStyle: A.showStyle !== !1,
2260
+ showAlign: A.showAlign !== !1,
2261
+ padding: A.padding,
2262
+ width: A.width,
2263
+ maxWidth: A.maxWidth,
2264
+ editLayout: "fill"
2265
+ }),
2266
+ [T, S, a, M, A]
2267
+ ), h = U(() => ({ kind: "page", view: m, overrides: y, embed: A }), [m, y, A]), g = U(() => ({ kind: "page", fragment: u.hash, navigation: u }), [u]), R = $((L) => l.announce(L), [l]);
2268
+ return /* @__PURE__ */ c(Tn, { path: e, markup: t, display: s, navigation: h, fragment: g, paneScroll: Po, announces: !0, announceFailure: R, onDocumentShown: r });
2269
+ }, _i = ({ path: e, markup: t, variant: n, onDocumentShown: r }) => {
2270
+ const { config: o, viewSettings: i } = D(), l = Ae((h) => h.style), d = Ae((h) => h.align), [p, f] = B(() => yn(o, void 0, l)), u = kn(void 0, d), v = $((h) => i.update({ align: h }), [i]), { maximized: m, onDocumentLink: y, pendingHash: A, onHashConsumed: k, announceFailure: S, paneScroll: M } = n, T = U(
2271
+ () => ({
2272
+ style: p,
2273
+ onStyleChange: f,
2274
+ align: u,
2275
+ onAlignChange: v,
2276
+ showToc: m,
2277
+ showStyle: m,
2278
+ showAlign: m,
2279
+ padding: void 0,
2280
+ width: void 0,
2281
+ maxWidth: void 0,
2282
+ editLayout: m ? "fill" : "content"
2283
+ }),
2284
+ [p, u, v, m]
2285
+ ), a = U(() => ({ kind: "panel", onDocumentLink: y }), [y]), s = U(() => ({ kind: "panel", fragment: A, consume: k }), [A, k]);
2286
+ return /* @__PURE__ */ c(Tn, { path: e, markup: t, display: T, navigation: a, fragment: s, paneScroll: M, announces: !1, announceFailure: S, onDocumentShown: r });
2287
+ }, Bi = ({ path: e, markup: t, variant: n, onDocumentShown: r }) => n.kind === "page" ? /* @__PURE__ */ c(qi, { path: e, markup: t, variant: n, onDocumentShown: r }) : /* @__PURE__ */ c(_i, { path: e, markup: t, variant: n, onDocumentShown: r });
2288
+ function Ii({
2289
+ title: e,
2290
+ titleId: t,
2291
+ ...n
2292
+ }, r) {
2293
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2294
+ xmlns: "http://www.w3.org/2000/svg",
2295
+ viewBox: "0 0 24 24",
2296
+ fill: "currentColor",
2297
+ "aria-hidden": "true",
2298
+ "data-slot": "icon",
2299
+ ref: r,
2300
+ "aria-labelledby": t
2301
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2302
+ id: t
2303
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2304
+ fillRule: "evenodd",
2305
+ d: "M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",
2306
+ clipRule: "evenodd"
2307
+ }));
2308
+ }
2309
+ const ji = /* @__PURE__ */ b.forwardRef(Ii);
2310
+ function Hi({
2311
+ title: e,
2312
+ titleId: t,
2313
+ ...n
2314
+ }, r) {
2315
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2316
+ xmlns: "http://www.w3.org/2000/svg",
2317
+ viewBox: "0 0 24 24",
2318
+ fill: "currentColor",
2319
+ "aria-hidden": "true",
2320
+ "data-slot": "icon",
2321
+ ref: r,
2322
+ "aria-labelledby": t
2323
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2324
+ id: t
2325
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2326
+ fillRule: "evenodd",
2327
+ d: "M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",
2328
+ clipRule: "evenodd"
2329
+ }));
2330
+ }
2331
+ const Cn = /* @__PURE__ */ b.forwardRef(Hi);
2332
+ function Vi({
2333
+ title: e,
2334
+ titleId: t,
2335
+ ...n
2336
+ }, r) {
2337
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2338
+ xmlns: "http://www.w3.org/2000/svg",
2339
+ viewBox: "0 0 24 24",
2340
+ fill: "currentColor",
2341
+ "aria-hidden": "true",
2342
+ "data-slot": "icon",
2343
+ ref: r,
2344
+ "aria-labelledby": t
2345
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2346
+ id: t
2347
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2348
+ fillRule: "evenodd",
2349
+ d: "M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",
2350
+ clipRule: "evenodd"
2351
+ }));
2352
+ }
2353
+ const zi = /* @__PURE__ */ b.forwardRef(Vi);
2354
+ function Ui({
2355
+ title: e,
2356
+ titleId: t,
2357
+ ...n
2358
+ }, r) {
2359
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2360
+ xmlns: "http://www.w3.org/2000/svg",
2361
+ viewBox: "0 0 24 24",
2362
+ fill: "currentColor",
2363
+ "aria-hidden": "true",
2364
+ "data-slot": "icon",
2365
+ ref: r,
2366
+ "aria-labelledby": t
2367
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2368
+ id: t
2369
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2370
+ fillRule: "evenodd",
2371
+ d: "M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",
2372
+ clipRule: "evenodd"
2373
+ }), /* @__PURE__ */ b.createElement("path", {
2374
+ fillRule: "evenodd",
2375
+ d: "M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",
2376
+ clipRule: "evenodd"
2377
+ }));
2378
+ }
2379
+ const Zi = /* @__PURE__ */ b.forwardRef(Ui);
2380
+ function Gi({
2381
+ title: e,
2382
+ titleId: t,
2383
+ ...n
2384
+ }, r) {
2385
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2386
+ xmlns: "http://www.w3.org/2000/svg",
2387
+ viewBox: "0 0 24 24",
2388
+ fill: "currentColor",
2389
+ "aria-hidden": "true",
2390
+ "data-slot": "icon",
2391
+ ref: r,
2392
+ "aria-labelledby": t
2393
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2394
+ id: t
2395
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2396
+ fillRule: "evenodd",
2397
+ d: "M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",
2398
+ clipRule: "evenodd"
2399
+ }));
2400
+ }
2401
+ const Ki = /* @__PURE__ */ b.forwardRef(Gi);
2402
+ function Wi({
2403
+ title: e,
2404
+ titleId: t,
2405
+ ...n
2406
+ }, r) {
2407
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2408
+ xmlns: "http://www.w3.org/2000/svg",
2409
+ viewBox: "0 0 24 24",
2410
+ fill: "currentColor",
2411
+ "aria-hidden": "true",
2412
+ "data-slot": "icon",
2413
+ ref: r,
2414
+ "aria-labelledby": t
2415
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2416
+ id: t
2417
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2418
+ fillRule: "evenodd",
2419
+ d: "M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",
2420
+ clipRule: "evenodd"
2421
+ }), /* @__PURE__ */ b.createElement("path", {
2422
+ d: "M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"
2423
+ }));
2424
+ }
2425
+ const Xi = /* @__PURE__ */ b.forwardRef(Wi);
2426
+ function Yi({
2427
+ title: e,
2428
+ titleId: t,
2429
+ ...n
2430
+ }, r) {
2431
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2432
+ xmlns: "http://www.w3.org/2000/svg",
2433
+ viewBox: "0 0 24 24",
2434
+ fill: "currentColor",
2435
+ "aria-hidden": "true",
2436
+ "data-slot": "icon",
2437
+ ref: r,
2438
+ "aria-labelledby": t
2439
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2440
+ id: t
2441
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2442
+ d: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
2443
+ }), /* @__PURE__ */ b.createElement("path", {
2444
+ fillRule: "evenodd",
2445
+ d: "M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",
2446
+ clipRule: "evenodd"
2447
+ }));
2448
+ }
2449
+ const Ji = /* @__PURE__ */ b.forwardRef(Yi);
2450
+ function Qi({
2451
+ title: e,
2452
+ titleId: t,
2453
+ ...n
2454
+ }, r) {
2455
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2456
+ xmlns: "http://www.w3.org/2000/svg",
2457
+ viewBox: "0 0 24 24",
2458
+ fill: "currentColor",
2459
+ "aria-hidden": "true",
2460
+ "data-slot": "icon",
2461
+ ref: r,
2462
+ "aria-labelledby": t
2463
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2464
+ id: t
2465
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2466
+ d: "M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"
2467
+ }), /* @__PURE__ */ b.createElement("path", {
2468
+ d: "M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"
2469
+ }));
2470
+ }
2471
+ const el = /* @__PURE__ */ b.forwardRef(Qi);
2472
+ function tl({
2473
+ title: e,
2474
+ titleId: t,
2475
+ ...n
2476
+ }, r) {
2477
+ return /* @__PURE__ */ b.createElement("svg", Object.assign({
2478
+ xmlns: "http://www.w3.org/2000/svg",
2479
+ viewBox: "0 0 24 24",
2480
+ fill: "currentColor",
2481
+ "aria-hidden": "true",
2482
+ "data-slot": "icon",
2483
+ ref: r,
2484
+ "aria-labelledby": t
2485
+ }, n), e ? /* @__PURE__ */ b.createElement("title", {
2486
+ id: t
2487
+ }, e) : null, /* @__PURE__ */ b.createElement("path", {
2488
+ d: "M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"
2489
+ }));
2490
+ }
2491
+ const nl = /* @__PURE__ */ b.forwardRef(tl), rl = ({ href: e, onRetry: t, testId: n }) => {
2492
+ const { labels: r, onEditGrant: o } = D(), [i, l] = B(!1), d = () => {
2493
+ o === void 0 || i || (l(!0), o(e).then((p) => {
2494
+ p && t();
2495
+ }).finally(() => l(!1)));
2496
+ };
2497
+ return /* @__PURE__ */ F("div", { className: "aqmx-callout aqmx-edit-grant", "data-testid": n, children: [
2498
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-title", children: r.editGrantTitle }),
2499
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: r.editGrantBody }),
2500
+ /* @__PURE__ */ F("div", { className: "aqmx-edit-grant-actions", children: [
2501
+ o === void 0 ? /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e, target: "_blank", rel: "noopener", "data-testid": `${n}-open`, children: r.editGrantAction }) : (
2502
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "aria-disabled": i, "data-testid": `${n}-open`, onClick: d, children: r.editGrantAction })
2503
+ ),
2504
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-testid": `${n}-retry`, onClick: t, children: r.editGrantRetry })
2505
+ ] })
2506
+ ] });
2507
+ }, ol = "Control+E Meta+E", il = (e, t, n) => n && t ? "split" : e.view, Bt = (e, t, n, r) => {
2508
+ if (n === "split") {
2509
+ e.setSideBySide(!0);
2510
+ return;
2511
+ }
2512
+ e.setView(t, n), r && e.sideBySide() && e.setSideBySide(!1);
2513
+ }, ba = (e) => e === "split" ? null : e, ll = (e) => e === "preview" ? "editor" : "preview", al = (e) => /Mac|iPhone|iPad|iPod/u.test(e), sl = (e, t) => {
2514
+ if (e.isComposing || e.altKey || e.shiftKey || (t ? !e.metaKey || e.ctrlKey : !e.ctrlKey || e.metaKey)) return !1;
2515
+ const n = e.key.toLowerCase();
2516
+ return n === "e" || e.code === "KeyE" && /^\p{L}$/u.test(n) && !/^[a-z]$/u.test(n);
2517
+ }, It = (e, t, n) => {
2518
+ const r = e.modifiedAt === null ? Number.NaN : Date.parse(e.modifiedAt);
2519
+ return n(Number.isNaN(r) ? e.id : t.format(r), e.author === null ? "" : e.author);
2520
+ }, cl = ({ path: e, documentName: t, open: n, onClose: r }) => {
2521
+ const { data: o, edits: i, labels: l, locale: d, announcer: p } = D(), f = q(null), u = q(null), v = ve(), [m, y] = B(null), [A, k] = B(0), [S, M] = B(null), [T, a] = B(null), s = U(() => new Intl.DateTimeFormat(d, { dateStyle: "medium", timeStyle: "short" }), [d]);
2522
+ Z(() => {
2523
+ const O = f.current;
2524
+ if (O !== null)
2525
+ if (n && !O.open) {
2526
+ const N = O.ownerDocument.activeElement;
2527
+ u.current = N instanceof HTMLElement ? N : null, M(null), a(null), O.showModal();
2528
+ } else !n && O.open && (O.close(), u.current?.isConnected === !0 && u.current.focus(), u.current = null);
2529
+ }, [n]), te(() => {
2530
+ if (!n) return;
2531
+ const O = new AbortController();
2532
+ return y(null), o.revisions(e, O.signal).then((N) => {
2533
+ "kind" in N && y(N);
2534
+ }), () => O.abort();
2535
+ }, [n, o, e, A]), te(() => {
2536
+ if (!n || S === null) return;
2537
+ const O = new AbortController();
2538
+ return a(null), o.revision(e, S, O.signal).then((N) => {
2539
+ "kind" in N && a(N);
2540
+ }), () => O.abort();
2541
+ }, [n, o, e, S]);
2542
+ const h = () => {
2543
+ T === null || T.kind !== "revision" || (i.replaceDraft(e, T.text), p.announce(l.historyRestored(t)), r());
2544
+ }, g = (O) => {
2545
+ O.key !== "Escape" || O.defaultPrevented || (rt(O), r());
2546
+ }, R = (O) => {
2547
+ O.target === O.currentTarget && r();
2548
+ }, L = m !== null && m.kind === "revisions" ? m.revisions.find((O) => O.id === S) : void 0;
2549
+ return /* @__PURE__ */ c("dialog", { ref: f, className: "aqmx-confirm aqmx-history", "aria-labelledby": v, "data-testid": "markdown-explorer-history", onKeyDown: g, onClick: R, onCancel: (O) => O.preventDefault(), children: /* @__PURE__ */ F("div", { className: "aqmx-confirm-panel aqmx-history-panel", children: [
2550
+ /* @__PURE__ */ c("p", { id: v, className: "aqmx-confirm-title", children: l.historyTitle(t) }),
2551
+ m === null ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", "data-testid": "markdown-explorer-history-loading", children: l.historyLoading }) : m.kind === "failure" ? /* @__PURE__ */ c(ge, { failure: m.failure, alert: !1, onRetry: () => k((O) => O + 1), testId: "markdown-explorer-history-failure" }) : m.revisions.length === 0 ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", "data-testid": "markdown-explorer-history-empty", children: l.historyEmpty }) : /* @__PURE__ */ c("ul", { className: "aqmx-history-list", "data-testid": "markdown-explorer-history-list", children: m.revisions.map((O) => /* @__PURE__ */ c("li", { children: /* @__PURE__ */ F("button", { type: "button", className: "aqmx-history-entry", "aria-pressed": O.id === S, "data-testid": "markdown-explorer-history-entry", onClick: () => M(O.id), children: [
2552
+ /* @__PURE__ */ c("span", { children: It(O, s, l.historyEntry) }),
2553
+ O.current ? /* @__PURE__ */ c("span", { className: "aqmx-history-mark", children: l.historyCurrent }) : null,
2554
+ O.kept ? /* @__PURE__ */ c("span", { className: "aqmx-history-mark", children: l.historyKept }) : null
2555
+ ] }) }, O.id)) }),
2556
+ S === null ? null : T === null ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", children: l.historyLoading }) : T.kind === "failure" ? /* @__PURE__ */ c(ge, { failure: T.failure, alert: !1, testId: "markdown-explorer-history-revision-failure" }) : (
2557
+ /* @__PURE__ */ c("section", { className: "aqmx-history-text", tabIndex: 0, "aria-label": L === void 0 ? l.historyTitle(t) : It(L, s, l.historyEntry), "data-testid": "markdown-explorer-history-text", children: /* @__PURE__ */ c("pre", { children: T.text }) })
2558
+ ),
2559
+ /* @__PURE__ */ F("div", { className: "aqmx-confirm-actions", children: [
2560
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-testid": "markdown-explorer-history-close", onClick: r, children: l.historyClose }),
2561
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "aria-disabled": T === null || T.kind !== "revision", "data-testid": "markdown-explorer-history-restore", onClick: h, children: l.historyRestore })
2562
+ ] })
2563
+ ] }) });
2564
+ }, dl = (e) => {
2565
+ const { documents: t } = D(), n = $(() => t.peek(e), [t, e]), r = $(() => t.peekSeeded(e), [t, e]), o = ee(t.subscribe, n, r), i = de(o)?.document;
2566
+ return i === void 0 || i.kind === "failure" ? { edit: null, name: ye(e) } : { edit: i.kind === "markdown" ? i.edit : null, name: i.name };
2567
+ }, ae = (e) => {
2568
+ e.stopPropagation();
2569
+ }, ul = ({ path: e, documentName: t, iconOnly: n, previewAvailable: r, draft: o }) => {
2570
+ const { draftConverter: i, edits: l, labels: d } = D(), p = ee(
2571
+ l.subscribe,
2572
+ () => l.session(e) !== void 0,
2573
+ () => !1
2574
+ ), [f, u] = B(null), v = () => {
2575
+ if (!p) {
2576
+ l.start(e, l.viewAnchor(e));
2577
+ return;
2578
+ }
2579
+ l.flush(e);
2580
+ const k = l.session(e);
2581
+ k?.dirty === !0 ? u(k.save.kind === "draft" ? "draft" : "unsaved") : l.close(e);
2582
+ }, m = () => {
2583
+ p || (Br(), r && l.sideBySide() && i?.prepare?.());
2584
+ }, y = n ? o ? d.editDraftDocumentNamed(t) : d.editDocumentNamed(t) : null, A = o ? d.editDraftDocument : d.editDocument;
2585
+ return /* @__PURE__ */ F(Ne, { children: [
2586
+ /* @__PURE__ */ F(
2587
+ "button",
2588
+ {
2589
+ type: "button",
2590
+ className: y === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2591
+ title: p ? d.closeEditor : y === null ? A : y,
2592
+ "aria-label": y === null ? void 0 : y,
2593
+ "aria-pressed": p,
2594
+ "data-testid": "markdown-explorer-document-edit",
2595
+ onClick: v,
2596
+ onDoubleClick: ae,
2597
+ onPointerEnter: m,
2598
+ onFocus: m,
2599
+ children: [
2600
+ /* @__PURE__ */ c(el, { "aria-hidden": "true" }),
2601
+ y === null ? /* @__PURE__ */ c("span", { children: d.editDocumentLabel }) : null
2602
+ ]
2603
+ }
2604
+ ),
2605
+ /* @__PURE__ */ c(
2606
+ an,
2607
+ {
2608
+ open: f !== null,
2609
+ title: f === "draft" ? d.draftDiscardTitle : d.unsavedTitle,
2610
+ body: f === "draft" ? d.draftDiscardBody(t) : d.unsavedBody(t),
2611
+ confirmLabel: d.unsavedDiscard,
2612
+ cancelLabel: d.unsavedStay,
2613
+ testId: "markdown-explorer-edit-close-confirm",
2614
+ onConfirm: () => {
2615
+ u(null), l.close(e);
2616
+ },
2617
+ onCancel: () => u(null)
2618
+ }
2619
+ )
2620
+ ] });
2621
+ }, fl = ({ href: e, documentName: t, iconOnly: n }) => {
2622
+ const { labels: r } = D(), o = n ? r.editExternallyNamed(t) : null;
2623
+ return /* @__PURE__ */ F(
2624
+ "a",
2625
+ {
2626
+ className: o === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2627
+ href: e,
2628
+ target: "_blank",
2629
+ rel: "noopener noreferrer",
2630
+ title: o === null ? r.editExternally : o,
2631
+ "aria-label": o === null ? void 0 : o,
2632
+ "data-testid": "markdown-explorer-document-edit-external",
2633
+ onDoubleClick: ae,
2634
+ children: [
2635
+ /* @__PURE__ */ c(zi, { "aria-hidden": "true" }),
2636
+ o === null ? /* @__PURE__ */ c("span", { children: r.editExternallyLabel }) : null
2637
+ ]
2638
+ }
2639
+ );
2640
+ }, ml = ({ session: e }) => {
2641
+ const { labels: t } = D(), n = kr(t, e);
2642
+ return /* @__PURE__ */ c("p", { className: "aqmx-edit-status", title: n === "" ? void 0 : n, "data-testid": "markdown-explorer-edit-status", "data-aqmx-save": e.save.kind, children: n });
2643
+ }, hl = Object.freeze(["editor", "split", "preview"]), pl = Object.freeze(["editor", "preview"]), vl = Object.freeze({ editor: Cn, split: nl, preview: Ji }), wl = ({ path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }) => {
2644
+ const { draftConverter: i, edits: l, labels: d } = D(), p = Pr(), f = il(r, p, o), u = o ? hl : pl, v = ve(), m = q(/* @__PURE__ */ new Map()), y = {
2645
+ editor: { label: d.editViewEditor, tooltip: d.editViewEditorTooltip },
2646
+ split: { label: d.editViewSplit, tooltip: d.editViewSplitTooltip },
2647
+ preview: { label: d.editViewPreview, tooltip: d.editViewPreviewTooltip }
2648
+ }, A = () => {
2649
+ l.preparePreview(e), i?.prepare?.();
2650
+ }, k = (S) => {
2651
+ if (!sl(S.nativeEvent, al(navigator.platform))) return;
2652
+ rt(S);
2653
+ const M = ll(f);
2654
+ Bt(l, e, M, o), m.current.get(M)?.focus();
2655
+ };
2656
+ return /* @__PURE__ */ c("div", { role: "radiogroup", "aria-label": n ? d.editViewNamed(t) : d.editView, className: "aqmx-edit-view", "data-testid": "markdown-explorer-edit-view", onKeyDown: k, children: u.map((S) => {
2657
+ const M = vl[S], { label: T, tooltip: a } = y[S], s = S === "preview" ? A : void 0;
2658
+ return /* @__PURE__ */ F("label", { className: n ? "aqmx-icon-button" : "aqmx-icon-button aqmx-labelled-button", children: [
2659
+ /* @__PURE__ */ c(
2660
+ "input",
2661
+ {
2662
+ ref: (h) => {
2663
+ h === null ? m.current.delete(S) : m.current.set(S, h);
2664
+ },
2665
+ type: "radio",
2666
+ name: v,
2667
+ value: S,
2668
+ checked: S === f,
2669
+ "aria-label": T,
2670
+ "aria-keyshortcuts": S === "split" ? void 0 : ol,
2671
+ title: a,
2672
+ "data-testid": `markdown-explorer-edit-view-${S}`,
2673
+ onChange: () => Bt(l, e, S, o),
2674
+ onDoubleClick: ae,
2675
+ onPointerEnter: s,
2676
+ onFocus: s
2677
+ }
2678
+ ),
2679
+ /* @__PURE__ */ c(M, { "aria-hidden": "true" }),
2680
+ n ? null : /* @__PURE__ */ c("span", { children: T })
2681
+ ] }, S);
2682
+ }) });
2683
+ }, gl = ({ path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }) => {
2684
+ const { edits: i, labels: l } = D(), [d, p] = B(!1);
2685
+ if (r.phase.kind !== "editing") return null;
2686
+ const f = r.save.kind === "saving", u = f || !r.dirty, v = () => {
2687
+ i.flush(e);
2688
+ const y = i.session(e);
2689
+ y === void 0 || !y.dirty || y.save.kind === "saving" || i.save(e);
2690
+ }, m = (y) => n ? { className: "aqmx-icon-button", "aria-label": y } : { className: "aqmx-icon-button aqmx-labelled-button" };
2691
+ return /* @__PURE__ */ F(Ne, { children: [
2692
+ r.save.kind === "conflicts" ? /* @__PURE__ */ F("button", { type: "button", ...m(l.conflictNext), title: l.conflictNext, "data-testid": "markdown-explorer-edit-next-conflict", onClick: () => i.nextConflict(e), onDoubleClick: ae, children: [
2693
+ /* @__PURE__ */ c(Zi, { "aria-hidden": "true" }),
2694
+ n ? null : /* @__PURE__ */ c("span", { children: l.conflictNext })
2695
+ ] }) : null,
2696
+ /* @__PURE__ */ c(wl, { path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }),
2697
+ r.history ? /* @__PURE__ */ F("button", { type: "button", ...m(l.historyOpen), title: l.historyOpen, "aria-haspopup": "dialog", "data-testid": "markdown-explorer-edit-history", onClick: () => p(!0), onDoubleClick: ae, children: [
2698
+ /* @__PURE__ */ c(Ki, { "aria-hidden": "true" }),
2699
+ n ? null : /* @__PURE__ */ c("span", { children: l.historyOpen })
2700
+ ] }) : null,
2701
+ r.save.kind === "draft" ? null : /* @__PURE__ */ F("button", { type: "button", ...m(l.saveDraft), title: l.saveDraftTooltip, "aria-disabled": u, "aria-busy": f, "aria-keyshortcuts": "Control+S Meta+S", "data-testid": "markdown-explorer-edit-save", onClick: v, onDoubleClick: ae, children: [
2702
+ /* @__PURE__ */ c(Xi, { "aria-hidden": "true" }),
2703
+ n ? null : /* @__PURE__ */ c("span", { children: l.saveDraft })
2704
+ ] }),
2705
+ r.history ? /* @__PURE__ */ c(cl, { path: e, documentName: t, open: d, onClose: () => p(!1) }) : null
2706
+ ] });
2707
+ }, bl = ({ path: e, session: t }) => {
2708
+ const { edits: n } = D();
2709
+ return t.save.kind !== "grant" ? null : /* @__PURE__ */ c(rl, { href: t.save.href, onRetry: () => {
2710
+ n.save(e);
2711
+ }, testId: "markdown-explorer-save-grant" });
2712
+ }, El = (e) => {
2713
+ const { documents: t } = D(), n = $(() => t.peek(e), [t, e]), r = $(() => t.peekSeeded(e), [t, e]), o = ee(t.subscribe, n, r);
2714
+ return de(o)?.document.kind === "markdown";
2715
+ }, yl = (e) => {
2716
+ const { config: t } = D(), n = Pe(), r = $(() => n(pe(t, { ...e, markup: !e.markup }), "browse"), [t, n, e]);
2717
+ return U(() => ({ shown: e.markup, toggle: r }), [e.markup, r]);
2718
+ }, kl = /* @__PURE__ */ new Set(), xl = (e, t) => {
2719
+ const { documents: n, announcer: r, labels: o } = D(), i = $(() => n.peek(e), [n, e]), l = $(() => n.peekSeeded(e), [n, e]), d = ee(n.subscribe, i, l), p = $(() => n.answerStampOf(e), [n, e]), f = ee(n.subscribe, p, p), [u] = B(() => /* @__PURE__ */ new Set()), [v, m] = B(kl), [y, A] = B(null);
2720
+ y !== null && y.path !== e && A(null);
2721
+ const k = q(null);
2722
+ Z(() => (k.current = e, () => {
2723
+ k.current = null;
2724
+ }), [e]);
2725
+ const S = $(() => {
2726
+ const a = e, s = n.peek(a);
2727
+ if (u.has(a) || s?.status === "pending") return;
2728
+ const h = t && !pn(s);
2729
+ u.add(a), m(new Set(u)), A(null), (async () => {
2730
+ try {
2731
+ const g = await n.refresh(a);
2732
+ if (k.current !== a || g.status === "superseded") return;
2733
+ if (g.status === "failed") {
2734
+ A({ path: a, failure: g.failure, stamp: n.answerStampOf(a) }), r.announce(o.documentRefreshFailed(se(o, g.failure.reason)));
2735
+ return;
2736
+ }
2737
+ const R = de(n.peek(a));
2738
+ if (h || R === null || R.document.kind === "failure") return;
2739
+ r.announce(o.documentRefreshed(R.document.name));
2740
+ } finally {
2741
+ u.delete(a), m(new Set(u));
2742
+ }
2743
+ })();
2744
+ }, [e, t, u, n, r, o]), M = v.has(e), T = y !== null && y.path === e && y.stamp === f ? y.failure : null;
2745
+ return { refreshing: M, unavailable: M || d?.status === "pending", failure: T, refresh: S };
2746
+ }, Sl = Object.freeze({ kind: "page" }), Rl = ({ path: e, placement: t, markup: n }) => {
2747
+ const { labels: r } = D(), { refreshing: o, unavailable: i, failure: l, refresh: d } = xl(e, t.kind === "page"), p = El(e), f = dl(e), u = sn(e), v = t.kind === "panel" ? r.refreshDocumentNamed(t.documentName) : null, m = t.kind === "panel" ? r.showMarkupNamed(t.documentName) : null, y = t.kind === "panel", A = t.kind === "panel" ? t.documentName : f.name, k = t.kind === "page" || t.maximized;
2748
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-refresh-bar", "data-testid": "markdown-explorer-document-refresh-bar", "data-aqmx-editing": u === void 0 ? void 0 : "true", children: [
2749
+ /* @__PURE__ */ F("div", { className: "aqmx-document-refresh-row", children: [
2750
+ u === void 0 ? null : /* @__PURE__ */ c(ml, { session: u }),
2751
+ u === void 0 ? null : /* @__PURE__ */ c(gl, { path: e, documentName: A, iconOnly: y, session: u, previewAvailable: k }),
2752
+ u === void 0 && p ? /* @__PURE__ */ F(
2753
+ "button",
2754
+ {
2755
+ type: "button",
2756
+ className: m === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2757
+ title: m === null ? r.showMarkup : m,
2758
+ "aria-label": m === null ? void 0 : m,
2759
+ "aria-pressed": n.shown,
2760
+ "data-testid": "markdown-explorer-document-markup",
2761
+ onClick: n.toggle,
2762
+ onDoubleClick: ae,
2763
+ children: [
2764
+ /* @__PURE__ */ c(Cn, { "aria-hidden": "true" }),
2765
+ m === null ? /* @__PURE__ */ c("span", { children: r.showMarkupLabel }) : null
2766
+ ]
2767
+ }
2768
+ ) : null,
2769
+ u !== void 0 || f.edit?.kind === "inline" || f.edit?.kind === "draft" ? /* @__PURE__ */ c(ul, { path: e, documentName: A, iconOnly: y, previewAvailable: k, draft: f.edit?.kind === "draft" }) : f.edit?.kind === "external" ? /* @__PURE__ */ c(fl, { href: f.edit.href, documentName: A, iconOnly: y }) : null,
2770
+ u === void 0 ? /* @__PURE__ */ F(
2771
+ "button",
2772
+ {
2773
+ type: "button",
2774
+ className: v === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2775
+ title: v === null ? r.refreshDocument : v,
2776
+ "aria-label": v === null ? void 0 : v,
2777
+ "aria-disabled": i,
2778
+ "aria-busy": o,
2779
+ "data-aqmx-busy": o ? "true" : void 0,
2780
+ "data-testid": "markdown-explorer-document-refresh",
2781
+ onClick: d,
2782
+ onDoubleClick: ae,
2783
+ children: [
2784
+ /* @__PURE__ */ c(ji, { "aria-hidden": "true" }),
2785
+ v === null ? /* @__PURE__ */ c("span", { children: r.refreshDocumentLabel }) : null
2786
+ ]
2787
+ }
2788
+ ) : null
2789
+ ] }),
2790
+ u !== void 0 || l === null ? null : /* @__PURE__ */ c("p", { className: "aqmx-document-refresh-failure", "data-testid": "markdown-explorer-document-refresh-failure", "data-aqmx-failure": l.reason, children: r.documentRefreshFailed(se(r, l.reason)) }),
2791
+ u === void 0 ? null : /* @__PURE__ */ c(bl, { path: e, session: u })
2792
+ ] });
2793
+ }, Tl = ({ location: e }) => {
2794
+ const t = e.doc, n = U(() => ({ kind: "page", view: "single", overrides: e.overrides, embed: e.embed }), [e.overrides, e.embed]), r = yl(e);
2795
+ return /* @__PURE__ */ F("div", { className: "aqmx-single aqmx-document-column", "data-testid": "markdown-explorer-single", children: [
2796
+ /* @__PURE__ */ c(Rl, { path: t, placement: Sl, markup: r }),
2797
+ /* @__PURE__ */ c(Bi, { path: t, markup: e.markup, variant: n })
2798
+ ] });
2799
+ }, Cl = ({ holds: e, testId: t }) => {
2800
+ const { labels: n, announcer: r } = D(), o = ve();
2801
+ Z(() => e ? r.claim(o) : void 0, [e, r, o]);
2802
+ const i = $(() => r.shownIn(o), [r, o]), l = ee(r.subscribe, i, i);
2803
+ return /* @__PURE__ */ c("div", { className: "aqmx-sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", "data-testid": t, children: l.length > 1 ? n.announcementSequence(l) : l[0] });
2804
+ }, ue = Object.freeze([]), Ol = (e) => {
2805
+ const t = /* @__PURE__ */ new Set();
2806
+ let n = ue, r = [], o = !1;
2807
+ const i = [], l = (u) => {
2808
+ n = u;
2809
+ for (const v of [...t]) v();
2810
+ }, d = () => i.at(-1)?.region, p = (u) => {
2811
+ const v = d();
2812
+ u(), d() !== v && n !== ue && l(ue);
2813
+ }, f = () => {
2814
+ o = !1;
2815
+ const u = r.map((v) => "sentence" in v ? v.sentence : v.list(v.items));
2816
+ r = [], l(Object.freeze(u));
2817
+ };
2818
+ return {
2819
+ announce: (u) => {
2820
+ if (typeof u == "string") r.push({ sentence: u });
2821
+ else {
2822
+ const v = r.find((m) => "list" in m && m.list === u.list);
2823
+ v !== void 0 && "items" in v ? v.items.push(u.item) : r.push({ list: u.list, items: [u.item] });
2824
+ }
2825
+ o || (o = !0, n !== ue && l(ue), e.request(f));
2826
+ },
2827
+ subscribe: (u) => (t.add(u), () => {
2828
+ t.delete(u);
2829
+ }),
2830
+ claim: (u) => {
2831
+ const v = { region: u };
2832
+ return p(() => i.push(v)), () => p(() => {
2833
+ const m = i.indexOf(v);
2834
+ m !== -1 && i.splice(m, 1);
2835
+ });
2836
+ },
2837
+ shownIn: (u) => d() === u ? n : ue
2838
+ };
2839
+ }, he = Object.freeze({ status: "cancelled" }), Al = (e) => {
2840
+ if (e === null || typeof e != "object") return null;
2841
+ const { failure: t } = e;
2842
+ if (Yn(t) !== null) return null;
2843
+ const { reason: n, code: r } = t;
2844
+ return Jn(n, r);
2845
+ }, Ll = ({ dataPath: e, onScope: t, fetch: n }) => {
2846
+ const r = n ?? ((f, u) => globalThis.fetch(f, u)), o = (f, u) => `${e}/${f}?${new URLSearchParams(u).toString()}`, i = async (f, u, v, m) => {
2847
+ let y;
2848
+ try {
2849
+ y = await r(f, { credentials: "same-origin", ...u, headers: { Accept: "application/json", ...u.headers } });
2850
+ } catch {
2851
+ return m({ reason: "failed" });
2852
+ }
2853
+ y.status === 401 && t(null);
2854
+ const A = y.headers.get(Zn);
2855
+ A !== null && t(A);
2856
+ let k;
2857
+ try {
2858
+ k = await y.json();
2859
+ } catch {
2860
+ return m({ reason: pt(y.status) });
2861
+ }
2862
+ let S;
2863
+ try {
2864
+ S = v(k);
2865
+ } catch {
2866
+ S = !1;
2867
+ }
2868
+ if (S) return k;
2869
+ const M = Al(k);
2870
+ return m(M !== null ? M : { reason: y.status === 200 ? "failed" : pt(y.status) });
2871
+ }, l = { [wt]: Qn }, d = { [wt]: or, "Content-Type": `${rr}; charset=utf-8` }, p = async (f, u, v) => {
2872
+ const m = await i(f, u, v, (y) => He(y.reason, y.code));
2873
+ return u.signal.aborted ? he : m;
2874
+ };
2875
+ return {
2876
+ tree: (f) => i(o("tree", { [W.source]: f }), { method: "GET" }, vt, (u) => ({ status: "error", failure: u })),
2877
+ children: async (f, u, v) => {
2878
+ const m = await i(o("children", { [W.source]: f, [W.path]: u }), { method: "GET", signal: v }, Xn, (y) => ({ status: "error", failure: y }));
2879
+ return v.aborted ? he : m;
2880
+ },
2881
+ ancestors: async (f, u, v) => {
2882
+ const m = await i(o("ancestors", { [W.source]: f, [W.path]: u }), { method: "GET", signal: v }, Wn, (y) => ({ status: "error", failure: y }));
2883
+ return v.aborted ? he : m;
2884
+ },
2885
+ reveal: async (f, u, v) => {
2886
+ const m = await i(o("reveal", { [W.source]: f, [W.path]: u }), { method: "GET", signal: v }, Kn, (y) => ({ status: "error", failure: y }));
2887
+ return v.aborted ? he : m;
2888
+ },
2889
+ document: (f, { refresh: u }) => i(o("document", { [W.path]: f }), u ? { method: "GET", headers: l } : { method: "GET" }, ar, (v) => He(v.reason, v.code)),
2890
+ text: async (f, u) => {
2891
+ const v = await i(o("text", { [W.path]: f }), { method: "GET", signal: u }, Gn, (m) => He(m.reason, m.code));
2892
+ return u.aborted ? he : v;
2893
+ },
2894
+ edit: (f, u) => p(o("edit", { [W.path]: f }), { method: "GET", signal: u }, lr),
2895
+ save: (f, u, v, m) => p(o("save", { [W.path]: f, [W.base]: u }), { method: "POST", headers: d, body: v, signal: m }, ir),
2896
+ preview: (f, u, v) => p(o("preview", { [W.path]: f }), { method: "POST", headers: d, body: u, signal: v }, nr),
2897
+ revisions: (f, u) => p(o("revisions", { [W.path]: f }), { method: "GET", signal: u }, tr),
2898
+ revision: (f, u, v) => p(o("revision", { [W.path]: f, [W.revision]: u }), { method: "GET", signal: v }, er),
2899
+ refresh: (f) => i(o("refresh", { [W.source]: f }), { method: "POST", headers: l }, vt, (u) => ({ status: "error", failure: u }))
2900
+ };
2901
+ }, Ml = () => {
2902
+ let e = null, t = null;
2903
+ return {
2904
+ settle: (n) => {
2905
+ e = n;
2906
+ },
2907
+ mayMove: (n) => e !== n,
2908
+ move: (n, r, o) => {
2909
+ e = r, t = { sourceId: n, path: r, ancestors: o };
2910
+ },
2911
+ take: (n, r) => {
2912
+ const o = t !== null && t.sourceId === n && t.path === r ? t.ancestors : null;
2913
+ return t = null, o;
2914
+ }
2915
+ };
2916
+ }, Nl = (e) => {
2917
+ const t = en(e);
2918
+ if (t === null) return ht;
2919
+ try {
2920
+ return jn(JSON.parse(t));
2921
+ } catch (n) {
2922
+ return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`, n), ht;
2923
+ }
2924
+ }, jt = (e, t) => {
2925
+ let n = null;
2926
+ const r = () => {
2927
+ if (n === null) {
2928
+ const i = Nl(e);
2929
+ n = { changes: i, settings: mt(t, i) };
2930
+ }
2931
+ return n;
2932
+ }, o = ke();
2933
+ return {
2934
+ storageKey: e,
2935
+ defaults: t,
2936
+ getSnapshot: () => r().settings,
2937
+ getServerSnapshot: () => t,
2938
+ subscribe: o.subscribe,
2939
+ advance: (i) => {
2940
+ const { changes: l, settings: d } = r(), p = _n(l, i, Bn(d, i)[i], t);
2941
+ return n = { changes: p, settings: mt(t, p) }, o.emit(), Qt(e, In(p)), n.settings;
2942
+ }
2943
+ };
2944
+ }, Dl = Object.freeze({ status: "refreshed" }), Pl = Object.freeze({ status: "superseded" }), et = Object.freeze({ status: "deferred" }), $l = hn(et), On = 4, Fl = On - 1, Ht = Object.freeze({ status: "loading" }), ql = Object.freeze({ status: "error", failure: Object.freeze({ reason: "failed" }) }), _l = (e) => {
2945
+ const t = /* @__PURE__ */ new Map(), n = mn(), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), d = ke(), p = /* @__PURE__ */ new Set();
2946
+ let f = 0, u = 0;
2947
+ const v = { direct: null, bulk: null }, m = /* @__PURE__ */ new Set();
2948
+ let y = !1, A = 0;
2949
+ const k = () => {
2950
+ A += 1, d.emit();
2951
+ }, S = (w) => o.get(w) ?? 0, M = (w) => {
2952
+ let E = l.get(w);
2953
+ return E === void 0 && (E = { claims: /* @__PURE__ */ new Map(), unclaimed: /* @__PURE__ */ new Set(), direct: /* @__PURE__ */ new Set(), bulk: /* @__PURE__ */ new Set(), inFlight: /* @__PURE__ */ new Map() }, l.set(w, E)), E;
2954
+ }, T = (w, E, x) => {
2955
+ w.inFlight.delete(E), f -= 1, x.lane === "bulk" && (u -= 1);
2956
+ }, a = (w) => {
2957
+ const E = l.get(w);
2958
+ if (E !== void 0) {
2959
+ for (const [x, C] of [...E.inFlight])
2960
+ T(E, x, C), C.controller.abort();
2961
+ E.direct.clear(), E.bulk.clear(), E.unclaimed.clear();
2962
+ }
2963
+ }, s = (w) => {
2964
+ const E = S(w) + 1;
2965
+ return o.set(w, E), a(w), E;
2966
+ }, h = (w, E) => {
2967
+ const x = Re(w), C = { promise: w, opened: E, stale: !1, loadedAt: x?.status === "ok" ? x.loadedAt : null };
2968
+ return w.status === "pending" && w.then((P) => {
2969
+ P.status === "ok" && (C.loadedAt = P.loadedAt);
2970
+ }), C;
2971
+ }, g = (w) => {
2972
+ let E = r.get(w);
2973
+ return E === void 0 && (E = /* @__PURE__ */ new Map(), r.set(w, E)), E;
2974
+ }, R = (w) => {
2975
+ const E = [...l.keys()], x = v[w], C = x === null ? 0 : E.indexOf(x) + 1;
2976
+ for (let P = 0; P < E.length; P += 1) {
2977
+ const _ = E[(C + P) % E.length], G = _ === void 0 ? void 0 : l.get(_);
2978
+ if (!(_ === void 0 || G === void 0)) {
2979
+ for (const V of G[w])
2980
+ if ((G.claims.get(V) ?? 0) !== 0)
2981
+ return G[w].delete(V), v[w] = _, { sourceId: _, path: V };
2982
+ }
2983
+ }
2984
+ return null;
2985
+ }, L = (w, E, x, C) => {
2986
+ const P = l.get(w);
2987
+ if (P === void 0 || P.inFlight.get(E) !== x) return;
2988
+ T(P, E, x);
2989
+ const _ = (P.claims.get(E) ?? 0) > 0, G = g(w);
2990
+ if (C.status === "ok" ? G.set(E, { status: "loaded", entries: C.entries }) : C.status === "error" && _ ? G.set(E, { status: "failed", failure: C.failure }) : G.delete(E), k(), C.status === "error" && _) {
2991
+ const V = { sourceId: w, path: E, failure: C.failure };
2992
+ for (const ie of [...p]) ie(V);
2993
+ }
2994
+ N();
2995
+ }, O = (w, E, x) => {
2996
+ const C = { controller: new AbortController(), lane: x };
2997
+ M(w).inFlight.set(E, C), f += 1, x === "bulk" && (u += 1), e.children(w, E, C.controller.signal).then(
2998
+ (P) => L(w, E, C, P),
2999
+ () => L(w, E, C, ql)
3000
+ );
3001
+ }, N = () => {
3002
+ for (; f < On; ) {
3003
+ const w = R("direct");
3004
+ if (w !== null) {
3005
+ O(w.sourceId, w.path, "direct");
3006
+ continue;
3007
+ }
3008
+ const E = u < Fl ? R("bulk") : null;
3009
+ if (E === null) return;
3010
+ O(E.sourceId, E.path, "bulk");
3011
+ }
3012
+ }, j = (w, E, x) => {
3013
+ if (!(E.direct.delete(x) || E.bulk.delete(x))) {
3014
+ const P = E.inFlight.get(x);
3015
+ if (P === void 0) return !1;
3016
+ T(E, x, P), P.controller.abort();
3017
+ }
3018
+ return r.get(w)?.delete(x), !0;
3019
+ }, I = () => {
3020
+ y = !1;
3021
+ let w = !1;
3022
+ for (const E of m) {
3023
+ const x = M(E);
3024
+ for (const C of x.unclaimed)
3025
+ (x.claims.get(C) ?? 0) === 0 && j(E, x, C) && (w = !0);
3026
+ x.unclaimed.clear();
3027
+ }
3028
+ m.clear(), w && (k(), N());
3029
+ }, X = (w, E) => {
3030
+ t.set(w, h(Ee(e.tree(w)), E));
3031
+ }, Q = (w, E, x) => {
3032
+ s(w);
3033
+ const C = h(hn(E), x);
3034
+ return t.set(w, C), r.delete(w), k(), N(), C;
3035
+ }, J = (w, E, x, C) => {
3036
+ if (x !== S(w) || t.get(w) !== E) return;
3037
+ const P = Re(E.promise);
3038
+ if (!(C.status !== "ok" || P?.status !== "ok" || E.loadedAt === null || C.loadedAt <= E.loadedAt)) {
3039
+ if (Me(P.entries, C.entries)) {
3040
+ E.loadedAt = C.loadedAt;
3041
+ return;
3042
+ }
3043
+ Q(w, C, E.opened);
3044
+ }
3045
+ }, H = (w, E) => {
3046
+ const x = t.get(w);
3047
+ return x !== void 0 && Re(x.promise)?.status === E;
3048
+ }, oe = (w, E) => {
3049
+ E.stale = !1;
3050
+ const x = S(w);
3051
+ e.tree(w).then((C) => J(w, E, x, C));
3052
+ };
3053
+ return {
3054
+ read: (w) => t.get(w)?.promise ?? $l,
3055
+ open: (w) => {
3056
+ const E = n.resumes(w), x = n.hold(w), C = t.get(w);
3057
+ return C === void 0 || H(w, "deferred") ? (X(w, !0), k()) : E || (C.opened && H(w, "error") ? (X(w, !0), k()) : (C.opened = !0, C.stale && H(w, "ok") && oe(w, C))), x;
3058
+ },
3059
+ retry: (w) => {
3060
+ H(w, "error") && (X(w, !0), k());
3061
+ },
3062
+ seed: (w, E) => {
3063
+ const x = E.then(
3064
+ (_) => _ === null ? et : _,
3065
+ () => et
3066
+ ), C = t.get(w);
3067
+ if (C !== void 0 && H(w, "ok")) {
3068
+ const _ = S(w);
3069
+ x.then((G) => J(w, C, _, G));
3070
+ return;
3071
+ }
3072
+ s(w);
3073
+ const P = h(Ee(x), C?.opened === !0);
3074
+ t.set(w, P), r.delete(w), N(), x.then((_) => {
3075
+ t.get(w) === P && (_.status === "deferred" && n.isHeld(w) && X(w, P.opened), k());
3076
+ });
3077
+ },
3078
+ refresh: async (w) => {
3079
+ const E = (i.get(w) ?? 0) + 1;
3080
+ i.set(w, E);
3081
+ const x = await e.refresh(w);
3082
+ if (i.get(w) !== E) return Pl;
3083
+ if (x.status === "error") return { status: "failed", failure: x.failure };
3084
+ const C = t.get(w);
3085
+ if (!(C !== void 0 && C.loadedAt !== null && H(w, "ok") && C.loadedAt > x.loadedAt)) {
3086
+ const _ = Q(w, x, !0);
3087
+ if (C !== void 0 && C.promise.status === "pending") {
3088
+ const G = S(w);
3089
+ C.promise.then((V) => J(w, _, G, V));
3090
+ }
3091
+ }
3092
+ for (const [_, G] of t)
3093
+ _ !== w && Re(G.promise)?.status === "ok" && (G.stale = !0);
3094
+ return Dl;
3095
+ },
3096
+ children: (w, E) => r.get(w)?.get(E),
3097
+ claimChildren: (w, E) => {
3098
+ const x = M(w), C = g(w);
3099
+ let P = !1, _ = !1;
3100
+ for (const [V, ie] of E)
3101
+ x.claims.set(V, (x.claims.get(V) ?? 0) + 1), C.get(V) === void 0 ? (C.set(V, Ht), x[ie].add(V), P = !0, _ = !0) : ie === "direct" && x.bulk.delete(V) && (x.direct.add(V), _ = !0);
3102
+ P && k(), _ && N();
3103
+ let G = !1;
3104
+ return () => {
3105
+ if (!G) {
3106
+ G = !0;
3107
+ for (const V of E.keys()) {
3108
+ const ie = (x.claims.get(V) ?? 0) - 1;
3109
+ ie > 0 ? x.claims.set(V, ie) : (x.claims.delete(V), x.unclaimed.add(V));
3110
+ }
3111
+ m.add(w), !y && (y = !0, queueMicrotask(I));
3112
+ }
3113
+ };
3114
+ },
3115
+ retryChildren: (w, E) => {
3116
+ const x = r.get(w);
3117
+ if (x === void 0 || x.get(E)?.status !== "failed") return;
3118
+ const C = M(w);
3119
+ if ((C.claims.get(E) ?? 0) > 0) {
3120
+ x.set(E, Ht), C.direct.add(E), k(), N();
3121
+ return;
3122
+ }
3123
+ x.delete(E), k();
3124
+ },
3125
+ pendingChildren: (w) => {
3126
+ const E = l.get(w);
3127
+ return E === void 0 ? 0 : E.direct.size + E.bulk.size + E.inFlight.size;
3128
+ },
3129
+ clear: () => {
3130
+ for (const w of /* @__PURE__ */ new Set([...t.keys(), ...r.keys(), ...o.keys(), ...l.keys()])) s(w);
3131
+ for (const [w, E] of i) i.set(w, E + 1);
3132
+ t.clear(), r.clear(), k();
3133
+ },
3134
+ subscribeChildrenFailures: (w) => (p.add(w), () => {
3135
+ p.delete(w);
3136
+ }),
3137
+ subscribe: d.subscribe,
3138
+ version: () => A
3139
+ };
3140
+ }, Bl = (e, t) => {
3141
+ let n = e;
3142
+ const r = ke();
3143
+ return {
3144
+ getSnapshot: () => n,
3145
+ subscribe: r.subscribe,
3146
+ update: (o) => {
3147
+ n = { ...n, ...o }, t(n), r.emit();
3148
+ }
3149
+ };
3150
+ }, Il = 1;
3151
+ let Te = 0, ce = null;
3152
+ const jl = () => {
3153
+ const { documentElement: e, body: t } = document;
3154
+ Te === 0 && (ce = { htmlOverflow: e.style.overflow, bodyOverflow: t.style.overflow, htmlGutter: e.style.scrollbarGutter, bodyGutter: t.style.scrollbarGutter }, e.style.overflow = "hidden", t.style.overflow = "hidden", e.style.scrollbarGutter = "auto", t.style.scrollbarGutter = "auto"), Te += 1;
3155
+ let n = !1;
3156
+ return () => {
3157
+ n || (n = !0, Te -= 1, !(Te > 0 || ce === null) && (e.style.overflow = ce.htmlOverflow, t.style.overflow = ce.bodyOverflow, e.style.scrollbarGutter = ce.htmlGutter, t.style.scrollbarGutter = ce.bodyGutter, ce = null));
3158
+ };
3159
+ }, Hl = [
3160
+ { selector: '[data-aqmx-document-flow="fill"]', name: "document region" },
3161
+ { selector: "[data-aqmx-explorer-body]", name: "tree area" }
3162
+ ], Vt = 1, zt = (e) => e.getClientRects().length > 0, Ke = "Give the explorer's container a definite block size (for example height: 100dvh, or a flex column of definite height whose item has flex: 1 and min-height: 0; in a fresh React Router app also html and body at height: 100%) instead of an auto or only a minimum height.", Vl = (e) => {
3163
+ if (!zt(e)) return null;
3164
+ const t = e.getBoundingClientRect(), n = window.innerHeight;
3165
+ if (t.bottom > n + Il)
3166
+ return `[markdown-explorer] the explorer ends ${String(Math.round(t.bottom))}px down a ${String(n)}px viewport while lockDocumentScroll stops the page from scrolling, so the rest cannot be reached. ${Ke}`;
3167
+ if (t.height < Vt)
3168
+ return `[markdown-explorer] the explorer collapsed to ${String(Math.round(t.height))}px while lockDocumentScroll stops the page from scrolling, so nothing can be read. ${Ke}`;
3169
+ for (const { selector: r, name: o } of Hl)
3170
+ for (const i of e.querySelectorAll(r)) {
3171
+ if (!zt(i)) continue;
3172
+ const l = i.getBoundingClientRect().height;
3173
+ if (l < Vt)
3174
+ return `[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(l))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Ke}`;
3175
+ }
3176
+ return null;
3177
+ }, zl = (e) => {
3178
+ let t = !1;
3179
+ const n = () => {
3180
+ if (t) return;
3181
+ const o = Vl(e);
3182
+ o !== null && (t = !0, console.error(o));
3183
+ }, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(n);
3184
+ return r?.observe(e), window.addEventListener("resize", n), n(), () => {
3185
+ r?.disconnect(), window.removeEventListener("resize", n);
3186
+ };
3187
+ }, Ul = (e, t) => {
3188
+ te(() => e ? jl() : void 0, [e]), te(() => {
3189
+ const n = t.current;
3190
+ if (!(!e || n === null))
3191
+ return zl(n);
3192
+ }, [e, t]);
3193
+ }, Ut = '[data-testid="markdown-explorer-view-switch"]', Zl = [
3194
+ { control: Ut, successors: [Ut, '[data-testid="markdown-explorer-sheet-toggle"]'] },
3195
+ { control: '[data-testid="markdown-explorer-selection-open"]', successors: ['[data-testid="markdown-explorer-panel-frame"]'] }
3196
+ ], Gl = (e) => {
3197
+ for (const t of Zl) {
3198
+ const n = e.closest(t.control);
3199
+ if (n !== null) return { element: n, control: t };
3200
+ }
3201
+ return null;
3202
+ }, Kl = (e, t) => {
3203
+ const n = q(null);
3204
+ te(() => {
3205
+ const o = (d) => {
3206
+ const p = e.current;
3207
+ n.current = p !== null && d instanceof Element && p.contains(d) ? Gl(d) : null;
3208
+ }, i = (d) => o(d.target);
3209
+ o(document.activeElement);
3210
+ const l = (d) => {
3211
+ const p = d.target;
3212
+ d.relatedTarget !== null || !(p instanceof Element) || queueMicrotask(() => {
3213
+ n.current?.element === p && p.isConnected && document.activeElement !== p && (n.current = null);
3214
+ });
3215
+ };
3216
+ return document.addEventListener("focusin", i), document.addEventListener("focusout", l), () => {
3217
+ document.removeEventListener("focusin", i), document.removeEventListener("focusout", l);
3218
+ };
3219
+ }, [e]);
3220
+ const r = q(t);
3221
+ Z(() => {
3222
+ if (r.current === t) return;
3223
+ r.current = t;
3224
+ const o = n.current;
3225
+ if (o === null) return;
3226
+ const i = () => {
3227
+ const p = document.activeElement;
3228
+ if (p !== null && p !== document.body && p !== o.element) return !0;
3229
+ const f = e.current;
3230
+ if (f === null) return !0;
3231
+ for (const u of o.control.successors)
3232
+ for (const v of f.querySelectorAll(u))
3233
+ if (v !== o.element && (v.focus({ preventScroll: !0 }), document.activeElement === v))
3234
+ return !0;
3235
+ return !1;
3236
+ };
3237
+ if (i()) return;
3238
+ const l = e.current;
3239
+ if (l === null) return;
3240
+ const d = new MutationObserver(() => {
3241
+ i() && d.disconnect();
3242
+ });
3243
+ return d.observe(l, { childList: !0, subtree: !0 }), () => d.disconnect();
3244
+ }, [t, e]);
3245
+ }, Wl = tt(() => import("./TreeLayout-FCp9WPFO.js").then((e) => ({ default: e.TreeLayout }))), Xl = tt(() => import("./MultiLayout-C2R85L4x.js").then((e) => ({ default: e.MultiLayout }))), Yl = 64, Jl = {
3246
+ request: (e) => {
3247
+ requestAnimationFrame(e);
3248
+ }
3249
+ }, Zt = (e) => {
3250
+ e.documents.clear(), e.trees.clear();
3251
+ }, We = (e, t) => {
3252
+ t.tree !== null && e.trees.seed(t.tree.sourceId, t.tree.result);
3253
+ for (const { path: n, document: r } of t.documents) e.documents.seed(n, r);
3254
+ }, Ql = (e, t) => {
3255
+ const [n, r] = B(() => ({ overrides: t, locale: e, labels: yt(e, t) }));
3256
+ if (n.locale === e && Er(n.overrides, t)) return n.labels;
3257
+ const o = { overrides: t, locale: e, labels: yt(e, t) };
3258
+ return r(o), o.labels;
3259
+ }, ea = (e, t, n) => {
3260
+ const [r, o] = B(() => ({ scope: t, store: jt(e, n) }));
3261
+ if (r.scope === t && r.store.storageKey === e && r.store.defaults === n) return r.store;
3262
+ const i = { scope: t, store: jt(e, n) };
3263
+ return o(i), i.store;
3264
+ }, Xe = (e, t) => {
3265
+ const [n, r] = B(() => ({ scope: e, value: t() }));
3266
+ if (n.scope === e) return n.value;
3267
+ const o = { scope: e, value: t() };
3268
+ return r(o), o.value;
3269
+ }, ta = () => Ol(Jl), Gt = "on", na = "off", ra = Object.freeze({ kind: "unavailable" }), oa = (e) => {
3270
+ if (e !== void 0 && (e === null || typeof e != "object" || typeof e.convert != "function"))
3271
+ throw new TypeError("[markdown-explorer] draftConverter must be an object with a convert function");
3272
+ }, ia = (e, t) => {
3273
+ const n = de(e.peek(t));
3274
+ return n === null || n.document.kind === "failure" ? ye(t) : n.document.name;
3275
+ }, Ea = ({
3276
+ data: e,
3277
+ config: t,
3278
+ storageNamespace: n,
3279
+ locale: r,
3280
+ labels: o,
3281
+ theme: i,
3282
+ renderFrame: l,
3283
+ renderTreeFailure: d,
3284
+ lockDocumentScroll: p = !1,
3285
+ onMathDiagnostics: f,
3286
+ onEditGrant: u,
3287
+ draftConverter: v
3288
+ }) => {
3289
+ ur(n), oa(v);
3290
+ const m = rn(r), y = yr(i), A = Ql(m, o), { revalidate: k } = $n(), S = q(() => {
3291
+ }), M = De(t.dataPath), [T] = B(() => {
3292
+ const x = Ll({ dataPath: M, onScope: (P) => S.current(P) }), C = { documents: so({ client: x, capacity: Math.max(Yl, t.multiView.maxPanels * 2) }), trees: _l(x) };
3293
+ return We(C, e), bt(n, e.scope), { data: x, ...C, aligned: { pageData: e, storageNamespace: n, pendingReader: null } };
3294
+ });
3295
+ if (T.aligned.pageData !== e || T.aligned.storageNamespace !== n) {
3296
+ const x = T.aligned.pageData;
3297
+ T.aligned.pageData = e, T.aligned.storageNamespace = n, x !== e && (x.scope !== e.scope ? T.aligned.pendingReader = e : We(T, e)), bt(n, e.scope);
3298
+ }
3299
+ const a = ea(Ve(n).treeSettings, e.scope, t.defaultTreeSettings);
3300
+ Z(() => {
3301
+ const x = T.aligned.pendingReader;
3302
+ x !== null && (T.aligned.pendingReader = null, Zt(T), We(T, x));
3303
+ }, [e, T]), Z(() => {
3304
+ let x = !1;
3305
+ return S.current = (C) => {
3306
+ C === e.scope || x || (x = !0, C !== null && (Zt(T), fr(n)), k());
3307
+ }, () => {
3308
+ S.current = () => {
3309
+ };
3310
+ };
3311
+ }, [e, k, T, n]);
3312
+ const s = q(t.settingsCookie);
3313
+ Z(() => {
3314
+ s.current = t.settingsCookie;
3315
+ }, [t.settingsCookie]);
3316
+ const [h] = B(
3317
+ () => Bl(e.settings, (x) => {
3318
+ document.cookie = Vn(s.current, x, window.location.protocol === "https:");
3319
+ })
3320
+ ), g = Xe(e.scope, ta), R = Xe(e.scope, Ml), L = q(A);
3321
+ Z(() => {
3322
+ L.current = A;
3323
+ }, [A]);
3324
+ const O = Xe(
3325
+ e.scope,
3326
+ () => Lr({
3327
+ data: T.data,
3328
+ conflictLabels: () => ({ ours: L.current.conflictOurs, theirs: L.current.conflictTheirs }),
3329
+ onSaveSettled: (x, C) => {
3330
+ C.kind === "saved" && T.documents.refresh(x);
3331
+ const P = xr(L.current, C, ia(T.documents, x));
3332
+ P !== null && g.announce(P);
3333
+ },
3334
+ sideBySideSetting: {
3335
+ read: () => en(Ve(n).editPreview) === Gt,
3336
+ write: (x) => Qt(Ve(n).editPreview, x ? Gt : na)
3337
+ }
3338
+ })
3339
+ ), N = U(() => Ee(e.notices.catch(() => [])), [e.notices]), j = e.sources.map((x) => x.id).join(`
3340
+ `), I = U(() => Hn(t, j.split(`
3341
+ `)), [t, j]), X = q(f);
3342
+ Z(() => {
3343
+ X.current = f;
3344
+ }, [f]);
3345
+ const [Q] = B(() => (x, C) => {
3346
+ X.current?.(x, C);
3347
+ }), J = f === void 0 ? void 0 : Q, H = q(v);
3348
+ Z(() => {
3349
+ H.current = v;
3350
+ }, [v]);
3351
+ const [oe] = B(() => {
3352
+ let x = !1;
3353
+ return {
3354
+ convert: (C, P) => {
3355
+ const _ = H.current;
3356
+ return _ === void 0 ? Promise.resolve(ra) : _.convert(C, P);
3357
+ },
3358
+ prepare: () => {
3359
+ try {
3360
+ H.current?.prepare?.();
3361
+ } catch (C) {
3362
+ if (x) return;
3363
+ x = !0, console.error("[markdown-explorer] the draft converter's prepare threw", C);
3364
+ }
3365
+ }
3366
+ };
3367
+ }), w = v === void 0 ? void 0 : oe, E = U(
3368
+ () => ({
3369
+ config: I,
3370
+ labels: A,
3371
+ locale: m,
3372
+ theme: y,
3373
+ storageNamespace: n,
3374
+ scope: e.scope,
3375
+ sources: e.sources,
3376
+ notices: N,
3377
+ documents: T.documents,
3378
+ trees: T.trees,
3379
+ data: T.data,
3380
+ viewSettings: h,
3381
+ treeSettings: a,
3382
+ announcer: g,
3383
+ reveals: R,
3384
+ edits: O,
3385
+ onEditGrant: u,
3386
+ draftConverter: w,
3387
+ renderTreeFailure: d,
3388
+ reportMathDiagnostics: J
3389
+ }),
3390
+ [I, A, m, y, n, e.scope, e.sources, N, T, h, a, g, R, O, u, w, d, J]
3391
+ );
3392
+ return /* @__PURE__ */ c(on, { value: E, children: /* @__PURE__ */ c(aa, { renderFrame: l, lockDocumentScroll: p }, e.scope) });
3393
+ }, la = ({ ref: e, theme: t, view: n, children: r }) => {
3394
+ const [o] = B(Go);
3395
+ return /* @__PURE__ */ c("div", { ref: e, className: "aqmx-root", "data-aqmx-theme": t, "data-aqmx-view": n, "data-testid": "markdown-explorer", onKeyDownCapture: o.onKeyDownCapture, onKeyUpCapture: o.onKeyUpCapture, onBlurCapture: o.onBlurCapture, children: r });
3396
+ }, aa = ({ renderFrame: e, lockDocumentScroll: t }) => {
3397
+ const { theme: n, labels: r } = D(), o = nt(), { hash: i } = Wt(), l = Pe(), d = q(null);
3398
+ Ul(t, d), Z(() => {
3399
+ o.kind === "redirect" && l(`${o.href}${i}`, "browse");
3400
+ }, [o, i, l]);
3401
+ const { location: p } = o, f = p.view;
3402
+ Kl(d, f);
3403
+ const u = p.view === "tree" ? /* @__PURE__ */ c(we, { fallback: /* @__PURE__ */ c("section", { className: "aqmx-split-fallback", "aria-label": r.explorerRegion, "aria-busy": "true", "data-testid": "markdown-explorer-split-loading" }), children: /* @__PURE__ */ c(Wl, { location: p }) }) : p.view === "multi" ? /* @__PURE__ */ c(we, { fallback: /* @__PURE__ */ c("section", { className: "aqmx-stage-fallback", "aria-label": r.multiRegion, "aria-busy": "true", "data-testid": "markdown-explorer-stage-loading" }), children: /* @__PURE__ */ c(Xl, { location: p }) }) : /* @__PURE__ */ c(Tl, { location: p }), v = /* @__PURE__ */ F(la, { ref: d, theme: n, view: f, children: [
3404
+ u,
3405
+ /* @__PURE__ */ c(Fr, {}),
3406
+ /* @__PURE__ */ c(Cl, { holds: !0, testId: "markdown-explorer-announcer" })
3407
+ ] });
3408
+ return e === void 0 ? v : e({ view: f, children: v });
3409
+ }, ya = ({ currentUrl: e, nextUrl: t, formMethod: n, defaultShouldRevalidate: r }) => n === void 0 && e.href === t.href && r;
3410
+ export {
3411
+ Qe as A,
3412
+ ga as B,
3413
+ Sr as C,
3414
+ Rl as D,
3415
+ rl as E,
3416
+ ge as F,
3417
+ un as G,
3418
+ ji as H,
3419
+ Xo as I,
3420
+ ro as J,
3421
+ Ji as K,
3422
+ lo as L,
3423
+ no as M,
3424
+ nt as N,
3425
+ Cl as O,
3426
+ Sl as P,
3427
+ Ae as Q,
3428
+ mr as R,
3429
+ kt as S,
3430
+ wr as T,
3431
+ nn as U,
3432
+ hr as V,
3433
+ Et as W,
3434
+ Ea as X,
3435
+ yt as Y,
3436
+ ya as Z,
3437
+ Pe as a,
3438
+ yl as b,
3439
+ Bi as c,
3440
+ Rr as d,
3441
+ Tr as e,
3442
+ Xr as f,
3443
+ Cr as g,
3444
+ eo as h,
3445
+ Wr as i,
3446
+ se as j,
3447
+ de as k,
3448
+ to as l,
3449
+ Gr as m,
3450
+ Kr as n,
3451
+ Pr as o,
3452
+ il as p,
3453
+ wa as q,
3454
+ ba as r,
3455
+ rt as s,
3456
+ sl as t,
3457
+ D as u,
3458
+ Yr as v,
3459
+ al as w,
3460
+ Bt as x,
3461
+ ll as y,
3462
+ ke as z
3463
+ };