@aiquants/markdown-explorer 0.2.0 → 0.4.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 (60) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +69 -11
  3. package/dist/ExplorerSplit-rUVsf5i-.cjs +1 -0
  4. package/dist/ExplorerSplit-uX2ojZe8.js +1479 -0
  5. package/dist/MultiLayout-8s7q3-Hm.js +919 -0
  6. package/dist/MultiLayout-ZK2V9nms.cjs +1 -0
  7. package/dist/NativeScrollBar-D3VDRQqf.js +59 -0
  8. package/dist/NativeScrollBar-DqkutcGb.cjs +1 -0
  9. package/dist/{TreeLayout-BoyFelK2.js → TreeLayout-C7ZNnaOr.js} +3 -3
  10. package/dist/{TreeLayout-CLWbWjOc.cjs → TreeLayout-DkTVgxxb.cjs} +1 -1
  11. package/dist/core/config.d.cts +15 -2
  12. package/dist/core/config.d.ts +15 -2
  13. package/dist/core/contracts.d.cts +8 -0
  14. package/dist/core/contracts.d.ts +8 -0
  15. package/dist/core/labels.d.cts +5 -1
  16. package/dist/core/labels.d.ts +5 -1
  17. package/dist/core/treeSettings.d.cts +4 -2
  18. package/dist/core/treeSettings.d.ts +4 -2
  19. package/dist/dataRoute-DYjYBiXF.cjs +1 -0
  20. package/dist/{dataRoute-Bkfwfp1R.js → dataRoute-Dl6xmEFs.js} +59 -53
  21. package/dist/index-CLe6vRXs.cjs +3 -0
  22. package/dist/{index-BfuAu2GV.js → index-Dv9lUZqD.js} +530 -503
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +23 -22
  27. package/dist/location-2QZADLiv.cjs +1 -0
  28. package/dist/location-CaNtUswk.js +424 -0
  29. package/dist/sanitizeWorker.cjs +1 -1
  30. package/dist/sanitizeWorker.js +1 -1
  31. package/dist/scrollBarGeometry-C46jBtmM.cjs +1 -0
  32. package/dist/scrollBarGeometry-DOBdGNV-.js +4 -0
  33. package/dist/server/anonymous.d.cts +2 -2
  34. package/dist/server/anonymous.d.ts +2 -2
  35. package/dist/server/errors.d.cts +1 -1
  36. package/dist/server/errors.d.ts +1 -1
  37. package/dist/server/fileSystemSource.d.cts +1 -0
  38. package/dist/server/fileSystemSource.d.ts +1 -0
  39. package/dist/server/ports.d.cts +8 -1
  40. package/dist/server/ports.d.ts +8 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -1
  43. package/dist/server.d.ts +1 -1
  44. package/dist/server.js +763 -690
  45. package/dist/styles/markdown-explorer.css +1 -1
  46. package/dist/tapScrollCircle-C5DGI-0H.cjs +1 -0
  47. package/dist/tapScrollCircle-u4EXeLhx.js +6 -0
  48. package/docs/behavior/dom-hooks.md +3 -1
  49. package/docs/behavior/layout.md +2 -0
  50. package/docs/behavior/localization.md +1 -0
  51. package/docs/behavior/security.md +17 -3
  52. package/package.json +7 -7
  53. package/dist/ExplorerSplit-D2plJRRe.cjs +0 -1
  54. package/dist/ExplorerSplit-DB37U7Kh.js +0 -1362
  55. package/dist/MultiLayout-DCPDu1-l.js +0 -909
  56. package/dist/MultiLayout-UyWxs6Xy.cjs +0 -1
  57. package/dist/dataRoute-CKbdwkQ7.cjs +0 -1
  58. package/dist/index-Cx3-jSna.cjs +0 -3
  59. package/dist/location-Oo21lTyV.cjs +0 -1
  60. package/dist/location-fVl2R1ee.js +0 -395
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),u=require("react"),B=require("./location-2QZADLiv.cjs"),k=require("./index-CLe6vRXs.cjs"),ne=require("./ExplorerSplit-rUVsf5i-.cjs"),D=require("@aiquants/drag-drop-panels"),me=require("react-router"),Z=require("./storage-Bkb2Axdi.cjs"),be=require("./dataRoute-DYjYBiXF.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=u.createContext(null),re=()=>{const e=u.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)},J=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},Le=(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]=B.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([a,f])=>e.slice(a,f).reduce((c,g)=>c+g.length,0);let s=t;for(const a of o)r(a)<r(s)&&(s=a);let l=s[0];for(let a=s[0];a<s[1];a+=1)(e[a]?.length??0)<(e[l]?.length??0)&&(l=a);return l},X=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Le(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)=>B.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),nn=(e,n,t)=>{const[o,r]=n,s=r-o,l=e.length,a=Array.from({length:s},(d,p)=>{const m=[0];for(const O of e)m.push((m.at(-1)??0)+(t(O)===o+p?1:0));return m}),f=(d,p,m)=>(a[d]?.[m]??0)-(a[d]?.[p]??0),c=Array.from({length:s+1},()=>Array.from({length:l+1},()=>Number.NEGATIVE_INFINITY)),g=Array.from({length:s+1},()=>Array.from({length:l+1},()=>0)),y=c[0];y&&(y[0]=0);for(let d=0;d<s;d+=1)for(let p=0;p<=l;p+=1)for(let m=0;m<=p;m+=1){const O=(c[d]?.[m]??Number.NEGATIVE_INFINITY)+f(d,m,p),x=c[d+1],T=g[d+1];x&&T&&O>(x[p]??Number.NEGATIVE_INFINITY)&&(x[p]=O,T[p]=m)}const L=Array.from({length:s},()=>[]);let E=l;for(let d=s;d>0;d-=1){const p=g[d]?.[E]??0;L[d-1]=e.slice(p,E),E=p}return L},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const l of s)o.delete(l),o.set(l,r);for(const r of o.keys()){if(o.size<=J)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=X(e,t),s=Le(e,n,t.logical)??Me(r,t);r[s]?.push(n);const l=new Map(e.panelIds);return l.set(n,Pe(n,new Set(l.values()))),{state:{...e,...Te(e,r),panelIds:l},outcome:"opened"}},Re=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Map(e.panelIds);return o.delete(n),{...e,docs:e.docs.filter(r=>r!==n),hidden:t,panelIds:o,maximized:e.maximized===n?null:e.maximized}},on=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(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 l=new Map(e.panelIds),a=l.get(n);if(a===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return l.delete(n),l.set(t,a),{state:{docs:e.docs.map(f=>f===n?t:f),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,panelIds:l},outcome:"navigated"}},Ne=(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)=>{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}},ln=(e,n,t)=>{const o=X(e,t),r=new Map;for(const[c,g]of o.entries())for(const y of g)r.set(y,c);const s=new Set(e.docs),l=new Set,a=B.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[c,g]of a.entries()){const y=(n[c]??[]).filter(L=>s.has(L)&&!l.has(L));for(const L of y)l.add(L);for(const[L,E]of nn(y,g,d=>r.get(d)).entries())f[g[0]+L]?.push(...E)}for(const c of e.docs)l.has(c)||f[r.get(c)??0]?.push(c);return f.every((c,g)=>c.length===o[g]?.length&&c.every((y,L)=>o[g]?.[L]===y))?e:{...e,...Te(e,f)}},Q=(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)),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 X(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=J)break;t.delete(o)}return{...e,columnOf:t}},Ie=1,F=Object.freeze({columnOf:new Map,hidden:new Set}),cn=(e,n)=>{if(e===null||e==="")return F;let t;try{t=JSON.parse(e)}catch{return F}if(t===null||typeof t!="object"||Array.isArray(t))return F;const o=t;if(o.v!==Ie)return F;const r=new Map;if(Array.isArray(o.columnOf))for(const l of o.columnOf.slice(-J))Array.isArray(l)&&l.length===2&&typeof l[0]=="string"&&l[0]!==""&&Number.isInteger(l[1])&&l[1]>=0&&l[1]<n&&(r.delete(l[0]),r.set(l[0],l[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(l=>typeof l=="string"&&l!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Ie,columnOf:[...e.columnOf.entries()].slice(-J),hidden:e.docs.filter(n=>e.hidden.has(n))}),se=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},$=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))}`)},un=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,l=k.createEmitter(),a=new Map,f=new Map;let c={layout:Q({docs:n.docs,maximized:n.maximized,stored:F},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},g=!1;const y=i=>g?fe(i,{logical:s,visible:c.visibleColumns}):i,L=(i,v)=>B.explorerHref(e,{view:"multi",source:i,docs:v.docs,maximized:v.maximized});let E=L(n.source,n),d=n.source,p=E;const m=[],O=[];let x=null;const T=()=>{if(!(m.length>0))for(const i of O.splice(0))i()},h=i=>{c={...c,...i},l.emit()},b=()=>{if(!c.ready)return;const i=an(c.layout);i!==x&&(x=i,o(i))},S=(i,v,M)=>{const A=L(i,v);A!==E&&(E=A,d=i,m.push(A),t(A,M))},P=i=>{const v=new Set(i.panelIds.values());for(const C of[...a.keys()])v.has(C)||a.delete(C);for(const C of[...f.keys()])v.has(C)||f.delete(C);const M=new Set(i.docs),A=[...c.titles.keys()].every(C=>M.has(C))?c.titles:new Map([...c.titles].filter(([C])=>M.has(C))),w=[...c.pendingHashes.keys()].every(C=>v.has(C))?c.pendingHashes:new Map([...c.pendingHashes].filter(([C])=>v.has(C)));return{titles:A,pendingHashes:w}},N=i=>i===c.layout?!1:(h({layout:i,...P(i)}),S(d,i,"replace"),b(),!0),I=()=>({logical:s,visible:c.visibleColumns});return{getSnapshot:()=>c,subscribe:l.subscribe,toggle:i=>{pe(i);const{state:v,outcome:M}=on(c.layout,i,I(),r);return N(v),M},close:i=>N(Re(c.layout,i)),navigate:(i,v)=>{pe(v);const{state:M,outcome:A}=rn(c.layout,i,v);if(A!=="navigated")return A;const w=M.panelIds.get(v);return w!==void 0&&(a.delete(w),f.delete(w)),N(M),A},setHidden:(i,v)=>N(Ne(c.layout,i,v)),maximize:i=>N(sn(c.layout,i)),arrange:i=>N(ln(c.layout,i,{logical:s,visible:i.length})),changeSource:i=>{S(i,c.layout,"push")},observeLocation:i=>{const v=L(i.source,i);if(v===E)return m.length=0,p=v,i.source!==c.source&&h({source:i.source}),T(),!1;if(v===p)return!1;p=v;const M=m.indexOf(v);if(M>=0)return m.splice(0,M+1),i.source!==c.source&&h({source:i.source}),T(),!1;m.length=0,E=v,d=i.source;const A=y(Q({docs:i.docs,maximized:i.maximized,stored:{columnOf:c.layout.columnOf,hidden:c.layout.hidden},panelIds:c.layout.panelIds},r));return h({layout:A,source:i.source,...P(A)}),b(),T(),!0},whenUrlRendered:i=>{O.push(i),T()},loadStored:i=>{h({layout:y(Q({docs:c.layout.docs,maximized:c.layout.maximized,stored:i,panelIds:c.layout.panelIds},r)),ready:!0}),b()},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)}`);g=!0;const v=fe(c.layout,{logical:s,visible:i});i===c.visibleColumns&&v===c.layout||(h({visibleColumns:i,layout:v}),v!==c.layout&&b())},setSplitDragging:i=>{i!==c.splitDragging&&h({splitDragging:i})},setTitle:(i,v)=>{!c.layout.docs.includes(i)||c.titles.get(i)===v||h({titles:new Map(c.titles).set(i,v)})},titleOf:i=>se(c.titles,i),setPendingHash:(i,v)=>{const M=c.pendingHashes.get(i);if(v===null||v===""){if(M===void 0)return;const A=new Map(c.pendingHashes);A.delete(i),h({pendingHashes:A});return}M!==v&&h({pendingHashes:new Map(c.pendingHashes).set(i,v)})},saveReadingPosition:(i,v,M)=>{c.layout.panelIds.get(v)===i&&a.set(i,{doc:v,position:M})},readingPositionOf:(i,v)=>{const M=a.get(i);return M===void 0||M.doc!==v?null:M.position},saveImageView:(i,v,M)=>{f.set(i,{url:v,state:M})},imageViewOf:(i,v)=>{const M=f.get(i);return M===void 0||M.url!==v?null:M.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},dn=e=>{const{config:n,storageNamespace:t}=k.useExplorer(),o=me.useNavigate(),r=u.useRef(o),s=Z.storageKeys(t).multiLayout,[l]=u.useState(()=>un({config:n,location:e,writeUrl:(c,g)=>{r.current(c,k.explorerNavigationOptions(g==="replace"?"browse":"switch-source"))},persist:c=>Z.writeStorage(s,c)}));u.useLayoutEffect(()=>{r.current=o},[o]);const a=me.useLocation(),f=u.useMemo(()=>({location:e,navigated:a}),[e,a]);return u.useLayoutEffect(()=>{l.observeLocation(f.location)},[l,f]),u.useLayoutEffect(()=>{l.loadStored(cn(Z.readStorage(s),n.multiView.columns))},[l,s,n]),l},mn=e=>{const n=e.closest(D.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},fn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:l,revealInPanel:a}=re(),{announcer:f}=k.useExplorer(),c=z(s,x=>Ue(x,n)),g=u.useCallback((x,T)=>l(n,e,x,T),[l,n,e]),y=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),L=u.useMemo(()=>({read:x=>s.imageViewOf(n,x),save:(x,T)=>s.saveImageView(n,x,T)}),[s,n]),E=u.useCallback((x,T)=>{T.kind!=="failure"&&s.setTitle(x,T.name),r(x)},[s,r]),d=u.useCallback(x=>{s.whenUrlRendered(()=>f.announce(x))},[s,f]),p=u.useMemo(()=>({scrollerOf:mn,reveal:x=>a(n,x)}),[a,n]),m=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:g,pendingHash:c,onHashConsumed:y,announceFailure:d,paneScroll:p}),[t,g,c,y,d,p]),O=u.useMemo(()=>({kind:"panel",documentName:o}),[o]);return R.jsxs(k.ImageViewMemoryContext,{value:L,children:[R.jsx(k.DocumentRefreshBar,{path:e,placement:O}),R.jsx(k.DocumentPane,{path:e,variant:m,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",le="data-aqmx-column-probe",Y="data-panel-id",te="--aqmx-multi-panel-chrome",j=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,pn=e=>e==="normal"?0:j(e),gn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${le}]`),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),l=t.clientWidth-j(s.paddingLeft)-j(s.paddingRight),a=t.clientHeight-j(s.paddingTop)-j(s.paddingBottom);return{plan:{trackInlineSize:l,gap:pn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:a}},hn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+j(t.paddingBottom)+j(t.borderBottomWidth)},W="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",vn=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}},yn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},Sn=(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),V=e=>{const n=e.closest(D.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},De=(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=De(e,n),o=[];let r=e;for(let s=ve([...r.children],t);s>=0;s=ve([...r.children],t)){const l=r.children[s];if(l===void 0)break;o.push(s),r=l}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-De(e,n)-t.anchor.offset)},wn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>JSON.stringify([e.tagName,...wn.map(n=>e.getAttribute(n))]),En=(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:_e(n)}},On=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&k.focusWithoutScroll(o)||n.focus({preventScroll:!0})},bn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?V(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=Sn(e,r,t);(o||Cn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Cn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Pn=e=>e.scrollHeight>e.clientHeight,Ln=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),l=()=>{const c=hn(e,n);if(!Number.isFinite(c))return;const g=s===null?0:s.getBoundingClientRect().height;g!==r&&(r=g,t.style.setProperty(he,`${String(g)}px`));const y=c+g;y!==o&&(o=y,e.style.setProperty(te,`${String(y)}px`))};l();let a=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,l()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),a!==null&&cancelAnimationFrame(a),e.style.removeProperty(te),t.style.removeProperty(he)}},Mn=e=>{const{docPath:n,panelId:t}=vn(e),{store:o,Body:r,maximize:s,focusCarry:l}=re(),a=z(o,d=>d.layout.maximized===n),f=z(o,d=>se(d.titles,n)),c=u.useRef(null),g=u.useRef(null),y=u.useRef(null);u.useEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null||a)return;const m=new Map,O=S=>{const P=m.get(S);if(P!==void 0)return P;const N=yn(S);return m.set(S,N),N},x=S=>bn(S,d,O);let T=!1;const h=()=>{const S=Pn(p);S!==T&&(T=S,S?d.addEventListener("wheel",x,{capture:!0,passive:!1}):d.removeEventListener("wheel",x,{capture:!0}))};h();const b=typeof ResizeObserver>"u"?null:new ResizeObserver(h);return b?.observe(p),b?.observe(d),()=>{b?.disconnect(),d.removeEventListener("wheel",x,{capture:!0})}},[a]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d),m=d===null?null:d.closest(`[${Y}]`);if(!(d===null||p===null||!(m instanceof HTMLElement)))return Ln(m,p,d)},[]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:V(d);if(d===null||p===null)return;const m=o.readingPositionOf(t,n);g.current=m===null?null:{doc:n,position:m},m!==null&&ye(d,p,m);let O=null;const x=()=>{O===null&&(O=requestAnimationFrame(()=>{O=null;const T=y.current;T!==null&&o.saveReadingPosition(t,T,xn(d,p))}))};return p.addEventListener("scroll",x,{passive:!0}),()=>{p.removeEventListener("scroll",x),O!==null&&cancelAnimationFrame(O)}},[o,t,n]),u.useLayoutEffect(()=>{const d=c.current,p=d===null?null:d.closest(`[${Y}]`);if(d===null||p===null)return;const m=l.take(t);return m!==null&&On(p,d,m),()=>{const O=En(p,p.ownerDocument.activeElement);O!==null&&l.hold(t,O)}},[l,t]);const L=u.useCallback(d=>{const p=c.current,m=p===null?null:V(p);if(p===null||m===null)return;const O=y.current;y.current=d;const x=g.current;g.current=null,x!==null&&x.doc===d?ye(p,m,x.position):O!==null&&O!==d&&(m.scrollTop=0)},[]),E=u.useCallback(()=>s(n),[s,n]);return R.jsx("div",{ref:c,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":a?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:a?void 0:E,children:R.jsx(r,{docPath:n,panelId:t,maximized:a,title:f,onContentShown:L})})},Tn=u.memo(Mn),G=(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(D.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=en(X(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>G(e,s))]))},Nn=(e,n)=>{const t=$(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},In=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,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}),An="--aqmx-multi-stage-bar-gutter",Dn=Object.freeze({[An]:`${String(Fe.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%"}),kn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),zn=e=>R.jsx("div",{...kn,children:R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Hn=({props:e,children:n})=>R.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:zn,children:n}),qn=e=>R.jsx(k.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ie="--aqmx-stage-block",Bn="--aqmx-multi-panel-body-floor",jn=`calc(var(${ie}) * ${String(B.PANEL_MIN_BLOCK_RATIO)})`,Fn=`max(calc(var(${ie}) * ${String(B.PANEL_MAX_BLOCK_RATIO)}), calc(var(${te}) + var(${Bn})))`,Vn=(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((l,a)=>r[a]===l)})},xe=["keydown","pointerdown","wheel","touchstart"],U=new WeakMap,we=(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)}},Un=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},K=(e,n,t)=>{U.get(e)?.();const o=e.querySelector(`[${Y}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const l=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const y=r?.isConnected===!0?r:o;y!==o&&y.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Un(y)};if(l(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(l);we(a,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&we(a,r,o);const{ownerDocument:f}=e,c=y=>{const L=y.target===f?f.scrollingElement:y.target;if(!(L instanceof Element))return;const E=s.get(L);E!==void 0&&(L.scrollTop!==E.top||L.scrollLeft!==E.left)&&g()},g=()=>{a.disconnect();for(const y of xe)f.removeEventListener(y,g,!0);f.removeEventListener("scroll",c,!0),U.get(e)===g&&U.delete(e)};for(const y of xe)f.addEventListener(y,g,{capture:!0,passive:!0});f.addEventListener("scroll",c,{capture:!0,passive:!0}),U.set(e,g)},ke=(e,n)=>{const t=e.querySelector(`[${W}="${n}"]`);return t instanceof HTMLElement?(K(e,n,null),t.focus({preventScroll:!0}),!0):!1},ce=(e,n)=>{const t=e.querySelector(`[${Y}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ce(e,n))return null;const t=[...e.querySelectorAll(`[${W}]`)].map(l=>l.getAttribute(W)),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"&&ke(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&ke(t,n)})},$n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(K(o,n,t&&ce(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const l=o.querySelector(`[${W}="${n}"]`);l instanceof HTMLElement&&l.focus({preventScroll:!0})})},Gn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r}=k.useExplorer(),{maximize:s}=re(),l=t.multiView.columns,a=z(e,w=>w.layout),f=z(e,w=>w.visibleColumns),c=z(e,w=>w.titles),g=z(e,w=>w.layout.maximized!==null||w.splitDragging),[y,L]=u.useState(!1),[E]=u.useState(()=>Se(f)),d=u.useMemo(()=>In(o),[o]),p=u.useCallback(w=>{e.arrange(Nn(e.getSnapshot().layout,w))},[e]),m=D.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:p}),{columnPanels:O,setColumnPanels:x}=m,T=u.useRef(g),h=u.useRef(O);u.useLayoutEffect(()=>{T.current=g,h.current=O},[g,O]);const b=u.useCallback(w=>{const C=n.current;if(C===null)return;const{plan:q,stageBlockSize:_}=gn(C,l);if(Number.isFinite(_)&&_>0&&C.style.setProperty(ie,`${String(_)}px`),T.current&&!w)return;const H=B.replanVisibleColumns(e.getSnapshot().visibleColumns,q);H!==null&&e.setVisibleColumns(H)},[e,n,l]);u.useLayoutEffect(()=>{b(!0),L(!0)},[b]),u.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let C=null;const q=new ResizeObserver(()=>{C===null&&(C=requestAnimationFrame(()=>{C=null,b(!1)}))}),_=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,H=w.querySelector(`[${le}]`);return _ instanceof Element&&q.observe(_),H instanceof Element&&q.observe(H),()=>{q.disconnect(),C!==null&&cancelAnimationFrame(C)}},[n,b]),u.useEffect(()=>{g||b(!1)},[g,b]);const S=u.useMemo(()=>y?Rn(a,{logical:l,visible:f}):Se(f),[y,a,l,f]);u.useLayoutEffect(()=>{Vn(h.current,S)||x(S)},[S,x]);const P=u.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),N=u.useMemo(()=>a.docs.map(w=>{const C=G(a,w);return{id:C,component:Tn,title:se(c,w),props:{docPath:w,panelId:C},minHeight:jn,maxHeight:Fn}}),[a,c]),I=u.useMemo(()=>Object.fromEntries(a.docs.map(w=>[G(a,w),!a.hidden.has(w)])),[a]),i=a.maximized===null?null:G(a,a.maximized),v=u.useCallback(w=>{const{layout:C}=e.getSnapshot();for(const[q,_]of $(C)){const H=w[q];if(H===void 0||H!==C.hidden.has(_))continue;const ae=e.titleOf(_);if(H){if(!e.setHidden(_,!1))continue;r.announce(o.panelShown(ae)),ze(n,q);continue}const ue=n.current,de=ue===null?null:Ee(ue,q);e.setHidden(_,!0)&&(r.announce(o.panelHidden(ae)),de!==null&&Oe(n,de))}},[e,n,r,o]),M=u.useCallback(w=>{const C=$(e.getSnapshot().layout).get(w);if(C===void 0)return;const q=e.titleOf(C),_=n.current,H=_===null?null:Ee(_,w);e.close(C)&&(r.announce(o.panelClosed(q)),H!==null&&Oe(n,H))},[e,n,r,o]),A=u.useCallback(w=>{if(w===null){s(null);return}const C=$(e.getSnapshot().layout).get(w);C!==void 0&&s(C)},[e,s]);return R.jsx("div",{className:"aqmx-multi-layout","aria-busy":!y,children:R.jsx(D.DragDropLayout,{columns:P,panels:N,columnPanels:O,onColumnPanelsChange:p,panelVisibility:I,onPanelVisibilityChange:v,dragState:m.dragState,dragOverPosition:m.dragOverPosition,originalPanelPosition:m.originalPanelPosition,dragModes:m.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:m.panelSizes,customDrag:m.customDrag,setPanelRef:m.setPanelRef,onDragStart:m.handleDragStart,onDragEnd:m.handleDragEnd,onPlaceholderDragEnter:m.handlePlaceholderDragEnter,onPlaceholderDragLeave:m.handlePlaceholderDragLeave,onDragOverWithInsert:m.handleDragOverWithInsert,onDropWithInsert:m.handleDropWithInsert,onColumnDragLeave:m.handleColumnDragLeave,onPanelMouseDown:m.handleMouseDown,onPanelSizeInfoClick:m.handlePanelSizeInfoClick,onToggleDragMode:m.toggleDragMode,onPanelClose:M,onPanelMaximizeChange:A,maximizedPanel:i,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Hn,renderStageScrollBar:qn})})},ee={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Yn=(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(l=>{const a=n.ownerDocument.elementsFromPoint(s,l),f=a.findIndex(g=>n.contains(g)),c=a.findIndex(g=>e.contains(g));return f!==-1&&c!==-1&&c<f}))},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(ee.blockStart,`${String(t.top)}px`),e.style.setProperty(ee.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(ee.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Kn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:l,announcer:a}=k.useExplorer(),f=u.useRef(null),c=u.useRef(null),g=z(e,h=>h.ready),y=z(e,h=>h.layout.docs.length>0),L=z(e,h=>h.visibleColumns),E=u.use(ne.SheetNoticeSlotContext),d=u.useCallback(h=>{const{layout:b}=e.getSnapshot(),S=b.maximized,P=h===null&&S!==null?b.panelIds.get(S):void 0,N=f.current,I=P!==void 0&&N!==null&&ce(N,P);e.maximize(h)&&(h!==null?a.announce(l.panelMaximized(e.titleOf(h))):S!==null&&a.announce(l.panelRestored(e.titleOf(S))),P!==void 0&&$n(f,P,I))},[e,a,l]),p=u.useCallback((h,b,S,P)=>{if(S===b){e.setPendingHash(h,P);return}const N=e.navigate(b,S);if(N==="navigated"){e.setPendingHash(h,P);return}if(N!=="existing")return;const{layout:I}=e.getSnapshot(),i=I.panelIds.get(S);i!==void 0&&(a.announce(l.panelAlreadyOpen(e.titleOf(S))),I.maximized===null?e.setHidden(S,!1):d(S),e.setPendingHash(i,P),ze(f,i))},[e,a,l,d]);u.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const h=c.current,b=f.current;if(h===null||b===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Wn(h,b)},[t,E]),u.useEffect(()=>{const h=c.current;if(t===null||h===null)return;const{ownerDocument:b}=h;let S=null;const P=N=>{const I=N.target;I instanceof Element&&(S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,b.activeElement===I&&h.isConnected&&Yn(h,I)&&o()}))};return b.addEventListener("focusin",P,!0),()=>{b.removeEventListener("focusin",P,!0),S!==null&&cancelAnimationFrame(S)}},[t,E,o]),u.useImperativeHandle(r,()=>({bringIntoView:h=>{requestAnimationFrame(()=>{const b=f.current,S=e.getSnapshot().layout.panelIds.get(h);b!==null&&S!==void 0&&K(b,S,null)})}}),[e]),u.useEffect(()=>{const h=f.current;return()=>{h!==null&&U.get(h)?.()}},[]);const m=u.useCallback((h,b)=>{const S=f.current;S!==null&&K(S,h,b)},[]),[O]=u.useState(Ve),x=u.useMemo(()=>({store:e,Body:n,followLink:p,maximize:d,revealInPanel:m,focusCarry:O}),[e,n,p,d,m,O]),T=u.useMemo(()=>Array.from({length:s.multiView.columns},(h,b)=>D.generateColumnId(b)),[s]);return R.jsxs("section",{ref:f,className:"aqmx-multi-stage",style:Dn,tabIndex:-1,"aria-label":l.multiRegion,"aria-busy":y&&!g,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":L,children:[R.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[le]:""}),y?g?R.jsx(Ce,{value:x,children:R.jsx(Gn,{store:e,stageRef:f})}):R.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:T.map(h=>R.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]},h))}):R.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:R.jsx("p",{className:"aqmx-empty-title",children:l.multiEmpty})}),t===null?null:E!==null?Be.createPortal(R.jsx("div",{ref:c,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):R.jsx("div",{ref:c,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},oe=(e,n,t)=>{const o=new Set(e),r=n.filter(l=>!o.has(l)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Jn=(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)}`)}}},Xn=({location:e})=>{const{config:n,labels:t,announcer:o}=k.useExplorer(),r=dn(e),s=z(r,P=>P.layout.docs),l=z(r,P=>P.layout.maximized),a=z(r,P=>P.source),[f,c]=u.useState(()=>({docs:s,latest:oe([],s,null)}));f.docs!==s&&c({docs:s,latest:oe(f.docs,s,f.latest)});const g=l!==null?l:f.latest,[y,L]=u.useState(!1),E=u.useRef(null),[d,p]=u.useState(0),m=u.useRef(null),O=u.useRef(null);u.useLayoutEffect(()=>{const P=m.current;m.current=null,P!==null&&(r.whenUrlRendered(()=>o.announce(P.announcement)),O.current?.bringIntoView(P.doc))}),u.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const x=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),L(!0),E.current=setTimeout(()=>{E.current=null,L(!1)},He)},[]),T=u.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,L(!1)},[]),h=u.useCallback(P=>{const N=r.titleOf(P),I=r.toggle(P);I==="rejected"&&x();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Jn(t,I,N);if(I==="shown"){m.current={doc:P,announcement:i},p(v=>v+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&O.current?.bringIntoView(P)})},[r,x,o,t,n]),b=u.useMemo(()=>new Set(s),[s]),S=u.useMemo(()=>({href:B.explorerHref(n,{view:"tree",source:a,doc:qe(s,l)}),target:"tree"}),[n,a,s,l]);return R.jsx(ne.ExplorerSplit,{view:"multi",explorer:R.jsx(ne.ExplorerPane,{mode:"multi",sourceId:a,currentPath:g,openPaths:b,onOpenDocument:h,onSourceChange:r.changeSource,viewSwitch:S}),content:R.jsx(Kn,{ref:O,store:r,body:fn,limitNotice:y?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:T}),contentCoversPage:l!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Xn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=oe;exports.treeSwitchDocument=qe;
@@ -0,0 +1,59 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { ScrollBar as u } from "@aiquants/virtualscroll";
3
+ import { useCallback as p, useMemo as b, useSyncExternalStore as S } from "react";
4
+ import { u as h } from "./index-Dv9lUZqD.js";
5
+ import { N as m } from "./scrollBarGeometry-DOBdGNV-.js";
6
+ import { T, N as d } from "./tapScrollCircle-u4EXeLhx.js";
7
+ const l = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), f = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, v = (e) => {
8
+ let t = l(e);
9
+ return {
10
+ getSnapshot: () => t,
11
+ subscribe: (s) => {
12
+ const o = () => {
13
+ const n = l(e);
14
+ f(t, n) || (t = n, s());
15
+ }, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(o), c = () => {
16
+ if (r !== null) {
17
+ r.disconnect(), r.observe(e);
18
+ for (const n of e.children) r.observe(n);
19
+ }
20
+ };
21
+ c();
22
+ const i = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
23
+ c(), o();
24
+ });
25
+ return i?.observe(e, { childList: !0 }), e.addEventListener("scroll", o, { passive: !0 }), o(), () => {
26
+ e.removeEventListener("scroll", o), i?.disconnect(), r?.disconnect();
27
+ };
28
+ }
29
+ };
30
+ }, g = (e) => {
31
+ const t = b(() => v(e), [e]);
32
+ return S(t.subscribe, t.getSnapshot, t.getSnapshot);
33
+ }, C = (e, t) => {
34
+ const s = typeof t == "function" ? t(e.scrollTop) : t;
35
+ return e.scrollTo({ top: s, behavior: "instant" }), e.scrollTop;
36
+ }, A = ({ scroller: e, withCircle: t }) => {
37
+ const { locale: s } = h(), { scrollTop: o, scrollHeight: r, clientHeight: c } = g(e), i = p((n) => C(e, n), [e]);
38
+ return /* @__PURE__ */ a(
39
+ u,
40
+ {
41
+ contentSize: r,
42
+ viewportSize: c,
43
+ scrollPosition: o,
44
+ onScroll: i,
45
+ scrollBarWidth: m,
46
+ enableThumbDrag: !0,
47
+ enableTrackClick: !0,
48
+ enableArrowButtons: !0,
49
+ enableArrowButtonTabStops: !1,
50
+ tapScrollCircleOptions: t ? T : d,
51
+ locale: s
52
+ }
53
+ );
54
+ };
55
+ export {
56
+ A as NativeScrollBar,
57
+ C as scrollScrollerTo,
58
+ g as useScrollerMetrics
59
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-CLe6vRXs.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(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}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
@@ -1,8 +1,8 @@
1
1
  import { jsx as s, jsxs as S } from "react/jsx-runtime";
2
2
  import { useState as f, useMemo as i, useCallback as u } from "react";
3
- import { e as a, c as g } from "./location-fVl2R1ee.js";
4
- import { u as P, a as D, D as b, P as C, b as N } from "./index-BfuAu2GV.js";
5
- import { E as O, a as T, b as M } from "./ExplorerSplit-DB37U7Kh.js";
3
+ import { e as a, c as g } from "./location-CaNtUswk.js";
4
+ import { u as P, a as D, D as b, P as C, b as N } from "./index-Dv9lUZqD.js";
5
+ import { E as O, a as T, b as M } from "./ExplorerSplit-uX2ojZe8.js";
6
6
  const _ = /* @__PURE__ */ new Set(), q = ({ location: l }) => {
7
7
  const { config: e } = P(), r = D(), { source: t, doc: o, overrides: n } = l, [m, p] = f(O), d = i(() => ({ gathered: m, onGatheredChange: p }), [m]), h = u((c) => r(a(e, { view: "tree", source: t, doc: c, overrides: n }), "browse"), [r, e, t, n]), v = u((c) => r(a(e, { view: "tree", source: c, doc: o, overrides: n }), "switch-source"), [r, e, o, n]), w = u((c) => r(a(e, { view: "multi", source: t, docs: g(e, c) }), "switch-view"), [r, e, t]), E = i(() => ({ href: a(e, { view: "multi", source: t, docs: o === null ? [] : [o] }), target: "multi" }), [e, t, o]), x = i(() => ({ kind: "page", view: "tree", overrides: n, embed: {} }), [n]);
8
8
  return /* @__PURE__ */ s(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),u=require("./location-Oo21lTyV.cjs"),i=require("./index-Cx3-jSna.cjs"),l=require("./ExplorerSplit-D2plJRRe.cjs"),g=new Set,f=({location:p})=>{const{config:e}=i.useExplorer(),n=i.useExplorerNavigate(),{source:o,doc:t,overrides:c}=p,[m,d]=r.useState(l.EMPTY_SELECTION),x=r.useMemo(()=>({gathered:m,onGatheredChange:d}),[m]),h=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:o,doc:s,overrides:c}),"browse"),[n,e,o,c]),v=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:s,doc:t,overrides:c}),"switch-source"),[n,e,t,c]),S=r.useCallback(s=>n(u.explorerHref(e,{view:"multi",source:o,docs:u.canonicalMultiDocuments(e,s)}),"switch-view"),[n,e,o]),w=r.useMemo(()=>({href:u.explorerHref(e,{view:"multi",source:o,docs:t===null?[]:[t]}),target:"multi"}),[e,o,t]),E=r.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]);return a.jsx(l.ExplorerSplit,{view:"tree",explorer:a.jsx(l.ExplorerPane,{mode:"tree",sourceId:o,currentPath:t,openPaths:g,onOpenDocument:h,onSourceChange:v,viewSwitch:w,tray:x,onOpenSelection:S}),content:a.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[t===null?null:a.jsx(i.DocumentRefreshBar,{path:t,placement:i.PAGE_DOCUMENT_REFRESH}),a.jsx(i.DocumentPane,{path:t,variant:E})]})})};exports.TreeLayout=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),u=require("./location-2QZADLiv.cjs"),i=require("./index-CLe6vRXs.cjs"),l=require("./ExplorerSplit-rUVsf5i-.cjs"),g=new Set,f=({location:p})=>{const{config:e}=i.useExplorer(),n=i.useExplorerNavigate(),{source:o,doc:t,overrides:c}=p,[m,d]=r.useState(l.EMPTY_SELECTION),x=r.useMemo(()=>({gathered:m,onGatheredChange:d}),[m]),h=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:o,doc:s,overrides:c}),"browse"),[n,e,o,c]),v=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:s,doc:t,overrides:c}),"switch-source"),[n,e,t,c]),S=r.useCallback(s=>n(u.explorerHref(e,{view:"multi",source:o,docs:u.canonicalMultiDocuments(e,s)}),"switch-view"),[n,e,o]),w=r.useMemo(()=>({href:u.explorerHref(e,{view:"multi",source:o,docs:t===null?[]:[t]}),target:"multi"}),[e,o,t]),E=r.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]);return a.jsx(l.ExplorerSplit,{view:"tree",explorer:a.jsx(l.ExplorerPane,{mode:"tree",sourceId:o,currentPath:t,openPaths:g,onOpenDocument:h,onSourceChange:v,viewSwitch:w,tray:x,onOpenSelection:S}),content:a.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[t===null?null:a.jsx(i.DocumentRefreshBar,{path:t,placement:i.PAGE_DOCUMENT_REFRESH}),a.jsx(i.DocumentPane,{path:t,variant:E})]})})};exports.TreeLayout=f;
