@aiquants/markdown-explorer 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +65 -1
  2. package/README.md +18 -9
  3. package/dist/EditSurface-Bwl4S1vQ.cjs +7 -0
  4. package/dist/EditSurface-rKoy_ndP.js +880 -0
  5. package/dist/{ExplorerSplit-LiI3IUZn.js → ExplorerSplit-3WMRDA7G.js} +1 -1
  6. package/dist/{ExplorerSplit-BDkBN8A0.cjs → ExplorerSplit-CdqEKz-I.cjs} +1 -1
  7. package/dist/{MultiLayout-BOaQK8fp.cjs → MultiLayout-BEg1X8Jx.cjs} +1 -1
  8. package/dist/{MultiLayout-KWacTPP8.js → MultiLayout-Gf1xT-Le.js} +2 -2
  9. package/dist/{NativeScrollBar-zzpty31a.js → NativeScrollBar-0cpp2OIu.js} +1 -1
  10. package/dist/{NativeScrollBar-BPgV3kp-.cjs → NativeScrollBar-idIQsvCv.cjs} +1 -1
  11. package/dist/{TreeLayout-S5TMf8_A.cjs → TreeLayout-DJY_WqzP.cjs} +1 -1
  12. package/dist/{TreeLayout-C8IP4cjY.js → TreeLayout-DzZCgMTt.js} +2 -2
  13. package/dist/core/labels.d.cts +26 -0
  14. package/dist/core/labels.d.ts +26 -0
  15. package/dist/{index-Dz01kBab.js → index-CJgHGeZs.js} +1323 -1238
  16. package/dist/index-bMaSoQTe.cjs +13 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/{merge-ClVgYrkS.js → merge-BOcofJN5.js} +1 -1
  20. package/dist/{merge-B7Lkcdz0.cjs → merge-BVk6pvO_.cjs} +1 -1
  21. package/dist/sanitizePolicy-BWQtWhsL.js +98 -0
  22. package/dist/sanitizePolicy-gEXeavb-.cjs +1 -0
  23. package/dist/sanitizeWorker.cjs +1 -1
  24. package/dist/sanitizeWorker.js +1 -1
  25. package/docs/behavior/localization.md +5 -1
  26. package/docs/behavior/security.md +18 -8
  27. package/package.json +9 -7
  28. package/dist/EditSurface-4VX20isB.cjs +0 -2
  29. package/dist/EditSurface-Ckg-3iTA.js +0 -786
  30. package/dist/index-DrKHJNY4.cjs +0 -13
  31. package/dist/sanitizePolicy-DlrakwA4.js +0 -96
  32. package/dist/sanitizePolicy-DrIMuYCb.cjs +0 -1
