@quixomatic/rpf 0.3.0 → 0.3.1

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.
@@ -1,4 +1,4 @@
1
- import{$t as e,A as t,At as n,B as r,Bt as i,Ct as a,Dt as o,E as s,Et as c,Ft as l,G as u,Gt as d,Ht as f,I as p,It as m,J as h,Jt as g,Kt as _,Lt as v,Mt as y,N as b,Nt as x,Ot as S,P as C,Pt as w,Qt as T,Rt as E,St as D,T as ee,Tt as O,U as k,Ut as te,Vt as A,W as j,Wt as ne,Xt as M,Yt as N,Zt as re,_ as ie,_t as ae,a as oe,an as se,at as ce,b as le,bt as ue,c as de,cn as fe,ct as pe,d as me,dn as he,dt as ge,en as _e,f as ve,ft as ye,g as be,gt as xe,h as Se,ht as Ce,i as we,in as Te,it as Ee,jt as De,kt as Oe,l as ke,ln as P,lt as Ae,m as je,mt as Me,n as Ne,nn as Pe,o as Fe,on as Ie,ot as Le,p as Re,pn as ze,pt as Be,qt as Ve,r as He,rn as Ue,rt as We,sn as Ge,st as Ke,t as qe,tn as Je,u as Ye,un as Xe,ut as Ze,v as Qe,vt as $e,wt as et,xt as tt,y as nt,yt as rt,z as it,zt as at}from"./index-DgB2FK2g.js";import{$ as ot,$t as st,A as ct,At as lt,B as ut,Bt as dt,C as ft,Ct as pt,D as F,Dt as I,E as mt,Et as ht,F as gt,Ft as _t,G as vt,Gt as yt,H as bt,Ht as xt,I as St,It as L,J as Ct,Jt as wt,K as Tt,Kt as Et,L as Dt,Lt as Ot,M as kt,Mt as At,N as jt,Nt as Mt,O as Nt,Ot as Pt,P as Ft,Pt as It,Q as Lt,Qt as Rt,R as zt,Rt as Bt,S as Vt,St as Ht,T as Ut,Tt as Wt,U as Gt,Ut as Kt,V as R,Vt as qt,W as Jt,Wt as Yt,X as Xt,Xt as Zt,Y as Qt,Yt as $t,Z as en,Zt as tn,_ as nn,_t as rn,a as an,at as on,b as sn,bt as cn,c as ln,ct as un,d as dn,dt as fn,en as pn,et as mn,f as hn,ft as gn,g as _n,gt as vn,h as yn,ht as bn,i as xn,j as Sn,k as Cn,kt as wn,lt as Tn,mt as En,n as Dn,nt as On,o as kn,ot as An,p as jn,pt as Mn,q as Nn,qt as Pn,r as Fn,rt as In,s as Ln,st as Rn,t as zn,tn as Bn,tt as Vn,u as Hn,ut as Un,v as Wn,vt as Gn,w as Kn,wt as qn,x as Jn,xt as Yn,y as Xn,yt as Zn,z as Qn,zt as $n}from"./useNextRenderData-BaDffqa5.js";import{a as er,c as tr,d as nr,l as z,n as rr,o as ir,r as ar,s as or,t as B,u as sr}from"./utils-C9Glzetk.js";import{f as cr,l as lr,n as ur,p as dr,t as fr,u as pr}from"./appendItems-D8y87kIw.js";function mr(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var hr=class extends Ue{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Pe.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Ie(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(mr(e,n).forEach(e=>{e.destroy()}),mr(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=se(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Je(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Pe.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},V=ze(Xe(),1);function gr({queries:t,...n},r){let i=Ge(r),a=_e(),o=e(),s=n.subscribed!==!1,c=V.useMemo(()=>t.map(e=>{let t=i.defaultQueryOptions(e);return t._optimisticResults=a?`isRestoring`:s?`optimistic`:void 0,t}),[t,i,a,s]);c.forEach(e=>{Ve(e);let t=i.getQueryCache().get(e.queryHash);M(e,o,t)}),T(o);let[l]=V.useState(()=>new hr(i,c,n)),[u,d,f]=l.getOptimisticResult(c,n.combine);V.useEffect(()=>{l.setQueries(c,n)},[c,n,l]);let p=!a&&s;V.useSyncExternalStore(V.useCallback(e=>p?l.subscribe(Pe.batchCalls(e)):Te,[l,p]),()=>l.getCurrentResult(),()=>l.getCurrentResult());let m=u.some((e,t)=>N(c[t],e))?u.flatMap((e,t)=>{let n=c[t];if(n&&N(n,e)){let e=new Je(i,n);return g(n,e,o)}return[]}):[];if(m.length>0)throw Promise.all(m);let h=u.find((e,t)=>{let n=c[t];return n&&re({result:e,errorResetBoundary:o,throwOnError:n.throwOnError,query:i.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(h)throw h.error;return d(f())}var _r={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};_r.node;var vr=at(_r),yr={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};yr.node;var br=at(yr),xr=`file-tree-container`,Sr=`data-file-tree-style`,Cr=`data-file-tree-unsafe-css`,wr=`data-file-tree-scrollbar-measure`,Tr=`data-file-tree-scrollbar-gutter-measured`,Er=`--trees-scrollbar-gutter-measured`,Dr=`header`,Or=`context-menu`,kr=`context-menu-trigger`,Ar={compositeOverBg:Pn,contrastRatio:wt,deriveMutedFg:$t,hoverWouldEraseText:Zt,isDarkSurface:tn,isFullyTransparent:Rt,pickReadableForeground:st,relativeLuminance:pn,surfacesMatch:Bn},jr=Object.freeze({searchPlaceholder:`Search…`,contextMenuTrigger:`Options`,renameItem:e=>`Rename ${e}`,gitStatusTitles:Object.freeze({added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`}),containsGitStatusTitle:`Contains git status items`});function Mr(e){if(e==null)return jr;let t=jr,n=e.gitStatusTitles;return{searchPlaceholder:e.searchPlaceholder??t.searchPlaceholder,contextMenuTrigger:e.contextMenuTrigger??t.contextMenuTrigger,renameItem:e.renameItem??t.renameItem,gitStatusTitles:n==null?t.gitStatusTitles:{added:n.added??t.gitStatusTitles.added,deleted:n.deleted??t.gitStatusTitles.deleted,ignored:n.ignored??t.gitStatusTitles.ignored,modified:n.modified??t.gitStatusTitles.modified,renamed:n.renamed??t.gitStatusTitles.renamed,untracked:n.untracked??t.gitStatusTitles.untracked},containsGitStatusTitle:e.containsGitStatusTitle??t.containsGitStatusTitle}}var Nr=5,Pr=32,Fr=128;function Ir(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Lr(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Rr(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 zr(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 Br(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Vr(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 Hr(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,Kr(e,t)}function Ur(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=zr(e).get(t);if(i===void 0)return;let a=i>>Nr;e.childVisibleChunkSums[a]+=r}function Wr(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=qr(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=Pr}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 Gr(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Nr;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Nr}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 Kr(e,t){if(t.childIds.length<Fr){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/Pr),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>>Nr]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function qr(e,t,n,r){let i=Math.min(t.childIds.length,n+Pr),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 Jr=7,Yr=3,Xr=8,Zr=4;function Qr(e,t,n=0){return e<<Zr|n<<Yr|t}function $r(e){return e.depthAndFlags>>>Zr}function ei(e){return(e.depthAndFlags&Xr)>>Yr}function H(e){return(e.depthAndFlags&Xr)!==0}function ti(e){return e.depthAndFlags&Jr}function ni(e,t){return(ti(e)&t)!==0}function ri(e,t){e.depthAndFlags|=t}function ii(e,t){e.depthAndFlags=Qr(t,ti(e),ei(e))}var ai=Symbol(`benchmarkInstrumentation`);function oi(e,t){return t==null||Object.defineProperty(e,ai,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function si(e){return e==null?null:e[ai]??null}function U(e,t,n){return e==null?n():e.measurePhase(t,n)}function ci(e,t,n){Number.isFinite(n)&&e!=null&&e.setCounter(t,n)}function li(e){return e>=48&&e<=57}function ui(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!li(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&&li(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 di(e){let t=e.toLowerCase();return{lowerValue:t,tokens:ui(t)}}function fi(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 pi(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=fi(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function mi(e,t,n){let r=pi(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function hi(e,t){return mi(e,t,di)}function gi(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function _i(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=gi(e,r);return a===gi(t,r)?hi(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 vi(e,t){return _i(e,t)}function yi(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=di(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=gi(e,n);return o===gi(t,n)?mi(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 bi(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=di(e.valueById[t]);return e.sortKeyById[t]=r,r}function xi(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Si(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 Ci(e){let{hasTrailingSlash:t,segments:n}=Si(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function wi(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Si(e);return{requiresDirectory:t,segments:n}}function Ti(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[di(``)]}}function Ei(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 Di(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Oi=Symbol(`pathStorePreparedInputKind`);function ki(e,t){return e[Oi]=t,e}function Ai(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ji(e,t,n){return n==="default"?vi(e,t):n(Ai(e),Ai(t))}function Mi(){return{depthAndFlags:Qr(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Ni(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 Pi(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Fi(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 Ii(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Li(e,t={}){return Ui(e,t).map(e=>e.path)}function Ri(e,t={}){let n=Ui(e,t);return ki({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function zi(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 ki({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Bi(e){let t=e,n=t.preparedPaths;if(t[Oi]===`prepared`&&n!=null)return n;if(!Fi(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Vi(e){let t=e;return t[Oi]===`presorted`&&t.presortedPaths!=null||Ii(t.presortedPaths)?t.presortedPaths:null}function Hi(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Ui(e,t={}){let n=xi(t),r=si(t);ci(r,`workload.inputFiles`,e.length);let i=U(r,`store.preparePathEntries.parse`,()=>e.map(e=>Ci(e)));return U(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>ji(e,t,n.sort))),i}var Wi=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Mi()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=Ti();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=si(e),this.options=xi(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,Ir())}appendPaths(e){return U(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Ci(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,U(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return U(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:Qr(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:Qr(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:Qr(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=Ci(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:Qr(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:Qr(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=Ci(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(U(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||U(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"?yi(this.lastPreparedPath,e,this.segmentSortKeyCache):ji(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=Pi(e),i=n==null?0:Pi(n),a=n==null?0:Ni(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=Ei(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:Qr($r(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Br(i,s),s}createFileChildUnchecked(e,t){let n=Ei(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:Qr($r(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),a}getOrCreateDirectoryChild(e,t){let n=Ei(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&&!H(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:Qr($r(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),this.directories.set(a,Ir()),a}createDirectoryChild(e,t){let n=Ei(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:Qr($r(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),this.directories.set(a,Ir()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!H(n))throw Error(`Path is not a directory: "${t}"`);if(ni(n,1))throw Error(`Duplicate path: "${t}"`);ri(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,Lr());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(H(a)){let t=Lr();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;H(n)&&this.directories.set(t,Ir());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Br(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!H(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 Hr(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Gi(e,t=`closed`,n=null){let r=qi(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 Ki(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function qi(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 Ji(e,t){return ni(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&$r(t)<=e.defaultExpansion}function Yi(e,t,n=e.snapshot.nodes[t]){return n==null||!H(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Ji(e,n)}function Xi(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!H(r))return;let i=Ji(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t)}else i?(e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0):e.expandedDirectoryIds.delete(t)}function Zi(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 Qi(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function $i(e,t){let n=Zi(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 ea(e,t){let n=Zi(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function ta(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 na(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function ra(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 ia(e,t){e.directoryLoadInfoById.delete(t)}function aa(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 oa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function sa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function ca(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function la(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ua(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function da(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function fa(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 pa(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 ma(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 ha(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 ga(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 _a(e,t,n){return{...n,visibleCountDelta:Oa(e)-t}}function va(e,t){let n=Oa(e),r=Ki();e.transactionStack.push(r);try{t()}catch(t){throw xa(e,r,!1),t}xa(e,r,!0,Oa(e)-n)}function ya(e,t){let n=e.instrumentation;n==null?ba(e,t):U(n,`store.events.record`,()=>ba(e,t))}function ba(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;n==null?Ea(e,t):(n.events.push(t),Ta(n,t))}function xa(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?wa(i,t):U(n,`store.events.batch.merge`,()=>wa(i,t));return}let a=Sa(t,r),o=e.instrumentation;o==null?Ea(e,a):U(o,`store.events.batch.commit`,()=>Ea(e,a))}function Sa(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 Ca(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function wa(e,t){for(let n of t.events)e.events.push(n);Ca(e,t)}function Ta(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Ea(e,t){let n=e.instrumentation;n==null?Da(e,t):U(n,`store.events.emit`,()=>Da(e,t))}function Da(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Oa(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function ka(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!H(n)||ni(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||!H(a)?null:i}function Aa(e,t){let n=t;for(;;){let t=ka(e,n);if(t==null)return n;n=t}}function ja(e,t){let n=[t],r=t;for(;;){let t=ka(e,r);if(t==null)return n;n.push(t),r=t}}function Ma(e,t){let n=t==null?e.snapshot.rootId:Va(e,t);return n==null?[]:Ua(e,n)}function Na(e,t){let n=Ci(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=io(e,ro(e,r)),{createdNodeIds:a,directoryId:o}=Wa(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(ni(n,1))throw Error(`Path already exists: "${t}"`);ri(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Ka(e,o,n.basename),s.add(c);Ra(e,o);let l=io(e,o);return oa({affectedAncestorIds:Ba(e,c),affectedNodeIds:[...s],path:t,projectionChanged:ao(i,l)})}function Pa(e,t,n){let r=Va(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(ni(i,2))throw Error(`The root node cannot be removed`);if(H(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=io(e,a),s=to(e,r);Ya(e,a,r,i.nameId),no(e,a),Ra(e,a);let c=io(e,a);return sa({affectedAncestorIds:Ba(e,a),affectedNodeIds:s,path:t,projectionChanged:ao(o,c),recursive:n.recursive===!0})}function Fa(e,t,n,r){let i=Va(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(ni(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=$a(e,i,n),c=io(e,a.parentId),l=io(e,s.parentId),u=Di(e.snapshot.segmentTable,a.nameId),d=Ei(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(H(a)&&lo(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Rr(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&eo(e,p,o,ei(a))===`skip`)return null;let m=a.parentId;Ya(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),co(e,i),Ja(e,s.parentId,i),no(e,m),e.pathCacheVersion++,Ra(e,m),s.parentId!==m&&Ra(e,s.parentId);let h=io(e,m),g=io(e,s.parentId);return ca({affectedAncestorIds:[...new Set([...Ba(e,m),...Ba(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:oo([c,l],[h,g]),to:W(e,i)})}function Ia(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function La(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=Ia(e,t);if(r!=null)return r;if(ni(n,2))return La(e,t,``);let i=W(e,n.parentId),a=Di(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return La(e,t,H(n)?`${o}/`:o)}function Ra(e,t){let n=e.instrumentation;n==null?fo(e,t):U(n,`store.recomputeCountsUpwardFrom`,()=>fo(e,t))}function za(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||!H(o)){uo(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){uo(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Ba(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 Va(e,t){if(t.length===0)return e.snapshot.rootId;let n=wi(t);return Ha(e,n.segments,n.requiresDirectory)}function Ha(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=Rr(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!H(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||ni(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Ua(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ni(n,4))return[];if(!H(n))return[W(e,t)];if(G(e,t).childIds.length===0)return ni(n,1)&&!ni(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||ni(n,4)){i.pop();continue}if(!H(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){ni(n,1)&&!ni(n,2)&&r.push(W(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];o==null?i.pop():(t.childIndex++,i.push({childIndex:0,nodeId:o}))}return r}function Wa(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=Ei(e.snapshot.segmentTable,i),a=G(e,r),o=Rr(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!H(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o}else r=Ga(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Ga(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Qr($r(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Ir()),Ja(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Ka(e,t,n){let r=Ei(e.snapshot.segmentTable,n),i=G(e,t);if(Rr(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${mo(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Qr($r(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Ja(e,t,o),e.activeNodeCount++,o}function qa(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];o==null||Xa(e,n,o)<0?i=a:r=a+1}return r}function Ja(e,t,n){let r=G(e,t),i=K(e,n);Rr(e.snapshot.nodes,r).set(i.nameId,n),Ur(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=qa(e,r,n);r.childIds.splice(a,0,n),Vr(r,a),Kr(e.snapshot.nodes,r)}function Ya(e,t,n,r){let i=G(e,t),a=zr(i),o=a.get(n)??-1;Rr(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Ur(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Vr(i,o),Kr(e.snapshot.nodes,i))}function Xa(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Za(e,t,n):r(Qa(e,t),Qa(e,n))}function Za(e,t,n){let r=K(e,t),i=K(e,n),a=H(r);if(a!==H(i))return a?-1:1;let o=pi(bi(e.snapshot.segmentTable,r.nameId),bi(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Di(e.snapshot.segmentTable,r.nameId),c=Di(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Qa(e,t){let n=K(e,t),r=W(e,t),i=H(n),a=i?r.slice(0,-1):r;return{basename:Di(e.snapshot.segmentTable,n.nameId),depth:$r(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function $a(e,t,n){let r=K(e,t),i=Va(e,n);if(i!=null){let t=K(e,i);if(H(t))return{basename:Di(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=wi(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=wi(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Ha(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function eo(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(ei(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(H(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 to(e,t),Ya(e,a,t,o),no(e,a),Ra(e,a),`handled`}function to(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||!H(i)){H(i)&&e.snapshot.directories.delete(t.nodeId),ri(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),ia(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 no(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!H(t)||ni(t,2)||G(e,n).childIds.length>0)return;ri(t,1),n=t.parentId===n?null:t.parentId}}function ro(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=Rr(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!H(K(e,i)))break;n=i}return n}function io(e,t){let n=so(e,t);if(n==null)return null;let r=Aa(e,n),i=K(e,r),a=n===r?null:ja(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:ei(i)})}function ao(e,t){return oo([e],[t])}function oo(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 so(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!H(t)||ni(t,2))return null;if(!Yi(e,n,t))return n;n=t.parentId}return null}function co(e,t){let n=K(e,t);if(ii(n,(t===e.snapshot.rootId?-1:$r(K(e,n.parentId)))+1),!H(n))return;let r=G(e,t);for(let t of r.childIds)co(e,t)}function lo(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 uo(e,t,n=K(e,t),r=!1){let i=e.instrumentation;i==null?po(e,t,n,r):U(i,`store.recomputeNodeCounts`,()=>po(e,t,n,r))}function fo(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(uo(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Ur(G(e,s),n,a,o),n=s}}function po(e,t,n,r){if(!H(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?Hr(e.snapshot.nodes,i):U(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Hr(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;n.subtreeNodeCount=a,n.visibleSubtreeCount=ni(n,2)?o:ka(e,t)==null?Yi(e,t,n)?1+o:1:o}function mo(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function ho(e){return e!=null&&!ni(e,4)}function go(e,t){let n=e.snapshot.nodes[t];return!ho(n)||!H(n)||ni(n,2)?null:n}function _o(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ho(e.snapshot.nodes[n])&&(t+=1);return t}function vo(e){return Math.max(0,e.valueById.length-1)}function yo(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:_o(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:vo(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function bo(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 xo(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)go(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)go(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function So(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)go(e,n)!=null&&Qi(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function Co(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Va(e,n);t!=null&&Xi(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=Va(e,n);t!=null&&Xi(e,t,!1,K(e,t))}}function wo(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Va(e,n.path);t!=null&&go(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function To(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Eo(e){let t=e.snapshot.segmentTable,n=Ti();for(let r of e.snapshot.nodes)ho(r)&&(r.nameId=ni(r,2)?0:Ei(n,Di(t,r.nameId)));e.snapshot.segmentTable=n}function Do(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ho(r)||!H(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ho(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])),Hr(e.snapshot.nodes,n)}}function Oo(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId&&!ho(e.snapshot.nodes[t]);)--t;e.snapshot.nodes.length=t+1}function ko(e){let t=xo(e),n=So(e);U(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>To(e)),U(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Eo(e)),U(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Do(e)),U(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Oo(e)),U(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Co(e,t)),U(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>wo(e,n)),U(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>za(e,e.snapshot.rootId))}function Ao(e){let t=xo(e),n=So(e),r=U(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Ma(e)),i=oi({...e.snapshot.options},e.instrumentation),a=U(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Wi(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,U(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Co(e,t)),U(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>wo(e,n)),U(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>za(e,e.snapshot.rootId))}function jo(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Mo(e,t){let n=yo(e);t===`stable`?U(e.instrumentation,`store.cleanup.stable`,()=>ko(e)):U(e.instrumentation,`store.cleanup.aggressive`,()=>Ao(e));let r=yo(e);return bo(t,t===`stable`,n,r)}var No=64;function Po(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 Fo(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function Io(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 Lo(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:ns(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Io(e,t.cursor,t.index,n)}}function Ro(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=Wr(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return zo(e,u,l,r+c,i+1,s,o.childIds.length,a)}function zo(e,t,n,r,i,a,o,s){if(!H(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=Xo(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!H(l)||!Yi(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ro(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Bo(e,t){let n=Fo(e);if(t<0||t>=n)return null;let r=Ro(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=Lo(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:ns(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Io(e,r.cursor,r.index,n)}}function Vo(e,t,n){let r=e.instrumentation,i=Fo(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 ts(e,o+1);let t=[],n=qo(e,a);for(let r=a;r<=o&&n!=null;r++){let r=ns(e,n);t.push(r),n=Qo(e,n)}return t}let s=[],c=0,l=0,u=U(r,`store.getVisibleSlice.selectFirstRow`,()=>qo(e,a));for(let t=a;t<=o&&u!=null;t++){let t=U(r,`store.getVisibleSlice.materializeRow`,()=>ns(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=U(r,`store.getVisibleSlice.advanceCursor`,()=>Qo(e,u))}return ci(r,`workload.visibleRowsRead`,s.length),ci(r,`workload.flattenedRowsRead`,c),ci(r,`workload.flattenedSegmentsRead`,l),s}function Ho(e,t=Fo(e)){let n=e.instrumentation;return n==null?es(e,t):U(n,`store.getVisibleTreeProjection`,()=>es(e,t))}function Uo(e){return $o(Ho(e))}function Wo(e,t){let n=Va(e,t);if(n==null||n===e.snapshot.rootId||H(K(e,n))&&Aa(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=zr(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Gr(a,n,s),t!==o){let n=K(e,t),a=ka(e,t);if(!Yi(e,t,n)&&a!==i)return null;Aa(e,t)===t&&(r+=1)}i=t}return r}function Go(e,t){let n=Va(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!H(r))throw Error(`Path is not a directory: "${t}"`);return Yi(e,n,r)?null:(Xi(e,n,!0,r),Ra(e,n),la({affectedAncestorIds:Ba(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Ko(e,t){let n=Va(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!H(r))throw Error(`Path is not a directory: "${t}"`);return Yi(e,n,r)?(Xi(e,n,!1,r),Ra(e,n),ua({affectedAncestorIds:Ba(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function qo(e,t){return t<0||t>=Fo(e)?null:Jo(e,e.snapshot.rootId,t,-1)}function Jo(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?Wr(e.snapshot.nodes,i,n):U(a,`store.getVisibleSlice.selectChildIndex`,()=>Wr(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Yo(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Yo(e,t,n,r){if(!H(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=Xo(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!H(a)||!Yi(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Jo(e,i.terminalNodeId,n-1,i.visibleDepth)}function Xo(e,t,n){return H(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Aa(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:U(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Aa(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Zo(e,t){let n=K(e,t);if(!H(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||ka(e,r)!==t}function Qo(e,t){let n=K(e,t.terminalNodeId);if(H(n)){let r=G(e,t.terminalNodeId);if(Yi(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Yo(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=zr(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 Yo(e,s,0,i);Zo(e,r)&&i--,r=n}}function $o(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 es(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(No);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=Po(o,y);let x,S=_;if(H(v))S=f?Aa(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]}`}let C=o[y];r[s]=C,n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let w=c[S];w!=null&&H(w)&&Yi(e,S,w)&&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 ts(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(!H(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?Aa(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=ns(e,g);let _=i[h];_!=null&&H(_)&&Yi(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function ns(e,t){let n=K(e,t.terminalNodeId),r=H(n)?rs(e,t):null,i=W(e,t.terminalNodeId),a=Di(e.snapshot.segmentTable,n.nameId),o=H(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?ja(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:Di(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):U(c,`store.getVisibleSlice.flatten.collectSegments`,()=>ja(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:Di(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:H(n)&&Yi(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:H(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function rs(e,t){if(t.headNodeId===t.terminalNodeId)return Qi(e,t.terminalNodeId);let n=ja(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Qi(e,t);if(n===`loading`)return`loading`;n===`error`?i=!0:n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var is=8;function as(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 os(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]&is)===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]]&is)===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 ss(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||!H(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&&Kr(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&H(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,Kr(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function cs(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=as(e.snapshot);os(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)&&Kr(n,i)}}function ls(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var us=class e{#e;constructor(e={}){let t=si(e),n=U(t,`store.builder.create`,()=>new Wi(e));if(e.preparedInput!=null){let t=Vi(e.preparedInput);t==null?n.appendPreparedPaths(Bi(e.preparedInput),!1):n.appendPresortedPaths(t,Hi(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(U(t,`store.preparePathEntries`,()=>Ui(r,e)))}let r=U(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=U(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=U(t,`store.state.create`,()=>Gi(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:U(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||ls(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&U(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?U(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>cs(this.#e)):U(t,`store.state.initializeOpenVisibleCounts`,()=>ss(this.#e)):U(t,`store.state.recomputeCounts`,()=>za(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Li(e,t)}static prepareInput(e,t={}){return Ri(e,t)}static preparePresortedInput(e){return zi(e)}list(e){return U(this.#e.instrumentation,`store.list`,()=>Ma(this.#e,e))}add(e){U(this.#e.instrumentation,`store.add`,()=>{let t=Fo(this.#e);ya(this.#e,_a(this.#e,t,Na(this.#e,e)))})}remove(e,t={}){U(this.#e.instrumentation,`store.remove`,()=>{let n=Fo(this.#e);ya(this.#e,_a(this.#e,n,Pa(this.#e,e,t)))})}move(e,t,n={}){U(this.#e.instrumentation,`store.move`,()=>{let r=Fo(this.#e),i=Fa(this.#e,e,t,n);i!=null&&ya(this.#e,_a(this.#e,r,i))})}batch(e){va(this.#e,()=>{if(typeof e==`function`)e(this);else 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 U(this.#e.instrumentation,`store.getVisibleCount`,()=>Fo(this.#e))}getVisibleSlice(e,t){return U(this.#e.instrumentation,`store.getVisibleSlice`,()=>Vo(this.#e,e,t))}getVisibleRowContext(e){return U(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Bo(this.#e,e))}getVisibleTreeProjection(){return Uo(this.#e)}getVisibleTreeProjectionData(e){return Ho(this.#e,e)}getVisibleIndex(e){return U(this.#e.instrumentation,`store.getVisibleIndex`,()=>Wo(this.#e,e))}getPathInfo(e){return U(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Va(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:$r(n),kind:H(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return U(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Yi(this.#e,t,n)})}expand(e){U(this.#e.instrumentation,`store.expand`,()=>{let t=Fo(this.#e),n=Go(this.#e,e);n!=null&&ya(this.#e,_a(this.#e,t,n))})}collapse(e){U(this.#e.instrumentation,`store.collapse`,()=>{let t=Fo(this.#e),n=Ko(this.#e,e);n!=null&&ya(this.#e,_a(this.#e,t,n))})}on(e,t){return aa(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Qi(this.#e,t)}markDirectoryUnloaded(e){U(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=Fo(this.#e);ea(this.#e,t),ya(this.#e,_a(this.#e,n,da({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return U(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=Fo(this.#e),r=$i(this.#e,t);return ya(this.#e,_a(this.#e,n,fa({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return U(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Qi(this.#e,n)!==`loading`||!na(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=Fo(this.#e),a=[];for(let e of t.operations){ds(r,e);let t=Fo(this.#e);switch(e.type){case`add`:a.push(_a(this.#e,t,Na(this.#e,e.path)));break;case`remove`:a.push(_a(this.#e,t,Pa(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Fa(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(_a(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ya(this.#e,_a(this.#e,i,pa({affectedAncestorIds:Ba(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return U(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=Fo(this.#e),r=ta(this.#e,t,e.attemptId);return ya(this.#e,_a(this.#e,n,ma({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return U(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=Fo(this.#e),i=ra(this.#e,n,e.attemptId,t);return ya(this.#e,_a(this.#e,r,ha({affectedAncestorIds:Ba(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 U(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(jo(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=Fo(this.#e),n=Mo(this.#e,e.mode??`stable`);return ya(this.#e,_a(this.#e,t,ga({...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)??di(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=pi(bi(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(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;else for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=K(this.#e,n);Yi(this.#e,n,i)||(Xi(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(!Yi(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Va(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!H(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!H(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=ka(this.#e,e);if(!Yi(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 ds(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 fs={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function ps(e,t){if(typeof e==`number`)return{itemHeight:t??fs.default.itemHeight,factor:e};let n=fs[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ms=fs.default.itemHeight,hs=`@layer base {
1
+ import{$t as e,A as t,At as n,B as r,Bt as i,Ct as a,Dt as o,E as s,Et as c,Ft as l,G as u,Gt as d,Ht as f,I as p,It as m,J as h,Jt as g,Kt as _,Lt as v,Mt as y,N as b,Nt as x,Ot as S,P as C,Pt as w,Qt as T,Rt as E,St as D,T as ee,Tt as O,U as k,Ut as te,Vt as A,W as j,Wt as ne,Xt as M,Yt as N,Zt as re,_ as ie,_t as ae,a as oe,an as se,at as ce,b as le,bt as ue,c as de,cn as fe,ct as pe,d as me,dn as he,dt as ge,en as _e,f as ve,ft as ye,g as be,gt as xe,h as Se,ht as Ce,i as we,in as Te,it as Ee,jt as De,kt as Oe,l as ke,ln as P,lt as Ae,m as je,mt as Me,n as Ne,nn as Pe,o as Fe,on as Ie,ot as Le,p as Re,pn as ze,pt as Be,qt as Ve,r as He,rn as Ue,rt as We,sn as Ge,st as Ke,t as qe,tn as Je,u as Ye,un as Xe,ut as Ze,v as Qe,vt as $e,wt as et,xt as tt,y as nt,yt as rt,z as it,zt as at}from"./index-UP3KtgHV.js";import{$ as ot,$t as st,A as ct,At as lt,B as ut,Bt as dt,C as ft,Ct as pt,D as F,Dt as I,E as mt,Et as ht,F as gt,Ft as _t,G as vt,Gt as yt,H as bt,Ht as xt,I as St,It as L,J as Ct,Jt as wt,K as Tt,Kt as Et,L as Dt,Lt as Ot,M as kt,Mt as At,N as jt,Nt as Mt,O as Nt,Ot as Pt,P as Ft,Pt as It,Q as Lt,Qt as Rt,R as zt,Rt as Bt,S as Vt,St as Ht,T as Ut,Tt as Wt,U as Gt,Ut as Kt,V as R,Vt as qt,W as Jt,Wt as Yt,X as Xt,Xt as Zt,Y as Qt,Yt as $t,Z as en,Zt as tn,_ as nn,_t as rn,a as an,at as on,b as sn,bt as cn,c as ln,ct as un,d as dn,dt as fn,en as pn,et as mn,f as hn,ft as gn,g as _n,gt as vn,h as yn,ht as bn,i as xn,j as Sn,k as Cn,kt as wn,lt as Tn,mt as En,n as Dn,nt as On,o as kn,ot as An,p as jn,pt as Mn,q as Nn,qt as Pn,r as Fn,rt as In,s as Ln,st as Rn,t as zn,tn as Bn,tt as Vn,u as Hn,ut as Un,v as Wn,vt as Gn,w as Kn,wt as qn,x as Jn,xt as Yn,y as Xn,yt as Zn,z as Qn,zt as $n}from"./useNextRenderData-dgMkjxGZ.js";import{a as er,c as tr,d as nr,l as z,n as rr,o as ir,r as ar,s as or,t as B,u as sr}from"./utils-C9Glzetk.js";import{f as cr,l as lr,n as ur,p as dr,t as fr,u as pr}from"./appendItems-CWJJlOE7.js";function mr(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var hr=class extends Ue{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Pe.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Ie(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(mr(e,n).forEach(e=>{e.destroy()}),mr(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=se(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Je(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Pe.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},V=ze(Xe(),1);function gr({queries:t,...n},r){let i=Ge(r),a=_e(),o=e(),s=n.subscribed!==!1,c=V.useMemo(()=>t.map(e=>{let t=i.defaultQueryOptions(e);return t._optimisticResults=a?`isRestoring`:s?`optimistic`:void 0,t}),[t,i,a,s]);c.forEach(e=>{Ve(e);let t=i.getQueryCache().get(e.queryHash);M(e,o,t)}),T(o);let[l]=V.useState(()=>new hr(i,c,n)),[u,d,f]=l.getOptimisticResult(c,n.combine);V.useEffect(()=>{l.setQueries(c,n)},[c,n,l]);let p=!a&&s;V.useSyncExternalStore(V.useCallback(e=>p?l.subscribe(Pe.batchCalls(e)):Te,[l,p]),()=>l.getCurrentResult(),()=>l.getCurrentResult());let m=u.some((e,t)=>N(c[t],e))?u.flatMap((e,t)=>{let n=c[t];if(n&&N(n,e)){let e=new Je(i,n);return g(n,e,o)}return[]}):[];if(m.length>0)throw Promise.all(m);let h=u.find((e,t)=>{let n=c[t];return n&&re({result:e,errorResetBoundary:o,throwOnError:n.throwOnError,query:i.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(h)throw h.error;return d(f())}var _r={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};_r.node;var vr=at(_r),yr={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};yr.node;var br=at(yr),xr=`file-tree-container`,Sr=`data-file-tree-style`,Cr=`data-file-tree-unsafe-css`,wr=`data-file-tree-scrollbar-measure`,Tr=`data-file-tree-scrollbar-gutter-measured`,Er=`--trees-scrollbar-gutter-measured`,Dr=`header`,Or=`context-menu`,kr=`context-menu-trigger`,Ar={compositeOverBg:Pn,contrastRatio:wt,deriveMutedFg:$t,hoverWouldEraseText:Zt,isDarkSurface:tn,isFullyTransparent:Rt,pickReadableForeground:st,relativeLuminance:pn,surfacesMatch:Bn},jr=Object.freeze({searchPlaceholder:`Search…`,contextMenuTrigger:`Options`,renameItem:e=>`Rename ${e}`,gitStatusTitles:Object.freeze({added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`}),containsGitStatusTitle:`Contains git status items`});function Mr(e){if(e==null)return jr;let t=jr,n=e.gitStatusTitles;return{searchPlaceholder:e.searchPlaceholder??t.searchPlaceholder,contextMenuTrigger:e.contextMenuTrigger??t.contextMenuTrigger,renameItem:e.renameItem??t.renameItem,gitStatusTitles:n==null?t.gitStatusTitles:{added:n.added??t.gitStatusTitles.added,deleted:n.deleted??t.gitStatusTitles.deleted,ignored:n.ignored??t.gitStatusTitles.ignored,modified:n.modified??t.gitStatusTitles.modified,renamed:n.renamed??t.gitStatusTitles.renamed,untracked:n.untracked??t.gitStatusTitles.untracked},containsGitStatusTitle:e.containsGitStatusTitle??t.containsGitStatusTitle}}var Nr=5,Pr=32,Fr=128;function Ir(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Lr(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Rr(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 zr(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 Br(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Vr(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 Hr(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,Kr(e,t)}function Ur(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=zr(e).get(t);if(i===void 0)return;let a=i>>Nr;e.childVisibleChunkSums[a]+=r}function Wr(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=qr(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=Pr}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 Gr(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Nr;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Nr}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 Kr(e,t){if(t.childIds.length<Fr){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/Pr),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>>Nr]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function qr(e,t,n,r){let i=Math.min(t.childIds.length,n+Pr),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 Jr=7,Yr=3,Xr=8,Zr=4;function Qr(e,t,n=0){return e<<Zr|n<<Yr|t}function $r(e){return e.depthAndFlags>>>Zr}function ei(e){return(e.depthAndFlags&Xr)>>Yr}function H(e){return(e.depthAndFlags&Xr)!==0}function ti(e){return e.depthAndFlags&Jr}function ni(e,t){return(ti(e)&t)!==0}function ri(e,t){e.depthAndFlags|=t}function ii(e,t){e.depthAndFlags=Qr(t,ti(e),ei(e))}var ai=Symbol(`benchmarkInstrumentation`);function oi(e,t){return t==null||Object.defineProperty(e,ai,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function si(e){return e==null?null:e[ai]??null}function U(e,t,n){return e==null?n():e.measurePhase(t,n)}function ci(e,t,n){Number.isFinite(n)&&e!=null&&e.setCounter(t,n)}function li(e){return e>=48&&e<=57}function ui(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!li(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&&li(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 di(e){let t=e.toLowerCase();return{lowerValue:t,tokens:ui(t)}}function fi(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 pi(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=fi(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function mi(e,t,n){let r=pi(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function hi(e,t){return mi(e,t,di)}function gi(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function _i(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=gi(e,r);return a===gi(t,r)?hi(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 vi(e,t){return _i(e,t)}function yi(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=di(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=gi(e,n);return o===gi(t,n)?mi(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 bi(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=di(e.valueById[t]);return e.sortKeyById[t]=r,r}function xi(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Si(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 Ci(e){let{hasTrailingSlash:t,segments:n}=Si(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function wi(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Si(e);return{requiresDirectory:t,segments:n}}function Ti(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[di(``)]}}function Ei(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 Di(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Oi=Symbol(`pathStorePreparedInputKind`);function ki(e,t){return e[Oi]=t,e}function Ai(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ji(e,t,n){return n==="default"?vi(e,t):n(Ai(e),Ai(t))}function Mi(){return{depthAndFlags:Qr(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Ni(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 Pi(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Fi(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 Ii(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Li(e,t={}){return Ui(e,t).map(e=>e.path)}function Ri(e,t={}){let n=Ui(e,t);return ki({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function zi(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 ki({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Bi(e){let t=e,n=t.preparedPaths;if(t[Oi]===`prepared`&&n!=null)return n;if(!Fi(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function Vi(e){let t=e;return t[Oi]===`presorted`&&t.presortedPaths!=null||Ii(t.presortedPaths)?t.presortedPaths:null}function Hi(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Ui(e,t={}){let n=xi(t),r=si(t);ci(r,`workload.inputFiles`,e.length);let i=U(r,`store.preparePathEntries.parse`,()=>e.map(e=>Ci(e)));return U(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>ji(e,t,n.sort))),i}var Wi=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Mi()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=Ti();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=si(e),this.options=xi(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,Ir())}appendPaths(e){return U(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Ci(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,U(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return U(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:Qr(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:Qr(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:Qr(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=Ci(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:Qr(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:Qr(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=Ci(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(U(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||U(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"?yi(this.lastPreparedPath,e,this.segmentSortKeyCache):ji(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=Pi(e),i=n==null?0:Pi(n),a=n==null?0:Ni(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=Ei(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:Qr($r(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Br(i,s),s}createFileChildUnchecked(e,t){let n=Ei(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:Qr($r(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),a}getOrCreateDirectoryChild(e,t){let n=Ei(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&&!H(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:Qr($r(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),this.directories.set(a,Ir()),a}createDirectoryChild(e,t){let n=Ei(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:Qr($r(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Br(r,a),this.directories.set(a,Ir()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!H(n))throw Error(`Path is not a directory: "${t}"`);if(ni(n,1))throw Error(`Duplicate path: "${t}"`);ri(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,Lr());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(H(a)){let t=Lr();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;H(n)&&this.directories.set(t,Ir());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Br(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!H(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 Hr(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Gi(e,t=`closed`,n=null){let r=qi(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 Ki(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function qi(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 Ji(e,t){return ni(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&$r(t)<=e.defaultExpansion}function Yi(e,t,n=e.snapshot.nodes[t]){return n==null||!H(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Ji(e,n)}function Xi(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!H(r))return;let i=Ji(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t)}else i?(e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0):e.expandedDirectoryIds.delete(t)}function Zi(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 Qi(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function $i(e,t){let n=Zi(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 ea(e,t){let n=Zi(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function ta(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 na(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function ra(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 ia(e,t){e.directoryLoadInfoById.delete(t)}function aa(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 oa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function sa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function ca(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function la(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ua(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function da(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function fa(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 pa(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 ma(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 ha(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 ga(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 _a(e,t,n){return{...n,visibleCountDelta:Oa(e)-t}}function va(e,t){let n=Oa(e),r=Ki();e.transactionStack.push(r);try{t()}catch(t){throw xa(e,r,!1),t}xa(e,r,!0,Oa(e)-n)}function ya(e,t){let n=e.instrumentation;n==null?ba(e,t):U(n,`store.events.record`,()=>ba(e,t))}function ba(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;n==null?Ea(e,t):(n.events.push(t),Ta(n,t))}function xa(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?wa(i,t):U(n,`store.events.batch.merge`,()=>wa(i,t));return}let a=Sa(t,r),o=e.instrumentation;o==null?Ea(e,a):U(o,`store.events.batch.commit`,()=>Ea(e,a))}function Sa(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 Ca(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function wa(e,t){for(let n of t.events)e.events.push(n);Ca(e,t)}function Ta(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Ea(e,t){let n=e.instrumentation;n==null?Da(e,t):U(n,`store.events.emit`,()=>Da(e,t))}function Da(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Oa(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function ka(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!H(n)||ni(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||!H(a)?null:i}function Aa(e,t){let n=t;for(;;){let t=ka(e,n);if(t==null)return n;n=t}}function ja(e,t){let n=[t],r=t;for(;;){let t=ka(e,r);if(t==null)return n;n.push(t),r=t}}function Ma(e,t){let n=t==null?e.snapshot.rootId:Va(e,t);return n==null?[]:Ua(e,n)}function Na(e,t){let n=Ci(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=io(e,ro(e,r)),{createdNodeIds:a,directoryId:o}=Wa(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=K(e,o);if(ni(n,1))throw Error(`Path already exists: "${t}"`);ri(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Ka(e,o,n.basename),s.add(c);Ra(e,o);let l=io(e,o);return oa({affectedAncestorIds:Ba(e,c),affectedNodeIds:[...s],path:t,projectionChanged:ao(i,l)})}function Pa(e,t,n){let r=Va(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=K(e,r);if(ni(i,2))throw Error(`The root node cannot be removed`);if(H(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=io(e,a),s=to(e,r);Ya(e,a,r,i.nameId),no(e,a),Ra(e,a);let c=io(e,a);return sa({affectedAncestorIds:Ba(e,a),affectedNodeIds:s,path:t,projectionChanged:ao(o,c),recursive:n.recursive===!0})}function Fa(e,t,n,r){let i=Va(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=K(e,i);if(ni(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=$a(e,i,n),c=io(e,a.parentId),l=io(e,s.parentId),u=Di(e.snapshot.segmentTable,a.nameId),d=Ei(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(H(a)&&lo(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Rr(e.snapshot.nodes,G(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&eo(e,p,o,ei(a))===`skip`)return null;let m=a.parentId;Ya(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),co(e,i),Ja(e,s.parentId,i),no(e,m),e.pathCacheVersion++,Ra(e,m),s.parentId!==m&&Ra(e,s.parentId);let h=io(e,m),g=io(e,s.parentId);return ca({affectedAncestorIds:[...new Set([...Ba(e,m),...Ba(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:oo([c,l],[h,g]),to:W(e,i)})}function Ia(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function La(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function W(e,t){let n=K(e,t),r=Ia(e,t);if(r!=null)return r;if(ni(n,2))return La(e,t,``);let i=W(e,n.parentId),a=Di(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return La(e,t,H(n)?`${o}/`:o)}function Ra(e,t){let n=e.instrumentation;n==null?fo(e,t):U(n,`store.recomputeCountsUpwardFrom`,()=>fo(e,t))}function za(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||!H(o)){uo(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){uo(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Ba(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 Va(e,t){if(t.length===0)return e.snapshot.rootId;let n=wi(t);return Ha(e,n.segments,n.requiresDirectory)}function Ha(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=Rr(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=K(e,r);return n&&!H(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||ni(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Ua(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ni(n,4))return[];if(!H(n))return[W(e,t)];if(G(e,t).childIds.length===0)return ni(n,1)&&!ni(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||ni(n,4)){i.pop();continue}if(!H(n)){r.push(W(e,t.nodeId)),i.pop();continue}let a=G(e,t.nodeId);if(a.childIds.length===0){ni(n,1)&&!ni(n,2)&&r.push(W(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];o==null?i.pop():(t.childIndex++,i.push({childIndex:0,nodeId:o}))}return r}function Wa(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=Ei(e.snapshot.segmentTable,i),a=G(e,r),o=Rr(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!H(K(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o}else r=Ga(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Ga(e,t,n){let r=K(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Qr($r(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Ir()),Ja(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Ka(e,t,n){let r=Ei(e.snapshot.segmentTable,n),i=G(e,t);if(Rr(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${mo(e,t,n)}"`);let a=K(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Qr($r(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Ja(e,t,o),e.activeNodeCount++,o}function qa(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];o==null||Xa(e,n,o)<0?i=a:r=a+1}return r}function Ja(e,t,n){let r=G(e,t),i=K(e,n);Rr(e.snapshot.nodes,r).set(i.nameId,n),Ur(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=qa(e,r,n);r.childIds.splice(a,0,n),Vr(r,a),Kr(e.snapshot.nodes,r)}function Ya(e,t,n,r){let i=G(e,t),a=zr(i),o=a.get(n)??-1;Rr(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Ur(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Vr(i,o),Kr(e.snapshot.nodes,i))}function Xa(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Za(e,t,n):r(Qa(e,t),Qa(e,n))}function Za(e,t,n){let r=K(e,t),i=K(e,n),a=H(r);if(a!==H(i))return a?-1:1;let o=pi(bi(e.snapshot.segmentTable,r.nameId),bi(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Di(e.snapshot.segmentTable,r.nameId),c=Di(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function Qa(e,t){let n=K(e,t),r=W(e,t),i=H(n),a=i?r.slice(0,-1):r;return{basename:Di(e.snapshot.segmentTable,n.nameId),depth:$r(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function $a(e,t,n){let r=K(e,t),i=Va(e,n);if(i!=null){let t=K(e,i);if(H(t))return{basename:Di(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=wi(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=wi(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Ha(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function eo(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(ei(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(H(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 to(e,t),Ya(e,a,t,o),no(e,a),Ra(e,a),`handled`}function to(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||!H(i)){H(i)&&e.snapshot.directories.delete(t.nodeId),ri(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),ia(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 no(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!H(t)||ni(t,2)||G(e,n).childIds.length>0)return;ri(t,1),n=t.parentId===n?null:t.parentId}}function ro(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=Rr(e.snapshot.nodes,G(e,n)).get(t);if(i==null||!H(K(e,i)))break;n=i}return n}function io(e,t){let n=so(e,t);if(n==null)return null;let r=Aa(e,n),i=K(e,r),a=n===r?null:ja(e,n).map(t=>W(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:G(e,r).childIds.length>0,path:W(e,r),terminalKind:ei(i)})}function ao(e,t){return oo([e],[t])}function oo(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 so(e,t){let n=t;for(;n!=null;){let t=K(e,n);if(!H(t)||ni(t,2))return null;if(!Yi(e,n,t))return n;n=t.parentId}return null}function co(e,t){let n=K(e,t);if(ii(n,(t===e.snapshot.rootId?-1:$r(K(e,n.parentId)))+1),!H(n))return;let r=G(e,t);for(let t of r.childIds)co(e,t)}function lo(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 uo(e,t,n=K(e,t),r=!1){let i=e.instrumentation;i==null?po(e,t,n,r):U(i,`store.recomputeNodeCounts`,()=>po(e,t,n,r))}function fo(e,t){let n=t;for(;n!=null;){let t=K(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(uo(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Ur(G(e,s),n,a,o),n=s}}function po(e,t,n,r){if(!H(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=G(e,t);if(r){let t=e.instrumentation;t==null?Hr(e.snapshot.nodes,i):U(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Hr(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;n.subtreeNodeCount=a,n.visibleSubtreeCount=ni(n,2)?o:ka(e,t)==null?Yi(e,t,n)?1+o:1:o}function mo(e,t,n){let r=W(e,t);return r.length===0?n:`${r}${n}`}function ho(e){return e!=null&&!ni(e,4)}function go(e,t){let n=e.snapshot.nodes[t];return!ho(n)||!H(n)||ni(n,2)?null:n}function _o(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ho(e.snapshot.nodes[n])&&(t+=1);return t}function vo(e){return Math.max(0,e.valueById.length-1)}function yo(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:_o(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:vo(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function bo(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 xo(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)go(e,n)!=null&&t.push(W(e,n));for(let t of e.expandedDirectoryIds)go(e,t)!=null&&n.push(W(e,t));return{collapsedPaths:t,expandedPaths:n}}function So(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)go(e,n)!=null&&Qi(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:W(e,n)});return t}function Co(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Va(e,n);t!=null&&Xi(e,t,!0,K(e,t))}for(let n of t.collapsedPaths){let t=Va(e,n);t!=null&&Xi(e,t,!1,K(e,t))}}function wo(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Va(e,n.path);t!=null&&go(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function To(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Eo(e){let t=e.snapshot.segmentTable,n=Ti();for(let r of e.snapshot.nodes)ho(r)&&(r.nameId=ni(r,2)?0:Ei(n,Di(t,r.nameId)));e.snapshot.segmentTable=n}function Do(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ho(r)||!H(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ho(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])),Hr(e.snapshot.nodes,n)}}function Oo(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId&&!ho(e.snapshot.nodes[t]);)--t;e.snapshot.nodes.length=t+1}function ko(e){let t=xo(e),n=So(e);U(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>To(e)),U(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Eo(e)),U(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Do(e)),U(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Oo(e)),U(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Co(e,t)),U(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>wo(e,n)),U(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>za(e,e.snapshot.rootId))}function Ao(e){let t=xo(e),n=So(e),r=U(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Ma(e)),i=oi({...e.snapshot.options},e.instrumentation),a=U(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new Wi(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,U(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Co(e,t)),U(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>wo(e,n)),U(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>za(e,e.snapshot.rootId))}function jo(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Mo(e,t){let n=yo(e);t===`stable`?U(e.instrumentation,`store.cleanup.stable`,()=>ko(e)):U(e.instrumentation,`store.cleanup.aggressive`,()=>Ao(e));let r=yo(e);return bo(t,t===`stable`,n,r)}var No=64;function Po(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 Fo(e){return K(e,e.snapshot.rootId).visibleSubtreeCount}function Io(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 Lo(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:ns(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Io(e,t.cursor,t.index,n)}}function Ro(e,t,n,r,i,a){let o=G(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=Wr(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return zo(e,u,l,r+c,i+1,s,o.childIds.length,a)}function zo(e,t,n,r,i,a,o,s){if(!H(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=Xo(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=K(e,c.terminalNodeId);if(!H(l)||!Yi(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ro(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Bo(e,t){let n=Fo(e);if(t<0||t>=n)return null;let r=Ro(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=Lo(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:ns(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Io(e,r.cursor,r.index,n)}}function Vo(e,t,n){let r=e.instrumentation,i=Fo(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 ts(e,o+1);let t=[],n=qo(e,a);for(let r=a;r<=o&&n!=null;r++){let r=ns(e,n);t.push(r),n=Qo(e,n)}return t}let s=[],c=0,l=0,u=U(r,`store.getVisibleSlice.selectFirstRow`,()=>qo(e,a));for(let t=a;t<=o&&u!=null;t++){let t=U(r,`store.getVisibleSlice.materializeRow`,()=>ns(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=U(r,`store.getVisibleSlice.advanceCursor`,()=>Qo(e,u))}return ci(r,`workload.visibleRowsRead`,s.length),ci(r,`workload.flattenedRowsRead`,c),ci(r,`workload.flattenedSegmentsRead`,l),s}function Ho(e,t=Fo(e)){let n=e.instrumentation;return n==null?es(e,t):U(n,`store.getVisibleTreeProjection`,()=>es(e,t))}function Uo(e){return $o(Ho(e))}function Wo(e,t){let n=Va(e,t);if(n==null||n===e.snapshot.rootId||H(K(e,n))&&Aa(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=zr(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Gr(a,n,s),t!==o){let n=K(e,t),a=ka(e,t);if(!Yi(e,t,n)&&a!==i)return null;Aa(e,t)===t&&(r+=1)}i=t}return r}function Go(e,t){let n=Va(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!H(r))throw Error(`Path is not a directory: "${t}"`);return Yi(e,n,r)?null:(Xi(e,n,!0,r),Ra(e,n),la({affectedAncestorIds:Ba(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Ko(e,t){let n=Va(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=K(e,n);if(!H(r))throw Error(`Path is not a directory: "${t}"`);return Yi(e,n,r)?(Xi(e,n,!1,r),Ra(e,n),ua({affectedAncestorIds:Ba(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function qo(e,t){return t<0||t>=Fo(e)?null:Jo(e,e.snapshot.rootId,t,-1)}function Jo(e,t,n,r){let i=G(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?Wr(e.snapshot.nodes,i,n):U(a,`store.getVisibleSlice.selectChildIndex`,()=>Wr(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Yo(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Yo(e,t,n,r){if(!H(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=Xo(e,t,r);if(n===0)return i;let a=K(e,i.terminalNodeId);if(!H(a)||!Yi(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Jo(e,i.terminalNodeId,n-1,i.visibleDepth)}function Xo(e,t,n){return H(K(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Aa(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:U(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Aa(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Zo(e,t){let n=K(e,t);if(!H(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||ka(e,r)!==t}function Qo(e,t){let n=K(e,t.terminalNodeId);if(H(n)){let r=G(e,t.terminalNodeId);if(Yi(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Yo(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=zr(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 Yo(e,s,0,i);Zo(e,r)&&i--,r=n}}function $o(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 es(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(No);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=Po(o,y);let x,S=_;if(H(v))S=f?Aa(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]}`}let C=o[y];r[s]=C,n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let w=c[S];w!=null&&H(w)&&Yi(e,S,w)&&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 ts(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(!H(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?Aa(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=ns(e,g);let _=i[h];_!=null&&H(_)&&Yi(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function ns(e,t){let n=K(e,t.terminalNodeId),r=H(n)?rs(e,t):null,i=W(e,t.terminalNodeId),a=Di(e.snapshot.segmentTable,n.nameId),o=H(n)&&G(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?ja(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:Di(e.snapshot.segmentTable,r.nameId),nodeId:n,path:W(e,n)}}):U(c,`store.getVisibleSlice.flatten.collectSegments`,()=>ja(e,t.headNodeId).map(n=>{let r=K(e,n);return{isTerminal:n===t.terminalNodeId,name:Di(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:H(n)&&Yi(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:H(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function rs(e,t){if(t.headNodeId===t.terminalNodeId)return Qi(e,t.terminalNodeId);let n=ja(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=Qi(e,t);if(n===`loading`)return`loading`;n===`error`?i=!0:n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var is=8;function as(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 os(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]&is)===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]]&is)===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 ss(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||!H(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&&Kr(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&H(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,Kr(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function cs(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=as(e.snapshot);os(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)&&Kr(n,i)}}function ls(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var us=class e{#e;constructor(e={}){let t=si(e),n=U(t,`store.builder.create`,()=>new Wi(e));if(e.preparedInput!=null){let t=Vi(e.preparedInput);t==null?n.appendPreparedPaths(Bi(e.preparedInput),!1):n.appendPresortedPaths(t,Hi(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(U(t,`store.preparePathEntries`,()=>Ui(r,e)))}let r=U(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=U(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=U(t,`store.state.create`,()=>Gi(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:U(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||ls(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&U(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?U(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>cs(this.#e)):U(t,`store.state.initializeOpenVisibleCounts`,()=>ss(this.#e)):U(t,`store.state.recomputeCounts`,()=>za(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Li(e,t)}static prepareInput(e,t={}){return Ri(e,t)}static preparePresortedInput(e){return zi(e)}list(e){return U(this.#e.instrumentation,`store.list`,()=>Ma(this.#e,e))}add(e){U(this.#e.instrumentation,`store.add`,()=>{let t=Fo(this.#e);ya(this.#e,_a(this.#e,t,Na(this.#e,e)))})}remove(e,t={}){U(this.#e.instrumentation,`store.remove`,()=>{let n=Fo(this.#e);ya(this.#e,_a(this.#e,n,Pa(this.#e,e,t)))})}move(e,t,n={}){U(this.#e.instrumentation,`store.move`,()=>{let r=Fo(this.#e),i=Fa(this.#e,e,t,n);i!=null&&ya(this.#e,_a(this.#e,r,i))})}batch(e){va(this.#e,()=>{if(typeof e==`function`)e(this);else 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 U(this.#e.instrumentation,`store.getVisibleCount`,()=>Fo(this.#e))}getVisibleSlice(e,t){return U(this.#e.instrumentation,`store.getVisibleSlice`,()=>Vo(this.#e,e,t))}getVisibleRowContext(e){return U(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Bo(this.#e,e))}getVisibleTreeProjection(){return Uo(this.#e)}getVisibleTreeProjectionData(e){return Ho(this.#e,e)}getVisibleIndex(e){return U(this.#e.instrumentation,`store.getVisibleIndex`,()=>Wo(this.#e,e))}getPathInfo(e){return U(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Va(this.#e,e);if(t==null)return null;let n=K(this.#e,t);return{depth:$r(n),kind:H(n)?`directory`:`file`,path:W(this.#e,t)}})}isExpanded(e){return U(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=K(this.#e,t);return Yi(this.#e,t,n)})}expand(e){U(this.#e.instrumentation,`store.expand`,()=>{let t=Fo(this.#e),n=Go(this.#e,e);n!=null&&ya(this.#e,_a(this.#e,t,n))})}collapse(e){U(this.#e.instrumentation,`store.collapse`,()=>{let t=Fo(this.#e),n=Ko(this.#e,e);n!=null&&ya(this.#e,_a(this.#e,t,n))})}on(e,t){return aa(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return Qi(this.#e,t)}markDirectoryUnloaded(e){U(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=Fo(this.#e);ea(this.#e,t),ya(this.#e,_a(this.#e,n,da({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return U(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=Fo(this.#e),r=$i(this.#e,t);return ya(this.#e,_a(this.#e,n,fa({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return U(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||Qi(this.#e,n)!==`loading`||!na(this.#e,n,e.attemptId))return!1;let r=W(this.#e,n);this.validateChildPatch(r,t);let i=Fo(this.#e),a=[];for(let e of t.operations){ds(r,e);let t=Fo(this.#e);switch(e.type){case`add`:a.push(_a(this.#e,t,Na(this.#e,e.path)));break;case`remove`:a.push(_a(this.#e,t,Pa(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Fa(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(_a(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return ya(this.#e,_a(this.#e,i,pa({affectedAncestorIds:Ba(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:W(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return U(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=Fo(this.#e),r=ta(this.#e,t,e.attemptId);return ya(this.#e,_a(this.#e,n,ma({affectedAncestorIds:Ba(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:W(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return U(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=Fo(this.#e),i=ra(this.#e,n,e.attemptId,t);return ya(this.#e,_a(this.#e,r,ha({affectedAncestorIds:Ba(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 U(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(jo(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=Fo(this.#e),n=Mo(this.#e,e.mode??`stable`);return ya(this.#e,_a(this.#e,t,ga({...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)??di(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=pi(bi(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(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;else for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=K(this.#e,n);Yi(this.#e,n,i)||(Xi(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(!Yi(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Va(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!H(K(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!H(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=ka(this.#e,e);if(!Yi(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 ds(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 fs={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function ps(e,t){if(typeof e==`number`)return{itemHeight:t??fs.default.itemHeight,factor:e};let n=fs[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ms=fs.default.itemHeight,hs=`@layer base {
2
2
  :host {
3
3
  --trees-accent: var(--trees-accent-override, #009fff);
4
4
  --trees-fg: var(--trees-fg-override, var(--trees-theme-sidebar-fg, light-dark(#6c6c71, #adadb1)));
@@ -1,4 +1,4 @@
1
- import{b as e,t,x as n}from"./appendItems-D8y87kIw.js";import{x as r}from"./index-DgB2FK2g.js";import{n as i,r as a,t as o}from"./stream-tokenizer-BzA0VElt.js";import{t as s}from"./formatCSSVariablePrefix-KRh9vnZf.js";var c=`none,attribute,attribute.jsx,boolean,comment,comment.doc,constant,constant.builtin,constructor,diff.minus,diff.plus,embedded,emphasis,emphasis.strong,function,function.definition,function.method,keyword,keyword.control,keyword.declaration,keyword.import,keyword.operator,label,namespace,number,operator,predictive,preproc,primary,property,property.json_key,punctuation,punctuation.bracket,punctuation.bracket.html,punctuation.bracket.jsx,punctuation.delimiter,punctuation.delimiter.html,punctuation.delimiter.jsx,punctuation.list_marker,punctuation.markup,punctuation.special,selector,selector.class,selector.id,string,string.escape,string.regex,string.special,string.special.symbol,tag,tag.doctype,tag.jsx,text.jsx,text.literal,title,type,type.builtin,type.class,variable,variable.parameter,variable.special,emphasis.strong.italic,enum,hint,keyword.jsdoc,link_text,link_uri,markup.strikethrough,selector.pseudo,tag.component.jsx,type.jsdoc,variable.jsdoc,variant,background,foreground`.split(`,`),l=`--hls-`,u=new TextEncoder,d=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,f=/^color\(display-p3\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:\s*\/\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+))?\s*\)$/i;function p(e){return typeof e==`string`&&(d.test(e.trim())||f.test(e.trim()))}function m(e){return e[`editor.foreground`]??e.text??e.foreground}function h(e){return e[`editor.background`]??e.background}var g=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`bright_black`,`bright_red`,`bright_green`,`bright_yellow`,`bright_blue`,`bright_magenta`,`bright_cyan`,`bright_white`],_=[`#000000`,`#cd3131`,`#0dbc79`,`#e5e510`,`#2472c8`,`#bc3fbc`,`#11a8cd`,`#e5e5e5`,`#666666`,`#f14c4c`,`#23d18b`,`#f5f543`,`#3b8eea`,`#d670d6`,`#29b8db`,`#ffffff`];function v(e){return g.map((t,n)=>ne({foreground:e[`terminal.ansi.${t}`]},`foreground`).color??_[n])}function y(e){return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?`the string ${JSON.stringify(e)} (theme ids are not supported; import the theme object from "@pierre/highlights/themes")`:Array.isArray(e)?`an array`:typeof e==`object`?`themes`in e&&Array.isArray(e.themes)?`a ThemeFamily whose first member is ${y(e.themes[0])}`:"an object without a `name`":`a ${typeof e}`}function b(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&e.name!==``}function x(e){let t=typeof e==`object`&&e&&`themes`in e&&e.themes!=null?e.themes[0]:e;if(!b(t))throw TypeError(`invalid theme: expected a Theme or ThemeFamily object, received ${y(e)}`);return t}function S(e,t){if(t===`emphasis.strong.italic`&&e[t]==null){let t=S(e,`emphasis.strong`),n=S(e,`emphasis`);return{color:t?.color??n?.color,font_style:n?.font_style,font_weight:t?.font_weight}}let n;for(let r=t;r!==``;){let t=e[r];if(typeof t==`string`)return{...n,color:t};if(typeof t==`object`&&t&&(n??=t,t.color!=null))return{...n,color:t.color};let i=r.lastIndexOf(`.`);r=i<0?``:r.slice(0,i)}return n}function ee(e){return typeof e==`number`&&e>=100&&e<=900?Math.round(e/100)*100:0}function te(e,t,n){let r=e.indexOf(`,`);return e.slice(0,r<0?-1:r)+`-`+t+(n===void 0?`)`:`,`+n+`)`)}function C(e,t,n,r,i=!1){let a=ee(r),o=n===`italic`,s=e===`markup.strikethrough`,c={color:t,weight:a,fontStyle:Number(o)|(a>=600?2:0)|(s?8:0)};if(o||a!==0||s){let e={};if(o&&(e[`font-style`]=`italic`),a!==0&&(e[`font-weight`]=String(a)),s&&(e[`text-decoration`]=`line-through`),i&&t!==void 0)for(let n of Object.keys(e))e[n]=te(t,n,e[n]);c.fontCss=e}return c}function ne(e,t){let n,r,i;return t===`background`?n=h(e):t===`foreground`?n=m(e):({color:n,font_style:r,font_weight:i}=S(e.syntax??{},t)??{},(r!=null||i!=null||t===`markup.strikethrough`)&&(n??=m(e))),p(n)?(n=n.trim().toLowerCase(),n.startsWith(`#`)&&(n.length<=5&&(n=n.replace(/[^#]/g,`$&$&`)),n.length===9&&n.endsWith(`ff`)&&(n=n.slice(0,7)),n===`#00000000`&&(n=void 0))):n=void 0,C(t,n,r,i)}function w(e,t){return`var(${t}${e.replace(/[._]/g,`-`)})`}function T(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function re(e){let t=e.map(e=>u.encode(e)),n=4+8*t.length,r=new Uint8Array(n+t.reduce((e,t)=>e+t.length,0)),i=new DataView(r.buffer),a=32;for(let e=0;e<t.length;e++)i.setUint32(4+8*e,n,!0),i.setUint32(8+8*e,t[e].length,!0),r.set(t[e],n),n+=t[e].length,e!==0&&(a=Math.max(a,t[e].length+32));return i.setUint32(0,a,!0),r}var ie=new WeakMap;function E(e,t=l){let n=x(e),r=n.cssVariables===!0?t:``,i=ie.get(n),a=i?.get(r);if(a!==void 0)return a;let o=n.cssVariables===!0?oe(n.name,t):typeof n.cssVariables==`object`?ae(n):ce(n);return i===void 0&&(i=new Map,ie.set(n,i)),i.set(r,o),o}function ae(e){let t=e.cssVariables;if(typeof t!=`object`)throw Error(`Expected CSS palette`);let n=t.prefix??`--hls-`,r=e=>{let r=t.defaults?.[e];return`var(${n}${e}${r?`, ${r}`:``})`},i=Array(c.length).fill(null),a=e.style.syntax??{};for(let e=1;e<c.length;e++){let t=S(a,c[e]);i[e]=C(c[e],r(t?.color??`foreground`),t?.font_style,t?.font_weight)}let o=r(m(e.style)??`foreground`),s=r(h(e.style)??`background`),l,u;return{name:e.name,styles:i,fg:o,bg:s,table:void 0,get htmlOpeners(){return l??=le(i,o,s)},get ansi(){return u??=g.map(t=>{let n=e.style[`terminal.ansi.${t}`];return r(typeof n==`string`?n:`terminal-ansi-${t.replace(`_`,`-`)}`)})}}}function oe(e,t){let n,r=()=>n??=se(t),i;return{name:e,get styles(){return r().styles},get fg(){return r().fg},get bg(){return r().bg},table:void 0,htmlOpeners:void 0,get ansi(){return i??=g.map(e=>w(`terminal.ansi.${e}`,t))}}}function se(e){let t=Array(c.length).fill(null);for(let n=1;n<c.length;n++){let r=c[n],i=r===`emphasis.strong.italic`;t[n]=C(r,w(r,e),r===`emphasis`||i?`italic`:void 0,r===`emphasis.strong`||i?700:0,!0)}return{styles:t,fg:w(`foreground`,e),bg:w(`background`,e)}}function ce(e){let t=e.style??{},n=Array(c.length).fill(null),r=new Uint8Array(c.length*5),i,a,o=!1;for(let e=1;e<c.length;e++){let s=c[e],l=ne(t,s),{color:u,fontStyle:d,weight:f}=l,p=e*5;if(u!==void 0){if(u.startsWith(`#`)){let e=parseInt(u.slice(1,7),16);r[p]=e>>16,r[p+1]=e>>8&255,r[p+2]=e&255,r[p+3]=u.length===9?parseInt(u.slice(7),16):255}else o=!0}r[p+4]=(d&1)<<4|(d&8)<<2|f/100,(u!==void 0||d!==0||f!==0)&&(s===`foreground`?i=u:s===`background`?a=u:n[e]=l)}let s,l;return{name:e.name,styles:n,fg:i,bg:a,table:o?void 0:r,get htmlOpeners(){if(o)return s??=le(n,i,a)},get ansi(){return l??=v(t)}}}function le(e,t,n){let r=[`<pre class="highlights" style="${T((n===void 0?``:`background-color:${n};`)+(t===void 0?``:`color:${t}`))}"><code>`];for(let t=1;t<c.length;t++){let n=e[t],i=`color:${n?.color??`inherit`}`;for(let e in n?.fontCss)i+=`;${e}:${n.fontCss[e]}`;r.push(`<span style="${T(i)}">`)}return re(r)}var ue=new TextEncoder,D=new Uint8Array(c.length);for(let e=0;e<c.length;e++){let t=c[e];t===`string.regex`?D[e]=3:t===`comment`||t.startsWith(`comment.`)?D[e]=1:(t===`string`||t.startsWith(`string.`))&&(D[e]=2)}var de=new WeakMap,fe=new WeakMap,pe=1,me=new WeakMap,he=new WeakMap,ge=new WeakMap,_e=0;function ve(e){let t=ge.get(e);return t===void 0&&(t=_e++,ge.set(e,t)),t}function ye(e,t,n){let{name:r,styles:i,fg:a,bg:o,table:s}=e;return{color:t,role:n,name:r,styles:i,fg:a,bg:o,table:s,get ansi(){return e.ansi}}}function O(e){let{cssVariablePrefix:t}=e;if(e.themes==null)return[ye(E(e.theme,t),null,`single`)];let n=Object.entries(e.themes).filter(([,e])=>e!=null).sort(([e],[t])=>e<t?-1:1);if(n.length===0)throw TypeError(`themes must not be empty`);let r=e.defaultColor??`light`,i;if(r===`light-dark()`){let e=n.find(([e])=>e===`light`),t=n.find(([e])=>e===`dark`);if(e===void 0||t===void 0)throw TypeError("`themes` must contain `light` and `dark` when defaultColor is 'light-dark()'");n.splice(0,n.length,e,t),i=[`light-dark`,`light-dark`]}else{if(r!==!1){let e=n.findIndex(([e])=>e===r);if(e<0)throw TypeError(`\`themes\` must contain the defaultColor key \`${r}\``);n.unshift(...n.splice(e,1))}i=n.map((e,t)=>r!==!1&&t===0?`default`:`variable`)}let a=n.map(([,e])=>E(e,t)),o=JSON.stringify(n.map(([e],t)=>[ve(a[t]),i[t],e])),s=he.get(a[0]),c=s?.get(o);if(c!==void 0)return c;let l=n.map(([e],t)=>ye(a[t],e,i[t]));if(s===void 0&&(s=new Map,he.set(a[0],s)),s.set(o,l),s.size>128){let e=s.keys().next().value;e!==void 0&&s.delete(e)}return l}function k(e,t,n,r,i,a,o=0){let s={content:e.slice(t,n),offset:t+o};if(i[0].role===`single`){let{styles:e,fg:t}=i[0],n=e[r];s.color=n?.color??t,s.fontStyle=n?.fontStyle??0}else s.htmlStyle=A(i,r,a);let c=D[r];return c!==0&&(s.type=c),s}function be(e,t){let n=de.get(e);n===void 0&&(n=new Map,de.set(e,n));let r=n.get(t);return r===void 0&&(r=[],n.set(t,r)),r}function A(e,t,n){let r=be(e,n),i=r[t];if(i===void 0){if(e[0].role===`light-dark`)i=Ce(e,t,n);else{i={};for(let{color:r,role:a,styles:o,fg:s}of e){let e=o[t],c=a==="default";i[c?`color`:n+r]=e?.color??s??`inherit`;for(let t in e?.fontCss)i[c?t:`${n}${r}-${t}`]=e.fontCss[t]}}r[t]=i}return i}function xe(e,t){let n=fe.get(e);n===void 0&&(n=new Map,fe.set(e,n));let r=n.get(t);if(r!==void 0)return r??void 0;let i=e.length;if(!(i<=255&&e.every(e=>e.table!==void 0))){n.set(t,null);return}let a=e.map(e=>e.role==="default"?new Uint8Array:ue.encode(T(`${t}${e.color}`))),o=32+16*i,s=o+384*i,c=64,l=128,u=0;for(let{length:e}of a)c+=96+4*e,l+=48+2*e,u+=e;let d=new Uint8Array(s+u),f=new DataView(d.buffer);d[0]=i,d[1]=+(e[0].role===`light-dark`),f.setUint32(4,o,!0),f.setUint32(8,c,!0),f.setUint32(12,l,!0),f.setUint32(16,pe++,!0);let p=s;for(let t=0;t<i;t++){let n=32+16*t;f.setUint32(n,p,!0),f.setUint32(n+4,a[t].length,!0),f.setUint32(n+8,+(e[t].role==="default"),!0),d.set(e[t].table,o+384*t),d.set(a[t],p),p+=a[t].length}return n.set(t,d),d}function Se(e,t){let n=me.get(e);n===void 0&&(n=new Map,me.set(e,n));let r=n.get(t);if(r!==void 0)return r;let{fg:i,bg:a,rootStyle:o}=j(e,t),s=[`<pre class="highlights" style="${T(o??`background-color:${a};color:${i}`)}"><code>`];for(let n=1;n<c.length;n++){let r=A(e,n,t),i=``;for(let e in r)i+=`${i===``?``:`;`}${e}:${r[e]}`;s.push(`<span style="${T(i)}">`)}let l=re(s);return n.set(t,l),l}function Ce(e,t,n){let[r,i]=e,a=r.styles[t],o=i.styles[t],s=a?.color??r.fg??`currentcolor`,c=o?.color??i.fg??`currentcolor`,l={color:s===c?s:`light-dark(${s}, ${c})`};for(let e of[`font-style`,`font-weight`,`text-decoration`]){let t=a?.fontCss?.[e],r=o?.fontCss?.[e];t!==void 0&&t===r?l[e]=t:(t!==void 0&&(l[`${n}light-${e}`]=t),r!==void 0&&(l[`${n}dark-${e}`]=r))}return l}function we(e,t,n,r,i,a=0){let o=[],s=i??0,{styles:c,fg:l,role:u}=n[0],d=u===`single`?void 0:be(n,r),f=new Int32Array(t.buffer,t.byteOffset,t.length),p=0;for(let i=0;;i+=2){let u=i;for(;i<t.length&&f[i+1]!==-1;)i+=2;let m=i===u?p:t[i-2],h;if(s>0&&m-p>=s)h=[k(e,p,m,0,n,r,a)];else{h=Array((i-u)/2);let o=0;for(let s=u;s<i;s+=2){let i=t[s];if(i>p){let u=t[s+1],f;if(d===void 0){let t=c[u];f={content:e.slice(p,i),offset:p+a,color:t?.color??l,fontStyle:t?.fontStyle??0}}else f={content:e.slice(p,i),offset:p+a,htmlStyle:d[u]??A(n,u,r)};let m=D[u];m!==0&&(f.type=m),h[o++]=f,p=i}}h.length=o}if(o.push(h),i===t.length)break;p=t[i]}return o}function j(e,t){if(e[0].role===`single`)return{fg:e[0].fg,bg:e[0].bg,themeName:e[0].name};let n=`highlights-themes ${e.map(e=>e.name).join(` `)}`;if(e[0].role===`light-dark`){let t=(e,t,n)=>{let r=e??n,i=t??n;return r===i?r:`light-dark(${r}, ${i})`};return{fg:t(e[0].fg,e[1].fg,`currentcolor`),bg:t(e[0].bg,e[1].bg,`transparent`),themeName:n}}let r=e.map(e=>e.role==="default"?e.fg??`inherit`:`${t}${e.color}:${e.fg??`inherit`}`).join(`;`),i=e.map(e=>e.role==="default"?e.bg??`inherit`:`${t}${e.color}-bg:${e.bg??`inherit`}`).join(`;`);return{fg:r,bg:i,themeName:n,rootStyle:e[0].role==="default"?void 0:`${r};${i}`}}var M=1,Te=2,Ee=4,De=8,Oe=16,ke=32,Ae=[0,M,Te,Ee,De,0,0,Oe,0,ke],N=[0,95,135,175,215,255],P=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -/]*[0-~])/y,je=class{fg=-1;bg=-1;flags=0;styles=new Map};function F(e){return String(e).toLowerCase()===`ansi`}function I(e,t){if(t<16)return e.ansi[t];let n=t&0xffffff;if(t<232){let e=t-16;n=N[e/36|0]<<16|N[(e/6|0)%6]<<8|N[e%6]}else t<256&&(n=(8+(t-232)*10)*65793);return`#${n.toString(16).padStart(6,`0`)}`}function Me(e,t,n,r,i=new je,a=0){let o=[],s=r??0,c=[],l,u,d,f=e.indexOf(`\x1B`),p=0;for(;;){let r=e.indexOf(`
1
+ import{b as e,t,x as n}from"./appendItems-CWJJlOE7.js";import{x as r}from"./index-UP3KtgHV.js";import{n as i,r as a,t as o}from"./stream-tokenizer-BMtK_3oz.js";import{t as s}from"./formatCSSVariablePrefix-KRh9vnZf.js";var c=`none,attribute,attribute.jsx,boolean,comment,comment.doc,constant,constant.builtin,constructor,diff.minus,diff.plus,embedded,emphasis,emphasis.strong,function,function.definition,function.method,keyword,keyword.control,keyword.declaration,keyword.import,keyword.operator,label,namespace,number,operator,predictive,preproc,primary,property,property.json_key,punctuation,punctuation.bracket,punctuation.bracket.html,punctuation.bracket.jsx,punctuation.delimiter,punctuation.delimiter.html,punctuation.delimiter.jsx,punctuation.list_marker,punctuation.markup,punctuation.special,selector,selector.class,selector.id,string,string.escape,string.regex,string.special,string.special.symbol,tag,tag.doctype,tag.jsx,text.jsx,text.literal,title,type,type.builtin,type.class,variable,variable.parameter,variable.special,emphasis.strong.italic,enum,hint,keyword.jsdoc,link_text,link_uri,markup.strikethrough,selector.pseudo,tag.component.jsx,type.jsdoc,variable.jsdoc,variant,background,foreground`.split(`,`),l=`--hls-`,u=new TextEncoder,d=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,f=/^color\(display-p3\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:\s*\/\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+))?\s*\)$/i;function p(e){return typeof e==`string`&&(d.test(e.trim())||f.test(e.trim()))}function m(e){return e[`editor.foreground`]??e.text??e.foreground}function h(e){return e[`editor.background`]??e.background}var g=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`bright_black`,`bright_red`,`bright_green`,`bright_yellow`,`bright_blue`,`bright_magenta`,`bright_cyan`,`bright_white`],_=[`#000000`,`#cd3131`,`#0dbc79`,`#e5e510`,`#2472c8`,`#bc3fbc`,`#11a8cd`,`#e5e5e5`,`#666666`,`#f14c4c`,`#23d18b`,`#f5f543`,`#3b8eea`,`#d670d6`,`#29b8db`,`#ffffff`];function v(e){return g.map((t,n)=>ne({foreground:e[`terminal.ansi.${t}`]},`foreground`).color??_[n])}function y(e){return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?`the string ${JSON.stringify(e)} (theme ids are not supported; import the theme object from "@pierre/highlights/themes")`:Array.isArray(e)?`an array`:typeof e==`object`?`themes`in e&&Array.isArray(e.themes)?`a ThemeFamily whose first member is ${y(e.themes[0])}`:"an object without a `name`":`a ${typeof e}`}function b(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&e.name!==``}function x(e){let t=typeof e==`object`&&e&&`themes`in e&&e.themes!=null?e.themes[0]:e;if(!b(t))throw TypeError(`invalid theme: expected a Theme or ThemeFamily object, received ${y(e)}`);return t}function S(e,t){if(t===`emphasis.strong.italic`&&e[t]==null){let t=S(e,`emphasis.strong`),n=S(e,`emphasis`);return{color:t?.color??n?.color,font_style:n?.font_style,font_weight:t?.font_weight}}let n;for(let r=t;r!==``;){let t=e[r];if(typeof t==`string`)return{...n,color:t};if(typeof t==`object`&&t&&(n??=t,t.color!=null))return{...n,color:t.color};let i=r.lastIndexOf(`.`);r=i<0?``:r.slice(0,i)}return n}function ee(e){return typeof e==`number`&&e>=100&&e<=900?Math.round(e/100)*100:0}function te(e,t,n){let r=e.indexOf(`,`);return e.slice(0,r<0?-1:r)+`-`+t+(n===void 0?`)`:`,`+n+`)`)}function C(e,t,n,r,i=!1){let a=ee(r),o=n===`italic`,s=e===`markup.strikethrough`,c={color:t,weight:a,fontStyle:Number(o)|(a>=600?2:0)|(s?8:0)};if(o||a!==0||s){let e={};if(o&&(e[`font-style`]=`italic`),a!==0&&(e[`font-weight`]=String(a)),s&&(e[`text-decoration`]=`line-through`),i&&t!==void 0)for(let n of Object.keys(e))e[n]=te(t,n,e[n]);c.fontCss=e}return c}function ne(e,t){let n,r,i;return t===`background`?n=h(e):t===`foreground`?n=m(e):({color:n,font_style:r,font_weight:i}=S(e.syntax??{},t)??{},(r!=null||i!=null||t===`markup.strikethrough`)&&(n??=m(e))),p(n)?(n=n.trim().toLowerCase(),n.startsWith(`#`)&&(n.length<=5&&(n=n.replace(/[^#]/g,`$&$&`)),n.length===9&&n.endsWith(`ff`)&&(n=n.slice(0,7)),n===`#00000000`&&(n=void 0))):n=void 0,C(t,n,r,i)}function w(e,t){return`var(${t}${e.replace(/[._]/g,`-`)})`}function T(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function re(e){let t=e.map(e=>u.encode(e)),n=4+8*t.length,r=new Uint8Array(n+t.reduce((e,t)=>e+t.length,0)),i=new DataView(r.buffer),a=32;for(let e=0;e<t.length;e++)i.setUint32(4+8*e,n,!0),i.setUint32(8+8*e,t[e].length,!0),r.set(t[e],n),n+=t[e].length,e!==0&&(a=Math.max(a,t[e].length+32));return i.setUint32(0,a,!0),r}var ie=new WeakMap;function E(e,t=l){let n=x(e),r=n.cssVariables===!0?t:``,i=ie.get(n),a=i?.get(r);if(a!==void 0)return a;let o=n.cssVariables===!0?oe(n.name,t):typeof n.cssVariables==`object`?ae(n):ce(n);return i===void 0&&(i=new Map,ie.set(n,i)),i.set(r,o),o}function ae(e){let t=e.cssVariables;if(typeof t!=`object`)throw Error(`Expected CSS palette`);let n=t.prefix??`--hls-`,r=e=>{let r=t.defaults?.[e];return`var(${n}${e}${r?`, ${r}`:``})`},i=Array(c.length).fill(null),a=e.style.syntax??{};for(let e=1;e<c.length;e++){let t=S(a,c[e]);i[e]=C(c[e],r(t?.color??`foreground`),t?.font_style,t?.font_weight)}let o=r(m(e.style)??`foreground`),s=r(h(e.style)??`background`),l,u;return{name:e.name,styles:i,fg:o,bg:s,table:void 0,get htmlOpeners(){return l??=le(i,o,s)},get ansi(){return u??=g.map(t=>{let n=e.style[`terminal.ansi.${t}`];return r(typeof n==`string`?n:`terminal-ansi-${t.replace(`_`,`-`)}`)})}}}function oe(e,t){let n,r=()=>n??=se(t),i;return{name:e,get styles(){return r().styles},get fg(){return r().fg},get bg(){return r().bg},table:void 0,htmlOpeners:void 0,get ansi(){return i??=g.map(e=>w(`terminal.ansi.${e}`,t))}}}function se(e){let t=Array(c.length).fill(null);for(let n=1;n<c.length;n++){let r=c[n],i=r===`emphasis.strong.italic`;t[n]=C(r,w(r,e),r===`emphasis`||i?`italic`:void 0,r===`emphasis.strong`||i?700:0,!0)}return{styles:t,fg:w(`foreground`,e),bg:w(`background`,e)}}function ce(e){let t=e.style??{},n=Array(c.length).fill(null),r=new Uint8Array(c.length*5),i,a,o=!1;for(let e=1;e<c.length;e++){let s=c[e],l=ne(t,s),{color:u,fontStyle:d,weight:f}=l,p=e*5;if(u!==void 0){if(u.startsWith(`#`)){let e=parseInt(u.slice(1,7),16);r[p]=e>>16,r[p+1]=e>>8&255,r[p+2]=e&255,r[p+3]=u.length===9?parseInt(u.slice(7),16):255}else o=!0}r[p+4]=(d&1)<<4|(d&8)<<2|f/100,(u!==void 0||d!==0||f!==0)&&(s===`foreground`?i=u:s===`background`?a=u:n[e]=l)}let s,l;return{name:e.name,styles:n,fg:i,bg:a,table:o?void 0:r,get htmlOpeners(){if(o)return s??=le(n,i,a)},get ansi(){return l??=v(t)}}}function le(e,t,n){let r=[`<pre class="highlights" style="${T((n===void 0?``:`background-color:${n};`)+(t===void 0?``:`color:${t}`))}"><code>`];for(let t=1;t<c.length;t++){let n=e[t],i=`color:${n?.color??`inherit`}`;for(let e in n?.fontCss)i+=`;${e}:${n.fontCss[e]}`;r.push(`<span style="${T(i)}">`)}return re(r)}var ue=new TextEncoder,D=new Uint8Array(c.length);for(let e=0;e<c.length;e++){let t=c[e];t===`string.regex`?D[e]=3:t===`comment`||t.startsWith(`comment.`)?D[e]=1:(t===`string`||t.startsWith(`string.`))&&(D[e]=2)}var de=new WeakMap,fe=new WeakMap,pe=1,me=new WeakMap,he=new WeakMap,ge=new WeakMap,_e=0;function ve(e){let t=ge.get(e);return t===void 0&&(t=_e++,ge.set(e,t)),t}function ye(e,t,n){let{name:r,styles:i,fg:a,bg:o,table:s}=e;return{color:t,role:n,name:r,styles:i,fg:a,bg:o,table:s,get ansi(){return e.ansi}}}function O(e){let{cssVariablePrefix:t}=e;if(e.themes==null)return[ye(E(e.theme,t),null,`single`)];let n=Object.entries(e.themes).filter(([,e])=>e!=null).sort(([e],[t])=>e<t?-1:1);if(n.length===0)throw TypeError(`themes must not be empty`);let r=e.defaultColor??`light`,i;if(r===`light-dark()`){let e=n.find(([e])=>e===`light`),t=n.find(([e])=>e===`dark`);if(e===void 0||t===void 0)throw TypeError("`themes` must contain `light` and `dark` when defaultColor is 'light-dark()'");n.splice(0,n.length,e,t),i=[`light-dark`,`light-dark`]}else{if(r!==!1){let e=n.findIndex(([e])=>e===r);if(e<0)throw TypeError(`\`themes\` must contain the defaultColor key \`${r}\``);n.unshift(...n.splice(e,1))}i=n.map((e,t)=>r!==!1&&t===0?`default`:`variable`)}let a=n.map(([,e])=>E(e,t)),o=JSON.stringify(n.map(([e],t)=>[ve(a[t]),i[t],e])),s=he.get(a[0]),c=s?.get(o);if(c!==void 0)return c;let l=n.map(([e],t)=>ye(a[t],e,i[t]));if(s===void 0&&(s=new Map,he.set(a[0],s)),s.set(o,l),s.size>128){let e=s.keys().next().value;e!==void 0&&s.delete(e)}return l}function k(e,t,n,r,i,a,o=0){let s={content:e.slice(t,n),offset:t+o};if(i[0].role===`single`){let{styles:e,fg:t}=i[0],n=e[r];s.color=n?.color??t,s.fontStyle=n?.fontStyle??0}else s.htmlStyle=A(i,r,a);let c=D[r];return c!==0&&(s.type=c),s}function be(e,t){let n=de.get(e);n===void 0&&(n=new Map,de.set(e,n));let r=n.get(t);return r===void 0&&(r=[],n.set(t,r)),r}function A(e,t,n){let r=be(e,n),i=r[t];if(i===void 0){if(e[0].role===`light-dark`)i=Ce(e,t,n);else{i={};for(let{color:r,role:a,styles:o,fg:s}of e){let e=o[t],c=a==="default";i[c?`color`:n+r]=e?.color??s??`inherit`;for(let t in e?.fontCss)i[c?t:`${n}${r}-${t}`]=e.fontCss[t]}}r[t]=i}return i}function xe(e,t){let n=fe.get(e);n===void 0&&(n=new Map,fe.set(e,n));let r=n.get(t);if(r!==void 0)return r??void 0;let i=e.length;if(!(i<=255&&e.every(e=>e.table!==void 0))){n.set(t,null);return}let a=e.map(e=>e.role==="default"?new Uint8Array:ue.encode(T(`${t}${e.color}`))),o=32+16*i,s=o+384*i,c=64,l=128,u=0;for(let{length:e}of a)c+=96+4*e,l+=48+2*e,u+=e;let d=new Uint8Array(s+u),f=new DataView(d.buffer);d[0]=i,d[1]=+(e[0].role===`light-dark`),f.setUint32(4,o,!0),f.setUint32(8,c,!0),f.setUint32(12,l,!0),f.setUint32(16,pe++,!0);let p=s;for(let t=0;t<i;t++){let n=32+16*t;f.setUint32(n,p,!0),f.setUint32(n+4,a[t].length,!0),f.setUint32(n+8,+(e[t].role==="default"),!0),d.set(e[t].table,o+384*t),d.set(a[t],p),p+=a[t].length}return n.set(t,d),d}function Se(e,t){let n=me.get(e);n===void 0&&(n=new Map,me.set(e,n));let r=n.get(t);if(r!==void 0)return r;let{fg:i,bg:a,rootStyle:o}=j(e,t),s=[`<pre class="highlights" style="${T(o??`background-color:${a};color:${i}`)}"><code>`];for(let n=1;n<c.length;n++){let r=A(e,n,t),i=``;for(let e in r)i+=`${i===``?``:`;`}${e}:${r[e]}`;s.push(`<span style="${T(i)}">`)}let l=re(s);return n.set(t,l),l}function Ce(e,t,n){let[r,i]=e,a=r.styles[t],o=i.styles[t],s=a?.color??r.fg??`currentcolor`,c=o?.color??i.fg??`currentcolor`,l={color:s===c?s:`light-dark(${s}, ${c})`};for(let e of[`font-style`,`font-weight`,`text-decoration`]){let t=a?.fontCss?.[e],r=o?.fontCss?.[e];t!==void 0&&t===r?l[e]=t:(t!==void 0&&(l[`${n}light-${e}`]=t),r!==void 0&&(l[`${n}dark-${e}`]=r))}return l}function we(e,t,n,r,i,a=0){let o=[],s=i??0,{styles:c,fg:l,role:u}=n[0],d=u===`single`?void 0:be(n,r),f=new Int32Array(t.buffer,t.byteOffset,t.length),p=0;for(let i=0;;i+=2){let u=i;for(;i<t.length&&f[i+1]!==-1;)i+=2;let m=i===u?p:t[i-2],h;if(s>0&&m-p>=s)h=[k(e,p,m,0,n,r,a)];else{h=Array((i-u)/2);let o=0;for(let s=u;s<i;s+=2){let i=t[s];if(i>p){let u=t[s+1],f;if(d===void 0){let t=c[u];f={content:e.slice(p,i),offset:p+a,color:t?.color??l,fontStyle:t?.fontStyle??0}}else f={content:e.slice(p,i),offset:p+a,htmlStyle:d[u]??A(n,u,r)};let m=D[u];m!==0&&(f.type=m),h[o++]=f,p=i}}h.length=o}if(o.push(h),i===t.length)break;p=t[i]}return o}function j(e,t){if(e[0].role===`single`)return{fg:e[0].fg,bg:e[0].bg,themeName:e[0].name};let n=`highlights-themes ${e.map(e=>e.name).join(` `)}`;if(e[0].role===`light-dark`){let t=(e,t,n)=>{let r=e??n,i=t??n;return r===i?r:`light-dark(${r}, ${i})`};return{fg:t(e[0].fg,e[1].fg,`currentcolor`),bg:t(e[0].bg,e[1].bg,`transparent`),themeName:n}}let r=e.map(e=>e.role==="default"?e.fg??`inherit`:`${t}${e.color}:${e.fg??`inherit`}`).join(`;`),i=e.map(e=>e.role==="default"?e.bg??`inherit`:`${t}${e.color}-bg:${e.bg??`inherit`}`).join(`;`);return{fg:r,bg:i,themeName:n,rootStyle:e[0].role==="default"?void 0:`${r};${i}`}}var M=1,Te=2,Ee=4,De=8,Oe=16,ke=32,Ae=[0,M,Te,Ee,De,0,0,Oe,0,ke],N=[0,95,135,175,215,255],P=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -/]*[0-~])/y,je=class{fg=-1;bg=-1;flags=0;styles=new Map};function F(e){return String(e).toLowerCase()===`ansi`}function I(e,t){if(t<16)return e.ansi[t];let n=t&0xffffff;if(t<232){let e=t-16;n=N[e/36|0]<<16|N[(e/6|0)%6]<<8|N[e%6]}else t<256&&(n=(8+(t-232)*10)*65793);return`#${n.toString(16).padStart(6,`0`)}`}function Me(e,t,n,r,i=new je,a=0){let o=[],s=r??0,c=[],l,u,d,f=e.indexOf(`\x1B`),p=0;for(;;){let r=e.indexOf(`
2
2
  `,p),m=r<0?e.length:r;r>p&&e.charCodeAt(r-1)===13&&m--;let h=s>0&&m-p>=s;for(;p<m;){f>=0&&f<p&&(f=e.indexOf(`\x1B`,p));let r=f>=0&&f<m?f:m,o=r,s;if(r<m){P.lastIndex=r;let t=P.exec(e);t===null?o=++r:(o=P.lastIndex,t[2]===`m`&&!(t[1].charCodeAt(0)>=60)&&(s=t[1]))}if(r>p&&h)u===void 0?(u=k(e,p,r,0,t,n,a),c.push(u)):u.content+=e.slice(p,r);else if(r>p){if(l===void 0){let{fg:e,bg:r,flags:a}=i,o=`${e},${r},${a}`;if(l=i.styles.get(o),l===void 0){let s=((a&Ee)===0?0:1)|((a&M)===0?0:2)|((a&De)===0?0:4)|((a&ke)===0?0:8),c=t.map(t=>{let n=e<0?t.fg:I(t,e),i=r<0?void 0:I(t,r);return(a&Oe)!==0&&(i=n,n=r<0?t.bg:I(t,r)),(a&Te)!==0&&n!==void 0&&(n=n.startsWith(`#`)?n.length===9?n.slice(0,7)+Math.round(parseInt(n.slice(7),16)/2).toString(16).padStart(2,`0`):`${n}80`:`color-mix(in srgb, ${n} 50%, transparent)`),[n,i]});if(t[0].role===`single`){let[e,t]=c[0];l=t===void 0?{color:e,fontStyle:s}:{color:e,bgColor:t,fontStyle:s}}else{let e=[];s&1&&e.push([`font-style`,`italic`]),s&2&&e.push([`font-weight`,`bold`]),s&12&&e.push([`text-decoration`,(s&12)==12?`underline line-through`:s&4?`underline`:`line-through`]);let r={};if(t[0].role===`light-dark`){let[[t,n],[i,a]]=c,o=t??`currentcolor`,s=i??`currentcolor`;if(r.color=o===s?o:`light-dark(${o}, ${s})`,n!==void 0||a!==void 0){let e=n??`transparent`,t=a??`transparent`;r[`background-color`]=e===t?e:`light-dark(${e}, ${t})`}for(let[t,n]of e)r[t]=n}else for(let i=0;i<t.length;i++){let[a,o]=c[i],s=t[i].role==="default",l=`${n}${t[i].color}`;r[s?`color`:l]=a??`inherit`,o!==void 0&&(r[s?`background-color`:`${l}-bg`]=o);for(let[t,n]of e)r[s?t:`${l}-${t}`]=n}l={htmlStyle:r}}i.styles.set(o,l)}}u!==void 0&&d===l?u.content+=e.slice(p,r):(u={content:e.slice(p,r),offset:p+a,...l},d=l,c.push(u))}if(s!==void 0){let e=s.split(`;`);for(let t=0;t<e.length;t++){let n=Number(e[t]);if(n===0)i.fg=-1,i.bg=-1,i.flags=0;else if(n<10)i.flags|=Ae[n]??0;else if(n>20&&n<30)i.flags&=~((Ae[n-20]??0)|(n===22?M:0));else if(n>=30&&n<38)i.fg=n-30;else if(n===39)i.fg=-1;else if(n>=40&&n<48)i.bg=n-40;else if(n===49)i.bg=-1;else if(n>=90&&n<98)i.fg=n-82;else if(n>=100&&n<108)i.bg=n-92;else if(n===38||n===48){let r=e[++t],a=-1;if(r===`5`){let n=Number(e[++t]);Number.isInteger(n)&&n<256&&(a=n)}else if(r===`2`){let n=Number(e[t+1]),r=Number(e[t+2]),i=Number(e[t+3]);t+=3,n>=0&&r>=0&&i>=0&&(a=16777216|Math.min(n,255)<<16|Math.min(r,255)<<8|Math.min(i,255))}a>=0&&(n===38?i.fg=a:i.bg=a)}}l=void 0}p=o}if(o.push(c),r<0)return o;p=r+1,c=[],u=void 0}}var Ne={plain:0,plaintext:0,text:0,txt:0,abap:1,ada:2,adb:2,ads:2,ahk:3,ahk1:3,ahk2:3,autohotkey:3,"angular-html":4,apache:5,apacheconf:5,htaccess:5,qmldir:5,"ssh-config":5,apex:6,apl:7,applescript:8,adoc:9,asciidoc:9,asm:10,assembly:10,mips:10,mipsasm:10,riscv:10,s:10,astro:11,awk:12,bal:13,ballerina:13,bat:14,batch:14,batchfile:14,cmd:14,dos:14,beancount:15,be:16,berry:16,bib:17,bibtex:17,bicep:18,blade:19,edge:19,"1c":20,bsl:20,c:21,h:21,c3:22,cadence:23,cdc:23,cairo:24,chapel:25,chpl:25,clj:26,cljc:26,cljs:26,clojure:26,edn:26,fennel:26,hy:26,cmake:27,cbl:28,cob:28,cobol:28,codeowners:29,codeql:30,ql:30,coffee:31,coffeescript:31,cl:32,clarity:32,"common-lisp":32,el:32,elisp:32,"emacs-lisp":32,lisp:32,lsp:32,racket:32,rkt:32,scheme:32,scm:32,coq:33,rocq:33,"c++":34,cc:34,cpp:34,cxx:34,hh:34,hpp:34,hxx:34,"c#":35,cs:35,csharp:35,genie:35,vala:35,css:36,postcss:36,qss:36,csv:37,cu:38,cuda:38,cuh:38,cue:39,cql:40,cypher:40,d:41,dart:42,dax:43,diff:44,"git-commit":44,"git-rebase":44,patch:44,containerfile:45,docker:45,dockerfile:45,dotenv:46,env:46,dm:47,"dream-maker":47,elixir:48,ex:48,exs:48,elm:49,erb:50,erl:51,erlang:51,hrl:51,fish:52,fluent:53,ftl:53,f:54,f77:54,for:54,"fortran-fixed-form":54,f03:55,f08:55,f18:55,f90:55,f95:55,fortran:55,"fortran-free-form":55,"f#":56,fs:56,fsharp:56,fsi:56,fsx:56,gdresource:57,"godot-resource":57,tres:57,tscn:57,gd:58,gdscript:58,gdshader:59,gdshaderinc:59,"godot-shader":59,cucumber:60,feature:60,gherkin:60,gleam:61,gjs:62,"glimmer-js":62,"glimmer-ts":63,gts:63,comp:64,frag:64,geom:64,glsl:64,vert:64,gnuplot:65,gp:65,go:66,golang:66,gql:67,graphql:67,groq:68,gradle:69,groovy:69,gsh:69,gvy:69,gy:69,nextflow:69,"nextflow-groovy":69,nf:69,ara:70,hack:70,haml:71,handlebars:72,hbs:72,mustache:72,haskell:73,hs:73,purescript:73,haxe:74,hx:74,hjson:75,hlsl:76,htm:77,html:77,"html-derivative":77,http:78,hurl:79,imba:80,desktop:81,ini:81,properties:81,systemd:81,java:82,cjs:83,javascript:83,js:83,mjs:83,j2:84,jinja:84,jinja2:84,json:85,jsonc:85,json5:86,jsonl:87,jsonnet:88,libsonnet:88,jsx:89,jl:90,julia:90,just:91,justfile:91,kdl:92,kotlin:93,kt:93,kts:93,kql:94,kusto:94,latex:95,tex:95,lean:96,lean4:96,less:97,liquid:98,llvm:99,log:100,lua:101,luau:102,make:103,makefile:103,mk:103,markdown:104,md:104,mdc:104,marko:105,matlab:106,octave:106,mdx:107,mermaid:108,mmd:108,mbt:109,mbti:109,moonbit:109,move:110,bird:111,bird2:111,nginx:111,nim:112,nix:113,nsh:114,nsi:114,nsis:114,nu:115,nushell:115,m:116,mm:116,objc:116,objcpp:116,"objective-c":116,"objective-cpp":116,objectivec:116,ml:117,mli:117,ocaml:117,odin:118,openscad:119,scad:119,org:120,delphi:121,dpk:121,dpr:121,lpr:121,"object-pascal":121,objectpascal:121,pas:121,pascal:121,pp:121,perl:122,pl:122,pm:122,php:123,pkl:124,plsql:125,po:126,pot:126,potx:126,powerquery:127,pq:127,powershell:128,ps:128,ps1:128,psd1:128,psm1:128,pwsh:128,prisma:129,prolog:130,promql:131,proto:132,protobuf:132,jade:133,pug:133,puppet:134,mojo:135,py:135,python:135,vy:135,vyper:135,qml:136,r:137,rscript:137,perl6:138,raku:138,cshtml:139,razor:139,reg:140,regex:141,regexp:141,rosmsg:142,restructuredtext:143,rst:143,crystal:144,rb:144,rbs:144,ruby:144,"ruby-signature":144,ron:145,rs:145,rust:145,sas:146,sass:147,sbt:148,sc:148,scala:148,scss:149,"1c-query":150,sdbl:150,shader:151,shaderlab:151,bash:152,console:152,hxml:152,sh:152,shell:152,shellscript:152,shellsession:152,zsh:152,smalltalk:153,st:153,smithy:154,sol:155,solidity:155,sparql:156,spl:157,splunk:157,sql:158,stata:159,styl:160,stylus:160,surql:161,surrealql:161,svelte:162,swift:163,talon:164,talonscript:164,tcl:165,templ:166,gn:167,hcl:167,terraform:167,tf:167,tfvars:167,toml:168,tsrx:169,tsv:170,tsx:171,ttl:172,turtle:172,twig:173,actionscript:174,"actionscript-3":174,"angular-ts":174,as3:174,cts:174,lit:174,mts:174,ts:174,"ts-tags":174,tsp:174,typescript:174,typespec:174,"vue-vine":174,typ:175,typst:175,v:176,vb:177,vba:177,vbnet:177,vbscript:177,sv:178,svh:178,"system-verilog":178,systemverilog:178,verilog:178,vhd:179,vhdl:179,vim:180,viml:180,vimscript:180,vue:181,"vue-html":181,wasm:182,wat:182,wgsl:183,mediawiki:184,wiki:184,wikitext:184,wit:185,mathematica:186,wl:186,wolfram:186,svg:187,xml:187,xsd:187,xsl:187,xslt:187,yaml:188,yml:188,zenscript:189,zs:189,zig:190,zon:190},L=new TextEncoder,R=new TextDecoder(`utf-8`,{ignoreBOM:!0}),z=65536,Pe=[/^\p{ID_Start}$/u,/^[\u200C\u200D\p{ID_Continue}]$/u],B,V=Ne;function H(e){let t=V[String(e).toLowerCase()];if(typeof t!=`number`)throw RangeError(`unknown lang: ${e}`);return t}function Fe(e){return typeof V[String(e).toLowerCase()]==`number`||F(e)}var U=class{#e;#t;#n;#r;#i=new Uint8Array;#a;#o;inputPtr;themePtr;wasmModule;instance;memory;buffer;dv;pageN;constructor(e,t,n={},r=!1,i){this.#a=t,this.#o=i,this.wasmModule=e;let a={lex_line:()=>0,fence_language:()=>0,fence_lex:()=>0,...n,is_id_start:(e,t)=>this.#c(e,t,0),is_id_continue:(e,t)=>this.#c(e,t,2)},o=new WebAssembly.Instance(e,{env:a});this.instance=o,this.memory=o.exports.memory,this.inputPtr=Number(o.exports.inputPtr.value),this.themePtr=Number(o.exports.themePtr?.value??0);let s=r?o.exports.emit:void 0;this.#e=s??o.exports.highlight??o.exports.lex,this.#t=s??o.exports.highlightStream??o.exports.lexStream,this.pageN=this.memory.buffer.byteLength/z,this.buffer=new Uint8Array(this.memory.buffer),this.dv=new DataView(this.memory.buffer)}writeInput(e,t=0){if(typeof e==`string`){this.grow(this.inputPtr+t+e.length+96);let{read:n,written:r}=L.encodeInto(e,this.buffer.subarray(this.inputPtr+t,this.buffer.length-96));if(n<e.length){let i=e.slice(n);this.grow(this.inputPtr+t+r+i.length*3+96),r+=L.encodeInto(i,this.buffer.subarray(this.inputPtr+t+r,this.buffer.length-96)).written}return r}if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw TypeError(`input must be a string, Uint8Array, or ArrayBuffer`);return this.grow(this.inputPtr+t+e.length+96),this.buffer.set(e,this.inputPtr+t),e.length}#s(e,t,n,r){this.#a?.(e,t,n,r),this.dv.setUint8(0,e),this.dv.setUint8(1,t),this.dv.setUint32(2,n,!0),this.buffer[this.inputPtr+n]=0;try{r===void 0?this.#e():this.#t(r)}finally{this.bindMemory()}}codeToHtml(e,t){let n=t.cssVariablePrefix??`--hls-`;if(F(t.lang)){let r=O(t),{fg:i,bg:a,rootStyle:o}=j(r,n),s=Ie(e),c=Me(s,r[0].role===`single`?[{...r[0],role:`default`}]:r,n),l=`<pre class="highlights" style="${T(o??(a===void 0?``:`background-color:${a};`)+(i===void 0?``:`color:${i}`))}"><code>`;for(let e=0,t=-1;e<c.length;e++){e>0&&(t=s.indexOf(`
3
3
  `,t+1),l+=s.charCodeAt(t-1)===13?`\r
4
4
  `:`