@@ -1,4 +1,4 @@
1
- import { EmbedProviderId, MarkdownEmbeds } from "@aiquants/markdown/embeds";
1
+ import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
2
2
  import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
3
3
  import { TreeSettings } from "./treeSettings.cjs";
4
4
  export type ExplorerViewSlugs = {
@@ -21,11 +21,15 @@ export type ExplorerConfigInput = {
21
21
  readonly maxFolders?: number;
22
22
  readonly maxDepth?: number;
23
23
  };
24
+ readonly revealDocument?: {
25
+ readonly maxDepth?: number;
26
+ };
24
27
  readonly documentStyles?: readonly ExplorerDocumentStyle[];
25
28
  readonly iframeHosts?: readonly string[];
26
29
  readonly embeds?: {
27
30
  readonly providers?: readonly EmbedProviderId[];
28
- readonly linkCardEndpoint?: string | null;
31
+ readonly linkCards?: boolean;
32
+ readonly linkCardSize?: LinkCardSize;
29
33
  };
30
34
  readonly defaultTreeSettings?: Partial<TreeSettings>;
31
35
  };
@@ -42,6 +46,9 @@ export type ExplorerConfig = {
42
46
  readonly maxFolders: number;
43
47
  readonly maxDepth: number;
44
48
  };
