"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayoutRadioSelector = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Radio_1 = tslib_1.__importDefault(require("../../components/Radio"));
const AdaptableContext_1 = require("../AdaptableContext");
const LayoutRadioSelector = ({ data }) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const currentLayout = adaptable.api.layoutApi.getCurrentLayout();
    const layouts = adaptable.api.layoutApi.getLayouts();
    const isDisabled = layouts?.length === 1;
    const isSelected = currentLayout.Name === data.Name;
    const handleToggle = React.useCallback(() => {
        adaptable.api.layoutApi.setLayout(data.Name);
    }, [isSelected]);
    return (React.createElement(Radio_1.default, { "data-name": "layout-select-button", "data-value": data.Name, disabled: isDisabled, checked: isSelected, onClick: handleToggle }));
};
exports.LayoutRadioSelector = LayoutRadioSelector;
