import { CSSProperties, ReactNode } from 'react';

type TreeDensity = 'compact' | 'cozy' | 'comfortable';
type TreeAccentIntensity = 'subtle' | 'default' | 'strong';
type TreeRadius = 'none' | 'sm' | 'md';
/**
 * Cosmetic configuration. Every field is optional; missing values fall
 * back to the `cozy` preset (a comfortable VSCode-Explorer-like density).
 *
 * Customize the look without re-implementing slots.
 */
interface TreeAppearance {
    /** Built-in size preset. Default: `'cozy'`. */
    density?: TreeDensity;
    /** Override row height in px (wins over density). */
    rowHeight?: number;
    /** Override icon + chevron size in px (wins over density). */
    iconSize?: number;
    /** Lucide stroke width for icon + chevron. Default: 1.5. */
    iconStrokeWidth?: number;
    /** Override label font size in px (wins over density). */
    fontSize?: number;
    /** Pixels between chevron / icon / label. Default depends on density. */
    gap?: number;
    /** Pixels between nesting levels. Default: 16. */
    indent?: number;
    /** Hover / selected highlight intensity. Default: `'default'`. */
    accent?: TreeAccentIntensity;
    /** Row corner radius. Default: `'sm'`. */
    radius?: TreeRadius;
    /** Indent-guide line opacity (0..1). Default: 0.4. */
    indentGuideOpacity?: number;
    /**
     * Show a 2px primary-tinted bar on the left of the selected row.
     * Mimics the VSCode active-tab indicator. Default: `true`.
     */
    showActiveIndicator?: boolean;
}
interface ResolvedAppearance {
    density: TreeDensity;
    rowHeight: number;
    iconSize: number;
    iconStrokeWidth: number;
    fontSize: number;
    gap: number;
    indent: number;
    accent: TreeAccentIntensity;
    radius: TreeRadius;
    indentGuideOpacity: number;
    showActiveIndicator: boolean;
}
declare const DEFAULT_TREE_APPEARANCE: ResolvedAppearance;
/**
 * Merge a partial appearance with the default + density preset.
 *
 * Explicit numeric overrides (e.g. `rowHeight`) win over the density preset.
 */
declare function resolveAppearance(input?: TreeAppearance, 
/** Outer `indent` prop (kept on TreeRoot for back-compat). */
outerIndent?: number): ResolvedAppearance;
/**
 * Build the `style` object that exposes the resolved appearance to any
 * descendant via CSS variables. Set on `<TreeRoot>`'s outer div.
 */
declare function appearanceToStyle(a: ResolvedAppearance): CSSProperties;

type TreeItemId = string;
/** A single node in the consumer's tree data. Generic over your payload. */
interface TreeNode<T = unknown> {
    id: TreeItemId;
    data: T;
    /** Inline children. Omit (and provide a `loadChildren`) for async loading. */
    children?: TreeNode<T>[];
    /**
     * Set to `true` to mark a node as a folder even when its `children` array
     * is empty (e.g. an unloaded async folder). Default: derived from
     * `Array.isArray(children)`.
     */
    isFolder?: boolean;
    /** Disable interaction. */
    disabled?: boolean;
}
interface TreeLabels {
    loading: string;
    empty: string;
    error: string;
    searchPlaceholder: string;
    searchMatches: (count: number) => string;
    ariaLabel: string;
}
declare const DEFAULT_TREE_LABELS: TreeLabels;
type TreeSelectionMode = 'none' | 'single' | 'multiple';
/**
 * How a node becomes "activated" (i.e. opened) on pointer interaction.
 *
 * - `'single-click'` (default): single click activates a leaf immediately;
 *   double-click also activates. Folders always toggle on single click.
 * - `'double-click'`: single click only selects + focuses; double-click is
 *   required to activate. Mirrors classic file-manager behaviour.
 * - `'single-click-preview'`: VSCode Explorer / Cursor behaviour. Single
 *   click activates with `{ preview: true }` (consumer renders a preview
 *   tab); double-click activates with `{ preview: false }` (pinned tab).
 *
 * Folders ignore this setting — they always toggle on single click and
 * never call `onActivate`.
 */
type TreeActivationMode = 'single-click' | 'double-click' | 'single-click-preview';
interface TreeActivateOptions {
    /**
     * `true` when the activation came from a single click in
     * `'single-click-preview'` mode. `false` for double-click and for
     * non-preview modes. Consumers typically map this to a
     * preview-tab vs pinned-tab distinction.
     */
    preview: boolean;
}
/**
 * Async loader: called the first time a folder is expanded with no inline
 * `children`. Result is cached; concurrent expansions are de-duplicated.
 */
