import { __decorate } from "tslib";
import { DesignSystem } from '@ni/fast-foundation';
import { ViewTemplate, observable } from '@ni/fast-element';
import { styles } from './styles';
import { template } from './template';
import { IconSeverity } from '../../../icon-base/types';
import { MappingIconConfig } from '../../enum-base/models/mapping-icon-config';
import { MappingSpinnerConfig } from '../../enum-base/models/mapping-spinner-config';
import { MappingTextConfig } from '../../enum-base/models/mapping-text-config';
import { MappingEmptyConfig } from '../../enum-base/models/mapping-empty-config';
import { TableGroupHeaderView } from '../../base/group-header-view';
/**
 * The group header view for the mapping column
 */
export class TableColumnMappingGroupHeaderView extends TableGroupHeaderView {
    constructor() {
        super(...arguments);
        /** @internal */
        this.hasOverflow = false;
        this.text = '';
        this.textHidden = false;
    }
    columnConfigChanged() {
        this.updateState();
    }
    groupHeaderValueChanged() {
        this.updateState();
    }
    updateState() {
        this.resetState();
        if (!this.columnConfig) {
            return;
        }
        const value = this.groupHeaderValue;
        const mappingConfig = this.columnConfig.mappingConfigs.get(value);
        if (mappingConfig instanceof MappingIconConfig) {
            this.severity = mappingConfig.severity;
            this.text = mappingConfig.text ?? '';
            this.visualizationTemplate = mappingConfig.iconTemplate;
        }
        else if (mappingConfig instanceof MappingSpinnerConfig) {
            this.text = mappingConfig.text ?? '';
            this.visualizationTemplate = mappingConfig.spinnerTemplate;
        }
        else if (mappingConfig instanceof MappingTextConfig) {
            this.text = mappingConfig.text ?? '';
        }
        else if (mappingConfig instanceof MappingEmptyConfig) {
            this.text = mappingConfig.text ?? '';
        }
    }
    resetState() {
        this.text = '';
        this.visualizationTemplate = undefined;
        this.severity = IconSeverity.default;
    }
}
__decorate([
    observable
], TableColumnMappingGroupHeaderView.prototype, "hasOverflow", void 0);
__decorate([
    observable
], TableColumnMappingGroupHeaderView.prototype, "text", void 0);
__decorate([
    observable
], TableColumnMappingGroupHeaderView.prototype, "severity", void 0);
__decorate([
    observable
], TableColumnMappingGroupHeaderView.prototype, "visualizationTemplate", void 0);
const mappingGroupHeaderView = TableColumnMappingGroupHeaderView.compose({
    baseName: 'table-column-mapping-group-header-view',
    template,
    styles
});
DesignSystem.getOrCreate()
    .withPrefix('nimble')
    .register(mappingGroupHeaderView());
export const tableColumnMappingGroupHeaderViewTag = 'nimble-table-column-mapping-group-header-view';
//# sourceMappingURL=index.js.map