@aiquants/markdown-explorer 0.24.0 → 0.25.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 (35) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +25 -11
  3. package/dist/{EditSurface-CcWEczj3.js → EditSurface-Blymamic.js} +3 -3
  4. package/dist/{EditSurface-CRc4g0Qa.cjs → EditSurface-Co4Rvfa1.cjs} +1 -1
  5. package/dist/{ExplorerSplit-97SeIAOS.js → ExplorerSplit-BZ0PA3z3.js} +47 -47
  6. package/dist/{ExplorerSplit-ByxxXlgs.cjs → ExplorerSplit-WApgYMPb.cjs} +1 -1
  7. package/dist/{MultiLayout-CnbuAlxd.js → MultiLayout-B5-1N3JD.js} +3 -3
  8. package/dist/{MultiLayout-B_yMVDt_.cjs → MultiLayout-dAW_JCzg.cjs} +1 -1
  9. package/dist/{NativeScrollBar-BXdaM3EA.js → NativeScrollBar-BraWuZvN.js} +1 -1
  10. package/dist/{NativeScrollBar-D4a7fBOS.cjs → NativeScrollBar-ThVMbI0Y.cjs} +1 -1
  11. package/dist/{TreeLayout-C6QDpEBS.cjs → TreeLayout-C60lb9hP.cjs} +1 -1
  12. package/dist/{TreeLayout-BIQBKAkV.js → TreeLayout-CChoxh9W.js} +3 -3
  13. package/dist/core/labels.d.cts +3 -0
  14. package/dist/core/labels.d.ts +3 -0
  15. package/dist/core/textEncoding.d.cts +1 -0
  16. package/dist/core/textEncoding.d.ts +1 -0
  17. package/dist/index-B6FkGD-p.cjs +13 -0
  18. package/dist/{index-CeZDCyEl.js → index-Bd6hgisa.js} +546 -537
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +3 -3
  21. package/dist/location-D3DgoELB.cjs +1 -0
  22. package/dist/{location-gXXmC7CQ.js → location-DIxIjqs7.js} +147 -140
  23. package/dist/{merge-DqjUgcV_.js → merge-CgSp-0Dd.js} +1 -1
  24. package/dist/{merge-QLktbpZY.cjs → merge-DRWmjC24.cjs} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +785 -725
  27. package/dist/{useSplitPersistence-Bmpb2prR.cjs → useSplitPersistence-D-T75Hlh.cjs} +1 -1
  28. package/dist/{useSplitPersistence-BPNjvuJi.js → useSplitPersistence-Df63lnQZ.js} +1 -1
  29. package/docs/behavior/layout.md +7 -4
  30. package/docs/behavior/localization.md +6 -3
  31. package/docs/behavior/security.md +7 -3
  32. package/docs/behavior/url-contract.md +3 -3
  33. package/package.json +3 -3
  34. package/dist/index-BwTVYkTR.cjs +0 -13
  35. package/dist/location-CasigkBk.cjs +0 -1
