import { __decorate } from "tslib";
import { DesignSystem } from '@ni/fast-foundation';
import { attr } from '@ni/fast-element';
import { TableColumn } from '../base';
import { styles } from '../base/styles';
import { template } from '../base/template';
import { TableColumnSortOperation } from '../base/types';
import { mixinFractionalWidthColumnAPI } from '../mixins/fractional-width-column';
import { mixinGroupableColumnAPI } from '../mixins/groupable-column';
import { mixinColumnWithPlaceholderAPI } from '../mixins/placeholder';
import { tableColumnAnchorCellViewTag } from './cell-view';
import { tableColumnTextGroupHeaderViewTag } from '../text/group-header-view';
import { mixinSortableColumnAPI } from '../mixins/sortable-column';
import { mixinCustomSortOrderColumnAPI } from '../mixins/custom-sort-order';
import { TableColumnAnchorValidator } from './models/table-column-anchor-validator';
/**
 * A table column for displaying links.
 */
export class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI(mixinCustomSortOrderColumnAPI((TableColumn)))))) {
    constructor() {
        super(...arguments);
        this.underlineHidden = false;
        this.defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;
    }
    placeholderChanged() {
        this.updateColumnConfig();
    }
    handleSortConfigurationChange() {
        this.updateColumnInternalsSortConfiguration();
    }
    getColumnInternalsOptions() {
        return {
            cellRecordFieldNames: ['label', 'href'],
            cellViewTag: tableColumnAnchorCellViewTag,
            groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,
            delegatedEvents: ['click'],
            sortOperation: this.getResolvedSortOperation(this.defaultSortOperation),
            validator: new TableColumnAnchorValidator()
        };
    }
    labelFieldNameChanged() {
        this.columnInternals.dataRecordFieldNames = [
            this.labelFieldName,
            this.hrefFieldName
        ];
        this.updateColumnInternalsSortConfiguration();
    }
    hrefFieldNameChanged() {
        this.columnInternals.dataRecordFieldNames = [
            this.labelFieldName,
            this.hrefFieldName
        ];
    }
    appearanceChanged() {
        this.updateColumnConfig();
    }
    underlineHiddenChanged() {
        this.updateColumnConfig();
    }
    hreflangChanged() {
        this.updateColumnConfig();
    }
    pingChanged() {
        this.updateColumnConfig();
    }
    referrerpolicyChanged() {
        this.updateColumnConfig();
    }
    relChanged() {
        this.updateColumnConfig();
    }
    targetChanged() {
        this.updateColumnConfig();
    }
    typeChanged() {
        this.updateColumnConfig();
    }
    downloadChanged() {
        this.updateColumnConfig();
    }
    updateColumnConfig() {
        this.columnInternals.columnConfig = {
            appearance: this.appearance,
            underlineHidden: this.underlineHidden,
            hreflang: this.hreflang,
            ping: this.ping,
            referrerpolicy: this.referrerpolicy,
            rel: this.rel,
            target: this.target,
            type: this.type,
            download: this.download,
            placeholder: this.placeholder
        };
    }
    updateColumnInternalsSortConfiguration() {
        this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.labelFieldName);
        this.columnInternals.sortOperation = this.getResolvedSortOperation(this.defaultSortOperation);
    }
}
__decorate([
    attr({ attribute: 'label-field-name' })
], TableColumnAnchor.prototype, "labelFieldName", void 0);
__decorate([
    attr({ attribute: 'href-field-name' })
], TableColumnAnchor.prototype, "hrefFieldName", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "appearance", void 0);
__decorate([
    attr({ attribute: 'underline-hidden', mode: 'boolean' })
], TableColumnAnchor.prototype, "underlineHidden", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "hreflang", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "ping", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "referrerpolicy", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "rel", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "target", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "type", void 0);
__decorate([
    attr
], TableColumnAnchor.prototype, "download", void 0);
const nimbleTableColumnAnchor = TableColumnAnchor.compose({
    baseName: 'table-column-anchor',
    template,
    styles
});
DesignSystem.getOrCreate()
    .withPrefix('nimble')
    .register(nimbleTableColumnAnchor());
export const tableColumnAnchorTag = 'nimble-table-column-anchor';
//# sourceMappingURL=index.js.map