import { r as registerInstance, c as createEvent, h } from './index-BIwHMk6j.js';

const InfoTileAdminConfig = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.change = createEvent(this, "change");
        this.getOptionValue = (option) => option.value;
        this.getAffixValue = (option) => {
            if (!option.value) {
                return;
            }
            return [option.value];
        };
        this.handleChangeOptions = (property, getValue = (value) => value) => (event) => {
            event.stopPropagation();
            this.change.emit(Object.assign(Object.assign({}, this.value), { options: Object.assign(Object.assign({ maximumFractionDigits: 0 }, this.value.options), { [property]: getValue(event.detail) || undefined }) }));
        };
        this.handleChangeAffix = (property) => (event) => {
            event.stopPropagation();
            this.change.emit(Object.assign(Object.assign({}, this.value), { [property]: this.getAffixValue(event.detail) }));
        };
    }
    render() {
        return [
            this.renderNotation(),
            this.renderCurrency(),
            this.renderCurrencyDisplay(),
            this.renderAffix('prefix'),
            this.renderAffix('suffix'),
        ];
    }
    renderCurrency() {
        var _a;
        return (h("limebb-currency-picker", { platform: this.platform, context: this.context, label: "Currency", value: (_a = this.value.options) === null || _a === void 0 ? void 0 : _a.currency, onChange: this.handleChangeOptions('currency') }));
    }
    renderCurrencyDisplay() {
        const options = [
            {
                text: 'ISO currency code',
                value: 'code',
            },
            {
                text: 'Localized currency symbol',
                value: 'symbol',
            },
            {
                text: 'Localized currency name',
                value: 'name',
            },
        ];
        const value = options.find((o) => { var _a; return o.value === ((_a = this.value.options) === null || _a === void 0 ? void 0 : _a.currencyDisplay); });
        return (h("limel-select", { label: "Currency display", options: options, value: value, onChange: this.handleChangeOptions('currencyDisplay', this.getOptionValue) }));
    }
    renderNotation() {
        const options = [
            {
                text: 'Standard',
                value: 'standard',
            },
            {
                text: 'Compact',
                value: 'compact',
            },
        ];
        const value = options.find((o) => { var _a; return o.value === ((_a = this.value.options) === null || _a === void 0 ? void 0 : _a.notation); });
        return (h("limel-select", { label: "Notation", helperText: "The formatting that should be displayed for the number", options: options, value: value, onChange: this.handleChangeOptions('notation', this.getOptionValue) }));
    }
    renderAffix(affix) {
        const options = [
            {
                text: '',
                value: '',
            },
            {
                text: 'Compact notation',
                value: 'compact',
            },
            {
                text: 'Currency',
                value: 'currency',
            },
        ];
        const value = options.find((o) => { var _a; return o.value && ((_a = this.value[affix]) === null || _a === void 0 ? void 0 : _a.includes(o.value)); });
        return (h("limel-select", { label: affix.charAt(0).toUpperCase() + affix.slice(1), options: options, value: value, onChange: this.handleChangeAffix(affix) }));
    }
};

export { InfoTileAdminConfig as limebb_info_tile_currency_format };
