// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Themeable } from '../../../Behaviors/Themeable';
import { RendererServiceLocator } from '../../../../Dom/Renderer';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { gridItemElementTemplate } from './GridItemElementTemplate';
import { gridItemElementJoyStyle } from './Themes/GridItemElement.Joy';
import { gridItemElementRetroStyle } from './Themes/GridItemElement.Retro';
import { gridItemElementCosmopolitanStyle } from './Themes/GridItemElement.Cosmopolitan';
// #endregion
/**
 * Grid Item - An element within a grid layout, organized in rows and columns.
 *
 * @element mosaik-grid-item
 *
 * @slot - The default slot.
 *
 * @public
 */
let GridItemElement = class GridItemElement extends Themeable(CustomElement) {
    // #region Fields
    _column;
    _columnSpan;
    _row;
    _rowSpan;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `GridItemElement` class.
     *
     * @public
     */
    constructor() {
        super();
        this._column = 0;
        this._columnSpan = 0;
        this._row = 0;
        this._rowSpan = 0;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     *
     * @public
     * @static
     * @readonly
    */
    static get is() {
        return 'mosaik-grid-item';
    }
    /**
     * Gets or sets the `column` property.
     *
     * @public
     */
    get column() {
        return this._column;
    }
    set column(value) {
        this._column = value;
    }
    /**
     * Gets or sets the `columnSpan` property.
     *
     * @public
     */
    get columnSpan() {
        return this._columnSpan;
    }
    set columnSpan(value) {
        this._columnSpan = value;
    }
    /**
     * Gets or sets the `row` property.
     *
     * @public
     */
    get row() {
        return this._row;
    }
    set row(value) {
        this._row = value;
    }
    /**
     * Gets or sets the `rowSpan` property.
     *
     * @public
     */
    get rowSpan() {
        return this._rowSpan;
    }
    set rowSpan(value) {
        this._rowSpan = value;
    }
    // #endregion
    /**
     * @public
     */
    connectedCallback() {
        super.connectedCallback();
        this.setItemStyle();
    }
    /**
     * @protected
     */
    onRowPropertyChanged() {
        this.setItemStyle();
    }
    /**
     * @protected
     */
    onColumnPropertyChanged() {
        this.setItemStyle();
    }
    /**
     * @protected
     */
    onRowSpanPropertyChanged() {
        this.setItemStyle();
    }
    /**
     * @protected
     */
    onColumnSpanPropertyChanged() {
        this.setItemStyle();
    }
    /**
     * @private
     */
    setItemStyle() {
        const row = this._row ? this._row : 'auto';
        const column = this._column ? this._column : 'auto';
        const rowSpan = this._rowSpan ? `span ${this._rowSpan}` : 'auto';
        const columnSpan = this._columnSpan ? `span ${this._columnSpan}` : 'auto';
        const gridAreaStyle = `${row} / ${column} / ${rowSpan} / ${columnSpan}`;
        RendererServiceLocator.current.setStyle(this, 'grid-area', gridAreaStyle);
    }
};
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], GridItemElement.prototype, "column", null);
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], GridItemElement.prototype, "columnSpan", null);
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], GridItemElement.prototype, "row", null);
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], GridItemElement.prototype, "rowSpan", null);
__decorate([
    Watch('row'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], GridItemElement.prototype, "onRowPropertyChanged", null);
__decorate([
    Watch('column'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], GridItemElement.prototype, "onColumnPropertyChanged", null);
__decorate([
    Watch('rowSpan'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], GridItemElement.prototype, "onRowSpanPropertyChanged", null);
__decorate([
    Watch('columnSpan'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], GridItemElement.prototype, "onColumnSpanPropertyChanged", null);
GridItemElement = __decorate([
    Component({
        selector: 'mosaik-grid-item',
        themes: {
            joy: gridItemElementJoyStyle,
            retro: gridItemElementRetroStyle,
            cosmopolitan: gridItemElementCosmopolitanStyle
        },
        template: gridItemElementTemplate
    }),
    __metadata("design:paramtypes", [])
], GridItemElement);
export { GridItemElement };
//# sourceMappingURL=GridItemElement.js.map