49
+ readonly revealDocument: {
50
+ readonly maxDepth: number;
51
+ };
45
52
  readonly documentStyles: readonly ExplorerDocumentStyle[];
46
53
  readonly iframeHosts: readonly string[];
47
54
  readonly embeds: MarkdownEmbeds;
@@ -68,7 +75,13 @@ export declare const EXPAND_ALL_DEPTH_LIMITS: Readonly<{
68
75
  min: 1;
69
76
  max: 64;
70
77
  }>;
78
+ export declare const REVEAL_DOCUMENT_DEPTH_LIMITS: Readonly<{
79
+ default: 16;
80
+ min: 1;
81
+ max: 64;
82
+ }>;
71
83
  export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
84
+ export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
72
85
  export declare const isExplorerSourceId: (value: unknown) => value is string;
73
86
  export type ExplorerLocationConfig = ExplorerConfig & {
74
87
  readonly sourceIds: readonly string[];
@@ -1,4 +1,4 @@
1
- import { EmbedProviderId, MarkdownEmbeds } from "@aiquants/markdown/embeds";
1
+ import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
2
2
  import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
3
3
  import { TreeSettings } from "./treeSettings.js";
4
4
  export type ExplorerViewSlugs = {
@@ -21,11 +21,15 @@ export type ExplorerConfigInput = {
21
21
  readonly maxFolders?: number;
22
22
  readonly maxDepth?: number;
23
23
  };
24
+ readonly revealDocument?: {
25
+ readonly maxDepth?: number;
26
+ };
24
27
  readonly documentStyles?: readonly ExplorerDocumentStyle[];
25
28
  readonly iframeHosts?: readonly string[];
26
29
  readonly embeds?: {
27
30
  readonly providers?: readonly EmbedProviderId[];
28
- readonly linkCardEndpoint?: string | null;
31
+ readonly linkCards?: boolean;
32
+ readonly linkCardSize?: LinkCardSize;
29
33
  };
30
34
  readonly defaultTreeSettings?: Partial<TreeSettings>;
31
35
  };
@@ -42,6 +46,9 @@ export type ExplorerConfig = {
42
46
  readonly maxFolders: number;
43
47
  readonly maxDepth: number;
44
48
  };
49
+ readonly revealDocument: {
50
+ readonly maxDepth: number;
51
+ };
45
52
  readonly documentStyles: readonly ExplorerDocumentStyle[];
46
53
  readonly iframeHosts: readonly string[];
47
54
  readonly embeds: MarkdownEmbeds;
@@ -68,7 +75,13 @@ export declare const EXPAND_ALL_DEPTH_LIMITS: Readonly<{
68
75
  min: 1;
69
76
  max: 64;
70
77
  }>;
78
+ export declare const REVEAL_DOCUMENT_DEPTH_LIMITS: Readonly<{
79
+ default: 16;
80
+ min: 1;
81
+ max: 64;
82
+ }>;
71
83
  export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
84
+ export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
72
85
  export declare const isExplorerSourceId: (value: unknown) => value is string;
73
86
  export type ExplorerLocationConfig = ExplorerConfig & {
74
87
  readonly sourceIds: readonly string[];
@@ -74,6 +74,13 @@ export type ExplorerChildrenResult = {
74
74
  readonly status: "error";
75
75
  readonly failure: ExplorerFailure;
76
76
  };
77
+ export type ExplorerAncestorsResult = {
78
+ readonly status: "ok";
79
+ readonly ancestors: readonly string[] | null;
80
+ } | {
81
+ readonly status: "error";
82
+ readonly failure: ExplorerFailure;
83
+ };
77
84
  export type ExplorerHeading = {
78
85
  readonly text: string;
79
86
  readonly depth: number;
@@ -132,6 +139,7 @@ export declare const isAcceptableUrl: (url: unknown, protocols: readonly string[
132
139
  export declare const failureViolation: (value: unknown) => string | null;
133
140
  export declare const entryViolation: (value: unknown) => string | null;
134
141
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
+ export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
135
143
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
136
144
  export declare const headingViolation: (value: unknown) => string | null;
137
145
  export declare const documentViolation: (value: unknown) => string | null;
@@ -74,6 +74,13 @@ export type ExplorerChildrenResult = {
74
74
  readonly status: "error";
75
75
  readonly failure: ExplorerFailure;
76
76
  };
77
+ export type ExplorerAncestorsResult = {
78
+ readonly status: "ok";
79
+ readonly ancestors: readonly string[] | null;
80
+ } | {
81
+ readonly status: "error";
82
+ readonly failure: ExplorerFailure;
83
+ };
77
84
  export type ExplorerHeading = {
78
85
  readonly text: string;
79
86
  readonly depth: number;
@@ -132,6 +139,7 @@ export declare const isAcceptableUrl: (url: unknown, protocols: readonly string[
132
139
  export declare const failureViolation: (value: unknown) => string | null;
133
140
  export declare const entryViolation: (value: unknown) => string | null;
134
141
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
+ export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
135
143
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
136
144
  export declare const headingViolation: (value: unknown) => string | null;
137
145
  export declare const documentViolation: (value: unknown) => string | null;
@@ -51,7 +51,10 @@ export type MarkdownExplorerLabels = {
51
51
  readonly sortNative: string;
52
52
  readonly sortAscending: string;
53
53
  readonly sortDescending: string;
54
- readonly settingDirectoriesFirst: string;
54
+ readonly settingFolderPlacement: string;
55
+ readonly folderPlacementMixed: string;
56
+ readonly folderPlacementFirst: string;
57
+ readonly folderPlacementLast: string;
55
58
  readonly settingSelectionMode: string;
56
59
  readonly selectionSingle: string;
57
60
  readonly selectionMultiple: string;
@@ -62,6 +65,7 @@ export type MarkdownExplorerLabels = {
62
65
  readonly settingExpandIconSize: string;
63
66
  readonly expandIconSizeValue: (pixels: number) => string;
64
67
  readonly settingAlwaysExpanded: string;
68
+ readonly settingRevealDocument: string;
65
69
  readonly settingRemoveRootIndent: string;
66
70
  readonly settingTreeLines: string;
67
71
  readonly settingExpandIcons: string;
@@ -51,7 +51,10 @@ export type MarkdownExplorerLabels = {
51
51
  readonly sortNative: string;
52
52
  readonly sortAscending: string;
53
53
  readonly sortDescending: string;
54
- readonly settingDirectoriesFirst: string;
54
+ readonly settingFolderPlacement: string;
55
+ readonly folderPlacementMixed: string;
56
+ readonly folderPlacementFirst: string;
57
+ readonly folderPlacementLast: string;
55
58
  readonly settingSelectionMode: string;
56
59
  readonly selectionSingle: string;
57
60
  readonly selectionMultiple: string;
@@ -62,6 +65,7 @@ export type MarkdownExplorerLabels = {
62
65
  readonly settingExpandIconSize: string;
63
66
  readonly expandIconSizeValue: (pixels: number) => string;
64
67
  readonly settingAlwaysExpanded: string;
68
+ readonly settingRevealDocument: string;
65
69
  readonly settingRemoveRootIndent: string;
66
70
  readonly settingTreeLines: string;
67
71
  readonly settingExpandIcons: string;
@@ -1,14 +1,16 @@
1
1
  import { MarkdownExplorerLabels } from "./labels.cjs";
2
2
  export type TreeSortMode = "native" | "asc" | "desc";
3
+ export type TreeFolderPlacement = "mixed" | "first" | "last";
3
4
  export type TreeDoubleClickAction = "recursive" | "toggle";
4
5
  export type TreeSelectionMode = "single" | "multiple" | "none";
5
6
  export type TreeSettings = {
6
7
  readonly sortMode: TreeSortMode;
7
- readonly directoriesFirst: boolean;
8
+ readonly folderPlacement: TreeFolderPlacement;
8
9
  readonly selectionMode: TreeSelectionMode;
9
10
  readonly doubleClickAction: TreeDoubleClickAction;
10
11
  readonly expandIconSize: number;
11
12
  readonly alwaysExpanded: boolean;
13
+ readonly revealDocument: boolean;
12
14
  readonly removeRootIndent: boolean;
13
15
  readonly lines: boolean;
14
16
  readonly expandIcons: boolean;
@@ -44,5 +46,5 @@ export type SortableEntry = {
44
46
  readonly type: "file" | "directory";
45
47
  };
46
48
  export type EntryComparator = (left: SortableEntry, right: SortableEntry) => number;
47
- export declare const createEntryComparator: (settings: Pick<TreeSettings, "sortMode" | "directoriesFirst">) => EntryComparator | undefined;
49
+ export declare const createEntryComparator: (settings: Pick<TreeSettings, "sortMode" | "folderPlacement">) => EntryComparator | undefined;
48
50
  export {};
@@ -1,14 +1,16 @@
1
1
  import { MarkdownExplorerLabels } from "./labels.js";
2
2
  export type TreeSortMode = "native" | "asc" | "desc";
3
+ export type TreeFolderPlacement = "mixed" | "first" | "last";
3
4
  export type TreeDoubleClickAction = "recursive" | "toggle";
4
5
  export type TreeSelectionMode = "single" | "multiple" | "none";
5
6
  export type TreeSettings = {
6
7
  readonly sortMode: TreeSortMode;
7
- readonly directoriesFirst: boolean;
8
+ readonly folderPlacement: TreeFolderPlacement;
8
9
  readonly selectionMode: TreeSelectionMode;
9
10
  readonly doubleClickAction: TreeDoubleClickAction;
10
11
  readonly expandIconSize: number;
11
12
  readonly alwaysExpanded: boolean;
13
+ readonly revealDocument: boolean;
12
14
  readonly removeRootIndent: boolean;
13
15
  readonly lines: boolean;
14
16
  readonly expandIcons: boolean;
@@ -44,5 +46,5 @@ export type SortableEntry = {
44
46
  readonly type: "file" | "directory";
45
47
  };
46
48
  export type EntryComparator = (left: SortableEntry, right: SortableEntry) => number;
47
- export declare const createEntryComparator: (settings: Pick<TreeSettings, "sortMode" | "directoriesFirst">) => EntryComparator | undefined;
49
+ export declare const createEntryComparator: (settings: Pick<TreeSettings, "sortMode" | "folderPlacement">) => EntryComparator | undefined;
48
50
  export {};
@@ -0,0 +1 @@
1
+ "use strict";const y=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),D=/[\u0000-\u001f\u007f]/u,x=/\p{Cs}/u,N=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},d=e=>e.length>0&&e.length<=4096&&!x.test(e)&&!D.test(e)&&!e.includes("\\"),A=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),C=/(?:%[0-9A-Fa-f]{2})+/gu,U=new TextDecoder("utf-8"),H=/[/\\]/u,k=e=>e.replace(C,t=>U.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),X=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=k(n);if(o===n)break;t.push(o),n=o}return t.map(A)},j=e=>{if(typeof e!="string"||e.trim()===""||e.includes("/")||e.includes("\\"))throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);const t=A(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},f=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(j),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&X(o).some(s=>n(s)||s.split(H).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},w=f(y),I=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),$=e=>e===void 0?w:e===!1?I:f(e),v=(e,t)=>f(e).deniesPath(t),p=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),z=Object.freeze(["file","directory"]),F=Object.freeze(["video","audio","pdf"]),M=Object.freeze(["info","warning","danger"]),V=Object.freeze(["markdown","text","image","media","file","failure"]),m=Object.freeze({min:1,max:6}),G=1e4,l=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),Y=Object.freeze(["http:","https:","mailto:"]),K=/^[a-z0-9-]{1,64}$/u,J="https://relative.invalid/",_=64,c=(e,t)=>typeof t=="string"&&e.includes(t),a=e=>typeof e=="string"?JSON.stringify(e.length>_?`${e.slice(0,_)}…`:e):typeof e,O=e=>c(p,e),Q=e=>c(z,e),g=e=>c(F,e),B=e=>c(M,e),W=e=>c(V,e),R=e=>typeof e=="string"&&K.test(e),q=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,J).protocol)}catch{return!1}},u=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return O(t)?n!==void 0&&!R(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}`:null:`unknown failure reason ${a(t)}`},T=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,children:s,lazy:i}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!d(n)?"an entry needs an acceptable path":Q(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&typeof i!="boolean"?"an entry lazy flag must be a boolean":s!==void 0&&!Array.isArray(s)?"entry children must be an array":r==="file"&&(s!==void 0||i===!0)?"a file entry cannot have children or be lazy":i===!0&&Array.isArray(s)&&s.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${a(r)}`},h=e=>{if(T(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(h)},L=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:n,failure:r}=e;return t==="ok"?Array.isArray(n)&&n.every(h):t==="error"&&u(r)===null},Z=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||Array.isArray(n)&&n.every(o=>typeof o=="string"&&d(o))&&new Set(n).size===n.length:t==="error"&&u(r)===null},ee=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:L(e)},te=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:n,id:r}=e;return typeof t!="string"||typeof r!="string"?"a heading needs text and id strings":typeof n!="number"||!Number.isInteger(n)||n<m.min||n>m.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},P=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!W(n))return`unknown document kind ${a(n)}`;if(n==="failure")return u(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const i=te(s);if(i!==null)return i}return null}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":l(t.url)?null:"a text document needs a root-relative url";case"image":return l(t.url)?null:"an image document needs a root-relative url";case"media":return l(t.url)?g(t.mediaType)?null:`unknown media type ${a(t.mediaType)}`:"a media document needs a root-relative url";case"file":return l(t.url)?null:"a file document needs a root-relative url"}},ne=e=>P(e)===null,re=(e,t)=>({kind:"failure",failure:b(e,t)}),b=(e,t)=>R(t)?{reason:e,code:t}:{reason:e},oe=Object.freeze(["tree","children","ancestors","document","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v"}),se="asset",ie="link-card",ae=(e,t,n)=>{const r=`${e}/${se}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},ce=e=>`${e}/${ie}`,le="X-Markdown-Explorer-Scope",ue="X-Markdown-Explorer",Ee="refresh",de=e=>oe.includes(e),S=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),fe=e=>{const[t,...n]=p.filter(r=>S[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=y;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_FAILURE_REASONS=p;exports.EXPLORER_FAILURE_STATUS=S;exports.EXPLORER_LINK_PROTOCOLS=Y;exports.EXPLORER_MAX_HEADINGS=G;exports.EXPLORER_REFRESH_HEADER=ue;exports.EXPLORER_REFRESH_HEADER_VALUE=Ee;exports.EXPLORER_SCOPE_HEADER=le;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=P;exports.entryViolation=T;exports.explorerAssetHref=ae;exports.explorerLinkCardEndpoint=ce;exports.failureDocument=re;exports.failureOf=b;exports.failureReasonOfStatus=fe;exports.failureViolation=u;exports.isAcceptableDocumentPath=d;exports.isAcceptableUrl=q;exports.isDeniedPath=v;exports.isExplorerAncestorsResult=Z;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=de;exports.isExplorerDocument=ne;exports.isExplorerFailureCode=R;exports.isExplorerFailureReason=O;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=B;exports.isExplorerTreeResult=ee;exports.lastPathSegment=N;exports.resolvePathRules=$;
@@ -1,5 +1,5 @@
1
1
  const q = 4096;
