import { __assign } from '../../node_modules/tslib/tslib.es6.js';
import React from 'react';
import { ListItem, Button } from '@chakra-ui/react';
import Checkbox from '../checkbox/index.js';
import { SearchableListItemLabel } from './SearchableListItemLabel.js';

var isCheckboxType = function (listItem) {
    return !!listItem.isCheckbox;
};
var SearchableListItem = function (props) {
    var isCheckbox = isCheckboxType(props);
    var label = props.label, value = props.value, facet = props.facet, isSelected = props.isSelected, _a = props.showChevron, showChevron = _a === void 0 ? true : _a, _b = props.highlightIndices, highlightIndices = _b === void 0 ? [] : _b, children = props.children;
    var labelProps = {
        label: label,
        isSelected: isSelected,
        showChevron: showChevron,
        highlightIndices: highlightIndices,
        isCheckbox: isCheckbox,
        facet: facet,
    };
    var commonProps = {
        value: value,
        paddingY: 'sm',
        name: "searchable-list-item-".concat(value),
        'aria-current': isSelected,
    };
    var checkboxProps = __assign(__assign({}, commonProps), { label: React.createElement(SearchableListItemLabel, __assign({}, labelProps)), isChecked: isSelected, isIndeterminate: isCheckbox ? !!props.isIndeterminate : false, fullWidth: true, variant: 'alignTop', onChange: isCheckbox ? props.onClick : undefined });
    var radioButtonProps = __assign(__assign({}, commonProps), { onClick: !isCheckbox ? props.onClick : undefined, onChange: undefined, width: 'full', display: 'flex', paddingX: 'none' });
    return (React.createElement(ListItem, { css: { breakInside: 'avoid' } },
        isCheckbox ? (React.createElement(Checkbox, __assign({}, checkboxProps))) : (React.createElement(Button, __assign({}, radioButtonProps),
            React.createElement(SearchableListItemLabel, __assign({}, labelProps)))),
        children));
};

export { SearchableListItem };
//# sourceMappingURL=SearchableListItem.js.map
