@aiquants/directory-tree 3.11.2 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/DirectoryTree.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +967 -897
- package/dist/labels.d.ts +23 -0
- package/dist/types.d.ts +7 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ A high-performance React directory tree component with virtualization, file sele
|
|
|
13
13
|
- **🔧 TypeScript**: Complete TypeScript support with comprehensive type definitions
|
|
14
14
|
- **💾 State Persistence**: Automatic localStorage persistence for expansion states
|
|
15
15
|
- **🎯 Flexible Selection**: Support for none, single, or multiple selection modes
|
|
16
|
+
- **🌐 Localization**: Row kind words and the embedded scroll chrome ship in English (default) and Japanese via `locale`, with per-key `labels` overrides. See [Localization](#localization)
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -32,6 +33,8 @@ This package requires the following peer dependencies:
|
|
|
32
33
|
npm install react react-dom @aiquants/virtualscroll
|
|
33
34
|
```
|
|
34
35
|
|
|
36
|
+
`@aiquants/virtualscroll` must be 3.7.0 or later (it supplies the `locale` / `labels` chrome catalog).
|
|
37
|
+
|
|
35
38
|
## Quick Start
|
|
36
39
|
|
|
37
40
|
```tsx
|
|
@@ -122,6 +125,8 @@ The main component for rendering the directory tree.
|
|
|
122
125
|
| `selection` | `object` | Yes | Configuration for item selection |
|
|
123
126
|
| `visual` | `object` | No | Visual customization options |
|
|
124
127
|
| `virtualScroll` | `DirectoryTreeVirtualScrollOptions` | No | Pass-through options for the underlying VirtualScroll component |
|
|
128
|
+
| `locale` | `DirectoryTreeLocale` (`"en"` \| `"ja"`) | No | UI chrome language (default `"en"`). See [Localization](#localization) |
|
|
129
|
+
| `labels` | `DirectoryTreeLabelOverrides` | No | Per-key overrides over the catalog of `locale`. See [Localization](#localization) |
|
|
125
130
|
|
|
126
131
|
#### Expansion Options (`expansion`)
|
|
127
132
|
|
|
@@ -179,6 +184,10 @@ The main component for rendering the directory tree.
|
|
|
179
184
|
- `behaviorOptions`: Configure scrolling behavior (pointer drag, keyboard navigation, inertia, wheel speed).
|
|
180
185
|
- `onScroll`, `onRangeChange`, `className`, `background`, `initialScrollIndex`, `initialScrollOffset`: Hook into scroll lifecycle or provide bespoke styling.
|
|
181
186
|
|
|
187
|
+
The engine's `locale` / `labels` are **not** accepted here (a type error): the one surface for the UI chrome
|
|
188
|
+
language is the top-level `locale` / `labels` of `DirectoryTree`, which also reaches the row kind words and the
|
|
189
|
+
grid-mode horizontal scrollbar. See [Localization](#localization).
|
|
190
|
+
|
|
182
191
|
Example:
|
|
183
192
|
|
|
184
193
|
```tsx
|
|
@@ -479,6 +488,74 @@ const { toggle, isExpanded, expandMultiple, collapseMultiple } = useDirectoryTre
|
|
|
479
488
|
});
|
|
480
489
|
```
|
|
481
490
|
|
|
491
|
+
## Localization
|
|
492
|
+
|
|
493
|
+
`DirectoryTree` renders nine strings of its own (UI chrome): the kind word of each classic-mode row's
|
|
494
|
+
accessible name (`"src (directory)"`, `"package.json (file)"`) and the seven chrome strings of the embedded
|
|
495
|
+
`@aiquants/virtualscroll` (scrollbar arrow labels, scroll-to-edge pills, empty state). They come from a built-in
|
|
496
|
+
catalog in English (`"en"`, the default) and Japanese (`"ja"`). Entry names, column headers / footers and the
|
|
497
|
+
tree's own accessible name (`visual.ariaLabel`) are your content and are never translated.
|
|
498
|
+
|
|
499
|
+
```tsx
|
|
500
|
+
<DirectoryTree {...commonProps} locale="ja" />
|
|
501
|
+
|
|
502
|
+
// Any subset of keys can be overridden on top of the chosen catalog
|
|
503
|
+
<DirectoryTree {...commonProps} locale="ja" labels={{ entryKindDirectory: "フォルダ", noItems: "ファイルがありません" }} />
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
| Key | `en` | `ja` | Where it appears |
|
|
507
|
+
| --- | --- | --- | --- |
|
|
508
|
+
| `entryKindDirectory` | `directory` | `ディレクトリ` | Directory row accessible name `${name} (${kind})` (classic mode) |
|
|
509
|
+
| `entryKindFile` | `file` | `ファイル` | File row accessible name `${name} (${kind})` (classic mode) |
|
|
510
|
+
| `scrollUp` | `Scroll up` | `上へスクロール` | Vertical scrollbar up-arrow `aria-label` |
|
|
511
|
+
| `scrollDown` | `Scroll down` | `下へスクロール` | Vertical scrollbar down-arrow `aria-label` |
|
|
512
|
+
| `scrollLeft` | `Scroll left` | `左へスクロール` | Grid-mode horizontal scrollbar left-arrow `aria-label` |
|
|
513
|
+
| `scrollRight` | `Scroll right` | `右へスクロール` | Grid-mode horizontal scrollbar right-arrow `aria-label` |
|
|
514
|
+
| `scrollToTop` | `Top` | `先頭へ` | Scroll-to-top pill (`scrollBarOptions.enableScrollToTopBottomButtons`) |
|
|
515
|
+
| `scrollToBottom` | `Bottom` | `末尾へ` | Scroll-to-bottom pill (same option) |
|
|
516
|
+
| `noItems` | `No items` | `項目がありません` | Empty state when `entries` is `[]` |
|
|
517
|
+
|
|
518
|
+
The seven engine rows are `VIRTUAL_SCROLL_LABEL_CATALOGS` of `@aiquants/virtualscroll`, reused by value. Grid-mode
|
|
519
|
+
rows carry no row-level accessible name (their cells name them), so the kind words apply to classic mode only.
|
|
520
|
+
|
|
521
|
+
- **Default**: omitting `locale` is identical to `locale="en"`, and the `en` catalog is the historical English
|
|
522
|
+
wording byte for byte, so hosts that pass nothing see no DOM change.
|
|
523
|
+
- **No negotiation**: `locale` accepts exactly `"en"` or `"ja"`. Anything else (`"ja-JP"`, `"EN"`, `""`, `null`)
|
|
524
|
+
throws a `RangeError` at render. Map `navigator.language` (or your own setting) to a supported locale yourself.
|
|
525
|
+
- **Validation** (`resolveDirectoryTreeLabels(locale, overrides)`, also exported): `undefined` overrides return the
|
|
526
|
+
frozen catalog itself; otherwise `labels` must be a plain object (prototype `Object.prototype` or `null`; arrays
|
|
527
|
+
and class instances are rejected), only its own properties are read, an unknown key is a `RangeError`, an
|
|
528
|
+
`undefined` value keeps the catalog value, and every present value must be a string with non-whitespace
|
|
529
|
+
content. The result is frozen. The engine keys are validated by the engine's `resolveVirtualScrollLabels`
|
|
530
|
+
(`[virtualscroll]` messages), the own keys by the package (`[directory-tree]` messages).
|
|
531
|
+
- **Forwarding**: `locale` and the seven engine keys reach both the embedded `VirtualScroll` and the grid-mode
|
|
532
|
+
horizontal `ScrollBar`. An inline `labels={{…}}` object is fine: the forwarded engine labels keep their identity
|
|
533
|
+
while the strings are unchanged, so the virtualized body is not re-rendered.
|
|
534
|
+
|
|
535
|
+
Exports: `DirectoryTreeLocale`, `DirectoryTreeLabels`, `DirectoryTreeLabelOverrides`, `DIRECTORY_TREE_LABEL_KEYS`,
|
|
536
|
+
`DIRECTORY_TREE_LABEL_CATALOGS`, `resolveDirectoryTreeLabels`.
|
|
537
|
+
|
|
538
|
+
### Migrating to 3.12.0
|
|
539
|
+
|
|
540
|
+
- **Runtime requirement — update `@aiquants/virtualscroll` in the same change**: 3.12.0 imports
|
|
541
|
+
`VIRTUAL_SCROLL_LABEL_KEYS`, `VIRTUAL_SCROLL_LABEL_CATALOGS`, `resolveVirtualScrollLocale` and
|
|
542
|
+
`resolveVirtualScrollLabels`, which exist only in `@aiquants/virtualscroll` >= 3.7.0 (the published peer range is
|
|
543
|
+
`^3.7.0`). A `^3.11.x` caret on this package accepts 3.12.0, so a host that updates only `@aiquants/directory-tree`
|
|
544
|
+
while its lockfile keeps virtualscroll 3.6.x gets just an unmet-peer warning from pnpm's default (non-strict) peer
|
|
545
|
+
handling, and then a missing-export failure at build or load time. Bump both together, e.g.
|
|
546
|
+
`"@aiquants/virtualscroll": "^3.6.1"` → `"^3.7.0"`.
|
|
547
|
+
- **Default output is unchanged**: omitting `locale` renders the same English DOM as 3.11.x. To show the chrome in
|
|
548
|
+
Japanese (`ディレクトリ` / `ファイル`, `上へスクロール`, `項目がありません`, …) pass `locale="ja"` explicitly —
|
|
549
|
+
there is no language negotiation.
|
|
550
|
+
- **New API**: the top-level `locale` / `labels` props and the exports listed above.
|
|
551
|
+
- **`virtualScroll.locale` / `virtualScroll.labels` are rejected by the type** (they were accepted but silently
|
|
552
|
+
dropped before, so they never had an effect): move them to the top-level `locale` / `labels`.
|
|
553
|
+
- **`DirectoryEntryItemProps` gains two required fields**, `entryKindDirectory` / `entryKindFile` (the resolved kind
|
|
554
|
+
words; take them from `resolveDirectoryTreeLabels(locale, labels)`). Only code that builds this exported type
|
|
555
|
+
itself is affected.
|
|
556
|
+
- **`locale` is not a formatting locale**: this package has no BCP 47 `formatLocale` axis. `locale` switches the UI
|
|
557
|
+
chrome language only; entry names, column headers / footers and `visual.ariaLabel` remain your content.
|
|
558
|
+
|
|
482
559
|
## TypeScript Support
|
|
483
560
|
|
|
484
561
|
This package is written in TypeScript and provides comprehensive type definitions. All components and hooks are fully typed for the best development experience.
|
package/dist/DirectoryTree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { directoryTreeClasses } from "./entryRendering.tsx";
|
|
2
2
|
import { DirectoryTreeProps, TreeLineGeometry, TreeLineItemInfo } from "./types.ts";
|
|
3
3
|
export declare const buildTreeLineGeometry: (items: TreeLineItemInfo[], itemHeights: number[], itemOffsets: number[], segmentWidth: number, includeGlyphs: boolean, glyphSizeOverride?: number) => TreeLineGeometry;
|
|
4
|
-
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, }, virtualScroll: virtualScrollOptions, grid, sort, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
4
|
+
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
5
5
|
export { directoryTreeClasses };
|
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"),ue=require("@aiquants/virtualscroll"),D=require("tailwind-merge"),F=require("@phosphor-icons/react");function br(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ie=br(l);var Ye={exports:{}},Ae={};var Wt;function gr(){if(Wt)return Ae;Wt=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,n,c){var i=null;if(c!==void 0&&(i=""+c),n.key!==void 0&&(i=""+n.key),"key"in n){c={};for(var f in n)f!=="key"&&(c[f]=n[f])}else c=n;return n=c.ref,{$$typeof:e,type:r,key:i,ref:n!==void 0?n:null,props:c}}return Ae.Fragment=t,Ae.jsx=s,Ae.jsxs=s,Ae}var Me={};var Bt;function xr(){return Bt||(Bt=1,process.env.NODE_ENV!=="production"&&(function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===B?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case y:return"Fragment";case C:return"Profiler";case S:return"StrictMode";case W:return"Suspense";case _:return"SuspenseList";case J:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case m:return"Portal";case E:return a.displayName||"Context";case I:return(a._context.displayName||"Context")+".Consumer";case p:var b=a.render;return a=a.displayName,a||(a=b.displayName||b.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return b=a.displayName||null,b!==null?b:e(a.type)||"Memo";case te:b=a._payload,a=a._init;try{return e(a(b))}catch{}}return null}function t(a){return""+a}function s(a){try{t(a);var b=!1}catch{b=!0}if(b){b=console;var T=b.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return T.call(b,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),t(a)}}function r(a){if(a===y)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===te)return"<...>";try{var b=e(a);return b?"<"+b+">":"<...>"}catch{return"<...>"}}function n(){var a=re.A;return a===null?null:a.getOwner()}function c(){return Error("react-stack-top-frame")}function i(a){if(ne.call(a,"key")){var b=Object.getOwnPropertyDescriptor(a,"key").get;if(b&&b.isReactWarning)return!1}return a.key!==void 0}function f(a,b){function T(){M||(M=!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)",b))}T.isReactWarning=!0,Object.defineProperty(a,"key",{get:T,configurable:!0})}function R(){var a=e(this.type);return V[a]||(V[a]=!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.")),a=this.props.ref,a!==void 0?a:null}function x(a,b,T,A,se,ce){var L=T.ref;return a={$$typeof:j,type:a,key:b,props:T,_owner:A},(L!==void 0?L:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:R}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ce}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function d(a,b,T,A,se,ce){var L=b.children;if(L!==void 0)if(A)if(N(L)){for(A=0;A<L.length;A++)h(L[A]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else h(L);if(ne.call(b,"key")){L=e(a);var ae=Object.keys(b).filter(function(U){return U!=="key"});A=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",P[L+A]||(ae=0<ae.length?"{"+ae.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} />`,F,x,Y,x),P[x+F]=!0)}if(x=null,M!==void 0&&(s(M),x=""+M),u(h)&&(s(h.key),x=""+h.key),"key"in h){M={};for(var W in h)W!=="key"&&(M[W]=h[W])}else M=h;return x&&f(M,typeof a=="function"?a.displayName||a.name||"Unknown":a),v(a,x,M,r(),ne,le)}function p(a){w(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===Q&&(a._payload.status==="fulfilled"?w(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function w(a){return typeof a=="object"&&a!==null&&a.$$typeof===I}var k=l,I=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),E=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),q=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,N=Array.isArray,G=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(a){return a()}};var z,V={},ie=k.react_stack_bottom_frame.bind(k,i)(),ce=G(n(i)),P={};je.Fragment=b,je.jsx=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!1,F?Error("react-stack-top-frame"):ie,F?G(n(a)):ce)},je.jsxs=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!0,F?Error("react-stack-top-frame"):ie,F?G(n(a)):ce)}})()),je}var At;function lr(){return At||(At=1,process.env.NODE_ENV==="production"?We.exports=ar():We.exports=or()),We.exports}var c=lr();function ir({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.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 cr=oe.forwardRef(ir);function ur({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.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 dr=oe.forwardRef(ur);function fr({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.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 mr=oe.forwardRef(fr),Be=18,ze=12,Ft=8,O={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:A.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},ve=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},$t=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:n,expandIconSize:r})=>{const i=r?{width:r,height:r}:void 0,u=r?"":"h-4 w-4";return!(s&&e)||n?c.jsx("span",{className:u,style:i,"aria-hidden":"true"}):t?c.jsx(cr,{className:u,style:i}):c.jsx(dr,{className:u,style:i})},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(r=>tt(r,t)).filter(Boolean);return n.length?n:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},hr=(e,t,s)=>{const n=(t||(s?ve(s):"")).toLowerCase(),r=(e||"").toLowerCase();if(r&&r!=="application/octet-stream"){if(r==="text/markdown"||r==="text/x-markdown")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="application/pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(r.includes("excel")||r.includes("spreadsheet")||r.includes("google-apps.spreadsheet"))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r==="text/csv"||r==="text/tab-separated-values")return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r.includes("word")||r.includes("msword")||r.includes("wordprocessingml")||r.includes("google-apps.document")||r==="application/rtf")return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(r.includes("powerpoint")||r.includes("presentation")||r.includes("google-apps.presentation"))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(r.startsWith("image/"))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(r.startsWith("audio/"))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(r.startsWith("video/"))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(r.includes("zip")||r.includes("tar")||r.includes("compressed")||r.includes("archive"))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(r==="application/json"||r.includes("javascript")||r.includes("typescript")||r.includes("xml")||r.startsWith("text/html")||r.startsWith("text/css")||r.includes("x-python")||r.includes("x-sh")||r.includes("x-go")||r.includes("x-rust"))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(r.startsWith("text/"))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(n))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["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"].includes(n))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return c.jsx(D.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Ht=(e,t)=>{const{entry:s,isDirectory:n,isExpanded:r,extension:i,mimeType:u}=e;let f;const C=u||s.mimeType;return s.icon!==void 0?f=s.icon:n?f=r&&t?.directoryExpanded||t?.directory||c.jsx(mr,{className:"h-4 w-4"}):i&&t?.fileByExtension?.[i]?f=t.fileByExtension[i]:f=t?.file||hr(C,i,s.name),tt(typeof f=="function"?f(e):f,s.absolutePath)},pr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,n])=>[`data-${pr(s)}`,String(n)]))},yr=500,Bt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:n,selectionMode:r,onSelectionChange:i,onEntryClick:u,toggleDirectory:f,onToggleDirectoryRecursive:C})=>{const v=l.useRef(null);return l.useEffect(()=>()=>{v.current&&window.clearTimeout(v.current)},[]),l.useCallback(d=>{d.stopPropagation(),r!=="none"&&!t&&i&&i(e,!n);let p=!1;u({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{p=!0}}),!(!t||p)&&(v.current?(window.clearTimeout(v.current),v.current=null,C(e)):v.current=window.setTimeout(()=>{f(e.absolutePath),v.current=null},yr))},[t,e,s,C,f,u,r,i,n])},zt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Dt=(e,t)=>e.children!==void 0&&t(e.absolutePath),Yt=(e,t)=>({width:e,gridTemplateColumns:t}),Gt=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:n,rowIndex:r,isSelectedForAria:i,rowHeight:u,isDirOpen:f,columns:C,numericTemplate:v,numericTotal:d,nameWidth:p,rowClassName:w,selection:{onEntryClick:k,selectedPath:I,mode:m="none",selectedItems:b,onSelectionChange:S},expansion:{toggleDirectory:j,onToggleDirectoryRecursive:R},visual:{iconOverrides:E,showExpandIcons:y=!0,showDirectoryIcons:$=!0,showFileIcons:T=!0,useCanvasExpandIcons:L=!1,expandIconSize:Q,indentSize:ee=ze,highlightStyles:H}})=>{const[q,te]=l.useState(!1),N=e.children!==void 0,G=N&&f(e.absolutePath),z=e.absolutePath===I,V=!N&&!!b?.has(e.absolutePath),ie=N?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath),ce=Bt({entry:e,isDirectory:N,isExpanded:G,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:k,toggleDirectory:j,onToggleDirectoryRecursive:R}),P=q?H?.hoverClassName!==void 0?H.hoverClassName:O.entryHover:"",a=(()=>{if(N){if(z)return H?.directorySelectedClassName!==void 0?H.directorySelectedClassName:O.entrySelected}else if(z||V)return H?.itemSelectedClassName!==void 0?H.itemSelectedClassName:A.twMerge(z&&O.entrySelected,V&&O.entryItemSelected);return""})(),h=typeof w=="function"?w(e):w,M=A.twMerge("dt-grid-row cursor-pointer select-none",P,a,h,e.className),F=A.twMerge(O.expandIcon,(z||V)&&O.expandIconSelected),ne=A.twMerge(O.typeIcon,(z||V)&&O.typeIconSelected),le=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&O.nameDirectory,(z||V)&&O.nameSelected),x=$t({isDirectory:N,isExpanded:G,showExpandIcons:y,useCanvasExpandIcons:L,expandIconSize:Q}),Y=(N?$:T)?Ht({entry:e,isDirectory:N,isExpanded:G,isSelected:z,isItemSelected:V,extension:ie,mimeType:e.mimeType},E):null,W={indentLevel:t,isDirectory:N,isExpanded:G},[U,...we]=C,fe=U?.render?U.render(e,W):e.label??e.name,ye={...q?H?.hoverStyle:{},...N&&z?H?.directorySelectedStyle:{},...!N&&(z||V)?H?.itemSelectedStyle:{}};return c.jsxs("div",{className:M,style:{height:u,...ye,...e.style},role:"row","aria-expanded":N?G:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":n,"aria-rowindex":r,"aria-selected":m==="none"?void 0:i,...Wt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(G):void 0,"data-entry-selected":z?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:ce,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onKeyDown:se=>se.key==="Enter"&&ce(se),tabIndex:0,children:[c.jsxs("div",{className:A.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:p,paddingLeft:Math.max(0,t*ee)},children:[(y||L)&&c.jsx("span",{className:F,children:x}),(N?$:T)&&c.jsx("span",{className:ne,children:Y}),c.jsx("span",{className:le,children:fe})]}),we.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(d,v),children:we.map(se=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(se.align),se.className),role:"gridcell",children:se.render?se.render(e,W):null},se.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Dt(e.entry,e.isDirOpen),n=Dt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===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.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Gt.displayName="DirectoryTreeGridRow";const Vt=({kind:e,columns:t,numericTemplate:s,numericTotal:n,nameWidth:r,scrollBarWidth:i,className:u,nameContent:f,renderCell:C})=>{const[,...v]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",p=e==="header"?"dt-grid-header":"dt-grid-footer",w=e==="header"?"columnheader":"gridcell";return c.jsxs("div",{className:A.twMerge(p,"text-gray-600 dark:text-gray-300",u),role:"row",children:[c.jsx("div",{className:A.twMerge(d,"px-1",t[0]?.className),role:w,style:{width:r},children:f}),v.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(n,s),children:v.map(k=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(k.align),k.className),role:w,children:C(k)},k.key))})}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},br=({columns:e,className:t,...s})=>c.jsx(Vt,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...s}),Ot=(e,t)=>typeof e=="function"?e(t):e??null,gr=({columns:e,allEntries:t,className:s,...n})=>c.jsx(Vt,{kind:"footer",columns:e,className:s,nameContent:Ot(e[0]?.footer,t),renderCell:r=>Ot(r.footer,t),...n}),xr=240,Ut=96,Xt=12,rt=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},vr=e=>e.slice(1).map(t=>`${rt(t,Ut)}px`).join(" "),wr=({measuredWidth:e,columns:t,scrollBarWidth:s=Xt})=>{const n=rt(t[0],xr),r=t.slice(1).reduce((C,v)=>C+rt(v,Ut),0),i=Number.isFinite(e)&&e>0?e:0,u=Math.max(0,i-n-Math.max(0,s)),f=Math.max(0,r-u);return{nameWidth:n,numericTotal:r,numericVisible:u,maxHScroll:f}},et=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,kr=e=>{const t=[],s=n=>{for(const r of n)t.push(r),r.children&&r.children.length>0&&s(r.children)};return s(e),t},Sr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Er=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const n=Sr(t,s),r=e[n];return r?{path:r.entry.absolutePath,offsetInViewport:s-t[n]}:null},Nr=(e,t,s)=>{if(t.length===0||s.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,s[n]+e.offsetInViewport);return null},Ir=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Rr=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Cr=(e,t,s,n)=>{const r=Math.max(1,Math.floor(t*n)),i=Math.max(1,Math.floor(s*n));(e.width!==r||e.height!==i)&&(e.width=r,e.height=i);const u=e.style;u.width!==`${t}px`&&(u.width=`${t}px`),u.height!==`${s}px`&&(u.height=`${s}px`)},jr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Mr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let n=s[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),u=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${u}, ${t})`},Tr=(e,t,s,n)=>{if(t.length===0)return;const r=Mr(s,.14),i=e.strokeStyle,u=e.fillStyle,f=e.lineWidth,C=e.lineCap,v=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const p=n??d.size,w=Math.max(0,p/2),k=Math.max(1,Math.round(p*.08)),I=Math.max(1,Math.round(p*.14)),m=Math.max(0,w-k*.8),b=Math.max(0,m*.55);r&&(e.fillStyle=r,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=k,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,w-k*.3),0,Math.PI*2),e.stroke(),e.lineWidth=I,e.beginPath(),e.moveTo(d.centerX-b,d.centerY),e.lineTo(d.centerX+b,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-b),e.lineTo(d.centerX,d.centerY+b),e.stroke())}e.strokeStyle=i,e.fillStyle=u,e.lineWidth=f,e.lineCap=C,e.lineJoin=v},Jt=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u="#a0aec0",strokeWidth:f=1,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k})=>{const I=l.useRef(null),m=l.useRef(null),b=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k}),S=l.useCallback(()=>{m.current=null;const R=I.current;if(!R)return;const E=R.getContext("2d");if(!E)return;const y=b.current;if(y.width<=0||y.viewportHeight<=0){E.clearRect(0,0,R.width,R.height);return}const $=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Cr(R,y.width,y.viewportHeight,$);const T=y.segmentsByItem.length,L=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),Q=Math.min(T,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ee=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const N=Math.floor(y.renderEndIndex);return Math.max(Math.min(T,N+1),L)}return Math.max(Q,L)})(),H=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const N=Math.floor(y.lookaheadEndIndex),G=Math.min(T,N+1);return Math.max(G,ee)}return Math.max(Q,ee)})(),q=Ir(y.segmentsByItem,L,H),te=Rr(y.glyphsByItem,L,H);E.save(),E.scale($,$),E.clearRect(0,0,y.width,y.viewportHeight),E.translate(0,-y.scrollPosition),E.strokeStyle=y.color,jr(E,q,y.strokeWidth),Tr(E,te,y.expandGlyphColor??y.color,y.expandGlyphSize),E.restore()},[]),j=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{b.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k},j()},[e,t,s,n,r,i,u,f,C,v,d,p,w,k,j]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),c.jsx("canvas",{ref:I,className:"pointer-events-none absolute top-0 left-0 z-0"})});Jt.displayName="TreeLineCanvas";const Pr={msOverflowStyle:"none",scrollbarWidth:"none"},_r=()=>{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))},Ar=(e,t,s,n,r)=>{const i=[],u=[];let f=0;const C=(v,d,p)=>{const w=r?[...v].sort(r):v;for(let k=0;k<w.length;k++){const I=w[k],m=k===w.length-1,b=[...p,m],S=I.children!==void 0,j=S&&t(I.absolutePath,I.relativePath);let R=d,E=b,y=p;n&&(R=d-1,E=b.slice(1),y=p.slice(1)),i.push({entry:I,indentLevel:R,depth:d,positionInSet:k+1,setSize:w.length,parentIsLast:E}),s&&(R>f&&(f=R),u.push({id:I.absolutePath,name:I.name,absolutePath:I.absolutePath,indentLevel:R,isLastChild:m,isDirectory:S,isExpanded:j,ancestorIsLast:[...y],hideLines:n&&d===0})),S&&j&&I.children&&C(I.children,d+1,b)}};return C(e,0,[]),{flatItems:i,lineItems:u,maxIndent:f}},Lt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Fr=(e,t,s,n,r,i)=>{const u=n?.renderStart??Math.max(0,Lt(i,r)),f=t>0?Lt(i,r+t)+s:u+s,C=e>0?Math.min(e-1,Math.max(u,f)):u,v=n?.renderEnd??C,d=e>0?Math.min(e-1,v+s):v;return{renderStart:u,renderEnd:v,lookaheadEnd:d}},Dr=(e,t,s,n,r,i)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const u=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),C=d=>r?typeof i=="number"&&Number.isFinite(i)&&i>0?i:Math.max(8,Math.min(n*.9,d*.7)):0,v=3;for(let d=0;d<e.length;d++){const p=e[d];if(p.hideLines)continue;const w=[],k=t[d]??0,I=s[d]??0,m=I+k/2,b=C(k),S=b>0?b/2+2:n/1.5;for(let E=0;E<p.indentLevel;E++){if(p.ancestorIsLast[E]??!1)continue;let $=!1;for(let T=d;T<e.length;T++){const L=e[T];if(L.indentLevel>E&&L.ancestorIsLast.length>E&&!L.ancestorIsLast[E]){$=!0;break}if(T>d&&L.indentLevel===E)break}if($){const T=E*n+n/2+v;w.push({key:`${p.id}-ancestor-${E}`,x1:T,y1:I,x2:T,y2:I+k,itemIndex:d})}}const j=p.indentLevel*n,R=j+n/2+v;if(p.isDirectory?w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m-S,itemIndex:d}):w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m,itemIndex:d}),!p.isDirectory&&p.isLastChild&&w.push({key:`${p.id}-connector-horizontal`,x1:R,y1:m,x2:j+n+v,y2:m,itemIndex:d}),p.isLastChild||(p.isDirectory?w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m+S,x2:R,y2:I+k,itemIndex:d}):w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m,x2:R,y2:I+k,itemIndex:d})),u[d]=w,r&&p.isDirectory){const E=b,y=R,$=m;f[d]=[{key:`${p.id}-glyph`,itemIndex:d,centerX:y,centerY:$,size:E,isExpanded:p.isExpanded}]}}return{segmentsByItem:u,glyphsByItem:f}},nt=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:n,setSize:r,isSelectedForAria:i,flatIndex:u,isActive:f,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j="none",selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$=!0,showDirectoryIcons:T=!0,showFileIcons:L=!0,useCanvasExpandIcons:Q=!1,expandIconSize:ee,typeIconSize:H,fontSize:q,indentSize:te=ze,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:ie,directoryNameClassName:ce,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}})=>{const[M,F]=l.useState(null),[ne,le]=l.useState(!1),x=e.children!==void 0,Y=x&&p(e.absolutePath),W=e.absolutePath===S,U=!x&&R?.has(e.absolutePath),we=x?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath);l.useEffect(()=>{F(Y&&e.children?e.children:null)},[Y,e.children]);const fe=Bt({entry:e,isDirectory:x,isExpanded:Y,isItemSelected:!!U,selectionMode:j,onSelectionChange:E,onEntryClick:b,toggleDirectory:I,onToggleDirectoryRecursive:m}),ye=ne?N?.hoverClassName!==void 0?N.hoverClassName:O.entryHover:"",se=(()=>{if(x){if(W)return N?.directorySelectedClassName!==void 0?N.directorySelectedClassName:O.entrySelected}else if(W||U)return N?.itemSelectedClassName!==void 0?N.itemSelectedClassName:A.twMerge(W&&O.entrySelected,U&&O.entryItemSelected);return""})(),Ye=A.twMerge(O.entry,ye,se,G,e.className),ke=A.twMerge(O.expandIcon,(W||U)&&O.expandIconSelected),Me=A.twMerge(O.typeIcon,(W||U)&&O.typeIconSelected),Te=A.twMerge(O.name,V,x&&O.nameDirectory,x&&ce,!x&&a,(W||U)&&O.nameSelected),Pe=$t({isDirectory:x,isExpanded:Y,showExpandIcons:$,useCanvasExpandIcons:Q,expandIconSize:ee}),_e=(x?T:L)?Ht({entry:e,isDirectory:x,isExpanded:Y,isSelected:W,isItemSelected:!!U,extension:we,mimeType:e.mimeType},y):null,Ae={...ne?N?.hoverStyle:{},...x&&W?N?.directorySelectedStyle:{},...!x&&(W||U)?N?.itemSelectedStyle:{}},me=Wt(e.data),Fe=H?{width:H,height:H}:void 0,Ie=q?{fontSize:typeof q=="number"?`${q}px`:q}:void 0;return c.jsxs(l.Fragment,{children:[c.jsxs("div",{className:Ye,style:{paddingLeft:`${Math.max(0,t*te)}px`,transform:t<0?`translateX(${t*te}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*te)}px)`:void 0,height:`${d}px`,...Ie,...Ae,...z,...e.style},...me,"data-entry-type":x?"directory":"file","data-entry-expanded":x?String(Y):void 0,"data-entry-selected":W?"true":void 0,"data-entry-item-selected":U?"true":void 0,onClick:fe,onMouseEnter:()=>le(!0),onMouseLeave:()=>le(!1),ref:re=>C(u,re),onKeyDown:re=>{if(re.key==="Enter"||re.key===" "){re.preventDefault(),fe(re);return}v(re,u)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":x?Y:void 0,"aria-level":s+1,"aria-posinset":n,"aria-setsize":r,"aria-selected":j==="none"?void 0:i,"aria-label":`${e.name} (${x?"directory":"file"})`,children:[($||Q)&&c.jsx("span",{className:ke,children:Pe}),(x?T:L)&&c.jsx("span",{className:Me,style:Fe,children:_e}),c.jsx("span",{className:Te,style:{...Ie,...ie,...x?P:h},"data-entry-type":x?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),Y&&M&&k&&c.jsx("fieldset",{children:M.map((re,Re)=>c.jsx(nt,{entry:re,indentLevel:t+1,depth:s+1,positionInSet:Re+1,setSize:M.length,isSelectedForAria:!!R?.has(re.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:[...w,Re===M.length-1],expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$,showDirectoryIcons:T,showFileIcons:L,useCanvasExpandIcons:Q,expandIconSize:ee,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:ie,directoryNameClassName:ce,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}},re.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,n=t.entry.children!==void 0,r=s&&e.isDirOpen(e.entry.absolutePath),i=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&r===i&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((u,f)=>u===t.parentIsLast[f])});nt.displayName="DirectoryEntryItem";const qt=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...qt(s)));return t},Or=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:n,collapseMultiple:r,isPending:i,alwaysExpanded:u=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:C,selectedPath:v,mode:d="none",selectedItems:p,onSelectionChange:w},visual:{className:k,style:I,ariaLabel:m,ariaLabelledBy:b,lineColor:S="#A0AEC0",showTreeLines:j=!0,showExpandIcons:R=!0,showDirectoryIcons:E=!0,showFileIcons:y=!0,iconOverrides:$,expandIconSize:T,itemHeight:L=Be,removeRootIndent:Q=!1,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:ie}={},virtualScroll:ce,grid:P,sort:a})=>{const h=P!==void 0,[M,F]=l.useState(!1),ne=l.useRef(null),le=l.useRef(null),x=l.useRef(null),[Y,W]=l.useState(0),[U,we]=l.useState(0),[fe,ye]=l.useState(0),[se,Ye]=l.useState(null),{overscanCount:ke=15,className:Me,background:Te,onScroll:Pe,onRangeChange:_e,initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,callbackThrottleMs:Ie=5,contentInsets:re,onItemFocus:Re,viewportHeightOverride:ae,scrollBarOptions:Ge,behaviorOptions:st,preserveScrollAnchor:at=!1,getItemKey:Zt,testId:ot,contentProps:Ve}=ce??{},lt=l.useMemo(()=>h?{role:"rowgroup",...Ve}:Ve,[h,Ve]),[De,it]=l.useState(typeof me=="number"?me:0),Ue=l.useRef(typeof me=="number"?me:0),ct=l.useCallback((o,g)=>{Ue.current=o,it(o),Pe?.(o,g)},[Pe]),ut=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:_}=o;Ye(B=>B&&B.renderStart===g&&B.renderEnd===_?B:{renderStart:g,renderEnd:_}),_e?.(o)},[_e]);l.useEffect(()=>{F(!0),_r()},[]),l.useEffect(()=>{const o=ne.current,g=h?le.current:o,_=()=>{if(o){const X=o.clientWidth;we(Z=>Math.abs(Z-X)>1?X:Z)}if(typeof ae=="number")W(X=>Math.abs(X-ae)>1?ae:X);else if(g){const X=g.clientHeight;W(Z=>Math.abs(Z-X)>1?X:Z)}};if(!(o||g))return W(0);_();const B=new ResizeObserver(_);return o&&B.observe(o),g&&g!==o&&B.observe(g),()=>B.disconnect()},[ae,h]);const Se=typeof ae=="number"?ae:Y,ue=l.useCallback(o=>u||(M?s(o):!1),[M,s,u]),dt=A.twMerge(O.container,i&&O.containerPending,k),ft=l.useMemo(()=>({...Pr,...I??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[I,ae]),Xe=l.useCallback((o,g)=>{const _=[o.absolutePath,...qt(o)],B=g||f;if(_.every(de=>ue(de)))return r(_);if(_.every(de=>!ue(de))||B==="recursive")return n(_);if(B==="toggle")return r(_);console.warn(`[DirectoryTree] Unknown double click action: ${B}. No action taken.`)},[ue,n,r,f]),mt=h?!1:Q,{flatItems:be,lineItems:Je,maxIndent:ht}=l.useMemo(()=>Ar(e,ue,j,mt,a),[e,ue,j,mt,a]),J=l.useMemo(()=>be.map((o,g)=>{const _=typeof L=="function"?L(o.entry,g):L;return{...o,rowHeight:Number.isFinite(_)&&_>0?_:Be}}),[be,L]),he=l.useMemo(()=>J.map(o=>o.rowHeight),[J]),ge=l.useMemo(()=>{const o=new Array(he.length+1);o[0]=0;for(let g=0;g<he.length;g++)o[g+1]=o[g]+he[g];return o},[he]),pt=l.useCallback(o=>J[o]?.rowHeight??Be,[J]),Kt=l.useCallback(o=>J[o]?.entry.absolutePath??o,[J]),yt=Zt??Kt,bt=l.useRef(be);bt.current=be;const gt=l.useRef(ue);gt.current=ue;const qe=l.useRef(t);qe.current=t;const[xt,vt]=l.useState(0),Ze=l.useRef(new Map),Ke=l.useRef(null),wt=l.useCallback((o,g)=>{g?(Ze.current.set(o,g),Ke.current===o&&(Ke.current=null,g.focus())):Ze.current.delete(o)},[]),xe=l.useCallback(o=>{vt(o);const g=Ze.current.get(o);if(g){g.focus();return}Ke.current=o,x.current?.scrollToIndex(o)},[]);l.useEffect(()=>{vt(o=>be.length===0?0:Math.min(o,be.length-1))},[be.length]);const kt=l.useCallback((o,g)=>{const _=bt.current,B=_.length-1;if(B<0)return;const X=_[g],Z=X?.entry.children!==void 0,de=Z&>.current(X.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),xe(Math.min(g+1,B));break;case"ArrowUp":o.preventDefault(),xe(Math.max(g-1,0));break;case"Home":o.preventDefault(),xe(0);break;case"End":o.preventDefault(),xe(B);break;case"ArrowRight":o.preventDefault(),Z&&!de?qe.current(X.entry.absolutePath):Z&&g<B&&xe(g+1);break;case"ArrowLeft":{if(o.preventDefault(),Z&&de){qe.current(X.entry.absolutePath);break}const nr=X?.depth??0;for(let He=g-1;He>=0;He--)if(_[He].depth<nr){xe(He);break}break}}},[xe]),Oe=l.useMemo(()=>!j||Je.length===0?{segmentsByItem:[],glyphsByItem:[]}:Dr(Je,he,ge,ze,j,T??Ft),[Je,he,ge,j,T]),Le=l.useMemo(()=>!j||e.length===0?0:(ht+2)*ze,[e.length,ht,j]),{renderStart:St,renderEnd:Et,lookaheadEnd:Nt}=l.useMemo(()=>Fr(J.length,Se,ke,se,De,ge),[J.length,Se,ke,se,De,ge]),Qe=l.useMemo(()=>!j||Le<=0||Se<=0||Oe.segmentsByItem.length===0?null:c.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:c.jsx("div",{className:"absolute top-0 left-0",style:{width:Le,height:Se},children:c.jsx(Jt,{segmentsByItem:Oe.segmentsByItem,glyphsByItem:Oe.glyphsByItem,itemHeight:he[0]??Be,width:Le,viewportHeight:Se,scrollPosition:De,color:S,expandGlyphColor:S,expandGlyphSize:T??Ft,renderStartIndex:St,renderEndIndex:Et,lookaheadEndIndex:Nt})})}),[Le,Se,St,Et,Nt,De,Oe,S,j,T,he]),It=l.useCallback(o=>J[o],[J]),Rt=l.useRef(null);l.useLayoutEffect(()=>{const o=Rt.current;if(Rt.current={items:J,offsets:ge},!at||!o||o.items===J)return;const g=x.current,_=g?.getScrollPosition(),B=typeof _=="number"&&_>=0?_:Ue.current,X=Er(o.items,o.offsets,B);if(!X)return;const Z=Nr(X,J,ge);if(Z===null||Math.abs(Z-B)<1)return;const de=g?g.scrollTo(Z):Z;Ue.current=de,it(de)},[J,ge,at]);const pe=P?.columns,Ee=P?.scrollBarWidth??Ge?.width??Xt,K=l.useMemo(()=>pe?wr({measuredWidth:U,columns:pe,scrollBarWidth:Ee}):null,[pe,U,Ee]),$e=l.useMemo(()=>pe?vr(pe):"",[pe]),Qt=l.useMemo(()=>P?.showFooter&&pe?kr(e):[],[P?.showFooter,pe,e]),Ne=K?.maxHScroll??0;l.useEffect(()=>{ye(o=>et(o,Ne))},[Ne]);const Ct=l.useCallback(o=>ye(g=>et(g+o,Ne)),[Ne]),jt=l.useMemo(()=>({iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee}),[$,R,E,y,j,T,ee]),Mt=l.useMemo(()=>c.jsx(Tt.VirtualScroll,{ref:x,itemCount:J.length,getItem:It,getItemHeight:pt,getItemKey:yt,testId:ot,contentProps:lt,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:ke,onScroll:ct,onRangeChange:ut,className:Me,onWheelHorizontal:h?Ct:void 0,background:c.jsxs(c.Fragment,{children:[h&&K?c.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:K.nameWidth},"aria-hidden":"true",children:Qe}):Qe,Te]}),initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,onItemFocus:Re,callbackThrottleMs:Ie,contentInsets:re,scrollBarOptions:Ge,behaviorOptions:st,children:(o,g)=>o?h&&P&&K?c.jsx(Gt,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!p?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:ue,columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},visual:jt},o.entry.absolutePath):c.jsx(nt,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!p?.has(o.entry.absolutePath),flatIndex:g,isActive:g===xt,registerRowRef:wt,onNavigationKeyDown:kt,rowHeight:o.rowHeight,isDirOpen:ue,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},visual:{iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:ie}},o.entry.absolutePath):null}),[J.length,It,pt,yt,ot,lt,xt,wt,kt,ae,ke,ct,ut,Me,h,Ct,K,Qe,Te,Ae,me,Fe,Re,Ie,re,Ge,st,P,$e,ue,C,v,d,p,w,t,Xe,jt,$,R,E,y,j,T,ee,H,q,te,N,G,z,V,ie]);if(!(P&&K))return c.jsx("div",{ref:ne,className:dt,style:ft,role:"tree","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,children:Mt});const er=P.showHeader??!0,tr=P.showFooter??!1,rr={...ft,"--dt-hscroll":`${fe}px`};return c.jsxs("div",{ref:ne,className:A.twMerge(dt,"dt-grid"),style:rr,role:"treegrid","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":J.length+(P.showHeader??!0?1:0),children:[er&&c.jsx("div",{role:"rowgroup",children:c.jsx(br,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,className:P.headerClassName})}),c.jsx("div",{ref:le,className:"dt-grid-body",children:Mt}),Ne>0&&c.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:K.nameWidth},"aria-hidden":"true"}),c.jsx(Tt.ScrollBar,{horizontal:!0,contentSize:K.numericTotal,viewportSize:K.numericVisible,scrollPosition:fe,scrollBarWidth:Ee,onScroll:o=>{const g=typeof o=="function"?o(fe):o,_=et(g,Ne);return ye(_),_}}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Ee},"aria-hidden":"true"})]}),tr&&c.jsx("div",{role:"rowgroup",children:c.jsx(gr,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,allEntries:Qt,className:P.footerClassName})})]})},Lr=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,n]=l.useTransition(),[r,i]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const b=JSON.parse(m);return new Set(b)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),u=l.useCallback(m=>{n(()=>{i(b=>{const S=new Set(b);return m(S),S})})},[]),f=l.useCallback((m,b)=>{u(S=>{for(const j of m)b(S,j)})},[u]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(r)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[r,t]);const C=l.useCallback(m=>{f([m],(b,S)=>{b.has(S)?b.delete(S):b.add(S)})},[f]),v=l.useCallback(m=>{f([m],(b,S)=>{b.add(S)})},[f]),d=l.useCallback(m=>{f([m],(b,S)=>{b.delete(S)})},[f]),p=l.useCallback(m=>{f(m,(b,S)=>{b.delete(S)})},[f]),w=l.useCallback(m=>{f(m,(b,S)=>{b.add(S)})},[f]),k=l.useCallback(()=>{u(m=>{m.clear()})},[u]),I=l.useCallback(m=>r.has(m),[r]);return{expanded:r,toggle:C,expand:v,collapse:d,collapseMultiple:p,expandMultiple:w,collapseAll:k,isExpanded:I,isPending:s}};exports.DirectoryTree=Or;exports.directoryTreeClasses=O;exports.useDirectoryTreeState=Lr;
|
|
6
|
+
<%s key={someKey} {...props} />`,A,L,ae,L),P[L+A]=!0)}if(L=null,T!==void 0&&(s(T),L=""+T),i(b)&&(s(b.key),L=""+b.key),"key"in b){T={};for(var k in b)k!=="key"&&(T[k]=b[k])}else T=b;return L&&f(T,typeof a=="function"?a.displayName||a.name||"Unknown":a),x(a,L,T,n(),se,ce)}function h(a){v(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===te&&(a._payload.status==="fulfilled"?v(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function v(a){return typeof a=="object"&&a!==null&&a.$$typeof===j}var w=l,j=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),E=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),B=Symbol.for("react.client.reference"),re=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,N=Array.isArray,z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(a){return a()}};var M,V={},de=w.react_stack_bottom_frame.bind(w,c)(),fe=z(r(c)),P={};Me.Fragment=y,Me.jsx=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!1,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)},Me.jsxs=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!0,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)}})()),Me}var Yt;function vr(){return Yt||(Yt=1,process.env.NODE_ENV==="production"?Ye.exports=gr():Ye.exports=xr()),Ye.exports}var u=vr();function wr({title:e,titleId:t,...s},r){return ie.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:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 Er=ie.forwardRef(wr);function Sr({title:e,titleId:t,...s},r){return ie.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:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 kr=ie.forwardRef(Sr);function Rr({title:e,titleId:t,...s},r){return ie.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:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 jr=ie.forwardRef(Rr),ze=18,Ve=12,zt=8,$={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:D.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:D.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:D.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:D.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:D.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:D.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:D.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:D.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:D.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},ve=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},Xt=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:r,expandIconSize:n})=>{const c=n?{width:n,height:n}:void 0,i=n?"":"h-4 w-4";return!(s&&e)||r?u.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?u.jsx(Er,{className:i,style:c}):u.jsx(kr,{className:i,style:c})},at=(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 r=e.map(n=>at(n,t)).filter(Boolean);return r.length?r:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},Ir=(e,t,s)=>{const r=(t||(s?ve(s):"")).toLowerCase(),n=(e||"").toLowerCase();if(n&&n!=="application/octet-stream"){if(n==="text/markdown"||n==="text/x-markdown")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="application/pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(n.includes("excel")||n.includes("spreadsheet")||n.includes("google-apps.spreadsheet"))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n==="text/csv"||n==="text/tab-separated-values")return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n.includes("word")||n.includes("msword")||n.includes("wordprocessingml")||n.includes("google-apps.document")||n==="application/rtf")return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(n.includes("powerpoint")||n.includes("presentation")||n.includes("google-apps.presentation"))return u.jsx(F.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(n.startsWith("image/"))return u.jsx(F.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(n.startsWith("audio/"))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(n.startsWith("video/"))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(n.includes("zip")||n.includes("tar")||n.includes("compressed")||n.includes("archive"))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(n==="application/json"||n.includes("javascript")||n.includes("typescript")||n.includes("xml")||n.startsWith("text/html")||n.startsWith("text/css")||n.includes("x-python")||n.includes("x-sh")||n.includes("x-go")||n.includes("x-rust"))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(n.startsWith("text/"))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(r){if(r==="md"||r==="markdown"||r==="mdx")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(r))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(r))return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(r))return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(r))return u.jsx(F.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(r))return u.jsx(F.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["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"].includes(r))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(r))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(r))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(r))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(r))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return u.jsx(F.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Jt=(e,t)=>{const{entry:s,isDirectory:r,isExpanded:n,extension:c,mimeType:i}=e;let f;const R=i||s.mimeType;return s.icon!==void 0?f=s.icon:r?f=n&&t?.directoryExpanded||t?.directory||u.jsx(jr,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||Ir(R,c,s.name),at(typeof f=="function"?f(e):f,s.absolutePath)},Cr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,r])=>[`data-${Cr(s)}`,String(r)]))},Nr=500,Zt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:r,selectionMode:n,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:R})=>{const x=l.useRef(null);return l.useEffect(()=>()=>{x.current&&window.clearTimeout(x.current)},[]),l.useCallback(d=>{d.stopPropagation(),n!=="none"&&!t&&c&&c(e,!r);let h=!1;i({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{h=!0}}),!(!t||h)&&(x.current?(window.clearTimeout(x.current),x.current=null,R(e)):x.current=window.setTimeout(()=>{f(e.absolutePath),x.current=null},Nr))},[t,e,s,R,f,i,n,c,r])},Qt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Vt=(e,t)=>e.children!==void 0&&t(e.absolutePath),er=(e,t)=>({width:e,gridTemplateColumns:t}),tr=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:r,rowIndex:n,isSelectedForAria:c,rowHeight:i,isDirOpen:f,columns:R,numericTemplate:x,numericTotal:d,nameWidth:h,rowClassName:v,selection:{onEntryClick:w,selectedPath:j,mode:m="none",selectedItems:y,onSelectionChange:S},expansion:{toggleDirectory:C,onToggleDirectoryRecursive:I},visual:{iconOverrides:E,showExpandIcons:p=!0,showDirectoryIcons:W=!0,showFileIcons:_=!0,useCanvasExpandIcons:H=!1,expandIconSize:te,indentSize:J=Ve,highlightStyles:B}})=>{const[re,ne]=l.useState(!1),N=e.children!==void 0,z=N&&f(e.absolutePath),M=e.absolutePath===j,V=!N&&!!y?.has(e.absolutePath),de=N?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath),fe=Zt({entry:e,isDirectory:N,isExpanded:z,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:w,toggleDirectory:C,onToggleDirectoryRecursive:I}),P=re?B?.hoverClassName!==void 0?B.hoverClassName:$.entryHover:"",a=(()=>{if(N){if(M)return B?.directorySelectedClassName!==void 0?B.directorySelectedClassName:$.entrySelected}else if(M||V)return B?.itemSelectedClassName!==void 0?B.itemSelectedClassName:D.twMerge(M&&$.entrySelected,V&&$.entryItemSelected);return""})(),b=typeof v=="function"?v(e):v,T=D.twMerge("dt-grid-row cursor-pointer select-none",P,a,b,e.className),A=D.twMerge($.expandIcon,(M||V)&&$.expandIconSelected),se=D.twMerge($.typeIcon,(M||V)&&$.typeIconSelected),ce=D.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&$.nameDirectory,(M||V)&&$.nameSelected),L=Xt({isDirectory:N,isExpanded:z,showExpandIcons:p,useCanvasExpandIcons:H,expandIconSize:te}),ae=(N?W:_)?Jt({entry:e,isDirectory:N,isExpanded:z,isSelected:M,isItemSelected:V,extension:de,mimeType:e.mimeType},E):null,k={indentLevel:t,isDirectory:N,isExpanded:z},[U,...q]=R,Z=U?.render?U.render(e,k):e.label??e.name,we={...re?B?.hoverStyle:{},...N&&M?B?.directorySelectedStyle:{},...!N&&(M||V)?B?.itemSelectedStyle:{}};return u.jsxs("div",{className:T,style:{height:i,...we,...e.style},role:"row","aria-expanded":N?z:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":r,"aria-rowindex":n,"aria-selected":m==="none"?void 0:c,...qt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(z):void 0,"data-entry-selected":M?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:fe,onMouseEnter:()=>ne(!0),onMouseLeave:()=>ne(!1),onKeyDown:Q=>Q.key==="Enter"&&fe(Q),tabIndex:0,children:[u.jsxs("div",{className:D.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:h,paddingLeft:Math.max(0,t*J)},children:[(p||H)&&u.jsx("span",{className:A,children:L}),(N?W:_)&&u.jsx("span",{className:se,children:ae}),u.jsx("span",{className:ce,children:Z})]}),q.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(d,x),children:q.map(Q=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(Q.align),Q.className),role:"gridcell",children:Q.render?Q.render(e,k):null},Q.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Vt(e.entry,e.isDirOpen),r=Vt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===r&&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.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});tr.displayName="DirectoryTreeGridRow";const rr=({kind:e,columns:t,numericTemplate:s,numericTotal:r,nameWidth:n,scrollBarWidth:c,className:i,nameContent:f,renderCell:R})=>{const[,...x]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",h=e==="header"?"dt-grid-header":"dt-grid-footer",v=e==="header"?"columnheader":"gridcell";return u.jsxs("div",{className:D.twMerge(h,"text-gray-600 dark:text-gray-300",i),role:"row",children:[u.jsx("div",{className:D.twMerge(d,"px-1",t[0]?.className),role:v,style:{width:n},children:f}),x.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(r,s),children:x.map(w=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(w.align),w.className),role:v,children:R(w)},w.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},Tr=({columns:e,className:t,...s})=>u.jsx(rr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:r=>r.header??null,...s}),Gt=(e,t)=>typeof e=="function"?e(t):e??null,_r=({columns:e,allEntries:t,className:s,...r})=>u.jsx(rr,{kind:"footer",columns:e,className:s,nameContent:Gt(e[0]?.footer,t),renderCell:n=>Gt(n.footer,t),...r}),Ar=240,nr=96,sr=12,ot=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},Mr=e=>e.slice(1).map(t=>`${ot(t,nr)}px`).join(" "),Lr=({measuredWidth:e,columns:t,scrollBarWidth:s=sr})=>{const r=ot(t[0],Ar),n=t.slice(1).reduce((R,x)=>R+ot(x,nr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-r-Math.max(0,s)),f=Math.max(0,n-i);return{nameWidth:r,numericTotal:n,numericVisible:i,maxHScroll:f}},st=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Pr=e=>{const t=[],s=r=>{for(const n of r)t.push(n),n.children&&n.children.length>0&&s(n.children)};return s(e),t},ar=["entryKindDirectory","entryKindFile"],lt=[...ue.VIRTUAL_SCROLL_LABEL_KEYS,...ar],it=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),or=Object.freeze({en:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...it.en}),ja:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...it.ja})}),Ut=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Or=e=>{const t={};let s=!1;for(const r of ue.VIRTUAL_SCROLL_LABEL_KEYS){const n=Object.hasOwn(e,r)?e[r]:void 0;n!==void 0&&(t[r]=n,s=!0)}return s?t:void 0},lr=(e,t)=>{const s=ue.resolveVirtualScrollLocale(e);if(t===void 0)return or[s];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${Ut(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==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(!lt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${lt.join(", ")}`);const c={...ue.resolveVirtualScrollLabels(s,Or(t)),...it[s]};for(const i of ar){const f=Object.hasOwn(t,i)?t[i]:void 0;if(f!==void 0){if(typeof f!="string"||f.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${Ut(f)}`);c[i]=f}}return Object.freeze(c)},Dr=e=>{const t={};for(const s of ue.VIRTUAL_SCROLL_LABEL_KEYS)t[s]=e[s];return Object.freeze(t)},Fr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},$r=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const r=Fr(t,s),n=e[r];return n?{path:n.entry.absolutePath,offsetInViewport:s-t[r]}:null},Hr=(e,t,s)=>{if(t.length===0||s.length!==t.length+1)return null;for(let r=0;r<t.length;r++)if(t[r].entry.absolutePath===e.path)return Math.max(0,s[r]+e.offsetInViewport);return null},Wr=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Br=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Yr=(e,t,s,r)=>{const n=Math.max(1,Math.floor(t*r)),c=Math.max(1,Math.floor(s*r));(e.width!==n||e.height!==c)&&(e.width=n,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${s}px`&&(i.height=`${s}px`)},zr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const r of t)e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2);e.stroke()},Vr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let r=s[1];r.length===3&&(r=r.split("").map(f=>f+f).join(""));const n=Number.parseInt(r.slice(0,2),16),c=Number.parseInt(r.slice(2,4),16),i=Number.parseInt(r.slice(4,6),16);return`rgba(${n}, ${c}, ${i}, ${t})`},Gr=(e,t,s,r)=>{if(t.length===0)return;const n=Vr(s,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,R=e.lineCap,x=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const h=r??d.size,v=Math.max(0,h/2),w=Math.max(1,Math.round(h*.08)),j=Math.max(1,Math.round(h*.14)),m=Math.max(0,v-w*.8),y=Math.max(0,m*.55);n&&(e.fillStyle=n,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=w,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,v-w*.3),0,Math.PI*2),e.stroke(),e.lineWidth=j,e.beginPath(),e.moveTo(d.centerX-y,d.centerY),e.lineTo(d.centerX+y,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-y),e.lineTo(d.centerX,d.centerY+y),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=f,e.lineCap=R,e.lineJoin=x},ir=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w})=>{const j=l.useRef(null),m=l.useRef(null),y=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w}),S=l.useCallback(()=>{m.current=null;const I=j.current;if(!I)return;const E=I.getContext("2d");if(!E)return;const p=y.current;if(p.width<=0||p.viewportHeight<=0){E.clearRect(0,0,I.width,I.height);return}const W=Number.isFinite(p.devicePixelRatio??NaN)?p.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Yr(I,p.width,p.viewportHeight,W);const _=p.segmentsByItem.length,H=typeof p.renderStartIndex=="number"&&Number.isFinite(p.renderStartIndex)?Math.max(0,Math.floor(p.renderStartIndex)):Math.max(0,Math.floor(p.scrollPosition/p.itemHeight)),te=Math.min(_,Math.ceil((p.scrollPosition+p.viewportHeight)/p.itemHeight)),J=(()=>{if(typeof p.renderEndIndex=="number"&&Number.isFinite(p.renderEndIndex)){const N=Math.floor(p.renderEndIndex);return Math.max(Math.min(_,N+1),H)}return Math.max(te,H)})(),B=(()=>{if(typeof p.lookaheadEndIndex=="number"&&Number.isFinite(p.lookaheadEndIndex)){const N=Math.floor(p.lookaheadEndIndex),z=Math.min(_,N+1);return Math.max(z,J)}return Math.max(te,J)})(),re=Wr(p.segmentsByItem,H,B),ne=Br(p.glyphsByItem,H,B);E.save(),E.scale(W,W),E.clearRect(0,0,p.width,p.viewportHeight),E.translate(0,-p.scrollPosition),E.strokeStyle=p.color,zr(E,re,p.strokeWidth),Gr(E,ne,p.expandGlyphColor??p.color,p.expandGlyphSize),E.restore()},[]),C=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{y.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w},C()},[e,t,s,r,n,c,i,f,R,x,d,h,v,w,C]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),u.jsx("canvas",{ref:j,className:"pointer-events-none absolute top-0 left-0 z-0"})});ir.displayName="TreeLineCanvas";const Ur={msOverflowStyle:"none",scrollbarWidth:"none"},Kr=()=>{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))},Xr=e=>{const t=l.useRef(null),s=t.current;return s!==null&&ue.VIRTUAL_SCROLL_LABEL_KEYS.every(r=>s[r]===e[r])?s:(t.current=e,e)},Jr=(e,t,s,r,n)=>{const c=[],i=[];let f=0;const R=(x,d,h)=>{const v=n?[...x].sort(n):x;for(let w=0;w<v.length;w++){const j=v[w],m=w===v.length-1,y=[...h,m],S=j.children!==void 0,C=S&&t(j.absolutePath,j.relativePath);let I=d,E=y,p=h;r&&(I=d-1,E=y.slice(1),p=h.slice(1)),c.push({entry:j,indentLevel:I,depth:d,positionInSet:w+1,setSize:v.length,parentIsLast:E}),s&&(I>f&&(f=I),i.push({id:j.absolutePath,name:j.name,absolutePath:j.absolutePath,indentLevel:I,isLastChild:m,isDirectory:S,isExpanded:C,ancestorIsLast:[...p],hideLines:r&&d===0})),S&&C&&j.children&&R(j.children,d+1,y)}};return R(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},Kt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},qr=(e,t,s,r,n,c)=>{const i=r?.renderStart??Math.max(0,Kt(c,n)),f=t>0?Kt(c,n+t)+s:i+s,R=e>0?Math.min(e-1,Math.max(i,f)):i,x=r?.renderEnd??R,d=e>0?Math.min(e-1,x+s):x;return{renderStart:i,renderEnd:x,lookaheadEnd:d}},Zr=(e,t,s,r,n,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),R=d=>n?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(r*.9,d*.7)):0,x=3;for(let d=0;d<e.length;d++){const h=e[d];if(h.hideLines)continue;const v=[],w=t[d]??0,j=s[d]??0,m=j+w/2,y=R(w),S=y>0?y/2+2:r/1.5;for(let E=0;E<h.indentLevel;E++){if(h.ancestorIsLast[E]??!1)continue;let W=!1;for(let _=d;_<e.length;_++){const H=e[_];if(H.indentLevel>E&&H.ancestorIsLast.length>E&&!H.ancestorIsLast[E]){W=!0;break}if(_>d&&H.indentLevel===E)break}if(W){const _=E*r+r/2+x;v.push({key:`${h.id}-ancestor-${E}`,x1:_,y1:j,x2:_,y2:j+w,itemIndex:d})}}const C=h.indentLevel*r,I=C+r/2+x;if(h.isDirectory?v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m-S,itemIndex:d}):v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m,itemIndex:d}),!h.isDirectory&&h.isLastChild&&v.push({key:`${h.id}-connector-horizontal`,x1:I,y1:m,x2:C+r+x,y2:m,itemIndex:d}),h.isLastChild||(h.isDirectory?v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m+S,x2:I,y2:j+w,itemIndex:d}):v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m,x2:I,y2:j+w,itemIndex:d})),i[d]=v,n&&h.isDirectory){const E=y,p=I,W=m;f[d]=[{key:`${h.id}-glyph`,itemIndex:d,centerX:p,centerY:W,size:E,isExpanded:h.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},ct=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:r,setSize:n,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:j,renderChildren:m=!0,expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E="none",selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H=!0,showDirectoryIcons:te=!0,showFileIcons:J=!0,useCanvasExpandIcons:B=!1,expandIconSize:re,typeIconSize:ne,fontSize:N,indentSize:z=Ve,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}})=>{const[se,ce]=l.useState(null),[L,ae]=l.useState(!1),k=e.children!==void 0,U=k&&w(e.absolutePath),q=e.absolutePath===I,Z=!k&&p?.has(e.absolutePath),we=k?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath);l.useEffect(()=>{ce(U&&e.children?e.children:null)},[U,e.children]);const Q=Zt({entry:e,isDirectory:k,isExpanded:U,isItemSelected:!!Z,selectionMode:E,onSelectionChange:W,onEntryClick:C,toggleDirectory:y,onToggleDirectoryRecursive:S}),Ge=L?M?.hoverClassName!==void 0?M.hoverClassName:$.entryHover:"",Ie=(()=>{if(k){if(q)return M?.directorySelectedClassName!==void 0?M.directorySelectedClassName:$.entrySelected}else if(q||Z)return M?.itemSelectedClassName!==void 0?M.itemSelectedClassName:D.twMerge(q&&$.entrySelected,Z&&$.entryItemSelected);return""})(),Le=D.twMerge($.entry,Ge,Ie,V,e.className),Ue=D.twMerge($.expandIcon,(q||Z)&&$.expandIconSelected),Ce=D.twMerge($.typeIcon,(q||Z)&&$.typeIconSelected),Ne=D.twMerge($.name,fe,k&&$.nameDirectory,k&&a,!k&&T,(q||Z)&&$.nameSelected),Pe=Xt({isDirectory:k,isExpanded:U,showExpandIcons:H,useCanvasExpandIcons:B,expandIconSize:re}),Ke=(k?te:J)?Jt({entry:e,isDirectory:k,isExpanded:U,isSelected:q,isItemSelected:!!Z,extension:we,mimeType:e.mimeType},_):null,Ee={...L?M?.hoverStyle:{},...k&&q?M?.directorySelectedStyle:{},...!k&&(q||Z)?M?.itemSelectedStyle:{}},Oe=qt(e.data),De=ne?{width:ne,height:ne}:void 0,Te=N?{fontSize:typeof N=="number"?`${N}px`:N}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:Le,style:{paddingLeft:`${Math.max(0,t*z)}px`,transform:t<0?`translateX(${t*z}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*z)}px)`:void 0,height:`${d}px`,...Te,...Ee,...de,...e.style},...Oe,"data-entry-type":k?"directory":"file","data-entry-expanded":k?String(U):void 0,"data-entry-selected":q?"true":void 0,"data-entry-item-selected":Z?"true":void 0,onClick:Q,onMouseEnter:()=>ae(!0),onMouseLeave:()=>ae(!1),ref:oe=>R(i,oe),onKeyDown:oe=>{if(oe.key==="Enter"||oe.key===" "){oe.preventDefault(),Q(oe);return}x(oe,i)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":k?U:void 0,"aria-level":s+1,"aria-posinset":r,"aria-setsize":n,"aria-selected":E==="none"?void 0:c,"aria-label":`${e.name} (${k?h:v})`,children:[(H||B)&&u.jsx("span",{className:Ue,children:Pe}),(k?te:J)&&u.jsx("span",{className:Ce,style:De,children:Ke}),u.jsx("span",{className:Ne,style:{...Te,...P,...k?b:A},"data-entry-type":k?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),U&&se&&m&&u.jsx("fieldset",{children:se.map((oe,_e)=>u.jsx(ct,{entry:oe,indentLevel:t+1,depth:s+1,positionInSet:_e+1,setSize:se.length,isSelectedForAria:!!p?.has(oe.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:[...j,_e===se.length-1],expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E,selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H,showDirectoryIcons:te,showFileIcons:J,useCanvasExpandIcons:B,expandIconSize:re,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}},oe.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,r=t.entry.children!==void 0,n=s&&e.isDirOpen(e.entry.absolutePath),c=r&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&n===c&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,f)=>i===t.parentIsLast[f])});ct.displayName="DirectoryEntryItem";const cr=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...cr(s)));return t},Qr=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:r,collapseMultiple:n,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:R,selectedPath:x,mode:d="none",selectedItems:h,onSelectionChange:v},visual:{className:w,style:j,ariaLabel:m,ariaLabelledBy:y,lineColor:S="#A0AEC0",showTreeLines:C=!0,showExpandIcons:I=!0,showDirectoryIcons:E=!0,showFileIcons:p=!0,iconOverrides:W,expandIconSize:_,itemHeight:H=ze,removeRootIndent:te=!1,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}={},virtualScroll:fe,grid:P,sort:a,locale:b,labels:T})=>{const A=ue.resolveVirtualScrollLocale(b),se=l.useMemo(()=>lr(b,T),[b,T]),ce=Xr(Dr(se)),{entryKindDirectory:L,entryKindFile:ae}=se,k=P!==void 0,[U,q]=l.useState(!1),Z=l.useRef(null),we=l.useRef(null),Q=l.useRef(null),[Ge,Ie]=l.useState(0),[Le,Ue]=l.useState(0),[Ce,Ne]=l.useState(0),[Pe,Ke]=l.useState(null),{overscanCount:Ee=15,className:Oe,background:De,onScroll:Te,onRangeChange:oe,initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,callbackThrottleMs:dt=5,contentInsets:ft,onItemFocus:mt,viewportHeightOverride:le,scrollBarOptions:Xe,behaviorOptions:ht,preserveScrollAnchor:pt=!1,getItemKey:ur,testId:yt,contentProps:Je}=fe??{},bt=l.useMemo(()=>k?{role:"rowgroup",...Je}:Je,[k,Je]),[Fe,gt]=l.useState(typeof Se=="number"?Se:0),qe=l.useRef(typeof Se=="number"?Se:0),xt=l.useCallback((o,g)=>{qe.current=o,gt(o),Te?.(o,g)},[Te]),vt=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:O}=o;Ke(Y=>Y&&Y.renderStart===g&&Y.renderEnd===O?Y:{renderStart:g,renderEnd:O}),oe?.(o)},[oe]);l.useEffect(()=>{q(!0),Kr()},[]),l.useEffect(()=>{const o=Z.current,g=k?we.current:o,O=()=>{if(o){const G=o.clientWidth;Ue(X=>Math.abs(X-G)>1?G:X)}if(typeof le=="number")Ie(G=>Math.abs(G-le)>1?le:G);else if(g){const G=g.clientHeight;Ie(X=>Math.abs(X-G)>1?G:X)}};if(!(o||g))return Ie(0);O();const Y=new ResizeObserver(O);return o&&Y.observe(o),g&&g!==o&&Y.observe(g),()=>Y.disconnect()},[le,k]);const ke=typeof le=="number"?le:Ge,me=l.useCallback(o=>i||(U?s(o):!1),[U,s,i]),wt=D.twMerge($.container,c&&$.containerPending,w),Et=l.useMemo(()=>({...Ur,...j??{},...typeof le=="number"?{height:le,minHeight:le}:{}}),[j,le]),Ze=l.useCallback((o,g)=>{const O=[o.absolutePath,...cr(o)],Y=g||f;if(O.every(he=>me(he)))return n(O);if(O.every(he=>!me(he))||Y==="recursive")return r(O);if(Y==="toggle")return n(O);console.warn(`[DirectoryTree] Unknown double click action: ${Y}. No action taken.`)},[me,r,n,f]),St=k?!1:te,{flatItems:be,lineItems:Qe,maxIndent:kt}=l.useMemo(()=>Jr(e,me,C,St,a),[e,me,C,St,a]),K=l.useMemo(()=>be.map((o,g)=>{const O=typeof H=="function"?H(o.entry,g):H;return{...o,rowHeight:Number.isFinite(O)&&O>0?O:ze}}),[be,H]),pe=l.useMemo(()=>K.map(o=>o.rowHeight),[K]),ge=l.useMemo(()=>{const o=new Array(pe.length+1);o[0]=0;for(let g=0;g<pe.length;g++)o[g+1]=o[g]+pe[g];return o},[pe]),Rt=l.useCallback(o=>K[o]?.rowHeight??ze,[K]),dr=l.useCallback(o=>K[o]?.entry.absolutePath??o,[K]),jt=ur??dr,It=l.useRef(be);It.current=be;const Ct=l.useRef(me);Ct.current=me;const et=l.useRef(t);et.current=t;const[Nt,Tt]=l.useState(0),tt=l.useRef(new Map),rt=l.useRef(null),_t=l.useCallback((o,g)=>{g?(tt.current.set(o,g),rt.current===o&&(rt.current=null,g.focus())):tt.current.delete(o)},[]),xe=l.useCallback(o=>{Tt(o);const g=tt.current.get(o);if(g){g.focus();return}rt.current=o,Q.current?.scrollToIndex(o)},[]);l.useEffect(()=>{Tt(o=>be.length===0?0:Math.min(o,be.length-1))},[be.length]);const At=l.useCallback((o,g)=>{const O=It.current,Y=O.length-1;if(Y<0)return;const G=O[g],X=G?.entry.children!==void 0,he=X&&Ct.current(G.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),xe(Math.min(g+1,Y));break;case"ArrowUp":o.preventDefault(),xe(Math.max(g-1,0));break;case"Home":o.preventDefault(),xe(0);break;case"End":o.preventDefault(),xe(Y);break;case"ArrowRight":o.preventDefault(),X&&!he?et.current(G.entry.absolutePath):X&&g<Y&&xe(g+1);break;case"ArrowLeft":{if(o.preventDefault(),X&&he){et.current(G.entry.absolutePath);break}const yr=G?.depth??0;for(let Be=g-1;Be>=0;Be--)if(O[Be].depth<yr){xe(Be);break}break}}},[xe]),$e=l.useMemo(()=>!C||Qe.length===0?{segmentsByItem:[],glyphsByItem:[]}:Zr(Qe,pe,ge,Ve,C,_??zt),[Qe,pe,ge,C,_]),He=l.useMemo(()=>!C||e.length===0?0:(kt+2)*Ve,[e.length,kt,C]),{renderStart:Mt,renderEnd:Lt,lookaheadEnd:Pt}=l.useMemo(()=>qr(K.length,ke,Ee,Pe,Fe,ge),[K.length,ke,Ee,Pe,Fe,ge]),nt=l.useMemo(()=>!C||He<=0||ke<=0||$e.segmentsByItem.length===0?null:u.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:u.jsx("div",{className:"absolute top-0 left-0",style:{width:He,height:ke},children:u.jsx(ir,{segmentsByItem:$e.segmentsByItem,glyphsByItem:$e.glyphsByItem,itemHeight:pe[0]??ze,width:He,viewportHeight:ke,scrollPosition:Fe,color:S,expandGlyphColor:S,expandGlyphSize:_??zt,renderStartIndex:Mt,renderEndIndex:Lt,lookaheadEndIndex:Pt})})}),[He,ke,Mt,Lt,Pt,Fe,$e,S,C,_,pe]),Ot=l.useCallback(o=>K[o],[K]),Dt=l.useRef(null);l.useLayoutEffect(()=>{const o=Dt.current;if(Dt.current={items:K,offsets:ge},!pt||!o||o.items===K)return;const g=Q.current,O=g?.getScrollPosition(),Y=typeof O=="number"&&O>=0?O:qe.current,G=$r(o.items,o.offsets,Y);if(!G)return;const X=Hr(G,K,ge);if(X===null||Math.abs(X-Y)<1)return;const he=g?g.scrollTo(X):X;qe.current=he,gt(he)},[K,ge,pt]);const ye=P?.columns,Re=P?.scrollBarWidth??Xe?.width??sr,ee=l.useMemo(()=>ye?Lr({measuredWidth:Le,columns:ye,scrollBarWidth:Re}):null,[ye,Le,Re]),We=l.useMemo(()=>ye?Mr(ye):"",[ye]),fr=l.useMemo(()=>P?.showFooter&&ye?Pr(e):[],[P?.showFooter,ye,e]),je=ee?.maxHScroll??0;l.useEffect(()=>{Ne(o=>st(o,je))},[je]);const Ft=l.useCallback(o=>Ne(g=>st(g+o,je)),[je]),$t=l.useMemo(()=>({iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J}),[W,I,E,p,C,_,J]),Ht=l.useMemo(()=>u.jsx(ue.VirtualScroll,{ref:Q,itemCount:K.length,getItem:Ot,getItemHeight:Rt,getItemKey:jt,testId:yt,contentProps:bt,locale:A,labels:ce,viewportSize:typeof le=="number"?le:void 0,overscanCount:Ee,onScroll:xt,onRangeChange:vt,className:Oe,onWheelHorizontal:k?Ft:void 0,background:u.jsxs(u.Fragment,{children:[k&&ee?u.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:ee.nameWidth},"aria-hidden":"true",children:nt}):nt,De]}),initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,onItemFocus:mt,callbackThrottleMs:dt,contentInsets:ft,scrollBarOptions:Xe,behaviorOptions:ht,children:(o,g)=>o?k&&P&&ee?u.jsx(tr,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!h?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:me,columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},visual:$t},o.entry.absolutePath):u.jsx(ct,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!h?.has(o.entry.absolutePath),flatIndex:g,isActive:g===Nt,registerRowRef:_t,onNavigationKeyDown:At,rowHeight:o.rowHeight,entryKindDirectory:L,entryKindFile:ae,isDirOpen:me,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},visual:{iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}},o.entry.absolutePath):null}),[K.length,Ot,Rt,jt,yt,bt,A,ce,L,ae,Nt,_t,At,le,Ee,xt,vt,Oe,k,Ft,ee,nt,De,_e,Se,ut,mt,dt,ft,Xe,ht,P,We,me,R,x,d,h,v,t,Ze,$t,W,I,E,p,C,_,J,B,re,ne,N,z,M,V,de]);if(!(P&&ee))return u.jsx("div",{ref:Z,className:wt,style:Et,role:"tree","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,children:Ht});const mr=P.showHeader??!0,hr=P.showFooter??!1,pr={...Et,"--dt-hscroll":`${Ce}px`};return u.jsxs("div",{ref:Z,className:D.twMerge(wt,"dt-grid"),style:pr,role:"treegrid","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":K.length+(P.showHeader??!0?1:0),children:[mr&&u.jsx("div",{role:"rowgroup",children:u.jsx(Tr,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,className:P.headerClassName})}),u.jsx("div",{ref:we,className:"dt-grid-body",children:Ht}),je>0&&u.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ee.nameWidth},"aria-hidden":"true"}),u.jsx(ue.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:Ce,scrollBarWidth:Re,locale:A,labels:ce,onScroll:o=>{const g=typeof o=="function"?o(Ce):o,O=st(g,je);return Ne(O),O}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Re},"aria-hidden":"true"})]}),hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(_r,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,allEntries:fr,className:P.footerClassName})})]})},en=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,r]=l.useTransition(),[n,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const y=JSON.parse(m);return new Set(y)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),i=l.useCallback(m=>{r(()=>{c(y=>{const S=new Set(y);return m(S),S})})},[]),f=l.useCallback((m,y)=>{i(S=>{for(const C of m)y(S,C)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(n)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[n,t]);const R=l.useCallback(m=>{f([m],(y,S)=>{y.has(S)?y.delete(S):y.add(S)})},[f]),x=l.useCallback(m=>{f([m],(y,S)=>{y.add(S)})},[f]),d=l.useCallback(m=>{f([m],(y,S)=>{y.delete(S)})},[f]),h=l.useCallback(m=>{f(m,(y,S)=>{y.delete(S)})},[f]),v=l.useCallback(m=>{f(m,(y,S)=>{y.add(S)})},[f]),w=l.useCallback(()=>{i(m=>{m.clear()})},[i]),j=l.useCallback(m=>n.has(m),[n]);return{expanded:n,toggle:R,expand:x,collapse:d,collapseMultiple:h,expandMultiple:v,collapseAll:w,isExpanded:j,isPending:s}};exports.DIRECTORY_TREE_LABEL_CATALOGS=or;exports.DIRECTORY_TREE_LABEL_KEYS=lt;exports.DirectoryTree=Qr;exports.directoryTreeClasses=$;exports.resolveDirectoryTreeLabels=lr;exports.useDirectoryTreeState=en;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { DirectoryTree, directoryTreeClasses } from "./DirectoryTree.tsx";
|
|
2
|
+
export { DIRECTORY_TREE_LABEL_CATALOGS, DIRECTORY_TREE_LABEL_KEYS, type DirectoryTreeLabelOverrides, type DirectoryTreeLabels, type DirectoryTreeLocale, resolveDirectoryTreeLabels } from "./labels.ts";
|
|
2
3
|
export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
|
|
3
4
|
export { useDirectoryTreeState } from "./useDirectoryTreeState.ts";
|