@aiquants/markdown-explorer 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +6 -3
- package/dist/{EditSurface-wXPvuB2n.cjs → EditSurface-B9IpZlBX.cjs} +1 -1
- package/dist/{EditSurface-BYKUL-a1.js → EditSurface-BrdChI9n.js} +27 -27
- package/dist/{ExplorerSplit-Bz-1G42e.js → ExplorerSplit-B-fr2nlU.js} +81 -81
- package/dist/{ExplorerSplit-CLxr4_0K.cjs → ExplorerSplit-B99KbYXc.cjs} +1 -1
- package/dist/{MultiLayout-Coc-HQUb.cjs → MultiLayout-BZ0zTAoi.cjs} +1 -1
- package/dist/{MultiLayout-DpxzsXKz.js → MultiLayout-Pf-6yPif.js} +2 -2
- package/dist/{NativeScrollBar-CDgYgxXK.cjs → NativeScrollBar-Bj5_LmwY.cjs} +1 -1
- package/dist/{NativeScrollBar-DLdveoaN.js → NativeScrollBar-ybJw3OHE.js} +2 -2
- package/dist/{TreeLayout-C8TuS9ue.js → TreeLayout-C4l591Nc.js} +2 -2
- package/dist/{TreeLayout-CJrJNZHq.cjs → TreeLayout-CblPMzQi.cjs} +1 -1
- package/dist/index-CnX313Ss.cjs +15 -0
- package/dist/{index-CdYr9OQ-.js → index-awodBw8r.js} +851 -823
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{merge-DRLuveD9.cjs → merge-DffWW96L.cjs} +1 -1
- package/dist/{merge-BQgbDcHR.js → merge-qfptirid.js} +1 -1
- package/dist/tapScrollCircle-CDBXEKvI.cjs +1 -0
- package/dist/tapScrollCircle-DYmzWI-8.js +12 -0
- package/docs/behavior/layout.md +2 -1
- package/package.json +5 -5
- package/dist/index-CjyRD7qg.cjs +0 -15
- package/dist/tapScrollCircle-B2A6CmmI.js +0 -13
- package/dist/tapScrollCircle-qD8iSmfq.cjs +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime"),c=require("react"),te=require("react-router"),H=require("./location-l_HysaZR.cjs"),ve=require("@aiquants/markdown/code-blocks"),_=require("./dataRoute-DwYtgyt6.cjs"),Ee=require("@aiquants/markdown"),ht=require("@aiquants/markdown/source-lines"),pt=require("@aiquants/spreadsheet/tsv"),Zt=require("@aiquants/spreadsheet/view"),bo=require("@aiquants/markdown/viewer-settings"),J=require("./storage-DM0EvkVf.cjs"),So=require("@aiquants/route-revalidation");function yo(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 y=yo(c),gt=Object.freeze(["en","ja"]),Mn="en",Rt=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Nn=Object.freeze(Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),jn=e=>Object.fromEntries(Nn.map(t=>[Rt(t),ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),Dn=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(Nn.filter(e=>ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[Rt(e),ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),ko=/\{(\w+)\}/gu,Pn={...jn("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.",spreadsheetWorkbookFirstSheet:"The whole workbook could not be read, so only its first sheet is shown.",spreadsheetSheets:e=>`Sheets of ${e}`,spreadsheetSheetName:(e,t)=>`${e}, sheet ${t}`,spreadsheetUnshownSheets:e=>e===1?"1 sheet is not shown (a hidden sheet or a chart sheet).":`${e} sheets are not shown (hidden sheets or chart sheets).`,spreadsheetUnlistedSheets:e=>`Only the first ${e} sheets are listed.`,spreadsheetSheetLoading:"Loading the sheet…",spreadsheetSheetEmpty:"This sheet has no data.",spreadsheetWorkbookEncrypted:"This workbook is password-protected, so it cannot be shown. Download it to open it.",spreadsheetNotWorkbook:"This file cannot be read as an Excel (.xlsx) or OpenDocument (.ods) workbook. Download it to open it.",spreadsheetWorkbookTooLarge:"This workbook is too large to preview. Download it to open it.",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.",viewerSvgImageCopyImage:"Copy the image",viewerSvgImageCopiedImage:"Copied the image.",viewerSvgImageCopyImageFailed:"Could not copy the image.",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"},Ro={...jn("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 を表示しません。新しいタブで開くか、ダウンロードしてください。",spreadsheetWorkbookFirstSheet:"ブック全体を読めなかったため、最初のシートだけを表示しています。",spreadsheetSheets:e=>`${e} のシート`,spreadsheetSheetName:(e,t)=>`${e} のシート「${t}」`,spreadsheetUnshownSheets:e=>`非表示のシートかグラフのシートが ${e} 枚あり、表示していません。`,spreadsheetUnlistedSheets:e=>`最初の ${e} 枚のシートだけを並べています。`,spreadsheetSheetLoading:"シートを読み込み中…",spreadsheetSheetEmpty:"このシートにはデータがありません。",spreadsheetWorkbookEncrypted:"このブックはパスワードで保護されているため、表示できません。ダウンロードして開いてください。",spreadsheetNotWorkbook:"このファイルは Excel (.xlsx) や OpenDocument (.ods) のブックとして読めません。ダウンロードして開いてください。",spreadsheetWorkbookTooLarge:"このブックはプレビューするには大きすぎます。ダウンロードして開いてください。",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:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",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:"ここへパネルをドロップ"},_n=Object.freeze({en:Object.freeze(Pn),ja:Object.freeze(Ro)}),Tt=Object.freeze(Object.keys(Pn)),To=new Set(Tt),Co=e=>To.has(e),$e=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,In=e=>{if(e===void 0)return Mn;if(gt.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${gt.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${$e(e)}`)},wt=(e,t)=>{const n=_n[In(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${$e(t)}`);if(!H.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${$e(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Co(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Tt.join(", ")}`);const a=r[s];if(a===void 0)continue;const i=typeof n[s];if(typeof a!==i)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${i}; got ${$e(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=Dn[s];if(typeof a=="string"&&m!==void 0){for(const[,f]of a.matchAll(ko))if(!m.includes(f??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(f)}}; it accepts ${m.map(d=>`{${d}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Lo=(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]))},vt=Object.freeze(["light","dark"]),Oo=e=>{if(e===void 0)return"light";if(vt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${vt.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},$n=c.createContext(null),$=()=>{const e=c.use($n);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},Re=e=>{const{viewSettings:t}=$(),n=()=>e(t.getSnapshot());return c.useSyncExternalStore(t.subscribe,n,n)},Ze=()=>{const{config:e}=$(),t=te.useParams()["*"],[n]=te.useSearchParams(),r=n.toString();return c.useMemo(()=>H.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Fn={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"]},re=(e,t)=>e[Fn[t][0]],ce=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=$(),s=re(o,e.reason),a=o[Fn[e.reason][1]],i=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":i,"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]})},Ao=(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 re(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(re(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Mo=(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(re(e,t.failure.reason));case"idle":case"saving":return null}},xe=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},qn="<<<<<<<",Bn="=======",Un=">>>>>>>",Wt=(e,t)=>e===t||e.startsWith(`${t} `),Gt=e=>Hn(e.split(`
|
|
2
|
+
`)),Hn=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||(Wt(s,qn)?(n=o,r=null):s===Bn?n!==null&&r===null?r=o:n=null:Wt(s,Un)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Kt=e=>e.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,Je=e=>e.replace(/\r\n?/gu,`
|
|
6
|
+
`),No=(e,t)=>t===`
|
|
7
|
+
`?e:e.replaceAll(`
|
|
8
|
+
`,`\r
|
|
9
|
+
`),jo=3,Do=/^\d+(?:\.\d+)?$/u,Po=e=>{if(e===null||!Do.test(e))return null;const t=Number(e);return t>=H.EDIT_SPLIT_MIN_PERCENT&&t<=H.EDIT_SPLIT_MAX_PERCENT?t:null},et=Object.freeze({kind:"idle"}),Xt=Object.freeze({kind:"draft"}),_o=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,i=new Map,m=new Map,f=new Map,d=xe();let u=null,p=null,w=null;const E=(h,g)=>{h.value={...h.value,...g},d.emit()},b=(h,g)=>s.get(h)===g,T=async(h,g)=>{g.controller.abort(),g.controller=new AbortController;const{signal:R}=g.controller;E(g,{phase:{kind:"opening"}});const N=await e.edit(h,R);if(!b(h,g)||R.aborted||!("kind"in N))return;if(N.kind==="grant"){E(g,{phase:{kind:"grant",href:N.href}});return}if(N.kind==="failure"){E(g,{phase:{kind:"failed",failure:N.failure}});return}const I=Je(N.text),F=N.kind==="draft";g.base={text:I,version:F?null:N.version},g.draft=I,g.ending=Kt(N.text),E(g,{phase:{kind:"editing"},history:F?!1:N.history,dirty:!1,save:F?Xt:et,generation:g.value.generation+1})},O=h=>{const g=s.get(h);g!==void 0&&(g.controller.abort(),s.delete(h),i.delete(h))},C=(h,g,R)=>(h.set(g,R),()=>{h.get(g)===R&&h.delete(g)}),q=(h,g,R,N={})=>{E(g,{...N,save:R}),n(h,R)},D=async h=>{m.get(h)?.flush();const g=s.get(h);if(g===void 0||g.value.phase.kind!=="editing"||g.base===null||g.value.save.kind==="saving")return;const{version:R}=g.base;if(R===null){n(h,Xt);return}const N=Gt(g.draft).length;if(N>0){q(h,g,{kind:"conflicts",count:N});return}g.controller.abort(),g.controller=new AbortController;const{signal:I}=g.controller;let F={text:g.base.text,version:R},x=g.draft,k=!1;E(g,{save:{kind:"saving"}});for(let A=0;A<jo;A+=1){const M=await e.save(h,F.version,No(x,g.ending),I);if(!b(h,g)||I.aborted||!("kind"in M))return;if(M.kind==="saved"){m.get(h)?.flush(),g.base={text:x,version:M.version},q(h,g,{kind:"saved",merged:k},{dirty:g.draft!==x});return}if(M.kind==="grant"){q(h,g,{kind:"grant",href:M.href});return}if(M.kind==="failure"){q(h,g,{kind:"failed",failure:M.failure});return}const{mergeDraft:P}=await Promise.resolve().then(()=>require("./merge-DffWW96L.cjs"));if(!b(h,g)||I.aborted)return;const B=m.get(h);B?.flush();const G=Je(M.text),v=P(F.text,g.draft,G,t());if(F={text:G,version:M.version},g.base=F,g.ending=Kt(M.text),g.draft=v.text,B?.adopt(v.text),v.kind==="conflicts"){q(h,g,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:g.value.generation+1});return}if(k=!0,x=v.text,x===F.text){q(h,g,{kind:"saved",merged:k},{dirty:!1,generation:g.value.generation+1});return}E(g,{dirty:!0,generation:g.value.generation+1})}q(h,g,{kind:"failed",failure:{reason:"failed"}})};return{session:h=>s.get(h)?.value,subscribe:d.subscribe,start:(h,g)=>{const R=s.get(h);if(R!==void 0){E(R,{request:{anchor:g},view:"editor"}),(R.value.phase.kind==="failed"||R.value.phase.kind==="grant")&&T(h,R);return}a.delete(h);const N={value:{path:h,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:et,generation:0,request:{anchor:g}},base:null,draft:"",ending:`
|
|
10
|
+
`,controller:new AbortController};s.set(h,N),T(h,N)},retry:h=>{const g=s.get(h);g===void 0||g.value.phase.kind==="editing"||T(h,g)},draft:h=>{const g=s.get(h);return g===void 0||g.base===null?null:g.draft},setDraft:(h,g)=>{const R=s.get(h);if(R===void 0||R.base===null)return;R.draft=g;const N={},I=g!==R.base.text;I!==R.value.dirty&&(N.dirty=I);const{save:F}=R.value;if(F.kind==="conflicts"){const x=Gt(g).length;x===0?N.save=et:x!==F.count&&(N.save={kind:"conflicts",count:x})}(N.dirty!==void 0||N.save!==void 0)&&E(R,N)},consumeRequest:h=>{const g=s.get(h);g!==void 0&&g.value.request!==null&&E(g,{request:null})},save:D,replaceDraft:(h,g)=>{const R=m.get(h);R?.flush();const N=s.get(h);if(N===void 0||N.base===null)return;const I=Je(g);N.draft=I,R?.adopt(I),E(N,{dirty:I!==N.base.text,generation:N.value.generation+1})},close:h=>{if(!s.has(h))return;const g=m.get(h),R=g===void 0?null:g.returnPoint();O(h),R===null?a.delete(h):a.set(h,R),d.emit()},takeReturn:h=>{const g=a.get(h)??null;return a.delete(h),g},dirtyPaths:()=>[...s.values()].filter(h=>h.value.dirty).map(h=>h.value.path),discard:h=>{for(const g of h)O(g);h.length>0&&d.emit()},editorState:{get:h=>i.get(h),set:(h,g)=>{s.has(h)&&i.set(h,g)}},bindEditor:(h,g)=>C(m,h,g),bindView:(h,g)=>C(f,h,g),viewAnchor:h=>{const g=f.get(h);return g===void 0?null:g.anchor()},flush:h=>m.get(h)?.flush(),flushDrafts:()=>{for(const h of m.values())h.flush()},nextConflict:h=>m.get(h)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:h=>{for(const g of m.values())g.flush();return h.filter(g=>s.get(g)?.value.dirty===!0)},askToDiscard:h=>new Promise(g=>{w?.settle(!1);const R={paths:h,settle:N=>{if(w===R){if(w=null,N)for(const I of h)O(I);d.emit(),g(N)}}};w=R,d.emit()}),discardRequest:()=>w,sideBySide:()=>(u??=r.read(),u),setSideBySide:h=>{u!==h&&(u=h,r.write(h),d.emit())},editorShare:()=>(p??=o.read()??H.EDIT_SPLIT_DEFAULT_PERCENT,p),setEditorShare:h=>{if(!Number.isFinite(h))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(h)}`);const g=Math.min(H.EDIT_SPLIT_MAX_PERCENT,Math.max(H.EDIT_SPLIT_MIN_PERCENT,h));p!==g&&(p=g,o.write(g))},setView:(h,g)=>{const R=s.get(h);R===void 0||R.value.view===g||(m.get(h)?.beforeView(g),E(R,{view:g,previewPrepared:R.value.previewPrepared||g==="preview"}))},preparePreview:h=>{const g=s.get(h);g!==void 0&&!g.value.previewPrepared&&E(g,{previewPrepared:!0})}}},Ct=e=>{e.preventDefault(),e.stopPropagation()},zn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Vn="data-aqmx-content-pane",Be=Object.freeze({[Vn]:""}),Io="--aqmx-dialog-left",$o="--aqmx-dialog-top",Fo='[data-testid="markdown-explorer"]',qo=e=>{const t=e.closest(Fo)?.querySelectorAll(`[${Vn}]`),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},Bo=e=>{const t=zn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=qo(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=H.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(Io,`${String(s)}px`),e.style.setProperty($o,`${String(a)}px`),n},Uo=e=>e.preventDefault(),Zn=({open:e,onOpen:t,onDismiss:n})=>{const r=c.useRef(null),o=c.useRef(null),s=c.useRef(!1),a=c.useRef(t);c.useLayoutEffect(()=>{a.current=t},[t]),c.useLayoutEffect(()=>{s.current=e;const d=r.current;if(d!==null)if(e&&!d.open){const u=d.ownerDocument.activeElement;o.current=u instanceof HTMLElement?u:null,d.showModal(),a.current?.()}else!e&&d.open&&(d.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),c.useLayoutEffect(()=>{const d=r.current;if(!e||d===null)return;const u=new ResizeObserver(()=>w());let p=null;const w=()=>{const b=Bo(d);b===null||b===p||(p!==null&&u.unobserve(p),u.observe(b),p=b)};w(),u.observe(d);const E=d.ownerDocument.defaultView;return E?.addEventListener("resize",w),d.ownerDocument.addEventListener("scroll",w,{capture:!0,passive:!0}),()=>{u.disconnect(),E?.removeEventListener("resize",w),d.ownerDocument.removeEventListener("scroll",w,{capture:!0})}},[e]);const i=c.useCallback(d=>{d.key!=="Escape"||d.defaultPrevented||(Ct(d),n())},[n]),m=c.useCallback(d=>{d.target===d.currentTarget&&n()},[n]),f=c.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:m,onCancel:Uo,onClose:f}},Wn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const m=c.useRef(null),f=c.useId(),d=c.useId(),u=c.useCallback(()=>m.current?.focus(),[]),p=Zn({open:e,onOpen:u,onDismiss:a});return l.jsx("dialog",{...p,className:"aqmx-confirm","aria-labelledby":f,"aria-describedby":d,"data-testid":i,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:d,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":`${i}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${i}-confirm`,onClick:s,children:r})]})]})})},Te=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},Gn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),Se=e=>e.status==="fulfilled"?e.value:void 0,Kn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),Ho=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),zo=(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,i=s.lazy===!0?a?.status==="loaded"?a.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return i;if(i!==null)for(const m of[...i].reverse())o.push(m)}return null},Xn=(e,t,n)=>{const r=Se(e.read(t));if(r===void 0||r.status==="deferred")return Kn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=zo(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:H.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?Ho:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:H.folderReadmeOf(s.entries)},claim:!0}},Vo=(e,t,n)=>{const{readme:r}=Xn(e,t,n);return r.status==="ok"?r.readme:null},Zo=(e,t,n)=>{const r=te.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=H.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)}},Yn=e=>{const{edits:t}=$(),n=c.useCallback(()=>t.session(e),[t,e]);return c.useSyncExternalStore(t.subscribe,n,Wo)},Qn=()=>!1,Wo=()=>{},Go=()=>{const{edits:e}=$();return c.useSyncExternalStore(e.subscribe,e.hasSessions,Qn)},Jn=()=>{const{edits:e}=$();return c.useSyncExternalStore(e.subscribe,e.sideBySide,Qn)},Ko=()=>null,Xo=()=>{const{edits:e,labels:t,config:n,trees:r}=$(),o=c.useRef([]),s=c.useCallback(({nextLocation:w})=>{const E=Zo(n,w,(b,T)=>Vo(r,b,T));return e.flushDrafts(),o.current=e.dirtyPaths().filter(b=>!E.has(b)),o.current.length>0},[e,n,r]),a=te.useBlocker(s),i=Go();c.useEffect(()=>{if(!i)return;const w=E=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(E.preventDefault(),E.returnValue=!0)};return window.addEventListener("beforeunload",w),()=>window.removeEventListener("beforeunload",w)},[i,e]);const m=c.useSyncExternalStore(e.subscribe,e.discardRequest,Ko),f=a.state==="blocked",d=f?o.current:m===null?[]:m.paths,u=d.map(w=>_.lastPathSegment(w)).join(", "),p=d.length>0&&d.every(w=>e.session(w)?.save.kind==="draft");return l.jsx(Wn,{open:f||m!==null,title:p?t.draftDiscardTitle:t.unsavedTitle,body:p?t.draftDiscardBody(u):t.unsavedBody(u),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 Yo({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Qo=y.forwardRef(Yo);let tt=null;const er=()=>(tt??=Promise.resolve().then(()=>require("./EditSurface-B9IpZlBX.cjs")).catch(e=>{throw tt=null,e}),tt),Jo=()=>{er().catch(()=>{})},es=e=>{const{default:t}=c.use(er());return l.jsx(t,{...e})};class ts extends c.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 Lt=`[${ht.SOURCE_LINES_ATTRIBUTE}]`,ns="[data-aqmd-content]",rs='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]',os=200,Ce=e=>ht.parseSourceLines(e.getAttribute(ht.SOURCE_LINES_ATTRIBUTE)),ss=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=Ce(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Lt)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=Ce(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},as=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},tr=e=>e.closest(ns)!==null&&e.closest(rs)===null,nr=(e,t,n)=>{const r=ss(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const i=r.lines.last+1;return{lines:{first:i,last:i},word:null,occurrence:0,clientTop:Ue(e)}}const a=ls(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Ue(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},rr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Lt)){const i=Ce(a);if(i===null)continue;n??=sr(t,a);const{top:m,bottom:f}=a.getBoundingClientRect();m<=n&&n<f?r={lines:i,block:a}:o===null&&m>=n&&(o={lines:i,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Ue(s.block)}},or=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,sr=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return or(e)+(Number.isFinite(n)?n:0)},ls=(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>os||/[\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:as(o.toString(),r),clientTop:n.getBoundingClientRect().top}},is=(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 i=r;i<=o;i+=1){const m=n[i-1]??"";for(let f=m.indexOf(t.word);f>=0;f=m.indexOf(t.word,f+t.word.length)){if(a===t.occurrence)return{line:i,column:f};a+=1}}return a>0?cs(n,r,o,t.word)??s:s},cs=(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},ar=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Lt)){const s=Ce(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},lr=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Ue(e),o=Ce(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},Ue=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:i}=s.getBoundingClientRect();if(i>0)return a}return e.getBoundingClientRect().top},Ot=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})}),ds=e=>Ot[e],Oe=()=>{const e=te.useNavigate();return c.useCallback((t,n)=>{e(t,Ot[n])},[e])},ir=({navigation:e,...t})=>l.jsx(te.Link,{...t,...Ot[e]}),At=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},cr=(e,t)=>{const n=c.useRef(null),r=c.useRef(null),o=c.useRef(null),s=c.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);c.useEffect(()=>s,[s]);const a=c.useCallback(f=>{if(r.current!==f)return;const d=o.current;if(d!==null){d.then(()=>a(f));return}e.prefetch(f);const u=e.peek(f);if(u?.status!=="pending")return;const p=Promise.allSettled([u.promise]);o.current=p,p.then(()=>{o.current===p&&(o.current=null)})},[e]),i=c.useCallback(f=>{const d=t(f);d!==r.current&&(s(),d!==null&&(r.current=d,n.current=window.setTimeout(()=>{n.current=null,a(d)},H.PREFETCH_DWELL_MS)))},[s,t,a]),m=c.useCallback(f=>{t(f)!==r.current&&s()},[s,t]);return c.useMemo(()=>({onPointerOver:f=>i(f.target),onPointerOut:f=>m(f.relatedTarget),onFocus:f=>i(f.target),onBlur:f=>m(f.relatedTarget)}),[i,m])},us=c.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-Bj5_LmwY.cjs")).then(e=>({default:e.NativeScrollBar})));class fs extends c.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 dr=({scroller:e,withCircle:t})=>l.jsx(fs,{children:l.jsx(c.Suspense,{fallback:null,children:l.jsx(us,{scroller:e,withCircle:t})})}),ur=e=>l.jsx(dr,{scroller:e,withCircle:!0}),ms=8,We=H.CONTROL_BLOCK_PIXELS,fr=H.FIBONACCI_SPACING_PIXELS[3],Mt=We+2*fr,hs=-(We+fr),mr=Object.freeze({minSpeedMultiplier:.25,maxSpeedMultiplier:18});let hr=null,nt=null;const Et=new Set,ps=e=>(Et.add(e),()=>{Et.delete(e)}),gs=()=>{nt===null&&(nt=Promise.resolve().then(()=>require("./tapScrollCircle-CDBXEKvI.cjs")).then(e=>{const t=e.TAP_SCROLL_CIRCLE.renderVisual;if(t===void 0)throw new TypeError("[markdown-explorer] the bars' tap-scroll circle has no look to share");hr=t;for(const n of[...Et])n()}).catch(e=>{nt=null,console.error("[markdown-explorer] the look of a table's tap-scroll circle failed to load; the circle still scrolls without it.",e)}))},ws=({look:e,state:t})=>e(t),vs=e=>{const t=c.useSyncExternalStore(ps,()=>hr,()=>null);return c.useEffect(()=>{t===null&&gs()},[t]),t===null?null:l.jsx(ws,{look:t,state:e})},pr=Object.freeze({renderVisual:e=>l.jsx(vs,{...e}),...mr,size:We}),gr=()=>{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()]}},He=(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)=>He(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)&&He(n[s],r[s]))},Es=55e3,Yt=Object.freeze({status:"deferred"}),rt=Object.freeze({status:"refreshed"}),ot=Object.freeze({status:"shown",failed:!1}),De=Object.freeze({status:"shown",failed:!0}),Pe=Object.freeze({status:"superseded"}),le=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,xs=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",bs=({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=gr(),o=xe(),s=new WeakSet,a=new Map,i=new Map,m=new Map;let f=0;const d=o.emit,u=()=>(f+=1,f),p=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},w=(x,k)=>{n.delete(x),n.set(x,k)},E=x=>performance.now()-x.validatedAt>=Es,b=(x,k,A)=>{const M=n.get(x),P=le(M?.snapshot),B=A||M?.refreshPending===!0,G=Te(e.document(x,{refresh:B}).then(S=>({status:"loaded",document:S}))),v={snapshot:{status:"pending",promise:G,previous:P},validatedAt:performance.now(),opened:k,background:null,refreshPending:!1,seeded:void 0,stamp:u()};return w(x,v),p(),G.then(S=>{n.get(x)===v&&(v.snapshot=S,v.stamp=u(),d())}),v},T=(x,k,A,M,P,B)=>{k.background===A&&(k.background=null,!(n.get(x)!==k||k.snapshot!==M)&&(P.kind==="failure"&&M.document.kind!=="failure"||(k.validatedAt=B,k.stamp=u(),He(M.document,P)||(k.snapshot={status:"loaded",document:P}),d())))},O=async(x,k)=>{const A=k.snapshot;if(A.status!=="loaded")return null;const M={};k.background=M;const P=performance.now(),B=e.document(x,{refresh:k.refreshPending});k.refreshPending=!1;const G=await B,v=k.background===M&&n.get(x)===k&&k.snapshot===A;return T(x,k,M,A,G,P),v?G:null},C=(x,k)=>{const{snapshot:A}=k;return A.status==="pending"?!1:A.status==="loaded"&&A.document.kind!=="failure"?(O(x,k),!1):(A.status==="loaded"&&s.add(A),b(x,!0,!1),!0)},q=x=>{i.delete(x);const k=m.get(x);if(k!==void 0){m.delete(x);for(const A of k)A()}},D=(x,k)=>new Promise(A=>{if(i.get(x)===k||!r.isHeld(x)){A();return}const M=m.get(x);M===void 0?m.set(x,new Set([A])):M.add(A)}),h=(x,k)=>{const A=a.get(x);if(A===void 0){k.resolve(null);return}if(A.last!==null&&A.last.stamp>=k.stamp){k.resolve(A.last);return}A.waiters.add(k)},g=async(x,k,A)=>{const M=await new Promise(P=>h(x,{stamp:k.stamp,resolve:P}));if(n.get(x)!==k)return Pe;if(M===null)return A?rt:ot;if(!A)return M.failure===null?ot:De;switch(M.before){case"copy":return M.failure===null?rt:{status:"failed",failure:M.failure};case"failure":return M.failure===null?ot:De;case"none":return M.failure===null?rt:De}},R=x=>{const k={showing:"none",last:null,waiters:new Set};a.set(x,k);let A=!1;return{settle:(M,P)=>{if(A||M===void 0)return;const B={stamp:M,failure:P,before:k.showing};k.last=B,P===null?k.showing="copy":k.showing==="none"&&(k.showing="failure");for(const G of[...k.waiters])M<G.stamp||(k.waiters.delete(G),G.resolve(B))},release:()=>{if(A)return;A=!0,a.get(x)===k&&a.delete(x);const M=[...k.waiters];k.waiters.clear(),M.length>0&&queueMicrotask(()=>{for(const P of M)h(x,P)})}}},N=x=>{const k=r.hold(x);let A=!1;return()=>{if(A)return;A=!0,k();const M=n.get(x);M!==void 0&&w(x,M),p(),r.isHeld(x)||queueMicrotask(()=>{r.isHeld(x)||q(x)})}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const k=n.get(x);k!==void 0&&k.snapshot.status!=="deferred"||(b(x,!1,!1),d())},open:x=>{const k=r.resumes(x),A=N(x),M=n.get(x);if(M===void 0||M.snapshot.status==="deferred")return b(x,!0,!1),d(),A;if(w(x,M),k)return A;const{snapshot:P}=M;return P.status==="pending"?(M.opened=!0,A):P.document.kind==="failure"?(M.opened||E(M)?(s.add(P),b(x,!0,!1),d()):M.opened=!0,A):(M.opened=!0,M.background===null&&E(M)&&O(x,M),A)},retain:N,retry:x=>{const k=n.get(x);k===void 0||k.snapshot.status!=="loaded"||k.snapshot.document.kind!=="failure"||(b(x,!0,!1),d())},seed:(x,k)=>{const A=performance.now(),M=Te(k.then(S=>S===null?Yt:{status:"loaded",document:S},()=>Yt)),P=n.get(x);if(P!==void 0&&P.snapshot.status==="loaded"){const S=P.snapshot,L={};P.background=L,M.then(j=>{if(j.status==="loaded"){T(x,P,L,S,j.document,A);return}P.background===L&&(P.background=null)});return}const B=P!==void 0&&P.snapshot.status==="pending"?P.snapshot.previous:null,G={status:"pending",promise:M,previous:B},v={snapshot:G,validatedAt:A,opened:P?.opened===!0,background:null,refreshPending:P?.refreshPending===!0,seeded:G,stamp:u()};w(x,v),p(),M.then(S=>{n.get(x)===v&&(S.status==="deferred"&&r.isHeld(x)?b(x,v.opened,!1):(v.snapshot=S,v.stamp=u()),d())})},invalidate:()=>{let x=!1;for(const[k,A]of[...n]){if(A.validatedAt=Number.NEGATIVE_INFINITY,A.opened=!0,A.refreshPending=!0,!r.isHeld(k))continue;const{snapshot:M}=A;if(M.status!=="pending"){C(k,A)&&(x=!0);continue}M.promise.then(()=>{n.get(k)===A&&A.refreshPending&&r.isHeld(k)&&C(k,A)&&d()})}x&&d()},refresh:async x=>{const k=n.get(x);if(k!==void 0&&xs(k.snapshot)){k.refreshPending=!0;const P=await O(x,k);return P===null?Pe:P.kind==="failure"?{status:"failed",failure:P.failure}:g(x,k,!0)}const A=b(x,!0,!0);if(d(),A.snapshot.status!=="pending")return Pe;const M=await A.snapshot.promise;return n.get(x)!==A||M.status!=="loaded"?Pe:M.document.kind==="failure"?De:(await D(x,M),g(x,A,!1))},clear:()=>{n.clear();for(const x of r.heldKeys())b(x,!0,!1);d()},subscribe:o.subscribe,readPart:R,noteShown:(x,k)=>{i.set(x,k);const A=m.get(x);if(A!==void 0){m.delete(x);for(const M of A)M()}},noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}},de=c.createContext("fill"),Ss="--aqmx-tap-circle-gutter",ys=Object.freeze({blockSize:"100%",[Ss]:`${String(Mt)}px`}),Ae=({scrollerProps:e,children:t})=>c.use(de)==="content"?l.jsx(Ee.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(Ee.HostedScrollArea,{scrollerProps:{...e,style:ys},rowClassName:"aqmx-document-scroll-row",renderScrollBar:ur,children:t}),ks=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Rs=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ue=({label:e,testId:t})=>l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:ks.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),Nt=({failure:e,onRetry:t,testId:n})=>l.jsx(Ae,{scrollerProps:Rs,children:l.jsx(ce,{failure:e,alert:!1,onRetry:t,testId:n})});function Ts({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Cs=y.forwardRef(Ts);function Ls({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Os=y.forwardRef(Ls);function As({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Ms=y.forwardRef(As),Ns=2e3,Qt=Object.freeze({outcome:"idle"}),js=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Ds=({text:e})=>{const{announcer:t,labels:n}=$(),[r,o]=c.useState(Qt);c.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(Qt),Ns);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{js(e).then(()=>s("copied"),()=>s("failed"))},i=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:i,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(Cs,{}):r.outcome==="failed"?l.jsx(Ms,{}):l.jsx(Os,{})})},wr=c.createContext(null),Ps=()=>{const e=c.use(wr);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 _s({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Is=y.forwardRef(_s);function $s({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Fs=y.forwardRef($s),Me=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=$();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(Fs,{})}),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(Is,{})})]})};function qs({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Bs=y.forwardRef(qs),Us=Object.freeze({className:"aqmx-document-stage"}),Hs=({document:e})=>{const{labels:t}=$();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Bs,{})}),l.jsx(Ae,{scrollerProps:Us,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})]})})]})},Ge="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",zs=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Vs=/(%[0-9A-Fa-f]{2})/u,jt=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Vs).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))},vr=e=>`#${encodeURIComponent(e)}`,Zs=e=>{if(e==="#")return!0;const t=jt(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Er=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Ws="http://www.w3.org/1999/xhtml",Jt=(e,t)=>{if(t==="")return null;const n=Er(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Ws&&r.getAttribute("name")===t)return r;return null},xr=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Jt(e,t.slice(1));if(n!==null)return n;const r=jt(t);return r===null?null:Jt(e,r)},en=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"},Gs=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"},Ks=(e,t)=>{const n=t.closest(Ge),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&en(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let i=e.parentElement;i!==null&&i!==s;i=i.parentElement)if(en(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&Gs(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Xs=Object.freeze({scrollerOf:Ks,reveal:e=>{e.scrollIntoView(xt)}}),xt=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),Ys=(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")}}},Qs=(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(),i=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!i&&Math.abs(a.top-s-n)<1){t.scrollIntoView(xt);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(xt)},Js=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Ge)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},tn=(e,t,n)=>{if(e===null)return null;const r=xr(e,t);return r===null?(Zs(t)&&Js(e,n),null):(Ys(e,r),Qs(n.scrollerOf(e,r),r),n.reveal(r),r)};function ea({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 ta=y.forwardRef(ea);function na({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 ra=y.forwardRef(na);function oa({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 sa=y.forwardRef(oa);function aa({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 la=y.forwardRef(aa),bt="data-aqmx-key-repeat",ze=Object.freeze({[bt]:"allow"}),ia=`[${bt}="${ze[bt]}"]`,ca=()=>{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(ia)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},Fe=Object.freeze([1/H.GOLDEN_RATIO**2,1/H.GOLDEN_RATIO,1,H.GOLDEN_RATIO,H.GOLDEN_RATIO**2]),nn=Object.freeze({mode:"fit"}),da=1,br=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),rn=`[data-testid="${br["data-testid"]}"]`,Sr=c.createContext(null),ua=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=da?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,on=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<Fe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?Fe.findIndex(o=>o>t):Fe.findLastIndex(o=>o<t);return r===-1?null:r},sn=(e,t,n)=>{if(e.mode==="level"){const o=on(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=on(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},fa=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(H.GOLDEN_RATIO));return n===0?0:n},an=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}}},ma=e=>{const t=Fe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},ln=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},ha=({document:e})=>{const{labels:t}=$(),n=c.use(Sr),[r]=c.useState(()=>n===null?null:n.read(e.url)),[o,s]=c.useState(r===null?nn:r.zoom),[a,i]=c.useState(r===null?null:r.reported),[m,f]=c.useState(null),d=c.useRef(null),u=c.useCallback(D=>{const{naturalWidth:h,naturalHeight:g}=D;i(R=>ln(R,h,g))},[]),p=c.useCallback(D=>{d.current=D,!(D===null||!D.complete)&&(D.naturalWidth>0||D.naturalHeight>0?u(D):D.decode().then(()=>u(D),()=>{}))},[u]);c.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),c.useLayoutEffect(()=>{const D=d.current;if(D===null||a===null||o.mode!=="fit")return;const h=()=>f(R=>ln(R,D.clientWidth,D.clientHeight));if(h(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(h);return g.observe(D),()=>g.disconnect()},[a,o.mode]);const w=a===null||m===null?null:ua(a,m),E=sn(o,w,-1),b=sn(o,w,1),T=o.mode==="level"?ma(o.index):null,O=c.useRef({zoomIn:b,zoomOut:E});c.useLayoutEffect(()=>{O.current={zoomIn:b,zoomOut:E}});const C=c.useRef(null);c.useLayoutEffect(()=>{const D=C.current,h=d.current?.closest(rn);C.current=null,!(D===null||h===null||h===void 0)&&(h.scrollLeft=D.across*h.scrollWidth-D.x,h.scrollTop=D.down*h.scrollHeight-D.y)},[o]),c.useEffect(()=>{const D=d.current?.closest(rn);if(D==null)return;let h=null;const g=I=>{const F=an(I.touches);h=F===null?null:{distance:F.distance,steps:0}},R=I=>{const F=an(I.touches);if(h===null||F===null)return;I.preventDefault();const x=fa(h.distance,F.distance);if(x===h.steps)return;const k=x>h.steps?1:-1,A=k===1?O.current.zoomIn:O.current.zoomOut;if(A===null)return;h.steps+=k;const M=D.getBoundingClientRect(),P=F.middle.x-M.left,B=F.middle.y-M.top;C.current=D.scrollWidth>0&&D.scrollHeight>0?{x:P,y:B,across:(D.scrollLeft+P)/D.scrollWidth,down:(D.scrollTop+B)/D.scrollHeight}:null,s(A)},N=I=>{I.touches.length<2&&(h=null)};return D.addEventListener("touchstart",g,{passive:!0}),D.addEventListener("touchmove",R,{passive:!1}),D.addEventListener("touchend",N,{passive:!0}),D.addEventListener("touchcancel",N,{passive:!0}),()=>{D.removeEventListener("touchstart",g),D.removeEventListener("touchmove",R),D.removeEventListener("touchend",N),D.removeEventListener("touchcancel",N)}},[]);const q=o.mode==="level"&&T!==null?{width:`${o.base.width*T}px`,height:`${o.base.height*T}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(la,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":E===null,onClick:()=>{E!==null&&s(E)},...ze,children:l.jsx(ra,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:T===null?t.imageFitLevel:t.imageZoomLevel(Math.round(T*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":b===null,onClick:()=>{b!==null&&s(b)},...ze,children:l.jsx(sa,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(nn),children:l.jsx(ta,{})})]}),l.jsx(Ae,{scrollerProps:br,children:l.jsx("img",{ref:p,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:q,onLoad:D=>u(D.currentTarget),"data-testid":"markdown-explorer-image"})})]})},pa=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"}},yr=c.createContext(null),Ke=c.createContext(void 0),kr=c.createContext(null),Xe=()=>{const e=c.use(yr);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},ga=()=>{const e=c.use(kr);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Ye=(e,t,n,r)=>t.kind==="panel"?H.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?H.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):H.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),wa=({children:e})=>{const{config:t}=$(),n=Xe(),r=Ze(),o=r.kind==="location"?r.location.source:void 0,s=te.useHref(Ye(t,n.navigation,o,n.currentPath));return l.jsx(Ke,{value:o,children:l.jsx(kr,{value:s,children:e})})},va='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Ea=e=>{const t=e instanceof Element?e.closest(va):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,xa=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:m})=>{const f=te.useHref(e),d=u=>{if(Qe(u)){if(u.preventDefault(),t===i.currentPath&&n!==""){i.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:f,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:d,children:m})},ba=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=$(),i=Xe(),m=c.use(Ke),f=zs(e),{navigation:d}=i,u=`${Ye(a,d,m,t)}${f}`,p=n===!1?"false":void 0;return d.kind==="page"?l.jsx(ir,{...o,to:u,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":p,children:s}):l.jsx(xa,{to:u,docPath:t,fragment:f,exists:p,className:r,attributes:o,onDocumentLink:d.onDocumentLink,scope:i,children:s})},Sa=({className:e,attributes:t,children:n})=>{const{labels:r}=$();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,")"]})]})},ya=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=$(),a=c.use(Ke),i=te.useHref(`${Ye(s,r.navigation,a,r.currentPath)}${e}`),m=f=>{Qe(f)&&(f.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:m,children:o})},ka=({href:e,className:t,attributes:n,children:r})=>{const o=Xe();if(o.navigation.kind==="page"){const s=a=>{if(!Qe(a))return;const i=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):i.href===i.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(ya,{href:e,className:t,attributes:n,scope:o,children:r})},Ra=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!_.isAcceptableDocumentPath(n)?l.jsx(Sa,{className:o,attributes:s,children:a}):l.jsx(ba,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(ka,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),Ta=()=>{const{config:e}=$(),t=Xe(),n=c.use(Ke),r=Oe();return c.useCallback((o,s)=>{if(!Qe(s))return!0;s.preventDefault();const a=vr(o.id),{navigation:i}=t;return i.kind==="panel"||jt(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Ye(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},Ca=()=>{const e=ga();return c.useCallback(t=>`${e}${vr(t.id)}`,[e])};function La({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Oa=y.forwardRef(La);function Aa({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Ma=y.forwardRef(Aa);function Na({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 ja=y.forwardRef(Na),Da=Object.freeze({className:"aqmx-document-stage"}),Pa=()=>()=>{},_a=()=>navigator.pdfViewerEnabled!==!1,Ia=()=>null,$a=({document:e})=>{const{labels:t}=$(),n=c.useSyncExternalStore(Pa,_a,Ia);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})]})]})},Fa=e=>{switch(e){case"video":return l.jsx(Ma,{});case"audio":return l.jsx(ja,{});case"pdf":return l.jsx(Oa,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},qa=({document:e})=>{const{labels:t}=$();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($a,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Ba=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Fa(e.mediaType)}),l.jsx(Ae,{scrollerProps:Da,children:l.jsx(qa,{document:e})})]}),Dt=e=>{switch(e.kind){case"markdown":return"markdown";case"image":return e.imageType==="svg"?"svg":null;case"spreadsheet":return e.format==="workbook"?null:e.format;default:return null}},Ua=e=>{const{documents:t}=$(),n=c.useCallback(()=>t.peek(e),[t,e]),r=c.useCallback(()=>t.peekSeeded(e),[t,e]),o=c.useSyncExternalStore(t.subscribe,n,r),s=le(o);return s===null?null:Dt(s.document)},Rr=e=>{const{config:t}=$(),n=Oe(),r=c.useCallback(()=>n(H.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return c.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function Ha({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 za=y.forwardRef(Ha),Va=100,Za=32767,qe=Object.freeze({maxCells:Zt.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:Zt.SPREADSHEET_MAX_OPERATION_CELLS/Va,maxCellLength:Za}),Tr=44,Cr=10,Lr=13,_e='"',cn=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Tr||r===Cr||r===Lr)return n;n+=1}return n};function*Wa(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(_e,r)){o="";let a=r+1;for(;;){const m=e.indexOf(_e,a);if(m<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,m),e.startsWith(_e,m+1)){o+=_e,a=m+2;continue}r=m+1;break}const i=cn(e,r);o+=e.slice(r,i),r=i}else{const a=cn(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!==Tr&&(yield n,n=[],s===Lr&&e.charCodeAt(r)===Cr&&(r+=1),r>=e.length))return}}const Ga=(e,t,n)=>t==="csv"?Wa(e,n):n==="whole"?pt.iterateTsvRows(e):pt.iterateTsvPrefixRows(e),Ka=(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)},Or=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const i of e){const m=i.length>t.maxColumns?i.slice(0,t.maxColumns):i,f=Math.max(r,m.length);if((n.length+1)*f>t.maxCells){s=!0;break}const d=m.some(u=>u.length>t.maxCellLength)?m.map(u=>Ka(u,t.maxCellLength)):m;d!==i&&(o=!0),n.push(d),r=f}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},st=(e,t,n,r,o)=>{const s=H.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:H.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=Or(Ga(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(i=>i.some(m=>m!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},Xa=Object.freeze({maxPartBytes:64*1024*1024,maxSheets:256}),Ar=e=>{const t=[];let n=0,r=!1;const o=s=>{if(r)return;const a=Math.max(n,Math.min(s.length,e.maxColumns));(t.length+1)*a>e.maxCells&&(r=!0),t.push(s),n=a};return{addRow:(s,a,i)=>{if(a.size===0||r)return;let m=-1;for(const u of a.keys())u>m&&(m=u);const f=Array(Math.min(m,e.maxColumns)+1).fill("");for(const[u,p]of a)u<=e.maxColumns&&(f[u]=p);const d=Math.min(f.length,e.maxColumns);if(n===0&&(s+1)*d>e.maxCells){const u=Math.floor(e.maxCells/d);for(;t.length<u;)t.push([]);o(f);return}for(;t.length<s&&!r;)o([]);for(let u=0;u<i&&!r;u+=1)o(u===0?f:[...f])},full:()=>r,table:()=>Or(t,e)}},Ya=e=>{const t=Array.from(e.currentTarget.querySelectorAll('[role="tab"]')),n=e.target instanceof HTMLButtonElement?t.indexOf(e.target):-1;if(n===-1)return;const r=getComputedStyle(e.currentTarget).direction==="rtl"?"ArrowRight":"ArrowLeft",o=r==="ArrowLeft"?"ArrowRight":"ArrowLeft",s=e.key===o?(n+1)%t.length:e.key===r?(n-1+t.length)%t.length:e.key==="Home"?0:e.key==="End"?t.length-1:null;s!==null&&(e.preventDefault(),t[s]?.focus())},Qa=({names:e,selected:t,onSelect:n,label:r,tabIdOf:o,panelId:s})=>l.jsx("div",{role:"tablist","aria-label":r,className:"aqmx-sheet-tabs","data-testid":"markdown-explorer-spreadsheet-sheets",onKeyDown:Ya,children:e.map((a,i)=>l.jsx("button",{type:"button",role:"tab",id:o(i),"aria-selected":i===t,"aria-controls":s,tabIndex:i===t?0:-1,className:"aqmx-sheet-tab","data-aqmx-sheet-tab":i,onClick:()=>n(i),children:a},i))}),Mr=64*1024,Ja=e=>{let t=new Uint8Array(Math.min(e,Mr)),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}},el=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},tl=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=Ja(o);let m=Mr;try{for(;;){const{done:f,value:d}=await a.read();if(f)return st(i.bytes(),!0,n,r,s);const u=o-i.length();if(i.append(d.byteLength>u?d.subarray(0,u):d),i.length()===o){const w=d.byteLength<=u&&await el(a);return st(i.bytes(),w,n,r,s)}if(i.length()<m)continue;m=i.length()*2;const p=st(i.bytes(),!1,n,r,s);if(p.kind==="unreadable"&&p.code!=="long-row"||p.kind==="table"&&p.table.full)return p}}finally{a.cancel().catch(()=>{})}},Nr=async(e,t,n,r)=>{const o=await e.asset(_.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await tl(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},Pt=(e,t,n)=>{const{documents:r,labels:o}=$(),s=Ps(),a=c.useCallback(()=>r.answerStampOf(e),[r,e]),i=c.useSyncExternalStore(r.subscribe,a,a),[m,f]=c.useState(0),d=c.useMemo(()=>({read:n,stamp:i,attempt:m}),[n,i,m]),[u,p]=c.useState({settled:null,shown:null,failure:null}),w=c.useRef(null),E=c.useEffectEvent((O,C)=>{if(w.current?.settle(C.stamp,O.kind==="failure"?O.failure:null),O.kind==="read"){p({settled:C,shown:O.value,failure:null});return}if(u.shown!==null){p({settled:C,shown:u.shown,failure:null});return}p({settled:C,shown:null,failure:O.failure}),s.announceFailure(o.documentFailed(t,re(o,O.failure.reason)))});c.useEffect(()=>{const O=s.readPart();return w.current=O,()=>{w.current=null,O.release()}},[s]),c.useEffect(()=>{const O=new AbortController;return d.read(O.signal).then(C=>{C!==null&&!O.signal.aborted&&E(C,d)}),()=>O.abort()},[d]);const b=u.settled!==d&&(u.shown!==null||u.failure!==null);c.useLayoutEffect(()=>b?s.holdBusy():void 0,[b,s]);const T=c.useCallback(()=>f(O=>O+1),[]);return{shown:u.shown,failure:u.failure,retry:T}},jr=(e,t)=>{const n={};for(const r of Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[Rt(r)];o!==ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},nl=(e,t)=>Object.fromEntries(Object.entries(jr(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),rl=(e,t)=>({...nl(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,svgImageCopyImage:e.viewerSvgImageCopyImage,svgImageCopiedImage:e.viewerSvgImageCopiedImage,svgImageCopyImageFailed:e.viewerSvgImageCopyImageFailed}),Dr=(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},Pr=(e,t)=>e!==void 0?e:t!==void 0?t:bo.DEFAULT_CONTENT_ALIGN;class Y extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const ol=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),sl=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,al=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,ll=/^[^\s/>]+/u,ge=e=>{throw new Y("not-workbook",`the XML ${e}`)},dn=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):ge(`refers to the code point ${e}`),_r=e=>e.includes("&")?e.replace(sl,(t,n)=>n.startsWith("#x")?dn(Number.parseInt(n.slice(2),16)):n.startsWith("#")?dn(Number.parseInt(n.slice(1),10)):ol.get(n)??ge(`names the undeclared entity ${t}`)):e,St=e=>e.slice(e.indexOf(":")+1),il=(e,t)=>{let n="";for(let r=t;r<e.length;r+=1){const o=e[r];if(n!=="")o===n&&(n="");else if(o==='"'||o==="'")n=o;else if(o===">")return r}return-1},cl=e=>{const t=new Map;for(const n of e.matchAll(al))t.set(St(n[1]??""),_r(n[2]??n[3]??""));return t},Ir=(e,t)=>{let n="";const r=()=>{let o=0;for(;!t();){const s=n.indexOf("<",o);if(s===-1)break;if(s>o&&(e.text?.(_r(n.slice(o,s))),o=s),n.startsWith("<!--",s)){const f=n.indexOf("-->",s+4);if(f===-1)break;o=f+3;continue}if(n.startsWith("<![CDATA[",s)){const f=n.indexOf("]]>",s+9);if(f===-1)break;e.text?.(n.slice(s+9,f)),o=f+3;continue}const a=n.slice(s);if(a.length<9&&("<!--".startsWith(a)||"<![CDATA[".startsWith(a)))break;if(n.startsWith("<!",s)&&ge("declares a document type or another declaration"),n.startsWith("<?",s)){const f=n.indexOf("?>",s+2);if(f===-1)break;o=f+2;continue}const i=il(n,s+1);if(i===-1)break;const m=n.slice(s+1,i);if(m.startsWith("/"))e.end?.(St(m.slice(1).trim()));else{const f=m.endsWith("/"),d=f?m.slice(0,-1):m,u=ll.exec(d)?.[0]??ge("has a tag without a name"),p=St(u);e.start?.(p,cl(d.slice(u.length)),f),f&&e.end?.(p)}o=i+1}n=n.slice(o)};return{write:o=>{n+=o,r()},finish:()=>{r(),!t()&&n.includes("<")&&ge("ends inside a tag, a comment or a section")}}},Ne=async(e,t,n)=>{const r=Ir(t,n),o=new TextDecoder("utf-8",{fatal:!0}),s=e.getReader();try{for(;!n();){const{done:a,value:i}=await s.read();if(a){r.write(o.decode()),r.finish();return}r.write(o.decode(i,{stream:!0}))}}catch(a){if(a instanceof Y)throw a;ge("could not be read as UTF-8 text")}finally{s.cancel().catch(()=>{})}},dl=101010256,ul=33639248,fl=67324752,$r=22,ml=65535,un=46,fn=30,hl=1,mn=0,pl=8,gl=65535,be=4294967295,wl=new TextDecoder("utf-8"),ee=e=>{throw new Y("not-workbook",`the ZIP package ${e}`)},vl=e=>{const t=e.byteLength-$r,n=Math.max(0,t-ml);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===dl)return r;return ee("has no end of central directory record")},El=e=>{if(e.byteLength<$r)return ee("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=vl(t),r=t.getUint16(n+4,!0),o=t.getUint16(n+6,!0),s=t.getUint16(n+10,!0),a=t.getUint32(n+12,!0),i=t.getUint32(n+16,!0);if(r!==0||o!==0)return ee("spans several disks");if(s===gl||a===be||i===be)return ee("is a ZIP64 package");if(i+a>n)return ee("has a central directory past its end record");const m=new Map;let f=i;for(let d=0;d<s;d+=1){if(f+un>n||t.getUint32(f,!0)!==ul)return ee("has a malformed central directory");const u=t.getUint16(f+8,!0),p=t.getUint16(f+10,!0),w=t.getUint32(f+20,!0),E=t.getUint32(f+24,!0),b=t.getUint16(f+28,!0),T=t.getUint16(f+30,!0),O=t.getUint16(f+32,!0),C=t.getUint32(f+42,!0),q=f+un;if(q+b>n)return ee("has a name past its central directory");const D=wl.decode(e.subarray(q,q+b));if(w===be||E===be||C===be)return ee("has a ZIP64 entry");if(!D.endsWith("/")){if(m.has(D))return ee(`names ${D} twice`);m.set(D,{name:D,encrypted:(u&hl)!==0,method:p,compressedSize:w,uncompressedSize:E,localHeaderOffset:C})}f=q+b+T+O}return{bytes:e,entries:m}},xl=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+fn>n.byteLength||r.getUint32(o,!0)!==fl)return ee(`has no local header for ${t.name}`);const s=o+fn+r.getUint16(o+26,!0)+r.getUint16(o+28,!0),a=s+t.compressedSize;return a>n.byteLength?ee(`has the data of ${t.name} past its end`):{start:s,end:a}},Fr=e=>new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e),t.close()}}),bl=e=>Fr(e).pipeThrough(new DecompressionStream("deflate-raw")),Sl=(e,t)=>{let n=0;return new TransformStream({transform(r,o){if(n+=r.byteLength,n>t){o.error(new Y("too-large",`${e} inflates past ${t} bytes`));return}o.enqueue(r)}})},Le=(e,t,n)=>{const r=e.entries.get(t);if(r===void 0)return null;if(r.encrypted)throw new Y("encrypted",`${t} is encrypted`);if(r.method!==mn&&r.method!==pl)return ee(`compresses ${t} with method ${r.method}`);if(r.uncompressedSize>n)throw new Y("too-large",`${t} declares ${r.uncompressedSize} bytes`);const{start:o,end:s}=xl(e,r),a=e.bytes.subarray(o,s);return(r.method===mn?Fr(a):bl(a)).pipeThrough(Sl(t,n))},Ve=async(e,t,n)=>{const r=Le(e,t,n);if(r===null)return null;const o=new TextDecoder("utf-8",{fatal:!0}),s=r.getReader();let a="";try{for(;;){const{done:i,value:m}=await s.read();if(i)break;a+=o.decode(m,{stream:!0})}return a+o.decode()}catch(i){if(i instanceof Y)throw i;return ee(`has ${t}, which does not inflate to UTF-8 text`)}finally{s.releaseLock()}},hn="content.xml",yl="META-INF/manifest.xml",qr=e=>{throw new Y("not-workbook",`the spreadsheet ${e}`)},pn=(e,t)=>Le(e,hn,t.maxPartBytes)??qr(`has no ${hn}`),kl=async(e,t)=>{const n=Le(e,yl,t.maxPartBytes);if(n===null)return!1;let r=!1;return await Ne(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},Rl=async e=>{const t=[],n=new Set;let r=null,o=0;return await Ne(e,{start:(s,a,i)=>{s==="style"?r=a.get("family")==="table"?a.get("name")??null:null:s==="table-properties"&&r!==null&&a.get("display")==="false"?n.add(r):s==="table"&&(o===0&&t.push({name:a.get("name")??"",style:a.get("style-name")??""}),i||(o+=1))},end:s=>{s==="style"?r=null:s==="table"&&(o=Math.max(0,o-1))}},()=>!1),{tables:t,hidingStyles:n}},at=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},Tl=async(e,t,n)=>{const r=Ar(n);let o=0,s=0,a=!1,i=!1,m=0,f=1,d=new Map,u=0,p=null;return await Ne(e,{start:(w,E,b)=>{if(w==="table"){s===0&&(a=o===t,o+=1),b||(s+=1);return}!a||s!==1||(w==="table-row"?(f=at(E.get("number-rows-repeated")),d=new Map,u=0):w==="table-cell"||w==="covered-table-cell"?p={repeat:at(E.get("number-columns-repeated")),covered:w==="covered-table-cell",parts:[],paragraphs:0,paragraphDepth:0,annotationDepth:0}:p!==null&&p.annotationDepth===0&&(w==="annotation"&&!b?p.annotationDepth+=1:w==="p"||w==="h"?(p.paragraphs>0&&p.parts.push(`
|
|
12
|
+
`),p.paragraphs+=1,b||(p.paragraphDepth+=1)):p.paragraphDepth>0&&(w==="s"?p.parts.push(" ".repeat(at(E.get("c")))):w==="tab"?p.parts.push(" "):w==="line-break"&&p.parts.push(`
|
|
13
|
+
`))))},end:w=>{if(w==="table"){s=Math.max(0,s-1),s===0&&a&&(a=!1,i=!0);return}if(p!==null&&p.annotationDepth>0){w==="annotation"&&(p.annotationDepth-=1);return}if(!(!a||s!==1))if((w==="table-cell"||w==="covered-table-cell")&&p!==null){const E=p.covered?"":p.parts.join("");if(E!==""){const b=Math.min(u+p.repeat,n.maxColumns+1);for(let T=u;T<b;T+=1)d.set(T,E)}u+=p.repeat,p=null}else w==="table-row"?(r.addRow(m,d,f),m+=f):(w==="p"||w==="h")&&p!==null&&(p.paragraphDepth=Math.max(0,p.paragraphDepth-1))},text:w=>{p!==null&&p.annotationDepth===0&&p.paragraphDepth>0&&p.parts.push(w)}},()=>i||r.full()),r.table()},Cl=async(e,t)=>{if(await kl(e,t))throw new Y("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await Rl(pn(e,t)),o=[];let s=0;return n.forEach((a,i)=>{if(r.has(a.style)){s+=1;return}o.push({name:a.name,read:async m=>Tl(pn(e,t),i,m)})}),o.length===0&&qr("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},pe=Object.freeze({kind:"general"}),Ll=new Map([[0,"General"],[1,"0"],[2,"0.00"],[3,"#,##0"],[4,"#,##0.00"],[9,"0%"],[10,"0.00%"],[11,"0.00E+00"],[12,"# ?/?"],[13,"# ??/??"],[14,"mm-dd-yy"],[15,"d-mmm-yy"],[16,"d-mmm"],[17,"mmm-yy"],[18,"h:mm AM/PM"],[19,"h:mm:ss AM/PM"],[20,"h:mm"],[21,"h:mm:ss"],[22,"m/d/yy h:mm"],...[27,28,29,30,31,34,35,36,50,51,52,53,54,55,56,57,58].map(e=>[e,"yyyy-mm-dd"]),[32,"h:mm"],[33,"h:mm:ss"],[37,"#,##0 ;(#,##0)"],[38,"#,##0 ;[Red](#,##0)"],[39,"#,##0.00;(#,##0.00)"],[40,"#,##0.00;[Red](#,##0.00)"],[45,"mm:ss"],[46,"[h]:mm:ss"],[47,"mmss.0"],[48,"##0.0E+0"],[49,"@"]]),Ol=/^\[(h+|m+|s+)\]$/iu,Al=e=>{let t="",n=!1;for(let r=0;r<e.length;r+=1){const o=e[r];if(o===";")break;if(o==='"'){const s=e.indexOf('"',r+1);r=s===-1?e.length:s}else if(o==="\\"||o==="_"||o==="*")r+=1;else if(o==="["){const s=e.indexOf("]",r+1),a=e.slice(r,s===-1?e.length:s+1);Ol.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},Ml=e=>{const{text:t,elapsed:n}=Al(e);if(t===""||t==="general"||t.includes("@")||/[0#?.]e[+-]/u.test(t))return pe;const r=n||/[hs]/u.test(t)||t.includes("am/pm")||t.includes("a/p"),o=/[ydge]/u.test(t.replace(/am\/pm|a\/p/gu,""))||t.includes("m")&&!r;if(o||r)return{kind:"date-time",date:o,time:r,seconds:t.includes("s"),elapsed:n};if(/[0#?]\s*\/\s*[0#?]/u.test(t))return pe;const s=/[0#?][0#?,]*(?:\.[0#?]*)?,*/u.exec(t)?.[0];if(s===void 0)return pe;const a=/,*$/u.exec(s)?.[0].length??0,[i="",m=""]=s.slice(0,s.length-a).split("."),f=(m.match(/[0#?]/gu)??[]).length;return t.includes("%")?{kind:"percent",decimals:f}:{kind:"fixed",decimals:f,grouping:i.includes(","),scale:1e3**a}},Nl=(e,t)=>{const n=t.get(e)??Ll.get(e);return n===void 0?pe:Ml(n)},_t=e=>{if(Number.isInteger(e)&&Math.abs(e)<1e15)return String(e);const[t="",n]=e.toPrecision(15).split("e"),r=t.includes(".")?t.replace(/0+$/u,"").replace(/\.$/u,""):t;return n===void 0?r:`${r}E${n.startsWith("-")?n:`+${n.replace("+","")}`}`},gn=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return _t(e);const[o="",s]=r.split("."),a=n?o.replace(/\B(?=(\d{3})+(?!\d))/gu,","):o;return`${e<0&&/[1-9]/u.test(r)?"-":""}${a}${s===void 0?"":`.${s}`}`},jl=864e5,wn=86400,Dl=2958465,we=(e,t)=>String(e).padStart(t,"0"),Pl=(e,t)=>{if(!t&&e===0)return"1900-01-00";if(!t&&e===60)return"1900-02-29";const n=t?Date.UTC(1904,0,1):e<60?Date.UTC(1899,11,31):Date.UTC(1899,11,30),r=new Date(n+e*jl);return`${we(r.getUTCFullYear(),4)}-${we(r.getUTCMonth()+1,2)}-${we(r.getUTCDate(),2)}`},_l=(e,t,n)=>{if(e<0||e>=Dl+1)return _t(e);let r=Math.floor(e),o=Math.round((e-r)*wn);o===wn&&(r+=1,o=0);const s=Math.floor(o/3600),a=Math.floor(o%3600/60),i=`${we(t.elapsed?r*24+s:s,2)}:${we(a,2)}${t.seconds?`:${we(o%60,2)}`:""}`;if(t.elapsed||!t.date)return i;const m=Pl(r,n);return t.time?`${m} ${i}`:m},Il=(e,t,n)=>{switch(t.kind){case"general":return _t(e);case"date-time":return _l(e,t,n);case"percent":return`${gn(e*100,t.decimals,!1)}%`;case"fixed":return gn(e/t.scale,t.decimals,t.grouping)}},Br="_rels/.rels",oe=e=>{throw new Y("not-workbook",`the workbook ${e}`)},It=(e,t)=>{const n=Ir(t,()=>!1);n.write(e),n.finish()},$l=(e,t)=>{try{return decodeURIComponent(e)}catch{return oe(`points to a malformed part name (${t})`)}},Fl=(e,t)=>{const r=[...t.startsWith("/")?[]:e.split("/").slice(0,-1)];for(const o of t.split("/"))o===""||o==="."||(o===".."?(r.length===0&&oe(`points above its root (${t})`),r.pop()):r.push($l(o,t)));return r.join("/")},ql=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},vn=async(e,t,n)=>{const r=await Ve(e,t===""?Br:ql(t),n.maxPartBytes),o=new Map;return r===null||It(r,{start:(s,a)=>{if(s!=="Relationship")return;const i=a.get("Id"),m=a.get("Type"),f=a.get("Target");i===void 0||m===void 0||f===void 0||a.get("TargetMode")==="External"||o.set(i,{type:m,target:Fl(t,f)})}}),o},lt=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},Bl=e=>{const t=[];let n=!1;return It(e,{start:(r,o)=>{if(r==="workbookPr"){const s=o.get("date1904");n=s==="1"||s==="true"}else r==="sheet"&&t.push({name:o.get("name")??"",state:o.get("state")??"visible",relationship:o.get("id")??""})}}),{sheets:t,date1904:n}},Ul=async e=>{const t=[];let n=null,r=!1,o=0;return await Ne(e,{start:(s,a,i)=>{s==="si"?n=[]:s==="rPh"&&!i?o+=1:s==="t"&&o===0&&(r=!i)},end:s=>{s==="si"&&n!==null?(t.push(n.join("")),n=null):s==="rPh"?o=Math.max(0,o-1):s==="t"&&(r=!1)},text:s=>{r&&n!==null&&n.push(s)}},()=>!1),t},Hl=e=>{const t=new Map,n=[];let r=!1;return It(e,{start:(o,s)=>{if(o==="numFmt"){const a=Number(s.get("numFmtId")),i=s.get("formatCode");Number.isInteger(a)&&i!==void 0&&t.set(a,i)}else if(o==="cellXfs")r=!0;else if(o==="xf"&&r){const a=Number(s.get("numFmtId")??"0");n.push(Number.isInteger(a)?a:0)}},end:o=>{o==="cellXfs"&&(r=!1)}}),n.map(o=>Nl(o,t))},zl=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,Vl=e=>{const t=zl.exec(e);if(t===null)return e;const[,n,r]=t;return r===void 0||/^00:00(?::00)?$/u.test(r)?n??e:`${n} ${r}`},Zl=/^([A-Za-z]{1,3})(\d+)$/u,Wl=e=>{const t=Zl.exec(e)?.[1];if(t===void 0)return null;let n=0;for(const r of t.toUpperCase())n=n*26+(r.charCodeAt(0)-64);return n-1},Gl=(e,t,n,r)=>{const o=e.value.join("");switch(e.type){case"s":return o===""?"":t[Number(o)]??oe(`refers to the shared string ${o}, past its ${t.length}`);case"inlineStr":return e.inline.join("");case"b":return o===""?"":o==="1"||o==="true"?"TRUE":"FALSE";case"str":case"e":return o;case"d":return Vl(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?Il(a,n[e.style]??pe,r):s}}},Kl=async(e,t,n,r,o)=>{const s=Ar(t);let a=-1,i=new Map,m=0,f=null;return await Ne(e,{start:(d,u,p)=>{if(d==="row"){const w=Number(u.get("r"));a=Number.isInteger(w)&&w>a+1?w-1:a+1,i=new Map,m=0}else if(d==="c"){const w=Wl(u.get("r")??"")??m,E=Number(u.get("s")??"0");f={column:w,type:u.get("t")??"n",style:Number.isInteger(E)?E:0,value:[],inline:[],inValue:!1,inInlineText:!1,phoneticDepth:0}}else f!==null&&(d==="v"?f.inValue=!p:d==="rPh"&&!p?f.phoneticDepth+=1:d==="t"&&f.type==="inlineStr"&&f.phoneticDepth===0&&(f.inInlineText=!p))},end:d=>{if(d==="c"&&f!==null){const u=Gl(f,n,r,o);u!==""&&i.set(f.column,u),m=f.column+1,f=null}else d==="row"?s.addRow(a,i,1):f!==null&&(d==="v"?f.inValue=!1:d==="rPh"?f.phoneticDepth=Math.max(0,f.phoneticDepth-1):d==="t"&&(f.inInlineText=!1))},text:d=>{f!==null&&(f.inValue?f.value.push(d):f.inInlineText&&f.inline.push(d))}},s.full),s.table()},Xl=async(e,t)=>{const n=lt(await vn(e,"",t),"officeDocument")??oe("has no officeDocument relationship"),r=await Ve(e,n,t.maxPartBytes)??oe(`has no part ${n}`),{sheets:o,date1904:s}=Bl(r),a=await vn(e,n,t),i=lt(a,"sharedStrings"),m=i===null?null:Le(e,i,t.maxPartBytes),f=m===null?[]:await Ul(m),d=lt(a,"styles"),u=d===null?null:await Ve(e,d,t.maxPartBytes),p=u===null?[]:Hl(u),w=[];let E=0;for(const b of o){const T=a.get(b.relationship)??oe(`lists the sheet ${b.name} without its relationship`);if(b.state!=="visible"||!T.type.endsWith("/worksheet")){E+=1;continue}e.entries.has(T.target)||oe(`has no part ${T.target} for the sheet ${b.name}`),w.push({name:b.name,read:async O=>{const C=Le(e,T.target,t.maxPartBytes)??oe(`has no part ${T.target}`);return Kl(C,O,f,p,s)}})}return w.length===0&&oe("shows no sheet"),{sheets:w.slice(0,t.maxSheets),unshownSheets:E,unlistedSheets:Math.max(0,w.length-t.maxSheets)}},Yl=Object.freeze([80,75,3,4]),Ql=Object.freeze([208,207,17,224,161,177,26,225]),it=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),Jl=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),ei="mimetype",Ur=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),Hr=e=>Ur(e,Yl),zr=e=>Ur(e,Ql),ti=e=>{const t=e.byteLength-it.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===it[0]&&it.every((r,o)=>e[n+o]===r))return!0;return!1},ni=async(e,t)=>{if(zr(e))throw ti(e)?new Y("encrypted","the bytes are a password-protected workbook"):new Y("not-workbook","the bytes are a compound file (a legacy .xls)");if(!Hr(e))throw new Y("not-workbook","the bytes are no ZIP package");const n=El(e),r=await Ve(n,ei,t.maxPartBytes);if(r!==null&&Jl.has(r.trim()))return Cl(n,t);if(n.entries.has(Br))return Xl(n,t);throw new Y("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},ri=async(e,t)=>{const n=e.getReader(),r=[];let o=0;try{for(;;){const{done:i,value:m}=await n.read();if(i)break;if(o+=m.byteLength,o>t)return null;r.push(m)}}finally{n.cancel().catch(()=>{})}const s=new Uint8Array(o);let a=0;for(const i of r)s.set(i,a),a+=i.byteLength;return s},Vr=async(e,t)=>{try{return{kind:"table",table:await e.read(t)}}catch(n){return{kind:"refused",refusal:n instanceof Y?n.refusal:"not-workbook"}}},oi=async(e,t,n,r,o)=>{const s=await e.asset(_.explorerWorkbookHref(t),o);if(s.status==="cancelled")return null;if(s.status==="error")return{kind:"failure",failure:s.failure};let a;try{a=await ri(s.body,n.maxBytes)}catch{return o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}if(o.aborted)return null;if(a===null)return{kind:"refused",refusal:"too-large"};if(!(Hr(a)||zr(a)))return{kind:"not-package"};try{const i=await ni(a,n.limits),m=r===null?-1:i.sheets.findIndex(p=>p.name===r),f=Math.max(m,0),d=i.sheets[f];if(d===void 0)return{kind:"refused",refusal:"not-workbook"};const u=await Vr(d,n.budget);return o.aborted?null:{kind:"workbook",workbook:i,selected:f,sheet:u}}catch(i){return i instanceof Y?{kind:"refused",refusal:i.refusal}:o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}},si=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),ai=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},En=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},ct=e=>e.every(t=>t.every(n=>n==="")),Zr=({name:e,url:t,openUrl:n,state:r,children:o})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-spreadsheet-view","data-aqmx-spreadsheet":r,children:[l.jsx(Me,{name:e,openUrl:n,downloadUrl:t,icon:l.jsx(za,{})}),l.jsx(Ae,{scrollerProps:si,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),Wr=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=$(),s=c.use(de),a=c.useMemo(()=>({...jr(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=c.useMemo(()=>pt.serializeTsv(e),[e]);return l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":o,children:l.jsx(Ee.SpreadsheetBlock,{tsv:i,layout:s==="fill"?"fill":"inline",locale:r,labels:a,tapScrollCircle:pr})})},ye=({note:e,testId:t,code:n,download:r})=>{const{labels:o}=$();return l.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:r===void 0?l.jsx("p",{className:"aqmx-callout",role:"note","data-testid":t,children:e}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":t,"data-aqmx-unreadable":n,children:[l.jsx("p",{className:"aqmx-callout-body",children:e}),l.jsx("a",{className:"aqmx-callout-action",href:r.url,download:r.name,"data-testid":"markdown-explorer-spreadsheet-unreadable-download",children:o.download})]})})},Gr=({reading:e,name:t,url:n})=>{const{labels:r}=$();switch(e.kind){case"table":return l.jsxs(l.Fragment,{children:[e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:r.spreadsheetTruncated}):null,l.jsx(Wr,{rows:e.rows,title:t})]});case"empty":return l.jsx(ye,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(ye,{note:ai(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},li=({path:e,document:t})=>t.format==="workbook"?l.jsx(ci,{path:e,document:t}):l.jsx(ii,{path:e,document:t,format:t.format}),ii=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=$(),{name:a,url:i}=t,m=c.useCallback(async p=>{const w=await Nr(o,i,{format:n,legacyEncoding:r.legacyTextEncoding,maxBytes:r.spreadsheets.maxBytes,budget:qe},p);return w===null||w.kind==="failure"?w:{kind:"read",value:w}},[o,i,n,r.legacyTextEncoding,r.spreadsheets.maxBytes]),{shown:f,failure:d,retry:u}=Pt(e,a,m);return l.jsxs(Zr,{name:a,url:i,openUrl:_.explorerPlainTextHref(i),state:f===null?d===null?"loading":"failure":f.kind,children:[f===null&&d===null?l.jsx(ue,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,f===null&&d!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:d,alert:!1,onRetry:u,testId:"markdown-explorer-spreadsheet-failure"})}):null,f===null?null:l.jsx(Gr,{reading:f,name:a,url:i})]})},ci=({path:e,document:t})=>{const{config:n,data:r,labels:o}=$(),{name:s,url:a,firstSheetText:i}=t,m=c.useId(),f=c.useRef(null),d=c.useCallback(async x=>{const k=await oi(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:Xa,budget:qe},f.current,x);if(k===null||k.kind==="failure")return k;if(k.kind==="workbook")return{kind:"read",value:k};if(i!==null){const A=await Nr(r,a,{format:i,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:qe},x);return A===null||A.kind==="failure"?A:{kind:"read",value:{kind:"first-sheet",reading:A}}}return{kind:"read",value:{kind:"refused",refusal:k.kind==="not-package"?"not-workbook":k.refusal}}},[r,a,i,n.legacyTextEncoding,n.spreadsheets.maxBytes,n.spreadsheets.maxWorkbookBytes]),{shown:u,failure:p,retry:w}=Pt(e,s,d),[E,b]=c.useState(null),T=c.useRef(new WeakMap),O=u?.kind==="workbook"?u:null,C=O===null?null:E!==null&&E.workbook===O.workbook?E:{workbook:O.workbook,index:O.selected,reading:O.sheet},q=x=>{if(O===null)return;const k=O.workbook.sheets[x];if(k===void 0)return;f.current=k.name;let A=T.current.get(O.workbook);A===void 0&&(A=new Map([[O.selected,O.sheet]]),T.current.set(O.workbook,A));const M=A.get(x),P={workbook:O.workbook,index:x,reading:M??null};if(b(P),M!==void 0)return;const B=A;Vr(k,qe).then(G=>{B.set(x,G),b(v=>v===P?{...P,reading:G}:v)})},D=C===null?null:C.reading===null?"loading":C.reading.kind==="refused"?"unreadable":ct(C.reading.table.rows)?"empty":"table",h=u===null?p===null?"loading":"failure":u.kind==="first-sheet"?u.reading.kind:u.kind==="refused"?"unreadable":D??"loading",g=i===null?a:_.explorerPlainTextHref(a),R=x=>`${m}-sheet-${x}`,N=`${m}-panel`,I=C===null?null:O?.workbook.sheets[C.index]?.name??null,F=O!==null&&O.workbook.sheets.length>1;return l.jsxs(Zr,{name:s,url:a,openUrl:g,state:h,children:[u===null&&p===null?l.jsx(ue,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,u===null&&p!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:p,alert:!1,onRetry:w,testId:"markdown-explorer-spreadsheet-failure"})}):null,u?.kind==="refused"?l.jsx(ye,{note:En(o,u.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:u.refusal,download:{url:a,name:s}}):null,u?.kind==="first-sheet"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-first-sheet",children:o.spreadsheetWorkbookFirstSheet}),l.jsx(Gr,{reading:u.reading,name:s,url:a})]}):null,O===null||C===null||I===null?null:l.jsxs(l.Fragment,{children:[O.workbook.unshownSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unshown-sheets",children:o.spreadsheetUnshownSheets(O.workbook.unshownSheets)}):null,O.workbook.unlistedSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unlisted-sheets",children:o.spreadsheetUnlistedSheets(O.workbook.sheets.length)}):null,F?l.jsx(Qa,{names:O.workbook.sheets.map(x=>x.name),selected:C.index,onSelect:q,label:o.spreadsheetSheets(s),tabIdOf:R,panelId:N}):null,l.jsxs("div",{className:"aqmx-document-spreadsheet-sheet","data-testid":"markdown-explorer-spreadsheet-sheet","data-aqmx-sheet":C.index,...F?{role:"tabpanel",id:N,"aria-labelledby":R(C.index)}:{},children:[C.reading===null?l.jsx(ue,{label:o.spreadsheetSheetLoading,testId:"markdown-explorer-spreadsheet-sheet-skeleton"}):null,C.reading?.kind==="table"&&C.reading.table.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,C.reading?.kind==="refused"?l.jsx(ye,{note:En(o,C.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:C.reading.refusal,download:{url:a,name:s}}):null,C.reading?.kind==="table"&&ct(C.reading.table.rows)?l.jsx(ye,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,C.reading?.kind==="table"&&!ct(C.reading.table.rows)?l.jsx(Wr,{rows:C.reading.table.rows,title:o.spreadsheetSheetName(s,I)},C.index):null]})]})]})},Kr=Object.freeze({kind:"empty"}),di=(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 H.explorerHref(e,{...t,overrides:r})},ke=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:i})=>{const m=c.use(de);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,i]})},ui=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=$(),s=e.kind==="no-readme"?e.folder:null,a=e.kind==="failure"?e.folder:null,i=e.kind==="failure"?e.failure:null;switch(c.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(_.lastPathSegment(s)))},[t,s,o,r]),c.useEffect(()=>{a!==null&&i!==null&&n(r.documentFailed(_.lastPathSegment(a),re(r,i.reason)))},[a,i,n,r]),e.kind){case"empty":return l.jsx(ke,{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($t,{label:r.documentRegion});case"no-readme":return l.jsx(ke,{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(_.lastPathSegment(e.folder))})})});case"failure":return l.jsx(ke,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(Nt,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},$t=({label:e})=>{const{labels:t}=$();return l.jsx(ke,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(ue,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},xn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),fi=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=$(),a=c.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=Ta(),m=Ca(),f=c.useMemo(()=>o===void 0?void 0:h=>o(e,h),[o,e]),d=c.useRef(null),{editable:u,doubleClick:p,region:w,paneScroll:E,stale:b}=r;c.useLayoutEffect(()=>{if(u)return s.bindView(e,{anchor:()=>{const h=d.current,g=w(),R=h===null?null:h.querySelector(Ge);return h===null||g===null||R===null?null:rr(h,E.scrollerOf(g,R))}})},[s,e,u,w,E]);const T=h=>{const g=d.current,{target:R}=h;!p||g===null||!(R instanceof Element)||!tr(R)||(h.stopPropagation(),s.start(e,nr(R,g,g.ownerDocument.getSelection())))},O=c.useRef(null),C=c.useRef(b);c.useLayoutEffect(()=>{C.current=b});const q=c.useEffectEvent(h=>{const g=d.current,R=w(),N=g===null?null:ar(g,h.line);if(R===null||N===null)return!1;const I=E.scrollerOf(R,N);return I.scrollTop+=lr(N,h.line)-h.clientTop,!0}),D=c.useEffectEvent(h=>{const g=w();if(g===null)return;const R=()=>{for(const I of xn)g.removeEventListener(I,N,!0);O.current?.release===R&&(O.current=null)},N=()=>R();for(const I of xn)g.addEventListener(I,N,{capture:!0,passive:!0});O.current={point:h,release:R}});return c.useLayoutEffect(()=>{const h=s.takeReturn(e);if(h!==null)return queueMicrotask(()=>{q(h)&&C.current&&D(h)}),()=>O.current?.release()},[s,e]),c.useLayoutEffect(()=>{const h=O.current;h===null||b||(h.release(),q(h.point))},[t,b]),l.jsx("div",{ref:d,className:"aqmx-document-viewer",onDoubleClick:T,children:l.jsx(Ee.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:m,onMathDiagnostics:f,parseResult:a,content:null})})},Xr=({document:e,viewer:t})=>{const{labels:n}=$();return l.jsxs(l.Fragment,{children:[l.jsx(Me,{name:e.name,openUrl:_.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(Qo,{}),children:e.truncated?null:l.jsx(Ds,{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(Ee.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},dt=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=$(),s=c.useCallback(async f=>{const d=await r.text(e,f);return"kind"in d?d.kind==="failure"?{kind:"failure",failure:d.failure}:{kind:"read",value:d}:null},[r,e]),{shown:a,failure:i,retry:m}=Pt(e,t,s);return a!==null?l.jsx(Xr,{document:a,viewer:n}):i!==null?l.jsx(Nt,{failure:i,onRetry:m,testId:"markdown-explorer-markup-failure"}):l.jsx(ue,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},mi=Object.freeze({reason:"failed"}),hi=e=>{const{labels:t}=$();return l.jsx(ts,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ce,{failure:mi,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(c.Suspense,{fallback:l.jsx(ue,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(es,{...e})})})},pi=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:i,region:m,paneScroll:f,stale:d}=s;if(n==="edit"&&a!==void 0)return l.jsx(hi,{path:e,name:t.name,session:a,layout:i,viewer:r,region:m,paneScroll:f});if(n==="markup")return l.jsx(dt,{path:e,name:t.name,viewer:r});const u=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(fi,{path:e,document:t,viewer:r,editing:{editable:u,doubleClick:u&&i==="fill",region:m,paneScroll:f,stale:d}})}case"text":return l.jsx(Xr,{document:t,viewer:r});case"image":return n==="markup"&&Dt(t)==="svg"?l.jsx(dt,{path:e,name:t.name,viewer:r}):l.jsx(ha,{document:t});case"media":return l.jsx(Ba,{document:t});case"spreadsheet":return n==="markup"?l.jsx(dt,{path:e,name:t.name,viewer:r}):l.jsx(li,{path:e,document:t});case"file":return l.jsx(Hs,{document:t});case"failure":return l.jsx(Nt,{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)}`)}}},gi='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',wi=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:xr(e,n),r===void 0?null:Er(e,r.id),e.querySelector(Ge),e.querySelector(gi)];for(const s of o)if(s instanceof HTMLElement&&At(s))return s;return null},bn=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&At(t)},vi=e=>{const t=c.useRef(!1);return c.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 i=p=>{s=!(p.target instanceof Node&&n.contains(p.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},m=p=>{t.current=p.target instanceof Node&&n.contains(p.target)},f=p=>{p.relatedTarget===null&&s&&(t.current=!1)},d=()=>{const{activeElement:p,body:w}=r;p!==null&&p!==w&&(t.current=n.contains(p))},u=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",i,!0),o.addEventListener("mousedown",i,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",d),o.addEventListener("focus",u),n.addEventListener("focusout",f),()=>{clearTimeout(a),o.removeEventListener("pointerdown",i,!0),o.removeEventListener("mousedown",i,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",d),o.removeEventListener("focus",u),n.removeEventListener("focusout",f)}},[e]),t},Ei=Object.freeze({count:0,recovered:!1}),xi=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:m,paneScroll:f,announces:d,announceFailure:u,onDocumentShown:p})=>{const{labels:w,announcer:E,documents:b}=$(),{document:T}=t,O=c.useRef(null),C=c.useRef(null),q=c.useRef(null),D=c.useRef(0),h=vi(O),g=c.useRef({path:e,document:T}),R=c.useRef(null),N=c.useCallback(z=>{const V=O.current,X=tn(V,z,f);V!==null&&X!==null&&bn(V,X,h.current)},[f,h]),I=c.useCallback((z,V)=>{const X=D.current;setTimeout(()=>{!V.defaultPrevented&&D.current===X&&N(z)},0)},[N]),F=c.useCallback(z=>{setTimeout(()=>{z.defaultPrevented||N("#")},0)},[N]),x=c.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:N,followSameUrlJump:I,followEmptyFragment:F}),[i,e,N,I,F]),k=c.useCallback(()=>b.retry(e),[b,e]),A=cr(b,Ea),M=Yn(e),P=M!==void 0?"edit":n?"markup":"rendered",B=Dt(T)===null?void 0:P,G=c.useCallback(()=>O.current,[]),v=c.useMemo(()=>({session:M,layout:s,region:G,paneScroll:f,stale:r}),[M,s,G,f,r]),S=B==="edit"?!1:r,L=c.use(de),j=B==="edit"&&s==="fill"?"fill":L,[U,Z]=c.useState(0),K=c.useRef(0),W=c.useRef(!1),[ne,qt]=c.useState(Ei),[Bt,fo]=c.useState(0),Ut=c.useRef(u),Ht=c.useRef(r);c.useLayoutEffect(()=>{Ut.current=u,Ht.current=r},[u,r]);const mo=c.useMemo(()=>({announceFailure:z=>{Ht.current||Ut.current(z)},readPart:()=>{const z=b.readPart(e);K.current+=1;let V=!1,X=!1,Q=!1;return{settle:(fe,me)=>{if(z.settle(fe,me),!(Q||V)){if(me!==null){X=!0,W.current=!1;return}V=!0,qt(je=>({count:je.count+1,recovered:X}))}},release:()=>{Q||(Q=!0,z.release(),K.current-=1,V||fo(fe=>fe+1))}}},holdBusy:()=>{Z(V=>V+1);let z=!0;return()=>{z&&(z=!1,Z(V=>V-1))}}}),[b,e]),zt=S||U>0,ho=c.useEffectEvent((z,V)=>{const X=C.current;if(X!==null&&X.path===z&&X.snapshot===V)return;C.current={path:z,snapshot:V},b.noteShown(z,V);const Q=V.document;if(Q.kind==="failure"){W.current=!1,b.noteFailureShown(V)&&u(w.documentFailed(_.lastPathSegment(z),re(w,Q.failure.reason)));return}p?.(z,Q),!(!d||X!==null&&X.path===z&&X.snapshot.document.kind!=="failure")&&(W.current=K.current>0,W.current||E.announce(w.documentShown(Q.name)))});c.useEffect(()=>{ho(e,t)},[e,t]);const po=c.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),Vt=c.useEffectEvent(z=>{const V=O.current;if(V===null||!h.current)return null;const{activeElement:X,body:Q}=V.ownerDocument;return X!==null&&X!==Q?null:wi(V,T,z)}),go=c.useEffectEvent(z=>{const V=W.current;W.current=!1,!r&&(z&&Vt(null),d&&(z||V)&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});c.useEffect(()=>{ne.count>0&&go(ne.recovered)},[ne]);const wo=c.useEffectEvent(()=>{K.current>0||!W.current||(W.current=!1,d&&!r&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});c.useEffect(()=>{Bt>0&&wo()},[Bt]);const vo=c.useEffectEvent(z=>{const V=O.current;V!==null&&bn(V,z,h.current)}),Eo=c.useEffectEvent(z=>f.reveal(z)),xo=c.useEffectEvent(z=>tn(O.current,z,f));return c.useEffect(()=>{if(r)return;const z=g.current.path!==e,V=z||g.current.document!==T;g.current={path:e,document:T};const X=R.current!==e;R.current=e;let Q=null;m.kind==="page"?q.current!==m.navigation&&(q.current=m.navigation,D.current+=1,Q=m.fragment):m.fragment!==null&&(Q=m.fragment,po());const fe=()=>{const me=Q===null?null:xo(Q);if(!V){me!==null&&vo(me);return}const je=Vt(m.fragment);z&&me===null&&je!==null&&Eo(je)};X?queueMicrotask(fe):fe()},[m,e,T,r]),l.jsx(de,{value:j,children:l.jsx(ke,{kind:T.kind,view:B,label:a(e,T),stale:zt,busy:zt,frameRef:O,intent:A,children:l.jsx(yr,{value:x,children:l.jsx(wa,{children:l.jsx(wr,{value:mo,children:l.jsx(pi,{path:e,document:T,view:P,viewer:o,onRetry:k,editing:v},e)})})})})})},Ft=Object.freeze({kind:"skeleton"}),bi=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=le(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:le(r);return n===null||a===null?Ft:{kind:"document",path:n,snapshot:a,stale:!0}},Si=(e,t)=>t.status==="deferred"?Ft:{kind:"document",path:e,snapshot:t,stale:!1},yi=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?Si(t.path,c.use(t.promise)):t;return o.kind!=="document"?l.jsx($t,{label:r.regionLabel(e,null)}):l.jsx(xi,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Yr=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})=>{const{config:d,labels:u,locale:p,theme:w,documents:E,data:b}=$(),T=Ee.useMarkdownToolbarState(),O=c.useRef(!1);c.useLayoutEffect(()=>{O.current=!0},[]);const[C,q]=c.useState(null),[D,h]=c.useState(n),g=c.useCallback(()=>e===null?void 0:E.peek(e),[E,e]),R=c.useSyncExternalStore(E.subscribe,g,g),N=c.useCallback(()=>C===null?void 0:E.peek(C),[E,C]),I=c.useSyncExternalStore(E.subscribe,N,N);c.useLayoutEffect(()=>e===null?void 0:E.open(e),[E,e]),c.useLayoutEffect(()=>C===null?void 0:E.retain(C),[E,C]);const F=e===null?Ft:bi(e,R,C,I,!O.current),x=e===null?null:F.kind==="document"&&!F.stale?F.path:C;x!==C&&q(x);const k=F.kind!=="document"||F.path===e;k&&n!==D&&h(n);const A=c.useMemo(()=>rl(u,p),[u,p]),M=c.useMemo(()=>({read:(L,j)=>pa(b,L,j)}),[b]),P=c.useMemo(()=>[...d.iframeHosts],[d]),B=o.kind==="panel",G=c.useMemo(()=>({labels:A,spreadsheetLocale:p,spreadsheetTapScrollCircle:pr,emptyMessage:u.documentEmpty,theme:w,availableStyles:d.documentStyles,iFrameAllowedDomains:P,embeds:d.embeds,linkComponent:Ra,toolbar:T,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:ur,scrollBarGutter:B?void 0:Mt,imageSource:M}),[A,p,u.documentEmpty,w,d.documentStyles,P,d.embeds,T,r,B,M]),v=c.useCallback((L,j)=>B?j===null||j.kind==="failure"?_.lastPathSegment(L):j.name:u.documentRegion,[B,u.documentRegion]),S=B?"content":"fill";return e===null?l.jsx(de,{value:S,children:l.jsx(ui,{absence:t,announces:i,announceFailure:m})}):l.jsx(de,{value:S,children:l.jsx(c.Suspense,{fallback:l.jsx($t,{label:v(e,null)}),children:l.jsx(yi,{requestedPath:e,content:F,markup:k?n:D,viewer:G,editLayout:r.editLayout,regionLabel:v,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})})})},ki=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:i}=$(),m=Re(I=>I.style),f=Re(I=>I.align),d=Oe(),u=te.useLocation(),p=Ze(),{view:w,overrides:E,embed:b}=r,T=c.useCallback(I=>{if(p.kind!=="location")return;const F=di(s,p.location,I);F!==null&&d(F,"browse")},[s,d,p]),O=c.useCallback(I=>{a.update({style:I}),T("style")},[a,T]),C=c.useCallback(I=>{a.update({align:I}),T("align")},[a,T]),q=Dr(s,E.style,m),D=Pr(E.align,f),h=c.useMemo(()=>({style:q,onStyleChange:O,align:D,onAlignChange:C,showToc:b.showToc!==!1,showStyle:b.showStyle!==!1,showAlign:b.showAlign!==!1,padding:b.padding,width:b.width,maxWidth:b.maxWidth,editLayout:"fill"}),[q,O,D,C,b]),g=c.useMemo(()=>({kind:"page",view:w,overrides:E,embed:b}),[w,E,b]),R=c.useMemo(()=>({kind:"page",fragment:u.hash,navigation:u}),[u]),N=c.useCallback(I=>i.announce(I),[i]);return l.jsx(Yr,{path:e,absence:t,markup:n,display:h,navigation:g,fragment:R,paneScroll:Xs,announces:!0,announceFailure:N,onDocumentShown:o})},Ri=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=$(),i=Re(g=>g.style),m=Re(g=>g.align),[f,d]=c.useState(()=>Dr(s,void 0,i)),u=Pr(void 0,m),p=c.useCallback(g=>a.update({align:g}),[a]),{maximized:w,onDocumentLink:E,pendingHash:b,onHashConsumed:T,announceFailure:O,paneScroll:C}=r,q=c.useMemo(()=>({style:f,onStyleChange:d,align:u,onAlignChange:p,showToc:w,showStyle:w,showAlign:w,padding:void 0,width:void 0,maxWidth:void 0,editLayout:w?"fill":"content"}),[f,u,p,w]),D=c.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),h=c.useMemo(()=>({kind:"panel",fragment:b,consume:T}),[b,T]);return l.jsx(Yr,{path:e,absence:t,markup:n,display:q,navigation:D,fragment:h,paneScroll:C,announces:!1,announceFailure:O,onDocumentShown:o})},Qr=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(ki,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(Ri,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function Ti({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Jr=y.forwardRef(Ti);function Ci({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 eo=y.forwardRef(Ci);function Li({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Oi=y.forwardRef(Li);function Ai({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Mi=y.forwardRef(Ai);function Ni({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 ji=y.forwardRef(Ni);function Di({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Pi=y.forwardRef(Di);function _i({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),y.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 to=y.forwardRef(_i);function Ii({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 $i=y.forwardRef(Ii);function Fi({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 qi=y.forwardRef(Fi),no=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=$(),[s,a]=c.useState(!1),i=()=>{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:i,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Bi="Control+E Meta+E",ro=(e,t,n)=>n&&t?"split":e.view,yt=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Ui=e=>e==="split"?null:e,oo=e=>e==="preview"?"editor":"preview",so=e=>/Mac|iPhone|iPad|iPod/u.test(e),ao=(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)},Sn=(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)},Hi=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:m}=$(),f=c.useId(),[d,u]=c.useState(null),[p,w]=c.useState(0),[E,b]=c.useState(null),[T,O]=c.useState(null),C=c.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),q=c.useCallback(()=>{b(null),O(null)},[]),D=Zn({open:n,onOpen:q,onDismiss:r});c.useEffect(()=>{if(!n)return;const R=new AbortController;return u(null),o.revisions(e,R.signal).then(N=>{"kind"in N&&u(N)}),()=>R.abort()},[n,o,e,p]),c.useEffect(()=>{if(!n||E===null)return;const R=new AbortController;return O(null),o.revision(e,E,R.signal).then(N=>{"kind"in N&&O(N)}),()=>R.abort()},[n,o,e,E]);const h=()=>{T===null||T.kind!=="revision"||(s.replaceDraft(e,T.text),m.announce(a.historyRestored(t)),r())},g=d!==null&&d.kind==="revisions"?d.revisions.find(R=>R.id===E):void 0;return l.jsx("dialog",{...D,className:"aqmx-confirm aqmx-history","aria-labelledby":f,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:a.historyTitle(t)}),d===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):d.kind==="failure"?l.jsx(ce,{failure:d.failure,alert:!1,onRetry:()=>w(R=>R+1),testId:"markdown-explorer-history-failure"}):d.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:d.revisions.map(R=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":R.id===E,"data-testid":"markdown-explorer-history-entry",onClick:()=>b(R.id),children:[l.jsx("span",{children:Sn(R,C,a.historyEntry)}),R.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,R.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},R.id))}),E===null?null:T===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):T.kind==="failure"?l.jsx(ce,{failure:T.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":g===void 0?a.historyTitle(t):Sn(g,C,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:T.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":T===null||T.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:h,children:a.historyRestore})]})]})})},zi=e=>{const{documents:t}=$(),n=c.useCallback(()=>t.peek(e),[t,e]),r=c.useCallback(()=>t.peekSeeded(e),[t,e]),o=c.useSyncExternalStore(t.subscribe,n,r),s=le(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:_.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},ae=e=>{e.stopPropagation()},Vi=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=$(),m=c.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[f,d]=c.useState(null),u=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const b=a.session(e);b?.dirty===!0?d(b.save.kind==="draft"?"draft":"unsaved"):a.close(e)},p=()=>{m||(Jo(),r&&a.sideBySide()&&s?.prepare?.())},w=n?o?i.editDraftDocumentNamed(t):i.editDocumentNamed(t):null,E=o?i.editDraftDocument:i.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:w===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:m?i.closeEditor:w===null?E:w,"aria-label":w===null?void 0:w,"aria-pressed":m,"data-testid":"markdown-explorer-document-edit",onClick:u,onDoubleClick:ae,onPointerEnter:p,onFocus:p,children:[l.jsx($i,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(Wn,{open:f!==null,title:f==="draft"?i.draftDiscardTitle:i.unsavedTitle,body:f==="draft"?i.draftDiscardBody(t):i.unsavedBody(t),confirmLabel:i.unsavedDiscard,cancelLabel:i.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{d(null),a.close(e)},onCancel:()=>d(null)})]})},Zi=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=$(),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:ae,children:[l.jsx(Oi,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Wi=({session:e})=>{const{labels:t}=$(),n=Ao(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})},Gi=Object.freeze(["editor","split","preview"]),Ki=Object.freeze(["editor","preview"]),Xi=Object.freeze({editor:eo,split:qi,preview:to}),Yi=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=$(),m=Jn(),f=ro(r,m,o),d=o?Gi:Ki,u=c.useId(),p=c.useRef(new Map),w={editor:{label:i.editViewEditor,tooltip:i.editViewEditorTooltip},split:{label:i.editViewSplit,tooltip:i.editViewSplitTooltip},preview:{label:i.editViewPreview,tooltip:i.editViewPreviewTooltip}},E=()=>{a.preparePreview(e),s?.prepare?.()},b=T=>{if(!ao(T.nativeEvent,so(navigator.platform)))return;Ct(T);const O=oo(f);yt(a,e,O,o),p.current.get(O)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?i.editViewNamed(t):i.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:b,children:d.map(T=>{const O=Xi[T],{label:C,tooltip:q}=w[T],D=T==="preview"?E:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:h=>{h===null?p.current.delete(T):p.current.set(T,h)},type:"radio",name:u,value:T,checked:T===f,"aria-label":C,"aria-keyshortcuts":T==="split"?void 0:Bi,title:q,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>yt(a,e,T,o),onDoubleClick:ae,onPointerEnter:D,onFocus:D}),l.jsx(O,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:C})]},T)})})},Qi=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=$(),[i,m]=c.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",d=f||!r.dirty,u=()=>{s.flush(e);const w=s.session(e);w===void 0||!w.dirty||w.save.kind==="saving"||s.save(e)},p=w=>n?{className:"aqmx-icon-button","aria-label":w}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...p(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ae,children:[l.jsx(Mi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(Yi,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...p(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ae,children:[l.jsx(ji,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...p(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":d,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:u,onDoubleClick:ae,children:[l.jsx(Pi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Hi,{path:e,documentName:t,open:i,onClose:()=>m(!1)}):null]})},Ji=({path:e,session:t})=>{const{edits:n}=$();return t.save.kind!=="grant"?null:l.jsx(no,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ec=new Set,tc=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=$(),a=c.useCallback(()=>r.peek(e),[r,e]),i=c.useCallback(()=>r.peekSeeded(e),[r,e]),m=c.useSyncExternalStore(r.subscribe,a,i),f=c.useCallback(()=>r.answerStampOf(e),[r,e]),d=c.useSyncExternalStore(r.subscribe,f,f),[u]=c.useState(()=>new Set),[p,w]=c.useState(ec),[E,b]=c.useState(null);E!==null&&(E.path!==e||E.markup!==n)&&b(null);const T=c.useRef(null);c.useLayoutEffect(()=>(T.current=e,()=>{T.current=null}),[e]);const O=c.useRef(n);c.useLayoutEffect(()=>{O.current=n},[n]);const C=c.useCallback(()=>{const h=e,g=r.peek(h);u.has(h)||g?.status==="pending"||(u.add(h),w(new Set(u)),b(null),(async()=>{try{const R=await r.refresh(h);if(T.current!==h||R.status==="superseded")return;if(R.status==="failed"){b({path:h,failure:R.failure,stamp:r.answerStampOf(h),markup:O.current}),o.announce(s.documentRefreshFailed(re(s,R.failure.reason)));return}if(R.status==="shown"&&(t||R.failed))return;const N=le(r.peek(h));if(N===null||N.document.kind==="failure")return;o.announce(s.documentRefreshed(N.document.name))}finally{u.delete(h),w(new Set(u))}})())},[e,t,u,r,o,s]),q=p.has(e),D=E!==null&&E.path===e&&E.stamp===d&&E.markup===n?E.failure:null;return{refreshing:q,unavailable:q||m?.status==="pending",failure:D,refresh:C}},nc=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},lo=Object.freeze({kind:"page"}),io=({path:e,placement:t,markup:n})=>{const{labels:r}=$(),{refreshing:o,unavailable:s,failure:a,refresh:i}=tc(e,t.kind==="page",n.shown),m=Ua(e),f=zi(e),d=Yn(e),u=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,p=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,w=t.kind==="panel",E=t.kind==="panel"?t.documentName:f.name,b=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":d===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[d===void 0?null:l.jsx(Wi,{session:d}),d===void 0?null:l.jsx(Qi,{path:e,documentName:E,iconOnly:w,session:d,previewAvailable:b}),d===void 0&&m!==null?l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?nc(r,m):p,"aria-label":p===null?void 0:p,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ae,children:[l.jsx(eo,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,d!==void 0||f.edit?.kind==="inline"||f.edit?.kind==="draft"?l.jsx(Vi,{path:e,documentName:E,iconOnly:w,previewAvailable:b,draft:f.edit?.kind==="draft"}):f.edit?.kind==="external"?l.jsx(Zi,{href:f.edit.href,documentName:E,iconOnly:w}):null,d===void 0?l.jsxs("button",{type:"button",className:u===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:u===null?r.refreshDocument:u,"aria-label":u===null?void 0:u,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:i,onDoubleClick:ae,children:[l.jsx(Jr,{"aria-hidden":"true"}),u===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),d!==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(re(r,a.reason))}),d===void 0?null:l.jsx(Ji,{path:e,session:d})]})},rc=({location:e})=>{const t=e.doc,n=c.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Rr(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Be,children:[l.jsx(io,{path:t,placement:lo,markup:r}),l.jsx(Qr,{path:t,absence:Kr,markup:e.markup,variant:n})]})},co=({holds:e,testId:t})=>{const{labels:n,announcer:r}=$(),o=c.useId();c.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=c.useCallback(()=>r.shownIn(o),[r,o]),a=c.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]})},he=Object.freeze([]),oc=e=>{const t=new Set;let n=he,r=[],o=!1;const s=[],a=d=>{n=d;for(const u of[...t])u()},i=()=>s.at(-1)?.region,m=d=>{const u=i();d(),i()!==u&&n!==he&&a(he)},f=()=>{o=!1;const d=r.map(u=>"sentence"in u?u.sentence:u.list(u.items));r=[],a(Object.freeze(d))};return{announce:d=>{if(typeof d=="string")r.push({sentence:d});else{const u=r.find(p=>"list"in p&&p.list===d.list);u!==void 0&&"items"in u?u.items.push(d.item):r.push({list:d.list,items:[d.item]})}o||(o=!0,n!==he&&a(he),e.request(f))},subscribe:d=>(t.add(d),()=>{t.delete(d)}),claim:d=>{const u={region:d};return m(()=>s.push(u)),()=>m(()=>{const p=s.indexOf(u);p!==-1&&s.splice(p,1)})},shownIn:d=>i()===d?n:he}},se=Object.freeze({status:"cancelled"}),yn=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(_.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return _.failureOf(n,r)},sc=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((d,u)=>globalThis.fetch(d,u)),o=(d,u)=>`${e}/${d}?${new URLSearchParams(u).toString()}`,s=d=>{d.status===401&&t(null);const u=d.headers.get(_.EXPLORER_SCOPE_HEADER);u!==null&&t(u)},a=async(d,u,p,w)=>{let E;try{E=await r(d,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return w({reason:"failed"})}s(E);let b;try{b=await E.json()}catch{return w({reason:_.failureReasonOfStatus(E.status)})}let T;try{T=p(b)}catch{T=!1}if(T)return b;const O=yn(b);return w(O!==null?O:{reason:E.status===200?"failed":_.failureReasonOfStatus(E.status)})},i={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_REFRESH_PROOF},m={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_EDIT_PROOF,"Content-Type":`${_.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},f=async(d,u,p)=>{const w=await a(d,u,p,E=>_.failureDocument(E.reason,E.code));return u.signal.aborted?se:w};return{tree:d=>a(o("tree",{[_.EXPLORER_DATA_QUERY.source]:d}),{method:"GET"},_.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(d,u,p)=>{const w=await a(o("children",{[_.EXPLORER_DATA_QUERY.source]:d,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerChildrenResult,E=>({status:"error",failure:E}));return p.aborted?se:w},ancestors:async(d,u,p)=>{const w=await a(o("ancestors",{[_.EXPLORER_DATA_QUERY.source]:d,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return p.aborted?se:w},reveal:async(d,u,p)=>{const w=await a(o("reveal",{[_.EXPLORER_DATA_QUERY.source]:d,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerRevealResult,E=>({status:"error",failure:E}));return p.aborted?se:w},document:(d,{refresh:u})=>a(o("document",{[_.EXPLORER_DATA_QUERY.path]:d}),u?{method:"GET",headers:i}:{method:"GET"},_.isExplorerDocument,p=>_.failureDocument(p.reason,p.code)),text:async(d,u)=>{const p=await a(o("text",{[_.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:u},_.isExplorerTextAnswer,w=>_.failureDocument(w.reason,w.code));return u.aborted?se:p},asset:async(d,u)=>{let p;try{p=await r(d,{method:"GET",credentials:"same-origin",signal:u})}catch{return u.aborted?se:{status:"error",failure:{reason:"failed"}}}if(s(p),p.ok)return u.aborted?se:{status:"ok",body:p.body===null?new ReadableStream({start:b=>b.close()}):p.body};let w=null;try{w=await p.json()}catch{}if(u.aborted)return se;const E=yn(w);return{status:"error",failure:E===null?{reason:_.failureReasonOfStatus(p.status)}:E}},edit:(d,u)=>f(o("edit",{[_.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:u},_.isExplorerEditAnswer),save:(d,u,p,w)=>f(o("save",{[_.EXPLORER_DATA_QUERY.path]:d,[_.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:m,body:p,signal:w},_.isExplorerSaveAnswer),preview:(d,u,p)=>f(o("preview",{[_.EXPLORER_DATA_QUERY.path]:d}),{method:"POST",headers:m,body:u,signal:p},_.isExplorerPreviewAnswer),revisions:(d,u)=>f(o("revisions",{[_.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:u},_.isExplorerRevisionsAnswer),revision:(d,u,p)=>f(o("revision",{[_.EXPLORER_DATA_QUERY.path]:d,[_.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:p},_.isExplorerRevisionAnswer),refresh:d=>a(o("refresh",{[_.EXPLORER_DATA_QUERY.source]:d}),{method:"POST",headers:i},_.isExplorerTreeResult,u=>({status:"error",failure:u}))}},ac=()=>{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}}},lc=e=>{const t=J.readStorage(e);if(t===null)return H.NO_TREE_SETTING_CHANGES;try{return H.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),H.NO_TREE_SETTING_CHANGES}},kn=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=lc(e);n={changes:s,settings:H.applyTreeSettingChanges(t,s)}}return n},o=xe();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:i}=r(),m=H.recordTreeSettingChange(a,s,H.advanceTreeSetting(i,s)[s],t);return n={changes:m,settings:H.applyTreeSettingChanges(t,m)},o.emit(),J.writeStorage(e,H.serializeTreeSettingChanges(m)),n.settings}}},ic=Object.freeze({status:"refreshed"}),cc=Object.freeze({status:"superseded"}),kt=Object.freeze({status:"deferred"}),dc=Gn(kt),uo=4,uc=uo-1,Rn=Object.freeze({status:"loading"}),fc=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),mc=e=>{const t=new Map,n=gr(),r=new Map,o=new Map,s=new Map,a=new Map,i=xe(),m=new Set;let f=0,d=0;const u={direct:null,bulk:null},p=new Set;let w=!1,E=0;const b=()=>{E+=1,i.emit()},T=v=>o.get(v)??0,O=v=>{let S=a.get(v);return S===void 0&&(S={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(v,S)),S},C=(v,S,L)=>{v.inFlight.delete(S),f-=1,L.lane==="bulk"&&(d-=1)},q=v=>{const S=a.get(v);if(S!==void 0){for(const[L,j]of[...S.inFlight])C(S,L,j),j.controller.abort();S.direct.clear(),S.bulk.clear(),S.unclaimed.clear()}},D=v=>{const S=T(v)+1;return o.set(v,S),q(v),S},h=(v,S)=>{const L=Se(v),j={promise:v,opened:S,stale:!1,loadedAt:L?.status==="ok"?L.loadedAt:null};return v.status==="pending"&&v.then(U=>{U.status==="ok"&&(j.loadedAt=U.loadedAt)}),j},g=v=>{let S=r.get(v);return S===void 0&&(S=new Map,r.set(v,S)),S},R=v=>{const S=[...a.keys()],L=u[v],j=L===null?0:S.indexOf(L)+1;for(let U=0;U<S.length;U+=1){const Z=S[(j+U)%S.length],K=Z===void 0?void 0:a.get(Z);if(!(Z===void 0||K===void 0)){for(const W of K[v])if((K.claims.get(W)??0)!==0)return K[v].delete(W),u[v]=Z,{sourceId:Z,path:W}}}return null},N=(v,S,L,j)=>{const U=a.get(v);if(U===void 0||U.inFlight.get(S)!==L)return;C(U,S,L);const Z=(U.claims.get(S)??0)>0,K=g(v);if(j.status==="ok"?K.set(S,{status:"loaded",entries:j.entries}):j.status==="error"&&Z?K.set(S,{status:"failed",failure:j.failure}):K.delete(S),b(),j.status==="error"&&Z){const W={sourceId:v,path:S,failure:j.failure};for(const ne of[...m])ne(W)}F()},I=(v,S,L)=>{const j={controller:new AbortController,lane:L};O(v).inFlight.set(S,j),f+=1,L==="bulk"&&(d+=1),e.children(v,S,j.controller.signal).then(U=>N(v,S,j,U),()=>N(v,S,j,fc))},F=()=>{for(;f<uo;){const v=R("direct");if(v!==null){I(v.sourceId,v.path,"direct");continue}const S=d<uc?R("bulk"):null;if(S===null)return;I(S.sourceId,S.path,"bulk")}},x=(v,S,L)=>{if(!(S.direct.delete(L)||S.bulk.delete(L))){const U=S.inFlight.get(L);if(U===void 0)return!1;C(S,L,U),U.controller.abort()}return r.get(v)?.delete(L),!0},k=()=>{w=!1;let v=!1;for(const S of p){const L=O(S);for(const j of L.unclaimed)(L.claims.get(j)??0)===0&&x(S,L,j)&&(v=!0);L.unclaimed.clear()}p.clear(),v&&(b(),F())},A=(v,S)=>{t.set(v,h(Te(e.tree(v)),S))},M=(v,S,L)=>{D(v);const j=h(Gn(S),L);return t.set(v,j),r.delete(v),b(),F(),j},P=(v,S,L,j)=>{if(L!==T(v)||t.get(v)!==S)return;const U=Se(S.promise);if(!(j.status!=="ok"||U?.status!=="ok"||S.loadedAt===null||j.loadedAt<=S.loadedAt)){if(He(U.entries,j.entries)){S.loadedAt=j.loadedAt;return}M(v,j,S.opened)}},B=(v,S)=>{const L=t.get(v);return L!==void 0&&Se(L.promise)?.status===S},G=(v,S)=>{S.stale=!1;const L=T(v);e.tree(v).then(j=>P(v,S,L,j))};return{read:v=>t.get(v)?.promise??dc,open:v=>{const S=n.resumes(v),L=n.hold(v),j=t.get(v);return j===void 0||B(v,"deferred")?(A(v,!0),b()):S||(j.opened&&B(v,"error")?(A(v,!0),b()):(j.opened=!0,j.stale&&B(v,"ok")&&G(v,j))),L},retry:v=>{B(v,"error")&&(A(v,!0),b())},seed:(v,S)=>{const L=S.then(Z=>Z===null?kt:Z,()=>kt),j=t.get(v);if(j!==void 0&&B(v,"ok")){const Z=T(v);L.then(K=>P(v,j,Z,K));return}D(v);const U=h(Te(L),j?.opened===!0);t.set(v,U),r.delete(v),F(),L.then(Z=>{t.get(v)===U&&(Z.status==="deferred"&&n.isHeld(v)&&A(v,U.opened),b())})},refresh:async v=>{const S=(s.get(v)??0)+1;s.set(v,S);const L=await e.refresh(v);if(s.get(v)!==S)return cc;if(L.status==="error")return{status:"failed",failure:L.failure};const j=t.get(v);if(!(j!==void 0&&j.loadedAt!==null&&B(v,"ok")&&j.loadedAt>L.loadedAt)){const Z=M(v,L,!0);if(j!==void 0&&j.promise.status==="pending"){const K=T(v);j.promise.then(W=>P(v,Z,K,W))}}for(const[Z,K]of t)Z!==v&&Se(K.promise)?.status==="ok"&&(K.stale=!0);return ic},children:(v,S)=>r.get(v)?.get(S),claimChildren:(v,S)=>{const L=O(v),j=g(v);let U=!1,Z=!1;for(const[W,ne]of S)L.claims.set(W,(L.claims.get(W)??0)+1),j.get(W)===void 0?(j.set(W,Rn),L[ne].add(W),U=!0,Z=!0):ne==="direct"&&L.bulk.delete(W)&&(L.direct.add(W),Z=!0);U&&b(),Z&&F();let K=!1;return()=>{if(!K){K=!0;for(const W of S.keys()){const ne=(L.claims.get(W)??0)-1;ne>0?L.claims.set(W,ne):(L.claims.delete(W),L.unclaimed.add(W))}p.add(v),!w&&(w=!0,queueMicrotask(k))}}},retryChildren:(v,S)=>{const L=r.get(v);if(L===void 0||L.get(S)?.status!=="failed")return;const j=O(v);if((j.claims.get(S)??0)>0){L.set(S,Rn),j.direct.add(S),b(),F();return}L.delete(S),b()},pendingChildren:v=>{const S=a.get(v);return S===void 0?0:S.direct.size+S.bulk.size+S.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))D(v);for(const[v,S]of s)s.set(v,S+1);t.clear(),r.clear(),b()},subscribeChildrenFailures:v=>(m.add(v),()=>{m.delete(v)}),subscribe:i.subscribe,version:()=>E}},hc=(e,t)=>{let n=e;const r=xe();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},pc=1;let Ie=0,ie=null;const gc=()=>{const{documentElement:e,body:t}=document;Ie===0&&(ie={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"),Ie+=1;let n=!1;return()=>{n||(n=!0,Ie-=1,!(Ie>0||ie===null)&&(e.style.overflow=ie.htmlOverflow,t.style.overflow=ie.bodyOverflow,e.style.scrollbarGutter=ie.htmlGutter,t.style.scrollbarGutter=ie.bodyGutter,ie=null))}},wc=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Tn=1,vc=1e3,Cn=e=>e.getClientRects().length>0,ut="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.",Ec=e=>{if(!Cn(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+pc)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. ${ut}`;if(t.height<Tn)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. ${ut}`;for(const{selector:r,name:o}of wc)for(const s of e.querySelectorAll(r)){if(!Cn(s))continue;const a=s.getBoundingClientRect().height;if(a<Tn)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. ${ut}`}return null},xc=e=>{let t=!1,n;const r=()=>{n=void 0;const a=Ec(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,vc))},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)}},bc=(e,t)=>{c.useEffect(()=>e?gc():void 0,[e]),c.useEffect(()=>{const n=t.current;if(!(!e||n===null))return xc(n)},[e,t])},Ln='[data-testid="markdown-explorer-view-switch"]',Sc=[{control:Ln,successors:[Ln,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],yc=e=>{for(const t of Sc){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},kc=(e,t)=>{const n=c.useRef(null);c.useEffect(()=>{const o=i=>{const m=e.current;n.current=m!==null&&i instanceof Element&&m.contains(i)?yc(i):null},s=i=>o(i.target);o(document.activeElement);const a=i=>{const m=i.target;i.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=c.useRef(t);c.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 f=e.current;if(f===null)return!0;for(const d of o.control.successors)for(const u of f.querySelectorAll(d))if(u!==o.element&&(u.focus({preventScroll:!0}),document.activeElement===u))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const i=new MutationObserver(()=>{s()&&i.disconnect()});return i.observe(a,{childList:!0,subtree:!0}),()=>i.disconnect()},[t,e])},Rc=c.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-CblPMzQi.cjs")).then(e=>({default:e.TreeLayout}))),Tc=c.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-BZ0zTAoi.cjs")).then(e=>({default:e.MultiLayout}))),Cc=64,Lc={request:e=>{requestAnimationFrame(e)}},On=e=>{e.documents.clear(),e.trees.clear()},ft=(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)},Oc=(e,t)=>{const[n,r]=c.useState(()=>({overrides:t,locale:e,labels:wt(e,t)}));if(n.locale===e&&Lo(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:wt(e,t)};return r(o),o.labels},Ac=(e,t,n)=>{const[r,o]=c.useState(()=>({scope:t,store:kn(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:kn(e,n)};return o(s),s.store},mt=(e,t)=>{const[n,r]=c.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Mc=()=>oc(Lc),An="on",Nc="off",jc=Object.freeze({kind:"unavailable"}),Dc=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")},Pc=(e,t)=>{const n=le(e.peek(t));return n===null||n.document.kind==="failure"?_.lastPathSegment(t):n.document.name},_c=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:m=!1,onMathDiagnostics:f,onEditGrant:d,draftConverter:u})=>{J.assertStorageNamespace(n),Dc(u);const p=In(r),w=Oo(s),E=Oc(p,o),{revalidate:b}=te.useRevalidator(),T=c.useRef(()=>{}),O=te.useHref(t.dataPath),[C]=c.useState(()=>{const L=sc({dataPath:O,onScope:U=>T.current(U)}),j={documents:bs({client:L,capacity:Math.max(Cc,t.multiView.maxPanels*2)}),trees:mc(L)};return ft(j,e),J.syncStorageScope(n,e.scope),{data:L,...j,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(C.aligned.pageData!==e||C.aligned.storageNamespace!==n){const L=C.aligned.pageData;C.aligned.pageData=e,C.aligned.storageNamespace=n,L!==e&&(L.scope!==e.scope?C.aligned.pendingReader=e:ft(C,e)),J.syncStorageScope(n,e.scope)}const q=Ac(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);c.useLayoutEffect(()=>{const L=C.aligned.pendingReader;L!==null&&(C.aligned.pendingReader=null,On(C),ft(C,L))},[e,C]),c.useLayoutEffect(()=>{let L=!1;return T.current=j=>{j===e.scope||L||(L=!0,j!==null&&(On(C),J.clearExplorerStorage(n)),b())},()=>{T.current=()=>{}}},[e,b,C,n]);const D=c.useRef(t.settingsCookie);c.useLayoutEffect(()=>{D.current=t.settingsCookie},[t.settingsCookie]);const[h]=c.useState(()=>hc(e.settings,L=>{document.cookie=H.viewSettingsCookieString(D.current,L,window.location.protocol==="https:")})),g=mt(e.scope,Mc),R=mt(e.scope,ac),N=c.useRef(E);c.useLayoutEffect(()=>{N.current=E},[E]);const I=mt(e.scope,()=>_o({data:C.data,conflictLabels:()=>({ours:N.current.conflictOurs,theirs:N.current.conflictTheirs}),onSaveSettled:(L,j)=>{j.kind==="saved"&&C.documents.refresh(L);const U=Mo(N.current,j,Pc(C.documents,L));U!==null&&g.announce(U)},sideBySideSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===An,write:L=>J.writeStorage(J.storageKeys(n).editPreview,L?An:Nc)},editorShareSetting:{read:()=>Po(J.readStorage(J.storageKeys(n).editSplit)),write:L=>J.writeStorage(J.storageKeys(n).editSplit,String(L))}})),F=c.useMemo(()=>Te(e.notices.catch(()=>[])),[e.notices]),x=e.sources.map(L=>L.id).join(`
|
|
14
|
+
`),k=c.useMemo(()=>H.withExplorerSources(t,x.split(`
|
|
15
|
+
`)),[t,x]),A=c.useRef(f);c.useLayoutEffect(()=>{A.current=f},[f]);const[M]=c.useState(()=>(L,j)=>{A.current?.(L,j)}),P=f===void 0?void 0:M,B=c.useRef(u);c.useLayoutEffect(()=>{B.current=u},[u]);const[G]=c.useState(()=>{let L=!1;return{convert:(j,U)=>{const Z=B.current;return Z===void 0?Promise.resolve(jc):Z.convert(j,U)},prepare:()=>{try{B.current?.prepare?.()}catch(j){if(L)return;L=!0,console.error("[markdown-explorer] the draft converter's prepare threw",j)}}}}),v=u===void 0?void 0:G,S=c.useMemo(()=>({config:k,labels:E,locale:p,theme:w,storageNamespace:n,scope:e.scope,sources:e.sources,notices:F,documents:C.documents,trees:C.trees,data:C.data,viewSettings:h,treeSettings:q,announcer:g,reveals:R,edits:I,onEditGrant:d,draftConverter:v,renderTreeFailure:i,reportMathDiagnostics:P}),[k,E,p,w,n,e.scope,e.sources,F,C,h,q,g,R,I,d,v,i,P]);return l.jsx($n,{value:S,children:l.jsx($c,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Ic=({ref:e,theme:t,view:n,children:r})=>{const[o]=c.useState(ca);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})},$c=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=$(),o=Ze(),{hash:s}=te.useLocation(),a=Oe(),i=c.useRef(null);bc(t,i),c.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,f=m.view;kc(i,f);const d=m.view==="tree"?l.jsx(c.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Be}),children:l.jsx(Rc,{location:m})}):m.view==="multi"?l.jsx(c.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Be}),children:l.jsx(Tc,{location:m})}):l.jsx(rc,{location:m}),u=l.jsxs(Ic,{ref:i,theme:n,view:f,children:[d,l.jsx(Xo,{}),l.jsx(co,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?u:e({view:f,children:u})},Fc=So.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=ze;exports.CONFLICT_OURS_MARKER=qn;exports.CONFLICT_SEPARATOR=Bn;exports.CONFLICT_THEIRS_MARKER=Un;exports.CONTENT_PANE=Be;exports.ContentSkeleton=ue;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Mn;exports.DocumentPane=Qr;exports.DocumentRefreshBar=io;exports.EXPLORER_THEMES=vt;exports.EditGrantNotice=no;exports.ExplorerLink=ir;exports.FOLDER_README_LOADING=Kn;exports.FailureView=ce;exports.ForwardRef=Jr;exports.ForwardRef$1=to;exports.ImageViewMemoryContext=Sr;exports.LazyNativeScrollBar=dr;exports.LiveRegion=co;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=_n;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Tt;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Dn;exports.MARKDOWN_EXPLORER_LOCALES=gt;exports.MarkdownExplorer=_c;exports.NATIVE_SCROLL_BAR_WIDTH=ms;exports.NO_DOCUMENT=Kr;exports.PAGE_DOCUMENT_REFRESH=lo;exports.TAP_SCROLL_CIRCLE_GUTTER=Mt;exports.TAP_SCROLL_CIRCLE_OFFSET_X=hs;exports.TAP_SCROLL_CIRCLE_SIZE=We;exports.TAP_SCROLL_CIRCLE_SPEED_RANGE=mr;exports.anchorOfDoubleClick=nr;exports.anchorOfView=rr;exports.blockAtLine=ar;exports.chooseEditView=yt;exports.consumeKey=Ct;exports.createEmitter=xe;exports.cssPixels=zn;exports.editViewOf=ro;exports.explorerNavigationOptions=ds;exports.failureTitleOf=re;exports.findConflictsInLines=Hn;exports.focusWithoutScroll=At;exports.frameTopOf=or;exports.isApplePlatform=so;exports.isEditViewShortcut=ao;exports.isEditingDoubleClick=tr;exports.lineTopIn=lr;exports.loadedOf=le;exports.paneShownAlone=Ui;exports.positionInSource=is;exports.readFolderReadme=Xn;exports.resolveMarkdownExplorerLabels=wt;exports.shouldRevalidateExplorer=Fc;exports.toggledEditView=oo;exports.useExplorer=$;exports.useExplorerLocation=Ze;exports.useExplorerNavigate=Oe;exports.useIntentPrefetch=cr;exports.usePageMarkupToggle=Rr;exports.useSideBySide=Jn;exports.useViewSetting=Re;exports.visibleTopOf=sr;
|