import { __decorate } from "tslib";
import { uniqueId } from '@ni/fast-web-utilities';
import { ViewTemplate, observable } from '@ni/fast-element';
import { TableColumnAlignment, TableColumnSortDirection } from '../../../table/types';
import { TableColumnSortOperation, defaultFractionalWidth, defaultMinPixelWidth } from '../types';
import { createGroupHeaderViewTemplate } from '../group-header-view/template';
import { createCellViewTemplate } from '../cell-view/template';
/**
 * Internal column state configured by plugin authors
 * @internal
 */
export class ColumnInternals {
    constructor(options) {
        /**
         * A unique id used internally in the table to identify specific column instances
         */
        this.uniqueId = uniqueId('table-column-slot');
        /**
         * The operation to use when sorting the table by this column.
         */
        this.sortOperation = TableColumnSortOperation.basic;
        /**
         * The names of the fields from the row's record that correlate to the data that will be in TCellRecord.
         * This array is parallel with the field names specified by `cellRecordFieldNames`.
         */
        this.dataRecordFieldNames = [];
        /**
         * Whether or not this column can be used to group rows by
         */
        this.groupingDisabled = true;
        /**
         * Used by column plugins to size a column proportionally to the available
         * width of a row. Sets currentFractionalWidth when changed.
         */
        this.fractionalWidth = defaultFractionalWidth;
        /**
         * The minimum size in pixels according to the design doc
         */
        this.minPixelWidth = defaultMinPixelWidth;
        /**
         * Whether or not resizing the column has been disabled.
         */
        this.resizingDisabled = false;
        /**
         * Whether or not the grouping and sorting indicators should be hidden in the column header
         * when the column is grouped or sorted.
         */
        this.hideHeaderIndicators = false;
        /**
         * How to align the header content.
         */
        this.headerAlignment = TableColumnAlignment.left;
        /**
         * @internal Do not write to this value directly. It is used by the Table in order to store
         * the resolved value of the fractionalWidth after updates programmatic or interactive updates.
         */
        this.currentFractionalWidth = defaultFractionalWidth;
        /**
         * Whether or not this column can be sorted
         */
        this.sortingDisabled = true;
        /**
         * @internal Do not write to this value directly. It is used by the Table in order to store
         * the resolved value of the sortDirection after programmatic or interactive updates.
         */
        this.currentSortDirection = TableColumnSortDirection.none;
        this.cellRecordFieldNames = options.cellRecordFieldNames;
        this.cellViewTemplate = createCellViewTemplate(options.cellViewTag);
        if (options.groupHeaderViewTag) {
            this.groupHeaderViewTemplate = createGroupHeaderViewTemplate(options.groupHeaderViewTag);
        }
        this.delegatedEvents = options.delegatedEvents;
        this.slotNames = options.slotNames ?? [];
        this.sortOperation = options.sortOperation ?? TableColumnSortOperation.basic;
        this.validator = options.validator;
    }
    fractionalWidthChanged() {
        this.currentFractionalWidth = this.fractionalWidth;
    }
    pixelWidthChanged() {
        this.currentPixelWidth = this.pixelWidth;
    }
}
__decorate([
    observable
], ColumnInternals.prototype, "columnConfig", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "operandDataRecordFieldName", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "sortOperation", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "dataRecordFieldNames", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "groupingDisabled", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "groupIndex", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "pixelWidth", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "fractionalWidth", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "minPixelWidth", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "resizingDisabled", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "hideHeaderIndicators", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "headerAlignment", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "currentFractionalWidth", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "currentPixelWidth", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "sortingDisabled", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "currentSortIndex", void 0);
__decorate([
    observable
], ColumnInternals.prototype, "currentSortDirection", void 0);
export function isColumnInternalsProperty(changedProperty, ...args) {
    for (const arg of args) {
        if (changedProperty === arg) {
            return true;
        }
    }
    return false;
}
//# sourceMappingURL=column-internals.js.map