@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
package/dist/index-CjyRD7qg.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("react/jsx-runtime"),d=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"),ft=require("@aiquants/markdown/source-lines"),mt=require("@aiquants/spreadsheet/tsv"),zt=require("@aiquants/spreadsheet/view"),go=require("@aiquants/markdown/viewer-settings"),J=require("./storage-DM0EvkVf.cjs"),wo=require("@aiquants/route-revalidation");function vo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const S=vo(d),ht=Object.freeze(["en","ja"]),On="en",yt=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,An=Object.freeze(Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),Mn=e=>Object.fromEntries(An.map(t=>[yt(t),ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),Nn=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(An.filter(e=>ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[yt(e),ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),Eo=/\{(\w+)\}/gu,Dn={...Mn("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"},xo={...Mn("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:"ここへパネルをドロップ"},jn=Object.freeze({en:Object.freeze(Dn),ja:Object.freeze(xo)}),St=Object.freeze(Object.keys(Dn)),bo=new Set(St),yo=e=>bo.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,Pn=e=>{if(e===void 0)return On;if(ht.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${ht.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${$e(e)}`)},pt=(e,t)=>{const n=jn[Pn(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(!yo(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${St.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=Nn[s];if(typeof a=="string"&&m!==void 0){for(const[,f]of a.matchAll(Eo))if(!m.includes(f??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(f)}}; it accepts ${m.map(c=>`{${c}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},So=(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]))},gt=Object.freeze(["light","dark"]),ko=e=>{if(e===void 0)return"light";if(gt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${gt.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},_n=d.createContext(null),$=()=>{const e=d.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 d.useSyncExternalStore(t.subscribe,n,n)},Ze=()=>{const{config:e}=$(),t=te.useParams()["*"],[n]=te.useSearchParams(),r=n.toString();return d.useMemo(()=>H.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},In={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[In[t][0]],ce=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=$(),s=re(o,e.reason),a=o[In[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]})},Ro=(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:""},To=(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()}}},$n="<<<<<<<",Fn="=======",qn=">>>>>>>",Vt=(e,t)=>e===t||e.startsWith(`${t} `),Zt=e=>Bn(e.split(`
|
|
2
|
-
`)),Bn=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||(Vt(s,$n)?(n=o,r=null):s===Fn?n!==null&&r===null?r=o:n=null:Vt(s,qn)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Wt=e=>e.includes(`\r
|
|
3
|
-
`)?`\r
|
|
4
|
-
`:`
|
|
5
|
-
`,Qe=e=>e.replace(/\r\n?/gu,`
|
|
6
|
-
`),Co=(e,t)=>t===`
|
|
7
|
-
`?e:e.replaceAll(`
|
|
8
|
-
`,`\r
|
|
9
|
-
`),Lo=3,Oo=/^\d+(?:\.\d+)?$/u,Ao=e=>{if(e===null||!Oo.test(e))return null;const t=Number(e);return t>=H.EDIT_SPLIT_MIN_PERCENT&&t<=H.EDIT_SPLIT_MAX_PERCENT?t:null},Je=Object.freeze({kind:"idle"}),Gt=Object.freeze({kind:"draft"}),Mo=({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,c=xe();let u=null,p=null,w=null;const E=(h,g)=>{h.value={...h.value,...g},c.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=Qe(N.text),F=N.kind==="draft";g.base={text:I,version:F?null:N.version},g.draft=I,g.ending=Wt(N.text),E(g,{phase:{kind:"editing"},history:F?!1:N.history,dirty:!1,save:F?Gt:Je,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)},j=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,Gt);return}const N=Zt(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<Lo;A+=1){const M=await e.save(h,F.version,Co(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-DRLuveD9.cjs"));if(!b(h,g)||I.aborted)return;const B=m.get(h);B?.flush();const G=Qe(M.text),v=P(F.text,g.draft,G,t());if(F={text:G,version:M.version},g.base=F,g.ending=Wt(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:c.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:Je,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=Zt(g).length;x===0?N.save=Je: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:j,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=Qe(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),c.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&&c.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);c.emit(),g(N)}}};w=R,c.emit()}),discardRequest:()=>w,sideBySide:()=>(u??=r.read(),u),setSideBySide:h=>{u!==h&&(u=h,r.write(h),c.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})}}},kt=e=>{e.preventDefault(),e.stopPropagation()},Un=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Hn="data-aqmx-content-pane",Be=Object.freeze({[Hn]:""}),No="--aqmx-dialog-left",Do="--aqmx-dialog-top",jo='[data-testid="markdown-explorer"]',Po=e=>{const t=e.closest(jo)?.querySelectorAll(`[${Hn}]`),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},_o=e=>{const t=Un(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=Po(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(No,`${String(s)}px`),e.style.setProperty(Do,`${String(a)}px`),n},Io=e=>e.preventDefault(),zn=({open:e,onOpen:t,onDismiss:n})=>{const r=d.useRef(null),o=d.useRef(null),s=d.useRef(!1),a=d.useRef(t);d.useLayoutEffect(()=>{a.current=t},[t]),d.useLayoutEffect(()=>{s.current=e;const c=r.current;if(c!==null)if(e&&!c.open){const u=c.ownerDocument.activeElement;o.current=u instanceof HTMLElement?u:null,c.showModal(),a.current?.()}else!e&&c.open&&(c.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),d.useLayoutEffect(()=>{const c=r.current;if(!e||c===null)return;const u=new ResizeObserver(()=>w());let p=null;const w=()=>{const b=_o(c);b===null||b===p||(p!==null&&u.unobserve(p),u.observe(b),p=b)};w(),u.observe(c);const E=c.ownerDocument.defaultView;return E?.addEventListener("resize",w),c.ownerDocument.addEventListener("scroll",w,{capture:!0,passive:!0}),()=>{u.disconnect(),E?.removeEventListener("resize",w),c.ownerDocument.removeEventListener("scroll",w,{capture:!0})}},[e]);const i=d.useCallback(c=>{c.key!=="Escape"||c.defaultPrevented||(kt(c),n())},[n]),m=d.useCallback(c=>{c.target===c.currentTarget&&n()},[n]),f=d.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:m,onCancel:Io,onClose:f}},Vn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const m=d.useRef(null),f=d.useId(),c=d.useId(),u=d.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":c,"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:c,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${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},Zn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ye=e=>e.status==="fulfilled"?e.value:void 0,Wn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),$o=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),Fo=(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},Gn=(e,t,n)=>{const r=ye(e.read(t));if(r===void 0||r.status==="deferred")return Wn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=Fo(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"?$o: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}},qo=(e,t,n)=>{const{readme:r}=Gn(e,t,n);return r.status==="ok"?r.readme:null},Bo=(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)}},Kn=e=>{const{edits:t}=$(),n=d.useCallback(()=>t.session(e),[t,e]);return d.useSyncExternalStore(t.subscribe,n,Uo)},Xn=()=>!1,Uo=()=>{},Ho=()=>{const{edits:e}=$();return d.useSyncExternalStore(e.subscribe,e.hasSessions,Xn)},Yn=()=>{const{edits:e}=$();return d.useSyncExternalStore(e.subscribe,e.sideBySide,Xn)},zo=()=>null,Vo=()=>{const{edits:e,labels:t,config:n,trees:r}=$(),o=d.useRef([]),s=d.useCallback(({nextLocation:w})=>{const E=Bo(n,w,(b,T)=>qo(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=Ho();d.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=d.useSyncExternalStore(e.subscribe,e.discardRequest,zo),f=a.state==="blocked",c=f?o.current:m===null?[]:m.paths,u=c.map(w=>_.lastPathSegment(w)).join(", "),p=c.length>0&&c.every(w=>e.session(w)?.save.kind==="draft");return l.jsx(Vn,{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 Zo({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Wo=S.forwardRef(Zo);let et=null;const Qn=()=>(et??=Promise.resolve().then(()=>require("./EditSurface-wXPvuB2n.cjs")).catch(e=>{throw et=null,e}),et),Go=()=>{Qn().catch(()=>{})},Ko=e=>{const{default:t}=d.use(Qn());return l.jsx(t,{...e})};class Xo extends d.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 Rt=`[${ft.SOURCE_LINES_ATTRIBUTE}]`,Yo="[data-aqmd-content]",Qo='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]',Jo=200,Ce=e=>ft.parseSourceLines(e.getAttribute(ft.SOURCE_LINES_ATTRIBUTE)),es=(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(Rt)){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}},ts=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Jn=e=>e.closest(Yo)!==null&&e.closest(Qo)===null,er=(e,t,n)=>{const r=es(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=ns(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}},tr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Rt)){const i=Ce(a);if(i===null)continue;n??=rr(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)}},nr=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,rr=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return nr(e)+(Number.isFinite(n)?n:0)},ns=(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>Jo||/[\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:ts(o.toString(),r),clientTop:n.getBoundingClientRect().top}},rs=(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?os(n,r,o,t.word)??s:s},os=(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},or=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Rt)){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},sr=(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},Tt=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})}),ss=e=>Tt[e],Oe=()=>{const e=te.useNavigate();return d.useCallback((t,n)=>{e(t,Tt[n])},[e])},ar=({navigation:e,...t})=>l.jsx(te.Link,{...t,...Tt[e]}),Ct=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},lr=(e,t)=>{const n=d.useRef(null),r=d.useRef(null),o=d.useRef(null),s=d.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);d.useEffect(()=>s,[s]);const a=d.useCallback(f=>{if(r.current!==f)return;const c=o.current;if(c!==null){c.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=d.useCallback(f=>{const c=t(f);c!==r.current&&(s(),c!==null&&(r.current=c,n.current=window.setTimeout(()=>{n.current=null,a(c)},H.PREFETCH_DWELL_MS)))},[s,t,a]),m=d.useCallback(f=>{t(f)!==r.current&&s()},[s,t]);return d.useMemo(()=>({onPointerOver:f=>i(f.target),onPointerOut:f=>m(f.relatedTarget),onFocus:f=>i(f.target),onBlur:f=>m(f.relatedTarget)}),[i,m])},as=d.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-CDgYgxXK.cjs")).then(e=>({default:e.NativeScrollBar})));class ls extends d.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 ir=({scroller:e,withCircle:t})=>l.jsx(ls,{children:l.jsx(d.Suspense,{fallback:null,children:l.jsx(as,{scroller:e,withCircle:t})})}),cr=e=>l.jsx(ir,{scroller:e,withCircle:!0}),is=8,Lt=H.CONTROL_BLOCK_PIXELS,dr=H.FIBONACCI_SPACING_PIXELS[3],Ot=Lt+2*dr,cs=-(Lt+dr),ur=()=>{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]))},ds=55e3,Kt=Object.freeze({status:"deferred"}),tt=Object.freeze({status:"refreshed"}),nt=Object.freeze({status:"shown",failed:!1}),je=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,us=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",fs=({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=ur(),o=xe(),s=new WeakSet,a=new Map,i=new Map,m=new Map;let f=0;const c=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>=ds,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(y=>({status:"loaded",document:y}))),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(y=>{n.get(x)===v&&(v.snapshot=y,v.stamp=u(),c())}),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}),c())))},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()}},j=(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?tt:nt;if(!A)return M.failure===null?nt:je;switch(M.before){case"copy":return M.failure===null?tt:{status:"failed",failure:M.failure};case"failure":return M.failure===null?nt:je;case"none":return M.failure===null?tt:je}},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),c())},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),c(),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),c()):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),c())},seed:(x,k)=>{const A=performance.now(),M=Te(k.then(y=>y===null?Kt:{status:"loaded",document:y},()=>Kt)),P=n.get(x);if(P!==void 0&&P.snapshot.status==="loaded"){const y=P.snapshot,L={};P.background=L,M.then(D=>{if(D.status==="loaded"){T(x,P,L,y,D.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(y=>{n.get(x)===v&&(y.status==="deferred"&&r.isHeld(x)?b(x,v.opened,!1):(v.snapshot=y,v.stamp=u()),c())})},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)&&c()})}x&&c()},refresh:async x=>{const k=n.get(x);if(k!==void 0&&us(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(c(),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"?je:(await j(x,M),g(x,A,!1))},clear:()=>{n.clear();for(const x of r.heldKeys())b(x,!0,!1);c()},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=d.createContext("fill"),ms="--aqmx-tap-circle-gutter",hs=Object.freeze({blockSize:"100%",[ms]:`${String(Ot)}px`}),Ae=({scrollerProps:e,children:t})=>d.use(de)==="content"?l.jsx(Ee.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(Ee.HostedScrollArea,{scrollerProps:{...e,style:hs},rowClassName:"aqmx-document-scroll-row",renderScrollBar:cr,children:t}),ps=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),gs=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:ps.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),At=({failure:e,onRetry:t,testId:n})=>l.jsx(Ae,{scrollerProps:gs,children:l.jsx(ce,{failure:e,alert:!1,onRetry:t,testId:n})});function ws({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const vs=S.forwardRef(ws);function Es({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),S.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const xs=S.forwardRef(Es);function bs({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const ys=S.forwardRef(bs),Ss=2e3,Xt=Object.freeze({outcome:"idle"}),ks=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Rs=({text:e})=>{const{announcer:t,labels:n}=$(),[r,o]=d.useState(Xt);d.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(Xt),Ss);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{ks(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(vs,{}):r.outcome==="failed"?l.jsx(ys,{}):l.jsx(xs,{})})},fr=d.createContext(null),Ts=()=>{const e=d.use(fr);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 Cs({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),S.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const Ls=S.forwardRef(Cs);function Os({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const As=S.forwardRef(Os),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(As,{})}),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(Ls,{})})]})};function Ms({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Ns=S.forwardRef(Ms),Ds=Object.freeze({className:"aqmx-document-stage"}),js=({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(Ns,{})}),l.jsx(Ae,{scrollerProps:Ds,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})]})})]})},We="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Ps=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},_s=/(%[0-9A-Fa-f]{2})/u,Mt=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(_s).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))},mr=e=>`#${encodeURIComponent(e)}`,Is=e=>{if(e==="#")return!0;const t=Mt(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},hr=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},$s="http://www.w3.org/1999/xhtml",Yt=(e,t)=>{if(t==="")return null;const n=hr(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===$s&&r.getAttribute("name")===t)return r;return null},pr=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Yt(e,t.slice(1));if(n!==null)return n;const r=Mt(t);return r===null?null:Yt(e,r)},Qt=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"},Fs=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"},qs=(e,t)=>{const n=t.closest(We),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&Qt(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(Qt(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&Fs(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Bs=Object.freeze({scrollerOf:qs,reveal:e=>{e.scrollIntoView(wt)}}),wt=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),Us=(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")}}},Hs=(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(wt);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(wt)},zs=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(We)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Jt=(e,t,n)=>{if(e===null)return null;const r=pr(e,t);return r===null?(Is(t)&&zs(e,n),null):(Us(e,r),Hs(n.scrollerOf(e,r),r),n.reveal(r),r)};function Vs({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const Zs=S.forwardRef(Vs);function Ws({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),S.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const Gs=S.forwardRef(Ws);function Ks({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),S.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const Xs=S.forwardRef(Ks);function Ys({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const Qs=S.forwardRef(Ys),vt="data-aqmx-key-repeat",ze=Object.freeze({[vt]:"allow"}),Js=`[${vt}="${ze[vt]}"]`,ea=()=>{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(Js)!==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]),en=Object.freeze({mode:"fit"}),ta=1,gr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),tn=`[data-testid="${gr["data-testid"]}"]`,wr=d.createContext(null),na=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=ta?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,nn=(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},rn=(e,t,n)=>{if(e.mode==="level"){const o=nn(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=nn(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},ra=(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},on=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}}},oa=e=>{const t=Fe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},sn=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},sa=({document:e})=>{const{labels:t}=$(),n=d.use(wr),[r]=d.useState(()=>n===null?null:n.read(e.url)),[o,s]=d.useState(r===null?en:r.zoom),[a,i]=d.useState(r===null?null:r.reported),[m,f]=d.useState(null),c=d.useRef(null),u=d.useCallback(j=>{const{naturalWidth:h,naturalHeight:g}=j;i(R=>sn(R,h,g))},[]),p=d.useCallback(j=>{c.current=j,!(j===null||!j.complete)&&(j.naturalWidth>0||j.naturalHeight>0?u(j):j.decode().then(()=>u(j),()=>{}))},[u]);d.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),d.useLayoutEffect(()=>{const j=c.current;if(j===null||a===null||o.mode!=="fit")return;const h=()=>f(R=>sn(R,j.clientWidth,j.clientHeight));if(h(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(h);return g.observe(j),()=>g.disconnect()},[a,o.mode]);const w=a===null||m===null?null:na(a,m),E=rn(o,w,-1),b=rn(o,w,1),T=o.mode==="level"?oa(o.index):null,O=d.useRef({zoomIn:b,zoomOut:E});d.useLayoutEffect(()=>{O.current={zoomIn:b,zoomOut:E}});const C=d.useRef(null);d.useLayoutEffect(()=>{const j=C.current,h=c.current?.closest(tn);C.current=null,!(j===null||h===null||h===void 0)&&(h.scrollLeft=j.across*h.scrollWidth-j.x,h.scrollTop=j.down*h.scrollHeight-j.y)},[o]),d.useEffect(()=>{const j=c.current?.closest(tn);if(j==null)return;let h=null;const g=I=>{const F=on(I.touches);h=F===null?null:{distance:F.distance,steps:0}},R=I=>{const F=on(I.touches);if(h===null||F===null)return;I.preventDefault();const x=ra(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=j.getBoundingClientRect(),P=F.middle.x-M.left,B=F.middle.y-M.top;C.current=j.scrollWidth>0&&j.scrollHeight>0?{x:P,y:B,across:(j.scrollLeft+P)/j.scrollWidth,down:(j.scrollTop+B)/j.scrollHeight}:null,s(A)},N=I=>{I.touches.length<2&&(h=null)};return j.addEventListener("touchstart",g,{passive:!0}),j.addEventListener("touchmove",R,{passive:!1}),j.addEventListener("touchend",N,{passive:!0}),j.addEventListener("touchcancel",N,{passive:!0}),()=>{j.removeEventListener("touchstart",g),j.removeEventListener("touchmove",R),j.removeEventListener("touchend",N),j.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(Qs,{}),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(Gs,{})}),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(Xs,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(en),children:l.jsx(Zs,{})})]}),l.jsx(Ae,{scrollerProps:gr,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:j=>u(j.currentTarget),"data-testid":"markdown-explorer-image"})})]})},aa=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"}},vr=d.createContext(null),Ge=d.createContext(void 0),Er=d.createContext(null),Ke=()=>{const e=d.use(vr);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},la=()=>{const e=d.use(Er);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Xe=(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}),ia=({children:e})=>{const{config:t}=$(),n=Ke(),r=Ze(),o=r.kind==="location"?r.location.source:void 0,s=te.useHref(Xe(t,n.navigation,o,n.currentPath));return l.jsx(Ge,{value:o,children:l.jsx(Er,{value:s,children:e})})},ca='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',da=e=>{const t=e instanceof Element?e.closest(ca):null;return t===null?null:t.getAttribute("data-doc-path")},Ye=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,ua=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:m})=>{const f=te.useHref(e),c=u=>{if(Ye(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:c,children:m})},fa=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=$(),i=Ke(),m=d.use(Ge),f=Ps(e),{navigation:c}=i,u=`${Xe(a,c,m,t)}${f}`,p=n===!1?"false":void 0;return c.kind==="page"?l.jsx(ar,{...o,to:u,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":p,children:s}):l.jsx(ua,{to:u,docPath:t,fragment:f,exists:p,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:i,children:s})},ma=({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,")"]})]})},ha=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=$(),a=d.use(Ge),i=te.useHref(`${Xe(s,r.navigation,a,r.currentPath)}${e}`),m=f=>{Ye(f)&&(f.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:m,children:o})},pa=({href:e,className:t,attributes:n,children:r})=>{const o=Ke();if(o.navigation.kind==="page"){const s=a=>{if(!Ye(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(ha,{href:e,className:t,attributes:n,scope:o,children:r})},ga=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!_.isAcceptableDocumentPath(n)?l.jsx(ma,{className:o,attributes:s,children:a}):l.jsx(fa,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(pa,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),wa=()=>{const{config:e}=$(),t=Ke(),n=d.use(Ge),r=Oe();return d.useCallback((o,s)=>{if(!Ye(s))return!0;s.preventDefault();const a=mr(o.id),{navigation:i}=t;return i.kind==="panel"||Mt(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Xe(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},va=()=>{const e=la();return d.useCallback(t=>`${e}${mr(t.id)}`,[e])};function Ea({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const xa=S.forwardRef(Ea);function ba({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const ya=S.forwardRef(ba);function Sa({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const ka=S.forwardRef(Sa),Ra=Object.freeze({className:"aqmx-document-stage"}),Ta=()=>()=>{},Ca=()=>navigator.pdfViewerEnabled!==!1,La=()=>null,Oa=({document:e})=>{const{labels:t}=$(),n=d.useSyncExternalStore(Ta,Ca,La);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})]})]})},Aa=e=>{switch(e){case"video":return l.jsx(ya,{});case"audio":return l.jsx(ka,{});case"pdf":return l.jsx(xa,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ma=({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(Oa,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Na=({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:Aa(e.mediaType)}),l.jsx(Ae,{scrollerProps:Ra,children:l.jsx(Ma,{document:e})})]}),Nt=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}},Da=e=>{const{documents:t}=$(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.useSyncExternalStore(t.subscribe,n,r),s=le(o);return s===null?null:Nt(s.document)},xr=e=>{const{config:t}=$(),n=Oe(),r=d.useCallback(()=>n(H.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return d.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function ja({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M.99 5.24A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25l.01 9.5A2.25 2.25 0 0 1 16.76 17H3.26A2.267 2.267 0 0 1 1 14.74l-.01-9.5Zm8.26 9.52v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 0 0 .627-.74Zm1.5 0a.75.75 0 0 0 .627.74h5.373a.75.75 0 0 0 .75-.75v-.615a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625Zm6.75-3.63v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75ZM17.5 7.5v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75Z",clipRule:"evenodd"}))}const Pa=S.forwardRef(ja),_a=100,Ia=32767,qe=Object.freeze({maxCells:zt.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:zt.SPREADSHEET_MAX_OPERATION_CELLS/_a,maxCellLength:Ia}),br=44,yr=10,Sr=13,_e='"',an=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===br||r===yr||r===Sr)return n;n+=1}return n};function*$a(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=an(e,r);o+=e.slice(r,i),r=i}else{const a=an(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!==br&&(yield n,n=[],s===Sr&&e.charCodeAt(r)===yr&&(r+=1),r>=e.length))return}}const Fa=(e,t,n)=>t==="csv"?$a(e,n):n==="whole"?mt.iterateTsvRows(e):mt.iterateTsvPrefixRows(e),qa=(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)},kr=(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 c=m.some(u=>u.length>t.maxCellLength)?m.map(u=>qa(u,t.maxCellLength)):m;c!==i&&(o=!0),n.push(c),r=f}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},rt=(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=kr(Fa(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}}},Ba=Object.freeze({maxPartBytes:64*1024*1024,maxSheets:256}),Rr=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 c=Math.min(f.length,e.maxColumns);if(n===0&&(s+1)*c>e.maxCells){const u=Math.floor(e.maxCells/c);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:()=>kr(t,e)}},Ua=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())},Ha=({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:Ua,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))}),Tr=64*1024,za=e=>{let t=new Uint8Array(Math.min(e,Tr)),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}},Va=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},Za=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=za(o);let m=Tr;try{for(;;){const{done:f,value:c}=await a.read();if(f)return rt(i.bytes(),!0,n,r,s);const u=o-i.length();if(i.append(c.byteLength>u?c.subarray(0,u):c),i.length()===o){const w=c.byteLength<=u&&await Va(a);return rt(i.bytes(),w,n,r,s)}if(i.length()<m)continue;m=i.length()*2;const p=rt(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(()=>{})}},Cr=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 Za(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},Dt=(e,t,n)=>{const{documents:r,labels:o}=$(),s=Ts(),a=d.useCallback(()=>r.answerStampOf(e),[r,e]),i=d.useSyncExternalStore(r.subscribe,a,a),[m,f]=d.useState(0),c=d.useMemo(()=>({read:n,stamp:i,attempt:m}),[n,i,m]),[u,p]=d.useState({settled:null,shown:null,failure:null}),w=d.useRef(null),E=d.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)))});d.useEffect(()=>{const O=s.readPart();return w.current=O,()=>{w.current=null,O.release()}},[s]),d.useEffect(()=>{const O=new AbortController;return c.read(O.signal).then(C=>{C!==null&&!O.signal.aborted&&E(C,c)}),()=>O.abort()},[c]);const b=u.settled!==c&&(u.shown!==null||u.failure!==null);d.useLayoutEffect(()=>b?s.holdBusy():void 0,[b,s]);const T=d.useCallback(()=>f(O=>O+1),[]);return{shown:u.shown,failure:u.failure,retry:T}},Lr=(e,t)=>{const n={};for(const r of Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[yt(r)];o!==ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},Wa=(e,t)=>Object.fromEntries(Object.entries(Lr(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),Ga=(e,t)=>({...Wa(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}),Or=(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},Ar=(e,t)=>e!==void 0?e:t!==void 0?t:go.DEFAULT_CONTENT_ALIGN;class Y extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const Ka=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),Xa=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,Ya=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,Qa=/^[^\s/>]+/u,ge=e=>{throw new Y("not-workbook",`the XML ${e}`)},ln=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):ge(`refers to the code point ${e}`),Mr=e=>e.includes("&")?e.replace(Xa,(t,n)=>n.startsWith("#x")?ln(Number.parseInt(n.slice(2),16)):n.startsWith("#")?ln(Number.parseInt(n.slice(1),10)):Ka.get(n)??ge(`names the undeclared entity ${t}`)):e,Et=e=>e.slice(e.indexOf(":")+1),Ja=(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},el=e=>{const t=new Map;for(const n of e.matchAll(Ya))t.set(Et(n[1]??""),Mr(n[2]??n[3]??""));return t},Nr=(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?.(Mr(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=Ja(n,s+1);if(i===-1)break;const m=n.slice(s+1,i);if(m.startsWith("/"))e.end?.(Et(m.slice(1).trim()));else{const f=m.endsWith("/"),c=f?m.slice(0,-1):m,u=Qa.exec(c)?.[0]??ge("has a tag without a name"),p=Et(u);e.start?.(p,el(c.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=Nr(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(()=>{})}},tl=101010256,nl=33639248,rl=67324752,Dr=22,ol=65535,cn=46,dn=30,sl=1,un=0,al=8,ll=65535,be=4294967295,il=new TextDecoder("utf-8"),ee=e=>{throw new Y("not-workbook",`the ZIP package ${e}`)},cl=e=>{const t=e.byteLength-Dr,n=Math.max(0,t-ol);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===tl)return r;return ee("has no end of central directory record")},dl=e=>{if(e.byteLength<Dr)return ee("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=cl(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===ll||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 c=0;c<s;c+=1){if(f+cn>n||t.getUint32(f,!0)!==nl)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+cn;if(q+b>n)return ee("has a name past its central directory");const j=il.decode(e.subarray(q,q+b));if(w===be||E===be||C===be)return ee("has a ZIP64 entry");if(!j.endsWith("/")){if(m.has(j))return ee(`names ${j} twice`);m.set(j,{name:j,encrypted:(u&sl)!==0,method:p,compressedSize:w,uncompressedSize:E,localHeaderOffset:C})}f=q+b+T+O}return{bytes:e,entries:m}},ul=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+dn>n.byteLength||r.getUint32(o,!0)!==rl)return ee(`has no local header for ${t.name}`);const s=o+dn+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}},jr=e=>new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e),t.close()}}),fl=e=>jr(e).pipeThrough(new DecompressionStream("deflate-raw")),ml=(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!==un&&r.method!==al)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}=ul(e,r),a=e.bytes.subarray(o,s);return(r.method===un?jr(a):fl(a)).pipeThrough(ml(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()}},fn="content.xml",hl="META-INF/manifest.xml",Pr=e=>{throw new Y("not-workbook",`the spreadsheet ${e}`)},mn=(e,t)=>Le(e,fn,t.maxPartBytes)??Pr(`has no ${fn}`),pl=async(e,t)=>{const n=Le(e,hl,t.maxPartBytes);if(n===null)return!1;let r=!1;return await Ne(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},gl=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}},ot=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},wl=async(e,t,n)=>{const r=Rr(n);let o=0,s=0,a=!1,i=!1,m=0,f=1,c=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=ot(E.get("number-rows-repeated")),c=new Map,u=0):w==="table-cell"||w==="covered-table-cell"?p={repeat:ot(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(ot(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)c.set(T,E)}u+=p.repeat,p=null}else w==="table-row"?(r.addRow(m,c,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()},vl=async(e,t)=>{if(await pl(e,t))throw new Y("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await gl(mn(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=>wl(mn(e,t),i,m)})}),o.length===0&&Pr("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},pe=Object.freeze({kind:"general"}),El=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,"@"]]),xl=/^\[(h+|m+|s+)\]$/iu,bl=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);xl.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},yl=e=>{const{text:t,elapsed:n}=bl(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}},Sl=(e,t)=>{const n=t.get(e)??El.get(e);return n===void 0?pe:yl(n)},jt=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("+","")}`}`},hn=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return jt(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}`}`},kl=864e5,pn=86400,Rl=2958465,we=(e,t)=>String(e).padStart(t,"0"),Tl=(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*kl);return`${we(r.getUTCFullYear(),4)}-${we(r.getUTCMonth()+1,2)}-${we(r.getUTCDate(),2)}`},Cl=(e,t,n)=>{if(e<0||e>=Rl+1)return jt(e);let r=Math.floor(e),o=Math.round((e-r)*pn);o===pn&&(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=Tl(r,n);return t.time?`${m} ${i}`:m},Ll=(e,t,n)=>{switch(t.kind){case"general":return jt(e);case"date-time":return Cl(e,t,n);case"percent":return`${hn(e*100,t.decimals,!1)}%`;case"fixed":return hn(e/t.scale,t.decimals,t.grouping)}},_r="_rels/.rels",oe=e=>{throw new Y("not-workbook",`the workbook ${e}`)},Pt=(e,t)=>{const n=Nr(t,()=>!1);n.write(e),n.finish()},Ol=(e,t)=>{try{return decodeURIComponent(e)}catch{return oe(`points to a malformed part name (${t})`)}},Al=(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(Ol(o,t)));return r.join("/")},Ml=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},gn=async(e,t,n)=>{const r=await Ve(e,t===""?_r:Ml(t),n.maxPartBytes),o=new Map;return r===null||Pt(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:Al(t,f)})}}),o},st=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},Nl=e=>{const t=[];let n=!1;return Pt(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}},Dl=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},jl=e=>{const t=new Map,n=[];let r=!1;return Pt(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=>Sl(o,t))},Pl=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,_l=e=>{const t=Pl.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}`},Il=/^([A-Za-z]{1,3})(\d+)$/u,$l=e=>{const t=Il.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},Fl=(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 _l(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?Ll(a,n[e.style]??pe,r):s}}},ql=async(e,t,n,r,o)=>{const s=Rr(t);let a=-1,i=new Map,m=0,f=null;return await Ne(e,{start:(c,u,p)=>{if(c==="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(c==="c"){const w=$l(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&&(c==="v"?f.inValue=!p:c==="rPh"&&!p?f.phoneticDepth+=1:c==="t"&&f.type==="inlineStr"&&f.phoneticDepth===0&&(f.inInlineText=!p))},end:c=>{if(c==="c"&&f!==null){const u=Fl(f,n,r,o);u!==""&&i.set(f.column,u),m=f.column+1,f=null}else c==="row"?s.addRow(a,i,1):f!==null&&(c==="v"?f.inValue=!1:c==="rPh"?f.phoneticDepth=Math.max(0,f.phoneticDepth-1):c==="t"&&(f.inInlineText=!1))},text:c=>{f!==null&&(f.inValue?f.value.push(c):f.inInlineText&&f.inline.push(c))}},s.full),s.table()},Bl=async(e,t)=>{const n=st(await gn(e,"",t),"officeDocument")??oe("has no officeDocument relationship"),r=await Ve(e,n,t.maxPartBytes)??oe(`has no part ${n}`),{sheets:o,date1904:s}=Nl(r),a=await gn(e,n,t),i=st(a,"sharedStrings"),m=i===null?null:Le(e,i,t.maxPartBytes),f=m===null?[]:await Dl(m),c=st(a,"styles"),u=c===null?null:await Ve(e,c,t.maxPartBytes),p=u===null?[]:jl(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 ql(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)}},Ul=Object.freeze([80,75,3,4]),Hl=Object.freeze([208,207,17,224,161,177,26,225]),at=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),zl=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),Vl="mimetype",Ir=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),$r=e=>Ir(e,Ul),Fr=e=>Ir(e,Hl),Zl=e=>{const t=e.byteLength-at.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===at[0]&&at.every((r,o)=>e[n+o]===r))return!0;return!1},Wl=async(e,t)=>{if(Fr(e))throw Zl(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(!$r(e))throw new Y("not-workbook","the bytes are no ZIP package");const n=dl(e),r=await Ve(n,Vl,t.maxPartBytes);if(r!==null&&zl.has(r.trim()))return vl(n,t);if(n.entries.has(_r))return Bl(n,t);throw new Y("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},Gl=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},qr=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"}}},Kl=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 Gl(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(!($r(a)||Fr(a)))return{kind:"not-package"};try{const i=await Wl(a,n.limits),m=r===null?-1:i.sheets.findIndex(p=>p.name===r),f=Math.max(m,0),c=i.sheets[f];if(c===void 0)return{kind:"refused",refusal:"not-workbook"};const u=await qr(c,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"}}}},Xl=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),Yl=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},wn=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},lt=e=>e.every(t=>t.every(n=>n==="")),Br=({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(Pa,{})}),l.jsx(Ae,{scrollerProps:Xl,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),Ur=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=$(),s=d.use(de),a=d.useMemo(()=>({...Lr(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=d.useMemo(()=>mt.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})})},Se=({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})]})})},Hr=({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(Ur,{rows:e.rows,title:t})]});case"empty":return l.jsx(Se,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(Se,{note:Yl(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},Ql=({path:e,document:t})=>t.format==="workbook"?l.jsx(ei,{path:e,document:t}):l.jsx(Jl,{path:e,document:t,format:t.format}),Jl=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=$(),{name:a,url:i}=t,m=d.useCallback(async p=>{const w=await Cr(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:c,retry:u}=Dt(e,a,m);return l.jsxs(Br,{name:a,url:i,openUrl:_.explorerPlainTextHref(i),state:f===null?c===null?"loading":"failure":f.kind,children:[f===null&&c===null?l.jsx(ue,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,f===null&&c!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:c,alert:!1,onRetry:u,testId:"markdown-explorer-spreadsheet-failure"})}):null,f===null?null:l.jsx(Hr,{reading:f,name:a,url:i})]})},ei=({path:e,document:t})=>{const{config:n,data:r,labels:o}=$(),{name:s,url:a,firstSheetText:i}=t,m=d.useId(),f=d.useRef(null),c=d.useCallback(async x=>{const k=await Kl(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:Ba,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 Cr(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}=Dt(e,s,c),[E,b]=d.useState(null),T=d.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;qr(k,qe).then(G=>{B.set(x,G),b(v=>v===P?{...P,reading:G}:v)})},j=C===null?null:C.reading===null?"loading":C.reading.kind==="refused"?"unreadable":lt(C.reading.table.rows)?"empty":"table",h=u===null?p===null?"loading":"failure":u.kind==="first-sheet"?u.reading.kind:u.kind==="refused"?"unreadable":j??"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(Br,{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(Se,{note:wn(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(Hr,{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(Ha,{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(Se,{note:wn(o,C.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:C.reading.refusal,download:{url:a,name:s}}):null,C.reading?.kind==="table"&<(C.reading.table.rows)?l.jsx(Se,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,C.reading?.kind==="table"&&!lt(C.reading.table.rows)?l.jsx(Ur,{rows:C.reading.table.rows,title:o.spreadsheetSheetName(s,I)},C.index):null]})]})]})},zr=Object.freeze({kind:"empty"}),ti=(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=d.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]})},ni=({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(d.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(_.lastPathSegment(s)))},[t,s,o,r]),d.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(At,{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"})})},vn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),ri=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=$(),a=d.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=wa(),m=va(),f=d.useMemo(()=>o===void 0?void 0:h=>o(e,h),[o,e]),c=d.useRef(null),{editable:u,doubleClick:p,region:w,paneScroll:E,stale:b}=r;d.useLayoutEffect(()=>{if(u)return s.bindView(e,{anchor:()=>{const h=c.current,g=w(),R=h===null?null:h.querySelector(We);return h===null||g===null||R===null?null:tr(h,E.scrollerOf(g,R))}})},[s,e,u,w,E]);const T=h=>{const g=c.current,{target:R}=h;!p||g===null||!(R instanceof Element)||!Jn(R)||(h.stopPropagation(),s.start(e,er(R,g,g.ownerDocument.getSelection())))},O=d.useRef(null),C=d.useRef(b);d.useLayoutEffect(()=>{C.current=b});const q=d.useEffectEvent(h=>{const g=c.current,R=w(),N=g===null?null:or(g,h.line);if(R===null||N===null)return!1;const I=E.scrollerOf(R,N);return I.scrollTop+=sr(N,h.line)-h.clientTop,!0}),j=d.useEffectEvent(h=>{const g=w();if(g===null)return;const R=()=>{for(const I of vn)g.removeEventListener(I,N,!0);O.current?.release===R&&(O.current=null)},N=()=>R();for(const I of vn)g.addEventListener(I,N,{capture:!0,passive:!0});O.current={point:h,release:R}});return d.useLayoutEffect(()=>{const h=s.takeReturn(e);if(h!==null)return queueMicrotask(()=>{q(h)&&C.current&&j(h)}),()=>O.current?.release()},[s,e]),d.useLayoutEffect(()=>{const h=O.current;h===null||b||(h.release(),q(h.point))},[t,b]),l.jsx("div",{ref:c,className:"aqmx-document-viewer",onDoubleClick:T,children:l.jsx(Ee.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:m,onMathDiagnostics:f,parseResult:a,content:null})})},Vr=({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(Wo,{}),children:e.truncated?null:l.jsx(Rs,{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})})]})},it=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=$(),s=d.useCallback(async f=>{const c=await r.text(e,f);return"kind"in c?c.kind==="failure"?{kind:"failure",failure:c.failure}:{kind:"read",value:c}:null},[r,e]),{shown:a,failure:i,retry:m}=Dt(e,t,s);return a!==null?l.jsx(Vr,{document:a,viewer:n}):i!==null?l.jsx(At,{failure:i,onRetry:m,testId:"markdown-explorer-markup-failure"}):l.jsx(ue,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},oi=Object.freeze({reason:"failed"}),si=e=>{const{labels:t}=$();return l.jsx(Xo,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ce,{failure:oi,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(d.Suspense,{fallback:l.jsx(ue,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(Ko,{...e})})})},ai=({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:c}=s;if(n==="edit"&&a!==void 0)return l.jsx(si,{path:e,name:t.name,session:a,layout:i,viewer:r,region:m,paneScroll:f});if(n==="markup")return l.jsx(it,{path:e,name:t.name,viewer:r});const u=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(ri,{path:e,document:t,viewer:r,editing:{editable:u,doubleClick:u&&i==="fill",region:m,paneScroll:f,stale:c}})}case"text":return l.jsx(Vr,{document:t,viewer:r});case"image":return n==="markup"&&Nt(t)==="svg"?l.jsx(it,{path:e,name:t.name,viewer:r}):l.jsx(sa,{document:t});case"media":return l.jsx(Na,{document:t});case"spreadsheet":return n==="markup"?l.jsx(it,{path:e,name:t.name,viewer:r}):l.jsx(Ql,{path:e,document:t});case"file":return l.jsx(js,{document:t});case"failure":return l.jsx(At,{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)}`)}}},li='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',ii=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:pr(e,n),r===void 0?null:hr(e,r.id),e.querySelector(We),e.querySelector(li)];for(const s of o)if(s instanceof HTMLElement&&Ct(s))return s;return null},En=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Ct(t)},ci=e=>{const t=d.useRef(!1);return d.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)},c=()=>{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",c),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",c),o.removeEventListener("focus",u),n.removeEventListener("focusout",f)}},[e]),t},di=Object.freeze({count:0,recovered:!1}),ui=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:m,paneScroll:f,announces:c,announceFailure:u,onDocumentShown:p})=>{const{labels:w,announcer:E,documents:b}=$(),{document:T}=t,O=d.useRef(null),C=d.useRef(null),q=d.useRef(null),j=d.useRef(0),h=ci(O),g=d.useRef({path:e,document:T}),R=d.useRef(null),N=d.useCallback(z=>{const V=O.current,X=Jt(V,z,f);V!==null&&X!==null&&En(V,X,h.current)},[f,h]),I=d.useCallback((z,V)=>{const X=j.current;setTimeout(()=>{!V.defaultPrevented&&j.current===X&&N(z)},0)},[N]),F=d.useCallback(z=>{setTimeout(()=>{z.defaultPrevented||N("#")},0)},[N]),x=d.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:N,followSameUrlJump:I,followEmptyFragment:F}),[i,e,N,I,F]),k=d.useCallback(()=>b.retry(e),[b,e]),A=lr(b,da),M=Kn(e),P=M!==void 0?"edit":n?"markup":"rendered",B=Nt(T)===null?void 0:P,G=d.useCallback(()=>O.current,[]),v=d.useMemo(()=>({session:M,layout:s,region:G,paneScroll:f,stale:r}),[M,s,G,f,r]),y=B==="edit"?!1:r,L=d.use(de),D=B==="edit"&&s==="fill"?"fill":L,[U,Z]=d.useState(0),K=d.useRef(0),W=d.useRef(!1),[ne,$t]=d.useState(di),[Ft,ao]=d.useState(0),qt=d.useRef(u),Bt=d.useRef(r);d.useLayoutEffect(()=>{qt.current=u,Bt.current=r},[u,r]);const lo=d.useMemo(()=>({announceFailure:z=>{Bt.current||qt.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,$t(De=>({count:De.count+1,recovered:X}))}},release:()=>{Q||(Q=!0,z.release(),K.current-=1,V||ao(fe=>fe+1))}}},holdBusy:()=>{Z(V=>V+1);let z=!0;return()=>{z&&(z=!1,Z(V=>V-1))}}}),[b,e]),Ut=y||U>0,io=d.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),!(!c||X!==null&&X.path===z&&X.snapshot.document.kind!=="failure")&&(W.current=K.current>0,W.current||E.announce(w.documentShown(Q.name)))});d.useEffect(()=>{io(e,t)},[e,t]);const co=d.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),Ht=d.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:ii(V,T,z)}),uo=d.useEffectEvent(z=>{const V=W.current;W.current=!1,!r&&(z&&Ht(null),c&&(z||V)&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{ne.count>0&&uo(ne.recovered)},[ne]);const fo=d.useEffectEvent(()=>{K.current>0||!W.current||(W.current=!1,c&&!r&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{Ft>0&&fo()},[Ft]);const mo=d.useEffectEvent(z=>{const V=O.current;V!==null&&En(V,z,h.current)}),ho=d.useEffectEvent(z=>f.reveal(z)),po=d.useEffectEvent(z=>Jt(O.current,z,f));return d.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,j.current+=1,Q=m.fragment):m.fragment!==null&&(Q=m.fragment,co());const fe=()=>{const me=Q===null?null:po(Q);if(!V){me!==null&&mo(me);return}const De=Ht(m.fragment);z&&me===null&&De!==null&&ho(De)};X?queueMicrotask(fe):fe()},[m,e,T,r]),l.jsx(de,{value:D,children:l.jsx(ke,{kind:T.kind,view:B,label:a(e,T),stale:Ut,busy:Ut,frameRef:O,intent:A,children:l.jsx(vr,{value:x,children:l.jsx(ia,{children:l.jsx(fr,{value:lo,children:l.jsx(ai,{path:e,document:T,view:P,viewer:o,onRetry:k,editing:v},e)})})})})})},It=Object.freeze({kind:"skeleton"}),fi=(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?It:{kind:"document",path:n,snapshot:a,stale:!0}},mi=(e,t)=>t.status==="deferred"?It:{kind:"document",path:e,snapshot:t,stale:!1},hi=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?mi(t.path,d.use(t.promise)):t;return o.kind!=="document"?l.jsx(_t,{label:r.regionLabel(e,null)}):l.jsx(ui,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Zr=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})=>{const{config:c,labels:u,locale:p,theme:w,documents:E,data:b}=$(),T=Ee.useMarkdownToolbarState(),O=d.useRef(!1);d.useLayoutEffect(()=>{O.current=!0},[]);const[C,q]=d.useState(null),[j,h]=d.useState(n),g=d.useCallback(()=>e===null?void 0:E.peek(e),[E,e]),R=d.useSyncExternalStore(E.subscribe,g,g),N=d.useCallback(()=>C===null?void 0:E.peek(C),[E,C]),I=d.useSyncExternalStore(E.subscribe,N,N);d.useLayoutEffect(()=>e===null?void 0:E.open(e),[E,e]),d.useLayoutEffect(()=>C===null?void 0:E.retain(C),[E,C]);const F=e===null?It:fi(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!==j&&h(n);const A=d.useMemo(()=>Ga(u,p),[u,p]),M=d.useMemo(()=>({read:(L,D)=>aa(b,L,D)}),[b]),P=d.useMemo(()=>[...c.iframeHosts],[c]),B=o.kind==="panel",G=d.useMemo(()=>({labels:A,spreadsheetLocale:p,emptyMessage:u.documentEmpty,theme:w,availableStyles:c.documentStyles,iFrameAllowedDomains:P,embeds:c.embeds,linkComponent:ga,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:cr,scrollBarGutter:B?void 0:Ot,imageSource:M}),[A,p,u.documentEmpty,w,c.documentStyles,P,c.embeds,T,r,B,M]),v=d.useCallback((L,D)=>B?D===null||D.kind==="failure"?_.lastPathSegment(L):D.name:u.documentRegion,[B,u.documentRegion]),y=B?"content":"fill";return e===null?l.jsx(de,{value:y,children:l.jsx(ni,{absence:t,announces:i,announceFailure:m})}):l.jsx(de,{value:y,children:l.jsx(d.Suspense,{fallback:l.jsx(_t,{label:v(e,null)}),children:l.jsx(hi,{requestedPath:e,content:F,markup:k?n:j,viewer:G,editLayout:r.editLayout,regionLabel:v,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})})})},pi=({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),c=Oe(),u=te.useLocation(),p=Ze(),{view:w,overrides:E,embed:b}=r,T=d.useCallback(I=>{if(p.kind!=="location")return;const F=ti(s,p.location,I);F!==null&&c(F,"browse")},[s,c,p]),O=d.useCallback(I=>{a.update({style:I}),T("style")},[a,T]),C=d.useCallback(I=>{a.update({align:I}),T("align")},[a,T]),q=Or(s,E.style,m),j=Ar(E.align,f),h=d.useMemo(()=>({style:q,onStyleChange:O,align:j,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,j,C,b]),g=d.useMemo(()=>({kind:"page",view:w,overrides:E,embed:b}),[w,E,b]),R=d.useMemo(()=>({kind:"page",fragment:u.hash,navigation:u}),[u]),N=d.useCallback(I=>i.announce(I),[i]);return l.jsx(Zr,{path:e,absence:t,markup:n,display:h,navigation:g,fragment:R,paneScroll:Bs,announces:!0,announceFailure:N,onDocumentShown:o})},gi=({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,c]=d.useState(()=>Or(s,void 0,i)),u=Ar(void 0,m),p=d.useCallback(g=>a.update({align:g}),[a]),{maximized:w,onDocumentLink:E,pendingHash:b,onHashConsumed:T,announceFailure:O,paneScroll:C}=r,q=d.useMemo(()=>({style:f,onStyleChange:c,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]),j=d.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),h=d.useMemo(()=>({kind:"panel",fragment:b,consume:T}),[b,T]);return l.jsx(Zr,{path:e,absence:t,markup:n,display:q,navigation:j,fragment:h,paneScroll:C,announces:!1,announceFailure:O,onDocumentShown:o})},Wr=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(pi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(gi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function wi({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const Gr=S.forwardRef(wi);function vi({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Kr=S.forwardRef(vi);function Ei({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const xi=S.forwardRef(Ei);function bi({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),S.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const yi=S.forwardRef(bi);function Si({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const ki=S.forwardRef(Si);function Ri({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),S.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Ti=S.forwardRef(Ri);function Ci({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),S.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const Xr=S.forwardRef(Ci);function Li({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),S.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Oi=S.forwardRef(Li);function Ai({title:e,titleId:t,...n},r){return S.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"}))}const Mi=S.forwardRef(Ai),Yr=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=$(),[s,a]=d.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})]})]})},Ni="Control+E Meta+E",Qr=(e,t,n)=>n&&t?"split":e.view,xt=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Di=e=>e==="split"?null:e,Jr=e=>e==="preview"?"editor":"preview",eo=e=>/Mac|iPhone|iPad|iPod/u.test(e),to=(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)},xn=(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)},ji=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:m}=$(),f=d.useId(),[c,u]=d.useState(null),[p,w]=d.useState(0),[E,b]=d.useState(null),[T,O]=d.useState(null),C=d.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),q=d.useCallback(()=>{b(null),O(null)},[]),j=zn({open:n,onOpen:q,onDismiss:r});d.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]),d.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=c!==null&&c.kind==="revisions"?c.revisions.find(R=>R.id===E):void 0;return l.jsx("dialog",{...j,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)}),c===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):c.kind==="failure"?l.jsx(ce,{failure:c.failure,alert:!1,onRetry:()=>w(R=>R+1),testId:"markdown-explorer-history-failure"}):c.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:c.revisions.map(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:xn(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):xn(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})]})]})})},Pi=e=>{const{documents:t}=$(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.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()},_i=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=$(),m=d.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[f,c]=d.useState(null),u=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const b=a.session(e);b?.dirty===!0?c(b.save.kind==="draft"?"draft":"unsaved"):a.close(e)},p=()=>{m||(Go(),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(Oi,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(Vn,{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:()=>{c(null),a.close(e)},onCancel:()=>c(null)})]})},Ii=({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(xi,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},$i=({session:e})=>{const{labels:t}=$(),n=Ro(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})},Fi=Object.freeze(["editor","split","preview"]),qi=Object.freeze(["editor","preview"]),Bi=Object.freeze({editor:Kr,split:Mi,preview:Xr}),Ui=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=$(),m=Yn(),f=Qr(r,m,o),c=o?Fi:qi,u=d.useId(),p=d.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(!to(T.nativeEvent,eo(navigator.platform)))return;kt(T);const O=Jr(f);xt(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:c.map(T=>{const O=Bi[T],{label:C,tooltip:q}=w[T],j=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:Ni,title:q,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>xt(a,e,T,o),onDoubleClick:ae,onPointerEnter:j,onFocus:j}),l.jsx(O,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:C})]},T)})})},Hi=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=$(),[i,m]=d.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",c=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(yi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(Ui,{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(ki,{"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":c,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:u,onDoubleClick:ae,children:[l.jsx(Ti,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(ji,{path:e,documentName:t,open:i,onClose:()=>m(!1)}):null]})},zi=({path:e,session:t})=>{const{edits:n}=$();return t.save.kind!=="grant"?null:l.jsx(Yr,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},Vi=new Set,Zi=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=$(),a=d.useCallback(()=>r.peek(e),[r,e]),i=d.useCallback(()=>r.peekSeeded(e),[r,e]),m=d.useSyncExternalStore(r.subscribe,a,i),f=d.useCallback(()=>r.answerStampOf(e),[r,e]),c=d.useSyncExternalStore(r.subscribe,f,f),[u]=d.useState(()=>new Set),[p,w]=d.useState(Vi),[E,b]=d.useState(null);E!==null&&(E.path!==e||E.markup!==n)&&b(null);const T=d.useRef(null);d.useLayoutEffect(()=>(T.current=e,()=>{T.current=null}),[e]);const O=d.useRef(n);d.useLayoutEffect(()=>{O.current=n},[n]);const C=d.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),j=E!==null&&E.path===e&&E.stamp===c&&E.markup===n?E.failure:null;return{refreshing:q,unavailable:q||m?.status==="pending",failure:j,refresh:C}},Wi=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},no=Object.freeze({kind:"page"}),ro=({path:e,placement:t,markup:n})=>{const{labels:r}=$(),{refreshing:o,unavailable:s,failure:a,refresh:i}=Zi(e,t.kind==="page",n.shown),m=Da(e),f=Pi(e),c=Kn(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":c===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:l.jsx($i,{session:c}),c===void 0?null:l.jsx(Hi,{path:e,documentName:E,iconOnly:w,session:c,previewAvailable:b}),c===void 0&&m!==null?l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?Wi(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(Kr,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,c!==void 0||f.edit?.kind==="inline"||f.edit?.kind==="draft"?l.jsx(_i,{path:e,documentName:E,iconOnly:w,previewAvailable:b,draft:f.edit?.kind==="draft"}):f.edit?.kind==="external"?l.jsx(Ii,{href:f.edit.href,documentName:E,iconOnly:w}):null,c===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(Gr,{"aria-hidden":"true"}),u===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),c!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(re(r,a.reason))}),c===void 0?null:l.jsx(zi,{path:e,session:c})]})},Gi=({location:e})=>{const t=e.doc,n=d.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=xr(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Be,children:[l.jsx(ro,{path:t,placement:no,markup:r}),l.jsx(Wr,{path:t,absence:zr,markup:e.markup,variant:n})]})},oo=({holds:e,testId:t})=>{const{labels:n,announcer:r}=$(),o=d.useId();d.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=d.useCallback(()=>r.shownIn(o),[r,o]),a=d.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([]),Ki=e=>{const t=new Set;let n=he,r=[],o=!1;const s=[],a=c=>{n=c;for(const u of[...t])u()},i=()=>s.at(-1)?.region,m=c=>{const u=i();c(),i()!==u&&n!==he&&a(he)},f=()=>{o=!1;const c=r.map(u=>"sentence"in u?u.sentence:u.list(u.items));r=[],a(Object.freeze(c))};return{announce:c=>{if(typeof c=="string")r.push({sentence:c});else{const u=r.find(p=>"list"in p&&p.list===c.list);u!==void 0&&"items"in u?u.items.push(c.item):r.push({list:c.list,items:[c.item]})}o||(o=!0,n!==he&&a(he),e.request(f))},subscribe:c=>(t.add(c),()=>{t.delete(c)}),claim:c=>{const u={region:c};return m(()=>s.push(u)),()=>m(()=>{const p=s.indexOf(u);p!==-1&&s.splice(p,1)})},shownIn:c=>i()===c?n:he}},se=Object.freeze({status:"cancelled"}),bn=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)},Xi=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,u)=>globalThis.fetch(c,u)),o=(c,u)=>`${e}/${c}?${new URLSearchParams(u).toString()}`,s=c=>{c.status===401&&t(null);const u=c.headers.get(_.EXPLORER_SCOPE_HEADER);u!==null&&t(u)},a=async(c,u,p,w)=>{let E;try{E=await r(c,{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=bn(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(c,u,p)=>{const w=await a(c,u,p,E=>_.failureDocument(E.reason,E.code));return u.signal.aborted?se:w};return{tree:c=>a(o("tree",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},_.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(c,u,p)=>{const w=await a(o("children",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerChildrenResult,E=>({status:"error",failure:E}));return p.aborted?se:w},ancestors:async(c,u,p)=>{const w=await a(o("ancestors",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return p.aborted?se:w},reveal:async(c,u,p)=>{const w=await a(o("reveal",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},_.isExplorerRevealResult,E=>({status:"error",failure:E}));return p.aborted?se:w},document:(c,{refresh:u})=>a(o("document",{[_.EXPLORER_DATA_QUERY.path]:c}),u?{method:"GET",headers:i}:{method:"GET"},_.isExplorerDocument,p=>_.failureDocument(p.reason,p.code)),text:async(c,u)=>{const p=await a(o("text",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerTextAnswer,w=>_.failureDocument(w.reason,w.code));return u.aborted?se:p},asset:async(c,u)=>{let p;try{p=await r(c,{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=bn(w);return{status:"error",failure:E===null?{reason:_.failureReasonOfStatus(p.status)}:E}},edit:(c,u)=>f(o("edit",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerEditAnswer),save:(c,u,p,w)=>f(o("save",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:m,body:p,signal:w},_.isExplorerSaveAnswer),preview:(c,u,p)=>f(o("preview",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"POST",headers:m,body:u,signal:p},_.isExplorerPreviewAnswer),revisions:(c,u)=>f(o("revisions",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerRevisionsAnswer),revision:(c,u,p)=>f(o("revision",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:p},_.isExplorerRevisionAnswer),refresh:c=>a(o("refresh",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:i},_.isExplorerTreeResult,u=>({status:"error",failure:u}))}},Yi=()=>{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}}},Qi=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}},yn=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Qi(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}}},Ji=Object.freeze({status:"refreshed"}),ec=Object.freeze({status:"superseded"}),bt=Object.freeze({status:"deferred"}),tc=Zn(bt),so=4,nc=so-1,Sn=Object.freeze({status:"loading"}),rc=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),oc=e=>{const t=new Map,n=ur(),r=new Map,o=new Map,s=new Map,a=new Map,i=xe(),m=new Set;let f=0,c=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 y=a.get(v);return y===void 0&&(y={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(v,y)),y},C=(v,y,L)=>{v.inFlight.delete(y),f-=1,L.lane==="bulk"&&(c-=1)},q=v=>{const y=a.get(v);if(y!==void 0){for(const[L,D]of[...y.inFlight])C(y,L,D),D.controller.abort();y.direct.clear(),y.bulk.clear(),y.unclaimed.clear()}},j=v=>{const y=T(v)+1;return o.set(v,y),q(v),y},h=(v,y)=>{const L=ye(v),D={promise:v,opened:y,stale:!1,loadedAt:L?.status==="ok"?L.loadedAt:null};return v.status==="pending"&&v.then(U=>{U.status==="ok"&&(D.loadedAt=U.loadedAt)}),D},g=v=>{let y=r.get(v);return y===void 0&&(y=new Map,r.set(v,y)),y},R=v=>{const y=[...a.keys()],L=u[v],D=L===null?0:y.indexOf(L)+1;for(let U=0;U<y.length;U+=1){const Z=y[(D+U)%y.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,y,L,D)=>{const U=a.get(v);if(U===void 0||U.inFlight.get(y)!==L)return;C(U,y,L);const Z=(U.claims.get(y)??0)>0,K=g(v);if(D.status==="ok"?K.set(y,{status:"loaded",entries:D.entries}):D.status==="error"&&Z?K.set(y,{status:"failed",failure:D.failure}):K.delete(y),b(),D.status==="error"&&Z){const W={sourceId:v,path:y,failure:D.failure};for(const ne of[...m])ne(W)}F()},I=(v,y,L)=>{const D={controller:new AbortController,lane:L};O(v).inFlight.set(y,D),f+=1,L==="bulk"&&(c+=1),e.children(v,y,D.controller.signal).then(U=>N(v,y,D,U),()=>N(v,y,D,rc))},F=()=>{for(;f<so;){const v=R("direct");if(v!==null){I(v.sourceId,v.path,"direct");continue}const y=c<nc?R("bulk"):null;if(y===null)return;I(y.sourceId,y.path,"bulk")}},x=(v,y,L)=>{if(!(y.direct.delete(L)||y.bulk.delete(L))){const U=y.inFlight.get(L);if(U===void 0)return!1;C(y,L,U),U.controller.abort()}return r.get(v)?.delete(L),!0},k=()=>{w=!1;let v=!1;for(const y of p){const L=O(y);for(const D of L.unclaimed)(L.claims.get(D)??0)===0&&x(y,L,D)&&(v=!0);L.unclaimed.clear()}p.clear(),v&&(b(),F())},A=(v,y)=>{t.set(v,h(Te(e.tree(v)),y))},M=(v,y,L)=>{j(v);const D=h(Zn(y),L);return t.set(v,D),r.delete(v),b(),F(),D},P=(v,y,L,D)=>{if(L!==T(v)||t.get(v)!==y)return;const U=ye(y.promise);if(!(D.status!=="ok"||U?.status!=="ok"||y.loadedAt===null||D.loadedAt<=y.loadedAt)){if(He(U.entries,D.entries)){y.loadedAt=D.loadedAt;return}M(v,D,y.opened)}},B=(v,y)=>{const L=t.get(v);return L!==void 0&&ye(L.promise)?.status===y},G=(v,y)=>{y.stale=!1;const L=T(v);e.tree(v).then(D=>P(v,y,L,D))};return{read:v=>t.get(v)?.promise??tc,open:v=>{const y=n.resumes(v),L=n.hold(v),D=t.get(v);return D===void 0||B(v,"deferred")?(A(v,!0),b()):y||(D.opened&&B(v,"error")?(A(v,!0),b()):(D.opened=!0,D.stale&&B(v,"ok")&&G(v,D))),L},retry:v=>{B(v,"error")&&(A(v,!0),b())},seed:(v,y)=>{const L=y.then(Z=>Z===null?bt:Z,()=>bt),D=t.get(v);if(D!==void 0&&B(v,"ok")){const Z=T(v);L.then(K=>P(v,D,Z,K));return}j(v);const U=h(Te(L),D?.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 y=(s.get(v)??0)+1;s.set(v,y);const L=await e.refresh(v);if(s.get(v)!==y)return ec;if(L.status==="error")return{status:"failed",failure:L.failure};const D=t.get(v);if(!(D!==void 0&&D.loadedAt!==null&&B(v,"ok")&&D.loadedAt>L.loadedAt)){const Z=M(v,L,!0);if(D!==void 0&&D.promise.status==="pending"){const K=T(v);D.promise.then(W=>P(v,Z,K,W))}}for(const[Z,K]of t)Z!==v&&ye(K.promise)?.status==="ok"&&(K.stale=!0);return Ji},children:(v,y)=>r.get(v)?.get(y),claimChildren:(v,y)=>{const L=O(v),D=g(v);let U=!1,Z=!1;for(const[W,ne]of y)L.claims.set(W,(L.claims.get(W)??0)+1),D.get(W)===void 0?(D.set(W,Sn),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 y.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,y)=>{const L=r.get(v);if(L===void 0||L.get(y)?.status!=="failed")return;const D=O(v);if((D.claims.get(y)??0)>0){L.set(y,Sn),D.direct.add(y),b(),F();return}L.delete(y),b()},pendingChildren:v=>{const y=a.get(v);return y===void 0?0:y.direct.size+y.bulk.size+y.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))j(v);for(const[v,y]of s)s.set(v,y+1);t.clear(),r.clear(),b()},subscribeChildrenFailures:v=>(m.add(v),()=>{m.delete(v)}),subscribe:i.subscribe,version:()=>E}},sc=(e,t)=>{let n=e;const r=xe();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ac=1;let Ie=0,ie=null;const lc=()=>{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))}},ic=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],kn=1,cc=1e3,Rn=e=>e.getClientRects().length>0,ct="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.",dc=e=>{if(!Rn(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ac)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. ${ct}`;if(t.height<kn)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. ${ct}`;for(const{selector:r,name:o}of ic)for(const s of e.querySelectorAll(r)){if(!Rn(s))continue;const a=s.getBoundingClientRect().height;if(a<kn)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. ${ct}`}return null},uc=e=>{let t=!1,n;const r=()=>{n=void 0;const a=dc(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,cc))},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)}},fc=(e,t)=>{d.useEffect(()=>e?lc():void 0,[e]),d.useEffect(()=>{const n=t.current;if(!(!e||n===null))return uc(n)},[e,t])},Tn='[data-testid="markdown-explorer-view-switch"]',mc=[{control:Tn,successors:[Tn,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],hc=e=>{for(const t of mc){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},pc=(e,t)=>{const n=d.useRef(null);d.useEffect(()=>{const o=i=>{const m=e.current;n.current=m!==null&&i instanceof Element&&m.contains(i)?hc(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=d.useRef(t);d.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 c of o.control.successors)for(const u of f.querySelectorAll(c))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])},gc=d.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-CJrJNZHq.cjs")).then(e=>({default:e.TreeLayout}))),wc=d.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-Coc-HQUb.cjs")).then(e=>({default:e.MultiLayout}))),vc=64,Ec={request:e=>{requestAnimationFrame(e)}},Cn=e=>{e.documents.clear(),e.trees.clear()},dt=(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)},xc=(e,t)=>{const[n,r]=d.useState(()=>({overrides:t,locale:e,labels:pt(e,t)}));if(n.locale===e&&So(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:pt(e,t)};return r(o),o.labels},bc=(e,t,n)=>{const[r,o]=d.useState(()=>({scope:t,store:yn(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:yn(e,n)};return o(s),s.store},ut=(e,t)=>{const[n,r]=d.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},yc=()=>Ki(Ec),Ln="on",Sc="off",kc=Object.freeze({kind:"unavailable"}),Rc=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")},Tc=(e,t)=>{const n=le(e.peek(t));return n===null||n.document.kind==="failure"?_.lastPathSegment(t):n.document.name},Cc=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:m=!1,onMathDiagnostics:f,onEditGrant:c,draftConverter:u})=>{J.assertStorageNamespace(n),Rc(u);const p=Pn(r),w=ko(s),E=xc(p,o),{revalidate:b}=te.useRevalidator(),T=d.useRef(()=>{}),O=te.useHref(t.dataPath),[C]=d.useState(()=>{const L=Xi({dataPath:O,onScope:U=>T.current(U)}),D={documents:fs({client:L,capacity:Math.max(vc,t.multiView.maxPanels*2)}),trees:oc(L)};return dt(D,e),J.syncStorageScope(n,e.scope),{data:L,...D,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:dt(C,e)),J.syncStorageScope(n,e.scope)}const q=bc(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);d.useLayoutEffect(()=>{const L=C.aligned.pendingReader;L!==null&&(C.aligned.pendingReader=null,Cn(C),dt(C,L))},[e,C]),d.useLayoutEffect(()=>{let L=!1;return T.current=D=>{D===e.scope||L||(L=!0,D!==null&&(Cn(C),J.clearExplorerStorage(n)),b())},()=>{T.current=()=>{}}},[e,b,C,n]);const j=d.useRef(t.settingsCookie);d.useLayoutEffect(()=>{j.current=t.settingsCookie},[t.settingsCookie]);const[h]=d.useState(()=>sc(e.settings,L=>{document.cookie=H.viewSettingsCookieString(j.current,L,window.location.protocol==="https:")})),g=ut(e.scope,yc),R=ut(e.scope,Yi),N=d.useRef(E);d.useLayoutEffect(()=>{N.current=E},[E]);const I=ut(e.scope,()=>Mo({data:C.data,conflictLabels:()=>({ours:N.current.conflictOurs,theirs:N.current.conflictTheirs}),onSaveSettled:(L,D)=>{D.kind==="saved"&&C.documents.refresh(L);const U=To(N.current,D,Tc(C.documents,L));U!==null&&g.announce(U)},sideBySideSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Ln,write:L=>J.writeStorage(J.storageKeys(n).editPreview,L?Ln:Sc)},editorShareSetting:{read:()=>Ao(J.readStorage(J.storageKeys(n).editSplit)),write:L=>J.writeStorage(J.storageKeys(n).editSplit,String(L))}})),F=d.useMemo(()=>Te(e.notices.catch(()=>[])),[e.notices]),x=e.sources.map(L=>L.id).join(`
|
|
14
|
-
`),k=d.useMemo(()=>H.withExplorerSources(t,x.split(`
|
|
15
|
-
`)),[t,x]),A=d.useRef(f);d.useLayoutEffect(()=>{A.current=f},[f]);const[M]=d.useState(()=>(L,D)=>{A.current?.(L,D)}),P=f===void 0?void 0:M,B=d.useRef(u);d.useLayoutEffect(()=>{B.current=u},[u]);const[G]=d.useState(()=>{let L=!1;return{convert:(D,U)=>{const Z=B.current;return Z===void 0?Promise.resolve(kc):Z.convert(D,U)},prepare:()=>{try{B.current?.prepare?.()}catch(D){if(L)return;L=!0,console.error("[markdown-explorer] the draft converter's prepare threw",D)}}}}),v=u===void 0?void 0:G,y=d.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:c,draftConverter:v,renderTreeFailure:i,reportMathDiagnostics:P}),[k,E,p,w,n,e.scope,e.sources,F,C,h,q,g,R,I,c,v,i,P]);return l.jsx(_n,{value:y,children:l.jsx(Oc,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Lc=({ref:e,theme:t,view:n,children:r})=>{const[o]=d.useState(ea);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})},Oc=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=$(),o=Ze(),{hash:s}=te.useLocation(),a=Oe(),i=d.useRef(null);fc(t,i),d.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,f=m.view;pc(i,f);const c=m.view==="tree"?l.jsx(d.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(gc,{location:m})}):m.view==="multi"?l.jsx(d.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(wc,{location:m})}):l.jsx(Gi,{location:m}),u=l.jsxs(Lc,{ref:i,theme:n,view:f,children:[c,l.jsx(Vo,{}),l.jsx(oo,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?u:e({view:f,children:u})},Ac=wo.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=ze;exports.CONFLICT_OURS_MARKER=$n;exports.CONFLICT_SEPARATOR=Fn;exports.CONFLICT_THEIRS_MARKER=qn;exports.CONTENT_PANE=Be;exports.ContentSkeleton=ue;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=On;exports.DocumentPane=Wr;exports.DocumentRefreshBar=ro;exports.EXPLORER_THEMES=gt;exports.EditGrantNotice=Yr;exports.ExplorerLink=ar;exports.FOLDER_README_LOADING=Wn;exports.FailureView=ce;exports.ForwardRef=Gr;exports.ForwardRef$1=Xr;exports.ImageViewMemoryContext=wr;exports.LazyNativeScrollBar=ir;exports.LiveRegion=oo;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=jn;exports.MARKDOWN_EXPLORER_LABEL_KEYS=St;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Nn;exports.MARKDOWN_EXPLORER_LOCALES=ht;exports.MarkdownExplorer=Cc;exports.NATIVE_SCROLL_BAR_WIDTH=is;exports.NO_DOCUMENT=zr;exports.PAGE_DOCUMENT_REFRESH=no;exports.TAP_SCROLL_CIRCLE_GUTTER=Ot;exports.TAP_SCROLL_CIRCLE_OFFSET_X=cs;exports.TAP_SCROLL_CIRCLE_SIZE=Lt;exports.anchorOfDoubleClick=er;exports.anchorOfView=tr;exports.blockAtLine=or;exports.chooseEditView=xt;exports.consumeKey=kt;exports.createEmitter=xe;exports.cssPixels=Un;exports.editViewOf=Qr;exports.explorerNavigationOptions=ss;exports.failureTitleOf=re;exports.findConflictsInLines=Bn;exports.focusWithoutScroll=Ct;exports.frameTopOf=nr;exports.isApplePlatform=eo;exports.isEditViewShortcut=to;exports.isEditingDoubleClick=Jn;exports.lineTopIn=sr;exports.loadedOf=le;exports.paneShownAlone=Di;exports.positionInSource=rs;exports.readFolderReadme=Gn;exports.resolveMarkdownExplorerLabels=pt;exports.shouldRevalidateExplorer=Ac;exports.toggledEditView=Jr;exports.useExplorer=$;exports.useExplorerLocation=Ze;exports.useExplorerNavigate=Oe;exports.useIntentPrefetch=lr;exports.usePageMarkupToggle=xr;exports.useSideBySide=Yn;exports.useViewSetting=Re;exports.visibleTopOf=rr;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { tapScrollCircleSampleVisual as e } from "@aiquants/virtualscroll";
|
|
2
|
-
import { T as r, c as C } from "./index-CdYr9OQ-.js";
|
|
3
|
-
const _ = Object.freeze({
|
|
4
|
-
renderVisual: e,
|
|
5
|
-
minSpeedMultiplier: 0.25,
|
|
6
|
-
maxSpeedMultiplier: 18,
|
|
7
|
-
size: C,
|
|
8
|
-
offsetX: r
|
|
9
|
-
}), a = Object.freeze({ enabled: !1 });
|
|
10
|
-
export {
|
|
11
|
-
a as N,
|
|
12
|
-
_ as T
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const C=require("@aiquants/virtualscroll"),e=require("./index-CjyRD7qg.cjs"),L=Object.freeze({renderVisual:C.tapScrollCircleSampleVisual,minSpeedMultiplier:.25,maxSpeedMultiplier:18,size:e.TAP_SCROLL_CIRCLE_SIZE,offsetX:e.TAP_SCROLL_CIRCLE_OFFSET_X}),_=Object.freeze({enabled:!1});exports.NO_TAP_SCROLL_CIRCLE=_;exports.TAP_SCROLL_CIRCLE=L;
|