2
- const _ = Object.freeze([
2
+ const A = Object.freeze([
3
3
  ".env*",
4
4
  "*.env",
5
5
  "*.env.*",
@@ -57,10 +57,10 @@ const _ = Object.freeze([
57
57
  "*.tfvars.json",
58
58
  ".*_history",
59
59
  "fish_history"
60
- ]), h = /[\u0000-\u001f\u007f]/u, O = /\p{Cs}/u, B = (e) => {
60
+ ]), O = /[\u0000-\u001f\u007f]/u, h = /\p{Cs}/u, Q = (e) => {
61
61
  const t = e.split("/").filter((n) => n !== "").at(-1);
62
62
  return t === void 0 ? e : t;
63
- }, A = (e) => e.length > 0 && e.length <= 4096 && !O.test(e) && !h.test(e) && !e.includes("\\"), p = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), b = /(?:%[0-9A-Fa-f]{2})+/gu, T = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
63
+ }, m = (e) => e.length > 0 && e.length <= 4096 && !h.test(e) && !O.test(e) && !e.includes("\\"), y = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), b = /(?:%[0-9A-Fa-f]{2})+/gu, T = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
64
64
  b,
65
65
  (t) => T.decode(
66
66
  Uint8Array.from(
@@ -75,11 +75,11 @@ const _ = Object.freeze([
75
75
  if (s === n) break;
76
76
  t.push(s), n = s;
77
77
  }
78
- return t.map(p);
78
+ return t.map(y);
79
79
  }, x = (e) => {
80
80
  if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
81
  throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
- const t = p(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
82
+ const t = y(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
83
  return new RegExp(`^${t}$`, "su");
84
84
  }, u = (e) => {
85
85
  if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
@@ -88,42 +88,46 @@ const _ = Object.freeze([
88
88
  deniesPath: (s) => s.split("/").some(r),
89
89
  deniesName: r
90
90
  };
91
- }, D = u(_), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Q = (e) => e === void 0 ? D : e === !1 ? N : u(e), W = (e, t) => u(e).deniesPath(t), m = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), k = Object.freeze(["video", "audio", "pdf"]), C = Object.freeze(["info", "warning", "danger"]), w = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), d = Object.freeze({ min: 1, max: 6 }), Z = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ee = Object.freeze(["http:", "https:", "mailto:"]), U = /^[a-z0-9-]{1,64}$/u, v = "https://relative.invalid/", f = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > f ? `${e.slice(0, f)}…` : e) : typeof e, z = (e) => c(m, e), $ = (e) => c(j, e), H = (e) => c(k, e), te = (e) => c(C, e), X = (e) => c(w, e), y = (e) => typeof e == "string" && U.test(e), ne = (e, t) => {
91
+ }, D = u(A), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), W = (e) => e === void 0 ? D : e === !1 ? N : u(e), Z = (e, t) => u(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), k = Object.freeze(["video", "audio", "pdf"]), C = Object.freeze(["info", "warning", "danger"]), w = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), f = Object.freeze({ min: 1, max: 6 }), ee = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), te = Object.freeze(["http:", "https:", "mailto:"]), U = /^[a-z0-9-]{1,64}$/u, $ = "https://relative.invalid/", E = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > E ? `${e.slice(0, E)}…` : e) : typeof e, z = (e) => c(R, e), v = (e) => c(j, e), I = (e) => c(k, e), ne = (e) => c(C, e), H = (e) => c(w, e), g = (e) => typeof e == "string" && U.test(e), re = (e, t) => {
92
92
  if (typeof e != "string") return !1;
93
93
  try {
94
- return t.includes(new URL(e, v).protocol);
94
+ return t.includes(new URL(e, $).protocol);
95
95
  } catch {
96
96
  return !1;
97
97
  }
98
- }, R = (e) => {
98
+ }, d = (e) => {
99
99
  if (e === null || typeof e != "object") return "a failure must be an object";
100
100
  const { reason: t, code: n } = e;
101
- return z(t) ? n !== void 0 && !y(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
- }, I = (e) => {
101
+ return z(t) ? n !== void 0 && !g(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
+ }, X = (e) => {
103
103
  if (e === null || typeof e != "object") return "an entry must be an object";
104
104
  const { name: t, path: n, type: r, mimeType: s, children: o, lazy: i } = e;
105
- return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !A(n) ? "an entry needs an acceptable path" : $(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
106
- }, g = (e) => {
107
- if (I(e) !== null) return !1;
105
+ return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !m(n) ? "an entry needs an acceptable path" : v(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
106
+ }, _ = (e) => {
107
+ if (X(e) !== null) return !1;
108
108
  const { children: t } = e;
109
- return t === void 0 || t.every(g);
109
+ return t === void 0 || t.every(_);
110
110
  }, F = (e) => {
111
111
  if (e === null || typeof e != "object") return !1;
112
112
  const { status: t, entries: n, failure: r } = e;
113
- return t === "ok" ? Array.isArray(n) && n.every(g) : t === "error" && R(r) === null;
114
- }, re = (e) => {
113
+ return t === "ok" ? Array.isArray(n) && n.every(_) : t === "error" && d(r) === null;
114
+ }, se = (e) => {
115
+ if (e === null || typeof e != "object") return !1;
116
+ const { status: t, ancestors: n, failure: r } = e;
117
+ return t === "ok" ? n === null || Array.isArray(n) && n.every((s) => typeof s == "string" && m(s)) && new Set(n).size === n.length : t === "error" && d(r) === null;
118
+ }, oe = (e) => {
115
119
  if (e === null || typeof e != "object") return !1;
116
120
  const { status: t, loadedAt: n } = e;
117
121
  return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : F(e);
118
122
  }, M = (e) => {
119
123
  if (e === null || typeof e != "object") return "a heading must be an object";
120
124
  const { text: t, depth: n, id: r } = e;
121
- return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < d.min || n > d.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
125
+ return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < f.min || n > f.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
122
126
  }, V = (e) => {
123
127
  if (e === null || typeof e != "object") return "a document must be an object";
124
128
  const t = e, { kind: n } = t;
125
- if (!X(n)) return `unknown document kind ${a(n)}`;
126
- if (n === "failure") return R(t.failure);
129
+ if (!H(n)) return `unknown document kind ${a(n)}`;
130
+ if (n === "failure") return d(t.failure);
127
131
  if (typeof t.name != "string") return "a document needs a name string";
128
132
  switch (n) {
129
133
  case "markdown": {
@@ -140,14 +144,14 @@ const _ = Object.freeze([
140
144
  case "image":
141
145
  return l(t.url) ? null : "an image document needs a root-relative url";
142
146
  case "media":
143
- return l(t.url) ? H(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
147
+ return l(t.url) ? I(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
144
148
  case "file":
145
149
  return l(t.url) ? null : "a file document needs a root-relative url";
146
150
  }
147
- }, se = (e) => V(e) === null, oe = (e, t) => ({ kind: "failure", failure: G(e, t) }), G = (e, t) => y(t) ? { reason: e, code: t } : { reason: e }, Y = Object.freeze(["tree", "children", "document", "refresh", "asset"]), E = Object.freeze({ source: "source", path: "path", version: "v" }), K = "asset", ie = (e, t, n) => {
148
- const r = `${e}/${K}?${E.path}=${encodeURIComponent(t)}`;
149
- return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
150
- }, ae = "X-Markdown-Explorer-Scope", ce = "X-Markdown-Explorer", le = "refresh", ue = (e) => Y.includes(e), J = Object.freeze({
151
+ }, ie = (e) => V(e) === null, ae = (e, t) => ({ kind: "failure", failure: G(e, t) }), G = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, Y = Object.freeze(["tree", "children", "ancestors", "document", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), K = "asset", B = "link-card", ce = (e, t, n) => {
152
+ const r = `${e}/${K}?${p.path}=${encodeURIComponent(t)}`;
153
+ return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
154
+ }, le = (e) => `${e}/${B}`, ue = "X-Markdown-Explorer-Scope", de = "X-Markdown-Explorer", fe = "refresh", Ee = (e) => Y.includes(e), J = Object.freeze({
151
155
  invalid: 400,
152
156
  unauthorized: 401,
153
157
  forbidden: 403,
@@ -156,39 +160,41 @@ const _ = Object.freeze([
156
160
  "not-configured": 500,
157
161
  unsupported: 500,
158
162
  failed: 500
159
- }), de = (e) => {
160
- const [t, ...n] = m.filter((r) => J[r] === e);
163
+ }), pe = (e) => {
164
+ const [t, ...n] = R.filter((r) => J[r] === e);
161
165
  return t !== void 0 && n.length === 0 ? t : "failed";
162
166
  };
163
167
  export {
164
- m as A,
165
- _ as D,
166
- Z as E,
168
+ oe as A,
169
+ ie as B,
170
+ R as C,
171
+ A as D,
172
+ ee as E,
167
173
  q as M,
168
- z as a,
169
- y as b,
170
- te as c,
174
+ le as a,
175
+ z as b,
176
+ g as c,
171
177
  ne as d,
172
- ie as e,
178
+ ce as e,
173
179
  G as f,
174
- H as g,
175
- V as h,
176
- A as i,
177
- I as j,
178
- ee as k,
179
- ue as l,
180
- J as m,
181
- ce as n,
182
- le as o,
183
- ae as p,
184
- E as q,
185
- Q as r,
186
- oe as s,
187
- W as t,
188
- B as u,
189
- de as v,
190
- F as w,
191
- R as x,
192
- re as y,
193
- se as z
180
+ re as g,
181
+ I as h,
182
+ m as i,
183
+ V as j,
184
+ X as k,
185
+ te as l,
186
+ Ee as m,
187
+ J as n,
188
+ de as o,
189
+ fe as p,
190
+ ue as q,
191
+ W as r,
192
+ p as s,
193
+ ae as t,
194
+ Z as u,
195
+ Q as v,
196
+ pe as w,
197
+ se as x,
198
+ F as y,
199
+ d as z
194
200
  };