@aiquants/markdown-explorer 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +4 -3
- package/dist/{EditSurface-BRuIjA9L.cjs → EditSurface-4VX20isB.cjs} +1 -1
- package/dist/{EditSurface-B2bzY1b_.js → EditSurface-Ckg-3iTA.js} +1 -1
- package/dist/ExplorerSplit-BDkBN8A0.cjs +1 -0
- package/dist/{ExplorerSplit-qAKZsLZa.js → ExplorerSplit-LiI3IUZn.js} +2 -2
- package/dist/{MultiLayout-Bc6RYc3U.cjs → MultiLayout-BOaQK8fp.cjs} +1 -1
- package/dist/{MultiLayout-rsmtFma5.js → MultiLayout-KWacTPP8.js} +2 -2
- package/dist/{NativeScrollBar-DqTkrnPZ.cjs → NativeScrollBar-BPgV3kp-.cjs} +1 -1
- package/dist/{NativeScrollBar-Dq3YeUVY.js → NativeScrollBar-zzpty31a.js} +1 -1
- package/dist/{TreeLayout-BPa7NdeT.js → TreeLayout-C8IP4cjY.js} +2 -2
- package/dist/{TreeLayout-DXoEAcpD.cjs → TreeLayout-S5TMf8_A.cjs} +1 -1
- package/dist/{index-W3iAjkLb.cjs → index-DrKHJNY4.cjs} +3 -3
- package/dist/{index-25s_q0vD.js → index-Dz01kBab.js} +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{merge-DuTAponF.cjs → merge-B7Lkcdz0.cjs} +1 -1
- package/dist/{merge-B9jrWxMa.js → merge-ClVgYrkS.js} +1 -1
- package/package.json +7 -7
- package/dist/ExplorerSplit-BE1VJuok.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
### Breaking
|
|
6
6
|
|
|
7
|
+
- **The peer floors are `@aiquants/directory-tree` ^5.0.0, `@aiquants/markdown` ^8.1.1 and `@aiquants/virtualscroll`
|
|
8
|
+
^3.22.0.** The tree's rows and expand glyph take paint and text styles only
|
|
9
|
+
(anything else throws a `RangeError` at render) and its rows have no vertical padding. The explorer's row style is
|
|
10
|
+
`{ fontSize: "inherit" }`: the `paddingBlock: 0` that cancelled the tree's row padding is gone, and the in-row retry
|
|
11
|
+
button keeps the row's whole height as its target. The row and expand-glyph styles are typed with the tree's
|
|
12
|
+
`DirectoryTreeRowStyle` and `DirectoryTreeExpandIconStyle`. Nothing changes on screen. markdown 8.1.1 finishes a
|
|
13
|
+
Mermaid drawing inside the document when the diagram's text changes or it unmounts mid-drawing; virtualscroll 3.21.0
|
|
14
|
+
and 3.22.0 give the scroll-to-edge pills and the tap-scroll circles 44 px targets and the pills body-step text (the
|
|
15
|
+
explorer neither repaints the pills nor sizes the circles, so it takes both as they are).
|
|
16
|
+
|
|
17
|
+
## 0.18.0 (2026-10-25)
|
|
18
|
+
|
|
19
|
+
### Breaking
|
|
20
|
+
|
|
7
21
|
- **The peer floors are `@aiquants/markdown` ^8.1.0 and `@aiquants/drag-drop-panels` ^0.12.0.** The viewer's controls
|
|
8
22
|
(its toolbar, the table of contents, a code block's copy button and a Mermaid diagram's controls, whose toolbar is a
|
|
9
23
|
row above the diagram) are 44 × 44 px targets under every pointer, and so are the panel headers' buttons and the
|
package/README.md
CHANGED
|
@@ -39,9 +39,10 @@ A single-view (embedding) page never downloads the tree and multi-panel views, w
|
|
|
39
39
|
|
|
40
40
|
- React 19.2.7 or later and React Router 8 in framework mode (route modules with `loader` / `headers`).
|
|
41
41
|
- Node.js 22.22 or later (the floor React Router 8 declares). The package ships ES modules and CommonJS; the CommonJS entries load the ESM-only `react-router` through `require(esm)`.
|
|
42
|
-
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^8.1.
|
|
43
|
-
its Mermaid labels, its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads and `@aiquants/markdown/source-lines` the editor and the sanitizer read, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
|
|
44
|
-
`@aiquants/directory-tree` ^
|
|
42
|
+
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^8.1.1 (document rendering; its components' stylesheet without utilities, its controls' 44 px targets under every pointer,
|
|
43
|
+
its Mermaid labels and drawings that finish inside the document when a diagram's text changes or it unmounts mid-drawing, its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads and `@aiquants/markdown/source-lines` the editor and the sanitizer read, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
|
|
44
|
+
`@aiquants/directory-tree` ^5.0.0 (rows that take paint and text styles only and have no vertical padding, a `removeRootIndent` shift that keeps the root's icon whole, and reveals of rows under the scroll bar's buttons),
|
|
45
|
+
`@aiquants/drag-drop-panels` ^0.12.0 (the panel headers' move menu, named by the explorer's `panelMove`, their 44 px buttons under every pointer and the header arrangement the behavior docs follow), `@aiquants/resize-panels` ^2.2.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.22.0 (44 px scroll-to-edge pills and tap-scroll circles, the pills' text at the body step).
|
|
45
46
|
The client depends on these floors, while a package manager may only warn about an older peer.
|
|
46
47
|
- A Markdown parser of your choice on the server that produces HTML and its headings (the explorer sanitizes the HTML before it is sent).
|
|
47
48
|
- Browsers: the multi view's panel-limit notice and the panel headers' move menu use the Popover API (Chrome and Edge 114, Firefox 125, Safari 17 and later). In browsers without it (for example iOS 16), the notice is drawn in place at the stage's corner instead of in the top layer (while the sheet is open it spans the sheet's header, as in every browser), and the move menu does not open: Alt + Shift + an arrow moves a panel there.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),p=require("react"),x=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),p=require("react"),x=require("./index-DrKHJNY4.cjs"),ee=require("@codemirror/commands"),ae=require("@codemirror/lang-markdown"),ye=require("@codemirror/language"),ce=require("@codemirror/search"),K=require("@codemirror/state"),I=require("@codemirror/view"),_=require("@lezer/highlight"),Ce=require("@aiquants/markdown"),ne=require("@aiquants/markdown/source-lines"),W=require("./dataRoute-BONacTPi.cjs"),oe=require("./sanitizePolicy-DrIMuYCb.cjs"),_e=require("isomorphic-dompurify"),Q=require("@aiquants/resize-panels"),G=require("./location-BVEN_Ihk.cjs"),ue=require("./useSplitPersistence-Ba-v64n-.cjs"),Te={history:ee.historyField},Pe=ye.HighlightStyle.define([{tag:[_.tags.heading1,_.tags.heading2,_.tags.heading3,_.tags.heading4,_.tags.heading5,_.tags.heading6,_.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:_.tags.strong,fontWeight:"700"},{tag:_.tags.emphasis,fontStyle:"italic"},{tag:_.tags.strikethrough,textDecoration:"line-through"},{tag:_.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:_.tags.url,color:"var(--aqmx-syntax-url)"},{tag:_.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:_.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[_.tags.processingInstruction,_.tags.contentSeparator,_.tags.labelName,_.tags.meta],color:"var(--aqmx-syntax-mark)"}]),Ne=I.EditorView.theme({"&":{height:"100%",color:"var(--aqmx-text)",backgroundColor:"var(--aqmx-surface)",fontSize:"var(--aqmx-font-size-title)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"var(--aqmx-line-height-prose)"},".cm-content":{caretColor:"var(--aqmx-text)",paddingBlock:"var(--aqmx-space-6)"},".cm-line":{paddingInline:"var(--aqmx-space-6)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--aqmx-text)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--aqmx-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-gutters":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-editor-gutter)",borderInlineEnd:"var(--aqmx-space-1) solid var(--aqmx-border)"},".cm-activeLineGutter":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-searchMatch":{outline:"var(--aqmx-space-1) solid var(--aqmx-border-strong)"},".cm-panels":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-text)"}}),Le="data-aqmx-conflict-actions",De=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),Ve=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),je=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class He extends I.WidgetType{constructor(t,r){super(),this.index=t,this.labels=r}index;labels;eq(t){return t.index===this.index&&t.labels===this.labels}toDOM(t){const r=document.createElement("div");r.setAttribute(Le,String(this.index));for(const[o,a]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const s=document.createElement("button");s.type="button",s.textContent=a,s.setAttribute("data-aqmx-conflict-choice",o),s.addEventListener("mousedown",l=>l.preventDefault()),s.addEventListener("click",()=>{const l=Y(t.state.doc)[this.index];l!==void 0&&(ke(t,l,o),t.focus())}),r.append(s)}return r}ignoreEvent(){return!0}}const Y=e=>x.findConflictsInLines(e.iterLines()),de=(e,t)=>{const r=new K.RangeSetBuilder;return Y(e).forEach((o,a)=>{const s=e.line(o.start);r.add(s.from,s.from,I.Decoration.widget({widget:new He(a,t),block:!0,side:-1}));for(let l=o.start;l<=o.end;l+=1){const n=e.line(l).from,h=l===o.start||l===o.separator||l===o.end?De:l<o.separator?Ve:je;r.add(n,n,h)}}),r.finish()},Be=e=>K.StateField.define({create:t=>de(t.doc,e),update:(t,r)=>r.docChanged?de(r.state.doc,e):t,provide:t=>I.EditorView.decorations.from(t)}),ke=(e,t,r)=>{const{doc:o}=e.state,a=(u,c)=>{const g=[];for(let m=u;m<=c;m+=1)g.push(o.line(m).text);return g},s=a(t.start+1,t.separator-1),l=a(t.separator+1,t.end-1),n=r==="ours"?s:r==="theirs"?l:[...s,...l];let h=o.line(t.start).from,f=o.line(t.end).to;n.length===0&&(t.end<o.lines?f+=1:t.start>1&&(h-=1));const i=n.join(`
|
|
2
2
|
`);e.dispatch({changes:{from:h,to:f,insert:i},selection:K.EditorSelection.cursor(h),scrollIntoView:!0,userEvent:"input.resolve"})},ze=({parent:e,scroll:t,text:r,saved:o,labels:a,onChange:s,onGeometry:l,onSave:n})=>{const h=[I.EditorView.scrollHandler.of((u,c,g)=>(Fe(u,c.head,g,t),!0)),I.lineNumbers(),I.highlightActiveLineGutter(),ee.history(),I.drawSelection(),I.highlightActiveLine(),ce.highlightSelectionMatches(),I.EditorView.lineWrapping,ae.markdown({base:ae.markdownLanguage}),ye.syntaxHighlighting(Pe),Be(a),I.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(n(),!0)},...ce.searchKeymap,...ee.historyKeymap,...ee.defaultKeymap]),I.EditorView.contentAttributes.of({"aria-label":a.editor,"aria-multiline":"true"}),I.EditorView.updateListener.of(u=>{u.docChanged&&s(),(u.docChanged||u.heightChanged||u.geometryChanged)&&l(u.docChanged)}),Ne],f=Xe(o,h)??K.EditorState.create({doc:r,extensions:h}),i=new I.EditorView({state:f,parent:e});return{text:()=>i.state.doc.toString(),replaceText:u=>{const c=i.state.doc.toString();if(c===u)return;let g=0;const m=Math.min(c.length,u.length);for(;g<m&&c.charCodeAt(g)===u.charCodeAt(g);)g+=1;let S=0;for(;S<m-g&&c.charCodeAt(c.length-1-S)===u.charCodeAt(u.length-1-S);)S+=1;i.dispatch({changes:{from:g,to:c.length-S,insert:u.slice(g,u.length-S)},userEvent:"input.replace"})},reveal:({line:u,column:c},g)=>{const{doc:m}=i.state,S=m.line(Math.min(Math.max(u,1),m.lines)),v=Math.min(S.from+c,S.to);i.dispatch({selection:K.EditorSelection.cursor(v),effects:fe(i,v,g,t)})},showLine:u=>{const{doc:c}=i.state,g=c.line(Math.min(Math.max(u,1),c.lines)).from;i.dispatch({effects:fe(i,g,null,t)})},topLine:()=>{const u=t.scrollerOf(i.scrollDOM),c=x.visibleTopOf(u,i.contentDOM),g=x.frameTopOf(u)+u.clientHeight,{documentTop:m}=i,{doc:S}=i.state;let v=i.lineBlockAtHeight(Math.max(c-m,0));for(;S.lineAt(v.from).text.trim()===""&&v.to<S.length;){const A=i.lineBlockAt(v.to+1);if(m+A.top>=g)break;v=A}const k=i.coordsAtPos(v.from),O=k===null?m+v.top:k.top;return{line:i.state.doc.lineAt(v.from).number,clientTop:O,offset:O-c}},lineSpans:u=>{const c=i.scrollDOM,g=c.scrollTop+i.documentTop-x.visibleTopOf(c,i.contentDOM),{doc:m}=i.state,S=v=>m.line(Math.min(Math.max(v,1),m.lines)).from;return u.map(({first:v,last:k})=>({top:g+i.lineBlockAt(S(v)).top,bottom:g+i.lineBlockAt(S(k)).bottom}))},scrollElement:i.scrollDOM,focus:()=>i.focus(),conflicts:()=>Y(i.state.doc),resolveAtCursor:u=>{const c=Y(i.state.doc),g=i.state.doc.lineAt(i.state.selection.main.head).number,m=c.find(S=>S.end>=g);return m===void 0?!1:(ke(i,m,u),!0)},nextConflict:()=>{const u=Y(i.state.doc);if(u[0]===void 0)return!1;const g=i.state.doc.lineAt(i.state.selection.main.head).number,m=u.findIndex(O=>O.start>g),S=m<0?0:m,v=i.state.doc.line(u[S].start).from;i.dispatch({selection:K.EditorSelection.cursor(v),effects:I.EditorView.scrollIntoView(v,{y:"center"})});const k=i.contentDOM.querySelector(`[${Le}="${String(S)}"] button`);return k instanceof HTMLElement?k.focus({preventScroll:!0}):i.focus(),!0},save:()=>i.state.toJSON(Te),destroy:()=>i.destroy()}},fe=(e,t,r,o)=>{const a=o.scrollerOf(e.scrollDOM),s=(r===null?x.visibleTopOf(a,e.contentDOM):r)-x.frameTopOf(a);return I.EditorView.scrollIntoView(t,{y:"start",yMargin:s})},Fe=(e,t,r,o)=>{const a=Ue(e,t),s=o.scrollerOf(e.scrollDOM),l=x.frameTopOf(s),n=x.visibleTopOf(s,e.contentDOM),h=l+s.clientHeight;let f=0;switch(r.y){case"start":f=a.top-(l+r.yMargin);break;case"center":f=(a.top+a.bottom)/2-(n+h)/2;break;case"end":f=a.bottom-(h-r.yMargin);break;default:a.top<n+r.yMargin?f=a.top-(n+r.yMargin):a.bottom>h-r.yMargin&&(f=Math.min(a.bottom-(h-r.yMargin),a.top-(n+r.yMargin)))}if(f!==0&&(s.scrollTop+=f),r.y==="start")return;const i=Ge(e,t);i!==null&&o.reveal(i)},Ue=(e,t)=>{const{node:r,offset:o}=e.domAtPos(t);if(r.nodeType===Node.TEXT_NODE){const l=r.ownerDocument?.createRange();if(l!==void 0){l.setStart(r,o),l.setEnd(r,o);const[n]=l.getClientRects();if(n!==void 0&&n.height>0)return{top:n.top,bottom:n.bottom}}}const a=e.lineBlockAt(t),s=e.documentTop+a.top;return{top:s,bottom:s+a.height}},Ge=(e,t)=>{const{node:r}=e.domAtPos(t);for(let o=r instanceof Element?r:r.parentElement;o!==null;o=o.parentElement)if(o.parentElement===e.contentDOM)return o;return null},Xe=(e,t)=>{if(e==null)return null;try{return K.EditorState.fromJSON(e,{extensions:t},Te)}catch{return null}},Ke=610,We=987,pe=Object.freeze({kind:"unavailable"}),$e="true",Ye="false",Je=e=>e===$e?!0:e===Ye?!1:null,Qe=e=>{const t=new DOMParser().parseFromString(e,"text/html"),r=[];for(const o of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")){const a=o.localName==="img",s=o.getAttribute(a?"data-asset-src":"data-doc-path");s!==null&&r.push({target:{kind:a?"asset":"doc",path:s},exists:Je(o.getAttribute(a?"data-asset-exists":"data-doc-exists"))})}return r},Ze=({path:e,instant:t,preview:r,initial:o,onView:a})=>{const s=new AbortController,l={asset:new Map,doc:new Map};let n=o,h=null,f=!1,i=!1,u=null,c=null,g=[],m,S=!1,v,k=null;const O=y=>{y.parsed===n.parsed&&y.failure===n.failure&&y.busy===n.busy&&y.tier===n.tier||(n=y,a(y))},A=(y,d)=>{f||(f=!0,console.error(`[markdown-explorer] ${y}`,...d===void 0?[]:[d]))},j=y=>{if(t!==null)for(const{target:d,exists:E}of t.marksOf(y))l[d.kind].set(d.path,E)},D=()=>{clearTimeout(v),v=void 0,k?.abort(),k=null},V=()=>{c=null,g=[],clearTimeout(m),m=void 0},H=(y,d)=>{O({parsed:n.parsed,failure:y,busy:!1,tier:d})},b=()=>{clearTimeout(m),m=g.length===0?void 0:setTimeout(q,We)},T=()=>{if(t===null||c===null)return;const y=c,d=[],E={asset:new Set,doc:new Set};let R;try{R=t.sanitize(y.html,C=>{const U=l[C.kind].get(C.path);return U===void 0&&!E[C.kind].has(C.path)&&(E[C.kind].add(C.path),d.push(C)),U??void 0})}catch(C){V(),C instanceof oe.HtmlNestingLimitError?H(W.failureOf("too-large"),"instant"):(A("the draft sanitizer failed",C),H(W.failureOf("failed"),"instant"));return}g=d;const M=n.parsed!==null&&n.parsed.htmlContent===R&&n.parsed.headings===y.headings?n.parsed:{htmlContent:R,headings:y.headings};O({parsed:M,failure:null,busy:!1,tier:"instant"}),b()},q=()=>{if(m=void 0,S||c===null||g.length===0)return;S=!0;const y=g;r(e,c.text,s.signal).then(d=>{if(S=!1,!(s.signal.aborted||!("kind"in d))){d.kind==="preview"&&j(d.htmlContent);for(const E of y)l[E.kind].has(E.path)||l[E.kind].set(E.path,null);T()}})},P=y=>{D(),V(),O({...n,busy:!0,tier:"server"});const d=new AbortController;k=d,v=setTimeout(()=>{v=void 0,r(e,y,d.signal).then(E=>{if(!(d.signal.aborted||!("kind"in E))){if(k=null,E.kind==="failure"){H(E.failure,"server");return}j(E.htmlContent),O({parsed:{htmlContent:E.htmlContent,headings:E.headings},failure:null,busy:!1,tier:"server"})}})},Ke)},w=async(y,d)=>{let E;try{E=await y.convert({path:e,text:d},s.signal)}catch(M){return s.signal.aborted||A("the draft converter rejected a conversion, which its contract allows only once the signal aborted",M),pe}const R=W.draftAnswerViolation(E);return R===null?E:(A(`the draft converter answered outside its contract: ${R}`),pe)},B=(y,d)=>{switch(d.kind){case"preview":if(D(),d.headings.length>W.EXPLORER_MAX_HEADINGS){V(),H(W.failureOf("too-large"),"instant");return}c={text:y,html:d.htmlContent,headings:d.headings.map(({text:E,depth:R,id:M})=>({text:E,depth:R,id:M}))},T();return;case"failure":D(),V(),H(W.failureOf(d.failure.reason,d.failure.code),"instant");return;case"unavailable":P(y);return}},z=async y=>{i=!0;try{for(;u!==null&&!s.signal.aborted;){const d=u;u=null;const E=await w(y,d);if(s.signal.aborted)return;B(d,E)}}finally{i=!1}};return t!==null&&t.seed!==null&&j(t.seed),{update:y=>{if(!(s.signal.aborted||y===h)){if(h=y,clearTimeout(m),m=void 0,t===null){P(y);return}u=y,i||z(t.converter)}},dispose:()=>{s.abort(),u=null,clearTimeout(m),m=void 0,D()}}},et=(e,t)=>oe.createHtmlSanitizer(_e(window),e,t,oe.MAX_HTML_NESTING_DEPTH),tt=(e,t)=>e.flatMap((r,o)=>{const a=t[o];return a===void 0?[]:[{editor:a.top,preview:r.top},{editor:a.bottom,preview:r.bottom}]}),X=(e,t)=>{const r=e[t];if(r===void 0)throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length-1)}; got ${String(t)}`);return r},rt=e=>{const t=[];for(const o of e){let a=0,s=t.length;for(;a<s;){const l=a+s>>1;X(t,l).pair.preview<=o.preview?a=l+1:s=l}t[a]={pair:o,before:a===0?void 0:X(t,a-1)}}const r=[];for(let o=t.at(-1);o!==void 0;o=o.before)r.push(o.pair);return r.reverse()},nt=(e,t)=>{const r=Math.max(t.editorMax,0),o=Math.max(t.previewMax,0),a=r-t.editorViewport,s=o-t.previewViewport,l=e.filter(f=>f.editor>0&&f.editor<a&&f.preview>0&&f.preview<s).sort((f,i)=>f.editor-i.editor||f.preview-i.preview);let n={editor:0,preview:0};const h=[n];for(const f of rt(l))f.editor>n.editor&&f.preview>n.preview&&(h.push(f),n=f);return h.push({editor:r,preview:o}),{toPreview:f=>me(h,"editor","preview",f),toEditor:f=>me(h,"preview","editor",f)}},me=(e,t,r,o)=>{const a=X(e,0),s=X(e,e.length-1);if(Number.isNaN(o)||o<=a[t])return a[r];if(o>=s[t])return s[r];let l=0,n=e.length-1;for(;n-l>1;){const i=l+n>>1;X(e,i)[t]<=o?l=i:n=i}const h=X(e,l),f=X(e,n);return h[r]+(f[r]-h[r])*(o-h[t])/(f[t]-h[t])},ot=610,he=89,ge=.5,it=({editor:e,preview:t,previewBlocks:r,editorSpans:o,requestFrame:a,cancelFrame:s,now:l})=>{let n="editor",h=0,f=null,i=null,u=!1,c=null,g=null;const m={editor:0,preview:0},S={editor:null,preview:null};let v=null,k=()=>{};const O=w=>{f!==null&&w!==f||(n=w,h=l()+ot)},A=(w,B)=>{w!==n&&f===null&&l()>=h&&!j(w,B)&&(n=w),T()},j=(w,B)=>{const z=S[w];return l()<m[w]||z!==null&&Math.abs(B.position()-z)<ge},D=e.onScroll(()=>A("editor",e)),V=e.onIntent(()=>O("editor")),H=()=>{const w=t();return w!==v&&(k(),v=w,k=w===null?()=>{}:b(w)),w},b=w=>{const B=w.onScroll(()=>A("preview",w)),z=w.onIntent(()=>O("preview"));return()=>{B(),z()}},T=()=>{!u&&i===null&&(i=a(q))},q=()=>{i=null;const w=H();w!==null&&(c??=r(),g??=nt(tt(c,o(c)),{editorMax:e.max(),previewMax:w.max(),editorViewport:e.viewport(),previewViewport:w.viewport()}),n==="editor"?P(w,"preview",g.toPreview(e.position())):P(e,"editor",g.toEditor(w.position())))},P=(w,B,z)=>{if(Math.abs(w.position()-z)<ge){S[B]=w.position();return}m[B]=l()+he,S[B]=w.scrollTo(z)};return T(),{editorChanged:w=>{g=null,w&&O("editor"),T()},previewChanged:()=>{c=null,g=null,m.preview=l()+he,T()},showAlone:w=>{f=w,!(w===null||w===n)&&(n=w,h=0,T())},dispose:()=>{u=!0,i!==null&&s(i),i=null,D(),V(),k()}}},ve=Object.freeze(["wheel","pointerdown","keydown","focusin"]),qe=e=>({position:()=>e.scrollTop,max:()=>Math.max(e.scrollHeight-e.clientHeight,0),viewport:()=>e.clientHeight,scrollTo:t=>(e.scrollTo({top:t,behavior:"instant"}),e.scrollTop),onScroll:t=>(e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)),onIntent:t=>{for(const r of ve)e.addEventListener(r,t,{capture:!0,passive:!0});return()=>{for(const r of ve)e.removeEventListener(r,t,{capture:!0})}}}),$="[data-aqmd-scroll-container]",st="[data-aqmd-content]",lt=`[${ne.SOURCE_LINES_ATTRIBUTE}]`,at=Object.freeze(["p1","p2","p3","p4","p5","p6","p7","p8"]),Re=(e,t)=>{const r=x.loadedOf(e.peek(t));return r!==null&&r.document.kind==="markdown"?{htmlContent:r.document.htmlContent,headings:r.document.headings}:null},ct=(e,t,r,o,a)=>{if(r===void 0)return null;let s;try{s=et(e,t)}catch(l){return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview",l),null}return{converter:r,sanitize:s,marksOf:Qe,seed:Re(o,a)?.htmlContent??null}},ut=e=>{const t=[];let r=null;for(const o of e.querySelectorAll(lt)){const a=ne.parseSourceLines(o.getAttribute(ne.SOURCE_LINES_ATTRIBUTE));if(a===null||o.getClientRects().length===0)continue;r??=e.scrollTop-x.visibleTopOf(e,o);const{top:s,bottom:l}=o.getBoundingClientRect();t.push({first:a.first,last:a.last,top:r+s,bottom:r+l})}return t},dt=({path:e,readDraft:t,viewer:r,concealed:o,onEditAt:a,onLayout:s,handleRef:l})=>{const{config:n,data:h,documents:f,draftConverter:i,labels:u}=x.useExplorer(),[c,g]=p.useState(()=>({parsed:Re(f,e),failure:null,busy:!0,tier:i===void 0?"server":"instant"})),m=p.useRef(null),S=p.useRef(null),v=p.useRef(c);p.useLayoutEffect(()=>{v.current=c});const k=p.useEffectEvent(()=>t());p.useEffect(()=>{const b=ct(n.iframeHosts,n.dataPath,i,f,e),T=Ze({path:e,instant:b,preview:h.preview,initial:v.current,onView:q=>p.startTransition(()=>g(q))});return S.current=T,T.update(k()),()=>{T.dispose(),S.current=null}},[n,h,f,i,e]);const O=p.useEffectEvent(()=>s());p.useLayoutEffect(()=>{c.parsed!==null&&O()},[c.parsed]);const A=c.parsed!==null;p.useLayoutEffect(()=>{const b=A?m.current?.querySelector($):null;if(!(b instanceof HTMLElement))return;b.tabIndex=0;const T=new ResizeObserver(()=>O());T.observe(b);const q=b.querySelector(st);return q!==null&&T.observe(q),()=>T.disconnect()},[A]);const j=p.useRef(null);p.useImperativeHandle(l,()=>({draft:b=>{S.current?.update(b)},scrollPort:()=>{const b=m.current?.querySelector($);return b instanceof HTMLElement?(j.current?.scroller!==b&&(j.current={scroller:b,port:qe(b)}),j.current.port):null},blocks:()=>{const b=m.current?.querySelector($);return b instanceof HTMLElement?ut(b):[]},focus:()=>{const b=m.current?.querySelector($);b instanceof HTMLElement&&b.focus({preventScroll:!0})},anchor:b=>{const T=m.current,q=T?.querySelector($);return T===null||!(q instanceof HTMLElement)?null:x.anchorOfView(T,b(q))},place:({line:b,clientTop:T},q)=>{const P=m.current,w=P===null?null:x.blockAtLine(P,b);w!==null&&(q(w).scrollTop+=x.lineTopIn(w,b)-T)}}),[]);const D=b=>{const T=m.current,{target:q}=b;if(a===void 0||T===null||!(q instanceof Element)||!x.isEditingDoubleClick(q))return;const P=x.anchorOfDoubleClick(q,T,T.ownerDocument.getSelection());P!==null&&a(P)},V=p.useMemo(()=>({...r,showToc:!1,showStyle:!1,showAlign:!1,renderScrollBar:void 0}),[r]),H=p.useMemo(()=>c.parsed===null?null:L.jsx("div",{className:"aqmx-document-viewer",children:L.jsx(Ce.MarkdownViewer,{...V,parseResult:c.parsed,content:null})}),[V,c.parsed]);return L.jsxs("section",{ref:m,className:"aqmx-edit-preview","aria-label":u.previewRegion,"aria-busy":c.busy,inert:o!==null,hidden:o==="removed","data-aqmx-preview-tier":c.tier,"data-testid":"markdown-explorer-edit-preview",onDoubleClick:a===void 0?void 0:D,children:[c.failure===null?null:L.jsx("p",{className:"aqmx-callout aqmx-document-notice","data-aqmx-tone":"warning","data-testid":"markdown-explorer-edit-preview-failure",children:u.previewFailed(x.failureTitleOf(u,c.failure.reason))}),H??(c.failure===null?L.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-preview-skeleton",children:at.map(b=>L.jsx("span",{},b))}):null),c.busy?L.jsx("p",{className:"aqmx-sr-only",children:u.previewUpdating}):null]})},we="data-aqmx-edit-split",re="--aqmx-edit-share",Ee="--aqmx-edit-gutter",ft="data-aqmx-edit-split-probe",pt="aqmx-edit-split",mt="aqmx-edit-editor",ht="aqmx-edit-preview",be={value:G.EDIT_SPLIT_MIN_PERCENT,unit:"percentage"},xe={value:G.EDIT_SPLIT_MAX_PERCENT,unit:"percentage"},Se=e=>{if(e.length!==2)return null;const[t=0,r=0]=e,o=t+r;return o>0?t/o*100:null},Z=e=>{const t=e.current?.parentElement;if(t==null)throw new Error("[markdown-explorer] the edit split is not mounted in its surface");return t},gt=(e,t,r)=>{const[o,a]=p.useState(null);return p.useLayoutEffect(()=>{const s=e.current,l=t.current;if(s===null||l===null)throw new Error("[markdown-explorer] the edit split is not mounted");const n={frame:s.getBoundingClientRect().width,measure:l.getBoundingClientRect().width},h=()=>{n.frame>0&&n.measure>0&&a(G.editSplitOrientation(n.frame,n.measure,r))};h();const f=new ResizeObserver(i=>{for(const u of i){const[c]=u.borderBoxSize;c!==void 0&&(u.target===s&&(n.frame=c.inlineSize),u.target===l&&(n.measure=c.inlineSize))}h()});return f.observe(s),f.observe(l),()=>f.disconnect()},[e,t,r]),o},vt=({editorId:e})=>{const{edits:t,labels:r}=x.useExplorer(),o=p.useRef(null),a=p.useRef(null),s=ue.useCoarsePointer()?G.COARSE_TARGET_PIXELS:G.FINE_TARGET_PIXELS,l=gt(o,a,s),[n]=p.useState(()=>t.editorShare());p.useLayoutEffect(()=>{const i=Z(o);return i.style.setProperty(Ee,`${String(s)}px`),()=>{i.style.removeProperty(Ee)}},[s]),p.useLayoutEffect(()=>{const i=Z(o);return i.style.setProperty(re,`${String(n)}%`),()=>{i.style.removeProperty(re)}},[n]),p.useLayoutEffect(()=>{if(l===null)return;const i=Z(o);return i.setAttribute(we,l),()=>i.removeAttribute(we)},[l]);const h=ue.useSplitPersistence(p.useCallback(i=>{const u=Se(i);u!==null&&t.setEditorShare(u)},[t])),f=p.useCallback((i,u)=>{const c=Se(i);c!==null&&Z(o).style.setProperty(re,`${String(c)}%`),h.layoutChanged(i,u)},[h]);return L.jsxs("div",{ref:o,className:"aqmx-edit-split","data-testid":"markdown-explorer-edit-split",children:[L.jsx("span",{ref:a,className:"aqmx-edit-split-probe","aria-hidden":"true",[ft]:""}),l===null?null:L.jsxs(Q.PanelGroup,{id:pt,direction:l==="beside"?"horizontal":"vertical",onLayout:f,className:"aqmx-edit-split-group",children:[L.jsx(Q.Panel,{id:mt,defaultSize:{value:n,unit:"percentage"},minSize:be,maxSize:xe,contentOverflow:"hidden"}),L.jsx(Q.PanelResizeHandle,{thickness:s,indicator:{visible:!0,thickness:G.SPLIT_HANDLE_PIXELS.gripThickness,length:G.SPLIT_HANDLE_PIXELS.gripLength,barThickness:G.SPLIT_HANDLE_PIXELS.barThickness,barLength:G.SPLIT_HANDLE_PIXELS.barLength},title:r.editViewSplitResize,"aria-label":r.editViewSplitResize,"aria-controls":e,onDragging:h.draggingChanged,className:"aqmx-split-handle aqmx-edit-split-handle"}),L.jsx(Q.Panel,{id:ht,defaultSize:{value:100-n,unit:"percentage"},minSize:be,maxSize:xe,contentOverflow:"hidden"})]})]})},Oe=144,wt=Object.freeze(["e1","e2","e3","e4","e5","e6","e7","e8"]),Et=e=>{if(typeof e!="object"||e===null)return!1;const{generation:t,topLine:r}=e;return"state"in e&&typeof t=="number"&&typeof r=="number"},bt=e=>{e.stopPropagation()},xt=e=>{const{path:t,name:r,session:o}=e,{edits:a,labels:s,announcer:l}=x.useExplorer(),{phase:n}=o,h=p.useCallback(()=>a.retry(t),[a,t]);switch(p.useEffect(()=>{n.kind==="failed"&&l.announce(s.documentFailed(r,x.failureTitleOf(s,n.failure.reason)))},[n,l,s,r]),n.kind){case"opening":return L.jsxs(L.Fragment,{children:[L.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:wt.map(f=>L.jsx("span",{},f))}),L.jsx("p",{className:"aqmx-sr-only",children:s.editLoading})]});case"grant":return L.jsx("div",{className:"aqmx-edit-message",children:L.jsx(x.EditGrantNotice,{href:n.href,onRetry:h,testId:"markdown-explorer-edit-grant"})});case"failed":return L.jsx("div",{className:"aqmx-edit-message",children:L.jsx(x.FailureView,{failure:n.failure,alert:!1,onRetry:h,testId:"markdown-explorer-edit-failure"})});case"editing":return L.jsx(St,{...e})}},St=({path:e,name:t,session:r,layout:o,viewer:a,region:s,paneScroll:l})=>{const{edits:n,labels:h}=x.useExplorer(),f=p.useRef(null),i=p.useId(),u=p.useRef(null),c=p.useRef(null),g=p.useRef(null),m=o==="fill",S=x.useSideBySide(),v=x.editViewOf(r,S,m),k=v!=="editor"||r.previewPrepared,O=k&&m,A=p.useRef({layout:o,region:s,paneScroll:l});p.useLayoutEffect(()=>{A.current={layout:o,region:s,paneScroll:l}});const j=p.useRef(r.generation);p.useLayoutEffect(()=>{j.current=r.generation});const D=p.useRef({view:v,previewMounted:k});p.useLayoutEffect(()=>{D.current={view:v,previewMounted:k}});const V=p.useRef(null),H=p.useRef(null),b=p.useRef(!1),T=p.useMemo(()=>({editor:h.editorLabel(t),useOurs:h.conflictUseOurs,useTheirs:h.conflictUseTheirs,keepBoth:h.conflictKeepBoth}),[h,t]),q=p.useCallback(d=>{const{region:E,paneScroll:R}=A.current,M=E();return M===null?d:R.scrollerOf(M,d)},[]);p.useLayoutEffect(()=>{const d=f.current,E=n.draft(e);if(d===null||E===null)return;const R=n.editorState.get(e),M=Et(R)&&R.generation===j.current?R:null;let C=null,U=null;const te=()=>{C!==null&&clearTimeout(C),C=null,U!==null&&n.setDraft(e,U.text())},F=ze({parent:d,scroll:{scrollerOf:N=>{const{layout:J,region:Ie,paneScroll:Me}=A.current,le=Ie();return J==="fill"||le===null?N:Me.scrollerOf(le,N)},reveal:N=>A.current.paneScroll.reveal(N)},text:E,saved:M===null?void 0:M.state,labels:T,onGeometry:N=>g.current?.editorChanged(N),onChange:()=>{C??=setTimeout(te,Oe),D.current.previewMounted&&U!==null&&c.current?.draft(U.text())},onSave:()=>{n.save(e)}});U=F,u.current=F;const ie=()=>{const N=F.topLine();return{line:N.line,clientTop:N.clientTop}},se=()=>c.current?.anchor(q)??null,Ae=n.bindEditor(e,{flush:te,adopt:N=>F.replaceText(N),returnPoint:()=>{const N=D.current.view==="preview"&&A.current.layout==="content"?se():null;return N===null?ie():{line:N.lines.first,clientTop:N.clientTop}},nextConflict:()=>D.current.view!=="preview"?F.nextConflict():F.conflicts().length===0?!1:(b.current=!0,n.setView(e,"editor"),!0),beforeView:N=>{if(A.current.layout==="fill")return;if(N==="preview"){V.current={to:"preview",point:ie()};return}const J=se();V.current=J===null?null:{to:"editor",anchor:J}}});return M!==null&&F.showLine(M.topLine),()=>{te(),n.editorState.set(e,{state:F.save(),generation:j.current,topLine:F.topLine().line}),Ae(),F.destroy(),U=null,u.current=null}},[n,e,T,q]);const{request:P}=r;p.useLayoutEffect(()=>{const d=u.current,E=n.draft(e);d===null||E===null||P===null||(P.anchor!==null&&d.reveal(x.positionInSource(E,P.anchor),P.anchor.clientTop),d.focus(),n.consumeRequest(e))},[n,e,P,T]),p.useLayoutEffect(()=>{v!=="editor"&&!r.previewPrepared&&n.preparePreview(e)},[n,e,v,r.previewPrepared]),p.useLayoutEffect(()=>{const d=V.current,E=H.current,R=b.current;V.current=null,H.current=null,b.current=!1;const M=u.current;if(d?.to==="preview")c.current?.place(d.point,q);else if(d?.to==="editor"&&M!==null){const C=n.draft(e);C!==null&&M.reveal(x.positionInSource(C,d.anchor),d.anchor.clientTop)}R?M?.nextConflict():E==="editor"?M?.focus():E==="preview"&&c.current?.focus()},[n,e,v,q]);const w=p.useCallback(()=>{const d=u.current;if(d===null)throw new Error("[markdown-explorer] the preview read the draft before the editor was mounted");return d.text()},[]);p.useLayoutEffect(()=>{const d=u.current;if(!O||d===null)return;const E=it({editor:qe(d.scrollElement),preview:()=>c.current?.scrollPort()??null,previewBlocks:()=>c.current?.blocks()??[],editorSpans:R=>d.lineSpans(R),requestFrame:R=>requestAnimationFrame(R),cancelFrame:R=>cancelAnimationFrame(R),now:()=>performance.now()});return E.showAlone(x.paneShownAlone(D.current.view)),g.current=E,()=>{E.dispose(),g.current=null}},[O,n,e,T]),p.useLayoutEffect(()=>{g.current?.showAlone(x.paneShownAlone(v))},[v]);const B=p.useCallback(()=>g.current?.previewChanged(),[]),z=p.useCallback(d=>n.start(e,d),[n,e]),y=d=>{if(d.key==="Escape"){x.consumeKey(d);return}if(!x.isEditViewShortcut(d.nativeEvent,x.isApplePlatform(navigator.platform)))return;x.consumeKey(d);const E=x.toggledEditView(v);H.current=E,x.chooseEditView(n,e,E,m)};return L.jsxs("div",{className:"aqmx-edit","data-aqmx-edit-layout":o,"data-aqmx-edit-view":v,"data-testid":"markdown-explorer-edit",onKeyDown:y,onDoubleClick:bt,children:[L.jsx("div",{ref:f,id:i,className:"aqmx-edit-editor","data-testid":"markdown-explorer-editor",inert:v==="preview",hidden:v==="preview"&&!m,...x.ALLOW_KEY_REPEAT}),v==="split"?L.jsx(vt,{editorId:i}):null,k?L.jsx(dt,{path:e,readDraft:w,viewer:a,concealed:v!=="editor"?null:m?"overlay":"removed",onEditAt:v==="preview"?z:void 0,onLayout:B,handleRef:c}):null]})};exports.DRAFT_WRITE_INTERVAL_MS=Oe;exports.default=xt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as L, jsxs as j, Fragment as ze } from "react/jsx-runtime";
|
|
2
2
|
import { useState as le, useRef as _, useLayoutEffect as N, useEffectEvent as fe, useEffect as Oe, useImperativeHandle as Fe, useMemo as ie, startTransition as Ge, useCallback as W, useId as Ue } from "react";
|
|
3
|
-
import { v as Y, g as ae, h as Ke, u as te, i as We, l as Xe, j as $e, k as qe, m as je, n as Ye, o as Je, p as Qe, E as Ze, q as et, s as tt, t as me, w as pe, A as rt, x as he, y as nt, z as ot, B as it, G as st } from "./index-
|
|
3
|
+
import { v as Y, g as ae, h as Ke, u as te, i as We, l as Xe, j as $e, k as qe, m as je, n as Ye, o as Je, p as Qe, E as Ze, q as et, s as tt, t as me, w as pe, A as rt, x as he, y as nt, z as ot, B as it, G as st } from "./index-Dz01kBab.js";
|
|
4
4
|
import { history as lt, historyKeymap as at, defaultKeymap as ct, historyField as ut } from "@codemirror/commands";
|
|
5
5
|
import { markdown as dt, markdownLanguage as ft } from "@codemirror/lang-markdown";
|
|
6
6
|
import { syntaxHighlighting as mt, HighlightStyle as pt } from "@codemirror/language";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),v=require("./index-DrKHJNY4.cjs"),r=require("react"),A=require("./location-BVEN_Ihk.cjs"),He=require("@aiquants/directory-tree"),mt=require("./tapScrollCircle-C5DGI-0H.cjs"),pt=require("./storage-DM0EvkVf.cjs"),xe=require("@aiquants/resize-panels"),Ae=require("./useSplitPersistence-Ba-v64n-.cjs"),ht=require("react-router");function xt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=xt(r);function wt({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const gt=p.forwardRef(wt);function Et({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const bt=p.forwardRef(Et);function vt({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),p.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const Rt=p.forwardRef(vt);function yt({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const St=p.forwardRef(yt),kt=()=>{const{notices:e}=v.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function Ct({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const Tt=p.forwardRef(Ct),ye=r.createContext(!0),Ze="\0loop\0",$e="\0",Lt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(h=>{const x=u(h,l,i);return x!==h&&(f=!0),x});if(!f)return o;const d=n.get(o);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(o,m),m)},u=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",d=m?f.entries:o.children;if(d===void 0)return o;i.add(o.path);const h=s(d,l,i);if(i.delete(o.path),!m&&h===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===h)return x.grafted;const g={...o,children:h,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:h,grafted:g}),g};return(o,l)=>s(o,l,new Set)},jt=(e,t)=>`${Ze}${e}${$e}${t}`,ie=e=>e.startsWith(Ze),Pt=e=>e.slice(e.lastIndexOf($e)+1),re="data-aqmx-path",Nt=(e,t,n,a,s)=>{const u={aqmxPath:e.path};return e.modifiedAt!==void 0&&(u.aqmxModifiedAt=e.modifiedAt),n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:u}},Ot=(e,t,n,a)=>{const s=jt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},At=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(h=>h.type==="loop"?u(h,i,f):o(h,i)),d=n.get(l);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(l,m),m)},u=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const d=Ot(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:d,parentKey:f,loopFolderName:i.loopFolderName}),d},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),d=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,h=d==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===d&&x.children===f&&x.renderFailedFolder===h)return x.row;const g=Nt(l,f,m,d,h===void 0?void 0:h(l));return e.set(l,{row:g,open:m,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(l,i)=>s(l,i,"")},qt=e=>{if(e===void 0)return;const t=n=>{const a=n.data?.aqmxModifiedAt;return typeof a=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:a}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,a)=>e(t(n),t(a))},Re=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},Mt=(e,t)=>{const n=new Map;let a=0;const s=u=>{for(const o of Re(u,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},Ft=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},Be=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Be(n.children,t);if(a!==null)return a}return null},_t=(e,t,n,a)=>{let s=e;for(const u of t){const o=s.find(l=>l.type==="directory"&&l.path===u);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(u=>u.type==="file"&&u.path===n)?"ready":"missing"},qe=new Set,It=(e,t)=>e.has(t)?e:new Set(e).add(t),Dt=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},Ht=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Zt=()=>{const[e,t]=r.useState(qe),n=r.useCallback(o=>t(l=>It(l,o)),[]),a=r.useCallback(o=>t(l=>Dt(l,o)),[]),s=r.useCallback(o=>t(l=>Ht(l,o)),[]),u=r.useCallback(()=>t(qe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:u}),[e,n,a,s,u])},$t=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),Bt=(e,t)=>{const n=[];let a=Re(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const u=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&u.push(...Re(o.children,t.compare))}a=u}return n},ze=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ze(n.children,t))),zt=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ze(t.entries,t.isShownExpanded)}},ve=Object.freeze({state:"idle"}),Vt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(ve);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=$t(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(ve)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=Bt(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const h=zt(f,i);s(h.kind==="done"?ve:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;s(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:o,advance:l}),[a,u,o,l])},Me=["pointerdown","wheel","touchstart","keydown","focusin"],Kt=8,Fe={least:Number.POSITIVE_INFINITY,stalled:0},Xt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:u,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(Fe),d=r.useRef(null),h=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const E=r.useCallback(()=>{const y=d.current;y!==null&&(d.current=null,y.phase==="asking"?y.controller.abort():x.current?.open(null))},[]),j=r.useCallback(()=>{i.current=null,E()},[E]),L=r.useCallback(()=>{const y=t.current;i.current===null||h.current!==null||y===null||y.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const T=i.current;if(T===null)return;const S=g.current(T);if(S===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(T,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:q,stalled:_}=m.current;m.current=S<q?{least:S,stalled:0}:{least:q,stalled:_+1},m.current.stalled<Kt&&L();return}const b=d.current;if(b===null){i.current=null;return}b.phase==="opening"&&x.current?.progress(b.folders,T)!=="loading"&&j()}))},[e,t,E,j]),N=r.useCallback(()=>{f.current=!1,m.current=Fe,L()},[L]);r.useEffect(()=>{const y=t.current;if(y===null)return;const T=typeof ResizeObserver>"u"?null:new ResizeObserver(N);T?.observe(y);for(const S of Me)y.addEventListener(S,j,{passive:!0});return()=>{T?.disconnect();for(const S of Me)y.removeEventListener(S,j);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,N,j,E]);const R=a!==null;r.useEffect(()=>{const y=t.current;if(j(),n===null||y===null||y.contains(y.ownerDocument.activeElement))return;i.current=n;const T=x.current;if(R&&T!==null){const S=new AbortController,b={phase:"asking",controller:S};d.current=b,T.ancestors(n,S.signal).then(q=>{d.current===b&&(q===null?d.current=null:(d.current={phase:"opening",folders:q},x.current?.open(q)),N())})}N()},[n,R,t,j,N]),r.useEffect(()=>{(d.current?.phase==="opening"||i.current!==null&&!f.current)&&N()},[s,N]);const F=r.useRef(u);r.useEffect(()=>{F.current!==u&&(F.current=u,j())},[u,j]);const C=r.useRef(o);r.useEffect(()=>{C.current&&!o&&E(),C.current=o},[o,E])},Wt="--aqmx-tree-line",Gt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Ut="data-aqmx-tree-probe",Yt=Object.freeze({rowHeight:A.CONTROL_BLOCK_PIXELS,lineColor:null}),Qt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Jt=e=>{const t=Qt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},en=(e,t)=>{const[n,a]=r.useState(Yt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const u=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Wt).trim()===""?null:Jt(f.color);a(d=>{const h=Number.isFinite(i)&&i>0?i:d.rowHeight;return d.rowHeight===h&&d.lineColor===m?d:{rowHeight:h,lineColor:m}})};u();const o=Gt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",u);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",u);l?.disconnect()}},[e,t]),n},Ve="markdown-explorer-tree-scroll",tn=.5,Ke=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${re}]`)].find(n=>n.getAttribute(re)===t),nn=(e,t)=>{const n=Ke(e,t),a=n?.closest(`[data-testid="${Ve}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),u=n.getBoundingClientRect(),o=s.top-u.top,l=u.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,u.bottom-s.bottom);return l<=tn?0:l},rn={testId:Ve,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:mt.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},an={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},ln={color:"inherit",fontSize:"inherit"},on={fontSize:"inherit"},sn=new Set,cn=new Map,un={color:"var(--aqmx-tree-line)"},dn=e=>{const t=e instanceof Element?e.closest(`[${re}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(re)},Xe=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),fn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):Xe(e,t,n.kind,n.opened),We=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},mn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Tt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},pn=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),a=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const u=s.currentTarget,o=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&v.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},hn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:u,openPaths:o,selection:l,onOpenDocument:i,folders:f,onRevealSource:m,expansion:d,onShown:h,marks:x,claimsHeld:g,expandAll:E,revealCancel:j})=>{const{trees:L,documents:N,labels:R,locale:F,theme:C,data:y,config:T,sources:S,reveals:b}=v.useExplorer(),q=r.use(ye),[_]=r.useState(At),ae=r.useRef(null),{rowHeight:Q,lineColor:Z}=en(ae,C),{isExpanded:$,toggle:J,expandMultiple:I,collapseMultiple:X,expanded:W,isPending:G}=d,{alwaysExpanded:O,sortMode:ee,folderPlacement:le,readmePlacement:ue}=s,{direct:te,markDirect:B,unmarkDirect:U,pruneDirect:fe}=x,{running:oe,advance:se}=E,de=r.useRef(null),ne=r.useRef(null),z=r.useMemo(()=>A.createEntryComparator({sortMode:ee,folderPlacement:le,readmePlacement:ue}),[ee,le,ue]),P=r.useMemo(()=>qt(z),[z]),M=r.useCallback(w=>L.children(a,w),[L,a]),D=r.useMemo(()=>Ft(e),[e]),Y=r.useCallback(w=>!ie(w)&&($(w)||O&&!D.has(w)),[$,O,D]),V=r.useRef({shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M});r.useLayoutEffect(()=>{V.current={shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M}},[Y,$,D,e,M]);const Ce=r.useCallback(w=>{de.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const k=ne.current,H=k===null?void 0:Ke(k,w);H!==void 0&&v.focusWithoutScroll(H)})},[]),tt=r.useCallback(w=>{if(ie(w)){Ce(Pt(w));return}V.current.isExpanded(w)?U([w]):V.current.unloadedFolders.has(w)&&B(w),J(w)},[Ce,B,U,J]),ge=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(U(k),X(k))},[U,X]),nt=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(k.length<w.length&&k.every(H=>V.current.shownExpanded(H))?ge(k):I(k))},[I,ge]),Te=r.useCallback(w=>c.jsx(pn,{name:w.name,onRetry:()=>{B(w.path),L.retryChildren(a,w.path),V.current.shownExpanded(w.path)||I([w.path])}}),[L,a,B,I]),Le=n==="multi"?o:sn,{loopFolderName:je}=R,rt=r.useMemo(()=>_(e,{openPaths:Le,childrenOf:M,renderFailedFolder:Te,loopFolderName:je}),[_,e,Le,M,Te,je,t]),at=v.useIntentPrefetch(N,dn),Pe=r.useRef([]),me=r.useCallback(()=>{for(const w of Pe.current)V.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:Ee}=T.revealDocument,Ne=r.useRef(m);r.useLayoutEffect(()=>{Ne.current=m},[m]);const lt=r.useMemo(()=>({ancestors:async(w,k)=>{const H=b.take(a,w);if(H!==null)return H;if(!b.mayMove(w)){const ce=await y.ancestors(a,w,k);return ce.status!=="ok"||ce.ancestors===null||ce.ancestors.length>Ee?null:ce.ancestors}const K=await y.reveal(a,w,k);return K.status!=="ok"||K.source===null||K.ancestors.length>Ee?null:K.source===a?K.ancestors:(k.aborted||!S.some(ce=>ce.id===K.source)||(b.move(K.source,w,K.ancestors),Ne.current(K.source)),null)},open:w=>{Pe.current=w??[],w!==null&&(me(),I([...w]))},progress:(w,k)=>_t(V.current.entries,w,k,{isShownExpanded:V.current.shownExpanded,childrenOf:V.current.childrenOf})}),[y,a,S,b,Ee,me,I]);r.useEffect(()=>me(),[me,D]);const ot=r.useMemo(()=>[e,t,W],[e,t,W]),st=r.useCallback(w=>ne.current===null?Number.POSITIVE_INFINITY:nn(ne.current,w),[]);Xt({tree:de,container:ne,path:u.path,chain:u.openFolders?lt:null,rows:ot,cancel:j,displayed:q,placement:st});const Oe=r.useCallback(w=>te.has(w),[te]),pe=r.useMemo(()=>Mt(e,{isShownExpanded:Y,childrenOf:M,compare:z,isDirect:Oe}),[e,Y,M,z,Oe,t]),he=q&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(a,he?pe.folders:cn),[L,a,he,pe]),r.useEffect(()=>fe(D),[fe,D]),r.useEffect(()=>{he&&oe&&se({entries:e,isShownExpanded:Y,childrenOf:M,compare:z,expanded:W,waiting:pe.waiting,expansionPending:G})},[he,oe,se,e,Y,M,z,W,pe,G]);const ct=r.useCallback(w=>{const k=w.entry.absolutePath;if(w.isDirectory){if(f===null||ie(k)||k===f.current)return;w.isExpanded&&w.preventDefault(),b.settle(k),f.open(k);return}b.settle(k),i(k)},[b,i,f]),{onChange:be}=l,it=r.useMemo(()=>be===null?void 0:(w,k)=>{ie(w.absolutePath)||be({path:w.absolutePath,name:w.name,selected:k})},[be]),ut=r.useMemo(()=>new Set(l.items),[l.items]),dt=r.useMemo(()=>({entryKindDirectory:R.treeEntryKindDirectory,entryKindFile:R.treeEntryKindFile,scrollUp:R.treeScrollUp,scrollDown:R.treeScrollDown,scrollToTop:R.treeScrollToTop,scrollToBottom:R.treeScrollToBottom}),[R]),ft=Z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:Z};return c.jsxs("div",{ref:ne,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...at,children:[c.jsx("span",{ref:ae,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Ut]:""}),c.jsx(He.DirectoryTree,{ref:de,entries:rt,expansion:{toggle:tt,isExpanded:Y,expandMultiple:nt,collapseMultiple:ge,isPending:G&&!oe,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ut,onEntryClick:ct,onSelectionChange:it},visual:{className:"aqmx-explorer-tree-view",ariaLabel:R.treeRegion,...ft,showExpandIcons:s.expandIcons,expandIconStyle:un,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:Q,removeRootIndent:s.removeRootIndent,highlightStyles:an,entryStyle:on,nameStyle:ln},virtualScroll:rn,sort:P,locale:F,labels:dt})]})},xn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),a=t.state!=="running",[s,u]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){u(0);return}if(e>0){u(e);return}if(s===0)return;const f=setTimeout(()=>u(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},wn=({stop:e,opened:t,budget:n})=>{const{labels:a}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:Xe(a,n,e,t)})},gn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[u]=r.useState(Lt),o=r.useMemo(()=>u(e,l=>n.children(s,l)),[u,e,n,s,a]);return o.length===0?c.jsx(mn,{}):c.jsx(hn,{entries:o,version:a,...t})},En=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=v.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(We,{});if(s.status==="ok")return c.jsx(gn,{entries:s.entries,...n});const u=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:u!==void 0?u:c.jsx(v.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},bn=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:u,config:o}=v.useExplorer(),{sourceId:l}=t,i=He.useDirectoryTreeState({storageKey:pt.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const d=Zt(),{expanded:h,expandMultiple:x,collapseAll:g}=i,[E,j]=r.useState(null),L=E!==h,N=r.useRef(h);r.useLayoutEffect(()=>{N.current=h},[h]);const R=o.expandAll,F=r.useCallback(()=>u.announce(s.expandAllStarted),[u,s]),C=r.useCallback(O=>u.announce(fn(s,R,O)),[u,s,R]),y=Vt({budget:R,expandMultiple:x,onStart:F,onFinish:C}),{status:T,start:S,end:b,advance:q}=y,_=T.state==="running",ae=r.useMemo(()=>({running:_,advance:q}),[_,q]),Q=r.useRef(null),[Z,$]=r.useState(!1),J=r.useCallback(O=>{Q.current=O,$(O!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(O=>{const ee=O.sourceId===l&&Q.current!==null?Be(Q.current,O.path):null;ee!==null&&u.announce({list:s.foldersLoadFailedNamed,item:ee.name})}),[n,l,u,s]);const{clearDirect:I}=d,[X,W]=r.useState(0),G=r.useCallback(()=>{W(O=>O+1),b(),I(),j(N.current),g()},[b,I,g]);return r.useEffect(()=>{e({collapseAll:G,expandAll:Z?S:null,expanding:_})},[e,G,S,Z,_]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{Z||b()},[Z,b]),c.jsxs(c.Fragment,{children:[T.state==="stopped"?c.jsx(wn,{stop:T.stop,opened:T.opened,budget:R}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(We,{}),children:c.jsx(En,{result:f,onRetry:m,expansion:i,onShown:J,marks:d,claimsHeld:L,expandAll:ae,revealCancel:X,...t})}),c.jsx(xn,{pending:n.pendingChildren(l),status:T})]})]})};function vn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ge=p.forwardRef(vn),_e="markdown-explorer-selection-remove",Rn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:u}=v.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${_e}"]`)],g=x.indexOf(h),E=[x[g+1],x[g-1]].find(j=>j!==void 0);E===void 0?s():E.focus()}t(d)},m=()=>{const d=l.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:u.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:u.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(h),title:u.removeFromSelection(h),"data-testid":_e,"data-aqmx-path":d,onClick:x=>f(d,x.currentTarget),children:c.jsx(Ge,{"aria-hidden":"true"})})]},d))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([d])=>d)),children:u.openSelectionInMulti(i.length)})]})},we=new Map,yn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},Sn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Ue=r.createContext(null),kn=e=>{const t=r.use(Ue);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Cn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Tn=p.forwardRef(Cn);function Ln({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const jn=p.forwardRef(Ln);function Pn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Nn=p.forwardRef(Pn);function On({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.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"}))}const An=p.forwardRef(On);function qn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const Mn=p.forwardRef(qn);function Fn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const _n=p.forwardRef(Fn);function In({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const Dn=p.forwardRef(In);function Hn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Zn=p.forwardRef(Hn);function $n({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-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.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),p.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 Bn=p.forwardRef($n);function zn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const Vn=p.forwardRef(zn);function Kn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const Xn=p.forwardRef(Kn);function Wn({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Gn=p.forwardRef(Wn);function Un({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Yn=p.forwardRef(Un),Qn=Object.freeze({sortMode:jn,folderPlacement:Vn,readmePlacement:Nn,selectionMode:An,doubleClickAction:Zn,expandIconSize:Gn,alwaysExpanded:Tn,revealDocument:v.ForwardRef$1,removeRootIndent:Mn,lines:Yn,expandIcons:_n,directoryIcons:Xn,fileIcons:Bn}),Ye=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Jn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:u})=>{const{labels:o}=v.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const d=n.length;l.current[(m%d+d)%d]?.focus()},[n.length]),f=r.useCallback((m,d)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(d+1);break;case"ArrowUp":m.preventDefault(),i(d-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":v.consumeKey(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:u,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,d)=>{const h=Qn[m.key],x=Ye(o,m),g=A.formatTreeSettingValue(o,t,m.key),E=t[m.key],j=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:L=>{l.current[d]=L},type:"button",tabIndex:-1,...j,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},er=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=v.useExplorer(),[u,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),d=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!u)return;const g=E=>{E.target instanceof Node&&(l.current?.contains(E.target)===!0||i.current?.contains(E.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!u||(v.consumeKey(g),d())},[u,d]),x=r.useCallback(g=>{const E=n(g.key);s.announce(a.settingAnnouncement(Ye(a,g),A.formatTreeSettingValue(a,E,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:h,children:c.jsx(Dn,{"aria-hidden":"true"})}),menu:u?c.jsx(Jn,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},tr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Ie=new Set,nr='[role="tree"] [role="treeitem"][tabindex="0"]',rr="[data-directory-tree-tab-stop]",ar=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:u,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:d,documents:h,announcer:x,reveals:g}=v.useExplorer(),{settings:E,advance:j}=tr(),L=r.useMemo(()=>A.visibleTreeSettingDescriptors(t==="tree"),[t]),N=t==="tree"&&E.selectionMode==="multiple";kn(N);const R=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,C=e.mode==="tree"?e.onOpenFolder:null,y=e.mode==="tree"&&e.currentFolder,T=r.useMemo(()=>C===null?null:{current:a,open:C},[C,a]),S=e.mode==="tree"&&N?e.tray.gathered:we,b=r.useCallback(P=>{const M=j(P);return M.selectionMode!=="multiple"&&R?.(we),M},[j,R]),q=er({settings:E,descriptors:L,onAdvance:b}),_=r.useCallback(P=>R?.(M=>yn(M,P)),[R]),ae=r.useCallback(P=>R?.(M=>Sn(M,P)),[R]),Q=r.useCallback(()=>R?.(we),[R]),Z=r.useRef(null),$=r.useCallback(()=>{const P=Z.current;if(P===null)return;[nr,rr,'[data-testid="markdown-explorer-tree-settings"]'].map(D=>P.querySelector(D)).find(D=>D!==null)?.focus()},[]),J=r.useMemo(()=>new Set(S.keys()),[S]),I=r.useMemo(()=>a===null?Ie:new Set([a]),[a]),X=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:I,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:J,shownPath:a,onChange:_};case"none":return{mode:"none",items:Ie,shownPath:null,onChange:null}}},[t,s,E.selectionMode,I,a,J,_]),W=r.useMemo(()=>E.revealDocument?{path:a,openFolders:!y}:{path:X.shownPath,openFolders:!1},[E.revealDocument,a,y,X.shownPath]),G=r.useCallback(P=>{a!==null&&g.settle(a),o(P)},[a,g,o]),[O,ee]=r.useState(null),[le,ue]=r.useState(!1),[te,B]=r.useState(null),U=r.useRef(!1),fe=r.useCallback(async()=>{if(!U.current){U.current=!0,ue(!0),B(null);try{const P=await d.refresh(n);if(P.status==="superseded")return;h.invalidate(),P.status==="failed"?B({sourceId:n,failure:P.failure}):x.announce(f.treeRefreshed)}finally{U.current=!1,ue(!1)}}},[d,h,n,x,f]),oe=O===null?null:O.expandAll,se=O?.expanding===!0,de=m.find(P=>P.id===n),ne=i.target==="multi"?St:Rt,z=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:Z,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:de?.label,value:n,onChange:P=>G(P.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(P=>c.jsx("option",{value:P.id,children:P.label},P.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":z,title:z,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ne,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":le,"aria-busy":le,"data-aqmx-busy":le?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{fe()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":oe===null||se,"aria-busy":se,"data-aqmx-busy":se?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>oe?.(),children:c.jsx(bt,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":O===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>O?.collapseAll(),children:c.jsx(gt,{"aria-hidden":"true"})}),q.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[te!==null&&te.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":te.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,te.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(kt,{})}),c.jsx(bn,{mode:t,sourceId:n,settings:E,reveal:W,openPaths:s,selection:X,onOpenDocument:u,folders:T,onRevealSource:l,onControls:ee},n),N&&S.size>0?c.jsx(Rn,{selection:S,onRemove:ae,onClear:Q,onOpenSelection:F,onLeave:$}):null,q.menu]})]})};function lr({title:e,titleId:t,...n},a){return p.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:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const or=p.forwardRef(lr),sr=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:u}=v.useExplorer(),o=ht.useLocation(),{location:l}=v.useExplorerLocation(),[i,f]=r.useState(!1),[m,d]=r.useState({navigated:o,source:l.source}),[h,x]=r.useState(!1);m.navigated!==o&&(d({navigated:o,source:l.source}),m.source===l.source&&!h&&f(!1));const[g,E]=r.useState(s);g!==s&&(E(s),f(!1));const j=r.useRef(null),L=r.useRef(null),N=r.useRef(null),R=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const b=j.current;b!==null&&(i&&!b.open?(b.showModal(),L.current?.focus()):!i&&b.open&&(b.close(),t.current?.focus()),a(i?N.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const C=r.useCallback(b=>{b.key!=="Escape"||b.defaultPrevented||(v.consumeKey(b),f(!1))},[]),y=r.useCallback(b=>{R.current=b.target===b.currentTarget},[]),T=r.useCallback(b=>{const q=R.current;R.current=!1,q&&b.target===b.currentTarget&&f(!1)},[]),S=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(or,{"aria-hidden":"true"}),c.jsx("span",{children:u.showExplorer})]})}),c.jsx("dialog",{ref:j,id:F,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:y,onClick:T,onClose:S,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:N,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:L,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Ge,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ye,{value:i,children:c.jsx(Ue,{value:x,children:e})})}),c.jsx(v.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Qe=r.createContext(null),Se="aqmx-explorer",Je="aqmx-content",cr="--aqmx-split-band",ke='[role="tree"] [role="treeitem"]',ir=`${ke}[tabindex="0"]`,ur="[data-directory-tree-tab-stop]",dr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${Se}"] ${ke}`))if(n.getAttribute(re)===t)return n;return null},De=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:A.ASSUMED_ROOT_FONT_PIXELS}),fr=(e,t)=>{const[n,a]=r.useState(()=>De(0,0));return r.useLayoutEffect(()=>{const s=e.current,u=t.current;if(s===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},l=()=>{const f=De(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[d]=m.borderBoxSize;d!==void 0&&(m.target===s&&(o.frame=d.inlineSize),m.target===u&&(o.rem=d.inlineSize))}l()});return i.observe(s),i.observe(u),()=>i.disconnect()},[e,t]),n},et=e=>`aqmx-split-handle-${e}`,mr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),u=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=d=>{const h=d.target instanceof Element?d.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Je}"]`)===null,!o.current&&(u.current=h?.closest(`${ke}[${re}]`)?.getAttribute(re)??null)},m=d=>{d.relatedTarget instanceof Node&&!i.contains(d.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:d,body:h}=i.ownerDocument;if(d!==null&&d!==h)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=u.current,d=`[data-panel-id="${Se}"]`;f([m===null?null:dr(i,m),i.querySelector(`${d} ${ir}`),i.querySelector(`${d} ${ur}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},pr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:u})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:d,rootFontPixels:h}=fr(o,f),x=d!==null&&d<A.explorerSheetBelowPixels(h);return mr(x,{frameRef:o,sheetToggleRef:m,handleId:et(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(sr,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Qe,{value:x?l:null,children:c.jsx(hr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:A.explorerMinPixels(h)})})]})},hr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:u,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=v.useExplorer(),m=v.useViewSetting(C=>e==="tree"?C.treeExplorer:C.multiExplorer)??(e==="tree"?A.EXPLORER_DEFAULT_PERCENT:A.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(!1),[h,x]=r.useState(!1),g=r.useRef(u);r.useLayoutEffect(()=>{g.current=u},[u]);const E=Ae.useSplitPersistence(r.useCallback(C=>{if(C.length!==2)return;const[y=0,T=0]=C,S=y+T;if(S<=0||y<=0)return;const b=Math.min(A.EXPLORER_MAX_PERCENT,y/S*100);l.update(e==="tree"?{treeExplorer:b}:{multiExplorer:b})},[l,e]));r.useEffect(()=>()=>{d.current&&g.current?.(!1)},[]);const L=Ae.useCoarsePointer()?A.COARSE_TARGET_PIXELS:A.FINE_TARGET_PIXELS,N=r.useMemo(()=>({[cr]:`${String(t?0:L)}px`}),[t,L]),R=r.useCallback((C,y)=>{const[T=0,S=0]=C;C.length===2&&S>0&&x(T<=0),E.layoutChanged(C,y)},[E]),F=r.useCallback(C=>{d.current=C,u?.(C),E.draggingChanged(C)},[u,E]);return c.jsxs(xe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:R,className:"aqmx-split",style:N,"data-aqmx-split":e,children:[t?null:c.jsx(xe.Panel,{id:Se,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:A.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ye,{value:!h,children:n})}),t?null:c.jsx(xe.PanelResizeHandle,{id:et(e),thickness:L,indicator:{visible:!0,thickness:A.SPLIT_HANDLE_PIXELS.gripThickness,length:A.SPLIT_HANDLE_PIXELS.gripLength,barThickness:A.SPLIT_HANDLE_PIXELS.barThickness,barLength:A.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:F,inert:s,className:"aqmx-split-handle"}),c.jsx(xe.Panel,{id:Je,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=we;exports.ExplorerPane=ar;exports.ExplorerSplit=pr;exports.SheetNoticeSlotContext=Qe;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as m, jsxs as L, Fragment as Qe } from "react/jsx-runtime";
|
|
2
|
-
import { u as $, p as kt, O as Oe, L as Je, Q as At, x as Pe, R as Lt, S as Ot, k as Pt, T as qt, U as Ct, V as Ft } from "./index-
|
|
2
|
+
import { u as $, p as kt, O as Oe, L as Je, Q as At, x as Pe, R as Lt, S as Ot, k as Pt, T as qt, U as Ct, V as Ft } from "./index-Dz01kBab.js";
|
|
3
3
|
import * as f from "react";
|
|
4
4
|
import { use as ye, createContext as qe, useState as F, useCallback as w, useMemo as C, useRef as E, useLayoutEffect as H, useEffect as D, useSyncExternalStore as Ce, Suspense as et, useId as Re } from "react";
|
|
5
5
|
import { n as Mt, o as _t, q as tt, v as It, s as Dt, t as Ht, C as $t, F as Zt, u as Ve, x as Bt, y as zt, b as Ee, A as Vt } from "./location-B-m9scLf.js";
|
|
@@ -426,7 +426,7 @@ const un = /* @__PURE__ */ f.forwardRef(dn), Fe = qe(!0), nt = "\0loop\0", rt =
|
|
|
426
426
|
tapScrollCircleOptions: Ut
|
|
427
427
|
},
|
|
428
428
|
behaviorOptions: { enablePointerDrag: !0 }
|
|
429
|
-
}, Bn = { hoverClassName: "", directorySelectedClassName: "", itemSelectedClassName: "" }, zn = { color: "inherit", fontSize: "inherit" }, Vn = {
|
|
429
|
+
}, Bn = { hoverClassName: "", directorySelectedClassName: "", itemSelectedClassName: "" }, zn = { color: "inherit", fontSize: "inherit" }, Vn = { fontSize: "inherit" }, jn = /* @__PURE__ */ new Set(), Kn = /* @__PURE__ */ new Map(), Un = { color: "var(--aqmx-tree-line)" }, Gn = (e) => {
|
|
430
430
|
const t = e instanceof Element ? e.closest(`[${ce}]`) : null;
|
|
431
431
|
return t === null || t.getAttribute("data-entry-type") !== "file" ? null : t.getAttribute(ce);
|
|
432
432
|
}, ct = (e, t, n, r) => n === "folder-limit" ? e.expandAllFolderLimit(r, t.maxFolders, e.expandAll) : e.expandAllDepthLimit(r, t.maxDepth), Wn = (e, t, n) => n.kind === "done" ? e.expandAllDone(n.opened, n.failed, n.complete) : ct(e, t, n.kind, n.opened), it = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),a=require("react"),j=require("./location-BVEN_Ihk.cjs"),R=require("./index-W3iAjkLb.cjs"),oe=require("./ExplorerSplit-BE1VJuok.cjs"),_=require("@aiquants/drag-drop-panels"),me=require("react-router"),ee=require("./storage-DM0EvkVf.cjs"),be=require("./dataRoute-BONacTPi.cjs"),Be=require("react-dom"),je=require("@aiquants/markdown"),Fe=require("./scrollBarGeometry-C46jBtmM.cjs"),Ve=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Ce=a.createContext(null),le=()=>{const e=a.use(Ce);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Ue=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},$e=0xcbf29ce484222325n,Ge=0x100000001b3n,Ye=(1n<<64n)-1n,We=(1n<<53n)-1n,Ke=new TextEncoder,Je=e=>{let n=$e;for(const t of Ke.encode(e))n=(n^BigInt(t))*Ge&Ye;return Number(n&We)},Z=256,Xe=e=>`aqmx-p-${Je(e).toString(36)}`,Pe=(e,n)=>{const t=Xe(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Ze=new Map,Qe=(e,n=Ze)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Pe(r,t);t.add(s),o.set(r,s)}return o},Te=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Me=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([u,f])=>e.slice(u,f).reduce((l,y)=>l+y.length,0);let s=t;for(const u of o)r(u)<r(s)&&(s=u);let c=s[0];for(let u=s[0];u<s[1];u+=1)(e[u]?.length??0)<(e[c]?.length??0)&&(c=u);return c},Q=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Te(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Me(t,n)]?.push(r);return t},en=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),nn=(e,n,t)=>{const[o,r]=n,s=r-o,c=e.length,u=Array.from({length:s},(E,m)=>{const v=[0];for(const p of e)v.push((v.at(-1)??0)+(t(p)===o+m?1:0));return v}),f=(E,m,v)=>(u[E]?.[v]??0)-(u[E]?.[m]??0),l=Array.from({length:s+1},()=>Array.from({length:c+1},()=>Number.NEGATIVE_INFINITY)),y=Array.from({length:s+1},()=>Array.from({length:c+1},()=>0)),x=l[0];x&&(x[0]=0);for(let E=0;E<s;E+=1)for(let m=0;m<=c;m+=1)for(let v=0;v<=m;v+=1){const p=(l[E]?.[v]??Number.NEGATIVE_INFINITY)+f(E,v,m),P=l[E+1],M=y[E+1];P&&M&&p>(P[m]??Number.NEGATIVE_INFINITY)&&(P[m]=p,M[m]=v)}const b=Array.from({length:s},()=>[]);let k=c;for(let E=s;E>0;E-=1){const m=y[E]?.[k]??0;b[E-1]=e.slice(m,k),k=m}return b},Le=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const c of s)o.delete(c),o.set(c,r);for(const r of o.keys()){if(o.size<=Z)break;o.delete(r)}return{docs:t,columnOf:o}},tn=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=Q(e,t),s=Te(e,n,t.logical)??Me(r,t);r[s]?.push(n);const c=new Map(e.panelIds);return c.set(n,Pe(n,new Set(c.values()))),{state:{...e,...Le(e,r),panelIds:c},outcome:"opened"}},ke=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},on=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Re(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:ke(e,n),outcome:"closed"};const r=tn(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},rn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const c=new Map(e.panelIds),u=c.get(n);if(u===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);c.delete(n),c.set(t,u);const f=new Set(e.markup);return f.delete(n),{state:{docs:e.docs.map(l=>l===n?t:l),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:f,panelIds:c},outcome:"navigated"}},Re=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},sn=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},ln=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},cn=(e,n,t)=>{const o=Q(e,t),r=new Map;for(const[l,y]of o.entries())for(const x of y)r.set(x,l);const s=new Set(e.docs),c=new Set,u=j.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[l,y]of u.entries()){const x=(n[l]??[]).filter(b=>s.has(b)&&!c.has(b));for(const b of x)c.add(b);for(const[b,k]of nn(x,y,E=>r.get(E)).entries())f[y[0]+b]?.push(...k)}for(const l of e.docs)c.has(l)||f[r.get(l)??0]?.push(l);return f.every((l,y)=>l.length===o[y]?.length&&l.every((x,b)=>o[y]?.[b]===x))?e:{...e,...Le(e,f)}},ne=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Qe(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of Q(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Z)break;t.delete(o)}return{...e,columnOf:t}},Ne=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),an=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Ne)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const c of o.columnOf.slice(-Z))Array.isArray(c)&&c.length===2&&typeof c[0]=="string"&&c[0]!==""&&Number.isInteger(c[1])&&c[1]>=0&&c[1]<n&&(r.delete(c[0]),r.set(c[0],c[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(c=>typeof c=="string"&&c!==""):[]);return{columnOf:r,hidden:s}},un=e=>JSON.stringify({v:Ne,columnOf:[...e.columnOf.entries()].slice(-Z),hidden:e.docs.filter(n=>e.hidden.has(n))}),ie=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},Y=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},dn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,c=R.createEmitter(),u=new Map,f=new Map;let l={layout:ne({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},y=!1;const x=i=>y?fe(i,{logical:s,visible:l.visibleColumns}):i,b=(i,g)=>j.explorerHref(e,{view:"multi",source:i,docs:g.docs,maximized:g.maximized,markup:g.markup}),k=i=>({docs:i.docs,maximized:i.maximized,markup:[...i.markup]});let E=b(n.source,n),m=n.source,v=E;const p=[],P=[];let M=null;const A=()=>{if(!(p.length>0))for(const i of P.splice(0))i()},d=i=>{l={...l,...i},c.emit()},S=()=>{if(!l.ready)return;const i=un(l.layout);i!==M&&(M=i,o(i))},h=(i,g,T)=>{const D=b(i,k(g));D!==E&&(E=D,m=i,p.push(D),t(D,T))},w=i=>{const g=new Set(i.panelIds.values());for(const C of[...u.keys()])g.has(C)||u.delete(C);for(const C of[...f.keys()])g.has(C)||f.delete(C);const T=new Set(i.docs),D=[...l.titles.keys()].every(C=>T.has(C))?l.titles:new Map([...l.titles].filter(([C])=>T.has(C))),O=[...l.pendingHashes.keys()].every(C=>g.has(C))?l.pendingHashes:new Map([...l.pendingHashes].filter(([C])=>g.has(C)));return{titles:D,pendingHashes:O}},N=i=>i===l.layout?!1:(d({layout:i,...w(i)}),h(m,i,"replace"),S(),!0),I=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:c.subscribe,toggle:i=>{pe(i);const{state:g,outcome:T}=on(l.layout,i,I(),r);return N(g),T},close:i=>N(ke(l.layout,i)),navigate:(i,g)=>{pe(g);const{state:T,outcome:D}=rn(l.layout,i,g);if(D!=="navigated")return D;const O=T.panelIds.get(g);return O!==void 0&&(u.delete(O),f.delete(O)),N(T),D},setHidden:(i,g)=>N(Re(l.layout,i,g)),maximize:i=>N(ln(l.layout,i)),setMarkup:(i,g)=>N(sn(l.layout,i,g)),arrange:i=>N(cn(l.layout,i,{logical:s,visible:i.length})),changeSource:i=>{h(i,l.layout,"push")},revealSource:i=>{h(i,l.layout,"replace")},observeLocation:i=>{const g=b(i.source,i);if(g===E)return p.length=0,v=g,i.source!==l.source&&d({source:i.source}),A(),!1;if(g===v)return!1;v=g;const T=p.indexOf(g);if(T>=0)return p.splice(0,T+1),i.source!==l.source&&d({source:i.source}),A(),!1;p.length=0,E=g,m=i.source;const D=x(ne({docs:i.docs,maximized:i.maximized,markup:i.markup,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return d({layout:D,source:i.source,...w(D)}),S(),A(),!0},whenUrlRendered:i=>{P.push(i),A()},loadStored:i=>{d({layout:x(ne({docs:l.layout.docs,maximized:l.layout.maximized,markup:[...l.layout.markup],stored:i,panelIds:l.layout.panelIds},r)),ready:!0}),S()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);y=!0;const g=fe(l.layout,{logical:s,visible:i});i===l.visibleColumns&&g===l.layout||(d({visibleColumns:i,layout:g}),g!==l.layout&&S())},setSplitDragging:i=>{i!==l.splitDragging&&d({splitDragging:i})},setTitle:(i,g)=>{!l.layout.docs.includes(i)||l.titles.get(i)===g||d({titles:new Map(l.titles).set(i,g)})},titleOf:i=>ie(l.titles,i),setPendingHash:(i,g)=>{const T=l.pendingHashes.get(i);if(g===null||g===""){if(T===void 0)return;const D=new Map(l.pendingHashes);D.delete(i),d({pendingHashes:D});return}T!==g&&d({pendingHashes:new Map(l.pendingHashes).set(i,g)})},saveReadingPosition:(i,g,T)=>{l.layout.panelIds.get(g)===i&&u.set(i,{doc:g,position:T})},readingPositionOf:(i,g)=>{const T=u.get(i);return T===void 0||T.doc!==g?null:T.position},saveImageView:(i,g,T)=>{f.set(i,{url:g,state:T})},imageViewOf:(i,g)=>{const T=f.get(i);return T===void 0||T.url!==g?null:T.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return a.useSyncExternalStore(e.subscribe,t,t)},mn=e=>{const{config:n,storageNamespace:t}=R.useExplorer(),o=me.useNavigate(),r=a.useRef(o),s=ee.storageKeys(t).multiLayout,[c]=a.useState(()=>dn({config:n,location:e,writeUrl:(l,y)=>{r.current(l,R.explorerNavigationOptions(y==="replace"?"browse":"switch-source"))},persist:l=>ee.writeStorage(s,l)}));a.useLayoutEffect(()=>{r.current=o},[o]);const u=me.useLocation(),f=a.useMemo(()=>({location:e,navigated:u}),[e,u]);return a.useLayoutEffect(()=>{c.observeLocation(f.location)},[c,f]),a.useLayoutEffect(()=>{c.loadStored(an(ee.readStorage(s),n.multiView.columns))},[c,s,n]),c},fn=e=>{const n=e.closest(_.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},pn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:c,revealInPanel:u}=le(),{announcer:f}=R.useExplorer(),l=z(s,d=>Ue(d,n)),y=z(s,d=>d.layout.markup.has(e)),x=a.useCallback((d,S)=>c(n,e,d,S),[c,n,e]),b=a.useCallback(()=>s.setPendingHash(n,null),[s,n]),k=a.useMemo(()=>({read:d=>s.imageViewOf(n,d),save:(d,S)=>s.saveImageView(n,d,S)}),[s,n]),E=a.useCallback((d,S)=>{S.kind!=="failure"&&s.setTitle(d,S.name),r(d)},[s,r]),m=a.useCallback(d=>{s.whenUrlRendered(()=>f.announce(d))},[s,f]),v=a.useMemo(()=>({scrollerOf:fn,reveal:d=>u(n,d)}),[u,n]),p=a.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:x,pendingHash:l,onHashConsumed:b,announceFailure:m,paneScroll:v}),[t,x,l,b,m,v]),P=a.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),M=a.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),A=a.useMemo(()=>({shown:y,toggle:M}),[y,M]);return L.jsxs(R.ImageViewMemoryContext,{value:k,children:[L.jsx(R.DocumentRefreshBar,{path:e,placement:P,markup:A}),L.jsx(R.DocumentPane,{path:e,absence:R.NO_DOCUMENT,markup:y,variant:p,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",K="data-panel-id",re="--aqmx-multi-panel-chrome",gn=e=>e==="normal"?0:R.cssPixels(e),hn=(e,n)=>{const t=e.querySelector(_.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),c=t.clientWidth-R.cssPixels(s.paddingLeft)-R.cssPixels(s.paddingRight),u=t.clientHeight-R.cssPixels(s.paddingTop)-R.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:c,gap:gn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:u}},vn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+R.cssPixels(t.paddingBottom)+R.cssPixels(t.borderBottomWidth)},J="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",yn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},wn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),$=e=>{const n=e.closest(_.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ie=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ve=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},xn=(e,n)=>{const t=Ie(e,n),o=[];let r=e;for(let c=ve([...r.children],t);c>=0;c=ve([...r.children],t)){const u=r.children[c];if(u===void 0)break;o.push(c),r=u}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const f of t.anchor.path)o=o?.children[f];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:c}=t.anchor,u=s<0&&c>0?s/c*r.height:s;n.scrollTop+=r.top-Ie(e,n)-u},En=Object.freeze(["data-testid","aria-label","title","href","id","name"]),De=e=>{const n=e.getAttribute(_.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...En.map(t=>e.getAttribute(t))]:[e.tagName,_.PANEL_ACTION_ATTRIBUTE,n])},On=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:De(n)}},bn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&De(o)===t.signature&&R.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(_.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=wn(e,r,t);(o||Pn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Pn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Tn=e=>e.scrollHeight>e.clientHeight,Mn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),c=()=>{const l=vn(e,n);if(!Number.isFinite(l))return;const y=s===null?0:s.getBoundingClientRect().height;y!==r&&(r=y,t.style.setProperty(he,`${String(y)}px`));const x=l+y;x!==o&&(o=x,e.style.setProperty(re,`${String(x)}px`))};c();let u=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{u===null&&(u=requestAnimationFrame(()=>{u=null,c()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),u!==null&&cancelAnimationFrame(u),e.style.removeProperty(re),t.style.removeProperty(he)}},Ln=e=>{const{docPath:n,panelId:t}=yn(e),{store:o,Body:r,maximize:s,focusCarry:c}=le(),u=z(o,m=>m.layout.maximized===n),f=z(o,m=>ie(m.titles,n)),l=a.useRef(null),y=a.useRef(null),x=a.useRef(null),b=a.useRef(null);a.useEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null||u)return;const p=new Map,P=h=>{const w=p.get(h);if(w!==void 0)return w;const N=Sn(h);return p.set(h,N),N},M=h=>Cn(h,m,P);let A=!1;const d=()=>{const h=Tn(v);h!==A&&(A=h,h?m.addEventListener("wheel",M,{capture:!0,passive:!1}):m.removeEventListener("wheel",M,{capture:!0}))};d();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return S?.observe(v),S?.observe(m),()=>{S?.disconnect(),m.removeEventListener("wheel",M,{capture:!0})}},[u]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m),p=m===null?null:m.closest(`[${K}]`);if(!(m===null||v===null||!(p instanceof HTMLElement)))return Mn(p,v,m)},[]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null)return;const p=h=>{ye(m,v,h),b.current=v.scrollTop},P=o.readingPositionOf(t,n);y.current=P===null?null:{doc:n,position:P},P!==null&&p(P);let M=null,A=m.getBoundingClientRect().width;const d=()=>{M===null&&(M=requestAnimationFrame(()=>{M=null;const h=b.current;if(b.current=null,h!==null&&v.scrollTop===h||m.getBoundingClientRect().width!==A)return;const w=x.current;w!==null&&o.saveReadingPosition(t,w,xn(m,v))}))};v.addEventListener("scroll",d,{passive:!0});const S=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const h=m.getBoundingClientRect().width;if(h===A)return;A=h;const w=o.readingPositionOf(t,n);w!==null&&p(w)});return S?.observe(m),()=>{v.removeEventListener("scroll",d),S?.disconnect(),M!==null&&cancelAnimationFrame(M)}},[o,t,n]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:m.closest(`[${K}]`);if(m===null||v===null)return;const p=c.take(t);return p!==null&&bn(v,m,p),()=>{const P=On(v,v.ownerDocument.activeElement);P!==null&&c.hold(t,P)}},[c,t]);const k=a.useCallback(m=>{const v=l.current,p=v===null?null:$(v);if(v===null||p===null)return;const P=x.current;x.current=m;const M=y.current;y.current=null,M!==null&&M.doc===m?(ye(v,p,M.position),b.current=p.scrollTop):P!==null&&P!==m&&(p.scrollTop=0)},[]),E=a.useCallback(()=>s(n),[s,n]);return L.jsx("div",{ref:l,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":u?"true":"false","data-testid":"markdown-explorer-panel-frame",...u?R.CONTENT_PANE:{},onDoubleClick:u?void 0:E,children:L.jsx(r,{docPath:n,panelId:t,maximized:u,title:f,onContentShown:k})})},kn=a.memo(Ln),W=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},Se=e=>Object.fromEntries(_.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=en(Q(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[_.generateColumnId(r),o.map(s=>W(e,s))]))},Nn=(e,n)=>{const t=Y(e);return _.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},An=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),In="--aqmx-multi-stage-bar-gutter",Dn=Object.freeze({[In]:`${String(Fe.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%"}),zn=Object.freeze({[_.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Hn=e=>L.jsx("div",{...zn,children:L.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),qn=({props:e,children:n})=>L.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:Hn,children:n}),Bn=e=>L.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ae="--aqmx-stage-block",jn="--aqmx-multi-panel-body-floor",Fn=`calc(var(${ae}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,Vn=`max(calc(var(${ae}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${re}) + var(${jn})))`,Un=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((c,u)=>r[u]===c)})},we=["keydown","pointerdown","wheel","touchstart"],G=new WeakMap,xe=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},$n=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},X=(e,n,t)=>{G.get(e)?.();const o=e.querySelector(`[${K}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const c=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const x=r?.isConnected===!0?r:o;x!==o&&x.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=$n(x)};if(c(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(c);xe(u,o,o.closest(_.SCROLL_ROOT_SELECTOR)),r!==null&&xe(u,r,o);const{ownerDocument:f}=e,l=x=>{const b=x.target===f?f.scrollingElement:x.target;if(!(b instanceof Element))return;const k=s.get(b);k!==void 0&&(b.scrollTop!==k.top||b.scrollLeft!==k.left)&&y()},y=()=>{u.disconnect();for(const x of we)f.removeEventListener(x,y,!0);f.removeEventListener("scroll",l,!0),G.get(e)===y&&G.delete(e)};for(const x of we)f.addEventListener(x,y,{capture:!0,passive:!0});f.addEventListener("scroll",l,{capture:!0,passive:!0}),G.set(e,y)},_e=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement?(X(e,n,null),t.focus({preventScroll:!0}),!0):!1},ue=(e,n)=>{const t=e.querySelector(`[${K}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ue(e,n))return null;const t=[...e.querySelectorAll(`[${J}]`)].map(c=>c.getAttribute(J)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Oe=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Gn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(X(o,n,t&&ue(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const c=o.querySelector(`[${J}="${n}"]`);c instanceof HTMLElement&&c.focus({preventScroll:!0})})},Yn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=R.useExplorer(),{maximize:c}=le(),u=t.multiView.columns,f=z(e,O=>O.layout),l=z(e,O=>O.visibleColumns),y=z(e,O=>O.titles),x=z(e,O=>O.layout.maximized!==null||O.splitDragging),[b,k]=a.useState(!1),[E]=a.useState(()=>Se(l)),m=a.useMemo(()=>An(o),[o]),v=a.useCallback(O=>{e.arrange(Nn(e.getSnapshot().layout,O))},[e]),p=_.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:_.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:v}),{columnPanels:P,setColumnPanels:M}=p,A=a.useRef(x),d=a.useRef(P);a.useLayoutEffect(()=>{A.current=x,d.current=P},[x,P]);const S=a.useCallback(O=>{const C=n.current;if(C===null)return;const{plan:B,stageBlockSize:H}=hn(C,u);if(Number.isFinite(H)&&H>0&&C.style.setProperty(ae,`${String(H)}px`),A.current&&!O)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,u]);a.useLayoutEffect(()=>{S(!0),k(!0)},[S]),a.useEffect(()=>{const O=n.current;if(O===null||typeof ResizeObserver>"u")return;let C=null;const B=new ResizeObserver(()=>{C===null&&(C=requestAnimationFrame(()=>{C=null,S(!1)}))}),H=O.querySelector(_.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=O.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),C!==null&&cancelAnimationFrame(C)}},[n,S]),a.useEffect(()=>{x||S(!1)},[x,S]);const h=a.useMemo(()=>b?Rn(f,{logical:u,visible:l}):Se(l),[b,f,u,l]);a.useLayoutEffect(()=>{Un(d.current,h)||M(h)},[h,M]);const w=a.useMemo(()=>_.sortColumnIds(Object.keys(P)).map(O=>({id:O,key:O,className:"aqmx-multi-column"})),[P]),N=a.useMemo(()=>f.docs.map(O=>{const C=W(f,O);return{id:C,component:kn,title:ie(y,O),props:{docPath:O,panelId:C},minHeight:Fn,maxHeight:Vn}}),[f,y]),I=a.useMemo(()=>Object.fromEntries(f.docs.map(O=>[W(f,O),!f.hidden.has(O)])),[f]),i=f.maximized===null?null:W(f,f.maximized),g=a.useCallback(O=>{const{layout:C}=e.getSnapshot();for(const[B,H]of Y(C)){const q=O[B];if(q===void 0||q!==C.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),ze(n,B);continue}const V=n.current,de=V===null?null:Ee(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),de!==null&&Oe(n,de))}},[e,n,r,o]),T=a.useCallback(O=>{const C=Y(e.getSnapshot().layout).get(O);if(C===void 0)return;const B=()=>{const q=e.titleOf(C),F=n.current,V=F===null?null:Ee(F,O);e.close(C)&&(r.announce(o.panelClosed(q)),V!==null&&Oe(n,V))},H=s.unsavedAmong([C]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),D=a.useCallback(O=>{if(O===null){c(null);return}const C=Y(e.getSnapshot().layout).get(O);C!==void 0&&c(C)},[e,c]);return L.jsx("div",{className:"aqmx-multi-layout","aria-busy":!b,children:L.jsx(_.DragDropLayout,{columns:w,panels:N,columnPanels:P,onColumnPanelsChange:v,panelVisibility:I,onPanelVisibilityChange:g,dragState:p.dragState,dragOverPosition:p.dragOverPosition,originalPanelPosition:p.originalPanelPosition,dragModes:p.dragModes,debugConfig:_.DEFAULT_DEBUG_CONFIG,panelSizes:p.panelSizes,customDrag:p.customDrag,setPanelRef:p.setPanelRef,onDragStart:p.handleDragStart,onDragEnd:p.handleDragEnd,onPlaceholderDragEnter:p.handlePlaceholderDragEnter,onPlaceholderDragLeave:p.handlePlaceholderDragLeave,onDragOverWithInsert:p.handleDragOverWithInsert,onDropWithInsert:p.handleDropWithInsert,onColumnDragLeave:p.handleColumnDragLeave,onPanelMouseDown:p.handleMouseDown,onPanelSizeInfoClick:p.handlePanelSizeInfoClick,onToggleDragMode:p.toggleDragMode,onPanelClose:T,onPanelMaximizeChange:D,maximizedPanel:i,dragHandle:"header",labels:m,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:qn,renderStageScrollBar:Bn})})},te={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(c=>{const u=n.ownerDocument.elementsFromPoint(s,c),f=u.findIndex(y=>n.contains(y)),l=u.findIndex(y=>e.contains(y));return f!==-1&&l!==-1&&l<f}))},Kn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(te.blockStart,`${String(t.top)}px`),e.style.setProperty(te.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(te.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Jn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:c,announcer:u,edits:f}=R.useExplorer(),l=a.useRef(null),y=a.useRef(null),x=z(e,d=>d.ready),b=z(e,d=>d.layout.docs.length>0),k=z(e,d=>d.visibleColumns),E=a.use(oe.SheetNoticeSlotContext),m=a.useCallback(d=>{const{layout:S}=e.getSnapshot(),h=S.maximized,w=d===null&&h!==null?S.panelIds.get(h):void 0,N=l.current,I=w!==void 0&&N!==null&&ue(N,w);e.maximize(d)&&(d!==null?u.announce(c.panelMaximized(e.titleOf(d))):h!==null&&u.announce(c.panelRestored(e.titleOf(h))),w!==void 0&&Gn(l,w,I))},[e,u,c]),v=a.useCallback((d,S,h,w)=>{if(h===S){e.setPendingHash(d,w);return}const N=f.unsavedAmong([S]);if(N.length>0){f.askToDiscard(N).then(T=>{T&&v(d,S,h,w)});return}const I=e.navigate(S,h);if(I==="navigated"){e.setPendingHash(d,w);return}if(I!=="existing")return;const{layout:i}=e.getSnapshot(),g=i.panelIds.get(h);g!==void 0&&(u.announce(c.panelAlreadyOpen(e.titleOf(h))),i.maximized===null?e.setHidden(h,!1):m(h),e.setPendingHash(g,w),ze(l,g))},[e,u,c,m,f]);a.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const d=y.current,S=l.current;if(d===null||S===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Kn(d,S)},[t,E]),a.useEffect(()=>{const d=y.current;if(t===null||d===null)return;const{ownerDocument:S}=d;let h=null;const w=N=>{const I=N.target;I instanceof Element&&(h!==null&&cancelAnimationFrame(h),h=requestAnimationFrame(()=>{h=null,S.activeElement===I&&d.isConnected&&Wn(d,I)&&o()}))};return S.addEventListener("focusin",w,!0),()=>{S.removeEventListener("focusin",w,!0),h!==null&&cancelAnimationFrame(h)}},[t,E,o]),a.useImperativeHandle(r,()=>({bringIntoView:d=>{requestAnimationFrame(()=>{const S=l.current,h=e.getSnapshot().layout.panelIds.get(d);S!==null&&h!==void 0&&X(S,h,null)})}}),[e]),a.useEffect(()=>{const d=l.current;return()=>{d!==null&&G.get(d)?.()}},[]);const p=a.useCallback((d,S)=>{const h=l.current;h!==null&&X(h,d,S)},[]),[P]=a.useState(Ve),M=a.useMemo(()=>({store:e,Body:n,followLink:v,maximize:m,revealInPanel:p,focusCarry:P}),[e,n,v,m,p,P]),A=a.useMemo(()=>Array.from({length:s.multiView.columns},(d,S)=>_.generateColumnId(S)),[s]);return L.jsxs("section",{ref:l,className:"aqmx-multi-stage",style:Dn,tabIndex:-1,"aria-label":c.multiRegion,"aria-busy":b&&!x,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":k,...R.CONTENT_PANE,children:[L.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),b?x?L.jsx(Ce,{value:M,children:L.jsx(Yn,{store:e,stageRef:l})}):L.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:A.map(d=>L.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[L.jsx("span",{}),L.jsx("span",{}),L.jsx("span",{})]},d))}):L.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:L.jsx("p",{className:"aqmx-empty-title",children:c.multiEmpty})}),t===null?null:E!==null?Be.createPortal(L.jsx("div",{ref:y,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):L.jsx("div",{ref:y,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},se=(e,n,t)=>{const o=new Set(e),r=n.filter(c=>!o.has(c)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Xn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Zn=({location:e})=>{const{config:n,labels:t,announcer:o}=R.useExplorer(),r=mn(e),s=z(r,w=>w.layout.docs),c=z(r,w=>w.layout.maximized),u=z(r,w=>w.layout.markup),f=z(r,w=>w.source),[l,y]=a.useState(()=>({docs:s,latest:se([],s,null)}));l.docs!==s&&y({docs:s,latest:se(l.docs,s,l.latest)});const x=c!==null?c:l.latest,[b,k]=a.useState(!1),E=a.useRef(null),[m,v]=a.useState(0),p=a.useRef(null),P=a.useRef(null);a.useLayoutEffect(()=>{const w=p.current;p.current=null,w!==null&&(r.whenUrlRendered(()=>o.announce(w.announcement)),P.current?.bringIntoView(w.doc))}),a.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const M=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),k(!0),E.current=setTimeout(()=>{E.current=null,k(!1)},He)},[]),A=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,k(!1)},[]),d=a.useCallback(w=>{const N=r.titleOf(w),I=r.toggle(w);I==="rejected"&&M();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Xn(t,I,N);if(I==="shown"){p.current={doc:w,announcement:i},v(g=>g+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&P.current?.bringIntoView(w)})},[r,M,o,t,n]),S=a.useMemo(()=>new Set(s),[s]),h=a.useMemo(()=>{const w=qe(s,c);return{href:j.explorerHref(n,{view:"tree",source:f,doc:w,markup:w!==null&&u.has(w)}),target:"tree"}},[n,f,s,c,u]);return L.jsx(oe.ExplorerSplit,{view:"multi",explorer:L.jsx(oe.ExplorerPane,{mode:"multi",sourceId:f,currentPath:x,openPaths:S,onOpenDocument:d,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:h}),content:L.jsx(Jn,{ref:P,store:r,body:pn,limitNotice:b?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:A}),contentCoversPage:c!==null,sheetDismissals:m,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Zn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=se;exports.treeSwitchDocument=qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),a=require("react"),j=require("./location-BVEN_Ihk.cjs"),R=require("./index-DrKHJNY4.cjs"),oe=require("./ExplorerSplit-BDkBN8A0.cjs"),_=require("@aiquants/drag-drop-panels"),me=require("react-router"),ee=require("./storage-DM0EvkVf.cjs"),be=require("./dataRoute-BONacTPi.cjs"),Be=require("react-dom"),je=require("@aiquants/markdown"),Fe=require("./scrollBarGeometry-C46jBtmM.cjs"),Ve=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Ce=a.createContext(null),le=()=>{const e=a.use(Ce);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Ue=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},$e=0xcbf29ce484222325n,Ge=0x100000001b3n,Ye=(1n<<64n)-1n,We=(1n<<53n)-1n,Ke=new TextEncoder,Je=e=>{let n=$e;for(const t of Ke.encode(e))n=(n^BigInt(t))*Ge&Ye;return Number(n&We)},Z=256,Xe=e=>`aqmx-p-${Je(e).toString(36)}`,Pe=(e,n)=>{const t=Xe(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Ze=new Map,Qe=(e,n=Ze)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Pe(r,t);t.add(s),o.set(r,s)}return o},Te=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Me=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([u,f])=>e.slice(u,f).reduce((l,y)=>l+y.length,0);let s=t;for(const u of o)r(u)<r(s)&&(s=u);let c=s[0];for(let u=s[0];u<s[1];u+=1)(e[u]?.length??0)<(e[c]?.length??0)&&(c=u);return c},Q=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Te(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Me(t,n)]?.push(r);return t},en=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),nn=(e,n,t)=>{const[o,r]=n,s=r-o,c=e.length,u=Array.from({length:s},(E,m)=>{const v=[0];for(const p of e)v.push((v.at(-1)??0)+(t(p)===o+m?1:0));return v}),f=(E,m,v)=>(u[E]?.[v]??0)-(u[E]?.[m]??0),l=Array.from({length:s+1},()=>Array.from({length:c+1},()=>Number.NEGATIVE_INFINITY)),y=Array.from({length:s+1},()=>Array.from({length:c+1},()=>0)),x=l[0];x&&(x[0]=0);for(let E=0;E<s;E+=1)for(let m=0;m<=c;m+=1)for(let v=0;v<=m;v+=1){const p=(l[E]?.[v]??Number.NEGATIVE_INFINITY)+f(E,v,m),P=l[E+1],M=y[E+1];P&&M&&p>(P[m]??Number.NEGATIVE_INFINITY)&&(P[m]=p,M[m]=v)}const b=Array.from({length:s},()=>[]);let k=c;for(let E=s;E>0;E-=1){const m=y[E]?.[k]??0;b[E-1]=e.slice(m,k),k=m}return b},Le=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const c of s)o.delete(c),o.set(c,r);for(const r of o.keys()){if(o.size<=Z)break;o.delete(r)}return{docs:t,columnOf:o}},tn=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=Q(e,t),s=Te(e,n,t.logical)??Me(r,t);r[s]?.push(n);const c=new Map(e.panelIds);return c.set(n,Pe(n,new Set(c.values()))),{state:{...e,...Le(e,r),panelIds:c},outcome:"opened"}},ke=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},on=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Re(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:ke(e,n),outcome:"closed"};const r=tn(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},rn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const c=new Map(e.panelIds),u=c.get(n);if(u===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);c.delete(n),c.set(t,u);const f=new Set(e.markup);return f.delete(n),{state:{docs:e.docs.map(l=>l===n?t:l),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:f,panelIds:c},outcome:"navigated"}},Re=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},sn=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},ln=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},cn=(e,n,t)=>{const o=Q(e,t),r=new Map;for(const[l,y]of o.entries())for(const x of y)r.set(x,l);const s=new Set(e.docs),c=new Set,u=j.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[l,y]of u.entries()){const x=(n[l]??[]).filter(b=>s.has(b)&&!c.has(b));for(const b of x)c.add(b);for(const[b,k]of nn(x,y,E=>r.get(E)).entries())f[y[0]+b]?.push(...k)}for(const l of e.docs)c.has(l)||f[r.get(l)??0]?.push(l);return f.every((l,y)=>l.length===o[y]?.length&&l.every((x,b)=>o[y]?.[b]===x))?e:{...e,...Le(e,f)}},ne=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Qe(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of Q(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Z)break;t.delete(o)}return{...e,columnOf:t}},Ne=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),an=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Ne)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const c of o.columnOf.slice(-Z))Array.isArray(c)&&c.length===2&&typeof c[0]=="string"&&c[0]!==""&&Number.isInteger(c[1])&&c[1]>=0&&c[1]<n&&(r.delete(c[0]),r.set(c[0],c[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(c=>typeof c=="string"&&c!==""):[]);return{columnOf:r,hidden:s}},un=e=>JSON.stringify({v:Ne,columnOf:[...e.columnOf.entries()].slice(-Z),hidden:e.docs.filter(n=>e.hidden.has(n))}),ie=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},Y=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},dn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,c=R.createEmitter(),u=new Map,f=new Map;let l={layout:ne({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},y=!1;const x=i=>y?fe(i,{logical:s,visible:l.visibleColumns}):i,b=(i,g)=>j.explorerHref(e,{view:"multi",source:i,docs:g.docs,maximized:g.maximized,markup:g.markup}),k=i=>({docs:i.docs,maximized:i.maximized,markup:[...i.markup]});let E=b(n.source,n),m=n.source,v=E;const p=[],P=[];let M=null;const A=()=>{if(!(p.length>0))for(const i of P.splice(0))i()},d=i=>{l={...l,...i},c.emit()},S=()=>{if(!l.ready)return;const i=un(l.layout);i!==M&&(M=i,o(i))},h=(i,g,T)=>{const D=b(i,k(g));D!==E&&(E=D,m=i,p.push(D),t(D,T))},w=i=>{const g=new Set(i.panelIds.values());for(const C of[...u.keys()])g.has(C)||u.delete(C);for(const C of[...f.keys()])g.has(C)||f.delete(C);const T=new Set(i.docs),D=[...l.titles.keys()].every(C=>T.has(C))?l.titles:new Map([...l.titles].filter(([C])=>T.has(C))),O=[...l.pendingHashes.keys()].every(C=>g.has(C))?l.pendingHashes:new Map([...l.pendingHashes].filter(([C])=>g.has(C)));return{titles:D,pendingHashes:O}},N=i=>i===l.layout?!1:(d({layout:i,...w(i)}),h(m,i,"replace"),S(),!0),I=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:c.subscribe,toggle:i=>{pe(i);const{state:g,outcome:T}=on(l.layout,i,I(),r);return N(g),T},close:i=>N(ke(l.layout,i)),navigate:(i,g)=>{pe(g);const{state:T,outcome:D}=rn(l.layout,i,g);if(D!=="navigated")return D;const O=T.panelIds.get(g);return O!==void 0&&(u.delete(O),f.delete(O)),N(T),D},setHidden:(i,g)=>N(Re(l.layout,i,g)),maximize:i=>N(ln(l.layout,i)),setMarkup:(i,g)=>N(sn(l.layout,i,g)),arrange:i=>N(cn(l.layout,i,{logical:s,visible:i.length})),changeSource:i=>{h(i,l.layout,"push")},revealSource:i=>{h(i,l.layout,"replace")},observeLocation:i=>{const g=b(i.source,i);if(g===E)return p.length=0,v=g,i.source!==l.source&&d({source:i.source}),A(),!1;if(g===v)return!1;v=g;const T=p.indexOf(g);if(T>=0)return p.splice(0,T+1),i.source!==l.source&&d({source:i.source}),A(),!1;p.length=0,E=g,m=i.source;const D=x(ne({docs:i.docs,maximized:i.maximized,markup:i.markup,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return d({layout:D,source:i.source,...w(D)}),S(),A(),!0},whenUrlRendered:i=>{P.push(i),A()},loadStored:i=>{d({layout:x(ne({docs:l.layout.docs,maximized:l.layout.maximized,markup:[...l.layout.markup],stored:i,panelIds:l.layout.panelIds},r)),ready:!0}),S()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);y=!0;const g=fe(l.layout,{logical:s,visible:i});i===l.visibleColumns&&g===l.layout||(d({visibleColumns:i,layout:g}),g!==l.layout&&S())},setSplitDragging:i=>{i!==l.splitDragging&&d({splitDragging:i})},setTitle:(i,g)=>{!l.layout.docs.includes(i)||l.titles.get(i)===g||d({titles:new Map(l.titles).set(i,g)})},titleOf:i=>ie(l.titles,i),setPendingHash:(i,g)=>{const T=l.pendingHashes.get(i);if(g===null||g===""){if(T===void 0)return;const D=new Map(l.pendingHashes);D.delete(i),d({pendingHashes:D});return}T!==g&&d({pendingHashes:new Map(l.pendingHashes).set(i,g)})},saveReadingPosition:(i,g,T)=>{l.layout.panelIds.get(g)===i&&u.set(i,{doc:g,position:T})},readingPositionOf:(i,g)=>{const T=u.get(i);return T===void 0||T.doc!==g?null:T.position},saveImageView:(i,g,T)=>{f.set(i,{url:g,state:T})},imageViewOf:(i,g)=>{const T=f.get(i);return T===void 0||T.url!==g?null:T.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return a.useSyncExternalStore(e.subscribe,t,t)},mn=e=>{const{config:n,storageNamespace:t}=R.useExplorer(),o=me.useNavigate(),r=a.useRef(o),s=ee.storageKeys(t).multiLayout,[c]=a.useState(()=>dn({config:n,location:e,writeUrl:(l,y)=>{r.current(l,R.explorerNavigationOptions(y==="replace"?"browse":"switch-source"))},persist:l=>ee.writeStorage(s,l)}));a.useLayoutEffect(()=>{r.current=o},[o]);const u=me.useLocation(),f=a.useMemo(()=>({location:e,navigated:u}),[e,u]);return a.useLayoutEffect(()=>{c.observeLocation(f.location)},[c,f]),a.useLayoutEffect(()=>{c.loadStored(an(ee.readStorage(s),n.multiView.columns))},[c,s,n]),c},fn=e=>{const n=e.closest(_.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},pn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:c,revealInPanel:u}=le(),{announcer:f}=R.useExplorer(),l=z(s,d=>Ue(d,n)),y=z(s,d=>d.layout.markup.has(e)),x=a.useCallback((d,S)=>c(n,e,d,S),[c,n,e]),b=a.useCallback(()=>s.setPendingHash(n,null),[s,n]),k=a.useMemo(()=>({read:d=>s.imageViewOf(n,d),save:(d,S)=>s.saveImageView(n,d,S)}),[s,n]),E=a.useCallback((d,S)=>{S.kind!=="failure"&&s.setTitle(d,S.name),r(d)},[s,r]),m=a.useCallback(d=>{s.whenUrlRendered(()=>f.announce(d))},[s,f]),v=a.useMemo(()=>({scrollerOf:fn,reveal:d=>u(n,d)}),[u,n]),p=a.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:x,pendingHash:l,onHashConsumed:b,announceFailure:m,paneScroll:v}),[t,x,l,b,m,v]),P=a.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),M=a.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),A=a.useMemo(()=>({shown:y,toggle:M}),[y,M]);return L.jsxs(R.ImageViewMemoryContext,{value:k,children:[L.jsx(R.DocumentRefreshBar,{path:e,placement:P,markup:A}),L.jsx(R.DocumentPane,{path:e,absence:R.NO_DOCUMENT,markup:y,variant:p,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",K="data-panel-id",re="--aqmx-multi-panel-chrome",gn=e=>e==="normal"?0:R.cssPixels(e),hn=(e,n)=>{const t=e.querySelector(_.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),c=t.clientWidth-R.cssPixels(s.paddingLeft)-R.cssPixels(s.paddingRight),u=t.clientHeight-R.cssPixels(s.paddingTop)-R.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:c,gap:gn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:u}},vn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+R.cssPixels(t.paddingBottom)+R.cssPixels(t.borderBottomWidth)},J="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",yn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},wn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),$=e=>{const n=e.closest(_.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ie=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ve=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},xn=(e,n)=>{const t=Ie(e,n),o=[];let r=e;for(let c=ve([...r.children],t);c>=0;c=ve([...r.children],t)){const u=r.children[c];if(u===void 0)break;o.push(c),r=u}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const f of t.anchor.path)o=o?.children[f];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:c}=t.anchor,u=s<0&&c>0?s/c*r.height:s;n.scrollTop+=r.top-Ie(e,n)-u},En=Object.freeze(["data-testid","aria-label","title","href","id","name"]),De=e=>{const n=e.getAttribute(_.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...En.map(t=>e.getAttribute(t))]:[e.tagName,_.PANEL_ACTION_ATTRIBUTE,n])},On=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:De(n)}},bn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&De(o)===t.signature&&R.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(_.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=wn(e,r,t);(o||Pn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Pn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Tn=e=>e.scrollHeight>e.clientHeight,Mn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),c=()=>{const l=vn(e,n);if(!Number.isFinite(l))return;const y=s===null?0:s.getBoundingClientRect().height;y!==r&&(r=y,t.style.setProperty(he,`${String(y)}px`));const x=l+y;x!==o&&(o=x,e.style.setProperty(re,`${String(x)}px`))};c();let u=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{u===null&&(u=requestAnimationFrame(()=>{u=null,c()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),u!==null&&cancelAnimationFrame(u),e.style.removeProperty(re),t.style.removeProperty(he)}},Ln=e=>{const{docPath:n,panelId:t}=yn(e),{store:o,Body:r,maximize:s,focusCarry:c}=le(),u=z(o,m=>m.layout.maximized===n),f=z(o,m=>ie(m.titles,n)),l=a.useRef(null),y=a.useRef(null),x=a.useRef(null),b=a.useRef(null);a.useEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null||u)return;const p=new Map,P=h=>{const w=p.get(h);if(w!==void 0)return w;const N=Sn(h);return p.set(h,N),N},M=h=>Cn(h,m,P);let A=!1;const d=()=>{const h=Tn(v);h!==A&&(A=h,h?m.addEventListener("wheel",M,{capture:!0,passive:!1}):m.removeEventListener("wheel",M,{capture:!0}))};d();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return S?.observe(v),S?.observe(m),()=>{S?.disconnect(),m.removeEventListener("wheel",M,{capture:!0})}},[u]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m),p=m===null?null:m.closest(`[${K}]`);if(!(m===null||v===null||!(p instanceof HTMLElement)))return Mn(p,v,m)},[]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null)return;const p=h=>{ye(m,v,h),b.current=v.scrollTop},P=o.readingPositionOf(t,n);y.current=P===null?null:{doc:n,position:P},P!==null&&p(P);let M=null,A=m.getBoundingClientRect().width;const d=()=>{M===null&&(M=requestAnimationFrame(()=>{M=null;const h=b.current;if(b.current=null,h!==null&&v.scrollTop===h||m.getBoundingClientRect().width!==A)return;const w=x.current;w!==null&&o.saveReadingPosition(t,w,xn(m,v))}))};v.addEventListener("scroll",d,{passive:!0});const S=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const h=m.getBoundingClientRect().width;if(h===A)return;A=h;const w=o.readingPositionOf(t,n);w!==null&&p(w)});return S?.observe(m),()=>{v.removeEventListener("scroll",d),S?.disconnect(),M!==null&&cancelAnimationFrame(M)}},[o,t,n]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:m.closest(`[${K}]`);if(m===null||v===null)return;const p=c.take(t);return p!==null&&bn(v,m,p),()=>{const P=On(v,v.ownerDocument.activeElement);P!==null&&c.hold(t,P)}},[c,t]);const k=a.useCallback(m=>{const v=l.current,p=v===null?null:$(v);if(v===null||p===null)return;const P=x.current;x.current=m;const M=y.current;y.current=null,M!==null&&M.doc===m?(ye(v,p,M.position),b.current=p.scrollTop):P!==null&&P!==m&&(p.scrollTop=0)},[]),E=a.useCallback(()=>s(n),[s,n]);return L.jsx("div",{ref:l,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":u?"true":"false","data-testid":"markdown-explorer-panel-frame",...u?R.CONTENT_PANE:{},onDoubleClick:u?void 0:E,children:L.jsx(r,{docPath:n,panelId:t,maximized:u,title:f,onContentShown:k})})},kn=a.memo(Ln),W=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},Se=e=>Object.fromEntries(_.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=en(Q(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[_.generateColumnId(r),o.map(s=>W(e,s))]))},Nn=(e,n)=>{const t=Y(e);return _.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},An=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),In="--aqmx-multi-stage-bar-gutter",Dn=Object.freeze({[In]:`${String(Fe.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%"}),zn=Object.freeze({[_.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Hn=e=>L.jsx("div",{...zn,children:L.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),qn=({props:e,children:n})=>L.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:Hn,children:n}),Bn=e=>L.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ae="--aqmx-stage-block",jn="--aqmx-multi-panel-body-floor",Fn=`calc(var(${ae}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,Vn=`max(calc(var(${ae}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${re}) + var(${jn})))`,Un=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((c,u)=>r[u]===c)})},we=["keydown","pointerdown","wheel","touchstart"],G=new WeakMap,xe=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},$n=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},X=(e,n,t)=>{G.get(e)?.();const o=e.querySelector(`[${K}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const c=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const x=r?.isConnected===!0?r:o;x!==o&&x.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=$n(x)};if(c(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(c);xe(u,o,o.closest(_.SCROLL_ROOT_SELECTOR)),r!==null&&xe(u,r,o);const{ownerDocument:f}=e,l=x=>{const b=x.target===f?f.scrollingElement:x.target;if(!(b instanceof Element))return;const k=s.get(b);k!==void 0&&(b.scrollTop!==k.top||b.scrollLeft!==k.left)&&y()},y=()=>{u.disconnect();for(const x of we)f.removeEventListener(x,y,!0);f.removeEventListener("scroll",l,!0),G.get(e)===y&&G.delete(e)};for(const x of we)f.addEventListener(x,y,{capture:!0,passive:!0});f.addEventListener("scroll",l,{capture:!0,passive:!0}),G.set(e,y)},_e=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement?(X(e,n,null),t.focus({preventScroll:!0}),!0):!1},ue=(e,n)=>{const t=e.querySelector(`[${K}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ue(e,n))return null;const t=[...e.querySelectorAll(`[${J}]`)].map(c=>c.getAttribute(J)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Oe=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Gn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(X(o,n,t&&ue(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const c=o.querySelector(`[${J}="${n}"]`);c instanceof HTMLElement&&c.focus({preventScroll:!0})})},Yn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=R.useExplorer(),{maximize:c}=le(),u=t.multiView.columns,f=z(e,O=>O.layout),l=z(e,O=>O.visibleColumns),y=z(e,O=>O.titles),x=z(e,O=>O.layout.maximized!==null||O.splitDragging),[b,k]=a.useState(!1),[E]=a.useState(()=>Se(l)),m=a.useMemo(()=>An(o),[o]),v=a.useCallback(O=>{e.arrange(Nn(e.getSnapshot().layout,O))},[e]),p=_.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:_.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:v}),{columnPanels:P,setColumnPanels:M}=p,A=a.useRef(x),d=a.useRef(P);a.useLayoutEffect(()=>{A.current=x,d.current=P},[x,P]);const S=a.useCallback(O=>{const C=n.current;if(C===null)return;const{plan:B,stageBlockSize:H}=hn(C,u);if(Number.isFinite(H)&&H>0&&C.style.setProperty(ae,`${String(H)}px`),A.current&&!O)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,u]);a.useLayoutEffect(()=>{S(!0),k(!0)},[S]),a.useEffect(()=>{const O=n.current;if(O===null||typeof ResizeObserver>"u")return;let C=null;const B=new ResizeObserver(()=>{C===null&&(C=requestAnimationFrame(()=>{C=null,S(!1)}))}),H=O.querySelector(_.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=O.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),C!==null&&cancelAnimationFrame(C)}},[n,S]),a.useEffect(()=>{x||S(!1)},[x,S]);const h=a.useMemo(()=>b?Rn(f,{logical:u,visible:l}):Se(l),[b,f,u,l]);a.useLayoutEffect(()=>{Un(d.current,h)||M(h)},[h,M]);const w=a.useMemo(()=>_.sortColumnIds(Object.keys(P)).map(O=>({id:O,key:O,className:"aqmx-multi-column"})),[P]),N=a.useMemo(()=>f.docs.map(O=>{const C=W(f,O);return{id:C,component:kn,title:ie(y,O),props:{docPath:O,panelId:C},minHeight:Fn,maxHeight:Vn}}),[f,y]),I=a.useMemo(()=>Object.fromEntries(f.docs.map(O=>[W(f,O),!f.hidden.has(O)])),[f]),i=f.maximized===null?null:W(f,f.maximized),g=a.useCallback(O=>{const{layout:C}=e.getSnapshot();for(const[B,H]of Y(C)){const q=O[B];if(q===void 0||q!==C.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),ze(n,B);continue}const V=n.current,de=V===null?null:Ee(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),de!==null&&Oe(n,de))}},[e,n,r,o]),T=a.useCallback(O=>{const C=Y(e.getSnapshot().layout).get(O);if(C===void 0)return;const B=()=>{const q=e.titleOf(C),F=n.current,V=F===null?null:Ee(F,O);e.close(C)&&(r.announce(o.panelClosed(q)),V!==null&&Oe(n,V))},H=s.unsavedAmong([C]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),D=a.useCallback(O=>{if(O===null){c(null);return}const C=Y(e.getSnapshot().layout).get(O);C!==void 0&&c(C)},[e,c]);return L.jsx("div",{className:"aqmx-multi-layout","aria-busy":!b,children:L.jsx(_.DragDropLayout,{columns:w,panels:N,columnPanels:P,onColumnPanelsChange:v,panelVisibility:I,onPanelVisibilityChange:g,dragState:p.dragState,dragOverPosition:p.dragOverPosition,originalPanelPosition:p.originalPanelPosition,dragModes:p.dragModes,debugConfig:_.DEFAULT_DEBUG_CONFIG,panelSizes:p.panelSizes,customDrag:p.customDrag,setPanelRef:p.setPanelRef,onDragStart:p.handleDragStart,onDragEnd:p.handleDragEnd,onPlaceholderDragEnter:p.handlePlaceholderDragEnter,onPlaceholderDragLeave:p.handlePlaceholderDragLeave,onDragOverWithInsert:p.handleDragOverWithInsert,onDropWithInsert:p.handleDropWithInsert,onColumnDragLeave:p.handleColumnDragLeave,onPanelMouseDown:p.handleMouseDown,onPanelSizeInfoClick:p.handlePanelSizeInfoClick,onToggleDragMode:p.toggleDragMode,onPanelClose:T,onPanelMaximizeChange:D,maximizedPanel:i,dragHandle:"header",labels:m,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:qn,renderStageScrollBar:Bn})})},te={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(c=>{const u=n.ownerDocument.elementsFromPoint(s,c),f=u.findIndex(y=>n.contains(y)),l=u.findIndex(y=>e.contains(y));return f!==-1&&l!==-1&&l<f}))},Kn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(te.blockStart,`${String(t.top)}px`),e.style.setProperty(te.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(te.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Jn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:c,announcer:u,edits:f}=R.useExplorer(),l=a.useRef(null),y=a.useRef(null),x=z(e,d=>d.ready),b=z(e,d=>d.layout.docs.length>0),k=z(e,d=>d.visibleColumns),E=a.use(oe.SheetNoticeSlotContext),m=a.useCallback(d=>{const{layout:S}=e.getSnapshot(),h=S.maximized,w=d===null&&h!==null?S.panelIds.get(h):void 0,N=l.current,I=w!==void 0&&N!==null&&ue(N,w);e.maximize(d)&&(d!==null?u.announce(c.panelMaximized(e.titleOf(d))):h!==null&&u.announce(c.panelRestored(e.titleOf(h))),w!==void 0&&Gn(l,w,I))},[e,u,c]),v=a.useCallback((d,S,h,w)=>{if(h===S){e.setPendingHash(d,w);return}const N=f.unsavedAmong([S]);if(N.length>0){f.askToDiscard(N).then(T=>{T&&v(d,S,h,w)});return}const I=e.navigate(S,h);if(I==="navigated"){e.setPendingHash(d,w);return}if(I!=="existing")return;const{layout:i}=e.getSnapshot(),g=i.panelIds.get(h);g!==void 0&&(u.announce(c.panelAlreadyOpen(e.titleOf(h))),i.maximized===null?e.setHidden(h,!1):m(h),e.setPendingHash(g,w),ze(l,g))},[e,u,c,m,f]);a.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const d=y.current,S=l.current;if(d===null||S===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Kn(d,S)},[t,E]),a.useEffect(()=>{const d=y.current;if(t===null||d===null)return;const{ownerDocument:S}=d;let h=null;const w=N=>{const I=N.target;I instanceof Element&&(h!==null&&cancelAnimationFrame(h),h=requestAnimationFrame(()=>{h=null,S.activeElement===I&&d.isConnected&&Wn(d,I)&&o()}))};return S.addEventListener("focusin",w,!0),()=>{S.removeEventListener("focusin",w,!0),h!==null&&cancelAnimationFrame(h)}},[t,E,o]),a.useImperativeHandle(r,()=>({bringIntoView:d=>{requestAnimationFrame(()=>{const S=l.current,h=e.getSnapshot().layout.panelIds.get(d);S!==null&&h!==void 0&&X(S,h,null)})}}),[e]),a.useEffect(()=>{const d=l.current;return()=>{d!==null&&G.get(d)?.()}},[]);const p=a.useCallback((d,S)=>{const h=l.current;h!==null&&X(h,d,S)},[]),[P]=a.useState(Ve),M=a.useMemo(()=>({store:e,Body:n,followLink:v,maximize:m,revealInPanel:p,focusCarry:P}),[e,n,v,m,p,P]),A=a.useMemo(()=>Array.from({length:s.multiView.columns},(d,S)=>_.generateColumnId(S)),[s]);return L.jsxs("section",{ref:l,className:"aqmx-multi-stage",style:Dn,tabIndex:-1,"aria-label":c.multiRegion,"aria-busy":b&&!x,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":k,...R.CONTENT_PANE,children:[L.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),b?x?L.jsx(Ce,{value:M,children:L.jsx(Yn,{store:e,stageRef:l})}):L.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:A.map(d=>L.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[L.jsx("span",{}),L.jsx("span",{}),L.jsx("span",{})]},d))}):L.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:L.jsx("p",{className:"aqmx-empty-title",children:c.multiEmpty})}),t===null?null:E!==null?Be.createPortal(L.jsx("div",{ref:y,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):L.jsx("div",{ref:y,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},se=(e,n,t)=>{const o=new Set(e),r=n.filter(c=>!o.has(c)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Xn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Zn=({location:e})=>{const{config:n,labels:t,announcer:o}=R.useExplorer(),r=mn(e),s=z(r,w=>w.layout.docs),c=z(r,w=>w.layout.maximized),u=z(r,w=>w.layout.markup),f=z(r,w=>w.source),[l,y]=a.useState(()=>({docs:s,latest:se([],s,null)}));l.docs!==s&&y({docs:s,latest:se(l.docs,s,l.latest)});const x=c!==null?c:l.latest,[b,k]=a.useState(!1),E=a.useRef(null),[m,v]=a.useState(0),p=a.useRef(null),P=a.useRef(null);a.useLayoutEffect(()=>{const w=p.current;p.current=null,w!==null&&(r.whenUrlRendered(()=>o.announce(w.announcement)),P.current?.bringIntoView(w.doc))}),a.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const M=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),k(!0),E.current=setTimeout(()=>{E.current=null,k(!1)},He)},[]),A=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,k(!1)},[]),d=a.useCallback(w=>{const N=r.titleOf(w),I=r.toggle(w);I==="rejected"&&M();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Xn(t,I,N);if(I==="shown"){p.current={doc:w,announcement:i},v(g=>g+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&P.current?.bringIntoView(w)})},[r,M,o,t,n]),S=a.useMemo(()=>new Set(s),[s]),h=a.useMemo(()=>{const w=qe(s,c);return{href:j.explorerHref(n,{view:"tree",source:f,doc:w,markup:w!==null&&u.has(w)}),target:"tree"}},[n,f,s,c,u]);return L.jsx(oe.ExplorerSplit,{view:"multi",explorer:L.jsx(oe.ExplorerPane,{mode:"multi",sourceId:f,currentPath:x,openPaths:S,onOpenDocument:d,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:h}),content:L.jsx(Jn,{ref:P,store:r,body:pn,limitNotice:b?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:A}),contentCoversPage:c!==null,sheetDismissals:m,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Zn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=se;exports.treeSwitchDocument=qe;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as ie, jsx as N } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as Je, use as ke, useRef as q, useState as $, useLayoutEffect as F, useMemo as D, useSyncExternalStore as Xe, useCallback as R, memo as Ze, useEffect as U, useImperativeHandle as Qe } from "react";
|
|
3
3
|
import { k as ce, e as Ae, l as en, P as nn, m as tn } from "./location-B-m9scLf.js";
|
|
4
|
-
import { H as on, u as J, I as rn, J as ln, D as sn, f as an, N as cn, K as V, e as Le, L as un, M as Ie } from "./index-
|
|
5
|
-
import { S as dn, a as mn, b as fn } from "./ExplorerSplit-
|
|
4
|
+
import { H as on, u as J, I as rn, J as ln, D as sn, f as an, N as cn, K as V, e as Le, L as un, M as Ie } from "./index-Dz01kBab.js";
|
|
5
|
+
import { S as dn, a as mn, b as fn } from "./ExplorerSplit-LiI3IUZn.js";
|
|
6
6
|
import { SCROLL_AREA_SELECTOR as Re, SCROLL_ROOT_SELECTOR as te, PANEL_ACTION_ATTRIBUTE as he, generateColumnIds as pn, sortColumnIds as De, generateColumnId as _e, NO_PANEL_DRAG_ATTRIBUTE as gn, useDragDropColumns as hn, DEFAULT_DEBUG_CONFIG as ve, DragDropLayout as vn } from "@aiquants/drag-drop-panels";
|
|
7
7
|
import { useNavigate as wn, useLocation as yn } from "react-router";
|
|
8
8
|
import { s as Sn, r as xn, w as En } from "./storage-CmGHg7OA.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),h=require("@aiquants/virtualscroll"),a=require("react"),v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),h=require("@aiquants/virtualscroll"),a=require("react"),v=require("./index-DrKHJNY4.cjs"),g=require("./scrollBarGeometry-C46jBtmM.cjs"),S=require("./tapScrollCircle-C5DGI-0H.cjs"),p=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),m=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,f=e=>{let t=p(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const i=p(e);m(t,i)||(t=i,s())};let n=0;const c=()=>{n===0&&(n=requestAnimationFrame(()=>{n=0,o()}))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(c),l=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const i of e.children)r.observe(i)}};l();const u=typeof MutationObserver>"u"?null:new MutationObserver(()=>{l(),c()});return u?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),u?.disconnect(),r?.disconnect(),cancelAnimationFrame(n)}}}},b=e=>{const t=a.useMemo(()=>f(e),[e]);return a.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},d=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=v.useExplorer(),{scrollTop:o,scrollHeight:n,clientHeight:c}=b(e),r=a.useCallback(l=>d(e,l),[e]);return T.jsx(h.ScrollBar,{contentSize:n,viewportSize:c,scrollPosition:o,onScroll:r,scrollBarWidth:g.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?S.TAP_SCROLL_CIRCLE:S.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=d;exports.useScrollerMetrics=b;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as p } from "react/jsx-runtime";
|
|
2
2
|
import { ScrollBar as m } from "@aiquants/virtualscroll";
|
|
3
3
|
import { useCallback as b, useMemo as S, useSyncExternalStore as h } from "react";
|
|
4
|
-
import { u as T } from "./index-
|
|
4
|
+
import { u as T } from "./index-Dz01kBab.js";
|
|
5
5
|
import { N as f } from "./scrollBarGeometry-DOBdGNV-.js";
|
|
6
6
|
import { T as d, N as v } from "./tapScrollCircle-u4EXeLhx.js";
|
|
7
7
|
const u = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), g = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, C = (e) => {
|
|
@@ -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-
|
|
6
|
-
import { E as Y, a as J, b as K } from "./ExplorerSplit-
|
|
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";
|
|
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-
|
|
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;
|