@aiquants/markdown-explorer 0.19.0 → 0.20.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 (32) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/README.md +17 -9
  3. package/dist/EditSurface-D1yklbWu.js +833 -0
  4. package/dist/EditSurface-GxmyUeGE.cjs +3 -0
  5. package/dist/{ExplorerSplit-LiI3IUZn.js → ExplorerSplit-BAYa3WO3.js} +1 -1
  6. package/dist/{ExplorerSplit-BDkBN8A0.cjs → ExplorerSplit-DkE46pS0.cjs} +1 -1
  7. package/dist/{MultiLayout-KWacTPP8.js → MultiLayout-BkhnkQs5.js} +2 -2
  8. package/dist/{MultiLayout-BOaQK8fp.cjs → MultiLayout-DsxYURra.cjs} +1 -1
  9. package/dist/{NativeScrollBar-BPgV3kp-.cjs → NativeScrollBar-B57yWQVG.cjs} +1 -1
  10. package/dist/{NativeScrollBar-zzpty31a.js → NativeScrollBar-CcNqDlO6.js} +1 -1
  11. package/dist/{TreeLayout-C8IP4cjY.js → TreeLayout-Cf2PzZEI.js} +2 -2
  12. package/dist/{TreeLayout-S5TMf8_A.cjs → TreeLayout-DCGqVwt9.cjs} +1 -1
  13. package/dist/core/labels.d.cts +26 -0
  14. package/dist/core/labels.d.ts +26 -0
  15. package/dist/index-Bdve5EFS.cjs +13 -0
  16. package/dist/{index-Dz01kBab.js → index-DiLkl4dC.js} +1323 -1238
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/{merge-ClVgYrkS.js → merge-BIXNcrea.js} +1 -1
  20. package/dist/{merge-B7Lkcdz0.cjs → merge-DSfJceoQ.cjs} +1 -1
  21. package/dist/sanitizePolicy-BWQtWhsL.js +98 -0
  22. package/dist/sanitizePolicy-gEXeavb-.cjs +1 -0
  23. package/dist/sanitizeWorker.cjs +1 -1
  24. package/dist/sanitizeWorker.js +1 -1
  25. package/docs/behavior/localization.md +5 -1
  26. package/docs/behavior/security.md +1 -1
  27. package/package.json +9 -7
  28. package/dist/EditSurface-4VX20isB.cjs +0 -2
  29. package/dist/EditSurface-Ckg-3iTA.js +0 -786
  30. package/dist/index-DrKHJNY4.cjs +0 -13
  31. package/dist/sanitizePolicy-DlrakwA4.js +0 -96
  32. package/dist/sanitizePolicy-DrIMuYCb.cjs +0 -1
@@ -2,8 +2,8 @@ import { jsx as w, jsxs as _ } from "react/jsx-runtime";
2
2
  import { useMemo as v, useCallback as m, useSyncExternalStore as C, useEffect as S, useState as M } from "react";
3
3
  import { useLocation as A } from "react-router";
4
4
  import { e as p, c as L } from "./location-B-m9scLf.js";
5
- import { u as h, r as y, F as G, c as j, N as H, d as q, e as U, D as $, P as z, f as B } from "./index-Dz01kBab.js";
6
- import { E as Y, a as J, b as K } from "./ExplorerSplit-LiI3IUZn.js";
5
+ import { u as h, r as y, F as G, c as j, N as H, d as q, e as U, D as $, P as z, f as B } from "./index-DiLkl4dC.js";
6
+ import { E as Y, a as J, b as K } from "./ExplorerSplit-BAYa3WO3.js";
7
7
  const Q = (t, e) => t.claim !== e.claim || t.readme.status !== e.readme.status ? !1 : t.readme.status === "failed" && e.readme.status === "failed" ? t.readme.failure === e.readme.failure : t.readme.status === "ok" && e.readme.status === "ok" ? t.readme.readme === e.readme.readme : !0, V = (t, e, n) => {
8
8
  let r = null;
9
9
  return () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),u=require("react"),T=require("react-router"),p=require("./location-BVEN_Ihk.cjs"),d=require("./index-DrKHJNY4.cjs"),x=require("./ExplorerSplit-BDkBN8A0.cjs"),P=(t,e)=>t.claim!==e.claim||t.readme.status!==e.readme.status?!1:t.readme.status==="failed"&&e.readme.status==="failed"?t.readme.failure===e.readme.failure:t.readme.status==="ok"&&e.readme.status==="ok"?t.readme.readme===e.readme.readme:!0,F=(t,e,n)=>{let r=null;return()=>{const a=t.version(),c=t.read(e),o=c.status!=="pending";if(r!==null&&r.version===a&&r.tree===c&&r.settled===o)return r.state;const l=d.readFolderReadme(t,e,n),s=r!==null&&P(r.state,l)?r.state:l;return r={version:a,tree:c,settled:o,state:s},s}},_=(t,e,n)=>{let r=!0,a=null;const c=()=>{r&&n()},o=()=>{const s=t.read(e);s===a||s.status!=="pending"||(a=s,s.then(c,c))};o();const l=t.subscribe(()=>{o(),n()});return()=>{r=!1,l()}},j=()=>d.FOLDER_README_LOADING,q=(t,e)=>{const{trees:n}=d.useExplorer(),r=u.useMemo(()=>e===null?null:F(n,t,e),[n,t,e]),a=u.useCallback(f=>r===null?()=>{}:_(n,t,f),[r,n,t]),c=u.useCallback(()=>r===null?null:r(),[r]),o=u.useCallback(()=>r===null?null:j(),[r]),l=u.useSyncExternalStore(a,c,o),s=l?.claim===!0;return u.useEffect(()=>e===null?void 0:n.open(t),[n,t,e]),u.useEffect(()=>e===null||!s?void 0:n.claimChildren(t,new Map([[e,"direct"]])),[n,t,e,s]),l===null?null:l.readme},y=new Set,H=Object.freeze({kind:"loading"}),L=(t,e)=>e.status==="loading"?H:e.status==="failed"?{kind:"failure",folder:t,failure:e.failure,onRetry:e.retry}:{kind:"no-readme",folder:t},A=({location:t})=>{const{config:e}=d.useExplorer(),n=d.useExplorerNavigate(),{hash:r}=T.useLocation(),{source:a,doc:c,folder:o,overrides:l,markup:s}=t,[f,S]=u.useState(x.EMPTY_SELECTION),w=u.useMemo(()=>({gathered:f,onGatheredChange:S}),[f]),v=q(a,o),i=v===null?c:v.status==="ok"?v.readme:null,k=u.useMemo(()=>o===null||v===null?d.NO_DOCUMENT:L(o,v),[o,v]),h=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,doc:m,overrides:l}),"browse"),[n,e,a,l]),O=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,folder:m,overrides:l}),"browse"),[n,e,a,l]),g=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s}),"switch-source"),[n,e,c,o,l,s]),C=u.useCallback(m=>n(`${p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s})}${r}`,"browse"),[n,e,c,o,l,s,r]),R=u.useCallback(m=>{const E=p.canonicalMultiDocuments(e,m);n(p.explorerHref(e,{view:"multi",source:a,docs:E,markup:s&&i!==null&&E.includes(i)?[i]:[]}),"switch-view")},[n,e,a,i,s]),M=u.useMemo(()=>({href:p.explorerHref(e,i===null?{view:"multi",source:a}:{view:"multi",source:a,docs:[i],markup:s?[i]:[]}),target:"multi"}),[e,a,i,s]),D=u.useMemo(()=>({kind:"page",view:"tree",overrides:l,embed:{}}),[l]),N=d.usePageMarkupToggle(t);return b.jsx(x.ExplorerSplit,{view:"tree",explorer:b.jsx(x.ExplorerPane,{mode:"tree",sourceId:a,currentPath:o===null?c:o,openPaths:y,onOpenDocument:h,onOpenFolder:O,currentFolder:o!==null,onSourceChange:g,onRevealSource:C,viewSwitch:M,tray:w,onOpenSelection:R}),content:b.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",...d.CONTENT_PANE,children:[i===null?null:b.jsx(d.DocumentRefreshBar,{path:i,placement:d.PAGE_DOCUMENT_REFRESH,markup:N}),b.jsx(d.DocumentPane,{path:i,absence:k,markup:s,variant:D})]})})};exports.TreeLayout=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),u=require("react"),T=require("react-router"),p=require("./location-BVEN_Ihk.cjs"),d=require("./index-Bdve5EFS.cjs"),x=require("./ExplorerSplit-DkE46pS0.cjs"),P=(t,e)=>t.claim!==e.claim||t.readme.status!==e.readme.status?!1:t.readme.status==="failed"&&e.readme.status==="failed"?t.readme.failure===e.readme.failure:t.readme.status==="ok"&&e.readme.status==="ok"?t.readme.readme===e.readme.readme:!0,F=(t,e,n)=>{let r=null;return()=>{const a=t.version(),c=t.read(e),o=c.status!=="pending";if(r!==null&&r.version===a&&r.tree===c&&r.settled===o)return r.state;const l=d.readFolderReadme(t,e,n),s=r!==null&&P(r.state,l)?r.state:l;return r={version:a,tree:c,settled:o,state:s},s}},_=(t,e,n)=>{let r=!0,a=null;const c=()=>{r&&n()},o=()=>{const s=t.read(e);s===a||s.status!=="pending"||(a=s,s.then(c,c))};o();const l=t.subscribe(()=>{o(),n()});return()=>{r=!1,l()}},j=()=>d.FOLDER_README_LOADING,q=(t,e)=>{const{trees:n}=d.useExplorer(),r=u.useMemo(()=>e===null?null:F(n,t,e),[n,t,e]),a=u.useCallback(f=>r===null?()=>{}:_(n,t,f),[r,n,t]),c=u.useCallback(()=>r===null?null:r(),[r]),o=u.useCallback(()=>r===null?null:j(),[r]),l=u.useSyncExternalStore(a,c,o),s=l?.claim===!0;return u.useEffect(()=>e===null?void 0:n.open(t),[n,t,e]),u.useEffect(()=>e===null||!s?void 0:n.claimChildren(t,new Map([[e,"direct"]])),[n,t,e,s]),l===null?null:l.readme},y=new Set,H=Object.freeze({kind:"loading"}),L=(t,e)=>e.status==="loading"?H:e.status==="failed"?{kind:"failure",folder:t,failure:e.failure,onRetry:e.retry}:{kind:"no-readme",folder:t},A=({location:t})=>{const{config:e}=d.useExplorer(),n=d.useExplorerNavigate(),{hash:r}=T.useLocation(),{source:a,doc:c,folder:o,overrides:l,markup:s}=t,[f,S]=u.useState(x.EMPTY_SELECTION),w=u.useMemo(()=>({gathered:f,onGatheredChange:S}),[f]),v=q(a,o),i=v===null?c:v.status==="ok"?v.readme:null,k=u.useMemo(()=>o===null||v===null?d.NO_DOCUMENT:L(o,v),[o,v]),h=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,doc:m,overrides:l}),"browse"),[n,e,a,l]),O=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,folder:m,overrides:l}),"browse"),[n,e,a,l]),g=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s}),"switch-source"),[n,e,c,o,l,s]),C=u.useCallback(m=>n(`${p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s})}${r}`,"browse"),[n,e,c,o,l,s,r]),R=u.useCallback(m=>{const E=p.canonicalMultiDocuments(e,m);n(p.explorerHref(e,{view:"multi",source:a,docs:E,markup:s&&i!==null&&E.includes(i)?[i]:[]}),"switch-view")},[n,e,a,i,s]),M=u.useMemo(()=>({href:p.explorerHref(e,i===null?{view:"multi",source:a}:{view:"multi",source:a,docs:[i],markup:s?[i]:[]}),target:"multi"}),[e,a,i,s]),D=u.useMemo(()=>({kind:"page",view:"tree",overrides:l,embed:{}}),[l]),N=d.usePageMarkupToggle(t);return b.jsx(x.ExplorerSplit,{view:"tree",explorer:b.jsx(x.ExplorerPane,{mode:"tree",sourceId:a,currentPath:o===null?c:o,openPaths:y,onOpenDocument:h,onOpenFolder:O,currentFolder:o!==null,onSourceChange:g,onRevealSource:C,viewSwitch:M,tray:w,onOpenSelection:R}),content:b.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",...d.CONTENT_PANE,children:[i===null?null:b.jsx(d.DocumentRefreshBar,{path:i,placement:d.PAGE_DOCUMENT_REFRESH,markup:N}),b.jsx(d.DocumentPane,{path:i,absence:k,markup:s,variant:D})]})})};exports.TreeLayout=A;
