@aiquants/directory-tree 4.5.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -41
- package/dist/DirectoryTreeGrid.d.ts +2 -2
- package/dist/hostStyle.d.ts +59 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +956 -886
- package/dist/styles/directory-tree.standalone.css +1 -1
- package/dist/types.d.ts +9 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ This package requires the following peer dependencies:
|
|
|
33
33
|
npm install react react-dom @aiquants/virtualscroll
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
`@aiquants/virtualscroll` must be 3.
|
|
36
|
+
`@aiquants/virtualscroll` must be 3.22.0 or later: it supplies the `locale` / `labels` chrome catalog, the pill-aware `scrollToIndex(index, { align: "nearest" })` that reveals focused rows, and the edge pills that hide while the pane rests at their edge (so the first and last rows are never left under a pill).
|
|
37
37
|
|
|
38
38
|
## Quick Start
|
|
39
39
|
|
|
@@ -41,24 +41,26 @@ npm install react react-dom @aiquants/virtualscroll
|
|
|
41
41
|
import React from 'react';
|
|
42
42
|
import { DirectoryTree, useDirectoryTreeState } from '@aiquants/directory-tree';
|
|
43
43
|
import { useTheme } from './hooks/useTheme'; // Your theme hook
|
|
44
|
-
import type { DirectoryEntry } from '@aiquants/directory-tree';
|
|
44
|
+
import type { DirectoryEntry, DirectoryTreeClickEvent } from '@aiquants/directory-tree';
|
|
45
45
|
|
|
46
46
|
const sampleData: DirectoryEntry[] = [
|
|
47
47
|
{
|
|
48
48
|
name: 'src',
|
|
49
|
+
type: 'directory',
|
|
49
50
|
absolutePath: '/src',
|
|
50
51
|
relativePath: 'src',
|
|
51
52
|
children: [
|
|
52
53
|
{
|
|
53
54
|
name: 'components',
|
|
55
|
+
type: 'directory',
|
|
54
56
|
absolutePath: '/src/components',
|
|
55
57
|
relativePath: 'src/components',
|
|
56
58
|
children: [
|
|
57
59
|
{
|
|
58
60
|
name: 'App.tsx',
|
|
61
|
+
type: 'file',
|
|
59
62
|
absolutePath: '/src/components/App.tsx',
|
|
60
|
-
relativePath: 'src/components/App.tsx'
|
|
61
|
-
children: null
|
|
63
|
+
relativePath: 'src/components/App.tsx'
|
|
62
64
|
}
|
|
63
65
|
]
|
|
64
66
|
}
|
|
@@ -170,17 +172,17 @@ The main component for rendering the directory tree.
|
|
|
170
172
|
| `indentSize` | `number` | No | `12` | Indentation per depth level in px; with tree lines it must lie in the range [Sizing](#sizing) gives |
|
|
171
173
|
| `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
174
|
| `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. |
|
|
173
|
-
| `highlightStyles` | `HighlightStyles` | No | - | Highlight styles
|
|
174
|
-
| `entryClassName` | `string` | No | - | Additional CSS classes for each
|
|
175
|
-
| `entryStyle` | `
|
|
175
|
+
| `highlightStyles` | `HighlightStyles` | No | - | Highlight styles for hover and selection states: class names (merged as they are, not checked) and inline row styles (`DirectoryTreeRowStyle`: paint and text properties only; any other property throws a `RangeError` at render). See [Row and expand-icon styles](#row-and-expand-icon-styles) |
|
|
176
|
+
| `entryClassName` | `string` | No | - | Additional CSS classes for each list row, merged as they are and not checked: keep box utilities (padding, margin, size, border width) out of it, see [Row and expand-icon styles](#row-and-expand-icon-styles) |
|
|
177
|
+
| `entryStyle` | `DirectoryTreeRowStyle` | No | - | Additional inline styles for each list row: paint and text properties only (`ROW_STYLE_PROPERTIES`); any other property throws a `RangeError` at render. Grid rows do not read it. See [Row and expand-icon styles](#row-and-expand-icon-styles) |
|
|
176
178
|
| `nameClassName` | `string` | No | - | Additional CSS classes for the name label |
|
|
177
179
|
| `nameStyle` | `React.CSSProperties` | No | - | Additional inline styles for the name label |
|
|
178
180
|
| `directoryNameClassName` | `string` | No | - | Additional CSS classes specifically for directory names |
|
|
179
181
|
| `directoryNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for directory names |
|
|
180
182
|
| `fileNameClassName` | `string` | No | - | Additional CSS classes specifically for file names |
|
|
181
183
|
| `fileNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for file names |
|
|
182
|
-
| `expandIconClassName` | `string` | No | - | Additional CSS classes for the expand glyph (the chevron drawn in the row when `showTreeLines` is `false`), merged like `nameClassName`: the selected-row colour class still follows it, and a colour class replaces only the light default, so the built-in `dark:text-gray-400` stays unless the class carries a `dark:` colour too |
|
|
183
|
-
| `expandIconStyle` | `
|
|
184
|
+
| `expandIconClassName` | `string` | No | - | Additional CSS classes for the expand glyph (the chevron drawn in the row when `showTreeLines` is `false`), merged like `nameClassName`: the selected-row colour class still follows it, and a colour class replaces only the light default, so the built-in `dark:text-gray-400` stays unless the class carries a `dark:` colour too. Not checked: keep box utilities out of it |
|
|
185
|
+
| `expandIconStyle` | `DirectoryTreeExpandIconStyle` | No | - | Inline styles for the expand glyph, applied like `nameStyle` (they win over every class, the selected-row colour included): `color` and `opacity` only (`EXPAND_ICON_STYLE_PROPERTIES`); any other property throws a `RangeError` at render, because the 14 px expand box is the tree's. The glyph is drawn in `currentColor`, so `{ color: "var(--your-token)" }` follows your colour tokens independently of the `dark` class. The canvas glyph drawn with the tree lines takes `lineColor`. See [Row and expand-icon styles](#row-and-expand-icon-styles) |
|
|
184
186
|
|
|
185
187
|
### Virtual Scroll Options
|
|
186
188
|
|
|
@@ -347,9 +349,16 @@ A hook for managing directory tree state with localStorage persistence.
|
|
|
347
349
|
```typescript
|
|
348
350
|
type DirectoryEntry = {
|
|
349
351
|
name: string;
|
|
352
|
+
label?: ReactNode; // rendered instead of `name`
|
|
353
|
+
type: "file" | "directory";
|
|
350
354
|
absolutePath: string;
|
|
351
355
|
relativePath: string;
|
|
352
|
-
|
|
356
|
+
mimeType?: string;
|
|
357
|
+
children?: DirectoryEntry[]; // directories only
|
|
358
|
+
icon?: DirectoryTreeIconRenderer;
|
|
359
|
+
className?: string; // merged into the row's classes, not checked
|
|
360
|
+
style?: DirectoryTreeRowStyle; // paint and text properties only
|
|
361
|
+
data?: Record<string, string | number | boolean>; // extra data-* attributes on the row
|
|
353
362
|
};
|
|
354
363
|
```
|
|
355
364
|
|
|
@@ -411,9 +420,9 @@ You can customize the appearance by passing custom classes or inline styles for
|
|
|
411
420
|
className: "custom-directory-tree",
|
|
412
421
|
style: { height: '400px' },
|
|
413
422
|
|
|
414
|
-
// Style the entry rows (
|
|
415
|
-
entryClassName: "rounded-md
|
|
416
|
-
entryStyle: {
|
|
423
|
+
// Style the entry rows: paint and text only (the row's box is the tree's)
|
|
424
|
+
entryClassName: "rounded-md hover:bg-slate-100/50",
|
|
425
|
+
entryStyle: { letterSpacing: "0.01em", textUnderlineOffset: "2px" },
|
|
417
426
|
|
|
418
427
|
// Style the label text
|
|
419
428
|
nameClassName: "text-sm font-medium",
|
|
@@ -458,21 +467,66 @@ Alternatively, you can dynamically configure specific highlight styles for hover
|
|
|
458
467
|
highlightStyles: {
|
|
459
468
|
// Custom hover style
|
|
460
469
|
hoverClassName: "bg-amber-100 dark:bg-amber-900/20",
|
|
461
|
-
hoverStyle: {
|
|
470
|
+
hoverStyle: { boxShadow: "inset -2px 0 0 orange" },
|
|
462
471
|
|
|
463
472
|
// Custom directory selection style
|
|
464
473
|
directorySelectedClassName: "bg-emerald-100 dark:bg-emerald-900/20 font-bold",
|
|
465
|
-
directorySelectedStyle: {
|
|
474
|
+
directorySelectedStyle: { boxShadow: "inset 3px 0 0 green" },
|
|
466
475
|
|
|
467
476
|
// Custom item (file) selection style
|
|
468
477
|
itemSelectedClassName: "bg-indigo-100 dark:bg-indigo-900/20 text-indigo-800",
|
|
469
|
-
itemSelectedStyle: {
|
|
478
|
+
itemSelectedStyle: { boxShadow: "inset 3px 0 0 indigo" },
|
|
470
479
|
}
|
|
471
480
|
}}
|
|
472
481
|
// ... other props
|
|
473
482
|
/>
|
|
474
483
|
```
|
|
475
484
|
|
|
485
|
+
### Row and expand-icon styles
|
|
486
|
+
|
|
487
|
+
The tree owns the box of every row and of its expand glyph: the row's height comes from `itemHeight`, its indent
|
|
488
|
+
from `indentSize`, its icon box from `typeIconSize` (next to the 14 px expand box) and its text size from `fontSize`,
|
|
489
|
+
and the tree lines are drawn on a canvas from the same values. The inline styles you lay over these boxes therefore
|
|
490
|
+
accept only properties that can neither move nor resize them:
|
|
491
|
+
|
|
492
|
+
| Option | Type | Accepts |
|
|
493
|
+
| --- | --- | --- |
|
|
494
|
+
| `entryStyle`, `highlightStyles.hoverStyle` / `directorySelectedStyle` / `itemSelectedStyle`, `DirectoryEntry.style` | `DirectoryTreeRowStyle` | Paint and text properties (`ROW_STYLE_PROPERTIES`): colour, background, opacity, shadows, filters and blend modes, border colour and radius, outline, accent and caret colour, cursor; font family, size, style, weight, variant, feature and variation settings, kerning, letter spacing, line height, text decoration and underline offset, text transform |
|
|
495
|
+
| `expandIconStyle` | `DirectoryTreeExpandIconStyle` | `color` and `opacity` (`EXPAND_ICON_STYLE_PROPERTIES`); the glyph is drawn in `currentColor` |
|
|
496
|
+
|
|
497
|
+
Both lists and both types are exported. Any other property (a size, padding including vertical padding, margin,
|
|
498
|
+
border width or style, inset and position, a transform, display and flex / grid layout, direction and writing mode,
|
|
499
|
+
box sizing, overflow, white space and wrapping, transitions and animations, `z-index`, pointer events, touch action,
|
|
500
|
+
visibility, containment, a custom property) is a type error, and because a JavaScript host or a variable typed as the
|
|
501
|
+
whole `React.CSSProperties` gets past the type, the tree also checks at render: such a property throws a `RangeError`
|
|
502
|
+
that names the option and the property, for example `visual.entryStyle.height`,
|
|
503
|
+
`visual.highlightStyles.hoverStyle.transform`, `entry.style.marginLeft of "/docs/a.md"` or
|
|
504
|
+
`visual.expandIconStyle.width`. The tree-level styles are checked once per change of the option (in list and grid
|
|
505
|
+
mode alike), an entry's `style` whenever its row renders. A property outside the lists whose value is `undefined` sets
|
|
506
|
+
nothing and is ignored; any other value, `null`, `""` and `0` included, is refused.
|
|
507
|
+
|
|
508
|
+
Only the listed names pass: a longhand of a listed shorthand that is not listed itself (`borderTopColor`,
|
|
509
|
+
`fontVariantNumeric`, `backgroundPositionX`) is refused like any other property. A style that is neither `undefined`
|
|
510
|
+
nor an object (`null`, a string, a number) throws a `RangeError` saying that it must be an object of CSS properties or
|
|
511
|
+
undefined, for example `visual.entryStyle must be an object of CSS properties or undefined, got string.`
|
|
512
|
+
|
|
513
|
+
The row styles are laid over each other in a fixed order, the later winning: on a list row the highlight styles
|
|
514
|
+
(`hoverStyle`, then the selected style that applies), then `visual.entryStyle`, then `entry.style`; on a grid row the
|
|
515
|
+
highlight styles, then `entry.style`. The tree writes its own box properties after all of them (the row height, and on
|
|
516
|
+
a list row the indent and the `removeRootIndent` shift), as it writes the 14 px expand box's size after
|
|
517
|
+
`expandIconStyle`.
|
|
518
|
+
|
|
519
|
+
To change a box, use the sizing options instead: `itemHeight` (row height), `indentSize` (indent per level),
|
|
520
|
+
`typeIconSize` (icon box) and `fontSize` (label text); see [Sizing](#sizing). Draw a border as a shadow or an outline
|
|
521
|
+
(`boxShadow: "inset 3px 0 0 green"`), which takes no room.
|
|
522
|
+
|
|
523
|
+
Class names are not checked: `entryClassName`, `entry.className`, `expandIconClassName`, the highlight class names and
|
|
524
|
+
your own CSS on `.directory-tree-entry` reach the row as they are, so a box utility there (`py-1`, `px-2`, `m-1`, `h-8`,
|
|
525
|
+
`w-6`, `border-2`) breaks the tree lines in the same way. Keep them to paint and text.
|
|
526
|
+
|
|
527
|
+
The row itself has no vertical padding: it is a box of exactly `itemHeight` with its content centred, so what you put
|
|
528
|
+
in it (the label, a button rendered through `label`) can use the row's whole height.
|
|
529
|
+
|
|
476
530
|
## Advanced Usage
|
|
477
531
|
|
|
478
532
|
### Row Height (fixed & variable)
|
|
@@ -514,7 +568,7 @@ Three settings size the parts of a row in list rows and grid rows alike; omitted
|
|
|
514
568
|
| --- | --- | --- |
|
|
515
569
|
| `indentSize` | `12` | The indentation per depth level: a row at depth *d* is padded by *d* × `indentSize` (in grid mode, its name cell). |
|
|
516
570
|
| `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` | body step (13 px) | The labels' font size: a number in px or any CSS font size (`'0.875rem'`). Omitted, list rows draw their labels at the body text step (13 px on a 20 px line, see [Text size](#text-size)) and grid rows keep the font size they inherit. A given value wins over the step as an inline style,
|
|
571
|
+
| `fontSize` | body step (13 px) | The labels' font size: a number in px or any CSS font size (`'0.875rem'`). Omitted, list rows draw their labels at the body text step (13 px on a 20 px line, see [Text size](#text-size)) and grid rows keep the font size they inherit. A given value wins over the step as an inline style, and the line becomes the larger of the step's line and 1.5 × the given size (WCAG 1.4.8). Rows keep `itemHeight`. |
|
|
518
572
|
|
|
519
573
|
From its indentation, every row lays out the 14 px expand box (the chevron, or the tree lines'
|
|
520
574
|
glyph), the type icon box, then the label. The tree lines follow these sizes at any row height,
|
|
@@ -561,9 +615,12 @@ setting even when the host binds nothing:
|
|
|
561
615
|
| `--dt-line-height-body` | `1.25rem` (20 px) | The list row (`line-height`: the larger of this and 1.5 × the text, so a larger `visual.fontSize` grows the line instead of clipping the label's descenders; the label inherits it) |
|
|
562
616
|
|
|
563
617
|
The host may bind them once on `:root`, for example to its own type scale; the tree only reads them and never declares
|
|
564
|
-
them on its own elements.
|
|
565
|
-
|
|
566
|
-
|
|
618
|
+
them on its own elements. The label sets the step's font size on itself (`directoryTreeClasses.name`), so it does not
|
|
619
|
+
take the row's: a size on the row (a font-size class in `entryClassName`, `fontSize` in `entryStyle`) changes the row
|
|
620
|
+
element and its line height (the larger of the step's line and 1.5 × the row's text), but not the label's size. The
|
|
621
|
+
label follows `visual.fontSize` (which replaces only the size), a font-size class in `nameClassName`, and `nameStyle`,
|
|
622
|
+
which win over the step; a host that wants the label to follow the row passes `nameStyle: { fontSize: "inherit" }`.
|
|
623
|
+
Grid rows' labels keep the font size they inherit from the host. The row height (`itemHeight`, 44 px by default), the icon box and the tree lines do not depend on
|
|
567
624
|
the text size.
|
|
568
625
|
|
|
569
626
|
```css
|
|
@@ -730,31 +787,14 @@ rows carry no row-level accessible name (their cells name them), so the kind wor
|
|
|
730
787
|
- **Forwarding**: `locale` and the engine keys reach both the embedded `VirtualScroll` and the grid-mode
|
|
731
788
|
horizontal `ScrollBar`. An inline `labels={{…}}` object is fine: the forwarded engine labels keep their identity
|
|
732
789
|
while the strings are unchanged, so the virtualized body is not re-rendered.
|
|
790
|
+
- **One surface**: `locale` and `labels` are props of `DirectoryTree` only; the type of the `virtualScroll` options
|
|
791
|
+
(`DirectoryTreeVirtualScrollOptions`) takes neither.
|
|
792
|
+
- **Not a formatting locale**: `locale` switches only the language of the UI chrome; the package has no BCP 47
|
|
793
|
+
formatting axis.
|
|
733
794
|
|
|
734
795
|
Exports: `DirectoryTreeLocale`, `DirectoryTreeLabels`, `DirectoryTreeLabelOverrides`, `DIRECTORY_TREE_LABEL_KEYS`,
|
|
735
796
|
`DIRECTORY_TREE_LABEL_CATALOGS`, `resolveDirectoryTreeLabels`.
|
|
736
797
|
|
|
737
|
-
### Migrating to 3.12.0
|
|
738
|
-
|
|
739
|
-
- **Runtime requirement — update `@aiquants/virtualscroll` in the same change**: 3.12.0 imports
|
|
740
|
-
`VIRTUAL_SCROLL_LABEL_KEYS`, `VIRTUAL_SCROLL_LABEL_CATALOGS`, `resolveVirtualScrollLocale` and
|
|
741
|
-
`resolveVirtualScrollLabels`, which exist only in `@aiquants/virtualscroll` >= 3.7.0 (the published peer range is
|
|
742
|
-
`^3.7.0`). A `^3.11.x` caret on this package accepts 3.12.0, so a host that updates only `@aiquants/directory-tree`
|
|
743
|
-
while its lockfile keeps virtualscroll 3.6.x gets just an unmet-peer warning from pnpm's default (non-strict) peer
|
|
744
|
-
handling, and then a missing-export failure at build or load time. Bump both together, e.g.
|
|
745
|
-
`"@aiquants/virtualscroll": "^3.6.1"` → `"^3.7.0"`.
|
|
746
|
-
- **Default output is unchanged**: omitting `locale` renders the same English DOM as 3.11.x. To show the chrome in
|
|
747
|
-
Japanese (`ディレクトリ` / `ファイル`, `上へスクロール`, `項目がありません`, …) pass `locale="ja"` explicitly —
|
|
748
|
-
there is no language negotiation.
|
|
749
|
-
- **New API**: the top-level `locale` / `labels` props and the exports listed above.
|
|
750
|
-
- **`virtualScroll.locale` / `virtualScroll.labels` are rejected by the type** (they were accepted but silently
|
|
751
|
-
dropped before, so they never had an effect): move them to the top-level `locale` / `labels`.
|
|
752
|
-
- **`DirectoryEntryItemProps` gains two required fields**, `entryKindDirectory` / `entryKindFile` (the resolved kind
|
|
753
|
-
words; take them from `resolveDirectoryTreeLabels(locale, labels)`). Only code that builds this exported type
|
|
754
|
-
itself is affected.
|
|
755
|
-
- **`locale` is not a formatting locale**: this package has no BCP 47 `formatLocale` axis. `locale` switches the UI
|
|
756
|
-
chrome language only; entry names, column headers / footers and `visual.ariaLabel` remain your content.
|
|
757
|
-
|
|
758
798
|
## TypeScript Support
|
|
759
799
|
|
|
760
800
|
This package is written in TypeScript and provides comprehensive type definitions. All components and hooks are fully typed for the best development experience.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DirectoryTreeExpandIconStyle } from "./hostStyle.ts";
|
|
2
2
|
import { DirectoryEntry, DirectoryTreeColumn, DirectoryTreeIconOverrides, HighlightStyles } from "./types.ts";
|
|
3
3
|
export type GridRowVisual = {
|
|
4
4
|
iconOverrides?: DirectoryTreeIconOverrides;
|
|
@@ -12,7 +12,7 @@ export type GridRowVisual = {
|
|
|
12
12
|
indentSize: number;
|
|
13
13
|
highlightStyles?: HighlightStyles;
|
|
14
14
|
expandIconClassName?: string;
|
|
15
|
-
expandIconStyle?:
|
|
15
|
+
expandIconStyle?: DirectoryTreeExpandIconStyle;
|
|
16
16
|
};
|
|
17
17
|
export declare const isEntryExpanded: (entry: DirectoryEntry, isDirOpen: (path: string) => boolean) => boolean;
|
|
18
18
|
export type DirectoryTreeGridRowProps = {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
export declare const ROW_STYLE_PROPERTIES: readonly [
|
|
3
|
+
"color",
|
|
4
|
+
"background",
|
|
5
|
+
"backgroundColor",
|
|
6
|
+
"backgroundImage",
|
|
7
|
+
"backgroundPosition",
|
|
8
|
+
"backgroundSize",
|
|
9
|
+
"backgroundRepeat",
|
|
10
|
+
"backgroundClip",
|
|
11
|
+
"backgroundOrigin",
|
|
12
|
+
"backgroundAttachment",
|
|
13
|
+
"backgroundBlendMode",
|
|
14
|
+
"opacity",
|
|
15
|
+
"boxShadow",
|
|
16
|
+
"filter",
|
|
17
|
+
"backdropFilter",
|
|
18
|
+
"mixBlendMode",
|
|
19
|
+
"borderColor",
|
|
20
|
+
"borderRadius",
|
|
21
|
+
"outline",
|
|
22
|
+
"outlineColor",
|
|
23
|
+
"outlineStyle",
|
|
24
|
+
"outlineWidth",
|
|
25
|
+
"outlineOffset",
|
|
26
|
+
"textShadow",
|
|
27
|
+
"accentColor",
|
|
28
|
+
"caretColor",
|
|
29
|
+
"cursor",
|
|
30
|
+
"fontFamily",
|
|
31
|
+
"fontSize",
|
|
32
|
+
"fontStyle",
|
|
33
|
+
"fontWeight",
|
|
34
|
+
"fontVariant",
|
|
35
|
+
"fontFeatureSettings",
|
|
36
|
+
"fontVariationSettings",
|
|
37
|
+
"fontKerning",
|
|
38
|
+
"letterSpacing",
|
|
39
|
+
"lineHeight",
|
|
40
|
+
"textDecoration",
|
|
41
|
+
"textDecorationColor",
|
|
42
|
+
"textDecorationLine",
|
|
43
|
+
"textDecorationStyle",
|
|
44
|
+
"textDecorationThickness",
|
|
45
|
+
"textUnderlineOffset",
|
|
46
|
+
"textTransform"
|
|
47
|
+
];
|
|
48
|
+
export declare const EXPAND_ICON_STYLE_PROPERTIES: readonly [
|
|
49
|
+
"color",
|
|
50
|
+
"opacity"
|
|
51
|
+
];
|
|
52
|
+
export type DirectoryTreeRowStyle = Pick<CSSProperties, (typeof ROW_STYLE_PROPERTIES)[number]>;
|
|
53
|
+
export type DirectoryTreeExpandIconStyle = Pick<CSSProperties, (typeof EXPAND_ICON_STYLE_PROPERTIES)[number]>;
|
|
54
|
+
export type HostStyleSource = {
|
|
55
|
+
readonly option: string;
|
|
56
|
+
readonly absolutePath?: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const assertRowStyle: (style: unknown, source: HostStyleSource) => void;
|
|
59
|
+
export declare const assertExpandIconStyle: (style: unknown, source: HostStyleSource) => void;
|
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"),me=require("@aiquants/virtualscroll"),A=require("tailwind-merge"),le=require("@phosphor-icons/react");function cn(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=cn(l);var ut={exports:{}},Ke={};var Sr;function un(){if(Sr)return Ke;Sr=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,o,c){var i=null;if(c!==void 0&&(i=""+c),o.key!==void 0&&(i=""+o.key),"key"in o){c={};for(var d in o)d!=="key"&&(c[d]=o[d])}else c=o;return o=c.ref,{$$typeof:e,type:n,key:i,ref:o!==void 0?o:null,props:c}}return Ke.Fragment=t,Ke.jsx=r,Ke.jsxs=r,Ke}var Ue={};var vr;function dn(){return vr||(vr=1,process.env.NODE_ENV!=="production"&&(function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===z?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case y:return"Fragment";case $:return"Profiler";case v:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case K:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case p:return"Portal";case P:return s.displayName||"Context";case N:return(s._context.displayName||"Context")+".Consumer";case g:var f=s.render;return s=s.displayName,s||(s=f.displayName||f.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case O:return f=s.displayName||null,f!==null?f:e(s.type)||"Memo";case q:f=s._payload,s=s._init;try{return e(s(f))}catch{}}return null}function t(s){return""+s}function r(s){try{t(s);var f=!1}catch{f=!0}if(f){f=console;var T=f.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return T.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),t(s)}}function n(s){if(s===y)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===q)return"<...>";try{var f=e(s);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function o(){var s=H.A;return s===null?null:s.getOwner()}function c(){return Error("react-stack-top-frame")}function i(s){if(ue.call(s,"key")){var f=Object.getOwnPropertyDescriptor(s,"key").get;if(f&&f.isReactWarning)return!1}return s.key!==void 0}function d(s,f){function T(){de||(de=!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)",f))}T.isReactWarning=!0,Object.defineProperty(s,"key",{get:T,configurable:!0})}function S(){var s=e(this.type);return G[s]||(G[s]=!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.")),s=this.props.ref,s!==void 0?s:null}function w(s,f,T,R,ye,C){var j=T.ref;return s={$$typeof:b,type:s,key:f,props:T,_owner:R},(j!==void 0?j:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:S}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ye}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function E(s,f,T,R,ye,C){var j=f.children;if(j!==void 0)if(R)if(W(j)){for(R=0;R<j.length;R++)I(j[R]);Object.freeze&&Object.freeze(j)}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 I(j);if(ue.call(f,"key")){j=e(s);var Z=Object.keys(f).filter(function(Re){return Re!=="key"});R=0<Z.length?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}",pe[j+R]||(Z=0<Z.length?"{"+Z.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} />`,I,O,Z,O),me[O+I]=!0)}if(O=null,C!==void 0&&(r(C),O=""+C),i(f)&&(r(f.key),O=""+f.key),"key"in f){C={};for(var de in f)de!=="key"&&(C[de]=f[de])}else C=f;return O&&d(C,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,O,C,a(),pe,T)}function R(o){N(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===q&&(o._payload.status==="fulfilled"?N(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function N(o){return typeof o=="object"&&o!==null&&o.$$typeof===b}var m=l,b=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),P=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),H=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=Object.prototype.hasOwnProperty,X=Array.isArray,re=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(o){return o()}};var we,Y={},G=m.react_stack_bottom_frame.bind(m,c)(),ve=re(n(c)),me={};Xe.Fragment=y,Xe.jsx=function(o,f,C){var I=1e4>H.recentlyCreatedOwnerStacks++;return x(o,f,C,!1,I?Error("react-stack-top-frame"):G,I?re(n(o)):ve)},Xe.jsxs=function(o,f,C){var I=1e4>H.recentlyCreatedOwnerStacks++;return x(o,f,C,!0,I?Error("react-stack-top-frame"):G,I?re(n(o)):ve)}})()),Xe}var vr;function an(){return vr||(vr=1,process.env.NODE_ENV==="production"?ct.exports=on():ct.exports=sn()),ct.exports}var h=an();function ln({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 cn=ce.forwardRef(ln);function un({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 dn=ce.forwardRef(un);function fn({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 hn=ce.forwardRef(fn),Nr="text-[length:var(--dt-font-size-body,0.8125rem)]",mn=`${Nr} leading-[max(var(--dt-line-height-body,1.25rem),1.5em)]`,kt=44,pn=12,yn=8,ie=14,gn=14,_r=e=>e===void 0?void 0:{fontSize:typeof e=="number"?`${e}px`:e},oe=e=>({width:e,height:e}),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 ${mn} 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 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 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 ${Nr} 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")},Ot=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},bn=/^[a-z][a-z\d+.-]*:\/\//i,Sr=e=>Ot(bn.test(e)?e.split(/[?#]/,1)[0]:e),Pr=e=>Ot(e.name)||Sr(e.relativePath)||Sr(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?h.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?h.jsx(cn,{className:i,style:c}):h.jsx(dn,{className:i,style:c})},Tt=(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=>Tt(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},wn={markdown:e=>h.jsx(le.FileMd,{className:"text-sky-500 dark:text-sky-400",style:oe(e)}),pdf:e=>h.jsx(le.FilePdf,{className:"text-red-500 dark:text-red-400",style:oe(e)}),spreadsheet:e=>h.jsx(le.FileXls,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),csv:e=>h.jsx(le.FileCsv,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),document:e=>h.jsx(le.FileDoc,{className:"text-blue-600 dark:text-blue-400",style:oe(e)}),presentation:e=>h.jsx(le.FilePpt,{className:"text-orange-500 dark:text-orange-400",style:oe(e)}),image:e=>h.jsx(le.FileImage,{className:"text-teal-500 dark:text-teal-400",style:oe(e)}),audio:e=>h.jsx(le.FileAudio,{className:"text-pink-500 dark:text-pink-400",style:oe(e)}),video:e=>h.jsx(le.FileVideo,{className:"text-violet-500 dark:text-violet-400",style:oe(e)}),archive:e=>h.jsx(le.FileZip,{className:"text-amber-500 dark:text-amber-400",style:oe(e)}),code:e=>h.jsx(le.FileCode,{className:"text-purple-500 dark:text-purple-400",style:oe(e)}),text:e=>h.jsx(le.FileText,{className:"text-gray-500 dark:text-gray-400",style:oe(e)})},vn={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"]},Sn=new Map(Object.entries(vn).flatMap(([e,t])=>t.map(r=>[r,e]))),xn=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),En=e=>(e??"").split(";",1)[0].trim().toLowerCase(),Rn=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"},In=(e,t,r,n)=>{const a=En(e),c=Rn(a),i=Sn.get((t||(r?Ot(r):"")).toLowerCase()),w=(xn.has(a)?[i,c]:[c,i]).find(S=>S!==void 0);return w===void 0?h.jsx(le.FileIcon,{className:"text-gray-400 dark:text-gray-400",style:oe(n)}):wn[w](n)},Or=(e,t,r)=>{const{entry:n,isDirectory:a,isExpanded:c,extension:i,mimeType:d}=e;let w;const S=d||n.mimeType;return n.icon!==void 0?w=n.icon:a?w=c&&t?.directoryExpanded||t?.directory||h.jsx(hn,{style:oe(r)}):i&&t?.fileByExtension?.[i]?w=t.fileByExtension[i]:w=t?.file||In(S,i,n.name,r),Tt(typeof w=="function"?w(e):w,n.absolutePath)},kn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Mr=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-${kn(r)}`,String(n)]))},Cn=500,Ar=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:a,onSelectionChange:c,onEntryClick:i,toggleDirectory:d,onToggleDirectoryRecursive:w})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(x=>{x.stopPropagation(),a!=="none"&&!t&&c&&c(e,!n);let R=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{R=!0}}),!(!t||R)&&(S.current?(window.clearTimeout(S.current),S.current=null,w(e)):S.current=window.setTimeout(()=>{d(e.absolutePath),S.current=null},Cn))},[t,e,r,w,d,i,a,c,n])},Lr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",xr=(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:w,rowHeight:S,isDirOpen:x,columns:R,numericTemplate:N,numericTotal:m,nameWidth:b,rowClassName:p,selection:{onEntryClick:y,selectedPath:v,currentPath:z,mode:_="none",selectedItems:P,onSelectionChange:g},expansion:{toggleDirectory:D,onToggleDirectoryRecursive:F},visual:{iconOverrides:j,showExpandIcons:q=!0,showDirectoryIcons:K=!0,showFileIcons:$=!0,useCanvasExpandIcons:H=!1,expandIconSize:ue,typeIconSize:X,fontSize:re,indentSize:we,highlightStyles:Y,expandIconClassName:G,expandIconStyle:ve}})=>{const[me,o]=l.useState(!1),f=e.children!==void 0,C=f&&x(e.absolutePath),I=e.absolutePath===v,pe=e.absolutePath===z,T=!f&&!!P?.has(e.absolutePath),O=f?void 0:Pr(e),Z=Ar({entry:e,isDirectory:f,isExpanded:C,isItemSelected:T,selectionMode:_,onSelectionChange:g,onEntryClick:y,toggleDirectory:D,onToggleDirectoryRecursive:F}),de=me?Y?.hoverClassName!==void 0?Y.hoverClassName:L.entryHover:"",Re=(()=>{if(f){if(I)return Y?.directorySelectedClassName!==void 0?Y.directorySelectedClassName:L.entrySelected}else if(I||T)return Y?.itemSelectedClassName!==void 0?Y.itemSelectedClassName:A.twMerge(I&&L.entrySelected,T&&L.entryItemSelected);return""})(),M=typeof p=="function"?p(e):p,ye=A.twMerge("dt-grid-row cursor-pointer select-none",de,Re,M,e.className),U=A.twMerge(L.expandIcon,G,(I||T)&&L.expandIconSelected),Oe=A.twMerge(L.typeIcon,(I||T)&&L.typeIconSelected),ne=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",f&&L.nameDirectory,(I||T)&&L.nameSelected),Q=jr({isDirectory:f,isExpanded:C,showExpandIcons:q,useCanvasExpandIcons:H,expandIconSize:ue}),se=(f?K:$)?Or({entry:e,isDirectory:f,isExpanded:C,isSelected:I,isItemSelected:T,extension:O,mimeType:e.mimeType},j,X):null,Ie={indentLevel:t,isDirectory:f,isExpanded:C},[Ne,...ke]=R,Me=Ne?.render?Ne.render(e,Ie):e.label??e.name,Se={...me?Y?.hoverStyle:{},...f&&I?Y?.directorySelectedStyle:{},...!f&&(I||T)?Y?.itemSelectedStyle:{}};return h.jsxs("div",{className:ye,style:{height:S,...Se,...e.style},role:"row","aria-expanded":f?C:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":a,"aria-selected":_==="none"?void 0:w,"aria-current":pe?"page":void 0,...Mr(e.data),"data-entry-type":f?"directory":"file","data-entry-expanded":f?String(C):void 0,"data-entry-selected":I?"true":void 0,"data-entry-item-selected":T?"true":void 0,onClick:Z,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:W=>i(c,e.absolutePath,W.currentTarget),onBlur:W=>d(e.absolutePath,W.currentTarget),onKeyDown:W=>{if(W.key==="Enter"){if(W.repeat){W.preventDefault();return}Z(W)}},tabIndex:0,children:[h.jsxs("div",{className:A.twMerge("dt-grid-name-cell",Ne?.className),role:"gridcell",style:{width:b,paddingLeft:Math.max(0,t*we)},children:[(q||H)&&h.jsx("span",{className:U,style:{width:ie,height:ie,...ve},children:Q}),(f?K:$)&&h.jsx("span",{className:Oe,style:{width:X,height:X},children:se}),h.jsx("span",{className:ne,style:_r(re),children:Me})]}),ke.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Dr(m,N),children:ke.map(W=>h.jsx("div",{className:A.twMerge("dt-grid-cell",Lr(W.align),W.className),role:"gridcell",children:W.render?W.render(e,Ie):null},W.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=xr(e.entry,e.isDirOpen),n=xr(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 zr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:a,scrollBarWidth:c,className:i,nameContent:d,renderCell:w})=>{const[,...S]=t,x=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",R=e==="header"?"dt-grid-header":"dt-grid-footer",N=e==="header"?"columnheader":"gridcell";return h.jsxs("div",{className:A.twMerge(R,"text-gray-600 dark:text-gray-300",i),role:"row",children:[h.jsx("div",{className:A.twMerge(x,"px-1",t[0]?.className),role:N,style:{width:a},children:d}),S.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Dr(n,r),children:S.map(m=>h.jsx("div",{className:A.twMerge("dt-grid-cell",Lr(m.align),m.className),role:N,children:w(m)},m.key))})}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},Tn=({columns:e,className:t,...r})=>h.jsx(zr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),Er=(e,t)=>typeof e=="function"?e(t):e??null,Nn=({columns:e,allEntries:t,className:r,...n})=>h.jsx(zr,{kind:"footer",columns:e,className:r,nameContent:Er(e[0]?.footer,t),renderCell:a=>Er(a.footer,t),...n}),_n=240,$r=96,Br=12,Nt=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},Pn=e=>e.slice(1).map(t=>`${Nt(t,$r)}px`).join(" "),jn=({measuredWidth:e,columns:t,scrollBarWidth:r=Br})=>{const n=Nt(t[0],_n),a=t.slice(1).reduce((w,S)=>w+Nt(S,$r),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}},Ct=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,On=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"],_t=[...he.VIRTUAL_SCROLL_LABEL_KEYS,...Hr],Pt=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,...Pt.en}),ja:Object.freeze({...he.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Pt.ja})}),Rr=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Mn=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 ${Rr(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(!_t.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${_t.join(", ")}`);const c={...he.resolveVirtualScrollLabels(r,Mn(t)),...Pt[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 ${Rr(d)}`);c[i]=d}}return Object.freeze(c)},An=e=>{const t={};for(const r of he.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Ln=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Ue=e=>typeof e=="string"?JSON.stringify(e):String(e),jt=(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 ${Ue(t)}.`);return t},Dn=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 ${Ue(e)}.`)},Fn=({indentSize:e,typeIconSize:t,fontSize:r})=>({indentSize:e===void 0?pn:jt("indentSize",e),typeIconSize:t===void 0?gn:jt("typeIconSize",t),fontSize:r===void 0?void 0:Dn(r)}),zn=({indentSize:e,removeRootIndent:t,hasExpandBox:r})=>t?Math.max(0,e-(r?ie:0)):0,$n=(e,t,r)=>{if(typeof e!="function")return jt("itemHeight",e);const n=e(t,r);if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new RangeError(`[directory-tree] visual.itemHeight returned ${Ue(n)} for ${JSON.stringify(t.absolutePath)} (row ${r}); it must return a finite number greater than 0 (px).`);return n},Bn=(e,t,r)=>{const n=t===void 0?yn:t;if(typeof n!="number"||!Number.isFinite(n)||n<=0||n>ie)throw new RangeError(`[directory-tree] visual.expandIconSize must be a finite number greater than 0 and at most ${ie} (the expand box, px) while tree lines are drawn; got ${Ue(n)}.`);const{indentSize:a,typeIconSize:c}=e,i=n/2,d=ie+c-n/2;if(a<i||a>d)throw new RangeError(`[directory-tree] visual.indentSize ${Ue(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 ${ie} px expand box + typeIconSize − half the glyph).`);return{indentSize:a,typeIconSize:c,glyphSize:n,originX:r}},Hn=({indentSize:e,typeIconSize:t,glyphSize:r})=>Math.min(Math.max(ie+t/2-e,r/2),ie-r/2),Wn=(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},Yn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=Wn(t,r),a=e[n];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[n]}:null},Gn=(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},Vn=(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},Kn=(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},Xn=(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`)},Un=(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()},Jn=(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})`},qn=(e,t,r,n)=>{if(t.length===0)return;const a=Jn(r,.14),c=e.strokeStyle,i=e.fillStyle,d=e.lineWidth,w=e.lineCap,S=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const x of t){const R=n??x.size,N=Math.max(0,R/2),m=Math.max(1,Math.round(R*.08)),b=Math.max(1,Math.round(R*.14)),p=Math.max(0,N-m*.8),y=Math.max(0,p*.55);a&&(e.fillStyle=a,e.beginPath(),e.arc(x.centerX,x.centerY,p,0,Math.PI*2),e.fill()),e.lineWidth=m,e.beginPath(),e.arc(x.centerX,x.centerY,Math.max(0,N-m*.3),0,Math.PI*2),e.stroke(),e.lineWidth=b,e.beginPath(),e.moveTo(x.centerX-y,x.centerY),e.lineTo(x.centerX+y,x.centerY),e.stroke(),x.isExpanded||(e.beginPath(),e.moveTo(x.centerX,x.centerY-y),e.lineTo(x.centerX,x.centerY+y),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=d,e.lineCap=w,e.lineJoin=S},Gr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i="#a0aec0",strokeWidth:d=1,renderStartIndex:w,renderEndIndex:S,lookaheadEndIndex:x,devicePixelRatio:R,expandGlyphColor:N,expandGlyphSize:m})=>{const b=l.useRef(null),p=l.useRef(null),y=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:w,renderEndIndex:S,lookaheadEndIndex:x,devicePixelRatio:R,expandGlyphColor:N,expandGlyphSize:m}),v=l.useCallback(()=>{p.current=null;const _=b.current;if(!_)return;const P=_.getContext("2d");if(!P)return;const g=y.current;if(g.width<=0||g.viewportHeight<=0){P.clearRect(0,0,_.width,_.height);return}const D=Number.isFinite(g.devicePixelRatio??NaN)?g.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Xn(_,g.width,g.viewportHeight,D);const F=g.segmentsByItem.length,j=typeof g.renderStartIndex=="number"&&Number.isFinite(g.renderStartIndex)?Math.max(0,Math.floor(g.renderStartIndex)):Math.max(0,Math.floor(g.scrollPosition/g.itemHeight)),q=Math.min(F,Math.ceil((g.scrollPosition+g.viewportHeight)/g.itemHeight)),K=(()=>{if(typeof g.renderEndIndex=="number"&&Number.isFinite(g.renderEndIndex)){const X=Math.floor(g.renderEndIndex);return Math.max(Math.min(F,X+1),j)}return Math.max(q,j)})(),$=(()=>{if(typeof g.lookaheadEndIndex=="number"&&Number.isFinite(g.lookaheadEndIndex)){const X=Math.floor(g.lookaheadEndIndex),re=Math.min(F,X+1);return Math.max(re,K)}return Math.max(q,K)})(),H=Vn(g.segmentsByItem,j,$),ue=Kn(g.glyphsByItem,j,$);P.save(),P.scale(D,D),P.clearRect(0,0,g.width,g.viewportHeight),P.translate(0,-g.scrollPosition),P.strokeStyle=g.color,Un(P,H,g.strokeWidth),qn(P,ue,g.expandGlyphColor??g.color,g.expandGlyphSize),P.restore()},[]),z=l.useCallback(()=>{p.current===null&&(p.current=window.requestAnimationFrame(v))},[v]);return l.useEffect(()=>{y.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:w,renderEndIndex:S,lookaheadEndIndex:x,devicePixelRatio:R,expandGlyphColor:N,expandGlyphSize:m},z()},[e,t,r,n,a,c,i,d,w,S,x,R,N,m,z]),l.useEffect(()=>()=>{p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)},[]),h.jsx("canvas",{ref:b,className:"pointer-events-none absolute top-0 left-0 z-0"})});Gr.displayName="TreeLineCanvas";const Zn=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},Ir=(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}}),eo=(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},to={msOverflowStyle:"none",scrollbarWidth:"none"},ro=()=>{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))},no=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)},kr=new Set(["top","bottom","center","nearest"]),Cr=e=>{const t=e?.align;if(t===void 0)return"top";if(!kr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...kr].join(", ")}.`);return t},oo={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},so=(e,t,r,n,a)=>{const c=[],i=[];let d=0;const w=(S,x,R)=>{const N=a?[...S].sort(a):S;for(let m=0;m<N.length;m++){const b=N[m],p=m===N.length-1,y=[...R,p],v=b.children!==void 0,z=v&&t(b.absolutePath,b.relativePath);let _=x,P=R;n&&(_=x-1,P=R.slice(1)),c.push({entry:b,indentLevel:_,depth:x,positionInSet:m+1,setSize:N.length}),r&&(_>d&&(d=_),i.push({id:b.absolutePath,name:b.name,absolutePath:b.absolutePath,indentLevel:_,isLastChild:p,isDirectory:v,isExpanded:z,ancestorIsLast:[...P],hideLines:n&&x===0})),v&&z&&b.children&&w(b.children,x+1,y)}};return w(e,0,[]),{flatItems:c,lineItems:i,maxIndent:d}},Tr=(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},ao=(e,t,r,n,a,c)=>{const i=n?.renderStart??Math.max(0,Tr(c,a)),d=t>0?Tr(c,a+t)+r:i+r,w=e>0?Math.min(e-1,Math.max(i,d)):i,S=n?.renderEnd??w,x=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:x}},lo=(e,t,r,n)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const{indentSize:a,typeIconSize:c,glyphSize:i,originX:d}=n,w=Array.from({length:e.length},()=>[]),S=Array.from({length:e.length},()=>[]),x=d+Hn(n),R=m=>m*a+x,N=i/2+2;for(let m=0;m<e.length;m++){const b=e[m],p=t[m]??0,y=r[m]??0,v=y+p/2,z=e[m+1],_=v+c/2,P=y+p,g=z!==void 0&&z.indentLevel===b.indentLevel+1&&_<P?{key:`${b.id}-connector-children`,x1:R(z.indentLevel),y1:_,x2:R(z.indentLevel),y2:P,itemIndex:m}:null;if(b.hideLines){g!==null&&(w[m]=[g]);continue}const D=[];for(let j=0;j<b.indentLevel;j++){if(b.ancestorIsLast[j]??!1)continue;let K=!1;for(let $=m;$<e.length;$++){const H=e[$];if(H.indentLevel>j&&H.ancestorIsLast.length>j&&!H.ancestorIsLast[j]){K=!0;break}if($>m&&H.indentLevel===j)break}if(K){const $=R(j);D.push({key:`${b.id}-ancestor-${j}`,x1:$,y1:y,x2:$,y2:y+p,itemIndex:m})}}const F=R(b.indentLevel);m>0&&D.push({key:`${b.id}-connector-top`,x1:F,y1:y,x2:F,y2:b.isDirectory?v-N:v,itemIndex:m}),!b.isDirectory&&b.isLastChild&&D.push({key:`${b.id}-connector-horizontal`,x1:F,y1:v,x2:d+b.indentLevel*a+ie,y2:v,itemIndex:m}),b.isLastChild||(b.isDirectory?D.push({key:`${b.id}-connector-bottom`,x1:F,y1:v+N,x2:F,y2:y+p,itemIndex:m}):D.push({key:`${b.id}-connector-bottom`,x1:F,y1:v,x2:F,y2:y+p,itemIndex:m})),g!==null&&D.push(g),w[m]=D,b.isDirectory&&(S[m]=[{key:`${b.id}-glyph`,itemIndex:m,centerX:F,centerY:v,size:i,isExpanded:b.isExpanded}])}return{segmentsByItem:w,glyphsByItem:S}},Vr=l.memo(({entry:e,indentLevel:t,originX:r,depth:n,positionInSet:a,setSize:c,isSelectedForAria:i,flatIndex:d,isActive:w,registerRowRef:S,onNavigationKeyDown:x,onRowFocus:R,onRowBlur:N,rowHeight:m,entryKindDirectory:b,entryKindFile:p,isDirOpen:y,expansion:{toggleDirectory:v,onToggleDirectoryRecursive:z},selection:{onEntryClick:_,selectedPath:P,currentPath:g,mode:D="none",selectedItems:F,onSelectionChange:j},visual:{iconOverrides:q,showExpandIcons:K=!0,showDirectoryIcons:$=!0,showFileIcons:H=!0,useCanvasExpandIcons:ue=!1,expandIconSize:X,typeIconSize:re,fontSize:we,indentSize:Y,highlightStyles:G,entryClassName:ve,entryStyle:me,nameClassName:o,nameStyle:f,directoryNameClassName:C,directoryNameStyle:I,fileNameClassName:pe,fileNameStyle:T,expandIconClassName:O,expandIconStyle:Z}})=>{const[de,Re]=l.useState(!1),M=e.children!==void 0,ye=M&&y(e.absolutePath),U=e.absolutePath===P,Oe=e.absolutePath===g,ne=!M&&F?.has(e.absolutePath),Q=l.useCallback(ee=>S(d,ee),[S,d]),se=M?void 0:Pr(e),Ie=Ar({entry:e,isDirectory:M,isExpanded:ye,isItemSelected:!!ne,selectionMode:D,onSelectionChange:j,onEntryClick:_,toggleDirectory:v,onToggleDirectoryRecursive:z}),Ne=de?G?.hoverClassName!==void 0?G.hoverClassName:L.entryHover:"",ke=(()=>{if(M){if(U)return G?.directorySelectedClassName!==void 0?G.directorySelectedClassName:L.entrySelected}else if(U||ne)return G?.itemSelectedClassName!==void 0?G.itemSelectedClassName:A.twMerge(U&&L.entrySelected,ne&&L.entryItemSelected);return""})(),Me=A.twMerge(L.entry,Ne,ke,ve,e.className),Se=A.twMerge(L.expandIcon,O,(U||ne)&&L.expandIconSelected),W=A.twMerge(L.typeIcon,(U||ne)&&L.typeIconSelected),Be=A.twMerge(L.name,o,M&&L.nameDirectory,M&&C,!M&&pe,(U||ne)&&L.nameSelected),Je=jr({isDirectory:M,isExpanded:ye,showExpandIcons:K&&t>=0,useCanvasExpandIcons:ue,expandIconSize:X}),ut=(M?$:H)?Or({entry:e,isDirectory:M,isExpanded:ye,isSelected:U,isItemSelected:!!ne,extension:se,mimeType:e.mimeType},q,re):null,He={...de?G?.hoverStyle:{},...M&&U?G?.directorySelectedStyle:{},...!M&&(U||ne)?G?.itemSelectedStyle:{}},We=Mr(e.data),qe={width:re,height:re},Ze=_r(we),ge=r+t*Y;return h.jsxs("div",{className:Me,style:{paddingLeft:`${Math.max(0,ge)}px`,transform:ge<0?`translateX(${ge}px)`:void 0,width:ge<0?`calc(100% + ${-ge}px)`:void 0,height:`${m}px`,...Ze,...He,...me,...e.style},...We,"data-entry-type":M?"directory":"file","data-entry-expanded":M?String(ye):void 0,"data-entry-selected":U?"true":void 0,"data-entry-item-selected":ne?"true":void 0,onClick:Ie,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),onFocus:ee=>R(d,e.absolutePath,ee.currentTarget),onBlur:ee=>N(e.absolutePath,ee.currentTarget),ref:Q,onKeyDown:ee=>{if(ee.key==="Enter"||ee.key===" "){ee.preventDefault(),ee.repeat||Ie(ee);return}x(ee,d)},tabIndex:w?0:-1,role:"treeitem","aria-expanded":M?ye:void 0,"aria-level":n+1,"aria-posinset":a,"aria-setsize":c,"aria-selected":D==="none"?void 0:i,"aria-current":Oe?"page":void 0,"aria-label":`${e.name} (${M?b:p})`,children:[(K||ue)&&h.jsx("span",{className:Se,style:{width:ie,height:ie,...Z},children:Je}),(M?$:H)&&h.jsx("span",{className:W,style:qe,children:ut}),h.jsx("span",{className:Be,style:{...Ze,...f,...M?I:T},"data-entry-type":M?"directory":"file","data-entry-role":"name",children:e.label??e.name})]})},(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});Vr.displayName="DirectoryEntryItem";const Kr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Kr(r)));return t},io=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:a,isPending:c,alwaysExpanded:i=!1,doubleClickAction:d="recursive"},selection:{onEntryClick:w,selectedPath:S,currentPath:x,mode:R="none",selectedItems:N,onSelectionChange:m},visual:{className:b,style:p,ariaLabel:y,ariaLabelledBy:v,lineColor:z="#A0AEC0",showTreeLines:_=!0,showExpandIcons:P=!0,showDirectoryIcons:g=!0,showFileIcons:D=!0,iconOverrides:F,expandIconSize:j,typeIconSize:q,fontSize:K,indentSize:$,itemHeight:H=kt,removeRootIndent:ue=!1,highlightStyles:X,entryClassName:re,entryStyle:we,nameClassName:Y,nameStyle:G,directoryNameClassName:ve,directoryNameStyle:me,fileNameClassName:o,fileNameStyle:f,expandIconClassName:C,expandIconStyle:I}={},virtualScroll:pe,grid:T,sort:O,locale:Z,labels:de,ref:Re})=>{const M=he.resolveVirtualScrollLocale(Z),ye=l.useMemo(()=>Yr(Z,de),[Z,de]),U=no(An(ye)),{entryKindDirectory:Oe,entryKindFile:ne}=ye,Q=l.useMemo(()=>Fn({indentSize:$,typeIconSize:q,fontSize:K}),[$,q,K]),se=T!==void 0,[Ie,Ne]=l.useState(!1),ke=l.useRef(null),Me=l.useRef(null),Se=l.useRef(null),[W,Be]=l.useState(0),[Je,ut]=l.useState(0),[He,We]=l.useState(0),[qe,Ze]=l.useState(null),{overscanCount:ge=15,className:ee,background:Mt,onScroll:At,onRangeChange:Lt,onScrollAdjust:Dt,liveRegion:Ft,initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:$t,callbackThrottleMs:Bt=5,contentInsets:Ht,onItemFocus:Wt,viewportHeightOverride:ae,scrollBarOptions:dt,behaviorOptions:Yt,preserveScrollAnchor:Gt=!1,getItemKey:Xr,testId:Vt,contentProps:ft}=pe??{},Kt=l.useMemo(()=>se?{...ft,role:"rowgroup"}:{...ft,role:"tree","aria-label":v?void 0:y,"aria-labelledby":v,"aria-multiselectable":R==="multiple"?!0:void 0},[se,ft,y,v,R]),Xt=l.useMemo(()=>({...Yt,enableKeyboardNavigation:!1}),[Yt]),[Qe,Ut]=l.useState(typeof Ae=="number"?Ae:0),ht=l.useRef(typeof Ae=="number"?Ae:0),Jt=l.useCallback((s,u)=>{ht.current=s,Ut(s),At?.(s,u)},[At]),qt=l.useCallback(s=>{const{renderingStartIndex:u,renderingEndIndex:E}=s;Ze(k=>k&&k.renderStart===u&&k.renderEnd===E?k:{renderStart:u,renderEnd:E}),Lt?.(s)},[Lt]);l.useEffect(()=>{Ne(!0),ro()},[]),l.useEffect(()=>{const s=ke.current,u=se?Me.current:s,E=()=>{if(s){const B=s.clientWidth;ut(J=>Math.abs(J-B)>1?B:J)}if(typeof ae=="number")Be(B=>Math.abs(B-ae)>1?ae:B);else if(u){const B=u.clientHeight;Be(J=>Math.abs(J-B)>1?B:J)}};if(!(s||u))return Be(0);E();const k=new ResizeObserver(E);return s&&k.observe(s),u&&u!==s&&k.observe(u),()=>k.disconnect()},[ae,se]);const Le=typeof ae=="number"?ae:W,be=l.useCallback(s=>i||(Ie?r(s):!1),[Ie,r,i]),Zt=A.twMerge(L.container,c&&L.containerPending,b),Qt=l.useMemo(()=>({...to,...p??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[p,ae]),mt=l.useCallback((s,u)=>{const E=[s.absolutePath,...Kr(s)],k=u||d;if(E.every(Ee=>be(Ee)))return a(E);if(E.every(Ee=>!be(Ee))||k==="recursive")return n(E);if(k==="toggle")return a(E);console.warn(`[DirectoryTree] Unknown double click action: ${k}. No action taken.`)},[be,n,a,d]),pt=se?!1:ue,{flatItems:_e,lineItems:yt,maxIndent:er}=l.useMemo(()=>so(e,be,_,pt,O),[e,be,_,pt,O]),et=zn({indentSize:Q.indentSize,removeRootIndent:pt,hasExpandBox:P||_}),fe=l.useMemo(()=>_?Bn(Q,j,et):null,[_,Q,j,et]),V=l.useMemo(()=>_e.map((s,u)=>({...s,rowHeight:$n(H,s.entry,u)})),[_e,H]),Ce=l.useMemo(()=>V.map(s=>s.rowHeight),[V]),Pe=l.useMemo(()=>{const s=new Array(Ce.length+1);s[0]=0;for(let u=0;u<Ce.length;u++)s[u+1]=s[u]+Ce[u];return s},[Ce]),tr=l.useCallback(s=>V[s]?.rowHeight??kt,[V]),Ur=l.useCallback(s=>V[s]?.entry.absolutePath??s,[V]),rr=Xr??Ur,De=S??null,gt=x??null,[nr,Ye]=l.useState(()=>({selectedPath:De,selectionGeneration:0,anchor:null})),bt=Ir(nr,De);bt!==nr&&Ye(s=>Ir(s,De));const tt=l.useMemo(()=>Zn(_e),[_e]),Fe=l.useMemo(()=>eo(tt,bt),[tt,bt]),Ge=l.useRef(new Map),rt=l.useRef(null),[nt]=l.useState(Ln),Ve=l.useRef(null),[Jr,or]=l.useState(!0),wt=l.useRef(_e);wt.current=_e;const sr=l.useRef(be);sr.current=be;const vt=l.useRef(t);vt.current=t;const ar=l.useRef(tt);ar.current=tt;const St=l.useRef(Fe);St.current=Fe;const lr=l.useRef(Wt);lr.current=Wt;const je=l.useCallback(s=>{const u=Se.current;return!u||u.getViewportSize()<=0?!1:(u.scrollToIndex(s,{align:"nearest"}),!0)},[]),xe=l.useCallback(s=>{const u=Ge.current.get(s);if(u===void 0){Ve.current=s,je(s)||(Ve.current=null);return}Ve.current=null,je(s),u.focus({preventScroll:!0})},[je]),ir=l.useCallback((s,u)=>{if(u)Ge.current.set(s,u),Ve.current===s?(Ve.current=null,u.focus({preventScroll:!0})):u.contains(u.ownerDocument.activeElement)&&Ye(E=>E.anchor===null?E:{...E,anchor:{...E.anchor,focused:!0}});else{const E=Ge.current.get(s);Ge.current.delete(s),E?.contains(E.ownerDocument.activeElement)&&Ye(k=>k.anchor===null?k:{...k,anchor:{...k.anchor,focused:!1}})}s===St.current&&or(u!==null)},[]);l.useLayoutEffect(()=>{or(Ge.current.has(Fe))},[Fe]);const xt=l.useCallback((s,u,E)=>{const k=rt.current===E;rt.current=null,k||(Ye(B=>Qn(B,u)),nt.landedOn(E)||je(s)),lr.current?.(s)},[je,nt]),ot=l.useCallback(s=>nt.mark(s.nativeEvent),[nt]),Et=l.useCallback((s,u)=>{const{ownerDocument:E}=u;if(!E.hasFocus()&&u.contains(E.activeElement)){rt.current=u;return}rt.current=null,Ye(k=>k.anchor!==null&&k.anchor.path===s?{...k,anchor:{...k.anchor,focused:!1}}:k)},[]),qr=l.useCallback(()=>xe(St.current),[xe]),Rt=l.useCallback((s,u)=>{const E=Cr(u),k=wt.current.length;if(!Number.isInteger(s)||s<0||s>=k)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${k===0?"the tree has no rows":`expected an integer in 0..${String(k-1)}`}).`);if(E==="nearest"){je(s);return}Se.current?.scrollToIndex(s,{align:E})},[je]);l.useImperativeHandle(Re,()=>({scrollToIndex:Rt,scrollToPath:(s,u)=>{Cr(u);const E=ar.current.get(s);return E===void 0?!1:(Rt(E,u),!0)},getScrollAnchor:()=>Se.current?.getScrollAnchor()??null}),[Rt]);const cr=l.useCallback((s,u)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const E=wt.current,k=E.length-1;if(k<0)return;const B=E[u],J=B?.entry.children!==void 0,Ee=J&&sr.current(B.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),xe(Math.min(u+1,k));break;case"ArrowUp":s.preventDefault(),xe(Math.max(u-1,0));break;case"Home":s.preventDefault(),xe(0);break;case"End":s.preventDefault(),xe(k);break;case"ArrowRight":s.preventDefault(),J&&!Ee?vt.current(B.entry.absolutePath):J&&u<k&&E[u+1].depth>B.depth&&xe(u+1);break;case"ArrowLeft":{if(s.preventDefault(),J&&Ee){vt.current(B.entry.absolutePath);break}const rn=B?.depth??0;for(let it=u-1;it>=0;it--)if(E[it].depth<rn){xe(it);break}break}}},[xe]),st=l.useMemo(()=>fe===null||yt.length===0?{segmentsByItem:[],glyphsByItem:[]}:lo(yt,Ce,Pe,fe),[yt,Ce,Pe,fe]),at=l.useMemo(()=>fe===null||e.length===0?0:fe.originX+er*fe.indentSize+ie+fe.typeIconSize,[e.length,er,fe]),{renderStart:ur,renderEnd:dr,lookaheadEnd:fr}=l.useMemo(()=>ao(V.length,Le,ge,qe,Qe,Pe),[V.length,Le,ge,qe,Qe,Pe]),It=l.useMemo(()=>fe===null||at<=0||Le<=0||st.segmentsByItem.length===0?null:h.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:h.jsx("div",{className:"absolute top-0 left-0",style:{width:at,height:Le},children:h.jsx(Gr,{segmentsByItem:st.segmentsByItem,glyphsByItem:st.glyphsByItem,itemHeight:Ce[0]??kt,width:at,viewportHeight:Le,scrollPosition:Qe,color:z,expandGlyphColor:z,expandGlyphSize:fe.glyphSize,renderStartIndex:ur,renderEndIndex:dr,lookaheadEndIndex:fr})})}),[at,Le,ur,dr,fr,Qe,st,z,fe,Ce]),hr=l.useCallback(s=>V[s],[V]),mr=l.useRef(null);l.useLayoutEffect(()=>{const s=mr.current;if(mr.current={items:V,offsets:Pe},!Gt||!s||s.items===V)return;const u=Se.current,E=u?.getScrollPosition(),k=typeof E=="number"&&E>=0?E:ht.current,B=Yn(s.items,s.offsets,k);if(!B)return;const J=Gn(B,V,Pe);if(J===null||Math.abs(J-k)<1)return;const Ee=u?u.scrollTo(J):J;ht.current=Ee,Ut(Ee)},[V,Pe,Gt]);const Te=T?.columns,ze=T?.scrollBarWidth??dt?.width??Br,te=l.useMemo(()=>Te?jn({measuredWidth:Je,columns:Te,scrollBarWidth:ze}):null,[Te,Je,ze]),lt=l.useMemo(()=>Te?Pn(Te):"",[Te]),Zr=l.useMemo(()=>T?.showFooter&&Te?On(e):[],[T?.showFooter,Te,e]),$e=te?.maxHScroll??0;l.useEffect(()=>{We(s=>Ct(s,$e))},[$e]);const pr=l.useCallback(s=>We(u=>Ct(u+s,$e)),[$e]),yr=l.useMemo(()=>({iconOverrides:F,showExpandIcons:P,showDirectoryIcons:g,showFileIcons:D,useCanvasExpandIcons:_,expandIconSize:j,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:X,expandIconClassName:C,expandIconStyle:I}),[F,P,g,D,_,j,Q,X,C,I]),gr=l.useMemo(()=>h.jsx(he.VirtualScroll,{ref:Se,itemCount:V.length,getItem:hr,getItemHeight:tr,getItemKey:rr,testId:Vt,contentProps:Kt,locale:M,labels:U,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:ge,onScroll:Jt,onRangeChange:qt,onScrollAdjust:Dt,liveRegion:Ft,className:ee,onWheelHorizontal:se?pr:void 0,background:h.jsxs(h.Fragment,{children:[se&&te?h.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:te.nameWidth},"aria-hidden":"true",children:It}):It,Mt]}),initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:$t,callbackThrottleMs:Bt,contentInsets:Ht,scrollBarOptions:dt,behaviorOptions:Xt,children:(s,u)=>s?se&&T&&te?h.jsx(Fr,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:u+(T.showHeader??!0?2:1),flatIndex:u,onRowFocus:xt,onRowBlur:Et,isSelectedForAria:!!N?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:be,columns:T.columns,numericTemplate:lt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,rowClassName:T.rowClassName,selection:{onEntryClick:w,selectedPath:De,currentPath:gt,mode:R,selectedItems:N,onSelectionChange:m},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:mt},visual:yr},s.entry.absolutePath):h.jsx(Vr,{entry:s.entry,indentLevel:s.indentLevel,originX:et,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!N?.has(s.entry.absolutePath),flatIndex:u,isActive:u===Fe,registerRowRef:ir,onNavigationKeyDown:cr,onRowFocus:xt,onRowBlur:Et,rowHeight:s.rowHeight,entryKindDirectory:Oe,entryKindFile:ne,isDirOpen:be,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:mt},selection:{onEntryClick:w,selectedPath:De,currentPath:gt,mode:R,selectedItems:N,onSelectionChange:m},visual:{iconOverrides:F,showExpandIcons:P,showDirectoryIcons:g,showFileIcons:D,useCanvasExpandIcons:_,expandIconSize:j,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:X,entryClassName:re,entryStyle:we,nameClassName:Y,nameStyle:G,directoryNameClassName:ve,directoryNameStyle:me,fileNameClassName:o,fileNameStyle:f,expandIconClassName:C,expandIconStyle:I}},s.entry.absolutePath):null}),[V.length,hr,tr,rr,Vt,Kt,M,U,Oe,ne,Fe,ir,cr,xt,Et,ae,ge,Jt,qt,Dt,Ft,ee,se,pr,te,It,Mt,zt,Ae,$t,Bt,Ht,dt,Xt,T,lt,be,w,De,gt,R,N,m,t,mt,yr,F,P,g,D,_,j,Q,et,X,re,we,Y,G,ve,me,o,f,C,I]);if(!(T&&te))return h.jsxs("div",{ref:ke,className:Zt,style:Qt,onPointerDownCapture:ot,onMouseDownCapture:ot,children:[_e.length>0&&!Jr&&h.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:oo,onFocus:qr}),gr]});const Qr=T.showHeader??!0,en=T.showFooter??!1,tn={...Qt,"--dt-hscroll":`${He}px`};return h.jsxs("div",{ref:ke,className:A.twMerge(Zt,"dt-grid"),style:tn,role:"treegrid","aria-label":v?void 0:y,"aria-labelledby":v,"aria-multiselectable":R==="multiple"?!0:void 0,"aria-rowcount":V.length+(T.showHeader??!0?1:0),onPointerDownCapture:ot,onMouseDownCapture:ot,children:[Qr&&h.jsx("div",{role:"rowgroup",children:h.jsx(Tn,{columns:T.columns,numericTemplate:lt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:ze,className:T.headerClassName})}),h.jsx("div",{ref:Me,className:"dt-grid-body",children:gr}),$e>0&&h.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:te.nameWidth},"aria-hidden":"true"}),h.jsx(he.ScrollBar,{horizontal:!0,contentSize:te.numericTotal,viewportSize:te.numericVisible,scrollPosition:He,scrollBarWidth:ze,locale:M,labels:U,onScroll:s=>{const u=typeof s=="function"?s(He):s,E=Ct(u,$e);return We(E),E}}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ze},"aria-hidden":"true"})]}),en&&h.jsx("div",{role:"rowgroup",children:h.jsx(Nn,{columns:T.columns,numericTemplate:lt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:ze,allEntries:Zr,className:T.footerClassName})})]})},co=({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 y=JSON.parse(p);return new Set(y)}}catch(p){console.error("[useDirectoryTreeState] Error reading from localStorage",p)}return e}),i=l.useCallback(p=>{n(()=>{c(y=>{const v=new Set(y);return p(v),v})})},[]),d=l.useCallback((p,y)=>{i(v=>{for(const z of p)y(v,z)})},[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 w=l.useCallback(p=>{d([p],(y,v)=>{y.has(v)?y.delete(v):y.add(v)})},[d]),S=l.useCallback(p=>{d([p],(y,v)=>{y.add(v)})},[d]),x=l.useCallback(p=>{d([p],(y,v)=>{y.delete(v)})},[d]),R=l.useCallback(p=>{d(p,(y,v)=>{y.delete(v)})},[d]),N=l.useCallback(p=>{d(p,(y,v)=>{y.add(v)})},[d]),m=l.useCallback(()=>{i(p=>{p.clear()})},[i]),b=l.useCallback(p=>a.has(p),[a]);return{expanded:a,toggle:w,expand:S,collapse:x,collapseMultiple:R,expandMultiple:N,collapseAll:m,isExpanded:b,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Wr;exports.DIRECTORY_TREE_LABEL_KEYS=_t;exports.DirectoryTree=io;exports.directoryTreeClasses=L;exports.resolveDirectoryTreeLabels=Yr;exports.useDirectoryTreeState=co;
|
|
6
|
+
<%s key={someKey} {...props} />`,R,j,Z,j),pe[j+R]=!0)}if(j=null,T!==void 0&&(r(T),j=""+T),i(f)&&(r(f.key),j=""+f.key),"key"in f){T={};for(var fe in f)fe!=="key"&&(T[fe]=f[fe])}else T=f;return j&&d(T,typeof s=="function"?s.displayName||s.name||"Unknown":s),w(s,j,T,o(),ye,C)}function I(s){_(s)?s._store&&(s._store.validated=1):typeof s=="object"&&s!==null&&s.$$typeof===q&&(s._payload.status==="fulfilled"?_(s._payload.value)&&s._payload.value._store&&(s._payload.value._store.validated=1):s._store&&(s._store.validated=1))}function _(s){return typeof s=="object"&&s!==null&&s.$$typeof===b}var m=l,b=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),P=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),H=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=Object.prototype.hasOwnProperty,W=Array.isArray,re=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(s){return s()}};var de,G={},V=m.react_stack_bottom_frame.bind(m,c)(),ve=re(n(c)),pe={};Ue.Fragment=y,Ue.jsx=function(s,f,T){var R=1e4>H.recentlyCreatedOwnerStacks++;return E(s,f,T,!1,R?Error("react-stack-top-frame"):V,R?re(n(s)):ve)},Ue.jsxs=function(s,f,T){var R=1e4>H.recentlyCreatedOwnerStacks++;return E(s,f,T,!0,R?Error("react-stack-top-frame"):V,R?re(n(s)):ve)}})()),Ue}var wr;function fn(){return wr||(wr=1,process.env.NODE_ENV==="production"?ut.exports=un():ut.exports=dn()),ut.exports}var h=fn();function hn({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 mn=ce.forwardRef(hn);function pn({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 yn=ce.forwardRef(pn);function gn({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 bn=ce.forwardRef(gn),Pr="text-[length:var(--dt-font-size-body,0.8125rem)]",Sn=`${Pr} leading-[max(var(--dt-line-height-body,1.25rem),1.5em)]`,Tt=44,vn=12,wn=8,ie=14,En=14,Or=e=>e===void 0?void 0:{fontSize:typeof e=="number"?`${e}px`:e},oe=e=>({width:e,height:e}),M={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 ${Sn}`,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 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 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 ${Pr} 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")},Lt=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},xn=/^[a-z][a-z\d+.-]*:\/\//i,Er=e=>Lt(xn.test(e)?e.split(/[?#]/,1)[0]:e),jr=e=>Lt(e.name)||Er(e.relativePath)||Er(e.absolutePath),Lr=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:o})=>{const c=o?{width:o,height:o}:void 0,i=o?"":"h-4 w-4";return!(r&&e)||n?h.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?h.jsx(mn,{className:i,style:c}):h.jsx(yn,{className:i,style:c})},_t=(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(o=>_t(o,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},Rn={markdown:e=>h.jsx(le.FileMd,{className:"text-sky-500 dark:text-sky-400",style:oe(e)}),pdf:e=>h.jsx(le.FilePdf,{className:"text-red-500 dark:text-red-400",style:oe(e)}),spreadsheet:e=>h.jsx(le.FileXls,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),csv:e=>h.jsx(le.FileCsv,{className:"text-emerald-600 dark:text-emerald-400",style:oe(e)}),document:e=>h.jsx(le.FileDoc,{className:"text-blue-600 dark:text-blue-400",style:oe(e)}),presentation:e=>h.jsx(le.FilePpt,{className:"text-orange-500 dark:text-orange-400",style:oe(e)}),image:e=>h.jsx(le.FileImage,{className:"text-teal-500 dark:text-teal-400",style:oe(e)}),audio:e=>h.jsx(le.FileAudio,{className:"text-pink-500 dark:text-pink-400",style:oe(e)}),video:e=>h.jsx(le.FileVideo,{className:"text-violet-500 dark:text-violet-400",style:oe(e)}),archive:e=>h.jsx(le.FileZip,{className:"text-amber-500 dark:text-amber-400",style:oe(e)}),code:e=>h.jsx(le.FileCode,{className:"text-purple-500 dark:text-purple-400",style:oe(e)}),text:e=>h.jsx(le.FileText,{className:"text-gray-500 dark:text-gray-400",style:oe(e)})},In={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"]},kn=new Map(Object.entries(In).flatMap(([e,t])=>t.map(r=>[r,e]))),Tn=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),Cn=e=>(e??"").split(";",1)[0].trim().toLowerCase(),_n=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"},Nn=(e,t,r,n)=>{const o=Cn(e),c=_n(o),i=kn.get((t||(r?Lt(r):"")).toLowerCase()),S=(Tn.has(o)?[i,c]:[c,i]).find(w=>w!==void 0);return S===void 0?h.jsx(le.FileIcon,{className:"text-gray-400 dark:text-gray-400",style:oe(n)}):Rn[S](n)},Ar=(e,t,r)=>{const{entry:n,isDirectory:o,isExpanded:c,extension:i,mimeType:d}=e;let S;const w=d||n.mimeType;return n.icon!==void 0?S=n.icon:o?S=c&&t?.directoryExpanded||t?.directory||h.jsx(bn,{style:oe(r)}):i&&t?.fileByExtension?.[i]?S=t.fileByExtension[i]:S=t?.file||Nn(w,i,n.name,r),_t(typeof S=="function"?S(e):S,n.absolutePath)},Pn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Mr=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-${Pn(r)}`,String(n)]))},Dr=["color","background","backgroundColor","backgroundImage","backgroundPosition","backgroundSize","backgroundRepeat","backgroundClip","backgroundOrigin","backgroundAttachment","backgroundBlendMode","opacity","boxShadow","filter","backdropFilter","mixBlendMode","borderColor","borderRadius","outline","outlineColor","outlineStyle","outlineWidth","outlineOffset","textShadow","accentColor","caretColor","cursor","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","fontFeatureSettings","fontVariationSettings","fontKerning","letterSpacing","lineHeight","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textDecorationThickness","textUnderlineOffset","textTransform"],Fr=["color","opacity"],On="the row's box belongs to the tree (height: visual.itemHeight, indent: visual.indentSize, icons: visual.typeIconSize, text size: visual.fontSize)",jn=new Set(Dr),Ln=new Set(Fr),xr=(e,t)=>{const r=t===void 0?e.option:`${e.option}.${t}`;return e.absolutePath===void 0?r:`${r} of "${e.absolutePath}"`},$r=(e,t,r,n)=>{if(e!==void 0){if(typeof e!="object"||e===null)throw new RangeError(`${xr(r,void 0)} must be an object of CSS properties or undefined, got ${e===null?"null":typeof e}.`);for(const[o,c]of Object.entries(e))if(c!==void 0&&!t.has(o))throw new RangeError(`${xr(r,o)} cannot be set: ${On}, so ${n}.`)}},Be=(e,t)=>$r(e,jn,t,"a row style accepts only paint and text properties (ROW_STYLE_PROPERTIES)"),An=(e,t)=>$r(e,Ln,t,"the expand icon style accepts only the glyph's colour and opacity (EXPAND_ICON_STYLE_PROPERTIES), and the 14 px expand box is the tree's"),Mn=500,zr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:o,onSelectionChange:c,onEntryClick:i,toggleDirectory:d,onToggleDirectoryRecursive:S})=>{const w=l.useRef(null);return l.useEffect(()=>()=>{w.current&&window.clearTimeout(w.current)},[]),l.useCallback(E=>{E.stopPropagation(),o!=="none"&&!t&&c&&c(e,!n);let I=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{I=!0}}),!(!t||I)&&(w.current?(window.clearTimeout(w.current),w.current=null,S(e)):w.current=window.setTimeout(()=>{d(e.absolutePath),w.current=null},Mn))},[t,e,r,S,d,i,o,c,n])},Br=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Rr=(e,t)=>e.children!==void 0&&t(e.absolutePath),Wr=(e,t)=>({width:e,gridTemplateColumns:t}),Hr=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:o,flatIndex:c,onRowFocus:i,onRowBlur:d,isSelectedForAria:S,rowHeight:w,isDirOpen:E,columns:I,numericTemplate:_,numericTotal:m,nameWidth:b,rowClassName:p,selection:{onEntryClick:y,selectedPath:v,currentPath:$,mode:N="none",selectedItems:P,onSelectionChange:g},expansion:{toggleDirectory:D,onToggleDirectoryRecursive:F},visual:{iconOverrides:O,showExpandIcons:q=!0,showDirectoryIcons:K=!0,showFileIcons:z=!0,useCanvasExpandIcons:H=!1,expandIconSize:ue,typeIconSize:W,fontSize:re,indentSize:de,highlightStyles:G,expandIconClassName:V,expandIconStyle:ve}})=>{Be(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[pe,s]=l.useState(!1),f=e.children!==void 0,T=f&&E(e.absolutePath),R=e.absolutePath===v,ye=e.absolutePath===$,C=!f&&!!P?.has(e.absolutePath),j=f?void 0:jr(e),Z=zr({entry:e,isDirectory:f,isExpanded:T,isItemSelected:C,selectionMode:N,onSelectionChange:g,onEntryClick:y,toggleDirectory:D,onToggleDirectoryRecursive:F}),fe=pe?G?.hoverClassName!==void 0?G.hoverClassName:M.entryHover:"",Re=(()=>{if(f){if(R)return G?.directorySelectedClassName!==void 0?G.directorySelectedClassName:M.entrySelected}else if(R||C)return G?.itemSelectedClassName!==void 0?G.itemSelectedClassName:A.twMerge(R&&M.entrySelected,C&&M.entryItemSelected);return""})(),L=typeof p=="function"?p(e):p,ge=A.twMerge("dt-grid-row cursor-pointer select-none",fe,Re,L,e.className),U=A.twMerge(M.expandIcon,V,(R||C)&&M.expandIconSelected),je=A.twMerge(M.typeIcon,(R||C)&&M.typeIconSelected),ne=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",f&&M.nameDirectory,(R||C)&&M.nameSelected),Q=Lr({isDirectory:f,isExpanded:T,showExpandIcons:q,useCanvasExpandIcons:H,expandIconSize:ue}),se=(f?K:z)?Ar({entry:e,isDirectory:f,isExpanded:T,isSelected:R,isItemSelected:C,extension:j,mimeType:e.mimeType},O,W):null,Ie={indentLevel:t,isDirectory:f,isExpanded:T},[_e,...ke]=I,Le=_e?.render?_e.render(e,Ie):e.label??e.name,we={...pe?G?.hoverStyle:{},...f&&R?G?.directorySelectedStyle:{},...!f&&(R||C)?G?.itemSelectedStyle:{}};return h.jsxs("div",{className:ge,style:{...we,...e.style,height:w},role:"row","aria-expanded":f?T:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":o,"aria-selected":N==="none"?void 0:S,"aria-current":ye?"page":void 0,...Mr(e.data),"data-entry-type":f?"directory":"file","data-entry-expanded":f?String(T):void 0,"data-entry-selected":R?"true":void 0,"data-entry-item-selected":C?"true":void 0,onClick:Z,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onFocus:Y=>i(c,e.absolutePath,Y.currentTarget),onBlur:Y=>d(e.absolutePath,Y.currentTarget),onKeyDown:Y=>{if(Y.key==="Enter"){if(Y.repeat){Y.preventDefault();return}Z(Y)}},tabIndex:0,children:[h.jsxs("div",{className:A.twMerge("dt-grid-name-cell",_e?.className),role:"gridcell",style:{width:b,paddingLeft:Math.max(0,t*de)},children:[(q||H)&&h.jsx("span",{className:U,style:{...ve,width:ie,height:ie},children:Q}),(f?K:z)&&h.jsx("span",{className:je,style:{width:W,height:W},children:se}),h.jsx("span",{className:ne,style:Or(re),children:Le})]}),ke.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Wr(m,_),children:ke.map(Y=>h.jsx("div",{className:A.twMerge("dt-grid-cell",Br(Y.align),Y.className),role:"gridcell",children:Y.render?Y.render(e,Ie):null},Y.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=Rr(e.entry,e.isDirOpen),n=Rr(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});Hr.displayName="DirectoryTreeGridRow";const Yr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:o,scrollBarWidth:c,className:i,nameContent:d,renderCell:S})=>{const[,...w]=t,E=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",I=e==="header"?"dt-grid-header":"dt-grid-footer",_=e==="header"?"columnheader":"gridcell";return h.jsxs("div",{className:A.twMerge(I,"text-gray-600 dark:text-gray-300",i),role:"row",children:[h.jsx("div",{className:A.twMerge(E,"px-1",t[0]?.className),role:_,style:{width:o},children:d}),w.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Wr(n,r),children:w.map(m=>h.jsx("div",{className:A.twMerge("dt-grid-cell",Br(m.align),m.className),role:_,children:S(m)},m.key))})}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},Dn=({columns:e,className:t,...r})=>h.jsx(Yr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),Ir=(e,t)=>typeof e=="function"?e(t):e??null,Fn=({columns:e,allEntries:t,className:r,...n})=>h.jsx(Yr,{kind:"footer",columns:e,className:r,nameContent:Ir(e[0]?.footer,t),renderCell:o=>Ir(o.footer,t),...n}),$n=240,Gr=96,Vr=12,Nt=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},zn=e=>e.slice(1).map(t=>`${Nt(t,Gr)}px`).join(" "),Bn=({measuredWidth:e,columns:t,scrollBarWidth:r=Vr})=>{const n=Nt(t[0],$n),o=t.slice(1).reduce((S,w)=>S+Nt(w,Gr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),d=Math.max(0,o-i);return{nameWidth:n,numericTotal:o,numericVisible:i,maxHScroll:d}},Ct=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Wn=e=>{const t=[],r=n=>{for(const o of n)t.push(o),o.children&&o.children.length>0&&r(o.children)};return r(e),t},Xr=["entryKindDirectory","entryKindFile"],Pt=[...me.VIRTUAL_SCROLL_LABEL_KEYS,...Xr],Ot=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Kr=Object.freeze({en:Object.freeze({...me.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Ot.en}),ja:Object.freeze({...me.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Ot.ja})}),kr=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Hn=e=>{const t={};let r=!1;for(const n of me.VIRTUAL_SCROLL_LABEL_KEYS){const o=Object.hasOwn(e,n)?e[n]:void 0;o!==void 0&&(t[n]=o,r=!0)}return r?t:void 0},Ur=(e,t)=>{const r=me.resolveVirtualScrollLocale(e);if(t===void 0)return Kr[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${kr(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(!Pt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${Pt.join(", ")}`);const c={...me.resolveVirtualScrollLabels(r,Hn(t)),...Ot[r]};for(const i of Xr){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 ${kr(d)}`);c[i]=d}}return Object.freeze(c)},Yn=e=>{const t={};for(const r of me.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Gn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Je=e=>typeof e=="string"?JSON.stringify(e):String(e),jt=(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 ${Je(t)}.`);return t},Vn=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 ${Je(e)}.`)},Xn=({indentSize:e,typeIconSize:t,fontSize:r})=>({indentSize:e===void 0?vn:jt("indentSize",e),typeIconSize:t===void 0?En:jt("typeIconSize",t),fontSize:r===void 0?void 0:Vn(r)}),Kn=({indentSize:e,removeRootIndent:t,hasExpandBox:r})=>t?Math.max(0,e-(r?ie:0)):0,Un=(e,t,r)=>{if(typeof e!="function")return jt("itemHeight",e);const n=e(t,r);if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new RangeError(`[directory-tree] visual.itemHeight returned ${Je(n)} for ${JSON.stringify(t.absolutePath)} (row ${r}); it must return a finite number greater than 0 (px).`);return n},Jn=(e,t,r)=>{const n=t===void 0?wn:t;if(typeof n!="number"||!Number.isFinite(n)||n<=0||n>ie)throw new RangeError(`[directory-tree] visual.expandIconSize must be a finite number greater than 0 and at most ${ie} (the expand box, px) while tree lines are drawn; got ${Je(n)}.`);const{indentSize:o,typeIconSize:c}=e,i=n/2,d=ie+c-n/2;if(o<i||o>d)throw new RangeError(`[directory-tree] visual.indentSize ${Je(o)} 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 ${ie} px expand box + typeIconSize − half the glyph).`);return{indentSize:o,typeIconSize:c,glyphSize:n,originX:r}},qn=({indentSize:e,typeIconSize:t,glyphSize:r})=>Math.min(Math.max(ie+t/2-e,r/2),ie-r/2),Zn=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,o=r-1,c=0;for(;n<=o;){const i=n+o>>>1;e[i]<=t?(c=i,n=i+1):o=i-1}return c},Qn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=Zn(t,r),o=e[n];return o?{path:o.entry.absolutePath,offsetInViewport:r-t[n]}:null},eo=(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},to=(e,t,r)=>{const n=[];for(let o=t;o<r;o++){const c=e[o];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},ro=(e,t,r)=>{const n=[];for(let o=t;o<r;o++){const c=e[o];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},no=(e,t,r,n)=>{const o=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(e.width!==o||e.height!==c)&&(e.width=o,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},oo=(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()},so=(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 o=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(${o}, ${c}, ${i}, ${t})`},ao=(e,t,r,n)=>{if(t.length===0)return;const o=so(r,.14),c=e.strokeStyle,i=e.fillStyle,d=e.lineWidth,S=e.lineCap,w=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const E of t){const I=n??E.size,_=Math.max(0,I/2),m=Math.max(1,Math.round(I*.08)),b=Math.max(1,Math.round(I*.14)),p=Math.max(0,_-m*.8),y=Math.max(0,p*.55);o&&(e.fillStyle=o,e.beginPath(),e.arc(E.centerX,E.centerY,p,0,Math.PI*2),e.fill()),e.lineWidth=m,e.beginPath(),e.arc(E.centerX,E.centerY,Math.max(0,_-m*.3),0,Math.PI*2),e.stroke(),e.lineWidth=b,e.beginPath(),e.moveTo(E.centerX-y,E.centerY),e.lineTo(E.centerX+y,E.centerY),e.stroke(),E.isExpanded||(e.beginPath(),e.moveTo(E.centerX,E.centerY-y),e.lineTo(E.centerX,E.centerY+y),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=d,e.lineCap=S,e.lineJoin=w},Jr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:o,scrollPosition:c,color:i="#a0aec0",strokeWidth:d=1,renderStartIndex:S,renderEndIndex:w,lookaheadEndIndex:E,devicePixelRatio:I,expandGlyphColor:_,expandGlyphSize:m})=>{const b=l.useRef(null),p=l.useRef(null),y=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:o,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:S,renderEndIndex:w,lookaheadEndIndex:E,devicePixelRatio:I,expandGlyphColor:_,expandGlyphSize:m}),v=l.useCallback(()=>{p.current=null;const N=b.current;if(!N)return;const P=N.getContext("2d");if(!P)return;const g=y.current;if(g.width<=0||g.viewportHeight<=0){P.clearRect(0,0,N.width,N.height);return}const D=Number.isFinite(g.devicePixelRatio??NaN)?g.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;no(N,g.width,g.viewportHeight,D);const F=g.segmentsByItem.length,O=typeof g.renderStartIndex=="number"&&Number.isFinite(g.renderStartIndex)?Math.max(0,Math.floor(g.renderStartIndex)):Math.max(0,Math.floor(g.scrollPosition/g.itemHeight)),q=Math.min(F,Math.ceil((g.scrollPosition+g.viewportHeight)/g.itemHeight)),K=(()=>{if(typeof g.renderEndIndex=="number"&&Number.isFinite(g.renderEndIndex)){const W=Math.floor(g.renderEndIndex);return Math.max(Math.min(F,W+1),O)}return Math.max(q,O)})(),z=(()=>{if(typeof g.lookaheadEndIndex=="number"&&Number.isFinite(g.lookaheadEndIndex)){const W=Math.floor(g.lookaheadEndIndex),re=Math.min(F,W+1);return Math.max(re,K)}return Math.max(q,K)})(),H=to(g.segmentsByItem,O,z),ue=ro(g.glyphsByItem,O,z);P.save(),P.scale(D,D),P.clearRect(0,0,g.width,g.viewportHeight),P.translate(0,-g.scrollPosition),P.strokeStyle=g.color,oo(P,H,g.strokeWidth),ao(P,ue,g.expandGlyphColor??g.color,g.expandGlyphSize),P.restore()},[]),$=l.useCallback(()=>{p.current===null&&(p.current=window.requestAnimationFrame(v))},[v]);return l.useEffect(()=>{y.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:o,scrollPosition:c,color:i,strokeWidth:d,renderStartIndex:S,renderEndIndex:w,lookaheadEndIndex:E,devicePixelRatio:I,expandGlyphColor:_,expandGlyphSize:m},$()},[e,t,r,n,o,c,i,d,S,w,E,I,_,m,$]),l.useEffect(()=>()=>{p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)},[]),h.jsx("canvas",{ref:b,className:"pointer-events-none absolute top-0 left-0 z-0"})});Jr.displayName="TreeLineCanvas";const lo=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},Tr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},io=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),co=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:o}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const c=e.get(r.path);if(c!==void 0)return c}if(o!==null){const c=e.get(o);if(c!==void 0)return c}return 0},uo={msOverflowStyle:"none",scrollbarWidth:"none"},fo=()=>{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))},ho=e=>{const t=l.useRef(null),r=t.current;return r!==null&&me.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},Cr=new Set(["top","bottom","center","nearest"]),_r=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},mo={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},po=(e,t,r,n,o)=>{const c=[],i=[];let d=0;const S=(w,E,I)=>{const _=o?[...w].sort(o):w;for(let m=0;m<_.length;m++){const b=_[m],p=m===_.length-1,y=[...I,p],v=b.children!==void 0,$=v&&t(b.absolutePath,b.relativePath);let N=E,P=I;n&&(N=E-1,P=I.slice(1)),c.push({entry:b,indentLevel:N,depth:E,positionInSet:m+1,setSize:_.length}),r&&(N>d&&(d=N),i.push({id:b.absolutePath,name:b.name,absolutePath:b.absolutePath,indentLevel:N,isLastChild:p,isDirectory:v,isExpanded:$,ancestorIsLast:[...P],hideLines:n&&E===0})),v&&$&&b.children&&S(b.children,E+1,y)}};return S(e,0,[]),{flatItems:c,lineItems:i,maxIndent:d}},Nr=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,o=r-1,c=0;for(;n<=o;){const i=n+o>>>1;e[i]<=t?(c=i,n=i+1):o=i-1}return c},yo=(e,t,r,n,o,c)=>{const i=n?.renderStart??Math.max(0,Nr(c,o)),d=t>0?Nr(c,o+t)+r:i+r,S=e>0?Math.min(e-1,Math.max(i,d)):i,w=n?.renderEnd??S,E=e>0?Math.min(e-1,w+r):w;return{renderStart:i,renderEnd:w,lookaheadEnd:E}},go=(e,t,r,n)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const{indentSize:o,typeIconSize:c,glyphSize:i,originX:d}=n,S=Array.from({length:e.length},()=>[]),w=Array.from({length:e.length},()=>[]),E=d+qn(n),I=m=>m*o+E,_=i/2+2;for(let m=0;m<e.length;m++){const b=e[m],p=t[m]??0,y=r[m]??0,v=y+p/2,$=e[m+1],N=v+c/2,P=y+p,g=$!==void 0&&$.indentLevel===b.indentLevel+1&&N<P?{key:`${b.id}-connector-children`,x1:I($.indentLevel),y1:N,x2:I($.indentLevel),y2:P,itemIndex:m}:null;if(b.hideLines){g!==null&&(S[m]=[g]);continue}const D=[];for(let O=0;O<b.indentLevel;O++){if(b.ancestorIsLast[O]??!1)continue;let K=!1;for(let z=m;z<e.length;z++){const H=e[z];if(H.indentLevel>O&&H.ancestorIsLast.length>O&&!H.ancestorIsLast[O]){K=!0;break}if(z>m&&H.indentLevel===O)break}if(K){const z=I(O);D.push({key:`${b.id}-ancestor-${O}`,x1:z,y1:y,x2:z,y2:y+p,itemIndex:m})}}const F=I(b.indentLevel);m>0&&D.push({key:`${b.id}-connector-top`,x1:F,y1:y,x2:F,y2:b.isDirectory?v-_:v,itemIndex:m}),!b.isDirectory&&b.isLastChild&&D.push({key:`${b.id}-connector-horizontal`,x1:F,y1:v,x2:d+b.indentLevel*o+ie,y2:v,itemIndex:m}),b.isLastChild||(b.isDirectory?D.push({key:`${b.id}-connector-bottom`,x1:F,y1:v+_,x2:F,y2:y+p,itemIndex:m}):D.push({key:`${b.id}-connector-bottom`,x1:F,y1:v,x2:F,y2:y+p,itemIndex:m})),g!==null&&D.push(g),S[m]=D,b.isDirectory&&(w[m]=[{key:`${b.id}-glyph`,itemIndex:m,centerX:F,centerY:v,size:i,isExpanded:b.isExpanded}])}return{segmentsByItem:S,glyphsByItem:w}},qr=l.memo(({entry:e,indentLevel:t,originX:r,depth:n,positionInSet:o,setSize:c,isSelectedForAria:i,flatIndex:d,isActive:S,registerRowRef:w,onNavigationKeyDown:E,onRowFocus:I,onRowBlur:_,rowHeight:m,entryKindDirectory:b,entryKindFile:p,isDirOpen:y,expansion:{toggleDirectory:v,onToggleDirectoryRecursive:$},selection:{onEntryClick:N,selectedPath:P,currentPath:g,mode:D="none",selectedItems:F,onSelectionChange:O},visual:{iconOverrides:q,showExpandIcons:K=!0,showDirectoryIcons:z=!0,showFileIcons:H=!0,useCanvasExpandIcons:ue=!1,expandIconSize:W,typeIconSize:re,fontSize:de,indentSize:G,highlightStyles:V,entryClassName:ve,entryStyle:pe,nameClassName:s,nameStyle:f,directoryNameClassName:T,directoryNameStyle:R,fileNameClassName:ye,fileNameStyle:C,expandIconClassName:j,expandIconStyle:Z}})=>{Be(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[fe,Re]=l.useState(!1),L=e.children!==void 0,ge=L&&y(e.absolutePath),U=e.absolutePath===P,je=e.absolutePath===g,ne=!L&&F?.has(e.absolutePath),Q=l.useCallback(ee=>w(d,ee),[w,d]),se=L?void 0:jr(e),Ie=zr({entry:e,isDirectory:L,isExpanded:ge,isItemSelected:!!ne,selectionMode:D,onSelectionChange:O,onEntryClick:N,toggleDirectory:v,onToggleDirectoryRecursive:$}),_e=fe?V?.hoverClassName!==void 0?V.hoverClassName:M.entryHover:"",ke=(()=>{if(L){if(U)return V?.directorySelectedClassName!==void 0?V.directorySelectedClassName:M.entrySelected}else if(U||ne)return V?.itemSelectedClassName!==void 0?V.itemSelectedClassName:A.twMerge(U&&M.entrySelected,ne&&M.entryItemSelected);return""})(),Le=A.twMerge(M.entry,_e,ke,ve,e.className),we=A.twMerge(M.expandIcon,j,(U||ne)&&M.expandIconSelected),Y=A.twMerge(M.typeIcon,(U||ne)&&M.typeIconSelected),We=A.twMerge(M.name,s,L&&M.nameDirectory,L&&T,!L&&ye,(U||ne)&&M.nameSelected),qe=Lr({isDirectory:L,isExpanded:ge,showExpandIcons:K&&t>=0,useCanvasExpandIcons:ue,expandIconSize:W}),dt=(L?z:H)?Ar({entry:e,isDirectory:L,isExpanded:ge,isSelected:U,isItemSelected:!!ne,extension:se,mimeType:e.mimeType},q,re):null,He={...fe?V?.hoverStyle:{},...L&&U?V?.directorySelectedStyle:{},...!L&&(U||ne)?V?.itemSelectedStyle:{}},Ye=Mr(e.data),Ze={width:re,height:re},Qe=Or(de),be=r+t*G;return h.jsxs("div",{className:Le,style:{...Qe,...He,...pe,...e.style,paddingLeft:`${Math.max(0,be)}px`,transform:be<0?`translateX(${be}px)`:void 0,width:be<0?`calc(100% + ${-be}px)`:void 0,height:`${m}px`},...Ye,"data-entry-type":L?"directory":"file","data-entry-expanded":L?String(ge):void 0,"data-entry-selected":U?"true":void 0,"data-entry-item-selected":ne?"true":void 0,onClick:Ie,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),onFocus:ee=>I(d,e.absolutePath,ee.currentTarget),onBlur:ee=>_(e.absolutePath,ee.currentTarget),ref:Q,onKeyDown:ee=>{if(ee.key==="Enter"||ee.key===" "){ee.preventDefault(),ee.repeat||Ie(ee);return}E(ee,d)},tabIndex:S?0:-1,role:"treeitem","aria-expanded":L?ge:void 0,"aria-level":n+1,"aria-posinset":o,"aria-setsize":c,"aria-selected":D==="none"?void 0:i,"aria-current":je?"page":void 0,"aria-label":`${e.name} (${L?b:p})`,children:[(K||ue)&&h.jsx("span",{className:we,style:{...Z,width:ie,height:ie},children:qe}),(L?z:H)&&h.jsx("span",{className:Y,style:Ze,children:dt}),h.jsx("span",{className:We,style:{...Qe,...f,...L?R:C},"data-entry-type":L?"directory":"file","data-entry-role":"name",children:e.label??e.name})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,o=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&&o===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});qr.displayName="DirectoryEntryItem";const Zr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Zr(r)));return t},bo=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:o,isPending:c,alwaysExpanded:i=!1,doubleClickAction:d="recursive"},selection:{onEntryClick:S,selectedPath:w,currentPath:E,mode:I="none",selectedItems:_,onSelectionChange:m},visual:{className:b,style:p,ariaLabel:y,ariaLabelledBy:v,lineColor:$="#A0AEC0",showTreeLines:N=!0,showExpandIcons:P=!0,showDirectoryIcons:g=!0,showFileIcons:D=!0,iconOverrides:F,expandIconSize:O,typeIconSize:q,fontSize:K,indentSize:z,itemHeight:H=Tt,removeRootIndent:ue=!1,highlightStyles:W,entryClassName:re,entryStyle:de,nameClassName:G,nameStyle:V,directoryNameClassName:ve,directoryNameStyle:pe,fileNameClassName:s,fileNameStyle:f,expandIconClassName:T,expandIconStyle:R}={},virtualScroll:ye,grid:C,sort:j,locale:Z,labels:fe,ref:Re})=>{const L=me.resolveVirtualScrollLocale(Z),ge=l.useMemo(()=>Ur(Z,fe),[Z,fe]),U=ho(Yn(ge)),{entryKindDirectory:je,entryKindFile:ne}=ge,Q=l.useMemo(()=>Xn({indentSize:z,typeIconSize:q,fontSize:K}),[z,q,K]);l.useMemo(()=>{Be(de,{option:"visual.entryStyle"}),Be(W?.hoverStyle,{option:"visual.highlightStyles.hoverStyle"}),Be(W?.directorySelectedStyle,{option:"visual.highlightStyles.directorySelectedStyle"}),Be(W?.itemSelectedStyle,{option:"visual.highlightStyles.itemSelectedStyle"}),An(R,{option:"visual.expandIconStyle"})},[de,W,R]);const se=C!==void 0,[Ie,_e]=l.useState(!1),ke=l.useRef(null),Le=l.useRef(null),we=l.useRef(null),[Y,We]=l.useState(0),[qe,dt]=l.useState(0),[He,Ye]=l.useState(0),[Ze,Qe]=l.useState(null),{overscanCount:be=15,className:ee,background:At,onScroll:Mt,onRangeChange:Dt,onScrollAdjust:Ft,liveRegion:$t,initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Bt,callbackThrottleMs:Wt=5,contentInsets:Ht,onItemFocus:Yt,viewportHeightOverride:ae,scrollBarOptions:ft,behaviorOptions:Gt,preserveScrollAnchor:Vt=!1,getItemKey:Qr,testId:Xt,contentProps:ht}=ye??{},Kt=l.useMemo(()=>se?{...ht,role:"rowgroup"}:{...ht,role:"tree","aria-label":v?void 0:y,"aria-labelledby":v,"aria-multiselectable":I==="multiple"?!0:void 0},[se,ht,y,v,I]),Ut=l.useMemo(()=>({...Gt,enableKeyboardNavigation:!1}),[Gt]),[et,Jt]=l.useState(typeof Ae=="number"?Ae:0),mt=l.useRef(typeof Ae=="number"?Ae:0),qt=l.useCallback((a,u)=>{mt.current=a,Jt(a),Mt?.(a,u)},[Mt]),Zt=l.useCallback(a=>{const{renderingStartIndex:u,renderingEndIndex:x}=a;Qe(k=>k&&k.renderStart===u&&k.renderEnd===x?k:{renderStart:u,renderEnd:x}),Dt?.(a)},[Dt]);l.useEffect(()=>{_e(!0),fo()},[]),l.useEffect(()=>{const a=ke.current,u=se?Le.current:a,x=()=>{if(a){const B=a.clientWidth;dt(J=>Math.abs(J-B)>1?B:J)}if(typeof ae=="number")We(B=>Math.abs(B-ae)>1?ae:B);else if(u){const B=u.clientHeight;We(J=>Math.abs(J-B)>1?B:J)}};if(!(a||u))return We(0);x();const k=new ResizeObserver(x);return a&&k.observe(a),u&&u!==a&&k.observe(u),()=>k.disconnect()},[ae,se]);const Me=typeof ae=="number"?ae:Y,Se=l.useCallback(a=>i||(Ie?r(a):!1),[Ie,r,i]),Qt=A.twMerge(M.container,c&&M.containerPending,b),er=l.useMemo(()=>({...uo,...p??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[p,ae]),pt=l.useCallback((a,u)=>{const x=[a.absolutePath,...Zr(a)],k=u||d;if(x.every(xe=>Se(xe)))return o(x);if(x.every(xe=>!Se(xe))||k==="recursive")return n(x);if(k==="toggle")return o(x);console.warn(`[DirectoryTree] Unknown double click action: ${k}. No action taken.`)},[Se,n,o,d]),yt=se?!1:ue,{flatItems:Ne,lineItems:gt,maxIndent:tr}=l.useMemo(()=>po(e,Se,N,yt,j),[e,Se,N,yt,j]),tt=Kn({indentSize:Q.indentSize,removeRootIndent:yt,hasExpandBox:P||N}),he=l.useMemo(()=>N?Jn(Q,O,tt):null,[N,Q,O,tt]),X=l.useMemo(()=>Ne.map((a,u)=>({...a,rowHeight:Un(H,a.entry,u)})),[Ne,H]),Te=l.useMemo(()=>X.map(a=>a.rowHeight),[X]),Pe=l.useMemo(()=>{const a=new Array(Te.length+1);a[0]=0;for(let u=0;u<Te.length;u++)a[u+1]=a[u]+Te[u];return a},[Te]),rr=l.useCallback(a=>X[a]?.rowHeight??Tt,[X]),en=l.useCallback(a=>X[a]?.entry.absolutePath??a,[X]),nr=Qr??en,De=w??null,bt=E??null,[or,Ge]=l.useState(()=>({selectedPath:De,selectionGeneration:0,anchor:null})),St=Tr(or,De);St!==or&&Ge(a=>Tr(a,De));const rt=l.useMemo(()=>lo(Ne),[Ne]),Fe=l.useMemo(()=>co(rt,St),[rt,St]),Ve=l.useRef(new Map),nt=l.useRef(null),[ot]=l.useState(Gn),Xe=l.useRef(null),[tn,sr]=l.useState(!0),vt=l.useRef(Ne);vt.current=Ne;const ar=l.useRef(Se);ar.current=Se;const wt=l.useRef(t);wt.current=t;const lr=l.useRef(rt);lr.current=rt;const Et=l.useRef(Fe);Et.current=Fe;const ir=l.useRef(Yt);ir.current=Yt;const Oe=l.useCallback(a=>{const u=we.current;return!u||u.getViewportSize()<=0?!1:(u.scrollToIndex(a,{align:"nearest"}),!0)},[]),Ee=l.useCallback(a=>{const u=Ve.current.get(a);if(u===void 0){Xe.current=a,Oe(a)||(Xe.current=null);return}Xe.current=null,Oe(a),u.focus({preventScroll:!0})},[Oe]),cr=l.useCallback((a,u)=>{if(u)Ve.current.set(a,u),Xe.current===a?(Xe.current=null,u.focus({preventScroll:!0})):u.contains(u.ownerDocument.activeElement)&&Ge(x=>x.anchor===null?x:{...x,anchor:{...x.anchor,focused:!0}});else{const x=Ve.current.get(a);Ve.current.delete(a),x?.contains(x.ownerDocument.activeElement)&&Ge(k=>k.anchor===null?k:{...k,anchor:{...k.anchor,focused:!1}})}a===Et.current&&sr(u!==null)},[]);l.useLayoutEffect(()=>{sr(Ve.current.has(Fe))},[Fe]);const xt=l.useCallback((a,u,x)=>{const k=nt.current===x;nt.current=null,k||(Ge(B=>io(B,u)),ot.landedOn(x)||Oe(a)),ir.current?.(a)},[Oe,ot]),st=l.useCallback(a=>ot.mark(a.nativeEvent),[ot]),Rt=l.useCallback((a,u)=>{const{ownerDocument:x}=u;if(!x.hasFocus()&&u.contains(x.activeElement)){nt.current=u;return}nt.current=null,Ge(k=>k.anchor!==null&&k.anchor.path===a?{...k,anchor:{...k.anchor,focused:!1}}:k)},[]),rn=l.useCallback(()=>Ee(Et.current),[Ee]),It=l.useCallback((a,u)=>{const x=_r(u),k=vt.current.length;if(!Number.isInteger(a)||a<0||a>=k)throw new RangeError(`[directory-tree] scrollToIndex: ${String(a)} is not a row index (${k===0?"the tree has no rows":`expected an integer in 0..${String(k-1)}`}).`);if(x==="nearest"){Oe(a);return}we.current?.scrollToIndex(a,{align:x})},[Oe]);l.useImperativeHandle(Re,()=>({scrollToIndex:It,scrollToPath:(a,u)=>{_r(u);const x=lr.current.get(a);return x===void 0?!1:(It(x,u),!0)},getScrollAnchor:()=>we.current?.getScrollAnchor()??null}),[It]);const ur=l.useCallback((a,u)=>{if(a.altKey||a.ctrlKey||a.metaKey)return;const x=vt.current,k=x.length-1;if(k<0)return;const B=x[u],J=B?.entry.children!==void 0,xe=J&&ar.current(B.entry.absolutePath);switch(a.key){case"ArrowDown":a.preventDefault(),Ee(Math.min(u+1,k));break;case"ArrowUp":a.preventDefault(),Ee(Math.max(u-1,0));break;case"Home":a.preventDefault(),Ee(0);break;case"End":a.preventDefault(),Ee(k);break;case"ArrowRight":a.preventDefault(),J&&!xe?wt.current(B.entry.absolutePath):J&&u<k&&x[u+1].depth>B.depth&&Ee(u+1);break;case"ArrowLeft":{if(a.preventDefault(),J&&xe){wt.current(B.entry.absolutePath);break}const ln=B?.depth??0;for(let ct=u-1;ct>=0;ct--)if(x[ct].depth<ln){Ee(ct);break}break}}},[Ee]),at=l.useMemo(()=>he===null||gt.length===0?{segmentsByItem:[],glyphsByItem:[]}:go(gt,Te,Pe,he),[gt,Te,Pe,he]),lt=l.useMemo(()=>he===null||e.length===0?0:he.originX+tr*he.indentSize+ie+he.typeIconSize,[e.length,tr,he]),{renderStart:dr,renderEnd:fr,lookaheadEnd:hr}=l.useMemo(()=>yo(X.length,Me,be,Ze,et,Pe),[X.length,Me,be,Ze,et,Pe]),kt=l.useMemo(()=>he===null||lt<=0||Me<=0||at.segmentsByItem.length===0?null:h.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:h.jsx("div",{className:"absolute top-0 left-0",style:{width:lt,height:Me},children:h.jsx(Jr,{segmentsByItem:at.segmentsByItem,glyphsByItem:at.glyphsByItem,itemHeight:Te[0]??Tt,width:lt,viewportHeight:Me,scrollPosition:et,color:$,expandGlyphColor:$,expandGlyphSize:he.glyphSize,renderStartIndex:dr,renderEndIndex:fr,lookaheadEndIndex:hr})})}),[lt,Me,dr,fr,hr,et,at,$,he,Te]),mr=l.useCallback(a=>X[a],[X]),pr=l.useRef(null);l.useLayoutEffect(()=>{const a=pr.current;if(pr.current={items:X,offsets:Pe},!Vt||!a||a.items===X)return;const u=we.current,x=u?.getScrollPosition(),k=typeof x=="number"&&x>=0?x:mt.current,B=Qn(a.items,a.offsets,k);if(!B)return;const J=eo(B,X,Pe);if(J===null||Math.abs(J-k)<1)return;const xe=u?u.scrollTo(J):J;mt.current=xe,Jt(xe)},[X,Pe,Vt]);const Ce=C?.columns,$e=C?.scrollBarWidth??ft?.width??Vr,te=l.useMemo(()=>Ce?Bn({measuredWidth:qe,columns:Ce,scrollBarWidth:$e}):null,[Ce,qe,$e]),it=l.useMemo(()=>Ce?zn(Ce):"",[Ce]),nn=l.useMemo(()=>C?.showFooter&&Ce?Wn(e):[],[C?.showFooter,Ce,e]),ze=te?.maxHScroll??0;l.useEffect(()=>{Ye(a=>Ct(a,ze))},[ze]);const yr=l.useCallback(a=>Ye(u=>Ct(u+a,ze)),[ze]),gr=l.useMemo(()=>({iconOverrides:F,showExpandIcons:P,showDirectoryIcons:g,showFileIcons:D,useCanvasExpandIcons:N,expandIconSize:O,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:W,expandIconClassName:T,expandIconStyle:R}),[F,P,g,D,N,O,Q,W,T,R]),br=l.useMemo(()=>h.jsx(me.VirtualScroll,{ref:we,itemCount:X.length,getItem:mr,getItemHeight:rr,getItemKey:nr,testId:Xt,contentProps:Kt,locale:L,labels:U,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:be,onScroll:qt,onRangeChange:Zt,onScrollAdjust:Ft,liveRegion:$t,className:ee,onWheelHorizontal:se?yr:void 0,background:h.jsxs(h.Fragment,{children:[se&&te?h.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:te.nameWidth},"aria-hidden":"true",children:kt}):kt,At]}),initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Bt,callbackThrottleMs:Wt,contentInsets:Ht,scrollBarOptions:ft,behaviorOptions:Ut,children:(a,u)=>a?se&&C&&te?h.jsx(Hr,{entry:a.entry,indentLevel:a.indentLevel,positionInSet:a.positionInSet,setSize:a.setSize,rowIndex:u+(C.showHeader??!0?2:1),flatIndex:u,onRowFocus:xt,onRowBlur:Rt,isSelectedForAria:!!_?.has(a.entry.absolutePath),rowHeight:a.rowHeight,isDirOpen:Se,columns:C.columns,numericTemplate:it,numericTotal:te.numericTotal,nameWidth:te.nameWidth,rowClassName:C.rowClassName,selection:{onEntryClick:S,selectedPath:De,currentPath:bt,mode:I,selectedItems:_,onSelectionChange:m},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:pt},visual:gr},a.entry.absolutePath):h.jsx(qr,{entry:a.entry,indentLevel:a.indentLevel,originX:tt,depth:a.depth,positionInSet:a.positionInSet,setSize:a.setSize,isSelectedForAria:!!_?.has(a.entry.absolutePath),flatIndex:u,isActive:u===Fe,registerRowRef:cr,onNavigationKeyDown:ur,onRowFocus:xt,onRowBlur:Rt,rowHeight:a.rowHeight,entryKindDirectory:je,entryKindFile:ne,isDirOpen:Se,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:pt},selection:{onEntryClick:S,selectedPath:De,currentPath:bt,mode:I,selectedItems:_,onSelectionChange:m},visual:{iconOverrides:F,showExpandIcons:P,showDirectoryIcons:g,showFileIcons:D,useCanvasExpandIcons:N,expandIconSize:O,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:W,entryClassName:re,entryStyle:de,nameClassName:G,nameStyle:V,directoryNameClassName:ve,directoryNameStyle:pe,fileNameClassName:s,fileNameStyle:f,expandIconClassName:T,expandIconStyle:R}},a.entry.absolutePath):null}),[X.length,mr,rr,nr,Xt,Kt,L,U,je,ne,Fe,cr,ur,xt,Rt,ae,be,qt,Zt,Ft,$t,ee,se,yr,te,kt,At,zt,Ae,Bt,Wt,Ht,ft,Ut,C,it,Se,S,De,bt,I,_,m,t,pt,gr,F,P,g,D,N,O,Q,tt,W,re,de,G,V,ve,pe,s,f,T,R]);if(!(C&&te))return h.jsxs("div",{ref:ke,className:Qt,style:er,onPointerDownCapture:st,onMouseDownCapture:st,children:[Ne.length>0&&!tn&&h.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:mo,onFocus:rn}),br]});const on=C.showHeader??!0,sn=C.showFooter??!1,an={...er,"--dt-hscroll":`${He}px`};return h.jsxs("div",{ref:ke,className:A.twMerge(Qt,"dt-grid"),style:an,role:"treegrid","aria-label":v?void 0:y,"aria-labelledby":v,"aria-multiselectable":I==="multiple"?!0:void 0,"aria-rowcount":X.length+(C.showHeader??!0?1:0),onPointerDownCapture:st,onMouseDownCapture:st,children:[on&&h.jsx("div",{role:"rowgroup",children:h.jsx(Dn,{columns:C.columns,numericTemplate:it,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:$e,className:C.headerClassName})}),h.jsx("div",{ref:Le,className:"dt-grid-body",children:br}),ze>0&&h.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:te.nameWidth},"aria-hidden":"true"}),h.jsx(me.ScrollBar,{horizontal:!0,contentSize:te.numericTotal,viewportSize:te.numericVisible,scrollPosition:He,scrollBarWidth:$e,locale:L,labels:U,onScroll:a=>{const u=typeof a=="function"?a(He):a,x=Ct(u,ze);return Ye(x),x}}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:$e},"aria-hidden":"true"})]}),sn&&h.jsx("div",{role:"rowgroup",children:h.jsx(Fn,{columns:C.columns,numericTemplate:it,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:$e,allEntries:nn,className:C.footerClassName})})]})},So=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[o,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const p=window.localStorage.getItem(t);if(p){const y=JSON.parse(p);return new Set(y)}}catch(p){console.error("[useDirectoryTreeState] Error reading from localStorage",p)}return e}),i=l.useCallback(p=>{n(()=>{c(y=>{const v=new Set(y);return p(v),v})})},[]),d=l.useCallback((p,y)=>{i(v=>{for(const $ of p)y(v,$)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(o)))}catch(p){console.warn(`Error setting localStorage key "${t}":`,p)}},[o,t]);const S=l.useCallback(p=>{d([p],(y,v)=>{y.has(v)?y.delete(v):y.add(v)})},[d]),w=l.useCallback(p=>{d([p],(y,v)=>{y.add(v)})},[d]),E=l.useCallback(p=>{d([p],(y,v)=>{y.delete(v)})},[d]),I=l.useCallback(p=>{d(p,(y,v)=>{y.delete(v)})},[d]),_=l.useCallback(p=>{d(p,(y,v)=>{y.add(v)})},[d]),m=l.useCallback(()=>{i(p=>{p.clear()})},[i]),b=l.useCallback(p=>o.has(p),[o]);return{expanded:o,toggle:S,expand:w,collapse:E,collapseMultiple:I,expandMultiple:_,collapseAll:m,isExpanded:b,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Kr;exports.DIRECTORY_TREE_LABEL_KEYS=Pt;exports.DirectoryTree=bo;exports.EXPAND_ICON_STYLE_PROPERTIES=Fr;exports.ROW_STYLE_PROPERTIES=Dr;exports.directoryTreeClasses=M;exports.resolveDirectoryTreeLabels=Ur;exports.useDirectoryTreeState=So;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { DirectoryTree, directoryTreeClasses } from "./DirectoryTree.tsx";
|
|
2
|
+
export { type DirectoryTreeExpandIconStyle, type DirectoryTreeRowStyle, EXPAND_ICON_STYLE_PROPERTIES, ROW_STYLE_PROPERTIES } from "./hostStyle.ts";
|
|
2
3
|
export { DIRECTORY_TREE_LABEL_CATALOGS, DIRECTORY_TREE_LABEL_KEYS, type DirectoryTreeLabelOverrides, type DirectoryTreeLabels, type DirectoryTreeLocale, resolveDirectoryTreeLabels } from "./labels.ts";
|
|
3
4
|
export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeHandle, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeScrollAlign, DirectoryTreeScrollOptions, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
|
|
4
5
|
export { useDirectoryTreeState } from "./useDirectoryTreeState.ts";
|