type TreeLoadChildren<T> = (node: TreeNode<T>) => Promise<TreeNode<T>[]>;
interface TreeRowRenderProps<T> {
    node: TreeNode<T>;
    level: number;
    isSelected: boolean;
    isExpanded: boolean;
    isFocused: boolean;
    isFolder: boolean;
    isLoading: boolean;
    isMatchingSearch: boolean;
}
type TreeRowSlot<T> = (props: TreeRowRenderProps<T>) => ReactNode;
type TreeContextMenuSlot<T> = (props: TreeRowRenderProps<T>, trigger: ReactNode) => ReactNode;
interface TreeRootProps<T> {
    /** Root nodes. Top-level items are rendered directly (no synthetic root). */
    data: TreeNode<T>[];
    /** Returns the human-readable name for a node (used by search/type-ahead). */
    getItemName: (node: TreeNode<T>) => string;
    /** Async loader for folders without inline `children`. */
    loadChildren?: TreeLoadChildren<T>;
    /** Selection behaviour. Default: `'single'`. */
    selectionMode?: TreeSelectionMode;
    /** Pointer activation behaviour. Default: `'single-click'`. */
    activationMode?: TreeActivationMode;
    /** Initially expanded ids. */
    initialExpandedIds?: TreeItemId[];
    /** Initially selected ids. */
    initialSelectedIds?: TreeItemId[];
    /** Pixels of indent per nesting level. Default: 16. (Shortcut for `appearance.indent`.) */
    indent?: number;
    /** Cosmetic configuration: density, sizes, accent intensity, radius. */
    appearance?: TreeAppearance;
    /** Triggered when selection changes. */
    onSelectionChange?: (selectedIds: TreeItemId[]) => void;
    /** Triggered when expanded set changes. */
    onExpansionChange?: (expandedIds: TreeItemId[]) => void;
    /**
     * Triggered when a leaf is activated (Enter / dblclick / click depending
     * on `activationMode`). Folders never call this — they toggle instead.
     */
    onActivate?: (node: TreeNode<T>, opts: TreeActivateOptions) => void;
    /**
     * Optional predicate. Nodes returning `false` (and their descendants) are
     * not rendered and not searchable. Use this to hide dot-files, system
     * entries, or anything else the consumer wants to filter out.
     */
    filterNode?: (node: TreeNode<T>) => boolean;
    /** Show built-in search input. Default: false. */
    enableSearch?: boolean;
    /** Type printable letters to jump to a matching name. Default: true. */
    enableTypeAhead?: boolean;
    /** Render vertical indent guides under expanded folders. Default: false. */
    showIndentGuides?: boolean;
    /** Custom row renderer. Falls back to the default <TreeRow />. */
    renderRow?: TreeRowSlot<T>;
    /** Replace default folder/file icon. */
    renderIcon?: TreeRowSlot<T>;
    /** Replace default label rendering. */
    renderLabel?: TreeRowSlot<T>;
    /** Right-side actions slot (per row). */
    renderActions?: TreeRowSlot<T>;
    /** Wrap each row in a context menu (right-click). Receives the row meta + trigger element. */
    renderContextMenu?: TreeContextMenuSlot<T>;
    /** Override built-in copy in your locale. */
    labels?: Partial<TreeLabels>;
    /** Persist expanded + (optional) selected ids in localStorage under this key. */
    persistKey?: string;
    /** Persist selection alongside expansion. Default: false. */
    persistSelection?: boolean;
    className?: string;
    style?: React.CSSProperties;
}
/** Internal flat-row representation used by the renderer + keyboard nav. */
interface FlatRow<T> {
    node: TreeNode<T>;
    level: number;
    parentId: TreeItemId | null;
    isFolder: boolean;
    isExpanded: boolean;
    isLoading: boolean;
    hasError: boolean;
    /** 1-based position among visible siblings (for `aria-posinset`). */
    posInSet: number;
    /** Count of visible siblings sharing this row's parent (for `aria-setsize`). */
    setSize: number;
}

export { DEFAULT_TREE_APPEARANCE as D, type FlatRow as F, type ResolvedAppearance as R, type TreeRootProps as T, type TreeItemId as a, type TreeNode as b, type TreeActivateOptions as c, type TreeLabels as d, type TreeSelectionMode as e, type TreeActivationMode as f, type TreeRowSlot as g, type TreeContextMenuSlot as h, appearanceToStyle as i, type TreeAppearance as j, type TreeDensity as k, type TreeAccentIntensity as l, type TreeRadius as m, DEFAULT_TREE_LABELS as n, type TreeRowRenderProps as o, type TreeLoadChildren as p, resolveAppearance as r };
