"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagValueOptionsTags = exports.TagValueSelector = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const ValueSelector_1 = require("../ValueSelector");
const AdaptableContext_1 = require("../../AdaptableContext");
const TagValueSelector = (props) => {
    const { api } = (0, AdaptableContext_1.useAdaptable)();
    const getDefaultTags = () => {
        return api.internalApi.getAvailableTags() ?? [];
    };
    const { availableTags = getDefaultTags(), selectedTags = [], onChange, singleSelect } = props;
    return (React.createElement(ValueSelector_1.ValueSelector, { options: availableTags, value: selectedTags.map((tag) => api.internalApi.getLabelForTag(tag)), singleSelect: singleSelect, allowReorder: false, onChange: (selectedTagsIds, selectedTagsMap) => {
            onChange(selectedTagsIds.map((id) => selectedTagsMap.get(id)));
        }, selectionBoxPosition: 'top', toIdentifier: (tag) => api.internalApi.getLabelForTag(tag), toLabel: (tag) => api.internalApi.getLabelForTag(tag), noSelectionLabel: singleSelect ? 'Select a tag' : 'You have not selected any tags.', xSelectedLabel: singleSelect ? () => 'Selected tag:' : () => 'Selected tags:' }));
};
exports.TagValueSelector = TagValueSelector;
const TagValueOptionsTags = (props) => {
    const { tags = [] } = props;
    const { api } = (0, AdaptableContext_1.useAdaptable)();
    return (React.createElement(ValueSelector_1.ValueOptionsTags, { options: tags, value: tags.map((tag) => api.internalApi.getValueForTag(tag)), toIdentifier: (tag) => api.internalApi.getValueForTag(tag), toLabel: (tag) => api.internalApi.getLabelForTag(tag), allowWrap: true, readOnly: true }));
};
exports.TagValueOptionsTags = TagValueOptionsTags;
