"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 Tag_1 = require("../../../components/Tag/Tag");
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)));
        }, toIdentifier: (tag) => api.internalApi.getLabelForTag(tag), toLabel: (tag) => api.internalApi.getLabelForTag(tag) }));
};
exports.TagValueSelector = TagValueSelector;
const TagValueOptionsTags = (props) => {
    const { tags = [] } = props;
    const { api } = (0, AdaptableContext_1.useAdaptable)();
    return React.createElement(Tag_1.TagList, { tags: tags.map((tag) => api.internalApi.getLabelForTag(tag)) });
};
exports.TagValueOptionsTags = TagValueOptionsTags;