@@ -230,6 +230,32 @@ export type MarkdownExplorerLabels = {
230
230
  readonly viewerEmbeddedVideo: string;
231
231
  readonly viewerEmbeddedPost: string;
232
232
  readonly viewerEmbeddedFrame: string;
233
+ readonly viewerSpreadsheetTable: string;
234
+ readonly viewerSpreadsheetZoomIn: string;
235
+ readonly viewerSpreadsheetZoomOut: string;
236
+ readonly viewerSpreadsheetResetZoom: string;
237
+ readonly viewerSpreadsheetHighlight: string;
238
+ readonly viewerSpreadsheetCopyAll: string;
239
+ readonly viewerSpreadsheetSaveTsv: string;
240
+ readonly viewerSpreadsheetSaveMenu: string;
241
+ readonly viewerSpreadsheetSaveTsvWithBom: string;
242
+ readonly viewerSpreadsheetFullscreen: string;
243
+ readonly viewerSpreadsheetExitFullscreen: string;
244
+ readonly viewerSpreadsheetFullscreenDialog: string;
245
+ readonly viewerSpreadsheetSize: string;
246
+ readonly viewerSpreadsheetFileName: string;
247
+ readonly viewerSpreadsheetCopied: string;
248
+ readonly viewerSpreadsheetCopyFailed: string;
249
+ readonly viewerSpreadsheetCellAnnouncement: string;
250
+ readonly viewerSpreadsheetEmptyCell: string;
251
+ readonly viewerSpreadsheetSelectionAnnouncement: string;
252
+ readonly viewerSpreadsheetReadOnly: string;
253
+ readonly viewerSpreadsheetFormatRefused: string;
254
+ readonly viewerSpreadsheetFenceRefused: string;
255
+ readonly viewerSpreadsheetEditConflict: string;
256
+ readonly viewerSpreadsheetOptionsError: string;
257
+ readonly viewerSpreadsheetLoadFailed: string;
258
+ readonly viewerSpreadsheetRetry: string;
233
259
  readonly multiRegion: string;
234
260
  readonly multiEmpty: string;
235
261
  readonly panelLimit: (max: number) => string;
@@ -230,6 +230,32 @@ export type MarkdownExplorerLabels = {
230
230
  readonly viewerEmbeddedVideo: string;
231
231
  readonly viewerEmbeddedPost: string;
232
232
  readonly viewerEmbeddedFrame: string;
233
+ readonly viewerSpreadsheetTable: string;
234
+ readonly viewerSpreadsheetZoomIn: string;
235
+ readonly viewerSpreadsheetZoomOut: string;
236
+ readonly viewerSpreadsheetResetZoom: string;
237
+ readonly viewerSpreadsheetHighlight: string;
238
+ readonly viewerSpreadsheetCopyAll: string;
239
+ readonly viewerSpreadsheetSaveTsv: string;
240
+ readonly viewerSpreadsheetSaveMenu: string;
241
+ readonly viewerSpreadsheetSaveTsvWithBom: string;
242
+ readonly viewerSpreadsheetFullscreen: string;
243
+ readonly viewerSpreadsheetExitFullscreen: string;
244
+ readonly viewerSpreadsheetFullscreenDialog: string;
245
+ readonly viewerSpreadsheetSize: string;
246
+ readonly viewerSpreadsheetFileName: string;
247
+ readonly viewerSpreadsheetCopied: string;
248
+ readonly viewerSpreadsheetCopyFailed: string;
249
+ readonly viewerSpreadsheetCellAnnouncement: string;
250
+ readonly viewerSpreadsheetEmptyCell: string;
251
+ readonly viewerSpreadsheetSelectionAnnouncement: string;
252
+ readonly viewerSpreadsheetReadOnly: string;
253
+ readonly viewerSpreadsheetFormatRefused: string;
254
+ readonly viewerSpreadsheetFenceRefused: string;
255
+ readonly viewerSpreadsheetEditConflict: string;
256
+ readonly viewerSpreadsheetOptionsError: string;
257
+ readonly viewerSpreadsheetLoadFailed: string;
258
+ readonly viewerSpreadsheetRetry: string;
233
259
  readonly multiRegion: string;
234
260
  readonly multiEmpty: string;
235
261
  readonly panelLimit: (max: number) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";const l=require("react/jsx-runtime"),a=require("react"),Y=require("react-router"),$=require("./location-BVEN_Ihk.cjs"),D=require("./dataRoute-BONacTPi.cjs"),me=require("@aiquants/markdown"),Ie=require("@aiquants/markdown/source-lines"),Bn=require("@aiquants/markdown/viewer-settings"),X=require("./storage-DM0EvkVf.cjs"),zn=require("@aiquants/route-revalidation");function Hn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const y=Hn(a),Be=Object.freeze(["en","ja"]),Nt="en",Dt=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"]),viewerSpreadsheetSize:Object.freeze(["rows","cols"]),viewerSpreadsheetCopyFailed:Object.freeze(["reason"]),viewerSpreadsheetCellAnnouncement:Object.freeze(["cell","value"]),viewerSpreadsheetSelectionAnnouncement:Object.freeze(["range"]),viewerSpreadsheetOptionsError:Object.freeze(["message"]),viewerSpreadsheetLoadFailed:Object.freeze(["message"])}),Vn=/\{(\w+)\}/gu,Pt={explorerRegion:"Explorer",sourceLabel:"Source",refreshTreeLabel:"Refresh tree",refreshTree:"Reload the tree and the open documents from the source",treeRefreshed:"Reloaded the tree from the source",treeRefreshFailed:e=>`Could not reload the tree: ${e}`,refreshDocumentLabel:"Refresh document",refreshDocument:"Reload the document from the source",refreshDocumentNamed:e=>`Refresh ${e}`,documentRefreshed:e=>`Reloaded ${e}`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",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}`,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…",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.",viewerLoading:"Loading data...",viewerErrorPrefix:"Error: ",viewerStyleTitle:"Display Style",viewerSelectStyle:"Select display style",viewerPinStyle:"Pin style selector",viewerUnpinStyle:"Unpin style selector",viewerErrorTitle:"An error occurred",viewerMissingImage:"Image not found",viewerOpenToc:"Open table of contents",viewerTocTitle:"Table of contents",viewerPinToc:"Pin table of contents",viewerUnpinToc:"Unpin table of contents",viewerSelectAlign:"Select alignment",viewerAlignTitle:"Alignment",viewerPinAlign:"Pin alignment selector",viewerUnpinAlign:"Unpin alignment selector",viewerAlignLeft:"Align left",viewerAlignCenter:"Align center",viewerAlignRight:"Align right",viewerMermaidInteractionMode:"Mouse interaction mode",viewerMermaidInteractionModeTouch:"Touch interaction mode",viewerMermaidModeNone:"No interaction",viewerMermaidModeZoom:"Zoom only",viewerMermaidModePan:"Pan only (drag)",viewerMermaidModePanShift:"Pan only (Shift+drag)",viewerMermaidModeBoth:"Zoom and pan (drag)",viewerMermaidModeBothShift:"Zoom and pan (Shift+drag)",viewerMermaidModeNoneTouch:"No interaction (a finger scrolls the page)",viewerMermaidModeZoomTouch:"Zoom only (two fingers)",viewerMermaidModePanTouch:"Pan only (one-finger drag while the diagram overflows)",viewerMermaidModeBothTouch:"Zoom and pan (two fingers, one finger while the diagram overflows)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidPanUp:"Pan Up",viewerMermaidPanDown:"Pan Down",viewerMermaidPanLeft:"Pan Left",viewerMermaidPanRight:"Pan Right",viewerMermaidDiagram:"Diagram (arrow keys pan, + and - zoom, 0 resets)",viewerMermaidRetry:"Try again",viewerEmbeddedVideo:"embedded video",viewerEmbeddedPost:"embedded post",viewerEmbeddedFrame:"Embedded content",viewerSpreadsheetTable:"Spreadsheet",viewerSpreadsheetZoomIn:"Zoom in",viewerSpreadsheetZoomOut:"Zoom out",viewerSpreadsheetResetZoom:"Reset zoom",viewerSpreadsheetHighlight:"Highlight the active row and column",viewerSpreadsheetCopyAll:"Copy the whole table",viewerSpreadsheetSaveTsv:"Save as TSV",viewerSpreadsheetSaveMenu:"More ways to save",viewerSpreadsheetSaveTsvWithBom:"Save with a BOM (for Excel)",viewerSpreadsheetFullscreen:"View full screen",viewerSpreadsheetExitFullscreen:"Exit full screen",viewerSpreadsheetFullscreenDialog:"Spreadsheet (full screen)",viewerSpreadsheetSize:"Rows {rows} × columns {cols}",viewerSpreadsheetFileName:"spreadsheet.tsv",viewerSpreadsheetCopied:"Copied the whole table.",viewerSpreadsheetCopyFailed:"Could not copy the table: {reason}",viewerSpreadsheetCellAnnouncement:"{cell}, {value}",viewerSpreadsheetEmptyCell:"blank",viewerSpreadsheetSelectionAnnouncement:"{range} selected",viewerSpreadsheetReadOnly:"This table is read-only here.",viewerSpreadsheetFormatRefused:"This table keeps text only, so formatting and links are not saved.",viewerSpreadsheetFenceRefused:"A cell cannot begin a line with ``` or ~~~ in this table, so the change was not saved.",viewerSpreadsheetEditConflict:"The table changed in the editor, so the change was not saved. Try again.",viewerSpreadsheetOptionsError:"Invalid spreadsheet options: {message}",viewerSpreadsheetLoadFailed:"Could not load the spreadsheet: {message}",viewerSpreadsheetRetry:"Retry",multiRegion:"Panels",multiEmpty:"Select documents in the explorer to open them side by side.",panelLimit:e=>`You can open up to ${String(e)} panels at once.`,panelOpened:e=>`Opened ${e}`,panelClosed:e=>`Closed ${e}`,panelAlreadyOpen:e=>`${e} is already open`,panelHidden:e=>`Hid ${e}`,panelShown:e=>`Showed ${e}`,panelMaximized:e=>`Maximized ${e}`,panelRestored:e=>`Restored ${e} to its size`,panelHide:"Hide the panel",panelMaximize:"Maximize the panel",panelRestore:"Restore the panel to its size",panelClose:"Close the panel",panelSwitchToCustomDrag:"Switch to the custom drag mode",panelSwitchToNormalDrag:"Back to the normal drag mode",panelCustomDragBadge:"Custom",panelMove:"Move the panel",panelMovePreviousColumn:"Move to the previous column",panelMoveNextColumn:"Move to the next column",panelMoveUp:"Move up",panelMoveDown:"Move down",panelMoved:"Moved {title} to column {column}, position {position}",panelMoveUnavailable:"{move} is not available for {title}",panelDragStarted:"Picked up {title}",panelDragCancelled:"Kept {title} where it was",hiddenPanelsTitle:"Hidden panels:",hiddenPanelBadge:"Hidden",hiddenPanelNotice:"This panel is hidden",multiColumnEmpty:"This column is empty",multiColumnRegion:"Column {column}",panelDropHere:"Drop the panel here"},Un={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",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}`,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:"ソースを読み込み中…",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 を表示しません。新しいタブで開くか、ダウンロードしてください。",viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidInteractionModeTouch:"タッチ操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidModeNoneTouch:"操作なし (指はページをスクロール)",viewerMermaidModeZoomTouch:"拡大縮小のみ (2 本指)",viewerMermaidModePanTouch:"移動のみ (はみ出す図を 1 本指でドラッグ)",viewerMermaidModeBothTouch:"拡大縮小+移動 (2 本指・はみ出す図は 1 本指)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidPanUp:"上へ移動",viewerMermaidPanDown:"下へ移動",viewerMermaidPanLeft:"左へ移動",viewerMermaidPanRight:"右へ移動",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerSpreadsheetTable:"表",viewerSpreadsheetZoomIn:"拡大",viewerSpreadsheetZoomOut:"縮小",viewerSpreadsheetResetZoom:"拡大率を戻す",viewerSpreadsheetHighlight:"選んだ行と列を強調",viewerSpreadsheetCopyAll:"表全体をコピー",viewerSpreadsheetSaveTsv:"TSV として保存",viewerSpreadsheetSaveMenu:"ほかの保存の方法",viewerSpreadsheetSaveTsvWithBom:"BOM を付けて保存 (Excel 向け)",viewerSpreadsheetFullscreen:"全画面で見る",viewerSpreadsheetExitFullscreen:"全画面を閉じる",viewerSpreadsheetFullscreenDialog:"表 (全画面)",viewerSpreadsheetSize:"{rows} 行 × {cols} 列",viewerSpreadsheetFileName:"表.tsv",viewerSpreadsheetCopied:"表全体をコピーしました。",viewerSpreadsheetCopyFailed:"表をコピーできませんでした: {reason}",viewerSpreadsheetCellAnnouncement:"{cell}、{value}",viewerSpreadsheetEmptyCell:"空白",viewerSpreadsheetSelectionAnnouncement:"{range} を選択",viewerSpreadsheetReadOnly:"この表はここでは編集できません。",viewerSpreadsheetFormatRefused:"この表は文字だけを保つため、書式とリンクは保存しません。",viewerSpreadsheetFenceRefused:"セルの行頭に ``` や ~~~ を置くと表が壊れるため、この変更は保存しませんでした。",viewerSpreadsheetEditConflict:"エディタで表が変わっていたため、この変更は保存しませんでした。もう一度お試しください。",viewerSpreadsheetOptionsError:"表の指定の誤り: {message}",viewerSpreadsheetLoadFailed:"表を読み込めませんでした: {message}",viewerSpreadsheetRetry:"再試行",multiRegion:"パネル",multiEmpty:"エクスプローラーで文書を選ぶと、ここに並べて開きます。",panelLimit:e=>`同時に開けるのは ${String(e)} パネルまでです。`,panelOpened:e=>`${e} を開きました`,panelClosed:e=>`${e} を閉じました`,panelAlreadyOpen:e=>`${e} は既に開いています`,panelHidden:e=>`${e} を隠しました`,panelShown:e=>`${e} を表示しました`,panelMaximized:e=>`${e} を最大化しました`,panelRestored:e=>`${e} を元のサイズに戻しました`,panelHide:"パネルを隠す",panelMaximize:"パネルを最大化",panelRestore:"パネルを元のサイズに戻す",panelClose:"パネルを閉じる",panelSwitchToCustomDrag:"カスタムのドラッグの方式に切り替え",panelSwitchToNormalDrag:"通常のドラッグの方式に戻す",panelCustomDragBadge:"カスタム",panelMove:"パネルを移動",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},_t=Object.freeze({en:Object.freeze(Pt),ja:Object.freeze(Un)}),We=Object.freeze(Object.keys(Pt)),Zn=new Set(We),Gn=e=>Zn.has(e),Ee=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,Ft=e=>{if(e===void 0)return Nt;if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Be.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Ee(e)}`)},ze=(e,t)=>{const n=_t[Ft(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Ee(t)}`);if(!$.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Ee(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Gn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${We.join(", ")}`);const i=r[s];if(i===void 0)continue;const f=typeof n[s];if(typeof i!==f)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${f}; got ${Ee(i)}`);if(typeof i=="string"&&i.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const h=Dt[s];if(typeof i=="string"&&h!==void 0){for(const[,m]of i.matchAll(Vn))if(!h.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${h.map(u=>`{${u}}`).join(", ")}`)}o[s]=i}return Object.freeze(o)},Wn=(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(i=>Object.hasOwn(n,i)&&Object.is(n[i],r[i]))},He=Object.freeze(["light","dark"]),Kn=e=>{if(e===void 0)return"light";if(He.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${He.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},$t=a.createContext(null),P=()=>{const e=a.use($t);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},he=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return a.useSyncExternalStore(t.subscribe,n,n)},ke=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return a.useMemo(()=>$.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},qt={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"]},ee=(e,t)=>e[qt[t][0]],se=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=ee(o,e.reason),i=o[qt[e.reason][1]],f=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":f,"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:i}),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]})},Xn=(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 ee(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(ee(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Yn=(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(ee(e,t.failure.reason));case"idle":case"saving":return null}},ae=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},It="<<<<<<<",Bt="=======",zt=">>>>>>>",lt=(e,t)=>e===t||e.startsWith(`${t} `),at=e=>Ht(e.split(`
2
+ `)),Ht=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const i=s.charCodeAt(0);i!==60&&i!==61&&i!==62||(lt(s,It)?(n=o,r=null):s===Bt?n!==null&&r===null?r=o:n=null:lt(s,zt)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},ct=e=>e.includes(`\r
3
+ `)?`\r
4
+ `:`
5
+ `,Ne=e=>e.replace(/\r\n?/gu,`
6
+ `),Qn=(e,t)=>t===`
7
+ `?e:e.replaceAll(`
8
+ `,`\r
9
+ `),Jn=3,er=/^\d+(?:\.\d+)?$/u,tr=e=>{if(e===null||!er.test(e))return null;const t=Number(e);return t>=$.EDIT_SPLIT_MIN_PERCENT&&t<=$.EDIT_SPLIT_MAX_PERCENT?t:null},De=Object.freeze({kind:"idle"}),dt=Object.freeze({kind:"draft"}),nr=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,i=new Map,f=new Map,h=new Map,m=new Map,u=ae();let p=null,E=null,S=null;const k=(c,d)=>{c.value={...c.value,...d},u.emit()},O=(c,d)=>s.get(c)===d,T=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:w}=d.controller;k(d,{phase:{kind:"opening"}});const C=await e.edit(c,w);if(!O(c,d)||w.aborted||!("kind"in C))return;if(C.kind==="grant"){k(d,{phase:{kind:"grant",href:C.href}});return}if(C.kind==="failure"){k(d,{phase:{kind:"failed",failure:C.failure}});return}const M=Ne(C.text),N=C.kind==="draft";d.base={text:M,version:N?null:C.version},d.draft=M,d.ending=ct(C.text),k(d,{phase:{kind:"editing"},history:N?!1:C.history,dirty:!1,save:N?dt:De,generation:d.value.generation+1})},A=c=>{const d=s.get(c);d!==void 0&&(d.controller.abort(),s.delete(c),f.delete(c))},j=(c,d,w)=>(c.set(d,w),()=>{c.get(d)===w&&c.delete(d)}),x=(c,d,w,C={})=>{k(d,{...C,save:w}),n(c,w)},g=async c=>{h.get(c)?.flush();const d=s.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const{version:w}=d.base;if(w===null){n(c,dt);return}const C=at(d.draft).length;if(C>0){x(c,d,{kind:"conflicts",count:C});return}d.controller.abort(),d.controller=new AbortController;const{signal:M}=d.controller;let N={text:d.base.text,version:w},F=d.draft,U=!1;k(d,{save:{kind:"saving"}});for(let V=0;V<Jn;V+=1){const q=await e.save(c,N.version,Qn(F,d.ending),M);if(!O(c,d)||M.aborted||!("kind"in q))return;if(q.kind==="saved"){h.get(c)?.flush(),d.base={text:F,version:q.version},x(c,d,{kind:"saved",merged:U},{dirty:d.draft!==F});return}if(q.kind==="grant"){x(c,d,{kind:"grant",href:q.href});return}if(q.kind==="failure"){x(c,d,{kind:"failed",failure:q.failure});return}const{mergeDraft:W}=await Promise.resolve().then(()=>require("./merge-DSfJceoQ.cjs"));if(!O(c,d)||M.aborted)return;const B=h.get(c);B?.flush();const Q=Ne(q.text),v=W(N.text,d.draft,Q,t());if(N={text:Q,version:q.version},d.base=N,d.ending=ct(q.text),d.draft=v.text,B?.adopt(v.text),v.kind==="conflicts"){x(c,d,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(U=!0,F=v.text,F===N.text){x(c,d,{kind:"saved",merged:U},{dirty:!1,generation:d.value.generation+1});return}k(d,{dirty:!0,generation:d.value.generation+1})}x(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>s.get(c)?.value,subscribe:u.subscribe,start:(c,d)=>{const w=s.get(c);if(w!==void 0){k(w,{request:{anchor:d},view:"editor"}),(w.value.phase.kind==="failed"||w.value.phase.kind==="grant")&&T(c,w);return}i.delete(c);const C={value:{path:c,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:De,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
+ `,controller:new AbortController};s.set(c,C),T(c,C)},retry:c=>{const d=s.get(c);d===void 0||d.value.phase.kind==="editing"||T(c,d)},draft:c=>{const d=s.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const w=s.get(c);if(w===void 0||w.base===null)return;w.draft=d;const C={},M=d!==w.base.text;M!==w.value.dirty&&(C.dirty=M);const{save:N}=w.value;if(N.kind==="conflicts"){const F=at(d).length;F===0?C.save=De:F!==N.count&&(C.save={kind:"conflicts",count:F})}(C.dirty!==void 0||C.save!==void 0)&&k(w,C)},consumeRequest:c=>{const d=s.get(c);d!==void 0&&d.value.request!==null&&k(d,{request:null})},save:g,replaceDraft:(c,d)=>{const w=h.get(c);w?.flush();const C=s.get(c);if(C===void 0||C.base===null)return;const M=Ne(d);C.draft=M,w?.adopt(M),k(C,{dirty:M!==C.base.text,generation:C.value.generation+1})},close:c=>{if(!s.has(c))return;const d=h.get(c),w=d===void 0?null:d.returnPoint();A(c),w===null?i.delete(c):i.set(c,w),u.emit()},takeReturn:c=>{const d=i.get(c)??null;return i.delete(c),d},dirtyPaths:()=>[...s.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)A(d);c.length>0&&u.emit()},editorState:{get:c=>f.get(c),set:(c,d)=>{s.has(c)&&f.set(c,d)}},bindEditor:(c,d)=>j(h,c,d),bindView:(c,d)=>j(m,c,d),viewAnchor:c=>{const d=m.get(c);return d===void 0?null:d.anchor()},flush:c=>h.get(c)?.flush(),flushDrafts:()=>{for(const c of h.values())c.flush()},nextConflict:c=>h.get(c)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:c=>{for(const d of h.values())d.flush();return c.filter(d=>s.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{S?.settle(!1);const w={paths:c,settle:C=>{if(S===w){if(S=null,C)for(const M of c)A(M);u.emit(),d(C)}}};S=w,u.emit()}),discardRequest:()=>S,sideBySide:()=>(p??=r.read(),p),setSideBySide:c=>{p!==c&&(p=c,r.write(c),u.emit())},editorShare:()=>(E??=o.read()??$.EDIT_SPLIT_DEFAULT_PERCENT,E),setEditorShare:c=>{if(!Number.isFinite(c))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(c)}`);const d=Math.min($.EDIT_SPLIT_MAX_PERCENT,Math.max($.EDIT_SPLIT_MIN_PERCENT,c));E!==d&&(E=d,o.write(d))},setView:(c,d)=>{const w=s.get(c);w===void 0||w.value.view===d||(h.get(c)?.beforeView(d),k(w,{view:d,previewPrepared:w.value.previewPrepared||d==="preview"}))},preparePreview:c=>{const d=s.get(c);d!==void 0&&!d.value.previewPrepared&&k(d,{previewPrepared:!0})}}},Ke=e=>{e.preventDefault(),e.stopPropagation()},Vt=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Ut="data-aqmx-content-pane",Se=Object.freeze({[Ut]:""}),rr="--aqmx-dialog-left",or="--aqmx-dialog-top",sr='[data-testid="markdown-explorer"]',ir=e=>{const t=e.closest(sr)?.querySelectorAll(`[${Ut}]`),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},lr=e=>{const t=Vt(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=ir(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:i}=$.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(rr,`${String(s)}px`),e.style.setProperty(or,`${String(i)}px`),n},ar=e=>e.preventDefault(),Zt=({open:e,onOpen:t,onDismiss:n})=>{const r=a.useRef(null),o=a.useRef(null),s=a.useRef(!1),i=a.useRef(t);a.useLayoutEffect(()=>{i.current=t},[t]),a.useLayoutEffect(()=>{s.current=e;const u=r.current;if(u!==null)if(e&&!u.open){const p=u.ownerDocument.activeElement;o.current=p instanceof HTMLElement?p:null,u.showModal(),i.current?.()}else!e&&u.open&&(u.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),a.useLayoutEffect(()=>{const u=r.current;if(!e||u===null)return;const p=new ResizeObserver(()=>S());let E=null;const S=()=>{const O=lr(u);O===null||O===E||(E!==null&&p.unobserve(E),p.observe(O),E=O)};S(),p.observe(u);const k=u.ownerDocument.defaultView;return k?.addEventListener("resize",S),u.ownerDocument.addEventListener("scroll",S,{capture:!0,passive:!0}),()=>{p.disconnect(),k?.removeEventListener("resize",S),u.ownerDocument.removeEventListener("scroll",S,{capture:!0})}},[e]);const f=a.useCallback(u=>{u.key!=="Escape"||u.defaultPrevented||(Ke(u),n())},[n]),h=a.useCallback(u=>{u.target===u.currentTarget&&n()},[n]),m=a.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:f,onClick:h,onCancel:ar,onClose:m}},Gt=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:i,testId:f})=>{const h=a.useRef(null),m=a.useId(),u=a.useId(),p=a.useCallback(()=>h.current?.focus(),[]),E=Zt({open:e,onOpen:p,onDismiss:i});return l.jsx("dialog",{...E,className:"aqmx-confirm","aria-labelledby":m,"aria-describedby":u,"data-testid":f,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:h,type:"button",className:"aqmx-callout-action","data-testid":`${f}-cancel`,onClick:i,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${f}-confirm`,onClick:s,children:r})]})]})})},pe=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},Wt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ue=e=>e.status==="fulfilled"?e.value:void 0,Kt=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),cr=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),dr=(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 i=s.lazy===!0?n(s.path):void 0,f=s.lazy===!0?i?.status==="loaded"?i.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return f;if(f!==null)for(const h of[...f].reverse())o.push(h)}return null},Xt=(e,t,n)=>{const r=ue(e.read(t));if(r===void 0||r.status==="deferred")return Kt;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=dr(r.entries,n,i=>e.children(t,i));if(o!==null)return{readme:{status:"ok",readme:$.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?cr:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:$.folderReadmeOf(s.entries)},claim:!0}},ur=(e,t,n)=>{const{readme:r}=Xt(e,t,n);return r.status==="ok"?r.readme:null},fr=(e,t,n)=>{const r=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=$.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)}},Yt=e=>{const{edits:t}=P(),n=a.useCallback(()=>t.session(e),[t,e]);return a.useSyncExternalStore(t.subscribe,n,mr)},Qt=()=>!1,mr=()=>{},hr=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.hasSessions,Qt)},Jt=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.sideBySide,Qt)},pr=()=>null,vr=()=>{const{edits:e,labels:t,config:n,trees:r}=P(),o=a.useRef([]),s=a.useCallback(({nextLocation:S})=>{const k=fr(n,S,(O,T)=>ur(r,O,T));return e.flushDrafts(),o.current=e.dirtyPaths().filter(O=>!k.has(O)),o.current.length>0},[e,n,r]),i=Y.useBlocker(s),f=hr();a.useEffect(()=>{if(!f)return;const S=k=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(k.preventDefault(),k.returnValue=!0)};return window.addEventListener("beforeunload",S),()=>window.removeEventListener("beforeunload",S)},[f,e]);const h=a.useSyncExternalStore(e.subscribe,e.discardRequest,pr),m=i.state==="blocked",u=m?o.current:h===null?[]:h.paths,p=u.map(S=>D.lastPathSegment(S)).join(", "),E=u.length>0&&u.every(S=>e.session(S)?.save.kind==="draft");return l.jsx(Gt,{open:m||h!==null,title:E?t.draftDiscardTitle:t.unsavedTitle,body:E?t.draftDiscardBody(p):t.unsavedBody(p),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(i.state==="blocked"){e.discard(o.current),i.proceed();return}h?.settle(!0)},onCancel:()=>{if(i.state==="blocked"){i.reset();return}h?.settle(!1)}})};function wr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const gr=y.forwardRef(wr);let Pe=null;const en=()=>(Pe??=Promise.resolve().then(()=>require("./EditSurface-GxmyUeGE.cjs")).catch(e=>{throw Pe=null,e}),Pe),Er=()=>{en().catch(()=>{})},xr=e=>{const{default:t}=a.use(en());return l.jsx(t,{...e})};class Sr extends a.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 Xe=`[${Ie.SOURCE_LINES_ATTRIBUTE}]`,br="[data-aqmd-content]",yr='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], [data-aqmd-spreadsheet-fullscreen]',Rr=200,ve=e=>Ie.parseSourceLines(e.getAttribute(Ie.SOURCE_LINES_ATTRIBUTE)),kr=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=ve(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Xe)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=ve(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Tr=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},tn=e=>e.closest(br)!==null&&e.closest(yr)===null,nn=(e,t,n)=>{const r=kr(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const f=r.lines.last+1;return{lines:{first:f,last:f},word:null,occurrence:0,clientTop:be(e)}}const i=Or(o,n);return i===null?{lines:r.lines,word:null,occurrence:0,clientTop:be(o)}:{lines:r.lines,word:i.text,occurrence:i.occurrence,clientTop:i.clientTop}},rn=(e,t)=>{let n=null,r=null,o=null;for(const i of e.querySelectorAll(Xe)){const f=ve(i);if(f===null)continue;n??=sn(t,i);const{top:h,bottom:m}=i.getBoundingClientRect();h<=n&&n<m?r={lines:f,block:i}:o===null&&h>=n&&(o={lines:f,block:i})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:be(s.block)}},on=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,sn=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return on(e)+(Number.isFinite(n)?n:0)},Or=(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>Rr||/[\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:Tr(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Cr=(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 i=0;for(let f=r;f<=o;f+=1){const h=n[f-1]??"";for(let m=h.indexOf(t.word);m>=0;m=h.indexOf(t.word,m+t.word.length)){if(i===t.occurrence)return{line:f,column:m};i+=1}}return i>0?Lr(n,r,o,t.word)??s:s},Lr=(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},ln=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Xe)){const s=ve(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},an=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=be(e),o=ve(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},be=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:i,height:f}=s.getBoundingClientRect();if(f>0)return i}return e.getBoundingClientRect().top},Ye=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})}),Mr=e=>Ye[e],we=()=>{const e=Y.useNavigate();return a.useCallback((t,n)=>{e(t,Ye[n])},[e])},cn=({navigation:e,...t})=>l.jsx(Y.Link,{...t,...Ye[e]}),Qe=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},dn=(e,t)=>{const n=a.useRef(null),r=a.useRef(null),o=a.useRef(null),s=a.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);a.useEffect(()=>s,[s]);const i=a.useCallback(m=>{if(r.current!==m)return;const u=o.current;if(u!==null){u.then(()=>i(m));return}e.prefetch(m);const p=e.peek(m);if(p?.status!=="pending")return;const E=Promise.allSettled([p.promise]);o.current=E,E.then(()=>{o.current===E&&(o.current=null)})},[e]),f=a.useCallback(m=>{const u=t(m);u!==r.current&&(s(),u!==null&&(r.current=u,n.current=window.setTimeout(()=>{n.current=null,i(u)},$.PREFETCH_DWELL_MS)))},[s,t,i]),h=a.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return a.useMemo(()=>({onPointerOver:m=>f(m.target),onPointerOut:m=>h(m.relatedTarget),onFocus:m=>f(m.target),onBlur:m=>h(m.relatedTarget)}),[f,h])},Ar=a.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-B57yWQVG.cjs")).then(e=>({default:e.NativeScrollBar})));class jr extends a.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 un=({scroller:e,withCircle:t})=>l.jsx(jr,{children:l.jsx(a.Suspense,{fallback:null,children:l.jsx(Ar,{scroller:e,withCircle:t})})}),fn=e=>l.jsx(un,{scroller:e,withCircle:!0}),mn=()=>{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 i=e.get(o);if(i!==void 0&&i>1){e.set(o,i-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},ye=(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,i)=>ye(s,t[i]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&ye(n[s],r[s]))},Nr=55e3,ut=Object.freeze({status:"deferred"}),ft=Object.freeze({status:"refreshed"}),_e=Object.freeze({status:"superseded"}),re=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,hn=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Dr=({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=mn(),o=ae(),s=new WeakSet;let i=0;const f=o.emit,h=()=>(i+=1,i),m=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},u=(x,g)=>{n.delete(x),n.set(x,g)},p=x=>performance.now()-x.validatedAt>=Nr,E=(x,g,c)=>{const d=n.get(x),w=re(d?.snapshot),C=c||d?.refreshPending===!0,M=pe(e.document(x,{refresh:C}).then(F=>({status:"loaded",document:F}))),N={snapshot:{status:"pending",promise:M,previous:w},validatedAt:performance.now(),opened:g,background:null,refreshPending:!1,seeded:void 0,stamp:h()};return u(x,N),m(),M.then(F=>{n.get(x)===N&&(N.snapshot=F,N.stamp=h(),f())}),N},S=(x,g,c,d,w,C)=>{g.background===c&&(g.background=null,!(n.get(x)!==g||g.snapshot!==d)&&(w.kind==="failure"&&d.document.kind!=="failure"||(g.validatedAt=C,g.stamp=h(),ye(d.document,w)||(g.snapshot={status:"loaded",document:w}),f())))},k=async(x,g)=>{const c=g.snapshot;if(c.status!=="loaded")return null;const d={};g.background=d;const w=performance.now(),C=e.document(x,{refresh:g.refreshPending});g.refreshPending=!1;const M=await C,N=g.background===d&&n.get(x)===g&&g.snapshot===c;return S(x,g,d,c,M,w),N?M:null},O=(x,g)=>{const{snapshot:c}=g;return c.status==="pending"?!1:c.status==="loaded"&&c.document.kind!=="failure"?(k(x,g),!1):(c.status==="loaded"&&s.add(c),E(x,!0,!1),!0)},T=x=>{const g=r.hold(x);let c=!1;return()=>{if(c)return;c=!0,g();const d=n.get(x);d!==void 0&&u(x,d),m()}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const g=n.get(x);g!==void 0&&g.snapshot.status!=="deferred"||(E(x,!1,!1),f())},open:x=>{const g=r.resumes(x),c=T(x),d=n.get(x);if(d===void 0||d.snapshot.status==="deferred")return E(x,!0,!1),f(),c;if(u(x,d),g)return c;const{snapshot:w}=d;return w.status==="pending"?(d.opened=!0,c):w.document.kind==="failure"?(d.opened||p(d)?(s.add(w),E(x,!0,!1),f()):d.opened=!0,c):(d.opened=!0,d.background===null&&p(d)&&k(x,d),c)},retain:T,retry:x=>{const g=n.get(x);g===void 0||g.snapshot.status!=="loaded"||g.snapshot.document.kind!=="failure"||(E(x,!0,!1),f())},seed:(x,g)=>{const c=performance.now(),d=pe(g.then(F=>F===null?ut:{status:"loaded",document:F},()=>ut)),w=n.get(x);if(w!==void 0&&w.snapshot.status==="loaded"){const F=w.snapshot,U={};w.background=U,d.then(V=>{if(V.status==="loaded"){S(x,w,U,F,V.document,c);return}w.background===U&&(w.background=null)});return}const C=w!==void 0&&w.snapshot.status==="pending"?w.snapshot.previous:null,M={status:"pending",promise:d,previous:C},N={snapshot:M,validatedAt:c,opened:w?.opened===!0,background:null,refreshPending:w?.refreshPending===!0,seeded:M,stamp:h()};u(x,N),m(),d.then(F=>{n.get(x)===N&&(F.status==="deferred"&&r.isHeld(x)?E(x,N.opened,!1):(N.snapshot=F,N.stamp=h()),f())})},invalidate:()=>{let x=!1;for(const[g,c]of[...n]){if(c.validatedAt=Number.NEGATIVE_INFINITY,c.opened=!0,c.refreshPending=!0,!r.isHeld(g))continue;const{snapshot:d}=c;if(d.status!=="pending"){O(g,c)&&(x=!0);continue}d.promise.then(()=>{n.get(g)===c&&c.refreshPending&&r.isHeld(g)&&O(g,c)&&f()})}x&&f()},refresh:async x=>{const g=n.get(x);if(g!==void 0&&hn(g.snapshot)){g.refreshPending=!0;const d=await k(x,g);return d===null?_e:d.kind==="failure"?{status:"failed",failure:d.failure}:ft}const c=E(x,!0,!0);return f(),c.snapshot.status!=="pending"?_e:(await c.snapshot.promise,n.get(x)===c?ft:_e)},clear:()=>{n.clear();for(const x of r.heldKeys())E(x,!0,!1);f()},subscribe:o.subscribe,noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}};function Pr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const _r=y.forwardRef(Pr);function Fr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const $r=y.forwardRef(Fr);function qr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const Ir=y.forwardRef(qr),Br=2e3,mt=Object.freeze({outcome:"idle"}),zr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Hr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=a.useState(mt);a.useEffect(()=>{if(r.outcome==="idle")return;const h=setTimeout(()=>o(mt),Br);return()=>clearTimeout(h)},[r]);const s=h=>{o({outcome:h}),t.announce(h==="copied"?n.copiedText:n.copyTextFailed)},i=()=>{zr(e).then(()=>s("copied"),()=>s("failed"))},f=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:f,onClick:i,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(_r,{}):r.outcome==="failed"?l.jsx(Ir,{}):l.jsx($r,{})})},le=a.createContext("fill"),Vr=Object.freeze({blockSize:"100%"}),ce=({scrollerProps:e,children:t})=>a.use(le)==="content"?l.jsx(me.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(me.HostedScrollArea,{scrollerProps:{...e,style:Vr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:fn,children:t});function Ur({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),y.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const Zr=y.forwardRef(Ur);function Gr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const Wr=y.forwardRef(Gr),Te=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=P();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(Wr,{})}),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(Zr,{})})]})};function Kr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Xr=y.forwardRef(Kr),Yr=Object.freeze({className:"aqmx-document-stage"}),Qr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Xr,{})}),l.jsx(ce,{scrollerProps:Yr,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})]})})]})},Oe="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Jr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},eo=/(%[0-9A-Fa-f]{2})/u,Je=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(eo).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},pn=e=>`#${encodeURIComponent(e)}`,to=e=>{if(e==="#")return!0;const t=Je(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},vn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},no="http://www.w3.org/1999/xhtml",ht=(e,t)=>{if(t==="")return null;const n=vn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===no&&r.getAttribute("name")===t)return r;return null},wn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=ht(e,t.slice(1));if(n!==null)return n;const r=Je(t);return r===null?null:ht(e,r)},pt=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"},ro=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"},oo=(e,t)=>{const n=t.closest(Oe),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&pt(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:i}=e.ownerDocument;for(let f=e.parentElement;f!==null&&f!==s;f=f.parentElement)if(pt(f)&&f.scrollHeight>f.clientHeight&&f.clientHeight<o)return f;return i instanceof Element&&ro(e.ownerDocument)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o?i:r},so=Object.freeze({scrollerOf:oo,reveal:e=>{e.scrollIntoView(Ve)}}),Ve=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),io=(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")}}},lo=(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),i=t.getBoundingClientRect(),f=i.height+s+Number.parseFloat(o)>e.clientHeight;if(!f&&Math.abs(i.top-s-n)<1){t.scrollIntoView(Ve);return}e.scrollBy({top:f?i.top-n-e.clientHeight:i.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ve)},ao=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Oe)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},vt=(e,t,n)=>{if(e===null)return null;const r=wn(e,t);return r===null?(to(t)&&ao(e,n),null):(io(e,r),lo(n.scrollerOf(e,r),r),n.reveal(r),r)};function co({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const uo=y.forwardRef(co);function fo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),y.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const mo=y.forwardRef(fo);function ho({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const po=y.forwardRef(ho);function vo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const wo=y.forwardRef(vo),Ue="data-aqmx-key-repeat",Re=Object.freeze({[Ue]:"allow"}),go=`[${Ue}="${Re[Ue]}"]`,Eo=()=>{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(go)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/$.GOLDEN_RATIO**2,1/$.GOLDEN_RATIO,1,$.GOLDEN_RATIO,$.GOLDEN_RATIO**2]),wt=Object.freeze({mode:"fit"}),xo=1,gn=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),gt=`[data-testid="${gn["data-testid"]}"]`,En=a.createContext(null),So=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=xo?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Et=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<xe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?xe.findIndex(o=>o>t):xe.findLastIndex(o=>o<t);return r===-1?null:r},xt=(e,t,n)=>{if(e.mode==="level"){const o=Et(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Et(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},bo=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log($.GOLDEN_RATIO));return n===0?0:n},St=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}}},yo=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},bt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Ro=({document:e})=>{const{labels:t}=P(),n=a.use(En),[r]=a.useState(()=>n===null?null:n.read(e.url)),[o,s]=a.useState(r===null?wt:r.zoom),[i,f]=a.useState(r===null?null:r.reported),[h,m]=a.useState(null),u=a.useRef(null),p=a.useCallback(g=>{const{naturalWidth:c,naturalHeight:d}=g;f(w=>bt(w,c,d))},[]),E=a.useCallback(g=>{u.current=g,!(g===null||!g.complete)&&(g.naturalWidth>0||g.naturalHeight>0?p(g):g.decode().then(()=>p(g),()=>{}))},[p]);a.useEffect(()=>{n!==null&&i!==null&&n.save(e.url,{zoom:o,reported:i})},[n,e.url,o,i]),a.useLayoutEffect(()=>{const g=u.current;if(g===null||i===null||o.mode!=="fit")return;const c=()=>m(w=>bt(w,g.clientWidth,g.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(g),()=>d.disconnect()},[i,o.mode]);const S=i===null||h===null?null:So(i,h),k=xt(o,S,-1),O=xt(o,S,1),T=o.mode==="level"?yo(o.index):null,A=a.useRef({zoomIn:O,zoomOut:k});a.useLayoutEffect(()=>{A.current={zoomIn:O,zoomOut:k}});const j=a.useRef(null);a.useLayoutEffect(()=>{const g=j.current,c=u.current?.closest(gt);j.current=null,!(g===null||c===null||c===void 0)&&(c.scrollLeft=g.across*c.scrollWidth-g.x,c.scrollTop=g.down*c.scrollHeight-g.y)},[o]),a.useEffect(()=>{const g=u.current?.closest(gt);if(g==null)return;let c=null;const d=M=>{const N=St(M.touches);c=N===null?null:{distance:N.distance,steps:0}},w=M=>{const N=St(M.touches);if(c===null||N===null)return;M.preventDefault();const F=bo(c.distance,N.distance);if(F===c.steps)return;const U=F>c.steps?1:-1,V=U===1?A.current.zoomIn:A.current.zoomOut;if(V===null)return;c.steps+=U;const q=g.getBoundingClientRect(),W=N.middle.x-q.left,B=N.middle.y-q.top;j.current=g.scrollWidth>0&&g.scrollHeight>0?{x:W,y:B,across:(g.scrollLeft+W)/g.scrollWidth,down:(g.scrollTop+B)/g.scrollHeight}:null,s(V)},C=M=>{M.touches.length<2&&(c=null)};return g.addEventListener("touchstart",d,{passive:!0}),g.addEventListener("touchmove",w,{passive:!1}),g.addEventListener("touchend",C,{passive:!0}),g.addEventListener("touchcancel",C,{passive:!0}),()=>{g.removeEventListener("touchstart",d),g.removeEventListener("touchmove",w),g.removeEventListener("touchend",C),g.removeEventListener("touchcancel",C)}},[]);const x=o.mode==="level"&&T!==null?{width:`${o.base.width*T}px`,height:`${o.base.height*T}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(wo,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":k===null,onClick:()=>{k!==null&&s(k)},...Re,children:l.jsx(mo,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:T===null?t.imageFitLevel:t.imageZoomLevel(Math.round(T*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":O===null,onClick:()=>{O!==null&&s(O)},...Re,children:l.jsx(po,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(wt),children:l.jsx(uo,{})})]}),l.jsx(ce,{scrollerProps:gn,children:l.jsx("img",{ref:E,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:x,onLoad:g=>p(g.currentTarget),"data-testid":"markdown-explorer-image"})})]})},xn=a.createContext(null),Ce=a.createContext(void 0),Sn=a.createContext(null),Le=()=>{const e=a.use(xn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},ko=()=>{const e=a.use(Sn);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Me=(e,t,n,r)=>t.kind==="panel"?$.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?$.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):$.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),To=({children:e})=>{const{config:t}=P(),n=Le(),r=ke(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Me(t,n.navigation,o,n.currentPath));return l.jsx(Ce,{value:o,children:l.jsx(Sn,{value:s,children:e})})},Oo='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Co=e=>{const t=e instanceof Element?e.closest(Oo):null;return t===null?null:t.getAttribute("data-doc-path")},Ae=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Lo=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:i,scope:f,children:h})=>{const m=Y.useHref(e),u=p=>{if(Ae(p)){if(p.preventDefault(),t===f.currentPath&&n!==""){f.scrollWithin(n);return}i(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:h})},Mo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:i}=P(),f=Le(),h=a.use(Ce),m=Jr(e),{navigation:u}=f,p=`${Me(i,u,h,t)}${m}`,E=n===!1?"false":void 0;return u.kind==="page"?l.jsx(cn,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":E,children:s}):l.jsx(Lo,{to:p,docPath:t,fragment:m,exists:E,className:r,attributes:o,onDocumentLink:u.onDocumentLink,scope:f,children:s})},Ao=({className:e,attributes:t,children:n})=>{const{labels:r}=P();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,")"]})]})},jo=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),i=a.use(Ce),f=Y.useHref(`${Me(s,r.navigation,i,r.currentPath)}${e}`),h=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:f,className:t,onClick:h,children:o})},No=({href:e,className:t,attributes:n,children:r})=>{const o=Le();if(o.navigation.kind==="page"){const s=i=>{if(!Ae(i))return;const f=i.currentTarget;e==="#"?o.followEmptyFragment(i.nativeEvent):f.href===f.ownerDocument.URL&&o.followSameUrlJump(e,i.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(jo,{href:e,className:t,attributes:n,scope:o,children:r})},Do=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:i})=>t==="doc"?n===void 0||!D.isAcceptableDocumentPath(n)?l.jsx(Ao,{className:o,attributes:s,children:i}):l.jsx(Mo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:i}):e.startsWith("#")?l.jsx(No,{href:e,className:o,attributes:s,children:i}):l.jsx("a",{...s,href:e,className:o,children:i}),Po=()=>{const{config:e}=P(),t=Le(),n=a.use(Ce),r=we();return a.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const i=pn(o.id),{navigation:f}=t;return f.kind==="panel"||Je(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(i),!0):(r(`${Me(e,f,n,t.currentPath)}${i}`,"follow-link"),!0)},[e,t,n,r])},_o=()=>{const e=ko();return a.useCallback(t=>`${e}${pn(t.id)}`,[e])};function Fo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const $o=y.forwardRef(Fo);function qo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Io=y.forwardRef(qo);function Bo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const zo=y.forwardRef(Bo),Ho=Object.freeze({className:"aqmx-document-stage"}),Vo=()=>()=>{},Uo=()=>navigator.pdfViewerEnabled!==!1,Zo=()=>null,Go=({document:e})=>{const{labels:t}=P(),n=a.useSyncExternalStore(Vo,Uo,Zo);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})]})]})},Wo=e=>{switch(e){case"video":return l.jsx(Io,{});case"audio":return l.jsx(zo,{});case"pdf":return l.jsx($o,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ko=({document:e})=>{const{labels:t}=P();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(Go,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Xo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Wo(e.mediaType)}),l.jsx(ce,{scrollerProps:Ho,children:l.jsx(Ko,{document:e})})]}),Yo=e=>({loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,defaultErrorTitle:e.viewerErrorTitle,missingImage:e.viewerMissingImage,openTocAria:e.viewerOpenToc,tocTitle:e.viewerTocTitle,pinTocAria:e.viewerPinToc,unpinTocAria:e.viewerUnpinToc,selectAlignAria:e.viewerSelectAlign,alignTitle:e.viewerAlignTitle,pinAlignAria:e.viewerPinAlign,unpinAlignAria:e.viewerUnpinAlign,alignLeft:e.viewerAlignLeft,alignCenter:e.viewerAlignCenter,alignRight:e.viewerAlignRight,mermaidInteractionMode:e.viewerMermaidInteractionMode,mermaidInteractionModeTouch:e.viewerMermaidInteractionModeTouch,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidModeNoneTouch:e.viewerMermaidModeNoneTouch,mermaidModeZoomTouch:e.viewerMermaidModeZoomTouch,mermaidModePanTouch:e.viewerMermaidModePanTouch,mermaidModeBothTouch:e.viewerMermaidModeBothTouch,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidPanUp:e.viewerMermaidPanUp,mermaidPanDown:e.viewerMermaidPanDown,mermaidPanLeft:e.viewerMermaidPanLeft,mermaidPanRight:e.viewerMermaidPanRight,mermaidDiagram:e.viewerMermaidDiagram,mermaidRetry:e.viewerMermaidRetry,spreadsheetTable:e.viewerSpreadsheetTable,spreadsheetZoomIn:e.viewerSpreadsheetZoomIn,spreadsheetZoomOut:e.viewerSpreadsheetZoomOut,spreadsheetResetZoom:e.viewerSpreadsheetResetZoom,spreadsheetHighlight:e.viewerSpreadsheetHighlight,spreadsheetCopyAll:e.viewerSpreadsheetCopyAll,spreadsheetSaveTsv:e.viewerSpreadsheetSaveTsv,spreadsheetSaveMenu:e.viewerSpreadsheetSaveMenu,spreadsheetSaveTsvWithBom:e.viewerSpreadsheetSaveTsvWithBom,spreadsheetFullscreen:e.viewerSpreadsheetFullscreen,spreadsheetExitFullscreen:e.viewerSpreadsheetExitFullscreen,spreadsheetFullscreenDialog:e.viewerSpreadsheetFullscreenDialog,spreadsheetSize:e.viewerSpreadsheetSize,spreadsheetFileName:e.viewerSpreadsheetFileName,spreadsheetCopied:e.viewerSpreadsheetCopied,spreadsheetCopyFailed:e.viewerSpreadsheetCopyFailed,spreadsheetCellAnnouncement:e.viewerSpreadsheetCellAnnouncement,spreadsheetEmptyCell:e.viewerSpreadsheetEmptyCell,spreadsheetSelectionAnnouncement:e.viewerSpreadsheetSelectionAnnouncement,spreadsheetReadOnly:e.viewerSpreadsheetReadOnly,spreadsheetFormatRefused:e.viewerSpreadsheetFormatRefused,spreadsheetFenceRefused:e.viewerSpreadsheetFenceRefused,spreadsheetEditConflict:e.viewerSpreadsheetEditConflict,spreadsheetOptionsError:e.viewerSpreadsheetOptionsError,spreadsheetLoadFailed:e.viewerSpreadsheetLoadFailed,spreadsheetRetry:e.viewerSpreadsheetRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame}),bn=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},yn=(e,t)=>e!==void 0?e:t!==void 0?t:Bn.DEFAULT_CONTENT_ALIGN,Rn=Object.freeze({kind:"empty"}),et=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Qo=(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 $.explorerHref(e,{...t,overrides:r})},fe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:i,children:f})=>{const h=a.use(le);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":h,className:"aqmx-document",...i,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,f]})},Jo=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=P(),s=e.kind==="no-readme"?e.folder:null,i=e.kind==="failure"?e.folder:null,f=e.kind==="failure"?e.failure:null;switch(a.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(D.lastPathSegment(s)))},[t,s,o,r]),a.useEffect(()=>{i!==null&&f!==null&&n(r.documentFailed(D.lastPathSegment(i),ee(r,f.reason)))},[i,f,n,r]),e.kind){case"empty":return l.jsx(fe,{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(tt,{label:r.documentRegion});case"no-readme":return l.jsx(fe,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(D.lastPathSegment(e.folder))})})});case"failure":return l.jsx(fe,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:e.failure,alert:!1,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})})}},tt=({label:e})=>{const{labels:t}=P();return l.jsxs(fe,{kind:"loading",label:e,stale:!1,busy:!0,children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:et.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},yt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),es=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),i=a.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),f=Po(),h=_o(),m=a.useMemo(()=>o===void 0?void 0:c=>o(e,c),[o,e]),u=a.useRef(null),{editable:p,doubleClick:E,region:S,paneScroll:k,stale:O}=r;a.useLayoutEffect(()=>{if(p)return s.bindView(e,{anchor:()=>{const c=u.current,d=S(),w=c===null?null:c.querySelector(Oe);return c===null||d===null||w===null?null:rn(c,k.scrollerOf(d,w))}})},[s,e,p,S,k]);const T=c=>{const d=u.current,{target:w}=c;!E||d===null||!(w instanceof Element)||!tn(w)||(c.stopPropagation(),s.start(e,nn(w,d,d.ownerDocument.getSelection())))},A=a.useRef(null),j=a.useRef(O);a.useLayoutEffect(()=>{j.current=O});const x=a.useEffectEvent(c=>{const d=u.current,w=S(),C=d===null?null:ln(d,c.line);if(w===null||C===null)return!1;const M=k.scrollerOf(w,C);return M.scrollTop+=an(C,c.line)-c.clientTop,!0}),g=a.useEffectEvent(c=>{const d=S();if(d===null)return;const w=()=>{for(const M of yt)d.removeEventListener(M,C,!0);A.current?.release===w&&(A.current=null)},C=()=>w();for(const M of yt)d.addEventListener(M,C,{capture:!0,passive:!0});A.current={point:c,release:w}});return a.useLayoutEffect(()=>{const c=s.takeReturn(e);if(c!==null)return queueMicrotask(()=>{x(c)&&j.current&&g(c)}),()=>A.current?.release()},[s,e]),a.useLayoutEffect(()=>{const c=A.current;c===null||O||(c.release(),x(c.point))},[t,O]),l.jsx("div",{ref:u,className:"aqmx-document-viewer",onDoubleClick:T,children:l.jsx(me.MarkdownViewer,{...n,onHeadingSelect:f,headingHref:h,onMathDiagnostics:m,parseResult:i,content:null})})},kn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(Te,{name:e.name,openUrl:D.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(gr,{}),children:e.truncated?null:l.jsx(Hr,{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(me.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},ts=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:i}=P(),f=a.useCallback(()=>o.answerStampOf(e),[o,e]),h=a.useSyncExternalStore(o.subscribe,f,f),[m,u]=a.useState(0),p=a.useMemo(()=>({path:e,stamp:h,attempt:m}),[e,h,m]),[E,S]=a.useState(null),k=a.useEffectEvent(T=>{S(T),T.kind==="failure"&&s.announce(i.documentFailed(t,ee(i,T.failure.reason)))});a.useEffect(()=>{const T=new AbortController;return r.text(p.path,T.signal).then(A=>{"kind"in A&&k(A)}),()=>T.abort()},[r,p]);const O=a.useCallback(()=>u(T=>T+1),[]);return E===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:et.map(T=>l.jsx("span",{},T))}),l.jsx("p",{className:"aqmx-sr-only",children:i.markupLoading})]}):E.kind==="failure"?l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:E.failure,alert:!1,onRetry:O,testId:"markdown-explorer-markup-failure"})}):l.jsx(kn,{document:E,viewer:n})},nt=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ns=Object.freeze({reason:"failed"}),rs=e=>l.jsx(Sr,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(se,{failure:ns,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(a.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:et.map(t=>l.jsx("span",{},t))}),children:l.jsx(xr,{...e})})}),os=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:i,layout:f,region:h,paneScroll:m,stale:u}=s;if(n==="edit"&&i!==void 0)return l.jsx(rs,{path:e,name:t.name,session:i,layout:f,viewer:r,region:h,paneScroll:m});if(n==="markup")return l.jsx(ts,{path:e,name:t.name,viewer:r});const p=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(es,{path:e,document:t,viewer:r,editing:{editable:p,doubleClick:p&&f==="fill",region:h,paneScroll:m,stale:u}})}case"text":return l.jsx(kn,{document:t,viewer:r});case"image":return l.jsx(Ro,{document:t});case"media":return l.jsx(Xo,{document:t});case"file":return l.jsx(Qr,{document:t});case"failure":return l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const i=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(i)}`)}}},ss='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',is=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:wn(e,n),r===void 0?null:vn(e,r.id),e.querySelector(Oe),e.querySelector(ss)];for(const s of o)if(s instanceof HTMLElement&&Qe(s))return s;return null},Rt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Qe(t)},ls=e=>{const t=a.useRef(!1);return a.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,i;const f=E=>{s=!(E.target instanceof Node&&n.contains(E.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(i),i=setTimeout(()=>{s=!1},0)},h=E=>{t.current=E.target instanceof Node&&n.contains(E.target)},m=E=>{E.relatedTarget===null&&s&&(t.current=!1)},u=()=>{const{activeElement:E,body:S}=r;E!==null&&E!==S&&(t.current=n.contains(E))},p=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",f,!0),o.addEventListener("mousedown",f,!0),o.addEventListener("focusin",h,!0),o.addEventListener("blur",u),o.addEventListener("focus",p),n.addEventListener("focusout",m),()=>{clearTimeout(i),o.removeEventListener("pointerdown",f,!0),o.removeEventListener("mousedown",f,!0),o.removeEventListener("focusin",h,!0),o.removeEventListener("blur",u),o.removeEventListener("focus",p),n.removeEventListener("focusout",m)}},[e]),t},as=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:i,navigation:f,fragment:h,paneScroll:m,announces:u,announceFailure:p,onDocumentShown:E})=>{const{labels:S,announcer:k,documents:O}=P(),{document:T}=t,A=a.useRef(null),j=a.useRef(null),x=a.useRef(null),g=a.useRef(0),c=ls(A),d=a.useRef({path:e,document:T}),w=a.useRef(null),C=a.useCallback(H=>{const G=A.current,K=vt(G,H,m);G!==null&&K!==null&&Rt(G,K,c.current)},[m,c]),M=a.useCallback((H,G)=>{const K=g.current;setTimeout(()=>{!G.defaultPrevented&&g.current===K&&C(H)},0)},[C]),N=a.useCallback(H=>{setTimeout(()=>{H.defaultPrevented||C("#")},0)},[C]),F=a.useMemo(()=>({navigation:f,currentPath:e,scrollWithin:C,followSameUrlJump:M,followEmptyFragment:N}),[f,e,C,M,N]),U=a.useCallback(()=>O.retry(e),[O,e]),V=dn(O,Co),q=Yt(e),W=q!==void 0?"edit":n?"markup":"rendered",B=T.kind==="markdown"?W:void 0,Q=a.useCallback(()=>A.current,[]),v=a.useMemo(()=>({session:q,layout:s,region:Q,paneScroll:m,stale:r}),[q,s,Q,m,r]),b=B==="edit"?!1:r,R=a.use(le),L=B==="edit"&&s==="fill"?"fill":R,_=a.useEffectEvent((H,G)=>{const K=j.current;if(K!==null&&K.path===H&&K.snapshot===G)return;j.current={path:H,snapshot:G};const J=G.document;if(J.kind==="failure"){O.noteFailureShown(G)&&p(S.documentFailed(D.lastPathSegment(H),ee(S,J.failure.reason)));return}E?.(H,J),u&&(K===null||K.path!==H||K.snapshot.document.kind==="failure")&&k.announce(S.documentShown(J.name))});a.useEffect(()=>{_(e,t)},[e,t]);const I=a.useEffectEvent(()=>{h.kind==="panel"&&h.consume()}),Z=a.useEffectEvent(H=>{const G=A.current;if(G===null||!c.current)return null;const{activeElement:K,body:J}=G.ownerDocument;return K!==null&&K!==J?null:is(G,T,H)}),z=a.useEffectEvent(H=>{const G=A.current;G!==null&&Rt(G,H,c.current)}),te=a.useEffectEvent(H=>m.reveal(H)),ot=a.useEffectEvent(H=>vt(A.current,H,m));return a.useEffect(()=>{if(r)return;const H=d.current.path!==e,G=H||d.current.document!==T;d.current={path:e,document:T};const K=w.current!==e;w.current=e;let J=null;h.kind==="page"?x.current!==h.navigation&&(x.current=h.navigation,g.current+=1,J=h.fragment):h.fragment!==null&&(J=h.fragment,I());const st=()=>{const je=J===null?null:ot(J);if(!G){je!==null&&z(je);return}const it=Z(h.fragment);H&&je===null&&it!==null&&te(it)};K?queueMicrotask(st):st()},[h,e,T,r]),l.jsx(le,{value:L,children:l.jsx(fe,{kind:T.kind,view:B,label:i(e,T),stale:b,busy:b,frameRef:A,intent:V,children:l.jsx(xn,{value:F,children:l.jsx(To,{children:l.jsx(os,{path:e,document:T,view:W,viewer:o,onRetry:U,editing:v},e)})})})})},rt=Object.freeze({kind:"skeleton"}),cs=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=re(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 i=n===null||n===e?null:re(r);return n===null||i===null?rt:{kind:"document",path:n,snapshot:i,stale:!0}},ds=(e,t)=>t.status==="deferred"?rt:{kind:"document",path:e,snapshot:t,stale:!1},us=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?ds(t.path,a.use(t.promise)):t;return o.kind!=="document"?l.jsx(tt,{label:r.regionLabel(e,null)}):l.jsx(as,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Tn=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:i,announces:f,announceFailure:h,onDocumentShown:m})=>{const{config:u,labels:p,locale:E,theme:S,documents:k}=P(),O=me.useMarkdownToolbarState(),T=a.useRef(!1);a.useLayoutEffect(()=>{T.current=!0},[]);const[A,j]=a.useState(null),[x,g]=a.useState(n),c=a.useCallback(()=>e===null?void 0:k.peek(e),[k,e]),d=a.useSyncExternalStore(k.subscribe,c,c),w=a.useCallback(()=>A===null?void 0:k.peek(A),[k,A]),C=a.useSyncExternalStore(k.subscribe,w,w);a.useLayoutEffect(()=>e===null?void 0:k.open(e),[k,e]),a.useLayoutEffect(()=>A===null?void 0:k.retain(A),[k,A]);const M=e===null?rt:cs(e,d,A,C,!T.current),N=e===null?null:M.kind==="document"&&!M.stale?M.path:A;N!==A&&j(N);const F=M.kind!=="document"||M.path===e;F&&n!==x&&g(n);const U=a.useMemo(()=>Yo(p),[p]),V=a.useMemo(()=>[...u.iframeHosts],[u]),q=o.kind==="panel",W=a.useMemo(()=>({labels:U,spreadsheetLocale:E,emptyMessage:p.documentEmpty,theme:S,availableStyles:u.documentStyles,iFrameAllowedDomains:V,embeds:u.embeds,linkComponent:Do,toolbar:O,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:q?void 0:fn}),[U,E,p.documentEmpty,S,u.documentStyles,V,u.embeds,O,r,q]),B=a.useCallback((v,b)=>q?b===null||b.kind==="failure"?D.lastPathSegment(v):b.name:p.documentRegion,[q,p.documentRegion]),Q=q?"content":"fill";return e===null?l.jsx(le,{value:Q,children:l.jsx(Jo,{absence:t,announces:f,announceFailure:h})}):l.jsx(le,{value:Q,children:l.jsx(a.Suspense,{fallback:l.jsx(tt,{label:B(e,null)}),children:l.jsx(us,{requestedPath:e,content:M,markup:F?n:x,viewer:W,editLayout:r.editLayout,regionLabel:B,navigation:o,fragment:s,paneScroll:i,announces:f,announceFailure:h,onDocumentShown:m})})})},fs=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:i,announcer:f}=P(),h=he(M=>M.style),m=he(M=>M.align),u=we(),p=Y.useLocation(),E=ke(),{view:S,overrides:k,embed:O}=r,T=a.useCallback(M=>{if(E.kind!=="location")return;const N=Qo(s,E.location,M);N!==null&&u(N,"browse")},[s,u,E]),A=a.useCallback(M=>{i.update({style:M}),T("style")},[i,T]),j=a.useCallback(M=>{i.update({align:M}),T("align")},[i,T]),x=bn(s,k.style,h),g=yn(k.align,m),c=a.useMemo(()=>({style:x,onStyleChange:A,align:g,onAlignChange:j,showToc:O.showToc!==!1,showStyle:O.showStyle!==!1,showAlign:O.showAlign!==!1,padding:O.padding,width:O.width,maxWidth:O.maxWidth,editLayout:"fill"}),[x,A,g,j,O]),d=a.useMemo(()=>({kind:"page",view:S,overrides:k,embed:O}),[S,k,O]),w=a.useMemo(()=>({kind:"page",fragment:p.hash,navigation:p}),[p]),C=a.useCallback(M=>f.announce(M),[f]);return l.jsx(Tn,{path:e,absence:t,markup:n,display:c,navigation:d,fragment:w,paneScroll:so,announces:!0,announceFailure:C,onDocumentShown:o})},ms=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:i}=P(),f=he(d=>d.style),h=he(d=>d.align),[m,u]=a.useState(()=>bn(s,void 0,f)),p=yn(void 0,h),E=a.useCallback(d=>i.update({align:d}),[i]),{maximized:S,onDocumentLink:k,pendingHash:O,onHashConsumed:T,announceFailure:A,paneScroll:j}=r,x=a.useMemo(()=>({style:m,onStyleChange:u,align:p,onAlignChange:E,showToc:S,showStyle:S,showAlign:S,padding:void 0,width:void 0,maxWidth:void 0,editLayout:S?"fill":"content"}),[m,p,E,S]),g=a.useMemo(()=>({kind:"panel",onDocumentLink:k}),[k]),c=a.useMemo(()=>({kind:"panel",fragment:O,consume:T}),[O,T]);return l.jsx(Tn,{path:e,absence:t,markup:n,display:x,navigation:g,fragment:c,paneScroll:j,announces:!1,announceFailure:A,onDocumentShown:o})},On=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(fs,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(ms,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function hs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const Cn=y.forwardRef(hs);function ps({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Ln=y.forwardRef(ps);function vs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const ws=y.forwardRef(vs);function gs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Es=y.forwardRef(gs);function xs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const Ss=y.forwardRef(xs);function bs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const ys=y.forwardRef(bs);function Rs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const Mn=y.forwardRef(Rs);function ks({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),y.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ts=y.forwardRef(ks);function Os({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"}))}const Cs=y.forwardRef(Os),An=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,i]=a.useState(!1),f=()=>{o===void 0||s||(i(!0),o(e).then(h=>{h&&t()}).finally(()=>i(!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:f,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Ls="Control+E Meta+E",jn=(e,t,n)=>n&&t?"split":e.view,Ze=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Ms=e=>e==="split"?null:e,Nn=e=>e==="preview"?"editor":"preview",Dn=e=>/Mac|iPhone|iPad|iPod/u.test(e),Pn=(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)},kt=(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)},As=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:i,locale:f,announcer:h}=P(),m=a.useId(),[u,p]=a.useState(null),[E,S]=a.useState(0),[k,O]=a.useState(null),[T,A]=a.useState(null),j=a.useMemo(()=>new Intl.DateTimeFormat(f,{dateStyle:"medium",timeStyle:"short"}),[f]),x=a.useCallback(()=>{O(null),A(null)},[]),g=Zt({open:n,onOpen:x,onDismiss:r});a.useEffect(()=>{if(!n)return;const w=new AbortController;return p(null),o.revisions(e,w.signal).then(C=>{"kind"in C&&p(C)}),()=>w.abort()},[n,o,e,E]),a.useEffect(()=>{if(!n||k===null)return;const w=new AbortController;return A(null),o.revision(e,k,w.signal).then(C=>{"kind"in C&&A(C)}),()=>w.abort()},[n,o,e,k]);const c=()=>{T===null||T.kind!=="revision"||(s.replaceDraft(e,T.text),h.announce(i.historyRestored(t)),r())},d=u!==null&&u.kind==="revisions"?u.revisions.find(w=>w.id===k):void 0;return l.jsx("dialog",{...g,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:i.historyTitle(t)}),u===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:i.historyLoading}):u.kind==="failure"?l.jsx(se,{failure:u.failure,alert:!1,onRetry:()=>S(w=>w+1),testId:"markdown-explorer-history-failure"}):u.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:i.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:u.revisions.map(w=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":w.id===k,"data-testid":"markdown-explorer-history-entry",onClick:()=>O(w.id),children:[l.jsx("span",{children:kt(w,j,i.historyEntry)}),w.current?l.jsx("span",{className:"aqmx-history-mark",children:i.historyCurrent}):null,w.kept?l.jsx("span",{className:"aqmx-history-mark",children:i.historyKept}):null]})},w.id))}),k===null?null:T===null?l.jsx("p",{className:"aqmx-history-note",children:i.historyLoading}):T.kind==="failure"?l.jsx(se,{failure:T.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":d===void 0?i.historyTitle(t):kt(d,j,i.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:T.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:i.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":T===null||T.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:c,children:i.historyRestore})]})]})})},js=e=>{const{documents:t}=P(),n=a.useCallback(()=>t.peek(e),[t,e]),r=a.useCallback(()=>t.peekSeeded(e),[t,e]),o=a.useSyncExternalStore(t.subscribe,n,r),s=re(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:D.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Ns=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:i,labels:f}=P(),h=a.useSyncExternalStore(i.subscribe,()=>i.session(e)!==void 0,()=>!1),[m,u]=a.useState(null),p=()=>{if(!h){i.start(e,i.viewAnchor(e));return}i.flush(e);const O=i.session(e);O?.dirty===!0?u(O.save.kind==="draft"?"draft":"unsaved"):i.close(e)},E=()=>{h||(Er(),r&&i.sideBySide()&&s?.prepare?.())},S=n?o?f.editDraftDocumentNamed(t):f.editDocumentNamed(t):null,k=o?f.editDraftDocument:f.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:S===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h?f.closeEditor:S===null?k:S,"aria-label":S===null?void 0:S,"aria-pressed":h,"data-testid":"markdown-explorer-document-edit",onClick:p,onDoubleClick:ne,onPointerEnter:E,onFocus:E,children:[l.jsx(Ts,{"aria-hidden":"true"}),S===null?l.jsx("span",{children:f.editDocumentLabel}):null]}),l.jsx(Gt,{open:m!==null,title:m==="draft"?f.draftDiscardTitle:f.unsavedTitle,body:m==="draft"?f.draftDiscardBody(t):f.unsavedBody(t),confirmLabel:f.unsavedDiscard,cancelLabel:f.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(null),i.close(e)},onCancel:()=>u(null)})]})},Ds=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),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:ne,children:[l.jsx(ws,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Ps=({session:e})=>{const{labels:t}=P(),n=Xn(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})},_s=Object.freeze(["editor","split","preview"]),Fs=Object.freeze(["editor","preview"]),$s=Object.freeze({editor:Ln,split:Cs,preview:Mn}),qs=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:i,labels:f}=P(),h=Jt(),m=jn(r,h,o),u=o?_s:Fs,p=a.useId(),E=a.useRef(new Map),S={editor:{label:f.editViewEditor,tooltip:f.editViewEditorTooltip},split:{label:f.editViewSplit,tooltip:f.editViewSplitTooltip},preview:{label:f.editViewPreview,tooltip:f.editViewPreviewTooltip}},k=()=>{i.preparePreview(e),s?.prepare?.()},O=T=>{if(!Pn(T.nativeEvent,Dn(navigator.platform)))return;Ke(T);const A=Nn(m);Ze(i,e,A,o),E.current.get(A)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?f.editViewNamed(t):f.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:O,children:u.map(T=>{const A=$s[T],{label:j,tooltip:x}=S[T],g=T==="preview"?k:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:c=>{c===null?E.current.delete(T):E.current.set(T,c)},type:"radio",name:p,value:T,checked:T===m,"aria-label":j,"aria-keyshortcuts":T==="split"?void 0:Ls,title:x,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>Ze(i,e,T,o),onDoubleClick:ne,onPointerEnter:g,onFocus:g}),l.jsx(A,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:j})]},T)})})},Is=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:i}=P(),[f,h]=a.useState(!1);if(r.phase.kind!=="editing")return null;const m=r.save.kind==="saving",u=m||!r.dirty,p=()=>{s.flush(e);const S=s.session(e);S===void 0||!S.dirty||S.save.kind==="saving"||s.save(e)},E=S=>n?{className:"aqmx-icon-button","aria-label":S}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...E(i.conflictNext),title:i.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Es,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.conflictNext})]}):null,l.jsx(qs,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...E(i.historyOpen),title:i.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>h(!0),onDoubleClick:ne,children:[l.jsx(Ss,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...E(i.saveDraft),title:i.saveDraftTooltip,"aria-disabled":u,"aria-busy":m,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:p,onDoubleClick:ne,children:[l.jsx(ys,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.saveDraft})]}),r.history?l.jsx(As,{path:e,documentName:t,open:f,onClose:()=>h(!1)}):null]})},Bs=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(An,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},zs=e=>{const{documents:t}=P(),n=a.useCallback(()=>t.peek(e),[t,e]),r=a.useCallback(()=>t.peekSeeded(e),[t,e]),o=a.useSyncExternalStore(t.subscribe,n,r);return re(o)?.document.kind==="markdown"},_n=e=>{const{config:t}=P(),n=we(),r=a.useCallback(()=>n($.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return a.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},Hs=new Set,Vs=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=a.useCallback(()=>n.peek(e),[n,e]),i=a.useCallback(()=>n.peekSeeded(e),[n,e]),f=a.useSyncExternalStore(n.subscribe,s,i),h=a.useCallback(()=>n.answerStampOf(e),[n,e]),m=a.useSyncExternalStore(n.subscribe,h,h),[u]=a.useState(()=>new Set),[p,E]=a.useState(Hs),[S,k]=a.useState(null);S!==null&&S.path!==e&&k(null);const O=a.useRef(null);a.useLayoutEffect(()=>(O.current=e,()=>{O.current=null}),[e]);const T=a.useCallback(()=>{const x=e,g=n.peek(x);if(u.has(x)||g?.status==="pending")return;const c=t&&!hn(g);u.add(x),E(new Set(u)),k(null),(async()=>{try{const d=await n.refresh(x);if(O.current!==x||d.status==="superseded")return;if(d.status==="failed"){k({path:x,failure:d.failure,stamp:n.answerStampOf(x)}),r.announce(o.documentRefreshFailed(ee(o,d.failure.reason)));return}const w=re(n.peek(x));if(c||w===null||w.document.kind==="failure")return;r.announce(o.documentRefreshed(w.document.name))}finally{u.delete(x),E(new Set(u))}})()},[e,t,u,n,r,o]),A=p.has(e),j=S!==null&&S.path===e&&S.stamp===m?S.failure:null;return{refreshing:A,unavailable:A||f?.status==="pending",failure:j,refresh:T}},Fn=Object.freeze({kind:"page"}),$n=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:i,refresh:f}=Vs(e,t.kind==="page"),h=zs(e),m=js(e),u=Yt(e),p=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,E=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,S=t.kind==="panel",k=t.kind==="panel"?t.documentName:m.name,O=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":u===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[u===void 0?null:l.jsx(Ps,{session:u}),u===void 0?null:l.jsx(Is,{path:e,documentName:k,iconOnly:S,session:u,previewAvailable:O}),u===void 0&&h?l.jsxs("button",{type:"button",className:E===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:E===null?r.showMarkup:E,"aria-label":E===null?void 0:E,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Ln,{"aria-hidden":"true"}),E===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,u!==void 0||m.edit?.kind==="inline"||m.edit?.kind==="draft"?l.jsx(Ns,{path:e,documentName:k,iconOnly:S,previewAvailable:O,draft:m.edit?.kind==="draft"}):m.edit?.kind==="external"?l.jsx(Ds,{href:m.edit.href,documentName:k,iconOnly:S}):null,u===void 0?l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?r.refreshDocument:p,"aria-label":p===null?void 0:p,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:f,onDoubleClick:ne,children:[l.jsx(Cn,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),u!==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:r.documentRefreshFailed(ee(r,i.reason))}),u===void 0?null:l.jsx(Bs,{path:e,session:u})]})},Us=({location:e})=>{const t=e.doc,n=a.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=_n(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Se,children:[l.jsx($n,{path:t,placement:Fn,markup:r}),l.jsx(On,{path:t,absence:Rn,markup:e.markup,variant:n})]})},qn=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),o=a.useId();a.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=a.useCallback(()=>r.shownIn(o),[r,o]),i=a.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:i.length>1?n.announcementSequence(i):i[0]})},ie=Object.freeze([]),Zs=e=>{const t=new Set;let n=ie,r=[],o=!1;const s=[],i=u=>{n=u;for(const p of[...t])p()},f=()=>s.at(-1)?.region,h=u=>{const p=f();u(),f()!==p&&n!==ie&&i(ie)},m=()=>{o=!1;const u=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],i(Object.freeze(u))};return{announce:u=>{if(typeof u=="string")r.push({sentence:u});else{const p=r.find(E=>"list"in E&&E.list===u.list);p!==void 0&&"items"in p?p.items.push(u.item):r.push({list:u.list,items:[u.item]})}o||(o=!0,n!==ie&&i(ie),e.request(m))},subscribe:u=>(t.add(u),()=>{t.delete(u)}),claim:u=>{const p={region:u};return h(()=>s.push(p)),()=>h(()=>{const E=s.indexOf(p);E!==-1&&s.splice(E,1)})},shownIn:u=>f()===u?n:ie}},de=Object.freeze({status:"cancelled"}),Gs=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(D.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return D.failureOf(n,r)},Ws=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,u)=>globalThis.fetch(m,u)),o=(m,u)=>`${e}/${m}?${new URLSearchParams(u).toString()}`,s=async(m,u,p,E)=>{let S;try{S=await r(m,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return E({reason:"failed"})}S.status===401&&t(null);const k=S.headers.get(D.EXPLORER_SCOPE_HEADER);k!==null&&t(k);let O;try{O=await S.json()}catch{return E({reason:D.failureReasonOfStatus(S.status)})}let T;try{T=p(O)}catch{T=!1}if(T)return O;const A=Gs(O);return E(A!==null?A:{reason:S.status===200?"failed":D.failureReasonOfStatus(S.status)})},i={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_REFRESH_PROOF},f={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_EDIT_PROOF,"Content-Type":`${D.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},h=async(m,u,p)=>{const E=await s(m,u,p,S=>D.failureDocument(S.reason,S.code));return u.signal.aborted?de:E};return{tree:m=>s(o("tree",{[D.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},D.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(m,u,p)=>{const E=await s(o("children",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerChildrenResult,S=>({status:"error",failure:S}));return p.aborted?de:E},ancestors:async(m,u,p)=>{const E=await s(o("ancestors",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerAncestorsResult,S=>({status:"error",failure:S}));return p.aborted?de:E},reveal:async(m,u,p)=>{const E=await s(o("reveal",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerRevealResult,S=>({status:"error",failure:S}));return p.aborted?de:E},document:(m,{refresh:u})=>s(o("document",{[D.EXPLORER_DATA_QUERY.path]:m}),u?{method:"GET",headers:i}:{method:"GET"},D.isExplorerDocument,p=>D.failureDocument(p.reason,p.code)),text:async(m,u)=>{const p=await s(o("text",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerTextAnswer,E=>D.failureDocument(E.reason,E.code));return u.aborted?de:p},edit:(m,u)=>h(o("edit",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerEditAnswer),save:(m,u,p,E)=>h(o("save",{[D.EXPLORER_DATA_QUERY.path]:m,[D.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:f,body:p,signal:E},D.isExplorerSaveAnswer),preview:(m,u,p)=>h(o("preview",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:f,body:u,signal:p},D.isExplorerPreviewAnswer),revisions:(m,u)=>h(o("revisions",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerRevisionsAnswer),revision:(m,u,p)=>h(o("revision",{[D.EXPLORER_DATA_QUERY.path]:m,[D.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:p},D.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[D.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:i},D.isExplorerTreeResult,u=>({status:"error",failure:u}))}},Ks=()=>{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}}},Xs=e=>{const t=X.readStorage(e);if(t===null)return $.NO_TREE_SETTING_CHANGES;try{return $.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),$.NO_TREE_SETTING_CHANGES}},Tt=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Xs(e);n={changes:s,settings:$.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:i,settings:f}=r(),h=$.recordTreeSettingChange(i,s,$.advanceTreeSetting(f,s)[s],t);return n={changes:h,settings:$.applyTreeSettingChanges(t,h)},o.emit(),X.writeStorage(e,$.serializeTreeSettingChanges(h)),n.settings}}},Ys=Object.freeze({status:"refreshed"}),Qs=Object.freeze({status:"superseded"}),Ge=Object.freeze({status:"deferred"}),Js=Wt(Ge),In=4,ei=In-1,Ot=Object.freeze({status:"loading"}),ti=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ni=e=>{const t=new Map,n=mn(),r=new Map,o=new Map,s=new Map,i=new Map,f=ae(),h=new Set;let m=0,u=0;const p={direct:null,bulk:null},E=new Set;let S=!1,k=0;const O=()=>{k+=1,f.emit()},T=v=>o.get(v)??0,A=v=>{let b=i.get(v);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},i.set(v,b)),b},j=(v,b,R)=>{v.inFlight.delete(b),m-=1,R.lane==="bulk"&&(u-=1)},x=v=>{const b=i.get(v);if(b!==void 0){for(const[R,L]of[...b.inFlight])j(b,R,L),L.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},g=v=>{const b=T(v)+1;return o.set(v,b),x(v),b},c=(v,b)=>{const R=ue(v),L={promise:v,opened:b,stale:!1,loadedAt:R?.status==="ok"?R.loadedAt:null};return v.status==="pending"&&v.then(_=>{_.status==="ok"&&(L.loadedAt=_.loadedAt)}),L},d=v=>{let b=r.get(v);return b===void 0&&(b=new Map,r.set(v,b)),b},w=v=>{const b=[...i.keys()],R=p[v],L=R===null?0:b.indexOf(R)+1;for(let _=0;_<b.length;_+=1){const I=b[(L+_)%b.length],Z=I===void 0?void 0:i.get(I);if(!(I===void 0||Z===void 0)){for(const z of Z[v])if((Z.claims.get(z)??0)!==0)return Z[v].delete(z),p[v]=I,{sourceId:I,path:z}}}return null},C=(v,b,R,L)=>{const _=i.get(v);if(_===void 0||_.inFlight.get(b)!==R)return;j(_,b,R);const I=(_.claims.get(b)??0)>0,Z=d(v);if(L.status==="ok"?Z.set(b,{status:"loaded",entries:L.entries}):L.status==="error"&&I?Z.set(b,{status:"failed",failure:L.failure}):Z.delete(b),O(),L.status==="error"&&I){const z={sourceId:v,path:b,failure:L.failure};for(const te of[...h])te(z)}N()},M=(v,b,R)=>{const L={controller:new AbortController,lane:R};A(v).inFlight.set(b,L),m+=1,R==="bulk"&&(u+=1),e.children(v,b,L.controller.signal).then(_=>C(v,b,L,_),()=>C(v,b,L,ti))},N=()=>{for(;m<In;){const v=w("direct");if(v!==null){M(v.sourceId,v.path,"direct");continue}const b=u<ei?w("bulk"):null;if(b===null)return;M(b.sourceId,b.path,"bulk")}},F=(v,b,R)=>{if(!(b.direct.delete(R)||b.bulk.delete(R))){const _=b.inFlight.get(R);if(_===void 0)return!1;j(b,R,_),_.controller.abort()}return r.get(v)?.delete(R),!0},U=()=>{S=!1;let v=!1;for(const b of E){const R=A(b);for(const L of R.unclaimed)(R.claims.get(L)??0)===0&&F(b,R,L)&&(v=!0);R.unclaimed.clear()}E.clear(),v&&(O(),N())},V=(v,b)=>{t.set(v,c(pe(e.tree(v)),b))},q=(v,b,R)=>{g(v);const L=c(Wt(b),R);return t.set(v,L),r.delete(v),O(),N(),L},W=(v,b,R,L)=>{if(R!==T(v)||t.get(v)!==b)return;const _=ue(b.promise);if(!(L.status!=="ok"||_?.status!=="ok"||b.loadedAt===null||L.loadedAt<=b.loadedAt)){if(ye(_.entries,L.entries)){b.loadedAt=L.loadedAt;return}q(v,L,b.opened)}},B=(v,b)=>{const R=t.get(v);return R!==void 0&&ue(R.promise)?.status===b},Q=(v,b)=>{b.stale=!1;const R=T(v);e.tree(v).then(L=>W(v,b,R,L))};return{read:v=>t.get(v)?.promise??Js,open:v=>{const b=n.resumes(v),R=n.hold(v),L=t.get(v);return L===void 0||B(v,"deferred")?(V(v,!0),O()):b||(L.opened&&B(v,"error")?(V(v,!0),O()):(L.opened=!0,L.stale&&B(v,"ok")&&Q(v,L))),R},retry:v=>{B(v,"error")&&(V(v,!0),O())},seed:(v,b)=>{const R=b.then(I=>I===null?Ge:I,()=>Ge),L=t.get(v);if(L!==void 0&&B(v,"ok")){const I=T(v);R.then(Z=>W(v,L,I,Z));return}g(v);const _=c(pe(R),L?.opened===!0);t.set(v,_),r.delete(v),N(),R.then(I=>{t.get(v)===_&&(I.status==="deferred"&&n.isHeld(v)&&V(v,_.opened),O())})},refresh:async v=>{const b=(s.get(v)??0)+1;s.set(v,b);const R=await e.refresh(v);if(s.get(v)!==b)return Qs;if(R.status==="error")return{status:"failed",failure:R.failure};const L=t.get(v);if(!(L!==void 0&&L.loadedAt!==null&&B(v,"ok")&&L.loadedAt>R.loadedAt)){const I=q(v,R,!0);if(L!==void 0&&L.promise.status==="pending"){const Z=T(v);L.promise.then(z=>W(v,I,Z,z))}}for(const[I,Z]of t)I!==v&&ue(Z.promise)?.status==="ok"&&(Z.stale=!0);return Ys},children:(v,b)=>r.get(v)?.get(b),claimChildren:(v,b)=>{const R=A(v),L=d(v);let _=!1,I=!1;for(const[z,te]of b)R.claims.set(z,(R.claims.get(z)??0)+1),L.get(z)===void 0?(L.set(z,Ot),R[te].add(z),_=!0,I=!0):te==="direct"&&R.bulk.delete(z)&&(R.direct.add(z),I=!0);_&&O(),I&&N();let Z=!1;return()=>{if(!Z){Z=!0;for(const z of b.keys()){const te=(R.claims.get(z)??0)-1;te>0?R.claims.set(z,te):(R.claims.delete(z),R.unclaimed.add(z))}E.add(v),!S&&(S=!0,queueMicrotask(U))}}},retryChildren:(v,b)=>{const R=r.get(v);if(R===void 0||R.get(b)?.status!=="failed")return;const L=A(v);if((L.claims.get(b)??0)>0){R.set(b,Ot),L.direct.add(b),O(),N();return}R.delete(b),O()},pendingChildren:v=>{const b=i.get(v);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...i.keys()]))g(v);for(const[v,b]of s)s.set(v,b+1);t.clear(),r.clear(),O()},subscribeChildrenFailures:v=>(h.add(v),()=>{h.delete(v)}),subscribe:f.subscribe,version:()=>k}},ri=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},oi=1;let ge=0,oe=null;const si=()=>{const{documentElement:e,body:t}=document;ge===0&&(oe={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"),ge+=1;let n=!1;return()=>{n||(n=!0,ge-=1,!(ge>0||oe===null)&&(e.style.overflow=oe.htmlOverflow,t.style.overflow=oe.bodyOverflow,e.style.scrollbarGutter=oe.htmlGutter,t.style.scrollbarGutter=oe.bodyGutter,oe=null))}},ii=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Ct=1,li=1e3,Lt=e=>e.getClientRects().length>0,Fe="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.",ai=e=>{if(!Lt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+oi)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. ${Fe}`;if(t.height<Ct)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. ${Fe}`;for(const{selector:r,name:o}of ii)for(const s of e.querySelectorAll(r)){if(!Lt(s))continue;const i=s.getBoundingClientRect().height;if(i<Ct)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(i))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Fe}`}return null},ci=e=>{let t=!1,n;const r=()=>{n=void 0;const i=ai(e);i!==null&&(t=!0,console.error(i))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,li))},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)}},di=(e,t)=>{a.useEffect(()=>e?si():void 0,[e]),a.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ci(n)},[e,t])},Mt='[data-testid="markdown-explorer-view-switch"]',ui=[{control:Mt,successors:[Mt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],fi=e=>{for(const t of ui){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},mi=(e,t)=>{const n=a.useRef(null);a.useEffect(()=>{const o=f=>{const h=e.current;n.current=h!==null&&f instanceof Element&&h.contains(f)?fi(f):null},s=f=>o(f.target);o(document.activeElement);const i=f=>{const h=f.target;f.relatedTarget!==null||!(h instanceof Element)||queueMicrotask(()=>{n.current?.element===h&&h.isConnected&&document.activeElement!==h&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",i),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",i)}},[e]);const r=a.useRef(t);a.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const h=document.activeElement;if(h!==null&&h!==document.body&&h!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const u of o.control.successors)for(const p of m.querySelectorAll(u))if(p!==o.element&&(p.focus({preventScroll:!0}),document.activeElement===p))return!0;return!1};if(s())return;const i=e.current;if(i===null)return;const f=new MutationObserver(()=>{s()&&f.disconnect()});return f.observe(i,{childList:!0,subtree:!0}),()=>f.disconnect()},[t,e])},hi=a.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-DCGqVwt9.cjs")).then(e=>({default:e.TreeLayout}))),pi=a.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-DsxYURra.cjs")).then(e=>({default:e.MultiLayout}))),vi=64,wi={request:e=>{requestAnimationFrame(e)}},At=e=>{e.documents.clear(),e.trees.clear()},$e=(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)},gi=(e,t)=>{const[n,r]=a.useState(()=>({overrides:t,locale:e,labels:ze(e,t)}));if(n.locale===e&&Wn(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:ze(e,t)};return r(o),o.labels},Ei=(e,t,n)=>{const[r,o]=a.useState(()=>({scope:t,store:Tt(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Tt(e,n)};return o(s),s.store},qe=(e,t)=>{const[n,r]=a.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},xi=()=>Zs(wi),jt="on",Si="off",bi=Object.freeze({kind:"unavailable"}),yi=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")},Ri=(e,t)=>{const n=re(e.peek(t));return n===null||n.document.kind==="failure"?D.lastPathSegment(t):n.document.name},ki=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:i,renderTreeFailure:f,lockDocumentScroll:h=!1,onMathDiagnostics:m,onEditGrant:u,draftConverter:p})=>{X.assertStorageNamespace(n),yi(p);const E=Ft(r),S=Kn(s),k=gi(E,o),{revalidate:O}=Y.useRevalidator(),T=a.useRef(()=>{}),A=Y.useHref(t.dataPath),[j]=a.useState(()=>{const R=Ws({dataPath:A,onScope:_=>T.current(_)}),L={documents:Dr({client:R,capacity:Math.max(vi,t.multiView.maxPanels*2)}),trees:ni(R)};return $e(L,e),X.syncStorageScope(n,e.scope),{data:R,...L,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(j.aligned.pageData!==e||j.aligned.storageNamespace!==n){const R=j.aligned.pageData;j.aligned.pageData=e,j.aligned.storageNamespace=n,R!==e&&(R.scope!==e.scope?j.aligned.pendingReader=e:$e(j,e)),X.syncStorageScope(n,e.scope)}const x=Ei(X.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);a.useLayoutEffect(()=>{const R=j.aligned.pendingReader;R!==null&&(j.aligned.pendingReader=null,At(j),$e(j,R))},[e,j]),a.useLayoutEffect(()=>{let R=!1;return T.current=L=>{L===e.scope||R||(R=!0,L!==null&&(At(j),X.clearExplorerStorage(n)),O())},()=>{T.current=()=>{}}},[e,O,j,n]);const g=a.useRef(t.settingsCookie);a.useLayoutEffect(()=>{g.current=t.settingsCookie},[t.settingsCookie]);const[c]=a.useState(()=>ri(e.settings,R=>{document.cookie=$.viewSettingsCookieString(g.current,R,window.location.protocol==="https:")})),d=qe(e.scope,xi),w=qe(e.scope,Ks),C=a.useRef(k);a.useLayoutEffect(()=>{C.current=k},[k]);const M=qe(e.scope,()=>nr({data:j.data,conflictLabels:()=>({ours:C.current.conflictOurs,theirs:C.current.conflictTheirs}),onSaveSettled:(R,L)=>{L.kind==="saved"&&j.documents.refresh(R);const _=Yn(C.current,L,Ri(j.documents,R));_!==null&&d.announce(_)},sideBySideSetting:{read:()=>X.readStorage(X.storageKeys(n).editPreview)===jt,write:R=>X.writeStorage(X.storageKeys(n).editPreview,R?jt:Si)},editorShareSetting:{read:()=>tr(X.readStorage(X.storageKeys(n).editSplit)),write:R=>X.writeStorage(X.storageKeys(n).editSplit,String(R))}})),N=a.useMemo(()=>pe(e.notices.catch(()=>[])),[e.notices]),F=e.sources.map(R=>R.id).join(`
12
+ `),U=a.useMemo(()=>$.withExplorerSources(t,F.split(`
13
+ `)),[t,F]),V=a.useRef(m);a.useLayoutEffect(()=>{V.current=m},[m]);const[q]=a.useState(()=>(R,L)=>{V.current?.(R,L)}),W=m===void 0?void 0:q,B=a.useRef(p);a.useLayoutEffect(()=>{B.current=p},[p]);const[Q]=a.useState(()=>{let R=!1;return{convert:(L,_)=>{const I=B.current;return I===void 0?Promise.resolve(bi):I.convert(L,_)},prepare:()=>{try{B.current?.prepare?.()}catch(L){if(R)return;R=!0,console.error("[markdown-explorer] the draft converter's prepare threw",L)}}}}),v=p===void 0?void 0:Q,b=a.useMemo(()=>({config:U,labels:k,locale:E,theme:S,storageNamespace:n,scope:e.scope,sources:e.sources,notices:N,documents:j.documents,trees:j.trees,data:j.data,viewSettings:c,treeSettings:x,announcer:d,reveals:w,edits:M,onEditGrant:u,draftConverter:v,renderTreeFailure:f,reportMathDiagnostics:W}),[U,k,E,S,n,e.scope,e.sources,N,j,c,x,d,w,M,u,v,f,W]);return l.jsx($t,{value:b,children:l.jsx(Oi,{renderFrame:i,lockDocumentScroll:h},e.scope)})},Ti=({ref:e,theme:t,view:n,children:r})=>{const[o]=a.useState(Eo);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})},Oi=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=ke(),{hash:s}=Y.useLocation(),i=we(),f=a.useRef(null);di(t,f),a.useLayoutEffect(()=>{o.kind==="redirect"&&i(`${o.href}${s}`,"browse")},[o,s,i]);const{location:h}=o,m=h.view;mi(f,m);const u=h.view==="tree"?l.jsx(a.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Se}),children:l.jsx(hi,{location:h})}):h.view==="multi"?l.jsx(a.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Se}),children:l.jsx(pi,{location:h})}):l.jsx(Us,{location:h}),p=l.jsxs(Ti,{ref:f,theme:n,view:m,children:[u,l.jsx(vr,{}),l.jsx(qn,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:m,children:p})},Ci=zn.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Re;exports.CONFLICT_OURS_MARKER=It;exports.CONFLICT_SEPARATOR=Bt;exports.CONFLICT_THEIRS_MARKER=zt;exports.CONTENT_PANE=Se;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Nt;exports.DocumentPane=On;exports.DocumentRefreshBar=$n;exports.EXPLORER_THEMES=He;exports.EditGrantNotice=An;exports.ExplorerLink=cn;exports.FOLDER_README_LOADING=Kt;exports.FailureView=se;exports.ForwardRef=Cn;exports.ForwardRef$1=Mn;exports.ImageViewMemoryContext=En;exports.LazyNativeScrollBar=un;exports.LiveRegion=qn;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=_t;exports.MARKDOWN_EXPLORER_LABEL_KEYS=We;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Dt;exports.MARKDOWN_EXPLORER_LOCALES=Be;exports.MarkdownExplorer=ki;exports.NO_DOCUMENT=Rn;exports.PAGE_DOCUMENT_REFRESH=Fn;exports.anchorOfDoubleClick=nn;exports.anchorOfView=rn;exports.blockAtLine=ln;exports.chooseEditView=Ze;exports.consumeKey=Ke;exports.createEmitter=ae;exports.cssPixels=Vt;exports.editViewOf=jn;exports.explorerNavigationOptions=Mr;exports.failureTitleOf=ee;exports.findConflictsInLines=Ht;exports.focusWithoutScroll=Qe;exports.frameTopOf=on;exports.isApplePlatform=Dn;exports.isEditViewShortcut=Pn;exports.isEditingDoubleClick=tn;exports.lineTopIn=an;exports.loadedOf=re;exports.paneShownAlone=Ms;exports.positionInSource=Cr;exports.readFolderReadme=Xt;exports.resolveMarkdownExplorerLabels=ze;exports.shouldRevalidateExplorer=Ci;exports.toggledEditView=Nn;exports.useExplorer=P;exports.useExplorerLocation=ke;exports.useExplorerNavigate=we;exports.useIntentPrefetch=dn;exports.usePageMarkupToggle=_n;exports.useSideBySide=Jt;exports.useViewSetting=he;exports.visibleTopOf=sn;