@@ -1,13 +0,0 @@
1
- "use strict";const l=require("react/jsx-runtime"),i=require("react"),J=require("react-router"),V=require("./location-CasigkBk.cjs"),de=require("@aiquants/markdown/code-blocks"),D=require("./dataRoute-Cv7fgCW7.cjs"),ue=require("@aiquants/markdown"),Xe=require("@aiquants/markdown/source-lines"),Ye=require("@aiquants/spreadsheet/tsv"),St=require("@aiquants/spreadsheet/view"),br=require("@aiquants/markdown/viewer-settings"),Q=require("./storage-DM0EvkVf.cjs"),Sr=require("@aiquants/route-revalidation");function yr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const S=yr(i),Qe=Object.freeze(["en","ja"]),Xt="en",st=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Yt=Object.freeze(Object.keys(de.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),Qt=e=>Object.fromEntries(Yt.map(t=>[st(t),de.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),Jt=Object.freeze({panelMoved:Object.freeze(["title","column","position"]),panelMoveUnavailable:Object.freeze(["title","move"]),panelDragStarted:Object.freeze(["title"]),panelDragCancelled:Object.freeze(["title"]),multiColumnRegion:Object.freeze(["column"]),viewerSvgImageSourceRegion:Object.freeze(["name"]),...Object.fromEntries(Yt.filter(e=>de.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[st(e),de.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),kr=/\{(\w+)\}/gu,en={...Qt("en"),explorerRegion:"Explorer",sourceLabel:"Source",refreshTreeLabel:"Refresh tree",refreshTree:"Reload the tree and the open documents from the source",treeRefreshed:"Reloaded the tree from the source",treeRefreshFailed:e=>`Could not reload the tree: ${e}`,refreshDocumentLabel:"Refresh document",refreshDocument:"Reload the document from the source",refreshDocumentNamed:e=>`Refresh ${e}`,documentRefreshed:e=>`Reloaded ${e}`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",showSvgMarkup:"Show the image's SVG as written",showSpreadsheetMarkup:e=>`Show the table's ${e} as written`,showMarkupNamed:e=>`Source of ${e}`,editDocumentLabel:"Edit",editDocument:"Edit the document's Markdown (or double-click the document)",editDocumentNamed:e=>`Edit ${e}`,editDraftDocument:"Edit the document's Markdown without saving, to try it in the preview (or double-click the document)",editDraftDocumentNamed:e=>`Edit ${e} without saving`,editExternallyLabel:"Open in its editor",editExternally:"Open the document in its own editor, in a new tab",editExternallyNamed:e=>`Open ${e} in its editor`,editorRegion:e=>`Editing ${e}`,editorLabel:e=>`Markdown of ${e}`,editLoading:"Loading the source for editing…",editToolbar:"Editor",saveDraft:"Save",saveDraftTooltip:"Save the draft (Ctrl+S, or ⌘S on a Mac)",closeEditor:"Close editor",editView:"View",editViewNamed:e=>`View of ${e}`,editViewEditor:"Editor",editViewEditorTooltip:"Show the editor (Ctrl+E, or ⌘E on a Mac, switches with the preview)",editViewSplit:"Side by side",editViewSplitTooltip:"Show the editor and the preview side by side",editViewSplitResize:"Resize the editor and the preview",editViewPreview:"Preview",editViewPreviewTooltip:"Show the preview (Ctrl+E, or ⌘E on a Mac, switches with the editor)",historyOpen:"History",draftUnsaved:"Unsaved changes",draftStatus:"Draft, not saved",draftNotSaved:"This draft is not saved: the document cannot be saved here.",draftSaving:"Saving…",draftSaved:"Saved",draftSavedMerged:"Saved, merged with changes saved elsewhere",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`,draftSaveFailed:e=>`Could not save: ${e}`,documentSaved:e=>`Saved ${e}`,documentSavedMerged:e=>`Saved ${e}, merged with changes saved elsewhere`,conflictOurs:"your draft",conflictTheirs:"saved elsewhere",conflictUseOurs:"Use my lines",conflictUseTheirs:"Use the saved lines",conflictKeepBoth:"Keep both",conflictNext:"Next conflict",editGrantTitle:"Editing needs your permission",editGrantBody:"Allow this site to change documents on your behalf. You are asked once; signing out asks again.",editGrantAction:"Grant permission",editGrantRetry:"Try again",unsavedTitle:"Discard unsaved changes?",unsavedBody:e=>`${e} has changes that are not saved.`,unsavedDiscard:"Discard changes",draftDiscardTitle:"Discard the draft?",draftDiscardBody:e=>`The changes to ${e} are not saved anywhere and will be lost.`,unsavedStay:"Keep editing",historyTitle:e=>`Revisions of ${e}`,historyLoading:"Loading the revisions…",historyEmpty:"No revisions are kept for this document.",historyCurrent:"Current",historyKept:"Kept",historyEntry:(e,t)=>t===""?e:`${e} by ${t}`,historyRestore:"Put into the draft",historyClose:"Close",historyRestored:e=>`Put the revision into the draft of ${e}; save to keep it`,previewRegion:"Preview",previewUpdating:"Updating the preview…",previewFailed:e=>`Could not preview: ${e}`,previewTablePending:"This table can be edited once the preview shows the draft.",expandAll:"Expand all folders",collapseAll:"Collapse all folders",treeSettings:"Tree settings",switchToMulti:"Open in the multi-panel view",switchToTree:"Open in the tree view",resizeExplorer:"Resize the explorer",showExplorer:"Show the explorer",hideExplorer:"Close the explorer",treeRegion:"Documents",treeLoading:"Loading the tree…",treeEmptyTitle:"Nothing to show",treeEmptyBody:"This source has no documents you can open.",folderLoadFailed:"This folder could not be loaded.",loopFolderName:e=>`${e} (already open above)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("en",{type:"conjunction"}).format(e)} could not be loaded`,foldersLoading:e=>e===1?"Loading 1 folder…":`Loading ${String(e)} folders…`,expandAllStarted:"Opening all folders…",expandAllProgress:(e,t)=>`Opening all folders (${String(e)} opened, ${String(t)} loading)…`,expandAllDone:(e,t,n)=>{const r=`Opened ${String(e)} ${e===1?"folder":"folders"}`;return t>0?`${r}; ${String(t)} could not be loaded`:n?e===0?"All folders are already open":`${r}; every folder is open`:r},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`,expandAllDepthLimit:(e,t)=>`Opened ${String(e)} ${e===1?"folder":"folders"}; folders more than ${String(t)} ${t===1?"level":"levels"} deep stay closed`,treeEntryKindDirectory:"directory",treeEntryKindFile:"file",treeScrollUp:"Scroll up",treeScrollDown:"Scroll down",treeScrollToTop:"Top",treeScrollToBottom:"Bottom",selectionTitle:e=>`Selected (${String(e)})`,clearSelection:"Clear the selection",openSelectionInMulti:e=>`Open ${String(e)} in panels`,removeFromSelection:e=>`Remove ${e} from the selection`,settingSortMode:"Sort order",sortNative:"Source order",sortAscending:"Name A→Z",sortDescending:"Name Z→A",sortOldest:"Modified old→new",sortNewest:"Modified new→old",settingFolderPlacement:"Folders",folderPlacementMixed:"Mixed",folderPlacementFirst:"First",folderPlacementLast:"Last",settingReadmePlacement:"README",readmePlacementMixed:"Mixed",readmePlacementFirst:"First",readmePlacementLast:"Last",settingSelectionMode:"Selection",selectionSingle:"Single",selectionMultiple:"Multiple",selectionNone:"Off",settingDoubleClick:"Double-click",doubleClickRecursive:"Expand all levels",doubleClickToggle:"Toggle",settingExpandIconSize:"Expander size",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"Always expanded",settingRevealDocument:"Reveal the open document",settingRemoveRootIndent:"No root indent",settingTreeLines:"Tree lines",settingExpandIcons:"Expanders",settingDirectoryIcons:"Folder icons",settingFileIcons:"File icons",settingOn:"On",settingOff:"Off",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"Document",documentEmpty:"Select a document in the explorer.",folderReadmeMissing:e=>`${e} has no README.`,documentLoading:"Loading the document…",markupLoading:"Loading the source…",spreadsheetLoading:"Loading the table…",documentShown:e=>`Showing ${e}`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[.!?]$/u.test(t)?t:`${t}.`).join(" "),textTruncated:"Only the beginning of this file is shown.",inertLink:"This link points outside the source and cannot be opened.",failureUnauthorizedTitle:"Your session has expired",failureUnauthorizedBody:"Reload the page to sign in again.",failureForbiddenTitle:"Access denied",failureForbiddenBody:"You do not have permission to open this.",failureNotFoundTitle:"Not found",failureNotFoundBody:"It may have been moved or deleted.",failureNotConfiguredTitle:"This source is not set up",failureNotConfiguredBody:"Ask your administrator to configure it.",failureInvalidTitle:"Invalid address",failureInvalidBody:"The document path in this address cannot be used.",failureTooLargeTitle:"Too large to display",failureTooLargeBody:"This file exceeds the size that can be displayed.",failureUnsupportedTitle:"Cannot be displayed",failureUnsupportedBody:"This type of file cannot be shown here.",failureFailedTitle:"Something went wrong",failureFailedBody:"Try again in a moment.",retry:"Try again",reloadPage:"Reload the page",imageZoomIn:"Zoom in",imageZoomOut:"Zoom out",imageFit:"Fit to the view",imageFitLevel:"Fit",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"Open in a new tab",download:"Download",copyText:"Copy the text",copiedText:"Copied the text",copyTextFailed:"Could not copy the text",mediaUnsupported:"Your browser cannot play this file.",fileNotShown:"This file cannot be shown here. Download it to open it.",pdfNotShown:"This browser does not show PDF files inside the page. Open it in a new tab or download it.",spreadsheetFirstSheetOnly:"Only the first sheet of this spreadsheet is shown.",spreadsheetTruncated:"The table shows only part of this file. Download it to open the whole file.",spreadsheetUnreadableEncoding:([e,t])=>t===void 0?`This file's text is not ${e}, so it cannot be shown as a table. Download it to open it.`:`This file's text is neither ${e} nor ${t}, so it cannot be shown as a table. Download it to open it.`,spreadsheetEmpty:"This file has no data.",spreadsheetNotText:"This file is not text, so it cannot be shown as a table. Download it to open it.",spreadsheetLongRow:"No row of this file ends within the part read for the preview, so it cannot be shown as a table. Download it to open it.",spreadsheetFullscreen:e=>`${e} (full screen)`,viewerLoading:"Loading data...",viewerErrorPrefix:"Error: ",viewerStyleTitle:"Display Style",viewerSelectStyle:"Select display style",viewerPinStyle:"Pin style selector",viewerUnpinStyle:"Unpin style selector",viewerErrorTitle:"An error occurred",viewerMissingImage:"Image not found",viewerOpenToc:"Open table of contents",viewerTocTitle:"Table of contents",viewerPinToc:"Pin table of contents",viewerUnpinToc:"Unpin table of contents",viewerSelectAlign:"Select alignment",viewerAlignTitle:"Alignment",viewerPinAlign:"Pin alignment selector",viewerUnpinAlign:"Unpin alignment selector",viewerAlignLeft:"Align left",viewerAlignCenter:"Align center",viewerAlignRight:"Align right",viewerMermaidInteractionMode:"Mouse interaction mode",viewerMermaidInteractionModeTouch:"Touch interaction mode",viewerMermaidModeNone:"No interaction",viewerMermaidModeZoom:"Zoom only",viewerMermaidModePan:"Pan only (drag)",viewerMermaidModePanShift:"Pan only (Shift+drag)",viewerMermaidModeBoth:"Zoom and pan (drag)",viewerMermaidModeBothShift:"Zoom and pan (Shift+drag)",viewerMermaidModeNoneTouch:"No interaction (a finger scrolls the page)",viewerMermaidModeZoomTouch:"Zoom only (two fingers)",viewerMermaidModePanTouch:"Pan only (one-finger drag while the diagram overflows)",viewerMermaidModeBothTouch:"Zoom and pan (two fingers, one finger while the diagram overflows)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidPanUp:"Pan Up",viewerMermaidPanDown:"Pan Down",viewerMermaidPanLeft:"Pan Left",viewerMermaidPanRight:"Pan Right",viewerMermaidDiagram:"Diagram (arrow keys pan, + and - zoom, 0 resets)",viewerMermaidRetry:"Try again",viewerEmbeddedVideo:"embedded video",viewerEmbeddedPost:"embedded post",viewerEmbeddedFrame:"Embedded content",viewerBlockFailed:"This block could not be shown.",viewerSvgImageToolbar:"SVG image",viewerSvgImageSource:"Source",viewerSvgImageSourceRegion:"Source of {name}",viewerSvgImageLoading:"Loading the source…",viewerSvgImageFailed:"The source could not be read.",viewerSvgImageRetry:"Try again",viewerSvgImageTruncated:"Only the beginning of this file is shown.",viewerSvgImageCopy:"Copy the source",viewerSvgImageCopied:"Copied the source.",viewerSvgImageCopyFailed:"Could not copy the source.",multiRegion:"Panels",multiEmpty:"Select documents in the explorer to open them side by side.",panelLimit:e=>`You can open up to ${String(e)} panels at once.`,panelOpened:e=>`Opened ${e}`,panelClosed:e=>`Closed ${e}`,panelAlreadyOpen:e=>`${e} is already open`,panelHidden:e=>`Hid ${e}`,panelShown:e=>`Showed ${e}`,panelMaximized:e=>`Maximized ${e}`,panelRestored:e=>`Restored ${e} to its size`,panelHide:"Hide the panel",panelMaximize:"Maximize the panel",panelRestore:"Restore the panel to its size",panelClose:"Close the panel",panelSwitchToCustomDrag:"Switch to the custom drag mode",panelSwitchToNormalDrag:"Back to the normal drag mode",panelCustomDragBadge:"Custom",panelMove:"Move the panel",panelMovePreviousColumn:"Move to the previous column",panelMoveNextColumn:"Move to the next column",panelMoveUp:"Move up",panelMoveDown:"Move down",panelMoved:"Moved {title} to column {column}, position {position}",panelMoveUnavailable:"{move} is not available for {title}",panelDragStarted:"Picked up {title}",panelDragCancelled:"Kept {title} where it was",hiddenPanelsTitle:"Hidden panels:",hiddenPanelBadge:"Hidden",hiddenPanelNotice:"This panel is hidden",multiColumnEmpty:"This column is empty",multiColumnRegion:"Column {column}",panelDropHere:"Drop the panel here"},Rr={...Qt("ja"),explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showSvgMarkup:"画像の SVG を書いたまま表示",showSpreadsheetMarkup:e=>`表の ${e} を書いたまま表示`,showMarkupNamed:e=>`${e} のソース`,editDocumentLabel:"編集",editDocument:"文書の Markdown を編集 (文書のダブルクリックでも)",editDocumentNamed:e=>`${e} を編集`,editDraftDocument:"文書の Markdown を保存せずに編集し、プレビューで確かめる (文書のダブルクリックでも)",editDraftDocumentNamed:e=>`${e} を保存せずに編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",editView:"表示",editViewNamed:e=>`${e} の表示`,editViewEditor:"エディタ",editViewEditorTooltip:"エディタを表示 (Ctrl+E、Mac は ⌘E でプレビューと切り替え)",editViewSplit:"並べて表示",editViewSplitTooltip:"エディタとプレビューを並べて表示",editViewSplitResize:"エディタとプレビューの割合を変更",editViewPreview:"プレビュー",editViewPreviewTooltip:"プレビューを表示 (Ctrl+E、Mac は ⌘E でエディタと切り替え)",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftStatus:"保存しない下書き",draftNotSaved:"この下書きは保存しません。ここでは文書を保存できません。",draftSaving:"保存中…",draftSaved:"保存しました",draftSavedMerged:"ほかで保存された変更と統合して保存しました",draftConflicts:e=>`ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,draftSaveFailed:e=>`保存できませんでした: ${e}`,documentSaved:e=>`${e} を保存しました`,documentSavedMerged:e=>`${e} を、ほかで保存された変更と統合して保存しました`,conflictOurs:"あなたの下書き",conflictTheirs:"ほかで保存された版",conflictUseOurs:"自分の行を使う",conflictUseTheirs:"保存された行を使う",conflictKeepBoth:"両方を残す",conflictNext:"次の衝突へ",editGrantTitle:"編集には許可が必要です",editGrantBody:"このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",editGrantAction:"許可する",editGrantRetry:"もう一度試す",unsavedTitle:"保存していない変更を破棄しますか?",unsavedBody:e=>`${e} に保存していない変更があります。`,unsavedDiscard:"変更を破棄",draftDiscardTitle:"下書きを破棄しますか?",draftDiscardBody:e=>`${e} への変更はどこにも保存されず、失われます。`,unsavedStay:"編集を続ける",historyTitle:e=>`${e} の版`,historyLoading:"版の一覧を読み込み中…",historyEmpty:"この文書の版は残っていません。",historyCurrent:"現在の版",historyKept:"保持",historyEntry:(e,t)=>t===""?e:`${e} (${t})`,historyRestore:"下書きに戻す",historyClose:"閉じる",historyRestored:e=>`${e} の下書きに版を戻しました。残すには保存してください`,previewRegion:"プレビュー",previewUpdating:"プレビューを更新中…",previewFailed:e=>`プレビューできませんでした: ${e}`,previewTablePending:"プレビューが下書きを描くと、この表を編集できます。",expandAll:"すべてのフォルダーを展開",collapseAll:"すべてのフォルダーを折りたたむ",treeSettings:"ツリーの設定",switchToMulti:"マルチビューで開く",switchToTree:"ツリービューで開く",resizeExplorer:"エクスプローラーの幅を変更",showExplorer:"エクスプローラーを開く",hideExplorer:"エクスプローラーを閉じる",treeRegion:"文書の一覧",treeLoading:"ツリーを読み込み中…",treeEmptyTitle:"表示できるファイルがありません",treeEmptyBody:"このソースには開ける文書がありません。",folderLoadFailed:"このフォルダーを読み込めませんでした。",loopFolderName:e=>`${e} (上の階層で開いています)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("ja",{type:"conjunction"}).format(e)} を読み込めませんでした`,foldersLoading:e=>`フォルダーを ${String(e)} 件読み込み中…`,expandAllStarted:"すべてのフォルダーを展開しています…",expandAllProgress:(e,t)=>`すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,expandAllDone:(e,t,n)=>{const r=`${String(e)} 件のフォルダーを展開しました`;return t>0?`${r}。うち ${String(t)} 件は読み込めませんでした`:n?e===0?"すべてのフォルダーが既に開いています":`${r}。すべてのフォルダーが開いています`:r},expandAllFolderLimit:(e,t,n)=>`${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,expandAllDepthLimit:(e,t)=>`${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,treeEntryKindDirectory:"ディレクトリ",treeEntryKindFile:"ファイル",treeScrollUp:"上へスクロール",treeScrollDown:"下へスクロール",treeScrollToTop:"先頭へ",treeScrollToBottom:"末尾へ",selectionTitle:e=>`選択中 (${String(e)})`,clearSelection:"選択を解除",openSelectionInMulti:e=>`${String(e)} 件をパネルで開く`,removeFromSelection:e=>`${e} を選択から外す`,settingSortMode:"並び順",sortNative:"取得順",sortAscending:"名前の昇順",sortDescending:"名前の降順",sortOldest:"更新日時の昇順 (古い順)",sortNewest:"更新日時の降順 (新しい順)",settingFolderPlacement:"フォルダーの位置",folderPlacementMixed:"混ぜる",folderPlacementFirst:"先に",folderPlacementLast:"後に",settingReadmePlacement:"README の位置",readmePlacementMixed:"混ぜる",readmePlacementFirst:"先に",readmePlacementLast:"後に",settingSelectionMode:"選択",selectionSingle:"1 件",selectionMultiple:"複数",selectionNone:"オフ",settingDoubleClick:"ダブルクリック",doubleClickRecursive:"下の階層まで展開",doubleClickToggle:"開閉",settingExpandIconSize:"展開アイコンの大きさ",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"常に展開",settingRevealDocument:"開いた文書をツリーで表示",settingRemoveRootIndent:"最上位の字下げなし",settingTreeLines:"ツリーの線",settingExpandIcons:"展開アイコン",settingDirectoryIcons:"フォルダーのアイコン",settingFileIcons:"ファイルのアイコン",settingOn:"オン",settingOff:"オフ",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"文書",documentEmpty:"エクスプローラーで文書を選んでください。",folderReadmeMissing:e=>`${e} には README がありません。`,documentLoading:"文書を読み込み中…",markupLoading:"ソースを読み込み中…",spreadsheetLoading:"表を読み込み中…",documentShown:e=>`${e} を表示しています`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[。!?]$/u.test(t)?t:`${t}。`).join(""),textTruncated:"このファイルは先頭だけを表示しています。",inertLink:"リンク先がソースの外にあるため開けません。",failureUnauthorizedTitle:"セッションの有効期限が切れました",failureUnauthorizedBody:"ページを再読み込みして、もう一度サインインしてください。",failureForbiddenTitle:"アクセスが許可されていません",failureForbiddenBody:"これを開く権限がありません。",failureNotFoundTitle:"見つかりません",failureNotFoundBody:"移動または削除された可能性があります。",failureNotConfiguredTitle:"このソースは設定されていません",failureNotConfiguredBody:"管理者に設定を依頼してください。",failureInvalidTitle:"アドレスが正しくありません",failureInvalidBody:"このアドレスに含まれる文書の経路は使えません。",failureTooLargeTitle:"大きすぎて表示できません",failureTooLargeBody:"このファイルは表示できる大きさを超えています。",failureUnsupportedTitle:"表示できない形式です",failureUnsupportedBody:"この種類のファイルはここでは表示できません。",failureFailedTitle:"読み込みに失敗しました",failureFailedBody:"しばらくしてからもう一度お試しください。",retry:"再試行",reloadPage:"ページを再読み込み",imageZoomIn:"拡大",imageZoomOut:"縮小",imageFit:"画面に合わせる",imageFitLevel:"全体",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"新しいタブで開く",download:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",mediaUnsupported:"このブラウザではこのファイルを再生できません。",fileNotShown:"このファイルはここでは表示できません。ダウンロードして開いてください。",pdfNotShown:"このブラウザはページの中に PDF を表示しません。新しいタブで開くか、ダウンロードしてください。",spreadsheetFirstSheetOnly:"このスプレッドシートは最初のシートだけを表示しています。",spreadsheetTruncated:"表はこのファイルの一部だけを表示しています。全体はダウンロードして開いてください。",spreadsheetUnreadableEncoding:([e,t])=>t===void 0?`このファイルの文字は ${e} ではないため、表として表示できません。ダウンロードして開いてください。`:`このファイルの文字は ${e} でも ${t} でもないため、表として表示できません。ダウンロードして開いてください。`,spreadsheetEmpty:"このファイルにはデータがありません。",spreadsheetNotText:"このファイルは文字のファイルではないため、表として表示できません。ダウンロードして開いてください。",spreadsheetLongRow:"プレビューに読む範囲の中でこのファイルの行が 1 つも終わらないため、表として表示できません。ダウンロードして開いてください。",spreadsheetFullscreen:e=>`${e} (全画面)`,viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidInteractionModeTouch:"タッチ操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidModeNoneTouch:"操作なし (指はページをスクロール)",viewerMermaidModeZoomTouch:"拡大縮小のみ (2 本指)",viewerMermaidModePanTouch:"移動のみ (はみ出す図を 1 本指でドラッグ)",viewerMermaidModeBothTouch:"拡大縮小+移動 (2 本指・はみ出す図は 1 本指)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidPanUp:"上へ移動",viewerMermaidPanDown:"下へ移動",viewerMermaidPanLeft:"左へ移動",viewerMermaidPanRight:"右へ移動",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",multiRegion:"パネル",multiEmpty:"エクスプローラーで文書を選ぶと、ここに並べて開きます。",panelLimit:e=>`同時に開けるのは ${String(e)} パネルまでです。`,panelOpened:e=>`${e} を開きました`,panelClosed:e=>`${e} を閉じました`,panelAlreadyOpen:e=>`${e} は既に開いています`,panelHidden:e=>`${e} を隠しました`,panelShown:e=>`${e} を表示しました`,panelMaximized:e=>`${e} を最大化しました`,panelRestored:e=>`${e} を元のサイズに戻しました`,panelHide:"パネルを隠す",panelMaximize:"パネルを最大化",panelRestore:"パネルを元のサイズに戻す",panelClose:"パネルを閉じる",panelSwitchToCustomDrag:"カスタムのドラッグの方式に切り替え",panelSwitchToNormalDrag:"通常のドラッグの方式に戻す",panelCustomDragBadge:"カスタム",panelMove:"パネルを移動",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},tn=Object.freeze({en:Object.freeze(en),ja:Object.freeze(Rr)}),at=Object.freeze(Object.keys(en)),Tr=new Set(at),Or=e=>Tr.has(e),Le=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,nn=e=>{if(e===void 0)return Xt;if(Qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Le(e)}`)},Je=(e,t)=>{const n=tn[nn(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Le(t)}`);if(!V.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Le(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Or(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${at.join(", ")}`);const a=r[s];if(a===void 0)continue;const d=typeof n[s];if(typeof a!==d)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${d}; got ${Le(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=Jt[s];if(typeof a=="string"&&m!==void 0){for(const[,w]of a.matchAll(kr))if(!m.includes(w??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(w)}}; it accepts ${m.map(c=>`{${c}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Lr=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(a=>Object.hasOwn(n,a)&&Object.is(n[a],r[a]))},et=Object.freeze(["light","dark"]),Cr=e=>{if(e===void 0)return"light";if(et.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${et.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},rn=i.createContext(null),I=()=>{const e=i.use(rn);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ge=e=>{const{viewSettings:t}=I(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},Pe=()=>{const{config:e}=I(),t=J.useParams()["*"],[n]=J.useSearchParams(),r=n.toString();return i.useMemo(()=>V.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},on={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},te=(e,t)=>e[on[t][0]],fe=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=I(),s=te(o,e.reason),a=o[on[e.reason][1]],d=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("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:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Ar=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"draft":return e.draftStatus;case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Mr=(e,t,n)=>{switch(t.kind){case"draft":return e.draftNotSaved;case"saved":return t.merged?e.documentSavedMerged(n):e.documentSaved(n);case"conflicts":return e.draftConflicts(t.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,t.failure.reason));case"idle":case"saving":return null}},me=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},sn="<<<<<<<",an="=======",ln=">>>>>>>",yt=(e,t)=>e===t||e.startsWith(`${t} `),kt=e=>cn(e.split(`
2
- `)),cn=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const a=s.charCodeAt(0);a!==60&&a!==61&&a!==62||(yt(s,sn)?(n=o,r=null):s===an?n!==null&&r===null?r=o:n=null:yt(s,ln)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Rt=e=>e.includes(`\r
3
- `)?`\r
4
- `:`
5
- `,$e=e=>e.replace(/\r\n?/gu,`
6
- `),jr=(e,t)=>t===`
7
- `?e:e.replaceAll(`
8
- `,`\r
9
- `),Nr=3,Pr=/^\d+(?:\.\d+)?$/u,Dr=e=>{if(e===null||!Pr.test(e))return null;const t=Number(e);return t>=V.EDIT_SPLIT_MIN_PERCENT&&t<=V.EDIT_SPLIT_MAX_PERCENT?t:null},Be=Object.freeze({kind:"idle"}),Tt=Object.freeze({kind:"draft"}),_r=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,d=new Map,m=new Map,w=new Map,c=me();let f=null,g=null,v=null;const x=(u,h)=>{u.value={...u.value,...h},c.emit()},R=(u,h)=>s.get(u)===h,O=async(u,h)=>{h.controller.abort(),h.controller=new AbortController;const{signal:k}=h.controller;x(h,{phase:{kind:"opening"}});const A=await e.edit(u,k);if(!R(u,h)||k.aborted||!("kind"in A))return;if(A.kind==="grant"){x(h,{phase:{kind:"grant",href:A.href}});return}if(A.kind==="failure"){x(h,{phase:{kind:"failed",failure:A.failure}});return}const F=$e(A.text),q=A.kind==="draft";h.base={text:F,version:q?null:A.version},h.draft=F,h.ending=Rt(A.text),x(h,{phase:{kind:"editing"},history:q?!1:A.history,dirty:!1,save:q?Tt:Be,generation:h.value.generation+1})},j=u=>{const h=s.get(u);h!==void 0&&(h.controller.abort(),s.delete(u),d.delete(u))},N=(u,h,k)=>(u.set(h,k),()=>{u.get(h)===k&&u.delete(h)}),$=(u,h,k,A={})=>{x(h,{...A,save:k}),n(u,k)},P=async u=>{m.get(u)?.flush();const h=s.get(u);if(h===void 0||h.value.phase.kind!=="editing"||h.base===null||h.value.save.kind==="saving")return;const{version:k}=h.base;if(k===null){n(u,Tt);return}const A=kt(h.draft).length;if(A>0){$(u,h,{kind:"conflicts",count:A});return}h.controller.abort(),h.controller=new AbortController;const{signal:F}=h.controller;let q={text:h.base.text,version:k},E=h.draft,T=!1;x(h,{save:{kind:"saving"}});for(let M=0;M<Nr;M+=1){const L=await e.save(u,q.version,jr(E,h.ending),F);if(!R(u,h)||F.aborted||!("kind"in L))return;if(L.kind==="saved"){m.get(u)?.flush(),h.base={text:E,version:L.version},$(u,h,{kind:"saved",merged:T},{dirty:h.draft!==E});return}if(L.kind==="grant"){$(u,h,{kind:"grant",href:L.href});return}if(L.kind==="failure"){$(u,h,{kind:"failed",failure:L.failure});return}const{mergeDraft:_}=await Promise.resolve().then(()=>require("./merge-QLktbpZY.cjs"));if(!R(u,h)||F.aborted)return;const B=m.get(u);B?.flush();const K=$e(L.text),p=_(q.text,h.draft,K,t());if(q={text:K,version:L.version},h.base=q,h.ending=Rt(L.text),h.draft=p.text,B?.adopt(p.text),p.kind==="conflicts"){$(u,h,{kind:"conflicts",count:p.conflicts},{dirty:!0,generation:h.value.generation+1});return}if(T=!0,E=p.text,E===q.text){$(u,h,{kind:"saved",merged:T},{dirty:!1,generation:h.value.generation+1});return}x(h,{dirty:!0,generation:h.value.generation+1})}$(u,h,{kind:"failed",failure:{reason:"failed"}})};return{session:u=>s.get(u)?.value,subscribe:c.subscribe,start:(u,h)=>{const k=s.get(u);if(k!==void 0){x(k,{request:{anchor:h},view:"editor"}),(k.value.phase.kind==="failed"||k.value.phase.kind==="grant")&&O(u,k);return}a.delete(u);const A={value:{path:u,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:Be,generation:0,request:{anchor:h}},base:null,draft:"",ending:`
10
- `,controller:new AbortController};s.set(u,A),O(u,A)},retry:u=>{const h=s.get(u);h===void 0||h.value.phase.kind==="editing"||O(u,h)},draft:u=>{const h=s.get(u);return h===void 0||h.base===null?null:h.draft},setDraft:(u,h)=>{const k=s.get(u);if(k===void 0||k.base===null)return;k.draft=h;const A={},F=h!==k.base.text;F!==k.value.dirty&&(A.dirty=F);const{save:q}=k.value;if(q.kind==="conflicts"){const E=kt(h).length;E===0?A.save=Be:E!==q.count&&(A.save={kind:"conflicts",count:E})}(A.dirty!==void 0||A.save!==void 0)&&x(k,A)},consumeRequest:u=>{const h=s.get(u);h!==void 0&&h.value.request!==null&&x(h,{request:null})},save:P,replaceDraft:(u,h)=>{const k=m.get(u);k?.flush();const A=s.get(u);if(A===void 0||A.base===null)return;const F=$e(h);A.draft=F,k?.adopt(F),x(A,{dirty:F!==A.base.text,generation:A.value.generation+1})},close:u=>{if(!s.has(u))return;const h=m.get(u),k=h===void 0?null:h.returnPoint();j(u),k===null?a.delete(u):a.set(u,k),c.emit()},takeReturn:u=>{const h=a.get(u)??null;return a.delete(u),h},dirtyPaths:()=>[...s.values()].filter(u=>u.value.dirty).map(u=>u.value.path),discard:u=>{for(const h of u)j(h);u.length>0&&c.emit()},editorState:{get:u=>d.get(u),set:(u,h)=>{s.has(u)&&d.set(u,h)}},bindEditor:(u,h)=>N(m,u,h),bindView:(u,h)=>N(w,u,h),viewAnchor:u=>{const h=w.get(u);return h===void 0?null:h.anchor()},flush:u=>m.get(u)?.flush(),flushDrafts:()=>{for(const u of m.values())u.flush()},nextConflict:u=>m.get(u)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:u=>{for(const h of m.values())h.flush();return u.filter(h=>s.get(h)?.value.dirty===!0)},askToDiscard:u=>new Promise(h=>{v?.settle(!1);const k={paths:u,settle:A=>{if(v===k){if(v=null,A)for(const F of u)j(F);c.emit(),h(A)}}};v=k,c.emit()}),discardRequest:()=>v,sideBySide:()=>(f??=r.read(),f),setSideBySide:u=>{f!==u&&(f=u,r.write(u),c.emit())},editorShare:()=>(g??=o.read()??V.EDIT_SPLIT_DEFAULT_PERCENT,g),setEditorShare:u=>{if(!Number.isFinite(u))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(u)}`);const h=Math.min(V.EDIT_SPLIT_MAX_PERCENT,Math.max(V.EDIT_SPLIT_MIN_PERCENT,u));g!==h&&(g=h,o.write(h))},setView:(u,h)=>{const k=s.get(u);k===void 0||k.value.view===h||(m.get(u)?.beforeView(h),x(k,{view:h,previewPrepared:k.value.previewPrepared||h==="preview"}))},preparePreview:u=>{const h=s.get(u);h!==void 0&&!h.value.previewPrepared&&x(h,{previewPrepared:!0})}}},lt=e=>{e.preventDefault(),e.stopPropagation()},dn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,un="data-aqmx-content-pane",Ae=Object.freeze({[un]:""}),Fr="--aqmx-dialog-left",Ir="--aqmx-dialog-top",qr='[data-testid="markdown-explorer"]',$r=e=>{const t=e.closest(qr)?.querySelectorAll(`[${un}]`),n=t?.item(t.length-1);if(!(n instanceof HTMLElement))throw new Error("[markdown-explorer] a dialog opened where the explorer marks no content pane");return n},Br=e=>{const t=dn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=$r(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=V.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(Fr,`${String(s)}px`),e.style.setProperty(Ir,`${String(a)}px`),n},Hr=e=>e.preventDefault(),fn=({open:e,onOpen:t,onDismiss:n})=>{const r=i.useRef(null),o=i.useRef(null),s=i.useRef(!1),a=i.useRef(t);i.useLayoutEffect(()=>{a.current=t},[t]),i.useLayoutEffect(()=>{s.current=e;const c=r.current;if(c!==null)if(e&&!c.open){const f=c.ownerDocument.activeElement;o.current=f instanceof HTMLElement?f:null,c.showModal(),a.current?.()}else!e&&c.open&&(c.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),i.useLayoutEffect(()=>{const c=r.current;if(!e||c===null)return;const f=new ResizeObserver(()=>v());let g=null;const v=()=>{const R=Br(c);R===null||R===g||(g!==null&&f.unobserve(g),f.observe(R),g=R)};v(),f.observe(c);const x=c.ownerDocument.defaultView;return x?.addEventListener("resize",v),c.ownerDocument.addEventListener("scroll",v,{capture:!0,passive:!0}),()=>{f.disconnect(),x?.removeEventListener("resize",v),c.ownerDocument.removeEventListener("scroll",v,{capture:!0})}},[e]);const d=i.useCallback(c=>{c.key!=="Escape"||c.defaultPrevented||(lt(c),n())},[n]),m=i.useCallback(c=>{c.target===c.currentTarget&&n()},[n]),w=i.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:d,onClick:m,onCancel:Hr,onClose:w}},mn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:d})=>{const m=i.useRef(null),w=i.useId(),c=i.useId(),f=i.useCallback(()=>m.current?.focus(),[]),g=fn({open:e,onOpen:f,onDismiss:a});return l.jsx("dialog",{...g,className:"aqmx-confirm","aria-labelledby":w,"aria-describedby":c,"data-testid":d,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:w,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:c,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${d}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${d}-confirm`,onClick:s,children:r})]})]})})},we=e=>{const t=e;return t.status===void 0&&(t.status="pending",e.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n})),t},hn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),he=e=>e.status==="fulfilled"?e.value:void 0,pn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),Ur=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),Vr=(e,t,n)=>{const r=new Set,o=[...e].reverse();for(let s=o.pop();s!==void 0;s=o.pop()){if(s.type!=="directory"||r.has(s.path))continue;r.add(s.path);const a=s.lazy===!0?n(s.path):void 0,d=s.lazy===!0?a?.status==="loaded"?a.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return d;if(d!==null)for(const m of[...d].reverse())o.push(m)}return null},gn=(e,t,n)=>{const r=he(e.read(t));if(r===void 0||r.status==="deferred")return pn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=Vr(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:V.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?Ur:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:V.folderReadmeOf(s.entries)},claim:!0}},zr=(e,t,n)=>{const{readme:r}=gn(e,t,n);return r.status==="ok"?r.readme:null},Zr=(e,t,n)=>{const r=J.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=V.resolveExplorerLocation(e,r.params["*"],new URLSearchParams(t.search));switch(o.view){case"tree":{const s=o.folder===null?o.doc:n(o.source,o.folder);return new Set(s===null?[]:[s])}case"single":return new Set([o.doc]);case"multi":return new Set(o.docs)}},wn=e=>{const{edits:t}=I(),n=i.useCallback(()=>t.session(e),[t,e]);return i.useSyncExternalStore(t.subscribe,n,Gr)},vn=()=>!1,Gr=()=>{},Kr=()=>{const{edits:e}=I();return i.useSyncExternalStore(e.subscribe,e.hasSessions,vn)},En=()=>{const{edits:e}=I();return i.useSyncExternalStore(e.subscribe,e.sideBySide,vn)},Wr=()=>null,Xr=()=>{const{edits:e,labels:t,config:n,trees:r}=I(),o=i.useRef([]),s=i.useCallback(({nextLocation:v})=>{const x=Zr(n,v,(R,O)=>zr(r,R,O));return e.flushDrafts(),o.current=e.dirtyPaths().filter(R=>!x.has(R)),o.current.length>0},[e,n,r]),a=J.useBlocker(s),d=Kr();i.useEffect(()=>{if(!d)return;const v=x=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(x.preventDefault(),x.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[d,e]);const m=i.useSyncExternalStore(e.subscribe,e.discardRequest,Wr),w=a.state==="blocked",c=w?o.current:m===null?[]:m.paths,f=c.map(v=>D.lastPathSegment(v)).join(", "),g=c.length>0&&c.every(v=>e.session(v)?.save.kind==="draft");return l.jsx(mn,{open:w||m!==null,title:g?t.draftDiscardTitle:t.unsavedTitle,body:g?t.draftDiscardBody(f):t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(a.state==="blocked"){e.discard(o.current),a.proceed();return}m?.settle(!0)},onCancel:()=>{if(a.state==="blocked"){a.reset();return}m?.settle(!1)}})};function Yr({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Qr=S.forwardRef(Yr);let He=null;const xn=()=>(He??=Promise.resolve().then(()=>require("./EditSurface-CRc4g0Qa.cjs")).catch(e=>{throw He=null,e}),He),Jr=()=>{xn().catch(()=>{})},eo=e=>{const{default:t}=i.use(xn());return l.jsx(t,{...e})};class to extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}retry=()=>this.setState({failed:!1});render(){return this.state.failed?this.props.fallback(this.retry):this.props.children}}const it=`[${Xe.SOURCE_LINES_ATTRIBUTE}]`,no="[data-aqmd-content]",ro='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], [data-aqmd-spreadsheet-fullscreen], [data-aqmd-svg-image-source]',oo=200,ve=e=>Xe.parseSourceLines(e.getAttribute(Xe.SOURCE_LINES_ATTRIBUTE)),so=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=ve(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(it)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=ve(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},ao=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},bn=e=>e.closest(no)!==null&&e.closest(ro)===null,Sn=(e,t,n)=>{const r=so(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const d=r.lines.last+1;return{lines:{first:d,last:d},word:null,occurrence:0,clientTop:Me(e)}}const a=lo(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Me(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(it)){const d=ve(a);if(d===null)continue;n??=Rn(t,a);const{top:m,bottom:w}=a.getBoundingClientRect();m<=n&&n<w?r={lines:d,block:a}:o===null&&m>=n&&(o={lines:d,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Me(s.block)}},kn=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,Rn=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return kn(e)+(Number.isFinite(n)?n:0)},lo=(e,t)=>{if(t===null||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!(e.contains(n.startContainer)&&e.contains(n.endContainer)))return null;const r=n.toString().trim();if(r===""||r.length>oo||/[\r\n]/u.test(r))return null;const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(n.startContainer,n.startOffset),{text:r,occurrence:ao(o.toString(),r),clientTop:n.getBoundingClientRect().top}},io=(e,t)=>{const n=e.split(`
11
- `),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let d=r;d<=o;d+=1){const m=n[d-1]??"";for(let w=m.indexOf(t.word);w>=0;w=m.indexOf(t.word,w+t.word.length)){if(a===t.occurrence)return{line:d,column:w};a+=1}}return a>0?co(n,r,o,t.word)??s:s},co=(e,t,n,r)=>{for(let o=n;o>=t;o-=1){const s=(e[o-1]??"").lastIndexOf(r);if(s>=0)return{line:o,column:s}}return null},Tn=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(it)){const s=ve(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},On=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Me(e),o=ve(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},Me=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:d}=s.getBoundingClientRect();if(d>0)return a}return e.getBoundingClientRect().top},ct=Object.freeze({browse:Object.freeze({replace:!0,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-source":Object.freeze({replace:!1,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-view":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1}),"follow-link":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1})}),uo=e=>ct[e],Ee=()=>{const e=J.useNavigate();return i.useCallback((t,n)=>{e(t,ct[n])},[e])},Ln=({navigation:e,...t})=>l.jsx(J.Link,{...t,...ct[e]}),dt=e=>{const t=e.ownerDocument;if(e.focus({preventScroll:!0}),t.activeElement===e)return!0;if(e.hasAttribute("tabindex"))return!1;if(e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),t.activeElement!==e)return e.removeAttribute("tabindex"),!1;const n=()=>{t.activeElement!==e&&(e.removeAttribute("tabindex"),e.removeEventListener("blur",n))};return e.addEventListener("blur",n),!0},Cn=(e,t)=>{const n=i.useRef(null),r=i.useRef(null),o=i.useRef(null),s=i.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);i.useEffect(()=>s,[s]);const a=i.useCallback(w=>{if(r.current!==w)return;const c=o.current;if(c!==null){c.then(()=>a(w));return}e.prefetch(w);const f=e.peek(w);if(f?.status!=="pending")return;const g=Promise.allSettled([f.promise]);o.current=g,g.then(()=>{o.current===g&&(o.current=null)})},[e]),d=i.useCallback(w=>{const c=t(w);c!==r.current&&(s(),c!==null&&(r.current=c,n.current=window.setTimeout(()=>{n.current=null,a(c)},V.PREFETCH_DWELL_MS)))},[s,t,a]),m=i.useCallback(w=>{t(w)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:w=>d(w.target),onPointerOut:w=>m(w.relatedTarget),onFocus:w=>d(w.target),onBlur:w=>m(w.relatedTarget)}),[d,m])},fo=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-D4a7fBOS.cjs")).then(e=>({default:e.NativeScrollBar})));class mo extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.",t)}render(){return this.state.failed?null:this.props.children}}const An=({scroller:e,withCircle:t})=>l.jsx(mo,{children:l.jsx(i.Suspense,{fallback:null,children:l.jsx(fo,{scroller:e,withCircle:t})})}),Mn=e=>l.jsx(An,{scroller:e,withCircle:!0}),jn=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const a=e.get(o);if(a!==void 0&&a>1){e.set(o,a-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},je=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,a)=>je(s,t[a]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&je(n[s],r[s]))},ho=55e3,Ot=Object.freeze({status:"deferred"}),Ue=Object.freeze({status:"refreshed"}),Ve=Object.freeze({status:"shown",failed:!1}),ke=Object.freeze({status:"shown",failed:!0}),Re=Object.freeze({status:"superseded"}),oe=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,po=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",go=({client:e,capacity:t})=>{if(!Number.isInteger(t)||t<1)throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);const n=new Map,r=jn(),o=me(),s=new WeakSet,a=new Map,d=new Map,m=new Map;let w=0;const c=o.emit,f=()=>(w+=1,w),g=()=>{if(!(n.size<=t))for(const E of[...n.keys()]){if(n.size<=t)return;r.isHeld(E)||n.delete(E)}},v=(E,T)=>{n.delete(E),n.set(E,T)},x=E=>performance.now()-E.validatedAt>=ho,R=(E,T,M)=>{const L=n.get(E),_=oe(L?.snapshot),B=M||L?.refreshPending===!0,K=we(e.document(E,{refresh:B}).then(b=>({status:"loaded",document:b}))),p={snapshot:{status:"pending",promise:K,previous:_},validatedAt:performance.now(),opened:T,background:null,refreshPending:!1,seeded:void 0,stamp:f()};return v(E,p),g(),K.then(b=>{n.get(E)===p&&(p.snapshot=b,p.stamp=f(),c())}),p},O=(E,T,M,L,_,B)=>{T.background===M&&(T.background=null,!(n.get(E)!==T||T.snapshot!==L)&&(_.kind==="failure"&&L.document.kind!=="failure"||(T.validatedAt=B,T.stamp=f(),je(L.document,_)||(T.snapshot={status:"loaded",document:_}),c())))},j=async(E,T)=>{const M=T.snapshot;if(M.status!=="loaded")return null;const L={};T.background=L;const _=performance.now(),B=e.document(E,{refresh:T.refreshPending});T.refreshPending=!1;const K=await B,p=T.background===L&&n.get(E)===T&&T.snapshot===M;return O(E,T,L,M,K,_),p?K:null},N=(E,T)=>{const{snapshot:M}=T;return M.status==="pending"?!1:M.status==="loaded"&&M.document.kind!=="failure"?(j(E,T),!1):(M.status==="loaded"&&s.add(M),R(E,!0,!1),!0)},$=E=>{d.delete(E);const T=m.get(E);if(T!==void 0){m.delete(E);for(const M of T)M()}},P=(E,T)=>new Promise(M=>{if(d.get(E)===T||!r.isHeld(E)){M();return}const L=m.get(E);L===void 0?m.set(E,new Set([M])):L.add(M)}),u=(E,T)=>{const M=a.get(E);if(M===void 0){T.resolve(null);return}if(M.last!==null&&M.last.stamp>=T.stamp){T.resolve(M.last);return}M.waiters.add(T)},h=async(E,T,M)=>{const L=await new Promise(_=>u(E,{stamp:T.stamp,resolve:_}));if(n.get(E)!==T)return Re;if(L===null)return M?Ue:Ve;if(!M)return L.failure===null?Ve:ke;switch(L.before){case"copy":return L.failure===null?Ue:{status:"failed",failure:L.failure};case"failure":return L.failure===null?Ve:ke;case"none":return L.failure===null?Ue:ke}},k=E=>{const T={showing:"none",last:null,waiters:new Set};a.set(E,T);let M=!1;return{settle:(L,_)=>{if(M||L===void 0)return;const B={stamp:L,failure:_,before:T.showing};T.last=B,_===null?T.showing="copy":T.showing==="none"&&(T.showing="failure");for(const K of[...T.waiters])L<K.stamp||(T.waiters.delete(K),K.resolve(B))},release:()=>{if(M)return;M=!0,a.get(E)===T&&a.delete(E);const L=[...T.waiters];T.waiters.clear(),L.length>0&&queueMicrotask(()=>{for(const _ of L)u(E,_)})}}},A=E=>{const T=r.hold(E);let M=!1;return()=>{if(M)return;M=!0,T();const L=n.get(E);L!==void 0&&v(E,L),g(),r.isHeld(E)||queueMicrotask(()=>{r.isHeld(E)||$(E)})}};return{peek:E=>n.get(E)?.snapshot,peekSeeded:E=>n.get(E)?.seeded,answerStampOf:E=>n.get(E)?.stamp,prefetch:E=>{const T=n.get(E);T!==void 0&&T.snapshot.status!=="deferred"||(R(E,!1,!1),c())},open:E=>{const T=r.resumes(E),M=A(E),L=n.get(E);if(L===void 0||L.snapshot.status==="deferred")return R(E,!0,!1),c(),M;if(v(E,L),T)return M;const{snapshot:_}=L;return _.status==="pending"?(L.opened=!0,M):_.document.kind==="failure"?(L.opened||x(L)?(s.add(_),R(E,!0,!1),c()):L.opened=!0,M):(L.opened=!0,L.background===null&&x(L)&&j(E,L),M)},retain:A,retry:E=>{const T=n.get(E);T===void 0||T.snapshot.status!=="loaded"||T.snapshot.document.kind!=="failure"||(R(E,!0,!1),c())},seed:(E,T)=>{const M=performance.now(),L=we(T.then(b=>b===null?Ot:{status:"loaded",document:b},()=>Ot)),_=n.get(E);if(_!==void 0&&_.snapshot.status==="loaded"){const b=_.snapshot,y={};_.background=y,L.then(C=>{if(C.status==="loaded"){O(E,_,y,b,C.document,M);return}_.background===y&&(_.background=null)});return}const B=_!==void 0&&_.snapshot.status==="pending"?_.snapshot.previous:null,K={status:"pending",promise:L,previous:B},p={snapshot:K,validatedAt:M,opened:_?.opened===!0,background:null,refreshPending:_?.refreshPending===!0,seeded:K,stamp:f()};v(E,p),g(),L.then(b=>{n.get(E)===p&&(b.status==="deferred"&&r.isHeld(E)?R(E,p.opened,!1):(p.snapshot=b,p.stamp=f()),c())})},invalidate:()=>{let E=!1;for(const[T,M]of[...n]){if(M.validatedAt=Number.NEGATIVE_INFINITY,M.opened=!0,M.refreshPending=!0,!r.isHeld(T))continue;const{snapshot:L}=M;if(L.status!=="pending"){N(T,M)&&(E=!0);continue}L.promise.then(()=>{n.get(T)===M&&M.refreshPending&&r.isHeld(T)&&N(T,M)&&c()})}E&&c()},refresh:async E=>{const T=n.get(E);if(T!==void 0&&po(T.snapshot)){T.refreshPending=!0;const _=await j(E,T);return _===null?Re:_.kind==="failure"?{status:"failed",failure:_.failure}:h(E,T,!0)}const M=R(E,!0,!0);if(c(),M.snapshot.status!=="pending")return Re;const L=await M.snapshot.promise;return n.get(E)!==M||L.status!=="loaded"?Re:L.document.kind==="failure"?ke:(await P(E,L),h(E,M,!1))},clear:()=>{n.clear();for(const E of r.heldKeys())R(E,!0,!1);c()},subscribe:o.subscribe,readPart:k,noteShown:(E,T)=>{d.set(E,T);const M=m.get(E);if(M!==void 0){m.delete(E);for(const L of M)L()}},noteFailureShown:E=>s.has(E)?!1:(s.add(E),!0)}},ae=i.createContext("fill"),wo=Object.freeze({blockSize:"100%"}),xe=({scrollerProps:e,children:t})=>i.use(ae)==="content"?l.jsx(ue.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(ue.HostedScrollArea,{scrollerProps:{...e,style:wo},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Mn,children:t}),vo=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Eo=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),be=({label:e,testId:t})=>l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:vo.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),ut=({failure:e,onRetry:t,testId:n})=>l.jsx(xe,{scrollerProps:Eo,children:l.jsx(fe,{failure:e,alert:!1,onRetry:t,testId:n})});function xo({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const bo=S.forwardRef(xo);function So({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),S.createElement("path",{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"}))}const yo=S.forwardRef(So);function ko({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Ro=S.forwardRef(ko),To=2e3,Lt=Object.freeze({outcome:"idle"}),Oo=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Lo=({text:e})=>{const{announcer:t,labels:n}=I(),[r,o]=i.useState(Lt);i.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(Lt),To);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{Oo(e).then(()=>s("copied"),()=>s("failed"))},d=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:d,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(bo,{}):r.outcome==="failed"?l.jsx(Ro,{}):l.jsx(yo,{})})},Nn=i.createContext(null),Co=()=>{const e=i.use(Nn);if(e===null)throw new Error("[markdown-explorer] a document's content reads its own part only inside a document pane (DocumentContentChannelContext)");return e};function Ao({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}),S.createElement("path",{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"}))}const Mo=S.forwardRef(Ao);function jo({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const No=S.forwardRef(jo),Se=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=I();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(No,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(Mo,{})})]})};function Po({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Do=S.forwardRef(Po),_o=Object.freeze({className:"aqmx-document-stage"}),Fo=({document:e})=>{const{labels:t}=I();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Do,{})}),l.jsx(xe,{scrollerProps:_o,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},De="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Io=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},qo=/(%[0-9A-Fa-f]{2})/u,ft=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(qo).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},Pn=e=>`#${encodeURIComponent(e)}`,$o=e=>{if(e==="#")return!0;const t=ft(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Dn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Bo="http://www.w3.org/1999/xhtml",Ct=(e,t)=>{if(t==="")return null;const n=Dn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Bo&&r.getAttribute("name")===t)return r;return null},_n=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Ct(e,t.slice(1));if(n!==null)return n;const r=ft(t);return r===null?null:Ct(e,r)},At=e=>{const{body:t,documentElement:n}=e.ownerDocument;if(e===t){const o=getComputedStyle(n);if(o.overflowX==="visible"&&o.overflowY==="visible")return!1}const{overflowY:r}=getComputedStyle(e);return r==="auto"||r==="scroll"},Ho=e=>{const{body:t,documentElement:n}=e,r=getComputedStyle(n),o=r.overflowX==="visible"&&r.overflowY==="visible"&&t!==null?getComputedStyle(t).overflowY:r.overflowY;return o!=="hidden"&&o!=="clip"},Uo=(e,t)=>{const n=t.closest(De),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&At(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let d=e.parentElement;d!==null&&d!==s;d=d.parentElement)if(At(d)&&d.scrollHeight>d.clientHeight&&d.clientHeight<o)return d;return a instanceof Element&&Ho(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Vo=Object.freeze({scrollerOf:Uo,reveal:e=>{e.scrollIntoView(tt)}}),tt=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),zo=(e,t)=>{for(let n=t;n!==null&&n!==e;n=n.parentElement){const r=n.parentElement;if(r instanceof HTMLDetailsElement&&n!==r.querySelector(":scope > summary")&&(r.open=!0),n.getAttribute("hidden")?.toLowerCase()==="until-found"){if(n.dispatchEvent(new Event("beforematch",{bubbles:!0})),!n.isConnected)return;n.removeAttribute("hidden")}}},Zo=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),a=t.getBoundingClientRect(),d=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!d&&Math.abs(a.top-s-n)<1){t.scrollIntoView(tt);return}e.scrollBy({top:d?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(tt)},Go=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(De)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Mt=(e,t,n)=>{if(e===null)return null;const r=_n(e,t);return r===null?($o(t)&&Go(e,n),null):(zo(e,r),Zo(n.scrollerOf(e,r),r),n.reveal(r),r)};function Ko({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}))}const Wo=S.forwardRef(Ko);function Xo({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Yo=S.forwardRef(Xo);function Qo({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}),S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Jo=S.forwardRef(Qo);function es({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const ts=S.forwardRef(es),nt="data-aqmx-key-repeat",Ne=Object.freeze({[nt]:"allow"}),ns=`[${nt}="${Ne[nt]}"]`,rs=()=>{let e=null;return{onKeyDownCapture:t=>{if(t.key==="Enter"){if(!t.repeat){e=t.target instanceof Element?t.target:null;return}e!==null&&t.target===e&&e.closest(ns)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},Ce=Object.freeze([1/V.GOLDEN_RATIO**2,1/V.GOLDEN_RATIO,1,V.GOLDEN_RATIO,V.GOLDEN_RATIO**2]),jt=Object.freeze({mode:"fit"}),os=1,Fn=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),Nt=`[data-testid="${Fn["data-testid"]}"]`,In=i.createContext(null),ss=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=os?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Pt=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<Ce.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?Ce.findIndex(o=>o>t):Ce.findLastIndex(o=>o<t);return r===-1?null:r},Dt=(e,t,n)=>{if(e.mode==="level"){const o=Pt(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Pt(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},as=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(V.GOLDEN_RATIO));return n===0?0:n},_t=e=>{const t=e[0],n=e[1];return e.length!==2||t===void 0||n===void 0?null:{distance:Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY),middle:{x:(t.clientX+n.clientX)/2,y:(t.clientY+n.clientY)/2}}},ls=e=>{const t=Ce[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},Ft=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},is=({document:e})=>{const{labels:t}=I(),n=i.use(In),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?jt:r.zoom),[a,d]=i.useState(r===null?null:r.reported),[m,w]=i.useState(null),c=i.useRef(null),f=i.useCallback(P=>{const{naturalWidth:u,naturalHeight:h}=P;d(k=>Ft(k,u,h))},[]),g=i.useCallback(P=>{c.current=P,!(P===null||!P.complete)&&(P.naturalWidth>0||P.naturalHeight>0?f(P):P.decode().then(()=>f(P),()=>{}))},[f]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const P=c.current;if(P===null||a===null||o.mode!=="fit")return;const u=()=>w(k=>Ft(k,P.clientWidth,P.clientHeight));if(u(),typeof ResizeObserver>"u")return;const h=new ResizeObserver(u);return h.observe(P),()=>h.disconnect()},[a,o.mode]);const v=a===null||m===null?null:ss(a,m),x=Dt(o,v,-1),R=Dt(o,v,1),O=o.mode==="level"?ls(o.index):null,j=i.useRef({zoomIn:R,zoomOut:x});i.useLayoutEffect(()=>{j.current={zoomIn:R,zoomOut:x}});const N=i.useRef(null);i.useLayoutEffect(()=>{const P=N.current,u=c.current?.closest(Nt);N.current=null,!(P===null||u===null||u===void 0)&&(u.scrollLeft=P.across*u.scrollWidth-P.x,u.scrollTop=P.down*u.scrollHeight-P.y)},[o]),i.useEffect(()=>{const P=c.current?.closest(Nt);if(P==null)return;let u=null;const h=F=>{const q=_t(F.touches);u=q===null?null:{distance:q.distance,steps:0}},k=F=>{const q=_t(F.touches);if(u===null||q===null)return;F.preventDefault();const E=as(u.distance,q.distance);if(E===u.steps)return;const T=E>u.steps?1:-1,M=T===1?j.current.zoomIn:j.current.zoomOut;if(M===null)return;u.steps+=T;const L=P.getBoundingClientRect(),_=q.middle.x-L.left,B=q.middle.y-L.top;N.current=P.scrollWidth>0&&P.scrollHeight>0?{x:_,y:B,across:(P.scrollLeft+_)/P.scrollWidth,down:(P.scrollTop+B)/P.scrollHeight}:null,s(M)},A=F=>{F.touches.length<2&&(u=null)};return P.addEventListener("touchstart",h,{passive:!0}),P.addEventListener("touchmove",k,{passive:!1}),P.addEventListener("touchend",A,{passive:!0}),P.addEventListener("touchcancel",A,{passive:!0}),()=>{P.removeEventListener("touchstart",h),P.removeEventListener("touchmove",k),P.removeEventListener("touchend",A),P.removeEventListener("touchcancel",A)}},[]);const $=o.mode==="level"&&O!==null?{width:`${o.base.width*O}px`,height:`${o.base.height*O}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(ts,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":x===null,onClick:()=>{x!==null&&s(x)},...Ne,children:l.jsx(Yo,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:O===null?t.imageFitLevel:t.imageZoomLevel(Math.round(O*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":R===null,onClick:()=>{R!==null&&s(R)},...Ne,children:l.jsx(Jo,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(jt),children:l.jsx(Wo,{})})]}),l.jsx(xe,{scrollerProps:Fn,children:l.jsx("img",{ref:g,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:$,onLoad:P=>f(P.currentTarget),"data-testid":"markdown-explorer-image"})})]})},cs=async(e,t,n)=>{const r=await e.text(t,n);if(!("kind"in r))throw n.reason;return r.kind==="text"?{kind:"text",text:r.text,truncated:r.truncated}:{kind:"failure",retryable:r.failure.reason==="failed"}},qn=i.createContext(null),_e=i.createContext(void 0),$n=i.createContext(null),Fe=()=>{const e=i.use(qn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},ds=()=>{const e=i.use($n);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Ie=(e,t,n,r)=>t.kind==="panel"?V.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?V.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):V.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),us=({children:e})=>{const{config:t}=I(),n=Fe(),r=Pe(),o=r.kind==="location"?r.location.source:void 0,s=J.useHref(Ie(t,n.navigation,o,n.currentPath));return l.jsx(_e,{value:o,children:l.jsx($n,{value:s,children:e})})},fs='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',ms=e=>{const t=e instanceof Element?e.closest(fs):null;return t===null?null:t.getAttribute("data-doc-path")},qe=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,hs=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:d,children:m})=>{const w=J.useHref(e),c=f=>{if(qe(f)){if(f.preventDefault(),t===d.currentPath&&n!==""){d.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:w,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:c,children:m})},ps=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=I(),d=Fe(),m=i.use(_e),w=Io(e),{navigation:c}=d,f=`${Ie(a,c,m,t)}${w}`,g=n===!1?"false":void 0;return c.kind==="page"?l.jsx(Ln,{...o,to:f,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":g,children:s}):l.jsx(hs,{to:f,docPath:t,fragment:w,exists:g,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:d,children:s})},gs=({className:e,attributes:t,children:n})=>{const{labels:r}=I();return l.jsxs("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:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},ws=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=I(),a=i.use(_e),d=J.useHref(`${Ie(s,r.navigation,a,r.currentPath)}${e}`),m=w=>{qe(w)&&(w.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:d,className:t,onClick:m,children:o})},vs=({href:e,className:t,attributes:n,children:r})=>{const o=Fe();if(o.navigation.kind==="page"){const s=a=>{if(!qe(a))return;const d=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):d.href===d.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(ws,{href:e,className:t,attributes:n,scope:o,children:r})},Es=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!D.isAcceptableDocumentPath(n)?l.jsx(gs,{className:o,attributes:s,children:a}):l.jsx(ps,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(vs,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),xs=()=>{const{config:e}=I(),t=Fe(),n=i.use(_e),r=Ee();return i.useCallback((o,s)=>{if(!qe(s))return!0;s.preventDefault();const a=Pn(o.id),{navigation:d}=t;return d.kind==="panel"||ft(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Ie(e,d,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},bs=()=>{const e=ds();return i.useCallback(t=>`${e}${Pn(t.id)}`,[e])};function Ss({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}))}const ys=S.forwardRef(Ss);function ks({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Rs=S.forwardRef(ks);function Ts({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Os=S.forwardRef(Ts),Ls=Object.freeze({className:"aqmx-document-stage"}),Cs=()=>()=>{},As=()=>navigator.pdfViewerEnabled!==!1,Ms=()=>null,js=({document:e})=>{const{labels:t}=I(),n=i.useSyncExternalStore(Cs,As,Ms);return n===null?null:n?l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-pdf-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.pdfNotShown}),l.jsxs("div",{className:"aqmx-callout-actions",children:[l.jsx("a",{className:"aqmx-callout-action",href:e.url,target:"_blank",rel:"noopener noreferrer","data-testid":"markdown-explorer-pdf-not-shown-open",children:t.openInNewTab}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-pdf-not-shown-download",children:t.download})]})]})},Ns=e=>{switch(e){case"video":return l.jsx(Rs,{});case"audio":return l.jsx(Os,{});case"pdf":return l.jsx(ys,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ps=({document:e})=>{const{labels:t}=I();switch(e.mediaType){case"video":return l.jsx("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});case"audio":return l.jsx("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});case"pdf":return l.jsx(js,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Ds=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Ns(e.mediaType)}),l.jsx(xe,{scrollerProps:Ls,children:l.jsx(Ps,{document:e})})]}),mt=e=>{switch(e.kind){case"markdown":return"markdown";case"image":return e.imageType==="svg"?"svg":null;case"spreadsheet":return e.format;default:return null}},_s=e=>{const{documents:t}=I(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=oe(o);return s===null?null:mt(s.document)},Bn=e=>{const{config:t}=I(),n=Ee(),r=i.useCallback(()=>n(V.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return i.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function Fs({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M.99 5.24A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25l.01 9.5A2.25 2.25 0 0 1 16.76 17H3.26A2.267 2.267 0 0 1 1 14.74l-.01-9.5Zm8.26 9.52v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 0 0 .627-.74Zm1.5 0a.75.75 0 0 0 .627.74h5.373a.75.75 0 0 0 .75-.75v-.615a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625Zm6.75-3.63v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75ZM17.5 7.5v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75Z",clipRule:"evenodd"}))}const Is=S.forwardRef(Fs),qs=100,$s=32767,Bs=Object.freeze({maxCells:St.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:St.SPREADSHEET_MAX_OPERATION_CELLS/qs,maxCellLength:$s}),Hn=44,Un=10,Vn=13,Te='"',It=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Hn||r===Un||r===Vn)return n;n+=1}return n};function*Hs(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(Te,r)){o="";let a=r+1;for(;;){const m=e.indexOf(Te,a);if(m<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,m),e.startsWith(Te,m+1)){o+=Te,a=m+2;continue}r=m+1;break}const d=It(e,r);o+=e.slice(r,d),r=d}else{const a=It(e,r);o=e.slice(r,a),r=a}if(n.push(o),r>=e.length){t==="whole"&&(yield n);return}const s=e.charCodeAt(r);if(r+=1,s!==Hn&&(yield n,n=[],s===Vn&&e.charCodeAt(r)===Un&&(r+=1),r>=e.length))return}}const Us=(e,t,n)=>t==="csv"?Hs(e,n):n==="whole"?Ye.iterateTsvRows(e):Ye.iterateTsvPrefixRows(e),Vs=(e,t)=>{if(e.length<=t)return e;const n=e.charCodeAt(t-1);return e.slice(0,n>=55296&&n<=56319?t-1:t)},zs=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const d of e){const m=d.length>t.maxColumns?d.slice(0,t.maxColumns):d,w=Math.max(r,m.length);if((n.length+1)*w>t.maxCells){s=!0;break}const c=m.some(f=>f.length>t.maxCellLength)?m.map(f=>Vs(f,t.maxCellLength)):m;c!==d&&(o=!0),n.push(c),r=w}return{rows:n.map(d=>d.length===r?d:[...d,...Array(r-d.length).fill("")]),truncated:s||o,full:s}},ze=(e,t,n,r,o)=>{const s=V.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:V.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=zs(Us(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(d=>d.some(m=>m!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},zn=64*1024,Zs=e=>{let t=new Uint8Array(Math.min(e,zn)),n=0;return{append:r=>{if(n+r.byteLength>t.byteLength){const o=new Uint8Array(Math.min(e,Math.max(t.byteLength*2,n+r.byteLength)));o.set(t.subarray(0,n)),t=o}t.set(r,n),n+=r.byteLength},bytes:()=>t.subarray(0,n),length:()=>n}},Gs=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},Ks=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),d=Zs(o);let m=zn;try{for(;;){const{done:w,value:c}=await a.read();if(w)return ze(d.bytes(),!0,n,r,s);const f=o-d.length();if(d.append(c.byteLength>f?c.subarray(0,f):c),d.length()===o){const v=c.byteLength<=f&&await Gs(a);return ze(d.bytes(),v,n,r,s)}if(d.length()<m)continue;m=d.length()*2;const g=ze(d.bytes(),!1,n,r,s);if(g.kind==="unreadable"&&g.code!=="long-row"||g.kind==="table"&&g.table.full)return g}}finally{a.cancel().catch(()=>{})}},Ws=async(e,t,n,r)=>{const o=await e.asset(D.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await Ks(o.body,n)}catch{return r.aborted?null:{kind:"failure",failure:{reason:"failed"}}}return r.aborted?null:s.kind==="table"?{kind:"table",rows:s.table.rows,truncated:s.table.truncated}:s},Zn=(e,t,n)=>{const{documents:r,labels:o}=I(),s=Co(),a=i.useCallback(()=>r.answerStampOf(e),[r,e]),d=i.useSyncExternalStore(r.subscribe,a,a),[m,w]=i.useState(0),c=i.useMemo(()=>({read:n,stamp:d,attempt:m}),[n,d,m]),[f,g]=i.useState({settled:null,shown:null,failure:null}),v=i.useRef(null),x=i.useEffectEvent((j,N)=>{if(v.current?.settle(N.stamp,j.kind==="failure"?j.failure:null),j.kind==="read"){g({settled:N,shown:j.value,failure:null});return}if(f.shown!==null){g({settled:N,shown:f.shown,failure:null});return}g({settled:N,shown:null,failure:j.failure}),s.announceFailure(o.documentFailed(t,te(o,j.failure.reason)))});i.useEffect(()=>{const j=s.readPart();return v.current=j,()=>{v.current=null,j.release()}},[s]),i.useEffect(()=>{const j=new AbortController;return c.read(j.signal).then(N=>{N!==null&&!j.signal.aborted&&x(N,c)}),()=>j.abort()},[c]);const R=f.settled!==c&&(f.shown!==null||f.failure!==null);i.useLayoutEffect(()=>R?s.holdBusy():void 0,[R,s]);const O=i.useCallback(()=>w(j=>j+1),[]);return{shown:f.shown,failure:f.failure,retry:O}},Gn=(e,t)=>{const n={};for(const r of Object.keys(de.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[st(r)];o!==de.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},Xs=(e,t)=>Object.fromEntries(Object.entries(Gn(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),Ys=(e,t)=>({...Xs(e,t),loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,defaultErrorTitle:e.viewerErrorTitle,missingImage:e.viewerMissingImage,openTocAria:e.viewerOpenToc,tocTitle:e.viewerTocTitle,pinTocAria:e.viewerPinToc,unpinTocAria:e.viewerUnpinToc,selectAlignAria:e.viewerSelectAlign,alignTitle:e.viewerAlignTitle,pinAlignAria:e.viewerPinAlign,unpinAlignAria:e.viewerUnpinAlign,alignLeft:e.viewerAlignLeft,alignCenter:e.viewerAlignCenter,alignRight:e.viewerAlignRight,mermaidInteractionMode:e.viewerMermaidInteractionMode,mermaidInteractionModeTouch:e.viewerMermaidInteractionModeTouch,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidModeNoneTouch:e.viewerMermaidModeNoneTouch,mermaidModeZoomTouch:e.viewerMermaidModeZoomTouch,mermaidModePanTouch:e.viewerMermaidModePanTouch,mermaidModeBothTouch:e.viewerMermaidModeBothTouch,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidPanUp:e.viewerMermaidPanUp,mermaidPanDown:e.viewerMermaidPanDown,mermaidPanLeft:e.viewerMermaidPanLeft,mermaidPanRight:e.viewerMermaidPanRight,mermaidDiagram:e.viewerMermaidDiagram,mermaidRetry:e.viewerMermaidRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame,blockFailed:e.viewerBlockFailed,svgImageToolbar:e.viewerSvgImageToolbar,svgImageSource:e.viewerSvgImageSource,svgImageSourceRegion:e.viewerSvgImageSourceRegion,svgImageLoading:e.viewerSvgImageLoading,svgImageFailed:e.viewerSvgImageFailed,svgImageRetry:e.viewerSvgImageRetry,svgImageTruncated:e.viewerSvgImageTruncated,svgImageCopy:e.viewerSvgImageCopy,svgImageCopied:e.viewerSvgImageCopied,svgImageCopyFailed:e.viewerSvgImageCopyFailed}),Kn=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},Wn=(e,t)=>e!==void 0?e:t!==void 0?t:br.DEFAULT_CONTENT_ALIGN,Qs=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),Js=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},ea=({path:e,document:t})=>{const{config:n,data:r,labels:o,locale:s,theme:a}=I(),d=i.use(ae),{name:m,url:w,format:c}=t,f=i.useMemo(()=>({format:c,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:Bs}),[c,n.legacyTextEncoding,n.spreadsheets.maxBytes]),g=i.useCallback(async N=>{const $=await Ws(r,w,f,N);return $===null||$.kind==="failure"?$:{kind:"read",value:$}},[r,w,f]),{shown:v,failure:x,retry:R}=Zn(e,m,g),O=i.useMemo(()=>({...Gn(o,s),table:m,fullscreenDialog:o.spreadsheetFullscreen(m)}),[o,s,m]),j=i.useMemo(()=>v?.kind==="table"?Ye.serializeTsv(v.rows):null,[v]);return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-spreadsheet-view","data-aqmx-spreadsheet":v===null?x===null?"loading":"failure":v.kind,children:[l.jsx(Se,{name:m,openUrl:D.explorerPlainTextHref(w),downloadUrl:w,icon:l.jsx(Is,{})}),l.jsx(xe,{scrollerProps:Qs,children:l.jsxs("div",{className:"aqmx-document-spreadsheet-column",children:[t.firstSheetOnly?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-first-sheet",children:o.spreadsheetFirstSheetOnly}):null,v?.kind==="table"&&v.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,v===null&&x===null?l.jsx(be,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,v===null&&x!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(fe,{failure:x,alert:!1,onRetry:R,testId:"markdown-explorer-spreadsheet-failure"})}):null,v?.kind==="empty"?l.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:l.jsx("p",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-spreadsheet-empty",children:o.spreadsheetEmpty})}):null,v?.kind==="unreadable"?l.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-spreadsheet-unreadable","data-aqmx-unreadable":v.code,children:[l.jsx("p",{className:"aqmx-callout-body",children:Js(o,v)}),l.jsx("a",{className:"aqmx-callout-action",href:w,download:m,"data-testid":"markdown-explorer-spreadsheet-unreadable-download",children:o.download})]})}):null,j===null?null:l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":a,children:l.jsx(ue.SpreadsheetBlock,{tsv:j,layout:d==="fill"?"fill":"inline",locale:s,labels:O})})]})})]})},Xn=Object.freeze({kind:"empty"}),ta=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return V.explorerHref(e,{...t,overrides:r})},pe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:d})=>{const m=i.use(ae);return l.jsxs("section",{ref:s,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":m,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,d]})},na=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=I(),s=e.kind==="no-readme"?e.folder:null,a=e.kind==="failure"?e.folder:null,d=e.kind==="failure"?e.failure:null;switch(i.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(D.lastPathSegment(s)))},[t,s,o,r]),i.useEffect(()=>{a!==null&&d!==null&&n(r.documentFailed(D.lastPathSegment(a),te(r,d.reason)))},[a,d,n,r]),e.kind){case"empty":return l.jsx(pe,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.documentEmpty})})});case"loading":return l.jsx(ht,{label:r.documentRegion});case"no-readme":return l.jsx(pe,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(D.lastPathSegment(e.folder))})})});case"failure":return l.jsx(pe,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(ut,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},ht=({label:e})=>{const{labels:t}=I();return l.jsx(pe,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(be,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},qt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),ra=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=I(),a=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),d=xs(),m=bs(),w=i.useMemo(()=>o===void 0?void 0:u=>o(e,u),[o,e]),c=i.useRef(null),{editable:f,doubleClick:g,region:v,paneScroll:x,stale:R}=r;i.useLayoutEffect(()=>{if(f)return s.bindView(e,{anchor:()=>{const u=c.current,h=v(),k=u===null?null:u.querySelector(De);return u===null||h===null||k===null?null:yn(u,x.scrollerOf(h,k))}})},[s,e,f,v,x]);const O=u=>{const h=c.current,{target:k}=u;!g||h===null||!(k instanceof Element)||!bn(k)||(u.stopPropagation(),s.start(e,Sn(k,h,h.ownerDocument.getSelection())))},j=i.useRef(null),N=i.useRef(R);i.useLayoutEffect(()=>{N.current=R});const $=i.useEffectEvent(u=>{const h=c.current,k=v(),A=h===null?null:Tn(h,u.line);if(k===null||A===null)return!1;const F=x.scrollerOf(k,A);return F.scrollTop+=On(A,u.line)-u.clientTop,!0}),P=i.useEffectEvent(u=>{const h=v();if(h===null)return;const k=()=>{for(const F of qt)h.removeEventListener(F,A,!0);j.current?.release===k&&(j.current=null)},A=()=>k();for(const F of qt)h.addEventListener(F,A,{capture:!0,passive:!0});j.current={point:u,release:k}});return i.useLayoutEffect(()=>{const u=s.takeReturn(e);if(u!==null)return queueMicrotask(()=>{$(u)&&N.current&&P(u)}),()=>j.current?.release()},[s,e]),i.useLayoutEffect(()=>{const u=j.current;u===null||R||(u.release(),$(u.point))},[t,R]),l.jsx("div",{ref:c,className:"aqmx-document-viewer",onDoubleClick:O,children:l.jsx(ue.MarkdownViewer,{...n,onHeadingSelect:d,headingHref:m,onMathDiagnostics:w,parseResult:a,content:null})})},Yn=({document:e,viewer:t})=>{const{labels:n}=I();return l.jsxs(l.Fragment,{children:[l.jsx(Se,{name:e.name,openUrl:D.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(Qr,{}),children:e.truncated?null:l.jsx(Lo,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(ue.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Ze=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=I(),s=i.useCallback(async w=>{const c=await r.text(e,w);return"kind"in c?c.kind==="failure"?{kind:"failure",failure:c.failure}:{kind:"read",value:c}:null},[r,e]),{shown:a,failure:d,retry:m}=Zn(e,t,s);return a!==null?l.jsx(Yn,{document:a,viewer:n}):d!==null?l.jsx(ut,{failure:d,onRetry:m,testId:"markdown-explorer-markup-failure"}):l.jsx(be,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},oa=Object.freeze({reason:"failed"}),sa=e=>{const{labels:t}=I();return l.jsx(to,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(fe,{failure:oa,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(i.Suspense,{fallback:l.jsx(be,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(eo,{...e})})})},aa=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:d,region:m,paneScroll:w,stale:c}=s;if(n==="edit"&&a!==void 0)return l.jsx(sa,{path:e,name:t.name,session:a,layout:d,viewer:r,region:m,paneScroll:w});if(n==="markup")return l.jsx(Ze,{path:e,name:t.name,viewer:r});const f=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(ra,{path:e,document:t,viewer:r,editing:{editable:f,doubleClick:f&&d==="fill",region:m,paneScroll:w,stale:c}})}case"text":return l.jsx(Yn,{document:t,viewer:r});case"image":return n==="markup"&&mt(t)==="svg"?l.jsx(Ze,{path:e,name:t.name,viewer:r}):l.jsx(is,{document:t});case"media":return l.jsx(Ds,{document:t});case"spreadsheet":return n==="markup"?l.jsx(Ze,{path:e,name:t.name,viewer:r}):l.jsx(ea,{path:e,document:t});case"file":return l.jsx(Fo,{document:t});case"failure":return l.jsx(ut,{failure:t.failure,onRetry:o,testId:"markdown-explorer-document-failure"});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},la='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',ia=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:_n(e,n),r===void 0?null:Dn(e,r.id),e.querySelector(De),e.querySelector(la)];for(const s of o)if(s instanceof HTMLElement&&dt(s))return s;return null},$t=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&dt(t)},ca=e=>{const t=i.useRef(!1);return i.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,a;const d=g=>{s=!(g.target instanceof Node&&n.contains(g.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},m=g=>{t.current=g.target instanceof Node&&n.contains(g.target)},w=g=>{g.relatedTarget===null&&s&&(t.current=!1)},c=()=>{const{activeElement:g,body:v}=r;g!==null&&g!==v&&(t.current=n.contains(g))},f=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",d,!0),o.addEventListener("mousedown",d,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",c),o.addEventListener("focus",f),n.addEventListener("focusout",w),()=>{clearTimeout(a),o.removeEventListener("pointerdown",d,!0),o.removeEventListener("mousedown",d,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",c),o.removeEventListener("focus",f),n.removeEventListener("focusout",w)}},[e]),t},da=Object.freeze({count:0,recovered:!1}),ua=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:d,fragment:m,paneScroll:w,announces:c,announceFailure:f,onDocumentShown:g})=>{const{labels:v,announcer:x,documents:R}=I(),{document:O}=t,j=i.useRef(null),N=i.useRef(null),$=i.useRef(null),P=i.useRef(0),u=ca(j),h=i.useRef({path:e,document:O}),k=i.useRef(null),A=i.useCallback(U=>{const z=j.current,X=Mt(z,U,w);z!==null&&X!==null&&$t(z,X,u.current)},[w,u]),F=i.useCallback((U,z)=>{const X=P.current;setTimeout(()=>{!z.defaultPrevented&&P.current===X&&A(U)},0)},[A]),q=i.useCallback(U=>{setTimeout(()=>{U.defaultPrevented||A("#")},0)},[A]),E=i.useMemo(()=>({navigation:d,currentPath:e,scrollWithin:A,followSameUrlJump:F,followEmptyFragment:q}),[d,e,A,F,q]),T=i.useCallback(()=>R.retry(e),[R,e]),M=Cn(R,ms),L=wn(e),_=L!==void 0?"edit":n?"markup":"rendered",B=mt(O)===null?void 0:_,K=i.useCallback(()=>j.current,[]),p=i.useMemo(()=>({session:L,layout:s,region:K,paneScroll:w,stale:r}),[L,s,K,w,r]),b=B==="edit"?!1:r,y=i.use(ae),C=B==="edit"&&s==="fill"?"fill":y,[H,Z]=i.useState(0),W=i.useRef(0),G=i.useRef(!1),[ee,gt]=i.useState(da),[wt,fr]=i.useState(0),vt=i.useRef(f),Et=i.useRef(r);i.useLayoutEffect(()=>{vt.current=f,Et.current=r},[f,r]);const mr=i.useMemo(()=>({announceFailure:U=>{Et.current||vt.current(U)},readPart:()=>{const U=R.readPart(e);W.current+=1;let z=!1,X=!1,Y=!1;return{settle:(le,ie)=>{if(U.settle(le,ie),!(Y||z)){if(ie!==null){X=!0,G.current=!1;return}z=!0,gt(ye=>({count:ye.count+1,recovered:X}))}},release:()=>{Y||(Y=!0,U.release(),W.current-=1,z||fr(le=>le+1))}}},holdBusy:()=>{Z(z=>z+1);let U=!0;return()=>{U&&(U=!1,Z(z=>z-1))}}}),[R,e]),xt=b||H>0,hr=i.useEffectEvent((U,z)=>{const X=N.current;if(X!==null&&X.path===U&&X.snapshot===z)return;N.current={path:U,snapshot:z},R.noteShown(U,z);const Y=z.document;if(Y.kind==="failure"){G.current=!1,R.noteFailureShown(z)&&f(v.documentFailed(D.lastPathSegment(U),te(v,Y.failure.reason)));return}g?.(U,Y),!(!c||X!==null&&X.path===U&&X.snapshot.document.kind!=="failure")&&(G.current=W.current>0,G.current||x.announce(v.documentShown(Y.name)))});i.useEffect(()=>{hr(e,t)},[e,t]);const pr=i.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),bt=i.useEffectEvent(U=>{const z=j.current;if(z===null||!u.current)return null;const{activeElement:X,body:Y}=z.ownerDocument;return X!==null&&X!==Y?null:ia(z,O,U)}),gr=i.useEffectEvent(U=>{const z=G.current;G.current=!1,!r&&(U&&bt(null),c&&(U||z)&&O.kind!=="failure"&&x.announce(v.documentShown(O.name)))});i.useEffect(()=>{ee.count>0&&gr(ee.recovered)},[ee]);const wr=i.useEffectEvent(()=>{W.current>0||!G.current||(G.current=!1,c&&!r&&O.kind!=="failure"&&x.announce(v.documentShown(O.name)))});i.useEffect(()=>{wt>0&&wr()},[wt]);const vr=i.useEffectEvent(U=>{const z=j.current;z!==null&&$t(z,U,u.current)}),Er=i.useEffectEvent(U=>w.reveal(U)),xr=i.useEffectEvent(U=>Mt(j.current,U,w));return i.useEffect(()=>{if(r)return;const U=h.current.path!==e,z=U||h.current.document!==O;h.current={path:e,document:O};const X=k.current!==e;k.current=e;let Y=null;m.kind==="page"?$.current!==m.navigation&&($.current=m.navigation,P.current+=1,Y=m.fragment):m.fragment!==null&&(Y=m.fragment,pr());const le=()=>{const ie=Y===null?null:xr(Y);if(!z){ie!==null&&vr(ie);return}const ye=bt(m.fragment);U&&ie===null&&ye!==null&&Er(ye)};X?queueMicrotask(le):le()},[m,e,O,r]),l.jsx(ae,{value:C,children:l.jsx(pe,{kind:O.kind,view:B,label:a(e,O),stale:xt,busy:xt,frameRef:j,intent:M,children:l.jsx(qn,{value:E,children:l.jsx(us,{children:l.jsx(Nn,{value:mr,children:l.jsx(aa,{path:e,document:O,view:_,viewer:o,onRetry:T,editing:p},e)})})})})})},pt=Object.freeze({kind:"skeleton"}),fa=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=oe(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const a=n===null||n===e?null:oe(r);return n===null||a===null?pt:{kind:"document",path:n,snapshot:a,stale:!0}},ma=(e,t)=>t.status==="deferred"?pt:{kind:"document",path:e,snapshot:t,stale:!1},ha=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?ma(t.path,i.use(t.promise)):t;return o.kind!=="document"?l.jsx(ht,{label:r.regionLabel(e,null)}):l.jsx(ua,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Qn=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:d,announceFailure:m,onDocumentShown:w})=>{const{config:c,labels:f,locale:g,theme:v,documents:x,data:R}=I(),O=ue.useMarkdownToolbarState(),j=i.useRef(!1);i.useLayoutEffect(()=>{j.current=!0},[]);const[N,$]=i.useState(null),[P,u]=i.useState(n),h=i.useCallback(()=>e===null?void 0:x.peek(e),[x,e]),k=i.useSyncExternalStore(x.subscribe,h,h),A=i.useCallback(()=>N===null?void 0:x.peek(N),[x,N]),F=i.useSyncExternalStore(x.subscribe,A,A);i.useLayoutEffect(()=>e===null?void 0:x.open(e),[x,e]),i.useLayoutEffect(()=>N===null?void 0:x.retain(N),[x,N]);const q=e===null?pt:fa(e,k,N,F,!j.current),E=e===null?null:q.kind==="document"&&!q.stale?q.path:N;E!==N&&$(E);const T=q.kind!=="document"||q.path===e;T&&n!==P&&u(n);const M=i.useMemo(()=>Ys(f,g),[f,g]),L=i.useMemo(()=>({read:(y,C)=>cs(R,y,C)}),[R]),_=i.useMemo(()=>[...c.iframeHosts],[c]),B=o.kind==="panel",K=i.useMemo(()=>({labels:M,spreadsheetLocale:g,emptyMessage:f.documentEmpty,theme:v,availableStyles:c.documentStyles,iFrameAllowedDomains:_,embeds:c.embeds,linkComponent:Es,toolbar:O,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:B?void 0:Mn,imageSource:L}),[M,g,f.documentEmpty,v,c.documentStyles,_,c.embeds,O,r,B,L]),p=i.useCallback((y,C)=>B?C===null||C.kind==="failure"?D.lastPathSegment(y):C.name:f.documentRegion,[B,f.documentRegion]),b=B?"content":"fill";return e===null?l.jsx(ae,{value:b,children:l.jsx(na,{absence:t,announces:d,announceFailure:m})}):l.jsx(ae,{value:b,children:l.jsx(i.Suspense,{fallback:l.jsx(ht,{label:p(e,null)}),children:l.jsx(ha,{requestedPath:e,content:q,markup:T?n:P,viewer:K,editLayout:r.editLayout,regionLabel:p,navigation:o,fragment:s,paneScroll:a,announces:d,announceFailure:m,onDocumentShown:w})})})},pa=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:d}=I(),m=ge(F=>F.style),w=ge(F=>F.align),c=Ee(),f=J.useLocation(),g=Pe(),{view:v,overrides:x,embed:R}=r,O=i.useCallback(F=>{if(g.kind!=="location")return;const q=ta(s,g.location,F);q!==null&&c(q,"browse")},[s,c,g]),j=i.useCallback(F=>{a.update({style:F}),O("style")},[a,O]),N=i.useCallback(F=>{a.update({align:F}),O("align")},[a,O]),$=Kn(s,x.style,m),P=Wn(x.align,w),u=i.useMemo(()=>({style:$,onStyleChange:j,align:P,onAlignChange:N,showToc:R.showToc!==!1,showStyle:R.showStyle!==!1,showAlign:R.showAlign!==!1,padding:R.padding,width:R.width,maxWidth:R.maxWidth,editLayout:"fill"}),[$,j,P,N,R]),h=i.useMemo(()=>({kind:"page",view:v,overrides:x,embed:R}),[v,x,R]),k=i.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),A=i.useCallback(F=>d.announce(F),[d]);return l.jsx(Qn,{path:e,absence:t,markup:n,display:u,navigation:h,fragment:k,paneScroll:Vo,announces:!0,announceFailure:A,onDocumentShown:o})},ga=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=I(),d=ge(h=>h.style),m=ge(h=>h.align),[w,c]=i.useState(()=>Kn(s,void 0,d)),f=Wn(void 0,m),g=i.useCallback(h=>a.update({align:h}),[a]),{maximized:v,onDocumentLink:x,pendingHash:R,onHashConsumed:O,announceFailure:j,paneScroll:N}=r,$=i.useMemo(()=>({style:w,onStyleChange:c,align:f,onAlignChange:g,showToc:v,showStyle:v,showAlign:v,padding:void 0,width:void 0,maxWidth:void 0,editLayout:v?"fill":"content"}),[w,f,g,v]),P=i.useMemo(()=>({kind:"panel",onDocumentLink:x}),[x]),u=i.useMemo(()=>({kind:"panel",fragment:R,consume:O}),[R,O]);return l.jsx(Qn,{path:e,absence:t,markup:n,display:$,navigation:P,fragment:u,paneScroll:N,announces:!1,announceFailure:j,onDocumentShown:o})},Jn=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(pa,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(ga,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function wa({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const er=S.forwardRef(wa);function va({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const tr=S.forwardRef(va);function Ea({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const xa=S.forwardRef(Ea);function ba({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Sa=S.forwardRef(ba);function ya({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const ka=S.forwardRef(ya);function Ra({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),S.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Ta=S.forwardRef(Ra);function Oa({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),S.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const nr=S.forwardRef(Oa);function La({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}),S.createElement("path",{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"}))}const Ca=S.forwardRef(La);function Aa({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{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"}))}const Ma=S.forwardRef(Aa),rr=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=I(),[s,a]=i.useState(!1),d=()=>{o===void 0||s||(a(!0),o(e).then(m=>{m&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:d,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},ja="Control+E Meta+E",or=(e,t,n)=>n&&t?"split":e.view,rt=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Na=e=>e==="split"?null:e,sr=e=>e==="preview"?"editor":"preview",ar=e=>/Mac|iPhone|iPad|iPod/u.test(e),lr=(e,t)=>{if(e.isComposing||e.altKey||e.shiftKey||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey))return!1;const n=e.key.toLowerCase();return n==="e"||e.code==="KeyE"&&/^\p{L}$/u.test(n)&&!/^[a-z]$/u.test(n)},Bt=(e,t,n)=>{const r=e.modifiedAt===null?Number.NaN:Date.parse(e.modifiedAt);return n(Number.isNaN(r)?e.id:t.format(r),e.author===null?"":e.author)},Pa=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:d,announcer:m}=I(),w=i.useId(),[c,f]=i.useState(null),[g,v]=i.useState(0),[x,R]=i.useState(null),[O,j]=i.useState(null),N=i.useMemo(()=>new Intl.DateTimeFormat(d,{dateStyle:"medium",timeStyle:"short"}),[d]),$=i.useCallback(()=>{R(null),j(null)},[]),P=fn({open:n,onOpen:$,onDismiss:r});i.useEffect(()=>{if(!n)return;const k=new AbortController;return f(null),o.revisions(e,k.signal).then(A=>{"kind"in A&&f(A)}),()=>k.abort()},[n,o,e,g]),i.useEffect(()=>{if(!n||x===null)return;const k=new AbortController;return j(null),o.revision(e,x,k.signal).then(A=>{"kind"in A&&j(A)}),()=>k.abort()},[n,o,e,x]);const u=()=>{O===null||O.kind!=="revision"||(s.replaceDraft(e,O.text),m.announce(a.historyRestored(t)),r())},h=c!==null&&c.kind==="revisions"?c.revisions.find(k=>k.id===x):void 0;return l.jsx("dialog",{...P,className:"aqmx-confirm aqmx-history","aria-labelledby":w,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:w,className:"aqmx-confirm-title",children:a.historyTitle(t)}),c===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):c.kind==="failure"?l.jsx(fe,{failure:c.failure,alert:!1,onRetry:()=>v(k=>k+1),testId:"markdown-explorer-history-failure"}):c.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:c.revisions.map(k=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":k.id===x,"data-testid":"markdown-explorer-history-entry",onClick:()=>R(k.id),children:[l.jsx("span",{children:Bt(k,N,a.historyEntry)}),k.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,k.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},k.id))}),x===null?null:O===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):O.kind==="failure"?l.jsx(fe,{failure:O.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":h===void 0?a.historyTitle(t):Bt(h,N,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:O.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":O===null||O.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:u,children:a.historyRestore})]})]})})},Da=e=>{const{documents:t}=I(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=oe(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:D.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},re=e=>{e.stopPropagation()},_a=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:d}=I(),m=i.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[w,c]=i.useState(null),f=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const R=a.session(e);R?.dirty===!0?c(R.save.kind==="draft"?"draft":"unsaved"):a.close(e)},g=()=>{m||(Jr(),r&&a.sideBySide()&&s?.prepare?.())},v=n?o?d.editDraftDocumentNamed(t):d.editDocumentNamed(t):null,x=o?d.editDraftDocument:d.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:m?d.closeEditor:v===null?x:v,"aria-label":v===null?void 0:v,"aria-pressed":m,"data-testid":"markdown-explorer-document-edit",onClick:f,onDoubleClick:re,onPointerEnter:g,onFocus:g,children:[l.jsx(Ca,{"aria-hidden":"true"}),v===null?l.jsx("span",{children:d.editDocumentLabel}):null]}),l.jsx(mn,{open:w!==null,title:w==="draft"?d.draftDiscardTitle:d.unsavedTitle,body:w==="draft"?d.draftDiscardBody(t):d.unsavedBody(t),confirmLabel:d.unsavedDiscard,cancelLabel:d.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{c(null),a.close(e)},onCancel:()=>c(null)})]})},Fa=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=I(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:re,children:[l.jsx(xa,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Ia=({session:e})=>{const{labels:t}=I(),n=Ar(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},qa=Object.freeze(["editor","split","preview"]),$a=Object.freeze(["editor","preview"]),Ba=Object.freeze({editor:tr,split:Ma,preview:nr}),Ha=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:d}=I(),m=En(),w=or(r,m,o),c=o?qa:$a,f=i.useId(),g=i.useRef(new Map),v={editor:{label:d.editViewEditor,tooltip:d.editViewEditorTooltip},split:{label:d.editViewSplit,tooltip:d.editViewSplitTooltip},preview:{label:d.editViewPreview,tooltip:d.editViewPreviewTooltip}},x=()=>{a.preparePreview(e),s?.prepare?.()},R=O=>{if(!lr(O.nativeEvent,ar(navigator.platform)))return;lt(O);const j=sr(w);rt(a,e,j,o),g.current.get(j)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?d.editViewNamed(t):d.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:R,children:c.map(O=>{const j=Ba[O],{label:N,tooltip:$}=v[O],P=O==="preview"?x:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:u=>{u===null?g.current.delete(O):g.current.set(O,u)},type:"radio",name:f,value:O,checked:O===w,"aria-label":N,"aria-keyshortcuts":O==="split"?void 0:ja,title:$,"data-testid":`markdown-explorer-edit-view-${O}`,onChange:()=>rt(a,e,O,o),onDoubleClick:re,onPointerEnter:P,onFocus:P}),l.jsx(j,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:N})]},O)})})},Ua=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=I(),[d,m]=i.useState(!1);if(r.phase.kind!=="editing")return null;const w=r.save.kind==="saving",c=w||!r.dirty,f=()=>{s.flush(e);const v=s.session(e);v===void 0||!v.dirty||v.save.kind==="saving"||s.save(e)},g=v=>n?{className:"aqmx-icon-button","aria-label":v}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...g(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:re,children:[l.jsx(Sa,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(Ha,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...g(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:re,children:[l.jsx(ka,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...g(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":c,"aria-busy":w,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:f,onDoubleClick:re,children:[l.jsx(Ta,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Pa,{path:e,documentName:t,open:d,onClose:()=>m(!1)}):null]})},Va=({path:e,session:t})=>{const{edits:n}=I();return t.save.kind!=="grant"?null:l.jsx(rr,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},za=new Set,Za=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=I(),a=i.useCallback(()=>r.peek(e),[r,e]),d=i.useCallback(()=>r.peekSeeded(e),[r,e]),m=i.useSyncExternalStore(r.subscribe,a,d),w=i.useCallback(()=>r.answerStampOf(e),[r,e]),c=i.useSyncExternalStore(r.subscribe,w,w),[f]=i.useState(()=>new Set),[g,v]=i.useState(za),[x,R]=i.useState(null);x!==null&&(x.path!==e||x.markup!==n)&&R(null);const O=i.useRef(null);i.useLayoutEffect(()=>(O.current=e,()=>{O.current=null}),[e]);const j=i.useRef(n);i.useLayoutEffect(()=>{j.current=n},[n]);const N=i.useCallback(()=>{const u=e,h=r.peek(u);f.has(u)||h?.status==="pending"||(f.add(u),v(new Set(f)),R(null),(async()=>{try{const k=await r.refresh(u);if(O.current!==u||k.status==="superseded")return;if(k.status==="failed"){R({path:u,failure:k.failure,stamp:r.answerStampOf(u),markup:j.current}),o.announce(s.documentRefreshFailed(te(s,k.failure.reason)));return}if(k.status==="shown"&&(t||k.failed))return;const A=oe(r.peek(u));if(A===null||A.document.kind==="failure")return;o.announce(s.documentRefreshed(A.document.name))}finally{f.delete(u),v(new Set(f))}})())},[e,t,f,r,o,s]),$=g.has(e),P=x!==null&&x.path===e&&x.stamp===c&&x.markup===n?x.failure:null;return{refreshing:$,unavailable:$||m?.status==="pending",failure:P,refresh:N}},Ga=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},ir=Object.freeze({kind:"page"}),cr=({path:e,placement:t,markup:n})=>{const{labels:r}=I(),{refreshing:o,unavailable:s,failure:a,refresh:d}=Za(e,t.kind==="page",n.shown),m=_s(e),w=Da(e),c=wn(e),f=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,g=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,v=t.kind==="panel",x=t.kind==="panel"?t.documentName:w.name,R=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":c===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:l.jsx(Ia,{session:c}),c===void 0?null:l.jsx(Ua,{path:e,documentName:x,iconOnly:v,session:c,previewAvailable:R}),c===void 0&&m!==null?l.jsxs("button",{type:"button",className:g===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:g===null?Ga(r,m):g,"aria-label":g===null?void 0:g,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:re,children:[l.jsx(tr,{"aria-hidden":"true"}),g===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,c!==void 0||w.edit?.kind==="inline"||w.edit?.kind==="draft"?l.jsx(_a,{path:e,documentName:x,iconOnly:v,previewAvailable:R,draft:w.edit?.kind==="draft"}):w.edit?.kind==="external"?l.jsx(Fa,{href:w.edit.href,documentName:x,iconOnly:v}):null,c===void 0?l.jsxs("button",{type:"button",className:f===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:f===null?r.refreshDocument:f,"aria-label":f===null?void 0:f,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:d,onDoubleClick:re,children:[l.jsx(er,{"aria-hidden":"true"}),f===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),c!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),c===void 0?null:l.jsx(Va,{path:e,session:c})]})},Ka=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Bn(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Ae,children:[l.jsx(cr,{path:t,placement:ir,markup:r}),l.jsx(Jn,{path:t,absence:Xn,markup:e.markup,variant:n})]})},dr=({holds:e,testId:t})=>{const{labels:n,announcer:r}=I(),o=i.useId();i.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=i.useCallback(()=>r.shownIn(o),[r,o]),a=i.useSyncExternalStore(r.subscribe,s,s);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:a.length>1?n.announcementSequence(a):a[0]})},ce=Object.freeze([]),Wa=e=>{const t=new Set;let n=ce,r=[],o=!1;const s=[],a=c=>{n=c;for(const f of[...t])f()},d=()=>s.at(-1)?.region,m=c=>{const f=d();c(),d()!==f&&n!==ce&&a(ce)},w=()=>{o=!1;const c=r.map(f=>"sentence"in f?f.sentence:f.list(f.items));r=[],a(Object.freeze(c))};return{announce:c=>{if(typeof c=="string")r.push({sentence:c});else{const f=r.find(g=>"list"in g&&g.list===c.list);f!==void 0&&"items"in f?f.items.push(c.item):r.push({list:c.list,items:[c.item]})}o||(o=!0,n!==ce&&a(ce),e.request(w))},subscribe:c=>(t.add(c),()=>{t.delete(c)}),claim:c=>{const f={region:c};return m(()=>s.push(f)),()=>m(()=>{const g=s.indexOf(f);g!==-1&&s.splice(g,1)})},shownIn:c=>d()===c?n:ce}},ne=Object.freeze({status:"cancelled"}),Ht=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(D.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return D.failureOf(n,r)},Xa=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,f)=>globalThis.fetch(c,f)),o=(c,f)=>`${e}/${c}?${new URLSearchParams(f).toString()}`,s=c=>{c.status===401&&t(null);const f=c.headers.get(D.EXPLORER_SCOPE_HEADER);f!==null&&t(f)},a=async(c,f,g,v)=>{let x;try{x=await r(c,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return v({reason:"failed"})}s(x);let R;try{R=await x.json()}catch{return v({reason:D.failureReasonOfStatus(x.status)})}let O;try{O=g(R)}catch{O=!1}if(O)return R;const j=Ht(R);return v(j!==null?j:{reason:x.status===200?"failed":D.failureReasonOfStatus(x.status)})},d={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_REFRESH_PROOF},m={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_EDIT_PROOF,"Content-Type":`${D.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},w=async(c,f,g)=>{const v=await a(c,f,g,x=>D.failureDocument(x.reason,x.code));return f.signal.aborted?ne:v};return{tree:c=>a(o("tree",{[D.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},D.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(c,f,g)=>{const v=await a(o("children",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:g},D.isExplorerChildrenResult,x=>({status:"error",failure:x}));return g.aborted?ne:v},ancestors:async(c,f,g)=>{const v=await a(o("ancestors",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:g},D.isExplorerAncestorsResult,x=>({status:"error",failure:x}));return g.aborted?ne:v},reveal:async(c,f,g)=>{const v=await a(o("reveal",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:g},D.isExplorerRevealResult,x=>({status:"error",failure:x}));return g.aborted?ne:v},document:(c,{refresh:f})=>a(o("document",{[D.EXPLORER_DATA_QUERY.path]:c}),f?{method:"GET",headers:d}:{method:"GET"},D.isExplorerDocument,g=>D.failureDocument(g.reason,g.code)),text:async(c,f)=>{const g=await a(o("text",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerTextAnswer,v=>D.failureDocument(v.reason,v.code));return f.aborted?ne:g},asset:async(c,f)=>{let g;try{g=await r(c,{method:"GET",credentials:"same-origin",signal:f})}catch{return f.aborted?ne:{status:"error",failure:{reason:"failed"}}}if(s(g),g.ok)return f.aborted?ne:{status:"ok",body:g.body===null?new ReadableStream({start:R=>R.close()}):g.body};let v=null;try{v=await g.json()}catch{}if(f.aborted)return ne;const x=Ht(v);return{status:"error",failure:x===null?{reason:D.failureReasonOfStatus(g.status)}:x}},edit:(c,f)=>w(o("edit",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerEditAnswer),save:(c,f,g,v)=>w(o("save",{[D.EXPLORER_DATA_QUERY.path]:c,[D.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:m,body:g,signal:v},D.isExplorerSaveAnswer),preview:(c,f,g)=>w(o("preview",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"POST",headers:m,body:f,signal:g},D.isExplorerPreviewAnswer),revisions:(c,f)=>w(o("revisions",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerRevisionsAnswer),revision:(c,f,g)=>w(o("revision",{[D.EXPLORER_DATA_QUERY.path]:c,[D.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:g},D.isExplorerRevisionAnswer),refresh:c=>a(o("refresh",{[D.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:d},D.isExplorerTreeResult,f=>({status:"error",failure:f}))}},Ya=()=>{let e=null,t=null;return{settle:n=>{e=n},mayMove:n=>e!==n,move:(n,r,o)=>{e=r,t={sourceId:n,path:r,ancestors:o}},take:(n,r)=>{const o=t!==null&&t.sourceId===n&&t.path===r?t.ancestors:null;return t=null,o}}},Qa=e=>{const t=Q.readStorage(e);if(t===null)return V.NO_TREE_SETTING_CHANGES;try{return V.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),V.NO_TREE_SETTING_CHANGES}},Ut=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Qa(e);n={changes:s,settings:V.applyTreeSettingChanges(t,s)}}return n},o=me();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:d}=r(),m=V.recordTreeSettingChange(a,s,V.advanceTreeSetting(d,s)[s],t);return n={changes:m,settings:V.applyTreeSettingChanges(t,m)},o.emit(),Q.writeStorage(e,V.serializeTreeSettingChanges(m)),n.settings}}},Ja=Object.freeze({status:"refreshed"}),el=Object.freeze({status:"superseded"}),ot=Object.freeze({status:"deferred"}),tl=hn(ot),ur=4,nl=ur-1,Vt=Object.freeze({status:"loading"}),rl=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ol=e=>{const t=new Map,n=jn(),r=new Map,o=new Map,s=new Map,a=new Map,d=me(),m=new Set;let w=0,c=0;const f={direct:null,bulk:null},g=new Set;let v=!1,x=0;const R=()=>{x+=1,d.emit()},O=p=>o.get(p)??0,j=p=>{let b=a.get(p);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(p,b)),b},N=(p,b,y)=>{p.inFlight.delete(b),w-=1,y.lane==="bulk"&&(c-=1)},$=p=>{const b=a.get(p);if(b!==void 0){for(const[y,C]of[...b.inFlight])N(b,y,C),C.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},P=p=>{const b=O(p)+1;return o.set(p,b),$(p),b},u=(p,b)=>{const y=he(p),C={promise:p,opened:b,stale:!1,loadedAt:y?.status==="ok"?y.loadedAt:null};return p.status==="pending"&&p.then(H=>{H.status==="ok"&&(C.loadedAt=H.loadedAt)}),C},h=p=>{let b=r.get(p);return b===void 0&&(b=new Map,r.set(p,b)),b},k=p=>{const b=[...a.keys()],y=f[p],C=y===null?0:b.indexOf(y)+1;for(let H=0;H<b.length;H+=1){const Z=b[(C+H)%b.length],W=Z===void 0?void 0:a.get(Z);if(!(Z===void 0||W===void 0)){for(const G of W[p])if((W.claims.get(G)??0)!==0)return W[p].delete(G),f[p]=Z,{sourceId:Z,path:G}}}return null},A=(p,b,y,C)=>{const H=a.get(p);if(H===void 0||H.inFlight.get(b)!==y)return;N(H,b,y);const Z=(H.claims.get(b)??0)>0,W=h(p);if(C.status==="ok"?W.set(b,{status:"loaded",entries:C.entries}):C.status==="error"&&Z?W.set(b,{status:"failed",failure:C.failure}):W.delete(b),R(),C.status==="error"&&Z){const G={sourceId:p,path:b,failure:C.failure};for(const ee of[...m])ee(G)}q()},F=(p,b,y)=>{const C={controller:new AbortController,lane:y};j(p).inFlight.set(b,C),w+=1,y==="bulk"&&(c+=1),e.children(p,b,C.controller.signal).then(H=>A(p,b,C,H),()=>A(p,b,C,rl))},q=()=>{for(;w<ur;){const p=k("direct");if(p!==null){F(p.sourceId,p.path,"direct");continue}const b=c<nl?k("bulk"):null;if(b===null)return;F(b.sourceId,b.path,"bulk")}},E=(p,b,y)=>{if(!(b.direct.delete(y)||b.bulk.delete(y))){const H=b.inFlight.get(y);if(H===void 0)return!1;N(b,y,H),H.controller.abort()}return r.get(p)?.delete(y),!0},T=()=>{v=!1;let p=!1;for(const b of g){const y=j(b);for(const C of y.unclaimed)(y.claims.get(C)??0)===0&&E(b,y,C)&&(p=!0);y.unclaimed.clear()}g.clear(),p&&(R(),q())},M=(p,b)=>{t.set(p,u(we(e.tree(p)),b))},L=(p,b,y)=>{P(p);const C=u(hn(b),y);return t.set(p,C),r.delete(p),R(),q(),C},_=(p,b,y,C)=>{if(y!==O(p)||t.get(p)!==b)return;const H=he(b.promise);if(!(C.status!=="ok"||H?.status!=="ok"||b.loadedAt===null||C.loadedAt<=b.loadedAt)){if(je(H.entries,C.entries)){b.loadedAt=C.loadedAt;return}L(p,C,b.opened)}},B=(p,b)=>{const y=t.get(p);return y!==void 0&&he(y.promise)?.status===b},K=(p,b)=>{b.stale=!1;const y=O(p);e.tree(p).then(C=>_(p,b,y,C))};return{read:p=>t.get(p)?.promise??tl,open:p=>{const b=n.resumes(p),y=n.hold(p),C=t.get(p);return C===void 0||B(p,"deferred")?(M(p,!0),R()):b||(C.opened&&B(p,"error")?(M(p,!0),R()):(C.opened=!0,C.stale&&B(p,"ok")&&K(p,C))),y},retry:p=>{B(p,"error")&&(M(p,!0),R())},seed:(p,b)=>{const y=b.then(Z=>Z===null?ot:Z,()=>ot),C=t.get(p);if(C!==void 0&&B(p,"ok")){const Z=O(p);y.then(W=>_(p,C,Z,W));return}P(p);const H=u(we(y),C?.opened===!0);t.set(p,H),r.delete(p),q(),y.then(Z=>{t.get(p)===H&&(Z.status==="deferred"&&n.isHeld(p)&&M(p,H.opened),R())})},refresh:async p=>{const b=(s.get(p)??0)+1;s.set(p,b);const y=await e.refresh(p);if(s.get(p)!==b)return el;if(y.status==="error")return{status:"failed",failure:y.failure};const C=t.get(p);if(!(C!==void 0&&C.loadedAt!==null&&B(p,"ok")&&C.loadedAt>y.loadedAt)){const Z=L(p,y,!0);if(C!==void 0&&C.promise.status==="pending"){const W=O(p);C.promise.then(G=>_(p,Z,W,G))}}for(const[Z,W]of t)Z!==p&&he(W.promise)?.status==="ok"&&(W.stale=!0);return Ja},children:(p,b)=>r.get(p)?.get(b),claimChildren:(p,b)=>{const y=j(p),C=h(p);let H=!1,Z=!1;for(const[G,ee]of b)y.claims.set(G,(y.claims.get(G)??0)+1),C.get(G)===void 0?(C.set(G,Vt),y[ee].add(G),H=!0,Z=!0):ee==="direct"&&y.bulk.delete(G)&&(y.direct.add(G),Z=!0);H&&R(),Z&&q();let W=!1;return()=>{if(!W){W=!0;for(const G of b.keys()){const ee=(y.claims.get(G)??0)-1;ee>0?y.claims.set(G,ee):(y.claims.delete(G),y.unclaimed.add(G))}g.add(p),!v&&(v=!0,queueMicrotask(T))}}},retryChildren:(p,b)=>{const y=r.get(p);if(y===void 0||y.get(b)?.status!=="failed")return;const C=j(p);if((C.claims.get(b)??0)>0){y.set(b,Vt),C.direct.add(b),R(),q();return}y.delete(b),R()},pendingChildren:p=>{const b=a.get(p);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const p of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))P(p);for(const[p,b]of s)s.set(p,b+1);t.clear(),r.clear(),R()},subscribeChildrenFailures:p=>(m.add(p),()=>{m.delete(p)}),subscribe:d.subscribe,version:()=>x}},sl=(e,t)=>{let n=e;const r=me();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},al=1;let Oe=0,se=null;const ll=()=>{const{documentElement:e,body:t}=document;Oe===0&&(se={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"),Oe+=1;let n=!1;return()=>{n||(n=!0,Oe-=1,!(Oe>0||se===null)&&(e.style.overflow=se.htmlOverflow,t.style.overflow=se.bodyOverflow,e.style.scrollbarGutter=se.htmlGutter,t.style.scrollbarGutter=se.bodyGutter,se=null))}},il=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],zt=1,cl=1e3,Zt=e=>e.getClientRects().length>0,Ge="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.",dl=e=>{if(!Zt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+al)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. ${Ge}`;if(t.height<zt)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. ${Ge}`;for(const{selector:r,name:o}of il)for(const s of e.querySelectorAll(r)){if(!Zt(s))continue;const a=s.getBoundingClientRect().height;if(a<zt)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(a))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Ge}`}return null},ul=e=>{let t=!1,n;const r=()=>{n=void 0;const a=dl(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,cl))},s=typeof ResizeObserver>"u"?null:new ResizeObserver(o);return s?.observe(e),window.addEventListener("resize",o),o(),()=>{clearTimeout(n),s?.disconnect(),window.removeEventListener("resize",o)}},fl=(e,t)=>{i.useEffect(()=>e?ll():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ul(n)},[e,t])},Gt='[data-testid="markdown-explorer-view-switch"]',ml=[{control:Gt,successors:[Gt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],hl=e=>{for(const t of ml){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},pl=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=d=>{const m=e.current;n.current=m!==null&&d instanceof Element&&m.contains(d)?hl(d):null},s=d=>o(d.target);o(document.activeElement);const a=d=>{const m=d.target;d.relatedTarget!==null||!(m instanceof Element)||queueMicrotask(()=>{n.current?.element===m&&m.isConnected&&document.activeElement!==m&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=i.useRef(t);i.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const m=document.activeElement;if(m!==null&&m!==document.body&&m!==o.element)return!0;const w=e.current;if(w===null)return!0;for(const c of o.control.successors)for(const f of w.querySelectorAll(c))if(f!==o.element&&(f.focus({preventScroll:!0}),document.activeElement===f))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const d=new MutationObserver(()=>{s()&&d.disconnect()});return d.observe(a,{childList:!0,subtree:!0}),()=>d.disconnect()},[t,e])},gl=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-C6QDpEBS.cjs")).then(e=>({default:e.TreeLayout}))),wl=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-B_yMVDt_.cjs")).then(e=>({default:e.MultiLayout}))),vl=64,El={request:e=>{requestAnimationFrame(e)}},Kt=e=>{e.documents.clear(),e.trees.clear()},Ke=(e,t)=>{t.tree!==null&&e.trees.seed(t.tree.sourceId,t.tree.result);for(const{path:n,document:r}of t.documents)e.documents.seed(n,r)},xl=(e,t)=>{const[n,r]=i.useState(()=>({overrides:t,locale:e,labels:Je(e,t)}));if(n.locale===e&&Lr(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Je(e,t)};return r(o),o.labels},bl=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:Ut(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Ut(e,n)};return o(s),s.store},We=(e,t)=>{const[n,r]=i.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Sl=()=>Wa(El),Wt="on",yl="off",kl=Object.freeze({kind:"unavailable"}),Rl=e=>{if(e!==void 0&&(e===null||typeof e!="object"||typeof e.convert!="function"))throw new TypeError("[markdown-explorer] draftConverter must be an object with a convert function")},Tl=(e,t)=>{const n=oe(e.peek(t));return n===null||n.document.kind==="failure"?D.lastPathSegment(t):n.document.name},Ol=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:d,lockDocumentScroll:m=!1,onMathDiagnostics:w,onEditGrant:c,draftConverter:f})=>{Q.assertStorageNamespace(n),Rl(f);const g=nn(r),v=Cr(s),x=xl(g,o),{revalidate:R}=J.useRevalidator(),O=i.useRef(()=>{}),j=J.useHref(t.dataPath),[N]=i.useState(()=>{const y=Xa({dataPath:j,onScope:H=>O.current(H)}),C={documents:go({client:y,capacity:Math.max(vl,t.multiView.maxPanels*2)}),trees:ol(y)};return Ke(C,e),Q.syncStorageScope(n,e.scope),{data:y,...C,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(N.aligned.pageData!==e||N.aligned.storageNamespace!==n){const y=N.aligned.pageData;N.aligned.pageData=e,N.aligned.storageNamespace=n,y!==e&&(y.scope!==e.scope?N.aligned.pendingReader=e:Ke(N,e)),Q.syncStorageScope(n,e.scope)}const $=bl(Q.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const y=N.aligned.pendingReader;y!==null&&(N.aligned.pendingReader=null,Kt(N),Ke(N,y))},[e,N]),i.useLayoutEffect(()=>{let y=!1;return O.current=C=>{C===e.scope||y||(y=!0,C!==null&&(Kt(N),Q.clearExplorerStorage(n)),R())},()=>{O.current=()=>{}}},[e,R,N,n]);const P=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{P.current=t.settingsCookie},[t.settingsCookie]);const[u]=i.useState(()=>sl(e.settings,y=>{document.cookie=V.viewSettingsCookieString(P.current,y,window.location.protocol==="https:")})),h=We(e.scope,Sl),k=We(e.scope,Ya),A=i.useRef(x);i.useLayoutEffect(()=>{A.current=x},[x]);const F=We(e.scope,()=>_r({data:N.data,conflictLabels:()=>({ours:A.current.conflictOurs,theirs:A.current.conflictTheirs}),onSaveSettled:(y,C)=>{C.kind==="saved"&&N.documents.refresh(y);const H=Mr(A.current,C,Tl(N.documents,y));H!==null&&h.announce(H)},sideBySideSetting:{read:()=>Q.readStorage(Q.storageKeys(n).editPreview)===Wt,write:y=>Q.writeStorage(Q.storageKeys(n).editPreview,y?Wt:yl)},editorShareSetting:{read:()=>Dr(Q.readStorage(Q.storageKeys(n).editSplit)),write:y=>Q.writeStorage(Q.storageKeys(n).editSplit,String(y))}})),q=i.useMemo(()=>we(e.notices.catch(()=>[])),[e.notices]),E=e.sources.map(y=>y.id).join(`
12
- `),T=i.useMemo(()=>V.withExplorerSources(t,E.split(`
13
- `)),[t,E]),M=i.useRef(w);i.useLayoutEffect(()=>{M.current=w},[w]);const[L]=i.useState(()=>(y,C)=>{M.current?.(y,C)}),_=w===void 0?void 0:L,B=i.useRef(f);i.useLayoutEffect(()=>{B.current=f},[f]);const[K]=i.useState(()=>{let y=!1;return{convert:(C,H)=>{const Z=B.current;return Z===void 0?Promise.resolve(kl):Z.convert(C,H)},prepare:()=>{try{B.current?.prepare?.()}catch(C){if(y)return;y=!0,console.error("[markdown-explorer] the draft converter's prepare threw",C)}}}}),p=f===void 0?void 0:K,b=i.useMemo(()=>({config:T,labels:x,locale:g,theme:v,storageNamespace:n,scope:e.scope,sources:e.sources,notices:q,documents:N.documents,trees:N.trees,data:N.data,viewSettings:u,treeSettings:$,announcer:h,reveals:k,edits:F,onEditGrant:c,draftConverter:p,renderTreeFailure:d,reportMathDiagnostics:_}),[T,x,g,v,n,e.scope,e.sources,q,N,u,$,h,k,F,c,p,d,_]);return l.jsx(rn,{value:b,children:l.jsx(Cl,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Ll=({ref:e,theme:t,view:n,children:r})=>{const[o]=i.useState(rs);return l.jsx("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})},Cl=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=I(),o=Pe(),{hash:s}=J.useLocation(),a=Ee(),d=i.useRef(null);fl(t,d),i.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,w=m.view;pl(d,w);const c=m.view==="tree"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Ae}),children:l.jsx(gl,{location:m})}):m.view==="multi"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Ae}),children:l.jsx(wl,{location:m})}):l.jsx(Ka,{location:m}),f=l.jsxs(Ll,{ref:d,theme:n,view:w,children:[c,l.jsx(Xr,{}),l.jsx(dr,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?f:e({view:w,children:f})},Al=Sr.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Ne;exports.CONFLICT_OURS_MARKER=sn;exports.CONFLICT_SEPARATOR=an;exports.CONFLICT_THEIRS_MARKER=ln;exports.CONTENT_PANE=Ae;exports.ContentSkeleton=be;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Xt;exports.DocumentPane=Jn;exports.DocumentRefreshBar=cr;exports.EXPLORER_THEMES=et;exports.EditGrantNotice=rr;exports.ExplorerLink=Ln;exports.FOLDER_README_LOADING=pn;exports.FailureView=fe;exports.ForwardRef=er;exports.ForwardRef$1=nr;exports.ImageViewMemoryContext=In;exports.LazyNativeScrollBar=An;exports.LiveRegion=dr;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=tn;exports.MARKDOWN_EXPLORER_LABEL_KEYS=at;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Jt;exports.MARKDOWN_EXPLORER_LOCALES=Qe;exports.MarkdownExplorer=Ol;exports.NO_DOCUMENT=Xn;exports.PAGE_DOCUMENT_REFRESH=ir;exports.anchorOfDoubleClick=Sn;exports.anchorOfView=yn;exports.blockAtLine=Tn;exports.chooseEditView=rt;exports.consumeKey=lt;exports.createEmitter=me;exports.cssPixels=dn;exports.editViewOf=or;exports.explorerNavigationOptions=uo;exports.failureTitleOf=te;exports.findConflictsInLines=cn;exports.focusWithoutScroll=dt;exports.frameTopOf=kn;exports.isApplePlatform=ar;exports.isEditViewShortcut=lr;exports.isEditingDoubleClick=bn;exports.lineTopIn=On;exports.loadedOf=oe;exports.paneShownAlone=Na;exports.positionInSource=io;exports.readFolderReadme=gn;exports.resolveMarkdownExplorerLabels=Je;exports.shouldRevalidateExplorer=Al;exports.toggledEditView=sr;exports.useExplorer=I;exports.useExplorerLocation=Pe;exports.useExplorerNavigate=Ee;exports.useIntentPrefetch=Cn;exports.usePageMarkupToggle=Bn;exports.useSideBySide=En;exports.useViewSetting=ge;exports.visibleTopOf=Rn;
@@ -1 +0,0 @@
1
- "use strict";const I=require("@aiquants/markdown/embeds"),k=require("@aiquants/markdown/viewer-settings"),N=require("./dataRoute-Cv7fgCW7.cjs"),y=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},De=Object.freeze(["UTF-8","IBM866","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-8-I","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic","GBK","gb18030","Big5","EUC-JP","ISO-2022-JP","Shift_JIS","EUC-KR","replacement","UTF-16BE","UTF-16LE","x-user-defined"]),ve=new Map(De.map(e=>[e.toLowerCase(),e])),$="UTF-8",te=Object.freeze([Object.freeze({bytes:Object.freeze([239,187,191]),encoding:$}),Object.freeze({bytes:Object.freeze([255,254]),encoding:"UTF-16LE"}),Object.freeze({bytes:Object.freeze([254,255]),encoding:"UTF-16BE"})]),je=new Map([[$,"is read before any legacy encoding"],["UTF-16LE","is read only by its byte order mark"],["UTF-16BE","is read only by its byte order mark"],["ISO-2022-JP","writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],["x-user-defined","is no text encoding (it maps bytes to private-use characters)"]]),q=e=>{let t;try{t=new TextDecoder(e).encoding}catch(o){throw o instanceof RangeError?new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`):o}const n=ze(t),r=je.get(n);if(r!==void 0)throw new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} names ${n}, which cannot be the legacy encoding: it ${r}`);return n},ze=e=>{const t=ve.get(e);if(t===void 0)throw new RangeError(`[markdown-explorer] TextDecoder answered ${JSON.stringify(e)}, which is no encoding of the WHATWG Encoding Standard`);return t},Y=(e,t,n)=>{const r=n===null?null:q(n),o=te.find(({bytes:s})=>s.every((a,l)=>e[l]===a));if(o!==void 0)return{body:e.subarray(o.bytes.length),encodings:[o.encoding]};const i=t||e.length===0?void 0:te.find(({bytes:s})=>e.length<s.length&&e.every((a,l)=>s[l]===a));return i!==void 0?{body:e.subarray(e.length),encodings:[i.encoding]}:{body:e,encodings:r===null?[$]:[$,r]}},Fe=(e,t,n)=>Y(e,t,n).encodings,Ue=(e,t,n)=>{try{return new TextDecoder(e,{fatal:!0,ignoreBOM:!0}).decode(t,{stream:!n})}catch(r){if(r instanceof TypeError)return null;throw r}},Ve=(e,t,n)=>fe(Y(e,t,n),t),fe=({body:e,encodings:t},n)=>{for(const r of t){const o=Ue(r,e,n);if(o!==null)return o}return null},Ge=(e,t,n)=>{const r=Y(e,t,n),o=fe(r,t);return o!==null?o:new TextDecoder(r.encodings[0],{ignoreBOM:!0}).decode(r.body,{stream:!t})},A=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),Xe=/^readme(?:\.|$)/iu,ne=/^readme(?:\.[^.]*)?$/iu,re=Object.freeze(["md","markdown","mdx","txt",""]),Je=e=>Xe.test(e),X=e=>e.type==="file"&&Je(e.name),oe=e=>{const t=e.lastIndexOf("."),n=re.indexOf(t<0?"":e.slice(t+1).toLowerCase());return n<0?re.length:n},Be=(e,t)=>{const n=+!ne.test(e.name)-+!ne.test(t.name);if(n!==0)return n;const r=oe(e.name)-oe(t.name);if(r!==0)return r;const o=A.compare(e.name,t.name);return o!==0?o:A.compare(e.path,t.path)},We=e=>{let t=null;for(const n of e)X(n)&&(t===null||Be(n,t)<0)&&(t=n);return t===null?null:t.path},J=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),He=[!0,!1],Ke=(e,t)=>t?e.settingOn:e.settingOff,p=(e,t)=>({key:e,labelKey:t,values:He,formatValue:Ke,requiresItemSelection:!1}),qe=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),T=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,t)=>qe[t](e),requiresItemSelection:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.folderPlacementMixed:t==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresItemSelection:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.readmePlacementMixed:t==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresItemSelection:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},p("alwaysExpanded","settingAlwaysExpanded"),p("revealDocument","settingRevealDocument"),p("removeRootIndent","settingRemoveRootIndent"),p("lines","settingTreeLines"),p("expandIcons","settingExpandIcons"),p("directoryIcons","settingDirectoryIcons"),p("fileIcons","settingFileIcons")]),Ye=e=>e?T:T.filter(t=>!t.requiresItemSelection),ue=e=>{const t=T.find(n=>n.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},Ze=(e,t)=>{const n=ue(t).values,r=n[(n.indexOf(e[t])+1)%n.length];return{...e,[t]:r}},Qe=(e,t,n)=>ue(n).formatValue(e,t[n]),ge=2,B=Object.freeze({}),Z=(e,t)=>Object.freeze(Object.fromEntries(T.filter(n=>t(n,e[n.key])).map(n=>[n.key,e[n.key]]))),ie="directoriesFirst",et=e=>{if(!Object.hasOwn(e,ie))return e;const{[ie]:t,...n}=e;return Object.hasOwn(n,"folderPlacement")||typeof t!="boolean"?n:{...n,folderPlacement:t?"first":"mixed"}},tt=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return B;const t=e;return t.version!==ge||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?B:Z(et(t.settings),(n,r)=>n.values.includes(r))},nt=(e,t)=>{const n=Z(t,(r,o)=>o!==void 0&&o!==e[r.key]);return Object.keys(n).length===0?e:Object.freeze({...e,...n})},rt=(e,t,n,r)=>Z({...e,[t]:n},(o,i)=>i!==void 0&&!(o.key===t&&i===r[t])),ot=e=>JSON.stringify({version:ge,settings:e}),it=(e,t,n)=>e===void 0||t===void 0?e===t?0:e===void 0?1:-1:n*(e-t),st=e=>{const{sortMode:t,folderPlacement:n,readmePlacement:r}=e;if(t==="native"&&n==="mixed"&&r==="mixed")return;const o=(i,s)=>{const a=A.compare(i.name,s.name);return a!==0?a:A.compare(i.path,s.path)};return(i,s)=>{if(n!=="mixed"&&i.type!==s.type)return i.type==="directory"==(n==="first")?-1:1;if(r!=="mixed"){const l=X(i);if(l!==X(s))return l===(r==="first")?-1:1}if(t==="native")return 0;if(t==="asc")return o(i,s);if(t==="desc")return-o(i,s);const a=it(i.modifiedAt,s.modifiedAt,t==="oldest"?1:-1);return a!==0?a:o(i,s)}},u=(1+Math.sqrt(5))/2,at=100/u**3,ct=100/u**4,Q=100/u**2,Ee=13,lt=16,dt=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),mt=Object.freeze([89,144,233,377]),we=44,ft=we,ut=24,gt=1/u,Et=1/u**3,wt="40ch",ht=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},he=e=>(ht(e),Ee*e),pt=e=>he(e)*u**2,St=233,xt=50,pe=100/u**3,Ot=100-pe,yt=mt[0],w=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},Tt=({trackInlineSize:e,gap:t,minColumnInlineSize:n,logicalColumns:r})=>{if(w("trackInlineSize",e),w("gap",t),!Number.isFinite(n)||n<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(n)}`);if(!Number.isInteger(r)||r<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(r)}`);const o=Math.floor((e+t)/(n+t));return Math.min(r,Math.max(1,o))},bt=(e,t)=>{const{trackInlineSize:n,gap:r,minColumnInlineSize:o,logicalColumns:i}=t;if(!([n,r,o].every(Number.isFinite)&&n>0&&r>=0&&o>0))return e;const a=Tt(t);if(e===null||a===e)return a;const l=Math.min(i,Math.max(1,e));if(a>l){const D=(l+1)*o+l*r+r/u;return n>=D?a:l}return n>=l*o+(l-1)*r?l:a},_t=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(n,r)=>[Math.floor(r*e/t),Math.floor((r+1)*e/t)])},Rt=(e,t,n)=>{if(w("surfaceInlineSize",e),w("handlePixels",n),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);return e>=2*t+n?"beside":"stacked"},G=(e,t,n)=>Math.max(t,Math.min(e,n)),se=(e,t,n,r)=>{const o=(G(e,0,n)+G(t,0,n))/2;return G(o-r/2,0,n-r)},It=(e,t,n)=>{for(const[r,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${r} must be a finite number; got ${String(o)}`);return w("marginBox.width",t.width),w("marginBox.height",t.height),w("viewport.width",n.width),w("viewport.height",n.height),{left:se(e.left,e.right,n.width,t.width),top:se(e.top,e.bottom,n.height,t.height)}},kt=31536e3,Nt=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,At=e=>{if(typeof e!="string"||!Nt.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},ae=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=Q,Pt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const n=e,{treeExplorer:r,multiExplorer:o,style:i,align:s}=n;return{...ae(r)?{treeExplorer:r}:{},...ae(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof s=="string"&&k.CONTENT_ALIGNS.includes(s)?{align:s}:{}}},Lt=(e,t)=>{if(e!==null)for(const n of e.split(";")){const r=n.indexOf("=");if(!(r<0)&&n.slice(0,r).trim()===t)return n.slice(r+1).trim()}},$t=(e,t)=>{if(e===void 0||e==="")return{};try{return Pt(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},C=100,Ct=Math.floor(Q*C)/C,Mt=e=>{const t=n=>Math.min(Ct,Math.max(1,Math.round(n*C))/C);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},Dt=(e,t,n)=>`${e}=${Mt(t)}; Path=/; Max-Age=${String(kt)}; SameSite=Lax${n?"; Secure":""}`,W=Object.freeze({tree:"tree",multi:"multi",single:"single"}),Se=Object.freeze({default:12,min:1,max:64}),xe=Object.freeze({default:4,min:1,max:6}),Oe=Object.freeze({default:500,min:1,max:1e4}),ye=Object.freeze({default:16,min:1,max:64}),Te=Object.freeze({default:16,min:1,max:64}),be=Object.freeze({default:2*1024*1024,min:1,max:256*1024*1024}),vt=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,jt=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,zt=/^[a-z0-9][a-z0-9-]*$/u,Ft=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,ce=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!vt.test(t)||t.split("/").some(n=>n==="."||n===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},m=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?y(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),le=Object.freeze(Object.keys({basePath:!0,dataPath:!0,settingsCookie:!0,views:!0,multiView:!0,expandAll:!0,revealDocument:!0,documentStyles:!0,iframeHosts:!0,embeds:!0,defaultTreeSettings:!0,legacyTextEncoding:!0,spreadsheets:!0})),S=(e,t,n)=>{if(t===void 0)return[];if(!y(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${m(t)}`);const r=Object.entries(t);for(const[o]of r)if(!n.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${n.join(", ")}`);return r.filter(([,o])=>o!==void 0)},Ut=e=>{const t={...W};for(const[n,r]of S("views",e,Object.keys(W)))t[n]=r;for(const[n,r]of Object.entries(t))if(typeof r!="string"||!jt.test(r))throw new RangeError(`[markdown-explorer] views.${n} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(r)}`);return Object.freeze(t)},O=(e,t,n)=>{if(t===void 0)return n.default;if(typeof t!="number"||!Number.isInteger(t)||t<n.min||t>n.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${m(t)}`);return t},Vt=(e,t)=>{const n=new Map(S("embeds",e,["providers","linkCards","linkCardSize"]));if(n.size===0)return I.NO_EMBEDS;const r=n.has("providers")?n.get("providers"):[];if(!Array.isArray(r))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${m(r)}`);for(const a of r)if(!I.isEmbedProviderId(a))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${I.EMBED_PROVIDER_IDS.join(", ")}; got ${m(a)}`);const o=n.has("linkCards")?n.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${m(o)}`);const i={providers:Object.freeze([...new Set(r)]),linkCardEndpoint:o?N.explorerLinkCardEndpoint(t):null};if(!n.has("linkCardSize"))return Object.freeze(i);const s=n.get("linkCardSize");if(!I.isLinkCardSize(s))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${I.LINK_CARD_SIZES.join(", ")}; got ${m(s)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${m(s)} with linkCards ${m(o)}`);return Object.freeze({...i,linkCardSize:s})},Gt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${m(e)}`);return q(e)},Xt=e=>{const t=new Map(S("defaultTreeSettings",e,T.map(r=>r.key)));if(t.size===0)return J;const n={...J};for(const r of T){if(!t.has(r.key))continue;const o=t.get(r.key),i=r.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${i.map(m).join(", ")}; got ${m(o)}`);n[r.key]=o}return Object.freeze(n)},_e=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");for(const c of Object.keys(e))if(!le.includes(c))throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${le.join(", ")}`);ce("basePath",e.basePath),ce("dataPath",e.dataPath);const t=Ut(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const c=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(c===t.tree||c===t.multi||c===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}At(e.settingsCookie);const n=e.iframeHosts??[];if(!Array.isArray(n)||n.some(c=>typeof c!="string"||!Ft.test(c)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(n)}`);const r=Object.fromEntries(S("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(S("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=Object.fromEntries(S("revealDocument",e.revealDocument,["maxDepth"])),s=Object.fromEntries(S("spreadsheets",e.spreadsheets,["maxBytes"])),a=e.documentStyles??k.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(a)||a.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const l=new Set;for(const c of a){if(c===null||typeof c!="object"||typeof c.name!="string"||c.name.trim()===""||typeof c.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(l.has(c.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(c.name)} repeats`);l.add(c.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:O("multiView.maxPanels",r.maxPanels,Se),columns:O("multiView.columns",r.columns,xe)}),expandAll:Object.freeze({maxFolders:O("expandAll.maxFolders",o.maxFolders,Oe),maxDepth:O("expandAll.maxDepth",o.maxDepth,ye)}),revealDocument:Object.freeze({maxDepth:O("revealDocument.maxDepth",i.maxDepth,Te)}),documentStyles:Object.freeze(a.map(c=>Object.freeze({name:c.name,className:c.className}))),iframeHosts:Object.freeze([...new Set(n)]),embeds:Vt(e.embeds,e.dataPath),defaultTreeSettings:Xt(e.defaultTreeSettings),legacyTextEncoding:Gt(e.legacyTextEncoding),spreadsheets:Object.freeze({maxBytes:O("spreadsheets.maxBytes",s.maxBytes,be)})})},Jt=e=>{const t=e.embeds;if(!y(t))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${m(t)}`);if(Object.hasOwn(t,"linkCards"))throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${m(t.linkCards)})`);const n=e.legacyTextEncoding;if(n!==null&&typeof n!="string")throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${m(n)}`);const{linkCardEndpoint:r,...o}=t,i=_e({...e,embeds:{...o,linkCards:r!==null},legacyTextEncoding:n===null?void 0:n});if(i.embeds.linkCardEndpoint!==r)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${m(i.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${m(r)}`);if(i.legacyTextEncoding!==n)throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${m(i.legacyTextEncoding)} (the written name of the encoding it names); got ${m(n)}`);const s=e;for(const[a,l]of Object.entries(i)){const c=H(s[a],l,a);if(c!==null)throw c.kind==="extra"?new RangeError(`[markdown-explorer] config.${c.path} is not a key of what defineExplorerConfig resolves; got ${m(c.given)} there`):new RangeError(`[markdown-explorer] config.${c.path} must be what defineExplorerConfig resolves; got ${m(c.given)} where it resolves ${m(c.resolved)}`)}return i},H=(e,t,n)=>{if(Object.is(e,t))return null;if(Array.isArray(t)){if(!Array.isArray(e))return{kind:"value",path:n,given:e,resolved:t};if(e.length!==t.length)return{kind:"value",path:`${n}.length`,given:e.length,resolved:t.length};for(const[o,i]of t.entries()){const s=H(e[o],i,`${n}[${String(o)}]`);if(s!==null)return s}return null}if(!(y(t)&&y(e)))return{kind:"value",path:n,given:e,resolved:t};for(const o of Object.keys(t)){const i=H(Object.hasOwn(e,o)?e[o]:void 0,t[o],`${n}.${o}`);if(i!==null)return i}const r=Object.keys(e).find(o=>!Object.hasOwn(t,o));return r===void 0?null:{kind:"extra",path:`${n}.${r}`,given:e[r]}},Re=e=>typeof e=="string"&&zt.test(e),Bt=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${m(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${m(t)}`);for(const n of t)if(!Re(n))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${m(n)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},Wt=e=>e.documentStyles.map(t=>t.name),d=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),Ie="true",M="/",de=".data",ke=256,Ne=/^\d+(?:\.\d+)?$/u,K=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,Ae=Object.freeze(["showToc","showStyle","showAlign"]),me=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(de)?`${t.slice(0,-de.length)}%2Edata`:t},Ht=e=>e.replaceAll("%25","%"),Pe=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},Kt=(e,t,n)=>{const r=n.getAll(d.source);if(r.length===0)return t;const[o]=r;return r.length>1||o===void 0||o===t||!e.includes(o)?null:o},qt=(e,t)=>{const n=t.get(d.style),r=t.get(d.align);return{...n!==null&&e.documentStyles.some(o=>o.name===n)?{style:n}:{},...r!==null&&k.CONTENT_ALIGNS.includes(r)?{align:r}:{}}},Le=e=>Number.isFinite(e)&&e>=0&&e<=ke&&Ne.test(String(e)),Yt=e=>{const t=e.get(d.padding),n=t!==null&&Ne.test(t)?Number(t):Number.NaN,r=e.get(d.width),o=e.get(d.maxWidth);return{...e.get(d.showToc)==="false"?{showToc:!1}:{},...e.get(d.showStyle)==="false"?{showStyle:!1}:{},...e.get(d.showAlign)==="false"?{showAlign:!1}:{},...Le(n)?{padding:n}:{},...r!==null&&K.test(r)?{width:r}:{},...o!==null&&K.test(o)?{maxWidth:o}:{}}},$e=(e,t)=>[...new Set(t.filter(N.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),Zt=(e,t,n,r)=>{for(const i of t)ee(i);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);if(t.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);if(n!==null&&!t.includes(n))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(n.slice(0,80))}`);if(new Set(r).size!==r.length)throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(r.length)} with repeats`);const o=r.find(i=>!t.includes(i));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0,80))}`)},ee=e=>{if(!N.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},Qt=e=>{if(ee(e).endsWith(M))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0,80))}`);return e},en=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(n=>n.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(n=>JSON.stringify(n.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!k.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${k.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},tn=e=>{for(const t of Ae)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!Le(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const n=e[t];if(n!==void 0&&!K.test(n))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(n)}`)}},Ce=(e,t)=>{const n=new URLSearchParams;let r=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],s=t.maximized??null,a=t.markup??[];Zt(e,i,s,a);for(const l of i)n.append(d.doc,l);s!==null&&n.set(d.maximized,s);for(const l of i)a.includes(l)&&n.append(d.markup,l)}else{const i=t.doc??null,s=t.view==="tree"?t.folder??null:null;if(i!==null&&s!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");i!==null&&(r+=`/${me(Qt(i))}`),s!==null&&(r+=`/${me(`${ee(s)}${M}`)}`)}if(t.source!==void 0){const i=Pe(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&n.set(d.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&(en(e,t.overrides),t.overrides.style!==void 0&&n.set(d.style,t.overrides.style),t.overrides.align!==void 0&&n.set(d.align,t.overrides.align)),t.view!=="multi"&&t.markup===!0){if(!(t.doc!==void 0&&t.doc!==null||t.view==="tree"&&t.folder!==void 0&&t.folder!==null))throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");n.set(d.markup,Ie)}if(t.view==="single"&&t.embed!==void 0){const{embed:i}=t;tn(i);for(const s of Ae)i[s]===!1&&n.set(d[s],"false");i.padding!==void 0&&n.set(d.padding,String(i.padding)),i.width!==void 0&&n.set(d.width,i.width),i.maxWidth!==void 0&&n.set(d.maxWidth,i.maxWidth)}const o=n.toString();return o===""?r:`${r}?${o}`},nn=(e,t)=>Object.keys(e.views).find(n=>e.views[n]===t),rn=(e,t,n)=>{const r=Pe(e),[o]=r;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=Kt(r,o,n),s=i===null?o:i,a=f=>({kind:"redirect",href:Ce(e,f),location:f}),l=()=>a({view:"tree",source:s,doc:null,folder:null,overrides:{},markup:!1});if(t===void 0||t==="")return l();const c=t.indexOf("/"),D=c<0?t:t.slice(0,c),v=c<0?null:t.slice(c+1),h=nn(e,D);if(h===void 0)return l();if(h==="multi"){const f=n.getAll(d.doc),x=$e(e,f),j=n.getAll(d.maximized),[z]=j,F=j.length===1&&z!==void 0&&x.includes(z)?z:null,U=n.getAll(d.markup),L=x.filter(R=>U.includes(R)),Me=L.length===U.length&&L.every((R,V)=>R===U[V]);return v===null&&i!==null&&x.length===f.length&&x.every((R,V)=>R===f[V])&&(j.length===0||F!==null)&&Me?{kind:"location",location:{view:"multi",source:s,docs:x,maximized:F,markup:L}}:a({view:"multi",source:s,docs:x,maximized:F,markup:L})}const P=v===null?null:Ht(v),g=P?.endsWith(M)===!0?P.slice(0,-M.length):null,E=P!==null&&g===null?P:null;if(E!==null&&!N.isAcceptableDocumentPath(E)||g!==null&&!N.isAcceptableDocumentPath(g))return l();const b=qt(e,n),_=(E!==null||g!==null)&&n.get(d.markup)===Ie;if(h==="single"){if(g!==null)return a({view:"tree",source:s,doc:null,folder:g,overrides:b,markup:_});if(E===null)return l();const f=Yt(n);return i===null?a({view:h,source:s,doc:E,overrides:b,embed:f,markup:_}):{kind:"location",location:{view:h,source:s,doc:E,overrides:b,embed:f,markup:_}}}return i===null?a({view:h,source:s,doc:E,folder:g,overrides:b,markup:_}):{kind:"location",location:{view:h,source:s,doc:E,folder:g,overrides:b,markup:_}}};exports.ASSUMED_ROOT_FONT_PIXELS=lt;exports.COARSE_TARGET_PIXELS=ft;exports.COLUMN_MIN_MEASURE=wt;exports.CONTROL_BLOCK_PIXELS=we;exports.DEFAULT_TREE_SETTINGS=J;exports.DEFAULT_VIEW_SLUGS=W;exports.EDIT_SPLIT_DEFAULT_PERCENT=xt;exports.EDIT_SPLIT_MAX_PERCENT=Ot;exports.EDIT_SPLIT_MIN_PERCENT=pe;exports.EXPAND_ALL_DEPTH_LIMITS=ye;exports.EXPAND_ALL_FOLDER_LIMITS=Oe;exports.EXPLORER_DEFAULT_PERCENT=at;exports.EXPLORER_MAX_PERCENT=Q;exports.EXPLORER_MIN_REM=Ee;exports.EXPLORER_MULTI_DEFAULT_PERCENT=ct;exports.FINE_TARGET_PIXELS=ut;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=xe;exports.MULTI_VIEW_PANEL_LIMITS=Se;exports.NAME_COLLATOR=A;exports.NO_TREE_SETTING_CHANGES=B;exports.PANEL_MAX_BLOCK_RATIO=gt;exports.PANEL_MIN_BLOCK_RATIO=Et;exports.PREFETCH_DWELL_MS=yt;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=Te;exports.SPLIT_HANDLE_PIXELS=dt;exports.SPLIT_PERSIST_DELAY_MS=St;exports.SPREADSHEET_BYTE_LIMITS=be;exports.advanceTreeSetting=Ze;exports.applyTreeSettingChanges=nt;exports.canonicalMultiDocuments=$e;exports.centeredDialogPosition=It;exports.columnGroups=_t;exports.createEntryComparator=st;exports.decodeText=Ve;exports.decodeTextLeniently=Ge;exports.defineExplorerConfig=_e;exports.documentStyleNames=Wt;exports.editSplitOrientation=Rt;exports.explorerHref=Ce;exports.explorerMinPixels=he;exports.explorerSheetBelowPixels=pt;exports.folderReadmeOf=We;exports.formatTreeSettingValue=Qe;exports.isExplorerSourceId=Re;exports.isPlainObject=y;exports.legacyTextEncodingOf=q;exports.parseViewSettings=$t;exports.readCookieValue=Lt;exports.readTreeSettingChanges=tt;exports.recordTreeSettingChange=rt;exports.replanVisibleColumns=bt;exports.resolveExplorerLocation=rn;exports.revalidateExplorerConfig=Jt;exports.serializeTreeSettingChanges=ot;exports.textEncodingsOf=Fe;exports.viewSettingsCookieString=Dt;exports.visibleTreeSettingDescriptors=Ye;exports.withExplorerSources=Bt;