@aiquants/markdown-explorer 0.6.0 → 0.7.1

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