@aiquants/markdown-explorer 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +608 -0
  2. package/README.md +121 -41
  3. package/dist/EditSurface-B70iRFkG.cjs +6 -0
  4. package/dist/EditSurface-BCFJRyIM.js +990 -0
  5. package/dist/ExplorerSplit-BNrHrIus.cjs +2 -0
  6. package/dist/ExplorerSplit-Bgccz2nm.js +1589 -0
  7. package/dist/MultiLayout-Bo9LAXiY.cjs +1 -0
  8. package/dist/{MultiLayout-kcZyVnvK.js → MultiLayout-Dy5TIC2t.js} +249 -248
  9. package/dist/{NativeScrollBar-pUbA4Zq3.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
  10. package/dist/{NativeScrollBar-UNed10Na.js → NativeScrollBar-DpZMYhmf.js} +2 -2
  11. package/dist/TreeLayout-DsSKW_Qj.js +103 -0
  12. package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
  13. package/dist/client/MarkdownExplorer.d.cts +14 -1
  14. package/dist/client/MarkdownExplorer.d.ts +14 -1
  15. package/dist/client/edit/lineEndings.d.cts +4 -0
  16. package/dist/client/edit/lineEndings.d.ts +4 -0
  17. package/dist/client/hostContract.d.cts +67 -0
  18. package/dist/client/hostContract.d.ts +67 -0
  19. package/dist/core/config.d.cts +13 -0
  20. package/dist/core/config.d.ts +13 -0
  21. package/dist/core/contracts.d.cts +31 -4
  22. package/dist/core/contracts.d.ts +31 -4
  23. package/dist/core/dataRoute.d.cts +5 -1
  24. package/dist/core/dataRoute.d.ts +5 -1
  25. package/dist/core/documentId.d.cts +6 -0
  26. package/dist/core/documentId.d.ts +6 -0
  27. package/dist/core/draftAnswer.d.cts +23 -0
  28. package/dist/core/draftAnswer.d.ts +23 -0
  29. package/dist/core/labels.d.cts +78 -0
  30. package/dist/core/labels.d.ts +78 -0
  31. package/dist/core/location.d.cts +22 -2
  32. package/dist/core/location.d.ts +22 -2
  33. package/dist/core/ownUrls.d.cts +15 -0
  34. package/dist/core/ownUrls.d.ts +15 -0
  35. package/dist/core/treeSettings.d.cts +3 -2
  36. package/dist/core/treeSettings.d.ts +3 -2
  37. package/dist/core/viewSettings.d.cts +3 -1
  38. package/dist/core/viewSettings.d.ts +3 -1
  39. package/dist/describeValue-CLlVRO8d.js +17 -0
  40. package/dist/describeValue-Ccvhbt36.cjs +1 -0
  41. package/dist/explorerCore-B3RGmMG6.js +1083 -0
  42. package/dist/explorerCore-CUkyKtm8.cjs +1 -0
  43. package/dist/index-D0l_BJqb.js +5980 -0
  44. package/dist/index-lpL7GltU.cjs +18 -0
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.d.cts +8 -4
  47. package/dist/index.d.ts +8 -4
  48. package/dist/index.js +53 -43
  49. package/dist/licenses/@heroicons/react/LICENSE +21 -0
  50. package/dist/licenses/entities/LICENSE +11 -0
  51. package/dist/licenses/parse5/LICENSE +19 -0
  52. package/dist/location-Dh6K-y7w.js +761 -0
  53. package/dist/location-DrOP6t1F.cjs +1 -0
  54. package/dist/lru-DC8GBmkX.js +39 -0
  55. package/dist/lru-SGmUyBQU.cjs +1 -0
  56. package/dist/{merge-C1MWvhCS.js → merge-BwcqBd4c.js} +1 -1
  57. package/dist/{merge-BziXxZkE.cjs → merge-Dckw7r9T.cjs} +1 -1
  58. package/dist/nestingGuardWorker.js +5511 -0
  59. package/dist/ownUrls-BTPGNhBt.cjs +1 -0
  60. package/dist/ownUrls-DD0cSCsF.js +409 -0
  61. package/dist/sanitizeJob-BYqzjFJC.js +21 -0
  62. package/dist/sanitizeJob-CudE1RUP.cjs +1 -0
  63. package/dist/sanitizePolicy-C-ehd0J_.cjs +2 -0
  64. package/dist/sanitizePolicy-DAPnUUVm.js +139 -0
  65. package/dist/sanitizeWorker.cjs +1 -1
  66. package/dist/sanitizeWorker.js +134 -139
  67. package/dist/sanitizerService-B8v4ap9t.js +240 -0
  68. package/dist/sanitizerService-DomN7lwC.cjs +1 -0
  69. package/dist/server/assetResponse.d.cts +60 -0
  70. package/dist/server/assetResponse.d.ts +60 -0
  71. package/dist/server/browser/browserPlatform.d.cts +12 -0
  72. package/dist/server/browser/browserPlatform.d.ts +12 -0
  73. package/dist/server/createMarkdownExplorer.d.cts +0 -10
  74. package/dist/server/createMarkdownExplorer.d.ts +0 -10
  75. package/dist/server/errors.d.cts +1 -1
  76. package/dist/server/errors.d.ts +1 -1
  77. package/dist/server/explorerCore.d.cts +12 -0
  78. package/dist/server/explorerCore.d.ts +12 -0
  79. package/dist/server/fileSystemSource.d.cts +1 -0
  80. package/dist/server/fileSystemSource.d.ts +1 -0
  81. package/dist/server/inProcessFetch.d.cts +5 -0
  82. package/dist/server/inProcessFetch.d.ts +5 -0
  83. package/dist/server/platform.d.cts +18 -0
  84. package/dist/server/platform.d.ts +18 -0
  85. package/dist/server/ports.d.cts +55 -5
  86. package/dist/server/ports.d.ts +55 -5
  87. package/dist/server/sanitizeProtocol.d.cts +3 -0
  88. package/dist/server/sanitizeProtocol.d.ts +3 -0
  89. package/dist/server/sanitizer.d.cts +5 -40
  90. package/dist/server/sanitizer.d.ts +5 -40
  91. package/dist/server/sanitizerOptions.d.cts +24 -0
  92. package/dist/server/sanitizerOptions.d.ts +24 -0
  93. package/dist/server/sanitizerService.d.cts +41 -0
  94. package/dist/server/sanitizerService.d.ts +41 -0
  95. package/dist/server/{workerPool.d.cts → workerJobs.d.cts} +0 -16
  96. package/dist/server/{workerPool.d.ts → workerJobs.d.ts} +0 -16
  97. package/dist/server.cjs +1 -1
  98. package/dist/server.d.cts +3 -1
  99. package/dist/server.d.ts +3 -1
  100. package/dist/server.js +270 -1343
  101. package/dist/serverBrowser.cjs +1 -0
  102. package/dist/serverBrowser.d.cts +1 -0
  103. package/dist/serverBrowser.d.ts +1 -0
  104. package/dist/serverBrowser.js +120 -0
  105. package/dist/serverCore.cjs +1 -0
  106. package/dist/serverCore.d.cts +14 -0
  107. package/dist/serverCore.d.ts +14 -0
  108. package/dist/serverCore.js +46 -0
  109. package/dist/storage-BpYsprog.cjs +1 -0
  110. package/dist/{storage-CmGHg7OA.js → storage-D1uSw-xj.js} +19 -18
  111. package/dist/storage.cjs +1 -1
  112. package/dist/storage.js +1 -1
  113. package/dist/styles/markdown-explorer.css +1 -1
  114. package/dist/{tapScrollCircle-DigcJCsu.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
  115. package/dist/{tapScrollCircle-D_BpaLwY.js → tapScrollCircle-smKLgRa2.js} +1 -1
  116. package/dist/testing.cjs +1 -0
  117. package/dist/testing.d.cts +11 -0
  118. package/dist/testing.d.ts +11 -0
  119. package/dist/testing.js +82 -0
  120. package/dist/useSplitPersistence-BUa_KMsV.cjs +1 -0
  121. package/dist/useSplitPersistence-pnb21dsr.js +44 -0
  122. package/docs/behavior/dom-hooks.md +5 -1
  123. package/docs/behavior/hosting.md +123 -0
  124. package/docs/behavior/layout.md +5 -3
  125. package/docs/behavior/localization.md +25 -8
  126. package/docs/behavior/security.md +55 -15
  127. package/docs/behavior/url-contract.md +30 -3
  128. package/package.json +48 -10
  129. package/dist/EditSurface-CF82jZQg.cjs +0 -6
  130. package/dist/EditSurface-CqHk2R3k.js +0 -982
  131. package/dist/ExplorerSplit-D325YGEf.cjs +0 -1
  132. package/dist/ExplorerSplit-DGH9bckm.js +0 -1500
  133. package/dist/MultiLayout-CzR7yJ0m.cjs +0 -1
  134. package/dist/TreeLayout-BnIU87HX.js +0 -96
  135. package/dist/TreeLayout-DtvIpuOe.cjs +0 -1
  136. package/dist/dataRoute-D6KiSHIc.js +0 -298
  137. package/dist/dataRoute-DwYtgyt6.cjs +0 -1
  138. package/dist/index-BDCbvHDs.cjs +0 -15
  139. package/dist/index-DR31S_-4.js +0 -5012
  140. package/dist/location-C44b9H1S.js +0 -676
  141. package/dist/location-hGLhCCg4.cjs +0 -1
  142. package/dist/sanitizePolicy-CwvyPpp5.js +0 -98
  143. package/dist/sanitizePolicy-T5T-3vV5.cjs +0 -1
  144. package/dist/storage-DM0EvkVf.cjs +0 -1
  145. package/dist/useSplitPersistence-DCeYbJMx.js +0 -38
  146. package/dist/useSplitPersistence-QGcvyMAa.cjs +0 -1
@@ -1,15 +0,0 @@
1
- "use strict";const l=require("react/jsx-runtime"),d=require("react"),te=require("react-router"),H=require("./location-hGLhCCg4.cjs"),ve=require("@aiquants/markdown/code-blocks"),P=require("./dataRoute-DwYtgyt6.cjs"),Ee=require("@aiquants/markdown"),gt=require("@aiquants/markdown/source-lines"),wt=require("@aiquants/spreadsheet/tsv"),Yt=require("@aiquants/spreadsheet/view"),Io=require("@aiquants/markdown/viewer-settings"),J=require("./storage-DM0EvkVf.cjs"),Fo=require("@aiquants/route-revalidation");function $o(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=$o(d),vt=Object.freeze(["en","ja"]),In="en",Tt=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Fn=Object.freeze(Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),$n=e=>Object.fromEntries(Fn.map(t=>[Tt(t),ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),Bn=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"]),viewerSvgImageFullscreenDialog:Object.freeze(["name"]),...Object.fromEntries(Fn.filter(e=>ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[Tt(e),ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),Bo=/\{(\w+)\}/gu,qn={...$n("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}`,documentMaximize:"Maximize the document",documentRestore:"Restore the document to its size",documentMaximized:e=>`Maximized ${e}`,documentRestored:e=>`Restored ${e} to its size`,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",viewerMermaidFullscreen:"View full screen",viewerMermaidExitFullscreen:"Exit full screen",viewerMermaidFullscreenDialog:"Diagram (full screen)",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.",viewerSvgImageFullscreen:"View full screen",viewerSvgImageExitFullscreen:"Exit full screen",viewerSvgImageFullscreenDialog:"{name} (full screen)",viewerCodeBlockCopy:"Copy the code",viewerCodeBlockCopied:"Copied the code.",viewerCodeBlockCopyFailed:"Could not copy the code.",viewerDisplayMathCopy:"Copy the formula",viewerDisplayMathCopied:"Copied the formula.",viewerDisplayMathCopyFailed:"Could not copy the formula.",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",panelMoreActions:"More actions",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"},qo={...$n("ja"),explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentMaximize:"文書を最大化",documentRestore:"文書を元のサイズに戻す",documentMaximized:e=>`${e} を最大化しました`,documentRestored: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:"右へ移動",viewerMermaidFullscreen:"全画面で見る",viewerMermaidExitFullscreen:"全画面を閉じる",viewerMermaidFullscreenDialog:"図 (全画面)",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",viewerSvgImageFullscreen:"全画面で見る",viewerSvgImageExitFullscreen:"全画面を閉じる",viewerSvgImageFullscreenDialog:"{name} (全画面)",viewerCodeBlockCopy:"コードをコピー",viewerCodeBlockCopied:"コードをコピーしました。",viewerCodeBlockCopyFailed:"コードをコピーできませんでした。",viewerDisplayMathCopy:"数式をコピー",viewerDisplayMathCopied:"数式をコピーしました。",viewerDisplayMathCopyFailed:"数式をコピーできませんでした。",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:"下へ移動",panelMoreActions:"その他の操作",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},Un=Object.freeze({en:Object.freeze(qn),ja:Object.freeze(qo)}),Ct=Object.freeze(Object.keys(qn)),Uo=new Set(Ct),Ho=e=>Uo.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,Hn=e=>{if(e===void 0)return In;if(vt.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${vt.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${$e(e)}`)},Et=(e,t)=>{const n=Un[Hn(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(!Ho(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ct.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 f=Bn[s];if(typeof a=="string"&&f!==void 0){for(const[,m]of a.matchAll(Bo))if(!f.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${f.map(u=>`{${u}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},zo=(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]))},xt=Object.freeze(["light","dark"]),Vo=e=>{if(e===void 0)return"light";if(xt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${xt.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},zn=d.createContext(null),I=()=>{const e=d.use(zn);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},Te=e=>{const{viewSettings:t}=I(),n=()=>e(t.getSnapshot());return d.useSyncExternalStore(t.subscribe,n,n)},Xe=()=>{const{config:e}=I(),t=te.useParams()["*"],[n]=te.useSearchParams(),r=n.toString();return d.useMemo(()=>H.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Vn={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[Vn[t][0]],ce=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=I(),s=re(o,e.reason),a=o[Vn[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]})},Zo=(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:""},Wo=(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()}}},Zn="<<<<<<<",Wn="=======",Gn=">>>>>>>",Qt=(e,t)=>e===t||e.startsWith(`${t} `),Jt=e=>Kn(e.split(`
2
- `)),Kn=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||(Qt(s,Zn)?(n=o,r=null):s===Wn?n!==null&&r===null?r=o:n=null:Qt(s,Gn)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},en=e=>e.includes(`\r
3
- `)?`\r
4
- `:`
5
- `,tt=e=>e.replace(/\r\n?/gu,`
6
- `),Go=(e,t)=>t===`
7
- `?e:e.replaceAll(`
8
- `,`\r
9
- `),Ko=3,Xo=/^\d+(?:\.\d+)?$/u,Yo=e=>{if(e===null||!Xo.test(e))return null;const t=Number(e);return t>=H.EDIT_SPLIT_MIN_PERCENT&&t<=H.EDIT_SPLIT_MAX_PERCENT?t:null},nt=Object.freeze({kind:"idle"}),tn=Object.freeze({kind:"draft"}),Qo=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,i=new Map,f=new Map,m=new Map,u=xe();let c=null,h=null,w=null;const E=(p,g)=>{p.value={...p.value,...g},u.emit()},b=(p,g)=>s.get(p)===g,k=async(p,g)=>{g.controller.abort(),g.controller=new AbortController;const{signal:C}=g.controller;E(g,{phase:{kind:"opening"}});const A=await e.edit(p,C);if(!b(p,g)||C.aborted||!("kind"in A))return;if(A.kind==="grant"){E(g,{phase:{kind:"grant",href:A.href}});return}if(A.kind==="failure"){E(g,{phase:{kind:"failed",failure:A.failure}});return}const $=tt(A.text),B=A.kind==="draft";g.base={text:$,version:B?null:A.version},g.draft=$,g.ending=en(A.text),E(g,{phase:{kind:"editing"},history:B?!1:A.history,dirty:!1,save:B?tn:nt,generation:g.value.generation+1})},L=p=>{const g=s.get(p);g!==void 0&&(g.controller.abort(),s.delete(p),i.delete(p))},R=(p,g,C)=>(p.set(g,C),()=>{p.get(g)===C&&p.delete(g)}),F=(p,g,C,A={})=>{E(g,{...A,save:C}),n(p,C)},D=async p=>{f.get(p)?.flush();const g=s.get(p);if(g===void 0||g.value.phase.kind!=="editing"||g.base===null||g.value.save.kind==="saving")return;const{version:C}=g.base;if(C===null){n(p,tn);return}const A=Jt(g.draft).length;if(A>0){F(p,g,{kind:"conflicts",count:A});return}g.controller.abort(),g.controller=new AbortController;const{signal:$}=g.controller;let B={text:g.base.text,version:C},x=g.draft,T=!1;E(g,{save:{kind:"saving"}});for(let M=0;M<Ko;M+=1){const N=await e.save(p,B.version,Go(x,g.ending),$);if(!b(p,g)||$.aborted||!("kind"in N))return;if(N.kind==="saved"){f.get(p)?.flush(),g.base={text:x,version:N.version},F(p,g,{kind:"saved",merged:T},{dirty:g.draft!==x});return}if(N.kind==="grant"){F(p,g,{kind:"grant",href:N.href});return}if(N.kind==="failure"){F(p,g,{kind:"failed",failure:N.failure});return}const{mergeDraft:_}=await Promise.resolve().then(()=>require("./merge-BziXxZkE.cjs"));if(!b(p,g)||$.aborted)return;const U=f.get(p);U?.flush();const Z=tt(N.text),v=_(B.text,g.draft,Z,t());if(B={text:Z,version:N.version},g.base=B,g.ending=en(N.text),g.draft=v.text,U?.adopt(v.text),v.kind==="conflicts"){F(p,g,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:g.value.generation+1});return}if(T=!0,x=v.text,x===B.text){F(p,g,{kind:"saved",merged:T},{dirty:!1,generation:g.value.generation+1});return}E(g,{dirty:!0,generation:g.value.generation+1})}F(p,g,{kind:"failed",failure:{reason:"failed"}})};return{session:p=>s.get(p)?.value,subscribe:u.subscribe,start:(p,g)=>{const C=s.get(p);if(C!==void 0){E(C,{request:{anchor:g},view:"editor"}),(C.value.phase.kind==="failed"||C.value.phase.kind==="grant")&&k(p,C);return}a.delete(p);const A={value:{path:p,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:nt,generation:0,request:{anchor:g}},base:null,draft:"",ending:`
10
- `,controller:new AbortController};s.set(p,A),k(p,A)},retry:p=>{const g=s.get(p);g===void 0||g.value.phase.kind==="editing"||k(p,g)},draft:p=>{const g=s.get(p);return g===void 0||g.base===null?null:g.draft},setDraft:(p,g)=>{const C=s.get(p);if(C===void 0||C.base===null)return;C.draft=g;const A={},$=g!==C.base.text;$!==C.value.dirty&&(A.dirty=$);const{save:B}=C.value;if(B.kind==="conflicts"){const x=Jt(g).length;x===0?A.save=nt:x!==B.count&&(A.save={kind:"conflicts",count:x})}(A.dirty!==void 0||A.save!==void 0)&&E(C,A)},consumeRequest:p=>{const g=s.get(p);g!==void 0&&g.value.request!==null&&E(g,{request:null})},save:D,replaceDraft:(p,g)=>{const C=f.get(p);C?.flush();const A=s.get(p);if(A===void 0||A.base===null)return;const $=tt(g);A.draft=$,C?.adopt($),E(A,{dirty:$!==A.base.text,generation:A.value.generation+1})},close:p=>{if(!s.has(p))return;const g=f.get(p),C=g===void 0?null:g.returnPoint();L(p),C===null?a.delete(p):a.set(p,C),u.emit()},takeReturn:p=>{const g=a.get(p)??null;return a.delete(p),g},dirtyPaths:()=>[...s.values()].filter(p=>p.value.dirty).map(p=>p.value.path),discard:p=>{for(const g of p)L(g);p.length>0&&u.emit()},editorState:{get:p=>i.get(p),set:(p,g)=>{s.has(p)&&i.set(p,g)}},bindEditor:(p,g)=>R(f,p,g),bindView:(p,g)=>R(m,p,g),viewAnchor:p=>{const g=m.get(p);return g===void 0?null:g.anchor()},flush:p=>f.get(p)?.flush(),flushDrafts:()=>{for(const p of f.values())p.flush()},nextConflict:p=>f.get(p)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:p=>{for(const g of f.values())g.flush();return p.filter(g=>s.get(g)?.value.dirty===!0)},askToDiscard:p=>new Promise(g=>{w?.settle(!1);const C={paths:p,settle:A=>{if(w===C){if(w=null,A)for(const $ of p)L($);u.emit(),g(A)}}};w=C,u.emit()}),discardRequest:()=>w,sideBySide:()=>(c??=r.read(),c),setSideBySide:p=>{c!==p&&(c=p,r.write(p),u.emit())},editorShare:()=>(h??=o.read()??H.EDIT_SPLIT_DEFAULT_PERCENT,h),setEditorShare:p=>{if(!Number.isFinite(p))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(p)}`);const g=Math.min(H.EDIT_SPLIT_MAX_PERCENT,Math.max(H.EDIT_SPLIT_MIN_PERCENT,p));h!==g&&(h=g,o.write(g))},setView:(p,g)=>{const C=s.get(p);C===void 0||C.value.view===g||(f.get(p)?.beforeView(g),E(C,{view:g,previewPrepared:C.value.previewPrepared||g==="preview"}))},preparePreview:p=>{const g=s.get(p);g!==void 0&&!g.value.previewPrepared&&E(g,{previewPrepared:!0})}}},Lt=e=>{e.preventDefault(),e.stopPropagation()},Xn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Yn="data-aqmx-content-pane",He=Object.freeze({[Yn]:""}),Jo="--aqmx-dialog-left",es="--aqmx-dialog-top",ts='[data-testid="markdown-explorer"]',ns=e=>{const t=e.closest(ts)?.querySelectorAll(`[${Yn}]`),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},rs=e=>{const t=Xn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=ns(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(Jo,`${String(s)}px`),e.style.setProperty(es,`${String(a)}px`),n},os=e=>e.preventDefault(),Qn=({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 u=r.current;if(u!==null)if(e&&!u.open){const c=u.ownerDocument.activeElement;o.current=c instanceof HTMLElement?c:null,u.showModal(),a.current?.()}else!e&&u.open&&(u.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),d.useLayoutEffect(()=>{const u=r.current;if(!e||u===null)return;const c=new ResizeObserver(()=>w());let h=null;const w=()=>{const b=rs(u);b===null||b===h||(h!==null&&c.unobserve(h),c.observe(b),h=b)};w(),c.observe(u);const E=u.ownerDocument.defaultView;return E?.addEventListener("resize",w),u.ownerDocument.addEventListener("scroll",w,{capture:!0,passive:!0}),()=>{c.disconnect(),E?.removeEventListener("resize",w),u.ownerDocument.removeEventListener("scroll",w,{capture:!0})}},[e]);const i=d.useCallback(u=>{u.key!=="Escape"||u.defaultPrevented||(Lt(u),n())},[n]),f=d.useCallback(u=>{u.target===u.currentTarget&&n()},[n]),m=d.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:f,onCancel:os,onClose:m}},Jn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const f=d.useRef(null),m=d.useId(),u=d.useId(),c=d.useCallback(()=>f.current?.focus(),[]),h=Qn({open:e,onOpen:c,onDismiss:a});return l.jsx("dialog",{...h,className:"aqmx-confirm","aria-labelledby":m,"aria-describedby":u,"data-testid":i,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:m,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:u,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:f,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})]})]})})},Ce=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},er=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ye=e=>e.status==="fulfilled"?e.value:void 0,tr=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),ss=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),as=(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 f of[...i].reverse())o.push(f)}return null},nr=(e,t,n)=>{const r=ye(e.read(t));if(r===void 0||r.status==="deferred")return tr;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=as(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"?ss: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}},ls=(e,t,n)=>{const{readme:r}=nr(e,t,n);return r.status==="ok"?r.readme:null},is=(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)}},rr=e=>{const{edits:t}=I(),n=d.useCallback(()=>t.session(e),[t,e]);return d.useSyncExternalStore(t.subscribe,n,cs)},or=()=>!1,cs=()=>{},ds=()=>{const{edits:e}=I();return d.useSyncExternalStore(e.subscribe,e.hasSessions,or)},sr=()=>{const{edits:e}=I();return d.useSyncExternalStore(e.subscribe,e.sideBySide,or)},us=()=>null,fs=()=>{const{edits:e,labels:t,config:n,trees:r}=I(),o=d.useRef([]),s=d.useCallback(({nextLocation:w})=>{const E=is(n,w,(b,k)=>ls(r,b,k));return e.flushDrafts(),o.current=e.dirtyPaths().filter(b=>!E.has(b)),o.current.length>0},[e,n,r]),a=te.useBlocker(s),i=ds();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 f=d.useSyncExternalStore(e.subscribe,e.discardRequest,us),m=a.state==="blocked",u=m?o.current:f===null?[]:f.paths,c=u.map(w=>P.lastPathSegment(w)).join(", "),h=u.length>0&&u.every(w=>e.session(w)?.save.kind==="draft");return l.jsx(Jn,{open:m||f!==null,title:h?t.draftDiscardTitle:t.unsavedTitle,body:h?t.draftDiscardBody(c):t.unsavedBody(c),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(a.state==="blocked"){e.discard(o.current),a.proceed();return}f?.settle(!0)},onCancel:()=>{if(a.state==="blocked"){a.reset();return}f?.settle(!1)}})};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.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 hs=S.forwardRef(ms);let rt=null;const ar=()=>(rt??=Promise.resolve().then(()=>require("./EditSurface-CF82jZQg.cjs")).catch(e=>{throw rt=null,e}),rt),ps=()=>{ar().catch(()=>{})},gs=e=>{const{default:t}=d.use(ar());return l.jsx(t,{...e})};class ws 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 lr="[data-aqmd-fullscreen]",vs=e=>e instanceof Element&&e.closest(lr)!==null,Ot=`[${gt.SOURCE_LINES_ATTRIBUTE}]`,Es="[data-aqmd-content]",xs=`a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], ${lr}, [data-aqmd-svg-image-source]`,bs=200,Le=e=>gt.parseSourceLines(e.getAttribute(gt.SOURCE_LINES_ATTRIBUTE)),Ss=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=Le(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Ot)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=Le(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},ys=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},ir=e=>e.closest(Es)!==null&&e.closest(xs)===null,cr=(e,t,n)=>{const r=Ss(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const i=r.lines.last+1;return{lines:{first:i,last:i},word:null,occurrence:0,clientTop:ze(e)}}const a=ks(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:ze(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},dr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Ot)){const i=Le(a);if(i===null)continue;n??=fr(t,a);const{top:f,bottom:m}=a.getBoundingClientRect();f<=n&&n<m?r={lines:i,block:a}:o===null&&f>=n&&(o={lines:i,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:ze(s.block)}},ur=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,fr=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return ur(e)+(Number.isFinite(n)?n:0)},ks=(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>bs||/[\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:ys(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 f=n[i-1]??"";for(let m=f.indexOf(t.word);m>=0;m=f.indexOf(t.word,m+t.word.length)){if(a===t.occurrence)return{line:i,column:m};a+=1}}return a>0?Ts(n,r,o,t.word)??s:s},Ts=(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},mr=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Ot)){const s=Le(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},hr=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=ze(e),o=Le(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},ze=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},At=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})}),Cs=e=>At[e],be=()=>{const e=te.useNavigate();return d.useCallback((t,n)=>{e(t,At[n])},[e])},pr=({navigation:e,...t})=>l.jsx(te.Link,{...t,...At[e]}),Mt=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},gr=(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(m=>{if(r.current!==m)return;const u=o.current;if(u!==null){u.then(()=>a(m));return}e.prefetch(m);const c=e.peek(m);if(c?.status!=="pending")return;const h=Promise.allSettled([c.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),i=d.useCallback(m=>{const u=t(m);u!==r.current&&(s(),u!==null&&(r.current=u,n.current=window.setTimeout(()=>{n.current=null,a(u)},H.PREFETCH_DWELL_MS)))},[s,t,a]),f=d.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return d.useMemo(()=>({onPointerOver:m=>i(m.target),onPointerOut:m=>f(m.relatedTarget),onFocus:m=>i(m.target),onBlur:m=>f(m.relatedTarget)}),[i,f])},Ls=d.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-pUbA4Zq3.cjs")).then(e=>({default:e.NativeScrollBar})));class Os 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 wr=({scroller:e,kind:t})=>l.jsx(Os,{children:l.jsx(d.Suspense,{fallback:null,children:l.jsx(Ls,{scroller:e,kind:t})})}),vr=e=>l.jsx(wr,{scroller:e,kind:"content"}),Er=Object.freeze({showArrowButtons:!0,enableThumbDrag:!0,enableTrackClick:!0}),xr=Object.freeze({showArrowButtons:!1,enableThumbDrag:!1,enableTrackClick:!1}),Nt=e=>e?xr:Er,As=8,Ms="--aqmx-scroll-bar-slot-size",Dt=`var(${Ms})`,jt=H.CONTROL_BLOCK_PIXELS,Ns=H.FIBONACCI_SPACING_PIXELS[3],Ds="--aqmx-tap-circle-gutter-size",_t=`var(${Ds})`,js=-(jt+Ns),br=Object.freeze({minSpeedMultiplier:.25,maxSpeedMultiplier:18});let Sr=null,ot=null;const bt=new Set,_s=e=>(bt.add(e),()=>{bt.delete(e)}),Ps=()=>{ot===null&&(ot=Promise.resolve().then(()=>require("./tapScrollCircle-DigcJCsu.cjs")).then(e=>{const t=e.TAP_SCROLL_CIRCLE.renderVisual;if(t===void 0)throw new TypeError("[markdown-explorer] the bars' tap-scroll circle has no look to share");Sr=t;for(const n of[...bt])n()}).catch(e=>{ot=null,console.error("[markdown-explorer] the look of a table's tap-scroll circle failed to load; the circle still scrolls without it.",e)}))},Is=({look:e,state:t})=>e(t),Fs=e=>{const t=d.useSyncExternalStore(_s,()=>Sr,()=>null);return d.useEffect(()=>{t===null&&Ps()},[t]),t===null?null:l.jsx(Is,{look:t,state:e})},yr=Object.freeze({renderVisual:e=>l.jsx(Fs,{...e}),...br,size:jt}),$s=Object.freeze({...yr,visibility:"scrolling"}),kr=e=>e?$s:yr,Rr="(pointer: coarse)",Bs=e=>{const t=window.matchMedia(Rr);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},qs=()=>window.matchMedia(Rr).matches,Us=()=>!1,Pt=()=>d.useSyncExternalStore(Bs,qs,Us),Tr=()=>{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()]}},Ve=(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)=>Ve(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)&&Ve(n[s],r[s]))},Hs=55e3,nn=Object.freeze({status:"deferred"}),st=Object.freeze({status:"refreshed"}),at=Object.freeze({status:"shown",failed:!1}),_e=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,zs=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Vs=({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=Tr(),o=xe(),s=new WeakSet,a=new Map,i=new Map,f=new Map;let m=0;const u=o.emit,c=()=>(m+=1,m),h=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},w=(x,T)=>{n.delete(x),n.set(x,T)},E=x=>performance.now()-x.validatedAt>=Hs,b=(x,T,M)=>{const N=n.get(x),_=le(N?.snapshot),U=M||N?.refreshPending===!0,Z=Ce(e.document(x,{refresh:U}).then(y=>({status:"loaded",document:y}))),v={snapshot:{status:"pending",promise:Z,previous:_},validatedAt:performance.now(),opened:T,background:null,refreshPending:!1,seeded:void 0,stamp:c()};return w(x,v),h(),Z.then(y=>{n.get(x)===v&&(v.snapshot=y,v.stamp=c(),u())}),v},k=(x,T,M,N,_,U)=>{T.background===M&&(T.background=null,!(n.get(x)!==T||T.snapshot!==N)&&(_.kind==="failure"&&N.document.kind!=="failure"||(T.validatedAt=U,T.stamp=c(),Ve(N.document,_)||(T.snapshot={status:"loaded",document:_}),u())))},L=async(x,T)=>{const M=T.snapshot;if(M.status!=="loaded")return null;const N={};T.background=N;const _=performance.now(),U=e.document(x,{refresh:T.refreshPending});T.refreshPending=!1;const Z=await U,v=T.background===N&&n.get(x)===T&&T.snapshot===M;return k(x,T,N,M,Z,_),v?Z:null},R=(x,T)=>{const{snapshot:M}=T;return M.status==="pending"?!1:M.status==="loaded"&&M.document.kind!=="failure"?(L(x,T),!1):(M.status==="loaded"&&s.add(M),b(x,!0,!1),!0)},F=x=>{i.delete(x);const T=f.get(x);if(T!==void 0){f.delete(x);for(const M of T)M()}},D=(x,T)=>new Promise(M=>{if(i.get(x)===T||!r.isHeld(x)){M();return}const N=f.get(x);N===void 0?f.set(x,new Set([M])):N.add(M)}),p=(x,T)=>{const M=a.get(x);if(M===void 0){T.resolve(null);return}if(M.last!==null&&M.last.stamp>=T.stamp){T.resolve(M.last);return}M.waiters.add(T)},g=async(x,T,M)=>{const N=await new Promise(_=>p(x,{stamp:T.stamp,resolve:_}));if(n.get(x)!==T)return Pe;if(N===null)return M?st:at;if(!M)return N.failure===null?at:_e;switch(N.before){case"copy":return N.failure===null?st:{status:"failed",failure:N.failure};case"failure":return N.failure===null?at:_e;case"none":return N.failure===null?st:_e}},C=x=>{const T={showing:"none",last:null,waiters:new Set};a.set(x,T);let M=!1;return{settle:(N,_)=>{if(M||N===void 0)return;const U={stamp:N,failure:_,before:T.showing};T.last=U,_===null?T.showing="copy":T.showing==="none"&&(T.showing="failure");for(const Z of[...T.waiters])N<Z.stamp||(T.waiters.delete(Z),Z.resolve(U))},release:()=>{if(M)return;M=!0,a.get(x)===T&&a.delete(x);const N=[...T.waiters];T.waiters.clear(),N.length>0&&queueMicrotask(()=>{for(const _ of N)p(x,_)})}}},A=x=>{const T=r.hold(x);let M=!1;return()=>{if(M)return;M=!0,T();const N=n.get(x);N!==void 0&&w(x,N),h(),r.isHeld(x)||queueMicrotask(()=>{r.isHeld(x)||F(x)})}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const T=n.get(x);T!==void 0&&T.snapshot.status!=="deferred"||(b(x,!1,!1),u())},open:x=>{const T=r.resumes(x),M=A(x),N=n.get(x);if(N===void 0||N.snapshot.status==="deferred")return b(x,!0,!1),u(),M;if(w(x,N),T)return M;const{snapshot:_}=N;return _.status==="pending"?(N.opened=!0,M):_.document.kind==="failure"?(N.opened||E(N)?(s.add(_),b(x,!0,!1),u()):N.opened=!0,M):(N.opened=!0,N.background===null&&E(N)&&L(x,N),M)},retain:A,retry:x=>{const T=n.get(x);T===void 0||T.snapshot.status!=="loaded"||T.snapshot.document.kind!=="failure"||(b(x,!0,!1),u())},seed:(x,T)=>{const M=performance.now(),N=Ce(T.then(y=>y===null?nn:{status:"loaded",document:y},()=>nn)),_=n.get(x);if(_!==void 0&&_.snapshot.status==="loaded"){const y=_.snapshot,O={};_.background=O,N.then(j=>{if(j.status==="loaded"){k(x,_,O,y,j.document,M);return}_.background===O&&(_.background=null)});return}const U=_!==void 0&&_.snapshot.status==="pending"?_.snapshot.previous:null,Z={status:"pending",promise:N,previous:U},v={snapshot:Z,validatedAt:M,opened:_?.opened===!0,background:null,refreshPending:_?.refreshPending===!0,seeded:Z,stamp:c()};w(x,v),h(),N.then(y=>{n.get(x)===v&&(y.status==="deferred"&&r.isHeld(x)?b(x,v.opened,!1):(v.snapshot=y,v.stamp=c()),u())})},invalidate:()=>{let x=!1;for(const[T,M]of[...n]){if(M.validatedAt=Number.NEGATIVE_INFINITY,M.opened=!0,M.refreshPending=!0,!r.isHeld(T))continue;const{snapshot:N}=M;if(N.status!=="pending"){R(T,M)&&(x=!0);continue}N.promise.then(()=>{n.get(T)===M&&M.refreshPending&&r.isHeld(T)&&R(T,M)&&u()})}x&&u()},refresh:async x=>{const T=n.get(x);if(T!==void 0&&zs(T.snapshot)){T.refreshPending=!0;const _=await L(x,T);return _===null?Pe:_.kind==="failure"?{status:"failed",failure:_.failure}:g(x,T,!0)}const M=b(x,!0,!0);if(u(),M.snapshot.status!=="pending")return Pe;const N=await M.snapshot.promise;return n.get(x)!==M||N.status!=="loaded"?Pe:N.document.kind==="failure"?_e:(await D(x,N),g(x,M,!1))},clear:()=>{n.clear();for(const x of r.heldKeys())b(x,!0,!1);u()},subscribe:o.subscribe,readPart:C,noteShown:(x,T)=>{i.set(x,T);const M=f.get(x);if(M!==void 0){f.delete(x);for(const N of M)N()}},noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}},de=d.createContext("fill"),Zs="--aqmx-tap-circle-gutter",Ws=Object.freeze({blockSize:"100%",[Zs]:_t}),Ae=({scrollerProps:e,children:t})=>d.use(de)==="content"?l.jsx(Ee.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(Ee.HostedScrollArea,{scrollerProps:{...e,style:Ws},rowClassName:"aqmx-document-scroll-row",renderScrollBar:vr,barInlineSize:Dt,children:t}),Gs=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Ks=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:Gs.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),It=({failure:e,onRetry:t,testId:n})=>l.jsx(Ae,{scrollerProps:Ks,children:l.jsx(ce,{failure:e,alert:!1,onRetry:t,testId:n})});function Xs({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 Ys=S.forwardRef(Xs);function Qs({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 Js=S.forwardRef(Qs);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",{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 ta=S.forwardRef(ea),na=2e3,rn=Object.freeze({outcome:"idle"}),ra=(e,t)=>new Promise(n=>n(e.writeText(t))),oa=({text:e})=>{const{announcer:t,labels:n}=I(),[r,o]=d.useState(rn),s=d.useRef(0);d.useEffect(()=>{if(r.outcome==="idle")return;const f=setTimeout(()=>o(rn),na);return()=>clearTimeout(f)},[r]);const a=()=>{s.current+=1;const f=s.current,m=c=>{s.current===f&&(o({outcome:c}),t.announce(c==="copied"?n.copiedText:n.copyTextFailed))},u=navigator.clipboard;if(u===void 0){m("failed");return}ra(u,e).then(()=>m("copied"),c=>{console.error("[markdown-explorer] could not copy the text",c),m("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(Ys,{}):r.outcome==="failed"?l.jsx(ta,{}):l.jsx(Js,{})})},Cr=d.createContext(null),sa=()=>{const e=d.use(Cr);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 aa({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 la=S.forwardRef(aa);function ia({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 ca=S.forwardRef(ia),Me=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=I();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(ca,{})}),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(la,{})})]})};function da({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 ua=S.forwardRef(da),fa=Object.freeze({className:"aqmx-document-stage"}),ma=({document:e})=>{const{labels:t}=I();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(ua,{})}),l.jsx(Ae,{scrollerProps:fa,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})]})})]})},on=["keydown","pointerdown","wheel","touchstart"],Be=new WeakMap,Ze=new WeakMap,ha=e=>{const t=Ze.get(e);if(t!==void 0){t.count+=1;return}Ze.set(e,{count:1,original:e.style.overflowAnchor}),e.style.overflowAnchor="none"},pa=e=>{const t=Ze.get(e);t!==void 0&&(t.count-=1,!(t.count>0)&&(Ze.delete(e),e.style.overflowAnchor=t.original))},ga=(e,t,n)=>{for(let r=t;r!==null&&r!==n;r=r.parentElement){e.observe(r);for(let o=r.previousElementSibling;o!==null;o=o.previousElementSibling)e.observe(o)}},wa=e=>{const t=new Map;for(let n=e.parentElement;n!==null;n=n.parentElement)t.set(n,{top:n.scrollTop,left:n.scrollLeft});return t},Lr=e=>{Be.get(e)?.()},Or=(e,t,n)=>{Lr(e);let r=new Map;const o=new Set,s=()=>{const c=t();return c===null?!1:(r=wa(c),!0)};if(!s()||typeof ResizeObserver>"u")return;const a=()=>{for(const c of r.keys())!(c instanceof HTMLElement)||o.has(c)||(o.add(c),ha(c))};a();const{ownerDocument:i}=e,f=new ResizeObserver(()=>{if(!s()){u();return}a()});for(const{element:c,boundary:h}of n)ga(f,c,h);const m=c=>{const h=c.target===i?i.scrollingElement:c.target;if(!(h instanceof Element))return;const w=r.get(h);w!==void 0&&(h.scrollTop!==w.top||h.scrollLeft!==w.left)&&u()},u=()=>{f.disconnect();for(const c of on)i.removeEventListener(c,u,!0);i.removeEventListener("scroll",m,!0);for(const c of o)pa(c);o.clear(),Be.get(e)===u&&Be.delete(e)};for(const c of on)i.addEventListener(c,u,{capture:!0,passive:!0});i.addEventListener("scroll",m,{capture:!0,passive:!0}),Be.set(e,u)},Ye="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",va=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Ea=/(%[0-9A-Fa-f]{2})/u,Ft=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Ea).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))},Ar=e=>`#${encodeURIComponent(e)}`,xa=e=>{if(e==="#")return!0;const t=Ft(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Mr=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},ba="http://www.w3.org/1999/xhtml",sn=(e,t)=>{if(t==="")return null;const n=Mr(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===ba&&r.getAttribute("name")===t)return r;return null},Nr=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=sn(e,t.slice(1));if(n!==null)return n;const r=Ft(t);return r===null?null:sn(e,r)},an=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"},Sa=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"},ya=(e,t)=>{const n=t.closest(Ye),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&an(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(an(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&Sa(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},ka=Object.freeze({scrollerOf:ya,reveal:e=>{e.scrollIntoView(We)},keepAtStart:(e,t)=>{Or(e,()=>t.isConnected?(Dr(e,t),t):null,[{element:t,boundary:e}])}}),We=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),Ra=(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")}}},Dr=(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(We);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(We)},Ta=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Ye)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},ln=(e,t,n)=>{if(e===null)return null;const r=Nr(e,t);return r===null?(xa(t)&&Ta(e,n),null):(Ra(e,r),n.keepAtStart(n.scrollerOf(e,r),r),r)};function Ca({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 La=S.forwardRef(Ca);function Oa({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 Aa=S.forwardRef(Oa);function Ma({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 Na=S.forwardRef(Ma);function Da({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 ja=S.forwardRef(Da),St="data-aqmx-key-repeat",Ge=Object.freeze({[St]:"allow"}),_a=`[${St}="${Ge[St]}"]`,Pa=()=>{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(_a)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},qe=Object.freeze([1/H.GOLDEN_RATIO**2,1/H.GOLDEN_RATIO,1,H.GOLDEN_RATIO,H.GOLDEN_RATIO**2]),cn=Object.freeze({mode:"fit"}),Ia=1,jr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),dn=`[data-testid="${jr["data-testid"]}"]`,_r=d.createContext(null),Fa=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=Ia?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,un=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<qe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?qe.findIndex(o=>o>t):qe.findLastIndex(o=>o<t);return r===-1?null:r},fn=(e,t,n)=>{if(e.mode==="level"){const o=un(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=un(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},$a=(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},mn=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}}},Ba=e=>{const t=qe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},hn=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},qa=({document:e})=>{const{labels:t}=I(),n=d.use(_r),[r]=d.useState(()=>n===null?null:n.read(e.url)),[o,s]=d.useState(r===null?cn:r.zoom),[a,i]=d.useState(r===null?null:r.reported),[f,m]=d.useState(null),u=d.useRef(null),c=d.useCallback(D=>{const{naturalWidth:p,naturalHeight:g}=D;i(C=>hn(C,p,g))},[]),h=d.useCallback(D=>{u.current=D,!(D===null||!D.complete)&&(D.naturalWidth>0||D.naturalHeight>0?c(D):D.decode().then(()=>c(D),()=>{}))},[c]);d.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),d.useLayoutEffect(()=>{const D=u.current;if(D===null||a===null||o.mode!=="fit")return;const p=()=>m(C=>hn(C,D.clientWidth,D.clientHeight));if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(D),()=>g.disconnect()},[a,o.mode]);const w=a===null||f===null?null:Fa(a,f),E=fn(o,w,-1),b=fn(o,w,1),k=o.mode==="level"?Ba(o.index):null,L=d.useRef({zoomIn:b,zoomOut:E});d.useLayoutEffect(()=>{L.current={zoomIn:b,zoomOut:E}});const R=d.useRef(null);d.useLayoutEffect(()=>{const D=R.current,p=u.current?.closest(dn);R.current=null,!(D===null||p===null||p===void 0)&&(p.scrollLeft=D.across*p.scrollWidth-D.x,p.scrollTop=D.down*p.scrollHeight-D.y)},[o]),d.useEffect(()=>{const D=u.current?.closest(dn);if(D==null)return;let p=null;const g=$=>{const B=mn($.touches);p=B===null?null:{distance:B.distance,steps:0}},C=$=>{const B=mn($.touches);if(p===null||B===null)return;$.preventDefault();const x=$a(p.distance,B.distance);if(x===p.steps)return;const T=x>p.steps?1:-1,M=T===1?L.current.zoomIn:L.current.zoomOut;if(M===null)return;p.steps+=T;const N=D.getBoundingClientRect(),_=B.middle.x-N.left,U=B.middle.y-N.top;R.current=D.scrollWidth>0&&D.scrollHeight>0?{x:_,y:U,across:(D.scrollLeft+_)/D.scrollWidth,down:(D.scrollTop+U)/D.scrollHeight}:null,s(M)},A=$=>{$.touches.length<2&&(p=null)};return D.addEventListener("touchstart",g,{passive:!0}),D.addEventListener("touchmove",C,{passive:!1}),D.addEventListener("touchend",A,{passive:!0}),D.addEventListener("touchcancel",A,{passive:!0}),()=>{D.removeEventListener("touchstart",g),D.removeEventListener("touchmove",C),D.removeEventListener("touchend",A),D.removeEventListener("touchcancel",A)}},[]);const F=o.mode==="level"&&k!==null?{width:`${o.base.width*k}px`,height:`${o.base.height*k}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(ja,{}),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)},...Ge,children:l.jsx(Aa,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:k===null?t.imageFitLevel:t.imageZoomLevel(Math.round(k*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)},...Ge,children:l.jsx(Na,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(cn),children:l.jsx(La,{})})]}),l.jsx(Ae,{scrollerProps:jr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:F,onLoad:D=>c(D.currentTarget),"data-testid":"markdown-explorer-image"})})]})},Ua=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"}},Pr=d.createContext(null),Qe=d.createContext(void 0),Ir=d.createContext(null),Je=()=>{const e=d.use(Pr);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Ha=()=>{const e=d.use(Ir);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},et=(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}),Fr=(e,t,n,r)=>t.view==="tree"?H.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides,maximized:t.maximized()}):et(e,t,n,r),za=({children:e})=>{const{config:t}=I(),n=Je(),r=Xe(),o=r.kind==="location"?r.location.source:void 0,s=te.useHref(et(t,n.navigation,o,n.currentPath));return l.jsx(Qe,{value:o,children:l.jsx(Ir,{value:s,children:e})})},Va='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Za=e=>{const t=e instanceof Element?e.closest(Va):null;return t===null?null:t.getAttribute("data-doc-path")},Ne=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Wa=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:f})=>{const m=te.useHref(e),u=c=>{if(Ne(c)){if(c.preventDefault(),t===i.currentPath&&n!==""){i.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:u,children:f})},Ga=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=I(),i=Je(),f=d.use(Qe),m=be(),u=va(e),{navigation:c}=i,h=`${et(a,c,f,t)}${u}`,w=n===!1?"false":void 0;if(c.kind==="page"){const E=b=>{if(!Ne(b))return;const k=`${Fr(a,c,f,t)}${u}`;k!==h&&(b.preventDefault(),m(k,"follow-link"))};return l.jsx(pr,{...o,to:h,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":w,onClick:E,children:s})}return l.jsx(Wa,{to:h,docPath:t,fragment:u,exists:w,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:i,children:s})},Ka=({className:e,attributes:t,children:n})=>{const{labels:r}=I();return l.jsxs("a",{...t,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,"data-link-kind":"doc","data-doc-exists":"false",children:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},Xa=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=I(),a=d.use(Qe),i=te.useHref(`${et(s,r.navigation,a,r.currentPath)}${e}`),f=m=>{Ne(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:f,children:o})},Ya=({href:e,className:t,attributes:n,children:r})=>{const o=Je();if(o.navigation.kind==="page"){const s=a=>{if(!Ne(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(Xa,{href:e,className:t,attributes:n,scope:o,children:r})},Qa=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!P.isAcceptableDocumentPath(n)?l.jsx(Ka,{className:o,attributes:s,children:a}):l.jsx(Ga,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(Ya,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),Ja=()=>{const{config:e}=I(),t=Je(),n=d.use(Qe),r=be();return d.useCallback((o,s)=>{if(!Ne(s))return!0;s.preventDefault();const a=Ar(o.id),{navigation:i}=t;return i.kind==="panel"||Ft(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Fr(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},el=()=>{const e=Ha();return d.useCallback(t=>`${e}${Ar(t.id)}`,[e])};function tl({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 nl=S.forwardRef(tl);function rl({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 ol=S.forwardRef(rl);function sl({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 al=S.forwardRef(sl),ll=Object.freeze({className:"aqmx-document-stage"}),il=()=>()=>{},cl=()=>navigator.pdfViewerEnabled!==!1,dl=()=>null,ul=({document:e})=>{const{labels:t}=I(),n=d.useSyncExternalStore(il,cl,dl);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})]})]})},fl=e=>{switch(e){case"video":return l.jsx(ol,{});case"audio":return l.jsx(al,{});case"pdf":return l.jsx(nl,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},ml=({document:e})=>{const{labels:t}=I();switch(e.mediaType){case"video":return l.jsx("video",{className:"aqmx-document-video",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"audio":return l.jsx("audio",{className:"aqmx-document-audio",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"pdf":return l.jsx(ul,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},hl=({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:fl(e.mediaType)}),l.jsx(Ae,{scrollerProps:ll,children:l.jsx(ml,{document:e})})]}),$t=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}},pl=e=>{const{documents:t}=I(),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:$t(s.document)},$r=e=>{const{config:t}=I(),n=be(),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 gl({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 wl=S.forwardRef(gl),vl=100,El=32767,Ue=Object.freeze({maxCells:Yt.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:Yt.SPREADSHEET_MAX_OPERATION_CELLS/vl,maxCellLength:El}),Br=44,qr=10,Ur=13,Ie='"',pn=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Br||r===qr||r===Ur)return n;n+=1}return n};function*xl(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(Ie,r)){o="";let a=r+1;for(;;){const f=e.indexOf(Ie,a);if(f<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,f),e.startsWith(Ie,f+1)){o+=Ie,a=f+2;continue}r=f+1;break}const i=pn(e,r);o+=e.slice(r,i),r=i}else{const a=pn(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===Ur&&e.charCodeAt(r)===qr&&(r+=1),r>=e.length))return}}const bl=(e,t,n)=>t==="csv"?xl(e,n):n==="whole"?wt.iterateTsvRows(e):wt.iterateTsvPrefixRows(e),Sl=(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)},Hr=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const i of e){const f=i.length>t.maxColumns?i.slice(0,t.maxColumns):i,m=Math.max(r,f.length);if((n.length+1)*m>t.maxCells){s=!0;break}const u=f.some(c=>c.length>t.maxCellLength)?f.map(c=>Sl(c,t.maxCellLength)):f;u!==i&&(o=!0),n.push(u),r=m}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},lt=(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=Hr(bl(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(i=>i.some(f=>f!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},yl=Object.freeze({maxPartBytes:64*1024*1024,maxSheets:256}),zr=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 f=-1;for(const c of a.keys())c>f&&(f=c);const m=Array(Math.min(f,e.maxColumns)+1).fill("");for(const[c,h]of a)c<=e.maxColumns&&(m[c]=h);const u=Math.min(m.length,e.maxColumns);if(n===0&&(s+1)*u>e.maxCells){const c=Math.floor(e.maxCells/u);for(;t.length<c;)t.push([]);o(m);return}for(;t.length<s&&!r;)o([]);for(let c=0;c<i&&!r;c+=1)o(c===0?m:[...m])},full:()=>r,table:()=>Hr(t,e)}},kl=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())},Rl=({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:kl,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))}),Vr=64*1024,Tl=e=>{let t=new Uint8Array(Math.min(e,Vr)),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}},Cl=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},Ll=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=Tl(o);let f=Vr;try{for(;;){const{done:m,value:u}=await a.read();if(m)return lt(i.bytes(),!0,n,r,s);const c=o-i.length();if(i.append(u.byteLength>c?u.subarray(0,c):u),i.length()===o){const w=u.byteLength<=c&&await Cl(a);return lt(i.bytes(),w,n,r,s)}if(i.length()<f)continue;f=i.length()*2;const h=lt(i.bytes(),!1,n,r,s);if(h.kind==="unreadable"&&h.code!=="long-row"||h.kind==="table"&&h.table.full)return h}}finally{a.cancel().catch(()=>{})}},Zr=async(e,t,n,r)=>{const o=await e.asset(P.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await Ll(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},Bt=(e,t,n)=>{const{documents:r,labels:o}=I(),s=sa(),a=d.useCallback(()=>r.answerStampOf(e),[r,e]),i=d.useSyncExternalStore(r.subscribe,a,a),[f,m]=d.useState(0),u=d.useMemo(()=>({read:n,stamp:i,attempt:f}),[n,i,f]),[c,h]=d.useState({settled:null,shown:null,failure:null}),w=d.useRef(null),E=d.useEffectEvent((L,R)=>{if(w.current?.settle(R.stamp,L.kind==="failure"?L.failure:null),L.kind==="read"){h({settled:R,shown:L.value,failure:null});return}if(c.shown!==null){h({settled:R,shown:c.shown,failure:null});return}h({settled:R,shown:null,failure:L.failure}),s.announceFailure(o.documentFailed(t,re(o,L.failure.reason)))});d.useEffect(()=>{const L=s.readPart();return w.current=L,()=>{w.current=null,L.release()}},[s]),d.useEffect(()=>{const L=new AbortController;return u.read(L.signal).then(R=>{R!==null&&!L.signal.aborted&&E(R,u)}),()=>L.abort()},[u]);const b=c.settled!==u&&(c.shown!==null||c.failure!==null);d.useLayoutEffect(()=>b?s.holdBusy():void 0,[b,s]);const k=d.useCallback(()=>m(L=>L+1),[]);return{shown:c.shown,failure:c.failure,retry:k}},Wr=(e,t)=>{const n={};for(const r of Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[Tt(r)];o!==ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},Ol=(e,t)=>Object.fromEntries(Object.entries(Wr(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),Al=(e,t)=>({...Ol(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,mermaidFullscreen:e.viewerMermaidFullscreen,mermaidExitFullscreen:e.viewerMermaidExitFullscreen,mermaidFullscreenDialog:e.viewerMermaidFullscreenDialog,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,svgImageFullscreen:e.viewerSvgImageFullscreen,svgImageExitFullscreen:e.viewerSvgImageExitFullscreen,svgImageFullscreenDialog:e.viewerSvgImageFullscreenDialog,codeBlockCopy:e.viewerCodeBlockCopy,codeBlockCopied:e.viewerCodeBlockCopied,codeBlockCopyFailed:e.viewerCodeBlockCopyFailed,displayMathCopy:e.viewerDisplayMathCopy,displayMathCopied:e.viewerDisplayMathCopied,displayMathCopyFailed:e.viewerDisplayMathCopyFailed}),Gr=(e,t,n)=>t!==void 0?t:n!==void 0?n:e.defaultDocumentStyle,Kr=(e,t)=>e!==void 0?e:t!==void 0?t:Io.DEFAULT_CONTENT_ALIGN;class Y extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const Ml=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),Nl=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,Dl=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,jl=/^[^\s/>]+/u,ge=e=>{throw new Y("not-workbook",`the XML ${e}`)},gn=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):ge(`refers to the code point ${e}`),Xr=e=>e.includes("&")?e.replace(Nl,(t,n)=>n.startsWith("#x")?gn(Number.parseInt(n.slice(2),16)):n.startsWith("#")?gn(Number.parseInt(n.slice(1),10)):Ml.get(n)??ge(`names the undeclared entity ${t}`)):e,yt=e=>e.slice(e.indexOf(":")+1),_l=(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},Pl=e=>{const t=new Map;for(const n of e.matchAll(Dl))t.set(yt(n[1]??""),Xr(n[2]??n[3]??""));return t},Yr=(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?.(Xr(n.slice(o,s))),o=s),n.startsWith("<!--",s)){const m=n.indexOf("-->",s+4);if(m===-1)break;o=m+3;continue}if(n.startsWith("<![CDATA[",s)){const m=n.indexOf("]]>",s+9);if(m===-1)break;e.text?.(n.slice(s+9,m)),o=m+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 m=n.indexOf("?>",s+2);if(m===-1)break;o=m+2;continue}const i=_l(n,s+1);if(i===-1)break;const f=n.slice(s+1,i);if(f.startsWith("/"))e.end?.(yt(f.slice(1).trim()));else{const m=f.endsWith("/"),u=m?f.slice(0,-1):f,c=jl.exec(u)?.[0]??ge("has a tag without a name"),h=yt(c);e.start?.(h,Pl(u.slice(c.length)),m),m&&e.end?.(h)}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")}}},De=async(e,t,n)=>{const r=Yr(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(()=>{})}},Il=101010256,Fl=33639248,$l=67324752,Qr=22,Bl=65535,wn=46,vn=30,ql=1,En=0,Ul=8,Hl=65535,Se=4294967295,zl=new TextDecoder("utf-8"),ee=e=>{throw new Y("not-workbook",`the ZIP package ${e}`)},Vl=e=>{const t=e.byteLength-Qr,n=Math.max(0,t-Bl);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===Il)return r;return ee("has no end of central directory record")},Zl=e=>{if(e.byteLength<Qr)return ee("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Vl(t),r=t.getUint16(n+4,!0),o=t.getUint16(n+6,!0),s=t.getUint16(n+10,!0),a=t.getUint32(n+12,!0),i=t.getUint32(n+16,!0);if(r!==0||o!==0)return ee("spans several disks");if(s===Hl||a===Se||i===Se)return ee("is a ZIP64 package");if(i+a>n)return ee("has a central directory past its end record");const f=new Map;let m=i;for(let u=0;u<s;u+=1){if(m+wn>n||t.getUint32(m,!0)!==Fl)return ee("has a malformed central directory");const c=t.getUint16(m+8,!0),h=t.getUint16(m+10,!0),w=t.getUint32(m+20,!0),E=t.getUint32(m+24,!0),b=t.getUint16(m+28,!0),k=t.getUint16(m+30,!0),L=t.getUint16(m+32,!0),R=t.getUint32(m+42,!0),F=m+wn;if(F+b>n)return ee("has a name past its central directory");const D=zl.decode(e.subarray(F,F+b));if(w===Se||E===Se||R===Se)return ee("has a ZIP64 entry");if(!D.endsWith("/")){if(f.has(D))return ee(`names ${D} twice`);f.set(D,{name:D,encrypted:(c&ql)!==0,method:h,compressedSize:w,uncompressedSize:E,localHeaderOffset:R})}m=F+b+k+L}return{bytes:e,entries:f}},Wl=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+vn>n.byteLength||r.getUint32(o,!0)!==$l)return ee(`has no local header for ${t.name}`);const s=o+vn+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()}}),Gl=e=>Jr(e).pipeThrough(new DecompressionStream("deflate-raw")),Kl=(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)}})},Oe=(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!==En&&r.method!==Ul)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}=Wl(e,r),a=e.bytes.subarray(o,s);return(r.method===En?Jr(a):Gl(a)).pipeThrough(Kl(t,n))},Ke=async(e,t,n)=>{const r=Oe(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:f}=await s.read();if(i)break;a+=o.decode(f,{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()}},xn="content.xml",Xl="META-INF/manifest.xml",eo=e=>{throw new Y("not-workbook",`the spreadsheet ${e}`)},bn=(e,t)=>Oe(e,xn,t.maxPartBytes)??eo(`has no ${xn}`),Yl=async(e,t)=>{const n=Oe(e,Xl,t.maxPartBytes);if(n===null)return!1;let r=!1;return await De(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},Ql=async e=>{const t=[],n=new Set;let r=null,o=0;return await De(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}},it=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},Jl=async(e,t,n)=>{const r=zr(n);let o=0,s=0,a=!1,i=!1,f=0,m=1,u=new Map,c=0,h=null;return await De(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"?(m=it(E.get("number-rows-repeated")),u=new Map,c=0):w==="table-cell"||w==="covered-table-cell"?h={repeat:it(E.get("number-columns-repeated")),covered:w==="covered-table-cell",parts:[],paragraphs:0,paragraphDepth:0,annotationDepth:0}:h!==null&&h.annotationDepth===0&&(w==="annotation"&&!b?h.annotationDepth+=1:w==="p"||w==="h"?(h.paragraphs>0&&h.parts.push(`
12
- `),h.paragraphs+=1,b||(h.paragraphDepth+=1)):h.paragraphDepth>0&&(w==="s"?h.parts.push(" ".repeat(it(E.get("c")))):w==="tab"?h.parts.push(" "):w==="line-break"&&h.parts.push(`
13
- `))))},end:w=>{if(w==="table"){s=Math.max(0,s-1),s===0&&a&&(a=!1,i=!0);return}if(h!==null&&h.annotationDepth>0){w==="annotation"&&(h.annotationDepth-=1);return}if(!(!a||s!==1))if((w==="table-cell"||w==="covered-table-cell")&&h!==null){const E=h.covered?"":h.parts.join("");if(E!==""){const b=Math.min(c+h.repeat,n.maxColumns+1);for(let k=c;k<b;k+=1)u.set(k,E)}c+=h.repeat,h=null}else w==="table-row"?(r.addRow(f,u,m),f+=m):(w==="p"||w==="h")&&h!==null&&(h.paragraphDepth=Math.max(0,h.paragraphDepth-1))},text:w=>{h!==null&&h.annotationDepth===0&&h.paragraphDepth>0&&h.parts.push(w)}},()=>i||r.full()),r.table()},ei=async(e,t)=>{if(await Yl(e,t))throw new Y("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await Ql(bn(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 f=>Jl(bn(e,t),i,f)})}),o.length===0&&eo("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},pe=Object.freeze({kind:"general"}),ti=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,"@"]]),ni=/^\[(h+|m+|s+)\]$/iu,ri=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);ni.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},oi=e=>{const{text:t,elapsed:n}=ri(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="",f=""]=s.slice(0,s.length-a).split("."),m=(f.match(/[0#?]/gu)??[]).length;return t.includes("%")?{kind:"percent",decimals:m}:{kind:"fixed",decimals:m,grouping:i.includes(","),scale:1e3**a}},si=(e,t)=>{const n=t.get(e)??ti.get(e);return n===void 0?pe:oi(n)},qt=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("+","")}`}`},Sn=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return qt(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}`}`},ai=864e5,yn=86400,li=2958465,we=(e,t)=>String(e).padStart(t,"0"),ii=(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*ai);return`${we(r.getUTCFullYear(),4)}-${we(r.getUTCMonth()+1,2)}-${we(r.getUTCDate(),2)}`},ci=(e,t,n)=>{if(e<0||e>=li+1)return qt(e);let r=Math.floor(e),o=Math.round((e-r)*yn);o===yn&&(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 f=ii(r,n);return t.time?`${f} ${i}`:f},di=(e,t,n)=>{switch(t.kind){case"general":return qt(e);case"date-time":return ci(e,t,n);case"percent":return`${Sn(e*100,t.decimals,!1)}%`;case"fixed":return Sn(e/t.scale,t.decimals,t.grouping)}},to="_rels/.rels",oe=e=>{throw new Y("not-workbook",`the workbook ${e}`)},Ut=(e,t)=>{const n=Yr(t,()=>!1);n.write(e),n.finish()},ui=(e,t)=>{try{return decodeURIComponent(e)}catch{return oe(`points to a malformed part name (${t})`)}},fi=(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(ui(o,t)));return r.join("/")},mi=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},kn=async(e,t,n)=>{const r=await Ke(e,t===""?to:mi(t),n.maxPartBytes),o=new Map;return r===null||Ut(r,{start:(s,a)=>{if(s!=="Relationship")return;const i=a.get("Id"),f=a.get("Type"),m=a.get("Target");i===void 0||f===void 0||m===void 0||a.get("TargetMode")==="External"||o.set(i,{type:f,target:fi(t,m)})}}),o},ct=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},hi=e=>{const t=[];let n=!1;return Ut(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}},pi=async e=>{const t=[];let n=null,r=!1,o=0;return await De(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},gi=e=>{const t=new Map,n=[];let r=!1;return Ut(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=>si(o,t))},wi=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,vi=e=>{const t=wi.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}`},Ei=/^([A-Za-z]{1,3})(\d+)$/u,xi=e=>{const t=Ei.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},bi=(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 vi(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?di(a,n[e.style]??pe,r):s}}},Si=async(e,t,n,r,o)=>{const s=zr(t);let a=-1,i=new Map,f=0,m=null;return await De(e,{start:(u,c,h)=>{if(u==="row"){const w=Number(c.get("r"));a=Number.isInteger(w)&&w>a+1?w-1:a+1,i=new Map,f=0}else if(u==="c"){const w=xi(c.get("r")??"")??f,E=Number(c.get("s")??"0");m={column:w,type:c.get("t")??"n",style:Number.isInteger(E)?E:0,value:[],inline:[],inValue:!1,inInlineText:!1,phoneticDepth:0}}else m!==null&&(u==="v"?m.inValue=!h:u==="rPh"&&!h?m.phoneticDepth+=1:u==="t"&&m.type==="inlineStr"&&m.phoneticDepth===0&&(m.inInlineText=!h))},end:u=>{if(u==="c"&&m!==null){const c=bi(m,n,r,o);c!==""&&i.set(m.column,c),f=m.column+1,m=null}else u==="row"?s.addRow(a,i,1):m!==null&&(u==="v"?m.inValue=!1:u==="rPh"?m.phoneticDepth=Math.max(0,m.phoneticDepth-1):u==="t"&&(m.inInlineText=!1))},text:u=>{m!==null&&(m.inValue?m.value.push(u):m.inInlineText&&m.inline.push(u))}},s.full),s.table()},yi=async(e,t)=>{const n=ct(await kn(e,"",t),"officeDocument")??oe("has no officeDocument relationship"),r=await Ke(e,n,t.maxPartBytes)??oe(`has no part ${n}`),{sheets:o,date1904:s}=hi(r),a=await kn(e,n,t),i=ct(a,"sharedStrings"),f=i===null?null:Oe(e,i,t.maxPartBytes),m=f===null?[]:await pi(f),u=ct(a,"styles"),c=u===null?null:await Ke(e,u,t.maxPartBytes),h=c===null?[]:gi(c),w=[];let E=0;for(const b of o){const k=a.get(b.relationship)??oe(`lists the sheet ${b.name} without its relationship`);if(b.state!=="visible"||!k.type.endsWith("/worksheet")){E+=1;continue}e.entries.has(k.target)||oe(`has no part ${k.target} for the sheet ${b.name}`),w.push({name:b.name,read:async L=>{const R=Oe(e,k.target,t.maxPartBytes)??oe(`has no part ${k.target}`);return Si(R,L,m,h,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)}},ki=Object.freeze([80,75,3,4]),Ri=Object.freeze([208,207,17,224,161,177,26,225]),dt=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),Ti=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),Ci="mimetype",no=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),ro=e=>no(e,ki),oo=e=>no(e,Ri),Li=e=>{const t=e.byteLength-dt.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===dt[0]&&dt.every((r,o)=>e[n+o]===r))return!0;return!1},Oi=async(e,t)=>{if(oo(e))throw Li(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(!ro(e))throw new Y("not-workbook","the bytes are no ZIP package");const n=Zl(e),r=await Ke(n,Ci,t.maxPartBytes);if(r!==null&&Ti.has(r.trim()))return ei(n,t);if(n.entries.has(to))return yi(n,t);throw new Y("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},Ai=async(e,t)=>{const n=e.getReader(),r=[];let o=0;try{for(;;){const{done:i,value:f}=await n.read();if(i)break;if(o+=f.byteLength,o>t)return null;r.push(f)}}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},so=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"}}},Mi=async(e,t,n,r,o)=>{const s=await e.asset(P.explorerWorkbookHref(t),o);if(s.status==="cancelled")return null;if(s.status==="error")return{kind:"failure",failure:s.failure};let a;try{a=await Ai(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(!(ro(a)||oo(a)))return{kind:"not-package"};try{const i=await Oi(a,n.limits),f=r===null?-1:i.sheets.findIndex(h=>h.name===r),m=Math.max(f,0),u=i.sheets[m];if(u===void 0)return{kind:"refused",refusal:"not-workbook"};const c=await so(u,n.budget);return o.aborted?null:{kind:"workbook",workbook:i,selected:m,sheet:c}}catch(i){return i instanceof Y?{kind:"refused",refusal:i.refusal}:o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}},Ni=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),Di=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},Rn=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},ut=e=>e.every(t=>t.every(n=>n==="")),ao=({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(wl,{})}),l.jsx(Ae,{scrollerProps:Ni,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),lo=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=I(),s=d.use(de),a=d.useMemo(()=>({...Wr(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=d.useMemo(()=>wt.serializeTsv(e),[e]),f=Pt();return l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":o,children:l.jsx(Ee.SpreadsheetBlock,{tsv:i,layout:s==="fill"?"fill":"inline",locale:r,labels:a,tapScrollCircle:kr(f),scrollBarControls:Nt(f)})})},ke=({note:e,testId:t,code:n,download:r})=>{const{labels:o}=I();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})]})})},io=({reading:e,name:t,url:n})=>{const{labels:r}=I();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(lo,{rows:e.rows,title:t})]});case"empty":return l.jsx(ke,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(ke,{note:Di(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},ji=({path:e,document:t})=>t.format==="workbook"?l.jsx(Pi,{path:e,document:t}):l.jsx(_i,{path:e,document:t,format:t.format}),_i=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=I(),{name:a,url:i}=t,f=d.useCallback(async h=>{const w=await Zr(o,i,{format:n,legacyEncoding:r.legacyTextEncoding,maxBytes:r.spreadsheets.maxBytes,budget:Ue},h);return w===null||w.kind==="failure"?w:{kind:"read",value:w}},[o,i,n,r.legacyTextEncoding,r.spreadsheets.maxBytes]),{shown:m,failure:u,retry:c}=Bt(e,a,f);return l.jsxs(ao,{name:a,url:i,openUrl:P.explorerPlainTextHref(i),state:m===null?u===null?"loading":"failure":m.kind,children:[m===null&&u===null?l.jsx(ue,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,m===null&&u!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:u,alert:!1,onRetry:c,testId:"markdown-explorer-spreadsheet-failure"})}):null,m===null?null:l.jsx(io,{reading:m,name:a,url:i})]})},Pi=({path:e,document:t})=>{const{config:n,data:r,labels:o}=I(),{name:s,url:a,firstSheetText:i}=t,f=d.useId(),m=d.useRef(null),u=d.useCallback(async x=>{const T=await Mi(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:yl,budget:Ue},m.current,x);if(T===null||T.kind==="failure")return T;if(T.kind==="workbook")return{kind:"read",value:T};if(i!==null){const M=await Zr(r,a,{format:i,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:Ue},x);return M===null||M.kind==="failure"?M:{kind:"read",value:{kind:"first-sheet",reading:M}}}return{kind:"read",value:{kind:"refused",refusal:T.kind==="not-package"?"not-workbook":T.refusal}}},[r,a,i,n.legacyTextEncoding,n.spreadsheets.maxBytes,n.spreadsheets.maxWorkbookBytes]),{shown:c,failure:h,retry:w}=Bt(e,s,u),[E,b]=d.useState(null),k=d.useRef(new WeakMap),L=c?.kind==="workbook"?c:null,R=L===null?null:E!==null&&E.workbook===L.workbook?E:{workbook:L.workbook,index:L.selected,reading:L.sheet},F=x=>{if(L===null)return;const T=L.workbook.sheets[x];if(T===void 0)return;m.current=T.name;let M=k.current.get(L.workbook);M===void 0&&(M=new Map([[L.selected,L.sheet]]),k.current.set(L.workbook,M));const N=M.get(x),_={workbook:L.workbook,index:x,reading:N??null};if(b(_),N!==void 0)return;const U=M;so(T,Ue).then(Z=>{U.set(x,Z),b(v=>v===_?{..._,reading:Z}:v)})},D=R===null?null:R.reading===null?"loading":R.reading.kind==="refused"?"unreadable":ut(R.reading.table.rows)?"empty":"table",p=c===null?h===null?"loading":"failure":c.kind==="first-sheet"?c.reading.kind:c.kind==="refused"?"unreadable":D??"loading",g=i===null?a:P.explorerPlainTextHref(a),C=x=>`${f}-sheet-${x}`,A=`${f}-panel`,$=R===null?null:L?.workbook.sheets[R.index]?.name??null,B=L!==null&&L.workbook.sheets.length>1;return l.jsxs(ao,{name:s,url:a,openUrl:g,state:p,children:[c===null&&h===null?l.jsx(ue,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,c===null&&h!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:h,alert:!1,onRetry:w,testId:"markdown-explorer-spreadsheet-failure"})}):null,c?.kind==="refused"?l.jsx(ke,{note:Rn(o,c.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:c.refusal,download:{url:a,name:s}}):null,c?.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(io,{reading:c.reading,name:s,url:a})]}):null,L===null||R===null||$===null?null:l.jsxs(l.Fragment,{children:[L.workbook.unshownSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unshown-sheets",children:o.spreadsheetUnshownSheets(L.workbook.unshownSheets)}):null,L.workbook.unlistedSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unlisted-sheets",children:o.spreadsheetUnlistedSheets(L.workbook.sheets.length)}):null,B?l.jsx(Rl,{names:L.workbook.sheets.map(x=>x.name),selected:R.index,onSelect:F,label:o.spreadsheetSheets(s),tabIdOf:C,panelId:A}):null,l.jsxs("div",{className:"aqmx-document-spreadsheet-sheet","data-testid":"markdown-explorer-spreadsheet-sheet","data-aqmx-sheet":R.index,...B?{role:"tabpanel",id:A,"aria-labelledby":C(R.index)}:{},children:[R.reading===null?l.jsx(ue,{label:o.spreadsheetSheetLoading,testId:"markdown-explorer-spreadsheet-sheet-skeleton"}):null,R.reading?.kind==="table"&&R.reading.table.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,R.reading?.kind==="refused"?l.jsx(ke,{note:Rn(o,R.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:R.reading.refusal,download:{url:a,name:s}}):null,R.reading?.kind==="table"&&ut(R.reading.table.rows)?l.jsx(ke,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,R.reading?.kind==="table"&&!ut(R.reading.table.rows)?l.jsx(lo,{rows:R.reading.table.rows,title:o.spreadsheetSheetName(s,$)},R.index):null]})]})]})},co=Object.freeze({kind:"empty"}),Ii=(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})},Re=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:i})=>{const f=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":f,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,i]})},Fi=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=I(),s=e.kind==="no-readme"?e.folder:null,a=e.kind==="failure"?e.folder:null,i=e.kind==="failure"?e.failure:null;switch(d.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(P.lastPathSegment(s)))},[t,s,o,r]),d.useEffect(()=>{a!==null&&i!==null&&n(r.documentFailed(P.lastPathSegment(a),re(r,i.reason)))},[a,i,n,r]),e.kind){case"empty":return l.jsx(Re,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.documentEmpty})})});case"loading":return l.jsx(Ht,{label:r.documentRegion});case"no-readme":return l.jsx(Re,{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(P.lastPathSegment(e.folder))})})});case"failure":return l.jsx(Re,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(It,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},Ht=({label:e})=>{const{labels:t}=I();return l.jsx(Re,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(ue,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},Tn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),$i=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=I(),a=d.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=Ja(),f=el(),m=d.useMemo(()=>o===void 0?void 0:p=>o(e,p),[o,e]),u=d.useRef(null),{editable:c,doubleClick:h,region:w,paneScroll:E,stale:b}=r;d.useLayoutEffect(()=>{if(c)return s.bindView(e,{anchor:()=>{const p=u.current,g=w(),C=p===null?null:p.querySelector(Ye);return p===null||g===null||C===null?null:dr(p,E.scrollerOf(g,C))}})},[s,e,c,w,E]);const k=p=>{const g=u.current,{target:C}=p;!h||g===null||!(C instanceof Element)||!ir(C)||(p.stopPropagation(),s.start(e,cr(C,g,g.ownerDocument.getSelection())))},L=d.useRef(null),R=d.useRef(b);d.useLayoutEffect(()=>{R.current=b});const F=d.useEffectEvent(p=>{const g=u.current,C=w(),A=g===null?null:mr(g,p.line);if(C===null||A===null)return!1;const $=E.scrollerOf(C,A);return $.scrollTop+=hr(A,p.line)-p.clientTop,!0}),D=d.useEffectEvent(p=>{const g=w();if(g===null)return;const C=()=>{for(const $ of Tn)g.removeEventListener($,A,!0);L.current?.release===C&&(L.current=null)},A=()=>C();for(const $ of Tn)g.addEventListener($,A,{capture:!0,passive:!0});L.current={point:p,release:C}});return d.useLayoutEffect(()=>{const p=s.takeReturn(e);if(p!==null)return queueMicrotask(()=>{F(p)&&R.current&&D(p)}),()=>L.current?.release()},[s,e]),d.useLayoutEffect(()=>{const p=L.current;p===null||b||(p.release(),F(p.point))},[t,b]),l.jsx("div",{ref:u,className:"aqmx-document-viewer",onDoubleClick:k,children:l.jsx(Ee.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:f,onMathDiagnostics:m,parseResult:a,content:null})})},uo=({document:e,viewer:t})=>{const{labels:n}=I();return l.jsxs(l.Fragment,{children:[l.jsx(Me,{name:e.name,openUrl:P.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(hs,{}),children:e.truncated?null:l.jsx(oa,{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})})]})},ft=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=I(),s=d.useCallback(async m=>{const u=await r.text(e,m);return"kind"in u?u.kind==="failure"?{kind:"failure",failure:u.failure}:{kind:"read",value:u}:null},[r,e]),{shown:a,failure:i,retry:f}=Bt(e,t,s);return a!==null?l.jsx(uo,{document:a,viewer:n}):i!==null?l.jsx(It,{failure:i,onRetry:f,testId:"markdown-explorer-markup-failure"}):l.jsx(ue,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},Bi=Object.freeze({reason:"failed"}),qi=e=>{const{labels:t}=I();return l.jsx(ws,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ce,{failure:Bi,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(gs,{...e})})})},Ui=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:i,region:f,paneScroll:m,stale:u}=s;if(n==="edit"&&a!==void 0)return l.jsx(qi,{path:e,name:t.name,session:a,layout:i,viewer:r,region:f,paneScroll:m});if(n==="markup")return l.jsx(ft,{path:e,name:t.name,viewer:r});const c=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx($i,{path:e,document:t,viewer:r,editing:{editable:c,doubleClick:c&&i==="fill",region:f,paneScroll:m,stale:u}})}case"text":return l.jsx(uo,{document:t,viewer:r});case"image":return n==="markup"&&$t(t)==="svg"?l.jsx(ft,{path:e,name:t.name,viewer:r}):l.jsx(qa,{document:t});case"media":return l.jsx(hl,{document:t});case"spreadsheet":return n==="markup"?l.jsx(ft,{path:e,name:t.name,viewer:r}):l.jsx(ji,{path:e,document:t});case"file":return l.jsx(ma,{document:t});case"failure":return l.jsx(It,{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)}`)}}},Hi='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',zi=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:Nr(e,n),r===void 0?null:Mr(e,r.id),e.querySelector(Ye),e.querySelector(Hi)];for(const s of o)if(s instanceof HTMLElement&&Mt(s))return s;return null},Cn=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Mt(t)},Vi=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=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},f=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},m=h=>{h.relatedTarget===null&&s&&(t.current=!1)},u=()=>{const{activeElement:h,body:w}=r;h!==null&&h!==w&&(t.current=n.contains(h))},c=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",i,!0),o.addEventListener("mousedown",i,!0),o.addEventListener("focusin",f,!0),o.addEventListener("blur",u),o.addEventListener("focus",c),n.addEventListener("focusout",m),()=>{clearTimeout(a),o.removeEventListener("pointerdown",i,!0),o.removeEventListener("mousedown",i,!0),o.removeEventListener("focusin",f,!0),o.removeEventListener("blur",u),o.removeEventListener("focus",c),n.removeEventListener("focusout",m)}},[e]),t},Zi=Object.freeze({count:0,recovered:!1}),Wi=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:f,paneScroll:m,announces:u,announceFailure:c,onDocumentShown:h})=>{const{labels:w,announcer:E,documents:b}=I(),{document:k}=t,L=d.useRef(null),R=d.useRef(null),F=d.useRef(null),D=d.useRef(0),p=Vi(L),g=d.useRef({path:e,document:k}),C=d.useRef(null),A=d.useCallback(z=>{const V=L.current,X=ln(V,z,m);V!==null&&X!==null&&Cn(V,X,p.current)},[m,p]),$=d.useCallback((z,V)=>{const X=D.current;setTimeout(()=>{!V.defaultPrevented&&D.current===X&&A(z)},0)},[A]),B=d.useCallback(z=>{setTimeout(()=>{z.defaultPrevented||A("#")},0)},[A]),x=d.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:A,followSameUrlJump:$,followEmptyFragment:B}),[i,e,A,$,B]),T=d.useCallback(()=>b.retry(e),[b,e]),M=gr(b,Za),N=rr(e),_=N!==void 0?"edit":n?"markup":"rendered",U=$t(k)===null?void 0:_,Z=d.useCallback(()=>L.current,[]),v=d.useMemo(()=>({session:N,layout:s,region:Z,paneScroll:m,stale:r}),[N,s,Z,m,r]),y=U==="edit"?!1:r,O=d.use(de),j=U==="edit"&&s==="fill"?"fill":O,[q,W]=d.useState(0),K=d.useRef(0),G=d.useRef(!1),[ne,Vt]=d.useState(Zi),[Zt,Lo]=d.useState(0),Wt=d.useRef(c),Gt=d.useRef(r);d.useLayoutEffect(()=>{Wt.current=c,Gt.current=r},[c,r]);const Oo=d.useMemo(()=>({announceFailure:z=>{Gt.current||Wt.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,G.current=!1;return}V=!0,Vt(je=>({count:je.count+1,recovered:X}))}},release:()=>{Q||(Q=!0,z.release(),K.current-=1,V||Lo(fe=>fe+1))}}},holdBusy:()=>{W(V=>V+1);let z=!0;return()=>{z&&(z=!1,W(V=>V-1))}}}),[b,e]),Kt=y||q>0,Ao=d.useEffectEvent((z,V)=>{const X=R.current;if(X!==null&&X.path===z&&X.snapshot===V)return;R.current={path:z,snapshot:V},b.noteShown(z,V);const Q=V.document;if(Q.kind==="failure"){G.current=!1,b.noteFailureShown(V)&&c(w.documentFailed(P.lastPathSegment(z),re(w,Q.failure.reason)));return}h?.(z,Q),!(!u||X!==null&&X.path===z&&X.snapshot.document.kind!=="failure")&&(G.current=K.current>0,G.current||E.announce(w.documentShown(Q.name)))});d.useEffect(()=>{Ao(e,t)},[e,t]);const Mo=d.useEffectEvent(()=>{f.kind==="panel"&&f.consume()}),Xt=d.useEffectEvent(z=>{const V=L.current;if(V===null||!p.current)return null;const{activeElement:X,body:Q}=V.ownerDocument;return X!==null&&X!==Q?null:zi(V,k,z)}),No=d.useEffectEvent(z=>{const V=G.current;G.current=!1,!r&&(z&&Xt(null),u&&(z||V)&&k.kind!=="failure"&&E.announce(w.documentShown(k.name)))});d.useEffect(()=>{ne.count>0&&No(ne.recovered)},[ne]);const Do=d.useEffectEvent(()=>{K.current>0||!G.current||(G.current=!1,u&&!r&&k.kind!=="failure"&&E.announce(w.documentShown(k.name)))});d.useEffect(()=>{Zt>0&&Do()},[Zt]);const jo=d.useEffectEvent(z=>{const V=L.current;V!==null&&Cn(V,z,p.current)}),_o=d.useEffectEvent(z=>m.reveal(z)),Po=d.useEffectEvent(z=>ln(L.current,z,m));return d.useEffect(()=>{if(r)return;const z=g.current.path!==e,V=z||g.current.document!==k;g.current={path:e,document:k};const X=C.current!==e;C.current=e;let Q=null;f.kind==="page"?F.current!==f.navigation&&(F.current=f.navigation,D.current+=1,Q=f.fragment):f.fragment!==null&&(Q=f.fragment,Mo());const fe=()=>{const me=Q===null?null:Po(Q);if(!V){me!==null&&jo(me);return}const je=Xt(f.fragment);z&&me===null&&je!==null&&_o(je)};X?queueMicrotask(fe):fe()},[f,e,k,r]),l.jsx(de,{value:j,children:l.jsx(Re,{kind:k.kind,view:U,label:a(e,k),stale:Kt,busy:Kt,frameRef:L,intent:M,children:l.jsx(Pr,{value:x,children:l.jsx(za,{children:l.jsx(Cr,{value:Oo,children:l.jsx(Ui,{path:e,document:k,view:_,viewer:o,onRetry:T,editing:v},e)})})})})})},zt=Object.freeze({kind:"skeleton"}),Gi=(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?zt:{kind:"document",path:n,snapshot:a,stale:!0}},Ki=(e,t)=>t.status==="deferred"?zt:{kind:"document",path:e,snapshot:t,stale:!1},Xi=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?Ki(t.path,d.use(t.promise)):t;return o.kind!=="document"?l.jsx(Ht,{label:r.regionLabel(e,null)}):l.jsx(Wi,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},fo=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:f,onDocumentShown:m})=>{const{config:u,labels:c,locale:h,theme:w,documents:E,data:b}=I(),k=Ee.useMarkdownToolbarState(),L=d.useRef(!1);d.useLayoutEffect(()=>{L.current=!0},[]);const[R,F]=d.useState(null),[D,p]=d.useState(n),g=d.useCallback(()=>e===null?void 0:E.peek(e),[E,e]),C=d.useSyncExternalStore(E.subscribe,g,g),A=d.useCallback(()=>R===null?void 0:E.peek(R),[E,R]),$=d.useSyncExternalStore(E.subscribe,A,A);d.useLayoutEffect(()=>e===null?void 0:E.open(e),[E,e]),d.useLayoutEffect(()=>R===null?void 0:E.retain(R),[E,R]);const B=e===null?zt:Gi(e,C,R,$,!L.current),x=e===null?null:B.kind==="document"&&!B.stale?B.path:R;x!==R&&F(x);const T=B.kind!=="document"||B.path===e;T&&n!==D&&p(n);const M=d.useMemo(()=>Al(c,h),[c,h]),N=d.useMemo(()=>({read:(j,q)=>Ua(b,j,q)}),[b]),_=d.useMemo(()=>[...u.iframeHosts],[u]),U=o.kind==="panel",Z=Pt(),v=d.useMemo(()=>({labels:M,spreadsheetLocale:h,spreadsheetTapScrollCircle:kr(Z),spreadsheetScrollBarControls:Nt(Z),emptyMessage:c.documentEmpty,theme:w,availableStyles:u.documentStyles,iFrameAllowedDomains:_,embeds:u.embeds,linkComponent:Qa,toolbar:k,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:U?void 0:vr,scrollBarInlineSize:U?void 0:Dt,scrollBarGutter:U?void 0:_t,imageSource:N}),[M,h,Z,c.documentEmpty,w,u.documentStyles,_,u.embeds,k,r,U,N]),y=d.useCallback((j,q)=>U?q===null||q.kind==="failure"?P.lastPathSegment(j):q.name:c.documentRegion,[U,c.documentRegion]),O=U?"content":"fill";return e===null?l.jsx(de,{value:O,children:l.jsx(Fi,{absence:t,announces:i,announceFailure:f})}):l.jsx(de,{value:O,children:l.jsx(d.Suspense,{fallback:l.jsx(Ht,{label:y(e,null)}),children:l.jsx(Xi,{requestedPath:e,content:B,markup:T?n:D,viewer:v,editLayout:r.editLayout,regionLabel:y,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:f,onDocumentShown:m})})})},Yi=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:i}=I(),f=Te(A=>A.style),m=Te(A=>A.align),u=be(),c=te.useLocation(),h=Xe(),{overrides:w,embed:E}=r,b=d.useCallback(A=>{if(h.kind!=="location")return;const $=Ii(s,h.location,A);$!==null&&u($,"browse")},[s,u,h]),k=d.useCallback(A=>{a.update({style:A}),b("style")},[a,b]),L=d.useCallback(A=>{a.update({align:A}),b("align")},[a,b]),R=Gr(s,w.style,f),F=Kr(w.align,m),D=d.useMemo(()=>({style:R,onStyleChange:k,align:F,onAlignChange:L,showToc:E.showToc!==!1,showStyle:E.showStyle!==!1,showAlign:E.showAlign!==!1,padding:E.padding,width:E.width,maxWidth:E.maxWidth,editLayout:"fill"}),[R,k,F,L,E]),p=r,g=d.useMemo(()=>({kind:"page",fragment:c.hash,navigation:c}),[c]),C=d.useCallback(A=>i.announce(A),[i]);return l.jsx(fo,{path:e,absence:t,markup:n,display:D,navigation:p,fragment:g,paneScroll:ka,announces:!0,announceFailure:C,onDocumentShown:o})},Qi=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=I(),i=Te(g=>g.style),f=Te(g=>g.align),[m,u]=d.useState(()=>Gr(s,void 0,i)),c=Kr(void 0,f),h=d.useCallback(g=>a.update({align:g}),[a]),{maximized:w,onDocumentLink:E,pendingHash:b,onHashConsumed:k,announceFailure:L,paneScroll:R}=r,F=d.useMemo(()=>({style:m,onStyleChange:u,align:c,onAlignChange:h,showToc:w,showStyle:w,showAlign:w,padding:void 0,width:void 0,maxWidth:void 0,editLayout:w?"fill":"content"}),[m,c,h,w]),D=d.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),p=d.useMemo(()=>({kind:"panel",fragment:b,consume:k}),[b,k]);return l.jsx(fo,{path:e,absence:t,markup:n,display:F,navigation:D,fragment:p,paneScroll:R,announces:!1,announceFailure:L,onDocumentShown:o})},mo=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(Yi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(Qi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function Ji({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 ho=S.forwardRef(Ji);function ec({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:"M3.22 3.22a.75.75 0 0 1 1.06 0l3.97 3.97V4.5a.75.75 0 0 1 1.5 0V9a.75.75 0 0 1-.75.75H4.5a.75.75 0 0 1 0-1.5h2.69L3.22 4.28a.75.75 0 0 1 0-1.06Zm17.56 0a.75.75 0 0 1 0 1.06l-3.97 3.97h2.69a.75.75 0 0 1 0 1.5H15a.75.75 0 0 1-.75-.75V4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0ZM3.75 15a.75.75 0 0 1 .75-.75H9a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-2.69l-3.97 3.97a.75.75 0 0 1-1.06-1.06l3.97-3.97H4.5a.75.75 0 0 1-.75-.75Zm10.5 0a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-2.69l3.97 3.97a.75.75 0 1 1-1.06 1.06l-3.97-3.97v2.69a.75.75 0 0 1-1.5 0V15Z",clipRule:"evenodd"}))}const tc=S.forwardRef(ec);function nc({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 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const po=S.forwardRef(nc);function rc({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 go=S.forwardRef(rc);function oc({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 sc=S.forwardRef(oc);function ac({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 lc=S.forwardRef(ac);function ic({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 cc=S.forwardRef(ic);function dc({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 uc=S.forwardRef(dc);function fc({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 wo=S.forwardRef(fc);function mc({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 hc=S.forwardRef(mc);function pc({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 gc=S.forwardRef(pc),vo=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=I(),[s,a]=d.useState(!1),i=()=>{o===void 0||s||(a(!0),o(e).then(f=>{f&&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})]})]})},wc="Control+E Meta+E",Eo=(e,t,n)=>n&&t?"split":e.view,kt=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},vc=e=>e==="split"?null:e,xo=e=>e==="preview"?"editor":"preview",bo=e=>/Mac|iPhone|iPad|iPod/u.test(e),So=(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)},Ln=(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)},Ec=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:f}=I(),m=d.useId(),[u,c]=d.useState(null),[h,w]=d.useState(0),[E,b]=d.useState(null),[k,L]=d.useState(null),R=d.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),F=d.useCallback(()=>{b(null),L(null)},[]),D=Qn({open:n,onOpen:F,onDismiss:r});d.useEffect(()=>{if(!n)return;const C=new AbortController;return c(null),o.revisions(e,C.signal).then(A=>{"kind"in A&&c(A)}),()=>C.abort()},[n,o,e,h]),d.useEffect(()=>{if(!n||E===null)return;const C=new AbortController;return L(null),o.revision(e,E,C.signal).then(A=>{"kind"in A&&L(A)}),()=>C.abort()},[n,o,e,E]);const p=()=>{k===null||k.kind!=="revision"||(s.replaceDraft(e,k.text),f.announce(a.historyRestored(t)),r())},g=u!==null&&u.kind==="revisions"?u.revisions.find(C=>C.id===E):void 0;return l.jsx("dialog",{...D,className:"aqmx-confirm aqmx-history","aria-labelledby":m,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:m,className:"aqmx-confirm-title",children:a.historyTitle(t)}),u===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):u.kind==="failure"?l.jsx(ce,{failure:u.failure,alert:!1,onRetry:()=>w(C=>C+1),testId:"markdown-explorer-history-failure"}):u.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:u.revisions.map(C=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":C.id===E,"data-testid":"markdown-explorer-history-entry",onClick:()=>b(C.id),children:[l.jsx("span",{children:Ln(C,R,a.historyEntry)}),C.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,C.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},C.id))}),E===null?null:k===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):k.kind==="failure"?l.jsx(ce,{failure:k.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):Ln(g,R,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:k.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":k===null||k.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:p,children:a.historyRestore})]})]})})},xc=e=>{const{documents:t}=I(),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:P.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},se=e=>{e.stopPropagation()},bc=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=I(),f=d.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[m,u]=d.useState(null),c=()=>{if(!f){a.start(e,a.viewAnchor(e));return}a.flush(e);const b=a.session(e);b?.dirty===!0?u(b.save.kind==="draft"?"draft":"unsaved"):a.close(e)},h=()=>{f||(ps(),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:f?i.closeEditor:w===null?E:w,"aria-label":w===null?void 0:w,"aria-pressed":f,"data-testid":"markdown-explorer-document-edit",onClick:c,onDoubleClick:se,onPointerEnter:h,onFocus:h,children:[l.jsx(hc,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(Jn,{open:m!==null,title:m==="draft"?i.draftDiscardTitle:i.unsavedTitle,body:m==="draft"?i.draftDiscardBody(t):i.unsavedBody(t),confirmLabel:i.unsavedDiscard,cancelLabel:i.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(null),a.close(e)},onCancel:()=>u(null)})]})},Sc=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=I(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:se,children:[l.jsx(sc,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},yc=({session:e})=>{const{labels:t}=I(),n=Zo(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})},kc=Object.freeze(["editor","split","preview"]),Rc=Object.freeze(["editor","preview"]),Tc=Object.freeze({editor:go,split:gc,preview:wo}),Cc=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=I(),f=sr(),m=Eo(r,f,o),u=o?kc:Rc,c=d.useId(),h=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=k=>{if(!So(k.nativeEvent,bo(navigator.platform)))return;Lt(k);const L=xo(m);kt(a,e,L,o),h.current.get(L)?.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:u.map(k=>{const L=Tc[k],{label:R,tooltip:F}=w[k],D=k==="preview"?E:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:p=>{p===null?h.current.delete(k):h.current.set(k,p)},type:"radio",name:c,value:k,checked:k===m,"aria-label":R,"aria-keyshortcuts":k==="split"?void 0:wc,title:F,"data-testid":`markdown-explorer-edit-view-${k}`,onChange:()=>kt(a,e,k,o),onDoubleClick:se,onPointerEnter:D,onFocus:D}),l.jsx(L,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:R})]},k)})})},Lc=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=I(),[i,f]=d.useState(!1);if(r.phase.kind!=="editing")return null;const m=r.save.kind==="saving",u=m||!r.dirty,c=()=>{s.flush(e);const w=s.session(e);w===void 0||!w.dirty||w.save.kind==="saving"||s.save(e)},h=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",...h(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:se,children:[l.jsx(lc,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(Cc,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...h(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>f(!0),onDoubleClick:se,children:[l.jsx(cc,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...h(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":u,"aria-busy":m,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:c,onDoubleClick:se,children:[l.jsx(uc,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Ec,{path:e,documentName:t,open:i,onClose:()=>f(!1)}):null]})},Oc=({path:e,session:t})=>{const{edits:n}=I();return t.save.kind!=="grant"?null:l.jsx(vo,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},yo=d.createContext(null),Ac=new Set,Mc=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=I(),a=d.useCallback(()=>r.peek(e),[r,e]),i=d.useCallback(()=>r.peekSeeded(e),[r,e]),f=d.useSyncExternalStore(r.subscribe,a,i),m=d.useCallback(()=>r.answerStampOf(e),[r,e]),u=d.useSyncExternalStore(r.subscribe,m,m),[c]=d.useState(()=>new Set),[h,w]=d.useState(Ac),[E,b]=d.useState(null);E!==null&&(E.path!==e||E.markup!==n)&&b(null);const k=d.useRef(null);d.useLayoutEffect(()=>(k.current=e,()=>{k.current=null}),[e]);const L=d.useRef(n);d.useLayoutEffect(()=>{L.current=n},[n]);const R=d.useCallback(()=>{const p=e,g=r.peek(p);c.has(p)||g?.status==="pending"||(c.add(p),w(new Set(c)),b(null),(async()=>{try{const C=await r.refresh(p);if(k.current!==p||C.status==="superseded")return;if(C.status==="failed"){b({path:p,failure:C.failure,stamp:r.answerStampOf(p),markup:L.current}),o.announce(s.documentRefreshFailed(re(s,C.failure.reason)));return}if(C.status==="shown"&&(t||C.failed))return;const A=le(r.peek(p));if(A===null||A.document.kind==="failure")return;o.announce(s.documentRefreshed(A.document.name))}finally{c.delete(p),w(new Set(c))}})())},[e,t,c,r,o,s]),F=h.has(e),D=E!==null&&E.path===e&&E.stamp===u&&E.markup===n?E.failure:null;return{refreshing:F,unavailable:F||f?.status==="pending",failure:D,refresh:R}},Nc=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},Dc=({maximize:e})=>{const{labels:t}=I(),n=e.maximized?t.documentRestore:t.documentMaximize;return l.jsx("button",{type:"button",className:"aqmx-icon-button",title:n,"aria-label":n,"data-testid":"markdown-explorer-document-maximize",onClick:e.toggle,onDoubleClick:se,children:e.maximized?l.jsx(tc,{"aria-hidden":"true"}):l.jsx(po,{"aria-hidden":"true"})})},ko=Object.freeze({kind:"page"}),Ro=({path:e,placement:t,markup:n,maximize:r})=>{const{labels:o}=I(),{refreshing:s,unavailable:a,failure:i,refresh:f}=Mc(e,t.kind==="page",n.shown),m=pl(e),u=xc(e),c=rr(e),h=t.kind==="panel"?o.refreshDocumentNamed(t.documentName):null,w=t.kind==="panel"?o.showMarkupNamed(t.documentName):null,E=t.kind==="panel",b=t.kind==="panel"?t.documentName:u.name,k=t.kind==="page"||t.maximized,L=d.use(yo),R=t.kind==="page"?L:null,F=R===null?null:R.onBar;d.useLayoutEffect(()=>{if(F!==null)return F(!0),()=>F(!1)},[F]);const D=R===null?void 0:R.lane?"merged":"covering";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","data-aqmx-sheet-bar":D,children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:l.jsx(yc,{session:c}),c===void 0?null:l.jsx(Lc,{path:e,documentName:b,iconOnly:E,session:c,previewAvailable:k}),c===void 0&&m!==null?l.jsxs("button",{type:"button",className:w===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:w===null?Nc(o,m):w,"aria-label":w===null?void 0:w,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:se,children:[l.jsx(go,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:o.showMarkupLabel}):null]}):null,c!==void 0||u.edit?.kind==="inline"||u.edit?.kind==="draft"?l.jsx(bc,{path:e,documentName:b,iconOnly:E,previewAvailable:k,draft:u.edit?.kind==="draft"}):u.edit?.kind==="external"?l.jsx(Sc,{href:u.edit.href,documentName:b,iconOnly:E}):null,c===void 0?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?o.refreshDocument:h,"aria-label":h===null?void 0:h,"aria-disabled":a,"aria-busy":s,"data-aqmx-busy":s?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:f,onDoubleClick:se,children:[l.jsx(ho,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:o.refreshDocumentLabel}):null]}):null,r===null?null:l.jsx(Dc,{maximize:r})]}),c!==void 0||i===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":i.reason,children:o.documentRefreshFailed(re(o,i.reason))}),c===void 0?null:l.jsx(Oc,{path:e,session:c})]})},jc=({location:e})=>{const t=e.doc,n=d.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=$r(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...He,children:[l.jsx(Ro,{path:t,placement:ko,markup:r,maximize:null}),l.jsx(mo,{path:t,absence:co,markup:e.markup,variant:n})]})},To=({holds:e,testId:t})=>{const{labels:n,announcer:r}=I(),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([]),_c=e=>{const t=new Set;let n=he,r=[],o=!1;const s=[],a=u=>{n=u;for(const c of[...t])c()},i=()=>s.at(-1)?.region,f=u=>{const c=i();u(),i()!==c&&n!==he&&a(he)},m=()=>{o=!1;const u=r.map(c=>"sentence"in c?c.sentence:c.list(c.items));r=[],a(Object.freeze(u))};return{announce:u=>{if(typeof u=="string")r.push({sentence:u});else{const c=r.find(h=>"list"in h&&h.list===u.list);c!==void 0&&"items"in c?c.items.push(u.item):r.push({list:u.list,items:[u.item]})}o||(o=!0,n!==he&&a(he),e.request(m))},subscribe:u=>(t.add(u),()=>{t.delete(u)}),claim:u=>{const c={region:u};return f(()=>s.push(c)),()=>f(()=>{const h=s.indexOf(c);h!==-1&&s.splice(h,1)})},shownIn:u=>i()===u?n:he}},ae=Object.freeze({status:"cancelled"}),On=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(P.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return P.failureOf(n,r)},Pc=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((u,c)=>globalThis.fetch(u,c)),o=(u,c)=>`${e}/${u}?${new URLSearchParams(c).toString()}`,s=u=>{u.status===401&&t(null);const c=u.headers.get(P.EXPLORER_SCOPE_HEADER);c!==null&&t(c)},a=async(u,c,h,w)=>{let E;try{E=await r(u,{credentials:"same-origin",...c,headers:{Accept:"application/json",...c.headers}})}catch{return w({reason:"failed"})}s(E);let b;try{b=await E.json()}catch{return w({reason:P.failureReasonOfStatus(E.status)})}let k;try{k=h(b)}catch{k=!1}if(k)return b;const L=On(b);return w(L!==null?L:{reason:E.status===200?"failed":P.failureReasonOfStatus(E.status)})},i={[P.EXPLORER_PROOF_HEADER]:P.EXPLORER_REFRESH_PROOF},f={[P.EXPLORER_PROOF_HEADER]:P.EXPLORER_EDIT_PROOF,"Content-Type":`${P.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},m=async(u,c,h)=>{const w=await a(u,c,h,E=>P.failureDocument(E.reason,E.code));return c.signal.aborted?ae:w};return{tree:u=>a(o("tree",{[P.EXPLORER_DATA_QUERY.source]:u}),{method:"GET"},P.isExplorerTreeResult,c=>({status:"error",failure:c})),children:async(u,c,h)=>{const w=await a(o("children",{[P.EXPLORER_DATA_QUERY.source]:u,[P.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:h},P.isExplorerChildrenResult,E=>({status:"error",failure:E}));return h.aborted?ae:w},ancestors:async(u,c,h)=>{const w=await a(o("ancestors",{[P.EXPLORER_DATA_QUERY.source]:u,[P.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:h},P.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return h.aborted?ae:w},reveal:async(u,c,h)=>{const w=await a(o("reveal",{[P.EXPLORER_DATA_QUERY.source]:u,[P.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:h},P.isExplorerRevealResult,E=>({status:"error",failure:E}));return h.aborted?ae:w},document:(u,{refresh:c})=>a(o("document",{[P.EXPLORER_DATA_QUERY.path]:u}),c?{method:"GET",headers:i}:{method:"GET"},P.isExplorerDocument,h=>P.failureDocument(h.reason,h.code)),text:async(u,c)=>{const h=await a(o("text",{[P.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:c},P.isExplorerTextAnswer,w=>P.failureDocument(w.reason,w.code));return c.aborted?ae:h},asset:async(u,c)=>{let h;try{h=await r(u,{method:"GET",credentials:"same-origin",signal:c})}catch{return c.aborted?ae:{status:"error",failure:{reason:"failed"}}}if(s(h),h.ok)return c.aborted?ae:{status:"ok",body:h.body===null?new ReadableStream({start:b=>b.close()}):h.body};let w=null;try{w=await h.json()}catch{}if(c.aborted)return ae;const E=On(w);return{status:"error",failure:E===null?{reason:P.failureReasonOfStatus(h.status)}:E}},edit:(u,c)=>m(o("edit",{[P.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:c},P.isExplorerEditAnswer),save:(u,c,h,w)=>m(o("save",{[P.EXPLORER_DATA_QUERY.path]:u,[P.EXPLORER_DATA_QUERY.base]:c}),{method:"POST",headers:f,body:h,signal:w},P.isExplorerSaveAnswer),preview:(u,c,h)=>m(o("preview",{[P.EXPLORER_DATA_QUERY.path]:u}),{method:"POST",headers:f,body:c,signal:h},P.isExplorerPreviewAnswer),revisions:(u,c)=>m(o("revisions",{[P.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:c},P.isExplorerRevisionsAnswer),revision:(u,c,h)=>m(o("revision",{[P.EXPLORER_DATA_QUERY.path]:u,[P.EXPLORER_DATA_QUERY.revision]:c}),{method:"GET",signal:h},P.isExplorerRevisionAnswer),refresh:u=>a(o("refresh",{[P.EXPLORER_DATA_QUERY.source]:u}),{method:"POST",headers:i},P.isExplorerTreeResult,c=>({status:"error",failure:c}))}},Ic=()=>{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}}},Fc=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}},An=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Fc(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(),f=H.recordTreeSettingChange(a,s,H.advanceTreeSetting(i,s)[s],t);return n={changes:f,settings:H.applyTreeSettingChanges(t,f)},o.emit(),J.writeStorage(e,H.serializeTreeSettingChanges(f)),n.settings}}},$c=Object.freeze({status:"refreshed"}),Bc=Object.freeze({status:"superseded"}),Rt=Object.freeze({status:"deferred"}),qc=er(Rt),Co=4,Uc=Co-1,Mn=Object.freeze({status:"loading"}),Hc=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),zc=e=>{const t=new Map,n=Tr(),r=new Map,o=new Map,s=new Map,a=new Map,i=xe(),f=new Set;let m=0,u=0;const c={direct:null,bulk:null},h=new Set;let w=!1,E=0;const b=()=>{E+=1,i.emit()},k=v=>o.get(v)??0,L=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},R=(v,y,O)=>{v.inFlight.delete(y),m-=1,O.lane==="bulk"&&(u-=1)},F=v=>{const y=a.get(v);if(y!==void 0){for(const[O,j]of[...y.inFlight])R(y,O,j),j.controller.abort();y.direct.clear(),y.bulk.clear(),y.unclaimed.clear()}},D=v=>{const y=k(v)+1;return o.set(v,y),F(v),y},p=(v,y)=>{const O=ye(v),j={promise:v,opened:y,stale:!1,loadedAt:O?.status==="ok"?O.loadedAt:null};return v.status==="pending"&&v.then(q=>{q.status==="ok"&&(j.loadedAt=q.loadedAt)}),j},g=v=>{let y=r.get(v);return y===void 0&&(y=new Map,r.set(v,y)),y},C=v=>{const y=[...a.keys()],O=c[v],j=O===null?0:y.indexOf(O)+1;for(let q=0;q<y.length;q+=1){const W=y[(j+q)%y.length],K=W===void 0?void 0:a.get(W);if(!(W===void 0||K===void 0)){for(const G of K[v])if((K.claims.get(G)??0)!==0)return K[v].delete(G),c[v]=W,{sourceId:W,path:G}}}return null},A=(v,y,O,j)=>{const q=a.get(v);if(q===void 0||q.inFlight.get(y)!==O)return;R(q,y,O);const W=(q.claims.get(y)??0)>0,K=g(v);if(j.status==="ok"?K.set(y,{status:"loaded",entries:j.entries}):j.status==="error"&&W?K.set(y,{status:"failed",failure:j.failure}):K.delete(y),b(),j.status==="error"&&W){const G={sourceId:v,path:y,failure:j.failure};for(const ne of[...f])ne(G)}B()},$=(v,y,O)=>{const j={controller:new AbortController,lane:O};L(v).inFlight.set(y,j),m+=1,O==="bulk"&&(u+=1),e.children(v,y,j.controller.signal).then(q=>A(v,y,j,q),()=>A(v,y,j,Hc))},B=()=>{for(;m<Co;){const v=C("direct");if(v!==null){$(v.sourceId,v.path,"direct");continue}const y=u<Uc?C("bulk"):null;if(y===null)return;$(y.sourceId,y.path,"bulk")}},x=(v,y,O)=>{if(!(y.direct.delete(O)||y.bulk.delete(O))){const q=y.inFlight.get(O);if(q===void 0)return!1;R(y,O,q),q.controller.abort()}return r.get(v)?.delete(O),!0},T=()=>{w=!1;let v=!1;for(const y of h){const O=L(y);for(const j of O.unclaimed)(O.claims.get(j)??0)===0&&x(y,O,j)&&(v=!0);O.unclaimed.clear()}h.clear(),v&&(b(),B())},M=(v,y)=>{t.set(v,p(Ce(e.tree(v)),y))},N=(v,y,O)=>{D(v);const j=p(er(y),O);return t.set(v,j),r.delete(v),b(),B(),j},_=(v,y,O,j)=>{if(O!==k(v)||t.get(v)!==y)return;const q=ye(y.promise);if(!(j.status!=="ok"||q?.status!=="ok"||y.loadedAt===null||j.loadedAt<=y.loadedAt)){if(Ve(q.entries,j.entries)){y.loadedAt=j.loadedAt;return}N(v,j,y.opened)}},U=(v,y)=>{const O=t.get(v);return O!==void 0&&ye(O.promise)?.status===y},Z=(v,y)=>{y.stale=!1;const O=k(v);e.tree(v).then(j=>_(v,y,O,j))};return{read:v=>t.get(v)?.promise??qc,open:v=>{const y=n.resumes(v),O=n.hold(v),j=t.get(v);return j===void 0||U(v,"deferred")?(M(v,!0),b()):y||(j.opened&&U(v,"error")?(M(v,!0),b()):(j.opened=!0,j.stale&&U(v,"ok")&&Z(v,j))),O},retry:v=>{U(v,"error")&&(M(v,!0),b())},seed:(v,y)=>{const O=y.then(W=>W===null?Rt:W,()=>Rt),j=t.get(v);if(j!==void 0&&U(v,"ok")){const W=k(v);O.then(K=>_(v,j,W,K));return}D(v);const q=p(Ce(O),j?.opened===!0);t.set(v,q),r.delete(v),B(),O.then(W=>{t.get(v)===q&&(W.status==="deferred"&&n.isHeld(v)&&M(v,q.opened),b())})},refresh:async v=>{const y=(s.get(v)??0)+1;s.set(v,y);const O=await e.refresh(v);if(s.get(v)!==y)return Bc;if(O.status==="error")return{status:"failed",failure:O.failure};const j=t.get(v);if(!(j!==void 0&&j.loadedAt!==null&&U(v,"ok")&&j.loadedAt>O.loadedAt)){const W=N(v,O,!0);if(j!==void 0&&j.promise.status==="pending"){const K=k(v);j.promise.then(G=>_(v,W,K,G))}}for(const[W,K]of t)W!==v&&ye(K.promise)?.status==="ok"&&(K.stale=!0);return $c},children:(v,y)=>r.get(v)?.get(y),claimChildren:(v,y)=>{const O=L(v),j=g(v);let q=!1,W=!1;for(const[G,ne]of y)O.claims.set(G,(O.claims.get(G)??0)+1),j.get(G)===void 0?(j.set(G,Mn),O[ne].add(G),q=!0,W=!0):ne==="direct"&&O.bulk.delete(G)&&(O.direct.add(G),W=!0);q&&b(),W&&B();let K=!1;return()=>{if(!K){K=!0;for(const G of y.keys()){const ne=(O.claims.get(G)??0)-1;ne>0?O.claims.set(G,ne):(O.claims.delete(G),O.unclaimed.add(G))}h.add(v),!w&&(w=!0,queueMicrotask(T))}}},retryChildren:(v,y)=>{const O=r.get(v);if(O===void 0||O.get(y)?.status!=="failed")return;const j=L(v);if((j.claims.get(y)??0)>0){O.set(y,Mn),j.direct.add(y),b(),B();return}O.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()]))D(v);for(const[v,y]of s)s.set(v,y+1);t.clear(),r.clear(),b()},subscribeChildrenFailures:v=>(f.add(v),()=>{f.delete(v)}),subscribe:i.subscribe,version:()=>E}},Vc=(e,t)=>{let n=e;const r=xe();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},Zc=1;let Fe=0,ie=null;const Wc=()=>{const{documentElement:e,body:t}=document;Fe===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"),Fe+=1;let n=!1;return()=>{n||(n=!0,Fe-=1,!(Fe>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))}},Gc=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Nn=1,Kc=1e3,Dn=e=>e.getClientRects().length>0,mt="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.",Xc=e=>{if(!Dn(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+Zc)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. ${mt}`;if(t.height<Nn)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. ${mt}`;for(const{selector:r,name:o}of Gc)for(const s of e.querySelectorAll(r)){if(!Dn(s))continue;const a=s.getBoundingClientRect().height;if(a<Nn)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. ${mt}`}return null},Yc=e=>{let t=!1,n;const r=()=>{n=void 0;const a=Xc(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,Kc))},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)}},Qc=(e,t)=>{d.useEffect(()=>e?Wc():void 0,[e]),d.useEffect(()=>{const n=t.current;if(!(!e||n===null))return Yc(n)},[e,t])},jn='[data-testid="markdown-explorer-view-switch"]',Jc=[{control:jn,successors:[jn,'[data-testid="markdown-explorer-sheet-toggle"]','[data-testid="markdown-explorer-rail-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],ed=e=>{for(const t of Jc){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},td=(e,t)=>{const n=d.useRef(null);d.useEffect(()=>{const o=i=>{const f=e.current;n.current=f!==null&&i instanceof Element&&f.contains(i)?ed(i):null},s=i=>o(i.target);o(document.activeElement);const a=i=>{const f=i.target;i.relatedTarget!==null||!(f instanceof Element)||queueMicrotask(()=>{n.current?.element===f&&f.isConnected&&document.activeElement!==f&&(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 f=document.activeElement;if(f!==null&&f!==document.body&&f!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const u of o.control.successors)for(const c of m.querySelectorAll(u))if(c!==o.element&&(c.focus({preventScroll:!0}),document.activeElement===c))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])},nd=d.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-DtvIpuOe.cjs")).then(e=>({default:e.TreeLayout}))),rd=d.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-CzR7yJ0m.cjs")).then(e=>({default:e.MultiLayout}))),od=64,sd={request:e=>{requestAnimationFrame(e)}},_n=e=>{e.documents.clear(),e.trees.clear()},ht=(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)},ad=(e,t)=>{const[n,r]=d.useState(()=>({overrides:t,locale:e,labels:Et(e,t)}));if(n.locale===e&&zo(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Et(e,t)};return r(o),o.labels},ld=(e,t,n)=>{const[r,o]=d.useState(()=>({scope:t,store:An(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:An(e,n)};return o(s),s.store},pt=(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},id=()=>_c(sd),Pn="on",cd="off",dd=Object.freeze({kind:"unavailable"}),ud=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")},fd=(e,t)=>{const n=le(e.peek(t));return n===null||n.document.kind==="failure"?P.lastPathSegment(t):n.document.name},md=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:f=!1,onMathDiagnostics:m,onEditGrant:u,draftConverter:c})=>{J.assertStorageNamespace(n),ud(c);const h=Hn(r),w=Vo(s),E=ad(h,o),{revalidate:b}=te.useRevalidator(),k=d.useRef(()=>{}),L=te.useHref(t.dataPath),[R]=d.useState(()=>{const O=Pc({dataPath:L,onScope:q=>k.current(q)}),j={documents:Vs({client:O,capacity:Math.max(od,t.multiView.maxPanels*2)}),trees:zc(O)};return ht(j,e),J.syncStorageScope(n,e.scope),{data:O,...j,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(R.aligned.pageData!==e||R.aligned.storageNamespace!==n){const O=R.aligned.pageData;R.aligned.pageData=e,R.aligned.storageNamespace=n,O!==e&&(O.scope!==e.scope?R.aligned.pendingReader=e:ht(R,e)),J.syncStorageScope(n,e.scope)}const F=ld(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);d.useLayoutEffect(()=>{const O=R.aligned.pendingReader;O!==null&&(R.aligned.pendingReader=null,_n(R),ht(R,O))},[e,R]),d.useLayoutEffect(()=>{let O=!1;return k.current=j=>{j===e.scope||O||(O=!0,j!==null&&(_n(R),J.clearExplorerStorage(n)),b())},()=>{k.current=()=>{}}},[e,b,R,n]);const D=d.useRef(t.settingsCookie);d.useLayoutEffect(()=>{D.current=t.settingsCookie},[t.settingsCookie]);const[p]=d.useState(()=>Vc(e.settings,O=>{document.cookie=H.viewSettingsCookieString(D.current,O,window.location.protocol==="https:")})),g=pt(e.scope,id),C=pt(e.scope,Ic),A=d.useRef(E);d.useLayoutEffect(()=>{A.current=E},[E]);const $=pt(e.scope,()=>Qo({data:R.data,conflictLabels:()=>({ours:A.current.conflictOurs,theirs:A.current.conflictTheirs}),onSaveSettled:(O,j)=>{j.kind==="saved"&&R.documents.refresh(O);const q=Wo(A.current,j,fd(R.documents,O));q!==null&&g.announce(q)},sideBySideSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Pn,write:O=>J.writeStorage(J.storageKeys(n).editPreview,O?Pn:cd)},editorShareSetting:{read:()=>Yo(J.readStorage(J.storageKeys(n).editSplit)),write:O=>J.writeStorage(J.storageKeys(n).editSplit,String(O))}})),B=d.useMemo(()=>Ce(e.notices.catch(()=>[])),[e.notices]),x=e.sources.map(O=>O.id).join(`
14
- `),T=d.useMemo(()=>H.withExplorerSources(t,x.split(`
15
- `)),[t,x]),M=d.useRef(m);d.useLayoutEffect(()=>{M.current=m},[m]);const[N]=d.useState(()=>(O,j)=>{M.current?.(O,j)}),_=m===void 0?void 0:N,U=d.useRef(c);d.useLayoutEffect(()=>{U.current=c},[c]);const[Z]=d.useState(()=>{let O=!1;return{convert:(j,q)=>{const W=U.current;return W===void 0?Promise.resolve(dd):W.convert(j,q)},prepare:()=>{try{U.current?.prepare?.()}catch(j){if(O)return;O=!0,console.error("[markdown-explorer] the draft converter's prepare threw",j)}}}}),v=c===void 0?void 0:Z,y=d.useMemo(()=>({config:T,labels:E,locale:h,theme:w,storageNamespace:n,scope:e.scope,sources:e.sources,notices:B,documents:R.documents,trees:R.trees,data:R.data,viewSettings:p,treeSettings:F,announcer:g,reveals:C,edits:$,onEditGrant:u,draftConverter:v,renderTreeFailure:i,reportMathDiagnostics:_}),[T,E,h,w,n,e.scope,e.sources,B,R,p,F,g,C,$,u,v,i,_]);return l.jsx(zn,{value:y,children:l.jsx(pd,{renderFrame:a,lockDocumentScroll:f},e.scope)})},hd=({ref:e,theme:t,view:n,children:r})=>{const[o]=d.useState(Pa);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})},pd=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=I(),o=Xe(),{hash:s}=te.useLocation(),a=be(),i=d.useRef(null);Qc(t,i),d.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:f}=o,m=f.view;td(i,m);const u=f.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",...He}),children:l.jsx(nd,{location:f})}):f.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",...He}),children:l.jsx(rd,{location:f})}):l.jsx(jc,{location:f}),c=l.jsxs(hd,{ref:i,theme:n,view:m,children:[u,l.jsx(fs,{}),l.jsx(To,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?c:e({view:m,children:c})},gd=Fo.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Ge;exports.CONFLICT_OURS_MARKER=Zn;exports.CONFLICT_SEPARATOR=Wn;exports.CONFLICT_THEIRS_MARKER=Gn;exports.CONTENT_PANE=He;exports.ContentSkeleton=ue;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=In;exports.DocumentPane=mo;exports.DocumentRefreshBar=Ro;exports.EXPLORER_THEMES=xt;exports.EditGrantNotice=vo;exports.ExplorerLink=pr;exports.FOLDER_README_LOADING=tr;exports.FailureView=ce;exports.ForwardRef=ho;exports.ForwardRef$1=wo;exports.ForwardRef$2=po;exports.ImageViewMemoryContext=_r;exports.LazyNativeScrollBar=wr;exports.LiveRegion=To;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=Un;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ct;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Bn;exports.MARKDOWN_EXPLORER_LOCALES=vt;exports.MarkdownExplorer=md;exports.NATIVE_SCROLL_BAR_SLOT_LENGTH=Dt;exports.NATIVE_SCROLL_BAR_WIDTH=As;exports.NEAREST=We;exports.NO_DOCUMENT=co;exports.PAGE_DOCUMENT_REFRESH=ko;exports.SCROLL_BAR_CONTROLS=Er;exports.SheetBarContext=yo;exports.TAP_SCROLL_CIRCLE_GUTTER_LENGTH=_t;exports.TAP_SCROLL_CIRCLE_OFFSET_X=js;exports.TAP_SCROLL_CIRCLE_SIZE=jt;exports.TAP_SCROLL_CIRCLE_SPEED_RANGE=br;exports.TOUCH_SCROLL_BAR_CONTROLS=xr;exports.alignToStart=Dr;exports.anchorOfDoubleClick=cr;exports.anchorOfView=dr;exports.blockAtLine=mr;exports.chooseEditView=kt;exports.consumeKey=Lt;exports.createEmitter=xe;exports.cssPixels=Xn;exports.editViewOf=Eo;exports.explorerNavigationOptions=Cs;exports.failureTitleOf=re;exports.findConflictsInLines=Kn;exports.focusWithoutScroll=Mt;exports.frameTopOf=ur;exports.isApplePlatform=bo;exports.isEditViewShortcut=So;exports.isEditingDoubleClick=ir;exports.isInFullscreenBlock=vs;exports.keepInView=Or;exports.lineTopIn=hr;exports.loadedOf=le;exports.paneShownAlone=vc;exports.positionInSource=Rs;exports.readFolderReadme=nr;exports.resolveMarkdownExplorerLabels=Et;exports.scrollBarControlsFor=Nt;exports.shouldRevalidateExplorer=gd;exports.stopKeepingInView=Lr;exports.toggledEditView=xo;exports.useCoarsePointer=Pt;exports.useExplorer=I;exports.useExplorerLocation=Xe;exports.useExplorerNavigate=be;exports.useIntentPrefetch=gr;exports.usePageMarkupToggle=$r;exports.useSideBySide=sr;exports.useViewSetting=Te;exports.visibleTopOf=fr;