@fungi.computer/prints 0.20.20 → 0.20.22

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 (45) hide show
  1. package/dist/assets/arrow-right-OARGllYn.js +1 -0
  2. package/dist/assets/data-list-BKnOm38M.js +1 -0
  3. package/dist/assets/dialog-BZ61MAZB.js +1 -0
  4. package/dist/assets/{images-CQ3EhUoY.js → images-DQ4iT8XG.js} +1 -1
  5. package/dist/assets/index-BNKONPP9.js +85 -0
  6. package/dist/assets/library-dialogs-CMyC51Mx.js +2 -0
  7. package/dist/assets/library-folders-dialog-BbcwRIZr.js +1 -0
  8. package/dist/assets/{library-rail-DPiYJWxN.js → library-rail-CwaMUE8m.js} +2 -2
  9. package/dist/assets/{print-download-button-ebYCmtQ8.js → print-download-button-Cb8rlgOl.js} +5 -5
  10. package/dist/assets/print-info-drawer-C3j6eKaQ.js +2 -0
  11. package/dist/assets/print-viewer-Cu6ATcQJ.js +2 -0
  12. package/dist/assets/prints-activity-tray-CuwXtIBN.js +1 -0
  13. package/dist/assets/prints-folder-dialog-CY6IWH42.js +1 -0
  14. package/dist/assets/prompt-character-controls-CPUNyX8u.js +1 -0
  15. package/dist/assets/prompt-styles-dialog-Bn9o2wRf.js +1 -0
  16. package/dist/assets/reference-lightbox-scBjj8tk.js +1 -0
  17. package/dist/assets/rotate-ccw-DH8lePtF.js +1 -0
  18. package/dist/assets/upload-queue-hWBGHaYu.js +1 -0
  19. package/dist/index.html +1 -22
  20. package/package.json +3 -3
  21. package/dist/assets/audio-waveform-DcMy9xl2.js +0 -1
  22. package/dist/assets/audio-waveform-view-Bt66rIpF.js +0 -1
  23. package/dist/assets/button-oE2Hrd5D.js +0 -83
  24. package/dist/assets/computer-Drn9XugY.js +0 -1
  25. package/dist/assets/dialog-BXLOuKaF.js +0 -1
  26. package/dist/assets/dist-ujdia29J.js +0 -1
  27. package/dist/assets/dropdown-menu-Dz4r7a9R.js +0 -1
  28. package/dist/assets/ellipsis-DlNHenkt.js +0 -1
  29. package/dist/assets/generation-quote-BstUB0PG.js +0 -2
  30. package/dist/assets/heart-BquDo4lf.js +0 -1
  31. package/dist/assets/index-DSTUqbdP.js +0 -2
  32. package/dist/assets/keycap-D2RkH2IS.js +0 -1
  33. package/dist/assets/library-view-C71Cv37D.js +0 -1
  34. package/dist/assets/log-event-IU820pK9.js +0 -1
  35. package/dist/assets/modules-C4mfDnjH.js +0 -1
  36. package/dist/assets/print-info-drawer-LxcR4Myk.js +0 -2
  37. package/dist/assets/print-viewer-B1_RBET9.js +0 -2
  38. package/dist/assets/prints-folder-dialog-DCmQaMUu.js +0 -1
  39. package/dist/assets/query-DKNLqHPu.js +0 -1
  40. package/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
  41. package/dist/assets/status-DNJRO5m5.js +0 -1
  42. package/dist/assets/textarea-DUwcxEMN.js +0 -1
  43. package/dist/assets/upload-queue-BHNUzgYV.js +0 -1
  44. package/dist/assets/useMutation-DAlc59rA.js +0 -1
  45. package/dist/assets/useTriggerFocusGuards-Bddw7Qdn.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,t as r,x as i}from"./button-oE2Hrd5D.js";import{Pt as a,jt as o,n as s}from"./dist-ujdia29J.js";import{a as c,c as l,d as u}from"./library-view-C71Cv37D.js";import{i as d,t as f}from"./query-DKNLqHPu.js";import{t as p}from"./computer-Drn9XugY.js";import{n as m,t as h}from"./heart-BquDo4lf.js";import{t as g}from"./images-CQ3EhUoY.js";var _=i(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),v=i(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),y=`file-tree-container`,b=`data-file-tree-style`,x=`data-file-tree-unsafe-css`,S=`data-file-tree-scrollbar-measure`,C=`data-file-tree-scrollbar-gutter-measured`,ee=`--trees-scrollbar-gutter-measured`,w=`header`,T=`context-menu`,te=`context-menu-trigger`,E=e(n(),1),D=t(),O=typeof window>`u`?E.useEffect:E.useLayoutEffect;function ne(e,t,n){let r=e==null?null:(0,D.jsx)(`div`,{slot:w,children:e}),i=t!=null&&n!=null?(0,D.jsx)(`div`,{slot:T,children:t(n.item,n.context)}):null;return r==null&&i==null?null:(0,D.jsxs)(D.Fragment,{children:[r,i]})}function k(e,t){return typeof window>`u`&&t!=null?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t.shadowHtml}}),e]}):(0,D.jsx)(D.Fragment,{children:e})}function re(e){let t=e.shadowRoot;return t?.querySelector(`[data-file-tree-id]`)instanceof HTMLElement||t?.querySelector(`[data-file-tree-id]`)instanceof SVGElement||e.querySelector(`template[shadowrootmode="open"]`)instanceof HTMLTemplateElement}function A(e,t,n,r,i){let a={...e??{}};if(t!=null&&delete a.header,n){let t=e?.contextMenu,n=t?.onClose,o=t?.onOpen;a.contextMenu={...t??{},enabled:!0,onClose:()=>{n?.(),r()},onOpen:(e,t)=>{i(e,t),o?.(e,t)}},delete a.contextMenu.render}return a.header!=null||a.contextMenu!=null?a:void 0}function j({header:e,id:t,model:n,preloadedData:r,renderContextMenu:i,...a}){let[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null),u=(0,E.useRef)(n.getComposition()),d=(0,E.useRef)(n);d.current!==n&&(d.current=n,u.current=n.getComposition());let f=i!=null,p=(0,E.useCallback)(()=>{s(null)},[]),m=(0,E.useCallback)((e,t)=>{s({context:t,item:e})},[]),h=u.current,g=(0,E.useMemo)(()=>A(h,e,f,p,m),[h,p,m,f,e]),_=(0,E.useCallback)(e=>{l(e)},[]);(0,E.useEffect)(()=>{f||s(null)},[f]),O(()=>{n.setComposition(g)},[g,n]),O(()=>{if(c!=null)return r!=null&&re(c)?n.hydrate({fileTreeContainer:c}):n.render({fileTreeContainer:c}),()=>{n.unmount(),n.setComposition(h)}},[h,c,n,r]);let v=k(ne(e,i,o),r),b=t??r?.id,x={"--trees-item-height":`${String(n.getItemHeight())}px`,"--trees-density-override":n.getDensityFactor(),...a.style};return(0,D.jsx)(y,{...a,id:b,ref:_,style:x,suppressHydrationWarning:r!=null,children:v})}var ie=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
1
+ import{t as e}from"./images-DQ4iT8XG.js";import{An as t,Cr as n,Dr as r,Tr as i,_r as a,ar as o,fr as s,ji as c,ki as l,mr as u,pr as d,rr as f,sn as p,vr as m,wr as h,yr as g}from"./index-BNKONPP9.js";var _=s(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),v=s(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),y=`file-tree-container`,b=`data-file-tree-style`,x=`data-file-tree-unsafe-css`,S=`data-file-tree-scrollbar-measure`,C=`data-file-tree-scrollbar-gutter-measured`,ee=`--trees-scrollbar-gutter-measured`,w=`header`,T=`context-menu`,te=`context-menu-trigger`,E=c(l(),1),D=i(),O=typeof window>`u`?E.useEffect:E.useLayoutEffect;function ne(e,t,n){let r=e==null?null:(0,D.jsx)(`div`,{slot:w,children:e}),i=t!=null&&n!=null?(0,D.jsx)(`div`,{slot:T,children:t(n.item,n.context)}):null;return r==null&&i==null?null:(0,D.jsxs)(D.Fragment,{children:[r,i]})}function k(e,t){return typeof window>`u`&&t!=null?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t.shadowHtml}}),e]}):(0,D.jsx)(D.Fragment,{children:e})}function re(e){let t=e.shadowRoot;return t?.querySelector(`[data-file-tree-id]`)instanceof HTMLElement||t?.querySelector(`[data-file-tree-id]`)instanceof SVGElement||e.querySelector(`template[shadowrootmode="open"]`)instanceof HTMLTemplateElement}function A(e,t,n,r,i){let a={...e??{}};if(t!=null&&delete a.header,n){let t=e?.contextMenu,n=t?.onClose,o=t?.onOpen;a.contextMenu={...t??{},enabled:!0,onClose:()=>{n?.(),r()},onOpen:(e,t)=>{i(e,t),o?.(e,t)}},delete a.contextMenu.render}return a.header!=null||a.contextMenu!=null?a:void 0}function j({header:e,id:t,model:n,preloadedData:r,renderContextMenu:i,...a}){let[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null),u=(0,E.useRef)(n.getComposition()),d=(0,E.useRef)(n);d.current!==n&&(d.current=n,u.current=n.getComposition());let f=i!=null,p=(0,E.useCallback)(()=>{s(null)},[]),m=(0,E.useCallback)((e,t)=>{s({context:t,item:e})},[]),h=u.current,g=(0,E.useMemo)(()=>A(h,e,f,p,m),[h,p,m,f,e]),_=(0,E.useCallback)(e=>{l(e)},[]);(0,E.useEffect)(()=>{f||s(null)},[f]),O(()=>{n.setComposition(g)},[g,n]),O(()=>{if(c!=null)return r!=null&&re(c)?n.hydrate({fileTreeContainer:c}):n.render({fileTreeContainer:c}),()=>{n.unmount(),n.setComposition(h)}},[h,c,n,r]);let v=k(ne(e,i,o),r),b=t??r?.id,x={"--trees-item-height":`${String(n.getItemHeight())}px`,"--trees-density-override":n.getDensityFactor(),...a.style};return(0,D.jsx)(y,{...a,id:b,ref:_,style:x,suppressHydrationWarning:r!=null,children:v})}var ie=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
2
2
  <symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
3
3
  <path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
4
4
  </symbol>
@@ -1263,4 +1263,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,t as r,
1263
1263
  }`}function xt(e){return`${yt}
