@aiquants/markdown-explorer 0.14.0 → 0.16.0

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