@@ -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-Dz01kBab.js";
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-CJgHGeZs.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";
@@ -1 +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
+ "use strict";const c=require("react/jsx-runtime"),v=require("./index-bMaSoQTe.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 +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-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
+ "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-bMaSoQTe.cjs"),oe=require("./ExplorerSplit-CdqEKz-I.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-Dz01kBab.js";
5
- import { S as dn, a as mn, b as fn } from "./ExplorerSplit-LiI3IUZn.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-CJgHGeZs.js";
5
+ import { S as dn, a as mn, b as fn } from "./ExplorerSplit-3WMRDA7G.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,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-Dz01kBab.js";
4
+ import { u as T } from "./index-CJgHGeZs.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) => {
@@ -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-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
+ "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-bMaSoQTe.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),u=require("react"),T=require("react-router"),p=require("./location-BVEN_Ihk.cjs"),d=require("./index-DrKHJNY4.cjs"),x=require("./ExplorerSplit-BDkBN8A0.cjs"),P=(t,e)=>t.claim!==e.claim||t.readme.status!==e.readme.status?!1:t.readme.status==="failed"&&e.readme.status==="failed"?t.readme.failure===e.readme.failure:t.readme.status==="ok"&&e.readme.status==="ok"?t.readme.readme===e.readme.readme:!0,F=(t,e,n)=>{let r=null;return()=>{const a=t.version(),c=t.read(e),o=c.status!=="pending";if(r!==null&&r.version===a&&r.tree===c&&r.settled===o)return r.state;const l=d.readFolderReadme(t,e,n),s=r!==null&&P(r.state,l)?r.state:l;return r={version:a,tree:c,settled:o,state:s},s}},_=(t,e,n)=>{let r=!0,a=null;const c=()=>{r&&n()},o=()=>{const s=t.read(e);s===a||s.status!=="pending"||(a=s,s.then(c,c))};o();const l=t.subscribe(()=>{o(),n()});return()=>{r=!1,l()}},j=()=>d.FOLDER_README_LOADING,q=(t,e)=>{const{trees:n}=d.useExplorer(),r=u.useMemo(()=>e===null?null:F(n,t,e),[n,t,e]),a=u.useCallback(f=>r===null?()=>{}:_(n,t,f),[r,n,t]),c=u.useCallback(()=>r===null?null:r(),[r]),o=u.useCallback(()=>r===null?null:j(),[r]),l=u.useSyncExternalStore(a,c,o),s=l?.claim===!0;return u.useEffect(()=>e===null?void 0:n.open(t),[n,t,e]),u.useEffect(()=>e===null||!s?void 0:n.claimChildren(t,new Map([[e,"direct"]])),[n,t,e,s]),l===null?null:l.readme},y=new Set,H=Object.freeze({kind:"loading"}),L=(t,e)=>e.status==="loading"?H:e.status==="failed"?{kind:"failure",folder:t,failure:e.failure,onRetry:e.retry}:{kind:"no-readme",folder:t},A=({location:t})=>{const{config:e}=d.useExplorer(),n=d.useExplorerNavigate(),{hash:r}=T.useLocation(),{source:a,doc:c,folder:o,overrides:l,markup:s}=t,[f,S]=u.useState(x.EMPTY_SELECTION),w=u.useMemo(()=>({gathered:f,onGatheredChange:S}),[f]),v=q(a,o),i=v===null?c:v.status==="ok"?v.readme:null,k=u.useMemo(()=>o===null||v===null?d.NO_DOCUMENT:L(o,v),[o,v]),h=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,doc:m,overrides:l}),"browse"),[n,e,a,l]),O=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:a,folder:m,overrides:l}),"browse"),[n,e,a,l]),g=u.useCallback(m=>n(p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s}),"switch-source"),[n,e,c,o,l,s]),C=u.useCallback(m=>n(`${p.explorerHref(e,{view:"tree",source:m,doc:c,folder:o,overrides:l,markup:s})}${r}`,"browse"),[n,e,c,o,l,s,r]),R=u.useCallback(m=>{const E=p.canonicalMultiDocuments(e,m);n(p.explorerHref(e,{view:"multi",source:a,docs:E,markup:s&&i!==null&&E.includes(i)?[i]:[]}),"switch-view")},[n,e,a,i,s]),M=u.useMemo(()=>({href:p.explorerHref(e,i===null?{view:"multi",source:a}:{view:"multi",source:a,docs:[i],markup:s?[i]:[]}),target:"multi"}),[e,a,i,s]),D=u.useMemo(()=>({kind:"page",view:"tree",overrides:l,embed:{}}),[l]),N=d.usePageMarkupToggle(t);return b.jsx(x.ExplorerSplit,{view:"tree",explorer:b.jsx(x.ExplorerPane,{mode:"tree",sourceId:a,currentPath:o===null?c:o,openPaths:y,onOpenDocument:h,onOpenFolder:O,currentFolder:o!==null,onSourceChange:g,onRevealSource:C,viewSwitch:M,tray:w,onOpenSelection:R}),content:b.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",...d.CONTENT_PANE,children:[i===null?null:b.jsx(d.DocumentRefreshBar,{path:i,placement:d.PAGE_DOCUMENT_REFRESH,markup:N}),b.jsx(d.DocumentPane,{path:i,absence:k,markup:s,variant:D})]})})};exports.TreeLayout=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),u=require("react"),T=require("react-router"),p=require("./location-BVEN_Ihk.cjs"),d=require("./index-bMaSoQTe.cjs"),x=require("./ExplorerSplit-CdqEKz-I.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;
@@ -2,8 +2,8 @@ import { jsx as w, jsxs as _ } from "react/jsx-runtime";
2
2
  import { useMemo as v, useCallback as m, useSyncExternalStore as C, useEffect as S, useState as M } from "react";
3
3
  import { useLocation as A } from "react-router";
4
4
  import { e as p, c as L } from "./location-B-m9scLf.js";
5
- import { u as h, r as y, F as G, c as j, N as H, d as q, e as U, D as $, P as z, f as B } from "./index-Dz01kBab.js";
6
- import { E as Y, a as J, b as K } from "./ExplorerSplit-LiI3IUZn.js";
5
+ import { u as h, r as y, F as G, c as j, N as H, d as q, e as U, D as $, P as z, f as B } from "./index-CJgHGeZs.js";
6
+ import { E as Y, a as J, b as K } from "./ExplorerSplit-3WMRDA7G.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 () => {
@@ -230,6 +230,32 @@ export type MarkdownExplorerLabels = {
230
230
  readonly viewerEmbeddedVideo: string;
231
231
  readonly viewerEmbeddedPost: string;
232
232
  readonly viewerEmbeddedFrame: string;
233
+ readonly viewerSpreadsheetTable: string;
234
+ readonly viewerSpreadsheetZoomIn: string;
235
+ readonly viewerSpreadsheetZoomOut: string;
236
+ readonly viewerSpreadsheetResetZoom: string;
237
+ readonly viewerSpreadsheetHighlight: string;
238
+ readonly viewerSpreadsheetCopyAll: string;
239
+ readonly viewerSpreadsheetSaveTsv: string;
240
+ readonly viewerSpreadsheetSaveMenu: string;
241
+ readonly viewerSpreadsheetSaveTsvWithBom: string;
242
+ readonly viewerSpreadsheetFullscreen: string;
243
+ readonly viewerSpreadsheetExitFullscreen: string;
244
+ readonly viewerSpreadsheetFullscreenDialog: string;
245
+ readonly viewerSpreadsheetSize: string;
246
+ readonly viewerSpreadsheetFileName: string;
247
+ readonly viewerSpreadsheetCopied: string;
248
+ readonly viewerSpreadsheetCopyFailed: string;
249
+ readonly viewerSpreadsheetCellAnnouncement: string;
250
+ readonly viewerSpreadsheetEmptyCell: string;
251
+ readonly viewerSpreadsheetSelectionAnnouncement: string;
252
+ readonly viewerSpreadsheetReadOnly: string;
253
+ readonly viewerSpreadsheetFormatRefused: string;
254
+ readonly viewerSpreadsheetFenceRefused: string;
255
+ readonly viewerSpreadsheetEditConflict: string;
256
+ readonly viewerSpreadsheetOptionsError: string;
257
+ readonly viewerSpreadsheetLoadFailed: string;
258
+ readonly viewerSpreadsheetRetry: string;
233
259
  readonly multiRegion: string;
234
260
  readonly multiEmpty: string;
235
261
  readonly panelLimit: (max: number) => string;