@aiquants/directory-tree 4.1.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -10
- package/dist/DirectoryTree.d.ts +3 -2
- package/dist/DirectoryTreeGrid.d.ts +2 -2
- package/dist/entryRendering.d.ts +7 -4
- package/dist/index.cjs +2 -2
- package/dist/index.js +1114 -1074
- package/dist/labels.d.ts +0 -2
- package/dist/rowSizing.d.ts +25 -0
- package/dist/styles/directory-tree.css +1 -1
- package/dist/styles/directory-tree.standalone.css +1 -1
- package/dist/types.d.ts +3 -2
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -164,9 +164,12 @@ The main component for rendering the directory tree.
|
|
|
164
164
|
| `showDirectoryIcons` | `boolean` | No | `true` | Flag indicating whether to render directory type icons |
|
|
165
165
|
| `showFileIcons` | `boolean` | No | `true` | Flag indicating whether to render file type icons |
|
|
166
166
|
| `iconOverrides` | `DirectoryTreeIconOverrides` | No | - | Icon overrides applied globally |
|
|
167
|
-
| `expandIconSize` | `number` | No |
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
167
|
+
| `expandIconSize` | `number` | No | `8` on the canvas | Size of the expand icon in px: the chevron in the row when `showTreeLines` is `false`, the glyph on the tree-line canvas when it is `true`. While tree lines are drawn it must be greater than 0 and at most 14 (the expand box); otherwise rendering throws a `RangeError` |
|
|
168
|
+
| `typeIconSize` | `number` | No | `14` | Side of the file/folder icon's box in px; the built-in icons grow and shrink with it. See [Sizing](#sizing) |
|
|
169
|
+
| `fontSize` | `number \| string` | No | inherited | Font size of the labels: px, or any CSS font size. See [Sizing](#sizing) |
|
|
170
|
+
| `indentSize` | `number` | No | `12` | Indentation per depth level in px; with tree lines it must lie in the range [Sizing](#sizing) gives |
|
|
171
|
+
| `itemHeight` | `number \| ((entry, index) => number)` | No | `44` | Row height in px, or a function computing the height per entry (variable-height rows). The default makes every row a pointer target of at least 44 × 44 CSS px under every pointer (WCAG 2.5.5). Tree connector lines follow each row's cumulative offset. The number, and every value the function returns, must be a finite number greater than 0; an invalid one (`NaN` / `Infinity` / `0` / negative) throws a `RangeError` at render that names the value (and, for the function, the entry). Memoize the function to keep its identity stable. |
|
|
172
|
+
| `removeRootIndent` | `boolean` | No | `false` | If true, the root rows drop their lead column (the expand box, with its chevron or glyph) and their own connector lines, and every list row moves left by that lead, at most one `indentSize` (see [Sizing](#sizing)). Ignored in grid mode. |
|
|
170
173
|
| `highlightStyles` | `HighlightStyles` | No | - | Highlight styles configuration for hover and selection states |
|
|
171
174
|
| `entryClassName` | `string` | No | - | Additional CSS classes for each entry row |
|
|
172
175
|
| `entryStyle` | `React.CSSProperties` | No | - | Additional inline styles for each entry row |
|
|
@@ -364,9 +367,9 @@ The component's hand-written classes ship in **two CSS artifacts**; choose by ho
|
|
|
364
367
|
/* monorepo: @source "../../../../packages/directory-tree/src/**/*.{ts,tsx}"; */
|
|
365
368
|
```
|
|
366
369
|
|
|
367
|
-
`directory-tree.css` (Artifact A) carries only the hand-written `.dt-*` classes — no `:root` theme variables, no Tailwind utilities, no preflight — and it does **not** embed the virtualscroll stylesheet (the host imports virtualscroll's own Artifact A once, avoiding a duplicated, possibly stale copy). Do not also `@import` the standalone build here — the duplicated utilities flip the base/variant cascade order.
|
|
370
|
+
`directory-tree.css` (Artifact A) carries only the hand-written component rules (the `.dt-*` classes and the `box-sizing: border-box` rule of the container, the rows and the grid's name cells) — no `:root` theme variables, no Tailwind utilities, no preflight — and it does **not** embed the virtualscroll stylesheet (the host imports virtualscroll's own Artifact A once, avoiding a duplicated, possibly stale copy). Do not also `@import` the standalone build here — the duplicated utilities flip the base/variant cascade order.
|
|
368
371
|
|
|
369
|
-
- **Non-Tailwind host** — import the single self-contained standalone build; it bundles the `.dt-*` classes, every JSX utility, and the virtualscroll peer CSS for convenience:
|
|
372
|
+
- **Non-Tailwind host** — import the single self-contained standalone build; it bundles the `.dt-*` classes, every JSX utility, and the virtualscroll peer CSS for convenience. It needs no preflight: the container, the rows and the grid's name cells are `border-box` in both builds, so a 44 px row is 44 px tall here too:
|
|
370
373
|
|
|
371
374
|
```css
|
|
372
375
|
@import "@aiquants/directory-tree/styles/directory-tree.standalone.css";
|
|
@@ -474,25 +477,78 @@ Alternatively, you can dynamically configure specific highlight styles for hover
|
|
|
474
477
|
|
|
475
478
|
### Row Height (fixed & variable)
|
|
476
479
|
|
|
477
|
-
Rows are
|
|
478
|
-
|
|
479
|
-
|
|
480
|
+
Rows are 44 px tall by default, so every row is a pointer target of at least 44 × 44 CSS px under
|
|
481
|
+
every pointer — mouse, pen and touch alike (WCAG 2.5.5 Target Size). The expand glyph keeps its size
|
|
482
|
+
(8 px on the tree-line canvas) because the whole row is the target; a height below 44 px makes the
|
|
483
|
+
rows smaller targets than that.
|
|
484
|
+
Pass a number for a uniform height, or a function for variable-height rows — the virtual scroller
|
|
485
|
+
and the tree connector lines both follow each row's resolved height. Memoize the function so its
|
|
486
|
+
identity stays stable.
|
|
487
|
+
|
|
488
|
+
At any row height, fixed or variable, the line from an expanded folder to its children starts just
|
|
489
|
+
below the folder's type icon (a `typeIconSize` box, 14 px by default, centred in the row) and runs on
|
|
490
|
+
into the first child's connector, so the tree reads as one joined line however tall the rows are. A host that hides
|
|
491
|
+
directory icons (`showDirectoryIcons: false`) gets the same line: the name takes the icon's place,
|
|
492
|
+
and the line starts just below it.
|
|
480
493
|
|
|
481
494
|
```tsx
|
|
482
495
|
import { useCallback } from 'react';
|
|
483
496
|
import { DirectoryTree, type DirectoryEntry } from '@aiquants/directory-tree';
|
|
484
497
|
|
|
485
498
|
// Fixed height
|
|
486
|
-
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight:
|
|
499
|
+
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight: 48 }} />
|
|
487
500
|
|
|
488
501
|
// Variable height: taller rows for files that render inline metadata
|
|
489
502
|
const itemHeight = useCallback(
|
|
490
|
-
(entry: DirectoryEntry) => (entry.type === 'file' ?
|
|
503
|
+
(entry: DirectoryEntry) => (entry.type === 'file' ? 56 : 44),
|
|
491
504
|
[],
|
|
492
505
|
);
|
|
493
506
|
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight }} />
|
|
494
507
|
```
|
|
495
508
|
|
|
509
|
+
### Sizing
|
|
510
|
+
|
|
511
|
+
Three settings size the parts of a row in list rows and grid rows alike; omitted, each keeps its default.
|
|
512
|
+
|
|
513
|
+
| Setting | Default | What it sizes |
|
|
514
|
+
| --- | --- | --- |
|
|
515
|
+
| `indentSize` | `12` | The indentation per depth level: a row at depth *d* is padded by *d* × `indentSize` (in grid mode, its name cell). |
|
|
516
|
+
| `typeIconSize` | `14` | The side of the file/folder icon's box. The built-in icons fill the box, so they grow and shrink with it; an icon you supply (`iconOverrides`, `entry.icon`) keeps its own size and is centred in the box. |
|
|
517
|
+
| `fontSize` | inherited | The labels' font size: a number in px or any CSS font size (`'0.875rem'`). Omitted, list rows keep their 12 px labels and grid rows the font size they inherit. Rows keep `itemHeight`. |
|
|
518
|
+
|
|
519
|
+
From its indentation, every row lays out the 14 px expand box (the chevron, or the tree lines'
|
|
520
|
+
glyph), the type icon box, then the label. The tree lines follow these sizes at any row height,
|
|
521
|
+
fixed or per entry: the line of a depth runs under the parents' icons (under their centre whenever
|
|
522
|
+
the glyph fits there, see below), every expand glyph sits on its line inside its own row's expand
|
|
523
|
+
box, and the line from an expanded folder starts just below its icon and runs straight on into its
|
|
524
|
+
children's lines. The font size moves no line:
|
|
525
|
+
the icon box stays centred in the row.
|
|
526
|
+
|
|
527
|
+
With `removeRootIndent`, the root rows give up their lead — the 14 px expand box while expand icons
|
|
528
|
+
or tree lines are shown, nothing otherwise — and every list row moves left by that lead, but by at
|
|
529
|
+
most one `indentSize`. The root's icon (or label) therefore starts at the left edge without being
|
|
530
|
+
clipped, every deeper row keeps its whole expand box, and the root rows draw no chevron. At the
|
|
531
|
+
default indentation (12, narrower than the box) the rows move by 12 and 2 px of the root's empty box
|
|
532
|
+
stay at the left; from 14 up the root's icon touches the left edge. Without an expand box there is
|
|
533
|
+
no lead to drop and the rows stay where they are.
|
|
534
|
+
|
|
535
|
+
The values are checked when the tree renders, and an invalid one throws a `RangeError` that names
|
|
536
|
+
the setting and the value (nothing falls back to a default):
|
|
537
|
+
|
|
538
|
+
- `indentSize` and `typeIconSize` must be finite numbers greater than 0; `fontSize` a finite number
|
|
539
|
+
greater than 0 or a string that is not blank; `itemHeight` a finite number greater than 0, and so
|
|
540
|
+
must every value its function returns (the error then also names the entry).
|
|
541
|
+
- While tree lines are drawn (`showTreeLines`, the default), `indentSize` must also lie from *g* / 2
|
|
542
|
+
to 14 + `typeIconSize` − *g* / 2, where *g* is the glyph (`expandIconSize`, 8 by default, at most
|
|
543
|
+
14): 4 to 24 with the default icon, 4 to 30 with a 20 px icon. Inside that range the line hangs
|
|
544
|
+
from the parent's icon — from its centre when the glyph fits there, otherwise moved toward the
|
|
545
|
+
glyph's box (2 px left of the centre at `indentSize: 8` with a 12 px icon). A tree without lines
|
|
546
|
+
takes any valid indentation.
|
|
547
|
+
|
|
548
|
+
```tsx
|
|
549
|
+
<DirectoryTree entries={entries} /* ...required props */ visual={{ indentSize: 20, typeIconSize: 20, fontSize: 16 }} />
|
|
550
|
+
```
|
|
551
|
+
|
|
496
552
|
### TreeGrid (columns) mode
|
|
497
553
|
|
|
498
554
|
Pass the optional `grid` prop to turn the tree into a **TreeGrid**: the name/tree column
|
package/dist/DirectoryTree.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { directoryTreeClasses } from "./entryRendering.tsx";
|
|
2
|
+
import { TreeLineLayout } from "./rowSizing.ts";
|
|
2
3
|
import { DirectoryTreeProps, TreeLineGeometry, TreeLineItemInfo } from "./types.ts";
|
|
3
|
-
export declare const buildTreeLineGeometry: (items: TreeLineItemInfo[], itemHeights: number[], itemOffsets: number[],
|
|
4
|
-
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, currentPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, expandIconClassName, expandIconStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, ref, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
4
|
+
export declare const buildTreeLineGeometry: (items: TreeLineItemInfo[], itemHeights: number[], itemOffsets: number[], layout: TreeLineLayout) => TreeLineGeometry;
|
|
5
|
+
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, currentPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, typeIconSize, fontSize, indentSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, expandIconClassName, expandIconStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, ref, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
5
6
|
export { directoryTreeClasses };
|
|
@@ -7,9 +7,9 @@ export type GridRowVisual = {
|
|
|
7
7
|
showFileIcons?: boolean;
|
|
8
8
|
useCanvasExpandIcons?: boolean;
|
|
9
9
|
expandIconSize?: number;
|
|
10
|
-
typeIconSize
|
|
10
|
+
typeIconSize: number;
|
|
11
11
|
fontSize?: number | string;
|
|
12
|
-
indentSize
|
|
12
|
+
indentSize: number;
|
|
13
13
|
highlightStyles?: HighlightStyles;
|
|
14
14
|
expandIconClassName?: string;
|
|
15
15
|
expandIconStyle?: CSSProperties;
|
package/dist/entryRendering.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import { DirectoryEntry, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from "./types.ts";
|
|
3
|
-
export declare const DEFAULT_ITEM_HEIGHT =
|
|
3
|
+
export declare const DEFAULT_ITEM_HEIGHT = 44;
|
|
4
4
|
export declare const INDENT_SIZE = 12;
|
|
5
5
|
export declare const EXPAND_GLYPH_SIZE = 8;
|
|
6
|
+
export declare const EXPAND_BOX_SIZE = 14;
|
|
7
|
+
export declare const TYPE_ICON_SIZE = 14;
|
|
8
|
+
export declare const toFontSizeStyle: (fontSize: number | string | undefined) => CSSProperties | undefined;
|
|
6
9
|
export declare const directoryTreeClasses: {
|
|
7
10
|
container: string;
|
|
8
11
|
containerPending: string;
|
|
@@ -31,6 +34,6 @@ export type ExpandIconParams = {
|
|
|
31
34
|
export declare const resolveExpandIcon: ({ isDirectory, isExpanded, showExpandIcons, useCanvasExpandIcons, expandIconSize }: ExpandIconParams) => ReactNode;
|
|
32
35
|
export declare const GENERIC_MIME_TYPES: ReadonlySet<string>;
|
|
33
36
|
export declare const normalizeMimeType: (mimeType: string | undefined) => string;
|
|
34
|
-
export declare const getFileIconByMimeOrExtension: (mimeType
|
|
35
|
-
export declare const resolveEntryIcon: (ctx: DirectoryTreeIconRenderContext, overrides
|
|
37
|
+
export declare const getFileIconByMimeOrExtension: (mimeType: string | undefined, extension: string | undefined, filename: string | undefined, typeIconSize: number) => ReactNode;
|
|
38
|
+
export declare const resolveEntryIcon: (ctx: DirectoryTreeIconRenderContext, overrides: DirectoryTreeIconOverrides | undefined, typeIconSize: number) => ReactNode;
|
|
36
39
|
export declare const toDataAttributes: (data?: Record<string, string | number | boolean>) => Record<string, string> | undefined;
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),he=require("@aiquants/virtualscroll"),O=require("tailwind-merge"),ae=require("@phosphor-icons/react");function rn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=rn(l);var ht={exports:{}},Je={};var vr;function nn(){if(vr)return Je;vr=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,a,c){var i=null;if(c!==void 0&&(i=""+c),a.key!==void 0&&(i=""+a.key),"key"in a){c={};for(var d in a)d!=="key"&&(c[d]=a[d])}else c=a;return a=c.ref,{$$typeof:e,type:n,key:i,ref:a!==void 0?a:null,props:c}}return Je.Fragment=t,Je.jsx=r,Je.jsxs=r,Je}var qe={};var wr;function on(){return wr||(wr=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===H?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case b:return"Fragment";case $:return"Profiler";case x:return"StrictMode";case F:return"Suspense";case D:return"SuspenseList";case Z:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case p:return"Portal";case P:return o.displayName||"Context";case N:return(o._context.displayName||"Context")+".Consumer";case y:var h=o.render;return o=o.displayName,o||(o=h.displayName||h.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case j:return h=o.displayName||null,h!==null?h:e(o.type)||"Memo";case J:h=o._payload,o=o._init;try{return e(o(h))}catch{}}return null}function t(o){return""+o}function r(o){try{t(o);var h=!1}catch{h=!0}if(h){h=console;var k=h.error,I=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return k.call(h,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",I),t(o)}}function n(o){if(o===b)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===J)return"<...>";try{var h=e(o);return h?"<"+h+">":"<...>"}catch{return"<...>"}}function a(){var o=Y.A;return o===null?null:o.getOwner()}function c(){return Error("react-stack-top-frame")}function i(o){if(ie.call(o,"key")){var h=Object.getOwnPropertyDescriptor(o,"key").get;if(h&&h.isReactWarning)return!1}return o.key!==void 0}function d(o,h){function k(){me||(me=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",h))}k.isReactWarning=!0,Object.defineProperty(o,"key",{get:k,configurable:!0})}function v(){var o=e(this.type);return G[o]||(G[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function w(o,h,k,I,ue,T){var L=k.ref;return o={$$typeof:g,type:o,key:h,props:k,_owner:I},(L!==void 0?L:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:v}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ue}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:T}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function S(o,h,k,I,ue,T){var L=h.children;if(L!==void 0)if(I)if(U(L)){for(I=0;I<L.length;I++)R(L[I]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else R(L);if(ie.call(h,"key")){L=e(o);var Q=Object.keys(h).filter(function(xe){return xe!=="key"});I=0<Q.length?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}",V[L+I]||(Q=0<Q.length?"{"+Q.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,_,M,Z,M),j[M+_]=!0)}if(M=null,v!==void 0&&(r(v),M=""+v),i(p)&&(r(p.key),M=""+p.key),"key"in p){v={};for(var me in p)me!=="key"&&(v[me]=p[me])}else v=p;return M&&u(v,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,M,v,a(),ne,ie)}function y(o){R(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===V&&(o._payload.status==="fulfilled"?R(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function R(o){return typeof o=="object"&&o!==null&&o.$$typeof===N}var E=l,N=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),C=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),q=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re=Object.prototype.hasOwnProperty,ee=Array.isArray,$=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(o){return o()}};var he,le={},ce=E.react_stack_bottom_frame.bind(E,c)(),z=$(n(c)),j={};ze.Fragment=w,ze.jsx=function(o,p,v){var _=1e4>q.recentlyCreatedOwnerStacks++;return h(o,p,v,!1,_?Error("react-stack-top-frame"):ce,_?$(n(o)):z)},ze.jsxs=function(o,p,v){var _=1e4>q.recentlyCreatedOwnerStacks++;return h(o,p,v,!0,_?Error("react-stack-top-frame"):ce,_?$(n(o)):z)}})()),ze}var fr;function Jr(){return fr||(fr=1,process.env.NODE_ENV==="production"?st.exports=Ur():st.exports=Xr()),st.exports}var f=Jr();function qr({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const Zr=fe.forwardRef(qr);function Qr({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const en=fe.forwardRef(Qr);function tn({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const rn=fe.forwardRef(tn),at=18,lt=12,hr=8,L={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:A.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},_t=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},nn=/^[a-z][a-z\d+.-]*:\/\//i,mr=e=>_t(nn.test(e)?e.split(/[?#]/,1)[0]:e),Sr=e=>_t(e.name)||mr(e.relativePath)||mr(e.absolutePath),Er=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:a})=>{const c=a?{width:a,height:a}:void 0,i=a?"":"h-4 w-4";return!(r&&e)||n?f.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?f.jsx(Zr,{className:i,style:c}):f.jsx(en,{className:i,style:c})},kt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(a=>kt(a,t)).filter(Boolean);return n.length?n:null}const r=e.type;if(r&&r.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},on={markdown:()=>f.jsx(se.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"}),pdf:()=>f.jsx(se.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"}),spreadsheet:()=>f.jsx(se.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),csv:()=>f.jsx(se.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),document:()=>f.jsx(se.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),presentation:()=>f.jsx(se.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"}),image:()=>f.jsx(se.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"}),audio:()=>f.jsx(se.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"}),video:()=>f.jsx(se.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"}),archive:()=>f.jsx(se.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"}),code:()=>f.jsx(se.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"}),text:()=>f.jsx(se.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})},sn={markdown:["md","markdown","mdx"],pdf:["pdf"],spreadsheet:["xls","xlsx","xlsm","xlsb","ods"],csv:["csv","tsv"],document:["doc","docx","rtf","odt"],presentation:["ppt","pptx","odp"],image:["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"],audio:["mp3","wav","ogg","m4a","flac","aac","wma"],video:["mp4","webm","mov","avi","mkv","wmv","flv"],archive:["zip","tar","gz","7z","rar","tgz","bz2"],code:["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"],text:["txt","log"]},an=new Map(Object.entries(sn).flatMap(([e,t])=>t.map(r=>[r,e]))),ln=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),cn=e=>(e??"").split(";",1)[0].trim().toLowerCase(),un=e=>{if(e==="text/markdown"||e==="text/x-markdown")return"markdown";if(e==="application/pdf")return"pdf";if(e.includes("excel")||e.includes("spreadsheet"))return"spreadsheet";if(e==="text/csv"||e==="text/tab-separated-values")return"csv";if(e.includes("word")||e.includes("google-apps.document")||e==="application/rtf")return"document";if(e.includes("powerpoint")||e.includes("presentation"))return"presentation";if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e.includes("zip")||e.includes("tar")||e.includes("compressed")||e.includes("archive"))return"archive";if(e==="application/json"||e.includes("javascript")||e.includes("typescript")||e.includes("xml")||e.startsWith("text/html")||e.startsWith("text/css")||e.includes("x-python")||e.includes("x-sh")||e.includes("x-go")||e.includes("x-rust"))return"code";if(e.startsWith("text/"))return"text"},dn=(e,t,r)=>{const n=cn(e),a=un(n),c=an.get((t||(r?_t(r):"")).toLowerCase()),u=(ln.has(n)?[c,a]:[a,c]).find(I=>I!==void 0);return u===void 0?f.jsx(se.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"}):on[u]()},Rr=(e,t)=>{const{entry:r,isDirectory:n,isExpanded:a,extension:c,mimeType:i}=e;let u;const I=i||r.mimeType;return r.icon!==void 0?u=r.icon:n?u=a&&t?.directoryExpanded||t?.directory||f.jsx(rn,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?u=t.fileByExtension[c]:u=t?.file||dn(I,c,r.name),kt(typeof u=="function"?u(e):u,r.absolutePath)},fn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kr=e=>{if(!e)return;const t=Object.entries(e).filter(([,r])=>r!=null);if(t.length!==0)return Object.fromEntries(t.map(([r,n])=>[`data-${fn(r)}`,String(n)]))},hn=500,Ir=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:a,onSelectionChange:c,onEntryClick:i,toggleDirectory:u,onToggleDirectoryRecursive:I})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(h=>{h.stopPropagation(),a!=="none"&&!t&&c&&c(e,!n);let y=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{y=!0}}),!(!t||y)&&(S.current?(window.clearTimeout(S.current),S.current=null,I(e)):S.current=window.setTimeout(()=>{u(e.absolutePath),S.current=null},hn))},[t,e,r,I,u,i,a,c,n])},Cr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",pr=(e,t)=>e.children!==void 0&&t(e.absolutePath),Tr=(e,t)=>({width:e,gridTemplateColumns:t}),_r=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:a,flatIndex:c,onRowFocus:i,onRowBlur:u,isSelectedForAria:I,rowHeight:S,isDirOpen:h,columns:y,numericTemplate:R,numericTotal:E,nameWidth:N,rowClassName:m,selection:{onEntryClick:w,selectedPath:k,currentPath:F,mode:x="none",selectedItems:C,onSelectionChange:b},expansion:{toggleDirectory:H,onToggleDirectoryRecursive:D},visual:{iconOverrides:P,showExpandIcons:V=!0,showDirectoryIcons:ae=!0,showFileIcons:X=!0,useCanvasExpandIcons:q=!1,expandIconSize:re,indentSize:ee=lt,highlightStyles:$,expandIconClassName:he,expandIconStyle:le}})=>{const[ce,z]=l.useState(!1),j=e.children!==void 0,o=j&&h(e.absolutePath),p=e.absolutePath===k,v=e.absolutePath===F,_=!j&&!!C?.has(e.absolutePath),ne=j?void 0:Sr(e),ie=Ir({entry:e,isDirectory:j,isExpanded:o,isItemSelected:_,selectionMode:x,onSelectionChange:b,onEntryClick:w,toggleDirectory:H,onToggleDirectoryRecursive:D}),M=ce?$?.hoverClassName!==void 0?$.hoverClassName:L.entryHover:"",Z=(()=>{if(j){if(p)return $?.directorySelectedClassName!==void 0?$.directorySelectedClassName:L.entrySelected}else if(p||_)return $?.itemSelectedClassName!==void 0?$.itemSelectedClassName:A.twMerge(p&&L.entrySelected,_&&L.entryItemSelected);return""})(),me=typeof m=="function"?m(e):m,ue=A.twMerge("dt-grid-row cursor-pointer select-none",M,Z,me,e.className),Te=A.twMerge(L.expandIcon,he,(p||_)&&L.expandIconSelected),Ee=A.twMerge(L.typeIcon,(p||_)&&L.typeIconSelected),te=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",j&&L.nameDirectory,(p||_)&&L.nameSelected),O=Er({isDirectory:j,isExpanded:o,showExpandIcons:V,useCanvasExpandIcons:q,expandIconSize:re}),de=(j?ae:X)?Rr({entry:e,isDirectory:j,isExpanded:o,isSelected:p,isItemSelected:_,extension:ne,mimeType:e.mimeType},P):null,K={indentLevel:t,isDirectory:j,isExpanded:o},[we,...G]=y,Oe=we?.render?we.render(e,K):e.label??e.name,Re={...ce?$?.hoverStyle:{},...j&&p?$?.directorySelectedStyle:{},...!j&&(p||_)?$?.itemSelectedStyle:{}};return f.jsxs("div",{className:ue,style:{height:S,...Re,...e.style},role:"row","aria-expanded":j?o:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":a,"aria-selected":x==="none"?void 0:I,"aria-current":v?"page":void 0,...kr(e.data),"data-entry-type":j?"directory":"file","data-entry-expanded":j?String(o):void 0,"data-entry-selected":p?"true":void 0,"data-entry-item-selected":_?"true":void 0,onClick:ie,onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),onFocus:W=>i(c,e.absolutePath,W.currentTarget),onBlur:W=>u(e.absolutePath,W.currentTarget),onKeyDown:W=>{if(W.key==="Enter"){if(W.repeat){W.preventDefault();return}ie(W)}},tabIndex:0,children:[f.jsxs("div",{className:A.twMerge("dt-grid-name-cell",we?.className),role:"gridcell",style:{width:N,paddingLeft:Math.max(0,t*ee)},children:[(V||q)&&f.jsx("span",{className:Te,style:le,children:O}),(j?ae:X)&&f.jsx("span",{className:Ee,children:de}),f.jsx("span",{className:te,children:Oe})]}),G.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:Tr(E,R),children:G.map(W=>f.jsx("div",{className:A.twMerge("dt-grid-cell",Cr(W.align),W.className),role:"gridcell",children:W.render?W.render(e,K):null},W.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=pr(e.entry,e.isDirOpen),n=pr(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.flatIndex===t.flatIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&r===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});_r.displayName="DirectoryTreeGridRow";const Nr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:a,scrollBarWidth:c,className:i,nameContent:u,renderCell:I})=>{const[,...S]=t,h=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",y=e==="header"?"dt-grid-header":"dt-grid-footer",R=e==="header"?"columnheader":"gridcell";return f.jsxs("div",{className:A.twMerge(y,"text-gray-600 dark:text-gray-300",i),role:"row",children:[f.jsx("div",{className:A.twMerge(h,"px-1",t[0]?.className),role:R,style:{width:a},children:u}),S.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:Tr(n,r),children:S.map(E=>f.jsx("div",{className:A.twMerge("dt-grid-cell",Cr(E.align),E.className),role:R,children:I(E)},E.key))})}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},mn=({columns:e,className:t,...r})=>f.jsx(Nr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),yr=(e,t)=>typeof e=="function"?e(t):e??null,pn=({columns:e,allEntries:t,className:r,...n})=>f.jsx(Nr,{kind:"footer",columns:e,className:r,nameContent:yr(e[0]?.footer,t),renderCell:a=>yr(a.footer,t),...n}),yn=240,jr=96,Pr=12,It=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},bn=e=>e.slice(1).map(t=>`${It(t,jr)}px`).join(" "),gn=({measuredWidth:e,columns:t,scrollBarWidth:r=Pr})=>{const n=It(t[0],yn),a=t.slice(1).reduce((I,S)=>I+It(S,jr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),u=Math.max(0,a-i);return{nameWidth:n,numericTotal:a,numericVisible:i,maxHScroll:u}},Rt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,vn=e=>{const t=[],r=n=>{for(const a of n)t.push(a),a.children&&a.children.length>0&&r(a.children)};return r(e),t},Mr=["entryKindDirectory","entryKindFile"],Ct=[...pe.VIRTUAL_SCROLL_LABEL_KEYS,...Mr],Tt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Ar=Object.freeze({en:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Tt.en}),ja:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Tt.ja})}),br=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,wn=e=>{const t={};let r=!1;for(const n of pe.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,n)?e[n]:void 0;a!==void 0&&(t[n]=a,r=!0)}return r?t:void 0},Or=(e,t)=>{const r=pe.resolveVirtualScrollLocale(e);if(t===void 0)return Ar[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${br(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const i of Object.keys(t))if(!Ct.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${Ct.join(", ")}`);const c={...pe.resolveVirtualScrollLabels(r,wn(t)),...Tt[r]};for(const i of Mr){const u=Object.hasOwn(t,i)?t[i]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${br(u)}`);c[i]=u}}return Object.freeze(c)},xn=e=>{const t={};for(const r of pe.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Sn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},En=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},Rn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=En(t,r),a=e[n];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[n]}:null},kn=(e,t,r)=>{if(t.length===0||r.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,r[n]+e.offsetInViewport);return null},In=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Cn=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Tn=(e,t,r,n)=>{const a=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(e.width!==a||e.height!==c)&&(e.width=a,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},_n=(e,t,r)=>{e.lineWidth=r,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Nn=(e,t)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!r)return null;let n=r[1];n.length===3&&(n=n.split("").map(u=>u+u).join(""));const a=Number.parseInt(n.slice(0,2),16),c=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgba(${a}, ${c}, ${i}, ${t})`},jn=(e,t,r,n)=>{if(t.length===0)return;const a=Nn(r,.14),c=e.strokeStyle,i=e.fillStyle,u=e.lineWidth,I=e.lineCap,S=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const h of t){const y=n??h.size,R=Math.max(0,y/2),E=Math.max(1,Math.round(y*.08)),N=Math.max(1,Math.round(y*.14)),m=Math.max(0,R-E*.8),w=Math.max(0,m*.55);a&&(e.fillStyle=a,e.beginPath(),e.arc(h.centerX,h.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=E,e.beginPath(),e.arc(h.centerX,h.centerY,Math.max(0,R-E*.3),0,Math.PI*2),e.stroke(),e.lineWidth=N,e.beginPath(),e.moveTo(h.centerX-w,h.centerY),e.lineTo(h.centerX+w,h.centerY),e.stroke(),h.isExpanded||(e.beginPath(),e.moveTo(h.centerX,h.centerY-w),e.lineTo(h.centerX,h.centerY+w),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=u,e.lineCap=I,e.lineJoin=S},Lr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i="#a0aec0",strokeWidth:u=1,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E})=>{const N=l.useRef(null),m=l.useRef(null),w=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E}),k=l.useCallback(()=>{m.current=null;const x=N.current;if(!x)return;const C=x.getContext("2d");if(!C)return;const b=w.current;if(b.width<=0||b.viewportHeight<=0){C.clearRect(0,0,x.width,x.height);return}const H=Number.isFinite(b.devicePixelRatio??NaN)?b.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Tn(x,b.width,b.viewportHeight,H);const D=b.segmentsByItem.length,P=typeof b.renderStartIndex=="number"&&Number.isFinite(b.renderStartIndex)?Math.max(0,Math.floor(b.renderStartIndex)):Math.max(0,Math.floor(b.scrollPosition/b.itemHeight)),V=Math.min(D,Math.ceil((b.scrollPosition+b.viewportHeight)/b.itemHeight)),ae=(()=>{if(typeof b.renderEndIndex=="number"&&Number.isFinite(b.renderEndIndex)){const ee=Math.floor(b.renderEndIndex);return Math.max(Math.min(D,ee+1),P)}return Math.max(V,P)})(),X=(()=>{if(typeof b.lookaheadEndIndex=="number"&&Number.isFinite(b.lookaheadEndIndex)){const ee=Math.floor(b.lookaheadEndIndex),$=Math.min(D,ee+1);return Math.max($,ae)}return Math.max(V,ae)})(),q=In(b.segmentsByItem,P,X),re=Cn(b.glyphsByItem,P,X);C.save(),C.scale(H,H),C.clearRect(0,0,b.width,b.viewportHeight),C.translate(0,-b.scrollPosition),C.strokeStyle=b.color,_n(C,q,b.strokeWidth),jn(C,re,b.expandGlyphColor??b.color,b.expandGlyphSize),C.restore()},[]),F=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(k))},[k]);return l.useEffect(()=>{w.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E},F()},[e,t,r,n,a,c,i,u,I,S,h,y,R,E,F]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),f.jsx("canvas",{ref:N,className:"pointer-events-none absolute top-0 left-0 z-0"})});Lr.displayName="TreeLineCanvas";const Pn=e=>{const t=new Map;for(let r=0;r<e.length;r++){const n=e[r].entry.absolutePath;t.has(n)||t.set(n,r)}return t},gr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},Mn=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),An=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:a}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const c=e.get(r.path);if(c!==void 0)return c}if(a!==null){const c=e.get(a);if(c!==void 0)return c}return 0},On={msOverflowStyle:"none",scrollbarWidth:"none"},Ln=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},Dn=e=>{const t=l.useRef(null),r=t.current;return r!==null&&pe.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},vr=new Set(["top","bottom","center","nearest"]),wr=e=>{const t=e?.align;if(t===void 0)return"top";if(!vr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...vr].join(", ")}.`);return t},Fn={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},$n=(e,t,r,n,a)=>{const c=[],i=[];let u=0;const I=(S,h,y)=>{const R=a?[...S].sort(a):S;for(let E=0;E<R.length;E++){const N=R[E],m=E===R.length-1,w=[...y,m],k=N.children!==void 0,F=k&&t(N.absolutePath,N.relativePath);let x=h,C=w,b=y;n&&(x=h-1,C=w.slice(1),b=y.slice(1)),c.push({entry:N,indentLevel:x,depth:h,positionInSet:E+1,setSize:R.length,parentIsLast:C}),r&&(x>u&&(u=x),i.push({id:N.absolutePath,name:N.name,absolutePath:N.absolutePath,indentLevel:x,isLastChild:m,isDirectory:k,isExpanded:F,ancestorIsLast:[...b],hideLines:n&&h===0})),k&&F&&N.children&&I(N.children,h+1,w)}};return I(e,0,[]),{flatItems:c,lineItems:i,maxIndent:u}},xr=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},Bn=(e,t,r,n,a,c)=>{const i=n?.renderStart??Math.max(0,xr(c,a)),u=t>0?xr(c,a+t)+r:i+r,I=e>0?Math.min(e-1,Math.max(i,u)):i,S=n?.renderEnd??I,h=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:h}},Hn=(e,t,r,n,a,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),u=Array.from({length:e.length},()=>[]),I=h=>a?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(n*.9,h*.7)):0,S=3;for(let h=0;h<e.length;h++){const y=e[h];if(y.hideLines)continue;const R=[],E=t[h]??0,N=r[h]??0,m=N+E/2,w=I(E),k=w>0?w/2+2:n/1.5;for(let C=0;C<y.indentLevel;C++){if(y.ancestorIsLast[C]??!1)continue;let H=!1;for(let D=h;D<e.length;D++){const P=e[D];if(P.indentLevel>C&&P.ancestorIsLast.length>C&&!P.ancestorIsLast[C]){H=!0;break}if(D>h&&P.indentLevel===C)break}if(H){const D=C*n+n/2+S;R.push({key:`${y.id}-ancestor-${C}`,x1:D,y1:N,x2:D,y2:N+E,itemIndex:h})}}const F=y.indentLevel*n,x=F+n/2+S;if(y.isDirectory?R.push({key:`${y.id}-connector-top`,x1:x,y1:N,x2:x,y2:m-k,itemIndex:h}):R.push({key:`${y.id}-connector-top`,x1:x,y1:N,x2:x,y2:m,itemIndex:h}),!y.isDirectory&&y.isLastChild&&R.push({key:`${y.id}-connector-horizontal`,x1:x,y1:m,x2:F+n+S,y2:m,itemIndex:h}),y.isLastChild||(y.isDirectory?R.push({key:`${y.id}-connector-bottom`,x1:x,y1:m+k,x2:x,y2:N+E,itemIndex:h}):R.push({key:`${y.id}-connector-bottom`,x1:x,y1:m,x2:x,y2:N+E,itemIndex:h})),i[h]=R,a&&y.isDirectory){const C=w,b=x,H=m;u[h]=[{key:`${y.id}-glyph`,itemIndex:h,centerX:b,centerY:H,size:C,isExpanded:y.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:u}},Nt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:n,setSize:a,isSelectedForAria:c,flatIndex:i,isActive:u,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:h,onRowBlur:y,rowHeight:R,entryKindDirectory:E,entryKindFile:N,isDirOpen:m,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:F,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:b,currentPath:H,mode:D="none",selectedItems:P,onSelectionChange:V},visual:{iconOverrides:ae,showExpandIcons:X=!0,showDirectoryIcons:q=!0,showFileIcons:re=!0,useCanvasExpandIcons:ee=!1,expandIconSize:$,typeIconSize:he,fontSize:le,indentSize:ce=lt,highlightStyles:z,entryClassName:j,entryStyle:o,nameClassName:p,nameStyle:v,directoryNameClassName:_,directoryNameStyle:ne,fileNameClassName:ie,fileNameStyle:M,expandIconClassName:Z,expandIconStyle:me}})=>{const[ue,Te]=l.useState(null),[Ee,te]=l.useState(!1),O=e.children!==void 0,de=O&&m(e.absolutePath),K=e.absolutePath===b,we=e.absolutePath===H,G=!O&&P?.has(e.absolutePath),Oe=l.useCallback(Y=>I(i,Y),[I,i]),Re=O?void 0:Sr(e);l.useEffect(()=>{Te(de&&e.children?e.children:null)},[de,e.children]);const W=Ir({entry:e,isDirectory:O,isExpanded:de,isItemSelected:!!G,selectionMode:D,onSelectionChange:V,onEntryClick:C,toggleDirectory:F,onToggleDirectoryRecursive:x}),ct=Ee?z?.hoverClassName!==void 0?z.hoverClassName:L.entryHover:"",Le=(()=>{if(O){if(K)return z?.directorySelectedClassName!==void 0?z.directorySelectedClassName:L.entrySelected}else if(K||G)return z?.itemSelectedClassName!==void 0?z.itemSelectedClassName:A.twMerge(K&&L.entrySelected,G&&L.entryItemSelected);return""})(),De=A.twMerge(L.entry,ct,Le,j,e.className),Ye=A.twMerge(L.expandIcon,Z,(K||G)&&L.expandIconSelected),it=A.twMerge(L.typeIcon,(K||G)&&L.typeIconSelected),_e=A.twMerge(L.name,p,O&&L.nameDirectory,O&&_,!O&&ie,(K||G)&&L.nameSelected),Ge=Er({isDirectory:O,isExpanded:de,showExpandIcons:X,useCanvasExpandIcons:ee,expandIconSize:$}),Ve=(O?q:re)?Rr({entry:e,isDirectory:O,isExpanded:de,isSelected:K,isItemSelected:!!G,extension:Re,mimeType:e.mimeType},ae):null,Ke={...Ee?z?.hoverStyle:{},...O&&K?z?.directorySelectedStyle:{},...!O&&(K||G)?z?.itemSelectedStyle:{}},Ue=kr(e.data),Xe=he?{width:he,height:he}:void 0,Fe=le?{fontSize:typeof le=="number"?`${le}px`:le}:void 0;return f.jsxs(l.Fragment,{children:[f.jsxs("div",{className:De,style:{paddingLeft:`${Math.max(0,t*ce)}px`,transform:t<0?`translateX(${t*ce}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*ce)}px)`:void 0,height:`${R}px`,...Fe,...Ke,...o,...e.style},...Ue,"data-entry-type":O?"directory":"file","data-entry-expanded":O?String(de):void 0,"data-entry-selected":K?"true":void 0,"data-entry-item-selected":G?"true":void 0,onClick:W,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onFocus:Y=>h(i,e.absolutePath,Y.currentTarget),onBlur:Y=>y(e.absolutePath,Y.currentTarget),ref:Oe,onKeyDown:Y=>{if(Y.key==="Enter"||Y.key===" "){Y.preventDefault(),Y.repeat||W(Y);return}S(Y,i)},tabIndex:u?0:-1,role:"treeitem","aria-expanded":O?de:void 0,"aria-level":r+1,"aria-posinset":n,"aria-setsize":a,"aria-selected":D==="none"?void 0:c,"aria-current":we?"page":void 0,"aria-label":`${e.name} (${O?E:N})`,children:[(X||ee)&&f.jsx("span",{className:Ye,style:me,children:Ge}),(O?q:re)&&f.jsx("span",{className:it,style:Xe,children:Ve}),f.jsx("span",{className:_e,style:{...Fe,...v,...O?ne:M},"data-entry-type":O?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),de&&ue&&k&&f.jsx("fieldset",{children:ue.map((Y,be)=>f.jsx(Nt,{entry:Y,indentLevel:t+1,depth:r+1,positionInSet:be+1,setSize:ue.length,isSelectedForAria:!!P?.has(Y.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:h,onRowBlur:y,rowHeight:R,entryKindDirectory:E,entryKindFile:N,isDirOpen:m,parentIsLast:[...w,be===ue.length-1],expansion:{toggleDirectory:F,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:b,currentPath:H,mode:D,selectedItems:P,onSelectionChange:V},visual:{iconOverrides:ae,showExpandIcons:X,showDirectoryIcons:q,showFileIcons:re,useCanvasExpandIcons:ee,expandIconSize:$,highlightStyles:z,entryClassName:j,entryStyle:o,nameClassName:p,nameStyle:v,directoryNameClassName:_,directoryNameStyle:ne,fileNameClassName:ie,fileNameStyle:M,expandIconClassName:Z,expandIconStyle:me}},Y.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,a=r&&e.isDirOpen(e.entry.absolutePath),c=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&a===c&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.visual.expandIconClassName===t.visual.expandIconClassName&&e.visual.expandIconStyle===t.visual.expandIconStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,u)=>i===t.parentIsLast[u])});Nt.displayName="DirectoryEntryItem";const Dr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Dr(r)));return t},Wn=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:a,isPending:c,alwaysExpanded:i=!1,doubleClickAction:u="recursive"},selection:{onEntryClick:I,selectedPath:S,currentPath:h,mode:y="none",selectedItems:R,onSelectionChange:E},visual:{className:N,style:m,ariaLabel:w,ariaLabelledBy:k,lineColor:F="#A0AEC0",showTreeLines:x=!0,showExpandIcons:C=!0,showDirectoryIcons:b=!0,showFileIcons:H=!0,iconOverrides:D,expandIconSize:P,itemHeight:V=at,removeRootIndent:ae=!1,highlightStyles:X,entryClassName:q,entryStyle:re,nameClassName:ee,nameStyle:$,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:z,expandIconClassName:j,expandIconStyle:o}={},virtualScroll:p,grid:v,sort:_,locale:ne,labels:ie,ref:M})=>{const Z=pe.resolveVirtualScrollLocale(ne),me=l.useMemo(()=>Or(ne,ie),[ne,ie]),ue=Dn(xn(me)),{entryKindDirectory:Te,entryKindFile:Ee}=me,te=v!==void 0,[O,de]=l.useState(!1),K=l.useRef(null),we=l.useRef(null),G=l.useRef(null),[Oe,Re]=l.useState(0),[W,ct]=l.useState(0),[Le,De]=l.useState(0),[Ye,it]=l.useState(null),{overscanCount:_e=15,className:Ge,background:Ve,onScroll:Ke,onRangeChange:Ue,onScrollAdjust:Xe,liveRegion:Fe,initialScrollIndex:Y,initialScrollOffset:be,initialScrollAnchor:jt,callbackThrottleMs:Pt=5,contentInsets:Mt,onItemFocus:At,viewportHeightOverride:oe,scrollBarOptions:ut,behaviorOptions:Ot,preserveScrollAnchor:Lt=!1,getItemKey:Fr,testId:Dt,contentProps:dt}=p??{},Ft=l.useMemo(()=>te?{...dt,role:"rowgroup"}:{...dt,role:"tree","aria-label":k?void 0:w,"aria-labelledby":k,"aria-multiselectable":y==="multiple"?!0:void 0},[te,dt,w,k,y]),$t=l.useMemo(()=>({...Ot,enableKeyboardNavigation:!1}),[Ot]),[Je,Bt]=l.useState(typeof be=="number"?be:0),ft=l.useRef(typeof be=="number"?be:0),Ht=l.useCallback((s,d)=>{ft.current=s,Bt(s),Ke?.(s,d)},[Ke]),Wt=l.useCallback(s=>{const{renderingStartIndex:d,renderingEndIndex:g}=s;it(T=>T&&T.renderStart===d&&T.renderEnd===g?T:{renderStart:d,renderEnd:g}),Ue?.(s)},[Ue]);l.useEffect(()=>{de(!0),Ln()},[]),l.useEffect(()=>{const s=K.current,d=te?we.current:s,g=()=>{if(s){const B=s.clientWidth;ct(J=>Math.abs(J-B)>1?B:J)}if(typeof oe=="number")Re(B=>Math.abs(B-oe)>1?oe:B);else if(d){const B=d.clientHeight;Re(J=>Math.abs(J-B)>1?B:J)}};if(!(s||d))return Re(0);g();const T=new ResizeObserver(g);return s&&T.observe(s),d&&d!==s&&T.observe(d),()=>T.disconnect()},[oe,te]);const Ne=typeof oe=="number"?oe:Oe,ye=l.useCallback(s=>i||(O?r(s):!1),[O,r,i]),zt=A.twMerge(L.container,c&&L.containerPending,N),Yt=l.useMemo(()=>({...On,...m??{},...typeof oe=="number"?{height:oe,minHeight:oe}:{}}),[m,oe]),ht=l.useCallback((s,d)=>{const g=[s.absolutePath,...Dr(s)],T=d||u;if(g.every(ve=>ye(ve)))return a(g);if(g.every(ve=>!ye(ve))||T==="recursive")return n(g);if(T==="toggle")return a(g);console.warn(`[DirectoryTree] Unknown double click action: ${T}. No action taken.`)},[ye,n,a,u]),Gt=te?!1:ae,{flatItems:ke,lineItems:mt,maxIndent:Vt}=l.useMemo(()=>$n(e,ye,x,Gt,_),[e,ye,x,Gt,_]),U=l.useMemo(()=>ke.map((s,d)=>{const g=typeof V=="function"?V(s.entry,d):V;return{...s,rowHeight:Number.isFinite(g)&&g>0?g:at}}),[ke,V]),xe=l.useMemo(()=>U.map(s=>s.rowHeight),[U]),Ie=l.useMemo(()=>{const s=new Array(xe.length+1);s[0]=0;for(let d=0;d<xe.length;d++)s[d+1]=s[d]+xe[d];return s},[xe]),Kt=l.useCallback(s=>U[s]?.rowHeight??at,[U]),$r=l.useCallback(s=>U[s]?.entry.absolutePath??s,[U]),Ut=Fr??$r,je=S??null,pt=h??null,[Xt,$e]=l.useState(()=>({selectedPath:je,selectionGeneration:0,anchor:null})),yt=gr(Xt,je);yt!==Xt&&$e(s=>gr(s,je));const qe=l.useMemo(()=>Pn(ke),[ke]),Pe=l.useMemo(()=>An(qe,yt),[qe,yt]),Be=l.useRef(new Map),Ze=l.useRef(null),[Qe]=l.useState(Sn),He=l.useRef(null),[Br,Jt]=l.useState(!0),bt=l.useRef(ke);bt.current=ke;const qt=l.useRef(ye);qt.current=ye;const gt=l.useRef(t);gt.current=t;const Zt=l.useRef(qe);Zt.current=qe;const vt=l.useRef(Pe);vt.current=Pe;const Qt=l.useRef(At);Qt.current=At;const Ce=l.useCallback(s=>{const d=G.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(s,{align:"nearest"}),!0)},[]),ge=l.useCallback(s=>{const d=Be.current.get(s);if(d===void 0){He.current=s,Ce(s)||(He.current=null);return}He.current=null,Ce(s),d.focus({preventScroll:!0})},[Ce]),er=l.useCallback((s,d)=>{if(d)Be.current.set(s,d),He.current===s?(He.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&$e(g=>g.anchor===null?g:{...g,anchor:{...g.anchor,focused:!0}});else{const g=Be.current.get(s);Be.current.delete(s),g?.contains(g.ownerDocument.activeElement)&&$e(T=>T.anchor===null?T:{...T,anchor:{...T.anchor,focused:!1}})}s===vt.current&&Jt(d!==null)},[]);l.useLayoutEffect(()=>{Jt(Be.current.has(Pe))},[Pe]);const wt=l.useCallback((s,d,g)=>{const T=Ze.current===g;Ze.current=null,T||($e(B=>Mn(B,d)),Qe.landedOn(g)||Ce(s)),Qt.current?.(s)},[Ce,Qe]),et=l.useCallback(s=>Qe.mark(s.nativeEvent),[Qe]),xt=l.useCallback((s,d)=>{const{ownerDocument:g}=d;if(!g.hasFocus()&&d.contains(g.activeElement)){Ze.current=d;return}Ze.current=null,$e(T=>T.anchor!==null&&T.anchor.path===s?{...T,anchor:{...T.anchor,focused:!1}}:T)},[]),Hr=l.useCallback(()=>ge(vt.current),[ge]),St=l.useCallback((s,d)=>{const g=wr(d),T=bt.current.length;if(!Number.isInteger(s)||s<0||s>=T)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${T===0?"the tree has no rows":`expected an integer in 0..${String(T-1)}`}).`);if(g==="nearest"){Ce(s);return}G.current?.scrollToIndex(s,{align:g})},[Ce]);l.useImperativeHandle(M,()=>({scrollToIndex:St,scrollToPath:(s,d)=>{wr(d);const g=Zt.current.get(s);return g===void 0?!1:(St(g,d),!0)},getScrollAnchor:()=>G.current?.getScrollAnchor()??null}),[St]);const tr=l.useCallback((s,d)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const g=bt.current,T=g.length-1;if(T<0)return;const B=g[d],J=B?.entry.children!==void 0,ve=J&&qt.current(B.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),ge(Math.min(d+1,T));break;case"ArrowUp":s.preventDefault(),ge(Math.max(d-1,0));break;case"Home":s.preventDefault(),ge(0);break;case"End":s.preventDefault(),ge(T);break;case"ArrowRight":s.preventDefault(),J&&!ve?gt.current(B.entry.absolutePath):J&&d<T&&g[d+1].depth>B.depth&&ge(d+1);break;case"ArrowLeft":{if(s.preventDefault(),J&&ve){gt.current(B.entry.absolutePath);break}const Vr=B?.depth??0;for(let ot=d-1;ot>=0;ot--)if(g[ot].depth<Vr){ge(ot);break}break}}},[ge]),tt=l.useMemo(()=>!x||mt.length===0?{segmentsByItem:[],glyphsByItem:[]}:Hn(mt,xe,Ie,lt,x,P??hr),[mt,xe,Ie,x,P]),rt=l.useMemo(()=>!x||e.length===0?0:(Vt+2)*lt,[e.length,Vt,x]),{renderStart:rr,renderEnd:nr,lookaheadEnd:or}=l.useMemo(()=>Bn(U.length,Ne,_e,Ye,Je,Ie),[U.length,Ne,_e,Ye,Je,Ie]),Et=l.useMemo(()=>!x||rt<=0||Ne<=0||tt.segmentsByItem.length===0?null:f.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:f.jsx("div",{className:"absolute top-0 left-0",style:{width:rt,height:Ne},children:f.jsx(Lr,{segmentsByItem:tt.segmentsByItem,glyphsByItem:tt.glyphsByItem,itemHeight:xe[0]??at,width:rt,viewportHeight:Ne,scrollPosition:Je,color:F,expandGlyphColor:F,expandGlyphSize:P??hr,renderStartIndex:rr,renderEndIndex:nr,lookaheadEndIndex:or})})}),[rt,Ne,rr,nr,or,Je,tt,F,x,P,xe]),sr=l.useCallback(s=>U[s],[U]),ar=l.useRef(null);l.useLayoutEffect(()=>{const s=ar.current;if(ar.current={items:U,offsets:Ie},!Lt||!s||s.items===U)return;const d=G.current,g=d?.getScrollPosition(),T=typeof g=="number"&&g>=0?g:ft.current,B=Rn(s.items,s.offsets,T);if(!B)return;const J=kn(B,U,Ie);if(J===null||Math.abs(J-T)<1)return;const ve=d?d.scrollTo(J):J;ft.current=ve,Bt(ve)},[U,Ie,Lt]);const Se=v?.columns,Me=v?.scrollBarWidth??ut?.width??Pr,Q=l.useMemo(()=>Se?gn({measuredWidth:W,columns:Se,scrollBarWidth:Me}):null,[Se,W,Me]),nt=l.useMemo(()=>Se?bn(Se):"",[Se]),Wr=l.useMemo(()=>v?.showFooter&&Se?vn(e):[],[v?.showFooter,Se,e]),Ae=Q?.maxHScroll??0;l.useEffect(()=>{De(s=>Rt(s,Ae))},[Ae]);const lr=l.useCallback(s=>De(d=>Rt(d+s,Ae)),[Ae]),cr=l.useMemo(()=>({iconOverrides:D,showExpandIcons:C,showDirectoryIcons:b,showFileIcons:H,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:X,expandIconClassName:j,expandIconStyle:o}),[D,C,b,H,x,P,X,j,o]),ir=l.useMemo(()=>f.jsx(pe.VirtualScroll,{ref:G,itemCount:U.length,getItem:sr,getItemHeight:Kt,getItemKey:Ut,testId:Dt,contentProps:Ft,locale:Z,labels:ue,viewportSize:typeof oe=="number"?oe:void 0,overscanCount:_e,onScroll:Ht,onRangeChange:Wt,onScrollAdjust:Xe,liveRegion:Fe,className:Ge,onWheelHorizontal:te?lr:void 0,background:f.jsxs(f.Fragment,{children:[te&&Q?f.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:Q.nameWidth},"aria-hidden":"true",children:Et}):Et,Ve]}),initialScrollIndex:Y,initialScrollOffset:be,initialScrollAnchor:jt,callbackThrottleMs:Pt,contentInsets:Mt,scrollBarOptions:ut,behaviorOptions:$t,children:(s,d)=>s?te&&v&&Q?f.jsx(_r,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:d+(v.showHeader??!0?2:1),flatIndex:d,onRowFocus:wt,onRowBlur:xt,isSelectedForAria:!!R?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:ye,columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,rowClassName:v.rowClassName,selection:{onEntryClick:I,selectedPath:je,currentPath:pt,mode:y,selectedItems:R,onSelectionChange:E},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},visual:cr},s.entry.absolutePath):f.jsx(Nt,{entry:s.entry,indentLevel:s.indentLevel,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!R?.has(s.entry.absolutePath),flatIndex:d,isActive:d===Pe,registerRowRef:er,onNavigationKeyDown:tr,onRowFocus:wt,onRowBlur:xt,rowHeight:s.rowHeight,entryKindDirectory:Te,entryKindFile:Ee,isDirOpen:ye,parentIsLast:s.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},selection:{onEntryClick:I,selectedPath:je,currentPath:pt,mode:y,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:D,showExpandIcons:C,showDirectoryIcons:b,showFileIcons:H,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:X,entryClassName:q,entryStyle:re,nameClassName:ee,nameStyle:$,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:z,expandIconClassName:j,expandIconStyle:o}},s.entry.absolutePath):null}),[U.length,sr,Kt,Ut,Dt,Ft,Z,ue,Te,Ee,Pe,er,tr,wt,xt,oe,_e,Ht,Wt,Xe,Fe,Ge,te,lr,Q,Et,Ve,Y,be,jt,Pt,Mt,ut,$t,v,nt,ye,I,je,pt,y,R,E,t,ht,cr,D,C,b,H,x,P,X,q,re,ee,$,he,le,ce,z,j,o]);if(!(v&&Q))return f.jsxs("div",{ref:K,className:zt,style:Yt,onPointerDownCapture:et,onMouseDownCapture:et,children:[ke.length>0&&!Br&&f.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:Fn,onFocus:Hr}),ir]});const zr=v.showHeader??!0,Yr=v.showFooter??!1,Gr={...Yt,"--dt-hscroll":`${Le}px`};return f.jsxs("div",{ref:K,className:A.twMerge(zt,"dt-grid"),style:Gr,role:"treegrid","aria-label":k?void 0:w,"aria-labelledby":k,"aria-multiselectable":y==="multiple"?!0:void 0,"aria-rowcount":U.length+(v.showHeader??!0?1:0),onPointerDownCapture:et,onMouseDownCapture:et,children:[zr&&f.jsx("div",{role:"rowgroup",children:f.jsx(mn,{columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,scrollBarWidth:Me,className:v.headerClassName})}),f.jsx("div",{ref:we,className:"dt-grid-body",children:ir}),Ae>0&&f.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Q.nameWidth},"aria-hidden":"true"}),f.jsx(pe.ScrollBar,{horizontal:!0,contentSize:Q.numericTotal,viewportSize:Q.numericVisible,scrollPosition:Le,scrollBarWidth:Me,locale:Z,labels:ue,onScroll:s=>{const d=typeof s=="function"?s(Le):s,g=Rt(d,Ae);return De(g),g}}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Me},"aria-hidden":"true"})]}),Yr&&f.jsx("div",{role:"rowgroup",children:f.jsx(pn,{columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,scrollBarWidth:Me,allEntries:Wr,className:v.footerClassName})})]})},zn=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[a,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const w=JSON.parse(m);return new Set(w)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),i=l.useCallback(m=>{n(()=>{c(w=>{const k=new Set(w);return m(k),k})})},[]),u=l.useCallback((m,w)=>{i(k=>{for(const F of m)w(k,F)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(a)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[a,t]);const I=l.useCallback(m=>{u([m],(w,k)=>{w.has(k)?w.delete(k):w.add(k)})},[u]),S=l.useCallback(m=>{u([m],(w,k)=>{w.add(k)})},[u]),h=l.useCallback(m=>{u([m],(w,k)=>{w.delete(k)})},[u]),y=l.useCallback(m=>{u(m,(w,k)=>{w.delete(k)})},[u]),R=l.useCallback(m=>{u(m,(w,k)=>{w.add(k)})},[u]),E=l.useCallback(()=>{i(m=>{m.clear()})},[i]),N=l.useCallback(m=>a.has(m),[a]);return{expanded:a,toggle:I,expand:S,collapse:h,collapseMultiple:y,expandMultiple:R,collapseAll:E,isExpanded:N,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Ar;exports.DIRECTORY_TREE_LABEL_KEYS=Ct;exports.DirectoryTree=Wn;exports.directoryTreeClasses=L;exports.resolveDirectoryTreeLabels=Or;exports.useDirectoryTreeState=zn;
|
|
6
|
+
<%s key={someKey} {...props} />`,I,L,Q,L),V[L+I]=!0)}if(L=null,k!==void 0&&(r(k),L=""+k),i(h)&&(r(h.key),L=""+h.key),"key"in h){k={};for(var de in h)de!=="key"&&(k[de]=h[de])}else k=h;return L&&d(k,typeof o=="function"?o.displayName||o.name||"Unknown":o),w(o,L,k,a(),ue,T)}function R(o){_(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===J&&(o._payload.status==="fulfilled"?_(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function _(o){return typeof o=="object"&&o!==null&&o.$$typeof===g}var m=l,g=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),P=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),Y=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie=Object.prototype.hasOwnProperty,U=Array.isArray,ne=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(o){return o()}};var me,G={},pe=m.react_stack_bottom_frame.bind(m,c)(),ye=ne(n(c)),V={};qe.Fragment=b,qe.jsx=function(o,h,k){var I=1e4>Y.recentlyCreatedOwnerStacks++;return S(o,h,k,!1,I?Error("react-stack-top-frame"):pe,I?ne(n(o)):ye)},qe.jsxs=function(o,h,k){var I=1e4>Y.recentlyCreatedOwnerStacks++;return S(o,h,k,!0,I?Error("react-stack-top-frame"):pe,I?ne(n(o)):ye)}})()),qe}var Sr;function sn(){return Sr||(Sr=1,process.env.NODE_ENV==="production"?ht.exports=nn():ht.exports=on()),ht.exports}var f=sn();function an({title:e,titleId:t,...r},n){return ce.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ce.createElement("title",{id:t},e):null,ce.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const ln=ce.forwardRef(an);function cn({title:e,titleId:t,...r},n){return ce.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ce.createElement("title",{id:t},e):null,ce.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const un=ce.forwardRef(cn);function dn({title:e,titleId:t,...r},n){return ce.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ce.createElement("title",{id:t},e):null,ce.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const fn=ce.forwardRef(dn),Pt=44,hn=12,mn=8,le=14,pn=14,Nr=e=>e===void 0?void 0:{fontSize:typeof e=="number"?`${e}px`:e},oe=e=>({width:e,height:e}),A={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:O.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:O.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:O.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:O.twMerge("directory-tree-expand-icon flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:O.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:O.twMerge("directory-tree-type-icon flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:O.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:O.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:O.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},Ft=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},yn=/^[a-z][a-z\d+.-]*:\/\//i,xr=e=>Ft(yn.test(e)?e.split(/[?#]/,1)[0]:e),Pr=e=>Ft(e.name)||xr(e.relativePath)||xr(e.absolutePath),jr=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:a})=>{const c=a?{width:a,height:a}:void 0,i=a?"":"h-4 w-4";return!(r&&e)||n?f.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?f.jsx(ln,{className:i,style:c}):f.jsx(un,{className:i,style:c})},Lt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(a=>Lt(a,t)).filter(Boolean);return n.length?n:null}const r=e.type;if(r&&r.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},bn={markdown:e=>f.jsx(ae.FileMd,{className:"text-sky-500 dark:text-sky-400",style:oe(e)}),pdf:e=>f.jsx(ae.FilePdf,{className:"text-red-500 dark:text-red-400",style:oe(e)}),spreadsheet:e=>f.jsx(ae.FileXls,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),csv:e=>f.jsx(ae.FileCsv,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),document:e=>f.jsx(ae.FileDoc,{className:"text-blue-600 dark:text-blue-400",style:oe(e)}),presentation:e=>f.jsx(ae.FilePpt,{className:"text-orange-500 dark:text-orange-400",style:oe(e)}),image:e=>f.jsx(ae.FileImage,{className:"text-teal-500 dark:text-teal-400",style:oe(e)}),audio:e=>f.jsx(ae.FileAudio,{className:"text-pink-500 dark:text-pink-400",style:oe(e)}),video:e=>f.jsx(ae.FileVideo,{className:"text-violet-500 dark:text-violet-400",style:oe(e)}),archive:e=>f.jsx(ae.FileZip,{className:"text-amber-500 dark:text-amber-400",style:oe(e)}),code:e=>f.jsx(ae.FileCode,{className:"text-purple-500 dark:text-purple-400",style:oe(e)}),text:e=>f.jsx(ae.FileText,{className:"text-gray-500 dark:text-gray-400",style:oe(e)})},gn={markdown:["md","markdown","mdx"],pdf:["pdf"],spreadsheet:["xls","xlsx","xlsm","xlsb","ods"],csv:["csv","tsv"],document:["doc","docx","rtf","odt"],presentation:["ppt","pptx","odp"],image:["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"],audio:["mp3","wav","ogg","m4a","flac","aac","wma"],video:["mp4","webm","mov","avi","mkv","wmv","flv"],archive:["zip","tar","gz","7z","rar","tgz","bz2"],code:["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"],text:["txt","log"]},vn=new Map(Object.entries(gn).flatMap(([e,t])=>t.map(r=>[r,e]))),wn=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),Sn=e=>(e??"").split(";",1)[0].trim().toLowerCase(),xn=e=>{if(e==="text/markdown"||e==="text/x-markdown")return"markdown";if(e==="application/pdf")return"pdf";if(e.includes("excel")||e.includes("spreadsheet"))return"spreadsheet";if(e==="text/csv"||e==="text/tab-separated-values")return"csv";if(e.includes("word")||e.includes("google-apps.document")||e==="application/rtf")return"document";if(e.includes("powerpoint")||e.includes("presentation"))return"presentation";if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e.includes("zip")||e.includes("tar")||e.includes("compressed")||e.includes("archive"))return"archive";if(e==="application/json"||e.includes("javascript")||e.includes("typescript")||e.includes("xml")||e.startsWith("text/html")||e.startsWith("text/css")||e.includes("x-python")||e.includes("x-sh")||e.includes("x-go")||e.includes("x-rust"))return"code";if(e.startsWith("text/"))return"text"},En=(e,t,r,n)=>{const a=Sn(e),c=xn(a),i=vn.get((t||(r?Ft(r):"")).toLowerCase()),v=(wn.has(a)?[i,c]:[c,i]).find(w=>w!==void 0);return v===void 0?f.jsx(ae.FileIcon,{className:"text-gray-400 dark:text-gray-400",style:oe(n)}):bn[v](n)},Lr=(e,t,r)=>{const{entry:n,isDirectory:a,isExpanded:c,extension:i,mimeType:d}=e;let v;const w=d||n.mimeType;return n.icon!==void 0?v=n.icon:a?v=c&&t?.directoryExpanded||t?.directory||f.jsx(fn,{style:oe(r)}):i&&t?.fileByExtension?.[i]?v=t.fileByExtension[i]:v=t?.file||En(w,i,n.name,r),Lt(typeof v=="function"?v(e):v,n.absolutePath)},Rn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Or=e=>{if(!e)return;const t=Object.entries(e).filter(([,r])=>r!=null);if(t.length!==0)return Object.fromEntries(t.map(([r,n])=>[`data-${Rn(r)}`,String(n)]))},In=500,Mr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:a,onSelectionChange:c,onEntryClick:i,toggleDirectory:d,onToggleDirectoryRecursive:v})=>{const w=l.useRef(null);return l.useEffect(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),l.useCallback(S=>{S.stopPropagation(),a!=="none"&&!t&&c&&c(e,!n);let R=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{R=!0}}),!(!t||R)&&(w.current?(window.clearTimeout(w.current),w.current=null,v(e)):w.current=window.setTimeout(()=>{d(e.absolutePath),w.current=null},In))},[t,e,r,v,d,i,a,c,n])},Ar=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Er=(e,t)=>e.children!==void 0&&t(e.absolutePath),Dr=(e,t)=>({width:e,gridTemplateColumns:t}),Fr=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:a,flatIndex:c,onRowFocus:i,onRowBlur:d,isSelectedForAria:v,rowHeight:w,isDirOpen:S,columns:R,numericTemplate:_,numericTotal:m,nameWidth:g,rowClassName:p,selection:{onEntryClick:b,selectedPath:x,currentPath:$,mode:N="none",selectedItems:P,onSelectionChange:y},expansion:{toggleDirectory:F,onToggleDirectoryRecursive:D},visual:{iconOverrides:j,showExpandIcons:J=!0,showDirectoryIcons:Z=!0,showFileIcons:H=!0,useCanvasExpandIcons:Y=!1,expandIconSize:ie,typeIconSize:U,fontSize:ne,indentSize:me,highlightStyles:G,expandIconClassName:pe,expandIconStyle:ye}})=>{const[V,o]=l.useState(!1),h=e.children!==void 0,k=h&&S(e.absolutePath),I=e.absolutePath===x,ue=e.absolutePath===$,T=!h&&!!P?.has(e.absolutePath),L=h?void 0:Pr(e),Q=Mr({entry:e,isDirectory:h,isExpanded:k,isItemSelected:T,selectionMode:N,onSelectionChange:y,onEntryClick:b,toggleDirectory:F,onToggleDirectoryRecursive:D}),de=V?G?.hoverClassName!==void 0?G.hoverClassName:A.entryHover:"",xe=(()=>{if(h){if(I)return G?.directorySelectedClassName!==void 0?G.directorySelectedClassName:A.entrySelected}else if(I||T)return G?.itemSelectedClassName!==void 0?G.itemSelectedClassName:O.twMerge(I&&A.entrySelected,T&&A.entryItemSelected);return""})(),be=typeof p=="function"?p(e):p,Le=O.twMerge("dt-grid-row cursor-pointer select-none",de,xe,be,e.className),Ee=O.twMerge(A.expandIcon,pe,(I||T)&&A.expandIconSelected),Te=O.twMerge(A.typeIcon,(I||T)&&A.typeIconSelected),M=O.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",h&&A.nameDirectory,(I||T)&&A.nameSelected),z=jr({isDirectory:h,isExpanded:k,showExpandIcons:J,useCanvasExpandIcons:Y,expandIconSize:ie}),B=(h?Z:H)?Lr({entry:e,isDirectory:h,isExpanded:k,isSelected:I,isItemSelected:T,extension:L,mimeType:e.mimeType},j,U):null,_e={indentLevel:t,isDirectory:h,isExpanded:k},[te,...Re]=R,Oe=te?.render?te.render(e,_e):e.label??e.name,ge={...V?G?.hoverStyle:{},...h&&I?G?.directorySelectedStyle:{},...!h&&(I||T)?G?.itemSelectedStyle:{}};return f.jsxs("div",{className:Le,style:{height:w,...ge,...e.style},role:"row","aria-expanded":h?k:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":a,"aria-selected":N==="none"?void 0:v,"aria-current":ue?"page":void 0,...Or(e.data),"data-entry-type":h?"directory":"file","data-entry-expanded":h?String(k):void 0,"data-entry-selected":I?"true":void 0,"data-entry-item-selected":T?"true":void 0,onClick:Q,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:X=>i(c,e.absolutePath,X.currentTarget),onBlur:X=>d(e.absolutePath,X.currentTarget),onKeyDown:X=>{if(X.key==="Enter"){if(X.repeat){X.preventDefault();return}Q(X)}},tabIndex:0,children:[f.jsxs("div",{className:O.twMerge("dt-grid-name-cell",te?.className),role:"gridcell",style:{width:g,paddingLeft:Math.max(0,t*me)},children:[(J||Y)&&f.jsx("span",{className:Ee,style:{width:le,height:le,...ye},children:z}),(h?Z:H)&&f.jsx("span",{className:Te,style:{width:U,height:U},children:B}),f.jsx("span",{className:M,style:Nr(ne),children:Oe})]}),Re.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:Dr(m,_),children:Re.map(X=>f.jsx("div",{className:O.twMerge("dt-grid-cell",Ar(X.align),X.className),role:"gridcell",children:X.render?X.render(e,_e):null},X.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=Er(e.entry,e.isDirOpen),n=Er(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.flatIndex===t.flatIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&r===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Fr.displayName="DirectoryTreeGridRow";const $r=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:a,scrollBarWidth:c,className:i,nameContent:d,renderCell:v})=>{const[,...w]=t,S=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",R=e==="header"?"dt-grid-header":"dt-grid-footer",_=e==="header"?"columnheader":"gridcell";return f.jsxs("div",{className:O.twMerge(R,"text-gray-600 dark:text-gray-300",i),role:"row",children:[f.jsx("div",{className:O.twMerge(S,"px-1",t[0]?.className),role:_,style:{width:a},children:d}),w.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:Dr(n,r),children:w.map(m=>f.jsx("div",{className:O.twMerge("dt-grid-cell",Ar(m.align),m.className),role:_,children:v(m)},m.key))})}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},kn=({columns:e,className:t,...r})=>f.jsx($r,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),Rr=(e,t)=>typeof e=="function"?e(t):e??null,Cn=({columns:e,allEntries:t,className:r,...n})=>f.jsx($r,{kind:"footer",columns:e,className:r,nameContent:Rr(e[0]?.footer,t),renderCell:a=>Rr(a.footer,t),...n}),Tn=240,zr=96,Br=12,Ot=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},_n=e=>e.slice(1).map(t=>`${Ot(t,zr)}px`).join(" "),Nn=({measuredWidth:e,columns:t,scrollBarWidth:r=Br})=>{const n=Ot(t[0],Tn),a=t.slice(1).reduce((v,w)=>v+Ot(w,zr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),d=Math.max(0,a-i);return{nameWidth:n,numericTotal:a,numericVisible:i,maxHScroll:d}},jt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Pn=e=>{const t=[],r=n=>{for(const a of n)t.push(a),a.children&&a.children.length>0&&r(a.children)};return r(e),t},Hr=["entryKindDirectory","entryKindFile"],Mt=[...he.VIRTUAL_SCROLL_LABEL_KEYS,...Hr],At=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Wr=Object.freeze({en:Object.freeze({...he.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...At.en}),ja:Object.freeze({...he.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...At.ja})}),Ir=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,jn=e=>{const t={};let r=!1;for(const n of he.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,n)?e[n]:void 0;a!==void 0&&(t[n]=a,r=!0)}return r?t:void 0},Yr=(e,t)=>{const r=he.resolveVirtualScrollLocale(e);if(t===void 0)return Wr[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${Ir(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const i of Object.keys(t))if(!Mt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${Mt.join(", ")}`);const c={...he.resolveVirtualScrollLabels(r,jn(t)),...At[r]};for(const i of Hr){const d=Object.hasOwn(t,i)?t[i]:void 0;if(d!==void 0){if(typeof d!="string"||d.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${Ir(d)}`);c[i]=d}}return Object.freeze(c)},Ln=e=>{const t={};for(const r of he.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},On=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Ze=e=>typeof e=="string"?JSON.stringify(e):String(e),Dt=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t)||t<=0)throw new RangeError(`[directory-tree] visual.${e} must be a finite number greater than 0 (px); got ${Ze(t)}.`);return t},Mn=e=>{if(typeof e=="string"&&e.trim()!==""||typeof e=="number"&&Number.isFinite(e)&&e>0)return e;throw new RangeError(`[directory-tree] visual.fontSize must be a finite number greater than 0 (px) or a CSS font size that is not blank; got ${Ze(e)}.`)},An=({indentSize:e,typeIconSize:t,fontSize:r})=>({indentSize:e===void 0?hn:Dt("indentSize",e),typeIconSize:t===void 0?pn:Dt("typeIconSize",t),fontSize:r===void 0?void 0:Mn(r)}),Dn=({indentSize:e,removeRootIndent:t,hasExpandBox:r})=>t?Math.max(0,e-(r?le:0)):0,Fn=(e,t,r)=>{if(typeof e!="function")return Dt("itemHeight",e);const n=e(t,r);if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new RangeError(`[directory-tree] visual.itemHeight returned ${Ze(n)} for ${JSON.stringify(t.absolutePath)} (row ${r}); it must return a finite number greater than 0 (px).`);return n},$n=(e,t,r)=>{const n=t===void 0?mn:t;if(typeof n!="number"||!Number.isFinite(n)||n<=0||n>le)throw new RangeError(`[directory-tree] visual.expandIconSize must be a finite number greater than 0 and at most ${le} (the expand box, px) while tree lines are drawn; got ${Ze(n)}.`);const{indentSize:a,typeIconSize:c}=e,i=n/2,d=le+c-n/2;if(a<i||a>d)throw new RangeError(`[directory-tree] visual.indentSize ${Ze(a)} does not fit the tree lines: with typeIconSize ${c} and an expand glyph of ${n} px it must be from ${i} (half the glyph) to ${d} (the ${le} px expand box + typeIconSize − half the glyph).`);return{indentSize:a,typeIconSize:c,glyphSize:n,originX:r}},zn=({indentSize:e,typeIconSize:t,glyphSize:r})=>Math.min(Math.max(le+t/2-e,r/2),le-r/2),Bn=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},Hn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=Bn(t,r),a=e[n];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[n]}:null},Wn=(e,t,r)=>{if(t.length===0||r.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,r[n]+e.offsetInViewport);return null},Yn=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Gn=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Vn=(e,t,r,n)=>{const a=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(e.width!==a||e.height!==c)&&(e.width=a,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},Kn=(e,t,r)=>{e.lineWidth=r,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Un=(e,t)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!r)return null;let n=r[1];n.length===3&&(n=n.split("").map(d=>d+d).join(""));const a=Number.parseInt(n.slice(0,2),16),c=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgba(${a}, ${c}, ${i}, ${t})`},Xn=(e,t,r,n)=>{if(t.length===0)return;const a=Un(r,.14),c=e.strokeStyle,i=e.fillStyle,d=e.lineWidth,v=e.lineCap,w=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const S of t){const R=n??S.size,_=Math.max(0,R/2),m=Math.max(1,Math.round(R*.08)),g=Math.max(1,Math.round(R*.14)),p=Math.max(0,_-m*.8),b=Math.max(0,p*.55);a&&(e.fillStyle=a,e.beginPath(),e.arc(S.centerX,S.centerY,p,0,Math.PI*2),e.fill()),e.lineWidth=m,e.beginPath(),e.arc(S.centerX,S.centerY,Math.max(0,_-m*.3),0,Math.PI*2),e.stroke(),e.lineWidth=g,e.beginPath(),e.moveTo(S.centerX-b,S.centerY),e.lineTo(S.centerX+b,S.centerY),e.stroke(),S.isExpanded||(e.beginPath(),e.moveTo(S.centerX,S.centerY-b),e.lineTo(S.centerX,S.centerY+b),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=d,e.lineCap=v,e.lineJoin=w},Gr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i="#a0aec0",strokeWidth:d=1,renderStartIndex:v,renderEndIndex:w,lookaheadEndIndex:S,devicePixelRatio:R,expandGlyphColor:_,expandGlyphSize:m})=>{const g=l.useRef(null),p=l.useRef(null),b=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:v,renderEndIndex:w,lookaheadEndIndex:S,devicePixelRatio:R,expandGlyphColor:_,expandGlyphSize:m}),x=l.useCallback(()=>{p.current=null;const N=g.current;if(!N)return;const P=N.getContext("2d");if(!P)return;const y=b.current;if(y.width<=0||y.viewportHeight<=0){P.clearRect(0,0,N.width,N.height);return}const F=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Vn(N,y.width,y.viewportHeight,F);const D=y.segmentsByItem.length,j=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),J=Math.min(D,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),Z=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const U=Math.floor(y.renderEndIndex);return Math.max(Math.min(D,U+1),j)}return Math.max(J,j)})(),H=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const U=Math.floor(y.lookaheadEndIndex),ne=Math.min(D,U+1);return Math.max(ne,Z)}return Math.max(J,Z)})(),Y=Yn(y.segmentsByItem,j,H),ie=Gn(y.glyphsByItem,j,H);P.save(),P.scale(F,F),P.clearRect(0,0,y.width,y.viewportHeight),P.translate(0,-y.scrollPosition),P.strokeStyle=y.color,Kn(P,Y,y.strokeWidth),Xn(P,ie,y.expandGlyphColor??y.color,y.expandGlyphSize),P.restore()},[]),$=l.useCallback(()=>{p.current===null&&(p.current=window.requestAnimationFrame(x))},[x]);return l.useEffect(()=>{b.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:v,renderEndIndex:w,lookaheadEndIndex:S,devicePixelRatio:R,expandGlyphColor:_,expandGlyphSize:m},$()},[e,t,r,n,a,c,i,d,v,w,S,R,_,m,$]),l.useEffect(()=>()=>{p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)},[]),f.jsx("canvas",{ref:g,className:"pointer-events-none absolute top-0 left-0 z-0"})});Gr.displayName="TreeLineCanvas";const Jn=e=>{const t=new Map;for(let r=0;r<e.length;r++){const n=e[r].entry.absolutePath;t.has(n)||t.set(n,r)}return t},kr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},qn=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),Zn=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:a}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const c=e.get(r.path);if(c!==void 0)return c}if(a!==null){const c=e.get(a);if(c!==void 0)return c}return 0},Qn={msOverflowStyle:"none",scrollbarWidth:"none"},eo=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},to=e=>{const t=l.useRef(null),r=t.current;return r!==null&&he.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},Cr=new Set(["top","bottom","center","nearest"]),Tr=e=>{const t=e?.align;if(t===void 0)return"top";if(!Cr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...Cr].join(", ")}.`);return t},ro={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},no=(e,t,r,n,a)=>{const c=[],i=[];let d=0;const v=(w,S,R)=>{const _=a?[...w].sort(a):w;for(let m=0;m<_.length;m++){const g=_[m],p=m===_.length-1,b=[...R,p],x=g.children!==void 0,$=x&&t(g.absolutePath,g.relativePath);let N=S,P=b,y=R;n&&(N=S-1,P=b.slice(1),y=R.slice(1)),c.push({entry:g,indentLevel:N,depth:S,positionInSet:m+1,setSize:_.length,parentIsLast:P}),r&&(N>d&&(d=N),i.push({id:g.absolutePath,name:g.name,absolutePath:g.absolutePath,indentLevel:N,isLastChild:p,isDirectory:x,isExpanded:$,ancestorIsLast:[...y],hideLines:n&&S===0})),x&&$&&g.children&&v(g.children,S+1,b)}};return v(e,0,[]),{flatItems:c,lineItems:i,maxIndent:d}},_r=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},oo=(e,t,r,n,a,c)=>{const i=n?.renderStart??Math.max(0,_r(c,a)),d=t>0?_r(c,a+t)+r:i+r,v=e>0?Math.min(e-1,Math.max(i,d)):i,w=n?.renderEnd??v,S=e>0?Math.min(e-1,w+r):w;return{renderStart:i,renderEnd:w,lookaheadEnd:S}},so=(e,t,r,n)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const{indentSize:a,typeIconSize:c,glyphSize:i,originX:d}=n,v=Array.from({length:e.length},()=>[]),w=Array.from({length:e.length},()=>[]),S=d+zn(n),R=m=>m*a+S,_=i/2+2;for(let m=0;m<e.length;m++){const g=e[m],p=t[m]??0,b=r[m]??0,x=b+p/2,$=e[m+1],N=x+c/2,P=b+p,y=$!==void 0&&$.indentLevel===g.indentLevel+1&&N<P?{key:`${g.id}-connector-children`,x1:R($.indentLevel),y1:N,x2:R($.indentLevel),y2:P,itemIndex:m}:null;if(g.hideLines){y!==null&&(v[m]=[y]);continue}const F=[];for(let j=0;j<g.indentLevel;j++){if(g.ancestorIsLast[j]??!1)continue;let Z=!1;for(let H=m;H<e.length;H++){const Y=e[H];if(Y.indentLevel>j&&Y.ancestorIsLast.length>j&&!Y.ancestorIsLast[j]){Z=!0;break}if(H>m&&Y.indentLevel===j)break}if(Z){const H=R(j);F.push({key:`${g.id}-ancestor-${j}`,x1:H,y1:b,x2:H,y2:b+p,itemIndex:m})}}const D=R(g.indentLevel);m>0&&F.push({key:`${g.id}-connector-top`,x1:D,y1:b,x2:D,y2:g.isDirectory?x-_:x,itemIndex:m}),!g.isDirectory&&g.isLastChild&&F.push({key:`${g.id}-connector-horizontal`,x1:D,y1:x,x2:d+g.indentLevel*a+le,y2:x,itemIndex:m}),g.isLastChild||(g.isDirectory?F.push({key:`${g.id}-connector-bottom`,x1:D,y1:x+_,x2:D,y2:b+p,itemIndex:m}):F.push({key:`${g.id}-connector-bottom`,x1:D,y1:x,x2:D,y2:b+p,itemIndex:m})),y!==null&&F.push(y),v[m]=F,g.isDirectory&&(w[m]=[{key:`${g.id}-glyph`,itemIndex:m,centerX:D,centerY:x,size:i,isExpanded:g.isExpanded}])}return{segmentsByItem:v,glyphsByItem:w}},$t=l.memo(({entry:e,indentLevel:t,originX:r,depth:n,positionInSet:a,setSize:c,isSelectedForAria:i,flatIndex:d,isActive:v,registerRowRef:w,onNavigationKeyDown:S,onRowFocus:R,onRowBlur:_,rowHeight:m,entryKindDirectory:g,entryKindFile:p,isDirOpen:b,parentIsLast:x,renderChildren:$=!0,expansion:{toggleDirectory:N,onToggleDirectoryRecursive:P},selection:{onEntryClick:y,selectedPath:F,currentPath:D,mode:j="none",selectedItems:J,onSelectionChange:Z},visual:{iconOverrides:H,showExpandIcons:Y=!0,showDirectoryIcons:ie=!0,showFileIcons:U=!0,useCanvasExpandIcons:ne=!1,expandIconSize:me,typeIconSize:G,fontSize:pe,indentSize:ye,highlightStyles:V,entryClassName:o,entryStyle:h,nameClassName:k,nameStyle:I,directoryNameClassName:ue,directoryNameStyle:T,fileNameClassName:L,fileNameStyle:Q,expandIconClassName:de,expandIconStyle:xe}})=>{const[be,Le]=l.useState(null),[Ee,Te]=l.useState(!1),M=e.children!==void 0,z=M&&b(e.absolutePath),B=e.absolutePath===F,_e=e.absolutePath===D,te=!M&&J?.has(e.absolutePath),Re=l.useCallback(K=>w(d,K),[w,d]),Oe=M?void 0:Pr(e);l.useEffect(()=>{Le(z&&e.children?e.children:null)},[z,e.children]);const ge=Mr({entry:e,isDirectory:M,isExpanded:z,isItemSelected:!!te,selectionMode:j,onSelectionChange:Z,onEntryClick:y,toggleDirectory:N,onToggleDirectoryRecursive:P}),X=Ee?V?.hoverClassName!==void 0?V.hoverClassName:A.entryHover:"",He=(()=>{if(M){if(B)return V?.directorySelectedClassName!==void 0?V.directorySelectedClassName:A.entrySelected}else if(B||te)return V?.itemSelectedClassName!==void 0?V.itemSelectedClassName:O.twMerge(B&&A.entrySelected,te&&A.entryItemSelected);return""})(),Qe=O.twMerge(A.entry,X,He,o,e.className),mt=O.twMerge(A.expandIcon,de,(B||te)&&A.expandIconSelected),We=O.twMerge(A.typeIcon,(B||te)&&A.typeIconSelected),Ye=O.twMerge(A.name,k,M&&A.nameDirectory,M&&ue,!M&&L,(B||te)&&A.nameSelected),et=jr({isDirectory:M,isExpanded:z,showExpandIcons:Y&&t>=0,useCanvasExpandIcons:ne,expandIconSize:me}),pt=(M?ie:U)?Lr({entry:e,isDirectory:M,isExpanded:z,isSelected:B,isItemSelected:!!te,extension:Oe,mimeType:e.mimeType},H,G):null,Me={...Ee?V?.hoverStyle:{},...M&&B?V?.directorySelectedStyle:{},...!M&&(B||te)?V?.itemSelectedStyle:{}},tt=Or(e.data),rt={width:G,height:G},Ge=Nr(pe),Ie=r+t*ye;return f.jsxs(l.Fragment,{children:[f.jsxs("div",{className:Qe,style:{paddingLeft:`${Math.max(0,Ie)}px`,transform:Ie<0?`translateX(${Ie}px)`:void 0,width:Ie<0?`calc(100% + ${-Ie}px)`:void 0,height:`${m}px`,...Ge,...Me,...h,...e.style},...tt,"data-entry-type":M?"directory":"file","data-entry-expanded":M?String(z):void 0,"data-entry-selected":B?"true":void 0,"data-entry-item-selected":te?"true":void 0,onClick:ge,onMouseEnter:()=>Te(!0),onMouseLeave:()=>Te(!1),onFocus:K=>R(d,e.absolutePath,K.currentTarget),onBlur:K=>_(e.absolutePath,K.currentTarget),ref:Re,onKeyDown:K=>{if(K.key==="Enter"||K.key===" "){K.preventDefault(),K.repeat||ge(K);return}S(K,d)},tabIndex:v?0:-1,role:"treeitem","aria-expanded":M?z:void 0,"aria-level":n+1,"aria-posinset":a,"aria-setsize":c,"aria-selected":j==="none"?void 0:i,"aria-current":_e?"page":void 0,"aria-label":`${e.name} (${M?g:p})`,children:[(Y||ne)&&f.jsx("span",{className:mt,style:{width:le,height:le,...xe},children:et}),(M?ie:U)&&f.jsx("span",{className:We,style:rt,children:pt}),f.jsx("span",{className:Ye,style:{...Ge,...I,...M?T:Q},"data-entry-type":M?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),z&&be&&$&&f.jsx("fieldset",{children:be.map((K,Ve)=>f.jsx($t,{entry:K,indentLevel:t+1,originX:r,depth:n+1,positionInSet:Ve+1,setSize:be.length,isSelectedForAria:!!J?.has(K.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:w,onNavigationKeyDown:S,onRowFocus:R,onRowBlur:_,rowHeight:m,entryKindDirectory:g,entryKindFile:p,isDirOpen:b,parentIsLast:[...x,Ve===be.length-1],expansion:{toggleDirectory:N,onToggleDirectoryRecursive:P},selection:{onEntryClick:y,selectedPath:F,currentPath:D,mode:j,selectedItems:J,onSelectionChange:Z},visual:{iconOverrides:H,showExpandIcons:Y,showDirectoryIcons:ie,showFileIcons:U,useCanvasExpandIcons:ne,expandIconSize:me,typeIconSize:G,fontSize:pe,indentSize:ye,highlightStyles:V,entryClassName:o,entryStyle:h,nameClassName:k,nameStyle:I,directoryNameClassName:ue,directoryNameStyle:T,fileNameClassName:L,fileNameStyle:Q,expandIconClassName:de,expandIconStyle:xe}},K.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,a=r&&e.isDirOpen(e.entry.absolutePath),c=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.originX===t.originX&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&a===c&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.typeIconSize===t.visual.typeIconSize&&e.visual.fontSize===t.visual.fontSize&&e.visual.indentSize===t.visual.indentSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.visual.expandIconClassName===t.visual.expandIconClassName&&e.visual.expandIconStyle===t.visual.expandIconStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,d)=>i===t.parentIsLast[d])});$t.displayName="DirectoryEntryItem";const Vr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Vr(r)));return t},ao=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:a,isPending:c,alwaysExpanded:i=!1,doubleClickAction:d="recursive"},selection:{onEntryClick:v,selectedPath:w,currentPath:S,mode:R="none",selectedItems:_,onSelectionChange:m},visual:{className:g,style:p,ariaLabel:b,ariaLabelledBy:x,lineColor:$="#A0AEC0",showTreeLines:N=!0,showExpandIcons:P=!0,showDirectoryIcons:y=!0,showFileIcons:F=!0,iconOverrides:D,expandIconSize:j,typeIconSize:J,fontSize:Z,indentSize:H,itemHeight:Y=Pt,removeRootIndent:ie=!1,highlightStyles:U,entryClassName:ne,entryStyle:me,nameClassName:G,nameStyle:pe,directoryNameClassName:ye,directoryNameStyle:V,fileNameClassName:o,fileNameStyle:h,expandIconClassName:k,expandIconStyle:I}={},virtualScroll:ue,grid:T,sort:L,locale:Q,labels:de,ref:xe})=>{const be=he.resolveVirtualScrollLocale(Q),Le=l.useMemo(()=>Yr(Q,de),[Q,de]),Ee=to(Ln(Le)),{entryKindDirectory:Te,entryKindFile:M}=Le,z=l.useMemo(()=>An({indentSize:H,typeIconSize:J,fontSize:Z}),[H,J,Z]),B=T!==void 0,[_e,te]=l.useState(!1),Re=l.useRef(null),Oe=l.useRef(null),ge=l.useRef(null),[X,He]=l.useState(0),[Qe,mt]=l.useState(0),[We,Ye]=l.useState(0),[et,pt]=l.useState(null),{overscanCount:Me=15,className:tt,background:rt,onScroll:Ge,onRangeChange:Ie,onScrollAdjust:K,liveRegion:Ve,initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Bt,callbackThrottleMs:Ht=5,contentInsets:Wt,onItemFocus:Yt,viewportHeightOverride:se,scrollBarOptions:yt,behaviorOptions:Gt,preserveScrollAnchor:Vt=!1,getItemKey:Kr,testId:Kt,contentProps:bt}=ue??{},Ut=l.useMemo(()=>B?{...bt,role:"rowgroup"}:{...bt,role:"tree","aria-label":x?void 0:b,"aria-labelledby":x,"aria-multiselectable":R==="multiple"?!0:void 0},[B,bt,b,x,R]),Xt=l.useMemo(()=>({...Gt,enableKeyboardNavigation:!1}),[Gt]),[nt,Jt]=l.useState(typeof Ae=="number"?Ae:0),gt=l.useRef(typeof Ae=="number"?Ae:0),qt=l.useCallback((s,u)=>{gt.current=s,Jt(s),Ge?.(s,u)},[Ge]),Zt=l.useCallback(s=>{const{renderingStartIndex:u,renderingEndIndex:E}=s;pt(C=>C&&C.renderStart===u&&C.renderEnd===E?C:{renderStart:u,renderEnd:E}),Ie?.(s)},[Ie]);l.useEffect(()=>{te(!0),eo()},[]),l.useEffect(()=>{const s=Re.current,u=B?Oe.current:s,E=()=>{if(s){const W=s.clientWidth;mt(ee=>Math.abs(ee-W)>1?W:ee)}if(typeof se=="number")He(W=>Math.abs(W-se)>1?se:W);else if(u){const W=u.clientHeight;He(ee=>Math.abs(ee-W)>1?W:ee)}};if(!(s||u))return He(0);E();const C=new ResizeObserver(E);return s&&C.observe(s),u&&u!==s&&C.observe(u),()=>C.disconnect()},[se,B]);const De=typeof se=="number"?se:X,ve=l.useCallback(s=>i||(_e?r(s):!1),[_e,r,i]),Qt=O.twMerge(A.container,c&&A.containerPending,g),er=l.useMemo(()=>({...Qn,...p??{},...typeof se=="number"?{height:se,minHeight:se}:{}}),[p,se]),vt=l.useCallback((s,u)=>{const E=[s.absolutePath,...Vr(s)],C=u||d;if(E.every(Se=>ve(Se)))return a(E);if(E.every(Se=>!ve(Se))||C==="recursive")return n(E);if(C==="toggle")return a(E);console.warn(`[DirectoryTree] Unknown double click action: ${C}. No action taken.`)},[ve,n,a,d]),wt=B?!1:ie,{flatItems:Ne,lineItems:St,maxIndent:tr}=l.useMemo(()=>no(e,ve,N,wt,L),[e,ve,N,wt,L]),ot=Dn({indentSize:z.indentSize,removeRootIndent:wt,hasExpandBox:P||N}),fe=l.useMemo(()=>N?$n(z,j,ot):null,[N,z,j,ot]),q=l.useMemo(()=>Ne.map((s,u)=>({...s,rowHeight:Fn(Y,s.entry,u)})),[Ne,Y]),ke=l.useMemo(()=>q.map(s=>s.rowHeight),[q]),Pe=l.useMemo(()=>{const s=new Array(ke.length+1);s[0]=0;for(let u=0;u<ke.length;u++)s[u+1]=s[u]+ke[u];return s},[ke]),rr=l.useCallback(s=>q[s]?.rowHeight??Pt,[q]),Ur=l.useCallback(s=>q[s]?.entry.absolutePath??s,[q]),nr=Kr??Ur,Fe=w??null,xt=S??null,[or,Ke]=l.useState(()=>({selectedPath:Fe,selectionGeneration:0,anchor:null})),Et=kr(or,Fe);Et!==or&&Ke(s=>kr(s,Fe));const st=l.useMemo(()=>Jn(Ne),[Ne]),$e=l.useMemo(()=>Zn(st,Et),[st,Et]),Ue=l.useRef(new Map),at=l.useRef(null),[lt]=l.useState(On),Xe=l.useRef(null),[Xr,sr]=l.useState(!0),Rt=l.useRef(Ne);Rt.current=Ne;const ar=l.useRef(ve);ar.current=ve;const It=l.useRef(t);It.current=t;const lr=l.useRef(st);lr.current=st;const kt=l.useRef($e);kt.current=$e;const ir=l.useRef(Yt);ir.current=Yt;const je=l.useCallback(s=>{const u=ge.current;return!u||u.getViewportSize()<=0?!1:(u.scrollToIndex(s,{align:"nearest"}),!0)},[]),we=l.useCallback(s=>{const u=Ue.current.get(s);if(u===void 0){Xe.current=s,je(s)||(Xe.current=null);return}Xe.current=null,je(s),u.focus({preventScroll:!0})},[je]),cr=l.useCallback((s,u)=>{if(u)Ue.current.set(s,u),Xe.current===s?(Xe.current=null,u.focus({preventScroll:!0})):u.contains(u.ownerDocument.activeElement)&&Ke(E=>E.anchor===null?E:{...E,anchor:{...E.anchor,focused:!0}});else{const E=Ue.current.get(s);Ue.current.delete(s),E?.contains(E.ownerDocument.activeElement)&&Ke(C=>C.anchor===null?C:{...C,anchor:{...C.anchor,focused:!1}})}s===kt.current&&sr(u!==null)},[]);l.useLayoutEffect(()=>{sr(Ue.current.has($e))},[$e]);const Ct=l.useCallback((s,u,E)=>{const C=at.current===E;at.current=null,C||(Ke(W=>qn(W,u)),lt.landedOn(E)||je(s)),ir.current?.(s)},[je,lt]),it=l.useCallback(s=>lt.mark(s.nativeEvent),[lt]),Tt=l.useCallback((s,u)=>{const{ownerDocument:E}=u;if(!E.hasFocus()&&u.contains(E.activeElement)){at.current=u;return}at.current=null,Ke(C=>C.anchor!==null&&C.anchor.path===s?{...C,anchor:{...C.anchor,focused:!1}}:C)},[]),Jr=l.useCallback(()=>we(kt.current),[we]),_t=l.useCallback((s,u)=>{const E=Tr(u),C=Rt.current.length;if(!Number.isInteger(s)||s<0||s>=C)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${C===0?"the tree has no rows":`expected an integer in 0..${String(C-1)}`}).`);if(E==="nearest"){je(s);return}ge.current?.scrollToIndex(s,{align:E})},[je]);l.useImperativeHandle(xe,()=>({scrollToIndex:_t,scrollToPath:(s,u)=>{Tr(u);const E=lr.current.get(s);return E===void 0?!1:(_t(E,u),!0)},getScrollAnchor:()=>ge.current?.getScrollAnchor()??null}),[_t]);const ur=l.useCallback((s,u)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const E=Rt.current,C=E.length-1;if(C<0)return;const W=E[u],ee=W?.entry.children!==void 0,Se=ee&&ar.current(W.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),we(Math.min(u+1,C));break;case"ArrowUp":s.preventDefault(),we(Math.max(u-1,0));break;case"Home":s.preventDefault(),we(0);break;case"End":s.preventDefault(),we(C);break;case"ArrowRight":s.preventDefault(),ee&&!Se?It.current(W.entry.absolutePath):ee&&u<C&&E[u+1].depth>W.depth&&we(u+1);break;case"ArrowLeft":{if(s.preventDefault(),ee&&Se){It.current(W.entry.absolutePath);break}const tn=W?.depth??0;for(let ft=u-1;ft>=0;ft--)if(E[ft].depth<tn){we(ft);break}break}}},[we]),ct=l.useMemo(()=>fe===null||St.length===0?{segmentsByItem:[],glyphsByItem:[]}:so(St,ke,Pe,fe),[St,ke,Pe,fe]),ut=l.useMemo(()=>fe===null||e.length===0?0:fe.originX+tr*fe.indentSize+le+fe.typeIconSize,[e.length,tr,fe]),{renderStart:dr,renderEnd:fr,lookaheadEnd:hr}=l.useMemo(()=>oo(q.length,De,Me,et,nt,Pe),[q.length,De,Me,et,nt,Pe]),Nt=l.useMemo(()=>fe===null||ut<=0||De<=0||ct.segmentsByItem.length===0?null:f.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:f.jsx("div",{className:"absolute top-0 left-0",style:{width:ut,height:De},children:f.jsx(Gr,{segmentsByItem:ct.segmentsByItem,glyphsByItem:ct.glyphsByItem,itemHeight:ke[0]??Pt,width:ut,viewportHeight:De,scrollPosition:nt,color:$,expandGlyphColor:$,expandGlyphSize:fe.glyphSize,renderStartIndex:dr,renderEndIndex:fr,lookaheadEndIndex:hr})})}),[ut,De,dr,fr,hr,nt,ct,$,fe,ke]),mr=l.useCallback(s=>q[s],[q]),pr=l.useRef(null);l.useLayoutEffect(()=>{const s=pr.current;if(pr.current={items:q,offsets:Pe},!Vt||!s||s.items===q)return;const u=ge.current,E=u?.getScrollPosition(),C=typeof E=="number"&&E>=0?E:gt.current,W=Hn(s.items,s.offsets,C);if(!W)return;const ee=Wn(W,q,Pe);if(ee===null||Math.abs(ee-C)<1)return;const Se=u?u.scrollTo(ee):ee;gt.current=Se,Jt(Se)},[q,Pe,Vt]);const Ce=T?.columns,ze=T?.scrollBarWidth??yt?.width??Br,re=l.useMemo(()=>Ce?Nn({measuredWidth:Qe,columns:Ce,scrollBarWidth:ze}):null,[Ce,Qe,ze]),dt=l.useMemo(()=>Ce?_n(Ce):"",[Ce]),qr=l.useMemo(()=>T?.showFooter&&Ce?Pn(e):[],[T?.showFooter,Ce,e]),Be=re?.maxHScroll??0;l.useEffect(()=>{Ye(s=>jt(s,Be))},[Be]);const yr=l.useCallback(s=>Ye(u=>jt(u+s,Be)),[Be]),br=l.useMemo(()=>({iconOverrides:D,showExpandIcons:P,showDirectoryIcons:y,showFileIcons:F,useCanvasExpandIcons:N,expandIconSize:j,typeIconSize:z.typeIconSize,fontSize:z.fontSize,indentSize:z.indentSize,highlightStyles:U,expandIconClassName:k,expandIconStyle:I}),[D,P,y,F,N,j,z,U,k,I]),gr=l.useMemo(()=>f.jsx(he.VirtualScroll,{ref:ge,itemCount:q.length,getItem:mr,getItemHeight:rr,getItemKey:nr,testId:Kt,contentProps:Ut,locale:be,labels:Ee,viewportSize:typeof se=="number"?se:void 0,overscanCount:Me,onScroll:qt,onRangeChange:Zt,onScrollAdjust:K,liveRegion:Ve,className:tt,onWheelHorizontal:B?yr:void 0,background:f.jsxs(f.Fragment,{children:[B&&re?f.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:re.nameWidth},"aria-hidden":"true",children:Nt}):Nt,rt]}),initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Bt,callbackThrottleMs:Ht,contentInsets:Wt,scrollBarOptions:yt,behaviorOptions:Xt,children:(s,u)=>s?B&&T&&re?f.jsx(Fr,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:u+(T.showHeader??!0?2:1),flatIndex:u,onRowFocus:Ct,onRowBlur:Tt,isSelectedForAria:!!_?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:ve,columns:T.columns,numericTemplate:dt,numericTotal:re.numericTotal,nameWidth:re.nameWidth,rowClassName:T.rowClassName,selection:{onEntryClick:v,selectedPath:Fe,currentPath:xt,mode:R,selectedItems:_,onSelectionChange:m},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:vt},visual:br},s.entry.absolutePath):f.jsx($t,{entry:s.entry,indentLevel:s.indentLevel,originX:ot,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!_?.has(s.entry.absolutePath),flatIndex:u,isActive:u===$e,registerRowRef:cr,onNavigationKeyDown:ur,onRowFocus:Ct,onRowBlur:Tt,rowHeight:s.rowHeight,entryKindDirectory:Te,entryKindFile:M,isDirOpen:ve,parentIsLast:s.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:vt},selection:{onEntryClick:v,selectedPath:Fe,currentPath:xt,mode:R,selectedItems:_,onSelectionChange:m},visual:{iconOverrides:D,showExpandIcons:P,showDirectoryIcons:y,showFileIcons:F,useCanvasExpandIcons:N,expandIconSize:j,typeIconSize:z.typeIconSize,fontSize:z.fontSize,indentSize:z.indentSize,highlightStyles:U,entryClassName:ne,entryStyle:me,nameClassName:G,nameStyle:pe,directoryNameClassName:ye,directoryNameStyle:V,fileNameClassName:o,fileNameStyle:h,expandIconClassName:k,expandIconStyle:I}},s.entry.absolutePath):null}),[q.length,mr,rr,nr,Kt,Ut,be,Ee,Te,M,$e,cr,ur,Ct,Tt,se,Me,qt,Zt,K,Ve,tt,B,yr,re,Nt,rt,zt,Ae,Bt,Ht,Wt,yt,Xt,T,dt,ve,v,Fe,xt,R,_,m,t,vt,br,D,P,y,F,N,j,z,ot,U,ne,me,G,pe,ye,V,o,h,k,I]);if(!(T&&re))return f.jsxs("div",{ref:Re,className:Qt,style:er,onPointerDownCapture:it,onMouseDownCapture:it,children:[Ne.length>0&&!Xr&&f.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:ro,onFocus:Jr}),gr]});const Zr=T.showHeader??!0,Qr=T.showFooter??!1,en={...er,"--dt-hscroll":`${We}px`};return f.jsxs("div",{ref:Re,className:O.twMerge(Qt,"dt-grid"),style:en,role:"treegrid","aria-label":x?void 0:b,"aria-labelledby":x,"aria-multiselectable":R==="multiple"?!0:void 0,"aria-rowcount":q.length+(T.showHeader??!0?1:0),onPointerDownCapture:it,onMouseDownCapture:it,children:[Zr&&f.jsx("div",{role:"rowgroup",children:f.jsx(kn,{columns:T.columns,numericTemplate:dt,numericTotal:re.numericTotal,nameWidth:re.nameWidth,scrollBarWidth:ze,className:T.headerClassName})}),f.jsx("div",{ref:Oe,className:"dt-grid-body",children:gr}),Be>0&&f.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:re.nameWidth},"aria-hidden":"true"}),f.jsx(he.ScrollBar,{horizontal:!0,contentSize:re.numericTotal,viewportSize:re.numericVisible,scrollPosition:We,scrollBarWidth:ze,locale:be,labels:Ee,onScroll:s=>{const u=typeof s=="function"?s(We):s,E=jt(u,Be);return Ye(E),E}}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ze},"aria-hidden":"true"})]}),Qr&&f.jsx("div",{role:"rowgroup",children:f.jsx(Cn,{columns:T.columns,numericTemplate:dt,numericTotal:re.numericTotal,nameWidth:re.nameWidth,scrollBarWidth:ze,allEntries:qr,className:T.footerClassName})})]})},lo=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[a,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const p=window.localStorage.getItem(t);if(p){const b=JSON.parse(p);return new Set(b)}}catch(p){console.error("[useDirectoryTreeState] Error reading from localStorage",p)}return e}),i=l.useCallback(p=>{n(()=>{c(b=>{const x=new Set(b);return p(x),x})})},[]),d=l.useCallback((p,b)=>{i(x=>{for(const $ of p)b(x,$)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(a)))}catch(p){console.warn(`Error setting localStorage key "${t}":`,p)}},[a,t]);const v=l.useCallback(p=>{d([p],(b,x)=>{b.has(x)?b.delete(x):b.add(x)})},[d]),w=l.useCallback(p=>{d([p],(b,x)=>{b.add(x)})},[d]),S=l.useCallback(p=>{d([p],(b,x)=>{b.delete(x)})},[d]),R=l.useCallback(p=>{d(p,(b,x)=>{b.delete(x)})},[d]),_=l.useCallback(p=>{d(p,(b,x)=>{b.add(x)})},[d]),m=l.useCallback(()=>{i(p=>{p.clear()})},[i]),g=l.useCallback(p=>a.has(p),[a]);return{expanded:a,toggle:v,expand:w,collapse:S,collapseMultiple:R,expandMultiple:_,collapseAll:m,isExpanded:g,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Wr;exports.DIRECTORY_TREE_LABEL_KEYS=Mt;exports.DirectoryTree=ao;exports.directoryTreeClasses=A;exports.resolveDirectoryTreeLabels=Yr;exports.useDirectoryTreeState=lo;
|