1264
1264
  @layer unsafe {
1265
1265
  ${e}
1266
- }`}var St=new WeakMap;function Ct(e){let t=St.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(S,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),St.set(e,i),i}function I(e,t){if(!e.isConnected)return;let n=Ct(t);if(n==null)return;let r=t.querySelector(`style[${C}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(C,``),t.appendChild(i)),i.textContent=`:host { ${ee}: ${n}px; }`}var wt;function L(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){wt??(wt=new CSSStyleSheet,wt.replaceSync(bt(vt)));let t=!1;try{e.adoptedStyleSheets=[wt],t=!0}catch{}if(t){e.querySelector(`style[${b}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(b,``),t.textContent=bt(vt),e.prepend(t)}}function Tt(e,t){Et(e,t),L(t),I(e,t)}function Et(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Tt(this,e)}}if(customElements.define(y,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(y)))e instanceof HTMLElement&&Tt(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Dt=5,Ot=32,kt=128;function At(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function jt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Mt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Nt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Pt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Ft(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function It(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,zt(e,t)}function Lt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Nt(e).get(t);if(i===void 0)return;let a=i>>Dt;e.childVisibleChunkSums[a]+=r}function R(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Bt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=Ot}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function Rt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Dt;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Dt}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function zt(e,t){if(t.childIds.length<kt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/Ot),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>Dt]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Bt(e,t,n,r){let i=Math.min(t.childIds.length,n+Ot),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Vt=7,Ht=3,Ut=8,Wt=4;function z(e,t,n=0){return e<<Wt|n<<Ht|t}function Gt(e){return e.depthAndFlags>>>Wt}function Kt(e){return(e.depthAndFlags&Ut)>>Ht}function B(e){return(e.depthAndFlags&Ut)!==0}function qt(e){return e.depthAndFlags&Vt}function V(e,t){return(qt(e)&t)!==0}function Jt(e,t){e.depthAndFlags|=t}function Yt(e,t){e.depthAndFlags=z(t,qt(e),Kt(e))}var Xt=Symbol(`benchmarkInstrumentation`);function Zt(e,t){return t==null||Object.defineProperty(e,Xt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Qt(e){return e==null?null:e[Xt]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function $t(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function en(e){return e>=48&&e<=57}function tn(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!en(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&en(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function nn(e){let t=e.toLowerCase();return{lowerValue:t,tokens:tn(t)}}function rn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function an(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=rn(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function on(e,t,n){let r=an(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function sn(e,t){return on(e,t,nn)}function cn(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function ln(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=cn(e,r);return a===cn(t,r)?sn(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function un(e,t){return ln(e,t)}function dn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=nn(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=cn(e,n);return o===cn(t,n)?on(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function fn(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=nn(r);return e.sortKeyById[t]=i,i}function pn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function mn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function hn(e){let{hasTrailingSlash:t,segments:n}=mn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function gn(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=mn(e);return{requiresDirectory:t,segments:n}}function _n(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[nn(``)]}}function vn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function U(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var yn=Symbol(`pathStorePreparedInputKind`);function bn(e,t){return e[yn]=t,e}function xn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function Sn(e,t,n){return n==="default"?un(e,t):n(xn(e),xn(t))}function Cn(){return{depthAndFlags:z(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function wn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function Tn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function En(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Dn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function On(e,t={}){return Pn(e,t).map(e=>e.path)}function kn(e,t={}){let n=Pn(e,t);return bn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function An(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return bn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function jn(e){let t=e,n=t.preparedPaths;if(t[yn]===`prepared`&&n!=null)return n;if(!En(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Mn(e){let t=e;return t[yn]===`presorted`&&t.presortedPaths!=null||Dn(t.presortedPaths)?t.presortedPaths:null}function Nn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Pn(e,t={}){let n=pn(t),r=Qt(t);$t(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>hn(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>Sn(e,t,n.sort))),i}var Fn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Cn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=_n();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Qt(e),this.options=pn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,At())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>hn(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,H(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return H(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null){if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:z(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:z(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d,m=a+1}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:z(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=hn(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null){if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:z(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:z(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=hn(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(H(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||H(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?dn(this.lastPreparedPath,e,this.segmentSortKeyCache):Sn(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=Tn(e),i=n==null?0:Tn(n),a=n==null?0:wn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=vn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Pt(i,s),s}createFileChildUnchecked(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),a}getOrCreateDirectoryChild(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!B(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),this.directories.set(a,At()),a}createDirectoryChild(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),this.directories.set(a,At()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(V(n,1))throw Error(`Duplicate path: "${t}"`);Jt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,jt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=jt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;B(n)&&this.directories.set(t,At());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Pt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return It(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function In(e,t=`closed`,n=null){let r=Rn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Ln(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Rn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function zn(e,t){return V(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&Gt(t)<=e.defaultExpansion}function Bn(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:zn(e,n)}function Vn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=zn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Hn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function Un(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Wn(e,t){let n=Hn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Gn(e,t){let n=Hn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Kn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function qn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Jn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Yn(e,t){e.directoryLoadInfoById.delete(t)}function Xn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function rr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function ir(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function ar(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function or(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function sr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function cr(e,t,n){return{...n,visibleCountDelta:yr(e)-t}}function lr(e,t){let n=yr(e),r=Ln();e.transactionStack.push(r);try{t()}catch(t){throw fr(e,r,!1),t}fr(e,r,!0,yr(e)-n)}function ur(e,t){let n=e.instrumentation;if(n==null){dr(e,t);return}H(n,`store.events.record`,()=>dr(e,t))}function dr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){_r(e,t);return}n.events.push(t),gr(n,t)}function fr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?hr(i,t):H(n,`store.events.batch.merge`,()=>hr(i,t));return}let a=pr(t,r),o=e.instrumentation;if(o==null){_r(e,a);return}H(o,`store.events.batch.commit`,()=>_r(e,a))}function pr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function mr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function hr(e,t){for(let n of t.events)e.events.push(n);mr(e,t)}function gr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function _r(e,t){let n=e.instrumentation;if(n==null){vr(e,t);return}H(n,`store.events.emit`,()=>vr(e,t))}function vr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function yr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function br(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||V(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!B(a)?null:i}function xr(e,t){let n=t;for(;;){let t=br(e,n);if(t==null)return n;n=t}}function Sr(e,t){let n=[t],r=t;for(;;){let t=br(e,r);if(t==null)return n;n.push(t),r=t}}function Cr(e,t){let n=t==null?e.snapshot.rootId:Mr(e,t);return n==null?[]:Pr(e,n)}function wr(e,t){let n=hn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Yr(e,Jr(e,r)),{createdNodeIds:a,directoryId:o}=Fr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(V(n,1))throw Error(`Path already exists: "${t}"`);Jt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Lr(e,o,n.basename),s.add(c);kr(e,o);let l=Yr(e,o);return Zn({affectedAncestorIds:jr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Xr(i,l)})}function Tr(e,t,n){let r=Mr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(V(i,2))throw Error(`The root node cannot be removed`);if(B(i)&&G(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Yr(e,a),s=Kr(e,r);Br(e,a,r,i.nameId),qr(e,a),kr(e,a);let c=Yr(e,a);return Qn({affectedAncestorIds:jr(e,a),affectedNodeIds:s,path:t,projectionChanged:Xr(o,c),recursive:n.recursive===!0})}function Er(e,t,n,r){let i=Mr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(V(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Wr(e,i,n),c=Yr(e,a.parentId),l=Yr(e,s.parentId),u=U(e.snapshot.segmentTable,a.nameId),d=vn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&ei(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Mt(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Gr(e,p,o,Kt(a))===`skip`)return null;let m=a.parentId;Br(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),$r(e,i),zr(e,s.parentId,i),qr(e,m),e.pathCacheVersion++,kr(e,m),s.parentId!==m&&kr(e,s.parentId);let h=Yr(e,m),g=Yr(e,s.parentId);return $n({affectedAncestorIds:[...new Set([...jr(e,m),...jr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Zr([c,l],[h,g]),to:W(e,i)})}function Dr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Or(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=Dr(e,t);if(r!=null)return r;if(V(n,2))return Or(e,t,``);let i=W(e,n.parentId),a=U(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Or(e,t,B(n)?`${o}/`:o)}function kr(e,t){let n=e.instrumentation;if(n==null){ni(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>ni(e,t))}function Ar(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!B(o)){ti(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){ti(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function jr(e,t){let n=[],r=t;for(;r!=null;){let t=K(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Mr(e,t){if(t.length===0)return e.snapshot.rootId;let n=gn(t);return Nr(e,n.segments,n.requiresDirectory)}function Nr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=G(e,r),a=Mt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!B(i)?null:r}function G(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function K(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Pr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))return[];if(!B(n))return[W(e,t)];if(G(e,t).childIds.length===0)return V(n,1)&&!V(n,2)?[W(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||V(n,4)){i.pop();continue}if(!B(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){V(n,1)&&!V(n,2)&&r.push(W(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function Fr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=vn(e.snapshot.segmentTable,i),a=G(e,r),o=Mt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Ir(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Ir(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:z(Gt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,At()),zr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Lr(e,t,n){let r=vn(e.snapshot.segmentTable,n),i=G(e,t);if(Mt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ii(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:z(Gt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),zr(e,t,o),e.activeNodeCount++,o}function Rr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Vr(e,n,o)<0?i=a:r=a+1}return r}function zr(e,t,n){let r=G(e,t),i=K(e,n);Mt(e.snapshot.nodes,r).set(i.nameId,n),Lt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Rr(e,r,n);r.childIds.splice(a,0,n),Ft(r,a),zt(e.snapshot.nodes,r)}function Br(e,t,n,r){let i=G(e,t),a=Nt(i),o=a.get(n)??-1;Mt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Lt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Ft(i,o),zt(e.snapshot.nodes,i))}function Vr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Hr(e,t,n):r(Ur(e,t),Ur(e,n))}function Hr(e,t,n){let r=K(e,t),i=K(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=an(fn(e.snapshot.segmentTable,r.nameId),fn(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=U(e.snapshot.segmentTable,r.nameId),c=U(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Ur(e,t){let n=K(e,t),r=W(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:U(e.snapshot.segmentTable,n.nameId),depth:Gt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Wr(e,t,n){let r=K(e,t),i=Mr(e,n);if(i!=null){let t=K(e,i);if(B(t))return{basename:U(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=gn(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=gn(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Nr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Gr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${W(e,t)}"`);let i=K(e,t);if(Kt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(i)&&G(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Kr(e,t),Br(e,a,t,o),qr(e,a),kr(e,a),`handled`}function Kr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=K(e,t.nodeId);if(t.visitedChildren||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Jt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Yn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=G(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function qr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!B(t)||V(t,2)||G(e,n).childIds.length>0)return;Jt(t,1),n=t.parentId===n?null:t.parentId}}function Jr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Mt(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!B(K(e,i)))break;n=i}return n}function Yr(e,t){let n=Qr(e,t);if(n==null)return null;let r=xr(e,n),i=K(e,r),a=n===r?null:Sr(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:Kt(i)})}function Xr(e,t){return Zr([e],[t])}function Zr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Qr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!B(t)||V(t,2))return null;if(!Bn(e,n,t))return n;n=t.parentId}return null}function $r(e,t){let n=K(e,t);if(Yt(n,(t===e.snapshot.rootId?-1:Gt(K(e,n.parentId)))+1),!B(n))return;let r=G(e,t);for(let t of r.childIds)$r(e,t)}function ei(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=K(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function ti(e,t,n=K(e,t),r=!1){let i=e.instrumentation;if(i==null){ri(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>ri(e,t,n,r))}function ni(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(ti(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Lt(G(e,s),n,a,o),n=s}}function ri(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?It(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>It(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,V(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=br(e,t)==null?Bn(e,t,n)?1+o:1:o}function ii(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function ai(e){return e!=null&&!V(e,4)}function oi(e,t){let n=e.snapshot.nodes[t];return!ai(n)||!B(n)||V(n,2)?null:n}function si(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ai(e.snapshot.nodes[n])&&(t+=1);return t}function ci(e){return Math.max(0,e.valueById.length-1)}function li(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:si(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ci(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function ui(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function di(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)oi(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)oi(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function fi(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)oi(e,n)!=null&&Un(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function pi(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Mr(e,n);t!=null&&Vn(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=Mr(e,n);t!=null&&Vn(e,t,!1,K(e,t))}}function mi(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Mr(e,n.path);t!=null&&oi(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function hi(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function gi(e){let t=e.snapshot.segmentTable,n=_n();for(let r of e.snapshot.nodes)if(ai(r)){if(V(r,2)){r.nameId=0;continue}r.nameId=vn(n,U(t,r.nameId))}e.snapshot.segmentTable=n}function _i(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ai(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ai(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[K(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),It(e.snapshot.nodes,n)}}function vi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ai(n))break;--t}e.snapshot.nodes.length=t+1}function yi(e){let t=di(e),n=fi(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>hi(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>gi(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>_i(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>vi(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>pi(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>mi(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Ar(e,e.snapshot.rootId))}function bi(e){let t=di(e),n=fi(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Cr(e)),i=Zt({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Fn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,H(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>pi(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>mi(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Ar(e,e.snapshot.rootId))}function xi(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Si(e,t){let n=li(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>yi(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>bi(e));let r=li(e);return ui(t,t===`stable`,n,r)}var Ci=64;function wi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function q(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function Ti(e,t,n,r){let i=K(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Ei(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Gi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Ti(e,t.cursor,t.index,n)}}function Di(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=R(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Oi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Oi(e,t,n,r,i,a,o,s){if(!B(K(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=zi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!B(l)||!Bn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Di(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function ki(e,t){let n=q(e);if(t<0||t>=n)return null;let r=Di(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>W(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Ei(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Gi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Ti(e,r.cursor,r.index,n)}}function Ai(e,t,n){let r=e.instrumentation,i=q(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Wi(e,o+1);let t=[],n=Ii(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Gi(e,n);t.push(r),n=Vi(e,n)}return t}let s=[],c=0,l=0,u=H(r,`store.getVisibleSlice.selectFirstRow`,()=>Ii(e,a));for(let t=a;t<=o&&u!=null;t++){let t=H(r,`store.getVisibleSlice.materializeRow`,()=>Gi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>Vi(e,u))}return $t(r,`workload.visibleRowsRead`,s.length),$t(r,`workload.flattenedRowsRead`,c),$t(r,`workload.flattenedSegmentsRead`,l),s}function ji(e,t=q(e)){let n=e.instrumentation;return n==null?Ui(e,t):H(n,`store.getVisibleTreeProjection`,()=>Ui(e,t))}function Mi(e){return Hi(ji(e))}function Ni(e,t){let n=Mr(e,t);if(n==null||n===e.snapshot.rootId||B(K(e,n))&&xr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=K(e,i).parentId,n=G(e,t),s=Nt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Rt(a,n,s),t!==o){let n=K(e,t),a=br(e,t);if(!Bn(e,t,n)&&a!==i)return null;xr(e,t)===t&&(r+=1)}i=t}return r}function Pi(e,t){let n=Mr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return Bn(e,n,r)?null:(Vn(e,n,!0,r),kr(e,n),er({affectedAncestorIds:jr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Fi(e,t){let n=Mr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return Bn(e,n,r)?(Vn(e,n,!1,r),kr(e,n),tr({affectedAncestorIds:jr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Ii(e,t){return t<0||t>=q(e)?null:Li(e,e.snapshot.rootId,t,-1)}function Li(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?R(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>R(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ri(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ri(e,t,n,r){if(!B(K(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=zi(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!B(a)||!Bn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Li(e,i.terminalNodeId,n-1,i.visibleDepth)}function zi(e,t,n){return B(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:xr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>xr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Bi(e,t){let n=K(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||br(e,r)!==t}function Vi(e,t){let n=K(e,t.terminalNodeId);if(B(n)){let r=G(e,t.terminalNodeId);if(Bn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ri(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=K(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=G(e,n),o=Nt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Ri(e,s,0,i);Bi(e,r)&&i--,r=n}}function Hi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Ui(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(Ci);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=wi(o,y);let x,S=_;if(B(v))S=f?xr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:W(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&B(C)&&Bn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Wi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!B(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:W(e,f)};continue}let h=l?xr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Gi(e,g);let _=i[h];_!=null&&B(_)&&Bn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Gi(e,t){let n=K(e,t.terminalNodeId),r=B(n)?Ki(e,t):null,i=W(e,t.terminalNodeId),a=U(e.snapshot.segmentTable,n.nameId),o=B(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?Sr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:U(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>Sr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:U(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:B(n)&&Bn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ki(e,t){if(t.headNodeId===t.terminalNodeId)return Un(e,t.terminalNodeId);let n=Sr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Un(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var qi=8;function Ji(e){let{nodes:t,directories:n,rootId:r,options:i}=e,a=t.length,o=new Int32Array(a),s=new Int32Array(a),c=new Int32Array(a),l=new Int32Array(a),u=new Int32Array(a),d=new Int32Array(a),f=new Int32Array(a);for(let e=0;e<a;e+=1){let n=t[e];n!=null&&(o[e]=n.parentId,s[e]=n.nameId,c[e]=n.depthAndFlags,l[e]=n.subtreeNodeCount,u[e]=n.visibleSubtreeCount)}let p=0;for(let e of n.values())p+=e.childIds.length;let m=new Int32Array(p),h=0;for(let[e,t]of n){let n=t.childIds;d[e]=h,f[e]=n.length;for(let e=0;e<n.length;e+=1)m[h]=n[e],h+=1}return{nodeCount:a,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:o,nameId:s,depthAndFlags:c,subtreeNodeCount:l,visibleSubtreeCount:u,childStart:d,childCount:f,childIdsFlat:m}}function Yi(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:a,visibleSubtreeCount:o,childStart:s,childCount:c,childIdsFlat:l}=e;for(let e=t-1;e>=1;--e){if((i[e]&qi)===0)continue;let t=s[e],n=c[e],u=0,d=0;for(let e=0;e<n;e+=1){let n=l[t+e];u+=a[n],d+=o[n]}a[e]=1+u;let f;f=r&&n===1?(i[l[t]]&qi)===0?1+d:d:1+d,o[e]=f}let u=s[n],d=c[n],f=0,p=0;for(let e=0;e<d;e+=1){let t=l[u+e];f+=a[t],p+=o[t]}a[n]=1+f,o[n]=p}function Xi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!B(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&zt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,zt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Zi(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Ji(e.snapshot);Yi(i);let a=i.subtreeNodeCount,o=i.visibleSubtreeCount;for(let e=0;e<n.length;e+=1){let t=n[e];t!=null&&(t.subtreeNodeCount=a[e],t.visibleSubtreeCount=o[e])}for(let[e,i]of t){let t=i.childIds,a=t.length,o=0,s=0;for(let e=0;e<a;e++){let r=t[e];if(r==null)continue;let i=n[r];o+=i.subtreeNodeCount,s+=i.visibleSubtreeCount}i.totalChildSubtreeNodeCount=o,i.totalChildVisibleSubtreeCount=s,(e===r||a>=128)&&zt(n,i)}}function Qi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var $i=class e{#e;constructor(e={}){let t=Qt(e),n=H(t,`store.builder.create`,()=>new Fn(e));if(e.preparedInput!=null){let t=Mn(e.preparedInput);t==null?n.appendPreparedPaths(jn(e.preparedInput),!1):n.appendPresortedPaths(t,Nn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>Pn(r,e)))}let r=H(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=H(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=H(t,`store.state.create`,()=>In(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:H(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Qi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&H(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?H(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>Zi(this.#e)):H(t,`store.state.initializeOpenVisibleCounts`,()=>Xi(this.#e)):H(t,`store.state.recomputeCounts`,()=>Ar(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return On(e,t)}static prepareInput(e,t={}){return kn(e,t)}static preparePresortedInput(e){return An(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>Cr(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=q(this.#e);ur(this.#e,cr(this.#e,t,wr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=q(this.#e);ur(this.#e,cr(this.#e,n,Tr(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=q(this.#e),i=Er(this.#e,e,t,n);i!=null&&ur(this.#e,cr(this.#e,r,i))})}batch(e){lr(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision})}})}getVisibleCount(){return H(this.#e.instrumentation,`store.getVisibleCount`,()=>q(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>Ai(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>ki(this.#e,e))}getVisibleTreeProjection(){return Mi(this.#e)}getVisibleTreeProjectionData(e){return ji(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ni(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Mr(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:Gt(n),kind:B(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return H(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Bn(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=q(this.#e),n=Pi(this.#e,e);n!=null&&ur(this.#e,cr(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=q(this.#e),n=Fi(this.#e,e);n!=null&&ur(this.#e,cr(this.#e,t,n))})}on(e,t){return Xn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Un(this.#e,t)}markDirectoryUnloaded(e){H(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(G(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=q(this.#e);Gn(this.#e,t),ur(this.#e,cr(this.#e,n,nr({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return H(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=q(this.#e),r=Wn(this.#e,t);return ur(this.#e,cr(this.#e,n,rr({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return H(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Un(this.#e,n)!==`loading`||!qn(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=q(this.#e),a=[];for(let e of t.operations){ea(r,e);let t=q(this.#e);switch(e.type){case`add`:a.push(cr(this.#e,t,wr(this.#e,e.path)));break;case`remove`:a.push(cr(this.#e,t,Tr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Er(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(cr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ur(this.#e,cr(this.#e,i,ir({affectedAncestorIds:jr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return H(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=q(this.#e),r=Kn(this.#e,t,e.attemptId);return ur(this.#e,cr(this.#e,n,ar({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return H(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=q(this.#e),i=Jn(this.#e,n,e.attemptId,t);return ur(this.#e,cr(this.#e,r,or({affectedAncestorIds:jr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:W(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return H(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(xi(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=q(this.#e),n=Si(this.#e,e.mode??`stable`);return ur(this.#e,cr(this.#e,t,sr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=G(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??nn(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=an(fn(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!B(K(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=K(this.#e,n);Bn(this.#e,n,i)||(Vn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=K(this.#e,e);if(!Bn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Mr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(K(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=K(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=K(this.#e,e),r=br(this.#e,e);if(!Bn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function ea(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`)}}var ta=e=>e.startsWith(`f::`)?e.slice(3):e;function na(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function ra(e,t){return e===``?t:`${e}/${t}`}function ia({files:e,path:t,isFolder:n,nextBasename:r}){let i=ta(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=na(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=ra(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function aa(e){return e.endsWith(`/`)}function oa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function sa(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function ca(e,t){return t.includes(e)?sa(t):[e]}function la(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function ua(e,t){return{draggedPaths:e,target:t}}function da(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(aa(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function fa(e,t){return t.kind===`root`||t.directoryPath==null?oa(e):t.directoryPath}function pa(e,t){let n=e.map(e=>{let n=fa(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function ma(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ha(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!ma($i.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function ga(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function _a(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function va(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function ya(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return va(e,t.path)?n?e:null:e;case`move`:return _a(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=ya(r,e,n),r==null)return null;return r}}}function ba(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function xa(e){switch(e.operation){case`add`:return{...ba(e),operation:`add`,path:e.path};case`remove`:return{...ba(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...ba(e),from:e.from,operation:`move`,to:e.to}}}function Sa(e){return{...ba(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>xa(e)),operation:`batch`}}function Ca(e){switch(e.operation){case`add`:case`remove`:case`move`:return xa(e);case`batch`:return Sa(e);default:return null}}function wa(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function Ta(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ea(e){return Ta(e).at(-1)??null}function Da(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function Oa(e){return e.endsWith(`/`)}var ka=e=>e.toLowerCase();function Aa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function ja(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Ma(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var Na=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},Pa=Symbol(`FILE_TREE_RENAME_VIEW`),Fa=512,Ia=512;function La(e){return e===`top`||e===`center`?e:`nearest`}function Ra(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=Ta(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function za(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:Ra(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var Ba=class e{static{Object.defineProperty(e.prototype,Pa,{configurable:!0,value(){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}},writable:!0})}#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=ha({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=Ea(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:La(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=Ia){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=ca(t,n);return this.#r.canDrag?.(r)!==!1&&(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=ua(t.draggedPaths,n);(da(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}la(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=ua(e.draggedPaths,t);if(da(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=pa(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=Oa(r),a=ja(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of Ta(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=Aa(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,Oa(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,Oa(e)?{recursive:!0}:void 0);return}let t=Oa(e),n=ia({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:ja(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(Ma(n.sourcePath,t),Ma(n.destinationPath,t))}#Y(e){this.#T!=null&&this.#E!==e&&(this.#E=e,this.#De())}resetPaths(e,t={}){let n=!Array.isArray(e),r=n?void 0:e,i=n?e:t,a=this.#H.list().length,o=this.#G,s=ha({paths:r,preparedInput:i.preparedInput},`resetPaths`,this.#e.sort),c=this.#le(s.paths,s.preparedInput,i.initialExpandedPaths),l=this.#c,u=this.#T,d=this.getSelectedPaths(),f=this.#z;this.#K?.(),this.#H=c,this.#d.clear(),this.#he();let p=d.map(e=>c.getPathInfo(e)?.path??null).filter(e=>e!=null),m=!wa(this.#B,p);this.#B=new Set(p),m&&(this.#V+=1),this.#z=f==null?null:c.getPathInfo(f)?.path??null,this.#T=u==null?null:c.getPathInfo(u)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(l,l!=null||p.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:s.paths.length,pathCountBefore:a,projectionChanged:!0,usedPreparedInput:i.preparedInput!=null,visibleCountDelta:this.#G-o})}#X(e){this.#Ie();let t=Ea(e),n=Da(e,t),r=null,i=null;for(let e of this.#be()){if(Ea(e)!==t)continue;let a=Da(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=Ta(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!wa(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new $i({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of Ta(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(ka),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(ka),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of Ta(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:Na(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of Ta(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of Ta(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=za(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,Fa)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s!==e||this.#c!==n)&&(this.#s=e,this.#c=n,t&&this.#De())}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=ya(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=ya(this.#c,e,!0),r=[...this.#B].map(t=>ya(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=ya(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return wa(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&ga(e)&&(this.#i=null);let t=ga(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=Ca(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},Va=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function Ha(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(e[t]!==`/`&&t!==e.length){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function Ua(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let e=t.indexOf(`/`,r);if(e===-1)break;n.push(t.slice(0,e+1)),r=e+1}return n}function Wa(e,t){return t?`${e}/`:e}function Ga(e,t=null){let n=Va(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set,o=new Map;for(let t of e??[]){let e=qa(t);e!=null&&Xa({canonicalPath:e.canonicalPath,changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,isDirectory:e.isDirectory,status:t.status,statusByPath:r})}return r.size===0?null:{changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}function Ka(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),a=new Set(e?.directoriesWithChanges),o=new Set(e?.ignoredDirectoryPaths),s=new Map(e?.changeCountByDirectoryPath),c=!1;for(let e of n){let t=Ja(e);t!=null&&(c=Ya({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,statusByPath:i})||c)}for(let e of r){let t=qa(e);t!=null&&(c=Xa({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,isDirectory:t.isDirectory,status:e.status,statusByPath:i})||c)}return c?i.size===0?null:{changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,signature:$a(i),statusByPath:i}:e}function qa(e){return Ja(e.path)}function Ja(e){let t=Ha(e);if(t!=null)return{canonicalPath:Wa(t.path,t.isDirectory),isDirectory:t.isDirectory}}function Ya({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let a=i.get(e);return a!=null&&(i.delete(e),a===`ignored`&&e.endsWith(`/`)&&r.delete(e),Qa(t,n,e),!0)}function Xa({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:a,statusByPath:o}){let s=o.get(e);return s!==a&&(s??Za(t,n,e),o.set(e,a),a===`ignored`&&i?r.add(e):i&&r.delete(e),!0)}function Za(e,t,n){for(let r of Ua(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function Qa(e,t,n){for(let r of Ua(n)){let n=(e.get(r)??0)-1;n>0?e.set(r,n):(e.delete(r),t.delete(r))}}function $a(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\0${n}\0${r}`;return t}var eo=e=>e.trim().toLowerCase(),to=e=>e.split(`/`).at(-1)??e,no=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function ro(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function io(e){let t=mt(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(eo(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let s=to(o),c=s.toLowerCase(),l=r.get(c);if(l!=null)return ro(l,e);for(let[t,n]of a)if(c.includes(t))return ro(n,e);let u=no(s);for(let t of u){let n=i.get(t);if(n!=null)return ro(n,e)}let d=P(t.set,s,u);if(d!=null&&t.set!==`none`){if(d==="default"){let t=n?.[e];if(t!=null)return ro(t,e)}return{name:ft(d),remappedFrom:e,token:d}}}let s=n?.[e];return s==null?{name:e}:ro(s,e)}}}var J,ao,oo,so,co,lo,uo,fo,po,mo,ho={},go=[],_o=Array.isArray,vo=go.slice,yo=Object.assign;function bo(e){e&&e.parentNode&&e.remove()}function xo(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?vo.call(arguments,2):n),So(e,o,r,i,null)}function So(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ao,__i:-1,__u:0};return i==null&&J.vnode!=null&&J.vnode(a),a}function Co(e){return e.children}function wo(e,t){this.props=e,this.context=t,this.__g=0}function To(e,t){if(t==null)return e.__?To(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?To(e):null}function Eo(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return Eo(e)}}function Do(e){(8&e.__g||!(e.__g|=8)||!oo.push(e)||co++)&&so==J.debounceRendering||((so=J.debounceRendering)||queueMicrotask)(Oo)}function Oo(){for(var e,t,n,r,i,a,o,s,c=1;oo.length;)oo.length>c&&oo.sort(lo),e=oo.shift(),c=oo.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=yo({},r)).__v=r.__v+1,J.vnode&&J.vnode(n),Io(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??To(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,Ro(a,n,o),n.__e!=i&&Eo(n)));co=0}function ko(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||go,b=t.length;for(c=Ao(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?ho:y[m.__i]||ho,m.__i=f,_=Io(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&Vo(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=jo(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function Ao(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?So(null,o,null,null,null):_o(o)?So(Co,{children:o},null,null,null):o.constructor==null&&o.__b>0?So(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=Mo(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=To(s)),Ho(s,s));return r}function jo(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=jo(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=To(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Mo(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function No(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function Po(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||No(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||No(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(uo,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=fo,e.addEventListener(t,a?mo:po,a)):e.removeEventListener(t,a?mo:po,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Fo(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=fo++;else if(t.u<n.l)return;return n(J.event?J.event(t):t)}}}function Io(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,ee,w,T,te,E,D,O,ne,k=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=J.__b)&&d(t);n:if(typeof k==`function`)try{if(v=t.props,y=`prototype`in k&&k.prototype.render,b=(d=k.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new k(v,x):(t.__c=f=new wo(v,x),f.constructor=k,f.render=Uo),b&&b.sub(f),f.props=v,f.state||(f.state={}),f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&k.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=yo({},f.__s)),yo(f.__s,k.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&k.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&k.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=J.__r,ee=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),w=0;w<f._sb.length;w++)f.__h.push(f._sb[w]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++ee<25);f.state=f.__s,f.getChildContext!=null&&(r=yo({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),T=d,d!=null&&d.type===Co&&d.key==null&&(T=zo(d.props.children)),s=ko(e,_o(T)?T:[T],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null){if(e.then){for(te=0,E=!1,t.__u|=c?160:128,t.__c.__z=[],D=0;D<a.length;D++)(O=a[D])==null||E||(O.nodeType==8&&O.data==`$s`?(te>0&&t.__c.__z.push(O),te++,a[D]=null):O.nodeType==8&&O.data==`/$s`?(--te>0&&t.__c.__z.push(O),E=te===0,s=a[D],a[D]=null):te>0&&(t.__c.__z.push(O),a[D]=null));if(!E){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(ne=a.length;ne--;)bo(a[ne]);Lo(t)}}else t.__e=n.__e,t.__k=n.__k,e.then||Lo(t);J.__e(e,t,n)}else s=t.__e=Bo(n.__e,t,n,r,i,a,o,c,l,u);return(d=J.diffed)&&d(t),128&t.__u?void 0:s}function Lo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Lo)}function Ro(e,t,n){for(var r=0;r<n.length;r++)Vo(n[r],n[++r],n[++r]);J.__c&&J.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){J.__e(e,t.__v)}})}function zo(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:_o(e)?e.map(zo):yo({},e)}function Bo(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(J.__m&&J.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=vo.call(e.childNodes),v=n.props||ho,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;Po(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||Po(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),ko(b==`template`?e.content:e,_o(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&To(n,0),s,c,l),a!=null)for(u=a.length;u--;)bo(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||Po(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&Po(e,u,g,v[u],i))}return e}function Vo(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){J.__e(e,n)}}function Ho(e,t,n){var r,i;if(J.unmount&&J.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Vo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){J.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ho(r[i],t,n||typeof e.type!=`function`);n||bo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function Uo(e,t,n){return this.constructor(e,n)}function Wo(e,t){var n,r,i,a;t==document&&(t=document.documentElement),J.__&&J.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=xo(Co,null,[e]),i=[],a=[],Io(t,e,r||ho,ho,t.namespaceURI,r?null:t.firstChild?vo.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),Ro(i,e,a)}function Go(e,t){e.__u|=32,Wo(e,t)}J={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw co=0,e}},ao=0,wo.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=yo({},this.state);typeof e==`function`&&(e=e(yo({},n),this.props)),e&&yo(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Do(this))},wo.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),Do(this))},wo.prototype.render=Co,oo=[],co=0,lo=function(e,t){return e.__v.__b-t.__v.__b},uo=/(PointerCapture)$|Capture$/i,fo=0,po=Fo(!1),mo=Fo(!0);var Ko=0;Array.isArray;function Y(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ko,__i:-1,__u:0,__source:i,__self:a};return J.vnode&&J.vnode(l),l}var qo=16,Jo=16,Yo={};function Xo({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=Yo[e]??{width:qo,height:Jo},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return Y(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:Y(`use`,{href:c})})}var Zo=e=>e!==void 0&&/\s/.test(e),Qo=(e,t)=>{let n=t=>Zo(e[t-1])||Zo(e[t]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let a=t+r;if(a<e.length&&!n(a))return a}return t},$o=e=>Qo(e,Math.ceil(e.length/2)),es=e=>{if(e.length<2)return[e,``];let t=$o(e);return[e.slice(0,t),e.slice(t)]},ts=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:$o(e);return[e.slice(0,r),e.slice(r)]},ns=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},rs=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},is=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},as=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function os({children:e,marker:t,variant:n=`default`}){"use no memo";return Y(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:Y(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?Y(`span`,{"data-truncate-fade":!0}):t})})}function ss(e){"use no memo";let{mode:t,children:n}=e;return Y(`div`,{children:[Y(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?Y(`span`,{children:n}):n}),Y(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?Y(`span`,{children:n}):n})]})}function cs({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=Y(ss,{mode:t,children:e},`content`),o=Y(os,{marker:n,mode:t,variant:r},`marker`),s=Y(`div`,{"data-truncate-fill":!0},`fill`);return Y(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:Y(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function ls({children:e,...t}){"use no memo";return Y(cs,{mode:`truncate`,...t,children:e})}function us({children:e,...t}){"use no memo";return Y(cs,{mode:`fruncate`,...t,children:e})}function ds({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=Y(ls,{...s,children:t[0]}),l=Y(us,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return Y(`div`,{className:a,style:o});if(e.length<i)return Y(n===`end`?us:ls,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=es:r===`extension`?t=ts:r===`leaf-path`&&(t=ns);else if(typeof r==`number`)t=rs,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=is:e===`first`&&(t=as)}else typeof r==`function`&&(t=r);t??=es;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=Y(ls,{...s,..._,children:f}),l=Y(us,{...s,...v,children:p})}return Y(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[Y(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),Y(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var fs={endIndex:-1,startIndex:-1};function ps(e,t,n){return Math.min(Math.max(e,t),n)}function ms(e,t){return e<0||t<e?fs:{endIndex:t,startIndex:e}}function hs(e){return e.startIndex<0||e.endIndex<e.startIndex}function gs(e,t){return hs(e)?0:(e.endIndex-e.startIndex+1)*t}function _s(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function vs(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function ys(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function bs(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function xs(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function Ss(e,t,n){if(e.length===0||t<=0)return[];let r=xs(e),i=ys(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=bs(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function Cs(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=ps(t.scrollTop,0,o),c=t.stickyRows??Ss(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=_s(s,n,t.itemHeight),m=_s(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?fs:ms(m,vs(u+d,n,t.itemHeight)),y=g+1,b=hs(v)?fs:ms(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=gs(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:hs(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var ws={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},Ts={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},Es=`Contains git status items`;function Ds(e){return e.current?!0:(e.current=!0,!1)}function Os(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function ks(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return Os({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function As(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function js(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function Ms(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function Ns(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function Ps(e,t){return e!=null&&e>0?e:t}function Fs(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function Is(e,t,n,r,i=0){let a=Os({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a!=null&&(e.scrollTop=a,!0)}function Ls(e,t,n,r,i,a,o=0){let s=ks({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s!=null&&(e.scrollTop=s,!0)}function Rs(e,t,n,r,i,a){let o=As({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o!=null&&(e.scrollTop=o,!0)}function zs(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function Bs(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function Vs({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return Y(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function Hs(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function Us(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var Ws,X,Gs,Ks,qs=Object.is,Js=0,Ys=[],Z=J,Xs=Z.__b,Zs=Z.__r,Qs=Z.diffed,$s=Z.__c,ec=Z.unmount,tc=Z.__;function nc(e,t){Z.__h&&Z.__h(X,e,Js||t),Js=0;var n=X.__H||(X.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function rc(e){return Js=1,ic(mc,e)}function ic(e,t,n){var r=nc(Ws++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):mc(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);qs(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=X,!X.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,qs(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};X.__f=!0;var a=X.shouldComponentUpdate,o=X.componentWillUpdate;X.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},X.shouldComponentUpdate=i}return r.__N||r.__}function ac(e,t){var n=nc(Ws++,3);!Z.__s&&pc(n.__H,t)&&(n.__=e,n.u=t,X.__H.__h.push(n))}function oc(e,t){var n=nc(Ws++,4);!Z.__s&&pc(n.__H,t)&&(n.__=e,n.u=t,X.__h.push(n))}function Q(e){return Js=5,sc(function(){return{current:e}},[])}function sc(e,t){var n=nc(Ws++,7);return pc(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return Js=8,sc(function(){return e},t)}function cc(){for(var e;e=Ys.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(dc),e.__H.__h.forEach(fc),e.__H.__h=[]}catch(t){e.__H.__h=[],Z.__e(t,e.__v)}}Z.__b=function(e){X=null,Xs&&Xs(e)},Z.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tc&&tc(e,t)},Z.__r=function(e){Zs&&Zs(e),Ws=0;var t=(X=e.__c).__H;t&&(Gs===X?(t.__h=[],X.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(dc),t.__h.forEach(fc),t.__h=[],Ws=0)),Gs=X},Z.diffed=function(e){Qs&&Qs(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ys.push(t)!==1&&Ks===Z.requestAnimationFrame||((Ks=Z.requestAnimationFrame)||uc)(cc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Gs=X=null},Z.__c=function(e,t){t.some(function(e){try{e.__h.forEach(dc),e.__h=e.__h.filter(function(e){return!e.__||fc(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Z.__e(n,e.__v)}}),$s&&$s(e,t)},Z.unmount=function(e){ec&&ec(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{dc(e)}catch(e){t=e}}),n.__H=void 0,t&&Z.__e(t,n.__v))};var lc=typeof requestAnimationFrame==`function`;function uc(e){var t,n=function(){clearTimeout(r),lc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);lc&&(t=requestAnimationFrame(n))}function dc(e){var t=X,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),X=t}function fc(e){var t=X;e.__c=e.__(),X=t}function pc(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!qs(t,e[n])})}function mc(e,t){return typeof t==`function`?t(e):t}function hc(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:Y(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return Y(Co,{children:[Y(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:Y(ls,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function gc(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function _c(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function vc(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function yc({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=Cs(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:vc(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?vc(u,1,t,o):i&&r<=0&&c.length>0?Ss(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var bc=400,xc=40,Sc=18;function Cc(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?wc(e,t,n):a instanceof HTMLElement?a:null}function wc(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function Tc(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function Ec(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function Dc(){return navigator.vendor!==`Apple Computer, Inc.`}function Oc(e,t){let n=e-t.top;if(n<xc)return-Math.ceil((xc-Math.max(0,n))/xc*Sc);let r=t.bottom-e;return r<xc?Math.ceil((xc-Math.max(0,r))/xc*Sc):0}function kc(e,t){if(e!=null){let t=ws[e];return t==null?null:{text:t,title:Ts[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:Es}:null}function Ac(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function jc(e){return e!=null&&`toggle`in e}function Mc(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function Nc(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Pc(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function Fc(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function Ic(e,t){return t&&Fc(e)||(e.ctrlKey||e.metaKey)&&Mc(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var Lc=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function Rc(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function zc(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function Bc(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function Vc(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function Hc(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function Uc(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function Wc(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function Gc(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function Kc(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=Gc(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function qc(e,t){return{kind:e.kind,name:_c(e),path:t}}function Jc(e){return e==null?void 0:`${e}__tree`}function Yc(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function Xc(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Zc(e,t){if(e==null)return null;if(`text`in e)return e.parts==null?Y(`span`,{title:e.title,children:e.text}):Y(`span`,{title:e.title,children:e.parts.map((e,t)=>Y(`span`,{style:{color:e.color},children:e.text},t))});let n=typeof e.icon==`string`?Xc(e.icon)?t(e.icon):{name:e.icon}:Xc(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return Y(`span`,{title:e.title,children:Y(Xo,{...n})})}function Qc(e){e!=null&&js(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function $c(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=gc(e);return Y(Co,{children:[e.depth>0?Y(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>Y(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,Y(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?Y(Xo,{...t(`file-tree-icon-chevron`)}):Y(Xo,{...t(`file-tree-icon-file`,u)})}),Y(`div`,{"data-item-section":`content`,children:e.isFlattened?hc(e,c,a):c??Y(ds,{minimumLength:5,split:`extension`,children:e.name})}),i?Y(`div`,{"data-item-section":`decoration`,children:r==null?null:Zc(r,t)}):null,s?Y(`div`,{"data-item-section":`git`,children:Zc(o,t)}):null,n?Y(`div`,{"data-item-section":`action`,children:l?Y(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:Y(Xo,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function el(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:ee,contextMenuButtonVisibility:w,contextMenuRightClickEnabled:T,registerRenameInput:te,registerButton:E,resolveIcon:D,renderDecorationForRow:O,openContextMenuForRow:ne,onRowClick:k,onKeyDown:re}=e,A=gc(t),{isParked:j=!1,mode:ie=`flow`,style:ae}=r,oe=ie===`sticky`,se=_?.get(A)??null??Ac(t.ancestorPaths,v,y),ce=t.kind===`directory`&&(b?.has(A)??!1),le=O(t,A),ue=kc(se,ce),de=S&&ee,fe=le!=null||x||de,pe=de&&w===`always`,me=a.getPath()===A,he=me?a.getValue():``,ge=oe||!me?null:Y(Vs,{ref:te,ariaLabel:`Rename ${_c(t)}`,isFlattened:t.isFlattened,value:he,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),_e=$c(t,D,{actionLaneEnabled:de,customDecoration:le,decorationLaneEnabled:fe,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:ue,gitLaneActive:x,renameInput:ge,showDecorativeActionAffordance:pe}),ve={...Hs({ariaLabel:_c(t),domId:t.isFocused?Yc(h,A,j):void 0,extraStyle:ae,features:{actionLaneEnabled:de,contextMenuButtonVisibility:de?w:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:j,itemHeight:g,mode:ie,row:t,state:{containsGitChange:ce,effectiveGitStatus:se,isContextHovered:s===A,isDragTarget:l?.kind===`directory`&&l.directoryPath===A,isDragging:c?.has(A)===!0,isFocusRinged:t.isFocused&&o===A},targetPath:A}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),T&&(i.focusMountedPathFromInput(A),ne(t,A,{anchorRect:Bc(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:oe?void 0:()=>{i.focusMountedPathFromInput(A)},onKeyDown:oe?void 0:re,ref:e=>{E(A,e)}};return!oe&&me?Y(`div`,{...ve,children:_e}):Y(`button`,{...ve,type:`button`,draggable:u&&!j,onDragEnd:u&&!j?p:void 0,onDragStart:u&&!j?e=>{f(e,t,A)}:void 0,onMouseDown:e=>{if(oe){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!j?e=>{m(e,t,A)}:void 0,onClick:e=>{k(e,t,A,ie)},children:_e})}function tl(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(gc(e))).map((n,r)=>el(e,n,t.start+r))}function nl({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=_t,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=Q(null),v=Q(null),y=Q(!1),b=Q(null),x=Q(null),S=Q(null),C=Q(null),ee=Q(null),E=Q(new Map),D=Q(new Map),O=Q(()=>{}),ne=Q(null),k=Q(0),re=Q(!1),A=Q(null);A.current!==t&&(re.current=!1,A.current=t);let j=Q(!1),ie=Q(null),ae=Q(null),oe=Q(!1),se=Q(null),ce=Q(null),le=Q(null),ue=Q(null),de=Q(null),fe=Q(null),pe=Q(null),me=Q(null),he=Q(!1),ge=Q(null),_e=Q(null),ve=Q(null),ye=Q(null),be=sc(()=>new Map,[]),[,xe]=rc(0),Se=Q(!1),[Ce,we]=rc(null),[Te,Ee]=rc(null),[De,Oe]=rc(null),[ke,Ae]=rc(null),[je,Me]=rc(0),[M,Ne]=rc(null),Pe=Q(M);Pe.current=M;let Fe=Q(null),Ie=Q(null),Le=Q(null),Re=Q(null),ze=Q(null),Be=Q(!1),Ve=()=>{Ie.current=null,Le.current=null,Re.current=null},He=(e,t)=>{Ie.current=e,Le.current=null,Re.current=t==null?null:{path:e,scrollTop:t}},Ue=(e,t)=>{Ie.current=null,Le.current={path:e,viewportOffset:t},Re.current=null},We=Q(d===`retain`&&t.isSearchOpen()),[Ge,Ke]=rc(p);ac(()=>{p||Ke(!1)},[p]);let qe=Q(!1),Je=$(()=>{qe.current=!0,Ke(e=>e&&!1)},[]),[Ye,Xe]=rc(()=>yc({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[Ze,Qe]=rc(!1);ac(()=>{Qe(!0)},[]);let N=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,$e=e?.contextMenu?.triggerMode??(N?`right-click`:`both`),et=$e===`both`||$e===`button`,tt=e?.contextMenu?.buttonVisibility??`when-needed`,nt=$e===`both`||$e===`right-click`;oc(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;ze.current=t,Ee(t),Ae(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Be.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let rt=$((e,t)=>{Hc(E.current,e,t)},[]),it=$((e,t)=>{Hc(D.current,e,t)},[]),at=$(e=>{x.current=e},[]),ot=$(e=>Uc(e,D.current,E.current),[]),st=n!=null||r!=null||i!=null,{resolveIcon:ct}=sc(()=>io(a),[a]),lt=t[Pa](),ut=lt.getPath(),dt=ut!=null,ft=t.isSearchOpen(),pt=t.getSearchValue(),P=t.getFocusedPath(),F=t.getFocusedIndex(),mt=t.getScrollRequest(),ht=t.isDragAndDropEnabled(),gt=t.getDragSession(),vt=sc(()=>gt==null?null:new Set(gt.draggedPaths),[gt]),yt=gt?.target??null,bt=gt?.primaryPath??null,xt=Jc(o),{overlayHeight:St,overlayRows:Ct,snapshot:I,visibleRows:wt}=Ye,L=I.physical.viewportHeight,Tt=sc(()=>({end:I.window.endIndex,start:I.window.startIndex}),[I.window.endIndex,I.window.startIndex]),Et=Ct,Dt=I.sticky.rows,Ot=I.physical.totalHeight,kt=I.sticky.height,At=sc(()=>new Set(Dt.map(e=>gc(e.row))),[Dt]),jt=F>=0&&F>=Tt.start&&F<=Tt.end,Mt=$((e,t)=>u?.({item:qc(e,t),row:e})??null,[u]),Nt=$(e=>js(e==null?null:E.current.get(e)??null)?!0:js(S.current),[]),Pt=$(e=>{Nt(t.focusNearestPath(e))},[t,Nt]),Ft=Q(Pt);Ft.current=Pt;let It=Q(!0),Lt=Q(()=>{}),R=$((t=!0)=>{let n=Pe.current;n!=null&&(It.current=It.current&&t,Ne(null),e?.contextMenu?.onClose?.(),It.current&&Pt(n.path))},[e?.contextMenu,Pt]);Lt.current=R;let Rt=$(e=>{let t=e==null?null:Vc(S.current,e);Oe(e=>e===t?e:t)},[]),zt=$((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=ot(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;He(n,e?.scrollTop??null),j.current=!0,we(e=>e===n?e:n)}i.focus(),Rt(a),It.current=!0,Ne({anchorRect:r?.anchorRect??null,item:qc(e,n),path:n,source:r?.source??`keyboard`})},[t,ot,Rt]),Bt=$(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=Ns(e,L);se.current=F<0||e==null?null:Math.max(0,Math.min(F*s-e.scrollTop,Math.max(0,t-s))),oe.current=!0}t.startRenaming(e)!==!1&&(Ae(`focus`),xe(e=>e+1))}},[t,F,s,l,L]),Vt=$((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=Ns(i,L),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:yc({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return j.current=!0,Rs(i,a,s,l,u,d),O.current(),Fe.current=n?e:null,!0},[t,s,c,L,h]),Ht=()=>y.current===!0||ye.current!=null||he.current===!0,Ut=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),Wt=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},z=()=>{ue.current!=null&&(clearTimeout(ue.current),ue.current=null),le.current=null},Gt=()=>{fe.current?.remove(),fe.current=null},Kt=()=>{Wt(ce.current),ce.current=null,de.current=null},B=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},qt=()=>{me.current?.(),me.current=null,ye.current!=null&&(clearTimeout(ye.current),ye.current=null),he.current=!1,ge.current=null,ve.current=null,_e.current!=null&&(_e.current.setAttribute(`draggable`,`true`),_e.current.style.removeProperty(`touch-action`),_e.current=null),Gt(),z(),Kt(),pe.current=null},V=(e,n)=>{let r=S.current?.getRootNode(),i=Tc(Cc(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Jt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){z();return}let r=t.getItem(e.directoryPath),i=jc(r)?r:null;if(i==null||i.isExpanded()){z();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;le.current!==a&&(z(),le.current=a,ue.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind===`directory`&&n.directoryPath===e.directoryPath&&n.flattenedSegmentPath===e.flattenedSegmentPath&&i.expand()},n))},Yt=()=>{ce.current=null;let e=de.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=Oc(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,O.current()),Jt(V(e.clientX,e.clientY)),ce.current=Ut(Yt)},Xt=(e,t)=>{de.current={clientX:e,clientY:t},ce.current??=Ut(Yt)},Zt=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(qt(),Gt(),z(),Kt(),t.startDrag(r)===!1){e.preventDefault();return}if(pe.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),Dc())){let t=Ec(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),B(t),fe.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Qt=()=>{Gt(),z(),Kt(),pe.current=null,t.cancelDrag()},H=(e,n,r)=>{if(ye.current!=null||he.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;ve.current={clientX:i.clientX,clientY:i.clientY},_e.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!he.current;ye.current!=null&&(clearTimeout(ye.current),ye.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),me.current===o&&(me.current=null),t&&(a.setAttribute(`draggable`,`true`),_e.current===a&&(_e.current=null),ve.current=null)},s=e=>{let t=e.touches[0],n=ve.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=100||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),me.current=o,ye.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),_e.current===a&&(_e.current=null),ve.current=null;return}he.current=!0,_e.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),pe.current=n;let e=a.getBoundingClientRect(),s=Ec(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),B(s),fe.current=s,ge.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=ge.current;n!=null&&fe.current!=null&&(fe.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Jt(V(t.clientX,t.clientY)),Xt(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&V(n.clientX,n.clientY),t.completeDrag(),qt()},u=()=>{t.cancelDrag(),qt()};me.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},bc)},$t=e=>{if(M!=null){if(e.key===`Escape`){R(),e.preventDefault(),e.stopPropagation();return}Lc.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(lt.isActive()){if(e.isComposing||e.keyCode===229)return;if(e.key===`Escape`)lt.cancel();else if(e.key===`Enter`)lt.commit();else return;Ae(`focus`),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){Bt(P??void 0),e.preventDefault(),e.stopPropagation();return}if(ft){if(e.key===`Escape`)oe.current=!1,se.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=Ns(n,L);se.current=F<0||n==null?null:Math.max(0,Math.min(F*s-n.scrollTop,Math.max(0,r-s))),oe.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;Ae(`focus`),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&Nc(e)){t.openSearch(e.key),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=N&&Fc(e),r=Ic(e,N),i=r&&S.current!=null?Ms(S.current):null,a=r?new Set(Wc(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==P&&a.has(o)){let e=C.current;He(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=jc(p)?p:null,h=u!=null&&(At.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=Uc(u,D.current,E.current);e==null||n==null?y=!1:zt(e,u)}else if((e.ctrlKey||e.metaKey)&&Mc(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;Ae(`focus`);let b=t.getFocusedPath(),x=b!=null&&(At.has(b)||a.has(b)),ee=g&&b!==u,w=n&&c&&o===u&&b===u;if((h||w)&&b!=null&&(ee&&x||w))He(b,v?.scrollTop??null),j.current=!0,we(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(Ue(b,Kc(S.current,v,i,u,s,kt,L)),j.current=!0,we(e=>e===b?e:b)):Ve()}xe(e=>e+1),e.preventDefault(),e.stopPropagation()};oc(()=>{if(!(!f||!ft)){if(We.current){We.current=!1;return}js(ee.current)}},[ft,f]),oc(()=>{let e=x.current;switch(Bs({hasRenderedInput:e!=null,previousRenamingPath:ae.current,renamingPath:ut})){case`reset`:ae.current=null;return;case`reveal-canonical`:ut!=null&&Vt(ut,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(Fe.current=null,ae.current=ut,js(e),e.select());return}},[Tt.end,Tt.start,ut,Vt,At]),oc(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=Ms(e)?.dataset.itemPath??null;we(e=>e===t?e:t)},i=()=>{n(),j.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,Ms(e)!=null){r();return}j.current=!1,we(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),j.current=!1,we(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;we(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),oc(()=>{let e=S.current;e!=null&&(I.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[I.physical.scrollTop]),oc(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;ne.current=Ns(n,g);let a=()=>{let e=t.getVisibleCount(),r=Ps(ne.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Xe(yc({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!re.current){re.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=Ps(ne.current,g),i=t.getVisibleRows(e,e)[0]??null;Is(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}O.current=a;let o=t.subscribe(()=>{Ds(Se)&&xe(e=>e+1),a()}),l=()=>{Be.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,Me(e=>e+1),e=null},50))},u=null,d=()=>{i!=null&&delete i.dataset.overlayReveal,u!=null&&(clearTimeout(u),u=null)},f=()=>{i!=null&&Be.current!==!0&&(n.scrollTop>0||(i.dataset.overlayReveal=`true`,u!=null&&clearTimeout(u),u=setTimeout(()=>{d()},200)))},p=()=>{if(a(),n.scrollTop>0&&d(),Pe.current!=null&&y.current&&Lt.current(),Be.current===!0){y.current=!1;return}Ee(e=>e==null?e:null),l()},m=()=>{l(),f()},_=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),v=e=>{_.has(e.key)&&m()};n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,m,{passive:!0}),n.addEventListener(`touchmove`,m,{passive:!0}),n.addEventListener(`keydown`,v);let x=typeof ResizeObserver<`u`?new ResizeObserver(e=>{ne.current=(e[0]==null?null:Fs(e[0]))??Ns(n,g),a()}):null;return x?.observe(n),()=>{O.current=()=>{},o(),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,m),n.removeEventListener(`touchmove`,m),n.removeEventListener(`keydown`,v),e!=null&&clearTimeout(e),u!=null&&clearTimeout(u),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,ne.current=null,x?.disconnect()}},[t,g,s,c,h]),oc(()=>{N||M==null||R(!1)},[R,N,M]);let en=sc(()=>M==null?null:`${M.path}::${M.source}`,[M]);oc(()=>{if(en==null){m?.clearSlotContent(T);return}let t=Pe.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??zc(n.getBoundingClientRect()),close:e=>{Lt.current(e?.restoreFocus??!0)},restoreFocus:()=>{It.current&&Ft.current(Pe.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(T,i),e?.contextMenu?.onOpen?.(t.item,r),Qc(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Qc(i)}),()=>{m?.clearSlotContent(T)}},[en,e?.contextMenu,m]),oc(()=>{M!=null&&t.getItem(M.path)==null&&R()},[R,M,t]),oc(()=>{if(M==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(Rc(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&R())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),R())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[R,M]),oc(()=>{let e=C.current,n=S.current;if(e==null||n==null){ie.current=P;return}let r=P==null?null:E.current.get(P)??null,i=Ms(n),a=i?.dataset.itemPath??null,o=dt&&x.current===i,c=f&&ee.current===i,l=oe.current&&!ft,u=se.current??0,d=Fe.current,p=Ie.current,m=Le.current,g=Re.current,_=i!=null,v=j.current||_,y=ie.current!==P,b=p!=null&&p===P&&P!=null,w=!1,T=!1;if(mt!=null&&mt.id!==k.current){k.current=mt.id;let n=mt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,L-s))):kt;w=!0,T=Ls(e,n,s,L,Ot,mt.offset,t)}t.clearScrollRequest(mt.id)}let te=!w&&l&&Rs(e,F,s,L,Ot,u),D=!w&&d!=null&&d===P&&Rs(e,F,s,L,Ot,kt),ne=!w&&m!=null&&m.path===P&&Rs(e,F,s,L,Ot,m.viewportOffset),re=!w&&g!=null&&g.path===P&&e.scrollTop!==g.scrollTop;if(re&&(e.scrollTop=g.scrollTop),(re||T||D||ne||te||v&&y&&d!==P&&!b&&Is(e,F,s,L,kt))&&O.current(),w){ie.current=P;return}if(!v){ie.current=P;return}if(o){ie.current=P;return}if(c&&!l){ie.current=P;return}if(r==null){l&&F>=0&&(Rs(e,F,s,L,Ot,u),O.current()),ie.current=P;return}(y||l||d===P||p===P||m?.path===P||g?.path===P||a==null||a!==P)&&(js(r),d===P&&(Fe.current=null),p===P&&(Ie.current=null),m?.path===P&&(Le.current=null),g?.path===P&&(Re.current=null),oe.current=!1,se.current=null),ie.current=P},[t,F,P,jt,s,dt,ft,Tt,L,f,mt,h,kt,Ot,wt]);let tn=F>=0&&F>=I.visible.startIndex&&F<=I.visible.endIndex,nn=P!=null&&Et.some(e=>gc(e.row)===P),rn=tn||nn,an=et&&j.current===!0&&rn?P:null,on=ke===`pointer`?Te:null,sn=M?.path??ze.current??on??an??Te,cn=M?.source===`right-click`;oc(()=>{y.current&&M==null||Rt(ot(sn))},[M,ot,Tt,L,je,Et,sn,Rt,wt]);let ln=$(e=>{if(y.current||Rc(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&Ae(e=>e===`pointer`?e:`pointer`),Ee(e=>e===i?e:i)},[]),un=$(()=>{Ee(null)},[]);oc(()=>{if(!ht)return;let e=()=>{qt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),qt(),t.cancelDrag()}},[t,ht]);let dn=e=>{if(!ht||t.getDragSession()==null||he.current)return;let n=Tc(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Jt(t.getDragSession()?.target??null),Xt(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},fn=e=>{if(!ht||t.getDragSession()==null||he.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(z(),Kt(),t.setDragTarget(null))},pn=e=>{!ht||t.getDragSession()==null||he.current||(e.preventDefault(),V(e.clientX,e.clientY),t.completeDrag(),Gt(),z(),Kt(),pe.current=null)},mn=I.window.height,hn=I.window.offsetTop,gn=Math.min(0,L-mn),_n=Math.min(0,L-mn-kt),vn=Ce===P||oe.current,U=P!=null&&vn&&!jt&&F>=0?wt[F]??t.getVisibleRows(F,F)[0]??null:null,yn=U==null?null:zs(F,s,Tt,mn),bn=pe.current,xn=bt!=null&&bn!=null&&bn.path===bt&&bn.index>=Tt.start&&bn.index<=Tt.end,Sn=bt!=null&&bn!=null&&bn.path===bt&&!xn&&bn.path!==U?.path?bn:null,Cn=Sn==null?null:zs(Sn.index,s,Tt,mn),wn=Pc((F>=0?wt[F]??t.getVisibleRows(F,F)[0]??null:null)?.ancestorPaths.at(-1)??null),Tn=ft&&P!=null?Yc(o,P,!jt):void 0,En=M?.path??(ft?P:Ce),Dn=M?.path??Te,On=ot(sn),kn=N&&et&&!cn&&!dt&&On!=null&&De!=null&&sn!=null,An=N&&(kn||M!=null),jn=M?.anchorRect,Mn=jn==null&&On!=null&&De!=null&&(M!=null||kn)?De:null,Nn=jn==null?Mn==null?void 0:{top:`${Mn}px`}:{left:`${jn.left}px`,position:`fixed`,right:`auto`,top:`${jn.top}px`},Pn=cn?{opacity:`0`}:void 0,Fn=$((e,n,r,i)=>{let a=Us({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:ft,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c)}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=I.visible.startIndex&&n.index<=I.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(j.current=!0,we(e=>e===c?e:c),Ae(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&Vt(c,{targetOffset:`sticky-parents`})},[t,ft,I.visible.endIndex,I.visible.startIndex,Vt]),In=()=>{if(y.current||!et||sn==null||On==null)return;let e=t.getItem(sn);e!=null&&(Rt(On),It.current=!0,Ne({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:On.getAttribute(`aria-label`)??sn,path:e.getPath()},path:e.getPath(),source:`button`}))},Ln={contextHoverPath:Dn,contextMenuButtonTriggerEnabled:et,contextMenuButtonVisibility:tt,contextMenuEnabled:N,contextMenuRightClickEnabled:nt,contextMenuTriggerMode:$e,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:ht,draggedPathSet:vt,dragTarget:yt,gitLaneActive:st,gitStatusByPath:n,handleRowDragEnd:Qt,handleRowDragStart:Zt,handleRowTouchStart:H,ignoredGitDirectories:r,ignoredInheritanceCache:be,instanceId:o,itemHeight:s,onKeyDown:$t,onRowClick:Fn,openContextMenuForRow:zt,registerButton:rt,registerRenameInput:at,renameView:lt,renderDecorationForRow:Mt,resolveIcon:ct,shouldSuppressContextMenu:Ht,visualFocusPath:En},Rn={...Ln,registerButton:it};return Y(`div`,{ref:S,id:xt,"data-file-tree-context-menu-button-visibility":N&&et?tt:void 0,"data-file-tree-context-menu-trigger-mode":N?$e:void 0,"data-file-tree-has-context-menu-action-lane":N&&et?`true`:void 0,"data-file-tree-has-git-lane":st?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:ht?fn:void 0,onDragOver:ht?dn:void 0,onDrop:ht?pn:void 0,onKeyDown:$t,onPointerLeave:N?un:void 0,onPointerOver:N?ln:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[Y(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:wn}}),Y(`slot`,{name:w,"data-type":`header-slot`}),f?Y(`div`,{"data-file-tree-search-container":!0,"data-open":ft?`true`:`false`,children:Y(`input`,{ref:ee,"aria-activedescendant":Tn,"aria-controls":xt,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ge?`true`:void 0,value:pt,onBlur:()=>{d===`retain`&&!qe.current||t.closeSearch()},onFocus:Je,onPointerDown:Je,onInput:e=>{Je();let n=e.currentTarget;t.setSearch(n.value)}})}):null,Y(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&Ze&&Et.length>0?Y(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:Y(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${St}px`},children:Et.map((e,t)=>el(Rn,e.row,`sticky:${gc(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${Et.length-t}`}}))})}):null,Y(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${Ot}px`},children:[Y(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${hn}px`}}),Y(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${mn}px`,top:`${gn}px`,bottom:`${_n}px`},children:[tl(Ln,Tt,At),U!=null&&yn!=null?el(Ln,U,`parked:${U.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:bt===U.path?`none`:void 0,position:`absolute`,right:`0`,top:`${yn}px`}}):null,Sn!=null&&Cn!=null?el(Ln,Sn,`parked-drag:${Sn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${Cn}px`}}):null]})]})]}),N?Y(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":An?`true`:`false`,style:Nn,children:[Y(`button`,{ref:v,type:`button`,"data-type":te,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":M==null?`false`:`true`,"data-visible":kn?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),M!=null){R();return}In()},tabIndex:-1,style:Pn,children:Y(Xo,{...ct(`file-tree-icon-ellipsis`)})}),M==null?null:Y(`slot`,{name:T})]}):null,M==null?null:Y(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),R()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),R()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var rl={hydrateRoot:(e,t)=>{Go(xo(nl,t),e)},renderRoot:(e,t)=>{Wo(xo(nl,t),e)},unmountRoot:e=>{Wo(null,e)}};function il(e,t){rl.renderRoot(e,t)}function al(e,t){rl.hydrateRoot(e,t)}function ol(e){rl.unmountRoot(e)}var sl=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}};Array.isArray;var cl=0;function ll(e){return e!=null&&e.length>0?e:(cl+=1,`pst_ft_${cl}`)}function ul({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??_t)}function dl(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function fl(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function pl(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var ml=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new sl;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=ll(a),this.#p=Ga(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=gt(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new Ba({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(ol(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=Ka(this.#p,e);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&il(n.wrapper,this.#w())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){Array.isArray(e)?this.#t.resetPaths(e,t):this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),il(t.wrapper,this.#w()))}setGitStatus(e){let t=Ga(e,this.#p);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&il(n.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),il(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),al(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),il(r,this.#w())}#C(){return{initialViewportHeight:ul({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(w,e());return}this.#l.setSlotHtml(w,this.#e?.header?.html??null)}#k(e){let t=pl(e).find(e=>fl(e)),n=dl(dt(mt(this.#m).set));n!=null&&(t==null||t.outerHTML!==n.outerHTML)&&(t==null?e.prepend(n):t.replaceWith(n))}#A(e){let t=pl(e),n=t.find(e=>fl(e)),r=t.filter(e=>e!==n),i=mt(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=dl(i);if(a==null){for(let e of r)e.remove();return}if(r.length!==1||r[0].outerHTML!==a.outerHTML){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=mt(this.#m);t.colored&&pt(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${x}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}(this.#g?.parentNode!==e||this.#_!==this.#h)&&(this.#g??=document.createElement(`style`),this.#g.setAttribute(x,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=xt(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Tt(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function hl(e){let[t]=(0,E.useState)(()=>new ml(e)),n=(0,E.useRef)({timeout:null,model:t});return(0,E.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function gl(e){return e.name.startsWith(`.`)}function _l(e,t,n=0){return f(e,p,d.of(e,`tree`,e?.capabilities.version??0,t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),{...i,entries:i.entries.filter(e=>!gl(e))}})}function vl(){return{known:new Set,projected:new Map}}function yl(e,t){t.known.clear(),t.projected.clear(),e.resetPaths([])}function bl(e,t,n){t.length===0&&yl(e,n);for(let{request:r,listing:i}of t){let t=`${r?.path??i.path}:${String(r?.offset??0)}`,a=i.entries.filter(e=>e.type!==`symlink`).map(e=>xl(i.path,e.name,e.type)),o=n.projected.get(t)??[];n.projected.set(t,a);let s=new Set([...n.projected.values()].flat());for(let t of o)if(!s.has(t)){e.getItem(t)&&e.remove(t,{recursive:!0});for(let e of n.known)(e===t||t.endsWith(`/`)&&e.startsWith(t))&&n.known.delete(e)}Sl(e,i,n.known)}}function xl(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function Sl(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>xl(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));i.length>0&&e.batch(i.map(e=>({type:`add`,path:e}))),n.add(t.path);for(let e of r)n.add(e);return i}function Cl(e,t){let n=t===`/`?`/`:t.replace(/\/+$/,``);if(n!==`/`&&e!==n&&!e.startsWith(`${n}/`))return[];let r=n===`/`?e.split(`/`).filter(Boolean):e.slice(n.length).split(`/`).filter(Boolean),i=[n],a=n;for(let e of r.slice(0,-1))a=`${a===`/`?``:a}/${e}`,i.push(a);return i}function wl({app:e,rootPath:t,activePath:n}){let r=o(),i=l(e),a=(0,E.useCallback)(t=>e.capabilities.subscribe(t),[e]),s=(0,E.useCallback)(()=>e.capabilities.version,[e]),c=(0,E.useSyncExternalStore)(a,s,s),f=(0,E.useMemo)(()=>({app:e,rootPath:t,computerId:i,version:c}),[e,t,i,c]),[p,m]=(0,E.useState)(null),h=p?.scope===f?p:null,g=n?Cl(n,t):[],_=h?.activePath===n?h.path:g.at(-1)??t,v=new Map;for(let e of[t,...g])v.set(`${e}:0`,{path:e,offset:0});for(let e of h?.pages??[])v.set(`${e.path}:${String(e.offset)}`,e);let y=[...v.values()],b=(t,n)=>d.of(e,`tree`,c,t,n);return{scope:f,snapshot:u({queries:y.map(({path:t,offset:n})=>_l(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:y[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),focusedPath:_,requestPage:(e,t)=>{let i=e.replace(/\/+$/,``)||`/`,a=b(i,t);r.getQueryState(a)?.status===`error`&&r.invalidateQueries({queryKey:a,exact:!0}),m(e=>({scope:f,activePath:n,path:i,pages:[...e?.scope===f?e.pages.filter(e=>e.path!==i||e.offset!==t):[],{path:i,offset:t}]}))},reload:()=>{r.invalidateQueries({queryKey:d.of(e,`tree`,c)})}}}var Tl=()=>globalThis.matchMedia(`(pointer: coarse)`).matches?44:32,El=()=>`Library`,Dl=(e,t)=>`${El()}${t.slice(e.length)}`,Ol=(e,t)=>`${e}${t.replace(/\/$/,``).slice(El().length)}`,kl=e=>e===void 0?`${El()}/`:`${El()}/${e}/`;function Al(e){if(!e.endsWith(`/`))return null;let t=e.slice(0,-1);return t===El()?{folder:void 0}:t.startsWith(`${El()}/`)?{folder:t.slice(El().length+1)}:null}var jl=e=>e.replace(/\/$/,``)===El(),Ml=e=>({flex:1,minHeight:0,"--trees-item-height":`${String(e)}px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--stipe-hairline)`,"--trees-focus-ring-color-override":`var(--color-primary)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`13px`,"--trees-search-bg-override":`var(--color-base-200)`,"--trees-search-fg-override":`var(--color-base-content)`});function Nl({app:e,root:t,activeFolder:n,active:i=!0,mode:o,onSelectFolder:l,onDrop:u,onRename:d,onNewFolder:f,onMoveRows:p,canWrite:h,version:g}){let y=kl(n),{scope:b,snapshot:x,requestPage:S,reload:C}=wl({app:e,rootPath:t,activePath:`${c(t,n)}/.`}),ee=(0,E.useRef)(!1),w=(0,E.useRef)({quiet:!1,root:t,mode:o,onSelectFolder:l,onDrop:u,onRename:d,onNewFolder:f,onMoveRows:p,requestPage:S});w.current={quiet:w.current.quiet,root:t,mode:o,onSelectFolder:l,onDrop:u,onRename:d,onNewFolder:f,onMoveRows:p,requestPage:S};let T=o===`browse`&&h,[te]=(0,E.useState)(Tl),{model:O}=hl({paths:[],itemHeight:te,initialExpansion:1,flattenEmptyDirectories:!1,search:o===`browse`,composition:{contextMenu:{enabled:o===`browse`}},onSelectionChange(e){if(w.current.quiet||ee.current)return;let t=e.at(-1);if(t===void 0||e.length!==1)return;let n=Al(t);n!==null&&(w.current.requestPage(Ol(w.current.root,t),0),w.current.onSelectFolder(n.folder))},dragAndDrop:T?{canDrag:e=>e.every(e=>!jl(e)),canDrop:({target:e})=>e.kind===`directory`&&e.directoryPath!==null&&Al(e.directoryPath)!==null,onDropComplete:({draggedPaths:e,target:t})=>{let n=t.directoryPath===null?null:Al(t.directoryPath);n!==null&&w.current.onDrop?.(e.map(e=>Ol(w.current.root,e)),n.folder)}}:void 0,renaming:T?{canRename:e=>!jl(e.path),onRename:({sourcePath:e,destinationPath:t})=>{let n=t.replace(/\/$/,``).split(`/`).at(-1);n!==void 0&&w.current.onRename?.(Ol(w.current.root,e),n)}}:void 0}),ne=(0,E.useRef)(vl());(0,E.useLayoutEffect)(()=>{yl(O,ne.current)},[O,b,g]);let k=(0,E.useRef)(g);(0,E.useEffect)(()=>{k.current!==g&&(k.current=g,C())},[C,g]),(0,E.useLayoutEffect)(()=>{let e=x.listings.map(({request:e,listing:n})=>({request:e,listing:{...n,path:Dl(t,n.path),entries:n.entries.filter(e=>e.type===`directory`)}}));bl(O,e,ne.current)},[O,t,x.listings]);let re=(0,E.useRef)(null);return(0,E.useLayoutEffect)(()=>{w.current.quiet=!0;try{if(!i){re.current=null;for(let e of O.getSelectedPaths())O.getItem(e)?.deselect();return}e()}finally{w.current.quiet=!1}function e(){if(re.current===y)return;let e=O.getItem(y);if(!e)return;re.current=y;for(let e of O.getSelectedPaths())e!==y&&O.getItem(e)?.deselect();e.isSelected()||e.select();let t=y.slice(0,-1).split(`/`);for(let e=1;e<t.length;e+=1){let n=O.getItem(`${t.slice(0,e).join(`/`)}/`);n&&`expand`in n&&!n.isExpanded()&&n.expand()}}},[i,y,O,x.listings]),(0,E.useEffect)(()=>{x.failure&&s.error(a(x.failure).message,{id:`prints-tree-error`,toasterId:`prints-generation-notices`,action:{label:`Retry`,onClick:C}})},[C,x.failure]),(0,D.jsx)(`div`,{className:`prints-tree`,"data-library-tree":o,onDragStartCapture:()=>{ee.current=!0},onDragEnd:()=>{ee.current=!1},onDrop:()=>{ee.current=!1},children:(0,D.jsx)(j,{model:O,className:`prints-tree-view`,style:Ml(te),renderContextMenu:o===`browse`?(e,n)=>{let i=Al(e.path);return(0,D.jsxs)(`div`,{className:`flex min-w-40 flex-col gap-xs p-xs`,role:`menu`,children:[i===null?null:(0,D.jsxs)(r,{className:`w-full justify-start`,disabled:!h,role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),w.current.onNewFolder?.(i.folder)},children:[(0,D.jsx)(_,{"aria-hidden":`true`}),` New folder`]}),(0,D.jsxs)(r,{className:`w-full justify-start`,disabled:!h||jl(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),O.startRenaming(e.path)},children:[(0,D.jsx)(v,{"aria-hidden":`true`}),` Rename`]}),(0,D.jsxs)(r,{className:`w-full justify-start`,disabled:!h||jl(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1});let r=O.getSelectedPaths(),i=r.includes(e.path)?r:[e.path];w.current.onMoveRows?.(i.map(e=>Ol(t,e)))},children:[(0,D.jsx)(m,{"aria-hidden":`true`}),` Move to…`]})]})}:void 0})})}function Pl({view:e,onView:t,onNewFolder:n,canWrite:i,...a}){return(0,D.jsxs)(`nav`,{className:`prints-rail`,"aria-label":`Library`,children:[(0,D.jsxs)(`div`,{className:`prints-rail-views`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`all`?`page`:void 0,onClick:()=>{t({kind:`all`})},children:[(0,D.jsx)(g,{"aria-hidden":!0,size:16}),` All prints`]}),(0,D.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`favorites`?`page`:void 0,onClick:()=>{t({kind:`favorites`})},children:[(0,D.jsx)(h,{"aria-hidden":!0,size:16}),` Favorites`]})]}),(0,D.jsxs)(`div`,{className:`prints-rail-head`,children:[(0,D.jsx)(`span`,{children:`Folders`}),(0,D.jsx)(r,{size:`sm`,variant:`ghost`,"aria-label":`New folder`,title:`New folder`,disabled:!i,onClick:()=>{n(e.kind===`folder`?e.folder:void 0)},children:(0,D.jsx)(_,{"aria-hidden":!0,size:16})})]}),(0,D.jsx)(Nl,{...a,mode:`browse`,canWrite:i,activeFolder:e.kind===`folder`?e.folder:void 0,active:e.kind===`folder`,onNewFolder:n,onSelectFolder:e=>{t({kind:`folder`,folder:e})}})]})}export{Pl as LibraryRail,Nl as LibraryTree};
1266
+ }`}var St=new WeakMap;function Ct(e){let t=St.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(S,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),St.set(e,i),i}function I(e,t){if(!e.isConnected)return;let n=Ct(t);if(n==null)return;let r=t.querySelector(`style[${C}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(C,``),t.appendChild(i)),i.textContent=`:host { ${ee}: ${n}px; }`}var wt;function L(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){wt??(wt=new CSSStyleSheet,wt.replaceSync(bt(vt)));let t=!1;try{e.adoptedStyleSheets=[wt],t=!0}catch{}if(t){e.querySelector(`style[${b}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(b,``),t.textContent=bt(vt),e.prepend(t)}}function Tt(e,t){Et(e,t),L(t),I(e,t)}function Et(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Tt(this,e)}}if(customElements.define(y,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(y)))e instanceof HTMLElement&&Tt(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Dt=5,Ot=32,kt=128;function At(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function jt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Mt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Nt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Pt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Ft(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function It(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,zt(e,t)}function Lt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Nt(e).get(t);if(i===void 0)return;let a=i>>Dt;e.childVisibleChunkSums[a]+=r}function R(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Bt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=Ot}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function Rt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Dt;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Dt}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function zt(e,t){if(t.childIds.length<kt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/Ot),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>Dt]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Bt(e,t,n,r){let i=Math.min(t.childIds.length,n+Ot),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Vt=7,Ht=3,Ut=8,Wt=4;function z(e,t,n=0){return e<<Wt|n<<Ht|t}function Gt(e){return e.depthAndFlags>>>Wt}function Kt(e){return(e.depthAndFlags&Ut)>>Ht}function B(e){return(e.depthAndFlags&Ut)!==0}function qt(e){return e.depthAndFlags&Vt}function V(e,t){return(qt(e)&t)!==0}function Jt(e,t){e.depthAndFlags|=t}function Yt(e,t){e.depthAndFlags=z(t,qt(e),Kt(e))}var Xt=Symbol(`benchmarkInstrumentation`);function Zt(e,t){return t==null||Object.defineProperty(e,Xt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Qt(e){return e==null?null:e[Xt]??null}function H(e,t,n){return e==null?n():e.measurePhase(t,n)}function $t(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function en(e){return e>=48&&e<=57}function tn(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!en(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&en(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function nn(e){let t=e.toLowerCase();return{lowerValue:t,tokens:tn(t)}}function rn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function an(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=rn(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function on(e,t,n){let r=an(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function sn(e,t){return on(e,t,nn)}function cn(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function ln(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=cn(e,r);return a===cn(t,r)?sn(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function un(e,t){return ln(e,t)}function dn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=nn(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=cn(e,n);return o===cn(t,n)?on(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function fn(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=nn(r);return e.sortKeyById[t]=i,i}function pn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function mn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function hn(e){let{hasTrailingSlash:t,segments:n}=mn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function gn(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=mn(e);return{requiresDirectory:t,segments:n}}function _n(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[nn(``)]}}function vn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function U(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var yn=Symbol(`pathStorePreparedInputKind`);function bn(e,t){return e[yn]=t,e}function xn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function Sn(e,t,n){return n==="default"?un(e,t):n(xn(e),xn(t))}function Cn(){return{depthAndFlags:z(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function wn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function Tn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function En(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Dn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function On(e,t={}){return Pn(e,t).map(e=>e.path)}function kn(e,t={}){let n=Pn(e,t);return bn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function An(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return bn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function jn(e){let t=e,n=t.preparedPaths;if(t[yn]===`prepared`&&n!=null)return n;if(!En(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Mn(e){let t=e;return t[yn]===`presorted`&&t.presortedPaths!=null||Dn(t.presortedPaths)?t.presortedPaths:null}function Nn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Pn(e,t={}){let n=pn(t),r=Qt(t);$t(r,`workload.inputFiles`,e.length);let i=H(r,`store.preparePathEntries.parse`,()=>e.map(e=>hn(e)));return H(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>Sn(e,t,n.sort))),i}var Fn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Cn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=_n();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Qt(e),this.options=pn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,At())}appendPaths(e){return H(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>hn(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,H(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return H(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null){if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:z(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:z(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d,m=a+1}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:z(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=hn(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null){if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:z(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:z(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=hn(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(H(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||H(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?dn(this.lastPreparedPath,e,this.segmentSortKeyCache):Sn(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=Tn(e),i=n==null?0:Tn(n),a=n==null?0:wn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=vn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Pt(i,s),s}createFileChildUnchecked(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),a}getOrCreateDirectoryChild(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!B(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),this.directories.set(a,At()),a}createDirectoryChild(e,t){let n=vn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:z(Gt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Pt(r,a),this.directories.set(a,At()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(V(n,1))throw Error(`Duplicate path: "${t}"`);Jt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,jt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=jt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;B(n)&&this.directories.set(t,At());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Pt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return It(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function In(e,t=`closed`,n=null){let r=Rn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Ln(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Rn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function zn(e,t){return V(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&Gt(t)<=e.defaultExpansion}function Bn(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:zn(e,n)}function Vn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=zn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Hn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function Un(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Wn(e,t){let n=Hn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Gn(e,t){let n=Hn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Kn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function qn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Jn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Yn(e,t){e.directoryLoadInfoById.delete(t)}function Xn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function rr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function ir(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function ar(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function or(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function sr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function cr(e,t,n){return{...n,visibleCountDelta:yr(e)-t}}function lr(e,t){let n=yr(e),r=Ln();e.transactionStack.push(r);try{t()}catch(t){throw fr(e,r,!1),t}fr(e,r,!0,yr(e)-n)}function ur(e,t){let n=e.instrumentation;if(n==null){dr(e,t);return}H(n,`store.events.record`,()=>dr(e,t))}function dr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){_r(e,t);return}n.events.push(t),gr(n,t)}function fr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?hr(i,t):H(n,`store.events.batch.merge`,()=>hr(i,t));return}let a=pr(t,r),o=e.instrumentation;if(o==null){_r(e,a);return}H(o,`store.events.batch.commit`,()=>_r(e,a))}function pr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function mr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function hr(e,t){for(let n of t.events)e.events.push(n);mr(e,t)}function gr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function _r(e,t){let n=e.instrumentation;if(n==null){vr(e,t);return}H(n,`store.events.emit`,()=>vr(e,t))}function vr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function yr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function br(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||V(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!B(a)?null:i}function xr(e,t){let n=t;for(;;){let t=br(e,n);if(t==null)return n;n=t}}function Sr(e,t){let n=[t],r=t;for(;;){let t=br(e,r);if(t==null)return n;n.push(t),r=t}}function Cr(e,t){let n=t==null?e.snapshot.rootId:Mr(e,t);return n==null?[]:Pr(e,n)}function wr(e,t){let n=hn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Yr(e,Jr(e,r)),{createdNodeIds:a,directoryId:o}=Fr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(V(n,1))throw Error(`Path already exists: "${t}"`);Jt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Lr(e,o,n.basename),s.add(c);kr(e,o);let l=Yr(e,o);return Zn({affectedAncestorIds:jr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Xr(i,l)})}function Tr(e,t,n){let r=Mr(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(V(i,2))throw Error(`The root node cannot be removed`);if(B(i)&&G(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Yr(e,a),s=Kr(e,r);Br(e,a,r,i.nameId),qr(e,a),kr(e,a);let c=Yr(e,a);return Qn({affectedAncestorIds:jr(e,a),affectedNodeIds:s,path:t,projectionChanged:Xr(o,c),recursive:n.recursive===!0})}function Er(e,t,n,r){let i=Mr(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(V(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Wr(e,i,n),c=Yr(e,a.parentId),l=Yr(e,s.parentId),u=U(e.snapshot.segmentTable,a.nameId),d=vn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&ei(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Mt(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Gr(e,p,o,Kt(a))===`skip`)return null;let m=a.parentId;Br(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),$r(e,i),zr(e,s.parentId,i),qr(e,m),e.pathCacheVersion++,kr(e,m),s.parentId!==m&&kr(e,s.parentId);let h=Yr(e,m),g=Yr(e,s.parentId);return $n({affectedAncestorIds:[...new Set([...jr(e,m),...jr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:Zr([c,l],[h,g]),to:W(e,i)})}function Dr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Or(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=Dr(e,t);if(r!=null)return r;if(V(n,2))return Or(e,t,``);let i=W(e,n.parentId),a=U(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Or(e,t,B(n)?`${o}/`:o)}function kr(e,t){let n=e.instrumentation;if(n==null){ni(e,t);return}H(n,`store.recomputeCountsUpwardFrom`,()=>ni(e,t))}function Ar(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!B(o)){ti(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){ti(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function jr(e,t){let n=[],r=t;for(;r!=null;){let t=K(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Mr(e,t){if(t.length===0)return e.snapshot.rootId;let n=gn(t);return Nr(e,n.segments,n.requiresDirectory)}function Nr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=G(e,r),a=Mt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!B(i)?null:r}function G(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function K(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Pr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||V(n,4))return[];if(!B(n))return[W(e,t)];if(G(e,t).childIds.length===0)return V(n,1)&&!V(n,2)?[W(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||V(n,4)){i.pop();continue}if(!B(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){V(n,1)&&!V(n,2)&&r.push(W(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function Fr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=vn(e.snapshot.segmentTable,i),a=G(e,r),o=Mt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Ir(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Ir(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:z(Gt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,At()),zr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Lr(e,t,n){let r=vn(e.snapshot.segmentTable,n),i=G(e,t);if(Mt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ii(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:z(Gt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),zr(e,t,o),e.activeNodeCount++,o}function Rr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Vr(e,n,o)<0?i=a:r=a+1}return r}function zr(e,t,n){let r=G(e,t),i=K(e,n);Mt(e.snapshot.nodes,r).set(i.nameId,n),Lt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Rr(e,r,n);r.childIds.splice(a,0,n),Ft(r,a),zt(e.snapshot.nodes,r)}function Br(e,t,n,r){let i=G(e,t),a=Nt(i),o=a.get(n)??-1;Mt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Lt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Ft(i,o),zt(e.snapshot.nodes,i))}function Vr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Hr(e,t,n):r(Ur(e,t),Ur(e,n))}function Hr(e,t,n){let r=K(e,t),i=K(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=an(fn(e.snapshot.segmentTable,r.nameId),fn(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=U(e.snapshot.segmentTable,r.nameId),c=U(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Ur(e,t){let n=K(e,t),r=W(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:U(e.snapshot.segmentTable,n.nameId),depth:Gt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Wr(e,t,n){let r=K(e,t),i=Mr(e,n);if(i!=null){let t=K(e,i);if(B(t))return{basename:U(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=gn(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=gn(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Nr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Gr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${W(e,t)}"`);let i=K(e,t);if(Kt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(i)&&G(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Kr(e,t),Br(e,a,t,o),qr(e,a),kr(e,a),`handled`}function Kr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=K(e,t.nodeId);if(t.visitedChildren||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Jt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Yn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=G(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function qr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!B(t)||V(t,2)||G(e,n).childIds.length>0)return;Jt(t,1),n=t.parentId===n?null:t.parentId}}function Jr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Mt(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!B(K(e,i)))break;n=i}return n}function Yr(e,t){let n=Qr(e,t);if(n==null)return null;let r=xr(e,n),i=K(e,r),a=n===r?null:Sr(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:Kt(i)})}function Xr(e,t){return Zr([e],[t])}function Zr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Qr(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!B(t)||V(t,2))return null;if(!Bn(e,n,t))return n;n=t.parentId}return null}function $r(e,t){let n=K(e,t);if(Yt(n,(t===e.snapshot.rootId?-1:Gt(K(e,n.parentId)))+1),!B(n))return;let r=G(e,t);for(let t of r.childIds)$r(e,t)}function ei(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=K(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function ti(e,t,n=K(e,t),r=!1){let i=e.instrumentation;if(i==null){ri(e,t,n,r);return}H(i,`store.recomputeNodeCounts`,()=>ri(e,t,n,r))}function ni(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(ti(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Lt(G(e,s),n,a,o),n=s}}function ri(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?It(e.snapshot.nodes,i):H(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>It(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,V(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=br(e,t)==null?Bn(e,t,n)?1+o:1:o}function ii(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function ai(e){return e!=null&&!V(e,4)}function oi(e,t){let n=e.snapshot.nodes[t];return!ai(n)||!B(n)||V(n,2)?null:n}function si(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ai(e.snapshot.nodes[n])&&(t+=1);return t}function ci(e){return Math.max(0,e.valueById.length-1)}function li(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:si(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ci(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function ui(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function di(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)oi(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)oi(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function fi(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)oi(e,n)!=null&&Un(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function pi(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Mr(e,n);t!=null&&Vn(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=Mr(e,n);t!=null&&Vn(e,t,!1,K(e,t))}}function mi(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Mr(e,n.path);t!=null&&oi(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function hi(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function gi(e){let t=e.snapshot.segmentTable,n=_n();for(let r of e.snapshot.nodes)if(ai(r)){if(V(r,2)){r.nameId=0;continue}r.nameId=vn(n,U(t,r.nameId))}e.snapshot.segmentTable=n}function _i(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ai(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ai(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[K(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),It(e.snapshot.nodes,n)}}function vi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ai(n))break;--t}e.snapshot.nodes.length=t+1}function yi(e){let t=di(e),n=fi(e);H(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>hi(e)),H(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>gi(e)),H(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>_i(e)),H(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>vi(e)),H(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>pi(e,t)),H(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>mi(e,n)),H(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Ar(e,e.snapshot.rootId))}function bi(e){let t=di(e),n=fi(e),r=H(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Cr(e)),i=Zt({...e.snapshot.options},e.instrumentation),a=H(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Fn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,H(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>pi(e,t)),H(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>mi(e,n)),H(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Ar(e,e.snapshot.rootId))}function xi(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Si(e,t){let n=li(e);t===`stable`?H(e.instrumentation,`store.cleanup.stable`,()=>yi(e)):H(e.instrumentation,`store.cleanup.aggressive`,()=>bi(e));let r=li(e);return ui(t,t===`stable`,n,r)}var Ci=64;function wi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function q(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function Ti(e,t,n,r){let i=K(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Ei(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Gi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Ti(e,t.cursor,t.index,n)}}function Di(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=R(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Oi(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Oi(e,t,n,r,i,a,o,s){if(!B(K(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=zi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!B(l)||!Bn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Di(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function ki(e,t){let n=q(e);if(t<0||t>=n)return null;let r=Di(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>W(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Ei(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Gi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Ti(e,r.cursor,r.index,n)}}function Ai(e,t,n){let r=e.instrumentation,i=q(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Wi(e,o+1);let t=[],n=Ii(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Gi(e,n);t.push(r),n=Vi(e,n)}return t}let s=[],c=0,l=0,u=H(r,`store.getVisibleSlice.selectFirstRow`,()=>Ii(e,a));for(let t=a;t<=o&&u!=null;t++){let t=H(r,`store.getVisibleSlice.materializeRow`,()=>Gi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=H(r,`store.getVisibleSlice.advanceCursor`,()=>Vi(e,u))}return $t(r,`workload.visibleRowsRead`,s.length),$t(r,`workload.flattenedRowsRead`,c),$t(r,`workload.flattenedSegmentsRead`,l),s}function ji(e,t=q(e)){let n=e.instrumentation;return n==null?Ui(e,t):H(n,`store.getVisibleTreeProjection`,()=>Ui(e,t))}function Mi(e){return Hi(ji(e))}function Ni(e,t){let n=Mr(e,t);if(n==null||n===e.snapshot.rootId||B(K(e,n))&&xr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=K(e,i).parentId,n=G(e,t),s=Nt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Rt(a,n,s),t!==o){let n=K(e,t),a=br(e,t);if(!Bn(e,t,n)&&a!==i)return null;xr(e,t)===t&&(r+=1)}i=t}return r}function Pi(e,t){let n=Mr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return Bn(e,n,r)?null:(Vn(e,n,!0,r),kr(e,n),er({affectedAncestorIds:jr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Fi(e,t){let n=Mr(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return Bn(e,n,r)?(Vn(e,n,!1,r),kr(e,n),tr({affectedAncestorIds:jr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Ii(e,t){return t<0||t>=q(e)?null:Li(e,e.snapshot.rootId,t,-1)}function Li(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?R(e.snapshot.nodes,i,n):H(a,`store.getVisibleSlice.selectChildIndex`,()=>R(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ri(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ri(e,t,n,r){if(!B(K(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=zi(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!B(a)||!Bn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Li(e,i.terminalNodeId,n-1,i.visibleDepth)}function zi(e,t,n){return B(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:xr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:H(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>xr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Bi(e,t){let n=K(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||br(e,r)!==t}function Vi(e,t){let n=K(e,t.terminalNodeId);if(B(n)){let r=G(e,t.terminalNodeId);if(Bn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ri(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=K(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=G(e,n),o=Nt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Ri(e,s,0,i);Bi(e,r)&&i--,r=n}}function Hi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Ui(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(Ci);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=wi(o,y);let x,S=_;if(B(v))S=f?xr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:W(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&B(C)&&Bn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Wi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!B(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:W(e,f)};continue}let h=l?xr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Gi(e,g);let _=i[h];_!=null&&B(_)&&Bn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Gi(e,t){let n=K(e,t.terminalNodeId),r=B(n)?Ki(e,t):null,i=W(e,t.terminalNodeId),a=U(e.snapshot.segmentTable,n.nameId),o=B(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?Sr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:U(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):H(c,`store.getVisibleSlice.flatten.collectSegments`,()=>Sr(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:U(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:B(n)&&Bn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ki(e,t){if(t.headNodeId===t.terminalNodeId)return Un(e,t.terminalNodeId);let n=Sr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Un(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var qi=8;function Ji(e){let{nodes:t,directories:n,rootId:r,options:i}=e,a=t.length,o=new Int32Array(a),s=new Int32Array(a),c=new Int32Array(a),l=new Int32Array(a),u=new Int32Array(a),d=new Int32Array(a),f=new Int32Array(a);for(let e=0;e<a;e+=1){let n=t[e];n!=null&&(o[e]=n.parentId,s[e]=n.nameId,c[e]=n.depthAndFlags,l[e]=n.subtreeNodeCount,u[e]=n.visibleSubtreeCount)}let p=0;for(let e of n.values())p+=e.childIds.length;let m=new Int32Array(p),h=0;for(let[e,t]of n){let n=t.childIds;d[e]=h,f[e]=n.length;for(let e=0;e<n.length;e+=1)m[h]=n[e],h+=1}return{nodeCount:a,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:o,nameId:s,depthAndFlags:c,subtreeNodeCount:l,visibleSubtreeCount:u,childStart:d,childCount:f,childIdsFlat:m}}function Yi(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:a,visibleSubtreeCount:o,childStart:s,childCount:c,childIdsFlat:l}=e;for(let e=t-1;e>=1;--e){if((i[e]&qi)===0)continue;let t=s[e],n=c[e],u=0,d=0;for(let e=0;e<n;e+=1){let n=l[t+e];u+=a[n],d+=o[n]}a[e]=1+u;let f;f=r&&n===1?(i[l[t]]&qi)===0?1+d:d:1+d,o[e]=f}let u=s[n],d=c[n],f=0,p=0;for(let e=0;e<d;e+=1){let t=l[u+e];f+=a[t],p+=o[t]}a[n]=1+f,o[n]=p}function Xi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!B(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&zt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,zt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Zi(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Ji(e.snapshot);Yi(i);let a=i.subtreeNodeCount,o=i.visibleSubtreeCount;for(let e=0;e<n.length;e+=1){let t=n[e];t!=null&&(t.subtreeNodeCount=a[e],t.visibleSubtreeCount=o[e])}for(let[e,i]of t){let t=i.childIds,a=t.length,o=0,s=0;for(let e=0;e<a;e++){let r=t[e];if(r==null)continue;let i=n[r];o+=i.subtreeNodeCount,s+=i.visibleSubtreeCount}i.totalChildSubtreeNodeCount=o,i.totalChildVisibleSubtreeCount=s,(e===r||a>=128)&&zt(n,i)}}function Qi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var $i=class e{#e;constructor(e={}){let t=Qt(e),n=H(t,`store.builder.create`,()=>new Fn(e));if(e.preparedInput!=null){let t=Mn(e.preparedInput);t==null?n.appendPreparedPaths(jn(e.preparedInput),!1):n.appendPresortedPaths(t,Nn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(H(t,`store.preparePathEntries`,()=>Pn(r,e)))}let r=H(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=H(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=H(t,`store.state.create`,()=>In(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:H(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Qi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&H(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?H(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>Zi(this.#e)):H(t,`store.state.initializeOpenVisibleCounts`,()=>Xi(this.#e)):H(t,`store.state.recomputeCounts`,()=>Ar(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return On(e,t)}static prepareInput(e,t={}){return kn(e,t)}static preparePresortedInput(e){return An(e)}list(e){return H(this.#e.instrumentation,`store.list`,()=>Cr(this.#e,e))}add(e){H(this.#e.instrumentation,`store.add`,()=>{let t=q(this.#e);ur(this.#e,cr(this.#e,t,wr(this.#e,e)))})}remove(e,t={}){H(this.#e.instrumentation,`store.remove`,()=>{let n=q(this.#e);ur(this.#e,cr(this.#e,n,Tr(this.#e,e,t)))})}move(e,t,n={}){H(this.#e.instrumentation,`store.move`,()=>{let r=q(this.#e),i=Er(this.#e,e,t,n);i!=null&&ur(this.#e,cr(this.#e,r,i))})}batch(e){lr(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision})}})}getVisibleCount(){return H(this.#e.instrumentation,`store.getVisibleCount`,()=>q(this.#e))}getVisibleSlice(e,t){return H(this.#e.instrumentation,`store.getVisibleSlice`,()=>Ai(this.#e,e,t))}getVisibleRowContext(e){return H(this.#e.instrumentation,`store.getVisibleRowContext`,()=>ki(this.#e,e))}getVisibleTreeProjection(){return Mi(this.#e)}getVisibleTreeProjectionData(e){return ji(this.#e,e)}getVisibleIndex(e){return H(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ni(this.#e,e))}getPathInfo(e){return H(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Mr(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:Gt(n),kind:B(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return H(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Bn(this.#e,t,n)})}expand(e){H(this.#e.instrumentation,`store.expand`,()=>{let t=q(this.#e),n=Pi(this.#e,e);n!=null&&ur(this.#e,cr(this.#e,t,n))})}collapse(e){H(this.#e.instrumentation,`store.collapse`,()=>{let t=q(this.#e),n=Fi(this.#e,e);n!=null&&ur(this.#e,cr(this.#e,t,n))})}on(e,t){return Xn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Un(this.#e,t)}markDirectoryUnloaded(e){H(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(G(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=q(this.#e);Gn(this.#e,t),ur(this.#e,cr(this.#e,n,nr({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return H(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=q(this.#e),r=Wn(this.#e,t);return ur(this.#e,cr(this.#e,n,rr({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return H(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Un(this.#e,n)!==`loading`||!qn(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=q(this.#e),a=[];for(let e of t.operations){ea(r,e);let t=q(this.#e);switch(e.type){case`add`:a.push(cr(this.#e,t,wr(this.#e,e.path)));break;case`remove`:a.push(cr(this.#e,t,Tr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Er(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(cr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ur(this.#e,cr(this.#e,i,ir({affectedAncestorIds:jr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return H(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=q(this.#e),r=Kn(this.#e,t,e.attemptId);return ur(this.#e,cr(this.#e,n,ar({affectedAncestorIds:jr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return H(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=q(this.#e),i=Jn(this.#e,n,e.attemptId,t);return ur(this.#e,cr(this.#e,r,or({affectedAncestorIds:jr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:W(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return H(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(xi(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=q(this.#e),n=Si(this.#e,e.mode??`stable`);return ur(this.#e,cr(this.#e,t,sr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=G(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??nn(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=an(fn(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!B(K(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=K(this.#e,n);Bn(this.#e,n,i)||(Vn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=K(this.#e,e);if(!Bn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Mr(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(K(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=K(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=K(this.#e,e),r=br(this.#e,e);if(!Bn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function ea(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`)}}var ta=e=>e.startsWith(`f::`)?e.slice(3):e;function na(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function ra(e,t){return e===``?t:`${e}/${t}`}function ia({files:e,path:t,isFolder:n,nextBasename:r}){let i=ta(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=na(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=ra(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function aa(e){return e.endsWith(`/`)}function oa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function sa(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function ca(e,t){return t.includes(e)?sa(t):[e]}function la(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function ua(e,t){return{draggedPaths:e,target:t}}function da(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(aa(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function fa(e,t){return t.kind===`root`||t.directoryPath==null?oa(e):t.directoryPath}function pa(e,t){let n=e.map(e=>{let n=fa(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function ma(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ha(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!ma($i.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function ga(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function _a(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function va(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function ya(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return va(e,t.path)?n?e:null:e;case`move`:return _a(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=ya(r,e,n),r==null)return null;return r}}}function ba(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function xa(e){switch(e.operation){case`add`:return{...ba(e),operation:`add`,path:e.path};case`remove`:return{...ba(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...ba(e),from:e.from,operation:`move`,to:e.to}}}function Sa(e){return{...ba(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>xa(e)),operation:`batch`}}function Ca(e){switch(e.operation){case`add`:case`remove`:case`move`:return xa(e);case`batch`:return Sa(e);default:return null}}function wa(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function Ta(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ea(e){return Ta(e).at(-1)??null}function Da(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function Oa(e){return e.endsWith(`/`)}var ka=e=>e.toLowerCase();function Aa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function ja(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Ma(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var Na=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},Pa=Symbol(`FILE_TREE_RENAME_VIEW`),Fa=512,Ia=512;function La(e){return e===`top`||e===`center`?e:`nearest`}function Ra(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=Ta(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function za(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:Ra(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var Ba=class e{static{Object.defineProperty(e.prototype,Pa,{configurable:!0,value(){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}},writable:!0})}#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=ha({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=Ea(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:La(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=Ia){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=ca(t,n);return this.#r.canDrag?.(r)!==!1&&(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=ua(t.draggedPaths,n);(da(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}la(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=ua(e.draggedPaths,t);if(da(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=pa(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=Oa(r),a=ja(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of Ta(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=Aa(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,Oa(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,Oa(e)?{recursive:!0}:void 0);return}let t=Oa(e),n=ia({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:ja(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(Ma(n.sourcePath,t),Ma(n.destinationPath,t))}#Y(e){this.#T!=null&&this.#E!==e&&(this.#E=e,this.#De())}resetPaths(e,t={}){let n=!Array.isArray(e),r=n?void 0:e,i=n?e:t,a=this.#H.list().length,o=this.#G,s=ha({paths:r,preparedInput:i.preparedInput},`resetPaths`,this.#e.sort),c=this.#le(s.paths,s.preparedInput,i.initialExpandedPaths),l=this.#c,u=this.#T,d=this.getSelectedPaths(),f=this.#z;this.#K?.(),this.#H=c,this.#d.clear(),this.#he();let p=d.map(e=>c.getPathInfo(e)?.path??null).filter(e=>e!=null),m=!wa(this.#B,p);this.#B=new Set(p),m&&(this.#V+=1),this.#z=f==null?null:c.getPathInfo(f)?.path??null,this.#T=u==null?null:c.getPathInfo(u)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(l,l!=null||p.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:s.paths.length,pathCountBefore:a,projectionChanged:!0,usedPreparedInput:i.preparedInput!=null,visibleCountDelta:this.#G-o})}#X(e){this.#Ie();let t=Ea(e),n=Da(e,t),r=null,i=null;for(let e of this.#be()){if(Ea(e)!==t)continue;let a=Da(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=Ta(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!wa(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new $i({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of Ta(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(ka),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(ka),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of Ta(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:Na(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of Ta(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of Ta(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=za(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,Fa)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s!==e||this.#c!==n)&&(this.#s=e,this.#c=n,t&&this.#De())}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=ya(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=ya(this.#c,e,!0),r=[...this.#B].map(t=>ya(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=ya(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return wa(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&ga(e)&&(this.#i=null);let t=ga(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=Ca(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},Va=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function Ha(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(e[t]!==`/`&&t!==e.length){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function Ua(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let e=t.indexOf(`/`,r);if(e===-1)break;n.push(t.slice(0,e+1)),r=e+1}return n}function Wa(e,t){return t?`${e}/`:e}function Ga(e,t=null){let n=Va(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set,o=new Map;for(let t of e??[]){let e=qa(t);e!=null&&Xa({canonicalPath:e.canonicalPath,changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,isDirectory:e.isDirectory,status:t.status,statusByPath:r})}return r.size===0?null:{changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}function Ka(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),a=new Set(e?.directoriesWithChanges),o=new Set(e?.ignoredDirectoryPaths),s=new Map(e?.changeCountByDirectoryPath),c=!1;for(let e of n){let t=Ja(e);t!=null&&(c=Ya({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,statusByPath:i})||c)}for(let e of r){let t=qa(e);t!=null&&(c=Xa({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,isDirectory:t.isDirectory,status:e.status,statusByPath:i})||c)}return c?i.size===0?null:{changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,signature:$a(i),statusByPath:i}:e}function qa(e){return Ja(e.path)}function Ja(e){let t=Ha(e);if(t!=null)return{canonicalPath:Wa(t.path,t.isDirectory),isDirectory:t.isDirectory}}function Ya({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let a=i.get(e);return a!=null&&(i.delete(e),a===`ignored`&&e.endsWith(`/`)&&r.delete(e),Qa(t,n,e),!0)}function Xa({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:a,statusByPath:o}){let s=o.get(e);return s!==a&&(s??Za(t,n,e),o.set(e,a),a===`ignored`&&i?r.add(e):i&&r.delete(e),!0)}function Za(e,t,n){for(let r of Ua(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function Qa(e,t,n){for(let r of Ua(n)){let n=(e.get(r)??0)-1;n>0?e.set(r,n):(e.delete(r),t.delete(r))}}function $a(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\0${n}\0${r}`;return t}var eo=e=>e.trim().toLowerCase(),to=e=>e.split(`/`).at(-1)??e,no=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function ro(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function io(e){let t=mt(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(eo(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let s=to(o),c=s.toLowerCase(),l=r.get(c);if(l!=null)return ro(l,e);for(let[t,n]of a)if(c.includes(t))return ro(n,e);let u=no(s);for(let t of u){let n=i.get(t);if(n!=null)return ro(n,e)}let d=P(t.set,s,u);if(d!=null&&t.set!==`none`){if(d==="default"){let t=n?.[e];if(t!=null)return ro(t,e)}return{name:ft(d),remappedFrom:e,token:d}}}let s=n?.[e];return s==null?{name:e}:ro(s,e)}}}var J,ao,oo,so,co,lo,uo,fo,po,mo,ho={},go=[],_o=Array.isArray,vo=go.slice,yo=Object.assign;function bo(e){e&&e.parentNode&&e.remove()}function xo(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?vo.call(arguments,2):n),So(e,o,r,i,null)}function So(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ao,__i:-1,__u:0};return i==null&&J.vnode!=null&&J.vnode(a),a}function Co(e){return e.children}function wo(e,t){this.props=e,this.context=t,this.__g=0}function To(e,t){if(t==null)return e.__?To(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?To(e):null}function Eo(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return Eo(e)}}function Do(e){(8&e.__g||!(e.__g|=8)||!oo.push(e)||co++)&&so==J.debounceRendering||((so=J.debounceRendering)||queueMicrotask)(Oo)}function Oo(){for(var e,t,n,r,i,a,o,s,c=1;oo.length;)oo.length>c&&oo.sort(lo),e=oo.shift(),c=oo.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=yo({},r)).__v=r.__v+1,J.vnode&&J.vnode(n),Io(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??To(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,Ro(a,n,o),n.__e!=i&&Eo(n)));co=0}function ko(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||go,b=t.length;for(c=Ao(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?ho:y[m.__i]||ho,m.__i=f,_=Io(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&Vo(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=jo(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function Ao(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?So(null,o,null,null,null):_o(o)?So(Co,{children:o},null,null,null):o.constructor==null&&o.__b>0?So(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=Mo(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=To(s)),Ho(s,s));return r}function jo(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=jo(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=To(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Mo(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function No(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function Po(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||No(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||No(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(uo,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=fo,e.addEventListener(t,a?mo:po,a)):e.removeEventListener(t,a?mo:po,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Fo(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=fo++;else if(t.u<n.l)return;return n(J.event?J.event(t):t)}}}function Io(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,ee,w,T,te,E,D,O,ne,k=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=J.__b)&&d(t);n:if(typeof k==`function`)try{if(v=t.props,y=`prototype`in k&&k.prototype.render,b=(d=k.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new k(v,x):(t.__c=f=new wo(v,x),f.constructor=k,f.render=Uo),b&&b.sub(f),f.props=v,f.state||(f.state={}),f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&k.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=yo({},f.__s)),yo(f.__s,k.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&k.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&k.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=J.__r,ee=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),w=0;w<f._sb.length;w++)f.__h.push(f._sb[w]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++ee<25);f.state=f.__s,f.getChildContext!=null&&(r=yo({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),T=d,d!=null&&d.type===Co&&d.key==null&&(T=zo(d.props.children)),s=ko(e,_o(T)?T:[T],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null){if(e.then){for(te=0,E=!1,t.__u|=c?160:128,t.__c.__z=[],D=0;D<a.length;D++)(O=a[D])==null||E||(O.nodeType==8&&O.data==`$s`?(te>0&&t.__c.__z.push(O),te++,a[D]=null):O.nodeType==8&&O.data==`/$s`?(--te>0&&t.__c.__z.push(O),E=te===0,s=a[D],a[D]=null):te>0&&(t.__c.__z.push(O),a[D]=null));if(!E){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(ne=a.length;ne--;)bo(a[ne]);Lo(t)}}else t.__e=n.__e,t.__k=n.__k,e.then||Lo(t);J.__e(e,t,n)}else s=t.__e=Bo(n.__e,t,n,r,i,a,o,c,l,u);return(d=J.diffed)&&d(t),128&t.__u?void 0:s}function Lo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Lo)}function Ro(e,t,n){for(var r=0;r<n.length;r++)Vo(n[r],n[++r],n[++r]);J.__c&&J.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){J.__e(e,t.__v)}})}function zo(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:_o(e)?e.map(zo):yo({},e)}function Bo(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(J.__m&&J.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=vo.call(e.childNodes),v=n.props||ho,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;Po(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||Po(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),ko(b==`template`?e.content:e,_o(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&To(n,0),s,c,l),a!=null)for(u=a.length;u--;)bo(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||Po(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&Po(e,u,g,v[u],i))}return e}function Vo(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){J.__e(e,n)}}function Ho(e,t,n){var r,i;if(J.unmount&&J.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Vo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){J.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ho(r[i],t,n||typeof e.type!=`function`);n||bo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function Uo(e,t,n){return this.constructor(e,n)}function Wo(e,t){var n,r,i,a;t==document&&(t=document.documentElement),J.__&&J.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=xo(Co,null,[e]),i=[],a=[],Io(t,e,r||ho,ho,t.namespaceURI,r?null:t.firstChild?vo.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),Ro(i,e,a)}function Go(e,t){e.__u|=32,Wo(e,t)}J={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw co=0,e}},ao=0,wo.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=yo({},this.state);typeof e==`function`&&(e=e(yo({},n),this.props)),e&&yo(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Do(this))},wo.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),Do(this))},wo.prototype.render=Co,oo=[],co=0,lo=function(e,t){return e.__v.__b-t.__v.__b},uo=/(PointerCapture)$|Capture$/i,fo=0,po=Fo(!1),mo=Fo(!0);var Ko=0;Array.isArray;function Y(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ko,__i:-1,__u:0,__source:i,__self:a};return J.vnode&&J.vnode(l),l}var qo=16,Jo=16,Yo={};function Xo({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=Yo[e]??{width:qo,height:Jo},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return Y(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:Y(`use`,{href:c})})}var Zo=e=>e!==void 0&&/\s/.test(e),Qo=(e,t)=>{let n=t=>Zo(e[t-1])||Zo(e[t]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let a=t+r;if(a<e.length&&!n(a))return a}return t},$o=e=>Qo(e,Math.ceil(e.length/2)),es=e=>{if(e.length<2)return[e,``];let t=$o(e);return[e.slice(0,t),e.slice(t)]},ts=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:$o(e);return[e.slice(0,r),e.slice(r)]},ns=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},rs=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},is=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},as=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function os({children:e,marker:t,variant:n=`default`}){"use no memo";return Y(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:Y(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?Y(`span`,{"data-truncate-fade":!0}):t})})}function ss(e){"use no memo";let{mode:t,children:n}=e;return Y(`div`,{children:[Y(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?Y(`span`,{children:n}):n}),Y(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?Y(`span`,{children:n}):n})]})}function cs({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=Y(ss,{mode:t,children:e},`content`),o=Y(os,{marker:n,mode:t,variant:r},`marker`),s=Y(`div`,{"data-truncate-fill":!0},`fill`);return Y(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:Y(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function ls({children:e,...t}){"use no memo";return Y(cs,{mode:`truncate`,...t,children:e})}function us({children:e,...t}){"use no memo";return Y(cs,{mode:`fruncate`,...t,children:e})}function ds({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=Y(ls,{...s,children:t[0]}),l=Y(us,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return Y(`div`,{className:a,style:o});if(e.length<i)return Y(n===`end`?us:ls,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=es:r===`extension`?t=ts:r===`leaf-path`&&(t=ns);else if(typeof r==`number`)t=rs,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=is:e===`first`&&(t=as)}else typeof r==`function`&&(t=r);t??=es;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=Y(ls,{...s,..._,children:f}),l=Y(us,{...s,...v,children:p})}return Y(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[Y(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),Y(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var fs={endIndex:-1,startIndex:-1};function ps(e,t,n){return Math.min(Math.max(e,t),n)}function ms(e,t){return e<0||t<e?fs:{endIndex:t,startIndex:e}}function hs(e){return e.startIndex<0||e.endIndex<e.startIndex}function gs(e,t){return hs(e)?0:(e.endIndex-e.startIndex+1)*t}function _s(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function vs(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function ys(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function bs(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function xs(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function Ss(e,t,n){if(e.length===0||t<=0)return[];let r=xs(e),i=ys(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=bs(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function Cs(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=ps(t.scrollTop,0,o),c=t.stickyRows??Ss(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=_s(s,n,t.itemHeight),m=_s(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?fs:ms(m,vs(u+d,n,t.itemHeight)),y=g+1,b=hs(v)?fs:ms(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=gs(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:hs(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var ws={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},Ts={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},Es=`Contains git status items`;function Ds(e){return e.current?!0:(e.current=!0,!1)}function Os(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function ks(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return Os({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function As(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function js(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function Ms(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function Ns(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function Ps(e,t){return e!=null&&e>0?e:t}function Fs(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function Is(e,t,n,r,i=0){let a=Os({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a!=null&&(e.scrollTop=a,!0)}function Ls(e,t,n,r,i,a,o=0){let s=ks({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s!=null&&(e.scrollTop=s,!0)}function Rs(e,t,n,r,i,a){let o=As({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o!=null&&(e.scrollTop=o,!0)}function zs(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function Bs(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function Vs({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return Y(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function Hs(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function Us(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var Ws,X,Gs,Ks,qs=Object.is,Js=0,Ys=[],Z=J,Xs=Z.__b,Zs=Z.__r,Qs=Z.diffed,$s=Z.__c,ec=Z.unmount,tc=Z.__;function nc(e,t){Z.__h&&Z.__h(X,e,Js||t),Js=0;var n=X.__H||(X.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function rc(e){return Js=1,ic(mc,e)}function ic(e,t,n){var r=nc(Ws++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):mc(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);qs(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=X,!X.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,qs(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};X.__f=!0;var a=X.shouldComponentUpdate,o=X.componentWillUpdate;X.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},X.shouldComponentUpdate=i}return r.__N||r.__}function ac(e,t){var n=nc(Ws++,3);!Z.__s&&pc(n.__H,t)&&(n.__=e,n.u=t,X.__H.__h.push(n))}function oc(e,t){var n=nc(Ws++,4);!Z.__s&&pc(n.__H,t)&&(n.__=e,n.u=t,X.__h.push(n))}function Q(e){return Js=5,sc(function(){return{current:e}},[])}function sc(e,t){var n=nc(Ws++,7);return pc(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return Js=8,sc(function(){return e},t)}function cc(){for(var e;e=Ys.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(dc),e.__H.__h.forEach(fc),e.__H.__h=[]}catch(t){e.__H.__h=[],Z.__e(t,e.__v)}}Z.__b=function(e){X=null,Xs&&Xs(e)},Z.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tc&&tc(e,t)},Z.__r=function(e){Zs&&Zs(e),Ws=0;var t=(X=e.__c).__H;t&&(Gs===X?(t.__h=[],X.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(dc),t.__h.forEach(fc),t.__h=[],Ws=0)),Gs=X},Z.diffed=function(e){Qs&&Qs(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ys.push(t)!==1&&Ks===Z.requestAnimationFrame||((Ks=Z.requestAnimationFrame)||uc)(cc)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Gs=X=null},Z.__c=function(e,t){t.some(function(e){try{e.__h.forEach(dc),e.__h=e.__h.filter(function(e){return!e.__||fc(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Z.__e(n,e.__v)}}),$s&&$s(e,t)},Z.unmount=function(e){ec&&ec(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{dc(e)}catch(e){t=e}}),n.__H=void 0,t&&Z.__e(t,n.__v))};var lc=typeof requestAnimationFrame==`function`;function uc(e){var t,n=function(){clearTimeout(r),lc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);lc&&(t=requestAnimationFrame(n))}function dc(e){var t=X,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),X=t}function fc(e){var t=X;e.__c=e.__(),X=t}function pc(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!qs(t,e[n])})}function mc(e,t){return typeof t==`function`?t(e):t}function hc(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:Y(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return Y(Co,{children:[Y(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:Y(ls,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function gc(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function _c(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function vc(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function yc({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=Cs(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:vc(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?vc(u,1,t,o):i&&r<=0&&c.length>0?Ss(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var bc=400,xc=40,Sc=18;function Cc(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?wc(e,t,n):a instanceof HTMLElement?a:null}function wc(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function Tc(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function Ec(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function Dc(){return navigator.vendor!==`Apple Computer, Inc.`}function Oc(e,t){let n=e-t.top;if(n<xc)return-Math.ceil((xc-Math.max(0,n))/xc*Sc);let r=t.bottom-e;return r<xc?Math.ceil((xc-Math.max(0,r))/xc*Sc):0}function kc(e,t){if(e!=null){let t=ws[e];return t==null?null:{text:t,title:Ts[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:Es}:null}function Ac(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function jc(e){return e!=null&&`toggle`in e}function Mc(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function Nc(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Pc(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function Fc(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function Ic(e,t){return t&&Fc(e)||(e.ctrlKey||e.metaKey)&&Mc(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var Lc=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function Rc(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function zc(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function Bc(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function Vc(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function Hc(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function Uc(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function Wc(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function Gc(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function Kc(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=Gc(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function qc(e,t){return{kind:e.kind,name:_c(e),path:t}}function Jc(e){return e==null?void 0:`${e}__tree`}function Yc(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function Xc(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Zc(e,t){if(e==null)return null;if(`text`in e)return e.parts==null?Y(`span`,{title:e.title,children:e.text}):Y(`span`,{title:e.title,children:e.parts.map((e,t)=>Y(`span`,{style:{color:e.color},children:e.text},t))});let n=typeof e.icon==`string`?Xc(e.icon)?t(e.icon):{name:e.icon}:Xc(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return Y(`span`,{title:e.title,children:Y(Xo,{...n})})}function Qc(e){e!=null&&js(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function $c(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=gc(e);return Y(Co,{children:[e.depth>0?Y(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>Y(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,Y(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?Y(Xo,{...t(`file-tree-icon-chevron`)}):Y(Xo,{...t(`file-tree-icon-file`,u)})}),Y(`div`,{"data-item-section":`content`,children:e.isFlattened?hc(e,c,a):c??Y(ds,{minimumLength:5,split:`extension`,children:e.name})}),i?Y(`div`,{"data-item-section":`decoration`,children:r==null?null:Zc(r,t)}):null,s?Y(`div`,{"data-item-section":`git`,children:Zc(o,t)}):null,n?Y(`div`,{"data-item-section":`action`,children:l?Y(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:Y(Xo,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function el(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:ee,contextMenuButtonVisibility:w,contextMenuRightClickEnabled:T,registerRenameInput:te,registerButton:E,resolveIcon:D,renderDecorationForRow:O,openContextMenuForRow:ne,onRowClick:k,onKeyDown:re}=e,A=gc(t),{isParked:j=!1,mode:ie=`flow`,style:ae}=r,oe=ie===`sticky`,se=_?.get(A)??null??Ac(t.ancestorPaths,v,y),ce=t.kind===`directory`&&(b?.has(A)??!1),le=O(t,A),ue=kc(se,ce),de=S&&ee,fe=le!=null||x||de,pe=de&&w===`always`,me=a.getPath()===A,he=me?a.getValue():``,ge=oe||!me?null:Y(Vs,{ref:te,ariaLabel:`Rename ${_c(t)}`,isFlattened:t.isFlattened,value:he,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),_e=$c(t,D,{actionLaneEnabled:de,customDecoration:le,decorationLaneEnabled:fe,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:ue,gitLaneActive:x,renameInput:ge,showDecorativeActionAffordance:pe}),ve={...Hs({ariaLabel:_c(t),domId:t.isFocused?Yc(h,A,j):void 0,extraStyle:ae,features:{actionLaneEnabled:de,contextMenuButtonVisibility:de?w:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:j,itemHeight:g,mode:ie,row:t,state:{containsGitChange:ce,effectiveGitStatus:se,isContextHovered:s===A,isDragTarget:l?.kind===`directory`&&l.directoryPath===A,isDragging:c?.has(A)===!0,isFocusRinged:t.isFocused&&o===A},targetPath:A}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),T&&(i.focusMountedPathFromInput(A),ne(t,A,{anchorRect:Bc(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:oe?void 0:()=>{i.focusMountedPathFromInput(A)},onKeyDown:oe?void 0:re,ref:e=>{E(A,e)}};return!oe&&me?Y(`div`,{...ve,children:_e}):Y(`button`,{...ve,type:`button`,draggable:u&&!j,onDragEnd:u&&!j?p:void 0,onDragStart:u&&!j?e=>{f(e,t,A)}:void 0,onMouseDown:e=>{if(oe){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!j?e=>{m(e,t,A)}:void 0,onClick:e=>{k(e,t,A,ie)},children:_e})}function tl(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(gc(e))).map((n,r)=>el(e,n,t.start+r))}function nl({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=_t,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=Q(null),v=Q(null),y=Q(!1),b=Q(null),x=Q(null),S=Q(null),C=Q(null),ee=Q(null),E=Q(new Map),D=Q(new Map),O=Q(()=>{}),ne=Q(null),k=Q(0),re=Q(!1),A=Q(null);A.current!==t&&(re.current=!1,A.current=t);let j=Q(!1),ie=Q(null),ae=Q(null),oe=Q(!1),se=Q(null),ce=Q(null),le=Q(null),ue=Q(null),de=Q(null),fe=Q(null),pe=Q(null),me=Q(null),he=Q(!1),ge=Q(null),_e=Q(null),ve=Q(null),ye=Q(null),be=sc(()=>new Map,[]),[,xe]=rc(0),Se=Q(!1),[Ce,we]=rc(null),[Te,Ee]=rc(null),[De,Oe]=rc(null),[ke,Ae]=rc(null),[je,Me]=rc(0),[M,Ne]=rc(null),Pe=Q(M);Pe.current=M;let Fe=Q(null),Ie=Q(null),Le=Q(null),Re=Q(null),ze=Q(null),Be=Q(!1),Ve=()=>{Ie.current=null,Le.current=null,Re.current=null},He=(e,t)=>{Ie.current=e,Le.current=null,Re.current=t==null?null:{path:e,scrollTop:t}},Ue=(e,t)=>{Ie.current=null,Le.current={path:e,viewportOffset:t},Re.current=null},We=Q(d===`retain`&&t.isSearchOpen()),[Ge,Ke]=rc(p);ac(()=>{p||Ke(!1)},[p]);let qe=Q(!1),Je=$(()=>{qe.current=!0,Ke(e=>e&&!1)},[]),[Ye,Xe]=rc(()=>yc({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[Ze,Qe]=rc(!1);ac(()=>{Qe(!0)},[]);let N=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,$e=e?.contextMenu?.triggerMode??(N?`right-click`:`both`),et=$e===`both`||$e===`button`,tt=e?.contextMenu?.buttonVisibility??`when-needed`,nt=$e===`both`||$e===`right-click`;oc(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;ze.current=t,Ee(t),Ae(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Be.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let rt=$((e,t)=>{Hc(E.current,e,t)},[]),it=$((e,t)=>{Hc(D.current,e,t)},[]),at=$(e=>{x.current=e},[]),ot=$(e=>Uc(e,D.current,E.current),[]),st=n!=null||r!=null||i!=null,{resolveIcon:ct}=sc(()=>io(a),[a]),lt=t[Pa](),ut=lt.getPath(),dt=ut!=null,ft=t.isSearchOpen(),pt=t.getSearchValue(),P=t.getFocusedPath(),F=t.getFocusedIndex(),mt=t.getScrollRequest(),ht=t.isDragAndDropEnabled(),gt=t.getDragSession(),vt=sc(()=>gt==null?null:new Set(gt.draggedPaths),[gt]),yt=gt?.target??null,bt=gt?.primaryPath??null,xt=Jc(o),{overlayHeight:St,overlayRows:Ct,snapshot:I,visibleRows:wt}=Ye,L=I.physical.viewportHeight,Tt=sc(()=>({end:I.window.endIndex,start:I.window.startIndex}),[I.window.endIndex,I.window.startIndex]),Et=Ct,Dt=I.sticky.rows,Ot=I.physical.totalHeight,kt=I.sticky.height,At=sc(()=>new Set(Dt.map(e=>gc(e.row))),[Dt]),jt=F>=0&&F>=Tt.start&&F<=Tt.end,Mt=$((e,t)=>u?.({item:qc(e,t),row:e})??null,[u]),Nt=$(e=>js(e==null?null:E.current.get(e)??null)?!0:js(S.current),[]),Pt=$(e=>{Nt(t.focusNearestPath(e))},[t,Nt]),Ft=Q(Pt);Ft.current=Pt;let It=Q(!0),Lt=Q(()=>{}),R=$((t=!0)=>{let n=Pe.current;n!=null&&(It.current=It.current&&t,Ne(null),e?.contextMenu?.onClose?.(),It.current&&Pt(n.path))},[e?.contextMenu,Pt]);Lt.current=R;let Rt=$(e=>{let t=e==null?null:Vc(S.current,e);Oe(e=>e===t?e:t)},[]),zt=$((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=ot(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;He(n,e?.scrollTop??null),j.current=!0,we(e=>e===n?e:n)}i.focus(),Rt(a),It.current=!0,Ne({anchorRect:r?.anchorRect??null,item:qc(e,n),path:n,source:r?.source??`keyboard`})},[t,ot,Rt]),Bt=$(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=Ns(e,L);se.current=F<0||e==null?null:Math.max(0,Math.min(F*s-e.scrollTop,Math.max(0,t-s))),oe.current=!0}t.startRenaming(e)!==!1&&(Ae(`focus`),xe(e=>e+1))}},[t,F,s,l,L]),Vt=$((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=Ns(i,L),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:yc({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return j.current=!0,Rs(i,a,s,l,u,d),O.current(),Fe.current=n?e:null,!0},[t,s,c,L,h]),Ht=()=>y.current===!0||ye.current!=null||he.current===!0,Ut=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),Wt=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},z=()=>{ue.current!=null&&(clearTimeout(ue.current),ue.current=null),le.current=null},Gt=()=>{fe.current?.remove(),fe.current=null},Kt=()=>{Wt(ce.current),ce.current=null,de.current=null},B=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},qt=()=>{me.current?.(),me.current=null,ye.current!=null&&(clearTimeout(ye.current),ye.current=null),he.current=!1,ge.current=null,ve.current=null,_e.current!=null&&(_e.current.setAttribute(`draggable`,`true`),_e.current.style.removeProperty(`touch-action`),_e.current=null),Gt(),z(),Kt(),pe.current=null},V=(e,n)=>{let r=S.current?.getRootNode(),i=Tc(Cc(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Jt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){z();return}let r=t.getItem(e.directoryPath),i=jc(r)?r:null;if(i==null||i.isExpanded()){z();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;le.current!==a&&(z(),le.current=a,ue.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind===`directory`&&n.directoryPath===e.directoryPath&&n.flattenedSegmentPath===e.flattenedSegmentPath&&i.expand()},n))},Yt=()=>{ce.current=null;let e=de.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=Oc(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,O.current()),Jt(V(e.clientX,e.clientY)),ce.current=Ut(Yt)},Xt=(e,t)=>{de.current={clientX:e,clientY:t},ce.current??=Ut(Yt)},Zt=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(qt(),Gt(),z(),Kt(),t.startDrag(r)===!1){e.preventDefault();return}if(pe.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),Dc())){let t=Ec(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),B(t),fe.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Qt=()=>{Gt(),z(),Kt(),pe.current=null,t.cancelDrag()},H=(e,n,r)=>{if(ye.current!=null||he.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;ve.current={clientX:i.clientX,clientY:i.clientY},_e.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!he.current;ye.current!=null&&(clearTimeout(ye.current),ye.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),me.current===o&&(me.current=null),t&&(a.setAttribute(`draggable`,`true`),_e.current===a&&(_e.current=null),ve.current=null)},s=e=>{let t=e.touches[0],n=ve.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=100||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),me.current=o,ye.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),_e.current===a&&(_e.current=null),ve.current=null;return}he.current=!0,_e.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),pe.current=n;let e=a.getBoundingClientRect(),s=Ec(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),B(s),fe.current=s,ge.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=ge.current;n!=null&&fe.current!=null&&(fe.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Jt(V(t.clientX,t.clientY)),Xt(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&V(n.clientX,n.clientY),t.completeDrag(),qt()},u=()=>{t.cancelDrag(),qt()};me.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},bc)},$t=e=>{if(M!=null){if(e.key===`Escape`){R(),e.preventDefault(),e.stopPropagation();return}Lc.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(lt.isActive()){if(e.isComposing||e.keyCode===229)return;if(e.key===`Escape`)lt.cancel();else if(e.key===`Enter`)lt.commit();else return;Ae(`focus`),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){Bt(P??void 0),e.preventDefault(),e.stopPropagation();return}if(ft){if(e.key===`Escape`)oe.current=!1,se.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=Ns(n,L);se.current=F<0||n==null?null:Math.max(0,Math.min(F*s-n.scrollTop,Math.max(0,r-s))),oe.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;Ae(`focus`),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&Nc(e)){t.openSearch(e.key),xe(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=N&&Fc(e),r=Ic(e,N),i=r&&S.current!=null?Ms(S.current):null,a=r?new Set(Wc(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==P&&a.has(o)){let e=C.current;He(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=jc(p)?p:null,h=u!=null&&(At.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=Uc(u,D.current,E.current);e==null||n==null?y=!1:zt(e,u)}else if((e.ctrlKey||e.metaKey)&&Mc(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;Ae(`focus`);let b=t.getFocusedPath(),x=b!=null&&(At.has(b)||a.has(b)),ee=g&&b!==u,w=n&&c&&o===u&&b===u;if((h||w)&&b!=null&&(ee&&x||w))He(b,v?.scrollTop??null),j.current=!0,we(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(Ue(b,Kc(S.current,v,i,u,s,kt,L)),j.current=!0,we(e=>e===b?e:b)):Ve()}xe(e=>e+1),e.preventDefault(),e.stopPropagation()};oc(()=>{if(!(!f||!ft)){if(We.current){We.current=!1;return}js(ee.current)}},[ft,f]),oc(()=>{let e=x.current;switch(Bs({hasRenderedInput:e!=null,previousRenamingPath:ae.current,renamingPath:ut})){case`reset`:ae.current=null;return;case`reveal-canonical`:ut!=null&&Vt(ut,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(Fe.current=null,ae.current=ut,js(e),e.select());return}},[Tt.end,Tt.start,ut,Vt,At]),oc(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=Ms(e)?.dataset.itemPath??null;we(e=>e===t?e:t)},i=()=>{n(),j.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,Ms(e)!=null){r();return}j.current=!1,we(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),j.current=!1,we(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;we(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),oc(()=>{let e=S.current;e!=null&&(I.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[I.physical.scrollTop]),oc(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;ne.current=Ns(n,g);let a=()=>{let e=t.getVisibleCount(),r=Ps(ne.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Xe(yc({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!re.current){re.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=Ps(ne.current,g),i=t.getVisibleRows(e,e)[0]??null;Is(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}O.current=a;let o=t.subscribe(()=>{Ds(Se)&&xe(e=>e+1),a()}),l=()=>{Be.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,Me(e=>e+1),e=null},50))},u=null,d=()=>{i!=null&&delete i.dataset.overlayReveal,u!=null&&(clearTimeout(u),u=null)},f=()=>{i!=null&&Be.current!==!0&&(n.scrollTop>0||(i.dataset.overlayReveal=`true`,u!=null&&clearTimeout(u),u=setTimeout(()=>{d()},200)))},p=()=>{if(a(),n.scrollTop>0&&d(),Pe.current!=null&&y.current&&Lt.current(),Be.current===!0){y.current=!1;return}Ee(e=>e==null?e:null),l()},m=()=>{l(),f()},_=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),v=e=>{_.has(e.key)&&m()};n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,m,{passive:!0}),n.addEventListener(`touchmove`,m,{passive:!0}),n.addEventListener(`keydown`,v);let x=typeof ResizeObserver<`u`?new ResizeObserver(e=>{ne.current=(e[0]==null?null:Fs(e[0]))??Ns(n,g),a()}):null;return x?.observe(n),()=>{O.current=()=>{},o(),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,m),n.removeEventListener(`touchmove`,m),n.removeEventListener(`keydown`,v),e!=null&&clearTimeout(e),u!=null&&clearTimeout(u),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,ne.current=null,x?.disconnect()}},[t,g,s,c,h]),oc(()=>{N||M==null||R(!1)},[R,N,M]);let en=sc(()=>M==null?null:`${M.path}::${M.source}`,[M]);oc(()=>{if(en==null){m?.clearSlotContent(T);return}let t=Pe.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??zc(n.getBoundingClientRect()),close:e=>{Lt.current(e?.restoreFocus??!0)},restoreFocus:()=>{It.current&&Ft.current(Pe.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(T,i),e?.contextMenu?.onOpen?.(t.item,r),Qc(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Qc(i)}),()=>{m?.clearSlotContent(T)}},[en,e?.contextMenu,m]),oc(()=>{M!=null&&t.getItem(M.path)==null&&R()},[R,M,t]),oc(()=>{if(M==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(Rc(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&R())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),R())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[R,M]),oc(()=>{let e=C.current,n=S.current;if(e==null||n==null){ie.current=P;return}let r=P==null?null:E.current.get(P)??null,i=Ms(n),a=i?.dataset.itemPath??null,o=dt&&x.current===i,c=f&&ee.current===i,l=oe.current&&!ft,u=se.current??0,d=Fe.current,p=Ie.current,m=Le.current,g=Re.current,_=i!=null,v=j.current||_,y=ie.current!==P,b=p!=null&&p===P&&P!=null,w=!1,T=!1;if(mt!=null&&mt.id!==k.current){k.current=mt.id;let n=mt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,L-s))):kt;w=!0,T=Ls(e,n,s,L,Ot,mt.offset,t)}t.clearScrollRequest(mt.id)}let te=!w&&l&&Rs(e,F,s,L,Ot,u),D=!w&&d!=null&&d===P&&Rs(e,F,s,L,Ot,kt),ne=!w&&m!=null&&m.path===P&&Rs(e,F,s,L,Ot,m.viewportOffset),re=!w&&g!=null&&g.path===P&&e.scrollTop!==g.scrollTop;if(re&&(e.scrollTop=g.scrollTop),(re||T||D||ne||te||v&&y&&d!==P&&!b&&Is(e,F,s,L,kt))&&O.current(),w){ie.current=P;return}if(!v){ie.current=P;return}if(o){ie.current=P;return}if(c&&!l){ie.current=P;return}if(r==null){l&&F>=0&&(Rs(e,F,s,L,Ot,u),O.current()),ie.current=P;return}(y||l||d===P||p===P||m?.path===P||g?.path===P||a==null||a!==P)&&(js(r),d===P&&(Fe.current=null),p===P&&(Ie.current=null),m?.path===P&&(Le.current=null),g?.path===P&&(Re.current=null),oe.current=!1,se.current=null),ie.current=P},[t,F,P,jt,s,dt,ft,Tt,L,f,mt,h,kt,Ot,wt]);let tn=F>=0&&F>=I.visible.startIndex&&F<=I.visible.endIndex,nn=P!=null&&Et.some(e=>gc(e.row)===P),rn=tn||nn,an=et&&j.current===!0&&rn?P:null,on=ke===`pointer`?Te:null,sn=M?.path??ze.current??on??an??Te,cn=M?.source===`right-click`;oc(()=>{y.current&&M==null||Rt(ot(sn))},[M,ot,Tt,L,je,Et,sn,Rt,wt]);let ln=$(e=>{if(y.current||Rc(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&Ae(e=>e===`pointer`?e:`pointer`),Ee(e=>e===i?e:i)},[]),un=$(()=>{Ee(null)},[]);oc(()=>{if(!ht)return;let e=()=>{qt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),qt(),t.cancelDrag()}},[t,ht]);let dn=e=>{if(!ht||t.getDragSession()==null||he.current)return;let n=Tc(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Jt(t.getDragSession()?.target??null),Xt(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},fn=e=>{if(!ht||t.getDragSession()==null||he.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(z(),Kt(),t.setDragTarget(null))},pn=e=>{!ht||t.getDragSession()==null||he.current||(e.preventDefault(),V(e.clientX,e.clientY),t.completeDrag(),Gt(),z(),Kt(),pe.current=null)},mn=I.window.height,hn=I.window.offsetTop,gn=Math.min(0,L-mn),_n=Math.min(0,L-mn-kt),vn=Ce===P||oe.current,U=P!=null&&vn&&!jt&&F>=0?wt[F]??t.getVisibleRows(F,F)[0]??null:null,yn=U==null?null:zs(F,s,Tt,mn),bn=pe.current,xn=bt!=null&&bn!=null&&bn.path===bt&&bn.index>=Tt.start&&bn.index<=Tt.end,Sn=bt!=null&&bn!=null&&bn.path===bt&&!xn&&bn.path!==U?.path?bn:null,Cn=Sn==null?null:zs(Sn.index,s,Tt,mn),wn=Pc((F>=0?wt[F]??t.getVisibleRows(F,F)[0]??null:null)?.ancestorPaths.at(-1)??null),Tn=ft&&P!=null?Yc(o,P,!jt):void 0,En=M?.path??(ft?P:Ce),Dn=M?.path??Te,On=ot(sn),kn=N&&et&&!cn&&!dt&&On!=null&&De!=null&&sn!=null,An=N&&(kn||M!=null),jn=M?.anchorRect,Mn=jn==null&&On!=null&&De!=null&&(M!=null||kn)?De:null,Nn=jn==null?Mn==null?void 0:{top:`${Mn}px`}:{left:`${jn.left}px`,position:`fixed`,right:`auto`,top:`${jn.top}px`},Pn=cn?{opacity:`0`}:void 0,Fn=$((e,n,r,i)=>{let a=Us({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:ft,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c)}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=I.visible.startIndex&&n.index<=I.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(j.current=!0,we(e=>e===c?e:c),Ae(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&Vt(c,{targetOffset:`sticky-parents`})},[t,ft,I.visible.endIndex,I.visible.startIndex,Vt]),In=()=>{if(y.current||!et||sn==null||On==null)return;let e=t.getItem(sn);e!=null&&(Rt(On),It.current=!0,Ne({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:On.getAttribute(`aria-label`)??sn,path:e.getPath()},path:e.getPath(),source:`button`}))},Ln={contextHoverPath:Dn,contextMenuButtonTriggerEnabled:et,contextMenuButtonVisibility:tt,contextMenuEnabled:N,contextMenuRightClickEnabled:nt,contextMenuTriggerMode:$e,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:ht,draggedPathSet:vt,dragTarget:yt,gitLaneActive:st,gitStatusByPath:n,handleRowDragEnd:Qt,handleRowDragStart:Zt,handleRowTouchStart:H,ignoredGitDirectories:r,ignoredInheritanceCache:be,instanceId:o,itemHeight:s,onKeyDown:$t,onRowClick:Fn,openContextMenuForRow:zt,registerButton:rt,registerRenameInput:at,renameView:lt,renderDecorationForRow:Mt,resolveIcon:ct,shouldSuppressContextMenu:Ht,visualFocusPath:En},Rn={...Ln,registerButton:it};return Y(`div`,{ref:S,id:xt,"data-file-tree-context-menu-button-visibility":N&&et?tt:void 0,"data-file-tree-context-menu-trigger-mode":N?$e:void 0,"data-file-tree-has-context-menu-action-lane":N&&et?`true`:void 0,"data-file-tree-has-git-lane":st?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:ht?fn:void 0,onDragOver:ht?dn:void 0,onDrop:ht?pn:void 0,onKeyDown:$t,onPointerLeave:N?un:void 0,onPointerOver:N?ln:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[Y(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:wn}}),Y(`slot`,{name:w,"data-type":`header-slot`}),f?Y(`div`,{"data-file-tree-search-container":!0,"data-open":ft?`true`:`false`,children:Y(`input`,{ref:ee,"aria-activedescendant":Tn,"aria-controls":xt,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ge?`true`:void 0,value:pt,onBlur:()=>{d===`retain`&&!qe.current||t.closeSearch()},onFocus:Je,onPointerDown:Je,onInput:e=>{Je();let n=e.currentTarget;t.setSearch(n.value)}})}):null,Y(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&Ze&&Et.length>0?Y(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:Y(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${St}px`},children:Et.map((e,t)=>el(Rn,e.row,`sticky:${gc(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${Et.length-t}`}}))})}):null,Y(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${Ot}px`},children:[Y(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${hn}px`}}),Y(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${mn}px`,top:`${gn}px`,bottom:`${_n}px`},children:[tl(Ln,Tt,At),U!=null&&yn!=null?el(Ln,U,`parked:${U.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:bt===U.path?`none`:void 0,position:`absolute`,right:`0`,top:`${yn}px`}}):null,Sn!=null&&Cn!=null?el(Ln,Sn,`parked-drag:${Sn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${Cn}px`}}):null]})]})]}),N?Y(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":An?`true`:`false`,style:Nn,children:[Y(`button`,{ref:v,type:`button`,"data-type":te,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":M==null?`false`:`true`,"data-visible":kn?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),M!=null){R();return}In()},tabIndex:-1,style:Pn,children:Y(Xo,{...ct(`file-tree-icon-ellipsis`)})}),M==null?null:Y(`slot`,{name:T})]}):null,M==null?null:Y(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),R()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),R()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var rl={hydrateRoot:(e,t)=>{Go(xo(nl,t),e)},renderRoot:(e,t)=>{Wo(xo(nl,t),e)},unmountRoot:e=>{Wo(null,e)}};function il(e,t){rl.renderRoot(e,t)}function al(e,t){rl.hydrateRoot(e,t)}function ol(e){rl.unmountRoot(e)}var sl=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}};Array.isArray;var cl=0;function ll(e){return e!=null&&e.length>0?e:(cl+=1,`pst_ft_${cl}`)}function ul({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??_t)}function dl(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function fl(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function pl(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var ml=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new sl;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=ll(a),this.#p=Ga(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=gt(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new Ba({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(ol(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=Ka(this.#p,e);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&il(n.wrapper,this.#w())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){Array.isArray(e)?this.#t.resetPaths(e,t):this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),il(t.wrapper,this.#w()))}setGitStatus(e){let t=Ga(e,this.#p);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&il(n.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),il(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),al(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),il(r,this.#w())}#C(){return{initialViewportHeight:ul({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(w,e());return}this.#l.setSlotHtml(w,this.#e?.header?.html??null)}#k(e){let t=pl(e).find(e=>fl(e)),n=dl(dt(mt(this.#m).set));n!=null&&(t==null||t.outerHTML!==n.outerHTML)&&(t==null?e.prepend(n):t.replaceWith(n))}#A(e){let t=pl(e),n=t.find(e=>fl(e)),r=t.filter(e=>e!==n),i=mt(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=dl(i);if(a==null){for(let e of r)e.remove();return}if(r.length!==1||r[0].outerHTML!==a.outerHTML){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=mt(this.#m);t.colored&&pt(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${x}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}(this.#g?.parentNode!==e||this.#_!==this.#h)&&(this.#g??=document.createElement(`style`),this.#g.setAttribute(x,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=xt(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Tt(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function hl(e){let[t]=(0,E.useState)(()=>new ml(e)),n=(0,E.useRef)({timeout:null,model:t});return(0,E.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function gl(e){return e.name.startsWith(`.`)}function _l(e,t,n=0){return a(e,u,m.of(e,`tree`,e?.capabilities.version??0,t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),{...i,entries:i.entries.filter(e=>!gl(e))}})}function vl(){return{known:new Set,projected:new Map}}function yl(e,t){t.known.clear(),t.projected.clear(),e.resetPaths([])}function bl(e,t,n){t.length===0&&yl(e,n);for(let{request:r,listing:i}of t){let t=`${r?.path??i.path}:${String(r?.offset??0)}`,a=i.entries.filter(e=>e.type!==`symlink`).map(e=>xl(i.path,e.name,e.type)),o=n.projected.get(t)??[];n.projected.set(t,a);let s=new Set([...n.projected.values()].flat());for(let t of o)if(!s.has(t)){e.getItem(t)&&e.remove(t,{recursive:!0});for(let e of n.known)(e===t||t.endsWith(`/`)&&e.startsWith(t))&&n.known.delete(e)}Sl(e,i,n.known)}}function xl(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function Sl(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>xl(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));i.length>0&&e.batch(i.map(e=>({type:`add`,path:e}))),n.add(t.path);for(let e of r)n.add(e);return i}function Cl(e,t){let n=t===`/`?`/`:t.replace(/\/+$/,``);if(n!==`/`&&e!==n&&!e.startsWith(`${n}/`))return[];let r=n===`/`?e.split(`/`).filter(Boolean):e.slice(n.length).split(`/`).filter(Boolean),i=[n],a=n;for(let e of r.slice(0,-1))a=`${a===`/`?``:a}/${e}`,i.push(a);return i}function wl({app:e,rootPath:t,activePath:r}){let i=h(),a=g(e),o=(0,E.useCallback)(t=>e.capabilities.subscribe(t),[e]),s=(0,E.useCallback)(()=>e.capabilities.version,[e]),c=(0,E.useSyncExternalStore)(o,s,s),l=(0,E.useMemo)(()=>({app:e,rootPath:t,computerId:a,version:c}),[e,t,a,c]),[u,d]=(0,E.useState)(null),f=u?.scope===l?u:null,p=r?Cl(r,t):[],_=f?.activePath===r?f.path:p.at(-1)??t,v=new Map;for(let e of[t,...p])v.set(`${e}:0`,{path:e,offset:0});for(let e of f?.pages??[])v.set(`${e.path}:${String(e.offset)}`,e);let y=[...v.values()],b=(t,n)=>m.of(e,`tree`,c,t,n);return{scope:l,snapshot:n({queries:y.map(({path:t,offset:n})=>_l(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:y[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),focusedPath:_,requestPage:(e,t)=>{let n=e.replace(/\/+$/,``)||`/`,a=b(n,t);i.getQueryState(a)?.status===`error`&&i.invalidateQueries({queryKey:a,exact:!0}),d(e=>({scope:l,activePath:r,path:n,pages:[...e?.scope===l?e.pages.filter(e=>e.path!==n||e.offset!==t):[],{path:n,offset:t}]}))},reload:()=>{i.invalidateQueries({queryKey:m.of(e,`tree`,c)})}}}var Tl=()=>globalThis.matchMedia(`(pointer: coarse)`).matches?44:32,El=()=>`Library`,Dl=(e,t)=>`${El()}${t.slice(e.length)}`,Ol=(e,t)=>`${e}${t.replace(/\/$/,``).slice(El().length)}`,kl=e=>e===void 0?`${El()}/`:`${El()}/${e}/`;function Al(e){if(!e.endsWith(`/`))return null;let t=e.slice(0,-1);return t===El()?{folder:void 0}:t.startsWith(`${El()}/`)?{folder:t.slice(El().length+1)}:null}var jl=e=>e.replace(/\/$/,``)===El(),Ml=e=>({flex:1,minHeight:0,"--trees-item-height":`${String(e)}px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--stipe-hairline)`,"--trees-focus-ring-color-override":`var(--color-primary)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`13px`,"--trees-search-bg-override":`var(--color-base-200)`,"--trees-search-fg-override":`var(--color-base-content)`});function Nl({app:e,root:n,activeFolder:i,active:a=!0,mode:s,onSelectFolder:c,onDrop:l,onRename:u,onNewFolder:f,onMoveRows:m,canWrite:h,version:g}){let y=kl(i),{scope:b,snapshot:x,requestPage:S,reload:C}=wl({app:e,rootPath:n,activePath:`${t(n,i)}/.`}),ee=(0,E.useRef)(!1),w=(0,E.useRef)({quiet:!1,root:n,mode:s,onSelectFolder:c,onDrop:l,onRename:u,onNewFolder:f,onMoveRows:m,requestPage:S});w.current={quiet:w.current.quiet,root:n,mode:s,onSelectFolder:c,onDrop:l,onRename:u,onNewFolder:f,onMoveRows:m,requestPage:S};let T=s===`browse`&&h,[te]=(0,E.useState)(Tl),{model:O}=hl({paths:[],itemHeight:te,initialExpansion:1,flattenEmptyDirectories:!1,search:s===`browse`,composition:{contextMenu:{enabled:s===`browse`}},onSelectionChange(e){if(w.current.quiet||ee.current)return;let t=e.at(-1);if(t===void 0||e.length!==1)return;let n=Al(t);n!==null&&(w.current.requestPage(Ol(w.current.root,t),0),w.current.onSelectFolder(n.folder))},dragAndDrop:T?{canDrag:e=>e.every(e=>!jl(e)),canDrop:({target:e})=>e.kind===`directory`&&e.directoryPath!==null&&Al(e.directoryPath)!==null,onDropComplete:({draggedPaths:e,target:t})=>{let n=t.directoryPath===null?null:Al(t.directoryPath);n!==null&&w.current.onDrop?.(e.map(e=>Ol(w.current.root,e)),n.folder)}}:void 0,renaming:T?{canRename:e=>!jl(e.path),onRename:({sourcePath:e,destinationPath:t})=>{let n=t.replace(/\/$/,``).split(`/`).at(-1);n!==void 0&&w.current.onRename?.(Ol(w.current.root,e),n)}}:void 0}),ne=(0,E.useRef)(vl());(0,E.useLayoutEffect)(()=>{yl(O,ne.current)},[O,b,g]);let k=(0,E.useRef)(g);(0,E.useEffect)(()=>{k.current!==g&&(k.current=g,C())},[C,g]),(0,E.useLayoutEffect)(()=>{let e=x.listings.map(({request:e,listing:t})=>({request:e,listing:{...t,path:Dl(n,t.path),entries:t.entries.filter(e=>e.type===`directory`)}}));bl(O,e,ne.current)},[O,n,x.listings]);let re=(0,E.useRef)(null);return(0,E.useLayoutEffect)(()=>{w.current.quiet=!0;try{if(!a){re.current=null;for(let e of O.getSelectedPaths())O.getItem(e)?.deselect();return}e()}finally{w.current.quiet=!1}function e(){if(re.current===y)return;let e=O.getItem(y);if(!e)return;re.current=y;for(let e of O.getSelectedPaths())e!==y&&O.getItem(e)?.deselect();e.isSelected()||e.select();let t=y.slice(0,-1).split(`/`);for(let e=1;e<t.length;e+=1){let n=O.getItem(`${t.slice(0,e).join(`/`)}/`);n&&`expand`in n&&!n.isExpanded()&&n.expand()}}},[a,y,O,x.listings]),(0,E.useEffect)(()=>{x.failure&&d.error(r(x.failure).message,{id:`prints-tree-error`,toasterId:`prints-generation-notices`,action:{label:`Retry`,onClick:C}})},[C,x.failure]),(0,D.jsx)(`div`,{className:`prints-tree`,"data-library-tree":s,onDragStartCapture:()=>{ee.current=!0},onDragEnd:()=>{ee.current=!1},onDrop:()=>{ee.current=!1},children:(0,D.jsx)(j,{model:O,className:`prints-tree-view`,style:Ml(te),renderContextMenu:s===`browse`?(e,t)=>{let r=Al(e.path);return(0,D.jsxs)(`div`,{className:`flex min-w-40 flex-col gap-xs p-xs`,role:`menu`,children:[r===null?null:(0,D.jsxs)(p,{className:`w-full justify-start`,disabled:!h,role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),w.current.onNewFolder?.(r.folder)},children:[(0,D.jsx)(_,{"aria-hidden":`true`}),` New folder`]}),(0,D.jsxs)(p,{className:`w-full justify-start`,disabled:!h||jl(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),O.startRenaming(e.path)},children:[(0,D.jsx)(v,{"aria-hidden":`true`}),` Rename`]}),(0,D.jsxs)(p,{className:`w-full justify-start`,disabled:!h||jl(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1});let r=O.getSelectedPaths(),i=r.includes(e.path)?r:[e.path];w.current.onMoveRows?.(i.map(e=>Ol(n,e)))},children:[(0,D.jsx)(o,{"aria-hidden":`true`}),` Move to…`]})]})}:void 0})})}function Pl({view:t,onView:n,onNewFolder:r,canWrite:i,...a}){return(0,D.jsxs)(`nav`,{className:`prints-rail`,"aria-label":`Library`,children:[(0,D.jsxs)(`div`,{className:`prints-rail-views`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":t.kind===`all`?`page`:void 0,onClick:()=>{n({kind:`all`})},children:[(0,D.jsx)(e,{"aria-hidden":!0,size:16}),` All prints`]}),(0,D.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":t.kind===`favorites`?`page`:void 0,onClick:()=>{n({kind:`favorites`})},children:[(0,D.jsx)(f,{"aria-hidden":!0,size:16}),` Favorites`]})]}),(0,D.jsxs)(`div`,{className:`prints-rail-head`,children:[(0,D.jsx)(`span`,{children:`Folders`}),(0,D.jsx)(p,{size:`sm`,variant:`ghost`,"aria-label":`New folder`,title:`New folder`,disabled:!i,onClick:()=>{r(t.kind===`folder`?t.folder:void 0)},children:(0,D.jsx)(_,{"aria-hidden":!0,size:16})})]}),(0,D.jsx)(Nl,{...a,mode:`browse`,canWrite:i,activeFolder:t.kind===`folder`?t.folder:void 0,active:t.kind===`folder`,onNewFolder:r,onSelectFolder:e=>{n({kind:`folder`,folder:e})}})]})}export{Pl as LibraryRail,Nl as LibraryTree};