/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-9f08182
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { MoreIcon, TrashIcon } from '../../../icons/index.js';
import { ItemAction } from '../../actions/ItemAction/index.js';
import { FilterPicker } from '../../fields/FilterPicker/FilterPicker.js';
// =============================================================================
// Component
// =============================================================================
/**
 * Tab picker component that displays a dropdown menu of all tabs.
 *
 * Used in the Tabs suffix area when tabs overflow to provide quick navigation
 * to any tab without scrolling.
 */
export function TabPicker({ tabs, selectedKey, onSelect, onDelete, size, type = 'default', }) {
    const isDeletable = !!onDelete;
    // Map TabSize to FilterPicker size (xsmall -> small)
    const pickerSize = size === 'xsmall' ? 'small' : size;
    // Only show border divider for file type
    const showBorderDivider = type === 'file';
    return (_jsx(FilterPicker, { selectionMode: "single", selectedKey: selectedKey, renderSummary: false, icon: _jsx(MoreIcon, {}), rightIcon: null, shape: "sharp", type: "neutral", size: pickerSize, 
        // Apply border to wrapper (FilterPickerWrapper) so :first-child evaluates
        // relative to Suffix container, not the internal DialogTrigger
        styles: {
            border: showBorderDivider
                ? {
                    '': 0,
                    '!:first-child': 'left',
                }
                : 0,
        }, triggerStyles: { border: 0 }, "aria-label": "Select tab", onSelectionChange: (key) => {
            if (key != null) {
                onSelect(key);
            }
        }, children: tabs.map((tab) => (_jsx(FilterPicker.Item, { textValue: typeof tab.title === 'string' ? tab.title : String(tab.key), showActionsOnHover: isDeletable, actions: isDeletable ? (_jsx(ItemAction, { icon: _jsx(TrashIcon, {}), theme: "danger", "aria-label": "Delete tab", onPress: () => {
                    onDelete(tab.key);
                } })) : undefined, children: tab.title }, tab.key))) }));
}

        